react-reason-editor 1.0.77 → 1.0.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Ai-CfgczVyp.cjs +1 -0
- package/dist/Ai-DsWeNKXF.js +1 -0
- package/dist/Ai.cjs +1 -1
- package/dist/Ai.js +1 -1
- package/dist/{Attachment-bBEf8uOc.js → Attachment-BmQoshq_.js} +1 -1
- package/dist/Attachment.cjs +1 -1
- package/dist/Attachment.js +1 -1
- package/dist/{Blockquote-Cw5Zty9X.js → Blockquote-cNS4L62L.js} +1 -1
- package/dist/Blockquote.cjs +1 -1
- package/dist/Blockquote.js +1 -1
- package/dist/{Bold-BwuX7fZs.js → Bold-DiKXbC2z.js} +1 -1
- package/dist/Bold.cjs +1 -1
- package/dist/Bold.js +1 -1
- package/dist/BubbleMenus-CIOMgQ-M.js +216 -0
- package/dist/BubbleMenus-vqNuXWlm.cjs +1 -0
- package/dist/BulletList.cjs +1 -1
- package/dist/BulletList.js +1 -1
- package/dist/{Callout-CJofZEpX.js → Callout-BLkbFKjv.js} +1 -1
- package/dist/{Callout-wjo2BYZi.cjs → Callout-CpkjGEBS.cjs} +1 -1
- package/dist/Callout.cjs +1 -1
- package/dist/Callout.js +1 -1
- package/dist/Clear.cjs +1 -1
- package/dist/Clear.js +1 -1
- package/dist/{Code-CtIvf6_L.js → Code-DvYJ892R.js} +1 -1
- package/dist/Code.cjs +1 -1
- package/dist/Code.js +1 -1
- package/dist/{CodeBlock-DoIb7GC2.js → CodeBlock-B3dLyClh.js} +1 -1
- package/dist/CodeBlock.cjs +1 -1
- package/dist/CodeBlock.js +1 -1
- package/dist/CodeView.cjs +1 -1
- package/dist/CodeView.js +1 -1
- package/dist/{Color-DSs2MkQU.js → Color-Cng09GRR.js} +1 -1
- package/dist/{Color-B9PloDr5.cjs → Color-ZjBs7t7J.cjs} +1 -1
- package/dist/Color.cjs +1 -1
- package/dist/Color.js +1 -1
- package/dist/{Column-BXSoMVXw.cjs → Column-BaMOYvoO.cjs} +1 -1
- package/dist/{Column-CrT9596v.js → Column-DO6MfrOQ.js} +1 -1
- package/dist/Column.cjs +1 -1
- package/dist/Column.js +1 -1
- package/dist/{Drawer-CfcCPGCn.cjs → Drawer-CC24iVYp.cjs} +1 -1
- package/dist/{Drawer-DuQ5tw2t.js → Drawer-CL5Rhqw4.js} +1 -1
- package/dist/Drawer.cjs +1 -1
- package/dist/Drawer.js +1 -1
- package/dist/{Drawio-DQEgw3du.cjs → Drawio-CD_Tea_o.cjs} +1 -1
- package/dist/{Drawio-P620K_Ps.js → Drawio-LEtUoVAY.js} +1 -1
- package/dist/Drawio.cjs +1 -1
- package/dist/Drawio.js +1 -1
- package/dist/{Emoji-CYM4tY7s.js → Emoji-DN3yfwz_.js} +1 -1
- package/dist/Emoji.cjs +1 -1
- package/dist/Emoji.js +1 -1
- package/dist/{ExportPdf-BoD_D91q.js → ExportPdf-CrQVmD4l.js} +1 -1
- package/dist/ExportPdf.cjs +1 -1
- package/dist/ExportPdf.js +1 -1
- package/dist/{ExportWord-Bj9q_cyK.js → ExportWord-BM4ogH_i.js} +1 -1
- package/dist/ExportWord.cjs +1 -1
- package/dist/ExportWord.js +1 -1
- package/dist/FontFamily.cjs +1 -1
- package/dist/FontFamily.js +1 -1
- package/dist/FontSize.cjs +1 -1
- package/dist/FontSize.js +1 -1
- package/dist/{Heading-BHOPoy3X.js → Heading-Bcrl3eKU.js} +1 -1
- package/dist/Heading.cjs +1 -1
- package/dist/Heading.js +1 -1
- package/dist/{Highlight-BxKQNHmT.cjs → Highlight-cO9V18Me.cjs} +1 -1
- package/dist/{Highlight-3SpxpGDw.js → Highlight-uXDlNgw3.js} +1 -1
- package/dist/Highlight.cjs +1 -1
- package/dist/Highlight.js +1 -1
- package/dist/{History-CmI6jUTV.js → History-BoHiw0Bn.js} +1 -1
- package/dist/History.cjs +1 -1
- package/dist/History.js +1 -1
- package/dist/{HorizontalRule-BeLfU92F.js → HorizontalRule-C7mAKdzL.js} +1 -1
- package/dist/HorizontalRule.cjs +1 -1
- package/dist/HorizontalRule.js +1 -1
- package/dist/{Iframe-D-WaYtdF.cjs → Iframe-DGL_MOLf.cjs} +1 -1
- package/dist/{Iframe-C0ozlEX4.js → Iframe-D_IjezyZ.js} +1 -1
- package/dist/Iframe.cjs +1 -1
- package/dist/Iframe.js +1 -1
- package/dist/Image.cjs +1 -1
- package/dist/Image.js +1 -1
- package/dist/{ImageCropper-BVl7AuRL.js → ImageCropper-ChOGJuHZ.js} +1 -1
- package/dist/{ImageCropper-DqHxEOtN.cjs → ImageCropper-DDWnFI2-.cjs} +1 -1
- package/dist/{ImageGif-BSVyqEv6.cjs → ImageGif-3dik7FeU.cjs} +1 -1
- package/dist/{ImageGif-BvthT-Lc.js → ImageGif-D_kKkBU5.js} +1 -1
- package/dist/ImageGif.cjs +1 -1
- package/dist/ImageGif.js +1 -1
- package/dist/{ImportWord-C6EnXbyR.js → ImportWord-CtFBb_n4.js} +1 -1
- package/dist/ImportWord.cjs +1 -1
- package/dist/ImportWord.js +1 -1
- package/dist/{Indent-BuzxHbMb.js → Indent-BIk98fDV.js} +1 -1
- package/dist/{Indent-eL-WNEF4.cjs → Indent-BVMl9zKV.cjs} +1 -1
- package/dist/Indent.cjs +1 -1
- package/dist/Indent.js +1 -1
- package/dist/{Italic-D8ZI09FZ.js → Italic-3mlmsxqN.js} +1 -1
- package/dist/Italic.cjs +1 -1
- package/dist/Italic.js +1 -1
- package/dist/{Katex-46mDLDuw.cjs → Katex-C2AcX_Un.cjs} +1 -1
- package/dist/{Katex-B-lo5eMz.js → Katex-DRPWO2AM.js} +1 -1
- package/dist/Katex.cjs +1 -1
- package/dist/Katex.js +1 -1
- package/dist/LineHeight.cjs +1 -1
- package/dist/LineHeight.js +1 -1
- package/dist/{Link-CDtipqwb.js → Link-D5y_0ekP.js} +1 -1
- package/dist/Link.cjs +1 -1
- package/dist/Link.js +1 -1
- package/dist/{LinkEditBlock-D0V9PwbF.cjs → LinkEditBlock-D78J06F7.cjs} +1 -1
- package/dist/MarkdownPaste.cjs +1 -1
- package/dist/MarkdownPaste.js +1 -1
- package/dist/{Mermaid-DDV93CBT.cjs → Mermaid-B6SL3cf5.cjs} +1 -1
- package/dist/{Mermaid-Cb8MiE1N.js → Mermaid-BaTtCsrD.js} +1 -1
- package/dist/Mermaid.cjs +1 -1
- package/dist/Mermaid.js +1 -1
- package/dist/{MoreMark-CJ3nTD1T.js → MoreMark-Bfsa3STU.js} +1 -1
- package/dist/MoreMark.cjs +1 -1
- package/dist/MoreMark.js +1 -1
- package/dist/OrderedList.cjs +1 -1
- package/dist/OrderedList.js +1 -1
- package/dist/{ReasonDocs-BliNN1Tt.cjs → ReasonDocs-Bjefr26w.cjs} +1 -1
- package/dist/{ReasonDocs-4vxZ3zY7.js → ReasonDocs-_hTAa8-q.js} +1 -1
- package/dist/{RichTextProvider-Dl77gVJI.cjs → RichTextProvider-BuTrDlZY.cjs} +1 -1
- package/dist/{RichTextProvider-E6rbc_J2.js → RichTextProvider-D9EtjDKS.js} +1 -1
- package/dist/SearchAndReplace.cjs +1 -1
- package/dist/SearchAndReplace.js +1 -1
- package/dist/{SlashCommand-DtlUkwyM.js → SlashCommand-Cg-Rvv3o.js} +1 -1
- package/dist/SlashCommand.js +1 -1
- package/dist/{Strike-CWYl45VK.js → Strike-CSxbYwpk.js} +1 -1
- package/dist/Strike.cjs +1 -1
- package/dist/Strike.js +1 -1
- package/dist/{Table-DCLsW5DJ.js → Table-CFcOg-4n.js} +1 -1
- package/dist/{Table-C9RAHNEk.cjs → Table-Do_kTawS.cjs} +1 -1
- package/dist/Table.cjs +1 -1
- package/dist/Table.js +1 -1
- package/dist/TaskList.cjs +1 -1
- package/dist/TaskList.js +1 -1
- package/dist/{TextAlign-D4UgbJ7F.cjs → TextAlign-CcsTIs-9.cjs} +1 -1
- package/dist/{TextAlign-9ezg8E99.js → TextAlign-Dun3_Ozv.js} +1 -1
- package/dist/TextAlign.cjs +1 -1
- package/dist/TextAlign.js +1 -1
- package/dist/TextDirection.cjs +1 -1
- package/dist/TextDirection.js +1 -1
- package/dist/{TextUnderline-C5A078R0.js → TextUnderline-Cqm5NQVW.js} +1 -1
- package/dist/TextUnderline.cjs +1 -1
- package/dist/TextUnderline.js +1 -1
- package/dist/{Twitter-D7ulyHFD.cjs → Twitter-B4IYTs3E.cjs} +1 -1
- package/dist/{Twitter-ByGJ4v1K.js → Twitter-CZHAICpz.js} +1 -1
- package/dist/Twitter.cjs +1 -1
- package/dist/Twitter.js +1 -1
- package/dist/{Video-hhw77FP4.js → Video-5nw_Zeob.js} +1 -1
- package/dist/{Video-ConJGjxP.cjs → Video-CtGR5VVD.cjs} +1 -1
- package/dist/Video.cjs +1 -1
- package/dist/Video.js +1 -1
- package/dist/WordCount.cjs +1 -1
- package/dist/WordCount.js +1 -1
- package/dist/bubble-BhkjoWdo.js +79 -0
- package/dist/bubble.cjs +1 -1
- package/dist/bubble.js +1 -1
- package/dist/{cdn-loader-BGIuN138-wkFA6jnE.cjs → cdn-loader-BGIuN138-7PrAg-Ef.cjs} +1 -1
- package/dist/docs-agent.cjs +1 -1
- package/dist/docs-agent.js +1 -1
- package/dist/editor-kit.cjs +1 -1
- package/dist/editor-kit.js +1 -1
- package/dist/editorConfig-BR7z-P0e.js +18 -0
- package/dist/editorConfig-CHBSp2KG.cjs +1 -0
- package/dist/extensions/Ai/Ai.d.ts +22 -5
- package/dist/extensions/Ai/commands.d.ts +6 -1
- package/dist/extensions/Ai/components/AiMenu.d.ts +6 -5
- package/dist/extensions/Ai/components/RichTextAi.d.ts +12 -0
- package/dist/extensions/Ai/index.d.ts +9 -3
- package/dist/extensions/Ai/lib/completionToContent.d.ts +35 -0
- package/dist/extensions/Ai/lib/createStreamingCompletion.d.ts +27 -0
- package/dist/extensions/Ai/lib/prompt.d.ts +38 -0
- package/dist/extensions/Ai/lib/sanitizeCompletion.d.ts +37 -0
- package/dist/extensions/Ai/types.d.ts +47 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/marked.esm-B7mQ2Kzc.cjs +1 -0
- package/dist/marked.esm-CNm6O672.js +1 -0
- package/dist/{react-BQVDEMs2.cjs → react-Bfe0Tko8.cjs} +1 -1
- package/dist/reason-docs.cjs +1 -1
- package/dist/reason-docs.js +1 -1
- package/dist/{reason-toolbar-skin-9xQLtzeK.js → reason-toolbar-skin-BNYK97ET.js} +1 -1
- package/dist/{reason-toolbar-skin-DyYu9ywU.cjs → reason-toolbar-skin-CD4T53He.cjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/useButtonProps-BBiR6DPI.cjs +1 -0
- package/dist/useButtonProps-Codtb0k0.js +1 -0
- package/package.json +1 -1
- package/dist/Ai-BGpnAE8s.js +0 -1
- package/dist/Ai-CORhNCSN.cjs +0 -1
- package/dist/BubbleMenus-QlttKSIN.cjs +0 -1
- package/dist/BubbleMenus-mwxYB3IU.js +0 -195
- package/dist/MarkdownPaste-C5jQ33SR.js +0 -1
- package/dist/bubble-CpeBzXMe.js +0 -78
- package/dist/editorConfig-D-Tlrdwj.js +0 -18
- package/dist/editorConfig-Du7YaEDm.cjs +0 -1
- package/dist/useButtonProps-BFfsKvCi.cjs +0 -1
- package/dist/useButtonProps-BZwO1Of-.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-BeavJI0R.cjs"),t=require("./dist-2-kjLBhJ.cjs"),n=require("./editorConfig-Du7YaEDm.cjs"),r=require("./toggle-JU5XOZYT.cjs"),s=require("./locales-DRkmn37v.cjs"),i=require("./floating-ui.dom-DG-jWCyc.cjs"),o=require("./useButtonProps-BFfsKvCi.cjs"),l=require("./theme.cjs"),a=require("./cdn-loader-BGIuN138-wkFA6jnE.cjs"),c=require("./Harper-nz_06NJH.cjs"),d=require("./Drawio-DQEgw3du.cjs"),h=require("./ReadAloud.cjs"),u=require("./Transcribe.cjs"),p=require("./SelectSimilar.cjs"),f=require("./Ai-CORhNCSN.cjs"),g=require("./WordCount.cjs");let m=require("@tiptap/react"),x=require("react");x=e.__toESM(x,1);let b=require("@tiptap/core"),y=require("@tiptap/pm/state"),v=require("react/jsx-runtime"),w=require("lucide-react"),k=require("react-dom"),S=require("@tiptap/react/menus"),j=require("@tiptap/pm/view"),C=require("@tiptap/pm/model"),N=require("use-voice-control/react"),E=require("easydrawer"),A=require("@tiptap/pm/commands"),_=require("use-voice-control/client");function T({children:e,label:n,className:r,icon:s,shortcut:i}){const o=(0,x.useRef)(null),l=(0,x.isValidElement)(e)?(0,x.cloneElement)(e,{tooltip:n?void 0:e.props?.tooltip,tooltipOptions:n?void 0:e.props?.tooltipOptions}):e;return(0,v.jsxs)("div",{ref:o,className:t.cn("flex items-center gap-2 px-2 py-0.5 rounded cursor-pointer w-full text-left","hover:bg-gray-100/80 dark:hover:bg-slate-800/80","transition-colors",r),onClick:e=>{e.stopPropagation(),e.target.closest('button, [role="button"], a')||(o.current?.querySelector("button"))?.click()},children:[s&&(0,v.jsx)("span",{className:"w-5 flex items-center justify-center text-gray-500 dark:text-gray-400 shrink-0",children:s}),(0,v.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[l,n&&(0,v.jsx)("span",{className:"text-xs whitespace-nowrap truncate",children:n}),i&&(0,v.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-gray-500 ml-auto whitespace-nowrap shrink-0",children:i})]})]})}function M(){const e=o.useButtonProps("subscript"),{icon:t,tooltip:n,shortcutKeys:s,tooltipOptions:i={},action:l,isActive:a}=e?.componentProps??{},{dataState:c,disabled:d,update:h}=o.useToggleActive(a);return e?(0,v.jsx)(r.ActionButton,{action:()=>{d||l&&(l(),h())},dataState:c,disabled:d,icon:t,shortcutKeys:s,tooltip:n,tooltipOptions:i}):(0,v.jsx)(v.Fragment,{})}function D(){const e=o.useButtonProps("superscript"),{icon:t,tooltip:n,shortcutKeys:s,tooltipOptions:i={},action:l,isActive:a}=e?.componentProps??{},{dataState:c,disabled:d,update:h}=o.useToggleActive(a);return e?(0,v.jsx)(r.ActionButton,{action:()=>{d||l&&(l(),h())},dataState:c,disabled:d,icon:t,shortcutKeys:s,tooltip:n,tooltipOptions:i}):(0,v.jsx)(v.Fragment,{})}function O({message:e}){const[t,n]=(0,x.useState)(!0);return(0,x.useEffect)(()=>{const e=setTimeout(()=>n(!1),2e3);return()=>clearTimeout(e)},[]),t?(0,k.createPortal)((0,v.jsx)("div",{className:"fixed bottom-4 right-4 z-[100] animate-in fade-in slide-in-from-bottom-2",children:(0,v.jsx)("div",{className:"bg-gray-900 dark:bg-gray-800 text-white px-4 py-2.5 rounded-lg shadow-lg text-sm font-medium",children:e})}),document.body):null}function $(){const{editor:e}=(0,m.useCurrentEditor)(),[t,n]=(0,x.useState)(1.25),[r,s]=(0,x.useState)(null),i=e=>{s(e)},o=(0,x.useCallback)(t=>{const n=e?.view?.dom??document.querySelector(".ProseMirror");if(!n)return;const r=n;r.style.zoom=String(t),r.style.transform="",r.style.transformOrigin=""},[e]);return(0,x.useEffect)(()=>{o(t)},[o,t]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-0.5",children:[(0,v.jsx)("button",{onClick:()=>{const e=Math.max(t-.25,.5);n(e),o(e),i(`Zoom: ${Math.round(100*e)}%`)},title:`Zoom Out (${Math.round(100*t)}%)`,className:"richtext-p-1 richtext-h-8 richtext-flex richtext-items-center richtext-justify-center richtext-rounded text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-slate-800 hover:text-gray-900 dark:hover:text-white transition-colors",children:(0,v.jsx)(w.ZoomOut,{size:16})}),(0,v.jsx)("button",{onClick:()=>{const e=Math.min(t+.25,2);n(e),o(e),i(`Zoom: ${Math.round(100*e)}%`)},title:`Zoom In (${Math.round(100*t)}%)`,className:"richtext-p-1 richtext-h-8 richtext-flex richtext-items-center richtext-justify-center richtext-rounded text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-slate-800 hover:text-gray-900 dark:hover:text-white transition-colors",children:(0,v.jsx)(w.ZoomIn,{size:16})})]}),r&&(0,v.jsx)(O,{message:r})]})}var R={a4:{name:"A4",pageHeight:1123,pageWidth:794,marginTop:72,marginBottom:72,marginLeft:72,marginRight:72},a3:{name:"A3",pageHeight:1591,pageWidth:1123,marginTop:72,marginBottom:72,marginLeft:72,marginRight:72},letter:{name:"Letter",pageHeight:1100,pageWidth:850,marginTop:72,marginBottom:72,marginLeft:72,marginRight:72},legal:{name:"Legal",pageHeight:1400,pageWidth:850,marginTop:72,marginBottom:72,marginLeft:72,marginRight:72}};function I(){const{editor:e}=(0,m.useCurrentEditor)(),[t,n]=(0,x.useState)(!1),[r,s]=(0,x.useState)("page"),[i,o]=(0,x.useState)({pageHeight:1056,pageWidth:816,pageGap:50,pageGapBorderSize:1,pageGapBorderColor:"#e5e5e5",pageBreakBackground:"#ffffff",marginTop:48,marginBottom:48,marginLeft:72,marginRight:72,contentMarginTop:10,contentMarginBottom:10,headerLeft:"",headerRight:"Page {page}",footerLeft:"",footerRight:""}),l=(0,x.useRef)(null),a=(0,x.useRef)(null),[c,d]=(0,x.useState)({top:0,left:-9999,visibility:"hidden"});if((0,x.useEffect)(()=>{if(!t)return;const e=e=>{const t=e.target;t?.isConnected&&(l.current?.contains(t)||a.current?.contains(t)||n(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,x.useLayoutEffect)(()=>{if(!t)return;const e=()=>{const e=a.current,t=l.current;if(!e||!t)return;const n=window.innerWidth,r=window.innerHeight,s=t.getBoundingClientRect(),i=t.closest(".dropdown-portal")?.getBoundingClientRect()??s,{offsetWidth:o,offsetHeight:c}=e;let h=i.right+8;h+o>n-8&&(h=i.left-o-8),h=Math.max(8,Math.min(h,n-o-8));const u=Math.max(8,Math.min(s.top,r-c-8));d({top:u,left:h,maxHeight:r-u-8})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[t,r]),!e)return null;const h=t=>{const n={...i,...t};o(n),t.pageHeight&&e.commands.updatePageHeight?.(t.pageHeight),t.pageWidth&&e.commands.updatePageWidth?.(t.pageWidth),t.pageGap&&e.commands.updatePageGap?.(t.pageGap),(t.marginTop||t.marginBottom||t.marginLeft||t.marginRight)&&e.commands.updateMargins?.({top:t.marginTop??i.marginTop,bottom:t.marginBottom??i.marginBottom,left:t.marginLeft??i.marginLeft,right:t.marginRight??i.marginRight}),(t.contentMarginTop||t.contentMarginBottom)&&e.commands.updateContentMargins?.({top:t.contentMarginTop??i.contentMarginTop,bottom:t.contentMarginBottom??i.contentMarginBottom}),(t.headerLeft||t.headerRight)&&e.commands.updateHeaderContent?.(t.headerLeft??i.headerLeft,t.headerRight??i.headerRight),(t.footerLeft||t.footerRight)&&e.commands.updateFooterContent?.(t.footerLeft??i.footerLeft,t.footerRight??i.footerRight),t.pageBreakBackground&&e.commands.updatePageBreakBackground?.(t.pageBreakBackground)};return(0,v.jsxs)("div",{className:"relative",ref:l,children:[(0,v.jsxs)("button",{onClick:()=>n(!t),className:"flex items-center gap-1 px-2 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-800 rounded transition-colors",title:"Page settings",children:[(0,v.jsx)(w.Settings,{className:"w-4 h-4"}),(0,v.jsx)(w.ChevronDown,{className:"w-3 h-3"})]}),t&&(0,k.createPortal)((0,v.jsxs)("div",{ref:a,"data-richtext-portal":!0,className:"dropdown-portal fixed flex flex-col overflow-hidden bg-white dark:bg-gray-900 border dark:border-gray-700 rounded-lg shadow-2xl z-50 w-96 max-w-[calc(100vw-16px)]",style:c,children:[(0,v.jsx)("div",{className:"flex border-b dark:border-gray-700 shrink-0",children:["page","spacing","header-footer"].map(e=>(0,v.jsxs)("button",{onClick:()=>s(e),className:"flex-1 px-3 py-2 text-sm font-medium transition-colors "+(r===e?"border-b-2 border-blue-500 text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"),children:["page"===e&&"Page","spacing"===e&&"Spacing","header-footer"===e&&"Header/Footer"]},e))}),(0,v.jsxs)("div",{className:"flex-1 min-h-0 p-4 space-y-4 overflow-y-auto",children:["page"===r&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs font-semibold mb-2 text-gray-700 dark:text-gray-300",children:"Presets"}),(0,v.jsx)("div",{className:"grid grid-cols-4 gap-2",children:Object.entries(R).map(([e,t])=>(0,v.jsx)("button",{onClick:()=>(e=>{h({pageHeight:e.pageHeight,pageWidth:e.pageWidth,marginTop:e.marginTop,marginBottom:e.marginBottom,marginLeft:e.marginLeft,marginRight:e.marginRight})})(t),className:"px-2 py-1 text-xs bg-gray-50 dark:bg-gray-800 border dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:t.name},e))})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs font-semibold mb-1 text-gray-700 dark:text-gray-300",children:"Page Height (px)"}),(0,v.jsx)("input",{type:"number",value:i.pageHeight,onChange:e=>h({pageHeight:Number(e.target.value)}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100",min:400,max:2e3})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs font-semibold mb-1 text-gray-700 dark:text-gray-300",children:"Page Width (px)"}),(0,v.jsx)("input",{type:"number",value:i.pageWidth,onChange:e=>h({pageWidth:Number(e.target.value)}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100",min:400,max:2e3})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs font-semibold mb-1 text-gray-700 dark:text-gray-300",children:"Page Gap (px)"}),(0,v.jsx)("input",{type:"number",value:i.pageGap,onChange:e=>h({pageGap:Number(e.target.value)}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100",min:0,max:100})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs font-semibold mb-1 text-gray-700 dark:text-gray-300",children:"Gap Border Color"}),(0,v.jsxs)("div",{className:"flex gap-2",children:[(0,v.jsx)("input",{type:"color",value:i.pageGapBorderColor,onChange:e=>h({pageGapBorderColor:e.target.value}),className:"w-10 h-9 rounded cursor-pointer"}),(0,v.jsx)("input",{type:"text",value:i.pageGapBorderColor,onChange:e=>h({pageGapBorderColor:e.target.value}),className:"flex-1 px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100"})]})]})]}),"spacing"===r&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)("label",{className:"block text-xs font-semibold text-gray-700 dark:text-gray-300",children:"Page Margins (px)"}),(0,v.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:"Top"}),(0,v.jsx)("input",{type:"number",value:i.marginTop,onChange:e=>h({marginTop:Number(e.target.value)}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100",min:0,max:200})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:"Bottom"}),(0,v.jsx)("input",{type:"number",value:i.marginBottom,onChange:e=>h({marginBottom:Number(e.target.value)}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100",min:0,max:200})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:"Left"}),(0,v.jsx)("input",{type:"number",value:i.marginLeft,onChange:e=>h({marginLeft:Number(e.target.value)}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100",min:0,max:200})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:"Right"}),(0,v.jsx)("input",{type:"number",value:i.marginRight,onChange:e=>h({marginRight:Number(e.target.value)}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100",min:0,max:200})]})]})]}),(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)("label",{className:"block text-xs font-semibold text-gray-700 dark:text-gray-300",children:"Content Margins (px)"}),(0,v.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:"Top"}),(0,v.jsx)("input",{type:"number",value:i.contentMarginTop,onChange:e=>h({contentMarginTop:Number(e.target.value)}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100",min:0,max:50})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:"Bottom"}),(0,v.jsx)("input",{type:"number",value:i.contentMarginBottom,onChange:e=>h({contentMarginBottom:Number(e.target.value)}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100",min:0,max:50})]})]})]})]}),"header-footer"===r&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs font-semibold mb-1 text-gray-700 dark:text-gray-300",children:"Header Left (supports HTML)"}),(0,v.jsx)("textarea",{value:i.headerLeft,onChange:e=>h({headerLeft:e.target.value}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono",rows:3,placeholder:"e.g., <strong>Company Name</strong>"})]}),(0,v.jsxs)("div",{children:[(0,v.jsxs)("label",{className:"block text-xs font-semibold mb-1 text-gray-700 dark:text-gray-300",children:["Header Right (use ","{page}"," for page number)"]}),(0,v.jsx)("textarea",{value:i.headerRight,onChange:e=>h({headerRight:e.target.value}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono",rows:3,placeholder:"e.g., Page {page}"})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("label",{className:"block text-xs font-semibold mb-1 text-gray-700 dark:text-gray-300",children:"Footer Left (supports HTML)"}),(0,v.jsx)("textarea",{value:i.footerLeft,onChange:e=>h({footerLeft:e.target.value}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono",rows:3,placeholder:"e.g., <em>Confidential</em>"})]}),(0,v.jsxs)("div",{children:[(0,v.jsxs)("label",{className:"block text-xs font-semibold mb-1 text-gray-700 dark:text-gray-300",children:["Footer Right (use ","{page}"," for page number)"]}),(0,v.jsx)("textarea",{value:i.footerRight,onChange:e=>h({footerRight:e.target.value}),className:"w-full px-2 py-1 border dark:border-gray-700 rounded text-sm bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono",rows:3,placeholder:"e.g., Page {page} of {total}"})]})]})]})]}),document.body)]})}var P=[1,2,3,4];function z({editor:e,onClose:t,defaultLevel:n=3}){const[r,s]=(0,x.useState)([]),[i,o]=(0,x.useState)(""),[l,a]=(0,x.useState)(n),[c,d]=(0,x.useState)(null);(0,x.useEffect)(()=>{if(!e)return;const t=()=>{const t=[];e.state.doc.descendants((e,n)=>{"heading"===e.type.name&&t.push({level:e.attrs.level,text:e.textContent,pos:n,index:t.length})}),s(t)};return t(),e.on("update",t),()=>e.off("update",t)},[e]);const h=(0,x.useMemo)(()=>{const e=i.trim().toLowerCase();return r.filter(t=>t.level<=l&&(""===e||t.text.toLowerCase().includes(e)))},[r,i,l]),u=(0,x.useCallback)(t=>{if(!e)return;const n=e.view.nodeDOM(t);n&&"function"==typeof n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"start"}),e.chain().focus().setTextSelection(t+1).run(),d(t)},[e]);return(0,k.createPortal)((0,v.jsxs)("div",{className:"fixed right-4 top-24 z-50 flex w-72 max-h-[70vh] flex-col rounded-lg border border-gray-200/60 bg-white/80 shadow-xl backdrop-blur-md dark:border-slate-700/60 dark:bg-slate-900/80",children:[(0,v.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-100 px-3 py-2 dark:border-slate-700",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(w.ListTree,{size:15,className:"text-blue-500"}),(0,v.jsx)("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Table of Contents"})]}),(0,v.jsx)("button",{onClick:t,title:"Hide table of contents",className:"rounded p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-slate-800",children:(0,v.jsx)(w.X,{size:14})})]}),(0,v.jsxs)("div",{className:"border-b border-gray-100 px-3 py-2 dark:border-slate-700",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-gray-200 bg-white px-2 py-1.5 dark:border-slate-700 dark:bg-slate-800",children:[(0,v.jsx)(w.Search,{size:13,className:"shrink-0 text-gray-400"}),(0,v.jsx)("input",{type:"text",value:i,onChange:e=>o(e.target.value),placeholder:"Filter headings…",className:"w-full bg-transparent text-xs text-gray-700 outline-none placeholder:text-gray-400 dark:text-gray-200"}),i&&(0,v.jsx)("button",{onClick:()=>o(""),className:"shrink-0 text-gray-400 hover:text-gray-600",title:"Clear filter",children:(0,v.jsx)(w.X,{size:12})})]}),(0,v.jsxs)("div",{className:"mt-2 flex items-center gap-1",children:[(0,v.jsx)("span",{className:"mr-1 text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Level"}),P.map(e=>(0,v.jsxs)("button",{onClick:()=>a(e),title:`Unfold headings up to H${e}`,className:"flex-1 rounded px-1.5 py-1 text-[11px] font-medium transition-colors "+(l===e?"bg-blue-500 text-white":"border border-gray-200 text-gray-600 hover:bg-gray-100 dark:border-slate-700 dark:text-gray-300 dark:hover:bg-slate-800"),children:["H",e]},e))]})]}),(0,v.jsx)("nav",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:0===h.length?(0,v.jsx)("div",{className:"px-2 py-6 text-center text-xs text-gray-400",children:0===r.length?"No headings yet.":"No headings match your filter."}):h.map(e=>(0,v.jsx)("button",{onClick:()=>u(e.pos),style:{paddingLeft:12*(e.level-1)+8+"px"},className:"block w-full truncate rounded py-1.5 pr-2 text-left text-xs transition-colors "+(c===e.pos?"bg-blue-50 font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-300":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-800"),children:e.text||`Heading ${e.level}`},e.pos))})]}),document.body)}function L({editor:e,className:n}){const[r,s]=(0,x.useState)(null),i=(0,x.useRef)(null),o=(0,x.useCallback)(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),l=(0,x.useCallback)(()=>{o(),i.current=setTimeout(()=>s(null),120)},[o]),a=(0,x.useCallback)(t=>{if(!e)return;const n=t.getAttribute("data-harper-id");if(!n)return;const r=c.getHarperState(e.state)?.issues.get(n);if(!r)return;const i=t.getBoundingClientRect();o(),s({issue:r,top:i.bottom+6,left:i.left})},[e,o]);if((0,x.useEffect)(()=>{if(!e)return;const t=e.view.dom,n=e=>{const t=e.target?.closest("[data-harper-id]");t&&a(t)},r=e=>{e.relatedTarget?.closest("[data-harper-id]")||l()};return t.addEventListener("mouseover",n),t.addEventListener("mouseout",r),()=>{t.removeEventListener("mouseover",n),t.removeEventListener("mouseout",r)}},[e,a,l]),!e||!r)return null;const{issue:d,top:h,left:u}=r;return(0,v.jsxs)("div",{role:"dialog","aria-label":"Proofing suggestion",className:t.cn("harper-tooltip",n),style:{position:"fixed",top:h,left:u,zIndex:60},onMouseEnter:o,onMouseLeave:l,children:[(0,v.jsx)("div",{className:"harper-tooltip-header",children:(0,v.jsx)("span",{className:"harper-tooltip-kind",children:d.kind})}),(0,v.jsx)("p",{className:"harper-tooltip-message",children:d.message}),(0,v.jsxs)("div",{className:"harper-tooltip-actions",children:[0===d.suggestions.length?(0,v.jsx)("span",{className:"harper-tooltip-empty",children:"No suggestions"}):d.suggestions.map((t,n)=>(0,v.jsx)("button",{type:"button",className:"harper-tooltip-suggestion",onClick:()=>(t=>{e.chain().focus().applyHarperSuggestion(d.id,t).run(),s(null)})(n),children:t.label||"(empty)"},`${t.kind}-${t.replacement}-${n}`)),(0,v.jsx)("button",{type:"button",className:"harper-tooltip-ignore",onClick:()=>{e.chain().focus().ignoreHarperSuggestion(d.id).run(),s(null)},children:"Ignore"})]})]})}var B={available:!1,state:"idle",isActive:!1,isSpeaking:!1,isPaused:!1,currentChunk:null,error:null};var F={available:!1,isListening:!1,partial:"",lastPhrase:"",phraseId:0,error:null};function V(e){const t=(0,x.useCallback)(t=>e?u.subscribeTranscribe(e,t):()=>{},[e]);if("none"===(0,x.useSyncExternalStore)(t,()=>{const t=e?u.getTranscribeStorage(e):void 0;return t?`${t.listening}|${t.phraseId}|${t.error?.message??""}`:"none"},()=>"none")||!e)return F;const n=u.getTranscribeStorage(e);return n?{available:!0,isListening:n.listening,partial:n.partial,lastPhrase:n.lastPhrase,phraseId:n.phraseId,error:n.error}:F}function W({editor:e,durationMs:t=2e3}){const{isListening:n,lastPhrase:r,phraseId:s}=V(e);return(0,v.jsx)(N.SpokenPhraseOverlay,{durationMs:t,phrase:r,phraseId:s,visible:n})}var H=[".dropdown-container",".dropdown-portal","[data-richtext-portal]","[data-radix-popper-content-wrapper]","[data-radix-portal]",'[role="dialog"]','[role="menu"]','[role="listbox"]'].join(",");var U="rte-custom-styles",q="rte-custom-style-presets",J="rte-active-style-preset";function K(e){(function(e){const t=e;return!!t?.closest&&!t.closest('input, textarea, select, [contenteditable="true"], [role="textbox"]')&&!!t.closest('button, [role="button"], [role="menuitem"], [role="menuitemcheckbox"]')})(e.target)&&e.preventDefault()}function G(e){const t=(0,x.useRef)(!1);return{onMouseDown:e=>{t.current=e.target===e.currentTarget},onClick:n=>{t.current&&n.target===n.currentTarget&&(t.current=!1,e())}}}function X({onClose:e}){const[t,n]=(0,x.useState)(()=>{try{const e=localStorage.getItem(q);return e?JSON.parse(e):[{id:"1",name:"Default",rules:[{id:1,selector:".ProseMirror p",property:"font-size",value:"16px"},{id:2,selector:".ProseMirror h1",property:"color",value:"#111827"}],active:!0}]}catch{return[]}}),[r,s]=(0,x.useState)(()=>{try{return localStorage.getItem(J)||t[0]?.id||"1"}catch{return"1"}}),[i,o]=(0,x.useState)(null),[l,a]=(0,x.useState)(""),c=t.find(e=>e.id===r)||t[0],[d,h]=(0,x.useState)(c?.rules||[]),u=(0,x.useRef)(d.length?Math.max(...d.map(e=>e.id),0)+1:1),p=e=>{let t=document.getElementById(U);t||(t=document.createElement("style"),t.id=U,document.head.appendChild(t)),t.textContent=e.filter(e=>e.selector&&e.property&&e.value).map(e=>`${e.selector} { ${e.property}: ${e.value}; }`).join("\n")},f=e=>{const n=t.find(t=>t.id===e);n&&(s(e),h([...n.rules]),p(n.rules),localStorage.setItem(J,e))},g=()=>{if(t.length>=10)return void alert("Maximum 10 style presets allowed");if(!l.trim())return void alert("Please enter a name for the preset");const e=Math.max(...t.map(e=>parseInt(e.id)),0)+1,r={id:String(e),name:l,rules:[{id:1,selector:".ProseMirror p",property:"font-size",value:"16px"}],active:!1},s=[...t,r];n(s),localStorage.setItem(q,JSON.stringify(s)),a(""),f(r.id)},m=(e,r)=>{if(!r.trim())return;const s=t.map(t=>t.id===e?{...t,name:r}:t);n(s),localStorage.setItem(q,JSON.stringify(s)),o(null)},b=(e,t,n)=>h(r=>r.map(r=>r.id===e?{...r,[t]:n}:r)),y=G(e);return(0,k.createPortal)((0,v.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[(0,v.jsx)("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",...y}),(0,v.jsxs)("div",{className:"relative bg-white dark:bg-slate-900 border border-gray-200 dark:border-slate-700 rounded-xl shadow-2xl w-[640px] max-h-[85vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,v.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 dark:border-slate-700",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(w.Paintbrush,{size:16,className:"text-blue-500"}),(0,v.jsx)("span",{className:"text-sm font-semibold",children:"Customize Editor Styles"})]}),(0,v.jsx)("button",{onClick:e,className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-slate-800",children:(0,v.jsx)(w.X,{size:14})})]}),(0,v.jsxs)("div",{className:"px-4 py-3 border-b border-gray-100 dark:border-slate-700 space-y-2",children:[(0,v.jsx)("div",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300",children:"Style Presets"}),(0,v.jsx)("div",{className:"flex gap-2 flex-wrap",children:t.map(e=>(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)("button",{onClick:()=>f(e.id),className:"px-3 py-1.5 text-xs rounded transition-colors "+(r===e.id?"bg-blue-500 text-white border-blue-600":"border border-gray-200 dark:border-slate-700 hover:bg-gray-50 dark:hover:bg-slate-800"),children:i===e.id?(0,v.jsx)("input",{autoFocus:!0,type:"text",value:l,onChange:e=>a(e.target.value),onBlur:()=>m(e.id,l),onKeyDown:t=>"Enter"===t.key&&m(e.id,l),className:"w-20 px-1 py-0.5 text-xs bg-transparent border-b border-current outline-none"}):(0,v.jsx)("span",{onDoubleClick:()=>{o(e.id),a(e.name)},children:e.name})}),t.length>1&&(0,v.jsx)("button",{onClick:()=>(e=>{if(t.length<=1)return void alert("Cannot delete the last preset");if(!confirm("Are you sure you want to delete this preset?"))return;const s=t.filter(t=>t.id!==e);n(s),localStorage.setItem(q,JSON.stringify(s)),r===e&&f(s[0].id)})(e.id),className:"p-0.5 rounded text-gray-400 hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:(0,v.jsx)(w.X,{size:12})})]},e.id))}),t.length<10&&(0,v.jsxs)("div",{className:"flex gap-2 pt-2",children:[(0,v.jsx)("input",{type:"text",value:l,onChange:e=>a(e.target.value),placeholder:"New preset name...",onKeyDown:e=>"Enter"===e.key&&g(),className:"flex-1 px-2 py-1.5 text-xs border rounded bg-white dark:bg-slate-800 border-gray-200 dark:border-slate-700"}),(0,v.jsxs)("button",{onClick:g,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs border rounded hover:bg-gray-50 dark:hover:bg-slate-800",children:[(0,v.jsx)(w.Plus,{size:12}),"Add"]})]})]}),(0,v.jsxs)("div",{className:"px-4 py-2 text-xs text-gray-500 dark:text-gray-400 border-b border-gray-100 dark:border-slate-700",children:["CSS rules applied live to the editor. Target ",(0,v.jsx)("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded",children:".ProseMirror"})," elements."]}),(0,v.jsxs)("div",{className:"overflow-y-auto flex-1 p-4 space-y-2",children:[0===d.length&&(0,v.jsx)("div",{className:"text-center text-xs text-gray-400 py-6",children:"No rules yet. Click + Add Rule to begin."}),d.map(e=>(0,v.jsxs)("div",{className:"flex items-center gap-2 group",children:[(0,v.jsx)("input",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs border rounded bg-white dark:bg-slate-800 border-gray-200 dark:border-slate-700 font-mono",placeholder:".ProseMirror p",value:e.selector,onChange:t=>b(e.id,"selector",t.target.value)}),(0,v.jsx)("input",{className:"w-32 px-2 py-1.5 text-xs border rounded bg-white dark:bg-slate-800 border-gray-200 dark:border-slate-700 font-mono",placeholder:"font-size",value:e.property,onChange:t=>b(e.id,"property",t.target.value)}),(0,v.jsx)("input",{className:"w-28 px-2 py-1.5 text-xs border rounded bg-white dark:bg-slate-800 border-gray-200 dark:border-slate-700 font-mono",placeholder:"16px",value:e.value,onChange:t=>b(e.id,"value",t.target.value)}),(0,v.jsx)("button",{onClick:()=>{return t=e.id,h(e=>e.filter(e=>e.id!==t));var t},className:"p-1 rounded text-gray-300 hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,v.jsx)(w.Trash2,{size:13})})]},e.id))]}),(0,v.jsxs)("div",{className:"px-4 py-3 border-t border-gray-100 dark:border-slate-700 flex items-center justify-between",children:[(0,v.jsxs)("button",{onClick:()=>{const e={id:u.current++,selector:"",property:"",value:""};h(t=>[...t,e])},className:"flex items-center gap-1.5 px-3 py-1.5 text-xs border rounded hover:bg-gray-50 dark:hover:bg-slate-800",children:[(0,v.jsx)(w.Plus,{size:12}),"Add Rule"]}),(0,v.jsxs)("div",{className:"flex gap-2",children:[(0,v.jsx)("button",{onClick:e,className:"px-3 py-1.5 text-xs border rounded hover:bg-gray-50 dark:hover:bg-slate-800",children:"Cancel"}),(0,v.jsx)("button",{onClick:()=>{const e=t.map(e=>e.id===r?{...e,rules:[...d]}:e);n(e),localStorage.setItem(q,JSON.stringify(e)),p(d)},className:"px-3 py-1.5 text-xs bg-blue-500 text-white rounded hover:bg-blue-600",children:"Save Style"})]})]})]})]}),document.body)}function Y({children:e,label:t,shortcut:n,icon:r,displayIcon:s}){const i=(0,x.useRef)(null);return(0,v.jsxs)("div",{ref:i,onClick:e=>{e.target.closest('button, [role="button"], a, select')||(i.current?.querySelector('button, [role="button"]'))?.click()},className:"relative flex items-center gap-3 px-3 py-1.5 rounded cursor-pointer hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",children:[(r||s)&&(0,v.jsx)("span",{className:"w-5 flex items-center justify-center text-gray-500 dark:text-gray-400 shrink-0 text-sm font-mono",children:s||r}),(0,v.jsx)("span",{className:"flex-1 text-sm text-gray-700 dark:text-gray-200",children:t}),n&&(0,v.jsx)("span",{className:"text-xs text-gray-400 dark:text-gray-500 ml-4 whitespace-nowrap",children:n}),(0,v.jsx)("span",{className:"absolute inset-0 opacity-0 pointer-events-none","aria-hidden":!0,children:e}),(0,v.jsx)("span",{className:"hidden",children:e})]})}function Z({icon:e,label:t,shortcut:n,onClick:r,disabled:s}){return(0,v.jsxs)("button",{onClick:r,disabled:s,className:"flex items-center gap-3 w-full px-3 py-1.5 rounded cursor-pointer hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[e&&(0,v.jsx)("span",{className:"w-5 flex items-center justify-center text-gray-500 dark:text-gray-400 shrink-0",children:e}),(0,v.jsx)("span",{className:"flex-1 text-left text-sm text-gray-700 dark:text-gray-200",children:t}),n&&(0,v.jsx)("span",{className:"text-xs text-gray-400 dark:text-gray-500 ml-4 whitespace-nowrap",children:n})]})}function Q({icon:e,label:t,checked:n,onChange:r}){return(0,v.jsxs)("button",{type:"button",role:"menuitemcheckbox","aria-checked":n,onClick:()=>r(!n),className:"flex items-center gap-3 w-full px-3 py-1.5 rounded cursor-pointer hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",children:[e&&(0,v.jsx)("span",{className:"w-5 flex items-center justify-center text-gray-500 dark:text-gray-400 shrink-0",children:e}),(0,v.jsx)("span",{className:"flex-1 text-left text-sm text-gray-700 dark:text-gray-200",children:t}),(0,v.jsx)("span",{className:"flex h-4 w-4 items-center justify-center rounded border shrink-0 transition-colors "+(n?"bg-blue-500 border-blue-500 text-white":"border-gray-300 dark:border-slate-600"),children:n&&(0,v.jsx)(w.Check,{size:12,strokeWidth:3})})]})}function ee({children:e,label:t,name:n,active:r,onClick:s}){return(0,v.jsxs)("button",{title:t,onClick:e=>s(n,e),className:"flex items-center gap-0.5 px-1.5 py-1 rounded text-sm font-medium transition-colors "+(r?"bg-gray-200 dark:bg-slate-700 text-gray-900 dark:text-white":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-slate-800 hover:text-gray-900 dark:hover:text-white"),children:[e,(0,v.jsx)(w.ChevronDown,{size:10,className:"opacity-40 mt-0.5"})]})}function te({top:e,left:t,right:n,className:r="",children:s}){const i=(0,x.useRef)(null),[o,l]=(0,x.useState)({top:e,left:-9999,visibility:"hidden"});return(0,x.useLayoutEffect)(()=>{const r=()=>{const r=i.current;if(!r)return;const s=window.innerWidth,o=window.innerHeight,a=Math.max(160,o-e-8);if(s<=640)return void l({top:e,left:8,right:8,width:"auto",minWidth:0,maxWidth:"none",maxHeight:a,overflowY:"auto"});const c=r.offsetWidth,d=null!=n?s-n-c:t??8,h=Math.max(8,Math.min(d,s-c-8));l({top:e,left:h,maxWidth:s-16,maxHeight:a,overflowY:"auto"})};return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[e,t,n]),(0,v.jsx)("div",{className:`fixed bg-white/70 dark:bg-slate-900/70 backdrop-blur-md border border-gray-200/60 dark:border-slate-700/60 rounded-lg shadow-xl py-1 z-50 min-w-[220px] dropdown-portal ${r}`,onMouseDown:K,ref:i,style:o,children:s})}function ne({onClose:e,documentTitle:t,editor:n,initialTab:r="info"}){const[s,i]=(0,x.useState)(r),[o,l]=(0,x.useState)(()=>g.getWordCountStats(n));(0,x.useEffect)(()=>{if(!n)return;const e=()=>l(g.getWordCountStats(n));return e(),n.on("update",e),()=>{n.off("update",e)}},[n]);const{createdDate:a,modifiedDate:c}=(0,x.useMemo)(()=>({createdDate:new Date(Date.now()-2592e6),modifiedDate:new Date}),[]),[d,h]=(0,x.useState)(""),[u,p]=(0,x.useState)("viewer"),[f,m]=(0,x.useState)({isPublic:!1,sharedWith:[{email:"alice@example.com",role:"editor",sharedAt:(new Date).toISOString(),name:"Alice"},{email:"bob@example.com",role:"viewer",sharedAt:(new Date).toISOString(),name:"Bob"}],shareLink:null}),b=()=>{d.trim()&&(f.sharedWith.find(e=>e.email===d)?alert("Already shared with this email"):(m(e=>({...e,sharedWith:[...e.sharedWith,{email:d,role:u,sharedAt:(new Date).toISOString()}]})),h("")))},y=e=>{switch(e){case"editor":return(0,v.jsx)(w.Edit3,{size:14});case"commentor":return(0,v.jsx)(w.MessageSquare,{size:14});case"viewer":return(0,v.jsx)(w.Eye,{size:14});default:return null}},S=[{label:"Words",value:o.words},{label:"Characters (with spaces)",value:o.charactersWithSpaces},{label:"Characters (no spaces)",value:o.charactersNoSpaces},{label:"Sentences",value:o.sentences},{label:"Paragraphs",value:o.paragraphs},{label:"Links",value:o.links},{label:"Images",value:o.images}],j=e=>"px-3 py-1.5 text-sm rounded-md transition-colors "+(s===e?"bg-white dark:bg-slate-900 text-gray-900 dark:text-white shadow-sm font-medium":"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200"),C=G(e);return(0,k.createPortal)((0,v.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[(0,v.jsx)("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",...C}),(0,v.jsxs)("div",{className:"relative bg-white dark:bg-slate-900 border border-gray-200 dark:border-slate-700 rounded-xl shadow-2xl w-[600px] max-h-[85vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,v.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100 dark:border-slate-700",children:[(0,v.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,v.jsx)(w.FileText,{size:18,className:"text-blue-500 shrink-0"}),(0,v.jsxs)("div",{className:"min-w-0",children:[(0,v.jsx)("h2",{className:"font-semibold text-gray-900 dark:text-white truncate",children:t}),(0,v.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"info"===s?"Document details and statistics":"Manage who can access this document"})]})]}),(0,v.jsx)("button",{onClick:e,className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-slate-800",children:(0,v.jsx)(w.X,{size:16})})]}),(0,v.jsx)("div",{className:"px-6 pt-3",children:(0,v.jsxs)("div",{className:"inline-flex gap-1 p-1 rounded-lg bg-gray-100 dark:bg-slate-800",children:[(0,v.jsx)("button",{className:j("info"),onClick:()=>i("info"),type:"button",children:"Info & word count"}),(0,v.jsx)("button",{className:j("share"),onClick:()=>i("share"),type:"button",children:"Sharing"})]})}),(0,v.jsxs)("div",{className:"overflow-y-auto flex-1 p-6 space-y-6 "+("info"===s?"":"hidden"),children:[(0,v.jsxs)("div",{className:"space-y-4",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("p",{className:"text-xs font-semibold uppercase text-gray-500 dark:text-gray-400 mb-2",children:"Document Name"}),(0,v.jsx)("p",{className:"text-sm text-gray-900 dark:text-white break-words",children:t})]}),(0,v.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("p",{className:"text-xs font-semibold uppercase text-gray-500 dark:text-gray-400 mb-2",children:"Created"}),(0,v.jsx)("p",{className:"text-sm text-gray-900 dark:text-white",children:a.toLocaleDateString()})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("p",{className:"text-xs font-semibold uppercase text-gray-500 dark:text-gray-400 mb-2",children:"Last Modified"}),(0,v.jsx)("p",{className:"text-sm text-gray-900 dark:text-white",children:c.toLocaleDateString()})]})]}),(0,v.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("p",{className:"text-xs font-semibold uppercase text-gray-500 dark:text-gray-400 mb-2",children:"Access"}),(0,v.jsx)("p",{className:"text-sm text-gray-900 dark:text-white",children:f.isPublic?"Public":"Private"})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("p",{className:"text-xs font-semibold uppercase text-gray-500 dark:text-gray-400 mb-2",children:"Shared with"}),(0,v.jsx)("p",{className:"text-sm text-gray-900 dark:text-white",children:1===f.sharedWith.length?"1 person":`${f.sharedWith.length} people`})]})]})]}),(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)("h3",{className:"text-xs font-semibold uppercase text-gray-500 dark:text-gray-400",children:"Word Count"}),(0,v.jsx)("table",{className:"w-full text-sm",children:(0,v.jsx)("tbody",{children:S.map(e=>(0,v.jsxs)("tr",{className:"border-b border-gray-100 dark:border-slate-700 last:border-b-0",children:[(0,v.jsx)("td",{className:"py-1.5 pr-2 text-gray-500 dark:text-gray-400",children:e.label}),(0,v.jsx)("td",{className:"py-1.5 text-right font-semibold tabular-nums text-gray-900 dark:text-white",children:e.value.toLocaleString()})]},e.label))})})]}),(0,v.jsxs)("button",{onClick:()=>i("share"),className:"flex items-center gap-2 px-3 py-2 text-sm border border-gray-200 dark:border-slate-700 rounded-lg hover:bg-gray-50 dark:hover:bg-slate-800 text-gray-700 dark:text-gray-200",children:[(0,v.jsx)(w.Share2,{size:14}),"Manage sharing"]})]}),(0,v.jsxs)("div",{className:"overflow-y-auto flex-1 p-6 space-y-6 "+("share"===s?"":"hidden"),children:[(0,v.jsxs)("div",{className:"flex items-center justify-between p-4 rounded-lg border border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800/50",children:[(0,v.jsxs)("div",{className:"flex items-center gap-3",children:[f.isPublic?(0,v.jsx)(w.Globe,{size:18,className:"text-blue-500"}):(0,v.jsx)(w.Lock,{size:18,className:"text-gray-400"}),(0,v.jsxs)("div",{children:[(0,v.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:f.isPublic?"Public":"Private"}),(0,v.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.isPublic?"Anyone with link can view":"Only invited people can access"})]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-3",children:[f.isPublic&&f.shareLink&&(0,v.jsx)("button",{onClick:()=>{f.shareLink&&(navigator.clipboard.writeText(f.shareLink),alert("Link copied to clipboard"))},className:"px-2 py-1 text-xs border border-gray-300 dark:border-slate-600 rounded hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors",children:"Copy link"}),(0,v.jsx)("button",{onClick:()=>{m(e=>({...e,isPublic:!e.isPublic,shareLink:e.isPublic?null:`https://docs.example.com/share/${Math.random().toString(36).slice(2,9)}`}))},className:"relative inline-flex h-6 w-11 items-center rounded-full transition-colors "+(f.isPublic?"bg-blue-500":"bg-gray-300 dark:bg-slate-700"),children:(0,v.jsx)("span",{className:"inline-block h-4 w-4 transform rounded-full bg-white transition "+(f.isPublic?"translate-x-6":"translate-x-1")})})]})]}),(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Add people"}),(0,v.jsxs)("div",{className:"flex gap-2",children:[(0,v.jsxs)("div",{className:"relative flex-1",children:[(0,v.jsx)(w.Mail,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),(0,v.jsx)("input",{type:"email",placeholder:"email@example.com",value:d,onChange:e=>h(e.target.value),onKeyDown:e=>"Enter"===e.key&&b(),className:"w-full pl-9 pr-3 py-2 text-sm border border-gray-200 dark:border-slate-700 rounded-lg bg-white dark:bg-slate-800 text-gray-900 dark:text-white placeholder-gray-500"})]}),(0,v.jsxs)("select",{value:u,onChange:e=>p(e.target.value),className:"px-3 py-2 text-sm border border-gray-200 dark:border-slate-700 rounded-lg bg-white dark:bg-slate-800 text-gray-900 dark:text-white",children:[(0,v.jsx)("option",{value:"viewer",children:"Viewer"}),(0,v.jsx)("option",{value:"commentor",children:"Commentor"}),(0,v.jsx)("option",{value:"editor",children:"Editor"})]}),(0,v.jsx)("button",{onClick:b,className:"px-4 py-2 text-sm bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors",children:"Share"})]})]}),(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"People with access"}),(0,v.jsx)("div",{className:"space-y-1 max-h-[280px] overflow-y-auto",children:f.sharedWith.length>0?f.sharedWith.map(e=>(0,v.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg hover:bg-gray-50 dark:hover:bg-slate-800/50 transition-colors",children:[(0,v.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[(0,v.jsx)("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-gradient-to-br from-blue-400 to-blue-600 text-white text-xs font-medium",children:e.email.substring(0,2).toUpperCase()}),(0,v.jsxs)("div",{className:"min-w-0",children:[(0,v.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:e.email}),(0,v.jsxs)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Added ",new Date(e.sharedAt).toLocaleDateString()]})]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{className:"text-gray-400 dark:text-gray-500",children:y(e.role)}),(0,v.jsxs)("select",{value:e.role,onChange:t=>{return n=e.email,r=t.target.value,void m(e=>({...e,sharedWith:e.sharedWith.map(e=>e.email===n?{...e,role:r}:e)}));var n,r},className:"px-2 py-1 text-xs border border-gray-200 dark:border-slate-700 rounded bg-white dark:bg-slate-800 text-gray-900 dark:text-white",children:[(0,v.jsx)("option",{value:"viewer",children:"Viewer"}),(0,v.jsx)("option",{value:"commentor",children:"Commentor"}),(0,v.jsx)("option",{value:"editor",children:"Editor"})]}),(0,v.jsx)("button",{onClick:()=>{return t=e.email,void m(e=>({...e,sharedWith:e.sharedWith.filter(e=>e.email!==t)}));var t},className:"p-1 text-gray-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors",children:(0,v.jsx)(w.X,{size:14})})]})]},e.email)):(0,v.jsxs)("div",{className:"text-center py-8",children:[(0,v.jsx)(w.Users,{size:24,className:"mx-auto text-gray-300 mb-2 opacity-50"}),(0,v.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No one else has access yet"})]})})]})]})]})]}),document.body)}function re({onClose:e,currentName:t}){const[n,r]=(0,x.useState)(t),s=()=>{n.trim()&&n!==t&&alert(`File renamed to: ${n}`),e()},i=G(e);return(0,k.createPortal)((0,v.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[(0,v.jsx)("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",...i}),(0,v.jsxs)("div",{className:"relative bg-white dark:bg-slate-900 border border-gray-200 dark:border-slate-700 rounded-xl shadow-2xl w-[400px]",onClick:e=>e.stopPropagation(),children:[(0,v.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100 dark:border-slate-700",children:[(0,v.jsx)("h2",{className:"font-semibold text-gray-900 dark:text-white",children:"Rename document"}),(0,v.jsx)("button",{onClick:e,className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-slate-800",children:(0,v.jsx)(w.X,{size:16})})]}),(0,v.jsx)("div",{className:"p-6 space-y-4",children:(0,v.jsx)("input",{type:"text",value:n,onChange:e=>r(e.target.value),onKeyDown:e=>"Enter"===e.key&&s(),autoFocus:!0,className:"w-full px-3 py-2 text-sm border border-gray-200 dark:border-slate-700 rounded-lg bg-white dark:bg-slate-800 text-gray-900 dark:text-white"})}),(0,v.jsxs)("div",{className:"flex gap-2 px-6 py-4 border-t border-gray-100 dark:border-slate-700 justify-end",children:[(0,v.jsx)("button",{onClick:e,className:"px-4 py-2 text-sm border border-gray-200 dark:border-slate-700 rounded-lg hover:bg-gray-50 dark:hover:bg-slate-800",children:"Cancel"}),(0,v.jsx)("button",{onClick:s,className:"px-4 py-2 text-sm bg-blue-500 text-white rounded-lg hover:bg-blue-600",children:"Rename"})]})]})]}),document.body)}var se=({theme:e,setTheme:t,onOpenSettings:r,onAddComment:i,commentDisabled:o,showComments:a,onToggleComments:c,commentCount:u})=>{const[f,g]=(0,x.useState)(null),[b,y]=(0,x.useState)(null),[S,j]=(0,x.useState)(!1),[C,N]=(0,x.useState)(!1),[E,A]=(0,x.useState)(!1),[O,R]=(0,x.useState)(!1),[P,F]=(0,x.useState)(null),G=!!r,se=(0,x.useRef)(null),ie=s.useLocale(),{editor:oe}=(0,m.useCurrentEditor)(),le="Untitled Document",ae=!!oe?.extensionManager.extensions.some(e=>"harper"===e.name);(0,x.useEffect)(()=>{oe&&ae&&(E?oe.chain().focus().runProofing().run():oe.commands.clearProofing())},[E,oe,ae]);const ce=function(e){const t=(0,x.useCallback)(t=>e?h.subscribeReadAloud(e,t):()=>{},[e]);if("none"===(0,x.useSyncExternalStore)(t,()=>{const t=e?h.getReadAloudStorage(e):void 0;return t?`${t.state}|${t.currentChunk?.index??-1}|${t.error?.message??""}`:"none"},()=>"none")||!e)return B;const n=h.getReadAloudStorage(e);return n?{available:!0,state:n.state,isActive:"idle"!==n.state,isSpeaking:"speaking"===n.state,isPaused:"paused"===n.state,currentChunk:n.currentChunk,error:n.error}:B}(oe??null),de=V(oe??null),he=oe&&!oe.state.selection.empty?"selection":"document",ue=!!oe&&h.getReadAloudText(oe).length>0,pe=!!oe?.extensionManager.extensions.some(e=>"PaginationPlus"===e.name),[fe,ge]=(0,x.useState)(!0);(0,x.useEffect)(()=>{if(!oe||!pe)return;const e=oe.storage?.PaginationPlus?.enabled;"boolean"==typeof e&&ge(e)},[oe,pe]);const me=(0,x.useCallback)(e=>{oe&&(e?oe.commands.enablePagination?.():oe.commands.disablePagination?.(),ge(e))},[oe]),xe=(0,x.useCallback)(()=>{oe?.chain().focus().run(),document.execCommand("cut")},[oe]),be=(0,x.useCallback)(()=>{oe?.chain().focus().run(),document.execCommand("copy")},[oe]),ye=(0,x.useCallback)(async()=>{oe?.chain().focus().run();try{const e=await navigator.clipboard.readText();oe?.commands.insertContent(e)}catch{document.execCommand("paste")}},[oe]),ve=(0,x.useCallback)(async()=>{oe?.chain().focus().run();try{const e=await navigator.clipboard.readText();oe?.chain().focus().insertContent(e,{parseOptions:{preserveWhitespace:!0}}).run()}catch{document.execCommand("paste")}},[oe]),we=(0,x.useCallback)(()=>{oe?.commands.deleteSelection()},[oe]),ke=(0,x.useCallback)(()=>{oe?.chain().focus().selectAll().run()},[oe]),Se=!!oe?.extensionManager.extensions.some(e=>"selectSimilar"===e.name),[je,Ce]=(0,x.useState)(0);(0,x.useEffect)(()=>{if(!oe||!Se)return;const e=()=>Ce(p.selectSimilarPluginKey.getState(oe.state)?.ranges.length??0);return e(),oe.on("transaction",e),()=>{oe.off("transaction",e)}},[oe,Se]);const Ne=(0,x.useCallback)(e=>{oe?.chain().focus().selectSimilar(e).run()},[oe]),Ee=(0,x.useCallback)(()=>{oe?.chain().focus().clearSimilarSelection().run()},[oe]);(0,x.useEffect)(()=>{try{const e=localStorage.getItem(J),t=JSON.parse(localStorage.getItem(q)||"[]");if(t.length>0){const n=t.find(t=>t.id===e)||t[0];if(n&&n.rules.length>0){let e=document.getElementById(U);e||(e=document.createElement("style"),e.id=U,document.head.appendChild(e)),e.textContent=n.rules.filter(e=>e.selector&&e.property&&e.value).map(e=>`${e.selector} { ${e.property}: ${e.value}; }`).join("\n")}}}catch{}},[]);const Ae=(e,t)=>{if(f===e)return g(null),void y(null);const n=t.currentTarget.getBoundingClientRect();y({top:n.bottom+4,left:n.left}),g(e)},_e=()=>{g(null),y(null)};return(0,x.useEffect)(()=>{if(!f)return;const e=e=>{(function(e,t=document){const n=e;return!!n?.isConnected&&!n.closest(H)&&!t.querySelector('[role="dialog"],[role="menu"],[role="listbox"]')})(e.target)&&_e()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[f]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-0.5 border-b border-gray-200 dark:border-slate-700 px-2 py-1 flex-wrap",onMouseDown:K,children:[(0,v.jsx)(n.Z,{hideWhenDisabled:!0}),(0,v.jsx)(n.$$1,{hideWhenDisabled:!0}),(0,v.jsx)("div",{className:"border-l border-gray-200 dark:border-slate-700 mx-0.5 px-0.5",children:(0,v.jsx)($,{})}),(0,v.jsx)(n.F$1,{}),(0,v.jsx)(n.y$2,{}),(0,v.jsx)(n.h$4,{}),(0,v.jsx)(n.y$1,{}),(0,v.jsx)(n.d$1,{}),(0,v.jsx)(n.M$1,{}),(0,v.jsxs)("div",{className:"dropdown-container",children:[(0,v.jsx)(ee,{name:"block",label:"Block Format",active:"block"===f,onClick:Ae,children:(0,v.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,v.jsx)("line",{x1:"2",y1:"4",x2:"14",y2:"4"}),(0,v.jsx)("line",{x1:"2",y1:"8",x2:"11",y2:"8"}),(0,v.jsx)("line",{x1:"2",y1:"12",x2:"8",y2:"12"})]})}),"block"===f&&b&&(0,k.createPortal)((0,v.jsxs)(te,{className:"min-w-[400px]",left:b.left,top:b.top,children:[(0,v.jsxs)("div",{className:"grid grid-cols-2 gap-0.5 px-1 py-1",children:[(0,v.jsx)("div",{children:(0,v.jsx)(Y,{icon:"H1",label:"Heading 1",shortcut:"Ctrl+Alt+1",children:(0,v.jsx)(n.$,{level:1})})}),(0,v.jsx)("div",{children:(0,v.jsx)(Y,{icon:"H2",label:"Heading 2",shortcut:"Ctrl+Alt+2",children:(0,v.jsx)(n.$,{level:2})})}),(0,v.jsx)("div",{children:(0,v.jsx)(Y,{icon:"H3",label:"Heading 3",shortcut:"Ctrl+Alt+3",children:(0,v.jsx)(n.$,{level:3})})}),(0,v.jsx)("div",{children:(0,v.jsx)(Y,{icon:"H4",label:"Heading 4",shortcut:"Ctrl+Alt+4",children:(0,v.jsx)(n.$,{level:4})})}),(0,v.jsx)("div",{children:(0,v.jsx)(Y,{icon:"H5",label:"Heading 5",shortcut:"Ctrl+Alt+5",children:(0,v.jsx)(n.$,{level:5})})}),(0,v.jsx)("div",{children:(0,v.jsx)(Y,{icon:"H6",label:"Heading 6",shortcut:"Ctrl+Alt+6",children:(0,v.jsx)(n.$,{level:6})})})]}),(0,v.jsx)("div",{className:"my-1 border-t border-gray-100 dark:border-slate-700"}),(0,v.jsxs)("div",{className:"grid grid-cols-2 gap-0.5 px-1",children:[(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Bullet List",shortcut:"Ctrl+Shift+8",children:(0,v.jsx)(n.r$1,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Ordered List",shortcut:"Ctrl+Shift+7",children:(0,v.jsx)(n.n$4,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Check List",shortcut:"Ctrl+Shift+9",children:(0,v.jsx)(n.r,{})})})]}),(0,v.jsx)("div",{className:"my-1 border-t border-gray-100 dark:border-slate-700"}),(0,v.jsxs)("div",{className:"grid grid-cols-2 gap-0.5 px-1",children:[(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Blockquote",shortcut:"Ctrl+Shift+B",children:(0,v.jsx)(n.p$1,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Code Block",shortcut:"Ctrl+Alt+C",children:(0,v.jsx)(n.k$2,{})})})]}),(0,v.jsx)("div",{className:"my-1 border-t border-gray-100 dark:border-slate-700"}),(0,v.jsx)("div",{className:"px-1",children:(0,v.jsx)(T,{label:"Clear Format",children:(0,v.jsx)(n.n$3,{})})}),(0,v.jsxs)("button",{onClick:()=>{_e(),j(!0)},className:"flex items-center gap-3 w-full px-3 py-1.5 text-sm text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-slate-800 rounded transition-colors",children:[(0,v.jsx)(w.Paintbrush,{size:14,className:"text-gray-400 shrink-0"}),"Customize default styles…"]})]}),document.body)]}),(0,v.jsxs)("div",{className:"dropdown-container",children:[(0,v.jsx)(ee,{name:"textstyles",label:"Text Styles",active:"textstyles"===f,onClick:Ae,children:(0,v.jsx)("span",{className:"text-sm font-mono",children:"Tt"})}),"textstyles"===f&&b&&(0,k.createPortal)((0,v.jsxs)(te,{className:"min-w-[400px]",left:b.left,top:b.top,children:[(0,v.jsx)("div",{className:"px-2 py-1 text-[10px] font-semibold uppercase text-gray-400 tracking-wide",children:"Text Styles"}),(0,v.jsxs)("div",{className:"grid grid-cols-2 gap-0.5 px-1 py-1",children:[(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Strikethrough",shortcut:"Ctrl+Shift+S",children:(0,v.jsx)(n.u$1,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Inline Code",shortcut:"Ctrl+E",children:(0,v.jsx)(n.m$1,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Text Color",shortcut:"Alt+Shift+C",children:(0,v.jsx)(n.h$3,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Superscript",shortcut:"Ctrl+.",children:(0,v.jsx)(D,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Subscript",shortcut:"Ctrl+,",children:(0,v.jsx)(M,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Indent",children:(0,v.jsx)(n.l,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Line Spacing",children:(0,v.jsx)(n.f,{})})}),(0,v.jsx)("div",{className:"col-span-2",children:(0,v.jsx)(T,{label:"Alignment",children:(0,v.jsx)(n.A$1,{})})})]})]}),document.body)]}),(0,v.jsxs)("div",{className:"dropdown-container",children:[(0,v.jsx)(ee,{name:"insert",label:"Insert",active:"insert"===f,onClick:Ae,children:(0,v.jsx)(w.Plus,{size:16})}),"insert"===f&&b&&(0,k.createPortal)((0,v.jsxs)(te,{className:"min-w-[300px]",left:b.left,top:b.top,children:[(0,v.jsx)("div",{className:"px-2 py-1 text-[10px] font-semibold uppercase text-gray-400 tracking-wide",children:"Insert"}),(0,v.jsxs)("div",{className:"grid grid-cols-2 gap-0.5 px-1",children:[(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Link",children:(0,v.jsx)(n.Be,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Emoji",children:(0,v.jsx)(n.ne,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Table",children:(0,v.jsx)(n.at,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Image",children:(0,v.jsx)(n.te,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Meme",children:(0,v.jsx)(n.T$2,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Document",children:(0,v.jsx)(n.E,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Columns",shortcut:"Ctrl+Alt+G",children:(0,v.jsx)(n.b,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Callout",children:(0,v.jsx)(n.F,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Twitter",children:(0,v.jsx)(n.N,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Divider",shortcut:"Ctrl+Alt+S",children:(0,v.jsx)(n.h,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Video",children:(0,v.jsx)(n.M,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Math",children:(0,v.jsx)(n.Dt,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Flowchart",children:(0,v.jsx)(n.P,{})})}),(0,v.jsx)("div",{children:(0,v.jsx)(T,{label:"Drawio",children:(0,v.jsx)(d.RichTextDrawio,{})})}),i&&(0,v.jsx)("div",{children:(0,v.jsxs)("button",{type:"button",disabled:o,onClick:()=>{_e(),i()},className:"flex items-center gap-2 px-2 py-0.5 rounded cursor-pointer w-full text-left hover:bg-gray-100/80 dark:hover:bg-slate-800/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,v.jsx)("span",{className:"w-5 flex items-center justify-center text-gray-500 dark:text-gray-400 shrink-0",children:(0,v.jsx)(w.MessageSquarePlus,{size:14})}),(0,v.jsx)("span",{className:"text-xs whitespace-nowrap truncate",children:"Comment"})]})})]})]}),document.body)]}),(0,v.jsxs)("div",{className:"dropdown-container",children:[(0,v.jsx)(ee,{name:"edit",label:"Edit",active:"edit"===f,onClick:Ae,children:(0,v.jsx)(w.Clipboard,{size:16})}),"edit"===f&&b&&(0,k.createPortal)((0,v.jsxs)(te,{left:b.left,top:b.top,children:[(0,v.jsx)("div",{className:"px-2 py-1 text-[10px] font-semibold uppercase text-gray-400 tracking-wide",children:"Clipboard"}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.Scissors,{size:14}),label:"Cut",shortcut:"Ctrl+X",onClick:()=>{_e(),xe()}}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.Clipboard,{size:14}),label:"Copy",shortcut:"Ctrl+C",onClick:()=>{_e(),be()}}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.ClipboardPaste,{size:14}),label:"Paste",shortcut:"Ctrl+V",onClick:()=>{_e(),ye()}}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.ClipboardType,{size:14}),label:"Paste Plain",shortcut:"Ctrl+Shift+V",onClick:()=>{_e(),ve()}}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.Trash2,{size:14}),label:"Delete",shortcut:"Del",onClick:()=>{_e(),we()}}),(0,v.jsx)("div",{className:"my-1 border-t border-gray-100 dark:border-slate-700"}),(0,v.jsx)("div",{className:"px-2 py-1 text-[10px] font-semibold uppercase text-gray-400 tracking-wide",children:"Selection"}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.TextCursorInput,{size:14}),label:"Select All",shortcut:"Ctrl+A",onClick:()=>{_e(),ke()}}),Se&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(Z,{icon:(0,v.jsx)(w.Type,{size:14}),label:"Select All Similar Fonts",onClick:()=>{_e(),Ne("font")}}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.Palette,{size:14}),label:"Select All Similar Styles",onClick:()=>{_e(),Ne("style")}}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.TextSelect,{size:14}),label:"Select All Similar Formatting",onClick:()=>{_e(),Ne("formatting")}}),(0,v.jsx)(Z,{disabled:0===je,icon:(0,v.jsx)(w.X,{size:14}),label:je?`Clear Multi-Selection (${je})`:"Clear Multi-Selection",shortcut:"Esc",onClick:()=>{_e(),Ee()}}),(0,v.jsx)("div",{className:"px-3 pb-1.5 pt-0.5 text-[10px] leading-snug text-gray-400 dark:text-gray-500",children:"Formatting applied afterwards lands on every highlighted run at once."})]})]}),document.body)]}),(0,v.jsxs)("div",{className:"dropdown-container",children:[(0,v.jsx)(ee,{name:"tools",label:"Tools",active:"tools"===f,onClick:Ae,children:(0,v.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,v.jsx)("path",{d:"M14.7 6.3a1 1 0 000 1.4l1.6 1.6a1 1 0 001.4 0l3.77-3.77a6 6 0 01-7.94 7.94l-6.91 6.91a2.12 2.12 0 01-3-3l6.91-6.91a6 6 0 017.94-7.94l-3.76 3.76z"})})}),"tools"===f&&b&&(0,k.createPortal)((0,v.jsxs)(te,{left:b.left,top:b.top,children:[(0,v.jsx)("div",{className:"px-2 py-1 text-[10px] font-semibold uppercase text-gray-400 tracking-wide",children:"Document"}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.FileText,{size:14}),label:"Document info & word count",onClick:()=>{_e(),F("info")}}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.Share2,{size:14}),label:"Share",onClick:()=>{_e(),F("share")}}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.Edit3,{size:14}),label:"Rename",onClick:()=>{_e(),R(!0)}}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.Copy,{size:14}),label:"Make a copy",onClick:()=>{_e(),alert("Document copied to your drive")}}),(0,v.jsx)(Z,{icon:(0,v.jsx)(w.Download,{size:14}),label:"Download",onClick:()=>{_e(),alert("Downloading document...")}}),(0,v.jsx)("div",{className:"my-1 border-t border-gray-100 dark:border-slate-700"}),(0,v.jsx)("div",{className:"px-2 py-1 text-[10px] font-semibold uppercase text-gray-400 tracking-wide",children:"Tools"}),c&&(0,v.jsx)(Q,{icon:(0,v.jsx)(w.MessageSquare,{size:14}),label:u?`Comments Panel (${u})`:"Comments Panel",checked:!!a,onChange:()=>c()}),c&&(0,v.jsx)("div",{className:"my-1 border-t border-gray-100 dark:border-slate-700"}),(0,v.jsx)(T,{label:"Find / Replace",children:(0,v.jsx)(n.I,{})}),(0,v.jsx)(T,{label:"View Source",children:(0,v.jsx)(n.n,{})}),(0,v.jsx)("div",{className:"my-1 border-t border-gray-100 dark:border-slate-700"}),(0,v.jsx)(Q,{icon:(0,v.jsx)(w.ListTree,{size:14}),label:"Table of Contents",checked:C,onChange:N}),ae&&(0,v.jsx)(Q,{icon:(0,v.jsx)(w.SpellCheck,{size:14}),label:"Spelling & Grammar",checked:E,onChange:A}),(ce.available||de.available)&&(0,v.jsx)("div",{className:"my-1 border-t border-gray-100 dark:border-slate-700"}),ce.available&&(0,v.jsx)(Z,{disabled:!ce.isActive&&!ue,icon:ce.isActive?(0,v.jsx)(w.VolumeX,{size:14}):(0,v.jsx)(w.Volume2,{size:14}),label:ce.isActive?"Stop reading":"selection"===he?"Read selection aloud":"Read document aloud",shortcut:"Ctrl+Shift+S",onClick:()=>{_e(),oe?.commands.toggleReadAloud()}}),de.available&&(0,v.jsx)(Q,{icon:(0,v.jsx)(w.Mic,{size:14}),label:(0,_.isTranscriptionSupported)()?de.isListening?"Dictating — click to stop":"Dictate into the document":"Dictation unavailable in this browser",checked:de.isListening,onChange:()=>{(0,_.isTranscriptionSupported)()&&oe?.commands.toggleTranscribe()}}),(0,v.jsx)("div",{className:"my-1 border-t border-gray-100 dark:border-slate-700"}),pe&&(0,v.jsx)(Q,{icon:fe?(0,v.jsx)(w.File,{size:14}):(0,v.jsx)(w.Globe,{size:14}),label:fe?"Page Layout: A4":"Page Layout: Web",checked:fe,onChange:me}),(0,v.jsx)(T,{label:"Page Settings",shortcut:"Ctrl+Shift+P",children:(0,v.jsx)(I,{})}),(0,v.jsx)("div",{className:"my-1 border-t border-gray-100 dark:border-slate-700"}),(0,v.jsx)(T,{label:"Import Word",children:(0,v.jsx)(n.Th,{})}),(0,v.jsx)(T,{label:"Export Word",children:(0,v.jsx)(n.d,{})}),(0,v.jsx)(T,{label:"Export PDF",children:(0,v.jsx)(n.a$1,{})})]}),document.body)]}),(0,v.jsxs)("div",{className:"ml-auto dropdown-container",children:[(0,v.jsx)("button",{ref:se,title:"Settings",onClick:e=>{G?(g(null),y(null),r()):((e,t)=>{if(f===e)return g(null),void y(null);const n=t.currentTarget.getBoundingClientRect();y({top:n.bottom+4,left:n.left,right:window.innerWidth-n.right}),g(e)})("settings",e)},className:"flex items-center gap-0.5 p-1.5 rounded transition-colors "+("settings"===f?"bg-gray-200 dark:bg-slate-700":"text-gray-500 hover:bg-gray-100 dark:hover:bg-slate-800"),children:(0,v.jsx)(w.Settings,{size:16})}),!G&&"settings"===f&&b&&(0,k.createPortal)((0,v.jsxs)(te,{className:"w-[260px] px-2 py-2 shadow-2xl",right:b.right,top:b.top,children:[(0,v.jsx)("div",{className:"text-[10px] font-semibold mb-1 text-gray-500 dark:text-gray-400 uppercase px-1",children:"Theme"}),(0,v.jsxs)("div",{className:"flex gap-1 mb-2 px-1",children:[(0,v.jsx)("button",{onClick:()=>t("light"),className:"flex-1 px-2 py-1 text-xs border rounded "+("light"===e?"bg-blue-500 text-white border-blue-600":"hover:bg-gray-100 dark:hover:bg-slate-800"),children:"☀️ Light"}),(0,v.jsx)("button",{onClick:()=>t("dark"),className:"flex-1 px-2 py-1 text-xs border rounded "+("dark"===e?"bg-blue-500 text-white border-blue-600":"hover:bg-gray-100 dark:hover:bg-slate-800"),children:"🌙 Dark"})]}),(0,v.jsx)("div",{className:"text-[10px] font-semibold mb-1 text-gray-500 dark:text-gray-400 uppercase px-1",children:"Accent Color"}),(0,v.jsx)("div",{className:"grid grid-cols-4 gap-0.5 px-1 mb-2",children:["default","red","blue","green","orange","rose","violet","yellow"].map(e=>(0,v.jsx)("button",{onClick:()=>l.themeActions.setColor(e),className:"px-1.5 py-1 text-[10px] border rounded hover:bg-gray-100 dark:hover:bg-slate-800 capitalize",children:e},e))}),(0,v.jsx)("div",{className:"border-t border-gray-100 dark:border-slate-700 my-1"}),(0,v.jsx)("div",{className:"text-[10px] font-semibold mb-1 text-gray-500 dark:text-gray-400 uppercase px-1",children:"Language"}),(0,v.jsx)("div",{className:"grid grid-cols-2 gap-0.5 px-1 max-h-[180px] overflow-y-auto",children:[{code:"en",flag:"🇺🇸",label:"English"},{code:"es",flag:"🇪🇸",label:"Español"},{code:"de",flag:"🇩🇪",label:"Deutsch"},{code:"zh_CN",flag:"🇨🇳",label:"中文"},{code:"ja",flag:"🇯🇵",label:"日本語"},{code:"ar",flag:"🇸🇦",label:"العربية"},{code:"fr",flag:"🇫🇷",label:"Français"},{code:"pt_BR",flag:"🇧🇷",label:"Português"},{code:"ru",flag:"🇷🇺",label:"Русский"},{code:"tr",flag:"🇹🇷",label:"Türkçe"},{code:"it",flag:"🇮🇹",label:"Italiano"},{code:"fa",flag:"🇮🇷",label:"فارسی"},{code:"nl",flag:"🇳🇱",label:"Nederlands"},{code:"ko",flag:"🇰🇷",label:"한국어"},{code:"hi",flag:"🇮🇳",label:"हिन्दी"},{code:"hu_HU",flag:"🇭🇺",label:"Magyar"},{code:"vi",flag:"🇻🇳",label:"Tiếng Việt"},{code:"fi",flag:"🇫🇮",label:"Suomi"}].map(({code:e,flag:t,label:n})=>(0,v.jsxs)("button",{onClick:()=>s.localeActions.setLang(e),className:"px-1.5 py-1 text-[10px] border rounded text-left hover:bg-gray-100 dark:hover:bg-slate-800 "+(ie.lang===e?"bg-blue-500/20 border-blue-500":""),children:[t," ",n]},e))})]}),document.body)]})]}),S&&(0,v.jsx)(X,{onClose:()=>j(!1)}),C&&oe&&(0,v.jsx)(z,{editor:oe,onClose:()=>N(!1)}),ae&&E&&oe&&(0,v.jsx)(L,{editor:oe}),de.available&&(0,v.jsx)(W,{editor:oe??null}),O&&(0,v.jsx)(re,{onClose:()=>R(!1),currentName:le}),P&&(0,v.jsx)(ne,{documentTitle:le,editor:oe,initialTab:P,onClose:()=>F(null)})]})},ie=()=>new Map,oe=e=>{const t=ie();return e.forEach((e,n)=>{t.set(n,e)}),t},le=(e,t,n)=>{let r=e.get(t);return void 0===r&&e.set(t,r=n()),r},ae=()=>new Set,ce=e=>e[e.length-1],de=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},he=Array.from,ue=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},pe=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},fe=Array.isArray,ge=class{constructor(){this._observers=ie()}on(e,t){return le(this._observers,e,ae).add(t),t}once(e,t){const n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){const n=this._observers.get(e);void 0!==n&&(n.delete(t),0===n.size&&this._observers.delete(e))}emit(e,t){return he((this._observers.get(e)||ie()).values()).forEach(e=>e(...t))}destroy(){this._observers=ie()}},me=Math.floor,xe=Math.abs,be=(e,t)=>e<t?e:t,ye=(e,t)=>e>t?e:t,ve=(Number.isNaN,e=>0!==e?e<0:1/e<0),we=Number.MAX_SAFE_INTEGER,ke=Number.MIN_SAFE_INTEGER,Se=Number.isInteger||(e=>"number"==typeof e&&isFinite(e)&&me(e)===e),je=(Number.isNaN,Number.parseInt,String.fromCharCode),Ce=(String.fromCodePoint,je(65535),/^\s*/g),Ne=/([A-Z])/g,Ee=(e,t)=>(e=>e.replace(Ce,""))(e.replace(Ne,e=>`${t}${(e=>e.toLowerCase())(e)}`)),Ae="undefined"!=typeof TextEncoder?new TextEncoder:null,_e=Ae?e=>Ae.encode(e):e=>{const t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=t.codePointAt(s);return r},Te="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Te&&1===Te.decode(new Uint8Array).length&&(Te=null);var Me,De,Oe,$e,Re=(e,t)=>((e,t)=>{const n=new Array(e);for(let r=0;r<e;r++)n[r]=t();return n})(t,()=>e).join(""),Ie=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Pe=()=>new Ie,ze=e=>{const t=new Uint8Array((e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t})(e));let n=0;for(let r=0;r<e.bufs.length;r++){const s=e.bufs[r];t.set(s,n),n+=s.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},Le=(e,t)=>{const n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(2*n),e.cpos=0),e.cbuf[e.cpos++]=t},Be=Le,Fe=(e,t)=>{for(;t>127;)Le(e,128|127&t),t=me(t/128);Le(e,127&t)},Ve=(e,t)=>{const n=ve(t);for(n&&(t=-t),Le(e,(t>63?128:0)|(n?64:0)|63&t),t=me(t/64);t>0;)Le(e,(t>127?128:0)|127&t),t=me(t/128)},We=new Uint8Array(3e4),He=We.length/3,Ue=Ae&&Ae.encodeInto?(e,t)=>{if(t.length<He){const n=Ae.encodeInto(t,We).written||0;Fe(e,n);for(let t=0;t<n;t++)Le(e,We[t])}else Je(e,_e(t))}:(e,t)=>{const n=unescape(encodeURIComponent(t)),r=n.length;Fe(e,r);for(let s=0;s<r;s++)Le(e,n.codePointAt(s))},qe=(e,t)=>{const n=e.cbuf.length,r=e.cpos,s=be(n-r,t.length),i=t.length-s;e.cbuf.set(t.subarray(0,s),r),e.cpos+=s,i>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(ye(2*n,i)),e.cbuf.set(t.subarray(s)),e.cpos=i)},Je=(e,t)=>{Fe(e,t.byteLength),qe(e,t)},Ke=(e,t)=>{((e,t)=>{const n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(2*ye(n,t)),e.cpos=0)})(e,t);const n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Ge=new DataView(new ArrayBuffer(4)),Xe=(e,t)=>{switch(typeof t){case"string":Le(e,119),Ue(e,t);break;case"number":Se(t)&&xe(t)<=2147483647?(Le(e,125),Ve(e,t)):(n=t,Ge.setFloat32(0,n),Ge.getFloat32(0)===n?(Le(e,124),((e,t)=>{Ke(e,4).setFloat32(0,t,!1)})(e,t)):(Le(e,123),((e,t)=>{Ke(e,8).setFloat64(0,t,!1)})(e,t)));break;case"bigint":Le(e,122),((e,t)=>{Ke(e,8).setBigInt64(0,t,!1)})(e,t);break;case"object":if(null===t)Le(e,126);else if(fe(t)){Le(e,117),Fe(e,t.length);for(let n=0;n<t.length;n++)Xe(e,t[n])}else if(t instanceof Uint8Array)Le(e,116),Je(e,t);else{Le(e,118);const n=Object.keys(t);Fe(e,n.length);for(let r=0;r<n.length;r++){const s=n[r];Ue(e,s),Xe(e,t[s])}}break;case"boolean":Le(e,t?120:121);break;default:Le(e,127)}var n},Ye=class extends Ie{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Fe(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Ze=e=>{e.count>0&&(Ve(e.encoder,1===e.count?e.s:-e.s),e.count>1&&Fe(e.encoder,e.count-2))},Qe=class{constructor(){this.encoder=new Ie,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Ze(this),this.count=1,this.s=e)}toUint8Array(){return Ze(this),ze(this.encoder)}},et=e=>{if(e.count>0){const t=2*e.diff+(1===e.count?0:1);Ve(e.encoder,t),e.count>1&&Fe(e.encoder,e.count-2)}},tt=class{constructor(){this.encoder=new Ie,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(et(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return et(this),ze(this.encoder)}},nt=class{constructor(){this.sarr=[],this.s="",this.lensE=new Qe}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 Ie;return this.sarr.push(this.s),this.s="",Ue(e,this.sarr.join("")),qe(e,this.lensE.toUint8Array()),ze(e)}},rt=e=>new Error(e),st=()=>{throw rt("Method unimplemented")},it=()=>{throw rt("Unexpected case")},ot=rt("Unexpected end of array"),lt=rt("Integer out of Range"),at=class{constructor(e){this.arr=e,this.pos=0}},ct=e=>new at(e),dt=e=>((e,t)=>{const n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n})(e,ut(e)),ht=e=>e.arr[e.pos++],ut=e=>{let t=0,n=1;const r=e.arr.length;for(;e.pos<r;){const r=e.arr[e.pos++];if(t+=(127&r)*n,n*=128,r<128)return t;if(t>we)throw lt}throw ot},pt=e=>{let t=e.arr[e.pos++],n=63&t,r=64;const s=(64&t)>0?-1:1;if(!(128&t))return s*n;const i=e.arr.length;for(;e.pos<i;){if(t=e.arr[e.pos++],n+=(127&t)*r,r*=128,t<128)return s*n;if(n>we)throw lt}throw ot},ft=Te?e=>Te.decode(dt(e)):e=>{let t=ut(e);if(0===t)return"";{let n=String.fromCodePoint(ht(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(ht(e));else for(;t>0;){const r=t<1e4?t:1e4,s=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,s),t-=r}return decodeURIComponent(escape(n))}},gt=(e,t)=>{const n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},mt=[e=>{},e=>null,pt,e=>gt(e,4).getFloat32(0,!1),e=>gt(e,8).getFloat64(0,!1),e=>gt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,ft,e=>{const t=ut(e),n={};for(let r=0;r<t;r++)n[ft(e)]=xt(e);return n},e=>{const t=ut(e),n=[];for(let r=0;r<t;r++)n.push(xt(e));return n},dt],xt=e=>mt[127-ht(e)](e),bt=class extends at{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return 0===this.count&&(this.s=this.reader(this),(e=this).pos!==e.arr.length?this.count=ut(this)+1:this.count=-1),this.count--,this.s;var e}},yt=class extends at{constructor(e){super(e),this.s=0,this.count=0}read(){if(0===this.count){this.s=pt(this);const e=ve(this.s);this.count=1,e&&(this.s=-this.s,this.count=ut(this)+2)}return this.count--,this.s}},vt=class extends at{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(0===this.count){const e=pt(this),t=1&e;this.diff=me(e/2),this.count=1,t&&(this.count=ut(this)+2)}return this.s+=this.diff,this.count--,this.s}},wt=class{constructor(e){this.decoder=new yt(e),this.str=ft(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}},kt=(crypto.subtle,crypto.getRandomValues.bind(crypto)),St=Math.random,jt=()=>kt(new Uint32Array(1))[0],Ct=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^jt()&15>>e/4).toString(16)),Nt=Date.now,Et=e=>new Promise(e),At=(Promise.all.bind(Promise),new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}});try{"undefined"!=typeof localStorage&&localStorage&&(At=localStorage,!1)}catch(Fh){}var _t,Tt=At,Mt=Symbol("Equality"),Dt=(e,t)=>e===t||!!e?.[Mt]?.(t)||!1,Ot=Object.assign,$t=Object.keys,Rt=e=>$t(e).length,It=(e,t)=>{for(const n in e)if(!t(e[n],n))return!1;return!0},Pt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),zt=Object.freeze,Lt=e=>{for(const t in e){const n=e[t];"object"!=typeof n&&"function"!=typeof n||Lt(e[t])}return zt(e)},Bt=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Bt(e,t,n+1)}},Ft=(e,t)=>{if(e===t)return!0;if(null==e||null==t||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(null!=e[Mt])return e[Mt](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(const n of e.keys())if(!t.has(n)||!Ft(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Rt(e)!==Rt(t))return!1;for(const n in e)if(!Pt(e,n)||!Ft(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ft(e[n],t[n]))return!1;break;default:return!1}return!0},Vt="undefined"!=typeof process&&process.release&&/node|io\.js/.test(process.release.name)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),Wt="undefined"!=typeof window&&"undefined"!=typeof document&&!Vt,Ht=("undefined"!=typeof navigator&&/Mac/.test(navigator.platform),[]),Ut=e=>(()=>{if(void 0===Me)if(Vt){Me=ie();const e=process.argv;let t=null;for(let n=0;n<e.length;n++){const r=e[n];"-"===r[0]?(null!==t&&Me.set(t,""),t=r):null!==t?(Me.set(t,r),t=null):Ht.push(r)}null!==t&&Me.set(t,"")}else"object"==typeof location?(Me=ie(),(location.search||"?").slice(1).split("&").forEach(e=>{if(0!==e.length){const[t,n]=e.split("=");Me.set(`--${Ee(t,"-")}`,n),Me.set(`-${Ee(t,"-")}`,n)}})):Me=ie();return Me})().has(e),qt=e=>(e=>void 0===e?null:e)(Vt?process.env[e.toUpperCase().replaceAll("-","_")]:Tt.getItem(e)),Jt=e=>Ut("--"+e)||null!==qt(e),Kt=Jt("production"),Gt=(Vt&&(De=process.env.FORCE_COLOR,Oe=["true","1","2"],Oe.includes(De))||!Ut("--no-colors")&&!Jt("no-color")&&(!Vt||process.stdout.isTTY)&&(!Vt||Ut("--color")||null!==qt("COLORTERM")||(qt("TERM")||"").includes("color")),Wt?e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=je(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64")),Xt=class{constructor(e,t){this.left=e,this.right=t}},Yt=(e,t)=>new Xt(e,t),Zt=e=>e.next()>=.5,Qt=(e,t,n)=>me(e.next()*(n+1-t)+t),en=(e,t,n)=>me(e.next()*(n+1-t)+t),tn=(e,t,n)=>en(e,t,n),nn=e=>je(tn(e,97,122)),rn=(e,t)=>t[tn(e,0,t.length-1)],sn=Symbol("0schema"),on=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){const e=[];for(let t=this._rerrs.length-1;t>0;t--){const n=this._rerrs[t];e.push(Re(" ",2*(this._rerrs.length-t))+`${null!=n.path?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join("\n")}},ln=(e,t)=>e===t||null!=e&&null!=t&&e.constructor===t.constructor&&(e[Mt]?Dt(e,t):fe(e)?ue(e,e=>pe(t,t=>ln(e,t))):"object"==typeof e&&It(e,(e,n)=>ln(e,t[n]))),an=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),ln(t,n)}equals(e){return this.constructor===e.constructor&&Ft(this.shape,e.shape)}[sn](){return!0}[Mt](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){st()}get nullable(){return zn(this,Qn)}get optional(){return new yn(this)}cast(e){return rr(e,this),e}expect(e){return rr(e,this),e}},cn=class extends an{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){const n=e?.constructor===this.shape&&(null==this._c||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}},dn=(e,t=null)=>new cn(e,t),hn=(dn(cn),class extends an{constructor(e){super(),this.shape=e}check(e,t){const n=this.shape(e);return!n&&t?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),n}}),un=e=>new hn(e),pn=(dn(hn),class extends an{constructor(e){super(),this.shape=e}check(e,t){const n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(" | "),e.toString()),n}}),fn=(...e)=>new pn(e),gn=dn(pn),mn=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),xn=e=>Kn.check(e)?[mn(e)]:gn.check(e)?e.shape.map(e=>e+""):Jn.check(e)?["[+-]?\\d+.?\\d*"]:Gn.check(e)?[".*"]:Ln.check(e)?e.shape.map(xn).flat(1):void it(),bn=(dn(class extends an{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(xn).map(e=>`(${e.join("|")})`).join("")+"$")}check(e,t){const n=null!=this._r.exec(e);return!n&&t?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),n}}),Symbol("optional")),yn=class extends an{constructor(e){super(),this.shape=e}check(e,t){const n=void 0===e||this.shape.check(e);return!n&&t?.extend(null,"undefined (optional)","()"),n}get[bn](){return!0}},vn=dn(yn),wn=class extends an{check(e,t){return t?.extend(null,"never",typeof e),!1}},kn=(new wn,dn(wn),class e extends an{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return null==e?(t?.extend(null,"object","null"),!1):It(this.shape,(n,r)=>{const s=this._isPartial&&!Pt(e,r)||n.check(e[r],t);return!s&&t?.extend(r.toString(),n.toString(),typeof e[r],"Object property does not match"),s})}}),Sn=dn(kn),jn=un(e=>null!=e&&(e.constructor===Object||null==e.constructor)),Cn=class extends an{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return null!=e&&It(e,(n,r)=>{const s=this.shape.keys.check(r,t);return!s&&t?.extend(r+"","Record",typeof e,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(n,t)})}},Nn=(e,t)=>new Cn(e,t),En=dn(Cn),An=class extends an{constructor(e){super(),this.shape=e}check(e,t){return null!=e&&It(this.shape,(n,r)=>{const s=n.check(e[r],t);return!s&&t?.extend(r.toString(),"Tuple",typeof n),s})}},_n=(dn(An),class extends an{constructor(e){super(),this.shape=1===e.length?e[0]:new Pn(e)}check(e,t){const n=fe(e)&&ue(e,e=>this.shape.check(e));return!n&&t?.extend(null,"Array",""),n}}),Tn=(...e)=>new _n(e),Mn=dn(_n),Dn=un(e=>fe(e)),On=class extends an{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){const n=e instanceof this.shape&&(null==this._c||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},$n=(dn(On),((e,t=null)=>new On(an,t))()),Rn=dn(class extends an{constructor(e){super(),this.len=e.length-1,this.args=((...e)=>new An(e))(...e.slice(-1)),this.res=e[this.len]}check(e,t){const n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,"function",typeof e),n}}),In=un(e=>"function"==typeof e),Pn=(dn(class extends an{constructor(e){super(),this.shape=e}check(e,t){const n=ue(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,"Intersectinon",typeof e),n}},e=>e.shape.length>0),class extends an{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){const n=pe(this.shape,n=>n.check(e,t));return t?.extend(null,"Union",typeof e),n}}),zn=(...e)=>e.findIndex(e=>Ln.check(e))>=0?zn(...e.map(e=>nr(e)).map(e=>Ln.check(e)?e.shape:[e]).flat(1)):1===e.length?e[0]:new Pn(e),Ln=dn(Pn),Bn=()=>!0,Fn=un(Bn),Vn=dn(hn,e=>e.shape===Bn),Wn=un(e=>"bigint"==typeof e),Hn=un(e=>e===Wn),Un=un(e=>"symbol"==typeof e),qn=(un(e=>e===Un),un(e=>"number"==typeof e)),Jn=un(e=>e===qn),Kn=un(e=>"string"==typeof e),Gn=un(e=>e===Kn),Xn=un(e=>"boolean"==typeof e),Yn=un(e=>e===Xn),Zn=fn(void 0),Qn=(dn(pn,e=>1===e.shape.length&&void 0===e.shape[0]),fn(void 0),fn(null)),er=dn(pn,e=>1===e.shape.length&&null===e.shape[0]),tr=(dn(Uint8Array),dn(cn,e=>e.shape===Uint8Array),zn(qn,Kn,Qn,Zn,Wn,Xn,Un)),nr=((()=>{const e=Tn(Fn),t=Nn(Kn,Fn),n=zn(qn,Kn,Qn,Xn,e,t);e.shape=n,t.shape.values=n})(),e=>{if($n.check(e))return e;if(jn.check(e)){const t={};for(const n in e)t[n]=nr(e[n]);return new kn(t)}return Dn.check(e)?zn(...e.map(nr)):tr.check(e)?fn(e):In.check(e)?dn(e):void it()}),rr=Kt?()=>{}:(e,t)=>{const n=new on;if(!t.check(e,n))throw rt(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},sr=($e=Fn,new class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:nr(e),h:t}),this}else(e){return this.if(Fn,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){const r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw rt("Unhandled pattern")}}}($e)).if(Jn,(e,t)=>Qt(t,ke,we)).if(Gn,(e,t)=>((e,t=0,n=20)=>{const r=tn(e,t,n);let s="";for(let i=0;i<r;i++)s+=nn(e);return s})(t)).if(Yn,(e,t)=>Zt(t)).if(Hn,(e,t)=>BigInt(Qt(t,ke,we))).if(Ln,(e,t)=>ir(t,rn(t,e.shape))).if(Sn,(e,t)=>{const n={};for(const r in e.shape){let s=e.shape[r];if(vn.check(s)){if(Zt(t))continue;s=s.shape}n[r]=sr(s,t)}return n}).if(Mn,(e,t)=>{const n=[],r=en(t,0,42);for(let s=0;s<r;s++)n.push(ir(t,e.shape));return n}).if(gn,(e,t)=>rn(t,e.shape)).if(er,(e,t)=>null).if(Rn,(e,t)=>{const n=ir(t,e.res);return()=>n}).if(Vn,(e,t)=>ir(t,rn(t,[qn,Kn,Qn,Zn,Wn,Xn,Tn(qn),Nn(zn("a","b","c"),qn)]))).if(En,(e,t)=>{const n={},r=Qt(t,0,3);for(let s=0;s<r;s++)n[ir(t,e.shape.keys)]=ir(t,e.shape.values);return n}).done(),ir=(e,t)=>sr(nr(t),e),or="undefined"!=typeof document?document:{},lr=(un(e=>e.nodeType===dr),"undefined"!=typeof DOMParser&&new DOMParser,un(e=>e.nodeType===lr),un(e=>e.nodeType===ar),or.ELEMENT_NODE),ar=or.TEXT_NODE,cr=(or.CDATA_SECTION_NODE,or.COMMENT_NODE,or.DOCUMENT_NODE),dr=(or.DOCUMENT_TYPE_NODE,or.DOCUMENT_FRAGMENT_NODE),hr=(un(e=>e.nodeType===cr),JSON.stringify,_t=clearTimeout,class{constructor(e){this._=e}destroy(){_t(this._)}}),ur=(e,t)=>new hr(setTimeout(t,e)),pr=Symbol,fr=pr(),gr=pr(),mr=(pr(),pr(),pr(),pr()),xr=(pr(),pr()),br=(pr(),Nt(),Yt("font-weight","bold"),Yt("font-weight","normal"),Yt("color","blue"),Yt("color","green"),Yt("color","grey"),Yt("color","red"),Yt("color","purple"),Yt("color","orange"),Yt("color","black"),(...e)=>{vr.forEach(t=>t.print(e))}),yr=(...e)=>{e.unshift(xr),vr.forEach(t=>t.print(e))},vr=ae(),wr=e=>({[Symbol.iterator](){return this},next:e}),kr=(e,t)=>wr(()=>{const{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),Sr=class{constructor(e,t){this.clock=e,this.len=t}},jr=class{constructor(){this.clients=new Map}},Cr=(e,t,n)=>t.clients.forEach((t,r)=>{const s=e.doc.store.clients.get(r);if(null!=s){const r=s[s.length-1],i=r.id.clock+r.length;for(let o=0,l=t[o];o<t.length&&l.clock<i;l=t[++o])ys(e,s,l.clock,l.len,n)}}),Nr=(e,t)=>{const n=e.clients.get(t.client);return void 0!==n&&null!==((e,t)=>{let n=0,r=e.length-1;for(;n<=r;){const s=me((n+r)/2),i=e[s],o=i.clock;if(o<=t){if(t<o+i.len)return s;n=s+1}else r=s-1}return null})(n,t.clock)},Er=e=>{e.clients.forEach(e=>{let t,n;for(e.sort((e,t)=>e.clock-t.clock),t=1,n=1;t<e.length;t++){const r=e[n-1],s=e[t];r.clock+r.len>=s.clock?e[n-1]=new Sr(r.clock,ye(r.len,s.clock+s.len-r.clock)):(n<t&&(e[n]=s),n++)}e.length=n})},Ar=e=>{const t=new jr;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,s)=>{if(!t.clients.has(s)){const i=r.slice();for(let t=n+1;t<e.length;t++)de(i,e[t].clients.get(s)||[]);t.clients.set(s,i)}});return Er(t),t},_r=(e,t,n,r)=>{le(e.clients,t,()=>[]).push(new Sr(n,r))},Tr=()=>new jr,Mr=(e,t)=>{Fe(e.restEncoder,t.clients.size),he(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),Fe(e.restEncoder,t);const r=n.length;Fe(e.restEncoder,r);for(let s=0;s<r;s++){const t=n[s];e.writeDsClock(t.clock),e.writeDsLen(t.len)}})},Dr=e=>{const t=new jr,n=ut(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();const n=ut(e.restDecoder),r=ut(e.restDecoder);if(r>0){const s=le(t.clients,n,()=>[]);for(let t=0;t<r;t++)s.push(new Sr(e.readDsClock(),e.readDsLen()))}}return t},Or=(e,t,n)=>{const r=new jr,s=ut(e.restDecoder);for(let i=0;i<s;i++){e.resetDsCurVal();const s=ut(e.restDecoder),i=ut(e.restDecoder),o=n.clients.get(s)||[],l=us(n,s);for(let n=0;n<i;n++){const n=e.readDsClock(),i=n+e.readDsLen();if(n<l){l<i&&_r(r,s,l,i-l);let e=fs(o,n),a=o[e];for(!a.deleted&&a.id.clock<n&&(o.splice(e+1,0,oo(t,a,n-a.id.clock)),e++);e<o.length&&(a=o[e++],a.id.clock<i);)a.deleted||(i<a.id.clock+a.length&&o.splice(e,0,oo(t,a,i-a.id.clock)),a.delete(t))}else _r(r,s,n,i-n)}}if(r.clients.size>0){const e=new Fr;return Fe(e.restEncoder,0),Mr(e,r),e.toUint8Array()}return null},$r=jt,Rr=class e extends ge{constructor({guid:e=Ct(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:i=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=$r(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new ds,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=i,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Et(e=>{this.on("load",()=>{this.isLoaded=!0,e(this)})});const l=()=>Et(e=>{const t=n=>{void 0!==n&&!0!==n||(this.off("sync",t),e())};this.on("sync",t)});this.on("sync",e=>{!1===e&&this.isSynced&&(this.whenSynced=l()),this.isSynced=void 0===e||!0===e,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;null===e||this.shouldLoad||Cs(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(he(this.subdocs).map(e=>e.guid))}transact(e,t=null){return Cs(this,e,t)}get(e,t=Js){const n=le(this.share,e,()=>{const e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==Js&&r!==t){if(r===Js){const r=new t;r._map=n._map,n._map.forEach(e=>{for(;null!==e;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;null!==e;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}throw new Error(`Type with the name ${e} has already been defined with a different constructor`)}return n}getArray(e=""){return this.get(e,ui)}getText(e=""){return this.get(e,Ti)}getMap(e=""){return this.get(e,fi)}getXmlElement(e=""){return this.get(e,Oi)}getXmlFragment(e=""){return this.get(e,Di)}toJSON(){const e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,he(this.subdocs).forEach(e=>e.destroy());const t=this._item;if(null!==t){this._item=null;const n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,Cs(t.parent.doc,e=>{const r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Ir=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=ut(this.restDecoder),this.dsCurrVal}readDsLen(){const e=ut(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Pr=class extends Ir{constructor(e){super(e),this.keys=[],ut(e),this.keyClockDecoder=new vt(dt(e)),this.clientDecoder=new yt(dt(e)),this.leftClockDecoder=new vt(dt(e)),this.rightClockDecoder=new vt(dt(e)),this.infoDecoder=new bt(dt(e),ht),this.stringDecoder=new wt(dt(e)),this.parentInfoDecoder=new bt(dt(e),ht),this.typeRefDecoder=new yt(dt(e)),this.lenDecoder=new yt(dt(e))}readLeftID(){return new Gr(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Gr(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return xt(this.restDecoder)}readBuf(){return dt(this.restDecoder)}readJSON(){return xt(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const e=this.stringDecoder.read();return this.keys.push(e),e}}},zr=class{constructor(){this.restEncoder=Pe()}toUint8Array(){return ze(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Fe(this.restEncoder,e)}writeDsLen(e){Fe(this.restEncoder,e)}},Lr=class extends zr{writeLeftID(e){Fe(this.restEncoder,e.client),Fe(this.restEncoder,e.clock)}writeRightID(e){Fe(this.restEncoder,e.client),Fe(this.restEncoder,e.clock)}writeClient(e){Fe(this.restEncoder,e)}writeInfo(e){Be(this.restEncoder,e)}writeString(e){Ue(this.restEncoder,e)}writeParentInfo(e){Fe(this.restEncoder,e?1:0)}writeTypeRef(e){Fe(this.restEncoder,e)}writeLen(e){Fe(this.restEncoder,e)}writeAny(e){Xe(this.restEncoder,e)}writeBuf(e){Je(this.restEncoder,e)}writeJSON(e){Ue(this.restEncoder,JSON.stringify(e))}writeKey(e){Ue(this.restEncoder,e)}},Br=class{constructor(){this.restEncoder=Pe(),this.dsCurrVal=0}toUint8Array(){return ze(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,Fe(this.restEncoder,t)}writeDsLen(e){0===e&&it(),Fe(this.restEncoder,e-1),this.dsCurrVal+=e}},Fr=class extends Br{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new tt,this.clientEncoder=new Qe,this.leftClockEncoder=new tt,this.rightClockEncoder=new tt,this.infoEncoder=new Ye(Be),this.stringEncoder=new nt,this.parentInfoEncoder=new Ye(Be),this.typeRefEncoder=new Qe,this.lenEncoder=new Qe}toUint8Array(){const e=Pe();return Fe(e,0),Je(e,this.keyClockEncoder.toUint8Array()),Je(e,this.clientEncoder.toUint8Array()),Je(e,this.leftClockEncoder.toUint8Array()),Je(e,this.rightClockEncoder.toUint8Array()),Je(e,ze(this.infoEncoder)),Je(e,this.stringEncoder.toUint8Array()),Je(e,ze(this.parentInfoEncoder)),Je(e,this.typeRefEncoder.toUint8Array()),Je(e,this.lenEncoder.toUint8Array()),qe(e,ze(this.restEncoder)),ze(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){Xe(this.restEncoder,e)}writeBuf(e){Je(this.restEncoder,e)}writeJSON(e){Xe(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);void 0===t?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},Vr=(e,t,n)=>{const r=new Map;n.forEach((e,n)=>{us(t,n)>e&&r.set(n,e)}),hs(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),Fe(e.restEncoder,r.size),he(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{((e,t,n,r)=>{r=ye(r,t[0].id.clock);const s=fs(t,r);Fe(e.restEncoder,t.length-s),e.writeClient(n),Fe(e.restEncoder,r);const i=t[s];i.write(e,r-i.id.clock);for(let o=s+1;o<t.length;o++)t[o].write(e,0)})(e,t.clients.get(n),n,r)})},Wr=(e,t,n,r=Pr)=>{const s=ct(t);((e,t,n,r=new Pr(e))=>{Cs(t,e=>{e.local=!1;let t=!1;const n=e.doc,s=n.store,i=((e,t,n)=>{const r=[];let s=he(n.keys()).sort((e,t)=>e-t);if(0===s.length)return null;const i=()=>{if(0===s.length)return null;let e=n.get(s[s.length-1]);for(;e.refs.length===e.i;){if(s.pop(),!(s.length>0))return null;e=n.get(s[s.length-1])}return e};let o=i();if(null===o)return null;const l=new ds,a=new Map,c=(e,t)=>{const n=a.get(e);(null==n||n>t)&&a.set(e,t)};let d=o.refs[o.i++];const h=new Map,u=()=>{for(const e of r){const t=e.id.client,r=n.get(t);r?(r.i--,l.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):l.clients.set(t,[e]),s=s.filter(e=>e!==t)}r.length=0};for(;;){if(d.constructor!==po){const s=le(h,d.id.client,()=>us(t,d.id.client))-d.id.clock;if(s<0)r.push(d),c(d.id.client,d.id.clock-1),u();else{const i=d.getMissing(e,t);if(null!==i){r.push(d);const e=n.get(i)||{refs:[],i:0};if(e.refs.length!==e.i){d=e.refs[e.i++];continue}c(i,us(t,i)),u()}else(0===s||s<d.length)&&(d.integrate(e,s),h.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(null!==o&&o.i<o.refs.length)d=o.refs[o.i++];else{if(o=i(),null===o)break;d=o.refs[o.i++]}}if(l.clients.size>0){const e=new Fr;return Vr(e,l,new Map),Fe(e.restEncoder,0),{missing:a,update:e.toUint8Array()}}return null})(e,s,((e,t)=>{const n=ie(),r=ut(e.restDecoder);for(let s=0;s<r;s++){const r=ut(e.restDecoder),s=new Array(r),i=e.readClient();let o=ut(e.restDecoder);n.set(i,{i:0,refs:s});for(let n=0;n<r;n++){const r=e.readInfo();switch(31&r){case 0:{const t=e.readLen();s[n]=new zi(Yr(i,o),t),o+=t;break}case 10:{const t=ut(e.restDecoder);s[n]=new po(Yr(i,o),t),o+=t;break}default:{const l=!(192&r),a=new co(Yr(i,o),null,128&~r?null:e.readLeftID(),null,64&~r?null:e.readRightID(),l?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,!l||32&~r?null:e.readString(),ho(e,r));s[n]=a,o+=a.length}}}}return n})(r,n)),o=s.pendingStructs;if(o){for(const[e,n]of o.missing)if(n<us(s,e)){t=!0;break}if(i){for(const[e,t]of i.missing){const n=o.missing.get(e);(null==n||n>t)&&o.missing.set(e,t)}o.update=Os([o.update,i.update])}}else s.pendingStructs=i;const l=Or(r,e,s);if(s.pendingDs){const t=new Pr(ct(s.pendingDs));ut(t.restDecoder);const n=Or(t,e,s);s.pendingDs=l&&n?Os([l,n]):l||n}else s.pendingDs=l;if(t){const t=s.pendingStructs.update;s.pendingStructs=null,Wr(e.doc,t)}},n,!1)})(s,e,n,new r(s))},Hr=class{constructor(){this.l=[]}},Ur=()=>new Hr,qr=(e,t)=>e.l.push(t),Jr=(e,t)=>{const n=e.l;n.length,e.l=n.filter(e=>t!==e),e.l.length},Kr=(e,t,n)=>Bt(e.l,[t,n]),Gr=class{constructor(e,t){this.client=e,this.clock=t}},Xr=(e,t)=>e===t||null!==e&&null!==t&&e.client===t.client&&e.clock===t.clock,Yr=(e,t)=>new Gr(e,t),Zr=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw it()},Qr=(e,t)=>{for(;null!==t;){if(t.parent===e)return!0;t=t.parent._item}return!1},es=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ts=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},ns=(e,t,n)=>{let r=null,s=null;return null===e._item?s=Zr(e):r=Yr(e._item.id.client,e._item.id.clock),new es(r,s,t,n)},rs=(e,t,n=0)=>{let r=e._start;if(n<0){if(0===t)return ns(e,null,n);t--}for(;null!==r;){if(!r.deleted&&r.countable){if(r.length>t)return ns(e,Yr(r.id.client,r.id.clock+t),n);t-=r.length}if(null===r.right&&n<0)return ns(e,r.lastId,n);r=r.right}return ns(e,null,n)},ss=(e,t,n=!0)=>{const r=t.store,s=e.item,i=e.type,o=e.tname,l=e.assoc;let a=null,c=0;if(null!==s){if(us(r,s.client)<=s.clock)return null;const e=n?so(r,s):((e,t)=>{const n=gs(e,t);return{item:n,diff:t.clock-n.id.clock}})(r,s),t=e.item;if(!(t instanceof co))return null;if(a=t.parent,null===a._item||!a._item.deleted){c=t.deleted||!t.countable?0:e.diff+(l>=0?0:1);let n=t.left;for(;null!==n;)!n.deleted&&n.countable&&(c+=n.length),n=n.left}}else{if(null!==o)a=t.get(o);else{if(null===i)throw it();{if(us(r,i.client)<=i.clock)return null;const{item:e}=n?so(r,i):{item:gs(r,i)};if(!(e instanceof co&&e.content instanceof ro))return null;a=e.content.type}}c=l>=0?a._length:0}return((e,t,n=0)=>new ts(e,t,n))(a,c,e.assoc)},is=class{constructor(e,t){this.ds=e,this.sv=t}},os=(e,t)=>new is(e,t),ls=(os(Tr(),new Map),e=>os((e=>{const t=Tr();return e.clients.forEach((e,n)=>{const r=[];for(let t=0;t<e.length;t++){const n=e[t];if(n.deleted){const s=n.id.clock;let i=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[1+ ++t])i+=n.length;r.push(new Sr(s,i))}}r.length>0&&t.clients.set(n,r)}),t})(e.store),hs(e.store))),as=(e,t)=>void 0===t?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Nr(t.ds,e.id),cs=(e,t)=>{const n=le(e.meta,cs,ae),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<us(r,n)&&xs(e,Yr(n,t))}),Cr(e,t.ds,e=>{}),n.add(t))},ds=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},hs=e=>{const t=new Map;return e.clients.forEach((e,n)=>{const r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},us=(e,t)=>{const n=e.clients.get(t);if(void 0===n)return 0;const r=n[n.length-1];return r.id.clock+r.length},ps=(e,t)=>{let n=e.clients.get(t.id.client);if(void 0===n)n=[],e.clients.set(t.id.client,n);else{const e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw it()}n.push(t)},fs=(e,t)=>{let n=0,r=e.length-1,s=e[r],i=s.id.clock;if(i===t)return r;let o=me(t/(i+s.length-1)*r);for(;n<=r;){if(s=e[o],i=s.id.clock,i<=t){if(t<i+s.length)return o;n=o+1}else r=o-1;o=me((n+r)/2)}throw it()},gs=(e,t)=>{const n=e.clients.get(t.client);return n[fs(n,t.clock)]},ms=(e,t,n)=>{const r=fs(t,n),s=t[r];return s.id.clock<n&&s instanceof co?(t.splice(r+1,0,oo(e,s,n-s.id.clock)),r+1):r},xs=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[ms(e,n,t.clock)]},bs=(e,t,n)=>{const r=t.clients.get(n.client),s=fs(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==zi&&r.splice(s+1,0,oo(e,i,n.clock-i.id.clock+1)),i},ys=(e,t,n,r,s)=>{if(0===r)return;const i=n+r;let o,l=ms(e,t,n);do{o=t[l++],i<o.id.clock+o.length&&ms(e,t,i),s(o)}while(l<t.length&&t[l].id.clock<i)},vs=class{constructor(e,t,n){this.doc=e,this.deleteSet=new jr,this.beforeState=hs(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},ws=(e,t)=>!(0===t.deleteSet.clients.size&&!((e,t)=>{for(const[n,r]of e)if(t(r,n))return!0;return!1})(t.afterState,(e,n)=>t.beforeState.get(n)!==e)||(Er(t.deleteSet),((e,t)=>{Vr(e,t.doc.store,t.beforeState)})(e,t),Mr(e,t.deleteSet),0)),ks=(e,t,n)=>{const r=t._item;(null===r||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&le(e.changed,t,ae).add(n)},Ss=(e,t)=>{let n=e[t],r=e[t-1],s=t;for(;s>0&&r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n);n=r,r=e[--s-1])n instanceof co&&null!==n.parentSub&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);const i=t-s;return i&&e.splice(t+1-i,i),i},js=(e,t)=>{if(t<e.length){const n=e[t],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{Er(i),n.afterState=hs(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const e=[];n.changed.forEach((t,r)=>e.push(()=>{null!==r._item&&r._item.deleted||r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(null===r._item||!r._item.deleted)&&((t=t.filter(e=>null===e.target._item||!e.target._item.deleted)).forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{Kr(r._dEH,t,n)}))}),e.push(()=>r.emit("afterTransaction",[n,r])),e.push(()=>{n._needFormattingCleanup&&Ei(n)})}),Bt(e,[])}finally{r.gc&&((e,t,n)=>{for(const[r,s]of e.clients.entries()){const e=t.clients.get(r);for(let r=s.length-1;r>=0;r--){const i=s[r],o=i.clock+i.len;for(let r=fs(e,i.clock),s=e[r];r<e.length&&s.id.clock<o;s=e[++r]){const s=e[r];if(i.clock+i.len<=s.id.clock)break;s instanceof co&&s.deleted&&!s.keep&&n(s)&&s.gc(t,!1)}}}})(i,s,r.gcFilter),((e,t)=>{e.clients.forEach((e,n)=>{const r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){const n=e[t];for(let e=be(r.length-1,1+fs(r,n.clock+n.len-1)),t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+Ss(r,e)}})})(i,s),n.afterState.forEach((e,t)=>{const r=n.beforeState.get(t)||0;if(r!==e){const e=s.clients.get(t),n=ye(fs(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Ss(e,t)}});for(let e=o.length-1;e>=0;e--){const{client:t,clock:n}=o[e].id,r=s.clients.get(t),i=fs(r,n);i+1<r.length&&Ss(r,i+1)>1||i>0&&Ss(r,i)}if(n.local||n.afterState.get(r.clientID)===n.beforeState.get(r.clientID)||(br(xr,fr,"[yjs] ",gr,mr,"Changed the client-id because another client seems to be using it."),r.clientID=$r()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const e=new Lr;ws(e,n)&&r.emit("update",[e.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const e=new Fr;ws(e,n)&&r.emit("updateV2",[e.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=n;(l.size>0||c.size>0||a.size>0)&&(l.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),c.forEach(e=>r.subdocs.delete(e)),r.emit("subdocs",[{loaded:a,added:l,removed:c},r,n]),c.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):js(e,t+1)}}},Cs=(e,t,n=null,r=!0)=>{const s=e._transactionCleanups;let i=!1,o=null;null===e._transaction&&(i=!0,e._transaction=new vs(e,n,r),s.push(e._transaction),1===s.length&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{o=t(e._transaction)}finally{if(i){const t=e._transaction===s[0];e._transaction=null,t&&js(s,0)}}return o},Ns=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Es=(e,t,n)=>{Cr(e,n.deletions,n=>{n instanceof co&&t.scope.some(t=>t===e.doc||Qr(t,n))&&io(n,!1)})},As=(e,t,n)=>{let r=null;const s=e.doc,i=e.scope;Cs(s,n=>{for(;t.length>0&&null===e.currStackItem;){const r=s.store,o=t.pop(),l=new Set,a=[];let c=!1;Cr(n,o.insertions,e=>{if(e instanceof co){if(null!==e.redone){let{item:t,diff:s}=so(r,e.id);s>0&&(t=xs(n,Yr(t.id.client,t.id.clock+s))),e=t}!e.deleted&&i.some(t=>t===n.doc||Qr(t,e))&&a.push(e)}}),Cr(n,o.deletions,e=>{e instanceof co&&i.some(t=>t===n.doc||Qr(t,e))&&!Nr(o.insertions,e.id)&&l.add(e)}),l.forEach(t=>{c=null!==ao(n,t,l,o.insertions,e.ignoreRemoteMapChanges,e)||c});for(let t=a.length-1;t>=0;t--){const r=a[t];e.deleteFilter(r)&&(r.delete(n),c=!0)}e.currStackItem=c?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);const o=e.currStackItem;if(null!=o){const t=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},_s=class extends ge{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:o=(fe(e)?e[0].doc:e instanceof Rr?e:e.doc)}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=i,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!(this.captureTransaction(e)&&this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)&&(this.trackedOrigins.has(e.origin)||e.origin&&this.trackedOrigins.has(e.origin.constructor))))return;const t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);const s=new jr;e.afterState.forEach((t,n)=>{const r=e.beforeState.get(n)||0,i=t-r;i>0&&_r(s,n,r,i)});const i=Nt();let o=!1;if(this.lastChange>0&&i-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){const t=r[r.length-1];t.deletions=Ar([t.deletions,e.deleteSet]),t.insertions=Ar([t.insertions,s])}else r.push(new Ns(e.deleteSet,s)),o=!0;t||n||(this.lastChange=i),Cr(e,e.deleteSet,t=>{t instanceof co&&this.scope.some(n=>n===e.doc||Qr(n,t))&&io(t,!0)});const l=[{stackItem:r[r.length-1],origin:e.origin,type:t?"redo":"undo",changedParentTypes:e.changedParentTypes},this];o?this.emit("stack-item-added",l):this.emit("stack-item-updated",l)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const t=new Set(this.scope);(e=fe(e)?e:[e]).forEach(e=>{t.has(e)||(t.add(e),(e instanceof Js?e.doc!==this.doc:e!==this.doc)&&yr("[yjs#509] Not same Y.Doc"),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>Es(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Es(n,this,e)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){let e;this.undoing=!0;try{e=As(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){let e;this.redoing=!0;try{e=As(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()}},Ts=class{constructor(e,t){this.gen=function*(e){const t=ut(e.restDecoder);for(let n=0;n<t;n++){const t=ut(e.restDecoder),n=e.readClient();let r=ut(e.restDecoder);for(let s=0;s<t;s++){const t=e.readInfo();if(10===t){const t=ut(e.restDecoder);yield new po(Yr(n,r),t),r+=t}else if(31&t){const s=!(192&t),i=new co(Yr(n,r),null,128&~t?null:e.readLeftID(),null,64&~t?null:e.readRightID(),s?e.readParentInfo()?e.readString():e.readLeftID():null,!s||32&~t?null:e.readString(),ho(e,t));yield i,r+=i.length}else{const t=e.readLen();yield new zi(Yr(n,r),t),r+=t}}}}(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do{this.curr=this.gen.next().value||null}while(this.filterSkips&&null!==this.curr&&this.curr.constructor===po);return this.curr}},Ms=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Ds=(e,t)=>{if(e.constructor===zi){const{client:n,clock:r}=e.id;return new zi(Yr(n,r+t),e.length-t)}if(e.constructor===po){const{client:n,clock:r}=e.id;return new po(Yr(n,r+t),e.length-t)}{const n=e,{client:r,clock:s}=n.id;return new co(Yr(r,s+t),null,Yr(r,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Os=(e,t=Pr,n=Fr)=>{if(1===e.length)return e[0];const r=e.map(e=>new t(ct(e)));let s=r.map(e=>new Ts(e,!0)),i=null;const o=new n,l=new Ms(o);for(;s=s.filter(e=>null!==e.curr),s.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){const n=e.curr.id.clock-t.curr.id.clock;return 0===n?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===po?1:-1:n}return t.curr.id.client-e.curr.id.client}),0!==s.length;){const e=s[0],t=e.curr.id.client;if(null!==i){let n=e.curr,r=!1;for(;null!==n&&n.id.clock+n.length<=i.struct.id.clock+i.struct.length&&n.id.client>=i.struct.id.client;)n=e.next(),r=!0;if(null===n||n.id.client!==t||r&&n.id.clock>i.struct.id.clock+i.struct.length)continue;if(t!==i.struct.id.client)Rs(l,i.struct,i.offset),i={struct:n,offset:0},e.next();else if(i.struct.id.clock+i.struct.length<n.id.clock)if(i.struct.constructor===po)i.struct.length=n.id.clock+n.length-i.struct.id.clock;else{Rs(l,i.struct,i.offset);const e=n.id.clock-i.struct.id.clock-i.struct.length;i={struct:new po(Yr(t,i.struct.id.clock+i.struct.length),e),offset:0}}else{const t=i.struct.id.clock+i.struct.length-n.id.clock;t>0&&(i.struct.constructor===po?i.struct.length-=t:n=Ds(n,t)),i.struct.mergeWith(n)||(Rs(l,i.struct,i.offset),i={struct:n,offset:0},e.next())}}else i={struct:e.curr,offset:0},e.next();for(let n=e.curr;null!==n&&n.id.client===t&&n.id.clock===i.struct.id.clock+i.struct.length&&n.constructor!==po;n=e.next())Rs(l,i.struct,i.offset),i={struct:n,offset:0}}return null!==i&&(Rs(l,i.struct,i.offset),i=null),Is(l),Mr(o,Ar(r.map(e=>Dr(e)))),o.toUint8Array()},$s=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:ze(e.encoder.restEncoder)}),e.encoder.restEncoder=Pe(),e.written=0)},Rs=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&$s(e),0===e.written&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),Fe(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Is=e=>{$s(e);const t=e.encoder.restEncoder;Fe(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const r=e.clientStructs[n];Fe(t,r.written),qe(t,r.restEncoder)}},Ps="You must not compute changes after the event-handler fired.",zs=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Ls(this.currentTarget,this.target))}deletes(e){return Nr(this.transaction.deleteSet,e.id)}get keys(){if(null===this._keys){if(0===this.transaction.doc._transactionCleanups.length)throw rt(Ps);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(null!==n){const r=t._map.get(n);let s,i;if(this.adds(r)){let e=r.left;for(;null!==e&&this.adds(e);)e=e.left;if(this.deletes(r)){if(null===e||!this.deletes(e))return;s="delete",i=ce(e.content.getContent())}else null!==e&&this.deletes(e)?(s="update",i=ce(e.content.getContent())):(s="add",i=void 0)}else{if(!this.deletes(r))return;s="delete",i=ce(r.content.getContent())}e.set(n,{action:s,oldValue:i})}}),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(null===e){if(0===this.transaction.doc._transactionCleanups.length)throw rt(Ps);const t=this.target,n=ae(),r=ae(),s=[];if(e={added:n,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null;const i=()=>{e&&s.push(e)};for(let s=t._start;null!==s;s=s.right)s.deleted?this.deletes(s)&&!this.adds(s)&&(null!==e&&void 0!==e.delete||(i(),e={delete:0}),e.delete+=s.length,r.add(s)):this.adds(s)?(null!==e&&void 0!==e.insert||(i(),e={insert:[]}),e.insert=e.insert.concat(s.content.getContent()),n.add(s)):(null!==e&&void 0!==e.retain||(i(),e={retain:0}),e.retain+=s.length);null!==e&&void 0===e.retain&&i()}this._changes=e}return e}},Ls=(e,t)=>{const n=[];for(;null!==t._item&&t!==e;){if(null!==t._item.parentSub)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&null!==r;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},Bs=()=>{yr("Invalid access: Add Yjs type to a document before reading data.")},Fs=0,Vs=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Fs++}},Ws=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Fs++},Hs=(e,t)=>{if(null===e._start||0===t||null===e._searchMarker)return null;const n=0===e._searchMarker.length?null:e._searchMarker.reduce((e,n)=>xe(t-e.index)<xe(t-n.index)?e:n);let r=e._start,s=0;for(null!==n&&(r=n.p,s=n.index,(e=>{e.timestamp=Fs++})(n));null!==r.right&&s<t;){if(!r.deleted&&r.countable){if(t<s+r.length)break;s+=r.length}r=r.right}for(;null!==r.left&&s>t;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;null!==r.left&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return null!==n&&xe(n.index-s)<r.parent.length/80?(Ws(n,r,s),n):((e,t,n)=>{if(e.length>=80){const r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return Ws(r,t,n),r}{const r=new Vs(t,n);return e.push(r),r}})(e._searchMarker,r,s)},Us=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){const s=e[r];if(n>0){let t=s.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(s.index-=t.length);if(null===t||!0===t.marker){e.splice(r,1);continue}s.p=t,t.marker=!0}(t<s.index||n>0&&t===s.index)&&(s.index=ye(t,s.index+n))}},qs=(e,t,n)=>{const r=e,s=t.changedParentTypes;for(;le(s,e,()=>[]).push(n),null!==e._item;)e=e._item.parent;Kr(r._eH,n,t)},Js=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ur(),this._dEH=Ur(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw st()}clone(){throw st()}_write(e){}get _first(){let e=this._start;for(;null!==e&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){qr(this._eH,e)}observeDeep(e){qr(this._dEH,e)}unobserve(e){Jr(this._eH,e)}unobserveDeep(e){Jr(this._dEH,e)}toJSON(){}},Ks=(e,t,n)=>{e.doc??Bs(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t;const s=[];let i=e._start;for(;null!==i&&r>0;){if(i.countable&&!i.deleted){const e=i.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)s.push(e[n]),r--;t=0}}i=i.right}return s},Gs=e=>{e.doc??Bs();const t=[];let n=e._start;for(;null!==n;){if(n.countable&&!n.deleted){const e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},Xs=(e,t)=>{const n=[];let r=e._start;for(;null!==r;){if(r.countable&&as(r,t)){const e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},Ys=(e,t)=>{let n=0,r=e._start;for(e.doc??Bs();null!==r;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let r=0;r<s.length;r++)t(s[r],n++,e)}r=r.right}},Zs=(e,t)=>{const n=[];return Ys(e,(r,s)=>{n.push(t(r,s,e))}),n},Qs=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(null===n){for(;null!==t&&t.deleted;)t=t.right;if(null===t)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}const e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},ei=(e,t)=>{e.doc??Bs();const n=Hs(e,t);let r=e._start;for(null!==n&&(r=n.p,t-=n.index);null!==r;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},ti=(e,t,n,r)=>{let s=n;const i=e.doc,o=i.clientID,l=i.store,a=null===n?t._start:n.right;let c=[];const d=()=>{c.length>0&&(s=new co(Yr(o,us(l,o)),s,s&&s.lastId,a,a&&a.id,t,null,new Ji(c)),s.integrate(e,0),c=[])};r.forEach(n=>{if(null===n)c.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(n);break;default:switch(d(),n.constructor){case Uint8Array:case ArrayBuffer:s=new co(Yr(o,us(l,o)),s,s&&s.lastId,a,a&&a.id,t,null,new Li(new Uint8Array(n))),s.integrate(e,0);break;case Rr:s=new co(Yr(o,us(l,o)),s,s&&s.lastId,a,a&&a.id,t,null,new Vi(n)),s.integrate(e,0);break;default:if(!(n instanceof Js))throw new Error("Unexpected content type in insert operation");s=new co(Yr(o,us(l,o)),s,s&&s.lastId,a,a&&a.id,t,null,new ro(n)),s.integrate(e,0)}}}),d()},ni=()=>rt("Length exceeded!"),ri=(e,t,n,r)=>{if(n>t._length)throw ni();if(0===n)return t._searchMarker&&Us(t._searchMarker,n,r.length),ti(e,t,null,r);const s=n,i=Hs(t,n);let o=t._start;for(null!==i&&(o=i.p,0===(n-=i.index)&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));null!==o;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&xs(e,Yr(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&Us(t._searchMarker,s,r.length),ti(e,t,o,r)},si=(e,t,n,r)=>{if(0===r)return;const s=n,i=r,o=Hs(t,n);let l=t._start;for(null!==o&&(l=o.p,n-=o.index);null!==l&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&xs(e,Yr(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&null!==l;)l.deleted||(r<l.length&&xs(e,Yr(l.id.client,l.id.clock+r)),l.delete(e),r-=l.length),l=l.right;if(r>0)throw ni();t._searchMarker&&Us(t._searchMarker,s,-i+r)},ii=(e,t,n)=>{const r=t._map.get(n);void 0!==r&&r.delete(e)},oi=(e,t,n,r)=>{const s=t._map.get(n)||null,i=e.doc,o=i.clientID;let l;if(null==r)l=new Ji([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Ji([r]);break;case Uint8Array:l=new Li(r);break;case Rr:l=new Vi(r);break;default:if(!(r instanceof Js))throw new Error("Unexpected content type");l=new ro(r)}new co(Yr(o,us(i.store,o)),s,s&&s.lastId,null,null,t,n,l).integrate(e,0)},li=(e,t)=>{e.doc??Bs();const n=e._map.get(t);return void 0===n||n.deleted?void 0:n.content.getContent()[n.length-1]},ai=e=>{const t={};return e.doc??Bs(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},ci=(e,t)=>{e.doc??Bs();const n=e._map.get(t);return void 0!==n&&!n.deleted},di=e=>{return e.doc??Bs(),t=e._map.entries(),n=e=>!e[1].deleted,wr(()=>{let e;do{e=t.next()}while(!e.done&&!n(e.value));return e});var t,n},hi=class extends zs{},ui=class e extends Js{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){const t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Js?e.clone():e)),t}get length(){return this.doc??Bs(),this._length}_callObserver(e,t){super._callObserver(e,t),qs(this,e,new hi(this,e))}insert(e,t){null!==this.doc?Cs(this.doc,n=>{ri(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){null!==this.doc?Cs(this.doc,t=>{((e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;ti(e,t,r,n)})(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){null!==this.doc?Cs(this.doc,n=>{si(n,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return ei(this,e)}toArray(){return Gs(this)}slice(e=0,t=this.length){return Ks(this,e,t)}toJSON(){return this.map(e=>e instanceof Js?e.toJSON():e)}map(e){return Zs(this,e)}forEach(e){Ys(this,e)}[Symbol.iterator](){return Qs(this)}_write(e){e.writeTypeRef(Xi)}},pi=class extends zs{constructor(e,t,n){super(e,t),this.keysChanged=n}},fi=class e extends Js{constructor(e){super(),this._prelimContent=null,this._prelimContent=void 0===e?new Map:new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){const t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof Js?e.clone():e)}),t}_callObserver(e,t){qs(this,e,new pi(this,e,t))}toJSON(){this.doc??Bs();const e={};return this._map.forEach((t,n)=>{if(!t.deleted){const r=t.content.getContent()[t.length-1];e[n]=r instanceof Js?r.toJSON():r}}),e}get size(){return[...di(this)].length}keys(){return kr(di(this),e=>e[0])}values(){return kr(di(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return kr(di(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Bs(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){null!==this.doc?Cs(this.doc,t=>{ii(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return null!==this.doc?Cs(this.doc,n=>{oi(n,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return li(this,e)}has(e){return ci(this,e)}clear(){null!==this.doc?Cs(this.doc,e=>{this.forEach(function(t,n,r){ii(e,r,n)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Yi)}},gi=(e,t)=>e===t||"object"==typeof e&&"object"==typeof t&&e&&t&&((e,t)=>e===t||Rt(e)===Rt(t)&&It(e,(e,n)=>(void 0!==e||Pt(t,n))&&Dt(t[n],e)))(e,t),mi=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){null===this.right&&it(),this.right.content.constructor===Hi?this.right.deleted||vi(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},xi=(e,t,n)=>{for(;null!==t.right&&n>0;)t.right.content.constructor===Hi?t.right.deleted||vi(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&xs(e,Yr(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},bi=(e,t,n,r)=>{const s=new Map,i=r?Hs(t,n):null;return i?xi(e,new mi(i.p.left,i.p,i.index,s),n-i.index):xi(e,new mi(null,t._start,0,s),n)},yi=(e,t,n,r)=>{for(;null!==n.right&&(!0===n.right.deleted||n.right.content.constructor===Hi&&gi(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=e.doc,i=s.clientID;r.forEach((r,o)=>{const l=n.left,a=n.right,c=new co(Yr(i,us(s.store,i)),l,l&&l.lastId,a,a&&a.id,t,null,new Hi(o,r));c.integrate(e,0),n.right=c,n.forward()})},vi=(e,t)=>{const{key:n,value:r}=t;null===r?e.delete(n):e.set(n,r)},wi=(e,t)=>{for(;null!==e.right&&(e.right.deleted||e.right.content.constructor===Hi&&gi(t[e.right.content.key]??null,e.right.content.value));)e.forward()},ki=(e,t,n,r)=>{const s=e.doc,i=s.clientID,o=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!gi(c,a)){o.set(l,c);const{left:r,right:d}=n;n.right=new co(Yr(i,us(s.store,i)),r,r&&r.lastId,d,d&&d.id,t,null,new Hi(l,a)),n.right.integrate(e,0),n.forward()}}return o},Si=(e,t,n,r,s)=>{n.currentAttributes.forEach((e,t)=>{void 0===s[t]&&(s[t]=null)});const i=e.doc,o=i.clientID;wi(n,s);const l=ki(e,t,n,s),a=r.constructor===String?new Ki(r):r instanceof Js?new ro(r):new Wi(r);let{left:c,right:d,index:h}=n;t._searchMarker&&Us(t._searchMarker,n.index,a.getLength()),d=new co(Yr(o,us(i.store,o)),c,c&&c.lastId,d,d&&d.id,t,null,a),d.integrate(e,0),n.right=d,n.index=h,n.forward(),yi(e,t,n,l)},ji=(e,t,n,r,s)=>{const i=e.doc,o=i.clientID;wi(n,s);const l=ki(e,t,n,s);e:for(;null!==n.right&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Hi));){if(!n.right.deleted)switch(n.right.content.constructor){case Hi:{const{key:t,value:i}=n.right.content,o=s[t];if(void 0!==o){if(gi(o,i))l.delete(t);else{if(0===r)break e;l.set(t,i)}n.right.delete(e)}else n.currentAttributes.set(t,i);break}default:r<n.right.length&&xs(e,Yr(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let s="";for(;r>0;r--)s+="\n";n.right=new co(Yr(o,us(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Ki(s)),n.right.integrate(e,0),n.forward()}yi(e,t,n,l)},Ci=(e,t,n,r,s)=>{let i=t;const o=ie();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Hi){const e=i.content;o.set(e.key,e)}i=i.right}let l=0,a=!1;for(;t!==i;){if(n===t&&(a=!0),!t.deleted){const n=t.content;switch(n.constructor){case Hi:{const{key:i,value:c}=n,d=r.get(i)??null;o.get(i)===n&&d!==c||(t.delete(e),l++,a||(s.get(i)??null)!==c||d===c||(null===d?s.delete(i):s.set(i,d))),a||t.deleted||vi(s,n);break}}}t=t.right}return l},Ni=e=>{let t=0;return Cs(e.doc,n=>{let r=e._start,s=e._start,i=ie();const o=oe(i);for(;s;)!1===s.deleted&&(s.content.constructor===Hi?vi(o,s.content):(t+=Ci(n,r,s,i,o),i=oe(o),r=s)),s=s.right}),t},Ei=e=>{const t=new Set,n=e.doc;for(const[r,s]of e.afterState.entries()){const i=e.beforeState.get(r)||0;s!==i&&ys(e,n.store.clients.get(r),i,s,e=>{e.deleted||e.content.constructor!==Hi||e.constructor===zi||t.add(e.parent)})}Cs(n,n=>{Cr(e,e.deleteSet,e=>{if(e instanceof zi||!e.parent._hasFormatting||t.has(e.parent))return;const r=e.parent;e.content.constructor===Hi?t.add(r):((e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===Hi){const r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}})(n,e)});for(const e of t)Ni(e)})},Ai=(e,t,n)=>{const r=n,s=oe(t.currentAttributes),i=t.right;for(;n>0&&null!==t.right;){if(!1===t.right.deleted)switch(t.right.content.constructor){case ro:case Wi:case Ki:n<t.right.length&&xs(e,Yr(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}i&&Ci(e,i,t.right,s,t.currentAttributes);const o=(t.left||t.right).parent;return o._searchMarker&&Us(o._searchMarker,t.index,-r+n),t},_i=class extends zs{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{null===e?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(null===this._changes){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(null===this._delta){const e=this.target.doc,t=[];Cs(e,e=>{const n=new Map,r=new Map;let s=this.target._start,i=null;const o={};let l="",a=0,c=0;const d=()=>{if(null!==i){let e=null;switch(i){case"delete":c>0&&(e={delete:c}),c=0;break;case"insert":("object"==typeof l||l.length>0)&&(e={insert:l},n.size>0&&(e.attributes={},n.forEach((t,n)=>{null!==t&&(e.attributes[n]=t)}))),l="";break;case"retain":a>0&&(e={retain:a},(e=>{for(const t in e)return!1;return!0})(o)||(e.attributes=Ot({},o))),a=0}e&&t.push(e),i=null}};for(;null!==s;){switch(s.content.constructor){case ro:case Wi:this.adds(s)?this.deletes(s)||(d(),i="insert",l=s.content.getContent()[0],d()):this.deletes(s)?("delete"!==i&&(d(),i="delete"),c+=1):s.deleted||("retain"!==i&&(d(),i="retain"),a+=1);break;case Ki:this.adds(s)?this.deletes(s)||("insert"!==i&&(d(),i="insert"),l+=s.content.str):this.deletes(s)?("delete"!==i&&(d(),i="delete"),c+=s.length):s.deleted||("retain"!==i&&(d(),i="retain"),a+=s.length);break;case Hi:{const{key:t,value:l}=s.content;if(this.adds(s))this.deletes(s)||(gi(n.get(t)??null,l)?null!==l&&s.delete(e):("retain"===i&&d(),gi(l,r.get(t)??null)?delete o[t]:o[t]=l));else if(this.deletes(s)){r.set(t,l);const e=n.get(t)??null;gi(e,l)||("retain"===i&&d(),o[t]=e)}else if(!s.deleted){r.set(t,l);const n=o[t];void 0!==n&&(gi(n,l)?null!==n&&s.delete(e):("retain"===i&&d(),null===l?delete o[t]:o[t]=l))}s.deleted||("insert"===i&&d(),vi(n,s.content));break}}s=s.right}for(d();t.length>0;){const e=t[t.length-1];if(void 0===e.retain||void 0!==e.attributes)break;t.pop()}}),this._delta=t}return this._delta}},Ti=class e extends Js{constructor(e){super(),this._pending=void 0!==e?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Bs(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(Fh){}this._pending=null}_copy(){return new e}clone(){const t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);const n=new _i(this,e,t);qs(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Bs();let e="",t=this._start;for(;null!==t;)!t.deleted&&t.countable&&t.content.constructor===Ki&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){null!==this.doc?Cs(this.doc,n=>{const r=new mi(null,this._start,0,new Map);for(let s=0;s<e.length;s++){const i=e[s];if(void 0!==i.insert){const o=t||"string"!=typeof i.insert||s!==e.length-1||null!==r.right||"\n"!==i.insert.slice(-1)?i.insert:i.insert.slice(0,-1);("string"!=typeof o||o.length>0)&&Si(n,this,r,o,i.attributes||{})}else void 0!==i.retain?ji(n,this,r,i.retain,i.attributes||{}):void 0!==i.delete&&Ai(n,r,i.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,n){this.doc??Bs();const r=[],s=new Map,i=this.doc;let o="",l=this._start;function a(){if(o.length>0){const e={};let t=!1;s.forEach((n,r)=>{t=!0,e[r]=n});const n={insert:o};t&&(n.attributes=e),r.push(n),o=""}}const c=()=>{for(;null!==l;){if(as(l,e)||void 0!==t&&as(l,t))switch(l.content.constructor){case Ki:{const r=s.get("ychange");void 0===e||as(l,e)?void 0===t||as(l,t)?void 0!==r&&(a(),s.delete("ychange")):void 0!==r&&r.user===l.id.client&&"added"===r.type||(a(),s.set("ychange",n?n("added",l.id):{type:"added"})):void 0!==r&&r.user===l.id.client&&"removed"===r.type||(a(),s.set("ychange",n?n("removed",l.id):{type:"removed"})),o+=l.content.str;break}case ro:case Wi:{a();const e={insert:l.content.getContent()[0]};if(s.size>0){const t={};e.attributes=t,s.forEach((e,n)=>{t[n]=e})}r.push(e);break}case Hi:as(l,e)&&(a(),vi(s,l.content))}l=l.right}a()};return e||t?Cs(i,n=>{e&&cs(n,e),t&&cs(n,t),c()},"cleanup"):c(),r}insert(e,t,n){if(t.length<=0)return;const r=this.doc;null!==r?Cs(r,r=>{const s=bi(r,this,e,!n);n||(n={},s.currentAttributes.forEach((e,t)=>{n[t]=e})),Si(r,this,s,t,n)}):this._pending.push(()=>this.insert(e,t,n))}insertEmbed(e,t,n){const r=this.doc;null!==r?Cs(r,r=>{const s=bi(r,this,e,!n);Si(r,this,s,t,n||{})}):this._pending.push(()=>this.insertEmbed(e,t,n||{}))}delete(e,t){if(0===t)return;const n=this.doc;null!==n?Cs(n,n=>{Ai(n,bi(n,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,n){if(0===t)return;const r=this.doc;null!==r?Cs(r,r=>{const s=bi(r,this,e,!1);null!==s.right&&ji(r,this,s,t,n)}):this._pending.push(()=>this.format(e,t,n))}removeAttribute(e){null!==this.doc?Cs(this.doc,t=>{ii(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){null!==this.doc?Cs(this.doc,n=>{oi(n,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return li(this,e)}getAttributes(){return ai(this)}_write(e){e.writeTypeRef(Zi)}},Mi=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Bs()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(null!==e&&(!this._firstCall||e.deleted||!this._filter(t)))do{if(t=e.content.type,e.deleted||t.constructor!==Oi&&t.constructor!==Di||null===t._start)for(;null!==e;){const t=e.next;if(null!==t){e=t;break}e=e.parent===this._root?null:e.parent._item}else e=t._start}while(null!==e&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,null===e?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},Di=class e extends Js{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 e}clone(){const t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Js?e.clone():e)),t}get length(){return this.doc??Bs(),null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(e){return new Mi(this,e)}querySelector(e){e=e.toUpperCase();const t=new Mi(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),he(new Mi(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){qs(this,e,new $i(this,t,e))}toString(){return Zs(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},n){const r=e.createDocumentFragment();return void 0!==n&&n._createAssociation(r,this),Ys(this,s=>{r.insertBefore(s.toDOM(e,t,n),null)}),r}insert(e,t){null!==this.doc?Cs(this.doc,n=>{ri(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(null!==this.doc)Cs(this.doc,n=>{const r=e&&e instanceof Js?e._item:e;ti(n,this,r,t)});else{const n=this._prelimContent,r=null===e?0:n.findIndex(t=>t===e)+1;if(0===r&&null!==e)throw rt("Reference item not found");n.splice(r,0,...t)}}delete(e,t=1){null!==this.doc?Cs(this.doc,n=>{si(n,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return Gs(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return ei(this,e)}slice(e=0,t=this.length){return Ks(this,e,t)}forEach(e){Ys(this,e)}_write(e){e.writeTypeRef(eo)}},Oi=class e extends Di{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((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){const t=new e(this.nodeName);return((e,t)=>{for(const n in e)t(e[n],n)})(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof Js?e.clone():e)),t}toString(){const e=this.getAttributes(),t=[],n=[];for(const i in e)n.push(i);n.sort();const r=n.length;for(let i=0;i<r;i++){const r=n[i];t.push(r+'="'+e[r]+'"')}const s=this.nodeName.toLocaleLowerCase();return`<${s}${t.length>0?" "+t.join(" "):""}>${super.toString()}</${s}>`}removeAttribute(e){null!==this.doc?Cs(this.doc,t=>{ii(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){null!==this.doc?Cs(this.doc,n=>{oi(n,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return li(this,e)}hasAttribute(e){return ci(this,e)}getAttributes(e){return e?((e,t)=>{const n={};return this._map.forEach((e,r)=>{let s=e;for(;null!==s&&(!t.sv.has(s.id.client)||s.id.clock>=(t.sv.get(s.id.client)||0));)s=s.left;null!==s&&as(s,t)&&(n[r]=s.content.getContent()[s.length-1])}),n})(0,e):ai(this)}toDOM(e=document,t={},n){const r=e.createElement(this.nodeName),s=this.getAttributes();for(const i in s){const e=s[i];"string"==typeof e&&r.setAttribute(i,e)}return Ys(this,s=>{r.appendChild(s.toDOM(e,t,n))}),void 0!==n&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Qi),e.writeKey(this.nodeName)}},$i=class extends zs{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{null===e?this.childListChanged=!0:this.attributesChanged.add(e)})}},Ri=class e extends fi{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){const t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){const r=t[this.hookName];let s;return s=void 0!==r?r.createDom(this):document.createElement(this.hookName),s.setAttribute("data-yjs-hook",this.hookName),void 0!==n&&n._createAssociation(s,this),s}_write(e){e.writeTypeRef(to),e.writeKey(this.hookName)}},Ii=class e extends Ti{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 e}clone(){const t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){const r=e.createTextNode(this.toString());return void 0!==n&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{const t=[];for(const r in e.attributes){const n=[];for(const t in e.attributes[r])n.push({key:t,value:e.attributes[r][t]});n.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:r,attrs:n})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n="";for(let r=0;r<t.length;r++){const e=t[r];n+=`<${e.nodeName}`;for(let t=0;t<e.attrs.length;t++){const r=e.attrs[t];n+=` ${r.key}="${r.value}"`}n+=">"}n+=e.insert;for(let r=t.length-1;r>=0;r--)n+=`</${t[r].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(no)}},Pi=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw st()}mergeWith(e){return!1}write(e,t,n){throw st()}integrate(e,t){throw st()}},zi=class extends Pi{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),ps(e.doc.store,this)}write(e,t){e.writeInfo(0),e.writeLen(this.length-t)}getMissing(e,t){return null}},Li=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw st()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},Bi=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){const n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){_r(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}},Fi=(e,t)=>new Rr({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),Vi=class e{constructor(e){e._item,this.doc=e;const t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),null!==e.meta&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(Fi(this.doc.guid,this.opts))}splice(e){throw st()}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}},Wi=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw st()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},Hi=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw st()}mergeWith(e){return!1}integrate(e,t){const n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},Ui=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){const n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){const t=this.arr[r];e.writeString(void 0===t?"undefined":JSON.stringify(t))}}getRef(){return 2}},qi="development"===qt("node_env"),Ji=class e{constructor(e){this.arr=e,qi&&Lt(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){const n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){const t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},Ki=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new e(this.str)}splice(t){const n=new e(this.str.slice(t));this.str=this.str.slice(0,t);const r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(0===t?this.str:this.str.slice(t))}getRef(){return 4}},Gi=[e=>new ui,e=>new fi,e=>new Ti,e=>new Oi(e.readKey()),e=>new Di,e=>new Ri(e.readKey()),e=>new Ii],Xi=0,Yi=1,Zi=2,Qi=3,eo=4,to=5,no=6,ro=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw st()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;null!==t;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;null!==t;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;null!==t;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},so=(e,t)=>{let n,r=t,s=0;do{s>0&&(r=Yr(r.client,r.clock+s)),n=gs(e,r),s=r.clock-n.id.clock,r=n.redone}while(null!==r&&n instanceof co);return{item:n,diff:s}},io=(e,t)=>{for(;null!==e&&e.keep!==t;)e.keep=t,e=e.parent._item},oo=(e,t,n)=>{const{client:r,clock:s}=t.id,i=new co(Yr(r,s+n),t,Yr(r,s+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),null!==t.redone&&(i.redone=Yr(t.redone.client,t.redone.clock+n)),t.right=i,null!==i.right&&(i.right.left=i),e._mergeStructs.push(i),null!==i.parentSub&&null===i.right&&i.parent._map.set(i.parentSub,i),t.length=n,i},lo=(e,t)=>pe(e,e=>Nr(e.deletions,t)),ao=(e,t,n,r,s,i)=>{const o=e.doc,l=o.store,a=o.clientID,c=t.redone;if(null!==c)return xs(e,c);let d,h=t.parent._item,u=null;if(null!==h&&!0===h.deleted){if(null===h.redone&&(!n.has(h)||null===ao(e,h,n,r,s,i)))return null;for(;null!==h.redone;)h=xs(e,h.redone)}const p=null===h?t.parent:h.content.type;if(null===t.parentSub){for(u=t.left,d=t;null!==u;){let t=u;for(;null!==t&&t.parent._item!==h;)t=null===t.redone?null:xs(e,t.redone);if(null!==t&&t.parent._item===h){u=t;break}u=u.left}for(;null!==d;){let t=d;for(;null!==t&&t.parent._item!==h;)t=null===t.redone?null:xs(e,t.redone);if(null!==t&&t.parent._item===h){d=t;break}d=d.right}}else{if(d=null,t.right&&!s){for(u=t;null!==u&&null!==u.right&&(u.right.redone||Nr(r,u.right.id)||lo(i.undoStack,u.right.id)||lo(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=xs(e,u.redone);if(u&&null!==u.right)return null}else u=p._map.get(t.parentSub)||null;null!==u&&u.parent._item!==h&&(u=p._map.get(t.parentSub)||null)}const f=Yr(a,us(l,a)),g=new co(f,u,u&&u.lastId,d,d&&d.id,p,t.parentSub,t.content.copy());return t.redone=f,io(g,!0),g.integrate(e,0),g},co=class e extends Pi{constructor(e,t,n,r,s,i,o,l){super(e,l.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=s,this.parent=i,this.parentSub=o,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(e){(8&this.info)>0!==e&&(this.info^=8)}get marker(){return(8&this.info)>0}get keep(){return(1&this.info)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(2&this.info)>0}get deleted(){return(4&this.info)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=us(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=us(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Gr&&this.id.client!==this.parent.client&&this.parent.clock>=us(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=bs(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=xs(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===zi||this.right&&this.right.constructor===zi)this.parent=null;else if(this.parent){if(this.parent.constructor===Gr){const e=gs(n,this.parent);e.constructor===zi?this.parent=null:this.parent=e.content.type}}else this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=bs(e,e.doc.store,Yr(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||null!==this.right.left)||this.left&&this.left.right!==this.right){let t,n=this.left;if(null!==n)t=n.right;else if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start;const r=new Set,s=new Set;for(;null!==t&&t!==this.right;){if(s.add(t),r.add(t),Xr(this.origin,t.origin)){if(t.id.client<this.id.client)n=t,r.clear();else if(Xr(this.rightOrigin,t.rightOrigin))break}else{if(null===t.origin||!s.has(gs(e.doc.store,t.origin)))break;r.has(gs(e.doc.store,t.origin))||(n=t,r.clear())}t=t.right}this.left=n}if(null!==this.left){const e=this.left.right;this.right=e,this.left.right=this}else{let e;if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(e)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),ps(e.doc.store,this),this.content.integrate(e,this),ks(e,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(e)}else new zi(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;null!==e&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;null!==e&&e.deleted;)e=e.left;return e}get lastId(){return 1===this.length?this.id:Yr(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Xr(e.origin,this.lastId)&&this.right===e&&Xr(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&null===this.redone&&null===e.redone&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,null!==this.right&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const t=this.parent;this.countable&&null===this.parentSub&&(t._length-=this.length),this.markDeleted(),_r(e.deleteSet,this.id.client,this.id.clock,this.length),ks(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw it();this.content.gc(e),t?((e,t,n)=>{const r=e.clients.get(t.id.client);r[fs(r,t.id.clock)]=n})(e,this,new zi(this.id,this.length)):this.content=new Bi(this.length)}write(e,t){const n=t>0?Yr(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,s=this.parentSub,i=31&this.content.getRef()|(null===n?0:128)|(null===r?0:64)|(null===s?0:32);if(e.writeInfo(i),null!==n&&e.writeLeftID(n),null!==r&&e.writeRightID(r),null===n&&null===r){const t=this.parent;if(void 0!==t._item){const n=t._item;if(null===n){const n=Zr(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===Gr?(e.writeParentInfo(!1),e.writeLeftID(t)):it();null!==s&&e.writeString(s)}this.content.write(e,t)}},ho=(e,t)=>uo[31&t](e),uo=[()=>{it()},e=>new Bi(e.readLen()),e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++){const t=e.readString();"undefined"===t?n.push(void 0):n.push(JSON.parse(t))}return new Ui(n)},e=>new Li(e.readBuf()),e=>new Ki(e.readString()),e=>new Wi(e.readJSON()),e=>new Hi(e.readKey(),e.readJSON()),e=>new ro(Gi[e.readTypeRef()](e)),e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Ji(n)},e=>new Vi(Fi(e.readString(),e.readAny())),()=>{it()}],po=class extends Pi{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){it()}write(e,t){e.writeInfo(10),Fe(e.restEncoder,this.length-t)}getMissing(e,t){return null}},fo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},go="__ $YJS$ __";function mo(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(r),i=t.child(r);if(s!=i){if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){let e=s.text,t=i.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&yo(e.charCodeAt(r-1))&&bo(e.charCodeAt(r))&&n--,n}if(s.content.size||i.content.size){let e=mo(s.content,i.content,n+1);if(null!=e)return e}n+=s.nodeSize}else n+=s.nodeSize}}function xo(e,t,n,r){for(let s=e.childCount,i=t.childCount;;){if(0==s||0==i)return s==i?null:{a:n,b:r};let o=e.child(--s),l=t.child(--i),a=o.nodeSize;if(o!=l){if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let e=o.text,t=l.text,s=e.length,i=t.length;for(;s>0&&i>0&&e[s-1]==t[i-1];)s--,i--,n--,r--;return s&&i&&s<e.length&&yo(e.charCodeAt(s-1))&&bo(e.charCodeAt(s))&&(n++,r++),{a:n,b:r}}if(o.content.size||l.content.size){let e=xo(o.content,l.content,n-1,r-1);if(e)return e}n-=a,r-=a}else n-=a,r-=a}}function bo(e){return e>=56320&&e<57344}function yo(e){return e>=55296&&e<56320}fo[go],fo[go]=!0;var vo=class e{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,r=0,s){for(let i=0,o=0;o<t;i++){let l=this.content[i],a=o+l.nodeSize;if(a>e&&!1!==n(l,r+o,s||null,i)&&l.content.size){let s=o+1;l.nodesBetween(Math.max(0,e-s),Math.min(l.content.size,t-s),n,r+s)}o=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let s="",i=!0;return this.nodesBetween(e,t,(o,l)=>{let a=o.isText?o.text.slice(Math.max(e,l)-l,t-l):o.isLeaf?r?"function"==typeof r?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&a||o.isTextblock)&&n&&(i?i=!1:s+=n),s+=a},0),s}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<t.content.length;i++)s.push(t.content[i]);return new e(s,this.size+t.size)}cut(t,n=this.size){if(0==t&&n==this.size)return this;let r=[],s=0;if(n>t)for(let e=0,i=0;i<n;e++){let o=this.content[e],l=i+o.nodeSize;l>t&&((i<t||l>n)&&(o=o.isText?o.cut(Math.max(0,t-i),Math.min(o.text.length,n-i)):o.cut(Math.max(0,t-i-1),Math.min(o.content.size,n-i-1))),r.push(o),s+=o.nodeSize),i=l}return new e(r,s)}cutByIndex(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[t]=n,new e(s,i)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return mo(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return xo(this,e,t,n)}findIndex(e){if(0==e)return ko(0,e);if(e==this.size)return ko(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e)return r==e?ko(t+1,r):ko(t,n);n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let s=t[e];r+=s.nodeSize,e&&s.isText&&t[e-1].sameMarkup(s)?(n||(n=t.slice(0,e)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};vo.empty=new vo([],0);var wo={index:0,offset:0};function ko(e,t){return wo.index=e,wo.offset=t,wo}function So(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!So(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!So(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var jo=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(s)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&So(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};jo.none=[];var Co=class extends Error{},No=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Ao(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Eo(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,s=n.openEnd||0;if("number"!=typeof r||"number"!=typeof s)throw new RangeError("Invalid input for Slice.fromJSON");return new e(vo.fromJSON(t,n.content),r,s)}static maxOpen(t,n=!0){let r=0,s=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)s++;return new e(t,r,s)}};function Eo(e,t,n){let{index:r,offset:s}=e.findIndex(t),i=e.maybeChild(r),{index:o,offset:l}=e.findIndex(n);if(s==t||i.isText){if(l!=n&&!e.child(o).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(Eo(i.content,t-s-1,n-s-1)))}function Ao(e,t,n,r,s,i){let{index:o,offset:l}=e.findIndex(t),a=e.maybeChild(o);if(l==t||a.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=Ao(a.content,t-l-1,n,0==o?r-1:0,o==e.childCount-1?s-1:0,a);return c&&e.replaceChild(o,a.copy(c))}No.empty=new No(vo.empty,0,0);var _o=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new To(t,n);if(null==r.next)return e.empty;let s=Mo(r);r.next&&r.err("Unexpected trailing text");let i=function(e){let t=Object.create(null);return function n(r){let s=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<s.length;e++)s[e][0]==t&&(r=s[e][1]);Po(e,n).forEach(e=>{r||s.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let i=t[r.join(",")]=new _o(r.indexOf(e.length-1)>-1);for(let e=0;e<s.length;e++){let r=s[e][1].sort(Io);i.next.push({type:s[e][0],next:t[r.join(",")]||n(r)})}return i}(Po(e,0))}(function(e){let t=[[]];return s(function e(t,i){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(e(n,i)),[]);if("seq"!=t.type){if("star"==t.type){let o=n();return r(i,o),s(e(t.expr,o),o),[r(o)]}if("plus"==t.type){let o=n();return s(e(t.expr,i),o),s(e(t.expr,o),o),[r(o)]}if("opt"==t.type)return[r(i)].concat(e(t.expr,i));if("range"==t.type){let o=i;for(let r=0;r<t.min;r++){let r=n();s(e(t.expr,o),r),o=r}if(-1==t.max)s(e(t.expr,o),o);else for(let i=t.min;i<t.max;i++){let i=n();r(o,i),s(e(t.expr,o),i),o=i}return[r(o)]}if("name"==t.type)return[r(i,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let o=e(t.exprs[r],i);if(r==t.exprs.length-1)return o;s(o,i=n())}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let s={term:r,to:n};return t[e].push(s),s}function s(e,t){e.forEach(e=>e.to=t)}}(s));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],s=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];i.push(n.name),!s||n.isText||n.hasRequiredAttrs()||(s=!1),-1==r.indexOf(o)&&r.push(o)}s&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let s=t;r&&s<n;s++)r=r.matchType(e.child(s).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function s(i,o){let l=i.matchFragment(e,n);if(l&&(!t||l.validEnd))return vo.from(o.map(e=>e.createAndFill()));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=s(n,o.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),s=r.match;if(s.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<s.next.length;e++){let{type:i,next:o}=s.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!o.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let s=0;s<t.next.length;s++)r+=(s?", ":"")+t.next[s].type.name+"->"+e.indexOf(t.next[s].next);return r}).join("\n")}};_o.empty=new _o(!0);var To=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Mo(e){let t=[];do{t.push(Do(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function Do(e){let t=[];do{t.push(Oo(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function Oo(e){let t=function(e){if(e.eat("(")){let t=Mo(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let s=[];for(let i in n){let e=n[i];e.isInGroup(t)&&s.push(e)}return 0==s.length&&e.err("No node type or group '"+t+"' found"),s}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=Ro(e,t)}return t}function $o(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function Ro(e,t){let n=$o(e),r=n;return e.eat(",")&&(r="}"!=e.next?$o(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function Io(e,t){return t-e}function Po(e,t){let n=[];return function t(r){let s=e[r];if(1==s.length&&!s[0].term)return t(s[0].to);n.push(r);for(let e=0;e<s.length;e++){let{term:r,to:i}=s[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(Io)}var zo=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Ho(this,t,!1);return n.addAll(e,jo.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Ho(this,t,!0);return n.addAll(e,jo.none,t.from,t.to),No.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Uo(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let r=this.styles[s],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let r in e.marks){let t=e.marks[r].spec.parseDOM;t&&t.forEach(e=>{n(e=qo(e)),e.mark||e.ignore||e.clearMark||(e.mark=r)})}for(let r in e.nodes){let t=e.nodes[r].spec.parseDOM;t&&t.forEach(e=>{n(e=qo(e)),e.node||e.ignore||e.mark||(e.node=r)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Lo={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Bo={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Fo={ol:!0,ul:!0};function Vo(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}var Wo=class{constructor(e,t,n,r,s,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=jo.none,this.match=s||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(vo.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=vo.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(vo.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Lo.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Ho=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,s=t.topNode,i=Vo(null,t.preserveWhitespace,0)|(n?4:0);r=s?new Wo(s.type,s.attrs,jo.none,!0,t.topMatch||s.type.contentMatch,i):new Wo(n?null:e.schema.topNodeType,null,jo.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,s=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:i}=this.parser;if("full"===s||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)if("full"===s)n=n.replace(/\r\n?/g,"\n");else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(i.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(i.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],s=e.previousSibling;(!t||s&&"BR"==s.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(i.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,s=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,o=e.nodeName.toLowerCase();Fo.hasOwnProperty(o)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Fo.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(l?l.ignore:Bo.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,r=this.needsBlock;if(Lo.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),n=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=l&&l.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(s),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let e=this.parser.matchedStyles[r],s=n.getPropertyValue(e);if(s)for(let n;;){let r=this.parser.matchStyle(e,s,this,n);if(!r)break;if(r.ignore)return null;if(t=r.clearMark?t.filter(e=>!r.clearMark(e)):t.concat(this.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming)break;n=r}}return t}addElementByRule(e,t,n,r){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(s=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}s&&this.sync(o)&&this.open--}addAll(e,t,n,r){let s=n||0;for(let i=n?e.childNodes[n]:e.firstChild,o=null==r?null:e.childNodes[r];i!=o;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,n){let r,s;for(let i=this.open,o=0;i>=0;i--){let t=this.nodes[i],l=t.findWrapping(e);if(l&&(!r||r.length>l.length+o)&&(r=l,s=t,!l.length))break;if(t.solid){if(n)break;o+=2}}if(!r)return null;this.sync(s);for(let i=0;i<r.length;i++)t=this.enterInner(r[i],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=jo.none;for(let s of r.concat(e.marks))(t.type?t.type.allowsMarkType(s.type):Jo(s.type,e.type))&&(n=s.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,r)),s}enterInner(e,t,n,r=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let o=Vo(e,s,i.options);4&i.options&&0==i.content.length&&(o|=4);let l=jo.none;return n=n.filter(t=>!(i.type?i.type.allowsMarkType(t.type):Jo(t.type,e))||(l=t.addToSet(l),!1)),this.nodes.push(new Wo(e,t,l,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),s=-(n?n.depth+1:0)+(r?0:1),i=(e,o)=>{for(;e>=0;e--){let l=t[e];if(""==l){if(e==t.length-1||0==e)continue;for(;o>=s;o--)if(i(e-1,o))return!0;return!1}{let e=o>0||0==o&&r?this.nodes[o].type:n&&o>=s?n.node(o-s).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;o--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}};function Uo(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function qo(e){let t={};for(let n in e)t[n]=e[n];return t}function Jo(e,t){let n=t.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let i=[],o=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:s}=e.edge(n);if(r==t)return!0;if(i.indexOf(s)<0&&o(s))return!0}};if(o(s.contentMatch))return!0}}var Ko=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Xo(t).createDocumentFragment());let r=n,s=[];return e.forEach(e=>{if(s.length||e.marks.length){let n=0,i=0;for(;n<s.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(s[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<s.length;)r=s.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],o=this.serializeMark(n,e.isInline,t);o&&(s.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Xo(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Zo(Xo(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Zo(Xo(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return"string"==typeof t?{dom:e.createTextNode(t)}:Zo(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=Go(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Go(e.marks)}};function Go(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Xo(e){return e.document||window.document}var Yo=new WeakMap;function Zo(e,t,n,r){if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let s,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=function(e){let t=Yo.get(e);return void 0===t&&Yo.set(e,t=function(e){let t=null;return function e(n){if(n&&"object"==typeof n)if(Array.isArray(n))if("string"==typeof n[0])t||(t=[]),t.push(n);else for(let t=0;t<n.length;t++)e(n[t]);else for(let t in n)e(n[t])}(e),t}(e)),t}(r))&&s.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?e.createElementNS(n,i):e.createElement(i),c=t[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?a.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&a.style?a.style.cssText=c[e]:a.setAttribute(e,c[e])}}for(let h=d;h<t.length;h++){let s=t[h];if(0===s){if(h<t.length-1||h>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}if("string"==typeof s)a.appendChild(e.createTextNode(s));else{let{dom:t,contentDOM:i}=Zo(e,s,n,r);if(a.appendChild(t),i){if(o)throw new RangeError("Multiple content holes");o=i}}}return{dom:a,contentDOM:o}}var Qo=Math.pow(2,16);function el(e,t){return e+t*Qo}function tl(e){return 65535&e}var nl=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}},rl=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=tl(e);if(!this.inverted)for(let r=0;r<n;r++)t+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Qo}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>e)break;let a=this.ranges[o+s],c=this.ranges[o+i],d=l+a;if(e<=d){let s=l+r+((a?e==l?-1:e==d?1:t:t)<0?0:c);if(n)return s;let i=e==(t<0?l:d)?null:el(o/3,e-l),h=e==l?2:e==d?1:4;return(t<0?e!=l:e!=d)&&(h|=8),new nl(s,h,i)}r+=c-a}return n?e+r:new nl(e+r,0,null)}touches(e,t){let n=0,r=tl(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let t=this.ranges[o]-(this.inverted?n:0);if(t>e)break;let l=this.ranges[o+s];if(e<=t+l&&o==3*r)return!0;n+=this.ranges[o+i]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let i=this.ranges[r],o=i-(this.inverted?s:0),l=i+(this.inverted?0:s),a=this.ranges[r+t],c=this.ranges[r+n];e(o,o+a,l,l+c),s+=c-a}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};rl.empty=new rl([]);var sl=Object.create(null),il=class{getMap(){return rl.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=sl[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in sl)throw new RangeError("Duplicate use of step JSON ID "+e);return sl[e]=t,t.prototype.jsonID=e,t}},ol=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,s){try{return e.ok(t.replace(n,r,s))}catch(Fh){if(Fh instanceof Co)return e.fail(Fh.message);throw Fh}}};function ll(e,t,n){let r=[];for(let s=0;s<e.childCount;s++){let i=e.child(s);i.content.size&&(i=i.copy(ll(i.content,t,i))),i.isInline&&(i=t(i,n,s)),r.push(i)}return vo.fromArray(r)}var al=class e extends il{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),s=new No(ll(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return ol.fromReplace(e,this.from,this.to,s)}invert(){return new cl(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))}};il.jsonID("addMark",al);var cl=class e extends il{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new No(ll(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return ol.fromReplace(e,this.from,this.to,n)}invert(){return new al(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))}};il.jsonID("removeMark",cl);var dl=class e extends il{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ol.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ol.fromReplace(e,this.pos,this.pos+1,new No(vo.from(n),0,t.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new hl(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new e(n.pos,t.markFromJSON(n.mark))}};il.jsonID("addNodeMark",dl);var hl=class e extends il{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ol.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ol.fromReplace(e,this.pos,this.pos+1,new No(vo.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new dl(this.pos,this.mark):this}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new e(n.pos,t.markFromJSON(n.mark))}};il.jsonID("removeNodeMark",hl);var ul=class e extends il{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&fl(e,this.from,this.to)?ol.fail("Structure replace would overwrite content"):ol.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new rl([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let n=this.slice.size+t.slice.size==0?No.empty:new No(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}}{let n=this.slice.size+t.slice.size==0?No.empty:new No(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new e(n.from,n.to,No.fromJSON(t,n.slice),!!n.structure)}};ul.MAP_BIAS=1,il.jsonID("replace",ul);var pl=class e extends il{constructor(e,t,n,r,s,i,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=s,this.insert=i,this.structure=o}apply(e){if(this.structure&&(fl(e,this.from,this.gapFrom)||fl(e,this.gapTo,this.to)))return ol.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ol.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?ol.fromReplace(e,this.from,this.to,n):ol.fail("Content does not fit in gap")}getMap(){return new rl([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new e(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new e(n.from,n.to,n.gapFrom,n.gapTo,No.fromJSON(t,n.slice),n.insert,!!n.structure)}};function fl(e,t,n){let r=e.resolve(t),s=n-t,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,s--}}return!1}il.jsonID("replaceAround",pl),il.jsonID("attr",class e extends il{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return ol.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return ol.fromReplace(e,this.pos,this.pos+1,new No(vo.from(r),0,t.isLeaf?0:1))}getMap(){return rl.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if("number"!=typeof n.pos||"string"!=typeof n.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new e(n.pos,n.attr,n.value)}}),il.jsonID("docAttr",class e extends il{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return ol.ok(n)}getMap(){return rl.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if("string"!=typeof n.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new e(n.attr,n.value)}});var gl=Error;((gl=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype)).constructor=gl,gl.prototype.name="TransformError";var ml=Object.create(null),xl=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new bl(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=No.empty){let n=t.content.lastChild,r=null;for(let o=0;o<t.openEnd;o++)r=n,n=n.lastChild;let s=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:a}=i[o],c=e.mapping.slice(s);e.replaceRange(c.map(l.pos),c.map(a.pos),o?No.empty:t),0==o&&Al(e,s,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:i,$to:o}=r[s],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(o.pos);s?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),Al(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new wl(e):El(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let s=e.depth-1;s>=0;s--){let r=t<0?El(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):El(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Cl(e.node(0))}static atStart(e){return El(e,e,0,0,1)||new Cl(e)}static atEnd(e){return El(e,e,e.content.size,e.childCount,-1)||new Cl(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=ml[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ml)throw new RangeError("Duplicate use of selection JSON ID "+e);return ml[e]=t,t.prototype.jsonID=e,t}getBookmark(){return wl.between(this.$anchor,this.$head).getBookmark()}};xl.prototype.visible=!0;var bl=class{constructor(e,t){this.$from=e,this.$to=t}},yl=!1;function vl(e){yl||e.parent.inlineContent||(yl=!0)}var wl=class e extends xl{constructor(e,t=e){vl(e),vl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return xl.near(r);let s=t.resolve(n.map(this.anchor));return new e(s.parent.inlineContent?s:r,r)}replace(e,t=No.empty){if(super.replace(e,t),t==No.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new kl(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let s=t.pos-n.pos;if(r&&!s||(r=s>=0?1:-1),!n.parent.inlineContent){let e=xl.findFrom(n,r,!0)||xl.findFrom(n,-r,!0);if(!e)return xl.near(n,r);n=e.$head}return t.parent.inlineContent||(0==s||(t=(xl.findFrom(t,-r,!0)||xl.findFrom(t,r,!0)).$anchor).pos<n.pos!=s<0)&&(t=n),new e(t,n)}};xl.jsonID("text",wl);var kl=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return wl.between(e.resolve(this.anchor),e.resolve(this.head))}},Sl=class e extends xl{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=t.resolve(s);return r?xl.near(i):new e(i)}content(){return new No(vo.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new jl(this.anchor)}static fromJSON(t,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}};Sl.prototype.visible=!1,xl.jsonID("node",Sl);var jl=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new kl(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Sl.isSelectable(n)?new Sl(t):xl.near(t)}},Cl=class e extends xl{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=No.empty){if(t==No.empty){e.delete(0,e.doc.content.size);let t=xl.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return Nl}};xl.jsonID("all",Cl);var Nl={map(){return this},resolve:e=>new Cl(e)};function El(e,t,n,r,s,i=!1){if(t.inlineContent)return wl.create(e,n);for(let o=r-(s>0?0:1);s>0?o<t.childCount:o>=0;o+=s){let r=t.child(o);if(r.isAtom){if(!i&&Sl.isSelectable(r))return Sl.create(e,n-(s<0?r.nodeSize:0))}else{let t=El(e,r,n+s,s<0?r.childCount:0,s,i);if(t)return t}n+=r.nodeSize*s}return null}function Al(e,t,n){let r=e.steps.length-1;if(r<t)return;let s,i=e.steps[r];(i instanceof ul||i instanceof pl)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{s??=r}),e.setSelection(xl.near(e.doc.resolve(s),n)))}function _l(e,t){return t&&e?e.bind(t):e}var Tl=class{constructor(e,t,n){this.name=e,this.init=_l(t.init,n),this.apply=_l(t.apply,n)}};function Ml(e,t,n){for(let r in e){let s=e[r];s instanceof Function?s=s.bind(t):"handleDOMEvents"==r&&(s=Ml(s,t,{})),n[r]=s}return n}new Tl("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new Tl("selection",{init:(e,t)=>e.selection||xl.atStart(t.doc),apply:e=>e.selection}),new Tl("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new Tl("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t});var Dl=class{constructor(e){this.spec=e,this.props={},e.props&&Ml(e.props,this,this.props),this.key=e.key?e.key.key:$l("plugin")}getState(e){return e[this.key]}},Ol=Object.create(null);function $l(e){return e in Ol?e+"$"+ ++Ol[e]:(Ol[e]=0,e+"$")}var Rl=class{constructor(e="key"){this.key=$l(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},Il=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Pl=function(e,t,n,r){return n&&(Ll(e,t,n,r,-1)||Ll(e,t,n,r,1))},zl=/^(img|br|input|textarea|hr)$/i;function Ll(e,t,n,r,s){for(var i;;){if(e==n&&t==r)return!0;if(t==(s<0?0:Bl(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Fl(e)||zl.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Il(e)+(s<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(s<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=s}else e=n,t=s<0?Bl(e):0}}}}function Bl(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Fl(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Vl=function(e){return e.focusNode&&Pl(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Wl(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}var Hl="undefined"!=typeof navigator?navigator:null,Ul="undefined"!=typeof document?document:null,ql=Hl&&Hl.userAgent||"",Jl=/Edge\/(\d+)/.exec(ql),Kl=/MSIE \d/.exec(ql),Gl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ql),Xl=!!(Kl||Gl||Jl),Yl=Kl?document.documentMode:Gl?+Gl[1]:Jl?+Jl[1]:0,Zl=!Xl&&/gecko\/(\d+)/i.test(ql);Zl&&(/Firefox\/(\d+)/.exec(ql)||[0,0])[1];var Ql=!Xl&&/Chrome\/(\d+)/.exec(ql),ea=!!Ql,ta=Ql?+Ql[1]:0,na=!Xl&&!!Hl&&/Apple Computer/.test(Hl.vendor),ra=na&&(/Mobile\/\w+/.test(ql)||!!Hl&&Hl.maxTouchPoints>2),sa=ra||!!Hl&&/Mac/.test(Hl.platform),ia=!!Hl&&/Win/.test(Hl.platform),oa=/Android \d/.test(ql),la=!!Ul&&"webkitFontSmoothing"in Ul.documentElement.style,aa=la?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,ca=function(e){e&&(this.nodeName=e)};function da(e){return e.editable?e.hasFocus():function(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(n){return!1}}(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function ha(e,t=!1){let n=e.state.selection;if(function(e,t){if(t instanceof Sl){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ma(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ma(e)}(e,n),!da(e))return;let r=e.input.mouseDown;if(!t&&ea&&r){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Pl(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)&&r.delaySelUpdate())return void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,Il(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&Xl&&Yl<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,s,{anchor:i,head:o}=n;!ua||n instanceof wl||(n.$from.parent.inlineContent||(r=pa(e,n.from)),n.empty||n.$from.parent.inlineContent||(s=pa(e,n.to))),e.docView.setSelection(i,o,e,t),ua&&(r&&ga(r),s&&ga(s)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==s||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{da(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}ca.prototype=Object.create(null),new ca;var ua=na||ea&&ta<63;function pa(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(na&&s&&"false"==s.contentEditable)return fa(s);if(!(s&&"false"!=s.contentEditable||i&&"false"!=i.contentEditable)){if(s)return fa(s);if(i)return fa(i)}}function fa(e){return e.contentEditable="true",na&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ga(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function ma(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function xa(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||wl.between(t,n,r)}function ba(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return i&&xl.findFrom(i,t)}function ya(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function va(e,t,n){let r=e.state.selection;if(!(r instanceof wl)){if(r instanceof Sl&&r.node.isInline)return ya(e,new wl(t>0?r.$to:r.$from));{let n=ba(e.state,t);return!!n&&ya(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,s=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+s.nodeSize*(t<0?-1:1));return ya(e,new wl(r.$anchor,i))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=ba(e.state,t);return!!(n&&n instanceof Sl)&&ya(e,n)}if(!(sa&&n.indexOf("m")>-1)){let n,s=r.$head,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText)return!1;let o=t<0?s.pos-i.nodeSize:s.pos;return!!(i.isAtom||(n=e.docView.descAt(o))&&!n.contentDOM)&&(Sl.isSelectable(i)?ya(e,new Sl(t<0?e.state.doc.resolve(s.pos-i.nodeSize):s)):!!la&&ya(e,new wl(e.state.doc.resolve(t<0?o:o+i.nodeSize))))}}function wa(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ka(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function Sa(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,i,o=!1;for(Zl&&1==n.nodeType&&r<wa(n)&&ka(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(ka(e,-1))s=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(ja(n))break;{let t=n.previousSibling;for(;t&&ka(t,-1);)s=n.parentNode,i=Il(t),t=t.previousSibling;if(t)n=t,r=wa(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}o?Ca(e,n,r):s&&Ca(e,s,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,i,o=wa(n);for(;;)if(r<o){if(1!=n.nodeType)break;if(!ka(n.childNodes[r],1))break;s=n,i=++r}else{if(ja(n))break;{let t=n.nextSibling;for(;t&&ka(t,1);)s=t.parentNode,i=Il(t)+1,t=t.nextSibling;if(t)n=t,r=0,o=wa(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}s&&Ca(e,s,i)}(e)}function ja(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ca(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!Fl(e);)t=Il(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!Fl(e);)t=Il(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Vl(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:s}=e;setTimeout(()=>{e.state==s&&ha(e)},50)}function Na(e,t){let n=e.state.doc.resolve(t);if(!ea&&!ia&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),s=(n.top+n.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),s=(n.top+n.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Ea(e,t,n){let r=e.state.selection;if(r instanceof wl&&!r.empty||n.indexOf("s")>-1)return!1;if(sa&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=ba(e.state,t);if(n&&n instanceof Sl)return ya(e,n)}if(!s.parent.inlineContent){let n=t<0?s:i,o=r instanceof Cl?xl.near(n,t):xl.findFrom(n,t);return!!o&&ya(e,o)}return!1}function Aa(e,t){if(!(e.state.selection instanceof wl))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function _a(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ta(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:s,openEnd:i}=t;for(;s>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){s--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let o=e.someProp("clipboardSerializer")||Ko.fromSchema(e.state.schema),l=La(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c,d=a.firstChild,h=0;for(;d&&1==d.nodeType&&(c=za[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=l.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),h++}d=a.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${s} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Ma(e,t,n,r,s){let i,o,l=s.parent.type.spec.code;if(!n&&!t)return null;let a=!!t&&(r||l||!n);if(a){if(e.someProp("transformPastedText",n=>{t=n(t,l||r,e)}),l)return o=new No(vo.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{o=t(o,e,!0)}),o;let n=e.someProp("clipboardTextParser",n=>n(t,s,r,e));if(n)o=n;else{let n=s.marks(),{schema:r}=e.state,o=Ko.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(o.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),i=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=La(),s=r.body,i=/<([a-z][^>\s]+)/i.exec(e);if((n=i&&za[i[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join("")),s.innerHTML=function(e){let t=window.trustedTypes;return t?(Ba||(Ba=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),Ba.createHTML(e)):e}(e),n)for(let o=0;o<n.length;o++)s=s.querySelector(n[o])||s;for(let o=0;o<r.styleSheets.length;o++){let e=r.styleSheets[o];for(let t=0;t<e.rules.length;t++){let n=e.rules[t];if(n instanceof CSSStyleRule){let e=s.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return s}(n),la&&function(e){let t=e.querySelectorAll(ea?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let h=+d[3];h>0;h--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(o||(o=(e.someProp("clipboardParser")||e.someProp("domParser")||zo.fromSchema(e.state.schema)).parseSlice(i,{preserveWhitespace:!(!a&&!d),context:s,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Da.test(e.parentNode.nodeName)?null:{ignore:!0}})),d)o=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(Fh){return e}let{content:s,openStart:i,openEnd:o}=e;for(let l=n.length-2;l>=0;l-=2){let e=r.nodes[n[l]];if(!e||e.hasRequiredAttrs())break;s=vo.from(e.create(n[l+1],s)),i++,o++}return new No(s,i,o)}(Pa(o,+d[1],+d[2]),d[4]);else if(o=No.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,s=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach(e=>{if(!i)return;let t,n=s.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&r.length&&$a(n,r,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=Ra(i[i.length-1],r.length));let t=Oa(e,n);i.push(t),s=s.matchType(t.type),r=n}}),i)return vo.from(i)}return e}(o.content,s),!0),o.openStart||o.openEnd){let e=0,t=0;for(let n=o.content.firstChild;e<o.openStart&&!n.type.spec.isolating;e++,n=n.firstChild);for(let n=o.content.lastChild;t<o.openEnd&&!n.type.spec.isolating;t++,n=n.lastChild);o=Pa(o,e,t)}return e.someProp("transformPasted",t=>{o=t(o,e,a)}),o}var Da=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Oa(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,vo.from(e));return e}function $a(e,t,n,r,s){if(s<e.length&&s<t.length&&e[s]==t[s]){let i=$a(e,t,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==e.length-1?n.type:e[s+1]))return r.copy(r.content.append(vo.from(Oa(n,e,s+1))))}}function Ra(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Ra(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(vo.empty,!0);return e.copy(n.append(r))}function Ia(e,t,n,r,s,i){let o=t<0?e.firstChild:e.lastChild,l=o.content;return e.childCount>1&&(i=0),s<r-1&&(l=Ia(l,t,n,r,s+1,i)),s>=n&&(l=t<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(vo.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(l))}function Pa(e,t,n){return t<e.openStart&&(e=new No(Ia(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new No(Ia(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var za={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function La(){return document.implementation.createHTMLDocument("title")}var Ba=null,Fa={},Va={};function Wa(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Ha(e){return{left:e.clientX,top:e.clientY}}function Ua(e,t,n,r,s){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(e.someProp(t,t=>o>i.depth?t(e,n,i.nodeAfter,i.before(o),s,!0):t(e,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function qa(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function Ja(e,t,n,r){return Ua(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function Ka(e,t,n,r){return Ua(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=Ga(e,t,!0),s=e.state.doc;return!!r&&(qa(e,r,"pointer"),r instanceof wl&&s.eq(e.state.doc)&&(e.input.mouseDown=new ec(e,r)),!0)}(e,n,r)}function Ga(e,t,n){let r=e.state.doc;if(-1==t)return r.inlineContent?wl.create(r,0,r.content.size):null;let s=r.resolve(t);for(let i=s.depth+1;i>0;i--){let e=i>s.depth?s.nodeAfter:s.node(i),t=s.before(i);if(e.inlineContent)return wl.create(r,t+1,t+1+e.content.size);if(n&&Sl.isSelectable(e))return Sl.create(r,t)}return null}function Xa(e){return sc(e)}Va.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!tc(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!oa||!ea||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!ra||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||function(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||sa&&72==n&&"c"==r)return Aa(e,-1)||Sa(e,-1);if(46==n&&!t.shiftKey||sa&&68==n&&"c"==r)return Aa(e,1)||Sa(e,1);if(13==n||27==n)return!0;if(37==n||sa&&66==n&&"c"==r){let t=37==n?"ltr"==Na(e,e.state.selection.from)?-1:1:-1;return va(e,t,r)||Sa(e,t)}if(39==n||sa&&70==n&&"c"==r){let t=39==n?"ltr"==Na(e,e.state.selection.from)?1:-1:1;return va(e,t,r)||Sa(e,t)}return 38==n||sa&&80==n&&"c"==r?Ea(e,-1,r)||Sa(e,-1):40==n||sa&&78==n&&"c"==r?function(e){if(!na||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;_a(e,n,"true"),setTimeout(()=>_a(e,n,"false"),20)}return!1}(e)||Ea(e,1,r)||Sa(e,1):r==(sa?"m":"c")&&(66==n||73==n||89==n||90==n)}(e,n)?n.preventDefault():Wa(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,Wl(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},Va.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},Va.keypress=(e,t)=>{let n=t;if(tc(e)||!n.charCode||n.ctrlKey&&!n.altKey||sa&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof wl&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode),s=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,r.$from.pos,r.$to.pos,t,s))||e.dispatch(s()),n.preventDefault()}};var Ya=sa?"metaKey":"ctrlKey";Fa.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Xa(e),s=Date.now(),i="singleClick";s-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[Ya]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let o=e.posAtCoords(Ha(n));o&&("singleClick"==i?e.input.mouseDown=new Qa(e,o,n,!!r):("doubleClick"==i?Ja:Ka)(e,o.pos,o.inside,n)?n.preventDefault():Wa(e,"pointer"))};var Za=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){0==e.buttons&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Qa=class extends Za{constructor(e,t,n,r){let s,i;if(super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[Ya],this.allowDefault=n.shiftKey,t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);s=n.parent,i=n.depth?n.before():0}const o=r?null:n.target,l=o?e.docView.nearestDesc(o,!0):null;this.target=l&&1==l.nodeDOM.nodeType?l.nodeDOM:null;let{selection:a}=e.state;0==n.button&&(s.type.spec.draggable&&!1!==s.type.spec.selectable||a instanceof Sl&&a.from<=i&&a.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Zl||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),Wa(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||ha(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Ha(e))),this.updateAllowDefault(e),this.allowDefault||!t?Wa(this.view,"pointer"):function(e,t,n,r,s){return Ua(e,"handleClickOn",t,n,r)||e.someProp("handleClick",n=>n(e,t,r))||(s?function(e,t){if(-1==t)return!1;let n,r,s=e.state.selection;s instanceof Sl&&(n=s.node);let i=e.state.doc.resolve(t);for(let o=i.depth+1;o>0;o--){let e=o>i.depth?i.nodeAfter:i.node(o);if(Sl.isSelectable(e)){r=n&&s.$from.depth>0&&o>=s.$from.depth&&i.before(s.$from.depth+1)==s.$from.pos?i.before(s.$from.depth):i.before(o);break}}return null!=r&&(qa(e,Sl.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Sl.isSelectable(r))&&(qa(e,new Sl(n),"pointer"),!0)}(e,n))}(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||na&&this.mightDrag&&!this.mightDrag.node.isAtom||ea&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(qa(this.view,xl.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Wa(this.view,"pointer")}move(e){this.updateAllowDefault(e),Wa(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return!!this.allowDefault&&(this.delayedSelectionSync=!0,!0)}},ec=class extends Za{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(0==e.buttons||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc))return void this.done();e.preventDefault(),Wa(this.view,"pointer");let t=this.view.posAtCoords(Ha(e)),n=t&&Ga(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,s=this.startSelection,[i,o]=n.from<s.from?[s.to,n.from]:[s.from,n.to];qa(this.view,wl.create(r,i,o),"pointer")}};function tc(e,t){return!!e.composing||!!(na&&Math.abs(Date.now()-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Fa.touchstart=e=>{e.input.lastTouch=Date.now(),Xa(e),Wa(e,"pointer")},Fa.touchmove=e=>{e.input.lastTouch=Date.now(),Wa(e,"pointer")},Fa.contextmenu=e=>Xa(e);var nc=oa?5e3:-1;function rc(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>sc(e),t))}function sc(e,t=!1){if(!(oa&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),function(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}(e),t||e.docView&&e.docView.dirty){let n=function(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),i=s&&0==s.size,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l,a,c=r.resolve(o);if(Vl(n)){for(l=o;s&&!s.node;)s=s.parent;let e=s.node;if(s&&e.isAtom&&Sl.isSelectable(e)&&s.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,s=t==Bl(e);r||s;){if(e==n)return!0;let t=Il(e);if(!(e=e.parentNode))return!1;r=r&&0==t,s=s&&t==Bl(e)}}(n.focusNode,n.focusOffset,s.dom))){let e=s.posBefore;a=new Sl(o==e?c:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,s=o;for(let r=0;r<n.rangeCount;r++){let i=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),s=Math.max(s,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[l,o]=s==e.state.selection.anchor?[s,t]:[t,s],c=r.resolve(o)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);return a||(a=xa(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)),a}(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Va.compositionstart=Va.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof wl&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||ea&&ia&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),sc(e,!0),e.markCursor=null;else if(sc(e,!t.selection.empty),Zl&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}rc(e,nc)},Va.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,rc(e,20))};var ic=Xl&&Yl<15||ra&&aa<604;function oc(e,t,n,r,s){let i=Ma(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,s,i||No.empty)))return!0;if(!i)return!1;let o=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),l=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function lc(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Fa.copy=Va.cut=(e,t)=>{let n=t,r=e.state.selection,s="cut"==n.type;if(r.empty)return;let i=ic?null:n.clipboardData,{dom:o,text:l}=Ta(e,r.content());i?(n.preventDefault(),i.clearData(),i.setData("text/html",o.innerHTML),i.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,o),s&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Va.paste=(e,t)=>{let n=t;if(e.composing&&!oa)return;let r=ic?null:n.clipboardData,s=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&oc(e,lc(r),r.getData("text/html"),s,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?oc(e,r.value,null,s,t):oc(e,r.textContent,r.innerHTML,s,t)},50)}(e,n)};var ac=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},cc=sa?"altKey":"ctrlKey";function dc(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[cc]}Fa.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s,i=e.state.selection,o=i.empty?null:e.posAtCoords(Ha(n));if(o&&o.pos>=i.from&&o.pos<=(i instanceof Sl?i.to-1:i.to));else if(r&&r.mightDrag)s=Sl.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(s=Sl.create(e.state.doc,t.posBefore))}let{dom:l,text:a,slice:c}=Ta(e,(s||e.state.selection).content());(!n.dataTransfer.files.length||!ea||ta>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ic?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",ic||n.dataTransfer.setData("text/plain",a),e.dragging=new ac(c,dc(e,n),s)},Fa.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},Va.dragover=Va.dragenter=(e,t)=>t.preventDefault(),Va.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Ha(t));if(!r)return;let s=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",t=>{i=t(i,e,!1)}):i=Ma(e,lc(t.dataTransfer),ic?null:t.dataTransfer.getData("text/html"),!1,s);let o=!(!n||!dc(e,t));if(e.someProp("handleDrop",n=>n(e,t,i||No.empty,o)))return void t.preventDefault();if(!i)return;t.preventDefault();let l=i?function(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(0==n.openStart&&n.size?2:1);i++)for(let e=r.depth;e>=0;e--){let t=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1,n=r.index(e)+(t>0?1:0),o=r.node(e),l=!1;if(1==i)l=o.canReplace(n,n,s);else{let e=o.contentMatchAt(n).findWrapping(s.firstChild.type);l=e&&o.canReplaceWith(n,n,e[0])}if(l)return 0==t?r.pos:t<0?r.before(e+1):r.after(e+1)}return null}(e.state.doc,s.pos,i):s.pos;l??=s.pos;let a=e.state.tr;if(o){let{node:e}=n;e?e.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,h=a.doc;if(d?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(h))return;let u=a.doc.resolve(c);if(d&&Sl.isSelectable(i.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new Sl(u));else{let t=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((e,n,r,s)=>t=s),a.setSelection(xa(e,u,a.doc.resolve(t)))}e.focus(),e.dispatch(a.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},Fa.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ha(e)},20))},Fa.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Fa.beforeinput=(e,t)=>{if(oa&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,Wl(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let Vh in Va)Fa[Vh]=Va[Vh];function hc(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var uc=class e{constructor(e,t){this.toDOM=e,this.spec=t||xc,this.side=this.spec.side||0}map(e,t,n,r){let{pos:s,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new gc(s-n,s-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&hc(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},pc=class e{constructor(e,t){this.attrs=e,this.spec=t||xc}map(e,t,n,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return s>=i?null:new gc(s,i,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&hc(this.attrs,t.attrs)&&hc(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},fc=class e{constructor(e,t){this.attrs=e,this.spec=t||xc}map(e,t,n,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=s.pos?null:new gc(s.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:s}=e.content.findIndex(t.from);return s==t.from&&!(n=e.child(r)).isText&&s+n.nodeSize==t.to}eq(t){return this==t||t instanceof e&&hc(this.attrs,t.attrs)&&hc(this.spec,t.spec)}destroy(){}},gc=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new uc(n,r))}static inline(t,n,r,s){return new e(t,n,new pc(r,s))}static node(t,n,r,s){return new e(t,n,new fc(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof pc}get widget(){return this.type instanceof uc}},mc=[],xc={},bc=class e{constructor(e,t){this.local=e.length?e:mc,this.children=t.length?t:mc}static create(e,t){return t.length?jc(t,e,0,xc):yc}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,s){for(let i=0;i<this.local.length;i++){let o=this.local[i];o.from<=t&&o.to>=e&&(!s||s(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let o=this.children[i]+1;this.children[i+2].findInner(e-o,t-o,n,r+o,s)}}map(e,t,n){return this==yc||0==e.maps.length?this:this.mapInner(e,t,0,0,n||xc)}mapInner(t,n,r,s,i){let o;for(let e=0;e<this.local.length;e++){let l=this.local[e].map(t,r,s);l&&l.type.valid(n,l)?(o||(o=[])).push(l):i.onRemove&&i.onRemove(this.local[e].spec)}return this.children.length?function(e,t,n,r,s,i,o){let l=e.slice();for(let c=0,d=i;c<n.maps.length;c++){let e=0;n.maps[c].forEach((t,n,r,s)=>{let i=s-r-(n-t);for(let o=0;o<l.length;o+=3){let r=l[o+1];if(r<0||t>r+d-e)continue;let s=l[o]+d-e;n>=s?l[o+1]=t<=s?-2:-1:t>=d&&i&&(l[o]+=i,l[o+1]+=i)}e+=i}),d=n.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(-2==l[c+1]){a=!0,l[c+1]=-1;continue}let t=n.map(e[c]+i),d=t-s;if(d<0||d>=r.content.size){a=!0;continue}let h=n.map(e[c+1]+i,-1)-s,{index:u,offset:p}=r.content.findIndex(d),f=r.maybeChild(u);if(f&&p==d&&p+f.nodeSize==h){let r=l[c+2].mapInner(n,f,t+1,e[c]+i+1,o);r!=yc?(l[c]=d,l[c+1]=h,l[c+2]=r):(l[c+1]=-2,a=!0)}else a=!0}if(a){let a=jc(function(e,t,n,r,s,i,o){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(r,s,t);l?n.push(l):o.onRemove&&o.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let a=0;a<e.length;a+=3)-1==e[a+1]&&l(e[a+2],t[a]+i+1);return n}(l,e,t,n,s,i,o),r,0,o);t=a.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<a.children.length;e+=3){let n=a.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,a.children[e],a.children[e+1],a.children[e+2])}}return new bc(t.sort(Cc),l)}(this.children,o||[],t,n,r,s,i):o?new e(o.sort(Cc),mc):yc}add(t,n){return n.length?this==yc?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let s,i=0;t.forEach((e,t)=>{let o,l=t+r;if(o=kc(n,e,l)){for(s||(s=this.children.slice());i<s.length&&s[i]<t;)i+=3;s[i]==t?s[i+2]=s[i+2].addInner(e,o,l+1):s.splice(i,0,t,t+e.nodeSize,jc(o,e,l+1,xc)),i+=3}});let o=wc(i?Sc(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(Cc):this.local,s||this.children)}remove(e){return 0==e.length||this==yc?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,s=this.local;for(let e=0;e<r.length;e+=3){let s,i=r[e]+n,o=r[e+1]+n;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>i&&e.to<o&&(t[n]=null,(s||(s=[])).push(e));if(!s)continue;r==this.children&&(r=this.children.slice());let l=r[e+2].removeInner(s,i+1);l!=yc?r[e+2]=l:(r.splice(e,3),e-=3)}if(s.length)for(let e,i=0;i<t.length;i++)if(e=t[i])for(let t=0;t<s.length;t++)s[t].eq(e,n)&&(s==this.local&&(s=this.local.slice()),s.splice(t--,1));return r==this.children&&s==this.local?this:s.length||r.length?new e(s,r):yc}forChild(t,n){if(this==yc)return this;if(n.isLeaf)return e.empty;let r,s;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let i=t+1,o=i+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>i&&t.type instanceof pc){let e=Math.max(i,t.from)-i,n=Math.min(o,t.to)-i;e<n&&(s||(s=[])).push(t.copy(e,n))}}if(s){let t=new e(s.sort(Cc),mc);return r?new vc([t,r]):t}return r||yc}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return Nc(this.localsInner(e))}localsInner(e){if(this==yc)return mc;if(e.inlineContent||!this.local.some(pc.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof pc||t.push(this.local[n]);return t}forEachSet(e){e(this)}};bc.empty=new bc([],[]),bc.removeOverlap=Nc;var yc=bc.empty,vc=class e{constructor(e){this.members=e}map(t,n){const r=this.members.map(e=>e.map(t,n,xc));return e.from(r)}forChild(t,n){if(n.isLeaf)return bc.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(t,n);i!=yc&&(i instanceof e?r=r.concat(i.members):r.push(i))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<s.length;e++)t.push(s[e])}else t=s}return t?Nc(n?t:t.sort(Cc)):mc}static from(t){switch(t.length){case 0:return yc;case 1:return t[0];default:return new e(t.every(e=>e instanceof bc)?t:t.reduce((e,t)=>e.concat(t instanceof bc?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function wc(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new gc(s.from+t,s.to+t,s.type))}return n}function kc(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,s=null;for(let i,o=0;o<e.length;o++)(i=e[o])&&i.from>n&&i.to<r&&((s||(s=[])).push(i),e[o]=null);return s}function Sc(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function jc(e,t,n,r){let s=[],i=!1;t.forEach((t,o)=>{let l=kc(e,t,o+n);if(l){i=!0;let e=jc(l,t,n+o+1,r);e!=yc&&s.push(o,o+t.nodeSize,e)}});let o=wc(i?Sc(e):e,-n).sort(Cc);for(let l=0;l<o.length;l++)o[l].type.valid(t,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new bc(o,s):yc}function Cc(e,t){return e.from-t.from||e.to-t.to}function Nc(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let s=n+1;s<t.length;s++){let i=t[s];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Ec(t,s,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[s]=i.copy(i.from,r.to),Ec(t,s+1,i.copy(r.to,i.to)))}}return t}function Ec(e,t,n){for(;t<e.length&&Cc(n,e[t])>0;)t++;e.splice(t,0,n)}var Ac=/[\uD800-\uDBFF]/,_c=/[\uDC00-\uDFFF]/,Tc=(e,t)=>e>>>t|e<<32-t,Mc=e=>Tc(e,2)^Tc(e,13)^Tc(e,22),Dc=e=>Tc(e,6)^Tc(e,11)^Tc(e,25),Oc=e=>Tc(e,7)^Tc(e,18)^e>>>3,$c=e=>Tc(e,17)^Tc(e,19)^e>>>10,Rc=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]),Ic=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pc=class{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Ic),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,t=this._W;for(let d=16;d<64;d++)t[d]=$c(t[d-2])+t[d-7]+Oc(t[d-15])+t[d-16];let n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],l=e[5],a=e[6],c=e[7];for(let d,h,u=0;u<64;u++)d=c+Dc(o)+(o&l^~o&a)+Rc[u]+t[u]>>>0,h=Mc(n)+(n&r^n&s^r&s)>>>0,c=a,a=l,l=o,o=i+d>>>0,i=s,s=r,r=n,n=d+h>>>0;e[0]+=n,e[1]+=r,e[2]+=s,e[3]+=i,e[4]+=o,e[5]+=l,e[6]+=a,e[7]+=c}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<8*(3-t%4),t++;this._W[n]|=128<<8*(3-t%4)}this._updateHash()}const n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<8*n;n||(this._W[r-(t%4==0?0:1)]|=128<<8*(3-t%4)),this._W[14]=e.byteLength/536870912,this._W[15]=8*e.byteLength,this._updateHash();const s=new Uint8Array(32);for(let i=0;i<this._H.length;i++)for(let e=0;e<4;e++)s[4*i+e]=this._H[i]>>>8*(3-e);return s}},zc=new Rl("y-sync"),Lc=new Rl("y-undo"),Bc=(new Rl("yjs-cursor"),e=>{return Gt((e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)})((t=(e=>(e=>{const t=Pe();return e(t),ze(t)})(t=>Xe(t,e)))(e),(new Pc).digest(t))));var t}),Fc=(e,t)=>void 0===t?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!Nr(t.ds,e.id),Vc=[{light:"#ecd44433",dark:"#ecd444"}],Wc=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){const n=ae();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,(r=t)[me(St()*r.length)])}var r;return e.get(n)},Hc=(e,{colors:t=Vc,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:i}={})=>{let o=!1;const l=new Jc(e,i),a=new Dl({props:{editable:e=>{const t=zc.getState(e);return null==t.snapshot&&null==t.prevSnapshot}},key:zc,state:{init:(s,i)=>({type:e,doc:e.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{const n=e.getMeta(zc);if(void 0!==n){t=Object.assign({},t);for(const e in n)t[e]=n[e]}return t.addToHistory=!1!==e.getMeta("addToHistory"),t.isChangeOrigin=void 0!==n&&!!n.isChangeOrigin,t.isUndoRedoOperation=void 0!==n&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,null!==l.prosemirrorView&&(void 0===n||null==n.snapshot&&null==n.prevSnapshot||ur(0,()=>{null!=l.prosemirrorView&&(null==n.restore?l._renderSnapshot(n.snapshot,n.prevSnapshot,t):(l._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))})),t}},view:e=>(l.initView(e),i??l._forceRerender(),s(),{update:()=>{const t=a.getState(e.state);if(null==t.snapshot&&null==t.prevSnapshot&&(o||null!==e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content))){if(o=!0,!1===t.addToHistory&&!t.isChangeOrigin){const t=Lc.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}l.mux(()=>{t.doc.transact(n=>{n.meta.set("addToHistory",t.addToHistory),l._prosemirrorChanged(e.state.doc)},zc)})}},destroy:()=>{l.destroy()}})});return a},Uc=(e,t,n,r)=>{if(null==n)return r;if(!(null===r||n>1&&r<=1||wd(t,e,n,r)))return r;const s=vd(t,e,n);return null!==s?s:r},qc=(e,t)=>{const n=t.selection.jsonID;return{type:n,depth:"nodeRange"===n?t.selection.depth:void 0,anchor:md(t.selection.anchor,e.type,e.mapping),head:md(t.selection.head,e.type,e.mapping),absAnchor:t.selection.anchor,absHead:t.selection.head}},Jc=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=(()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else void 0!==n&&n()}})(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{null===this.beforeTransactionSelection&&null!=this.prosemirrorView&&(this.beforeTransactionSelection=qc(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()&&(Wt&&null===this._domSelectionInView&&(ur(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView)}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(null==e||null==e.anchorNode)return!1;const t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),0===t.getClientRects().length&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);const n=t.getBoundingClientRect(),r=or.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||(t=os(Tr(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(zc,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(e=>Gc(e,this.prosemirrorView.state.schema,this)).filter(e=>null!==e),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new No(vo.from(e),0,0));t.setMeta(zc,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=null!==this.beforeTransactionSelection?null:this.prosemirrorView.state.selection,t=this.type.toArray().map(e=>Gc(e,this.prosemirrorView.state.schema,this)).filter(e=>null!==e),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new No(vo.from(t),0,0));if(e){const t=be(ye(e.anchor,0),n.doc.content.size),r=be(ye(e.head,0),n.doc.content.size);n.setSelection(wl.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(zc,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,s=this.type;if(e||(e=ls(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if(e instanceof Uint8Array&&t instanceof Uint8Array||it(),r=new Rr({gc:!1}),Wr(r,t),t=ls(r),Wr(r,e),e=ls(r),null===s._item){const e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);s=r.getXmlFragment(e)}else{const e=r.store.clients.get(s._item.id.client)??[];s=e[fs(e,s._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{const i=n.permanentUserData;i&&i.dss.forEach(e=>{Cr(r,e,e=>{})});const o=(e,t)=>{const r="added"===e?i.getUserByClientId(t.client):i.getUserByDeletedId(t);return{user:r,type:e,color:Wc(n.colorMapping,n.colors,r)}},l=Xs(s,new is(t.ds,e.sv)).map(n=>!n._item.deleted||Fc(n._item,e)||Fc(n._item,t)?Gc(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>null!==e),a=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new No(vo.from(l),0,0));this.prosemirrorView.dispatch(a.setMeta(zc,{isChangeOrigin:!0}))},zc)})}_typeChanged(e,t){if(null==this.prosemirrorView)return;const n=zc.getState(this.prosemirrorView.state);0!==e.length&&null==n.snapshot&&null==n.prevSnapshot?this.mux(()=>{const e=(e,t)=>this.mapping.delete(t);Cr(t,t.deleteSet,e=>{if(e.constructor===co){const t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e),this.mapping.clear();const n=this.type.toArray().map(e=>Kc(e,this.prosemirrorView.state.schema,this)).filter(e=>null!==e),r=this.prosemirrorView.state.doc;let s=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new No(vo.from(n),0,0));((e,t,n,r)=>{if(null!==t&&null!==t.anchor&&null!==t.head)if("all"===t.type)e.setSelection(new Cl(e.doc));else if("node"===t.type){const r=bd(n.doc,n.type,t.anchor,n.mapping);null!==r&&e.setSelection(((e,t)=>{const n=e.doc.resolve(t);return n.nodeAfter?Sl.create(e.doc,t):wl.near(n)})(e,r))}else if("nodeRange"===t.type){const r=((e,t,n,r)=>{if(null===t||null===n)return null;const s=Math.min(Math.max(t,0),e.doc.content.size),i=Math.min(Math.max(n,0),e.doc.content.size);try{const t=xl.fromJSON(e.doc,{type:"nodeRange",anchor:s,head:i,depth:r});return t.ranges.length?t:wl.near(e.doc.resolve(s))}catch(Fh){return wl.near(e.doc.resolve(s))}})(e,bd(n.doc,n.type,t.anchor,n.mapping),bd(n.doc,n.type,t.head,n.mapping),t.depth);null!==r&&e.setSelection(r)}else{let s=bd(n.doc,n.type,t.anchor,n.mapping),i=bd(n.doc,n.type,t.head,n.mapping);null!=r&&(s=Uc(e.doc,r,t.absAnchor,s),i=Uc(e.doc,r,t.absHead,i)),null===s&&(s=i),null===i&&(i=s),null!==s&&null!==i&&e.setSelection(wl.between(e.doc.resolve(s),e.doc.resolve(i)))}})(s,this.beforeTransactionSelection,this,r),s=s.setMeta(zc,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof _s}),null!==this.beforeTransactionSelection&&this._isLocalCursorInView()&&s.scrollIntoView(),this.prosemirrorView.dispatch(s)}):this.renderSnapshot(n.snapshot,n.prevSnapshot)}_prosemirrorChanged(e){this.doc.transact(()=>{fd(this.doc,this.type,e,this),this.beforeTransactionSelection=qc(this,this.prosemirrorView.state)},zc)}initView(e){null!=this.prosemirrorView&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){null!=this.prosemirrorView&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}},Kc=(e,t,n,r,s,i)=>{const o=n.mapping.get(e);if(void 0===o){if(e instanceof Oi)return Gc(e,t,n,r,s,i);throw st()}return o},Gc=(e,t,n,r,s,i)=>{const o=[],l=e=>{if(e instanceof Oi){const l=Kc(e,t,n,r,s,i);null!==l&&o.push(l)}else{const l=(e._item.right?.content)?.type;l instanceof Ti&&!l._item.deleted&&l._item.id.client===l.doc.clientID&&(e.applyDelta([{retain:e.length},...l.toDelta()]),l.doc.transact(e=>{l._item.delete(e)}));const a=Xc(e,t,n,r,s,i);null!==a&&a.forEach(e=>{null!==e&&o.push(e)})}};void 0===r||void 0===s?e.toArray().forEach(l):Xs(e,new is(s.ds,r.sv)).forEach(l);try{const l=e.getAttributes(r);void 0!==r&&(Fc(e._item,r)?Fc(e._item,s)||(l.ychange=i?i("added",e._item.id):{type:"added"}):l.ychange=i?i("removed",e._item.id):{type:"removed"});const a=t.node(e.nodeName,l,o);return n.mapping.set(e,a),a}catch(Fh){return e.doc.transact(t=>{e._item.delete(t)},zc),n.mapping.delete(e),null}},Xc=(e,t,n,r,s,i)=>{const o=[],l=e.toDelta(r,s,i);try{for(let e=0;e<l.length;e++){const n=l[e];o.push(t.text(n.insert,ud(n.attributes,t)))}}catch(Fh){return e.doc.transact(t=>{e._item.delete(t)},zc),null}return o},Yc=(e,t)=>e instanceof Array?((e,t)=>{const n=new Ii,r=e.map(e=>({insert:e.text,attributes:pd(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n})(e,t):((e,t)=>{const n=new Oi(e.type.name);for(const r in e.attrs){const t=e.attrs[r];null!==t&&"ychange"!==r&&n.setAttribute(r,t)}return n.insert(0,ed(e).map(e=>Yc(e,t))),t.mapping.set(n,e),n})(e,t),Zc=e=>"object"==typeof e&&null!==e,Qc=(e,t)=>{const n=Object.keys(e).filter(t=>null!==e[t]);let r=n.length===Object.keys(t).filter(e=>null!==t[e]).length;for(let s=0;s<n.length&&r;s++){const i=n[s],o=e[i],l=t[i];r="ychange"===i||o===l||Zc(o)&&Zc(l)&&Qc(o,l)}return r},ed=e=>{const t=e.content.content,n=[];for(let r=0;r<t.length;r++){const e=t[r];if(e.isText){const e=[];for(let n=t[r];r<t.length&&n.isText;n=t[++r])e.push(n);r--,n.push(e)}else n.push(e)}return n},td=(e,t)=>{const n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&$t(e.attributes||{}).length===t[n].marks.length&&It(e.attributes,(e,r)=>{const s=hd(r),i=t[n].marks;return!!i.find(e=>e.type.name===s)&&Qc(e,i.find(e=>e.type.name===s)?.attrs)}))},nd=(e,t)=>{if(e instanceof Oi&&!(t instanceof Array)&&gd(e,t)){const n=ed(t);return e._length===n.length&&Qc(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>nd(e,n[t]))}return e instanceof Ii&&t instanceof Array&&td(e,t)},rd=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),sd=(e,t,n,r)=>{n>0&&(e.slice(t,t+n).forEach(e=>r.mapping.delete(e)),e.delete(t,n))},id=(e,t,n,r,s,i)=>{if(r<s){const o=[];for(let e=r;e<s;e++)o.push(Yc(n[e],i));e.insert(t,o)}},od=(e,t,n,r)=>t instanceof Ii&&n instanceof Array?(td(t,n)?r.mapping.set(t,n):cd(t,n,r),!0):!(!(t instanceof Oi)||n instanceof Array||!gd(t,n)||(nd(t,n)?r.mapping.set(t,n):fd(e,t,n,r),0)),ld=(e,t,n,r,s,i,o,l,a)=>{const c=be(i-s,l-o);for(let d=0;d<c;d++){const i=r[s+d],l=n[o+d];od(e,i,l,a)||(sd(t,o+d,1,a),id(t,o+d,n,o+d,o+d+1,a))}sd(t,o+c,i-s-c,a),id(t,o+c,n,o+c,l,a)},ad=(e,t,n)=>{const r=e.toArray(),s=ed(t),i=s.length,o=r.length,l=be(o,i);let a=0,c=0,d=!1;for(;a<l;a++){const e=r[a],t=s[a];if(rd(n.mapping.get(e),t))d=!0;else if(!nd(e,t))break}for(;a+c<l;c++){const e=r[o-c-1],t=s[i-c-1];if(rd(n.mapping.get(e),t))d=!0;else if(!nd(e,t))break}return{equalityFactor:a+c,foundMappedChild:d}},cd=(e,t,n)=>{n.mapping.set(e,t);const{nAttrs:r,str:s}=(e=>{let t="",n=e._start;const r={};for(;null!==n;)n.deleted||(n.countable&&n.content instanceof Ki?t+=n.content.str:n.content instanceof Hi&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}})(e),i=t.map(e=>({insert:e.text,attributes:Object.assign({},r,pd(e.marks,n))})),{insert:o,remove:l,index:a}=((e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&Ac.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&_c.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}})(s,i.map(e=>e.insert).join(""));e.delete(a,l),e.insert(a,o),e.applyDelta(i.map(e=>({retain:e.insert.length,attributes:e.attributes})))},dd=/(.*)(--[a-zA-Z0-9+/=]{8})$/,hd=e=>dd.exec(e)?.[1]??e,ud=(e,t)=>{const n=[];for(const r in e)n.push(t.mark(hd(r),e[r]));return n},pd=(e,t)=>{const n={};return e.forEach(e=>{if("ychange"!==e.type.name){const r=le(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${Bc(e.toJSON())}`:e.type.name]=e.attrs}}),n},fd=(e,t,n,r)=>{if(t instanceof Oi&&t.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(t,n),t instanceof Oi){const e=t.getAttributes(),r=n.attrs;for(const n in r)null!==r[n]?e[n]!==r[n]&&"ychange"!==n&&t.setAttribute(n,r[n]):t.removeAttribute(n);for(const n in e)void 0===r[n]&&t.removeAttribute(n)}const s=ed(n),i=s.length,o=t.toArray(),l=o.length,a=be(i,l);if(((e,t,n,r,s)=>{const i=((e,t,n)=>{const r=new Map;t.forEach((e,t)=>{r.has(e)||r.set(e,t)});const s=[];if(e.forEach((e,i)=>{const o=n.mapping.get(e),l=r.get(o);void 0!==l&&rd(o,t[l])&&s.push({yIndex:i,pIndex:l,yChild:e})}),0===s.length)return[];const i=new Array(s.length),o=[];for(let a=0;a<s.length;a++){let e=0,t=o.length;for(;e<t;){const n=e+t>>1;s[o[n]].pIndex<s[a].pIndex?e=n+1:t=n}i[a]=e>0?o[e-1]:-1,o[e]=a}const l=[];for(let a=o[o.length-1];-1!==a;a=i[a])l.push(s[a]);return l.reverse()})(r,n,s);if(i.length<2||!i.some(e=>e.yIndex!==e.pIndex)||i.some(e=>{const t=n[e.pIndex];return!(e.yChild instanceof Ii&&t instanceof Array||e.yChild instanceof Oi&&!(t instanceof Array))}))return!1;let o=0,l=0;for(const a of i){ld(e,t,n,r,o,a.yIndex,l,a.pIndex,s);const i=n[a.pIndex];od(e,a.yChild,i,s),o=a.yIndex+1,l=a.pIndex+1}return ld(e,t,n,r,o,r.length,l,n.length,s),!0})(e,t,s,o,r))return;let c=0,d=0;for(;c<a;c++){const e=o[c],t=s[c];if(!rd(r.mapping.get(e),t)){if(!nd(e,t))break;r.mapping.set(e,t)}}for(;d+c+1<a;d++){const e=o[l-d-1],t=s[i-d-1];if(!rd(r.mapping.get(e),t)){if(!nd(e,t))break;r.mapping.set(e,t)}}e.transact(()=>{for(;l-c-d>0&&i-c-d>0;){const n=o[c],a=s[c],h=o[l-d-1],u=s[i-d-1];if(n instanceof Ii&&a instanceof Array)td(n,a)||cd(n,a,r),c+=1;else{let s=n instanceof Oi&&gd(n,a),i=h instanceof Oi&&gd(h,u);if(s&&i){const e=ad(n,a,r),t=ad(h,u,r);e.foundMappedChild&&!t.foundMappedChild?i=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?s=!1:i=!1}s?(fd(e,n,a,r),c+=1):i?(fd(e,h,u,r),d+=1):(r.mapping.delete(t.get(c)),t.delete(c,1),t.insert(c,[Yc(a,r)]),c+=1)}}const n=l-c-d;if(1===l&&0===i&&o[0]instanceof Ii?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(c,c+n).forEach(e=>r.mapping.delete(e)),t.delete(c,n)),c+d<i){const e=[];for(let t=c;t<i-d;t++)e.push(Yc(s[t],r));t.insert(c,e)}},zc)},gd=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,md=(e,t,n)=>{if(0===e)return rs(t,0,-1);let r=null===t._first?null:t._first.content.type;for(;null!==r&&t!==r;){if(r instanceof Ii){if(r._length>=e)return rs(r,e,-1);if(e-=r._length,null!==r._item&&null!==r._item.next)r=r._item.next.content.type;else{do{r=null===r._item?null:r._item.parent,e--}while(r!==t&&null!==r&&null!==r._item&&null===r._item.next);null!==r&&r!==t&&(r=null===r._item?null:r._item.next.content.type)}}else{const s=(n.get(r)||{nodeSize:0}).nodeSize;if(null!==r._first&&e<s)r=r._first.content.type,e--;else{if(1===e&&0===r._length&&s>1)return new es(null===r._item?null:r._item.id,null===r._item?Zr(r):null,null);if(e-=s,null!==r._item&&null!==r._item.next)r=r._item.next.content.type;else{if(0===e)return r=null===r._item?r:r._item.parent,new es(null===r._item?null:r._item.id,null===r._item?Zr(r):null,null);do{r=r._item.parent,e--}while(r!==t&&null===r._item.next);r!==t&&(r=r._item.next.content.type)}}}if(null===r)throw it();if(0===e&&r.constructor!==Ii&&r!==t)return xd(r._item.parent,r._item)}return rs(t,t._length,-1)},xd=(e,t)=>{let n=null,r=null;return null===e._item?r=Zr(e):n=Yr(e._item.id.client,e._item.id.clock),new es(n,r,t.id)},bd=(e,t,n,r)=>{const s=ss(n,e);if(null===s||s.type!==t&&!Qr(t,s.type._item))return null;let i=s.type,o=0;if(i.constructor===Ii)o=s.index;else if(null===i._item||!i._item.deleted){let e=i._first,t=0;for(;t<i._length&&t<s.index&&null!==e;){if(!e.deleted){const n=e.content.type;if(t++,n instanceof Ii)o+=n._length;else{const e=r.get(n);if(null==e)return null;o+=e.nodeSize}}e=e.right}o+=1}for(;i!==t&&null!==i._item;){const e=i._item.parent;if(null===e._item||!e._item.deleted){o+=1;let t=e._first;for(;null!==t;){const e=t.content.type;if(e===i)break;if(!t.deleted)if(e instanceof Ii)o+=e._length;else{const t=r.get(e);if(null==t)return null;o+=t.nodeSize}t=t.right}}i=e}const l=o-1;return((e,t,n)=>{if(null===n)return!1;const r=ss(t,e);return null!==r&&r.type instanceof Ii&&null!==t.item&&n<=1})(e,n,l)?null:l},yd=(e,t)=>{if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])},vd=(e,t,n)=>{let r=0,s=0;for(;s<e.childCount;s++){const t=e.child(s);if(r+t.nodeSize>n)break;r+=t.nodeSize}if(s>=e.childCount)return null;const i=e.child(s),o=e.resolve(n),l=(e,t)=>{if(0===o.depth){const s=e+(n-r),i=e+1,o=e+t.nodeSize-1;return Math.max(i,Math.min(s,o))}return((e,t,n)=>{let r=t+1,s=n;for(let i=1;i<e.depth;i++){const t=e.index(i);if(t>=s.childCount)return null;for(let e=0;e<t;e++)r+=s.child(e).nodeSize;if(r+=1,s=s.child(t),s.type!==e.node(i+1).type)return null}return s.isTextblock?r+Math.min(e.parentOffset,s.content.size):null})(o,e,t)},a=(n,r=!1)=>{let i=0;for(let t=0;t<=s;t++)n(e.child(t))&&i++;let o=0,a=-1,c=null,d=0;for(let e=0;e<t.childCount;e++){const r=t.child(e);n(r)&&(o++,o===i&&(a=d,c=r)),d+=r.nodeSize}return null===c||r&&(1!==i||1!==o)?null:l(a,c)},c=e=>e.type===i.type&&yd(e.attrs,i.attrs),d=i.textContent,h=a(e=>c(e)&&e.textContent===d);if(null!==h)return h;const u=a(e=>e.type===i.type&&e.textContent===d);if(null!==u)return u;if((e=>{const t=e.type.spec.attrs||{};return Object.keys(e.attrs).some(n=>{const r=t[n];return null==r||!Object.prototype.hasOwnProperty.call(r,"default")||r.default!==e.attrs[n]})})(i)){const e=a(c,!0);if(null!==e)return e}return a(e=>c(e)&&""!==d&&""!==e.textContent&&(d.startsWith(e.textContent)||e.textContent.startsWith(d)),!0)},wd=(e,t,n,r)=>{if(null===r)return!1;const s=e.resolve(n),i=t.resolve(r);if(!s.parent.isTextblock)return!1;if(!i.parent.isTextblock)return!0;if(s.parent.textContent!==i.parent.textContent)return!0;if(0!==s.parentOffset&&0===i.parentOffset)return!0;const o=0===s.parentOffset&&0===i.parentOffset,l=s.parentOffset!==i.parentOffset||s.parent.type!==i.parent.type||!yd(s.parent.attrs,i.parent.attrs);if(o||l){const s=vd(e,t,n);return null!==s&&s!==r}return!1},kd=new Set(["paragraph"]);function Sd(e){return!!e.getMeta(zc)}function jd(e,t){const n=zc.getState(e);return bd(n.doc,n.type,t,n.binding.mapping)||0}function Cd(e,t){const n=zc.getState(e);return md(t,n.type,n.binding.mapping)}var Nd=class e extends b.MappablePosition{constructor(e,t){super(e),this.yRelativePosition=t}static fromJSON(t){return new e(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};b.Extension.create({name:"collaboration",priority:1e3,addOptions:()=>({document:null,field:"default",fragment:null,provider:null}),addStorage:()=>({isDisabled:!1}),onCreate(){this.editor.extensionManager.extensions.find(e=>"undoRedo"===e.name)},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>function(e,t,n){const r=e instanceof Nd?e.yRelativePosition:null;if(Sd(t)&&r)return{position:new Nd(jd(n,r),r),mapResult:null};const s=(0,b.getUpdatedPosition)(e,t),i=s.position.position;return{position:new Nd(i,null!=r?r:Cd(n,i)),mapResult:s.mapResult}}(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>function(e,t){return new Nd(e,Cd(t,e))}(e,this.editor.state)},addCommands:()=>({undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta("preventDispatch",!0),0!==Lc.getState(t).undoManager.undoStack.length&&(!n||(e=>{const t=Lc.getState(e).undoManager;if(null!=t)return t.undo(),!0})(t))),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta("preventDispatch",!0),0!==Lc.getState(t).undoManager.redoStack.length&&(!n||(e=>{const t=Lc.getState(e).undoManager;if(null!=t)return t.redo(),!0})(t)))}),addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=(({protectedNodes:e=kd,trackedOrigins:t=[],undoManager:n=null}={})=>new Dl({key:Lc,state:{init:(r,s)=>{const i=zc.getState(s);let o=n;if(!o){const n=i.doc,r=new Set(n?n._observers.get("destroy"):[]);o=new _s(i.type,{trackedOrigins:new Set([zc].concat(t)),deleteFilter:t=>((e,t)=>!(e instanceof co&&e.content instanceof ro&&(e.content.type instanceof Ti||e.content.type instanceof Oi&&t.has(e.content.type.nodeName))&&0!==e.content.type._length))(t,e),captureTransaction:e=>!1!==e.meta.get("addToHistory")});const s=n?n._observers.get("destroy"):new Set;o._yTiptapDocDestroyListeners=Array.from(s||[]).filter(e=>!r.has(e))}return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{const s=zc.getState(r).binding,i=t.undoManager,o=i.undoStack.length>0,l=i.redoStack.length>0;return s?{undoManager:i,prevSel:qc(s,n),hasUndoOps:o,hasRedoOps:l}:o!==t.hasUndoOps||l!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:i.undoStack.length>0,hasRedoOps:i.redoStack.length>0}):t}},view:e=>{const t=zc.getState(e.state),n=Lc.getState(e.state).undoManager;return n.on("stack-item-added",({stackItem:n})=>{const r=t.binding;r&&n.meta.set(r,Lc.getState(e.state).prevSel)}),n.on("stack-item-popped",({stackItem:e})=>{const n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy();const e=n._yTiptapDocDestroyListeners;e&&n.doc&&(e.forEach(e=>n.doc.off("destroy",e)),n._yTiptapDocDestroyListeners=null)}}}}))(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{const{undoManager:t}=Lc.getState(e.state);t.restore&&(t.restore(),t.restore=()=>{});const r=n?n(e):void 0;return{destroy:()=>{const e=t.trackedOrigins.has(t),n=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on("afterTransaction",t.afterTransactionHandler),t._observers=n},null!=r&&r.destroy&&r.destroy()}}},[Hc(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,this.editor.options.enableContentCheck&&new y.Plugin({key:new y.PluginKey("filterInvalidContent"),filterTransaction:t=>{if(!Sd(t))return!0;if(this.storage.isDisabled)return!1;if(!t.docChanged)return!0;try{return t.doc.check(),!0}catch(n){return this.storage.isDisabled=!0,this.editor.emit("contentError",{error:n,editor:this.editor,disableCollaboration:()=>{var t;null==(t=e.doc)||t.destroy()}}),!0}}})].filter(Boolean)}});function Ed(e,t){const{state:n}=t,r=n.selection.$anchor;let s=!1;if(r.depth)for(let i=r.depth;i>0;i--)r.node(i).type.name===e&&(t.dispatchTransaction&&t.dispatchTransaction(n.tr.delete(r.before(i),r.after(i)).scrollIntoView()),s=!0);else{const r=n.selection.node;r&&r.type.name===e&&(t.chain().deleteSelection().run(),s=!0)}if(!s){const i=r.pos;if(i){const r=n.tr.doc.nodeAt(i);r&&r.type.name===e&&(t.dispatchTransaction&&t.dispatchTransaction(n.tr.delete(i,i+r.nodeSize)),s=!0)}}return s}var Ad=[{value:"note",label:"Note",icon:"Info"},{value:"tip",label:"Tip",icon:"Lightbulb"},{value:"important",label:"Important",icon:"AlertCircle"},{value:"warning",label:"Warning",icon:"TriangleAlert"},{value:"caution",label:"Caution",icon:"OctagonAlert"}];function _d(){const e=n.l$2(),t=n.f$2(),{t:r}=n._(),{type:s,title:i,body:o}=n.Ht(t,n.q.name,{type:"note",title:"",body:""}),[l,a]=(0,x.useState)(!1),[c,d]=(0,x.useState)("note"),[h,u]=(0,x.useState)(""),[p,f]=(0,x.useState)("");(0,x.useEffect)(()=>{l&&(d(s||"note"),u(i||""),f(o||""))},[l,s,i,o]);const g=(0,x.useCallback)(()=>{t&&(t.chain().updateAttributes(n.q.name,{type:c,title:h,body:p}).focus().run(),a(!1))},[t,c,h,p]),m=(0,x.useCallback)(()=>{a(!1)},[]),b=(0,x.useCallback)(()=>{Ed(n.q.name,t)},[t]),y=(0,x.useCallback)(()=>t.isActive(n.q.name),[t]);return e?(0,v.jsx)(S.BubbleMenu,{editor:t,options:{placement:"top",offset:8,flip:!0},pluginKey:"RichTextBubbleCallout",shouldShow:y,children:(0,v.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,v.jsxs)(n.o,{onOpenChange:a,open:l,children:[(0,v.jsx)(n.s,{asChild:!0,children:(0,v.jsx)(n.f$3,{icon:"Pencil",tooltip:r("editor.callout.edit.title")})}),(0,v.jsxs)(n.h$1,{children:[(0,v.jsx)(n.m,{children:r("editor.callout.edit.title")}),(0,v.jsxs)("div",{className:"richtext-space-y-4 richtext-py-4",children:[(0,v.jsxs)("div",{className:"richtext-space-y-2",children:[(0,v.jsx)(n.s$2,{children:r("editor.callout.dialog.type")}),(0,v.jsxs)(n.R,{onValueChange:d,value:c,children:[(0,v.jsx)(n.B,{children:(0,v.jsx)(n.S,{className:"richtext-text-accent",placeholder:r("editor.callout.dialog.type.placeholder")})}),(0,v.jsx)(n.V,{children:Ad.map(e=>(0,v.jsx)(n.D$1,{value:e.value,children:r(`editor.callout.type.${e.value}`)},e.value))})]})]}),(0,v.jsxs)("div",{className:"richtext-space-y-2",children:[(0,v.jsx)(n.s$2,{children:r("editor.callout.dialog.title.label")}),(0,v.jsx)(n.i$1,{onChange:e=>u(e.target.value),placeholder:r("editor.callout.dialog.title.placeholder"),type:"text",value:h})]}),(0,v.jsxs)("div",{className:"richtext-space-y-2",children:[(0,v.jsx)(n.s$2,{children:r("editor.callout.dialog.body.label")}),(0,v.jsx)(n.i$1,{onChange:e=>f(e.target.value),placeholder:r("editor.callout.dialog.body.placeholder"),type:"text",value:p})]})]}),(0,v.jsxs)(n.n$2,{children:[(0,v.jsx)(n.x$1,{onClick:m,variant:"outline",children:r("editor.callout.dialog.button.cancel")}),(0,v.jsx)(n.x$1,{onClick:g,children:r("editor.callout.dialog.button.apply")})]})]})]}),(0,v.jsx)(n.f$3,{action:b,icon:"Trash2",tooltip:r("editor.delete")})]})}):(0,v.jsx)(v.Fragment,{})}function Td(){const e=n.l$2(),t=n.f$2(),{t:r}=n._(),s=(0,x.useCallback)(()=>t.isActive(n.A.name),[t]),i=(0,x.useCallback)(()=>Ed(n.A.name,t),[t]),o=(0,x.useCallback)(()=>t.chain().focus().addColBefore().run(),[t]),l=(0,x.useCallback)(()=>t.chain().focus().addColAfter().run(),[t]),a=(0,x.useCallback)(()=>t.chain().focus().deleteCol().run(),[t]);return e?(0,v.jsx)(S.BubbleMenu,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleColumns",shouldShow:s,children:(0,v.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,v.jsx)(n.f$3,{action:o,icon:"ColumnAddLeft",tooltip:r("editor.table.menu.insertColumnBefore")}),(0,v.jsx)(n.f$3,{action:l,icon:"ColumnAddRight",tooltip:r("editor.table.menu.insertColumnAfter")}),(0,v.jsx)(n.f$3,{action:a,icon:"DeleteColumn",tooltip:r("editor.table.menu.deleteColumn")}),(0,v.jsx)(n.f$3,{action:i,icon:"Trash2",tooltip:r("editor.table.menu.delete_column")})]})}):(0,v.jsx)(v.Fragment,{})}function Md(e,t){const r=["SizeS","SizeM","SizeL"];return["size-small","size-medium","size-large"].map((s,i)=>({type:`image-${s}`,component:n.f$3,componentProps:{tooltip:t(`editor.${s.replace("-",".")}.tooltip`),icon:r[i],action:()=>e.commands.updateImage({width:n.p$3[s]}),isActive:()=>e.isActive("image",{width:n.p$3[s]})}}))}function Dd(e,t){const r=["SizeS","SizeM","SizeL"];return["size-small","size-medium","size-large"].map((s,i)=>({type:`image-${s}`,component:n.f$3,componentProps:{tooltip:t(`editor.${s.replace("-",".")}.tooltip`),icon:r[i],action:()=>e.commands.updateImageGif({width:n.p$3[s]}),isActive:()=>e.isActive("image",{width:n.p$3[s]})}}))}function Od(e,t){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(s=>({type:`image-${s}`,component:n.f$3,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:r[s],action:()=>e.commands?.setAlignImage?.(s),isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function $d(e,t){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(s=>({type:`image-${s}`,component:n.f$3,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:r[s],action:()=>e.commands?.setAlignImageGif?.(s),isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function Rd(e,t){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(s=>({type:`image-${s}`,component:n.f$3,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:r[s],action:()=>e.commands?.setAlignImageMermaid?.(s),isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function Id(e,t){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(s=>({type:`image-${s}`,component:n.f$3,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:r[s],action:()=>e.commands?.setAlignImageDrawer?.(s),isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function Pd(e){return[{type:"flex-start",icon:"AlignLeft",tooltip:"Align left"},{type:"center",icon:"AlignCenter",tooltip:"Align center"},{type:"flex-end",icon:"AlignRight",tooltip:"Align right"}].map(t=>({type:`video-align-${t.type}`,component:n.f$3,componentProps:{tooltip:t.tooltip,icon:t.icon,action:()=>e.commands.updateVideo({align:t.type}),isActive:()=>e.getAttributes("video").align===t.type}}))}function zd(e,t){const r=["SizeS","SizeM","SizeL"];return["size-small","size-medium","size-large"].map((s,i)=>({type:`video-${s}`,component:n.f$3,componentProps:{tooltip:t(`editor.${s.replace("-",".")}.tooltip`),icon:r[i],action:()=>e.commands.updateVideo({width:n.u$3[s]}),isActive:()=>e.isActive("video",{width:n.u$3[s]})}}))}var Ld=!1;function Bd({editor:e,attrs:t,extension:r}){const[s,i]=(0,x.useState)(!1),o=(0,x.useRef)(null),l=(0,x.useRef)(null),{alt:a,align:c}=t,d=r?.options.upload;(0,x.useEffect)(()=>{s&&setTimeout(()=>{(async()=>{const e=document.querySelector("#easydrawer");e&&(o.current=new E.Editor(e,{wheelEventsEnabled:!1,disableZoom:!0}),l.current=(0,E.makeDropdownToolbar)(o.current),l.current.addDefaultToolWidgets(),o.current.loadFromSVG(decodeURIComponent(a)))})()},200)},[s]);const h=()=>{if(Ld){for(;o.current.history.redoStackSize>0;)o.current.history.redo();Ld=!1}else o.current.history.undo()};return(0,v.jsxs)(n.o,{onOpenChange:i,open:s,children:[(0,v.jsx)(n.s,{asChild:!0,children:(0,v.jsx)(n.f$3,{action:()=>i(!0),icon:"Pencil",tooltip:"Edit Drawer"})}),(0,v.jsxs)(n.h$1,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,v.jsx)(n.m,{children:"Edit Drawer"}),(0,v.jsxs)("div",{style:{height:"100%",borderWidth:1,background:"white",position:"relative"},children:[(0,v.jsx)("div",{className:"richtext-size-full",id:"easydrawer"}),(0,v.jsx)(n.me,{changeBorderColorShape:e=>{const t=o.current.toolController.getPrimaryTools()[5],n=l.current.getWidgetById("shape");t&&n&&(t.setBorderColor(e),n.serializeState())},changeColorShape:e=>{const t=o.current.toolController.getPrimaryTools()[5],n=l.current.getWidgetById("shape");t&&n&&(t.setColor(e),n.serializeState())},changeShape:e=>{const t=l.current.getWidgetById("shape");t&&t.setShapeType(e)},onClear:()=>{if(!Ld){for(;o.current.history.undoStackSize>0;)h();Ld=!0}},onRedo:()=>{Ld||o.current.history.redo()},onThicknessChange:e=>{const t=o.current.toolController.getPrimaryTools()[5],n=l.current.getWidgetById("shape");t&&n&&(t.setThickness(e),n.serializeState())},onUndo:h,refEditor:o,setColorHighlight:e=>{const t=o.current.toolController.getPrimaryTools()[3],n=l.current.getWidgetById("pen-2");t&&n&&(t.setColor(e),n.serializeState())},setColorPen:e=>{const t=o.current.toolController.getPrimaryTools()[2],n=l.current.getWidgetById("pen-1");t&&n&&(t.setColor(e),n.serializeState())},setThicknessPen:e=>{const t=o.current.toolController.getPrimaryTools()[2],n=l.current.getWidgetById("pen-1");t&&n&&(t.setThickness(e),n.serializeState())}})]}),(0,v.jsx)(n.n$2,{children:(0,v.jsx)(n.x$1,{onClick:async()=>{if(o.current){const t=o.current.toSVG(),r=t.outerHTML,s=`drawer-${n.a$2()}.svg`;let i=n.n$1(t.outerHTML);if(d){const e=n.s$1(i,s);i=await d(e)}e?.chain().focus().setDrawer({type:"drawer",src:i,alt:encodeURIComponent(r),width:426,height:212},!!r).run(),e?.commands.setAlignImageDrawer(c)}i(!1)},type:"button",children:"Save changes"})})]})]})}function Fd({item:e,disabled:t,editor:r}){const s=e.component;return s?(0,v.jsx)(x.Fragment,{children:"divider"===e.type?(0,v.jsx)(n.k$1,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):(0,v.jsx)(s,{...e.componentProps,disabled:t||e?.componentProps?.disabled,editor:r})}):(0,v.jsx)(v.Fragment,{})}function Vd(){const{lang:e,t:t}=n._(),r=n.l$2(),s=n.f$2(),i=n.Ht(s,n.ve.name),o=n.y$3(n.ve.name),l=(0,x.useMemo)(()=>function(e,t){return[...Id(e,t),{type:"edit",component:n.f$3,componentProps:{editor:e,tooltip:t("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:n.f$3,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;(0,A.deleteSelection)(t,n)}}}]}(s,t),[s,e,t]);return r?(0,v.jsx)(S.BubbleMenu,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleDrawer",shouldShow:({editor:e})=>{const{selection:t}=e.view.state,{$from:r,to:s}=t;let i=!1;return e.view.state.doc.nodesBetween(r.pos,s,e=>{if(e.type.name===n.ve.name)return i=!0,!1}),i},children:l?.length?(0,v.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:l?.map((e,t)=>"edit"===e.type&&i?.src?(0,v.jsx)(Bd,{attrs:i,editor:s,extension:o},`bubbleMenu-drawer-${t}`):(0,v.jsx)(Fd,{editor:s,item:e},`bubbleMenu-drawer-${t}`))}):(0,v.jsx)(v.Fragment,{})}):(0,v.jsx)(v.Fragment,{})}function Wd({children:e,visible:t,toggleVisible:r}){const{t:s}=n._(),i=n.f$2(),[o,l]=(0,x.useState)(null);(0,x.useEffect)(()=>{a.l().then(l)},[]);const{text:c,macros:d}=n.Ht(i,n.Wt.name,{text:"",macros:""}),[h,u]=(0,x.useState)(decodeURIComponent(c||"")),[p,f]=(0,x.useState)(decodeURIComponent(d||""));(0,x.useEffect)(()=>{t&&(u(decodeURIComponent(c||"")),f(decodeURIComponent(d||"")))},[t]);const g=(0,x.useCallback)(()=>{i.chain().focus().setKatex({text:encodeURIComponent(h),macros:encodeURIComponent(p)}).run(),u(""),f(""),r(!1)},[i,h,p,r]),m=(0,x.useMemo)(()=>{if(!o)return h;try{return o.renderToString(h,{macros:n.Y(p||"")})}catch{return h}},[h,p,o]),b=(0,x.useMemo)(()=>`${h}`.trim()?m:null,[h,m]);return(0,v.jsxs)(n.o,{onOpenChange:r,open:t,children:[(0,v.jsx)(n.s,{asChild:!0,children:e}),(0,v.jsxs)(n.h$1,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,v.jsx)(n.m,{children:s("editor.formula.dialog.text")}),(0,v.jsx)("div",{style:{height:"100%",border:"1px solid var(--richtext-border)"},children:(0,v.jsxs)("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[(0,v.jsxs)("div",{className:"richtext-flex-1",children:[(0,v.jsx)(n.s$2,{className:"mb-[6px]",children:"Expression"}),(0,v.jsx)(n.i,{autoFocus:!0,className:"richtext-mb-[10px]",onChange:e=>u(e.target.value),placeholder:"Text",required:!0,rows:10,value:h,style:{color:"var(--richtext-foreground)"}}),(0,v.jsx)(n.s$2,{className:"mb-[6px]",children:"Macros"}),(0,v.jsx)(n.i,{onChange:e=>f(e.target.value),placeholder:"Macros",rows:10,value:p,style:{color:"var(--richtext-foreground)"}})]}),(0,v.jsx)("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:b||""},style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),(0,v.jsx)(n.n$2,{children:(0,v.jsx)(n.x$1,{onClick:g,type:"button",children:"Save changes"})})]})]})}function Hd(){const e=n.l$2(),t=n.f$2(),[r,s]=(0,x.useState)(!1),i=(0,x.useCallback)(()=>t.isActive(n.Wt.name),[t]),o=(0,x.useCallback)(()=>Ed(n.Wt.name,t),[t]);return e?(0,v.jsx)(S.BubbleMenu,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleKatex",shouldShow:i,children:(0,v.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,v.jsx)(Wd,{toggleVisible:s,visible:r,children:(0,v.jsx)(n.f$3,{action:()=>s(!r),tooltip:"Edit",children:(0,v.jsx)(w.Pencil,{size:16})})}),(0,v.jsx)(n.f$3,{action:o,tooltip:"Delete",children:(0,v.jsx)(w.Trash2,{size:16})})]})}):(0,v.jsx)(v.Fragment,{})}function Ud(e){const{t:t}=n._();return(0,v.jsxs)("div",{className:"richtext-flex richtext-flex-nowrap",children:[(0,v.jsx)(n.f$3,{disabled:!e?.link,icon:"ExternalLink",tooltip:t("editor.link.open.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{window.open(e?.link,"_blank")}}),(0,v.jsx)(n.f$3,{icon:"Pencil",tooltip:t("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{e?.onEdit()}}),(0,v.jsx)(n.f$3,{icon:"Unlink",tooltip:t("editor.link.unlink.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{e?.onClear()}})]})}function qd(){const e=n.l$2(),t=n.f$2(),[r,s]=(0,x.useState)(!1),i=n.Ht(t,n.Fe.name)?.href,o=(0,x.useCallback)(({editor:e})=>e.isActive(n.Fe.name),[]),l=(0,x.useCallback)(()=>{t.chain().extendMarkRange("link").unsetLink().focus().run(),s(!1)},[t]);return e?(0,v.jsx)(S.BubbleMenu,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleLink",shouldShow:o,children:(0,v.jsx)(v.Fragment,{children:(0,v.jsx)("div",r?{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-4 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,v.jsx)(n.De,{editor:t,onClose:()=>{s(!1)},onSetLink:(e,n,r)=>{const{from:i}=t.state.selection,o=i+(n?.length??0);t.chain().extendMarkRange("link").insertContent({type:"text",text:n,marks:[{type:"link",attrs:{href:e,target:r?"_blank":""}}]}).setLink({href:e}).setTextSelection({from:i,to:o}).focus().run(),s(!1)}})}:{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,v.jsx)(Ud,{editor:t,link:i,onClear:l,onEdit:()=>{s(!0)}})})})}):(0,v.jsx)(v.Fragment,{})}function Jd({item:e,disabled:t,editor:r}){const s=e.component;return s?(0,v.jsx)(x.Fragment,{children:"divider"===e.type?(0,v.jsx)(n.k$1,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):(0,v.jsx)(s,{...e.componentProps,disabled:t||e?.componentdisabled,editor:r})}):(0,v.jsx)(v.Fragment,{})}function Kd(){const{lang:e,t:t}=n._(),r=n.l$2(),s=n.f$2(),i=(0,x.useMemo)(()=>function(e,t){return[{type:"flipX",component:n.f$3,componentProps:{editor:e,tooltip:t("editor.tooltip.flipX"),icon:"FlipX",action:()=>{const{flipX:t}=e.getAttributes("image");e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipX:!t}).run()}}},{type:"flipY",component:n.f$3,componentProps:{editor:e,tooltip:t("editor.tooltip.flipY"),icon:"FlipY",action:()=>{const{flipY:t}=e.getAttributes("image");e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipY:!t}).run()}}},...Md(e,t),...Od(e,t),{type:"remove",component:n.f$3,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;(0,A.deleteSelection)(t,n)}}}]}(s,t),[s,e,t]);return r?(0,v.jsx)(S.BubbleMenu,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleImage",shouldShow:({editor:e})=>{const{selection:t}=e.view.state,{$from:r,to:s}=t;let i=!1;return e.view.state.doc.nodesBetween(r.pos,s,e=>{if(function(e){return e.type.name===n.ae.name}(e))return i=!0,!1}),i},children:i?.length?(0,v.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:i?.map((e,t)=>(0,v.jsx)(Jd,{editor:s,item:e},`bubbleMenu-image-${t}`))}):(0,v.jsx)(v.Fragment,{})}):(0,v.jsx)(v.Fragment,{})}function Gd(){const{lang:e,t:t}=n._(),r=n.l$2(),s=n.f$2(),i=(0,x.useMemo)(()=>function(e,t){return[...Dd(e,t),...$d(e,t),{type:"remove",component:n.f$3,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;(0,A.deleteSelection)(t,n)}}}]}(s,t),[s,t,e]);return r?(0,v.jsx)(S.BubbleMenu,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleImageGif",shouldShow:({editor:e})=>{const{selection:t}=e.view.state,{$from:r,to:s}=t;let i=!1;return e.view.state.doc.nodesBetween(r.pos,s,e=>{if(function(e){return e.type.name===n.C.name}(e))return i=!0,!1}),i},children:i?.length?(0,v.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:i?.map((e,t)=>(0,v.jsx)(Jd,{editor:s,item:e},`bubbleMenu-image-gif-${t}`))}):(0,v.jsx)(v.Fragment,{})}):(0,v.jsx)(v.Fragment,{})}function Xd(){const{t:e}=n._(),t=n.l$2(),r=n.f$2(),s=(0,x.useMemo)(()=>function(e,t){return[...zd(e,t),...Pd(e),{type:"remove",component:n.f$3,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;(0,A.deleteSelection)(t,n)}}}]}(r,e),[r,e]);return t?(0,v.jsx)(S.BubbleMenu,{editor:r,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleVideo",shouldShow:({editor:e})=>{const{selection:t}=e.view.state,{$from:r,to:s}=t;let i=!1;return e.view.state.doc.nodesBetween(r.pos,s,e=>{if(function(e){return e.type.name===n.T.name}(e))return i=!0,!1}),i},children:s?.length?(0,v.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:s?.map((e,t)=>(0,v.jsx)(Jd,{editor:r,item:e},`bubbleMenu-video-${t}`))}):(0,v.jsx)(v.Fragment,{})}):(0,v.jsx)(v.Fragment,{})}var Yd="graph TB\na--\x3eb",Zd=({editor:e,attrs:t,extension:r})=>{const{alt:s,align:i}=t,[o,l]=(0,x.useState)(decodeURIComponent(s??Yd)),[a,c]=(0,x.useState)(""),[d,h]=(0,x.useState)(!1),u=(0,x.useRef)(null),[p,f]=(0,x.useState)(null),g=r?.options.upload,m=(0,x.useCallback)(e=>{e&&import("mermaid").then(e=>{f(e.default)})},[]),b=async e=>{try{const{svg:t}=await p.render("mermaid-svg",e);c(t)}catch{c("")}};return(0,x.useEffect)(()=>{p&&d&&(p.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),b(o))},[p,d]),(0,x.useEffect)(()=>{p&&d&&b(o)},[p,o]),(0,v.jsxs)(n.o,{onOpenChange:h,open:d,children:[(0,v.jsx)(n.s,{asChild:!0,children:(0,v.jsx)(n.f$3,{action:()=>h(!0),icon:"Pencil",tooltip:"Edit Mermaid"})}),(0,v.jsxs)(n.h$1,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,v.jsx)(n.m,{children:"Edit Mermaid"}),(0,v.jsx)("div",{ref:m,style:{height:"100%",border:"1px solid var(--richtext-border)"},children:(0,v.jsxs)("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[(0,v.jsx)(n.i,{autoFocus:!0,className:"richtext-flex-1",defaultValue:Yd,onChange:e=>l(e.target.value),placeholder:"Text",required:!0,rows:10,value:o,style:{color:"var(--richtext-foreground)"}}),(0,v.jsx)("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:a},ref:u,style:{height:"100%",border:"1px solid var(--richtext-border)",minHeight:500}})]})}),(0,v.jsx)(n.n$2,{children:(0,v.jsx)(n.x$1,{onClick:async()=>{if(""!==o){if(o){const t=u.current.querySelector("svg"),{width:r,height:s}=t.getBoundingClientRect(),l=`mermaid-${n.a$2()}.svg`;let a=n.n$1(t.outerHTML);if(g){const e=n.s$1(a,l);a=await g(e)}e?.chain().focus().setMermaid({type:"mermaid",src:a,alt:encodeURIComponent(o),width:r,height:s},!!o).run(),e?.commands.setAlignImageMermaid(i)}h(!1)}},type:"button",children:"Save changes"})})]})]})};function Qd({item:e,disabled:t,editor:r}){const s=e.component;return s?(0,v.jsx)(x.Fragment,{children:"divider"===e.type?(0,v.jsx)(n.k$1,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):(0,v.jsx)(s,{...e.componentProps,disabled:t||e?.componentProps?.disabled,editor:r})}):(0,v.jsx)(v.Fragment,{})}function eh(){const{lang:e,t:t}=n._(),r=n.l$2(),s=n.f$2(),i=n.Ht(s,n.O.name),o=n.y$3(n.O.name),l=(0,x.useMemo)(()=>function(e,t){return[...Rd(e,t),{type:"edit",component:n.f$3,componentProps:{editor:e,tooltip:t("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:n.f$3,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:n}=e.view;(0,A.deleteSelection)(t,n)}}}]}(s,t),[s,e,t]);return r?(0,v.jsx)(S.BubbleMenu,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleMermaid",shouldShow:({editor:e})=>{const{selection:t}=e.view.state,{$from:r,to:s}=t;let i=!1;return e.view.state.doc.nodesBetween(r.pos,s,e=>{if(function(e){return e.type.name===n.O.name}(e))return i=!0,!1}),i},children:l?.length?(0,v.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:l?.map((e,t)=>"edit"===e.type&&i?.src?(0,v.jsx)(Zd,{attrs:i,editor:s,extension:o},`bubbleMenu-mermaid-${t}`):(0,v.jsx)(Qd,{editor:s,item:e},`bubbleMenu-mermaid-${t}`))}):(0,v.jsx)(v.Fragment,{})}):(0,v.jsx)(v.Fragment,{})}function th({hiddenActions:e=[]}){const{t:t}=n._(),r=n.l$2(),s=n.f$2(),i=t=>e.includes(t);return r?(0,v.jsx)(S.BubbleMenu,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleTable",shouldShow:({editor:e})=>(0,b.isActive)(e.view.state,n.st.name),children:(0,v.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[!i("addColumnBefore")&&(0,v.jsx)(n.f$3,{action:function(){s.chain().focus().addColumnBefore().run()},disabled:!s?.can()?.addColumnBefore?.(),icon:"BetweenHorizonalEnd",tooltip:t("editor.table.menu.insertColumnBefore"),tooltipOptions:{sideOffset:15}}),!i("addColumnAfter")&&(0,v.jsx)(n.f$3,{action:function(){s.chain().focus().addColumnAfter().run()},disabled:!s?.can()?.addColumnAfter?.(),icon:"BetweenHorizonalStart",tooltip:t("editor.table.menu.insertColumnAfter"),tooltipOptions:{sideOffset:15}}),!i("deleteColumn")&&(0,v.jsx)(n.f$3,{action:function(){s.chain().focus().deleteColumn().run()},disabled:!s?.can().deleteColumn?.(),icon:"DeleteColumn",tooltip:t("editor.table.menu.deleteColumn"),tooltipOptions:{sideOffset:15}}),(0,v.jsx)(n.k$1,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!i("addRowAbove")&&(0,v.jsx)(n.f$3,{action:function(){s.chain().focus().addRowBefore().run()},disabled:!s?.can().addRowBefore?.(),icon:"BetweenVerticalEnd",tooltip:t("editor.table.menu.insertRowAbove"),tooltipOptions:{sideOffset:15}}),!i("addRowBelow")&&(0,v.jsx)(n.f$3,{action:function(){s.chain().focus().addRowAfter().run()},disabled:!s?.can()?.addRowAfter?.(),icon:"BetweenVerticalStart",tooltip:t("editor.table.menu.insertRowBelow"),tooltipOptions:{sideOffset:15}}),!i("deleteRow")&&(0,v.jsx)(n.f$3,{action:function(){s.chain().focus().deleteRow().run()},disabled:!s?.can()?.deleteRow?.(),icon:"DeleteRow",tooltip:t("editor.table.menu.deleteRow"),tooltipOptions:{sideOffset:15}}),(0,v.jsx)(n.k$1,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!i("mergeCells")&&(0,v.jsx)(n.f$3,{action:function(){s.chain().focus().mergeCells().run()},disabled:!s?.can()?.mergeCells?.(),icon:"TableCellsMerge",tooltip:t("editor.table.menu.mergeCells"),tooltipOptions:{sideOffset:15}}),!i("splitCells")&&(0,v.jsx)(n.f$3,{action:function(){s?.chain().focus().splitCell().run()},disabled:!s?.can()?.splitCell?.(),icon:"TableCellsSplit",tooltip:t("editor.table.menu.splitCells"),tooltipOptions:{sideOffset:15}}),(0,v.jsx)(n.k$1,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!i("deleteTable")&&(0,v.jsx)(n.f$3,{action:function(){s.chain().focus().deleteTable().run()},disabled:!s?.can()?.deleteTable?.(),icon:"Trash2",tooltip:t("editor.table.menu.deleteTable"),tooltipOptions:{sideOffset:15}})]})}):(0,v.jsx)(v.Fragment,{})}function nh(){const{t:e}=n._(),[t,r]=(0,x.useState)(!1),s=n.f$2(),i=(0,x.useMemo)(()=>n.a({t:e})?.[0]?.commands,[e]),o=(0,x.useMemo)(()=>i?.find(e=>e?.isActive?.(s))?.label,[s.state.selection.ranges,t,s,i,e]),l=(0,x.useMemo)(()=>i?.find(e=>e?.isActive?.(s)),[s.state.selection.ranges,t,s,i]);return(0,v.jsxs)(n.i$2,{modal:!0,onOpenChange:r,open:t,children:[(0,v.jsx)(n.o$1,{asChild:!0,className:"hover:richtext-bg-accent data-[state=on]:richtext-bg-accent",children:(0,v.jsx)(n.f$3,{dataState:!!o,tooltip:o||e("editor.paragraph.tooltip"),children:(0,v.jsx)(n.c,{name:l?.iconName||"Type"})})}),(0,v.jsx)(n.s$3,{align:"start",className:"!richtext-w-[initial] !richtext-p-[4px]",hideWhenDetached:!0,side:"bottom",children:i?.map(t=>{const i=t?.isActive?.(s);return(0,v.jsxs)("div",{className:"richtext-flex richtext-w-full richtext-items-center richtext-gap-1.5 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",onClick:e=>{e.preventDefault(),t.action({editor:s,range:s.state.selection.ranges}),r(!1)},children:[(0,v.jsxs)("div",{className:"!richtext-min-w-[16px]",children:[i&&(0,v.jsx)(w.Check,{size:16}),!o&&t.label===e("editor.paragraph.tooltip")&&!i&&(0,v.jsx)(w.Check,{size:16})]}),(0,v.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-1",children:[t.iconName&&(0,v.jsx)(n.c,{className:"!richtext-mr-1 !richtext-text-lg",name:t.iconName}),t.label]})]},t.name)})})]})}function rh(){return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(nh,{}),(0,v.jsx)(n.k$1,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,v.jsx)(n.h$4,{}),(0,v.jsx)(n.y$1,{}),(0,v.jsx)(n.d$1,{}),(0,v.jsx)(n.m$1,{}),(0,v.jsx)(n.Be,{}),(0,v.jsx)(n.k$1,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,v.jsx)(n.h$3,{}),(0,v.jsx)(n.M$1,{}),(0,v.jsx)(n.A$1,{})]})}function sh({buttonBubble:e}){const t=n.f$2();return n.l$2()?(0,v.jsx)(S.BubbleMenu,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleText",shouldShow:({editor:e})=>{const{selection:t}=e.view.state,{$from:n,to:r}=t;return!e.isActive("codeBlock")&&n.pos!==r&&t instanceof y.TextSelection},children:e?(0,v.jsx)(v.Fragment,{children:e}):(0,v.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,v.jsx)(rh,{})})}):(0,v.jsx)(v.Fragment,{})}function ih(){const{t:e}=n._(),t=n.l$2(),r=n.f$2(),[s,i]=(0,x.useState)(!1),o=(0,x.useCallback)(({editor:e})=>e.isActive(n.k.name),[]),l=(0,x.useCallback)(()=>Ed(n.k.name,r),[r]);return t?(0,v.jsx)(S.BubbleMenu,{editor:r,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleTwitter",shouldShow:o,children:(0,v.jsx)(v.Fragment,{children:s?(0,v.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-4 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,v.jsx)(n.T$1,{editor:r,onSetLink:e=>{r.commands.updateTweet({src:e}),i(!1)}})}):(0,v.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,v.jsx)(n.f$3,{icon:"Pencil",tooltip:e("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{i(!0)}}),(0,v.jsx)(n.f$3,{action:l,icon:"Trash",tooltip:e("editor.delete"),tooltipOptions:{sideOffset:15}})]})})}):(0,v.jsx)(v.Fragment,{})}function oh(e){if(!e.length)return j.DecorationSet.empty;const t=[],n=e[0].$from.node(0);return e.forEach(e=>{const n=e.$from.pos,r=e.$from.nodeAfter;r&&t.push(j.Decoration.node(n,n+r.nodeSize,{class:"ProseMirror-selectednoderange"}))}),j.DecorationSet.create(n,t)}function lh(e,t,n,r={}){const s=[],i=e.node(0),{extendOnBoundaryOverlap:o=!0}=r;"number"==typeof n&&n>=0||(n=e.sameParent(t)?Math.max(0,e.sharedDepth(t.pos)-1):e.sharedDepth(t.pos));const l=new C.NodeRange(e,t,n),a=0===l.depth?0:i.resolve(l.start).posAtIndex(0);return l.parent.forEach((n,r)=>{const c=a+r,d=c+n.nodeSize,h=function(e,t,n){const r=n.isText||n.isAtom?0:1;return{start:e+r,end:e+t-r}}(c,n.nodeSize,n),u=o?t.pos>=h.start&&e.pos<=h.end:t.pos>h.start&&e.pos<h.end;if(c<l.start||c>=l.end)return;if(!u)return;const p=new y.SelectionRange(i.resolve(c),i.resolve(d));s.push(p)}),s}var ah=class e{constructor(e,t,n){this.anchor=e,this.head=t,this.depth=null!=n?n:0}map(t){return new e(t.map(this.anchor),t.map(this.head),this.depth)}resolve(e){return new ch(e.resolve(this.anchor),e.resolve(this.head),this.depth)}},ch=class e extends y.Selection{constructor(e,t,n,r=1){const{doc:s}=e,i=e===t,o=e.pos===s.content.size&&t.pos===s.content.size,l=i&&!o?s.resolve(t.pos+(r>0?1:-1)):t,a=i&&o?s.resolve(e.pos-(r>0?1:-1)):e,c=lh(a.min(l),a.max(l),n);super(l.pos>=e.pos?c[0].$from:c[c.length-1].$to,l.pos>=e.pos?c[c.length-1].$to:c[0].$from,c),this.depth=n}get $to(){return this.ranges[this.ranges.length-1].$to}eq(t){return t instanceof e&&t.$from.pos===this.$from.pos&&t.$to.pos===this.$to.pos}map(t,n){const r=t.resolve(n.map(this.anchor)),s=t.resolve(n.map(this.head));return new e(r,s,this.depth)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head,depth:this.depth}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:t}=this.$from;if(this.isForwards&&this.ranges.length>1){const t=this.ranges.slice(0,-1),n=t[0].$from,r=t[t.length-1].$to;return new e(n,r,this.depth)}const n=this.ranges[0],r=t.resolve(Math.max(0,n.$from.pos-1));return new e(this.$anchor,r,this.depth)}extendForwards(){const{doc:t}=this.$from;if(this.isBackwards&&this.ranges.length>1){const t=this.ranges.slice(1),n=t[0].$from,r=t[t.length-1].$to;return new e(r,n,this.depth)}const n=this.ranges[this.ranges.length-1],r=t.resolve(Math.min(t.content.size,n.$to.pos+1));return new e(this.$anchor,r,this.depth)}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head),n.depth)}static create(e,t,n,r,s=1){return new this(e.resolve(t),e.resolve(n),r,s)}getBookmark(){return new ah(this.anchor,this.head,this.depth)}};ch.prototype.visible=!1;try{y.Selection.jsonID("nodeRange",ch)}catch{}function dh(e){return e instanceof ch}b.Extension.create({name:"nodeRange",addOptions:()=>({depth:void 0,key:"Mod"}),addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:e})=>{const{depth:t}=this.options,{view:n,state:r}=e,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!dh(i)){const e=ch.create(s,l,a,t,-1);return o.setSelection(e),n.dispatch(o),!0}const c=i.extendBackwards();return o.setSelection(c),n.dispatch(o),!0},"Shift-ArrowDown":({editor:e})=>{const{depth:t}=this.options,{view:n,state:r}=e,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!dh(i)){const e=ch.create(s,l,a,t);return o.setSelection(e),n.dispatch(o),!0}const c=i.extendForwards();return o.setSelection(c),n.dispatch(o),!0},"Mod-a":({editor:e})=>{const{depth:t}=this.options,{view:n,state:r}=e,{doc:s,tr:i}=r,o=ch.create(s,0,s.content.size,t);return i.setSelection(o),n.dispatch(i),!0}}},onSelectionUpdate(){const{selection:e}=this.editor.state;dh(e)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let e=!1,t=!1;return[new y.Plugin({key:new y.PluginKey("nodeRange"),props:{attributes:()=>e?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(e,n)=>{const{key:r}=this.options,s=/Mac/.test(navigator.platform),i=!!n.shiftKey,o=!!n.ctrlKey,l=!!n.altKey,a=!!n.metaKey;return(null==r||"Shift"===r&&i||"Control"===r&&o||"Alt"===r&&l||"Meta"===r&&a||"Mod"===r&&(s?a:o))&&(t=!0),!!t&&(document.addEventListener("mouseup",()=>{t=!1;const{state:n}=e,{doc:r,selection:s,tr:i}=n,{$anchor:o,$head:l}=s;if(o.sameParent(l))return;const a=ch.create(r,o.pos,l.pos,this.options.depth);i.setSelection(a),e.dispatch(i)},{once:!0}),!1)}},decorations:n=>{const{selection:r}=n,s=dh(r);if(e=!1,!t)return s?(e=!0,oh(r.ranges)):null;const{$from:i,$to:o}=r;if(!s&&i.sameParent(o))return null;const l=lh(i,o,this.options.depth);return l.length?(e=!0,oh(l)):null}}})]}});var hh=[{id:"listItemFirstChild",evaluate:({parent:e,isFirst:t})=>t&&e&&["listItem","taskItem"].includes(e.type.name)?1e3:0},{id:"listWrapperDeprioritize",evaluate:({node:e})=>{const t=e.firstChild;return t&&["listItem","taskItem"].includes(t.type.name)?1e3:0}},{id:"tableStructure",evaluate:({node:e,parent:t})=>["tableRow","tableCell","tableHeader"].includes(e.type.name)||t&&"tableHeader"===t.type.name?1e3:0},{id:"inlineContent",evaluate:({node:e})=>e.isInline||e.isText?1e3:0}],uh={edges:["left","top"],threshold:12,strength:500};function ph(e){return void 0===e||"left"===e?{...uh}:"right"===e?{edges:["right","top"],threshold:12,strength:500}:"both"===e?{edges:["left","right","top"],threshold:12,strength:500}:"none"===e?{edges:[],threshold:0,strength:0}:{...uh,...e}}function fh(e,t,n,r){let s=1e3,i=!1;if(t.every(t=>{const n=t.evaluate(e);return s-=n,!(s<=0&&(i=!0,1))}),i)return-1;const o=e.view.nodeDOM(e.pos);return s-=function(e,t,n,r){return t&&0!==n.edges.length&&function(e,t,n){if(0===n.edges.length)return!1;const r=t.getBoundingClientRect(),{threshold:s,edges:i}=n;return i.some(t=>"left"===t?e.x-r.left<s:"right"===t?r.right-e.x<s:"top"===t?e.y-r.top<s:"bottom"===t&&r.bottom-e.y<s)}(e,t,n)?n.strength*r:0}(r,o,n,e.depth),s<=0?-1:s}function gh(e,t,n){return Array.from({length:t},(e,n)=>t-1-n).some(t=>n.includes(e.node(t).type.name))}function mh(e){return Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&e.width>0&&e.height>0}function xh(e,t){let n="first"===t?e.firstElementChild:e.lastElementChild;for(;n;){const e=n.getBoundingClientRect();if(mh(e))return e;n="first"===t?n.nextElementSibling:n.previousElementSibling}return null}var bh=e=>{const{x:t,y:n,editor:r,nestedOptions:s}=e,{view:i,state:o}=r,l=function(e,t,n,r=5){if(!Number.isFinite(t)||!Number.isFinite(n))return null;const s=e.dom,i=xh(s,"first"),o=xh(s,"last");if(!i||!o)return null;const l=Math.min(Math.max(i.top+r,n),o.bottom-r),a=Math.abs(i.left-o.left)<.5,c=Math.abs(i.right-o.right)<.5;let d=i;a&&c&&(d=i);const h=Math.min(Math.max(d.left+r,t),d.right-r);return Number.isFinite(h)&&Number.isFinite(l)?{x:h,y:l}:null}(i,t,n,5);if(!l)return{resultElement:null,resultNode:null,pos:null};const{x:a,y:c}=l;if(null==s?void 0:s.enabled){const e=function(e,t,n){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))return null;const r=e.posAtCoords({left:t.x,top:t.y});if(!r)return null;const{doc:s}=e.state,i=s.resolve(r.pos),o=[];n.defaultRules&&o.push(...hh),o.push(...n.rules);const l=Array.from({length:i.depth},(e,t)=>i.depth-t).map(r=>{const s=i.node(r),l=i.before(r);if(n.allowedContainers&&r>0&&!gh(i,r,n.allowedContainers))return null;const a=r>0?i.node(r-1):null,c=r>0?i.index(r-1):0,d=fh({node:s,pos:l,depth:r,parent:a,index:c,isFirst:0===c,isLast:c===(a?a.childCount:1)-1,$pos:i,view:e},o,n.edgeDetection,t);return d<0?null:{node:s,pos:l,depth:r,score:d,dom:e.nodeDOM(l)}}).filter(e=>null!==e),a=i.nodeAfter;if(a&&a.isAtom&&!a.isInline){const s=r.pos,c=i.depth+1,d=i.parent,h=i.index(),u=d.childCount;let p=!0;if(n.allowedContainers&&(p=gh(i,c,n.allowedContainers)),p){const r=fh({node:a,pos:s,depth:c,parent:d,index:h,isFirst:0===h,isLast:h===u-1,$pos:i,view:e},o,n.edgeDetection,t);if(r>=0){const t=e.nodeDOM(s);t&&l.push({node:a,pos:s,depth:c,score:r,dom:t})}}}if(0===l.length)return null;l.sort((e,t)=>t.score!==e.score?t.score-e.score:t.depth-e.depth);const c=l[0];return c.dom?{node:c.node,pos:c.pos,dom:c.dom}:null}(i,{x:a,y:c},s);return e?{resultElement:e.dom,resultNode:e.node,pos:e.pos}:{resultElement:null,resultNode:null,pos:null}}const d=i.root.elementsFromPoint(a,c);let h,u;if(Array.prototype.some.call(d,e=>{if(!i.dom.contains(e))return!1;const t=function(e,t){var n;let r=e;for(;(null==r?void 0:r.parentElement)&&r.parentElement!==t.dom;)r=r.parentElement;if((null==r?void 0:r.parentElement)===t.dom&&(null==(n=r.pmViewDesc)?void 0:n.node))return r}(e,i);return!!t&&(h=t,!0)}),!h){const e=i.posAtCoords({left:a,top:c});if(e){const t=o.doc.resolve(e.pos),n=Math.min(t.depth,1),r=n>0?t.before(n):t.pos,s=o.doc.nodeAt(r);if(s){const e=i.nodeDOM(r);return{resultElement:e instanceof HTMLElement?e:null,resultNode:s,pos:r}}}return{resultElement:null,resultNode:null,pos:null}}try{u=i.posAtDOM(h,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const p=o.doc.nodeAt(u);if(!p){const e=o.doc.resolve(u),t=e.parent;return{resultElement:h,resultNode:t,pos:e.start()}}return{resultElement:h,resultNode:p,pos:u}};function yh(e,t){const n=e.nodeDOM(t);if(n instanceof Element&&n!==e.dom)return n;const{node:r,offset:s}=e.domAtPos(t),i=r.childNodes[s];return i instanceof Element?i:r instanceof Element?r:r.nodeType===Node.TEXT_NODE&&r.parentElement?r.parentElement:null}function vh(e){var t;null==(t=e.parentNode)||t.removeChild(e)}function wh(e,t,n,r,s){const{view:i}=t;if(!e.dataTransfer)return;const{empty:o,$from:l,$to:a}=i.state.selection,c=function(e,t,n,r){const{doc:s}=t.view.state;if((null==n?void 0:n.enabled)&&(null==r?void 0:r.node)&&r.pos>=0){const e=r.pos,t=r.pos+r.node.nodeSize;return[{$from:s.resolve(e),$to:s.resolve(t)}]}const i=bh({editor:t,x:e.clientX,y:e.clientY,direction:"right",nestedOptions:n});if(!i.resultNode||null===i.pos)return[];const o=i.resultNode.isText||i.resultNode.isAtom?0:-1;return lh(s.resolve(i.pos),s.resolve(i.pos+i.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}(e,t,n,r),d=lh(l,a,0,{extendOnBoundaryOverlap:!1}),h=d.some(e=>c.find(t=>t.$from===e.$from&&t.$to===e.$to)),u=o||!h?c:d;if(!u.length)return;const{tr:p}=i.state,f=document.createElement("div"),g=u[0].$from.pos,m=u[u.length-1].$to.pos,x=function(e,t){const n=yh(e,t);return(n?getComputedStyle(n).direction:getComputedStyle(e.dom).direction)||"ltr"}(i,g);f.setAttribute("dir",x);const b=(null==n?void 0:n.enabled)&&(null==r?void 0:r.node),v=1===u.length;let w,k;b&&v?(w=i.state.doc.slice(g,m),k=y.NodeSelection.create(i.state.doc,g)):(k=ch.create(i.state.doc,g,m),w=k.content());const S=function(e){return!e||!e.some(e=>{const t=e.trim().toLowerCase();return"margin"===t||t.startsWith("margin-")})}(s);u.forEach(e=>{const t=yh(i,e.$from.pos);if(!t)return;const n=function(e,t){const n=e.cloneNode(!0),r=[e,...Array.from(e.getElementsByTagName("*"))],s=[n,...Array.from(n.getElementsByTagName("*"))];return r.forEach((e,n)=>{s[n].style.cssText=function(e,t){const n=getComputedStyle(e);if(t)return t.map(e=>e.trim()).filter(e=>e.length>0).map(e=>`${e}:${n.getPropertyValue(e)};`).join("");let r="";for(let s=0;s<n.length;s+=1)r+=`${n[s]}:${n.getPropertyValue(n[s])};`;return r}(e,t)}),n}(t,s);S&&(n.style.margin="0"),f.append(n)}),f.style.position="absolute",f.style.top="-10000px",document.body.append(f),e.dataTransfer.clearData();const j=function(e,t){return"rtl"===e?t:0}(x,f.getBoundingClientRect().width);e.dataTransfer.setDragImage(f,j,0);let C=!1;const N=()=>{C||(C=!0,vh(f),document.removeEventListener("drop",N),document.removeEventListener("dragend",N))},E=k instanceof y.NodeSelection?k:void 0;i.dragging={slice:w,move:!0,node:E},p.setSelection(k),i.dispatch(p),document.addEventListener("drop",N),document.addEventListener("dragend",N)}var kh=(e,t)=>{const n=e.resolve(t),{depth:r}=n;return 0===r?t:n.pos-n.parentOffset-1},Sh=(e,t)=>{const n=e.nodeAt(t),r=e.resolve(t);let{depth:s}=r,i=n;for(;s>0;){const e=r.node(s);s-=1,0===s&&(i=e)}return i};function jh(e,t,n){let r=0;for(let s=t;s<n;s+=1)r+=e.child(s).nodeSize;return r}var Ch=(e,t)=>{const n=zc.getState(e);return n?md(t,n.type,n.binding.mapping):null},Nh=(e,t)=>{const n=zc.getState(e);return n?bd(n.doc,n.type,t,n.binding.mapping)||0:-1},Eh=(e,t)=>{let n=t;for(;(null==n?void 0:n.parentNode)&&n.parentNode!==e.dom;)n=n.parentNode;return n},Ah=new y.PluginKey("dragHandle"),_h=({pluginKey:e=Ah,element:t,editor:r,computePositionConfig:s,getReferencedVirtualElement:i,onNodeChange:o,onElementDragStart:l,onElementDragEnd:a,nestedOptions:c,dragImageProperties:d})=>{const h=document.createElement("div");let u,p=!1,f=null,g=-1,m=null,x=null,v=null,w=null;function k(){v=null,w=null}function S(){t&&(t.style.visibility="hidden",t.style.pointerEvents="none")}function j(e){const r=(null==i?void 0:i())||{getBoundingClientRect:()=>e.getBoundingClientRect()};n.xt(r,t,s).then(e=>{Object.assign(t.style,{position:e.strategy,left:`${e.x}px`,top:`${e.y}px`})})}function C(e){var n,s;l?.(e),wh(e,r,c,{node:f,pos:g},d),n=r.state.selection,v=dh(n)?{anchorPos:n.from,nodeCount:n.ranges.length,depth:null!=(s=n.depth)?s:0}:null,t&&(t.dataset.dragging="true"),setTimeout(()=>{t&&(t.style.pointerEvents="none")},0)}function N(e){a?.(e),v=null,S(),t&&(t.style.pointerEvents="auto",t.dataset.dragging="false")}function E(e){if(!e.target||!r.view.dom.contains(e.target))return;if((0,b.isFirefox)()){const e=r.view.dom;requestAnimationFrame(()=>{e.isContentEditable&&(e.contentEditable="false",e.contentEditable="true")})}if(!v||r.view.state.selection.empty)return;const t=r.state.selection.from,n=Ch(r.state,t);w={...v,anchorPos:t,relativeAnchorPos:null!=n?n:void 0},r.view.dispatch(r.state.tr.setMeta("addToHistory",!1))}function A(){t.removeEventListener("dragstart",C),t.removeEventListener("dragend",N),document.removeEventListener("drop",E),m&&(cancelAnimationFrame(m),m=null,x=null),k()}return h.appendChild(t),{unbind(){A()},plugin:new y.Plugin({key:"string"==typeof e?new y.PluginKey(e):e,state:{init:()=>({locked:!1}),apply(e,n,s,i){!function(e,t){w&&(w=function(e,t,n){if(!t.docChanged)return e;if(n.isChangeOrigin&&null!=e.relativeAnchorPos){const t=n.getAbsolutePos(e.relativeAnchorPos);return!Number.isFinite(t)||t<=0?null:{...e,anchorPos:t}}const r=t.mapping.mapResult(e.anchorPos,1);return r.deleted?null:{...e,anchorPos:r.pos}}(w,e,{isChangeOrigin:Sd(e),getAbsolutePos:e=>Nh(t,e)}))}(e,i);const l=e.getMeta("lockDragHandle"),a=e.getMeta("hideDragHandle");if(void 0!==l&&(p=l),a)return S(),p=!1,f=null,g=-1,o?.({editor:r,node:null,pos:-1}),n;if(e.docChanged&&-1!==g&&t)if(Sd(e)){const e=Nh(i,u);e!==g&&(g=e)}else{const t=e.mapping.map(g);t!==g&&(g=t,u=Ch(i,g))}return n}},appendTransaction:(e,t,n)=>function(e){if(!w)return null;const t=function(e,t,n,r){try{const s=function(e,t,n,r){const s=e.resolve(t),i=s.node(r);let o=s.index(r);o>=i.childCount&&(o=Math.max(0,i.childCount-n));const l=Math.min(n,i.childCount-o);if(l<=0)return null;const a=s.start(r)+jh(i,0,o);return{anchor:a,head:a+jh(i,o,o+l),count:l}}(e,t,n,r);if(!s)return null;const i=ch.create(e,s.anchor,s.head,r);return i.ranges.length===n?i:null}catch{return null}}(e.doc,w.anchorPos,w.nodeCount,w.depth);return t?(k(),e.tr.setSelection(t)):(w=null,v=null,null)}(n),view:e=>{var n;return t.draggable=!0,t.style.pointerEvents="auto",t.dataset.dragging="false",null==(n=r.view.dom.parentElement)||n.appendChild(h),h.style.pointerEvents="none",h.style.position="absolute",h.style.top="0",h.style.left="0",h.style.zIndex="10",t.addEventListener("dragstart",C),t.addEventListener("dragend",N),document.addEventListener("drop",E),{update(n,s){if(!t)return;if(!r.isEditable)return void S();if(t.draggable=!p,e.state.doc.eq(s.doc)||-1===g)return;let i=e.nodeDOM(g);if(i=Eh(e,i),i===e.dom)return;if(1!==(null==i?void 0:i.nodeType))return;const l=e.posAtDOM(i,0),a=Sh(r.state.doc,l),c=kh(r.state.doc,l);f=a,g=c,u=Ch(e.state,g),o?.({editor:r,node:f,pos:g}),j(i)},destroy(){A(),t&&vh(h)}}},props:{handleDOMEvents:{keydown:e=>!(!t||p||!e.hasFocus()||(S(),f=null,g=-1,o?.({editor:r,node:null,pos:-1}),1)),mouseleave:(e,t)=>(p||t.target&&!h.contains(t.relatedTarget)&&(S(),f=null,g=-1,o?.({editor:r,node:null,pos:-1})),!1),mousemove:(e,n)=>!(!t||p||(x={x:n.clientX,y:n.clientY},m||(m=requestAnimationFrame(()=>{if(m=null,!x)return;const{x:n,y:s}=x;x=null;const i=bh({x:n,y:s,direction:"right",editor:r,nestedOptions:c});if(!i.resultElement)return;let l=i.resultElement,a=i.resultNode,d=i.pos;if(!(null==c?void 0:c.enabled)){if(l=Eh(e,l),l===e.dom)return;if(1!==(null==l?void 0:l.nodeType))return;const t=e.posAtDOM(l,0);a=Sh(r.state.doc,t),d=kh(r.state.doc,t)}a!==f&&(f=a,g=null!=d?d:-1,u=Ch(e.state,g),o?.({editor:r,node:f,pos:g}),j(l),t&&(r.isEditable?(t.style.visibility="",t.style.pointerEvents="auto"):S()))})),1))}}})}};function Th(e){var t,n;return!1===e||void 0===e?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:ph("none")}:!0===e?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:ph("left")}:{enabled:!0,rules:null!=(t=e.rules)?t:[],defaultRules:null==(n=e.defaultRules)||n,allowedContainers:e.allowedContainers,edgeDetection:ph(e.edgeDetection)}}var Mh={placement:"left-start",strategy:"absolute"},Dh=(b.Extension.create({name:"dragHandle",addOptions:()=>({render(){const e=document.createElement("div");return e.classList.add("drag-handle"),e},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1,dragImageProperties:void 0}),addCommands(){return{lockDragHandle:()=>({editor:e})=>(this.options.locked=!0,e.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:e})=>(this.options.locked=!1,e.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:e})=>(this.options.locked=!this.options.locked,e.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const e=this.options.render(),t=Th(this.options.nested);return[_h({computePositionConfig:{...Mh,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:e,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:t,dragImageProperties:this.options.dragImageProperties}).plugin]}}),e=>{const{className:t="drag-handle",children:n,editor:r,pluginKey:s=Ah,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l,getReferencedVirtualElement:a,computePositionConfig:c=Mh,nested:d=!1}=e,h=(0,x.useRef)(null);null===h.current&&"undefined"!=typeof document&&(h.current=document.createElement("div"));const u=(0,x.useMemo)(()=>Th(d),[JSON.stringify(d)]);(0,x.useEffect)(()=>{const e=h.current;e&&(e.className=t)},[t]),(0,x.useEffect)(()=>{if("undefined"==typeof document)return;if(r.isDestroyed)return;const e=h.current;if(!e)return;e.style.visibility="hidden",e.style.position="absolute",e.dataset.dragging="false";const{plugin:t,unbind:n}=_h({editor:r,element:e,pluginKey:s,computePositionConfig:{...Mh,...c},onElementDragStart:o,onElementDragEnd:l,onNodeChange:i,getReferencedVirtualElement:a,nestedOptions:u});return r.registerPlugin(t),()=>{r.isDestroyed||r.unregisterPlugin(s),n()}},[r,i,a,s,c,o,l,u]);const p=h.current;return p?(0,k.createPortal)(n,p):null});function Oh(){const e=n.f$2(),t=n.l$2(),{t:r}=n._(),[s,i]=(0,x.useState)(null),[o,l]=(0,x.useState)(-1),[a,c]=(0,x.useState)(!1),d=e?.extensionManager?.extensions?.some(e=>e?.name===n.y.name),h=e?.extensionManager?.extensions?.some(e=>e?.name===n.h$2.name),u=e?.extensionManager?.extensions?.some(e=>e?.name===n.c$1.name);function p(t){e.commands.setTextAlign(t)}const f=(0,x.useCallback)(e=>{e.node&&i(e.node),l(e.pos),requestAnimationFrame(()=>{e.editor.commands.focus()})},[]);(0,x.useEffect)(()=>(a?e.commands.setMeta("lockDragHandle",!0):e.commands.setMeta("lockDragHandle",!1),()=>{e.commands.setMeta("lockDragHandle",!1)}),[a]);const g=e=>{t&&c(e)};return(0,v.jsx)(Dh,{className:"richtext-transition-all richtext-duration-200 richtext-ease-out",editor:e,onNodeChange:f,pluginKey:"RichTextBubbleMenuDragHandle",children:(0,v.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-0.5",children:[(0,v.jsx)(n.f$3,{disabled:!t,icon:"Grip",tooltip:r("editor.draghandle.grip"),action:e=>{e.preventDefault(),e.stopPropagation(),g(!a)}}),(0,v.jsxs)(n.d$2,{onOpenChange:g,open:a,children:[(0,v.jsx)(n.x,{className:"richtext-pointer-events-none"}),(0,v.jsxs)(n.u$2,{align:"start",className:"richtext-w-48",hideWhenDetached:!0,side:"bottom",sideOffset:0,children:[(0,v.jsxs)(n.b$1,{className:"richtext-flex richtext-gap-3 richtext-bg-opacity-10 hover:richtext-bg-red-400 hover:richtext-bg-opacity-20 focus:richtext-bg-red-400 focus:richtext-bg-opacity-30 focus:richtext-text-red-500 dark:hover:richtext-bg-opacity-20 dark:hover:richtext-text-red-500",onClick:function(){e.chain().setMeta("hideDragHandle",!0).setNodeSelection(o).deleteSelection().run()},children:[(0,v.jsx)(n.c,{name:"Trash2"}),(0,v.jsx)("span",{children:r("editor.remove")})]}),u?(0,v.jsxs)(n.b$1,{className:"richtext-flex richtext-gap-3",onClick:function(){const t=e.chain();t.setNodeSelection(o).unsetAllMarks(),"paragraph"!==s?.type.name&&t.setParagraph(),t.run()},children:[(0,v.jsx)(n.c,{name:"PaintRoller"}),(0,v.jsx)("span",{children:r("editor.clear.tooltip")})]}):null,(0,v.jsxs)(n.b$1,{className:"richtext-flex richtext-gap-3",onClick:function(){e.commands.setNodeSelection(o);const{$anchor:t}=e.state.selection,n=t.node(1)||e.state.selection.node;e.chain().setMeta("hideDragHandle",!0).insertContentAt(o+(s?.nodeSize||0),n.toJSON()).run()},children:[(0,v.jsx)(n.c,{name:"Copy"}),(0,v.jsx)("span",{children:r("editor.copy")})]}),d||h?(0,v.jsx)(n.v,{}):null,d?(0,v.jsxs)(n.l$1,{children:[(0,v.jsxs)(n.p$2,{className:"richtext-flex richtext-gap-3",children:[(0,v.jsx)(n.c,{name:"AlignCenter"}),(0,v.jsx)("span",{children:r("editor.textalign.tooltip")})]}),(0,v.jsx)(n.n$5,{children:(0,v.jsxs)(n.f$1,{children:[(0,v.jsxs)(n.b$1,{className:"richtext-flex richtext-gap-3",onClick:()=>p("left"),children:[(0,v.jsx)(n.c,{name:"AlignLeft"}),(0,v.jsx)("span",{children:r("editor.textalign.left.tooltip")})]}),(0,v.jsxs)(n.b$1,{className:"richtext-flex richtext-gap-3",onClick:()=>p("center"),children:[(0,v.jsx)(n.c,{name:"AlignCenter"}),(0,v.jsx)("span",{children:r("editor.textalign.center.tooltip")})]}),(0,v.jsxs)(n.b$1,{className:"richtext-flex richtext-gap-3",onClick:()=>p("right"),children:[(0,v.jsx)(n.c,{name:"AlignRight"}),(0,v.jsx)("span",{children:r("editor.textalign.right.tooltip")})]})]})})]}):null,h?(0,v.jsxs)(n.l$1,{children:[(0,v.jsxs)(n.p$2,{className:"richtext-flex richtext-gap-3",children:[(0,v.jsx)(n.c,{name:"IndentIncrease"}),(0,v.jsx)("span",{children:r("editor.indent")})]}),(0,v.jsx)(n.n$5,{children:(0,v.jsxs)(n.f$1,{children:[(0,v.jsxs)(n.b$1,{className:"richtext-flex richtext-gap-3",disabled:s?.attrs?.indent>=n.u.max,onClick:function(){const t=n.p(e.state.tr,o,1);t.setMeta("hideDragHandle",!0),e.view.dispatch&&e.view.dispatch(t)},children:[(0,v.jsx)(n.c,{name:"IndentIncrease"}),(0,v.jsx)("span",{children:r("editor.indent.tooltip")})]}),(0,v.jsxs)(n.b$1,{className:"richtext-flex richtext-gap-3",disabled:s?.attrs?.indent<=n.u.min,onClick:function(){const t=n.p(e.state.tr,o,-1);e.view.dispatch&&e.view.dispatch(t)},children:[(0,v.jsx)(n.c,{name:"IndentDecrease"}),(0,v.jsx)("span",{children:r("editor.outdent.tooltip")})]})]})})]}):null]})]})]})})}var $h={plaintext:"Plain Text",js:"JavaScript",ts:"TypeScript",css:"CSS",html:"HTML",python:"Python",bash:"Bash"};function Rh({listLanguages:e}){const{t:t}=n._(),[r,s]=(0,x.useState)(!1),i=n.f$2(),o=(0,x.useMemo)(()=>{const{selection:e}=i.state,t=e.$from.parent;if("codeBlock"===t.type.name){const e=t.attrs.language||"plaintext";return $h[e]||e}},[i.state,e]),l=(0,x.useMemo)(()=>{let t=e||[];return e?.includes("plaintext")||(t=["plaintext",...t]),t.map(e=>({label:$h[e]||e,value:e}))},[e]);return(0,v.jsxs)(n.i$2,{modal:!0,onOpenChange:s,open:r,children:[(0,v.jsx)(n.o$1,{asChild:!0,className:"hover:richtext-bg-accent data-[state=on]:richtext-bg-accent",children:(0,v.jsxs)(n.f$3,{dataState:!!o,children:[(0,v.jsx)(v.Fragment,o?{children:o}:{children:t("editor.paragraph.tooltip")}),(0,v.jsx)(n.c,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})]})}),(0,v.jsx)(n.s$3,{align:"start",className:"!richtext-w-[initial] !richtext-p-[4px]",hideWhenDetached:!0,side:"bottom",children:l?.map(e=>(0,v.jsxs)("div",{className:"richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",onClick:t=>{t.preventDefault(),i.chain().focus().setCodeBlock({language:e.value}).run(),s(!1)},children:[(0,v.jsx)("div",{className:"!richtext-min-w-[20px]",children:o===e.value&&(0,v.jsx)(w.Check,{size:16})}),(0,v.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-1",children:e.label})]},e.value))})]})}function Ih(){const e=n.l$2(),t=n.f$2(),r=n.y$3(n.M$2.name),s=(0,x.useCallback)(({editor:e})=>e.isActive(n.M$2.name),[]),i=(0,x.useMemo)(()=>r?r.options?.lowlight?.listLanguages?.()||["plaintext","html","css","js","ts"]:[],[r]),o=(0,x.useCallback)(()=>Ed(n.M$2.name,t),[t]);return e?(0,v.jsx)(S.BubbleMenu,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleCodeBlock",shouldShow:s,getReferencedVirtualElement:()=>{const{from:e}=t.state.selection,n=t.view.domAtPos(e).node.parentElement;return n?{getBoundingClientRect:()=>n.getBoundingClientRect()}:null},children:(0,v.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,v.jsx)(Rh,{listLanguages:i}),(0,v.jsx)(n.k$1,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,v.jsx)(n.f$3,{action:()=>{const e=(()=>{const{from:e}=t.state.selection,n=t.state.doc.resolve(e);for(let t=n.depth;t>=0;t--){const e=n.node(t);if("codeBlock"===e.type.name)return e.textContent}return""})();navigator.clipboard.writeText(e)},tooltip:"Copy",children:(0,v.jsx)(w.Copy,{size:16})}),(0,v.jsx)(n.k$1,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,v.jsx)(n.f$3,{action:o,tooltip:"Delete",children:(0,v.jsx)(w.Trash2,{size:16})})]})}):(0,v.jsx)(v.Fragment,{})}var Ph={status:"closed"};function zh({icon:e,label:t,onClick:n,disabled:r}){return(0,v.jsxs)("button",{type:"button",disabled:r,onClick:n,className:"ai-menu-row",children:[(0,v.jsx)(e,{className:"ai-menu-row-icon"}),t]})}function Lh(){const e=o.useEditorInstance(),t=o.useEditableEditor(),n=(0,x.useRef)(null),r=(0,x.useRef)(null),[s,l]=(0,x.useState)(""),[a,c]=(0,x.useState)(null),d=(0,m.useEditorState)({editor:e,selector:({editor:e})=>e?f.getAiState(e.state)?.panel??Ph:Ph}),h=(0,x.useMemo)(()=>"closed"===d.status?null:"reviewing"===d.status?{from:d.suggestion.from,to:d.suggestion.to}:{from:d.from,to:d.to},[d]),u="closed"!==d.status;if((0,x.useEffect)(()=>{if("menu"===d.status){l("");const e=requestAnimationFrame(()=>r.current?.focus());return()=>cancelAnimationFrame(e)}},[d.status]),(0,x.useEffect)(()=>{if(!e||!h||!n.current)return void c(null);const t={getBoundingClientRect:()=>(0,m.posToDOMRect)(e.view,h.from,h.to)},r=()=>{n.current&&i.computePosition(t,n.current,{placement:"bottom-start",strategy:"fixed",middleware:[i.offset(8),i.flip(),i.shift({padding:8})]}).then(({x:e,y:t})=>c({x:e,y:t}))};return r(),window.addEventListener("resize",r),window.addEventListener("scroll",r,!0),()=>{window.removeEventListener("resize",r),window.removeEventListener("scroll",r,!0)}},[e,h?.from,h?.to,d]),(0,x.useEffect)(()=>{if(!u||!e)return;const t=t=>{n.current&&!n.current.contains(t.target)&&e.commands.closeAiMenu()},r=t=>{"Escape"===t.key&&e.commands.closeAiMenu()};return document.addEventListener("mousedown",t),document.addEventListener("keydown",r),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("keydown",r)}},[u,e]),!(t&&e&&u&&a))return null;const p=f.getAiOptions(e)?.commands??[];return(0,k.createPortal)((0,v.jsxs)("div",{ref:n,role:"dialog","aria-label":"Ask AI",className:"ai-menu",style:{position:"fixed",top:a.y,left:a.x,zIndex:60},children:[(0,v.jsxs)("div",{className:"ai-menu-input-row",children:[(0,v.jsx)(w.Sparkles,{className:"ai-menu-input-icon"}),(0,v.jsx)("input",{ref:r,value:s,onChange:e=>l(e.target.value),onKeyDown:t=>{"Enter"===t.key&&(t.preventDefault(),s.trim()&&e.commands.submitAiPrompt(s))},placeholder:"Ask AI anything…",className:"ai-menu-input"})]}),"menu"===d.status&&(0,v.jsx)("div",{className:"ai-menu-commands",children:p.map(t=>(0,v.jsxs)("button",{type:"button",onClick:()=>e.commands.runAiCommand(t.id),className:"ai-menu-command",children:[(0,v.jsx)(t.icon,{className:"ai-menu-row-icon"}),(0,v.jsxs)("span",{className:"ai-menu-command-text",children:[(0,v.jsx)("span",{className:"ai-menu-command-label",children:t.label}),t.description&&(0,v.jsx)("span",{className:"ai-menu-command-description",children:t.description})]})]},t.id))}),"loading"===d.status&&(0,v.jsxs)("div",{className:"ai-menu-loading",children:[(0,v.jsx)(w.Loader2,{className:"ai-menu-row-icon ai-menu-spin"}),"Custom"===d.commandLabel?"Generating…":`${d.commandLabel}…`]}),"error"===d.status&&(0,v.jsxs)("div",{className:"ai-menu-error",children:[(0,v.jsx)("p",{className:"ai-menu-error-message",children:d.message}),(0,v.jsx)(zh,{icon:w.RotateCcw,label:"Try again",onClick:()=>e.commands.retryAiSuggestion()})]}),"reviewing"===d.status&&(0,v.jsxs)("div",{className:"ai-menu-review",children:[(0,v.jsx)(zh,{icon:w.Check,label:"Accept",disabled:d.suggestion.isStreaming,onClick:()=>e.commands.acceptAiSuggestion()}),(0,v.jsx)(zh,{icon:w.X,label:"Discard",onClick:()=>e.commands.discardAiSuggestion()}),(0,v.jsx)(zh,{icon:w.CornerDownRight,label:"Insert below",disabled:d.suggestion.isStreaming,onClick:()=>e.commands.insertAiSuggestionBelow()}),(0,v.jsx)(zh,{icon:w.RotateCcw,label:"Try again",onClick:()=>e.commands.retryAiSuggestion()})]})]}),document.body)}var Bh=()=>(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(_d,{}),(0,v.jsx)(Td,{}),(0,v.jsx)(Vd,{}),(0,v.jsx)(Hd,{}),(0,v.jsx)(qd,{}),(0,v.jsx)(Kd,{}),(0,v.jsx)(Xd,{}),(0,v.jsx)(Gd,{}),(0,v.jsx)(eh,{}),(0,v.jsx)(th,{}),(0,v.jsx)(sh,{}),(0,v.jsx)(ih,{}),(0,v.jsx)(Ih,{}),(0,v.jsx)(Oh,{}),(0,v.jsx)(n.D,{}),(0,v.jsx)(Lh,{})]});Object.defineProperty(exports,"BubbleMenus",{enumerable:!0,get:function(){return Bh}}),Object.defineProperty(exports,"RichTextToolbar",{enumerable:!0,get:function(){return se}});
|