@inkeep/open-knowledge 0.0.0-dev-20260501170533 → 0.0.0-dev-20260501181216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +5 -5
- package/dist/config-schema.json +25 -0
- package/dist/config.project.schema.json +25 -0
- package/dist/config.user.schema.json +25 -0
- package/dist/constants-BnNhFY0P.mjs +2 -0
- package/dist/{dist-oDoSs1Bl.mjs → dist-BmX1Ns7C.mjs} +2 -2
- package/dist/{dist-BVnVlgjQ.mjs → dist-C5mH5cvM.mjs} +1 -1
- package/dist/{dist-CDuTCUx1.mjs → dist-CQ3cd3s_.mjs} +2 -2
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-CPq6B11A.mjs → init-CAeQdWL6.mjs} +3 -3
- package/dist/init-CCYsXS_y.mjs +1 -0
- package/dist/init-CIM4I1tW.mjs +1 -0
- package/dist/{init-Bf7LOYAr.mjs → init-DHwfj3AW.mjs} +2 -2
- package/dist/{loader-C79dNoU-.mjs → loader-CC_RQ-w2.mjs} +2 -2
- package/dist/loader-DqreB0_J.mjs +1 -0
- package/dist/paths-1NW3UxwQ.mjs +1 -0
- package/dist/paths-BwrGhrga.mjs +2 -0
- package/dist/{preview-AXEdeZ4w.mjs → preview-B-rYWHOQ.mjs} +2 -2
- package/dist/preview-Sf_RYYpl.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-CCJOMAyp.js → ActivityModeContent-Cdl0frU2.js} +1 -1
- package/dist/public/assets/{DocumentContext-BHFNw5NZ.js → DocumentContext-BRyrYElZ.js} +1 -1
- package/dist/public/assets/{GraphPanel-BuZEMdl-.js → GraphPanel-BH5vs7kB.js} +1 -1
- package/dist/public/assets/{OutlinePanel-CnKUM65X.js → OutlinePanel-BcdH74Qw.js} +1 -1
- package/dist/public/assets/{SettingsPane-B3rEEyMP.js → SettingsPane-rdUN7cCp.js} +1 -1
- package/dist/public/assets/{SourceEditor-CE_X9auW.js → SourceEditor-Df4RyC-2.js} +1 -1
- package/dist/public/assets/{config-validation-events-DqfR4UtM.js → config-validation-events-CWaXc07D.js} +1 -1
- package/dist/public/assets/{index-NVu982rh.js → index-DN_1M53F.js} +70 -70
- package/dist/public/assets/{target-navigation-intent-1238Z_HW.js → target-navigation-intent-CIITpiPs.js} +1 -1
- package/dist/public/assets/{toggle-group-C5MXNna8.js → toggle-group-1sl8rMnA.js} +1 -1
- package/dist/public/assets/{tooltip-BMlqVI54.js → tooltip-CFeKxs4p.js} +1 -1
- package/dist/public/index.html +7 -7
- package/dist/schemas/v0/config.project.schema.json +25 -0
- package/dist/schemas/v0/config.user.schema.json +25 -0
- package/dist/{server-Cb1yd7Zc.mjs → server-CJdOKLcU.mjs} +2 -2
- package/dist/src-8G0QyHkY.mjs +1 -0
- package/dist/start-BlAW3ifD.mjs +1 -0
- package/dist/{start-Dl1pApAn.mjs → start-CrKpyaZC.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-B8HpPaWG.mjs +0 -2
- package/dist/init-BhfL8UL0.mjs +0 -1
- package/dist/init-DkzHwyzJ.mjs +0 -1
- package/dist/loader-5abUX3Eq.mjs +0 -1
- package/dist/paths-BIsyTDX6.mjs +0 -1
- package/dist/paths-Drz5vBVF.mjs +0 -2
- package/dist/preview-DUYE2XxR.mjs +0 -1
- package/dist/src-CPe0c6hz.mjs +0 -1
- package/dist/start-COO3npTl.mjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-C3u7R0q7.js","./dist-dkPJvrfr.js","./chunk-DECur_0Z.js","./w3c-keyname-B5t0fahT.js","./dist-RVD4DzGH.js","./dist-Dtie9-Ui.js","./dist-C82hC0q7.js","./dist-oNAFjGrp.js","./dist-mXs-_OvZ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e,t}from"./chunk-DECur_0Z.js";import{i as n,n as r,t as i}from"./propagation-api-LnD10wq2.js";import{n as a,r as o,t as s}from"./compiler-runtime-Y11fyRVL.js";import{$ as c,$t as l,An as u,At as d,B as f,C as p,Cn as m,Ct as h,Dt as g,E as _,En as v,Et as y,F as b,Ft as x,G as S,Gn as C,H as w,Hn as T,It as E,Jn as D,Jt as O,K as k,L as A,Ln as j,M,Mn as N,N as P,Nn as F,Nt as I,Ot as L,P as R,Pn as z,Pt as B,Qt as V,R as H,Rn as U,S as ee,Sn as te,St as ne,Tn as re,Tt as ie,U as ae,Un as oe,Ut as se,V as ce,Vt as le,W as ue,Wn as de,Xn as fe,Xt as pe,Yt as me,_n as he,_t as ge,a as _e,b as ve,bn as ye,c as be,cn as xe,d as Se,dn as Ce,dt as we,en as Te,et as Ee,f as De,fn as Oe,gn as ke,h as Ae,hn as je,i as Me,in as Ne,j as Pe,jn as Fe,k as Ie,lt as Le,m as Re,mn as ze,mt as Be,n as Ve,nn as He,nt as Ue,pn as We,rn as Ge,s as Ke,sn as qe,st as Je,t as Ye,tn as Xe,tt as Ze,u as Qe,un as $e,ut as et,v as tt,vn as nt,vt as rt,wn as it,wt as at,x as ot,xn as st,y as ct,yn as lt,yt as ut,z as dt,zn as ft,zt as pt}from"./toggle-group-C5MXNna8.js";import{C as mt,S as ht,_ as gt,a as _t,b as vt,c as yt,d as bt,g as xt,i as St,l as Ct,m as wt,p as Tt,r as Et,s as Dt,t as Ot,u as kt,x as At}from"./button-Dyz7QGIk.js";import{S as jt,_ as Mt,a as Nt,c as Pt,d as Ft,f as It,g as Lt,h as Rt,i as zt,m as Bt,n as Vt,o as Ht,p as Ut,s as Wt,t as Gt,u as Kt,v as qt,x as Jt,y as Yt}from"./dialog-FUclf-NK.js";import{B as Xt,Bt as Zt,D as Qt,Et as $t,G as en,H as tn,I as nn,K as rn,L as W,M as an,N as on,Nt as sn,P as cn,Pt as ln,Tt as un,U as dn,V as fn,W as pn,Y as mn,Z as hn,_ as gn,a as _n,b as vn,f as yn,h as bn,i as xn,j as Sn,jt as Cn,k as wn,kt as Tn,l as En,lt as Dn,o as On,p as kn,q as An,r as jn,s as Mn,t as Nn,u as Pn,w as Fn,wt as In,y as Ln,z as Rn}from"./dist-dkPJvrfr.js";import{a as zn,c as Bn,s as Vn,t as Hn}from"./dist-oNAFjGrp.js";import{i as Un,n as Wn,r as Gn,t as Kn}from"./dist-RVD4DzGH.js";var qn=ht(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Jn=ht(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Yn=ht(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),Xn=ht(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Zn=ht(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Qn=ht(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),$n=ht(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),er=ht(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),tr=ht(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),nr=ht(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),rr=ht(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),ir=ht(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),ar=ht(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),or=ht(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),sr=ht(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),cr=ht(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),lr=ht(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),ur=ht(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),dr=ht(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),fr=ht(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),pr=ht(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),mr=ht(`message-square-warning`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]),hr=ht(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),gr=ht(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),_r=ht(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),vr=ht(`quote`,[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]),yr=ht(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),br=ht(`square-play`,[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}]]),xr=ht(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),Sr=ht(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Cr=ht(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),wr=ht(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),G=e(a(),1),K=o(),Tr=`Collapsible`,[Er,Dr]=Tt(Tr),[Or,kr]=Er(Tr),Ar=G.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=Ct({prop:r,defaultProp:i??!1,onChange:o,caller:Tr});return(0,K.jsx)(Or,{scope:n,disabled:a,contentId:Dt(),open:c,onOpenToggle:G.useCallback(()=>l(e=>!e),[l]),children:(0,K.jsx)(wt.div,{"data-state":Ir(c),"data-disabled":a?``:void 0,...s,ref:t})})});Ar.displayName=Tr;var jr=`CollapsibleTrigger`,Mr=G.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=kr(jr,n);return(0,K.jsx)(wt.button,{type:`button`,"aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Ir(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:bt(e.onClick,i.onOpenToggle)})});Mr.displayName=jr;var Nr=`CollapsibleContent`,Pr=G.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=kr(Nr,e.__scopeCollapsible);return(0,K.jsx)(yt,{present:n||i.open,children:({present:e})=>(0,K.jsx)(Fr,{...r,ref:t,present:e})})});Pr.displayName=Nr;var Fr=G.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=kr(Nr,n),[s,c]=G.useState(r),l=G.useRef(null),u=vt(t,l),d=G.useRef(0),f=d.current,p=G.useRef(0),m=p.current,h=o.open||s,g=G.useRef(h),_=G.useRef(void 0);return G.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),kt(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,K.jsx)(wt.div,{"data-state":Ir(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function Ir(e){return e?`open`:`closed`}var Lr=Ar,Rr=Mr,zr=Pr,Br=t((e=>{var t=a();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),a=r[0].inst,l=r[1];return s(function(){a.value=n,a.getSnapshot=t,u(a)&&l({inst:a})},[e,n,t]),o(function(){return u(a)&&l({inst:a}),e(function(){u(a)&&l({inst:a})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Vr=t(((e,t)=>{t.exports=Br()}));function Hr(e){let t=G.useRef({value:e,previous:e});return G.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ur=`Popover`,[Wr,Gr]=Tt(Ur,[z]),Kr=z(),[qr,Jr]=Wr(Ur),Yr=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Kr(t),c=G.useRef(null),[l,u]=G.useState(!1),[d,f]=Ct({prop:r,defaultProp:i??!1,onChange:a,caller:Ur});return(0,K.jsx)(F,{...s,children:(0,K.jsx)(qr,{scope:t,contentId:Dt(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:G.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:G.useCallback(()=>u(!0),[]),onCustomAnchorRemove:G.useCallback(()=>u(!1),[]),modal:o,children:n})})};Yr.displayName=Ur;var Xr=`PopoverAnchor`,Zr=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Jr(Xr,n),a=Kr(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return G.useEffect(()=>(o(),()=>s()),[o,s]),(0,K.jsx)(u,{...a,...r,ref:t})});Zr.displayName=Xr;var Qr=`PopoverTrigger`,$r=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Jr(Qr,n),a=Kr(n),o=vt(t,i.triggerRef),s=(0,K.jsx)(wt.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":mi(i.open),...r,ref:o,onClick:bt(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,K.jsx)(u,{asChild:!0,...a,children:s})});$r.displayName=Qr;var ei=`PopoverPortal`,[ti,ni]=Wr(ei,{forceMount:void 0}),ri=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Jr(ei,t);return(0,K.jsx)(ti,{scope:t,forceMount:n,children:(0,K.jsx)(yt,{present:n||a.open,children:(0,K.jsx)(St,{asChild:!0,container:i,children:r})})})};ri.displayName=ei;var ii=`PopoverContent`,ai=G.forwardRef((e,t)=>{let n=ni(ii,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Jr(ii,e.__scopePopover);return(0,K.jsx)(yt,{present:r||a.open,children:a.modal?(0,K.jsx)(si,{...i,ref:t}):(0,K.jsx)(ci,{...i,ref:t})})});ai.displayName=ii;var oi=gt(`PopoverContent.RemoveScroll`),si=G.forwardRef((e,t)=>{let n=Jr(ii,e.__scopePopover),r=G.useRef(null),i=vt(t,r),a=G.useRef(!1);return G.useEffect(()=>{let e=r.current;if(e)return Lt(e)},[]),(0,K.jsx)(Mt,{as:oi,allowPinchZoom:!0,children:(0,K.jsx)(li,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:bt(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:bt(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:bt(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),ci=G.forwardRef((e,t)=>{let n=Jr(ii,e.__scopePopover),r=G.useRef(!1),i=G.useRef(!1);return(0,K.jsx)(li,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),li=G.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Jr(ii,n),p=Kr(n);return qt(),(0,K.jsx)(Yt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,K.jsx)(_t,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,K.jsx)(N,{"data-state":mi(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),ui=`PopoverClose`,di=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Jr(ui,n);return(0,K.jsx)(wt.button,{type:`button`,...r,ref:t,onClick:bt(e.onClick,()=>i.onOpenChange(!1))})});di.displayName=ui;var fi=`PopoverArrow`,pi=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Kr(n);return(0,K.jsx)(Fe,{...i,...r,ref:t})});pi.displayName=fi;function mi(e){return e?`open`:`closed`}var hi=Yr,gi=Zr,_i=$r,vi=ri,yi=ai,bi=`Switch`,[xi,Si]=Tt(bi),[Ci,wi]=xi(bi),Ti=G.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=G.useState(null),m=vt(t,e=>p(e)),h=G.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=Ct({prop:i,defaultProp:a??!1,onChange:l,caller:bi});return(0,K.jsxs)(Ci,{scope:n,checked:_,disabled:s,children:[(0,K.jsx)(wt.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Ai(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:bt(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,K.jsx)(ki,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Ti.displayName=bi;var Ei=`SwitchThumb`,Di=G.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=wi(Ei,n);return(0,K.jsx)(wt.span,{"data-state":Ai(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});Di.displayName=Ei;var Oi=`SwitchBubbleInput`,ki=G.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=G.useRef(null),s=vt(o,a),c=Hr(n),l=C(t);return G.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,K.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});ki.displayName=Oi;function Ai(e){return e?`checked`:`unchecked`}var ji=Ti,Mi=Di,Ni=e(mt(),1),q=s();function Pi(e){let t=(0,q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,type:a,ref:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=Et(`h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,n),t[5]=n,t[6]=o);let s;return t[7]!==r||t[8]!==i||t[9]!==o||t[10]!==a?(s=(0,K.jsx)(`input`,{type:a,ref:i,"data-slot":`input`,className:o,...r}),t[7]=r,t[8]=i,t[9]=o,t[10]=a,t[11]=s):s=t[11],s}var Fi=Vr(),Ii=At(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3! font-mono uppercase`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,warning:`bg-yellow-500/10 text-yellow-600 [a]:hover:bg-yellow-500/20`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`,dashed:`border-dashed border-border text-muted-foreground rounded-sm`}},defaultVariants:{variant:`default`}});function Li(e){let t=(0,q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,variant:i,asChild:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a!==void 0&&a?xt:`span`,c;t[5]!==n||t[6]!==o?(c=Et(Ii({variant:o}),n),t[5]=n,t[6]=o,t[7]=c):c=t[7];let l;return t[8]!==s||t[9]!==r||t[10]!==c||t[11]!==o?(l=(0,K.jsx)(s,{"data-slot":`badge`,"data-variant":o,className:c,...r}),t[8]=s,t[9]=r,t[10]=c,t[11]=o,t[12]=l):l=t[12],l}function Ri(e){let t=e.split(`/`);return t.length<2?`ok`:`${t[0]}/${t[1]}`}function zi(e){if(!e)return;let t=Object.entries(e);if(t.length!==0)return t.map(([e,t])=>{if(t==null)return[e,String(t)];if(typeof t==`string`)return[e,t];if(typeof t==`number`||typeof t==`boolean`)return[e,String(t)];try{return[e,JSON.stringify(t)]}catch{return[e,`[unserializable]`]}})}function J(e,t,n){if(typeof performance>`u`||!performance.measure)return;let r=Ri(e),i=zi(t),a={devtools:{dataType:`track-entry`,track:r,...i?{properties:i}:{},...n?.tooltipText?{tooltipText:n.tooltipText}:{}}},o=performance.now(),s=n?.startTime??o,c=n?.duration??Math.max(0,o-s);try{performance.measure(e,{start:s,duration:c,detail:a})}catch{}({...t?{properties:t}:{}})}function Bi(e){let t=(0,q.c)(3),{name:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,K.jsx)(G.Profiler,{id:n,onRender:Vi,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var Vi=(e,t,n,r,i,a)=>{J(`ok/render/${e}`,{phase:t,actualDuration:Math.round(n*1e3)/1e3,baseDuration:Math.round(r*1e3)/1e3},{startTime:i,duration:Math.max(0,a-i)})},{getOwnPropertyNames:Hi,getOwnPropertySymbols:Ui}=Object,{hasOwnProperty:Wi}=Object.prototype;function Gi(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Ki(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function qi(e){return e?.[Symbol.toStringTag]}function Ji(e){return Hi(e).concat(Ui(e))}var Yi=Object.hasOwn||((e,t)=>Wi.call(e,t));function Xi(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var Zi=`__v`,Qi=`__o`,$i=`_owner`,{getOwnPropertyDescriptor:ea,keys:ta}=Object;function na(e,t){return e.byteLength===t.byteLength&&ha(new Uint8Array(e),new Uint8Array(t))}function ra(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function ia(e,t){return e.byteLength===t.byteLength&&ha(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function aa(e,t){return Xi(e.getTime(),t.getTime())}function oa(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function sa(e,t){return e===t}function ca(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var la=Xi;function ua(e,t,n){let r=ta(e),i=r.length;if(ta(t).length!==i)return!1;for(;i-- >0;)if(!_a(e,t,n,r[i]))return!1;return!0}function da(e,t,n){let r=Ji(e),i=r.length;if(Ji(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!_a(e,t,n,a)||(o=ea(e,a),s=ea(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function fa(e,t){return Xi(e.valueOf(),t.valueOf())}function pa(e,t){return e.source===t.source&&e.flags===t.flags}function ma(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function ha(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function ga(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function _a(e,t,n,r){return(r===$i||r===Qi||r===Zi)&&(e.$$typeof||t.$$typeof)?!0:Yi(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var va=`[object ArrayBuffer]`,ya=`[object Arguments]`,ba=`[object Boolean]`,xa=`[object DataView]`,Sa=`[object Date]`,Ca=`[object Error]`,wa=`[object Map]`,Ta=`[object Number]`,Ea=`[object Object]`,Da=`[object RegExp]`,Oa=`[object Set]`,ka=`[object String]`,Aa={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},ja=`[object URL]`,Ma=Object.prototype.toString;function Na({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`?a(h,g,_):!1;let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=Ma.call(h);if(b===Sa)return r(h,g,_);if(b===Da)return u(h,g,_);if(b===wa)return o(h,g,_);if(b===Oa)return d(h,g,_);if(b===Ea)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===ja)return p(h,g,_);if(b===Ca)return i(h,g,_);if(b===ya)return c(h,g,_);if(Aa[b])return f(h,g,_);if(b===va)return e(h,g,_);if(b===xa)return n(h,g,_);if(b===ba||b===Ta||b===ka)return l(h,g,_);if(m){let e=m[b];if(!e){let t=qi(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function Pa({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:na,areArraysEqual:n?da:ra,areDataViewsEqual:ia,areDatesEqual:aa,areErrorsEqual:oa,areFunctionsEqual:sa,areMapsEqual:n?Gi(ca,da):ca,areNumbersEqual:la,areObjectsEqual:n?da:ua,arePrimitiveWrappersEqual:fa,areRegExpsEqual:pa,areSetsEqual:n?Gi(ma,da):ma,areTypedArraysEqual:n?Gi(ha,da):ha,areUrlsEqual:ga,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Ki(r.areArraysEqual),t=Ki(r.areMapsEqual),n=Ki(r.areObjectsEqual),i=Ki(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function Fa(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function Ia({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var La=Ra();Ra({strict:!0}),Ra({circular:!0}),Ra({circular:!0,strict:!0}),Ra({createInternalComparator:()=>Xi}),Ra({strict:!0,createInternalComparator:()=>Xi}),Ra({circular:!0,createInternalComparator:()=>Xi}),Ra({circular:!0,createInternalComparator:()=>Xi,strict:!0});function Ra(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=Na(Pa(e));return Ia({circular:t,comparator:a,createState:r,equals:n?n(a):Fa(a),strict:i})}var za=t((e=>{var t=a(),n=Vr();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,a){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),a!==void 0&&f.hasValue){var t=f.value;if(a(t,e))return c=t}return c=e}if(t=c,i(s,e))return t;var n=r(e);return a!==void 0&&a(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,a]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Ba=t(((e,t)=>{t.exports=za()}))(),Va=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},Ha=({contentComponent:e})=>{let t=(0,Fi.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,K.jsx)(K.Fragment,{children:Object.values(t)})};function Ua(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:Ni.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var Wa=class extends G.Component{constructor(e){super(e),this.editorContentRef=G.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Ua(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{ref:Va(t,this.editorContentRef),...n}),e?.contentComponent&&(0,K.jsx)(Ha,{contentComponent:e.contentComponent})]})}},Ga=(0,G.forwardRef)((e,t)=>{let n=G.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return G.createElement(Wa,{key:n,innerRef:t,...e})}),Ka=G.memo(Ga),qa=typeof window<`u`?G.useLayoutEffect:G.useEffect,Ja=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}}}};function Ya(e){let[t]=(0,G.useState)(()=>new Ja(e.editor)),n=(0,Ba.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??La);return qa(()=>t.watch(e.editor),[e.editor,t]),(0,G.useDebugValue)(n),n}typeof window>`u`||typeof window<`u`&&window.next;var Xa=(0,G.createContext)({editor:null});Xa.Consumer;var Za=()=>(0,G.useContext)(Xa),Qa=(0,G.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),$a=()=>(0,G.useContext)(Qa);function eo({as:e=`div`,...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=$a();return(0,K.jsx)(e,{...t,ref:n,"data-node-view-content":``,style:{whiteSpace:`pre-wrap`,...t.style},children:r})}var to=G.forwardRef((e,t)=>{let{onDragStart:n}=$a();return(0,K.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function no(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function ro(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.forward_ref)`||e.$$typeof.description===`react.forward_ref`))}function io(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.memo)`||e.$$typeof.description===`react.memo`))}function ao(e){if(no(e)||ro(e))return!0;if(io(e)){let t=e.type;if(t)return no(t)||ro(t)}return!1}function oo(){try{if(G.version)return parseInt(G.version.split(`.`)[0],10)>=19}catch{}return!1}var so=class{constructor(e,{editor:t,props:n={},as:r=`div`,className:i=``}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add(`react-renderer`),i&&this.element.classList.add(...i.split(` `)),this.editor.isEditorContentInitialized?(0,Ni.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,i=oo(),a=ao(t),o={...n};o.ref&&!(i||a)&&delete o.ref,!o.ref&&(i||a)&&(o.ref=e=>{this.ref=e}),this.reactElement=(0,K.jsx)(t,{...o}),(e=r?.contentComponent)==null||e.setRenderer(this.id,this)}updateProps(e={}){this.destroyed||(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0,(e=this.editor?.contentComponent)==null||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};G.createContext({markViewContentRef:()=>{}});var co=class extends Te{constructor(e,t,n){if(super(e,t,n),this.selectionRafId=null,this.positionCheckCallback=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?`span`:`div`),this.contentDOMElement.dataset.nodeViewContentReact=``,this.contentDOMElement.dataset.nodeViewWrapper=``,this.contentDOMElement.style.whiteSpace=`inherit`;let e=this.dom.querySelector(`[data-node-view-content]`);if(!e)return;e.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){return r===`storage`?e.storage[t.name]??{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,G.createRef)()};if(!this.component.displayName){let e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute(`data-node-view-wrapper`)&&e.removeAttribute(`data-node-view-wrapper`),e.appendChild(this.contentDOMElement))}},n=this.component,r=(0,G.memo)(e=>(0,K.jsx)(Qa.Provider,{value:t,children:(0,G.createElement)(n,e)}));r.displayName=`ReactNodeView`;let i=this.node.isInline?`span`:`div`;this.options.as&&(i=this.options.as);let{className:a=``}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new so(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on(`selectionUpdate`,this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos(),this.positionCheckCallback=()=>{let e=this.getPos();typeof e!=`number`||e===this.currentPos||(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs==`function`&&this.updateElementAttributes())},Oe(this.editor,this.positionCheckCallback)}get dom(){if(this.renderer.element.firstElementChild&&!this.renderer.element.firstElementChild?.hasAttribute(`data-node-view-wrapper`))throw Error(`Please use the NodeViewWrapper component for your node view.`);return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;let{from:e,to:t}=this.editor.state.selection,n=this.currentPos;if(typeof n==`number`)if(e<=n&&t>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(e,t,n){let r=e=>{this.renderer.updateProps(e),typeof this.options.attrs==`function`&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update==`function`){let i=this.node,a=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:a,newNode:e,newDecorations:t,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}let i=this.getPos();return e===this.node&&this.decorations===t&&this.innerDecorations===n?i===this.currentPos?!0:(this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage,getPos:()=>this.getPos()}),!0):(this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage}),!0)}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add(`ProseMirror-selectednode`)}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove(`ProseMirror-selectednode`)}destroy(){this.renderer.destroy(),this.editor.off(`selectionUpdate`,this.handleSelectionUpdate),this.positionCheckCallback&&=(Xe(this.editor,this.positionCheckCallback),null),this.contentDOMElement=null,this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null)}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs==`function`){let t=this.editor.extensionManager.attributes,n=Ge(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function lo(e,t){return n=>n.editor.contentComponent?new co(e,n,t):{}}var uo=(0,G.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});uo.displayName=`TiptapContext`;var fo=()=>(0,G.useContext)(uo);function po({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,G.useMemo)(()=>({editor:r}),[r]),a=(0,G.useMemo)(()=>({editor:r}),[r]);return(0,K.jsx)(Xa.Provider,{value:a,children:(0,K.jsx)(uo.Provider,{value:i,children:n})})}po.displayName=`Tiptap`;function mo({...e}){let{editor:t}=fo();return(0,K.jsx)(Ka,{editor:t,...e})}mo.displayName=`Tiptap.Content`,Object.assign(po,{Content:mo});var ho=()=>new Map,go=e=>{let t=ho();return e.forEach((e,n)=>{t.set(n,e)}),t},_o=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},vo=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},yo=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},bo=()=>new Set,xo=e=>e[e.length-1],So=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Co=Array.from,wo=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},To=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Eo=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Do=Array.isArray,Oo=class{constructor(){this._observers=ho()}on(e,t){return _o(this._observers,e,bo).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 Co((this._observers.get(e)||ho()).values()).forEach(e=>e(...t))}destroy(){this._observers=ho()}},ko=class{constructor(){this._observers=ho()}on(e,t){_o(this._observers,e,bo).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 Co((this._observers.get(e)||ho()).values()).forEach(e=>e(...t))}destroy(){this._observers=ho()}},Ao=Math.floor,jo=Math.abs,Mo=(e,t)=>e<t?e:t,No=(e,t)=>e>t?e:t;Number.isNaN;var Po=e=>e===0?1/e<0:e<0,Fo=1<<17,Io=1<<18,Lo=1<<19,Ro=1<<20,zo=1<<21,Bo=1<<22,Vo=1<<23,Ho=1<<24,Uo=1<<25,Wo=1<<26,Go=1<<27,Ko=1<<28,qo=1<<29;Fo-1,Io-1,Lo-1,Ro-1,zo-1,Bo-1,Vo-1,Ho-1,Uo-1,Wo-1,Go-1,Ko-1,qo-1;var Jo=2**53-1,Yo=-(2**53-1),Xo=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&Ao(e)===e);Number.isNaN,Number.parseInt;var Zo=String.fromCharCode;String.fromCodePoint,Zo(65535);var Qo=e=>e.toLowerCase(),$o=/^\s*/g,es=e=>e.replace($o,``),ts=/([A-Z])/g,ns=(e,t)=>es(e.replace(ts,e=>`${t}${Qo(e)}`)),rs=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},is=typeof TextEncoder<`u`?new TextEncoder:null,as=is?e=>is.encode(e):rs,os=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});os&&os.decode(new Uint8Array).length===1&&(os=null);var ss=(e,t)=>Eo(t,()=>e).join(``),cs=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},ls=()=>new cs,us=e=>{let t=ls();return e(t),fs(t)},ds=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},fs=e=>{let t=new Uint8Array(ds(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},ps=(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(No(n,t)*2),e.cpos=0)},ms=(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},hs=ms,Y=(e,t)=>{for(;t>127;)ms(e,128|127&t),t=Ao(t/128);ms(e,127&t)},gs=(e,t)=>{let n=Po(t);for(n&&(t=-t),ms(e,(t>63?128:0)|(n?64:0)|63&t),t=Ao(t/64);t>0;)ms(e,(t>127?128:0)|127&t),t=Ao(t/128)},_s=new Uint8Array(3e4),vs=_s.length/3,ys=is&&is.encodeInto?(e,t)=>{if(t.length<vs){let n=is.encodeInto(t,_s).written||0;Y(e,n);for(let t=0;t<n;t++)ms(e,_s[t])}else xs(e,as(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Y(e,r);for(let t=0;t<r;t++)ms(e,n.codePointAt(t))},bs=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Mo(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(No(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},xs=(e,t)=>{Y(e,t.byteLength),bs(e,t)},Ss=(e,t)=>{ps(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Cs=(e,t)=>Ss(e,4).setFloat32(0,t,!1),ws=(e,t)=>Ss(e,8).setFloat64(0,t,!1),Ts=(e,t)=>Ss(e,8).setBigInt64(0,t,!1),Es=new DataView(new ArrayBuffer(4)),Ds=e=>(Es.setFloat32(0,e),Es.getFloat32(0)===e),Os=(e,t)=>{switch(typeof t){case`string`:ms(e,119),ys(e,t);break;case`number`:Xo(t)&&jo(t)<=2147483647?(ms(e,125),gs(e,t)):Ds(t)?(ms(e,124),Cs(e,t)):(ms(e,123),ws(e,t));break;case`bigint`:ms(e,122),Ts(e,t);break;case`object`:if(t===null)ms(e,126);else if(Do(t)){ms(e,117),Y(e,t.length);for(let n=0;n<t.length;n++)Os(e,t[n])}else if(t instanceof Uint8Array)ms(e,116),xs(e,t);else{ms(e,118);let n=Object.keys(t);Y(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];ys(e,i),Os(e,t[i])}}break;case`boolean`:ms(e,t?120:121);break;default:ms(e,127)}},ks=class extends cs{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Y(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},As=e=>{e.count>0&&(gs(e.encoder,e.count===1?e.s:-e.s),e.count>1&&Y(e.encoder,e.count-2))},js=class{constructor(){this.encoder=new cs,this.s=0,this.count=0}write(e){this.s===e?this.count++:(As(this),this.count=1,this.s=e)}toUint8Array(){return As(this),fs(this.encoder)}},Ms=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);gs(e.encoder,t),e.count>1&&Y(e.encoder,e.count-2)}},Ns=class{constructor(){this.encoder=new cs,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ms(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ms(this),fs(this.encoder)}},Ps=class{constructor(){this.sarr=[],this.s=``,this.lensE=new js}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 cs;return this.sarr.push(this.s),this.s=``,ys(e,this.sarr.join(``)),bs(e,this.lensE.toUint8Array()),fs(e)}},Fs=e=>Error(e),Is=()=>{throw Fs(`Method unimplemented`)},Ls=()=>{throw Fs(`Unexpected case`)},Rs=Fs(`Unexpected end of array`),zs=Fs(`Integer out of Range`),Bs=class{constructor(e){this.arr=e,this.pos=0}},Vs=e=>new Bs(e),Hs=e=>e.pos!==e.arr.length,Us=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Ws=e=>Us(e,X(e)),Gs=e=>e.arr[e.pos++],X=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>Jo)throw zs}throw Rs},Ks=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>Jo)throw zs}throw Rs},qs=os?e=>os.decode(Ws(e)):e=>{let t=X(e);if(t===0)return``;{let n=String.fromCodePoint(Gs(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Gs(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))}},Js=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Ys=[e=>void 0,e=>null,Ks,e=>Js(e,4).getFloat32(0,!1),e=>Js(e,8).getFloat64(0,!1),e=>Js(e,8).getBigInt64(0,!1),e=>!1,e=>!0,qs,e=>{let t=X(e),n={};for(let r=0;r<t;r++){let t=qs(e);n[t]=Xs(e)}return n},e=>{let t=X(e),n=[];for(let r=0;r<t;r++)n.push(Xs(e));return n},Ws],Xs=e=>Ys[127-Gs(e)](e),Zs=class extends Bs{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Hs(this)?this.count=X(this)+1:this.count=-1),this.count--,this.s}},Qs=class extends Bs{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ks(this);let e=Po(this.s);this.count=1,e&&(this.s=-this.s,this.count=X(this)+2)}return this.count--,this.s}},$s=class extends Bs{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Ks(this),t=e&1;this.diff=Ao(e/2),this.count=1,t&&(this.count=X(this)+2)}return this.s+=this.diff,this.count--,this.s}},ec=class{constructor(e){this.decoder=new Qs(e),this.str=qs(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 tc=crypto.getRandomValues.bind(crypto),nc=Math.random,rc=()=>tc(new Uint32Array(1))[0],ic=e=>e[Ao(nc()*e.length)],ac=`10000000-1000-4000-8000-100000000000`,oc=()=>ac.replace(/[018]/g,e=>(e^rc()&15>>e/4).toString(16)),sc=Date.now,cc=e=>new Promise(e);Promise.all.bind(Promise);var lc=e=>e===void 0?null:e,uc=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&&(uc=localStorage)}catch{}var dc=uc,fc=Symbol(`Equality`),pc=(e,t)=>e===t||!!e?.[fc]?.(t)||!1,mc=e=>typeof e==`object`,hc=Object.assign,gc=Object.keys,_c=(e,t)=>{for(let n in e)t(e[n],n)},vc=e=>gc(e).length,yc=e=>{for(let t in e)return!1;return!0},bc=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},xc=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Sc=(e,t)=>e===t||vc(e)===vc(t)&&bc(e,(e,n)=>(e!==void 0||xc(t,n))&&pc(t[n],e)),Cc=Object.freeze,wc=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&wc(e[t])}return Cc(e)},Tc=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Tc(e,t,n+1)}},Ec=e=>e,Dc=(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[fc]!=null)return e[fc](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)||!Dc(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(vc(e)!==vc(t))return!1;for(let n in e)if(!xc(e,n)||!Dc(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(!Dc(e[n],t[n]))return!1;break;default:return!1}return!0},Oc=(e,t)=>t.includes(e),kc=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Ac=typeof window<`u`&&typeof document<`u`&&!kc;typeof navigator<`u`&&/Mac/.test(navigator.platform);var jc,Mc=[],Nc=()=>{if(jc===void 0)if(kc){jc=ho();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&jc.set(t,``),t=r):t===null?Mc.push(r):(jc.set(t,r),t=null)}t!==null&&jc.set(t,``)}else typeof location==`object`?(jc=ho(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);jc.set(`--${ns(t,`-`)}`,n),jc.set(`-${ns(t,`-`)}`,n)}})):jc=ho();return jc},Pc=e=>Nc().has(e),Fc=e=>lc(kc?{}[e.toUpperCase().replaceAll(`-`,`_`)]:dc.getItem(e)),Ic=e=>Pc(`--`+e)||Fc(e)!==null,Lc=Ic(`production`),Rc=kc&&Oc({}.FORCE_COLOR,[`true`,`1`,`2`])||!Pc(`--no-colors`)&&!Ic(`no-color`)&&(!kc||process.stdout.isTTY)&&(!kc||Pc(`--color`)||Fc(`COLORTERM`)!==null||(Fc(`TERM`)||``).includes(`color`)),zc=e=>new Uint8Array(e),Bc=Ac?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Zo(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Vc=e=>{let t=zc(e.byteLength);return t.set(e),t},Hc=e=>us(t=>Os(t,e)),Uc=class{constructor(e,t){this.left=e,this.right=t}},Wc=(e,t)=>new Uc(e,t),Gc=(e,t)=>e.forEach(e=>t(e.left,e.right)),Kc=e=>e.next()>=.5,qc=(e,t,n)=>Ao(e.next()*(n+1-t)+t),Jc=(e,t,n)=>Ao(e.next()*(n+1-t)+t),Yc=(e,t,n)=>Jc(e,t,n),Xc=e=>Zo(Yc(e,97,122)),Zc=(e,t=0,n=20)=>{let r=Yc(e,t,n),i=``;for(let t=0;t<r;t++)i+=Xc(e);return i},Qc=(e,t)=>t[Yc(e,0,t.length-1)],$c=Symbol(`0schema`),el=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(ss(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
2
|
+
import{r as e,t}from"./chunk-DECur_0Z.js";import{i as n,n as r,t as i}from"./propagation-api-LnD10wq2.js";import{n as a,r as o,t as s}from"./compiler-runtime-Y11fyRVL.js";import{$ as c,$t as l,An as u,At as d,B as f,C as p,Cn as m,Ct as h,Dt as g,E as _,En as v,Et as y,F as b,Ft as x,G as S,Gn as C,H as w,Hn as T,It as E,Jn as D,Jt as O,K as k,L as A,Ln as j,M,Mn as N,N as P,Nn as F,Nt as I,Ot as L,P as R,Pn as z,Pt as B,Qt as V,R as H,Rn as U,S as ee,Sn as te,St as ne,Tn as re,Tt as ie,U as ae,Un as oe,Ut as se,V as ce,Vt as le,W as ue,Wn as de,Xn as fe,Xt as pe,Yt as me,_n as he,_t as ge,a as _e,b as ve,bn as ye,c as be,cn as xe,d as Se,dn as Ce,dt as we,en as Te,et as Ee,f as De,fn as Oe,gn as ke,h as Ae,hn as je,i as Me,in as Ne,j as Pe,jn as Fe,k as Ie,lt as Le,m as Re,mn as ze,mt as Be,n as Ve,nn as He,nt as Ue,pn as We,rn as Ge,s as Ke,sn as qe,st as Je,t as Ye,tn as Xe,tt as Ze,u as Qe,un as $e,ut as et,v as tt,vn as nt,vt as rt,wn as it,wt as at,x as ot,xn as st,y as ct,yn as lt,yt as ut,z as dt,zn as ft,zt as pt}from"./toggle-group-1sl8rMnA.js";import{C as mt,S as ht,_ as gt,a as _t,b as vt,c as yt,d as bt,g as xt,i as St,l as Ct,m as wt,p as Tt,r as Et,s as Dt,t as Ot,u as kt,x as At}from"./button-Dyz7QGIk.js";import{S as jt,_ as Mt,a as Nt,c as Pt,d as Ft,f as It,g as Lt,h as Rt,i as zt,m as Bt,n as Vt,o as Ht,p as Ut,s as Wt,t as Gt,u as Kt,v as qt,x as Jt,y as Yt}from"./dialog-FUclf-NK.js";import{B as Xt,Bt as Zt,D as Qt,Et as $t,G as en,H as tn,I as nn,K as rn,L as W,M as an,N as on,Nt as sn,P as cn,Pt as ln,Tt as un,U as dn,V as fn,W as pn,Y as mn,Z as hn,_ as gn,a as _n,b as vn,f as yn,h as bn,i as xn,j as Sn,jt as Cn,k as wn,kt as Tn,l as En,lt as Dn,o as On,p as kn,q as An,r as jn,s as Mn,t as Nn,u as Pn,w as Fn,wt as In,y as Ln,z as Rn}from"./dist-dkPJvrfr.js";import{a as zn,c as Bn,s as Vn,t as Hn}from"./dist-oNAFjGrp.js";import{i as Un,n as Wn,r as Gn,t as Kn}from"./dist-RVD4DzGH.js";var qn=ht(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Jn=ht(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Yn=ht(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),Xn=ht(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Zn=ht(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Qn=ht(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),$n=ht(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),er=ht(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),tr=ht(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),nr=ht(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),rr=ht(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),ir=ht(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),ar=ht(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),or=ht(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),sr=ht(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),cr=ht(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),lr=ht(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),ur=ht(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),dr=ht(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),fr=ht(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),pr=ht(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),mr=ht(`message-square-warning`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]),hr=ht(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),gr=ht(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),_r=ht(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),vr=ht(`quote`,[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]),yr=ht(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),br=ht(`square-play`,[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}]]),xr=ht(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),Sr=ht(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Cr=ht(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),wr=ht(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),G=e(a(),1),K=o(),Tr=`Collapsible`,[Er,Dr]=Tt(Tr),[Or,kr]=Er(Tr),Ar=G.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=Ct({prop:r,defaultProp:i??!1,onChange:o,caller:Tr});return(0,K.jsx)(Or,{scope:n,disabled:a,contentId:Dt(),open:c,onOpenToggle:G.useCallback(()=>l(e=>!e),[l]),children:(0,K.jsx)(wt.div,{"data-state":Ir(c),"data-disabled":a?``:void 0,...s,ref:t})})});Ar.displayName=Tr;var jr=`CollapsibleTrigger`,Mr=G.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=kr(jr,n);return(0,K.jsx)(wt.button,{type:`button`,"aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Ir(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:bt(e.onClick,i.onOpenToggle)})});Mr.displayName=jr;var Nr=`CollapsibleContent`,Pr=G.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=kr(Nr,e.__scopeCollapsible);return(0,K.jsx)(yt,{present:n||i.open,children:({present:e})=>(0,K.jsx)(Fr,{...r,ref:t,present:e})})});Pr.displayName=Nr;var Fr=G.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=kr(Nr,n),[s,c]=G.useState(r),l=G.useRef(null),u=vt(t,l),d=G.useRef(0),f=d.current,p=G.useRef(0),m=p.current,h=o.open||s,g=G.useRef(h),_=G.useRef(void 0);return G.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),kt(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,K.jsx)(wt.div,{"data-state":Ir(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function Ir(e){return e?`open`:`closed`}var Lr=Ar,Rr=Mr,zr=Pr,Br=t((e=>{var t=a();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),a=r[0].inst,l=r[1];return s(function(){a.value=n,a.getSnapshot=t,u(a)&&l({inst:a})},[e,n,t]),o(function(){return u(a)&&l({inst:a}),e(function(){u(a)&&l({inst:a})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Vr=t(((e,t)=>{t.exports=Br()}));function Hr(e){let t=G.useRef({value:e,previous:e});return G.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ur=`Popover`,[Wr,Gr]=Tt(Ur,[z]),Kr=z(),[qr,Jr]=Wr(Ur),Yr=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Kr(t),c=G.useRef(null),[l,u]=G.useState(!1),[d,f]=Ct({prop:r,defaultProp:i??!1,onChange:a,caller:Ur});return(0,K.jsx)(F,{...s,children:(0,K.jsx)(qr,{scope:t,contentId:Dt(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:G.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:G.useCallback(()=>u(!0),[]),onCustomAnchorRemove:G.useCallback(()=>u(!1),[]),modal:o,children:n})})};Yr.displayName=Ur;var Xr=`PopoverAnchor`,Zr=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Jr(Xr,n),a=Kr(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return G.useEffect(()=>(o(),()=>s()),[o,s]),(0,K.jsx)(u,{...a,...r,ref:t})});Zr.displayName=Xr;var Qr=`PopoverTrigger`,$r=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Jr(Qr,n),a=Kr(n),o=vt(t,i.triggerRef),s=(0,K.jsx)(wt.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":mi(i.open),...r,ref:o,onClick:bt(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,K.jsx)(u,{asChild:!0,...a,children:s})});$r.displayName=Qr;var ei=`PopoverPortal`,[ti,ni]=Wr(ei,{forceMount:void 0}),ri=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Jr(ei,t);return(0,K.jsx)(ti,{scope:t,forceMount:n,children:(0,K.jsx)(yt,{present:n||a.open,children:(0,K.jsx)(St,{asChild:!0,container:i,children:r})})})};ri.displayName=ei;var ii=`PopoverContent`,ai=G.forwardRef((e,t)=>{let n=ni(ii,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Jr(ii,e.__scopePopover);return(0,K.jsx)(yt,{present:r||a.open,children:a.modal?(0,K.jsx)(si,{...i,ref:t}):(0,K.jsx)(ci,{...i,ref:t})})});ai.displayName=ii;var oi=gt(`PopoverContent.RemoveScroll`),si=G.forwardRef((e,t)=>{let n=Jr(ii,e.__scopePopover),r=G.useRef(null),i=vt(t,r),a=G.useRef(!1);return G.useEffect(()=>{let e=r.current;if(e)return Lt(e)},[]),(0,K.jsx)(Mt,{as:oi,allowPinchZoom:!0,children:(0,K.jsx)(li,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:bt(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:bt(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:bt(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),ci=G.forwardRef((e,t)=>{let n=Jr(ii,e.__scopePopover),r=G.useRef(!1),i=G.useRef(!1);return(0,K.jsx)(li,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),li=G.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Jr(ii,n),p=Kr(n);return qt(),(0,K.jsx)(Yt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,K.jsx)(_t,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,K.jsx)(N,{"data-state":mi(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),ui=`PopoverClose`,di=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Jr(ui,n);return(0,K.jsx)(wt.button,{type:`button`,...r,ref:t,onClick:bt(e.onClick,()=>i.onOpenChange(!1))})});di.displayName=ui;var fi=`PopoverArrow`,pi=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Kr(n);return(0,K.jsx)(Fe,{...i,...r,ref:t})});pi.displayName=fi;function mi(e){return e?`open`:`closed`}var hi=Yr,gi=Zr,_i=$r,vi=ri,yi=ai,bi=`Switch`,[xi,Si]=Tt(bi),[Ci,wi]=xi(bi),Ti=G.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=G.useState(null),m=vt(t,e=>p(e)),h=G.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=Ct({prop:i,defaultProp:a??!1,onChange:l,caller:bi});return(0,K.jsxs)(Ci,{scope:n,checked:_,disabled:s,children:[(0,K.jsx)(wt.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Ai(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:bt(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,K.jsx)(ki,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Ti.displayName=bi;var Ei=`SwitchThumb`,Di=G.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=wi(Ei,n);return(0,K.jsx)(wt.span,{"data-state":Ai(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});Di.displayName=Ei;var Oi=`SwitchBubbleInput`,ki=G.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=G.useRef(null),s=vt(o,a),c=Hr(n),l=C(t);return G.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,K.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});ki.displayName=Oi;function Ai(e){return e?`checked`:`unchecked`}var ji=Ti,Mi=Di,Ni=e(mt(),1),q=s();function Pi(e){let t=(0,q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,type:a,ref:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=Et(`h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,n),t[5]=n,t[6]=o);let s;return t[7]!==r||t[8]!==i||t[9]!==o||t[10]!==a?(s=(0,K.jsx)(`input`,{type:a,ref:i,"data-slot":`input`,className:o,...r}),t[7]=r,t[8]=i,t[9]=o,t[10]=a,t[11]=s):s=t[11],s}var Fi=Vr(),Ii=At(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3! font-mono uppercase`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,warning:`bg-yellow-500/10 text-yellow-600 [a]:hover:bg-yellow-500/20`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`,dashed:`border-dashed border-border text-muted-foreground rounded-sm`}},defaultVariants:{variant:`default`}});function Li(e){let t=(0,q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,variant:i,asChild:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a!==void 0&&a?xt:`span`,c;t[5]!==n||t[6]!==o?(c=Et(Ii({variant:o}),n),t[5]=n,t[6]=o,t[7]=c):c=t[7];let l;return t[8]!==s||t[9]!==r||t[10]!==c||t[11]!==o?(l=(0,K.jsx)(s,{"data-slot":`badge`,"data-variant":o,className:c,...r}),t[8]=s,t[9]=r,t[10]=c,t[11]=o,t[12]=l):l=t[12],l}function Ri(e){let t=e.split(`/`);return t.length<2?`ok`:`${t[0]}/${t[1]}`}function zi(e){if(!e)return;let t=Object.entries(e);if(t.length!==0)return t.map(([e,t])=>{if(t==null)return[e,String(t)];if(typeof t==`string`)return[e,t];if(typeof t==`number`||typeof t==`boolean`)return[e,String(t)];try{return[e,JSON.stringify(t)]}catch{return[e,`[unserializable]`]}})}function J(e,t,n){if(typeof performance>`u`||!performance.measure)return;let r=Ri(e),i=zi(t),a={devtools:{dataType:`track-entry`,track:r,...i?{properties:i}:{},...n?.tooltipText?{tooltipText:n.tooltipText}:{}}},o=performance.now(),s=n?.startTime??o,c=n?.duration??Math.max(0,o-s);try{performance.measure(e,{start:s,duration:c,detail:a})}catch{}({...t?{properties:t}:{}})}function Bi(e){let t=(0,q.c)(3),{name:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,K.jsx)(G.Profiler,{id:n,onRender:Vi,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var Vi=(e,t,n,r,i,a)=>{J(`ok/render/${e}`,{phase:t,actualDuration:Math.round(n*1e3)/1e3,baseDuration:Math.round(r*1e3)/1e3},{startTime:i,duration:Math.max(0,a-i)})},{getOwnPropertyNames:Hi,getOwnPropertySymbols:Ui}=Object,{hasOwnProperty:Wi}=Object.prototype;function Gi(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Ki(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function qi(e){return e?.[Symbol.toStringTag]}function Ji(e){return Hi(e).concat(Ui(e))}var Yi=Object.hasOwn||((e,t)=>Wi.call(e,t));function Xi(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var Zi=`__v`,Qi=`__o`,$i=`_owner`,{getOwnPropertyDescriptor:ea,keys:ta}=Object;function na(e,t){return e.byteLength===t.byteLength&&ha(new Uint8Array(e),new Uint8Array(t))}function ra(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function ia(e,t){return e.byteLength===t.byteLength&&ha(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function aa(e,t){return Xi(e.getTime(),t.getTime())}function oa(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function sa(e,t){return e===t}function ca(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var la=Xi;function ua(e,t,n){let r=ta(e),i=r.length;if(ta(t).length!==i)return!1;for(;i-- >0;)if(!_a(e,t,n,r[i]))return!1;return!0}function da(e,t,n){let r=Ji(e),i=r.length;if(Ji(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!_a(e,t,n,a)||(o=ea(e,a),s=ea(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function fa(e,t){return Xi(e.valueOf(),t.valueOf())}function pa(e,t){return e.source===t.source&&e.flags===t.flags}function ma(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function ha(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function ga(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function _a(e,t,n,r){return(r===$i||r===Qi||r===Zi)&&(e.$$typeof||t.$$typeof)?!0:Yi(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var va=`[object ArrayBuffer]`,ya=`[object Arguments]`,ba=`[object Boolean]`,xa=`[object DataView]`,Sa=`[object Date]`,Ca=`[object Error]`,wa=`[object Map]`,Ta=`[object Number]`,Ea=`[object Object]`,Da=`[object RegExp]`,Oa=`[object Set]`,ka=`[object String]`,Aa={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},ja=`[object URL]`,Ma=Object.prototype.toString;function Na({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`?a(h,g,_):!1;let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=Ma.call(h);if(b===Sa)return r(h,g,_);if(b===Da)return u(h,g,_);if(b===wa)return o(h,g,_);if(b===Oa)return d(h,g,_);if(b===Ea)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===ja)return p(h,g,_);if(b===Ca)return i(h,g,_);if(b===ya)return c(h,g,_);if(Aa[b])return f(h,g,_);if(b===va)return e(h,g,_);if(b===xa)return n(h,g,_);if(b===ba||b===Ta||b===ka)return l(h,g,_);if(m){let e=m[b];if(!e){let t=qi(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function Pa({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:na,areArraysEqual:n?da:ra,areDataViewsEqual:ia,areDatesEqual:aa,areErrorsEqual:oa,areFunctionsEqual:sa,areMapsEqual:n?Gi(ca,da):ca,areNumbersEqual:la,areObjectsEqual:n?da:ua,arePrimitiveWrappersEqual:fa,areRegExpsEqual:pa,areSetsEqual:n?Gi(ma,da):ma,areTypedArraysEqual:n?Gi(ha,da):ha,areUrlsEqual:ga,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Ki(r.areArraysEqual),t=Ki(r.areMapsEqual),n=Ki(r.areObjectsEqual),i=Ki(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function Fa(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function Ia({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var La=Ra();Ra({strict:!0}),Ra({circular:!0}),Ra({circular:!0,strict:!0}),Ra({createInternalComparator:()=>Xi}),Ra({strict:!0,createInternalComparator:()=>Xi}),Ra({circular:!0,createInternalComparator:()=>Xi}),Ra({circular:!0,createInternalComparator:()=>Xi,strict:!0});function Ra(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=Na(Pa(e));return Ia({circular:t,comparator:a,createState:r,equals:n?n(a):Fa(a),strict:i})}var za=t((e=>{var t=a(),n=Vr();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,a){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),a!==void 0&&f.hasValue){var t=f.value;if(a(t,e))return c=t}return c=e}if(t=c,i(s,e))return t;var n=r(e);return a!==void 0&&a(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,a]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Ba=t(((e,t)=>{t.exports=za()}))(),Va=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},Ha=({contentComponent:e})=>{let t=(0,Fi.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,K.jsx)(K.Fragment,{children:Object.values(t)})};function Ua(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:Ni.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var Wa=class extends G.Component{constructor(e){super(e),this.editorContentRef=G.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Ua(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{ref:Va(t,this.editorContentRef),...n}),e?.contentComponent&&(0,K.jsx)(Ha,{contentComponent:e.contentComponent})]})}},Ga=(0,G.forwardRef)((e,t)=>{let n=G.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return G.createElement(Wa,{key:n,innerRef:t,...e})}),Ka=G.memo(Ga),qa=typeof window<`u`?G.useLayoutEffect:G.useEffect,Ja=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}}}};function Ya(e){let[t]=(0,G.useState)(()=>new Ja(e.editor)),n=(0,Ba.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??La);return qa(()=>t.watch(e.editor),[e.editor,t]),(0,G.useDebugValue)(n),n}typeof window>`u`||typeof window<`u`&&window.next;var Xa=(0,G.createContext)({editor:null});Xa.Consumer;var Za=()=>(0,G.useContext)(Xa),Qa=(0,G.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),$a=()=>(0,G.useContext)(Qa);function eo({as:e=`div`,...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=$a();return(0,K.jsx)(e,{...t,ref:n,"data-node-view-content":``,style:{whiteSpace:`pre-wrap`,...t.style},children:r})}var to=G.forwardRef((e,t)=>{let{onDragStart:n}=$a();return(0,K.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function no(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function ro(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.forward_ref)`||e.$$typeof.description===`react.forward_ref`))}function io(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.memo)`||e.$$typeof.description===`react.memo`))}function ao(e){if(no(e)||ro(e))return!0;if(io(e)){let t=e.type;if(t)return no(t)||ro(t)}return!1}function oo(){try{if(G.version)return parseInt(G.version.split(`.`)[0],10)>=19}catch{}return!1}var so=class{constructor(e,{editor:t,props:n={},as:r=`div`,className:i=``}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add(`react-renderer`),i&&this.element.classList.add(...i.split(` `)),this.editor.isEditorContentInitialized?(0,Ni.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,i=oo(),a=ao(t),o={...n};o.ref&&!(i||a)&&delete o.ref,!o.ref&&(i||a)&&(o.ref=e=>{this.ref=e}),this.reactElement=(0,K.jsx)(t,{...o}),(e=r?.contentComponent)==null||e.setRenderer(this.id,this)}updateProps(e={}){this.destroyed||(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0,(e=this.editor?.contentComponent)==null||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};G.createContext({markViewContentRef:()=>{}});var co=class extends Te{constructor(e,t,n){if(super(e,t,n),this.selectionRafId=null,this.positionCheckCallback=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?`span`:`div`),this.contentDOMElement.dataset.nodeViewContentReact=``,this.contentDOMElement.dataset.nodeViewWrapper=``,this.contentDOMElement.style.whiteSpace=`inherit`;let e=this.dom.querySelector(`[data-node-view-content]`);if(!e)return;e.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){return r===`storage`?e.storage[t.name]??{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,G.createRef)()};if(!this.component.displayName){let e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute(`data-node-view-wrapper`)&&e.removeAttribute(`data-node-view-wrapper`),e.appendChild(this.contentDOMElement))}},n=this.component,r=(0,G.memo)(e=>(0,K.jsx)(Qa.Provider,{value:t,children:(0,G.createElement)(n,e)}));r.displayName=`ReactNodeView`;let i=this.node.isInline?`span`:`div`;this.options.as&&(i=this.options.as);let{className:a=``}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new so(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on(`selectionUpdate`,this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos(),this.positionCheckCallback=()=>{let e=this.getPos();typeof e!=`number`||e===this.currentPos||(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs==`function`&&this.updateElementAttributes())},Oe(this.editor,this.positionCheckCallback)}get dom(){if(this.renderer.element.firstElementChild&&!this.renderer.element.firstElementChild?.hasAttribute(`data-node-view-wrapper`))throw Error(`Please use the NodeViewWrapper component for your node view.`);return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;let{from:e,to:t}=this.editor.state.selection,n=this.currentPos;if(typeof n==`number`)if(e<=n&&t>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(e,t,n){let r=e=>{this.renderer.updateProps(e),typeof this.options.attrs==`function`&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update==`function`){let i=this.node,a=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:a,newNode:e,newDecorations:t,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}let i=this.getPos();return e===this.node&&this.decorations===t&&this.innerDecorations===n?i===this.currentPos?!0:(this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage,getPos:()=>this.getPos()}),!0):(this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage}),!0)}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add(`ProseMirror-selectednode`)}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove(`ProseMirror-selectednode`)}destroy(){this.renderer.destroy(),this.editor.off(`selectionUpdate`,this.handleSelectionUpdate),this.positionCheckCallback&&=(Xe(this.editor,this.positionCheckCallback),null),this.contentDOMElement=null,this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null)}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs==`function`){let t=this.editor.extensionManager.attributes,n=Ge(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function lo(e,t){return n=>n.editor.contentComponent?new co(e,n,t):{}}var uo=(0,G.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});uo.displayName=`TiptapContext`;var fo=()=>(0,G.useContext)(uo);function po({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,G.useMemo)(()=>({editor:r}),[r]),a=(0,G.useMemo)(()=>({editor:r}),[r]);return(0,K.jsx)(Xa.Provider,{value:a,children:(0,K.jsx)(uo.Provider,{value:i,children:n})})}po.displayName=`Tiptap`;function mo({...e}){let{editor:t}=fo();return(0,K.jsx)(Ka,{editor:t,...e})}mo.displayName=`Tiptap.Content`,Object.assign(po,{Content:mo});var ho=()=>new Map,go=e=>{let t=ho();return e.forEach((e,n)=>{t.set(n,e)}),t},_o=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},vo=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},yo=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},bo=()=>new Set,xo=e=>e[e.length-1],So=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Co=Array.from,wo=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},To=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Eo=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Do=Array.isArray,Oo=class{constructor(){this._observers=ho()}on(e,t){return _o(this._observers,e,bo).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 Co((this._observers.get(e)||ho()).values()).forEach(e=>e(...t))}destroy(){this._observers=ho()}},ko=class{constructor(){this._observers=ho()}on(e,t){_o(this._observers,e,bo).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 Co((this._observers.get(e)||ho()).values()).forEach(e=>e(...t))}destroy(){this._observers=ho()}},Ao=Math.floor,jo=Math.abs,Mo=(e,t)=>e<t?e:t,No=(e,t)=>e>t?e:t;Number.isNaN;var Po=e=>e===0?1/e<0:e<0,Fo=1<<17,Io=1<<18,Lo=1<<19,Ro=1<<20,zo=1<<21,Bo=1<<22,Vo=1<<23,Ho=1<<24,Uo=1<<25,Wo=1<<26,Go=1<<27,Ko=1<<28,qo=1<<29;Fo-1,Io-1,Lo-1,Ro-1,zo-1,Bo-1,Vo-1,Ho-1,Uo-1,Wo-1,Go-1,Ko-1,qo-1;var Jo=2**53-1,Yo=-(2**53-1),Xo=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&Ao(e)===e);Number.isNaN,Number.parseInt;var Zo=String.fromCharCode;String.fromCodePoint,Zo(65535);var Qo=e=>e.toLowerCase(),$o=/^\s*/g,es=e=>e.replace($o,``),ts=/([A-Z])/g,ns=(e,t)=>es(e.replace(ts,e=>`${t}${Qo(e)}`)),rs=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},is=typeof TextEncoder<`u`?new TextEncoder:null,as=is?e=>is.encode(e):rs,os=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});os&&os.decode(new Uint8Array).length===1&&(os=null);var ss=(e,t)=>Eo(t,()=>e).join(``),cs=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},ls=()=>new cs,us=e=>{let t=ls();return e(t),fs(t)},ds=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},fs=e=>{let t=new Uint8Array(ds(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},ps=(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(No(n,t)*2),e.cpos=0)},ms=(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},hs=ms,Y=(e,t)=>{for(;t>127;)ms(e,128|127&t),t=Ao(t/128);ms(e,127&t)},gs=(e,t)=>{let n=Po(t);for(n&&(t=-t),ms(e,(t>63?128:0)|(n?64:0)|63&t),t=Ao(t/64);t>0;)ms(e,(t>127?128:0)|127&t),t=Ao(t/128)},_s=new Uint8Array(3e4),vs=_s.length/3,ys=is&&is.encodeInto?(e,t)=>{if(t.length<vs){let n=is.encodeInto(t,_s).written||0;Y(e,n);for(let t=0;t<n;t++)ms(e,_s[t])}else xs(e,as(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Y(e,r);for(let t=0;t<r;t++)ms(e,n.codePointAt(t))},bs=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Mo(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(No(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},xs=(e,t)=>{Y(e,t.byteLength),bs(e,t)},Ss=(e,t)=>{ps(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Cs=(e,t)=>Ss(e,4).setFloat32(0,t,!1),ws=(e,t)=>Ss(e,8).setFloat64(0,t,!1),Ts=(e,t)=>Ss(e,8).setBigInt64(0,t,!1),Es=new DataView(new ArrayBuffer(4)),Ds=e=>(Es.setFloat32(0,e),Es.getFloat32(0)===e),Os=(e,t)=>{switch(typeof t){case`string`:ms(e,119),ys(e,t);break;case`number`:Xo(t)&&jo(t)<=2147483647?(ms(e,125),gs(e,t)):Ds(t)?(ms(e,124),Cs(e,t)):(ms(e,123),ws(e,t));break;case`bigint`:ms(e,122),Ts(e,t);break;case`object`:if(t===null)ms(e,126);else if(Do(t)){ms(e,117),Y(e,t.length);for(let n=0;n<t.length;n++)Os(e,t[n])}else if(t instanceof Uint8Array)ms(e,116),xs(e,t);else{ms(e,118);let n=Object.keys(t);Y(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];ys(e,i),Os(e,t[i])}}break;case`boolean`:ms(e,t?120:121);break;default:ms(e,127)}},ks=class extends cs{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Y(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},As=e=>{e.count>0&&(gs(e.encoder,e.count===1?e.s:-e.s),e.count>1&&Y(e.encoder,e.count-2))},js=class{constructor(){this.encoder=new cs,this.s=0,this.count=0}write(e){this.s===e?this.count++:(As(this),this.count=1,this.s=e)}toUint8Array(){return As(this),fs(this.encoder)}},Ms=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);gs(e.encoder,t),e.count>1&&Y(e.encoder,e.count-2)}},Ns=class{constructor(){this.encoder=new cs,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ms(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ms(this),fs(this.encoder)}},Ps=class{constructor(){this.sarr=[],this.s=``,this.lensE=new js}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 cs;return this.sarr.push(this.s),this.s=``,ys(e,this.sarr.join(``)),bs(e,this.lensE.toUint8Array()),fs(e)}},Fs=e=>Error(e),Is=()=>{throw Fs(`Method unimplemented`)},Ls=()=>{throw Fs(`Unexpected case`)},Rs=Fs(`Unexpected end of array`),zs=Fs(`Integer out of Range`),Bs=class{constructor(e){this.arr=e,this.pos=0}},Vs=e=>new Bs(e),Hs=e=>e.pos!==e.arr.length,Us=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Ws=e=>Us(e,X(e)),Gs=e=>e.arr[e.pos++],X=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>Jo)throw zs}throw Rs},Ks=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>Jo)throw zs}throw Rs},qs=os?e=>os.decode(Ws(e)):e=>{let t=X(e);if(t===0)return``;{let n=String.fromCodePoint(Gs(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Gs(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))}},Js=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Ys=[e=>void 0,e=>null,Ks,e=>Js(e,4).getFloat32(0,!1),e=>Js(e,8).getFloat64(0,!1),e=>Js(e,8).getBigInt64(0,!1),e=>!1,e=>!0,qs,e=>{let t=X(e),n={};for(let r=0;r<t;r++){let t=qs(e);n[t]=Xs(e)}return n},e=>{let t=X(e),n=[];for(let r=0;r<t;r++)n.push(Xs(e));return n},Ws],Xs=e=>Ys[127-Gs(e)](e),Zs=class extends Bs{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Hs(this)?this.count=X(this)+1:this.count=-1),this.count--,this.s}},Qs=class extends Bs{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ks(this);let e=Po(this.s);this.count=1,e&&(this.s=-this.s,this.count=X(this)+2)}return this.count--,this.s}},$s=class extends Bs{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Ks(this),t=e&1;this.diff=Ao(e/2),this.count=1,t&&(this.count=X(this)+2)}return this.s+=this.diff,this.count--,this.s}},ec=class{constructor(e){this.decoder=new Qs(e),this.str=qs(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 tc=crypto.getRandomValues.bind(crypto),nc=Math.random,rc=()=>tc(new Uint32Array(1))[0],ic=e=>e[Ao(nc()*e.length)],ac=`10000000-1000-4000-8000-100000000000`,oc=()=>ac.replace(/[018]/g,e=>(e^rc()&15>>e/4).toString(16)),sc=Date.now,cc=e=>new Promise(e);Promise.all.bind(Promise);var lc=e=>e===void 0?null:e,uc=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&&(uc=localStorage)}catch{}var dc=uc,fc=Symbol(`Equality`),pc=(e,t)=>e===t||!!e?.[fc]?.(t)||!1,mc=e=>typeof e==`object`,hc=Object.assign,gc=Object.keys,_c=(e,t)=>{for(let n in e)t(e[n],n)},vc=e=>gc(e).length,yc=e=>{for(let t in e)return!1;return!0},bc=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},xc=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Sc=(e,t)=>e===t||vc(e)===vc(t)&&bc(e,(e,n)=>(e!==void 0||xc(t,n))&&pc(t[n],e)),Cc=Object.freeze,wc=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&wc(e[t])}return Cc(e)},Tc=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Tc(e,t,n+1)}},Ec=e=>e,Dc=(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[fc]!=null)return e[fc](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)||!Dc(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(vc(e)!==vc(t))return!1;for(let n in e)if(!xc(e,n)||!Dc(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(!Dc(e[n],t[n]))return!1;break;default:return!1}return!0},Oc=(e,t)=>t.includes(e),kc=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Ac=typeof window<`u`&&typeof document<`u`&&!kc;typeof navigator<`u`&&/Mac/.test(navigator.platform);var jc,Mc=[],Nc=()=>{if(jc===void 0)if(kc){jc=ho();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&jc.set(t,``),t=r):t===null?Mc.push(r):(jc.set(t,r),t=null)}t!==null&&jc.set(t,``)}else typeof location==`object`?(jc=ho(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);jc.set(`--${ns(t,`-`)}`,n),jc.set(`-${ns(t,`-`)}`,n)}})):jc=ho();return jc},Pc=e=>Nc().has(e),Fc=e=>lc(kc?{}[e.toUpperCase().replaceAll(`-`,`_`)]:dc.getItem(e)),Ic=e=>Pc(`--`+e)||Fc(e)!==null,Lc=Ic(`production`),Rc=kc&&Oc({}.FORCE_COLOR,[`true`,`1`,`2`])||!Pc(`--no-colors`)&&!Ic(`no-color`)&&(!kc||process.stdout.isTTY)&&(!kc||Pc(`--color`)||Fc(`COLORTERM`)!==null||(Fc(`TERM`)||``).includes(`color`)),zc=e=>new Uint8Array(e),Bc=Ac?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Zo(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Vc=e=>{let t=zc(e.byteLength);return t.set(e),t},Hc=e=>us(t=>Os(t,e)),Uc=class{constructor(e,t){this.left=e,this.right=t}},Wc=(e,t)=>new Uc(e,t),Gc=(e,t)=>e.forEach(e=>t(e.left,e.right)),Kc=e=>e.next()>=.5,qc=(e,t,n)=>Ao(e.next()*(n+1-t)+t),Jc=(e,t,n)=>Ao(e.next()*(n+1-t)+t),Yc=(e,t,n)=>Jc(e,t,n),Xc=e=>Zo(Yc(e,97,122)),Zc=(e,t=0,n=20)=>{let r=Yc(e,t,n),i=``;for(let t=0;t<r;t++)i+=Xc(e);return i},Qc=(e,t)=>t[Yc(e,0,t.length-1)],$c=Symbol(`0schema`),el=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(ss(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
3
3
|
`)}},tl=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[fc]?pc(e,t):Do(e)?wo(e,e=>To(t,t=>tl(e,t))):mc(e)?bc(e,(e,n)=>tl(e,t[n])):!1,nl=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),tl(t,n)}equals(e){return this.constructor===e.constructor&&Dc(this.shape,e.shape)}[$c](){return!0}[fc](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Is()}get nullable(){return Fl(this,Xl)}get optional(){return new pl(this)}cast(e){return eu(e,this),e}expect(e){return eu(e,this),e}},rl=class extends nl{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}},il=(e,t=null)=>new rl(e,t);il(rl);var al=class extends nl{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}},ol=e=>new al(e);il(al);var sl=class extends nl{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}},cl=(...e)=>new sl(e),ll=il(sl),ul=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),dl=e=>{if(Gl.check(e))return[ul(e)];if(ll.check(e))return e.shape.map(e=>e+``);if(Wl.check(e))return[`[+-]?\\d+.?\\d*`];if(Kl.check(e))return[`.*`];if(Il.check(e))return e.shape.map(dl).flat(1);Ls()};il(class extends nl{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(dl).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 fl=Symbol(`optional`),pl=class extends nl{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[fl](){return!0}},ml=il(pl),hl=class extends nl{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new hl,il(hl);var gl=class e extends nl{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):bc(this.shape,(n,r)=>{let i=this._isPartial&&!xc(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},_l=e=>new gl(e),vl=il(gl),yl=ol(e=>e!=null&&(e.constructor===Object||e.constructor==null)),bl=class extends nl{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&bc(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)})}},xl=(e,t)=>new bl(e,t),Sl=il(bl),Cl=class extends nl{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&bc(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},wl=(...e)=>new Cl(e);il(Cl);var Tl=class extends nl{constructor(e){super(),this.shape=e.length===1?e[0]:new Pl(e)}check(e,t){let n=Do(e)&&wo(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},El=(...e)=>new Tl(e),Dl=il(Tl),Ol=ol(e=>Do(e)),kl=class extends nl{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}},Al=(e,t=null)=>new kl(e,t);il(kl);var jl=Al(nl),Ml=il(class extends nl{constructor(e){super(),this.len=e.length-1,this.args=wl(...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}}),Nl=ol(e=>typeof e==`function`);il(class extends nl{constructor(e){super(),this.shape=e}check(e,t){let n=wo(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Pl=class extends nl{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=To(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},Fl=(...e)=>e.findIndex(e=>Il.check(e))>=0?Fl(...e.map(e=>$l(e)).map(e=>Il.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Pl(e),Il=il(Pl),Ll=()=>!0,Rl=ol(Ll),zl=il(al,e=>e.shape===Ll),Bl=ol(e=>typeof e==`bigint`),Vl=ol(e=>e===Bl),Hl=ol(e=>typeof e==`symbol`);ol(e=>e===Hl);var Ul=ol(e=>typeof e==`number`),Wl=ol(e=>e===Ul),Gl=ol(e=>typeof e==`string`),Kl=ol(e=>e===Gl),ql=ol(e=>typeof e==`boolean`),Jl=ol(e=>e===ql),Yl=cl(void 0);il(sl,e=>e.shape.length===1&&e.shape[0]===void 0),cl(void 0);var Xl=cl(null),Zl=il(sl,e=>e.shape.length===1&&e.shape[0]===null);il(Uint8Array),il(rl,e=>e.shape===Uint8Array);var Ql=Fl(Ul,Gl,Xl,Yl,Bl,ql,Hl);(()=>{let e=El(Rl),t=xl(Gl,Rl),n=Fl(Ul,Gl,Xl,ql,e,t);return e.shape=n,t.shape.values=n,n})();var $l=e=>{if(jl.check(e))return e;if(yl.check(e)){let t={};for(let n in e)t[n]=$l(e[n]);return _l(t)}else if(Ol.check(e))return Fl(...e.map($l));else if(Ql.check(e))return cl(e);else if(Nl.check(e))return il(e);Ls()},eu=Lc?()=>{}:(e,t)=>{let n=new el;if(!t.check(e,n))throw Fs(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},tu=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:$l(e),h:t}),this}else(e){return this.if(Rl,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 Fs(`Unhandled pattern`)}}},nu=(e=>new tu(e))(Rl).if(Wl,(e,t)=>qc(t,Yo,Jo)).if(Kl,(e,t)=>Zc(t)).if(Jl,(e,t)=>Kc(t)).if(Vl,(e,t)=>BigInt(qc(t,Yo,Jo))).if(Il,(e,t)=>ru(t,Qc(t,e.shape))).if(vl,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(ml.check(i)){if(Kc(t))continue;i=i.shape}n[r]=nu(i,t)}return n}).if(Dl,(e,t)=>{let n=[],r=Jc(t,0,42);for(let i=0;i<r;i++)n.push(ru(t,e.shape));return n}).if(ll,(e,t)=>Qc(t,e.shape)).if(Zl,(e,t)=>null).if(Ml,(e,t)=>{let n=ru(t,e.res);return()=>n}).if(zl,(e,t)=>ru(t,Qc(t,[Ul,Gl,Xl,Yl,Bl,ql,El(Ul),xl(Fl(`a`,`b`,`c`),Ul)]))).if(Sl,(e,t)=>{let n={},r=qc(t,0,3);for(let i=0;i<r;i++){let r=ru(t,e.shape.keys);n[r]=ru(t,e.shape.values)}return n}).done(),ru=(e,t)=>nu($l(t),e),iu=typeof document<`u`?document:{},au=e=>iu.createElement(e),ou=()=>iu.createDocumentFragment();ol(e=>e.nodeType===vu);var su=e=>iu.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var cu=(e,t)=>(Gc(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),lu=e=>{let t=ou();for(let n=0;n<e.length;n++)mu(t,e[n]);return t},uu=(e,t)=>(mu(e,lu(t)),e),du=(e,t=[],n=[])=>uu(cu(au(e),t),n);ol(e=>e.nodeType===hu);var fu=su;ol(e=>e.nodeType===gu);var pu=e=>vo(e,(e,t)=>`${t}:${e};`).join(``),mu=(e,t)=>e.appendChild(t),hu=iu.ELEMENT_NODE,gu=iu.TEXT_NODE;iu.CDATA_SECTION_NODE,iu.COMMENT_NODE;var _u=iu.DOCUMENT_NODE;iu.DOCUMENT_TYPE_NODE;var vu=iu.DOCUMENT_FRAGMENT_NODE;ol(e=>e.nodeType===_u);var yu=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),bu=(e,t)=>new yu(setTimeout(t,e)),xu=Symbol,Su=xu(),Cu=xu(),wu=xu(),Tu=xu(),Eu=xu(),Du=xu(),Ou=xu(),ku=xu(),Au=xu(),ju=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};sc();var Mu={[Su]:Wc(`font-weight`,`bold`),[Cu]:Wc(`font-weight`,`normal`),[wu]:Wc(`color`,`blue`),[Eu]:Wc(`color`,`green`),[Tu]:Wc(`color`,`grey`),[Du]:Wc(`color`,`red`),[Ou]:Wc(`color`,`purple`),[ku]:Wc(`color`,`orange`),[Au]:Wc(`color`,`black`)},Nu=Rc?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=ho(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=Mu[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=pu(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}:ju,Pu=(...e)=>{console.log(...Nu(e)),Iu.forEach(t=>t.print(e))},Fu=(...e)=>{console.warn(...Nu(e)),e.unshift(ku),Iu.forEach(t=>t.print(e))},Iu=bo(),Lu=e=>({[Symbol.iterator](){return this},next:e}),Ru=(e,t)=>Lu(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),zu=(e,t)=>Lu(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),Bu=class{constructor(e,t){this.clock=e,this.len=t}},Vu=class{constructor(){this.clients=new Map}},Hu=(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])sf(e,i,o.clock,o.len,n)}}),Uu=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=Ao((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},Wu=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Uu(n,t.clock)!==null},Gu=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 Bu(r.clock,No(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},Ku=e=>{let t=new Vu;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++)So(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Gu(t),t},qu=(e,t,n,r)=>{_o(e.clients,t,()=>[]).push(new Bu(n,r))},Ju=()=>new Vu,Yu=e=>{let t=Ju();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 Bu(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Xu=(e,t)=>{Y(e.restEncoder,t.clients.size),Co(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),Y(e.restEncoder,t);let r=n.length;Y(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Zu=e=>{let t=new Vu,n=X(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=X(e.restDecoder),r=X(e.restDecoder);if(r>0){let i=_o(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new Bu(e.readDsClock(),e.readDsLen()))}}return t},Qu=(e,t,n)=>{let r=new Vu,i=X(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=X(e.restDecoder),a=X(e.restDecoder),o=n.clients.get(i)||[],s=Qd(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&qu(r,i,s,a-s);let e=ef(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,wm(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,wm(t,c,a-c.id.clock)),c.delete(t))}else qu(r,i,n,a-n)}}if(r.clients.size>0){let e=new cd;return Y(e.restEncoder,0),Xu(e,r),e.toUint8Array()}return null},$u=rc,ed=class e extends Oo{constructor({guid:e=oc(),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=$u(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Xd,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=cc(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>cc(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&&hf(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Co(this.subdocs).map(e=>e.guid))}transact(e,t=null){return hf(this,e,t)}get(e,t=Gf){let n=_o(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==Gf&&r!==t)if(r===Gf){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,fp)}getText(e=``){return this.get(e,Np)}getMap(e=``){return this.get(e,hp)}getXmlElement(e=``){return this.get(e,Rp)}getXmlFragment(e=``){return this.get(e,Ip)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,Co(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,hf(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()}},td=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return X(this.restDecoder)}readDsLen(){return X(this.restDecoder)}},nd=class extends td{readLeftID(){return Z(X(this.restDecoder),X(this.restDecoder))}readRightID(){return Z(X(this.restDecoder),X(this.restDecoder))}readClient(){return X(this.restDecoder)}readInfo(){return Gs(this.restDecoder)}readString(){return qs(this.restDecoder)}readParentInfo(){return X(this.restDecoder)===1}readTypeRef(){return X(this.restDecoder)}readLen(){return X(this.restDecoder)}readAny(){return Xs(this.restDecoder)}readBuf(){return Vc(Ws(this.restDecoder))}readJSON(){return JSON.parse(qs(this.restDecoder))}readKey(){return qs(this.restDecoder)}},rd=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=X(this.restDecoder),this.dsCurrVal}readDsLen(){let e=X(this.restDecoder)+1;return this.dsCurrVal+=e,e}},id=class extends rd{constructor(e){super(e),this.keys=[],X(e),this.keyClockDecoder=new $s(Ws(e)),this.clientDecoder=new Qs(Ws(e)),this.leftClockDecoder=new $s(Ws(e)),this.rightClockDecoder=new $s(Ws(e)),this.infoDecoder=new Zs(Ws(e),Gs),this.stringDecoder=new ec(Ws(e)),this.parentInfoDecoder=new Zs(Ws(e),Gs),this.typeRefDecoder=new Qs(Ws(e)),this.lenDecoder=new Qs(Ws(e))}readLeftID(){return new jd(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new jd(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 Xs(this.restDecoder)}readBuf(){return Ws(this.restDecoder)}readJSON(){return Xs(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}}},ad=class{constructor(){this.restEncoder=ls()}toUint8Array(){return fs(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Y(this.restEncoder,e)}writeDsLen(e){Y(this.restEncoder,e)}},od=class extends ad{writeLeftID(e){Y(this.restEncoder,e.client),Y(this.restEncoder,e.clock)}writeRightID(e){Y(this.restEncoder,e.client),Y(this.restEncoder,e.clock)}writeClient(e){Y(this.restEncoder,e)}writeInfo(e){hs(this.restEncoder,e)}writeString(e){ys(this.restEncoder,e)}writeParentInfo(e){Y(this.restEncoder,+!!e)}writeTypeRef(e){Y(this.restEncoder,e)}writeLen(e){Y(this.restEncoder,e)}writeAny(e){Os(this.restEncoder,e)}writeBuf(e){xs(this.restEncoder,e)}writeJSON(e){ys(this.restEncoder,JSON.stringify(e))}writeKey(e){ys(this.restEncoder,e)}},sd=class{constructor(){this.restEncoder=ls(),this.dsCurrVal=0}toUint8Array(){return fs(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,Y(this.restEncoder,t)}writeDsLen(e){e===0&&Ls(),Y(this.restEncoder,e-1),this.dsCurrVal+=e}},cd=class extends sd{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ns,this.clientEncoder=new js,this.leftClockEncoder=new Ns,this.rightClockEncoder=new Ns,this.infoEncoder=new ks(hs),this.stringEncoder=new Ps,this.parentInfoEncoder=new ks(hs),this.typeRefEncoder=new js,this.lenEncoder=new js}toUint8Array(){let e=ls();return Y(e,0),xs(e,this.keyClockEncoder.toUint8Array()),xs(e,this.clientEncoder.toUint8Array()),xs(e,this.leftClockEncoder.toUint8Array()),xs(e,this.rightClockEncoder.toUint8Array()),xs(e,fs(this.infoEncoder)),xs(e,this.stringEncoder.toUint8Array()),xs(e,fs(this.parentInfoEncoder)),xs(e,this.typeRefEncoder.toUint8Array()),xs(e,this.lenEncoder.toUint8Array()),bs(e,fs(this.restEncoder)),fs(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){Os(this.restEncoder,e)}writeBuf(e){xs(this.restEncoder,e)}writeJSON(e){Os(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)}},ld=(e,t,n,r)=>{r=No(r,t[0].id.clock);let i=ef(t,r);Y(e.restEncoder,t.length-i),e.writeClient(n),Y(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)},ud=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{Qd(t,n)>e&&r.set(n,e)}),Zd(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),Y(e.restEncoder,r.size),Co(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{ld(e,t.clients.get(n),n,r)})},dd=(e,t)=>{let n=ho(),r=X(e.restDecoder);for(let i=0;i<r;i++){let r=X(e.restDecoder),i=Array(r),a=e.readClient(),o=X(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 qp(Z(a,o),t),o+=t;break}case 10:{let t=X(e.restDecoder);i[n]=new jm(Z(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new Dm(Z(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,Om(e,r));i[n]=c,o+=c.length}}}}return n},fd=(e,t,n)=>{let r=[],i=Co(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 Xd,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!==jm){let i=_o(d,u.id.client,()=>Qd(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,Qd(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 cd;return ud(e,s,new Map),Y(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},pd=(e,t)=>ud(e,t.doc.store,t.beforeState),md=(e,t,n,r=new id(e))=>hf(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=fd(e,i,dd(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<Qd(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=Tf([o.update,a.update])}}else i.pendingStructs=a;let s=Qu(r,e,i);if(i.pendingDs){let t=new id(Vs(i.pendingDs));X(t.restDecoder);let n=Qu(t,e,i);s&&n?i.pendingDs=Tf([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,hd(e.doc,t)}},n,!1),hd=(e,t,n,r=id)=>{let i=Vs(t);md(i,e,n,new r(i))},gd=(e,t,n)=>hd(e,t,n,nd),_d=(e,t,n=new Map)=>{ud(e,t.store,n),Xu(e,Yu(t.store))},vd=(e,t=new Uint8Array([0]),n=new cd)=>{_d(n,e,xd(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Ef(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===od)return Cf(r.map((e,t)=>t===0?e:jf(e)));if(n.constructor===cd)return Tf(r)}return r[0]},yd=(e,t)=>vd(e,t,new od),bd=e=>{let t=new Map,n=X(e.restDecoder);for(let r=0;r<n;r++){let n=X(e.restDecoder),r=X(e.restDecoder);t.set(n,r)}return t},xd=e=>bd(new td(Vs(e))),Sd=(e,t)=>(Y(e.restEncoder,t.size),Co(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{Y(e.restEncoder,t),Y(e.restEncoder,n)}),e),Cd=(e,t)=>Sd(e,Zd(t.store)),wd=(e,t=new sd)=>(e instanceof Map?Sd(t,e):Cd(t,e),t.toUint8Array()),Td=e=>wd(e,new ad),Ed=class{constructor(){this.l=[]}},Dd=()=>new Ed,Od=(e,t)=>e.l.push(t),kd=(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.`)},Ad=(e,t,n)=>Tc(e.l,[t,n]),jd=class{constructor(e,t){this.client=e,this.clock=t}},Md=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,Z=(e,t)=>new jd(e,t),Nd=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw Ls()},Pd=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Fd=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},Id=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},Ld=e=>new Fd(e.type==null?null:Z(e.type.client,e.type.clock),e.tname??null,e.item==null?null:Z(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),Rd=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},zd=(e,t,n=0)=>new Rd(e,t,n),Bd=(e,t,n)=>{let r=null,i=null;return e._item===null?i=Nd(e):r=Z(e._item.id.client,e._item.id.clock),new Fd(r,i,t,n)},Vd=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Bd(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Bd(e,Z(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Bd(e,r.lastId,n);r=r.right}return Bd(e,null,n)},Hd=(e,t)=>{let n=tf(e,t);return{item:n,diff:t.clock-n.id.clock}},Ud=(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(Qd(r,i.client)<=i.clock)return null;let e=n?Sm(r,i):Hd(r,i),t=e.item;if(!(t instanceof Dm))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(Qd(r,a.client)<=a.clock)return null;let{item:e}=n?Sm(r,a):{item:tf(r,a)};if(e instanceof Dm&&e.content instanceof bm)c=e.content.type;else return null}else throw Ls();l=s>=0?c._length:0}return zd(c,l,e.assoc)},Wd=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Md(e.item,t.item)&&Md(e.type,t.type)&&e.assoc===t.assoc,Gd=class{constructor(e,t){this.ds=e,this.sv=t}},Kd=(e,t)=>new Gd(e,t);Kd(Ju(),new Map);var qd=e=>Kd(Yu(e.store),Zd(e.store)),Jd=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Wu(t.ds,e.id),Yd=(e,t)=>{let n=_o(e.meta,Yd,bo),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<Qd(r,n)&&rf(e,Z(n,t))}),Hu(e,t.ds,e=>{}),n.add(t))},Xd=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Zd=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},Qd=(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},$d=(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 Ls()}n.push(t)},ef=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=Ao(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=Ao((n+r)/2)}throw Ls()},tf=(e,t)=>{let n=e.clients.get(t.client);return n[ef(n,t.clock)]},nf=(e,t,n)=>{let r=ef(t,n),i=t[r];return i.id.clock<n&&i instanceof Dm?(t.splice(r+1,0,wm(e,i,n-i.id.clock)),r+1):r},rf=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[nf(e,n,t.clock)]},af=(e,t,n)=>{let r=t.clients.get(n.client),i=ef(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==qp&&r.splice(i+1,0,wm(e,a,n.clock-a.id.clock+1)),a},of=(e,t,n)=>{let r=e.clients.get(t.id.client);r[ef(r,t.id.clock)]=n},sf=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=nf(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&nf(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},cf=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Vu,this.beforeState=Zd(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}},lf=(e,t)=>t.deleteSet.clients.size===0&&!yo(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Gu(t.deleteSet),pd(e,t),Xu(e,t.deleteSet),!0),uf=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&_o(e.changed,t,bo).add(n)},df=(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 Dm&&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},ff=(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=ef(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 Dm&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},pf=(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=Mo(r.length-1,1+ef(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+df(r,e)}})},mf=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Gu(a),n.afterState=Zd(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(()=>{Ad(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Ap(n)})}),Tc(e,[])}finally{r.gc&&ff(a,i,r.gcFilter),pf(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=No(ef(e,r),1);for(let t=e.length-1;t>=n;)t-=1+df(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=ef(r,n);a+1<r.length&&df(r,a+1)>1||a>0&&df(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Pu(ku,Su,`[yjs] `,Cu,Du,`Changed the client-id because another client seems to be using it.`),r.clientID=$u()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new od;lf(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new cd;lf(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])):mf(e,t+1)}}},hf=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new cf(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&&mf(i,0)}}return o},gf=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},_f=(e,t,n)=>{Hu(e,n.deletions,n=>{n instanceof Dm&&t.scope.some(t=>t===e.doc||Pd(t,n))&&Cm(n,!1)})},vf=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;hf(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;Hu(n,o.insertions,e=>{if(e instanceof Dm){if(e.redone!==null){let{item:t,diff:i}=Sm(r,e.id);i>0&&(t=rf(n,Z(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||Pd(t,e))&&c.push(e)}}),Hu(n,o.deletions,e=>{e instanceof Dm&&a.some(t=>t===n.doc||Pd(t,e))&&!Wu(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Em(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},yf=class extends Oo{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=Do(e)?e[0].doc:e instanceof ed?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 Vu;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&qu(i,n,r,a)});let a=sc(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=Ku([t.deletions,e.deleteSet]),t.insertions=Ku([t.insertions,i])}else r.push(new gf(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),Hu(e,e.deleteSet,t=>{t instanceof Dm&&this.scope.some(n=>n===e.doc||Pd(n,t))&&Cm(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=Do(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof Gf?e.doc!==this.doc:e!==this.doc)&&Fu(`[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=>_f(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>_f(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=vf(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=vf(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*bf(e){let t=X(e.restDecoder);for(let n=0;n<t;n++){let t=X(e.restDecoder),n=e.readClient(),r=X(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=X(e.restDecoder);yield new jm(Z(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new Dm(Z(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,Om(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new qp(Z(n,r),t),r+=t}}}}var xf=class{constructor(e,t){this.gen=bf(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===jm);return this.curr}},Sf=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Cf=e=>Tf(e,nd,od),wf=(e,t)=>{if(e.constructor===qp){let{client:n,clock:r}=e.id;return new qp(Z(n,r+t),e.length-t)}else if(e.constructor===jm){let{client:n,clock:r}=e.id;return new jm(Z(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new Dm(Z(r,i+t),null,Z(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Tf=(e,t=id,n=cd)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Vs(e))),i=r.map(e=>new xf(e,!0)),a=null,o=new n,s=new Sf(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===jm?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)Of(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===jm)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{Of(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new jm(Z(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===jm?a.struct.length-=t:n=wf(n,t)),a.struct.mergeWith(n)||(Of(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!==jm;n=e.next())Of(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Of(s,a.struct,a.offset),a=null),kf(s),Xu(o,Ku(r.map(e=>Zu(e)))),o.toUint8Array()},Ef=(e,t,n=id,r=cd)=>{let i=xd(t),a=new r,o=new Sf(a),s=new n(Vs(e)),c=new xf(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===jm){c.next();continue}if(e.id.clock+e.length>n)for(Of(o,e,No(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Of(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 kf(o),Xu(a,Zu(s)),a.toUint8Array()},Df=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:fs(e.encoder.restEncoder)}),e.encoder.restEncoder=ls(),e.written=0)},Of=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Df(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),Y(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},kf=e=>{Df(e);let t=e.encoder.restEncoder;Y(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];Y(t,r.written),bs(t,r.restEncoder)}},Af=(e,t,n,r)=>{let i=new n(Vs(e)),a=new xf(i,!1),o=new r,s=new Sf(o);for(let e=a.curr;e!==null;e=a.next())Of(s,t(e),0);return kf(s),Xu(o,Zu(i)),o.toUint8Array()},jf=e=>Af(e,Ec,id,od),Mf=`You must not compute changes after the event-handler fired.`,Nf=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||=Pf(this.currentTarget,this.target)}deletes(e){return Wu(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Fs(Mf);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=xo(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=xo(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=xo(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 Fs(Mf);let t=this.target,n=bo(),r=bo(),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}},Pf=(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},Ff=()=>{Fu(`Invalid access: Add Yjs type to a document before reading data.`)},If=80,Lf=0,Rf=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Lf++}},zf=e=>{e.timestamp=Lf++},Bf=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Lf++},Vf=(e,t,n)=>{if(e.length>=If){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return Bf(r,t,n),r}else{let r=new Rf(t,n);return e.push(r),r}},Hf=(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)=>jo(t-e.index)<jo(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,zf(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&&jo(n.index-i)<r.parent.length/If?(Bf(n,r,i),n):Vf(e._searchMarker,r,i)},Uf=(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=No(t,i.index+n))}},Wf=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;_o(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Ad(r._eH,n,t)},Gf=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Dd(),this._dEH=Dd(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Is()}clone(){throw Is()}_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){Od(this._eH,e)}observeDeep(e){Od(this._dEH,e)}unobserve(e){kd(this._eH,e)}unobserveDeep(e){kd(this._dEH,e)}toJSON(){}},Kf=(e,t,n)=>{e.doc??Ff(),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},qf=e=>{e.doc??Ff();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},Jf=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Jd(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},Yf=(e,t)=>{let n=0,r=e._start;for(e.doc??Ff();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}},Xf=(e,t)=>{let n=[];return Yf(e,(r,i)=>{n.push(t(r,i,e))}),n},Zf=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}}}},Qf=(e,t)=>{e.doc??Ff();let n=Hf(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}},$f=(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 Dm(Z(o,Qd(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new cm(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 Dm(Z(o,Qd(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Jp(new Uint8Array(n))),i.integrate(e,0);break;case ed:i=new Dm(Z(o,Qd(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new $p(n)),i.integrate(e,0);break;default:if(n instanceof Gf)i=new Dm(Z(o,Qd(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new bm(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},ep=()=>Fs(`Length exceeded!`),tp=(e,t,n,r)=>{if(n>t._length)throw ep();if(n===0)return t._searchMarker&&Uf(t._searchMarker,n,r.length),$f(e,t,null,r);let i=n,a=Hf(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&&rf(e,Z(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&Uf(t._searchMarker,i,r.length),$f(e,t,o,r)},np=(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 $f(e,t,r,n)},rp=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=Hf(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&&rf(e,Z(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&rf(e,Z(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw ep();t._searchMarker&&Uf(t._searchMarker,i,-a+r)},ip=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},ap=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new cm([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new cm([r]);break;case Uint8Array:s=new Jp(r);break;case ed:s=new $p(r);break;default:if(r instanceof Gf)s=new bm(r);else throw Error(`Unexpected content type`)}new Dm(Z(o,Qd(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},op=(e,t)=>{e.doc??Ff();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},sp=e=>{let t={};return e.doc??Ff(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},cp=(e,t)=>{e.doc??Ff();let n=e._map.get(t);return n!==void 0&&!n.deleted},lp=(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&&Jd(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},up=e=>(e.doc??Ff(),Ru(e._map.entries(),e=>!e[1].deleted)),dp=class extends Nf{},fp=class e extends Gf{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 Gf?e.clone():e)),t}get length(){return this.doc??Ff(),this._length}_callObserver(e,t){super._callObserver(e,t),Wf(this,e,new dp(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):hf(this.doc,n=>{tp(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):hf(this.doc,t=>{np(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):hf(this.doc,n=>{rp(n,this,e,t)})}get(e){return Qf(this,e)}toArray(){return qf(this)}slice(e=0,t=this.length){return Kf(this,e,t)}toJSON(){return this.map(e=>e instanceof Gf?e.toJSON():e)}map(e){return Xf(this,e)}forEach(e){Yf(this,e)}[Symbol.iterator](){return Zf(this)}_write(e){e.writeTypeRef(pm)}},pp=e=>new fp,mp=class extends Nf{constructor(e,t,n){super(e,t),this.keysChanged=n}},hp=class e extends Gf{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 Gf?e.clone():e)}),t}_callObserver(e,t){Wf(this,e,new mp(this,e,t))}toJSON(){this.doc??Ff();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof Gf?r.toJSON():r}}),e}get size(){return[...up(this)].length}keys(){return zu(up(this),e=>e[0])}values(){return zu(up(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return zu(up(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Ff(),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):hf(this.doc,t=>{ip(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):hf(this.doc,n=>{ap(n,this,e,t)}),t}get(e){return op(this,e)}has(e){return cp(this,e)}clear(){this.doc===null?this._prelimContent.clear():hf(this.doc,e=>{this.forEach(function(t,n,r){ip(e,r,n)})})}_write(e){e.writeTypeRef(mm)}},gp=e=>new hp,_p=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&Sc(e,t),vp=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&Ls(),this.right.content.constructor){case rm:this.right.deleted||Sp(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}},yp=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case rm:t.right.deleted||Sp(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&rf(e,Z(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},bp=(e,t,n,r)=>{let i=new Map,a=r?Hf(t,n):null;return a?yp(e,new vp(a.p.left,a.p,a.index,i),n-a.index):yp(e,new vp(null,t._start,0,i),n)},xp=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===rm&&_p(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 Dm(Z(a,Qd(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new rm(o,r));l.integrate(e,0),n.right=l,n.forward()})},Sp=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Cp=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===rm&&_p(t[e.right.content.key]??null,e.right.content.value));)e.forward()},wp=(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(!_p(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new Dm(Z(a,Qd(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new rm(s,c)),n.right.integrate(e,0),n.forward()}}return o},Tp=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Cp(n,i);let s=wp(e,t,n,i),c=r.constructor===String?new um(r):r instanceof Gf?new bm(r):new tm(r),{left:l,right:u,index:d}=n;t._searchMarker&&Uf(t._searchMarker,n.index,c.getLength()),u=new Dm(Z(o,Qd(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(),xp(e,t,n,s)},Ep=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Cp(n,i);let s=wp(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===rm));){if(!n.right.deleted)switch(n.right.content.constructor){case rm:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(_p(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&&rf(e,Z(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+=`
|
|
4
4
|
`;n.right=new Dm(Z(o,Qd(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new um(i)),n.right.integrate(e,0),n.forward()}xp(e,t,n,s)},Dp=(e,t,n,r,i)=>{let a=t,o=ho();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===rm){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 rm:{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&&Sp(i,n);break}}}t=t.right}return s},Op=(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===rm){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},kp=e=>{let t=0;return hf(e.doc,n=>{let r=e._start,i=e._start,a=ho(),o=go(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case rm:Sp(o,i.content);break;default:t+=Dp(n,r,i,a,o),a=go(o),r=i;break}i=i.right}}),t},Ap=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&&sf(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===rm&&e.constructor!==qp&&t.add(e.parent)})}hf(n,n=>{Hu(e,e.deleteSet,e=>{if(e instanceof qp||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===rm?t.add(r):Op(n,e)});for(let e of t)kp(e)})},jp=(e,t,n)=>{let r=n,i=go(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case bm:case tm:case um:n<t.right.length&&rf(e,Z(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&Dp(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&Uf(o._searchMarker,t.index,-r+n),t},Mp=class extends Nf{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=[];hf(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},yc(o)||(e.attributes=hc({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case bm:case tm: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 um: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 rm:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(_p(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),_p(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;_p(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(_p(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Sp(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}},Np=class e extends Gf{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Ff(),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 Mp(this,e,t);Wf(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Ff();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===um&&(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)):hf(this.doc,n=>{let r=new vp(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)===`
|
|
5
5
|
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Tp(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&jp(n,r,a.delete):Ep(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??Ff();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(Jd(s,e)||t!==void 0&&Jd(s,t))switch(s.content.constructor){case um:{let r=i.get(`ychange`);e!==void 0&&!Jd(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&&!Jd(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 bm:case tm:{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 rm:Jd(s,e)&&(c(),Sp(i,s.content));break}s=s.right}c()};return e||t?hf(a,n=>{e&&Yd(n,e),t&&Yd(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)):hf(r,r=>{let i=bp(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Tp(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):hf(r,r=>{let i=bp(r,this,e,!n);Tp(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)):hf(n,n=>{jp(n,bp(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)):hf(r,r=>{let i=bp(r,this,e,!1);i.right!==null&&Ep(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):hf(this.doc,t=>{ip(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):hf(this.doc,n=>{ap(n,this,e,t)})}getAttribute(e){return op(this,e)}getAttributes(){return sp(this)}_write(e){e.writeTypeRef(hm)}},Pp=e=>new Np,Fp=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Ff()}[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===Rp||t.constructor===Ip)&&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})}},Ip=class e extends Gf{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 Gf?e.clone():e)),t}get length(){return this.doc??Ff(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Fp(this,e)}querySelector(e){e=e.toUpperCase();let t=new Fp(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Co(new Fp(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Wf(this,e,new Bp(this,t,e))}toString(){return Xf(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),Yf(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):hf(this.doc,n=>{tp(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)hf(this.doc,n=>{let r=e&&e instanceof Gf?e._item:e;$f(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 Fs(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):hf(this.doc,n=>{rp(n,this,e,t)})}toArray(){return qf(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Qf(this,e)}slice(e=0,t=this.length){return Kf(this,e,t)}forEach(e){Yf(this,e)}_write(e){e.writeTypeRef(_m)}},Lp=e=>new Ip,Rp=class e extends Ip{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 _c(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof Gf?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):hf(this.doc,t=>{ip(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):hf(this.doc,n=>{ap(n,this,e,t)})}getAttribute(e){return op(this,e)}hasAttribute(e){return cp(this,e)}getAttributes(e){return e?lp(this,e):sp(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 Yf(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(gm),e.writeKey(this.nodeName)}},zp=e=>new Rp(e.readKey()),Bp=class extends Nf{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)})}},Vp=class e extends hp{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(vm),e.writeKey(this.hookName)}},Hp=e=>new Vp(e.readKey()),Up=class e extends Np{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(ym)}},Wp=e=>new Up,Gp=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Is()}mergeWith(e){return!1}write(e,t,n){throw Is()}integrate(e,t){throw Is()}},Kp=0,qp=class extends Gp{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),$d(e.doc.store,this)}write(e,t){e.writeInfo(Kp),e.writeLen(this.length-t)}getMissing(e,t){return null}},Jp=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 Is()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},Yp=e=>new Jp(e.readBuf()),Xp=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){qu(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}},Zp=e=>new Xp(e.readLen()),Qp=(e,t)=>new ed({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),$p=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(Qp(this.doc.guid,this.opts))}splice(e){throw Is()}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}},em=e=>new $p(Qp(e.readString(),e.readAny())),tm=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 Is()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},nm=e=>new tm(e.readJSON()),rm=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 Is()}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}},im=e=>new rm(e.readKey(),e.readJSON()),am=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}},om=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 am(n)},sm=Fc(`node_env`)===`development`,cm=class e{constructor(e){this.arr=e,sm&&wc(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}},lm=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new cm(n)},um=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}},dm=e=>new um(e.readString()),fm=[pp,gp,Pp,zp,Lp,Hp,Wp],pm=0,mm=1,hm=2,gm=3,_m=4,vm=5,ym=6,bm=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 Is()}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}},xm=e=>new bm(fm[e.readTypeRef()](e)),Sm=(e,t)=>{let n=t,r=0,i;do r>0&&(n=Z(n.client,n.clock+r)),i=tf(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Dm);return{item:i,diff:r}},Cm=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},wm=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Dm(Z(r,i+n),t,Z(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=Z(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},Tm=(e,t)=>To(e,e=>Wu(e.deletions,t)),Em=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return rf(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Em(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=rf(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:rf(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:rf(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||Wu(r,d.right.id)||Tm(a.undoStack,d.right.id)||Tm(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=rf(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=Z(c,Qd(s,c)),h=new Dm(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,Cm(h,!0),h.integrate(e,0),h},Dm=class e extends Gp{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>=Qd(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Qd(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===jd&&this.id.client!==this.parent.client&&this.parent.clock>=Qd(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=af(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=rf(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===qp||this.right&&this.right.constructor===qp)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===jd){let e=tf(n,this.parent);e.constructor===qp?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=af(e,e.doc.store,Z(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),Md(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(Md(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(tf(e.doc.store,n.origin)))r.has(tf(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),$d(e.doc.store,this),this.content.integrate(e,this),uf(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new qp(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:Z(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Md(e.origin,this.lastId)&&this.right===e&&Md(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(),qu(e.deleteSet,this.id.client,this.id.clock,this.length),uf(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw Ls();this.content.gc(e),t?of(e,this,new qp(this.id,this.length)):this.content=new Xp(this.length)}write(e,t){let n=t>0?Z(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=Nd(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===jd?(e.writeParentInfo(!1),e.writeLeftID(t)):Ls();i!==null&&e.writeString(i)}this.content.write(e,t)}},Om=(e,t)=>km[t&31](e),km=[()=>{Ls()},Zp,om,Yp,dm,nm,im,xm,lm,em,()=>{Ls()}],Am=10,jm=class extends Gp{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){Ls()}write(e,t){e.writeInfo(Am),Y(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Mm=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Nm=`__ $YJS$ __`;Mm[Nm]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Mm[Nm]=!0;var Pm=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},Fm=/[\uD800-\uDBFF]/,Im=/[\uDC00-\uDFFF]/,Lm=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&Fm.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&Im.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},Rm=(e,t)=>e>>>t|e<<32-t,zm=e=>Rm(e,2)^Rm(e,13)^Rm(e,22),Bm=e=>Rm(e,6)^Rm(e,11)^Rm(e,25),Vm=e=>Rm(e,7)^Rm(e,18)^e>>>3,Hm=e=>Rm(e,17)^Rm(e,19)^e>>>10,Um=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Wm=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Gm=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Wm),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=Hm(t[e-2])+t[e-7]+Vm(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+Bm(o)+(o&s^~o&c)+Um[e]+t[e]>>>0,d=zm(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/qo,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},Km=e=>new Gm().digest(e),qm=new nt(`y-sync`),Jm=new nt(`y-undo`),Ym=new nt(`yjs-cursor`),Xm=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},Zm=e=>Bc(Xm(Km(Hc(e)))),Qm=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!Wu(t.ds,e.id),$m=[{light:`#ecd44433`,dark:`#ecd444`}],eh=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=bo();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,ic(t))}return e.get(n)},th=(e,{colors:t=$m,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new ah(e,a),c=new he({props:{editable:e=>{let t=qm.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:qm,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(qm);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&bu(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=Jm.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},qm)})}},destroy:()=>{s.destroy()}})});return c},nh=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new je(e.doc));else if(t.type===`node`){let r=Ph(n.doc,n.type,t.anchor,n.mapping);e.setSelection(rh(e,r))}else{let r=Ph(n.doc,n.type,t.anchor,n.mapping),i=Ph(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(st.between(e.doc.resolve(r),e.doc.resolve(i)))}},rh=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?ke.create(e.doc,t):st.near(n)},ih=(e,t)=>({type:t.selection.jsonID,anchor:Mh(t.selection.anchor,e.type,e.mapping),head:Mh(t.selection.head,e.type,e.mapping)}),ah=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=Pm(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=ih(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta(`addToHistory`,!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Ac&&this._domSelectionInView===null&&(bu(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=iu.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=Kd(Ju(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(qm,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>sh(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new v(it.from(e),0,0));t.setMeta(qm,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>sh(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new v(it.from(t),0,0));if(e){let t=Mo(No(e.anchor,0),n.doc.content.size),r=Mo(No(e.head,0),n.doc.content.size);n.setSelection(st.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(qm,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=qd(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&Ls(),r=new ed({gc:!1}),hd(r,t),t=qd(r),hd(r,e),e=qd(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[ef(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{Hu(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:eh(n.colorMapping,n.colors,r)}},s=Jf(i,new Gd(t.ds,e.sv)).map(n=>!n._item.deleted||Qm(n._item,e)||Qm(n._item,t)?sh(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new v(it.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(qm,{isChangeOrigin:!0}))},qm)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=qm.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);Hu(t,t.deleteSet,e=>{if(e.constructor===Dm){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>oh(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new v(it.from(n),0,0));nh(r,this.beforeTransactionSelection,this),r=r.setMeta(qm,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof yf}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{Th(this.doc,this.type,e,this),this.beforeTransactionSelection=ih(this,this.prosemirrorView.state)},qm)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.on(`afterAllTransactions`,this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.off(`afterAllTransactions`,this.afterAllTransactions))}},oh=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof Rp)return sh(e,t,n,r,i,a);throw Is()}return o},sh=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof Rp){let s=oh(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof Np&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=ch(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):Jf(e,new Gd(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(Qm(e._item,r)?Qm(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=t.node(e.nodeName,s,o);return n.mapping.set(e,c),c}catch(r){console.warn(`[y-prosemirror] schema.node(`+e.nodeName+`) threw:`,String(r&&r.message||r));let i=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};if(t.nodes[e.nodeName]&&t.nodes[e.nodeName].spec&&t.nodes[e.nodeName].spec.inline)i.inline++;else if(i.block++,t.nodes.rawMdxFallback)try{let i=t.node(`rawMdxFallback`,{reason:String(r&&r.message||r)},[t.text(e.nodeName)]);return n.mapping.set(e,i),i}catch(e){console.warn(`[y-prosemirror] rawMdxFallback substitution also failed:`,String(e&&e.message||e))}return n.mapping.delete(e),null}},ch=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,Ch(n.attributes,t)))}}catch(e){console.warn(`[y-prosemirror] schema.text() threw:`,String(e&&e.message||e));let t=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};return t.inline++,null}return o},lh=(e,t)=>{let n=new Up,r=e.map(e=>({insert:e.text,attributes:wh(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},uh=(e,t)=>{let n=new Rp(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,mh(e).map(e=>dh(e,t))),t.mapping.set(n,e),n},dh=(e,t)=>e instanceof Array?lh(e,t):uh(e,t),fh=e=>typeof e==`object`&&!!e,ph=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===Object.keys(t).filter(e=>t[e]!==null).length;for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||fh(o)&&fh(s)&&ph(o,s)}return r},mh=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},hh=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&gc(e.attributes||{}).length===t[n].marks.length&&bc(e.attributes,(e,r)=>{let i=Sh(r),a=t[n].marks;return a.find(e=>e.type.name===i)?ph(e,a.find(e=>e.type.name===i)?.attrs):!1}))},gh=(e,t)=>{if(e instanceof Rp&&!(t instanceof Array)&&Eh(e,t)){let n=mh(t);return e._length===n.length&&ph(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>gh(e,n[t]))}return e instanceof Up&&t instanceof Array&&hh(e,t)},_h=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),vh=(e,t,n)=>{let r=e.toArray(),i=mh(t),a=i.length,o=r.length,s=Mo(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(_h(n.mapping.get(e),t))u=!0;else if(!gh(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(_h(n.mapping.get(e),t))u=!0;else if(!gh(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},yh=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof um?t+=n.content.str:n.content instanceof rm&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},bh=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=yh(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,wh(e.marks,n))})),{insert:o,remove:s,index:c}=Lm(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},xh=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Sh=e=>xh.exec(e)?.[1]??e,Ch=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(Sh(r),e[r]));return n},wh=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=_o(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${Zm(e.toJSON())}`:e.type.name]=e.attrs}}),n},Th=(e,t,n,r)=>{if(t instanceof Rp&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof Rp){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=mh(n),a=i.length,o=t.toArray(),s=o.length,c=Mo(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!_h(r.mapping.get(e),t))if(gh(e,t))r.mapping.set(e,t);else break}for(;u+l+1<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!_h(r.mapping.get(e),t))if(gh(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof Up&&c instanceof Array)hh(n,c)||bh(n,c,r),l+=1;else{let i=n instanceof Rp&&Eh(n,c),a=d instanceof Rp&&Eh(d,f);if(i&&a){let e=vh(n,c,r),t=vh(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(Th(e,n,c,r),l+=1):a?(Th(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[dh(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof Up?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(dh(i[t],r));t.insert(l,e)}},qm)},Eh=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,Dh=null,Oh=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=qm.getState(this.view.state);if(e&&e.binding&&!e.binding.isDestroyed){let e=this.view.state.tr;e.setMeta(this.key,this.value),this.view.dispatch(e)}}},kh=class e{constructor(e=[]){this.entries=e}getFirst(){return this.entries[0]}dequeueFirst(){return this.entries.shift()}isEmpty(){return this.entries.length===0}static fromViewsToUpdate(){let t=Dh;Dh=null;let n=[];return t.forEach((e,t)=>{e.forEach((e,r)=>{n.push(new Oh(t,r,e))})}),new e(n)}},Ah=(e=kh.fromViewsToUpdate(),t=!1)=>{let n=!0;for(;!e.isEmpty();){let r=e.getFirst();try{r.apply()}catch(r){if(r instanceof RangeError){t&&n&&e.dequeueFirst(),e.isEmpty()||bu(0,()=>Ah(e,!0));return}throw r}n=!1,e.dequeueFirst()}},jh=(e,t,n)=>{Dh||(Dh=new Map,bu(0,Ah)),_o(Dh,e,ho).set(t,n)},Mh=(e,t,n)=>{if(e===0)return Vd(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof Up){if(r._length>=e)return Vd(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new Fd(r._item===null?null:r._item.id,r._item===null?Nd(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new Fd(r._item===null?null:r._item.id,r._item===null?Nd(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw Ls();if(e===0&&r.constructor!==Up&&r!==t)return Nh(r._item.parent,r._item)}return Vd(t,t._length,-1)},Nh=(e,t)=>{let n=null,r=null;return e._item===null?r=Nd(e):n=Z(e._item.id.client,e._item.id.clock),new Fd(n,r,t.id)},Ph=(e,t,n,r)=>{let i=Ud(n,e);if(i===null||i.type!==t&&!Pd(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===Up)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;t++,n instanceof Up?o+=n._length:o+=r.get(n).nodeSize}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;t.deleted||(e instanceof Up?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1},Fh=(e,t,n)=>e!==t,Ih=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(``),i=document.createTextNode(``);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},Lh=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),Rh=/^#[0-9a-fA-F]{6}$/,zh=(e,t,n,r,i)=>{let a=qm.getState(e);if(a==null||a.doc==null||a.binding==null)return ze.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?ze.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:Rh.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=Ph(o,a.type,Ld(t.cursor.anchor),a.binding.mapping),u=Ph(o,a.type,Ld(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=No(e.doc.content.size-1,0);l=Mo(l,t),u=Mo(u,t),s.push(We.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=Mo(l,u),o=No(l,u);s.push(We.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),ze.create(e.doc,s))},Bh=(e,{awarenessStateFilter:t=Fh,cursorBuilder:n=Ih,selectionBuilder:r=Lh,getSelection:i=e=>e.selection}={},a=`cursor`)=>new he({key:Ym,state:{init(i,a){return zh(a,e,t,n,r)},apply(i,a,o,s){let c=qm.getState(s),l=i.getMeta(Ym);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?zh(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>Ym.getState(e)},view:t=>{let n=()=>{t.docView&&jh(t,Ym,{awarenessUpdated:!0})},r=()=>{let n=qm.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=Mh(o.anchor,n.type,n.binding.mapping),c=Mh(o.head,n.type,n.binding.mapping);(r.cursor==null||!Wd(Ld(r.cursor.anchor),s)||!Wd(Ld(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&Ph(n.doc,n.type,Ld(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)};return e.on(`change`,n),t.dom.addEventListener(`focusin`,r),t.dom.addEventListener(`focusout`,r),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,r),t.dom.removeEventListener(`focusout`,r),e.off(`change`,n),e.setLocalStateField(a,null)}}}}),Vh=e=>{let t=Jm.getState(e).undoManager;if(t!=null)return t.undo(),!0},Hh=e=>{let t=Jm.getState(e).undoManager;if(t!=null)return t.redo(),!0},Uh=new Set([`paragraph`]),Wh=(e,t)=>!(e instanceof Dm)||!(e.content instanceof bm)||!(e.content.type instanceof Np||e.content.type instanceof Rp&&t.has(e.content.type.nodeName))||e.content.type._length===0,Gh=({protectedNodes:e=Uh,trackedOrigins:t=[],undoManager:n=null}={})=>new he({key:Jm,state:{init:(r,i)=>{let a=qm.getState(i),o=n||new yf(a.type,{trackedOrigins:new Set([qm].concat(t)),deleteFilter:t=>Wh(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=qm.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:ih(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=qm.getState(e.state),n=Jm.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,Jm.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}});me({event:O(`ok-branch-switched-clear-failed`),branch:pe(),docName:pe(),reason:pe()});async function Kh(e,t){let n=[];for(let[r,i]of e.entries)i.kind===`active`&&i.persistence!==null&&n.push(i.persistence.clearData().catch(e=>{let n={event:`ok-branch-switched-clear-failed`,docName:r,branch:t,reason:e instanceof Error?e.message:String(e)};console.warn(JSON.stringify(n))}));await Promise.all(n),e.clearBufferedUpdates(),e.recycleAllEntries()}function qh(e){let t=!1;return()=>{t?e():t=!0}}function Jh(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Yh(e,t=``){let n;try{n=await fetch(`${t}/api/server-info`,{signal:AbortSignal.timeout(5e3)})}catch{return}if(!n.ok)return;let r;try{r=await n.json()}catch{return}let i=w.safeParse(r);if(!i.success){console.warn(JSON.stringify({event:`ok-server-info-schema-mismatch`,issues:i.error.issues}));return}if(e.setExpectedServerInstanceId(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&Kh(e,i.data.currentBranch),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=Jh(n)}catch{}e.observeDiskAckBatch(t)}}async function Xh(e){let t;try{t=await fetch(`/api/config`,{signal:e,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return{status:`error`,code:`network`}}if(t.status===404||t.status===501)return{status:`absent`};if(!t.ok)return{status:`error`,code:t.status};let n;try{n=await t.json()}catch{return{status:`error`,code:`invalid-body`}}if(typeof n!=`object`||!n||Array.isArray(n))return{status:`error`,code:`invalid-body`};let r=n;return{status:`ok`,config:{collabUrl:typeof r.collabUrl==`string`?r.collabUrl:null,previewUrl:typeof r.previewUrl==`string`?r.previewUrl:null,port:typeof r.port==`number`?r.port:0}}}function Zh(e){return ig(e,ot)}function Qh(e){return ig(e,p)}function $h(e){return ig(e,ct)}function eg(e){return ig(e,ve)}function tg(e){let t=ig(e,ee);if(!t)return null;try{return{docName:t.docName,sv:ng(t.sv)}}catch{return null}}function ng(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function rg(e,t){let n=Qh(e);if(n){t.onServerInfo?.(n);return}let r=$h(e);if(r){t.onBranchSwitched?.(r);return}let i=tg(e);if(i){t.onDiskAck?.(i);return}let a=Zh(e);if(a){t.onDerivedView?.(a);return}let o=eg(e);if(o){t.onConfigValidationRejected?.(o);return}t.onUnknown?.(e)}function ig(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function ag(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function og(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function sg(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var cg=2e3,lg=15e3;function ug(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??cg,r=e.maxDelayMs??lg,i=e.log??{info:console.info,warn:console.warn},a=new AbortController,o=null,s=n,c=0,l=!1,u=!1,d=null,f=e.now(),p=async()=>{c+=1;let n=null;try{let t=await e.fetchConfig(a.signal);t.status===`absent`?(n=e.fallbackUrl(),d=null):t.status===`ok`&&t.config.collabUrl!==null?(n=t.config.collabUrl,d=null):t.status===`ok`?(u||(u=!0,i.info(`[collab-url] ok ui responded but server.lock has no port yet — retrying`)),d={kind:`null-collab`}):t.status===`error`&&(i.warn(`[collab-url] /api/config error (${t.code}) — retrying in ${s}ms`),d={kind:`error`,code:t.code})}catch(e){if(e.name===`AbortError`)return;d={kind:`error`,code:`network`}}if(!l){if(n!==null){e.onStateChange({collabUrl:n,attempts:c,terminal:!1,lastError:null});return}if(e.now()-f>=t){e.onStateChange({collabUrl:null,attempts:c,terminal:!0,lastError:d});return}e.onStateChange({collabUrl:null,attempts:c,terminal:!1,lastError:d}),o=e.setTimeout(()=>{p()},s),s=Math.min(s*2,r)}};return p(),{cancel:()=>{l=!0,a.abort(),o!==null&&(e.clearTimeout(o),o=null)}}}function dg(){let e=(0,q.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,G.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,G.useRef)(i),[o,s]=(0,G.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=og(typeof window<`u`?window:void 0);if(t){r(sg(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(sg(t))});return()=>{n()}}let n=ug({fetchConfig:Xh,fallbackUrl:ag,now:Date.now,setTimeout:hg,clearTimeout:mg,onStateChange:t=>{e===a.current.token&&r(t)}});return()=>{n.cancel()}},e[2]=c):c=e[2];let l;e[3]===o?l=e[4]:(l=[o],e[3]=o,e[4]=l),(0,G.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(pg),s(fg)},e[5]=u):u=e[5];let d=u,f;return e[6]===n?f=e[7]:(f={...n,retry:d},e[6]=n,e[7]=f),f}function fg(e){return e+1}function pg(e){return{...e,terminal:!1,lastError:null}}function mg(e){return globalThis.clearTimeout(e)}function hg(e,t){return globalThis.setTimeout(e,t)}function gg(e){try{let t=e.state;return Jm.getState(t)?.undoManager??null}catch{return null}}function _g(e){return!(e.viewCount>0&&e.viewCount>=50||e.bytes>5e5)}var vg=new Map,yg=new Map,bg=[],xg=[],Sg=new Set,Cg=null;function wg(){if(Cg)return Cg;if(typeof document>`u`||typeof document.createElement!=`function`)return null;let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-parking`,``),e.style.display=`none`,e.style.position=`absolute`,e.style.left=`-99999px`,Cg=e,e}function Tg(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!_g(i)){let e=r(n);return J(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`}),{editor:e.editor,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,__uncached:!0}}let a=vg.get(t);if(a){if(Ng(a,n),a.activeMountKey=t,Fg(bg,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return J(`ok/cache/hit`,{docName:t,kind:`tiptap`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;vg.size>=10;){let e=Ig(bg,t);if(!e)break;Dg(e)}let o=r(n),s={editor:o.editor,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t};return vg.set(t,s),Fg(bg,t),J(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function Eg(e){if(e.__uncached){let t=gg(e.editor);try{e.editor.destroy()}catch{}t&&(t.restore=void 0),e.activeMountKey=null;return}let t=jg(e.editor);if(t){e.hadFocus=Mg(t.dom),e.scrollTop=(t.scrollDOM??t.dom.parentElement??t.dom).scrollTop??0;let n=t.dom.parentElement;n&&n.removeChild(t.dom);let r=wg();r&&r.appendChild(t.dom)}e.activeMountKey=null}function Dg(e){let t=vg.get(e);if(!t)return!1;let n=gg(t.editor);try{t.editor.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}n&&(n.restore=void 0);try{t.provider.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}vg.delete(e);let r=bg.indexOf(e);return r!==-1&&bg.splice(r,1),J(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function Og(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!_g(i)){let e=r(n);return J(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,__uncached:!0}}let a=yg.get(t);if(a){if(Pg(a,n),a.activeMountKey=t,Fg(xg,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return J(`ok/cache/hit`,{docName:t,kind:`cm`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;yg.size>=10;){let e=Ig(xg,t);if(!e)break;Ag(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t};return yg.set(t,s),Fg(xg,t),J(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function kg(e){if(e.__uncached){try{e.view.destroy()}catch{}e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=Mg(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t);let r=wg();r&&r.appendChild(t),e.activeMountKey=null}function Ag(e){let t=yg.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}yg.delete(e);let n=xg.indexOf(e);return n!==-1&&xg.splice(n,1),J(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function jg(e){return e.editorView??null}function Mg(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function Ng(e,t){let n=jg(e.editor);if(!n)return;let r=n.dom,i=r.parentElement;i&&i!==t&&i.removeChild(r),r.parentElement!==t&&t.appendChild(r)}function Pg(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function Fg(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function Ig(e,t){for(let n of e)if(n!==t&&!Sg.has(n))return n;J(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:Sg.size});for(let n of e)if(n!==t)return n;return null}function Lg(e){let t=Sg,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=zg(e);if(t)try{t.disconnect(),J(`ok/cache/disconnect`,{docName:e})}catch(t){J(`ok/cache/disconnect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}}for(let e of n){if(t.has(e))continue;let n=zg(e);if(!n)continue;let r=t=>{J(`ok/cache/connect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})};try{let t=n.connect();t&&typeof t.then==`function`?t.then(()=>J(`ok/cache/connect`,{docName:e}),e=>r(e)):J(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}Sg=n}var Rg=null;function zg(e){let t=vg.get(e);if(t)return t.provider;let n=yg.get(e);if(n)return n.provider;if(Rg){let t=Rg.entries.get(e);if(t)return t.provider}return null}function Bg(e){Rg=e;let t=e.onEvict(e=>{Dg(e),Ag(e)});return()=>{t(),Rg===e&&(Rg=null)}}var Vg=Math.floor,Hg=(e,t)=>e<t?e:t,Ug=(e,t)=>e>t?e:t;Number.isNaN;var Wg=128,Gg=1<<17,Kg=1<<18,qg=1<<19,Jg=1<<20,Yg=1<<21,Xg=1<<22,Zg=1<<23,Qg=1<<24,$g=1<<25,e_=1<<26,t_=1<<27,n_=1<<28,r_=1<<29,i_=1<<30,a_=127;Gg-1,Kg-1,qg-1,Jg-1,Yg-1,Xg-1,Zg-1,Qg-1,$g-1,e_-1,t_-1,n_-1,r_-1,i_-1;var o_=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var s_=String.fromCharCode;String.fromCodePoint,s_(65535);var c_=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},l_=typeof TextEncoder<`u`?new TextEncoder:null,u_=l_?e=>l_.encode(e):c_,d_=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});d_&&d_.decode(new Uint8Array).length===1&&(d_=null);var f_=(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},p_=(e,t)=>{for(;t>a_;)f_(e,Wg|a_&t),t=Vg(t/128);f_(e,a_&t)},m_=new Uint8Array(3e4),h_=m_.length/3,g_=l_&&l_.encodeInto?(e,t)=>{if(t.length<h_){let n=l_.encodeInto(t,m_).written||0;p_(e,n);for(let t=0;t<n;t++)f_(e,m_[t])}else v_(e,u_(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;p_(e,r);for(let t=0;t<r;t++)f_(e,n.codePointAt(t))},__=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Hg(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(Ug(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},v_=(e,t)=>{p_(e,t.byteLength),__(e,t)},y_=e=>Error(e),b_=y_(`Unexpected end of array`),x_=y_(`Integer out of Range`),S_=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},C_=e=>S_(e,T_(e)),w_=e=>e.arr[e.pos++],T_=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&a_)*n,n*=128,r<Wg)return t;if(t>o_)throw x_}throw b_},E_=d_?e=>d_.decode(C_(e)):e=>{let t=T_(e);if(t===0)return``;{let n=String.fromCodePoint(w_(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(w_(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))}},D_=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),O_=(e,t)=>{p_(e,D_.Token),g_(e,t)},k_=(e,t,n,r)=>{switch(T_(e)){case D_.Token:t();break;case D_.PermissionDenied:n(E_(e));break;case D_.Authenticated:r(E_(e));break;default:}},A_=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),j_=`\0`;function M_(e,t){return e+j_+t}function N_(e){let t=e.indexOf(j_);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var P_=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 F_(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 I_(e){return new Promise(t=>setTimeout(t,e))}function L_(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 R_(e,t){let n=F_(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||L_;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 I_(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 I_(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await I_(e)}return a()}var z_=Math.floor,B_=(e,t)=>e<t?e:t,V_=(e,t)=>e>t?e:t;Number.isNaN;var H_=64,U_=128,W_=1<<17,G_=1<<18,K_=1<<19,q_=1<<20,J_=1<<21,Y_=1<<22,X_=1<<23,Z_=1<<24,Q_=1<<25,$_=1<<26,ev=1<<27,tv=1<<28,nv=1<<29,rv=1<<30,iv=63,av=127;W_-1,G_-1,K_-1,q_-1,J_-1,Y_-1,X_-1,Z_-1,Q_-1,$_-1,ev-1,tv-1,nv-1,rv-1;var ov=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var sv=()=>new Set,cv=Array.from;Array.isArray;var lv=String.fromCharCode;String.fromCodePoint,lv(65535);var uv=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},dv=typeof TextEncoder<`u`?new TextEncoder:null,fv=dv?e=>dv.encode(e):uv,pv=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});pv&&pv.decode(new Uint8Array).length===1&&(pv=null);var mv=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},hv=()=>new mv,gv=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},_v=e=>{let t=new Uint8Array(gv(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},vv=(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},yv=(e,t)=>{for(;t>av;)vv(e,U_|av&t),t=z_(t/128);vv(e,av&t)},bv=new Uint8Array(3e4),xv=bv.length/3,Sv=dv&&dv.encodeInto?(e,t)=>{if(t.length<xv){let n=dv.encodeInto(t,bv).written||0;yv(e,n);for(let t=0;t<n;t++)vv(e,bv[t])}else wv(e,fv(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;yv(e,r);for(let t=0;t<r;t++)vv(e,n.codePointAt(t))},Cv=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=B_(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(V_(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},wv=(e,t)=>{yv(e,t.byteLength),Cv(e,t)},Tv=e=>Error(e),Ev=Tv(`Unexpected end of array`),Dv=Tv(`Integer out of Range`),Ov=class{constructor(e){this.arr=e,this.pos=0}},kv=e=>new Ov(e),Av=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},jv=e=>Av(e,Nv(e)),Mv=e=>e.arr[e.pos++],Nv=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&av)*n,n*=128,r<U_)return t;if(t>ov)throw Dv}throw Ev},Pv=e=>{let t=e.arr[e.pos++],n=t&iv,r=64,i=(t&H_)>0?-1:1;if((t&U_)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&av)*r,r*=128,t<U_)return i*n;if(n>ov)throw Dv}throw Ev},Fv=pv?e=>pv.decode(jv(e)):e=>{let t=Nv(e);if(t===0)return``;{let n=String.fromCodePoint(Mv(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Mv(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))}},Iv=e=>{let t=e.pos,n=Fv(e);return e.pos=t,n},Lv=Date.now,Rv=()=>new Map,zv=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Bv=class{constructor(){this._observers=Rv()}on(e,t){zv(this._observers,e,sv).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 cv((this._observers.get(e)||Rv()).values()).forEach(e=>e(...t))}destroy(){this._observers=Rv()}},Vv=Symbol(`Equality`),Hv=Object.keys,Uv=e=>Hv(e).length,Wv=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Gv=(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[Vv]!=null)return e[Vv](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)||!Gv(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Uv(e)!==Uv(t))return!1;for(let n in e)if(!Wv(e,n)||!Gv(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(!Gv(e[n],t[n]))return!1;break;default:return!1}return!0},Kv=3e4,qv=class extends Bv{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Lv();this.getLocalState()!==null&&Kv/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&Kv<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&Jv(this,t,`timeout`)},z_(Kv/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:Lv()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Gv(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}},Jv=(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:Lv()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},Yv=(e,t,n=e.states)=>{let r=t.length,i=hv();yv(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;yv(i,r),yv(i,s),Sv(i,JSON.stringify(o))}return _v(i)},Xv=(e,t,n)=>{let r=kv(t),i=Lv(),a=[],o=[],s=[],c=[],l=Nv(r);for(let t=0;t<l;t++){let t=Nv(r),n=Nv(r),l=JSON.parse(Fv(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&&(Gv(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])},Zv=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={}}},Qv=class{constructor(e){this.data=e,this.encoder=hv(),this.decoder=kv(new Uint8Array(this.data))}peekVarString(){return Iv(this.decoder)}readVarUint(){return Nv(this.decoder)}readVarString(){return Fv(this.decoder)}readVarUint8Array(){return jv(this.decoder)}writeVarUint(e){return yv(this.encoder,e)}writeVarString(e){return Sv(this.encoder,e)}writeVarUint8Array(e){return wv(this.encoder,e)}length(){return gv(this.encoder)}},$v=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}({}),ey=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),ty=class{constructor(){this.encoder=hv()}get(e){return e.encoder}toUint8Array(){return _v(this.encoder)}},ny=class extends ty{constructor(...e){super(...e),this.type=$v.CLOSE,this.description=`Ask the server to close the connection`}get(e){return Sv(this.encoder,e.documentName),yv(this.encoder,this.type),this.encoder}},ry=class e extends Zv{static{this.DEDUPLICATABLE_TYPES=new Set([$v.Awareness,$v.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=ey.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=ey.Connected,this.emit(`status`,{status:ey.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===ey.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===ey.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(ny,{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===ey.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:R_(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=ey.Connecting,this.emit(`status`,{status:ey.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=Lv();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===$v.Ping){this.sendPong();return}let n=new Qv(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=hv();yv(e,$v.Pong),this.send(_v(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=ey.Connected,this.emit(`status`,{status:ey.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===ey.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Lv()-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=kv(e);return{documentName:Fv(t),messageType:Nv(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===P_.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=ey.Disconnected,this.emit(`status`,{status:ey.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()}},iy=0,ay=1,oy=2,sy=(e,t)=>{yv(e,iy),wv(e,Td(t))},cy=(e,t,n)=>{yv(e,ay),wv(e,yd(t,n))},ly=(e,t,n)=>cy(t,n,jv(e)),uy=(e,t,n,r)=>{try{gd(t,jv(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},dy=(e,t)=>{yv(e,oy),wv(e,t)},fy=uy,py=(e,t,n,r,i)=>{let a=Nv(e);switch(a){case iy:ly(e,t,n);break;case ay:uy(e,n,r,i);break;case oy:fy(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},my=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case $v.Sync:this.applySyncMessage(e,t);break;case $v.Awareness:this.applyAwarenessMessage(e);break;case $v.Auth:this.applyAuthMessage(e);break;case $v.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case $v.Stateless:e.receiveStateless(Fv(n.decoder));break;case $v.SyncStatus:this.applySyncStatusMessage(e,Pv(n.decoder)===1);break;case $v.CLOSE:let i={code:1e3,reason:Fv(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(ty,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint($v.Sync);let r=py(n.decoder,n.encoder,e.document,e);t&&r===ay&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;Xv(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;k_(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($v.Awareness),t.writeVarUint8Array(Yv(e.awareness,Array.from(e.awareness.getStates().keys())))}},hy=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return _v(this.encoder)}send(e){e?.send(this.create())}},gy=`4.0.0-rc.1`,_y=class extends ty{constructor(...e){super(...e),this.type=$v.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return Sv(this.encoder,e.documentName),yv(this.encoder,this.type),O_(this.encoder,e.token),Sv(this.encoder,gy),this.encoder}},vy=class extends ty{constructor(...e){super(...e),this.type=$v.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`);Sv(this.encoder,e.documentName),yv(this.encoder,this.type);let t;return t=e.states===void 0?Yv(e.awareness,e.clients):Yv(e.awareness,e.clients,e.states),wv(this.encoder,t),this.encoder}},yy=class extends ty{constructor(...e){super(...e),this.type=$v.Stateless,this.description=`A stateless message`}get(e){return Sv(this.encoder,e.documentName),yv(this.encoder,this.type),Sv(this.encoder,e.payload??``),this.encoder}},by=class extends ty{constructor(...e){super(...e),this.type=$v.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 Sv(this.encoder,e.documentName),yv(this.encoder,this.type),sy(this.encoder,e.document),this.encoder}},xy=class extends ty{constructor(...e){super(...e),this.type=$v.Sync,this.description=`A document update`}get(e){return Sv(this.encoder,e.documentName),yv(this.encoder,this.type),dy(this.encoder,e.update),this.encoder}},Sy=class extends Error{constructor(...e){super(...e),this.code=1001}},Cy=class extends Zv{get effectiveName(){return this.configuration.sessionAwareness?M_(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 ed,this.configuration.awareness=e.awareness===void 0?new qv(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:A_(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:A_(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 ry(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(by,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&Jv(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(yy,{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(_y,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(xy,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(vy,{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(by,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(vy,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new hy(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new Qv(e.data),{documentName:n}=N_(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new Qv(e.data)}),new my(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Jv(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&&(Jv(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 Sy(`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)}},wy=e=>cc((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),Ty=(e,t)=>cc((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(Fs(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),Ey=e=>wy(indexedDB.deleteDatabase(e)),Dy=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),Oy=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>zy(r,e))},ky=(e,t)=>wy(e.count(t)),Ay=(e,t)=>wy(e.get(t)),jy=(e,t)=>wy(e.delete(t)),My=(e,t,n)=>wy(e.put(t,n)),Ny=(e,t)=>wy(e.add(t)),Py=(e,t,n)=>wy(e.getAll(t,n)),Fy=(e,t,n)=>{let r=null;return Ry(e,t,e=>(r=e,!1),n).then(()=>r)},Iy=(e,t=null)=>Fy(e,t,`prev`),Ly=(e,t)=>cc((n,r)=>{e.onerror=r,e.onsuccess=async e=>{let r=e.target.result;if(r===null||await t(r)===!1)return n();r.continue()}}),Ry=(e,t,n,r=`next`)=>Ly(e.openKeyCursor(t,r),e=>n(e.key)),zy=(e,t)=>e.objectStore(t),By=(e,t)=>IDBKeyRange.upperBound(e,t),Vy=(e,t)=>IDBKeyRange.lowerBound(e,t),Hy=`custom`,Uy=`updates`,Wy=(e,t=()=>{},n=()=>{})=>{let[r]=Oy(e.db,[Uy]);return Py(r,Vy(e._dbref,!1)).then(i=>{e._destroyed||(t(r),hf(e.doc,()=>{i.forEach(t=>gd(e.doc,t))},e,!1),n(r))}).then(()=>Iy(r).then(t=>{e._dbref=t+1})).then(()=>ky(r).then(t=>{e._dbsize=t})).then(()=>r)},Gy=(e,t=!0)=>Wy(e).then(n=>{(t||e._dbsize>=500)&&Ny(n,yd(e.doc)).then(()=>jy(n,By(e._dbref,!0))).then(()=>ky(n).then(t=>{e._dbsize=t}))}),Ky=class extends ko{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=Ty(e,e=>Dy(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=cc(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,Wy(this,async e=>{await ky(e)>0&&Ny(e,yd(t))},()=>{if(this._destroyed)return this;this.synced=!0,this.emit(`synced`,[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(e,t)=>{if(this.db&&t!==this){let[t]=Oy(this.db,[Uy]);Ny(t,e).catch(e=>{globalThis.__okYdbWriteWarned||(globalThis.__okYdbWriteWarned=!0,console.warn(JSON.stringify({event:`ok-ydb-write-failed`,cause:e?.name??`unknown`,message:e?.message??String(e)})))}),++this._dbsize>=500&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{Gy(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on(`update`,this._storeUpdate),this.destroy=this.destroy.bind(this),t.on(`destroy`,this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off(`update`,this._storeUpdate),this.doc.off(`destroy`,this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{Ey(this.name)})}get(e){return this._db.then(t=>{let[n]=Oy(t,[Hy],`readonly`);return Ay(n,e)})}set(e,t){return this._db.then(n=>{let[r]=Oy(n,[Hy]);return My(r,t,e)})}del(e){return this._db.then(t=>{let[n]=Oy(t,[Hy]);return jy(n,e)})}},qy=class{_idb;_dbName;whenSynced;constructor({branch:e,serverInstanceId:t,docName:n,doc:r}){if(typeof t!=`string`||t.length===0)throw Error(`createClientPersistence: serverInstanceId is required and must be non-empty`);this._dbName=`ok-ydoc:${e}:${t}:${n}`,this._idb=new Ky(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>this)}get synced(){return this._idb.synced}async destroy(){await this._idb.destroy()}async clearData(){await this._idb.destroy();let e=this._dbName;await new Promise((t,n)=>{let r=indexedDB.deleteDatabase(e);r.onsuccess=()=>t(),r.onerror=()=>n(r.error),r.onblocked=()=>{console.warn(JSON.stringify({event:`ok-client-persistence-clear-blocked`,dbName:e})),n(Error(`idb-clear-blocked: ${e}`))}})}};function Jy(e){return new qy(e)}function Yy(e){return Td(e)}function Xy(e,t){return t===null?yd(e):yd(e,t)}function Zy(e,t){if(e===null)return t;if(t===null)return e;let n=xd(e),r=xd(t),i=new Map;for(let[e,t]of n)i.set(e,t);for(let[e,t]of r){let n=i.get(e);(n===void 0||t>n)&&i.set(e,t)}return Td(i)}function Qy(e){let t={};if(i.inject(r.active(),t),!t.traceparent)return e;let n=e.includes(`?`)?`&`:`?`,a=[`traceparent=${encodeURIComponent(t.traceparent)}`];return t.tracestate&&a.push(`tracestate=${encodeURIComponent(t.tracestate)}`),`${e}${n}${a.join(`&`)}`}var $y=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new he({key:e||new nt(`fileHandler`),props:{handleDrop(e,n){if(!r||!n.dataTransfer?.files.length)return!1;let a=e.posAtCoords({left:n.clientX,top:n.clientY}),o=Array.from(n.dataTransfer.files);return i&&(o=o.filter(e=>i.includes(e.type))),o.length===0?!1:(n.preventDefault(),n.stopPropagation(),r(t,o,a?.pos||0),!0)},handlePaste(e,r){if(!n||!r.clipboardData?.files.length)return!1;let a=Array.from(r.clipboardData.files),o=r.clipboardData.getData(`text/html`);return i&&(a=a.filter(e=>i.includes(e.type))),!(a.length===0||(r.preventDefault(),r.stopPropagation(),n(t,a,o),o.length>0))}}}),eb=V.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[$y({key:new nt(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}}),tb=V.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof ke){let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=st.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof st?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof ke))return!1;let n=t.selection.from,r=t.doc.resolve(n);if(r.index(r.depth)===0)return!1;let i=r.before(r.depth);if(i<=0)return!1;let a=t.doc.resolve(i-1).nodeBefore;if(!a||i-1-a.nodeSize+1<0)return!1;try{let n=ke.create(t.doc,i-a.nodeSize);return e.view.dispatch(t.tr.setSelection(n).scrollIntoView()),!0}catch{return!1}},ArrowDown:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof ke))return!1;let n=t.selection.from+t.selection.node.nodeSize;if(n>=t.doc.content.size)return!1;try{if(!t.doc.nodeAt(n))return!1;let r=ke.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch{return!1}},Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof st)||!t.selection.empty)return!1;let n=t.selection.$from,r=n.parent;if(r.type.name!==`paragraph`||r.textContent!==``||n.depth<2)return!1;let i=-1;for(let e=n.depth-1;e>=1;e--)if(n.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;let a=n.node(i);if(n.index(i)!==a.childCount-1)return!1;let o=n.after(i);if(o>t.doc.content.size)return!1;let s=t.tr,c=n.before(n.depth),l=n.after(n.depth);s.delete(c,l);let u=o-(l-c),d=t.schema.nodes.paragraph.create();s.insert(u,d);let f=u+1;return s.setSelection(st.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),nb=new WeakMap;function rb(e,t){if(t===null){nb.delete(e);return}nb.set(e,t)}function ib(e){return nb.get(e)??null}function ab(e){return`pagesBySlug`in e}function ob(e){return ab(e)?e.pages:e}function sb(e,t){let n=se(e);if(n){if(ab(t))return t.pagesBySlug.get(n);for(let e of t)if(se(e)===n)return e}}function cb(e){let t=e.trim();if(!t)return null;let n=se(t);return n?{target:n,alias:n===t?null:t,anchor:null}:null}function lb(e){let t=e.trim();if(!t)return[];let n=se(t);return n.length>0&&n!==t?[n]:[]}function ub(e,t){let n=e.trim();if(!n)return!1;let r=ob(t);return r.has(n)||lb(n).some(e=>r.has(e))?!0:sb(n,t)!==void 0}var db={ChevronRight:Zn};function fb(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn(db,t)?db[t]:null}function pb(e){let t=(0,q.c)(24),n;t[0]===e.icon?n=t[1]:(n=fb(e.icon),t[0]=e.icon,t[1]=n);let r=n,i=r?`custom`:void 0,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,K.jsx)(Zn,{size:14,className:`accordion-chevron`,"aria-hidden":`true`}),t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=r?(0,K.jsx)(r,{size:16,className:`accordion-icon`,"aria-hidden":`true`}):null,t[3]=r,t[4]=o);let s=e.title??`Accordion`,c;t[5]===s?c=t[6]:(c=(0,K.jsx)(`span`,{className:`accordion-title`,children:s}),t[5]=s,t[6]=c);let l;t[7]===e.description?l=t[8]:(l=e.description?(0,K.jsx)(`span`,{className:`accordion-description`,children:e.description}):null,t[7]=e.description,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,K.jsxs)(`span`,{className:`accordion-title-group`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==u?(d=(0,K.jsxs)(`summary`,{className:`accordion-summary`,contentEditable:!1,children:[a,o,u]}),t[12]=o,t[13]=u,t[14]=d):d=t[14];let f;t[15]===e.children?f=t[16]:(f=(0,K.jsx)(`div`,{className:`accordion-body`,children:e.children}),t[15]=e.children,t[16]=f);let p;return t[17]!==e.defaultOpen||t[18]!==e.id||t[19]!==e.name||t[20]!==i||t[21]!==d||t[22]!==f?(p=(0,K.jsxs)(`details`,{className:`accordion`,"data-accordion-icon":i,open:e.defaultOpen,id:e.id,name:e.name,children:[d,f]}),t[17]=e.defaultOpen,t[18]=e.id,t[19]=e.name,t[20]=i,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function mb(e){return e!==!1}function hb(e){let t=(0,q.c)(10),n=e.src,r=e.title,i;t[0]===e.controls?i=t[1]:(i=mb(e.controls),t[0]=e.controls,t[1]=i);let a;return t[2]!==e.autoplay||t[3]!==e.loop||t[4]!==e.muted||t[5]!==e.preload||t[6]!==e.src||t[7]!==e.title||t[8]!==i?(a=(0,K.jsx)(`audio`,{className:`ok-audio`,src:n,title:r,controls:i,autoPlay:e.autoplay,loop:e.loop,muted:e.muted,preload:e.preload}),t[2]=e.autoplay,t[3]=e.loop,t[4]=e.muted,t[5]=e.preload,t[6]=e.src,t[7]=e.title,t[8]=i,t[9]=a):a=t[9],a}var gb={note:cr,tip:lr,important:mr,warning:D,caution:gr},_b={Info:cr,Lightbulb:lr,MessageSquareWarning:mr,AlertTriangle:D,AlertOctagon:gr};function vb(e,t){if(!e||!e.startsWith(`lucide:`))return gb[t];let n=e.slice(7);return Object.hasOwn(_b,n)?_b[n]:gb[t]}function yb(e){return e===`note`||e===`tip`||e===`important`||e===`warning`||e===`caution`?e:`note`}function bb(e){let t=(0,q.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=yb(e.type),n=vb(e.icon,r),t[0]=e.icon,t[1]=e.type,t[2]=n,t[3]=r):(n=t[2],r=t[3]);let i=n,a;t[4]===e.color?a=t[5]:(a=e.color?{"--callout-type-color":e.color}:{},t[4]=e.color,t[5]=a);let o=a,s;t[6]!==i||t[7]!==e.title?(s=e.title||i?(0,K.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,K.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,K.jsx)(`span`,{className:`callout-title`,children:e.title}):null]}):null,t[6]=i,t[7]=e.title,t[8]=s):s=t[8];let c=s;if(e.collapsible){let n=e.defaultOpen??!0,i;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,K.jsx)(Zn,{size:14,className:`callout-chevron`,"aria-hidden":`true`}),t[9]=i):i=t[9];let a;t[10]===c?a=t[11]:(a=c??(0,K.jsx)(`span`,{className:`callout-title`,children:`Details`}),t[10]=c,t[11]=a);let s;t[12]===a?s=t[13]:(s=(0,K.jsxs)(`summary`,{className:`callout-summary`,contentEditable:!1,children:[i,a]}),t[12]=a,t[13]=s);let l;t[14]===e.children?l=t[15]:(l=(0,K.jsx)(`div`,{className:`callout-body`,children:e.children}),t[14]=e.children,t[15]=l);let u;return t[16]!==n||t[17]!==o||t[18]!==s||t[19]!==l||t[20]!==r?(u=(0,K.jsxs)(`details`,{className:`callout callout-collapsible`,"data-callout-type":r,open:n,style:o,children:[s,l]}),t[16]=n,t[17]=o,t[18]=s,t[19]=l,t[20]=r,t[21]=u):u=t[21],u}let l;t[22]===e.children?l=t[23]:(l=(0,K.jsx)(`div`,{className:`callout-body`,children:e.children}),t[22]=e.children,t[23]=l);let u;return t[24]!==c||t[25]!==o||t[26]!==l||t[27]!==r?(u=(0,K.jsxs)(`div`,{className:`callout callout-static`,"data-callout-type":r,style:o,children:[c,l]}),t[24]=c,t[25]=o,t[26]=l,t[27]=r,t[28]=u):u=t[28],u}function xb(){return G.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},G.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function Sb(){return G.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},G.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function Cb(e){return typeof Element>`u`?!1:e instanceof Element}var wb=(e,t)=>Cb(t)&&t.tagName.toUpperCase()===e,Tb=e=>wb(`DIV`,e)||wb(`SPAN`,e),Eb=e=>wb(`IMG`,e),Db=e=>e.complete&&e.naturalHeight!==0,Ob=e=>wb(`SVG`,e),kb=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),Ab=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=kb({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},jb=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?Ab({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):kb({height:e,offset:r,width:t}),Mb=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,Nb=e=>{if(e!==null){if(Eb(e))return e.currentSrc===``?void 0:e.currentSrc;if(Tb(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return Mb.exec(t)?.[1]}}},Pb=e=>{if(e!==null)return Eb(e)?e.alt:e.getAttribute(`aria-label`)??void 0},Fb=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=jb({containerHeight:e,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s});return{top:n,left:t,width:r*c,height:e*c,transform:`translate(0,0) scale(${1/c})`}},Ib=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},Lb=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,objectFit:a,objectPosition:o,offset:s,targetHeight:c,targetWidth:l})=>{let u=a;if(u===`scale-down`&&(u=l<=r&&c<=e?`none`:`contain`),u===`cover`||u===`contain`){let a=r/l,d=e/c,f=u===`cover`?Math.max(a,d):Math.min(a,d),[p=`50%`,m=`50%`]=o.split(` `),h=Ib({position:p,relativeNum:r-l*f}),g=Ib({position:m,relativeNum:e-c*f}),_=jb({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+g,left:t+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(u===`none`){let[a=`50%`,u=`50%`]=o.split(` `),d=Ib({position:a,relativeNum:r-l}),f=Ib({position:u,relativeNum:e-c}),p=jb({containerHeight:c,containerWidth:l,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+f,left:t+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else if(u===`fill`){let t=r/l,n=e/c,a=Math.max(t,n),o=jb({containerHeight:c*a,containerWidth:l*a,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{width:r*o,height:e*o,transform:`translate(0,0) scale(${1/o})`}}else return{}},Rb=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:i,containerWidth:a,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l})=>{if(t===`cover`||t===`contain`){let u=a/l,d=n/c,f=t===`cover`?Math.max(u,d):Math.min(u,d),[p=`50%`,m=`50%`]=e.split(` `),h=Ib({position:p,relativeNum:a-l*f}),g=Ib({position:m,relativeNum:n-c*f}),_=jb({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+g,left:r+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(t===`auto`){let[t=`50%`,u=`50%`]=e.split(` `),d=Ib({position:t,relativeNum:a-l}),f=Ib({position:u,relativeNum:n-c}),p=jb({containerHeight:c,containerWidth:l,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+f,left:r+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else{let[u=`50%`,d=`50%`]=t.split(` `),f=Ib({position:u,relativeNum:a}),p=Ib({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=Ib({position:_,relativeNum:a-l*g}),b=Ib({position:v,relativeNum:n-c*g}),x=jb({containerHeight:c*g,containerWidth:l*g,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+b,left:r+y,width:l*g*x,height:c*g*x,transform:`translate(0,0) scale(${1/x})`}}},zb=/\.svg$/i,Bb=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:i,offset:a,shouldRefresh:o,targetEl:s})=>{let c=n||t?.slice(0,18)===`data:image/svg+xml`||e||t!==void 0&&zb.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&Tb(s),f=i!=null&&!d,p=i!=null&&i.naturalHeight!==0?i.naturalHeight:l.height,m=i!=null&&i.naturalWidth!==0?i.naturalWidth:l.width,h=Fb({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?Lb({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,objectFit:u.objectFit,objectPosition:u.objectPosition,offset:a,targetHeight:p,targetWidth:m}):void 0,_=d?Rb({backgroundPosition:u.backgroundPosition,backgroundSize:u.backgroundSize,containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}):void 0,v={...h,...g,..._};if(r){let e=window.innerWidth/2,t=window.innerHeight/2,n=parseFloat(String(v.left??0))+parseFloat(String(v.width??0))/2,r=parseFloat(String(v.top??0))+parseFloat(String(v.height??0))/2,i=e-n,a=t-r;o&&(v.transitionDuration=`0.01ms`),v.transform=`translate(${i}px,${a}px) scale(1)`}return v},Vb=e=>{if(e==null)return{};if(Ob(e)){let{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{let e=t.getBoundingClientRect();return{height:n.height,left:e.left-n.left,top:e.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},Hb=e=>{let t=`-zoom`,n=[`clip-path`,`fill`,`mask`,`marker-start`,`marker-mid`,`marker-end`],r=new Map;if(e.hasAttribute(`id`)){let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}e.querySelectorAll(`[id]`).forEach(e=>{let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}),r.forEach((t,r)=>{let i=`url(#${r})`,a=`url(#${t})`,o=n.map(e=>`[${e}="${i}"]`).join(`, `);e.querySelectorAll(o).forEach(e=>{n.forEach(t=>{e.getAttribute(t)===i&&e.setAttribute(t,a)})})}),e.querySelectorAll(`style`).forEach(e=>{r.forEach((t,n)=>{let{textContent:r}=e;if(r!==``){let i=e;i.textContent=r.replaceAll(`#${n}`,`#${t}`)}})})},Ub=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),Wb={overflow:``,width:``};function Gb(){let e=document.querySelector(`[data-rmiz-portal]`);if(e!=null)return e;let t=document.createElement(`div`);return t.setAttribute(`data-rmiz-portal`,``),document.body.appendChild(t),t}function Kb(e){e.preventDefault()}function qb(e){return G.createElement(Jb,{...e})}var Jb=class extends G.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=G.createRef(),this.refDialog=G.createRef(),this.refModalContent=G.createRef(),this.refModalImg=G.createRef(),this.refWrap=G.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=Wb,this.styleModalImg={},this.handleModalStateChange=e=>{let{state:{modalState:t}}=this;e!==`LOADING`&&t===`LOADING`?(this.loadZoomImg(),window.addEventListener(`resize`,this.handleResize,{passive:!0}),window.addEventListener(`touchstart`,this.handleTouchStart,{passive:!0}),window.addEventListener(`touchmove`,this.handleTouchMove,{passive:!0}),window.addEventListener(`touchend`,this.handleTouchEnd,{passive:!0}),window.addEventListener(`touchcancel`,this.handleTouchCancel,{passive:!0}),document.addEventListener(`keydown`,this.handleKeyDown,!0)):e!==`LOADED`&&t===`LOADED`?window.addEventListener(`wheel`,this.handleWheel,{passive:!0}):e!==`UNLOADING`&&t===`UNLOADING`?(this.ensureImgTransitionEnd(),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),document.removeEventListener(`keydown`,this.handleKeyDown,!0)):e!==`UNLOADED`&&t===`UNLOADED`&&(this.bodyScrollEnable(),window.removeEventListener(`resize`,this.handleResize),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{let e=()=>Math.random().toString(16).slice(-4);this.setState({id:e()+e()+e()})},this.setAndTrackImg=()=>{let{refContent:{current:e}}=this;e!=null&&(this.imgEl=e.querySelector(Ub),this.imgEl===null?this.contentNotFoundChangeObserver??(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(e,{childList:!0,subtree:!0})):(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener(`load`,this.handleImgLoad),this.imgEl.addEventListener(`click`,this.handleZoom),this.state.loadedImgEl??this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(e=>{let[t]=e;t?.target!==void 0&&(this.imgEl=t.target,this.setState({styleGhost:Vb(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:Vb(this.imgEl)})}),this.contentChangeObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}))))},this.handleIfZoomChanged=e=>{let{props:{isZoomed:t}}=this;!e&&t?this.zoom():e&&!t&&this.unzoom()},this.handleImgLoad=()=>{let e=Nb(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(Eb(n)){let{sizes:e,srcset:r,crossOrigin:i}=n;t.sizes=e,t.srcset=r,t.crossOrigin=i}t.src=e;let r=()=>{this.setState({loadedImgEl:t,styleGhost:Vb(this.imgEl)})};t.decode().then(r).catch(()=>{if(Db(t)){r();return}t.onload=r})},this.handleZoom=e=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:e})},this.handleUnzoom=e=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:e})},this.handleBtnUnzoomClick=e=>{e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e)},this.handleDialogClick=e=>{(e.target===this.refModalContent.current||e.target===this.refModalImg.current)&&(e.stopPropagation(),this.handleUnzoom(e))},this.handleDialogClose=e=>{e.stopPropagation(),this.handleUnzoom(e)},this.handleKeyDown=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e))},this.handleWheel=e=>{e.ctrlKey||(e.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(e)}))},this.handleTouchStart=e=>{if(e.touches.length>1){this.isScaling=!0;return}let{changedTouches:t}=e,[n]=t;if(t.length===1&&n!==void 0){let{screenY:e}=n;this.touchYStart=e}},this.handleTouchMove=e=>{let t=window.visualViewport?.scale??1,{changedTouches:n}=e,[r]=n;if(this.props.canSwipeToUnzoom&&!this.isScaling&&t<=1&&this.touchYStart!=null&&r!==void 0){let{screenY:t}=r;this.touchYEnd=t;let n=Math.max(this.touchYStart,this.touchYEnd),i=Math.min(this.touchYStart,this.touchYEnd);Math.abs(n-i)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(e))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||Ob(this.imgEl))&&window.getComputedStyle(this.imgEl).display!==`none`,this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener(`transitionend`,this.handleImgTransitionEnd),this.setState({modalState:`LOADING`})},this.unzoom=()=>{this.setState({modalState:`UNLOADING`})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState===`LOADING`?this.setState({modalState:`LOADED`}):this.state.modalState===`UNLOADING`&&this.setState({shouldRefresh:!1,modalState:`UNLOADED`})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){let{transitionDuration:e}=window.getComputedStyle(this.refModalImg.current),t=parseFloat(e);if(t!==0&&!Number.isNaN(t)){let n=t*(e.endsWith(`ms`)?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,n)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};let{body:{clientWidth:e}}=document;document.body.style.overflow=`hidden`,document.body.style.width=`${e}px`},this.bodyScrollEnable=()=>{let{prevBodyAttrs:{overflow:e,width:t}}=this;document.body.style.width=t,document.body.style.overflow=e,this.prevBodyAttrs=Wb},this.loadZoomImg=()=>{let{props:{zoomImg:e}}=this;if(e==null)return;let{src:t}=e;if(t!==void 0&&t!==``){let n=new Image;n.sizes=e.sizes??``,n.srcset=e.srcSet??``,n.crossOrigin=e.crossOrigin??void 0,n.src=t;let r=()=>{this.setState({isZoomImgLoaded:!0})};n.decode().then(r).catch(()=>{if(Db(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(Ob(e)){let r=e.cloneNode(!0);Hb(r),r.style.width=`${n.width??0}px`,r.style.height=`${n.height??0}px`,r.addEventListener(`click`,this.handleUnzoom),t.current?.firstChild?.remove(),t.current?.appendChild(r)}}}render(){let{handleBtnUnzoomClick:e,handleDialogClick:t,handleDialogClose:n,handleUnzoom:r,handleZoom:i,imgEl:a,props:{a11yNameButtonUnzoom:o,a11yNameButtonZoom:s,children:c,classDialog:l,IconUnzoom:u,IconZoom:d,isZoomed:f,wrapElement:p,ZoomContent:m,zoomImg:h,zoomMargin:g},refContent:_,refDialog:v,refModalContent:y,refModalImg:b,refWrap:x,state:{id:S,isZoomImgLoaded:C,loadedImgEl:w,modalState:T,shouldRefresh:E,styleGhost:D}}=this,O=`rmiz-modal-${S}`,k=`rmiz-modal-img-${S}`,A=Tb(a),j=Eb(a),M=Ob(a),N=Pb(a),P=Nb(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,R=h?.src!==void 0&&h.src!==``,z=this.hasImage(),B=N!==void 0&&N!==``?`${s}: ${N}`:s,V=T===`LOADING`||T===`LOADED`,H=z?`found`:`not-found`,U=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,ee={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=z&&a!==null?Bb({hasZoomImg:R,imgSrc:P,isSvg:M,isZoomed:f&&V,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let te=null;if(z){let t=j||A?G.createElement(`img`,{alt:N,crossOrigin:L,sizes:F,src:P,srcSet:I,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?G.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=G.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},G.createElement(u,null));te=m==null?G.createElement(G.Fragment,null,t,n):G.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return G.createElement(p,{"aria-owns":O,"data-rmiz":``,ref:x},G.createElement(p,{"data-rmiz-content":H,ref:_,style:ee},c),z&&G.createElement(p,{"data-rmiz-ghost":``,style:D},G.createElement(`button`,{"aria-label":B,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},G.createElement(d,null))),z&&Ni.createPortal(G.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:Kb,ref:v,role:`dialog`},G.createElement(`div`,{"data-rmiz-modal-overlay":U}),G.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},te)),Gb()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!==`UNLOADED`&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener(`load`,this.handleImgLoad),this.imgEl?.removeEventListener(`click`,this.handleZoom),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),window.removeEventListener(`resize`,this.handleResize),document.removeEventListener(`keydown`,this.handleKeyDown,!0)}componentDidUpdate(e,t){this.handleModalStateChange(t.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(e.isZoomed)}};Jb.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:xb,IconZoom:Sb,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function Yb({onZoomChange:e,...t}){let[n,r]=G.useState(!1),i=G.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return G.createElement(qb,{...t,isZoomed:n,onZoomChange:i})}function Xb(e){return e??`lazy`}function Zb(e){let t=(0,q.c)(15),n=e.src,r=e.alt??``,i=e.width,a=e.height,o=e.title,s;t[0]===e.loading?s=t[1]:(s=Xb(e.loading),t[0]=e.loading,t[1]=s);let c;return t[2]!==e.crossorigin||t[3]!==e.decoding||t[4]!==e.fetchpriority||t[5]!==e.height||t[6]!==e.referrerpolicy||t[7]!==e.sizes||t[8]!==e.src||t[9]!==e.srcset||t[10]!==e.title||t[11]!==e.width||t[12]!==r||t[13]!==s?(c=(0,K.jsx)(`img`,{src:n,alt:r,width:i,height:a,title:o,loading:s,srcSet:e.srcset,sizes:e.sizes,decoding:e.decoding,fetchPriority:e.fetchpriority,crossOrigin:e.crossorigin,referrerPolicy:e.referrerpolicy}),t[2]=e.crossorigin,t[3]=e.decoding,t[4]=e.fetchpriority,t[5]=e.height,t[6]=e.referrerpolicy,t[7]=e.sizes,t[8]=e.src,t[9]=e.srcset,t[10]=e.title,t[11]=e.width,t[12]=r,t[13]=s,t[14]=c):c=t[14],c}function Qb(e){let t=(0,q.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,K.jsx)(Yb,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,K.jsx)(Zb,{...e})}),t[1]=e,t[2]=r),r}function $b(e){return e!==!1}function ex(e){let t=(0,q.c)(14),n=e.src,r=e.title,i;t[0]===e.controls?i=t[1]:(i=$b(e.controls),t[0]=e.controls,t[1]=i);let a;return t[2]!==e.autoplay||t[3]!==e.height||t[4]!==e.loop||t[5]!==e.muted||t[6]!==e.playsinline||t[7]!==e.poster||t[8]!==e.preload||t[9]!==e.src||t[10]!==e.title||t[11]!==e.width||t[12]!==i?(a=(0,K.jsx)(`video`,{className:`ok-video`,src:n,title:r,controls:i,autoPlay:e.autoplay,muted:e.muted,loop:e.loop,playsInline:e.playsinline,poster:e.poster,preload:e.preload,width:e.width,height:e.height}),t[2]=e.autoplay,t[3]=e.height,t[4]=e.loop,t[5]=e.muted,t[6]=e.playsinline,t[7]=e.poster,t[8]=e.preload,t[9]=e.src,t[10]=e.title,t[11]=e.width,t[12]=i,t[13]=a):a=t[13],a}function tx(e){let t=(0,q.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,K.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var nx={Callout:bb,img:Qb,video:ex,audio:hb,Accordion:pb,"*":tx};function rx(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var ix=Je(),ax=new Map;function ox(e){if(e.surface===`compat`){let t=nx[e.rendersAs];if(!t)throw Error(`Compat descriptor '${e.name}' declares rendersAs: '${e.rendersAs}', but no React component is registered under that name in componentMap. Add the canonical component before registering the compat descriptor.`);return{Component:t,reactNodePropNames:rx(e.props)}}let t=nx[e.name];return t?{Component:t,reactNodePropNames:rx(e.props)}:null}for(let[e,t]of ix.entries()){let n=ox(t);n&&ax.set(e,n)}function sx(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function cx(e){let t=ix.getOrWildcard(e),n=ax.get(t.name)??ax.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return sx(t,n)}function lx(){let e=[];for(let[t,n]of ix.entries()){if(t===`*`)continue;let r=ax.get(t);r&&e.push(sx(n,r))}return e}var ux={ChevronRight:Zn,Image:sr,MessageSquareWarning:mr,SquarePlay:br,Volume2:wr};function dx(e){return e&&Object.hasOwn(ux,e)?ux[e]:Yn}var fx=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,px=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,mx={Callout:{description:`Highlight tips, warnings, and notes.`,props:{type:`note`,title:`Heads up`},children:`Callouts draw attention to key information.`},Accordion:{description:`Collapsible section with a clickable summary.`,props:{title:`Click to expand`,defaultOpen:!0},children:`Hidden content goes here.`},img:{description:`Embed an image with optional alt text.`,props:{src:fx,alt:`Sample image`}},video:{description:`Embed a video with native player controls.`,props:{controls:!0,poster:px}},audio:{description:`Embed an audio file with native player controls.`,props:{controls:!0}}};function hx(e){let t={};for(let n of e.props)n.type!==`reactnode`&&`defaultValue`in n&&n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function gx(e){let t=cx(e),n=hx(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var _x=new Set;function vx(e){_x.add(e)}function yx(e){if(typeof e==`number`)return _x.delete(e);let t=_x.values().next();return t.done?!1:(_x.delete(t.value),!0)}function bx(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(vx(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function xx(e){return t=>{let n=new WeakSet;t.state.doc.descendants(t=>{t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&n.add(t)}),t.chain().focus().insertContent(gx(e.name)).run();let r=-1;t.state.doc.descendants((t,i)=>{if(r>=0)return!1;t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&!n.has(t)&&(r=i)}),!(r<0)&&bx(t,r,e)}}function Sx(){return lx().filter(e=>e.surface===`canonical`).map(e=>{let t=mx[e.name],n=e.Component,r=t?{description:t.description,render:()=>(0,K.jsx)(n,{...t.props,children:t.children})}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:dx(e.icon),category:e.category??`content`,command:xx(e),aliases:e.searchTerms,description:e.description,preview:r}})}var Cx=new nt(`imageUpload`);function wx(e){let t=document.createElement(`div`);return t.className=`image-upload-skeleton w-full h-40 rounded-md bg-muted animate-pulse motion-reduce:animate-none my-2`,t.setAttribute(`data-upload-widget`,`loading`),t.setAttribute(`role`,`status`),t.setAttribute(`aria-label`,e?.name?`Uploading ${e.name}…`:`Uploading file…`),t}var Tx=new he({key:Cx,state:{init(){return{decorations:ze.empty,uploads:new Map}},apply(e,t){let n=t.decorations.map(e.mapping,e.doc),r=new Map;for(let[n,i]of t.uploads)r.set(n,e.mapping.map(i));let i=e.getMeta(Cx);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=We.widget(i.pos,i.widget,{id:i.id,stopEvent:()=>!0}),a=n.add(e.doc,[t]),o=new Map(r);return o.set(i.id,e.mapping.map(i.pos)),{decorations:a,uploads:o}}if(i.type===`remove`){let e=n.find(void 0,void 0,e=>e.id===i.id),t=n.remove(e),a=new Map(r);return a.delete(i.id),{decorations:t,uploads:a}}return{decorations:n,uploads:r}}},props:{decorations(e){return Cx.getState(e)?.decorations??ze.empty}}});function Ex(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function Dx(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Ox(e){return e.split(`/`).filter(e=>e!==``)}function kx(e,t){let n=Ex(e),r=Ex(t),i=Dx(e);if(n===r)return i;let a=Ox(r),o=Ox(n),s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s++;let c=a.length-s,l=o.slice(s);return c===0?`./${[...l,i].join(`/`)}`:[...Array(c).fill(`..`),...l,i].join(`/`)}function Ax(e){return ib(e)}function jx(e,t){return{type:`jsxComponent`,attrs:{componentName:e===`jsx-img`?`img`:e===`jsx-video`?`video`:`audio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:e===`jsx-img`?{src:t,alt:``}:{src:t,controls:!0}}}}function Mx(e){let t=et(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:M.has(t)?{kind:`jsx-img`,ext:t}:ae.has(t)?{kind:`jsx-video`,ext:t}:tt.has(t)?{kind:`jsx-audio`,ext:t}:ue.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function Nx(e,t,n){let r=Ax(t),i=r?`${r}.md`:``;if(!i){Jt.error(`Cannot upload: no document is open`);return}let a=crypto.randomUUID(),o=wx(e);t.view.dispatch(t.state.tr.setMeta(Cx,{type:`add`,id:a,pos:n,widget:o}));let s=new FormData;s.append(`file`,e),s.append(`parentDocName`,i);let c;try{c=await fetch(`/api/upload`,{method:`POST`,body:s})}catch(e){console.error(`[uploadAndInsert] Network error:`,e),Px(t,a);return}let l={};try{l=await c.json()}catch{}if(!c.ok){let e=l.message??l.error??`Upload failed (${c.status})`;console.error(`[uploadAndInsert] Server error:`,e),Px(t,a,e);return}if(typeof l.src!=`string`){console.error(`[uploadAndInsert] Response missing src:`,l),Px(t,a);return}let u=l.src,d=l.deduped===!0,f=Ex(i),p=typeof l.path==`string`&&l.path.length>0?l.path:f?`${f}/${u}`:u;d&&Jt.info(`Already at ${p} — reusing.`);let m=Mx(e.name),{state:h}=t,g=Cx.getState(h)?.uploads.get(a)??n,_=h.tr.setMeta(Cx,{type:`remove`,id:a}),v=kx(p,i),y=`/${p}`;if(m.kind===`jsx-img`||m.kind===`jsx-video`||m.kind===`jsx-audio`){if(!h.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),Px(t,a);return}let e=jx(m.kind,y),n=e.attrs.componentName;t.chain().command(({tr:e})=>(e.setMeta(Cx,{type:`remove`,id:a}),!0)).focus().insertContentAt(g,e).run(),bx(t,g,cx(n));return}if(m.kind===`wikiembed`){let e=h.schema.nodes.wikiLinkEmbed;if(!e){console.error(`[uploadAndInsert] wikiLinkEmbed node missing from schema`),Px(t,a);return}_.insert(g,e.create({target:u,alias:null,anchor:null,resolvedSrc:y}))}else if(m.kind===`wiki-link`){let n=h.schema.nodes.wikiLink;if(!n){console.error(`[uploadAndInsert] wikiLink node missing from schema`),Px(t,a);return}let r=cb(e.name.replace(/\.(md|mdx)$/i,``));r?_.insert(g,n.create(r)):_.insert(g,h.schema.text(e.name))}else{let t=h.schema.marks.link;if(t){let n=h.schema.text(e.name,[t.create({href:v})]);_.insert(g,n)}else _.insert(g,h.schema.text(e.name))}t.view.dispatch(_)}function Px(e,t,n){e.view.dispatch(e.state.tr.setMeta(Cx,{type:`remove`,id:t})),Jt.error(n??`Upload failed`)}var Fx=[{name:`heading1`,label:`Heading 1`,icon:ir,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:1}).run(),aliases:[`h1`],preview:{description:`Big section heading.`,render:()=>(0,K.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Heading 1`})}},{name:`heading2`,label:`Heading 2`,icon:ar,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:2}).run(),aliases:[`h2`],preview:{description:`Medium section heading.`,render:()=>(0,K.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Heading 2`})}},{name:`heading3`,label:`Heading 3`,icon:or,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:3}).run(),aliases:[`h3`],preview:{description:`Small section heading.`,render:()=>(0,K.jsx)(`h3`,{className:`text-base font-semibold tracking-tight`,children:`Heading 3`})}},{name:`bulletList`,label:`Bullet List`,icon:fr,category:`basic`,command:e=>e.chain().focus().toggleBulletList().run(),aliases:[`ul`,`unordered`],preview:{description:`Unordered list of items.`,render:()=>(0,K.jsxs)(`ul`,{className:`list-disc pl-5 text-sm leading-7`,children:[(0,K.jsx)(`li`,{children:`First item`}),(0,K.jsx)(`li`,{children:`Second item`})]})}},{name:`orderedList`,label:`Ordered List`,icon:ur,category:`basic`,command:e=>e.chain().focus().toggleOrderedList().run(),aliases:[`ol`,`numbered`],preview:{description:`Numbered list of items.`,render:()=>(0,K.jsxs)(`ol`,{className:`list-decimal pl-5 text-sm leading-7`,children:[(0,K.jsx)(`li`,{children:`First item`}),(0,K.jsx)(`li`,{children:`Second item`})]})}},{name:`taskList`,label:`Task List`,icon:dr,category:`basic`,command:e=>e.chain().focus().toggleTaskList().run(),aliases:[`todo`,`checklist`,`checkbox`],preview:{description:`Checklist with checkboxes.`,render:()=>(0,K.jsxs)(`ul`,{className:`space-y-1.5 text-sm`,children:[(0,K.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:!0,readOnly:!0,className:`size-3.5`}),(0,K.jsx)(`span`,{className:`text-muted-foreground line-through`,children:`Done`})]}),(0,K.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,readOnly:!0,className:`size-3.5`}),(0,K.jsx)(`span`,{children:`To do`})]})]})}},{name:`blockquote`,label:`Quote`,icon:vr,category:`basic`,command:e=>e.chain().focus().toggleBlockquote().run(),aliases:[`quote`],preview:{description:`Indented blockquote for citations.`,render:()=>(0,K.jsx)(`blockquote`,{className:`border-l-2 border-muted-foreground/40 pl-3 text-sm italic text-muted-foreground`,children:`A pull quote stands out from the surrounding text.`})}},{name:`codeBlock`,label:`Code Block`,icon:$n,category:`basic`,command:e=>e.chain().focus().toggleCodeBlock().run(),aliases:[`code`,`fence`],preview:{description:`Fenced code block with monospace text.`,render:()=>(0,K.jsx)(`pre`,{className:`rounded-md bg-muted px-2.5 py-2 font-mono text-xs leading-5`,children:(0,K.jsx)(`code`,{children:`const greeting = "Hello";
|