@oneclick.dev/cms-core-modules 0.0.57 → 0.0.59

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.
@@ -25055,9 +25055,13 @@ const Wg = (i, e) => e.deleteSet.clients.size === 0 && !_v(e.afterState, (t, a)
25055
25055
  (d) => d.target._item === null || !d.target._item.deleted
25056
25056
  ), l.forEach((d) => {
25057
25057
  d.currentTarget = u, d._path = null;
25058
- }), l.sort((d, f) => d.path.length - f.path.length), uF(u._dEH, l, t));
25058
+ }), l.sort((d, f) => d.path.length - f.path.length), s.push(() => {
25059
+ uF(u._dEH, l, t);
25060
+ }));
25061
+ }), s.push(() => a.emit("afterTransaction", [t, a])), s.push(() => {
25062
+ t._needFormattingCleanup && Z5(t);
25059
25063
  });
25060
- }), s.push(() => a.emit("afterTransaction", [t, a])), hf(s, []), t._needFormattingCleanup && Z5(t);
25064
+ }), hf(s, []);
25061
25065
  } finally {
25062
25066
  a.gc && q5(o, n, a.gcFilter), A5(o, n), t.afterState.forEach((d, f) => {
25063
25067
  const c = t.beforeState.get(f) || 0;
@@ -131,7 +131,7 @@ img.ProseMirror-separator {
131
131
  ${u.editor.isEditable?"editable":""}
132
132
  ${s.unref(a)?"-no-interaction":""}`]),style:s.normalizeStyle(`width: ${u.node.attrs.size/12*100}%; max-width: ${u.node.attrs.size/12*100}%; margin-top: ${u.node.attrs.marginTop||0}px;`)},{default:s.withCtx(()=>[s.unref(t)?(s.openBlock(),s.createBlock(Fi,{key:0,node:u.node,getPos:u.getPos,editor:u.editor},null,8,["node","getPos","editor"])):s.createCommentVNode("",!0),s.unref(a)?s.createCommentVNode("",!0):(s.openBlock(),s.createBlock(It,s.normalizeProps(s.mergeProps({key:1},e)),{default:s.withCtx(()=>[...d[0]||(d[0]=[s.createTextVNode("Button",-1)])]),_:1},16)),s.createElementVNode("div",{class:s.normalizeClass(["max-w-full px-4 py-2",`${u.node.attrs.width==="fill"?"w-full":"w-auto"}`]),"data-drag-handle":"",style:s.normalizeStyle(l(r.value))},[s.createElementVNode("span",Yw,s.toDisplayString(u.node.attrs.text),1)],6),s.unref(t)&&!s.unref(a)?(s.openBlock(),s.createBlock(pi,{key:2,node:u.node,editor:u.editor},null,8,["node","editor"])):s.createCommentVNode("",!0)]),_:1},8,["data-id","class","style"]))}}),Zw=se._export_sfc(Xw,[["__scopeId","data-v-dceaffb8"]]),Qw=Te.create({name:"button",group:"block",atom:!0,selectable:!0,draggable:!0,addOptions(){return{HTMLAttributes:{},theme:"DEFAULT",themeClass:"",className:"tiptap-button"}},addAttributes(){return{id:{default:null},theme:{default:"DEFAULT"},themeClass:{default:""},marginTop:{default:0},alignment:{default:"left",renderHTML:()=>({}),parseHTML:i=>i.dataset.alignment||"left"},size:{default:2,renderHTML:()=>({}),parseHTML:i=>{const e=i.dataset.size;return e?parseInt(e):2}},text:{default:"Button",renderHTML:()=>({}),parseHTML:i=>{const e=i.dataset.text;return e?String(e):null}},width:{default:"fill"},linkType:{default:"page"},link:{default:""},openInNewTab:{default:!1},pageId:{default:""}}},parseHTML(){return[{tag:'div[data-type="button"]'}]},renderHTML({HTMLAttributes:i,node:e}){return["div",be(this.options.HTMLAttributes,i,{"data-type":"button","data-theme":e.attrs.theme,"data-theme-class":e.attrs.themeClass,"data-text":String(e.attrs.text||"Button"),"data-link-type":String(e.attrs.linkType||"page"),"data-link":String(e.attrs.link||""),"data-open-in-new-tab":String(e.attrs.openInNewTab||!1),"data-page-id":String(e.attrs.pageId||""),"data-width":String(e.attrs.width||"fill")}),["div",{},0]]},addCommands(){const i=(e,t)=>{let a=null;return e.doc.descendants((n,o)=>n.attrs.id===t?(a={pos:o,node:n},!1):!0),a};return{setButton:e=>({chain:t})=>t().insertContent({type:this.name}).run(),setButtonTheme:({id:e,themeId:t,className:a,addToHistory:n})=>({state:o,tr:r,dispatch:l})=>{const u=i(o,e);return u?(r.setNodeMarkup(u.pos,u.node.type,{...u.node.attrs,theme:t,themeClass:a}),n===!1&&r.setMeta("addToHistory",!1),l&&l(r),!0):!1}}},addNodeView(){return gt(Zw)}}),eD=s.defineComponent({__name:"Map",props:We,setup(i){const e=i;return(t,a)=>(s.openBlock(),s.createBlock(s.unref(ct),{"data-draggable":"true","data-type":"map","data-id":t.node.attrs.id,class:s.normalizeClass(["tiptap-map relative group/node flex my-1 p-1",`${t.node.attrs.alignment==="center"?"mx-auto":t.node.attrs.alignment==="right"?"ml-auto":"mr-auto"}`]),style:s.normalizeStyle(`width: ${t.node.attrs.size/12*100}%; max-width: ${t.node.attrs.size/12*100}%; margin-top: ${t.node.attrs.marginTop||0}px;`)},{default:s.withCtx(()=>[s.createVNode(Fi,{node:t.node,getPos:t.getPos,editor:t.editor},null,8,["node","getPos","editor"]),s.createVNode(It,s.normalizeProps(s.guardReactiveProps(e)),{default:s.withCtx(()=>[...a[0]||(a[0]=[s.createTextVNode("Map",-1)])]),_:1},16),s.createTextVNode(" "+s.toDisplayString(t.node.attrs.location)+" ",1),s.createVNode(pi,{node:t.node,editor:t.editor},null,8,["node","editor"])]),_:1},8,["data-id","class","style"]))}}),tD=se._export_sfc(eD,[["__scopeId","data-v-07966b02"]]),iD=Te.create({name:"map",group:"block",atom:!0,selectable:!0,draggable:!0,addOptions(){return{HTMLAttributes:{},className:"tiptap-map"}},addAttributes(){return{id:{default:null},marginTop:{default:0},location:{default:{address:"",city:"",zip:"",state:"",country:""},renderHTML:()=>({}),parseHTML:i=>{const e=i.dataset;return{address:e.address||"",city:e.city||"",zip:e.zip||"",state:e.state||"",country:e.country||""}}}}},parseHTML(){return[{tag:'div[data-type="map"]'}]},renderHTML({HTMLAttributes:i,node:e}){return["div",be(this.options.HTMLAttributes,i,{"data-type":"map"}),["div",{},0]]},addCommands(){return{setMap:i=>({chain:e})=>e().insertContent({type:this.name}).run()}},addNodeView(){return gt(tD)}}),aD={class:"w-full h-full flex items-center justify-center text-gray-400"},nD={key:3,class:"relative w-full h-full cursor-grab p-1"},oD=["src"],rD=s.defineComponent({__name:"Image",props:We,setup(i){const e=i,{isActive:t,isPerformingActionOutside:a}=_t(e.node);return(n,o)=>(s.openBlock(),s.createBlock(s.unref(ct),{"data-id":n.node.attrs.id,class:s.normalizeClass(["tiptap-image relative group/node flex my-1",`${n.node.attrs.alignment==="center"?"mx-auto":n.node.attrs.alignment==="right"?"ml-auto":"mr-auto"} ${n.editor.isEditable?"editable":""} ${s.unref(a)?"-no-interaction":""}`]),style:s.normalizeStyle(`width: ${n.node.attrs.size/12*100}%; max-width: ${n.node.attrs.size/12*100}%; margin-top: ${n.node.attrs.marginTop||0}px;`)},{default:s.withCtx(()=>[s.unref(t)?(s.openBlock(),s.createBlock(Fi,{key:0,node:n.node,getPos:n.getPos,editor:n.editor},null,8,["node","getPos","editor"])):s.createCommentVNode("",!0),s.unref(a)?s.createCommentVNode("",!0):(s.openBlock(),s.createBlock(It,s.normalizeProps(s.mergeProps({key:1},e)),{default:s.withCtx(()=>[...o[0]||(o[0]=[s.createTextVNode("Image",-1)])]),_:1},16)),n.node.attrs.src?(s.openBlock(),s.createElementBlock("div",nD,[s.createElementVNode("img",{src:n.node.attrs.src,class:s.normalizeClass(s.unref(Yd.classNames)("w-full object-cover",n.node.attrs.shape!=="rectangle"?"aspect-square":!n.node.attrs.aspectRatio||n.node.attrs.aspectRatio==="original"?"":n.node.attrs.aspectRatio==="widescreen"?"aspect-[16/9]":n.node.attrs.aspectRatio==="landscape"?"aspect-[3/2]":n.node.attrs.aspectRatio==="portrait"?"aspect-[4/3]":"",n.node.attrs.shape==="circle"?"rounded-full":"")),draggable:"false"},null,10,oD),o[1]||(o[1]=s.createElementVNode("div",{class:"absolute inset-0","data-drag-handle":""},null,-1))])):(s.openBlock(),s.createElementBlock("div",{key:2,class:s.normalizeClass(s.unref(Yd.classNames)("w-full bg-gray-200 dark:bg-input border cursor-grab p-1",n.node.attrs.shape!=="rectangle"?"aspect-square":!n.node.attrs.aspectRatio||n.node.attrs.aspectRatio==="original"||n.node.attrs.aspectRatio==="widescreen"?"aspect-[16/9]":n.node.attrs.aspectRatio==="landscape"?"aspect-[3/2]":n.node.attrs.aspectRatio==="portrait"?"aspect-[4/3]":"",n.node.attrs.shape==="circle"?"rounded-full":""))},[s.createElementVNode("div",aD,[s.createVNode(s.unref(M.ImageIcon),{class:"size-8"})])],2)),s.unref(t)&&!s.unref(a)?(s.openBlock(),s.createBlock(pi,{key:4,node:n.node,editor:n.editor},null,8,["node","editor"])):s.createCommentVNode("",!0)]),_:1},8,["data-id","class","style"]))}}),sD=se._export_sfc(rD,[["__scopeId","data-v-d6fa758a"]]),lD=Te.create({name:"image",group:"block",atom:!0,selectable:!0,draggable:!0,addOptions(){return{HTMLAttributes:{},className:"tiptap-image"}},addAttributes(){return{id:{default:null},marginTop:{default:0},src:{default:null,renderHTML:()=>({}),parseHTML:i=>i.dataset.src||null},alt:{default:null,renderHTML:()=>({}),parseHTML:i=>i.dataset.alt||null},alignment:{default:"left",renderHTML:()=>({}),parseHTML:i=>i.dataset.alignment||"left"},size:{default:4,renderHTML:()=>({}),parseHTML:i=>{const e=i.dataset.size;return e?parseInt(e):4}},aspectRatio:{default:"original",renderHTML:()=>({}),parseHTML:i=>i.dataset.aspectRatio||"original"},shape:{default:"rectangle",renderHTML:()=>({}),parseHTML:i=>i.dataset.shape||"rectangle"}}},parseHTML(){return[{tag:'div[data-type="image"]'}]},renderHTML({HTMLAttributes:i}){return["div",be(this.options.HTMLAttributes,i,{"data-type":"image"})]},addCommands(){return{setImage:i=>({chain:e})=>e().insertContent({type:this.name}).run(),setImageWidth:i=>({state:e,tr:t,dispatch:a})=>{const n=e.selection;if(!n)return!1;const o=n.$from.before(n.$from.depth+1),r=t.doc.nodeAt(o);return!r||r.type.name!==this.name?!1:(a&&t.setNodeMarkup(o,r.type,{...r.attrs,size:i}),!0)}}},addNodeView(){return gt(sD)}}),uD={key:2,class:"w-full h-48 bg-gray-200 dark:bg-input border"},dD={class:"w-full h-full flex items-center justify-center text-gray-400"},fD=["innerHTML"],cD=s.defineComponent({__name:"Video",props:We,setup(i){const e=i,{isActive:t,isPerformingActionOutside:a}=_t(e.node),n=s.ref(""),o=s.computed(()=>e.node.attrs.src||"");s.watch(o,l=>{if(!l){n.value="";return}try{n.value=r(l,{autoplay:!1,controls:!0})}catch(u){console.error("Error generating embed code:",u),n.value=""}},{immediate:!0});function r(l,u={}){const{autoplay:d=!1,controls:f=!0}=u,c=/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/,g=l.match(c);if(!g||!g[1])return"";const _=g[1],h=new URLSearchParams({autoplay:d?1:0,controls:f?1:0});return`<iframe style="aspect-ratio: 16/9; width: 100%;" src="${`https://www.youtube.com/embed/${_}?${h}`}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`}return(l,u)=>(s.openBlock(),s.createBlock(s.unref(ct),{"data-draggable":"true","data-id":l.node.attrs.id,class:s.normalizeClass(["tiptap-video relative group/node flex my-1 p-1",`${l.node.attrs.alignment==="center"?"mx-auto":l.node.attrs.alignment==="right"?"ml-auto":"mr-auto"} ${l.editor.isEditable?"editable":""} ${s.unref(a)?"-no-interaction":""}`]),style:s.normalizeStyle(`width: ${l.node.attrs.size/12*100}%; max-width: ${l.node.attrs.size/12*100}%; margin-top: ${l.node.attrs.marginTop||0}px;`)},{default:s.withCtx(()=>[s.unref(t)?(s.openBlock(),s.createBlock(Fi,{key:0,node:l.node,getPos:l.getPos,editor:l.editor},null,8,["node","getPos","editor"])):s.createCommentVNode("",!0),s.unref(a)?s.createCommentVNode("",!0):(s.openBlock(),s.createBlock(It,s.normalizeProps(s.mergeProps({key:1},e)),{default:s.withCtx(()=>[...u[0]||(u[0]=[s.createTextVNode("Video",-1)])]),_:1},16)),n.value?(s.openBlock(),s.createElementBlock("div",{key:3,draggable:"false",class:"w-full pointer-events-none",innerHTML:n.value},null,8,fD)):(s.openBlock(),s.createElementBlock("div",uD,[s.createElementVNode("div",dD,[s.createVNode(s.unref(M.VideoIcon),{class:"size-8"})])])),s.unref(t)&&!s.unref(a)?(s.openBlock(),s.createBlock(pi,{key:4,node:l.node,editor:l.editor},null,8,["node","editor"])):s.createCommentVNode("",!0)]),_:1},8,["data-id","class","style"]))}}),gD=se._export_sfc(cD,[["__scopeId","data-v-1f03dbf8"]]),_D=Te.create({name:"video",group:"block",atom:!0,selectable:!0,draggable:!0,addOptions(){return{HTMLAttributes:{},className:"tiptap-video"}},addAttributes(){return{id:{default:null},marginTop:{default:0},src:{default:"",renderHTML:()=>({}),parseHTML:i=>i.dataset.src||""},alignment:{default:"left",renderHTML:()=>({}),parseHTML:i=>i.dataset.alignment||"left"},size:{default:4,renderHTML:()=>({}),parseHTML:i=>{const e=i.dataset.size;return e?parseInt(e):4}}}},parseHTML(){return[{tag:'div[data-type="video"]'}]},renderHTML({HTMLAttributes:i,node:e}){return["div",be(this.options.HTMLAttributes,i,{"data-type":"video","data-src":e.attrs.src,"data-alignment":e.attrs.alignment,"data-size":e.attrs.size,"data-id":e.attrs.id,"data-margin-top":e.attrs.marginTop}),["div",{},0]]},addCommands(){return{setVideo:i=>({chain:e})=>e().insertContent({type:this.name}).run(),setVideoWidth:i=>({state:e,tr:t,dispatch:a})=>{const n=e.selection;if(!n)return!1;const o=n.$from.before(n.$from.depth+1),r=t.doc.nodeAt(o);return!r||r.type.name!==this.name?!1:(a&&t.setNodeMarkup(o,r.type,{...r.attrs,size:i}),!0)}}},addNodeView(){return gt(gD)}}),hD=s.defineComponent({__name:"Heading",props:We,setup(i){const e=i,{isActive:t,isInsideNode:a,isPerformingActionOutside:n}=_t(e.node);function o(){if(typeof e.getPos=="function"){const r=e.getPos();e.editor.chain().setNodeSelection(r).focus().run()}}return(r,l)=>(s.openBlock(),s.createBlock(s.unref(ct),{"data-id":r.node.attrs.id,class:s.normalizeClass(["tiptap-heading relative group/node flex my-1 p-1",`${r.node.attrs.alignment==="center"?"mx-auto text-center":r.node.attrs.alignment==="right"?"ml-auto text-right":"mr-auto text-left"} ${r.editor.isEditable?"editable":""} ${s.unref(n)?"-no-interaction":""}`]),style:s.normalizeStyle(`width: ${r.node.attrs.size/12*100}%; max-width: ${r.node.attrs.size/12*100}%; margin-top: ${r.node.attrs.marginTop||0}px`)},{default:s.withCtx(()=>[s.unref(t)?(s.openBlock(),s.createBlock(Fi,{key:0,node:r.node,getPos:r.getPos,editor:r.editor},null,8,["node","getPos","editor"])):s.createCommentVNode("",!0),s.unref(n)?s.createCommentVNode("",!0):(s.openBlock(),s.createBlock(It,s.normalizeProps(s.mergeProps({key:1},e)),{default:s.withCtx(()=>[s.createTextVNode("Heading "+s.toDisplayString(r.node.attrs.level),1)]),_:1},16)),(s.openBlock(),s.createBlock(s.resolveDynamicComponent(`h${r.node.attrs.level}`),{class:"w-full text-[var(--title-color)]"},{default:s.withCtx(()=>[s.createVNode(s.unref(Da),{class:s.normalizeClass(["w-full",{"pointer-events-none":!s.unref(t)&&r.editor.isEditable}])},null,8,["class"])]),_:1})),r.node.childCount===0&&r.editor.isEditable?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(`h${r.node.attrs.level}`),{key:2,class:"absolute left-2 w-full pointer-events-none text-muted-foreground truncate",contenteditable:"false"},{default:s.withCtx(()=>[...l[0]||(l[0]=[s.createTextVNode(" Empty title ",-1)])]),_:1})):s.createCommentVNode("",!0),!s.unref(a)&&!s.unref(t)&&r.editor.isEditable?(s.openBlock(),s.createElementBlock("div",{key:3,onClick:s.withModifiers(o,["stop"]),tabindex:"-1","data-drag-handle":"",contenteditable:"false",class:"absolute w-full h-full top-0 left-0 z-10 cursor-grab"})):s.createCommentVNode("",!0),s.unref(t)&&!s.unref(n)?(s.openBlock(),s.createBlock(pi,{key:4,node:r.node,editor:r.editor},null,8,["node","editor"])):s.createCommentVNode("",!0)]),_:1},8,["data-id","class","style"]))}}),mD=se._export_sfc(hD,[["__scopeId","data-v-38a378b1"]]),FD=Te.create({name:"heading",group:"block",content:"inline*",defining:!0,selectable:!0,draggable:!0,addOptions(){return{HTMLAttributes:{},className:"tiptap-heading"}},addAttributes(){return{id:{default:null},marginTop:{default:0},level:{default:1},alignment:{default:"left",renderHTML:()=>({}),parseHTML:i=>i.dataset.alignment||"left"},size:{default:12,renderHTML:()=>({}),parseHTML:i=>{const e=i.dataset.size;return e?parseInt(e):12}}}},parseHTML(){return[{tag:"h1"},{tag:"h2"},{tag:"h3"},{tag:"h4"},{tag:"h5"},{tag:"h6"}]},renderHTML({HTMLAttributes:i,node:e}){return["h"+e.attrs.level,be(this.options.HTMLAttributes,i,{"data-type":"heading","data-level":e.attrs.level,"data-alignment":e.attrs.alignment,"data-size":e.attrs.size}),0]},addCommands(){return{setHeading:i=>({chain:e})=>e().insertContent({type:this.name}).run()}},addNodeView(){return gt(mD,{update:({oldNode:i,newNode:e,updateProps:t})=>e.type.name!==this.name||e.attrs!==i.attrs?!1:(t(),!0)})}}),pD={key:2,class:"absolute left-2 w-full pointer-events-none text-muted-foreground truncate",contenteditable:"false"},bD=s.defineComponent({__name:"Paragraph",props:We,setup(i){const e=i,{isSelected:t,isActive:a,isInsideNode:n,isPerformingActionOutside:o}=_t(e.node);function r(){if(typeof e.getPos=="function"){const l=e.getPos();e.editor.chain().setNodeSelection(l).focus().run()}}return(l,u)=>(s.openBlock(),s.createBlock(s.unref(ct),{"data-id":l.node.attrs.id,class:s.normalizeClass(["tiptap-paragraph relative group/node flex my-1 p-1",`${l.node.attrs.alignment==="center"?"mx-auto text-center":l.node.attrs.alignment==="right"?"ml-auto text-right":"mr-auto text-left"} ${l.editor.isEditable?"editable":""} ${s.unref(o)?"-no-interaction":""}`]),style:s.normalizeStyle(`width: ${l.node.attrs.size/12*100}%; max-width: ${l.node.attrs.size/12*100}%; margin-top: ${l.node.attrs.marginTop||0}px;`)},{default:s.withCtx(()=>[s.unref(a)?(s.openBlock(),s.createBlock(Fi,{key:0,node:l.node,getPos:l.getPos,editor:l.editor},null,8,["node","getPos","editor"])):s.createCommentVNode("",!0),s.unref(o)?s.createCommentVNode("",!0):(s.openBlock(),s.createBlock(It,s.normalizeProps(s.mergeProps({key:1},e)),{default:s.withCtx(()=>[...u[0]||(u[0]=[s.createTextVNode("Paragraph",-1)])]),_:1},16)),s.createVNode(s.unref(Da),{class:s.normalizeClass(["w-full",{"pointer-events-none":!s.unref(a)&&l.editor.isEditable}])},null,8,["class"]),l.node.childCount===0&&l.editor.isEditable?(s.openBlock(),s.createElementBlock("span",pD,s.toDisplayString(s.unref(a)&&!s.unref(t)?"Type / for commands":"Empty text"),1)):s.createCommentVNode("",!0),!s.unref(n)&&!s.unref(a)&&l.editor.isEditable?(s.openBlock(),s.createElementBlock("div",{key:3,onClick:s.withModifiers(r,["stop"]),tabindex:"-1","data-drag-handle":"",contenteditable:"false",class:"absolute w-full h-full top-0 left-0 z-10 cursor-grab"})):s.createCommentVNode("",!0),s.unref(a)&&!s.unref(o)?(s.openBlock(),s.createBlock(pi,{key:4,node:l.node,editor:l.editor},null,8,["node","editor"])):s.createCommentVNode("",!0)]),_:1},8,["data-id","class","style"]))}}),yD=se._export_sfc(bD,[["__scopeId","data-v-442c28d7"]]),kD=Te.create({name:"paragraph",group:"block",content:"inline*",defining:!0,selectable:!0,draggable:!0,addOptions(){return{HTMLAttributes:{},className:"tiptap-paragraph"}},addAttributes(){return{id:{default:null},marginTop:{default:0},alignment:{default:"left",renderHTML:()=>({}),parseHTML:i=>i.dataset.alignment||"left"},size:{default:12,renderHTML:()=>({}),parseHTML:i=>{const e=i.dataset.size;return e?parseInt(e):12}}}},parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:i,node:e}){return["p",be(this.options.HTMLAttributes,i,{"data-type":"paragraph"}),0]},addCommands(){return{setParagraph:i=>({chain:e})=>e().insertContent({type:this.name}).run()}},addKeyboardShortcuts(){return{Enter:()=>{const i=document.querySelector("#content-manager-editor-slash-menu");if(i){const e=i.querySelector("button.bg-input")||i.querySelector("button");if(e)return e.click(),!0}return!1}}},addNodeView(){return gt(yD)}}),wD=s.defineComponent({__name:"Divider",props:We,setup(i){const e=i,{isActive:t,isPerformingActionOutside:a}=_t(e.node);function n(){if(typeof e.getPos=="function"){const o=e.getPos();e.editor.chain().setNodeSelection(o).focus().run()}}return(o,r)=>(s.openBlock(),s.createBlock(s.unref(ct),{"data-id":o.node.attrs.id,class:s.normalizeClass(["tiptap-divider relative group/node flex my-1 p-2",`${o.node.attrs.alignment==="center"?"mx-auto text-center":o.node.attrs.alignment==="right"?"ml-auto text-right":"mr-auto text-left"} ${o.editor.isEditable?"editable":""} ${s.unref(a)?"-no-interaction":""}`]),style:s.normalizeStyle(`width: ${o.node.attrs.size/12*100}%; max-width: ${o.node.attrs.size/12*100}%; margin-top: ${o.node.attrs.marginTop||0}px;`)},{default:s.withCtx(()=>[s.unref(t)?(s.openBlock(),s.createBlock(Fi,{key:0,node:o.node,getPos:o.getPos,editor:o.editor},null,8,["node","getPos","editor"])):s.createCommentVNode("",!0),s.unref(a)?s.createCommentVNode("",!0):(s.openBlock(),s.createBlock(It,s.normalizeProps(s.mergeProps({key:1},e)),{default:s.withCtx(()=>[...r[0]||(r[0]=[s.createTextVNode("Divider",-1)])]),_:1},16)),r[1]||(r[1]=s.createElementVNode("div",{class:"bg-current h-0.5 w-full"},null,-1)),!s.unref(t)&&o.editor.isEditable?(s.openBlock(),s.createElementBlock("div",{key:2,onClick:s.withModifiers(n,["stop"]),tabindex:"-1","data-drag-handle":"",contenteditable:"false",class:"absolute w-full h-full top-0 left-0 z-10 cursor-grab"})):s.createCommentVNode("",!0),s.unref(t)&&!s.unref(a)?(s.openBlock(),s.createBlock(pi,{key:3,node:o.node,editor:o.editor},null,8,["node","editor"])):s.createCommentVNode("",!0)]),_:1},8,["data-id","class","style"]))}}),DD=se._export_sfc(wD,[["__scopeId","data-v-f773e474"]]),vD=Te.create({name:"divider",group:"block",content:"inline*",defining:!0,selectable:!0,draggable:!0,addOptions(){return{HTMLAttributes:{},className:"tiptap-divider"}},addAttributes(){return{id:{default:null},marginTop:{default:0},alignment:{default:"left",renderHTML:()=>({}),parseHTML:i=>i.dataset.alignment||"left"},size:{default:12,renderHTML:()=>({}),parseHTML:i=>{const e=i.dataset.size;return e?parseInt(e):12}}}},parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:i,node:e}){return["hr",be(this.options.HTMLAttributes,i,{"data-type":"divider"}),0]},addCommands(){return{setDivider:i=>({chain:e})=>e().insertContent({type:this.name}).run()}},addNodeView(){return gt(DD)}}),ED=re.create({name:"trailingNodeInContainers",addOptions(){return{containerType:"container",trailingType:"paragraph"}},addProseMirrorPlugins(){const{containerType:i,trailingType:e}=this.options;return[new Z({appendTransaction(t,a,n){if(!t.some(d=>d.docChanged)||a.doc.eq(n.doc))return null;const r=n.schema.nodes[i],l=n.schema.nodes[e];if(!r||!l)return null;let u=null;return n.doc.descendants((d,f)=>{if(d.type!==r)return;const c=d.childCount===0,g=!c&&d.lastChild&&d.lastChild.type===l;if(c||!g){const _=f+d.nodeSize-1;u=(u??n.tr).insert(_,l.create())}}),u&&u.steps.length?u:null}})]}}),Ht=()=>new Map,Ql=i=>{const e=Ht();return i.forEach((t,a)=>{e.set(a,t)}),e},bi=(i,e,t)=>{let a=i.get(e);return a===void 0&&i.set(e,a=t()),a},xD=(i,e)=>{const t=[];for(const[a,n]of i)t.push(e(n,a));return t},CD=(i,e)=>{for(const[t,a]of i)if(e(a,t))return!0;return!1},Fa=()=>new Set,ul=i=>i[i.length-1],BD=(i,e)=>{for(let t=0;t<e.length;t++)i.push(e[t])},pa=Array.from,kd=(i,e)=>{for(let t=0;t<i.length;t++)if(!e(i[t],t,i))return!1;return!0},wd=(i,e)=>{for(let t=0;t<i.length;t++)if(e(i[t],t,i))return!0;return!1},SD=(i,e)=>{const t=new Array(i);for(let a=0;a<i;a++)t[a]=e(a,t);return t},on=Array.isArray;class x1{constructor(){this._observers=Ht()}on(e,t){return bi(this._observers,e,Fa).add(t),t}once(e,t){const a=(...n)=>{this.off(e,a),t(...n)};this.on(e,a)}off(e,t){const a=this._observers.get(e);a!==void 0&&(a.delete(t),a.size===0&&this._observers.delete(e))}emit(e,t){return pa((this._observers.get(e)||Ht()).values()).forEach(a=>a(...t))}destroy(){this._observers=Ht()}}const Wt=Math.floor,ur=Math.abs,rn=(i,e)=>i<e?i:e,Ii=(i,e)=>i>e?i:e,C1=i=>i!==0?i<0:1/i<0,Vc=1,Ic=2,dl=4,fl=8,ro=32,gi=64,Ze=128,jD=1<<29,ps=31,eu=63,da=127,qD=2147483647,Vr=Number.MAX_SAFE_INTEGER,Pc=Number.MIN_SAFE_INTEGER,AD=Number.isInteger||(i=>typeof i=="number"&&isFinite(i)&&Wt(i)===i),B1=String.fromCharCode,ND=i=>i.toLowerCase(),MD=/^\s*/g,TD=i=>i.replace(MD,""),OD=/([A-Z])/g,Lc=(i,e)=>TD(i.replace(OD,t=>`${e}${ND(t)}`)),VD=i=>{const e=unescape(encodeURIComponent(i)),t=e.length,a=new Uint8Array(t);for(let n=0;n<t;n++)a[n]=e.codePointAt(n);return a},so=typeof TextEncoder<"u"?new TextEncoder:null,ID=i=>so.encode(i),PD=so?ID:VD;let Rn=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Rn&&Rn.decode(new Uint8Array).length===1&&(Rn=null);const LD=(i,e)=>SD(e,()=>i).join("");class vo{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Eo=()=>new vo,zD=i=>{const e=Eo();return i(e),$t(e)},RD=i=>{let e=i.cpos;for(let t=0;t<i.bufs.length;t++)e+=i.bufs[t].length;return e},$t=i=>{const e=new Uint8Array(RD(i));let t=0;for(let a=0;a<i.bufs.length;a++){const n=i.bufs[a];e.set(n,t),t+=n.length}return e.set(new Uint8Array(i.cbuf.buffer,0,i.cpos),t),e},$D=(i,e)=>{const t=i.cbuf.length;t-i.cpos<e&&(i.bufs.push(new Uint8Array(i.cbuf.buffer,0,i.cpos)),i.cbuf=new Uint8Array(Ii(t,e)*2),i.cpos=0)},Ee=(i,e)=>{const t=i.cbuf.length;i.cpos===t&&(i.bufs.push(i.cbuf),i.cbuf=new Uint8Array(t*2),i.cpos=0),i.cbuf[i.cpos++]=e},tu=Ee,te=(i,e)=>{for(;e>da;)Ee(i,Ze|da&e),e=Wt(e/128);Ee(i,da&e)},Dd=(i,e)=>{const t=C1(e);for(t&&(e=-e),Ee(i,(e>eu?Ze:0)|(t?gi:0)|eu&e),e=Wt(e/64);e>0;)Ee(i,(e>da?Ze:0)|da&e),e=Wt(e/128)},iu=new Uint8Array(3e4),HD=iu.length/3,WD=(i,e)=>{if(e.length<HD){const t=so.encodeInto(e,iu).written||0;te(i,t);for(let a=0;a<t;a++)Ee(i,iu[a])}else pt(i,PD(e))},UD=(i,e)=>{const t=unescape(encodeURIComponent(e)),a=t.length;te(i,a);for(let n=0;n<a;n++)Ee(i,t.codePointAt(n))},$a=so&&so.encodeInto?WD:UD,bs=(i,e)=>{const t=i.cbuf.length,a=i.cpos,n=rn(t-a,e.length),o=e.length-n;i.cbuf.set(e.subarray(0,n),a),i.cpos+=n,o>0&&(i.bufs.push(i.cbuf),i.cbuf=new Uint8Array(Ii(t*2,o)),i.cbuf.set(e.subarray(n)),i.cpos=o)},pt=(i,e)=>{te(i,e.byteLength),bs(i,e)},vd=(i,e)=>{$D(i,e);const t=new DataView(i.cbuf.buffer,i.cpos,e);return i.cpos+=e,t},KD=(i,e)=>vd(i,4).setFloat32(0,e,!1),JD=(i,e)=>vd(i,8).setFloat64(0,e,!1),GD=(i,e)=>vd(i,8).setBigInt64(0,e,!1),zc=new DataView(new ArrayBuffer(4)),YD=i=>(zc.setFloat32(0,i),zc.getFloat32(0)===i),sn=(i,e)=>{switch(typeof e){case"string":Ee(i,119),$a(i,e);break;case"number":AD(e)&&ur(e)<=qD?(Ee(i,125),Dd(i,e)):YD(e)?(Ee(i,124),KD(i,e)):(Ee(i,123),JD(i,e));break;case"bigint":Ee(i,122),GD(i,e);break;case"object":if(e===null)Ee(i,126);else if(on(e)){Ee(i,117),te(i,e.length);for(let t=0;t<e.length;t++)sn(i,e[t])}else if(e instanceof Uint8Array)Ee(i,116),pt(i,e);else{Ee(i,118);const t=Object.keys(e);te(i,t.length);for(let a=0;a<t.length;a++){const n=t[a];$a(i,n),sn(i,e[n])}}break;case"boolean":Ee(i,e?120:121);break;default:Ee(i,127)}};class Rc extends vo{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&te(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const $c=i=>{i.count>0&&(Dd(i.encoder,i.count===1?i.s:-i.s),i.count>1&&te(i.encoder,i.count-2))};class dr{constructor(){this.encoder=new vo,this.s=0,this.count=0}write(e){this.s===e?this.count++:($c(this),this.count=1,this.s=e)}toUint8Array(){return $c(this),$t(this.encoder)}}const Hc=i=>{if(i.count>0){const e=i.diff*2+(i.count===1?0:1);Dd(i.encoder,e),i.count>1&&te(i.encoder,i.count-2)}};class cl{constructor(){this.encoder=new vo,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Hc(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Hc(this),$t(this.encoder)}}class XD{constructor(){this.sarr=[],this.s="",this.lensE=new dr}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new vo;return this.sarr.push(this.s),this.s="",$a(e,this.sarr.join("")),bs(e,this.lensE.toUint8Array()),$t(e)}}const ai=i=>new Error(i),Mt=()=>{throw ai("Method unimplemented")},$e=()=>{throw ai("Unexpected case")},S1=ai("Unexpected end of array"),j1=ai("Integer out of Range");class ys{constructor(e){this.arr=e,this.pos=0}}const Ed=i=>new ys(i),ZD=i=>i.pos!==i.arr.length,QD=(i,e)=>{const t=new Uint8Array(i.arr.buffer,i.pos+i.arr.byteOffset,e);return i.pos+=e,t},xt=i=>QD(i,ue(i)),lo=i=>i.arr[i.pos++],ue=i=>{let e=0,t=1;const a=i.arr.length;for(;i.pos<a;){const n=i.arr[i.pos++];if(e=e+(n&da)*t,t*=128,n<Ze)return e;if(e>Vr)throw j1}throw S1},xd=i=>{let e=i.arr[i.pos++],t=e&eu,a=64;const n=(e&gi)>0?-1:1;if((e&Ze)===0)return n*t;const o=i.arr.length;for(;i.pos<o;){if(e=i.arr[i.pos++],t=t+(e&da)*a,a*=128,e<Ze)return n*t;if(t>Vr)throw j1}throw S1},e9=i=>{let e=ue(i);if(e===0)return"";{let t=String.fromCodePoint(lo(i));if(--e<100)for(;e--;)t+=String.fromCodePoint(lo(i));else for(;e>0;){const a=e<1e4?e:1e4,n=i.arr.subarray(i.pos,i.pos+a);i.pos+=a,t+=String.fromCodePoint.apply(null,n),e-=a}return decodeURIComponent(escape(t))}},t9=i=>Rn.decode(xt(i)),au=Rn?t9:e9,Cd=(i,e)=>{const t=new DataView(i.arr.buffer,i.arr.byteOffset+i.pos,e);return i.pos+=e,t},i9=i=>Cd(i,4).getFloat32(0,!1),a9=i=>Cd(i,8).getFloat64(0,!1),n9=i=>Cd(i,8).getBigInt64(0,!1),o9=[i=>{},i=>null,xd,i9,a9,n9,i=>!1,i=>!0,au,i=>{const e=ue(i),t={};for(let a=0;a<e;a++){const n=au(i);t[n]=Ir(i)}return t},i=>{const e=ue(i),t=[];for(let a=0;a<e;a++)t.push(Ir(i));return t},xt],Ir=i=>o9[127-lo(i)](i);class Wc extends ys{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),ZD(this)?this.count=ue(this)+1:this.count=-1),this.count--,this.s}}class fr extends ys{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=xd(this);const e=C1(this.s);this.count=1,e&&(this.s=-this.s,this.count=ue(this)+2)}return this.count--,this.s}}class gl extends ys{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=xd(this),t=e&1;this.diff=Wt(e/2),this.count=1,t&&(this.count=ue(this)+2)}return this.s+=this.diff,this.count--,this.s}}class r9{constructor(e){this.decoder=new fr(e),this.str=au(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const s9=crypto.getRandomValues.bind(crypto),l9=Math.random,q1=()=>s9(new Uint32Array(1))[0],u9=i=>i[Wt(l9()*i.length)],d9="10000000-1000-4000-8000"+-1e11,f9=()=>d9.replace(/[018]/g,i=>(i^q1()&15>>i/4).toString(16)),c9=Date.now,Uc=i=>new Promise(i);Promise.all.bind(Promise);const Kc=i=>i===void 0?null:i;class g9{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let A1=new g9,_9=!0;try{typeof localStorage<"u"&&localStorage&&(A1=localStorage,_9=!1)}catch{}const h9=A1,uo=Symbol("Equality"),N1=(i,e)=>i===e||!!i?.[uo]?.(e)||!1,m9=i=>typeof i=="object",F9=Object.assign,M1=Object.keys,p9=(i,e)=>{for(const t in i)e(i[t],t)},Pr=i=>M1(i).length,b9=i=>{for(const e in i)return!1;return!0},mn=(i,e)=>{for(const t in i)if(!e(i[t],t))return!1;return!0},Bd=(i,e)=>Object.prototype.hasOwnProperty.call(i,e),y9=(i,e)=>i===e||Pr(i)===Pr(e)&&mn(i,(t,a)=>(t!==void 0||Bd(e,a))&&N1(e[a],t)),k9=Object.freeze,T1=i=>{for(const e in i){const t=i[e];(typeof t=="object"||typeof t=="function")&&T1(i[e])}return k9(i)},Sd=(i,e,t=0)=>{try{for(;t<i.length;t++)i[t](...e)}finally{t<i.length&&Sd(i,e,t+1)}},cr=(i,e)=>{if(i===e)return!0;if(i==null||e==null||i.constructor!==e.constructor&&(i.constructor||Object)!==(e.constructor||Object))return!1;if(i[uo]!=null)return i[uo](e);switch(i.constructor){case ArrayBuffer:i=new Uint8Array(i),e=new Uint8Array(e);case Uint8Array:{if(i.byteLength!==e.byteLength)return!1;for(let t=0;t<i.length;t++)if(i[t]!==e[t])return!1;break}case Set:{if(i.size!==e.size)return!1;for(const t of i)if(!e.has(t))return!1;break}case Map:{if(i.size!==e.size)return!1;for(const t of i.keys())if(!e.has(t)||!cr(i.get(t),e.get(t)))return!1;break}case void 0:case Object:if(Pr(i)!==Pr(e))return!1;for(const t in i)if(!Bd(i,t)||!cr(i[t],e[t]))return!1;break;case Array:if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!cr(i[t],e[t]))return!1;break;default:return!1}return!0},w9=(i,e)=>e.includes(i),ln=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",O1=typeof window<"u"&&typeof document<"u"&&!ln;let Yt;const D9=()=>{if(Yt===void 0)if(ln){Yt=Ht();const i=process.argv;let e=null;for(let t=0;t<i.length;t++){const a=i[t];a[0]==="-"?(e!==null&&Yt.set(e,""),e=a):e!==null&&(Yt.set(e,a),e=null)}e!==null&&Yt.set(e,"")}else typeof location=="object"?(Yt=Ht(),(location.search||"?").slice(1).split("&").forEach(i=>{if(i.length!==0){const[e,t]=i.split("=");Yt.set(`--${Lc(e,"-")}`,t),Yt.set(`-${Lc(e,"-")}`,t)}})):Yt=Ht();return Yt},nu=i=>D9().has(i),Lr=i=>Kc(ln?process.env[i.toUpperCase().replaceAll("-","_")]:h9.getItem(i)),V1=i=>nu("--"+i)||Lr(i)!==null,v9=V1("production"),E9=ln&&w9(process.env.FORCE_COLOR,["true","1","2"]),x9=E9||!nu("--no-colors")&&!V1("no-color")&&(!ln||process.stdout.isTTY)&&(!ln||nu("--color")||Lr("COLORTERM")!==null||(Lr("TERM")||"").includes("color")),C9=i=>{let e="";for(let t=0;t<i.byteLength;t++)e+=B1(i[t]);return btoa(e)},B9=i=>Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString("base64"),S9=O1?C9:B9,j9=i=>zD(e=>sn(e,i));class q9{constructor(e,t){this.left=e,this.right=t}}const ri=(i,e)=>new q9(i,e),Jc=i=>i.next()>=.5,_l=(i,e,t)=>Wt(i.next()*(t+1-e)+e),I1=(i,e,t)=>Wt(i.next()*(t+1-e)+e),jd=(i,e,t)=>I1(i,e,t),A9=i=>B1(jd(i,97,122)),N9=(i,e=0,t=20)=>{const a=jd(i,e,t);let n="";for(let o=0;o<a;o++)n+=A9(i);return n},hl=(i,e)=>e[jd(i,0,e.length-1)],M9=Symbol("0schema");class T9{constructor(){this._rerrs=[]}extend(e,t,a,n=null){this._rerrs.push({path:e,expected:t,has:a,message:n})}toString(){const e=[];for(let t=this._rerrs.length-1;t>0;t--){const a=this._rerrs[t];e.push(LD(" ",(this._rerrs.length-t)*2)+`${a.path!=null?`[${a.path}] `:""}${a.has} doesn't match ${a.expected}. ${a.message}`)}return e.join(`
133
133
  `)}}const ou=(i,e)=>i===e?!0:i==null||e==null||i.constructor!==e.constructor?!1:i[uo]?N1(i,e):on(i)?kd(i,t=>wd(e,a=>ou(t,a))):m9(i)?mn(i,(t,a)=>ou(t,e[a])):!1;class at{static _dilutes=!1;extends(e){let[t,a]=[this.shape,e.shape];return this.constructor._dilutes&&([a,t]=[t,a]),ou(t,a)}equals(e){return this.constructor===e.constructor&&cr(this.shape,e.shape)}[M9](){return!0}[uo](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Mt()}get nullable(){return Fn(this,Es)}get optional(){return new z1(this)}cast(e){return Gc(e,this),e}expect(e){return Gc(e,this),e}}class qd extends at{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){const a=e?.constructor===this.shape&&(this._c==null||this._c(e));return!a&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),a}}const ke=(i,e=null)=>new qd(i,e);ke(qd);class Ad extends at{constructor(e){super(),this.shape=e}check(e,t){const a=this.shape(e);return!a&&t?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),a}}const Se=i=>new Ad(i);ke(Ad);class ks extends at{constructor(e){super(),this.shape=e}check(e,t){const a=this.shape.some(n=>n===e);return!a&&t?.extend(null,this.shape.join(" | "),e.toString()),a}}const ws=(...i)=>new ks(i),P1=ke(ks),O9=RegExp.escape||(i=>i.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),L1=i=>{if(un.check(i))return[O9(i)];if(P1.check(i))return i.shape.map(e=>e+"");if(Y1.check(i))return["[+-]?\\d+.?\\d*"];if(X1.check(i))return[".*"];if(zr.check(i))return i.shape.map(L1).flat(1);$e()};class V9 extends at{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(L1).map(t=>`(${t.join("|")})`).join("")+"$")}check(e,t){const a=this._r.exec(e)!=null;return!a&&t?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),a}}ke(V9);const I9=Symbol("optional");class z1 extends at{constructor(e){super(),this.shape=e}check(e,t){const a=e===void 0||this.shape.check(e);return!a&&t?.extend(null,"undefined (optional)","()"),a}get[I9](){return!0}}const P9=ke(z1);class L9 extends at{check(e,t){return t?.extend(null,"never",typeof e),!1}}ke(L9);class Ds extends at{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new Ds(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,"object","null"),!1):mn(this.shape,(a,n)=>{const o=this._isPartial&&!Bd(e,n)||a.check(e[n],t);return!o&&t?.extend(n.toString(),a.toString(),typeof e[n],"Object property does not match"),o})}}const z9=i=>new Ds(i),R9=ke(Ds),$9=Se(i=>i!=null&&(i.constructor===Object||i.constructor==null));class R1 extends at{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&mn(e,(a,n)=>{const o=this.shape.keys.check(n,t);return!o&&t?.extend(n+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value"),o&&this.shape.values.check(a,t)})}}const $1=(i,e)=>new R1(i,e),H9=ke(R1);class H1 extends at{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&mn(this.shape,(a,n)=>{const o=a.check(e[n],t);return!o&&t?.extend(n.toString(),"Tuple",typeof a),o})}}const W9=(...i)=>new H1(i);ke(H1);class W1 extends at{constructor(e){super(),this.shape=e.length===1?e[0]:new Nd(e)}check(e,t){const a=on(e)&&kd(e,n=>this.shape.check(n));return!a&&t?.extend(null,"Array",""),a}}const U1=(...i)=>new W1(i),U9=ke(W1),K9=Se(i=>on(i));class K1 extends at{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){const a=e instanceof this.shape&&(this._c==null||this._c(e));return!a&&t?.extend(null,this.shape.name,e?.constructor.name),a}}const J9=(i,e=null)=>new K1(i,e);ke(K1);const G9=J9(at);class Y9 extends at{constructor(e){super(),this.len=e.length-1,this.args=W9(...e.slice(-1)),this.res=e[this.len]}check(e,t){const a=e.constructor===Function&&e.length<=this.len;return!a&&t?.extend(null,"function",typeof e),a}}const X9=ke(Y9),Z9=Se(i=>typeof i=="function");class Q9 extends at{constructor(e){super(),this.shape=e}check(e,t){const a=kd(this.shape,n=>n.check(e,t));return!a&&t?.extend(null,"Intersectinon",typeof e),a}}ke(Q9,i=>i.shape.length>0);class Nd extends at{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){const a=wd(this.shape,n=>n.check(e,t));return t?.extend(null,"Union",typeof e),a}}const Fn=(...i)=>i.findIndex(e=>zr.check(e))>=0?Fn(...i.map(e=>fo(e)).map(e=>zr.check(e)?e.shape:[e]).flat(1)):i.length===1?i[0]:new Nd(i),zr=ke(Nd),J1=()=>!0,Rr=Se(J1),ev=ke(Ad,i=>i.shape===J1),Md=Se(i=>typeof i=="bigint"),tv=Se(i=>i===Md),G1=Se(i=>typeof i=="symbol");Se(i=>i===G1);const Ha=Se(i=>typeof i=="number"),Y1=Se(i=>i===Ha),un=Se(i=>typeof i=="string"),X1=Se(i=>i===un),vs=Se(i=>typeof i=="boolean"),iv=Se(i=>i===vs),Z1=ws(void 0);ke(ks,i=>i.shape.length===1&&i.shape[0]===void 0);ws(void 0);const Es=ws(null),av=ke(ks,i=>i.shape.length===1&&i.shape[0]===null);ke(Uint8Array);ke(qd,i=>i.shape===Uint8Array);const nv=Fn(Ha,un,Es,Z1,Md,vs,G1);(()=>{const i=U1(Rr),e=$1(un,Rr),t=Fn(Ha,un,Es,vs,i,e);return i.shape=t,e.shape.values=t,t})();const fo=i=>{if(G9.check(i))return i;if($9.check(i)){const e={};for(const t in i)e[t]=fo(i[t]);return z9(e)}else{if(K9.check(i))return Fn(...i.map(fo));if(nv.check(i))return ws(i);if(Z9.check(i))return ke(i)}$e()},Gc=v9?()=>{}:(i,e)=>{const t=new T9;if(!e.check(i,t))throw ai(`Expected value to be of type ${e.constructor.name}.
134
- ${t.toString()}`)};class ov{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:fo(e),h:t}),this}else(e){return this.if(Rr,e)}done(){return(e,t)=>{for(let a=0;a<this.patterns.length;a++){const n=this.patterns[a];if(n.if.check(e))return n.h(e,t)}throw ai("Unhandled pattern")}}}const rv=i=>new ov(i),Q1=rv(Rr).if(Y1,(i,e)=>_l(e,Pc,Vr)).if(X1,(i,e)=>N9(e)).if(iv,(i,e)=>Jc(e)).if(tv,(i,e)=>BigInt(_l(e,Pc,Vr))).if(zr,(i,e)=>Ma(e,hl(e,i.shape))).if(R9,(i,e)=>{const t={};for(const a in i.shape){let n=i.shape[a];if(P9.check(n)){if(Jc(e))continue;n=n.shape}t[a]=Q1(n,e)}return t}).if(U9,(i,e)=>{const t=[],a=I1(e,0,42);for(let n=0;n<a;n++)t.push(Ma(e,i.shape));return t}).if(P1,(i,e)=>hl(e,i.shape)).if(av,(i,e)=>null).if(X9,(i,e)=>{const t=Ma(e,i.res);return()=>t}).if(ev,(i,e)=>Ma(e,hl(e,[Ha,un,Es,Z1,Md,vs,U1(Ha),$1(Fn("a","b","c"),Ha)]))).if(H9,(i,e)=>{const t={},a=_l(e,0,3);for(let n=0;n<a;n++){const o=Ma(e,i.shape.keys),r=Ma(e,i.shape.values);t[o]=r}return t}).done(),Ma=(i,e)=>Q1(fo(e),i),xo=typeof document<"u"?document:{};Se(i=>i.nodeType===fv);typeof DOMParser<"u"&&new DOMParser;Se(i=>i.nodeType===lv);Se(i=>i.nodeType===uv);const sv=i=>xD(i,(e,t)=>`${t}:${e};`).join(""),lv=xo.ELEMENT_NODE,uv=xo.TEXT_NODE,dv=xo.DOCUMENT_NODE,fv=xo.DOCUMENT_FRAGMENT_NODE;Se(i=>i.nodeType===dv);const cv=i=>class{constructor(t){this._=t}destroy(){i(this._)}},gv=cv(clearTimeout),em=(i,e)=>new gv(setTimeout(e,i)),yi=Symbol,tm=yi(),im=yi(),_v=yi(),hv=yi(),mv=yi(),am=yi(),Fv=yi(),Td=yi(),pv=yi(),bv=i=>{i.length===1&&i[0]?.constructor===Function&&(i=i[0]());const e=[],t=[];let a=0;for(;a<i.length;a++){const n=i[a];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)e.push(n);else if(n.constructor===Object)break}for(a>0&&t.push(e.join(""));a<i.length;a++){const n=i[a];n instanceof Symbol||t.push(n)}return t},yv={[tm]:ri("font-weight","bold"),[im]:ri("font-weight","normal"),[_v]:ri("color","blue"),[mv]:ri("color","green"),[hv]:ri("color","grey"),[am]:ri("color","red"),[Fv]:ri("color","purple"),[Td]:ri("color","orange"),[pv]:ri("color","black")},kv=i=>{i.length===1&&i[0]?.constructor===Function&&(i=i[0]());const e=[],t=[],a=Ht();let n=[],o=0;for(;o<i.length;o++){const r=i[o],l=yv[r];if(l!==void 0)a.set(l.left,l.right);else{if(r===void 0)break;if(r.constructor===String||r.constructor===Number){const u=sv(a);o>0||u.length>0?(e.push("%c"+r),t.push(u)):e.push(r)}else break}}for(o>0&&(n=t,n.unshift(e.join("")));o<i.length;o++){const r=i[o];r instanceof Symbol||n.push(r)}return n},nm=x9?kv:bv,wv=(...i)=>{console.log(...nm(i)),rm.forEach(e=>e.print(i))},om=(...i)=>{console.warn(...nm(i)),i.unshift(Td),rm.forEach(e=>e.print(i))},rm=Fa(),sm=i=>({[Symbol.iterator](){return this},next:i}),Dv=(i,e)=>sm(()=>{let t;do t=i.next();while(!t.done&&!e(t.value));return t}),ml=(i,e)=>sm(()=>{const{done:t,value:a}=i.next();return{done:t,value:t?void 0:e(a)}});class Od{constructor(e,t){this.clock=e,this.len=t}}class pn{constructor(){this.clients=new Map}}const Pi=(i,e,t)=>e.clients.forEach((a,n)=>{const o=i.doc.store.clients.get(n);if(o!=null){const r=o[o.length-1],l=r.id.clock+r.length;for(let u=0,d=a[u];u<a.length&&d.clock<l;d=a[++u])hm(i,o,d.clock,d.len,t)}}),vv=(i,e)=>{let t=0,a=i.length-1;for(;t<=a;){const n=Wt((t+a)/2),o=i[n],r=o.clock;if(r<=e){if(e<r+o.len)return n;t=n+1}else a=n-1}return null},bn=(i,e)=>{const t=i.clients.get(e.client);return t!==void 0&&vv(t,e.clock)!==null},Vd=i=>{i.clients.forEach(e=>{e.sort((n,o)=>n.clock-o.clock);let t,a;for(t=1,a=1;t<e.length;t++){const n=e[a-1],o=e[t];n.clock+n.len>=o.clock?n.len=Ii(n.len,o.clock+o.len-n.clock):(a<t&&(e[a]=o),a++)}e.length=a})},ru=i=>{const e=new pn;for(let t=0;t<i.length;t++)i[t].clients.forEach((a,n)=>{if(!e.clients.has(n)){const o=a.slice();for(let r=t+1;r<i.length;r++)BD(o,i[r].clients.get(n)||[]);e.clients.set(n,o)}});return Vd(e),e},co=(i,e,t,a)=>{bi(i.clients,e,()=>[]).push(new Od(t,a))},lm=()=>new pn,Ev=i=>{const e=lm();return i.clients.forEach((t,a)=>{const n=[];for(let o=0;o<t.length;o++){const r=t[o];if(r.deleted){const l=r.id.clock;let u=r.length;if(o+1<t.length)for(let d=t[o+1];o+1<t.length&&d.deleted;d=t[++o+1])u+=d.length;n.push(new Od(l,u))}}n.length>0&&e.clients.set(a,n)}),e},Id=(i,e)=>{te(i.restEncoder,e.clients.size),pa(e.clients.entries()).sort((t,a)=>a[0]-t[0]).forEach(([t,a])=>{i.resetDsCurVal(),te(i.restEncoder,t);const n=a.length;te(i.restEncoder,n);for(let o=0;o<n;o++){const r=a[o];i.writeDsClock(r.clock),i.writeDsLen(r.len)}})},xv=i=>{const e=new pn,t=ue(i.restDecoder);for(let a=0;a<t;a++){i.resetDsCurVal();const n=ue(i.restDecoder),o=ue(i.restDecoder);if(o>0){const r=bi(e.clients,n,()=>[]);for(let l=0;l<o;l++)r.push(new Od(i.readDsClock(),i.readDsLen()))}}return e},Yc=(i,e,t)=>{const a=new pn,n=ue(i.restDecoder);for(let o=0;o<n;o++){i.resetDsCurVal();const r=ue(i.restDecoder),l=ue(i.restDecoder),u=t.clients.get(r)||[],d=Fe(t,r);for(let f=0;f<l;f++){const c=i.readDsClock(),g=c+i.readDsLen();if(c<d){d<g&&co(a,r,d,g-d);let _=Ut(u,c),h=u[_];for(!h.deleted&&h.id.clock<c&&(u.splice(_+1,0,Gr(e,h,c-h.id.clock)),_++);_<u.length&&(h=u[_++],h.id.clock<g);)h.deleted||(g<h.id.clock+h.length&&u.splice(_,0,Gr(e,h,g-h.id.clock)),h.delete(e))}else co(a,r,c,g-c)}}if(a.clients.size>0){const o=new xs;return te(o.restEncoder,0),Id(o,a),o.toUint8Array()}return null},um=q1;class va extends x1{constructor({guid:e=f9(),collectionid:t=null,gc:a=!0,gcFilter:n=()=>!0,meta:o=null,autoLoad:r=!1,shouldLoad:l=!0}={}){super(),this.gc=a,this.gcFilter=n,this.clientID=um(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new gm,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=r,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Uc(d=>{this.on("load",()=>{this.isLoaded=!0,d(this)})});const u=()=>Uc(d=>{const f=c=>{(c===void 0||c===!0)&&(this.off("sync",f),d())};this.on("sync",f)});this.on("sync",d=>{d===!1&&this.isSynced&&(this.whenSynced=u()),this.isSynced=d===void 0||d===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=u()}load(){const e=this._item;e!==null&&!this.shouldLoad&&ne(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(pa(this.subdocs).map(e=>e.guid))}transact(e,t=null){return ne(this,e,t)}get(e,t=Be){const a=bi(this.share,e,()=>{const o=new t;return o._integrate(this,null),o}),n=a.constructor;if(t!==Be&&n!==t)if(n===Be){const o=new t;o._map=a._map,a._map.forEach(r=>{for(;r!==null;r=r.left)r.parent=o}),o._start=a._start;for(let r=o._start;r!==null;r=r.right)r.parent=o;return o._length=a._length,this.share.set(e,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return a}getArray(e=""){return this.get(e,Ka)}getText(e=""){return this.get(e,Li)}getMap(e=""){return this.get(e,dn)}getXmlElement(e=""){return this.get(e,Pe)}getXmlFragment(e=""){return this.get(e,ba)}toJSON(){const e={};return this.share.forEach((t,a)=>{e[a]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,pa(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new va({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,ne(e.parent.doc,a=>{const n=t.doc;e.deleted||a.subdocsAdded.add(n),a.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Cv{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=ue(this.restDecoder),this.dsCurrVal}readDsLen(){const e=ue(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class $r extends Cv{constructor(e){super(e),this.keys=[],ue(e),this.keyClockDecoder=new gl(xt(e)),this.clientDecoder=new fr(xt(e)),this.leftClockDecoder=new gl(xt(e)),this.rightClockDecoder=new gl(xt(e)),this.infoDecoder=new Wc(xt(e),lo),this.stringDecoder=new r9(xt(e)),this.parentInfoDecoder=new Wc(xt(e),lo),this.typeRefDecoder=new fr(xt(e)),this.lenDecoder=new fr(xt(e))}readLeftID(){return new Wa(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Wa(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 Ir(this.restDecoder)}readBuf(){return xt(this.restDecoder)}readJSON(){return Ir(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class Bv{constructor(){this.restEncoder=Eo()}toUint8Array(){return $t(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){te(this.restEncoder,e)}writeDsLen(e){te(this.restEncoder,e)}}class Sv extends Bv{writeLeftID(e){te(this.restEncoder,e.client),te(this.restEncoder,e.clock)}writeRightID(e){te(this.restEncoder,e.client),te(this.restEncoder,e.clock)}writeClient(e){te(this.restEncoder,e)}writeInfo(e){tu(this.restEncoder,e)}writeString(e){$a(this.restEncoder,e)}writeParentInfo(e){te(this.restEncoder,e?1:0)}writeTypeRef(e){te(this.restEncoder,e)}writeLen(e){te(this.restEncoder,e)}writeAny(e){sn(this.restEncoder,e)}writeBuf(e){pt(this.restEncoder,e)}writeJSON(e){$a(this.restEncoder,JSON.stringify(e))}writeKey(e){$a(this.restEncoder,e)}}class jv{constructor(){this.restEncoder=Eo(),this.dsCurrVal=0}toUint8Array(){return $t(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,te(this.restEncoder,t)}writeDsLen(e){e===0&&$e(),te(this.restEncoder,e-1),this.dsCurrVal+=e}}class xs extends jv{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new cl,this.clientEncoder=new dr,this.leftClockEncoder=new cl,this.rightClockEncoder=new cl,this.infoEncoder=new Rc(tu),this.stringEncoder=new XD,this.parentInfoEncoder=new Rc(tu),this.typeRefEncoder=new dr,this.lenEncoder=new dr}toUint8Array(){const e=Eo();return te(e,0),pt(e,this.keyClockEncoder.toUint8Array()),pt(e,this.clientEncoder.toUint8Array()),pt(e,this.leftClockEncoder.toUint8Array()),pt(e,this.rightClockEncoder.toUint8Array()),pt(e,$t(this.infoEncoder)),pt(e,this.stringEncoder.toUint8Array()),pt(e,$t(this.parentInfoEncoder)),pt(e,this.typeRefEncoder.toUint8Array()),pt(e,this.lenEncoder.toUint8Array()),bs(e,$t(this.restEncoder)),$t(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?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){sn(this.restEncoder,e)}writeBuf(e){pt(this.restEncoder,e)}writeJSON(e){sn(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const qv=(i,e,t,a)=>{a=Ii(a,e[0].id.clock);const n=Ut(e,a);te(i.restEncoder,e.length-n),i.writeClient(t),te(i.restEncoder,a);const o=e[n];o.write(i,a-o.id.clock);for(let r=n+1;r<e.length;r++)e[r].write(i,0)},dm=(i,e,t)=>{const a=new Map;t.forEach((n,o)=>{Fe(e,o)>n&&a.set(o,n)}),Cs(e).forEach((n,o)=>{t.has(o)||a.set(o,0)}),te(i.restEncoder,a.size),pa(a.entries()).sort((n,o)=>o[0]-n[0]).forEach(([n,o])=>{qv(i,e.clients.get(n),n,o)})},Av=(i,e)=>{const t=Ht(),a=ue(i.restDecoder);for(let n=0;n<a;n++){const o=ue(i.restDecoder),r=new Array(o),l=i.readClient();let u=ue(i.restDecoder);t.set(l,{i:0,refs:r});for(let d=0;d<o;d++){const f=i.readInfo();switch(ps&f){case 0:{const c=i.readLen();r[d]=new jt(X(l,u),c),u+=c;break}case 10:{const c=ue(i.restDecoder);r[d]=new Rt(X(l,u),c),u+=c;break}default:{const c=(f&(gi|Ze))===0,g=new ae(X(l,u),null,(f&Ze)===Ze?i.readLeftID():null,null,(f&gi)===gi?i.readRightID():null,c?i.readParentInfo()?e.get(i.readString()):i.readLeftID():null,c&&(f&ro)===ro?i.readString():null,Vm(i,f));r[d]=g,u+=g.length}}}}return t},Nv=(i,e,t)=>{const a=[];let n=pa(t.keys()).sort((_,h)=>_-h);if(n.length===0)return null;const o=()=>{if(n.length===0)return null;let _=t.get(n[n.length-1]);for(;_.refs.length===_.i;)if(n.pop(),n.length>0)_=t.get(n[n.length-1]);else return null;return _};let r=o();if(r===null)return null;const l=new gm,u=new Map,d=(_,h)=>{const F=u.get(_);(F==null||F>h)&&u.set(_,h)};let f=r.refs[r.i++];const c=new Map,g=()=>{for(const _ of a){const h=_.id.client,F=t.get(h);F?(F.i--,l.clients.set(h,F.refs.slice(F.i)),t.delete(h),F.i=0,F.refs=[]):l.clients.set(h,[_]),n=n.filter(m=>m!==h)}a.length=0};for(;;){if(f.constructor!==Rt){const h=bi(c,f.id.client,()=>Fe(e,f.id.client))-f.id.clock;if(h<0)a.push(f),d(f.id.client,f.id.clock-1),g();else{const F=f.getMissing(i,e);if(F!==null){a.push(f);const m=t.get(F)||{refs:[],i:0};if(m.refs.length===m.i)d(F,Fe(e,F)),g();else{f=m.refs[m.i++];continue}}else(h===0||h<f.length)&&(f.integrate(i,h),c.set(f.id.client,f.id.clock+f.length))}}if(a.length>0)f=a.pop();else if(r!==null&&r.i<r.refs.length)f=r.refs[r.i++];else{if(r=o(),r===null)break;f=r.refs[r.i++]}}if(l.clients.size>0){const _=new xs;return dm(_,l,new Map),te(_.restEncoder,0),{missing:u,update:_.toUint8Array()}}return null},Mv=(i,e)=>dm(i,e.doc.store,e.beforeState),Tv=(i,e,t,a=new $r(i))=>ne(e,n=>{n.local=!1;let o=!1;const r=n.doc,l=r.store,u=Av(a,r),d=Nv(n,l,u),f=l.pendingStructs;if(f){for(const[g,_]of f.missing)if(_<Fe(l,g)){o=!0;break}if(d){for(const[g,_]of d.missing){const h=f.missing.get(g);(h==null||h>_)&&f.missing.set(g,_)}f.update=og([f.update,d.update])}}else l.pendingStructs=d;const c=Yc(a,n,l);if(l.pendingDs){const g=new $r(Ed(l.pendingDs));ue(g.restDecoder);const _=Yc(g,n,l);c&&_?l.pendingDs=og([c,_]):l.pendingDs=c||_}else l.pendingDs=c;if(o){const g=l.pendingStructs.update;l.pendingStructs=null,su(n.doc,g)}},t,!1),su=(i,e,t,a=$r)=>{const n=Ed(e);Tv(n,i,t,new a(n))};class Ov{constructor(){this.l=[]}}const Xc=()=>new Ov,Zc=(i,e)=>i.l.push(e),Qc=(i,e)=>{const t=i.l,a=t.length;i.l=t.filter(n=>e!==n),a===i.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},fm=(i,e,t)=>Sd(i.l,[e,t]);class Wa{constructor(e,t){this.client=e,this.clock=t}}const Yo=(i,e)=>i===e||i!==null&&e!==null&&i.client===e.client&&i.clock===e.clock,X=(i,e)=>new Wa(i,e),go=i=>{for(const[e,t]of i.doc.share.entries())if(t===i)return e;throw $e()},_o=(i,e)=>{for(;e!==null;){if(e.parent===i)return!0;e=e.parent._item}return!1};class Hr{constructor(e,t,a,n=0){this.type=e,this.tname=t,this.item=a,this.assoc=n}}class Vv{constructor(e,t,a=0){this.type=e,this.index=t,this.assoc=a}}const Iv=(i,e,t=0)=>new Vv(i,e,t),Xo=(i,e,t)=>{let a=null,n=null;return i._item===null?n=go(i):a=X(i._item.id.client,i._item.id.clock),new Hr(a,n,e,t)},Fl=(i,e,t=0)=>{let a=i._start;if(t<0){if(e===0)return Xo(i,null,t);e--}for(;a!==null;){if(!a.deleted&&a.countable){if(a.length>e)return Xo(i,X(a.id.client,a.id.clock+e),t);e-=a.length}if(a.right===null&&t<0)return Xo(i,a.lastId,t);a=a.right}return Xo(i,null,t)},Pv=(i,e)=>{const t=Ua(i,e),a=e.clock-t.id.clock;return{item:t,diff:a}},Lv=(i,e,t=!0)=>{const a=e.store,n=i.item,o=i.type,r=i.tname,l=i.assoc;let u=null,d=0;if(n!==null){if(Fe(a,n.client)<=n.clock)return null;const f=t?fu(a,n):Pv(a,n),c=f.item;if(!(c instanceof ae))return null;if(u=c.parent,u._item===null||!u._item.deleted){d=c.deleted||!c.countable?0:f.diff+(l>=0?0:1);let g=c.left;for(;g!==null;)!g.deleted&&g.countable&&(d+=g.length),g=g.left}}else{if(r!==null)u=e.get(r);else if(o!==null){if(Fe(a,o.client)<=o.clock)return null;const{item:f}=t?fu(a,o):{item:Ua(a,o)};if(f instanceof ae&&f.content instanceof Jt)u=f.content.type;else return null}else throw $e();l>=0?d=u._length:d=0}return Iv(u,d,i.assoc)};class Pd{constructor(e,t){this.ds=e,this.sv=t}}const cm=(i,e)=>new Pd(i,e),pl=i=>cm(Ev(i.store),Cs(i.store)),Xi=(i,e)=>e===void 0?!i.deleted:e.sv.has(i.id.client)&&(e.sv.get(i.id.client)||0)>i.id.clock&&!bn(e.ds,i.id),lu=(i,e)=>{const t=bi(i.meta,lu,Fa),a=i.doc.store;t.has(e)||(e.sv.forEach((n,o)=>{n<Fe(a,o)&&nt(i,X(o,n))}),Pi(i,e.ds,n=>{}),t.add(e))};class gm{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Cs=i=>{const e=new Map;return i.clients.forEach((t,a)=>{const n=t[t.length-1];e.set(a,n.id.clock+n.length)}),e},Fe=(i,e)=>{const t=i.clients.get(e);if(t===void 0)return 0;const a=t[t.length-1];return a.id.clock+a.length},_m=(i,e)=>{let t=i.clients.get(e.id.client);if(t===void 0)t=[],i.clients.set(e.id.client,t);else{const a=t[t.length-1];if(a.id.clock+a.length!==e.id.clock)throw $e()}t.push(e)},Ut=(i,e)=>{let t=0,a=i.length-1,n=i[a],o=n.id.clock;if(o===e)return a;let r=Wt(e/(o+n.length-1)*a);for(;t<=a;){if(n=i[r],o=n.id.clock,o<=e){if(e<o+n.length)return r;t=r+1}else a=r-1;r=Wt((t+a)/2)}throw $e()},zv=(i,e)=>{const t=i.clients.get(e.client);return t[Ut(t,e.clock)]},Ua=zv,uu=(i,e,t)=>{const a=Ut(e,t),n=e[a];return n.id.clock<t&&n instanceof ae?(e.splice(a+1,0,Gr(i,n,t-n.id.clock)),a+1):a},nt=(i,e)=>{const t=i.doc.store.clients.get(e.client);return t[uu(i,t,e.clock)]},eg=(i,e,t)=>{const a=e.clients.get(t.client),n=Ut(a,t.clock),o=a[n];return t.clock!==o.id.clock+o.length-1&&o.constructor!==jt&&a.splice(n+1,0,Gr(i,o,t.clock-o.id.clock+1)),o},Rv=(i,e,t)=>{const a=i.clients.get(e.id.client);a[Ut(a,e.id.clock)]=t},hm=(i,e,t,a,n)=>{if(a===0)return;const o=t+a;let r=uu(i,e,t),l;do l=e[r++],o<l.id.clock+l.length&&uu(i,e,o),n(l);while(r<e.length&&e[r].id.clock<o)};class $v{constructor(e,t,a){this.doc=e,this.deleteSet=new pn,this.beforeState=Cs(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=a,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const tg=(i,e)=>e.deleteSet.clients.size===0&&!CD(e.afterState,(t,a)=>e.beforeState.get(a)!==t)?!1:(Vd(e.deleteSet),Mv(i,e),Id(i,e.deleteSet),!0),ig=(i,e,t)=>{const a=e._item;(a===null||a.id.clock<(i.beforeState.get(a.id.client)||0)&&!a.deleted)&&bi(i.changed,e,Fa).add(t)},gr=(i,e)=>{let t=i[e],a=i[e-1],n=e;for(;n>0;t=a,a=i[--n-1]){if(a.deleted===t.deleted&&a.constructor===t.constructor&&a.mergeWith(t)){t instanceof ae&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,a);continue}break}const o=e-n;return o&&i.splice(e+1-o,o),o},Hv=(i,e,t)=>{for(const[a,n]of i.clients.entries()){const o=e.clients.get(a);for(let r=n.length-1;r>=0;r--){const l=n[r],u=l.clock+l.len;for(let d=Ut(o,l.clock),f=o[d];d<o.length&&f.id.clock<u;f=o[++d]){const c=o[d];if(l.clock+l.len<=c.id.clock)break;c instanceof ae&&c.deleted&&!c.keep&&t(c)&&c.gc(e,!1)}}}},Wv=(i,e)=>{i.clients.forEach((t,a)=>{const n=e.clients.get(a);for(let o=t.length-1;o>=0;o--){const r=t[o],l=rn(n.length-1,1+Ut(n,r.clock+r.len-1));for(let u=l,d=n[u];u>0&&d.id.clock>=r.clock;d=n[u])u-=1+gr(n,u)}})},mm=(i,e)=>{if(e<i.length){const t=i[e],a=t.doc,n=a.store,o=t.deleteSet,r=t._mergeStructs;try{Vd(o),t.afterState=Cs(t.doc.store),a.emit("beforeObserverCalls",[t,a]);const l=[];t.changed.forEach((u,d)=>l.push(()=>{(d._item===null||!d._item.deleted)&&d._callObserver(t,u)})),l.push(()=>{t.changedParentTypes.forEach((u,d)=>{d._dEH.l.length>0&&(d._item===null||!d._item.deleted)&&(u=u.filter(f=>f.target._item===null||!f.target._item.deleted),u.forEach(f=>{f.currentTarget=d,f._path=null}),u.sort((f,c)=>f.path.length-c.path.length),fm(d._dEH,u,t))})}),l.push(()=>a.emit("afterTransaction",[t,a])),Sd(l,[]),t._needFormattingCleanup&&fE(t)}finally{a.gc&&Hv(o,n,a.gcFilter),Wv(o,n),t.afterState.forEach((f,c)=>{const g=t.beforeState.get(c)||0;if(g!==f){const _=n.clients.get(c),h=Ii(Ut(_,g),1);for(let F=_.length-1;F>=h;)F-=1+gr(_,F)}});for(let f=r.length-1;f>=0;f--){const{client:c,clock:g}=r[f].id,_=n.clients.get(c),h=Ut(_,g);h+1<_.length&&gr(_,h+1)>1||h>0&&gr(_,h)}if(!t.local&&t.afterState.get(a.clientID)!==t.beforeState.get(a.clientID)&&(wv(Td,tm,"[yjs] ",im,am,"Changed the client-id because another client seems to be using it."),a.clientID=um()),a.emit("afterTransactionCleanup",[t,a]),a._observers.has("update")){const f=new Sv;tg(f,t)&&a.emit("update",[f.toUint8Array(),t.origin,a,t])}if(a._observers.has("updateV2")){const f=new xs;tg(f,t)&&a.emit("updateV2",[f.toUint8Array(),t.origin,a,t])}const{subdocsAdded:l,subdocsLoaded:u,subdocsRemoved:d}=t;(l.size>0||d.size>0||u.size>0)&&(l.forEach(f=>{f.clientID=a.clientID,f.collectionid==null&&(f.collectionid=a.collectionid),a.subdocs.add(f)}),d.forEach(f=>a.subdocs.delete(f)),a.emit("subdocs",[{loaded:u,added:l,removed:d},a,t]),d.forEach(f=>f.destroy())),i.length<=e+1?(a._transactionCleanups=[],a.emit("afterAllTransactions",[a,i])):mm(i,e+1)}}},ne=(i,e,t=null,a=!0)=>{const n=i._transactionCleanups;let o=!1,r=null;i._transaction===null&&(o=!0,i._transaction=new $v(i,t,a),n.push(i._transaction),n.length===1&&i.emit("beforeAllTransactions",[i]),i.emit("beforeTransaction",[i._transaction,i]));try{r=e(i._transaction)}finally{if(o){const l=i._transaction===n[0];i._transaction=null,l&&mm(n,0)}}return r};class Uv{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const ag=(i,e,t)=>{Pi(i,t.deletions,a=>{a instanceof ae&&e.scope.some(n=>n===i.doc||_o(n,a))&&Hd(a,!1)})},ng=(i,e,t)=>{let a=null;const n=i.doc,o=i.scope;ne(n,l=>{for(;e.length>0&&i.currStackItem===null;){const u=n.store,d=e.pop(),f=new Set,c=[];let g=!1;Pi(l,d.insertions,_=>{if(_ instanceof ae){if(_.redone!==null){let{item:h,diff:F}=fu(u,_.id);F>0&&(h=nt(l,X(h.id.client,h.id.clock+F))),_=h}!_.deleted&&o.some(h=>h===l.doc||_o(h,_))&&c.push(_)}}),Pi(l,d.deletions,_=>{_ instanceof ae&&o.some(h=>h===l.doc||_o(h,_))&&!bn(d.insertions,_.id)&&f.add(_)}),f.forEach(_=>{g=Om(l,_,f,d.insertions,i.ignoreRemoteMapChanges,i)!==null||g});for(let _=c.length-1;_>=0;_--){const h=c[_];i.deleteFilter(h)&&(h.delete(l),g=!0)}i.currStackItem=g?d:null}l.changed.forEach((u,d)=>{u.has(null)&&d._searchMarker&&(d._searchMarker.length=0)}),a=l},i);const r=i.currStackItem;if(r!=null){const l=a.changedParentTypes;i.emit("stack-item-popped",[{stackItem:r,type:t,changedParentTypes:l,origin:i},i]),i.currStackItem=null}return r};class Fm extends x1{constructor(e,{captureTimeout:t=500,captureTransaction:a=u=>!0,deleteFilter:n=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:r=!1,doc:l=on(e)?e[0].doc:e instanceof va?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=n,o.add(this),this.trackedOrigins=o,this.captureTransaction=a,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=r,this.captureTimeout=t,this.afterTransactionHandler=u=>{if(!this.captureTransaction(u)||!this.scope.some(m=>u.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(u.origin)&&(!u.origin||!this.trackedOrigins.has(u.origin.constructor)))return;const d=this.undoing,f=this.redoing,c=d?this.redoStack:this.undoStack;d?this.stopCapturing():f||this.clear(!1,!0);const g=new pn;u.afterState.forEach((m,p)=>{const y=u.beforeState.get(p)||0,k=m-y;k>0&&co(g,p,y,k)});const _=c9();let h=!1;if(this.lastChange>0&&_-this.lastChange<this.captureTimeout&&c.length>0&&!d&&!f){const m=c[c.length-1];m.deletions=ru([m.deletions,u.deleteSet]),m.insertions=ru([m.insertions,g])}else c.push(new Uv(u.deleteSet,g)),h=!0;!d&&!f&&(this.lastChange=_),Pi(u,u.deleteSet,m=>{m instanceof ae&&this.scope.some(p=>p===u.doc||_o(p,m))&&Hd(m,!0)});const F=[{stackItem:c[c.length-1],origin:u.origin,type:d?"redo":"undo",changedParentTypes:u.changedParentTypes},this];h?this.emit("stack-item-added",F):this.emit("stack-item-updated",F)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const t=new Set(this.scope);e=on(e)?e:[e],e.forEach(a=>{t.has(a)||(t.add(a),(a instanceof Be?a.doc!==this.doc:a!==this.doc)&&om("[yjs#509] Not same Y.Doc"),this.scope.push(a))})}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(a=>{e&&(this.undoStack.forEach(n=>ag(a,this,n)),this.undoStack=[]),t&&(this.redoStack.forEach(n=>ag(a,this,n)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=ng(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=ng(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*Kv(i){const e=ue(i.restDecoder);for(let t=0;t<e;t++){const a=ue(i.restDecoder),n=i.readClient();let o=ue(i.restDecoder);for(let r=0;r<a;r++){const l=i.readInfo();if(l===10){const u=ue(i.restDecoder);yield new Rt(X(n,o),u),o+=u}else if((ps&l)!==0){const u=(l&(gi|Ze))===0,d=new ae(X(n,o),null,(l&Ze)===Ze?i.readLeftID():null,null,(l&gi)===gi?i.readRightID():null,u?i.readParentInfo()?i.readString():i.readLeftID():null,u&&(l&ro)===ro?i.readString():null,Vm(i,l));yield d,o+=d.length}else{const u=i.readLen();yield new jt(X(n,o),u),o+=u}}}}class Jv{constructor(e,t){this.gen=Kv(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===Rt);return this.curr}}class Gv{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Yv=(i,e)=>{if(i.constructor===jt){const{client:t,clock:a}=i.id;return new jt(X(t,a+e),i.length-e)}else if(i.constructor===Rt){const{client:t,clock:a}=i.id;return new Rt(X(t,a+e),i.length-e)}else{const t=i,{client:a,clock:n}=t.id;return new ae(X(a,n+e),null,X(a,n+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},og=(i,e=$r,t=xs)=>{if(i.length===1)return i[0];const a=i.map(f=>new e(Ed(f)));let n=a.map(f=>new Jv(f,!0)),o=null;const r=new t,l=new Gv(r);for(;n=n.filter(g=>g.curr!==null),n.sort((g,_)=>{if(g.curr.id.client===_.curr.id.client){const h=g.curr.id.clock-_.curr.id.clock;return h===0?g.curr.constructor===_.curr.constructor?0:g.curr.constructor===Rt?1:-1:h}else return _.curr.id.client-g.curr.id.client}),n.length!==0;){const f=n[0],c=f.curr.id.client;if(o!==null){let g=f.curr,_=!1;for(;g!==null&&g.id.clock+g.length<=o.struct.id.clock+o.struct.length&&g.id.client>=o.struct.id.client;)g=f.next(),_=!0;if(g===null||g.id.client!==c||_&&g.id.clock>o.struct.id.clock+o.struct.length)continue;if(c!==o.struct.id.client)Dn(l,o.struct,o.offset),o={struct:g,offset:0},f.next();else if(o.struct.id.clock+o.struct.length<g.id.clock)if(o.struct.constructor===Rt)o.struct.length=g.id.clock+g.length-o.struct.id.clock;else{Dn(l,o.struct,o.offset);const h=g.id.clock-o.struct.id.clock-o.struct.length;o={struct:new Rt(X(c,o.struct.id.clock+o.struct.length),h),offset:0}}else{const h=o.struct.id.clock+o.struct.length-g.id.clock;h>0&&(o.struct.constructor===Rt?o.struct.length-=h:g=Yv(g,h)),o.struct.mergeWith(g)||(Dn(l,o.struct,o.offset),o={struct:g,offset:0},f.next())}}else o={struct:f.curr,offset:0},f.next();for(let g=f.curr;g!==null&&g.id.client===c&&g.id.clock===o.struct.id.clock+o.struct.length&&g.constructor!==Rt;g=f.next())Dn(l,o.struct,o.offset),o={struct:g,offset:0}}o!==null&&(Dn(l,o.struct,o.offset),o=null),Xv(l);const u=a.map(f=>xv(f)),d=ru(u);return Id(r,d),r.toUint8Array()},pm=i=>{i.written>0&&(i.clientStructs.push({written:i.written,restEncoder:$t(i.encoder.restEncoder)}),i.encoder.restEncoder=Eo(),i.written=0)},Dn=(i,e,t)=>{i.written>0&&i.currClient!==e.id.client&&pm(i),i.written===0&&(i.currClient=e.id.client,i.encoder.writeClient(e.id.client),te(i.encoder.restEncoder,e.id.clock+t)),e.write(i.encoder,t),i.written++},Xv=i=>{pm(i);const e=i.encoder.restEncoder;te(e,i.clientStructs.length);for(let t=0;t<i.clientStructs.length;t++){const a=i.clientStructs[t];te(e,a.written),bs(e,a.restEncoder)}},rg="You must not compute changes after the event-handler fired.";class Bs{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||(this._path=Zv(this.currentTarget,this.target))}deletes(e){return bn(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ai(rg);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){const o=t._map.get(n);let r,l;if(this.adds(o)){let u=o.left;for(;u!==null&&this.adds(u);)u=u.left;if(this.deletes(o))if(u!==null&&this.deletes(u))r="delete",l=ul(u.content.getContent());else return;else u!==null&&this.deletes(u)?(r="update",l=ul(u.content.getContent())):(r="add",l=void 0)}else if(this.deletes(o))r="delete",l=ul(o.content.getContent());else return;e.set(n,{action:r,oldValue:l})}}),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 ai(rg);const t=this.target,a=Fa(),n=Fa(),o=[];if(e={added:a,deleted:n,delta:o,keys:this.keys},this.transaction.changed.get(t).has(null)){let l=null;const u=()=>{l&&o.push(l)};for(let d=t._start;d!==null;d=d.right)d.deleted?this.deletes(d)&&!this.adds(d)&&((l===null||l.delete===void 0)&&(u(),l={delete:0}),l.delete+=d.length,n.add(d)):this.adds(d)?((l===null||l.insert===void 0)&&(u(),l={insert:[]}),l.insert=l.insert.concat(d.content.getContent()),a.add(d)):((l===null||l.retain===void 0)&&(u(),l={retain:0}),l.retain+=d.length);l!==null&&l.retain===void 0&&u()}this._changes=e}return e}}const Zv=(i,e)=>{const t=[];for(;e._item!==null&&e!==i;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let a=0,n=e._item.parent._start;for(;n!==e._item&&n!==null;)!n.deleted&&n.countable&&(a+=n.length),n=n.right;t.unshift(a)}e=e._item.parent}return t},Le=()=>{om("Invalid access: Add Yjs type to a document before reading data.")},bm=80;let Ld=0;class Qv{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Ld++}}const eE=i=>{i.timestamp=Ld++},ym=(i,e,t)=>{i.p.marker=!1,i.p=e,e.marker=!0,i.index=t,i.timestamp=Ld++},tE=(i,e,t)=>{if(i.length>=bm){const a=i.reduce((n,o)=>n.timestamp<o.timestamp?n:o);return ym(a,e,t),a}else{const a=new Qv(e,t);return i.push(a),a}},Ss=(i,e)=>{if(i._start===null||e===0||i._searchMarker===null)return null;const t=i._searchMarker.length===0?null:i._searchMarker.reduce((o,r)=>ur(e-o.index)<ur(e-r.index)?o:r);let a=i._start,n=0;for(t!==null&&(a=t.p,n=t.index,eE(t));a.right!==null&&n<e;){if(!a.deleted&&a.countable){if(e<n+a.length)break;n+=a.length}a=a.right}for(;a.left!==null&&n>e;)a=a.left,!a.deleted&&a.countable&&(n-=a.length);for(;a.left!==null&&a.left.id.client===a.id.client&&a.left.id.clock+a.left.length===a.id.clock;)a=a.left,!a.deleted&&a.countable&&(n-=a.length);return t!==null&&ur(t.index-n)<a.parent.length/bm?(ym(t,a,n),t):tE(i._searchMarker,a,n)},ho=(i,e,t)=>{for(let a=i.length-1;a>=0;a--){const n=i[a];if(t>0){let o=n.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(n.index-=o.length);if(o===null||o.marker===!0){i.splice(a,1);continue}n.p=o,o.marker=!0}(e<n.index||t>0&&e===n.index)&&(n.index=Ii(e,n.index+t))}},js=(i,e,t)=>{const a=i,n=e.changedParentTypes;for(;bi(n,i,()=>[]).push(t),i._item!==null;)i=i._item.parent;fm(a._eH,t,e)};class Be{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Xc(),this._dEH=Xc(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Mt()}clone(){throw Mt()}_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){Zc(this._eH,e)}observeDeep(e){Zc(this._dEH,e)}unobserve(e){Qc(this._eH,e)}unobserveDeep(e){Qc(this._dEH,e)}toJSON(){}}const km=(i,e,t)=>{i.doc??Le(),e<0&&(e=i._length+e),t<0&&(t=i._length+t);let a=t-e;const n=[];let o=i._start;for(;o!==null&&a>0;){if(o.countable&&!o.deleted){const r=o.content.getContent();if(r.length<=e)e-=r.length;else{for(let l=e;l<r.length&&a>0;l++)n.push(r[l]),a--;e=0}}o=o.right}return n},wm=i=>{i.doc??Le();const e=[];let t=i._start;for(;t!==null;){if(t.countable&&!t.deleted){const a=t.content.getContent();for(let n=0;n<a.length;n++)e.push(a[n])}t=t.right}return e},Dm=(i,e)=>{const t=[];let a=i._start;for(;a!==null;){if(a.countable&&Xi(a,e)){const n=a.content.getContent();for(let o=0;o<n.length;o++)t.push(n[o])}a=a.right}return t},mo=(i,e)=>{let t=0,a=i._start;for(i.doc??Le();a!==null;){if(a.countable&&!a.deleted){const n=a.content.getContent();for(let o=0;o<n.length;o++)e(n[o],t++,i)}a=a.right}},vm=(i,e)=>{const t=[];return mo(i,(a,n)=>{t.push(e(a,n,i))}),t},iE=i=>{let e=i._start,t=null,a=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),a=0,e=e.right}const n=t[a++];return t.length<=a&&(t=null),{done:!1,value:n}}}},Em=(i,e)=>{i.doc??Le();const t=Ss(i,e);let a=i._start;for(t!==null&&(a=t.p,e-=t.index);a!==null;a=a.right)if(!a.deleted&&a.countable){if(e<a.length)return a.content.getContent()[e];e-=a.length}},Wr=(i,e,t,a)=>{let n=t;const o=i.doc,r=o.clientID,l=o.store,u=t===null?e._start:t.right;let d=[];const f=()=>{d.length>0&&(n=new ae(X(r,Fe(l,r)),n,n&&n.lastId,u,u&&u.id,e,null,new ya(d)),n.integrate(i,0),d=[])};a.forEach(c=>{if(c===null)d.push(c);else switch(c.constructor){case Number:case Object:case Boolean:case Array:case String:d.push(c);break;default:switch(f(),c.constructor){case Uint8Array:case ArrayBuffer:n=new ae(X(r,Fe(l,r)),n,n&&n.lastId,u,u&&u.id,e,null,new Co(new Uint8Array(c))),n.integrate(i,0);break;case va:n=new ae(X(r,Fe(l,r)),n,n&&n.lastId,u,u&&u.id,e,null,new Bo(c)),n.integrate(i,0);break;default:if(c instanceof Be)n=new ae(X(r,Fe(l,r)),n,n&&n.lastId,u,u&&u.id,e,null,new Jt(c)),n.integrate(i,0);else throw new Error("Unexpected content type in insert operation")}}}),f()},xm=()=>ai("Length exceeded!"),Cm=(i,e,t,a)=>{if(t>e._length)throw xm();if(t===0)return e._searchMarker&&ho(e._searchMarker,t,a.length),Wr(i,e,null,a);const n=t,o=Ss(e,t);let r=e._start;for(o!==null&&(r=o.p,t-=o.index,t===0&&(r=r.prev,t+=r&&r.countable&&!r.deleted?r.length:0));r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<=r.length){t<r.length&&nt(i,X(r.id.client,r.id.clock+t));break}t-=r.length}return e._searchMarker&&ho(e._searchMarker,n,a.length),Wr(i,e,r,a)},aE=(i,e,t)=>{let n=(e._searchMarker||[]).reduce((o,r)=>r.index>o.index?r:o,{index:0,p:e._start}).p;if(n)for(;n.right;)n=n.right;return Wr(i,e,n,t)},Bm=(i,e,t,a)=>{if(a===0)return;const n=t,o=a,r=Ss(e,t);let l=e._start;for(r!==null&&(l=r.p,t-=r.index);l!==null&&t>0;l=l.right)!l.deleted&&l.countable&&(t<l.length&&nt(i,X(l.id.client,l.id.clock+t)),t-=l.length);for(;a>0&&l!==null;)l.deleted||(a<l.length&&nt(i,X(l.id.client,l.id.clock+a)),l.delete(i),a-=l.length),l=l.right;if(a>0)throw xm();e._searchMarker&&ho(e._searchMarker,n,-o+a)},Ur=(i,e,t)=>{const a=e._map.get(t);a!==void 0&&a.delete(i)},zd=(i,e,t,a)=>{const n=e._map.get(t)||null,o=i.doc,r=o.clientID;let l;if(a==null)l=new ya([a]);else switch(a.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new ya([a]);break;case Uint8Array:l=new Co(a);break;case va:l=new Bo(a);break;default:if(a instanceof Be)l=new Jt(a);else throw new Error("Unexpected content type")}new ae(X(r,Fe(o.store,r)),n,n&&n.lastId,null,null,e,t,l).integrate(i,0)},Rd=(i,e)=>{i.doc??Le();const t=i._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},Sm=i=>{const e={};return i.doc??Le(),i._map.forEach((t,a)=>{t.deleted||(e[a]=t.content.getContent()[t.length-1])}),e},jm=(i,e)=>{i.doc??Le();const t=i._map.get(e);return t!==void 0&&!t.deleted},nE=(i,e)=>{const t={};return i._map.forEach((a,n)=>{let o=a;for(;o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0));)o=o.left;o!==null&&Xi(o,e)&&(t[n]=o.content.getContent()[o.length-1])}),t},Zo=i=>(i.doc??Le(),Dv(i._map.entries(),e=>!e[1].deleted));class oE extends Bs{}class Ka extends Be{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new Ka;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ka}clone(){const e=new Ka;return e.insert(0,this.toArray().map(t=>t instanceof Be?t.clone():t)),e}get length(){return this.doc??Le(),this._length}_callObserver(e,t){super._callObserver(e,t),js(this,e,new oE(this,e))}insert(e,t){this.doc!==null?ne(this.doc,a=>{Cm(a,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?ne(this.doc,t=>{aE(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?ne(this.doc,a=>{Bm(a,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return Em(this,e)}toArray(){return wm(this)}slice(e=0,t=this.length){return km(this,e,t)}toJSON(){return this.map(e=>e instanceof Be?e.toJSON():e)}map(e){return vm(this,e)}forEach(e){mo(this,e)}[Symbol.iterator](){return iE(this)}_write(e){e.writeTypeRef(jE)}}const rE=i=>new Ka;class sE extends Bs{constructor(e,t,a){super(e,t),this.keysChanged=a}}class dn extends Be{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((a,n)=>{this.set(n,a)}),this._prelimContent=null}_copy(){return new dn}clone(){const e=new dn;return this.forEach((t,a)=>{e.set(a,t instanceof Be?t.clone():t)}),e}_callObserver(e,t){js(this,e,new sE(this,e,t))}toJSON(){this.doc??Le();const e={};return this._map.forEach((t,a)=>{if(!t.deleted){const n=t.content.getContent()[t.length-1];e[a]=n instanceof Be?n.toJSON():n}}),e}get size(){return[...Zo(this)].length}keys(){return ml(Zo(this),e=>e[0])}values(){return ml(Zo(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return ml(Zo(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Le(),this._map.forEach((t,a)=>{t.deleted||e(t.content.getContent()[t.length-1],a,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?ne(this.doc,t=>{Ur(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?ne(this.doc,a=>{zd(a,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return Rd(this,e)}has(e){return jm(this,e)}clear(){this.doc!==null?ne(this.doc,e=>{this.forEach(function(t,a,n){Ur(e,n,a)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(qE)}}const lE=i=>new dn,Ai=(i,e)=>i===e||typeof i=="object"&&typeof e=="object"&&i&&e&&y9(i,e);class du{constructor(e,t,a,n){this.left=e,this.right=t,this.index=a,this.currentAttributes=n}forward(){this.right===null&&$e(),this.right.content.constructor===ye?this.right.deleted||yn(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const sg=(i,e,t)=>{for(;e.right!==null&&t>0;)e.right.content.constructor===ye?e.right.deleted||yn(e.currentAttributes,e.right.content):e.right.deleted||(t<e.right.length&&nt(i,X(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length),e.left=e.right,e.right=e.right.right;return e},Qo=(i,e,t,a)=>{const n=new Map,o=a?Ss(e,t):null;if(o){const r=new du(o.p.left,o.p,o.index,n);return sg(i,r,t-o.index)}else{const r=new du(null,e._start,0,n);return sg(i,r,t)}},qm=(i,e,t,a)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===ye&&Ai(a.get(t.right.content.key),t.right.content.value));)t.right.deleted||a.delete(t.right.content.key),t.forward();const n=i.doc,o=n.clientID;a.forEach((r,l)=>{const u=t.left,d=t.right,f=new ae(X(o,Fe(n.store,o)),u,u&&u.lastId,d,d&&d.id,e,null,new ye(l,r));f.integrate(i,0),t.right=f,t.forward()})},yn=(i,e)=>{const{key:t,value:a}=e;a===null?i.delete(t):i.set(t,a)},Am=(i,e)=>{for(;i.right!==null;){if(!(i.right.deleted||i.right.content.constructor===ye&&Ai(e[i.right.content.key]??null,i.right.content.value)))break;i.forward()}},Nm=(i,e,t,a)=>{const n=i.doc,o=n.clientID,r=new Map;for(const l in a){const u=a[l],d=t.currentAttributes.get(l)??null;if(!Ai(d,u)){r.set(l,d);const{left:f,right:c}=t;t.right=new ae(X(o,Fe(n.store,o)),f,f&&f.lastId,c,c&&c.id,e,null,new ye(l,u)),t.right.integrate(i,0),t.forward()}}return r},bl=(i,e,t,a,n)=>{t.currentAttributes.forEach((g,_)=>{n[_]===void 0&&(n[_]=null)});const o=i.doc,r=o.clientID;Am(t,n);const l=Nm(i,e,t,n),u=a.constructor===String?new Kt(a):a instanceof Be?new Jt(a):new Ea(a);let{left:d,right:f,index:c}=t;e._searchMarker&&ho(e._searchMarker,t.index,u.getLength()),f=new ae(X(r,Fe(o.store,r)),d,d&&d.lastId,f,f&&f.id,e,null,u),f.integrate(i,0),t.right=f,t.index=c,t.forward(),qm(i,e,t,l)},lg=(i,e,t,a,n)=>{const o=i.doc,r=o.clientID;Am(t,n);const l=Nm(i,e,t,n);e:for(;t.right!==null&&(a>0||l.size>0&&(t.right.deleted||t.right.content.constructor===ye));){if(!t.right.deleted)switch(t.right.content.constructor){case ye:{const{key:u,value:d}=t.right.content,f=n[u];if(f!==void 0){if(Ai(f,d))l.delete(u);else{if(a===0)break e;l.set(u,d)}t.right.delete(i)}else t.currentAttributes.set(u,d);break}default:a<t.right.length&&nt(i,X(t.right.id.client,t.right.id.clock+a)),a-=t.right.length;break}t.forward()}if(a>0){let u="";for(;a>0;a--)u+=`
134
+ ${t.toString()}`)};class ov{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:fo(e),h:t}),this}else(e){return this.if(Rr,e)}done(){return(e,t)=>{for(let a=0;a<this.patterns.length;a++){const n=this.patterns[a];if(n.if.check(e))return n.h(e,t)}throw ai("Unhandled pattern")}}}const rv=i=>new ov(i),Q1=rv(Rr).if(Y1,(i,e)=>_l(e,Pc,Vr)).if(X1,(i,e)=>N9(e)).if(iv,(i,e)=>Jc(e)).if(tv,(i,e)=>BigInt(_l(e,Pc,Vr))).if(zr,(i,e)=>Ma(e,hl(e,i.shape))).if(R9,(i,e)=>{const t={};for(const a in i.shape){let n=i.shape[a];if(P9.check(n)){if(Jc(e))continue;n=n.shape}t[a]=Q1(n,e)}return t}).if(U9,(i,e)=>{const t=[],a=I1(e,0,42);for(let n=0;n<a;n++)t.push(Ma(e,i.shape));return t}).if(P1,(i,e)=>hl(e,i.shape)).if(av,(i,e)=>null).if(X9,(i,e)=>{const t=Ma(e,i.res);return()=>t}).if(ev,(i,e)=>Ma(e,hl(e,[Ha,un,Es,Z1,Md,vs,U1(Ha),$1(Fn("a","b","c"),Ha)]))).if(H9,(i,e)=>{const t={},a=_l(e,0,3);for(let n=0;n<a;n++){const o=Ma(e,i.shape.keys),r=Ma(e,i.shape.values);t[o]=r}return t}).done(),Ma=(i,e)=>Q1(fo(e),i),xo=typeof document<"u"?document:{};Se(i=>i.nodeType===fv);typeof DOMParser<"u"&&new DOMParser;Se(i=>i.nodeType===lv);Se(i=>i.nodeType===uv);const sv=i=>xD(i,(e,t)=>`${t}:${e};`).join(""),lv=xo.ELEMENT_NODE,uv=xo.TEXT_NODE,dv=xo.DOCUMENT_NODE,fv=xo.DOCUMENT_FRAGMENT_NODE;Se(i=>i.nodeType===dv);const cv=i=>class{constructor(t){this._=t}destroy(){i(this._)}},gv=cv(clearTimeout),em=(i,e)=>new gv(setTimeout(e,i)),yi=Symbol,tm=yi(),im=yi(),_v=yi(),hv=yi(),mv=yi(),am=yi(),Fv=yi(),Td=yi(),pv=yi(),bv=i=>{i.length===1&&i[0]?.constructor===Function&&(i=i[0]());const e=[],t=[];let a=0;for(;a<i.length;a++){const n=i[a];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)e.push(n);else if(n.constructor===Object)break}for(a>0&&t.push(e.join(""));a<i.length;a++){const n=i[a];n instanceof Symbol||t.push(n)}return t},yv={[tm]:ri("font-weight","bold"),[im]:ri("font-weight","normal"),[_v]:ri("color","blue"),[mv]:ri("color","green"),[hv]:ri("color","grey"),[am]:ri("color","red"),[Fv]:ri("color","purple"),[Td]:ri("color","orange"),[pv]:ri("color","black")},kv=i=>{i.length===1&&i[0]?.constructor===Function&&(i=i[0]());const e=[],t=[],a=Ht();let n=[],o=0;for(;o<i.length;o++){const r=i[o],l=yv[r];if(l!==void 0)a.set(l.left,l.right);else{if(r===void 0)break;if(r.constructor===String||r.constructor===Number){const u=sv(a);o>0||u.length>0?(e.push("%c"+r),t.push(u)):e.push(r)}else break}}for(o>0&&(n=t,n.unshift(e.join("")));o<i.length;o++){const r=i[o];r instanceof Symbol||n.push(r)}return n},nm=x9?kv:bv,wv=(...i)=>{console.log(...nm(i)),rm.forEach(e=>e.print(i))},om=(...i)=>{console.warn(...nm(i)),i.unshift(Td),rm.forEach(e=>e.print(i))},rm=Fa(),sm=i=>({[Symbol.iterator](){return this},next:i}),Dv=(i,e)=>sm(()=>{let t;do t=i.next();while(!t.done&&!e(t.value));return t}),ml=(i,e)=>sm(()=>{const{done:t,value:a}=i.next();return{done:t,value:t?void 0:e(a)}});class Od{constructor(e,t){this.clock=e,this.len=t}}class pn{constructor(){this.clients=new Map}}const Pi=(i,e,t)=>e.clients.forEach((a,n)=>{const o=i.doc.store.clients.get(n);if(o!=null){const r=o[o.length-1],l=r.id.clock+r.length;for(let u=0,d=a[u];u<a.length&&d.clock<l;d=a[++u])hm(i,o,d.clock,d.len,t)}}),vv=(i,e)=>{let t=0,a=i.length-1;for(;t<=a;){const n=Wt((t+a)/2),o=i[n],r=o.clock;if(r<=e){if(e<r+o.len)return n;t=n+1}else a=n-1}return null},bn=(i,e)=>{const t=i.clients.get(e.client);return t!==void 0&&vv(t,e.clock)!==null},Vd=i=>{i.clients.forEach(e=>{e.sort((n,o)=>n.clock-o.clock);let t,a;for(t=1,a=1;t<e.length;t++){const n=e[a-1],o=e[t];n.clock+n.len>=o.clock?n.len=Ii(n.len,o.clock+o.len-n.clock):(a<t&&(e[a]=o),a++)}e.length=a})},ru=i=>{const e=new pn;for(let t=0;t<i.length;t++)i[t].clients.forEach((a,n)=>{if(!e.clients.has(n)){const o=a.slice();for(let r=t+1;r<i.length;r++)BD(o,i[r].clients.get(n)||[]);e.clients.set(n,o)}});return Vd(e),e},co=(i,e,t,a)=>{bi(i.clients,e,()=>[]).push(new Od(t,a))},lm=()=>new pn,Ev=i=>{const e=lm();return i.clients.forEach((t,a)=>{const n=[];for(let o=0;o<t.length;o++){const r=t[o];if(r.deleted){const l=r.id.clock;let u=r.length;if(o+1<t.length)for(let d=t[o+1];o+1<t.length&&d.deleted;d=t[++o+1])u+=d.length;n.push(new Od(l,u))}}n.length>0&&e.clients.set(a,n)}),e},Id=(i,e)=>{te(i.restEncoder,e.clients.size),pa(e.clients.entries()).sort((t,a)=>a[0]-t[0]).forEach(([t,a])=>{i.resetDsCurVal(),te(i.restEncoder,t);const n=a.length;te(i.restEncoder,n);for(let o=0;o<n;o++){const r=a[o];i.writeDsClock(r.clock),i.writeDsLen(r.len)}})},xv=i=>{const e=new pn,t=ue(i.restDecoder);for(let a=0;a<t;a++){i.resetDsCurVal();const n=ue(i.restDecoder),o=ue(i.restDecoder);if(o>0){const r=bi(e.clients,n,()=>[]);for(let l=0;l<o;l++)r.push(new Od(i.readDsClock(),i.readDsLen()))}}return e},Yc=(i,e,t)=>{const a=new pn,n=ue(i.restDecoder);for(let o=0;o<n;o++){i.resetDsCurVal();const r=ue(i.restDecoder),l=ue(i.restDecoder),u=t.clients.get(r)||[],d=Fe(t,r);for(let f=0;f<l;f++){const c=i.readDsClock(),g=c+i.readDsLen();if(c<d){d<g&&co(a,r,d,g-d);let _=Ut(u,c),h=u[_];for(!h.deleted&&h.id.clock<c&&(u.splice(_+1,0,Gr(e,h,c-h.id.clock)),_++);_<u.length&&(h=u[_++],h.id.clock<g);)h.deleted||(g<h.id.clock+h.length&&u.splice(_,0,Gr(e,h,g-h.id.clock)),h.delete(e))}else co(a,r,c,g-c)}}if(a.clients.size>0){const o=new xs;return te(o.restEncoder,0),Id(o,a),o.toUint8Array()}return null},um=q1;class va extends x1{constructor({guid:e=f9(),collectionid:t=null,gc:a=!0,gcFilter:n=()=>!0,meta:o=null,autoLoad:r=!1,shouldLoad:l=!0}={}){super(),this.gc=a,this.gcFilter=n,this.clientID=um(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new gm,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=r,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Uc(d=>{this.on("load",()=>{this.isLoaded=!0,d(this)})});const u=()=>Uc(d=>{const f=c=>{(c===void 0||c===!0)&&(this.off("sync",f),d())};this.on("sync",f)});this.on("sync",d=>{d===!1&&this.isSynced&&(this.whenSynced=u()),this.isSynced=d===void 0||d===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=u()}load(){const e=this._item;e!==null&&!this.shouldLoad&&ne(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(pa(this.subdocs).map(e=>e.guid))}transact(e,t=null){return ne(this,e,t)}get(e,t=Be){const a=bi(this.share,e,()=>{const o=new t;return o._integrate(this,null),o}),n=a.constructor;if(t!==Be&&n!==t)if(n===Be){const o=new t;o._map=a._map,a._map.forEach(r=>{for(;r!==null;r=r.left)r.parent=o}),o._start=a._start;for(let r=o._start;r!==null;r=r.right)r.parent=o;return o._length=a._length,this.share.set(e,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return a}getArray(e=""){return this.get(e,Ka)}getText(e=""){return this.get(e,Li)}getMap(e=""){return this.get(e,dn)}getXmlElement(e=""){return this.get(e,Pe)}getXmlFragment(e=""){return this.get(e,ba)}toJSON(){const e={};return this.share.forEach((t,a)=>{e[a]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,pa(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new va({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,ne(e.parent.doc,a=>{const n=t.doc;e.deleted||a.subdocsAdded.add(n),a.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Cv{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=ue(this.restDecoder),this.dsCurrVal}readDsLen(){const e=ue(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class $r extends Cv{constructor(e){super(e),this.keys=[],ue(e),this.keyClockDecoder=new gl(xt(e)),this.clientDecoder=new fr(xt(e)),this.leftClockDecoder=new gl(xt(e)),this.rightClockDecoder=new gl(xt(e)),this.infoDecoder=new Wc(xt(e),lo),this.stringDecoder=new r9(xt(e)),this.parentInfoDecoder=new Wc(xt(e),lo),this.typeRefDecoder=new fr(xt(e)),this.lenDecoder=new fr(xt(e))}readLeftID(){return new Wa(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Wa(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 Ir(this.restDecoder)}readBuf(){return xt(this.restDecoder)}readJSON(){return Ir(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class Bv{constructor(){this.restEncoder=Eo()}toUint8Array(){return $t(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){te(this.restEncoder,e)}writeDsLen(e){te(this.restEncoder,e)}}class Sv extends Bv{writeLeftID(e){te(this.restEncoder,e.client),te(this.restEncoder,e.clock)}writeRightID(e){te(this.restEncoder,e.client),te(this.restEncoder,e.clock)}writeClient(e){te(this.restEncoder,e)}writeInfo(e){tu(this.restEncoder,e)}writeString(e){$a(this.restEncoder,e)}writeParentInfo(e){te(this.restEncoder,e?1:0)}writeTypeRef(e){te(this.restEncoder,e)}writeLen(e){te(this.restEncoder,e)}writeAny(e){sn(this.restEncoder,e)}writeBuf(e){pt(this.restEncoder,e)}writeJSON(e){$a(this.restEncoder,JSON.stringify(e))}writeKey(e){$a(this.restEncoder,e)}}class jv{constructor(){this.restEncoder=Eo(),this.dsCurrVal=0}toUint8Array(){return $t(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,te(this.restEncoder,t)}writeDsLen(e){e===0&&$e(),te(this.restEncoder,e-1),this.dsCurrVal+=e}}class xs extends jv{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new cl,this.clientEncoder=new dr,this.leftClockEncoder=new cl,this.rightClockEncoder=new cl,this.infoEncoder=new Rc(tu),this.stringEncoder=new XD,this.parentInfoEncoder=new Rc(tu),this.typeRefEncoder=new dr,this.lenEncoder=new dr}toUint8Array(){const e=Eo();return te(e,0),pt(e,this.keyClockEncoder.toUint8Array()),pt(e,this.clientEncoder.toUint8Array()),pt(e,this.leftClockEncoder.toUint8Array()),pt(e,this.rightClockEncoder.toUint8Array()),pt(e,$t(this.infoEncoder)),pt(e,this.stringEncoder.toUint8Array()),pt(e,$t(this.parentInfoEncoder)),pt(e,this.typeRefEncoder.toUint8Array()),pt(e,this.lenEncoder.toUint8Array()),bs(e,$t(this.restEncoder)),$t(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?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){sn(this.restEncoder,e)}writeBuf(e){pt(this.restEncoder,e)}writeJSON(e){sn(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const qv=(i,e,t,a)=>{a=Ii(a,e[0].id.clock);const n=Ut(e,a);te(i.restEncoder,e.length-n),i.writeClient(t),te(i.restEncoder,a);const o=e[n];o.write(i,a-o.id.clock);for(let r=n+1;r<e.length;r++)e[r].write(i,0)},dm=(i,e,t)=>{const a=new Map;t.forEach((n,o)=>{Fe(e,o)>n&&a.set(o,n)}),Cs(e).forEach((n,o)=>{t.has(o)||a.set(o,0)}),te(i.restEncoder,a.size),pa(a.entries()).sort((n,o)=>o[0]-n[0]).forEach(([n,o])=>{qv(i,e.clients.get(n),n,o)})},Av=(i,e)=>{const t=Ht(),a=ue(i.restDecoder);for(let n=0;n<a;n++){const o=ue(i.restDecoder),r=new Array(o),l=i.readClient();let u=ue(i.restDecoder);t.set(l,{i:0,refs:r});for(let d=0;d<o;d++){const f=i.readInfo();switch(ps&f){case 0:{const c=i.readLen();r[d]=new jt(X(l,u),c),u+=c;break}case 10:{const c=ue(i.restDecoder);r[d]=new Rt(X(l,u),c),u+=c;break}default:{const c=(f&(gi|Ze))===0,g=new ae(X(l,u),null,(f&Ze)===Ze?i.readLeftID():null,null,(f&gi)===gi?i.readRightID():null,c?i.readParentInfo()?e.get(i.readString()):i.readLeftID():null,c&&(f&ro)===ro?i.readString():null,Vm(i,f));r[d]=g,u+=g.length}}}}return t},Nv=(i,e,t)=>{const a=[];let n=pa(t.keys()).sort((_,h)=>_-h);if(n.length===0)return null;const o=()=>{if(n.length===0)return null;let _=t.get(n[n.length-1]);for(;_.refs.length===_.i;)if(n.pop(),n.length>0)_=t.get(n[n.length-1]);else return null;return _};let r=o();if(r===null)return null;const l=new gm,u=new Map,d=(_,h)=>{const F=u.get(_);(F==null||F>h)&&u.set(_,h)};let f=r.refs[r.i++];const c=new Map,g=()=>{for(const _ of a){const h=_.id.client,F=t.get(h);F?(F.i--,l.clients.set(h,F.refs.slice(F.i)),t.delete(h),F.i=0,F.refs=[]):l.clients.set(h,[_]),n=n.filter(m=>m!==h)}a.length=0};for(;;){if(f.constructor!==Rt){const h=bi(c,f.id.client,()=>Fe(e,f.id.client))-f.id.clock;if(h<0)a.push(f),d(f.id.client,f.id.clock-1),g();else{const F=f.getMissing(i,e);if(F!==null){a.push(f);const m=t.get(F)||{refs:[],i:0};if(m.refs.length===m.i)d(F,Fe(e,F)),g();else{f=m.refs[m.i++];continue}}else(h===0||h<f.length)&&(f.integrate(i,h),c.set(f.id.client,f.id.clock+f.length))}}if(a.length>0)f=a.pop();else if(r!==null&&r.i<r.refs.length)f=r.refs[r.i++];else{if(r=o(),r===null)break;f=r.refs[r.i++]}}if(l.clients.size>0){const _=new xs;return dm(_,l,new Map),te(_.restEncoder,0),{missing:u,update:_.toUint8Array()}}return null},Mv=(i,e)=>dm(i,e.doc.store,e.beforeState),Tv=(i,e,t,a=new $r(i))=>ne(e,n=>{n.local=!1;let o=!1;const r=n.doc,l=r.store,u=Av(a,r),d=Nv(n,l,u),f=l.pendingStructs;if(f){for(const[g,_]of f.missing)if(_<Fe(l,g)){o=!0;break}if(d){for(const[g,_]of d.missing){const h=f.missing.get(g);(h==null||h>_)&&f.missing.set(g,_)}f.update=og([f.update,d.update])}}else l.pendingStructs=d;const c=Yc(a,n,l);if(l.pendingDs){const g=new $r(Ed(l.pendingDs));ue(g.restDecoder);const _=Yc(g,n,l);c&&_?l.pendingDs=og([c,_]):l.pendingDs=c||_}else l.pendingDs=c;if(o){const g=l.pendingStructs.update;l.pendingStructs=null,su(n.doc,g)}},t,!1),su=(i,e,t,a=$r)=>{const n=Ed(e);Tv(n,i,t,new a(n))};class Ov{constructor(){this.l=[]}}const Xc=()=>new Ov,Zc=(i,e)=>i.l.push(e),Qc=(i,e)=>{const t=i.l,a=t.length;i.l=t.filter(n=>e!==n),a===i.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},fm=(i,e,t)=>Sd(i.l,[e,t]);class Wa{constructor(e,t){this.client=e,this.clock=t}}const Yo=(i,e)=>i===e||i!==null&&e!==null&&i.client===e.client&&i.clock===e.clock,X=(i,e)=>new Wa(i,e),go=i=>{for(const[e,t]of i.doc.share.entries())if(t===i)return e;throw $e()},_o=(i,e)=>{for(;e!==null;){if(e.parent===i)return!0;e=e.parent._item}return!1};class Hr{constructor(e,t,a,n=0){this.type=e,this.tname=t,this.item=a,this.assoc=n}}class Vv{constructor(e,t,a=0){this.type=e,this.index=t,this.assoc=a}}const Iv=(i,e,t=0)=>new Vv(i,e,t),Xo=(i,e,t)=>{let a=null,n=null;return i._item===null?n=go(i):a=X(i._item.id.client,i._item.id.clock),new Hr(a,n,e,t)},Fl=(i,e,t=0)=>{let a=i._start;if(t<0){if(e===0)return Xo(i,null,t);e--}for(;a!==null;){if(!a.deleted&&a.countable){if(a.length>e)return Xo(i,X(a.id.client,a.id.clock+e),t);e-=a.length}if(a.right===null&&t<0)return Xo(i,a.lastId,t);a=a.right}return Xo(i,null,t)},Pv=(i,e)=>{const t=Ua(i,e),a=e.clock-t.id.clock;return{item:t,diff:a}},Lv=(i,e,t=!0)=>{const a=e.store,n=i.item,o=i.type,r=i.tname,l=i.assoc;let u=null,d=0;if(n!==null){if(Fe(a,n.client)<=n.clock)return null;const f=t?fu(a,n):Pv(a,n),c=f.item;if(!(c instanceof ae))return null;if(u=c.parent,u._item===null||!u._item.deleted){d=c.deleted||!c.countable?0:f.diff+(l>=0?0:1);let g=c.left;for(;g!==null;)!g.deleted&&g.countable&&(d+=g.length),g=g.left}}else{if(r!==null)u=e.get(r);else if(o!==null){if(Fe(a,o.client)<=o.clock)return null;const{item:f}=t?fu(a,o):{item:Ua(a,o)};if(f instanceof ae&&f.content instanceof Jt)u=f.content.type;else return null}else throw $e();l>=0?d=u._length:d=0}return Iv(u,d,i.assoc)};class Pd{constructor(e,t){this.ds=e,this.sv=t}}const cm=(i,e)=>new Pd(i,e),pl=i=>cm(Ev(i.store),Cs(i.store)),Xi=(i,e)=>e===void 0?!i.deleted:e.sv.has(i.id.client)&&(e.sv.get(i.id.client)||0)>i.id.clock&&!bn(e.ds,i.id),lu=(i,e)=>{const t=bi(i.meta,lu,Fa),a=i.doc.store;t.has(e)||(e.sv.forEach((n,o)=>{n<Fe(a,o)&&nt(i,X(o,n))}),Pi(i,e.ds,n=>{}),t.add(e))};class gm{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Cs=i=>{const e=new Map;return i.clients.forEach((t,a)=>{const n=t[t.length-1];e.set(a,n.id.clock+n.length)}),e},Fe=(i,e)=>{const t=i.clients.get(e);if(t===void 0)return 0;const a=t[t.length-1];return a.id.clock+a.length},_m=(i,e)=>{let t=i.clients.get(e.id.client);if(t===void 0)t=[],i.clients.set(e.id.client,t);else{const a=t[t.length-1];if(a.id.clock+a.length!==e.id.clock)throw $e()}t.push(e)},Ut=(i,e)=>{let t=0,a=i.length-1,n=i[a],o=n.id.clock;if(o===e)return a;let r=Wt(e/(o+n.length-1)*a);for(;t<=a;){if(n=i[r],o=n.id.clock,o<=e){if(e<o+n.length)return r;t=r+1}else a=r-1;r=Wt((t+a)/2)}throw $e()},zv=(i,e)=>{const t=i.clients.get(e.client);return t[Ut(t,e.clock)]},Ua=zv,uu=(i,e,t)=>{const a=Ut(e,t),n=e[a];return n.id.clock<t&&n instanceof ae?(e.splice(a+1,0,Gr(i,n,t-n.id.clock)),a+1):a},nt=(i,e)=>{const t=i.doc.store.clients.get(e.client);return t[uu(i,t,e.clock)]},eg=(i,e,t)=>{const a=e.clients.get(t.client),n=Ut(a,t.clock),o=a[n];return t.clock!==o.id.clock+o.length-1&&o.constructor!==jt&&a.splice(n+1,0,Gr(i,o,t.clock-o.id.clock+1)),o},Rv=(i,e,t)=>{const a=i.clients.get(e.id.client);a[Ut(a,e.id.clock)]=t},hm=(i,e,t,a,n)=>{if(a===0)return;const o=t+a;let r=uu(i,e,t),l;do l=e[r++],o<l.id.clock+l.length&&uu(i,e,o),n(l);while(r<e.length&&e[r].id.clock<o)};class $v{constructor(e,t,a){this.doc=e,this.deleteSet=new pn,this.beforeState=Cs(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=a,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const tg=(i,e)=>e.deleteSet.clients.size===0&&!CD(e.afterState,(t,a)=>e.beforeState.get(a)!==t)?!1:(Vd(e.deleteSet),Mv(i,e),Id(i,e.deleteSet),!0),ig=(i,e,t)=>{const a=e._item;(a===null||a.id.clock<(i.beforeState.get(a.id.client)||0)&&!a.deleted)&&bi(i.changed,e,Fa).add(t)},gr=(i,e)=>{let t=i[e],a=i[e-1],n=e;for(;n>0;t=a,a=i[--n-1]){if(a.deleted===t.deleted&&a.constructor===t.constructor&&a.mergeWith(t)){t instanceof ae&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,a);continue}break}const o=e-n;return o&&i.splice(e+1-o,o),o},Hv=(i,e,t)=>{for(const[a,n]of i.clients.entries()){const o=e.clients.get(a);for(let r=n.length-1;r>=0;r--){const l=n[r],u=l.clock+l.len;for(let d=Ut(o,l.clock),f=o[d];d<o.length&&f.id.clock<u;f=o[++d]){const c=o[d];if(l.clock+l.len<=c.id.clock)break;c instanceof ae&&c.deleted&&!c.keep&&t(c)&&c.gc(e,!1)}}}},Wv=(i,e)=>{i.clients.forEach((t,a)=>{const n=e.clients.get(a);for(let o=t.length-1;o>=0;o--){const r=t[o],l=rn(n.length-1,1+Ut(n,r.clock+r.len-1));for(let u=l,d=n[u];u>0&&d.id.clock>=r.clock;d=n[u])u-=1+gr(n,u)}})},mm=(i,e)=>{if(e<i.length){const t=i[e],a=t.doc,n=a.store,o=t.deleteSet,r=t._mergeStructs;try{Vd(o),t.afterState=Cs(t.doc.store),a.emit("beforeObserverCalls",[t,a]);const l=[];t.changed.forEach((u,d)=>l.push(()=>{(d._item===null||!d._item.deleted)&&d._callObserver(t,u)})),l.push(()=>{t.changedParentTypes.forEach((u,d)=>{d._dEH.l.length>0&&(d._item===null||!d._item.deleted)&&(u=u.filter(f=>f.target._item===null||!f.target._item.deleted),u.forEach(f=>{f.currentTarget=d,f._path=null}),u.sort((f,c)=>f.path.length-c.path.length),l.push(()=>{fm(d._dEH,u,t)}))}),l.push(()=>a.emit("afterTransaction",[t,a])),l.push(()=>{t._needFormattingCleanup&&fE(t)})}),Sd(l,[])}finally{a.gc&&Hv(o,n,a.gcFilter),Wv(o,n),t.afterState.forEach((f,c)=>{const g=t.beforeState.get(c)||0;if(g!==f){const _=n.clients.get(c),h=Ii(Ut(_,g),1);for(let F=_.length-1;F>=h;)F-=1+gr(_,F)}});for(let f=r.length-1;f>=0;f--){const{client:c,clock:g}=r[f].id,_=n.clients.get(c),h=Ut(_,g);h+1<_.length&&gr(_,h+1)>1||h>0&&gr(_,h)}if(!t.local&&t.afterState.get(a.clientID)!==t.beforeState.get(a.clientID)&&(wv(Td,tm,"[yjs] ",im,am,"Changed the client-id because another client seems to be using it."),a.clientID=um()),a.emit("afterTransactionCleanup",[t,a]),a._observers.has("update")){const f=new Sv;tg(f,t)&&a.emit("update",[f.toUint8Array(),t.origin,a,t])}if(a._observers.has("updateV2")){const f=new xs;tg(f,t)&&a.emit("updateV2",[f.toUint8Array(),t.origin,a,t])}const{subdocsAdded:l,subdocsLoaded:u,subdocsRemoved:d}=t;(l.size>0||d.size>0||u.size>0)&&(l.forEach(f=>{f.clientID=a.clientID,f.collectionid==null&&(f.collectionid=a.collectionid),a.subdocs.add(f)}),d.forEach(f=>a.subdocs.delete(f)),a.emit("subdocs",[{loaded:u,added:l,removed:d},a,t]),d.forEach(f=>f.destroy())),i.length<=e+1?(a._transactionCleanups=[],a.emit("afterAllTransactions",[a,i])):mm(i,e+1)}}},ne=(i,e,t=null,a=!0)=>{const n=i._transactionCleanups;let o=!1,r=null;i._transaction===null&&(o=!0,i._transaction=new $v(i,t,a),n.push(i._transaction),n.length===1&&i.emit("beforeAllTransactions",[i]),i.emit("beforeTransaction",[i._transaction,i]));try{r=e(i._transaction)}finally{if(o){const l=i._transaction===n[0];i._transaction=null,l&&mm(n,0)}}return r};class Uv{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const ag=(i,e,t)=>{Pi(i,t.deletions,a=>{a instanceof ae&&e.scope.some(n=>n===i.doc||_o(n,a))&&Hd(a,!1)})},ng=(i,e,t)=>{let a=null;const n=i.doc,o=i.scope;ne(n,l=>{for(;e.length>0&&i.currStackItem===null;){const u=n.store,d=e.pop(),f=new Set,c=[];let g=!1;Pi(l,d.insertions,_=>{if(_ instanceof ae){if(_.redone!==null){let{item:h,diff:F}=fu(u,_.id);F>0&&(h=nt(l,X(h.id.client,h.id.clock+F))),_=h}!_.deleted&&o.some(h=>h===l.doc||_o(h,_))&&c.push(_)}}),Pi(l,d.deletions,_=>{_ instanceof ae&&o.some(h=>h===l.doc||_o(h,_))&&!bn(d.insertions,_.id)&&f.add(_)}),f.forEach(_=>{g=Om(l,_,f,d.insertions,i.ignoreRemoteMapChanges,i)!==null||g});for(let _=c.length-1;_>=0;_--){const h=c[_];i.deleteFilter(h)&&(h.delete(l),g=!0)}i.currStackItem=g?d:null}l.changed.forEach((u,d)=>{u.has(null)&&d._searchMarker&&(d._searchMarker.length=0)}),a=l},i);const r=i.currStackItem;if(r!=null){const l=a.changedParentTypes;i.emit("stack-item-popped",[{stackItem:r,type:t,changedParentTypes:l,origin:i},i]),i.currStackItem=null}return r};class Fm extends x1{constructor(e,{captureTimeout:t=500,captureTransaction:a=u=>!0,deleteFilter:n=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:r=!1,doc:l=on(e)?e[0].doc:e instanceof va?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=n,o.add(this),this.trackedOrigins=o,this.captureTransaction=a,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=r,this.captureTimeout=t,this.afterTransactionHandler=u=>{if(!this.captureTransaction(u)||!this.scope.some(m=>u.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(u.origin)&&(!u.origin||!this.trackedOrigins.has(u.origin.constructor)))return;const d=this.undoing,f=this.redoing,c=d?this.redoStack:this.undoStack;d?this.stopCapturing():f||this.clear(!1,!0);const g=new pn;u.afterState.forEach((m,p)=>{const y=u.beforeState.get(p)||0,k=m-y;k>0&&co(g,p,y,k)});const _=c9();let h=!1;if(this.lastChange>0&&_-this.lastChange<this.captureTimeout&&c.length>0&&!d&&!f){const m=c[c.length-1];m.deletions=ru([m.deletions,u.deleteSet]),m.insertions=ru([m.insertions,g])}else c.push(new Uv(u.deleteSet,g)),h=!0;!d&&!f&&(this.lastChange=_),Pi(u,u.deleteSet,m=>{m instanceof ae&&this.scope.some(p=>p===u.doc||_o(p,m))&&Hd(m,!0)});const F=[{stackItem:c[c.length-1],origin:u.origin,type:d?"redo":"undo",changedParentTypes:u.changedParentTypes},this];h?this.emit("stack-item-added",F):this.emit("stack-item-updated",F)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const t=new Set(this.scope);e=on(e)?e:[e],e.forEach(a=>{t.has(a)||(t.add(a),(a instanceof Be?a.doc!==this.doc:a!==this.doc)&&om("[yjs#509] Not same Y.Doc"),this.scope.push(a))})}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(a=>{e&&(this.undoStack.forEach(n=>ag(a,this,n)),this.undoStack=[]),t&&(this.redoStack.forEach(n=>ag(a,this,n)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=ng(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=ng(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*Kv(i){const e=ue(i.restDecoder);for(let t=0;t<e;t++){const a=ue(i.restDecoder),n=i.readClient();let o=ue(i.restDecoder);for(let r=0;r<a;r++){const l=i.readInfo();if(l===10){const u=ue(i.restDecoder);yield new Rt(X(n,o),u),o+=u}else if((ps&l)!==0){const u=(l&(gi|Ze))===0,d=new ae(X(n,o),null,(l&Ze)===Ze?i.readLeftID():null,null,(l&gi)===gi?i.readRightID():null,u?i.readParentInfo()?i.readString():i.readLeftID():null,u&&(l&ro)===ro?i.readString():null,Vm(i,l));yield d,o+=d.length}else{const u=i.readLen();yield new jt(X(n,o),u),o+=u}}}}class Jv{constructor(e,t){this.gen=Kv(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===Rt);return this.curr}}class Gv{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Yv=(i,e)=>{if(i.constructor===jt){const{client:t,clock:a}=i.id;return new jt(X(t,a+e),i.length-e)}else if(i.constructor===Rt){const{client:t,clock:a}=i.id;return new Rt(X(t,a+e),i.length-e)}else{const t=i,{client:a,clock:n}=t.id;return new ae(X(a,n+e),null,X(a,n+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},og=(i,e=$r,t=xs)=>{if(i.length===1)return i[0];const a=i.map(f=>new e(Ed(f)));let n=a.map(f=>new Jv(f,!0)),o=null;const r=new t,l=new Gv(r);for(;n=n.filter(g=>g.curr!==null),n.sort((g,_)=>{if(g.curr.id.client===_.curr.id.client){const h=g.curr.id.clock-_.curr.id.clock;return h===0?g.curr.constructor===_.curr.constructor?0:g.curr.constructor===Rt?1:-1:h}else return _.curr.id.client-g.curr.id.client}),n.length!==0;){const f=n[0],c=f.curr.id.client;if(o!==null){let g=f.curr,_=!1;for(;g!==null&&g.id.clock+g.length<=o.struct.id.clock+o.struct.length&&g.id.client>=o.struct.id.client;)g=f.next(),_=!0;if(g===null||g.id.client!==c||_&&g.id.clock>o.struct.id.clock+o.struct.length)continue;if(c!==o.struct.id.client)Dn(l,o.struct,o.offset),o={struct:g,offset:0},f.next();else if(o.struct.id.clock+o.struct.length<g.id.clock)if(o.struct.constructor===Rt)o.struct.length=g.id.clock+g.length-o.struct.id.clock;else{Dn(l,o.struct,o.offset);const h=g.id.clock-o.struct.id.clock-o.struct.length;o={struct:new Rt(X(c,o.struct.id.clock+o.struct.length),h),offset:0}}else{const h=o.struct.id.clock+o.struct.length-g.id.clock;h>0&&(o.struct.constructor===Rt?o.struct.length-=h:g=Yv(g,h)),o.struct.mergeWith(g)||(Dn(l,o.struct,o.offset),o={struct:g,offset:0},f.next())}}else o={struct:f.curr,offset:0},f.next();for(let g=f.curr;g!==null&&g.id.client===c&&g.id.clock===o.struct.id.clock+o.struct.length&&g.constructor!==Rt;g=f.next())Dn(l,o.struct,o.offset),o={struct:g,offset:0}}o!==null&&(Dn(l,o.struct,o.offset),o=null),Xv(l);const u=a.map(f=>xv(f)),d=ru(u);return Id(r,d),r.toUint8Array()},pm=i=>{i.written>0&&(i.clientStructs.push({written:i.written,restEncoder:$t(i.encoder.restEncoder)}),i.encoder.restEncoder=Eo(),i.written=0)},Dn=(i,e,t)=>{i.written>0&&i.currClient!==e.id.client&&pm(i),i.written===0&&(i.currClient=e.id.client,i.encoder.writeClient(e.id.client),te(i.encoder.restEncoder,e.id.clock+t)),e.write(i.encoder,t),i.written++},Xv=i=>{pm(i);const e=i.encoder.restEncoder;te(e,i.clientStructs.length);for(let t=0;t<i.clientStructs.length;t++){const a=i.clientStructs[t];te(e,a.written),bs(e,a.restEncoder)}},rg="You must not compute changes after the event-handler fired.";class Bs{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||(this._path=Zv(this.currentTarget,this.target))}deletes(e){return bn(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ai(rg);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){const o=t._map.get(n);let r,l;if(this.adds(o)){let u=o.left;for(;u!==null&&this.adds(u);)u=u.left;if(this.deletes(o))if(u!==null&&this.deletes(u))r="delete",l=ul(u.content.getContent());else return;else u!==null&&this.deletes(u)?(r="update",l=ul(u.content.getContent())):(r="add",l=void 0)}else if(this.deletes(o))r="delete",l=ul(o.content.getContent());else return;e.set(n,{action:r,oldValue:l})}}),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 ai(rg);const t=this.target,a=Fa(),n=Fa(),o=[];if(e={added:a,deleted:n,delta:o,keys:this.keys},this.transaction.changed.get(t).has(null)){let l=null;const u=()=>{l&&o.push(l)};for(let d=t._start;d!==null;d=d.right)d.deleted?this.deletes(d)&&!this.adds(d)&&((l===null||l.delete===void 0)&&(u(),l={delete:0}),l.delete+=d.length,n.add(d)):this.adds(d)?((l===null||l.insert===void 0)&&(u(),l={insert:[]}),l.insert=l.insert.concat(d.content.getContent()),a.add(d)):((l===null||l.retain===void 0)&&(u(),l={retain:0}),l.retain+=d.length);l!==null&&l.retain===void 0&&u()}this._changes=e}return e}}const Zv=(i,e)=>{const t=[];for(;e._item!==null&&e!==i;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let a=0,n=e._item.parent._start;for(;n!==e._item&&n!==null;)!n.deleted&&n.countable&&(a+=n.length),n=n.right;t.unshift(a)}e=e._item.parent}return t},Le=()=>{om("Invalid access: Add Yjs type to a document before reading data.")},bm=80;let Ld=0;class Qv{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Ld++}}const eE=i=>{i.timestamp=Ld++},ym=(i,e,t)=>{i.p.marker=!1,i.p=e,e.marker=!0,i.index=t,i.timestamp=Ld++},tE=(i,e,t)=>{if(i.length>=bm){const a=i.reduce((n,o)=>n.timestamp<o.timestamp?n:o);return ym(a,e,t),a}else{const a=new Qv(e,t);return i.push(a),a}},Ss=(i,e)=>{if(i._start===null||e===0||i._searchMarker===null)return null;const t=i._searchMarker.length===0?null:i._searchMarker.reduce((o,r)=>ur(e-o.index)<ur(e-r.index)?o:r);let a=i._start,n=0;for(t!==null&&(a=t.p,n=t.index,eE(t));a.right!==null&&n<e;){if(!a.deleted&&a.countable){if(e<n+a.length)break;n+=a.length}a=a.right}for(;a.left!==null&&n>e;)a=a.left,!a.deleted&&a.countable&&(n-=a.length);for(;a.left!==null&&a.left.id.client===a.id.client&&a.left.id.clock+a.left.length===a.id.clock;)a=a.left,!a.deleted&&a.countable&&(n-=a.length);return t!==null&&ur(t.index-n)<a.parent.length/bm?(ym(t,a,n),t):tE(i._searchMarker,a,n)},ho=(i,e,t)=>{for(let a=i.length-1;a>=0;a--){const n=i[a];if(t>0){let o=n.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(n.index-=o.length);if(o===null||o.marker===!0){i.splice(a,1);continue}n.p=o,o.marker=!0}(e<n.index||t>0&&e===n.index)&&(n.index=Ii(e,n.index+t))}},js=(i,e,t)=>{const a=i,n=e.changedParentTypes;for(;bi(n,i,()=>[]).push(t),i._item!==null;)i=i._item.parent;fm(a._eH,t,e)};class Be{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Xc(),this._dEH=Xc(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Mt()}clone(){throw Mt()}_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){Zc(this._eH,e)}observeDeep(e){Zc(this._dEH,e)}unobserve(e){Qc(this._eH,e)}unobserveDeep(e){Qc(this._dEH,e)}toJSON(){}}const km=(i,e,t)=>{i.doc??Le(),e<0&&(e=i._length+e),t<0&&(t=i._length+t);let a=t-e;const n=[];let o=i._start;for(;o!==null&&a>0;){if(o.countable&&!o.deleted){const r=o.content.getContent();if(r.length<=e)e-=r.length;else{for(let l=e;l<r.length&&a>0;l++)n.push(r[l]),a--;e=0}}o=o.right}return n},wm=i=>{i.doc??Le();const e=[];let t=i._start;for(;t!==null;){if(t.countable&&!t.deleted){const a=t.content.getContent();for(let n=0;n<a.length;n++)e.push(a[n])}t=t.right}return e},Dm=(i,e)=>{const t=[];let a=i._start;for(;a!==null;){if(a.countable&&Xi(a,e)){const n=a.content.getContent();for(let o=0;o<n.length;o++)t.push(n[o])}a=a.right}return t},mo=(i,e)=>{let t=0,a=i._start;for(i.doc??Le();a!==null;){if(a.countable&&!a.deleted){const n=a.content.getContent();for(let o=0;o<n.length;o++)e(n[o],t++,i)}a=a.right}},vm=(i,e)=>{const t=[];return mo(i,(a,n)=>{t.push(e(a,n,i))}),t},iE=i=>{let e=i._start,t=null,a=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),a=0,e=e.right}const n=t[a++];return t.length<=a&&(t=null),{done:!1,value:n}}}},Em=(i,e)=>{i.doc??Le();const t=Ss(i,e);let a=i._start;for(t!==null&&(a=t.p,e-=t.index);a!==null;a=a.right)if(!a.deleted&&a.countable){if(e<a.length)return a.content.getContent()[e];e-=a.length}},Wr=(i,e,t,a)=>{let n=t;const o=i.doc,r=o.clientID,l=o.store,u=t===null?e._start:t.right;let d=[];const f=()=>{d.length>0&&(n=new ae(X(r,Fe(l,r)),n,n&&n.lastId,u,u&&u.id,e,null,new ya(d)),n.integrate(i,0),d=[])};a.forEach(c=>{if(c===null)d.push(c);else switch(c.constructor){case Number:case Object:case Boolean:case Array:case String:d.push(c);break;default:switch(f(),c.constructor){case Uint8Array:case ArrayBuffer:n=new ae(X(r,Fe(l,r)),n,n&&n.lastId,u,u&&u.id,e,null,new Co(new Uint8Array(c))),n.integrate(i,0);break;case va:n=new ae(X(r,Fe(l,r)),n,n&&n.lastId,u,u&&u.id,e,null,new Bo(c)),n.integrate(i,0);break;default:if(c instanceof Be)n=new ae(X(r,Fe(l,r)),n,n&&n.lastId,u,u&&u.id,e,null,new Jt(c)),n.integrate(i,0);else throw new Error("Unexpected content type in insert operation")}}}),f()},xm=()=>ai("Length exceeded!"),Cm=(i,e,t,a)=>{if(t>e._length)throw xm();if(t===0)return e._searchMarker&&ho(e._searchMarker,t,a.length),Wr(i,e,null,a);const n=t,o=Ss(e,t);let r=e._start;for(o!==null&&(r=o.p,t-=o.index,t===0&&(r=r.prev,t+=r&&r.countable&&!r.deleted?r.length:0));r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<=r.length){t<r.length&&nt(i,X(r.id.client,r.id.clock+t));break}t-=r.length}return e._searchMarker&&ho(e._searchMarker,n,a.length),Wr(i,e,r,a)},aE=(i,e,t)=>{let n=(e._searchMarker||[]).reduce((o,r)=>r.index>o.index?r:o,{index:0,p:e._start}).p;if(n)for(;n.right;)n=n.right;return Wr(i,e,n,t)},Bm=(i,e,t,a)=>{if(a===0)return;const n=t,o=a,r=Ss(e,t);let l=e._start;for(r!==null&&(l=r.p,t-=r.index);l!==null&&t>0;l=l.right)!l.deleted&&l.countable&&(t<l.length&&nt(i,X(l.id.client,l.id.clock+t)),t-=l.length);for(;a>0&&l!==null;)l.deleted||(a<l.length&&nt(i,X(l.id.client,l.id.clock+a)),l.delete(i),a-=l.length),l=l.right;if(a>0)throw xm();e._searchMarker&&ho(e._searchMarker,n,-o+a)},Ur=(i,e,t)=>{const a=e._map.get(t);a!==void 0&&a.delete(i)},zd=(i,e,t,a)=>{const n=e._map.get(t)||null,o=i.doc,r=o.clientID;let l;if(a==null)l=new ya([a]);else switch(a.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new ya([a]);break;case Uint8Array:l=new Co(a);break;case va:l=new Bo(a);break;default:if(a instanceof Be)l=new Jt(a);else throw new Error("Unexpected content type")}new ae(X(r,Fe(o.store,r)),n,n&&n.lastId,null,null,e,t,l).integrate(i,0)},Rd=(i,e)=>{i.doc??Le();const t=i._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},Sm=i=>{const e={};return i.doc??Le(),i._map.forEach((t,a)=>{t.deleted||(e[a]=t.content.getContent()[t.length-1])}),e},jm=(i,e)=>{i.doc??Le();const t=i._map.get(e);return t!==void 0&&!t.deleted},nE=(i,e)=>{const t={};return i._map.forEach((a,n)=>{let o=a;for(;o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0));)o=o.left;o!==null&&Xi(o,e)&&(t[n]=o.content.getContent()[o.length-1])}),t},Zo=i=>(i.doc??Le(),Dv(i._map.entries(),e=>!e[1].deleted));class oE extends Bs{}class Ka extends Be{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new Ka;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ka}clone(){const e=new Ka;return e.insert(0,this.toArray().map(t=>t instanceof Be?t.clone():t)),e}get length(){return this.doc??Le(),this._length}_callObserver(e,t){super._callObserver(e,t),js(this,e,new oE(this,e))}insert(e,t){this.doc!==null?ne(this.doc,a=>{Cm(a,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?ne(this.doc,t=>{aE(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?ne(this.doc,a=>{Bm(a,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return Em(this,e)}toArray(){return wm(this)}slice(e=0,t=this.length){return km(this,e,t)}toJSON(){return this.map(e=>e instanceof Be?e.toJSON():e)}map(e){return vm(this,e)}forEach(e){mo(this,e)}[Symbol.iterator](){return iE(this)}_write(e){e.writeTypeRef(jE)}}const rE=i=>new Ka;class sE extends Bs{constructor(e,t,a){super(e,t),this.keysChanged=a}}class dn extends Be{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((a,n)=>{this.set(n,a)}),this._prelimContent=null}_copy(){return new dn}clone(){const e=new dn;return this.forEach((t,a)=>{e.set(a,t instanceof Be?t.clone():t)}),e}_callObserver(e,t){js(this,e,new sE(this,e,t))}toJSON(){this.doc??Le();const e={};return this._map.forEach((t,a)=>{if(!t.deleted){const n=t.content.getContent()[t.length-1];e[a]=n instanceof Be?n.toJSON():n}}),e}get size(){return[...Zo(this)].length}keys(){return ml(Zo(this),e=>e[0])}values(){return ml(Zo(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return ml(Zo(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Le(),this._map.forEach((t,a)=>{t.deleted||e(t.content.getContent()[t.length-1],a,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?ne(this.doc,t=>{Ur(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?ne(this.doc,a=>{zd(a,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return Rd(this,e)}has(e){return jm(this,e)}clear(){this.doc!==null?ne(this.doc,e=>{this.forEach(function(t,a,n){Ur(e,n,a)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(qE)}}const lE=i=>new dn,Ai=(i,e)=>i===e||typeof i=="object"&&typeof e=="object"&&i&&e&&y9(i,e);class du{constructor(e,t,a,n){this.left=e,this.right=t,this.index=a,this.currentAttributes=n}forward(){this.right===null&&$e(),this.right.content.constructor===ye?this.right.deleted||yn(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const sg=(i,e,t)=>{for(;e.right!==null&&t>0;)e.right.content.constructor===ye?e.right.deleted||yn(e.currentAttributes,e.right.content):e.right.deleted||(t<e.right.length&&nt(i,X(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length),e.left=e.right,e.right=e.right.right;return e},Qo=(i,e,t,a)=>{const n=new Map,o=a?Ss(e,t):null;if(o){const r=new du(o.p.left,o.p,o.index,n);return sg(i,r,t-o.index)}else{const r=new du(null,e._start,0,n);return sg(i,r,t)}},qm=(i,e,t,a)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===ye&&Ai(a.get(t.right.content.key),t.right.content.value));)t.right.deleted||a.delete(t.right.content.key),t.forward();const n=i.doc,o=n.clientID;a.forEach((r,l)=>{const u=t.left,d=t.right,f=new ae(X(o,Fe(n.store,o)),u,u&&u.lastId,d,d&&d.id,e,null,new ye(l,r));f.integrate(i,0),t.right=f,t.forward()})},yn=(i,e)=>{const{key:t,value:a}=e;a===null?i.delete(t):i.set(t,a)},Am=(i,e)=>{for(;i.right!==null;){if(!(i.right.deleted||i.right.content.constructor===ye&&Ai(e[i.right.content.key]??null,i.right.content.value)))break;i.forward()}},Nm=(i,e,t,a)=>{const n=i.doc,o=n.clientID,r=new Map;for(const l in a){const u=a[l],d=t.currentAttributes.get(l)??null;if(!Ai(d,u)){r.set(l,d);const{left:f,right:c}=t;t.right=new ae(X(o,Fe(n.store,o)),f,f&&f.lastId,c,c&&c.id,e,null,new ye(l,u)),t.right.integrate(i,0),t.forward()}}return r},bl=(i,e,t,a,n)=>{t.currentAttributes.forEach((g,_)=>{n[_]===void 0&&(n[_]=null)});const o=i.doc,r=o.clientID;Am(t,n);const l=Nm(i,e,t,n),u=a.constructor===String?new Kt(a):a instanceof Be?new Jt(a):new Ea(a);let{left:d,right:f,index:c}=t;e._searchMarker&&ho(e._searchMarker,t.index,u.getLength()),f=new ae(X(r,Fe(o.store,r)),d,d&&d.lastId,f,f&&f.id,e,null,u),f.integrate(i,0),t.right=f,t.index=c,t.forward(),qm(i,e,t,l)},lg=(i,e,t,a,n)=>{const o=i.doc,r=o.clientID;Am(t,n);const l=Nm(i,e,t,n);e:for(;t.right!==null&&(a>0||l.size>0&&(t.right.deleted||t.right.content.constructor===ye));){if(!t.right.deleted)switch(t.right.content.constructor){case ye:{const{key:u,value:d}=t.right.content,f=n[u];if(f!==void 0){if(Ai(f,d))l.delete(u);else{if(a===0)break e;l.set(u,d)}t.right.delete(i)}else t.currentAttributes.set(u,d);break}default:a<t.right.length&&nt(i,X(t.right.id.client,t.right.id.clock+a)),a-=t.right.length;break}t.forward()}if(a>0){let u="";for(;a>0;a--)u+=`
135
135
  `;t.right=new ae(X(r,Fe(o.store,r)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new Kt(u)),t.right.integrate(i,0),t.forward()}qm(i,e,t,l)},Mm=(i,e,t,a,n)=>{let o=e;const r=Ht();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===ye){const d=o.content;r.set(d.key,d)}o=o.right}let l=0,u=!1;for(;e!==o;){if(t===e&&(u=!0),!e.deleted){const d=e.content;if(d.constructor===ye){const{key:f,value:c}=d,g=a.get(f)??null;(r.get(f)!==d||g===c)&&(e.delete(i),l++,!u&&(n.get(f)??null)===c&&g!==c&&(g===null?n.delete(f):n.set(f,g))),!u&&!e.deleted&&yn(n,d)}}e=e.right}return l},uE=(i,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===ye){const a=e.content.key;t.has(a)?e.delete(i):t.add(a)}e=e.left}},dE=i=>{let e=0;return ne(i.doc,t=>{let a=i._start,n=i._start,o=Ht();const r=Ql(o);for(;n;)n.deleted===!1&&(n.content.constructor===ye?yn(r,n.content):(e+=Mm(t,a,n,o,r),o=Ql(r),a=n)),n=n.right}),e},fE=i=>{const e=new Set,t=i.doc;for(const[a,n]of i.afterState.entries()){const o=i.beforeState.get(a)||0;n!==o&&hm(i,t.store.clients.get(a),o,n,r=>{!r.deleted&&r.content.constructor===ye&&r.constructor!==jt&&e.add(r.parent)})}ne(t,a=>{Pi(i,i.deleteSet,n=>{if(n instanceof jt||!n.parent._hasFormatting||e.has(n.parent))return;const o=n.parent;n.content.constructor===ye?e.add(o):uE(a,n)});for(const n of e)dE(n)})},ug=(i,e,t)=>{const a=t,n=Ql(e.currentAttributes),o=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Jt:case Ea:case Kt:t<e.right.length&&nt(i,X(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(i);break}e.forward()}o&&Mm(i,o,e.right,n,e.currentAttributes);const r=(e.left||e.right).parent;return r._searchMarker&&ho(r._searchMarker,e.index,-a+t),e};class cE extends Bs{constructor(e,t,a){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,a.forEach(n=>{n===null?this.childListChanged=!0:this.keysChanged.add(n)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];ne(e,a=>{const n=new Map,o=new Map;let r=this.target._start,l=null;const u={};let d="",f=0,c=0;const g=()=>{if(l!==null){let _=null;switch(l){case"delete":c>0&&(_={delete:c}),c=0;break;case"insert":(typeof d=="object"||d.length>0)&&(_={insert:d},n.size>0&&(_.attributes={},n.forEach((h,F)=>{h!==null&&(_.attributes[F]=h)}))),d="";break;case"retain":f>0&&(_={retain:f},b9(u)||(_.attributes=F9({},u))),f=0;break}_&&t.push(_),l=null}};for(;r!==null;){switch(r.content.constructor){case Jt:case Ea:this.adds(r)?this.deletes(r)||(g(),l="insert",d=r.content.getContent()[0],g()):this.deletes(r)?(l!=="delete"&&(g(),l="delete"),c+=1):r.deleted||(l!=="retain"&&(g(),l="retain"),f+=1);break;case Kt:this.adds(r)?this.deletes(r)||(l!=="insert"&&(g(),l="insert"),d+=r.content.str):this.deletes(r)?(l!=="delete"&&(g(),l="delete"),c+=r.length):r.deleted||(l!=="retain"&&(g(),l="retain"),f+=r.length);break;case ye:{const{key:_,value:h}=r.content;if(this.adds(r)){if(!this.deletes(r)){const F=n.get(_)??null;Ai(F,h)?h!==null&&r.delete(a):(l==="retain"&&g(),Ai(h,o.get(_)??null)?delete u[_]:u[_]=h)}}else if(this.deletes(r)){o.set(_,h);const F=n.get(_)??null;Ai(F,h)||(l==="retain"&&g(),u[_]=F)}else if(!r.deleted){o.set(_,h);const F=u[_];F!==void 0&&(Ai(F,h)?F!==null&&r.delete(a):(l==="retain"&&g(),h===null?delete u[_]:u[_]=h))}r.deleted||(l==="insert"&&g(),yn(n,r.content));break}}r=r.right}for(g();t.length>0;){const _=t[t.length-1];if(_.retain!==void 0&&_.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class Li extends Be{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Le(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(a=>a())}catch(a){console.error(a)}this._pending=null}_copy(){return new Li}clone(){const e=new Li;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const a=new cE(this,e,t);js(this,e,a),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Le();let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Kt&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?ne(this.doc,a=>{const n=new du(null,this._start,0,new Map);for(let o=0;o<e.length;o++){const r=e[o];if(r.insert!==void 0){const l=!t&&typeof r.insert=="string"&&o===e.length-1&&n.right===null&&r.insert.slice(-1)===`
136
136
  `?r.insert.slice(0,-1):r.insert;(typeof l!="string"||l.length>0)&&bl(a,this,n,l,r.attributes||{})}else r.retain!==void 0?lg(a,this,n,r.retain,r.attributes||{}):r.delete!==void 0&&ug(a,n,r.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,a){this.doc??Le();const n=[],o=new Map,r=this.doc;let l="",u=this._start;function d(){if(l.length>0){const c={};let g=!1;o.forEach((h,F)=>{g=!0,c[F]=h});const _={insert:l};g&&(_.attributes=c),n.push(_),l=""}}const f=()=>{for(;u!==null;){if(Xi(u,e)||t!==void 0&&Xi(u,t))switch(u.content.constructor){case Kt:{const c=o.get("ychange");e!==void 0&&!Xi(u,e)?(c===void 0||c.user!==u.id.client||c.type!=="removed")&&(d(),o.set("ychange",a?a("removed",u.id):{type:"removed"})):t!==void 0&&!Xi(u,t)?(c===void 0||c.user!==u.id.client||c.type!=="added")&&(d(),o.set("ychange",a?a("added",u.id):{type:"added"})):c!==void 0&&(d(),o.delete("ychange")),l+=u.content.str;break}case Jt:case Ea:{d();const c={insert:u.content.getContent()[0]};if(o.size>0){const g={};c.attributes=g,o.forEach((_,h)=>{g[h]=_})}n.push(c);break}case ye:Xi(u,e)&&(d(),yn(o,u.content));break}u=u.right}d()};return e||t?ne(r,c=>{e&&lu(c,e),t&&lu(c,t),f()},"cleanup"):f(),n}insert(e,t,a){if(t.length<=0)return;const n=this.doc;n!==null?ne(n,o=>{const r=Qo(o,this,e,!a);a||(a={},r.currentAttributes.forEach((l,u)=>{a[u]=l})),bl(o,this,r,t,a)}):this._pending.push(()=>this.insert(e,t,a))}insertEmbed(e,t,a){const n=this.doc;n!==null?ne(n,o=>{const r=Qo(o,this,e,!a);bl(o,this,r,t,a||{})}):this._pending.push(()=>this.insertEmbed(e,t,a||{}))}delete(e,t){if(t===0)return;const a=this.doc;a!==null?ne(a,n=>{ug(n,Qo(n,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,a){if(t===0)return;const n=this.doc;n!==null?ne(n,o=>{const r=Qo(o,this,e,!1);r.right!==null&&lg(o,this,r,t,a)}):this._pending.push(()=>this.format(e,t,a))}removeAttribute(e){this.doc!==null?ne(this.doc,t=>{Ur(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?ne(this.doc,a=>{zd(a,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return Rd(this,e)}getAttributes(){return Sm(this)}_write(e){e.writeTypeRef(AE)}}const gE=i=>new Li;class yl{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Le()}[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===Pe||t.constructor===ba)&&t._start!==null)e=t._start;else for(;e!==null;){const a=e.next;if(a!==null){e=a;break}else e.parent===this._root?e=null:e=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})}}class ba extends Be{constructor(){super(),this._prelimContent=[]}get firstChild(){const 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 ba}clone(){const e=new ba;return e.insert(0,this.toArray().map(t=>t instanceof Be?t.clone():t)),e}get length(){return this.doc??Le(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new yl(this,e)}querySelector(e){e=e.toUpperCase();const a=new yl(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e).next();return a.done?null:a.value}querySelectorAll(e){return e=e.toUpperCase(),pa(new yl(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){js(this,e,new mE(this,t,e))}toString(){return vm(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},a){const n=e.createDocumentFragment();return a!==void 0&&a._createAssociation(n,this),mo(this,o=>{n.insertBefore(o.toDOM(e,t,a),null)}),n}insert(e,t){this.doc!==null?ne(this.doc,a=>{Cm(a,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)ne(this.doc,a=>{const n=e&&e instanceof Be?e._item:e;Wr(a,this,n,t)});else{const a=this._prelimContent,n=e===null?0:a.findIndex(o=>o===e)+1;if(n===0&&e!==null)throw ai("Reference item not found");a.splice(n,0,...t)}}delete(e,t=1){this.doc!==null?ne(this.doc,a=>{Bm(a,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return wm(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Em(this,e)}slice(e=0,t=this.length){return km(this,e,t)}forEach(e){mo(this,e)}_write(e){e.writeTypeRef(ME)}}const _E=i=>new ba;class Pe extends ba{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((a,n)=>{this.setAttribute(n,a)}),this._prelimAttrs=null}_copy(){return new Pe(this.nodeName)}clone(){const e=new Pe(this.nodeName),t=this.getAttributes();return p9(t,(a,n)=>{e.setAttribute(n,a)}),e.insert(0,this.toArray().map(a=>a instanceof Be?a.clone():a)),e}toString(){const e=this.getAttributes(),t=[],a=[];for(const l in e)a.push(l);a.sort();const n=a.length;for(let l=0;l<n;l++){const u=a[l];t.push(u+'="'+e[u]+'"')}const o=this.nodeName.toLocaleLowerCase(),r=t.length>0?" "+t.join(" "):"";return`<${o}${r}>${super.toString()}</${o}>`}removeAttribute(e){this.doc!==null?ne(this.doc,t=>{Ur(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?ne(this.doc,a=>{zd(a,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return Rd(this,e)}hasAttribute(e){return jm(this,e)}getAttributes(e){return e?nE(this,e):Sm(this)}toDOM(e=document,t={},a){const n=e.createElement(this.nodeName),o=this.getAttributes();for(const r in o){const l=o[r];typeof l=="string"&&n.setAttribute(r,l)}return mo(this,r=>{n.appendChild(r.toDOM(e,t,a))}),a!==void 0&&a._createAssociation(n,this),n}_write(e){e.writeTypeRef(NE),e.writeKey(this.nodeName)}}const hE=i=>new Pe(i.readKey());class mE extends Bs{constructor(e,t,a){super(e,a),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(n=>{n===null?this.childListChanged=!0:this.attributesChanged.add(n)})}}class Kr extends dn{constructor(e){super(),this.hookName=e}_copy(){return new Kr(this.hookName)}clone(){const e=new Kr(this.hookName);return this.forEach((t,a)=>{e.set(a,t)}),e}toDOM(e=document,t={},a){const n=t[this.hookName];let o;return n!==void 0?o=n.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),a!==void 0&&a._createAssociation(o,this),o}_write(e){e.writeTypeRef(TE),e.writeKey(this.hookName)}}const FE=i=>new Kr(i.readKey());class lt extends Li{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new lt}clone(){const e=new lt;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,a){const n=e.createTextNode(this.toString());return a!==void 0&&a._createAssociation(n,this),n}toString(){return this.toDelta().map(e=>{const t=[];for(const n in e.attributes){const o=[];for(const r in e.attributes[n])o.push({key:r,value:e.attributes[n][r]});o.sort((r,l)=>r.key<l.key?-1:1),t.push({nodeName:n,attrs:o})}t.sort((n,o)=>n.nodeName<o.nodeName?-1:1);let a="";for(let n=0;n<t.length;n++){const o=t[n];a+=`<${o.nodeName}`;for(let r=0;r<o.attrs.length;r++){const l=o.attrs[r];a+=` ${l.key}="${l.value}"`}a+=">"}a+=e.insert;for(let n=t.length-1;n>=0;n--)a+=`</${t[n].nodeName}>`;return a}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(OE)}}const pE=i=>new lt;class $d{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Mt()}mergeWith(e){return!1}write(e,t,a){throw Mt()}integrate(e,t){throw Mt()}}const bE=0;class jt extends $d{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),_m(e.doc.store,this)}write(e,t){e.writeInfo(bE),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Co{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Co(this.content)}splice(e){throw Mt()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const yE=i=>new Co(i.readBuf());class Fo{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Fo(this.len)}splice(e){const t=new Fo(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){co(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}}const kE=i=>new Fo(i.readLen()),Tm=(i,e)=>new va({guid:i,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Bo{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;const 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 Bo(Tm(this.doc.guid,this.opts))}splice(e){throw Mt()}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}}const wE=i=>new Bo(Tm(i.readString(),i.readAny()));class Ea{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Ea(this.embed)}splice(e){throw Mt()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const DE=i=>new Ea(i.readJSON());class ye{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new ye(this.key,this.value)}splice(e){throw Mt()}mergeWith(e){return!1}integrate(e,t){const a=t.parent;a._searchMarker=null,a._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const vE=i=>new ye(i.readKey(),i.readJSON());class Jr{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Jr(this.arr)}splice(e){const t=new Jr(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const a=this.arr.length;e.writeLen(a-t);for(let n=t;n<a;n++){const o=this.arr[n];e.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}}const EE=i=>{const e=i.readLen(),t=[];for(let a=0;a<e;a++){const n=i.readString();n==="undefined"?t.push(void 0):t.push(JSON.parse(n))}return new Jr(t)},xE=Lr("node_env")==="development";class ya{constructor(e){this.arr=e,xE&&T1(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ya(this.arr)}splice(e){const t=new ya(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const a=this.arr.length;e.writeLen(a-t);for(let n=t;n<a;n++){const o=this.arr[n];e.writeAny(o)}}getRef(){return 8}}const CE=i=>{const e=i.readLen(),t=[];for(let a=0;a<e;a++)t.push(i.readAny());return new ya(t)};class Kt{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Kt(this.str)}splice(e){const t=new Kt(this.str.slice(e));this.str=this.str.slice(0,e);const a=this.str.charCodeAt(e-1);return a>=55296&&a<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}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}}const BE=i=>new Kt(i.readString()),SE=[rE,lE,gE,hE,_E,FE,pE],jE=0,qE=1,AE=2,NE=3,ME=4,TE=5,OE=6;class Jt{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Jt(this.type._copy())}splice(e){throw Mt()}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(a=>{a.deleted?a.id.clock<(e.beforeState.get(a.id.client)||0)&&e._mergeStructs.push(a):a.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(a=>{for(;a!==null;)a.gc(e,!0),a=a.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const VE=i=>new Jt(SE[i.readTypeRef()](i)),fu=(i,e)=>{let t=e,a=0,n;do a>0&&(t=X(t.client,t.clock+a)),n=Ua(i,t),a=t.clock-n.id.clock,t=n.redone;while(t!==null&&n instanceof ae);return{item:n,diff:a}},Hd=(i,e)=>{for(;i!==null&&i.keep!==e;)i.keep=e,i=i.parent._item},Gr=(i,e,t)=>{const{client:a,clock:n}=e.id,o=new ae(X(a,n+t),e,X(a,n+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&o.markDeleted(),e.keep&&(o.keep=!0),e.redone!==null&&(o.redone=X(e.redone.client,e.redone.clock+t)),e.right=o,o.right!==null&&(o.right.left=o),i._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),e.length=t,o},dg=(i,e)=>wd(i,t=>bn(t.deletions,e)),Om=(i,e,t,a,n,o)=>{const r=i.doc,l=r.store,u=r.clientID,d=e.redone;if(d!==null)return nt(i,d);let f=e.parent._item,c=null,g;if(f!==null&&f.deleted===!0){if(f.redone===null&&(!t.has(f)||Om(i,f,t,a,n,o)===null))return null;for(;f.redone!==null;)f=nt(i,f.redone)}const _=f===null?e.parent:f.content.type;if(e.parentSub===null){for(c=e.left,g=e;c!==null;){let p=c;for(;p!==null&&p.parent._item!==f;)p=p.redone===null?null:nt(i,p.redone);if(p!==null&&p.parent._item===f){c=p;break}c=c.left}for(;g!==null;){let p=g;for(;p!==null&&p.parent._item!==f;)p=p.redone===null?null:nt(i,p.redone);if(p!==null&&p.parent._item===f){g=p;break}g=g.right}}else if(g=null,e.right&&!n){for(c=e;c!==null&&c.right!==null&&(c.right.redone||bn(a,c.right.id)||dg(o.undoStack,c.right.id)||dg(o.redoStack,c.right.id));)for(c=c.right;c.redone;)c=nt(i,c.redone);if(c&&c.right!==null)return null}else c=_._map.get(e.parentSub)||null;const h=Fe(l,u),F=X(u,h),m=new ae(F,c,c&&c.lastId,g,g&&g.id,_,e.parentSub,e.content.copy());return e.redone=F,Hd(m,!0),m.integrate(i,0),m};class ae extends $d{constructor(e,t,a,n,o,r,l,u){super(e,u.getLength()),this.origin=a,this.left=t,this.right=n,this.rightOrigin=o,this.parent=r,this.parentSub=l,this.redone=null,this.content=u,this.info=this.content.isCountable()?Ic:0}set marker(e){(this.info&fl)>0!==e&&(this.info^=fl)}get marker(){return(this.info&fl)>0}get keep(){return(this.info&Vc)>0}set keep(e){this.keep!==e&&(this.info^=Vc)}get countable(){return(this.info&Ic)>0}get deleted(){return(this.info&dl)>0}set deleted(e){this.deleted!==e&&(this.info^=dl)}markDeleted(){this.info|=dl}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Fe(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Fe(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Wa&&this.id.client!==this.parent.client&&this.parent.clock>=Fe(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=eg(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=nt(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===jt||this.right&&this.right.constructor===jt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===ae?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===ae&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Wa){const a=Ua(t,this.parent);a.constructor===jt?this.parent=null:this.parent=a.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=eg(e,e.doc.store,X(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 a=this.left,n;if(a!==null)n=a.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;const o=new Set,r=new Set;for(;n!==null&&n!==this.right;){if(r.add(n),o.add(n),Yo(this.origin,n.origin)){if(n.id.client<this.id.client)a=n,o.clear();else if(Yo(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&r.has(Ua(e.doc.store,n.origin)))o.has(Ua(e.doc.store,n.origin))||(a=n,o.clear());else break;n=n.right}this.left=a}if(this.left!==null){const a=this.left.right;this.right=a,this.left.right=this}else{let a;if(this.parentSub!==null)for(a=this.parent._map.get(this.parentSub)||null;a!==null&&a.left!==null;)a=a.left;else a=this.parent._start,this.parent._start=this;this.right=a}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),_m(e.doc.store,this),this.content.integrate(e,this),ig(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new jt(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:X(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Yo(e.origin,this.lastId)&&this.right===e&&Yo(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)){const t=this.parent._searchMarker;return t&&t.forEach(a=>{a.p===e&&(a.p=this,!this.deleted&&this.countable&&(a.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){const t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),co(e.deleteSet,this.id.client,this.id.clock,this.length),ig(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw $e();this.content.gc(e),t?Rv(e,this,new jt(this.id,this.length)):this.content=new Fo(this.length)}write(e,t){const a=t>0?X(this.id.client,this.id.clock+t-1):this.origin,n=this.rightOrigin,o=this.parentSub,r=this.content.getRef()&ps|(a===null?0:Ze)|(n===null?0:gi)|(o===null?0:ro);if(e.writeInfo(r),a!==null&&e.writeLeftID(a),n!==null&&e.writeRightID(n),a===null&&n===null){const l=this.parent;if(l._item!==void 0){const u=l._item;if(u===null){const d=go(l);e.writeParentInfo(!0),e.writeString(d)}else e.writeParentInfo(!1),e.writeLeftID(u.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===Wa?(e.writeParentInfo(!1),e.writeLeftID(l)):$e();o!==null&&e.writeString(o)}this.content.write(e,t)}}const Vm=(i,e)=>IE[e&ps](i),IE=[()=>{$e()},kE,EE,yE,BE,DE,vE,VE,CE,wE,()=>{$e()}],PE=10;class Rt extends $d{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){$e()}write(e,t){e.writeInfo(PE),te(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const Im=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Pm="__ $YJS$ __";Im[Pm]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Im[Pm]=!0;const LE=()=>{let i=!0;return(e,t)=>{if(i){i=!1;try{e()}finally{i=!0}}else t!==void 0&&t()}},zE=/[\uD800-\uDBFF]/,RE=/[\uDC00-\uDFFF]/,$E=(i,e)=>{let t=0,a=0;for(;t<i.length&&t<e.length&&i[t]===e[t];)t++;for(t>0&&zE.test(i[t-1])&&t--;a+t<i.length&&a+t<e.length&&i[i.length-a-1]===e[e.length-a-1];)a++;return a>0&&RE.test(i[i.length-a])&&a--,{index:t,remove:i.length-t-a,insert:e.slice(t,e.length-a)}},HE=$E,Qt=(i,e)=>i>>>e|i<<32-e,WE=i=>Qt(i,2)^Qt(i,13)^Qt(i,22),UE=i=>Qt(i,6)^Qt(i,11)^Qt(i,25),KE=i=>Qt(i,7)^Qt(i,18)^i>>>3,JE=i=>Qt(i,17)^Qt(i,19)^i>>>10,GE=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]),YE=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class XE{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(YE),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,t=this._W;for(let c=16;c<64;c++)t[c]=JE(t[c-2])+t[c-7]+KE(t[c-15])+t[c-16];let a=e[0],n=e[1],o=e[2],r=e[3],l=e[4],u=e[5],d=e[6],f=e[7];for(let c=0,g,_;c<64;c++)g=f+UE(l)+(l&u^~l&d)+GE[c]+t[c]>>>0,_=WE(a)+(a&n^a&o^n&o)>>>0,f=d,d=u,u=l,l=r+g>>>0,r=o,o=n,n=a,a=g+_>>>0;e[0]+=a,e[1]+=n,e[2]+=o,e[3]+=r,e[4]+=l,e[5]+=u,e[6]+=d,e[7]+=f}digest(e){let t=0;for(;t+56<=e.length;){let r=0;for(;r<16&&t+3<e.length;r++)this._W[r]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!==0){for(this._W.fill(0,r,16);t<e.length;)this._W[r]|=e[t]<<(3-t%4)*8,t++;this._W[r]|=Ze<<(3-t%4)*8}this._updateHash()}const a=t%64!==0;this._W.fill(0,0,16);let n=0;for(;t<e.length;n++)for(let r=3;r>=0&&t<e.length;r--)this._W[n]|=e[t++]<<r*8;a||(this._W[n-(t%4===0?0:1)]|=Ze<<(3-t%4)*8),this._W[14]=e.byteLength/jD,this._W[15]=e.byteLength*8,this._updateHash();const o=new Uint8Array(32);for(let r=0;r<this._H.length;r++)for(let l=0;l<4;l++)o[r*4+l]=this._H[r]>>>(3-l)*8;return o}}const ZE=i=>new XE().digest(i),me=new Q("y-sync"),_i=new Q("y-undo");new Q("yjs-cursor");const QE=i=>{for(let t=6;t<i.length;t++)i[t%6]=i[t%6]^i[t];return i.slice(0,6)},ex=i=>S9(QE(ZE(j9(i)))),Yr=(i,e)=>e===void 0?!i.deleted:e.sv.has(i.id.client)&&e.sv.get(i.id.client)>i.id.clock&&!bn(e.ds,i.id),tx=[{light:"#ecd44433",dark:"#ecd444"}],ix=(i,e,t)=>{if(!i.has(t)){if(i.size<e.length){const a=Fa();i.forEach(n=>a.add(n)),e=e.filter(n=>!a.has(n))}i.set(t,u9(e))}return i.get(t)},ax=(i,{colors:e=tx,colorMapping:t=new Map,permanentUserData:a=null,onFirstRender:n=()=>{},mapping:o}={})=>{let r=!1;const l=new ox(i,o),u=new Z({props:{editable:d=>{const f=me.getState(d);return f.snapshot==null&&f.prevSnapshot==null}},key:me,state:{init:(d,f)=>({type:i,doc:i.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:t,permanentUserData:a}),apply:(d,f)=>{const c=d.getMeta(me);if(c!==void 0){f=Object.assign({},f);for(const g in c)f[g]=c[g]}return f.addToHistory=d.getMeta("addToHistory")!==!1,f.isChangeOrigin=c!==void 0&&!!c.isChangeOrigin,f.isUndoRedoOperation=c!==void 0&&!!c.isChangeOrigin&&!!c.isUndoRedoOperation,l.prosemirrorView!==null&&c!==void 0&&(c.snapshot!=null||c.prevSnapshot!=null)&&em(0,()=>{l.prosemirrorView!=null&&(c.restore==null?l._renderSnapshot(c.snapshot,c.prevSnapshot,f):(l._renderSnapshot(c.snapshot,c.snapshot,f),delete f.restore,delete f.snapshot,delete f.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),f}},view:d=>(l.initView(d),o==null&&l._forceRerender(),n(),{update:()=>{const f=u.getState(d.state);if(f.snapshot==null&&f.prevSnapshot==null&&(r||d.state.doc.content.findDiffStart(d.state.doc.type.createAndFill().content)!==null)){if(r=!0,f.addToHistory===!1&&!f.isChangeOrigin){const c=_i.getState(d.state),g=c&&c.undoManager;g&&g.stopCapturing()}l.mux(()=>{f.doc.transact(c=>{c.meta.set("addToHistory",f.addToHistory),l._prosemirrorChanged(d.state.doc)},me)})}},destroy:()=>{l.destroy()}})});return u},nx=(i,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")i.setSelection(new Xe(i.doc));else if(e.type==="node"){const a=hr(t.doc,t.type,e.anchor,t.mapping);i.setSelection(L.create(i.doc,a))}else{const a=hr(t.doc,t.type,e.anchor,t.mapping),n=hr(t.doc,t.type,e.head,t.mapping);a!==null&&n!==null&&i.setSelection(P.between(i.doc.resolve(a),i.doc.resolve(n)))}},cu=(i,e)=>({type:e.selection.jsonID,anchor:mu(e.selection.anchor,i.type,i.mapping),head:mu(e.selection.head,i.type,i.mapping)});class ox{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=LE(),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=cu(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()?(O1&&this._domSelectionInView===null&&(em(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const 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);const n=t.getBoundingClientRect(),o=xo.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||o.clientWidth||0)&&n.top<=(window.innerHeight||o.clientHeight||0)}renderSnapshot(e,t){t||(t=cm(lm(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(me,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(a=>_r(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(j.from(e),0,0));t.setMeta(me,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,t=this.type.toArray().map(n=>_r(n,this.prosemirrorView.state.schema,this)).filter(n=>n!==null),a=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(j.from(t),0,0));if(e){const n=rn(Ii(e.anchor,0),a.doc.content.size),o=rn(Ii(e.head,0),a.doc.content.size);a.setSelection(P.create(a.doc,n,o))}this.prosemirrorView.dispatch(a.setMeta(me,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,a){let n=this.doc,o=this.type;if(e||(e=pl(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&$e(),n=new va({gc:!1}),su(n,t),t=pl(n),su(n,e),e=pl(n),o._item===null){const r=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);o=n.getXmlFragment(r)}else{const r=n.store.clients.get(o._item.id.client)??[],l=Ut(r,o._item.id.clock);o=r[l].content.type}this.mapping.clear(),this.mux(()=>{n.transact(r=>{const l=a.permanentUserData;l&&l.dss.forEach(c=>{Pi(r,c,g=>{})});const u=(c,g)=>{const _=c==="added"?l.getUserByClientId(g.client):l.getUserByDeletedId(g);return{user:_,type:c,color:ix(a.colorMapping,a.colors,_)}},d=Dm(o,new Pd(t.ds,e.sv)).map(c=>!c._item.deleted||Yr(c._item,e)||Yr(c._item,t)?_r(c,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,u):null).filter(c=>c!==null),f=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(j.from(d),0,0));this.prosemirrorView.dispatch(f.setMeta(me,{isChangeOrigin:!0}))},me)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;const a=me.getState(this.prosemirrorView.state);if(e.length===0||a.snapshot!=null||a.prevSnapshot!=null){this.renderSnapshot(a.snapshot,a.prevSnapshot);return}this.mux(()=>{const n=(l,u)=>this.mapping.delete(u);Pi(t,t.deleteSet,l=>{if(l.constructor===ae){const u=l.content.type;u&&this.mapping.delete(u)}}),t.changed.forEach(n),t.changedParentTypes.forEach(n);const o=this.type.toArray().map(l=>Lm(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null);let r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(j.from(o),0,0));nx(r,this.beforeTransactionSelection,this),r=r.setMeta(me,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof Fm}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{_u(this.doc,this.type,e,this),this.beforeTransactionSelection=cu(this,this.prosemirrorView.state)},me)}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))}}const Lm=(i,e,t,a,n,o)=>{const r=t.mapping.get(i);if(r===void 0){if(i instanceof Pe)return _r(i,e,t,a,n,o);throw Mt()}return r},_r=(i,e,t,a,n,o)=>{const r=[],l=u=>{if(u instanceof Pe){const d=Lm(u,e,t,a,n,o);d!==null&&r.push(d)}else{const d=u._item.right?.content?.type;d instanceof Li&&!d._item.deleted&&d._item.id.client===d.doc.clientID&&(u.applyDelta([{retain:u.length},...d.toDelta()]),d.doc.transact(c=>{d._item.delete(c)}));const f=rx(u,e,t,a,n,o);f!==null&&f.forEach(c=>{c!==null&&r.push(c)})}};a===void 0||n===void 0?i.toArray().forEach(l):Dm(i,new Pd(n.ds,a.sv)).forEach(l);try{const u=i.getAttributes(a);a!==void 0&&(Yr(i._item,a)?Yr(i._item,n)||(u.ychange=o?o("added",i._item.id):{type:"added"}):u.ychange=o?o("removed",i._item.id):{type:"removed"});const d=e.node(i.nodeName,u,r);return t.mapping.set(i,d),d}catch{return i.doc.transact(d=>{i._item.delete(d)},me),t.mapping.delete(i),null}},rx=(i,e,t,a,n,o)=>{const r=[],l=i.toDelta(a,n,o);try{for(let u=0;u<l.length;u++){const d=l[u];r.push(e.text(d.insert,cx(d.attributes,e)))}}catch{return i.doc.transact(d=>{i._item.delete(d)},me),null}return r},sx=(i,e)=>{const t=new lt,a=i.map(n=>({insert:n.text,attributes:Rm(n.marks,e)}));return t.applyDelta(a),e.mapping.set(t,i),t},lx=(i,e)=>{const t=new Pe(i.type.name);for(const a in i.attrs){const n=i.attrs[a];n!==null&&a!=="ychange"&&t.setAttribute(a,n)}return t.insert(0,qs(i).map(a=>gu(a,e))),e.mapping.set(t,i),t},gu=(i,e)=>i instanceof Array?sx(i,e):lx(i,e),fg=i=>typeof i=="object"&&i!==null,Wd=(i,e)=>{const t=Object.keys(i).filter(n=>i[n]!==null);let a=t.length===Object.keys(e).filter(n=>e[n]!==null).length;for(let n=0;n<t.length&&a;n++){const o=t[n],r=i[o],l=e[o];a=o==="ychange"||r===l||fg(r)&&fg(l)&&Wd(r,l)}return a},qs=i=>{const e=i.content.content,t=[];for(let a=0;a<e.length;a++){const n=e[a];if(n.isText){const o=[];for(let r=e[a];a<e.length&&r.isText;r=e[++a])o.push(r);a--,t.push(o)}else t.push(n)}return t},zm=(i,e)=>{const t=i.toDelta();return t.length===e.length&&t.every((a,n)=>a.insert===e[n].text&&M1(a.attributes||{}).length===e[n].marks.length&&mn(a.attributes,(o,r)=>{const l=Ud(r),u=e[n].marks;return Wd(o,u.find(d=>d.type.name===l)?.attrs)}))},po=(i,e)=>{if(i instanceof Pe&&!(e instanceof Array)&&hu(i,e)){const t=qs(e);return i._length===t.length&&Wd(i.getAttributes(),e.attrs)&&i.toArray().every((a,n)=>po(a,t[n]))}return i instanceof lt&&e instanceof Array&&zm(i,e)},Xr=(i,e)=>i===e||i instanceof Array&&e instanceof Array&&i.length===e.length&&i.every((t,a)=>e[a]===t),cg=(i,e,t)=>{const a=i.toArray(),n=qs(e),o=n.length,r=a.length,l=rn(r,o);let u=0,d=0,f=!1;for(;u<l;u++){const c=a[u],g=n[u];if(Xr(t.mapping.get(c),g))f=!0;else if(!po(c,g))break}for(;u+d<l;d++){const c=a[r-d-1],g=n[o-d-1];if(Xr(t.mapping.get(c),g))f=!0;else if(!po(c,g))break}return{equalityFactor:u+d,foundMappedChild:f}},ux=i=>{let e="",t=i._start;const a={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof Kt?e+=t.content.str:t.content instanceof ye&&(a[t.content.key]=null)),t=t.right;return{str:e,nAttrs:a}},dx=(i,e,t)=>{t.mapping.set(i,e);const{nAttrs:a,str:n}=ux(i),o=e.map(d=>({insert:d.text,attributes:Object.assign({},a,Rm(d.marks,t))})),{insert:r,remove:l,index:u}=HE(n,o.map(d=>d.insert).join(""));i.delete(u,l),i.insert(u,r),i.applyDelta(o.map(d=>({retain:d.insert.length,attributes:d.attributes})))},fx=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Ud=i=>fx.exec(i)?.[1]??i,cx=(i,e)=>{const t=[];for(const a in i)t.push(e.mark(Ud(a),i[a]));return t},Rm=(i,e)=>{const t={};return i.forEach(a=>{if(a.type.name!=="ychange"){const n=bi(e.isOMark,a.type,()=>!a.type.excludes(a.type));t[n?`${a.type.name}--${ex(a.toJSON())}`:a.type.name]=a.attrs}}),t},_u=(i,e,t,a)=>{if(e instanceof Pe&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(a.mapping.set(e,t),e instanceof Pe){const c=e.getAttributes(),g=t.attrs;for(const _ in g)g[_]!==null?c[_]!==g[_]&&_!=="ychange"&&e.setAttribute(_,g[_]):e.removeAttribute(_);for(const _ in c)g[_]===void 0&&e.removeAttribute(_)}const n=qs(t),o=n.length,r=e.toArray(),l=r.length,u=rn(o,l);let d=0,f=0;for(;d<u;d++){const c=r[d],g=n[d];if(!Xr(a.mapping.get(c),g))if(po(c,g))a.mapping.set(c,g);else break}for(;f+d+1<u;f++){const c=r[l-f-1],g=n[o-f-1];if(!Xr(a.mapping.get(c),g))if(po(c,g))a.mapping.set(c,g);else break}i.transact(()=>{for(;l-d-f>0&&o-d-f>0;){const g=r[d],_=n[d],h=r[l-f-1],F=n[o-f-1];if(g instanceof lt&&_ instanceof Array)zm(g,_)||dx(g,_,a),d+=1;else{let m=g instanceof Pe&&hu(g,_),p=h instanceof Pe&&hu(h,F);if(m&&p){const y=cg(g,_,a),k=cg(h,F,a);y.foundMappedChild&&!k.foundMappedChild?p=!1:!y.foundMappedChild&&k.foundMappedChild||y.equalityFactor<k.equalityFactor?m=!1:p=!1}m?(_u(i,g,_,a),d+=1):p?(_u(i,h,F,a),f+=1):(a.mapping.delete(e.get(d)),e.delete(d,1),e.insert(d,[gu(_,a)]),d+=1)}}const c=l-d-f;if(l===1&&o===0&&r[0]instanceof lt?(a.mapping.delete(r[0]),r[0].delete(0,r[0].length)):c>0&&(e.slice(d,d+c).forEach(g=>a.mapping.delete(g)),e.delete(d,c)),d+f<o){const g=[];for(let _=d;_<o-f;_++)g.push(gu(n[_],a));e.insert(d,g)}},me)},hu=(i,e)=>!(e instanceof Array)&&i.nodeName===e.type.name,mu=(i,e,t)=>{if(i===0)return Fl(e,0,-1);let a=e._first===null?null:e._first.content.type;for(;a!==null&&e!==a;){if(a instanceof lt){if(a._length>=i)return Fl(a,i,-1);if(i-=a._length,a._item!==null&&a._item.next!==null)a=a._item.next.content.type;else{do a=a._item===null?null:a._item.parent,i--;while(a!==e&&a!==null&&a._item!==null&&a._item.next===null);a!==null&&a!==e&&(a=a._item===null?null:a._item.next.content.type)}}else{const n=(t.get(a)||{nodeSize:0}).nodeSize;if(a._first!==null&&i<n)a=a._first.content.type,i--;else{if(i===1&&a._length===0&&n>1)return new Hr(a._item===null?null:a._item.id,a._item===null?go(a):null,null);if(i-=n,a._item!==null&&a._item.next!==null)a=a._item.next.content.type;else{if(i===0)return a=a._item===null?a:a._item.parent,new Hr(a._item===null?null:a._item.id,a._item===null?go(a):null,null);do a=a._item.parent,i--;while(a!==e&&a._item.next===null);a!==e&&(a=a._item.next.content.type)}}}if(a===null)throw $e();if(i===0&&a.constructor!==lt&&a!==e)return gx(a._item.parent,a._item)}return Fl(e,e._length,-1)},gx=(i,e)=>{let t=null,a=null;return i._item===null?a=go(i):t=X(i._item.id.client,i._item.id.clock),new Hr(t,a,e.id)},hr=(i,e,t,a)=>{const n=Lv(t,i);if(n===null||n.type!==e&&!_o(e,n.type._item))return null;let o=n.type,r=0;if(o.constructor===lt)r=n.index;else if(o._item===null||!o._item.deleted){let l=o._first,u=0;for(;u<o._length&&u<n.index&&l!==null;){if(!l.deleted){const d=l.content.type;u++,d instanceof lt?r+=d._length:r+=a.get(d).nodeSize}l=l.right}r+=1}for(;o!==e&&o._item!==null;){const l=o._item.parent;if(l._item===null||!l._item.deleted){r+=1;let u=l._first;for(;u!==null;){const d=u.content.type;if(d===o)break;u.deleted||(d instanceof lt?r+=d._length:r+=a.get(d).nodeSize),u=u.right}}o=l}return r-1};function _x(i){const e=i.toArray(),t=a=>{let n;if(a instanceof lt)n=a.toDelta().map(r=>{const l={type:"text",text:r.insert};return r.attributes&&(l.marks=Object.keys(r.attributes).map(u=>{const d=r.attributes[u],c={type:Ud(u)};return Object.keys(d)&&(c.attrs=d),c})),l});else if(a instanceof Pe){n={type:a.nodeName};const o=a.getAttributes();Object.keys(o).length&&(n.attrs=o);const r=a.toArray();r.length&&(n.content=r.map(t).flat())}else $e();return n};return{type:"doc",content:e.map(t)}}const hx=i=>{const e=_i.getState(i).undoManager;if(e!=null)return e.undo(),!0},mx=i=>{const e=_i.getState(i).undoManager;if(e!=null)return e.redo(),!0},Fx=new Set(["paragraph"]),px=(i,e)=>!(i instanceof ae)||!(i.content instanceof Jt)||!(i.content.type instanceof Li||i.content.type instanceof Pe&&e.has(i.content.type.nodeName))||i.content.type._length===0,bx=({protectedNodes:i=Fx,trackedOrigins:e=[],undoManager:t=null}={})=>new Z({key:_i,state:{init:(a,n)=>{const o=me.getState(n),r=t||new Fm(o.type,{trackedOrigins:new Set([me].concat(e)),deleteFilter:l=>px(l,i),captureTransaction:l=>l.meta.get("addToHistory")!==!1});return{undoManager:r,prevSel:null,hasUndoOps:r.undoStack.length>0,hasRedoOps:r.redoStack.length>0}},apply:(a,n,o,r)=>{const l=me.getState(r).binding,u=n.undoManager,d=u.undoStack.length>0,f=u.redoStack.length>0;return l?{undoManager:u,prevSel:cu(l,o),hasUndoOps:d,hasRedoOps:f}:d!==n.hasUndoOps||f!==n.hasRedoOps?Object.assign({},n,{hasUndoOps:u.undoStack.length>0,hasRedoOps:u.redoStack.length>0}):n}},view:a=>{const n=me.getState(a.state),o=_i.getState(a.state).undoManager;return o.on("stack-item-added",({stackItem:r})=>{const l=n.binding;l&&r.meta.set(l,_i.getState(a.state).prevSel)}),o.on("stack-item-popped",({stackItem:r})=>{const l=n.binding;l&&(l.beforeTransactionSelection=r.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{o.destroy()}}}});re.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(i=>i.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},addCommands(){return{undo:()=>({tr:i,state:e,dispatch:t})=>(i.setMeta("preventDispatch",!0),_i.getState(e).undoManager.undoStack.length===0?!1:t?hx(e):!0),redo:()=>({tr:i,state:e,dispatch:t})=>(i.setMeta("preventDispatch",!0),_i.getState(e).undoManager.redoStack.length===0?!1:t?mx(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var i;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=bx(this.options.yUndoOptions),a=t.spec.view;t.spec.view=r=>{const{undoManager:l}=_i.getState(r.state);l.restore&&(l.restore(),l.restore=()=>{});const u=a?a(r):void 0;return{destroy:()=>{const d=l.trackedOrigins.has(l),f=l._observers;l.restore=()=>{d&&l.trackedOrigins.add(l),l.doc.on("afterTransaction",l.afterTransactionHandler),l._observers=f},u?.destroy&&u.destroy()}}};const n={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},o=ax(e,n);return this.editor.options.enableContentCheck&&((i=e.doc)==null||i.on("beforeTransaction",()=>{try{const r=_x(e);if(r.content.length===0)return;this.editor.schema.nodeFromJSON(r).check()}catch(r){return this.editor.emit("contentError",{error:r,editor:this.editor,disableCollaboration:()=>{var l;(l=e.doc)==null||l.destroy(),this.storage.isDisabled=!0}}),!1}})),[o,t,this.editor.options.enableContentCheck&&new Z({key:new Q("filterInvalidContent"),filterTransaction:()=>{var r;return this.storage.isDisabled!==!1&&((r=e.doc)==null||r.destroy()),!0}})].filter(Boolean)}});function yx(i){return!!i.getMeta(me)}function kx(i){let e="";const t=getComputedStyle(i);for(let a=0;a<t.length;a+=1)e+=`${t[a]}:${t.getPropertyValue(t[a])};`;return e}function wx(i){const e=i.cloneNode(!0),t=[i,...Array.from(i.getElementsByTagName("*"))],a=[e,...Array.from(e.getElementsByTagName("*"))];return t.forEach((n,o)=>{a[o].style.cssText=kx(n)}),e}function Fu(i){console.log("removing node",i),i.parentNode?.removeChild(i)}function Dx(i,e){let t=null;return i.doc.descendants((a,n,o,r)=>{if(a?.attrs?.id===e){const l=i.doc.resolve(n);return t={pos:n,node:a,depth:l.depth},!1}return!0}),t}function vx(i,e,t){const{view:a}=e;if(!i.dataTransfer)return;const n=Dx(a.state,t);if(!n)return;const o=a.state.doc.resolve(n.pos),r=o.depth>0?o.node(o.depth-1):null;!r||r.type.name;const l=L.create(a.state.doc,n.pos),u=l.content(),d=a.nodeDOM(n.pos);if(!d)return;const f=document.createElement("div");f.append(wx(d)),f.style.position="absolute",f.style.top="-10000px",f.dataset.dragClone="true",document.body.append(f),i.dataTransfer.clearData(),i.dataTransfer.setDragImage(f,0,0),a.dragging={slice:u,move:!0};const c=a.state.tr.setSelection(l);a.dispatch(c),document.addEventListener("drop",()=>Fu(f),{once:!0})}const Ex=i=>{const{x:e,y:t,direction:a="right",editor:n,bandHeight:o=5}=i,r={top:t-o,bottom:t+o,left:a==="right"?e:0,right:a==="right"?window.innerWidth-e:e},u=[...n.view.dom.querySelectorAll("*")].filter(_=>_.dataset.draggable==="true").filter(_=>n.view.posAtDOM(_,0)>=0).filter(_=>{const h=_.getBoundingClientRect();return!(h.bottom<r.top||h.top>r.bottom||h.right<r.left||h.left>r.right)});if(!u||u.length===0)return{resultElement:null,resultNode:null,pos:null};const d=u[0],f=n.view.posAtDOM(d,0);if(f===-1)return{resultElement:d,resultNode:null,pos:null};const c=n.state.doc.resolve(f);if(c.nodeAfter){const _=n.view.nodeDOM(c.pos);if(_&&_===d)return{resultElement:d,resultNode:c.nodeAfter,pos:f}}const g=n.state.doc.nodeAt(f-1);return{resultElement:d,resultNode:g,pos:f}},kl=(i,e)=>{const t=me.getState(i);return t?mu(e,t.type,t.binding.mapping):null},xx=(i,e)=>{const t=me.getState(i);return t?hr(t.doc,t.type,e,t.binding.mapping)||0:-1},$m=new Q("dragHandle"),Hm=({pluginKey:i=$m,element:e,editor:t,computePositionConfig:a,getReferencedVirtualElement:n,onNodeChange:o,onElementDragStart:r,onElementDragEnd:l})=>{const u=document.createElement("div");let d=!1,f=null,c=-1,g,_=null,h=null;function F(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function m(){if(e){if(!t.isEditable){F();return}e.style.visibility="",e.style.pointerEvents="auto"}}function p(w){const D=n?.()||{getBoundingClientRect:()=>w.getBoundingClientRect()};lF.computePosition(D,e,a).then(C=>{Object.assign(e.style,{position:C.strategy,left:`${C.x}px`,top:`${C.y}px`})})}function y(w){r?.(w),vx(w,t,f.dataset.id),setTimeout(()=>{e&&(e.style.pointerEvents="none"),document.querySelector(".tiptap-container").style.pointerEvents="none",document.body.setAttribute("data-is-grabbing","true")},0)}function k(w){l?.(w),F(),b(),e&&(e.style.pointerEvents="auto"),document.querySelector(".tiptap-container").style.pointerEvents="auto",document.body.removeAttribute("data-is-grabbing")}function b(){document.querySelectorAll('div[data-drag-clone="true"]')?.forEach(w=>Fu(w))}return e.addEventListener("dragstart",y),e.addEventListener("dragend",k),u.appendChild(e),{unbind(){e.removeEventListener("dragstart",y),e.removeEventListener("dragend",k),_&&(cancelAnimationFrame(_),_=null,h=null)},plugin:new Z({key:typeof i=="string"?new Q(i):i,state:{init(){return{locked:!1}},apply(w,D,C,E){const v=w.getMeta("lockDragHandle"),x=w.getMeta("hideDragHandle");if(v!==void 0&&(d=v),x)return F(),d=!1,f=null,c=-1,o?.({editor:t,node:null,pos:-1}),D;if(w.docChanged&&c!==-1&&e)if(yx(w)){const T=xx(E,g);T!==c&&(c=T)}else{const T=w.mapping.map(c);T!==c&&(c=T,g=kl(E,c))}return D}},view:w=>(e.draggable=!0,e.style.pointerEvents="auto",t.view.dom.parentElement?.appendChild(u),u.style.pointerEvents="none",u.style.position="absolute",u.style.top="0",u.style.left="0",{update(D,C){if(!e)return;if(!t.isEditable){F();return}if(d?e.draggable=!1:e.draggable=!0,w.state.doc.eq(C.doc)||c===-1)return;let E=w.nodeDOM(c);if(E===w.dom||E?.nodeType!==1)return;const v=w.posAtDOM(E,0);f=E,c=v,g=kl(w.state,c),o?.({editor:t,node:f,pos:c}),p(E)},destroy(){_&&(cancelAnimationFrame(_),_=null,h=null),e&&Fu(u)}}),props:{handleDOMEvents:{keydown(w){return!e||d||w.hasFocus()&&(F(),f=null,c=-1,o?.({editor:t,node:null,pos:-1})),!1},mouseleave(w,D){return d||D.target&&!u.contains(D.relatedTarget)&&(F(),f=null,c=-1,o?.({editor:t,node:null,pos:-1})),!1},mousemove(w,D){return!e||d||(h={x:D.clientX,y:D.clientY},_)||(_=requestAnimationFrame(()=>{if(_=null,!h)return;const{x:C,y:E}=h;h=null;const v=Ex({x:C,y:E,direction:"right",editor:t});if(!v.resultElement)return;let x=v.resultElement;if(x===w.dom||x?.nodeType!==1)return;const T=w.posAtDOM(x,0);x!==f&&(f=x,c=T,g=kl(w.state,c),o?.({editor:t,node:f,pos:c}),p(x),m())})),!1}}}})}},Wm={placement:"left-start",strategy:"absolute"};re.create({name:"dragHandle",addOptions(){return{render(){const i=document.createElement("div");return i.classList.add("drag-handle"),i},computePositionConfig:{},locked:!1,onNodeChange:()=>null}},addCommands(){return{lockDragHandle:()=>({editor:i})=>(this.options.locked=!0,i.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:i})=>(this.options.locked=!1,i.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:i})=>(this.options.locked=!this.options.locked,i.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const i=this.options.render();return[Hm({computePositionConfig:{...Wm,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:i,editor:this.editor,onNodeChange:this.options.onNodeChange}).plugin]}});const Cx=s.defineComponent({name:"DragHandleVue",props:{pluginKey:{type:[String,Object],default:$m},editor:{type:Object,required:!0},computePositionConfig:{type:Object,default:()=>({})},onNodeChange:{type:Function,default:null},class:{type:String,default:"drag-handle"}},setup(i,{slots:e}){const t=s.ref(null);return s.onMounted(()=>{const{editor:a,pluginKey:n,onNodeChange:o,computePositionConfig:r}=i;a.registerPlugin(Hm({editor:a,element:t.value,pluginKey:n,computePositionConfig:{...Wm,...r},onNodeChange:o}).plugin)}),s.onBeforeUnmount(()=>{const{pluginKey:a,editor:n}=i;n.unregisterPlugin(a)}),()=>s.h("div",{ref:t,class:i.class,style:{visibility:"hidden",position:"absolute"}},e.default?.())}}),Bx={class:"tiptap-details__inner"},Sx=s.defineComponent({__name:"DetailsNodeView",props:We,setup(i){const e=i,{isActive:t,isInsideNode:a,isPerformingActionOutside:n}=_t(e.node),o=s.ref(!1),r=s.computed(()=>{const u=e.extension?.options?.HTMLAttributes??{};return be(u,e.HTMLAttributes)});function l(){if(typeof e.getPos=="function"){const u=e.getPos();e.editor.chain().setNodeSelection(u).focus().run(),console.log(e.editor.state?.selection?.node)}}return(u,d)=>(s.openBlock(),s.createBlock(s.unref(ct),s.mergeProps({"data-draggable":"true","data-id":u.node.attrs.id,class:["tiptap-details group/node",`${u.node.attrs.alignment==="center"?"mx-auto":u.node.attrs.alignment==="right"?"ml-auto":"mr-auto"} ${u.editor.isEditable?"editable":""} ${s.unref(n)?"-no-interaction":""}`],style:`width: ${u.node.attrs.size/12*100}%; max-width: ${u.node.attrs.size/12*100}%; margin-top: ${u.node.attrs.marginTop||0}px;`},r.value,{"data-type":u.extension.name,"data-open":o.value?"true":"false"}),{default:s.withCtx(()=>[s.unref(t)?(s.openBlock(),s.createBlock(Fi,{key:0,node:u.node,getPos:u.getPos,editor:u.editor},null,8,["node","getPos","editor"])):s.createCommentVNode("",!0),s.unref(n)?s.createCommentVNode("",!0):(s.openBlock(),s.createBlock(It,s.normalizeProps(s.mergeProps({key:1},e)),{default:s.withCtx(()=>[...d[1]||(d[1]=[s.createTextVNode("Accordion",-1)])]),_:1},16)),s.createElementVNode("button",{class:"tiptap-details__toggle",type:"button",onClick:d[0]||(d[0]=f=>o.value=!o.value),contenteditable:"false"}),s.createElementVNode("div",Bx,[s.createVNode(s.unref(Da))]),!s.unref(a)&&!s.unref(t)&&u.editor.isEditable?(s.openBlock(),s.createElementBlock("button",{key:2,onClick:s.withModifiers(l,["stop"]),class:"absolute w-full h-full top-0 left-0 z-10 cursor-pointer"})):s.createCommentVNode("",!0),s.unref(t)&&!s.unref(n)?(s.openBlock(),s.createBlock(pi,{key:3,node:u.node,editor:u.editor},null,8,["node","editor"])):s.createCommentVNode("",!0)]),_:1},16,["data-id","class","style","data-type","data-open"]))}}),jx=se._export_sfc(Sx,[["__scopeId","data-v-1a4a02dd"]]),Zr=(i,e)=>e.view.domAtPos(i).node.offsetParent!==null,qx=(i,e,t)=>{for(let a=i.depth;a>0;a-=1){const n=i.node(a),o=e(n),r=Zr(i.start(a),t);if(o&&r)return{pos:a>0?i.before(a):0,start:i.start(a),depth:a,node:n}}},gg=(i,e)=>{const{state:t,view:a,extensionManager:n}=i,{schema:o,selection:r}=t,{empty:l,$anchor:u}=r,d=!!n.extensions.find(p=>p.name==="gapCursor");if(!l||u.parent.type!==o.nodes.detailsSummary||!d||e==="right"&&u.parentOffset!==u.parent.nodeSize-2)return!1;const f=_n(p=>p.type===o.nodes.details)(r);if(!f)return!1;const c=On(f.node,p=>p.type===o.nodes.detailsContent);if(!c.length||Zr(f.start+c[0].pos+1,i))return!1;const _=t.doc.resolve(f.pos+f.node.nodeSize),h=ce.findFrom(_,1,!1);if(!h)return!1;const{tr:F}=t,m=new ce(h);return F.setSelection(m),F.scrollIntoView(),a.dispatch(F),!0},Ax=Te.create({name:"details",content:"detailsSummary detailsContent",group:"block",defining:!0,selectable:!0,draggable:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{HTMLAttributes:{},className:"tiptap-details"}},addAttributes(){return{id:{default:null},marginTop:{default:0},alignment:{default:"left",renderHTML:()=>({}),parseHTML:i=>i.dataset.alignment||"left"},size:{default:12,renderHTML:()=>({}),parseHTML:i=>{const e=i.dataset.size;return e?parseInt(e):12}}}},parseHTML(){return[{tag:'div[data-type="details"]'}]},renderHTML({HTMLAttributes:i,node:e}){return["div",be(this.options.HTMLAttributes,i,{"data-type":"details","data-alignment":e.attrs.alignment,"data-size":e.attrs.size}),["div",{},0]]},addCommands(){return{setDetails:()=>({state:i,chain:e})=>{const{schema:t,selection:a}=i,{$from:n,$to:o}=a,r=n.blockRange(o);if(!r)return!1;const l=i.doc.slice(r.start,r.end);if(!t.nodes.detailsContent.contentMatch.matchFragment(l.content))return!1;const d=l.toJSON()?.content||[];return e().insertContentAt({from:r.start,to:r.end},{type:this.name,content:[{type:"detailsSummary"},{type:"detailsContent",content:d}]}).setTextSelection(r.start+2).run()},unsetDetails:()=>({state:i,chain:e})=>{const{selection:t,schema:a}=i,n=_n(p=>p.type===this.type)(t);if(!n)return!1;const o=On(n.node,p=>p.type===a.nodes.detailsSummary),r=On(n.node,p=>p.type===a.nodes.detailsContent);if(!o.length||!r.length)return!1;const l=o[0],u=r[0],d=n.pos,f=i.doc.resolve(d),c=d+n.node.nodeSize,g={from:d,to:c},_=u.node.content.toJSON()||[],m=[f.parent.type.contentMatch.defaultType?.create(null,l.node.content).toJSON(),..._];return e().insertContentAt(g,m).setTextSelection(d+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{const{schema:i,selection:e}=this.editor.state,{empty:t,$anchor:a}=e;return!t||a.parent.type!==i.nodes.detailsSummary?!1:a.parentOffset!==0?this.editor.commands.command(({tr:n})=>{const o=a.pos-1,r=a.pos;return n.delete(o,r),!0}):this.editor.commands.unsetDetails()},Enter:({editor:i})=>{const{state:e,view:t}=i;if(!qn(e,this.type.name))return!1;const{schema:n,selection:o}=e,{$head:r}=o;if(r.parent.type!==n.nodes.detailsSummary)return!1;const l=Zr(r.after()+1,i),u=l?e.doc.nodeAt(r.after()):r.node(-2);if(!u)return!1;const d=l?0:r.indexAfter(-1),f=Yu(u.contentMatchAt(d));if(!f||!u.canReplaceWith(d,d,f))return!1;const c=f.createAndFill();if(!c)return!1;const g=l?r.after()+1:r.after(-1),_=e.tr.replaceWith(g,g,c),h=_.doc.resolve(g),F=H.near(h,1);return _.setSelection(F),_.scrollIntoView(),t.dispatch(_),!0},ArrowRight:({editor:i})=>{const{state:e}=i;return qn(e,this.type.name)?gg(i,"right"):!1},ArrowDown:({editor:i})=>{const{state:e}=i;if(!qn(e,this.type.name)){const a=document.querySelector("#content-manager-editor-slash-menu");return!!(a&&(a.querySelector("button.bg-input")||a.querySelector("button")))}return gg(i,"down")}}},addProseMirrorPlugins(){return[new Z({key:new Q("detailsSelection"),appendTransaction:(i,e,t)=>{const{editor:a,type:n}=this;if(a.view.composing||!i.some(p=>p.selectionSet)||!e.selection.empty||!t.selection.empty||!qn(t,n.name))return;const{$from:u}=t.selection;if(Zr(u.pos,a))return;const f=qx(u,p=>p.type===n,a);if(!f)return;const c=On(f.node,p=>p.type===t.schema.nodes.detailsSummary);if(!c.length)return;const g=c[0],h=(e.selection.from<t.selection.from?"forward":"backward")==="forward"?f.start+g.pos:f.pos+g.pos+g.node.nodeSize,F=P.create(t.doc,h);return t.tr.setSelection(F)}})]},addNodeView(){return gt(jx)}}),Nx=Te.create({name:"detailsContent",content:"block+",defining:!0,selectable:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:i}){return["div",be(this.options.HTMLAttributes,i,{"data-type":this.name,contenteditable:!0}),0]},addNodeView(){return({HTMLAttributes:i})=>{const e=document.createElement("div"),t=be(this.options.HTMLAttributes,i,{"data-type":this.name});return Object.entries(t).forEach(([a,n])=>e.setAttribute(a,n)),{dom:e,contentDOM:e,ignoreMutation(a){return a.type==="selection"?!1:!e.contains(a.target)||e===a.target},update:a=>a.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:i})=>{const{state:e,view:t}=i,{selection:a}=e,{$from:n,empty:o}=a,r=_n(T=>T.type===this.type)(a);if(!o||!r||!r.node.childCount)return!1;const l=n.index(r.depth),{childCount:u}=r.node;if(!(u===l+1))return!1;const c=r.node.type.contentMatch.defaultType?.createAndFill();if(!c)return!1;const g=e.doc.resolve(r.pos+1),_=u-1,h=r.node.child(_),F=g.posAtIndex(_,r.depth);if(!h.eq(c))return!1;const p=n.node(-3);if(!p)return!1;const y=n.indexAfter(-3),k=Yu(p.contentMatchAt(y));if(!k||!p.canReplaceWith(y,y,k))return!1;const b=k.createAndFill();if(!b)return!1;const{tr:w}=e,D=n.after(-2);w.replaceWith(D,D,b);const C=w.doc.resolve(D),E=H.near(C,1);w.setSelection(E);const v=F,x=F+h.nodeSize;return w.delete(v,x),w.scrollIntoView(),t.dispatch(w),!0}}}}),Mx=Te.create({name:"detailsSummary",content:"text*",defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"summary"}]},renderHTML({HTMLAttributes:i}){return["summary",be(this.options.HTMLAttributes,i,{contenteditable:!0}),0]}}),Tx=re.create({name:"nodeDragPointerEventsFix",addProseMirrorPlugins(){return[new Z({props:{handleDOMEvents:{dragstart(i,e){const a=e.target;return a&&(document.body.classList.add("tiptap-node-dragging"),a.classList.add("tiptap-node--dragged")),!1},dragend(i,e){return document.body.classList.remove("tiptap-node-dragging"),document.querySelectorAll(".tiptap-node--dragged").forEach(t=>{t.classList.remove("tiptap-node--dragged")}),!1},drop(i,e){return document.body.classList.remove("tiptap-node-dragging"),document.querySelectorAll(".tiptap-node--dragged").forEach(t=>{t.classList.remove("tiptap-node--dragged")}),!1}}}})]}}),Ox=re.create({name:"scopedSelectAll",addKeyboardShortcuts(){return{"Mod-a":({editor:i})=>{const{state:e,view:t}=i,{selection:a,doc:n}=e,{$from:o,$to:r}=a;let l=-1;for(let u=o.depth;u>=0;u--)if(o.node(u).type.name==="container"){l=u;break}if(l>0){const u=o.node(l),d=o.start(l),f=d+u.content.size,c=P.create(n,d,f),g=e.tr.setSelection(c);return t.dispatch(g),!0}return!1}}}}),Ki=s.defineComponent({__name:"BubbleMenuToggleButton",props:{isActive:{type:Boolean,default:!1}},setup(i){return(e,t)=>(s.openBlock(),s.createElementBlock("button",{class:s.normalizeClass(["focus:outline-none focus-visible:outline-0 disabled:cursor-not-allowed disabled:opacity-75 aria-disabled:cursor-not-allowed aria-disabled:opacity-75 flex-shrink-0 font-medium rounded-md text-sm gap-x-1.5 p-1.5 text-stone-900 dark:text-white inline-flex items-center hover:bg-stone-100 shadow-sm focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400",i.isActive?`
137
137
  ring-1 ring-inset ring-stone-300 dark:ring-stone-700