@jxsuite/studio 6.0.0 → 6.1.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-cs2sb9t1.js → 2020-nkxms0ay.js} +3 -3
- package/dist/chunks/adapter-m948ab5f.js +4 -0
- package/dist/chunks/{cf-account-picker-bb2yq946.js → cf-account-picker-n8hr38v7.js} +3 -3
- package/dist/chunks/cf-settings-356xdtne.js +4 -0
- package/dist/chunks/components-yk3t844e.js +4 -0
- package/dist/chunks/content-source-bawmyc09.js +4 -0
- package/dist/chunks/{convert-to-repeater-vqkt7s3s.js → convert-to-repeater-7wns8kf1.js} +3 -3
- package/dist/chunks/editor-6sc8nacq.js +4 -0
- package/dist/chunks/entry-commands-8ay9fh81.js +4 -0
- package/dist/chunks/{extension-sections-8beq9ac3.js → extension-sections-na7rj3nr.js} +3 -3
- package/dist/chunks/file-ops-gye0qw56.js +4 -0
- package/dist/chunks/files-dmc2xvcq.js +4 -0
- package/dist/chunks/format-host-t76b53f8.js +4 -0
- package/dist/chunks/fs-events-cg4tpz06.js +4 -0
- package/dist/chunks/git-panel-yef7bshy.js +4 -0
- package/dist/chunks/{grid-view-ca10def6.js → grid-view-7tt4bxw1.js} +6 -6
- package/dist/chunks/iframe-host-tmz30gfp.js +4 -0
- package/dist/chunks/{index-9ydfe04y.js → index-gybvv7a6.js} +3 -3
- package/dist/chunks/index-nag78a9h.js +4 -0
- package/dist/chunks/{javascript-d9pqgc2p.js → javascript-rnvdp3k4.js} +2 -2
- package/dist/chunks/{jsonMode-800yvbem.js → jsonMode-zhwsprqk.js} +5 -5
- package/dist/chunks/jx-validate-3gbp5nkn.js +4 -0
- package/dist/chunks/layers-fvz99859.js +4 -0
- package/dist/chunks/layers-panel-gchmbf9p.js +4 -0
- package/dist/chunks/lit-html-9agdspkt.js +4 -0
- package/dist/chunks/media-picker-rhjvyy00.js +4 -0
- package/dist/chunks/menu-2e4y9j7b.js +4 -0
- package/dist/chunks/{monaco-binding-62dtmgbf.js → monaco-binding-2jnhjjvr.js} +3 -3
- package/dist/chunks/monaco-buffer-rp21359g.js +4 -0
- package/dist/chunks/{monaco-setup-tj13ndtm.js → monaco-setup-vhh7gayr.js} +3 -3
- package/dist/chunks/notify-h3www560.js +4 -0
- package/dist/chunks/platform-hz34wcd7.js +4 -0
- package/dist/chunks/publish-panel-exsmjzyj.js +4 -0
- package/dist/chunks/quick-search-pgaqeh0m.js +4 -0
- package/dist/chunks/references-2cgdxnb8.js +4 -0
- package/dist/chunks/right-panel-jf856w5w.js +4 -0
- package/dist/chunks/section-registry-jnf8r5gy.js +4 -0
- package/dist/chunks/studio-0f55h9ye.js +5 -0
- package/dist/chunks/{studio-hjbg8d5y.js → studio-0sqdhnew.js} +7 -7
- package/dist/chunks/{studio-1wvfxkyy.js → studio-0x3jyb8r.js} +4 -4
- package/dist/chunks/{studio-yr04mv2j.js → studio-19x1c75w.js} +4 -4
- package/dist/chunks/{studio-evwgp1ym.js → studio-2sqcndak.js} +4 -4
- package/dist/chunks/{studio-x5g1xk77.js → studio-3aey7dd3.js} +4 -4
- package/dist/chunks/{studio-xkfs0dp2.js → studio-3bpdkq2s.js} +4 -4
- package/dist/chunks/{studio-5gs9th4b.js → studio-47y6fbpf.js} +4 -4
- package/dist/chunks/{studio-e47215hh.js → studio-4m3826v2.js} +4 -4
- package/dist/chunks/studio-4nx2dj1g.js +4 -0
- package/dist/chunks/{studio-gjknvzam.js → studio-4xv5s47r.js} +5 -5
- package/dist/chunks/{studio-sxc0zvpt.js → studio-5g0ag7c0.js} +3 -3
- package/dist/chunks/{studio-semd1s8s.js → studio-5g4t8v6w.js} +4 -4
- package/dist/chunks/studio-5py436sf.js +5 -0
- package/dist/chunks/{studio-aje966s9.js → studio-77kt594t.js} +4 -4
- package/dist/chunks/{studio-3ck2a5c4.js → studio-8f87n763.js} +6 -6
- package/dist/chunks/studio-8mb00b84.js +5 -0
- package/dist/chunks/studio-8p51gq2h.js +6 -0
- package/dist/chunks/studio-954ds834.js +5 -0
- package/dist/chunks/{studio-capk0583.js → studio-9ft45c83.js} +6 -6
- package/dist/chunks/studio-a2138x5k.js +7 -0
- package/dist/chunks/studio-a9yzstqj.js +5 -0
- package/dist/chunks/{studio-gp02nqnw.js → studio-acdksxx6.js} +4 -4
- package/dist/chunks/{studio-edbtvcd1.js → studio-anyrgzvb.js} +4 -4
- package/dist/chunks/{studio-4r0sjtx8.js → studio-ar8jcf2y.js} +4 -4
- package/dist/chunks/{studio-rmn2dz59.js → studio-bmn4mn9j.js} +5 -5
- package/dist/chunks/{studio-03wwfvyt.js → studio-cpxkgjrj.js} +4 -4
- package/dist/chunks/{studio-7qvs7v0m.js → studio-e7xxa0sj.js} +4 -4
- package/dist/chunks/{studio-01qza1n3.js → studio-ecaz25vk.js} +4 -4
- package/dist/chunks/{studio-5e9zsamh.js → studio-fzdywr6p.js} +6 -6
- package/dist/chunks/{studio-xg1942as.js → studio-g5fmf0c1.js} +4 -4
- package/dist/chunks/{studio-1q6amtph.js → studio-g7nse7zb.js} +4 -4
- package/dist/chunks/studio-geq1ea6k.js +14 -0
- package/dist/chunks/{studio-n78gjfy8.js → studio-ghkb32r8.js} +4 -4
- package/dist/chunks/{studio-bftp4n4b.js → studio-ghrhy2y7.js} +4 -4
- package/dist/chunks/{studio-5d7wfmnp.js → studio-grawhey1.js} +4 -4
- package/dist/chunks/{studio-rr4xkv81.js → studio-h0xgswew.js} +4 -4
- package/dist/chunks/{studio-cbr9czkn.js → studio-h9c4p2tx.js} +4 -4
- package/dist/chunks/studio-jyzj5cxs.js +5 -0
- package/dist/chunks/{studio-x92tgnee.js → studio-mgx8yhnz.js} +31 -31
- package/dist/chunks/{studio-g8dsj3d2.js → studio-mpb04y1d.js} +5 -5
- package/dist/chunks/{studio-zev8ssp1.js → studio-n17mty64.js} +4 -4
- package/dist/chunks/{studio-4jj9gme2.js → studio-nwh2eqsk.js} +5 -5
- package/dist/chunks/{studio-8xcwewjq.js → studio-pxg4ap1e.js} +3 -3
- package/dist/chunks/{studio-4m50vh74.js → studio-q1h883bt.js} +5 -5
- package/dist/chunks/{studio-c6zdm25z.js → studio-q4tv82h7.js} +6 -6
- package/dist/chunks/{studio-st75kn99.js → studio-qbj760tx.js} +5 -5
- package/dist/chunks/{studio-y7jehjrp.js → studio-qpqa7vk3.js} +4 -4
- package/dist/chunks/{studio-5vy2wfm5.js → studio-qqz8e5gk.js} +4 -4
- package/dist/chunks/{studio-qa73881a.js → studio-qvasen3f.js} +4 -4
- package/dist/chunks/studio-rggdb3hm.js +5 -0
- package/dist/chunks/{studio-4xppwncr.js → studio-sghy936h.js} +3 -3
- package/dist/chunks/{studio-mk00zd5d.js → studio-skprc6ef.js} +4 -4
- package/dist/chunks/{studio-cqmtbg2p.js → studio-tt2nactf.js} +4 -4
- package/dist/chunks/{studio-ge5fqjth.js → studio-txjjzrsm.js} +5 -5
- package/dist/chunks/{studio-tmeq6mjb.js → studio-tyasmc39.js} +4 -4
- package/dist/chunks/{studio-0bbxhhce.js → studio-v2bvmbjj.js} +4 -4
- package/dist/chunks/{studio-pwqfmt4p.js → studio-vk9ezads.js} +4 -4
- package/dist/chunks/{studio-fqq890ap.js → studio-vzacdfsc.js} +3 -3
- package/dist/chunks/{studio-zd4kayn2.js → studio-w4c0xmrw.js} +4 -4
- package/dist/chunks/{studio-ztvcxm3w.js → studio-wfjqhhbk.js} +4 -4
- package/dist/chunks/{studio-tp642n5g.js → studio-wgh5kxpj.js} +4 -4
- package/dist/chunks/studio-xasj0796.js +5 -0
- package/dist/chunks/{studio-tzegmy4w.js → studio-y78s8r2n.js} +4 -4
- package/dist/chunks/{studio-7pgy3xaf.js → studio-z8w183sh.js} +4 -4
- package/dist/chunks/{studio-01kbbqg3.js → studio-zscd9ty4.js} +124 -124
- package/dist/chunks/{studio-hnvnfbdv.js → studio-zxp13sss.js} +6 -6
- package/dist/chunks/{studio-r3kaka4d.js → studio-zygnmm01.js} +4 -4
- package/dist/chunks/{tsMode-k9s9fcag.js → tsMode-gr0m4dzr.js} +5 -5
- package/dist/chunks/workspace-m15qtcqp.js +4 -0
- package/dist/chunks/{ws-client-0ja08haa.js → ws-client-nf61frr1.js} +3 -3
- package/dist/manifest.json +62 -62
- package/dist/studio.js +83 -83
- package/package.json +2 -2
- package/src/new-project/add-repo-modal.ts +459 -59
- package/src/platforms/cloud.ts +95 -18
- package/src/publish/pages-service.ts +7 -0
- package/src/publish/publish-panel.ts +16 -2
- package/src/surfaces/add-repo.json +721 -224
- package/src/surfaces/add-repo.ts +196 -31
- package/src/types.ts +42 -3
- package/src/utils/project-dir.ts +24 -0
- package/dist/chunks/adapter-y5gdq19c.js +0 -4
- package/dist/chunks/cf-settings-20dznc3j.js +0 -4
- package/dist/chunks/components-q037dya7.js +0 -4
- package/dist/chunks/content-source-t0q184js.js +0 -4
- package/dist/chunks/editor-j5sq149q.js +0 -4
- package/dist/chunks/entry-commands-fxzgcc4k.js +0 -4
- package/dist/chunks/file-ops-2n77759h.js +0 -4
- package/dist/chunks/files-fjy7zpxt.js +0 -4
- package/dist/chunks/format-host-wj3mf3n8.js +0 -4
- package/dist/chunks/fs-events-7kcgn4e9.js +0 -4
- package/dist/chunks/git-panel-7z2mpt2d.js +0 -4
- package/dist/chunks/iframe-host-a0zjd6xp.js +0 -4
- package/dist/chunks/index-m0x5ztax.js +0 -4
- package/dist/chunks/jx-validate-zc9zp77s.js +0 -4
- package/dist/chunks/layers-p677nrh5.js +0 -4
- package/dist/chunks/layers-panel-y4w1dq90.js +0 -4
- package/dist/chunks/lit-html-cfn61dn7.js +0 -4
- package/dist/chunks/media-picker-xg7yjpz9.js +0 -4
- package/dist/chunks/menu-fpekzj6w.js +0 -4
- package/dist/chunks/monaco-buffer-nn4dtx27.js +0 -4
- package/dist/chunks/notify-ahs57a2z.js +0 -4
- package/dist/chunks/platform-v9xyfkbx.js +0 -4
- package/dist/chunks/publish-panel-xtbfgg2r.js +0 -4
- package/dist/chunks/quick-search-d3a6m7j3.js +0 -4
- package/dist/chunks/references-99ws0b0m.js +0 -4
- package/dist/chunks/right-panel-31vbk5xp.js +0 -4
- package/dist/chunks/section-registry-b2yzp9sw.js +0 -4
- package/dist/chunks/studio-1a99w39s.js +0 -5
- package/dist/chunks/studio-4fde4a0x.js +0 -5
- package/dist/chunks/studio-84rtc120.js +0 -5
- package/dist/chunks/studio-aekhcdzw.js +0 -7
- package/dist/chunks/studio-aqmph6k4.js +0 -5
- package/dist/chunks/studio-chdmwwzw.js +0 -5
- package/dist/chunks/studio-cp1gbff9.js +0 -14
- package/dist/chunks/studio-fbx6twps.js +0 -6
- package/dist/chunks/studio-fthwn4kf.js +0 -5
- package/dist/chunks/studio-nbxqcgvf.js +0 -5
- package/dist/chunks/studio-t1eedsyx.js +0 -4
- package/dist/chunks/studio-vavmwshr.js +0 -5
- package/dist/chunks/workspace-5vmgsagj.js +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{kk}from"./studio-geq1ea6k.js";import{T,R,vs,Om}from"./studio-e7xxa0sj.js";import{v}from"./studio-vzacdfsc.js";import{Oe}from"./studio-a9yzstqj.js";var w={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMenu",$description:"A Studio menu: one jx-menu whose rows are a projection of command records the adapter hands in as `rows`. Nothing here decides what a row says; a row prints its record's title, chord, disabled reason and destructive flag, a divider falls where the adapter marked a group boundary, and a row with children owns a one-level submenu of the same shape. The chord and the reason are rendered only when present, so a row's text is its title.",tagName:"jx-menu",$props:{label:{$ref:"#/state/label"},x:{$ref:"#/state/x"},y:{$ref:"#/state/y"},floor:{$ref:"#/state/floor"},placement:{$ref:"#/state/placement"}},onselect:{$ref:"#/state/select"},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/id"},map:{tagName:"div",attributes:{role:"none"},children:[{tagName:"div",attributes:{role:"none"},$switch:{$ref:"$map/item/dividerAbove"},cases:{true:{tagName:"hr"}}},{tagName:"jx-menu-item",$props:{value:{$ref:"$map/item/id"},disabled:{$ref:"$map/item/disabled"},destructive:{$ref:"$map/item/destructive"},requires:{$ref:"$map/item/requires"},checked:{$ref:"$map/item/checked"},haspopup:{$ref:"$map/item/haspopup"}},attributes:{"data-command-id":"${$map.item.id}"},children:[{tagName:"span",textContent:"${$map.item.title}"},{tagName:"span",attributes:{slot:"value"},$switch:{$ref:"$map/item/noChord"},cases:{false:{tagName:"kbd",textContent:"${$map.item.chord}"}}},{tagName:"span",attributes:{slot:"description"},$switch:{$ref:"$map/item/enabled"},cases:{false:{tagName:"span",textContent:"Needs ${$map.item.requires}"}}},{tagName:"span",attributes:{slot:"submenu"},$switch:{$ref:"$map/item/haspopup"},cases:{true:{tagName:"jx-menu",$props:{label:{$ref:"$map/item/submenuLabel"}},children:[{$prototype:"Array",items:{$ref:"$map/item/children"},key:{$ref:"$map/item/id"},map:{tagName:"div",attributes:{role:"none"},children:[{tagName:"div",attributes:{role:"none"},$switch:{$ref:"$map/item/dividerAbove"},cases:{true:{tagName:"hr"}}},{tagName:"jx-menu-item",$props:{value:{$ref:"$map/item/id"},disabled:{$ref:"$map/item/disabled"},destructive:{$ref:"$map/item/destructive"},requires:{$ref:"$map/item/requires"},checked:{$ref:"$map/item/checked"}},attributes:{"data-command-id":"${$map.item.id}"},children:[{tagName:"span",textContent:"${$map.item.title}"},{tagName:"span",attributes:{slot:"value"},$switch:{$ref:"$map/item/noChord"},cases:{false:{tagName:"kbd",textContent:"${$map.item.chord}"}}},{tagName:"span",attributes:{slot:"description"},$switch:{$ref:"$map/item/enabled"},cases:{false:{tagName:"span",textContent:"Needs ${$map.item.requires}"}}}]}]}}]}}}]}]}}]};T("menu",w);var M="block-end span-inline-end";function j(e){if(e.placement!==void 0)return e.placement;return e.opener&&!e.origin&&!e.place&&!e.floor?M:""}function E(e){if(!e)return{x:0,y:0};let n=Oe(e);return{x:Math.round(n.left),y:Math.round(n.bottom)}}function p(e,n=0){let r=n===0?(e.children??[]).map((t)=>p(t,1)):[];return{...e,checked:e.checked??"",children:r,chord:e.chord??"",enabled:!e.disabled,haspopup:r.length>0,noChord:!e.chord,noDivider:!e.dividerAbove,requires:e.requires??"",submenuLabel:e.submenuLabel??e.title}}function N(e,n){for(let r of e){if(r.id===n)return r;let t=r.children.find((d)=>d.id===n);if(t)return t}return}var L={bottom:0,height:0,left:0,right:0,top:0,width:0,x:0,y:0};function Nt(e){let n=vs("popover",e.region),r=new AbortController,t=null,d=null,i=!1,f=()=>{if(i)return;i=!0,r.abort(),d?.(),d=null,Om("popover",e.region),P(e.opener??null),e.onClosed?.(u)},h=e.place?e.place(L):e.origin??E(e.opener),l=v({floor:e.floor?.()??0,label:e.label,placement:j(e),rows:e.rows.map((o)=>p(o)),select:(o,m)=>{let a=String(m.detail),s=N(l.rows,a);if(!s)return;if(s.run)s.run();else e.run?.(a);u.close()},x:h.x,y:h.y}),b=()=>{if(i||!t||!e.place)return;let o=e.place(Oe(t));l.x=o.x,l.y=o.y},y=(async()=>{let o=await R("menu",l,n,{signal:r.signal});if(r.signal.aborted)return;if({dispose:d}=o,t=o.root,t.addEventListener("toggle",(a)=>{if(a.newState==="closed")f()}),!t.hasAttribute("popover"))await new Promise((a)=>{t.addEventListener("jx-ready",()=>a(),{once:!0})});if(r.signal.aborted)return;let m=e.opener instanceof HTMLElement&&e.opener!==document.body?e.opener:void 0;t.showPopover(m?{source:m}:void 0),b(),requestAnimationFrame(b)})(),u={close:()=>{if(i)return;if(t?.open)t.hidePopover();f()},host:n,ready:y,setRows:(o)=>{if(i)return;let a=document.activeElement?.closest("jx-menu"),s=a&&a!==t?a.parentElement?.closest("jx-menu-item")?.dataset.commandId:void 0;l.rows=o.map((c)=>p(c)),setTimeout(()=>{if(i||!t||t.contains(document.activeElement))return;let c=s?t.querySelector(`jx-menu-item[data-command-id="${s}"]`):null,g=c?.querySelector("jx-menu")??null;if(c&&!(g?.open&&g.querySelector("jx-menu-item")))c.focus();else kk(t)},0)}};return u}function P(e){let n=document.activeElement;if(e?.isConnected&&(!n||n===document.body))e.focus()}
|
|
2
2
|
export{Nt};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=7280D90AC8977E7664756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-pxg4ap1e.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{ge,Q,v,re
|
|
1
|
+
import{ge,Q,v,re,AI,k}from"./studio-vzacdfsc.js";import{ov,$o,ai,dv,mp,q,ot,yi,li,Se,Do,oo,He,Qn,yp,m,$r,qa}from"./studio-3aey7dd3.js";import{p}from"./studio-qpqa7vk3.js";import{nh}from"./studio-tt2nactf.js";import{_t,Lr,qr}from"./studio-5g4t8v6w.js";import{te}from"./studio-ery42sqr.js";import{D,Bl,vt}from"./studio-wgh5kxpj.js";import{me}from"./studio-v2bvmbjj.js";function G(e){return e.replaceAll("~","~0").replaceAll("/","~1")}var Oe=100;function H(e){let t={blankAfter:new Set,escaped:new Map,inline:new Map},o=0,n=()=>{let a=0;while(o<e.length&&(e[o]===" "||e[o]==="\t"||e[o]==="\r"||e[o]===`
|
|
2
2
|
`)){if(e[o]===`
|
|
3
3
|
`)a+=1;o+=1}return a},r=()=>{let a=o,f=new Set;o+=1;while(o<e.length&&e[o]!=='"')if(e[o]==="\\")if(e[o+1]==="u"){let u=Number.parseInt(e.slice(o+2,o+6),16);if(u>=128)f.add(u);o+=6}else o+=2;else o+=1;return o+=1,{escaped:f,raw:e.slice(a,o)}},i=(a,f)=>{let u=n();if(e[o]===f)return o+=1,!0;if(o+=1,u+=n(),u>=2)t.blankAfter.add(a);return!1},s=(a)=>{n();let f=e[o];if(f==="{"){o+=1;let u=n()>0;if(e[o]==="}"){o+=1;return}t.inline.set(a,!u);while(o<e.length){let l=JSON.parse(r().raw);n(),o+=1;let c=`${a}/${G(l)}`;if(s(c),i(c,"}"))return}}else if(f==="["){if(o+=1,n(),e[o]==="]"){o+=1;return}for(let u=0;o<e.length;u+=1){let l=`${a}/${u}`;if(s(l),i(l,"]"))return}}else if(f==='"'){let{escaped:u}=r();if(u.size>0)t.escaped.set(a,u)}else while(o<e.length&&!`,]} \r
|
|
4
4
|
`.includes(e[o]))o+=1};return s(""),t}function hs(e){return{document:JSON.parse(e),layout:H(e)}}var Me=/[^\u0020-\u007E]/,Je=/^[\p{Mn}\p{Me}\p{Cf}]$/u,ze=/^\p{Emoji_Presentation}$/u;function Fe(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=12871&&e!==12351||e>=12880&&e<=19903||e>=19968&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65131||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=110592&&e<=110593||e>=127488&&e<=127569||e>=131072&&e<=262141)}function ae(e){if(!Me.test(e))return e.length;let t=0;for(let o of e){if(Je.test(o))continue;t+=Fe(o.codePointAt(0))||ze.test(o)?2:1}return t}function Be(e){return e===void 0||typeof e==="function"||typeof e==="symbol"}function V(e){return Object.entries(e).filter(([,t])=>!Be(t))}function M(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Ue(e){if(e.length<2)return!1;let t=Array.isArray(e[0])?"array":M(e[0])?"object":null;if(t===null)return!1;return e.every((o)=>t==="array"?Array.isArray(o)&&o.length>1:M(o)&&V(o).length>1)}function Ge(e){return e.length>1&&e.every((t)=>typeof t==="number")}function le(e,t){let o=JSON.stringify(e)??"null";return t===void 0?o:o.replaceAll(/[\u0080-\uFFFF]/g,(n)=>{let r=n.codePointAt(0);return t.has(r)?`\\u${r.toString(16).padStart(4,"0")}`:n})}function pr(e,t,o=Oe){let n=t?.inline??new Map,r=t?.blankAfter??new Set,i=t?.escaped??new Map,s=(l,c)=>n.get(l)??c,a=(l,c,d)=>{if(Array.isArray(l)){if(l.length===0)return"[]";if(Ue(l))return null;let g=[];for(let[b,h]of l.entries()){let w=`${c}/${b}`,x=r.has(w)?null:a(h,w,d);if(x===null)return null;g.push(x)}return`[${g.join(", ")}]`}if(M(l)){let g=V(l);if(g.length===0)return"{}";if(!s(c,d))return null;let b=[];for(let[h,w]of g){let x=`${c}/${G(h)}`,S=r.has(x)?null:a(w,x,!0);if(S===null)return null;b.push(`${JSON.stringify(h)}: ${S}`)}return`{ ${b.join(", ")} }`}return le(l,i.get(c))},f=(l)=>l.map(({path:c,text:d},g)=>g===l.length-1?d:`${d},
|
|
@@ -9,8 +9,8 @@ ${Ve(l,S,o,(_)=>r.has(`${c}/${_}`))}${B}]`;let E=l.map((N,_)=>{let A=`${c}/${_}`
|
|
|
9
9
|
${f(E)}${B}]`}let se=V(l),Ee=s(c,b),Ne=se.map(([E,N],_)=>{let A=`${c}/${G(E)}`,O=`${JSON.stringify(E)}: `,U=_===se.length-1,$e=S.length+ae(O),De=u(N,A,d+2,$e,Ee,U?0:1);return{path:A,text:`${S}${O}${De}`}});return`{
|
|
10
10
|
${f(Ne)}${B}}`};return`${u(e,"",0,0,!1,0)}
|
|
11
11
|
`}function Ve(e,t,o,n){let r=[],i="";for(let[s,a]of e.entries()){let f=`${le(a)}${s===e.length-1?"":","}`;if(i==="")i=`${t}${f}`;else if(i.length+1+f.length<=o)i=`${i} ${f}`;else r.push(i),i=`${t}${f}`;if(n(s)&&s<e.length-1)r.push(i,""),i=""}return r.push(i),r.join(`
|
|
12
|
-
`)}var ce=new Set([Qn,vp]),Ze=new Set(["auto","light","dark"]);function qe(e){let{ui:t}=e.session;return{activeMedia:t.activeMedia,canvasMode:t.canvasMode,editZoom:t.editZoom,preview:t.preview,previewColorScheme:t.previewColorScheme,previewLocale:t.previewLocale,showLayout:t.showLayout,zoom:t.zoom}}function ue(){let e={},t=[];for(let o of m.panes){if(o.derived)continue;let n=[];for(let i of o.tabOrder){let s=m.tabs.get(i);if(!s?.documentPath)continue;n.push(s.documentPath),e[s.documentPath]=qe(s)}if(n.length===0)continue;let r=o.activeTabId?m.tabs.get(o.activeTabId):null;t.push({activeFile:r?.documentPath??null,files:n,id:o.id})}return{focusedPane:m.activePaneId,panes:t,ui:e}}function We(e){if(typeof e!=="object"||e===null)return{};let t=e,o={};if(typeof t.canvasMode==="string")o.canvasMode=t.canvasMode;if(typeof t.preview==="boolean")o.preview=t.preview;if(typeof t.zoom==="number"&&Number.isFinite(t.zoom))o.zoom=t.zoom;if(typeof t.editZoom==="number"&&Number.isFinite(t.editZoom))o.editZoom=t.editZoom;if(t.activeMedia===null||typeof t.activeMedia==="string")o.activeMedia=t.activeMedia;if(typeof t.previewColorScheme==="string"&&Ze.has(t.previewColorScheme))o.previewColorScheme=t.previewColorScheme;if(t.previewLocale===null||iv(t.previewLocale))o.previewLocale=t.previewLocale;if(typeof t.showLayout==="boolean")o.showLayout=t.showLayout;return o}function fe(e){if(typeof e!=="object"||e===null)return null;let t=e;if(!Array.isArray(t.panes))return null;let o=[];for(let r of t.panes){if(typeof r!=="object"||r===null)continue;let i=r;if(typeof i.id!=="string"||!ce.has(i.id))continue;let s=Array.isArray(i.files)?i.files.filter((a)=>typeof a==="string"&&a!==""):[];if(s.length===0)continue;o.push({activeFile:typeof i.activeFile==="string"&&s.includes(i.activeFile)?i.activeFile:null,files:s,id:i.id})}if(o.length===0)return null;let n={};if(typeof t.ui==="object"&&t.ui!==null)for(let[r,i]of Object.entries(t.ui))n[r]=We(i);return{focusedPane:typeof t.focusedPane==="string"&&ce.has(t.focusedPane)?t.focusedPane:Qn,panes:o,ui:n}}async function XT(e,t){let o=0;if(e.panes.some((n)=>n.id===vp))t.ensureSecondPane();for(let n of e.panes)for(let r of n.files){try{await t.openFile(r,n.id)}catch{}if([...m.tabs.values()].some((i)=>i.documentPath===r))o+=1}if(o===0)return 0;for(let n of m.tabs.values()){let r=n.documentPath?e.ui[n.documentPath]:void 0;if(!r)continue;let{ui:i}=n.session;if(r.canvasMode&&n.capabilities.modes.includes(r.canvasMode))i.canvasMode=r.canvasMode;if(r.preview!==void 0)i.preview=r.preview;if(r.zoom!==void 0)i.zoom=r.zoom;if(r.editZoom!==void 0)i.editZoom=r.editZoom;if(r.activeMedia!==void 0)i.activeMedia=r.activeMedia;if(r.previewColorScheme!==void 0)i.previewColorScheme=r.previewColorScheme;if(r.previewLocale!==void 0)i.previewLocale=r.previewLocale;if(r.showLayout!==void 0)i.showLayout=r.showLayout}for(let n of e.panes){let r=m.panes.find((s)=>s.id===n.id);if(!r||!n.activeFile)continue;let i=r.tabOrder.find((s)=>m.tabs.get(s)?.documentPath===n.activeFile);if(i)r.activeTabId=i}if(m.panes.some((n)=>n.id===e.focusedPane))$r(e.focusedPane);return o}var pe={default:{description:"Resume whatever was persisted — layout, recents, settings, chat history.",id:"default",reset:"none"},fresh:{description:"A first-run app: no layout, no recents, no settings, no history.",id:"fresh",reset:"app-state"}},Ke="default",Ye=/^jx[-._:]/;function Xe(e){return Ye.test(e)}function Qe(){let e=globalThis.localStorage;if(!e)return[];let t=[];try{for(let o=0;o<e.length;o++){let n=e.key(o);if(n&&Xe(n))t.push(n)}for(let o of t)e.removeItem(o)}catch{}return t}function et(e){let t=pe[e];if(!t)throw RangeError(`unknown startup profile "${e}"; declared: ${Object.keys(pe).join(", ")}`);if(t.reset==="app-state")Qe();return t}var J=null;function de(e){if(J)return J;let t=new URLSearchParams(e??globalThis.location?.search??""),o=et(t.get("profile")??Ke),n=t.get("clock");return J={clock:n===null?null:$I(n),profile:o},J}var W=["files","search","git","i18n","layers","page","data","packages","insert"],tt={blocks:"insert",head:"page",imports:"packages",state:"data"},ye="layers";function ee(e){return typeof e==="string"&&W.includes(e)}function vx(e,t){if(!ee(e))throw Error(`${t}: "${e}" is not a declared Navigator panel id.`);return e}function be(e){if(typeof e!=="string")return null;let t=tt[e];if(t)return t;return ee(e)?e:null}var K=["properties","style","events","assistant"],qb="properties";function yx(e){return typeof e==="string"&&K.includes(e)}var Gb=["problems","logic","activity"],wx="problems";function Kb(e){return typeof e==="string"&&Gb.includes(e)}var Jb=["light","dark"],he="jx-studio-panel-widths",ve="jx-studio-project::",nt="dark";function rt(e){return typeof e==="string"&&Jb.includes(e)}function it(){let e=Lr(_t.theme);return rt(e)?e:nt}var Sd=["left","right","bottom"],R={bottom:{collapsed:!0,size:220},left:{collapsed:!1,size:240},right:{collapsed:!1,size:280}},QT={bottom:R.bottom.size,left:R.left.size,right:R.right.size},st={bottom:"--dock-h-bottom",left:"--panel-w-left",right:"--panel-w-right"},at={bottom:"bottom-collapsed",left:"left-collapsed",right:"right-collapsed"},AC=0.5,xx=0.2,_x=0.8;function lt(e){return typeof e==="number"&&e>=xx&&e<=_x?e:AC}function eL(e){y.paneSplit=Math.min(_x,Math.max(xx,e))}function ct(){try{return JSON.parse(localStorage.getItem(he)||"{}")}catch{return{}}}function we(){return{branches:null,commitMessage:"",diffState:null,error:null,lastUpdated:null,loading:!1,logEntries:null,rev:0,status:null,subTab:"changes"}}function Pe(){return{customizedOnly:!1,filter:"",selection:null,tab:"elements"}}function ke(){return[{bottomTab:"problems",docks:{bottom:{collapsed:!0,size:220},left:{collapsed:!1,size:240},right:{collapsed:!0,size:280}},id:"write",inspectorTab:"properties",name:"Write",navigatorPanel:"files"},{bottomTab:"problems",docks:{bottom:{collapsed:!0,size:220},left:{collapsed:!1,size:240},right:{collapsed:!1,size:320}},id:"design",inspectorTab:"style",name:"Design",navigatorPanel:"layers"},{bottomTab:"logic",docks:{bottom:{collapsed:!0,size:260},left:{collapsed:!1,size:280},right:{collapsed:!1,size:300}},id:"build",inspectorTab:"events",name:"Build",navigatorPanel:"data"},{bottomTab:"activity",docks:{bottom:{collapsed:!1,size:240},left:{collapsed:!1,size:300},right:{collapsed:!0,size:280}},id:"ship",inspectorTab:"properties",name:"Ship",navigatorPanel:"git"}]}var z="design";function ut(){let e=ct(),t={};for(let o of Sd){let n=e[o],r=e[`${o}Collapsed`];t[o]={collapsed:typeof r==="boolean"?r:R[o].collapsed,size:typeof n==="number"&&n>0?n:R[o].size}}return{bottomTab:Kb(e.bottomTab)?e.bottomTab:wx,docks:t,focusRegion:"pane",paneSplit:lt(e.paneSplit),git:we(),layout:z,layoutSelection:null,layouts:ke(),leftTab:be(e.leftTab)??ye,settingsTab:"stylebook",stylebook:Pe(),theme:it()}}de();var y=v(ut());function Ed(){try{localStorage.setItem(he,JSON.stringify({bottom:y.docks.bottom.size,bottomCollapsed:y.docks.bottom.collapsed,bottomTab:y.bottomTab,left:y.docks.left.size,leftCollapsed:y.docks.left.collapsed,leftTab:y.leftTab,paneSplit:y.paneSplit,right:y.docks.right.size,rightCollapsed:y.docks.right.collapsed}))}catch{}}var Y;function ft(e){if(typeof e!=="object"||e===null)return!1;let t=e;return typeof t.id==="string"&&t.id!==""&&typeof t.name==="string"&&ee(t.navigatorPanel)&&yx(t.inspectorTab)&&Kb(t.bottomTab)&&Sd.every((o)=>typeof t.docks?.[o]?.size==="number")}function oe(e){if(!e)return{};try{return JSON.parse(localStorage.getItem(`${ve}${e}`)||"{}")}catch{return{}}}function pt(e){let t={activeLayout:null,layouts:ke()};if(!e)return t;let o=oe(e),n=Array.isArray(o.layouts)?o.layouts.filter(ft):[];if(n.length===0)return t;return{activeLayout:typeof o.activeLayout==="string"?o.activeLayout:null,layouts:n}}function tL(e){return fe(oe(e).session)}var ne=null;function Yb(e){ne=e}function nL(){C()}function C(){let e=m.projectRoot;if(!e)return;try{localStorage.setItem(`${ve}${e}`,JSON.stringify({activeLayout:y.layout,layouts:y.layouts,session:e===ne?ue():oe(e).session}))}catch{}}function dt(e){if(e===Y)return;Y=e;let{activeLayout:t,layouts:o}=pt(e);y.layouts=o;let n=(r)=>r!==null&&o.some((i)=>i.id===r);y.layout=n(t)?t:n(y.layout)?y.layout:n(z)?z:o[0]?.id??z}function xe(e){return y.layouts.find((t)=>t.id===e)}function mt(e){return e.trim().toLowerCase().replaceAll(/[^a-z0-9]+/g,"-").replaceAll(/^-|-$/g,"")||"layout"}function Te(e,t){let o=xe(e);if(!o)throw RangeError(`no layout named "${e}" — this project has: ${y.layouts.map((n)=>n.id).join(", ")}`);y.layout=o.id,y.leftTab=o.navigatorPanel,y.bottomTab=o.bottomTab;for(let n of Sd)y.docks[n].collapsed=o.docks[n].collapsed,y.docks[n].size=o.docks[n].size;t.setInspectorTab(o.inspectorTab),Ed(),C()}function gt(e,t){let o=e.trim(),n=mt(o),r={};for(let a of Sd)r[a]={collapsed:y.docks[a].collapsed,size:y.docks[a].size};let i={bottomTab:Kb(y.bottomTab)?y.bottomTab:wx,docks:r,id:n,inspectorTab:t.inspectorTab(),name:o||n,navigatorPanel:be(y.leftTab)??ye},s=y.layouts.findIndex((a)=>a.id===n);if(s===-1)y.layouts.push(i);else y.layouts.splice(s,1,i);return y.layout=n,C(),i}function yt(e,t){let o=xe(e),n=t.trim();if(!o||!n)return;o.name=n,C()}function bt(e){if(y.layouts.length<2)return;let t=y.layouts.findIndex((o)=>o.id===e);if(t===-1)return;if(y.layouts.splice(t,1),y.layout===e)y.layout=y.layouts[0].id;C()}function ht(e){Te(y.layout,e)}function dp(e=y.theme){return e==="light"?"vs":"vs-dark"}function wt(){document.documentElement.dataset.theme=y.theme,th()?.editor.setTheme(dp())}function St(){let e=document.documentElement;for(let o of Sd)e.style.setProperty(st[o],`${y.docks[o].size}px`);let t=document.querySelector("#app");if(!t)return;for(let o of Sd)t.classList.toggle(at[o],y.docks[o].collapsed)}var Z=null,X=[];function dm(e){if(!X.includes(e))X.push(e)}function iL(){if(Z)return;for(let e of X)e.mount();Z=ge(),Z.run(()=>{Q(()=>{St()}),Q(()=>{wt()}),Q(()=>{dt(m.projectRoot)}),Q(()=>{let e=m.projectRoot;m.activePaneId;for(let t of m.panes)t.id,t.activeTabId,t.tabOrder.join("\x00");if(e)C()})})}function fr(e,t){if(y.docks[e].collapsed===t){Ed();return}y.docks[e].collapsed=t,Ed()}function Pt(e){fr(e,!y.docks[e].collapsed)}function oL(e,t){y.docks[e].size=t}function fs(e){y.leftTab=e,fr("left",!1),Ed()}function Td(e){y.bottomTab=e,fr("bottom",!1),Ed()}function NC(e){if(y.theme===e)return;y.theme=e,qr(_t.theme,e)}function rL(e){if(e===y.leftTab&&!y.docks.left.collapsed){fr("left",!0);return}fs(e)}function OC(e){y.layoutSelection=e}function Zb(){Object.assign(y.git,we()),Object.assign(y.stylebook,Pe()),y.settingsTab="stylebook",y.layoutSelection=null,ne=null,Y=void 0}var I=(e)=>e.project.open;function kt(e){return[{args:Se({tab:Do(W,"Which Navigator panel to show.")}),category:"View",id:"view.setActivity",level:"application",menus:["commandbar/overflow","palette"],group:"4_docks",requires:"an open project",when:I,run:(t,o)=>{let n=li("view.setActivity",o,"tab",W);if(e.panelAvailable&&!e.panelAvailable(n))throw RangeError(`command "view.setActivity" argument "tab": "${n}" names a panel that is registered but not available right now, so showing it would persist a Navigator tab nothing can draw`);fs(n)},title:"Show Navigator Panel"},{args:Se({tab:Do(K,"Which Inspector tab to show.")}),category:"View",id:"view.setRightTab",level:"document",menus:["palette"],group:"4_docks",requires:"an open document",when:(t)=>t.document.open,run:(t,o)=>{e.setInspectorTab(li("view.setRightTab",o,"tab",K))},title:"Show Inspector Tab"},{args:Se({open:oo("True to show the Navigator dock, false to collapse it.")}),category:"View",id:"view.setNavigator",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{fr("left",!yi("view.setNavigator",o,"open"))},title:"Show Navigator Dock"},{args:Se({open:oo("True to show the Inspector dock, false to collapse it.")}),category:"View",id:"view.setRightPanel",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{fr("right",!yi("view.setRightPanel",o,"open"))},title:"Show Inspector Dock"},{args:Se({open:oo("True to show the Bottom dock, false to collapse it.")}),category:"View",id:"view.setBottomDock",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{fr("bottom",!yi("view.setBottomDock",o,"open"))},title:"Show Bottom Dock"},{category:"View",id:"view.toggleBottomDock",keybinding:"mod+j",level:"application",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>{Pt("bottom")},title:"Toggle Bottom Dock"},{args:Se({tab:Do(Gb,"Which Bottom dock tab to show.")}),category:"View",id:"view.setBottomTab",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{let n=li("view.setBottomTab",o,"tab",Gb);if(e.panelAvailable&&!e.panelAvailable(n))throw RangeError(`command "view.setBottomTab" argument "tab": "${n}" names a panel that is registered but not available right now, so showing it would persist a Bottom dock tab nothing can draw`);Td(n)},title:"Show Bottom Dock Tab"},{args:Se({open:oo("True to show the Assistant tab, false to step off it.")}),category:"View",id:"view.setAssistant",level:"application",menus:["never"],group:"4_docks",run:(t,o)=>{if(yi("view.setAssistant",o,"open")){fr("right",!1),e.setInspectorTab("assistant");return}if(e.inspectorTab()==="assistant")e.setInspectorTab(qb)},title:"Show Assistant"},{args:Se({layout:He("The layout's id — one of this project's saved layouts.")}),category:"View",id:"view.setLayout",level:"application",menus:["palette"],group:"4_layouts",requires:"an open project",when:I,run:(t,o)=>{Te(ot("view.setLayout",o,"layout"),e)},title:"Switch Layout"},{args:Se({name:He("What to call this arrangement. An existing name is overwritten.")}),category:"View",id:"view.saveLayout",level:"application",menus:["palette"],group:"4_layouts",requires:"an open project",when:I,run:(t,o)=>{gt(ot("view.saveLayout",o,"name"),e)},title:"Save Layout"},{args:Se({layout:He("The layout's id."),name:He("Its new name. The id, and every reference to it, is unchanged.")}),category:"View",id:"view.renameLayout",level:"application",menus:["palette"],group:"4_layouts",requires:"an open project",when:I,run:(t,o)=>{yt(ot("view.renameLayout",o,"layout"),ot("view.renameLayout",o,"name"))},title:"Rename Layout"},{args:Se({layout:He("The layout's id. The last remaining layout is kept.")}),category:"View",id:"view.deleteLayout",level:"application",menus:["palette"],group:"4_layouts",requires:"an open project",when:I,run:(t,o)=>{bt(ot("view.deleteLayout",o,"layout"))},title:"Delete Layout"},{category:"View",id:"view.resetLayout",level:"application",menus:["palette"],group:"4_layouts",requires:"an open project",when:I,run:()=>{ht(e)},title:"Reset Layout"},{args:Se({color:Do(Jb,"The Studio chrome's theme.")}),category:"View",id:"view.setTheme",level:"application",menus:["palette"],group:"6_appearance",run:(t,o)=>{NC(li("view.setTheme",o,"color",Jb))},title:"Set Theme"}]}function sL(e,t){e.registerAll(kt(t))}function ju(e){return pr(e,xt())}var P=null,L=null,j=null,T=null;function xt(){return Ce()?.doc.layout??T}var ie=null;function Ce(){let e=m.tabs.get(ai);return e?re(e):null}function Tt(){if(L)fp(L),L=null;P=null,j=null,T=null,ie=null}function Le(){return ie??=(async()=>{try{let e=await p().readFile(ai),{document:t,layout:o}=hs(e);T=o,j=ju(t)}catch{j=null}})(),ie}async function DC(e){if(await Le(),e.doc.layout===null&&T!==null)e.doc.layout=T}function It(e){let t=vt();if(t.projectConfig===e)return;Hl({...t,projectConfig:e}),Ua(m.projectRoot,e)}function Ct(){let e=vt()?.projectConfig;return e?re(e):null}function je(e,t){for(let o of Object.keys(e))delete e[o];Object.assign(e,t)}function _e(e){return P=e,e.scope.run(()=>{Q(()=>{let t=e.doc.document;if(P!==e||!vt())return;It(re(t))})}),e}function Ae(){let e=vt(),t=Ce();if(P&&(P!==(t??L)||re(P.doc.document)!==e.projectConfig))Tt();if(P)return P;if(t)return _e(t);return L=cv({document:e.projectConfig??{},documentPath:ai,id:ai}),_e(L)}function Ie(e){return JSON.stringify(e.extensions??null)}async function Lt(){let{loadFormats:e,refreshExtensionUi:t,refreshFormats:o}=await (me("wj3mf3n8"),import("./format-host-wj3mf3n8.js"));o(),e(),t(p())}async function kd(e){let t=Ct(),o=Ae();await DC(o);let n=re(o.doc.document),r=ju(n),i=t&&t!==n&&ju(t)!==r?t:null;if(i&&o.doc.dirty){let d=Error(`${ai} has unsaved changes in its editor tab`);return k.error(`Could not save ${ai} — the file is open with unsaved changes. Save or `+"revert that tab, then make the settings change again.",{key:`save:${ai}`,path:ai,source:"Settings"}),{error:d,ok:!1}}let s=i??n,a=e?{...s,...e}:s,f=ju(a);if(!i&&!o.doc.dirty&&f===j)return{ok:!0};let u=Ie(n);q(o,(d)=>{let g=d.doc.document;if(i)je(g,i);for(let[b,h]of Object.entries(e??{}))g[b]=h});let l=re(o.doc.document),c=ju(l);try{await p().writeFile(ai,c)}catch(d){return k.error(`Could not save ${ai} — ${te(d)}`,{key:`save:${ai}`,path:ai,source:"Settings"}),{error:d,ok:!1}}if(j=c,o.doc.dirty=!1,Ie(l)!==u)await Lt();return{ok:!0}}async function KT(e,t){if(!vt()){Ua(m.projectRoot,e);return}let o=Ae();q(o,(n)=>je(n.doc.document,e),{skipHistory:!0}),o.doc.dirty=!1,await Le(),T=H(t),o.doc.layout=T,j=ju(e)}function Di(e){let t=D?.projectConfig?.$media;if(!t)return e||{};if(!e)return{...t};return{...t,...e}}function qo(e){let t=D?.projectConfig?.style;if(!t)return e||{};if(!e)return{...t};let o={...t};for(let[n,r]of Object.entries(e))o[n]=typeof r==="object"&&r!==null&&typeof o[n]==="object"&&o[n]!==null?{...o[n],...r}:r;return o}function JT(e){let t=D?.projectConfig?.imports;if(!t)return e||{};if(!e)return{...t};return{...t,...e}}function Vb(e){let t=D?.projectConfig?.$elements;if(!t?.length)return e||[];if(!e?.length)return[...t];let o=new Set,n=[];for(let r of[...t,...e]){let i=typeof r==="string"?r:r?.$ref;if(i&&!o.has(i))o.add(i),n.push(r)}return n}function YT(e){let t=D?.projectConfig?.$head;if(!t?.length)return e||[];if(!e?.length)return[...t];let o=new Set,n=[];for(let r of[...t,...e]){let i=String(r?.attributes?.href||r?.attributes?.src||"")||JSON.stringify(r);if(!o.has(i))o.add(i),n.push(r)}return n}function ps(){let e=D?.projectConfig;return e?$o(e).i18n:null}var F=new Map;function bx(){F.clear()}function $l(e){if(e===!1)return null;let t=D?.projectConfig?.defaults?.layout;return e||t||null}async function Ub(e){let t=e.replace(/^\.\//,"");if(F.has(t))return structuredClone(F.get(t));try{let n=await p().readFile(t),r=JSON.parse(n);return F.set(t,r),structuredClone(r)}catch{return null}}function ZT(e,t){let o=t.children??[],n=Array.isArray(o)?o:[],r=new Map,i=[];for(let s of n){let a=typeof s==="object"?s.attributes?.slot:void 0;if(typeof s==="object"&&typeof a==="string"&&a){if(!r.has(a))r.set(a,[]);r.get(a).push(s)}else i.push(s)}if(Re(e,r,i),t.state)e.state={...e.state,...t.state};if(t.$media)e.$media={...e.$media,...t.$media};if(t.style)e.style={...e.style,...t.style};if(t.attributes)e.attributes={...e.attributes,...t.attributes};return e}function Re(e,t,o){if(!e||typeof e!=="object")return;if(!Array.isArray(e.children))return;let n=[];for(let r of e.children)if(r&&typeof r==="object"&&r.tagName==="slot"){let i=r.attributes?.name;if(typeof i==="string"&&i&&t.has(i))n.push(...t.get(i)),t.delete(i);else if(!i&&o.length>0)n.push(...o);else if(Array.isArray(r.children))n.push(...r.children)}else{if(typeof r!=="string")Re(r,t,o);n.push(r)}e.children=n}async function Bi(e){let t=await kd(e);if(!t.ok)throw t.error}
|
|
13
|
-
export{hs,pr,
|
|
12
|
+
`)}var ce=new Set([Qn,yp]),Ze=new Set(["auto","light","dark"]);function qe(e){let{ui:t}=e.session;return{activeMedia:t.activeMedia,canvasMode:t.canvasMode,editZoom:t.editZoom,preview:t.preview,previewColorScheme:t.previewColorScheme,previewLocale:t.previewLocale,showLayout:t.showLayout,zoom:t.zoom}}function ue(){let e={},t=[];for(let o of m.panes){if(o.derived)continue;let n=[];for(let i of o.tabOrder){let s=m.tabs.get(i);if(!s?.documentPath)continue;n.push(s.documentPath),e[s.documentPath]=qe(s)}if(n.length===0)continue;let r=o.activeTabId?m.tabs.get(o.activeTabId):null;t.push({activeFile:r?.documentPath??null,files:n,id:o.id})}return{focusedPane:m.activePaneId,panes:t,ui:e}}function We(e){if(typeof e!=="object"||e===null)return{};let t=e,o={};if(typeof t.canvasMode==="string")o.canvasMode=t.canvasMode;if(typeof t.preview==="boolean")o.preview=t.preview;if(typeof t.zoom==="number"&&Number.isFinite(t.zoom))o.zoom=t.zoom;if(typeof t.editZoom==="number"&&Number.isFinite(t.editZoom))o.editZoom=t.editZoom;if(t.activeMedia===null||typeof t.activeMedia==="string")o.activeMedia=t.activeMedia;if(typeof t.previewColorScheme==="string"&&Ze.has(t.previewColorScheme))o.previewColorScheme=t.previewColorScheme;if(t.previewLocale===null||ov(t.previewLocale))o.previewLocale=t.previewLocale;if(typeof t.showLayout==="boolean")o.showLayout=t.showLayout;return o}function fe(e){if(typeof e!=="object"||e===null)return null;let t=e;if(!Array.isArray(t.panes))return null;let o=[];for(let r of t.panes){if(typeof r!=="object"||r===null)continue;let i=r;if(typeof i.id!=="string"||!ce.has(i.id))continue;let s=Array.isArray(i.files)?i.files.filter((a)=>typeof a==="string"&&a!==""):[];if(s.length===0)continue;o.push({activeFile:typeof i.activeFile==="string"&&s.includes(i.activeFile)?i.activeFile:null,files:s,id:i.id})}if(o.length===0)return null;let n={};if(typeof t.ui==="object"&&t.ui!==null)for(let[r,i]of Object.entries(t.ui))n[r]=We(i);return{focusedPane:typeof t.focusedPane==="string"&&ce.has(t.focusedPane)?t.focusedPane:Qn,panes:o,ui:n}}async function eL(e,t){let o=0;if(e.panes.some((n)=>n.id===yp))t.ensureSecondPane();for(let n of e.panes)for(let r of n.files){try{await t.openFile(r,n.id)}catch{}if([...m.tabs.values()].some((i)=>i.documentPath===r))o+=1}if(o===0)return 0;for(let n of m.tabs.values()){let r=n.documentPath?e.ui[n.documentPath]:void 0;if(!r)continue;let{ui:i}=n.session;if(r.canvasMode&&n.capabilities.modes.includes(r.canvasMode))i.canvasMode=r.canvasMode;if(r.preview!==void 0)i.preview=r.preview;if(r.zoom!==void 0)i.zoom=r.zoom;if(r.editZoom!==void 0)i.editZoom=r.editZoom;if(r.activeMedia!==void 0)i.activeMedia=r.activeMedia;if(r.previewColorScheme!==void 0)i.previewColorScheme=r.previewColorScheme;if(r.previewLocale!==void 0)i.previewLocale=r.previewLocale;if(r.showLayout!==void 0)i.showLayout=r.showLayout}for(let n of e.panes){let r=m.panes.find((s)=>s.id===n.id);if(!r||!n.activeFile)continue;let i=r.tabOrder.find((s)=>m.tabs.get(s)?.documentPath===n.activeFile);if(i)r.activeTabId=i}if(m.panes.some((n)=>n.id===e.focusedPane))$r(e.focusedPane);return o}var pe={default:{description:"Resume whatever was persisted — layout, recents, settings, chat history.",id:"default",reset:"none"},fresh:{description:"A first-run app: no layout, no recents, no settings, no history.",id:"fresh",reset:"app-state"}},Ke="default",Ye=/^jx[-._:]/;function Xe(e){return Ye.test(e)}function Qe(){let e=globalThis.localStorage;if(!e)return[];let t=[];try{for(let o=0;o<e.length;o++){let n=e.key(o);if(n&&Xe(n))t.push(n)}for(let o of t)e.removeItem(o)}catch{}return t}function et(e){let t=pe[e];if(!t)throw RangeError(`unknown startup profile "${e}"; declared: ${Object.keys(pe).join(", ")}`);if(t.reset==="app-state")Qe();return t}var J=null;function de(e){if(J)return J;let t=new URLSearchParams(e??globalThis.location?.search??""),o=et(t.get("profile")??Ke),n=t.get("clock");return J={clock:n===null?null:AI(n),profile:o},J}var W=["files","search","git","i18n","layers","page","data","packages","insert"],tt={blocks:"insert",head:"page",imports:"packages",state:"data"},ye="layers";function ee(e){return typeof e==="string"&&W.includes(e)}function yx(e,t){if(!ee(e))throw Error(`${t}: "${e}" is not a declared Navigator panel id.`);return e}function be(e){if(typeof e!=="string")return null;let t=tt[e];if(t)return t;return ee(e)?e:null}var K=["properties","style","events","assistant"],Gb="properties";function wx(e){return typeof e==="string"&&K.includes(e)}var Kb=["problems","logic","activity"],xx="problems";function Jb(e){return typeof e==="string"&&Kb.includes(e)}var Yb=["light","dark"],he="jx-studio-panel-widths",ve="jx-studio-project::",nt="dark";function rt(e){return typeof e==="string"&&Yb.includes(e)}function it(){let e=Lr(_t.theme);return rt(e)?e:nt}var Ed=["left","right","bottom"],R={bottom:{collapsed:!0,size:220},left:{collapsed:!1,size:240},right:{collapsed:!1,size:280}},tL={bottom:R.bottom.size,left:R.left.size,right:R.right.size},st={bottom:"--dock-h-bottom",left:"--panel-w-left",right:"--panel-w-right"},at={bottom:"bottom-collapsed",left:"left-collapsed",right:"right-collapsed"},OC=0.5,_x=0.2,Cx=0.8;function lt(e){return typeof e==="number"&&e>=_x&&e<=Cx?e:OC}function nL(e){y.paneSplit=Math.min(Cx,Math.max(_x,e))}function ct(){try{return JSON.parse(localStorage.getItem(he)||"{}")}catch{return{}}}function we(){return{branches:null,commitMessage:"",diffState:null,error:null,lastUpdated:null,loading:!1,logEntries:null,rev:0,status:null,subTab:"changes"}}function Pe(){return{customizedOnly:!1,filter:"",selection:null,tab:"elements"}}function ke(){return[{bottomTab:"problems",docks:{bottom:{collapsed:!0,size:220},left:{collapsed:!1,size:240},right:{collapsed:!0,size:280}},id:"write",inspectorTab:"properties",name:"Write",navigatorPanel:"files"},{bottomTab:"problems",docks:{bottom:{collapsed:!0,size:220},left:{collapsed:!1,size:240},right:{collapsed:!1,size:320}},id:"design",inspectorTab:"style",name:"Design",navigatorPanel:"layers"},{bottomTab:"logic",docks:{bottom:{collapsed:!0,size:260},left:{collapsed:!1,size:280},right:{collapsed:!1,size:300}},id:"build",inspectorTab:"events",name:"Build",navigatorPanel:"data"},{bottomTab:"activity",docks:{bottom:{collapsed:!1,size:240},left:{collapsed:!1,size:300},right:{collapsed:!0,size:280}},id:"ship",inspectorTab:"properties",name:"Ship",navigatorPanel:"git"}]}var z="design";function ut(){let e=ct(),t={};for(let o of Ed){let n=e[o],r=e[`${o}Collapsed`];t[o]={collapsed:typeof r==="boolean"?r:R[o].collapsed,size:typeof n==="number"&&n>0?n:R[o].size}}return{bottomTab:Jb(e.bottomTab)?e.bottomTab:xx,docks:t,focusRegion:"pane",paneSplit:lt(e.paneSplit),git:we(),layout:z,layoutSelection:null,layouts:ke(),leftTab:be(e.leftTab)??ye,settingsTab:"stylebook",stylebook:Pe(),theme:it()}}de();var y=v(ut());function Td(){try{localStorage.setItem(he,JSON.stringify({bottom:y.docks.bottom.size,bottomCollapsed:y.docks.bottom.collapsed,bottomTab:y.bottomTab,left:y.docks.left.size,leftCollapsed:y.docks.left.collapsed,leftTab:y.leftTab,paneSplit:y.paneSplit,right:y.docks.right.size,rightCollapsed:y.docks.right.collapsed}))}catch{}}var Y;function ft(e){if(typeof e!=="object"||e===null)return!1;let t=e;return typeof t.id==="string"&&t.id!==""&&typeof t.name==="string"&&ee(t.navigatorPanel)&&wx(t.inspectorTab)&&Jb(t.bottomTab)&&Ed.every((o)=>typeof t.docks?.[o]?.size==="number")}function oe(e){if(!e)return{};try{return JSON.parse(localStorage.getItem(`${ve}${e}`)||"{}")}catch{return{}}}function pt(e){let t={activeLayout:null,layouts:ke()};if(!e)return t;let o=oe(e),n=Array.isArray(o.layouts)?o.layouts.filter(ft):[];if(n.length===0)return t;return{activeLayout:typeof o.activeLayout==="string"?o.activeLayout:null,layouts:n}}function iL(e){return fe(oe(e).session)}var ne=null;function Zb(e){ne=e}function oL(){C()}function C(){let e=m.projectRoot;if(!e)return;try{localStorage.setItem(`${ve}${e}`,JSON.stringify({activeLayout:y.layout,layouts:y.layouts,session:e===ne?ue():oe(e).session}))}catch{}}function dt(e){if(e===Y)return;Y=e;let{activeLayout:t,layouts:o}=pt(e);y.layouts=o;let n=(r)=>r!==null&&o.some((i)=>i.id===r);y.layout=n(t)?t:n(y.layout)?y.layout:n(z)?z:o[0]?.id??z}function xe(e){return y.layouts.find((t)=>t.id===e)}function mt(e){return e.trim().toLowerCase().replaceAll(/[^a-z0-9]+/g,"-").replaceAll(/^-|-$/g,"")||"layout"}function Te(e,t){let o=xe(e);if(!o)throw RangeError(`no layout named "${e}" — this project has: ${y.layouts.map((n)=>n.id).join(", ")}`);y.layout=o.id,y.leftTab=o.navigatorPanel,y.bottomTab=o.bottomTab;for(let n of Ed)y.docks[n].collapsed=o.docks[n].collapsed,y.docks[n].size=o.docks[n].size;t.setInspectorTab(o.inspectorTab),Td(),C()}function gt(e,t){let o=e.trim(),n=mt(o),r={};for(let a of Ed)r[a]={collapsed:y.docks[a].collapsed,size:y.docks[a].size};let i={bottomTab:Jb(y.bottomTab)?y.bottomTab:xx,docks:r,id:n,inspectorTab:t.inspectorTab(),name:o||n,navigatorPanel:be(y.leftTab)??ye},s=y.layouts.findIndex((a)=>a.id===n);if(s===-1)y.layouts.push(i);else y.layouts.splice(s,1,i);return y.layout=n,C(),i}function yt(e,t){let o=xe(e),n=t.trim();if(!o||!n)return;o.name=n,C()}function bt(e){if(y.layouts.length<2)return;let t=y.layouts.findIndex((o)=>o.id===e);if(t===-1)return;if(y.layouts.splice(t,1),y.layout===e)y.layout=y.layouts[0].id;C()}function ht(e){Te(y.layout,e)}function up(e=y.theme){return e==="light"?"vs":"vs-dark"}function wt(){document.documentElement.dataset.theme=y.theme,nh()?.editor.setTheme(up())}function St(){let e=document.documentElement;for(let o of Ed)e.style.setProperty(st[o],`${y.docks[o].size}px`);let t=document.querySelector("#app");if(!t)return;for(let o of Ed)t.classList.toggle(at[o],y.docks[o].collapsed)}var Z=null,X=[];function um(e){if(!X.includes(e))X.push(e)}function rL(){if(Z)return;for(let e of X)e.mount();Z=ge(),Z.run(()=>{Q(()=>{St()}),Q(()=>{wt()}),Q(()=>{dt(m.projectRoot)}),Q(()=>{let e=m.projectRoot;m.activePaneId;for(let t of m.panes)t.id,t.activeTabId,t.tabOrder.join("\x00");if(e)C()})})}function fr(e,t){if(y.docks[e].collapsed===t){Td();return}y.docks[e].collapsed=t,Td()}function Pt(e){fr(e,!y.docks[e].collapsed)}function sL(e,t){y.docks[e].size=t}function fs(e){y.leftTab=e,fr("left",!1),Td()}function Ld(e){y.bottomTab=e,fr("bottom",!1),Td()}function MC(e){if(y.theme===e)return;y.theme=e,qr(_t.theme,e)}function aL(e){if(e===y.leftTab&&!y.docks.left.collapsed){fr("left",!0);return}fs(e)}function PC(e){y.layoutSelection=e}function Xb(){Object.assign(y.git,we()),Object.assign(y.stylebook,Pe()),y.settingsTab="stylebook",y.layoutSelection=null,ne=null,Y=void 0}var I=(e)=>e.project.open;function kt(e){return[{args:Se({tab:Do(W,"Which Navigator panel to show.")}),category:"View",id:"view.setActivity",level:"application",menus:["commandbar/overflow","palette"],group:"4_docks",requires:"an open project",when:I,run:(t,o)=>{let n=li("view.setActivity",o,"tab",W);if(e.panelAvailable&&!e.panelAvailable(n))throw RangeError(`command "view.setActivity" argument "tab": "${n}" names a panel that is registered but not available right now, so showing it would persist a Navigator tab nothing can draw`);fs(n)},title:"Show Navigator Panel"},{args:Se({tab:Do(K,"Which Inspector tab to show.")}),category:"View",id:"view.setRightTab",level:"document",menus:["palette"],group:"4_docks",requires:"an open document",when:(t)=>t.document.open,run:(t,o)=>{e.setInspectorTab(li("view.setRightTab",o,"tab",K))},title:"Show Inspector Tab"},{args:Se({open:oo("True to show the Navigator dock, false to collapse it.")}),category:"View",id:"view.setNavigator",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{fr("left",!yi("view.setNavigator",o,"open"))},title:"Show Navigator Dock"},{args:Se({open:oo("True to show the Inspector dock, false to collapse it.")}),category:"View",id:"view.setRightPanel",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{fr("right",!yi("view.setRightPanel",o,"open"))},title:"Show Inspector Dock"},{args:Se({open:oo("True to show the Bottom dock, false to collapse it.")}),category:"View",id:"view.setBottomDock",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{fr("bottom",!yi("view.setBottomDock",o,"open"))},title:"Show Bottom Dock"},{category:"View",id:"view.toggleBottomDock",keybinding:"mod+j",level:"application",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>{Pt("bottom")},title:"Toggle Bottom Dock"},{args:Se({tab:Do(Kb,"Which Bottom dock tab to show.")}),category:"View",id:"view.setBottomTab",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{let n=li("view.setBottomTab",o,"tab",Kb);if(e.panelAvailable&&!e.panelAvailable(n))throw RangeError(`command "view.setBottomTab" argument "tab": "${n}" names a panel that is registered but not available right now, so showing it would persist a Bottom dock tab nothing can draw`);Ld(n)},title:"Show Bottom Dock Tab"},{args:Se({open:oo("True to show the Assistant tab, false to step off it.")}),category:"View",id:"view.setAssistant",level:"application",menus:["never"],group:"4_docks",run:(t,o)=>{if(yi("view.setAssistant",o,"open")){fr("right",!1),e.setInspectorTab("assistant");return}if(e.inspectorTab()==="assistant")e.setInspectorTab(Gb)},title:"Show Assistant"},{args:Se({layout:He("The layout's id — one of this project's saved layouts.")}),category:"View",id:"view.setLayout",level:"application",menus:["palette"],group:"4_layouts",requires:"an open project",when:I,run:(t,o)=>{Te(ot("view.setLayout",o,"layout"),e)},title:"Switch Layout"},{args:Se({name:He("What to call this arrangement. An existing name is overwritten.")}),category:"View",id:"view.saveLayout",level:"application",menus:["palette"],group:"4_layouts",requires:"an open project",when:I,run:(t,o)=>{gt(ot("view.saveLayout",o,"name"),e)},title:"Save Layout"},{args:Se({layout:He("The layout's id."),name:He("Its new name. The id, and every reference to it, is unchanged.")}),category:"View",id:"view.renameLayout",level:"application",menus:["palette"],group:"4_layouts",requires:"an open project",when:I,run:(t,o)=>{yt(ot("view.renameLayout",o,"layout"),ot("view.renameLayout",o,"name"))},title:"Rename Layout"},{args:Se({layout:He("The layout's id. The last remaining layout is kept.")}),category:"View",id:"view.deleteLayout",level:"application",menus:["palette"],group:"4_layouts",requires:"an open project",when:I,run:(t,o)=>{bt(ot("view.deleteLayout",o,"layout"))},title:"Delete Layout"},{category:"View",id:"view.resetLayout",level:"application",menus:["palette"],group:"4_layouts",requires:"an open project",when:I,run:()=>{ht(e)},title:"Reset Layout"},{args:Se({color:Do(Yb,"The Studio chrome's theme.")}),category:"View",id:"view.setTheme",level:"application",menus:["palette"],group:"6_appearance",run:(t,o)=>{MC(li("view.setTheme",o,"color",Yb))},title:"Set Theme"}]}function lL(e,t){e.registerAll(kt(t))}function Hu(e){return pr(e,xt())}var P=null,L=null,j=null,T=null;function xt(){return Ce()?.doc.layout??T}var ie=null;function Ce(){let e=m.tabs.get(ai);return e?re(e):null}function Tt(){if(L)mp(L),L=null;P=null,j=null,T=null,ie=null}function Le(){return ie??=(async()=>{try{let e=await p().readFile(ai),{document:t,layout:o}=hs(e);T=o,j=Hu(t)}catch{j=null}})(),ie}async function NC(e){if(await Le(),e.doc.layout===null&&T!==null)e.doc.layout=T}function It(e){let t=vt();if(t.projectConfig===e)return;Bl({...t,projectConfig:e}),qa(m.projectRoot,e)}function Ct(){let e=vt()?.projectConfig;return e?re(e):null}function je(e,t){for(let o of Object.keys(e))delete e[o];Object.assign(e,t)}function _e(e){return P=e,e.scope.run(()=>{Q(()=>{let t=e.doc.document;if(P!==e||!vt())return;It(re(t))})}),e}function Ae(){let e=vt(),t=Ce();if(P&&(P!==(t??L)||re(P.doc.document)!==e.projectConfig))Tt();if(P)return P;if(t)return _e(t);return L=dv({document:e.projectConfig??{},documentPath:ai,id:ai}),_e(L)}function Ie(e){return JSON.stringify(e.extensions??null)}async function Lt(){let{loadFormats:e,refreshExtensionUi:t,refreshFormats:o}=await (me("t76b53f8"),import("./format-host-t76b53f8.js"));o(),e(),t(p())}async function Sd(e){let t=Ct(),o=Ae();await NC(o);let n=re(o.doc.document),r=Hu(n),i=t&&t!==n&&Hu(t)!==r?t:null;if(i&&o.doc.dirty){let d=Error(`${ai} has unsaved changes in its editor tab`);return k.error(`Could not save ${ai} — the file is open with unsaved changes. Save or `+"revert that tab, then make the settings change again.",{key:`save:${ai}`,path:ai,source:"Settings"}),{error:d,ok:!1}}let s=i??n,a=e?{...s,...e}:s,f=Hu(a);if(!i&&!o.doc.dirty&&f===j)return{ok:!0};let u=Ie(n);q(o,(d)=>{let g=d.doc.document;if(i)je(g,i);for(let[b,h]of Object.entries(e??{}))g[b]=h});let l=re(o.doc.document),c=Hu(l);try{await p().writeFile(ai,c)}catch(d){return k.error(`Could not save ${ai} — ${te(d)}`,{key:`save:${ai}`,path:ai,source:"Settings"}),{error:d,ok:!1}}if(j=c,o.doc.dirty=!1,Ie(l)!==u)await Lt();return{ok:!0}}async function YT(e,t){if(!vt()){qa(m.projectRoot,e);return}let o=Ae();q(o,(n)=>je(n.doc.document,e),{skipHistory:!0}),o.doc.dirty=!1,await Le(),T=H(t),o.doc.layout=T,j=Hu(e)}function Di(e){let t=D?.projectConfig?.$media;if(!t)return e||{};if(!e)return{...t};return{...t,...e}}function qo(e){let t=D?.projectConfig?.style;if(!t)return e||{};if(!e)return{...t};let o={...t};for(let[n,r]of Object.entries(e))o[n]=typeof r==="object"&&r!==null&&typeof o[n]==="object"&&o[n]!==null?{...o[n],...r}:r;return o}function ZT(e){let t=D?.projectConfig?.imports;if(!t)return e||{};if(!e)return{...t};return{...t,...e}}function Ub(e){let t=D?.projectConfig?.$elements;if(!t?.length)return e||[];if(!e?.length)return[...t];let o=new Set,n=[];for(let r of[...t,...e]){let i=typeof r==="string"?r:r?.$ref;if(i&&!o.has(i))o.add(i),n.push(r)}return n}function XT(e){let t=D?.projectConfig?.$head;if(!t?.length)return e||[];if(!e?.length)return[...t];let o=new Set,n=[];for(let r of[...t,...e]){let i=String(r?.attributes?.href||r?.attributes?.src||"")||JSON.stringify(r);if(!o.has(i))o.add(i),n.push(r)}return n}function ps(){let e=D?.projectConfig;return e?$o(e).i18n:null}var F=new Map;function vx(){F.clear()}function Dl(e){if(e===!1)return null;let t=D?.projectConfig?.defaults?.layout;return e||t||null}async function qb(e){let t=e.replace(/^\.\//,"");if(F.has(t))return structuredClone(F.get(t));try{let n=await p().readFile(t),r=JSON.parse(n);return F.set(t,r),structuredClone(r)}catch{return null}}function QT(e,t){let o=t.children??[],n=Array.isArray(o)?o:[],r=new Map,i=[];for(let s of n){let a=typeof s==="object"?s.attributes?.slot:void 0;if(typeof s==="object"&&typeof a==="string"&&a){if(!r.has(a))r.set(a,[]);r.get(a).push(s)}else i.push(s)}if(Re(e,r,i),t.state)e.state={...e.state,...t.state};if(t.$media)e.$media={...e.$media,...t.$media};if(t.style)e.style={...e.style,...t.style};if(t.attributes)e.attributes={...e.attributes,...t.attributes};return e}function Re(e,t,o){if(!e||typeof e!=="object")return;if(!Array.isArray(e.children))return;let n=[];for(let r of e.children)if(r&&typeof r==="object"&&r.tagName==="slot"){let i=r.attributes?.name;if(typeof i==="string"&&i&&t.has(i))n.push(...t.get(i)),t.delete(i);else if(!i&&o.length>0)n.push(...o);else if(Array.isArray(r.children))n.push(...r.children)}else{if(typeof r!=="string")Re(r,t,o);n.push(r)}e.children=n}async function Bi(e){let t=await Sd(e);if(!t.ok)throw t.error}
|
|
13
|
+
export{hs,pr,Hu,NC,Sd,YT,Di,qo,ZT,Ub,XT,ps,vx,Dl,qb,QT,Bi,eL,yx,Gb,wx,Kb,xx,Jb,Yb,Ed,tL,OC,_x,Cx,nL,y,Td,iL,Zb,oL,up,um,rL,fr,sL,fs,Ld,MC,aL,PC,Xb,lL};
|
|
14
14
|
|
|
15
|
-
//# debugId=
|
|
16
|
-
//# sourceMappingURL=studio-
|
|
15
|
+
//# debugId=D1FA63014C43549A64756E2164756E21
|
|
16
|
+
//# sourceMappingURL=studio-q1h883bt.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var O=()=>new Map,Se=(t)=>{let e=O();return t.forEach((n,r)=>{e.set(r,n)}),e},P=(t,e,n)=>{let r=t.get(e);if(r===void 0)t.set(e,r=n());return r},vr=(t,e)=>{let n=[];for(let[r,s]of t)n.push(e(s,r));return n},Rr=(t,e)=>{for(let[n,r]of t)if(e(r,n))return!0;return!1};var Y=()=>new Set;var _e=(t)=>t[t.length-1];var Lr=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},z=Array.from,Te=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},zt=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1};var Vr=(t,e)=>{let n=Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n};var tt=Array.isArray;class Ue{constructor(){this._observers=O()}on(t,e){return P(this._observers,t,Y).add(e),e}once(t,e){let n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){let n=this._observers.get(t);if(n!==void 0){if(n.delete(e),n.size===0)this._observers.delete(t)}}emit(t,e){return z((this._observers.get(t)||O()).values()).forEach((n)=>n(...e))}destroy(){this._observers=O()}}var N=Math.floor;var ct=Math.abs;var Ee=(t,e)=>t<e?t:e,et=(t,e)=>t>e?t:e;var Be=(t)=>t!==0?t<0:1/t<0;var Un=1,En=2,Ae=4,Ce=8;var bt=32,G=64,A=128;var Wt=31,Zt=63,nt=127;var Mr=2147483647;var{MAX_SAFE_INTEGER:It,MIN_SAFE_INTEGER:An}=Number;var Fr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&N(t)===t);var{fromCharCode:Dn,fromCodePoint:Wo}=String,Hl=Dn(65535),Zo=(t)=>t.toLowerCase(),Xo=/^\s*/g,Qo=(t)=>t.replace(Xo,""),Yo=/([A-Z])/g,On=(t,e)=>Qo(t.replace(Yo,(n)=>`${e}${Zo(n)}`));var ti=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},St=typeof TextEncoder<"u"?new TextEncoder:null,ei=(t)=>St.encode(t),$r=St?ei:ti;var kt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(kt&&kt.decode(new Uint8Array).length===1)kt=null;var jr=(t,e)=>Vr(e,()=>t).join("");class Tt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Xt=()=>new Tt;var ni=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var H=(t)=>{let e=new Uint8Array(ni(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},ri=(t,e)=>{let n=t.cbuf.length;if(n-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(et(n,e)*2),t.cpos=0},E=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var Oe=E;var w=(t,e)=>{while(e>nt)E(t,A|nt&e),e=N(e/128);E(t,nt&e)},Ne=(t,e)=>{let n=Be(e);if(n)e=-e;E(t,(e>Zt?A:0)|(n?G:0)|Zt&e),e=N(e/64);while(e>0)E(t,(e>nt?A:0)|nt&e),e=N(e/128)},Nn=new Uint8Array(30000),si=Nn.length/3,oi=(t,e)=>{if(e.length<si){let n=St.encodeInto(e,Nn).written||0;w(t,n);for(let r=0;r<n;r++)E(t,Nn[r])}else R(t,$r(e))},ii=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;w(t,r);for(let s=0;s<r;s++)E(t,n.codePointAt(s))},lt=St&&St.encodeInto?oi:ii;var Qt=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Ee(n-r,e.length),o=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(et(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o},R=(t,e)=>{w(t,e.byteLength),Qt(t,e)},vn=(t,e)=>{ri(t,e);let n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},ci=(t,e)=>vn(t,4).setFloat32(0,e,!1),li=(t,e)=>vn(t,8).setFloat64(0,e,!1),ai=(t,e)=>vn(t,8).setBigInt64(0,e,!1);var qr=new DataView(new ArrayBuffer(4)),hi=(t)=>(qr.setFloat32(0,t),qr.getFloat32(0)===t),_t=(t,e)=>{switch(typeof e){case"string":E(t,119),lt(t,e);break;case"number":if(Fr(e)&&ct(e)<=Mr)E(t,125),Ne(t,e);else if(hi(e))E(t,124),ci(t,e);else E(t,123),li(t,e);break;case"bigint":E(t,122),ai(t,e);break;case"object":if(e===null)E(t,126);else if(tt(e)){E(t,117),w(t,e.length);for(let n=0;n<e.length;n++)_t(t,e[n])}else if(e instanceof Uint8Array)E(t,116),R(t,e);else{E(t,118);let n=Object.keys(e);w(t,n.length);for(let r=0;r<n.length;r++){let s=n[r];lt(t,s),_t(t,e[s])}}break;case"boolean":E(t,e?120:121);break;default:E(t,127)}};class ve extends Tt{constructor(t){super();this.w=t,this.s=null,this.count=0}write(t){if(this.s===t)this.count++;else{if(this.count>0)w(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var Gr=(t)=>{if(t.count>0){if(Ne(t.encoder,t.count===1?t.s:-t.s),t.count>1)w(t.encoder,t.count-2)}};class Ut{constructor(){this.encoder=new Tt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else Gr(this),this.count=1,this.s=t}toUint8Array(){return Gr(this),H(this.encoder)}}var Hr=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(Ne(t.encoder,e),t.count>1)w(t.encoder,t.count-2)}};class Yt{constructor(){this.encoder=new Tt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else Hr(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return Hr(this),H(this.encoder)}}class Rn{constructor(){this.sarr=[],this.s="",this.lensE=new Ut}write(t){if(this.s+=t,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(t.length)}toUint8Array(){let t=new Tt;return this.sarr.push(this.s),this.s="",lt(t,this.sarr.join("")),Qt(t,this.lensE.toUint8Array()),H(t)}}var M=(t)=>Error(t),F=()=>{throw M("Method unimplemented")},v=()=>{throw M("Unexpected case")};var Pr=M("Unexpected end of array"),zr=M("Integer out of Range");class te{constructor(t){this.arr=t,this.pos=0}}var ut=(t)=>new te(t),Jr=(t)=>t.pos!==t.arr.length;var fi=(t,e)=>{let n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},L=(t)=>fi(t,x(t));var at=(t)=>t.arr[t.pos++];var x=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&nt)*n,n*=128,s<A)return e;if(e>It)throw zr}throw Pr},Re=(t)=>{let e=t.arr[t.pos++],n=e&Zt,r=64,s=(e&G)>0?-1:1;if((e&A)===0)return s*n;let o=t.arr.length;while(t.pos<o){if(e=t.arr[t.pos++],n=n+(e&nt)*r,r*=128,e<A)return s*n;if(n>It)throw zr}throw Pr};var di=(t)=>{let e=x(t);if(e===0)return"";else{let n=String.fromCodePoint(at(t));if(--e<100)while(e--)n+=String.fromCodePoint(at(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},pi=(t)=>kt.decode(L(t)),ht=kt?pi:di;var Vn=(t,e)=>{let n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},gi=(t)=>Vn(t,4).getFloat32(0,!1),mi=(t)=>Vn(t,8).getFloat64(0,!1),xi=(t)=>Vn(t,8).getBigInt64(0,!1);var wi=[(t)=>{return},(t)=>null,Re,gi,mi,xi,(t)=>!1,(t)=>!0,ht,(t)=>{let e=x(t),n={};for(let r=0;r<e;r++){let s=ht(t);n[s]=Et(t)}return n},(t)=>{let e=x(t),n=[];for(let r=0;r<e;r++)n.push(Et(t));return n},L],Et=(t)=>wi[127-at(t)](t);class Le extends te{constructor(t,e){super(t);this.reader=e,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Jr(this))this.count=x(this)+1;else this.count=-1;return this.count--,this.s}}class Bt extends te{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=Re(this);let t=Be(this.s);if(this.count=1,t)this.s=-this.s,this.count=x(this)+2}return this.count--,this.s}}class ee extends te{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=Re(this),e=t&1;if(this.diff=N(t/2),this.count=1,e)this.count=x(this)+2}return this.s+=this.diff,this.count--,this.s}}class Mn{constructor(t){this.decoder=new Bt(t),this.str=ht(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}var Jl=crypto.subtle,Kr=crypto.getRandomValues.bind(crypto);var Fn=()=>Kr(new Uint32Array(1))[0];var bi=[1e7]+-1000+-4000+-8000+-100000000000,Wr=()=>bi.replace(/[018]/g,(t)=>(t^Fn()&15>>t/4).toString(16));var Ve=Date.now;var $n=(t)=>new Promise(t);var Zl=Promise.all.bind(Promise);var jn=(t)=>t===void 0?null:t;class Xr{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var Qr=new Xr,_i=!0;try{if(typeof localStorage<"u"&&localStorage)Qr=localStorage,_i=!1}catch(t){}var Yr=Qr;var ft=Symbol("Equality"),Me=(t,e)=>t===e||!!t?.[ft]?.(e)||!1;var ts=(t)=>typeof t==="object",{assign:es,keys:Ui}=Object;var ns=(t,e)=>{for(let n in t)e(t[n],n)};var ne=(t)=>Ui(t).length;var rs=(t)=>{for(let e in t)return!1;return!0},At=(t,e)=>{for(let n in t)if(!e(t[n],n))return!1;return!0},re=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Gn=(t,e)=>t===e||ne(t)===ne(e)&&At(t,(n,r)=>(n!==void 0||re(e,r))&&Me(e[r],n)),Ei=Object.freeze,Hn=(t)=>{for(let e in t){let n=t[e];if(typeof n==="object"||typeof n==="function")Hn(t[e])}return Ei(t)};var oe=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{if(n<t.length)oe(t,e,n+1)}};var ss=(t)=>t;var se=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[ft]!=null)return t[ft](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let n of t.keys())if(!e.has(n)||!se(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ne(t)!==ne(e))return!1;for(let n in t)if(!re(t,n)||!se(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!se(t[n],e[n]))return!1;break;default:return!1}return!0},os=(t,e)=>e.includes(t);var ie=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var Xl=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,J,Bi=[],Ai=()=>{if(J===void 0)if(ie){J=O();let t=process.argv,e=null;for(let n=0;n<t.length;n++){let r=t[n];if(r[0]==="-"){if(e!==null)J.set(e,"");e=r}else if(e!==null)J.set(e,r),e=null;else Bi.push(r)}if(e!==null)J.set(e,"")}else if(typeof location==="object")J=O(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,n]=t.split("=");J.set(`--${On(e,"-")}`,n),J.set(`-${On(e,"-")}`,n)}});else J=O();return J},Jn=(t)=>Ai().has(t);var ce=(t)=>ie?jn(process.env[t.toUpperCase().replaceAll("-","_")]):jn(Yr.getItem(t));var is=(t)=>Jn("--"+t)||ce(t)!==null,cs=is("production"),Ci=ie&&os(process.env.FORCE_COLOR,["true","1","2"]),ls=Ci||!Jn("--no-colors")&&!is("no-color")&&(!ie||process.stdout.isTTY)&&(!ie||Jn("--color")||ce("COLORTERM")!==null||(ce("TERM")||"").includes("color"));var Di=(t)=>new Uint8Array(t);var hs=(t)=>{let e=Di(t.byteLength);return e.set(t),e};class us{constructor(t,e){this.left=t,this.right=e}}var K=(t,e)=>new us(t,e);var Wn=(t)=>t.next()>=0.5,Fe=(t,e,n)=>N(t.next()*(n+1-e)+e);var Zn=(t,e,n)=>N(t.next()*(n+1-e)+e);var Xn=(t,e,n)=>Zn(t,e,n);var vi=(t)=>Dn(Xn(t,97,122)),fs=(t,e=0,n=20)=>{let r=Xn(t,e,n),s="";for(let o=0;o<r;o++)s+=vi(t);return s};var $e=(t,e)=>e[Xn(t,0,e.length-1)];var Li=Symbol("0schema");class ps{constructor(){this._rerrs=[]}extend(t,e,n,r=null){this._rerrs.push({path:t,expected:e,has:n,message:r})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let n=this._rerrs[e];t.push(jr(" ",(this._rerrs.length-e)*2)+`${n.path!=null?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return t.join(`
|
|
2
2
|
`)}}var Qn=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor)return!1;if(t[ft])return Me(t,e);if(tt(t))return Te(t,(n)=>zt(e,(r)=>Qn(n,r)));else if(ts(t))return At(t,(n,r)=>Qn(n,e[r]));return!1};class C{static _dilutes=!1;extends(t){let[e,n]=[this.shape,t.shape];if(this.constructor._dilutes)[n,e]=[e,n];return Qn(e,n)}equals(t){return this.constructor===t.constructor&&se(this.shape,t.shape)}[Li](){return!0}[ft](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){F()}get nullable(){return Nt(this,We)}get optional(){return new Yn(this)}cast(t){return ds(t,this),t}expect(t){return ds(t,this),t}}class Ge extends C{constructor(t,e){super();this.shape=t,this._c=e}check(t,e=void 0){let n=t?.constructor===this.shape&&(this._c==null||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}}var S=(t,e=null)=>new Ge(t,e),Yl=S(Ge);class He extends C{constructor(t){super();this.shape=t}check(t,e){let n=this.shape(t);return!n&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),n}}var _=(t)=>new He(t),ta=S(He);class ae extends C{constructor(t){super();this.shape=t}check(t,e){let n=this.shape.some((r)=>r===t);return!n&&e?.extend(null,this.shape.join(" | "),t.toString()),n}}var Pe=(...t)=>new ae(t),gs=S(ae),Vi=RegExp.escape||((t)=>t.replace(/[().|&,$^[\]]/g,(e)=>"\\"+e)),ms=(t)=>{if(Ot.check(t))return[Vi(t)];if(gs.check(t))return t.shape.map((e)=>e+"");if(_s.check(t))return["[+-]?\\d+.?\\d*"];if(Ts.check(t))return[".*"];if(je.check(t))return t.shape.map(ms).flat(1);v()};class xs extends C{constructor(t){super();this.shape=t,this._r=new RegExp("^"+t.map(ms).map((e)=>`(${e.join("|")})`).join("")+"$")}check(t,e){let n=this._r.exec(t)!=null;return!n&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),n}}var ea=S(xs),Mi=Symbol("optional");class Yn extends C{constructor(t){super();this.shape=t}check(t,e){let n=t===void 0||this.shape.check(t);return!n&&e?.extend(null,"undefined (optional)","()"),n}get[Mi](){return!0}}var Fi=S(Yn);class tr extends C{check(t,e){return e?.extend(null,"never",typeof t),!1}}var na=new tr,ra=S(tr);class ze extends C{constructor(t,e=!1){super();this.shape=t,this._isPartial=e}static _dilutes=!0;get partial(){return new ze(this.shape,!0)}check(t,e){if(t==null)return e?.extend(null,"object","null"),!1;return At(this.shape,(n,r)=>{let s=this._isPartial&&!re(t,r)||n.check(t[r],e);return!s&&e?.extend(r.toString(),n.toString(),typeof t[r],"Object property does not match"),s})}}var $i=(t)=>new ze(t),ji=S(ze),qi=_((t)=>t!=null&&(t.constructor===Object||t.constructor==null));class er extends C{constructor(t,e){super();this.shape={keys:t,values:e}}check(t,e){return t!=null&&At(t,(n,r)=>{let s=this.shape.keys.check(r,e);return!s&&e?.extend(r+"","Record",typeof t,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(n,e)})}}var ws=(t,e)=>new er(t,e),Gi=S(er);class nr extends C{constructor(t){super();this.shape=t}check(t,e){return t!=null&&At(this.shape,(n,r)=>{let s=n.check(t[r],e);return!s&&e?.extend(r.toString(),"Tuple",typeof n),s})}}var Hi=(...t)=>new nr(t),sa=S(nr);class rr extends C{constructor(t){super();this.shape=t.length===1?t[0]:new Je(t)}check(t,e){let n=tt(t)&&Te(t,(r)=>this.shape.check(r));return!n&&e?.extend(null,"Array",""),n}}var ys=(...t)=>new rr(t),Pi=S(rr),zi=_((t)=>tt(t));class sr extends C{constructor(t,e){super();this.shape=t,this._c=e}check(t,e){let n=t instanceof this.shape&&(this._c==null||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name),n}}var Ji=(t,e=null)=>new sr(t,e),oa=S(sr),Ki=Ji(C);class bs extends C{constructor(t){super();this.len=t.length-1,this.args=Hi(...t.slice(-1)),this.res=t[this.len]}check(t,e){let n=t.constructor===Function&&t.length<=this.len;return!n&&e?.extend(null,"function",typeof t),n}}var Wi=S(bs),Zi=_((t)=>typeof t==="function");class Is extends C{constructor(t){super();this.shape=t}check(t,e){let n=Te(this.shape,(r)=>r.check(t,e));return!n&&e?.extend(null,"Intersectinon",typeof t),n}}var ia=S(Is,(t)=>t.shape.length>0);class Je extends C{static _dilutes=!0;constructor(t){super();this.shape=t}check(t,e){let n=zt(this.shape,(r)=>r.check(t,e));return e?.extend(null,"Union",typeof t),n}}var Nt=(...t)=>t.findIndex((e)=>je.check(e))>=0?Nt(...t.map((e)=>le(e)).map((e)=>je.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Je(t),je=S(Je),ks=()=>!0,qe=_(ks),Xi=S(He,(t)=>t.shape===ks),or=_((t)=>typeof t==="bigint"),Qi=_((t)=>t===or),Ss=_((t)=>typeof t==="symbol"),ca=_((t)=>t===Ss),Dt=_((t)=>typeof t==="number"),_s=_((t)=>t===Dt),Ot=_((t)=>typeof t==="string"),Ts=_((t)=>t===Ot),Ke=_((t)=>typeof t==="boolean"),Yi=_((t)=>t===Ke),Us=Pe(void 0),la=S(ae,(t)=>t.shape.length===1&&t.shape[0]===void 0),aa=Pe(void 0);var We=Pe(null),tc=S(ae,(t)=>t.shape.length===1&&t.shape[0]===null),ha=S(Uint8Array),ua=S(Ge,(t)=>t.shape===Uint8Array),ec=Nt(Dt,Ot,We,Us,or,Ke,Ss),fa=(()=>{let t=ys(qe),e=ws(Ot,qe),n=Nt(Dt,Ot,We,Ke,t,e);return t.shape=n,e.shape.values=n,n})(),le=(t)=>{if(Ki.check(t))return t;else if(qi.check(t)){let e={};for(let n in t)e[n]=le(t[n]);return $i(e)}else if(zi.check(t))return Nt(...t.map(le));else if(ec.check(t))return Pe(t);else if(Zi.check(t))return S(t);v()},ds=cs?()=>{}:(t,e)=>{let n=new ps;if(!e.check(t,n))throw M(`Expected value to be of type ${e.constructor.name}.
|
|
3
|
-
${n.toString()}`)};class Es{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:le(t),h:e}),this}else(t){return this.if(qe,t)}done(){return(t,e)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(t))return r.h(t,e)}throw M("Unhandled pattern")}}}var nc=(t)=>new Es(t),Bs=nc(qe).if(_s,(t,e)=>Fe(e,An,It)).if(Ts,(t,e)=>fs(e)).if(Yi,(t,e)=>Wn(e)).if(Qi,(t,e)=>BigInt(Fe(e,An,It))).if(je,(t,e)=>Ct(e,$e(e,t.shape))).if(ji,(t,e)=>{let n={};for(let r in t.shape){let s=t.shape[r];if(Fi.check(s)){if(Wn(e))continue;s=s.shape}n[r]=Bs(s,e)}return n}).if(Pi,(t,e)=>{let n=[],r=Zn(e,0,42);for(let s=0;s<r;s++)n.push(Ct(e,t.shape));return n}).if(gs,(t,e)=>$e(e,t.shape)).if(tc,(t,e)=>null).if(Wi,(t,e)=>{let n=Ct(e,t.res);return()=>n}).if(Xi,(t,e)=>Ct(e,$e(e,[Dt,Ot,We,Us,or,Ke,ys(Dt),ws(Nt("a","b","c"),Dt)]))).if(Gi,(t,e)=>{let n={},r=Fe(e,0,3);for(let s=0;s<r;s++){let o=Ct(e,t.shape.keys),i=Ct(e,t.shape.values);n[o]=i}return n}).done(),Ct=(t,e)=>Bs(le(e),t);var dt=typeof document<"u"?document:{};var da=_((t)=>t.nodeType===cc);var pa=typeof DOMParser<"u"?new DOMParser:null;var ga=_((t)=>t.nodeType===sc);var ma=_((t)=>t.nodeType===oc);var As=(t)=>vr(t,(e,n)=>`${n}:${e};`).join("");var{ELEMENT_NODE:sc,TEXT_NODE:oc,CDATA_SECTION_NODE:xa,COMMENT_NODE:wa,DOCUMENT_NODE:ic,DOCUMENT_TYPE_NODE:ya,DOCUMENT_FRAGMENT_NODE:cc}=dt,ba=_((t)=>t.nodeType===ic);var W=Symbol;var he=W(),ue=W(),ir=W(),cr=W(),lr=W(),fe=W(),ar=W(),vt=W(),hr=W(),Cs=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=0;for(;r<t.length;r++){let s=t[r];if(s===void 0)break;else if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}if(r>0)n.push(e.join(""));for(;r<t.length;r++){let s=t[r];if(!(s instanceof Symbol))n.push(s)}return n};var Ia=Ve();var fc={[he]:K("font-weight","bold"),[ue]:K("font-weight","normal"),[ir]:K("color","blue"),[lr]:K("color","green"),[cr]:K("color","grey"),[fe]:K("color","red"),[ar]:K("color","purple"),[vt]:K("color","orange"),[hr]:K("color","black")},dc=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=O(),s=[],o=0;for(;o<t.length;o++){let i=t[o],c=fc[i];if(c!==void 0)r.set(c.left,c.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let a=As(r);if(o>0||a.length>0)e.push("%c"+i),n.push(a);else e.push(i)}else break}}if(o>0)s=n,s.unshift(e.join(""));for(;o<t.length;o++){let i=t[o];if(!(i instanceof Symbol))s.push(i)}return s},Ds=ls?dc:Cs,Ns=(...t)=>{console.log(...Ds(t)),vs.forEach((e)=>e.print(t))},ur=(...t)=>{console.warn(...Ds(t)),t.unshift(vt),vs.forEach((e)=>e.print(t))};var vs=Y();var Rs=(t)=>({[Symbol.iterator](){return this},next:t}),Ls=(t,e)=>Rs(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Ze=(t,e)=>Rs(()=>{let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class xe{constructor(t,e){this.clock=t,this.len=e}}class wt{constructor(){this.clients=new Map}}var Vt=(t,e,n)=>e.clients.forEach((r,s)=>{let o=t.doc.store.clients.get(s);if(o!=null){let i=o[o.length-1],c=i.id.clock+i.length;for(let a=0,f=r[a];a<r.length&&f.clock<c;f=r[++a])ho(t,o,f.clock,f.len,n)}}),mc=(t,e)=>{let n=0,r=t.length-1;while(n<=r){let s=N((n+r)/2),o=t[s],i=o.clock;if(i<=e){if(e<i+o.len)return s;n=s+1}else r=s-1}return null},we=(t,e)=>{let n=t.clients.get(e.client);return n!==void 0&&mc(n,e.clock)!==null},xr=(t)=>{t.clients.forEach((e)=>{e.sort((s,o)=>s.clock-o.clock);let n,r;for(n=1,r=1;n<e.length;n++){let s=e[r-1],o=e[n];if(s.clock+s.len>=o.clock)e[r-1]=new xe(s.clock,et(s.len,o.clock+o.len-s.clock));else{if(r<n)e[r]=o;r++}}e.length=r})},dr=(t)=>{let e=new wt;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){let o=r.slice();for(let i=n+1;i<t.length;i++)Lr(o,t[i].clients.get(s)||[]);e.clients.set(s,o)}});return xr(e),e},de=(t,e,n,r)=>{P(t.clients,e,()=>[]).push(new xe(n,r))},Xs=()=>new wt,xc=(t)=>{let e=Xs();return t.clients.forEach((n,r)=>{let s=[];for(let o=0;o<n.length;o++){let i=n[o];if(i.deleted){let c=i.id.clock,a=i.length;if(o+1<n.length)for(let f=n[o+1];o+1<n.length&&f.deleted;f=n[++o+1])a+=f.length;s.push(new xe(c,a))}}if(s.length>0)e.clients.set(r,s)}),e},Ft=(t,e)=>{w(t.restEncoder,e.clients.size),z(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),w(t.restEncoder,n);let s=r.length;w(t.restEncoder,s);for(let o=0;o<s;o++){let i=r[o];t.writeDsClock(i.clock),t.writeDsLen(i.len)}})},wr=(t)=>{let e=new wt,n=x(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();let s=x(t.restDecoder),o=x(t.restDecoder);if(o>0){let i=P(e.clients,s,()=>[]);for(let c=0;c<o;c++)i.push(new xe(t.readDsClock(),t.readDsLen()))}}return e},Vs=(t,e,n)=>{let r=new wt,s=x(t.restDecoder);for(let o=0;o<s;o++){t.resetDsCurVal();let i=x(t.restDecoder),c=x(t.restDecoder),a=n.clients.get(i)||[],f=I(n,i);for(let l=0;l<c;l++){let h=t.readDsClock(),u=h+t.readDsLen();if(h<f){if(f<u)de(r,i,f,u-f);let d=Z(a,h),p=a[d];if(!p.deleted&&p.id.clock<h)a.splice(d+1,0,fn(e,p,h-p.id.clock)),d++;while(d<a.length)if(p=a[d++],p.id.clock<u){if(!p.deleted){if(u<p.id.clock+p.length)a.splice(d,0,fn(e,p,u-p.id.clock));p.delete(e)}}else break}else de(r,i,h,u-h)}}if(r.clients.size>0){let o=new it;return w(o.restEncoder,0),Ft(o,r),o.toUint8Array()}return null};var Qs=Fn;class ac extends Ue{constructor({guid:t=Wr(),collectionid:e=null,gc:n=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:i=!0}={}){super();this.gc=n,this.gcFilter=r,this.clientID=Qs(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new _r,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=$n((a)=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>$n((a)=>{let f=(l)=>{if(l===void 0||l===!0)this.off("sync",f),a()};this.on("sync",f)});this.on("sync",(a)=>{if(a===!1&&this.isSynced)this.whenSynced=c();if(this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=c()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)y(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(z(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return y(this,t,e)}get(t,e=T){let n=P(this.share,t,()=>{let s=new e;return s._integrate(this,null),s}),r=n.constructor;if(e!==T&&r!==e)if(r===T){let s=new e;s._map=n._map,n._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=s}),s._start=n._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=n._length,this.share.set(t,s),s._integrate(this,null),s}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return n}getArray(t=""){return this.get(t,Os)}getText(t=""){return this.get(t,as)}getMap(t=""){return this.get(t,Ur)}getXmlElement(t=""){return this.get(t,Mt)}getXmlFragment(t=""){return this.get(t,mt)}toJSON(){let t={};return this.share.forEach((e,n)=>{t[n]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,z(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new ac({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,y(t.parent.doc,(n)=>{let r=e.doc;if(!t.deleted)n.subdocsAdded.add(r);n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class yr{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return x(this.restDecoder)}readDsLen(){return x(this.restDecoder)}}class br extends yr{readLeftID(){return g(x(this.restDecoder),x(this.restDecoder))}readRightID(){return g(x(this.restDecoder),x(this.restDecoder))}readClient(){return x(this.restDecoder)}readInfo(){return at(this.restDecoder)}readString(){return ht(this.restDecoder)}readParentInfo(){return x(this.restDecoder)===1}readTypeRef(){return x(this.restDecoder)}readLen(){return x(this.restDecoder)}readAny(){return Et(this.restDecoder)}readBuf(){return hs(L(this.restDecoder))}readJSON(){return JSON.parse(ht(this.restDecoder))}readKey(){return ht(this.restDecoder)}}class Ys{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=x(this.restDecoder),this.dsCurrVal}readDsLen(){let t=x(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class gt extends Ys{constructor(t){super(t);this.keys=[],x(t),this.keyClockDecoder=new ee(L(t)),this.clientDecoder=new Bt(L(t)),this.leftClockDecoder=new ee(L(t)),this.rightClockDecoder=new ee(L(t)),this.infoDecoder=new Le(L(t),at),this.stringDecoder=new Mn(L(t)),this.parentInfoDecoder=new Le(L(t),at),this.typeRefDecoder=new Bt(L(t)),this.lenDecoder=new Bt(L(t))}readLeftID(){return new pt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new pt(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Et(this.restDecoder)}readBuf(){return L(this.restDecoder)}readJSON(){return Et(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];else{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class Ir{constructor(){this.restEncoder=Xt()}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){w(this.restEncoder,t)}writeDsLen(t){w(this.restEncoder,t)}}class $t extends Ir{writeLeftID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeRightID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeClient(t){w(this.restEncoder,t)}writeInfo(t){Oe(this.restEncoder,t)}writeString(t){lt(this.restEncoder,t)}writeParentInfo(t){w(this.restEncoder,t?1:0)}writeTypeRef(t){w(this.restEncoder,t)}writeLen(t){w(this.restEncoder,t)}writeAny(t){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){lt(this.restEncoder,JSON.stringify(t))}writeKey(t){lt(this.restEncoder,t)}}class kr{constructor(){this.restEncoder=Xt(),this.dsCurrVal=0}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,w(this.restEncoder,e)}writeDsLen(t){if(t===0)v();w(this.restEncoder,t-1),this.dsCurrVal+=t}}class it extends kr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Yt,this.clientEncoder=new Ut,this.leftClockEncoder=new Yt,this.rightClockEncoder=new Yt,this.infoEncoder=new ve(Oe),this.stringEncoder=new Rn,this.parentInfoEncoder=new ve(Oe),this.typeRefEncoder=new Ut,this.lenEncoder=new Ut}toUint8Array(){let t=Xt();return w(t,0),R(t,this.keyClockEncoder.toUint8Array()),R(t,this.clientEncoder.toUint8Array()),R(t,this.leftClockEncoder.toUint8Array()),R(t,this.rightClockEncoder.toUint8Array()),R(t,H(this.infoEncoder)),R(t,this.stringEncoder.toUint8Array()),R(t,H(this.parentInfoEncoder)),R(t,this.typeRefEncoder.toUint8Array()),R(t,this.lenEncoder.toUint8Array()),Qt(t,H(this.restEncoder)),H(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){_t(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);if(e===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t);else this.keyClockEncoder.write(e)}}var wc=(t,e,n,r)=>{r=et(r,e[0].id.clock);let s=Z(e,r);w(t.restEncoder,e.length-s),t.writeClient(n),w(t.restEncoder,r);let o=e[s];o.write(t,r-o.id.clock);for(let i=s+1;i<e.length;i++)e[i].write(t,0)},Sr=(t,e,n)=>{let r=new Map;n.forEach((s,o)=>{if(I(e,o)>s)r.set(o,s)}),dn(e).forEach((s,o)=>{if(!n.has(o))r.set(o,0)}),w(t.restEncoder,r.size),z(r.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{wc(t,e.clients.get(s),s,o)})},yc=(t,e)=>{let n=O(),r=x(t.restDecoder);for(let s=0;s<r;s++){let o=x(t.restDecoder),i=Array(o),c=t.readClient(),a=x(t.restDecoder);n.set(c,{i:0,refs:i});for(let f=0;f<o;f++){let l=t.readInfo();switch(Wt&l){case 0:{let h=t.readLen();i[f]=new j(g(c,a),h),a+=h;break}case 10:{let h=x(t.restDecoder);i[f]=new q(g(c,a),h),a+=h;break}default:{let h=(l&(G|A))===0,u=new b(g(c,a),null,(l&A)===A?t.readLeftID():null,null,(l&G)===G?t.readRightID():null,h?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,h&&(l&bt)===bt?t.readString():null,Ro(t,l));i[f]=u,a+=u.length}}}}return n},bc=(t,e,n)=>{let r=[],s=z(n.keys()).sort((d,p)=>d-p);if(s.length===0)return null;let o=()=>{if(s.length===0)return null;let d=n.get(s[s.length-1]);while(d.refs.length===d.i)if(s.pop(),s.length>0)d=n.get(s[s.length-1]);else return null;return d},i=o();if(i===null)return null;let c=new _r,a=new Map,f=(d,p)=>{let m=a.get(d);if(m==null||m>p)a.set(d,p)},l=i.refs[i.i++],h=new Map,u=()=>{for(let d of r){let p=d.id.client,m=n.get(p);if(m)m.i--,c.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[];else c.clients.set(p,[d]);s=s.filter((B)=>B!==p)}r.length=0};while(!0){if(l.constructor!==q){let p=P(h,l.id.client,()=>I(e,l.id.client))-l.id.clock;if(p<0)r.push(l),f(l.id.client,l.id.clock-1),u();else{let m=l.getMissing(t,e);if(m!==null){r.push(l);let B=n.get(m)||{refs:[],i:0};if(B.refs.length===B.i)f(m,I(e,m)),u();else{l=B.refs[B.i++];continue}}else if(p===0||p<l.length)l.integrate(t,p),h.set(l.id.client,l.id.clock+l.length)}}if(r.length>0)l=r.pop();else if(i!==null&&i.i<i.refs.length)l=i.refs[i.i++];else if(i=o(),i===null)break;else l=i.refs[i.i++]}if(c.clients.size>0){let d=new it;return Sr(d,c,new Map),w(d.restEncoder,0),{missing:a,update:d.toUint8Array()}}return null},Ic=(t,e)=>Sr(t,e.doc.store,e.beforeState),kc=(t,e,n,r=new gt(t))=>y(e,(s)=>{s.local=!1;let o=!1,i=s.doc,c=i.store,a=yc(r,i),f=bc(s,c,a),l=c.pendingStructs;if(l){for(let[u,d]of l.missing)if(d<I(c,u)){o=!0;break}if(f){for(let[u,d]of f.missing){let p=l.missing.get(u);if(p==null||p>d)l.missing.set(u,d)}l.update=sn([l.update,f.update])}}else c.pendingStructs=f;let h=Vs(r,s,c);if(c.pendingDs){let u=new gt(ut(c.pendingDs));x(u.restDecoder);let d=Vs(u,s,c);if(h&&d)c.pendingDs=sn([h,d]);else c.pendingDs=h||d}else c.pendingDs=h;if(o){let u=c.pendingStructs.update;c.pendingStructs=null,to(s.doc,u)}},n,!1);var to=(t,e,n,r=gt)=>{let s=ut(e);kc(s,t,n,new r(s))},fS=(t,e,n)=>to(t,e,n,br),Sc=(t,e,n=new Map)=>{Sr(t,e.store,n),Ft(t,xc(e.store))},_c=(t,e=new Uint8Array([0]),n=new it)=>{let r=eo(e);Sc(n,t,r);let s=[n.toUint8Array()];if(t.store.pendingDs)s.push(t.store.pendingDs);if(t.store.pendingStructs)s.push(Mc(t.store.pendingStructs.update,e));if(s.length>1){if(n.constructor===$t)return Lc(s.map((o,i)=>i===0?o:$c(o)));else if(n.constructor===it)return sn(s)}return s[0]},mS=(t,e)=>_c(t,e,new $t),Tc=(t)=>{let e=new Map,n=x(t.restDecoder);for(let r=0;r<n;r++){let s=x(t.restDecoder),o=x(t.restDecoder);e.set(s,o)}return e},eo=(t)=>Tc(new yr(ut(t))),no=(t,e)=>(w(t.restEncoder,e.size),z(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{w(t.restEncoder,n),w(t.restEncoder,r)}),t),Uc=(t,e)=>no(t,dn(e.store)),Ec=(t,e=new kr)=>{if(t instanceof Map)no(e,t);else Uc(e,t);return e.toUint8Array()},gS=(t)=>Ec(t,new Ir);class ro{constructor(){this.l=[]}}var Ms=()=>new ro,Fs=(t,e)=>t.l.push(e),$s=(t,e)=>{let n=t.l,r=n.length;if(t.l=n.filter((s)=>e!==s),r===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},so=(t,e,n)=>oe(t.l,[e,n]);class pt{constructor(t,e){this.client=t,this.clock=e}}var Xe=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,g=(t,e)=>new pt(t,e);var oo=(t)=>{for(let[e,n]of t.doc.share.entries())if(n===t)return e;throw v()},rn=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class io{constructor(t,e,n,r=0){this.type=t,this.tname=e,this.item=n,this.assoc=r}}class co{constructor(t,e,n=0){this.type=t,this.index=e,this.assoc=n}}var Bc=(t,e,n=0)=>new co(t,e,n),Qe=(t,e,n)=>{let r=null,s=null;if(t._item===null)s=oo(t);else r=g(t._item.id.client,t._item.id.clock);return new io(r,s,e,n)},zy=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Qe(t,null,n);e--}while(r!==null){if(!r.deleted&&r.countable){if(r.length>e)return Qe(t,g(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Qe(t,r.lastId,n);r=r.right}return Qe(t,null,n)};var Ac=(t,e)=>{let n=Lt(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},Cf=(t,e,n=!0)=>{let r=e.store,{item:s,type:o,tname:i,assoc:c}=t,a=null,f=0;if(s!==null){if(I(r,s.client)<=s.clock)return null;let l=n?mr(r,s):Ac(r,s),h=l.item;if(!(h instanceof b))return null;if(a=h.parent,a._item===null||!a._item.deleted){f=h.deleted||!h.countable?0:l.diff+(c>=0?0:1);let u=h.left;while(u!==null){if(!u.deleted&&u.countable)f+=u.length;u=u.left}}}else{if(i!==null)a=e.get(i);else if(o!==null){if(I(r,o.client)<=o.clock)return null;let{item:l}=n?mr(r,o):{item:Lt(r,o)};if(l instanceof b&&l.content instanceof Q)a=l.content.type;else return null}else throw v();if(c>=0)f=a._length;else f=0}return Bc(a,f,t.assoc)};class lo{constructor(t,e){this.ds=t,this.sv=e}}var Cc=(t,e)=>new lo(t,e),Oa=Cc(Xs(),new Map);var Rt=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!we(e.ds,t.id),pr=(t,e)=>{let n=P(t.meta,pr,Y),r=t.doc.store;if(!n.has(e))e.sv.forEach((s,o)=>{if(s<I(r,o))V(t,g(o,s))}),Vt(t,e.ds,(s)=>{}),n.add(e)};class _r{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var dn=(t)=>{let e=new Map;return t.clients.forEach((n,r)=>{let s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},I=(t,e)=>{let n=t.clients.get(e);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},ao=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw v()}n.push(e)},Z=(t,e)=>{let n=0,r=t.length-1,s=t[r],o=s.id.clock;if(o===e)return r;let i=N(e/(o+s.length-1)*r);while(n<=r){if(s=t[i],o=s.id.clock,o<=e){if(e<o+s.length)return i;n=i+1}else r=i-1;i=N((n+r)/2)}throw v()},Dc=(t,e)=>{let n=t.clients.get(e.client);return n[Z(n,e.clock)]},Lt=Dc,gr=(t,e,n)=>{let r=Z(e,n),s=e[r];if(s.id.clock<n&&s instanceof b)return e.splice(r+1,0,fn(t,s,n-s.id.clock)),r+1;return r},V=(t,e)=>{let n=t.doc.store.clients.get(e.client);return n[gr(t,n,e.clock)]},js=(t,e,n)=>{let r=e.clients.get(n.client),s=Z(r,n.clock),o=r[s];if(n.clock!==o.id.clock+o.length-1&&o.constructor!==j)r.splice(s+1,0,fn(t,o,n.clock-o.id.clock+1));return o},Oc=(t,e,n)=>{let r=t.clients.get(e.id.client);r[Z(r,e.id.clock)]=n},ho=(t,e,n,r,s)=>{if(r===0)return;let o=n+r,i=gr(t,e,n),c;do{if(c=e[i++],o<c.id.clock+c.length)gr(t,e,o);s(c)}while(i<e.length&&e[i].id.clock<o)};class uo{constructor(t,e,n){this.doc=t,this.deleteSet=new wt,this.beforeState=dn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var qs=(t,e)=>{if(e.deleteSet.clients.size===0&&!Rr(e.afterState,(n,r)=>e.beforeState.get(r)!==n))return!1;return xr(e.deleteSet),Ic(t,e),Ft(t,e.deleteSet),!0},Gs=(t,e,n)=>{let r=e._item;if(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)P(t.changed,e,Y).add(n)},en=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor){if(r.mergeWith(n)){if(n instanceof b&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n)n.parent._map.set(n.parentSub,r);continue}}break}let o=e-s;if(o)t.splice(e+1-o,o);return o},Nc=(t,e,n)=>{for(let[r,s]of t.clients.entries()){let o=e.clients.get(r);for(let i=s.length-1;i>=0;i--){let c=s[i],a=c.clock+c.len;for(let f=Z(o,c.clock),l=o[f];f<o.length&&l.id.clock<a;l=o[++f]){let h=o[f];if(c.clock+c.len<=h.id.clock)break;if(h instanceof b&&h.deleted&&!h.keep&&n(h))h.gc(e,!1)}}}},vc=(t,e)=>{t.clients.forEach((n,r)=>{let s=e.clients.get(r);for(let o=n.length-1;o>=0;o--){let i=n[o],c=Ee(s.length-1,1+Z(s,i.clock+i.len-1));for(let a=c,f=s[a];a>0&&f.id.clock>=i.clock;f=s[a])a-=1+en(s,a)}})};var fo=(t,e)=>{if(e<t.length){let n=t[e],r=n.doc,s=r.store,{deleteSet:o,_mergeStructs:i}=n;try{xr(o),n.afterState=dn(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((a,f)=>c.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(n,a)})),c.push(()=>{n.changedParentTypes.forEach((a,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))c.push(()=>{a=a.filter((l)=>l.target._item===null||!l.target._item.deleted),a.forEach((l)=>{l.currentTarget=f,l._path=null}),a.sort((l,h)=>l.path.length-h.path.length),so(f._dEH,a,n)})}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{if(n._needFormattingCleanup)Xc(n)})}),oe(c,[])}finally{if(r.gc)Nc(o,s,r.gcFilter);vc(o,s),n.afterState.forEach((l,h)=>{let u=n.beforeState.get(h)||0;if(u!==l){let d=s.clients.get(h),p=et(Z(d,u),1);for(let m=d.length-1;m>=p;)m-=1+en(d,m)}});for(let l=i.length-1;l>=0;l--){let{client:h,clock:u}=i[l].id,d=s.clients.get(h),p=Z(d,u);if(p+1<d.length){if(en(d,p+1)>1)continue}if(p>0)en(d,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID))Ns(vt,he,"[yjs] ",ue,fe,"Changed the client-id because another client seems to be using it."),r.clientID=Qs();if(r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let l=new $t;if(qs(l,n))r.emit("update",[l.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let l=new it;if(qs(l,n))r.emit("updateV2",[l.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:f}=n;if(c.size>0||f.size>0||a.size>0)c.forEach((l)=>{if(l.clientID=r.clientID,l.collectionid==null)l.collectionid=r.collectionid;r.subdocs.add(l)}),f.forEach((l)=>r.subdocs.delete(l)),r.emit("subdocs",[{loaded:a,added:c,removed:f},r,n]),f.forEach((l)=>l.destroy());if(t.length<=e+1)r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t]);else fo(t,e+1)}}},y=(t,e,n=null,r=!0)=>{let s=t._transactionCleanups,o=!1,i=null;if(t._transaction===null){if(o=!0,t._transaction=new uo(t,n,r),s.push(t._transaction),s.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{i=e(t._transaction)}finally{if(o){let c=t._transaction===s[0];if(t._transaction=null,c)fo(s,0)}}return i};class po{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Hs=(t,e,n)=>{Vt(t,n.deletions,(r)=>{if(r instanceof b&&e.scope.some((s)=>s===t.doc||rn(s,r)))Cr(r,!1)})},Ps=(t,e,n)=>{let r=null,{doc:s,scope:o}=t;y(s,(c)=>{while(e.length>0&&t.currStackItem===null){let a=s.store,f=e.pop(),l=new Set,h=[],u=!1;Vt(c,f.insertions,(d)=>{if(d instanceof b){if(d.redone!==null){let{item:p,diff:m}=mr(a,d.id);if(m>0)p=V(c,g(p.id.client,p.id.clock+m));d=p}if(!d.deleted&&o.some((p)=>p===c.doc||rn(p,d)))h.push(d)}}),Vt(c,f.deletions,(d)=>{if(d instanceof b&&o.some((p)=>p===c.doc||rn(p,d))&&!we(f.insertions,d.id))l.add(d)}),l.forEach((d)=>{u=vo(c,d,l,f.insertions,t.ignoreRemoteMapChanges,t)!==null||u});for(let d=h.length-1;d>=0;d--){let p=h[d];if(t.deleteFilter(p))p.delete(c),u=!0}t.currStackItem=u?f:null}c.changed.forEach((a,f)=>{if(a.has(null)&&f._searchMarker)f._searchMarker.length=0}),r=c},t);let i=t.currStackItem;if(i!=null){let c=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:c,origin:t},t]),t.currStackItem=null}return i};class YR extends Ue{constructor(t,{captureTimeout:e=500,captureTransaction:n=(c)=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:i=tt(t)?t[0].doc:t instanceof ac?t:t.doc}={}){super();this.scope=[],this.doc=i,this.addToScope(t),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(c)=>{if(!this.captureTransaction(c)||!this.scope.some((m)=>c.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;let a=this.undoing,f=this.redoing,l=a?this.redoStack:this.undoStack;if(a)this.stopCapturing();else if(!f)this.clear(!1,!0);let h=new wt;c.afterState.forEach((m,B)=>{let k=c.beforeState.get(B)||0,Nr=m-k;if(Nr>0)de(h,B,k,Nr)});let u=Ve(),d=!1;if(this.lastChange>0&&u-this.lastChange<this.captureTimeout&&l.length>0&&!a&&!f){let m=l[l.length-1];m.deletions=dr([m.deletions,c.deleteSet]),m.insertions=dr([m.insertions,h])}else l.push(new po(c.deleteSet,h)),d=!0;if(!a&&!f)this.lastChange=u;Vt(c,c.deleteSet,(m)=>{if(m instanceof b&&this.scope.some((B)=>B===c.doc||rn(B,m)))Cr(m,!0)});let p=[{stackItem:l[l.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];if(d)this.emit("stack-item-added",p);else this.emit("stack-item-updated",p)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let e=new Set(this.scope);t=tt(t)?t:[t],t.forEach((n)=>{if(!e.has(n)){if(e.add(n),n instanceof T?n.doc!==this.doc:n!==this.doc)ur("[yjs#509] Not same Y.Doc");this.scope.push(n)}})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){if(t&&this.canUndo()||e&&this.canRedo())this.doc.transact((n)=>{if(t)this.undoStack.forEach((r)=>Hs(n,this,r)),this.undoStack=[];if(e)this.redoStack.forEach((r)=>Hs(n,this,r)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Ps(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Ps(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*Rc(t){let e=x(t.restDecoder);for(let n=0;n<e;n++){let r=x(t.restDecoder),s=t.readClient(),o=x(t.restDecoder);for(let i=0;i<r;i++){let c=t.readInfo();if(c===10){let a=x(t.restDecoder);yield new q(g(s,o),a),o+=a}else if((Wt&c)!==0){let a=(c&(G|A))===0,f=new b(g(s,o),null,(c&A)===A?t.readLeftID():null,null,(c&G)===G?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(c&bt)===bt?t.readString():null,Ro(t,c));yield f,o+=f.length}else{let a=t.readLen();yield new j(g(s,o),a),o+=a}}}}class pn{constructor(t,e){this.gen=Rc(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===q);return this.curr}}class gn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var Lc=(t)=>sn(t,br,$t);var Vc=(t,e)=>{if(t.constructor===j){let{client:n,clock:r}=t.id;return new j(g(n,r+e),t.length-e)}else if(t.constructor===q){let{client:n,clock:r}=t.id;return new q(g(n,r+e),t.length-e)}else{let n=t,{client:r,clock:s}=n.id;return new b(g(r,s+e),null,g(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},sn=(t,e=gt,n=it)=>{if(t.length===1)return t[0];let r=t.map((l)=>new e(ut(l))),s=r.map((l)=>new pn(l,!0)),o=null,i=new n,c=new gn(i);while(!0){if(s=s.filter((u)=>u.curr!==null),s.sort((u,d)=>{if(u.curr.id.client===d.curr.id.client){let p=u.curr.id.clock-d.curr.id.clock;if(p===0)return u.curr.constructor===d.curr.constructor?0:u.curr.constructor===q?1:-1;else return p}else return d.curr.id.client-u.curr.id.client}),s.length===0)break;let l=s[0],h=l.curr.id.client;if(o!==null){let u=l.curr,d=!1;while(u!==null&&u.id.clock+u.length<=o.struct.id.clock+o.struct.length&&u.id.client>=o.struct.id.client)u=l.next(),d=!0;if(u===null||u.id.client!==h||d&&u.id.clock>o.struct.id.clock+o.struct.length)continue;if(h!==o.struct.id.client)st(c,o.struct,o.offset),o={struct:u,offset:0},l.next();else if(o.struct.id.clock+o.struct.length<u.id.clock)if(o.struct.constructor===q)o.struct.length=u.id.clock+u.length-o.struct.id.clock;else{st(c,o.struct,o.offset);let p=u.id.clock-o.struct.id.clock-o.struct.length;o={struct:new q(g(h,o.struct.id.clock+o.struct.length),p),offset:0}}else{let p=o.struct.id.clock+o.struct.length-u.id.clock;if(p>0)if(o.struct.constructor===q)o.struct.length-=p;else u=Vc(u,p);if(!o.struct.mergeWith(u))st(c,o.struct,o.offset),o={struct:u,offset:0},l.next()}}else o={struct:l.curr,offset:0},l.next();for(let u=l.curr;u!==null&&u.id.client===h&&u.id.clock===o.struct.id.clock+o.struct.length&&u.constructor!==q;u=l.next())st(c,o.struct,o.offset),o={struct:u,offset:0}}if(o!==null)st(c,o.struct,o.offset),o=null;Tr(c);let a=r.map((l)=>wr(l)),f=dr(a);return Ft(i,f),i.toUint8Array()},Mc=(t,e,n=gt,r=it)=>{let s=eo(e),o=new r,i=new gn(o),c=new n(ut(t)),a=new pn(c,!1);while(a.curr){let l=a.curr,h=l.id.client,u=s.get(h)||0;if(a.curr.constructor===q){a.next();continue}if(l.id.clock+l.length>u){st(i,l,et(u-l.id.clock,0)),a.next();while(a.curr&&a.curr.id.client===h)st(i,a.curr,0),a.next()}else while(a.curr&&a.curr.id.client===h&&a.curr.id.clock+a.curr.length<=u)a.next()}Tr(i);let f=wr(c);return Ft(o,f),o.toUint8Array()};var go=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:H(t.encoder.restEncoder)}),t.encoder.restEncoder=Xt(),t.written=0},st=(t,e,n)=>{if(t.written>0&&t.currClient!==e.id.client)go(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),w(t.encoder.restEncoder,e.id.clock+n);e.write(t.encoder,n),t.written++},Tr=(t)=>{go(t);let e=t.encoder.restEncoder;w(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){let r=t.clientStructs[n];w(e,r.written),Qt(e,r.restEncoder)}},Fc=(t,e,n,r)=>{let s=new n(ut(t)),o=new pn(s,!1),i=new r,c=new gn(i);for(let f=o.curr;f!==null;f=o.next())st(c,e(f),0);Tr(c);let a=wr(s);return Ft(i,a),i.toUint8Array()};var $c=(t)=>Fc(t,ss,gt,$t),zs="You must not compute changes after the event-handler fired.";class ye{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=jc(this.currentTarget,this.target))}deletes(t){return we(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((r)=>{if(r!==null){let s=e._map.get(r),o,i;if(this.adds(s)){let c=s.left;while(c!==null&&this.adds(c))c=c.left;if(this.deletes(s))if(c!==null&&this.deletes(c))o="delete",i=_e(c.content.getContent());else return;else if(c!==null&&this.deletes(c))o="update",i=_e(c.content.getContent());else o="add",i=void 0}else if(this.deletes(s))o="delete",i=_e(s.content.getContent());else return;t.set(r,{action:o,oldValue:i})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let e=this.target,n=Y(),r=Y(),s=[];if(t={added:n,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(e).has(null)){let i=null,c=()=>{if(i)s.push(i)};for(let a=e._start;a!==null;a=a.right)if(a.deleted){if(this.deletes(a)&&!this.adds(a)){if(i===null||i.delete===void 0)c(),i={delete:0};i.delete+=a.length,r.add(a)}}else if(this.adds(a)){if(i===null||i.insert===void 0)c(),i={insert:[]};i.insert=i.insert.concat(a.content.getContent()),n.add(a)}else{if(i===null||i.retain===void 0)c(),i={retain:0};i.retain+=a.length}if(i!==null&&i.retain===void 0)c()}this._changes=t}return t}}var jc=(t,e)=>{let n=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;while(s!==e._item&&s!==null){if(!s.deleted&&s.countable)r+=s.length;s=s.right}n.unshift(r)}e=e._item.parent}return n},D=()=>{ur("Invalid access: Add Yjs type to a document before reading data.")},mo=80,Er=0;class xo{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=Er++}}var qc=(t)=>{t.timestamp=Er++},wo=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Er++},Gc=(t,e,n)=>{if(t.length>=mo){let r=t.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return wo(r,e,n),r}else{let r=new xo(e,n);return t.push(r),r}},mn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,i)=>ct(e-o.index)<ct(e-i.index)?o:i),r=t._start,s=0;if(n!==null)r=n.p,s=n.index,qc(n);while(r.right!==null&&s<e){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}while(r.left!==null&&s>e)if(r=r.left,!r.deleted&&r.countable)s-=r.length;while(r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock)if(r=r.left,!r.deleted&&r.countable)s-=r.length;if(n!==null&&ct(n.index-s)<r.parent.length/mo)return wo(n,r,s),n;else return Gc(t._searchMarker,r,s)},pe=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){let s=t[r];if(n>0){let o=s.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)s.index-=o.length;if(o===null||o.marker===!0){t.splice(r,1);continue}s.p=o,o.marker=!0}if(e<s.index||n>0&&e===s.index)s.index=et(e,s.index+n)}};var xn=(t,e,n)=>{let r=t,s=e.changedParentTypes;while(!0){if(P(s,t,()=>[]).push(n),t._item===null)break;t=t._item.parent}so(r._eH,n,e)};class T{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ms(),this._dEH=Ms(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw F()}clone(){throw F()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted)t=t.right;return t}_callObserver(t,e){if(!t.local&&this._searchMarker)this._searchMarker.length=0}observe(t){Fs(this._eH,t)}observeDeep(t){Fs(this._dEH,t)}unobserve(t){$s(this._eH,t)}unobserveDeep(t){$s(this._dEH,t)}toJSON(){}}var yo=(t,e,n)=>{if(t.doc??D(),e<0)e=t._length+e;if(n<0)n=t._length+n;let r=n-e,s=[],o=t._start;while(o!==null&&r>0){if(o.countable&&!o.deleted){let i=o.content.getContent();if(i.length<=e)e-=i.length;else{for(let c=e;c<i.length&&r>0;c++)s.push(i[c]),r--;e=0}}o=o.right}return s},bo=(t)=>{t.doc??D();let e=[],n=t._start;while(n!==null){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e};var ge=(t,e)=>{let n=0,r=t._start;t.doc??D();while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let o=0;o<s.length;o++)e(s[o],n++,t)}r=r.right}},Io=(t,e)=>{let n=[];return ge(t,(r,s)=>{n.push(e(r,s,t))}),n},Hc=(t)=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}let s=n[r++];if(n.length<=r)n=null;return{done:!1,value:s}}}},ko=(t,e)=>{t.doc??D();let n=mn(t,e),r=t._start;if(n!==null)r=n.p,e-=n.index;for(;r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},on=(t,e,n,r)=>{let s=n,o=t.doc,{clientID:i,store:c}=o,a=n===null?e._start:n.right,f=[],l=()=>{if(f.length>0)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new xt(f)),s.integrate(t,0),f=[]};r.forEach((h)=>{if(h===null)f.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(h);break;default:switch(l(),h.constructor){case Uint8Array:case ArrayBuffer:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new be(new Uint8Array(h))),s.integrate(t,0);break;case ac:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Ie(h)),s.integrate(t,0);break;default:if(h instanceof T)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Q(h)),s.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),l()},So=()=>M("Length exceeded!"),_o=(t,e,n,r)=>{if(n>e._length)throw So();if(n===0){if(e._searchMarker)pe(e._searchMarker,n,r.length);return on(t,e,null,r)}let s=n,o=mn(e,n),i=e._start;if(o!==null){if(i=o.p,n-=o.index,n===0)i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0}for(;i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){if(n<i.length)V(t,g(i.id.client,i.id.clock+n));break}n-=i.length}if(e._searchMarker)pe(e._searchMarker,s,r.length);return on(t,e,i,r)},Pc=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:e._start}).p;if(s)while(s.right)s=s.right;return on(t,e,s,n)},To=(t,e,n,r)=>{if(r===0)return;let s=n,o=r,i=mn(e,n),c=e._start;if(i!==null)c=i.p,n-=i.index;for(;c!==null&&n>0;c=c.right)if(!c.deleted&&c.countable){if(n<c.length)V(t,g(c.id.client,c.id.clock+n));n-=c.length}while(r>0&&c!==null){if(!c.deleted){if(r<c.length)V(t,g(c.id.client,c.id.clock+r));c.delete(t),r-=c.length}c=c.right}if(r>0)throw So();if(e._searchMarker)pe(e._searchMarker,s,-o+r)},cn=(t,e,n)=>{let r=e._map.get(n);if(r!==void 0)r.delete(t)},Br=(t,e,n,r)=>{let s=e._map.get(n)||null,o=t.doc,i=o.clientID,c;if(r==null)c=new xt([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new xt([r]);break;case Uint8Array:c=new be(r);break;case ac:c=new Ie(r);break;default:if(r instanceof T)c=new Q(r);else throw Error("Unexpected content type")}new b(g(i,I(o.store,i)),s,s&&s.lastId,null,null,e,n,c).integrate(t,0)},Ar=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Uo=(t)=>{let e={};return t.doc??D(),t._map.forEach((n,r)=>{if(!n.deleted)e[r]=n.content.getContent()[n.length-1]}),e},Eo=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted};var zc=(t,e)=>{let n={};return t._map.forEach((r,s)=>{let o=r;while(o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0)))o=o.left;if(o!==null&&Rt(o,e))n[s]=o.content.getContent()[o.length-1]}),n},Ye=(t)=>(t.doc??D(),Ls(t._map.entries(),(e)=>!e[1].deleted));class Mg extends ye{}class Os extends T{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new Os;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Os}clone(){let t=new Os;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._length}_callObserver(t,e){super._callObserver(t,e),xn(this,t,new Mg(this,t))}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)y(this.doc,(e)=>{Pc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ko(this,t)}toArray(){return bo(this)}slice(t=0,e=this.length){return yo(this,t,e)}toJSON(){return this.map((t)=>t instanceof T?t.toJSON():t)}map(t){return Io(this,t)}forEach(t){ge(this,t)}[Symbol.iterator](){return Hc(this)}_write(t){t.writeTypeRef(pl)}}var Jc=(t)=>new Os;class Wy extends ye{constructor(t,e,n){super(t,e);this.keysChanged=n}}class Ur extends T{constructor(t){super();if(this._prelimContent=null,t===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((n,r)=>{this.set(r,n)}),this._prelimContent=null}_copy(){return new Ur}clone(){let t=new Ur;return this.forEach((e,n)=>{t.set(n,e instanceof T?e.clone():e)}),t}_callObserver(t,e){xn(this,t,new Wy(this,t,e))}toJSON(){this.doc??D();let t={};return this._map.forEach((e,n)=>{if(!e.deleted){let r=e.content.getContent()[e.length-1];t[n]=r instanceof T?r.toJSON():r}}),t}get size(){return[...Ye(this)].length}keys(){return Ze(Ye(this),(t)=>t[0])}values(){return Ze(Ye(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Ze(Ye(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??D(),this._map.forEach((e,n)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return Ar(this,t)}has(t){return Eo(this,t)}clear(){if(this.doc!==null)y(this.doc,(t)=>{this.forEach(function(e,n,r){cn(t,r,n)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(gl)}}var Kc=(t)=>new Ur,ot=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&Gn(t,e);class ln{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)jt(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Js=(t,e,n)=>{while(e.right!==null&&n>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)jt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));e.index+=e.right.length,n-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},tn=(t,e,n,r)=>{let s=new Map,o=r?mn(e,n):null;if(o){let i=new ln(o.p.left,o.p,o.index,s);return Js(t,i,n-o.index)}else{let i=new ln(null,e._start,0,s);return Js(t,i,n)}},Bo=(t,e,n,r)=>{while(n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===U&&ot(r.get(n.right.content.key),n.right.content.value))){if(!n.right.deleted)r.delete(n.right.content.key);n.forward()}let s=t.doc,o=s.clientID;r.forEach((i,c)=>{let{left:a,right:f}=n,l=new b(g(o,I(s.store,o)),a,a&&a.lastId,f,f&&f.id,e,null,new U(c,i));l.integrate(t,0),n.right=l,n.forward()})},jt=(t,e)=>{let{key:n,value:r}=e;if(r===null)t.delete(n);else t.set(n,r)},Ao=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&ot(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},Co=(t,e,n,r)=>{let s=t.doc,o=s.clientID,i=new Map;for(let c in r){let a=r[c],f=n.currentAttributes.get(c)??null;if(!ot(f,a)){i.set(c,f);let{left:l,right:h}=n;n.right=new b(g(o,I(s.store,o)),l,l&&l.lastId,h,h&&h.id,e,null,new U(c,a)),n.right.integrate(t,0),n.forward()}}return i},fr=(t,e,n,r,s)=>{n.currentAttributes.forEach((u,d)=>{if(s[d]===void 0)s[d]=null});let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s),a=r.constructor===String?new X(r):r instanceof T?new Q(r):new yt(r),{left:f,right:l,index:h}=n;if(e._searchMarker)pe(e._searchMarker,n.index,a.getLength());l=new b(g(i,I(o.store,i)),f,f&&f.lastId,l,l&&l.id,e,null,a),l.integrate(t,0),n.right=l,n.index=h,n.forward(),Bo(t,e,n,c)},Ks=(t,e,n,r,s)=>{let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s);t:while(n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===U))){if(!n.right.deleted)switch(n.right.content.constructor){case U:{let{key:a,value:f}=n.right.content,l=s[a];if(l!==void 0){if(ot(l,f))c.delete(a);else{if(r===0)break t;c.set(a,f)}n.right.delete(t)}else n.currentAttributes.set(a,f);break}default:if(r<n.right.length)V(t,g(n.right.id.client,n.right.id.clock+r));r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
4
|
-
`;n.right=new b(g(i,I(o.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new X(a)),n.right.integrate(t,0),n.forward()}Bo(t,e,n,c)},Do=(t,e,n,r,s)=>{let o=e,i=O();while(o&&(!o.countable||o.deleted)){if(!o.deleted&&o.content.constructor===U){let f=o.content;i.set(f.key,f)}o=o.right}let c=0,a=!1;while(e!==o){if(n===e)a=!0;if(!e.deleted){let f=e.content;switch(f.constructor){case U:{let{key:l,value:h}=f,u=r.get(l)??null;if(i.get(l)!==f||u===h){if(e.delete(t),c++,!a&&(s.get(l)??null)===h&&u!==h)if(u===null)s.delete(l);else s.set(l,u)}if(!a&&!e.deleted)jt(s,f);break}}}e=e.right}return c},Wc=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable))e=e.right;let n=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===U){let r=e.content.key;if(n.has(r))e.delete(t);else n.add(r)}e=e.left}},Zc=(t)=>{let e=0;return y(t.doc,(n)=>{let{_start:r,_start:s}=t,o=O(),i=Se(o);while(s){if(s.deleted===!1)switch(s.content.constructor){case U:jt(i,s.content);break;default:e+=Do(n,r,s,o,i),o=Se(i),r=s;break}s=s.right}}),e},Xc=(t)=>{let e=new Set,n=t.doc;for(let[r,s]of t.afterState.entries()){let o=t.beforeState.get(r)||0;if(s===o)continue;ho(t,n.store.clients.get(r),o,s,(i)=>{if(!i.deleted&&i.content.constructor===U&&i.constructor!==j)e.add(i.parent)})}y(n,(r)=>{Vt(t,t.deleteSet,(s)=>{if(s instanceof j||!s.parent._hasFormatting||e.has(s.parent))return;let o=s.parent;if(s.content.constructor===U)e.add(o);else Wc(r,s)});for(let s of e)Zc(s)})},Ws=(t,e,n)=>{let r=n,s=Se(e.currentAttributes),o=e.right;while(n>0&&e.right!==null){if(e.right.deleted===!1)switch(e.right.content.constructor){case Q:case yt:case X:if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));n-=e.right.length,e.right.delete(t);break}e.forward()}if(o)Do(t,o,e.right,s,e.currentAttributes);let i=(e.left||e.right).parent;if(i._searchMarker)pe(i._searchMarker,e.index,-r+n);return e};class
|
|
5
|
-
`?o.insert.slice(0,-1):o.insert;if(typeof i!=="string"||i.length>0)fr(n,this,r,i,o.attributes||{})}else if(o.retain!==void 0)Ks(n,this,r,o.retain,o.attributes||{});else if(o.delete!==void 0)Ws(n,r,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,n){this.doc??D();let r=[],s=new Map,o=this.doc,i="",c=this._start;function a(){if(i.length>0){let l={},h=!1;s.forEach((d,p)=>{h=!0,l[p]=d});let u={insert:i};if(h)u.attributes=l;r.push(u),i=""}}let f=()=>{while(c!==null){if(Rt(c,t)||e!==void 0&&Rt(c,e))switch(c.content.constructor){case X:{let l=s.get("ychange");if(t!==void 0&&!Rt(c,t)){if(l===void 0||l.user!==c.id.client||l.type!=="removed")a(),s.set("ychange",n?n("removed",c.id):{type:"removed"})}else if(e!==void 0&&!Rt(c,e)){if(l===void 0||l.user!==c.id.client||l.type!=="added")a(),s.set("ychange",n?n("added",c.id):{type:"added"})}else if(l!==void 0)a(),s.delete("ychange");i+=c.content.str;break}case Q:case yt:{a();let l={insert:c.content.getContent()[0]};if(s.size>0){let h={};l.attributes=h,s.forEach((u,d)=>{h[d]=u})}r.push(l);break}case U:if(Rt(c,t))a(),jt(s,c.content);break}c=c.right}a()};if(t||e)y(o,(l)=>{if(t)pr(l,t);if(e)pr(l,e);f()},"cleanup");else f();return r}insert(t,e,n){if(e.length<=0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);if(!n)n={},o.currentAttributes.forEach((i,c)=>{n[c]=i});fr(s,this,o,e,n)});else this._pending.push(()=>this.insert(t,e,n))}insertEmbed(t,e,n){let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);fr(s,this,o,e,n||{})});else this._pending.push(()=>this.insertEmbed(t,e,n||{}))}delete(t,e){if(e===0)return;let n=this.doc;if(n!==null)y(n,(r)=>{Ws(r,tn(r,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,n){if(e===0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!1);if(o.right===null)return;Ks(s,this,o,e,n)});else this._pending.push(()=>this.format(t,e,n))}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return Ar(this,t)}getAttributes(){return Uo(this)}_write(t){t.writeTypeRef(ml)}}var Qc=(t)=>new as;class nn{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??D()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Mt||e.constructor===mt)&&e._start!==null)t=e._start;else while(t!==null){let n=t.next;if(n!==null){t=n;break}else if(t.parent===this._root)t=null;else t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));if(this._firstCall=!1,t===null)return{value:void 0,done:!0};return this._currentNode=t,{value:t.content.type,done:!1}}}class mt extends T{constructor(){super();this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new mt}clone(){let t=new mt;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new nn(this,t)}querySelector(t){t=t.toUpperCase();let n=new nn(this,(r)=>r.nodeName&&r.nodeName.toUpperCase()===t).next();if(n.done)return null;else return n.value}querySelectorAll(t){return t=t.toUpperCase(),z(new nn(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){xn(this,t,new Oo(this,e,t))}toString(){return Io(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){let r=t.createDocumentFragment();if(n!==void 0)n._createAssociation(r,this);return ge(this,(s)=>{r.insertBefore(s.toDOM(t,e,n),null)}),r}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)y(this.doc,(n)=>{let r=t&&t instanceof T?t._item:t;on(n,this,r,e)});else{let n=this._prelimContent,r=t===null?0:n.findIndex((s)=>s===t)+1;if(r===0&&t!==null)throw M("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return bo(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ko(this,t)}slice(t=0,e=this.length){return yo(this,t,e)}forEach(t){ge(this,t)}_write(t){t.writeTypeRef(wl)}}var Yc=(t)=>new mt;class Mt extends mt{constructor(t="UNDEFINED"){super();this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((n,r)=>{this.setAttribute(r,n)}),this._prelimAttrs=null}_copy(){return new Mt(this.nodeName)}clone(){let t=new Mt(this.nodeName),e=this.getAttributes();return ns(e,(n,r)=>{t.setAttribute(r,n)}),t.insert(0,this.toArray().map((n)=>n instanceof T?n.clone():n)),t}toString(){let t=this.getAttributes(),e=[],n=[];for(let i in t)n.push(i);n.sort();let r=n.length;for(let i=0;i<r;i++){let c=n[i];e.push(c+'="'+t[c]+'"')}let s=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return Ar(this,t)}hasAttribute(t){return Eo(this,t)}getAttributes(t){return t?zc(this,t):Uo(this)}toDOM(t=document,e={},n){let r=t.createElement(this.nodeName),s=this.getAttributes();for(let o in s){let i=s[o];if(typeof i==="string")r.setAttribute(o,i)}if(ge(this,(o)=>{r.appendChild(o.toDOM(t,e,n))}),n!==void 0)n._createAssociation(r,this);return r}_write(t){t.writeTypeRef(xl),t.writeKey(this.nodeName)}}var tl=(t)=>new Mt(t.readKey());class Oo extends ye{constructor(t,e,n){super(t,n);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.attributesChanged.add(r)})}}class an extends Ur{constructor(t){super();this.hookName=t}_copy(){return new an(this.hookName)}clone(){let t=new an(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(t=document,e={},n){let r=e[this.hookName],s;if(r!==void 0)s=r.createDom(this);else s=document.createElement(this.hookName);if(s.setAttribute("data-yjs-hook",this.hookName),n!==void 0)n._createAssociation(s,this);return s}_write(t){t.writeTypeRef(yl),t.writeKey(this.hookName)}}var el=(t)=>new an(t.readKey());class hn extends as{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new hn}clone(){let t=new hn;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,n){let r=t.createTextNode(this.toString());if(n!==void 0)n._createAssociation(r,this);return r}toString(){return this.toDelta().map((t)=>{let e=[];for(let r in t.attributes){let s=[];for(let o in t.attributes[r])s.push({key:o,value:t.attributes[r][o]});s.sort((o,i)=>o.key<i.key?-1:1),e.push({nodeName:r,attrs:s})}e.sort((r,s)=>r.nodeName<s.nodeName?-1:1);let n="";for(let r=0;r<e.length;r++){let s=e[r];n+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){let i=s.attrs[o];n+=` ${i.key}="${i.value}"`}n+=">"}n+=t.insert;for(let r=e.length-1;r>=0;r--)n+=`</${e[r].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(bl)}}var nl=(t)=>new hn;class wn{constructor(t,e){this.id=t,this.length=e}get deleted(){throw F()}mergeWith(t){return!1}write(t,e,n){throw F()}integrate(t,e){throw F()}}var rl=0;class j extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){if(e>0)this.id.clock+=e,this.length-=e;ao(t.doc.store,this)}write(t,e){t.writeInfo(rl),t.writeLen(this.length-e)}getMissing(t,e){return null}}class be{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new be(this.content)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var sl=(t)=>new be(t.readBuf());class me{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new me(this.len)}splice(t){let e=new me(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){de(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}var ol=(t)=>new me(t.readLen()),No=(t,e)=>new ac({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ie{constructor(t){if(t._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=t;let e={};if(this.opts=e,!t.gc)e.gc=!1;if(t.autoLoad)e.autoLoad=!0;if(t.meta!==null)e.meta=t.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ie(No(this.doc.guid,this.opts))}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){if(this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad)t.subdocsLoaded.add(this.doc)}delete(t){if(t.subdocsAdded.has(this.doc))t.subdocsAdded.delete(this.doc);else t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}var il=(t)=>new Ie(No(t.readString(),t.readAny()));class yt{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new yt(this.embed)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var cl=(t)=>new yt(t.readJSON());class U{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new U(this.key,this.value)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){let n=e.parent;n._searchMarker=null,n._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}var ll=(t)=>new U(t.readKey(),t.readJSON());class un{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new un(this.arr)}splice(t){let e=new un(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}var al=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++){let s=t.readString();if(s==="undefined")n.push(void 0);else n.push(JSON.parse(s))}return new un(n)},hl=ce("node_env")==="development";class xt{constructor(t){this.arr=t,hl&&Hn(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new xt(this.arr)}splice(t){let e=new xt(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeAny(s)}}getRef(){return 8}}var ul=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new xt(n)};class X{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new X(this.str)}splice(t){let e=new X(this.str.slice(t));this.str=this.str.slice(0,t);let n=this.str.charCodeAt(t-1);if(n>=55296&&n<=56319)this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1);return e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}var fl=(t)=>new X(t.readString()),dl=[Jc,Kc,Qc,tl,Yc,el,nl],pl=0,gl=1,ml=2,xl=3,wl=4,yl=5,bl=6;class Q{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Q(this.type._copy())}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted)e.delete(t);else if(e.id.clock<(t.beforeState.get(e.id.client)||0))t._mergeStructs.push(e);e=e.right}this.type._map.forEach((n)=>{if(!n.deleted)n.delete(t);else if(n.id.clock<(t.beforeState.get(n.id.client)||0))t._mergeStructs.push(n)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((n)=>{while(n!==null)n.gc(t,!0),n=n.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Il=(t)=>new Q(dl[t.readTypeRef()](t)),mr=(t,e)=>{let n=e,r=0,s;do{if(r>0)n=g(n.client,n.clock+r);s=Lt(t,n),r=n.clock-s.id.clock,n=s.redone}while(n!==null&&s instanceof b);return{item:s,diff:r}},Cr=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},fn=(t,e,n)=>{let{client:r,clock:s}=e.id,o=new b(g(r,s+n),e,g(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=g(e.redone.client,e.redone.clock+n);if(e.right=o,o.right!==null)o.right.left=o;if(t._mergeStructs.push(o),o.parentSub!==null&&o.right===null)o.parent._map.set(o.parentSub,o);return e.length=n,o},Zs=(t,e)=>zt(t,(n)=>we(n.deletions,e)),vo=(t,e,n,r,s,o)=>{let i=t.doc,{store:c,clientID:a}=i,f=e.redone;if(f!==null)return V(t,f);let l=e.parent._item,h=null,u;if(l!==null&&l.deleted===!0){if(l.redone===null&&(!n.has(l)||vo(t,l,n,r,s,o)===null))return null;while(l.redone!==null)l=V(t,l.redone)}let d=l===null?e.parent:l.content.type;if(e.parentSub===null){h=e.left,u=e;while(h!==null){let k=h;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){h=k;break}h=h.left}while(u!==null){let k=u;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){u=k;break}u=u.right}}else{if(u=null,e.right&&!s){h=e;while(h!==null&&h.right!==null&&(h.right.redone||we(r,h.right.id)||Zs(o.undoStack,h.right.id)||Zs(o.redoStack,h.right.id))){h=h.right;while(h.redone)h=V(t,h.redone)}if(h&&h.right!==null)return null}else h=d._map.get(e.parentSub)||null;if(h!==null&&h.parent._item!==l)h=d._map.get(e.parentSub)||null}let p=I(c,a),m=g(a,p),B=new b(m,h,h&&h.lastId,u,u&&u.id,d,e.parentSub,e.content.copy());return e.redone=m,Cr(B,!0),B.integrate(t,0),B};class b extends wn{constructor(t,e,n,r,s,o,i,c){super(t,c.getLength());this.origin=n,this.left=e,this.right=r,this.rightOrigin=s,this.parent=o,this.parentSub=i,this.redone=null,this.content=c,this.info=this.content.isCountable()?En:0}set marker(t){if((this.info&Ce)>0!==t)this.info^=Ce}get marker(){return(this.info&Ce)>0}get keep(){return(this.info&Un)>0}set keep(t){if(this.keep!==t)this.info^=Un}get countable(){return(this.info&En)>0}get deleted(){return(this.info&Ae)>0}set deleted(t){if(this.deleted!==t)this.info^=Ae}markDeleted(){this.info|=Ae}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=I(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=I(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===pt&&this.id.client!==this.parent.client&&this.parent.clock>=I(e,this.parent.client))return this.parent.client;if(this.origin)this.left=js(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=V(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===j||this.right&&this.right.constructor===j)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===b)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===b)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===pt){let n=Lt(e,this.parent);if(n.constructor===j)this.parent=null;else this.parent=n.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=js(t,t.doc.store,g(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,r;if(n!==null)r=n.right;else if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start;let s=new Set,o=new Set;while(r!==null&&r!==this.right){if(o.add(r),s.add(r),Xe(this.origin,r.origin)){if(r.id.client<this.id.client)n=r,s.clear();else if(Xe(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(Lt(t.doc.store,r.origin))){if(!s.has(Lt(t.doc.store,r.origin)))n=r,s.clear()}else break;r=r.right}this.left=n}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start,this.parent._start=this;this.right=n}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(t)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(ao(t.doc.store,this),this.content.integrate(t,this),Gs(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new j(this.id,this.length).integrate(t,0)}get next(){let t=this.right;while(t!==null&&t.deleted)t=t.right;return t}get prev(){let t=this.left;while(t!==null&&t.deleted)t=t.left;return t}get lastId(){return this.length===1?this.id:g(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Xe(t.origin,this.lastId)&&this.right===t&&Xe(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let e=this.parent._searchMarker;if(e)e.forEach((n)=>{if(n.p===t){if(n.p=this,!this.deleted&&this.countable)n.index-=this.length}});if(t.keep)this.keep=!0;if(this.right=t.right,this.right!==null)this.right.left=this;return this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;if(this.countable&&this.parentSub===null)e._length-=this.length;this.markDeleted(),de(t.deleteSet,this.id.client,this.id.clock,this.length),Gs(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)Oc(t,this,new j(this.id,this.length));else this.content=new me(this.length)}write(t,e){let n=e>0?g(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Wt|(n===null?0:A)|(r===null?0:G)|(s===null?0:bt);if(t.writeInfo(o),n!==null)t.writeLeftID(n);if(r!==null)t.writeRightID(r);if(n===null&&r===null){let i=this.parent;if(i._item!==void 0){let c=i._item;if(c===null){let a=oo(i);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(c.id)}else if(i.constructor===String)t.writeParentInfo(!0),t.writeString(i);else if(i.constructor===pt)t.writeParentInfo(!1),t.writeLeftID(i);else v();if(s!==null)t.writeString(s)}this.content.write(t,e)}}var Ro=(t,e)=>kl[e&Wt](t),kl=[()=>{v()},ol,al,sl,fl,cl,ll,Il,ul,il,()=>{v()}],Sl=10;class q extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){v()}write(t,e){t.writeInfo(Sl),w(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var Lo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Vo="__ $YJS$ __";if(Lo[Vo]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Lo[Vo]=!0;var Mo=Math.floor;var Fo=(t,e)=>t<e?t:e,$o=(t,e)=>t>e?t:e;var yn=128;var qt=127;var{MAX_SAFE_INTEGER:qo,MIN_SAFE_INTEGER:va}=Number;var{fromCharCode:Ul,fromCodePoint:Ra}=String,La=Ul(65535);var El=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},Ht=typeof TextEncoder<"u"?new TextEncoder:null,Bl=(t)=>Ht.encode(t),Go=Ht?Bl:El;var Gt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(Gt&&Gt.decode(new Uint8Array).length===1)Gt=null;class Po{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var kf=()=>new Po;var y_=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var Sf=(t)=>{let e=new Uint8Array(y_(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e};var bn=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var rt=(t,e)=>{while(e>qt)bn(t,yn|qt&e),e=Mo(e/128);bn(t,qt&e)};var Dr=new Uint8Array(30000),Dl=Dr.length/3,Ol=(t,e)=>{if(e.length<Dl){let n=Ht.encodeInto(e,Dr).written||0;rt(t,n);for(let r=0;r<n;r++)bn(t,Dr[r])}else kn(t,Go(e))},Nl=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;rt(t,r);for(let s=0;s<r;s++)bn(t,n.codePointAt(s))},In=Ht&&Ht.encodeInto?Ol:Nl;var vl=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Fo(n-r,e.length),o=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array($o(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o},kn=(t,e)=>{rt(t,e.byteLength),vl(t,e)};var ja=new DataView(new ArrayBuffer(4));var Or=(t)=>Error(t);var Jo=Or("Unexpected end of array"),Vl=Or("Integer out of Range"),Ml=(t,e,n)=>{if(e<0||n<0||e+n>t.length)throw Jo;return new Uint8Array(t.buffer,t.byteOffset+e,n)};class Ko{constructor(t){this.arr=t,this.pos=0}}var Uy=(t)=>new Ko(t);var Fl=(t,e)=>{let n=Ml(t.arr,t.pos,e);return t.pos+=e,n},Sn=(t)=>Fl(t,ke(t));var zo=(t)=>t.arr[t.pos++];var ke=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&qt)*n,n*=128,s<yn)return e;if(e>qo)throw Vl}throw Jo};var $l=(t)=>{let e=ke(t);if(e===0)return"";else{let n=String.fromCodePoint(zo(t));if(--e<100)while(e--)n+=String.fromCodePoint(zo(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},jl=(t)=>Gt.decode(Sn(t)),_n=Gt?jl:$l;var bS=0,vS=1,yS=2,wS=3;class Ef extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function w_(t){let e=kf();switch(t.type){case"doc-sync":{rt(e,bS),In(e,t.path),rt(e,t.epoch),kn(e,t.body);break}case"awareness":{rt(e,vS),kn(e,t.body);break}case"doc-close":{rt(e,yS),In(e,t.path);break}case"control":{rt(e,wS),In(e,JSON.stringify(t.message));break}default:throw new Ef(`unknown-frame:${t.type}`)}return Sf(e)}function x_(t){try{let e=Uy(t),n=ke(e);switch(n){case bS:{let r=_n(e),s=ke(e);return{body:Sn(e),epoch:s,path:r,type:"doc-sync"}}case vS:return{body:Sn(e),type:"awareness"};case yS:return{path:_n(e),type:"doc-close"};case wS:{let r=JSON.parse(_n(e));if(typeof r!=="object"||typeof r.type!=="string")throw new Ef("malformed-control");return{message:r,type:"control"}}default:throw new Ef(`unknown-frame-type:${n}`)}}catch(e){if(e instanceof Ef)throw e;throw new Ef(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
|
|
6
|
-
export{
|
|
3
|
+
${n.toString()}`)};class Es{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:le(t),h:e}),this}else(t){return this.if(qe,t)}done(){return(t,e)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(t))return r.h(t,e)}throw M("Unhandled pattern")}}}var nc=(t)=>new Es(t),Bs=nc(qe).if(_s,(t,e)=>Fe(e,An,It)).if(Ts,(t,e)=>fs(e)).if(Yi,(t,e)=>Wn(e)).if(Qi,(t,e)=>BigInt(Fe(e,An,It))).if(je,(t,e)=>Ct(e,$e(e,t.shape))).if(ji,(t,e)=>{let n={};for(let r in t.shape){let s=t.shape[r];if(Fi.check(s)){if(Wn(e))continue;s=s.shape}n[r]=Bs(s,e)}return n}).if(Pi,(t,e)=>{let n=[],r=Zn(e,0,42);for(let s=0;s<r;s++)n.push(Ct(e,t.shape));return n}).if(gs,(t,e)=>$e(e,t.shape)).if(tc,(t,e)=>null).if(Wi,(t,e)=>{let n=Ct(e,t.res);return()=>n}).if(Xi,(t,e)=>Ct(e,$e(e,[Dt,Ot,We,Us,or,Ke,ys(Dt),ws(Nt("a","b","c"),Dt)]))).if(Gi,(t,e)=>{let n={},r=Fe(e,0,3);for(let s=0;s<r;s++){let o=Ct(e,t.shape.keys),i=Ct(e,t.shape.values);n[o]=i}return n}).done(),Ct=(t,e)=>Bs(le(e),t);var dt=typeof document<"u"?document:{};var da=_((t)=>t.nodeType===cc);var pa=typeof DOMParser<"u"?new DOMParser:null;var ga=_((t)=>t.nodeType===sc);var ma=_((t)=>t.nodeType===oc);var As=(t)=>vr(t,(e,n)=>`${n}:${e};`).join("");var{ELEMENT_NODE:sc,TEXT_NODE:oc,CDATA_SECTION_NODE:xa,COMMENT_NODE:wa,DOCUMENT_NODE:ic,DOCUMENT_TYPE_NODE:ya,DOCUMENT_FRAGMENT_NODE:cc}=dt,ba=_((t)=>t.nodeType===ic);var W=Symbol;var he=W(),ue=W(),ir=W(),cr=W(),lr=W(),fe=W(),ar=W(),vt=W(),hr=W(),Cs=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=0;for(;r<t.length;r++){let s=t[r];if(s===void 0)break;else if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}if(r>0)n.push(e.join(""));for(;r<t.length;r++){let s=t[r];if(!(s instanceof Symbol))n.push(s)}return n};var Ia=Ve();var fc={[he]:K("font-weight","bold"),[ue]:K("font-weight","normal"),[ir]:K("color","blue"),[lr]:K("color","green"),[cr]:K("color","grey"),[fe]:K("color","red"),[ar]:K("color","purple"),[vt]:K("color","orange"),[hr]:K("color","black")},dc=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],n=[],r=O(),s=[],o=0;for(;o<t.length;o++){let i=t[o],c=fc[i];if(c!==void 0)r.set(c.left,c.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let a=As(r);if(o>0||a.length>0)e.push("%c"+i),n.push(a);else e.push(i)}else break}}if(o>0)s=n,s.unshift(e.join(""));for(;o<t.length;o++){let i=t[o];if(!(i instanceof Symbol))s.push(i)}return s},Ds=ls?dc:Cs,Ns=(...t)=>{console.log(...Ds(t)),vs.forEach((e)=>e.print(t))},ur=(...t)=>{console.warn(...Ds(t)),t.unshift(vt),vs.forEach((e)=>e.print(t))};var vs=Y();var Rs=(t)=>({[Symbol.iterator](){return this},next:t}),Ls=(t,e)=>Rs(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Ze=(t,e)=>Rs(()=>{let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class xe{constructor(t,e){this.clock=t,this.len=e}}class wt{constructor(){this.clients=new Map}}var Vt=(t,e,n)=>e.clients.forEach((r,s)=>{let o=t.doc.store.clients.get(s);if(o!=null){let i=o[o.length-1],c=i.id.clock+i.length;for(let a=0,f=r[a];a<r.length&&f.clock<c;f=r[++a])ho(t,o,f.clock,f.len,n)}}),mc=(t,e)=>{let n=0,r=t.length-1;while(n<=r){let s=N((n+r)/2),o=t[s],i=o.clock;if(i<=e){if(e<i+o.len)return s;n=s+1}else r=s-1}return null},we=(t,e)=>{let n=t.clients.get(e.client);return n!==void 0&&mc(n,e.clock)!==null},xr=(t)=>{t.clients.forEach((e)=>{e.sort((s,o)=>s.clock-o.clock);let n,r;for(n=1,r=1;n<e.length;n++){let s=e[r-1],o=e[n];if(s.clock+s.len>=o.clock)e[r-1]=new xe(s.clock,et(s.len,o.clock+o.len-s.clock));else{if(r<n)e[r]=o;r++}}e.length=r})},dr=(t)=>{let e=new wt;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){let o=r.slice();for(let i=n+1;i<t.length;i++)Lr(o,t[i].clients.get(s)||[]);e.clients.set(s,o)}});return xr(e),e},de=(t,e,n,r)=>{P(t.clients,e,()=>[]).push(new xe(n,r))},Xs=()=>new wt,xc=(t)=>{let e=Xs();return t.clients.forEach((n,r)=>{let s=[];for(let o=0;o<n.length;o++){let i=n[o];if(i.deleted){let c=i.id.clock,a=i.length;if(o+1<n.length)for(let f=n[o+1];o+1<n.length&&f.deleted;f=n[++o+1])a+=f.length;s.push(new xe(c,a))}}if(s.length>0)e.clients.set(r,s)}),e},Ft=(t,e)=>{w(t.restEncoder,e.clients.size),z(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),w(t.restEncoder,n);let s=r.length;w(t.restEncoder,s);for(let o=0;o<s;o++){let i=r[o];t.writeDsClock(i.clock),t.writeDsLen(i.len)}})},wr=(t)=>{let e=new wt,n=x(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();let s=x(t.restDecoder),o=x(t.restDecoder);if(o>0){let i=P(e.clients,s,()=>[]);for(let c=0;c<o;c++)i.push(new xe(t.readDsClock(),t.readDsLen()))}}return e},Vs=(t,e,n)=>{let r=new wt,s=x(t.restDecoder);for(let o=0;o<s;o++){t.resetDsCurVal();let i=x(t.restDecoder),c=x(t.restDecoder),a=n.clients.get(i)||[],f=I(n,i);for(let l=0;l<c;l++){let h=t.readDsClock(),u=h+t.readDsLen();if(h<f){if(f<u)de(r,i,f,u-f);let d=Z(a,h),p=a[d];if(!p.deleted&&p.id.clock<h)a.splice(d+1,0,fn(e,p,h-p.id.clock)),d++;while(d<a.length)if(p=a[d++],p.id.clock<u){if(!p.deleted){if(u<p.id.clock+p.length)a.splice(d,0,fn(e,p,u-p.id.clock));p.delete(e)}}else break}else de(r,i,h,u-h)}}if(r.clients.size>0){let o=new it;return w(o.restEncoder,0),Ft(o,r),o.toUint8Array()}return null};var Qs=Fn;class lc extends Ue{constructor({guid:t=Wr(),collectionid:e=null,gc:n=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:i=!0}={}){super();this.gc=n,this.gcFilter=r,this.clientID=Qs(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new _r,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=$n((a)=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>$n((a)=>{let f=(l)=>{if(l===void 0||l===!0)this.off("sync",f),a()};this.on("sync",f)});this.on("sync",(a)=>{if(a===!1&&this.isSynced)this.whenSynced=c();if(this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=c()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)y(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(z(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return y(this,t,e)}get(t,e=T){let n=P(this.share,t,()=>{let s=new e;return s._integrate(this,null),s}),r=n.constructor;if(e!==T&&r!==e)if(r===T){let s=new e;s._map=n._map,n._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=s}),s._start=n._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=n._length,this.share.set(t,s),s._integrate(this,null),s}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return n}getArray(t=""){return this.get(t,Os)}getText(t=""){return this.get(t,as)}getMap(t=""){return this.get(t,Ur)}getXmlElement(t=""){return this.get(t,Mt)}getXmlFragment(t=""){return this.get(t,mt)}toJSON(){let t={};return this.share.forEach((e,n)=>{t[n]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,z(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new lc({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,y(t.parent.doc,(n)=>{let r=e.doc;if(!t.deleted)n.subdocsAdded.add(r);n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class yr{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return x(this.restDecoder)}readDsLen(){return x(this.restDecoder)}}class br extends yr{readLeftID(){return g(x(this.restDecoder),x(this.restDecoder))}readRightID(){return g(x(this.restDecoder),x(this.restDecoder))}readClient(){return x(this.restDecoder)}readInfo(){return at(this.restDecoder)}readString(){return ht(this.restDecoder)}readParentInfo(){return x(this.restDecoder)===1}readTypeRef(){return x(this.restDecoder)}readLen(){return x(this.restDecoder)}readAny(){return Et(this.restDecoder)}readBuf(){return hs(L(this.restDecoder))}readJSON(){return JSON.parse(ht(this.restDecoder))}readKey(){return ht(this.restDecoder)}}class Ys{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=x(this.restDecoder),this.dsCurrVal}readDsLen(){let t=x(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class gt extends Ys{constructor(t){super(t);this.keys=[],x(t),this.keyClockDecoder=new ee(L(t)),this.clientDecoder=new Bt(L(t)),this.leftClockDecoder=new ee(L(t)),this.rightClockDecoder=new ee(L(t)),this.infoDecoder=new Le(L(t),at),this.stringDecoder=new Mn(L(t)),this.parentInfoDecoder=new Le(L(t),at),this.typeRefDecoder=new Bt(L(t)),this.lenDecoder=new Bt(L(t))}readLeftID(){return new pt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new pt(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Et(this.restDecoder)}readBuf(){return L(this.restDecoder)}readJSON(){return Et(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];else{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class Ir{constructor(){this.restEncoder=Xt()}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){w(this.restEncoder,t)}writeDsLen(t){w(this.restEncoder,t)}}class $t extends Ir{writeLeftID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeRightID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeClient(t){w(this.restEncoder,t)}writeInfo(t){Oe(this.restEncoder,t)}writeString(t){lt(this.restEncoder,t)}writeParentInfo(t){w(this.restEncoder,t?1:0)}writeTypeRef(t){w(this.restEncoder,t)}writeLen(t){w(this.restEncoder,t)}writeAny(t){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){lt(this.restEncoder,JSON.stringify(t))}writeKey(t){lt(this.restEncoder,t)}}class kr{constructor(){this.restEncoder=Xt(),this.dsCurrVal=0}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,w(this.restEncoder,e)}writeDsLen(t){if(t===0)v();w(this.restEncoder,t-1),this.dsCurrVal+=t}}class it extends kr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Yt,this.clientEncoder=new Ut,this.leftClockEncoder=new Yt,this.rightClockEncoder=new Yt,this.infoEncoder=new ve(Oe),this.stringEncoder=new Rn,this.parentInfoEncoder=new ve(Oe),this.typeRefEncoder=new Ut,this.lenEncoder=new Ut}toUint8Array(){let t=Xt();return w(t,0),R(t,this.keyClockEncoder.toUint8Array()),R(t,this.clientEncoder.toUint8Array()),R(t,this.leftClockEncoder.toUint8Array()),R(t,this.rightClockEncoder.toUint8Array()),R(t,H(this.infoEncoder)),R(t,this.stringEncoder.toUint8Array()),R(t,H(this.parentInfoEncoder)),R(t,this.typeRefEncoder.toUint8Array()),R(t,this.lenEncoder.toUint8Array()),Qt(t,H(this.restEncoder)),H(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){_t(this.restEncoder,t)}writeBuf(t){R(this.restEncoder,t)}writeJSON(t){_t(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);if(e===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t);else this.keyClockEncoder.write(e)}}var wc=(t,e,n,r)=>{r=et(r,e[0].id.clock);let s=Z(e,r);w(t.restEncoder,e.length-s),t.writeClient(n),w(t.restEncoder,r);let o=e[s];o.write(t,r-o.id.clock);for(let i=s+1;i<e.length;i++)e[i].write(t,0)},Sr=(t,e,n)=>{let r=new Map;n.forEach((s,o)=>{if(I(e,o)>s)r.set(o,s)}),dn(e).forEach((s,o)=>{if(!n.has(o))r.set(o,0)}),w(t.restEncoder,r.size),z(r.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{wc(t,e.clients.get(s),s,o)})},yc=(t,e)=>{let n=O(),r=x(t.restDecoder);for(let s=0;s<r;s++){let o=x(t.restDecoder),i=Array(o),c=t.readClient(),a=x(t.restDecoder);n.set(c,{i:0,refs:i});for(let f=0;f<o;f++){let l=t.readInfo();switch(Wt&l){case 0:{let h=t.readLen();i[f]=new j(g(c,a),h),a+=h;break}case 10:{let h=x(t.restDecoder);i[f]=new q(g(c,a),h),a+=h;break}default:{let h=(l&(G|A))===0,u=new b(g(c,a),null,(l&A)===A?t.readLeftID():null,null,(l&G)===G?t.readRightID():null,h?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,h&&(l&bt)===bt?t.readString():null,Ro(t,l));i[f]=u,a+=u.length}}}}return n},bc=(t,e,n)=>{let r=[],s=z(n.keys()).sort((d,p)=>d-p);if(s.length===0)return null;let o=()=>{if(s.length===0)return null;let d=n.get(s[s.length-1]);while(d.refs.length===d.i)if(s.pop(),s.length>0)d=n.get(s[s.length-1]);else return null;return d},i=o();if(i===null)return null;let c=new _r,a=new Map,f=(d,p)=>{let m=a.get(d);if(m==null||m>p)a.set(d,p)},l=i.refs[i.i++],h=new Map,u=()=>{for(let d of r){let p=d.id.client,m=n.get(p);if(m)m.i--,c.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[];else c.clients.set(p,[d]);s=s.filter((B)=>B!==p)}r.length=0};while(!0){if(l.constructor!==q){let p=P(h,l.id.client,()=>I(e,l.id.client))-l.id.clock;if(p<0)r.push(l),f(l.id.client,l.id.clock-1),u();else{let m=l.getMissing(t,e);if(m!==null){r.push(l);let B=n.get(m)||{refs:[],i:0};if(B.refs.length===B.i)f(m,I(e,m)),u();else{l=B.refs[B.i++];continue}}else if(p===0||p<l.length)l.integrate(t,p),h.set(l.id.client,l.id.clock+l.length)}}if(r.length>0)l=r.pop();else if(i!==null&&i.i<i.refs.length)l=i.refs[i.i++];else if(i=o(),i===null)break;else l=i.refs[i.i++]}if(c.clients.size>0){let d=new it;return Sr(d,c,new Map),w(d.restEncoder,0),{missing:a,update:d.toUint8Array()}}return null},Ic=(t,e)=>Sr(t,e.doc.store,e.beforeState),kc=(t,e,n,r=new gt(t))=>y(e,(s)=>{s.local=!1;let o=!1,i=s.doc,c=i.store,a=yc(r,i),f=bc(s,c,a),l=c.pendingStructs;if(l){for(let[u,d]of l.missing)if(d<I(c,u)){o=!0;break}if(f){for(let[u,d]of f.missing){let p=l.missing.get(u);if(p==null||p>d)l.missing.set(u,d)}l.update=sn([l.update,f.update])}}else c.pendingStructs=f;let h=Vs(r,s,c);if(c.pendingDs){let u=new gt(ut(c.pendingDs));x(u.restDecoder);let d=Vs(u,s,c);if(h&&d)c.pendingDs=sn([h,d]);else c.pendingDs=h||d}else c.pendingDs=h;if(o){let u=c.pendingStructs.update;c.pendingStructs=null,to(s.doc,u)}},n,!1);var to=(t,e,n,r=gt)=>{let s=ut(e);kc(s,t,n,new r(s))},gS=(t,e,n)=>to(t,e,n,br),Sc=(t,e,n=new Map)=>{Sr(t,e.store,n),Ft(t,xc(e.store))},_c=(t,e=new Uint8Array([0]),n=new it)=>{let r=eo(e);Sc(n,t,r);let s=[n.toUint8Array()];if(t.store.pendingDs)s.push(t.store.pendingDs);if(t.store.pendingStructs)s.push(Mc(t.store.pendingStructs.update,e));if(s.length>1){if(n.constructor===$t)return Lc(s.map((o,i)=>i===0?o:$c(o)));else if(n.constructor===it)return sn(s)}return s[0]},bS=(t,e)=>_c(t,e,new $t),Tc=(t)=>{let e=new Map,n=x(t.restDecoder);for(let r=0;r<n;r++){let s=x(t.restDecoder),o=x(t.restDecoder);e.set(s,o)}return e},eo=(t)=>Tc(new yr(ut(t))),no=(t,e)=>(w(t.restEncoder,e.size),z(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{w(t.restEncoder,n),w(t.restEncoder,r)}),t),Uc=(t,e)=>no(t,dn(e.store)),Ec=(t,e=new kr)=>{if(t instanceof Map)no(e,t);else Uc(e,t);return e.toUint8Array()},vS=(t)=>Ec(t,new Ir);class ro{constructor(){this.l=[]}}var Ms=()=>new ro,Fs=(t,e)=>t.l.push(e),$s=(t,e)=>{let n=t.l,r=n.length;if(t.l=n.filter((s)=>e!==s),r===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},so=(t,e,n)=>oe(t.l,[e,n]);class pt{constructor(t,e){this.client=t,this.clock=e}}var Xe=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,g=(t,e)=>new pt(t,e);var oo=(t)=>{for(let[e,n]of t.doc.share.entries())if(n===t)return e;throw v()},rn=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class io{constructor(t,e,n,r=0){this.type=t,this.tname=e,this.item=n,this.assoc=r}}class co{constructor(t,e,n=0){this.type=t,this.index=e,this.assoc=n}}var Bc=(t,e,n=0)=>new co(t,e,n),Qe=(t,e,n)=>{let r=null,s=null;if(t._item===null)s=oo(t);else r=g(t._item.id.client,t._item.id.clock);return new io(r,s,e,n)},Wy=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Qe(t,null,n);e--}while(r!==null){if(!r.deleted&&r.countable){if(r.length>e)return Qe(t,g(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Qe(t,r.lastId,n);r=r.right}return Qe(t,null,n)};var Ac=(t,e)=>{let n=Lt(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},kf=(t,e,n=!0)=>{let r=e.store,{item:s,type:o,tname:i,assoc:c}=t,a=null,f=0;if(s!==null){if(I(r,s.client)<=s.clock)return null;let l=n?mr(r,s):Ac(r,s),h=l.item;if(!(h instanceof b))return null;if(a=h.parent,a._item===null||!a._item.deleted){f=h.deleted||!h.countable?0:l.diff+(c>=0?0:1);let u=h.left;while(u!==null){if(!u.deleted&&u.countable)f+=u.length;u=u.left}}}else{if(i!==null)a=e.get(i);else if(o!==null){if(I(r,o.client)<=o.clock)return null;let{item:l}=n?mr(r,o):{item:Lt(r,o)};if(l instanceof b&&l.content instanceof Q)a=l.content.type;else return null}else throw v();if(c>=0)f=a._length;else f=0}return Bc(a,f,t.assoc)};class lo{constructor(t,e){this.ds=t,this.sv=e}}var Cc=(t,e)=>new lo(t,e),Oa=Cc(Xs(),new Map);var Rt=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!we(e.ds,t.id),pr=(t,e)=>{let n=P(t.meta,pr,Y),r=t.doc.store;if(!n.has(e))e.sv.forEach((s,o)=>{if(s<I(r,o))V(t,g(o,s))}),Vt(t,e.ds,(s)=>{}),n.add(e)};class _r{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var dn=(t)=>{let e=new Map;return t.clients.forEach((n,r)=>{let s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},I=(t,e)=>{let n=t.clients.get(e);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},ao=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw v()}n.push(e)},Z=(t,e)=>{let n=0,r=t.length-1,s=t[r],o=s.id.clock;if(o===e)return r;let i=N(e/(o+s.length-1)*r);while(n<=r){if(s=t[i],o=s.id.clock,o<=e){if(e<o+s.length)return i;n=i+1}else r=i-1;i=N((n+r)/2)}throw v()},Dc=(t,e)=>{let n=t.clients.get(e.client);return n[Z(n,e.clock)]},Lt=Dc,gr=(t,e,n)=>{let r=Z(e,n),s=e[r];if(s.id.clock<n&&s instanceof b)return e.splice(r+1,0,fn(t,s,n-s.id.clock)),r+1;return r},V=(t,e)=>{let n=t.doc.store.clients.get(e.client);return n[gr(t,n,e.clock)]},js=(t,e,n)=>{let r=e.clients.get(n.client),s=Z(r,n.clock),o=r[s];if(n.clock!==o.id.clock+o.length-1&&o.constructor!==j)r.splice(s+1,0,fn(t,o,n.clock-o.id.clock+1));return o},Oc=(t,e,n)=>{let r=t.clients.get(e.id.client);r[Z(r,e.id.clock)]=n},ho=(t,e,n,r,s)=>{if(r===0)return;let o=n+r,i=gr(t,e,n),c;do{if(c=e[i++],o<c.id.clock+c.length)gr(t,e,o);s(c)}while(i<e.length&&e[i].id.clock<o)};class uo{constructor(t,e,n){this.doc=t,this.deleteSet=new wt,this.beforeState=dn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var qs=(t,e)=>{if(e.deleteSet.clients.size===0&&!Rr(e.afterState,(n,r)=>e.beforeState.get(r)!==n))return!1;return xr(e.deleteSet),Ic(t,e),Ft(t,e.deleteSet),!0},Gs=(t,e,n)=>{let r=e._item;if(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)P(t.changed,e,Y).add(n)},en=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor){if(r.mergeWith(n)){if(n instanceof b&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n)n.parent._map.set(n.parentSub,r);continue}}break}let o=e-s;if(o)t.splice(e+1-o,o);return o},Nc=(t,e,n)=>{for(let[r,s]of t.clients.entries()){let o=e.clients.get(r);for(let i=s.length-1;i>=0;i--){let c=s[i],a=c.clock+c.len;for(let f=Z(o,c.clock),l=o[f];f<o.length&&l.id.clock<a;l=o[++f]){let h=o[f];if(c.clock+c.len<=h.id.clock)break;if(h instanceof b&&h.deleted&&!h.keep&&n(h))h.gc(e,!1)}}}},vc=(t,e)=>{t.clients.forEach((n,r)=>{let s=e.clients.get(r);for(let o=n.length-1;o>=0;o--){let i=n[o],c=Ee(s.length-1,1+Z(s,i.clock+i.len-1));for(let a=c,f=s[a];a>0&&f.id.clock>=i.clock;f=s[a])a-=1+en(s,a)}})};var fo=(t,e)=>{if(e<t.length){let n=t[e],r=n.doc,s=r.store,{deleteSet:o,_mergeStructs:i}=n;try{xr(o),n.afterState=dn(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((a,f)=>c.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(n,a)})),c.push(()=>{n.changedParentTypes.forEach((a,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))c.push(()=>{a=a.filter((l)=>l.target._item===null||!l.target._item.deleted),a.forEach((l)=>{l.currentTarget=f,l._path=null}),a.sort((l,h)=>l.path.length-h.path.length),so(f._dEH,a,n)})}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{if(n._needFormattingCleanup)Xc(n)})}),oe(c,[])}finally{if(r.gc)Nc(o,s,r.gcFilter);vc(o,s),n.afterState.forEach((l,h)=>{let u=n.beforeState.get(h)||0;if(u!==l){let d=s.clients.get(h),p=et(Z(d,u),1);for(let m=d.length-1;m>=p;)m-=1+en(d,m)}});for(let l=i.length-1;l>=0;l--){let{client:h,clock:u}=i[l].id,d=s.clients.get(h),p=Z(d,u);if(p+1<d.length){if(en(d,p+1)>1)continue}if(p>0)en(d,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID))Ns(vt,he,"[yjs] ",ue,fe,"Changed the client-id because another client seems to be using it."),r.clientID=Qs();if(r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let l=new $t;if(qs(l,n))r.emit("update",[l.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let l=new it;if(qs(l,n))r.emit("updateV2",[l.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:f}=n;if(c.size>0||f.size>0||a.size>0)c.forEach((l)=>{if(l.clientID=r.clientID,l.collectionid==null)l.collectionid=r.collectionid;r.subdocs.add(l)}),f.forEach((l)=>r.subdocs.delete(l)),r.emit("subdocs",[{loaded:a,added:c,removed:f},r,n]),f.forEach((l)=>l.destroy());if(t.length<=e+1)r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t]);else fo(t,e+1)}}},y=(t,e,n=null,r=!0)=>{let s=t._transactionCleanups,o=!1,i=null;if(t._transaction===null){if(o=!0,t._transaction=new uo(t,n,r),s.push(t._transaction),s.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{i=e(t._transaction)}finally{if(o){let c=t._transaction===s[0];if(t._transaction=null,c)fo(s,0)}}return i};class po{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Hs=(t,e,n)=>{Vt(t,n.deletions,(r)=>{if(r instanceof b&&e.scope.some((s)=>s===t.doc||rn(s,r)))Cr(r,!1)})},Ps=(t,e,n)=>{let r=null,{doc:s,scope:o}=t;y(s,(c)=>{while(e.length>0&&t.currStackItem===null){let a=s.store,f=e.pop(),l=new Set,h=[],u=!1;Vt(c,f.insertions,(d)=>{if(d instanceof b){if(d.redone!==null){let{item:p,diff:m}=mr(a,d.id);if(m>0)p=V(c,g(p.id.client,p.id.clock+m));d=p}if(!d.deleted&&o.some((p)=>p===c.doc||rn(p,d)))h.push(d)}}),Vt(c,f.deletions,(d)=>{if(d instanceof b&&o.some((p)=>p===c.doc||rn(p,d))&&!we(f.insertions,d.id))l.add(d)}),l.forEach((d)=>{u=vo(c,d,l,f.insertions,t.ignoreRemoteMapChanges,t)!==null||u});for(let d=h.length-1;d>=0;d--){let p=h[d];if(t.deleteFilter(p))p.delete(c),u=!0}t.currStackItem=u?f:null}c.changed.forEach((a,f)=>{if(a.has(null)&&f._searchMarker)f._searchMarker.length=0}),r=c},t);let i=t.currStackItem;if(i!=null){let c=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:c,origin:t},t]),t.currStackItem=null}return i};class XR extends Ue{constructor(t,{captureTimeout:e=500,captureTransaction:n=(c)=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:i=tt(t)?t[0].doc:t instanceof lc?t:t.doc}={}){super();this.scope=[],this.doc=i,this.addToScope(t),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(c)=>{if(!this.captureTransaction(c)||!this.scope.some((m)=>c.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;let a=this.undoing,f=this.redoing,l=a?this.redoStack:this.undoStack;if(a)this.stopCapturing();else if(!f)this.clear(!1,!0);let h=new wt;c.afterState.forEach((m,B)=>{let k=c.beforeState.get(B)||0,Nr=m-k;if(Nr>0)de(h,B,k,Nr)});let u=Ve(),d=!1;if(this.lastChange>0&&u-this.lastChange<this.captureTimeout&&l.length>0&&!a&&!f){let m=l[l.length-1];m.deletions=dr([m.deletions,c.deleteSet]),m.insertions=dr([m.insertions,h])}else l.push(new po(c.deleteSet,h)),d=!0;if(!a&&!f)this.lastChange=u;Vt(c,c.deleteSet,(m)=>{if(m instanceof b&&this.scope.some((B)=>B===c.doc||rn(B,m)))Cr(m,!0)});let p=[{stackItem:l[l.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];if(d)this.emit("stack-item-added",p);else this.emit("stack-item-updated",p)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let e=new Set(this.scope);t=tt(t)?t:[t],t.forEach((n)=>{if(!e.has(n)){if(e.add(n),n instanceof T?n.doc!==this.doc:n!==this.doc)ur("[yjs#509] Not same Y.Doc");this.scope.push(n)}})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){if(t&&this.canUndo()||e&&this.canRedo())this.doc.transact((n)=>{if(t)this.undoStack.forEach((r)=>Hs(n,this,r)),this.undoStack=[];if(e)this.redoStack.forEach((r)=>Hs(n,this,r)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Ps(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Ps(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*Rc(t){let e=x(t.restDecoder);for(let n=0;n<e;n++){let r=x(t.restDecoder),s=t.readClient(),o=x(t.restDecoder);for(let i=0;i<r;i++){let c=t.readInfo();if(c===10){let a=x(t.restDecoder);yield new q(g(s,o),a),o+=a}else if((Wt&c)!==0){let a=(c&(G|A))===0,f=new b(g(s,o),null,(c&A)===A?t.readLeftID():null,null,(c&G)===G?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(c&bt)===bt?t.readString():null,Ro(t,c));yield f,o+=f.length}else{let a=t.readLen();yield new j(g(s,o),a),o+=a}}}}class pn{constructor(t,e){this.gen=Rc(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===q);return this.curr}}class gn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var Lc=(t)=>sn(t,br,$t);var Vc=(t,e)=>{if(t.constructor===j){let{client:n,clock:r}=t.id;return new j(g(n,r+e),t.length-e)}else if(t.constructor===q){let{client:n,clock:r}=t.id;return new q(g(n,r+e),t.length-e)}else{let n=t,{client:r,clock:s}=n.id;return new b(g(r,s+e),null,g(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},sn=(t,e=gt,n=it)=>{if(t.length===1)return t[0];let r=t.map((l)=>new e(ut(l))),s=r.map((l)=>new pn(l,!0)),o=null,i=new n,c=new gn(i);while(!0){if(s=s.filter((u)=>u.curr!==null),s.sort((u,d)=>{if(u.curr.id.client===d.curr.id.client){let p=u.curr.id.clock-d.curr.id.clock;if(p===0)return u.curr.constructor===d.curr.constructor?0:u.curr.constructor===q?1:-1;else return p}else return d.curr.id.client-u.curr.id.client}),s.length===0)break;let l=s[0],h=l.curr.id.client;if(o!==null){let u=l.curr,d=!1;while(u!==null&&u.id.clock+u.length<=o.struct.id.clock+o.struct.length&&u.id.client>=o.struct.id.client)u=l.next(),d=!0;if(u===null||u.id.client!==h||d&&u.id.clock>o.struct.id.clock+o.struct.length)continue;if(h!==o.struct.id.client)st(c,o.struct,o.offset),o={struct:u,offset:0},l.next();else if(o.struct.id.clock+o.struct.length<u.id.clock)if(o.struct.constructor===q)o.struct.length=u.id.clock+u.length-o.struct.id.clock;else{st(c,o.struct,o.offset);let p=u.id.clock-o.struct.id.clock-o.struct.length;o={struct:new q(g(h,o.struct.id.clock+o.struct.length),p),offset:0}}else{let p=o.struct.id.clock+o.struct.length-u.id.clock;if(p>0)if(o.struct.constructor===q)o.struct.length-=p;else u=Vc(u,p);if(!o.struct.mergeWith(u))st(c,o.struct,o.offset),o={struct:u,offset:0},l.next()}}else o={struct:l.curr,offset:0},l.next();for(let u=l.curr;u!==null&&u.id.client===h&&u.id.clock===o.struct.id.clock+o.struct.length&&u.constructor!==q;u=l.next())st(c,o.struct,o.offset),o={struct:u,offset:0}}if(o!==null)st(c,o.struct,o.offset),o=null;Tr(c);let a=r.map((l)=>wr(l)),f=dr(a);return Ft(i,f),i.toUint8Array()},Mc=(t,e,n=gt,r=it)=>{let s=eo(e),o=new r,i=new gn(o),c=new n(ut(t)),a=new pn(c,!1);while(a.curr){let l=a.curr,h=l.id.client,u=s.get(h)||0;if(a.curr.constructor===q){a.next();continue}if(l.id.clock+l.length>u){st(i,l,et(u-l.id.clock,0)),a.next();while(a.curr&&a.curr.id.client===h)st(i,a.curr,0),a.next()}else while(a.curr&&a.curr.id.client===h&&a.curr.id.clock+a.curr.length<=u)a.next()}Tr(i);let f=wr(c);return Ft(o,f),o.toUint8Array()};var go=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:H(t.encoder.restEncoder)}),t.encoder.restEncoder=Xt(),t.written=0},st=(t,e,n)=>{if(t.written>0&&t.currClient!==e.id.client)go(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),w(t.encoder.restEncoder,e.id.clock+n);e.write(t.encoder,n),t.written++},Tr=(t)=>{go(t);let e=t.encoder.restEncoder;w(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){let r=t.clientStructs[n];w(e,r.written),Qt(e,r.restEncoder)}},Fc=(t,e,n,r)=>{let s=new n(ut(t)),o=new pn(s,!1),i=new r,c=new gn(i);for(let f=o.curr;f!==null;f=o.next())st(c,e(f),0);Tr(c);let a=wr(s);return Ft(i,a),i.toUint8Array()};var $c=(t)=>Fc(t,ss,gt,$t),zs="You must not compute changes after the event-handler fired.";class ye{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=jc(this.currentTarget,this.target))}deletes(t){return we(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((r)=>{if(r!==null){let s=e._map.get(r),o,i;if(this.adds(s)){let c=s.left;while(c!==null&&this.adds(c))c=c.left;if(this.deletes(s))if(c!==null&&this.deletes(c))o="delete",i=_e(c.content.getContent());else return;else if(c!==null&&this.deletes(c))o="update",i=_e(c.content.getContent());else o="add",i=void 0}else if(this.deletes(s))o="delete",i=_e(s.content.getContent());else return;t.set(r,{action:o,oldValue:i})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw M(zs);let e=this.target,n=Y(),r=Y(),s=[];if(t={added:n,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(e).has(null)){let i=null,c=()=>{if(i)s.push(i)};for(let a=e._start;a!==null;a=a.right)if(a.deleted){if(this.deletes(a)&&!this.adds(a)){if(i===null||i.delete===void 0)c(),i={delete:0};i.delete+=a.length,r.add(a)}}else if(this.adds(a)){if(i===null||i.insert===void 0)c(),i={insert:[]};i.insert=i.insert.concat(a.content.getContent()),n.add(a)}else{if(i===null||i.retain===void 0)c(),i={retain:0};i.retain+=a.length}if(i!==null&&i.retain===void 0)c()}this._changes=t}return t}}var jc=(t,e)=>{let n=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;while(s!==e._item&&s!==null){if(!s.deleted&&s.countable)r+=s.length;s=s.right}n.unshift(r)}e=e._item.parent}return n},D=()=>{ur("Invalid access: Add Yjs type to a document before reading data.")},mo=80,Er=0;class xo{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=Er++}}var qc=(t)=>{t.timestamp=Er++},wo=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Er++},Gc=(t,e,n)=>{if(t.length>=mo){let r=t.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return wo(r,e,n),r}else{let r=new xo(e,n);return t.push(r),r}},mn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,i)=>ct(e-o.index)<ct(e-i.index)?o:i),r=t._start,s=0;if(n!==null)r=n.p,s=n.index,qc(n);while(r.right!==null&&s<e){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}while(r.left!==null&&s>e)if(r=r.left,!r.deleted&&r.countable)s-=r.length;while(r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock)if(r=r.left,!r.deleted&&r.countable)s-=r.length;if(n!==null&&ct(n.index-s)<r.parent.length/mo)return wo(n,r,s),n;else return Gc(t._searchMarker,r,s)},pe=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){let s=t[r];if(n>0){let o=s.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)s.index-=o.length;if(o===null||o.marker===!0){t.splice(r,1);continue}s.p=o,o.marker=!0}if(e<s.index||n>0&&e===s.index)s.index=et(e,s.index+n)}};var xn=(t,e,n)=>{let r=t,s=e.changedParentTypes;while(!0){if(P(s,t,()=>[]).push(n),t._item===null)break;t=t._item.parent}so(r._eH,n,e)};class T{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ms(),this._dEH=Ms(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw F()}clone(){throw F()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted)t=t.right;return t}_callObserver(t,e){if(!t.local&&this._searchMarker)this._searchMarker.length=0}observe(t){Fs(this._eH,t)}observeDeep(t){Fs(this._dEH,t)}unobserve(t){$s(this._eH,t)}unobserveDeep(t){$s(this._dEH,t)}toJSON(){}}var yo=(t,e,n)=>{if(t.doc??D(),e<0)e=t._length+e;if(n<0)n=t._length+n;let r=n-e,s=[],o=t._start;while(o!==null&&r>0){if(o.countable&&!o.deleted){let i=o.content.getContent();if(i.length<=e)e-=i.length;else{for(let c=e;c<i.length&&r>0;c++)s.push(i[c]),r--;e=0}}o=o.right}return s},bo=(t)=>{t.doc??D();let e=[],n=t._start;while(n!==null){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e};var ge=(t,e)=>{let n=0,r=t._start;t.doc??D();while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let o=0;o<s.length;o++)e(s[o],n++,t)}r=r.right}},Io=(t,e)=>{let n=[];return ge(t,(r,s)=>{n.push(e(r,s,t))}),n},Hc=(t)=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}let s=n[r++];if(n.length<=r)n=null;return{done:!1,value:s}}}},ko=(t,e)=>{t.doc??D();let n=mn(t,e),r=t._start;if(n!==null)r=n.p,e-=n.index;for(;r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},on=(t,e,n,r)=>{let s=n,o=t.doc,{clientID:i,store:c}=o,a=n===null?e._start:n.right,f=[],l=()=>{if(f.length>0)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new xt(f)),s.integrate(t,0),f=[]};r.forEach((h)=>{if(h===null)f.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(h);break;default:switch(l(),h.constructor){case Uint8Array:case ArrayBuffer:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new be(new Uint8Array(h))),s.integrate(t,0);break;case lc:s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Ie(h)),s.integrate(t,0);break;default:if(h instanceof T)s=new b(g(i,I(c,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Q(h)),s.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),l()},So=()=>M("Length exceeded!"),_o=(t,e,n,r)=>{if(n>e._length)throw So();if(n===0){if(e._searchMarker)pe(e._searchMarker,n,r.length);return on(t,e,null,r)}let s=n,o=mn(e,n),i=e._start;if(o!==null){if(i=o.p,n-=o.index,n===0)i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0}for(;i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){if(n<i.length)V(t,g(i.id.client,i.id.clock+n));break}n-=i.length}if(e._searchMarker)pe(e._searchMarker,s,r.length);return on(t,e,i,r)},Pc=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:e._start}).p;if(s)while(s.right)s=s.right;return on(t,e,s,n)},To=(t,e,n,r)=>{if(r===0)return;let s=n,o=r,i=mn(e,n),c=e._start;if(i!==null)c=i.p,n-=i.index;for(;c!==null&&n>0;c=c.right)if(!c.deleted&&c.countable){if(n<c.length)V(t,g(c.id.client,c.id.clock+n));n-=c.length}while(r>0&&c!==null){if(!c.deleted){if(r<c.length)V(t,g(c.id.client,c.id.clock+r));c.delete(t),r-=c.length}c=c.right}if(r>0)throw So();if(e._searchMarker)pe(e._searchMarker,s,-o+r)},cn=(t,e,n)=>{let r=e._map.get(n);if(r!==void 0)r.delete(t)},Br=(t,e,n,r)=>{let s=e._map.get(n)||null,o=t.doc,i=o.clientID,c;if(r==null)c=new xt([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new xt([r]);break;case Uint8Array:c=new be(r);break;case lc:c=new Ie(r);break;default:if(r instanceof T)c=new Q(r);else throw Error("Unexpected content type")}new b(g(i,I(o.store,i)),s,s&&s.lastId,null,null,e,n,c).integrate(t,0)},Ar=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Uo=(t)=>{let e={};return t.doc??D(),t._map.forEach((n,r)=>{if(!n.deleted)e[r]=n.content.getContent()[n.length-1]}),e},Eo=(t,e)=>{t.doc??D();let n=t._map.get(e);return n!==void 0&&!n.deleted};var zc=(t,e)=>{let n={};return t._map.forEach((r,s)=>{let o=r;while(o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0)))o=o.left;if(o!==null&&Rt(o,e))n[s]=o.content.getContent()[o.length-1]}),n},Ye=(t)=>(t.doc??D(),Ls(t._map.entries(),(e)=>!e[1].deleted));class Pg extends ye{}class Os extends T{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new Os;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Os}clone(){let t=new Os;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._length}_callObserver(t,e){super._callObserver(t,e),xn(this,t,new Pg(this,t))}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)y(this.doc,(e)=>{Pc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ko(this,t)}toArray(){return bo(this)}slice(t=0,e=this.length){return yo(this,t,e)}toJSON(){return this.map((t)=>t instanceof T?t.toJSON():t)}map(t){return Io(this,t)}forEach(t){ge(this,t)}[Symbol.iterator](){return Hc(this)}_write(t){t.writeTypeRef(pl)}}var Jc=(t)=>new Os;class Vy extends ye{constructor(t,e,n){super(t,e);this.keysChanged=n}}class Ur extends T{constructor(t){super();if(this._prelimContent=null,t===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((n,r)=>{this.set(r,n)}),this._prelimContent=null}_copy(){return new Ur}clone(){let t=new Ur;return this.forEach((e,n)=>{t.set(n,e instanceof T?e.clone():e)}),t}_callObserver(t,e){xn(this,t,new Vy(this,t,e))}toJSON(){this.doc??D();let t={};return this._map.forEach((e,n)=>{if(!e.deleted){let r=e.content.getContent()[e.length-1];t[n]=r instanceof T?r.toJSON():r}}),t}get size(){return[...Ye(this)].length}keys(){return Ze(Ye(this),(t)=>t[0])}values(){return Ze(Ye(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Ze(Ye(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??D(),this._map.forEach((e,n)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return Ar(this,t)}has(t){return Eo(this,t)}clear(){if(this.doc!==null)y(this.doc,(t)=>{this.forEach(function(e,n,r){cn(t,r,n)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(gl)}}var Kc=(t)=>new Ur,ot=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&Gn(t,e);class ln{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)jt(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Js=(t,e,n)=>{while(e.right!==null&&n>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)jt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));e.index+=e.right.length,n-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},tn=(t,e,n,r)=>{let s=new Map,o=r?mn(e,n):null;if(o){let i=new ln(o.p.left,o.p,o.index,s);return Js(t,i,n-o.index)}else{let i=new ln(null,e._start,0,s);return Js(t,i,n)}},Bo=(t,e,n,r)=>{while(n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===U&&ot(r.get(n.right.content.key),n.right.content.value))){if(!n.right.deleted)r.delete(n.right.content.key);n.forward()}let s=t.doc,o=s.clientID;r.forEach((i,c)=>{let{left:a,right:f}=n,l=new b(g(o,I(s.store,o)),a,a&&a.lastId,f,f&&f.id,e,null,new U(c,i));l.integrate(t,0),n.right=l,n.forward()})},jt=(t,e)=>{let{key:n,value:r}=e;if(r===null)t.delete(n);else t.set(n,r)},Ao=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&ot(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},Co=(t,e,n,r)=>{let s=t.doc,o=s.clientID,i=new Map;for(let c in r){let a=r[c],f=n.currentAttributes.get(c)??null;if(!ot(f,a)){i.set(c,f);let{left:l,right:h}=n;n.right=new b(g(o,I(s.store,o)),l,l&&l.lastId,h,h&&h.id,e,null,new U(c,a)),n.right.integrate(t,0),n.forward()}}return i},fr=(t,e,n,r,s)=>{n.currentAttributes.forEach((u,d)=>{if(s[d]===void 0)s[d]=null});let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s),a=r.constructor===String?new X(r):r instanceof T?new Q(r):new yt(r),{left:f,right:l,index:h}=n;if(e._searchMarker)pe(e._searchMarker,n.index,a.getLength());l=new b(g(i,I(o.store,i)),f,f&&f.lastId,l,l&&l.id,e,null,a),l.integrate(t,0),n.right=l,n.index=h,n.forward(),Bo(t,e,n,c)},Ks=(t,e,n,r,s)=>{let o=t.doc,i=o.clientID;Ao(n,s);let c=Co(t,e,n,s);t:while(n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===U))){if(!n.right.deleted)switch(n.right.content.constructor){case U:{let{key:a,value:f}=n.right.content,l=s[a];if(l!==void 0){if(ot(l,f))c.delete(a);else{if(r===0)break t;c.set(a,f)}n.right.delete(t)}else n.currentAttributes.set(a,f);break}default:if(r<n.right.length)V(t,g(n.right.id.client,n.right.id.clock+r));r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
4
|
+
`;n.right=new b(g(i,I(o.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new X(a)),n.right.integrate(t,0),n.forward()}Bo(t,e,n,c)},Do=(t,e,n,r,s)=>{let o=e,i=O();while(o&&(!o.countable||o.deleted)){if(!o.deleted&&o.content.constructor===U){let f=o.content;i.set(f.key,f)}o=o.right}let c=0,a=!1;while(e!==o){if(n===e)a=!0;if(!e.deleted){let f=e.content;switch(f.constructor){case U:{let{key:l,value:h}=f,u=r.get(l)??null;if(i.get(l)!==f||u===h){if(e.delete(t),c++,!a&&(s.get(l)??null)===h&&u!==h)if(u===null)s.delete(l);else s.set(l,u)}if(!a&&!e.deleted)jt(s,f);break}}}e=e.right}return c},Wc=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable))e=e.right;let n=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===U){let r=e.content.key;if(n.has(r))e.delete(t);else n.add(r)}e=e.left}},Zc=(t)=>{let e=0;return y(t.doc,(n)=>{let{_start:r,_start:s}=t,o=O(),i=Se(o);while(s){if(s.deleted===!1)switch(s.content.constructor){case U:jt(i,s.content);break;default:e+=Do(n,r,s,o,i),o=Se(i),r=s;break}s=s.right}}),e},Xc=(t)=>{let e=new Set,n=t.doc;for(let[r,s]of t.afterState.entries()){let o=t.beforeState.get(r)||0;if(s===o)continue;ho(t,n.store.clients.get(r),o,s,(i)=>{if(!i.deleted&&i.content.constructor===U&&i.constructor!==j)e.add(i.parent)})}y(n,(r)=>{Vt(t,t.deleteSet,(s)=>{if(s instanceof j||!s.parent._hasFormatting||e.has(s.parent))return;let o=s.parent;if(s.content.constructor===U)e.add(o);else Wc(r,s)});for(let s of e)Zc(s)})},Ws=(t,e,n)=>{let r=n,s=Se(e.currentAttributes),o=e.right;while(n>0&&e.right!==null){if(e.right.deleted===!1)switch(e.right.content.constructor){case Q:case yt:case X:if(n<e.right.length)V(t,g(e.right.id.client,e.right.id.clock+n));n-=e.right.length,e.right.delete(t);break}e.forward()}if(o)Do(t,o,e.right,s,e.currentAttributes);let i=(e.left||e.right).parent;if(i._searchMarker)pe(i._searchMarker,e.index,-r+n);return e};class Uy extends ye{constructor(t,e,n){super(t,e);this.childListChanged=!1,this.keysChanged=new Set,n.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.keysChanged.add(r)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,e=[];y(t,(n)=>{let r=new Map,s=new Map,o=this.target._start,i=null,c={},a="",f=0,l=0,h=()=>{if(i!==null){let u=null;switch(i){case"delete":if(l>0)u={delete:l};l=0;break;case"insert":if(typeof a==="object"||a.length>0){if(u={insert:a},r.size>0)u.attributes={},r.forEach((d,p)=>{if(d!==null)u.attributes[p]=d})}a="";break;case"retain":if(f>0){if(u={retain:f},!rs(c))u.attributes=es({},c)}f=0;break}if(u)e.push(u);i=null}};while(o!==null){switch(o.content.constructor){case Q:case yt:if(this.adds(o)){if(!this.deletes(o))h(),i="insert",a=o.content.getContent()[0],h()}else if(this.deletes(o)){if(i!=="delete")h(),i="delete";l+=1}else if(!o.deleted){if(i!=="retain")h(),i="retain";f+=1}break;case X:if(this.adds(o)){if(!this.deletes(o)){if(i!=="insert")h(),i="insert";a+=o.content.str}}else if(this.deletes(o)){if(i!=="delete")h(),i="delete";l+=o.length}else if(!o.deleted){if(i!=="retain")h(),i="retain";f+=o.length}break;case U:{let{key:u,value:d}=o.content;if(this.adds(o)){if(!this.deletes(o)){let p=r.get(u)??null;if(!ot(p,d)){if(i==="retain")h();if(ot(d,s.get(u)??null))delete c[u];else c[u]=d}else if(d!==null)o.delete(n)}}else if(this.deletes(o)){s.set(u,d);let p=r.get(u)??null;if(!ot(p,d)){if(i==="retain")h();c[u]=p}}else if(!o.deleted){s.set(u,d);let p=c[u];if(p!==void 0){if(!ot(p,d)){if(i==="retain")h();if(d===null)delete c[u];else c[u]=d}else if(p!==null)o.delete(n)}}if(!o.deleted){if(i==="insert")h();jt(r,o.content)}break}}o=o.right}h();while(e.length>0){let u=e[e.length-1];if(u.retain!==void 0&&u.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}}class as extends T{constructor(t){super();this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??D(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((n)=>n())}catch(n){console.error(n)}this._pending=null}_copy(){return new as}clone(){let t=new as;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);let n=new Uy(this,t,e);if(xn(this,t,n),!t.local&&this._hasFormatting)t._needFormattingCleanup=!0}toString(){this.doc??D();let t="",e=this._start;while(e!==null){if(!e.deleted&&e.countable&&e.content.constructor===X)t+=e.content.str;e=e.right}return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){if(this.doc!==null)y(this.doc,(n)=>{let r=new ln(null,this._start,0,new Map);for(let s=0;s<t.length;s++){let o=t[s];if(o.insert!==void 0){let i=!e&&typeof o.insert==="string"&&s===t.length-1&&r.right===null&&o.insert.slice(-1)===`
|
|
5
|
+
`?o.insert.slice(0,-1):o.insert;if(typeof i!=="string"||i.length>0)fr(n,this,r,i,o.attributes||{})}else if(o.retain!==void 0)Ks(n,this,r,o.retain,o.attributes||{});else if(o.delete!==void 0)Ws(n,r,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,n){this.doc??D();let r=[],s=new Map,o=this.doc,i="",c=this._start;function a(){if(i.length>0){let l={},h=!1;s.forEach((d,p)=>{h=!0,l[p]=d});let u={insert:i};if(h)u.attributes=l;r.push(u),i=""}}let f=()=>{while(c!==null){if(Rt(c,t)||e!==void 0&&Rt(c,e))switch(c.content.constructor){case X:{let l=s.get("ychange");if(t!==void 0&&!Rt(c,t)){if(l===void 0||l.user!==c.id.client||l.type!=="removed")a(),s.set("ychange",n?n("removed",c.id):{type:"removed"})}else if(e!==void 0&&!Rt(c,e)){if(l===void 0||l.user!==c.id.client||l.type!=="added")a(),s.set("ychange",n?n("added",c.id):{type:"added"})}else if(l!==void 0)a(),s.delete("ychange");i+=c.content.str;break}case Q:case yt:{a();let l={insert:c.content.getContent()[0]};if(s.size>0){let h={};l.attributes=h,s.forEach((u,d)=>{h[d]=u})}r.push(l);break}case U:if(Rt(c,t))a(),jt(s,c.content);break}c=c.right}a()};if(t||e)y(o,(l)=>{if(t)pr(l,t);if(e)pr(l,e);f()},"cleanup");else f();return r}insert(t,e,n){if(e.length<=0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);if(!n)n={},o.currentAttributes.forEach((i,c)=>{n[c]=i});fr(s,this,o,e,n)});else this._pending.push(()=>this.insert(t,e,n))}insertEmbed(t,e,n){let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!n);fr(s,this,o,e,n||{})});else this._pending.push(()=>this.insertEmbed(t,e,n||{}))}delete(t,e){if(e===0)return;let n=this.doc;if(n!==null)y(n,(r)=>{Ws(r,tn(r,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,n){if(e===0)return;let r=this.doc;if(r!==null)y(r,(s)=>{let o=tn(s,this,t,!1);if(o.right===null)return;Ks(s,this,o,e,n)});else this._pending.push(()=>this.format(t,e,n))}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return Ar(this,t)}getAttributes(){return Uo(this)}_write(t){t.writeTypeRef(ml)}}var Qc=(t)=>new as;class nn{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??D()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Mt||e.constructor===mt)&&e._start!==null)t=e._start;else while(t!==null){let n=t.next;if(n!==null){t=n;break}else if(t.parent===this._root)t=null;else t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));if(this._firstCall=!1,t===null)return{value:void 0,done:!0};return this._currentNode=t,{value:t.content.type,done:!1}}}class mt extends T{constructor(){super();this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new mt}clone(){let t=new mt;return t.insert(0,this.toArray().map((e)=>e instanceof T?e.clone():e)),t}get length(){return this.doc??D(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new nn(this,t)}querySelector(t){t=t.toUpperCase();let n=new nn(this,(r)=>r.nodeName&&r.nodeName.toUpperCase()===t).next();if(n.done)return null;else return n.value}querySelectorAll(t){return t=t.toUpperCase(),z(new nn(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){xn(this,t,new Oo(this,e,t))}toString(){return Io(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){let r=t.createDocumentFragment();if(n!==void 0)n._createAssociation(r,this);return ge(this,(s)=>{r.insertBefore(s.toDOM(t,e,n),null)}),r}insert(t,e){if(this.doc!==null)y(this.doc,(n)=>{_o(n,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)y(this.doc,(n)=>{let r=t&&t instanceof T?t._item:t;on(n,this,r,e)});else{let n=this._prelimContent,r=t===null?0:n.findIndex((s)=>s===t)+1;if(r===0&&t!==null)throw M("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){if(this.doc!==null)y(this.doc,(n)=>{To(n,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return bo(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ko(this,t)}slice(t=0,e=this.length){return yo(this,t,e)}forEach(t){ge(this,t)}_write(t){t.writeTypeRef(wl)}}var Yc=(t)=>new mt;class Mt extends mt{constructor(t="UNDEFINED"){super();this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((n,r)=>{this.setAttribute(r,n)}),this._prelimAttrs=null}_copy(){return new Mt(this.nodeName)}clone(){let t=new Mt(this.nodeName),e=this.getAttributes();return ns(e,(n,r)=>{t.setAttribute(r,n)}),t.insert(0,this.toArray().map((n)=>n instanceof T?n.clone():n)),t}toString(){let t=this.getAttributes(),e=[],n=[];for(let i in t)n.push(i);n.sort();let r=n.length;for(let i=0;i<r;i++){let c=n[i];e.push(c+'="'+t[c]+'"')}let s=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(t){if(this.doc!==null)y(this.doc,(e)=>{cn(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)y(this.doc,(n)=>{Br(n,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return Ar(this,t)}hasAttribute(t){return Eo(this,t)}getAttributes(t){return t?zc(this,t):Uo(this)}toDOM(t=document,e={},n){let r=t.createElement(this.nodeName),s=this.getAttributes();for(let o in s){let i=s[o];if(typeof i==="string")r.setAttribute(o,i)}if(ge(this,(o)=>{r.appendChild(o.toDOM(t,e,n))}),n!==void 0)n._createAssociation(r,this);return r}_write(t){t.writeTypeRef(xl),t.writeKey(this.nodeName)}}var tl=(t)=>new Mt(t.readKey());class Oo extends ye{constructor(t,e,n){super(t,n);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.attributesChanged.add(r)})}}class an extends Ur{constructor(t){super();this.hookName=t}_copy(){return new an(this.hookName)}clone(){let t=new an(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(t=document,e={},n){let r=e[this.hookName],s;if(r!==void 0)s=r.createDom(this);else s=document.createElement(this.hookName);if(s.setAttribute("data-yjs-hook",this.hookName),n!==void 0)n._createAssociation(s,this);return s}_write(t){t.writeTypeRef(yl),t.writeKey(this.hookName)}}var el=(t)=>new an(t.readKey());class hn extends as{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new hn}clone(){let t=new hn;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,n){let r=t.createTextNode(this.toString());if(n!==void 0)n._createAssociation(r,this);return r}toString(){return this.toDelta().map((t)=>{let e=[];for(let r in t.attributes){let s=[];for(let o in t.attributes[r])s.push({key:o,value:t.attributes[r][o]});s.sort((o,i)=>o.key<i.key?-1:1),e.push({nodeName:r,attrs:s})}e.sort((r,s)=>r.nodeName<s.nodeName?-1:1);let n="";for(let r=0;r<e.length;r++){let s=e[r];n+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){let i=s.attrs[o];n+=` ${i.key}="${i.value}"`}n+=">"}n+=t.insert;for(let r=e.length-1;r>=0;r--)n+=`</${e[r].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(bl)}}var nl=(t)=>new hn;class wn{constructor(t,e){this.id=t,this.length=e}get deleted(){throw F()}mergeWith(t){return!1}write(t,e,n){throw F()}integrate(t,e){throw F()}}var rl=0;class j extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){if(e>0)this.id.clock+=e,this.length-=e;ao(t.doc.store,this)}write(t,e){t.writeInfo(rl),t.writeLen(this.length-e)}getMissing(t,e){return null}}class be{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new be(this.content)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var sl=(t)=>new be(t.readBuf());class me{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new me(this.len)}splice(t){let e=new me(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){de(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}var ol=(t)=>new me(t.readLen()),No=(t,e)=>new lc({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ie{constructor(t){if(t._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=t;let e={};if(this.opts=e,!t.gc)e.gc=!1;if(t.autoLoad)e.autoLoad=!0;if(t.meta!==null)e.meta=t.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ie(No(this.doc.guid,this.opts))}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){if(this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad)t.subdocsLoaded.add(this.doc)}delete(t){if(t.subdocsAdded.has(this.doc))t.subdocsAdded.delete(this.doc);else t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}var il=(t)=>new Ie(No(t.readString(),t.readAny()));class yt{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new yt(this.embed)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var cl=(t)=>new yt(t.readJSON());class U{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new U(this.key,this.value)}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){let n=e.parent;n._searchMarker=null,n._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}var ll=(t)=>new U(t.readKey(),t.readJSON());class un{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new un(this.arr)}splice(t){let e=new un(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}var al=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++){let s=t.readString();if(s==="undefined")n.push(void 0);else n.push(JSON.parse(s))}return new un(n)},hl=ce("node_env")==="development";class xt{constructor(t){this.arr=t,hl&&Hn(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new xt(this.arr)}splice(t){let e=new xt(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){let s=this.arr[r];t.writeAny(s)}}getRef(){return 8}}var ul=(t)=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new xt(n)};class X{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new X(this.str)}splice(t){let e=new X(this.str.slice(t));this.str=this.str.slice(0,t);let n=this.str.charCodeAt(t-1);if(n>=55296&&n<=56319)this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1);return e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}var fl=(t)=>new X(t.readString()),dl=[Jc,Kc,Qc,tl,Yc,el,nl],pl=0,gl=1,ml=2,xl=3,wl=4,yl=5,bl=6;class Q{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Q(this.type._copy())}splice(t){throw F()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted)e.delete(t);else if(e.id.clock<(t.beforeState.get(e.id.client)||0))t._mergeStructs.push(e);e=e.right}this.type._map.forEach((n)=>{if(!n.deleted)n.delete(t);else if(n.id.clock<(t.beforeState.get(n.id.client)||0))t._mergeStructs.push(n)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((n)=>{while(n!==null)n.gc(t,!0),n=n.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Il=(t)=>new Q(dl[t.readTypeRef()](t)),mr=(t,e)=>{let n=e,r=0,s;do{if(r>0)n=g(n.client,n.clock+r);s=Lt(t,n),r=n.clock-s.id.clock,n=s.redone}while(n!==null&&s instanceof b);return{item:s,diff:r}},Cr=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},fn=(t,e,n)=>{let{client:r,clock:s}=e.id,o=new b(g(r,s+n),e,g(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=g(e.redone.client,e.redone.clock+n);if(e.right=o,o.right!==null)o.right.left=o;if(t._mergeStructs.push(o),o.parentSub!==null&&o.right===null)o.parent._map.set(o.parentSub,o);return e.length=n,o},Zs=(t,e)=>zt(t,(n)=>we(n.deletions,e)),vo=(t,e,n,r,s,o)=>{let i=t.doc,{store:c,clientID:a}=i,f=e.redone;if(f!==null)return V(t,f);let l=e.parent._item,h=null,u;if(l!==null&&l.deleted===!0){if(l.redone===null&&(!n.has(l)||vo(t,l,n,r,s,o)===null))return null;while(l.redone!==null)l=V(t,l.redone)}let d=l===null?e.parent:l.content.type;if(e.parentSub===null){h=e.left,u=e;while(h!==null){let k=h;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){h=k;break}h=h.left}while(u!==null){let k=u;while(k!==null&&k.parent._item!==l)k=k.redone===null?null:V(t,k.redone);if(k!==null&&k.parent._item===l){u=k;break}u=u.right}}else{if(u=null,e.right&&!s){h=e;while(h!==null&&h.right!==null&&(h.right.redone||we(r,h.right.id)||Zs(o.undoStack,h.right.id)||Zs(o.redoStack,h.right.id))){h=h.right;while(h.redone)h=V(t,h.redone)}if(h&&h.right!==null)return null}else h=d._map.get(e.parentSub)||null;if(h!==null&&h.parent._item!==l)h=d._map.get(e.parentSub)||null}let p=I(c,a),m=g(a,p),B=new b(m,h,h&&h.lastId,u,u&&u.id,d,e.parentSub,e.content.copy());return e.redone=m,Cr(B,!0),B.integrate(t,0),B};class b extends wn{constructor(t,e,n,r,s,o,i,c){super(t,c.getLength());this.origin=n,this.left=e,this.right=r,this.rightOrigin=s,this.parent=o,this.parentSub=i,this.redone=null,this.content=c,this.info=this.content.isCountable()?En:0}set marker(t){if((this.info&Ce)>0!==t)this.info^=Ce}get marker(){return(this.info&Ce)>0}get keep(){return(this.info&Un)>0}set keep(t){if(this.keep!==t)this.info^=Un}get countable(){return(this.info&En)>0}get deleted(){return(this.info&Ae)>0}set deleted(t){if(this.deleted!==t)this.info^=Ae}markDeleted(){this.info|=Ae}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=I(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=I(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===pt&&this.id.client!==this.parent.client&&this.parent.clock>=I(e,this.parent.client))return this.parent.client;if(this.origin)this.left=js(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=V(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===j||this.right&&this.right.constructor===j)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===b)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===b)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===pt){let n=Lt(e,this.parent);if(n.constructor===j)this.parent=null;else this.parent=n.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=js(t,t.doc.store,g(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,r;if(n!==null)r=n.right;else if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start;let s=new Set,o=new Set;while(r!==null&&r!==this.right){if(o.add(r),s.add(r),Xe(this.origin,r.origin)){if(r.id.client<this.id.client)n=r,s.clear();else if(Xe(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(Lt(t.doc.store,r.origin))){if(!s.has(Lt(t.doc.store,r.origin)))n=r,s.clear()}else break;r=r.right}this.left=n}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start,this.parent._start=this;this.right=n}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(t)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(ao(t.doc.store,this),this.content.integrate(t,this),Gs(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new j(this.id,this.length).integrate(t,0)}get next(){let t=this.right;while(t!==null&&t.deleted)t=t.right;return t}get prev(){let t=this.left;while(t!==null&&t.deleted)t=t.left;return t}get lastId(){return this.length===1?this.id:g(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Xe(t.origin,this.lastId)&&this.right===t&&Xe(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let e=this.parent._searchMarker;if(e)e.forEach((n)=>{if(n.p===t){if(n.p=this,!this.deleted&&this.countable)n.index-=this.length}});if(t.keep)this.keep=!0;if(this.right=t.right,this.right!==null)this.right.left=this;return this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;if(this.countable&&this.parentSub===null)e._length-=this.length;this.markDeleted(),de(t.deleteSet,this.id.client,this.id.clock,this.length),Gs(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)Oc(t,this,new j(this.id,this.length));else this.content=new me(this.length)}write(t,e){let n=e>0?g(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Wt|(n===null?0:A)|(r===null?0:G)|(s===null?0:bt);if(t.writeInfo(o),n!==null)t.writeLeftID(n);if(r!==null)t.writeRightID(r);if(n===null&&r===null){let i=this.parent;if(i._item!==void 0){let c=i._item;if(c===null){let a=oo(i);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(c.id)}else if(i.constructor===String)t.writeParentInfo(!0),t.writeString(i);else if(i.constructor===pt)t.writeParentInfo(!1),t.writeLeftID(i);else v();if(s!==null)t.writeString(s)}this.content.write(t,e)}}var Ro=(t,e)=>kl[e&Wt](t),kl=[()=>{v()},ol,al,sl,fl,cl,ll,Il,ul,il,()=>{v()}],Sl=10;class q extends wn{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){v()}write(t,e){t.writeInfo(Sl),w(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var Lo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Vo="__ $YJS$ __";if(Lo[Vo]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Lo[Vo]=!0;var Mo=Math.floor;var Fo=(t,e)=>t<e?t:e,$o=(t,e)=>t>e?t:e;var yn=128;var qt=127;var{MAX_SAFE_INTEGER:qo,MIN_SAFE_INTEGER:va}=Number;var{fromCharCode:Ul,fromCodePoint:Ra}=String,La=Ul(65535);var El=(t)=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},Ht=typeof TextEncoder<"u"?new TextEncoder:null,Bl=(t)=>Ht.encode(t),Go=Ht?Bl:El;var Gt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(Gt&&Gt.decode(new Uint8Array).length===1)Gt=null;class Po{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Sf=()=>new Po;var x_=(t)=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var Ef=(t)=>{let e=new Uint8Array(x_(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e};var bn=(t,e)=>{let n=t.cbuf.length;if(t.cpos===n)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0;t.cbuf[t.cpos++]=e};var rt=(t,e)=>{while(e>qt)bn(t,yn|qt&e),e=Mo(e/128);bn(t,qt&e)};var Dr=new Uint8Array(30000),Dl=Dr.length/3,Ol=(t,e)=>{if(e.length<Dl){let n=Ht.encodeInto(e,Dr).written||0;rt(t,n);for(let r=0;r<n;r++)bn(t,Dr[r])}else kn(t,Go(e))},Nl=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;rt(t,r);for(let s=0;s<r;s++)bn(t,n.codePointAt(s))},In=Ht&&Ht.encodeInto?Ol:Nl;var vl=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Fo(n-r,e.length),o=e.length-s;if(t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array($o(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o},kn=(t,e)=>{rt(t,e.byteLength),vl(t,e)};var ja=new DataView(new ArrayBuffer(4));var Or=(t)=>Error(t);var Jo=Or("Unexpected end of array"),Vl=Or("Integer out of Range"),Ml=(t,e,n)=>{if(e<0||n<0||e+n>t.length)throw Jo;return new Uint8Array(t.buffer,t.byteOffset+e,n)};class Ko{constructor(t){this.arr=t,this.pos=0}}var qy=(t)=>new Ko(t);var Fl=(t,e)=>{let n=Ml(t.arr,t.pos,e);return t.pos+=e,n},Sn=(t)=>Fl(t,ke(t));var zo=(t)=>t.arr[t.pos++];var ke=(t)=>{let e=0,n=1,r=t.arr.length;while(t.pos<r){let s=t.arr[t.pos++];if(e=e+(s&qt)*n,n*=128,s<yn)return e;if(e>qo)throw Vl}throw Jo};var $l=(t)=>{let e=ke(t);if(e===0)return"";else{let n=String.fromCodePoint(zo(t));if(--e<100)while(e--)n+=String.fromCodePoint(zo(t));else while(e>0){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},jl=(t)=>Gt.decode(Sn(t)),_n=Gt?jl:$l;var yS=0,wS=1,xS=2,_S=3;class Tf extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function __(t){let e=Sf();switch(t.type){case"doc-sync":{rt(e,yS),In(e,t.path),rt(e,t.epoch),kn(e,t.body);break}case"awareness":{rt(e,wS),kn(e,t.body);break}case"doc-close":{rt(e,xS),In(e,t.path);break}case"control":{rt(e,_S),In(e,JSON.stringify(t.message));break}default:throw new Tf(`unknown-frame:${t.type}`)}return Ef(e)}function C_(t){try{let e=qy(t),n=ke(e);switch(n){case yS:{let r=_n(e),s=ke(e);return{body:Sn(e),epoch:s,path:r,type:"doc-sync"}}case wS:return{body:Sn(e),type:"awareness"};case xS:return{path:_n(e),type:"doc-close"};case _S:{let r=JSON.parse(_n(e));if(typeof r!=="object"||typeof r.type!=="string")throw new Tf("malformed-control");return{message:r,type:"control"}}default:throw new Tf(`unknown-frame-type:${n}`)}}catch(e){if(e instanceof Tf)throw e;throw new Tf(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
|
|
6
|
+
export{lc,gS,bS,vS,Wy,kf,XR,Pg,Os,Vy,Ur,Uy,as,Sf,x_,Ef,qy,yS,wS,xS,_S,Tf,__,C_};
|
|
7
7
|
|
|
8
|
-
//# debugId=
|
|
9
|
-
//# sourceMappingURL=studio-
|
|
8
|
+
//# debugId=C8A932CB0923CE9D64756E2164756E21
|
|
9
|
+
//# sourceMappingURL=studio-q4tv82h7.js.map
|