@inkeep/open-knowledge 0.26.0-beta.3 → 0.26.0-beta.4

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.
Files changed (71) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +1 -1
  3. package/dist/cli.mjs +6 -6
  4. package/dist/constants-CLOl-YPp.mjs +2 -0
  5. package/dist/index.mjs +1 -1
  6. package/dist/{init-Dfv_79XQ.mjs → init-BRM4D3aN.mjs} +3 -3
  7. package/dist/init-BmxZyzqX.mjs +1 -0
  8. package/dist/loader-5jGFIbzM.mjs +1 -0
  9. package/dist/{loader-CsHEMUCb.mjs → loader-CeUTJnBT.mjs} +2 -2
  10. package/dist/{preview-gGYGk2wA.mjs → preview-CNakf9xz.mjs} +2 -2
  11. package/dist/preview-YlanDsYQ.mjs +1 -0
  12. package/dist/public/assets/{ActivityModeContent-Dh9ZRSoQ.js → ActivityModeContent-DXYPqOq4.js} +1 -1
  13. package/dist/public/assets/{ConsentDialogBody-Bza0TMPd.js → ConsentDialogBody-CJbrNbjF.js} +1 -1
  14. package/dist/public/assets/DocumentContext-CVfa457X.js +36 -0
  15. package/dist/public/assets/{EnableSyncConfirmDialog-C9ftvg6E.js → EnableSyncConfirmDialog-Bp6Kd2LQ.js} +1 -1
  16. package/dist/public/assets/{GraphPanel-BtsCCmfa.js → GraphPanel-BOJfbkTJ.js} +2 -2
  17. package/dist/public/assets/{ManagedArtifactProperties-lwut8ycK.js → ManagedArtifactProperties-DXnRZrvY.js} +1 -1
  18. package/dist/public/assets/McpConsentDialogBody-B0SbotVo.js +1 -0
  19. package/dist/public/assets/{PropertyPanel-D60ytpLJ.js → PropertyPanel-IVYdT8kB.js} +1 -1
  20. package/dist/public/assets/{SettingsDialogBody-BEB9E4L8.js → SettingsDialogBody-C3klTl8y.js} +2 -2
  21. package/dist/public/assets/{ShareBranchSwitchDialog-wS9K-tig.js → ShareBranchSwitchDialog-C19Tz0FD.js} +1 -1
  22. package/dist/public/assets/{ShareReceiveDialog-Dj9jDr9i.js → ShareReceiveDialog-dqLPJobK.js} +1 -1
  23. package/dist/public/assets/{ShareReceiveMissDialog-Dl8ubE0W.js → ShareReceiveMissDialog-BmK1FcKl.js} +1 -1
  24. package/dist/public/assets/{SkillEditorActions-_MpJ084l.js → SkillEditorActions-DrxXwSQZ.js} +1 -1
  25. package/dist/public/assets/{SourceEditor-C0bMqVnT.js → SourceEditor-C69C5VbZ.js} +2 -2
  26. package/dist/public/assets/{TerminalPanel-CWbsUOWf.js → TerminalPanel-F9VxCkzR.js} +3 -3
  27. package/dist/public/assets/{auth-state-cache-D1Zf_XZx.js → auth-state-cache-ceG_ksVa.js} +4 -4
  28. package/dist/public/assets/{checkbox-P04sbGVQ.js → checkbox-f-bVZCIm.js} +1 -1
  29. package/dist/public/assets/config-provider-BCfJ49jt.js +4 -0
  30. package/dist/public/assets/dist-BEjpPm3y.js +1 -0
  31. package/dist/public/assets/{dist-DQdOYnjt.js → dist-Bp_rHida.js} +1 -1
  32. package/dist/public/assets/{dist-CcPVYMcT.js → dist-COgUpCH8.js} +125 -125
  33. package/dist/public/assets/dist-C_vWk3jN.js +1 -0
  34. package/dist/public/assets/{doc-hash-BN71TGv_.js → doc-hash-D4PHQioS.js} +1 -1
  35. package/dist/public/assets/{documents-events-DpvvMnqc.js → documents-events-CC0YYok8.js} +1 -1
  36. package/dist/public/assets/{file-tree-adapter-D0zxekvZ.js → file-tree-adapter-kyG62qi4.js} +1 -1
  37. package/dist/public/assets/{index-DxjAwDPu.js → index-B7eqx3hL.js} +10 -10
  38. package/dist/public/assets/index-ufsO3NHc.css +1 -0
  39. package/dist/public/assets/{keyboard-shortcuts-BlefnxS9.js → keyboard-shortcuts-BvDMvGCY.js} +1 -1
  40. package/dist/public/assets/{open-managed-artifact-tab-D3BcVUm2.js → open-managed-artifact-tab--yPNMSsq.js} +1 -1
  41. package/dist/public/assets/{pending-receive-nav-store-Dof2gLIy.js → pending-receive-nav-store-DHcSK_qb.js} +1 -1
  42. package/dist/public/assets/{project-paths-Dvd83Cnz.js → project-paths-cuCZTJ3P.js} +1 -1
  43. package/dist/public/assets/{prop-types-Dw7AI8Ws.js → prop-types-t38xDaSJ.js} +1 -1
  44. package/dist/public/assets/{radio-group-1_2tsQbc.js → radio-group-G2GVDZug.js} +1 -1
  45. package/dist/public/assets/{receive-store-Chr-F8g-.js → receive-store-D19RejeY.js} +1 -1
  46. package/dist/public/assets/{selection-context-CQ-aBMVN.js → selection-context-DbKYyKpW.js} +1 -1
  47. package/dist/public/assets/{skill-actions-LWoE96gI.js → skill-actions-ClI_nW9-.js} +1 -1
  48. package/dist/public/assets/skills-api-iQOrzhIN.js +1 -0
  49. package/dist/public/assets/{target-navigation-intent-Cr9Afdw3.js → target-navigation-intent-DGRIAiM0.js} +1 -1
  50. package/dist/public/assets/{toggle-group-IN7Np0Is.js → toggle-group-ChBgoXkr.js} +1 -1
  51. package/dist/public/assets/{tooltip-C9Dd0rIc.js → tooltip-C-qXynAd.js} +1 -1
  52. package/dist/public/assets/{typing-burst-detector-CNef6al6.js → typing-burst-detector-B8USnmhk.js} +2 -2
  53. package/dist/public/index.html +29 -29
  54. package/dist/{repair-launch-json-Dt-nN_hi.mjs → repair-launch-json-DS8B8XJT.mjs} +2 -2
  55. package/dist/{repair-mcp-configs-Bql_mi5y.mjs → repair-mcp-configs-DeDm8DcU.mjs} +2 -2
  56. package/dist/{src-CWrclvo9.mjs → src-lhsbbOZY.mjs} +2 -2
  57. package/dist/start-CgJl4R-h.mjs +1 -0
  58. package/dist/{start-C08bcOdE.mjs → start-Dy9qpF1P.mjs} +2 -2
  59. package/package.json +1 -1
  60. package/dist/constants-C9SjgIv3.mjs +0 -2
  61. package/dist/init-Ctw_2Azf.mjs +0 -1
  62. package/dist/loader-doLu8-rF.mjs +0 -1
  63. package/dist/preview-BIQkZ80l.mjs +0 -1
  64. package/dist/public/assets/DocumentContext-MXbwQp5D.js +0 -36
  65. package/dist/public/assets/McpConsentDialogBody-DXwlUNR4.js +0 -1
  66. package/dist/public/assets/config-provider-Czfn62dp.js +0 -4
  67. package/dist/public/assets/dist-C0qRhuIN.js +0 -1
  68. package/dist/public/assets/dist-DfThKWJX.js +0 -1
  69. package/dist/public/assets/index-BBDK8MxG.css +0 -1
  70. package/dist/public/assets/skills-api-4lPs2YSK.js +0 -1
  71. package/dist/start-DYazQJIU.mjs +0 -1
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{n as i,r as a}from"./dist-CQw2y-s3.js";import{t as o}from"./button-cneJOVxD.js";import{n as s}from"./dist-IEs1iCqd.js";import{a as c,c as l,i as u,n as ee,o as te,s as ne,t as re}from"./dialog-BiB39Lhy.js";import{t as d}from"./checkbox-P04sbGVQ.js";import{t as f}from"./label-hTzLGQhh.js";import{n as p}from"./mcp-consent-store-Bx7YkTj-.js";var ie=r(),m=e(t(),1),h=n();function ae(e){return e.shellDetected&&!e.alreadyInstalled}function oe(e){let t=new Set;for(let n of e)n.detected&&t.add(n.id);return t}function se(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function ce(e,t){let n=[];for(let r of t)e.has(r.id)&&n.push(r.id);return n}function le(e){return new Set(e.map(e=>e.id))}function ue(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function de(e,t){return t.filter(t=>e.has(t.id)).map(e=>e.id)}var g={error:e=>s.error(e)};function _(e){let t=(0,ie.c)(9),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{store:r,toast:i,payload:a}=n,o=r===void 0?p:r,s=i===void 0?g:i,c;t[2]!==a||t[3]!==o?(c=a??o.getSnapshot(),t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=c;if(!l)return null;let u;return t[5]!==l||t[6]!==o||t[7]!==s?(u=(0,h.jsx)(v,{payload:l,store:o,toast:s}),t[5]=l,t[6]=o,t[7]=s,t[8]=u):u=t[8],u}function v(e){let t=(0,ie.c)(82),{payload:n,store:r,toast:s}=e,{_:p}=a(),g=n.detectedEditors,_=n.pathInstall,v=n.globalSkills,y=v.length>0,b;t[0]===_?b=t[1]:(b=ae(_),t[0]=_,t[1]=b);let x=b,S;t[2]===g?S=t[3]:(S=()=>oe(g),t[2]=g,t[3]=S);let[C,pe]=(0,m.useState)(S),[w,me]=(0,m.useState)(!0),T;t[4]===v?T=t[5]:(T=()=>le(v),t[4]=v,t[5]=T);let[E,he]=(0,m.useState)(T),[D,O]=(0,m.useState)(!1),k=(0,m.useId)(),A;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(e){pe(t=>se(t,e))},t[6]=A):A=t[6];let ge=A,j;t[7]!==g||t[8]!==v||t[9]!==x||t[10]!==w||t[11]!==C||t[12]!==E||t[13]!==y||t[14]!==r||t[15]!==s?(j=async function(){O(!0);let e=await r.confirm({editorIds:ce(C,g),pathInstall:x?w:void 0,skills:y?de(E,v):void 0});e.ok||(s.error(e.error),O(!1))},t[7]=g,t[8]=v,t[9]=x,t[10]=w,t[11]=C,t[12]=E,t[13]=y,t[14]=r,t[15]=s,t[16]=j):j=t[16];let _e=j,M;t[17]!==r||t[18]!==s?(M=async function(){O(!0);let e=await r.skip();e.ok||(s.error(e.error),O(!1))},t[17]=r,t[18]=s,t[19]=M):M=t[19];let N=M,P;t[20]!==D||t[21]!==N?(P=function(e){!e&&!D&&N()},t[20]=D,t[21]=N,t[22]=P):P=t[22];let F=P,I;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,h.jsx)(l,{children:(0,h.jsx)(i,{id:`vM7XUh`})}),t[23]=I):I=t[23];let L;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,h.jsxs)(ne,{children:[I,(0,h.jsx)(c,{children:(0,h.jsx)(i,{id:`YGQm6y`,components:{0:(0,h.jsx)(`code`,{}),1:(0,h.jsx)(`code`,{}),2:(0,h.jsx)(`code`,{}),3:(0,h.jsx)(`code`,{})}})})]}),t[24]=L):L=t[24];let R;t[25]!==p||t[26]!==D||t[27]!==k||t[28]!==x||t[29]!==w||t[30]!==_.rcFilesToTouch||t[31]!==_.shellDetected?(R=_.shellDetected&&(0,h.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,h.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:(0,h.jsx)(i,{id:`ALhMYW`})}),(0,h.jsx)(`div`,{className:`overflow-hidden rounded-md border border-border bg-card/50`,children:(0,h.jsxs)(f,{htmlFor:`${k}-path`,className:x?`flex cursor-pointer items-start gap-2.5 px-3 py-2.5 font-normal hover:bg-accent`:`flex items-start gap-2.5 px-3 py-2.5 font-normal`,children:[(0,h.jsx)(d,{id:`${k}-path`,checked:x?w:!0,disabled:D||!x,onCheckedChange:()=>me(fe),className:`mt-0.5`,"data-testid":`mcp-consent-path-checkbox`}),(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,h.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:(0,h.jsx)(i,{id:`Fsx78O`,components:{0:(0,h.jsx)(`code`,{})}})}),(0,h.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`mcp-consent-path-status`,children:p(x?{id:`04XyCH`,values:{0:_.rcFilesToTouch.join(`, `)}}:{id:`RnrnTe`})}),x&&!w&&(0,h.jsx)(`span`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`mcp-consent-path-warning`,children:(0,h.jsx)(i,{id:`7PXYaF`,components:{0:(0,h.jsx)(`code`,{})}})})]})]})})]}),t[25]=p,t[26]=D,t[27]=k,t[28]=x,t[29]=w,t[30]=_.rcFilesToTouch,t[31]=_.shellDetected,t[32]=R):R=t[32];let z;t[33]===_.shellDetected?z=t[34]:(z=_.shellDetected&&(0,h.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:(0,h.jsx)(i,{id:`crqzW5`})}),t[33]=_.shellDetected,t[34]=z);let B;if(t[35]!==p||t[36]!==D||t[37]!==g||t[38]!==k||t[39]!==C){let e;t[41]!==p||t[42]!==D||t[43]!==k||t[44]!==C?(e=e=>{let t=C.has(e.id),n=`${k}-${e.id}`,r=e.willReplace?p({id:`TEEPPF`}):e.detected?p({id:`bBE5tC`}):p({id:`yu8Pzy`}),i=e.willReplace?`text-xs text-amber-600 dark:text-amber-400`:`text-xs text-muted-foreground`;return(0,h.jsx)(`li`,{children:(0,h.jsxs)(f,{htmlFor:n,className:`flex cursor-pointer items-start gap-2.5 px-3 py-2.5 font-normal hover:bg-accent`,children:[(0,h.jsx)(d,{id:n,checked:t,disabled:D,onCheckedChange:()=>ge(e.id),className:`mt-0.5`,"data-testid":`mcp-consent-checkbox-${e.id}`}),(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,h.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.label}),(0,h.jsx)(`span`,{className:i,"data-testid":`mcp-consent-status-${e.id}`,children:r})]})]})},e.id)},t[41]=p,t[42]=D,t[43]=k,t[44]=C,t[45]=e):e=t[45],B=g.map(e),t[35]=p,t[36]=D,t[37]=g,t[38]=k,t[39]=C,t[40]=B}else B=t[40];let V;t[46]===B?V=t[47]:(V=(0,h.jsx)(`ul`,{className:`rounded-md border border-border bg-card/50 divide-y divide-border overflow-hidden`,children:B}),t[46]=B,t[47]=V);let H;t[48]!==z||t[49]!==V?(H=(0,h.jsxs)(ee,{children:[z,V]}),t[48]=z,t[49]=V,t[50]=H):H=t[50];let U;t[51]!==D||t[52]!==v||t[53]!==k||t[54]!==E||t[55]!==y?(U=y&&(0,h.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,h.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:(0,h.jsx)(i,{id:`28B21t`})}),(0,h.jsx)(`ul`,{className:`rounded-md border border-border bg-card/50 divide-y divide-border overflow-hidden`,children:v.map(e=>{let t=E.has(e.id),n=`${k}-skill-${e.id}`;return(0,h.jsx)(`li`,{children:(0,h.jsxs)(f,{htmlFor:n,className:`flex cursor-pointer items-start gap-2.5 px-3 py-2.5 font-normal hover:bg-accent`,children:[(0,h.jsx)(d,{id:n,checked:t,disabled:D,onCheckedChange:()=>he(t=>ue(t,e.id)),className:`mt-0.5`,"data-testid":`mcp-consent-skill-checkbox-${e.id}`}),(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,h.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:(0,h.jsx)(`code`,{children:e.name})}),(0,h.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`mcp-consent-skill-status-${e.id}`,children:e.id===`discovery`?(0,h.jsx)(i,{id:`0inVGS`}):(0,h.jsx)(i,{id:`FXk_zY`})}),e.alreadyInstalled&&!t&&(0,h.jsx)(`span`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`mcp-consent-skill-warning-${e.id}`,children:(0,h.jsx)(i,{id:`dXWMFn`})})]})]})},e.id)})})]}),t[51]=D,t[52]=v,t[53]=k,t[54]=E,t[55]=y,t[56]=U):U=t[56];let W;t[57]===N?W=t[58]:(W=()=>void N(),t[57]=N,t[58]=W);let G;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,h.jsx)(i,{id:`6Uau97`}),t[59]=G):G=t[59];let K;t[60]!==D||t[61]!==W?(K=(0,h.jsx)(o,{variant:`outline`,className:`font-mono uppercase`,onClick:W,disabled:D,"data-testid":`mcp-consent-skip`,children:G}),t[60]=D,t[61]=W,t[62]=K):K=t[62];let q;t[63]===_e?q=t[64]:(q=()=>void _e(),t[63]=_e,t[64]=q);let J=D||C.size===0&&!(x&&w)&&!y,Y;t[65]===D?Y=t[66]:(Y=D?(0,h.jsx)(i,{id:`b4itZn`}):(0,h.jsx)(i,{id:`m16xKo`}),t[65]=D,t[66]=Y);let X;t[67]!==q||t[68]!==J||t[69]!==Y?(X=(0,h.jsx)(o,{onClick:q,disabled:J,"data-testid":`mcp-consent-add`,children:Y}),t[67]=q,t[68]=J,t[69]=Y,t[70]=X):X=t[70];let Z;t[71]!==K||t[72]!==X?(Z=(0,h.jsxs)(te,{children:[K,X]}),t[71]=K,t[72]=X,t[73]=Z):Z=t[73];let Q;t[74]!==R||t[75]!==H||t[76]!==U||t[77]!==Z?(Q=(0,h.jsxs)(u,{className:`sm:max-w-md`,children:[L,R,H,U,Z]}),t[74]=R,t[75]=H,t[76]=U,t[77]=Z,t[78]=Q):Q=t[78];let $;return t[79]!==F||t[80]!==Q?($=(0,h.jsx)(re,{open:!0,onOpenChange:F,children:Q}),t[79]=F,t[80]=Q,t[81]=$):$=t[81],$}function fe(e){return!e}export{_ as McpConsentDialogBody,_ as default,oe as computeInitialSelection,le as computeInitialSkillSelection,ae as isPathRowActionable,ce as selectedIdsOrdered,de as skillIdsOrdered,se as toggleSelectedId,ue as toggleSkillId};
@@ -1,4 +0,0 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{n as i}from"./dist-BVOt51sU.js";import{It as a,Jt as o,Pt as s,_ as c,er as l,g as u,h as d,m as f,qt as p}from"./dist-CcPVYMcT.js";import{u as ee}from"./button-cneJOVxD.js";import{t as te}from"./config-context-CVpOcWSZ.js";var ne=ee(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),re=r(),m=e(t(),1),ie=null,ae=new Set;function oe(){return ie}function se(e){let t=e!==null&&e.length>0?e:null;if(t!==ie){ie=t;for(let e of ae)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function ce(e){return ae.add(e),()=>{ae.delete(e)}}function le(){return(0,m.useSyncExternalStore)(ce,oe,oe)}var h=()=>new Map,ue=e=>{let t=h();return e.forEach((e,n)=>{t.set(n,e)}),t},g=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},de=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},fe=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},_=()=>new Set,pe=e=>e[e.length-1],me=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},v=Array.from,he=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},ge=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},_e=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},y=Array.isArray,ve=class{constructor(){this._observers=h()}on(e,t){return g(this._observers,e,_).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return v((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},ye=class{constructor(){this._observers=h()}on(e,t){g(this._observers,e,_).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return v((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},b=Math.floor,be=Math.abs,xe=(e,t)=>e<t?e:t,x=(e,t)=>e>t?e:t;Number.isNaN;var Se=e=>e===0?1/e<0:e<0,Ce=1<<17,we=1<<18,Te=1<<19,Ee=1<<20,De=1<<21,Oe=1<<22,ke=1<<23,Ae=1<<24,je=1<<25,Me=1<<26,Ne=1<<27,Pe=1<<28,Fe=1<<29;Ce-1,we-1,Te-1,Ee-1,De-1,Oe-1,ke-1,Ae-1,je-1,Me-1,Ne-1,Pe-1,Fe-1;var Ie=2**53-1,Le=-(2**53-1),Re=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&b(e)===e);Number.isNaN,Number.parseInt;var ze=String.fromCharCode;String.fromCodePoint,ze(65535);var Be=e=>e.toLowerCase(),Ve=/^\s*/g,He=e=>e.replace(Ve,``),Ue=/([A-Z])/g,We=(e,t)=>He(e.replace(Ue,e=>`${t}${Be(e)}`)),Ge=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Ke=typeof TextEncoder<`u`?new TextEncoder:null,qe=Ke?e=>Ke.encode(e):Ge,Je=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Je&&Je.decode(new Uint8Array).length===1&&(Je=null);var Ye=(e,t)=>_e(t,()=>e).join(``),Xe=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Ze=()=>new Xe,Qe=e=>{let t=Ze();return e(t),S(t)},$e=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},S=e=>{let t=new Uint8Array($e(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},et=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(x(n,t)*2),e.cpos=0)},C=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},tt=C,w=(e,t)=>{for(;t>127;)C(e,128|127&t),t=b(t/128);C(e,127&t)},nt=(e,t)=>{let n=Se(t);for(n&&(t=-t),C(e,(t>63?128:0)|(n?64:0)|63&t),t=b(t/64);t>0;)C(e,(t>127?128:0)|127&t),t=b(t/128)},rt=new Uint8Array(3e4),it=rt.length/3,at=Ke&&Ke.encodeInto?(e,t)=>{if(t.length<it){let n=Ke.encodeInto(t,rt).written||0;w(e,n);for(let t=0;t<n;t++)C(e,rt[t])}else T(e,qe(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;w(e,r);for(let t=0;t<r;t++)C(e,n.codePointAt(t))},ot=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=xe(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(x(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},T=(e,t)=>{w(e,t.byteLength),ot(e,t)},st=(e,t)=>{et(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ct=(e,t)=>st(e,4).setFloat32(0,t,!1),lt=(e,t)=>st(e,8).setFloat64(0,t,!1),ut=(e,t)=>st(e,8).setBigInt64(0,t,!1),dt=new DataView(new ArrayBuffer(4)),ft=e=>(dt.setFloat32(0,e),dt.getFloat32(0)===e),pt=(e,t)=>{switch(typeof t){case`string`:C(e,119),at(e,t);break;case`number`:Re(t)&&be(t)<=2147483647?(C(e,125),nt(e,t)):ft(t)?(C(e,124),ct(e,t)):(C(e,123),lt(e,t));break;case`bigint`:C(e,122),ut(e,t);break;case`object`:if(t===null)C(e,126);else if(y(t)){C(e,117),w(e,t.length);for(let n=0;n<t.length;n++)pt(e,t[n])}else if(t instanceof Uint8Array)C(e,116),T(e,t);else{C(e,118);let n=Object.keys(t);w(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];at(e,i),pt(e,t[i])}}break;case`boolean`:C(e,t?120:121);break;default:C(e,127)}},mt=class extends Xe{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&w(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},ht=e=>{e.count>0&&(nt(e.encoder,e.count===1?e.s:-e.s),e.count>1&&w(e.encoder,e.count-2))},gt=class{constructor(){this.encoder=new Xe,this.s=0,this.count=0}write(e){this.s===e?this.count++:(ht(this),this.count=1,this.s=e)}toUint8Array(){return ht(this),S(this.encoder)}},_t=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);nt(e.encoder,t),e.count>1&&w(e.encoder,e.count-2)}},vt=class{constructor(){this.encoder=new Xe,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(_t(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return _t(this),S(this.encoder)}},yt=class{constructor(){this.sarr=[],this.s=``,this.lensE=new gt}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Xe;return this.sarr.push(this.s),this.s=``,at(e,this.sarr.join(``)),ot(e,this.lensE.toUint8Array()),S(e)}},E=e=>Error(e),D=()=>{throw E(`Method unimplemented`)},O=()=>{throw E(`Unexpected case`)},bt=E(`Unexpected end of array`),xt=E(`Integer out of Range`),St=class{constructor(e){this.arr=e,this.pos=0}},Ct=e=>new St(e),wt=e=>e.pos!==e.arr.length,Tt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},k=e=>Tt(e,A(e)),Et=e=>e.arr[e.pos++],A=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Ie)throw xt}throw bt},Dt=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Ie)throw xt}throw bt},Ot=Je?e=>Je.decode(k(e)):e=>{let t=A(e);if(t===0)return``;{let n=String.fromCodePoint(Et(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Et(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},kt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},At=[e=>void 0,e=>null,Dt,e=>kt(e,4).getFloat32(0,!1),e=>kt(e,8).getFloat64(0,!1),e=>kt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Ot,e=>{let t=A(e),n={};for(let r=0;r<t;r++){let t=Ot(e);n[t]=jt(e)}return n},e=>{let t=A(e),n=[];for(let r=0;r<t;r++)n.push(jt(e));return n},k],jt=e=>At[127-Et(e)](e),Mt=class extends St{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),wt(this)?this.count=A(this)+1:this.count=-1),this.count--,this.s}},Nt=class extends St{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Dt(this);let e=Se(this.s);this.count=1,e&&(this.s=-this.s,this.count=A(this)+2)}return this.count--,this.s}},Pt=class extends St{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Dt(this),t=e&1;this.diff=b(e/2),this.count=1,t&&(this.count=A(this)+2)}return this.s+=this.diff,this.count--,this.s}},Ft=class{constructor(e){this.decoder=new Nt(e),this.str=Ot(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var It=crypto.getRandomValues.bind(crypto),Lt=Math.random,Rt=()=>It(new Uint32Array(1))[0],zt=e=>e[b(Lt()*e.length)],Bt=`10000000-1000-4000-8000-100000000000`,Vt=()=>Bt.replace(/[018]/g,e=>(e^Rt()&15>>e/4).toString(16)),Ht=Date.now,Ut=e=>new Promise(e);Promise.all.bind(Promise);var Wt=e=>e===void 0?null:e,Gt=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(Gt=localStorage)}catch{}var Kt=Gt,qt=Symbol(`Equality`),Jt=(e,t)=>e===t||!!e?.[qt]?.(t)||!1,Yt=e=>typeof e==`object`,Xt=Object.assign,Zt=Object.keys,Qt=(e,t)=>{for(let n in e)t(e[n],n)},$t=e=>Zt(e).length,en=e=>{for(let t in e)return!1;return!0},tn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},nn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),rn=(e,t)=>e===t||$t(e)===$t(t)&&tn(e,(e,n)=>(e!==void 0||nn(t,n))&&Jt(t[n],e)),an=Object.freeze,on=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&on(e[t])}return an(e)},sn=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&sn(e,t,n+1)}},cn=e=>e,ln=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[qt]!=null)return e[qt](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!ln(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if($t(e)!==$t(t))return!1;for(let n in e)if(!nn(e,n)||!ln(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!ln(e[n],t[n]))return!1;break;default:return!1}return!0},un=(e,t)=>t.includes(e),dn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,fn=typeof window<`u`&&typeof document<`u`&&!dn;typeof navigator<`u`&&/Mac/.test(navigator.platform);var j,pn=[],mn=()=>{if(j===void 0)if(dn){j=h();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&j.set(t,``),t=r):t===null?pn.push(r):(j.set(t,r),t=null)}t!==null&&j.set(t,``)}else typeof location==`object`?(j=h(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);j.set(`--${We(t,`-`)}`,n),j.set(`-${We(t,`-`)}`,n)}})):j=h();return j},hn=e=>mn().has(e),gn=e=>Wt(dn?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Kt.getItem(e)),_n=e=>hn(`--`+e)||gn(e)!==null,vn=_n(`production`),yn=dn&&un({}.FORCE_COLOR,[`true`,`1`,`2`])||!hn(`--no-colors`)&&!_n(`no-color`)&&(!dn||process.stdout.isTTY)&&(!dn||hn(`--color`)||gn(`COLORTERM`)!==null||(gn(`TERM`)||``).includes(`color`)),bn=e=>new Uint8Array(e),xn=fn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=ze(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Sn=e=>{let t=bn(e.byteLength);return t.set(e),t},Cn=e=>Qe(t=>pt(t,e)),wn=class{constructor(e,t){this.left=e,this.right=t}},M=(e,t)=>new wn(e,t),Tn=(e,t)=>e.forEach(e=>t(e.left,e.right)),En=e=>e.next()>=.5,Dn=(e,t,n)=>b(e.next()*(n+1-t)+t),On=(e,t,n)=>b(e.next()*(n+1-t)+t),kn=(e,t,n)=>On(e,t,n),An=e=>ze(kn(e,97,122)),jn=(e,t=0,n=20)=>{let r=kn(e,t,n),i=``;for(let t=0;t<r;t++)i+=An(e);return i},Mn=(e,t)=>t[kn(e,0,t.length-1)],Nn=Symbol(`0schema`),Pn=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Ye(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
2
- `)}},Fn=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[qt]?Jt(e,t):y(e)?he(e,e=>ge(t,t=>Fn(e,t))):Yt(e)?tn(e,(e,n)=>Fn(e,t[n])):!1,N=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Fn(t,n)}equals(e){return this.constructor===e.constructor&&ln(this.shape,e.shape)}[Nn](){return!0}[qt](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){D()}get nullable(){return fr(this,Dr)}get optional(){return new Wn(this)}cast(e){return jr(e,this),e}expect(e){return jr(e,this),e}},In=class extends N{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},P=(e,t=null)=>new In(e,t);P(In);var Ln=class extends N{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},F=e=>new Ln(e);P(Ln);var Rn=class extends N{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},zn=(...e)=>new Rn(e),Bn=P(Rn),Vn=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Hn=e=>{if(Sr.check(e))return[Vn(e)];if(Bn.check(e))return e.shape.map(e=>e+``);if(xr.check(e))return[`[+-]?\\d+.?\\d*`];if(Cr.check(e))return[`.*`];if(pr.check(e))return e.shape.map(Hn).flat(1);O()};P(class extends N{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Hn).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var Un=Symbol(`optional`),Wn=class extends N{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Un](){return!0}},Gn=P(Wn),Kn=class extends N{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Kn,P(Kn);var qn=class e extends N{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):tn(this.shape,(n,r)=>{let i=this._isPartial&&!nn(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Jn=e=>new qn(e),Yn=P(qn),Xn=F(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Zn=class extends N{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&tn(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},Qn=(e,t)=>new Zn(e,t),$n=P(Zn),er=class extends N{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&tn(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},tr=(...e)=>new er(e);P(er);var nr=class extends N{constructor(e){super(),this.shape=e.length===1?e[0]:new dr(e)}check(e,t){let n=y(e)&&he(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},rr=(...e)=>new nr(e),ir=P(nr),ar=F(e=>y(e)),or=class extends N{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},sr=(e,t=null)=>new or(e,t);P(or);var cr=sr(N),lr=P(class extends N{constructor(e){super(),this.len=e.length-1,this.args=tr(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),ur=F(e=>typeof e==`function`);P(class extends N{constructor(e){super(),this.shape=e}check(e,t){let n=he(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var dr=class extends N{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=ge(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},fr=(...e)=>e.findIndex(e=>pr.check(e))>=0?fr(...e.map(e=>Ar(e)).map(e=>pr.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new dr(e),pr=P(dr),mr=()=>!0,hr=F(mr),gr=P(Ln,e=>e.shape===mr),_r=F(e=>typeof e==`bigint`),vr=F(e=>e===_r),yr=F(e=>typeof e==`symbol`);F(e=>e===yr);var br=F(e=>typeof e==`number`),xr=F(e=>e===br),Sr=F(e=>typeof e==`string`),Cr=F(e=>e===Sr),wr=F(e=>typeof e==`boolean`),Tr=F(e=>e===wr),Er=zn(void 0);P(Rn,e=>e.shape.length===1&&e.shape[0]===void 0),zn(void 0);var Dr=zn(null),Or=P(Rn,e=>e.shape.length===1&&e.shape[0]===null);P(Uint8Array),P(In,e=>e.shape===Uint8Array);var kr=fr(br,Sr,Dr,Er,_r,wr,yr);(()=>{let e=rr(hr),t=Qn(Sr,hr),n=fr(br,Sr,Dr,wr,e,t);return e.shape=n,t.shape.values=n,n})();var Ar=e=>{if(cr.check(e))return e;if(Xn.check(e)){let t={};for(let n in e)t[n]=Ar(e[n]);return Jn(t)}else if(ar.check(e))return fr(...e.map(Ar));else if(kr.check(e))return zn(e);else if(ur.check(e))return P(e);O()},jr=vn?()=>{}:(e,t)=>{let n=new Pn;if(!t.check(e,n))throw E(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Mr=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Ar(e),h:t}),this}else(e){return this.if(hr,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw E(`Unhandled pattern`)}}},Nr=(e=>new Mr(e))(hr).if(xr,(e,t)=>Dn(t,Le,Ie)).if(Cr,(e,t)=>jn(t)).if(Tr,(e,t)=>En(t)).if(vr,(e,t)=>BigInt(Dn(t,Le,Ie))).if(pr,(e,t)=>Pr(t,Mn(t,e.shape))).if(Yn,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Gn.check(i)){if(En(t))continue;i=i.shape}n[r]=Nr(i,t)}return n}).if(ir,(e,t)=>{let n=[],r=On(t,0,42);for(let i=0;i<r;i++)n.push(Pr(t,e.shape));return n}).if(Bn,(e,t)=>Mn(t,e.shape)).if(Or,(e,t)=>null).if(lr,(e,t)=>{let n=Pr(t,e.res);return()=>n}).if(gr,(e,t)=>Pr(t,Mn(t,[br,Sr,Dr,Er,_r,wr,rr(br),Qn(fr(`a`,`b`,`c`),br)]))).if($n,(e,t)=>{let n={},r=Dn(t,0,3);for(let i=0;i<r;i++){let r=Pr(t,e.shape.keys);n[r]=Pr(t,e.shape.values)}return n}).done(),Pr=(e,t)=>Nr(Ar(t),e),I=typeof document<`u`?document:{},Fr=e=>I.createElement(e),Ir=()=>I.createDocumentFragment();F(e=>e.nodeType===Jr);var Lr=e=>I.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Rr=(e,t)=>(Tn(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),zr=e=>{let t=Ir();for(let n=0;n<e.length;n++)Wr(t,e[n]);return t},Br=(e,t)=>(Wr(e,zr(t)),e),Vr=(e,t=[],n=[])=>Br(Rr(Fr(e),t),n);F(e=>e.nodeType===Gr);var Hr=Lr;F(e=>e.nodeType===Kr);var Ur=e=>de(e,(e,t)=>`${t}:${e};`).join(``),Wr=(e,t)=>e.appendChild(t),Gr=I.ELEMENT_NODE,Kr=I.TEXT_NODE;I.CDATA_SECTION_NODE,I.COMMENT_NODE;var qr=I.DOCUMENT_NODE;I.DOCUMENT_TYPE_NODE;var Jr=I.DOCUMENT_FRAGMENT_NODE;F(e=>e.nodeType===qr);var Yr=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),Xr=(e,t)=>new Yr(setTimeout(t,e)),L=Symbol,Zr=L(),Qr=L(),$r=L(),ei=L(),ti=L(),ni=L(),ri=L(),ii=L(),ai=L(),oi=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};Ht();var si={[Zr]:M(`font-weight`,`bold`),[Qr]:M(`font-weight`,`normal`),[$r]:M(`color`,`blue`),[ti]:M(`color`,`green`),[ei]:M(`color`,`grey`),[ni]:M(`color`,`red`),[ri]:M(`color`,`purple`),[ii]:M(`color`,`orange`),[ai]:M(`color`,`black`)},ci=yn?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=h(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=si[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=Ur(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:oi,li=(...e)=>{console.log(...ci(e)),di.forEach(t=>t.print(e))},ui=(...e)=>{console.warn(...ci(e)),e.unshift(ii),di.forEach(t=>t.print(e))},di=_(),fi=e=>({[Symbol.iterator](){return this},next:e}),pi=(e,t)=>fi(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),mi=(e,t)=>fi(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),hi=class{constructor(e,t){this.clock=e,this.len=t}},gi=class{constructor(){this.clients=new Map}},_i=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])Ma(e,i,o.clock,o.len,n)}}),vi=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=b((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},yi=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&vi(n,t.clock)!==null},bi=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new hi(r.clock,x(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},xi=e=>{let t=new gi;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)me(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return bi(t),t},Si=(e,t,n,r)=>{g(e.clients,t,()=>[]).push(new hi(n,r))},Ci=()=>new gi,wi=e=>{let t=Ci();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new hi(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Ti=(e,t)=>{w(e.restEncoder,t.clients.size),v(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),w(e.restEncoder,t);let r=n.length;w(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Ei=e=>{let t=new gi,n=A(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=A(e.restDecoder),r=A(e.restDecoder);if(r>0){let i=g(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new hi(e.readDsClock(),e.readDsLen()))}}return t},Di=(e,t,n)=>{let r=new gi,i=A(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=A(e.restDecoder),a=A(e.restDecoder),o=n.clients.get(i)||[],s=z(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&Si(r,i,s,a-s);let e=B(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,Ws(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,Ws(t,c,a-c.id.clock)),c.delete(t))}else Si(r,i,n,a-n)}}if(r.clients.size>0){let e=new Li;return w(e.restEncoder,0),Ti(e,r),e.toUint8Array()}return null},Oi=Rt,ki=class e extends ve{constructor({guid:e=Vt(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Oi(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Ta,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Ut(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Ut(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&H(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(v(this.subdocs).map(e=>e.guid))}transact(e,t=null){return H(this,e,t)}get(e,t=W){let n=g(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==W&&r!==t)if(r===W){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,Fo)}getText(e=``){return this.get(e,ns)}getMap(e=``){return this.get(e,Ro)}getXmlElement(e=``){return this.get(e,ss)}getXmlFragment(e=``){return this.get(e,as)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,v(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,H(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},Ai=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return A(this.restDecoder)}readDsLen(){return A(this.restDecoder)}},ji=class extends Ai{readLeftID(){return R(A(this.restDecoder),A(this.restDecoder))}readRightID(){return R(A(this.restDecoder),A(this.restDecoder))}readClient(){return A(this.restDecoder)}readInfo(){return Et(this.restDecoder)}readString(){return Ot(this.restDecoder)}readParentInfo(){return A(this.restDecoder)===1}readTypeRef(){return A(this.restDecoder)}readLen(){return A(this.restDecoder)}readAny(){return jt(this.restDecoder)}readBuf(){return Sn(k(this.restDecoder))}readJSON(){return JSON.parse(Ot(this.restDecoder))}readKey(){return Ot(this.restDecoder)}},Mi=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=A(this.restDecoder),this.dsCurrVal}readDsLen(){let e=A(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Ni=class extends Mi{constructor(e){super(e),this.keys=[],A(e),this.keyClockDecoder=new Pt(k(e)),this.clientDecoder=new Nt(k(e)),this.leftClockDecoder=new Pt(k(e)),this.rightClockDecoder=new Pt(k(e)),this.infoDecoder=new Mt(k(e),Et),this.stringDecoder=new Ft(k(e)),this.parentInfoDecoder=new Mt(k(e),Et),this.typeRefDecoder=new Nt(k(e)),this.lenDecoder=new Nt(k(e))}readLeftID(){return new oa(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new oa(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 jt(this.restDecoder)}readBuf(){return k(this.restDecoder)}readJSON(){return jt(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Pi=class{constructor(){this.restEncoder=Ze()}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){w(this.restEncoder,e)}writeDsLen(e){w(this.restEncoder,e)}},Fi=class extends Pi{writeLeftID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeRightID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeClient(e){w(this.restEncoder,e)}writeInfo(e){tt(this.restEncoder,e)}writeString(e){at(this.restEncoder,e)}writeParentInfo(e){w(this.restEncoder,+!!e)}writeTypeRef(e){w(this.restEncoder,e)}writeLen(e){w(this.restEncoder,e)}writeAny(e){pt(this.restEncoder,e)}writeBuf(e){T(this.restEncoder,e)}writeJSON(e){at(this.restEncoder,JSON.stringify(e))}writeKey(e){at(this.restEncoder,e)}},Ii=class{constructor(){this.restEncoder=Ze(),this.dsCurrVal=0}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,w(this.restEncoder,t)}writeDsLen(e){e===0&&O(),w(this.restEncoder,e-1),this.dsCurrVal+=e}},Li=class extends Ii{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new vt,this.clientEncoder=new gt,this.leftClockEncoder=new vt,this.rightClockEncoder=new vt,this.infoEncoder=new mt(tt),this.stringEncoder=new yt,this.parentInfoEncoder=new mt(tt),this.typeRefEncoder=new gt,this.lenEncoder=new gt}toUint8Array(){let e=Ze();return w(e,0),T(e,this.keyClockEncoder.toUint8Array()),T(e,this.clientEncoder.toUint8Array()),T(e,this.leftClockEncoder.toUint8Array()),T(e,this.rightClockEncoder.toUint8Array()),T(e,S(this.infoEncoder)),T(e,this.stringEncoder.toUint8Array()),T(e,S(this.parentInfoEncoder)),T(e,this.typeRefEncoder.toUint8Array()),T(e,this.lenEncoder.toUint8Array()),ot(e,S(this.restEncoder)),S(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){pt(this.restEncoder,e)}writeBuf(e){T(this.restEncoder,e)}writeJSON(e){pt(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},Ri=(e,t,n,r)=>{r=x(r,t[0].id.clock);let i=B(t,r);w(e.restEncoder,t.length-i),e.writeClient(n),w(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},zi=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{z(t,n)>e&&r.set(n,e)}),Ea(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),w(e.restEncoder,r.size),v(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Ri(e,t.clients.get(n),n,r)})},Bi=(e,t)=>{let n=h(),r=A(e.restDecoder);for(let i=0;i<r;i++){let r=A(e.restDecoder),i=Array(r),a=e.readClient(),o=A(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new G(R(a,o),t),o+=t;break}case 10:{let t=A(e.restDecoder);i[n]=new Y(R(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new J(R(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,qs(e,r));i[n]=c,o+=c.length}}}}return n},Vi=(e,t,n)=>{let r=[],i=v(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new Ta,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==Y){let i=g(d,u.id.client,()=>z(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,z(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new Li;return zi(e,s,new Map),w(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Hi=(e,t)=>zi(e,t.doc.store,t.beforeState),Ui=(e,t,n,r=new Ni(e))=>H(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Vi(e,i,Bi(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<z(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=Ya([o.update,a.update])}}else i.pendingStructs=a;let s=Di(r,e,i);if(i.pendingDs){let t=new Ni(Ct(i.pendingDs));A(t.restDecoder);let n=Di(t,e,i);s&&n?i.pendingDs=Ya([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Wi(e.doc,t)}},n,!1),Wi=(e,t,n,r=Ni)=>{let i=Ct(t);Ui(i,e,n,new r(i))},Gi=(e,t,n)=>Wi(e,t,n,ji),Ki=(e,t,n=new Map)=>{zi(e,t.store,n),Ti(e,wi(t.store))},qi=(e,t=new Uint8Array([0]),n=new Li)=>{Ki(n,e,Xi(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Xa(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Fi)return qa(r.map((e,t)=>t===0?e:to(e)));if(n.constructor===Li)return Ya(r)}return r[0]},Ji=(e,t)=>qi(e,t,new Fi),Yi=e=>{let t=new Map,n=A(e.restDecoder);for(let r=0;r<n;r++){let n=A(e.restDecoder),r=A(e.restDecoder);t.set(n,r)}return t},Xi=e=>Yi(new Ai(Ct(e))),Zi=(e,t)=>(w(e.restEncoder,t.size),v(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{w(e.restEncoder,t),w(e.restEncoder,n)}),e),Qi=(e,t)=>Zi(e,Ea(t.store)),$i=(e,t=new Ii)=>(e instanceof Map?Zi(t,e):Qi(t,e),t.toUint8Array()),ea=e=>$i(e,new Pi),ta=class{constructor(){this.l=[]}},na=()=>new ta,ra=(e,t)=>e.l.push(t),ia=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},aa=(e,t,n)=>sn(e.l,[t,n]),oa=class{constructor(e,t){this.client=e,this.clock=t}},sa=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,R=(e,t)=>new oa(e,t),ca=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw O()},la=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},ua=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},da=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},fa=e=>new ua(e.type==null?null:R(e.type.client,e.type.clock),e.tname??null,e.item==null?null:R(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),pa=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},ma=(e,t,n=0)=>new pa(e,t,n),ha=(e,t,n)=>{let r=null,i=null;return e._item===null?i=ca(e):r=R(e._item.id.client,e._item.id.clock),new ua(r,i,t,n)},ga=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return ha(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return ha(e,R(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return ha(e,r.lastId,n);r=r.right}return ha(e,null,n)},_a=(e,t)=>{let n=Oa(e,t);return{item:n,diff:t.clock-n.id.clock}},va=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(z(r,i.client)<=i.clock)return null;let e=n?Hs(r,i):_a(r,i),t=e.item;if(!(t instanceof J))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(z(r,a.client)<=a.clock)return null;let{item:e}=n?Hs(r,a):{item:Oa(r,a)};if(e instanceof J&&e.content instanceof q)c=e.content.type;else return null}else throw O();l=s>=0?c._length:0}return ma(c,l,e.assoc)},ya=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&sa(e.item,t.item)&&sa(e.type,t.type)&&e.assoc===t.assoc,ba=class{constructor(e,t){this.ds=e,this.sv=t}},xa=(e,t)=>new ba(e,t);xa(Ci(),new Map);var Sa=e=>xa(wi(e.store),Ea(e.store)),Ca=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!yi(t.ds,e.id),wa=(e,t)=>{let n=g(e.meta,wa,_),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<z(r,n)&&V(e,R(n,t))}),_i(e,t.ds,e=>{}),n.add(t))},Ta=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Ea=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},z=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Da=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw O()}n.push(t)},B=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=b(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=b((n+r)/2)}throw O()},Oa=(e,t)=>{let n=e.clients.get(t.client);return n[B(n,t.clock)]},ka=(e,t,n)=>{let r=B(t,n),i=t[r];return i.id.clock<n&&i instanceof J?(t.splice(r+1,0,Ws(e,i,n-i.id.clock)),r+1):r},V=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[ka(e,n,t.clock)]},Aa=(e,t,n)=>{let r=t.clients.get(n.client),i=B(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==G&&r.splice(i+1,0,Ws(e,a,n.clock-a.id.clock+1)),a},ja=(e,t,n)=>{let r=e.clients.get(t.id.client);r[B(r,t.id.clock)]=n},Ma=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=ka(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&ka(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Na=class{constructor(e,t,n){this.doc=e,this.deleteSet=new gi,this.beforeState=Ea(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Pa=(e,t)=>t.deleteSet.clients.size===0&&!fe(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(bi(t.deleteSet),Hi(e,t),Ti(e,t.deleteSet),!0),Fa=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&g(e.changed,t,_).add(n)},Ia=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof J&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},La=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=B(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof J&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Ra=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=xe(r.length-1,1+B(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+Ia(r,e)}})},za=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{bi(a),n.afterState=Ea(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{aa(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&$o(n)})}),sn(e,[])}finally{r.gc&&La(a,i,r.gcFilter),Ra(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=x(B(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Ia(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=B(r,n);a+1<r.length&&Ia(r,a+1)>1||a>0&&Ia(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(li(ii,Zr,`[yjs] `,Qr,ni,`Changed the client-id because another client seems to be using it.`),r.clientID=Oi()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Fi;Pa(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Li;Pa(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):za(e,t+1)}}},H=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Na(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&za(i,0)}}return o},Ba=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Va=(e,t,n)=>{_i(e,n.deletions,n=>{n instanceof J&&t.scope.some(t=>t===e.doc||la(t,n))&&Us(n,!1)})},Ha=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;H(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;_i(n,o.insertions,e=>{if(e instanceof J){if(e.redone!==null){let{item:t,diff:i}=Hs(r,e.id);i>0&&(t=V(n,R(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||la(t,e))&&c.push(e)}}),_i(n,o.deletions,e=>{e instanceof J&&a.some(t=>t===n.doc||la(t,e))&&!yi(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Ks(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},Ua=class extends ve{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=y(e)?e[0].doc:e instanceof ki?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new gi;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&Si(i,n,r,a)});let a=Ht(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=xi([t.deletions,e.deleteSet]),t.insertions=xi([t.insertions,i])}else r.push(new Ba(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),_i(e,e.deleteSet,t=>{t instanceof J&&this.scope.some(n=>n===e.doc||la(n,t))&&Us(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=y(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof W?e.doc!==this.doc:e!==this.doc)&&ui(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>Va(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Va(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Ha(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Ha(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off(`afterTransaction`,this.afterTransactionHandler),super.destroy()}};function*Wa(e){let t=A(e.restDecoder);for(let n=0;n<t;n++){let t=A(e.restDecoder),n=e.readClient(),r=A(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=A(e.restDecoder);yield new Y(R(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new J(R(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,qs(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new G(R(n,r),t),r+=t}}}}var Ga=class{constructor(e,t){this.gen=Wa(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Y);return this.curr}},Ka=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},qa=e=>Ya(e,ji,Fi),Ja=(e,t)=>{if(e.constructor===G){let{client:n,clock:r}=e.id;return new G(R(n,r+t),e.length-t)}else if(e.constructor===Y){let{client:n,clock:r}=e.id;return new Y(R(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new J(R(r,i+t),null,R(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Ya=(e,t=Ni,n=Li)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Ct(e))),i=r.map(e=>new Ga(e,!0)),a=null,o=new n,s=new Ka(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===Y?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)Qa(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===Y)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{Qa(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Y(R(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===Y?a.struct.length-=t:n=Ja(n,t)),a.struct.mergeWith(n)||(Qa(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==Y;n=e.next())Qa(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Qa(s,a.struct,a.offset),a=null),$a(s),Ti(o,xi(r.map(e=>Ei(e)))),o.toUint8Array()},Xa=(e,t,n=Ni,r=Li)=>{let i=Xi(t),a=new r,o=new Ka(a),s=new n(Ct(e)),c=new Ga(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Y){c.next();continue}if(e.id.clock+e.length>n)for(Qa(o,e,x(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Qa(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return $a(o),Ti(a,Ei(s)),a.toUint8Array()},Za=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:S(e.encoder.restEncoder)}),e.encoder.restEncoder=Ze(),e.written=0)},Qa=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Za(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),w(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},$a=e=>{Za(e);let t=e.encoder.restEncoder;w(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];w(t,r.written),ot(t,r.restEncoder)}},eo=(e,t,n,r)=>{let i=new n(Ct(e)),a=new Ga(i,!1),o=new r,s=new Ka(o);for(let e=a.curr;e!==null;e=a.next())Qa(s,t(e),0);return $a(s),Ti(o,Ei(i)),o.toUint8Array()},to=e=>eo(e,cn,Ni,Fi),no=`You must not compute changes after the event-handler fired.`,ro=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=io(this.currentTarget,this.target)}deletes(e){return yi(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw E(no);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=pe(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=pe(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=pe(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw E(no);let t=this.target,n=_(),r=_(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},io=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},U=()=>{ui(`Invalid access: Add Yjs type to a document before reading data.`)},ao=80,oo=0,so=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=oo++}},co=e=>{e.timestamp=oo++},lo=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=oo++},uo=(e,t,n)=>{if(e.length>=ao){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return lo(r,t,n),r}else{let r=new so(t,n);return e.push(r),r}},fo=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>be(t-e.index)<be(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,co(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&be(n.index-i)<r.parent.length/ao?(lo(n,r,i),n):uo(e._searchMarker,r,i)},po=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=x(t,i.index+n))}},mo=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;g(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;aa(r._eH,n,t)},W=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=na(),this._dEH=na(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw D()}clone(){throw D()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){ra(this._eH,e)}observeDeep(e){ra(this._dEH,e)}unobserve(e){ia(this._eH,e)}unobserveDeep(e){ia(this._dEH,e)}toJSON(){}},ho=(e,t,n)=>{e.doc??U(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},go=e=>{e.doc??U();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},_o=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Ca(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},vo=(e,t)=>{let n=0,r=e._start;for(e.doc??U();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},yo=(e,t)=>{let n=[];return vo(e,(r,i)=>{n.push(t(r,i,e))}),n},bo=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},xo=(e,t)=>{e.doc??U();let n=fo(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},So=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new J(R(o,z(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new ks(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new J(R(o,z(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new gs(new Uint8Array(n))),i.integrate(e,0);break;case ki:i=new J(R(o,z(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new xs(n)),i.integrate(e,0);break;default:if(n instanceof W)i=new J(R(o,z(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new q(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Co=()=>E(`Length exceeded!`),wo=(e,t,n,r)=>{if(n>t._length)throw Co();if(n===0)return t._searchMarker&&po(t._searchMarker,n,r.length),So(e,t,null,r);let i=n,a=fo(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&V(e,R(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&po(t._searchMarker,i,r.length),So(e,t,o,r)},To=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return So(e,t,r,n)},Eo=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=fo(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&V(e,R(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&V(e,R(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw Co();t._searchMarker&&po(t._searchMarker,i,-a+r)},Do=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Oo=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new ks([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new ks([r]);break;case Uint8Array:s=new gs(r);break;case ki:s=new xs(r);break;default:if(r instanceof W)s=new q(r);else throw Error(`Unexpected content type`)}new J(R(o,z(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},ko=(e,t)=>{e.doc??U();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Ao=e=>{let t={};return e.doc??U(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},jo=(e,t)=>{e.doc??U();let n=e._map.get(t);return n!==void 0&&!n.deleted},Mo=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&Ca(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},No=e=>(e.doc??U(),pi(e._map.entries(),e=>!e[1].deleted)),Po=class extends ro{},Fo=class e extends W{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof W?e.clone():e)),t}get length(){return this.doc??U(),this._length}_callObserver(e,t){super._callObserver(e,t),mo(this,e,new Po(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):H(this.doc,n=>{wo(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):H(this.doc,t=>{To(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):H(this.doc,n=>{Eo(n,this,e,t)})}get(e){return xo(this,e)}toArray(){return go(this)}slice(e=0,t=this.length){return ho(this,e,t)}toJSON(){return this.map(e=>e instanceof W?e.toJSON():e)}map(e){return yo(this,e)}forEach(e){vo(this,e)}[Symbol.iterator](){return bo(this)}_write(e){e.writeTypeRef(Ps)}},Io=e=>new Fo,Lo=class extends ro{constructor(e,t,n){super(e,t),this.keysChanged=n}},Ro=class e extends W{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof W?e.clone():e)}),t}_callObserver(e,t){mo(this,e,new Lo(this,e,t))}toJSON(){this.doc??U();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof W?r.toJSON():r}}),e}get size(){return[...No(this)].length}keys(){return mi(No(this),e=>e[0])}values(){return mi(No(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return mi(No(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??U(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):H(this.doc,t=>{Do(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):H(this.doc,n=>{Oo(n,this,e,t)}),t}get(e){return ko(this,e)}has(e){return jo(this,e)}clear(){this.doc===null?this._prelimContent.clear():H(this.doc,e=>{this.forEach(function(t,n,r){Do(e,r,n)})})}_write(e){e.writeTypeRef(Fs)}},zo=e=>new Ro,Bo=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&rn(e,t),Vo=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&O(),this.right.content.constructor){case K:this.right.deleted||Go(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}},Ho=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case K:t.right.deleted||Go(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&V(e,R(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},Uo=(e,t,n,r)=>{let i=new Map,a=r?fo(t,n):null;return a?Ho(e,new Vo(a.p.left,a.p,a.index,i),n-a.index):Ho(e,new Vo(null,t._start,0,i),n)},Wo=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===K&&Bo(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new J(R(a,z(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new K(o,r));l.integrate(e,0),n.right=l,n.forward()})},Go=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Ko=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===K&&Bo(t[e.right.content.key]??null,e.right.content.value));)e.forward()},qo=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!Bo(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new J(R(a,z(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new K(s,c)),n.right.integrate(e,0),n.forward()}}return o},Jo=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Ko(n,i);let s=qo(e,t,n,i),c=r.constructor===String?new js(r):r instanceof W?new q(r):new Cs(r),{left:l,right:u,index:d}=n;t._searchMarker&&po(t._searchMarker,n.index,c.getLength()),u=new J(R(o,z(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Wo(e,t,n,s)},Yo=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Ko(n,i);let s=qo(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===K));){if(!n.right.deleted)switch(n.right.content.constructor){case K:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Bo(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&V(e,R(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
3
- `;n.right=new J(R(o,z(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new js(i)),n.right.integrate(e,0),n.forward()}Wo(e,t,n,s)},Xo=(e,t,n,r,i)=>{let a=t,o=h();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===K){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case K:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&Go(i,n);break}}}t=t.right}return s},Zo=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===K){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Qo=e=>{let t=0;return H(e.doc,n=>{let r=e._start,i=e._start,a=h(),o=ue(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case K:Go(o,i.content);break;default:t+=Xo(n,r,i,a,o),a=ue(o),r=i;break}i=i.right}}),t},$o=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&Ma(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===K&&e.constructor!==G&&t.add(e.parent)})}H(n,n=>{_i(e,e.deleteSet,e=>{if(e instanceof G||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===K?t.add(r):Zo(n,e)});for(let e of t)Qo(e)})},es=(e,t,n)=>{let r=n,i=ue(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case q:case Cs:case js:n<t.right.length&&V(e,R(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&Xo(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&po(o._searchMarker,t.index,-r+n),t},ts=class extends ro{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){return this._changes===null&&(this._changes={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set}),this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];H(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},en(o)||(e.attributes=Xt({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case q:case Cs:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case js:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case K:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Bo(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Bo(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;Bo(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Bo(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Go(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},ns=class e extends W{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??U(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new ts(this,e,t);mo(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??U();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===js&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):H(this.doc,n=>{let r=new Vo(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
4
- `?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Jo(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&es(n,r,a.delete):Yo(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??U();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(Ca(s,e)||t!==void 0&&Ca(s,t))switch(s.content.constructor){case js:{let r=i.get(`ychange`);e!==void 0&&!Ca(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!Ca(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case q:case Cs:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case K:Ca(s,e)&&(c(),Go(i,s.content));break}s=s.right}c()};return e||t?H(a,n=>{e&&wa(n,e),t&&wa(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):H(r,r=>{let i=Uo(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Jo(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):H(r,r=>{let i=Uo(r,this,e,!n);Jo(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):H(n,n=>{es(n,Uo(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):H(r,r=>{let i=Uo(r,this,e,!1);i.right!==null&&Yo(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):H(this.doc,t=>{Do(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):H(this.doc,n=>{Oo(n,this,e,t)})}getAttribute(e){return ko(this,e)}getAttributes(){return Ao(this)}_write(e){e.writeTypeRef(Is)}},rs=e=>new ns,is=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??U()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===ss||t.constructor===as)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},as=class e extends W{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof W?e.clone():e)),t}get length(){return this.doc??U(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new is(this,e)}querySelector(e){e=e.toUpperCase();let t=new is(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),v(new is(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){mo(this,e,new ls(this,t,e))}toString(){return yo(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),vo(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):H(this.doc,n=>{wo(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)H(this.doc,n=>{let r=e&&e instanceof W?e._item:e;So(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw E(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):H(this.doc,n=>{Eo(n,this,e,t)})}toArray(){return go(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return xo(this,e)}slice(e=0,t=this.length){return ho(this,e,t)}forEach(e){vo(this,e)}_write(e){e.writeTypeRef(Rs)}},os=e=>new as,ss=class e extends as{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return Qt(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof W?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):H(this.doc,t=>{Do(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):H(this.doc,n=>{Oo(n,this,e,t)})}getAttribute(e){return ko(this,e)}hasAttribute(e){return jo(this,e)}getAttributes(e){return e?Mo(this,e):Ao(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return vo(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Ls),e.writeKey(this.nodeName)}},cs=e=>new ss(e.readKey()),ls=class extends ro{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},us=class e extends Ro{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(zs),e.writeKey(this.hookName)}},ds=e=>new us(e.readKey()),fs=class e extends ns{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Bs)}},ps=e=>new fs,ms=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw D()}mergeWith(e){return!1}write(e,t,n){throw D()}integrate(e,t){throw D()}},hs=0,G=class extends ms{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Da(e.doc.store,this)}write(e,t){e.writeInfo(hs),e.writeLen(this.length-t)}getMissing(e,t){return null}},gs=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw D()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},_s=e=>new gs(e.readBuf()),vs=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Si(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},ys=e=>new vs(e.readLen()),bs=(e,t)=>new ki({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),xs=class e{constructor(e){e._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=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(bs(this.doc.guid,this.opts))}splice(e){throw D()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},Ss=e=>new xs(bs(e.readString(),e.readAny())),Cs=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw D()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},ws=e=>new Cs(e.readJSON()),K=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw D()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},Ts=e=>new K(e.readKey(),e.readJSON()),Es=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},Ds=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new Es(n)},Os=gn(`node_env`)===`development`,ks=class e{constructor(e){this.arr=e,Os&&on(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},As=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new ks(n)},js=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},Ms=e=>new js(e.readString()),Ns=[Io,zo,rs,cs,os,ds,ps],Ps=0,Fs=1,Is=2,Ls=3,Rs=4,zs=5,Bs=6,q=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw D()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},Vs=e=>new q(Ns[e.readTypeRef()](e)),Hs=(e,t)=>{let n=t,r=0,i;do r>0&&(n=R(n.client,n.clock+r)),i=Oa(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof J);return{item:i,diff:r}},Us=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Ws=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new J(R(r,i+n),t,R(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=R(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},Gs=(e,t)=>ge(e,e=>yi(e.deletions,t)),Ks=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return V(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Ks(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=V(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:V(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:V(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||yi(r,d.right.id)||Gs(a.undoStack,d.right.id)||Gs(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=V(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let ee=R(c,z(s,c)),te=new J(ee,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=ee,Us(te,!0),te.integrate(e,0),te},J=class e extends ms{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=z(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=z(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===oa&&this.id.client!==this.parent.client&&this.parent.clock>=z(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Aa(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=V(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===G||this.right&&this.right.constructor===G)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===oa){let e=Oa(n,this.parent);e.constructor===G?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Aa(e,e.doc.store,R(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),sa(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(sa(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Oa(e.doc.store,n.origin)))r.has(Oa(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Da(e.doc.store,this),this.content.integrate(e,this),Fa(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new G(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:R(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&sa(e.origin,this.lastId)&&this.right===e&&sa(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),Si(e.deleteSet,this.id.client,this.id.clock,this.length),Fa(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw O();this.content.gc(e),t?ja(e,this,new G(this.id,this.length)):this.content=new vs(this.length)}write(e,t){let n=t>0?R(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=ca(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===oa?(e.writeParentInfo(!1),e.writeLeftID(t)):O();i!==null&&e.writeString(i)}this.content.write(e,t)}},qs=(e,t)=>Js[t&31](e),Js=[()=>{O()},ys,Ds,_s,Ms,ws,Ts,Vs,As,Ss,()=>{O()}],Ys=10,Y=class extends ms{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){O()}write(e,t){e.writeInfo(Ys),w(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Xs=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Zs=`__ $YJS$ __`;Xs[Zs]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Xs[Zs]=!0;var Qs=Math.floor,$s=(e,t)=>e<t?e:t,ec=(e,t)=>e>t?e:t;Number.isNaN;var tc=128,nc=1<<17,rc=1<<18,ic=1<<19,ac=1<<20,oc=1<<21,sc=1<<22,cc=1<<23,lc=1<<24,uc=1<<25,dc=1<<26,fc=1<<27,pc=1<<28,mc=1<<29,hc=1<<30,gc=127;nc-1,rc-1,ic-1,ac-1,oc-1,sc-1,cc-1,lc-1,uc-1,dc-1,fc-1,pc-1,mc-1,hc-1;var _c=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var vc=String.fromCharCode;String.fromCodePoint,vc(65535);var yc=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},bc=typeof TextEncoder<`u`?new TextEncoder:null,xc=bc?e=>bc.encode(e):yc,Sc=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Sc&&Sc.decode(new Uint8Array).length===1&&(Sc=null);var Cc=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},wc=(e,t)=>{for(;t>gc;)Cc(e,tc|gc&t),t=Qs(t/128);Cc(e,gc&t)},Tc=new Uint8Array(3e4),Ec=Tc.length/3,Dc=bc&&bc.encodeInto?(e,t)=>{if(t.length<Ec){let n=bc.encodeInto(t,Tc).written||0;wc(e,n);for(let t=0;t<n;t++)Cc(e,Tc[t])}else kc(e,xc(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;wc(e,r);for(let t=0;t<r;t++)Cc(e,n.codePointAt(t))},Oc=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=$s(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(ec(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},kc=(e,t)=>{wc(e,t.byteLength),Oc(e,t)},Ac=e=>Error(e),jc=Ac(`Unexpected end of array`),Mc=Ac(`Integer out of Range`),Nc=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Pc=e=>Nc(e,Ic(e)),Fc=e=>e.arr[e.pos++],Ic=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&gc)*n,n*=128,r<tc)return t;if(t>_c)throw Mc}throw jc},Lc=Sc?e=>Sc.decode(Pc(e)):e=>{let t=Ic(e);if(t===0)return``;{let n=String.fromCodePoint(Fc(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Fc(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Rc=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),zc=(e,t)=>{wc(e,Rc.Token),Dc(e,t)},Bc=(e,t,n,r)=>{switch(Ic(e)){case Rc.Token:t();break;case Rc.PermissionDenied:n(Lc(e));break;case Rc.Authenticated:r(Lc(e));break;default:}},Vc=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),Hc=`\0`;function Uc(e,t){return e+Hc+t}function Wc(e){let t=e.indexOf(Hc);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Gc=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({});function Kc(e){return e||={},{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function qc(e){return new Promise(t=>setTimeout(t,e))}function Jc(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function Yc(e,t){let n=Kc(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||Jc;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await qc(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await qc(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await qc(e)}return a()}var Xc=Math.floor,Zc=(e,t)=>e<t?e:t,Qc=(e,t)=>e>t?e:t;Number.isNaN;var $c=64,el=128,tl=1<<17,nl=1<<18,rl=1<<19,il=1<<20,al=1<<21,ol=1<<22,sl=1<<23,cl=1<<24,ll=1<<25,ul=1<<26,dl=1<<27,fl=1<<28,pl=1<<29,ml=1<<30,hl=63,gl=127;tl-1,nl-1,rl-1,il-1,al-1,ol-1,sl-1,cl-1,ll-1,ul-1,dl-1,fl-1,pl-1,ml-1;var _l=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var vl=()=>new Set,yl=Array.from;Array.isArray;var bl=String.fromCharCode;String.fromCodePoint,bl(65535);var xl=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Sl=typeof TextEncoder<`u`?new TextEncoder:null,Cl=Sl?e=>Sl.encode(e):xl,wl=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});wl&&wl.decode(new Uint8Array).length===1&&(wl=null);var Tl=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},El=()=>new Tl,Dl=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Ol=e=>{let t=new Uint8Array(Dl(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},kl=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},X=(e,t)=>{for(;t>gl;)kl(e,el|gl&t),t=Xc(t/128);kl(e,gl&t)},Al=new Uint8Array(3e4),jl=Al.length/3,Z=Sl&&Sl.encodeInto?(e,t)=>{if(t.length<jl){let n=Sl.encodeInto(t,Al).written||0;X(e,n);for(let t=0;t<n;t++)kl(e,Al[t])}else Nl(e,Cl(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;X(e,r);for(let t=0;t<r;t++)kl(e,n.codePointAt(t))},Ml=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Zc(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Qc(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Nl=(e,t)=>{X(e,t.byteLength),Ml(e,t)},Pl=e=>Error(e),Fl=Pl(`Unexpected end of array`),Il=Pl(`Integer out of Range`),Ll=class{constructor(e){this.arr=e,this.pos=0}},Rl=e=>new Ll(e),zl=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Bl=e=>zl(e,Hl(e)),Vl=e=>e.arr[e.pos++],Hl=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&gl)*n,n*=128,r<el)return t;if(t>_l)throw Il}throw Fl},Ul=e=>{let t=e.arr[e.pos++],n=t&hl,r=64,i=(t&$c)>0?-1:1;if((t&el)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&gl)*r,r*=128,t<el)return i*n;if(n>_l)throw Il}throw Fl},Wl=wl?e=>wl.decode(Bl(e)):e=>{let t=Hl(e);if(t===0)return``;{let n=String.fromCodePoint(Vl(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Vl(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Gl=e=>{let t=e.pos,n=Wl(e);return e.pos=t,n},Kl=Date.now,ql=()=>new Map,Jl=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Yl=class{constructor(){this._observers=ql()}on(e,t){Jl(this._observers,e,vl).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return yl((this._observers.get(e)||ql()).values()).forEach(e=>e(...t))}destroy(){this._observers=ql()}},Xl=Symbol(`Equality`),Zl=Object.keys,Ql=e=>Zl(e).length,$l=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),eu=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Xl]!=null)return e[Xl](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!eu(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Ql(e)!==Ql(t))return!1;for(let n in e)if(!$l(e,n)||!eu(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!eu(e[n],t[n]))return!1;break;default:return!1}return!0},tu=3e4,nu=class extends Yl{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Kl();this.getLocalState()!==null&&tu/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&tu<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&ru(this,t,`timeout`)},Xc(tu/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:Kl()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),eu(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},ru=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:Kl()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},iu=(e,t,n=e.states)=>{let r=t.length,i=El();X(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;X(i,r),X(i,s),Z(i,JSON.stringify(o))}return Ol(i)},au=(e,t,n)=>{let r=Rl(t),i=Kl(),a=[],o=[],s=[],c=[],l=Hl(r);for(let t=0;t<l;t++){let t=Hl(r),n=Hl(r),l=JSON.parse(Wl(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(eu(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},ou=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},su=class{constructor(e){this.data=e,this.encoder=El(),this.decoder=Rl(new Uint8Array(this.data))}peekVarString(){return Gl(this.decoder)}readVarUint(){return Hl(this.decoder)}readVarString(){return Wl(this.decoder)}readVarUint8Array(){return Bl(this.decoder)}writeVarUint(e){return X(this.encoder,e)}writeVarString(e){return Z(this.encoder,e)}writeVarUint8Array(e){return Nl(this.encoder,e)}length(){return Dl(this.encoder)}},Q=function(e){return e[e.Sync=0]=`Sync`,e[e.Awareness=1]=`Awareness`,e[e.Auth=2]=`Auth`,e[e.QueryAwareness=3]=`QueryAwareness`,e[e.Stateless=5]=`Stateless`,e[e.CLOSE=7]=`CLOSE`,e[e.SyncStatus=8]=`SyncStatus`,e[e.Ping=9]=`Ping`,e[e.Pong=10]=`Pong`,e}({}),$=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),cu=class{constructor(){this.encoder=El()}get(e){return e.encoder}toUint8Array(){return Ol(this.encoder)}},lu=class extends cu{constructor(...e){super(...e),this.type=Q.CLOSE,this.description=`Ask the server to close the connection`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),this.encoder}},uu=class e extends ou{static{this.DEDUPLICATABLE_TYPES=new Set([Q.Awareness,Q.QueryAwareness])}constructor(e){super(),this.messageQueue=[],this.configuration={url:``,autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=$.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on(`open`,this.configuration.onOpen),this.on(`open`,this.onOpen.bind(this)),this.on(`connect`,this.configuration.onConnect),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`status`,this.configuration.onStatus),this.on(`disconnect`,this.configuration.onDisconnect),this.on(`close`,this.configuration.onClose),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`close`,this.onClose.bind(this)),this.on(`message`,this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(e){this.status=$.Connected,this.emit(`status`,{status:$.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){let t=e.effectiveName,n=this.configuration.providerMap.get(t);if(n&&n!==e&&n.isAuthenticated)throw Error(`Cannot attach two providers with the same effective name "${t}". Use sessionAwareness: true to multiplex providers with the same document name.`);this.configuration.providerMap.set(t,e),this.status===$.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===$.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(lu,{documentName:t}),this.configuration.providerMap.delete(t))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===$.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:Yc(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{this.webSocket?.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=$.Connecting,this.emit(`status`,{status:$.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=Kl();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Q.Ping){this.sendPong();return}let n=new su(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=El();X(e,Q.Pong),this.send(Ol(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=$.Connected,this.emit(`status`,{status:$.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}checkConnection(){this.status===$.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Kl()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:`forced`}}),this.closeTries=0):(this.webSocket?.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}parseQueuedMessage(e){try{let t=Rl(e);return{documentName:Wl(t),messageType:Hl(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===Gc.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=$.Disconnected,this.emit(`status`,{status:$.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},du=0,fu=1,pu=2,mu=(e,t)=>{X(e,du),Nl(e,ea(t))},hu=(e,t,n)=>{X(e,fu),Nl(e,Ji(t,n))},gu=(e,t,n)=>hu(t,n,Bl(e)),_u=(e,t,n,r)=>{try{Gi(t,Bl(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},vu=(e,t)=>{X(e,pu),Nl(e,t)},yu=_u,bu=(e,t,n,r,i)=>{let a=Hl(e);switch(a){case du:gu(e,t,n);break;case fu:_u(e,n,r,i);break;case pu:yu(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},xu=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case Q.Sync:this.applySyncMessage(e,t);break;case Q.Awareness:this.applyAwarenessMessage(e);break;case Q.Auth:this.applyAuthMessage(e);break;case Q.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Q.Stateless:e.receiveStateless(Wl(n.decoder));break;case Q.SyncStatus:this.applySyncStatusMessage(e,Ul(n.decoder)===1);break;case Q.CLOSE:let i={code:1e3,reason:Wl(n.decoder)};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:console.error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(cu,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Q.Sync);let r=bu(n.decoder,n.encoder,e.document,e);t&&r===fu&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;au(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;Bc(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(Q.Awareness),t.writeVarUint8Array(iu(e.awareness,Array.from(e.awareness.getStates().keys())))}},Su=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Ol(this.encoder)}send(e){e?.send(this.create())}},Cu=`4.0.0-rc.1`,wu=class extends cu{constructor(...e){super(...e),this.type=Q.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return Z(this.encoder,e.documentName),X(this.encoder,this.type),zc(this.encoder,e.token),Z(this.encoder,Cu),this.encoder}},Tu=class extends cu{constructor(...e){super(...e),this.type=Q.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);Z(this.encoder,e.documentName),X(this.encoder,this.type);let t;return t=e.states===void 0?iu(e.awareness,e.clients):iu(e.awareness,e.clients,e.states),Nl(this.encoder,t),this.encoder}},Eu=class extends cu{constructor(...e){super(...e),this.type=Q.Stateless,this.description=`A stateless message`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),Z(this.encoder,e.payload??``),this.encoder}},Du=class extends cu{constructor(...e){super(...e),this.type=Q.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return Z(this.encoder,e.documentName),X(this.encoder,this.type),mu(this.encoder,e.document),this.encoder}},Ou=class extends cu{constructor(...e){super(...e),this.type=Q.Sync,this.description=`A document update`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),vu(this.encoder,e.update),this.encoder}},ku=class extends Error{constructor(...e){super(...e),this.code=1001}},Au=class extends ou{get effectiveName(){return this.configuration.sessionAwareness?Uc(this.configuration.name,this.sessionId):this.configuration.name}constructor(e){super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,sessionAwareness:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.sessionId=Math.random().toString(36).slice(2),this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new ki,this.configuration.awareness=e.awareness===void 0?new nu(this.document):e.awareness,this.on(`open`,this.configuration.onOpen),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`synced`,this.configuration.onSynced),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`stateless`,this.configuration.onStateless),this.on(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),this.awareness?.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:Vc(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:Vc(this.awareness.getStates())})}),this.document.on(`update`,this.boundDocumentUpdateHandler),this.awareness?.on(`update`,this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval==`number`&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new uu(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(Du,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&ru(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(Eu,{documentName:this.effectiveName,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(wu,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(Ou,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(Tu,{awareness:this.awareness,clients:i,documentName:this.effectiveName})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(Du,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(Tu,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new Su(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new su(e.data),{documentName:n}=Wc(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new su(e.data)}),new xu(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&ru(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit(`destroy`),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(ru(this.awareness,[this.document.clientID],`provider destroy`),this.awareness.off(`update`,this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off(`update`,this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),this.configuration.websocketProvider.off(`close`,this.boundOnClose),this.configuration.websocketProvider.off(`close`,this.configuration.onClose),this.configuration.websocketProvider.off(`close`,this.forwardClose),this.configuration.websocketProvider.off(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.off(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.off(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.off(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),this.configuration.websocketProvider.on(`close`,this.boundOnClose),this.configuration.websocketProvider.on(`close`,this.configuration.onClose),this.configuration.websocketProvider.on(`close`,this.forwardClose),this.configuration.websocketProvider.on(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.on(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.on(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.on(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new ku(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}},ju={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.25.0`}?.VITE_APP_VERSION??`0.0.0-unknown`;function Mu(){return p({kind:`web`,runtimeVersion:ju})}function Nu(){return o({kind:`web`,runtimeVersion:ju})}function Pu(e,t,n=null,r=null){let i={...Nu()};return e!==null&&(i.principalId=e.principalId,i.tabSessionId=e.tabSessionId),t!==null&&t.length>0&&(i.expectedServerInstanceId=t),n!==null&&n.length>0&&(i.expectedBranch=n),r!==null&&r.length>0&&(i.expectedDocLineageEpoch=r),JSON.stringify(i)}function Fu(e,t){let n=(0,re.c)(7),r,i;n[0]!==e||n[1]!==t?(r=()=>{if(t!==`light`&&t!==`dark`&&t!==`system`||!e)return;let n=!1;return e.setThemeSource(t).catch(e=>{console.warn(JSON.stringify({event:`theme-source-set-failed`,themeValue:t,error:e instanceof Error?e.message:String(e)}))}).finally(()=>{if(n)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`).matches;e.signalThemeApplied({reducedTransparency:t})}),()=>{n=!0}},i=[e,t],n[0]=e,n[1]=t,n[2]=r,n[3]=i):(r=n[2],i=n[3]),(0,m.useEffect)(r,i);let a,o;n[4]===e?(a=n[5],o=n[6]):(a=()=>{if(!e)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`),n=t=>{e.signalThemeApplied({reducedTransparency:t.matches})};return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}},o=[e],n[4]=e,n[5]=a,n[6]=o),(0,m.useEffect)(a,o)}function Iu(e){let t=(0,re.c)(5),{setTheme:n}=i(),r;t[0]!==n||t[1]!==e?(r=()=>{(e===`light`||e===`dark`||e===`system`)&&n(e)},t[0]=n,t[1]=e,t[2]=r):r=t[2];let a;t[3]===e?a=t[4]:(a=[e],t[3]=e,t[4]=a),(0,m.useEffect)(r,a)}var Lu=n();function Ru(e,t,n,r){console.warn(JSON.stringify({event:`ok-${e}-${n}`,docName:t,code:r?.code,reason:r?.reason??void 0}))}function zu(e,t,n,r){let i=new ki,a=new Au({url:e,name:t,document:i,token:Pu(null,r,null),onDisconnect:({event:e})=>Ru(`config-provider`,t,`disconnect`,e),onClose:({event:e})=>Ru(`config-provider`,t,`close`,e)}),o=s(a,n);return{binding:o,config:o.current(),cleanup:()=>{o.dispose(),a.destroy(),i.destroy()}}}function Bu(e,t){let n=new ki,r=new Au({url:e,name:f,document:n,token:Pu(null,t,null),onDisconnect:({event:e})=>Ru(`okignore-provider`,f,`disconnect`,e),onClose:({event:e})=>Ru(`okignore-provider`,f,`close`,e)}),i=a(r);return{binding:i,provider:r,cleanup:()=>{i.dispose(),r.destroy(),n.destroy()}}}function Vu(e){let t=(0,re.c)(24),{collabUrl:n,children:r}=e,i=le(),[a,o]=(0,m.useState)(null),[s,f]=(0,m.useState)(null),[p,ee]=(0,m.useState)(null),[ne,ie]=(0,m.useState)(null),ae,oe;t[0]!==n||t[1]!==i?(ae=()=>{if(n===null)return;let e=zu(n,c,`user`,i),t=zu(n,d,`project`,i),r=zu(n,u,`project-local`,i),a=Bu(n,i);o({binding:e.binding,config:e.config,synced:e.binding.hasSynced()}),f({binding:t.binding,config:t.config,synced:t.binding.hasSynced()}),ee({binding:r.binding,config:r.config,synced:r.binding.hasSynced()}),ie({binding:a.binding,synced:!1});let s=e.binding.subscribe(t=>{o(n=>n?.binding===e.binding?{...n,config:t}:n)}),l=e.binding.subscribeSynced(()=>{o(t=>t?.binding===e.binding?{...t,synced:!0}:t)}),p=t.binding.subscribe(e=>{f(n=>n?.binding===t.binding?{...n,config:e}:n)}),te=t.binding.subscribeSynced(()=>{f(e=>e?.binding===t.binding?{...e,synced:!0}:e)}),ne=r.binding.subscribe(e=>{ee(t=>t?.binding===r.binding?{...t,config:e}:t)}),re=r.binding.subscribeSynced(()=>{ee(e=>e?.binding===r.binding?{...e,synced:!0}:e)}),m=()=>{ie(e=>e?.binding===a.binding?{...e,synced:!0}:e)};return a.provider.on(`synced`,m),()=>{s(),l(),p(),te(),ne(),re(),a.provider.off(`synced`,m);for(let n of[e,t,r,a])try{n.cleanup()}catch(e){console.warn(JSON.stringify({event:`ok-config-provider-cleanup-error`,error:String(e)}))}o(t=>t?.binding===e.binding?null:t),f(e=>e?.binding===t.binding?null:e),ee(e=>e?.binding===r.binding?null:e),ie(e=>e?.binding===a.binding?null:e)}},oe=[n,i],t[0]=n,t[1]=i,t[2]=ae,t[3]=oe):(ae=t[2],oe=t[3]),(0,m.useEffect)(ae,oe);let se;t[4]!==p?.config||t[5]!==s||t[6]!==a?(se=a&&s?l(a.config,s.config,p?.config):null,t[4]=p?.config,t[5]=s,t[6]=a,t[7]=se):se=t[7];let ce=se,h=ce?.appearance?.theme;Iu(h),Fu(typeof window<`u`?window.okDesktop:void 0,h??`system`);let ue=a?.binding??null,g=a?.synced??!1,de=s?.binding??null,fe=p?.binding??null,_=ne?.binding??null,pe=ne?.synced??!1,me=a?.config??null,v=s?.config??null,he=s?.synced??!1,ge=p?.config??null,_e=p?.synced??!1,y;t[8]!==ce||t[9]!==me||t[10]!==v||t[11]!==he||t[12]!==ge||t[13]!==_e||t[14]!==ue||t[15]!==g||t[16]!==de||t[17]!==fe||t[18]!==_||t[19]!==pe?(y={userBinding:ue,userSynced:g,projectBinding:de,projectLocalBinding:fe,okignoreBinding:_,okignoreSynced:pe,userConfig:me,projectConfig:v,projectSynced:he,projectLocalConfig:ge,projectLocalSynced:_e,merged:ce},t[8]=ce,t[9]=me,t[10]=v,t[11]=he,t[12]=ge,t[13]=_e,t[14]=ue,t[15]=g,t[16]=de,t[17]=fe,t[18]=_,t[19]=pe,t[20]=y):y=t[20];let ve=y,ye;return t[21]!==r||t[22]!==ve?(ye=(0,Lu.jsx)(te,{value:ve,children:r}),t[21]=r,t[22]=ve,t[23]=ye):ye=t[23],ye}export{Fe as $,ca as A,Vr as B,fa as C,Ji as D,Xi as E,Sa as F,fn as G,M as H,H as I,Ut as J,tn as K,_o as L,la as M,_i as N,ea as O,da as P,O as Q,Xr as R,R as S,xa as T,Cn as U,Hr as V,xn as W,E as X,zt as Y,D as Z,Gi as _,Au as a,g as at,va as b,q as c,ua as d,x as et,ba as f,fs as g,ss as h,Mu as i,h as it,yi as j,B as k,ki as l,ns as m,Fu as n,ye as nt,K as o,se as ot,Ua as p,Zt as q,Pu as r,_ as rt,js as s,ne as st,Vu as t,xe as tt,J as u,Wi as v,ga as w,Ci as x,ya as y,I as z};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n}from"./compiler-runtime-CVnuRdak.js";import{t as r}from"./react-dom-C-oc-P2K.js";import{l as i,o as a}from"./button-cneJOVxD.js";import{d as o,r as s,s as c,u as l}from"./dist-D9WIglau.js";import{t as u}from"./dist-DfThKWJX.js";var d=e(t(),1),f=n();function p(e){let t=e+`CollectionProvider`,[n,r]=l(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=e=>{let{scope:t,children:n}=e,r=d.useRef(null),i=d.useRef(new Map).current;return(0,f.jsx)(o,{scope:t,itemMap:i,collectionRef:r,children:n})};c.displayName=t;let u=e+`CollectionSlot`,p=a(u),m=d.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,f.jsx)(p,{ref:i(t,s(u,n).collectionRef),children:r})});m.displayName=u;let h=e+`CollectionItemSlot`,g=`data-radix-collection-item`,_=a(h),v=d.forwardRef((e,t)=>{let{scope:n,children:r,...a}=e,o=d.useRef(null),c=i(t,o),l=s(h,n);return d.useEffect(()=>(l.itemMap.set(o,{ref:o,...a}),()=>void l.itemMap.delete(o))),(0,f.jsx)(_,{[g]:``,ref:c,children:r})});v.displayName=h;function y(t){let n=s(e+`CollectionConsumer`,t);return d.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${g}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:c,Slot:m,ItemSlot:v},y,r]}var m=d.createContext(void 0);function h(e){let t=d.useContext(m);return e||t||`ltr`}var g=[`top`,`right`,`bottom`,`left`],_=[`start`,`end`],v=g.reduce((e,t)=>e.concat(t,t+`-`+_[0],t+`-`+_[1]),[]),y=Math.min,b=Math.max,x=Math.round,S=Math.floor,C=e=>({x:e,y:e}),w={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function T(e,t,n){return b(e,y(t,n))}function E(e,t){return typeof e==`function`?e(t):e}function D(e){return e.split(`-`)[0]}function O(e){return e.split(`-`)[1]}function k(e){return e===`x`?`y`:`x`}function A(e){return e===`y`?`height`:`width`}function j(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function M(e){return k(j(e))}function N(e,t,n){n===void 0&&(n=!1);let r=O(e),i=M(e),a=A(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=V(o)),[o,V(o)]}function P(e){let t=V(e);return[F(e),t,F(t)]}function F(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var I=[`left`,`right`],L=[`right`,`left`],R=[`top`,`bottom`],z=[`bottom`,`top`];function ee(e,t,n){switch(e){case`top`:case`bottom`:return n?t?L:I:t?I:L;case`left`:case`right`:return t?R:z;default:return[]}}function B(e,t,n,r){let i=O(e),a=ee(D(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(F)))),a}function V(e){let t=D(e);return w[t]+e.slice(t.length)}function te(e){return{top:0,right:0,bottom:0,left:0,...e}}function ne(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:te(e)}function H(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function re(e,t,n){let{reference:r,floating:i}=e,a=j(t),o=M(t),s=A(o),c=D(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(O(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function ie(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=E(t,e),p=ne(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=H(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=H(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ae=50,oe=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:ie},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=re(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<ae&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=re(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},se=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=E(e,t)||{};if(l==null)return{};let d=ne(u),f={x:n,y:r},p=M(i),m=A(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,b=g?`clientHeight`:`clientWidth`,x=a.reference[m]+a.reference[p]-f[p]-a.floating[m],S=f[p]-a.reference[p],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),w=C?C[b]:0;(!w||!await(o.isElement==null?void 0:o.isElement(C)))&&(w=s.floating[b]||a.floating[m]);let D=x/2-S/2,k=w/2-h[m]/2-1,j=y(d[_],k),N=y(d[v],k),P=j,F=w-h[m]-N,I=w/2-h[m]/2+D,L=T(P,I,F),R=!c.arrow&&O(i)!=null&&I!==L&&a.reference[m]/2-(I<P?j:N)-h[m]/2<0,z=R?I<P?I-P:I-F:0;return{[p]:f[p]+z,data:{[p]:L,centerOffset:I-L-z,...R&&{alignmentOffset:z}},reset:R}}});function ce(e,t,n){return(e?[...n.filter(t=>O(t)===e),...n.filter(t=>O(t)!==e)]:n.filter(e=>D(e)===e)).filter(n=>e?O(n)===e||(t?F(n)!==n:!1):!0)}var le=function(e){return e===void 0&&(e={}),{name:`autoPlacement`,options:e,async fn(t){let{rects:n,middlewareData:r,placement:i,platform:a,elements:o}=t,{crossAxis:s=!1,alignment:c,allowedPlacements:l=v,autoAlignment:u=!0,...d}=E(e,t),f=c!==void 0||l===v?ce(c||null,u,l):l,p=await a.detectOverflow(t,d),m=r.autoPlacement?.index||0,h=f[m];if(h==null)return{};let g=N(h,n,await(a.isRTL==null?void 0:a.isRTL(o.floating)));if(i!==h)return{reset:{placement:f[0]}};let _=[p[D(h)],p[g[0]],p[g[1]]],y=[...r.autoPlacement?.overflows||[],{placement:h,overflows:_}],b=f[m+1];if(b)return{data:{index:m+1,overflows:y},reset:{placement:b}};let x=y.map(e=>{let t=O(e.placement);return[e.placement,t&&s?e.overflows.slice(0,2).reduce((e,t)=>e+t,0):e.overflows[0],e.overflows]}).sort((e,t)=>e[1]-t[1]),S=x.filter(e=>e[2].slice(0,O(e[0])?2:3).every(e=>e<=0))[0]?.[0]||x[0][0];return S===i?{}:{data:{index:m+1,overflows:y},reset:{placement:S}}}}},ue=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=E(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=D(r),_=j(o),v=D(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[V(o)]:P(o)),x=p!==`none`;!d&&x&&b.push(...B(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=N(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==j(t))||T.every(e=>j(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=j(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function de(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function fe(e){return g.some(t=>e[t]>=0)}var pe=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=E(e,t);switch(i){case`referenceHidden`:{let e=de(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:fe(e)}}}case`escaped`:{let e=de(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:fe(e)}}}default:return{}}}}};function me(e){let t=y(...e.map(e=>e.left)),n=y(...e.map(e=>e.top)),r=b(...e.map(e=>e.right)),i=b(...e.map(e=>e.bottom));return{x:t,y:n,width:r-t,height:i-n}}function he(e){let t=e.slice().sort((e,t)=>e.y-t.y),n=[],r=null;for(let e=0;e<t.length;e++){let i=t[e];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(e=>H(me(e)))}var ge=function(e){return e===void 0&&(e={}),{name:`inline`,options:e,async fn(t){let{placement:n,elements:r,rects:i,platform:a,strategy:o}=t,{padding:s=2,x:c,y:l}=E(e,t),u=Array.from(await(a.getClientRects==null?void 0:a.getClientRects(r.reference))||[]),d=he(u),f=H(me(u)),p=ne(s);function m(){if(d.length===2&&d[0].left>d[1].right&&c!=null&&l!=null)return d.find(e=>c>e.left-p.left&&c<e.right+p.right&&l>e.top-p.top&&l<e.bottom+p.bottom)||f;if(d.length>=2){if(j(n)===`y`){let e=d[0],t=d[d.length-1],r=D(n)===`top`,i=e.top,a=t.bottom,o=r?e.left:t.left,s=r?e.right:t.right;return{top:i,bottom:a,left:o,right:s,width:s-o,height:a-i,x:o,y:i}}let e=D(n)===`left`,t=b(...d.map(e=>e.right)),r=y(...d.map(e=>e.left)),i=d.filter(n=>e?n.left===r:n.right===t),a=i[0].top,o=i[i.length-1].bottom,s=r,c=t;return{top:a,bottom:o,left:s,right:c,width:c-s,height:o-a,x:s,y:a}}return f}let h=await a.getElementRects({reference:{getBoundingClientRect:m},floating:r.floating,strategy:o});return i.reference.x!==h.reference.x||i.reference.y!==h.reference.y||i.reference.width!==h.reference.width||i.reference.height!==h.reference.height?{reset:{rects:h}}:{}}}},_e=new Set([`left`,`top`]);async function ve(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=D(n),s=O(n),c=j(n)===`y`,l=_e.has(o)?-1:1,u=a&&c?-1:1,d=E(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ye=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await ve(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},be=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=E(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=j(D(i)),p=k(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=T(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=T(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},xe=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=E(e,t),u={x:n,y:r},d=j(i),f=k(d),p=u[f],m=u[d],h=E(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=_e.has(D(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Se=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=E(e,t),u=await o.detectOverflow(t,l),d=D(i),f=O(i),p=j(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,x=m-u.left-u.right,S=y(h-u[g],v),C=y(m-u[_],x),w=!t.middlewareData.shift,T=S,k=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=v),w&&!f){let e=b(u.left,0),t=b(u.right,0),n=b(u.top,0),r=b(u.bottom,0);p?k=m-2*(e!==0||t!==0?e+t:b(u.left,u.right)):T=h-2*(n!==0||r!==0?n+r:b(u.top,u.bottom))}await c({...t,availableWidth:k,availableHeight:T});let A=await o.getDimensions(s.floating);return m!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function Ce(){return typeof window<`u`}function U(e){return we(e)?(e.nodeName||``).toLowerCase():`#document`}function W(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function G(e){return((we(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function we(e){return Ce()?e instanceof Node||e instanceof W(e).Node:!1}function K(e){return Ce()?e instanceof Element||e instanceof W(e).Element:!1}function q(e){return Ce()?e instanceof HTMLElement||e instanceof W(e).HTMLElement:!1}function Te(e){return!Ce()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof W(e).ShadowRoot}function Ee(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=X(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function De(e){return/^(table|td|th)$/.test(U(e))}function Oe(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ke=/transform|translate|scale|rotate|perspective|filter/,Ae=/paint|layout|strict|content/,J=e=>!!e&&e!==`none`,je;function Me(e){let t=K(e)?X(e):e;return J(t.transform)||J(t.translate)||J(t.scale)||J(t.rotate)||J(t.perspective)||!Pe()&&(J(t.backdropFilter)||J(t.filter))||ke.test(t.willChange||``)||Ae.test(t.contain||``)}function Ne(e){let t=Z(e);for(;q(t)&&!Y(t);){if(Me(t))return t;if(Oe(t))return null;t=Z(t)}return null}function Pe(){return je??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),je}function Y(e){return/^(html|body|#document)$/.test(U(e))}function X(e){return W(e).getComputedStyle(e)}function Fe(e){return K(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Z(e){if(U(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Te(e)&&e.host||G(e);return Te(t)?t.host:t}function Ie(e){let t=Z(e);return Y(t)?e.ownerDocument?e.ownerDocument.body:e.body:q(t)&&Ee(t)?t:Ie(t)}function Le(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ie(e),i=r===e.ownerDocument?.body,a=W(r);if(i){let e=Re(a);return t.concat(a,a.visualViewport||[],Ee(r)?r:[],e&&n?Le(e):[])}else return t.concat(r,Le(r,[],n))}function Re(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ze(e){let t=X(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=q(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=x(n)!==a||x(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Be(e){return K(e)?e:e.contextElement}function Q(e){let t=Be(e);if(!q(t))return C(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=ze(t),o=(a?x(n.width):n.width)/r,s=(a?x(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Ve=C(0);function He(e){let t=W(e);return!Pe()||!t.visualViewport?Ve:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ue(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==W(e)?!1:t}function $(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Be(e),o=C(1);t&&(r?K(r)&&(o=Q(r)):o=Q(e));let s=Ue(a,n,r)?He(a):C(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=W(a),t=r&&K(r)?W(r):r,n=e,i=Re(n);for(;i&&r&&t!==n;){let e=Q(i),t=i.getBoundingClientRect(),r=X(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=W(i),i=Re(n)}}return H({width:u,height:d,x:c,y:l})}function We(e,t){let n=Fe(e).scrollLeft;return t?t.left+n:$(G(e)).left+n}function Ge(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-We(e,n),y:n.top+t.scrollTop}}function Ke(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=G(r),s=t?Oe(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=C(1),u=C(0),d=q(r);if((d||!d&&!a)&&((U(r)!==`body`||Ee(o))&&(c=Fe(r)),d)){let e=$(r);l=Q(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ge(o,c):C(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function qe(e){return Array.from(e.getClientRects())}function Je(e){let t=G(e),n=Fe(e),r=e.ownerDocument.body,i=b(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=b(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+We(e),s=-n.scrollTop;return X(r).direction===`rtl`&&(o+=b(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Ye=25;function Xe(e,t){let n=W(e),r=G(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Pe();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=We(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Ye&&(a-=o)}else l<=Ye&&(a+=l);return{width:a,height:o,x:s,y:c}}function Ze(e,t){let n=$(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=q(e)?Q(e):C(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Qe(e,t,n){let r;if(t===`viewport`)r=Xe(e,n);else if(t===`document`)r=Je(G(e));else if(K(t))r=Ze(t,n);else{let n=He(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return H(r)}function $e(e,t){let n=Z(e);return n===t||!K(n)||Y(n)?!1:X(n).position===`fixed`||$e(n,t)}function et(e,t){let n=t.get(e);if(n)return n;let r=Le(e,[],!1).filter(e=>K(e)&&U(e)!==`body`),i=null,a=X(e).position===`fixed`,o=a?Z(e):e;for(;K(o)&&!Y(o);){let t=X(o),n=Me(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||Ee(o)&&!n&&$e(e,o))?r=r.filter(e=>e!==o):i=t,o=Z(o)}return t.set(e,r),r}function tt(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Oe(t)?[]:et(t,this._c):[].concat(n),r],o=Qe(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Qe(t,a[e],i);s=b(n.top,s),c=y(n.right,c),l=y(n.bottom,l),u=b(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function nt(e){let{width:t,height:n}=ze(e);return{width:t,height:n}}function rt(e,t,n){let r=q(t),i=G(t),a=n===`fixed`,o=$(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=C(0);function l(){c.x=We(i)}if(r||!r&&!a)if((U(t)!==`body`||Ee(i))&&(s=Fe(t)),r){let e=$(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?Ge(i,s):C(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function it(e){return X(e).position===`static`}function at(e,t){if(!q(e)||X(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return G(e)===n&&(n=n.ownerDocument.body),n}function ot(e,t){let n=W(e);if(Oe(e))return n;if(!q(e)){let t=Z(e);for(;t&&!Y(t);){if(K(t)&&!it(t))return t;t=Z(t)}return n}let r=at(e,t);for(;r&&De(r)&&it(r);)r=at(r,t);return r&&Y(r)&&it(r)&&!Me(r)?n:r||Ne(e)||n}var st=async function(e){let t=this.getOffsetParent||ot,n=this.getDimensions,r=await n(e.floating);return{reference:rt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ct(e){return X(e).direction===`rtl`}var lt={convertOffsetParentRelativeRectToViewportRelativeRect:Ke,getDocumentElement:G,getClippingRect:tt,getOffsetParent:ot,getElementRects:st,getClientRects:qe,getDimensions:nt,getScale:Q,isElement:K,isRTL:ct};function ut(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function dt(e,t){let n=null,r,i=G(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=S(d),h=S(i.clientWidth-(u+f)),g=S(i.clientHeight-(d+p)),_=S(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:b(0,y(1,c))||1},x=!0;function C(t){let n=t[0].intersectionRatio;if(n!==c){if(!x)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!ut(l,e.getBoundingClientRect())&&o(),x=!1}try{n=new IntersectionObserver(C,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,v)}n.observe(e)}return o(!0),a}function ft(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Be(e),u=i||a?[...l?Le(l):[],...t?Le(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?dt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?$(e):null;c&&g();function g(){let t=$(e);h&&!ut(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var pt=ye,mt=le,ht=be,gt=ue,_t=Se,vt=pe,yt=se,bt=ge,xt=xe,St=(e,t,n)=>{let r=new Map,i={platform:lt,...n},a={...i.platform,_c:r};return oe(e,t,{...i,platform:a})},Ct=e(r(),1),wt=typeof document<`u`?d.useLayoutEffect:function(){};function Tt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Tt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Tt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Et(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Dt(e,t){let n=Et(e);return Math.round(t*n)/n}function Ot(e){let t=d.useRef(e);return wt(()=>{t.current=e}),t}function kt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,f]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=d.useState(r);Tt(p,r)||m(r);let[h,g]=d.useState(null),[_,v]=d.useState(null),y=d.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=d.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=d.useRef(null),w=d.useRef(null),T=d.useRef(u),E=c!=null,D=Ot(c),O=Ot(i),k=Ot(l),A=d.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),St(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Tt(T.current,t)&&(T.current=t,Ct.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);wt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[l]);let j=d.useRef(!1);wt(()=>(j.current=!0,()=>{j.current=!1}),[]),wt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=d.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=d.useMemo(()=>({reference:x,floating:S}),[x,S]),P=d.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Dt(N.floating,u.x),r=Dt(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Et(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return d.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var At=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:yt({element:r.current,padding:i}).fn(n):r?yt({element:r,padding:i}).fn(n):{}}}},jt=(e,t)=>{let n=pt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mt=(e,t)=>{let n=ht(e);return{name:n.name,fn:n.fn,options:[e,t]}},Nt=(e,t)=>({fn:xt(e).fn,options:[e,t]}),Pt=(e,t)=>{let n=gt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ft=(e,t)=>{let n=_t(e);return{name:n.name,fn:n.fn,options:[e,t]}},It=(e,t)=>{let n=vt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Lt=(e,t)=>{let n=At(e);return{name:n.name,fn:n.fn,options:[e,t]}},Rt=`Arrow`,zt=d.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,f.jsx)(o.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,f.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});zt.displayName=Rt;var Bt=zt,Vt=`Popper`,[Ht,Ut]=l(Vt),[Wt,Gt]=Ht(Vt),Kt=e=>{let{__scopePopper:t,children:n}=e,[r,i]=d.useState(null);return(0,f.jsx)(Wt,{scope:t,anchor:r,onAnchorChange:i,children:n})};Kt.displayName=Vt;var qt=`PopperAnchor`,Jt=d.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...a}=e,s=Gt(qt,n),c=d.useRef(null),l=i(t,c),u=d.useRef(null);return d.useEffect(()=>{let e=u.current;u.current=r?.current||c.current,e!==u.current&&s.onAnchorChange(u.current)}),r?null:(0,f.jsx)(o.div,{...a,ref:l})});Jt.displayName=qt;var Yt=`PopperContent`,[Xt,Zt]=Ht(Yt),Qt=d.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:a=0,align:l=`center`,alignOffset:p=0,arrowPadding:m=0,avoidCollisions:h=!0,collisionBoundary:g=[],collisionPadding:_=0,sticky:v=`partial`,hideWhenDetached:y=!1,updatePositionStrategy:b=`optimized`,onPlaced:x,...S}=e,C=Gt(Yt,n),[w,T]=d.useState(null),E=i(t,e=>T(e)),[D,O]=d.useState(null),k=u(D),A=k?.width??0,j=k?.height??0,M=r+(l===`center`?``:`-`+l),N=typeof _==`number`?_:{top:0,right:0,bottom:0,left:0,..._},P=Array.isArray(g)?g:[g],F=P.length>0,I={padding:N,boundary:P.filter(nn),altBoundary:F},{refs:L,floatingStyles:R,placement:z,isPositioned:ee,middlewareData:B}=kt({strategy:`fixed`,placement:M,whileElementsMounted:(...e)=>ft(...e,{animationFrame:b===`always`}),elements:{reference:C.anchor},middleware:[jt({mainAxis:a+j,alignmentAxis:p}),h&&Mt({mainAxis:!0,crossAxis:!1,limiter:v===`partial`?Nt():void 0,...I}),h&&Pt({...I}),Ft({...I,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),D&&Lt({element:D,padding:m}),rn({arrowWidth:A,arrowHeight:j}),y&&It({strategy:`referenceHidden`,...I})]}),[V,te]=an(z),ne=s(x);c(()=>{ee&&ne?.()},[ee,ne]);let H=B.arrow?.x,re=B.arrow?.y,ie=B.arrow?.centerOffset!==0,[ae,oe]=d.useState();return c(()=>{w&&oe(window.getComputedStyle(w).zIndex)},[w]),(0,f.jsx)(`div`,{ref:L.setFloating,"data-radix-popper-content-wrapper":``,style:{...R,transform:ee?R.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(` `),...B.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,f.jsx)(Xt,{scope:n,placedSide:V,onArrowChange:O,arrowX:H,arrowY:re,shouldHideArrow:ie,children:(0,f.jsx)(o.div,{"data-side":V,"data-align":te,...S,ref:E,style:{...S.style,animation:ee?void 0:`none`}})})})});Qt.displayName=Yt;var $t=`PopperArrow`,en={top:`bottom`,right:`left`,bottom:`top`,left:`right`},tn=d.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Zt($t,n),a=en[i.placedSide];return(0,f.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,f.jsx)(Bt,{...r,ref:t,style:{...r.style,display:`block`}})})});tn.displayName=$t;function nn(e){return e!==null}var rn=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=an(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function an(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var on=Kt,sn=Jt,cn=Qt,ln=tn;export{p as _,Ut as a,ft as c,vt as d,bt as f,h as g,_t as h,on as i,St as l,ht as m,ln as n,yt as o,pt as p,cn as r,mt as s,sn as t,gt as u};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{n as t}from"./compiler-runtime-CVnuRdak.js";import{s as n}from"./dist-D9WIglau.js";var r=e(t(),1);function i(e){let[t,i]=r.useState(void 0);return n(()=>{if(e){i({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let n=t[0],r,a;if(`borderBoxSize`in n){let e=n.borderBoxSize,t=Array.isArray(e)?e[0]:e;r=t.inlineSize,a=t.blockSize}else r=e.offsetWidth,a=e.offsetHeight;i({width:r,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else i(void 0)},[e]),t}export{i as t};