@jxsuite/studio 9.0.0 → 10.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-89fz3pfy.js → 2020-j56903f1.js} +3 -3
- package/dist/chunks/adapter-wc5zvg9a.js +4 -0
- package/dist/chunks/{add-new-flow-nmkqpjym.js → add-new-flow-snx1s4b0.js} +3 -3
- package/dist/chunks/{cf-account-picker-2e06qxey.js → cf-account-picker-xyqw0jex.js} +3 -3
- package/dist/chunks/cf-settings-hp1pjm0n.js +4 -0
- package/dist/chunks/components-nkwphrx3.js +4 -0
- package/dist/chunks/content-source-6a253wmk.js +4 -0
- package/dist/chunks/{convert-to-repeater-j9hfcj4f.js → convert-to-repeater-fhdwyg14.js} +3 -3
- package/dist/chunks/editor-wqrc68ca.js +4 -0
- package/dist/chunks/entry-commands-nef0wrmp.js +4 -0
- package/dist/chunks/{extension-sections-thfke054.js → extension-sections-8ez2rrk8.js} +2 -2
- package/dist/chunks/file-ops-y3w71k1n.js +4 -0
- package/dist/chunks/files-de90apn9.js +4 -0
- package/dist/chunks/format-host-zfjz4rzm.js +4 -0
- package/dist/chunks/fs-events-77c0mr0x.js +4 -0
- package/dist/chunks/grid-open-4n4fjfpf.js +4 -0
- package/dist/chunks/{grid-view-7d2nx83y.js → grid-view-ka55z38f.js} +4 -4
- package/dist/chunks/iframe-host-na2mywz4.js +4 -0
- package/dist/chunks/index-ewmgdb7c.js +4 -0
- package/dist/chunks/{index-jxmt7vh8.js → index-qb98xhse.js} +3 -3
- package/dist/chunks/{javascript-vmqp56ke.js → javascript-ces13wny.js} +2 -2
- package/dist/chunks/{jsonMode-n3wmpant.js → jsonMode-6md16d4v.js} +2 -2
- package/dist/chunks/jx-validate-b309c020.js +4 -0
- package/dist/chunks/layers-8rn8y6qv.js +4 -0
- package/dist/chunks/layers-panel-eyah7h9z.js +4 -0
- package/dist/chunks/media-library-gs3np47y.js +4 -0
- package/dist/chunks/media-picker-tt7dk4tb.js +4 -0
- package/dist/chunks/{monaco-binding-wfhmz89d.js → monaco-binding-p8j80s4w.js} +3 -3
- package/dist/chunks/monaco-buffer-wsf6cmnq.js +4 -0
- package/dist/chunks/{monaco-setup-fty7a8vg.js → monaco-setup-wasktzfg.js} +2 -2
- package/dist/chunks/notify-qwst108r.js +4 -0
- package/dist/chunks/platform-c16mqvmp.js +4 -0
- package/dist/chunks/publish-panel-d34bhvwj.js +4 -0
- package/dist/chunks/{publish-quick-12hh8926.js → publish-quick-vr695j26.js} +3 -3
- package/dist/chunks/publish-workspace-2yr60mt4.js +4 -0
- package/dist/chunks/quick-search-e6xsdv0d.js +4 -0
- package/dist/chunks/references-gsj6trdv.js +4 -0
- package/dist/chunks/right-panel-33jv1knc.js +4 -0
- package/dist/chunks/source-control-bj9bejjv.js +4 -0
- package/dist/chunks/{studio-9ndgd55w.js → studio-03mqh8ax.js} +4 -4
- package/dist/chunks/{studio-apapy17g.js → studio-06j4en5h.js} +2 -2
- package/dist/chunks/{studio-aghsg0ds.js → studio-0ydxv2mr.js} +6 -6
- package/dist/chunks/{studio-ekzbgnjp.js → studio-1e8dw2w2.js} +4 -4
- package/dist/chunks/{studio-0nefxhar.js → studio-2hsqbq7b.js} +5 -5
- package/dist/chunks/{studio-sm2f0sc6.js → studio-2j86y34y.js} +5 -5
- package/dist/chunks/{studio-1cfyd1ys.js → studio-2ks6ka4g.js} +3 -3
- package/dist/chunks/{studio-vtey9w98.js → studio-34jrz12k.js} +4 -4
- package/dist/chunks/{studio-e4rq6x0q.js → studio-35vrtpdq.js} +4 -4
- package/dist/chunks/{studio-a9k86nq6.js → studio-38g0jdz7.js} +4 -4
- package/dist/chunks/{studio-9gzvypw4.js → studio-396srjbk.js} +4 -4
- package/dist/chunks/{studio-4j35hgsw.js → studio-3c8pp7pb.js} +4 -4
- package/dist/chunks/{studio-z1p91z5a.js → studio-3v5cagy9.js} +4 -4
- package/dist/chunks/{studio-a6e5fzve.js → studio-3w35qvay.js} +4 -4
- package/dist/chunks/{studio-ry4789ng.js → studio-3zge48z4.js} +6 -6
- package/dist/chunks/{studio-9ra9e7m4.js → studio-45gyxpcq.js} +4 -4
- package/dist/chunks/{studio-tfmhnwyr.js → studio-4kzbrr5t.js} +3 -3
- package/dist/chunks/{studio-tyzgte21.js → studio-5tzgq6fx.js} +4 -4
- package/dist/chunks/{studio-nqexty8x.js → studio-5wzdy1jc.js} +6 -6
- package/dist/chunks/{studio-14hh60j8.js → studio-771k2n12.js} +4 -4
- package/dist/chunks/{studio-nm86874b.js → studio-7dzyz9n8.js} +98 -98
- package/dist/chunks/{studio-k5n4es74.js → studio-7xag4na8.js} +4 -4
- package/dist/chunks/studio-88bmt9rh.js +5 -0
- package/dist/chunks/{studio-kyw47pet.js → studio-9b7177jq.js} +4 -4
- package/dist/chunks/{studio-yjh9gddd.js → studio-9cxmp61c.js} +5 -5
- package/dist/chunks/{studio-qd0cycm4.js → studio-9dz76yqc.js} +5 -5
- package/dist/chunks/{studio-cg54vtet.js → studio-agyvzfm4.js} +4 -4
- package/dist/chunks/{studio-x2trkhk5.js → studio-c1pxszat.js} +4 -4
- package/dist/chunks/{studio-qs5fmhtj.js → studio-cpkamjdn.js} +7 -7
- package/dist/chunks/{studio-n4qq1n57.js → studio-d038kqbs.js} +4 -4
- package/dist/chunks/{studio-fj6jzgxw.js → studio-d83m0wyq.js} +4 -4
- package/dist/chunks/studio-dbxv7w4s.js +5 -0
- package/dist/chunks/{studio-7q6jdd4h.js → studio-de1s2x9v.js} +4 -4
- package/dist/chunks/{studio-h4jbgne2.js → studio-dx73md4n.js} +6 -6
- package/dist/chunks/{studio-nfwacw31.js → studio-ekgtrndg.js} +4 -4
- package/dist/chunks/{studio-79r8msnr.js → studio-epenqmvk.js} +3 -3
- package/dist/chunks/{studio-sc35ttdk.js → studio-et2q4s8n.js} +4 -4
- package/dist/chunks/{studio-g45r5vm8.js → studio-ewarnzm4.js} +2 -2
- package/dist/chunks/{studio-nfmpmkqb.js → studio-fy7jzj9j.js} +4 -4
- package/dist/chunks/{studio-kqh7fxn6.js → studio-gr36vnte.js} +4 -4
- package/dist/chunks/{studio-spza69tb.js → studio-gwrhcrss.js} +5 -5
- package/dist/chunks/{studio-8hf8qcm1.js → studio-h310mbqm.js} +4 -4
- package/dist/chunks/{studio-qevf5z9d.js → studio-h5tpz5ke.js} +4 -4
- package/dist/chunks/studio-h7weqf2q.js +5 -0
- package/dist/chunks/{studio-gk9yk8dj.js → studio-hcsba201.js} +6 -6
- package/dist/chunks/{studio-ws2r1d7e.js → studio-hwejq03c.js} +4 -4
- package/dist/chunks/{studio-9179bsm7.js → studio-hy4ye0dx.js} +6 -6
- package/dist/chunks/{studio-myb4mf0h.js → studio-jttyqrmh.js} +4 -4
- package/dist/chunks/{studio-k6hbx2fc.js → studio-jw0q5j6k.js} +4 -4
- package/dist/chunks/{studio-s4fq9jht.js → studio-k3a8rp3d.js} +4 -4
- package/dist/chunks/{studio-by8x0jvc.js → studio-k3bcy02e.js} +4 -4
- package/dist/chunks/{studio-3hpcawh8.js → studio-m48v13s3.js} +3 -3
- package/dist/chunks/{studio-4qg61g9j.js → studio-ndskgqef.js} +4 -4
- package/dist/chunks/studio-p1n2xjda.js +5 -0
- package/dist/chunks/{studio-ae7a69jc.js → studio-pgm83a2f.js} +5 -5
- package/dist/chunks/{studio-0rg30pvs.js → studio-pqqq6v85.js} +4 -4
- package/dist/chunks/{studio-gskkgfe3.js → studio-r17asgs0.js} +4 -4
- package/dist/chunks/{studio-8pne0rx4.js → studio-ry81j4q1.js} +4 -4
- package/dist/chunks/{studio-mkw17ngg.js → studio-rzg8hnkf.js} +4 -4
- package/dist/chunks/{studio-trcfer2b.js → studio-s0fg2wav.js} +4 -4
- package/dist/chunks/{studio-gczve8zf.js → studio-tj2s0tks.js} +3 -3
- package/dist/chunks/{studio-tn7v8gey.js → studio-v9ywz2se.js} +5 -5
- package/dist/chunks/{studio-nvfa137z.js → studio-vswcpzk7.js} +5 -5
- package/dist/chunks/{studio-ztppbam0.js → studio-vzgmyt0v.js} +4 -4
- package/dist/chunks/{studio-fg4fj9ec.js → studio-wxdcd42g.js} +5 -5
- package/dist/chunks/{studio-xzgp0cp7.js → studio-wxhy1yh7.js} +4 -4
- package/dist/chunks/{studio-4rgem12q.js → studio-x08a3m0a.js} +4 -4
- package/dist/chunks/{studio-t6dqnnft.js → studio-x3mjr5cc.js} +4 -4
- package/dist/chunks/{studio-9ff0vqff.js → studio-x97ay0v4.js} +4 -4
- package/dist/chunks/{studio-32d8wyxq.js → studio-xdpz9rpe.js} +29 -29
- package/dist/chunks/{studio-6k9djnxw.js → studio-xh683qzy.js} +4 -4
- package/dist/chunks/{studio-c88gq88j.js → studio-xkxetm65.js} +5 -5
- package/dist/chunks/{studio-jr30g4ae.js → studio-y26hx9re.js} +4 -4
- package/dist/chunks/{studio-hcy9zeac.js → studio-yg3djpnm.js} +4 -4
- package/dist/chunks/studio-yx8hzqja.js +5 -0
- package/dist/chunks/{studio-ht81xjkr.js → studio-zg16eeq1.js} +4 -4
- package/dist/chunks/{studio-6rbaedw2.js → studio-zgx7svjd.js} +6 -6
- package/dist/chunks/{studio-ywf9y1e2.js → studio-zkq3r91p.js} +4 -4
- package/dist/chunks/{tsMode-byje4a01.js → tsMode-h6tkz0ea.js} +2 -2
- package/dist/chunks/workspace-home-zkkrxq3r.js +4 -0
- package/dist/chunks/workspace-tdqqjqaa.js +4 -0
- package/dist/chunks/{ws-client-h09h6sqg.js → ws-client-e951my95.js} +3 -3
- package/dist/iframe-entry.js +8 -8
- package/dist/manifest.json +72 -72
- package/dist/studio.js +64 -65
- package/package.json +11 -11
- package/src/canvas/iframe-editable-root.ts +32 -2
- package/src/format/format-host.ts +1 -1
- package/src/github/github-auth-status.ts +2 -2
- package/src/media/media-library.ts +73 -3
- package/src/packages/ensure-deps.ts +5 -5
- package/src/packages/pull-package-sync.ts +4 -4
- package/src/panels/activity-panel.ts +1 -1
- package/src/platforms/cloud.ts +48 -34
- package/src/settings/extension-commands.ts +1 -1
- package/src/settings/extension-rows.ts +1 -6
- package/src/settings/extensions-section.ts +3 -6
- package/src/surfaces/block-action-bar.json +1 -3
- package/src/surfaces/media-library.json +35 -0
- package/src/surfaces/media-library.ts +2 -0
- package/src/surfaces/menu.ts +62 -1
- package/src/surfaces/settings-packages.ts +1 -1
- package/src/types.ts +10 -8
- package/src/ui/layers.ts +1 -1
- package/src/ui/progress-modal.ts +3 -3
- package/dist/chunks/adapter-ay13gema.js +0 -4
- package/dist/chunks/cf-settings-5y04810c.js +0 -4
- package/dist/chunks/components-3vf75n83.js +0 -4
- package/dist/chunks/content-source-4f2raf4a.js +0 -4
- package/dist/chunks/editor-645krvtz.js +0 -4
- package/dist/chunks/entry-commands-3qmv8wkr.js +0 -4
- package/dist/chunks/file-ops-kkhp9ma7.js +0 -4
- package/dist/chunks/files-yswdhxrf.js +0 -4
- package/dist/chunks/format-host-4g8ex6bz.js +0 -4
- package/dist/chunks/fs-events-z9gpvc6t.js +0 -4
- package/dist/chunks/grid-open-fm4j183c.js +0 -4
- package/dist/chunks/iframe-host-q7fedsmr.js +0 -4
- package/dist/chunks/index-pt4wh98x.js +0 -4
- package/dist/chunks/jx-validate-19y62knt.js +0 -4
- package/dist/chunks/layers-panel-1qvc83y9.js +0 -4
- package/dist/chunks/layers-qf0bc7ze.js +0 -4
- package/dist/chunks/media-library-f9d5qcjb.js +0 -4
- package/dist/chunks/media-picker-rsb1fmk2.js +0 -4
- package/dist/chunks/monaco-buffer-ak0raadw.js +0 -4
- package/dist/chunks/notify-4qj70q0x.js +0 -4
- package/dist/chunks/platform-ehg6t9vd.js +0 -4
- package/dist/chunks/publish-panel-yhmda3cd.js +0 -4
- package/dist/chunks/publish-workspace-hx8qdv9p.js +0 -4
- package/dist/chunks/quick-search-r955m3q1.js +0 -4
- package/dist/chunks/references-8gxv0x7t.js +0 -4
- package/dist/chunks/right-panel-jarwqjpy.js +0 -4
- package/dist/chunks/source-control-84qt25m9.js +0 -4
- package/dist/chunks/studio-2bq7hheq.js +0 -5
- package/dist/chunks/studio-dvhxxxbd.js +0 -5
- package/dist/chunks/studio-ge08zwpv.js +0 -5
- package/dist/chunks/studio-nr0kcqc6.js +0 -5
- package/dist/chunks/studio-y47090vq.js +0 -5
- package/dist/chunks/workspace-7q4arnt3.js +0 -4
- package/dist/chunks/workspace-home-ge027kr6.js +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{bh}from"./studio-
|
|
2
|
-
export{qE,ya,
|
|
1
|
+
import{bh}from"./studio-vzgmyt0v.js";import{mb}from"./studio-wxdcd42g.js";import{S}from"./studio-45gyxpcq.js";import{n,_}from"./studio-zkq3r91p.js";function qE(){return Object.keys(S?.projectConfig?.content??{})}function ya(e){let t=mb(e);if(!t)return null;if(/\.[a-z\d]+$/i.test(t.dir))return null;return{def:t.def,dir:t.dir,ext:t.ext,name:t.name,schema:t.def.schema??null}}function vw(){return qE().map((e)=>ya(e)).filter((e)=>e!==null)}function Ic(e){let t=bh(e??null,S?.projectConfig);return t?ya(t.name):null}function FD(e){let t=bh(e??null,S?.projectConfig),r=t?mb(t.name):null;if(!t||!r)return null;return{def:r.def,dir:r.dir,ext:r.ext,name:r.name,schema:t.schema}}function c(e){if(e===null||!_(e))return e;return JSON.parse(JSON.stringify(e))}function u(e){if(n(e.$ref))return"";switch(e.type){case"boolean":return!1;case"integer":case"number":return 0;case"array":return[];case"object":return GE(e);default:return""}}function GE(e){let t=e?.properties;if(!t)return{};let r=new Set(Array.isArray(e.required)?e.required:[]),o={};for(let[i,l]of Object.entries(t))if(l.default!==void 0)o[i]=c(l.default);else if(r.has(i))o[i]=u(l);return o}function jD(e,t){return(Array.isArray(e?.required)?e.required:[]).filter((o)=>t[o]===void 0)}
|
|
2
|
+
export{qE,ya,vw,Ic,FD,GE,jD};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=85686C1B38E6872464756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-d038kqbs.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{te}from"./studio-psh8mwnw.js";import{Oe,ir,Vd,u}from"./studio-
|
|
2
|
-
export{
|
|
1
|
+
import{te}from"./studio-psh8mwnw.js";import{Oe,ir,Vd,u}from"./studio-vzgmyt0v.js";import{C}from"./studio-4kzbrr5t.js";import{p}from"./studio-03mqh8ax.js";import{Ne,xa,jc}from"./studio-1e8dw2w2.js";import{xi}from"./studio-jttyqrmh.js";import{lw,lb}from"./studio-jw0q5j6k.js";import{xS}from"./studio-c1pxszat.js";import{Co}from"./studio-5wzdy1jc.js";import{Ut,zi}from"./studio-45gyxpcq.js";import{oe}from"./studio-ekgtrndg.js";import{_,it}from"./studio-zkq3r91p.js";function ew(){let t=u.value,e=Oe(t?.session.selection);if(!t||!e||e.length<2)return null;let o=oe(t.doc.document,e);if(!o||!o.tagName)return null;return{node:o,path:e}}async function rm(){let t=ew();if(!t)return;let e=await b(g(t.node));if(!e)return;await cE(e.toLowerCase())}async function cE(t){let e=u.value,o=ew();if(!e||!o)return null;let{node:m,path:d}=o,l=v(m);l.tagName=t;let r=`components/${t}.json`,c=jc(e.documentPath,r),f=d;if(!Vd(e,(n)=>{let s=Ut(f)??[],h=zi(f),a=n;for(let i of s)a=a[i];if(!Array.isArray(a.children))a.children=[];if(a.children[h]={tagName:t},!n.$elements)n.$elements=[];if(!n.$elements.some((i)=>_(i)&&("$ref"in i)&&i.$ref===c))n.$elements.push({$ref:c})}))return null;try{await p().writeFile(r,Co(l,null)),await xa();let s=xS(l);if(C.success(`Converted to <${t}>`),s)C.warn(`<${t}> has a slot problem: ${s}`,{path:r,source:"Components",tier:"problem"});return r}catch(n){return C.error(`Could not save the <${t}> component.`,{detail:te(n),path:r,source:"Components"}),null}}function g(t){if(t.$id){let o=lb(t.$id);if(o!=="")return o}let e=(it(t.tagName)||"div").toLowerCase();return e.includes("-")?e:lb(e)}function v(t){let e=ir(t);return delete e.$id,delete e.$layout,delete e.$paths,e}function N(t){let e=t.trim().toLowerCase(),o=lw(e);if(o!=="")return o;return Ne.some((m)=>m.tagName===e)?`Component <${e}> already exists`:""}function b(t){return xi("Convert to Component",{confirmLabel:"Convert",message:"Enter a hyphenated tag name for the new component.",placeholder:"my-component",validate:N,value:t})}
|
|
2
|
+
export{ew,rm,cE};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=860580C8404DCC3364756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-d83m0wyq.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{Un,m,jt}from"./studio-vzgmyt0v.js";import{kD}from"./studio-zgx7svjd.js";import{Xu}from"./studio-pqqq6v85.js";import{le}from"./studio-7xag4na8.js";var e="edit",a=new Set(["edit","design"]);function r(t){for(let i of m.tabs.values())if(i.documentPath===t)return i;return null}async function Ml(t){if(!Xu(t)){let o=Un(t);if(o&&!o.fileBacked)return kD(t);let{openFileInTab:s}=await (le("de90apn9"),import("./files-de90apn9.js"));return await s(t),r(t)}let{openFileInTab:i}=await (le("de90apn9"),import("./files-de90apn9.js"));await i(t);let n=r(t);if(!n)return null;if(!a.has(n.session.ui.canvasMode)&&n.capabilities.modes.includes(e))n.session.ui.canvasMode=e,n.session.ui.preview=!1;return jt(n.id),n}
|
|
2
|
+
export{Ml};
|
|
3
|
+
|
|
4
|
+
//# debugId=C86248B95CF9AA2164756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-dbxv7w4s.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{p,_e}from"./studio-
|
|
2
|
-
export{hh,Bd,La,k$,Sr,E$,
|
|
1
|
+
import{p,_e}from"./studio-03mqh8ax.js";import{te}from"./studio-psh8mwnw.js";import{Q}from"./studio-zkq3r91p.js";function hh(){return _e()&&Q(p().findReferences)}function u(e){return`${e.path??""}\x00${e.tagName??""}`}var i=new Map,o=new Map;function Bd(e){if(!hh())return{status:"unsupported"};return i.get(u(e))??(o.has(u(e))?{status:"pending"}:null)}async function La(e){if(!hh())return{status:"unsupported"};if(!e.path&&!e.tagName)return{status:"failed",message:"no target to look for"};let t=u(e),s=i.get(t);if(s)return s;let r=o.get(t);if(r)return r;let n={};if(e.path!==void 0)n.path=e.path;if(e.tagName!==void 0)n.tagName=e.tagName;let a=(async()=>{try{return{result:await p().findReferences(n),status:"ready"}}catch(c){return{message:te(c),status:"failed"}}})();o.set(t,a);let d=f,l=await a;if(o.get(t)===a)o.delete(t);if(d!==f)return l;return i.set(t,l),l}function k$(e){return i.delete(u(e)),La(e)}var f=0,g=new Set;function Sr(){f+=1,i.clear(),o.clear();for(let e of g)e()}function E$(e){return g.add(e),()=>{g.delete(e)}}function h(e){let t=0;for(let s of e.files)if(s.path.startsWith("pages/"))t+=1;return{others:e.files.length-t,pages:t}}function Qb(e){let{others:t,pages:s}=h(e);if(s===0&&t===0)return"Not used yet";let r=t===1?"file":"files";if(s===0)return`Used in ${t} ${r}`;let n=`Used on ${s} page${s===1?"":"s"}`;return t===0?n:`${n} and ${t} other ${r}`}function T$(e,t){if(e.status==="unsupported")return null;if(e.status==="pending")return"Counting references…";if(e.status==="failed")return`References could not be counted (${e.message}) — this may break more than it appears to.`;let{files:s,refsTotal:r}=e.result;if(s.length===0)return t==="delete"?"Nothing else in this project refers to it.":"Nothing else in this project refers to it, so nothing needs updating.";let n=`${r} reference${r===1?"":"s"} in ${s.length} file${s.length===1?"":"s"}`,a=e.result.errors.length>0?" (at least — some documents could not be read)":"";if(t==="delete")return`${n}${a} will break. Those files stay on disk; the references in them stop resolving.`;if(t==="convert")return`${n}${a} will be updated automatically to point at the new file.`;return`${n}${a} will be updated automatically. Nothing else changes.`}function ev(e){return e.files.toSorted((t,s)=>s.count-t.count||t.path.localeCompare(s.path))}
|
|
2
|
+
export{hh,Bd,La,k$,Sr,E$,Qb,T$,ev};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=A692A5E1D155847B64756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-de1s2x9v.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{n,_}from"./studio-ywf9y1e2.js";var os=Math.floor;var nt=Math.abs;var ue=(t,e)=>t<e?t:e,Z=(t,e)=>t>e?t:e;var de=(t)=>t!==0?t<0:1/t<0;var cn=1,ln=2,fe=4,pe=8;var dt=32,F=64,D=128;var Vt=31,Mt=63,X=127;var fr=2147483647;var{MAX_SAFE_INTEGER:ft,MIN_SAFE_INTEGER:hn}=Number;var pr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&os(t)===t);var G=()=>new Set;var ge=(t)=>t[t.length-1];var gr=(t,e)=>{for(let r=0;r<e.length;r++)t.push(e[r])},j=Array.from,me=(t,e)=>{for(let r=0;r<t.length;r++)if(!e(t[r],r,t))return!1;return!0},$t=(t,e)=>{for(let r=0;r<t.length;r++)if(e(t[r],r,t))return!0;return!1};var mr=(t,e)=>{let r=Array(t);for(let s=0;s<t;s++)r[s]=e(s,r);return r};var Q=Array.isArray;var{fromCharCode:fn,fromCodePoint:yi}=String,Zc=fn(65535),bi=(t)=>t.toLowerCase(),ki=/^\s*/g,_i=(t)=>t.replace(ki,""),Si=/([A-Z])/g,pn=(t,e)=>_i(t.replace(Si,(r)=>`${e}${bi(r)}`));var Ei=(t)=>{let e=unescape(encodeURIComponent(t)),r=e.length,s=new Uint8Array(r);for(let i=0;i<r;i++)s[i]=e.codePointAt(i);return s},gt=typeof TextEncoder<"u"?new TextEncoder:null,Ii=(t)=>gt.encode(t),wr=gt?Ii:Ei;var pt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(pt&&pt.decode(new Uint8Array).length===1)pt=null;var xr=(t,e)=>mr(e,()=>t).join("");class wt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Ka=()=>new wt;var fk=(t)=>{let e=t.cpos;for(let r=0;r<t.bufs.length;r++)e+=t.bufs[r].length;return e};var br=(t)=>{let e=new Uint8Array(fk(t)),r=0;for(let s=0;s<t.bufs.length;s++){let i=t.bufs[s];e.set(i,r),r+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),r),e},Ui=(t,e)=>{let r=t.cbuf.length;if(r-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(Z(r,e)*2),t.cpos=0},T=(t,e)=>{let r=t.cbuf.length;if(t.cpos===r)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(r*2),t.cpos=0;t.cbuf[t.cpos++]=e};var xe=T;var _t=(t,e)=>{while(e>X)T(t,D|X&e),e=os(e/128);T(t,X&e)},ye=(t,e)=>{let r=de(e);if(r)e=-e;T(t,(e>Mt?D:0)|(r?F:0)|Mt&e),e=os(e/64);while(e>0)T(t,(e>X?D:0)|X&e),e=os(e/128)},gn=new Uint8Array(30000),Ti=gn.length/3,Ai=(t,e)=>{if(e.length<Ti){let r=gt.encodeInto(e,gn).written||0;_t(t,r);for(let s=0;s<r;s++)T(t,gn[s])}else Bo(t,wr(e))},Ci=(t,e)=>{let r=unescape(encodeURIComponent(e)),s=r.length;_t(t,s);for(let i=0;i<s;i++)T(t,r.codePointAt(i))},Ja=gt&>.encodeInto?Ai:Ci;var jt=(t,e)=>{let r=t.cbuf.length,s=t.cpos,i=ue(r-s,e.length),o=e.length-i;if(t.cbuf.set(e.subarray(0,i),s),t.cpos+=i,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Z(r*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o},Bo=(t,e)=>{_t(t,e.byteLength),jt(t,e)},mn=(t,e)=>{Ui(t,e);let r=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,r},Di=(t,e)=>mn(t,4).setFloat32(0,e,!1),Bi=(t,e)=>mn(t,8).setFloat64(0,e,!1),Oi=(t,e)=>mn(t,8).setBigInt64(0,e,!1);var yr=new DataView(new ArrayBuffer(4)),vi=(t)=>(yr.setFloat32(0,t),yr.getFloat32(0)===t),mt=(t,e)=>{switch(typeof e){case"string":T(t,119),Ja(t,e);break;case"number":if(pr(e)&&nt(e)<=fr)T(t,125),ye(t,e);else if(vi(e))T(t,124),Di(t,e);else T(t,123),Bi(t,e);break;case"bigint":T(t,122),Oi(t,e);break;case"object":if(e===null)T(t,126);else if(Q(e)){T(t,117),_t(t,e.length);for(let r=0;r<e.length;r++)mt(t,e[r])}else if(e instanceof Uint8Array)T(t,116),Bo(t,e);else{T(t,118);let r=Object.keys(e);_t(t,r.length);for(let s=0;s<r.length;s++){let i=r[s];Ja(t,i),mt(t,e[i])}}break;case"boolean":T(t,e?120:121);break;default:T(t,127)}};class be extends wt{constructor(t){super();this.w=t,this.s=null,this.count=0}write(t){if(this.s===t)this.count++;else{if(this.count>0)_t(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var kr=(t)=>{if(t.count>0){if(ye(t.encoder,t.count===1?t.s:-t.s),t.count>1)_t(t.encoder,t.count-2)}};class xt{constructor(){this.encoder=new wt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else kr(this),this.count=1,this.s=t}toUint8Array(){return kr(this),br(this.encoder)}}var _r=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(ye(t.encoder,e),t.count>1)_t(t.encoder,t.count-2)}};class qt{constructor(){this.encoder=new wt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else _r(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return _r(this),br(this.encoder)}}class wn{constructor(){this.sarr=[],this.s="",this.lensE=new xt}write(t){if(this.s+=t,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(t.length)}toUint8Array(){let t=new wt;return this.sarr.push(this.s),this.s="",Ja(t,this.sarr.join("")),jt(t,this.lensE.toUint8Array()),br(t)}}var R=(t)=>Error(t),L=()=>{throw R("Method unimplemented")},v=()=>{throw R("Unexpected case")};var ke=R("Unexpected end of array"),Er=R("Integer out of Range"),Ni=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ke;return new Uint8Array(t.buffer,t.byteOffset+e,r)},Ri=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ke;return new DataView(t.buffer,t.byteOffset+e,r)};class Gt{constructor(t){this.arr=t,this.pos=0}}var Ya=(t)=>new Gt(t),Ir=(t)=>t.pos!==t.arr.length;var Li=(t,e)=>{let r=Ni(t.arr,t.pos,e);return t.pos+=e,r},Xo=(t)=>Li(t,Dt(t));var rt=(t)=>t.arr[t.pos++];var Dt=(t)=>{let e=0,r=1,s=t.arr.length;while(t.pos<s){let i=t.arr[t.pos++];if(e=e+(i&X)*r,r*=128,i<D)return e;if(e>ft)throw Er}throw ke},_e=(t)=>{let e=t.arr[t.pos++],r=e&Mt,s=64,i=(e&F)>0?-1:1;if((e&D)===0)return i*r;let o=t.arr.length;while(t.pos<o){if(e=t.arr[t.pos++],r=r+(e&X)*s,s*=128,e<D)return i*r;if(r>ft)throw Er}throw ke};var Vi=(t)=>{let e=Dt(t);if(e===0)return"";else{let r=String.fromCodePoint(rt(t));if(--e<100)while(e--)r+=String.fromCodePoint(rt(t));else while(e>0){let s=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+s);t.pos+=s,r+=String.fromCodePoint.apply(null,i),e-=s}return decodeURIComponent(escape(r))}},Mi=(t)=>pt.decode(Xo(t)),Za=pt?Mi:Vi;var yn=(t,e)=>{let r=Ri(t.arr,t.pos,e);return t.pos+=e,r},$i=(t)=>yn(t,4).getFloat32(0,!1),Fi=(t)=>yn(t,8).getFloat64(0,!1),ji=(t)=>yn(t,8).getBigInt64(0,!1);var qi=[(t)=>{return},(t)=>null,_e,$i,Fi,ji,(t)=>!1,(t)=>!0,Za,(t)=>{let e=Dt(t),r={};for(let s=0;s<e;s++){let i=Za(t);r[i]=yt(t)}return r},(t)=>{let e=Dt(t),r=[];for(let s=0;s<e;s++)r.push(yt(t));return r},Xo],yt=(t)=>qi[127-rt(t)](t);class Se extends Gt{constructor(t,e){super(t);this.reader=e,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Ir(this))this.count=Dt(this)+1;else this.count=-1;return this.count--,this.s}}class bt extends Gt{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=_e(this);let t=de(this.s);if(this.count=1,t)this.s=-this.s,this.count=Dt(this)+2}return this.count--,this.s}}class zt extends Gt{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=_e(this),e=t&1;if(this.diff=os(t/2),this.count=1,e)this.count=Dt(this)+2}return this.s+=this.diff,this.count--,this.s}}class bn{constructor(t){this.decoder=new bt(t),this.str=Za(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}var A=()=>new Map,Ee=(t)=>{let e=A();return t.forEach((r,s)=>{e.set(s,r)}),e},q=(t,e,r)=>{let s=t.get(e);if(s===void 0)t.set(e,s=r());return s},Tr=(t,e)=>{let r=[];for(let[s,i]of t)r.push(e(i,s));return r},Ar=(t,e)=>{for(let[r,s]of t)if(e(s,r))return!0;return!1};class Ie{constructor(){this._observers=A()}on(t,e){return q(this._observers,t,G).add(e),e}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return j((this._observers.get(t)||A()).values()).forEach((r)=>r(...e))}destroy(){this._observers=A()}}class pk{constructor(){this._observers=A()}on(t,e){q(this._observers,t,G).add(e)}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return j((this._observers.get(t)||A()).values()).forEach((r)=>r(...e))}destroy(){this._observers=A()}}var tl=crypto.subtle,Cr=crypto.getRandomValues.bind(crypto);var kn=()=>Cr(new Uint32Array(1))[0];var Gi=[1e7]+-1000+-4000+-8000+-100000000000,Dr=()=>Gi.replace(/[018]/g,(t)=>(t^kn()&15>>t/4).toString(16));var _u=Date.now;var _n=(t)=>new Promise(t);var rl=Promise.all.bind(Promise);var Sn=(t)=>t===void 0?null:t;class Or{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var vr=new Or,Pi=!0;try{if(typeof localStorage<"u"&&localStorage)vr=localStorage,Pi=!1}catch(t){}var Nr=vr;var st=Symbol("Equality"),Ue=(t,e)=>t===e||!!t?.[st]?.(e)||!1;var Rr=(t)=>typeof t==="object",{assign:Lr,keys:Wi}=Object;var Vr=(t,e)=>{for(let r in t)e(t[r],r)};var Jt=(t)=>Wi(t).length;var Mr=(t)=>{for(let e in t)return!1;return!0},kt=(t,e)=>{for(let r in t)if(!e(t[r],r))return!1;return!0},Pt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),In=(t,e)=>t===e||Jt(t)===Jt(e)&&kt(t,(r,s)=>(r!==void 0||Pt(e,s))&&Ue(e[s],r)),Zi=Object.freeze,Un=(t)=>{for(let e in t){let r=t[e];if(typeof r==="object"||typeof r==="function")Un(t[e])}return Zi(t)};var Kt=(t,e,r=0)=>{try{for(;r<t.length;r++)t[r](...e)}finally{if(r<t.length)Kt(t,e,r+1)}};var $r=(t)=>t;var op=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[st]!=null)return t[st](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let r of t)if(!e.has(r))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let r of t.keys())if(!e.has(r)||!op(t.get(r),e.get(r)))return!1;break}case void 0:case Object:if(Jt(t)!==Jt(e))return!1;for(let r in t)if(!Pt(t,r)||!op(t[r],e[r]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!op(t[r],e[r]))return!1;break;default:return!1}return!0},Fr=(t,e)=>e.includes(t);var Wt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var sl=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,z,Xi=[],Qi=()=>{if(z===void 0)if(Wt){z=A();let t=process.argv,e=null;for(let r=0;r<t.length;r++){let s=t[r];if(s[0]==="-"){if(e!==null)z.set(e,"");e=s}else if(e!==null)z.set(e,s),e=null;else Xi.push(s)}if(e!==null)z.set(e,"")}else if(typeof location==="object")z=A(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,r]=t.split("=");z.set(`--${pn(e,"-")}`,r),z.set(`-${pn(e,"-")}`,r)}});else z=A();return z},Cn=(t)=>Qi().has(t);var Zt=(t)=>Wt?Sn(process.env[t.toUpperCase().replaceAll("-","_")]):Sn(Nr.getItem(t));var jr=(t)=>Cn("--"+t)||Zt(t)!==null,qr=jr("production"),Yi=Wt&&Fr(process.env.FORCE_COLOR,["true","1","2"]),Gr=Yi||!Cn("--no-colors")&&!jr("no-color")&&(!Wt||process.stdout.isTTY)&&(!Wt||Cn("--color")||Zt("COLORTERM")!==null||(Zt("TERM")||"").includes("color"));var to=(t)=>new Uint8Array(t);var zr=(t)=>{let e=to(t.byteLength);return e.set(t),e};class Hr{constructor(t,e){this.left=t,this.right=e}}var H=(t,e)=>new Hr(t,e);var Bn=(t)=>t.next()>=0.5,Te=(t,e,r)=>os(t.next()*(r+1-e)+e);var On=(t,e,r)=>os(t.next()*(r+1-e)+e);var vn=(t,e,r)=>On(t,e,r);var ro=(t)=>fn(vn(t,97,122)),Jr=(t,e=0,r=20)=>{let s=vn(t,e,r),i="";for(let o=0;o<s;o++)i+=ro(t);return i};var Ae=(t,e)=>e[vn(t,0,e.length-1)];var io=Symbol("0schema");class Kr{constructor(){this._rerrs=[]}extend(t,e,r,s=null){this._rerrs.push({path:t,expected:e,has:r,message:s})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let r=this._rerrs[e];t.push(xr(" ",(this._rerrs.length-e)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
|
|
1
|
+
import{n,_}from"./studio-zkq3r91p.js";var os=Math.floor;var nt=Math.abs;var ue=(t,e)=>t<e?t:e,Z=(t,e)=>t>e?t:e;var de=(t)=>t!==0?t<0:1/t<0;var cn=1,ln=2,fe=4,pe=8;var dt=32,F=64,D=128;var Vt=31,Mt=63,X=127;var fr=2147483647;var{MAX_SAFE_INTEGER:ft,MIN_SAFE_INTEGER:hn}=Number;var pr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&os(t)===t);var G=()=>new Set;var ge=(t)=>t[t.length-1];var gr=(t,e)=>{for(let r=0;r<e.length;r++)t.push(e[r])},j=Array.from,me=(t,e)=>{for(let r=0;r<t.length;r++)if(!e(t[r],r,t))return!1;return!0},$t=(t,e)=>{for(let r=0;r<t.length;r++)if(e(t[r],r,t))return!0;return!1};var mr=(t,e)=>{let r=Array(t);for(let s=0;s<t;s++)r[s]=e(s,r);return r};var Q=Array.isArray;var{fromCharCode:fn,fromCodePoint:yi}=String,Zc=fn(65535),bi=(t)=>t.toLowerCase(),ki=/^\s*/g,_i=(t)=>t.replace(ki,""),Si=/([A-Z])/g,pn=(t,e)=>_i(t.replace(Si,(r)=>`${e}${bi(r)}`));var Ei=(t)=>{let e=unescape(encodeURIComponent(t)),r=e.length,s=new Uint8Array(r);for(let i=0;i<r;i++)s[i]=e.codePointAt(i);return s},gt=typeof TextEncoder<"u"?new TextEncoder:null,Ii=(t)=>gt.encode(t),wr=gt?Ii:Ei;var pt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(pt&&pt.decode(new Uint8Array).length===1)pt=null;var xr=(t,e)=>mr(e,()=>t).join("");class wt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Ka=()=>new wt;var fk=(t)=>{let e=t.cpos;for(let r=0;r<t.bufs.length;r++)e+=t.bufs[r].length;return e};var br=(t)=>{let e=new Uint8Array(fk(t)),r=0;for(let s=0;s<t.bufs.length;s++){let i=t.bufs[s];e.set(i,r),r+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),r),e},Ui=(t,e)=>{let r=t.cbuf.length;if(r-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(Z(r,e)*2),t.cpos=0},T=(t,e)=>{let r=t.cbuf.length;if(t.cpos===r)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(r*2),t.cpos=0;t.cbuf[t.cpos++]=e};var xe=T;var _t=(t,e)=>{while(e>X)T(t,D|X&e),e=os(e/128);T(t,X&e)},ye=(t,e)=>{let r=de(e);if(r)e=-e;T(t,(e>Mt?D:0)|(r?F:0)|Mt&e),e=os(e/64);while(e>0)T(t,(e>X?D:0)|X&e),e=os(e/128)},gn=new Uint8Array(30000),Ti=gn.length/3,Ai=(t,e)=>{if(e.length<Ti){let r=gt.encodeInto(e,gn).written||0;_t(t,r);for(let s=0;s<r;s++)T(t,gn[s])}else Bo(t,wr(e))},Ci=(t,e)=>{let r=unescape(encodeURIComponent(e)),s=r.length;_t(t,s);for(let i=0;i<s;i++)T(t,r.codePointAt(i))},Ja=gt&>.encodeInto?Ai:Ci;var jt=(t,e)=>{let r=t.cbuf.length,s=t.cpos,i=ue(r-s,e.length),o=e.length-i;if(t.cbuf.set(e.subarray(0,i),s),t.cpos+=i,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Z(r*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o},Bo=(t,e)=>{_t(t,e.byteLength),jt(t,e)},mn=(t,e)=>{Ui(t,e);let r=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,r},Di=(t,e)=>mn(t,4).setFloat32(0,e,!1),Bi=(t,e)=>mn(t,8).setFloat64(0,e,!1),Oi=(t,e)=>mn(t,8).setBigInt64(0,e,!1);var yr=new DataView(new ArrayBuffer(4)),vi=(t)=>(yr.setFloat32(0,t),yr.getFloat32(0)===t),mt=(t,e)=>{switch(typeof e){case"string":T(t,119),Ja(t,e);break;case"number":if(pr(e)&&nt(e)<=fr)T(t,125),ye(t,e);else if(vi(e))T(t,124),Di(t,e);else T(t,123),Bi(t,e);break;case"bigint":T(t,122),Oi(t,e);break;case"object":if(e===null)T(t,126);else if(Q(e)){T(t,117),_t(t,e.length);for(let r=0;r<e.length;r++)mt(t,e[r])}else if(e instanceof Uint8Array)T(t,116),Bo(t,e);else{T(t,118);let r=Object.keys(e);_t(t,r.length);for(let s=0;s<r.length;s++){let i=r[s];Ja(t,i),mt(t,e[i])}}break;case"boolean":T(t,e?120:121);break;default:T(t,127)}};class be extends wt{constructor(t){super();this.w=t,this.s=null,this.count=0}write(t){if(this.s===t)this.count++;else{if(this.count>0)_t(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var kr=(t)=>{if(t.count>0){if(ye(t.encoder,t.count===1?t.s:-t.s),t.count>1)_t(t.encoder,t.count-2)}};class xt{constructor(){this.encoder=new wt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else kr(this),this.count=1,this.s=t}toUint8Array(){return kr(this),br(this.encoder)}}var _r=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(ye(t.encoder,e),t.count>1)_t(t.encoder,t.count-2)}};class qt{constructor(){this.encoder=new wt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else _r(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return _r(this),br(this.encoder)}}class wn{constructor(){this.sarr=[],this.s="",this.lensE=new xt}write(t){if(this.s+=t,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(t.length)}toUint8Array(){let t=new wt;return this.sarr.push(this.s),this.s="",Ja(t,this.sarr.join("")),jt(t,this.lensE.toUint8Array()),br(t)}}var R=(t)=>Error(t),L=()=>{throw R("Method unimplemented")},v=()=>{throw R("Unexpected case")};var ke=R("Unexpected end of array"),Er=R("Integer out of Range"),Ni=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ke;return new Uint8Array(t.buffer,t.byteOffset+e,r)},Ri=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ke;return new DataView(t.buffer,t.byteOffset+e,r)};class Gt{constructor(t){this.arr=t,this.pos=0}}var Ya=(t)=>new Gt(t),Ir=(t)=>t.pos!==t.arr.length;var Li=(t,e)=>{let r=Ni(t.arr,t.pos,e);return t.pos+=e,r},Xo=(t)=>Li(t,Dt(t));var rt=(t)=>t.arr[t.pos++];var Dt=(t)=>{let e=0,r=1,s=t.arr.length;while(t.pos<s){let i=t.arr[t.pos++];if(e=e+(i&X)*r,r*=128,i<D)return e;if(e>ft)throw Er}throw ke},_e=(t)=>{let e=t.arr[t.pos++],r=e&Mt,s=64,i=(e&F)>0?-1:1;if((e&D)===0)return i*r;let o=t.arr.length;while(t.pos<o){if(e=t.arr[t.pos++],r=r+(e&X)*s,s*=128,e<D)return i*r;if(r>ft)throw Er}throw ke};var Vi=(t)=>{let e=Dt(t);if(e===0)return"";else{let r=String.fromCodePoint(rt(t));if(--e<100)while(e--)r+=String.fromCodePoint(rt(t));else while(e>0){let s=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+s);t.pos+=s,r+=String.fromCodePoint.apply(null,i),e-=s}return decodeURIComponent(escape(r))}},Mi=(t)=>pt.decode(Xo(t)),Za=pt?Mi:Vi;var yn=(t,e)=>{let r=Ri(t.arr,t.pos,e);return t.pos+=e,r},$i=(t)=>yn(t,4).getFloat32(0,!1),Fi=(t)=>yn(t,8).getFloat64(0,!1),ji=(t)=>yn(t,8).getBigInt64(0,!1);var qi=[(t)=>{return},(t)=>null,_e,$i,Fi,ji,(t)=>!1,(t)=>!0,Za,(t)=>{let e=Dt(t),r={};for(let s=0;s<e;s++){let i=Za(t);r[i]=yt(t)}return r},(t)=>{let e=Dt(t),r=[];for(let s=0;s<e;s++)r.push(yt(t));return r},Xo],yt=(t)=>qi[127-rt(t)](t);class Se extends Gt{constructor(t,e){super(t);this.reader=e,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Ir(this))this.count=Dt(this)+1;else this.count=-1;return this.count--,this.s}}class bt extends Gt{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=_e(this);let t=de(this.s);if(this.count=1,t)this.s=-this.s,this.count=Dt(this)+2}return this.count--,this.s}}class zt extends Gt{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=_e(this),e=t&1;if(this.diff=os(t/2),this.count=1,e)this.count=Dt(this)+2}return this.s+=this.diff,this.count--,this.s}}class bn{constructor(t){this.decoder=new bt(t),this.str=Za(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}var A=()=>new Map,Ee=(t)=>{let e=A();return t.forEach((r,s)=>{e.set(s,r)}),e},q=(t,e,r)=>{let s=t.get(e);if(s===void 0)t.set(e,s=r());return s},Tr=(t,e)=>{let r=[];for(let[s,i]of t)r.push(e(i,s));return r},Ar=(t,e)=>{for(let[r,s]of t)if(e(s,r))return!0;return!1};class Ie{constructor(){this._observers=A()}on(t,e){return q(this._observers,t,G).add(e),e}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return j((this._observers.get(t)||A()).values()).forEach((r)=>r(...e))}destroy(){this._observers=A()}}class pk{constructor(){this._observers=A()}on(t,e){q(this._observers,t,G).add(e)}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return j((this._observers.get(t)||A()).values()).forEach((r)=>r(...e))}destroy(){this._observers=A()}}var tl=crypto.subtle,Cr=crypto.getRandomValues.bind(crypto);var kn=()=>Cr(new Uint32Array(1))[0];var Gi=[1e7]+-1000+-4000+-8000+-100000000000,Dr=()=>Gi.replace(/[018]/g,(t)=>(t^kn()&15>>t/4).toString(16));var _u=Date.now;var _n=(t)=>new Promise(t);var rl=Promise.all.bind(Promise);var Sn=(t)=>t===void 0?null:t;class Or{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var vr=new Or,Pi=!0;try{if(typeof localStorage<"u"&&localStorage)vr=localStorage,Pi=!1}catch(t){}var Nr=vr;var st=Symbol("Equality"),Ue=(t,e)=>t===e||!!t?.[st]?.(e)||!1;var Rr=(t)=>typeof t==="object",{assign:Lr,keys:Wi}=Object;var Vr=(t,e)=>{for(let r in t)e(t[r],r)};var Jt=(t)=>Wi(t).length;var Mr=(t)=>{for(let e in t)return!1;return!0},kt=(t,e)=>{for(let r in t)if(!e(t[r],r))return!1;return!0},Pt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),In=(t,e)=>t===e||Jt(t)===Jt(e)&&kt(t,(r,s)=>(r!==void 0||Pt(e,s))&&Ue(e[s],r)),Zi=Object.freeze,Un=(t)=>{for(let e in t){let r=t[e];if(typeof r==="object"||typeof r==="function")Un(t[e])}return Zi(t)};var Kt=(t,e,r=0)=>{try{for(;r<t.length;r++)t[r](...e)}finally{if(r<t.length)Kt(t,e,r+1)}};var $r=(t)=>t;var op=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[st]!=null)return t[st](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let r of t)if(!e.has(r))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let r of t.keys())if(!e.has(r)||!op(t.get(r),e.get(r)))return!1;break}case void 0:case Object:if(Jt(t)!==Jt(e))return!1;for(let r in t)if(!Pt(t,r)||!op(t[r],e[r]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!op(t[r],e[r]))return!1;break;default:return!1}return!0},Fr=(t,e)=>e.includes(t);var Wt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var sl=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,z,Xi=[],Qi=()=>{if(z===void 0)if(Wt){z=A();let t=process.argv,e=null;for(let r=0;r<t.length;r++){let s=t[r];if(s[0]==="-"){if(e!==null)z.set(e,"");e=s}else if(e!==null)z.set(e,s),e=null;else Xi.push(s)}if(e!==null)z.set(e,"")}else if(typeof location==="object")z=A(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,r]=t.split("=");z.set(`--${pn(e,"-")}`,r),z.set(`-${pn(e,"-")}`,r)}});else z=A();return z},Cn=(t)=>Qi().has(t);var Zt=(t)=>Wt?Sn(process.env[t.toUpperCase().replaceAll("-","_")]):Sn(Nr.getItem(t));var jr=(t)=>Cn("--"+t)||Zt(t)!==null,qr=jr("production"),Yi=Wt&&Fr(process.env.FORCE_COLOR,["true","1","2"]),Gr=Yi||!Cn("--no-colors")&&!jr("no-color")&&(!Wt||process.stdout.isTTY)&&(!Wt||Cn("--color")||Zt("COLORTERM")!==null||(Zt("TERM")||"").includes("color"));var to=(t)=>new Uint8Array(t);var zr=(t)=>{let e=to(t.byteLength);return e.set(t),e};class Hr{constructor(t,e){this.left=t,this.right=e}}var H=(t,e)=>new Hr(t,e);var Bn=(t)=>t.next()>=0.5,Te=(t,e,r)=>os(t.next()*(r+1-e)+e);var On=(t,e,r)=>os(t.next()*(r+1-e)+e);var vn=(t,e,r)=>On(t,e,r);var ro=(t)=>fn(vn(t,97,122)),Jr=(t,e=0,r=20)=>{let s=vn(t,e,r),i="";for(let o=0;o<s;o++)i+=ro(t);return i};var Ae=(t,e)=>e[vn(t,0,e.length-1)];var io=Symbol("0schema");class Kr{constructor(){this._rerrs=[]}extend(t,e,r,s=null){this._rerrs.push({path:t,expected:e,has:r,message:s})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let r=this._rerrs[e];t.push(xr(" ",(this._rerrs.length-e)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
|
|
2
2
|
`)}}var Nn=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor)return!1;if(t[st])return Ue(t,e);if(Q(t))return me(t,(r)=>$t(e,(s)=>Nn(r,s)));else if(Rr(t))return kt(t,(r,s)=>Nn(r,e[s]));return!1};class B{static _dilutes=!1;extends(t){let[e,r]=[this.shape,t.shape];if(this.constructor._dilutes)[r,e]=[e,r];return Nn(e,r)}equals(t){return this.constructor===t.constructor&&op(this.shape,t.shape)}[io](){return!0}[st](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){L()}get nullable(){return Ut(this,Ve)}get optional(){return new Rn(this)}cast(t){return Pr(t,this),t}expect(t){return Pr(t,this),t}}class Be extends B{constructor(t,e){super();this.shape=t,this._c=e}check(t,e=void 0){let r=t?.constructor===this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}}var S=(t,e=null)=>new Be(t,e),ol=S(Be);class Oe extends B{constructor(t){super();this.shape=t}check(t,e){let r=this.shape(t);return!r&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),r}}var E=(t)=>new Oe(t),cl=S(Oe);class Qt extends B{constructor(t){super();this.shape=t}check(t,e){let r=this.shape.some((s)=>s===t);return!r&&e?.extend(null,this.shape.join(" | "),t.toString()),r}}var ve=(...t)=>new Qt(t),Wr=S(Qt),oo=RegExp.escape||((t)=>t.replace(/[().|&,$^[\]]/g,(e)=>"\\"+e)),Zr=(t)=>{if(It.check(t))return[oo(t)];if(Wr.check(t))return t.shape.map((e)=>e+"");if(cs.check(t))return["[+-]?\\d+.?\\d*"];if(ls.check(t))return[".*"];if(Ce.check(t))return t.shape.map(Zr).flat(1);v()};class Xr extends B{constructor(t){super();this.shape=t,this._r=new RegExp("^"+t.map(Zr).map((e)=>`(${e.join("|")})`).join("")+"$")}check(t,e){let r=this._r.exec(t)!=null;return!r&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),r}}var ll=S(Xr),co=Symbol("optional");class Rn extends B{constructor(t){super();this.shape=t}check(t,e){let r=t===void 0||this.shape.check(t);return!r&&e?.extend(null,"undefined (optional)","()"),r}get[co](){return!0}}var lo=S(Rn);class Ln extends B{check(t,e){return e?.extend(null,"never",typeof t),!1}}var al=new Ln,hl=S(Ln);class Ne extends B{constructor(t,e=!1){super();this.shape=t,this._isPartial=e}static _dilutes=!0;get partial(){return new Ne(this.shape,!0)}check(t,e){if(t==null)return e?.extend(null,"object","null"),!1;return kt(this.shape,(r,s)=>{let i=this._isPartial&&!Pt(t,s)||r.check(t[s],e);return!i&&e?.extend(s.toString(),r.toString(),typeof t[s],"Object property does not match"),i})}}var ao=(t)=>new Ne(t),ho=S(Ne),uo=E((t)=>t!=null&&(t.constructor===Object||t.constructor==null));class Vn extends B{constructor(t,e){super();this.shape={keys:t,values:e}}check(t,e){return t!=null&&kt(t,(r,s)=>{let i=this.shape.keys.check(s,e);return!i&&e?.extend(s+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(r,e)})}}var Qr=(t,e)=>new Vn(t,e),fo=S(Vn);class Mn extends B{constructor(t){super();this.shape=t}check(t,e){return t!=null&&kt(this.shape,(r,s)=>{let i=r.check(t[s],e);return!i&&e?.extend(s.toString(),"Tuple",typeof r),i})}}var po=(...t)=>new Mn(t),ul=S(Mn);class $n extends B{constructor(t){super();this.shape=t.length===1?t[0]:new Re(t)}check(t,e){let r=Q(t)&&me(t,(s)=>this.shape.check(s));return!r&&e?.extend(null,"Array",""),r}}var Yr=(...t)=>new $n(t),go=S($n),mo=E((t)=>Q(t));class Fn extends B{constructor(t,e){super();this.shape=t,this._c=e}check(t,e){let r=t instanceof this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name),r}}var wo=(t,e=null)=>new Fn(t,e),dl=S(Fn),xo=wo(B);class ts extends B{constructor(t){super();this.len=t.length-1,this.args=po(...t.slice(-1)),this.res=t[this.len]}check(t,e){let r=t.constructor===Function&&t.length<=this.len;return!r&&e?.extend(null,"function",typeof t),r}}var yo=S(ts),bo=E((t)=>typeof t==="function");class es extends B{constructor(t){super();this.shape=t}check(t,e){let r=me(this.shape,(s)=>s.check(t,e));return!r&&e?.extend(null,"Intersectinon",typeof t),r}}var fl=S(es,(t)=>t.shape.length>0);class Re extends B{static _dilutes=!0;constructor(t){super();this.shape=t}check(t,e){let r=$t(this.shape,(s)=>s.check(t,e));return e?.extend(null,"Union",typeof t),r}}var Ut=(...t)=>t.findIndex((e)=>Ce.check(e))>=0?Ut(...t.map((e)=>Xt(e)).map((e)=>Ce.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Re(t),Ce=S(Re),ns=()=>!0,De=E(ns),ko=S(Oe,(t)=>t.shape===ns),jn=E((t)=>typeof t==="bigint"),_o=E((t)=>t===jn),is=E((t)=>typeof t==="symbol"),pl=E((t)=>t===is),Et=E((t)=>typeof t==="number"),cs=E((t)=>t===Et),It=E((t)=>typeof t==="string"),ls=E((t)=>t===It),Le=E((t)=>typeof t==="boolean"),So=E((t)=>t===Le),as=ve(void 0),gl=S(Qt,(t)=>t.shape.length===1&&t.shape[0]===void 0),ml=ve(void 0);var Ve=ve(null),Eo=S(Qt,(t)=>t.shape.length===1&&t.shape[0]===null),wl=S(Uint8Array),xl=S(Be,(t)=>t.shape===Uint8Array),Io=Ut(Et,It,Ve,as,jn,Le,is),yl=(()=>{let t=Yr(De),e=Qr(It,De),r=Ut(Et,It,Ve,Le,t,e);return t.shape=r,e.shape.values=r,r})(),Xt=(t)=>{if(xo.check(t))return t;else if(uo.check(t)){let e={};for(let r in t)e[r]=Xt(t[r]);return ao(e)}else if(mo.check(t))return Ut(...t.map(Xt));else if(Io.check(t))return ve(t);else if(bo.check(t))return S(t);v()},Pr=qr?()=>{}:(t,e)=>{let r=new Kr;if(!e.check(t,r))throw R(`Expected value to be of type ${e.constructor.name}.
|
|
3
|
-
${r.toString()}`)};class hs{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:Xt(t),h:e}),this}else(t){return this.if(De,t)}done(){return(t,e)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,e)}throw R("Unhandled pattern")}}}var Uo=(t)=>new hs(t),us=Uo(De).if(cs,(t,e)=>Te(e,hn,ft)).if(ls,(t,e)=>Jr(e)).if(So,(t,e)=>Bn(e)).if(_o,(t,e)=>BigInt(Te(e,hn,ft))).if(Ce,(t,e)=>St(e,Ae(e,t.shape))).if(ho,(t,e)=>{let r={};for(let s in t.shape){let i=t.shape[s];if(lo.check(i)){if(Bn(e))continue;i=i.shape}r[s]=us(i,e)}return r}).if(go,(t,e)=>{let r=[],s=On(e,0,42);for(let i=0;i<s;i++)r.push(St(e,t.shape));return r}).if(Wr,(t,e)=>Ae(e,t.shape)).if(Eo,(t,e)=>null).if(yo,(t,e)=>{let r=St(e,t.res);return()=>r}).if(ko,(t,e)=>St(e,Ae(e,[Et,It,Ve,as,jn,Le,Yr(Et),Qr(Ut("a","b","c"),Et)]))).if(fo,(t,e)=>{let r={},s=Te(e,0,3);for(let i=0;i<s;i++){let o=St(e,t.shape.keys),c=St(e,t.shape.values);r[o]=c}return r}).done(),St=(t,e)=>us(Xt(e),t);var it=typeof document<"u"?document:{};var bl=E((t)=>t.nodeType===Oo);var kl=typeof DOMParser<"u"?new DOMParser:null;var _l=E((t)=>t.nodeType===Ao);var Sl=E((t)=>t.nodeType===Co);var ds=(t)=>Tr(t,(e,r)=>`${r}:${e};`).join("");var{ELEMENT_NODE:Ao,TEXT_NODE:Co,CDATA_SECTION_NODE:El,COMMENT_NODE:Il,DOCUMENT_NODE:Do,DOCUMENT_TYPE_NODE:Ul,DOCUMENT_FRAGMENT_NODE:Oo}=it,Tl=E((t)=>t.nodeType===Do);var J=Symbol;var Yt=J(),te=J(),qn=J(),Gn=J(),zn=J(),ee=J(),Hn=J(),Tt=J(),Jn=J(),fs=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=0;for(;s<t.length;s++){let i=t[s];if(i===void 0)break;else if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}if(s>0)r.push(e.join(""));for(;s<t.length;s++){let i=t[s];if(!(i instanceof Symbol))r.push(i)}return r};var Al=_u();var Lo={[Yt]:H("font-weight","bold"),[te]:H("font-weight","normal"),[qn]:H("color","blue"),[zn]:H("color","green"),[Gn]:H("color","grey"),[ee]:H("color","red"),[Hn]:H("color","purple"),[Tt]:H("color","orange"),[Jn]:H("color","black")},Vo=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=A(),i=[],o=0;for(;o<t.length;o++){let c=t[o],l=Lo[c];if(l!==void 0)s.set(l.left,l.right);else{if(c===void 0)break;if(c.constructor===String||c.constructor===Number){let h=ds(s);if(o>0||h.length>0)e.push("%c"+c),r.push(h);else e.push(c)}else break}}if(o>0)i=r,i.unshift(e.join(""));for(;o<t.length;o++){let c=t[o];if(!(c instanceof Symbol))i.push(c)}return i},ps=Gr?Vo:fs,gs=(...t)=>{console.log(...ps(t)),ms.forEach((e)=>e.print(t))},Pn=(...t)=>{console.warn(...ps(t)),t.unshift(Tt),ms.forEach((e)=>e.print(t))};var ms=G();var ws=(t)=>({[Symbol.iterator](){return this},next:t}),xs=(t,e)=>ws(()=>{let r;do r=t.next();while(!r.done&&!e(r.value));return r}),Me=(t,e)=>ws(()=>{let{done:r,value:s}=t.next();return{done:r,value:r?void 0:e(s)}});class oe{constructor(t,e){this.clock=t,this.len=e}}class ht{constructor(){this.clients=new Map}}var Bt=(t,e,r)=>e.clients.forEach((s,i)=>{let o=t.doc.store.clients.get(i);if(o!=null){let c=o[o.length-1],l=c.id.clock+c.length;for(let h=0,f=s[h];h<s.length&&f.clock<l;f=s[++h])Js(t,o,f.clock,f.len,r)}}),Fo=(t,e)=>{let r=0,s=t.length-1;while(r<=s){let i=os((r+s)/2),o=t[i],c=o.clock;if(c<=e){if(e<c+o.len)return i;r=i+1}else s=i-1}return null},ce=(t,e)=>{let r=t.clients.get(e.client);return r!==void 0&&Fo(r,e.clock)!==null},Yn=(t)=>{t.clients.forEach((e)=>{e.sort((i,o)=>i.clock-o.clock);let r,s;for(r=1,s=1;r<e.length;r++){let i=e[s-1],o=e[r];if(i.clock+i.len>=o.clock)e[s-1]=new oe(i.clock,Z(i.len,o.clock+o.len-i.clock));else{if(s<r)e[s]=o;s++}}e.length=s})},Wn=(t)=>{let e=new ht;for(let r=0;r<t.length;r++)t[r].clients.forEach((s,i)=>{if(!e.clients.has(i)){let o=s.slice();for(let c=r+1;c<t.length;c++)gr(o,t[c].clients.get(i)||[]);e.clients.set(i,o)}});return Yn(e),e},ne=(t,e,r,s)=>{q(t.clients,e,()=>[]).push(new oe(r,s))},vs=()=>new ht,jo=(t)=>{let e=vs();return t.clients.forEach((r,s)=>{let i=[];for(let o=0;o<r.length;o++){let c=r[o];if(c.deleted){let l=c.id.clock,h=c.length;if(o+1<r.length)for(let f=r[o+1];o+1<r.length&&f.deleted;f=r[++o+1])h+=f.length;i.push(new oe(l,h))}}if(i.length>0)e.clients.set(s,i)}),e},vt=(t,e)=>{_t(t.restEncoder,e.clients.size),j(e.clients.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{t.resetDsCurVal(),_t(t.restEncoder,r);let i=s.length;_t(t.restEncoder,i);for(let o=0;o<i;o++){let c=s[o];t.writeDsClock(c.clock),t.writeDsLen(c.len)}})},tr=(t)=>{let e=new ht,r=Dt(t.restDecoder);for(let s=0;s<r;s++){t.resetDsCurVal();let i=Dt(t.restDecoder),o=Dt(t.restDecoder);if(o>0){let c=q(e.clients,i,()=>[]);for(let l=0;l<o;l++)c.push(new oe(t.readDsClock(),t.readDsLen()))}}return e},ys=(t,e,r)=>{let s=new ht,i=Dt(t.restDecoder);for(let o=0;o<i;o++){t.resetDsCurVal();let c=Dt(t.restDecoder),l=Dt(t.restDecoder),h=r.clients.get(c)||[],f=b(r,c);for(let a=0;a<l;a++){let u=t.readDsClock(),d=u+t.readDsLen();if(u<f){if(f<d)ne(s,c,f,d-f);let p=P(h,u),g=h[p];if(!g.deleted&&g.id.clock<u)h.splice(p+1,0,Ye(e,g,u-g.id.clock)),p++;while(p<h.length)if(g=h[p++],g.id.clock<d){if(!g.deleted){if(d<g.id.clock+g.length)h.splice(p,0,Ye(e,g,d-g.id.clock));g.delete(e)}}else break}else ne(s,c,u,d-u)}}if(s.clients.size>0){let o=new et;return _t(o.restEncoder,0),vt(o,s),o.toUint8Array()}return null};var Ns=kn;class yd extends Ie{constructor({guid:t=Dr(),collectionid:e=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super();this.gc=r,this.gcFilter=s,this.clientID=Ns(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new or,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=_n((h)=>{this.on("load",()=>{this.isLoaded=!0,h(this)})});let l=()=>_n((h)=>{let f=(a)=>{if(a===void 0||a===!0)this.off("sync",f),h()};this.on("sync",f)});this.on("sync",(h)=>{if(h===!1&&this.isSynced)this.whenSynced=l();if(this.isSynced=h===void 0||h===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)x(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(j(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return x(this,t,e)}get(t,e=I){let r=q(this.share,t,()=>{let i=new e;return i._integrate(this,null),i}),s=r.constructor;if(e!==I&&s!==e)if(s===I){let i=new e;i._map=r._map,r._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,ba)}getText(t=""){return this.get(t,ss)}getMap(t=""){return this.get(t,rs)}getXmlElement(t=""){return this.get(t,Ot)}getXmlFragment(t=""){return this.get(t,lt)}toJSON(){let t={};return this.share.forEach((e,r)=>{t[r]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,j(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new yd({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,x(t.parent.doc,(r)=>{let s=e.doc;if(!t.deleted)r.subdocsAdded.add(s);r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class er{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return Dt(this.restDecoder)}readDsLen(){return Dt(this.restDecoder)}}class nr extends er{readLeftID(){return m(Dt(this.restDecoder),Dt(this.restDecoder))}readRightID(){return m(Dt(this.restDecoder),Dt(this.restDecoder))}readClient(){return Dt(this.restDecoder)}readInfo(){return rt(this.restDecoder)}readString(){return Za(this.restDecoder)}readParentInfo(){return Dt(this.restDecoder)===1}readTypeRef(){return Dt(this.restDecoder)}readLen(){return Dt(this.restDecoder)}readAny(){return yt(this.restDecoder)}readBuf(){return zr(Xo(this.restDecoder))}readJSON(){return JSON.parse(Za(this.restDecoder))}readKey(){return Za(this.restDecoder)}}class Rs{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Dt(this.restDecoder),this.dsCurrVal}readDsLen(){let t=Dt(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class ct extends Rs{constructor(t){super(t);this.keys=[],Dt(t),this.keyClockDecoder=new zt(Xo(t)),this.clientDecoder=new bt(Xo(t)),this.leftClockDecoder=new zt(Xo(t)),this.rightClockDecoder=new zt(Xo(t)),this.infoDecoder=new Se(Xo(t),rt),this.stringDecoder=new bn(Xo(t)),this.parentInfoDecoder=new Se(Xo(t),rt),this.typeRefDecoder=new bt(Xo(t)),this.lenDecoder=new bt(Xo(t))}readLeftID(){return new ot(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ot(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return yt(this.restDecoder)}readBuf(){return Xo(this.restDecoder)}readJSON(){return yt(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];else{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class rr{constructor(){this.restEncoder=Ka()}toUint8Array(){return br(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){_t(this.restEncoder,t)}writeDsLen(t){_t(this.restEncoder,t)}}class Nt extends rr{writeLeftID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeRightID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeClient(t){_t(this.restEncoder,t)}writeInfo(t){xe(this.restEncoder,t)}writeString(t){Ja(this.restEncoder,t)}writeParentInfo(t){_t(this.restEncoder,t?1:0)}writeTypeRef(t){_t(this.restEncoder,t)}writeLen(t){_t(this.restEncoder,t)}writeAny(t){mt(this.restEncoder,t)}writeBuf(t){Bo(this.restEncoder,t)}writeJSON(t){Ja(this.restEncoder,JSON.stringify(t))}writeKey(t){Ja(this.restEncoder,t)}}class sr{constructor(){this.restEncoder=Ka(),this.dsCurrVal=0}toUint8Array(){return br(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,_t(this.restEncoder,e)}writeDsLen(t){if(t===0)v();_t(this.restEncoder,t-1),this.dsCurrVal+=t}}class et extends sr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new qt,this.clientEncoder=new xt,this.leftClockEncoder=new qt,this.rightClockEncoder=new qt,this.infoEncoder=new be(xe),this.stringEncoder=new wn,this.parentInfoEncoder=new be(xe),this.typeRefEncoder=new xt,this.lenEncoder=new xt}toUint8Array(){let t=Ka();return _t(t,0),Bo(t,this.keyClockEncoder.toUint8Array()),Bo(t,this.clientEncoder.toUint8Array()),Bo(t,this.leftClockEncoder.toUint8Array()),Bo(t,this.rightClockEncoder.toUint8Array()),Bo(t,br(this.infoEncoder)),Bo(t,this.stringEncoder.toUint8Array()),Bo(t,br(this.parentInfoEncoder)),Bo(t,this.typeRefEncoder.toUint8Array()),Bo(t,this.lenEncoder.toUint8Array()),jt(t,br(this.restEncoder)),br(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){mt(this.restEncoder,t)}writeBuf(t){Bo(this.restEncoder,t)}writeJSON(t){mt(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);if(e===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t);else this.keyClockEncoder.write(e)}}var qo=(t,e,r,s)=>{s=Z(s,e[0].id.clock);let i=P(e,s);_t(t.restEncoder,e.length-i),t.writeClient(r),_t(t.restEncoder,s);let o=e[i];o.write(t,s-o.id.clock);for(let c=i+1;c<e.length;c++)e[c].write(t,0)},ir=(t,e,r)=>{let s=new Map;r.forEach((i,o)=>{if(b(e,o)>i)s.set(o,i)}),tn(e).forEach((i,o)=>{if(!r.has(o))s.set(o,0)}),_t(t.restEncoder,s.size),j(s.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{qo(t,e.clients.get(i),i,o)})},Go=(t,e)=>{let r=A(),s=Dt(t.restDecoder);for(let i=0;i<s;i++){let o=Dt(t.restDecoder),c=Array(o),l=t.readClient(),h=Dt(t.restDecoder);r.set(l,{i:0,refs:c});for(let f=0;f<o;f++){let a=t.readInfo();switch(Vt&a){case 0:{let u=t.readLen();c[f]=new V(m(l,h),u),h+=u;break}case 10:{let u=Dt(t.restDecoder);c[f]=new M(m(l,h),u),h+=u;break}default:{let u=(a&(F|D))===0,d=new y(m(l,h),null,(a&D)===D?t.readLeftID():null,null,(a&F)===F?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(a&dt)===dt?t.readString():null,mi(t,a));c[f]=d,h+=d.length}}}}return r},zo=(t,e,r)=>{let s=[],i=j(r.keys()).sort((p,g)=>p-g);if(i.length===0)return null;let o=()=>{if(i.length===0)return null;let p=r.get(i[i.length-1]);while(p.refs.length===p.i)if(i.pop(),i.length>0)p=r.get(i[i.length-1]);else return null;return p},c=o();if(c===null)return null;let l=new or,h=new Map,f=(p,g)=>{let w=h.get(p);if(w==null||w>g)h.set(p,g)},a=c.refs[c.i++],u=new Map,d=()=>{for(let p of s){let g=p.id.client,w=r.get(g);if(w)w.i--,l.clients.set(g,w.refs.slice(w.i)),r.delete(g),w.i=0,w.refs=[];else l.clients.set(g,[p]);i=i.filter((C)=>C!==g)}s.length=0};while(!0){if(a.constructor!==M){let g=q(u,a.id.client,()=>b(e,a.id.client))-a.id.clock;if(g<0)s.push(a),f(a.id.client,a.id.clock-1),d();else{let w=a.getMissing(t,e);if(w!==null){s.push(a);let C=r.get(w)||{refs:[],i:0};if(C.refs.length===C.i)f(w,b(e,w)),d();else{a=C.refs[C.i++];continue}}else if(g===0||g<a.length)a.integrate(t,g),u.set(a.id.client,a.id.clock+a.length)}}if(s.length>0)a=s.pop();else if(c!==null&&c.i<c.refs.length)a=c.refs[c.i++];else if(c=o(),c===null)break;else a=c.refs[c.i++]}if(l.clients.size>0){let p=new et;return ir(p,l,new Map),_t(p.restEncoder,0),{missing:h,update:p.toUint8Array()}}return null},Ho=(t,e)=>ir(t,e.doc.store,e.beforeState),Jo=(t,e,r,s=new ct(t))=>x(e,(i)=>{i.local=!1;let o=!1,c=i.doc,l=c.store,h=Go(s,c),f=zo(i,l,h),a=l.pendingStructs;if(a){for(let[d,p]of a.missing)if(p<b(l,d)){o=!0;break}if(f){for(let[d,p]of f.missing){let g=a.missing.get(d);if(g==null||g>p)a.missing.set(d,p)}a.update=Je([a.update,f.update])}}else l.pendingStructs=f;let u=ys(s,i,l);if(l.pendingDs){let d=new ct(Ya(l.pendingDs));Dt(d.restDecoder);let p=ys(d,i,l);if(u&&p)l.pendingDs=Je([u,p]);else l.pendingDs=u||p}else l.pendingDs=u;if(o){let d=l.pendingStructs.update;l.pendingStructs=null,Ls(i.doc,d)}},r,!1);var Ls=(t,e,r,s=ct)=>{let i=Ya(e);Jo(i,t,r,new s(i))},KI=(t,e,r)=>Ls(t,e,r,nr),Po=(t,e,r=new Map)=>{ir(t,e.store,r),vt(t,jo(e.store))},Ko=(t,e=new Uint8Array([0]),r=new et)=>{let s=Vs(e);Po(r,t,s);let i=[r.toUint8Array()];if(t.store.pendingDs)i.push(t.store.pendingDs);if(t.store.pendingStructs)i.push(ac(t.store.pendingStructs.update,e));if(i.length>1){if(r.constructor===Nt)return cc(i.map((o,c)=>c===0?o:uc(o)));else if(r.constructor===et)return Je(i)}return i[0]},JI=(t,e)=>Ko(t,e,new Nt),Wo=(t)=>{let e=new Map,r=Dt(t.restDecoder);for(let s=0;s<r;s++){let i=Dt(t.restDecoder),o=Dt(t.restDecoder);e.set(i,o)}return e},Vs=(t)=>Wo(new er(Ya(t))),Ms=(t,e)=>(_t(t.restEncoder,e.size),j(e.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{_t(t.restEncoder,r),_t(t.restEncoder,s)}),t),Zo=(t,e)=>Ms(t,tn(e.store)),Qo=(t,e=new sr)=>{if(t instanceof Map)Ms(e,t);else Zo(e,t);return e.toUint8Array()},YI=(t)=>Qo(t,new rr);class $s{constructor(){this.l=[]}}var bs=()=>new $s,ks=(t,e)=>t.l.push(e),_s=(t,e)=>{let r=t.l,s=r.length;if(t.l=r.filter((i)=>e!==i),s===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},Fs=(t,e,r)=>Kt(t.l,[e,r]);class ot{constructor(t,e){this.client=t,this.clock=e}}var $e=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,m=(t,e)=>new ot(t,e);var js=(t)=>{for(let[e,r]of t.doc.share.entries())if(r===t)return e;throw v()},He=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class qs{constructor(t,e,r,s=0){this.type=t,this.tname=e,this.item=r,this.assoc=s}}class Gs{constructor(t,e,r=0){this.type=t,this.index=e,this.assoc=r}}var Yo=(t,e,r=0)=>new Gs(t,e,r),Fe=(t,e,r)=>{let s=null,i=null;if(t._item===null)i=js(t);else s=m(t._item.id.client,t._item.id.clock);return new qs(s,i,e,r)},Q0=(t,e,r=0)=>{let s=t._start;if(r<0){if(e===0)return Fe(t,null,r);e--}while(s!==null){if(!s.deleted&&s.countable){if(s.length>e)return Fe(t,m(s.id.client,s.id.clock+e),r);e-=s.length}if(s.right===null&&r<0)return Fe(t,s.lastId,r);s=s.right}return Fe(t,null,r)};var tc=(t,e)=>{let r=Ct(t,e),s=e.clock-r.id.clock;return{item:r,diff:s}},Mg=(t,e,r=!0)=>{let s=e.store,{item:i,type:o,tname:c,assoc:l}=t,h=null,f=0;if(i!==null){if(b(s,i.client)<=i.clock)return null;let a=r?Qn(s,i):tc(s,i),u=a.item;if(!(u instanceof y))return null;if(h=u.parent,h._item===null||!h._item.deleted){f=u.deleted||!u.countable?0:a.diff+(l>=0?0:1);let d=u.left;while(d!==null){if(!d.deleted&&d.countable)f+=d.length;d=d.left}}}else{if(c!==null)h=e.get(c);else if(o!==null){if(b(s,o.client)<=o.clock)return null;let{item:a}=r?Qn(s,o):{item:Ct(s,o)};if(a instanceof y&&a.content instanceof W)h=a.content.type;else return null}else throw v();if(l>=0)f=h._length;else f=0}return Yo(h,f,t.assoc)};class zs{constructor(t,e){this.ds=t,this.sv=e}}var ec=(t,e)=>new zs(t,e),$l=ec(vs(),new Map);var At=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ce(e.ds,t.id),Zn=(t,e)=>{let r=q(t.meta,Zn,G),s=t.doc.store;if(!r.has(e))e.sv.forEach((i,o)=>{if(i<b(s,o))N(t,m(o,i))}),Bt(t,e.ds,(i)=>{}),r.add(e)};class or{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var tn=(t)=>{let e=new Map;return t.clients.forEach((r,s)=>{let i=r[r.length-1];e.set(s,i.id.clock+i.length)}),e},b=(t,e)=>{let r=t.clients.get(e);if(r===void 0)return 0;let s=r[r.length-1];return s.id.clock+s.length},Hs=(t,e)=>{let r=t.clients.get(e.id.client);if(r===void 0)r=[],t.clients.set(e.id.client,r);else{let s=r[r.length-1];if(s.id.clock+s.length!==e.id.clock)throw v()}r.push(e)},P=(t,e)=>{let r=0,s=t.length-1,i=t[s],o=i.id.clock;if(o===e)return s;let c=os(e/(o+i.length-1)*s);while(r<=s){if(i=t[c],o=i.id.clock,o<=e){if(e<o+i.length)return c;r=c+1}else s=c-1;c=os((r+s)/2)}throw v()},nc=(t,e)=>{let r=t.clients.get(e.client);return r[P(r,e.clock)]},Ct=nc,Xn=(t,e,r)=>{let s=P(e,r),i=e[s];if(i.id.clock<r&&i instanceof y)return e.splice(s+1,0,Ye(t,i,r-i.id.clock)),s+1;return s},N=(t,e)=>{let r=t.doc.store.clients.get(e.client);return r[Xn(t,r,e.clock)]},Ss=(t,e,r)=>{let s=e.clients.get(r.client),i=P(s,r.clock),o=s[i];if(r.clock!==o.id.clock+o.length-1&&o.constructor!==V)s.splice(i+1,0,Ye(t,o,r.clock-o.id.clock+1));return o},rc=(t,e,r)=>{let s=t.clients.get(e.id.client);s[P(s,e.id.clock)]=r},Js=(t,e,r,s,i)=>{if(s===0)return;let o=r+s,c=Xn(t,e,r),l;do{if(l=e[c++],o<l.id.clock+l.length)Xn(t,e,o);i(l)}while(c<e.length&&e[c].id.clock<o)};class Ps{constructor(t,e,r){this.doc=t,this.deleteSet=new ht,this.beforeState=tn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var Es=(t,e)=>{if(e.deleteSet.clients.size===0&&!Ar(e.afterState,(r,s)=>e.beforeState.get(s)!==r))return!1;return Yn(e.deleteSet),Ho(t,e),vt(t,e.deleteSet),!0},Is=(t,e,r)=>{let s=e._item;if(s===null||s.id.clock<(t.beforeState.get(s.id.client)||0)&&!s.deleted)q(t.changed,e,G).add(r)},Ge=(t,e)=>{let r=t[e],s=t[e-1],i=e;for(;i>0;r=s,s=t[--i-1]){if(s.deleted===r.deleted&&s.constructor===r.constructor){if(s.mergeWith(r)){if(r instanceof y&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r)r.parent._map.set(r.parentSub,s);continue}}break}let o=e-i;if(o)t.splice(e+1-o,o);return o},sc=(t,e,r)=>{for(let[s,i]of t.clients.entries()){let o=e.clients.get(s);for(let c=i.length-1;c>=0;c--){let l=i[c],h=l.clock+l.len;for(let f=P(o,l.clock),a=o[f];f<o.length&&a.id.clock<h;a=o[++f]){let u=o[f];if(l.clock+l.len<=u.id.clock)break;if(u instanceof y&&u.deleted&&!u.keep&&r(u))u.gc(e,!1)}}}},ic=(t,e)=>{t.clients.forEach((r,s)=>{let i=e.clients.get(s);for(let o=r.length-1;o>=0;o--){let c=r[o],l=ue(i.length-1,1+P(i,c.clock+c.len-1));for(let h=l,f=i[h];h>0&&f.id.clock>=c.clock;f=i[h])h-=1+Ge(i,h)}})};var Ks=(t,e)=>{if(e<t.length){let r=t[e],s=r.doc,i=s.store,{deleteSet:o,_mergeStructs:c}=r;try{Yn(o),r.afterState=tn(r.doc.store),s.emit("beforeObserverCalls",[r,s]);let l=[];r.changed.forEach((h,f)=>l.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(r,h)})),l.push(()=>{r.changedParentTypes.forEach((h,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))l.push(()=>{h=h.filter((a)=>a.target._item===null||!a.target._item.deleted),h.forEach((a)=>{a.currentTarget=f,a._path=null}),h.sort((a,u)=>a.path.length-u.path.length),Fs(f._dEH,h,r)})}),l.push(()=>s.emit("afterTransaction",[r,s])),l.push(()=>{if(r._needFormattingCleanup)_c(r)})}),Kt(l,[])}finally{if(s.gc)sc(o,i,s.gcFilter);ic(o,i),r.afterState.forEach((a,u)=>{let d=r.beforeState.get(u)||0;if(d!==a){let p=i.clients.get(u),g=Z(P(p,d),1);for(let w=p.length-1;w>=g;)w-=1+Ge(p,w)}});for(let a=c.length-1;a>=0;a--){let{client:u,clock:d}=c[a].id,p=i.clients.get(u),g=P(p,d);if(g+1<p.length){if(Ge(p,g+1)>1)continue}if(g>0)Ge(p,g)}if(!r.local&&r.afterState.get(s.clientID)!==r.beforeState.get(s.clientID))gs(Tt,Yt,"[yjs] ",te,ee,"Changed the client-id because another client seems to be using it."),s.clientID=Ns();if(s.emit("afterTransactionCleanup",[r,s]),s._observers.has("update")){let a=new Nt;if(Es(a,r))s.emit("update",[a.toUint8Array(),r.origin,s,r])}if(s._observers.has("updateV2")){let a=new et;if(Es(a,r))s.emit("updateV2",[a.toUint8Array(),r.origin,s,r])}let{subdocsAdded:l,subdocsLoaded:h,subdocsRemoved:f}=r;if(l.size>0||f.size>0||h.size>0)l.forEach((a)=>{if(a.clientID=s.clientID,a.collectionid==null)a.collectionid=s.collectionid;s.subdocs.add(a)}),f.forEach((a)=>s.subdocs.delete(a)),s.emit("subdocs",[{loaded:h,added:l,removed:f},s,r]),f.forEach((a)=>a.destroy());if(t.length<=e+1)s._transactionCleanups=[],s.emit("afterAllTransactions",[s,t]);else Ks(t,e+1)}}},x=(t,e,r=null,s=!0)=>{let i=t._transactionCleanups,o=!1,c=null;if(t._transaction===null){if(o=!0,t._transaction=new Ps(t,r,s),i.push(t._transaction),i.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{c=e(t._transaction)}finally{if(o){let l=t._transaction===i[0];if(t._transaction=null,l)Ks(i,0)}}return c};class Ws{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Us=(t,e,r)=>{Bt(t,r.deletions,(s)=>{if(s instanceof y&&e.scope.some((i)=>i===t.doc||He(i,s)))ur(s,!1)})},Ts=(t,e,r)=>{let s=null,{doc:i,scope:o}=t;x(i,(l)=>{while(e.length>0&&t.currStackItem===null){let h=i.store,f=e.pop(),a=new Set,u=[],d=!1;Bt(l,f.insertions,(p)=>{if(p instanceof y){if(p.redone!==null){let{item:g,diff:w}=Qn(h,p.id);if(w>0)g=N(l,m(g.id.client,g.id.clock+w));p=g}if(!p.deleted&&o.some((g)=>g===l.doc||He(g,p)))u.push(p)}}),Bt(l,f.deletions,(p)=>{if(p instanceof y&&o.some((g)=>g===l.doc||He(g,p))&&!ce(f.insertions,p.id))a.add(p)}),a.forEach((p)=>{d=gi(l,p,a,f.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let p=u.length-1;p>=0;p--){let g=u[p];if(t.deleteFilter(g))g.delete(l),d=!0}t.currStackItem=d?f:null}l.changed.forEach((h,f)=>{if(h.has(null)&&f._searchMarker)f._searchMarker.length=0}),s=l},t);let c=t.currStackItem;if(c!=null){let l=s.changedParentTypes;t.emit("stack-item-popped",[{stackItem:c,type:r,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return c};class S2 extends Ie{constructor(t,{captureTimeout:e=500,captureTransaction:r=(l)=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=Q(t)?t[0].doc:t instanceof yd?t:t.doc}={}){super();this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(l)=>{if(!this.captureTransaction(l)||!this.scope.some((w)=>l.changedParentTypes.has(w)||w===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let h=this.undoing,f=this.redoing,a=h?this.redoStack:this.undoStack;if(h)this.stopCapturing();else if(!f)this.clear(!1,!0);let u=new ht;l.afterState.forEach((w,C)=>{let k=l.beforeState.get(C)||0,dr=w-k;if(dr>0)ne(u,C,k,dr)});let d=_u(),p=!1;if(this.lastChange>0&&d-this.lastChange<this.captureTimeout&&a.length>0&&!h&&!f){let w=a[a.length-1];w.deletions=Wn([w.deletions,l.deleteSet]),w.insertions=Wn([w.insertions,u])}else a.push(new Ws(l.deleteSet,u)),p=!0;if(!h&&!f)this.lastChange=d;Bt(l,l.deleteSet,(w)=>{if(w instanceof y&&this.scope.some((C)=>C===l.doc||He(C,w)))ur(w,!0)});let g=[{stackItem:a[a.length-1],origin:l.origin,type:h?"redo":"undo",changedParentTypes:l.changedParentTypes},this];if(p)this.emit("stack-item-added",g);else this.emit("stack-item-updated",g)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let e=new Set(this.scope);t=Q(t)?t:[t],t.forEach((r)=>{if(!e.has(r)){if(e.add(r),r instanceof I?r.doc!==this.doc:r!==this.doc)Pn("[yjs#509] Not same Y.Doc");this.scope.push(r)}})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){if(t&&this.canUndo()||e&&this.canRedo())this.doc.transact((r)=>{if(t)this.undoStack.forEach((s)=>Us(r,this,s)),this.undoStack=[];if(e)this.redoStack.forEach((s)=>Us(r,this,s)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Ts(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Ts(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*oc(t){let e=Dt(t.restDecoder);for(let r=0;r<e;r++){let s=Dt(t.restDecoder),i=t.readClient(),o=Dt(t.restDecoder);for(let c=0;c<s;c++){let l=t.readInfo();if(l===10){let h=Dt(t.restDecoder);yield new M(m(i,o),h),o+=h}else if((Vt&l)!==0){let h=(l&(F|D))===0,f=new y(m(i,o),null,(l&D)===D?t.readLeftID():null,null,(l&F)===F?t.readRightID():null,h?t.readParentInfo()?t.readString():t.readLeftID():null,h&&(l&dt)===dt?t.readString():null,mi(t,l));yield f,o+=f.length}else{let h=t.readLen();yield new V(m(i,o),h),o+=h}}}}class en{constructor(t,e){this.gen=oc(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===M);return this.curr}}class nn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var cc=(t)=>Je(t,nr,Nt);var lc=(t,e)=>{if(t.constructor===V){let{client:r,clock:s}=t.id;return new V(m(r,s+e),t.length-e)}else if(t.constructor===M){let{client:r,clock:s}=t.id;return new M(m(r,s+e),t.length-e)}else{let r=t,{client:s,clock:i}=r.id;return new y(m(s,i+e),null,m(s,i+e-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(e))}},Je=(t,e=ct,r=et)=>{if(t.length===1)return t[0];let s=t.map((a)=>new e(Ya(a))),i=s.map((a)=>new en(a,!0)),o=null,c=new r,l=new nn(c);while(!0){if(i=i.filter((d)=>d.curr!==null),i.sort((d,p)=>{if(d.curr.id.client===p.curr.id.client){let g=d.curr.id.clock-p.curr.id.clock;if(g===0)return d.curr.constructor===p.curr.constructor?0:d.curr.constructor===M?1:-1;else return g}else return p.curr.id.client-d.curr.id.client}),i.length===0)break;let a=i[0],u=a.curr.id.client;if(o!==null){let d=a.curr,p=!1;while(d!==null&&d.id.clock+d.length<=o.struct.id.clock+o.struct.length&&d.id.client>=o.struct.id.client)d=a.next(),p=!0;if(d===null||d.id.client!==u||p&&d.id.clock>o.struct.id.clock+o.struct.length)continue;if(u!==o.struct.id.client)Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next();else if(o.struct.id.clock+o.struct.length<d.id.clock)if(o.struct.constructor===M)o.struct.length=d.id.clock+d.length-o.struct.id.clock;else{Y(l,o.struct,o.offset);let g=d.id.clock-o.struct.id.clock-o.struct.length;o={struct:new M(m(u,o.struct.id.clock+o.struct.length),g),offset:0}}else{let g=o.struct.id.clock+o.struct.length-d.id.clock;if(g>0)if(o.struct.constructor===M)o.struct.length-=g;else d=lc(d,g);if(!o.struct.mergeWith(d))Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next()}}else o={struct:a.curr,offset:0},a.next();for(let d=a.curr;d!==null&&d.id.client===u&&d.id.clock===o.struct.id.clock+o.struct.length&&d.constructor!==M;d=a.next())Y(l,o.struct,o.offset),o={struct:d,offset:0}}if(o!==null)Y(l,o.struct,o.offset),o=null;cr(l);let h=s.map((a)=>tr(a)),f=Wn(h);return vt(c,f),c.toUint8Array()},ac=(t,e,r=ct,s=et)=>{let i=Vs(e),o=new s,c=new nn(o),l=new r(Ya(t)),h=new en(l,!1);while(h.curr){let a=h.curr,u=a.id.client,d=i.get(u)||0;if(h.curr.constructor===M){h.next();continue}if(a.id.clock+a.length>d){Y(c,a,Z(d-a.id.clock,0)),h.next();while(h.curr&&h.curr.id.client===u)Y(c,h.curr,0),h.next()}else while(h.curr&&h.curr.id.client===u&&h.curr.id.clock+h.curr.length<=d)h.next()}cr(c);let f=tr(l);return vt(o,f),o.toUint8Array()};var Zs=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:br(t.encoder.restEncoder)}),t.encoder.restEncoder=Ka(),t.written=0},Y=(t,e,r)=>{if(t.written>0&&t.currClient!==e.id.client)Zs(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),_t(t.encoder.restEncoder,e.id.clock+r);e.write(t.encoder,r),t.written++},cr=(t)=>{Zs(t);let e=t.encoder.restEncoder;_t(e,t.clientStructs.length);for(let r=0;r<t.clientStructs.length;r++){let s=t.clientStructs[r];_t(e,s.written),jt(e,s.restEncoder)}},hc=(t,e,r,s)=>{let i=new r(Ya(t)),o=new en(i,!1),c=new s,l=new nn(c);for(let f=o.curr;f!==null;f=o.next())Y(l,e(f),0);cr(l);let h=tr(i);return vt(c,h),c.toUint8Array()};var uc=(t)=>hc(t,$r,ct,Nt),As="You must not compute changes after the event-handler fired.";class le{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=dc(this.currentTarget,this.target))}deletes(t){return ce(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw R(As);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((s)=>{if(s!==null){let i=e._map.get(s),o,c;if(this.adds(i)){let l=i.left;while(l!==null&&this.adds(l))l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=ge(l.content.getContent());else return;else if(l!==null&&this.deletes(l))o="update",c=ge(l.content.getContent());else o="add",c=void 0}else if(this.deletes(i))o="delete",c=ge(i.content.getContent());else return;t.set(s,{action:o,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw R(As);let e=this.target,r=G(),s=G(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(e).has(null)){let c=null,l=()=>{if(c)i.push(c)};for(let h=e._start;h!==null;h=h.right)if(h.deleted){if(this.deletes(h)&&!this.adds(h)){if(c===null||c.delete===void 0)l(),c={delete:0};c.delete+=h.length,s.add(h)}}else if(this.adds(h)){if(c===null||c.insert===void 0)l(),c={insert:[]};c.insert=c.insert.concat(h.content.getContent()),r.add(h)}else{if(c===null||c.retain===void 0)l(),c={retain:0};c.retain+=h.length}if(c!==null&&c.retain===void 0)l()}this._changes=t}return t}}var dc=(t,e)=>{let r=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)r.unshift(e._item.parentSub);else{let s=0,i=e._item.parent._start;while(i!==e._item&&i!==null){if(!i.deleted&&i.countable)s+=i.length;i=i.right}r.unshift(s)}e=e._item.parent}return r},O=()=>{Pn("Invalid access: Add Yjs type to a document before reading data.")},Xs=80,lr=0;class Qs{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=lr++}}var fc=(t)=>{t.timestamp=lr++},Ys=(t,e,r)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=r,t.timestamp=lr++},pc=(t,e,r)=>{if(t.length>=Xs){let s=t.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return Ys(s,e,r),s}else{let s=new Qs(e,r);return t.push(s),s}},rn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let r=t._searchMarker.length===0?null:t._searchMarker.reduce((o,c)=>nt(e-o.index)<nt(e-c.index)?o:c),s=t._start,i=0;if(r!==null)s=r.p,i=r.index,fc(r);while(s.right!==null&&i<e){if(!s.deleted&&s.countable){if(e<i+s.length)break;i+=s.length}s=s.right}while(s.left!==null&&i>e)if(s=s.left,!s.deleted&&s.countable)i-=s.length;while(s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock)if(s=s.left,!s.deleted&&s.countable)i-=s.length;if(r!==null&&nt(r.index-i)<s.parent.length/Xs)return Ys(r,s,i),r;else return pc(t._searchMarker,s,i)},re=(t,e,r)=>{for(let s=t.length-1;s>=0;s--){let i=t[s];if(r>0){let o=i.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)i.index-=o.length;if(o===null||o.marker===!0){t.splice(s,1);continue}i.p=o,o.marker=!0}if(e<i.index||r>0&&e===i.index)i.index=Z(e,i.index+r)}};var sn=(t,e,r)=>{let s=t,i=e.changedParentTypes;while(!0){if(q(i,t,()=>[]).push(r),t._item===null)break;t=t._item.parent}Fs(s._eH,r,e)};class I{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=bs(),this._dEH=bs(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw L()}clone(){throw L()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted)t=t.right;return t}_callObserver(t,e){if(!t.local&&this._searchMarker)this._searchMarker.length=0}observe(t){ks(this._eH,t)}observeDeep(t){ks(this._dEH,t)}unobserve(t){_s(this._eH,t)}unobserveDeep(t){_s(this._dEH,t)}toJSON(){}}var ti=(t,e,r)=>{if(t.doc??O(),e<0)e=t._length+e;if(r<0)r=t._length+r;let s=r-e,i=[],o=t._start;while(o!==null&&s>0){if(o.countable&&!o.deleted){let c=o.content.getContent();if(c.length<=e)e-=c.length;else{for(let l=e;l<c.length&&s>0;l++)i.push(c[l]),s--;e=0}}o=o.right}return i},ei=(t)=>{t.doc??O();let e=[],r=t._start;while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)e.push(s[i])}r=r.right}return e};var se=(t,e)=>{let r=0,s=t._start;t.doc??O();while(s!==null){if(s.countable&&!s.deleted){let i=s.content.getContent();for(let o=0;o<i.length;o++)e(i[o],r++,t)}s=s.right}},ni=(t,e)=>{let r=[];return se(t,(s,i)=>{r.push(e(s,i,t))}),r},gc=(t)=>{let e=t._start,r=null,s=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};r=e.content.getContent(),s=0,e=e.right}let i=r[s++];if(r.length<=s)r=null;return{done:!1,value:i}}}},ri=(t,e)=>{t.doc??O();let r=rn(t,e),s=t._start;if(r!==null)s=r.p,e-=r.index;for(;s!==null;s=s.right)if(!s.deleted&&s.countable){if(e<s.length)return s.content.getContent()[e];e-=s.length}},Pe=(t,e,r,s)=>{let i=r,o=t.doc,{clientID:c,store:l}=o,h=r===null?e._start:r.right,f=[],a=()=>{if(f.length>0)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new at(f)),i.integrate(t,0),f=[]};s.forEach((u)=>{if(u===null)f.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(u);break;default:switch(a(),u.constructor){case Uint8Array:case ArrayBuffer:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new ae(new Uint8Array(u))),i.integrate(t,0);break;case yd:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new he(u)),i.integrate(t,0);break;default:if(u instanceof I)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new W(u)),i.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),a()},si=()=>R("Length exceeded!"),ii=(t,e,r,s)=>{if(r>e._length)throw si();if(r===0){if(e._searchMarker)re(e._searchMarker,r,s.length);return Pe(t,e,null,s)}let i=r,o=rn(e,r),c=e._start;if(o!==null){if(c=o.p,r-=o.index,r===0)c=c.prev,r+=c&&c.countable&&!c.deleted?c.length:0}for(;c!==null;c=c.right)if(!c.deleted&&c.countable){if(r<=c.length){if(r<c.length)N(t,m(c.id.client,c.id.clock+r));break}r-=c.length}if(e._searchMarker)re(e._searchMarker,i,s.length);return Pe(t,e,c,s)},mc=(t,e,r)=>{let i=(e._searchMarker||[]).reduce((o,c)=>c.index>o.index?c:o,{index:0,p:e._start}).p;if(i)while(i.right)i=i.right;return Pe(t,e,i,r)},oi=(t,e,r,s)=>{if(s===0)return;let i=r,o=s,c=rn(e,r),l=e._start;if(c!==null)l=c.p,r-=c.index;for(;l!==null&&r>0;l=l.right)if(!l.deleted&&l.countable){if(r<l.length)N(t,m(l.id.client,l.id.clock+r));r-=l.length}while(s>0&&l!==null){if(!l.deleted){if(s<l.length)N(t,m(l.id.client,l.id.clock+s));l.delete(t),s-=l.length}l=l.right}if(s>0)throw si();if(e._searchMarker)re(e._searchMarker,i,-o+s)},Ke=(t,e,r)=>{let s=e._map.get(r);if(s!==void 0)s.delete(t)},ar=(t,e,r,s)=>{let i=e._map.get(r)||null,o=t.doc,c=o.clientID,l;if(s==null)l=new at([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new at([s]);break;case Uint8Array:l=new ae(s);break;case yd:l=new he(s);break;default:if(s instanceof I)l=new W(s);else throw Error("Unexpected content type")}new y(m(c,b(o.store,c)),i,i&&i.lastId,null,null,e,r,l).integrate(t,0)},hr=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},ci=(t)=>{let e={};return t.doc??O(),t._map.forEach((r,s)=>{if(!r.deleted)e[s]=r.content.getContent()[r.length-1]}),e},li=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted};var wc=(t,e)=>{let r={};return t._map.forEach((s,i)=>{let o=s;while(o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0)))o=o.left;if(o!==null&&At(o,e))r[i]=o.content.getContent()[o.length-1]}),r},je=(t)=>(t.doc??O(),xs(t._map.entries(),(e)=>!e[1].deleted));class Cy extends le{}class ba extends I{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new ba;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ba}clone(){let t=new ba;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._length}_callObserver(t,e){super._callObserver(t,e),sn(this,t,new Cy(this,t))}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{ii(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)x(this.doc,(e)=>{mc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ri(this,t)}toArray(){return ei(this)}slice(t=0,e=this.length){return ti(this,t,e)}toJSON(){return this.map((t)=>t instanceof I?t.toJSON():t)}map(t){return ni(this,t)}forEach(t){se(this,t)}[Symbol.iterator](){return gc(this)}_write(t){t.writeTypeRef($c)}}var xc=(t)=>new ba;class e_ extends le{constructor(t,e,r){super(t,e);this.keysChanged=r}}class rs extends I{constructor(t){super();if(this._prelimContent=null,t===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new rs}clone(){let t=new rs;return this.forEach((e,r)=>{t.set(r,e instanceof I?e.clone():e)}),t}_callObserver(t,e){sn(this,t,new e_(this,t,e))}toJSON(){this.doc??O();let t={};return this._map.forEach((e,r)=>{if(!e.deleted){let s=e.content.getContent()[e.length-1];t[r]=s instanceof I?s.toJSON():s}}),t}get size(){return[...je(this)].length}keys(){return Me(je(this),(t)=>t[0])}values(){return Me(je(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Me(je(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??O(),this._map.forEach((e,r)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return hr(this,t)}has(t){return li(this,t)}clear(){if(this.doc!==null)x(this.doc,(t)=>{this.forEach(function(e,r,s){Ke(t,s,r)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(Fc)}}var yc=(t)=>new rs,tt=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&In(t,e);class We{constructor(t,e,r,s){this.left=t,this.right=e,this.index=r,this.currentAttributes=s}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)Rt(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Cs=(t,e,r)=>{while(e.right!==null&&r>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)Rt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(r<e.right.length)N(t,m(e.right.id.client,e.right.id.clock+r));e.index+=e.right.length,r-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},qe=(t,e,r,s)=>{let i=new Map,o=s?rn(e,r):null;if(o){let c=new We(o.p.left,o.p,o.index,i);return Cs(t,c,r-o.index)}else{let c=new We(null,e._start,0,i);return Cs(t,c,r)}},ai=(t,e,r,s)=>{while(r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===U&&tt(s.get(r.right.content.key),r.right.content.value))){if(!r.right.deleted)s.delete(r.right.content.key);r.forward()}let i=t.doc,o=i.clientID;s.forEach((c,l)=>{let{left:h,right:f}=r,a=new y(m(o,b(i.store,o)),h,h&&h.lastId,f,f&&f.id,e,null,new U(l,c));a.integrate(t,0),r.right=a,r.forward()})},Rt=(t,e)=>{let{key:r,value:s}=e;if(s===null)t.delete(r);else t.set(r,s)},hi=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&tt(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},ui=(t,e,r,s)=>{let i=t.doc,o=i.clientID,c=new Map;for(let l in s){let h=s[l],f=r.currentAttributes.get(l)??null;if(!tt(f,h)){c.set(l,f);let{left:a,right:u}=r;r.right=new y(m(o,b(i.store,o)),a,a&&a.lastId,u,u&&u.id,e,null,new U(l,h)),r.right.integrate(t,0),r.forward()}}return c},Kn=(t,e,r,s,i)=>{r.currentAttributes.forEach((d,p)=>{if(i[p]===void 0)i[p]=null});let o=t.doc,c=o.clientID;hi(r,i);let l=ui(t,e,r,i),h=s.constructor===String?new K(s):s instanceof I?new W(s):new ut(s),{left:f,right:a,index:u}=r;if(e._searchMarker)re(e._searchMarker,r.index,h.getLength());a=new y(m(c,b(o.store,c)),f,f&&f.lastId,a,a&&a.id,e,null,h),a.integrate(t,0),r.right=a,r.index=u,r.forward(),ai(t,e,r,l)},Ds=(t,e,r,s,i)=>{let o=t.doc,c=o.clientID;hi(r,i);let l=ui(t,e,r,i);t:while(r.right!==null&&(s>0||l.size>0&&(r.right.deleted||r.right.content.constructor===U))){if(!r.right.deleted)switch(r.right.content.constructor){case U:{let{key:h,value:f}=r.right.content,a=i[h];if(a!==void 0){if(tt(a,f))l.delete(h);else{if(s===0)break t;l.set(h,f)}r.right.delete(t)}else r.currentAttributes.set(h,f);break}default:if(s<r.right.length)N(t,m(r.right.id.client,r.right.id.clock+s));s-=r.right.length;break}r.forward()}if(s>0){let h="";for(;s>0;s--)h+=`
|
|
3
|
+
${r.toString()}`)};class hs{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:Xt(t),h:e}),this}else(t){return this.if(De,t)}done(){return(t,e)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,e)}throw R("Unhandled pattern")}}}var Uo=(t)=>new hs(t),us=Uo(De).if(cs,(t,e)=>Te(e,hn,ft)).if(ls,(t,e)=>Jr(e)).if(So,(t,e)=>Bn(e)).if(_o,(t,e)=>BigInt(Te(e,hn,ft))).if(Ce,(t,e)=>St(e,Ae(e,t.shape))).if(ho,(t,e)=>{let r={};for(let s in t.shape){let i=t.shape[s];if(lo.check(i)){if(Bn(e))continue;i=i.shape}r[s]=us(i,e)}return r}).if(go,(t,e)=>{let r=[],s=On(e,0,42);for(let i=0;i<s;i++)r.push(St(e,t.shape));return r}).if(Wr,(t,e)=>Ae(e,t.shape)).if(Eo,(t,e)=>null).if(yo,(t,e)=>{let r=St(e,t.res);return()=>r}).if(ko,(t,e)=>St(e,Ae(e,[Et,It,Ve,as,jn,Le,Yr(Et),Qr(Ut("a","b","c"),Et)]))).if(fo,(t,e)=>{let r={},s=Te(e,0,3);for(let i=0;i<s;i++){let o=St(e,t.shape.keys),c=St(e,t.shape.values);r[o]=c}return r}).done(),St=(t,e)=>us(Xt(e),t);var it=typeof document<"u"?document:{};var bl=E((t)=>t.nodeType===Oo);var kl=typeof DOMParser<"u"?new DOMParser:null;var _l=E((t)=>t.nodeType===Ao);var Sl=E((t)=>t.nodeType===Co);var ds=(t)=>Tr(t,(e,r)=>`${r}:${e};`).join("");var{ELEMENT_NODE:Ao,TEXT_NODE:Co,CDATA_SECTION_NODE:El,COMMENT_NODE:Il,DOCUMENT_NODE:Do,DOCUMENT_TYPE_NODE:Ul,DOCUMENT_FRAGMENT_NODE:Oo}=it,Tl=E((t)=>t.nodeType===Do);var J=Symbol;var Yt=J(),te=J(),qn=J(),Gn=J(),zn=J(),ee=J(),Hn=J(),Tt=J(),Jn=J(),fs=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=0;for(;s<t.length;s++){let i=t[s];if(i===void 0)break;else if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}if(s>0)r.push(e.join(""));for(;s<t.length;s++){let i=t[s];if(!(i instanceof Symbol))r.push(i)}return r};var Al=_u();var Lo={[Yt]:H("font-weight","bold"),[te]:H("font-weight","normal"),[qn]:H("color","blue"),[zn]:H("color","green"),[Gn]:H("color","grey"),[ee]:H("color","red"),[Hn]:H("color","purple"),[Tt]:H("color","orange"),[Jn]:H("color","black")},Vo=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=A(),i=[],o=0;for(;o<t.length;o++){let c=t[o],l=Lo[c];if(l!==void 0)s.set(l.left,l.right);else{if(c===void 0)break;if(c.constructor===String||c.constructor===Number){let h=ds(s);if(o>0||h.length>0)e.push("%c"+c),r.push(h);else e.push(c)}else break}}if(o>0)i=r,i.unshift(e.join(""));for(;o<t.length;o++){let c=t[o];if(!(c instanceof Symbol))i.push(c)}return i},ps=Gr?Vo:fs,gs=(...t)=>{console.log(...ps(t)),ms.forEach((e)=>e.print(t))},Pn=(...t)=>{console.warn(...ps(t)),t.unshift(Tt),ms.forEach((e)=>e.print(t))};var ms=G();var ws=(t)=>({[Symbol.iterator](){return this},next:t}),xs=(t,e)=>ws(()=>{let r;do r=t.next();while(!r.done&&!e(r.value));return r}),Me=(t,e)=>ws(()=>{let{done:r,value:s}=t.next();return{done:r,value:r?void 0:e(s)}});class oe{constructor(t,e){this.clock=t,this.len=e}}class ht{constructor(){this.clients=new Map}}var Bt=(t,e,r)=>e.clients.forEach((s,i)=>{let o=t.doc.store.clients.get(i);if(o!=null){let c=o[o.length-1],l=c.id.clock+c.length;for(let h=0,f=s[h];h<s.length&&f.clock<l;f=s[++h])Js(t,o,f.clock,f.len,r)}}),Fo=(t,e)=>{let r=0,s=t.length-1;while(r<=s){let i=os((r+s)/2),o=t[i],c=o.clock;if(c<=e){if(e<c+o.len)return i;r=i+1}else s=i-1}return null},ce=(t,e)=>{let r=t.clients.get(e.client);return r!==void 0&&Fo(r,e.clock)!==null},Yn=(t)=>{t.clients.forEach((e)=>{e.sort((i,o)=>i.clock-o.clock);let r,s;for(r=1,s=1;r<e.length;r++){let i=e[s-1],o=e[r];if(i.clock+i.len>=o.clock)e[s-1]=new oe(i.clock,Z(i.len,o.clock+o.len-i.clock));else{if(s<r)e[s]=o;s++}}e.length=s})},Wn=(t)=>{let e=new ht;for(let r=0;r<t.length;r++)t[r].clients.forEach((s,i)=>{if(!e.clients.has(i)){let o=s.slice();for(let c=r+1;c<t.length;c++)gr(o,t[c].clients.get(i)||[]);e.clients.set(i,o)}});return Yn(e),e},ne=(t,e,r,s)=>{q(t.clients,e,()=>[]).push(new oe(r,s))},vs=()=>new ht,jo=(t)=>{let e=vs();return t.clients.forEach((r,s)=>{let i=[];for(let o=0;o<r.length;o++){let c=r[o];if(c.deleted){let l=c.id.clock,h=c.length;if(o+1<r.length)for(let f=r[o+1];o+1<r.length&&f.deleted;f=r[++o+1])h+=f.length;i.push(new oe(l,h))}}if(i.length>0)e.clients.set(s,i)}),e},vt=(t,e)=>{_t(t.restEncoder,e.clients.size),j(e.clients.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{t.resetDsCurVal(),_t(t.restEncoder,r);let i=s.length;_t(t.restEncoder,i);for(let o=0;o<i;o++){let c=s[o];t.writeDsClock(c.clock),t.writeDsLen(c.len)}})},tr=(t)=>{let e=new ht,r=Dt(t.restDecoder);for(let s=0;s<r;s++){t.resetDsCurVal();let i=Dt(t.restDecoder),o=Dt(t.restDecoder);if(o>0){let c=q(e.clients,i,()=>[]);for(let l=0;l<o;l++)c.push(new oe(t.readDsClock(),t.readDsLen()))}}return e},ys=(t,e,r)=>{let s=new ht,i=Dt(t.restDecoder);for(let o=0;o<i;o++){t.resetDsCurVal();let c=Dt(t.restDecoder),l=Dt(t.restDecoder),h=r.clients.get(c)||[],f=b(r,c);for(let a=0;a<l;a++){let u=t.readDsClock(),d=u+t.readDsLen();if(u<f){if(f<d)ne(s,c,f,d-f);let p=P(h,u),g=h[p];if(!g.deleted&&g.id.clock<u)h.splice(p+1,0,Ye(e,g,u-g.id.clock)),p++;while(p<h.length)if(g=h[p++],g.id.clock<d){if(!g.deleted){if(d<g.id.clock+g.length)h.splice(p,0,Ye(e,g,d-g.id.clock));g.delete(e)}}else break}else ne(s,c,u,d-u)}}if(s.clients.size>0){let o=new et;return _t(o.restEncoder,0),vt(o,s),o.toUint8Array()}return null};var Ns=kn;class yd extends Ie{constructor({guid:t=Dr(),collectionid:e=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super();this.gc=r,this.gcFilter=s,this.clientID=Ns(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new or,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=_n((h)=>{this.on("load",()=>{this.isLoaded=!0,h(this)})});let l=()=>_n((h)=>{let f=(a)=>{if(a===void 0||a===!0)this.off("sync",f),h()};this.on("sync",f)});this.on("sync",(h)=>{if(h===!1&&this.isSynced)this.whenSynced=l();if(this.isSynced=h===void 0||h===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)x(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(j(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return x(this,t,e)}get(t,e=I){let r=q(this.share,t,()=>{let i=new e;return i._integrate(this,null),i}),s=r.constructor;if(e!==I&&s!==e)if(s===I){let i=new e;i._map=r._map,r._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,ba)}getText(t=""){return this.get(t,ss)}getMap(t=""){return this.get(t,rs)}getXmlElement(t=""){return this.get(t,Ot)}getXmlFragment(t=""){return this.get(t,lt)}toJSON(){let t={};return this.share.forEach((e,r)=>{t[r]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,j(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new yd({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,x(t.parent.doc,(r)=>{let s=e.doc;if(!t.deleted)r.subdocsAdded.add(s);r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class er{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return Dt(this.restDecoder)}readDsLen(){return Dt(this.restDecoder)}}class nr extends er{readLeftID(){return m(Dt(this.restDecoder),Dt(this.restDecoder))}readRightID(){return m(Dt(this.restDecoder),Dt(this.restDecoder))}readClient(){return Dt(this.restDecoder)}readInfo(){return rt(this.restDecoder)}readString(){return Za(this.restDecoder)}readParentInfo(){return Dt(this.restDecoder)===1}readTypeRef(){return Dt(this.restDecoder)}readLen(){return Dt(this.restDecoder)}readAny(){return yt(this.restDecoder)}readBuf(){return zr(Xo(this.restDecoder))}readJSON(){return JSON.parse(Za(this.restDecoder))}readKey(){return Za(this.restDecoder)}}class Rs{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Dt(this.restDecoder),this.dsCurrVal}readDsLen(){let t=Dt(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class ct extends Rs{constructor(t){super(t);this.keys=[],Dt(t),this.keyClockDecoder=new zt(Xo(t)),this.clientDecoder=new bt(Xo(t)),this.leftClockDecoder=new zt(Xo(t)),this.rightClockDecoder=new zt(Xo(t)),this.infoDecoder=new Se(Xo(t),rt),this.stringDecoder=new bn(Xo(t)),this.parentInfoDecoder=new Se(Xo(t),rt),this.typeRefDecoder=new bt(Xo(t)),this.lenDecoder=new bt(Xo(t))}readLeftID(){return new ot(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ot(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return yt(this.restDecoder)}readBuf(){return Xo(this.restDecoder)}readJSON(){return yt(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];else{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class rr{constructor(){this.restEncoder=Ka()}toUint8Array(){return br(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){_t(this.restEncoder,t)}writeDsLen(t){_t(this.restEncoder,t)}}class Nt extends rr{writeLeftID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeRightID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeClient(t){_t(this.restEncoder,t)}writeInfo(t){xe(this.restEncoder,t)}writeString(t){Ja(this.restEncoder,t)}writeParentInfo(t){_t(this.restEncoder,t?1:0)}writeTypeRef(t){_t(this.restEncoder,t)}writeLen(t){_t(this.restEncoder,t)}writeAny(t){mt(this.restEncoder,t)}writeBuf(t){Bo(this.restEncoder,t)}writeJSON(t){Ja(this.restEncoder,JSON.stringify(t))}writeKey(t){Ja(this.restEncoder,t)}}class sr{constructor(){this.restEncoder=Ka(),this.dsCurrVal=0}toUint8Array(){return br(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,_t(this.restEncoder,e)}writeDsLen(t){if(t===0)v();_t(this.restEncoder,t-1),this.dsCurrVal+=t}}class et extends sr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new qt,this.clientEncoder=new xt,this.leftClockEncoder=new qt,this.rightClockEncoder=new qt,this.infoEncoder=new be(xe),this.stringEncoder=new wn,this.parentInfoEncoder=new be(xe),this.typeRefEncoder=new xt,this.lenEncoder=new xt}toUint8Array(){let t=Ka();return _t(t,0),Bo(t,this.keyClockEncoder.toUint8Array()),Bo(t,this.clientEncoder.toUint8Array()),Bo(t,this.leftClockEncoder.toUint8Array()),Bo(t,this.rightClockEncoder.toUint8Array()),Bo(t,br(this.infoEncoder)),Bo(t,this.stringEncoder.toUint8Array()),Bo(t,br(this.parentInfoEncoder)),Bo(t,this.typeRefEncoder.toUint8Array()),Bo(t,this.lenEncoder.toUint8Array()),jt(t,br(this.restEncoder)),br(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){mt(this.restEncoder,t)}writeBuf(t){Bo(this.restEncoder,t)}writeJSON(t){mt(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);if(e===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t);else this.keyClockEncoder.write(e)}}var qo=(t,e,r,s)=>{s=Z(s,e[0].id.clock);let i=P(e,s);_t(t.restEncoder,e.length-i),t.writeClient(r),_t(t.restEncoder,s);let o=e[i];o.write(t,s-o.id.clock);for(let c=i+1;c<e.length;c++)e[c].write(t,0)},ir=(t,e,r)=>{let s=new Map;r.forEach((i,o)=>{if(b(e,o)>i)s.set(o,i)}),tn(e).forEach((i,o)=>{if(!r.has(o))s.set(o,0)}),_t(t.restEncoder,s.size),j(s.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{qo(t,e.clients.get(i),i,o)})},Go=(t,e)=>{let r=A(),s=Dt(t.restDecoder);for(let i=0;i<s;i++){let o=Dt(t.restDecoder),c=Array(o),l=t.readClient(),h=Dt(t.restDecoder);r.set(l,{i:0,refs:c});for(let f=0;f<o;f++){let a=t.readInfo();switch(Vt&a){case 0:{let u=t.readLen();c[f]=new V(m(l,h),u),h+=u;break}case 10:{let u=Dt(t.restDecoder);c[f]=new M(m(l,h),u),h+=u;break}default:{let u=(a&(F|D))===0,d=new y(m(l,h),null,(a&D)===D?t.readLeftID():null,null,(a&F)===F?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(a&dt)===dt?t.readString():null,mi(t,a));c[f]=d,h+=d.length}}}}return r},zo=(t,e,r)=>{let s=[],i=j(r.keys()).sort((p,g)=>p-g);if(i.length===0)return null;let o=()=>{if(i.length===0)return null;let p=r.get(i[i.length-1]);while(p.refs.length===p.i)if(i.pop(),i.length>0)p=r.get(i[i.length-1]);else return null;return p},c=o();if(c===null)return null;let l=new or,h=new Map,f=(p,g)=>{let w=h.get(p);if(w==null||w>g)h.set(p,g)},a=c.refs[c.i++],u=new Map,d=()=>{for(let p of s){let g=p.id.client,w=r.get(g);if(w)w.i--,l.clients.set(g,w.refs.slice(w.i)),r.delete(g),w.i=0,w.refs=[];else l.clients.set(g,[p]);i=i.filter((C)=>C!==g)}s.length=0};while(!0){if(a.constructor!==M){let g=q(u,a.id.client,()=>b(e,a.id.client))-a.id.clock;if(g<0)s.push(a),f(a.id.client,a.id.clock-1),d();else{let w=a.getMissing(t,e);if(w!==null){s.push(a);let C=r.get(w)||{refs:[],i:0};if(C.refs.length===C.i)f(w,b(e,w)),d();else{a=C.refs[C.i++];continue}}else if(g===0||g<a.length)a.integrate(t,g),u.set(a.id.client,a.id.clock+a.length)}}if(s.length>0)a=s.pop();else if(c!==null&&c.i<c.refs.length)a=c.refs[c.i++];else if(c=o(),c===null)break;else a=c.refs[c.i++]}if(l.clients.size>0){let p=new et;return ir(p,l,new Map),_t(p.restEncoder,0),{missing:h,update:p.toUint8Array()}}return null},Ho=(t,e)=>ir(t,e.doc.store,e.beforeState),Jo=(t,e,r,s=new ct(t))=>x(e,(i)=>{i.local=!1;let o=!1,c=i.doc,l=c.store,h=Go(s,c),f=zo(i,l,h),a=l.pendingStructs;if(a){for(let[d,p]of a.missing)if(p<b(l,d)){o=!0;break}if(f){for(let[d,p]of f.missing){let g=a.missing.get(d);if(g==null||g>p)a.missing.set(d,p)}a.update=Je([a.update,f.update])}}else l.pendingStructs=f;let u=ys(s,i,l);if(l.pendingDs){let d=new ct(Ya(l.pendingDs));Dt(d.restDecoder);let p=ys(d,i,l);if(u&&p)l.pendingDs=Je([u,p]);else l.pendingDs=u||p}else l.pendingDs=u;if(o){let d=l.pendingStructs.update;l.pendingStructs=null,Ls(i.doc,d)}},r,!1);var Ls=(t,e,r,s=ct)=>{let i=Ya(e);Jo(i,t,r,new s(i))},KI=(t,e,r)=>Ls(t,e,r,nr),Po=(t,e,r=new Map)=>{ir(t,e.store,r),vt(t,jo(e.store))},Ko=(t,e=new Uint8Array([0]),r=new et)=>{let s=Vs(e);Po(r,t,s);let i=[r.toUint8Array()];if(t.store.pendingDs)i.push(t.store.pendingDs);if(t.store.pendingStructs)i.push(ac(t.store.pendingStructs.update,e));if(i.length>1){if(r.constructor===Nt)return cc(i.map((o,c)=>c===0?o:uc(o)));else if(r.constructor===et)return Je(i)}return i[0]},JI=(t,e)=>Ko(t,e,new Nt),Wo=(t)=>{let e=new Map,r=Dt(t.restDecoder);for(let s=0;s<r;s++){let i=Dt(t.restDecoder),o=Dt(t.restDecoder);e.set(i,o)}return e},Vs=(t)=>Wo(new er(Ya(t))),Ms=(t,e)=>(_t(t.restEncoder,e.size),j(e.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{_t(t.restEncoder,r),_t(t.restEncoder,s)}),t),Zo=(t,e)=>Ms(t,tn(e.store)),Qo=(t,e=new sr)=>{if(t instanceof Map)Ms(e,t);else Zo(e,t);return e.toUint8Array()},YI=(t)=>Qo(t,new rr);class $s{constructor(){this.l=[]}}var bs=()=>new $s,ks=(t,e)=>t.l.push(e),_s=(t,e)=>{let r=t.l,s=r.length;if(t.l=r.filter((i)=>e!==i),s===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},Fs=(t,e,r)=>Kt(t.l,[e,r]);class ot{constructor(t,e){this.client=t,this.clock=e}}var $e=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,m=(t,e)=>new ot(t,e);var js=(t)=>{for(let[e,r]of t.doc.share.entries())if(r===t)return e;throw v()},He=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class qs{constructor(t,e,r,s=0){this.type=t,this.tname=e,this.item=r,this.assoc=s}}class Gs{constructor(t,e,r=0){this.type=t,this.index=e,this.assoc=r}}var Yo=(t,e,r=0)=>new Gs(t,e,r),Fe=(t,e,r)=>{let s=null,i=null;if(t._item===null)i=js(t);else s=m(t._item.id.client,t._item.id.clock);return new qs(s,i,e,r)},Q0=(t,e,r=0)=>{let s=t._start;if(r<0){if(e===0)return Fe(t,null,r);e--}while(s!==null){if(!s.deleted&&s.countable){if(s.length>e)return Fe(t,m(s.id.client,s.id.clock+e),r);e-=s.length}if(s.right===null&&r<0)return Fe(t,s.lastId,r);s=s.right}return Fe(t,null,r)};var tc=(t,e)=>{let r=Ct(t,e),s=e.clock-r.id.clock;return{item:r,diff:s}},Pg=(t,e,r=!0)=>{let s=e.store,{item:i,type:o,tname:c,assoc:l}=t,h=null,f=0;if(i!==null){if(b(s,i.client)<=i.clock)return null;let a=r?Qn(s,i):tc(s,i),u=a.item;if(!(u instanceof y))return null;if(h=u.parent,h._item===null||!h._item.deleted){f=u.deleted||!u.countable?0:a.diff+(l>=0?0:1);let d=u.left;while(d!==null){if(!d.deleted&&d.countable)f+=d.length;d=d.left}}}else{if(c!==null)h=e.get(c);else if(o!==null){if(b(s,o.client)<=o.clock)return null;let{item:a}=r?Qn(s,o):{item:Ct(s,o)};if(a instanceof y&&a.content instanceof W)h=a.content.type;else return null}else throw v();if(l>=0)f=h._length;else f=0}return Yo(h,f,t.assoc)};class zs{constructor(t,e){this.ds=t,this.sv=e}}var ec=(t,e)=>new zs(t,e),$l=ec(vs(),new Map);var At=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ce(e.ds,t.id),Zn=(t,e)=>{let r=q(t.meta,Zn,G),s=t.doc.store;if(!r.has(e))e.sv.forEach((i,o)=>{if(i<b(s,o))N(t,m(o,i))}),Bt(t,e.ds,(i)=>{}),r.add(e)};class or{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var tn=(t)=>{let e=new Map;return t.clients.forEach((r,s)=>{let i=r[r.length-1];e.set(s,i.id.clock+i.length)}),e},b=(t,e)=>{let r=t.clients.get(e);if(r===void 0)return 0;let s=r[r.length-1];return s.id.clock+s.length},Hs=(t,e)=>{let r=t.clients.get(e.id.client);if(r===void 0)r=[],t.clients.set(e.id.client,r);else{let s=r[r.length-1];if(s.id.clock+s.length!==e.id.clock)throw v()}r.push(e)},P=(t,e)=>{let r=0,s=t.length-1,i=t[s],o=i.id.clock;if(o===e)return s;let c=os(e/(o+i.length-1)*s);while(r<=s){if(i=t[c],o=i.id.clock,o<=e){if(e<o+i.length)return c;r=c+1}else s=c-1;c=os((r+s)/2)}throw v()},nc=(t,e)=>{let r=t.clients.get(e.client);return r[P(r,e.clock)]},Ct=nc,Xn=(t,e,r)=>{let s=P(e,r),i=e[s];if(i.id.clock<r&&i instanceof y)return e.splice(s+1,0,Ye(t,i,r-i.id.clock)),s+1;return s},N=(t,e)=>{let r=t.doc.store.clients.get(e.client);return r[Xn(t,r,e.clock)]},Ss=(t,e,r)=>{let s=e.clients.get(r.client),i=P(s,r.clock),o=s[i];if(r.clock!==o.id.clock+o.length-1&&o.constructor!==V)s.splice(i+1,0,Ye(t,o,r.clock-o.id.clock+1));return o},rc=(t,e,r)=>{let s=t.clients.get(e.id.client);s[P(s,e.id.clock)]=r},Js=(t,e,r,s,i)=>{if(s===0)return;let o=r+s,c=Xn(t,e,r),l;do{if(l=e[c++],o<l.id.clock+l.length)Xn(t,e,o);i(l)}while(c<e.length&&e[c].id.clock<o)};class Ps{constructor(t,e,r){this.doc=t,this.deleteSet=new ht,this.beforeState=tn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var Es=(t,e)=>{if(e.deleteSet.clients.size===0&&!Ar(e.afterState,(r,s)=>e.beforeState.get(s)!==r))return!1;return Yn(e.deleteSet),Ho(t,e),vt(t,e.deleteSet),!0},Is=(t,e,r)=>{let s=e._item;if(s===null||s.id.clock<(t.beforeState.get(s.id.client)||0)&&!s.deleted)q(t.changed,e,G).add(r)},Ge=(t,e)=>{let r=t[e],s=t[e-1],i=e;for(;i>0;r=s,s=t[--i-1]){if(s.deleted===r.deleted&&s.constructor===r.constructor){if(s.mergeWith(r)){if(r instanceof y&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r)r.parent._map.set(r.parentSub,s);continue}}break}let o=e-i;if(o)t.splice(e+1-o,o);return o},sc=(t,e,r)=>{for(let[s,i]of t.clients.entries()){let o=e.clients.get(s);for(let c=i.length-1;c>=0;c--){let l=i[c],h=l.clock+l.len;for(let f=P(o,l.clock),a=o[f];f<o.length&&a.id.clock<h;a=o[++f]){let u=o[f];if(l.clock+l.len<=u.id.clock)break;if(u instanceof y&&u.deleted&&!u.keep&&r(u))u.gc(e,!1)}}}},ic=(t,e)=>{t.clients.forEach((r,s)=>{let i=e.clients.get(s);for(let o=r.length-1;o>=0;o--){let c=r[o],l=ue(i.length-1,1+P(i,c.clock+c.len-1));for(let h=l,f=i[h];h>0&&f.id.clock>=c.clock;f=i[h])h-=1+Ge(i,h)}})};var Ks=(t,e)=>{if(e<t.length){let r=t[e],s=r.doc,i=s.store,{deleteSet:o,_mergeStructs:c}=r;try{Yn(o),r.afterState=tn(r.doc.store),s.emit("beforeObserverCalls",[r,s]);let l=[];r.changed.forEach((h,f)=>l.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(r,h)})),l.push(()=>{r.changedParentTypes.forEach((h,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))l.push(()=>{h=h.filter((a)=>a.target._item===null||!a.target._item.deleted),h.forEach((a)=>{a.currentTarget=f,a._path=null}),h.sort((a,u)=>a.path.length-u.path.length),Fs(f._dEH,h,r)})}),l.push(()=>s.emit("afterTransaction",[r,s])),l.push(()=>{if(r._needFormattingCleanup)_c(r)})}),Kt(l,[])}finally{if(s.gc)sc(o,i,s.gcFilter);ic(o,i),r.afterState.forEach((a,u)=>{let d=r.beforeState.get(u)||0;if(d!==a){let p=i.clients.get(u),g=Z(P(p,d),1);for(let w=p.length-1;w>=g;)w-=1+Ge(p,w)}});for(let a=c.length-1;a>=0;a--){let{client:u,clock:d}=c[a].id,p=i.clients.get(u),g=P(p,d);if(g+1<p.length){if(Ge(p,g+1)>1)continue}if(g>0)Ge(p,g)}if(!r.local&&r.afterState.get(s.clientID)!==r.beforeState.get(s.clientID))gs(Tt,Yt,"[yjs] ",te,ee,"Changed the client-id because another client seems to be using it."),s.clientID=Ns();if(s.emit("afterTransactionCleanup",[r,s]),s._observers.has("update")){let a=new Nt;if(Es(a,r))s.emit("update",[a.toUint8Array(),r.origin,s,r])}if(s._observers.has("updateV2")){let a=new et;if(Es(a,r))s.emit("updateV2",[a.toUint8Array(),r.origin,s,r])}let{subdocsAdded:l,subdocsLoaded:h,subdocsRemoved:f}=r;if(l.size>0||f.size>0||h.size>0)l.forEach((a)=>{if(a.clientID=s.clientID,a.collectionid==null)a.collectionid=s.collectionid;s.subdocs.add(a)}),f.forEach((a)=>s.subdocs.delete(a)),s.emit("subdocs",[{loaded:h,added:l,removed:f},s,r]),f.forEach((a)=>a.destroy());if(t.length<=e+1)s._transactionCleanups=[],s.emit("afterAllTransactions",[s,t]);else Ks(t,e+1)}}},x=(t,e,r=null,s=!0)=>{let i=t._transactionCleanups,o=!1,c=null;if(t._transaction===null){if(o=!0,t._transaction=new Ps(t,r,s),i.push(t._transaction),i.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{c=e(t._transaction)}finally{if(o){let l=t._transaction===i[0];if(t._transaction=null,l)Ks(i,0)}}return c};class Ws{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Us=(t,e,r)=>{Bt(t,r.deletions,(s)=>{if(s instanceof y&&e.scope.some((i)=>i===t.doc||He(i,s)))ur(s,!1)})},Ts=(t,e,r)=>{let s=null,{doc:i,scope:o}=t;x(i,(l)=>{while(e.length>0&&t.currStackItem===null){let h=i.store,f=e.pop(),a=new Set,u=[],d=!1;Bt(l,f.insertions,(p)=>{if(p instanceof y){if(p.redone!==null){let{item:g,diff:w}=Qn(h,p.id);if(w>0)g=N(l,m(g.id.client,g.id.clock+w));p=g}if(!p.deleted&&o.some((g)=>g===l.doc||He(g,p)))u.push(p)}}),Bt(l,f.deletions,(p)=>{if(p instanceof y&&o.some((g)=>g===l.doc||He(g,p))&&!ce(f.insertions,p.id))a.add(p)}),a.forEach((p)=>{d=gi(l,p,a,f.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let p=u.length-1;p>=0;p--){let g=u[p];if(t.deleteFilter(g))g.delete(l),d=!0}t.currStackItem=d?f:null}l.changed.forEach((h,f)=>{if(h.has(null)&&f._searchMarker)f._searchMarker.length=0}),s=l},t);let c=t.currStackItem;if(c!=null){let l=s.changedParentTypes;t.emit("stack-item-popped",[{stackItem:c,type:r,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return c};class C2 extends Ie{constructor(t,{captureTimeout:e=500,captureTransaction:r=(l)=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=Q(t)?t[0].doc:t instanceof yd?t:t.doc}={}){super();this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(l)=>{if(!this.captureTransaction(l)||!this.scope.some((w)=>l.changedParentTypes.has(w)||w===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let h=this.undoing,f=this.redoing,a=h?this.redoStack:this.undoStack;if(h)this.stopCapturing();else if(!f)this.clear(!1,!0);let u=new ht;l.afterState.forEach((w,C)=>{let k=l.beforeState.get(C)||0,dr=w-k;if(dr>0)ne(u,C,k,dr)});let d=_u(),p=!1;if(this.lastChange>0&&d-this.lastChange<this.captureTimeout&&a.length>0&&!h&&!f){let w=a[a.length-1];w.deletions=Wn([w.deletions,l.deleteSet]),w.insertions=Wn([w.insertions,u])}else a.push(new Ws(l.deleteSet,u)),p=!0;if(!h&&!f)this.lastChange=d;Bt(l,l.deleteSet,(w)=>{if(w instanceof y&&this.scope.some((C)=>C===l.doc||He(C,w)))ur(w,!0)});let g=[{stackItem:a[a.length-1],origin:l.origin,type:h?"redo":"undo",changedParentTypes:l.changedParentTypes},this];if(p)this.emit("stack-item-added",g);else this.emit("stack-item-updated",g)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let e=new Set(this.scope);t=Q(t)?t:[t],t.forEach((r)=>{if(!e.has(r)){if(e.add(r),r instanceof I?r.doc!==this.doc:r!==this.doc)Pn("[yjs#509] Not same Y.Doc");this.scope.push(r)}})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){if(t&&this.canUndo()||e&&this.canRedo())this.doc.transact((r)=>{if(t)this.undoStack.forEach((s)=>Us(r,this,s)),this.undoStack=[];if(e)this.redoStack.forEach((s)=>Us(r,this,s)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Ts(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Ts(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*oc(t){let e=Dt(t.restDecoder);for(let r=0;r<e;r++){let s=Dt(t.restDecoder),i=t.readClient(),o=Dt(t.restDecoder);for(let c=0;c<s;c++){let l=t.readInfo();if(l===10){let h=Dt(t.restDecoder);yield new M(m(i,o),h),o+=h}else if((Vt&l)!==0){let h=(l&(F|D))===0,f=new y(m(i,o),null,(l&D)===D?t.readLeftID():null,null,(l&F)===F?t.readRightID():null,h?t.readParentInfo()?t.readString():t.readLeftID():null,h&&(l&dt)===dt?t.readString():null,mi(t,l));yield f,o+=f.length}else{let h=t.readLen();yield new V(m(i,o),h),o+=h}}}}class en{constructor(t,e){this.gen=oc(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===M);return this.curr}}class nn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var cc=(t)=>Je(t,nr,Nt);var lc=(t,e)=>{if(t.constructor===V){let{client:r,clock:s}=t.id;return new V(m(r,s+e),t.length-e)}else if(t.constructor===M){let{client:r,clock:s}=t.id;return new M(m(r,s+e),t.length-e)}else{let r=t,{client:s,clock:i}=r.id;return new y(m(s,i+e),null,m(s,i+e-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(e))}},Je=(t,e=ct,r=et)=>{if(t.length===1)return t[0];let s=t.map((a)=>new e(Ya(a))),i=s.map((a)=>new en(a,!0)),o=null,c=new r,l=new nn(c);while(!0){if(i=i.filter((d)=>d.curr!==null),i.sort((d,p)=>{if(d.curr.id.client===p.curr.id.client){let g=d.curr.id.clock-p.curr.id.clock;if(g===0)return d.curr.constructor===p.curr.constructor?0:d.curr.constructor===M?1:-1;else return g}else return p.curr.id.client-d.curr.id.client}),i.length===0)break;let a=i[0],u=a.curr.id.client;if(o!==null){let d=a.curr,p=!1;while(d!==null&&d.id.clock+d.length<=o.struct.id.clock+o.struct.length&&d.id.client>=o.struct.id.client)d=a.next(),p=!0;if(d===null||d.id.client!==u||p&&d.id.clock>o.struct.id.clock+o.struct.length)continue;if(u!==o.struct.id.client)Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next();else if(o.struct.id.clock+o.struct.length<d.id.clock)if(o.struct.constructor===M)o.struct.length=d.id.clock+d.length-o.struct.id.clock;else{Y(l,o.struct,o.offset);let g=d.id.clock-o.struct.id.clock-o.struct.length;o={struct:new M(m(u,o.struct.id.clock+o.struct.length),g),offset:0}}else{let g=o.struct.id.clock+o.struct.length-d.id.clock;if(g>0)if(o.struct.constructor===M)o.struct.length-=g;else d=lc(d,g);if(!o.struct.mergeWith(d))Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next()}}else o={struct:a.curr,offset:0},a.next();for(let d=a.curr;d!==null&&d.id.client===u&&d.id.clock===o.struct.id.clock+o.struct.length&&d.constructor!==M;d=a.next())Y(l,o.struct,o.offset),o={struct:d,offset:0}}if(o!==null)Y(l,o.struct,o.offset),o=null;cr(l);let h=s.map((a)=>tr(a)),f=Wn(h);return vt(c,f),c.toUint8Array()},ac=(t,e,r=ct,s=et)=>{let i=Vs(e),o=new s,c=new nn(o),l=new r(Ya(t)),h=new en(l,!1);while(h.curr){let a=h.curr,u=a.id.client,d=i.get(u)||0;if(h.curr.constructor===M){h.next();continue}if(a.id.clock+a.length>d){Y(c,a,Z(d-a.id.clock,0)),h.next();while(h.curr&&h.curr.id.client===u)Y(c,h.curr,0),h.next()}else while(h.curr&&h.curr.id.client===u&&h.curr.id.clock+h.curr.length<=d)h.next()}cr(c);let f=tr(l);return vt(o,f),o.toUint8Array()};var Zs=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:br(t.encoder.restEncoder)}),t.encoder.restEncoder=Ka(),t.written=0},Y=(t,e,r)=>{if(t.written>0&&t.currClient!==e.id.client)Zs(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),_t(t.encoder.restEncoder,e.id.clock+r);e.write(t.encoder,r),t.written++},cr=(t)=>{Zs(t);let e=t.encoder.restEncoder;_t(e,t.clientStructs.length);for(let r=0;r<t.clientStructs.length;r++){let s=t.clientStructs[r];_t(e,s.written),jt(e,s.restEncoder)}},hc=(t,e,r,s)=>{let i=new r(Ya(t)),o=new en(i,!1),c=new s,l=new nn(c);for(let f=o.curr;f!==null;f=o.next())Y(l,e(f),0);cr(l);let h=tr(i);return vt(c,h),c.toUint8Array()};var uc=(t)=>hc(t,$r,ct,Nt),As="You must not compute changes after the event-handler fired.";class le{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=dc(this.currentTarget,this.target))}deletes(t){return ce(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw R(As);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((s)=>{if(s!==null){let i=e._map.get(s),o,c;if(this.adds(i)){let l=i.left;while(l!==null&&this.adds(l))l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=ge(l.content.getContent());else return;else if(l!==null&&this.deletes(l))o="update",c=ge(l.content.getContent());else o="add",c=void 0}else if(this.deletes(i))o="delete",c=ge(i.content.getContent());else return;t.set(s,{action:o,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw R(As);let e=this.target,r=G(),s=G(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(e).has(null)){let c=null,l=()=>{if(c)i.push(c)};for(let h=e._start;h!==null;h=h.right)if(h.deleted){if(this.deletes(h)&&!this.adds(h)){if(c===null||c.delete===void 0)l(),c={delete:0};c.delete+=h.length,s.add(h)}}else if(this.adds(h)){if(c===null||c.insert===void 0)l(),c={insert:[]};c.insert=c.insert.concat(h.content.getContent()),r.add(h)}else{if(c===null||c.retain===void 0)l(),c={retain:0};c.retain+=h.length}if(c!==null&&c.retain===void 0)l()}this._changes=t}return t}}var dc=(t,e)=>{let r=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)r.unshift(e._item.parentSub);else{let s=0,i=e._item.parent._start;while(i!==e._item&&i!==null){if(!i.deleted&&i.countable)s+=i.length;i=i.right}r.unshift(s)}e=e._item.parent}return r},O=()=>{Pn("Invalid access: Add Yjs type to a document before reading data.")},Xs=80,lr=0;class Qs{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=lr++}}var fc=(t)=>{t.timestamp=lr++},Ys=(t,e,r)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=r,t.timestamp=lr++},pc=(t,e,r)=>{if(t.length>=Xs){let s=t.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return Ys(s,e,r),s}else{let s=new Qs(e,r);return t.push(s),s}},rn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let r=t._searchMarker.length===0?null:t._searchMarker.reduce((o,c)=>nt(e-o.index)<nt(e-c.index)?o:c),s=t._start,i=0;if(r!==null)s=r.p,i=r.index,fc(r);while(s.right!==null&&i<e){if(!s.deleted&&s.countable){if(e<i+s.length)break;i+=s.length}s=s.right}while(s.left!==null&&i>e)if(s=s.left,!s.deleted&&s.countable)i-=s.length;while(s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock)if(s=s.left,!s.deleted&&s.countable)i-=s.length;if(r!==null&&nt(r.index-i)<s.parent.length/Xs)return Ys(r,s,i),r;else return pc(t._searchMarker,s,i)},re=(t,e,r)=>{for(let s=t.length-1;s>=0;s--){let i=t[s];if(r>0){let o=i.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)i.index-=o.length;if(o===null||o.marker===!0){t.splice(s,1);continue}i.p=o,o.marker=!0}if(e<i.index||r>0&&e===i.index)i.index=Z(e,i.index+r)}};var sn=(t,e,r)=>{let s=t,i=e.changedParentTypes;while(!0){if(q(i,t,()=>[]).push(r),t._item===null)break;t=t._item.parent}Fs(s._eH,r,e)};class I{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=bs(),this._dEH=bs(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw L()}clone(){throw L()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted)t=t.right;return t}_callObserver(t,e){if(!t.local&&this._searchMarker)this._searchMarker.length=0}observe(t){ks(this._eH,t)}observeDeep(t){ks(this._dEH,t)}unobserve(t){_s(this._eH,t)}unobserveDeep(t){_s(this._dEH,t)}toJSON(){}}var ti=(t,e,r)=>{if(t.doc??O(),e<0)e=t._length+e;if(r<0)r=t._length+r;let s=r-e,i=[],o=t._start;while(o!==null&&s>0){if(o.countable&&!o.deleted){let c=o.content.getContent();if(c.length<=e)e-=c.length;else{for(let l=e;l<c.length&&s>0;l++)i.push(c[l]),s--;e=0}}o=o.right}return i},ei=(t)=>{t.doc??O();let e=[],r=t._start;while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)e.push(s[i])}r=r.right}return e};var se=(t,e)=>{let r=0,s=t._start;t.doc??O();while(s!==null){if(s.countable&&!s.deleted){let i=s.content.getContent();for(let o=0;o<i.length;o++)e(i[o],r++,t)}s=s.right}},ni=(t,e)=>{let r=[];return se(t,(s,i)=>{r.push(e(s,i,t))}),r},gc=(t)=>{let e=t._start,r=null,s=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};r=e.content.getContent(),s=0,e=e.right}let i=r[s++];if(r.length<=s)r=null;return{done:!1,value:i}}}},ri=(t,e)=>{t.doc??O();let r=rn(t,e),s=t._start;if(r!==null)s=r.p,e-=r.index;for(;s!==null;s=s.right)if(!s.deleted&&s.countable){if(e<s.length)return s.content.getContent()[e];e-=s.length}},Pe=(t,e,r,s)=>{let i=r,o=t.doc,{clientID:c,store:l}=o,h=r===null?e._start:r.right,f=[],a=()=>{if(f.length>0)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new at(f)),i.integrate(t,0),f=[]};s.forEach((u)=>{if(u===null)f.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(u);break;default:switch(a(),u.constructor){case Uint8Array:case ArrayBuffer:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new ae(new Uint8Array(u))),i.integrate(t,0);break;case yd:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new he(u)),i.integrate(t,0);break;default:if(u instanceof I)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new W(u)),i.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),a()},si=()=>R("Length exceeded!"),ii=(t,e,r,s)=>{if(r>e._length)throw si();if(r===0){if(e._searchMarker)re(e._searchMarker,r,s.length);return Pe(t,e,null,s)}let i=r,o=rn(e,r),c=e._start;if(o!==null){if(c=o.p,r-=o.index,r===0)c=c.prev,r+=c&&c.countable&&!c.deleted?c.length:0}for(;c!==null;c=c.right)if(!c.deleted&&c.countable){if(r<=c.length){if(r<c.length)N(t,m(c.id.client,c.id.clock+r));break}r-=c.length}if(e._searchMarker)re(e._searchMarker,i,s.length);return Pe(t,e,c,s)},mc=(t,e,r)=>{let i=(e._searchMarker||[]).reduce((o,c)=>c.index>o.index?c:o,{index:0,p:e._start}).p;if(i)while(i.right)i=i.right;return Pe(t,e,i,r)},oi=(t,e,r,s)=>{if(s===0)return;let i=r,o=s,c=rn(e,r),l=e._start;if(c!==null)l=c.p,r-=c.index;for(;l!==null&&r>0;l=l.right)if(!l.deleted&&l.countable){if(r<l.length)N(t,m(l.id.client,l.id.clock+r));r-=l.length}while(s>0&&l!==null){if(!l.deleted){if(s<l.length)N(t,m(l.id.client,l.id.clock+s));l.delete(t),s-=l.length}l=l.right}if(s>0)throw si();if(e._searchMarker)re(e._searchMarker,i,-o+s)},Ke=(t,e,r)=>{let s=e._map.get(r);if(s!==void 0)s.delete(t)},ar=(t,e,r,s)=>{let i=e._map.get(r)||null,o=t.doc,c=o.clientID,l;if(s==null)l=new at([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new at([s]);break;case Uint8Array:l=new ae(s);break;case yd:l=new he(s);break;default:if(s instanceof I)l=new W(s);else throw Error("Unexpected content type")}new y(m(c,b(o.store,c)),i,i&&i.lastId,null,null,e,r,l).integrate(t,0)},hr=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},ci=(t)=>{let e={};return t.doc??O(),t._map.forEach((r,s)=>{if(!r.deleted)e[s]=r.content.getContent()[r.length-1]}),e},li=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted};var wc=(t,e)=>{let r={};return t._map.forEach((s,i)=>{let o=s;while(o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0)))o=o.left;if(o!==null&&At(o,e))r[i]=o.content.getContent()[o.length-1]}),r},je=(t)=>(t.doc??O(),xs(t._map.entries(),(e)=>!e[1].deleted));class ky extends le{}class ba extends I{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new ba;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ba}clone(){let t=new ba;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._length}_callObserver(t,e){super._callObserver(t,e),sn(this,t,new ky(this,t))}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{ii(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)x(this.doc,(e)=>{mc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ri(this,t)}toArray(){return ei(this)}slice(t=0,e=this.length){return ti(this,t,e)}toJSON(){return this.map((t)=>t instanceof I?t.toJSON():t)}map(t){return ni(this,t)}forEach(t){se(this,t)}[Symbol.iterator](){return gc(this)}_write(t){t.writeTypeRef($c)}}var xc=(t)=>new ba;class e_ extends le{constructor(t,e,r){super(t,e);this.keysChanged=r}}class rs extends I{constructor(t){super();if(this._prelimContent=null,t===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new rs}clone(){let t=new rs;return this.forEach((e,r)=>{t.set(r,e instanceof I?e.clone():e)}),t}_callObserver(t,e){sn(this,t,new e_(this,t,e))}toJSON(){this.doc??O();let t={};return this._map.forEach((e,r)=>{if(!e.deleted){let s=e.content.getContent()[e.length-1];t[r]=s instanceof I?s.toJSON():s}}),t}get size(){return[...je(this)].length}keys(){return Me(je(this),(t)=>t[0])}values(){return Me(je(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Me(je(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??O(),this._map.forEach((e,r)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return hr(this,t)}has(t){return li(this,t)}clear(){if(this.doc!==null)x(this.doc,(t)=>{this.forEach(function(e,r,s){Ke(t,s,r)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(Fc)}}var yc=(t)=>new rs,tt=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&In(t,e);class We{constructor(t,e,r,s){this.left=t,this.right=e,this.index=r,this.currentAttributes=s}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)Rt(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Cs=(t,e,r)=>{while(e.right!==null&&r>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)Rt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(r<e.right.length)N(t,m(e.right.id.client,e.right.id.clock+r));e.index+=e.right.length,r-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},qe=(t,e,r,s)=>{let i=new Map,o=s?rn(e,r):null;if(o){let c=new We(o.p.left,o.p,o.index,i);return Cs(t,c,r-o.index)}else{let c=new We(null,e._start,0,i);return Cs(t,c,r)}},ai=(t,e,r,s)=>{while(r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===U&&tt(s.get(r.right.content.key),r.right.content.value))){if(!r.right.deleted)s.delete(r.right.content.key);r.forward()}let i=t.doc,o=i.clientID;s.forEach((c,l)=>{let{left:h,right:f}=r,a=new y(m(o,b(i.store,o)),h,h&&h.lastId,f,f&&f.id,e,null,new U(l,c));a.integrate(t,0),r.right=a,r.forward()})},Rt=(t,e)=>{let{key:r,value:s}=e;if(s===null)t.delete(r);else t.set(r,s)},hi=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&tt(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},ui=(t,e,r,s)=>{let i=t.doc,o=i.clientID,c=new Map;for(let l in s){let h=s[l],f=r.currentAttributes.get(l)??null;if(!tt(f,h)){c.set(l,f);let{left:a,right:u}=r;r.right=new y(m(o,b(i.store,o)),a,a&&a.lastId,u,u&&u.id,e,null,new U(l,h)),r.right.integrate(t,0),r.forward()}}return c},Kn=(t,e,r,s,i)=>{r.currentAttributes.forEach((d,p)=>{if(i[p]===void 0)i[p]=null});let o=t.doc,c=o.clientID;hi(r,i);let l=ui(t,e,r,i),h=s.constructor===String?new K(s):s instanceof I?new W(s):new ut(s),{left:f,right:a,index:u}=r;if(e._searchMarker)re(e._searchMarker,r.index,h.getLength());a=new y(m(c,b(o.store,c)),f,f&&f.lastId,a,a&&a.id,e,null,h),a.integrate(t,0),r.right=a,r.index=u,r.forward(),ai(t,e,r,l)},Ds=(t,e,r,s,i)=>{let o=t.doc,c=o.clientID;hi(r,i);let l=ui(t,e,r,i);t:while(r.right!==null&&(s>0||l.size>0&&(r.right.deleted||r.right.content.constructor===U))){if(!r.right.deleted)switch(r.right.content.constructor){case U:{let{key:h,value:f}=r.right.content,a=i[h];if(a!==void 0){if(tt(a,f))l.delete(h);else{if(s===0)break t;l.set(h,f)}r.right.delete(t)}else r.currentAttributes.set(h,f);break}default:if(s<r.right.length)N(t,m(r.right.id.client,r.right.id.clock+s));s-=r.right.length;break}r.forward()}if(s>0){let h="";for(;s>0;s--)h+=`
|
|
4
4
|
`;r.right=new y(m(c,b(o.store,c)),r.left,r.left&&r.left.lastId,r.right,r.right&&r.right.id,e,null,new K(h)),r.right.integrate(t,0),r.forward()}ai(t,e,r,l)},di=(t,e,r,s,i)=>{let o=e,c=A();while(o&&(!o.countable||o.deleted)){if(!o.deleted&&o.content.constructor===U){let f=o.content;c.set(f.key,f)}o=o.right}let l=0,h=!1;while(e!==o){if(r===e)h=!0;if(!e.deleted){let f=e.content;switch(f.constructor){case U:{let{key:a,value:u}=f,d=s.get(a)??null;if(c.get(a)!==f||d===u){if(e.delete(t),l++,!h&&(i.get(a)??null)===u&&d!==u)if(d===null)i.delete(a);else i.set(a,d)}if(!h&&!e.deleted)Rt(i,f);break}}}e=e.right}return l},bc=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable))e=e.right;let r=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===U){let s=e.content.key;if(r.has(s))e.delete(t);else r.add(s)}e=e.left}},kc=(t)=>{let e=0;return x(t.doc,(r)=>{let{_start:s,_start:i}=t,o=A(),c=Ee(o);while(i){if(i.deleted===!1)switch(i.content.constructor){case U:Rt(c,i.content);break;default:e+=di(r,s,i,o,c),o=Ee(c),s=i;break}i=i.right}}),e},_c=(t)=>{let e=new Set,r=t.doc;for(let[s,i]of t.afterState.entries()){let o=t.beforeState.get(s)||0;if(i===o)continue;Js(t,r.store.clients.get(s),o,i,(c)=>{if(!c.deleted&&c.content.constructor===U&&c.constructor!==V)e.add(c.parent)})}x(r,(s)=>{Bt(t,t.deleteSet,(i)=>{if(i instanceof V||!i.parent._hasFormatting||e.has(i.parent))return;let o=i.parent;if(i.content.constructor===U)e.add(o);else bc(s,i)});for(let i of e)kc(i)})},Bs=(t,e,r)=>{let s=r,i=Ee(e.currentAttributes),o=e.right;while(r>0&&e.right!==null){if(e.right.deleted===!1)switch(e.right.content.constructor){case W:case ut:case K:if(r<e.right.length)N(t,m(e.right.id.client,e.right.id.clock+r));r-=e.right.length,e.right.delete(t);break}e.forward()}if(o)di(t,o,e.right,i,e.currentAttributes);let c=(e.left||e.right).parent;if(c._searchMarker)re(c._searchMarker,e.index,-s+r);return e};class t_ extends le{constructor(t,e,r){super(t,e);this.childListChanged=!1,this.keysChanged=new Set,r.forEach((s)=>{if(s===null)this.childListChanged=!0;else this.keysChanged.add(s)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,e=[];x(t,(r)=>{let s=new Map,i=new Map,o=this.target._start,c=null,l={},h="",f=0,a=0,u=()=>{if(c!==null){let d=null;switch(c){case"delete":if(a>0)d={delete:a};a=0;break;case"insert":if(typeof h==="object"||h.length>0){if(d={insert:h},s.size>0)d.attributes={},s.forEach((p,g)=>{if(p!==null)d.attributes[g]=p})}h="";break;case"retain":if(f>0){if(d={retain:f},!Mr(l))d.attributes=Lr({},l)}f=0;break}if(d)e.push(d);c=null}};while(o!==null){switch(o.content.constructor){case W:case ut:if(this.adds(o)){if(!this.deletes(o))u(),c="insert",h=o.content.getContent()[0],u()}else if(this.deletes(o)){if(c!=="delete")u(),c="delete";a+=1}else if(!o.deleted){if(c!=="retain")u(),c="retain";f+=1}break;case K:if(this.adds(o)){if(!this.deletes(o)){if(c!=="insert")u(),c="insert";h+=o.content.str}}else if(this.deletes(o)){if(c!=="delete")u(),c="delete";a+=o.length}else if(!o.deleted){if(c!=="retain")u(),c="retain";f+=o.length}break;case U:{let{key:d,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){let g=s.get(d)??null;if(!tt(g,p)){if(c==="retain")u();if(tt(p,i.get(d)??null))delete l[d];else l[d]=p}else if(p!==null)o.delete(r)}}else if(this.deletes(o)){i.set(d,p);let g=s.get(d)??null;if(!tt(g,p)){if(c==="retain")u();l[d]=g}}else if(!o.deleted){i.set(d,p);let g=l[d];if(g!==void 0){if(!tt(g,p)){if(c==="retain")u();if(p===null)delete l[d];else l[d]=p}else if(g!==null)o.delete(r)}}if(!o.deleted){if(c==="insert")u();Rt(s,o.content)}break}}o=o.right}u();while(e.length>0){let d=e[e.length-1];if(d.retain!==void 0&&d.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}}class ss extends I{constructor(t){super();this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??O(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((r)=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ss}clone(){let t=new ss;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);let r=new t_(this,t,e);if(sn(this,t,r),!t.local&&this._hasFormatting)t._needFormattingCleanup=!0}toString(){this.doc??O();let t="",e=this._start;while(e!==null){if(!e.deleted&&e.countable&&e.content.constructor===K)t+=e.content.str;e=e.right}return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){if(this.doc!==null)x(this.doc,(r)=>{let s=new We(null,this._start,0,new Map);for(let i=0;i<t.length;i++){let o=t[i];if(o.insert!==void 0){let c=!e&&typeof o.insert==="string"&&i===t.length-1&&s.right===null&&o.insert.slice(-1)===`
|
|
5
|
-
`?o.insert.slice(0,-1):o.insert;if(typeof c!=="string"||c.length>0)Kn(r,this,s,c,o.attributes||{})}else if(o.retain!==void 0)Ds(r,this,s,o.retain,o.attributes||{});else if(o.delete!==void 0)Bs(r,s,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,r){this.doc??O();let s=[],i=new Map,o=this.doc,c="",l=this._start;function h(){if(c.length>0){let a={},u=!1;i.forEach((p,g)=>{u=!0,a[g]=p});let d={insert:c};if(u)d.attributes=a;s.push(d),c=""}}let f=()=>{while(l!==null){if(At(l,t)||e!==void 0&&At(l,e))switch(l.content.constructor){case K:{let a=i.get("ychange");if(t!==void 0&&!At(l,t)){if(a===void 0||a.user!==l.id.client||a.type!=="removed")h(),i.set("ychange",r?r("removed",l.id):{type:"removed"})}else if(e!==void 0&&!At(l,e)){if(a===void 0||a.user!==l.id.client||a.type!=="added")h(),i.set("ychange",r?r("added",l.id):{type:"added"})}else if(a!==void 0)h(),i.delete("ychange");c+=l.content.str;break}case W:case ut:{h();let a={insert:l.content.getContent()[0]};if(i.size>0){let u={};a.attributes=u,i.forEach((d,p)=>{u[p]=d})}s.push(a);break}case U:if(At(l,t))h(),Rt(i,l.content);break}l=l.right}h()};if(t||e)x(o,(a)=>{if(t)Zn(a,t);if(e)Zn(a,e);f()},"cleanup");else f();return s}insert(t,e,r){if(e.length<=0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);if(!r)r={},o.currentAttributes.forEach((c,l)=>{r[l]=c});Kn(i,this,o,e,r)});else this._pending.push(()=>this.insert(t,e,r))}insertEmbed(t,e,r){let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);Kn(i,this,o,e,r||{})});else this._pending.push(()=>this.insertEmbed(t,e,r||{}))}delete(t,e){if(e===0)return;let r=this.doc;if(r!==null)x(r,(s)=>{Bs(s,qe(s,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,r){if(e===0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!1);if(o.right===null)return;Ds(i,this,o,e,r)});else this._pending.push(()=>this.format(t,e,r))}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return hr(this,t)}getAttributes(){return ci(this)}_write(t){t.writeTypeRef(jc)}}var Sc=(t)=>new ss;class ze{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??O()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Ot||e.constructor===lt)&&e._start!==null)t=e._start;else while(t!==null){let r=t.next;if(r!==null){t=r;break}else if(t.parent===this._root)t=null;else t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));if(this._firstCall=!1,t===null)return{value:void 0,done:!0};return this._currentNode=t,{value:t.content.type,done:!1}}}class lt extends I{constructor(){super();this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new lt}clone(){let t=new lt;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new ze(this,t)}querySelector(t){t=t.toUpperCase();let r=new ze(this,(s)=>s.nodeName&&s.nodeName.toUpperCase()===t).next();if(r.done)return null;else return r.value}querySelectorAll(t){return t=t.toUpperCase(),j(new ze(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){sn(this,t,new fi(this,e,t))}toString(){return ni(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},r){let s=t.createDocumentFragment();if(r!==void 0)r._createAssociation(s,this);return se(this,(i)=>{s.insertBefore(i.toDOM(t,e,r),null)}),s}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{ii(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)x(this.doc,(r)=>{let s=t&&t instanceof I?t._item:t;Pe(r,this,s,e)});else{let r=this._prelimContent,s=t===null?0:r.findIndex((i)=>i===t)+1;if(s===0&&t!==null)throw R("Reference item not found");r.splice(s,0,...e)}}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return ei(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ri(this,t)}slice(t=0,e=this.length){return ti(this,t,e)}forEach(t){se(this,t)}_write(t){t.writeTypeRef(Gc)}}var Ec=(t)=>new lt;class Ot extends lt{constructor(t="UNDEFINED"){super();this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new Ot(this.nodeName)}clone(){let t=new Ot(this.nodeName),e=this.getAttributes();return Vr(e,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map((r)=>r instanceof I?r.clone():r)),t}toString(){let t=this.getAttributes(),e=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];e.push(l+'="'+t[l]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return hr(this,t)}hasAttribute(t){return li(this,t)}getAttributes(t){return t?wc(this,t):ci(this)}toDOM(t=document,e={},r){let s=t.createElement(this.nodeName),i=this.getAttributes();for(let o in i){let c=i[o];if(typeof c==="string")s.setAttribute(o,c)}if(se(this,(o)=>{s.appendChild(o.toDOM(t,e,r))}),r!==void 0)r._createAssociation(s,this);return s}_write(t){t.writeTypeRef(qc),t.writeKey(this.nodeName)}}var Ic=(t)=>new Ot(t.readKey());class fi extends le{constructor(t,e,r){super(t,r);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((s)=>{if(s===null)this.childListChanged=!0;else this.attributesChanged.add(s)})}}class Ze extends rs{constructor(t){super();this.hookName=t}_copy(){return new Ze(this.hookName)}clone(){let t=new Ze(this.hookName);return this.forEach((e,r)=>{t.set(r,e)}),t}toDOM(t=document,e={},r){let s=e[this.hookName],i;if(s!==void 0)i=s.createDom(this);else i=document.createElement(this.hookName);if(i.setAttribute("data-yjs-hook",this.hookName),r!==void 0)r._createAssociation(i,this);return i}_write(t){t.writeTypeRef(zc),t.writeKey(this.hookName)}}var Uc=(t)=>new Ze(t.readKey());class Xe extends ss{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new Xe}clone(){let t=new Xe;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,r){let s=t.createTextNode(this.toString());if(r!==void 0)r._createAssociation(s,this);return s}toString(){return this.toDelta().map((t)=>{let e=[];for(let s in t.attributes){let i=[];for(let o in t.attributes[s])i.push({key:o,value:t.attributes[s][o]});i.sort((o,c)=>o.key<c.key?-1:1),e.push({nodeName:s,attrs:i})}e.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<e.length;s++){let i=e[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){let c=i.attrs[o];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=e.length-1;s>=0;s--)r+=`</${e[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Hc)}}var Tc=(t)=>new Xe;class on{constructor(t,e){this.id=t,this.length=e}get deleted(){throw L()}mergeWith(t){return!1}write(t,e,r){throw L()}integrate(t,e){throw L()}}var Ac=0;class V extends on{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){if(e>0)this.id.clock+=e,this.length-=e;Hs(t.doc.store,this)}write(t,e){t.writeInfo(Ac),t.writeLen(this.length-e)}getMissing(t,e){return null}}class ae{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ae(this.content)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var Cc=(t)=>new ae(t.readBuf());class ie{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new ie(this.len)}splice(t){let e=new ie(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){ne(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}var Dc=(t)=>new ie(t.readLen()),pi=(t,e)=>new yd({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class he{constructor(t){if(t._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=t;let e={};if(this.opts=e,!t.gc)e.gc=!1;if(t.autoLoad)e.autoLoad=!0;if(t.meta!==null)e.meta=t.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new he(pi(this.doc.guid,this.opts))}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){if(this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad)t.subdocsLoaded.add(this.doc)}delete(t){if(t.subdocsAdded.has(this.doc))t.subdocsAdded.delete(this.doc);else t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}var Bc=(t)=>new he(pi(t.readString(),t.readAny()));class ut{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ut(this.embed)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var Oc=(t)=>new ut(t.readJSON());class U{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new U(this.key,this.value)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){let r=e.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}var vc=(t)=>new U(t.readKey(),t.readJSON());class Qe{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Qe(this.arr)}splice(t){let e=new Qe(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}var Nc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++){let i=t.readString();if(i==="undefined")r.push(void 0);else r.push(JSON.parse(i))}return new Qe(r)},Rc=Zt("node_env")==="development";class at{constructor(t){this.arr=t,Rc&&Un(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new at(this.arr)}splice(t){let e=new at(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeAny(i)}}getRef(){return 8}}var Lc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++)r.push(t.readAny());return new at(r)};class K{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new K(this.str)}splice(t){let e=new K(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);if(r>=55296&&r<=56319)this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1);return e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}var Vc=(t)=>new K(t.readString()),Mc=[xc,yc,Sc,Ic,Ec,Uc,Tc],$c=0,Fc=1,jc=2,qc=3,Gc=4,zc=5,Hc=6;class W{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new W(this.type._copy())}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted)e.delete(t);else if(e.id.clock<(t.beforeState.get(e.id.client)||0))t._mergeStructs.push(e);e=e.right}this.type._map.forEach((r)=>{if(!r.deleted)r.delete(t);else if(r.id.clock<(t.beforeState.get(r.id.client)||0))t._mergeStructs.push(r)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((r)=>{while(r!==null)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Jc=(t)=>new W(Mc[t.readTypeRef()](t)),Qn=(t,e)=>{let r=e,s=0,i;do{if(s>0)r=m(r.client,r.clock+s);i=Ct(t,r),s=r.clock-i.id.clock,r=i.redone}while(r!==null&&i instanceof y);return{item:i,diff:s}},ur=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},Ye=(t,e,r)=>{let{client:s,clock:i}=e.id,o=new y(m(s,i+r),e,m(s,i+r-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(r));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=m(e.redone.client,e.redone.clock+r);if(e.right=o,o.right!==null)o.right.left=o;if(t._mergeStructs.push(o),o.parentSub!==null&&o.right===null)o.parent._map.set(o.parentSub,o);return e.length=r,o},Os=(t,e)=>$t(t,(r)=>ce(r.deletions,e)),gi=(t,e,r,s,i,o)=>{let c=t.doc,{store:l,clientID:h}=c,f=e.redone;if(f!==null)return N(t,f);let a=e.parent._item,u=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!r.has(a)||gi(t,a,r,s,i,o)===null))return null;while(a.redone!==null)a=N(t,a.redone)}let p=a===null?e.parent:a.content.type;if(e.parentSub===null){u=e.left,d=e;while(u!==null){let k=u;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){u=k;break}u=u.left}while(d!==null){let k=d;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){d=k;break}d=d.right}}else{if(d=null,e.right&&!i){u=e;while(u!==null&&u.right!==null&&(u.right.redone||ce(s,u.right.id)||Os(o.undoStack,u.right.id)||Os(o.redoStack,u.right.id))){u=u.right;while(u.redone)u=N(t,u.redone)}if(u&&u.right!==null)return null}else u=p._map.get(e.parentSub)||null;if(u!==null&&u.parent._item!==a)u=p._map.get(e.parentSub)||null}let g=b(l,h),w=m(h,g),C=new y(w,u,u&&u.lastId,d,d&&d.id,p,e.parentSub,e.content.copy());return e.redone=w,ur(C,!0),C.integrate(t,0),C};class y extends on{constructor(t,e,r,s,i,o,c,l){super(t,l.getLength());this.origin=r,this.left=e,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?ln:0}set marker(t){if((this.info&pe)>0!==t)this.info^=pe}get marker(){return(this.info&pe)>0}get keep(){return(this.info&cn)>0}set keep(t){if(this.keep!==t)this.info^=cn}get countable(){return(this.info&ln)>0}get deleted(){return(this.info&fe)>0}set deleted(t){if(this.deleted!==t)this.info^=fe}markDeleted(){this.info|=fe}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=b(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=b(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ot&&this.id.client!==this.parent.client&&this.parent.clock>=b(e,this.parent.client))return this.parent.client;if(this.origin)this.left=Ss(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=N(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===V||this.right&&this.right.constructor===V)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===y)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===y)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===ot){let r=Ct(e,this.parent);if(r.constructor===V)this.parent=null;else this.parent=r.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=Ss(t,t.doc.store,m(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null){s=this.parent._map.get(this.parentSub)||null;while(s!==null&&s.left!==null)s=s.left}else s=this.parent._start;let i=new Set,o=new Set;while(s!==null&&s!==this.right){if(o.add(s),i.add(s),$e(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if($e(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Ct(t.doc.store,s.origin))){if(!i.has(Ct(t.doc.store,s.origin)))r=s,i.clear()}else break;s=s.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start,this.parent._start=this;this.right=r}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(t)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(Hs(t.doc.store,this),this.content.integrate(t,this),Is(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new V(this.id,this.length).integrate(t,0)}get next(){let t=this.right;while(t!==null&&t.deleted)t=t.right;return t}get prev(){let t=this.left;while(t!==null&&t.deleted)t=t.left;return t}get lastId(){return this.length===1?this.id:m(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&$e(t.origin,this.lastId)&&this.right===t&&$e(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let e=this.parent._searchMarker;if(e)e.forEach((r)=>{if(r.p===t){if(r.p=this,!this.deleted&&this.countable)r.index-=this.length}});if(t.keep)this.keep=!0;if(this.right=t.right,this.right!==null)this.right.left=this;return this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;if(this.countable&&this.parentSub===null)e._length-=this.length;this.markDeleted(),ne(t.deleteSet,this.id.client,this.id.clock,this.length),Is(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)rc(t,this,new V(this.id,this.length));else this.content=new ie(this.length)}write(t,e){let r=e>0?m(this.id.client,this.id.clock+e-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Vt|(r===null?0:D)|(s===null?0:F)|(i===null?0:dt);if(t.writeInfo(o),r!==null)t.writeLeftID(r);if(s!==null)t.writeRightID(s);if(r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let h=js(c);t.writeParentInfo(!0),t.writeString(h)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else if(c.constructor===String)t.writeParentInfo(!0),t.writeString(c);else if(c.constructor===ot)t.writeParentInfo(!1),t.writeLeftID(c);else v();if(i!==null)t.writeString(i)}this.content.write(t,e)}}var mi=(t,e)=>Pc[e&Vt](t),Pc=[()=>{v()},Dc,Nc,Cc,Vc,Oc,vc,Jc,Lc,Bc,()=>{v()}],Kc=10;class M extends on{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){v()}write(t,e){t.writeInfo(Kc),_t(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var wi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},xi="__ $YJS$ __";if(wi[xi]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");wi[xi]=!0;var ZI=0,XI=1,QI=2,eR=3;class Pg extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function Wc(t){return _(t)&&"type"in t&&n(t.type)}function mk(t){let e=Ka(),{type:r}=t;switch(t.type){case"doc-sync":{_t(e,ZI),Ja(e,t.path),_t(e,t.epoch),Bo(e,t.body);break}case"awareness":{_t(e,XI),Bo(e,t.body);break}case"doc-close":{_t(e,QI),Ja(e,t.path);break}case"control":{_t(e,eR),Ja(e,JSON.stringify(t.message));break}default:throw new Pg(`unknown-frame:${r}`)}return br(e)}function gk(t){try{let e=Ya(t),r=Dt(e);switch(r){case ZI:{let s=Za(e),i=Dt(e);return{body:Xo(e),epoch:i,path:s,type:"doc-sync"}}case XI:return{body:Xo(e),type:"awareness"};case QI:return{path:Za(e),type:"doc-close"};case eR:{let s=JSON.parse(Za(e));if(!Wc(s))throw new Pg("malformed-control");return{message:s,type:"control"}}default:throw new Pg(`unknown-frame-type:${r}`)}}catch(e){if(e instanceof Pg)throw e;throw new Pg(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
|
|
6
|
-
export{pk,os,Ka,fk,br,_t,Ja,Bo,Ya,Xo,Dt,Za,_u,op,yd,KI,JI,YI,Q0,
|
|
5
|
+
`?o.insert.slice(0,-1):o.insert;if(typeof c!=="string"||c.length>0)Kn(r,this,s,c,o.attributes||{})}else if(o.retain!==void 0)Ds(r,this,s,o.retain,o.attributes||{});else if(o.delete!==void 0)Bs(r,s,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,r){this.doc??O();let s=[],i=new Map,o=this.doc,c="",l=this._start;function h(){if(c.length>0){let a={},u=!1;i.forEach((p,g)=>{u=!0,a[g]=p});let d={insert:c};if(u)d.attributes=a;s.push(d),c=""}}let f=()=>{while(l!==null){if(At(l,t)||e!==void 0&&At(l,e))switch(l.content.constructor){case K:{let a=i.get("ychange");if(t!==void 0&&!At(l,t)){if(a===void 0||a.user!==l.id.client||a.type!=="removed")h(),i.set("ychange",r?r("removed",l.id):{type:"removed"})}else if(e!==void 0&&!At(l,e)){if(a===void 0||a.user!==l.id.client||a.type!=="added")h(),i.set("ychange",r?r("added",l.id):{type:"added"})}else if(a!==void 0)h(),i.delete("ychange");c+=l.content.str;break}case W:case ut:{h();let a={insert:l.content.getContent()[0]};if(i.size>0){let u={};a.attributes=u,i.forEach((d,p)=>{u[p]=d})}s.push(a);break}case U:if(At(l,t))h(),Rt(i,l.content);break}l=l.right}h()};if(t||e)x(o,(a)=>{if(t)Zn(a,t);if(e)Zn(a,e);f()},"cleanup");else f();return s}insert(t,e,r){if(e.length<=0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);if(!r)r={},o.currentAttributes.forEach((c,l)=>{r[l]=c});Kn(i,this,o,e,r)});else this._pending.push(()=>this.insert(t,e,r))}insertEmbed(t,e,r){let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);Kn(i,this,o,e,r||{})});else this._pending.push(()=>this.insertEmbed(t,e,r||{}))}delete(t,e){if(e===0)return;let r=this.doc;if(r!==null)x(r,(s)=>{Bs(s,qe(s,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,r){if(e===0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!1);if(o.right===null)return;Ds(i,this,o,e,r)});else this._pending.push(()=>this.format(t,e,r))}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return hr(this,t)}getAttributes(){return ci(this)}_write(t){t.writeTypeRef(jc)}}var Sc=(t)=>new ss;class ze{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??O()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Ot||e.constructor===lt)&&e._start!==null)t=e._start;else while(t!==null){let r=t.next;if(r!==null){t=r;break}else if(t.parent===this._root)t=null;else t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));if(this._firstCall=!1,t===null)return{value:void 0,done:!0};return this._currentNode=t,{value:t.content.type,done:!1}}}class lt extends I{constructor(){super();this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new lt}clone(){let t=new lt;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new ze(this,t)}querySelector(t){t=t.toUpperCase();let r=new ze(this,(s)=>s.nodeName&&s.nodeName.toUpperCase()===t).next();if(r.done)return null;else return r.value}querySelectorAll(t){return t=t.toUpperCase(),j(new ze(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){sn(this,t,new fi(this,e,t))}toString(){return ni(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},r){let s=t.createDocumentFragment();if(r!==void 0)r._createAssociation(s,this);return se(this,(i)=>{s.insertBefore(i.toDOM(t,e,r),null)}),s}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{ii(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)x(this.doc,(r)=>{let s=t&&t instanceof I?t._item:t;Pe(r,this,s,e)});else{let r=this._prelimContent,s=t===null?0:r.findIndex((i)=>i===t)+1;if(s===0&&t!==null)throw R("Reference item not found");r.splice(s,0,...e)}}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return ei(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ri(this,t)}slice(t=0,e=this.length){return ti(this,t,e)}forEach(t){se(this,t)}_write(t){t.writeTypeRef(Gc)}}var Ec=(t)=>new lt;class Ot extends lt{constructor(t="UNDEFINED"){super();this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new Ot(this.nodeName)}clone(){let t=new Ot(this.nodeName),e=this.getAttributes();return Vr(e,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map((r)=>r instanceof I?r.clone():r)),t}toString(){let t=this.getAttributes(),e=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];e.push(l+'="'+t[l]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return hr(this,t)}hasAttribute(t){return li(this,t)}getAttributes(t){return t?wc(this,t):ci(this)}toDOM(t=document,e={},r){let s=t.createElement(this.nodeName),i=this.getAttributes();for(let o in i){let c=i[o];if(typeof c==="string")s.setAttribute(o,c)}if(se(this,(o)=>{s.appendChild(o.toDOM(t,e,r))}),r!==void 0)r._createAssociation(s,this);return s}_write(t){t.writeTypeRef(qc),t.writeKey(this.nodeName)}}var Ic=(t)=>new Ot(t.readKey());class fi extends le{constructor(t,e,r){super(t,r);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((s)=>{if(s===null)this.childListChanged=!0;else this.attributesChanged.add(s)})}}class Ze extends rs{constructor(t){super();this.hookName=t}_copy(){return new Ze(this.hookName)}clone(){let t=new Ze(this.hookName);return this.forEach((e,r)=>{t.set(r,e)}),t}toDOM(t=document,e={},r){let s=e[this.hookName],i;if(s!==void 0)i=s.createDom(this);else i=document.createElement(this.hookName);if(i.setAttribute("data-yjs-hook",this.hookName),r!==void 0)r._createAssociation(i,this);return i}_write(t){t.writeTypeRef(zc),t.writeKey(this.hookName)}}var Uc=(t)=>new Ze(t.readKey());class Xe extends ss{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new Xe}clone(){let t=new Xe;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,r){let s=t.createTextNode(this.toString());if(r!==void 0)r._createAssociation(s,this);return s}toString(){return this.toDelta().map((t)=>{let e=[];for(let s in t.attributes){let i=[];for(let o in t.attributes[s])i.push({key:o,value:t.attributes[s][o]});i.sort((o,c)=>o.key<c.key?-1:1),e.push({nodeName:s,attrs:i})}e.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<e.length;s++){let i=e[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){let c=i.attrs[o];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=e.length-1;s>=0;s--)r+=`</${e[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Hc)}}var Tc=(t)=>new Xe;class on{constructor(t,e){this.id=t,this.length=e}get deleted(){throw L()}mergeWith(t){return!1}write(t,e,r){throw L()}integrate(t,e){throw L()}}var Ac=0;class V extends on{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){if(e>0)this.id.clock+=e,this.length-=e;Hs(t.doc.store,this)}write(t,e){t.writeInfo(Ac),t.writeLen(this.length-e)}getMissing(t,e){return null}}class ae{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ae(this.content)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var Cc=(t)=>new ae(t.readBuf());class ie{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new ie(this.len)}splice(t){let e=new ie(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){ne(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}var Dc=(t)=>new ie(t.readLen()),pi=(t,e)=>new yd({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class he{constructor(t){if(t._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=t;let e={};if(this.opts=e,!t.gc)e.gc=!1;if(t.autoLoad)e.autoLoad=!0;if(t.meta!==null)e.meta=t.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new he(pi(this.doc.guid,this.opts))}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){if(this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad)t.subdocsLoaded.add(this.doc)}delete(t){if(t.subdocsAdded.has(this.doc))t.subdocsAdded.delete(this.doc);else t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}var Bc=(t)=>new he(pi(t.readString(),t.readAny()));class ut{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ut(this.embed)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var Oc=(t)=>new ut(t.readJSON());class U{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new U(this.key,this.value)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){let r=e.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}var vc=(t)=>new U(t.readKey(),t.readJSON());class Qe{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Qe(this.arr)}splice(t){let e=new Qe(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}var Nc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++){let i=t.readString();if(i==="undefined")r.push(void 0);else r.push(JSON.parse(i))}return new Qe(r)},Rc=Zt("node_env")==="development";class at{constructor(t){this.arr=t,Rc&&Un(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new at(this.arr)}splice(t){let e=new at(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeAny(i)}}getRef(){return 8}}var Lc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++)r.push(t.readAny());return new at(r)};class K{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new K(this.str)}splice(t){let e=new K(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);if(r>=55296&&r<=56319)this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1);return e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}var Vc=(t)=>new K(t.readString()),Mc=[xc,yc,Sc,Ic,Ec,Uc,Tc],$c=0,Fc=1,jc=2,qc=3,Gc=4,zc=5,Hc=6;class W{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new W(this.type._copy())}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted)e.delete(t);else if(e.id.clock<(t.beforeState.get(e.id.client)||0))t._mergeStructs.push(e);e=e.right}this.type._map.forEach((r)=>{if(!r.deleted)r.delete(t);else if(r.id.clock<(t.beforeState.get(r.id.client)||0))t._mergeStructs.push(r)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((r)=>{while(r!==null)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Jc=(t)=>new W(Mc[t.readTypeRef()](t)),Qn=(t,e)=>{let r=e,s=0,i;do{if(s>0)r=m(r.client,r.clock+s);i=Ct(t,r),s=r.clock-i.id.clock,r=i.redone}while(r!==null&&i instanceof y);return{item:i,diff:s}},ur=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},Ye=(t,e,r)=>{let{client:s,clock:i}=e.id,o=new y(m(s,i+r),e,m(s,i+r-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(r));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=m(e.redone.client,e.redone.clock+r);if(e.right=o,o.right!==null)o.right.left=o;if(t._mergeStructs.push(o),o.parentSub!==null&&o.right===null)o.parent._map.set(o.parentSub,o);return e.length=r,o},Os=(t,e)=>$t(t,(r)=>ce(r.deletions,e)),gi=(t,e,r,s,i,o)=>{let c=t.doc,{store:l,clientID:h}=c,f=e.redone;if(f!==null)return N(t,f);let a=e.parent._item,u=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!r.has(a)||gi(t,a,r,s,i,o)===null))return null;while(a.redone!==null)a=N(t,a.redone)}let p=a===null?e.parent:a.content.type;if(e.parentSub===null){u=e.left,d=e;while(u!==null){let k=u;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){u=k;break}u=u.left}while(d!==null){let k=d;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){d=k;break}d=d.right}}else{if(d=null,e.right&&!i){u=e;while(u!==null&&u.right!==null&&(u.right.redone||ce(s,u.right.id)||Os(o.undoStack,u.right.id)||Os(o.redoStack,u.right.id))){u=u.right;while(u.redone)u=N(t,u.redone)}if(u&&u.right!==null)return null}else u=p._map.get(e.parentSub)||null;if(u!==null&&u.parent._item!==a)u=p._map.get(e.parentSub)||null}let g=b(l,h),w=m(h,g),C=new y(w,u,u&&u.lastId,d,d&&d.id,p,e.parentSub,e.content.copy());return e.redone=w,ur(C,!0),C.integrate(t,0),C};class y extends on{constructor(t,e,r,s,i,o,c,l){super(t,l.getLength());this.origin=r,this.left=e,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?ln:0}set marker(t){if((this.info&pe)>0!==t)this.info^=pe}get marker(){return(this.info&pe)>0}get keep(){return(this.info&cn)>0}set keep(t){if(this.keep!==t)this.info^=cn}get countable(){return(this.info&ln)>0}get deleted(){return(this.info&fe)>0}set deleted(t){if(this.deleted!==t)this.info^=fe}markDeleted(){this.info|=fe}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=b(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=b(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ot&&this.id.client!==this.parent.client&&this.parent.clock>=b(e,this.parent.client))return this.parent.client;if(this.origin)this.left=Ss(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=N(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===V||this.right&&this.right.constructor===V)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===y)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===y)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===ot){let r=Ct(e,this.parent);if(r.constructor===V)this.parent=null;else this.parent=r.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=Ss(t,t.doc.store,m(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null){s=this.parent._map.get(this.parentSub)||null;while(s!==null&&s.left!==null)s=s.left}else s=this.parent._start;let i=new Set,o=new Set;while(s!==null&&s!==this.right){if(o.add(s),i.add(s),$e(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if($e(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Ct(t.doc.store,s.origin))){if(!i.has(Ct(t.doc.store,s.origin)))r=s,i.clear()}else break;s=s.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start,this.parent._start=this;this.right=r}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(t)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(Hs(t.doc.store,this),this.content.integrate(t,this),Is(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new V(this.id,this.length).integrate(t,0)}get next(){let t=this.right;while(t!==null&&t.deleted)t=t.right;return t}get prev(){let t=this.left;while(t!==null&&t.deleted)t=t.left;return t}get lastId(){return this.length===1?this.id:m(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&$e(t.origin,this.lastId)&&this.right===t&&$e(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let e=this.parent._searchMarker;if(e)e.forEach((r)=>{if(r.p===t){if(r.p=this,!this.deleted&&this.countable)r.index-=this.length}});if(t.keep)this.keep=!0;if(this.right=t.right,this.right!==null)this.right.left=this;return this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;if(this.countable&&this.parentSub===null)e._length-=this.length;this.markDeleted(),ne(t.deleteSet,this.id.client,this.id.clock,this.length),Is(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)rc(t,this,new V(this.id,this.length));else this.content=new ie(this.length)}write(t,e){let r=e>0?m(this.id.client,this.id.clock+e-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Vt|(r===null?0:D)|(s===null?0:F)|(i===null?0:dt);if(t.writeInfo(o),r!==null)t.writeLeftID(r);if(s!==null)t.writeRightID(s);if(r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let h=js(c);t.writeParentInfo(!0),t.writeString(h)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else if(c.constructor===String)t.writeParentInfo(!0),t.writeString(c);else if(c.constructor===ot)t.writeParentInfo(!1),t.writeLeftID(c);else v();if(i!==null)t.writeString(i)}this.content.write(t,e)}}var mi=(t,e)=>Pc[e&Vt](t),Pc=[()=>{v()},Dc,Nc,Cc,Vc,Oc,vc,Jc,Lc,Bc,()=>{v()}],Kc=10;class M extends on{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){v()}write(t,e){t.writeInfo(Kc),_t(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var wi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},xi="__ $YJS$ __";if(wi[xi]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");wi[xi]=!0;var ZI=0,XI=1,QI=2,eR=3;class Fg extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function Wc(t){return _(t)&&"type"in t&&n(t.type)}function mk(t){let e=Ka(),{type:r}=t;switch(t.type){case"doc-sync":{_t(e,ZI),Ja(e,t.path),_t(e,t.epoch),Bo(e,t.body);break}case"awareness":{_t(e,XI),Bo(e,t.body);break}case"doc-close":{_t(e,QI),Ja(e,t.path);break}case"control":{_t(e,eR),Ja(e,JSON.stringify(t.message));break}default:throw new Fg(`unknown-frame:${r}`)}return br(e)}function gk(t){try{let e=Ya(t),r=Dt(e);switch(r){case ZI:{let s=Za(e),i=Dt(e);return{body:Xo(e),epoch:i,path:s,type:"doc-sync"}}case XI:return{body:Xo(e),type:"awareness"};case QI:return{path:Za(e),type:"doc-close"};case eR:{let s=JSON.parse(Za(e));if(!Wc(s))throw new Fg("malformed-control");return{message:s,type:"control"}}default:throw new Fg(`unknown-frame-type:${r}`)}}catch(e){if(e instanceof Fg)throw e;throw new Fg(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
|
|
6
|
+
export{pk,os,Ka,fk,br,_t,Ja,Bo,Ya,Xo,Dt,Za,_u,op,yd,KI,JI,YI,Q0,Pg,C2,ky,ba,e_,rs,t_,ss,ZI,XI,QI,eR,Fg,mk,gk};
|
|
7
7
|
|
|
8
|
-
//# debugId=
|
|
9
|
-
//# sourceMappingURL=studio-
|
|
8
|
+
//# debugId=88FB6E3DA045B1CD64756E2164756E21
|
|
9
|
+
//# sourceMappingURL=studio-dx73md4n.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{n,Z,_}from"./studio-
|
|
2
|
-
export{Se,oe,
|
|
1
|
+
import{n,Z,_}from"./studio-zkq3r91p.js";function y(t){return JSON.parse(JSON.stringify(t))}function Se(t){return t===void 0||t===null?t:y(t)}function oe(t,e){let r=t;for(let o of e){if(r==null)return;r=r[o]}return r}function Lv(t){if(Array.isArray(t))throw TypeError("Cannot insert into a children array; parentPath must point at a node");if(!t.children)t.children=[];if(!Array.isArray(t.children))throw TypeError("Cannot insert into mapped-array children; edit the map template instead");return t.children}function $v(t,e){let{op:r}=e;switch(e.op){case"set-key":{let o=oe(t,e.path);if(!o)throw Error(`doc-op-node-not-found:${e.path.join("/")}`);if(e.value===void 0)delete o[e.key];else o[e.key]=Se(e.value);return}case"insert-child":{l(t,e.parentPath).splice(e.index,0,Se(e.node));return}case"remove-child":{l(t,e.parentPath).splice(e.index,1);return}case"set-child":{l(t,e.parentPath).splice(e.index,1,Se(e.node));return}case"move-child":{P(e);let o=l(t,e.fromParentPath),a=l(t,e.toParentPath),[i]=o.splice(e.fromIndex,1);a.splice(e.toIndex,0,i);return}default:break}throw Error(`unknown-doc-op:${r}`)}function l(t,e){let r=oe(t,e);if(r==null)throw TypeError(`doc-op-node-not-found:${e.join("/")}`);return Lv(r)}function FC(t,e,r,o,a){let i=t.length,c=i<e.length&&t.every((s,u)=>s===e[u]),d=e[i+1];if(!c||e[i]!=="children"||!Z(d))return e;if(a?d<r:d<=r)return e;let h=[...e];return h[i+1]=d+o,h}function P(t){let e=[...t.fromParentPath,"children",t.fromIndex],r=t.toParentPath;if(r.length>=e.length&&e.every((o,a)=>o===r[a]))throw Error(`doc-op-move-into-self:${r.join("/")}`)}function sf(t,e){return t<0?Math.max(e+t,0):Math.min(t,e)}function jC(t,e){let{op:r}=e;switch(b(e),e.op){case"set-key":{let o=oe(t,e.path);if(o===void 0)throw Error(`doc-op-node-not-found:${e.path.join("/")}`);if(!_(o)||Array.isArray(o))throw TypeError(`doc-op-not-a-node:${e.path.join("/")}`);let a=Se(o[e.key]);return a===void 0?{key:e.key,op:"set-key",path:e.path}:{key:e.key,op:"set-key",path:e.path,value:a}}case"insert-child":{let{length:o}=f(t,e.parentPath);return{index:sf(e.index,o),op:"remove-child",parentPath:e.parentPath}}case"remove-child":{let o=x(t,e.parentPath,e.index);return{index:e.index,node:o,op:"insert-child",parentPath:e.parentPath}}case"set-child":{let o=x(t,e.parentPath,e.index);return{index:e.index,node:o,op:"set-child",parentPath:e.parentPath}}case"move-child":{P(e);let o=J(t,e.fromParentPath);m(o,e.fromParentPath,e.fromIndex);let a=f(t,e.toParentPath),i=sf(e.toIndex,a.length-(a===o?1:0));return{fromIndex:i,fromParentPath:FC(e.fromParentPath,e.toParentPath,e.fromIndex,-1,!1),op:"move-child",toIndex:e.fromIndex,toParentPath:FC(e.toParentPath,e.fromParentPath,i,1,!0)}}default:break}throw Error(`unknown-doc-op:${r}`)}function b(t){let e=[];if(t.op==="move-child")e.push([t.fromParentPath,t.fromIndex],[t.toParentPath,t.toIndex]);else if(t.op==="insert-child"||t.op==="remove-child"||t.op==="set-child")e.push([t.parentPath,t.index]);for(let[r,o]of e)if(!Number.isInteger(o))throw TypeError(`doc-op-index:${[...r,"children",String(o)].join("/")}`)}function J(t,e){let r=oe(t,e);return r&&Array.isArray(r.children)?r.children:null}function m(t,e,r){if(!t||r<0||r>=t.length)throw Error(`doc-op-node-not-found:${[...e,"children",r].join("/")}`)}function x(t,e,r){let o=J(t,e);return m(o,e,r),Se(o[r])}function f(t,e){let r=oe(t,e);if(!_(r)||Array.isArray(r))throw Error(`doc-op-node-not-found:${e.join("/")}`);if(r.children===void 0)return[];if(!Array.isArray(r.children))throw TypeError(`doc-op-mapped-children:${e.join("/")}`);return r.children}function ta(t,e){if(t.length>e.length)return!1;return t.every((r,o)=>r===e[o])}function g(t,e){let r=Math.min(t.length,e.length);for(let o=0;o<r;o++){let a=t[o],i=e[o];if(a===i)continue;if(Z(a)&&Z(i))return a-i;return String(a)<String(i)?-1:1}return t.length-e.length}function w(t){let e=[];for(let r of t)if(!t.some((o)=>!v(o,r)&&ta(o,r)))e.push([...r]);return e}function v(t,e){return t.length===e.length&&ta(t,e)}function af(t){let e=t?.at(-1);return t&&t.at(-2)==="children"&&Z(e)?{index:e,parentPath:t.slice(0,-2)}:null}function Qd(t){return af(t)!==null}function Ym(t){return w(t).filter((e)=>Qd(e)).toSorted((e,r)=>g(r,e))}function qx(t){if(Z(t)&&Number.isInteger(t))return t;return n(t)&&/^(?:0|[1-9]\d*)$/.test(t)?Number(t):null}function Gx(t,e,r,o){let a=af(e),i=a&&oe(t,a.parentPath),c=oe(t,r);if(!a||!i||!Array.isArray(i.children)||!c)return null;if(i.children[a.index]===void 0)return null;let d=i===c,h=d&&a.index<o?o-1:o,s=Array.isArray(c.children)?c.children.length:0,u={fromIndex:a.index,fromParentPath:a.parentPath,op:"move-child",toIndex:sf(h,s-(d?1:0)),toParentPath:r},p=jC(t,u);return{forward:u,inverse:p}}
|
|
2
|
+
export{Se,oe,Lv,$v,FC,sf,jC,ta,af,Qd,Ym,qx,Gx};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=5049D5BEC82B22A464756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-ekgtrndg.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{te}from"./studio-psh8mwnw.js";import{g,C}from"./studio-
|
|
1
|
+
import{te}from"./studio-psh8mwnw.js";import{g,C}from"./studio-4kzbrr5t.js";import{Ot,Nt}from"./studio-cpkamjdn.js";import{Ue,ft,T,R,Yt,tt}from"./studio-jttyqrmh.js";var _={$schema:"https://jxsuite.com/schema/v1",$id:"StudioGithubAuth",$description:"The RFC 8628 device flow's waiting room: the code GitHub minted, the page to type it into, and a Cancel. A `jx-dialog`, so the platform owns modality, Escape, focus restoration and the backdrop — and it is the reason the dialog has no confirm button at all: the answer arrives from GitHub over a poll rather than from anything the reader can press here, so a primary button would be a control with nothing to do. Nothing in this document talks to GitHub: `github/github-auth.ts` keeps the client id, the poll loop, its failure budget and every report the three outcomes raise.",tagName:"jx-dialog",$props:{headline:"Sign in to GitHub",confirmLabel:"",cancelLabel:"Cancel",size:"sm"},attributes:{part:"github-auth"},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/cancel"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},style:{$description:"Four `.github-auth-*` rules in `styles/overlays.css` become the parts below, and two things in them do not travel. `.github-auth-dialog`'s `padding: 16px 0` was the card's own body padding drawn by hand, and `jx-dialog` already pads its body; `.github-auth-dialog p { font-size: 13px }` was a body size this surface picked for itself, and what the paragraphs now inherit is the dialog's own `--jx-text-md`. The `8px 0` margins go with them — the column is a flex column with a gap, so a margin between two rows would be a second opinion about the same space. The code keeps its 24px, which is above the token scale on purpose: it is a string the reader has to copy onto another screen, and reading it out loud is the whole job of this dialog.",'& [part="device"]':{display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-3)",textAlign:"center"},'& [part="lede"], & [part="waiting"]':{margin:"0"},'& [part="code"]':{$description:"`<code>`, not a styled `<div>`: this is a literal string to be transcribed, and the element that says so is also the one a reader's own stylesheet and a screen reader's character-by-character mode already know about. It is this dialog's message, and the one string in it the reader must carry to another screen, so it opts back in to selection against the root's `user-select: none`. `all` rather than `text`: one click selects the whole code, so a copy never leaves a character behind.",userSelect:"all",fontFamily:"var(--font-mono)",fontSize:"24px",fontWeight:"700",letterSpacing:"2px",padding:"var(--jx-space-3) var(--jx-space-4)",background:"var(--hover-bg)",borderRadius:"var(--radius)"},'& [part="link"]':{$description:"The blue this carried as a `var(--accent, …)` fallback is gone: `--accent` is declared on `:root` in `styles/tokens.css`, so the fallback could only ever have painted when the token was missing — which is a theme fault to fix rather than a colour to hard-code.",color:"var(--accent)",textDecoration:"underline"},'& [part="waiting"]':{color:"var(--fg-dim)",fontStyle:"italic"}},children:[{tagName:"div",attributes:{part:"device"},children:[{tagName:"p",attributes:{part:"lede"},textContent:"Enter this code on GitHub to authorize Jx Studio:"},{tagName:"code",attributes:{part:"code"},textContent:"${state.userCode}"},{tagName:"a",attributes:{part:"link",href:"${state.verificationUri}",target:"_blank",rel:"noreferrer"},textContent:"Open ${state.verificationUri}"},{tagName:"p",attributes:{part:"waiting"},textContent:"Waiting for authorization…"}]}]};T("github-auth",_);function A(e){let t=document.createElement("div");t.style.pointerEvents="auto",t.setAttribute(Ue,ft("dialog","github-auth")),e.layer.append(t);let s=!1,l=()=>{if(s)return;s=!0,e.onClosed()},u=()=>s,b=g({cancel:()=>{e.onCancel()},closed:l,userCode:e.userCode,verificationUri:e.verificationUri}),n=null,r=R("github-auth",b,t).then(async(i)=>{n=i;let o=i.root;if(u())return i.dispose(),o;if(await Yt(o),u())return o;return Ot(o),o});return{close(){let i=n?.root;if(i instanceof HTMLElement)Nt(i);n?.dispose(),n=null,t.remove(),l()},host:t,ready:r}}var S="jx_github_token",v="Ov23liYVlMFpgjOEPXJH";function P(e){return typeof e==="object"&&e!==null&&"githubAuth"in e&&e.githubAuth!=null}function p(){let e=globalThis,t="__jxPlatform"in e?e.__jxPlatform:void 0;return P(t)?t.githubAuth:null}var f=null,H=!1;function E(e){f=e}function kT(){return f!==null||H||localStorage.getItem("jx_github_token")!==null}function ET(){return p()?"desktop":"browser"}function y(){return f??localStorage.getItem("jx_github_token")}function TT(){f=null,H=!1,localStorage.removeItem("jx_github_token"),p()?.signOut().catch(()=>{})}var O="github.auth",j="Source Control",N="git.signInToGithub",Y=3,z="The request never reached GitHub. GitHub's device-flow endpoints send no CORS headers, so a "+"browser cannot call them directly — the desktop app can. A machine that is offline fails "+"identically, and the browser does not say which happened.";function I(e){C.error("Could not reach GitHub to sign in.",{action:N,detail:`${z}
|
|
2
2
|
|
|
3
3
|
${te(e)}`,key:O,source:j})}function w(e,t){C.warn(e,{action:N,detail:t,key:O,source:j})}async function F(){let e;try{e=await fetch("https://github.com/login/device/code",{body:JSON.stringify({client_id:v,scope:"repo"}),headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"})}catch(t){return I(t),null}if(!e.ok)return w("GitHub refused to start the sign-in.",`GitHub answered ${e.status}${e.statusText?` ${e.statusText}`:""}.`),null;return await e.json()}async function hS(){let e=y();if(e)return e;let t=p();if(t)try{let{token:r}=await t.signIn();return E(r),r}catch(r){return w("GitHub sign-in was not completed.",te(r)),null}let s=await F();if(!s)return null;let{device_code:l,user_code:u,verification_uri:b,interval:n=5}=s;return new Promise((r)=>{let i=!1,o=null,m=0,k=!1,L=(c)=>{if(k)return;if(k=!0,i=!0,o)clearTimeout(o),o=null;r(c)},x=!1,G=()=>{if(x)return;x=!0,D.close()},d=(c)=>{L(c),G()},h=async()=>{if(i)return;try{let a=await(await fetch("https://github.com/login/oauth/access_token",{body:JSON.stringify({client_id:v,device_code:l,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"})).json();if(m=0,a.access_token){localStorage.setItem(S,a.access_token),d(a.access_token);return}if(a.error==="authorization_pending"){o=setTimeout(h,n*1000);return}if(a.error==="slow_down"){o=setTimeout(h,(n+5)*1000);return}w("GitHub sign-in was not completed.",a.error==="access_denied"?"The authorization was declined on GitHub.":a.error==="expired_token"?"The device code expired before it was entered.":`GitHub answered "${a.error??"an unrecognised response"}".`),d(null)}catch(c){if(m+=1,m>=Y){I(c),d(null);return}o=setTimeout(h,n*1000)}},D=A({layer:tt("dialog"),onCancel:()=>{G()},onClosed:()=>{d(null)},userCode:u,verificationUri:b});o=setTimeout(h,n*1000)})}
|
|
4
4
|
export{kT,ET,TT,hS};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
7
|
-
//# sourceMappingURL=studio-
|
|
6
|
+
//# debugId=71230E3FAF07DF7764756E2164756E21
|
|
7
|
+
//# sourceMappingURL=studio-epenqmvk.js.map
|