@import-ai/omnibox-editor 0.0.5 → 0.0.6
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/components/tiptap-node/table-node/lib/tiptap-table-utils.d.ts +2 -0
- package/dist/components/tiptap-node/table-node/ui/table-selection-overlay/table-selection-overlay.d.ts +0 -3
- package/dist/omnibox-editor.css +1 -1
- package/dist/omnibox-editor.js +3243 -3209
- package/dist/omnibox-editor.umd.cjs +9 -9
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
(function(B,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react/jsx-runtime"),require("react"),require("@tiptap/react"),require("react-dom"),require("@tiptap/extension-collaboration"),require("@tiptap/extension-collaboration-caret"),require("@tiptap/starter-kit"),require("@tiptap/extension-mention"),require("@tiptap/extension-list"),require("@tiptap/extension-text-style"),require("@tiptap/extensions"),require("@tiptap/extension-typography"),require("@tiptap/extension-highlight"),require("@tiptap/extension-superscript"),require("@tiptap/extension-subscript"),require("@tiptap/extension-text-align"),require("@tiptap/extension-mathematics"),require("@tiptap/extension-unique-id"),require("@tiptap/extension-emoji"),require("@tiptap/extension-table-of-contents"),require("@tiptap/pm/state"),require("@tiptap/core"),require("clsx"),require("@tiptap/pm/tables"),require("@tiptap/extension-horizontal-rule"),require("@tiptap/extension-image"),require("@tiptap/extension-code-block"),require("echarts"),require("mermaid"),require("@tiptap/pm/view"),require("@floating-ui/react"),require("@tiptap/extension-table/table"),require("@tiptap/extension-table"),require("@tiptap/pm/transform"),require("@ariakit/react"),require("class-variance-authority"),require("react-hotkeys-hook"),require("@radix-ui/react-popover"),require("@base-ui/react/merge-props"),require("@base-ui/react/use-render"),require("@tiptap/suggestion"),require("@tiptap/markdown"),require("@tiptap/extension-drag-handle-react"),require("@tiptap/pm/model"),require("lodash.throttle"),require("@radix-ui/react-dropdown-menu")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@tiptap/react","react-dom","@tiptap/extension-collaboration","@tiptap/extension-collaboration-caret","@tiptap/starter-kit","@tiptap/extension-mention","@tiptap/extension-list","@tiptap/extension-text-style","@tiptap/extensions","@tiptap/extension-typography","@tiptap/extension-highlight","@tiptap/extension-superscript","@tiptap/extension-subscript","@tiptap/extension-text-align","@tiptap/extension-mathematics","@tiptap/extension-unique-id","@tiptap/extension-emoji","@tiptap/extension-table-of-contents","@tiptap/pm/state","@tiptap/core","clsx","@tiptap/pm/tables","@tiptap/extension-horizontal-rule","@tiptap/extension-image","@tiptap/extension-code-block","echarts","mermaid","@tiptap/pm/view","@floating-ui/react","@tiptap/extension-table/table","@tiptap/extension-table","@tiptap/pm/transform","@ariakit/react","class-variance-authority","react-hotkeys-hook","@radix-ui/react-popover","@base-ui/react/merge-props","@base-ui/react/use-render","@tiptap/suggestion","@tiptap/markdown","@tiptap/extension-drag-handle-react","@tiptap/pm/model","lodash.throttle","@radix-ui/react-dropdown-menu"],l):(B=typeof globalThis<"u"?globalThis:B||self,l(B.OmniboxEditor={},B.jsxRuntime,B.React,B.tiptapReact,B.ReactDOM,B.tiptapExtensionCollaboration,B.tiptapExtensionCollaborationCaret,B.tiptapStarterKit,B.tiptapExtensionMention,B.tiptapExtensionList,B.tiptapExtensionTextStyle,B.tiptapExtensions,B.tiptapExtensionTypography,B.tiptapExtensionHighlight,B.tiptapExtensionSuperscript,B.tiptapExtensionSubscript,B.tiptapExtensionTextAlign,B.tiptapExtensionMathematics,B.tiptapExtensionUniqueId,B.tiptapExtensionEmoji,B.tiptapExtensionTableOfContents,B.tiptapPmState,B.tiptapCore,B.clsx,B.tiptapPmTables,B.tiptapExtensionHorizontalRule,B.tiptapExtensionImage,B.tiptapExtensionCodeBlock,B.echarts,B.mermaid,B.tiptapPmView,B.floatingUiReact,B.tiptapExtensionTableTable,B.tiptapExtensionTable,B.tiptapPmTransform,B.ariakitReact,B.classVarianceAuthority,B.reactHotkeysHook,B.radixUiReactPopover,B.baseUiReactMergeProps,B.baseUiReactUseRender,B.tiptapSuggestion,B.tiptapMarkdown,B.tiptapExtensionDragHandleReact,B.tiptapPmModel,B.lodash.throttle,B.radixUiReactDropdownMenu))})(this,(function(B,l,u,G,i1,a1,c1,Mr,d1,Tt,Nr,Hr,u1,f1,p1,h1,C1,Vr,g1,Br,Dr,E,we,b1,T,m1,Ur,w1,v1,y1,Te,z,x1,Be,Or,k1,Cn,ue,S1,x0,k0,Pr,T1,A1,Wr,I1,L1){"use strict";function st(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const At=st(u),E1=st(v1),ce=st(k1),It=st(S1),ve=st(L1),De={commentInputVisible:!1,lockDragHandle:!1,isDragging:!1},M1=we.Extension.create({name:"uiState",addStorage(){return{uiState:{...De}}},addCommands(){const e=n=>o=>()=>(this.storage[n]=o,!0),t=(n,o)=>()=>()=>(this.storage[n]=o,!0);return{commentInputShow:t("commentInputVisible",!0),commentInputHide:t("commentInputVisible",!1),setLockDragHandle:e("lockDragHandle"),setIsDragging:e("isDragging"),resetUiState:()=>()=>(Object.assign(this.storage,{...De}),!0)}},onCreate(){this.storage={...De}}});function gn(e){return G.useEditorState({editor:e,selector:({editor:t})=>{if(!t)return De;const n=t.storage.uiState;return n?{...De,...n}:(console.warn("Editor storage uiState is not initialized. Ensure you have the uiState extension added to your editor."),De)}})??De}function N1(e){const n=e.storage.pages;return!n||!("activeEditor"in n)?null:n.activeEditor??null}function k(e){const{editor:t}=G.useCurrentEditor(),n=e??t,[o,r]=u.useState(null);return u.useEffect(()=>{if(!n){r(null);return}const i=()=>r(N1(n));return i(),n.on("update",i),n.on("selectionUpdate",i),()=>{n.off("update",i),n.off("selectionUpdate",i)}},[n]),u.useEffect(()=>{if(!o)return;const i=()=>r(null);return o.on("destroy",i),()=>{o.off("destroy",i)}},[o]),G.useEditorState({editor:o??n,selector(i){return i.editor?{editor:i.editor,editorState:i.editor.state,canCommand:i.editor.can}:{editor:null,editorState:void 0,canCommand:void 0}}})??{editor:null}}const bn=5*1024*1024,H1={mod:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",option:"⌥",shift:"⇧",backspace:"Del",delete:"⌦",enter:"⏎",escape:"⎋",capslock:"⇪"},mn={position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:0};function $(...e){return b1.clsx(e)}function V1(){return typeof navigator<"u"&&navigator.platform.toLowerCase().includes("mac")}const B1=(e,t,n=!0)=>{if(t){const o=e.toLowerCase();return H1[o]||(n?e.toUpperCase():e)}return n?e.charAt(0).toUpperCase()+e.slice(1):e},J=e=>{const{shortcutKeys:t,delimiter:n="+",capitalize:o=!0}=e;return t?t.split(n).map(r=>r.trim()).map(r=>B1(r,V1(),o)):[]},Ae=(e,t)=>t?.schema?t.schema.spec.marks.get(e)!==void 0:!1,te=(e,t)=>t?.schema?t.schema.spec.nodes.get(e)!==void 0:!1;function D1(e){const{state:t,view:n}=e,{doc:o,selection:r}=t,s=E.Selection.findFrom(r.$to,1,!0);if(s)return n.dispatch(t.tr.setSelection(s).scrollIntoView()),!0;const i=t.schema.nodes.paragraph;if(!i)return console.warn("No paragraph node type found in schema."),!1;const a=o.content.size,c=i.create();let d=t.tr.insert(a,c);const p=d.doc.resolve(a+1);return d=d.setSelection(E.TextSelection.near(p)).scrollIntoView(),n.dispatch(d),!0}function X(e){return typeof e=="number"&&e>=0}function _(e,t){if(!e)return!1;const n=Array.isArray(t)?t:[t],o=n.some(r=>e.extensionManager.extensions.some(s=>s.name===r));return o||console.warn(`None of the extensions [${n.join(", ")}] were found in the editor schema. Ensure they are included in the editor configuration.`),o}function U1(e,t){try{const n=e.state.doc.nodeAt(t);return n||(console.warn(`No node found at position ${t}`),null)}catch(n){return console.error(`Error getting node at position ${t}:`,n),null}}function me(e){const{editor:t,node:n,nodePos:o}=e;if(!t||!t.state?.doc)return null;const r=n!=null,s=X(o);if(!r&&!s)return null;if(r){let i=-1,a=null;if(t.state.doc.descendants((c,d)=>c===n?(i=d,a=c,!1):!0),i!==-1&&a!==null)return{pos:i,node:a}}if(s){const i=U1(t,o);if(i)return{pos:o,node:i}}return null}function ie(e,t=[],n=!1){if(!e||!e.state.selection)return!1;const{selection:o}=e.state;if(o.empty)return!1;if(o instanceof E.NodeSelection){const r=o.node;return r?t.includes(r.type.name):!1}if(n){const{$from:r}=o;for(let s=r.depth;s>0;s--){const i=r.node(s);if(t.includes(i.type.name))return!0}}return!1}function xe(e,t=[]){if(!e||t.length===0)return!1;const{state:n}=e,{selection:o}=n,r=new Set(t);if(o instanceof E.NodeSelection){const s=o.node?.type?.name;return!!s&&r.has(s)}if(o instanceof E.TextSelection||o instanceof E.AllSelection){let s=!0;return n.doc.nodesBetween(o.from,o.to,i=>i.isTextblock&&!r.has(i.type.name)?(s=!1,!1):s),s}return!1}const O1=async(e,t,n)=>{if(!e)throw new Error("No file provided");if(e.size>bn)throw new Error(`File size exceeds maximum allowed (${bn/(1024*1024)}MB)`);for(let o=0;o<=100;o+=10){if(n?.aborted)throw new Error("Upload cancelled");await new Promise(r=>setTimeout(r,500)),t?.({progress:o})}return"/images/tiptap-ui-placeholder-image.jpg"},P1=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function W1(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return!e||e.replace(P1,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}function wn(e,t,n){try{const o=new URL(e,t);if(W1(o.href,n))return o.href}catch{}return"#"}function vn(e,t,n,o){if(!t.length)return!1;let r=!1;for(const{pos:s}of t){const i=e.doc.nodeAt(s);if(!i)continue;const a=i.attrs[n],c=typeof o=="function"?o(a):o;if(a===c)continue;const d={...i.attrs};c===void 0?delete d[n]:d[n]=c,e.setNodeMarkup(s,void 0,d),r=!0}return r}function _1(e){const{selection:t,doc:n}=e.state;if(!t.empty)return;const o=t.$from;let r=null,s=-1;for(let i=o.depth;i>=0;i--){const a=o.node(i),c=o.start(i);if(a.isBlock&&a.textContent.trim()){r=a,s=c;break}}if(r&&s>=0){const i=s,a=s+r.nodeSize-2;if(i<a){const c=n.resolve(i),d=n.resolve(a),p=E.TextSelection.between(c,d,1);p&&!t.eq(p)&&e.view.dispatch(e.state.tr.setSelection(p))}}}function it(e,t){const n=[],o=new Set(t);if(e instanceof T.CellSelection)return e.forEachCell((a,c)=>{o.has(a.type.name)&&n.push({node:a,pos:c})}),n;if(e instanceof E.NodeSelection){const{node:a,from:c}=e;return a&&o.has(a.type.name)&&n.push({node:a,pos:c}),n}const{$anchor:r}=e,s=T.cellAround(r);if(s){const a=e.$anchor.doc.nodeAt(s.pos);if(a&&o.has(a.type.name))return n.push({node:a,pos:s.pos}),n}const i=G.findParentNodeClosestToPos(r,a=>o.has(a.type.name));return i&&n.push({node:i.node,pos:i.pos}),n}function yn(e,t,n){return Math.max(t,Math.min(e,n))}function at(e){const{doc:t}=e.state,{from:n,to:o}=e.state.selection,r=[],s=new Set;return t.nodesBetween(n,o,(i,a)=>{if(i.isBlock)return s.has(a)||(s.add(a),r.push(i)),!1}),r}function _r(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,o)=>e.slice(o*t,o*t+t))}function Zr(e,t){if(!e)return null;const{state:n}=e,{from:o,to:r,empty:s,$from:i}=n.selection;if(s)return i.marks().find(p=>p.type.name===t)?.attrs??null;const a=new Set;let c=null;return n.doc.nodesBetween(o,r,d=>{if(d.isText)for(const p of d.marks)p.type.name===t&&!a.has(p.type.name)&&(a.add(p.type.name),c=p.attrs)}),c}function ct(e,t=!0){if(!e)return null;const{state:n}=e,{selection:o}=n;if(o instanceof E.NodeSelection){const c=o.node,d=o.from;if(c&&X(d))return{node:c,pos:d}}if(o.empty&&!t)return null;const r=o.$anchor,s=1,i=r.node(s),a=r.before(s);return{node:i,pos:a}}function Fr(e,t){if(!e)return null;const n=e.extensionManager.extensions.find(o=>o.name===t);return n||(console.warn(`Extension "${t}" not found in the editor schema. Ensure it is included in the editor configuration.`),null)}const zr="hideFloatingToolbar";function Z1(e){const{editor:t,isSelectionValid:n,extraHideWhen:o=!1}=e,[r,s]=u.useState(!1),i=u.useRef(!1);return u.useEffect(()=>{if(!t)return;const a=({transaction:c})=>{c.getMeta(zr)?i.current=!0:c.selectionSet&&(i.current=!1)};return t.on("transaction",a),()=>{t.off("transaction",a)}},[t]),u.useEffect(()=>{if(!t)return;const a=t.view.dom,c=d=>{const p=t.state.selection;if(!(p instanceof E.NodeSelection))return;const f=t.view.nodeDOM(p.from);if(f&&f.contains(d.target)){i.current=!1;const h=n(t,p);s(h&&!o)}};return a.addEventListener("pointerdown",c,{capture:!0}),()=>a.removeEventListener("pointerdown",c,{capture:!0})},[t,o,n]),u.useEffect(()=>{if(!t)return;const a=()=>{const{selection:c}=t.state,d=n(t,c);if(o||G.isNodeSelection(c)&&i.current){s(!1);return}s(d)};return a(),t.on("selectionUpdate",a),()=>{t.off("selectionUpdate",a)}},[t,o,n]),{shouldShow:r}}const xn=(e,t)=>{if(!e)return;const{state:n,view:o}=e;o.dispatch(n.tr.setSelection(E.NodeSelection.create(n.doc,t)).setMeta(zr,!0))};function F1(e={}){const{editor:t,onTargetFound:n=()=>{},onTargetNotFound:o=()=>{}}=e,{editor:r}=k(t),s=u.useRef(null),i=u.useRef(n),a=u.useRef(o);i.current=n,a.current=o;const c=u.useCallback(p=>{if(!r)return!1;const f=Fr(r,"uniqueID")?.options?.attributeName??"data-id";let h=null;return r.state.doc.descendants((C,g)=>C.attrs?.[f]===p?(h=g,!1):!0),h===null?!1:(xn(r,h),setTimeout(()=>{const C=r.view.nodeDOM(h);C&&C.scrollIntoView({behavior:"smooth",block:"center"})},0),!0)},[r]),d=u.useCallback((p=0)=>{const f=window.location.hash?.substring(1);f&&f!==s.current&&setTimeout(()=>{c(f)?(s.current=f,i.current(f)):a.current(f)},p)},[c]);return u.useEffect(()=>{r&&d(500)},[r,d]),u.useEffect(()=>{const p=()=>d(),f=()=>d(500);return window.addEventListener("hashchange",p),window.addEventListener("pageshow",f),window.addEventListener("popstate",p),()=>{window.removeEventListener("hashchange",p),window.removeEventListener("pageshow",f),window.removeEventListener("popstate",p)}},[d]),{scrollToHash:c}}const z1=m1.extend({renderHTML(){return["div",G.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),$r={addCaption:"添加图片说明...",add:"添加",ai:"AI",aiIsWriting:"AI 正在写作",aiReviewPrompt:"告诉 AI 还需要改什么...",aiTone:"语气",apply:"应用",askAi:"询问 AI",askAiPrompt:"告诉 AI 你想做什么...",askAiSubtext:"让 AI 帮你生成或编辑内容",blockquote:"引用",blockquoteBlock:"引用块",bulletList:"无序列表",bold:"加粗",clearAllContents:"清空所有内容",clickForOptions:"点击打开选项",code:"代码",codeBlock:"代码块",codeBlockWithSyntaxHighlighting:"带语法高亮的代码块",color:"颜色",continueWriting:"继续写作",continueWritingPrompt:"让 AI 继续写下去...",continueWritingSubtext:"让 AI 继续当前内容",close:"关闭",copyAnchorLink:"复制锚点链接",copyToClipboard:"复制到剪贴板",delete:"删除",discard:"丢弃",duplicateNode:"复制节点",applyFormula:"应用公式",closeFormulaEditor:"关闭公式编辑器",editFormula:"编辑公式",emoji:"表情",emojiSubtext:"插入表情",failedToRenderChart:"图表渲染失败",failedToRenderDiagram:"流程图渲染失败",heading:"标题",heading1:"一级标题",heading2:"二级标题",heading3:"三级标题",heading4:"四级标题",heading5:"五级标题",heading6:"六级标题",highlightColor:"高亮颜色",holdForDrag:"按住拖动",hideSource:"隐藏源码",image:"图片",imageSubtext:"可调整大小并支持说明的图片",addImage:"添加图片",replaceImage:"替换图片",increaseIndent:"增加缩进",insert:"插入",italic:"斜体",linkEditor:"链接编辑",link:"链接",listItem:"列表项",listWithOrderedItems:"有序项目列表",listWithTasks:"任务列表",listWithUnorderedItems:"无序项目列表",loading:"正在加载...",mention:"提及",mentionSubtext:"提及用户或项目",node:"节点",orderedList:"有序列表",placeholder:"开始输入...",pasteLink:"粘贴链接...",openLinkInNewWindow:"在新窗口打开",recentColors:"最近使用的颜色",recentTextColor:"最近使用的文字颜色",recentHighlightColor:"最近使用的高亮颜色",regularTextParagraph:"普通文本段落",resetFormatting:"清除格式",separator:"分隔线",separatorSubtext:"用于分隔内容的水平线",showSource:"显示源码",style:"样式",subsectionAndGroupHeading:"小节和分组标题",table:"表格",rowActions:"行操作",columnActions:"列操作",tableCellsOption:"单元格选项",insertRowAbove:"在上方插入行",insertRowBelow:"在下方插入行",deleteRow:"删除行",clearRowContents:"清空行内容",insertColumnLeft:"在左侧插入列",insertColumnRight:"在右侧插入列",duplicateRow:"复制行",duplicateColumn:"复制列",moveRowUp:"上移行",moveRowDown:"下移行",moveColumnLeft:"左移列",moveColumnRight:"右移列",sortRowAsc:"行升序排序",sortRowDesc:"行降序排序",sortColumnAsc:"列升序排序",sortColumnDesc:"列降序排序",deleteColumn:"删除列",clearColumnContents:"清空列内容",headerRow:"表头行",headerColumn:"表头列",mergeCells:"合并单元格",splitCell:"拆分单元格",alignLeft:"左对齐",alignCenter:"居中对齐",alignRight:"右对齐",alignTop:"顶部对齐",alignMiddle:"垂直居中",alignBottom:"底部对齐",alignment:"对齐",backgroundColor:"背景颜色",defaultTextColor:"默认文字",grayTextColor:"灰色文字",brownTextColor:"棕色文字",orangeTextColor:"橙色文字",yellowTextColor:"黄色文字",greenTextColor:"绿色文字",blueTextColor:"蓝色文字",purpleTextColor:"紫色文字",pinkTextColor:"粉色文字",redTextColor:"红色文字",defaultBackgroundColor:"默认背景",grayBackgroundColor:"灰色背景",brownBackgroundColor:"棕色背景",orangeBackgroundColor:"橙色背景",yellowBackgroundColor:"黄色背景",greenBackgroundColor:"绿色背景",blueBackgroundColor:"蓝色背景",purpleBackgroundColor:"紫色背景",pinkBackgroundColor:"粉色背景",redBackgroundColor:"红色背景",clearContents:"清空内容",fitToWidth:"适应宽度",deleteTable:"删除表格",tableOfContents:"目录",tableOfContentsSubtext:"插入目录",tableSubtext:"插入表格",taskList:"待办列表",text:"文本",textColor:"文字颜色",textColorOptions:"文字颜色选项",textHighlighter:"文字高亮",highlightColors:"高亮颜色",removeHighlight:"移除高亮",moreOptions:"更多选项",removeLink:"移除链接",strike:"删除线",underline:"下划线",alignJustify:"两端对齐",applyLink:"应用链接",superscript:"上标",subscript:"下标",decreaseIndent:"减少缩进",submitAiPrompt:"发送 AI 提示词",stopAiGeneration:"停止 AI 生成",topLevelHeading:"顶级标题",turnInto:"转换为",turnIntoCurrent:"转换为(当前:{{current}})",tryAgain:"重试",upload:"上传",uploadFailed:"上传失败"},$1={addCaption:"Add a caption...",add:"Add",ai:"AI",aiIsWriting:"AI is writing",aiReviewPrompt:"Tell AI what else needs to be changed...",aiTone:"Tone",apply:"Apply",askAi:"Ask AI",askAiPrompt:"Ask AI what you want...",askAiSubtext:"Ask AI to generate or edit content",blockquote:"Blockquote",blockquoteBlock:"Blockquote block",bulletList:"Bullet List",bold:"Bold",clearAllContents:"Clear all contents",clickForOptions:"Click for options",code:"Code",codeBlock:"Code Block",codeBlockWithSyntaxHighlighting:"Code block with syntax highlighting",color:"Color",continueWriting:"Continue Writing",continueWritingPrompt:"Ask AI to continue writing...",continueWritingSubtext:"Continue writing from the current content",close:"Close",copyAnchorLink:"Copy anchor link",copyToClipboard:"Copy to clipboard",delete:"Delete",discard:"Discard",duplicateNode:"Duplicate node",applyFormula:"Apply formula",closeFormulaEditor:"Close formula editor",editFormula:"Edit formula",emoji:"Emoji",emojiSubtext:"Insert an emoji",failedToRenderChart:"Failed to render chart",failedToRenderDiagram:"Failed to render diagram",heading:"Heading",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",highlightColor:"Highlight color",holdForDrag:"Hold for drag",hideSource:"Hide source",image:"Image",imageSubtext:"Resizable image with caption",addImage:"Add image",replaceImage:"Replace image",increaseIndent:"Increase indent",insert:"Insert",italic:"Italic",linkEditor:"Link Editor",link:"Link",listItem:"List Item",listWithOrderedItems:"List with ordered items",listWithTasks:"List with tasks",listWithUnorderedItems:"List with unordered items",loading:"Connecting...",mention:"Mention",mentionSubtext:"Mention a user or item",node:"Node",orderedList:"Ordered List",placeholder:"Start writing...",pasteLink:"Paste a link...",openLinkInNewWindow:"Open in new window",recentColors:"Recent colors",recentTextColor:"Recent text color",recentHighlightColor:"Recent highlight color",regularTextParagraph:"Regular text paragraph",resetFormatting:"Reset formatting",separator:"Separator",separatorSubtext:"Horizontal line to separate content",showSource:"Show source",style:"Style",subsectionAndGroupHeading:"Subsection and group heading",table:"Table",rowActions:"Row actions",columnActions:"Column actions",tableCellsOption:"Table cells option",insertRowAbove:"Insert row above",insertRowBelow:"Insert row below",deleteRow:"Delete row",clearRowContents:"Clear row contents",insertColumnLeft:"Insert column left",insertColumnRight:"Insert column right",duplicateRow:"Duplicate row",duplicateColumn:"Duplicate column",moveRowUp:"Move row up",moveRowDown:"Move row down",moveColumnLeft:"Move column left",moveColumnRight:"Move column right",sortRowAsc:"Sort row A-Z",sortRowDesc:"Sort row Z-A",sortColumnAsc:"Sort column A-Z",sortColumnDesc:"Sort column Z-A",deleteColumn:"Delete column",clearColumnContents:"Clear column contents",headerRow:"Header row",headerColumn:"Header column",mergeCells:"Merge cells",splitCell:"Split cell",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignTop:"Align top",alignMiddle:"Align middle",alignBottom:"Align bottom",alignment:"Alignment",backgroundColor:"Background color",defaultTextColor:"Default text",grayTextColor:"Gray text",brownTextColor:"Brown text",orangeTextColor:"Orange text",yellowTextColor:"Yellow text",greenTextColor:"Green text",blueTextColor:"Blue text",purpleTextColor:"Purple text",pinkTextColor:"Pink text",redTextColor:"Red text",defaultBackgroundColor:"Default background",grayBackgroundColor:"Gray background",brownBackgroundColor:"Brown background",orangeBackgroundColor:"Orange background",yellowBackgroundColor:"Yellow background",greenBackgroundColor:"Green background",blueBackgroundColor:"Blue background",purpleBackgroundColor:"Purple background",pinkBackgroundColor:"Pink background",redBackgroundColor:"Red background",clearContents:"Clear contents",fitToWidth:"Fit to width",deleteTable:"Delete table",tableOfContents:"Table of contents",tableOfContentsSubtext:"Insert a table of contents",tableSubtext:"Insert a table",taskList:"Task List",text:"Text",textColor:"Text color",textColorOptions:"Text color options",textHighlighter:"Text Highlighter",highlightColors:"Highlight colors",removeHighlight:"Remove highlight",moreOptions:"More options",removeLink:"Remove link",strike:"Strikethrough",underline:"Underline",alignJustify:"Align justify",applyLink:"Apply link",superscript:"Superscript",subscript:"Subscript",decreaseIndent:"Decrease indent",submitAiPrompt:"Submit AI prompt",stopAiGeneration:"Stop AI generation",topLevelHeading:"Top-level heading",turnInto:"Turn into",turnIntoCurrent:"Turn into (current: {{current}})",tryAgain:"Try again",upload:"Upload",uploadFailed:"Upload failed"};function q1(e){return e?e.toLowerCase().startsWith("zh")?$r:$1:$r}function Ie(e,t){return{...q1(e),...t}}const qr=u.createContext(Ie());function D(){return u.useContext(qr)}function G1(e,t){return t==="load"?"loaded":"loading"}function Gr(e,t){return e.src===t?e.state:"loading"}function Kr(e,t,n){return{src:t,state:G1(Gr(e,t),n)}}function K1(e){const{editor:t,node:n,updateAttributes:o,getPos:r}=e,s=n.content.size>0,i=e.extension.options.i18n??Ie();return l.jsx(Y1,{src:n.attrs.src,alt:n.attrs.alt||"",editor:t,align:n.attrs["data-align"],initialWidth:n.attrs.width,showCaption:n.attrs.showCaption,hasContent:s,i18n:i,nodeSize:n.nodeSize,onImageResize:a=>o({width:a}),onUpdateAttributes:o,getPos:r})}const Y1=({src:e,alt:t="",editor:n,minWidth:o=96,maxWidth:r=800,align:s="left",initialWidth:i,showCaption:a=!1,hasContent:c=!1,nodeSize:d,onImageResize:p,onUpdateAttributes:f,i18n:h=Ie(),getPos:C})=>{const[g,b]=u.useState(),[m,w]=u.useState(i),[v,y]=u.useState(!1),[x,S]=u.useState({src:e,state:"loading"}),L=u.useRef(!1),I=u.useRef(!0),V=u.useRef(null),K=u.useRef(null),se=u.useRef(null),O=u.useRef(null);u.useEffect(()=>{if(!n||!a)return;const F=()=>{const oe=C();if(!X(oe)||!d)return;const{from:hn,to:rt}=n.state.selection,lt=oe,Er=oe+d;(rt<lt||hn>Er)&&!c&&f&&f({showCaption:!1})};return n.on("selectionUpdate",F),()=>{n.off("selectionUpdate",F)}},[n,a,c,C,d,f]);const Y=u.useCallback(F=>{if(!n||!C||g)return;F.preventDefault(),F.stopPropagation();const oe=C();X(oe)&&n.chain().focus().setNodeSelection(oe).run()},[n,C,g]),A=u.useCallback(F=>{if(!g||!n||!I.current)return;const oe="touches"in F?F.touches[0]?.clientX??0:F.clientX,hn=g.handleUsed==="left",rt=s==="center"?2:1,lt=hn?(g.initialClientX-oe)*rt:(oe-g.initialClientX)*rt,Er=g.initialWidth+lt,l1=n.view.dom?.firstElementChild?.clientWidth||r,s1=Math.min(Math.max(Er,o),l1);w(s1),V.current&&(V.current.style.width=`${s1}px`)},[n,s,r,o,g]),N=u.useCallback(F=>{if(!n||!I.current)return;const oe="touches"in F?document.elementFromPoint(F.changedTouches[0]?.clientX??0,F.changedTouches[0]?.clientY??0):F.target;if((!(oe&&V.current?.contains(oe))||!n.isEditable)&&v&&I.current&&y(!1),!g)return;const rt=n.state.selection instanceof E.NodeSelection&&n.state.selection.node.type.name==="image";I.current&&b(void 0),p?.(m);const lt=C();X(lt)&&rt&&I.current&&n.chain().focus().setNodeSelection(lt).run(),L.current=!1},[n,C,p,g,v,m]),U=u.useCallback((F,oe)=>{b({handleUsed:F,initialWidth:V.current?.clientWidth??o,initialClientX:oe}),L.current=!0},[o]),H=F=>{F.preventDefault(),F.stopPropagation(),U("left",F.clientX)},W=F=>{F.preventDefault();const oe=F.touches[0];oe&&U("left",oe.clientX)},P=F=>{F.preventDefault(),F.stopPropagation(),U("right",F.clientX)},q=F=>{F.preventDefault();const oe=F.touches[0];oe&&U("right",oe.clientX)},Z=()=>{n?.isEditable&&I.current&&y(!0)},le=F=>{I.current&&(F.relatedTarget===K.current||F.relatedTarget===se.current||g||n?.isEditable&&y(!1))},be=()=>{n?.isEditable&&I.current&&y(!0)},ot=()=>{S(F=>Kr(F,e,"load"))},o1=()=>{S(F=>Kr(F,e,"error"))};u.useEffect(()=>(window.addEventListener("mousemove",A),window.addEventListener("mouseup",N),window.addEventListener("touchmove",A,{passive:!1}),window.addEventListener("touchend",N),()=>{window.removeEventListener("mousemove",A),window.removeEventListener("mouseup",N),window.removeEventListener("touchmove",A),window.removeEventListener("touchend",N)}),[A,N]),u.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const r1=a||c,Ve=Gr(x,e)==="loading";return l.jsx(G.NodeViewWrapper,{onMouseEnter:Z,onMouseLeave:le,onTouchStart:be,"data-align":s,"data-width":m,className:"tiptap-image",children:l.jsxs("div",{ref:V,className:"tiptap-image-container",style:{width:m?`${m}px`:"fit-content"},children:[l.jsxs("div",{className:"tiptap-image-content tw:min-h-8 tw:min-w-8 tw:justify-center",children:[Ve&&l.jsx("div",{"aria-hidden":"true",className:"tw:absolute tw:inset-0 tw:flex tw:min-h-8 tw:min-w-8 tw:items-center tw:justify-center tw:rounded-[var(--tt-radius-xs)] tw:pointer-events-none",contentEditable:!1,children:l.jsx("span",{className:"tw:size-4 tw:animate-[spin_1s_linear_infinite] tw:rounded-full tw:border-2 tw:border-[var(--tt-gray-light-a-200)] tw:border-t-[var(--tt-brand-color-500)] tw:dark:border-[var(--tt-gray-dark-a-200)] tw:dark:border-t-[var(--tt-brand-color-400)]"})}),l.jsx("img",{ref:O,src:e,alt:t,className:$("tiptap-image-img",Ve&&"tw:invisible"),contentEditable:!1,draggable:!1,referrerPolicy:"same-origin",onLoad:ot,onError:o1,onClick:Y,style:{cursor:n?.isEditable?"pointer":"default"}}),v&&n?.isEditable&&l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:K,className:"tiptap-image-handle tiptap-image-handle-left",onMouseDown:H,onTouchStart:W}),l.jsx("div",{ref:se,className:"tiptap-image-handle tiptap-image-handle-right",onMouseDown:P,onTouchStart:q})]})]}),n?.isEditable&&r1&&l.jsx(G.NodeViewContent,{as:"div",className:"tiptap-image-caption","data-placeholder":h.addCaption})]})})},Yr=e=>({src:e.getAttribute("src"),alt:e.getAttribute("alt"),title:e.getAttribute("title"),width:e.getAttribute("width"),height:e.getAttribute("height")});function j1(e){const t={src:e.src||"",referrerpolicy:"same-origin"};return e.alt&&(t.alt=e.alt),e.title&&(t.title=e.title),e.width&&(t.width=e.width),e.height&&(t.height=e.height),t}const X1=Ur.Image.extend({content:"inline*",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1,...this.parent?.(),i18n:Ie()}},addAttributes(){return{...this.parent?.(),"data-align":{default:null},showCaption:{default:!1,parseHTML:e=>e.tagName==="FIGURE"||e.getAttribute("data-show-caption")==="true",renderHTML:e=>e.showCaption?{"data-show-caption":"true"}:{}}}},parseHTML(){return[{tag:"figure",getAttrs:e=>{const t=e.querySelector("img");return t?{...Yr(t),"data-align":e.getAttribute("data-align"),showCaption:!0}:!1},contentElement:"figcaption"},{tag:"img[src]",getAttrs:e=>e.closest("figure")?!1:{...Yr(e),"data-align":e.getAttribute("data-align"),showCaption:!1}}]},renderHTML({node:e}){const{src:t,alt:n,title:o,width:r,height:s,showCaption:i}=e.attrs,a=e.attrs["data-align"],c=j1({src:t,alt:n,title:o,width:r,height:s}),d=e.content.size>0;if(i||d){const p={"data-url":t||""};return i&&(p["data-show-caption"]="true"),a&&(p["data-align"]=a),["figure",p,["img",c],["figcaption",{},0]]}return a&&(c["data-align"]=a),["img",c]},addKeyboardShortcuts(){const e=(t,n)=>{if(t instanceof E.NodeSelection&&t.node.type===n)return{imageNode:t.node,imagePos:t.from,atStart:!0,atEnd:!0};if(t.empty&&t.$from.parent.type===n){const{$from:o}=t;return{imageNode:o.parent,imagePos:o.before(),atStart:o.parentOffset===0,atEnd:o.parentOffset===o.parent.content.size}}return null};return{"Mod-a":({editor:t})=>{const{state:n,view:o}=t,{selection:r}=n,{$from:s}=r;let i=null,a=null;for(let h=s.depth;h>=0;h--){const C=s.node(h);if(C.type===this.type){a=C,i=h===0?0:s.before(h);break}}if(!a||i==null||a.content.size===0||a.textContent.length===0)return!1;const d=i+1,p=i+a.nodeSize-1,f=n.tr.setSelection(E.TextSelection.create(n.doc,d,p));return o.dispatch(f),!0},ArrowUp:({editor:t})=>{const{state:n}=t,o=e(n.selection,this.type);return!o||!o.atStart||o.imagePos!==0?!1:t.chain().insertContentAt(0,{type:"paragraph"}).setTextSelection(1).run()}}},addNodeView(){return G.ReactNodeViewRenderer(K1)}});function J1(e,t){if(e.length===0)return null;for(const n of e)if((n.node.attrs?.backgroundColor??null)!==t)return t;return null}const Q1=we.Extension.create({name:"nodeBackground",addOptions(){return{types:["paragraph","heading","blockquote","taskList","bulletList","orderedList","tableCell","tableHeader"],useStyle:!0}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{const t=e.style?.backgroundColor;return t||e.getAttribute("data-background-color")||null},renderHTML:e=>{const t=e.backgroundColor;return t?this.options.useStyle?{style:`background-color: ${t}`}:{"data-background-color":t}:{}}}}}]},addCommands(){const e=t=>n=>({state:o,tr:r})=>{const s=it(o.selection,this.options.types);if(s.length===0)return!1;const i=t(s,n);return vn(r,s,"backgroundColor",i)};return{setNodeBackgroundColor:e((t,n)=>n||null),unsetNodeBackgroundColor:e(()=>null),toggleNodeBackgroundColor:e((t,n)=>J1(t,n||""))}}});function jr(e,t,n){if(e.length===0)return null;for(const o of e)if((o.node.attrs?.[t]??null)!==n)return n;return null}const R1=we.Extension.create({name:"nodeAlignment",addOptions(){return{types:["paragraph","heading","blockquote","tableCell","tableHeader"],useStyle:!0,textAlignValues:["left","center","right","justify"],verticalAlignValues:["top","middle","bottom"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{nodeTextAlign:{default:null,parseHTML:e=>{const t=e.style?.textAlign;if(t&&this.options.textAlignValues.includes(t))return t;const n=e.getAttribute("data-node-text-align");return n&&this.options.textAlignValues.includes(n)?n:null},renderHTML:e=>{const t=e.nodeTextAlign;return!t||!this.options.textAlignValues.includes(t)?{}:this.options.useStyle?{style:`text-align: ${t}`}:{"data-node-text-align":t}}},nodeVerticalAlign:{default:null,parseHTML:e=>{const t=e.style?.verticalAlign;if(t&&this.options.verticalAlignValues.includes(t))return t;const n=e.getAttribute("data-node-vertical-align");return n&&this.options.verticalAlignValues.includes(n)?n:null},renderHTML:e=>{const t=e.nodeVerticalAlign;return!t||!this.options.verticalAlignValues.includes(t)?{}:this.options.useStyle?{style:`vertical-align: ${t}`}:{"data-node-vertical-align":t}}}}}]},addCommands(){const e=(t,n)=>o=>({state:r,tr:s})=>{const i=it(r.selection,this.options.types);if(i.length===0)return!1;const a=n(i,o);return vn(s,i,t,a)};return{setNodeTextAlign:e("nodeTextAlign",(t,n)=>!n||!this.options.textAlignValues.includes(n)?null:n),unsetNodeTextAlign:e("nodeTextAlign",()=>null),toggleNodeTextAlign:e("nodeTextAlign",(t,n)=>!n||!this.options.textAlignValues.includes(n)?null:jr(t,"nodeTextAlign",n)),setNodeVAlign:e("nodeVerticalAlign",(t,n)=>!n||!this.options.verticalAlignValues.includes(n)?null:n),unsetNodeVAlign:e("nodeVerticalAlign",()=>null),toggleNodeVAlign:e("nodeVerticalAlign",(t,n)=>!n||!this.options.verticalAlignValues.includes(n)?null:jr(t,"nodeVerticalAlign",n)),setNodeAlignment:(t,n)=>({state:o,tr:r})=>{const s=it(o.selection,this.options.types);if(s.length===0)return!1;let i=!1;for(const{node:a,pos:c}of s){const d={...a.attrs};t&&this.options.textAlignValues.includes(t)&&(d.nodeTextAlign=t,i=!0),n&&this.options.verticalAlignValues.includes(n)&&(d.nodeVerticalAlign=n,i=!0),i&&r.setNodeMarkup(c,void 0,d)}return i},unsetNodeAlignment:()=>({state:t,tr:n})=>{const o=it(t.selection,this.options.types);if(o.length===0)return!1;let r=!1;for(const{node:s,pos:i}of o){const a=s.attrs?.nodeTextAlign??null,c=s.attrs?.nodeVerticalAlign??null;if(a||c){const d={...s.attrs,nodeTextAlign:null,nodeVerticalAlign:null};n.setNodeMarkup(i,void 0,d),r=!0}}return r}}}}),Xr=u.createContext(void 0);function ec(e){if(e.length===0)return[];const t=e.map(a=>a.originalLevel??a.level??1),n=t.filter(a=>a>0),o=n.includes(1)?1:Math.min(...n),r=t.map(a=>Math.max(1,a-(o-1))),s=[],i=[];for(let a=0;a<r.length;a++){const c=r[a]??1;for(;i.length>0&&i[i.length-1].level>=c;)i.pop();const d=i.length===0?1:i[i.length-1].depth+1;s.push(d),i.push({level:c,depth:d})}return s}const Jr=e=>{let t=e.parentElement;for(;t;){const{overflowY:n}=getComputedStyle(t);if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return window},tc=(e,t)=>{const n=e.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight;return n.top>=t&&n.bottom>t&&n.top<o},nc=(e,t,n="smooth")=>{if(!(!e.dom||typeof window>"u")){if(!tc(e.dom,t)){const o=Jr(e.dom);if(o instanceof Window){const s=e.dom.getBoundingClientRect().top+window.scrollY-t;window.scrollTo({top:s,behavior:n})}else{const r=e.dom.getBoundingClientRect(),s=o.getBoundingClientRect(),i=r.top-s.top+o.scrollTop-t;o.scrollTo({top:i,behavior:n})}}if(e.editor&&typeof e.pos=="number"&&xn(e.editor,e.pos),e.id){const o=new URL(window.location.href);o.hash=e.id,window.history.replaceState(null,"",o.toString())}}},oc=({children:e})=>{const[t,n]=u.useState(null),o=u.useCallback((r,s)=>{const i=s?.topOffset??0,a=s?.behavior??"smooth";nc(r,i,a)},[]);return l.jsx(Xr.Provider,{value:{tocContent:t,setTocContent:n,navigateToHeading:o,normalizeHeadingDepths:ec},children:e})},kn=()=>{const e=u.useContext(Xr);if(!e)throw new Error("useToc must be used inside <TocProvider>");return e};function rc(e){const{node:t,extension:n}=e,{tocContent:o,navigateToHeading:r,normalizeHeadingDepths:s}=kn(),{topOffset:i=0,maxShowCount:a=20,showTitle:c=!0}=n.options,d=t.attrs??{},{backgroundColor:p}=d,f=d.topOffset??i,h=d.maxShowCount??a,C=d.showTitle??c,g=u.useMemo(()=>o??[],[o]),b=u.useMemo(()=>g.slice(0,h),[g,h]),m=u.useMemo(()=>s(b),[b,s]),w=u.useMemo(()=>b.map((S,L)=>({item:S,depth:m[L]??1})),[b,m]),v=u.useCallback((S,L)=>{S.preventDefault(),S.stopPropagation(),r(L,{topOffset:f})},[r,f]),y={...e.HTMLAttributes};delete y.style;const x={className:"tiptap-table-of-contents-node",style:{backgroundColor:p||void 0},...y};return b.length?l.jsxs(G.NodeViewWrapper,{...x,children:[C&&l.jsx("div",{className:"tiptap-table-of-contents-title",children:"Table of contents"}),l.jsx("nav",{"aria-label":"Table of contents",className:"tiptap-table-of-contents-list",children:w.map((S,L)=>l.jsx("a",{href:`#${S.item.id}`,rel:"noopener noreferrer",className:"tiptap-table-of-contents-item notranslate","data-depth":S.depth,style:{"--toc-depth":S.depth},onClick:I=>v(I,S.item),children:S.item.textContent},S.item.id??`${L}-${S.item.textContent}`))})]}):l.jsx(G.NodeViewWrapper,{...x,children:l.jsx("div",{className:"tiptap-table-of-contents-empty",children:"Add headings to create a table of contents."})})}const lc=we.Node.create({name:"tocNode",group:"block customNode",draggable:!0,selectable:!0,atom:!0,addOptions(){return{topOffset:0,maxShowCount:20,showTitle:!0,HTMLAttributes:{}}},addAttributes(){return{topOffset:{default:null,parseHTML:e=>{const t=e.getAttribute("data-top-offset"),n=t!=null?Number(t):null;return Number.isFinite(n)?n:null},renderHTML:e=>e.topOffset==null?{}:{"data-top-offset":e.topOffset}},maxShowCount:{default:null,parseHTML:e=>{const t=e.getAttribute("data-max-show-count"),n=t!=null?Number(t):null;return Number.isFinite(n)?n:null},renderHTML:e=>e.maxShowCount==null?{}:{"data-max-show-count":e.maxShowCount}},showTitle:{default:!0,parseHTML:e=>{const t=e.getAttribute("data-show-title");return t==="false"?!1:t==="true"?!0:null},renderHTML:e=>e.showTitle==null?{}:{"data-show-title":String(e.showTitle)}}}},parseHTML(){return[{tag:'div[data-type="toc-node"]'}]},renderHTML({HTMLAttributes:e}){return["div",we.mergeAttributes(this.options.HTMLAttributes,e,{"data-type":"toc-node"})]},addNodeView(){return G.ReactNodeViewRenderer(rc,{stopEvent:({event:e})=>{if(!(e instanceof MouseEvent))return!1;const t=e.target;return t?!!t.closest(".tiptap-table-of-contents-item"):!1}})},addCommands(){return{insertTocNode:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}}}),sc=new Set(["flowchart","mermaid","mindmap"]);function ic(e){return sc.has(e.trim().toLowerCase())}function Qr(e){const t=e.trim().toLowerCase();return t==="echarts"?"echarts":ic(t)?"mermaid":null}function Rr(e){return e.replace(/\\r\\n/g,`
|
|
1
|
+
(function(B,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react/jsx-runtime"),require("react"),require("@tiptap/react"),require("react-dom"),require("@tiptap/extension-collaboration"),require("@tiptap/extension-collaboration-caret"),require("@tiptap/starter-kit"),require("@tiptap/extension-mention"),require("@tiptap/extension-list"),require("@tiptap/extension-text-style"),require("@tiptap/extensions"),require("@tiptap/extension-typography"),require("@tiptap/extension-highlight"),require("@tiptap/extension-superscript"),require("@tiptap/extension-subscript"),require("@tiptap/extension-text-align"),require("@tiptap/extension-mathematics"),require("@tiptap/extension-unique-id"),require("@tiptap/extension-emoji"),require("@tiptap/extension-table-of-contents"),require("@tiptap/pm/state"),require("@tiptap/core"),require("clsx"),require("@tiptap/pm/tables"),require("@tiptap/extension-horizontal-rule"),require("@tiptap/extension-image"),require("@tiptap/extension-code-block"),require("echarts"),require("mermaid"),require("@tiptap/pm/view"),require("@floating-ui/react"),require("@tiptap/extension-table/table"),require("@tiptap/extension-table"),require("@tiptap/pm/transform"),require("@ariakit/react"),require("class-variance-authority"),require("react-hotkeys-hook"),require("@radix-ui/react-popover"),require("@base-ui/react/merge-props"),require("@base-ui/react/use-render"),require("@tiptap/suggestion"),require("@tiptap/markdown"),require("@tiptap/extension-drag-handle-react"),require("@tiptap/pm/model"),require("lodash.throttle"),require("@radix-ui/react-dropdown-menu")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@tiptap/react","react-dom","@tiptap/extension-collaboration","@tiptap/extension-collaboration-caret","@tiptap/starter-kit","@tiptap/extension-mention","@tiptap/extension-list","@tiptap/extension-text-style","@tiptap/extensions","@tiptap/extension-typography","@tiptap/extension-highlight","@tiptap/extension-superscript","@tiptap/extension-subscript","@tiptap/extension-text-align","@tiptap/extension-mathematics","@tiptap/extension-unique-id","@tiptap/extension-emoji","@tiptap/extension-table-of-contents","@tiptap/pm/state","@tiptap/core","clsx","@tiptap/pm/tables","@tiptap/extension-horizontal-rule","@tiptap/extension-image","@tiptap/extension-code-block","echarts","mermaid","@tiptap/pm/view","@floating-ui/react","@tiptap/extension-table/table","@tiptap/extension-table","@tiptap/pm/transform","@ariakit/react","class-variance-authority","react-hotkeys-hook","@radix-ui/react-popover","@base-ui/react/merge-props","@base-ui/react/use-render","@tiptap/suggestion","@tiptap/markdown","@tiptap/extension-drag-handle-react","@tiptap/pm/model","lodash.throttle","@radix-ui/react-dropdown-menu"],l):(B=typeof globalThis<"u"?globalThis:B||self,l(B.OmniboxEditor={},B.jsxRuntime,B.React,B.tiptapReact,B.ReactDOM,B.tiptapExtensionCollaboration,B.tiptapExtensionCollaborationCaret,B.tiptapStarterKit,B.tiptapExtensionMention,B.tiptapExtensionList,B.tiptapExtensionTextStyle,B.tiptapExtensions,B.tiptapExtensionTypography,B.tiptapExtensionHighlight,B.tiptapExtensionSuperscript,B.tiptapExtensionSubscript,B.tiptapExtensionTextAlign,B.tiptapExtensionMathematics,B.tiptapExtensionUniqueId,B.tiptapExtensionEmoji,B.tiptapExtensionTableOfContents,B.tiptapPmState,B.tiptapCore,B.clsx,B.tiptapPmTables,B.tiptapExtensionHorizontalRule,B.tiptapExtensionImage,B.tiptapExtensionCodeBlock,B.echarts,B.mermaid,B.tiptapPmView,B.floatingUiReact,B.tiptapExtensionTableTable,B.tiptapExtensionTable,B.tiptapPmTransform,B.ariakitReact,B.classVarianceAuthority,B.reactHotkeysHook,B.radixUiReactPopover,B.baseUiReactMergeProps,B.baseUiReactUseRender,B.tiptapSuggestion,B.tiptapMarkdown,B.tiptapExtensionDragHandleReact,B.tiptapPmModel,B.lodash.throttle,B.radixUiReactDropdownMenu))})(this,(function(B,l,u,G,c1,d1,u1,Nr,f1,Tt,Hr,Vr,p1,h1,C1,g1,b1,Br,m1,Dr,Ur,E,we,w1,T,v1,Or,y1,x1,k1,Te,F,S1,Be,Pr,T1,gn,ue,A1,S0,T0,Wr,I1,L1,_r,E1,M1){"use strict";function st(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const At=st(u),N1=st(x1),ce=st(T1),It=st(A1),ve=st(M1),De={commentInputVisible:!1,lockDragHandle:!1,isDragging:!1},H1=we.Extension.create({name:"uiState",addStorage(){return{uiState:{...De}}},addCommands(){const e=n=>o=>()=>(this.storage[n]=o,!0),t=(n,o)=>()=>()=>(this.storage[n]=o,!0);return{commentInputShow:t("commentInputVisible",!0),commentInputHide:t("commentInputVisible",!1),setLockDragHandle:e("lockDragHandle"),setIsDragging:e("isDragging"),resetUiState:()=>()=>(Object.assign(this.storage,{...De}),!0)}},onCreate(){this.storage={...De}}});function bn(e){return G.useEditorState({editor:e,selector:({editor:t})=>{if(!t)return De;const n=t.storage.uiState;return n?{...De,...n}:(console.warn("Editor storage uiState is not initialized. Ensure you have the uiState extension added to your editor."),De)}})??De}function V1(e){const n=e.storage.pages;return!n||!("activeEditor"in n)?null:n.activeEditor??null}function k(e){const{editor:t}=G.useCurrentEditor(),n=e??t,[o,r]=u.useState(null);return u.useEffect(()=>{if(!n){r(null);return}const i=()=>r(V1(n));return i(),n.on("update",i),n.on("selectionUpdate",i),()=>{n.off("update",i),n.off("selectionUpdate",i)}},[n]),u.useEffect(()=>{if(!o)return;const i=()=>r(null);return o.on("destroy",i),()=>{o.off("destroy",i)}},[o]),G.useEditorState({editor:o??n,selector(i){return i.editor?{editor:i.editor,editorState:i.editor.state,canCommand:i.editor.can}:{editor:null,editorState:void 0,canCommand:void 0}}})??{editor:null}}const mn=5*1024*1024,B1={mod:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",option:"⌥",shift:"⇧",backspace:"Del",delete:"⌦",enter:"⏎",escape:"⎋",capslock:"⇪"},wn={position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:0};function z(...e){return w1.clsx(e)}function D1(){return typeof navigator<"u"&&navigator.platform.toLowerCase().includes("mac")}const U1=(e,t,n=!0)=>{if(t){const o=e.toLowerCase();return B1[o]||(n?e.toUpperCase():e)}return n?e.charAt(0).toUpperCase()+e.slice(1):e},J=e=>{const{shortcutKeys:t,delimiter:n="+",capitalize:o=!0}=e;return t?t.split(n).map(r=>r.trim()).map(r=>U1(r,D1(),o)):[]},Ae=(e,t)=>t?.schema?t.schema.spec.marks.get(e)!==void 0:!1,te=(e,t)=>t?.schema?t.schema.spec.nodes.get(e)!==void 0:!1;function O1(e){const{state:t,view:n}=e,{doc:o,selection:r}=t,s=E.Selection.findFrom(r.$to,1,!0);if(s)return n.dispatch(t.tr.setSelection(s).scrollIntoView()),!0;const i=t.schema.nodes.paragraph;if(!i)return console.warn("No paragraph node type found in schema."),!1;const a=o.content.size,c=i.create();let d=t.tr.insert(a,c);const f=d.doc.resolve(a+1);return d=d.setSelection(E.TextSelection.near(f)).scrollIntoView(),n.dispatch(d),!0}function X(e){return typeof e=="number"&&e>=0}function _(e,t){if(!e)return!1;const n=Array.isArray(t)?t:[t],o=n.some(r=>e.extensionManager.extensions.some(s=>s.name===r));return o||console.warn(`None of the extensions [${n.join(", ")}] were found in the editor schema. Ensure they are included in the editor configuration.`),o}function P1(e,t){try{const n=e.state.doc.nodeAt(t);return n||(console.warn(`No node found at position ${t}`),null)}catch(n){return console.error(`Error getting node at position ${t}:`,n),null}}function me(e){const{editor:t,node:n,nodePos:o}=e;if(!t||!t.state?.doc)return null;const r=n!=null,s=X(o);if(!r&&!s)return null;if(r){let i=-1,a=null;if(t.state.doc.descendants((c,d)=>c===n?(i=d,a=c,!1):!0),i!==-1&&a!==null)return{pos:i,node:a}}if(s){const i=P1(t,o);if(i)return{pos:o,node:i}}return null}function ie(e,t=[],n=!1){if(!e||!e.state.selection)return!1;const{selection:o}=e.state;if(o.empty)return!1;if(o instanceof E.NodeSelection){const r=o.node;return r?t.includes(r.type.name):!1}if(n){const{$from:r}=o;for(let s=r.depth;s>0;s--){const i=r.node(s);if(t.includes(i.type.name))return!0}}return!1}function xe(e,t=[]){if(!e||t.length===0)return!1;const{state:n}=e,{selection:o}=n,r=new Set(t);if(o instanceof E.NodeSelection){const s=o.node?.type?.name;return!!s&&r.has(s)}if(o instanceof E.TextSelection||o instanceof E.AllSelection){let s=!0;return n.doc.nodesBetween(o.from,o.to,i=>i.isTextblock&&!r.has(i.type.name)?(s=!1,!1):s),s}return!1}const W1=async(e,t,n)=>{if(!e)throw new Error("No file provided");if(e.size>mn)throw new Error(`File size exceeds maximum allowed (${mn/(1024*1024)}MB)`);for(let o=0;o<=100;o+=10){if(n?.aborted)throw new Error("Upload cancelled");await new Promise(r=>setTimeout(r,500)),t?.({progress:o})}return"/images/tiptap-ui-placeholder-image.jpg"},_1=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function Z1(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return!e||e.replace(_1,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}function vn(e,t,n){try{const o=new URL(e,t);if(Z1(o.href,n))return o.href}catch{}return"#"}function yn(e,t,n,o){if(!t.length)return!1;let r=!1;for(const{pos:s}of t){const i=e.doc.nodeAt(s);if(!i)continue;const a=i.attrs[n],c=typeof o=="function"?o(a):o;if(a===c)continue;const d={...i.attrs};c===void 0?delete d[n]:d[n]=c,e.setNodeMarkup(s,void 0,d),r=!0}return r}function F1(e){const{selection:t,doc:n}=e.state;if(!t.empty)return;const o=t.$from;let r=null,s=-1;for(let i=o.depth;i>=0;i--){const a=o.node(i),c=o.start(i);if(a.isBlock&&a.textContent.trim()){r=a,s=c;break}}if(r&&s>=0){const i=s,a=s+r.nodeSize-2;if(i<a){const c=n.resolve(i),d=n.resolve(a),f=E.TextSelection.between(c,d,1);f&&!t.eq(f)&&e.view.dispatch(e.state.tr.setSelection(f))}}}function it(e,t){const n=[],o=new Set(t);if(e instanceof T.CellSelection)return e.forEachCell((a,c)=>{o.has(a.type.name)&&n.push({node:a,pos:c})}),n;if(e instanceof E.NodeSelection){const{node:a,from:c}=e;return a&&o.has(a.type.name)&&n.push({node:a,pos:c}),n}const{$anchor:r}=e,s=T.cellAround(r);if(s){const a=e.$anchor.doc.nodeAt(s.pos);if(a&&o.has(a.type.name))return n.push({node:a,pos:s.pos}),n}const i=G.findParentNodeClosestToPos(r,a=>o.has(a.type.name));return i&&n.push({node:i.node,pos:i.pos}),n}function xn(e,t,n){return Math.max(t,Math.min(e,n))}function at(e){const{doc:t}=e.state,{from:n,to:o}=e.state.selection,r=[],s=new Set;return t.nodesBetween(n,o,(i,a)=>{if(i.isBlock)return s.has(a)||(s.add(a),r.push(i)),!1}),r}function Zr(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,o)=>e.slice(o*t,o*t+t))}function Fr(e,t){if(!e)return null;const{state:n}=e,{from:o,to:r,empty:s,$from:i}=n.selection;if(s)return i.marks().find(f=>f.type.name===t)?.attrs??null;const a=new Set;let c=null;return n.doc.nodesBetween(o,r,d=>{if(d.isText)for(const f of d.marks)f.type.name===t&&!a.has(f.type.name)&&(a.add(f.type.name),c=f.attrs)}),c}function ct(e,t=!0){if(!e)return null;const{state:n}=e,{selection:o}=n;if(o instanceof E.NodeSelection){const c=o.node,d=o.from;if(c&&X(d))return{node:c,pos:d}}if(o.empty&&!t)return null;const r=o.$anchor,s=1,i=r.node(s),a=r.before(s);return{node:i,pos:a}}function zr(e,t){if(!e)return null;const n=e.extensionManager.extensions.find(o=>o.name===t);return n||(console.warn(`Extension "${t}" not found in the editor schema. Ensure it is included in the editor configuration.`),null)}const $r="hideFloatingToolbar";function z1(e){const{editor:t,isSelectionValid:n,extraHideWhen:o=!1}=e,[r,s]=u.useState(!1),i=u.useRef(!1);return u.useEffect(()=>{if(!t)return;const a=({transaction:c})=>{c.getMeta($r)?i.current=!0:c.selectionSet&&(i.current=!1)};return t.on("transaction",a),()=>{t.off("transaction",a)}},[t]),u.useEffect(()=>{if(!t)return;const a=t.view.dom,c=d=>{const f=t.state.selection;if(!(f instanceof E.NodeSelection))return;const p=t.view.nodeDOM(f.from);if(p&&p.contains(d.target)){i.current=!1;const h=n(t,f);s(h&&!o)}};return a.addEventListener("pointerdown",c,{capture:!0}),()=>a.removeEventListener("pointerdown",c,{capture:!0})},[t,o,n]),u.useEffect(()=>{if(!t)return;const a=()=>{const{selection:c}=t.state,d=n(t,c);if(o||G.isNodeSelection(c)&&i.current){s(!1);return}s(d)};return a(),t.on("selectionUpdate",a),()=>{t.off("selectionUpdate",a)}},[t,o,n]),{shouldShow:r}}const kn=(e,t)=>{if(!e)return;const{state:n,view:o}=e;o.dispatch(n.tr.setSelection(E.NodeSelection.create(n.doc,t)).setMeta($r,!0))};function $1(e={}){const{editor:t,onTargetFound:n=()=>{},onTargetNotFound:o=()=>{}}=e,{editor:r}=k(t),s=u.useRef(null),i=u.useRef(n),a=u.useRef(o);i.current=n,a.current=o;const c=u.useCallback(f=>{if(!r)return!1;const p=zr(r,"uniqueID")?.options?.attributeName??"data-id";let h=null;return r.state.doc.descendants((C,g)=>C.attrs?.[p]===f?(h=g,!1):!0),h===null?!1:(kn(r,h),setTimeout(()=>{const C=r.view.nodeDOM(h);C&&C.scrollIntoView({behavior:"smooth",block:"center"})},0),!0)},[r]),d=u.useCallback((f=0)=>{const p=window.location.hash?.substring(1);p&&p!==s.current&&setTimeout(()=>{c(p)?(s.current=p,i.current(p)):a.current(p)},f)},[c]);return u.useEffect(()=>{r&&d(500)},[r,d]),u.useEffect(()=>{const f=()=>d(),p=()=>d(500);return window.addEventListener("hashchange",f),window.addEventListener("pageshow",p),window.addEventListener("popstate",f),()=>{window.removeEventListener("hashchange",f),window.removeEventListener("pageshow",p),window.removeEventListener("popstate",f)}},[d]),{scrollToHash:c}}const q1=v1.extend({renderHTML(){return["div",G.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),qr={addCaption:"添加图片说明...",add:"添加",ai:"AI",aiIsWriting:"AI 正在写作",aiReviewPrompt:"告诉 AI 还需要改什么...",aiTone:"语气",apply:"应用",askAi:"询问 AI",askAiPrompt:"告诉 AI 你想做什么...",askAiSubtext:"让 AI 帮你生成或编辑内容",blockquote:"引用",blockquoteBlock:"引用块",bulletList:"无序列表",bold:"加粗",clearAllContents:"清空所有内容",clickForOptions:"点击打开选项",code:"代码",codeBlock:"代码块",codeBlockWithSyntaxHighlighting:"带语法高亮的代码块",color:"颜色",continueWriting:"继续写作",continueWritingPrompt:"让 AI 继续写下去...",continueWritingSubtext:"让 AI 继续当前内容",close:"关闭",copyAnchorLink:"复制锚点链接",copyToClipboard:"复制到剪贴板",delete:"删除",discard:"丢弃",duplicateNode:"复制节点",applyFormula:"应用公式",closeFormulaEditor:"关闭公式编辑器",editFormula:"编辑公式",emoji:"表情",emojiSubtext:"插入表情",failedToRenderChart:"图表渲染失败",failedToRenderDiagram:"流程图渲染失败",heading:"标题",heading1:"一级标题",heading2:"二级标题",heading3:"三级标题",heading4:"四级标题",heading5:"五级标题",heading6:"六级标题",highlightColor:"高亮颜色",holdForDrag:"按住拖动",hideSource:"隐藏源码",image:"图片",imageSubtext:"可调整大小并支持说明的图片",addImage:"添加图片",replaceImage:"替换图片",increaseIndent:"增加缩进",insert:"插入",italic:"斜体",linkEditor:"链接编辑",link:"链接",listItem:"列表项",listWithOrderedItems:"有序项目列表",listWithTasks:"任务列表",listWithUnorderedItems:"无序项目列表",loading:"正在加载...",mention:"提及",mentionSubtext:"提及用户或项目",node:"节点",orderedList:"有序列表",placeholder:"开始输入...",pasteLink:"粘贴链接...",openLinkInNewWindow:"在新窗口打开",recentColors:"最近使用的颜色",recentTextColor:"最近使用的文字颜色",recentHighlightColor:"最近使用的高亮颜色",regularTextParagraph:"普通文本段落",resetFormatting:"清除格式",separator:"分隔线",separatorSubtext:"用于分隔内容的水平线",showSource:"显示源码",style:"样式",subsectionAndGroupHeading:"小节和分组标题",table:"表格",rowActions:"行操作",columnActions:"列操作",tableCellsOption:"单元格选项",insertRowAbove:"在上方插入行",insertRowBelow:"在下方插入行",deleteRow:"删除行",clearRowContents:"清空行内容",insertColumnLeft:"在左侧插入列",insertColumnRight:"在右侧插入列",duplicateRow:"复制行",duplicateColumn:"复制列",moveRowUp:"上移行",moveRowDown:"下移行",moveColumnLeft:"左移列",moveColumnRight:"右移列",sortRowAsc:"行升序排序",sortRowDesc:"行降序排序",sortColumnAsc:"列升序排序",sortColumnDesc:"列降序排序",deleteColumn:"删除列",clearColumnContents:"清空列内容",headerRow:"表头行",headerColumn:"表头列",mergeCells:"合并单元格",splitCell:"拆分单元格",alignLeft:"左对齐",alignCenter:"居中对齐",alignRight:"右对齐",alignTop:"顶部对齐",alignMiddle:"垂直居中",alignBottom:"底部对齐",alignment:"对齐",backgroundColor:"背景颜色",defaultTextColor:"默认文字",grayTextColor:"灰色文字",brownTextColor:"棕色文字",orangeTextColor:"橙色文字",yellowTextColor:"黄色文字",greenTextColor:"绿色文字",blueTextColor:"蓝色文字",purpleTextColor:"紫色文字",pinkTextColor:"粉色文字",redTextColor:"红色文字",defaultBackgroundColor:"默认背景",grayBackgroundColor:"灰色背景",brownBackgroundColor:"棕色背景",orangeBackgroundColor:"橙色背景",yellowBackgroundColor:"黄色背景",greenBackgroundColor:"绿色背景",blueBackgroundColor:"蓝色背景",purpleBackgroundColor:"紫色背景",pinkBackgroundColor:"粉色背景",redBackgroundColor:"红色背景",clearContents:"清空内容",fitToWidth:"适应宽度",deleteTable:"删除表格",tableOfContents:"目录",tableOfContentsSubtext:"插入目录",tableSubtext:"插入表格",taskList:"待办列表",text:"文本",textColor:"文字颜色",textColorOptions:"文字颜色选项",textHighlighter:"文字高亮",highlightColors:"高亮颜色",removeHighlight:"移除高亮",moreOptions:"更多选项",removeLink:"移除链接",strike:"删除线",underline:"下划线",alignJustify:"两端对齐",applyLink:"应用链接",superscript:"上标",subscript:"下标",decreaseIndent:"减少缩进",submitAiPrompt:"发送 AI 提示词",stopAiGeneration:"停止 AI 生成",topLevelHeading:"顶级标题",turnInto:"转换为",turnIntoCurrent:"转换为(当前:{{current}})",tryAgain:"重试",upload:"上传",uploadFailed:"上传失败"},G1={addCaption:"Add a caption...",add:"Add",ai:"AI",aiIsWriting:"AI is writing",aiReviewPrompt:"Tell AI what else needs to be changed...",aiTone:"Tone",apply:"Apply",askAi:"Ask AI",askAiPrompt:"Ask AI what you want...",askAiSubtext:"Ask AI to generate or edit content",blockquote:"Blockquote",blockquoteBlock:"Blockquote block",bulletList:"Bullet List",bold:"Bold",clearAllContents:"Clear all contents",clickForOptions:"Click for options",code:"Code",codeBlock:"Code Block",codeBlockWithSyntaxHighlighting:"Code block with syntax highlighting",color:"Color",continueWriting:"Continue Writing",continueWritingPrompt:"Ask AI to continue writing...",continueWritingSubtext:"Continue writing from the current content",close:"Close",copyAnchorLink:"Copy anchor link",copyToClipboard:"Copy to clipboard",delete:"Delete",discard:"Discard",duplicateNode:"Duplicate node",applyFormula:"Apply formula",closeFormulaEditor:"Close formula editor",editFormula:"Edit formula",emoji:"Emoji",emojiSubtext:"Insert an emoji",failedToRenderChart:"Failed to render chart",failedToRenderDiagram:"Failed to render diagram",heading:"Heading",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",highlightColor:"Highlight color",holdForDrag:"Hold for drag",hideSource:"Hide source",image:"Image",imageSubtext:"Resizable image with caption",addImage:"Add image",replaceImage:"Replace image",increaseIndent:"Increase indent",insert:"Insert",italic:"Italic",linkEditor:"Link Editor",link:"Link",listItem:"List Item",listWithOrderedItems:"List with ordered items",listWithTasks:"List with tasks",listWithUnorderedItems:"List with unordered items",loading:"Connecting...",mention:"Mention",mentionSubtext:"Mention a user or item",node:"Node",orderedList:"Ordered List",placeholder:"Start writing...",pasteLink:"Paste a link...",openLinkInNewWindow:"Open in new window",recentColors:"Recent colors",recentTextColor:"Recent text color",recentHighlightColor:"Recent highlight color",regularTextParagraph:"Regular text paragraph",resetFormatting:"Reset formatting",separator:"Separator",separatorSubtext:"Horizontal line to separate content",showSource:"Show source",style:"Style",subsectionAndGroupHeading:"Subsection and group heading",table:"Table",rowActions:"Row actions",columnActions:"Column actions",tableCellsOption:"Table cells option",insertRowAbove:"Insert row above",insertRowBelow:"Insert row below",deleteRow:"Delete row",clearRowContents:"Clear row contents",insertColumnLeft:"Insert column left",insertColumnRight:"Insert column right",duplicateRow:"Duplicate row",duplicateColumn:"Duplicate column",moveRowUp:"Move row up",moveRowDown:"Move row down",moveColumnLeft:"Move column left",moveColumnRight:"Move column right",sortRowAsc:"Sort row A-Z",sortRowDesc:"Sort row Z-A",sortColumnAsc:"Sort column A-Z",sortColumnDesc:"Sort column Z-A",deleteColumn:"Delete column",clearColumnContents:"Clear column contents",headerRow:"Header row",headerColumn:"Header column",mergeCells:"Merge cells",splitCell:"Split cell",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignTop:"Align top",alignMiddle:"Align middle",alignBottom:"Align bottom",alignment:"Alignment",backgroundColor:"Background color",defaultTextColor:"Default text",grayTextColor:"Gray text",brownTextColor:"Brown text",orangeTextColor:"Orange text",yellowTextColor:"Yellow text",greenTextColor:"Green text",blueTextColor:"Blue text",purpleTextColor:"Purple text",pinkTextColor:"Pink text",redTextColor:"Red text",defaultBackgroundColor:"Default background",grayBackgroundColor:"Gray background",brownBackgroundColor:"Brown background",orangeBackgroundColor:"Orange background",yellowBackgroundColor:"Yellow background",greenBackgroundColor:"Green background",blueBackgroundColor:"Blue background",purpleBackgroundColor:"Purple background",pinkBackgroundColor:"Pink background",redBackgroundColor:"Red background",clearContents:"Clear contents",fitToWidth:"Fit to width",deleteTable:"Delete table",tableOfContents:"Table of contents",tableOfContentsSubtext:"Insert a table of contents",tableSubtext:"Insert a table",taskList:"Task List",text:"Text",textColor:"Text color",textColorOptions:"Text color options",textHighlighter:"Text Highlighter",highlightColors:"Highlight colors",removeHighlight:"Remove highlight",moreOptions:"More options",removeLink:"Remove link",strike:"Strikethrough",underline:"Underline",alignJustify:"Align justify",applyLink:"Apply link",superscript:"Superscript",subscript:"Subscript",decreaseIndent:"Decrease indent",submitAiPrompt:"Submit AI prompt",stopAiGeneration:"Stop AI generation",topLevelHeading:"Top-level heading",turnInto:"Turn into",turnIntoCurrent:"Turn into (current: {{current}})",tryAgain:"Try again",upload:"Upload",uploadFailed:"Upload failed"};function K1(e){return e?e.toLowerCase().startsWith("zh")?qr:G1:qr}function Ie(e,t){return{...K1(e),...t}}const Gr=u.createContext(Ie());function D(){return u.useContext(Gr)}function Y1(e,t){return t==="load"?"loaded":"loading"}function Kr(e,t){return e.src===t?e.state:"loading"}function Yr(e,t,n){return{src:t,state:Y1(Kr(e,t),n)}}function j1(e){const{editor:t,node:n,updateAttributes:o,getPos:r}=e,s=n.content.size>0,i=e.extension.options.i18n??Ie();return l.jsx(X1,{src:n.attrs.src,alt:n.attrs.alt||"",editor:t,align:n.attrs["data-align"],initialWidth:n.attrs.width,showCaption:n.attrs.showCaption,hasContent:s,i18n:i,nodeSize:n.nodeSize,onImageResize:a=>o({width:a}),onUpdateAttributes:o,getPos:r})}const X1=({src:e,alt:t="",editor:n,minWidth:o=96,maxWidth:r=800,align:s="left",initialWidth:i,showCaption:a=!1,hasContent:c=!1,nodeSize:d,onImageResize:f,onUpdateAttributes:p,i18n:h=Ie(),getPos:C})=>{const[g,b]=u.useState(),[m,w]=u.useState(i),[v,y]=u.useState(!1),[x,S]=u.useState({src:e,state:"loading"}),L=u.useRef(!1),I=u.useRef(!0),V=u.useRef(null),K=u.useRef(null),le=u.useRef(null),O=u.useRef(null);u.useEffect(()=>{if(!n||!a)return;const Z=()=>{const oe=C();if(!X(oe)||!d)return;const{from:Cn,to:rt}=n.state.selection,lt=oe,Mr=oe+d;(rt<lt||Cn>Mr)&&!c&&p&&p({showCaption:!1})};return n.on("selectionUpdate",Z),()=>{n.off("selectionUpdate",Z)}},[n,a,c,C,d,p]);const Y=u.useCallback(Z=>{if(!n||!C||g)return;Z.preventDefault(),Z.stopPropagation();const oe=C();X(oe)&&n.chain().focus().setNodeSelection(oe).run()},[n,C,g]),A=u.useCallback(Z=>{if(!g||!n||!I.current)return;const oe="touches"in Z?Z.touches[0]?.clientX??0:Z.clientX,Cn=g.handleUsed==="left",rt=s==="center"?2:1,lt=Cn?(g.initialClientX-oe)*rt:(oe-g.initialClientX)*rt,Mr=g.initialWidth+lt,i1=n.view.dom?.firstElementChild?.clientWidth||r,a1=Math.min(Math.max(Mr,o),i1);w(a1),V.current&&(V.current.style.width=`${a1}px`)},[n,s,r,o,g]),N=u.useCallback(Z=>{if(!n||!I.current)return;const oe="touches"in Z?document.elementFromPoint(Z.changedTouches[0]?.clientX??0,Z.changedTouches[0]?.clientY??0):Z.target;if((!(oe&&V.current?.contains(oe))||!n.isEditable)&&v&&I.current&&y(!1),!g)return;const rt=n.state.selection instanceof E.NodeSelection&&n.state.selection.node.type.name==="image";I.current&&b(void 0),f?.(m);const lt=C();X(lt)&&rt&&I.current&&n.chain().focus().setNodeSelection(lt).run(),L.current=!1},[n,C,f,g,v,m]),U=u.useCallback((Z,oe)=>{b({handleUsed:Z,initialWidth:V.current?.clientWidth??o,initialClientX:oe}),L.current=!0},[o]),H=Z=>{Z.preventDefault(),Z.stopPropagation(),U("left",Z.clientX)},W=Z=>{Z.preventDefault();const oe=Z.touches[0];oe&&U("left",oe.clientX)},P=Z=>{Z.preventDefault(),Z.stopPropagation(),U("right",Z.clientX)},q=Z=>{Z.preventDefault();const oe=Z.touches[0];oe&&U("right",oe.clientX)},$=()=>{n?.isEditable&&I.current&&y(!0)},se=Z=>{I.current&&(Z.relatedTarget===K.current||Z.relatedTarget===le.current||g||n?.isEditable&&y(!1))},be=()=>{n?.isEditable&&I.current&&y(!0)},ot=()=>{S(Z=>Yr(Z,e,"load"))},l1=()=>{S(Z=>Yr(Z,e,"error"))};u.useEffect(()=>(window.addEventListener("mousemove",A),window.addEventListener("mouseup",N),window.addEventListener("touchmove",A,{passive:!1}),window.addEventListener("touchend",N),()=>{window.removeEventListener("mousemove",A),window.removeEventListener("mouseup",N),window.removeEventListener("touchmove",A),window.removeEventListener("touchend",N)}),[A,N]),u.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const s1=a||c,Ve=Kr(x,e)==="loading";return l.jsx(G.NodeViewWrapper,{onMouseEnter:$,onMouseLeave:se,onTouchStart:be,"data-align":s,"data-width":m,className:"tiptap-image",children:l.jsxs("div",{ref:V,className:"tiptap-image-container",style:{width:m?`${m}px`:"fit-content"},children:[l.jsxs("div",{className:"tiptap-image-content tw:min-h-8 tw:min-w-8 tw:justify-center",children:[Ve&&l.jsx("div",{"aria-hidden":"true",className:"tw:absolute tw:inset-0 tw:flex tw:min-h-8 tw:min-w-8 tw:items-center tw:justify-center tw:rounded-[var(--tt-radius-xs)] tw:pointer-events-none",contentEditable:!1,children:l.jsx("span",{className:"tw:size-4 tw:animate-[spin_1s_linear_infinite] tw:rounded-full tw:border-2 tw:border-[var(--tt-gray-light-a-200)] tw:border-t-[var(--tt-brand-color-500)] tw:dark:border-[var(--tt-gray-dark-a-200)] tw:dark:border-t-[var(--tt-brand-color-400)]"})}),l.jsx("img",{ref:O,src:e,alt:t,className:z("tiptap-image-img",Ve&&"tw:invisible"),contentEditable:!1,draggable:!1,referrerPolicy:"same-origin",onLoad:ot,onError:l1,onClick:Y,style:{cursor:n?.isEditable?"pointer":"default"}}),v&&n?.isEditable&&l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:K,className:"tiptap-image-handle tiptap-image-handle-left",onMouseDown:H,onTouchStart:W}),l.jsx("div",{ref:le,className:"tiptap-image-handle tiptap-image-handle-right",onMouseDown:P,onTouchStart:q})]})]}),n?.isEditable&&s1&&l.jsx(G.NodeViewContent,{as:"div",className:"tiptap-image-caption","data-placeholder":h.addCaption})]})})},jr=e=>({src:e.getAttribute("src"),alt:e.getAttribute("alt"),title:e.getAttribute("title"),width:e.getAttribute("width"),height:e.getAttribute("height")});function J1(e){const t={src:e.src||"",referrerpolicy:"same-origin"};return e.alt&&(t.alt=e.alt),e.title&&(t.title=e.title),e.width&&(t.width=e.width),e.height&&(t.height=e.height),t}const Q1=Or.Image.extend({content:"inline*",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1,...this.parent?.(),i18n:Ie()}},addAttributes(){return{...this.parent?.(),"data-align":{default:null},showCaption:{default:!1,parseHTML:e=>e.tagName==="FIGURE"||e.getAttribute("data-show-caption")==="true",renderHTML:e=>e.showCaption?{"data-show-caption":"true"}:{}}}},parseHTML(){return[{tag:"figure",getAttrs:e=>{const t=e.querySelector("img");return t?{...jr(t),"data-align":e.getAttribute("data-align"),showCaption:!0}:!1},contentElement:"figcaption"},{tag:"img[src]",getAttrs:e=>e.closest("figure")?!1:{...jr(e),"data-align":e.getAttribute("data-align"),showCaption:!1}}]},renderHTML({node:e}){const{src:t,alt:n,title:o,width:r,height:s,showCaption:i}=e.attrs,a=e.attrs["data-align"],c=J1({src:t,alt:n,title:o,width:r,height:s}),d=e.content.size>0;if(i||d){const f={"data-url":t||""};return i&&(f["data-show-caption"]="true"),a&&(f["data-align"]=a),["figure",f,["img",c],["figcaption",{},0]]}return a&&(c["data-align"]=a),["img",c]},addKeyboardShortcuts(){const e=(t,n)=>{if(t instanceof E.NodeSelection&&t.node.type===n)return{imageNode:t.node,imagePos:t.from,atStart:!0,atEnd:!0};if(t.empty&&t.$from.parent.type===n){const{$from:o}=t;return{imageNode:o.parent,imagePos:o.before(),atStart:o.parentOffset===0,atEnd:o.parentOffset===o.parent.content.size}}return null};return{"Mod-a":({editor:t})=>{const{state:n,view:o}=t,{selection:r}=n,{$from:s}=r;let i=null,a=null;for(let h=s.depth;h>=0;h--){const C=s.node(h);if(C.type===this.type){a=C,i=h===0?0:s.before(h);break}}if(!a||i==null||a.content.size===0||a.textContent.length===0)return!1;const d=i+1,f=i+a.nodeSize-1,p=n.tr.setSelection(E.TextSelection.create(n.doc,d,f));return o.dispatch(p),!0},ArrowUp:({editor:t})=>{const{state:n}=t,o=e(n.selection,this.type);return!o||!o.atStart||o.imagePos!==0?!1:t.chain().insertContentAt(0,{type:"paragraph"}).setTextSelection(1).run()}}},addNodeView(){return G.ReactNodeViewRenderer(j1)}});function R1(e,t){if(e.length===0)return null;for(const n of e)if((n.node.attrs?.backgroundColor??null)!==t)return t;return null}const ec=we.Extension.create({name:"nodeBackground",addOptions(){return{types:["paragraph","heading","blockquote","taskList","bulletList","orderedList","tableCell","tableHeader"],useStyle:!0}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{const t=e.style?.backgroundColor;return t||e.getAttribute("data-background-color")||null},renderHTML:e=>{const t=e.backgroundColor;return t?this.options.useStyle?{style:`background-color: ${t}`}:{"data-background-color":t}:{}}}}}]},addCommands(){const e=t=>n=>({state:o,tr:r})=>{const s=it(o.selection,this.options.types);if(s.length===0)return!1;const i=t(s,n);return yn(r,s,"backgroundColor",i)};return{setNodeBackgroundColor:e((t,n)=>n||null),unsetNodeBackgroundColor:e(()=>null),toggleNodeBackgroundColor:e((t,n)=>R1(t,n||""))}}});function Xr(e,t,n){if(e.length===0)return null;for(const o of e)if((o.node.attrs?.[t]??null)!==n)return n;return null}const tc=we.Extension.create({name:"nodeAlignment",addOptions(){return{types:["paragraph","heading","blockquote","tableCell","tableHeader"],useStyle:!0,textAlignValues:["left","center","right","justify"],verticalAlignValues:["top","middle","bottom"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{nodeTextAlign:{default:null,parseHTML:e=>{const t=e.style?.textAlign;if(t&&this.options.textAlignValues.includes(t))return t;const n=e.getAttribute("data-node-text-align");return n&&this.options.textAlignValues.includes(n)?n:null},renderHTML:e=>{const t=e.nodeTextAlign;return!t||!this.options.textAlignValues.includes(t)?{}:this.options.useStyle?{style:`text-align: ${t}`}:{"data-node-text-align":t}}},nodeVerticalAlign:{default:null,parseHTML:e=>{const t=e.style?.verticalAlign;if(t&&this.options.verticalAlignValues.includes(t))return t;const n=e.getAttribute("data-node-vertical-align");return n&&this.options.verticalAlignValues.includes(n)?n:null},renderHTML:e=>{const t=e.nodeVerticalAlign;return!t||!this.options.verticalAlignValues.includes(t)?{}:this.options.useStyle?{style:`vertical-align: ${t}`}:{"data-node-vertical-align":t}}}}}]},addCommands(){const e=(t,n)=>o=>({state:r,tr:s})=>{const i=it(r.selection,this.options.types);if(i.length===0)return!1;const a=n(i,o);return yn(s,i,t,a)};return{setNodeTextAlign:e("nodeTextAlign",(t,n)=>!n||!this.options.textAlignValues.includes(n)?null:n),unsetNodeTextAlign:e("nodeTextAlign",()=>null),toggleNodeTextAlign:e("nodeTextAlign",(t,n)=>!n||!this.options.textAlignValues.includes(n)?null:Xr(t,"nodeTextAlign",n)),setNodeVAlign:e("nodeVerticalAlign",(t,n)=>!n||!this.options.verticalAlignValues.includes(n)?null:n),unsetNodeVAlign:e("nodeVerticalAlign",()=>null),toggleNodeVAlign:e("nodeVerticalAlign",(t,n)=>!n||!this.options.verticalAlignValues.includes(n)?null:Xr(t,"nodeVerticalAlign",n)),setNodeAlignment:(t,n)=>({state:o,tr:r})=>{const s=it(o.selection,this.options.types);if(s.length===0)return!1;let i=!1;for(const{node:a,pos:c}of s){const d={...a.attrs};t&&this.options.textAlignValues.includes(t)&&(d.nodeTextAlign=t,i=!0),n&&this.options.verticalAlignValues.includes(n)&&(d.nodeVerticalAlign=n,i=!0),i&&r.setNodeMarkup(c,void 0,d)}return i},unsetNodeAlignment:()=>({state:t,tr:n})=>{const o=it(t.selection,this.options.types);if(o.length===0)return!1;let r=!1;for(const{node:s,pos:i}of o){const a=s.attrs?.nodeTextAlign??null,c=s.attrs?.nodeVerticalAlign??null;if(a||c){const d={...s.attrs,nodeTextAlign:null,nodeVerticalAlign:null};n.setNodeMarkup(i,void 0,d),r=!0}}return r}}}}),Jr=u.createContext(void 0);function nc(e){if(e.length===0)return[];const t=e.map(a=>a.originalLevel??a.level??1),n=t.filter(a=>a>0),o=n.includes(1)?1:Math.min(...n),r=t.map(a=>Math.max(1,a-(o-1))),s=[],i=[];for(let a=0;a<r.length;a++){const c=r[a]??1;for(;i.length>0&&i[i.length-1].level>=c;)i.pop();const d=i.length===0?1:i[i.length-1].depth+1;s.push(d),i.push({level:c,depth:d})}return s}const Qr=e=>{let t=e.parentElement;for(;t;){const{overflowY:n}=getComputedStyle(t);if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return window},oc=(e,t)=>{const n=e.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight;return n.top>=t&&n.bottom>t&&n.top<o},rc=(e,t,n="smooth")=>{if(!(!e.dom||typeof window>"u")){if(!oc(e.dom,t)){const o=Qr(e.dom);if(o instanceof Window){const s=e.dom.getBoundingClientRect().top+window.scrollY-t;window.scrollTo({top:s,behavior:n})}else{const r=e.dom.getBoundingClientRect(),s=o.getBoundingClientRect(),i=r.top-s.top+o.scrollTop-t;o.scrollTo({top:i,behavior:n})}}if(e.editor&&typeof e.pos=="number"&&kn(e.editor,e.pos),e.id){const o=new URL(window.location.href);o.hash=e.id,window.history.replaceState(null,"",o.toString())}}},lc=({children:e})=>{const[t,n]=u.useState(null),o=u.useCallback((r,s)=>{const i=s?.topOffset??0,a=s?.behavior??"smooth";rc(r,i,a)},[]);return l.jsx(Jr.Provider,{value:{tocContent:t,setTocContent:n,navigateToHeading:o,normalizeHeadingDepths:nc},children:e})},Sn=()=>{const e=u.useContext(Jr);if(!e)throw new Error("useToc must be used inside <TocProvider>");return e};function sc(e){const{node:t,extension:n}=e,{tocContent:o,navigateToHeading:r,normalizeHeadingDepths:s}=Sn(),{topOffset:i=0,maxShowCount:a=20,showTitle:c=!0}=n.options,d=t.attrs??{},{backgroundColor:f}=d,p=d.topOffset??i,h=d.maxShowCount??a,C=d.showTitle??c,g=u.useMemo(()=>o??[],[o]),b=u.useMemo(()=>g.slice(0,h),[g,h]),m=u.useMemo(()=>s(b),[b,s]),w=u.useMemo(()=>b.map((S,L)=>({item:S,depth:m[L]??1})),[b,m]),v=u.useCallback((S,L)=>{S.preventDefault(),S.stopPropagation(),r(L,{topOffset:p})},[r,p]),y={...e.HTMLAttributes};delete y.style;const x={className:"tiptap-table-of-contents-node",style:{backgroundColor:f||void 0},...y};return b.length?l.jsxs(G.NodeViewWrapper,{...x,children:[C&&l.jsx("div",{className:"tiptap-table-of-contents-title",children:"Table of contents"}),l.jsx("nav",{"aria-label":"Table of contents",className:"tiptap-table-of-contents-list",children:w.map((S,L)=>l.jsx("a",{href:`#${S.item.id}`,rel:"noopener noreferrer",className:"tiptap-table-of-contents-item notranslate","data-depth":S.depth,style:{"--toc-depth":S.depth},onClick:I=>v(I,S.item),children:S.item.textContent},S.item.id??`${L}-${S.item.textContent}`))})]}):l.jsx(G.NodeViewWrapper,{...x,children:l.jsx("div",{className:"tiptap-table-of-contents-empty",children:"Add headings to create a table of contents."})})}const ic=we.Node.create({name:"tocNode",group:"block customNode",draggable:!0,selectable:!0,atom:!0,addOptions(){return{topOffset:0,maxShowCount:20,showTitle:!0,HTMLAttributes:{}}},addAttributes(){return{topOffset:{default:null,parseHTML:e=>{const t=e.getAttribute("data-top-offset"),n=t!=null?Number(t):null;return Number.isFinite(n)?n:null},renderHTML:e=>e.topOffset==null?{}:{"data-top-offset":e.topOffset}},maxShowCount:{default:null,parseHTML:e=>{const t=e.getAttribute("data-max-show-count"),n=t!=null?Number(t):null;return Number.isFinite(n)?n:null},renderHTML:e=>e.maxShowCount==null?{}:{"data-max-show-count":e.maxShowCount}},showTitle:{default:!0,parseHTML:e=>{const t=e.getAttribute("data-show-title");return t==="false"?!1:t==="true"?!0:null},renderHTML:e=>e.showTitle==null?{}:{"data-show-title":String(e.showTitle)}}}},parseHTML(){return[{tag:'div[data-type="toc-node"]'}]},renderHTML({HTMLAttributes:e}){return["div",we.mergeAttributes(this.options.HTMLAttributes,e,{"data-type":"toc-node"})]},addNodeView(){return G.ReactNodeViewRenderer(sc,{stopEvent:({event:e})=>{if(!(e instanceof MouseEvent))return!1;const t=e.target;return t?!!t.closest(".tiptap-table-of-contents-item"):!1}})},addCommands(){return{insertTocNode:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}}}),ac=new Set(["flowchart","mermaid","mindmap"]);function cc(e){return ac.has(e.trim().toLowerCase())}function Rr(e){const t=e.trim().toLowerCase();return t==="echarts"?"echarts":cc(t)?"mermaid":null}function el(e){return e.replace(/\\r\\n/g,`
|
|
2
2
|
`).replace(/\\n/g,`
|
|
3
3
|
`).replace(/\\r/g,`
|
|
4
|
-
`).replace(/\\t/g," ").replace(/\\(["'`{}\[\](),:])/g,"$1").trim()}function ac(e){const t=Rr(e);try{return JSON.parse(t)}catch{return Function(`"use strict";return (${t})`)()}}function Lt(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function el(e){return Object.hasOwn(e,"top")||Object.hasOwn(e,"bottom")}function cc(e){return Object.hasOwn(e,"left")||Object.hasOwn(e,"right")}function Ke(e){return Array.isArray(e)?e.length>0:!!e}function tl(e,t,n=!1){const o=r=>{const s={...r};return el(s)||(s.top=t),n&&!cc(s)&&(s.left="center"),s};return Array.isArray(e)?e.map(r=>Lt(r)?o(r):r):Lt(e)?o(e):e}function dc(e){return Ke(e.xAxis)||Ke(e.yAxis)}function uc(e){const t=Ke(e.title),n=Ke(e.legend);return t&&n?120:t||n?80:null}function fc(e,t){const n=o=>el(o)?o:{...o,top:t};return Array.isArray(e)?e.map(o=>Lt(o)?n(o):o):Lt(e)?n(e):{top:t}}function pc(e){const t={...e},n=Ke(e.title),o=Ke(e.legend);n&&(t.title=tl(e.title,16,!0)),o&&(t.legend=tl(e.legend,n?64:24,!0));const r=uc(e);return r!==null&&dc(e)&&(t.grid=fc(e.grid,r)),t}function hc(e,t){return typeof e!="string"||!e.trim()?t.code:e.trim()}function Cc({code:e,i18n:t}){const n=u.useRef(null),[o,r]=u.useState(null);return u.useEffect(()=>{const s=n.current;if(!s)return;let i=null,a=null;try{const c=ac(e);i=E1.init(s),i.setOption(pc(c)),r(null),a=new ResizeObserver(()=>i?.resize()),a.observe(s)}catch(c){r(c instanceof Error?c.message:t.failedToRenderChart)}return()=>{a?.disconnect(),i?.dispose()}},[e,t.failedToRenderChart]),l.jsxs("div",{className:"code-block-node__diagram-body",contentEditable:!1,children:[l.jsx("div",{className:"code-block-node__echarts",ref:n}),o?l.jsx("div",{className:"code-block-node__diagram-error",children:o}):null]})}function gc({code:e,i18n:t,language:n}){const o=Qr(n);return o==="echarts"?l.jsx(Cc,{code:e,i18n:t}):o==="mermaid"?l.jsx(bc,{code:e,i18n:t}):null}function bc({code:e,i18n:t}){const n=u.useId(),[o,r]=u.useState(""),[s,i]=u.useState(null);return u.useEffect(()=>{let a=!1;async function c(){try{const d=await y1.render(`code-block-diagram-${n.replace(/:/g,"")}`,Rr(e));a||(r(d.svg),i(null))}catch(d){a||(r(""),i(d instanceof Error?d.message:t.failedToRenderDiagram))}}return c(),()=>{a=!0}},[e,t.failedToRenderDiagram,n]),l.jsxs("div",{className:"code-block-node__diagram-body",contentEditable:!1,children:[o?l.jsx("div",{className:"code-block-node__mermaid",dangerouslySetInnerHTML:{__html:o}}):null,s?l.jsx("div",{className:"code-block-node__diagram-error",children:s}):null]})}function mc(e){const t=e.extension.options.i18n??Ie(),n=hc(e.node.attrs.language,t),r=!!Qr(n),[s,i]=u.useState(r),a=e.node.textContent,c=r&&e.editor.isEditable;return u.useEffect(()=>{i(r)},[r,n]),l.jsxs(G.NodeViewWrapper,{className:"code-block-node","data-collapsed":s?"true":"false","data-diagram":r?"true":"false","data-language":n,children:[l.jsxs("div",{className:"code-block-node__header",contentEditable:!1,children:[l.jsx("span",{className:"code-block-node__language",children:n}),c?l.jsx("button",{type:"button",className:"code-block-node__toggle","aria-expanded":!s,onClick:()=>i(d=>!d),children:s?t.showSource:t.hideSource}):null]}),r?l.jsx(gc,{code:a,i18n:t,language:n}):null,l.jsx("pre",{className:"code-block-node__pre",children:l.jsx(G.NodeViewContent,{className:"code-block-node__content"})})]})}const wc=w1.CodeBlock.extend({addOptions(){return{...this.parent?.(),i18n:Ie()}},addNodeView(){return G.ReactNodeViewRenderer(mc)}}),dt=new E.PluginKey("aiGenerationWidget");function vc(e,t,n){return t?.type==="clear"?{pos:null,status:"idle"}:t?.type==="set"?{pos:t.pos,status:t.status}:e.pos===null?e:{...e,pos:n(e.pos)}}const yc=we.Extension.create({name:"aiGenerationWidget",addStorage(){return{labels:void 0,onApply:void 0,onDiscard:void 0,onRetry:void 0,onStop:void 0,onSubmitInstruction:void 0}},addCommands(){return{clearAiGenerationWidget:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(dt,{type:"clear"}),!0),setAiGenerationWidget:e=>({tr:t,dispatch:n})=>(n&&t.setMeta(dt,{type:"set",...e}),!0)}},addProseMirrorPlugins(){const e=this.editor;return[new E.Plugin({key:dt,state:{init(){return{pos:null,status:"idle"}},apply(t,n){const o=t.getMeta(dt);return vc(n,o,r=>t.mapping.map(r))}},props:{decorations(t){const n=dt.getState(t);if(!n||n.pos===null)return Te.DecorationSet.empty;const o=Math.min(n.pos,t.doc.content.size);return Te.DecorationSet.create(t.doc,[Te.Decoration.widget(o,()=>xc(e.storage.aiGenerationWidget,n.status),{key:`ai-generation-widget-${n.status}`,side:1})])}}})]}});function xc(e,t){return t==="writing"?kc(e):Sc(e)}function kc(e){const t=document.createElement("span"),n=e.labels;t.className="tiptap-ai-widget tiptap-ai-writing-indicator",t.contentEditable="false",t.setAttribute("role","status"),t.setAttribute("aria-live","polite");const o=document.createElement("span");o.className="tiptap-ai-writing-indicator__content";const r=document.createElement("span");r.className="tiptap-ai-writing-indicator__label",r.textContent=n?.aiIsWriting??"AI is writing";const s=document.createElement("span");s.className="tiptap-ai-writing-indicator__dots",s.setAttribute("aria-hidden","true"),s.append(document.createElement("span")),s.append(document.createElement("span")),s.append(document.createElement("span")),o.append(r,s);const i=document.createElement("button");return i.type="button",i.className="tiptap-ai-writing-indicator__stop",i.setAttribute("aria-label",n?.stopAiGeneration??"Stop AI generation"),i.textContent="■",i.addEventListener("click",a=>{a.preventDefault(),e.onStop?.()}),t.append(o,i),t}function Sc(e){const t=document.createElement("span"),n=e.labels;t.className="tiptap-ai-widget tiptap-ai-review",t.contentEditable="false",t.setAttribute("role","dialog"),t.setAttribute("aria-label","AI");const o=document.createElement("span");o.className="tiptap-ai-review__prompt-row";const r=document.createElement("textarea");r.className="tiptap-ai-review__textarea",r.rows=1,r.placeholder=n?.aiReviewPrompt??"Tell AI what else needs to be changed...";const s=document.createElement("button");s.type="button",s.className="tiptap-ai-review__submit",s.setAttribute("aria-label",n?.submitAiPrompt??"Submit AI prompt"),s.textContent="↑",o.append(r,s);const i=document.createElement("span");i.className="tiptap-ai-review__actions";const a=nl("retry",`↻ ${n?.tryAgain??"Try again"}`),c=document.createElement("span");c.className="tiptap-ai-review__spacer";const d=nl("discard",`× ${n?.discard??"Discard"}`),p=document.createElement("button");p.type="button",p.className="tiptap-ai-review__apply",p.dataset.action="apply",p.textContent=`✓ ${n?.apply??"Apply"}`,i.append(a,c,d,p),t.append(o,i);const f=()=>{const h=r?.value.trim();h&&(e.onSubmitInstruction?.(h),r&&(r.value=""))};return r?.addEventListener("keydown",h=>{h.key!=="Enter"||h.shiftKey||(h.preventDefault(),f())}),s.addEventListener("click",h=>{h.preventDefault(),f()}),a.addEventListener("click",h=>{h.preventDefault(),e.onRetry?.()}),d.addEventListener("click",h=>{h.preventDefault(),e.onDiscard?.()}),p.addEventListener("click",h=>{h.preventDefault(),e.onApply?.()}),t}function nl(e,t){const n=document.createElement("button");return n.type="button",n.className="tiptap-ai-review__action",n.dataset.action=e,n.textContent=t,n}function Tc({initialOpen:e=!1,placement:t="top",open:n,onOpenChange:o,delay:r=600,closeDelay:s=0}={}){const[i,a]=u.useState(e),c=n??i,d=o??a,p=z.useFloating({placement:t,open:c,onOpenChange:d,whileElementsMounted:z.autoUpdate,middleware:[z.offset(4),z.flip({crossAxis:t.includes("-"),fallbackAxisSideDirection:"start",padding:4}),z.shift({padding:4})]}),f=p.context,h=z.useHover(f,{mouseOnly:!0,move:!1,restMs:r,enabled:n==null,delay:{close:s}}),C=z.useFocus(f,{enabled:n==null}),g=z.useDismiss(f),b=z.useRole(f,{role:"tooltip"}),m=z.useInteractions([h,C,g,b]);return u.useMemo(()=>({open:c,setOpen:d,...m,...p}),[c,d,m,p])}const Sn=u.createContext(null);function ol(){const e=u.useContext(Sn);if(e==null)throw new Error("Tooltip components must be wrapped in <TooltipProvider />");return e}function rl({children:e,...t}){const n=Tc(t);return t.useDelayGroup?l.jsx(z.FloatingDelayGroup,{delay:{open:t.delay??0,close:t.closeDelay??0},timeoutMs:t.timeout,children:l.jsx(Sn.Provider,{value:n,children:e})}):l.jsx(Sn.Provider,{value:n,children:e})}const ll=u.forwardRef(function({children:t,asChild:n=!1,...o},r){const s=ol(),i=u.isValidElement(t)?parseInt(u.version,10)>=19?t.props.ref:t.ref:void 0,a=z.useMergeRefs([s.refs.setReference,r,i]);if(n&&u.isValidElement(t)){const c={"data-tooltip-state":s.open?"open":"closed"};return u.cloneElement(t,s.getReferenceProps({ref:a,...o,...typeof t.props=="object"?t.props:{},...c}))}return l.jsx("button",{ref:a,"data-tooltip-state":s.open?"open":"closed",...s.getReferenceProps(o),children:t})}),sl=u.forwardRef(function({style:t,children:n,portal:o=!0,portalProps:r={},...s},i){const a=ol(),c=z.useMergeRefs([a.refs.setFloating,i]);if(!a.open)return null;const d=l.jsx("div",{ref:c,style:{...a.floatingStyles,...t},...a.getFloatingProps(s),className:"tiptap-tooltip",children:n});return o?l.jsx(z.FloatingPortal,{...r,children:d}):d});rl.displayName="Tooltip",ll.displayName="TooltipTrigger",sl.displayName="TooltipContent";const Ac=({shortcuts:e})=>e.length===0?null:l.jsx("div",{children:e.map((t,n)=>l.jsxs(u.Fragment,{children:[n>0&&l.jsx("kbd",{children:"+"}),l.jsx("kbd",{children:t})]},n))}),M=u.forwardRef(({className:e,children:t,tooltip:n,showTooltip:o=!0,shortcutKeys:r,variant:s,size:i,...a},c)=>{const d=u.useMemo(()=>J({shortcutKeys:r}),[r]);return!n||!o?l.jsx("button",{"data-slot":"tiptap-button",className:$("tiptap-button",e),ref:c,"data-style":s,"data-size":i,...a,children:t}):l.jsxs(rl,{delay:200,children:[l.jsx(ll,{"data-slot":"tiptap-button",className:$("tiptap-button",e),ref:c,"data-style":s,"data-size":i,...a,children:t}),l.jsxs(sl,{children:[n,l.jsx(Ac,{shortcuts:d})]})]})});M.displayName="Button";const il=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M18.7071 6.70711C19.0976 6.31658 19.0976 5.68342 18.7071 5.29289C18.3166 4.90237 17.6834 4.90237 17.2929 5.29289L12 10.5858L6.70711 5.29289C6.31658 4.90237 5.68342 4.90237 5.29289 5.29289C4.90237 5.68342 4.90237 6.31658 5.29289 6.70711L10.5858 12L5.29289 17.2929C4.90237 17.6834 4.90237 18.3166 5.29289 18.7071C5.68342 19.0976 6.31658 19.0976 6.70711 18.7071L12 13.4142L17.2929 18.7071C17.6834 19.0976 18.3166 19.0976 18.7071 18.7071C19.0976 18.3166 19.0976 17.6834 18.7071 17.2929L13.4142 12L18.7071 6.70711Z",fill:"currentColor"})}));il.displayName="CloseIcon";function Ic(e){const[t,n]=u.useState([]),o=async a=>{if(a.size>e.maxSize){const f=new Error(`File size exceeds maximum allowed (${e.maxSize/1024/1024}MB)`);return e.onError?.(f),null}const c=new AbortController,d=crypto.randomUUID(),p={id:d,file:a,progress:0,status:"uploading",abortController:c};n(f=>[...f,p]);try{if(!e.upload)throw new Error("Upload function is not defined");const f=await e.upload(a,h=>{n(C=>C.map(g=>g.id===d?{...g,progress:h.progress}:g))},c.signal);if(!f)throw new Error("Upload failed: No URL returned");return c.signal.aborted?null:(n(h=>h.map(C=>C.id===d?{...C,status:"success",url:f,progress:100}:C)),e.onSuccess?.(f),f)}catch(f){return c.signal.aborted||(n(h=>h.map(C=>C.id===d?{...C,status:"error",progress:0}:C)),e.onError?.(f instanceof Error?f:new Error("Upload failed"))),null}};return{fileItems:t,uploadFiles:async a=>{if(!a||a.length===0)return e.onError?.(new Error("No files to upload")),[];if(e.limit&&a.length>e.limit)return e.onError?.(new Error(`Maximum ${e.limit} file${e.limit===1?"":"s"} allowed`)),[];const c=a.map(p=>o(p));return(await Promise.all(c)).filter(p=>p!==null)},removeFileItem:a=>{n(c=>{const d=c.find(p=>p.id===a);return d?.abortController&&d.abortController.abort(),d?.url&&URL.revokeObjectURL(d.url),c.filter(p=>p.id!==a)})},clearAllFiles:()=>{t.forEach(a=>{a.abortController&&a.abortController.abort(),a.url&&URL.revokeObjectURL(a.url)}),n([])}}}const al=()=>l.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"tiptap-image-upload-icon",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M11.1953 4.41771C10.3478 4.08499 9.43578 3.94949 8.5282 4.02147C7.62062 4.09345 6.74133 4.37102 5.95691 4.83316C5.1725 5.2953 4.50354 5.92989 4.00071 6.68886C3.49788 7.44783 3.17436 8.31128 3.05465 9.2138C2.93495 10.1163 3.0222 11.0343 3.3098 11.8981C3.5974 12.7619 4.07781 13.5489 4.71463 14.1995C5.10094 14.5942 5.09414 15.2274 4.69945 15.6137C4.30476 16 3.67163 15.9932 3.28532 15.5985C2.43622 14.731 1.79568 13.6816 1.41221 12.5299C1.02875 11.3781 0.91241 10.1542 1.07201 8.95084C1.23162 7.74748 1.66298 6.59621 2.33343 5.58425C3.00387 4.57229 3.89581 3.72617 4.9417 3.10998C5.98758 2.4938 7.15998 2.1237 8.37008 2.02773C9.58018 1.93176 10.7963 2.11243 11.9262 2.55605C13.0561 2.99968 14.0703 3.69462 14.8919 4.58825C15.5423 5.29573 16.0585 6.11304 16.4177 7.00002H17.4999C18.6799 6.99991 19.8288 7.37933 20.7766 8.08222C21.7245 8.78515 22.4212 9.7743 22.7637 10.9036C23.1062 12.0328 23.0765 13.2423 22.6788 14.3534C22.2812 15.4644 21.5367 16.4181 20.5554 17.0736C20.0962 17.3803 19.4752 17.2567 19.1684 16.7975C18.8617 16.3382 18.9853 15.7172 19.4445 15.4105C20.069 14.9934 20.5427 14.3865 20.7958 13.6794C21.0488 12.9724 21.0678 12.2027 20.8498 11.4841C20.6318 10.7655 20.1885 10.136 19.5853 9.6887C18.9821 9.24138 18.251 8.99993 17.5001 9.00002H15.71C15.2679 9.00002 14.8783 8.70973 14.7518 8.28611C14.4913 7.41374 14.0357 6.61208 13.4195 5.94186C12.8034 5.27164 12.0427 4.75043 11.1953 4.41771Z",fill:"currentColor"}),l.jsx("path",{d:"M11 14.4142V21C11 21.5523 11.4477 22 12 22C12.5523 22 13 21.5523 13 21V14.4142L15.2929 16.7071C15.6834 17.0976 16.3166 17.0976 16.7071 16.7071C17.0976 16.3166 17.0976 15.6834 16.7071 15.2929L12.7078 11.2936C12.7054 11.2912 12.703 11.2888 12.7005 11.2864C12.5208 11.1099 12.2746 11.0008 12.003 11L12 11L11.997 11C11.8625 11.0004 11.7343 11.0273 11.6172 11.0759C11.502 11.1236 11.3938 11.1937 11.2995 11.2864C11.297 11.2888 11.2946 11.2912 11.2922 11.2936L7.29289 15.2929C6.90237 15.6834 6.90237 16.3166 7.29289 16.7071C7.68342 17.0976 8.31658 17.0976 8.70711 16.7071L11 14.4142Z",fill:"currentColor"})]}),Lc=()=>l.jsx("svg",{width:"43",height:"57",viewBox:"0 0 43 57",fill:"currentColor",className:"tiptap-image-upload-dropzone-rect-primary",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{d:"M0.75 10.75C0.75 5.64137 4.89137 1.5 10 1.5H32.3431C33.2051 1.5 34.0317 1.84241 34.6412 2.4519L40.2981 8.10876C40.9076 8.71825 41.25 9.5449 41.25 10.4069V46.75C41.25 51.8586 37.1086 56 32 56H10C4.89137 56 0.75 51.8586 0.75 46.75V10.75Z",fill:"currentColor",fillOpacity:"0.11",stroke:"currentColor",strokeWidth:"1.5"})}),Ec=()=>l.jsx("svg",{width:"10",height:"10",className:"tiptap-image-upload-dropzone-rect-secondary",viewBox:"0 0 10 10",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{d:"M0 0.75H0.343146C1.40401 0.75 2.42143 1.17143 3.17157 1.92157L8.82843 7.57843C9.57857 8.32857 10 9.34599 10 10.4069V10.75H4C1.79086 10.75 0 8.95914 0 6.75V0.75Z",fill:"currentColor"})}),Mc=({onFile:e,children:t})=>{const[n,o]=u.useState(!1),[r,s]=u.useState(!1),i=p=>{p.preventDefault(),p.stopPropagation(),s(!0)},a=p=>{p.preventDefault(),p.stopPropagation(),p.currentTarget.contains(p.relatedTarget)||(s(!1),o(!1))},c=p=>{p.preventDefault(),p.stopPropagation(),o(!0)},d=p=>{p.preventDefault(),p.stopPropagation(),s(!1),o(!1);const f=Array.from(p.dataTransfer.files);f.length>0&&e(f)};return l.jsx("div",{className:`tiptap-image-upload-drag-area ${r?"drag-active":""} ${n?"drag-over":""}`,onDragEnter:i,onDragLeave:a,onDragOver:c,onDrop:d,children:t})},Nc=({fileItem:e,onRemove:t})=>{const n=o=>{if(o===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],i=Math.floor(Math.log(o)/Math.log(r));return`${parseFloat((o/Math.pow(r,i)).toFixed(2))} ${s[i]}`};return l.jsxs("div",{className:"tiptap-image-upload-preview",children:[e.status==="uploading"&&l.jsx("div",{className:"tiptap-image-upload-progress",style:{width:`${e.progress}%`}}),l.jsxs("div",{className:"tiptap-image-upload-preview-content",children:[l.jsxs("div",{className:"tiptap-image-upload-file-info",children:[l.jsx("div",{className:"tiptap-image-upload-file-icon",children:l.jsx(al,{})}),l.jsxs("div",{className:"tiptap-image-upload-details",children:[l.jsx("span",{className:"tiptap-image-upload-text",children:e.file.name}),l.jsx("span",{className:"tiptap-image-upload-subtext",children:n(e.file.size)})]})]}),l.jsxs("div",{className:"tiptap-image-upload-actions",children:[e.status==="uploading"&&l.jsxs("span",{className:"tiptap-image-upload-progress-text",children:[e.progress,"%"]}),l.jsx(M,{type:"button",variant:"ghost",onClick:o=>{o.stopPropagation(),t()},children:l.jsx(il,{className:"tiptap-button-icon"})})]})]})]})},Hc=({maxSize:e,limit:t})=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"tiptap-image-upload-dropzone",children:[l.jsx(Lc,{}),l.jsx(Ec,{}),l.jsx("div",{className:"tiptap-image-upload-icon-container",children:l.jsx(al,{})})]}),l.jsxs("div",{className:"tiptap-image-upload-content",children:[l.jsxs("span",{className:"tiptap-image-upload-text",children:[l.jsx("em",{children:"Click to upload"})," or drag and drop"]}),l.jsxs("span",{className:"tiptap-image-upload-subtext",children:["Maximum ",t," file",t===1?"":"s",", ",e/1024/1024,"MB each."]})]})]}),Vc=e=>{const{accept:t,limit:n,maxSize:o}=e.node.attrs,r=u.useRef(null),s=e.extension,i={maxSize:o,limit:n,accept:t,upload:s.options.upload,onSuccess:s.options.onSuccess,onError:s.options.onError},{fileItems:a,uploadFiles:c,removeFileItem:d,clearAllFiles:p}=Ic(i),f=async b=>{const m=await c(b);if(m.length>0){const w=e.getPos();if(X(w)){const v=m.map((y,x)=>{const S=b[x]?.name.replace(/\.[^/.]+$/,"")||"unknown";return{type:s.options.type,attrs:{...s.options,src:y,alt:S,title:S}}});e.editor.chain().focus().deleteRange({from:w,to:w+e.node.nodeSize}).insertContentAt(w,v).run(),D1(e.editor)}}},h=b=>{const m=b.target.files;if(!m||m.length===0){s.options.onError?.(new Error("No file selected"));return}f(Array.from(m))},C=()=>{r.current&&a.length===0&&(r.current.value="",r.current.click())},g=a.length>0;return l.jsxs(G.NodeViewWrapper,{className:"tiptap-image-upload",tabIndex:0,onClick:C,children:[!g&&l.jsx(Mc,{onFile:f,children:l.jsx(Hc,{maxSize:o,limit:n})}),g&&l.jsxs("div",{className:"tiptap-image-upload-previews",children:[a.length>1&&l.jsxs("div",{className:"tiptap-image-upload-header",children:[l.jsxs("span",{children:["Uploading ",a.length," files"]}),l.jsx(M,{type:"button",variant:"ghost",onClick:b=>{b.stopPropagation(),p()},children:"Clear All"})]}),a.map(b=>l.jsx(Nc,{fileItem:b,onRemove:()=>d(b.id)},b.id))]}),l.jsx("input",{ref:r,name:"file",accept:t,type:"file",multiple:n>1,onChange:h,onClick:b=>b.stopPropagation()})]})},Bc=G.Node.create({name:"imageUpload",group:"block",draggable:!0,selectable:!0,atom:!0,addOptions(){return{type:"image",accept:"image/*",limit:1,maxSize:0,upload:void 0,onError:void 0,onSuccess:void 0,HTMLAttributes:{}}},addAttributes(){return{accept:{default:this.options.accept},limit:{default:this.options.limit},maxSize:{default:this.options.maxSize}}},parseHTML(){return[{tag:'div[data-type="image-upload"]'}]},renderHTML({HTMLAttributes:e}){return["div",G.mergeAttributes({"data-type":"image-upload"},e)]},addNodeView(){return G.ReactNodeViewRenderer(Vc)},addCommands(){return{setImageUploadNode:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addKeyboardShortcuts(){return{Enter:({editor:e})=>{const{selection:t}=e.state,{nodeAfter:n}=t.$from;if(n&&n.type.name==="imageUpload"&&e.isActive("imageUpload")){const o=e.view.nodeDOM(t.$from.pos);if(o&&o instanceof HTMLElement){const r=o.firstChild;if(r&&r instanceof HTMLElement)return r.click(),!0}}return!1}}}}),cl=35,ut=120,Dc=40,Et={cells:[],mergedCells:[]};function Tn(e){return e instanceof HTMLElement}function dl(e,t){return e?.closest?.(t)??null}function ul(e){let t=e;for(;t&&t.tagName!=="TD"&&t.tagName!=="TH"&&!t.classList.contains("tableWrapper");){if(t.classList.contains("ProseMirror"))return;t=Tn(t.parentNode)?t.parentNode:null}if(t)return t.tagName==="TD"||t.tagName==="TH"?{type:"cell",domNode:t,tbodyNode:dl(t,"tbody")}:{type:"wrapper",domNode:t,tbodyNode:t.querySelector("tbody")}}function Ue(e,t,n){return Math.max(t,Math.min(e,n))}function fl(e,t,n){return e>=0&&e<n.height&&t>=0&&t<n.width}function Uc(e,t,n,o){if(typeof o=="number")return o;if(e.selection instanceof T.CellSelection){const a=T.selectedRect(e);return n==="row"?a.top:a.left}const r=T.cellAround(e.selection.$anchor)??T.selectionCell(e);if(!r)return null;const s=r.pos-t.start,i=t.map.findCell(s);return n==="row"?i.top:i.left}function Oc(e,t,n,o){return{row:e,column:t,pos:n,node:o,start:n+1,depth:o?o.content.size:0}}function Pc(e){if(!e)return!1;const t=e.attrs.colspan??1,n=e.attrs.rowspan??1;return t>1||n>1}function An(e,t,n,o){if(!e)return Et;const{state:r}=e,s=ne(e,o);if(!s)return Et;const i=s.start,a=s.node,c=s.map,d=Uc(r,s,t,n);if(d===null)return Et;const p=t==="row"?c.height:c.width;if(d<0||d>=p)return Et;const f=[],h=[],C=new Set,g=t==="row"?c.width:c.height;for(let b=0;b<g;b++){const m=t==="row"?d:b,w=t==="row"?b:d,v=m*c.width+w,y=c.map[v];if(y===void 0)continue;const x=i+y,S=a.nodeAt(y);if(!S)continue;const L=Oc(m,w,x,S);Pc(S)&&(C.has(x)||(h.push(L),C.add(x))),f.push(L)}return{cells:f,mergedCells:h}}function pl(e,t,n){const o=ne(e,t);if(!o)return 0;const{doc:r}=e.state,s=n==="row"?o.map.height:o.map.width;let i=0;for(let a=s-1;a>=0;a--){const c=new Set;let d=!0;const p=n==="row"?o.map.width:o.map.height;for(let f=0;f<p;f++){const h=n==="row"?a:f,C=n==="row"?f:a,g=o.map.positionAt(h,C,o.node);if(c.has(g))continue;c.add(g);const b=t+1+g,m=r.nodeAt(b);if(m&&!Oe(m)){d=!1;break}}if(d)i++;else break}return i}function ne(e,t){if(!e)return null;let n=null;if(typeof t=="number"){const r=e.state.doc.nodeAt(t);r?.type.name==="table"&&(n={node:r,pos:t,start:t+1,depth:e.state.doc.resolve(t).depth})}if(!n){const{state:r}=e,s=r.doc.resolve(r.selection.from);n=T.findTable(s)}if(!n)return null;const o=T.TableMap.get(n.node);return o?{...n,map:o}:null}function hl({width:e,height:t,map:n},o){let r=o.top*e+o.left,s=r,i=(o.bottom-1)*e+o.left,a=r+(o.right-o.left-1);for(let c=o.top;c<o.bottom;c++){if(o.left>0&&n[s]==n[s-1]||o.right<e&&n[a]==n[a+1])return!0;s+=e,a+=e}for(let c=o.left;c<o.right;c++){if(o.top>0&&n[r]==n[r-e]||o.bottom<t&&n[i]==n[i+e])return!0;r++,i++}return!1}function In(e,t){const n=e.view,o=n.state.selection,r=o.getBookmark(),s=new Or.Mapping,i=n.dispatch;n.dispatch=a=>{s.appendMapping(a.mapping),i(a)};try{t()}finally{n.dispatch=i}try{const a=r.map(s).resolve(n.state.doc);return n.dispatch(n.state.tr.setSelection(a)),!0}catch{const a=s.map(o.from,-1),c=Ue(a,0,n.state.doc.content.size),d=E.Selection.near(n.state.doc.resolve(c),-1);return n.dispatch(n.state.tr.setSelection(d)),!1}}function Oe(e){if(e.childCount===0)return!0;let t=!0;return e.descendants(n=>n.isText&&n.text?.trim()||n.isLeaf&&!n.isText?(t=!1,!1):!0),t}function Q(e,t,n,o){if(typeof t=="number"&&n)return{orientation:n,index:t};if(!e)return null;const{state:r}=e;if(!ne(e,o))return null;if(r.selection instanceof T.CellSelection){const i=T.selectedRect(r),a=i.right-i.left,c=i.bottom-i.top;return c===1&&a>=1?{orientation:"row",index:i.top}:a===1&&c>=1?{orientation:"column",index:i.left}:null}return null}function ge(e,t,n,o){const r={cells:[],mergedCells:[],index:void 0,orientation:void 0,tablePos:void 0};if(!e||typeof t!="number"&&!(e.state.selection instanceof T.CellSelection))return r;let s=t,i=n;if(typeof s!="number"||!i||!["row","column"].includes(i)){const c=Q(e);if(!c)return r;s=c.index,i=c.orientation}return{...An(e,i,s,o),index:s,orientation:i}}function Cl(e,t,n){return An(e,"row",t,n)}function gl(e,t,n){return An(e,"column",t,n)}function Ln(e,t,n,o){try{const r=ne(e,o);if(!r)return;const{state:s}=e,{map:i}=r;if(t==="row"){if(n>=0&&n<i.height){const c=i.width-1,d=r.start+i.positionAt(n,0,r.node),p=r.start+i.positionAt(n,c,r.node),f=s.doc.resolve(d),h=s.doc.resolve(p),C=T.CellSelection.create(s.doc,f.pos,h.pos),g=s.tr.setSelection(C);e.view.dispatch(g)}}else if(t==="column"&&n>=0&&n<i.width){const c=i.height-1,d=r.start+i.positionAt(0,n,r.node),p=r.start+i.positionAt(c,n,r.node),f=s.doc.resolve(d),h=s.doc.resolve(p),C=T.CellSelection.create(s.doc,f.pos,h.pos),g=s.tr.setSelection(C);e.view.dispatch(g)}}catch(r){console.warn("Failed to update selection after move:",r)}}function Wc(e,t){return function(n,o){if(!T.isInTable(n))return!1;const r=T.selectionCell(n),s=typeof e=="string"?{[e]:t}:e;if(o){const i=n.tr;n.selection instanceof T.CellSelection?n.selection.forEachCell((a,c)=>{Object.entries(s).some(([p,f])=>a.attrs[p]!==f)&&i.setNodeMarkup(c,null,{...a.attrs,...s})}):Object.entries(s).some(([c,d])=>r.nodeAfter.attrs[c]!==d)&&i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,...s}),o(i)}return!0}}function _c(e,t){return pl(e,t,"row")}function Zc(e,t){return pl(e,t,"column")}function Fc(e,t=.3){const n=Math.floor(e),o=Math.ceil(e),r=n+t,s=o-t;return e<r?n:e>s?o:Math.round(e)}function bl(e,t){return!e&&!t?!0:!e||!t?!1:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function zc(e,t,n){switch(n.mode??"state"){case"dispatch":{const r=n;typeof r.dispatch=="function"&&r.dispatch(t);return}case"transaction":return t;default:return e.apply(t)}}function ke(e,t,n,o={mode:"state"}){if(!e)return;const r=ne(e,t);if(!r)return;const{state:s}=e,i=r.map,a=n.map(w=>({row:Ue(w.row,0,i.height-1),col:Ue(w.col,0,i.width-1)})).filter(w=>fl(w.row,w.col,i));if(a.length===0)return;const c=a.map(w=>w.row),d=Math.min(...c),p=Math.max(...c),f=a.map(w=>w.col),h=Math.min(...f),C=Math.max(...f),g=(w,v)=>{const y=i.map[w*i.width+v];return y===void 0?null:t+1+y},b=g(d,h);if(b===null)return;let m=g(p,C);if(m!==null){if(m===b){let w=!1;for(let v=p;v>=d&&!w;v--)for(let y=C;y>=h&&!w;y--){const x=g(v,y);x!==null&&x!==b&&(m=x,w=!0)}}try{const w=s.doc.resolve(b),v=s.doc.resolve(m),y=new T.CellSelection(w,v),x=s.tr.setSelection(y);return zc(s,x,o)}catch(w){console.error("Failed to create cell selection:",w);return}}}function $c({editor:e,row:t,col:n,tablePos:o,dispatch:r}){if(!e)return!1;const{state:s,view:i}=e,a=ne(e,o);if(!a||!fl(t,n,a.map))return!1;const c=a.map.positionAt(t,n,a.node),d=a.start+c,p=s.doc.resolve(d),f=T.cellAround(p),h=f?f.pos:d,C=T.CellSelection.create(s.doc,h),g=r??i?.dispatch;return g?(g(s.tr.setSelection(C)),!0):!1}function En(e,t,n,o){const r=T.TableMap.get(t),s=o==="row",i=s?r.height-1:0,a=s?0:r.width-1,c=i*r.width+a,d=r.map[c];if(!d&&d!==0)return console.warn("selectLastCell: cell position not found in map",{index:c,row:i,col:a,map:r}),!1;const p=r.map.indexOf(d),f=p>=0?Math.floor(p/r.width):0,h=p>=0?p%r.width:0;return $c({editor:e,row:f,col:h,tablePos:n,dispatch:e.view.dispatch.bind(e.view)})}function Pe({editor:e,index:t,orientation:n,tablePos:o}){if(!e)return null;const r=ne(e,o);if(!r)return null;const{map:s}=r,{width:i,height:a}=s;return t<0||n==="row"&&t>=a||n==="column"&&t>=i?null:n==="row"?Array.from({length:s.width},(c,d)=>({row:t,col:d})):Array.from({length:s.height},(c,d)=>({row:d,col:t}))}function ml(e,t,n){if(!t)return null;try{const o=n.view.posAtDOM(e,0),r=n.view.state.doc.resolve(o);for(let s=r.depth;s>0;s--){const i=r.node(s);if(i.type.name==="tableCell"||i.type.name==="tableHeader"){const a=T.TableMap.get(t),c=r.before(s),d=r.start(s-2),p=c-d,f=a.map.indexOf(p);return{rowIndex:Math.floor(f/a.width),colIndex:f%a.width}}}}catch(o){console.warn("Could not get cell position:",o)}return null}function qc(e,t){try{const n=t.view.posAtDOM(e,0),o=t.view.state.doc.resolve(n);for(let r=o.depth;r>=0;r--){const s=o.node(r);if(wl(s))return{node:s,pos:r===0?0:o.before(r)}}}catch(n){console.warn("Could not get table from DOM:",n)}return null}function wl(e){return!!e&&(e.type.name==="table"||e.type.spec.tableRole==="table")}const Gc=x1.Table.extend({addProseMirrorPlugins(){const e=this.options.resizable&&this.editor.isEditable,t=this.options.cellMinWidth<ut?ut:this.options.cellMinWidth;return[Kc(),...e?[T.columnResizing({handleWidth:this.options.handleWidth,cellMinWidth:cl,defaultCellMinWidth:t,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],T.tableEditing({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){return({node:e,HTMLAttributes:t})=>{class n extends T.TableView{blockContainer;innerTableContainer;widgetsContainer;overlayContainer;containerAttributes;constructor(s,i,a){super(s,i),this.containerAttributes=a??{},this.blockContainer=this.createBlockContainer(),this.innerTableContainer=this.createInnerTableContainer(),this.widgetsContainer=this.createWidgetsContainer(),this.overlayContainer=this.createOverlayContainer(),this.setupDOMStructure()}createBlockContainer(){const s=document.createElement("div");return s.setAttribute("data-content-type","table"),this.applyContainerAttributes(s),s}createInnerTableContainer(){const s=document.createElement("div");return s.className="table-container",s}createWidgetsContainer(){const s=document.createElement("div");return s.className="table-controls",s.style.position="relative",s}createOverlayContainer(){const s=document.createElement("div");return s.className="table-selection-overlay-container",s}applyContainerAttributes(s){Object.entries(this.containerAttributes).forEach(([i,a])=>{i!=="class"&&s.setAttribute(i,a)})}setupDOMStructure(){const s=this.dom,i=s.firstChild;this.innerTableContainer.appendChild(i),s.appendChild(this.innerTableContainer),s.appendChild(this.widgetsContainer),s.appendChild(this.overlayContainer),this.blockContainer.appendChild(s),this.dom=this.blockContainer}ignoreMutation(s){return!s.target.closest(".table-container")||super.ignoreMutation(s)}}const o=this.options.cellMinWidth<ut?ut:this.options.cellMinWidth;return new n(e,o,t)}}});function Kc(){return new E.Plugin({props:{handleDOMEvents:{mousedown(e,t){return Yc(e.editable,t)}}}})}function Yc(e,t){if(e||!t.target)return!1;const n=t.target.closest;return typeof n!="function"||!!!n.call(t.target,"[data-content-type=table], .tableWrapper")?!1:(t.preventDefault(),!0)}const jc=Be.TableCell.extend({addKeyboardShortcuts(){return{...this.parent?.(),"Mod-a":()=>{const{state:e,view:t}=this.editor,{selection:n,doc:o}=e,r=n.$anchor,s=T.cellAround(r);if(!s)return!1;const i=o.nodeAt(s.pos);if(!i||!i.textContent)return!1;const a=s.pos+1,c=s.pos+i.nodeSize-1;if(a>=c)return!0;const d=o.resolve(a),p=o.resolve(c),f=E.TextSelection.between(d,p,1);return!f||e.selection.eq(f)||t.dispatch(e.tr.setSelection(f)),!0}}}}),Xc=we.Extension.create({name:"tableKit",addExtensions(){const e=[];return this.options.table!==!1&&e.push(Gc.configure(this.options.table)),this.options.tableCell!==!1&&e.push(jc.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(Be.TableHeader.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(Be.TableRow.configure(this.options.tableRow)),e}}),Jc=["boxSizing","backgroundColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","paddingTop","paddingRight","paddingBottom","paddingLeft","color","font","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textTransform","textDecoration","textAlign","verticalAlign","whiteSpace","width","minWidth","maxWidth","height","minHeight","maxHeight","backgroundClip"],vl=e=>e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase());function Qc(e,t){const n=getComputedStyle(e);for(const o of Jc){const r=String(o),s=n.getPropertyValue(vl(r));s&&t.style.setProperty(vl(r),s)}t.style.overflow="hidden",t.style.textOverflow="ellipsis",(n.whiteSpace===""||n.whiteSpace==="normal")&&(t.style.whiteSpace="nowrap")}function yl(e){const t=e.cloneNode(!0),n=[{src:e,dst:t}];for(;n.length;){const{src:o,dst:r}=n.shift();o instanceof HTMLElement&&r instanceof HTMLElement&&Qc(o,r);const s=Array.from(o.children),i=Array.from(r.children),a=Math.min(s.length,i.length);for(let c=0;c<a;c++){const d=s[c],p=i[c];d&&p&&n.push({src:d,dst:p})}}return t}function Rc(e,t){Object.assign(e.style,{position:"fixed",top:"-10000px",left:"-10000px",pointerEvents:"none",zIndex:"2147483647",maxWidth:`${t}px`,borderRadius:"12px",background:"transparent",filter:"drop-shadow(0 8px 24px rgba(0,0,0,0.18)) drop-shadow(0 2px 8px rgba(0,0,0,0.10))",overflow:"hidden"})}function e2(e,t){e.isConnected||document.body.appendChild(e);const n=e.getBoundingClientRect();if(n.width>t&&n.width>0){const o=t/n.width;e.style.transformOrigin="top left",e.style.transform=`scale(${o})`}}function xl(e,t){const n=getComputedStyle(e);t.style.borderCollapse=n.borderCollapse,t.style.borderSpacing=n.borderSpacing,t.style.tableLayout="fixed",t.className=e.className}function kl(e,t){const n=e.getBoundingClientRect();n.width>0&&(t.style.width=`${n.width}px`,t.style.maxWidth=`${n.width}px`)}function t2(e,t){const n=e.tBodies?.[0]??e.querySelector("tbody");if(!n)return null;const o=n.rows?.[t];if(!o)return null;const r=document.createElement("table"),s=document.createElement("tbody"),i=yl(o);xl(e,r);for(let a=0;a<o.cells.length;a++){const c=o.cells[a],d=i.cells[a];d&&kl(c,d)}return s.appendChild(i),r.appendChild(s),r}function n2(e,t){const n=e.tBodies?.[0]??e.querySelector("tbody");if(!n)return null;const o=document.createElement("table"),r=document.createElement("tbody");xl(e,o);let s=0;for(let i=0;i<n.rows.length;i++){const a=n.rows[i];if(!a)continue;const c=a.cells?.[t];if(!c)continue;const d=document.createElement("tr"),p=yl(c),f=c.getBoundingClientRect();!s&&f.width>0&&(s=f.width),kl(c,p),d.appendChild(p),r.appendChild(d)}return s>0&&(o.style.width=`${s}px`,o.style.maxWidth=`${s}px`),o.appendChild(r),o}function o2(e,t,n,o){const r=e.view.dom.getBoundingClientRect(),s=Math.max(0,r.width),i=document.createElement("div");Rc(i,s);const a=e.view.nodeDOM(o);if(!a)return document.body.appendChild(i),i;const c=a.getBoundingClientRect(),d=Math.min(c.width,r.width);i.style.width=`${d}px`;const p=t==="row"?t2(a,n):n2(a,n);if(p){const f=document.createElement("div");Object.assign(f.style,{background:"var(--drag-image-bg, transparent)",overflow:"hidden"}),f.appendChild(p),i.appendChild(f)}return e2(i,s),i}function r2(e,t){t.querySelectorAll(e).forEach(n=>{n.style.visibility="hidden"})}const Le=new E.PluginKey("tableHandlePlugin");class l2{editor;editorView;state=void 0;menuFrozen=!1;mouseState="up";tableId;tablePos;tableElement;emitUpdate;constructor(t,n,o){this.editor=t,this.editorView=n,this.emitUpdate=()=>this.state&&o(this.state),this.editorView.dom.addEventListener("mousemove",this.mouseMoveHandler),this.editorView.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),this.editorView.root.addEventListener("dragover",this.dragOverHandler),this.editorView.root.addEventListener("drop",this.dropHandler)}viewMousedownHandler=t=>{this.mouseState="down";const{state:n,view:o}=this.editor;if(!(n.selection instanceof T.CellSelection)||this.editor.isFocused)return;const r=o.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return;const s=n.doc.resolve(r.pos),{nodes:i}=n.schema;let a=-1,c=!1;for(let h=s.depth;h>=0;h--){const C=s.node(h);if(!c&&(C.type===i.tableCell||C.type===i.tableHeader)&&(c=!0),a===-1&&C.type===i.paragraph&&(a=h),c&&a!==-1)break}if(!c||a===-1)return;const d=s.start(a),p=s.end(a),f=E.TextSelection.create(n.doc,d,p);n.selection.eq(f)||(o.dispatch(n.tr.setSelection(f)),o.focus())};mouseUpHandler=t=>{this.mouseState="up",this.mouseMoveHandler(t)};mouseMoveHandler=t=>{if(this.menuFrozen||this.mouseState==="selecting")return;const n=t.target;!Tn(n)||!this.editorView.dom.contains(n)||this._handleMouseMoveNow(t)};hideHandles(){this.state?.show&&(this.state={...this.state,show:!1,showAddOrRemoveRowsButton:!1,showAddOrRemoveColumnsButton:!1,colIndex:void 0,rowIndex:void 0,referencePosCell:void 0},this.emitUpdate())}_handleMouseMoveNow(t){const n=ul(t.target);if(n?.type==="cell"&&this.mouseState==="down"&&!this.state?.draggingState){this.mouseState="selecting",this.hideHandles();return}if(!n||!this.editor.isEditable){this.hideHandles();return}const o=n.tbodyNode;if(!o)return;const r=o.getBoundingClientRect(),s=this.editor.view.posAtCoords({left:t.clientX,top:t.clientY});if(!s)return;const i=this.editor.view.state.doc.resolve(s.pos);let a;for(let p=i.depth;p>=0;p--){const f=i.node(p);if(wl(f)){a={node:f,pos:p===0?0:i.before(p)};break}}if(!a||a.node.type.name!=="table")return;this.tableElement=this.editor.view.nodeDOM(a.pos),this.tablePos=a.pos,this.tableId=a.node.attrs.id;const d=dl(n.domNode,".tableWrapper")?.querySelector(".table-controls");if(n.type==="wrapper"){const p=t.clientY>=r.bottom-1&&t.clientY<r.bottom+20,f=t.clientX>=r.right-1&&t.clientX<r.right+20,h=t.clientX>r.right||t.clientY>r.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:p,showAddOrRemoveColumnsButton:f,referencePosTable:r,block:a.node,blockPos:a.pos,widgetContainer:d,colIndex:h?void 0:this.state?.colIndex,rowIndex:h?void 0:this.state?.rowIndex,referencePosCell:h?void 0:this.state?.referencePosCell}}else{const p=ml(n.domNode,a.node,this.editor);if(!p)return;const{rowIndex:f,colIndex:h}=p,C=n.domNode.getBoundingClientRect(),g=a.node.content.childCount-1,b=(a.node.content.firstChild?.content.childCount??0)-1;if(this.state?.show&&this.tableId===a.node.attrs.id&&this.state.rowIndex===f&&this.state.colIndex===h)return;this.state={show:!0,showAddOrRemoveColumnsButton:h===b,showAddOrRemoveRowsButton:f===g,referencePosTable:r,block:a.node,blockPos:a.pos,draggingState:void 0,referencePosCell:C,colIndex:h,rowIndex:f,widgetContainer:d}}return this.emitUpdate(),!1}dragOverHandler=t=>{if(this.state?.draggingState===void 0)return;t.preventDefault(),t.dataTransfer.dropEffect="move",r2(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.editorView.root);const{left:n,right:o,top:r,bottom:s}=this.state.referencePosTable,i={left:Ue(t.clientX,n+1,o-1),top:Ue(t.clientY,r+1,s-1)},a=this.editorView.root.elementsFromPoint(i.left,i.top).filter(v=>v.tagName==="TD"||v.tagName==="TH");if(a.length===0)return;const c=a[0];if(!Tn(c))return;const d=ml(c,this.state.block,this.editor);if(!d)return;const{rowIndex:p,colIndex:f}=d,h=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,g=(this.state.draggingState.draggedCellOrientation==="row"?p:f)!==h,b=this.state.draggingState.draggedCellOrientation==="row"?i.top:i.left,m=this.state.rowIndex!==p||this.state.colIndex!==f,w=this.state.draggingState.mousePos!==b;(m||w)&&(this.state={...this.state,rowIndex:p,colIndex:f,referencePosCell:c.getBoundingClientRect(),draggingState:{...this.state.draggingState,mousePos:b}},this.emitUpdate()),g&&this.editor.view.dispatch(this.editor.state.tr.setMeta(Le,!0))};dropHandler=()=>{this.mouseState="up";const t=this.state;if(!t?.draggingState)return!1;const{draggingState:n,rowIndex:o,colIndex:r,blockPos:s}=t;if(!X(s))return!1;if(n.draggedCellOrientation==="row"&&o===void 0||n.draggedCellOrientation==="col"&&r===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");const i=n.draggedCellOrientation==="row",a=i?"row":"column",c=i?o:r,d=Pe({editor:this.editor,index:n.originalIndex,orientation:a,tablePos:s});if(!d)return!1;const p=ke(this.editor,s,d,{mode:"state"});if(!p)return!1;const f=h=>this.editor.view.dispatch(h);return i?T.moveTableRow({from:n.originalIndex,to:c,select:!0,pos:s+1})(p,f):T.moveTableColumn({from:n.originalIndex,to:c,select:!0,pos:s+1})(p,f),this.state={...t,draggingState:void 0},this.emitUpdate(),this.editor.view.dispatch(this.editor.state.tr.setMeta(Le,null)),!0};update(t){const n=Le.getState(t.state);if(n!==void 0&&n!==this.menuFrozen&&(this.menuFrozen=n),!this.state?.show)return;if(!this.tableElement?.isConnected){this.hideHandles();return}const o=qc(this.tableElement,this.editor);if(!o){this.hideHandles();return}const r=this.state.block!==o.node||this.state.blockPos!==o.pos;if(!o.node||o.node.type.name!=="table"||!this.tableElement?.isConnected){this.hideHandles();return}const{height:s,width:i}=T.TableMap.get(o.node);let a=this.state.rowIndex,c=this.state.colIndex;a!==void 0&&a>=s&&(a=s?s-1:void 0),c!==void 0&&c>=i&&(c=i?i-1:void 0);const d=this.tableElement.querySelector("tbody");if(!d)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");let p=this.state.referencePosCell;if(a!==void 0&&c!==void 0){const b=d.children[a]?.children[c];b?p=b.getBoundingClientRect():(a=void 0,c=void 0,p=void 0)}const f=d.getBoundingClientRect(),h=a!==this.state.rowIndex||c!==this.state.colIndex,C=p!==this.state.referencePosCell||f!==this.state.referencePosTable;(r||h||C)&&(this.state={...this.state,block:o.node,blockPos:o.pos,rowIndex:a,colIndex:c,referencePosCell:p,referencePosTable:f},this.emitUpdate())}destroy(){this.editorView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.editorView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.editorView.root.removeEventListener("dragover",this.dragOverHandler),this.editorView.root.removeEventListener("drop",this.dropHandler)}}let j=null;function s2(e,t){return new E.Plugin({key:Le,state:{init:()=>!1,apply:(n,o)=>{const r=n.getMeta(Le);return r!==void 0?r:o}},view:n=>(j=new l2(e,n,t),j),props:{decorations:n=>{if(!j)return null;if(j===void 0||j.state===void 0||j.state.draggingState===void 0||j.tablePos===void 0)return;const o=j.state.draggingState.draggedCellOrientation==="row"?j.state.rowIndex:j.state.colIndex;if(o===void 0)return;const r=[],{draggingState:s}=j.state,{originalIndex:i}=s;return j.state.draggingState.draggedCellOrientation==="row"?Cl(e,i,j.state.blockPos).cells.forEach(c=>{c.node&&r.push(Te.Decoration.node(c.pos,c.pos+c.node.nodeSize,{class:"table-cell-dragging-source"}))}):gl(e,i,j.state.blockPos).cells.forEach(c=>{c.node&&r.push(Te.Decoration.node(c.pos,c.pos+c.node.nodeSize,{class:"table-cell-dragging-source"}))}),o===i||!e||(j.state.draggingState.draggedCellOrientation==="row"?Cl(e,o,j.state.blockPos).cells.forEach(c=>{const d=c.node;if(!d)return;const p=c.pos+(o>i?d.nodeSize-2:2);r.push(Te.Decoration.widget(p,()=>{const f=document.createElement("div");return f.className="tiptap-table-dropcursor",f.style.left="0",f.style.right="0",o>i?f.style.bottom="-1px":f.style.top="-1px",f.style.height="3px",f}))}):gl(e,o,j.state.blockPos).cells.forEach(c=>{const d=c.node;if(!d)return;const p=c.pos+(o>i?d.nodeSize-2:2);r.push(Te.Decoration.widget(p,()=>{const f=document.createElement("div");return f.className="tiptap-table-dropcursor",f.style.top="0",f.style.bottom="0",o>i?f.style.right="-1px":f.style.left="-1px",f.style.width="3px",f}))})),Te.DecorationSet.create(n.doc,r)}}})}const Sl=(e,t)=>{if(!j?.state)throw new Error(`Attempted to drag table ${e}, but no table block was hovered prior.`);const{state:n,editor:o}=j,r=e==="col"?n.colIndex:n.rowIndex;if(r===void 0)throw new Error(`Attempted to drag table ${e}, but no table block was hovered prior.`);const{blockPos:s,referencePosCell:i}=n,a=e==="col"?t.clientX:t.clientY;if(o.state.selection instanceof T.CellSelection){const f=E.TextSelection.near(o.state.doc.resolve(s),1);o.view.dispatch(o.state.tr.setSelection(f))}const c=o2(o,e,r,s);if(t.dataTransfer){const f=t.currentTarget.getBoundingClientRect(),h=e==="col"?{x:f.width/2,y:0}:{x:0,y:f.height/2};t.dataTransfer.effectAllowed=e==="col"?"move":"copyMove",t.dataTransfer.setDragImage(c,h.x,h.y)}const d=()=>c.parentNode?.removeChild(c);document.addEventListener("drop",d,{once:!0}),document.addEventListener("dragend",d,{once:!0});const p=i?(e==="col"?i.left:i.top)-a:0;j.state={...n,draggingState:{draggedCellOrientation:e,originalIndex:r,mousePos:a,initialOffset:p}},j.emitUpdate(),o.view.dispatch(o.state.tr.setMeta(Le,!0))},i2=e=>Sl("col",{...e,clientY:0}),a2=e=>Sl("row",{...e,clientX:0}),c2=()=>{if(!j||j.state===void 0)return;j.state={...j.state,draggingState:void 0},j.emitUpdate();const e=j.editor;e.view.dispatch(e.state.tr.setMeta(Le,null))},d2=we.Extension.create({name:"tableHandleExtension",addCommands(){return{freezeHandles:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(Le,!0),!0),unfreezeHandles:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(Le,!1),!0)}},addProseMirrorPlugins(){const{editor:e}=this;return[s2(e,t=>{this.editor.emit("tableHandleState",t)})]}});function u2(e,t,n){if(n?.draggedCellOrientation==="row"){const o=n.mousePos+(n.initialOffset??0),r=Ue(o,t.y,t.bottom-e.height);return new DOMRect(t.x,r,t.width,e.height)}return new DOMRect(t.x,e.y,t.width,e.height)}function f2(e,t,n){if(n?.draggedCellOrientation==="col"){const o=n.mousePos+(n.initialOffset??0),r=Ue(o,t.x,t.right-e.width);return new DOMRect(r,t.y,e.width,t.height)}return new DOMRect(e.x,t.y,e.width,t.height)}function p2(e){return new DOMRect(e.x,e.y,e.width,0)}function h2(e){switch(e){case"row":return"left";case"col":return"top";default:return"bottom-end"}}function C2(e){switch(e){case"row":return 4;case"col":return 4;default:return{mainAxis:1,crossAxis:-1}}}function g2(e,t,n,o){switch(e){case"row":return u2(t,n,o);case"col":return f2(t,n,o);default:return p2(t)}}function Mn(e,t,n,o,r){const s=u.useMemo(()=>h2(e),[e]),i=u.useMemo(()=>C2(e),[e]),{refs:a,update:c,context:d,floatingStyles:p}=z.useFloating({open:t,placement:s,middleware:[z.offset(i),z.size({apply({rects:C,elements:g}){if(!g.floating)return;const b=(e==="col"?n?.width??o?.width:o?.width)??C.reference.width,m=(e==="row"?n?.height??o?.height:o?.height)??C.reference.height;g.floating.style.setProperty("--table-handle-ref-width",`${b}px`),g.floating.style.setProperty("--table-handle-ref-height",`${m}px`);const w=e==="row"?m:b;g.floating.style.setProperty("--table-handle-available-size",`${w}px`)}})]}),{isMounted:f,styles:h}=z.useTransitionStyles(d);return u.useEffect(()=>{c()},[c,t,e,n,o,r]),u.useEffect(()=>{!n||!o||r&&e==="cell"||a.setReference({getBoundingClientRect:()=>g2(e,n,o,r)})},[a,e,n,o,r]),u.useMemo(()=>({isMounted:f,ref:a.setFloating,style:{display:"flex",...h,...p}}),[f,a.setFloating,h,p])}function b2(e,t,n,o){const r=Mn("row",e,t,n,o),s=Mn("col",e,t,n,o),i=Mn("cell",e,t,n,o);return u.useMemo(()=>({rowHandle:r,colHandle:s,cellHandle:i}),[r,s,i])}function Nn(e={}){const{editor:t,initialState:n=null,watchFields:o,onStateChange:r}=e,{editor:s}=k(t),[i,a]=u.useState(n),c=u.useRef(n),d=u.useCallback(p=>{o&&c.current&&!o.some(h=>c.current[h]!==p[h])||(a(p),c.current=p,r?.(p))},[o,r]);return u.useEffect(()=>{if(!s){a(null),c.current=null,r?.(null);return}return s.on("tableHandleState",d),()=>{s.off("tableHandleState",d)}},[s,r,d]),i}const Mt=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12C14 13.1046 13.1046 14 12 14C10.8954 14 10 13.1046 10 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 5C10 3.89543 10.8954 3 12 3C13.1046 3 14 3.89543 14 5C14 6.10457 13.1046 7 12 7C10.8954 7 10 6.10457 10 5Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 19C10 17.8954 10.8954 17 12 17C13.1046 17 14 17.8954 14 19C14 20.1046 13.1046 21 12 21C10.8954 21 10 20.1046 10 19Z",fill:"currentColor"})]}));Mt.displayName="MoreVerticalIcon";function Tl({className:e,type:t,...n}){return l.jsx("input",{type:t,"data-slot":"tiptap-input",className:$("tiptap-input",e),...n})}Cn.cva("tiptap-input-group-addon",{variants:{align:{"inline-start":"tiptap-input-group-addon--inline-start","inline-end":"tiptap-input-group-addon--inline-end","block-start":"tiptap-input-group-addon--block-start","block-end":"tiptap-input-group-addon--block-end"}},defaultVariants:{align:"inline-start"}}),Cn.cva("tiptap-input-group-button",{variants:{size:{xs:"tiptap-input-group-button--xs",sm:"tiptap-input-group-button--sm","icon-xs":"tiptap-input-group-button--icon-xs","icon-sm":"tiptap-input-group-button--icon-sm"}},defaultVariants:{size:"xs"}});function m2({...e}){return l.jsx(ce.ComboboxProvider,{includesBaseElement:!1,resetValueOnHide:!0,...e})}function Hn({className:e,...t}){return l.jsx(ce.Combobox,{autoSelect:!0,...t,className:$("tiptap-combobox",e)})}function Ye({className:e,...t}){return l.jsx(ce.ComboboxList,{"data-slot":"tiptap-combobox-list",className:$("tiptap-combobox-list",e),...t})}function w2({className:e,...t}){return l.jsx(ce.ComboboxItem,{"data-slot":"tiptap-combobox-item",className:$("tiptap-combobox-item",e),...t})}const v2=typeof window<"u"?u.useLayoutEffect:u.useEffect;function y2(e,t,n,o){const r=u.useRef(t);v2(()=>{r.current=t},[t]),u.useEffect(()=>{const s=window;if(!(s&&s.addEventListener))return;const i=a=>{r.current(a)};return s.addEventListener(e,i,o),()=>{s.removeEventListener(e,i,o)}},[e,n,o])}function x2(e,t,n="mousedown",o={}){y2(n,r=>{const s=r.target;if(!s||!s.isConnected)return;(Array.isArray(e)?e.filter(a=>!!a.current).every(a=>a.current&&!a.current.contains(s)):e.current&&!e.current.contains(s))&&t(r)},void 0,o)}const Al=(e,t)=>{typeof e=="function"?e(t):e&&typeof e=="object"&&"current"in e&&(e.current=t)},Il=(e,t)=>{const n=u.useRef(null);return u.useCallback(o=>{e&&"current"in e&&(e.current=o),n.current&&Al(n.current,null),n.current=t,t&&Al(t,o)},[e,t])};function je({children:e,trigger:t,value:n,onOpenChange:o,onValueChange:r,onValuesChange:s,...i}){const a=!ce.useMenuContext(),[c,d]=u.useState(!1),p=!!s||a,f=u.useCallback(g=>{i.open===void 0&&d(g),o?.(g)},[i.open,o]),h=u.useMemo(()=>({isRootMenu:a,open:i.open??c}),[a,i.open,c]),C=l.jsxs(ce.MenuProvider,{open:c,setOpen:f,setValues:s,showTimeout:100,...i,children:[t,l.jsx(El.Provider,{value:h,children:l.jsx(Ll.Provider,{value:p,children:e})})]});return p?l.jsx(m2,{value:n,setValue:r,children:C}):C}function Xe({children:e,className:t,ref:n,onClickOutside:o,...r}){const s=u.useRef(null),{open:i}=A2(),a=I2();return x2(s,o||(()=>{})),l.jsx(ce.Menu,{ref:Il(s,n),className:$("tiptap-menu-content",t),"data-side":a,"data-state":i?"open":"closed",gutter:4,flip:!0,unmountOnHide:!0,...r,children:e})}function Je({className:e,...t}){return l.jsx(ce.MenuButton,{...t,className:$("tiptap-menu-button",e)})}function k2({className:e,...t}){return l.jsx(ce.MenuButtonArrow,{...t,className:$("tiptap-menu-button-arrow",e)})}function de({className:e,...t}){return l.jsx(ce.MenuGroup,{...t,className:$("tiptap-menu-group",e)})}function ft({className:e,...t}){return l.jsx(ce.MenuGroupLabel,{...t,className:$("tiptap-menu-group-label",e)})}function S2({className:e,...t}){return l.jsx(ce.MenuItemRadio,{...t,className:$("tiptap-menu-item-radio",e)})}function Ee({name:e,value:t,preventClose:n,className:o,...r}){const s=ce.useMenuContext(),i=T2(),a=L2(s,n),c={blurOnHoverEnd:!1,focusOnHover:!0,className:$("tiptap-menu-item",o),...r};return i?l.jsx(w2,{...c,hideOnClick:a}):e&&t?l.jsx(S2,{...c,hideOnClick:!0,name:e,value:t}):l.jsx(ce.MenuItem,{...c})}const Ll=u.createContext(!1),El=u.createContext({isRootMenu:!1,open:!1}),T2=()=>u.useContext(Ll),A2=()=>u.useContext(El);function I2(){const e=ce.useMenuStore();return ce.useStoreState(e,n=>n.currentPlacement?.split("-")[0]||"bottom")}function L2(e,t){return u.useCallback(n=>(n.currentTarget.hasAttribute("aria-expanded")||t||e?.hideAll(),!1),[e,t])}function ee({decorative:e,orientation:t="vertical",className:n,...o}){const s=e?{role:"none"}:{"aria-orientation":t==="vertical"?t:void 0,role:"separator"};return l.jsx("div",{className:$("tiptap-separator",n),"data-orientation":t,...s,...o})}const E2=u.forwardRef(({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:r=!1,onDuplicated:s,text:i,onClick:a,children:c,...d},p)=>{const{editor:f}=k(e),{isVisible:h,handleDuplicate:C,label:g,canDuplicateRowColumn:b,Icon:m}=Nl({editor:f,index:t,orientation:n,tablePos:o,hideWhenUnavailable:r,onDuplicated:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:w,...d,ref:p,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),i&&l.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});E2.displayName="TableDuplicateRowColumnButton";const Vn=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 9C9.44772 9 9 9.44772 9 10V20C9 20.5523 9.44772 21 10 21H20C20.5523 21 21 20.5523 21 20V10C21 9.44772 20.5523 9 20 9H10ZM7 10C7 8.34315 8.34315 7 10 7H20C21.6569 7 23 8.34315 23 10V20C23 21.6569 21.6569 23 20 23H10C8.34315 23 7 21.6569 7 20V10Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C3.45228 3 3 3.45228 3 4V14C3 14.5477 3.45228 15 4 15C4.55228 15 5 15.4477 5 16C5 16.5523 4.55228 17 4 17C2.34772 17 1 15.6523 1 14V4C1 2.34772 2.34772 1 4 1H14C15.6523 1 17 2.34772 17 4C17 4.55228 16.5523 5 16 5C15.4477 5 15 4.55228 15 4C15 3.45228 14.5477 3 14 3H4Z",fill:"currentColor"})]}));Vn.displayName="CopyIcon";const Ml=["tableHandleExtension"];function Bn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!_(e,Ml))return!1;try{if(!ne(e,o))return!1;const s=ge(e,t,n,o);return s.mergedCells.length>0?!1:s.cells.length>0}catch{return!1}}function M2({editor:e,index:t,tablePos:n}){try{const o=ge(e,t,"row",n);if(o.cells.length===0)return!1;let r=!1;if(e.state.selection instanceof T.CellSelection)r=e.chain().focus(void 0,{scrollIntoView:!1}).addRowAfter().run();else{if(!n)return!1;const f=Pe({editor:e,index:t,orientation:"row",tablePos:n});if(!f)return!1;const h=ke(e,n,f,{mode:"state"});r=T.addRowAfter(h,e.view.dispatch)}if(!r)return!1;const s=ge(e,t+1,"row",n);if(s.cells.length===0)return!1;const{state:i,view:a}=e,c=i.tr,d=[...s.cells].reverse(),p=[...o.cells].reverse();return d.forEach((f,h)=>{const C=p[h];if(f.node&&C?.node){const g=f.node.type.create({...C.node.attrs},C.node.content,C.node.marks),b=f.pos+f.node.nodeSize;c.replaceWith(f.pos,b,g)}}),c.docChanged?(a.dispatch(c),Ln(e,"row",t+1,n),!0):!1}catch(o){return console.error("Error duplicating row:",o),!1}}function N2({editor:e,index:t,tablePos:n}){try{const o=ge(e,t,"column",n);if(o.cells.length===0)return!1;let r=!1;if(e.state.selection instanceof T.CellSelection)r=e.chain().focus(void 0,{scrollIntoView:!1}).addColumnAfter().run();else{if(!n)return!1;const f=Pe({editor:e,index:t,orientation:"column",tablePos:n});if(!f)return!1;const h=ke(e,n,f,{mode:"state"});r=T.addColumnAfter(h,e.view.dispatch)}if(!r)return!1;const s=ge(e,t+1,"column",n);if(s.cells.length===0)return!1;const{state:i,view:a}=e,c=i.tr,d=[...s.cells].reverse(),p=[...o.cells].reverse();return d.forEach((f,h)=>{const C=p[h];if(f.node&&C?.node){const g=f.node.type.create({...C.node.attrs},C.node.content,C.node.marks),b=f.pos+f.node.nodeSize;c.replaceWith(f.pos,b,g)}}),c.docChanged?(a.dispatch(c),Ln(e,"column",t+1,n),!0):!1}catch(o){return console.error("Error duplicating column:",o),!1}}function H2({editor:e,index:t,orientation:n,tablePos:o}){if(!Bn({editor:e,index:t,orientation:n,tablePos:o})||!e||!ne(e,o))return!1;const s=Q(e,t,n,o);if(!s)return!1;try{return s.orientation==="row"?M2({editor:e,index:s.index,tablePos:o}):s.orientation==="column"?N2({editor:e,index:s.index,tablePos:o}):!1}catch(i){return console.error("Error duplicating row/column:",i),!1}}function V2({editor:e,index:t,orientation:n,hideWhenUnavailable:o}){return!e||!e.isEditable||!_(e,Ml)?!1:o?Bn({editor:e,index:t,orientation:n}):!0}function Nl(e){const{editor:t,index:n,orientation:o,tablePos:r,hideWhenUnavailable:s=!1,onDuplicated:i}=e,{editor:a}=k(t),c=D(),d=Q(a,n,o),p=V2({editor:a,index:n,orientation:o,hideWhenUnavailable:s}),f=Bn({editor:a,index:n,tablePos:r,orientation:o}),h=u.useCallback(()=>{const b=H2({editor:a,index:n,orientation:o,tablePos:r});return b&&i?.(),b},[a,n,o,r,i]),C=u.useMemo(()=>d?.orientation==="column"?c.duplicateColumn:c.duplicateRow,[c.duplicateColumn,c.duplicateRow,d]);return{isVisible:p,canDuplicateRowColumn:f,handleDuplicate:h,label:C,Icon:Vn}}const B2=u.forwardRef(({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:r=!1,onMoved:s,text:i,onClick:a,children:c,...d},p)=>{const{editor:f}=k(e),{isVisible:h,handleMove:C,label:g,canMoveRowColumn:b,Icon:m}=pt({editor:f,index:t,orientation:n,direction:o,hideWhenUnavailable:r,onMoved:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:w,...d,ref:p,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),i&&l.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});B2.displayName="TableMoveRowColumnButton";const Dn=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M12.7071 5.70711C13.0976 5.31658 13.0976 4.68342 12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071L11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071C13.0976 19.3166 13.0976 18.6834 12.7071 18.2929L7.41421 13L19 13C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11L7.41421 11L12.7071 5.70711Z",fill:"currentColor"})}));Dn.displayName="ArrowLeftIcon";const Hl=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289C10.9024 4.68342 10.9024 5.31658 11.2929 5.70711L16.5858 11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H16.5858L11.2929 18.2929C10.9024 18.6834 10.9024 19.3166 11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071L19.7071 12.7071C20.0976 12.3166 20.0976 11.6834 19.7071 11.2929L12.7071 4.29289Z",fill:"currentColor"})}));Hl.displayName="ArrowRightIcon";const Un=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071C4.68342 13.0976 5.31658 13.0976 5.70711 12.7071L11 7.41421V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V7.41421L18.2929 12.7071C18.6834 13.0976 19.3166 13.0976 19.7071 12.7071C20.0976 12.3166 20.0976 11.6834 19.7071 11.2929L12.7071 4.29289Z",fill:"currentColor"})}));Un.displayName="ArrowUpIcon";const Vl=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M12.707 19.707C12.3165 20.0976 11.6835 20.0976 11.293 19.707L4.29297 12.707C3.90245 12.3165 3.90245 11.6835 4.29297 11.293C4.68349 10.9024 5.31651 10.9024 5.70703 11.293L11 16.5859L11 5C11 4.44771 11.4477 4 12 4C12.5523 4 13 4.44771 13 5L13 16.5859L18.293 11.293C18.6835 10.9024 19.3165 10.9024 19.707 11.293C20.0976 11.6835 20.0976 12.3165 19.707 12.707L12.707 19.707Z",fill:"currentColor"})}));Vl.displayName="ArrowDownIcon";const Bl=["tableHandleExtension"],D2={up:Un,down:Vl,left:Dn,right:Hl};function U2(e,t,n){try{return T.columnIsHeader(e,t,n)}catch{return!1}}function O2(e,t,n){try{return T.rowIsHeader(e,t,n)}catch{return!1}}function On(e,t){return e==="row"?t==="up"||t==="down":e==="column"?t==="left"||t==="right":!1}function Pn({editor:e,index:t,orientation:n,direction:o,tablePos:r}){if(!e||!e.isEditable||!_(e,Bl))return!1;try{const s=ne(e,r);if(!s)return!1;const i=Q(e,t,n);if(!i)return!1;const{orientation:a,index:c}=i;if(!On(a,o)||a==="row"&&O2(s.map,s.node,c)||a==="column"&&U2(s.map,s.node,c))return!1;const{width:d,height:p}=s.map,f=a==="row"?o==="up"?c-1:c+1:o==="left"?c-1:c+1,h=a==="row"?p:d;if(f<0||f>=h)return!1;const C=Pe({editor:e,index:c,orientation:a,tablePos:r}),g=Pe({editor:e,index:f,orientation:a,tablePos:r});if(!C||!g)return!1;const b=ke(e,s.pos,C,{mode:"state"});if(!b)return!1;const m=T.selectedRect(b),w=ke(e,s.pos,g,{mode:"state"});if(!w)return!1;const v=T.selectedRect(w);return hl(s.map,m)&&hl(s.map,v)?!1:a==="row"?o==="up"?c>0:c<p-1:o==="left"?c>0:c<d-1}catch{return!1}}function P2({editor:e,index:t,orientation:n,direction:o,tablePos:r}){if(!Pn({editor:e,index:t,orientation:n,direction:o,tablePos:r})||!e)return!1;try{const s=ne(e,r);if(!s)return!1;const i=Q(e,t,n);if(!i)return!1;const{orientation:a,index:c}=i;if(!On(a,o))return!1;const p=c+{up:-1,down:1,left:-1,right:1}[o],f=a==="row"?T.moveTableRow:T.moveTableColumn,h=C=>e.view.dispatch(C);if(e.state.selection instanceof T.CellSelection)return f({from:c,to:p,select:!0,pos:s.start})(e.state,h);{const C=Pe({editor:e,index:c,orientation:a,tablePos:r});if(!C)return!1;const g=ke(e,s.pos,C,{mode:"state"});return g?f({from:c,to:p,select:!0,pos:s.start})(g,h):!1}}catch(s){return console.error("Error moving table row/column:",s),!1}}function W2({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:r,tablePos:s}){if(!e||!e.isEditable||!_(e,Bl))return!1;const i=Q(e,t,n);return!i||!On(i.orientation,o)?!1:r?Pn({editor:e,index:t,orientation:n,direction:o,tablePos:s}):!0}function pt(e){const{editor:t,index:n,orientation:o,tablePos:r,direction:s,hideWhenUnavailable:i=!1,onMoved:a}=e,{editor:c}=k(t),d=D(),p=Q(c,n,o),f=W2({editor:c,index:n,orientation:o,direction:s,hideWhenUnavailable:i,tablePos:r}),h=Pn({editor:c,index:n,orientation:o,direction:s,tablePos:r}),C=u.useCallback(()=>{const m=P2({editor:c,index:n,orientation:o,direction:s,tablePos:r});return m&&a?.(),m},[c,n,o,s,r,a]),g=u.useMemo(()=>p?.orientation==="column"?s==="left"?d.moveColumnLeft:d.moveColumnRight:s==="up"?d.moveRowUp:d.moveRowDown,[s,d.moveColumnLeft,d.moveColumnRight,d.moveRowDown,d.moveRowUp,p]),b=u.useMemo(()=>D2[s],[s]);return{isVisible:f,canMoveRowColumn:h,handleMove:C,label:g,Icon:b}}const _2=u.forwardRef(({editor:e,index:t,orientation:n,hideWhenUnavailable:o=!1,resetAttrs:r=!1,onCleared:s,text:i,onClick:a,children:c,...d},p)=>{const{editor:f}=k(e),{isVisible:h,handleClear:C,label:g,canClearRowColumnContent:b,Icon:m}=Qe({editor:f,index:t,orientation:n,hideWhenUnavailable:o,resetAttrs:r,onCleared:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:w,...d,ref:p,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),i&&l.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});_2.displayName="TableClearRowColumnContentButton";const Dl=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H19C19.5523 20 20 19.5523 20 19V5C20 4.44772 19.5523 4 19 4H5ZM2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM15.7071 8.29289C16.0976 8.68342 16.0976 9.31658 15.7071 9.70711L13.4142 12L15.7071 14.2929C16.0976 14.6834 16.0976 15.3166 15.7071 15.7071C15.3166 16.0976 14.6834 16.0976 14.2929 15.7071L12 13.4142L9.70711 15.7071C9.31658 16.0976 8.68342 16.0976 8.29289 15.7071C7.90237 15.3166 7.90237 14.6834 8.29289 14.2929L10.5858 12L8.29289 9.70711C7.90237 9.31658 7.90237 8.68342 8.29289 8.29289C8.68342 7.90237 9.31658 7.90237 9.70711 8.29289L12 10.5858L14.2929 8.29289C14.6834 7.90237 15.3166 7.90237 15.7071 8.29289Z",fill:"currentColor"})}));Dl.displayName="SquareXIcon";const Ul=["table"],Ol={backgroundColor:null,nodeVerticalAlign:null,nodeTextAlign:null};function Pl(e){try{return Wc(Ol)(e.state,e.view.dispatch)}catch(t){return console.error("Error resetting cell attributes:",t),!1}}function Wn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!_(e,Ul))return!1;try{if(!ne(e,o))return!1;const s=Q(e,t,n,o);if(s){const i=ge(e,s.index,s.orientation,o);return i.cells.length===0?!1:i.cells.some(a=>a.node&&!Oe(a.node))}else{const{selection:i}=e.state;if(i instanceof T.CellSelection){let p=!1;return i.forEachCell(f=>{Oe(f)||(p=!0)}),p}const{$anchor:a}=i,c=T.cellAround(a);if(!c)return!1;const d=e.state.doc.nodeAt(c.pos);return d?!Oe(d):!1}}catch{return!1}}function Z2(e,t=!1){try{const{selection:n}=e.state;if(n instanceof T.CellSelection)return t&&Pl(e),T.deleteCellSelection(e.state,e.view.dispatch),!0;const{$anchor:o}=n,r=T.cellAround(o);if(!r)return!1;const s=e.state.doc.nodeAt(r.pos);if(!s)return!1;const i=r.pos+1,a=r.pos+s.nodeSize-1;return i>=a?!1:(t&&Pl(e),e.view.dispatch(e.state.tr.delete(i,a)),!0)}catch(n){return console.error("Error clearing selected cells:",n),!1}}function F2({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:r=!1}){try{const{state:s,view:i}=e,a=s.tr,c=ge(e,t,n,o);return c.cells.length===0?!1:([...c.cells].reverse().forEach(p=>{if(p.node&&!Oe(p.node)){const f=p.pos+1,h=p.pos+p.node.nodeSize-1;f<h&&a.delete(f,h),r&&a.setNodeMarkup(p.pos,null,{...p.node.attrs,...Ol})}}),a.docChanged?(i.dispatch(a),!0):!1)}catch(s){return console.error(`Error clearing ${n} content:`,s),!1}}function z2({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:r=!1}){if(!Wn({editor:e,index:t,orientation:n,tablePos:o})||!e)return!1;try{const s=Q(e,t,n,o);return s?F2({editor:e,index:s.index,orientation:s.orientation,resetAttrs:r,tablePos:o}):Z2(e,r)}catch(s){return console.error("Error clearing table content:",s),!1}}function $2({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:r}){if(!e||!e.isEditable||!_(e,Ul)||!ne(e,o))return!1;const i=Q(e,t,n,o),{selection:a}=e.state,c=a instanceof T.CellSelection||T.cellAround(a.$anchor);return!i&&!c?!1:r?Wn({editor:e,index:t,orientation:n,tablePos:o}):!0}function Qe(e={}){const{editor:t,index:n,orientation:o,tablePos:r,hideWhenUnavailable:s=!1,resetAttrs:i=!1,onCleared:a}=e,{editor:c}=k(t),d=D(),p=Q(c,n,o,r),f=$2({editor:c,index:n,orientation:o,tablePos:r,hideWhenUnavailable:s}),h=Wn({editor:c,index:n,orientation:o,tablePos:r}),C=u.useCallback(()=>{const m=z2({editor:c,index:n,orientation:o,tablePos:r,resetAttrs:i});return m&&a?.(),m},[c,n,o,r,i,a]),g=u.useMemo(()=>p?p.orientation==="column"?d.clearColumnContents:d.clearRowContents:d.clearContents,[d.clearColumnContents,d.clearContents,d.clearRowContents,p]);return{isVisible:f,canClearRowColumnContent:h,handleClear:C,label:g,Icon:Dl}}const q2=u.forwardRef(({editor:e,index:t,orientation:n,hideWhenUnavailable:o=!1,onToggled:r,text:s,onClick:i,children:a,...c},d)=>{const{editor:p}=k(e),{isVisible:f,handleToggle:h,label:C,canToggleHeader:g,Icon:b,isActive:m}=Zn({editor:p,index:t,orientation:n,hideWhenUnavailable:o,onToggled:r}),w=u.useCallback(v=>{i?.(v),!v.defaultPrevented&&h()},[h,i]);return f?l.jsx(M,{type:"button",disabled:!g,variant:"ghost","data-active-state":m?"on":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":C,"aria-pressed":m,tooltip:C,onClick:w,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(b,{className:"tiptap-button-icon"}),s&&l.jsx("span",{className:"tiptap-button-text",children:s})]})}):null});q2.displayName="TableHeaderRowColumnButton";const Wl=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 5V7V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19V7V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5ZM20 19V8H16V20H19C19.5523 20 20 19.5523 20 19ZM14 20L14 8H10L10 20H14ZM8 20L8 8H4V19C4 19.5523 4.44772 20 5 20H8Z",fill:"currentColor"})}));Wl.displayName="TableHeaderRowIcon";const _l=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 19V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19ZM8 20V16H20V19C20 19.5523 19.5523 20 19 20H8ZM8 14L20 14V10L8 10V14ZM20 8L8 8V4H19C19.5523 4 20 4.44772 20 5V8Z",fill:"currentColor"})}));_l.displayName="TableHeaderColumnIcon";const Zl=["table"],G2={row:Wl,column:_l};function _n({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!_(e,Zl))return!1;const r=Q(e,t,n,o);return r?r.index===0:!1}function K2({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!_n({editor:e,index:t,orientation:n,tablePos:o}))return!1;try{const r=Q(e,t,n,o);if(!r)return!1;const s=r.orientation==="row";if(e.state.selection instanceof T.CellSelection)return s?e.commands.toggleHeaderRow():e.commands.toggleHeaderColumn();if(!X(o))return!1;const i=Pe({editor:e,index:r.index,orientation:r.orientation,tablePos:o});if(!i)return!1;const a=ke(e,o,i,{mode:"state"});if(!a)return!1;const c=d=>e.view.dispatch(d);return s?T.toggleHeader("row")(a,c):T.toggleHeader("column")(a,c)}catch{return!1}}function Y2({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:r}){return!e||!e.isEditable||!_(e,Zl)?!1:o?_n({editor:e,index:t,orientation:n,tablePos:r}):!!Q(e,t,n)}function Zn(e){const{editor:t,index:n,orientation:o,tablePos:r,hideWhenUnavailable:s=!1,onToggled:i}=e,{editor:a}=k(t),c=D(),d=Q(a,n,o),p=Y2({editor:a,index:n,orientation:o,hideWhenUnavailable:s,tablePos:r}),f=_n({editor:a,index:n,orientation:o,tablePos:r});let h=!1;if(a?.state.selection instanceof T.CellSelection)h=a?.isActive("tableHeader")||!1;else{const m=ge(a,n,d?.orientation,r);if(m){const w=m.cells.length>1?1:0;h=m.cells[w]?.node?.type.name==="tableHeader"||!1}}const C=u.useCallback(()=>{const m=K2({editor:a,index:n,orientation:o,tablePos:r});return m&&i?.(),m},[a,n,o,r,i]),g=u.useMemo(()=>d?.orientation==="column"?c.headerColumn:c.headerRow,[c.headerColumn,c.headerRow,d]),b=G2[d?.orientation||"row"];return{isVisible:p,canToggleHeader:f,handleToggle:C,label:g,Icon:b,isActive:h}}const j2=u.forwardRef(({editor:e,index:t,orientation:n,side:o,tablePos:r,hideWhenUnavailable:s=!1,onAdded:i,text:a,onClick:c,children:d,...p},f)=>{const{editor:h}=k(e),{isVisible:C,handleAdd:g,label:b,canAddRowColumn:m,Icon:w}=We({editor:h,index:t,orientation:n,side:o,tablePos:r,hideWhenUnavailable:s,onAdded:i}),v=u.useCallback(y=>{c?.(y),!y.defaultPrevented&&g()},[g,c]);return C?l.jsx(M,{type:"button",disabled:!m,variant:"ghost","data-active-state":"off","data-disabled":!m,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...p,ref:f,children:d??l.jsxs(l.Fragment,{children:[l.jsx(w,{className:"tiptap-button-icon"}),a&&l.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});j2.displayName="TableAddRowColumnButton";const Fl=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 2C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H15C13.3431 22 12 20.6569 12 19V5C12 3.34315 13.3431 2 15 2H19ZM14 19C14 19.5523 14.4477 20 15 20H19C19.5523 20 20 19.5523 20 19V13H14V19ZM15 4C14.4477 4 14 4.44772 14 5V11H20V5C20 4.44772 19.5523 4 19 4H15Z",fill:"currentColor"}),l.jsx("path",{d:"M6 8C6.55228 8 7 8.44772 7 9V11H9C9.55228 11 10 11.4477 10 12C10 12.5523 9.55228 13 9 13H7V15C7 15.5523 6.55228 16 6 16C5.44772 16 5 15.5523 5 15V13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H5V9C5 8.44772 5.44772 8 6 8Z",fill:"currentColor"})]}));Fl.displayName="AddColLeftIcon";const zl=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 2C10.6569 2 12 3.34315 12 5V19C12 20.6569 10.6569 22 9 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2H9ZM4 19C4 19.5523 4.44772 20 5 20H9C9.55228 20 10 19.5523 10 19V13H4V19ZM5 4C4.44772 4 4 4.44772 4 5V11H10V5C10 4.44772 9.55228 4 9 4H5Z",fill:"currentColor"}),l.jsx("path",{d:"M18 8C18.5523 8 19 8.44772 19 9V11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H19V15C19 15.5523 18.5523 16 18 16C17.4477 16 17 15.5523 17 15V13H15C14.4477 13 14 12.5523 14 12C14 11.4477 14.4477 11 15 11H17V9C17 8.44772 17.4477 8 18 8Z",fill:"currentColor"})]}));zl.displayName="AddColRightIcon";const $l=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M12 14C12.5523 14 13 14.4477 13 15V17H15C15.5523 17 16 17.4477 16 18C16 18.5523 15.5523 19 15 19H13V21C13 21.5523 12.5523 22 12 22C11.4477 22 11 21.5523 11 21V19H9C8.44772 19 8 18.5523 8 18C8 17.4477 8.44772 17 9 17H11V15C11 14.4477 11.4477 14 12 14Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 2C20.6569 2 22 3.34315 22 5V9C22 10.6569 20.6569 12 19 12H5C3.34315 12 2 10.6569 2 9V5C2 3.34315 3.34315 2 5 2H19ZM5 4C4.44772 4 4 4.44772 4 5V9C4 9.55228 4.44772 10 5 10H11V4H5ZM13 10H19C19.5523 10 20 9.55228 20 9V5C20 4.44772 19.5523 4 19 4H13V10Z",fill:"currentColor"})]}));$l.displayName="AddRowBottomIcon";const ql=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 12C20.6569 12 22 13.3431 22 15V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V15C2 13.3431 3.34315 12 5 12H19ZM5 14C4.44772 14 4 14.4477 4 15V19C4 19.5523 4.44772 20 5 20H11V14H5ZM13 20H19C19.5523 20 20 19.5523 20 19V15C20 14.4477 19.5523 14 19 14H13V20Z",fill:"currentColor"}),l.jsx("path",{d:"M12 2C12.5523 2 13 2.44772 13 3V5H15C15.5523 5 16 5.44772 16 6C16 6.55228 15.5523 7 15 7H13V9C13 9.55228 12.5523 10 12 10C11.4477 10 11 9.55228 11 9V7H9C8.44772 7 8 6.55228 8 6C8 5.44772 8.44772 5 9 5H11V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor"})]}));ql.displayName="AddRowTopIcon";const Gl=["table"];function X2(e,t,n){try{return T.columnIsHeader(e,t,n)}catch{return!1}}function J2(e,t,n){try{return T.rowIsHeader(e,t,n)}catch{return!1}}function Fn({editor:e,index:t,orientation:n,tablePos:o,side:r}){if(!e||!e.isEditable||!_(e,Gl))return!1;const s=ne(e,o);if(!s)return!1;const i=Q(e,t,n);if(!i)return!1;const{map:a,node:c}=s,d=i.index,p=i.orientation;return!(typeof d!="number"||d<0||p==="column"&&d>=a.width||p==="row"&&d>=a.height||r==="left"&&p==="column"&&X2(a,c,d)||r==="above"&&p==="row"&&J2(a,c,d))}function Q2(e,t,n){return t==="row"?n==="above"?e:e+1:n==="left"?e:e+1}function R2({editor:e,index:t,orientation:n,side:o,tablePos:r}){if(!Fn({editor:e,index:t,orientation:n,tablePos:r,side:o})||!e)return!1;const s=Q(e,t,n);if(!s)return!1;const{orientation:i,index:a}=s,c=i==="row",d=f=>e.view.dispatch(f),p=c?o==="above"?T.addRowBefore:T.addRowAfter:o==="left"?T.addColumnBefore:T.addColumnAfter;try{let f=!1;if(e.state.selection instanceof T.CellSelection)f=p(e.state,d);else{const h=ne(e,r);if(!h)return!1;const C=i==="row"?{row:a,col:0}:{row:0,col:a},g=ke(e,h.pos,[C],{mode:"state"});if(!g)return!1;f=p(g,d)}if(f){const h=Q2(a,i,o);Ln(e,i,h,r)}return f}catch(f){return console.error("Error adding row/column:",f),!1}}function ed({editor:e,index:t,orientation:n,tablePos:o,side:r,hideWhenUnavailable:s}){return!e||!e.isEditable||!_(e,Gl)?!1:s?Fn({editor:e,index:t,orientation:n,tablePos:o,side:r}):!!Q(e,t,n)}function We(e){const{editor:t,index:n,orientation:o,side:r,tablePos:s,hideWhenUnavailable:i=!1,onAdded:a}=e,{editor:c}=k(t),d=D(),p=Q(c,n,o),f=ed({editor:c,index:n,orientation:o,tablePos:s,side:r,hideWhenUnavailable:i}),h=Fn({editor:c,index:n,orientation:o,tablePos:s,side:r}),C=u.useCallback(()=>{const m=R2({editor:c,index:n,orientation:o,tablePos:s,side:r});return m&&a?.(),m},[c,n,o,s,r,a]),g=p?.orientation==="row"?r==="above"?d.insertRowAbove:d.insertRowBelow:r==="left"?d.insertColumnLeft:d.insertColumnRight,b=p?.orientation==="row"?r==="above"?ql:$l:r==="left"?Fl:zl;return{isVisible:f,canAddRowColumn:h,handleAdd:C,label:g,Icon:b}}const td=u.forwardRef(({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:r=!1,onDeleted:s,text:i,onClick:a,children:c,...d},p)=>{const{editor:f}=k(e),{isVisible:h,handleDelete:C,label:g,canDeleteRowColumn:b,Icon:m}=$n({editor:f,index:t,orientation:n,tablePos:o,hideWhenUnavailable:r,onDeleted:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:w,...d,ref:p,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),i&&l.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});td.displayName="TableDeleteRowColumnButton";const ht=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z",fill:"currentColor"})}));ht.displayName="TrashIcon";const Kl=["table"];function zn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!_(e,Kl))return!1;try{return!(!ne(e,o)||!Q(e,t,n))}catch{return!1}}function nd({editor:e,index:t,orientation:n,tablePos:o}){if(!zn({editor:e,index:t,orientation:n,tablePos:o})||!e)return!1;try{const r=Q(e,t,n);if(!r)return!1;const{orientation:s,index:i}=r,a=s==="row",c=C=>e.view.dispatch(C),d=a?T.deleteRow:T.deleteColumn;if(e.state.selection instanceof T.CellSelection)return d(e.state,c);const p=ne(e,o);if(!p)return!1;const f=a?{row:i,col:0}:{row:0,col:i},h=ke(e,p.pos,[f],{mode:"state"});return h?d(h,c):!1}catch(r){return console.error("Error deleting table row/column:",r),!1}}function od({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:r}){return!e||!e.isEditable||!_(e,Kl)?!1:o?zn({editor:e,index:t,orientation:n,tablePos:r}):!0}function $n(e){const{editor:t,index:n,orientation:o,tablePos:r,hideWhenUnavailable:s=!1,onDeleted:i}=e,{editor:a}=k(t),c=D(),d=Q(a,n,o),p=od({editor:a,index:n,orientation:o,hideWhenUnavailable:s}),f=zn({editor:a,index:n,orientation:o,tablePos:r}),h=u.useCallback(()=>{const g=nd({editor:a,index:n,orientation:o,tablePos:r});return g&&i?.(),g},[a,n,o,r,i]),C=u.useMemo(()=>d?.orientation==="column"?c.deleteColumn:c.deleteRow,[c.deleteColumn,c.deleteRow,d]);return{isVisible:p,canDeleteRowColumn:f,handleDelete:h,label:C,Icon:ht}}const rd=u.forwardRef(({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:r=!1,onSorted:s,text:i,onClick:a,children:c,...d},p)=>{const{editor:f}=k(e),{isVisible:h,handleSort:C,label:g,canSortRowColumn:b,Icon:m}=Kn({editor:f,index:t,orientation:n,direction:o,hideWhenUnavailable:r,onSorted:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:w,...d,ref:p,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),i&&l.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});rd.displayName="TableSortRowColumnButton";const qn=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M7.00017 3C7.55242 3.00004 8.00017 3.44774 8.00017 4V17.5859L10.2931 15.293C10.6837 14.9025 11.3167 14.9025 11.7072 15.293C12.0976 15.6835 12.0976 16.3165 11.7072 16.707L7.7072 20.707C7.66067 20.7536 7.60881 20.7944 7.55388 20.8311C7.51475 20.8572 7.47445 20.8804 7.43279 20.9004C7.38729 20.9223 7.34018 20.9412 7.29118 20.9561C7.27445 20.9611 7.25734 20.9646 7.2404 20.9688C7.2248 20.9726 7.20941 20.9774 7.19353 20.9805C7.18643 20.9819 7.17916 20.9822 7.17204 20.9834C7.1161 20.9931 7.05889 21 7.00017 21L6.89763 20.9951C6.87615 20.9929 6.85521 20.9879 6.83415 20.9844C6.82375 20.9826 6.81326 20.9816 6.8029 20.9795C6.7914 20.9772 6.78008 20.9744 6.76872 20.9717C6.74815 20.9668 6.72749 20.9622 6.7072 20.9561C6.65855 20.9412 6.61176 20.9222 6.56658 20.9004C6.5247 20.8802 6.48381 20.8574 6.4445 20.8311C6.39008 20.7946 6.3393 20.7532 6.29314 20.707L2.29314 16.707C1.90261 16.3165 1.90261 15.6835 2.29314 15.293C2.68367 14.9025 3.3167 14.9025 3.7072 15.293L6.00017 17.5859V4C6.00017 3.44772 6.44788 3 7.00017 3Z",fill:"currentColor"}),l.jsx("path",{d:"M20.1437 13.0107C20.4734 13.0585 20.7615 13.2687 20.9054 13.5762C21.0699 13.9275 21.0171 14.3426 20.7687 14.6406L17.1359 19H20.0002C20.5524 19 21.0002 19.4477 21.0002 20C21.0002 20.5523 20.5524 21 20.0002 21H15.0002C14.6122 21 14.2595 20.7752 14.0949 20.4238C13.9304 20.0725 13.9832 19.6574 14.2316 19.3594L17.8644 15H15.0002C14.4479 15 14.0002 14.5523 14.0002 14C14.0002 13.4477 14.4479 13 15.0002 13H20.0002L20.1437 13.0107Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.5002 3C18.4284 3.00002 19.3184 3.36903 19.9748 4.02539C20.6311 4.68176 21.0002 5.57176 21.0002 6.5V10C21.0002 10.5523 20.5524 11 20.0002 11C19.4479 11 19.0002 10.5523 19.0002 10V9H16.0002V10C16.0002 10.5523 15.5524 11 15.0002 11C14.4479 11 14.0002 10.5523 14.0002 10V6.5C14.0002 5.57174 14.3692 4.68177 15.0256 4.02539C15.6819 3.36904 16.5719 3 17.5002 3ZM17.5002 5C17.1024 5 16.7209 5.15817 16.4396 5.43945C16.1583 5.72076 16.0002 6.10218 16.0002 6.5V7H19.0002V6.5C19.0002 6.10219 18.842 5.72075 18.5607 5.43945C18.2794 5.15817 17.898 5.00002 17.5002 5Z",fill:"currentColor"})]}));qn.displayName="ArrowDownAZIcon";const Yl=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M7.00017 3C7.55242 3.00004 8.00017 3.44774 8.00017 4V17.5859L10.2931 15.293C10.6837 14.9025 11.3167 14.9025 11.7072 15.293C12.0976 15.6835 12.0976 16.3165 11.7072 16.707L7.7072 20.707C7.66067 20.7536 7.60881 20.7944 7.55388 20.8311C7.51475 20.8572 7.47445 20.8804 7.43279 20.9004C7.38729 20.9223 7.34018 20.9412 7.29118 20.9561C7.27445 20.9611 7.25734 20.9646 7.2404 20.9688C7.2248 20.9726 7.20941 20.9774 7.19353 20.9805C7.18643 20.9819 7.17916 20.9822 7.17204 20.9834C7.1161 20.9931 7.05889 21 7.00017 21L6.89763 20.9951C6.87615 20.9929 6.85521 20.9879 6.83415 20.9844C6.82375 20.9826 6.81326 20.9816 6.8029 20.9795C6.7914 20.9772 6.78008 20.9744 6.76872 20.9717C6.74815 20.9668 6.72749 20.9622 6.7072 20.9561C6.65855 20.9412 6.61176 20.9222 6.56658 20.9004C6.5247 20.8802 6.48381 20.8574 6.4445 20.8311C6.39008 20.7946 6.3393 20.7532 6.29314 20.707L2.29314 16.707C1.90261 16.3165 1.90261 15.6835 2.29314 15.293C2.68367 14.9025 3.3167 14.9025 3.7072 15.293L6.00017 17.5859V4C6.00017 3.44772 6.44788 3 7.00017 3Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.5002 13C18.4284 13 19.3184 13.369 19.9748 14.0254C20.6311 14.6818 21.0002 15.5718 21.0002 16.5V20C21.0002 20.5523 20.5524 21 20.0002 21C19.4479 21 19.0002 20.5523 19.0002 20V19H16.0002V20C16.0002 20.5523 15.5524 21 15.0002 21C14.4479 21 14.0002 20.5523 14.0002 20V16.5C14.0002 15.5717 14.3692 14.6818 15.0256 14.0254C15.6819 13.369 16.5719 13 17.5002 13ZM17.5002 15C17.1024 15 16.7209 15.1582 16.4396 15.4395C16.1583 15.7208 16.0002 16.1022 16.0002 16.5V17H19.0002V16.5C19.0002 16.1022 18.842 15.7208 18.5607 15.4395C18.2794 15.1582 17.898 15 17.5002 15Z",fill:"currentColor"}),l.jsx("path",{d:"M20.1437 3.01074C20.4734 3.05854 20.7615 3.26875 20.9054 3.57617C21.0699 3.9275 21.0171 4.34259 20.7687 4.64062L17.1359 9H20.0002C20.5524 9.00004 21.0002 9.44774 21.0002 10C21.0002 10.5523 20.5524 11 20.0002 11H15.0002C14.6122 11 14.2595 10.7752 14.0949 10.4238C13.9304 10.0725 13.9832 9.65742 14.2316 9.35938L17.8644 5H15.0002C14.4479 5 14.0002 4.55228 14.0002 4C14.0002 3.44772 14.4479 3 15.0002 3H20.0002L20.1437 3.01074Z",fill:"currentColor"})]}));Yl.displayName="ArrowDownZAIcon";const jl=["tableHandleExtension"],ld={asc:qn,desc:Yl};function Xl(e){return e?e.type.name==="tableHeader"||e.type.name==="table_header"||e.attrs?.header===!0:!1}function sd(e){if(!e)return"";let t="";return e.descendants(n=>(n.isText&&(t+=n.text||""),!0)),t.trim().toLowerCase()}function Gn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!_(e,jl))return!1;try{const r=ne(e,o);if(!r)return!1;const s=ge(e,t,n,o);if(s.orientation==="row"){if(r.map.width<2)return!1}else if(r.map.height<2)return!1;return!(s.mergedCells.length>0||!s.cells.some(a=>a.node&&!Xl(a.node)&&!Oe(a.node)))}catch{return!1}}function id({editor:e,index:t,orientation:n,direction:o,tablePos:r}){if(!Gn({editor:e,index:t,orientation:n,tablePos:r})||!e)return!1;try{const{state:s,view:i}=e,a=s.tr,c=ge(e,t,n,r);if(c.mergedCells.length>0)return console.warn(`Cannot sort ${n} ${t}: contains merged cells`),!1;if(c.cells.length<2)return!1;const d=c.cells.map((b,m)=>{const w=Xl(b.node),v=b.node?Oe(b.node):!0;return{sortText:sd(b.node),originalNode:b.node,cellInfo:b,originalIndex:m,isHeader:w,isEmpty:v}}),p=d.filter(b=>!b.isHeader);if(p.length<2)return!1;p.sort((b,m)=>{if(b.isEmpty&&!m.isEmpty)return 1;if(!b.isEmpty&&m.isEmpty)return-1;if(b.isEmpty&&m.isEmpty)return 0;const w=b.sortText.localeCompare(m.sortText,void 0,{sensitivity:"base"});return o==="asc"?w:-w});const f=[];let h=0;for(let b=0;b<d.length;b++){const m=d[b],w=c.cells[b];if(!w||!m)continue;let v=null;if(m.isHeader?v=m.originalNode:(v=p[h]?.originalNode||null,h++),v&&w.node){const x=w.node.type.create(v.attrs,v.content,v.marks);f.push(x)}else f.push(w.node)}const C=[...c.cells].reverse(),g=[...f].reverse();return C.forEach((b,m)=>{const w=g[m];if(w&&b.node){const v=b.pos+b.node.nodeSize;a.replaceWith(b.pos,v,w)}}),a.docChanged?(i.dispatch(a),!0):!1}catch(s){return console.error(`Error sorting table ${n}:`,s),!1}}function ad({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:r}){return!e||!e.isEditable||!_(e,jl)||!ne(e,r)||!Q(e,t,n,r)?!1:o?Gn({editor:e,index:t,orientation:n,tablePos:r}):!0}function Kn(e={direction:"asc"}){const{editor:t,index:n,orientation:o,tablePos:r,direction:s,hideWhenUnavailable:i=!1,onSorted:a}=e,{editor:c}=k(t),d=D(),p=Q(c,n,o),f=ad({editor:c,index:n,orientation:o,hideWhenUnavailable:i,tablePos:r}),h=Gn({editor:c,index:n,orientation:o,tablePos:r}),C=u.useCallback(()=>{const m=id({editor:c,index:n,orientation:o,direction:s,tablePos:r});return m&&a?.(),m},[c,n,o,s,r,a]),g=u.useMemo(()=>p?.orientation==="column"?s==="asc"?d.sortColumnAsc:d.sortColumnDesc:s==="asc"?d.sortRowAsc:d.sortRowDesc,[s,d.sortColumnAsc,d.sortColumnDesc,d.sortRowAsc,d.sortRowDesc,p]),b=u.useMemo(()=>ld[s]||qn,[s]);return{isVisible:f,canSortRowColumn:h,handleSort:C,label:g,Icon:b}}function Ct({orientation:e="horizontal",size:t,style:n={},...o}){const r={...n,...e==="horizontal"&&!t&&{flex:1},...t&&{width:e==="vertical"?"1px":t,height:e==="horizontal"?"1px":t}};return l.jsx("div",{...o,style:r})}const R=u.forwardRef(({variant:e,size:t="default",appearance:n="default",trimText:o=!1,className:r,children:s,...i},a)=>l.jsx("div",{ref:a,className:`tiptap-badge ${r||""}`,"data-style":e,"data-size":t,"data-appearance":n,"data-text-trim":o?"on":"off",...i,children:s}));R.displayName="Badge";function cd({shortcutKeys:e=Yn}){return l.jsx(R,{children:J({shortcutKeys:e})})}const gt=u.forwardRef(({editor:e,textColor:t,text:n,hideWhenUnavailable:o=!1,onApplied:r,showShortcut:s=!1,onClick:i,children:a,style:c,...d},p)=>{const{editor:f}=k(e),{isVisible:h,canColorText:C,isActive:g,handleColorText:b,label:m,shortcutKeys:w,Icon:v}=Jl({editor:f,textColor:t,label:n||`Color text to ${t}`,hideWhenUnavailable:o,onApplied:r}),y=u.useCallback(S=>{i?.(S),!S.defaultPrevented&&b()},[b,i]),x=u.useMemo(()=>({...c,"--color-text-button-color":t}),[t,c]);return h?l.jsx(M,{type:"button",variant:"ghost","data-active-state":g?"on":"off",role:"button",tabIndex:-1,disabled:!C,"data-disabled":!C,"aria-label":m,"aria-pressed":g,tooltip:m,onClick:y,style:x,...d,ref:p,children:a??l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tiptap-button-color-text",style:{color:t},children:l.jsx(v,{className:"tiptap-button-icon",style:{color:t,flexGrow:1}})}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(cd,{shortcutKeys:w})]})}):null});gt.displayName="ColorTextButton";function re(e="max",t=768){const[n,o]=u.useState(void 0);return u.useEffect(()=>{const r=e==="min"?`(min-width: ${t}px)`:`(max-width: ${t-1}px)`,s=window.matchMedia(r),i=a=>o(a.matches);return o(s.matches),s.addEventListener("change",i),()=>s.removeEventListener("change",i)},[e,t]),!!n}const Nt=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.8944 5.55279C12.725 5.214 12.3787 5 12 5C11.6212 5 11.2749 5.214 11.1055 5.55279L5.10555 17.5528C4.85856 18.0468 5.05878 18.6474 5.55276 18.8944C6.04674 19.1414 6.64741 18.9412 6.8944 18.4472L8.64957 14.9369C8.75862 14.9777 8.87671 15 9 15H15C15.1233 15 15.2413 14.9777 15.3504 14.9369L17.1055 18.4472C17.3525 18.9412 17.9532 19.1414 18.4472 18.8944C18.9412 18.6474 19.1414 18.0468 18.8944 17.5528L12.8944 5.55279ZM14.3819 13L12 8.23607L9.61801 13H14.3819Z",fill:"currentColor"})}));Nt.displayName="TextColorSmallIcon";const Yn="mod+shift+t",Ht=[{label:"Default text",value:"var(--tt-color-text)",border:"var(--tt-color-text-contrast)"},{label:"Gray text",value:"var(--tt-color-text-gray)",border:"var(--tt-color-text-gray-contrast)"},{label:"Brown text",value:"var(--tt-color-text-brown)",border:"var(--tt-color-text-brown-contrast)"},{label:"Orange text",value:"var(--tt-color-text-orange)",border:"var(--tt-color-text-orange-contrast)"},{label:"Yellow text",value:"var(--tt-color-text-yellow)",border:"var(--tt-color-text-yellow-contrast)"},{label:"Green text",value:"var(--tt-color-text-green)",border:"var(--tt-color-text-green-contrast)"},{label:"Blue text",value:"var(--tt-color-text-blue)",border:"var(--tt-color-text-blue-contrast)"},{label:"Purple text",value:"var(--tt-color-text-purple)",border:"var(--tt-color-text-purple-contrast)"},{label:"Pink text",value:"var(--tt-color-text-pink)",border:"var(--tt-color-text-pink-contrast)"},{label:"Red text",value:"var(--tt-color-text-red)",border:"var(--tt-color-text-red-contrast)"}];function Vt(e){if(!e||!e.isEditable||!Ae("textStyle",e)||ie(e,["image"]))return!1;try{return e.can().setMark("textStyle",{color:"currentColor"})}catch{return!1}}function dd(e,t){return!e||!e.isEditable?!1:e.isActive("textStyle",{color:t})}function ud(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!Ae("textStyle",t)?!1:t.isActive("code")?!0:Vt(t):!0:!1}function Jl(e){const{editor:t,label:n,textColor:o,hideWhenUnavailable:r=!1,onApplied:s}=e,{editor:i}=k(t),a=re(),[c,d]=u.useState(!0),p=Vt(i),f=dd(i,o);u.useEffect(()=>{if(!i)return;const C=()=>{d(ud({editor:i,hideWhenUnavailable:r}))};return C(),i.on("selectionUpdate",C),()=>{i.off("selectionUpdate",C)}},[i,r]);const h=u.useCallback(()=>{if(!i||!p)return!1;if(i.state.storedMarks){const C=i.schema.marks.textStyle;C&&i.view.dispatch(i.state.tr.removeStoredMark(C))}setTimeout(()=>{_1(i);const C=i.chain().focus(void 0,{scrollIntoView:!1}).toggleMark("textStyle",{color:o}).run();return C&&s?.({color:o,label:n}),C},0)},[i,p,o,s,n]);return ue.useHotkeys(Yn,C=>{C.preventDefault(),h()},{enabled:c&&p,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:c,isActive:f,handleColorText:h,canColorText:p,label:n||`Color text to ${o}`,shortcutKeys:Yn,Icon:Nt}}function fd({shortcutKeys:e=jn}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Re=u.forwardRef(({editor:e,highlightColor:t,text:n,hideWhenUnavailable:o=!1,mode:r="mark",onApplied:s,showShortcut:i=!1,onClick:a,children:c,style:d,useColorValue:p=!1,...f},h)=>{const{editor:C}=k(e),{isVisible:g,canColorHighlight:b,isActive:m,handleColorHighlight:w,label:v,shortcutKeys:y}=Dt({editor:C,highlightColor:t,useColorValue:p,label:n||`Toggle highlight (${t})`,hideWhenUnavailable:o,mode:r,onApplied:s}),x=u.useCallback(L=>{a?.(L),!L.defaultPrevented&&w()},[w,a]),S=u.useMemo(()=>({...d,"--highlight-color":t}),[t,d]);return g?l.jsx(M,{type:"button",variant:"ghost","data-active-state":m?"on":"off",role:"button",tabIndex:-1,disabled:!b,"data-disabled":!b,"aria-label":v,"aria-pressed":m,tooltip:v,onClick:x,style:S,...f,ref:h,children:c??l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tiptap-button-highlight",style:{"--highlight-color":t}}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),i&&l.jsx(fd,{shortcutKeys:y})]})}):null});Re.displayName="ColorHighlightButton";const Bt=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.7072 4.70711C15.0977 4.31658 15.0977 3.68342 14.7072 3.29289C14.3167 2.90237 13.6835 2.90237 13.293 3.29289L8.69294 7.89286L8.68594 7.9C8.13626 8.46079 7.82837 9.21474 7.82837 10C7.82837 10.2306 7.85491 10.4584 7.90631 10.6795L2.29289 16.2929C2.10536 16.4804 2 16.7348 2 17V20C2 20.5523 2.44772 21 3 21H12C12.2652 21 12.5196 20.8946 12.7071 20.7071L15.3205 18.0937C15.5416 18.1452 15.7695 18.1717 16.0001 18.1717C16.7853 18.1717 17.5393 17.8639 18.1001 17.3142L22.7072 12.7071C23.0977 12.3166 23.0977 11.6834 22.7072 11.2929C22.3167 10.9024 21.6835 10.9024 21.293 11.2929L16.6971 15.8887C16.5105 16.0702 16.2605 16.1717 16.0001 16.1717C15.7397 16.1717 15.4897 16.0702 15.303 15.8887L10.1113 10.697C9.92992 10.5104 9.82837 10.2604 9.82837 10C9.82837 9.73963 9.92992 9.48958 10.1113 9.30297L14.7072 4.70711ZM13.5858 17L9.00004 12.4142L4 17.4142V19H11.5858L13.5858 17Z",fill:"currentColor"})}));Bt.displayName="HighlighterIcon";const jn="mod+shift+h",et=[{label:"Default background",value:"var(--tt-bg-color)",colorValue:"#ffffff",border:"var(--tt-bg-color-contrast)"},{label:"Gray background",value:"var(--tt-color-highlight-gray)",colorValue:"#f8f8f7",border:"var(--tt-color-highlight-gray-contrast)"},{label:"Brown background",value:"var(--tt-color-highlight-brown)",colorValue:"#f4eeee",border:"var(--tt-color-highlight-brown-contrast)"},{label:"Orange background",value:"var(--tt-color-highlight-orange)",colorValue:"#fbecdd",border:"var(--tt-color-highlight-orange-contrast)"},{label:"Yellow background",value:"var(--tt-color-highlight-yellow)",colorValue:"#fef9c3",border:"var(--tt-color-highlight-yellow-contrast)"},{label:"Green background",value:"var(--tt-color-highlight-green)",colorValue:"#dcfce7",border:"var(--tt-color-highlight-green-contrast)"},{label:"Blue background",value:"var(--tt-color-highlight-blue)",colorValue:"#e0f2fe",border:"var(--tt-color-highlight-blue-contrast)"},{label:"Purple background",value:"var(--tt-color-highlight-purple)",colorValue:"#f3e8ff",border:"var(--tt-color-highlight-purple-contrast)"},{label:"Pink background",value:"var(--tt-color-highlight-pink)",colorValue:"#fcf1f6",border:"var(--tt-color-highlight-pink-contrast)"},{label:"Red background",value:"var(--tt-color-highlight-red)",colorValue:"#ffe4e6",border:"var(--tt-color-highlight-red-contrast)"}];function Ql(e){const t=new Map(et.map(n=>[n.value,n]));return e.map(n=>t.get(n)).filter(n=>!!n)}function pd(e,t=!1){return t&&et.find(o=>o.value===e||o.colorValue===e)?.colorValue||e}function _e(e,t="mark"){if(!e||!e.isEditable)return!1;if(t==="mark")return!Ae("highlight",e)||ie(e,["image"])?!1:e.can().setMark("highlight");if(!_(e,["nodeBackground"]))return!1;try{return e.can().toggleNodeBackgroundColor("test")}catch{return!1}}function hd(e,t,n="mark"){if(!e||!e.isEditable)return!1;if(n==="mark")return t?e.isActive("highlight",{color:t}):e.isActive("highlight");if(!t)return!1;try{const{state:o}=e,{selection:r}=o,s=r.$anchor;for(let i=s.depth;i>=0;i--){const a=s.node(i);if(a&&a.attrs?.backgroundColor===t)return!0}return!1}catch{return!1}}function Cd(e,t="mark"){return!e||!e.isEditable||!_e(e,t)?!1:t==="mark"?e.chain().focus(void 0,{scrollIntoView:!1}).unsetMark("highlight").run():e.chain().focus(void 0,{scrollIntoView:!1}).unsetNodeBackgroundColor().run()}function gd(e){const{editor:t,hideWhenUnavailable:n,mode:o}=e;if(!t)return!1;if(!n)return!0;if(!t.isEditable)return!1;if(o==="mark"){if(!Ae("highlight",t))return!1}else if(!_(t,["nodeBackground"]))return!1;return t.isActive("code")?!0:_e(t,o)}function Dt(e){const{editor:t,label:n,highlightColor:o,hideWhenUnavailable:r=!1,mode:s="mark",useColorValue:i=!1,onApplied:a}=e,{editor:c}=k(t),d=D(),p=re(),f=n||d.highlightColor,[h,C]=u.useState(!0),g=_e(c,s),b=o&&pd(o,i),m=hd(c,b,s);u.useEffect(()=>{if(!c)return;const y=()=>{C(gd({editor:c,hideWhenUnavailable:r,mode:s}))};return y(),c.on("selectionUpdate",y),()=>{c.off("selectionUpdate",y)}},[c,r,s]);const w=u.useCallback(()=>{if(!c||!g||!b||!f)return!1;if(s==="mark"){if(c.state.storedMarks){const y=c.schema.marks.highlight;y&&c.view.dispatch(c.state.tr.removeStoredMark(y))}return setTimeout(()=>{const y=c.chain().focus(void 0,{scrollIntoView:!1}).toggleHighlight({color:b}).run();return y&&a?.({color:b,label:f,mode:s}),y},0),!0}else{const y=c.chain().focus(void 0,{scrollIntoView:!1}).toggleNodeBackgroundColor(b).run();return y&&a?.({color:b,label:f,mode:s}),y}},[g,b,c,f,a,s]),v=u.useCallback(()=>{const y=Cd(c,s);return y&&a?.({color:"",label:d.removeHighlight,mode:s}),y},[c,d.removeHighlight,a,s]);return ue.useHotkeys(jn,y=>{y.preventDefault(),w()},{enabled:h&&g,enableOnContentEditable:!p,enableOnFormTags:!0}),{isVisible:h,isActive:m,handleColorHighlight:w,handleRemoveHighlight:v,canColorHighlight:g,label:f,shortcutKeys:jn,Icon:Bt,mode:s}}function Ut({editor:e,containerRef:t,query:n,items:o,onSelect:r,onClose:s,orientation:i="vertical",autoSelectFirstItem:a=!0}){const[c,d]=u.useState(a?0:-1);return u.useEffect(()=>{const p=C=>{C.preventDefault(),C.stopPropagation()},f=C=>{if(!o.length)return!1;const g=()=>d(m=>m===-1?0:(m+1)%o.length),b=()=>d(m=>m===-1?o.length-1:(m-1+o.length)%o.length);switch(C.key){case"ArrowUp":return i==="horizontal"?!1:(p(C),b(),!0);case"ArrowDown":return i==="horizontal"?!1:(p(C),g(),!0);case"ArrowLeft":return i==="vertical"?!1:(p(C),b(),!0);case"ArrowRight":return i==="vertical"?!1:(p(C),g(),!0);case"Tab":return p(C),C.shiftKey?b():g(),!0;case"Home":return p(C),d(0),!0;case"End":return p(C),d(o.length-1),!0;case"Enter":return C.isComposing?!1:(p(C),c!==-1&&o[c]&&r?.(o[c]),!0);case"Escape":return p(C),s?.(),!0;default:return!1}};let h=null;if(e?h=e.view.dom:t?.current&&(h=t.current),h)return h.addEventListener("keydown",f,!0),()=>{h?.removeEventListener("keydown",f,!0)}},[e,t,o,c,r,s,i]),u.useEffect(()=>{n&&d(a?0:-1)},[n,a]),{selectedIndex:o.length?c:void 0,setSelectedIndex:d}}const Xn=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z",fill:"currentColor"})}));Xn.displayName="ChevronDownIcon";function Ot({...e}){return l.jsx(It.Root,{...e})}function Pt({...e}){return l.jsx(It.Trigger,{...e})}function Wt({className:e,align:t="center",sideOffset:n=4,...o}){return l.jsx(It.Portal,{children:l.jsx(It.Content,{align:t,sideOffset:n,className:$("tiptap-popover",e),...o})})}const Ze=u.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:$("tiptap-card",e),...t}));Ze.displayName="Card";const bd=u.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:$("tiptap-card-header",e),...t}));bd.displayName="CardHeader";const Fe=u.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:$("tiptap-card-body",e),...t}));Fe.displayName="CardBody";const Me=u.forwardRef(({className:e,orientation:t="vertical",...n},o)=>l.jsx("div",{ref:o,"data-orientation":t,className:$("tiptap-card-item-group",e),...n}));Me.displayName="CardItemGroup";const bt=u.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:$("tiptap-card-group-label",e),...t}));bt.displayName="CardGroupLabel";const md=u.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:$("tiptap-card-footer",e),...t}));md.displayName="CardFooter";const wd=Cn.cva("tiptap-button-group",{variants:{orientation:{horizontal:"tiptap-button-group-horizontal",vertical:"tiptap-button-group-vertical"}},defaultVariants:{orientation:"horizontal"}});function fe({className:e,orientation:t,...n}){return l.jsx("div",{role:"group","data-slot":"tiptap-button-group","data-orientation":t,className:$(wd({orientation:t}),e),...n})}function vd({colorObj:e,withLabel:t=!1,onColorChanged:n,editor:o,resolveColorValue:r,...s}){const i=e.type==="text"?Ht:et,a=es(e.value,i),c=a.label===a.value?e.label:a.label,d=r?.({type:e.type,label:c,value:e.value})??e.value,p={tooltip:c,text:t?c:void 0,onApplied:()=>n?.({type:e.type,label:c,value:a.value}),...s};return e.type==="text"?l.jsx(gt,{textColor:d,label:c,editor:o,...p}):l.jsx(Re,{highlightColor:d,label:c,editor:o,...p})}function Rl({type:e,colors:t,onColorSelected:n,selectedIndex:o,startIndexOffset:r,editor:s,resolveColorValue:i}){return t.map((a,c)=>l.jsx(fe,{children:a.map((d,p)=>{const f=r+t.slice(0,c).reduce((b,m)=>b+m.length,0)+p,h=o===f,C=i?.({type:e,label:d.label,value:d.value})??d.value,g={tooltip:d.label,onApplied:()=>n({type:e,label:d.label,value:d.value}),tabIndex:h?0:-1,"data-highlighted":h,"aria-label":`${d.label} ${e==="text"?"text":"highlight"} color`};return e==="text"?l.jsx(fe,{children:l.jsx(gt,{textColor:C,label:d.label,editor:s,...g})},`${e}-${d.value}-${p}`):l.jsx(fe,{children:l.jsx(Re,{highlightColor:C,label:d.label,editor:s,...g})},`${e}-${d.value}-${p}`)})},`${e}-group-${c}`))}function yd({recentColors:e,onColorSelected:t,selectedIndex:n,editor:o,resolveColorValue:r}){const s=D();return e.length===0?null:l.jsxs(Me,{children:[l.jsx(bt,{children:s.recentColors}),l.jsx(fe,{children:e.map((i,a)=>l.jsx(fe,{children:l.jsx(vd,{colorObj:i,onColorChanged:t,tabIndex:n===a?0:-1,"data-highlighted":n===a,editor:o,resolveColorValue:r})},`recent-${i.type}-${i.value}`))})]})}function xd({maxColorsPerGroup:e=5,maxRecentColors:t=3,onColorChanged:n,editor:o,resolveColorValue:r}){const s=D(),{recentColors:i,addRecentColor:a,isInitialized:c}=mt(t),d=u.useRef(null),p=u.useMemo(()=>_r(Ht,e),[e]),f=u.useMemo(()=>_r(et,e),[e]),h=u.useMemo(()=>p.flat(),[p]),C=u.useMemo(()=>f.flat(),[f]),g=u.useMemo(()=>c?i.length:0,[c,i.length]),b=u.useMemo(()=>g+h.length,[g,h.length]),m=u.useMemo(()=>{const y=[];return c&&i.length>0&&y.push(...i.map(x=>({type:x.type,value:x.value,label:x.type==="text"?s.recentTextColor:s.recentHighlightColor,group:"recent"}))),y.push(...h.map(x=>({type:"text",value:x.value,label:x.label,group:"text"}))),y.push(...C.map(x=>({type:"highlight",value:x.value,label:x.label,group:"highlight"}))),y},[c,i,h,C]),w=u.useCallback(({type:y,label:x,value:S})=>{if(!d.current)return!1;d.current.querySelector('[data-highlighted="true"]')?.click(),a({type:y,label:x,value:S}),n?.({type:y,label:x,value:S})},[a,n]),{selectedIndex:v}=Ut({containerRef:d,items:m,onSelect:y=>{y&&w({type:y.type,label:y.label,value:y.value})},orientation:"both",autoSelectFirstItem:!1});return l.jsx(Ze,{ref:d,tabIndex:0,role:"menu",children:l.jsxs(Fe,{children:[c&&l.jsx(yd,{recentColors:i,onColorSelected:w,selectedIndex:v,editor:o,resolveColorValue:r}),l.jsxs(Me,{children:[l.jsx(bt,{children:s.textColor}),l.jsx(Rl,{type:"text",colors:p,onColorSelected:w,selectedIndex:v,startIndexOffset:g,editor:o,resolveColorValue:r})]}),l.jsxs(Me,{children:[l.jsx(bt,{children:s.highlightColor}),l.jsx(Rl,{type:"highlight",colors:f,onColorSelected:w,selectedIndex:v,startIndexOffset:b,editor:o,resolveColorValue:r})]})]})})}function kd({editor:e,hideWhenUnavailable:t=!1,onColorChanged:n,onClick:o,children:r,ref:s,resolveColorValue:i,...a}){const{editor:c}=k(e),d=D(),[p,f]=u.useState(!1),{isVisible:h,canToggle:C,activeTextStyle:g,activeHighlight:b,handleColorChanged:m,label:w,Icon:v}=Td({editor:c,hideWhenUnavailable:t,onColorChanged:n}),y=u.useCallback(x=>{o?.(x),!x.defaultPrevented&&f(S=>!S)},[o]);return h?l.jsxs(Ot,{open:p,onOpenChange:f,children:[l.jsx(Pt,{asChild:!0,children:l.jsx(M,{type:"button",variant:"ghost","data-appearance":"default",role:"button","aria-label":w,tooltip:w,disabled:!C,"data-disabled":!C,onClick:y,ref:s,...a,children:r??l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tiptap-button-color-text-popover",style:b.color?{"--active-highlight-color":b.color}:{},children:l.jsx(v,{className:"tiptap-button-icon",style:{color:g.color||void 0}})}),l.jsx(Xn,{className:"tiptap-button-dropdown-small"})]})})}),l.jsx(Wt,{"aria-label":d.textColorOptions,side:"bottom",align:"start",collisionPadding:4,children:l.jsx(xd,{onColorChanged:m,editor:c,resolveColorValue:i})})]}):null}function es(e,t){return t.find(n=>n.value===e)??{value:e,label:e}}function Sd(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:Vt(t)||_e(t):!1:!0:!1}function mt(e=3){const[t,n]=u.useState([]),[o,r]=u.useState(!1);u.useEffect(()=>{try{const i=localStorage.getItem("tiptapRecentlyUsedColors");if(i){const a=JSON.parse(i);n(a.slice(0,e))}}catch(i){console.error("Failed to load stored colors:",i)}finally{r(!0)}},[e]);const s=u.useCallback(({type:i,label:a,value:c})=>{n(d=>{const p=d.filter(h=>!(h.type===i&&h.value===c)),f=[{type:i,label:a,value:c},...p].slice(0,e);try{localStorage.setItem("tiptapRecentlyUsedColors",JSON.stringify(f))}catch(h){console.error("Failed to store colors:",h)}return f})},[e]);return{recentColors:t,addRecentColor:s,isInitialized:o}}function Td(e){const{editor:t,hideWhenUnavailable:n=!1,onColorChanged:o}=e||{},{editor:r}=k(t),s=D(),[i,a]=u.useState(!0),c=Ae("textStyle",r),d=Ae("highlight",r),p=Zr(r,"textStyle")||{},f=Zr(r,"highlight")||{},h=Vt(r)||_e(r);u.useEffect(()=>{if(!r)return;const g=()=>{a(Sd({editor:r,hideWhenUnavailable:n}))};return g(),r.on("selectionUpdate",g),()=>{r.off("selectionUpdate",g)}},[r,n,d,c]);const C=u.useCallback(({type:g,label:b,value:m})=>{o?.({type:g,label:b,value:m})},[o]);return{isVisible:i,canToggle:h,activeTextStyle:p,activeHighlight:f,handleColorChanged:C,label:s.textColor,Icon:Nt}}const Jn=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.70711 1.29289C5.31658 0.902369 4.68342 0.902369 4.29289 1.29289C3.90237 1.68342 3.90237 2.31658 4.29289 2.70711L7.08575 5.49997L1.69282 10.8929L1.68582 10.9C1.13614 11.4608 0.828247 12.2147 0.828247 13C0.828247 13.7853 1.1361 14.5392 1.68578 15.1L6.89285 20.3071C8.08338 21.4976 9.91654 21.4976 11.1071 20.3071L19.7071 11.7071C20.0976 11.3166 20.0976 10.6834 19.7071 10.2929L11.7071 2.29289C11.3165 1.90237 10.6834 1.90237 10.2929 2.29289L8.49997 4.08576L5.70711 1.29289ZM17.5857 11L16.5857 12H3.41418L8.49998 6.91419L9.29289 7.70711C9.68342 8.09763 10.3166 8.09763 10.7071 7.70711C11.0976 7.31658 11.0976 6.68342 10.7071 6.29289L9.91419 5.49998L11 4.41421L17.5857 11ZM14.5857 14H3.41418L8.30707 18.8929C8.71654 19.3024 9.28338 19.3024 9.69285 18.8929L14.5857 14Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.9829 15.8157C20.8942 15.3427 20.4812 15 20 15C19.5188 15 19.1058 15.3427 19.0171 15.8157C18.9233 16.3161 18.6226 16.706 18.1385 17.3337L18.0955 17.3895C17.6418 17.9781 17 18.8237 17 20C17 20.7957 17.3161 21.5587 17.8787 22.1213C18.4413 22.6839 19.2043 23 20 23C20.7957 23 21.5587 22.6839 22.1213 22.1213C22.6839 21.5587 23 20.7957 23 20C23 18.8237 22.3582 17.9781 21.9045 17.3895L21.8615 17.3337C21.3774 16.706 21.0767 16.3161 20.9829 15.8157ZM19 20C19 19.5763 19.2082 19.2219 19.6795 18.6105C19.714 18.5658 19.7503 18.5192 19.7881 18.4709C19.855 18.3851 19.9265 18.2935 20 18.1963C20.0735 18.2935 20.1449 18.385 20.2119 18.4708C20.2496 18.5192 20.286 18.5658 20.3205 18.6105C20.7918 19.2219 21 19.5763 21 20C21 20.2652 20.8946 20.5196 20.7071 20.7071C20.5196 20.8946 20.2652 21 20 21C19.7348 21 19.4804 20.8946 19.2929 20.7071C19.1054 20.5196 19 20.2652 19 20Z",fill:"currentColor"})]}));Jn.displayName="MoreVerticalIcon";const tt=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.29289 5.29289C8.68342 4.90237 9.31658 4.90237 9.70711 5.29289L15.7071 11.2929C16.0976 11.6834 16.0976 12.3166 15.7071 12.7071L9.70711 18.7071C9.31658 19.0976 8.68342 19.0976 8.29289 18.7071C7.90237 18.3166 7.90237 17.6834 8.29289 17.2929L13.5858 12L8.29289 6.70711C7.90237 6.31658 7.90237 5.68342 8.29289 5.29289Z",fill:"currentColor"})}));tt.displayName="ChevronRightIcon";const Ad={text:{"Default text":"defaultTextColor","Gray text":"grayTextColor","Brown text":"brownTextColor","Orange text":"orangeTextColor","Yellow text":"yellowTextColor","Green text":"greenTextColor","Blue text":"blueTextColor","Purple text":"purpleTextColor","Pink text":"pinkTextColor","Red text":"redTextColor"},highlight:{"Default background":"defaultBackgroundColor","Gray background":"grayBackgroundColor","Brown background":"brownBackgroundColor","Orange background":"orangeBackgroundColor","Yellow background":"yellowBackgroundColor","Green background":"greenBackgroundColor","Blue background":"blueBackgroundColor","Purple background":"purpleBackgroundColor","Pink background":"pinkBackgroundColor","Red background":"redBackgroundColor"}};function ts(e,t,n){return e.map(o=>{const r=Ad[t][o.label];return r?{...o,label:n[r]}:o})}const ns=({editor:e,color:t})=>{const{addRecentColor:n}=mt(),{isActive:o,handleColorText:r,label:s}=Jl({editor:e,label:t.label,textColor:t.value,onApplied:({color:i,label:a})=>n({type:"text",label:a,value:i})});return l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":o?"on":"off"}),onClick:r,children:[l.jsx("span",{className:"tiptap-button-color-text",style:{color:t.value},children:l.jsx(Nt,{className:"tiptap-button-icon",style:{color:t.value,flexGrow:1}})}),l.jsx("span",{className:"tiptap-button-text",children:s})]})},os=({editor:e,color:t})=>{const{addRecentColor:n}=mt(),{isActive:o,handleColorHighlight:r,label:s}=Dt({editor:e,label:t.label,highlightColor:t.value,mode:"node",onApplied:({color:i,label:a})=>n({type:"highlight",label:a,value:i})});return l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":o?"on":"off"}),onClick:r,children:[l.jsx("span",{className:"tiptap-button-highlight",style:{"--highlight-color":t.value}}),l.jsx("span",{className:"tiptap-button-text",children:s})]})},Id=({editor:e,colorObj:t,textColors:n,highlightColors:o})=>{const r=t.type==="text"?n:o,s=es(t.value,r),i=t.type==="text"?ns:os;return l.jsx(i,{editor:e,color:s})},Qn=({editor:e,trigger:t,label:n,placement:o="right"})=>{const{editor:r}=k(e),s=D(),{recentColors:i,isInitialized:a}=mt(),c=n??s.color,d=u.useMemo(()=>ts(Ht,"text",s),[s]),p=u.useMemo(()=>ts(et,"highlight",s),[s]),f=!!r?.can().setMark("textStyle")||!!r?.can().setMark("highlight")||_e(r,"node")||!1;if(!r||!f)return null;const h=l.jsx(Ee,{render:l.jsx(Je,{render:l.jsxs(M,{variant:"ghost",children:[l.jsx(Jn,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:c}),l.jsx(Ct,{}),l.jsx(tt,{className:"tiptap-button-icon"})]})})});return l.jsx(je,{placement:o,trigger:t||h,children:l.jsx(Xe,{portal:!0,children:l.jsxs(Ye,{children:[a&&i.length>0&&l.jsxs(de,{children:[l.jsx(ft,{children:s.recentColors}),i.map(C=>l.jsx(Id,{editor:r,colorObj:C,textColors:d,highlightColors:p},C.value)),l.jsx(ee,{orientation:"horizontal"})]}),l.jsxs(de,{children:[l.jsx(ft,{children:s.textColor}),d.map(C=>l.jsx(ns,{editor:r,color:C},C.value))]}),l.jsx(ee,{orientation:"horizontal"}),l.jsxs(de,{children:[l.jsx(ft,{children:s.backgroundColor}),p.map(C=>l.jsx(os,{editor:r,color:C},C.value))]})]})})})},Ld=u.forwardRef(({editor:e,alignmentType:t,alignment:n,index:o,orientation:r,hideWhenUnavailable:s=!1,onAligned:i,text:a,onClick:c,children:d,...p},f)=>{const{editor:h}=k(e),{isVisible:C,handleAlign:g,label:b,canAlignCell:m,Icon:w,isActive:v}=ye({editor:h,alignmentType:t,alignment:n,index:o,orientation:r,hideWhenUnavailable:s,onAligned:i}),y=u.useCallback(x=>{c?.(x),!x.defaultPrevented&&g()},[g,c]);return C?l.jsx(M,{type:"button",disabled:!m,variant:"ghost","data-active-state":v?"on":"off","data-disabled":!m,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":v,tooltip:b,onClick:y,...p,ref:f,children:d??l.jsxs(l.Fragment,{children:[l.jsx(w,{className:"tiptap-button-icon"}),a&&l.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});Ld.displayName="TableAlignCellButton";const Rn=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H17C17.5523 17 18 17.4477 18 18C18 18.5523 17.5523 19 17 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));Rn.displayName="AlignLeftIcon";const eo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 12C6 11.4477 6.44772 11 7 11H17C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13H7C6.44772 13 6 12.5523 6 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 18C4 17.4477 4.44772 17 5 17H19C19.5523 17 20 17.4477 20 18C20 18.5523 19.5523 19 19 19H5C4.44772 19 4 18.5523 4 18Z",fill:"currentColor"})]}));eo.displayName="AlignCenterIcon";const to=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 18C6 17.4477 6.44772 17 7 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H7C6.44772 19 6 18.5523 6 18Z",fill:"currentColor"})]}));to.displayName="AlignRightIcon";const no=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));no.displayName="AlignJustifyIcon";const oo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M11 11.5858L9.70711 10.2929C9.31658 9.90237 8.68342 9.90237 8.29289 10.2929C7.90237 10.6834 7.90237 11.3166 8.29289 11.7071L11.2929 14.7071C11.6834 15.0976 12.3166 15.0976 12.7071 14.7071L15.7071 11.7071C16.0976 11.3166 16.0976 10.6834 15.7071 10.2929C15.3166 9.90237 14.6834 9.90237 14.2929 10.2929L13 11.5858V4C13 3.44771 12.5523 3 12 3C11.4477 3 11 3.44771 11 4V11.5858Z",fill:"currentColor"}),l.jsx("path",{d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));oo.displayName="AlignBottomIcon";const ro=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M2 4C2 3.44772 2.44772 3 3 3H21C21.5523 3 22 3.44772 22 4C22 4.55228 21.5523 5 21 5H3C2.44772 5 2 4.55228 2 4Z",fill:"currentColor"}),l.jsx("path",{d:"M13 10.4142L14.2929 11.7071C14.6834 12.0976 15.3166 12.0976 15.7071 11.7071C16.0976 11.3166 16.0976 10.6834 15.7071 10.2929L12.7071 7.29289C12.3166 6.90237 11.6834 6.90237 11.2929 7.29289L8.29289 10.2929C7.90237 10.6834 7.90237 11.3166 8.29289 11.7071C8.68342 12.0976 9.31658 12.0976 9.70711 11.7071L11 10.4142L11 20C11 20.5523 11.4477 21 12 21C12.5523 21 13 20.5523 13 20L13 10.4142Z",fill:"currentColor"})]}));ro.displayName="AlignTopIcon";const rs=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M3 12H21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M12 22V16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M12 2L12 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M15 19L12 16L9 19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M9 5L12 8L15 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));rs.displayName="AlignMiddleIcon";const lo=["table"],ls={text:{left:"Align left",center:"Align center",right:"Align right",justify:"Justify"},vertical:{top:"Align top",middle:"Align middle",bottom:"Align bottom"}},ss={text:{left:Rn,center:eo,right:to,justify:no},vertical:{top:ro,middle:rs,bottom:oo}};function _t(e){if(!e||!e.isEditable||!_(e,lo))return!1;try{return e.isActive("tableCell")||e.isActive("tableHeader")}catch{return!1}}function so({editor:e,index:t,orientation:n}){if(!e||!e.isEditable||!_(e,lo))return!1;try{return!(!ne(e)||ge(e,t,n).cells.length===0)}catch{return!1}}function Ed(e,t){if(!_t(e)||!e)return null;try{const{selection:n}=e.state,o=n.$anchor;let r=null;for(let i=o.depth;i>=0;i--){const a=o.node(i);if(a.type.name==="tableCell"||a.type.name==="tableHeader"){r=a;break}}if(!r)return null;const s=r.attrs||{};return t==="text"?s.nodeTextAlign||"left":s.nodeVerticalAlign||"top"}catch{return null}}function Md(e,t,n,o){if(!e)return null;try{const r=ge(e,n,o);if(r.cells.length===0)return null;const s=r.cells[0];if(!s?.node)return null;const i=s.node.attrs||{};return t==="text"?i.nodeTextAlign||"left":i.nodeVerticalAlign||"top"}catch{return null}}function Nd(e,t,n){if(!_t(e)||!e)return!1;try{return t==="text"?e.commands.setCellAttribute("nodeTextAlign",n):e.commands.setCellAttribute("nodeVerticalAlign",n)}catch(o){return console.error("Error setting table cell alignment:",o),!1}}function Hd({editor:e,alignmentType:t,alignment:n,index:o,orientation:r}){if(!so({editor:e,index:o,orientation:r})||!e)return!1;try{const{state:s,view:i}=e,a=s.tr,c=ge(e,o,r);if(c.cells.length===0)return!1;const d=new Map;if(c.cells.forEach(h=>{h.node&&h.pos!==void 0&&d.set(h.pos,h)}),d.size===0)return!1;const p=Array.from(d.values()).sort((h,C)=>C.pos-h.pos),f=t==="text"?"nodeTextAlign":"nodeVerticalAlign";return p.forEach(h=>{if(h.node&&h.pos!==void 0){const g=h.node.type.create({...h.node.attrs,[f]:n},h.node.content,h.node.marks),b=h.pos+h.node.nodeSize;a.replaceWith(h.pos,b,g)}}),a.docChanged?(i.dispatch(a),!0):!1}catch(s){return console.error(`Error aligning table ${r}:`,s),!1}}function Vd({editor:e,alignmentType:t,alignment:n,index:o,orientation:r}){if(!e)return!1;try{return typeof o=="number"&&r?Hd({editor:e,alignmentType:t,alignment:n,index:o,orientation:r}):Nd(e,t,n)}catch(s){return console.error("Error aligning table cell:",s),!1}}function Bd({editor:e,hideWhenUnavailable:t,index:n,orientation:o}){return!e||!e.isEditable||!_(e,lo)?!1:t?typeof n=="number"&&o?so({editor:e,index:n,orientation:o}):_t(e):!0}function ye(e){const{editor:t,alignmentType:n,alignment:o,index:r,orientation:s,hideWhenUnavailable:i=!1,onAligned:a}=e,{editor:c}=k(t),d=Bd({editor:c,hideWhenUnavailable:i,index:r,orientation:s}),p=()=>typeof r=="number"&&s?so({editor:c,index:r,orientation:s}):_t(c),f=()=>typeof r=="number"&&s?Md(c,n,r,s):Ed(c,n),h=f()===o,C=u.useCallback(()=>{const m=Vd({editor:c,alignmentType:n,alignment:o,index:r,orientation:s});return m&&a?.(o),m},[c,n,o,r,s,a]),g=u.useMemo(()=>n==="text"?ls.text[o]:ls.vertical[o],[n,o]),b=u.useMemo(()=>n==="text"?ss.text[o]:ss.vertical[o],[n,o]);return{isVisible:d,canAlignCell:p,handleAlign:C,label:g,Icon:b,isActive:h,currentAlignment:f}}const is=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M3 16C3.55228 16 4 16.4477 4 17V19L4.00488 19.0986C4.02757 19.3276 4.12883 19.5429 4.29297 19.707C4.48051 19.8946 4.73478 20 5 20H7C7.55228 20 8 20.4477 8 21C8 21.5523 7.55228 22 7 22H5C4.20435 22 3.44151 21.6837 2.87891 21.1211C2.3163 20.5585 2 19.7957 2 19V17C2 16.4477 2.44772 16 3 16Z",fill:"currentColor"}),l.jsx("path",{d:"M21 16C21.5523 16 22 16.4477 22 17V19C22 19.7957 21.6837 20.5585 21.1211 21.1211C20.5585 21.6837 19.7957 22 19 22H17C16.4477 22 16 21.5523 16 21C16 20.4477 16.4477 20 17 20H19C19.2652 20 19.5195 19.8946 19.707 19.707C19.8946 19.5195 20 19.2652 20 19V17C20 16.4477 20.4477 16 21 16Z",fill:"currentColor"}),l.jsx("path",{d:"M7 16C7.55228 16 8 16.4477 8 17C8 17.5523 7.55228 18 7 18C6.44772 18 6 17.5523 6 17C6 16.4477 6.44772 16 7 16Z",fill:"currentColor"}),l.jsx("path",{d:"M12 16C12.5523 16 13 16.4477 13 17C13 17.5523 12.5523 18 12 18C11.4477 18 11 17.5523 11 17C11 16.4477 11.4477 16 12 16Z",fill:"currentColor"}),l.jsx("path",{d:"M17 16C17.5523 16 18 16.4477 18 17C18 17.5523 17.5523 18 17 18C16.4477 18 16 17.5523 16 17C16 16.4477 16.4477 16 17 16Z",fill:"currentColor"}),l.jsx("path",{d:"M7 11C7.55228 11 8 11.4477 8 12C8 12.5523 7.55228 13 7 13C6.44772 13 6 12.5523 6 12C6 11.4477 6.44772 11 7 11Z",fill:"currentColor"}),l.jsx("path",{d:"M12 11C12.5523 11 13 11.4477 13 12C13 12.5523 12.5523 13 12 13C11.4477 13 11 12.5523 11 12C11 11.4477 11.4477 11 12 11Z",fill:"currentColor"}),l.jsx("path",{d:"M17 11C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13C16.4477 13 16 12.5523 16 12C16 11.4477 16.4477 11 17 11Z",fill:"currentColor"}),l.jsx("path",{d:"M7 2C7.55228 2 8 2.44772 8 3C8 3.55228 7.55228 4 7 4H5C4.73478 4 4.4805 4.10543 4.29297 4.29297C4.10543 4.4805 4 4.73478 4 5V7C4 7.55228 3.55228 8 3 8C2.44772 8 2 7.55228 2 7V5C2 4.20435 2.3163 3.44152 2.87891 2.87891C3.44152 2.3163 4.20435 2 5 2H7Z",fill:"currentColor"}),l.jsx("path",{d:"M7 6C7.55228 6 8 6.44772 8 7C8 7.55228 7.55228 8 7 8C6.44772 8 6 7.55228 6 7C6 6.44772 6.44772 6 7 6Z",fill:"currentColor"}),l.jsx("path",{d:"M12 6C12.5523 6 13 6.44772 13 7C13 7.55228 12.5523 8 12 8C11.4477 8 11 7.55228 11 7C11 6.44772 11.4477 6 12 6Z",fill:"currentColor"}),l.jsx("path",{d:"M17 6C17.5523 6 18 6.44772 18 7C18 7.55228 17.5523 8 17 8C16.4477 8 16 7.55228 16 7C16 6.44772 16.4477 6 17 6Z",fill:"currentColor"}),l.jsx("path",{d:"M19 2C19.7957 2 20.5585 2.3163 21.1211 2.87891C21.6837 3.44151 22 4.20435 22 5V7C22 7.55228 21.5523 8 21 8C20.4477 8 20 7.55228 20 7V5C20 4.73478 19.8946 4.48051 19.707 4.29297C19.5429 4.12883 19.3276 4.02757 19.0986 4.00488L19 4H17C16.4477 4 16 3.55228 16 3C16 2.44772 16.4477 2 17 2H19Z",fill:"currentColor"})]}));is.displayName="AlignmentIcon";const io=({index:e,orientation:t})=>{const n=D(),o={left:ye({alignmentType:"text",alignment:"left",index:e,orientation:t}),center:ye({alignmentType:"text",alignment:"center",index:e,orientation:t}),right:ye({alignmentType:"text",alignment:"right",index:e,orientation:t})},r={top:ye({alignmentType:"vertical",alignment:"top",index:e,orientation:t}),middle:ye({alignmentType:"vertical",alignment:"middle",index:e,orientation:t}),bottom:ye({alignmentType:"vertical",alignment:"bottom",index:e,orientation:t})};if(!o.left.canAlignCell())return null;const s=[n.alignLeft,n.alignCenter,n.alignRight],i=[n.alignTop,n.alignMiddle,n.alignBottom];return l.jsx(je,{placement:"right",trigger:l.jsx(Je,{render:l.jsx(Ee,{render:l.jsxs(M,{variant:"ghost",children:[l.jsx(is,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:n.alignment}),l.jsx(k2,{render:l.jsx(tt,{})})]})})}),children:l.jsx(Xe,{portal:!0,children:l.jsx(Ye,{children:l.jsxs(de,{children:[Object.values(o).map((a,c)=>l.jsx(ao,{icon:a.Icon,label:s[c],disabled:!a.canAlignCell,isActive:a.isActive,onClick:a.handleAlign},`text-${c}`)),l.jsx(ee,{orientation:"horizontal"}),Object.values(r).map((a,c)=>l.jsx(ao,{icon:a.Icon,label:i[c],disabled:!a.canAlignCell,isActive:a.isActive,onClick:a.handleAlign},`vertical-${c}`))]})})})})},ao=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:r=!1,shortcutBadge:s})=>l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":r?"on":"off"}),onClick:n,disabled:o,children:[l.jsx(e,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:t}),s]});ao.displayName="ActionItem";const Dd={row:"top-start",column:"bottom-start"},as=u.createContext(null);function Zt(){const e=u.useContext(as);if(!e)throw new Error("useTableHandleContext must be used within TableHandleProvider");return e}function cs(e,t){const{editor:n,orientation:o,index:r,tableNode:s,tablePos:i}=Zt(),[a,c]=u.useState(!1),[d,p]=u.useState(!1),f=u.useMemo(()=>Dd[o],[o]),h=u.useCallback(()=>{if(!(!n||!s||!X(i)||!X(r)))try{const{width:b,height:m}=T.TableMap.get(s),w=o==="row"?{row:r,col:0}:{row:0,col:r},v=o==="row"?{row:r,col:b-1}:{row:m-1,col:r};ke(n,i,[w,v],{mode:"dispatch",dispatch:n.view.dispatch.bind(n.view)})}catch(b){console.warn("Failed to select row/column:",b)}},[n,s,i,o,r]),C=u.useCallback(b=>{n&&(c(b),t?.(b),b?(n.commands.freezeHandles(),h(),e?.(!1)):(n.commands.unfreezeHandles(),e?.(!0)))},[n,t,e,h]),g=u.useCallback(()=>{n&&(c(!1),t?.(!1),n.commands.unfreezeHandles(),e?.(!0))},[n,t,e]);return{isMenuOpen:a,isDragging:d,setIsDragging:p,menuPlacement:f,handleMenuToggle:C,resetMenu:g}}function Ud(){const{editor:e,index:t,orientation:n,tablePos:o}=Zt(),r=$n({editor:e,index:t,orientation:n,tablePos:o}),s=Nl({editor:e,index:t,orientation:n,tablePos:o}),i=Kn({editor:e,tablePos:o,index:t,orientation:n,direction:"asc",hideWhenUnavailable:!0}),a=Kn({editor:e,tablePos:o,index:t,orientation:n,direction:"desc",hideWhenUnavailable:!0}),c=Qe({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:!0,hideWhenUnavailable:!0}),d=Zn({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:!0}),p=pt({editor:e,index:t,tablePos:o,orientation:"row",direction:"up",hideWhenUnavailable:!0}),f=pt({editor:e,index:t,tablePos:o,orientation:"row",direction:"down",hideWhenUnavailable:!0}),h=pt({editor:e,index:t,tablePos:o,orientation:"column",direction:"left",hideWhenUnavailable:!0}),C=pt({editor:e,index:t,tablePos:o,orientation:"column",direction:"right",hideWhenUnavailable:!0}),g=We({editor:e,index:t,tablePos:o,orientation:"row",side:"above",hideWhenUnavailable:!0}),b=We({editor:e,index:t,tablePos:o,orientation:"row",side:"below",hideWhenUnavailable:!0}),m=We({editor:e,index:t,tablePos:o,orientation:"column",side:"left",hideWhenUnavailable:!0}),w=We({editor:e,index:t,tablePos:o,orientation:"column",side:"right",hideWhenUnavailable:!0}),v=u.useMemo(()=>({moveUp:p,moveDown:f,moveLeft:h,moveRight:C}),[p,f,h,C]),y=u.useMemo(()=>({addAbove:g,addBelow:b,addLeft:m,addRight:w}),[g,b,m,w]),x=u.useMemo(()=>({sortAsc:i,sortDesc:a}),[i,a]),S=u.useCallback(()=>{const V=[];return x.sortAsc.isVisible&&V.push({icon:x.sortAsc.Icon,label:x.sortAsc.label,disabled:!x.sortAsc.canSortRowColumn,onClick:x.sortAsc.handleSort}),x.sortDesc.isVisible&&V.push({icon:x.sortDesc.Icon,label:x.sortDesc.label,disabled:!x.sortDesc.canSortRowColumn,onClick:x.sortDesc.handleSort}),V},[x]),L=u.useCallback(()=>{const V=[];return n==="row"?(y.addAbove.isVisible&&V.push({icon:y.addAbove.Icon,label:y.addAbove.label,disabled:!y.addAbove.canAddRowColumn,onClick:y.addAbove.handleAdd}),y.addBelow.isVisible&&V.push({icon:y.addBelow.Icon,label:y.addBelow.label,disabled:!y.addBelow.canAddRowColumn,onClick:y.addBelow.handleAdd})):(y.addLeft.isVisible&&V.push({icon:y.addLeft.Icon,label:y.addLeft.label,disabled:!y.addLeft.canAddRowColumn,onClick:y.addLeft.handleAdd}),y.addRight.isVisible&&V.push({icon:y.addRight.Icon,label:y.addRight.label,disabled:!y.addRight.canAddRowColumn,onClick:y.addRight.handleAdd})),V},[n,y]),I=u.useCallback(()=>{const V=[];return n==="row"?(v.moveUp.isVisible&&V.push({icon:v.moveUp.Icon,label:v.moveUp.label,disabled:!v.moveUp.canMoveRowColumn,onClick:v.moveUp.handleMove}),v.moveDown.isVisible&&V.push({icon:v.moveDown.Icon,label:v.moveDown.label,disabled:!v.moveDown.canMoveRowColumn,onClick:v.moveDown.handleMove})):(v.moveLeft.isVisible&&V.push({icon:v.moveLeft.Icon,label:v.moveLeft.label,disabled:!v.moveLeft.canMoveRowColumn,onClick:v.moveLeft.handleMove}),v.moveRight.isVisible&&V.push({icon:v.moveRight.Icon,label:v.moveRight.label,disabled:!v.moveRight.canMoveRowColumn,onClick:v.moveRight.handleMove})),V},[n,v]);return{deleteAction:r,duplicateAction:s,clearContentAction:c,headerAction:d,addItems:L(),moveItems:I(),sortItems:S()}}const ze=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:r=!1,shortcutBadge:s})=>l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":r?"on":"off"}),onClick:n,disabled:o,children:[l.jsx(e,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:t}),s]}),Od=()=>{const{index:e,orientation:t}=Zt(),{deleteAction:n,duplicateAction:o,clearContentAction:r,headerAction:s,addItems:i,moveItems:a,sortItems:c}=Ud(),d=n.isVisible||o.isVisible||r.isVisible,p=i.length>0,f=a.length>0,h=c.length>0,C=s.isVisible&&e===0;return!d&&!p&&!f&&!h&&!C?null:l.jsxs(l.Fragment,{children:[C&&l.jsxs(l.Fragment,{children:[l.jsx(de,{children:l.jsx(ze,{icon:s.Icon,label:s.label,disabled:!s.canToggleHeader,isActive:s.isActive,onClick:s.handleToggle})}),l.jsx(ee,{orientation:"horizontal"})]}),f&&l.jsxs(l.Fragment,{children:[l.jsx(de,{children:a.map((g,b)=>l.jsx(ze,{...g},`move-${b}`))}),l.jsx(ee,{orientation:"horizontal"})]}),p&&l.jsxs(l.Fragment,{children:[l.jsx(de,{children:i.map((g,b)=>l.jsx(ze,{...g},`add-${b}`))}),l.jsx(ee,{orientation:"horizontal"})]}),h&&l.jsxs(l.Fragment,{children:[l.jsx(de,{children:c.map((g,b)=>l.jsx(ze,{...g},`sort-${b}`))}),l.jsx(ee,{orientation:"horizontal"})]}),l.jsxs(l.Fragment,{children:[l.jsxs(de,{children:[l.jsx(Qn,{}),l.jsx(io,{index:e,orientation:t}),r.isVisible&&l.jsx(ze,{icon:r.Icon,label:r.label,disabled:!r.canClearRowColumnContent,onClick:r.handleClear})]}),l.jsx(ee,{orientation:"horizontal"})]}),d&&l.jsxs(de,{children:[o.isVisible&&l.jsx(ze,{icon:o.Icon,label:o.label,disabled:!o.canDuplicateRowColumn,onClick:o.handleDuplicate}),n.isVisible&&l.jsx(ze,{icon:n.Icon,label:n.label,disabled:!n.canDeleteRowColumn,onClick:n.handleDelete})]})]})},Pd=()=>{const{resetMenu:e}=cs();return l.jsxs(Xe,{autoFocusOnShow:!0,autoFocusOnHide:!1,modal:!0,onClose:e,children:[l.jsx(Hn,{style:mn}),l.jsx(Ye,{style:{minWidth:"15rem"},children:l.jsx(Od,{})})]})},ds=({editor:e,orientation:t,index:n,tableNode:o,tablePos:r,onToggleOtherHandle:s,onOpenChange:i,dragStart:a})=>{const{editor:c}=k(e),d=u.useMemo(()=>({editor:c,orientation:t,index:n,tableNode:o,tablePos:r}),[c,t,n,o,r]);return l.jsx(as.Provider,{value:d,children:l.jsx(Wd,{onToggleOtherHandle:s,onOpenChange:i,dragStart:a})})},Wd=({onToggleOtherHandle:e,onOpenChange:t,dragStart:n})=>{const{orientation:o}=Zt(),{isMenuOpen:r,isDragging:s,setIsDragging:i,menuPlacement:a,handleMenuToggle:c}=cs(e,t),d=D(),p=o==="row"?d.rowActions:d.columnActions,f=u.useCallback(C=>{i(!0),n?.(C)},[n,i]),h=u.useCallback(()=>{i(!1),c2()},[i]);return l.jsx(je,{open:r,onOpenChange:c,placement:a,trigger:l.jsx(Je,{className:$("tiptap-table-handle-menu",r&&"menu-opened",s&&"is-dragging",o),draggable:!0,"aria-label":p,"aria-haspopup":"menu","aria-expanded":r,onDragStart:f,onDragEnd:h,children:l.jsx(Mt,{className:"tiptap-button-icon"})}),children:l.jsx(Pd,{})})};function us({editor:e,rowButton:t,columnButton:n}){const{editor:o}=k(e),r=Nn({editor:o}),[s,i]=u.useState(!0),[a,c]=u.useState(!0),[d,p]=u.useState(null),f=u.useMemo(()=>{if(r?.draggingState)return{draggedCellOrientation:r.draggingState.draggedCellOrientation,mousePos:r.draggingState.mousePos,initialOffset:r.draggingState.initialOffset}},[r?.draggingState]),{rowHandle:h,colHandle:C}=b2(r?.show||!1,r?.referencePosCell||null,r?.referencePosTable||null,f),g=u.useCallback(I=>{i(I)},[]),b=u.useCallback(I=>{c(I)},[]),m=u.useCallback((I,V)=>{p(V?I:null)},[]);if(!o||!r)return null;const w=typeof r.rowIndex=="number",v=typeof r.colIndex=="number",y=s&&h.isMounted&&w||d==="row",x=a&&C.isMounted&&v||d==="column",S=t||ds,L=n||ds;return l.jsxs(z.FloatingPortal,{root:r.widgetContainer,children:[y&&l.jsx("div",{ref:h.ref,style:h.style,children:l.jsx(S,{editor:o,orientation:"row",index:r.rowIndex,tablePos:r.blockPos,tableNode:r.block,onToggleOtherHandle:b,dragStart:a2,onOpenChange:I=>m("row",I)})}),x&&l.jsx("div",{ref:C.ref,style:C.style,children:l.jsx(L,{editor:o,orientation:"column",index:r.colIndex,tablePos:r.blockPos,tableNode:r.block,onToggleOtherHandle:g,dragStart:i2,onOpenChange:I=>m("column",I)})})]})}us.displayName="TableHandle";function _d(e,t){const n=u.useRef(null),o=u.useCallback(()=>{n.current!=null&&(cancelAnimationFrame(n.current),n.current=null)},[]),r=u.useCallback(()=>{if(n.current!=null)return;const s=()=>{const a=!!T.columnResizingPluginKey.getState(e.state)?.dragging;t(),a?n.current=requestAnimationFrame(s):(o(),t())};n.current=requestAnimationFrame(s)},[e,t,o]);u.useEffect(()=>{if(!e)return;const s=({transaction:i})=>{t();const a=i.getMeta(T.columnResizingPluginKey);a&&(Object.prototype.hasOwnProperty.call(a,"setDragging")&&a.setDragging&&r(),Object.prototype.hasOwnProperty.call(a,"setDragging")&&a.setDragging==null&&(o(),t()),Object.prototype.hasOwnProperty.call(a,"setHandle")&&t())};return e.on("transaction",s),()=>{e.off("transaction",s),o()}},[e,r,o,t])}function Zd(e){return!!e?.isEditable}const Fd=5,zd=(e,t,n,o)=>{const r=t.posAtCoords({left:n,top:o})?.pos;if(r==null)return null;const s=e.doc.resolve(r);return T.cellAround(s)},$d=(e,t)=>{if(!(t instanceof T.CellSelection))return null;const n=[];if(t.forEachCell((r,s)=>{const i=e.nodeDOM(s);i&&n.push(i)}),n.length===0)return null;const o={left:1/0,top:1/0,right:-1/0,bottom:-1/0};return n.forEach(r=>{const s=r.getBoundingClientRect();o.left=Math.min(o.left,s.left),o.top=Math.min(o.top,s.top),o.right=Math.max(o.right,s.right),o.bottom=Math.max(o.bottom,s.bottom)}),new DOMRect(o.left,o.top,o.right-o.left,o.bottom-o.top)},qd=(e,t)=>{const n=e.nodeDOM(t);if(!n)return null;const o=n.getBoundingClientRect();return new DOMRect(o.left,o.top,o.width,o.height)},Gd=e=>({getBoundingClientRect:()=>e}),Kd=(e,t,n)=>{const o={topLeft:null,topRight:null,bottomLeft:null,bottomRight:null},r=(s,i)=>Math.abs(s-i)<Fd;return t.forEachCell((s,i)=>{const a=e.nodeDOM(i);if(!a)return;const c=a.getBoundingClientRect();r(c.left,n.left)&&r(c.top,n.top)&&(o.topLeft=i),r(c.right,n.right)&&r(c.top,n.top)&&(o.topRight=i),r(c.left,n.left)&&r(c.bottom,n.bottom)&&(o.bottomLeft=i),r(c.right,n.right)&&r(c.bottom,n.bottom)&&(o.bottomRight=i)}),o},Yd=(e,t,n,o)=>{if(!o)return null;const i=Kd(e,t,n)[{tl:"bottomRight",tr:"bottomLeft",bl:"topRight",br:"topLeft"}[o]];return i?{pos:i}:null},jd=()=>({position:"absolute",width:15,height:15,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",pointerEvents:"auto",zIndex:10}),Ft=(e,t,n=!1)=>({...jd(),...{tl:{top:-7.5,left:-7.5,cursor:n?"default":"nwse-resize"},tr:{top:-7.5,right:-7.5,cursor:n?"default":"nesw-resize"},bl:{bottom:-7.5,left:-7.5,cursor:n?"default":"nesw-resize"},br:{bottom:-7.5,right:-7.5,cursor:n?"default":"nwse-resize"}}[e],opacity:n?.3:t?1:.5,pointerEvents:n?"none":"auto"}),Xd=({editor:e,cellMenu:t,showResizeHandles:n=!0,onMenuOpenChange:o})=>{const{editor:r}=k(e),[s,i]=u.useState(!0),[a,c]=u.useState(null),[d,p]=u.useState(null),[f,h]=u.useState(null),[C,g]=u.useState(!1),b=Zd(r),m=u.useRef(null),w=u.useRef(null),v=u.useRef(null),{refs:y,floatingStyles:x,update:S}=z.useFloating({placement:"top-start"});u.useEffect(()=>{if(a){const O=Gd(a);y.setPositionReference(O)}},[a,y]);const L=u.useCallback(()=>{if(!r||!b)return;const{selection:O}=r.state;if(O instanceof T.CellSelection){const N=$d(r.view,O);if(!N){i(!1),c(U=>U&&null);return}c(U=>bl(U,N)?U:N),i(!0);return}const{$anchor:Y}=O,A=T.cellAround(Y);if(A){const N=qd(r.view,A.pos);if(N){c(U=>bl(U,N)?U:N),i(!0);return}}i(!1),c(N=>N&&null)},[r,b]);_d(r,L),u.useEffect(()=>{S&&a&&S()},[S,a]);const I=u.useCallback(O=>Y=>{if(!r||!O||!a||C||!n)return;Y.preventDefault(),Y.stopPropagation();const{selection:A}=r.state;let N=null;if(A instanceof T.CellSelection)N=A;else{const{$anchor:P}=A,q=T.cellAround(P);if(q)try{N=T.CellSelection.create(r.state.doc,q.pos,q.pos)}catch(Z){console.warn("Could not create single cell selection for resize:",Z);return}}if(!N)return;const U=Yd(r.view,N,a,O);if(!U)return;p(O),w.current=O,m.current=U.pos;const H=P=>{if(!r||m.current==null)return;const q=ul(P.target);if(!q||q.type!=="cell")return;const Z=zd(r.state,r.view,P.clientX,P.clientY);if(Z)try{const le=T.CellSelection.create(r.state.doc,m.current,Z.pos),be=r.state.tr.setSelection(le);r.view.dispatch(be)}catch{return}},W=()=>{p(null),w.current=null,m.current=null,window.removeEventListener("mousemove",H),window.removeEventListener("mouseup",W)};window.addEventListener("mousemove",H),window.addEventListener("mouseup",W)},[r,a,C,n]),V=u.useCallback(()=>{if(!r){h(null);return}const O=ne(r);if(!O){h(null);return}h(Y=>{const A=Y,N=r.view.nodeDOM(O.pos);return A===N?A:N})},[r]),K=u.useCallback(O=>{g(O),o?.(O)},[o]);if(u.useEffect(()=>{if(!r||!b)return;const O=()=>{L(),V()};return r.on("selectionUpdate",O),L(),V(),()=>{r.off("selectionUpdate",O)}},[r,b,L,V]),u.useEffect(()=>{const O=f?.querySelector(".table-selection-overlay-container");v.current=O??null},[f]),!b||!s||!a||!r)return null;const se=()=>t?l.jsx("span",{onMouseDown:O=>O.stopPropagation(),style:{pointerEvents:"auto"},children:l.jsx(t,{onOpenChange:K,editor:r,onResizeStart:I})}):null;return l.jsx(z.FloatingPortal,{root:v.current,children:l.jsx("div",{ref:y.setFloating,style:{...x,pointerEvents:"none",zIndex:10},children:l.jsxs("div",{className:"tiptap-table-selection-overlay",children:[l.jsx("div",{style:{position:"absolute",width:a.width,height:a.height,zIndex:2,borderRadius:2,top:0,left:0}}),l.jsxs("div",{style:{position:"absolute",width:a.width,height:a.height,border:"2px solid var(--tt-brand-color-400)",borderRadius:2,zIndex:3,top:0,left:0},children:[se(),n&&l.jsxs(l.Fragment,{children:[l.jsx("div",{style:Ft("tl",!d||d==="tl",C),onMouseDown:I("tl")}),l.jsx("div",{style:Ft("tr",!d||d==="tr",C),onMouseDown:I("tr")}),l.jsx("div",{style:Ft("bl",!d||d==="bl",C),onMouseDown:I("bl")}),l.jsx("div",{style:Ft("br",!d||d==="br",C),onMouseDown:I("br")})]})]})]})})})},Jd=u.forwardRef(({editor:e,action:t,hideWhenUnavailable:n=!1,onExecuted:o,text:r,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:p,handleExecute:f,label:h,canExecute:C,Icon:g}=wt({editor:d,action:t,hideWhenUnavailable:n,onExecuted:o}),b=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&f()},[f,s]);return p?l.jsx(M,{type:"button",disabled:!C,variant:"ghost","data-active-state":"off","data-disabled":!C,role:"button",tabIndex:-1,"aria-label":h,"aria-pressed":!1,tooltip:h,onClick:b,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(g,{className:"tiptap-button-icon"}),r&&l.jsx("span",{className:"tiptap-button-text",children:r})]})}):null});Jd.displayName="TableMergeSplitCellButton";const fs=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M10 16C10.5177 16 10.9438 16.3933 10.9951 16.8975L11 17V19C11 20.6569 9.65685 22 8 22H4C2.34315 22 1 20.6569 1 19V17C1 16.4477 1.44772 16 2 16C2.55228 16 3 16.4477 3 17V19C3 19.5523 3.44772 20 4 20H8C8.55228 20 9 19.5523 9 19V17L9.00488 16.8975C9.05621 16.3933 9.48232 16 10 16Z",fill:"currentColor"}),l.jsx("path",{d:"M22 16C22.5177 16 22.9438 16.3933 22.9951 16.8975L23 17V19C23 20.6569 21.6569 22 20 22H16C14.3431 22 13 20.6569 13 19V17C13 16.4477 13.4477 16 14 16C14.5523 16 15 16.4477 15 17V19C15 19.5523 15.4477 20 16 20H20C20.5523 20 21 19.5523 21 19V17L21.0049 16.8975C21.0562 16.3933 21.4823 16 22 16Z",fill:"currentColor"}),l.jsx("path",{d:"M5.29297 8.29297C5.68349 7.90244 6.31651 7.90244 6.70703 8.29297L9.70703 11.293L9.77539 11.3691C10.0957 11.7619 10.0731 12.3409 9.70703 12.707L6.70703 15.707C6.31651 16.0975 5.68349 16.0975 5.29297 15.707C4.90245 15.3165 4.90245 14.6835 5.29297 14.293L6.58594 13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H6.58594L5.29297 9.70703C4.90245 9.31651 4.90245 8.68349 5.29297 8.29297Z",fill:"currentColor"}),l.jsx("path",{d:"M17.293 8.29297C17.6835 7.90245 18.3165 7.90246 18.707 8.29297C19.0976 8.68349 19.0976 9.31651 18.707 9.70703L17.4141 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H17.4141L18.707 14.293C19.0976 14.6835 19.0976 15.3165 18.707 15.707C18.3165 16.0976 17.6835 16.0976 17.293 15.707L14.293 12.707L14.2246 12.6309C13.9043 12.2381 13.9269 11.6591 14.293 11.293L17.293 8.29297Z",fill:"currentColor"}),l.jsx("path",{d:"M8 2C9.65685 2 11 3.34315 11 5V7C11 7.55228 10.5523 8 10 8C9.44771 8 9 7.55228 9 7V5C9 4.44772 8.55228 4 8 4H4C3.44772 4 3 4.44772 3 5V7C3 7.55228 2.55228 8 2 8C1.44772 8 1 7.55228 1 7V5C1 3.34315 2.34315 2 4 2H8Z",fill:"currentColor"}),l.jsx("path",{d:"M20 2C21.6569 2 23 3.34315 23 5V7C23 7.55228 22.5523 8 22 8C21.4477 8 21 7.55228 21 7V5C21 4.44772 20.5523 4 20 4H16C15.4477 4 15 4.44772 15 5V7C15 7.55228 14.5523 8 14 8C13.4477 8 13 7.55228 13 7V5C13 3.34315 14.3431 2 16 2H20Z",fill:"currentColor"})]}));fs.displayName="TableCellMergeIcon";const ps=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M4 2C2.34315 2 1 3.34315 1 5V7C1 7.55228 1.44772 8 2 8C2.55228 8 3 7.55228 3 7V5C3 4.44772 3.44772 4 4 4H8C8.55228 4 9 4.44772 9 5V7C9 7.55228 9.44772 8 10 8C10.5523 8 11 7.55228 11 7V5C11 3.34315 9.65685 2 8 2H4Z",fill:"currentColor"}),l.jsx("path",{d:"M20 22C21.6569 22 23 20.6569 23 19V17C23 16.4477 22.5523 16 22 16C21.4477 16 21 16.4477 21 17V19C21 19.5523 20.5523 20 20 20H16C15.4477 20 15 19.5523 15 19V17C15 16.4477 14.5523 16 14 16C13.4477 16 13 16.4477 13 17V19C13 20.6569 14.3431 22 16 22H20Z",fill:"currentColor"}),l.jsx("path",{d:"M13 5C13 3.34315 14.3431 2 16 2H20C21.6569 2 23 3.34315 23 5V7C23 7.55228 22.5523 8 22 8C21.4477 8 21 7.55228 21 7V5C21 4.44772 20.5523 4 20 4H16C15.4477 4 15 4.44772 15 5V7C15 7.55228 14.5523 8 14 8C13.4477 8 13 7.55228 13 7V5Z",fill:"currentColor"}),l.jsx("path",{d:"M8 22C9.65685 22 11 20.6569 11 19V17C11 16.4477 10.5523 16 10 16C9.44772 16 9 16.4477 9 17V19C9 19.5523 8.55229 20 8 20H4C3.44772 20 3 19.5523 3 19L3 17C3 16.4477 2.55229 16 2 16C1.44772 16 1 16.4477 1 17V19C1 20.6569 2.34315 22 4 22H8Z",fill:"currentColor"}),l.jsx("path",{d:"M18.7071 15.7071L21.7061 12.7081C21.8877 12.527 22 12.2766 22 12L22 11.997C21.9992 11.7421 21.9016 11.4874 21.7071 11.2929L18.7071 8.29289C18.3166 7.90237 17.6834 7.90237 17.2929 8.29289C16.9024 8.68342 16.9024 9.31658 17.2929 9.70711L18.5858 11H15C14.4477 11 14 11.4477 14 12C14 12.5523 14.4477 13 15 13H18.5858L17.2929 14.2929C16.9024 14.6834 16.9024 15.3166 17.2929 15.7071C17.6834 16.0976 18.3166 16.0976 18.7071 15.7071Z",fill:"currentColor"}),l.jsx("path",{d:"M2.07588 11.6172C2.02699 11.7351 2 11.8644 2 12C2 12.2728 2.10925 12.5201 2.2864 12.7005C2.28879 12.703 2.2912 12.7054 2.29362 12.7078L5.29289 15.7071C5.68342 16.0976 6.31658 16.0976 6.70711 15.7071C7.09763 15.3166 7.09763 14.6834 6.70711 14.2929L5.41421 13L9 13C9.55228 13 10 12.5523 10 12C10 11.4477 9.55229 11 9 11L5.41421 11L6.70711 9.70711C7.09763 9.31658 7.09763 8.68342 6.70711 8.29289C6.31658 7.90237 5.68342 7.90237 5.29289 8.29289L2.29366 11.2921C2.29122 11.2946 2.2888 11.297 2.2864 11.2995C2.19374 11.3938 2.12357 11.502 2.07588 11.6172Z",fill:"currentColor"})]}));ps.displayName="TableCellSplitIcon";const co=["table"],Qd={merge:fs,split:ps};function uo(e){if(!e||!e.isEditable||!_(e,co))return!1;try{return T.mergeCells(e.state,void 0)}catch{return!1}}function fo(e){if(!e||!e.isEditable||!_(e,co))return!1;try{return T.splitCell(e.state,void 0)}catch{return!1}}function Rd(e){if(!uo(e)||!e)return!1;try{const{state:t,view:n}=e;return T.mergeCells(t,n.dispatch.bind(n))}catch(t){return console.error("Error merging table cells:",t),!1}}function eu(e){if(!fo(e)||!e)return!1;try{const{state:t,view:n}=e;return T.splitCell(t,n.dispatch.bind(n))}catch(t){return console.error("Error splitting table cell:",t),!1}}function tu({editor:e,action:t}){if(!e)return!1;try{return t==="merge"?Rd(e):eu(e)}catch(n){return console.error(`Error ${t}ing table cell:`,n),!1}}function nu({editor:e,action:t,hideWhenUnavailable:n}){return!e||!e.isEditable||!_(e,co)?!1:n?t==="merge"?uo(e):fo(e):!0}function wt(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onExecuted:r}=e,{editor:s}=k(t),i=D(),a=nu({editor:s,action:n,hideWhenUnavailable:o}),c=n==="merge"?uo(s):fo(s),d=u.useCallback(()=>{const p=tu({editor:s,action:n});return p&&r?.(n),p},[s,n,r]);return{isVisible:a,canExecute:c,handleExecute:d,label:n==="merge"?i.mergeCells:i.splitCell,Icon:Qd[n]}}const hs=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M8 14C9.10457 14 10 14.8954 10 16C10 17.1046 9.10457 18 8 18C6.89543 18 6 17.1046 6 16C6 14.8954 6.89543 14 8 14ZM16 14C17.1046 14 18 14.8954 18 16C18 17.1046 17.1046 18 16 18C14.8954 18 14 17.1046 14 16C14 14.8954 14.8954 14 16 14ZM8 6C9.10457 6 10 6.89543 10 8C10 9.10457 9.10457 10 8 10C6.89543 10 6 9.10457 6 8C6 6.89543 6.89543 6 8 6ZM16 6C17.1046 6 18 6.89543 18 8C18 9.10457 17.1046 10 16 10C14.8954 10 14 9.10457 14 8C14 6.89543 14.8954 6 16 6Z",fill:"currentColor"})}));hs.displayName="Grip4Icon";function ou(e){return{merge:e.mergeCells,split:e.splitCell,clear:e.clearContents}}function ru(e){const t=ou(e),n=wt({action:"merge"}),o=wt({action:"split"}),r=Qe({resetAttrs:!0}),s={icon:n.Icon,label:t.merge,onClick:n.handleExecute,isAvailable:n.canExecute},i={icon:o.Icon,label:t.split,onClick:o.handleExecute,isAvailable:o.canExecute},a={icon:r.Icon,label:t.clear,onClick:r.handleClear,isAvailable:r.canClearRowColumnContent};return{mergeAction:s,splitAction:i,clearAction:a}}function lu({editor:e}){const[t,n]=u.useState(!1),o=u.useCallback(()=>{n(!1),e?.commands.unfreezeHandles()},[e]),r=u.useCallback(s=>{n(s),e&&(s?e.commands.freezeHandles():e.commands.unfreezeHandles())},[e]);return{isMenuOpen:t,handleMenuToggle:r,closeMenu:o}}const po=({action:e})=>{const{icon:t,label:n,onClick:o,isActive:r=!1,shortcutBadge:s}=e;return l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":r?"on":"off"}),onClick:o,children:[l.jsx(t,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:n}),s]})},su=({i18n:e,onClose:t})=>{const{mergeAction:n,splitAction:o,clearAction:r}=ru(e),s=n.isAvailable||o.isAvailable;return l.jsxs(Xe,{autoFocusOnShow:!0,autoFocusOnHide:!1,modal:!0,onClose:t,children:[l.jsx(Hn,{style:mn}),l.jsxs(Ye,{style:{minWidth:"15rem"},children:[s&&l.jsxs(de,{children:[n.isAvailable&&l.jsx(po,{action:n}),o.isAvailable&&l.jsx(po,{action:o}),l.jsx(ee,{orientation:"horizontal"})]}),l.jsxs(de,{children:[l.jsx(Qn,{}),l.jsx(io,{}),r.isAvailable&&l.jsx(po,{action:r})]})]})]})},Cs=u.forwardRef(({editor:e,onOpenChange:t,className:n,...o},r)=>{const{editor:s}=k(e),i=D(),{isMenuOpen:a,handleMenuToggle:c,closeMenu:d}=lu({editor:s});return u.useEffect(()=>{t?.(a)},[a,t]),l.jsx(je,{open:a,onOpenChange:c,placement:"bottom-start",trigger:l.jsx(Je,{ref:r,className:$("expandable-menu-button",a&&"menu-opened",n),"aria-label":i.tableCellsOption,"aria-haspopup":"menu","aria-expanded":a,...o,children:l.jsx(hs,{className:"tiptap-button-icon"})}),children:l.jsx(su,{i18n:i,onClose:d})})});Cs.displayName="TableCellHandleMenu";const gs=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M17.293 7.29303C17.6835 6.90251 18.3165 6.90251 18.707 7.29303L22.707 11.293C22.7548 11.3408 22.7976 11.3936 22.835 11.4503C22.8597 11.4877 22.8812 11.5267 22.9004 11.5665C22.9222 11.6117 22.9412 11.6584 22.9561 11.7071C22.9622 11.7274 22.9668 11.748 22.9717 11.7686C22.9893 11.843 23 11.9203 23 12.0001C23 12.0831 22.9878 12.1632 22.9688 12.2403C22.9646 12.2572 22.9611 12.2743 22.9561 12.2911C22.9421 12.337 22.9244 12.3811 22.9043 12.4239C22.8833 12.4686 22.859 12.5119 22.8311 12.5538C22.8185 12.5726 22.8048 12.5905 22.791 12.6085C22.7649 12.6423 22.738 12.6761 22.707 12.7071L18.707 16.7071C18.3165 17.0976 17.6835 17.0975 17.293 16.7071C16.9024 16.3166 16.9025 15.6836 17.293 15.293L19.5859 13.0001H4.41406L6.70703 15.293C7.09747 15.6836 7.09753 16.3166 6.70703 16.7071C6.31654 17.0976 5.6835 17.0975 5.29297 16.7071L1.29297 12.7071C1.26185 12.676 1.23417 12.6424 1.20801 12.6085C1.19423 12.5906 1.18053 12.5726 1.16797 12.5538C1.14006 12.5119 1.11566 12.4686 1.09473 12.4239C1.07465 12.3811 1.0569 12.3369 1.04297 12.2911C1.0379 12.2743 1.03445 12.2572 1.03027 12.2403C1.01124 12.1633 1.00001 12.083 1 12.0001C1 11.9204 1.00974 11.8429 1.02734 11.7686C1.03221 11.7481 1.03678 11.7274 1.04297 11.7071C1.05787 11.6583 1.07777 11.6117 1.09961 11.5665C1.11877 11.5267 1.1403 11.4877 1.16504 11.4503C1.20242 11.3936 1.24516 11.3408 1.29297 11.293L5.29297 7.29303C5.68349 6.90251 6.31651 6.90251 6.70703 7.29303C7.09747 7.68356 7.09753 8.3166 6.70703 8.70709L4.41406 11.0001H19.5859L17.293 8.70709C16.9024 8.31657 16.9025 7.68356 17.293 7.29303Z",fill:"currentColor"})}));gs.displayName="MoveHorizontalIcon";const bs=["table","tableHandleExtension"];function zt(e){if(!e||!e.isEditable||!_(e,bs))return!1;try{return e.isActive("table")||e.isActive("tableCell")||e.isActive("tableHeader")}catch{return!1}}function iu(e){if(!zt(e)||!e)return!1;try{const t=ne(e);if(!t)return!1;const n=e.view.dom,o=getComputedStyle(n),r=parseFloat(o.paddingLeft)||0,s=parseFloat(o.paddingRight)||0,i=n.clientWidth-r-s,a=t.map.width;if(a===0)return!1;let c=0;const d=i-a-8;c=Math.floor(d/a);const p=Math.max(c,cl),f=e.state.tr;return t.node.descendants((h,C)=>{if(h.type.name==="tableCell"||h.type.name==="tableHeader"){const g=t.start+C,b=h.attrs.colspan||1,m=Array(b).fill(p);f.setNodeMarkup(g,void 0,{...h.attrs,colwidth:m})}}),f.docChanged&&e.view.dispatch(f),!0}catch(t){return console.error("Error setting table auto width:",t),!1}}function au({editor:e}){if(!zt(e)||!e)return!1;try{return iu(e)}catch(t){return console.error("Error adjusting table width:",t),!1}}function cu({editor:e,hideWhenUnavailable:t}){return!e||!e.isEditable||!_(e,bs)?!1:t?zt(e):!0}function ho(e={}){const{editor:t,hideWhenUnavailable:n=!1,onWidthAdjusted:o}=e,{editor:r}=k(t),s=D(),i=cu({editor:r,hideWhenUnavailable:n}),a=zt(r),c=u.useCallback(()=>{const f=au({editor:r});return f&&o?.(),f},[r,o]),d=s.fitToWidth;return{isVisible:i,canFitToWidth:a,handleFitToWidth:c,label:d,Icon:gs}}const du=u.forwardRef(({editor:e,hideWhenUnavailable:t=!1,onWidthAdjusted:n,text:o,onClick:r,children:s,...i},a)=>{const{editor:c}=k(e),{isVisible:d,canFitToWidth:p,label:f,Icon:h,handleFitToWidth:C}=ho({editor:c,hideWhenUnavailable:t,onWidthAdjusted:n}),g=u.useCallback(b=>{r?.(b),!b.defaultPrevented&&C()},[C,r]);return d?l.jsx(M,{type:"button",disabled:!p,variant:"ghost","data-active-state":"off","data-disabled":!p,role:"button",tabIndex:-1,"aria-label":f,tooltip:f,onClick:g,...i,ref:a,children:s??l.jsxs(l.Fragment,{children:[l.jsx(h,{className:"tiptap-button-icon"}),o&&l.jsx("span",{className:"tiptap-button-text",children:o})]})}):null});du.displayName="TableFitToWidthButton";const $e=8,uu=184;function fu(e){return e instanceof Element&&!!e.closest("td, th")}function pu(e){return{x:Math.max($e,Math.min(e.clientX,window.innerWidth-uu-$e)),y:Math.max($e,e.clientY)}}function hu(e,t){return{x:Math.max($e,Math.min(e.x,window.innerWidth-t.width-$e)),y:Math.max($e,Math.min(e.y,window.innerHeight-t.height-$e))}}function Cu(e,t){return!!(e?.isEditable&&t)}function gu(e,t){const n=e.view.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;const o=e.state.doc.resolve(n.pos),r=T.findTable(o);if(!r)return null;const s=T.TableMap.get(r.node);for(let i=o.depth;i>0;i-=1){const a=o.node(i);if(a.type.name!=="tableCell"&&a.type.name!=="tableHeader")continue;const c=o.before(i),d=s.findCell(c-r.start);return{rowIndex:d.top,columnIndex:d.left,tablePos:r.pos}}return null}function bu(e,t){const n=e.view.posAtCoords({left:t.clientX,top:t.clientY});if(!n){e.view.focus();return}const o=E.Selection.near(e.state.doc.resolve(n.pos));e.view.dispatch(e.state.tr.setSelection(o)),e.view.focus()}function mu(e,t,n){const{selection:o}=e.state;if(o instanceof T.CellSelection){const r=T.selectedRect(e.state);if(t.rowIndex>=r.top&&t.rowIndex<r.bottom&&t.columnIndex>=r.left&&t.columnIndex<r.right){e.view.focus();return}}bu(e,n)}function wu(e,t){const n=e();return t(),n}function Co({action:e,closeMenu:t}){const{icon:n,label:o,onClick:r,disabled:s,isActive:i}=e;return l.jsxs(M,{type:"button",variant:"ghost","data-active-state":i?"on":"off",disabled:s,className:"tiptap-table-context-menu__item",onMouseDown:a=>a.preventDefault(),onClick:()=>wu(r,t),children:[l.jsx(n,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:o})]})}function go({actions:e,closeMenu:t}){const n=e.filter(o=>o.isVisible!==!1);return n.length===0?null:l.jsx("div",{className:"tiptap-table-context-menu__group",children:n.map(o=>l.jsx(Co,{action:o,closeMenu:t},o.label))})}function ms({editor:e,index:t,orientation:n,tablePos:o,i18n:r}){const s=n==="row"?"above":"left",i=n==="row"?"below":"right",a=We({editor:e,index:t,orientation:n,side:s,tablePos:o,hideWhenUnavailable:!0}),c=We({editor:e,index:t,orientation:n,side:i,tablePos:o,hideWhenUnavailable:!0}),d=$n({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:!0}),p=Qe({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:!0,hideWhenUnavailable:!0}),f=Zn({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:!0});return u.useMemo(()=>[{icon:a.Icon,label:n==="row"?r.insertRowAbove:r.insertColumnLeft,onClick:a.handleAdd,disabled:!a.canAddRowColumn,isVisible:a.isVisible},{icon:c.Icon,label:n==="row"?r.insertRowBelow:r.insertColumnRight,onClick:c.handleAdd,disabled:!c.canAddRowColumn,isVisible:c.isVisible},{icon:f.Icon,label:n==="row"?r.headerRow:r.headerColumn,onClick:f.handleToggle,disabled:!f.canToggleHeader,isVisible:f.isVisible,isActive:f.isActive},{icon:p.Icon,label:n==="row"?r.clearRowContents:r.clearColumnContents,onClick:p.handleClear,disabled:!p.canClearRowColumnContent,isVisible:p.isVisible},{icon:d.Icon,label:n==="row"?r.deleteRow:r.deleteColumn,onClick:d.handleDelete,disabled:!d.canDeleteRowColumn,isVisible:d.isVisible}],[c,a,p,d,f,r,n])}function vu(e,t){const n=wt({editor:e,action:"merge",hideWhenUnavailable:!0}),o=wt({editor:e,action:"split",hideWhenUnavailable:!0}),r=Qe({editor:e,resetAttrs:!0,hideWhenUnavailable:!0}),s=ye({editor:e,alignmentType:"text",alignment:"left",hideWhenUnavailable:!0}),i=ye({editor:e,alignmentType:"text",alignment:"center",hideWhenUnavailable:!0}),a=ye({editor:e,alignmentType:"text",alignment:"right",hideWhenUnavailable:!0}),c=ye({editor:e,alignmentType:"vertical",alignment:"middle",hideWhenUnavailable:!0});return u.useMemo(()=>[{icon:n.Icon,label:t.mergeCells,onClick:n.handleExecute,disabled:!n.canExecute,isVisible:n.isVisible},{icon:o.Icon,label:t.splitCell,onClick:o.handleExecute,disabled:!o.canExecute,isVisible:o.isVisible},{icon:s.Icon,label:t.alignLeft,onClick:s.handleAlign,disabled:!s.canAlignCell(),isVisible:s.isVisible,isActive:s.isActive},{icon:i.Icon,label:t.alignCenter,onClick:i.handleAlign,disabled:!i.canAlignCell(),isVisible:i.isVisible,isActive:i.isActive},{icon:a.Icon,label:t.alignRight,onClick:a.handleAlign,disabled:!a.canAlignCell(),isVisible:a.isVisible,isActive:a.isActive},{icon:c.Icon,label:t.alignMiddle,onClick:c.handleAlign,disabled:!c.canAlignCell(),isVisible:c.isVisible,isActive:c.isActive},{icon:r.Icon,label:t.clearContents,onClick:r.handleClear,disabled:!r.canClearRowColumnContent,isVisible:r.isVisible}],[i,s,c,a,r,t,n,o])}function yu({editor:e}){const t=D(),n=u.useRef(null),[o,r]=u.useState(null),[s,i]=u.useState(null),a=u.useCallback(()=>{r(null),i(null),e?.commands.unfreezeHandles?.()},[e]),c=ms({editor:e,index:s?.rowIndex,orientation:"row",tablePos:s?.tablePos,i18n:t}),d=ms({editor:e,index:s?.columnIndex,orientation:"column",tablePos:s?.tablePos,i18n:t}),p=vu(e,t),f=ho({editor:e,hideWhenUnavailable:!0}),h=u.useMemo(()=>({icon:ht,label:t.deleteTable,onClick:()=>e?.chain().focus(void 0,{scrollIntoView:!1}).deleteTable().run()??!1,disabled:!Cu(e,s),isVisible:!!e?.isEditable}),[e,t.deleteTable,s]),C=u.useMemo(()=>({icon:f.Icon,label:t.fitToWidth,onClick:f.handleFitToWidth,disabled:!f.canFitToWidth,isVisible:f.isVisible}),[f,t.fitToWidth]);return u.useEffect(()=>{if(!e)return;const g=e.view.dom,b=m=>{if(!e.isEditable||!fu(m.target)){a();return}const w=m,v=gu(e,w);if(!v){a();return}m.preventDefault(),m.stopPropagation(),mu(e,v,w),e.commands.freezeHandles?.(),i(v),r(pu(w))};return g.addEventListener("contextmenu",b),()=>{g.removeEventListener("contextmenu",b)}},[a,e]),u.useLayoutEffect(()=>{if(!o||!n.current)return;const g=hu(o,n.current.getBoundingClientRect());(g.x!==o.x||g.y!==o.y)&&r(g)},[o]),u.useEffect(()=>{if(!o)return;const g=m=>{n.current?.contains(m.target)||a()},b=m=>{m.key==="Escape"&&a()};return window.addEventListener("mousedown",g),window.addEventListener("scroll",a,!0),window.addEventListener("keydown",b),()=>{window.removeEventListener("mousedown",g),window.removeEventListener("scroll",a,!0),window.removeEventListener("keydown",b)}},[a,o]),!o||!s?null:l.jsxs("div",{ref:n,className:"tiptap-table-context-menu",style:{left:o.x,top:o.y},onContextMenu:g=>g.preventDefault(),children:[l.jsx(go,{actions:c,closeMenu:a}),l.jsx("div",{className:"tiptap-table-context-menu__separator"}),l.jsx(go,{actions:d,closeMenu:a}),l.jsx("div",{className:"tiptap-table-context-menu__separator"}),l.jsx(go,{actions:p,closeMenu:a}),l.jsx("div",{className:"tiptap-table-context-menu__separator"}),l.jsx(Co,{action:C,closeMenu:a}),l.jsx(Co,{action:h,closeMenu:a})]})}const ws=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M13.5 8C13.5 7.17157 12.8284 6.5 12 6.5C11.1716 6.5 10.5 7.17157 10.5 8V10.5H8C7.17157 10.5 6.5 11.1716 6.5 12C6.5 12.8284 7.17157 13.5 8 13.5H10.5V16C10.5 16.8284 11.1716 17.5 12 17.5C12.8284 17.5 13.5 16.8284 13.5 16V13.5H16C16.8284 13.5 17.5 12.8284 17.5 12C17.5 11.1716 16.8284 10.5 16 10.5H13.5V8Z",fill:"currentColor"})}));ws.displayName="PlusSmallIcon";const xu={row:{placement:"bottom",sizeProperty:"width"},column:{placement:"right",sizeProperty:"height"}};function vs(e,t,n){const o=xu[e],{refs:r,update:s,context:i,floatingStyles:a}=z.useFloating({open:t,placement:o.placement,middleware:[z.offset(4),z.size({apply({rects:f,elements:h}){const C=h.floating;if(!C)return;const g=`${f.reference[o.sizeProperty]}px`;C.style[o.sizeProperty]=g}})]}),{isMounted:c,styles:d}=z.useTransitionStyles(i),p=u.useCallback(f=>({getBoundingClientRect:()=>f}),[]);return u.useEffect(()=>{n&&(r.setReference(p(n)),s())},[n,r,s,p]),u.useMemo(()=>({isMounted:c,ref:r.setFloating,style:{display:"flex",...d,...a}}),[a,c,r.setFloating,d])}function ku(e,t,n){const o=vs("row",t,n),r=vs("column",e,n);return u.useMemo(()=>({rowButton:o,columnButton:r}),[o,r])}const ys=({editor:e,onMouseDown:t,onMouseUp:n,orientation:o,children:r})=>{const{editor:s}=k(e),i=Nn({editor:s}),a=o==="row",c=u.useRef(!1),[d,p]=u.useState(null),f=u.useCallback(C=>{if(!i)return;const g=T.TableMap.get(i.block);c.current=!1,p({startPos:a?C.clientY:C.clientX,originalHeight:g.height,originalWidth:g.width}),t(),C.preventDefault()},[i,a,t]),h=u.useCallback(()=>{c.current||!s||!i||In(s,()=>{En(s,i.block,i.blockPos,o),a?s.commands.addRowAfter():s.commands.addColumnAfter()})},[s,a,o,i]);return u.useEffect(()=>{if(!d||!s||!i)return;const C=b=>{c.current=!0;const w=(a?b.clientY:b.clientX)-d.startPos,v=a?Dc:ut,y=T.TableMap.get(i.block),x=a?y.height:y.width,S=a?d.originalHeight:d.originalWidth,I=Math.max(1,S+Fc(w/v,.3))-x;I!==0&&(I>0?In(s,()=>{En(s,i.block,i.blockPos,o);for(let V=0;V<I;V++)a?s.commands.addRowAfter():s.commands.addColumnAfter()}):In(s,()=>{const V=Math.abs(I),K=a?_c(s,i.blockPos):Zc(s,i.blockPos),se=Math.min(V,K,x-1);En(s,i.block,i.blockPos,o);for(let O=0;O<se;O++)a?s.commands.deleteRow():s.commands.deleteColumn()}))},g=()=>{p(null),n()};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",g),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",g)}},[d,s,a,o,n,i]),s?.isEditable?l.jsx("button",{className:$("tiptap-table-extend-row-column-button",a?"tiptap-table-row-end-add-remove":"tiptap-table-column-end-add-remove",d&&"editing"),onClick:h,onMouseDown:f,type:"button","aria-label":a?"Add or remove rows":"Add or remove columns",children:r??l.jsx(ws,{className:"tiptap-button-icon"})}):null},Su=({editor:e,onMouseDown:t,onMouseUp:n})=>{const{editor:o}=k(e),r=Nn({editor:o}),{columnButton:s,rowButton:i}=ku(r?.showAddOrRemoveColumnsButton??!1,r?.showAddOrRemoveRowsButton??!1,r?.referencePosTable??null),a=u.useCallback(()=>{o&&(o.commands.freezeHandles(),t?.())},[o,t]),c=u.useCallback(()=>{o&&(o.commands.unfreezeHandles(),n?.())},[o,n]);return r?l.jsxs(z.FloatingPortal,{root:r.widgetContainer,children:[l.jsx("div",{ref:i.ref,style:i.style,children:l.jsx(ys,{editor:o,orientation:"row",block:r.block,onMouseDown:a,onMouseUp:c})}),l.jsx("div",{ref:s.ref,style:s.style,children:l.jsx(ys,{editor:o,orientation:"column",block:r.block,onMouseDown:a,onMouseUp:c})})]}):null};function xs(e,t,n,o,r){const{dismissOptions:s,...i}=o||{},{refs:a,context:c,floatingStyles:d}=z.useFloating({open:e,whileElementsMounted(b,m,w){return z.autoUpdate(b,m,w,r)},...i}),{isMounted:p,styles:f}=z.useTransitionStyles(c),h=z.useDismiss(c,s),{getReferenceProps:C,getFloatingProps:g}=z.useInteractions([h]);return u.useEffect(()=>{if(t===null){a.setReference(null);return}if(t instanceof HTMLElement){a.setReference(t);return}const b=()=>(typeof t=="function"?t():t)||new DOMRect;a.setReference({getBoundingClientRect:b})},[t,a]),u.useMemo(()=>({isMounted:p,ref:a.setFloating,style:{...f,...d,zIndex:n},getFloatingProps:g,getReferenceProps:C}),[d,p,a.setFloating,f,n,g,C])}function Tu(e,t,n){if(!t?.text||!n)return e;const o=t.text,r=o.lastIndexOf(n);if(r===-1)return e;const s=o.substring(r).length;return e-s}function Au(e,t){const n=t.trim().toLowerCase();return n?e.filter(o=>!!(o.title.toLowerCase().includes(n)||o.subtext?.toLowerCase().includes(n)||o.keywords?.some(r=>r.toLowerCase().includes(n)))).sort((o,r)=>{const s=o.title.toLowerCase(),i=r.title.toLowerCase();return s===n&&i!==n?-1:i===n&&s!==n?1:s.startsWith(n)&&!i.startsWith(n)?-1:i.startsWith(n)&&!s.startsWith(n)?1:0}):e}const bo=({editor:e,floatingOptions:t,selector:n="tiptap-suggestion-menu",children:o,maxHeight:r=384,pluginKey:s=Pr.SuggestionPluginKey,...i})=>{const{editor:a}=k(e),[c,d]=u.useState(!1),[p,f]=u.useState(null),[h,C]=u.useState(null),[g,b]=u.useState([]),[m,w]=u.useState(""),[,v]=u.useState(null),{ref:y,style:x,getFloatingProps:S,isMounted:L}=xs(c,p,1e3,{placement:"bottom-start",middleware:[z.offset(10),z.flip({mainAxis:!0,crossAxis:!1}),z.shift(),z.size({apply({availableHeight:O,elements:Y}){if(Y.floating){const A=r?Math.min(r,O):O;Y.floating.style.setProperty("--suggestion-menu-max-height",`${A}px`)}}})],onOpenChange(O){O||d(!1)},...t}),I=u.useRef(i);u.useEffect(()=>{I.current=i},[i]);const V=u.useCallback(()=>{d(!1)},[]);u.useEffect(()=>{if(!a||a.isDestroyed)return;a.state.plugins.find(H=>H.spec.key===s)&&a.unregisterPlugin(s);const Y=I.current.char??"@",A=a.extensionManager.extensions.find(H=>{if(H.name!=="mention")return!1;const W=H.options?.suggestions;return W?.length?W.some(P=>(P.char??"@")===Y):(H.options?.suggestion?.char??"@")===Y}),N={};if(A){let H=null;const W=A.options?.suggestions;if(W?.length?H=W.find(P=>(P.char??"@")===Y):A.options?.suggestion&&(H=A.options.suggestion),H){const P=new Set(["pluginKey","editor","render","command","items","allow","char"]);for(const q of Object.keys(H))P.has(q)||(N[q]=H[q])}}const U=Pr.Suggestion({...N,pluginKey:s instanceof E.PluginKey?s:new E.PluginKey(s),editor:a,allow(H){const W=a.state.doc.resolve(H.range.from);for(let P=W.depth;P>0;P--)if(W.node(P).type.name==="image")return!1;return!0},command({editor:H,range:W,props:P}){if(!W)return;const{view:q,state:Z}=H,{selection:le}=Z;if(!H.extensionManager.extensions.some(Ge=>{if(Ge.name!=="mention")return!1;const Ve=Ge.options?.suggestions;return Ve?.length?Ve.some(F=>(F.char??"@")===I.current.char):(Ge.options?.suggestion?.char??"@")===I.current.char})){const Ge=le.$from.pos,Ve=le.$head?.nodeBefore,F=Ve?Tu(Ge,Ve,I.current.char):le.$from.start(),oe=Z.tr.deleteRange(F,Ge);q.dispatch(oe)}const ot={...W};q.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(ot.to+=1),P.onSelect({editor:H,range:ot,context:P.context})},render:()=>({onStart:H=>{f(H.decorationNode??null),C(()=>H.command),b(H.items),w(H.query),v(H.range),d(!0)},onUpdate:H=>{f(H.decorationNode??null),C(()=>H.command),b(H.items),w(H.query),v(H.range)},onKeyDown:H=>(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab","Home","End","Enter","Escape"].includes(H.event.key)&&(H.event.preventDefault(),H.event.stopPropagation()),H.event.key==="Escape"?(V(),!0):!1),onExit:()=>{f(null),C(null),b([]),w(""),v(null),d(!1)}}),...I.current});return a.registerPlugin(U),()=>{a.isDestroyed||a.unregisterPlugin(s)}},[a,s,V]);const K=u.useCallback(O=>{V(),h&&h(O)},[V,h]),{selectedIndex:se}=Ut({editor:a,query:m,items:g,onSelect:K});return!L||!c||!a?null:l.jsx("div",{ref:y,style:x,...S(),"data-selector":n,className:"tiptap-suggestion-menu",role:"listbox","aria-label":"Suggestions",onPointerDown:O=>O.preventDefault(),children:o({items:g,selectedIndex:se,onSelect:K})})};function Iu(e){return{paragraph:e.text,heading:e.heading,blockquote:e.blockquote,listItem:e.listItem,codeBlock:e.codeBlock,table:e.table,tocNode:e.tableOfContents}}const ks=(e,t=Ie())=>{if(!e)return t.node;const n=Iu(t),{selection:o}=e.state;if(o instanceof E.NodeSelection){const i=o.node.type.name;return n[i]||i.toLowerCase()}if(o instanceof T.CellSelection)return t.table;const{$anchor:r}=o,s=r.parent.type.name;return n[s]||s.toLowerCase()};function Ss(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.top<o.top,s=n.bottom>o.bottom;return r&&s?"both":r?"top":s?"bottom":"none"}const Ts=(e,t,n=["imageUpload","horizontalRule"])=>{if(!e)return!1;t||(t=e.state.selection);const{state:o}=e,{doc:r}=o,{empty:s,from:i,to:a}=t,c=!r.textBetween(i,a).length&&G.isTextSelection(t),d=t.$from.parent.type.spec.code||G.isNodeSelection(t)&&t.node.type.spec.code,p=G.isNodeSelection(t)&&n.includes(t.node.type.name),f=t instanceof T.CellSelection;return!s&&!c&&!d&&!p&&!f},Lu=e=>{if(!e)return!1;const{state:t}=e,{selection:n}=t;return G.isTextSelection(n)&&!n.empty&&!n.$from.parent.type.spec.code&&!G.isNodeSelection(n)},Eu=e=>{const{state:t}=e.view,{selection:n}=t,{ranges:o}=n,r=Math.min(...o.map(i=>i.$from.pos)),s=Math.max(...o.map(i=>i.$to.pos));if(G.isNodeSelection(n)){const i=e.view.nodeDOM(r);if(i)return i.getBoundingClientRect()}return G.posToDOMRect(e.view,r,s)},mo=e=>{if(!e)return"/avatars/memoji_01.png";let t=0;for(let s=0;s<e.length;s++)t=e.charCodeAt(s)+((t<<5)-t),t=t&t;const n=Math.abs(t)%1e6/1e6;return`/avatars/memoji_${(1+Math.floor(n*20)).toString().padStart(2,"0")}.png`},As=100,Mu=(e,t)=>e.name.localeCompare(t.name),Nu=(e,t)=>{const n=e.toLowerCase().trim();return t.name.toLowerCase().includes(n)||t.shortcodes.some(o=>o.toLowerCase().includes(n))||t.tags.some(o=>o.toLowerCase().includes(n))},Hu=e=>{const{query:t,emojis:n}=e,o=t.trim();return(o?n.filter(s=>Nu(o,s)).slice(0,As):n.slice(0,As)).sort(Mu)},Vu=e=>{const{emoji:t,isSelected:n,onSelect:o,selector:r}=e,s=u.useRef(null);return u.useEffect(()=>{const i=document.querySelector(r);if(!s.current||!n||!i)return;const a=Ss(s.current,i);a==="top"?s.current.scrollIntoView(!0):a==="bottom"&&s.current.scrollIntoView(!1)},[n,r]),t?l.jsxs(M,{ref:s,variant:"ghost","data-active-state":n?"on":"off",onClick:()=>o(t),children:[t.fallbackImage?l.jsx("img",{className:"tiptap-button-emoji",src:t.fallbackImage,alt:t.name}):l.jsx("span",{className:"tiptap-button-emoji",children:t.emoji}),l.jsxs("span",{className:"tiptap-button-text",children:[":",t.name,":"]})]}):null},Bu=e=>l.jsx(bo,{char:":",pluginKey:"emojiDropdownMenu",decorationClass:"tiptap-emoji-decoration",selector:"tiptap-emoji-dropdown-menu",items:Du,...e,children:t=>l.jsx(Uu,{...t})}),Du=async e=>{const t=e.editor.extensionStorage.emoji.emojis||[];return Hu({query:e.query,emojis:t}).map(o=>({title:o.name,subtext:o.shortcodes.join(", "),context:o,onSelect:r=>{!r.editor||!r.range||!r.context||r.editor.chain().focus().setEmoji(r.context.name).run()}}))},Uu=({items:e,selectedIndex:t,onSelect:n})=>{const o=u.useMemo(()=>{const r=[];return e.forEach((s,i)=>{s.context&&r.push(l.jsx(Vu,{emoji:s.context,index:i,isSelected:i===t,onSelect:()=>n(s),selector:"[data-selector='tiptap-emoji-dropdown-menu']"},s.title))}),r},[e,t,n]);return o.length?l.jsx(Ze,{style:{maxHeight:"var(--suggestion-menu-max-height)"},children:l.jsx(Fe,{children:l.jsx(Me,{children:o})})}):null},Is="_tiptap_username",Ls="_tiptap_color",Es="_tiptap_user_id",Ms=["John","Jane","Alice","Bob","Eve","Charlie","David","Frank","Grace","Helen","Rob Lowe","Rob"],Ou=["Smith","Johnson","Williams","Jones","Brown","Davis","Miller","Wilson","Moore","Taylor","Anderson","Thomas","Lowe"],Pu=["#fb7185","#fdba74","#d9f99d","#a7f3d0","#a5f3fc","#a5b4fc","#f0abfc","#fda58d","#f2cc8f","#9ae6b4"],Wu=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.random()*16|0;return(t==="x"?n:n&3|8).toString(16)}),$t=e=>{if(e.length===0)throw new Error("Cannot get random item from empty array");return e[Math.floor(Math.random()*e.length)]},_u=()=>{const e=[$t(Ms)];return Math.random()>.85&&e.push($t(Ms)),e.push($t(Ou)),e.join(" ")},Zu=()=>$t(Pu)??"#9ae6b4",Fu=()=>typeof window>"u"?null:window.localStorage;function zu(e=Fu()){const t=e?.getItem(Is)||_u(),n=e?.getItem(Ls)||Zu(),r={id:e?.getItem(Es)||Wu(),name:t,color:n,avatar:mo(t)};return e?.setItem(Is,r.name),e?.setItem(Ls,r.color),e?.setItem(Es,r.id),r}function Ns(e){return e?.name?{id:"id"in e&&e.id?e.id:e.name,name:e.name,color:e.color||"#958df1",avatar:e.avatar||mo(e.name),position:"position"in e?e.position:void 0}:null}function $u(e){return e?.map(Ns).filter(t=>!!t)??[]}function Hs(e){return typeof e.name!="string"||!e.name?null:{id:typeof e.id=="string"&&e.id?e.id:e.clientId!=null?String(e.clientId):e.name,name:e.name,color:typeof e.color=="string"&&e.color?e.color:"#958df1",avatar:typeof e.avatar=="string"&&e.avatar?e.avatar:mo(e.name),position:typeof e.position=="string"&&e.position?e.position:void 0}}function qu(e){return e.id||e.name}function wo(e){const t=new Set,n=[];return e.forEach(o=>{const r=qu(o);t.has(r)||(t.add(r),n.push(o))}),n}function Gu(e,t,n=20){const o=e.trim().toLowerCase(),r=wo(t);return o?r.filter(s=>s.name.toLowerCase().includes(o)||s.position?.toLowerCase().includes(o)).slice(0,n):r.slice(0,n)}const Vs=u.createContext(void 0),Bs=()=>{const e=u.useContext(Vs);if(!e)throw new Error("Avatar components must be used within an Avatar.Root");return e},Ku=(e,t)=>{const n=e?"loading":"error",[o,r]=u.useState(n);return u.useLayoutEffect(()=>{if(!e)return;let s=!0;const i=new window.Image,a=c=>()=>{s&&r(c)};return i.onload=a("loaded"),i.onerror=a("error"),i.src=e,t&&(i.referrerPolicy=t),()=>{s=!1}},[e,t]),o},qt=u.forwardRef(({children:e,className:t="",size:n="default",userColor:o,...r},s)=>{const[i,a]=u.useState("idle"),c=u.useCallback(f=>{a(f)},[]),d=u.useMemo(()=>({imageLoadingStatus:i,onImageLoadingStatusChange:c,size:n}),[i,c,n]),p=o?{"--dynamic-user-color":o}:void 0;return l.jsx(Vs.Provider,{value:d,children:l.jsx("span",{...r,ref:s,className:`tiptap-avatar ${t}`,style:p,"data-size":n,children:l.jsx("span",{className:"tiptap-avatar-item",children:e})})})});qt.displayName="Avatar";const vo=u.forwardRef(({onLoadingStatusChange:e,src:t,className:n="",...o},r)=>{const{onImageLoadingStatusChange:s}=Bs(),i=Ku(t,o.referrerPolicy);return u.useLayoutEffect(()=>{i!=="idle"&&(e?.(i),s(i))},[i,e,s]),i!=="loaded"?null:l.jsx("img",{alt:"",...o,ref:r,src:t,className:`tiptap-avatar-image ${n}`})});vo.displayName="AvatarImage";const Gt=u.forwardRef(({delayMs:e,className:t="",children:n,...o},r)=>{const s=Bs(),[i,a]=u.useState(e===void 0);return u.useEffect(()=>{if(e!==void 0){const c=window.setTimeout(()=>a(!0),e);return()=>window.clearTimeout(c)}},[e]),!i||s.imageLoadingStatus==="loaded"?null:l.jsxs(l.Fragment,{children:[l.jsx("span",{className:`tiptap-avatar-bg ${t}`}),l.jsx("span",{...o,ref:r,className:`tiptap-avatar-fallback ${t}`,children:n})]})});Gt.displayName="AvatarFallback";const Ds=({maxVisible:e,children:t,className:n="",...o})=>{const r=u.Children.toArray(t),s=e?r.slice(0,e):r,i=r.length-s.length;let a={};return u.Children.forEach(t,c=>{if(u.isValidElement(c)&&c.type&&typeof c.type!="string"&&c.type.displayName==="Avatar"){a={...a,...c.props};return}}),l.jsxs("div",{...o,className:`tiptap-avatar-group ${n}`,"data-max-user-visible":e,children:[s,i>0&&l.jsx(qt,{...a,children:l.jsxs(Gt,{children:["+",i]})})]})};Ds.displayName="AvatarGroup";const Yu=({users:e=[],...t})=>{const n=u.useRef(e);u.useEffect(()=>{n.current=e},[e]);const o=s=>{!s.editor||!s.range||!s.context||s.editor.chain().focus().insertContentAt(s.range,[{type:"mention",attrs:{id:s.context.id,label:s.context.name}},{type:"text",text:" "}]).run()},r=async s=>Gu(s.query,n.current).map(a=>({title:a.name,subtext:a.position,context:a,onSelect:o}));return l.jsx(bo,{char:"@",pluginKey:"mentionDropdownMenu",decorationClass:"tiptap-mention-decoration",selector:"tiptap-mention-dropdown-menu",items:r,...t,children:s=>l.jsx(Xu,{...s})})},ju=({item:e,isSelected:t,onSelect:n})=>{const o=u.useRef(null);return u.useEffect(()=>{const r=document.querySelector('[data-selector="tiptap-mention-dropdown-menu"]');if(!o.current||!t||!r)return;const s=Ss(o.current,r);s==="top"?o.current.scrollIntoView(!0):s==="bottom"&&o.current.scrollIntoView(!1)},[t]),l.jsxs(M,{ref:o,variant:"ghost","data-active-state":t?"on":"off",onClick:n,"data-user-id":e.context?.id,children:[l.jsxs(qt,{userColor:e.context?.color,children:[l.jsx(vo,{src:e.context?.avatar,alt:e.title}),l.jsx(Gt,{children:e.title[0]?.toUpperCase()})]}),l.jsx("span",{className:"tiptap-button-text",children:e.title})]})},Xu=({items:e,selectedIndex:t,onSelect:n})=>{const o=u.useMemo(()=>{const r=[];return e.forEach((s,i)=>{r.push(l.jsx(ju,{item:s,isSelected:i===t,onSelect:()=>n(s)},s.context?.id||s.title))}),r},[e,t,n]);return o.length?l.jsx(Ze,{style:{maxHeight:"var(--suggestion-menu-max-height)"},children:l.jsx(Fe,{children:l.jsx(Me,{children:o})})}):null},yo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.70711 2.29289C7.09763 2.68342 7.09763 3.31658 6.70711 3.70711L4.41421 6L6.70711 8.29289C7.09763 8.68342 7.09763 9.31658 6.70711 9.70711C6.31658 10.0976 5.68342 10.0976 5.29289 9.70711L2.29289 6.70711C1.90237 6.31658 1.90237 5.68342 2.29289 5.29289L5.29289 2.29289C5.68342 1.90237 6.31658 1.90237 6.70711 2.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2929 2.29289C10.6834 1.90237 11.3166 1.90237 11.7071 2.29289L14.7071 5.29289C15.0976 5.68342 15.0976 6.31658 14.7071 6.70711L11.7071 9.70711C11.3166 10.0976 10.6834 10.0976 10.2929 9.70711C9.90237 9.31658 9.90237 8.68342 10.2929 8.29289L12.5858 6L10.2929 3.70711C9.90237 3.31658 9.90237 2.68342 10.2929 2.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 4C17 3.44772 17.4477 3 18 3H19C20.6569 3 22 4.34315 22 6V18C22 19.6569 20.6569 21 19 21H5C3.34315 21 2 19.6569 2 18V12C2 11.4477 2.44772 11 3 11C3.55228 11 4 11.4477 4 12V18C4 18.5523 4.44772 19 5 19H19C19.5523 19 20 18.5523 20 18V6C20 5.44772 19.5523 5 19 5H18C17.4477 5 17 4.55228 17 4Z",fill:"currentColor"})]}));yo.displayName="CodeBlockIcon";const xo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),l.jsx("path",{d:"M21.0001 10C21.0001 9.63121 20.7971 9.29235 20.472 9.11833C20.1468 8.94431 19.7523 8.96338 19.4454 9.16795L16.4454 11.168C15.9859 11.4743 15.8617 12.0952 16.1681 12.5547C16.4744 13.0142 17.0953 13.1384 17.5548 12.8321L19.0001 11.8685V18C19.0001 18.5523 19.4478 19 20.0001 19C20.5524 19 21.0001 18.5523 21.0001 18V10Z",fill:"currentColor"})]}));xo.displayName="HeadingOneIcon";const ko=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),l.jsx("path",{d:"M22.0001 12C22.0001 10.7611 21.1663 9.79297 20.0663 9.42632C18.9547 9.05578 17.6171 9.28724 16.4001 10.2C15.9582 10.5314 15.8687 11.1582 16.2001 11.6C16.5314 12.0418 17.1582 12.1314 17.6001 11.8C18.383 11.2128 19.0455 11.1942 19.4338 11.3237C19.8339 11.457 20.0001 11.7389 20.0001 12C20.0001 12.4839 19.8554 12.7379 19.6537 12.9481C19.4275 13.1837 19.1378 13.363 18.7055 13.6307C18.6313 13.6767 18.553 13.7252 18.4701 13.777C17.9572 14.0975 17.3128 14.5261 16.8163 15.2087C16.3007 15.9177 16.0001 16.8183 16.0001 18C16.0001 18.5523 16.4478 19 17.0001 19H21.0001C21.5523 19 22.0001 18.5523 22.0001 18C22.0001 17.4477 21.5523 17 21.0001 17H18.131C18.21 16.742 18.3176 16.5448 18.4338 16.385C18.6873 16.0364 19.0429 15.7775 19.5301 15.473C19.5898 15.4357 19.6536 15.3966 19.7205 15.3556C20.139 15.0992 20.6783 14.7687 21.0964 14.3332C21.6447 13.7621 22.0001 13.0161 22.0001 12Z",fill:"currentColor"})]}));ko.displayName="HeadingTwoIcon";const So=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4608 11.2169C19.1135 11.0531 18.5876 11.0204 18.0069 11.3619C17.5309 11.642 16.918 11.4831 16.638 11.007C16.358 10.531 16.5169 9.91809 16.9929 9.63807C18.1123 8.97962 19.3364 8.94691 20.314 9.40808C21.2839 9.86558 21.9999 10.818 21.9999 12C21.9999 12.7957 21.6838 13.5587 21.1212 14.1213C20.5586 14.6839 19.7956 15 18.9999 15C18.4476 15 17.9999 14.5523 17.9999 14C17.9999 13.4477 18.4476 13 18.9999 13C19.2651 13 19.5195 12.8947 19.707 12.7071C19.8946 12.5196 19.9999 12.2652 19.9999 12C19.9999 11.6821 19.8159 11.3844 19.4608 11.2169Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.0001 14C18.0001 13.4477 18.4478 13 19.0001 13C19.7957 13 20.5588 13.3161 21.1214 13.8787C21.684 14.4413 22.0001 15.2043 22.0001 16C22.0001 17.2853 21.2767 18.3971 20.1604 18.8994C19.0257 19.41 17.642 19.2315 16.4001 18.3C15.9582 17.9686 15.8687 17.3418 16.2001 16.9C16.5314 16.4582 17.1582 16.3686 17.6001 16.7C18.3581 17.2685 18.9744 17.24 19.3397 17.0756C19.7234 16.9029 20.0001 16.5147 20.0001 16C20.0001 15.7348 19.8947 15.4804 19.7072 15.2929C19.5196 15.1054 19.2653 15 19.0001 15C18.4478 15 18.0001 14.5523 18.0001 14Z",fill:"currentColor"})]}));So.displayName="HeadingThreeIcon";const Us=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V5C20 4.44772 19.5523 4 19 4H5ZM22 14.998V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H5.99781C5.99927 22 6.00073 22 6.00219 22H19C20.6569 22 22 20.6569 22 19V15.002C22 15.0007 22 14.9994 22 14.998ZM20 15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20H19C19.5523 20 20 19.5523 20 19V15.4142ZM9 8C8.44772 8 8 8.44772 8 9C8 9.55228 8.44772 10 9 10C9.55228 10 10 9.55228 10 9C10 8.44772 9.55228 8 9 8ZM6 9C6 7.34315 7.34315 6 9 6C10.6569 6 12 7.34315 12 9C12 10.6569 10.6569 12 9 12C7.34315 12 6 10.6569 6 9Z",fill:"currentColor"})}));Us.displayName="ImageIcon";const To=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));To.displayName="ListIcon";const Ao=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",fill:"currentColor"})]}));Ao.displayName="ListOrderedIcon";const Io=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H16C16.5523 5 17 5.44772 17 6C17 6.55228 16.5523 7 16 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C4.55228 3 5 3.44772 5 4L5 20C5 20.5523 4.55229 21 4 21C3.44772 21 3 20.5523 3 20L3 4C3 3.44772 3.44772 3 4 3Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H20C20.5523 11 21 11.4477 21 12C21 12.5523 20.5523 13 20 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H16C16.5523 17 17 17.4477 17 18C17 18.5523 16.5523 19 16 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"})]}));Io.displayName="BlockquoteIcon";const Lo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 4.89543 2.89543 4 4 4H8C9.10457 4 10 4.89543 10 6V10C10 11.1046 9.10457 12 8 12H4C2.89543 12 2 11.1046 2 10V6ZM8 6H4V10H8V6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L5.70711 19.7071C5.31658 20.0976 4.68342 20.0976 4.29289 19.7071L2.29289 17.7071C1.90237 17.3166 1.90237 16.6834 2.29289 16.2929C2.68342 15.9024 3.31658 15.9024 3.70711 16.2929L5 17.5858L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 6C12 5.44772 12.4477 5 13 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H13C12.4477 7 12 6.55228 12 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 12C12 11.4477 12.4477 11 13 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H13C12.4477 13 12 12.5523 12 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 18C12 17.4477 12.4477 17 13 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H13C12.4477 19 12 18.5523 12 18Z",fill:"currentColor"})]}));Lo.displayName="ListTodoIcon";const Os=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 12C4 11.4477 4.44772 11 5 11H19C19.5523 11 20 11.4477 20 12C20 12.5523 19.5523 13 19 13H5C4.44772 13 4 12.5523 4 12Z",fill:"currentColor"})}));Os.displayName="MinusIcon";const Eo=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M3 4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4V7C21 7.55228 20.5523 8 20 8C19.4477 8 19 7.55228 19 7V5H13V19H15C15.5523 19 16 19.4477 16 20C16 20.5523 15.5523 21 15 21H9C8.44772 21 8 20.5523 8 20C8 19.4477 8.44772 19 9 19H11V5H5V7C5 7.55228 4.55228 8 4 8C3.44772 8 3 7.55228 3 7V4Z",fill:"currentColor"})}));Eo.displayName="TypeIcon";const Mo=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.5273 1.29427C12.1156 0.724951 9.58234 0.986597 7.33794 2.03682C5.09354 3.08704 3.26948 4.8643 2.1613 7.08066C1.05312 9.29702 0.725742 11.8226 1.23221 14.2483C1.73868 16.6739 3.04931 18.8575 4.95178 20.4453C6.85424 22.033 9.23706 22.9319 11.7142 22.9963C14.1913 23.0607 16.6176 22.2868 18.6 20.8C19.0418 20.4686 19.1314 19.8418 18.8 19.4C18.4686 18.9582 17.8418 18.8686 17.4 19.2C15.7781 20.4165 13.7929 21.0496 11.7662 20.997C9.73942 20.9443 7.78983 20.2088 6.23327 18.9098C4.67671 17.6107 3.60437 15.8241 3.18999 13.8395C2.77561 11.8549 3.04346 9.78847 3.95015 7.97509C4.85685 6.1617 6.34926 4.70758 8.18559 3.84831C10.0219 2.98904 12.0946 2.77496 14.0678 3.24077C16.041 3.70658 17.7991 4.82497 19.0573 6.41476C20.3155 8.00455 21 9.97258 21 12V13C21 13.5304 20.7893 14.0392 20.4142 14.4142C20.0391 14.7893 19.5304 15 19 15C18.4696 15 17.9609 14.7893 17.5858 14.4142C17.2107 14.0392 17 13.5304 17 13V8.00001C17 7.44772 16.5523 7.00001 16 7.00001C15.4478 7.00001 15.0002 7.44752 15 7.99964C14.1643 7.37195 13.1256 7 12 7C9.23858 7 7 9.23858 7 12C7 14.7614 9.23858 17 12 17C13.4881 17 14.8243 16.3499 15.7403 15.3183C15.8687 15.4989 16.0128 15.6696 16.1716 15.8284C16.9217 16.5786 17.9391 17 19 17C20.0609 17 21.0783 16.5786 21.8284 15.8284C22.5786 15.0783 23 14.0609 23 13V12C23 9.52205 22.1633 7.11667 20.6255 5.17359C19.0878 3.23052 16.939 1.86359 14.5273 1.29427ZM15 11.9958V12.0042C14.9977 13.6591 13.6555 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6555 9 14.9977 10.3409 15 11.9958Z",fill:"currentColor"})}));Mo.displayName="AtSignIcon";const No=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.67909 4.05505C9.27254 3.18292 11.0926 2.81337 12.9 2.995C13.4495 3.05022 13.9398 2.64952 13.995 2.1C14.0502 1.55048 13.6495 1.06024 13.1 1.00502C10.8909 0.783033 8.66641 1.2347 6.71886 2.30064C4.7713 3.36659 3.19189 4.99691 2.18824 6.97729C1.1846 8.95767 0.803706 11.1954 1.09564 13.3963C1.38758 15.5972 2.33867 17.6583 3.8239 19.3085C5.30912 20.9588 7.25894 22.121 9.41704 22.6423C11.5751 23.1637 13.8405 23.0198 15.9153 22.2296C17.9901 21.4394 19.7772 20.0398 21.0417 18.2149C22.3062 16.39 22.9889 14.2252 23 12.005L23 12V11C23 10.4477 22.5523 10 22 10C21.4477 10 21 10.4477 21 11V11.9976C20.9904 13.8132 20.4319 15.5834 19.3978 17.0758C18.3632 18.5689 16.901 19.714 15.2034 20.3605C13.5059 21.0071 11.6524 21.1248 9.8867 20.6982C8.12098 20.2717 6.52567 19.3208 5.31048 17.9706C4.0953 16.6204 3.31713 14.9341 3.07828 13.1333C2.83942 11.3326 3.15106 9.50171 3.97222 7.8814C4.79339 6.26109 6.08564 4.92719 7.67909 4.05505ZM7.4 13.2C7.84043 12.8697 8.46468 12.9576 8.79686 13.3958L8.8015 13.4018C8.80745 13.4093 8.81876 13.4234 8.83531 13.4431C8.86846 13.4826 8.92219 13.5442 8.99542 13.6206C9.14272 13.7743 9.36407 13.9828 9.65067 14.1913C10.2277 14.6109 11.0255 15 12 15C12.9745 15 13.7723 14.6109 14.3493 14.1913C14.6359 13.9828 14.8573 13.7743 15.0046 13.6206C15.0778 13.5442 15.1315 13.4826 15.1647 13.4431C15.1812 13.4234 15.1925 13.4093 15.1985 13.4018L15.2031 13.3958C15.5353 12.9576 16.1596 12.8697 16.6 13.2C17.0418 13.5314 17.1314 14.1582 16.8 14.6L16 14C16.8 14.6 16.7998 14.6003 16.7995 14.6006L16.799 14.6013L16.7978 14.6029L16.7951 14.6065L16.7879 14.6159L16.7666 14.6432C16.7493 14.6649 16.726 14.6938 16.6966 14.7288C16.638 14.7987 16.555 14.8933 16.4485 15.0044C16.2365 15.2257 15.9266 15.5172 15.5257 15.8087C14.7277 16.3891 13.5255 17 12 17C10.4745 17 9.27227 16.3891 8.47433 15.8087C8.07343 15.5172 7.76352 15.2257 7.55145 15.0044C7.445 14.8933 7.362 14.7987 7.30336 14.7288C7.274 14.6938 7.25065 14.6649 7.23341 14.6432L7.21211 14.6159L7.2049 14.6065L7.20216 14.6029L7.20101 14.6013L7.20048 14.6006C7.20024 14.6003 7.2 14.6 8 14L7.2 14.6C6.86863 14.1582 6.95817 13.5314 7.4 13.2ZM8 9C8 8.44772 8.44772 8 9 8H9.01C9.56229 8 10.01 8.44772 10.01 9C10.01 9.55229 9.56229 10 9.01 10H9C8.44772 10 8 9.55229 8 9ZM15 8C14.4477 8 14 8.44772 14 9C14 9.55229 14.4477 10 15 10H15.01C15.5623 10 16.01 9.55229 16.01 9C16.01 8.44772 15.5623 8 15.01 8H15ZM15 5C15 4.44772 15.4477 4 16 4H18V2C18 1.44772 18.4477 1 19 1C19.5523 1 20 1.44772 20 2V4H22C22.5523 4 23 4.44772 23 5C23 5.55228 22.5523 6 22 6H20V8C20 8.55228 19.5523 9 19 9C18.4477 9 18 8.55228 18 8V6H16C15.4477 6 15 5.55228 15 5Z",fill:"currentColor"})}));No.displayName="SmilePlusIcon";const Ps=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM4 5C4 4.44772 4.44772 4 5 4H11V8H4V5ZM4 10H11V14H4V10ZM20 14V10H13V14H20ZM13 16H20V19C20 19.5523 19.5523 20 19 20H13V16ZM11 16V20H5C4.44772 20 4 19.5523 4 19V16H11ZM13 8H20V5C20 4.44772 19.5523 4 19 4H13V8Z",fill:"currentColor"})}));Ps.displayName="TableIcon";const Ho=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 12C11 11.4477 11.4477 11 12 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H12C11.4477 13 11 12.5523 11 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.5 16.5C3.22386 16.5 3 16.7239 3 17V19C3 19.2761 3.22386 19.5 3.5 19.5H5.5C5.77614 19.5 6 19.2761 6 19V17C6 16.7239 5.77614 16.5 5.5 16.5H3.5Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.5 10.5C6.22386 10.5 6 10.7239 6 11V13C6 13.2761 6.22386 13.5 6.5 13.5H8.5C8.77614 13.5 9 13.2761 9 13V11C9 10.7239 8.77614 10.5 8.5 10.5H6.5Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.5 4.5C3.22386 4.5 3 4.72386 3 5V7C3 7.27614 3.22386 7.5 3.5 7.5H5.5C5.77614 7.5 6 7.27614 6 7V5C6 4.72386 5.77614 4.5 5.5 4.5H3.5Z",fill:"currentColor"})]}));Ho.displayName="ListIndentedIcon";const Vo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.94924 1.68544C6.81364 1.27624 6.43108 1 6 1C5.56892 1 5.18636 1.27624 5.05076 1.68544L4.3711 3.73642C4.2717 4.03638 4.03638 4.2717 3.73642 4.3711L1.68544 5.05076C1.27624 5.18636 1 5.56892 1 6C1 6.43108 1.27624 6.81364 1.68544 6.94924L3.73642 7.6289C4.03638 7.7283 4.2717 7.96362 4.3711 8.26358L5.05076 10.3146C5.18636 10.7238 5.56892 11 6 11C6.43108 11 6.81364 10.7238 6.94924 10.3146L7.6289 8.26358C7.7283 7.96362 7.96362 7.7283 8.26358 7.6289L10.3146 6.94924C10.7238 6.81364 11 6.43108 11 6C11 5.56892 10.7238 5.18636 10.3146 5.05076L8.26358 4.3711C7.96362 4.2717 7.7283 4.03638 7.6289 3.73642L6.94924 1.68544ZM4.95595 6C5.38537 5.74447 5.74447 5.38537 6 4.95595C6.25554 5.38537 6.61463 5.74447 7.04405 6C6.61463 6.25554 6.25554 6.61463 6 7.04405C5.74447 6.61463 5.38537 6.25554 4.95595 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.9492 5.68544C14.8136 5.27624 14.4311 5 14 5C13.5689 5 13.1864 5.27624 13.0508 5.68544L11.3755 10.7408C11.2761 11.0408 11.0408 11.2761 10.7408 11.3755L5.68544 13.0508C5.27624 13.1864 5 13.5689 5 14C5 14.4311 5.27624 14.8136 5.68544 14.9492L10.7408 16.6245C11.0408 16.7239 11.2761 16.9592 11.3755 17.2592L13.0508 22.3146C13.1864 22.7238 13.5689 23 14 23C14.4311 23 14.8136 22.7238 14.9492 22.3146L16.6245 17.2592C16.7239 16.9592 16.9592 16.7239 17.2592 16.6245L22.3146 14.9492C22.7238 14.8136 23 14.4311 23 14C23 13.5689 22.7238 13.1864 22.3146 13.0508L17.2592 11.3755C16.9592 11.2761 16.7239 11.0408 16.6245 10.7408L14.9492 5.68544ZM13.274 11.3699L14 9.17903L14.726 11.3699C15.0242 12.2698 15.7302 12.9758 16.6301 13.274L18.821 14L16.6301 14.726C15.7302 15.0242 15.0242 15.7302 14.726 16.6301L14 18.821L13.274 16.6301C12.9758 15.7302 12.2698 15.0242 11.3699 14.726L9.17903 14L11.3699 13.274C12.2698 12.9758 12.9758 12.2698 13.274 11.3699Z",fill:"currentColor"})]}));Vo.displayName="AiSparklesIcon";function Ju({shortcutKeys:e=Bo}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Qu=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:r=":",hideWhenUnavailable:s=!1,onTriggerApplied:i,showShortcut:a=!1,onClick:c,children:d,...p},f)=>{const{editor:h}=k(e),{isVisible:C,canAddTrigger:g,handleAddTrigger:b,label:m,shortcutKeys:w,Icon:v}=n7({editor:h,node:t,nodePos:n,trigger:r,hideWhenUnavailable:s,onTriggerApplied:i}),y=u.useCallback(x=>{c?.(x),!x.defaultPrevented&&b()},[b,c]);return C?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!g,"data-disabled":!g,"aria-label":m,tooltip:"Add emoji",onClick:y,...p,ref:f,children:d??l.jsxs(l.Fragment,{children:[l.jsx(v,{className:"tiptap-button-icon"}),o&&l.jsx("span",{className:"tiptap-button-text",children:o}),a&&l.jsx(Ju,{shortcutKeys:w})]})}):null});Qu.displayName="EmojiTriggerButton";const Bo="mod+shift+e";function Do(e){return!(!e||!e.isEditable||ie(e,["image"]))}function Ru(e,t,n,o){if(n!=null||X(o)){const s=me({editor:e,node:n||void 0,nodePos:o||void 0});if(!s)return!1;const i=s.node.type.name==="paragraph"&&s.node.content.size===0,a=s.pos+s.node.nodeSize;return e.chain().insertContentAt(i?s.pos:a,{type:"paragraph",content:[{type:"text",text:t}]}).focus(i?s.pos+t.length+1:a+t.length+1).run()}const{$from:r}=e.state.selection;return e.chain().insertContentAt(r.after(),{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}function e7(e,t,n,o){if(n!=null||X(o)){const a=me({editor:e,node:n||void 0,nodePos:o||void 0});if(!a)return!1;const c=a.node.type.name==="paragraph"&&a.node.content.size===0,d=a.pos+a.node.nodeSize;return e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,c?a.pos:d,c?a.pos:d)),e.commands.focus(c?a.pos+2:d+t.length+1),!0}const{$from:r}=e.state.selection,s=r.node(),i=r.parentOffset>0&&s.textContent[r.parentOffset-1]!==" ";return e.chain().insertContent({type:"text",text:i?` ${t}`:t}).focus().run()}function Ws(e,t=":",n,o){if(!e||!e.isEditable||!Do(e))return!1;try{const{$from:r}=e.state.selection,s=r.node();return s.isBlock&&!s.isTextblock?Ru(e,t,n,o):e7(e,t,n,o)}catch{return!1}}function t7(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:Do(t):!1:!0:!1}function n7(e){const{editor:t,node:n,nodePos:o,trigger:r=":",hideWhenUnavailable:s=!1,onTriggerApplied:i}=e||{},{editor:a}=k(t),c=re(),[d,p]=u.useState(!0),f=Do(a);u.useEffect(()=>{if(!a)return;const C=()=>{p(t7({editor:a,hideWhenUnavailable:s}))};return C(),a.on("selectionUpdate",C),()=>{a.off("selectionUpdate",C)}},[a,s]);const h=u.useCallback(()=>{if(!a)return!1;const C=Ws(a,r,n,o);return C&&i?.(r),C},[a,r,n,o,i]);return ue.useHotkeys(Bo,C=>{C.preventDefault(),h()},{enabled:d&&f,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,handleAddTrigger:h,canAddTrigger:f,label:"Add emoji",shortcutKeys:Bo,trigger:r,Icon:No}}function o7({shortcutKeys:e=Uo}){return l.jsx(R,{children:J({shortcutKeys:e})})}const r7=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:r="@",hideWhenUnavailable:s=!1,onTriggered:i,showShortcut:a=!1,onClick:c,children:d,...p},f)=>{const{editor:h}=k(e),{isVisible:C,canInsert:g,handleMention:b,label:m,shortcutKeys:w,Icon:v}=a7({editor:h,node:t,nodePos:n,trigger:r,hideWhenUnavailable:s,onTriggered:i}),y=u.useCallback(x=>{c?.(x),!x.defaultPrevented&&b()},[b,c]);return C?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!g,"data-disabled":!g,"aria-label":m,tooltip:m,onClick:y,...p,ref:f,children:d??l.jsxs(l.Fragment,{children:[l.jsx(v,{className:"tiptap-button-icon"}),o&&l.jsx("span",{className:"tiptap-button-text",children:o}),a&&l.jsx(o7,{shortcutKeys:w})]})}):null});r7.displayName="MentionTriggerButton";const Uo="mod+shift+2";function Oo(e,t,n){if(!e||!e.isEditable||ie(e,["image"]))return!1;if(t||X(n)){if(X(n)&&n>=0)return!0;if(t)return me({editor:e,node:t})!==null}return!0}function l7(e,t,n,o){if(n!=null||X(o)){const s=me({editor:e,node:n||void 0,nodePos:o||void 0});if(!s)return!1;const i=s.node.type.name==="paragraph"&&s.node.content.size===0,a=i?s.pos:s.pos+s.node.nodeSize,c=t.length+1,d=i?s.pos+c:s.pos+s.node.nodeSize+c;return e.chain().insertContentAt(i?s.pos:a,{type:"paragraph",content:[{type:"text",text:t}]}).focus(d).run()}const{$from:r}=e.state.selection;return e.chain().insertContentAt(r.after(),{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}function s7(e,t,n,o){if(n!=null||X(o)){const a=me({editor:e,node:n||void 0,nodePos:o||void 0});if(!a)return!1;const c=a.node.type.name==="paragraph"&&a.node.content.size===0,d=c?a.pos:a.pos+a.node.nodeSize;e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,d,d));const p=t.length+1,f=c?a.pos+p:a.pos+a.node.nodeSize+p;return e.commands.focus(f),!0}const{$from:r}=e.state.selection,s=r.node(),i=r.parentOffset>0&&s.textContent[r.parentOffset-1]!==" ";return e.chain().insertContent({type:"text",text:i?` ${t}`:t}).focus().run()}function _s(e,t="@",n,o){if(!e||!e.isEditable||!Oo(e,n,o))return!1;try{const{$from:r}=e.state.selection,s=r.node();return s.isBlock&&!s.isTextblock?l7(e,t,n,o):s7(e,t,n,o)}catch{return!1}}function i7(e){const{editor:t,hideWhenUnavailable:n,node:o,nodePos:r}=e;return t?n?t.isEditable?t.isActive("code")?!0:Oo(t,o,r):!1:!0:!1}function a7(e){const{editor:t,node:n,nodePos:o,trigger:r="@",hideWhenUnavailable:s=!1,onTriggered:i}=e||{},{editor:a}=k(t),c=re(),[d,p]=u.useState(!0),f=Oo(a,n,o);u.useEffect(()=>{if(!a)return;const C=()=>{p(i7({editor:a,hideWhenUnavailable:s,node:n,nodePos:o}))};return C(),a.on("selectionUpdate",C),()=>{a.off("selectionUpdate",C)}},[a,s,n,o]);const h=u.useCallback(()=>{if(!a)return!1;const C=_s(a,r,n,o);return C&&i?.(r),C},[a,r,n,o,i]);return ue.useHotkeys(Uo,C=>{C.preventDefault(),h()},{enabled:d&&f,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,handleMention:h,canInsert:f,label:"Add mention",shortcutKeys:Uo,trigger:r,Icon:Mo}}function c7(e){return{ai_continue_writing:{title:e.continueWriting,subtext:e.continueWritingSubtext,keywords:["ai","continue","writing","autocomplete","complete"],badge:Vo,group:e.ai},ai_ask:{title:e.askAi,subtext:e.askAiSubtext,keywords:["ai","ask","assistant","generate","write"],badge:Vo,group:e.ai},text:{title:e.text,subtext:e.regularTextParagraph,keywords:["p","paragraph","text"],badge:Eo,group:e.style},heading_1:{title:e.heading1,subtext:e.topLevelHeading,keywords:["h","heading1","h1"],badge:xo,group:e.style},heading_2:{title:e.heading2,subtext:e.heading2,keywords:["h2","heading2","subheading"],badge:ko,group:e.style},heading_3:{title:e.heading3,subtext:e.subsectionAndGroupHeading,keywords:["h3","heading3","subheading"],badge:So,group:e.style},bullet_list:{title:e.bulletList,subtext:e.listWithUnorderedItems,keywords:["ul","li","list","bulletlist","bullet list"],badge:To,group:e.style},ordered_list:{title:e.orderedList,subtext:e.listWithOrderedItems,keywords:["ol","li","list","numberedlist","numbered list"],badge:Ao,group:e.style},task_list:{title:e.taskList,subtext:e.listWithTasks,keywords:["tasklist","task list","todo","checklist"],badge:Lo,group:e.style},quote:{title:e.blockquote,subtext:e.blockquoteBlock,keywords:["quote","blockquote"],badge:Io,group:e.style},code_block:{title:e.codeBlock,subtext:e.codeBlockWithSyntaxHighlighting,keywords:["code","pre"],badge:yo,group:e.style},mention:{title:e.mention,subtext:e.mentionSubtext,keywords:["mention","user","item","tag"],badge:Mo,group:e.insert},emoji:{title:e.emoji,subtext:e.emojiSubtext,keywords:["emoji","emoticon","smiley"],badge:No,group:e.insert},table:{title:e.table,subtext:e.tableSubtext,keywords:["table","insertTable"],badge:Ps,group:e.insert},divider:{title:e.separator,subtext:e.separatorSubtext,keywords:["hr","horizontalRule","line","separator"],badge:Os,group:e.insert},toc:{title:e.tableOfContents,subtext:e.tableOfContentsSubtext,keywords:["toc","tableofcontents","table of contents"],badge:Ho,group:e.insert},image:{title:e.image,subtext:e.imageSubtext,keywords:["image","imageUpload","upload","img","picture","media","url"],badge:Us,group:e.upload}}}function d7(e,t){return t?.aiEnabled?e:e.filter(n=>!n.startsWith("ai_"))}const u7=e=>({ai_continue_writing:{check:t=>t.isEditable,action:({editor:t})=>{t.chain().focus().run(),e?.onAiAction?.("continue_writing")}},ai_ask:{check:t=>t.isEditable,action:({editor:t})=>{t.chain().focus().run(),e?.onAiAction?.("ask")}},text:{check:t=>te("paragraph",t),action:({editor:t})=>{t.chain().focus().setParagraph().run()}},heading_1:{check:t=>te("heading",t),action:({editor:t})=>{t.chain().focus().toggleHeading({level:1}).run()}},heading_2:{check:t=>te("heading",t),action:({editor:t})=>{t.chain().focus().toggleHeading({level:2}).run()}},heading_3:{check:t=>te("heading",t),action:({editor:t})=>{t.chain().focus().toggleHeading({level:3}).run()}},bullet_list:{check:t=>te("bulletList",t),action:({editor:t})=>{t.chain().focus().toggleBulletList().run()}},ordered_list:{check:t=>te("orderedList",t),action:({editor:t})=>{t.chain().focus().toggleOrderedList().run()}},task_list:{check:t=>te("taskList",t),action:({editor:t})=>{t.chain().focus().toggleTaskList().run()}},quote:{check:t=>te("blockquote",t),action:({editor:t})=>{t.chain().focus().toggleBlockquote().run()}},code_block:{check:t=>te("codeBlock",t),action:({editor:t})=>{t.chain().focus().toggleNode("codeBlock","paragraph").run()}},mention:{check:t=>_(t,["mention","mentionAdvanced"]),action:({editor:t})=>_s(t)},emoji:{check:t=>_(t,["emoji","emojiPicker"]),action:({editor:t})=>Ws(t)},divider:{check:t=>te("horizontalRule",t),action:({editor:t})=>{t.chain().focus().setHorizontalRule().run()}},toc:{check:t=>te("tocNode",t),action:({editor:t})=>{t.chain().focus().insertTocNode().run()}},table:{check:t=>te("table",t),action:({editor:t})=>{t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}},image:{check:t=>te("image",t),action:({editor:t})=>{t.chain().focus().insertContent({type:"imageUpload"}).run()}}});function f7(e,t){if(!t)return e.map(r=>({...r,group:""}));const n={};e.forEach(r=>{const s=r.group||"";n[s]||(n[s]=[]),n[s].push(r)});const o=[];return Object.entries(n).forEach(([,r])=>{o.push(...r)}),o}function p7(e){const t=D();return{getSlashMenuItems:u.useCallback(o=>{const r=[],s=c7(t),i=d7(e?.enabledItems||Object.keys(s),e),a=e?.showGroups!==!1,c=u7(e);return i.forEach(d=>{const p=c[d],f=s[d];if(p&&f&&p.check(o)){const h={onSelect:({editor:C})=>p.action({editor:C}),...f};e?.itemGroups?.[d]?h.group=e.itemGroups[d]:a||(h.group=""),r.push(h)}}),e?.customItems&&r.push(...e.customItems),f7(r,a)},[e,t]),config:e}}const h7=e=>{const{config:t,...n}=e,{getSlashMenuItems:o}=p7(t);return l.jsx(bo,{char:"/",pluginKey:"slashDropdownMenu",decorationClass:"tiptap-slash-decoration",decorationContent:"Filter...",selector:"tiptap-slash-dropdown-menu",items:({query:r,editor:s})=>Au(o(s),r),...n,children:r=>l.jsx(C7,{...r,config:t})})},Zs=e=>{const{item:t,isSelected:n,onSelect:o}=e,r=u.useRef(null);u.useEffect(()=>{const a=document.querySelector('[data-selector="tiptap-slash-dropdown-menu"]')?.querySelector(".tiptap-slash-card-body");if(!r.current||!n||!a)return;const c=r.current.previousElementSibling,d=c instanceof HTMLElement&&c.classList.contains("tiptap-card-group-label")?c.getBoundingClientRect().top:r.current.getBoundingClientRect().top,p=r.current.getBoundingClientRect(),f=a.getBoundingClientRect();d<f.top?a.scrollTop-=f.top-d:p.bottom>f.bottom&&(a.scrollTop+=p.bottom-f.bottom)},[n]);const s=t.badge;return l.jsxs(M,{ref:r,variant:"ghost","data-active-state":n?"on":"off",onClick:o,children:[s&&l.jsx(s,{className:"tiptap-button-icon"}),l.jsx("div",{className:"tiptap-button-text",children:t.title})]})},C7=({items:e,selectedIndex:t,onSelect:n,config:o})=>{const r=u.useMemo(()=>{const s=[];if(!(o?.showGroups!==!1))return e.forEach((c,d)=>{s.push(l.jsx(Zs,{item:c,isSelected:d===t,onSelect:()=>n(c)},`item-${d}-${c.title}`))}),s;const a={};return e.forEach((c,d)=>{const p=c.group||"";a[p]||(a[p]={items:[],indices:[]}),a[p].items.push(c),a[p].indices.push(d)}),Object.entries(a).forEach(([c,d],p)=>{p>0&&s.push(l.jsx(ee,{orientation:"horizontal"},`separator-${p}`));const f=d.items.map((h,C)=>{const g=d.indices[C];return l.jsx(Zs,{item:h,isSelected:g===t,onSelect:()=>n(h)},`item-${g}-${h.title}`)});c?s.push(l.jsxs(Me,{children:[l.jsx(bt,{children:c}),f]},`group-${p}-${c}`)):s.push(...f)}),s},[e,t,n,o?.showGroups]);return r.length?l.jsx(Ze,{className:"tiptap-slash-card",style:{maxHeight:"var(--suggestion-menu-max-height)"},children:l.jsx(Fe,{className:"tiptap-slash-card-body",children:r})}):null},Kt=u.forwardRef(({editor:e,shouldShow:t=void 0,floatingOptions:n,zIndex:o=50,onOpenChange:r,referenceElement:s,getBoundingClientRect:i=Eu,closeOnEscape:a=!0,resetTextSelectionOnClose:c=!0,children:d,style:p,...f},h)=>{const[C,g]=u.useState(t!==void 0?t:!1),b=u.useRef(null),m=u.useRef(!1),w=u.useRef(!1),v=u.useRef(null),y=u.useRef(i),{editor:x}=k(e);u.useEffect(()=>{v.current=x,y.current=i},[x,i]);const S=u.useCallback(U=>{r?.(U),g(U)},[r]),L=U=>{if(!U&&x&&c){const H=x.state.tr.setSelection(E.Selection.near(x.state.doc.resolve(0)));x.view.dispatch(H)}S(U)},I=u.useMemo(()=>s||(()=>v.current?y.current(v.current):null),[s]),{isMounted:V,ref:K,style:se,getFloatingProps:O}=xs(C,I,o,{placement:"top",middleware:[z.shift(),z.flip(),z.offset(4)],onOpenChange:L,dismissOptions:{enabled:!0,escapeKey:!0,outsidePress(U){const H=U.target;return!H||zs(H)?!1:!Fs(x,H)}},...n}),Y=u.useCallback(()=>{if(!x)return;const U=i(x);if(U&&t!==void 0&&!w.current){S(t);return}const H=Ts(x);U&&!w.current&&(H||m.current)?S(!0):!m.current&&(!H||w.current||!x.isEditable)&&S(!1)},[x,i,S,t]);u.useEffect(()=>{if(!x||!a)return;const U=H=>H.key==="Escape"&&C?(S(!1),!0):!1;return x.view.dom.addEventListener("keydown",U),()=>{x.view.dom.removeEventListener("keydown",U)}},[x,C,a,S]),u.useEffect(()=>{if(!x)return;const U=H=>{if(m.current){m.current=!1;return}const W=H.relatedTarget;if(!W)return;const P=Fs(x,W),q=b.current,Z=q&&(q===W||q.contains(W)),le=zs(W);!P&&!Z&&!le&&C&&S(!1)};return x.view.dom.addEventListener("blur",U),()=>{x.view.dom.removeEventListener("blur",U)}},[x,S,C]),u.useEffect(()=>{if(!x)return;const U=()=>{C&&S(!1)};return x.view.dom.addEventListener("dragstart",U),x.view.dom.addEventListener("dragover",U),()=>{x.view.dom.removeEventListener("dragstart",U),x.view.dom.removeEventListener("dragover",U)}},[x,C,S]),u.useEffect(()=>{if(!x)return;const U=W=>{if(W.button!==0||(w.current=!0,W.detail>1))return;const{state:P,view:q}=x,Z=q.posAtCoords({left:W.clientX,top:W.clientY});if(!Z||!X(Z.pos))return;const be=P.doc.resolve(Z.pos).nodeBefore;if(!be||be.isBlock)return;const ot=P.tr.setSelection(E.Selection.near(P.doc.resolve(Z.pos)));q.dispatch(ot)},H=()=>{w.current&&(w.current=!1,Y())};return x.view.dom.addEventListener("mousedown",U),x.view.root.addEventListener("mouseup",H),()=>{x.view.dom.removeEventListener("mousedown",U),x.view.root.removeEventListener("mouseup",H)}},[x,Y]),u.useEffect(()=>{if(x)return x.on("selectionUpdate",Y),()=>{x.off("selectionUpdate",Y)}},[x,Y]),u.useEffect(()=>{x&&Y()},[x,Y]);const A=u.useMemo(()=>p&&Object.keys(p).length>0?p:se,[p,se]),N=z.useMergeRefs([K,h,b]);return!x||!V||!C?null:l.jsx("div",{ref:N,style:A,...f,...O(),children:d})});Kt.displayName="FloatingElement";const Fs=(e,t)=>{if(!t||!e)return!1;const n=e.view.dom.parentElement,o=e.view.dom;return n?n===t||o===t||n.contains(t):!1},zs=e=>e instanceof HTMLElement?e.closest(["[data-radix-popper-content-wrapper]","[data-base-ui-portal]"].join(","))!==null:!1,$s=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M10.5 1C9.43913 1 8.42172 1.42143 7.67157 2.17157C6.92143 2.92172 6.5 3.93913 6.5 5V12C6.5 13.0609 6.92143 14.0783 7.67157 14.8284C8.42172 15.5786 9.43913 16 10.5 16C11.5609 16 12.5783 15.5786 13.3284 14.8284C14.0786 14.0783 14.5 13.0609 14.5 12C14.5 11.4477 14.0523 11 13.5 11C12.9477 11 12.5 11.4477 12.5 12C12.5 12.5304 12.2893 13.0391 11.9142 13.4142C11.5391 13.7893 11.0304 14 10.5 14C9.96957 14 9.46086 13.7893 9.08579 13.4142C8.71071 13.0391 8.5 12.5304 8.5 12V5C8.5 4.46957 8.71071 3.96086 9.08579 3.58579C9.46086 3.21071 9.96957 3 10.5 3C11.0523 3 11.5 2.55228 11.5 2C11.5 1.44772 11.0523 1 10.5 1Z",fill:"currentColor"}),l.jsx("path",{d:"M4.5 10C4.5 9.44771 4.05228 9 3.5 9C2.94772 9 2.5 9.44771 2.5 10V12C2.5 13.7611 3.0811 15.4729 4.15318 16.8701C5.22525 18.2672 6.72838 19.2716 8.42945 19.7274C8.7827 19.8221 9.14038 19.892 9.5 19.9373V22C9.5 22.5523 9.94772 23 10.5 23C11.0523 23 11.5 22.5523 11.5 22V19.9373C12.2039 19.8486 12.8974 19.6661 13.5615 19.391C15.1885 18.7171 16.5477 17.5251 17.4282 16C17.7043 15.5217 17.5405 14.9101 17.0622 14.634C16.5839 14.3578 15.9723 14.5217 15.6962 15C15.0358 16.1438 14.0164 17.0378 12.7961 17.5433C11.5758 18.0487 10.2229 18.1374 8.94709 17.7956C7.67129 17.4537 6.54394 16.7004 5.73988 15.6526C4.93583 14.6047 4.5 13.3208 4.5 12L4.5 11.9977V10Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.4492 1.68544C17.3136 1.27624 16.9311 1 16.5 1C16.0689 1 15.6864 1.27624 15.5508 1.68544L14.8711 3.73642C14.7717 4.03638 14.5364 4.2717 14.2364 4.3711L12.1854 5.05076C11.7762 5.18636 11.5 5.56892 11.5 6C11.5 6.43108 11.7762 6.81364 12.1854 6.94924L14.2364 7.6289C14.5364 7.7283 14.7717 7.96362 14.8711 8.26358L15.5508 10.3146C15.6864 10.7238 16.0689 11 16.5 11C16.9311 11 17.3136 10.7238 17.4492 10.3146L18.1289 8.26358C18.2283 7.96362 18.4636 7.7283 18.7636 7.6289L20.8146 6.94924C21.2238 6.81364 21.5 6.43108 21.5 6C21.5 5.56892 21.2238 5.18636 20.8146 5.05076L18.7636 4.3711C18.4636 4.2717 18.2283 4.03638 18.1289 3.73642L17.4492 1.68544ZM15.4559 6C15.8854 5.74447 16.2445 5.38537 16.5 4.95595C16.7555 5.38537 17.1146 5.74447 17.5441 6C17.1146 6.25554 16.7555 6.61463 16.5 7.04405C16.2445 6.61463 15.8854 6.25554 15.4559 6Z",fill:"currentColor"})]}));$s.displayName="MicAiIcon";const Po=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M18.7071 6.70711C19.0976 6.31658 19.0976 5.68342 18.7071 5.29289C18.3166 4.90237 17.6834 4.90237 17.2929 5.29289L12 10.5858L6.70711 5.29289C6.31658 4.90237 5.68342 4.90237 5.29289 5.29289C4.90237 5.68342 4.90237 6.31658 5.29289 6.70711L10.5858 12L5.29289 17.2929C4.90237 17.6834 4.90237 18.3166 5.29289 18.7071C5.68342 19.0976 6.31658 19.0976 6.70711 18.7071L12 13.4142L17.2929 18.7071C17.6834 19.0976 18.3166 19.0976 18.7071 18.7071C19.0976 18.3166 19.0976 17.6834 18.7071 17.2929L13.4142 12L18.7071 6.70711Z",fill:"currentColor"})}));Po.displayName="XIcon";function g7(e){return e.trim()}function b7({action:e,editor:t,open:n,onOpenChange:o,onSubmit:r,signal:s}){const i=D(),a=u.useRef(null),[c,d]=u.useState("");u.useEffect(()=>{if(!n){d("");return}window.requestAnimationFrame(()=>{a.current?.focus()})},[n]);const p=e==="continue_writing"?i.continueWritingPrompt:i.askAiPrompt,f=g7(c),h=async()=>{!e||!f||(r&&await r({action:e,editor:t,prompt:f,signal:s}),o(!1))};return l.jsx(Kt,{editor:t,shouldShow:n,onOpenChange:o,closeOnEscape:!0,resetTextSelectionOnClose:!1,zIndex:1001,floatingOptions:{placement:"bottom-start"},className:"tiptap-ai-composer",role:"dialog","aria-label":i.ai,children:l.jsxs("div",{className:"tiptap-ai-composer__body",children:[l.jsx("textarea",{ref:a,className:"tiptap-ai-composer__textarea",placeholder:p,value:c,rows:1,onChange:C=>d(C.target.value),onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),o(!1)),C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),h())}}),l.jsxs("div",{className:"tiptap-ai-composer__footer",children:[l.jsxs("button",{type:"button",className:"tiptap-ai-composer__tone","aria-label":i.aiTone,children:[l.jsx($s,{className:"tiptap-ai-composer__icon"}),l.jsx("span",{children:i.aiTone})]}),l.jsxs("div",{className:"tiptap-ai-composer__actions",children:[l.jsx("button",{type:"button",className:"tiptap-ai-composer__icon-button","aria-label":i.close,onClick:()=>o(!1),children:l.jsx(Po,{className:"tiptap-ai-composer__icon"})}),l.jsx("button",{type:"button",className:"tiptap-ai-composer__submit","aria-label":i.submitAiPrompt,disabled:!f,onClick:()=>{h()},children:l.jsx(Un,{className:"tiptap-ai-composer__icon"})})]})]})]})})}const m7=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 2C7.43108 2 7.81364 2.27624 7.94924 2.68544L8.6289 4.73642C8.7283 5.03638 8.96362 5.2717 9.26358 5.3711L11.3146 6.05076C11.7238 6.18636 12 6.56892 12 7C12 7.43108 11.7238 7.81364 11.3146 7.94924L9.26358 8.6289C8.96362 8.7283 8.7283 8.96362 8.6289 9.26358L7.94924 11.3146C7.81364 11.7238 7.43108 12 7 12C6.56892 12 6.18636 11.7238 6.05076 11.3146L5.3711 9.26358C5.2717 8.96362 5.03638 8.7283 4.73642 8.6289L2.68544 7.94924C2.27624 7.81364 2 7.43108 2 7C2 6.56892 2.27624 6.18636 2.68544 6.05076L4.73642 5.3711C5.03638 5.2717 5.2717 5.03638 5.3711 4.73642L6.05076 2.68544C6.18636 2.27624 6.56892 2 7 2ZM7 5.95595C6.74447 6.38537 6.38537 6.74447 5.95595 7C6.38537 7.25554 6.74447 7.61463 7 8.04405C7.25554 7.61463 7.61463 7.25554 8.04405 7C7.61463 6.74447 7.25554 6.38537 7 5.95595Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.7071 8.29289C22.0976 8.68342 22.0976 9.31658 21.7071 9.70711L10.7071 20.7071C10.3166 21.0976 9.68342 21.0976 9.29289 20.7071L4.29289 15.7071C3.90237 15.3166 3.90237 14.6834 4.29289 14.2929C4.68342 13.9024 5.31658 13.9024 5.70711 14.2929L10 18.5858L20.2929 8.29289C20.6834 7.90237 21.3166 7.90237 21.7071 8.29289Z",fill:"currentColor"})]}));m7.displayName="CheckAiIcon";const w7=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M11.9949 2.00001C9.22128 2.01079 6.55914 3.0932 4.56496 5.02103L4.55289 5.03289L4 5.58579V3C4 2.44771 3.55228 2 3 2C2.44771 2 2 2.44771 2 3V7.99931L2 8.003C2.0004 8.1375 2.02735 8.26575 2.07588 8.38278C2.12357 8.49805 2.19374 8.6062 2.2864 8.70055L2.29945 8.7136C2.3938 8.80626 2.50195 8.87643 2.61722 8.92412C2.73512 8.97301 2.86441 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41421L5.96097 6.45325C7.58334 4.8878 9.74744 4.00891 12.0021 4C13.7624 4.00045 15.4735 4.58152 16.8701 5.65317C18.2673 6.72525 19.2716 8.22838 19.7274 9.92945C19.8704 10.4629 20.4187 10.7795 20.9522 10.6366C21.4856 10.4936 21.8022 9.94528 21.6593 9.41181C21.0895 7.28548 19.8341 5.40656 18.0876 4.06647C16.3412 2.72637 14.2014 2 12 2L11.9962 2.00001L11.9949 2.00001Z",fill:"currentColor"}),l.jsx("path",{d:"M10.6366 20.9522C10.4936 21.4856 9.9453 21.8022 9.41183 21.6593C7.2855 21.0895 5.40658 19.8341 4.06649 18.0876C2.72639 16.3412 2.00002 14.2013 2.00002 12C2.00002 11.4477 2.44774 11 3.00002 11C3.55231 11 4.00002 11.4477 4.00002 12C4.00002 13.7611 4.58112 15.4729 5.65319 16.8701C6.72527 18.2672 8.2284 19.2716 9.92947 19.7274C10.4629 19.8703 10.7795 20.4187 10.6366 20.9522Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.9379 11.653C17.7926 11.2605 17.4184 11 17 11C16.5816 11 16.2074 11.2605 16.0621 11.653L14.9511 14.6556C14.9004 14.7925 14.7925 14.9004 14.6556 14.9511L11.653 16.0621C11.2605 16.2074 11 16.5816 11 17C11 17.4184 11.2605 17.7926 11.653 17.9379L14.6556 19.0489C14.7925 19.0996 14.9004 19.2075 14.9511 19.3444L16.0621 22.347C16.2074 22.7395 16.5816 23 17 23C17.4184 23 17.7926 22.7395 17.9379 22.347L19.0489 19.3444C19.0996 19.2075 19.2075 19.0996 19.3444 19.0489L22.347 17.9379C22.7395 17.7926 23 17.4184 23 17C23 16.5816 22.7395 16.2074 22.347 16.0621L19.3444 14.9511C19.2075 14.9004 19.0996 14.7925 19.0489 14.6556L17.9379 11.653ZM16.8268 15.3497L17 14.8815L17.1732 15.3497C17.4265 16.034 17.966 16.5735 18.6503 16.8268L19.1185 17L18.6503 17.1732C17.966 17.4265 17.4265 17.966 17.1732 18.6503L17 19.1185L16.8268 18.6503C16.5735 17.966 16.034 17.4265 15.3497 17.1732L14.8815 17L15.3497 16.8268C16.034 16.5735 16.5735 16.034 16.8268 15.3497Z",fill:"currentColor"})]}));w7.displayName="RefreshAiIcon";const v7=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12ZM8 9C8 8.44772 8.44772 8 9 8H15C15.5523 8 16 8.44772 16 9V15C16 15.5523 15.5523 16 15 16H9C8.44772 16 8 15.5523 8 15V9Z",fill:"currentColor"})}));v7.displayName="StopCircle2Icon";const y7={amp:"&",gt:">",lt:"<",nbsp:" ",quot:'"'};function qs(e){const t=k7(e);if(!t.length)return null;const n=T7(t);return{type:"table",content:t.map((r,s)=>({type:"tableRow",content:r.map(i=>A7(i,s<n))}))}}function Gs(e){return!!(e.type==="table"&&Ks(e)||e.content?.some(t=>Gs(t)))}function Ks(e){return e.type!=="table"?!1:!!e.content?.some(t=>t.content?.some(n=>{const o=Number(n.attrs?.colspan??1),r=Number(n.attrs?.rowspan??1);return o>1||r>1}))}function x7(e,t){return`<table>${(e.content||[]).filter(o=>o.type==="tableRow").map(o=>`<tr>${(o.content||[]).filter(s=>s.type==="tableCell"||s.type==="tableHeader").map(s=>E7(s,t)).join("")}</tr>`).join("")}</table>`}function k7(e){return Array.from(e.matchAll(/<tr\b[^>]*>([\s\S]*?)<\/tr>/gi)).map(t=>S7(t[1])).filter(t=>t.length>0)}function S7(e){return Array.from(e.matchAll(/<(t[dh])\b([^>]*)>([\s\S]*?)<\/\1>/gi)).map(t=>({tagName:t[1].toLowerCase(),text:I7(t[3]),colspan:Ys(t[2],"colspan"),rowspan:Ys(t[2],"rowspan")}))}function T7(e){const t=e.findIndex(r=>r.some(s=>s.tagName!=="th"));if(t>0)return t;const[n]=e,o=n?.reduce((r,s)=>Math.max(r,s.rowspan),1)||1;return Math.min(o,e.length)}function A7(e,t){const n=e.text?[{type:"text",text:e.text}]:void 0;return{type:e.tagName==="th"||t?"tableHeader":"tableCell",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:e.colspan,rowspan:e.rowspan,colwidth:null},content:[{type:"paragraph",content:n}]}}function Ys(e,t){const n=e.match(new RegExp(`${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'>/]+))`,"i")),o=n?.[1]??n?.[2]??n?.[3],r=Number.parseInt(o||"1",10);return Number.isFinite(r)&&r>0?r:1}function I7(e){return L7(e.replace(/<br\s*\/?>/gi,`
|
|
4
|
+
`).replace(/\\t/g," ").replace(/\\(["'`{}\[\](),:])/g,"$1").trim()}function dc(e){const t=el(e);try{return JSON.parse(t)}catch{return Function(`"use strict";return (${t})`)()}}function Lt(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function tl(e){return Object.hasOwn(e,"top")||Object.hasOwn(e,"bottom")}function uc(e){return Object.hasOwn(e,"left")||Object.hasOwn(e,"right")}function Ge(e){return Array.isArray(e)?e.length>0:!!e}function nl(e,t,n=!1){const o=r=>{const s={...r};return tl(s)||(s.top=t),n&&!uc(s)&&(s.left="center"),s};return Array.isArray(e)?e.map(r=>Lt(r)?o(r):r):Lt(e)?o(e):e}function fc(e){return Ge(e.xAxis)||Ge(e.yAxis)}function pc(e){const t=Ge(e.title),n=Ge(e.legend);return t&&n?120:t||n?80:null}function hc(e,t){const n=o=>tl(o)?o:{...o,top:t};return Array.isArray(e)?e.map(o=>Lt(o)?n(o):o):Lt(e)?n(e):{top:t}}function Cc(e){const t={...e},n=Ge(e.title),o=Ge(e.legend);n&&(t.title=nl(e.title,16,!0)),o&&(t.legend=nl(e.legend,n?64:24,!0));const r=pc(e);return r!==null&&fc(e)&&(t.grid=hc(e.grid,r)),t}function gc(e,t){return typeof e!="string"||!e.trim()?t.code:e.trim()}function bc({code:e,i18n:t}){const n=u.useRef(null),[o,r]=u.useState(null);return u.useEffect(()=>{const s=n.current;if(!s)return;let i=null,a=null;try{const c=dc(e);i=N1.init(s),i.setOption(Cc(c)),r(null),a=new ResizeObserver(()=>i?.resize()),a.observe(s)}catch(c){r(c instanceof Error?c.message:t.failedToRenderChart)}return()=>{a?.disconnect(),i?.dispose()}},[e,t.failedToRenderChart]),l.jsxs("div",{className:"code-block-node__diagram-body",contentEditable:!1,children:[l.jsx("div",{className:"code-block-node__echarts",ref:n}),o?l.jsx("div",{className:"code-block-node__diagram-error",children:o}):null]})}function mc({code:e,i18n:t,language:n}){const o=Rr(n);return o==="echarts"?l.jsx(bc,{code:e,i18n:t}):o==="mermaid"?l.jsx(wc,{code:e,i18n:t}):null}function wc({code:e,i18n:t}){const n=u.useId(),[o,r]=u.useState(""),[s,i]=u.useState(null);return u.useEffect(()=>{let a=!1;async function c(){try{const d=await k1.render(`code-block-diagram-${n.replace(/:/g,"")}`,el(e));a||(r(d.svg),i(null))}catch(d){a||(r(""),i(d instanceof Error?d.message:t.failedToRenderDiagram))}}return c(),()=>{a=!0}},[e,t.failedToRenderDiagram,n]),l.jsxs("div",{className:"code-block-node__diagram-body",contentEditable:!1,children:[o?l.jsx("div",{className:"code-block-node__mermaid",dangerouslySetInnerHTML:{__html:o}}):null,s?l.jsx("div",{className:"code-block-node__diagram-error",children:s}):null]})}function vc(e){const t=e.extension.options.i18n??Ie(),n=gc(e.node.attrs.language,t),r=!!Rr(n),[s,i]=u.useState(r),a=e.node.textContent,c=r&&e.editor.isEditable;return u.useEffect(()=>{i(r)},[r,n]),l.jsxs(G.NodeViewWrapper,{className:"code-block-node","data-collapsed":s?"true":"false","data-diagram":r?"true":"false","data-language":n,children:[l.jsxs("div",{className:"code-block-node__header",contentEditable:!1,children:[l.jsx("span",{className:"code-block-node__language",children:n}),c?l.jsx("button",{type:"button",className:"code-block-node__toggle","aria-expanded":!s,onClick:()=>i(d=>!d),children:s?t.showSource:t.hideSource}):null]}),r?l.jsx(mc,{code:a,i18n:t,language:n}):null,l.jsx("pre",{className:"code-block-node__pre",children:l.jsx(G.NodeViewContent,{className:"code-block-node__content"})})]})}const yc=y1.CodeBlock.extend({addOptions(){return{...this.parent?.(),i18n:Ie()}},addNodeView(){return G.ReactNodeViewRenderer(vc)}}),dt=new E.PluginKey("aiGenerationWidget");function xc(e,t,n){return t?.type==="clear"?{pos:null,status:"idle"}:t?.type==="set"?{pos:t.pos,status:t.status}:e.pos===null?e:{...e,pos:n(e.pos)}}const kc=we.Extension.create({name:"aiGenerationWidget",addStorage(){return{labels:void 0,onApply:void 0,onDiscard:void 0,onRetry:void 0,onStop:void 0,onSubmitInstruction:void 0}},addCommands(){return{clearAiGenerationWidget:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(dt,{type:"clear"}),!0),setAiGenerationWidget:e=>({tr:t,dispatch:n})=>(n&&t.setMeta(dt,{type:"set",...e}),!0)}},addProseMirrorPlugins(){const e=this.editor;return[new E.Plugin({key:dt,state:{init(){return{pos:null,status:"idle"}},apply(t,n){const o=t.getMeta(dt);return xc(n,o,r=>t.mapping.map(r))}},props:{decorations(t){const n=dt.getState(t);if(!n||n.pos===null)return Te.DecorationSet.empty;const o=Math.min(n.pos,t.doc.content.size);return Te.DecorationSet.create(t.doc,[Te.Decoration.widget(o,()=>Sc(e.storage.aiGenerationWidget,n.status),{key:`ai-generation-widget-${n.status}`,side:1})])}}})]}});function Sc(e,t){return t==="writing"?Tc(e):Ac(e)}function Tc(e){const t=document.createElement("span"),n=e.labels;t.className="tiptap-ai-widget tiptap-ai-writing-indicator",t.contentEditable="false",t.setAttribute("role","status"),t.setAttribute("aria-live","polite");const o=document.createElement("span");o.className="tiptap-ai-writing-indicator__content";const r=document.createElement("span");r.className="tiptap-ai-writing-indicator__label",r.textContent=n?.aiIsWriting??"AI is writing";const s=document.createElement("span");s.className="tiptap-ai-writing-indicator__dots",s.setAttribute("aria-hidden","true"),s.append(document.createElement("span")),s.append(document.createElement("span")),s.append(document.createElement("span")),o.append(r,s);const i=document.createElement("button");return i.type="button",i.className="tiptap-ai-writing-indicator__stop",i.setAttribute("aria-label",n?.stopAiGeneration??"Stop AI generation"),i.textContent="■",i.addEventListener("click",a=>{a.preventDefault(),e.onStop?.()}),t.append(o,i),t}function Ac(e){const t=document.createElement("span"),n=e.labels;t.className="tiptap-ai-widget tiptap-ai-review",t.contentEditable="false",t.setAttribute("role","dialog"),t.setAttribute("aria-label","AI");const o=document.createElement("span");o.className="tiptap-ai-review__prompt-row";const r=document.createElement("textarea");r.className="tiptap-ai-review__textarea",r.rows=1,r.placeholder=n?.aiReviewPrompt??"Tell AI what else needs to be changed...";const s=document.createElement("button");s.type="button",s.className="tiptap-ai-review__submit",s.setAttribute("aria-label",n?.submitAiPrompt??"Submit AI prompt"),s.textContent="↑",o.append(r,s);const i=document.createElement("span");i.className="tiptap-ai-review__actions";const a=ol("retry",`↻ ${n?.tryAgain??"Try again"}`),c=document.createElement("span");c.className="tiptap-ai-review__spacer";const d=ol("discard",`× ${n?.discard??"Discard"}`),f=document.createElement("button");f.type="button",f.className="tiptap-ai-review__apply",f.dataset.action="apply",f.textContent=`✓ ${n?.apply??"Apply"}`,i.append(a,c,d,f),t.append(o,i);const p=()=>{const h=r?.value.trim();h&&(e.onSubmitInstruction?.(h),r&&(r.value=""))};return r?.addEventListener("keydown",h=>{h.key!=="Enter"||h.shiftKey||(h.preventDefault(),p())}),s.addEventListener("click",h=>{h.preventDefault(),p()}),a.addEventListener("click",h=>{h.preventDefault(),e.onRetry?.()}),d.addEventListener("click",h=>{h.preventDefault(),e.onDiscard?.()}),f.addEventListener("click",h=>{h.preventDefault(),e.onApply?.()}),t}function ol(e,t){const n=document.createElement("button");return n.type="button",n.className="tiptap-ai-review__action",n.dataset.action=e,n.textContent=t,n}function Ic({initialOpen:e=!1,placement:t="top",open:n,onOpenChange:o,delay:r=600,closeDelay:s=0}={}){const[i,a]=u.useState(e),c=n??i,d=o??a,f=F.useFloating({placement:t,open:c,onOpenChange:d,whileElementsMounted:F.autoUpdate,middleware:[F.offset(4),F.flip({crossAxis:t.includes("-"),fallbackAxisSideDirection:"start",padding:4}),F.shift({padding:4})]}),p=f.context,h=F.useHover(p,{mouseOnly:!0,move:!1,restMs:r,enabled:n==null,delay:{close:s}}),C=F.useFocus(p,{enabled:n==null}),g=F.useDismiss(p),b=F.useRole(p,{role:"tooltip"}),m=F.useInteractions([h,C,g,b]);return u.useMemo(()=>({open:c,setOpen:d,...m,...f}),[c,d,m,f])}const Tn=u.createContext(null);function rl(){const e=u.useContext(Tn);if(e==null)throw new Error("Tooltip components must be wrapped in <TooltipProvider />");return e}function ll({children:e,...t}){const n=Ic(t);return t.useDelayGroup?l.jsx(F.FloatingDelayGroup,{delay:{open:t.delay??0,close:t.closeDelay??0},timeoutMs:t.timeout,children:l.jsx(Tn.Provider,{value:n,children:e})}):l.jsx(Tn.Provider,{value:n,children:e})}const sl=u.forwardRef(function({children:t,asChild:n=!1,...o},r){const s=rl(),i=u.isValidElement(t)?parseInt(u.version,10)>=19?t.props.ref:t.ref:void 0,a=F.useMergeRefs([s.refs.setReference,r,i]);if(n&&u.isValidElement(t)){const c={"data-tooltip-state":s.open?"open":"closed"};return u.cloneElement(t,s.getReferenceProps({ref:a,...o,...typeof t.props=="object"?t.props:{},...c}))}return l.jsx("button",{ref:a,"data-tooltip-state":s.open?"open":"closed",...s.getReferenceProps(o),children:t})}),il=u.forwardRef(function({style:t,children:n,portal:o=!0,portalProps:r={},...s},i){const a=rl(),c=F.useMergeRefs([a.refs.setFloating,i]);if(!a.open)return null;const d=l.jsx("div",{ref:c,style:{...a.floatingStyles,...t},...a.getFloatingProps(s),className:"tiptap-tooltip",children:n});return o?l.jsx(F.FloatingPortal,{...r,children:d}):d});ll.displayName="Tooltip",sl.displayName="TooltipTrigger",il.displayName="TooltipContent";const Lc=({shortcuts:e})=>e.length===0?null:l.jsx("div",{children:e.map((t,n)=>l.jsxs(u.Fragment,{children:[n>0&&l.jsx("kbd",{children:"+"}),l.jsx("kbd",{children:t})]},n))}),M=u.forwardRef(({className:e,children:t,tooltip:n,showTooltip:o=!0,shortcutKeys:r,variant:s,size:i,...a},c)=>{const d=u.useMemo(()=>J({shortcutKeys:r}),[r]);return!n||!o?l.jsx("button",{"data-slot":"tiptap-button",className:z("tiptap-button",e),ref:c,"data-style":s,"data-size":i,...a,children:t}):l.jsxs(ll,{delay:200,children:[l.jsx(sl,{"data-slot":"tiptap-button",className:z("tiptap-button",e),ref:c,"data-style":s,"data-size":i,...a,children:t}),l.jsxs(il,{children:[n,l.jsx(Lc,{shortcuts:d})]})]})});M.displayName="Button";const al=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M18.7071 6.70711C19.0976 6.31658 19.0976 5.68342 18.7071 5.29289C18.3166 4.90237 17.6834 4.90237 17.2929 5.29289L12 10.5858L6.70711 5.29289C6.31658 4.90237 5.68342 4.90237 5.29289 5.29289C4.90237 5.68342 4.90237 6.31658 5.29289 6.70711L10.5858 12L5.29289 17.2929C4.90237 17.6834 4.90237 18.3166 5.29289 18.7071C5.68342 19.0976 6.31658 19.0976 6.70711 18.7071L12 13.4142L17.2929 18.7071C17.6834 19.0976 18.3166 19.0976 18.7071 18.7071C19.0976 18.3166 19.0976 17.6834 18.7071 17.2929L13.4142 12L18.7071 6.70711Z",fill:"currentColor"})}));al.displayName="CloseIcon";function Ec(e){const[t,n]=u.useState([]),o=async a=>{if(a.size>e.maxSize){const p=new Error(`File size exceeds maximum allowed (${e.maxSize/1024/1024}MB)`);return e.onError?.(p),null}const c=new AbortController,d=crypto.randomUUID(),f={id:d,file:a,progress:0,status:"uploading",abortController:c};n(p=>[...p,f]);try{if(!e.upload)throw new Error("Upload function is not defined");const p=await e.upload(a,h=>{n(C=>C.map(g=>g.id===d?{...g,progress:h.progress}:g))},c.signal);if(!p)throw new Error("Upload failed: No URL returned");return c.signal.aborted?null:(n(h=>h.map(C=>C.id===d?{...C,status:"success",url:p,progress:100}:C)),e.onSuccess?.(p),p)}catch(p){return c.signal.aborted||(n(h=>h.map(C=>C.id===d?{...C,status:"error",progress:0}:C)),e.onError?.(p instanceof Error?p:new Error("Upload failed"))),null}};return{fileItems:t,uploadFiles:async a=>{if(!a||a.length===0)return e.onError?.(new Error("No files to upload")),[];if(e.limit&&a.length>e.limit)return e.onError?.(new Error(`Maximum ${e.limit} file${e.limit===1?"":"s"} allowed`)),[];const c=a.map(f=>o(f));return(await Promise.all(c)).filter(f=>f!==null)},removeFileItem:a=>{n(c=>{const d=c.find(f=>f.id===a);return d?.abortController&&d.abortController.abort(),d?.url&&URL.revokeObjectURL(d.url),c.filter(f=>f.id!==a)})},clearAllFiles:()=>{t.forEach(a=>{a.abortController&&a.abortController.abort(),a.url&&URL.revokeObjectURL(a.url)}),n([])}}}const cl=()=>l.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"tiptap-image-upload-icon",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M11.1953 4.41771C10.3478 4.08499 9.43578 3.94949 8.5282 4.02147C7.62062 4.09345 6.74133 4.37102 5.95691 4.83316C5.1725 5.2953 4.50354 5.92989 4.00071 6.68886C3.49788 7.44783 3.17436 8.31128 3.05465 9.2138C2.93495 10.1163 3.0222 11.0343 3.3098 11.8981C3.5974 12.7619 4.07781 13.5489 4.71463 14.1995C5.10094 14.5942 5.09414 15.2274 4.69945 15.6137C4.30476 16 3.67163 15.9932 3.28532 15.5985C2.43622 14.731 1.79568 13.6816 1.41221 12.5299C1.02875 11.3781 0.91241 10.1542 1.07201 8.95084C1.23162 7.74748 1.66298 6.59621 2.33343 5.58425C3.00387 4.57229 3.89581 3.72617 4.9417 3.10998C5.98758 2.4938 7.15998 2.1237 8.37008 2.02773C9.58018 1.93176 10.7963 2.11243 11.9262 2.55605C13.0561 2.99968 14.0703 3.69462 14.8919 4.58825C15.5423 5.29573 16.0585 6.11304 16.4177 7.00002H17.4999C18.6799 6.99991 19.8288 7.37933 20.7766 8.08222C21.7245 8.78515 22.4212 9.7743 22.7637 10.9036C23.1062 12.0328 23.0765 13.2423 22.6788 14.3534C22.2812 15.4644 21.5367 16.4181 20.5554 17.0736C20.0962 17.3803 19.4752 17.2567 19.1684 16.7975C18.8617 16.3382 18.9853 15.7172 19.4445 15.4105C20.069 14.9934 20.5427 14.3865 20.7958 13.6794C21.0488 12.9724 21.0678 12.2027 20.8498 11.4841C20.6318 10.7655 20.1885 10.136 19.5853 9.6887C18.9821 9.24138 18.251 8.99993 17.5001 9.00002H15.71C15.2679 9.00002 14.8783 8.70973 14.7518 8.28611C14.4913 7.41374 14.0357 6.61208 13.4195 5.94186C12.8034 5.27164 12.0427 4.75043 11.1953 4.41771Z",fill:"currentColor"}),l.jsx("path",{d:"M11 14.4142V21C11 21.5523 11.4477 22 12 22C12.5523 22 13 21.5523 13 21V14.4142L15.2929 16.7071C15.6834 17.0976 16.3166 17.0976 16.7071 16.7071C17.0976 16.3166 17.0976 15.6834 16.7071 15.2929L12.7078 11.2936C12.7054 11.2912 12.703 11.2888 12.7005 11.2864C12.5208 11.1099 12.2746 11.0008 12.003 11L12 11L11.997 11C11.8625 11.0004 11.7343 11.0273 11.6172 11.0759C11.502 11.1236 11.3938 11.1937 11.2995 11.2864C11.297 11.2888 11.2946 11.2912 11.2922 11.2936L7.29289 15.2929C6.90237 15.6834 6.90237 16.3166 7.29289 16.7071C7.68342 17.0976 8.31658 17.0976 8.70711 16.7071L11 14.4142Z",fill:"currentColor"})]}),Mc=()=>l.jsx("svg",{width:"43",height:"57",viewBox:"0 0 43 57",fill:"currentColor",className:"tiptap-image-upload-dropzone-rect-primary",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{d:"M0.75 10.75C0.75 5.64137 4.89137 1.5 10 1.5H32.3431C33.2051 1.5 34.0317 1.84241 34.6412 2.4519L40.2981 8.10876C40.9076 8.71825 41.25 9.5449 41.25 10.4069V46.75C41.25 51.8586 37.1086 56 32 56H10C4.89137 56 0.75 51.8586 0.75 46.75V10.75Z",fill:"currentColor",fillOpacity:"0.11",stroke:"currentColor",strokeWidth:"1.5"})}),Nc=()=>l.jsx("svg",{width:"10",height:"10",className:"tiptap-image-upload-dropzone-rect-secondary",viewBox:"0 0 10 10",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{d:"M0 0.75H0.343146C1.40401 0.75 2.42143 1.17143 3.17157 1.92157L8.82843 7.57843C9.57857 8.32857 10 9.34599 10 10.4069V10.75H4C1.79086 10.75 0 8.95914 0 6.75V0.75Z",fill:"currentColor"})}),Hc=({onFile:e,children:t})=>{const[n,o]=u.useState(!1),[r,s]=u.useState(!1),i=f=>{f.preventDefault(),f.stopPropagation(),s(!0)},a=f=>{f.preventDefault(),f.stopPropagation(),f.currentTarget.contains(f.relatedTarget)||(s(!1),o(!1))},c=f=>{f.preventDefault(),f.stopPropagation(),o(!0)},d=f=>{f.preventDefault(),f.stopPropagation(),s(!1),o(!1);const p=Array.from(f.dataTransfer.files);p.length>0&&e(p)};return l.jsx("div",{className:`tiptap-image-upload-drag-area ${r?"drag-active":""} ${n?"drag-over":""}`,onDragEnter:i,onDragLeave:a,onDragOver:c,onDrop:d,children:t})},Vc=({fileItem:e,onRemove:t})=>{const n=o=>{if(o===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],i=Math.floor(Math.log(o)/Math.log(r));return`${parseFloat((o/Math.pow(r,i)).toFixed(2))} ${s[i]}`};return l.jsxs("div",{className:"tiptap-image-upload-preview",children:[e.status==="uploading"&&l.jsx("div",{className:"tiptap-image-upload-progress",style:{width:`${e.progress}%`}}),l.jsxs("div",{className:"tiptap-image-upload-preview-content",children:[l.jsxs("div",{className:"tiptap-image-upload-file-info",children:[l.jsx("div",{className:"tiptap-image-upload-file-icon",children:l.jsx(cl,{})}),l.jsxs("div",{className:"tiptap-image-upload-details",children:[l.jsx("span",{className:"tiptap-image-upload-text",children:e.file.name}),l.jsx("span",{className:"tiptap-image-upload-subtext",children:n(e.file.size)})]})]}),l.jsxs("div",{className:"tiptap-image-upload-actions",children:[e.status==="uploading"&&l.jsxs("span",{className:"tiptap-image-upload-progress-text",children:[e.progress,"%"]}),l.jsx(M,{type:"button",variant:"ghost",onClick:o=>{o.stopPropagation(),t()},children:l.jsx(al,{className:"tiptap-button-icon"})})]})]})]})},Bc=({maxSize:e,limit:t})=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"tiptap-image-upload-dropzone",children:[l.jsx(Mc,{}),l.jsx(Nc,{}),l.jsx("div",{className:"tiptap-image-upload-icon-container",children:l.jsx(cl,{})})]}),l.jsxs("div",{className:"tiptap-image-upload-content",children:[l.jsxs("span",{className:"tiptap-image-upload-text",children:[l.jsx("em",{children:"Click to upload"})," or drag and drop"]}),l.jsxs("span",{className:"tiptap-image-upload-subtext",children:["Maximum ",t," file",t===1?"":"s",", ",e/1024/1024,"MB each."]})]})]}),Dc=e=>{const{accept:t,limit:n,maxSize:o}=e.node.attrs,r=u.useRef(null),s=e.extension,i={maxSize:o,limit:n,accept:t,upload:s.options.upload,onSuccess:s.options.onSuccess,onError:s.options.onError},{fileItems:a,uploadFiles:c,removeFileItem:d,clearAllFiles:f}=Ec(i),p=async b=>{const m=await c(b);if(m.length>0){const w=e.getPos();if(X(w)){const v=m.map((y,x)=>{const S=b[x]?.name.replace(/\.[^/.]+$/,"")||"unknown";return{type:s.options.type,attrs:{...s.options,src:y,alt:S,title:S}}});e.editor.chain().focus().deleteRange({from:w,to:w+e.node.nodeSize}).insertContentAt(w,v).run(),O1(e.editor)}}},h=b=>{const m=b.target.files;if(!m||m.length===0){s.options.onError?.(new Error("No file selected"));return}p(Array.from(m))},C=()=>{r.current&&a.length===0&&(r.current.value="",r.current.click())},g=a.length>0;return l.jsxs(G.NodeViewWrapper,{className:"tiptap-image-upload",tabIndex:0,onClick:C,children:[!g&&l.jsx(Hc,{onFile:p,children:l.jsx(Bc,{maxSize:o,limit:n})}),g&&l.jsxs("div",{className:"tiptap-image-upload-previews",children:[a.length>1&&l.jsxs("div",{className:"tiptap-image-upload-header",children:[l.jsxs("span",{children:["Uploading ",a.length," files"]}),l.jsx(M,{type:"button",variant:"ghost",onClick:b=>{b.stopPropagation(),f()},children:"Clear All"})]}),a.map(b=>l.jsx(Vc,{fileItem:b,onRemove:()=>d(b.id)},b.id))]}),l.jsx("input",{ref:r,name:"file",accept:t,type:"file",multiple:n>1,onChange:h,onClick:b=>b.stopPropagation()})]})},Uc=G.Node.create({name:"imageUpload",group:"block",draggable:!0,selectable:!0,atom:!0,addOptions(){return{type:"image",accept:"image/*",limit:1,maxSize:0,upload:void 0,onError:void 0,onSuccess:void 0,HTMLAttributes:{}}},addAttributes(){return{accept:{default:this.options.accept},limit:{default:this.options.limit},maxSize:{default:this.options.maxSize}}},parseHTML(){return[{tag:'div[data-type="image-upload"]'}]},renderHTML({HTMLAttributes:e}){return["div",G.mergeAttributes({"data-type":"image-upload"},e)]},addNodeView(){return G.ReactNodeViewRenderer(Dc)},addCommands(){return{setImageUploadNode:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addKeyboardShortcuts(){return{Enter:({editor:e})=>{const{selection:t}=e.state,{nodeAfter:n}=t.$from;if(n&&n.type.name==="imageUpload"&&e.isActive("imageUpload")){const o=e.view.nodeDOM(t.$from.pos);if(o&&o instanceof HTMLElement){const r=o.firstChild;if(r&&r instanceof HTMLElement)return r.click(),!0}}return!1}}}}),dl=35,ut=120,Oc=40,Et={cells:[],mergedCells:[]};function An(e){return e instanceof HTMLElement}function ul(e,t){return e?.closest?.(t)??null}function fl(e){let t=e;for(;t&&t.tagName!=="TD"&&t.tagName!=="TH"&&!t.classList.contains("tableWrapper");){if(t.classList.contains("ProseMirror"))return;t=An(t.parentNode)?t.parentNode:null}if(t)return t.tagName==="TD"||t.tagName==="TH"?{type:"cell",domNode:t,tbodyNode:ul(t,"tbody")}:{type:"wrapper",domNode:t,tbodyNode:t.querySelector("tbody")}}function Ue(e,t,n){return Math.max(t,Math.min(e,n))}function pl(e,t,n){return e>=0&&e<n.height&&t>=0&&t<n.width}function Pc(e,t,n,o){if(typeof o=="number")return o;if(e.selection instanceof T.CellSelection){const a=T.selectedRect(e);return n==="row"?a.top:a.left}const r=T.cellAround(e.selection.$anchor)??T.selectionCell(e);if(!r)return null;const s=r.pos-t.start,i=t.map.findCell(s);return n==="row"?i.top:i.left}function Wc(e,t,n,o){return{row:e,column:t,pos:n,node:o,start:n+1,depth:o?o.content.size:0}}function _c(e){if(!e)return!1;const t=e.attrs.colspan??1,n=e.attrs.rowspan??1;return t>1||n>1}function In(e,t,n,o){if(!e)return Et;const{state:r}=e,s=ne(e,o);if(!s)return Et;const i=s.start,a=s.node,c=s.map,d=Pc(r,s,t,n);if(d===null)return Et;const f=t==="row"?c.height:c.width;if(d<0||d>=f)return Et;const p=[],h=[],C=new Set,g=t==="row"?c.width:c.height;for(let b=0;b<g;b++){const m=t==="row"?d:b,w=t==="row"?b:d,v=m*c.width+w,y=c.map[v];if(y===void 0)continue;const x=i+y,S=a.nodeAt(y);if(!S)continue;const L=Wc(m,w,x,S);_c(S)&&(C.has(x)||(h.push(L),C.add(x))),p.push(L)}return{cells:p,mergedCells:h}}function hl(e,t,n){const o=ne(e,t);if(!o)return 0;const{doc:r}=e.state,s=n==="row"?o.map.height:o.map.width;let i=0;for(let a=s-1;a>=0;a--){const c=new Set;let d=!0;const f=n==="row"?o.map.width:o.map.height;for(let p=0;p<f;p++){const h=n==="row"?a:p,C=n==="row"?p:a,g=o.map.positionAt(h,C,o.node);if(c.has(g))continue;c.add(g);const b=t+1+g,m=r.nodeAt(b);if(m&&!Oe(m)){d=!1;break}}if(d)i++;else break}return i}function ne(e,t){if(!e)return null;let n=null;if(typeof t=="number"){const r=e.state.doc.nodeAt(t);r?.type.name==="table"&&(n={node:r,pos:t,start:t+1,depth:e.state.doc.resolve(t).depth})}if(!n){const{state:r}=e,s=r.doc.resolve(r.selection.from);n=T.findTable(s)}if(!n)return null;const o=T.TableMap.get(n.node);return o?{...n,map:o}:null}function Mt(e,t,n){const o=n==="row"?e.height:e.width;if(t<0||t>=o)return[];let r=t,s=t,i=!0;for(;i;){i=!1;const a=r,c=s,d=new Map,f=n==="row"?e.height:e.width,p=n==="row"?e.width:e.height;for(let h=0;h<f;h++)for(let C=0;C<p;C++){const g=n==="row"?h*e.width+C:C*e.width+h,b=e.map[g],m=d.get(b)??[];m.push(h),d.set(b,m)}d.forEach(h=>{const C=Math.min(...h),g=Math.max(...h);g>=r&&C<=s&&(C<r&&(r=C),g>s&&(s=g))}),i=a!==r||c!==s}return Array.from({length:s-r+1},(a,c)=>r+c)}function Cl(e,t,n,o){const r=Mt(e,t,n);if(r.length===0)return null;const s=n==="row"?e.height:e.width,i=o==="previous"?r[0]-1:r[r.length-1]+1;return i>=0&&i<s?i:null}function Ln(e,t){const n=e.view,o=n.state.selection,r=o.getBookmark(),s=new Pr.Mapping,i=n.dispatch;n.dispatch=a=>{s.appendMapping(a.mapping),i(a)};try{t()}finally{n.dispatch=i}try{const a=r.map(s).resolve(n.state.doc);return n.dispatch(n.state.tr.setSelection(a)),!0}catch{const a=s.map(o.from,-1),c=Ue(a,0,n.state.doc.content.size),d=E.Selection.near(n.state.doc.resolve(c),-1);return n.dispatch(n.state.tr.setSelection(d)),!1}}function Oe(e){if(e.childCount===0)return!0;let t=!0;return e.descendants(n=>n.isText&&n.text?.trim()||n.isLeaf&&!n.isText?(t=!1,!1):!0),t}function Q(e,t,n,o){if(typeof t=="number"&&n)return{orientation:n,index:t};if(!e)return null;const{state:r}=e;if(!ne(e,o))return null;if(r.selection instanceof T.CellSelection){const i=T.selectedRect(r),a=i.right-i.left,c=i.bottom-i.top;return c===1&&a>=1?{orientation:"row",index:i.top}:a===1&&c>=1?{orientation:"column",index:i.left}:null}return null}function ge(e,t,n,o){const r={cells:[],mergedCells:[],index:void 0,orientation:void 0,tablePos:void 0};if(!e||typeof t!="number"&&!(e.state.selection instanceof T.CellSelection))return r;let s=t,i=n;if(typeof s!="number"||!i||!["row","column"].includes(i)){const c=Q(e);if(!c)return r;s=c.index,i=c.orientation}return{...In(e,i,s,o),index:s,orientation:i}}function gl(e,t,n){return In(e,"row",t,n)}function bl(e,t,n){return In(e,"column",t,n)}function En(e,t,n,o){try{const r=ne(e,o);if(!r)return;const{state:s}=e,{map:i}=r;if(t==="row"){if(n>=0&&n<i.height){const c=i.width-1,d=r.start+i.positionAt(n,0,r.node),f=r.start+i.positionAt(n,c,r.node),p=s.doc.resolve(d),h=s.doc.resolve(f),C=T.CellSelection.create(s.doc,p.pos,h.pos),g=s.tr.setSelection(C);e.view.dispatch(g)}}else if(t==="column"&&n>=0&&n<i.width){const c=i.height-1,d=r.start+i.positionAt(0,n,r.node),f=r.start+i.positionAt(c,n,r.node),p=s.doc.resolve(d),h=s.doc.resolve(f),C=T.CellSelection.create(s.doc,p.pos,h.pos),g=s.tr.setSelection(C);e.view.dispatch(g)}}catch(r){console.warn("Failed to update selection after move:",r)}}function Zc(e,t){return function(n,o){if(!T.isInTable(n))return!1;const r=T.selectionCell(n),s=typeof e=="string"?{[e]:t}:e;if(o){const i=n.tr;n.selection instanceof T.CellSelection?n.selection.forEachCell((a,c)=>{Object.entries(s).some(([f,p])=>a.attrs[f]!==p)&&i.setNodeMarkup(c,null,{...a.attrs,...s})}):Object.entries(s).some(([c,d])=>r.nodeAfter.attrs[c]!==d)&&i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,...s}),o(i)}return!0}}function Fc(e,t){return hl(e,t,"row")}function zc(e,t){return hl(e,t,"column")}function $c(e,t=.3){const n=Math.floor(e),o=Math.ceil(e),r=n+t,s=o-t;return e<r?n:e>s?o:Math.round(e)}function ml(e,t){return!e&&!t?!0:!e||!t?!1:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function qc(e,t,n){switch(n.mode??"state"){case"dispatch":{const r=n;typeof r.dispatch=="function"&&r.dispatch(t);return}case"transaction":return t;default:return e.apply(t)}}function Le(e,t,n,o={mode:"state"}){if(!e)return;const r=ne(e,t);if(!r)return;const{state:s}=e,i=r.map,a=n.map(w=>({row:Ue(w.row,0,i.height-1),col:Ue(w.col,0,i.width-1)})).filter(w=>pl(w.row,w.col,i));if(a.length===0)return;const c=a.map(w=>w.row),d=Math.min(...c),f=Math.max(...c),p=a.map(w=>w.col),h=Math.min(...p),C=Math.max(...p),g=(w,v)=>{const y=i.map[w*i.width+v];return y===void 0?null:t+1+y},b=g(d,h);if(b===null)return;let m=g(f,C);if(m!==null){if(m===b){let w=!1;for(let v=f;v>=d&&!w;v--)for(let y=C;y>=h&&!w;y--){const x=g(v,y);x!==null&&x!==b&&(m=x,w=!0)}}try{const w=s.doc.resolve(b),v=s.doc.resolve(m),y=new T.CellSelection(w,v),x=s.tr.setSelection(y);return qc(s,x,o)}catch(w){console.error("Failed to create cell selection:",w);return}}}function Gc({editor:e,row:t,col:n,tablePos:o,dispatch:r}){if(!e)return!1;const{state:s,view:i}=e,a=ne(e,o);if(!a||!pl(t,n,a.map))return!1;const c=a.map.positionAt(t,n,a.node),d=a.start+c,f=s.doc.resolve(d),p=T.cellAround(f),h=p?p.pos:d,C=T.CellSelection.create(s.doc,h),g=r??i?.dispatch;return g?(g(s.tr.setSelection(C)),!0):!1}function Mn(e,t,n,o){const r=T.TableMap.get(t),s=o==="row",i=s?r.height-1:0,a=s?0:r.width-1,c=i*r.width+a,d=r.map[c];if(!d&&d!==0)return console.warn("selectLastCell: cell position not found in map",{index:c,row:i,col:a,map:r}),!1;const f=r.map.indexOf(d),p=f>=0?Math.floor(f/r.width):0,h=f>=0?f%r.width:0;return Gc({editor:e,row:p,col:h,tablePos:n,dispatch:e.view.dispatch.bind(e.view)})}function Ke({editor:e,index:t,orientation:n,tablePos:o}){if(!e)return null;const r=ne(e,o);if(!r)return null;const{map:s}=r,{width:i,height:a}=s;return t<0||n==="row"&&t>=a||n==="column"&&t>=i?null:n==="row"?Array.from({length:s.width},(c,d)=>({row:t,col:d})):Array.from({length:s.height},(c,d)=>({row:d,col:t}))}function wl(e,t,n){if(!t)return null;try{const o=n.view.posAtDOM(e,0),r=n.view.state.doc.resolve(o);for(let s=r.depth;s>0;s--){const i=r.node(s);if(i.type.name==="tableCell"||i.type.name==="tableHeader"){const a=T.TableMap.get(t),c=r.before(s),d=r.start(s-2),f=c-d,p=a.map.indexOf(f);return{rowIndex:Math.floor(p/a.width),colIndex:p%a.width}}}}catch(o){console.warn("Could not get cell position:",o)}return null}function Kc(e,t){try{const n=t.view.posAtDOM(e,0),o=t.view.state.doc.resolve(n);for(let r=o.depth;r>=0;r--){const s=o.node(r);if(vl(s))return{node:s,pos:r===0?0:o.before(r)}}}catch(n){console.warn("Could not get table from DOM:",n)}return null}function vl(e){return!!e&&(e.type.name==="table"||e.type.spec.tableRole==="table")}const Yc=S1.Table.extend({addProseMirrorPlugins(){const e=this.options.resizable&&this.editor.isEditable,t=this.options.cellMinWidth<ut?ut:this.options.cellMinWidth;return[jc(),...e?[T.columnResizing({handleWidth:this.options.handleWidth,cellMinWidth:dl,defaultCellMinWidth:t,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],T.tableEditing({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){return({node:e,HTMLAttributes:t})=>{class n extends T.TableView{blockContainer;innerTableContainer;widgetsContainer;overlayContainer;containerAttributes;constructor(s,i,a){super(s,i),this.containerAttributes=a??{},this.blockContainer=this.createBlockContainer(),this.innerTableContainer=this.createInnerTableContainer(),this.widgetsContainer=this.createWidgetsContainer(),this.overlayContainer=this.createOverlayContainer(),this.setupDOMStructure()}createBlockContainer(){const s=document.createElement("div");return s.setAttribute("data-content-type","table"),this.applyContainerAttributes(s),s}createInnerTableContainer(){const s=document.createElement("div");return s.className="table-container",s}createWidgetsContainer(){const s=document.createElement("div");return s.className="table-controls",s.style.position="relative",s}createOverlayContainer(){const s=document.createElement("div");return s.className="table-selection-overlay-container",s}applyContainerAttributes(s){Object.entries(this.containerAttributes).forEach(([i,a])=>{i!=="class"&&s.setAttribute(i,a)})}setupDOMStructure(){const s=this.dom,i=s.firstChild;this.innerTableContainer.appendChild(i),s.appendChild(this.innerTableContainer),s.appendChild(this.widgetsContainer),s.appendChild(this.overlayContainer),this.blockContainer.appendChild(s),this.dom=this.blockContainer}ignoreMutation(s){return!s.target.closest(".table-container")||super.ignoreMutation(s)}}const o=this.options.cellMinWidth<ut?ut:this.options.cellMinWidth;return new n(e,o,t)}}});function jc(){return new E.Plugin({props:{handleDOMEvents:{mousedown(e,t){return Xc(e.editable,t)}}}})}function Xc(e,t){if(e||!t.target)return!1;const n=t.target.closest;return typeof n!="function"||!!!n.call(t.target,"[data-content-type=table], .tableWrapper")?!1:(t.preventDefault(),!0)}const Jc=Be.TableCell.extend({addKeyboardShortcuts(){return{...this.parent?.(),"Mod-a":()=>{const{state:e,view:t}=this.editor,{selection:n,doc:o}=e,r=n.$anchor,s=T.cellAround(r);if(!s)return!1;const i=o.nodeAt(s.pos);if(!i||!i.textContent)return!1;const a=s.pos+1,c=s.pos+i.nodeSize-1;if(a>=c)return!0;const d=o.resolve(a),f=o.resolve(c),p=E.TextSelection.between(d,f,1);return!p||e.selection.eq(p)||t.dispatch(e.tr.setSelection(p)),!0}}}}),Qc=we.Extension.create({name:"tableKit",addExtensions(){const e=[];return this.options.table!==!1&&e.push(Yc.configure(this.options.table)),this.options.tableCell!==!1&&e.push(Jc.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(Be.TableHeader.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(Be.TableRow.configure(this.options.tableRow)),e}}),Rc=["boxSizing","backgroundColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","paddingTop","paddingRight","paddingBottom","paddingLeft","color","font","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textTransform","textDecoration","textAlign","verticalAlign","whiteSpace","width","minWidth","maxWidth","height","minHeight","maxHeight","backgroundClip"],yl=e=>e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase());function e2(e,t){const n=getComputedStyle(e);for(const o of Rc){const r=String(o),s=n.getPropertyValue(yl(r));s&&t.style.setProperty(yl(r),s)}t.style.overflow="hidden",t.style.textOverflow="ellipsis",(n.whiteSpace===""||n.whiteSpace==="normal")&&(t.style.whiteSpace="nowrap")}function xl(e){const t=e.cloneNode(!0),n=[{src:e,dst:t}];for(;n.length;){const{src:o,dst:r}=n.shift();o instanceof HTMLElement&&r instanceof HTMLElement&&e2(o,r);const s=Array.from(o.children),i=Array.from(r.children),a=Math.min(s.length,i.length);for(let c=0;c<a;c++){const d=s[c],f=i[c];d&&f&&n.push({src:d,dst:f})}}return t}function t2(e,t){Object.assign(e.style,{position:"fixed",top:"-10000px",left:"-10000px",pointerEvents:"none",zIndex:"2147483647",maxWidth:`${t}px`,borderRadius:"12px",background:"transparent",filter:"drop-shadow(0 8px 24px rgba(0,0,0,0.18)) drop-shadow(0 2px 8px rgba(0,0,0,0.10))",overflow:"hidden"})}function n2(e,t){e.isConnected||document.body.appendChild(e);const n=e.getBoundingClientRect();if(n.width>t&&n.width>0){const o=t/n.width;e.style.transformOrigin="top left",e.style.transform=`scale(${o})`}}function kl(e,t){const n=getComputedStyle(e);t.style.borderCollapse=n.borderCollapse,t.style.borderSpacing=n.borderSpacing,t.style.tableLayout="fixed",t.className=e.className}function Sl(e,t){const n=e.getBoundingClientRect();n.width>0&&(t.style.width=`${n.width}px`,t.style.maxWidth=`${n.width}px`)}function o2(e,t){const n=e.tBodies?.[0]??e.querySelector("tbody");if(!n)return null;const o=n.rows?.[t];if(!o)return null;const r=document.createElement("table"),s=document.createElement("tbody"),i=xl(o);kl(e,r);for(let a=0;a<o.cells.length;a++){const c=o.cells[a],d=i.cells[a];d&&Sl(c,d)}return s.appendChild(i),r.appendChild(s),r}function r2(e,t){const n=e.tBodies?.[0]??e.querySelector("tbody");if(!n)return null;const o=document.createElement("table"),r=document.createElement("tbody");kl(e,o);let s=0;for(let i=0;i<n.rows.length;i++){const a=n.rows[i];if(!a)continue;const c=a.cells?.[t];if(!c)continue;const d=document.createElement("tr"),f=xl(c),p=c.getBoundingClientRect();!s&&p.width>0&&(s=p.width),Sl(c,f),d.appendChild(f),r.appendChild(d)}return s>0&&(o.style.width=`${s}px`,o.style.maxWidth=`${s}px`),o.appendChild(r),o}function l2(e,t,n,o){const r=e.view.dom.getBoundingClientRect(),s=Math.max(0,r.width),i=document.createElement("div");t2(i,s);const a=e.view.nodeDOM(o);if(!a)return document.body.appendChild(i),i;const c=a.getBoundingClientRect(),d=Math.min(c.width,r.width);i.style.width=`${d}px`;const f=t==="row"?o2(a,n):r2(a,n);if(f){const p=document.createElement("div");Object.assign(p.style,{background:"var(--drag-image-bg, transparent)",overflow:"hidden"}),p.appendChild(f),i.appendChild(p)}return n2(i,s),i}function s2(e,t){t.querySelectorAll(e).forEach(n=>{n.style.visibility="hidden"})}const ke=new E.PluginKey("tableHandlePlugin");class i2{editor;editorView;state=void 0;menuFrozen=!1;mouseState="up";tableId;tablePos;tableElement;emitUpdate;constructor(t,n,o){this.editor=t,this.editorView=n,this.emitUpdate=()=>this.state&&o(this.state),this.editorView.dom.addEventListener("mousemove",this.mouseMoveHandler),this.editorView.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),this.editorView.root.addEventListener("dragover",this.dragOverHandler),this.editorView.root.addEventListener("drop",this.dropHandler)}viewMousedownHandler=t=>{this.mouseState="down";const{state:n,view:o}=this.editor;if(!(n.selection instanceof T.CellSelection)||this.editor.isFocused)return;const r=o.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return;const s=n.doc.resolve(r.pos),{nodes:i}=n.schema;let a=-1,c=!1;for(let h=s.depth;h>=0;h--){const C=s.node(h);if(!c&&(C.type===i.tableCell||C.type===i.tableHeader)&&(c=!0),a===-1&&C.type===i.paragraph&&(a=h),c&&a!==-1)break}if(!c||a===-1)return;const d=s.start(a),f=s.end(a),p=E.TextSelection.create(n.doc,d,f);n.selection.eq(p)||(o.dispatch(n.tr.setSelection(p)),o.focus())};mouseUpHandler=t=>{this.mouseState="up",this.mouseMoveHandler(t)};mouseMoveHandler=t=>{if(this.menuFrozen||this.mouseState==="selecting")return;const n=t.target;!An(n)||!this.editorView.dom.contains(n)||this._handleMouseMoveNow(t)};hideHandles(){this.state?.show&&(this.state={...this.state,show:!1,showAddOrRemoveRowsButton:!1,showAddOrRemoveColumnsButton:!1,colIndex:void 0,rowIndex:void 0,referencePosCell:void 0},this.emitUpdate())}_handleMouseMoveNow(t){const n=fl(t.target);if(n?.type==="cell"&&this.mouseState==="down"&&!this.state?.draggingState){this.mouseState="selecting",this.hideHandles();return}if(!n||!this.editor.isEditable){this.hideHandles();return}const o=n.tbodyNode;if(!o)return;const r=o.getBoundingClientRect(),s=this.editor.view.posAtCoords({left:t.clientX,top:t.clientY});if(!s)return;const i=this.editor.view.state.doc.resolve(s.pos);let a;for(let f=i.depth;f>=0;f--){const p=i.node(f);if(vl(p)){a={node:p,pos:f===0?0:i.before(f)};break}}if(!a||a.node.type.name!=="table")return;this.tableElement=this.editor.view.nodeDOM(a.pos),this.tablePos=a.pos,this.tableId=a.node.attrs.id;const d=ul(n.domNode,".tableWrapper")?.querySelector(".table-controls");if(n.type==="wrapper"){const f=t.clientY>=r.bottom-1&&t.clientY<r.bottom+20,p=t.clientX>=r.right-1&&t.clientX<r.right+20,h=t.clientX>r.right||t.clientY>r.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:f,showAddOrRemoveColumnsButton:p,referencePosTable:r,block:a.node,blockPos:a.pos,widgetContainer:d,colIndex:h?void 0:this.state?.colIndex,rowIndex:h?void 0:this.state?.rowIndex,referencePosCell:h?void 0:this.state?.referencePosCell}}else{const f=wl(n.domNode,a.node,this.editor);if(!f)return;const{rowIndex:p,colIndex:h}=f,C=n.domNode.getBoundingClientRect(),g=a.node.content.childCount-1,b=(a.node.content.firstChild?.content.childCount??0)-1;if(this.state?.show&&this.tableId===a.node.attrs.id&&this.state.rowIndex===p&&this.state.colIndex===h)return;this.state={show:!0,showAddOrRemoveColumnsButton:h===b,showAddOrRemoveRowsButton:p===g,referencePosTable:r,block:a.node,blockPos:a.pos,draggingState:void 0,referencePosCell:C,colIndex:h,rowIndex:p,widgetContainer:d}}return this.emitUpdate(),!1}dragOverHandler=t=>{if(this.state?.draggingState===void 0)return;t.preventDefault(),t.dataTransfer.dropEffect="move",s2(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.editorView.root);const{left:n,right:o,top:r,bottom:s}=this.state.referencePosTable,i={left:Ue(t.clientX,n+1,o-1),top:Ue(t.clientY,r+1,s-1)},a=this.editorView.root.elementsFromPoint(i.left,i.top).filter(v=>v.tagName==="TD"||v.tagName==="TH");if(a.length===0)return;const c=a[0];if(!An(c))return;const d=wl(c,this.state.block,this.editor);if(!d)return;const{rowIndex:f,colIndex:p}=d,h=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,g=(this.state.draggingState.draggedCellOrientation==="row"?f:p)!==h,b=this.state.draggingState.draggedCellOrientation==="row"?i.top:i.left,m=this.state.rowIndex!==f||this.state.colIndex!==p,w=this.state.draggingState.mousePos!==b;(m||w)&&(this.state={...this.state,rowIndex:f,colIndex:p,referencePosCell:c.getBoundingClientRect(),draggingState:{...this.state.draggingState,mousePos:b}},this.emitUpdate()),g&&this.editor.view.dispatch(this.editor.state.tr.setMeta(ke,!0))};dropHandler=()=>{this.mouseState="up";const t=this.state;if(!t?.draggingState)return!1;const{draggingState:n,rowIndex:o,colIndex:r,blockPos:s}=t;if(!X(s))return!1;if(n.draggedCellOrientation==="row"&&o===void 0||n.draggedCellOrientation==="col"&&r===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");const i=n.draggedCellOrientation==="row",a=i?"row":"column",c=i?o:r,d=Mt(T.TableMap.get(t.block),n.originalIndex,a);if(d.length===0||d.includes(c))return this.state={...t,draggingState:void 0},this.emitUpdate(),this.editor.view.dispatch(this.editor.state.tr.setMeta(ke,null)),!1;const f=d[0],p=Ke({editor:this.editor,index:f,orientation:a,tablePos:s});if(!p)return!1;const h=Le(this.editor,s,p,{mode:"state"});if(!h)return!1;const C=g=>this.editor.view.dispatch(g);return i?T.moveTableRow({from:f,to:c,select:!0,pos:s+1})(h,C):T.moveTableColumn({from:f,to:c,select:!0,pos:s+1})(h,C),this.state={...t,draggingState:void 0},this.emitUpdate(),this.editor.view.dispatch(this.editor.state.tr.setMeta(ke,null)),!0};update(t){const n=ke.getState(t.state);if(n!==void 0&&n!==this.menuFrozen&&(this.menuFrozen=n),!this.state?.show)return;if(!this.tableElement?.isConnected){this.hideHandles();return}const o=Kc(this.tableElement,this.editor);if(!o){this.hideHandles();return}const r=this.state.block!==o.node||this.state.blockPos!==o.pos;if(!o.node||o.node.type.name!=="table"||!this.tableElement?.isConnected){this.hideHandles();return}const{height:s,width:i}=T.TableMap.get(o.node);let a=this.state.rowIndex,c=this.state.colIndex;a!==void 0&&a>=s&&(a=s?s-1:void 0),c!==void 0&&c>=i&&(c=i?i-1:void 0);const d=this.tableElement.querySelector("tbody");if(!d)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");let f=this.state.referencePosCell;if(a!==void 0&&c!==void 0){const b=d.children[a]?.children[c];b?f=b.getBoundingClientRect():(a=void 0,c=void 0,f=void 0)}const p=d.getBoundingClientRect(),h=a!==this.state.rowIndex||c!==this.state.colIndex,C=f!==this.state.referencePosCell||p!==this.state.referencePosTable;(r||h||C)&&(this.state={...this.state,block:o.node,blockPos:o.pos,rowIndex:a,colIndex:c,referencePosCell:f,referencePosTable:p},this.emitUpdate())}destroy(){this.editorView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.editorView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.editorView.root.removeEventListener("dragover",this.dragOverHandler),this.editorView.root.removeEventListener("drop",this.dropHandler)}}let j=null;function a2(e,t){return new E.Plugin({key:ke,state:{init:()=>!1,apply:(n,o)=>{const r=n.getMeta(ke);return r!==void 0?r:o}},view:n=>(j=new i2(e,n,t),j),props:{decorations:n=>{if(!j)return null;if(j===void 0||j.state===void 0||j.state.draggingState===void 0||j.tablePos===void 0)return;const o=j.state.draggingState.draggedCellOrientation==="row"?j.state.rowIndex:j.state.colIndex;if(o===void 0)return;const r=[],{draggingState:s}=j.state,{originalIndex:i}=s;return j.state.draggingState.draggedCellOrientation==="row"?gl(e,i,j.state.blockPos).cells.forEach(c=>{c.node&&r.push(Te.Decoration.node(c.pos,c.pos+c.node.nodeSize,{class:"table-cell-dragging-source"}))}):bl(e,i,j.state.blockPos).cells.forEach(c=>{c.node&&r.push(Te.Decoration.node(c.pos,c.pos+c.node.nodeSize,{class:"table-cell-dragging-source"}))}),o===i||!e||(j.state.draggingState.draggedCellOrientation==="row"?gl(e,o,j.state.blockPos).cells.forEach(c=>{const d=c.node;if(!d)return;const f=c.pos+(o>i?d.nodeSize-2:2);r.push(Te.Decoration.widget(f,()=>{const p=document.createElement("div");return p.className="tiptap-table-dropcursor",p.style.left="0",p.style.right="0",o>i?p.style.bottom="-1px":p.style.top="-1px",p.style.height="3px",p}))}):bl(e,o,j.state.blockPos).cells.forEach(c=>{const d=c.node;if(!d)return;const f=c.pos+(o>i?d.nodeSize-2:2);r.push(Te.Decoration.widget(f,()=>{const p=document.createElement("div");return p.className="tiptap-table-dropcursor",p.style.top="0",p.style.bottom="0",o>i?p.style.right="-1px":p.style.left="-1px",p.style.width="3px",p}))})),Te.DecorationSet.create(n.doc,r)}}})}const Tl=(e,t)=>{if(!j?.state)throw new Error(`Attempted to drag table ${e}, but no table block was hovered prior.`);const{state:n,editor:o}=j,r=e==="col"?n.colIndex:n.rowIndex;if(r===void 0)throw new Error(`Attempted to drag table ${e}, but no table block was hovered prior.`);const{blockPos:s,referencePosCell:i}=n,a=e==="col"?t.clientX:t.clientY;if(o.state.selection instanceof T.CellSelection){const p=E.TextSelection.near(o.state.doc.resolve(s),1);o.view.dispatch(o.state.tr.setSelection(p))}const c=l2(o,e,r,s);if(t.dataTransfer){const p=t.currentTarget.getBoundingClientRect(),h=e==="col"?{x:p.width/2,y:0}:{x:0,y:p.height/2};t.dataTransfer.effectAllowed=e==="col"?"move":"copyMove",t.dataTransfer.setDragImage(c,h.x,h.y)}const d=()=>c.parentNode?.removeChild(c);document.addEventListener("drop",d,{once:!0}),document.addEventListener("dragend",d,{once:!0});const f=i?(e==="col"?i.left:i.top)-a:0;j.state={...n,draggingState:{draggedCellOrientation:e,originalIndex:r,mousePos:a,initialOffset:f}},j.emitUpdate(),o.view.dispatch(o.state.tr.setMeta(ke,!0))},c2=e=>Tl("col",{...e,clientY:0}),d2=e=>Tl("row",{...e,clientX:0}),u2=()=>{if(!j||j.state===void 0)return;j.state={...j.state,draggingState:void 0},j.emitUpdate();const e=j.editor;e.view.dispatch(e.state.tr.setMeta(ke,null))},f2=we.Extension.create({name:"tableHandleExtension",addCommands(){return{freezeHandles:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(ke,!0),!0),unfreezeHandles:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(ke,!1),!0)}},addProseMirrorPlugins(){const{editor:e}=this;return[a2(e,t=>{this.editor.emit("tableHandleState",t)})]}});function p2(e,t,n){if(n?.draggedCellOrientation==="row"){const o=n.mousePos+(n.initialOffset??0),r=Ue(o,t.y,t.bottom-e.height);return new DOMRect(t.x,r,t.width,e.height)}return new DOMRect(t.x,e.y,t.width,e.height)}function h2(e,t,n){if(n?.draggedCellOrientation==="col"){const o=n.mousePos+(n.initialOffset??0),r=Ue(o,t.x,t.right-e.width);return new DOMRect(r,t.y,e.width,t.height)}return new DOMRect(e.x,t.y,e.width,t.height)}function C2(e){return new DOMRect(e.x,e.y,e.width,0)}function g2(e){switch(e){case"row":return"left";case"col":return"top";default:return"bottom-end"}}function b2(e){switch(e){case"row":return 4;case"col":return 4;default:return{mainAxis:1,crossAxis:-1}}}function m2(e,t,n,o){switch(e){case"row":return p2(t,n,o);case"col":return h2(t,n,o);default:return C2(t)}}function Nn(e,t,n,o,r){const s=u.useMemo(()=>g2(e),[e]),i=u.useMemo(()=>b2(e),[e]),{refs:a,update:c,context:d,floatingStyles:f}=F.useFloating({open:t,placement:s,middleware:[F.offset(i),F.size({apply({rects:C,elements:g}){if(!g.floating)return;const b=(e==="col"?n?.width??o?.width:o?.width)??C.reference.width,m=(e==="row"?n?.height??o?.height:o?.height)??C.reference.height;g.floating.style.setProperty("--table-handle-ref-width",`${b}px`),g.floating.style.setProperty("--table-handle-ref-height",`${m}px`);const w=e==="row"?m:b;g.floating.style.setProperty("--table-handle-available-size",`${w}px`)}})]}),{isMounted:p,styles:h}=F.useTransitionStyles(d);return u.useEffect(()=>{c()},[c,t,e,n,o,r]),u.useEffect(()=>{!n||!o||r&&e==="cell"||a.setReference({getBoundingClientRect:()=>m2(e,n,o,r)})},[a,e,n,o,r]),u.useMemo(()=>({isMounted:p,ref:a.setFloating,style:{display:"flex",...h,...f}}),[p,a.setFloating,h,f])}function w2(e,t,n,o){const r=Nn("row",e,t,n,o),s=Nn("col",e,t,n,o),i=Nn("cell",e,t,n,o);return u.useMemo(()=>({rowHandle:r,colHandle:s,cellHandle:i}),[r,s,i])}function Hn(e={}){const{editor:t,initialState:n=null,watchFields:o,onStateChange:r}=e,{editor:s}=k(t),[i,a]=u.useState(n),c=u.useRef(n),d=u.useCallback(f=>{o&&c.current&&!o.some(h=>c.current[h]!==f[h])||(a(f),c.current=f,r?.(f))},[o,r]);return u.useEffect(()=>{if(!s){a(null),c.current=null,r?.(null);return}return s.on("tableHandleState",d),()=>{s.off("tableHandleState",d)}},[s,r,d]),i}const Nt=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12C14 13.1046 13.1046 14 12 14C10.8954 14 10 13.1046 10 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 5C10 3.89543 10.8954 3 12 3C13.1046 3 14 3.89543 14 5C14 6.10457 13.1046 7 12 7C10.8954 7 10 6.10457 10 5Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 19C10 17.8954 10.8954 17 12 17C13.1046 17 14 17.8954 14 19C14 20.1046 13.1046 21 12 21C10.8954 21 10 20.1046 10 19Z",fill:"currentColor"})]}));Nt.displayName="MoreVerticalIcon";function Al({className:e,type:t,...n}){return l.jsx("input",{type:t,"data-slot":"tiptap-input",className:z("tiptap-input",e),...n})}gn.cva("tiptap-input-group-addon",{variants:{align:{"inline-start":"tiptap-input-group-addon--inline-start","inline-end":"tiptap-input-group-addon--inline-end","block-start":"tiptap-input-group-addon--block-start","block-end":"tiptap-input-group-addon--block-end"}},defaultVariants:{align:"inline-start"}}),gn.cva("tiptap-input-group-button",{variants:{size:{xs:"tiptap-input-group-button--xs",sm:"tiptap-input-group-button--sm","icon-xs":"tiptap-input-group-button--icon-xs","icon-sm":"tiptap-input-group-button--icon-sm"}},defaultVariants:{size:"xs"}});function v2({...e}){return l.jsx(ce.ComboboxProvider,{includesBaseElement:!1,resetValueOnHide:!0,...e})}function Vn({className:e,...t}){return l.jsx(ce.Combobox,{autoSelect:!0,...t,className:z("tiptap-combobox",e)})}function Ye({className:e,...t}){return l.jsx(ce.ComboboxList,{"data-slot":"tiptap-combobox-list",className:z("tiptap-combobox-list",e),...t})}function y2({className:e,...t}){return l.jsx(ce.ComboboxItem,{"data-slot":"tiptap-combobox-item",className:z("tiptap-combobox-item",e),...t})}const x2=typeof window<"u"?u.useLayoutEffect:u.useEffect;function k2(e,t,n,o){const r=u.useRef(t);x2(()=>{r.current=t},[t]),u.useEffect(()=>{const s=window;if(!(s&&s.addEventListener))return;const i=a=>{r.current(a)};return s.addEventListener(e,i,o),()=>{s.removeEventListener(e,i,o)}},[e,n,o])}function S2(e,t,n="mousedown",o={}){k2(n,r=>{const s=r.target;if(!s||!s.isConnected)return;(Array.isArray(e)?e.filter(a=>!!a.current).every(a=>a.current&&!a.current.contains(s)):e.current&&!e.current.contains(s))&&t(r)},void 0,o)}const Il=(e,t)=>{typeof e=="function"?e(t):e&&typeof e=="object"&&"current"in e&&(e.current=t)},Ll=(e,t)=>{const n=u.useRef(null);return u.useCallback(o=>{e&&"current"in e&&(e.current=o),n.current&&Il(n.current,null),n.current=t,t&&Il(t,o)},[e,t])};function je({children:e,trigger:t,value:n,onOpenChange:o,onValueChange:r,onValuesChange:s,...i}){const a=!ce.useMenuContext(),[c,d]=u.useState(!1),f=!!s||a,p=u.useCallback(g=>{i.open===void 0&&d(g),o?.(g)},[i.open,o]),h=u.useMemo(()=>({isRootMenu:a,open:i.open??c}),[a,i.open,c]),C=l.jsxs(ce.MenuProvider,{open:c,setOpen:p,setValues:s,showTimeout:100,...i,children:[t,l.jsx(Ml.Provider,{value:h,children:l.jsx(El.Provider,{value:f,children:e})})]});return f?l.jsx(v2,{value:n,setValue:r,children:C}):C}function Xe({children:e,className:t,ref:n,onClickOutside:o,...r}){const s=u.useRef(null),{open:i}=L2(),a=E2();return S2(s,o||(()=>{})),l.jsx(ce.Menu,{ref:Ll(s,n),className:z("tiptap-menu-content",t),"data-side":a,"data-state":i?"open":"closed",gutter:4,flip:!0,unmountOnHide:!0,...r,children:e})}function Je({className:e,...t}){return l.jsx(ce.MenuButton,{...t,className:z("tiptap-menu-button",e)})}function T2({className:e,...t}){return l.jsx(ce.MenuButtonArrow,{...t,className:z("tiptap-menu-button-arrow",e)})}function de({className:e,...t}){return l.jsx(ce.MenuGroup,{...t,className:z("tiptap-menu-group",e)})}function ft({className:e,...t}){return l.jsx(ce.MenuGroupLabel,{...t,className:z("tiptap-menu-group-label",e)})}function A2({className:e,...t}){return l.jsx(ce.MenuItemRadio,{...t,className:z("tiptap-menu-item-radio",e)})}function Ee({name:e,value:t,preventClose:n,className:o,...r}){const s=ce.useMenuContext(),i=I2(),a=M2(s,n),c={blurOnHoverEnd:!1,focusOnHover:!0,className:z("tiptap-menu-item",o),...r};return i?l.jsx(y2,{...c,hideOnClick:a}):e&&t?l.jsx(A2,{...c,hideOnClick:!0,name:e,value:t}):l.jsx(ce.MenuItem,{...c})}const El=u.createContext(!1),Ml=u.createContext({isRootMenu:!1,open:!1}),I2=()=>u.useContext(El),L2=()=>u.useContext(Ml);function E2(){const e=ce.useMenuStore();return ce.useStoreState(e,n=>n.currentPlacement?.split("-")[0]||"bottom")}function M2(e,t){return u.useCallback(n=>(n.currentTarget.hasAttribute("aria-expanded")||t||e?.hideAll(),!1),[e,t])}function ee({decorative:e,orientation:t="vertical",className:n,...o}){const s=e?{role:"none"}:{"aria-orientation":t==="vertical"?t:void 0,role:"separator"};return l.jsx("div",{className:z("tiptap-separator",n),"data-orientation":t,...s,...o})}const N2=u.forwardRef(({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:r=!1,onDuplicated:s,text:i,onClick:a,children:c,...d},f)=>{const{editor:p}=k(e),{isVisible:h,handleDuplicate:C,label:g,canDuplicateRowColumn:b,Icon:m}=Hl({editor:p,index:t,orientation:n,tablePos:o,hideWhenUnavailable:r,onDuplicated:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:w,...d,ref:f,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),i&&l.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});N2.displayName="TableDuplicateRowColumnButton";const Bn=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 9C9.44772 9 9 9.44772 9 10V20C9 20.5523 9.44772 21 10 21H20C20.5523 21 21 20.5523 21 20V10C21 9.44772 20.5523 9 20 9H10ZM7 10C7 8.34315 8.34315 7 10 7H20C21.6569 7 23 8.34315 23 10V20C23 21.6569 21.6569 23 20 23H10C8.34315 23 7 21.6569 7 20V10Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C3.45228 3 3 3.45228 3 4V14C3 14.5477 3.45228 15 4 15C4.55228 15 5 15.4477 5 16C5 16.5523 4.55228 17 4 17C2.34772 17 1 15.6523 1 14V4C1 2.34772 2.34772 1 4 1H14C15.6523 1 17 2.34772 17 4C17 4.55228 16.5523 5 16 5C15.4477 5 15 4.55228 15 4C15 3.45228 14.5477 3 14 3H4Z",fill:"currentColor"})]}));Bn.displayName="CopyIcon";const Nl=["tableHandleExtension"];function Dn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!_(e,Nl))return!1;try{if(!ne(e,o))return!1;const s=ge(e,t,n,o);return s.mergedCells.length>0?!1:s.cells.length>0}catch{return!1}}function H2({editor:e,index:t,tablePos:n}){try{const o=ge(e,t,"row",n);if(o.cells.length===0)return!1;let r=!1;if(e.state.selection instanceof T.CellSelection)r=e.chain().focus(void 0,{scrollIntoView:!1}).addRowAfter().run();else{if(!n)return!1;const p=Ke({editor:e,index:t,orientation:"row",tablePos:n});if(!p)return!1;const h=Le(e,n,p,{mode:"state"});r=T.addRowAfter(h,e.view.dispatch)}if(!r)return!1;const s=ge(e,t+1,"row",n);if(s.cells.length===0)return!1;const{state:i,view:a}=e,c=i.tr,d=[...s.cells].reverse(),f=[...o.cells].reverse();return d.forEach((p,h)=>{const C=f[h];if(p.node&&C?.node){const g=p.node.type.create({...C.node.attrs},C.node.content,C.node.marks),b=p.pos+p.node.nodeSize;c.replaceWith(p.pos,b,g)}}),c.docChanged?(a.dispatch(c),En(e,"row",t+1,n),!0):!1}catch(o){return console.error("Error duplicating row:",o),!1}}function V2({editor:e,index:t,tablePos:n}){try{const o=ge(e,t,"column",n);if(o.cells.length===0)return!1;let r=!1;if(e.state.selection instanceof T.CellSelection)r=e.chain().focus(void 0,{scrollIntoView:!1}).addColumnAfter().run();else{if(!n)return!1;const p=Ke({editor:e,index:t,orientation:"column",tablePos:n});if(!p)return!1;const h=Le(e,n,p,{mode:"state"});r=T.addColumnAfter(h,e.view.dispatch)}if(!r)return!1;const s=ge(e,t+1,"column",n);if(s.cells.length===0)return!1;const{state:i,view:a}=e,c=i.tr,d=[...s.cells].reverse(),f=[...o.cells].reverse();return d.forEach((p,h)=>{const C=f[h];if(p.node&&C?.node){const g=p.node.type.create({...C.node.attrs},C.node.content,C.node.marks),b=p.pos+p.node.nodeSize;c.replaceWith(p.pos,b,g)}}),c.docChanged?(a.dispatch(c),En(e,"column",t+1,n),!0):!1}catch(o){return console.error("Error duplicating column:",o),!1}}function B2({editor:e,index:t,orientation:n,tablePos:o}){if(!Dn({editor:e,index:t,orientation:n,tablePos:o})||!e||!ne(e,o))return!1;const s=Q(e,t,n,o);if(!s)return!1;try{return s.orientation==="row"?H2({editor:e,index:s.index,tablePos:o}):s.orientation==="column"?V2({editor:e,index:s.index,tablePos:o}):!1}catch(i){return console.error("Error duplicating row/column:",i),!1}}function D2({editor:e,index:t,orientation:n,hideWhenUnavailable:o}){return!e||!e.isEditable||!_(e,Nl)?!1:o?Dn({editor:e,index:t,orientation:n}):!0}function Hl(e){const{editor:t,index:n,orientation:o,tablePos:r,hideWhenUnavailable:s=!1,onDuplicated:i}=e,{editor:a}=k(t),c=D(),d=Q(a,n,o),f=D2({editor:a,index:n,orientation:o,hideWhenUnavailable:s}),p=Dn({editor:a,index:n,tablePos:r,orientation:o}),h=u.useCallback(()=>{const b=B2({editor:a,index:n,orientation:o,tablePos:r});return b&&i?.(),b},[a,n,o,r,i]),C=u.useMemo(()=>d?.orientation==="column"?c.duplicateColumn:c.duplicateRow,[c.duplicateColumn,c.duplicateRow,d]);return{isVisible:f,canDuplicateRowColumn:p,handleDuplicate:h,label:C,Icon:Bn}}const U2=u.forwardRef(({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:r=!1,onMoved:s,text:i,onClick:a,children:c,...d},f)=>{const{editor:p}=k(e),{isVisible:h,handleMove:C,label:g,canMoveRowColumn:b,Icon:m}=pt({editor:p,index:t,orientation:n,direction:o,hideWhenUnavailable:r,onMoved:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:w,...d,ref:f,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),i&&l.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});U2.displayName="TableMoveRowColumnButton";const Un=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M12.7071 5.70711C13.0976 5.31658 13.0976 4.68342 12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071L11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071C13.0976 19.3166 13.0976 18.6834 12.7071 18.2929L7.41421 13L19 13C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11L7.41421 11L12.7071 5.70711Z",fill:"currentColor"})}));Un.displayName="ArrowLeftIcon";const Vl=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289C10.9024 4.68342 10.9024 5.31658 11.2929 5.70711L16.5858 11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H16.5858L11.2929 18.2929C10.9024 18.6834 10.9024 19.3166 11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071L19.7071 12.7071C20.0976 12.3166 20.0976 11.6834 19.7071 11.2929L12.7071 4.29289Z",fill:"currentColor"})}));Vl.displayName="ArrowRightIcon";const On=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071C4.68342 13.0976 5.31658 13.0976 5.70711 12.7071L11 7.41421V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V7.41421L18.2929 12.7071C18.6834 13.0976 19.3166 13.0976 19.7071 12.7071C20.0976 12.3166 20.0976 11.6834 19.7071 11.2929L12.7071 4.29289Z",fill:"currentColor"})}));On.displayName="ArrowUpIcon";const Bl=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M12.707 19.707C12.3165 20.0976 11.6835 20.0976 11.293 19.707L4.29297 12.707C3.90245 12.3165 3.90245 11.6835 4.29297 11.293C4.68349 10.9024 5.31651 10.9024 5.70703 11.293L11 16.5859L11 5C11 4.44771 11.4477 4 12 4C12.5523 4 13 4.44771 13 5L13 16.5859L18.293 11.293C18.6835 10.9024 19.3165 10.9024 19.707 11.293C20.0976 11.6835 20.0976 12.3165 19.707 12.707L12.707 19.707Z",fill:"currentColor"})}));Bl.displayName="ArrowDownIcon";const Dl=["tableHandleExtension"],O2={up:On,down:Bl,left:Un,right:Vl};function P2(e,t,n){try{return T.columnIsHeader(e,t,n)}catch{return!1}}function W2(e,t,n){try{return T.rowIsHeader(e,t,n)}catch{return!1}}function Ul(e){return e==="up"||e==="left"?"previous":"next"}function Pn(e,t){return e==="row"?t==="up"||t==="down":e==="column"?t==="left"||t==="right":!1}function Wn({editor:e,index:t,orientation:n,direction:o,tablePos:r}){if(!e||!e.isEditable||!_(e,Dl))return!1;try{const s=ne(e,r);if(!s)return!1;const i=Q(e,t,n);if(!i)return!1;const{orientation:a,index:c}=i;if(!Pn(a,o))return!1;const d=Mt(s.map,c,a);if(d.length===0)return!1;if(a==="row"){if(d.some(m=>W2(s.map,s.node,m)))return!1}else if(d.some(m=>P2(s.map,s.node,m)))return!1;const{width:f,height:p}=s.map,h=Cl(s.map,c,a,Ul(o)),C=a==="row"?p:f;if(h===null||h<0||h>=C)return!1;const g=Ke({editor:e,index:h,orientation:a,tablePos:r});return!g||!Le(e,s.pos,g,{mode:"state"})?!1:a==="row"?o==="up"?d[0]>0:d[d.length-1]<p-1:o==="left"?d[0]>0:d[d.length-1]<f-1}catch{return!1}}function _2({editor:e,index:t,orientation:n,direction:o,tablePos:r}){if(!Wn({editor:e,index:t,orientation:n,direction:o,tablePos:r})||!e)return!1;try{const s=ne(e,r);if(!s)return!1;const i=Q(e,t,n);if(!i)return!1;const{orientation:a,index:c}=i;if(!Pn(a,o))return!1;const f=Mt(s.map,c,a)[0],p=Cl(s.map,c,a,Ul(o));if(f===void 0||p===null)return!1;const h=a==="row"?T.moveTableRow:T.moveTableColumn,C=g=>e.view.dispatch(g);if(e.state.selection instanceof T.CellSelection)return h({from:f,to:p,select:!0,pos:s.start})(e.state,C);{const g=Ke({editor:e,index:f,orientation:a,tablePos:r});if(!g)return!1;const b=Le(e,s.pos,g,{mode:"state"});return b?h({from:f,to:p,select:!0,pos:s.start})(b,C):!1}}catch(s){return console.error("Error moving table row/column:",s),!1}}function Z2({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:r,tablePos:s}){if(!e||!e.isEditable||!_(e,Dl))return!1;const i=Q(e,t,n);return!i||!Pn(i.orientation,o)?!1:r?Wn({editor:e,index:t,orientation:n,direction:o,tablePos:s}):!0}function pt(e){const{editor:t,index:n,orientation:o,tablePos:r,direction:s,hideWhenUnavailable:i=!1,onMoved:a}=e,{editor:c}=k(t),d=D(),f=Q(c,n,o),p=Z2({editor:c,index:n,orientation:o,direction:s,hideWhenUnavailable:i,tablePos:r}),h=Wn({editor:c,index:n,orientation:o,direction:s,tablePos:r}),C=u.useCallback(()=>{const m=_2({editor:c,index:n,orientation:o,direction:s,tablePos:r});return m&&a?.(),m},[c,n,o,s,r,a]),g=u.useMemo(()=>f?.orientation==="column"?s==="left"?d.moveColumnLeft:d.moveColumnRight:s==="up"?d.moveRowUp:d.moveRowDown,[s,d.moveColumnLeft,d.moveColumnRight,d.moveRowDown,d.moveRowUp,f]),b=u.useMemo(()=>O2[s],[s]);return{isVisible:p,canMoveRowColumn:h,handleMove:C,label:g,Icon:b}}const F2=u.forwardRef(({editor:e,index:t,orientation:n,hideWhenUnavailable:o=!1,resetAttrs:r=!1,onCleared:s,text:i,onClick:a,children:c,...d},f)=>{const{editor:p}=k(e),{isVisible:h,handleClear:C,label:g,canClearRowColumnContent:b,Icon:m}=Qe({editor:p,index:t,orientation:n,hideWhenUnavailable:o,resetAttrs:r,onCleared:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:w,...d,ref:f,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),i&&l.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});F2.displayName="TableClearRowColumnContentButton";const Ol=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H19C19.5523 20 20 19.5523 20 19V5C20 4.44772 19.5523 4 19 4H5ZM2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM15.7071 8.29289C16.0976 8.68342 16.0976 9.31658 15.7071 9.70711L13.4142 12L15.7071 14.2929C16.0976 14.6834 16.0976 15.3166 15.7071 15.7071C15.3166 16.0976 14.6834 16.0976 14.2929 15.7071L12 13.4142L9.70711 15.7071C9.31658 16.0976 8.68342 16.0976 8.29289 15.7071C7.90237 15.3166 7.90237 14.6834 8.29289 14.2929L10.5858 12L8.29289 9.70711C7.90237 9.31658 7.90237 8.68342 8.29289 8.29289C8.68342 7.90237 9.31658 7.90237 9.70711 8.29289L12 10.5858L14.2929 8.29289C14.6834 7.90237 15.3166 7.90237 15.7071 8.29289Z",fill:"currentColor"})}));Ol.displayName="SquareXIcon";const Pl=["table"],Wl={backgroundColor:null,nodeVerticalAlign:null,nodeTextAlign:null};function _l(e){try{return Zc(Wl)(e.state,e.view.dispatch)}catch(t){return console.error("Error resetting cell attributes:",t),!1}}function _n({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!_(e,Pl))return!1;try{if(!ne(e,o))return!1;const s=Q(e,t,n,o);if(s){const i=ge(e,s.index,s.orientation,o);return i.cells.length===0?!1:i.cells.some(a=>a.node&&!Oe(a.node))}else{const{selection:i}=e.state;if(i instanceof T.CellSelection){let f=!1;return i.forEachCell(p=>{Oe(p)||(f=!0)}),f}const{$anchor:a}=i,c=T.cellAround(a);if(!c)return!1;const d=e.state.doc.nodeAt(c.pos);return d?!Oe(d):!1}}catch{return!1}}function z2(e,t=!1){try{const{selection:n}=e.state;if(n instanceof T.CellSelection)return t&&_l(e),T.deleteCellSelection(e.state,e.view.dispatch),!0;const{$anchor:o}=n,r=T.cellAround(o);if(!r)return!1;const s=e.state.doc.nodeAt(r.pos);if(!s)return!1;const i=r.pos+1,a=r.pos+s.nodeSize-1;return i>=a?!1:(t&&_l(e),e.view.dispatch(e.state.tr.delete(i,a)),!0)}catch(n){return console.error("Error clearing selected cells:",n),!1}}function $2({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:r=!1}){try{const{state:s,view:i}=e,a=s.tr,c=ge(e,t,n,o);return c.cells.length===0?!1:([...c.cells].reverse().forEach(f=>{if(f.node&&!Oe(f.node)){const p=f.pos+1,h=f.pos+f.node.nodeSize-1;p<h&&a.delete(p,h),r&&a.setNodeMarkup(f.pos,null,{...f.node.attrs,...Wl})}}),a.docChanged?(i.dispatch(a),!0):!1)}catch(s){return console.error(`Error clearing ${n} content:`,s),!1}}function q2({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:r=!1}){if(!_n({editor:e,index:t,orientation:n,tablePos:o})||!e)return!1;try{const s=Q(e,t,n,o);return s?$2({editor:e,index:s.index,orientation:s.orientation,resetAttrs:r,tablePos:o}):z2(e,r)}catch(s){return console.error("Error clearing table content:",s),!1}}function G2({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:r}){if(!e||!e.isEditable||!_(e,Pl)||!ne(e,o))return!1;const i=Q(e,t,n,o),{selection:a}=e.state,c=a instanceof T.CellSelection||T.cellAround(a.$anchor);return!i&&!c?!1:r?_n({editor:e,index:t,orientation:n,tablePos:o}):!0}function Qe(e={}){const{editor:t,index:n,orientation:o,tablePos:r,hideWhenUnavailable:s=!1,resetAttrs:i=!1,onCleared:a}=e,{editor:c}=k(t),d=D(),f=Q(c,n,o,r),p=G2({editor:c,index:n,orientation:o,tablePos:r,hideWhenUnavailable:s}),h=_n({editor:c,index:n,orientation:o,tablePos:r}),C=u.useCallback(()=>{const m=q2({editor:c,index:n,orientation:o,tablePos:r,resetAttrs:i});return m&&a?.(),m},[c,n,o,r,i,a]),g=u.useMemo(()=>f?f.orientation==="column"?d.clearColumnContents:d.clearRowContents:d.clearContents,[d.clearColumnContents,d.clearContents,d.clearRowContents,f]);return{isVisible:p,canClearRowColumnContent:h,handleClear:C,label:g,Icon:Ol}}const K2=u.forwardRef(({editor:e,index:t,orientation:n,hideWhenUnavailable:o=!1,onToggled:r,text:s,onClick:i,children:a,...c},d)=>{const{editor:f}=k(e),{isVisible:p,handleToggle:h,label:C,canToggleHeader:g,Icon:b,isActive:m}=Fn({editor:f,index:t,orientation:n,hideWhenUnavailable:o,onToggled:r}),w=u.useCallback(v=>{i?.(v),!v.defaultPrevented&&h()},[h,i]);return p?l.jsx(M,{type:"button",disabled:!g,variant:"ghost","data-active-state":m?"on":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":C,"aria-pressed":m,tooltip:C,onClick:w,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(b,{className:"tiptap-button-icon"}),s&&l.jsx("span",{className:"tiptap-button-text",children:s})]})}):null});K2.displayName="TableHeaderRowColumnButton";const Zl=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 5V7V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19V7V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5ZM20 19V8H16V20H19C19.5523 20 20 19.5523 20 19ZM14 20L14 8H10L10 20H14ZM8 20L8 8H4V19C4 19.5523 4.44772 20 5 20H8Z",fill:"currentColor"})}));Zl.displayName="TableHeaderRowIcon";const Fl=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 19V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19ZM8 20V16H20V19C20 19.5523 19.5523 20 19 20H8ZM8 14L20 14V10L8 10V14ZM20 8L8 8V4H19C19.5523 4 20 4.44772 20 5V8Z",fill:"currentColor"})}));Fl.displayName="TableHeaderColumnIcon";const zl=["table"],Y2={row:Zl,column:Fl};function Zn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!_(e,zl))return!1;const r=Q(e,t,n,o);return r?r.index===0:!1}function j2({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!Zn({editor:e,index:t,orientation:n,tablePos:o}))return!1;try{const r=Q(e,t,n,o);if(!r)return!1;const s=r.orientation==="row";if(e.state.selection instanceof T.CellSelection)return s?e.commands.toggleHeaderRow():e.commands.toggleHeaderColumn();if(!X(o))return!1;const i=Ke({editor:e,index:r.index,orientation:r.orientation,tablePos:o});if(!i)return!1;const a=Le(e,o,i,{mode:"state"});if(!a)return!1;const c=d=>e.view.dispatch(d);return s?T.toggleHeader("row")(a,c):T.toggleHeader("column")(a,c)}catch{return!1}}function X2({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:r}){return!e||!e.isEditable||!_(e,zl)?!1:o?Zn({editor:e,index:t,orientation:n,tablePos:r}):!!Q(e,t,n)}function Fn(e){const{editor:t,index:n,orientation:o,tablePos:r,hideWhenUnavailable:s=!1,onToggled:i}=e,{editor:a}=k(t),c=D(),d=Q(a,n,o),f=X2({editor:a,index:n,orientation:o,hideWhenUnavailable:s,tablePos:r}),p=Zn({editor:a,index:n,orientation:o,tablePos:r});let h=!1;if(a?.state.selection instanceof T.CellSelection)h=a?.isActive("tableHeader")||!1;else{const m=ge(a,n,d?.orientation,r);if(m){const w=m.cells.length>1?1:0;h=m.cells[w]?.node?.type.name==="tableHeader"||!1}}const C=u.useCallback(()=>{const m=j2({editor:a,index:n,orientation:o,tablePos:r});return m&&i?.(),m},[a,n,o,r,i]),g=u.useMemo(()=>d?.orientation==="column"?c.headerColumn:c.headerRow,[c.headerColumn,c.headerRow,d]),b=Y2[d?.orientation||"row"];return{isVisible:f,canToggleHeader:p,handleToggle:C,label:g,Icon:b,isActive:h}}const J2=u.forwardRef(({editor:e,index:t,orientation:n,side:o,tablePos:r,hideWhenUnavailable:s=!1,onAdded:i,text:a,onClick:c,children:d,...f},p)=>{const{editor:h}=k(e),{isVisible:C,handleAdd:g,label:b,canAddRowColumn:m,Icon:w}=Pe({editor:h,index:t,orientation:n,side:o,tablePos:r,hideWhenUnavailable:s,onAdded:i}),v=u.useCallback(y=>{c?.(y),!y.defaultPrevented&&g()},[g,c]);return C?l.jsx(M,{type:"button",disabled:!m,variant:"ghost","data-active-state":"off","data-disabled":!m,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":!1,tooltip:b,onClick:v,...f,ref:p,children:d??l.jsxs(l.Fragment,{children:[l.jsx(w,{className:"tiptap-button-icon"}),a&&l.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});J2.displayName="TableAddRowColumnButton";const $l=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 2C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H15C13.3431 22 12 20.6569 12 19V5C12 3.34315 13.3431 2 15 2H19ZM14 19C14 19.5523 14.4477 20 15 20H19C19.5523 20 20 19.5523 20 19V13H14V19ZM15 4C14.4477 4 14 4.44772 14 5V11H20V5C20 4.44772 19.5523 4 19 4H15Z",fill:"currentColor"}),l.jsx("path",{d:"M6 8C6.55228 8 7 8.44772 7 9V11H9C9.55228 11 10 11.4477 10 12C10 12.5523 9.55228 13 9 13H7V15C7 15.5523 6.55228 16 6 16C5.44772 16 5 15.5523 5 15V13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H5V9C5 8.44772 5.44772 8 6 8Z",fill:"currentColor"})]}));$l.displayName="AddColLeftIcon";const ql=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 2C10.6569 2 12 3.34315 12 5V19C12 20.6569 10.6569 22 9 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2H9ZM4 19C4 19.5523 4.44772 20 5 20H9C9.55228 20 10 19.5523 10 19V13H4V19ZM5 4C4.44772 4 4 4.44772 4 5V11H10V5C10 4.44772 9.55228 4 9 4H5Z",fill:"currentColor"}),l.jsx("path",{d:"M18 8C18.5523 8 19 8.44772 19 9V11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H19V15C19 15.5523 18.5523 16 18 16C17.4477 16 17 15.5523 17 15V13H15C14.4477 13 14 12.5523 14 12C14 11.4477 14.4477 11 15 11H17V9C17 8.44772 17.4477 8 18 8Z",fill:"currentColor"})]}));ql.displayName="AddColRightIcon";const Gl=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M12 14C12.5523 14 13 14.4477 13 15V17H15C15.5523 17 16 17.4477 16 18C16 18.5523 15.5523 19 15 19H13V21C13 21.5523 12.5523 22 12 22C11.4477 22 11 21.5523 11 21V19H9C8.44772 19 8 18.5523 8 18C8 17.4477 8.44772 17 9 17H11V15C11 14.4477 11.4477 14 12 14Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 2C20.6569 2 22 3.34315 22 5V9C22 10.6569 20.6569 12 19 12H5C3.34315 12 2 10.6569 2 9V5C2 3.34315 3.34315 2 5 2H19ZM5 4C4.44772 4 4 4.44772 4 5V9C4 9.55228 4.44772 10 5 10H11V4H5ZM13 10H19C19.5523 10 20 9.55228 20 9V5C20 4.44772 19.5523 4 19 4H13V10Z",fill:"currentColor"})]}));Gl.displayName="AddRowBottomIcon";const Kl=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 12C20.6569 12 22 13.3431 22 15V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V15C2 13.3431 3.34315 12 5 12H19ZM5 14C4.44772 14 4 14.4477 4 15V19C4 19.5523 4.44772 20 5 20H11V14H5ZM13 20H19C19.5523 20 20 19.5523 20 19V15C20 14.4477 19.5523 14 19 14H13V20Z",fill:"currentColor"}),l.jsx("path",{d:"M12 2C12.5523 2 13 2.44772 13 3V5H15C15.5523 5 16 5.44772 16 6C16 6.55228 15.5523 7 15 7H13V9C13 9.55228 12.5523 10 12 10C11.4477 10 11 9.55228 11 9V7H9C8.44772 7 8 6.55228 8 6C8 5.44772 8.44772 5 9 5H11V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor"})]}));Kl.displayName="AddRowTopIcon";const Yl=["table"];function Q2(e,t,n){try{return T.columnIsHeader(e,t,n)}catch{return!1}}function R2(e,t,n){try{return T.rowIsHeader(e,t,n)}catch{return!1}}function zn({editor:e,index:t,orientation:n,tablePos:o,side:r}){if(!e||!e.isEditable||!_(e,Yl))return!1;const s=ne(e,o);if(!s)return!1;const i=Q(e,t,n);if(!i)return!1;const{map:a,node:c}=s,d=i.index,f=i.orientation;return!(typeof d!="number"||d<0||f==="column"&&d>=a.width||f==="row"&&d>=a.height||r==="left"&&f==="column"&&Q2(a,c,d)||r==="above"&&f==="row"&&R2(a,c,d))}function ed(e,t,n){return t==="row"?n==="above"?e:e+1:n==="left"?e:e+1}function td({editor:e,index:t,orientation:n,side:o,tablePos:r}){if(!zn({editor:e,index:t,orientation:n,tablePos:r,side:o})||!e)return!1;const s=Q(e,t,n);if(!s)return!1;const{orientation:i,index:a}=s,c=i==="row",d=p=>e.view.dispatch(p),f=c?o==="above"?T.addRowBefore:T.addRowAfter:o==="left"?T.addColumnBefore:T.addColumnAfter;try{let p=!1;if(e.state.selection instanceof T.CellSelection)p=f(e.state,d);else{const h=ne(e,r);if(!h)return!1;const C=i==="row"?{row:a,col:0}:{row:0,col:a},g=Le(e,h.pos,[C],{mode:"state"});if(!g)return!1;p=f(g,d)}if(p){const h=ed(a,i,o);En(e,i,h,r)}return p}catch(p){return console.error("Error adding row/column:",p),!1}}function nd({editor:e,index:t,orientation:n,tablePos:o,side:r,hideWhenUnavailable:s}){return!e||!e.isEditable||!_(e,Yl)?!1:s?zn({editor:e,index:t,orientation:n,tablePos:o,side:r}):!!Q(e,t,n)}function Pe(e){const{editor:t,index:n,orientation:o,side:r,tablePos:s,hideWhenUnavailable:i=!1,onAdded:a}=e,{editor:c}=k(t),d=D(),f=Q(c,n,o),p=nd({editor:c,index:n,orientation:o,tablePos:s,side:r,hideWhenUnavailable:i}),h=zn({editor:c,index:n,orientation:o,tablePos:s,side:r}),C=u.useCallback(()=>{const m=td({editor:c,index:n,orientation:o,tablePos:s,side:r});return m&&a?.(),m},[c,n,o,s,r,a]),g=f?.orientation==="row"?r==="above"?d.insertRowAbove:d.insertRowBelow:r==="left"?d.insertColumnLeft:d.insertColumnRight,b=f?.orientation==="row"?r==="above"?Kl:Gl:r==="left"?$l:ql;return{isVisible:p,canAddRowColumn:h,handleAdd:C,label:g,Icon:b}}const od=u.forwardRef(({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:r=!1,onDeleted:s,text:i,onClick:a,children:c,...d},f)=>{const{editor:p}=k(e),{isVisible:h,handleDelete:C,label:g,canDeleteRowColumn:b,Icon:m}=qn({editor:p,index:t,orientation:n,tablePos:o,hideWhenUnavailable:r,onDeleted:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:w,...d,ref:f,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),i&&l.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});od.displayName="TableDeleteRowColumnButton";const ht=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z",fill:"currentColor"})}));ht.displayName="TrashIcon";const jl=["table"];function $n({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!_(e,jl))return!1;try{return!(!ne(e,o)||!Q(e,t,n))}catch{return!1}}function rd({editor:e,index:t,orientation:n,tablePos:o}){if(!$n({editor:e,index:t,orientation:n,tablePos:o})||!e)return!1;try{const r=Q(e,t,n);if(!r)return!1;const{orientation:s,index:i}=r,a=s==="row",c=C=>e.view.dispatch(C),d=a?T.deleteRow:T.deleteColumn;if(e.state.selection instanceof T.CellSelection)return d(e.state,c);const f=ne(e,o);if(!f)return!1;const p=a?{row:i,col:0}:{row:0,col:i},h=Le(e,f.pos,[p],{mode:"state"});return h?d(h,c):!1}catch(r){return console.error("Error deleting table row/column:",r),!1}}function ld({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:r}){return!e||!e.isEditable||!_(e,jl)?!1:o?$n({editor:e,index:t,orientation:n,tablePos:r}):!0}function qn(e){const{editor:t,index:n,orientation:o,tablePos:r,hideWhenUnavailable:s=!1,onDeleted:i}=e,{editor:a}=k(t),c=D(),d=Q(a,n,o),f=ld({editor:a,index:n,orientation:o,hideWhenUnavailable:s}),p=$n({editor:a,index:n,orientation:o,tablePos:r}),h=u.useCallback(()=>{const g=rd({editor:a,index:n,orientation:o,tablePos:r});return g&&i?.(),g},[a,n,o,r,i]),C=u.useMemo(()=>d?.orientation==="column"?c.deleteColumn:c.deleteRow,[c.deleteColumn,c.deleteRow,d]);return{isVisible:f,canDeleteRowColumn:p,handleDelete:h,label:C,Icon:ht}}const sd=u.forwardRef(({editor:e,index:t,orientation:n,direction:o,hideWhenUnavailable:r=!1,onSorted:s,text:i,onClick:a,children:c,...d},f)=>{const{editor:p}=k(e),{isVisible:h,handleSort:C,label:g,canSortRowColumn:b,Icon:m}=Yn({editor:p,index:t,orientation:n,direction:o,hideWhenUnavailable:r,onSorted:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":!1,tooltip:g,onClick:w,...d,ref:f,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),i&&l.jsx("span",{className:"tiptap-button-text",children:i})]})}):null});sd.displayName="TableSortRowColumnButton";const Gn=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M7.00017 3C7.55242 3.00004 8.00017 3.44774 8.00017 4V17.5859L10.2931 15.293C10.6837 14.9025 11.3167 14.9025 11.7072 15.293C12.0976 15.6835 12.0976 16.3165 11.7072 16.707L7.7072 20.707C7.66067 20.7536 7.60881 20.7944 7.55388 20.8311C7.51475 20.8572 7.47445 20.8804 7.43279 20.9004C7.38729 20.9223 7.34018 20.9412 7.29118 20.9561C7.27445 20.9611 7.25734 20.9646 7.2404 20.9688C7.2248 20.9726 7.20941 20.9774 7.19353 20.9805C7.18643 20.9819 7.17916 20.9822 7.17204 20.9834C7.1161 20.9931 7.05889 21 7.00017 21L6.89763 20.9951C6.87615 20.9929 6.85521 20.9879 6.83415 20.9844C6.82375 20.9826 6.81326 20.9816 6.8029 20.9795C6.7914 20.9772 6.78008 20.9744 6.76872 20.9717C6.74815 20.9668 6.72749 20.9622 6.7072 20.9561C6.65855 20.9412 6.61176 20.9222 6.56658 20.9004C6.5247 20.8802 6.48381 20.8574 6.4445 20.8311C6.39008 20.7946 6.3393 20.7532 6.29314 20.707L2.29314 16.707C1.90261 16.3165 1.90261 15.6835 2.29314 15.293C2.68367 14.9025 3.3167 14.9025 3.7072 15.293L6.00017 17.5859V4C6.00017 3.44772 6.44788 3 7.00017 3Z",fill:"currentColor"}),l.jsx("path",{d:"M20.1437 13.0107C20.4734 13.0585 20.7615 13.2687 20.9054 13.5762C21.0699 13.9275 21.0171 14.3426 20.7687 14.6406L17.1359 19H20.0002C20.5524 19 21.0002 19.4477 21.0002 20C21.0002 20.5523 20.5524 21 20.0002 21H15.0002C14.6122 21 14.2595 20.7752 14.0949 20.4238C13.9304 20.0725 13.9832 19.6574 14.2316 19.3594L17.8644 15H15.0002C14.4479 15 14.0002 14.5523 14.0002 14C14.0002 13.4477 14.4479 13 15.0002 13H20.0002L20.1437 13.0107Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.5002 3C18.4284 3.00002 19.3184 3.36903 19.9748 4.02539C20.6311 4.68176 21.0002 5.57176 21.0002 6.5V10C21.0002 10.5523 20.5524 11 20.0002 11C19.4479 11 19.0002 10.5523 19.0002 10V9H16.0002V10C16.0002 10.5523 15.5524 11 15.0002 11C14.4479 11 14.0002 10.5523 14.0002 10V6.5C14.0002 5.57174 14.3692 4.68177 15.0256 4.02539C15.6819 3.36904 16.5719 3 17.5002 3ZM17.5002 5C17.1024 5 16.7209 5.15817 16.4396 5.43945C16.1583 5.72076 16.0002 6.10218 16.0002 6.5V7H19.0002V6.5C19.0002 6.10219 18.842 5.72075 18.5607 5.43945C18.2794 5.15817 17.898 5.00002 17.5002 5Z",fill:"currentColor"})]}));Gn.displayName="ArrowDownAZIcon";const Xl=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M7.00017 3C7.55242 3.00004 8.00017 3.44774 8.00017 4V17.5859L10.2931 15.293C10.6837 14.9025 11.3167 14.9025 11.7072 15.293C12.0976 15.6835 12.0976 16.3165 11.7072 16.707L7.7072 20.707C7.66067 20.7536 7.60881 20.7944 7.55388 20.8311C7.51475 20.8572 7.47445 20.8804 7.43279 20.9004C7.38729 20.9223 7.34018 20.9412 7.29118 20.9561C7.27445 20.9611 7.25734 20.9646 7.2404 20.9688C7.2248 20.9726 7.20941 20.9774 7.19353 20.9805C7.18643 20.9819 7.17916 20.9822 7.17204 20.9834C7.1161 20.9931 7.05889 21 7.00017 21L6.89763 20.9951C6.87615 20.9929 6.85521 20.9879 6.83415 20.9844C6.82375 20.9826 6.81326 20.9816 6.8029 20.9795C6.7914 20.9772 6.78008 20.9744 6.76872 20.9717C6.74815 20.9668 6.72749 20.9622 6.7072 20.9561C6.65855 20.9412 6.61176 20.9222 6.56658 20.9004C6.5247 20.8802 6.48381 20.8574 6.4445 20.8311C6.39008 20.7946 6.3393 20.7532 6.29314 20.707L2.29314 16.707C1.90261 16.3165 1.90261 15.6835 2.29314 15.293C2.68367 14.9025 3.3167 14.9025 3.7072 15.293L6.00017 17.5859V4C6.00017 3.44772 6.44788 3 7.00017 3Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.5002 13C18.4284 13 19.3184 13.369 19.9748 14.0254C20.6311 14.6818 21.0002 15.5718 21.0002 16.5V20C21.0002 20.5523 20.5524 21 20.0002 21C19.4479 21 19.0002 20.5523 19.0002 20V19H16.0002V20C16.0002 20.5523 15.5524 21 15.0002 21C14.4479 21 14.0002 20.5523 14.0002 20V16.5C14.0002 15.5717 14.3692 14.6818 15.0256 14.0254C15.6819 13.369 16.5719 13 17.5002 13ZM17.5002 15C17.1024 15 16.7209 15.1582 16.4396 15.4395C16.1583 15.7208 16.0002 16.1022 16.0002 16.5V17H19.0002V16.5C19.0002 16.1022 18.842 15.7208 18.5607 15.4395C18.2794 15.1582 17.898 15 17.5002 15Z",fill:"currentColor"}),l.jsx("path",{d:"M20.1437 3.01074C20.4734 3.05854 20.7615 3.26875 20.9054 3.57617C21.0699 3.9275 21.0171 4.34259 20.7687 4.64062L17.1359 9H20.0002C20.5524 9.00004 21.0002 9.44774 21.0002 10C21.0002 10.5523 20.5524 11 20.0002 11H15.0002C14.6122 11 14.2595 10.7752 14.0949 10.4238C13.9304 10.0725 13.9832 9.65742 14.2316 9.35938L17.8644 5H15.0002C14.4479 5 14.0002 4.55228 14.0002 4C14.0002 3.44772 14.4479 3 15.0002 3H20.0002L20.1437 3.01074Z",fill:"currentColor"})]}));Xl.displayName="ArrowDownZAIcon";const Jl=["tableHandleExtension"],id={asc:Gn,desc:Xl};function Ql(e){return e?e.type.name==="tableHeader"||e.type.name==="table_header"||e.attrs?.header===!0:!1}function ad(e){if(!e)return"";let t="";return e.descendants(n=>(n.isText&&(t+=n.text||""),!0)),t.trim().toLowerCase()}function Kn({editor:e,index:t,orientation:n,tablePos:o}){if(!e||!e.isEditable||!_(e,Jl))return!1;try{const r=ne(e,o);if(!r)return!1;const s=ge(e,t,n,o);if(s.orientation==="row"){if(r.map.width<2)return!1}else if(r.map.height<2)return!1;return!(s.mergedCells.length>0||!s.cells.some(a=>a.node&&!Ql(a.node)&&!Oe(a.node)))}catch{return!1}}function cd({editor:e,index:t,orientation:n,direction:o,tablePos:r}){if(!Kn({editor:e,index:t,orientation:n,tablePos:r})||!e)return!1;try{const{state:s,view:i}=e,a=s.tr,c=ge(e,t,n,r);if(c.mergedCells.length>0)return console.warn(`Cannot sort ${n} ${t}: contains merged cells`),!1;if(c.cells.length<2)return!1;const d=c.cells.map((b,m)=>{const w=Ql(b.node),v=b.node?Oe(b.node):!0;return{sortText:ad(b.node),originalNode:b.node,cellInfo:b,originalIndex:m,isHeader:w,isEmpty:v}}),f=d.filter(b=>!b.isHeader);if(f.length<2)return!1;f.sort((b,m)=>{if(b.isEmpty&&!m.isEmpty)return 1;if(!b.isEmpty&&m.isEmpty)return-1;if(b.isEmpty&&m.isEmpty)return 0;const w=b.sortText.localeCompare(m.sortText,void 0,{sensitivity:"base"});return o==="asc"?w:-w});const p=[];let h=0;for(let b=0;b<d.length;b++){const m=d[b],w=c.cells[b];if(!w||!m)continue;let v=null;if(m.isHeader?v=m.originalNode:(v=f[h]?.originalNode||null,h++),v&&w.node){const x=w.node.type.create(v.attrs,v.content,v.marks);p.push(x)}else p.push(w.node)}const C=[...c.cells].reverse(),g=[...p].reverse();return C.forEach((b,m)=>{const w=g[m];if(w&&b.node){const v=b.pos+b.node.nodeSize;a.replaceWith(b.pos,v,w)}}),a.docChanged?(i.dispatch(a),!0):!1}catch(s){return console.error(`Error sorting table ${n}:`,s),!1}}function dd({editor:e,index:t,orientation:n,hideWhenUnavailable:o,tablePos:r}){return!e||!e.isEditable||!_(e,Jl)||!ne(e,r)||!Q(e,t,n,r)?!1:o?Kn({editor:e,index:t,orientation:n,tablePos:r}):!0}function Yn(e={direction:"asc"}){const{editor:t,index:n,orientation:o,tablePos:r,direction:s,hideWhenUnavailable:i=!1,onSorted:a}=e,{editor:c}=k(t),d=D(),f=Q(c,n,o),p=dd({editor:c,index:n,orientation:o,hideWhenUnavailable:i,tablePos:r}),h=Kn({editor:c,index:n,orientation:o,tablePos:r}),C=u.useCallback(()=>{const m=cd({editor:c,index:n,orientation:o,direction:s,tablePos:r});return m&&a?.(),m},[c,n,o,s,r,a]),g=u.useMemo(()=>f?.orientation==="column"?s==="asc"?d.sortColumnAsc:d.sortColumnDesc:s==="asc"?d.sortRowAsc:d.sortRowDesc,[s,d.sortColumnAsc,d.sortColumnDesc,d.sortRowAsc,d.sortRowDesc,f]),b=u.useMemo(()=>id[s]||Gn,[s]);return{isVisible:p,canSortRowColumn:h,handleSort:C,label:g,Icon:b}}function Ct({orientation:e="horizontal",size:t,style:n={},...o}){const r={...n,...e==="horizontal"&&!t&&{flex:1},...t&&{width:e==="vertical"?"1px":t,height:e==="horizontal"?"1px":t}};return l.jsx("div",{...o,style:r})}const R=u.forwardRef(({variant:e,size:t="default",appearance:n="default",trimText:o=!1,className:r,children:s,...i},a)=>l.jsx("div",{ref:a,className:`tiptap-badge ${r||""}`,"data-style":e,"data-size":t,"data-appearance":n,"data-text-trim":o?"on":"off",...i,children:s}));R.displayName="Badge";function ud({shortcutKeys:e=jn}){return l.jsx(R,{children:J({shortcutKeys:e})})}const gt=u.forwardRef(({editor:e,textColor:t,text:n,hideWhenUnavailable:o=!1,onApplied:r,showShortcut:s=!1,onClick:i,children:a,style:c,...d},f)=>{const{editor:p}=k(e),{isVisible:h,canColorText:C,isActive:g,handleColorText:b,label:m,shortcutKeys:w,Icon:v}=Rl({editor:p,textColor:t,label:n||`Color text to ${t}`,hideWhenUnavailable:o,onApplied:r}),y=u.useCallback(S=>{i?.(S),!S.defaultPrevented&&b()},[b,i]),x=u.useMemo(()=>({...c,"--color-text-button-color":t}),[t,c]);return h?l.jsx(M,{type:"button",variant:"ghost","data-active-state":g?"on":"off",role:"button",tabIndex:-1,disabled:!C,"data-disabled":!C,"aria-label":m,"aria-pressed":g,tooltip:m,onClick:y,style:x,...d,ref:f,children:a??l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tiptap-button-color-text",style:{color:t},children:l.jsx(v,{className:"tiptap-button-icon",style:{color:t,flexGrow:1}})}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(ud,{shortcutKeys:w})]})}):null});gt.displayName="ColorTextButton";function re(e="max",t=768){const[n,o]=u.useState(void 0);return u.useEffect(()=>{const r=e==="min"?`(min-width: ${t}px)`:`(max-width: ${t-1}px)`,s=window.matchMedia(r),i=a=>o(a.matches);return o(s.matches),s.addEventListener("change",i),()=>s.removeEventListener("change",i)},[e,t]),!!n}const Ht=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.8944 5.55279C12.725 5.214 12.3787 5 12 5C11.6212 5 11.2749 5.214 11.1055 5.55279L5.10555 17.5528C4.85856 18.0468 5.05878 18.6474 5.55276 18.8944C6.04674 19.1414 6.64741 18.9412 6.8944 18.4472L8.64957 14.9369C8.75862 14.9777 8.87671 15 9 15H15C15.1233 15 15.2413 14.9777 15.3504 14.9369L17.1055 18.4472C17.3525 18.9412 17.9532 19.1414 18.4472 18.8944C18.9412 18.6474 19.1414 18.0468 18.8944 17.5528L12.8944 5.55279ZM14.3819 13L12 8.23607L9.61801 13H14.3819Z",fill:"currentColor"})}));Ht.displayName="TextColorSmallIcon";const jn="mod+shift+t",Vt=[{label:"Default text",value:"var(--tt-color-text)",border:"var(--tt-color-text-contrast)"},{label:"Gray text",value:"var(--tt-color-text-gray)",border:"var(--tt-color-text-gray-contrast)"},{label:"Brown text",value:"var(--tt-color-text-brown)",border:"var(--tt-color-text-brown-contrast)"},{label:"Orange text",value:"var(--tt-color-text-orange)",border:"var(--tt-color-text-orange-contrast)"},{label:"Yellow text",value:"var(--tt-color-text-yellow)",border:"var(--tt-color-text-yellow-contrast)"},{label:"Green text",value:"var(--tt-color-text-green)",border:"var(--tt-color-text-green-contrast)"},{label:"Blue text",value:"var(--tt-color-text-blue)",border:"var(--tt-color-text-blue-contrast)"},{label:"Purple text",value:"var(--tt-color-text-purple)",border:"var(--tt-color-text-purple-contrast)"},{label:"Pink text",value:"var(--tt-color-text-pink)",border:"var(--tt-color-text-pink-contrast)"},{label:"Red text",value:"var(--tt-color-text-red)",border:"var(--tt-color-text-red-contrast)"}];function Bt(e){if(!e||!e.isEditable||!Ae("textStyle",e)||ie(e,["image"]))return!1;try{return e.can().setMark("textStyle",{color:"currentColor"})}catch{return!1}}function fd(e,t){return!e||!e.isEditable?!1:e.isActive("textStyle",{color:t})}function pd(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!Ae("textStyle",t)?!1:t.isActive("code")?!0:Bt(t):!0:!1}function Rl(e){const{editor:t,label:n,textColor:o,hideWhenUnavailable:r=!1,onApplied:s}=e,{editor:i}=k(t),a=re(),[c,d]=u.useState(!0),f=Bt(i),p=fd(i,o);u.useEffect(()=>{if(!i)return;const C=()=>{d(pd({editor:i,hideWhenUnavailable:r}))};return C(),i.on("selectionUpdate",C),()=>{i.off("selectionUpdate",C)}},[i,r]);const h=u.useCallback(()=>{if(!i||!f)return!1;if(i.state.storedMarks){const C=i.schema.marks.textStyle;C&&i.view.dispatch(i.state.tr.removeStoredMark(C))}setTimeout(()=>{F1(i);const C=i.chain().focus(void 0,{scrollIntoView:!1}).toggleMark("textStyle",{color:o}).run();return C&&s?.({color:o,label:n}),C},0)},[i,f,o,s,n]);return ue.useHotkeys(jn,C=>{C.preventDefault(),h()},{enabled:c&&f,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:c,isActive:p,handleColorText:h,canColorText:f,label:n||`Color text to ${o}`,shortcutKeys:jn,Icon:Ht}}function hd({shortcutKeys:e=Xn}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Re=u.forwardRef(({editor:e,highlightColor:t,text:n,hideWhenUnavailable:o=!1,mode:r="mark",onApplied:s,showShortcut:i=!1,onClick:a,children:c,style:d,useColorValue:f=!1,...p},h)=>{const{editor:C}=k(e),{isVisible:g,canColorHighlight:b,isActive:m,handleColorHighlight:w,label:v,shortcutKeys:y}=Ut({editor:C,highlightColor:t,useColorValue:f,label:n||`Toggle highlight (${t})`,hideWhenUnavailable:o,mode:r,onApplied:s}),x=u.useCallback(L=>{a?.(L),!L.defaultPrevented&&w()},[w,a]),S=u.useMemo(()=>({...d,"--highlight-color":t}),[t,d]);return g?l.jsx(M,{type:"button",variant:"ghost","data-active-state":m?"on":"off",role:"button",tabIndex:-1,disabled:!b,"data-disabled":!b,"aria-label":v,"aria-pressed":m,tooltip:v,onClick:x,style:S,...p,ref:h,children:c??l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tiptap-button-highlight",style:{"--highlight-color":t}}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),i&&l.jsx(hd,{shortcutKeys:y})]})}):null});Re.displayName="ColorHighlightButton";const Dt=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.7072 4.70711C15.0977 4.31658 15.0977 3.68342 14.7072 3.29289C14.3167 2.90237 13.6835 2.90237 13.293 3.29289L8.69294 7.89286L8.68594 7.9C8.13626 8.46079 7.82837 9.21474 7.82837 10C7.82837 10.2306 7.85491 10.4584 7.90631 10.6795L2.29289 16.2929C2.10536 16.4804 2 16.7348 2 17V20C2 20.5523 2.44772 21 3 21H12C12.2652 21 12.5196 20.8946 12.7071 20.7071L15.3205 18.0937C15.5416 18.1452 15.7695 18.1717 16.0001 18.1717C16.7853 18.1717 17.5393 17.8639 18.1001 17.3142L22.7072 12.7071C23.0977 12.3166 23.0977 11.6834 22.7072 11.2929C22.3167 10.9024 21.6835 10.9024 21.293 11.2929L16.6971 15.8887C16.5105 16.0702 16.2605 16.1717 16.0001 16.1717C15.7397 16.1717 15.4897 16.0702 15.303 15.8887L10.1113 10.697C9.92992 10.5104 9.82837 10.2604 9.82837 10C9.82837 9.73963 9.92992 9.48958 10.1113 9.30297L14.7072 4.70711ZM13.5858 17L9.00004 12.4142L4 17.4142V19H11.5858L13.5858 17Z",fill:"currentColor"})}));Dt.displayName="HighlighterIcon";const Xn="mod+shift+h",et=[{label:"Default background",value:"var(--tt-bg-color)",colorValue:"#ffffff",border:"var(--tt-bg-color-contrast)"},{label:"Gray background",value:"var(--tt-color-highlight-gray)",colorValue:"#f8f8f7",border:"var(--tt-color-highlight-gray-contrast)"},{label:"Brown background",value:"var(--tt-color-highlight-brown)",colorValue:"#f4eeee",border:"var(--tt-color-highlight-brown-contrast)"},{label:"Orange background",value:"var(--tt-color-highlight-orange)",colorValue:"#fbecdd",border:"var(--tt-color-highlight-orange-contrast)"},{label:"Yellow background",value:"var(--tt-color-highlight-yellow)",colorValue:"#fef9c3",border:"var(--tt-color-highlight-yellow-contrast)"},{label:"Green background",value:"var(--tt-color-highlight-green)",colorValue:"#dcfce7",border:"var(--tt-color-highlight-green-contrast)"},{label:"Blue background",value:"var(--tt-color-highlight-blue)",colorValue:"#e0f2fe",border:"var(--tt-color-highlight-blue-contrast)"},{label:"Purple background",value:"var(--tt-color-highlight-purple)",colorValue:"#f3e8ff",border:"var(--tt-color-highlight-purple-contrast)"},{label:"Pink background",value:"var(--tt-color-highlight-pink)",colorValue:"#fcf1f6",border:"var(--tt-color-highlight-pink-contrast)"},{label:"Red background",value:"var(--tt-color-highlight-red)",colorValue:"#ffe4e6",border:"var(--tt-color-highlight-red-contrast)"}];function es(e){const t=new Map(et.map(n=>[n.value,n]));return e.map(n=>t.get(n)).filter(n=>!!n)}function Cd(e,t=!1){return t&&et.find(o=>o.value===e||o.colorValue===e)?.colorValue||e}function We(e,t="mark"){if(!e||!e.isEditable)return!1;if(t==="mark")return!Ae("highlight",e)||ie(e,["image"])?!1:e.can().setMark("highlight");if(!_(e,["nodeBackground"]))return!1;try{return e.can().toggleNodeBackgroundColor("test")}catch{return!1}}function gd(e,t,n="mark"){if(!e||!e.isEditable)return!1;if(n==="mark")return t?e.isActive("highlight",{color:t}):e.isActive("highlight");if(!t)return!1;try{const{state:o}=e,{selection:r}=o,s=r.$anchor;for(let i=s.depth;i>=0;i--){const a=s.node(i);if(a&&a.attrs?.backgroundColor===t)return!0}return!1}catch{return!1}}function bd(e,t="mark"){return!e||!e.isEditable||!We(e,t)?!1:t==="mark"?e.chain().focus(void 0,{scrollIntoView:!1}).unsetMark("highlight").run():e.chain().focus(void 0,{scrollIntoView:!1}).unsetNodeBackgroundColor().run()}function md(e){const{editor:t,hideWhenUnavailable:n,mode:o}=e;if(!t)return!1;if(!n)return!0;if(!t.isEditable)return!1;if(o==="mark"){if(!Ae("highlight",t))return!1}else if(!_(t,["nodeBackground"]))return!1;return t.isActive("code")?!0:We(t,o)}function Ut(e){const{editor:t,label:n,highlightColor:o,hideWhenUnavailable:r=!1,mode:s="mark",useColorValue:i=!1,onApplied:a}=e,{editor:c}=k(t),d=D(),f=re(),p=n||d.highlightColor,[h,C]=u.useState(!0),g=We(c,s),b=o&&Cd(o,i),m=gd(c,b,s);u.useEffect(()=>{if(!c)return;const y=()=>{C(md({editor:c,hideWhenUnavailable:r,mode:s}))};return y(),c.on("selectionUpdate",y),()=>{c.off("selectionUpdate",y)}},[c,r,s]);const w=u.useCallback(()=>{if(!c||!g||!b||!p)return!1;if(s==="mark"){if(c.state.storedMarks){const y=c.schema.marks.highlight;y&&c.view.dispatch(c.state.tr.removeStoredMark(y))}return setTimeout(()=>{const y=c.chain().focus(void 0,{scrollIntoView:!1}).toggleHighlight({color:b}).run();return y&&a?.({color:b,label:p,mode:s}),y},0),!0}else{const y=c.chain().focus(void 0,{scrollIntoView:!1}).toggleNodeBackgroundColor(b).run();return y&&a?.({color:b,label:p,mode:s}),y}},[g,b,c,p,a,s]),v=u.useCallback(()=>{const y=bd(c,s);return y&&a?.({color:"",label:d.removeHighlight,mode:s}),y},[c,d.removeHighlight,a,s]);return ue.useHotkeys(Xn,y=>{y.preventDefault(),w()},{enabled:h&&g,enableOnContentEditable:!f,enableOnFormTags:!0}),{isVisible:h,isActive:m,handleColorHighlight:w,handleRemoveHighlight:v,canColorHighlight:g,label:p,shortcutKeys:Xn,Icon:Dt,mode:s}}function Ot({editor:e,containerRef:t,query:n,items:o,onSelect:r,onClose:s,orientation:i="vertical",autoSelectFirstItem:a=!0}){const[c,d]=u.useState(a?0:-1);return u.useEffect(()=>{const f=C=>{C.preventDefault(),C.stopPropagation()},p=C=>{if(!o.length)return!1;const g=()=>d(m=>m===-1?0:(m+1)%o.length),b=()=>d(m=>m===-1?o.length-1:(m-1+o.length)%o.length);switch(C.key){case"ArrowUp":return i==="horizontal"?!1:(f(C),b(),!0);case"ArrowDown":return i==="horizontal"?!1:(f(C),g(),!0);case"ArrowLeft":return i==="vertical"?!1:(f(C),b(),!0);case"ArrowRight":return i==="vertical"?!1:(f(C),g(),!0);case"Tab":return f(C),C.shiftKey?b():g(),!0;case"Home":return f(C),d(0),!0;case"End":return f(C),d(o.length-1),!0;case"Enter":return C.isComposing?!1:(f(C),c!==-1&&o[c]&&r?.(o[c]),!0);case"Escape":return f(C),s?.(),!0;default:return!1}};let h=null;if(e?h=e.view.dom:t?.current&&(h=t.current),h)return h.addEventListener("keydown",p,!0),()=>{h?.removeEventListener("keydown",p,!0)}},[e,t,o,c,r,s,i]),u.useEffect(()=>{n&&d(a?0:-1)},[n,a]),{selectedIndex:o.length?c:void 0,setSelectedIndex:d}}const Jn=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z",fill:"currentColor"})}));Jn.displayName="ChevronDownIcon";function Pt({...e}){return l.jsx(It.Root,{...e})}function Wt({...e}){return l.jsx(It.Trigger,{...e})}function _t({className:e,align:t="center",sideOffset:n=4,...o}){return l.jsx(It.Portal,{children:l.jsx(It.Content,{align:t,sideOffset:n,className:z("tiptap-popover",e),...o})})}const _e=u.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:z("tiptap-card",e),...t}));_e.displayName="Card";const wd=u.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:z("tiptap-card-header",e),...t}));wd.displayName="CardHeader";const Ze=u.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:z("tiptap-card-body",e),...t}));Ze.displayName="CardBody";const Me=u.forwardRef(({className:e,orientation:t="vertical",...n},o)=>l.jsx("div",{ref:o,"data-orientation":t,className:z("tiptap-card-item-group",e),...n}));Me.displayName="CardItemGroup";const bt=u.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:z("tiptap-card-group-label",e),...t}));bt.displayName="CardGroupLabel";const vd=u.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:z("tiptap-card-footer",e),...t}));vd.displayName="CardFooter";const yd=gn.cva("tiptap-button-group",{variants:{orientation:{horizontal:"tiptap-button-group-horizontal",vertical:"tiptap-button-group-vertical"}},defaultVariants:{orientation:"horizontal"}});function fe({className:e,orientation:t,...n}){return l.jsx("div",{role:"group","data-slot":"tiptap-button-group","data-orientation":t,className:z(yd({orientation:t}),e),...n})}function xd({colorObj:e,withLabel:t=!1,onColorChanged:n,editor:o,resolveColorValue:r,...s}){const i=e.type==="text"?Vt:et,a=ns(e.value,i),c=a.label===a.value?e.label:a.label,d=r?.({type:e.type,label:c,value:e.value})??e.value,f={tooltip:c,text:t?c:void 0,onApplied:()=>n?.({type:e.type,label:c,value:a.value}),...s};return e.type==="text"?l.jsx(gt,{textColor:d,label:c,editor:o,...f}):l.jsx(Re,{highlightColor:d,label:c,editor:o,...f})}function ts({type:e,colors:t,onColorSelected:n,selectedIndex:o,startIndexOffset:r,editor:s,resolveColorValue:i}){return t.map((a,c)=>l.jsx(fe,{children:a.map((d,f)=>{const p=r+t.slice(0,c).reduce((b,m)=>b+m.length,0)+f,h=o===p,C=i?.({type:e,label:d.label,value:d.value})??d.value,g={tooltip:d.label,onApplied:()=>n({type:e,label:d.label,value:d.value}),tabIndex:h?0:-1,"data-highlighted":h,"aria-label":`${d.label} ${e==="text"?"text":"highlight"} color`};return e==="text"?l.jsx(fe,{children:l.jsx(gt,{textColor:C,label:d.label,editor:s,...g})},`${e}-${d.value}-${f}`):l.jsx(fe,{children:l.jsx(Re,{highlightColor:C,label:d.label,editor:s,...g})},`${e}-${d.value}-${f}`)})},`${e}-group-${c}`))}function kd({recentColors:e,onColorSelected:t,selectedIndex:n,editor:o,resolveColorValue:r}){const s=D();return e.length===0?null:l.jsxs(Me,{children:[l.jsx(bt,{children:s.recentColors}),l.jsx(fe,{children:e.map((i,a)=>l.jsx(fe,{children:l.jsx(xd,{colorObj:i,onColorChanged:t,tabIndex:n===a?0:-1,"data-highlighted":n===a,editor:o,resolveColorValue:r})},`recent-${i.type}-${i.value}`))})]})}function Sd({maxColorsPerGroup:e=5,maxRecentColors:t=3,onColorChanged:n,editor:o,resolveColorValue:r}){const s=D(),{recentColors:i,addRecentColor:a,isInitialized:c}=mt(t),d=u.useRef(null),f=u.useMemo(()=>Zr(Vt,e),[e]),p=u.useMemo(()=>Zr(et,e),[e]),h=u.useMemo(()=>f.flat(),[f]),C=u.useMemo(()=>p.flat(),[p]),g=u.useMemo(()=>c?i.length:0,[c,i.length]),b=u.useMemo(()=>g+h.length,[g,h.length]),m=u.useMemo(()=>{const y=[];return c&&i.length>0&&y.push(...i.map(x=>({type:x.type,value:x.value,label:x.type==="text"?s.recentTextColor:s.recentHighlightColor,group:"recent"}))),y.push(...h.map(x=>({type:"text",value:x.value,label:x.label,group:"text"}))),y.push(...C.map(x=>({type:"highlight",value:x.value,label:x.label,group:"highlight"}))),y},[c,i,h,C]),w=u.useCallback(({type:y,label:x,value:S})=>{if(!d.current)return!1;d.current.querySelector('[data-highlighted="true"]')?.click(),a({type:y,label:x,value:S}),n?.({type:y,label:x,value:S})},[a,n]),{selectedIndex:v}=Ot({containerRef:d,items:m,onSelect:y=>{y&&w({type:y.type,label:y.label,value:y.value})},orientation:"both",autoSelectFirstItem:!1});return l.jsx(_e,{ref:d,tabIndex:0,role:"menu",children:l.jsxs(Ze,{children:[c&&l.jsx(kd,{recentColors:i,onColorSelected:w,selectedIndex:v,editor:o,resolveColorValue:r}),l.jsxs(Me,{children:[l.jsx(bt,{children:s.textColor}),l.jsx(ts,{type:"text",colors:f,onColorSelected:w,selectedIndex:v,startIndexOffset:g,editor:o,resolveColorValue:r})]}),l.jsxs(Me,{children:[l.jsx(bt,{children:s.highlightColor}),l.jsx(ts,{type:"highlight",colors:p,onColorSelected:w,selectedIndex:v,startIndexOffset:b,editor:o,resolveColorValue:r})]})]})})}function Td({editor:e,hideWhenUnavailable:t=!1,onColorChanged:n,onClick:o,children:r,ref:s,resolveColorValue:i,...a}){const{editor:c}=k(e),d=D(),[f,p]=u.useState(!1),{isVisible:h,canToggle:C,activeTextStyle:g,activeHighlight:b,handleColorChanged:m,label:w,Icon:v}=Id({editor:c,hideWhenUnavailable:t,onColorChanged:n}),y=u.useCallback(x=>{o?.(x),!x.defaultPrevented&&p(S=>!S)},[o]);return h?l.jsxs(Pt,{open:f,onOpenChange:p,children:[l.jsx(Wt,{asChild:!0,children:l.jsx(M,{type:"button",variant:"ghost","data-appearance":"default",role:"button","aria-label":w,tooltip:w,disabled:!C,"data-disabled":!C,onClick:y,ref:s,...a,children:r??l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tiptap-button-color-text-popover",style:b.color?{"--active-highlight-color":b.color}:{},children:l.jsx(v,{className:"tiptap-button-icon",style:{color:g.color||void 0}})}),l.jsx(Jn,{className:"tiptap-button-dropdown-small"})]})})}),l.jsx(_t,{"aria-label":d.textColorOptions,side:"bottom",align:"start",collisionPadding:4,children:l.jsx(Sd,{onColorChanged:m,editor:c,resolveColorValue:i})})]}):null}function ns(e,t){return t.find(n=>n.value===e)??{value:e,label:e}}function Ad(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:Bt(t)||We(t):!1:!0:!1}function mt(e=3){const[t,n]=u.useState([]),[o,r]=u.useState(!1);u.useEffect(()=>{try{const i=localStorage.getItem("tiptapRecentlyUsedColors");if(i){const a=JSON.parse(i);n(a.slice(0,e))}}catch(i){console.error("Failed to load stored colors:",i)}finally{r(!0)}},[e]);const s=u.useCallback(({type:i,label:a,value:c})=>{n(d=>{const f=d.filter(h=>!(h.type===i&&h.value===c)),p=[{type:i,label:a,value:c},...f].slice(0,e);try{localStorage.setItem("tiptapRecentlyUsedColors",JSON.stringify(p))}catch(h){console.error("Failed to store colors:",h)}return p})},[e]);return{recentColors:t,addRecentColor:s,isInitialized:o}}function Id(e){const{editor:t,hideWhenUnavailable:n=!1,onColorChanged:o}=e||{},{editor:r}=k(t),s=D(),[i,a]=u.useState(!0),c=Ae("textStyle",r),d=Ae("highlight",r),f=Fr(r,"textStyle")||{},p=Fr(r,"highlight")||{},h=Bt(r)||We(r);u.useEffect(()=>{if(!r)return;const g=()=>{a(Ad({editor:r,hideWhenUnavailable:n}))};return g(),r.on("selectionUpdate",g),()=>{r.off("selectionUpdate",g)}},[r,n,d,c]);const C=u.useCallback(({type:g,label:b,value:m})=>{o?.({type:g,label:b,value:m})},[o]);return{isVisible:i,canToggle:h,activeTextStyle:f,activeHighlight:p,handleColorChanged:C,label:s.textColor,Icon:Ht}}const Qn=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.70711 1.29289C5.31658 0.902369 4.68342 0.902369 4.29289 1.29289C3.90237 1.68342 3.90237 2.31658 4.29289 2.70711L7.08575 5.49997L1.69282 10.8929L1.68582 10.9C1.13614 11.4608 0.828247 12.2147 0.828247 13C0.828247 13.7853 1.1361 14.5392 1.68578 15.1L6.89285 20.3071C8.08338 21.4976 9.91654 21.4976 11.1071 20.3071L19.7071 11.7071C20.0976 11.3166 20.0976 10.6834 19.7071 10.2929L11.7071 2.29289C11.3165 1.90237 10.6834 1.90237 10.2929 2.29289L8.49997 4.08576L5.70711 1.29289ZM17.5857 11L16.5857 12H3.41418L8.49998 6.91419L9.29289 7.70711C9.68342 8.09763 10.3166 8.09763 10.7071 7.70711C11.0976 7.31658 11.0976 6.68342 10.7071 6.29289L9.91419 5.49998L11 4.41421L17.5857 11ZM14.5857 14H3.41418L8.30707 18.8929C8.71654 19.3024 9.28338 19.3024 9.69285 18.8929L14.5857 14Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.9829 15.8157C20.8942 15.3427 20.4812 15 20 15C19.5188 15 19.1058 15.3427 19.0171 15.8157C18.9233 16.3161 18.6226 16.706 18.1385 17.3337L18.0955 17.3895C17.6418 17.9781 17 18.8237 17 20C17 20.7957 17.3161 21.5587 17.8787 22.1213C18.4413 22.6839 19.2043 23 20 23C20.7957 23 21.5587 22.6839 22.1213 22.1213C22.6839 21.5587 23 20.7957 23 20C23 18.8237 22.3582 17.9781 21.9045 17.3895L21.8615 17.3337C21.3774 16.706 21.0767 16.3161 20.9829 15.8157ZM19 20C19 19.5763 19.2082 19.2219 19.6795 18.6105C19.714 18.5658 19.7503 18.5192 19.7881 18.4709C19.855 18.3851 19.9265 18.2935 20 18.1963C20.0735 18.2935 20.1449 18.385 20.2119 18.4708C20.2496 18.5192 20.286 18.5658 20.3205 18.6105C20.7918 19.2219 21 19.5763 21 20C21 20.2652 20.8946 20.5196 20.7071 20.7071C20.5196 20.8946 20.2652 21 20 21C19.7348 21 19.4804 20.8946 19.2929 20.7071C19.1054 20.5196 19 20.2652 19 20Z",fill:"currentColor"})]}));Qn.displayName="MoreVerticalIcon";const tt=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.29289 5.29289C8.68342 4.90237 9.31658 4.90237 9.70711 5.29289L15.7071 11.2929C16.0976 11.6834 16.0976 12.3166 15.7071 12.7071L9.70711 18.7071C9.31658 19.0976 8.68342 19.0976 8.29289 18.7071C7.90237 18.3166 7.90237 17.6834 8.29289 17.2929L13.5858 12L8.29289 6.70711C7.90237 6.31658 7.90237 5.68342 8.29289 5.29289Z",fill:"currentColor"})}));tt.displayName="ChevronRightIcon";const Ld={text:{"Default text":"defaultTextColor","Gray text":"grayTextColor","Brown text":"brownTextColor","Orange text":"orangeTextColor","Yellow text":"yellowTextColor","Green text":"greenTextColor","Blue text":"blueTextColor","Purple text":"purpleTextColor","Pink text":"pinkTextColor","Red text":"redTextColor"},highlight:{"Default background":"defaultBackgroundColor","Gray background":"grayBackgroundColor","Brown background":"brownBackgroundColor","Orange background":"orangeBackgroundColor","Yellow background":"yellowBackgroundColor","Green background":"greenBackgroundColor","Blue background":"blueBackgroundColor","Purple background":"purpleBackgroundColor","Pink background":"pinkBackgroundColor","Red background":"redBackgroundColor"}};function os(e,t,n){return e.map(o=>{const r=Ld[t][o.label];return r?{...o,label:n[r]}:o})}const rs=({editor:e,color:t})=>{const{addRecentColor:n}=mt(),{isActive:o,handleColorText:r,label:s}=Rl({editor:e,label:t.label,textColor:t.value,onApplied:({color:i,label:a})=>n({type:"text",label:a,value:i})});return l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":o?"on":"off"}),onClick:r,children:[l.jsx("span",{className:"tiptap-button-color-text",style:{color:t.value},children:l.jsx(Ht,{className:"tiptap-button-icon",style:{color:t.value,flexGrow:1}})}),l.jsx("span",{className:"tiptap-button-text",children:s})]})},ls=({editor:e,color:t})=>{const{addRecentColor:n}=mt(),{isActive:o,handleColorHighlight:r,label:s}=Ut({editor:e,label:t.label,highlightColor:t.value,mode:"node",onApplied:({color:i,label:a})=>n({type:"highlight",label:a,value:i})});return l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":o?"on":"off"}),onClick:r,children:[l.jsx("span",{className:"tiptap-button-highlight",style:{"--highlight-color":t.value}}),l.jsx("span",{className:"tiptap-button-text",children:s})]})},Ed=({editor:e,colorObj:t,textColors:n,highlightColors:o})=>{const r=t.type==="text"?n:o,s=ns(t.value,r),i=t.type==="text"?rs:ls;return l.jsx(i,{editor:e,color:s})},Rn=({editor:e,trigger:t,label:n,placement:o="right"})=>{const{editor:r}=k(e),s=D(),{recentColors:i,isInitialized:a}=mt(),c=n??s.color,d=u.useMemo(()=>os(Vt,"text",s),[s]),f=u.useMemo(()=>os(et,"highlight",s),[s]),p=!!r?.can().setMark("textStyle")||!!r?.can().setMark("highlight")||We(r,"node")||!1;if(!r||!p)return null;const h=l.jsx(Ee,{render:l.jsx(Je,{render:l.jsxs(M,{variant:"ghost",children:[l.jsx(Qn,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:c}),l.jsx(Ct,{}),l.jsx(tt,{className:"tiptap-button-icon"})]})})});return l.jsx(je,{placement:o,trigger:t||h,children:l.jsx(Xe,{portal:!0,children:l.jsxs(Ye,{children:[a&&i.length>0&&l.jsxs(de,{children:[l.jsx(ft,{children:s.recentColors}),i.map(C=>l.jsx(Ed,{editor:r,colorObj:C,textColors:d,highlightColors:f},C.value)),l.jsx(ee,{orientation:"horizontal"})]}),l.jsxs(de,{children:[l.jsx(ft,{children:s.textColor}),d.map(C=>l.jsx(rs,{editor:r,color:C},C.value))]}),l.jsx(ee,{orientation:"horizontal"}),l.jsxs(de,{children:[l.jsx(ft,{children:s.backgroundColor}),f.map(C=>l.jsx(ls,{editor:r,color:C},C.value))]})]})})})},Md=u.forwardRef(({editor:e,alignmentType:t,alignment:n,index:o,orientation:r,hideWhenUnavailable:s=!1,onAligned:i,text:a,onClick:c,children:d,...f},p)=>{const{editor:h}=k(e),{isVisible:C,handleAlign:g,label:b,canAlignCell:m,Icon:w,isActive:v}=ye({editor:h,alignmentType:t,alignment:n,index:o,orientation:r,hideWhenUnavailable:s,onAligned:i}),y=u.useCallback(x=>{c?.(x),!x.defaultPrevented&&g()},[g,c]);return C?l.jsx(M,{type:"button",disabled:!m,variant:"ghost","data-active-state":v?"on":"off","data-disabled":!m,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":v,tooltip:b,onClick:y,...f,ref:p,children:d??l.jsxs(l.Fragment,{children:[l.jsx(w,{className:"tiptap-button-icon"}),a&&l.jsx("span",{className:"tiptap-button-text",children:a})]})}):null});Md.displayName="TableAlignCellButton";const eo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H17C17.5523 17 18 17.4477 18 18C18 18.5523 17.5523 19 17 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));eo.displayName="AlignLeftIcon";const to=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 12C6 11.4477 6.44772 11 7 11H17C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13H7C6.44772 13 6 12.5523 6 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 18C4 17.4477 4.44772 17 5 17H19C19.5523 17 20 17.4477 20 18C20 18.5523 19.5523 19 19 19H5C4.44772 19 4 18.5523 4 18Z",fill:"currentColor"})]}));to.displayName="AlignCenterIcon";const no=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 18C6 17.4477 6.44772 17 7 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H7C6.44772 19 6 18.5523 6 18Z",fill:"currentColor"})]}));no.displayName="AlignRightIcon";const oo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));oo.displayName="AlignJustifyIcon";const ro=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M11 11.5858L9.70711 10.2929C9.31658 9.90237 8.68342 9.90237 8.29289 10.2929C7.90237 10.6834 7.90237 11.3166 8.29289 11.7071L11.2929 14.7071C11.6834 15.0976 12.3166 15.0976 12.7071 14.7071L15.7071 11.7071C16.0976 11.3166 16.0976 10.6834 15.7071 10.2929C15.3166 9.90237 14.6834 9.90237 14.2929 10.2929L13 11.5858V4C13 3.44771 12.5523 3 12 3C11.4477 3 11 3.44771 11 4V11.5858Z",fill:"currentColor"}),l.jsx("path",{d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));ro.displayName="AlignBottomIcon";const lo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M2 4C2 3.44772 2.44772 3 3 3H21C21.5523 3 22 3.44772 22 4C22 4.55228 21.5523 5 21 5H3C2.44772 5 2 4.55228 2 4Z",fill:"currentColor"}),l.jsx("path",{d:"M13 10.4142L14.2929 11.7071C14.6834 12.0976 15.3166 12.0976 15.7071 11.7071C16.0976 11.3166 16.0976 10.6834 15.7071 10.2929L12.7071 7.29289C12.3166 6.90237 11.6834 6.90237 11.2929 7.29289L8.29289 10.2929C7.90237 10.6834 7.90237 11.3166 8.29289 11.7071C8.68342 12.0976 9.31658 12.0976 9.70711 11.7071L11 10.4142L11 20C11 20.5523 11.4477 21 12 21C12.5523 21 13 20.5523 13 20L13 10.4142Z",fill:"currentColor"})]}));lo.displayName="AlignTopIcon";const ss=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M3 12H21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M12 22V16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M12 2L12 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M15 19L12 16L9 19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M9 5L12 8L15 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));ss.displayName="AlignMiddleIcon";const so=["table"],is={text:{left:"Align left",center:"Align center",right:"Align right",justify:"Justify"},vertical:{top:"Align top",middle:"Align middle",bottom:"Align bottom"}},as={text:{left:eo,center:to,right:no,justify:oo},vertical:{top:lo,middle:ss,bottom:ro}};function Zt(e){if(!e||!e.isEditable||!_(e,so))return!1;try{return e.isActive("tableCell")||e.isActive("tableHeader")}catch{return!1}}function io({editor:e,index:t,orientation:n}){if(!e||!e.isEditable||!_(e,so))return!1;try{return!(!ne(e)||ge(e,t,n).cells.length===0)}catch{return!1}}function Nd(e,t){if(!Zt(e)||!e)return null;try{const{selection:n}=e.state,o=n.$anchor;let r=null;for(let i=o.depth;i>=0;i--){const a=o.node(i);if(a.type.name==="tableCell"||a.type.name==="tableHeader"){r=a;break}}if(!r)return null;const s=r.attrs||{};return t==="text"?s.nodeTextAlign||"left":s.nodeVerticalAlign||"top"}catch{return null}}function Hd(e,t,n,o){if(!e)return null;try{const r=ge(e,n,o);if(r.cells.length===0)return null;const s=r.cells[0];if(!s?.node)return null;const i=s.node.attrs||{};return t==="text"?i.nodeTextAlign||"left":i.nodeVerticalAlign||"top"}catch{return null}}function Vd(e,t,n){if(!Zt(e)||!e)return!1;try{return t==="text"?e.commands.setCellAttribute("nodeTextAlign",n):e.commands.setCellAttribute("nodeVerticalAlign",n)}catch(o){return console.error("Error setting table cell alignment:",o),!1}}function Bd({editor:e,alignmentType:t,alignment:n,index:o,orientation:r}){if(!io({editor:e,index:o,orientation:r})||!e)return!1;try{const{state:s,view:i}=e,a=s.tr,c=ge(e,o,r);if(c.cells.length===0)return!1;const d=new Map;if(c.cells.forEach(h=>{h.node&&h.pos!==void 0&&d.set(h.pos,h)}),d.size===0)return!1;const f=Array.from(d.values()).sort((h,C)=>C.pos-h.pos),p=t==="text"?"nodeTextAlign":"nodeVerticalAlign";return f.forEach(h=>{if(h.node&&h.pos!==void 0){const g=h.node.type.create({...h.node.attrs,[p]:n},h.node.content,h.node.marks),b=h.pos+h.node.nodeSize;a.replaceWith(h.pos,b,g)}}),a.docChanged?(i.dispatch(a),!0):!1}catch(s){return console.error(`Error aligning table ${r}:`,s),!1}}function Dd({editor:e,alignmentType:t,alignment:n,index:o,orientation:r}){if(!e)return!1;try{return typeof o=="number"&&r?Bd({editor:e,alignmentType:t,alignment:n,index:o,orientation:r}):Vd(e,t,n)}catch(s){return console.error("Error aligning table cell:",s),!1}}function Ud({editor:e,hideWhenUnavailable:t,index:n,orientation:o}){return!e||!e.isEditable||!_(e,so)?!1:t?typeof n=="number"&&o?io({editor:e,index:n,orientation:o}):Zt(e):!0}function ye(e){const{editor:t,alignmentType:n,alignment:o,index:r,orientation:s,hideWhenUnavailable:i=!1,onAligned:a}=e,{editor:c}=k(t),d=Ud({editor:c,hideWhenUnavailable:i,index:r,orientation:s}),f=()=>typeof r=="number"&&s?io({editor:c,index:r,orientation:s}):Zt(c),p=()=>typeof r=="number"&&s?Hd(c,n,r,s):Nd(c,n),h=p()===o,C=u.useCallback(()=>{const m=Dd({editor:c,alignmentType:n,alignment:o,index:r,orientation:s});return m&&a?.(o),m},[c,n,o,r,s,a]),g=u.useMemo(()=>n==="text"?is.text[o]:is.vertical[o],[n,o]),b=u.useMemo(()=>n==="text"?as.text[o]:as.vertical[o],[n,o]);return{isVisible:d,canAlignCell:f,handleAlign:C,label:g,Icon:b,isActive:h,currentAlignment:p}}const cs=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M3 16C3.55228 16 4 16.4477 4 17V19L4.00488 19.0986C4.02757 19.3276 4.12883 19.5429 4.29297 19.707C4.48051 19.8946 4.73478 20 5 20H7C7.55228 20 8 20.4477 8 21C8 21.5523 7.55228 22 7 22H5C4.20435 22 3.44151 21.6837 2.87891 21.1211C2.3163 20.5585 2 19.7957 2 19V17C2 16.4477 2.44772 16 3 16Z",fill:"currentColor"}),l.jsx("path",{d:"M21 16C21.5523 16 22 16.4477 22 17V19C22 19.7957 21.6837 20.5585 21.1211 21.1211C20.5585 21.6837 19.7957 22 19 22H17C16.4477 22 16 21.5523 16 21C16 20.4477 16.4477 20 17 20H19C19.2652 20 19.5195 19.8946 19.707 19.707C19.8946 19.5195 20 19.2652 20 19V17C20 16.4477 20.4477 16 21 16Z",fill:"currentColor"}),l.jsx("path",{d:"M7 16C7.55228 16 8 16.4477 8 17C8 17.5523 7.55228 18 7 18C6.44772 18 6 17.5523 6 17C6 16.4477 6.44772 16 7 16Z",fill:"currentColor"}),l.jsx("path",{d:"M12 16C12.5523 16 13 16.4477 13 17C13 17.5523 12.5523 18 12 18C11.4477 18 11 17.5523 11 17C11 16.4477 11.4477 16 12 16Z",fill:"currentColor"}),l.jsx("path",{d:"M17 16C17.5523 16 18 16.4477 18 17C18 17.5523 17.5523 18 17 18C16.4477 18 16 17.5523 16 17C16 16.4477 16.4477 16 17 16Z",fill:"currentColor"}),l.jsx("path",{d:"M7 11C7.55228 11 8 11.4477 8 12C8 12.5523 7.55228 13 7 13C6.44772 13 6 12.5523 6 12C6 11.4477 6.44772 11 7 11Z",fill:"currentColor"}),l.jsx("path",{d:"M12 11C12.5523 11 13 11.4477 13 12C13 12.5523 12.5523 13 12 13C11.4477 13 11 12.5523 11 12C11 11.4477 11.4477 11 12 11Z",fill:"currentColor"}),l.jsx("path",{d:"M17 11C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13C16.4477 13 16 12.5523 16 12C16 11.4477 16.4477 11 17 11Z",fill:"currentColor"}),l.jsx("path",{d:"M7 2C7.55228 2 8 2.44772 8 3C8 3.55228 7.55228 4 7 4H5C4.73478 4 4.4805 4.10543 4.29297 4.29297C4.10543 4.4805 4 4.73478 4 5V7C4 7.55228 3.55228 8 3 8C2.44772 8 2 7.55228 2 7V5C2 4.20435 2.3163 3.44152 2.87891 2.87891C3.44152 2.3163 4.20435 2 5 2H7Z",fill:"currentColor"}),l.jsx("path",{d:"M7 6C7.55228 6 8 6.44772 8 7C8 7.55228 7.55228 8 7 8C6.44772 8 6 7.55228 6 7C6 6.44772 6.44772 6 7 6Z",fill:"currentColor"}),l.jsx("path",{d:"M12 6C12.5523 6 13 6.44772 13 7C13 7.55228 12.5523 8 12 8C11.4477 8 11 7.55228 11 7C11 6.44772 11.4477 6 12 6Z",fill:"currentColor"}),l.jsx("path",{d:"M17 6C17.5523 6 18 6.44772 18 7C18 7.55228 17.5523 8 17 8C16.4477 8 16 7.55228 16 7C16 6.44772 16.4477 6 17 6Z",fill:"currentColor"}),l.jsx("path",{d:"M19 2C19.7957 2 20.5585 2.3163 21.1211 2.87891C21.6837 3.44151 22 4.20435 22 5V7C22 7.55228 21.5523 8 21 8C20.4477 8 20 7.55228 20 7V5C20 4.73478 19.8946 4.48051 19.707 4.29297C19.5429 4.12883 19.3276 4.02757 19.0986 4.00488L19 4H17C16.4477 4 16 3.55228 16 3C16 2.44772 16.4477 2 17 2H19Z",fill:"currentColor"})]}));cs.displayName="AlignmentIcon";const ao=({index:e,orientation:t})=>{const n=D(),o={left:ye({alignmentType:"text",alignment:"left",index:e,orientation:t}),center:ye({alignmentType:"text",alignment:"center",index:e,orientation:t}),right:ye({alignmentType:"text",alignment:"right",index:e,orientation:t})},r={top:ye({alignmentType:"vertical",alignment:"top",index:e,orientation:t}),middle:ye({alignmentType:"vertical",alignment:"middle",index:e,orientation:t}),bottom:ye({alignmentType:"vertical",alignment:"bottom",index:e,orientation:t})};if(!o.left.canAlignCell())return null;const s=[n.alignLeft,n.alignCenter,n.alignRight],i=[n.alignTop,n.alignMiddle,n.alignBottom];return l.jsx(je,{placement:"right",trigger:l.jsx(Je,{render:l.jsx(Ee,{render:l.jsxs(M,{variant:"ghost",children:[l.jsx(cs,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:n.alignment}),l.jsx(T2,{render:l.jsx(tt,{})})]})})}),children:l.jsx(Xe,{portal:!0,children:l.jsx(Ye,{children:l.jsxs(de,{children:[Object.values(o).map((a,c)=>l.jsx(co,{icon:a.Icon,label:s[c],disabled:!a.canAlignCell,isActive:a.isActive,onClick:a.handleAlign},`text-${c}`)),l.jsx(ee,{orientation:"horizontal"}),Object.values(r).map((a,c)=>l.jsx(co,{icon:a.Icon,label:i[c],disabled:!a.canAlignCell,isActive:a.isActive,onClick:a.handleAlign},`vertical-${c}`))]})})})})},co=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:r=!1,shortcutBadge:s})=>l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":r?"on":"off"}),onClick:n,disabled:o,children:[l.jsx(e,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:t}),s]});co.displayName="ActionItem";const Od={row:"top-start",column:"bottom-start"},ds=u.createContext(null);function Ft(){const e=u.useContext(ds);if(!e)throw new Error("useTableHandleContext must be used within TableHandleProvider");return e}function us(e,t){const{editor:n,orientation:o,index:r,tableNode:s,tablePos:i}=Ft(),[a,c]=u.useState(!1),[d,f]=u.useState(!1),p=u.useMemo(()=>Od[o],[o]),h=u.useCallback(()=>{if(!(!n||!s||!X(i)||!X(r)))try{const{width:b,height:m}=T.TableMap.get(s),w=o==="row"?{row:r,col:0}:{row:0,col:r},v=o==="row"?{row:r,col:b-1}:{row:m-1,col:r};Le(n,i,[w,v],{mode:"dispatch",dispatch:n.view.dispatch.bind(n.view)})}catch(b){console.warn("Failed to select row/column:",b)}},[n,s,i,o,r]),C=u.useCallback(b=>{n&&(c(b),t?.(b),b?(n.commands.freezeHandles(),h(),e?.(!1)):(n.commands.unfreezeHandles(),e?.(!0)))},[n,t,e,h]),g=u.useCallback(()=>{n&&(c(!1),t?.(!1),n.commands.unfreezeHandles(),e?.(!0))},[n,t,e]);return{isMenuOpen:a,isDragging:d,setIsDragging:f,menuPlacement:p,handleMenuToggle:C,resetMenu:g}}function Pd(){const{editor:e,index:t,orientation:n,tablePos:o}=Ft(),r=qn({editor:e,index:t,orientation:n,tablePos:o}),s=Hl({editor:e,index:t,orientation:n,tablePos:o}),i=Yn({editor:e,tablePos:o,index:t,orientation:n,direction:"asc",hideWhenUnavailable:!0}),a=Yn({editor:e,tablePos:o,index:t,orientation:n,direction:"desc",hideWhenUnavailable:!0}),c=Qe({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:!0,hideWhenUnavailable:!0}),d=Fn({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:!0}),f=pt({editor:e,index:t,tablePos:o,orientation:"row",direction:"up",hideWhenUnavailable:!0}),p=pt({editor:e,index:t,tablePos:o,orientation:"row",direction:"down",hideWhenUnavailable:!0}),h=pt({editor:e,index:t,tablePos:o,orientation:"column",direction:"left",hideWhenUnavailable:!0}),C=pt({editor:e,index:t,tablePos:o,orientation:"column",direction:"right",hideWhenUnavailable:!0}),g=Pe({editor:e,index:t,tablePos:o,orientation:"row",side:"above",hideWhenUnavailable:!0}),b=Pe({editor:e,index:t,tablePos:o,orientation:"row",side:"below",hideWhenUnavailable:!0}),m=Pe({editor:e,index:t,tablePos:o,orientation:"column",side:"left",hideWhenUnavailable:!0}),w=Pe({editor:e,index:t,tablePos:o,orientation:"column",side:"right",hideWhenUnavailable:!0}),v=u.useMemo(()=>({moveUp:f,moveDown:p,moveLeft:h,moveRight:C}),[f,p,h,C]),y=u.useMemo(()=>({addAbove:g,addBelow:b,addLeft:m,addRight:w}),[g,b,m,w]),x=u.useMemo(()=>({sortAsc:i,sortDesc:a}),[i,a]),S=u.useCallback(()=>{const V=[];return x.sortAsc.isVisible&&V.push({icon:x.sortAsc.Icon,label:x.sortAsc.label,disabled:!x.sortAsc.canSortRowColumn,onClick:x.sortAsc.handleSort}),x.sortDesc.isVisible&&V.push({icon:x.sortDesc.Icon,label:x.sortDesc.label,disabled:!x.sortDesc.canSortRowColumn,onClick:x.sortDesc.handleSort}),V},[x]),L=u.useCallback(()=>{const V=[];return n==="row"?(y.addAbove.isVisible&&V.push({icon:y.addAbove.Icon,label:y.addAbove.label,disabled:!y.addAbove.canAddRowColumn,onClick:y.addAbove.handleAdd}),y.addBelow.isVisible&&V.push({icon:y.addBelow.Icon,label:y.addBelow.label,disabled:!y.addBelow.canAddRowColumn,onClick:y.addBelow.handleAdd})):(y.addLeft.isVisible&&V.push({icon:y.addLeft.Icon,label:y.addLeft.label,disabled:!y.addLeft.canAddRowColumn,onClick:y.addLeft.handleAdd}),y.addRight.isVisible&&V.push({icon:y.addRight.Icon,label:y.addRight.label,disabled:!y.addRight.canAddRowColumn,onClick:y.addRight.handleAdd})),V},[n,y]),I=u.useCallback(()=>{const V=[];return n==="row"?(v.moveUp.isVisible&&V.push({icon:v.moveUp.Icon,label:v.moveUp.label,disabled:!v.moveUp.canMoveRowColumn,onClick:v.moveUp.handleMove}),v.moveDown.isVisible&&V.push({icon:v.moveDown.Icon,label:v.moveDown.label,disabled:!v.moveDown.canMoveRowColumn,onClick:v.moveDown.handleMove})):(v.moveLeft.isVisible&&V.push({icon:v.moveLeft.Icon,label:v.moveLeft.label,disabled:!v.moveLeft.canMoveRowColumn,onClick:v.moveLeft.handleMove}),v.moveRight.isVisible&&V.push({icon:v.moveRight.Icon,label:v.moveRight.label,disabled:!v.moveRight.canMoveRowColumn,onClick:v.moveRight.handleMove})),V},[n,v]);return{deleteAction:r,duplicateAction:s,clearContentAction:c,headerAction:d,addItems:L(),moveItems:I(),sortItems:S()}}const Fe=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:r=!1,shortcutBadge:s})=>l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":r?"on":"off"}),onClick:n,disabled:o,children:[l.jsx(e,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:t}),s]}),Wd=()=>{const{index:e,orientation:t}=Ft(),{deleteAction:n,duplicateAction:o,clearContentAction:r,headerAction:s,addItems:i,moveItems:a,sortItems:c}=Pd(),d=n.isVisible||o.isVisible||r.isVisible,f=i.length>0,p=a.length>0,h=c.length>0,C=s.isVisible&&e===0;return!d&&!f&&!p&&!h&&!C?null:l.jsxs(l.Fragment,{children:[C&&l.jsxs(l.Fragment,{children:[l.jsx(de,{children:l.jsx(Fe,{icon:s.Icon,label:s.label,disabled:!s.canToggleHeader,isActive:s.isActive,onClick:s.handleToggle})}),l.jsx(ee,{orientation:"horizontal"})]}),p&&l.jsxs(l.Fragment,{children:[l.jsx(de,{children:a.map((g,b)=>l.jsx(Fe,{...g},`move-${b}`))}),l.jsx(ee,{orientation:"horizontal"})]}),f&&l.jsxs(l.Fragment,{children:[l.jsx(de,{children:i.map((g,b)=>l.jsx(Fe,{...g},`add-${b}`))}),l.jsx(ee,{orientation:"horizontal"})]}),h&&l.jsxs(l.Fragment,{children:[l.jsx(de,{children:c.map((g,b)=>l.jsx(Fe,{...g},`sort-${b}`))}),l.jsx(ee,{orientation:"horizontal"})]}),l.jsxs(l.Fragment,{children:[l.jsxs(de,{children:[l.jsx(Rn,{}),l.jsx(ao,{index:e,orientation:t}),r.isVisible&&l.jsx(Fe,{icon:r.Icon,label:r.label,disabled:!r.canClearRowColumnContent,onClick:r.handleClear})]}),l.jsx(ee,{orientation:"horizontal"})]}),d&&l.jsxs(de,{children:[o.isVisible&&l.jsx(Fe,{icon:o.Icon,label:o.label,disabled:!o.canDuplicateRowColumn,onClick:o.handleDuplicate}),n.isVisible&&l.jsx(Fe,{icon:n.Icon,label:n.label,disabled:!n.canDeleteRowColumn,onClick:n.handleDelete})]})]})},_d=()=>{const{resetMenu:e}=us();return l.jsxs(Xe,{autoFocusOnShow:!0,autoFocusOnHide:!1,modal:!0,onClose:e,children:[l.jsx(Vn,{style:wn}),l.jsx(Ye,{style:{minWidth:"15rem"},children:l.jsx(Wd,{})})]})},fs=({editor:e,orientation:t,index:n,tableNode:o,tablePos:r,onToggleOtherHandle:s,onOpenChange:i,dragStart:a})=>{const{editor:c}=k(e),d=u.useMemo(()=>({editor:c,orientation:t,index:n,tableNode:o,tablePos:r}),[c,t,n,o,r]);return l.jsx(ds.Provider,{value:d,children:l.jsx(Zd,{onToggleOtherHandle:s,onOpenChange:i,dragStart:a})})},Zd=({onToggleOtherHandle:e,onOpenChange:t,dragStart:n})=>{const{orientation:o}=Ft(),{isMenuOpen:r,isDragging:s,setIsDragging:i,menuPlacement:a,handleMenuToggle:c}=us(e,t),d=D(),f=o==="row"?d.rowActions:d.columnActions,p=u.useCallback(C=>{i(!0),n?.(C)},[n,i]),h=u.useCallback(()=>{i(!1),u2()},[i]);return l.jsx(je,{open:r,onOpenChange:c,placement:a,trigger:l.jsx(Je,{className:z("tiptap-table-handle-menu",r&&"menu-opened",s&&"is-dragging",o),draggable:!0,"aria-label":f,"aria-haspopup":"menu","aria-expanded":r,onDragStart:p,onDragEnd:h,children:l.jsx(Nt,{className:"tiptap-button-icon"})}),children:l.jsx(_d,{})})};function ps({editor:e,rowButton:t,columnButton:n}){const{editor:o}=k(e),r=Hn({editor:o}),[s,i]=u.useState(!0),[a,c]=u.useState(!0),[d,f]=u.useState(null),p=u.useMemo(()=>{if(r?.draggingState)return{draggedCellOrientation:r.draggingState.draggedCellOrientation,mousePos:r.draggingState.mousePos,initialOffset:r.draggingState.initialOffset}},[r?.draggingState]),{rowHandle:h,colHandle:C}=w2(r?.show||!1,r?.referencePosCell||null,r?.referencePosTable||null,p),g=u.useCallback(I=>{i(I)},[]),b=u.useCallback(I=>{c(I)},[]),m=u.useCallback((I,V)=>{f(V?I:null)},[]);if(!o||!r)return null;const w=typeof r.rowIndex=="number",v=typeof r.colIndex=="number",y=s&&h.isMounted&&w||d==="row",x=a&&C.isMounted&&v||d==="column",S=t||fs,L=n||fs;return l.jsxs(F.FloatingPortal,{root:r.widgetContainer,children:[y&&l.jsx("div",{ref:h.ref,style:h.style,children:l.jsx(S,{editor:o,orientation:"row",index:r.rowIndex,tablePos:r.blockPos,tableNode:r.block,onToggleOtherHandle:b,dragStart:d2,onOpenChange:I=>m("row",I)})}),x&&l.jsx("div",{ref:C.ref,style:C.style,children:l.jsx(L,{editor:o,orientation:"column",index:r.colIndex,tablePos:r.blockPos,tableNode:r.block,onToggleOtherHandle:g,dragStart:c2,onOpenChange:I=>m("column",I)})})]})}ps.displayName="TableHandle";function Fd(e,t){const n=u.useRef(null),o=u.useCallback(()=>{n.current!=null&&(cancelAnimationFrame(n.current),n.current=null)},[]),r=u.useCallback(()=>{if(n.current!=null)return;const s=()=>{const a=!!T.columnResizingPluginKey.getState(e.state)?.dragging;t(),a?n.current=requestAnimationFrame(s):(o(),t())};n.current=requestAnimationFrame(s)},[e,t,o]);u.useEffect(()=>{if(!e)return;const s=({transaction:i})=>{t();const a=i.getMeta(T.columnResizingPluginKey);a&&(Object.prototype.hasOwnProperty.call(a,"setDragging")&&a.setDragging&&r(),Object.prototype.hasOwnProperty.call(a,"setDragging")&&a.setDragging==null&&(o(),t()),Object.prototype.hasOwnProperty.call(a,"setHandle")&&t())};return e.on("transaction",s),()=>{e.off("transaction",s),o()}},[e,r,o,t])}function zd(e){return!!e?.isEditable}const $d=5,qd=(e,t,n,o)=>{const r=t.posAtCoords({left:n,top:o})?.pos;if(r==null)return null;const s=e.doc.resolve(r);return T.cellAround(s)},Gd=(e,t)=>{if(!(t instanceof T.CellSelection))return null;const n=[];if(t.forEachCell((r,s)=>{const i=e.nodeDOM(s);i&&n.push(i)}),n.length===0)return null;const o={left:1/0,top:1/0,right:-1/0,bottom:-1/0};return n.forEach(r=>{const s=r.getBoundingClientRect();o.left=Math.min(o.left,s.left),o.top=Math.min(o.top,s.top),o.right=Math.max(o.right,s.right),o.bottom=Math.max(o.bottom,s.bottom)}),new DOMRect(o.left,o.top,o.right-o.left,o.bottom-o.top)},Kd=(e,t)=>{const n=e.nodeDOM(t);if(!n)return null;const o=n.getBoundingClientRect();return new DOMRect(o.left,o.top,o.width,o.height)},Yd=e=>({getBoundingClientRect:()=>e}),jd=(e,t,n)=>{const o={topLeft:null,topRight:null,bottomLeft:null,bottomRight:null},r=(s,i)=>Math.abs(s-i)<$d;return t.forEachCell((s,i)=>{const a=e.nodeDOM(i);if(!a)return;const c=a.getBoundingClientRect();r(c.left,n.left)&&r(c.top,n.top)&&(o.topLeft=i),r(c.right,n.right)&&r(c.top,n.top)&&(o.topRight=i),r(c.left,n.left)&&r(c.bottom,n.bottom)&&(o.bottomLeft=i),r(c.right,n.right)&&r(c.bottom,n.bottom)&&(o.bottomRight=i)}),o},Xd=(e,t,n,o)=>{if(!o)return null;const i=jd(e,t,n)[{tl:"bottomRight",tr:"bottomLeft",bl:"topRight",br:"topLeft"}[o]];return i?{pos:i}:null},Jd=()=>({position:"absolute",width:15,height:15,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",pointerEvents:"auto",zIndex:10}),zt=(e,t,n=!1)=>({...Jd(),...{tl:{top:-7.5,left:-7.5,cursor:n?"default":"nwse-resize"},tr:{top:-7.5,right:-7.5,cursor:n?"default":"nesw-resize"},bl:{bottom:-7.5,left:-7.5,cursor:n?"default":"nesw-resize"},br:{bottom:-7.5,right:-7.5,cursor:n?"default":"nwse-resize"}}[e],opacity:n?.3:t?1:.5,pointerEvents:n?"none":"auto"}),Qd=({editor:e,cellMenu:t,showResizeHandles:n=!0,onMenuOpenChange:o})=>{const{editor:r}=k(e),[s,i]=u.useState(!0),[a,c]=u.useState(null),[d,f]=u.useState(null),[p,h]=u.useState(null),[C,g]=u.useState(!1),b=zd(r),m=u.useRef(null),w=u.useRef(null),v=u.useRef(null),{refs:y,floatingStyles:x,update:S}=F.useFloating({placement:"top-start"});u.useEffect(()=>{if(a){const O=Yd(a);y.setPositionReference(O)}},[a,y]);const L=u.useCallback(()=>{if(!r||!b)return;const{selection:O}=r.state;if(O instanceof T.CellSelection){const N=Gd(r.view,O);if(!N){i(!1),c(U=>U&&null);return}c(U=>ml(U,N)?U:N),i(!0);return}const{$anchor:Y}=O,A=T.cellAround(Y);if(A){const N=Kd(r.view,A.pos);if(N){c(U=>ml(U,N)?U:N),i(!0);return}}i(!1),c(N=>N&&null)},[r,b]);Fd(r,L),u.useEffect(()=>{S&&a&&S()},[S,a]);const I=u.useCallback(O=>Y=>{if(!r||!O||!a||C||!n)return;Y.preventDefault(),Y.stopPropagation();const{selection:A}=r.state;let N=null;if(A instanceof T.CellSelection)N=A;else{const{$anchor:P}=A,q=T.cellAround(P);if(q)try{N=T.CellSelection.create(r.state.doc,q.pos,q.pos)}catch($){console.warn("Could not create single cell selection for resize:",$);return}}if(!N)return;const U=Xd(r.view,N,a,O);if(!U)return;f(O),w.current=O,m.current=U.pos;const H=P=>{if(!r||m.current==null)return;const q=fl(P.target);if(!q||q.type!=="cell")return;const $=qd(r.state,r.view,P.clientX,P.clientY);if($)try{const se=T.CellSelection.create(r.state.doc,m.current,$.pos),be=r.state.tr.setSelection(se);r.view.dispatch(be)}catch{return}},W=()=>{f(null),w.current=null,m.current=null,window.removeEventListener("mousemove",H),window.removeEventListener("mouseup",W)};window.addEventListener("mousemove",H),window.addEventListener("mouseup",W)},[r,a,C,n]),V=u.useCallback(()=>{if(!r){h(null);return}const O=ne(r);if(!O){h(null);return}h(Y=>{const A=Y,N=r.view.nodeDOM(O.pos);return A===N?A:N})},[r]),K=u.useCallback(O=>{g(O),o?.(O)},[o]);if(u.useEffect(()=>{if(!r||!b)return;const O=()=>{L(),V()};return r.on("selectionUpdate",O),L(),V(),()=>{r.off("selectionUpdate",O)}},[r,b,L,V]),u.useEffect(()=>{const O=p?.querySelector(".table-selection-overlay-container");v.current=O??null},[p]),!b||!s||!a||!r)return null;const le=()=>t?l.jsx("span",{onMouseDown:O=>O.stopPropagation(),style:{pointerEvents:"auto"},children:l.jsx(t,{onOpenChange:K,editor:r})}):null;return l.jsx(F.FloatingPortal,{root:v.current,children:l.jsx("div",{ref:y.setFloating,style:{...x,pointerEvents:"none",zIndex:10},children:l.jsxs("div",{className:"tiptap-table-selection-overlay",children:[l.jsx("div",{style:{position:"absolute",width:a.width,height:a.height,zIndex:2,borderRadius:2,top:0,left:0}}),l.jsxs("div",{style:{position:"absolute",width:a.width,height:a.height,border:"2px solid var(--tt-brand-color-400)",borderRadius:2,zIndex:3,top:0,left:0},children:[le(),n&&l.jsxs(l.Fragment,{children:[l.jsx("div",{style:zt("tl",!d||d==="tl",C),onMouseDown:I("tl")}),l.jsx("div",{style:zt("tr",!d||d==="tr",C),onMouseDown:I("tr")}),l.jsx("div",{style:zt("bl",!d||d==="bl",C),onMouseDown:I("bl")}),l.jsx("div",{style:zt("br",!d||d==="br",C),onMouseDown:I("br")})]})]})]})})})},Rd=u.forwardRef(({editor:e,action:t,hideWhenUnavailable:n=!1,onExecuted:o,text:r,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:f,handleExecute:p,label:h,canExecute:C,Icon:g}=wt({editor:d,action:t,hideWhenUnavailable:n,onExecuted:o}),b=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&p()},[p,s]);return f?l.jsx(M,{type:"button",disabled:!C,variant:"ghost","data-active-state":"off","data-disabled":!C,role:"button",tabIndex:-1,"aria-label":h,"aria-pressed":!1,tooltip:h,onClick:b,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(g,{className:"tiptap-button-icon"}),r&&l.jsx("span",{className:"tiptap-button-text",children:r})]})}):null});Rd.displayName="TableMergeSplitCellButton";const hs=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M10 16C10.5177 16 10.9438 16.3933 10.9951 16.8975L11 17V19C11 20.6569 9.65685 22 8 22H4C2.34315 22 1 20.6569 1 19V17C1 16.4477 1.44772 16 2 16C2.55228 16 3 16.4477 3 17V19C3 19.5523 3.44772 20 4 20H8C8.55228 20 9 19.5523 9 19V17L9.00488 16.8975C9.05621 16.3933 9.48232 16 10 16Z",fill:"currentColor"}),l.jsx("path",{d:"M22 16C22.5177 16 22.9438 16.3933 22.9951 16.8975L23 17V19C23 20.6569 21.6569 22 20 22H16C14.3431 22 13 20.6569 13 19V17C13 16.4477 13.4477 16 14 16C14.5523 16 15 16.4477 15 17V19C15 19.5523 15.4477 20 16 20H20C20.5523 20 21 19.5523 21 19V17L21.0049 16.8975C21.0562 16.3933 21.4823 16 22 16Z",fill:"currentColor"}),l.jsx("path",{d:"M5.29297 8.29297C5.68349 7.90244 6.31651 7.90244 6.70703 8.29297L9.70703 11.293L9.77539 11.3691C10.0957 11.7619 10.0731 12.3409 9.70703 12.707L6.70703 15.707C6.31651 16.0975 5.68349 16.0975 5.29297 15.707C4.90245 15.3165 4.90245 14.6835 5.29297 14.293L6.58594 13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H6.58594L5.29297 9.70703C4.90245 9.31651 4.90245 8.68349 5.29297 8.29297Z",fill:"currentColor"}),l.jsx("path",{d:"M17.293 8.29297C17.6835 7.90245 18.3165 7.90246 18.707 8.29297C19.0976 8.68349 19.0976 9.31651 18.707 9.70703L17.4141 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H17.4141L18.707 14.293C19.0976 14.6835 19.0976 15.3165 18.707 15.707C18.3165 16.0976 17.6835 16.0976 17.293 15.707L14.293 12.707L14.2246 12.6309C13.9043 12.2381 13.9269 11.6591 14.293 11.293L17.293 8.29297Z",fill:"currentColor"}),l.jsx("path",{d:"M8 2C9.65685 2 11 3.34315 11 5V7C11 7.55228 10.5523 8 10 8C9.44771 8 9 7.55228 9 7V5C9 4.44772 8.55228 4 8 4H4C3.44772 4 3 4.44772 3 5V7C3 7.55228 2.55228 8 2 8C1.44772 8 1 7.55228 1 7V5C1 3.34315 2.34315 2 4 2H8Z",fill:"currentColor"}),l.jsx("path",{d:"M20 2C21.6569 2 23 3.34315 23 5V7C23 7.55228 22.5523 8 22 8C21.4477 8 21 7.55228 21 7V5C21 4.44772 20.5523 4 20 4H16C15.4477 4 15 4.44772 15 5V7C15 7.55228 14.5523 8 14 8C13.4477 8 13 7.55228 13 7V5C13 3.34315 14.3431 2 16 2H20Z",fill:"currentColor"})]}));hs.displayName="TableCellMergeIcon";const Cs=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M4 2C2.34315 2 1 3.34315 1 5V7C1 7.55228 1.44772 8 2 8C2.55228 8 3 7.55228 3 7V5C3 4.44772 3.44772 4 4 4H8C8.55228 4 9 4.44772 9 5V7C9 7.55228 9.44772 8 10 8C10.5523 8 11 7.55228 11 7V5C11 3.34315 9.65685 2 8 2H4Z",fill:"currentColor"}),l.jsx("path",{d:"M20 22C21.6569 22 23 20.6569 23 19V17C23 16.4477 22.5523 16 22 16C21.4477 16 21 16.4477 21 17V19C21 19.5523 20.5523 20 20 20H16C15.4477 20 15 19.5523 15 19V17C15 16.4477 14.5523 16 14 16C13.4477 16 13 16.4477 13 17V19C13 20.6569 14.3431 22 16 22H20Z",fill:"currentColor"}),l.jsx("path",{d:"M13 5C13 3.34315 14.3431 2 16 2H20C21.6569 2 23 3.34315 23 5V7C23 7.55228 22.5523 8 22 8C21.4477 8 21 7.55228 21 7V5C21 4.44772 20.5523 4 20 4H16C15.4477 4 15 4.44772 15 5V7C15 7.55228 14.5523 8 14 8C13.4477 8 13 7.55228 13 7V5Z",fill:"currentColor"}),l.jsx("path",{d:"M8 22C9.65685 22 11 20.6569 11 19V17C11 16.4477 10.5523 16 10 16C9.44772 16 9 16.4477 9 17V19C9 19.5523 8.55229 20 8 20H4C3.44772 20 3 19.5523 3 19L3 17C3 16.4477 2.55229 16 2 16C1.44772 16 1 16.4477 1 17V19C1 20.6569 2.34315 22 4 22H8Z",fill:"currentColor"}),l.jsx("path",{d:"M18.7071 15.7071L21.7061 12.7081C21.8877 12.527 22 12.2766 22 12L22 11.997C21.9992 11.7421 21.9016 11.4874 21.7071 11.2929L18.7071 8.29289C18.3166 7.90237 17.6834 7.90237 17.2929 8.29289C16.9024 8.68342 16.9024 9.31658 17.2929 9.70711L18.5858 11H15C14.4477 11 14 11.4477 14 12C14 12.5523 14.4477 13 15 13H18.5858L17.2929 14.2929C16.9024 14.6834 16.9024 15.3166 17.2929 15.7071C17.6834 16.0976 18.3166 16.0976 18.7071 15.7071Z",fill:"currentColor"}),l.jsx("path",{d:"M2.07588 11.6172C2.02699 11.7351 2 11.8644 2 12C2 12.2728 2.10925 12.5201 2.2864 12.7005C2.28879 12.703 2.2912 12.7054 2.29362 12.7078L5.29289 15.7071C5.68342 16.0976 6.31658 16.0976 6.70711 15.7071C7.09763 15.3166 7.09763 14.6834 6.70711 14.2929L5.41421 13L9 13C9.55228 13 10 12.5523 10 12C10 11.4477 9.55229 11 9 11L5.41421 11L6.70711 9.70711C7.09763 9.31658 7.09763 8.68342 6.70711 8.29289C6.31658 7.90237 5.68342 7.90237 5.29289 8.29289L2.29366 11.2921C2.29122 11.2946 2.2888 11.297 2.2864 11.2995C2.19374 11.3938 2.12357 11.502 2.07588 11.6172Z",fill:"currentColor"})]}));Cs.displayName="TableCellSplitIcon";const uo=["table"],eu={merge:hs,split:Cs};function fo(e){if(!e||!e.isEditable||!_(e,uo))return!1;try{return T.mergeCells(e.state,void 0)}catch{return!1}}function po(e){if(!e||!e.isEditable||!_(e,uo))return!1;try{return T.splitCell(e.state,void 0)}catch{return!1}}function tu(e){if(!fo(e)||!e)return!1;try{const{state:t,view:n}=e;return T.mergeCells(t,n.dispatch.bind(n))}catch(t){return console.error("Error merging table cells:",t),!1}}function nu(e){if(!po(e)||!e)return!1;try{const{state:t,view:n}=e;return T.splitCell(t,n.dispatch.bind(n))}catch(t){return console.error("Error splitting table cell:",t),!1}}function ou({editor:e,action:t}){if(!e)return!1;try{return t==="merge"?tu(e):nu(e)}catch(n){return console.error(`Error ${t}ing table cell:`,n),!1}}function ru({editor:e,action:t,hideWhenUnavailable:n}){return!e||!e.isEditable||!_(e,uo)?!1:n?t==="merge"?fo(e):po(e):!0}function wt(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onExecuted:r}=e,{editor:s}=k(t),i=D(),a=ru({editor:s,action:n,hideWhenUnavailable:o}),c=n==="merge"?fo(s):po(s),d=u.useCallback(()=>{const f=ou({editor:s,action:n});return f&&r?.(n),f},[s,n,r]);return{isVisible:a,canExecute:c,handleExecute:d,label:n==="merge"?i.mergeCells:i.splitCell,Icon:eu[n]}}const gs=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M8 14C9.10457 14 10 14.8954 10 16C10 17.1046 9.10457 18 8 18C6.89543 18 6 17.1046 6 16C6 14.8954 6.89543 14 8 14ZM16 14C17.1046 14 18 14.8954 18 16C18 17.1046 17.1046 18 16 18C14.8954 18 14 17.1046 14 16C14 14.8954 14.8954 14 16 14ZM8 6C9.10457 6 10 6.89543 10 8C10 9.10457 9.10457 10 8 10C6.89543 10 6 9.10457 6 8C6 6.89543 6.89543 6 8 6ZM16 6C17.1046 6 18 6.89543 18 8C18 9.10457 17.1046 10 16 10C14.8954 10 14 9.10457 14 8C14 6.89543 14.8954 6 16 6Z",fill:"currentColor"})}));gs.displayName="Grip4Icon";function lu(e){return{merge:e.mergeCells,split:e.splitCell,clear:e.clearContents}}function su(e){const t=lu(e),n=wt({action:"merge"}),o=wt({action:"split"}),r=Qe({resetAttrs:!0}),s={icon:n.Icon,label:t.merge,onClick:n.handleExecute,isAvailable:n.canExecute},i={icon:o.Icon,label:t.split,onClick:o.handleExecute,isAvailable:o.canExecute},a={icon:r.Icon,label:t.clear,onClick:r.handleClear,isAvailable:r.canClearRowColumnContent};return{mergeAction:s,splitAction:i,clearAction:a}}function iu({editor:e}){const[t,n]=u.useState(!1),o=u.useCallback(()=>{n(!1),e?.commands.unfreezeHandles()},[e]),r=u.useCallback(s=>{n(s),e&&(s?e.commands.freezeHandles():e.commands.unfreezeHandles())},[e]);return{isMenuOpen:t,handleMenuToggle:r,closeMenu:o}}const ho=({action:e})=>{const{icon:t,label:n,onClick:o,isActive:r=!1,shortcutBadge:s}=e;return l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":r?"on":"off"}),onClick:o,children:[l.jsx(t,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:n}),s]})},au=({i18n:e,onClose:t})=>{const{mergeAction:n,splitAction:o,clearAction:r}=su(e),s=n.isAvailable||o.isAvailable;return l.jsxs(Xe,{autoFocusOnShow:!0,autoFocusOnHide:!1,modal:!0,onClose:t,children:[l.jsx(Vn,{style:wn}),l.jsxs(Ye,{style:{minWidth:"15rem"},children:[s&&l.jsxs(de,{children:[n.isAvailable&&l.jsx(ho,{action:n}),o.isAvailable&&l.jsx(ho,{action:o}),l.jsx(ee,{orientation:"horizontal"})]}),l.jsxs(de,{children:[l.jsx(Rn,{}),l.jsx(ao,{}),r.isAvailable&&l.jsx(ho,{action:r})]})]})]})},bs=u.forwardRef(({editor:e,onOpenChange:t,className:n,...o},r)=>{const{editor:s}=k(e),i=D(),{isMenuOpen:a,handleMenuToggle:c,closeMenu:d}=iu({editor:s});return u.useEffect(()=>{t?.(a)},[a,t]),l.jsx(je,{open:a,onOpenChange:c,placement:"bottom-start",trigger:l.jsx(Je,{ref:r,className:z("expandable-menu-button",a&&"menu-opened",n),"aria-label":i.tableCellsOption,"aria-haspopup":"menu","aria-expanded":a,...o,children:l.jsx(gs,{className:"tiptap-button-icon"})}),children:l.jsx(au,{i18n:i,onClose:d})})});bs.displayName="TableCellHandleMenu";const ms=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M17.293 7.29303C17.6835 6.90251 18.3165 6.90251 18.707 7.29303L22.707 11.293C22.7548 11.3408 22.7976 11.3936 22.835 11.4503C22.8597 11.4877 22.8812 11.5267 22.9004 11.5665C22.9222 11.6117 22.9412 11.6584 22.9561 11.7071C22.9622 11.7274 22.9668 11.748 22.9717 11.7686C22.9893 11.843 23 11.9203 23 12.0001C23 12.0831 22.9878 12.1632 22.9688 12.2403C22.9646 12.2572 22.9611 12.2743 22.9561 12.2911C22.9421 12.337 22.9244 12.3811 22.9043 12.4239C22.8833 12.4686 22.859 12.5119 22.8311 12.5538C22.8185 12.5726 22.8048 12.5905 22.791 12.6085C22.7649 12.6423 22.738 12.6761 22.707 12.7071L18.707 16.7071C18.3165 17.0976 17.6835 17.0975 17.293 16.7071C16.9024 16.3166 16.9025 15.6836 17.293 15.293L19.5859 13.0001H4.41406L6.70703 15.293C7.09747 15.6836 7.09753 16.3166 6.70703 16.7071C6.31654 17.0976 5.6835 17.0975 5.29297 16.7071L1.29297 12.7071C1.26185 12.676 1.23417 12.6424 1.20801 12.6085C1.19423 12.5906 1.18053 12.5726 1.16797 12.5538C1.14006 12.5119 1.11566 12.4686 1.09473 12.4239C1.07465 12.3811 1.0569 12.3369 1.04297 12.2911C1.0379 12.2743 1.03445 12.2572 1.03027 12.2403C1.01124 12.1633 1.00001 12.083 1 12.0001C1 11.9204 1.00974 11.8429 1.02734 11.7686C1.03221 11.7481 1.03678 11.7274 1.04297 11.7071C1.05787 11.6583 1.07777 11.6117 1.09961 11.5665C1.11877 11.5267 1.1403 11.4877 1.16504 11.4503C1.20242 11.3936 1.24516 11.3408 1.29297 11.293L5.29297 7.29303C5.68349 6.90251 6.31651 6.90251 6.70703 7.29303C7.09747 7.68356 7.09753 8.3166 6.70703 8.70709L4.41406 11.0001H19.5859L17.293 8.70709C16.9024 8.31657 16.9025 7.68356 17.293 7.29303Z",fill:"currentColor"})}));ms.displayName="MoveHorizontalIcon";const ws=["table","tableHandleExtension"];function $t(e){if(!e||!e.isEditable||!_(e,ws))return!1;try{return e.isActive("table")||e.isActive("tableCell")||e.isActive("tableHeader")}catch{return!1}}function cu(e){if(!$t(e)||!e)return!1;try{const t=ne(e);if(!t)return!1;const n=e.view.dom,o=getComputedStyle(n),r=parseFloat(o.paddingLeft)||0,s=parseFloat(o.paddingRight)||0,i=n.clientWidth-r-s,a=t.map.width;if(a===0)return!1;let c=0;const d=i-a-8;c=Math.floor(d/a);const f=Math.max(c,dl),p=e.state.tr;return t.node.descendants((h,C)=>{if(h.type.name==="tableCell"||h.type.name==="tableHeader"){const g=t.start+C,b=h.attrs.colspan||1,m=Array(b).fill(f);p.setNodeMarkup(g,void 0,{...h.attrs,colwidth:m})}}),p.docChanged&&e.view.dispatch(p),!0}catch(t){return console.error("Error setting table auto width:",t),!1}}function du({editor:e}){if(!$t(e)||!e)return!1;try{return cu(e)}catch(t){return console.error("Error adjusting table width:",t),!1}}function uu({editor:e,hideWhenUnavailable:t}){return!e||!e.isEditable||!_(e,ws)?!1:t?$t(e):!0}function Co(e={}){const{editor:t,hideWhenUnavailable:n=!1,onWidthAdjusted:o}=e,{editor:r}=k(t),s=D(),i=uu({editor:r,hideWhenUnavailable:n}),a=$t(r),c=u.useCallback(()=>{const p=du({editor:r});return p&&o?.(),p},[r,o]),d=s.fitToWidth;return{isVisible:i,canFitToWidth:a,handleFitToWidth:c,label:d,Icon:ms}}const fu=u.forwardRef(({editor:e,hideWhenUnavailable:t=!1,onWidthAdjusted:n,text:o,onClick:r,children:s,...i},a)=>{const{editor:c}=k(e),{isVisible:d,canFitToWidth:f,label:p,Icon:h,handleFitToWidth:C}=Co({editor:c,hideWhenUnavailable:t,onWidthAdjusted:n}),g=u.useCallback(b=>{r?.(b),!b.defaultPrevented&&C()},[C,r]);return d?l.jsx(M,{type:"button",disabled:!f,variant:"ghost","data-active-state":"off","data-disabled":!f,role:"button",tabIndex:-1,"aria-label":p,tooltip:p,onClick:g,...i,ref:a,children:s??l.jsxs(l.Fragment,{children:[l.jsx(h,{className:"tiptap-button-icon"}),o&&l.jsx("span",{className:"tiptap-button-text",children:o})]})}):null});fu.displayName="TableFitToWidthButton";const ze=8,pu=184;function hu(e){return e instanceof Element&&!!e.closest("td, th")}function Cu(e){return{x:Math.max(ze,Math.min(e.clientX,window.innerWidth-pu-ze)),y:Math.max(ze,e.clientY)}}function gu(e,t){return{x:Math.max(ze,Math.min(e.x,window.innerWidth-t.width-ze)),y:Math.max(ze,Math.min(e.y,window.innerHeight-t.height-ze))}}function bu(e,t){return!!(e?.isEditable&&t)}function mu(e,t){const n=e.view.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;const o=e.state.doc.resolve(n.pos),r=T.findTable(o);if(!r)return null;const s=T.TableMap.get(r.node);for(let i=o.depth;i>0;i-=1){const a=o.node(i);if(a.type.name!=="tableCell"&&a.type.name!=="tableHeader")continue;const c=o.before(i),d=s.findCell(c-r.start);return{rowIndex:d.top,columnIndex:d.left,tablePos:r.pos}}return null}function wu(e,t){const n=e.view.posAtCoords({left:t.clientX,top:t.clientY});if(!n){e.view.focus();return}const o=E.Selection.near(e.state.doc.resolve(n.pos));e.view.dispatch(e.state.tr.setSelection(o)),e.view.focus()}function vu(e,t,n){const{selection:o}=e.state;if(o instanceof T.CellSelection){const r=T.selectedRect(e.state);if(t.rowIndex>=r.top&&t.rowIndex<r.bottom&&t.columnIndex>=r.left&&t.columnIndex<r.right){e.view.focus();return}}wu(e,n)}function yu(e,t){const n=e();return t(),n}function go({action:e,closeMenu:t}){const{icon:n,label:o,onClick:r,disabled:s,isActive:i}=e;return l.jsxs(M,{type:"button",variant:"ghost","data-active-state":i?"on":"off",disabled:s,className:"tiptap-table-context-menu__item",onMouseDown:a=>a.preventDefault(),onClick:()=>yu(r,t),children:[l.jsx(n,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:o})]})}function bo({actions:e,closeMenu:t}){const n=e.filter(o=>o.isVisible!==!1);return n.length===0?null:l.jsx("div",{className:"tiptap-table-context-menu__group",children:n.map(o=>l.jsx(go,{action:o,closeMenu:t},o.label))})}function vs({editor:e,index:t,orientation:n,tablePos:o,i18n:r}){const s=n==="row"?"above":"left",i=n==="row"?"below":"right",a=Pe({editor:e,index:t,orientation:n,side:s,tablePos:o,hideWhenUnavailable:!0}),c=Pe({editor:e,index:t,orientation:n,side:i,tablePos:o,hideWhenUnavailable:!0}),d=qn({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:!0}),f=Qe({editor:e,index:t,orientation:n,tablePos:o,resetAttrs:!0,hideWhenUnavailable:!0}),p=Fn({editor:e,index:t,orientation:n,tablePos:o,hideWhenUnavailable:!0});return u.useMemo(()=>[{icon:a.Icon,label:n==="row"?r.insertRowAbove:r.insertColumnLeft,onClick:a.handleAdd,disabled:!a.canAddRowColumn,isVisible:a.isVisible},{icon:c.Icon,label:n==="row"?r.insertRowBelow:r.insertColumnRight,onClick:c.handleAdd,disabled:!c.canAddRowColumn,isVisible:c.isVisible},{icon:p.Icon,label:n==="row"?r.headerRow:r.headerColumn,onClick:p.handleToggle,disabled:!p.canToggleHeader,isVisible:p.isVisible,isActive:p.isActive},{icon:f.Icon,label:n==="row"?r.clearRowContents:r.clearColumnContents,onClick:f.handleClear,disabled:!f.canClearRowColumnContent,isVisible:f.isVisible},{icon:d.Icon,label:n==="row"?r.deleteRow:r.deleteColumn,onClick:d.handleDelete,disabled:!d.canDeleteRowColumn,isVisible:d.isVisible}],[c,a,f,d,p,r,n])}function xu(e,t){const n=wt({editor:e,action:"merge",hideWhenUnavailable:!0}),o=wt({editor:e,action:"split",hideWhenUnavailable:!0}),r=Qe({editor:e,resetAttrs:!0,hideWhenUnavailable:!0}),s=ye({editor:e,alignmentType:"text",alignment:"left",hideWhenUnavailable:!0}),i=ye({editor:e,alignmentType:"text",alignment:"center",hideWhenUnavailable:!0}),a=ye({editor:e,alignmentType:"text",alignment:"right",hideWhenUnavailable:!0}),c=ye({editor:e,alignmentType:"vertical",alignment:"middle",hideWhenUnavailable:!0});return u.useMemo(()=>[{icon:n.Icon,label:t.mergeCells,onClick:n.handleExecute,disabled:!n.canExecute,isVisible:n.isVisible},{icon:o.Icon,label:t.splitCell,onClick:o.handleExecute,disabled:!o.canExecute,isVisible:o.isVisible},{icon:s.Icon,label:t.alignLeft,onClick:s.handleAlign,disabled:!s.canAlignCell(),isVisible:s.isVisible,isActive:s.isActive},{icon:i.Icon,label:t.alignCenter,onClick:i.handleAlign,disabled:!i.canAlignCell(),isVisible:i.isVisible,isActive:i.isActive},{icon:a.Icon,label:t.alignRight,onClick:a.handleAlign,disabled:!a.canAlignCell(),isVisible:a.isVisible,isActive:a.isActive},{icon:c.Icon,label:t.alignMiddle,onClick:c.handleAlign,disabled:!c.canAlignCell(),isVisible:c.isVisible,isActive:c.isActive},{icon:r.Icon,label:t.clearContents,onClick:r.handleClear,disabled:!r.canClearRowColumnContent,isVisible:r.isVisible}],[i,s,c,a,r,t,n,o])}function ku({editor:e}){const t=D(),n=u.useRef(null),[o,r]=u.useState(null),[s,i]=u.useState(null),a=u.useCallback(()=>{r(null),i(null),e?.commands.unfreezeHandles?.()},[e]),c=vs({editor:e,index:s?.rowIndex,orientation:"row",tablePos:s?.tablePos,i18n:t}),d=vs({editor:e,index:s?.columnIndex,orientation:"column",tablePos:s?.tablePos,i18n:t}),f=xu(e,t),p=Co({editor:e,hideWhenUnavailable:!0}),h=u.useMemo(()=>({icon:ht,label:t.deleteTable,onClick:()=>e?.chain().focus(void 0,{scrollIntoView:!1}).deleteTable().run()??!1,disabled:!bu(e,s),isVisible:!!e?.isEditable}),[e,t.deleteTable,s]),C=u.useMemo(()=>({icon:p.Icon,label:t.fitToWidth,onClick:p.handleFitToWidth,disabled:!p.canFitToWidth,isVisible:p.isVisible}),[p,t.fitToWidth]);return u.useEffect(()=>{if(!e)return;const g=e.view.dom,b=m=>{if(!e.isEditable||!hu(m.target)){a();return}const w=m,v=mu(e,w);if(!v){a();return}m.preventDefault(),m.stopPropagation(),vu(e,v,w),e.commands.freezeHandles?.(),i(v),r(Cu(w))};return g.addEventListener("contextmenu",b),()=>{g.removeEventListener("contextmenu",b)}},[a,e]),u.useLayoutEffect(()=>{if(!o||!n.current)return;const g=gu(o,n.current.getBoundingClientRect());(g.x!==o.x||g.y!==o.y)&&r(g)},[o]),u.useEffect(()=>{if(!o)return;const g=m=>{n.current?.contains(m.target)||a()},b=m=>{m.key==="Escape"&&a()};return window.addEventListener("mousedown",g),window.addEventListener("scroll",a,!0),window.addEventListener("keydown",b),()=>{window.removeEventListener("mousedown",g),window.removeEventListener("scroll",a,!0),window.removeEventListener("keydown",b)}},[a,o]),!o||!s?null:l.jsxs("div",{ref:n,className:"tiptap-table-context-menu",style:{left:o.x,top:o.y},onContextMenu:g=>g.preventDefault(),children:[l.jsx(bo,{actions:c,closeMenu:a}),l.jsx("div",{className:"tiptap-table-context-menu__separator"}),l.jsx(bo,{actions:d,closeMenu:a}),l.jsx("div",{className:"tiptap-table-context-menu__separator"}),l.jsx(bo,{actions:f,closeMenu:a}),l.jsx("div",{className:"tiptap-table-context-menu__separator"}),l.jsx(go,{action:C,closeMenu:a}),l.jsx(go,{action:h,closeMenu:a})]})}const ys=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M13.5 8C13.5 7.17157 12.8284 6.5 12 6.5C11.1716 6.5 10.5 7.17157 10.5 8V10.5H8C7.17157 10.5 6.5 11.1716 6.5 12C6.5 12.8284 7.17157 13.5 8 13.5H10.5V16C10.5 16.8284 11.1716 17.5 12 17.5C12.8284 17.5 13.5 16.8284 13.5 16V13.5H16C16.8284 13.5 17.5 12.8284 17.5 12C17.5 11.1716 16.8284 10.5 16 10.5H13.5V8Z",fill:"currentColor"})}));ys.displayName="PlusSmallIcon";const Su={row:{placement:"bottom",sizeProperty:"width"},column:{placement:"right",sizeProperty:"height"}};function xs(e,t,n){const o=Su[e],{refs:r,update:s,context:i,floatingStyles:a}=F.useFloating({open:t,placement:o.placement,middleware:[F.offset(4),F.size({apply({rects:p,elements:h}){const C=h.floating;if(!C)return;const g=`${p.reference[o.sizeProperty]}px`;C.style[o.sizeProperty]=g}})]}),{isMounted:c,styles:d}=F.useTransitionStyles(i),f=u.useCallback(p=>({getBoundingClientRect:()=>p}),[]);return u.useEffect(()=>{n&&(r.setReference(f(n)),s())},[n,r,s,f]),u.useMemo(()=>({isMounted:c,ref:r.setFloating,style:{display:"flex",...d,...a}}),[a,c,r.setFloating,d])}function Tu(e,t,n){const o=xs("row",t,n),r=xs("column",e,n);return u.useMemo(()=>({rowButton:o,columnButton:r}),[o,r])}const ks=({editor:e,onMouseDown:t,onMouseUp:n,orientation:o,children:r})=>{const{editor:s}=k(e),i=Hn({editor:s}),a=o==="row",c=u.useRef(!1),[d,f]=u.useState(null),p=u.useCallback(C=>{if(!i)return;const g=T.TableMap.get(i.block);c.current=!1,f({startPos:a?C.clientY:C.clientX,originalHeight:g.height,originalWidth:g.width}),t(),C.preventDefault()},[i,a,t]),h=u.useCallback(()=>{c.current||!s||!i||Ln(s,()=>{Mn(s,i.block,i.blockPos,o),a?s.commands.addRowAfter():s.commands.addColumnAfter()})},[s,a,o,i]);return u.useEffect(()=>{if(!d||!s||!i)return;const C=b=>{c.current=!0;const w=(a?b.clientY:b.clientX)-d.startPos,v=a?Oc:ut,y=T.TableMap.get(i.block),x=a?y.height:y.width,S=a?d.originalHeight:d.originalWidth,I=Math.max(1,S+$c(w/v,.3))-x;I!==0&&(I>0?Ln(s,()=>{Mn(s,i.block,i.blockPos,o);for(let V=0;V<I;V++)a?s.commands.addRowAfter():s.commands.addColumnAfter()}):Ln(s,()=>{const V=Math.abs(I),K=a?Fc(s,i.blockPos):zc(s,i.blockPos),le=Math.min(V,K,x-1);Mn(s,i.block,i.blockPos,o);for(let O=0;O<le;O++)a?s.commands.deleteRow():s.commands.deleteColumn()}))},g=()=>{f(null),n()};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",g),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",g)}},[d,s,a,o,n,i]),s?.isEditable?l.jsx("button",{className:z("tiptap-table-extend-row-column-button",a?"tiptap-table-row-end-add-remove":"tiptap-table-column-end-add-remove",d&&"editing"),onClick:h,onMouseDown:p,type:"button","aria-label":a?"Add or remove rows":"Add or remove columns",children:r??l.jsx(ys,{className:"tiptap-button-icon"})}):null},Au=({editor:e,onMouseDown:t,onMouseUp:n})=>{const{editor:o}=k(e),r=Hn({editor:o}),{columnButton:s,rowButton:i}=Tu(r?.showAddOrRemoveColumnsButton??!1,r?.showAddOrRemoveRowsButton??!1,r?.referencePosTable??null),a=u.useCallback(()=>{o&&(o.commands.freezeHandles(),t?.())},[o,t]),c=u.useCallback(()=>{o&&(o.commands.unfreezeHandles(),n?.())},[o,n]);return r?l.jsxs(F.FloatingPortal,{root:r.widgetContainer,children:[l.jsx("div",{ref:i.ref,style:i.style,children:l.jsx(ks,{editor:o,orientation:"row",block:r.block,onMouseDown:a,onMouseUp:c})}),l.jsx("div",{ref:s.ref,style:s.style,children:l.jsx(ks,{editor:o,orientation:"column",block:r.block,onMouseDown:a,onMouseUp:c})})]}):null};function Ss(e,t,n,o,r){const{dismissOptions:s,...i}=o||{},{refs:a,context:c,floatingStyles:d}=F.useFloating({open:e,whileElementsMounted(b,m,w){return F.autoUpdate(b,m,w,r)},...i}),{isMounted:f,styles:p}=F.useTransitionStyles(c),h=F.useDismiss(c,s),{getReferenceProps:C,getFloatingProps:g}=F.useInteractions([h]);return u.useEffect(()=>{if(t===null){a.setReference(null);return}if(t instanceof HTMLElement){a.setReference(t);return}const b=()=>(typeof t=="function"?t():t)||new DOMRect;a.setReference({getBoundingClientRect:b})},[t,a]),u.useMemo(()=>({isMounted:f,ref:a.setFloating,style:{...p,...d,zIndex:n},getFloatingProps:g,getReferenceProps:C}),[d,f,a.setFloating,p,n,g,C])}function Iu(e,t,n){if(!t?.text||!n)return e;const o=t.text,r=o.lastIndexOf(n);if(r===-1)return e;const s=o.substring(r).length;return e-s}function Lu(e,t){const n=t.trim().toLowerCase();return n?e.filter(o=>!!(o.title.toLowerCase().includes(n)||o.subtext?.toLowerCase().includes(n)||o.keywords?.some(r=>r.toLowerCase().includes(n)))).sort((o,r)=>{const s=o.title.toLowerCase(),i=r.title.toLowerCase();return s===n&&i!==n?-1:i===n&&s!==n?1:s.startsWith(n)&&!i.startsWith(n)?-1:i.startsWith(n)&&!s.startsWith(n)?1:0}):e}const mo=({editor:e,floatingOptions:t,selector:n="tiptap-suggestion-menu",children:o,maxHeight:r=384,pluginKey:s=Wr.SuggestionPluginKey,...i})=>{const{editor:a}=k(e),[c,d]=u.useState(!1),[f,p]=u.useState(null),[h,C]=u.useState(null),[g,b]=u.useState([]),[m,w]=u.useState(""),[,v]=u.useState(null),{ref:y,style:x,getFloatingProps:S,isMounted:L}=Ss(c,f,1e3,{placement:"bottom-start",middleware:[F.offset(10),F.flip({mainAxis:!0,crossAxis:!1}),F.shift(),F.size({apply({availableHeight:O,elements:Y}){if(Y.floating){const A=r?Math.min(r,O):O;Y.floating.style.setProperty("--suggestion-menu-max-height",`${A}px`)}}})],onOpenChange(O){O||d(!1)},...t}),I=u.useRef(i);u.useEffect(()=>{I.current=i},[i]);const V=u.useCallback(()=>{d(!1)},[]);u.useEffect(()=>{if(!a||a.isDestroyed)return;a.state.plugins.find(H=>H.spec.key===s)&&a.unregisterPlugin(s);const Y=I.current.char??"@",A=a.extensionManager.extensions.find(H=>{if(H.name!=="mention")return!1;const W=H.options?.suggestions;return W?.length?W.some(P=>(P.char??"@")===Y):(H.options?.suggestion?.char??"@")===Y}),N={};if(A){let H=null;const W=A.options?.suggestions;if(W?.length?H=W.find(P=>(P.char??"@")===Y):A.options?.suggestion&&(H=A.options.suggestion),H){const P=new Set(["pluginKey","editor","render","command","items","allow","char"]);for(const q of Object.keys(H))P.has(q)||(N[q]=H[q])}}const U=Wr.Suggestion({...N,pluginKey:s instanceof E.PluginKey?s:new E.PluginKey(s),editor:a,allow(H){const W=a.state.doc.resolve(H.range.from);for(let P=W.depth;P>0;P--)if(W.node(P).type.name==="image")return!1;return!0},command({editor:H,range:W,props:P}){if(!W)return;const{view:q,state:$}=H,{selection:se}=$;if(!H.extensionManager.extensions.some(qe=>{if(qe.name!=="mention")return!1;const Ve=qe.options?.suggestions;return Ve?.length?Ve.some(Z=>(Z.char??"@")===I.current.char):(qe.options?.suggestion?.char??"@")===I.current.char})){const qe=se.$from.pos,Ve=se.$head?.nodeBefore,Z=Ve?Iu(qe,Ve,I.current.char):se.$from.start(),oe=$.tr.deleteRange(Z,qe);q.dispatch(oe)}const ot={...W};q.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(ot.to+=1),P.onSelect({editor:H,range:ot,context:P.context})},render:()=>({onStart:H=>{p(H.decorationNode??null),C(()=>H.command),b(H.items),w(H.query),v(H.range),d(!0)},onUpdate:H=>{p(H.decorationNode??null),C(()=>H.command),b(H.items),w(H.query),v(H.range)},onKeyDown:H=>(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab","Home","End","Enter","Escape"].includes(H.event.key)&&(H.event.preventDefault(),H.event.stopPropagation()),H.event.key==="Escape"?(V(),!0):!1),onExit:()=>{p(null),C(null),b([]),w(""),v(null),d(!1)}}),...I.current});return a.registerPlugin(U),()=>{a.isDestroyed||a.unregisterPlugin(s)}},[a,s,V]);const K=u.useCallback(O=>{V(),h&&h(O)},[V,h]),{selectedIndex:le}=Ot({editor:a,query:m,items:g,onSelect:K});return!L||!c||!a?null:l.jsx("div",{ref:y,style:x,...S(),"data-selector":n,className:"tiptap-suggestion-menu",role:"listbox","aria-label":"Suggestions",onPointerDown:O=>O.preventDefault(),children:o({items:g,selectedIndex:le,onSelect:K})})};function Eu(e){return{paragraph:e.text,heading:e.heading,blockquote:e.blockquote,listItem:e.listItem,codeBlock:e.codeBlock,table:e.table,tocNode:e.tableOfContents}}const Ts=(e,t=Ie())=>{if(!e)return t.node;const n=Eu(t),{selection:o}=e.state;if(o instanceof E.NodeSelection){const i=o.node.type.name;return n[i]||i.toLowerCase()}if(o instanceof T.CellSelection)return t.table;const{$anchor:r}=o,s=r.parent.type.name;return n[s]||s.toLowerCase()};function As(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.top<o.top,s=n.bottom>o.bottom;return r&&s?"both":r?"top":s?"bottom":"none"}const Is=(e,t,n=["imageUpload","horizontalRule"])=>{if(!e)return!1;t||(t=e.state.selection);const{state:o}=e,{doc:r}=o,{empty:s,from:i,to:a}=t,c=!r.textBetween(i,a).length&&G.isTextSelection(t),d=t.$from.parent.type.spec.code||G.isNodeSelection(t)&&t.node.type.spec.code,f=G.isNodeSelection(t)&&n.includes(t.node.type.name),p=t instanceof T.CellSelection;return!s&&!c&&!d&&!f&&!p},Mu=e=>{if(!e)return!1;const{state:t}=e,{selection:n}=t;return G.isTextSelection(n)&&!n.empty&&!n.$from.parent.type.spec.code&&!G.isNodeSelection(n)},Nu=e=>{const{state:t}=e.view,{selection:n}=t,{ranges:o}=n,r=Math.min(...o.map(i=>i.$from.pos)),s=Math.max(...o.map(i=>i.$to.pos));if(G.isNodeSelection(n)){const i=e.view.nodeDOM(r);if(i)return i.getBoundingClientRect()}return G.posToDOMRect(e.view,r,s)},wo=e=>{if(!e)return"/avatars/memoji_01.png";let t=0;for(let s=0;s<e.length;s++)t=e.charCodeAt(s)+((t<<5)-t),t=t&t;const n=Math.abs(t)%1e6/1e6;return`/avatars/memoji_${(1+Math.floor(n*20)).toString().padStart(2,"0")}.png`},Ls=100,Hu=(e,t)=>e.name.localeCompare(t.name),Vu=(e,t)=>{const n=e.toLowerCase().trim();return t.name.toLowerCase().includes(n)||t.shortcodes.some(o=>o.toLowerCase().includes(n))||t.tags.some(o=>o.toLowerCase().includes(n))},Bu=e=>{const{query:t,emojis:n}=e,o=t.trim();return(o?n.filter(s=>Vu(o,s)).slice(0,Ls):n.slice(0,Ls)).sort(Hu)},Du=e=>{const{emoji:t,isSelected:n,onSelect:o,selector:r}=e,s=u.useRef(null);return u.useEffect(()=>{const i=document.querySelector(r);if(!s.current||!n||!i)return;const a=As(s.current,i);a==="top"?s.current.scrollIntoView(!0):a==="bottom"&&s.current.scrollIntoView(!1)},[n,r]),t?l.jsxs(M,{ref:s,variant:"ghost","data-active-state":n?"on":"off",onClick:()=>o(t),children:[t.fallbackImage?l.jsx("img",{className:"tiptap-button-emoji",src:t.fallbackImage,alt:t.name}):l.jsx("span",{className:"tiptap-button-emoji",children:t.emoji}),l.jsxs("span",{className:"tiptap-button-text",children:[":",t.name,":"]})]}):null},Uu=e=>l.jsx(mo,{char:":",pluginKey:"emojiDropdownMenu",decorationClass:"tiptap-emoji-decoration",selector:"tiptap-emoji-dropdown-menu",items:Ou,...e,children:t=>l.jsx(Pu,{...t})}),Ou=async e=>{const t=e.editor.extensionStorage.emoji.emojis||[];return Bu({query:e.query,emojis:t}).map(o=>({title:o.name,subtext:o.shortcodes.join(", "),context:o,onSelect:r=>{!r.editor||!r.range||!r.context||r.editor.chain().focus().setEmoji(r.context.name).run()}}))},Pu=({items:e,selectedIndex:t,onSelect:n})=>{const o=u.useMemo(()=>{const r=[];return e.forEach((s,i)=>{s.context&&r.push(l.jsx(Du,{emoji:s.context,index:i,isSelected:i===t,onSelect:()=>n(s),selector:"[data-selector='tiptap-emoji-dropdown-menu']"},s.title))}),r},[e,t,n]);return o.length?l.jsx(_e,{style:{maxHeight:"var(--suggestion-menu-max-height)"},children:l.jsx(Ze,{children:l.jsx(Me,{children:o})})}):null},Es="_tiptap_username",Ms="_tiptap_color",Ns="_tiptap_user_id",Hs=["John","Jane","Alice","Bob","Eve","Charlie","David","Frank","Grace","Helen","Rob Lowe","Rob"],Wu=["Smith","Johnson","Williams","Jones","Brown","Davis","Miller","Wilson","Moore","Taylor","Anderson","Thomas","Lowe"],_u=["#fb7185","#fdba74","#d9f99d","#a7f3d0","#a5f3fc","#a5b4fc","#f0abfc","#fda58d","#f2cc8f","#9ae6b4"],Zu=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.random()*16|0;return(t==="x"?n:n&3|8).toString(16)}),qt=e=>{if(e.length===0)throw new Error("Cannot get random item from empty array");return e[Math.floor(Math.random()*e.length)]},Fu=()=>{const e=[qt(Hs)];return Math.random()>.85&&e.push(qt(Hs)),e.push(qt(Wu)),e.join(" ")},zu=()=>qt(_u)??"#9ae6b4",$u=()=>typeof window>"u"?null:window.localStorage;function qu(e=$u()){const t=e?.getItem(Es)||Fu(),n=e?.getItem(Ms)||zu(),r={id:e?.getItem(Ns)||Zu(),name:t,color:n,avatar:wo(t)};return e?.setItem(Es,r.name),e?.setItem(Ms,r.color),e?.setItem(Ns,r.id),r}function Vs(e){return e?.name?{id:"id"in e&&e.id?e.id:e.name,name:e.name,color:e.color||"#958df1",avatar:e.avatar||wo(e.name),position:"position"in e?e.position:void 0}:null}function Gu(e){return e?.map(Vs).filter(t=>!!t)??[]}function Bs(e){return typeof e.name!="string"||!e.name?null:{id:typeof e.id=="string"&&e.id?e.id:e.clientId!=null?String(e.clientId):e.name,name:e.name,color:typeof e.color=="string"&&e.color?e.color:"#958df1",avatar:typeof e.avatar=="string"&&e.avatar?e.avatar:wo(e.name),position:typeof e.position=="string"&&e.position?e.position:void 0}}function Ku(e){return e.id||e.name}function vo(e){const t=new Set,n=[];return e.forEach(o=>{const r=Ku(o);t.has(r)||(t.add(r),n.push(o))}),n}function Yu(e,t,n=20){const o=e.trim().toLowerCase(),r=vo(t);return o?r.filter(s=>s.name.toLowerCase().includes(o)||s.position?.toLowerCase().includes(o)).slice(0,n):r.slice(0,n)}const Ds=u.createContext(void 0),Us=()=>{const e=u.useContext(Ds);if(!e)throw new Error("Avatar components must be used within an Avatar.Root");return e},ju=(e,t)=>{const n=e?"loading":"error",[o,r]=u.useState(n);return u.useLayoutEffect(()=>{if(!e)return;let s=!0;const i=new window.Image,a=c=>()=>{s&&r(c)};return i.onload=a("loaded"),i.onerror=a("error"),i.src=e,t&&(i.referrerPolicy=t),()=>{s=!1}},[e,t]),o},Gt=u.forwardRef(({children:e,className:t="",size:n="default",userColor:o,...r},s)=>{const[i,a]=u.useState("idle"),c=u.useCallback(p=>{a(p)},[]),d=u.useMemo(()=>({imageLoadingStatus:i,onImageLoadingStatusChange:c,size:n}),[i,c,n]),f=o?{"--dynamic-user-color":o}:void 0;return l.jsx(Ds.Provider,{value:d,children:l.jsx("span",{...r,ref:s,className:`tiptap-avatar ${t}`,style:f,"data-size":n,children:l.jsx("span",{className:"tiptap-avatar-item",children:e})})})});Gt.displayName="Avatar";const yo=u.forwardRef(({onLoadingStatusChange:e,src:t,className:n="",...o},r)=>{const{onImageLoadingStatusChange:s}=Us(),i=ju(t,o.referrerPolicy);return u.useLayoutEffect(()=>{i!=="idle"&&(e?.(i),s(i))},[i,e,s]),i!=="loaded"?null:l.jsx("img",{alt:"",...o,ref:r,src:t,className:`tiptap-avatar-image ${n}`})});yo.displayName="AvatarImage";const Kt=u.forwardRef(({delayMs:e,className:t="",children:n,...o},r)=>{const s=Us(),[i,a]=u.useState(e===void 0);return u.useEffect(()=>{if(e!==void 0){const c=window.setTimeout(()=>a(!0),e);return()=>window.clearTimeout(c)}},[e]),!i||s.imageLoadingStatus==="loaded"?null:l.jsxs(l.Fragment,{children:[l.jsx("span",{className:`tiptap-avatar-bg ${t}`}),l.jsx("span",{...o,ref:r,className:`tiptap-avatar-fallback ${t}`,children:n})]})});Kt.displayName="AvatarFallback";const Os=({maxVisible:e,children:t,className:n="",...o})=>{const r=u.Children.toArray(t),s=e?r.slice(0,e):r,i=r.length-s.length;let a={};return u.Children.forEach(t,c=>{if(u.isValidElement(c)&&c.type&&typeof c.type!="string"&&c.type.displayName==="Avatar"){a={...a,...c.props};return}}),l.jsxs("div",{...o,className:`tiptap-avatar-group ${n}`,"data-max-user-visible":e,children:[s,i>0&&l.jsx(Gt,{...a,children:l.jsxs(Kt,{children:["+",i]})})]})};Os.displayName="AvatarGroup";const Xu=({users:e=[],...t})=>{const n=u.useRef(e);u.useEffect(()=>{n.current=e},[e]);const o=s=>{!s.editor||!s.range||!s.context||s.editor.chain().focus().insertContentAt(s.range,[{type:"mention",attrs:{id:s.context.id,label:s.context.name}},{type:"text",text:" "}]).run()},r=async s=>Yu(s.query,n.current).map(a=>({title:a.name,subtext:a.position,context:a,onSelect:o}));return l.jsx(mo,{char:"@",pluginKey:"mentionDropdownMenu",decorationClass:"tiptap-mention-decoration",selector:"tiptap-mention-dropdown-menu",items:r,...t,children:s=>l.jsx(Qu,{...s})})},Ju=({item:e,isSelected:t,onSelect:n})=>{const o=u.useRef(null);return u.useEffect(()=>{const r=document.querySelector('[data-selector="tiptap-mention-dropdown-menu"]');if(!o.current||!t||!r)return;const s=As(o.current,r);s==="top"?o.current.scrollIntoView(!0):s==="bottom"&&o.current.scrollIntoView(!1)},[t]),l.jsxs(M,{ref:o,variant:"ghost","data-active-state":t?"on":"off",onClick:n,"data-user-id":e.context?.id,children:[l.jsxs(Gt,{userColor:e.context?.color,children:[l.jsx(yo,{src:e.context?.avatar,alt:e.title}),l.jsx(Kt,{children:e.title[0]?.toUpperCase()})]}),l.jsx("span",{className:"tiptap-button-text",children:e.title})]})},Qu=({items:e,selectedIndex:t,onSelect:n})=>{const o=u.useMemo(()=>{const r=[];return e.forEach((s,i)=>{r.push(l.jsx(Ju,{item:s,isSelected:i===t,onSelect:()=>n(s)},s.context?.id||s.title))}),r},[e,t,n]);return o.length?l.jsx(_e,{style:{maxHeight:"var(--suggestion-menu-max-height)"},children:l.jsx(Ze,{children:l.jsx(Me,{children:o})})}):null},xo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.70711 2.29289C7.09763 2.68342 7.09763 3.31658 6.70711 3.70711L4.41421 6L6.70711 8.29289C7.09763 8.68342 7.09763 9.31658 6.70711 9.70711C6.31658 10.0976 5.68342 10.0976 5.29289 9.70711L2.29289 6.70711C1.90237 6.31658 1.90237 5.68342 2.29289 5.29289L5.29289 2.29289C5.68342 1.90237 6.31658 1.90237 6.70711 2.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2929 2.29289C10.6834 1.90237 11.3166 1.90237 11.7071 2.29289L14.7071 5.29289C15.0976 5.68342 15.0976 6.31658 14.7071 6.70711L11.7071 9.70711C11.3166 10.0976 10.6834 10.0976 10.2929 9.70711C9.90237 9.31658 9.90237 8.68342 10.2929 8.29289L12.5858 6L10.2929 3.70711C9.90237 3.31658 9.90237 2.68342 10.2929 2.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 4C17 3.44772 17.4477 3 18 3H19C20.6569 3 22 4.34315 22 6V18C22 19.6569 20.6569 21 19 21H5C3.34315 21 2 19.6569 2 18V12C2 11.4477 2.44772 11 3 11C3.55228 11 4 11.4477 4 12V18C4 18.5523 4.44772 19 5 19H19C19.5523 19 20 18.5523 20 18V6C20 5.44772 19.5523 5 19 5H18C17.4477 5 17 4.55228 17 4Z",fill:"currentColor"})]}));xo.displayName="CodeBlockIcon";const ko=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),l.jsx("path",{d:"M21.0001 10C21.0001 9.63121 20.7971 9.29235 20.472 9.11833C20.1468 8.94431 19.7523 8.96338 19.4454 9.16795L16.4454 11.168C15.9859 11.4743 15.8617 12.0952 16.1681 12.5547C16.4744 13.0142 17.0953 13.1384 17.5548 12.8321L19.0001 11.8685V18C19.0001 18.5523 19.4478 19 20.0001 19C20.5524 19 21.0001 18.5523 21.0001 18V10Z",fill:"currentColor"})]}));ko.displayName="HeadingOneIcon";const So=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),l.jsx("path",{d:"M22.0001 12C22.0001 10.7611 21.1663 9.79297 20.0663 9.42632C18.9547 9.05578 17.6171 9.28724 16.4001 10.2C15.9582 10.5314 15.8687 11.1582 16.2001 11.6C16.5314 12.0418 17.1582 12.1314 17.6001 11.8C18.383 11.2128 19.0455 11.1942 19.4338 11.3237C19.8339 11.457 20.0001 11.7389 20.0001 12C20.0001 12.4839 19.8554 12.7379 19.6537 12.9481C19.4275 13.1837 19.1378 13.363 18.7055 13.6307C18.6313 13.6767 18.553 13.7252 18.4701 13.777C17.9572 14.0975 17.3128 14.5261 16.8163 15.2087C16.3007 15.9177 16.0001 16.8183 16.0001 18C16.0001 18.5523 16.4478 19 17.0001 19H21.0001C21.5523 19 22.0001 18.5523 22.0001 18C22.0001 17.4477 21.5523 17 21.0001 17H18.131C18.21 16.742 18.3176 16.5448 18.4338 16.385C18.6873 16.0364 19.0429 15.7775 19.5301 15.473C19.5898 15.4357 19.6536 15.3966 19.7205 15.3556C20.139 15.0992 20.6783 14.7687 21.0964 14.3332C21.6447 13.7621 22.0001 13.0161 22.0001 12Z",fill:"currentColor"})]}));So.displayName="HeadingTwoIcon";const To=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4608 11.2169C19.1135 11.0531 18.5876 11.0204 18.0069 11.3619C17.5309 11.642 16.918 11.4831 16.638 11.007C16.358 10.531 16.5169 9.91809 16.9929 9.63807C18.1123 8.97962 19.3364 8.94691 20.314 9.40808C21.2839 9.86558 21.9999 10.818 21.9999 12C21.9999 12.7957 21.6838 13.5587 21.1212 14.1213C20.5586 14.6839 19.7956 15 18.9999 15C18.4476 15 17.9999 14.5523 17.9999 14C17.9999 13.4477 18.4476 13 18.9999 13C19.2651 13 19.5195 12.8947 19.707 12.7071C19.8946 12.5196 19.9999 12.2652 19.9999 12C19.9999 11.6821 19.8159 11.3844 19.4608 11.2169Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.0001 14C18.0001 13.4477 18.4478 13 19.0001 13C19.7957 13 20.5588 13.3161 21.1214 13.8787C21.684 14.4413 22.0001 15.2043 22.0001 16C22.0001 17.2853 21.2767 18.3971 20.1604 18.8994C19.0257 19.41 17.642 19.2315 16.4001 18.3C15.9582 17.9686 15.8687 17.3418 16.2001 16.9C16.5314 16.4582 17.1582 16.3686 17.6001 16.7C18.3581 17.2685 18.9744 17.24 19.3397 17.0756C19.7234 16.9029 20.0001 16.5147 20.0001 16C20.0001 15.7348 19.8947 15.4804 19.7072 15.2929C19.5196 15.1054 19.2653 15 19.0001 15C18.4478 15 18.0001 14.5523 18.0001 14Z",fill:"currentColor"})]}));To.displayName="HeadingThreeIcon";const Ps=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V5C20 4.44772 19.5523 4 19 4H5ZM22 14.998V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H5.99781C5.99927 22 6.00073 22 6.00219 22H19C20.6569 22 22 20.6569 22 19V15.002C22 15.0007 22 14.9994 22 14.998ZM20 15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20H19C19.5523 20 20 19.5523 20 19V15.4142ZM9 8C8.44772 8 8 8.44772 8 9C8 9.55228 8.44772 10 9 10C9.55228 10 10 9.55228 10 9C10 8.44772 9.55228 8 9 8ZM6 9C6 7.34315 7.34315 6 9 6C10.6569 6 12 7.34315 12 9C12 10.6569 10.6569 12 9 12C7.34315 12 6 10.6569 6 9Z",fill:"currentColor"})}));Ps.displayName="ImageIcon";const Ao=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));Ao.displayName="ListIcon";const Io=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",fill:"currentColor"})]}));Io.displayName="ListOrderedIcon";const Lo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H16C16.5523 5 17 5.44772 17 6C17 6.55228 16.5523 7 16 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C4.55228 3 5 3.44772 5 4L5 20C5 20.5523 4.55229 21 4 21C3.44772 21 3 20.5523 3 20L3 4C3 3.44772 3.44772 3 4 3Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H20C20.5523 11 21 11.4477 21 12C21 12.5523 20.5523 13 20 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H16C16.5523 17 17 17.4477 17 18C17 18.5523 16.5523 19 16 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"})]}));Lo.displayName="BlockquoteIcon";const Eo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 4.89543 2.89543 4 4 4H8C9.10457 4 10 4.89543 10 6V10C10 11.1046 9.10457 12 8 12H4C2.89543 12 2 11.1046 2 10V6ZM8 6H4V10H8V6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L5.70711 19.7071C5.31658 20.0976 4.68342 20.0976 4.29289 19.7071L2.29289 17.7071C1.90237 17.3166 1.90237 16.6834 2.29289 16.2929C2.68342 15.9024 3.31658 15.9024 3.70711 16.2929L5 17.5858L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 6C12 5.44772 12.4477 5 13 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H13C12.4477 7 12 6.55228 12 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 12C12 11.4477 12.4477 11 13 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H13C12.4477 13 12 12.5523 12 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 18C12 17.4477 12.4477 17 13 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H13C12.4477 19 12 18.5523 12 18Z",fill:"currentColor"})]}));Eo.displayName="ListTodoIcon";const Ws=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 12C4 11.4477 4.44772 11 5 11H19C19.5523 11 20 11.4477 20 12C20 12.5523 19.5523 13 19 13H5C4.44772 13 4 12.5523 4 12Z",fill:"currentColor"})}));Ws.displayName="MinusIcon";const Mo=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M3 4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4V7C21 7.55228 20.5523 8 20 8C19.4477 8 19 7.55228 19 7V5H13V19H15C15.5523 19 16 19.4477 16 20C16 20.5523 15.5523 21 15 21H9C8.44772 21 8 20.5523 8 20C8 19.4477 8.44772 19 9 19H11V5H5V7C5 7.55228 4.55228 8 4 8C3.44772 8 3 7.55228 3 7V4Z",fill:"currentColor"})}));Mo.displayName="TypeIcon";const No=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.5273 1.29427C12.1156 0.724951 9.58234 0.986597 7.33794 2.03682C5.09354 3.08704 3.26948 4.8643 2.1613 7.08066C1.05312 9.29702 0.725742 11.8226 1.23221 14.2483C1.73868 16.6739 3.04931 18.8575 4.95178 20.4453C6.85424 22.033 9.23706 22.9319 11.7142 22.9963C14.1913 23.0607 16.6176 22.2868 18.6 20.8C19.0418 20.4686 19.1314 19.8418 18.8 19.4C18.4686 18.9582 17.8418 18.8686 17.4 19.2C15.7781 20.4165 13.7929 21.0496 11.7662 20.997C9.73942 20.9443 7.78983 20.2088 6.23327 18.9098C4.67671 17.6107 3.60437 15.8241 3.18999 13.8395C2.77561 11.8549 3.04346 9.78847 3.95015 7.97509C4.85685 6.1617 6.34926 4.70758 8.18559 3.84831C10.0219 2.98904 12.0946 2.77496 14.0678 3.24077C16.041 3.70658 17.7991 4.82497 19.0573 6.41476C20.3155 8.00455 21 9.97258 21 12V13C21 13.5304 20.7893 14.0392 20.4142 14.4142C20.0391 14.7893 19.5304 15 19 15C18.4696 15 17.9609 14.7893 17.5858 14.4142C17.2107 14.0392 17 13.5304 17 13V8.00001C17 7.44772 16.5523 7.00001 16 7.00001C15.4478 7.00001 15.0002 7.44752 15 7.99964C14.1643 7.37195 13.1256 7 12 7C9.23858 7 7 9.23858 7 12C7 14.7614 9.23858 17 12 17C13.4881 17 14.8243 16.3499 15.7403 15.3183C15.8687 15.4989 16.0128 15.6696 16.1716 15.8284C16.9217 16.5786 17.9391 17 19 17C20.0609 17 21.0783 16.5786 21.8284 15.8284C22.5786 15.0783 23 14.0609 23 13V12C23 9.52205 22.1633 7.11667 20.6255 5.17359C19.0878 3.23052 16.939 1.86359 14.5273 1.29427ZM15 11.9958V12.0042C14.9977 13.6591 13.6555 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6555 9 14.9977 10.3409 15 11.9958Z",fill:"currentColor"})}));No.displayName="AtSignIcon";const Ho=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.67909 4.05505C9.27254 3.18292 11.0926 2.81337 12.9 2.995C13.4495 3.05022 13.9398 2.64952 13.995 2.1C14.0502 1.55048 13.6495 1.06024 13.1 1.00502C10.8909 0.783033 8.66641 1.2347 6.71886 2.30064C4.7713 3.36659 3.19189 4.99691 2.18824 6.97729C1.1846 8.95767 0.803706 11.1954 1.09564 13.3963C1.38758 15.5972 2.33867 17.6583 3.8239 19.3085C5.30912 20.9588 7.25894 22.121 9.41704 22.6423C11.5751 23.1637 13.8405 23.0198 15.9153 22.2296C17.9901 21.4394 19.7772 20.0398 21.0417 18.2149C22.3062 16.39 22.9889 14.2252 23 12.005L23 12V11C23 10.4477 22.5523 10 22 10C21.4477 10 21 10.4477 21 11V11.9976C20.9904 13.8132 20.4319 15.5834 19.3978 17.0758C18.3632 18.5689 16.901 19.714 15.2034 20.3605C13.5059 21.0071 11.6524 21.1248 9.8867 20.6982C8.12098 20.2717 6.52567 19.3208 5.31048 17.9706C4.0953 16.6204 3.31713 14.9341 3.07828 13.1333C2.83942 11.3326 3.15106 9.50171 3.97222 7.8814C4.79339 6.26109 6.08564 4.92719 7.67909 4.05505ZM7.4 13.2C7.84043 12.8697 8.46468 12.9576 8.79686 13.3958L8.8015 13.4018C8.80745 13.4093 8.81876 13.4234 8.83531 13.4431C8.86846 13.4826 8.92219 13.5442 8.99542 13.6206C9.14272 13.7743 9.36407 13.9828 9.65067 14.1913C10.2277 14.6109 11.0255 15 12 15C12.9745 15 13.7723 14.6109 14.3493 14.1913C14.6359 13.9828 14.8573 13.7743 15.0046 13.6206C15.0778 13.5442 15.1315 13.4826 15.1647 13.4431C15.1812 13.4234 15.1925 13.4093 15.1985 13.4018L15.2031 13.3958C15.5353 12.9576 16.1596 12.8697 16.6 13.2C17.0418 13.5314 17.1314 14.1582 16.8 14.6L16 14C16.8 14.6 16.7998 14.6003 16.7995 14.6006L16.799 14.6013L16.7978 14.6029L16.7951 14.6065L16.7879 14.6159L16.7666 14.6432C16.7493 14.6649 16.726 14.6938 16.6966 14.7288C16.638 14.7987 16.555 14.8933 16.4485 15.0044C16.2365 15.2257 15.9266 15.5172 15.5257 15.8087C14.7277 16.3891 13.5255 17 12 17C10.4745 17 9.27227 16.3891 8.47433 15.8087C8.07343 15.5172 7.76352 15.2257 7.55145 15.0044C7.445 14.8933 7.362 14.7987 7.30336 14.7288C7.274 14.6938 7.25065 14.6649 7.23341 14.6432L7.21211 14.6159L7.2049 14.6065L7.20216 14.6029L7.20101 14.6013L7.20048 14.6006C7.20024 14.6003 7.2 14.6 8 14L7.2 14.6C6.86863 14.1582 6.95817 13.5314 7.4 13.2ZM8 9C8 8.44772 8.44772 8 9 8H9.01C9.56229 8 10.01 8.44772 10.01 9C10.01 9.55229 9.56229 10 9.01 10H9C8.44772 10 8 9.55229 8 9ZM15 8C14.4477 8 14 8.44772 14 9C14 9.55229 14.4477 10 15 10H15.01C15.5623 10 16.01 9.55229 16.01 9C16.01 8.44772 15.5623 8 15.01 8H15ZM15 5C15 4.44772 15.4477 4 16 4H18V2C18 1.44772 18.4477 1 19 1C19.5523 1 20 1.44772 20 2V4H22C22.5523 4 23 4.44772 23 5C23 5.55228 22.5523 6 22 6H20V8C20 8.55228 19.5523 9 19 9C18.4477 9 18 8.55228 18 8V6H16C15.4477 6 15 5.55228 15 5Z",fill:"currentColor"})}));Ho.displayName="SmilePlusIcon";const _s=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM4 5C4 4.44772 4.44772 4 5 4H11V8H4V5ZM4 10H11V14H4V10ZM20 14V10H13V14H20ZM13 16H20V19C20 19.5523 19.5523 20 19 20H13V16ZM11 16V20H5C4.44772 20 4 19.5523 4 19V16H11ZM13 8H20V5C20 4.44772 19.5523 4 19 4H13V8Z",fill:"currentColor"})}));_s.displayName="TableIcon";const Vo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 12C11 11.4477 11.4477 11 12 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H12C11.4477 13 11 12.5523 11 12Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.5 16.5C3.22386 16.5 3 16.7239 3 17V19C3 19.2761 3.22386 19.5 3.5 19.5H5.5C5.77614 19.5 6 19.2761 6 19V17C6 16.7239 5.77614 16.5 5.5 16.5H3.5Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.5 10.5C6.22386 10.5 6 10.7239 6 11V13C6 13.2761 6.22386 13.5 6.5 13.5H8.5C8.77614 13.5 9 13.2761 9 13V11C9 10.7239 8.77614 10.5 8.5 10.5H6.5Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.5 4.5C3.22386 4.5 3 4.72386 3 5V7C3 7.27614 3.22386 7.5 3.5 7.5H5.5C5.77614 7.5 6 7.27614 6 7V5C6 4.72386 5.77614 4.5 5.5 4.5H3.5Z",fill:"currentColor"})]}));Vo.displayName="ListIndentedIcon";const Bo=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.94924 1.68544C6.81364 1.27624 6.43108 1 6 1C5.56892 1 5.18636 1.27624 5.05076 1.68544L4.3711 3.73642C4.2717 4.03638 4.03638 4.2717 3.73642 4.3711L1.68544 5.05076C1.27624 5.18636 1 5.56892 1 6C1 6.43108 1.27624 6.81364 1.68544 6.94924L3.73642 7.6289C4.03638 7.7283 4.2717 7.96362 4.3711 8.26358L5.05076 10.3146C5.18636 10.7238 5.56892 11 6 11C6.43108 11 6.81364 10.7238 6.94924 10.3146L7.6289 8.26358C7.7283 7.96362 7.96362 7.7283 8.26358 7.6289L10.3146 6.94924C10.7238 6.81364 11 6.43108 11 6C11 5.56892 10.7238 5.18636 10.3146 5.05076L8.26358 4.3711C7.96362 4.2717 7.7283 4.03638 7.6289 3.73642L6.94924 1.68544ZM4.95595 6C5.38537 5.74447 5.74447 5.38537 6 4.95595C6.25554 5.38537 6.61463 5.74447 7.04405 6C6.61463 6.25554 6.25554 6.61463 6 7.04405C5.74447 6.61463 5.38537 6.25554 4.95595 6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.9492 5.68544C14.8136 5.27624 14.4311 5 14 5C13.5689 5 13.1864 5.27624 13.0508 5.68544L11.3755 10.7408C11.2761 11.0408 11.0408 11.2761 10.7408 11.3755L5.68544 13.0508C5.27624 13.1864 5 13.5689 5 14C5 14.4311 5.27624 14.8136 5.68544 14.9492L10.7408 16.6245C11.0408 16.7239 11.2761 16.9592 11.3755 17.2592L13.0508 22.3146C13.1864 22.7238 13.5689 23 14 23C14.4311 23 14.8136 22.7238 14.9492 22.3146L16.6245 17.2592C16.7239 16.9592 16.9592 16.7239 17.2592 16.6245L22.3146 14.9492C22.7238 14.8136 23 14.4311 23 14C23 13.5689 22.7238 13.1864 22.3146 13.0508L17.2592 11.3755C16.9592 11.2761 16.7239 11.0408 16.6245 10.7408L14.9492 5.68544ZM13.274 11.3699L14 9.17903L14.726 11.3699C15.0242 12.2698 15.7302 12.9758 16.6301 13.274L18.821 14L16.6301 14.726C15.7302 15.0242 15.0242 15.7302 14.726 16.6301L14 18.821L13.274 16.6301C12.9758 15.7302 12.2698 15.0242 11.3699 14.726L9.17903 14L11.3699 13.274C12.2698 12.9758 12.9758 12.2698 13.274 11.3699Z",fill:"currentColor"})]}));Bo.displayName="AiSparklesIcon";function Ru({shortcutKeys:e=Do}){return l.jsx(R,{children:J({shortcutKeys:e})})}const e7=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:r=":",hideWhenUnavailable:s=!1,onTriggerApplied:i,showShortcut:a=!1,onClick:c,children:d,...f},p)=>{const{editor:h}=k(e),{isVisible:C,canAddTrigger:g,handleAddTrigger:b,label:m,shortcutKeys:w,Icon:v}=r7({editor:h,node:t,nodePos:n,trigger:r,hideWhenUnavailable:s,onTriggerApplied:i}),y=u.useCallback(x=>{c?.(x),!x.defaultPrevented&&b()},[b,c]);return C?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!g,"data-disabled":!g,"aria-label":m,tooltip:"Add emoji",onClick:y,...f,ref:p,children:d??l.jsxs(l.Fragment,{children:[l.jsx(v,{className:"tiptap-button-icon"}),o&&l.jsx("span",{className:"tiptap-button-text",children:o}),a&&l.jsx(Ru,{shortcutKeys:w})]})}):null});e7.displayName="EmojiTriggerButton";const Do="mod+shift+e";function Uo(e){return!(!e||!e.isEditable||ie(e,["image"]))}function t7(e,t,n,o){if(n!=null||X(o)){const s=me({editor:e,node:n||void 0,nodePos:o||void 0});if(!s)return!1;const i=s.node.type.name==="paragraph"&&s.node.content.size===0,a=s.pos+s.node.nodeSize;return e.chain().insertContentAt(i?s.pos:a,{type:"paragraph",content:[{type:"text",text:t}]}).focus(i?s.pos+t.length+1:a+t.length+1).run()}const{$from:r}=e.state.selection;return e.chain().insertContentAt(r.after(),{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}function n7(e,t,n,o){if(n!=null||X(o)){const a=me({editor:e,node:n||void 0,nodePos:o||void 0});if(!a)return!1;const c=a.node.type.name==="paragraph"&&a.node.content.size===0,d=a.pos+a.node.nodeSize;return e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,c?a.pos:d,c?a.pos:d)),e.commands.focus(c?a.pos+2:d+t.length+1),!0}const{$from:r}=e.state.selection,s=r.node(),i=r.parentOffset>0&&s.textContent[r.parentOffset-1]!==" ";return e.chain().insertContent({type:"text",text:i?` ${t}`:t}).focus().run()}function Zs(e,t=":",n,o){if(!e||!e.isEditable||!Uo(e))return!1;try{const{$from:r}=e.state.selection,s=r.node();return s.isBlock&&!s.isTextblock?t7(e,t,n,o):n7(e,t,n,o)}catch{return!1}}function o7(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:Uo(t):!1:!0:!1}function r7(e){const{editor:t,node:n,nodePos:o,trigger:r=":",hideWhenUnavailable:s=!1,onTriggerApplied:i}=e||{},{editor:a}=k(t),c=re(),[d,f]=u.useState(!0),p=Uo(a);u.useEffect(()=>{if(!a)return;const C=()=>{f(o7({editor:a,hideWhenUnavailable:s}))};return C(),a.on("selectionUpdate",C),()=>{a.off("selectionUpdate",C)}},[a,s]);const h=u.useCallback(()=>{if(!a)return!1;const C=Zs(a,r,n,o);return C&&i?.(r),C},[a,r,n,o,i]);return ue.useHotkeys(Do,C=>{C.preventDefault(),h()},{enabled:d&&p,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,handleAddTrigger:h,canAddTrigger:p,label:"Add emoji",shortcutKeys:Do,trigger:r,Icon:Ho}}function l7({shortcutKeys:e=Oo}){return l.jsx(R,{children:J({shortcutKeys:e})})}const s7=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:r="@",hideWhenUnavailable:s=!1,onTriggered:i,showShortcut:a=!1,onClick:c,children:d,...f},p)=>{const{editor:h}=k(e),{isVisible:C,canInsert:g,handleMention:b,label:m,shortcutKeys:w,Icon:v}=d7({editor:h,node:t,nodePos:n,trigger:r,hideWhenUnavailable:s,onTriggered:i}),y=u.useCallback(x=>{c?.(x),!x.defaultPrevented&&b()},[b,c]);return C?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!g,"data-disabled":!g,"aria-label":m,tooltip:m,onClick:y,...f,ref:p,children:d??l.jsxs(l.Fragment,{children:[l.jsx(v,{className:"tiptap-button-icon"}),o&&l.jsx("span",{className:"tiptap-button-text",children:o}),a&&l.jsx(l7,{shortcutKeys:w})]})}):null});s7.displayName="MentionTriggerButton";const Oo="mod+shift+2";function Po(e,t,n){if(!e||!e.isEditable||ie(e,["image"]))return!1;if(t||X(n)){if(X(n)&&n>=0)return!0;if(t)return me({editor:e,node:t})!==null}return!0}function i7(e,t,n,o){if(n!=null||X(o)){const s=me({editor:e,node:n||void 0,nodePos:o||void 0});if(!s)return!1;const i=s.node.type.name==="paragraph"&&s.node.content.size===0,a=i?s.pos:s.pos+s.node.nodeSize,c=t.length+1,d=i?s.pos+c:s.pos+s.node.nodeSize+c;return e.chain().insertContentAt(i?s.pos:a,{type:"paragraph",content:[{type:"text",text:t}]}).focus(d).run()}const{$from:r}=e.state.selection;return e.chain().insertContentAt(r.after(),{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}function a7(e,t,n,o){if(n!=null||X(o)){const a=me({editor:e,node:n||void 0,nodePos:o||void 0});if(!a)return!1;const c=a.node.type.name==="paragraph"&&a.node.content.size===0,d=c?a.pos:a.pos+a.node.nodeSize;e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,d,d));const f=t.length+1,p=c?a.pos+f:a.pos+a.node.nodeSize+f;return e.commands.focus(p),!0}const{$from:r}=e.state.selection,s=r.node(),i=r.parentOffset>0&&s.textContent[r.parentOffset-1]!==" ";return e.chain().insertContent({type:"text",text:i?` ${t}`:t}).focus().run()}function Fs(e,t="@",n,o){if(!e||!e.isEditable||!Po(e,n,o))return!1;try{const{$from:r}=e.state.selection,s=r.node();return s.isBlock&&!s.isTextblock?i7(e,t,n,o):a7(e,t,n,o)}catch{return!1}}function c7(e){const{editor:t,hideWhenUnavailable:n,node:o,nodePos:r}=e;return t?n?t.isEditable?t.isActive("code")?!0:Po(t,o,r):!1:!0:!1}function d7(e){const{editor:t,node:n,nodePos:o,trigger:r="@",hideWhenUnavailable:s=!1,onTriggered:i}=e||{},{editor:a}=k(t),c=re(),[d,f]=u.useState(!0),p=Po(a,n,o);u.useEffect(()=>{if(!a)return;const C=()=>{f(c7({editor:a,hideWhenUnavailable:s,node:n,nodePos:o}))};return C(),a.on("selectionUpdate",C),()=>{a.off("selectionUpdate",C)}},[a,s,n,o]);const h=u.useCallback(()=>{if(!a)return!1;const C=Fs(a,r,n,o);return C&&i?.(r),C},[a,r,n,o,i]);return ue.useHotkeys(Oo,C=>{C.preventDefault(),h()},{enabled:d&&p,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,handleMention:h,canInsert:p,label:"Add mention",shortcutKeys:Oo,trigger:r,Icon:No}}function u7(e){return{ai_continue_writing:{title:e.continueWriting,subtext:e.continueWritingSubtext,keywords:["ai","continue","writing","autocomplete","complete"],badge:Bo,group:e.ai},ai_ask:{title:e.askAi,subtext:e.askAiSubtext,keywords:["ai","ask","assistant","generate","write"],badge:Bo,group:e.ai},text:{title:e.text,subtext:e.regularTextParagraph,keywords:["p","paragraph","text"],badge:Mo,group:e.style},heading_1:{title:e.heading1,subtext:e.topLevelHeading,keywords:["h","heading1","h1"],badge:ko,group:e.style},heading_2:{title:e.heading2,subtext:e.heading2,keywords:["h2","heading2","subheading"],badge:So,group:e.style},heading_3:{title:e.heading3,subtext:e.subsectionAndGroupHeading,keywords:["h3","heading3","subheading"],badge:To,group:e.style},bullet_list:{title:e.bulletList,subtext:e.listWithUnorderedItems,keywords:["ul","li","list","bulletlist","bullet list"],badge:Ao,group:e.style},ordered_list:{title:e.orderedList,subtext:e.listWithOrderedItems,keywords:["ol","li","list","numberedlist","numbered list"],badge:Io,group:e.style},task_list:{title:e.taskList,subtext:e.listWithTasks,keywords:["tasklist","task list","todo","checklist"],badge:Eo,group:e.style},quote:{title:e.blockquote,subtext:e.blockquoteBlock,keywords:["quote","blockquote"],badge:Lo,group:e.style},code_block:{title:e.codeBlock,subtext:e.codeBlockWithSyntaxHighlighting,keywords:["code","pre"],badge:xo,group:e.style},mention:{title:e.mention,subtext:e.mentionSubtext,keywords:["mention","user","item","tag"],badge:No,group:e.insert},emoji:{title:e.emoji,subtext:e.emojiSubtext,keywords:["emoji","emoticon","smiley"],badge:Ho,group:e.insert},table:{title:e.table,subtext:e.tableSubtext,keywords:["table","insertTable"],badge:_s,group:e.insert},divider:{title:e.separator,subtext:e.separatorSubtext,keywords:["hr","horizontalRule","line","separator"],badge:Ws,group:e.insert},toc:{title:e.tableOfContents,subtext:e.tableOfContentsSubtext,keywords:["toc","tableofcontents","table of contents"],badge:Vo,group:e.insert},image:{title:e.image,subtext:e.imageSubtext,keywords:["image","imageUpload","upload","img","picture","media","url"],badge:Ps,group:e.upload}}}function f7(e,t){return t?.aiEnabled?e:e.filter(n=>!n.startsWith("ai_"))}const p7=e=>({ai_continue_writing:{check:t=>t.isEditable,action:({editor:t})=>{t.chain().focus().run(),e?.onAiAction?.("continue_writing")}},ai_ask:{check:t=>t.isEditable,action:({editor:t})=>{t.chain().focus().run(),e?.onAiAction?.("ask")}},text:{check:t=>te("paragraph",t),action:({editor:t})=>{t.chain().focus().setParagraph().run()}},heading_1:{check:t=>te("heading",t),action:({editor:t})=>{t.chain().focus().toggleHeading({level:1}).run()}},heading_2:{check:t=>te("heading",t),action:({editor:t})=>{t.chain().focus().toggleHeading({level:2}).run()}},heading_3:{check:t=>te("heading",t),action:({editor:t})=>{t.chain().focus().toggleHeading({level:3}).run()}},bullet_list:{check:t=>te("bulletList",t),action:({editor:t})=>{t.chain().focus().toggleBulletList().run()}},ordered_list:{check:t=>te("orderedList",t),action:({editor:t})=>{t.chain().focus().toggleOrderedList().run()}},task_list:{check:t=>te("taskList",t),action:({editor:t})=>{t.chain().focus().toggleTaskList().run()}},quote:{check:t=>te("blockquote",t),action:({editor:t})=>{t.chain().focus().toggleBlockquote().run()}},code_block:{check:t=>te("codeBlock",t),action:({editor:t})=>{t.chain().focus().toggleNode("codeBlock","paragraph").run()}},mention:{check:t=>_(t,["mention","mentionAdvanced"]),action:({editor:t})=>Fs(t)},emoji:{check:t=>_(t,["emoji","emojiPicker"]),action:({editor:t})=>Zs(t)},divider:{check:t=>te("horizontalRule",t),action:({editor:t})=>{t.chain().focus().setHorizontalRule().run()}},toc:{check:t=>te("tocNode",t),action:({editor:t})=>{t.chain().focus().insertTocNode().run()}},table:{check:t=>te("table",t),action:({editor:t})=>{t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}},image:{check:t=>te("image",t),action:({editor:t})=>{t.chain().focus().insertContent({type:"imageUpload"}).run()}}});function h7(e,t){if(!t)return e.map(r=>({...r,group:""}));const n={};e.forEach(r=>{const s=r.group||"";n[s]||(n[s]=[]),n[s].push(r)});const o=[];return Object.entries(n).forEach(([,r])=>{o.push(...r)}),o}function C7(e){const t=D();return{getSlashMenuItems:u.useCallback(o=>{const r=[],s=u7(t),i=f7(e?.enabledItems||Object.keys(s),e),a=e?.showGroups!==!1,c=p7(e);return i.forEach(d=>{const f=c[d],p=s[d];if(f&&p&&f.check(o)){const h={onSelect:({editor:C})=>f.action({editor:C}),...p};e?.itemGroups?.[d]?h.group=e.itemGroups[d]:a||(h.group=""),r.push(h)}}),e?.customItems&&r.push(...e.customItems),h7(r,a)},[e,t]),config:e}}const g7=e=>{const{config:t,...n}=e,{getSlashMenuItems:o}=C7(t);return l.jsx(mo,{char:"/",pluginKey:"slashDropdownMenu",decorationClass:"tiptap-slash-decoration",decorationContent:"Filter...",selector:"tiptap-slash-dropdown-menu",items:({query:r,editor:s})=>Lu(o(s),r),...n,children:r=>l.jsx(b7,{...r,config:t})})},zs=e=>{const{item:t,isSelected:n,onSelect:o}=e,r=u.useRef(null);u.useEffect(()=>{const a=document.querySelector('[data-selector="tiptap-slash-dropdown-menu"]')?.querySelector(".tiptap-slash-card-body");if(!r.current||!n||!a)return;const c=r.current.previousElementSibling,d=c instanceof HTMLElement&&c.classList.contains("tiptap-card-group-label")?c.getBoundingClientRect().top:r.current.getBoundingClientRect().top,f=r.current.getBoundingClientRect(),p=a.getBoundingClientRect();d<p.top?a.scrollTop-=p.top-d:f.bottom>p.bottom&&(a.scrollTop+=f.bottom-p.bottom)},[n]);const s=t.badge;return l.jsxs(M,{ref:r,variant:"ghost","data-active-state":n?"on":"off",onClick:o,children:[s&&l.jsx(s,{className:"tiptap-button-icon"}),l.jsx("div",{className:"tiptap-button-text",children:t.title})]})},b7=({items:e,selectedIndex:t,onSelect:n,config:o})=>{const r=u.useMemo(()=>{const s=[];if(!(o?.showGroups!==!1))return e.forEach((c,d)=>{s.push(l.jsx(zs,{item:c,isSelected:d===t,onSelect:()=>n(c)},`item-${d}-${c.title}`))}),s;const a={};return e.forEach((c,d)=>{const f=c.group||"";a[f]||(a[f]={items:[],indices:[]}),a[f].items.push(c),a[f].indices.push(d)}),Object.entries(a).forEach(([c,d],f)=>{f>0&&s.push(l.jsx(ee,{orientation:"horizontal"},`separator-${f}`));const p=d.items.map((h,C)=>{const g=d.indices[C];return l.jsx(zs,{item:h,isSelected:g===t,onSelect:()=>n(h)},`item-${g}-${h.title}`)});c?s.push(l.jsxs(Me,{children:[l.jsx(bt,{children:c}),p]},`group-${f}-${c}`)):s.push(...p)}),s},[e,t,n,o?.showGroups]);return r.length?l.jsx(_e,{className:"tiptap-slash-card",style:{maxHeight:"var(--suggestion-menu-max-height)"},children:l.jsx(Ze,{className:"tiptap-slash-card-body",children:r})}):null},Yt=u.forwardRef(({editor:e,shouldShow:t=void 0,floatingOptions:n,zIndex:o=50,onOpenChange:r,referenceElement:s,getBoundingClientRect:i=Nu,closeOnEscape:a=!0,resetTextSelectionOnClose:c=!0,children:d,style:f,...p},h)=>{const[C,g]=u.useState(t!==void 0?t:!1),b=u.useRef(null),m=u.useRef(!1),w=u.useRef(!1),v=u.useRef(null),y=u.useRef(i),{editor:x}=k(e);u.useEffect(()=>{v.current=x,y.current=i},[x,i]);const S=u.useCallback(U=>{r?.(U),g(U)},[r]),L=U=>{if(!U&&x&&c){const H=x.state.tr.setSelection(E.Selection.near(x.state.doc.resolve(0)));x.view.dispatch(H)}S(U)},I=u.useMemo(()=>s||(()=>v.current?y.current(v.current):null),[s]),{isMounted:V,ref:K,style:le,getFloatingProps:O}=Ss(C,I,o,{placement:"top",middleware:[F.shift(),F.flip(),F.offset(4)],onOpenChange:L,dismissOptions:{enabled:!0,escapeKey:!0,outsidePress(U){const H=U.target;return!H||qs(H)?!1:!$s(x,H)}},...n}),Y=u.useCallback(()=>{if(!x)return;const U=i(x);if(U&&t!==void 0&&!w.current){S(t);return}const H=Is(x);U&&!w.current&&(H||m.current)?S(!0):!m.current&&(!H||w.current||!x.isEditable)&&S(!1)},[x,i,S,t]);u.useEffect(()=>{if(!x||!a)return;const U=H=>H.key==="Escape"&&C?(S(!1),!0):!1;return x.view.dom.addEventListener("keydown",U),()=>{x.view.dom.removeEventListener("keydown",U)}},[x,C,a,S]),u.useEffect(()=>{if(!x)return;const U=H=>{if(m.current){m.current=!1;return}const W=H.relatedTarget;if(!W)return;const P=$s(x,W),q=b.current,$=q&&(q===W||q.contains(W)),se=qs(W);!P&&!$&&!se&&C&&S(!1)};return x.view.dom.addEventListener("blur",U),()=>{x.view.dom.removeEventListener("blur",U)}},[x,S,C]),u.useEffect(()=>{if(!x)return;const U=()=>{C&&S(!1)};return x.view.dom.addEventListener("dragstart",U),x.view.dom.addEventListener("dragover",U),()=>{x.view.dom.removeEventListener("dragstart",U),x.view.dom.removeEventListener("dragover",U)}},[x,C,S]),u.useEffect(()=>{if(!x)return;const U=W=>{if(W.button!==0||(w.current=!0,W.detail>1))return;const{state:P,view:q}=x,$=q.posAtCoords({left:W.clientX,top:W.clientY});if(!$||!X($.pos))return;const be=P.doc.resolve($.pos).nodeBefore;if(!be||be.isBlock)return;const ot=P.tr.setSelection(E.Selection.near(P.doc.resolve($.pos)));q.dispatch(ot)},H=()=>{w.current&&(w.current=!1,Y())};return x.view.dom.addEventListener("mousedown",U),x.view.root.addEventListener("mouseup",H),()=>{x.view.dom.removeEventListener("mousedown",U),x.view.root.removeEventListener("mouseup",H)}},[x,Y]),u.useEffect(()=>{if(x)return x.on("selectionUpdate",Y),()=>{x.off("selectionUpdate",Y)}},[x,Y]),u.useEffect(()=>{x&&Y()},[x,Y]);const A=u.useMemo(()=>f&&Object.keys(f).length>0?f:le,[f,le]),N=F.useMergeRefs([K,h,b]);return!x||!V||!C?null:l.jsx("div",{ref:N,style:A,...p,...O(),children:d})});Yt.displayName="FloatingElement";const $s=(e,t)=>{if(!t||!e)return!1;const n=e.view.dom.parentElement,o=e.view.dom;return n?n===t||o===t||n.contains(t):!1},qs=e=>e instanceof HTMLElement?e.closest(["[data-radix-popper-content-wrapper]","[data-base-ui-portal]"].join(","))!==null:!1,Gs=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M10.5 1C9.43913 1 8.42172 1.42143 7.67157 2.17157C6.92143 2.92172 6.5 3.93913 6.5 5V12C6.5 13.0609 6.92143 14.0783 7.67157 14.8284C8.42172 15.5786 9.43913 16 10.5 16C11.5609 16 12.5783 15.5786 13.3284 14.8284C14.0786 14.0783 14.5 13.0609 14.5 12C14.5 11.4477 14.0523 11 13.5 11C12.9477 11 12.5 11.4477 12.5 12C12.5 12.5304 12.2893 13.0391 11.9142 13.4142C11.5391 13.7893 11.0304 14 10.5 14C9.96957 14 9.46086 13.7893 9.08579 13.4142C8.71071 13.0391 8.5 12.5304 8.5 12V5C8.5 4.46957 8.71071 3.96086 9.08579 3.58579C9.46086 3.21071 9.96957 3 10.5 3C11.0523 3 11.5 2.55228 11.5 2C11.5 1.44772 11.0523 1 10.5 1Z",fill:"currentColor"}),l.jsx("path",{d:"M4.5 10C4.5 9.44771 4.05228 9 3.5 9C2.94772 9 2.5 9.44771 2.5 10V12C2.5 13.7611 3.0811 15.4729 4.15318 16.8701C5.22525 18.2672 6.72838 19.2716 8.42945 19.7274C8.7827 19.8221 9.14038 19.892 9.5 19.9373V22C9.5 22.5523 9.94772 23 10.5 23C11.0523 23 11.5 22.5523 11.5 22V19.9373C12.2039 19.8486 12.8974 19.6661 13.5615 19.391C15.1885 18.7171 16.5477 17.5251 17.4282 16C17.7043 15.5217 17.5405 14.9101 17.0622 14.634C16.5839 14.3578 15.9723 14.5217 15.6962 15C15.0358 16.1438 14.0164 17.0378 12.7961 17.5433C11.5758 18.0487 10.2229 18.1374 8.94709 17.7956C7.67129 17.4537 6.54394 16.7004 5.73988 15.6526C4.93583 14.6047 4.5 13.3208 4.5 12L4.5 11.9977V10Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.4492 1.68544C17.3136 1.27624 16.9311 1 16.5 1C16.0689 1 15.6864 1.27624 15.5508 1.68544L14.8711 3.73642C14.7717 4.03638 14.5364 4.2717 14.2364 4.3711L12.1854 5.05076C11.7762 5.18636 11.5 5.56892 11.5 6C11.5 6.43108 11.7762 6.81364 12.1854 6.94924L14.2364 7.6289C14.5364 7.7283 14.7717 7.96362 14.8711 8.26358L15.5508 10.3146C15.6864 10.7238 16.0689 11 16.5 11C16.9311 11 17.3136 10.7238 17.4492 10.3146L18.1289 8.26358C18.2283 7.96362 18.4636 7.7283 18.7636 7.6289L20.8146 6.94924C21.2238 6.81364 21.5 6.43108 21.5 6C21.5 5.56892 21.2238 5.18636 20.8146 5.05076L18.7636 4.3711C18.4636 4.2717 18.2283 4.03638 18.1289 3.73642L17.4492 1.68544ZM15.4559 6C15.8854 5.74447 16.2445 5.38537 16.5 4.95595C16.7555 5.38537 17.1146 5.74447 17.5441 6C17.1146 6.25554 16.7555 6.61463 16.5 7.04405C16.2445 6.61463 15.8854 6.25554 15.4559 6Z",fill:"currentColor"})]}));Gs.displayName="MicAiIcon";const Wo=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M18.7071 6.70711C19.0976 6.31658 19.0976 5.68342 18.7071 5.29289C18.3166 4.90237 17.6834 4.90237 17.2929 5.29289L12 10.5858L6.70711 5.29289C6.31658 4.90237 5.68342 4.90237 5.29289 5.29289C4.90237 5.68342 4.90237 6.31658 5.29289 6.70711L10.5858 12L5.29289 17.2929C4.90237 17.6834 4.90237 18.3166 5.29289 18.7071C5.68342 19.0976 6.31658 19.0976 6.70711 18.7071L12 13.4142L17.2929 18.7071C17.6834 19.0976 18.3166 19.0976 18.7071 18.7071C19.0976 18.3166 19.0976 17.6834 18.7071 17.2929L13.4142 12L18.7071 6.70711Z",fill:"currentColor"})}));Wo.displayName="XIcon";function m7(e){return e.trim()}function w7({action:e,editor:t,open:n,onOpenChange:o,onSubmit:r,signal:s}){const i=D(),a=u.useRef(null),[c,d]=u.useState("");u.useEffect(()=>{if(!n){d("");return}window.requestAnimationFrame(()=>{a.current?.focus()})},[n]);const f=e==="continue_writing"?i.continueWritingPrompt:i.askAiPrompt,p=m7(c),h=async()=>{!e||!p||(r&&await r({action:e,editor:t,prompt:p,signal:s}),o(!1))};return l.jsx(Yt,{editor:t,shouldShow:n,onOpenChange:o,closeOnEscape:!0,resetTextSelectionOnClose:!1,zIndex:1001,floatingOptions:{placement:"bottom-start"},className:"tiptap-ai-composer",role:"dialog","aria-label":i.ai,children:l.jsxs("div",{className:"tiptap-ai-composer__body",children:[l.jsx("textarea",{ref:a,className:"tiptap-ai-composer__textarea",placeholder:f,value:c,rows:1,onChange:C=>d(C.target.value),onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),o(!1)),C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),h())}}),l.jsxs("div",{className:"tiptap-ai-composer__footer",children:[l.jsxs("button",{type:"button",className:"tiptap-ai-composer__tone","aria-label":i.aiTone,children:[l.jsx(Gs,{className:"tiptap-ai-composer__icon"}),l.jsx("span",{children:i.aiTone})]}),l.jsxs("div",{className:"tiptap-ai-composer__actions",children:[l.jsx("button",{type:"button",className:"tiptap-ai-composer__icon-button","aria-label":i.close,onClick:()=>o(!1),children:l.jsx(Wo,{className:"tiptap-ai-composer__icon"})}),l.jsx("button",{type:"button",className:"tiptap-ai-composer__submit","aria-label":i.submitAiPrompt,disabled:!p,onClick:()=>{h()},children:l.jsx(On,{className:"tiptap-ai-composer__icon"})})]})]})]})})}const v7=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 2C7.43108 2 7.81364 2.27624 7.94924 2.68544L8.6289 4.73642C8.7283 5.03638 8.96362 5.2717 9.26358 5.3711L11.3146 6.05076C11.7238 6.18636 12 6.56892 12 7C12 7.43108 11.7238 7.81364 11.3146 7.94924L9.26358 8.6289C8.96362 8.7283 8.7283 8.96362 8.6289 9.26358L7.94924 11.3146C7.81364 11.7238 7.43108 12 7 12C6.56892 12 6.18636 11.7238 6.05076 11.3146L5.3711 9.26358C5.2717 8.96362 5.03638 8.7283 4.73642 8.6289L2.68544 7.94924C2.27624 7.81364 2 7.43108 2 7C2 6.56892 2.27624 6.18636 2.68544 6.05076L4.73642 5.3711C5.03638 5.2717 5.2717 5.03638 5.3711 4.73642L6.05076 2.68544C6.18636 2.27624 6.56892 2 7 2ZM7 5.95595C6.74447 6.38537 6.38537 6.74447 5.95595 7C6.38537 7.25554 6.74447 7.61463 7 8.04405C7.25554 7.61463 7.61463 7.25554 8.04405 7C7.61463 6.74447 7.25554 6.38537 7 5.95595Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.7071 8.29289C22.0976 8.68342 22.0976 9.31658 21.7071 9.70711L10.7071 20.7071C10.3166 21.0976 9.68342 21.0976 9.29289 20.7071L4.29289 15.7071C3.90237 15.3166 3.90237 14.6834 4.29289 14.2929C4.68342 13.9024 5.31658 13.9024 5.70711 14.2929L10 18.5858L20.2929 8.29289C20.6834 7.90237 21.3166 7.90237 21.7071 8.29289Z",fill:"currentColor"})]}));v7.displayName="CheckAiIcon";const y7=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M11.9949 2.00001C9.22128 2.01079 6.55914 3.0932 4.56496 5.02103L4.55289 5.03289L4 5.58579V3C4 2.44771 3.55228 2 3 2C2.44771 2 2 2.44771 2 3V7.99931L2 8.003C2.0004 8.1375 2.02735 8.26575 2.07588 8.38278C2.12357 8.49805 2.19374 8.6062 2.2864 8.70055L2.29945 8.7136C2.3938 8.80626 2.50195 8.87643 2.61722 8.92412C2.73512 8.97301 2.86441 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41421L5.96097 6.45325C7.58334 4.8878 9.74744 4.00891 12.0021 4C13.7624 4.00045 15.4735 4.58152 16.8701 5.65317C18.2673 6.72525 19.2716 8.22838 19.7274 9.92945C19.8704 10.4629 20.4187 10.7795 20.9522 10.6366C21.4856 10.4936 21.8022 9.94528 21.6593 9.41181C21.0895 7.28548 19.8341 5.40656 18.0876 4.06647C16.3412 2.72637 14.2014 2 12 2L11.9962 2.00001L11.9949 2.00001Z",fill:"currentColor"}),l.jsx("path",{d:"M10.6366 20.9522C10.4936 21.4856 9.9453 21.8022 9.41183 21.6593C7.2855 21.0895 5.40658 19.8341 4.06649 18.0876C2.72639 16.3412 2.00002 14.2013 2.00002 12C2.00002 11.4477 2.44774 11 3.00002 11C3.55231 11 4.00002 11.4477 4.00002 12C4.00002 13.7611 4.58112 15.4729 5.65319 16.8701C6.72527 18.2672 8.2284 19.2716 9.92947 19.7274C10.4629 19.8703 10.7795 20.4187 10.6366 20.9522Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.9379 11.653C17.7926 11.2605 17.4184 11 17 11C16.5816 11 16.2074 11.2605 16.0621 11.653L14.9511 14.6556C14.9004 14.7925 14.7925 14.9004 14.6556 14.9511L11.653 16.0621C11.2605 16.2074 11 16.5816 11 17C11 17.4184 11.2605 17.7926 11.653 17.9379L14.6556 19.0489C14.7925 19.0996 14.9004 19.2075 14.9511 19.3444L16.0621 22.347C16.2074 22.7395 16.5816 23 17 23C17.4184 23 17.7926 22.7395 17.9379 22.347L19.0489 19.3444C19.0996 19.2075 19.2075 19.0996 19.3444 19.0489L22.347 17.9379C22.7395 17.7926 23 17.4184 23 17C23 16.5816 22.7395 16.2074 22.347 16.0621L19.3444 14.9511C19.2075 14.9004 19.0996 14.7925 19.0489 14.6556L17.9379 11.653ZM16.8268 15.3497L17 14.8815L17.1732 15.3497C17.4265 16.034 17.966 16.5735 18.6503 16.8268L19.1185 17L18.6503 17.1732C17.966 17.4265 17.4265 17.966 17.1732 18.6503L17 19.1185L16.8268 18.6503C16.5735 17.966 16.034 17.4265 15.3497 17.1732L14.8815 17L15.3497 16.8268C16.034 16.5735 16.5735 16.034 16.8268 15.3497Z",fill:"currentColor"})]}));y7.displayName="RefreshAiIcon";const x7=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12ZM8 9C8 8.44772 8.44772 8 9 8H15C15.5523 8 16 8.44772 16 9V15C16 15.5523 15.5523 16 15 16H9C8.44772 16 8 15.5523 8 15V9Z",fill:"currentColor"})}));x7.displayName="StopCircle2Icon";const k7={amp:"&",gt:">",lt:"<",nbsp:" ",quot:'"'};function Ks(e){const t=T7(e);if(!t.length)return null;const n=I7(t);return{type:"table",content:t.map((r,s)=>({type:"tableRow",content:r.map(i=>L7(i,s<n))}))}}function Ys(e){return!!(e.type==="table"&&js(e)||e.content?.some(t=>Ys(t)))}function js(e){return e.type!=="table"?!1:!!e.content?.some(t=>t.content?.some(n=>{const o=Number(n.attrs?.colspan??1),r=Number(n.attrs?.rowspan??1);return o>1||r>1}))}function S7(e,t){return`<table>${(e.content||[]).filter(o=>o.type==="tableRow").map(o=>`<tr>${(o.content||[]).filter(s=>s.type==="tableCell"||s.type==="tableHeader").map(s=>N7(s,t)).join("")}</tr>`).join("")}</table>`}function T7(e){return Array.from(e.matchAll(/<tr\b[^>]*>([\s\S]*?)<\/tr>/gi)).map(t=>A7(t[1])).filter(t=>t.length>0)}function A7(e){return Array.from(e.matchAll(/<(t[dh])\b([^>]*)>([\s\S]*?)<\/\1>/gi)).map(t=>({tagName:t[1].toLowerCase(),text:E7(t[3]),colspan:Xs(t[2],"colspan"),rowspan:Xs(t[2],"rowspan")}))}function I7(e){const t=e.findIndex(r=>r.some(s=>s.tagName!=="th"));if(t>0)return t;const[n]=e,o=n?.reduce((r,s)=>Math.max(r,s.rowspan),1)||1;return Math.min(o,e.length)}function L7(e,t){const n=e.text?[{type:"text",text:e.text}]:void 0;return{type:e.tagName==="th"||t?"tableHeader":"tableCell",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:e.colspan,rowspan:e.rowspan,colwidth:null},content:[{type:"paragraph",content:n}]}}function Xs(e,t){const n=e.match(new RegExp(`${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'>/]+))`,"i")),o=n?.[1]??n?.[2]??n?.[3],r=Number.parseInt(o||"1",10);return Number.isFinite(r)&&r>0?r:1}function E7(e){return M7(e.replace(/<br\s*\/?>/gi,`
|
|
5
5
|
`).replace(/<[^>]*>/g,"").replace(/[ \t\f\v]+/g," ").replace(/\s*\n\s*/g,`
|
|
6
|
-
`).trim())}function
|
|
7
|
-
`),n=[];let o=0;for(;o<t.length;){const r=[],s=o;for(;o<t.length;){const i=
|
|
8
|
-
`)}function
|
|
9
|
-
`);return
|
|
10
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\+(["'`{}[\](),:])/g,"$1");if(o===t)break;t=o}return t}function
|
|
6
|
+
`).trim())}function M7(e){return e.replace(/&(#x[\da-f]+|#\d+|[a-z]+);/gi,(t,n)=>{const o=String(n).toLowerCase();return o.startsWith("#x")?Js(Number.parseInt(o.slice(2),16),t):o.startsWith("#")?Js(Number.parseInt(o.slice(1),10),t):k7[o]||t})}function Js(e,t){if(!Number.isFinite(e))return t;try{return String.fromCodePoint(e)}catch{return t}}function N7(e,t){const n=e.type==="tableHeader"?"th":"td",o=[Qs("colspan",e.attrs?.colspan,1),Qs("rowspan",e.attrs?.rowspan,1),H7(e.attrs?.colwidth)].filter(Boolean).join(""),r=V7(e,t);return`<${n}${o}>${r}</${n}>`}function Qs(e,t,n){const o=Number(t??n);return!Number.isFinite(o)||o===n?"":` ${e}="${_o(String(o))}"`}function H7(e){return!Array.isArray(e)||!e.length?"":` colwidth="${_o(e.join(","))}"`}function V7(e,t){const n=e.content||[];return n.length===1&&n[0].type==="paragraph"&&n[0].content?n[0].content.map(o=>B7(o)).join(""):n.map(o=>t(o).trim()).filter(Boolean).map(jt).join("<br>")}function B7(e){if(e.type==="text"){let t=jt(e.text||"");for(const n of e.marks||[])n.type==="bold"?t=`<strong>${t}</strong>`:n.type==="italic"?t=`<em>${t}</em>`:n.type==="code"?t=`<code>${t}</code>`:n.type==="strike"?t=`<s>${t}</s>`:n.type==="link"&&n.attrs?.href&&(t=`<a href="${_o(String(n.attrs.href))}">${t}</a>`);return t}return jt(e.text||"")}function jt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function _o(e){return jt(e).replace(/"/g,""")}const D7=new Set(["abc","echarts","flowchart","graphviz","markmap","mermaid","mindmap","plantuml","smiles"]),U7=[Nr.StarterKit.configure({dropcursor:!1,gapcursor:!1,undoRedo:!1}),Tt.TaskList,Tt.TaskItem.configure({nested:!0}),Or.Image,Br.Mathematics,Be.Table.configure({resizable:!1}),Be.TableRow,Be.TableHeader,Be.TableCell],Zo=new I1.MarkdownManager({extensions:U7});function Fo(e,t,n){console.log(`[omnibox-editor:${e}] input`,t),console.log(`[omnibox-editor:${e}] output`,n)}function zo(e){return e?.debug!==!1}function O7(e){return!!e&&!e.startsWith("/")&&!e.startsWith("#")&&!/^[a-z][a-z\d+.-]*:/i.test(e)}function P7(e){const t=e.match(/^([^?#]*)([?#].*)?$/);return{path:t?.[1]??"",suffix:t?.[2]??""}}function Rs(e){return e.replace(/^(\.\/)+/,"").replace(/^\/+|\/+$/g,"").split("/").filter(Boolean)}function W7(e,t){const n=Math.min(e.length,t.length);for(let o=n;o>0;o--){const r=e.slice(-o),s=t.slice(0,o);if(r.every((i,a)=>i===s[a]))return o}return 0}function ei(e,t){const n=Rs(e),o=Rs(t),r=W7(n,o);return[...n,...o.slice(r)].join("/")}function $o(e,t){const n=t?.linkBase?.trim().replace(/\/$/,"");if(!n||!O7(e))return e;const{path:o,suffix:r}=P7(e);try{const s=new URL(n);return s.pathname=`/${ei(s.pathname,o)}`,s.search="",s.hash="",`${s.toString()}${r}`}catch{const s=ei(n,o);return`${n.startsWith("/")?"/":""}${s}${r}`}}function ti(){return{type:"paragraph",content:[]}}function _7(e){return e.replace(/^(\s*[-+*]\s+)\\\[([ xX])\\\](?=\s+)/gm,"$1[$2]")}function Z7(e){return e.replace(/^([ \t]*)(\\```|\\`\\`\\`|\\~~~|\\~\\~\\~)(.*)$/gm,(t,n,o,r)=>{const s=o.includes("`")?"```":"~~~";return`${n}${s}${r}`})}function F7(e){const t=e.split(`
|
|
7
|
+
`),n=[];let o=0;for(;o<t.length;){const r=[],s=o;for(;o<t.length;){const i=z7(t[o]);if(i===null)break;r.push(i),o+=1}if(r.length>=3){const i=$7(r);if(i){n.push(`\`\`\`${i.language}`,i.code,"```");continue}}if(o===s){n.push(t[o]),o+=1;continue}n.push(...t.slice(s,o))}return n.join(`
|
|
8
|
+
`)}function z7(e){const n=e.trim().match(/^`([^`]*)`$/);return n?n[1]:null}function $7(e){const t=e.join(`
|
|
9
|
+
`);return q7(t)?{language:"echarts",code:t}:G7(t)?{language:"mermaid",code:t}:null}function q7(e){const t=e.trim();return!t.startsWith("{")||!t.endsWith("}")?!1:/"?(series|xAxis|yAxis|tooltip|legend|grid|title)"?\s*:/.test(t)}function G7(e){return/^(mindmap|flowchart|graph|sequenceDiagram|stateDiagram|erDiagram)\b/m.test(e.trim())}function K7(e){return typeof e=="string"?e.trim().toLowerCase():""}function Y7(e){let t=e;for(let n=0;n<10;n+=1){const o=t.replace(/\\n/g,`
|
|
10
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\+(["'`{}[\](),:])/g,"$1");if(o===t)break;t=o}return t}function qo(e){return e.type==="doc"?{...e,content:e.content?.length?e.content:[ti()]}:{type:"doc",content:[e]}}function vt(e,t){let n=e.attrs?{...e.attrs}:void 0;const o=e.marks?.map(r=>r.attrs?.href?{...r,attrs:{...r.attrs,href:$o(String(r.attrs.href),t)}}:r);return n?.href&&(n.href=$o(String(n.href),t)),n?.src&&(n.src=$o(String(n.src),t)),e.type==="image"&&(n=n??{},n.showCaption=n.showCaption??!1),{...e,...n?{attrs:n}:{},...o?{marks:o}:{},...e.content?{content:e.content.map(r=>vt(r,t))}:{}}}function yt(e,t){const n=F7(Z7(_7(e))),o=vt(ri(oi(qo(Zo.parse(n)))),t);return zo(t)&&Fo("markdownToTiptapJson",e,o),o}function Go(e,t){const n=X7(e);if(!n.some(s=>s.type==="table"))return yt(e,t);const o=n.flatMap(s=>{if(s.type==="table"){const i=Ks(s.value);return i?[i]:ni(s.value,t)}return ni(s.value,t)}),r=vt({type:"doc",content:o.length?o:[ti()]},t);return zo(t)&&Fo("markdownWithHtmlTablesToTiptapJson",e,r),r}function Xt(e,t){if(typeof e!="string")return vt(qo(e),t);const n=e.trim();if(!n)return yt("",t);try{const o=JSON.parse(n);if(typeof o=="string")return Go(o,t);if(o?.type==="doc"&&Array.isArray(o.content))return vt(o,t)}catch{}return Go(e,t)}function Jt(e,t){const n=r4(e);return zo(t)&&Fo("tiptapJsonToMarkdown",e,n),n}function j7(e,t){return Jt(Xt(e,t),t)}function X7(e){const t=[],n=/<table\b[\s\S]*?<\/table>/gi;let o=0,r;for(;r=n.exec(e);)r.index>o&&t.push({type:"markdown",value:e.slice(o,r.index)}),t.push({type:"table",value:r[0]}),o=n.lastIndex;return o<e.length&&t.push({type:"markdown",value:e.slice(o)}),t}function ni(e,t){return e.trim()?(yt(e,t).content||[]).filter(n=>!J7(n)):[]}function J7(e){return e.type==="paragraph"&&!e.content?.length}function oi(e){return e.type==="table"?Q7(e):{...e,...e.content?{content:e.content.map(t=>oi(t))}:{}}}function ri(e){return e.type==="codeBlock"&&D7.has(K7(e.attrs?.language))?{...e,...e.content?{content:e.content.map(t=>t.type==="text"&&typeof t.text=="string"?{...t,text:Y7(t.text)}:t)}:{}}:{...e,...e.content?{content:e.content.map(t=>ri(t))}:{}}}function Q7(e){const t=e.content||[],n=R7(t);if(!n)return e;const o=e4(t,n),r=t4(o,n);return{...e,content:r}}function R7(e){const[t,n,...o]=e;if(!t||!n)return null;const r=t.content||[],s=n.content||[];if(r.length!==s.length||r.some(d=>d.type!=="tableHeader")||s.some(d=>!o4(d)))return null;const i=r.findIndex(nt);if(i<=0||!r.slice(i).every(nt)||nt(r[i-1]))return null;const c=s.filter(d=>!nt(d));return c.length<=1?null:{fixedColumnCount:i-1,groupColumnCount:c.length,logicalColumnCount:r.length}}function e4(e,t){const[n,o,...r]=e,s=n.content||[],a=(o.content||[]).filter(d=>!nt(d)).map(d=>({...d,type:"tableHeader"}));if(!n||!o)return e;const c=s.slice(0,t.fixedColumnCount+1).map((d,f)=>f===t.fixedColumnCount?Yo(d,{colspan:t.groupColumnCount}):Yo(d,{rowspan:2}));return[{...n,content:c},{...o,content:a},...r]}function t4(e,t){const n=[];let o=[];const r=()=>{if(!o.length)return;const s=Math.max(...o.map((i,a)=>a===0?0:Ko(i.content||[],t)));o.forEach((i,a)=>{const c=i.content||[];if(a===0&&o.length>1&&s>0){n.push({...i,content:c.map((d,f)=>f<s?Yo(d,{rowspan:o.length}):d)});return}if(a>0){const d=Ko(c,t);n.push({...i,content:n4(c,d)});return}n.push(i)}),o=[]};return e.forEach(s=>{const i=s.content||[];if(!i.length||i.some(c=>c.type==="tableHeader")){r(),n.push(s);return}const a=Ko(i,t);(!o.length||a===0)&&r(),o.push(s)}),r(),n}function Ko(e,t){const n=e.findIndex(o=>!nt(o));return n>0?Math.min(n,t.fixedColumnCount):li(jo(e[0]))?Math.min(2,t.fixedColumnCount):li(jo(e[1]))?Math.min(1,t.fixedColumnCount):0}function n4(e,t){if(t<=0)return e;const n=[...e];for(let o=0;o<t;o+=1)n.pop();return n}function Yo(e,t){return{...e,attrs:{...e.attrs,...t}}}function nt(e){return!jo(e).trim()}function o4(e){return e?.type==="tableCell"||e?.type==="tableHeader"}function jo(e){return e&&e.content?.map(t=>t.content?.map(n=>n.text||"").join("")||"").join("")||""}function li(e){return/^\s*\d+(?:\s*[×xX*]\s*\d+){1,}/.test(e)}function r4(e){return Ys(e)?e.type==="doc"?(e.content||[]).map(Xo).join(`
|
|
11
11
|
|
|
12
|
-
`):jo(e):_o.serialize(e)}function jo(e){return e.type==="table"&&Ks(e)?x7(e,jo):_o.serialize($o(e)).trim()}function o4(e){return yt(e).content??[]}function ri(e){return Array.isArray(e)?Jt(e):e.type==="doc"?Jt(e.content??[]):li(e)}function Jt(e){return e.flatMap(li)}function li(e){return e.type==="blockquote"?Jt(e.content??[]):e.content?.length?[{...e,content:Jt(e.content)}]:[e]}function r4({shortcutKeys:e=Xo}){return l.jsx(R,{children:J({shortcutKeys:e})})}const si=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDownloaded:o,resolveFileUrl:r,downloadMethod:s,showShortcut:i=!1,onClick:a,children:c,...d},p)=>{const{editor:f}=k(e),{isVisible:h,canDownload:C,handleDownload:g,label:b,shortcutKeys:m,Icon:w}=fi({editor:f,hideWhenUnavailable:n,onDownloaded:o,resolveFileUrl:r,downloadMethod:s}),v=u.useCallback(async y=>{a?.(y),!y.defaultPrevented&&await g()},[g,a]);return h?l.jsx(M,{type:"button",variant:"ghost","data-active-state":"off",role:"button",tabIndex:-1,disabled:!C,"data-disabled":!C,"aria-label":b,tooltip:b,onClick:v,...d,ref:p,children:c??l.jsxs(l.Fragment,{children:[l.jsx(w,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),i&&l.jsx(r4,{shortcutKeys:m})]})}):null});si.displayName="ImageDownloadButton";const ii=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M12 2C12.5523 2 13 2.44772 13 3V14.5858L17.2929 10.2929C17.6834 9.90237 18.3166 9.90237 18.7071 10.2929C19.0976 10.6834 19.0976 11.3166 18.7071 11.7071L12.7071 17.7071C12.3166 18.0976 11.6834 18.0976 11.2929 17.7071L5.29289 11.7071C4.90237 11.3166 4.90237 10.6834 5.29289 10.2929C5.68342 9.90237 6.31658 9.90237 6.70711 10.2929L11 14.5858V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor"}),l.jsx("path",{d:"M5 20C4.44772 20 4 20.4477 4 21C4 21.5523 4.44772 22 5 22H19C19.5523 22 20 21.5523 20 21C20 20.4477 19.5523 20 19 20H5Z",fill:"currentColor"})]}));ii.displayName="ArrowDownToLineIcon";const Xo="mod+shift+d";function ai(e,t){const n=e.match(/\.([a-zA-Z0-9]+)(?:\?|#|$)/);return n&&n[1]?`.${n[1].toLowerCase()}`:t&&{"image/jpeg":".jpg","image/jpg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/svg+xml":".svg","image/bmp":".bmp"}[t.toLowerCase()]||".jpg"}function Qt(e){return!e||!e.isEditable||!_(e,["image"])?!1:ie(e,["image"])}function ci(e){if(!e||!Qt(e))return null;const{selection:t}=e.state;if(t instanceof E.NodeSelection){const n=t.node;if(n.type.name==="image")return{src:n.attrs.src,alt:n.attrs.alt,title:n.attrs.title}}return null}async function di(e,t){try{const n=await fetch(e);if(!n.ok)return!1;const o=await n.blob(),r=URL.createObjectURL(o),i=/\.[a-zA-Z0-9]+$/.test(t)?t:t+ai(e,n.headers.get("content-type")||void 0),a=document.createElement("a");return a.href=r,a.download=i,a.style.display="none",document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(r),0),!0}catch(n){return console.warn("Fetch download failed:",n),!1}}function ui(e,t){try{const o=/\.[a-zA-Z0-9]+$/.test(t)?t:t+ai(e),r=document.createElement("a");return r.href=e,r.download=o,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),!0}catch(n){return console.warn("Direct download failed:",n),!1}}function Rt(e){try{return window.open(e,"_blank"),!0}catch(t){return console.error("Failed to open image:",t),!1}}async function l4(e,t,n,o="auto"){if(!e||!Qt(e))return!1;const r=ci(e);if(!r?.src)return!1;try{let s=r.src;n&&(s=await n(r.src));const i=window.location.href,a=wn(s,i);if(a==="#")return console.error("Invalid or unsafe URL after sanitization"),!1;const c=t||r.alt||r.title||`image-${Date.now()}`;switch(o){case"open":return Rt(a);case"download":return a.startsWith(window.location.origin)||a.startsWith("data:")?ui(a,c):await di(a,c)||Rt(a);default:return a.startsWith("data:")||a.startsWith(window.location.origin)?ui(a,c):await di(a,c)?!0:Rt(a)}}catch(s){console.error("Failed to download image:",s);try{const i=window.location.href,a=wn(r.src,i);if(a!=="#")return Rt(a)}catch{}return!1}}function s4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!_(t,["image","imageUpload"])?!1:Qt(t):!0:!1}function fi(e){const{editor:t,hideWhenUnavailable:n=!1,onDownloaded:o,resolveFileUrl:r,downloadMethod:s="auto"}=e||{},{editor:i}=k(t),a=re(),[c,d]=u.useState(!0),p=Qt(i);u.useEffect(()=>{if(!i)return;const h=()=>{d(s4({editor:i,hideWhenUnavailable:n}))};return h(),i.on("selectionUpdate",h),()=>{i.off("selectionUpdate",h)}},[i,n]);const f=u.useCallback(async()=>{if(!i)return!1;const h=ci(i),C=h?.alt||h?.title,g=await l4(i,C,r,s);return g&&o?.(C),g},[i,o,r,s]);return ue.useHotkeys(Xo,h=>{h.preventDefault(),f()},{enabled:c&&p,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:c,canDownload:p,handleDownload:f,label:"Download image",shortcutKeys:Xo,Icon:ii}}function pi({shortcutKeys:e=Jo}){return l.jsx(R,{children:J({shortcutKeys:e})})}const hi=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDuplicated:o,showShortcut:r=!1,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:p,handleDuplicate:f,label:h,shortcutKeys:C,Icon:g}=gi({editor:d,hideWhenUnavailable:n,onDuplicated:o}),b=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&f()},[f,s]);return p?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":h,tooltip:h,onClick:b,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(g,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(pi,{shortcutKeys:C})]})}):null});hi.displayName="DuplicateButton";const Jo="mod+d";function Ci(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t;if(n instanceof E.NodeSelection)return!!n.node;const o=n.$anchor;for(let r=1;r<=o.depth;r++){const s=o.node(r);if(!(s.type.name==="doc"||!s.type.spec.group))return!0}return!1}catch{return!1}}function i4(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t,o=e.chain().focus();if(n instanceof E.NodeSelection){const s=n.node,i=n.to;return o.insertContentAt(i,s.toJSON()).run(),!0}const r=n.$anchor;for(let s=1;s<=r.depth;s++){const i=r.node(s);if(i.type.name==="doc"||!i.type.spec.group)continue;const a=r.start(s),c=Math.min(a+i.nodeSize,t.doc.content.size);return o.insertContentAt(c,i.toJSON()).run(),!0}return!1}catch{return!1}}function a4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:Ci(t):!1:!0:!1}function gi(e){const{editor:t,hideWhenUnavailable:n=!1,onDuplicated:o}=e||{},{editor:r}=k(t),s=D(),i=re(),[a,c]=u.useState(!0),d=Ci(r);u.useEffect(()=>{if(!r)return;const f=()=>{c(a4({editor:r,hideWhenUnavailable:n}))};return f(),r.on("selectionUpdate",f),()=>{r.off("selectionUpdate",f)}},[r,n]);const p=u.useCallback(()=>{if(!r)return!1;const f=i4(r);return f&&o?.(),f},[r,o]);return ue.useHotkeys(Jo,f=>{f.preventDefault(),p()},{enabled:a&&d,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:a,handleDuplicate:p,canDuplicate:d,label:s.duplicateNode,shortcutKeys:Jo,Icon:Vn}}function bi({shortcutKeys:e=Qo}){return l.jsx(R,{children:J({shortcutKeys:e})})}const mi=u.forwardRef(({editor:e,text:t,copyWithFormatting:n=!0,hideWhenUnavailable:o=!1,onCopied:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:p}=k(e),{isVisible:f,handleCopyToClipboard:h,label:C,shortcutKeys:g,Icon:b}=xi({editor:p,copyWithFormatting:n,hideWhenUnavailable:o,onCopied:r}),m=u.useCallback(async w=>{i?.(w),!w.defaultPrevented&&await h()},[h,i]);return f?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":C,tooltip:C,onClick:m,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(b,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),s&&l.jsx(bi,{shortcutKeys:g})]})}):null});mi.displayName="CopyToClipboardButton";function c4(e){return Xt(e,{debug:!1})}function d4(e){return{type:"doc",content:e.content.toJSON()}}function wi(e){return c4(d4(e))}const vi=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M15 1C16.1046 1 17 1.89543 17 3H18C18.7956 3 19.5585 3.3163 20.1211 3.87891C20.6837 4.44151 21 5.20435 21 6V20C21 20.7957 20.6837 21.5585 20.1211 22.1211C19.5585 22.6837 18.7957 23 18 23H6C5.20435 23 4.44151 22.6837 3.87891 22.1211C3.3163 21.5585 3 20.7957 3 20V6C3 5.20435 3.3163 4.44152 3.87891 3.87891C4.44152 3.3163 5.20435 3 6 3H7C7 1.89543 7.89543 1 9 1H15ZM6 5C5.73478 5 5.4805 5.10543 5.29297 5.29297C5.10543 5.4805 5 5.73478 5 6V20L5.00488 20.0986C5.02757 20.3276 5.12883 20.5429 5.29297 20.707C5.48051 20.8946 5.73478 21 6 21H18C18.2652 21 18.5195 20.8946 18.707 20.707C18.8946 20.5195 19 20.2652 19 20V6C19 5.73478 18.8946 5.48051 18.707 5.29297C18.5429 5.12883 18.3276 5.02757 18.0986 5.00488L18 5H17C17 6.10457 16.1046 7 15 7H9C7.89543 7 7 6.10457 7 5H6ZM9 5H15V3H9V5Z",fill:"currentColor"})}));vi.displayName="ClipboardIcon";const Qo="mod+c";async function u4(e,t){try{if(t&&navigator.clipboard&&"write"in navigator.clipboard){const n=new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([e],{type:"text/plain"})});await navigator.clipboard.write([n])}else await navigator.clipboard.writeText(e)}catch{await navigator.clipboard.writeText(e)}}function f4(e){const{selection:t}=e,{empty:n}=t;return!n}function yi(e){if(!e)return!1;const t=e.state.tr;return f4(t)}function p4(e,t=!0){const{selection:n}=e.state,{$anchor:o}=n;let r=n.content();if(n.empty||n instanceof E.TextSelection){const a=o.node(1);r=new Wr.Slice(Wr.Fragment.from(a),0,0)}const s=wi(r),i=t?e.view.serializeForClipboard(r).dom.innerHTML:void 0;return{textContent:s,htmlContent:i}}async function h4(e,t=!0){if(!e)return!1;try{const{textContent:n,htmlContent:o}=p4(e,t);return await u4(n,o),!0}catch{return!1}}function C4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isActive("code")?!0:yi(t):!0:!1}function xi(e){const{editor:t,copyWithFormatting:n=!0,hideWhenUnavailable:o=!1,onCopied:r}=e||{},{editor:s}=k(t),i=D(),a=re(),[c,d]=u.useState(!0),p=yi(s);u.useEffect(()=>{if(!s)return;const h=()=>{d(C4({editor:s,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o]);const f=u.useCallback(async()=>{if(!s)return!1;const h=await h4(s,n);return h&&r?.(),h},[s,n,r]);return ue.useHotkeys(Qo,h=>{h.preventDefault(),f()},{enabled:c&&p,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:c,handleCopyToClipboard:f,canCopyToClipboard:p,label:i.copyToClipboard,shortcutKeys:Qo,Icon:vi}}function ki({shortcutKeys:e=er}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Ro=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDeleted:o,showShortcut:r=!1,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:p,handleDeleteNode:f,label:h,shortcutKeys:C,Icon:g}=Ai({editor:d,hideWhenUnavailable:n,onDeleted:o}),b=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&f()},[f,s]);return p?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":h,tooltip:h,onClick:b,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(g,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(ki,{shortcutKeys:C})]})}):null});Ro.displayName="DeleteNodeButton";const er="backspace";function Si(e){if(!e||!e.isEditable)return!1;const{state:t}=e,{selection:n}=t;if(n instanceof E.NodeSelection)return!0;const o=n.$anchor;for(let r=o.depth;r>0;r--){const s=o.node(r),i=o.before(r);if(t.tr.delete(i,i+s.nodeSize).doc!==t.doc)return!0}return!1}function Ti(e,t,n){const o=e.chain().focus();return o.deleteRange({from:t,to:t+n}).run()?!0:o.setNodeSelection(t).deleteSelection().run()}function g4(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t;if(n instanceof E.NodeSelection){const r=n.from,s=n.node;return s?Ti(e,r,s.nodeSize):!1}const o=n.$from;for(let r=o.depth;r>0;r--){const s=n.$from.node(r),i=n.$from.before(r);if(s&&s.isBlock&&s.type.name!=="tableRow"&&s.type.name!=="tableHeader"&&s.type.name!=="tableCell")return Ti(e,i,s.nodeSize)}return!1}catch{return!1}}function b4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:Si(t):!1:!0:!1}function Ai(e){const{editor:t,hideWhenUnavailable:n=!1,onDeleted:o}=e||{},{editor:r}=k(t),s=D(),i=re(),[a,c]=u.useState(!0),d=Si(r);u.useEffect(()=>{if(!r)return;const f=()=>{c(b4({editor:r,hideWhenUnavailable:n}))};return f(),r.on("selectionUpdate",f),()=>{r.off("selectionUpdate",f)}},[r,n]);const p=u.useCallback(()=>{if(!r)return!1;const f=g4(r);return f&&o?.(),f},[r,o]);return ue.useHotkeys(er,f=>{f.preventDefault(),p()},{enabled:a&&d,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:a,handleDeleteNode:p,canDeleteNode:d,label:s.delete,shortcutKeys:er,Icon:ht}}function Ii({shortcutKeys:e=tr}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Li=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onNodeIdNotFound:o,onExtractedNodeId:r,onCopied:s,showShortcut:i=!1,onClick:a,children:c,...d},p)=>{const{editor:f}=k(e),{isVisible:h,handleCopyAnchorLink:C,label:g,shortcutKeys:b,Icon:m}=Hi({editor:f,hideWhenUnavailable:n,onNodeIdNotFound:o,onExtractedNodeId:r,onCopied:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":g,tooltip:g,onClick:w,...d,ref:p,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),i&&l.jsx(Ii,{shortcutKeys:b})]})}):null});Li.displayName="CopyAnchorLinkButton";const xt=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",fill:"currentColor"}),l.jsx("path",{d:"M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",fill:"currentColor"})]}));xt.displayName="LinkIcon";const tr="mod+ctrl+l";function Ei(e){return!!(e&&e.isEditable)}function m4(e){return Fr(e,"uniqueID")?.options?.attributeName||"data-id"}function Mi(e){if(!Ei(e))return null;const t=ct(e);if(!t)return null;const n=m4(e),o=w4(t.node,n);return{node:t.node,nodeId:o,hasNodeId:o!==null}}function w4(e,t){if(!e?.attrs?.[t])return null;try{return e.attrs[t]}catch{return null}}function Ni(e){return Mi(e)?.hasNodeId??!1}async function v4(e,t,n){const o=Mi(e);if(!o)return!1;const{nodeId:r,hasNodeId:s}=o;if(t?.(r),n?.(!s),!s||!r)return!1;try{const i=new URL(window.location.href);return i.searchParams.set("source","copy_link"),i.hash=r,await navigator.clipboard.writeText(i.toString()),!0}catch(i){return console.error("Failed to copy node ID to clipboard:",i),!1}}function y4(e){const{editor:t,hideWhenUnavailable:n}=e;if(!Ei(t))return!1;const o=!!ct(t);return n?Ni(t):o}function Hi(e){const{editor:t,hideWhenUnavailable:n=!1,onNodeIdNotFound:o,onExtractedNodeId:r,onCopied:s}=e||{},{editor:i}=k(t),a=D(),c=re(),[d,p]=u.useState(!0),f=Ni(i);u.useEffect(()=>{if(!i)return;const C=()=>{p(y4({editor:i,hideWhenUnavailable:n}))};return C(),i.on("selectionUpdate",C),()=>{i.off("selectionUpdate",C)}},[i,n]);const h=u.useCallback(async()=>{const C=await v4(i,r,o);return C&&s?.(),C},[i,r,o,s]);return ue.useHotkeys(tr,C=>{C.preventDefault(),h()},{enabled:d&&f,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,handleCopyAnchorLink:h,canCopyAnchorLink:f,label:a.copyAnchorLink,shortcutKeys:tr,Icon:xt}}function x4({shortcutKeys:e=nr}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Vi=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,preserveMarks:o=Di,onResetAllFormatting:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:p}=k(e),{isVisible:f,canReset:h,handleResetFormatting:C,label:g,shortcutKeys:b,Icon:m}=Oi({editor:p,preserveMarks:o,hideWhenUnavailable:n,onResetAllFormatting:r}),w=u.useCallback(v=>{i?.(v),!v.defaultPrevented&&C()},[C,i]);return f?l.jsx(M,{type:"button",variant:"ghost",disabled:!h,"data-disabled":!h,"data-active-state":"off",role:"button",tabIndex:-1,"aria-label":g,tooltip:g,onClick:w,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),s&&l.jsx(x4,{shortcutKeys:b})]})}):null});Vi.displayName="ResetAllFormattingButton";const Bi=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M12 2L11.9962 2.00001C9.22213 2.01045 6.55946 3.0929 4.56496 5.02104L4.55289 5.0329L4 5.58579V3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3V8C2 8.55228 2.44772 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41422L5.96097 6.45325C7.58329 4.88786 9.7473 4.00897 12.0019 4.00001C13.5835 4.00038 15.1295 4.46955 16.4446 5.34825C17.7602 6.2273 18.7855 7.47673 19.391 8.93854C19.9965 10.4003 20.155 12.0089 19.8463 13.5607C19.5376 15.1126 18.7757 16.538 17.6569 17.6569C16.538 18.7757 15.1126 19.5376 13.5607 19.8463C12.0089 20.155 10.4003 19.9965 8.93853 19.391C7.47672 18.7855 6.22729 17.7602 5.34824 16.4446C4.46919 15.129 4 13.5823 4 12C4 11.4477 3.55228 11 3 11C2.44772 11 2 11.4477 2 12C2 13.9778 2.58649 15.9112 3.6853 17.5557C4.78412 19.2002 6.3459 20.4819 8.17317 21.2388C10.0004 21.9957 12.0111 22.1937 13.9509 21.8079C15.8907 21.422 17.6725 20.4696 19.0711 19.0711C20.4696 17.6726 21.422 15.8907 21.8079 13.9509C22.1937 12.0111 21.9957 10.0004 21.2388 8.17317C20.4819 6.34591 19.2002 4.78412 17.5557 3.68531C15.9112 2.5865 13.9778 2.00001 12 2Z",fill:"currentColor"})}));Bi.displayName="RotateCcwIcon";const nr="mod+r",Di=["inlineThread"];function k4(e,t=[]){const{selection:n}=e,{empty:o,ranges:r}=n;return o||r.forEach(s=>{const i=s.$from.pos,a=s.$to.pos;e.doc.nodesBetween(i,a,(c,d)=>(c.isInline&&c.marks.forEach(p=>{t.includes(p.type.name)||e.removeMark(d,d+c.nodeSize,p.type)}),!0))}),e}function S4(e,t=[]){const{selection:n}=e,{empty:o,ranges:r}=n;if(o)return!1;for(const s of r){const i=s.$from.pos,a=s.$to.pos;let c=!1;if(e.doc.nodesBetween(i,a,d=>{if(!d.isInline)return!0;for(const p of d.marks)if(!t.includes(p.type.name))return c=!0,!1;return!0}),c)return!0}return!1}function Ui(e,t){if(!e||!e.isEditable)return!1;const n=e.state.tr;return S4(n,t)}function T4(e,t){if(!e||!e.isEditable)return!1;try{const{view:n,state:o}=e,{tr:r}=o,s=k4(r,t);return n.dispatch(s),e.commands.focus(),!0}catch{return!1}}function A4(e){const{editor:t,hideWhenUnavailable:n,preserveMarks:o}=e;return!t||!t.isEditable?!1:n&&!t.isActive("code")?Ui(t,o):!0}function Oi(e){const{editor:t,preserveMarks:n=Di,hideWhenUnavailable:o=!1,onResetAllFormatting:r}=e||{},{editor:s}=k(t),i=D(),a=re(),[c,d]=u.useState(!0),p=Ui(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{d(A4({editor:s,hideWhenUnavailable:o,preserveMarks:n}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o,n]);const f=u.useCallback(()=>{if(!s)return!1;const h=T4(s,n);return h&&r?.(),h},[s,r,n]);return ue.useHotkeys(nr,h=>{h.preventDefault(),f()},{enabled:c&&p,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:c,handleResetFormatting:f,canReset:p,label:i.resetFormatting,shortcutKeys:nr,Icon:Bi}}function I4({shortcutKeys:e=or}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Pi=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:r=!1,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:p,canToggle:f,isActive:h,handleToggle:C,label:g,shortcutKeys:b,Icon:m}=Wi({editor:d,hideWhenUnavailable:n,onToggled:o}),w=u.useCallback(v=>{s?.(v),!v.defaultPrevented&&C()},[C,s]);return p?l.jsx(M,{type:"button",variant:"ghost","data-active-state":h?"on":"off",role:"button",tabIndex:-1,disabled:!f,"data-disabled":!f,"aria-label":g,"aria-pressed":h,tooltip:g,onClick:w,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(I4,{shortcutKeys:b})]})}):null});Pi.displayName="TextButton";const or="mod+alt+0";function rr(e,t=!0){return!e||!e.schema.nodes.paragraph?!1:t?xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().setNode("paragraph")||e.can().clearNodes():!1:e.can().setNode("paragraph")}function L4(e){return e?e.isActive("paragraph"):!1}function E4(e){if(!e||!e.isEditable||!rr(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const r=at(e),s=xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&r.length===1;if((n.selection.empty||n.selection instanceof E.TextSelection)&&s){const c=me({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!X(c))return!1;o=o.setSelection(E.NodeSelection.create(n.doc,c)),t.dispatch(o),n=t.state}const i=n.selection;let a=e.chain().focus();if(i instanceof E.NodeSelection){const c=i.node.firstChild?.firstChild,d=i.node.lastChild?.lastChild,p=c?i.from+c.nodeSize:i.from+1,f=d?i.to-d.nodeSize:i.to-1,h=n.doc.resolve(p),C=n.doc.resolve(f);a=a.setTextSelection(E.TextSelection.between(h,C)).clearNodes()}return e.isActive("paragraph")||a.setNode("paragraph").run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function M4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!te("paragraph",t)?!1:t.isActive("code")?!0:rr(t):!0:!1}function Wi(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:r}=k(t),s=D(),i=re(),[a,c]=u.useState(!0),d=rr(r),p=L4(r);u.useEffect(()=>{if(!r)return;const h=()=>{c(M4({editor:r,hideWhenUnavailable:n}))};return h(),r.on("selectionUpdate",h),()=>{r.off("selectionUpdate",h)}},[r,n]);const f=u.useCallback(()=>{if(!r)return!1;const h=E4(r);return h&&o?.(),h},[r,o]);return ue.useHotkeys(or,h=>{h.preventDefault(),f()},{enabled:a&&d,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:a,isActive:p,handleToggle:f,canToggle:d,label:s.text,shortcutKeys:or,Icon:Eo}}function N4({level:e,shortcutKeys:t=$i[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const _i=u.forwardRef(({editor:e,level:t,text:n,hideWhenUnavailable:o=!1,onToggled:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:p}=k(e),{isVisible:f,canToggle:h,isActive:C,handleToggle:g,label:b,Icon:m,shortcutKeys:w}=tn({editor:p,level:t,hideWhenUnavailable:o,onToggled:r}),v=u.useCallback(y=>{i?.(y),!y.defaultPrevented&&g()},[g,i]);return f?l.jsx(M,{type:"button",variant:"ghost","data-active-state":C?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":b,"aria-pressed":C,tooltip:b,onClick:v,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(N4,{level:t,shortcutKeys:w})]})}):null});_i.displayName="HeadingButton";const Zi=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),l.jsx("path",{d:"M17 9C17.5523 9 18 9.44772 18 10V13H20V10C20 9.44772 20.4477 9 21 9C21.5523 9 22 9.44772 22 10V18C22 18.5523 21.5523 19 21 19C20.4477 19 20 18.5523 20 18V15H17C16.4477 15 16 14.5523 16 14V10C16 9.44772 16.4477 9 17 9Z",fill:"currentColor"})]}));Zi.displayName="HeadingFourIcon";const Fi=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),l.jsx("path",{d:"M16 10C16 9.44772 16.4477 9 17 9H21C21.5523 9 22 9.44772 22 10C22 10.5523 21.5523 11 21 11H18V12H18.3C20.2754 12 22 13.4739 22 15.5C22 17.5261 20.2754 19 18.3 19C17.6457 19 17.0925 18.8643 16.5528 18.5944C16.0588 18.3474 15.8586 17.7468 16.1055 17.2528C16.3525 16.7588 16.9532 16.5586 17.4472 16.8056C17.7074 16.9357 17.9542 17 18.3 17C19.3246 17 20 16.2739 20 15.5C20 14.7261 19.3246 14 18.3 14H17C16.4477 14 16 13.5523 16 13L16 12.9928V10Z",fill:"currentColor"})]}));Fi.displayName="HeadingFiveIcon";const zi=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 9.29289C21.0976 9.68342 21.0976 10.3166 20.7071 10.7071C19.8392 11.575 19.2179 12.2949 18.7889 13.0073C18.8587 13.0025 18.929 13 19 13C20.6569 13 22 14.3431 22 16C22 17.6569 20.6569 19 19 19C17.3431 19 16 17.6569 16 16C16 14.6007 16.2837 13.4368 16.8676 12.3419C17.4384 11.2717 18.2728 10.3129 19.2929 9.29289C19.6834 8.90237 20.3166 8.90237 20.7071 9.29289ZM19 17C18.4477 17 18 16.5523 18 16C18 15.4477 18.4477 15 19 15C19.5523 15 20 15.4477 20 16C20 16.5523 19.5523 17 19 17Z",fill:"currentColor"})]}));zi.displayName="HeadingSixIcon";const H4={1:xo,2:ko,3:So,4:Zi,5:Fi,6:zi},$i={1:"ctrl+alt+1",2:"ctrl+alt+2",3:"ctrl+alt+3",4:"ctrl+alt+4",5:"ctrl+alt+5",6:"ctrl+alt+6"};function V4(e,t){return{1:t.heading1,2:t.heading2,3:t.heading3,4:t.heading4,5:t.heading5,6:t.heading6}[e]}function en(e,t,n=!0){return!e||!e.isEditable||!te("heading",e)||ie(e,["image"])?!1:n?xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?t?e.can().setNode("heading",{level:t})||e.can().clearNodes():e.can().setNode("heading")||e.can().clearNodes():!1:t?e.can().setNode("heading",{level:t}):e.can().setNode("heading")}function B4(e,t){return!e||!e.isEditable?!1:Array.isArray(t)?t.some(n=>e.isActive("heading",{level:n})):t?e.isActive("heading",{level:t}):e.isActive("heading")}function D4(e,t){if(!e||!e.isEditable)return!1;const n=Array.isArray(t)?t:[t],o=n.find(r=>en(e,r));if(!o)return!1;try{const r=e.view;let s=r.state,i=s.tr;const a=at(e),c=xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&a.length===1;if((s.selection.empty||s.selection instanceof E.TextSelection)&&c){const C=me({editor:e,node:s.selection.$anchor.node(1)})?.pos;if(!X(C))return!1;i=i.setSelection(E.NodeSelection.create(s.doc,C)),r.dispatch(i),s=r.state}const d=s.selection;let p=e.chain().focus();if(d instanceof E.NodeSelection){const C=d.node.firstChild?.firstChild,g=d.node.lastChild?.lastChild,b=C?d.from+C.nodeSize:d.from+1,m=g?d.to-g.nodeSize:d.to-1,w=s.doc.resolve(b),v=s.doc.resolve(m);p=p.setTextSelection(E.TextSelection.between(w,v)).clearNodes()}return(n.some(C=>e.isActive("heading",{level:C}))?p.setNode("paragraph"):p.setNode("heading",{level:o})).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function U4(e){const{editor:t,level:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!te("heading",t)?!1:t.isActive("code")?!0:Array.isArray(n)?n.some(r=>en(t,r)):en(t,n):!0:!1}function tn(e){const{editor:t,level:n,hideWhenUnavailable:o=!1,onToggled:r}=e,{editor:s}=k(t),i=D(),[a,c]=u.useState(!0),d=en(s,n),p=B4(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{c(U4({editor:s,level:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const f=u.useCallback(()=>{if(!s)return!1;const h=D4(s,n);return h&&r?.(),h},[s,n,r]);return{isVisible:a,isActive:p,handleToggle:f,canToggle:d,label:V4(n,i),shortcutKeys:$i[n],Icon:H4[n]}}function O4({type:e,shortcutKeys:t=qi[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const nn=u.forwardRef(({editor:e,type:t,text:n,hideWhenUnavailable:o=!1,onToggled:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:p}=k(e),{isVisible:f,canToggle:h,isActive:C,handleToggle:g,label:b,shortcutKeys:m,Icon:w}=on({editor:p,type:t,hideWhenUnavailable:o,onToggled:r}),v=u.useCallback(y=>{i?.(y),!y.defaultPrevented&&g()},[g,i]);return f?l.jsx(M,{type:"button",variant:"ghost","data-active-state":C?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":b,"aria-pressed":C,tooltip:b,onClick:v,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(w,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(O4,{type:t,shortcutKeys:m})]})}):null});nn.displayName="ListButton";const P4={bulletList:To,orderedList:Ao,taskList:Lo};function W4(e){return{bulletList:e.bulletList,orderedList:e.orderedList,taskList:e.taskList}}const qi={bulletList:"mod+shift+8",orderedList:"mod+shift+7",taskList:"mod+shift+9"};function lr(e,t,n=!0){if(!e||!e.isEditable||!te(t,e)||ie(e,["image"]))return!1;if(!n)switch(t){case"bulletList":return e.can().toggleBulletList();case"orderedList":return e.can().toggleOrderedList();case"taskList":return e.can().toggleList("taskList","taskItem");default:return!1}if(!xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"]))return!1;switch(t){case"bulletList":return e.can().toggleBulletList()||e.can().clearNodes();case"orderedList":return e.can().toggleOrderedList()||e.can().clearNodes();case"taskList":return e.can().toggleList("taskList","taskItem")||e.can().clearNodes();default:return!1}}function _4(e,t){if(!e||!e.isEditable)return!1;switch(t){case"bulletList":return e.isActive("bulletList");case"orderedList":return e.isActive("orderedList");case"taskList":return e.isActive("taskList");default:return!1}}function Z4(e,t){if(!e||!e.isEditable||!lr(e,t))return!1;try{const n=e.view;let o=n.state,r=o.tr;const s=at(e),i=xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&s.length===1;if((o.selection.empty||o.selection instanceof E.TextSelection)&&i){const d=me({editor:e,node:o.selection.$anchor.node(1)})?.pos;if(!X(d))return!1;r=r.setSelection(E.NodeSelection.create(o.doc,d)),n.dispatch(r),o=n.state}const a=o.selection;let c=e.chain().focus();if(a instanceof E.NodeSelection){const d=a.node.firstChild?.firstChild,p=a.node.lastChild?.lastChild,f=d?a.from+d.nodeSize:a.from+1,h=p?a.to-p.nodeSize:a.to-1,C=o.doc.resolve(f),g=o.doc.resolve(h);c=c.setTextSelection(E.TextSelection.between(C,g)).clearNodes()}if(e.isActive(t))c.liftListItem("listItem").lift("bulletList").lift("orderedList").lift("taskList").run();else{const p={bulletList:()=>c.toggleBulletList(),orderedList:()=>c.toggleOrderedList(),taskList:()=>c.toggleList("taskList","taskItem")}[t];if(!p)return!1;p().run()}return e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function F4(e){const{editor:t,type:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!te(n,t)?!1:t.isActive("code")?!0:lr(t,n):!0:!1}function on(e){const{editor:t,type:n,hideWhenUnavailable:o=!1,onToggled:r}=e,{editor:s}=k(t),i=D(),[a,c]=u.useState(!0),d=lr(s,n),p=_4(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{c(F4({editor:s,type:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const f=u.useCallback(()=>{if(!s)return!1;const h=Z4(s,n);return h&&r?.(),h},[s,n,r]);return{isVisible:a,isActive:p,handleToggle:f,canToggle:d,label:W4(i)[n],shortcutKeys:qi[n],Icon:P4[n]}}function z4({shortcutKeys:e=Ki}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Gi=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:r=!1,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:p,canToggle:f,isActive:h,handleToggle:C,label:g,shortcutKeys:b,Icon:m}=Yi({editor:d,hideWhenUnavailable:n,onToggled:o}),w=u.useCallback(v=>{s?.(v),!v.defaultPrevented&&C()},[C,s]);return p?l.jsx(M,{type:"button",variant:"ghost","data-active-state":h?"on":"off",role:"button",tabIndex:-1,disabled:!f,"data-disabled":!f,"aria-label":g,"aria-pressed":h,tooltip:g,onClick:w,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(z4,{shortcutKeys:b})]})}):null});Gi.displayName="BlockquoteButton";const Ki="mod+shift+b";function sr(e,t=!0){return!e||!e.isEditable||!te("blockquote",e)||ie(e,["image"])?!1:t?xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().toggleWrap("blockquote")||e.can().clearNodes():!1:e.can().toggleWrap("blockquote")}function $4(e){if(!e||!e.isEditable||!sr(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const r=at(e),s=xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&r.length===1;if((n.selection.empty||n.selection instanceof E.TextSelection)&&s){const d=me({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!X(d))return!1;o=o.setSelection(E.NodeSelection.create(n.doc,d)),t.dispatch(o),n=t.state}const i=n.selection;let a=e.chain().focus();if(i instanceof E.NodeSelection){const d=i.node.firstChild?.firstChild,p=i.node.lastChild?.lastChild,f=d?i.from+d.nodeSize:i.from+1,h=p?i.to-p.nodeSize:i.to-1,C=n.doc.resolve(f),g=n.doc.resolve(h);a=a.setTextSelection(E.TextSelection.between(C,g)).clearNodes()}return(e.isActive("blockquote")?a.lift("blockquote"):a.wrapIn("blockquote")).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function q4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!te("blockquote",t)?!1:t.isActive("code")?!0:sr(t):!0:!1}function Yi(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:r}=k(t),s=D(),[i,a]=u.useState(!0),c=sr(r),d=r?.isActive("blockquote")||!1;u.useEffect(()=>{if(!r)return;const f=()=>{a(q4({editor:r,hideWhenUnavailable:n}))};return f(),r.on("selectionUpdate",f),()=>{r.off("selectionUpdate",f)}},[r,n]);const p=u.useCallback(()=>{if(!r)return!1;const f=$4(r);return f&&o?.(),f},[r,o]);return{isVisible:i,isActive:d,handleToggle:p,canToggle:c,label:s.blockquote,shortcutKeys:Ki,Icon:Io}}function G4({shortcutKeys:e=Xi}){return l.jsx(R,{children:J({shortcutKeys:e})})}const ji=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:r=!1,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:p,canToggle:f,isActive:h,handleToggle:C,label:g,shortcutKeys:b,Icon:m}=Ji({editor:d,hideWhenUnavailable:n,onToggled:o}),w=u.useCallback(v=>{s?.(v),!v.defaultPrevented&&C()},[C,s]);return p?l.jsx(M,{type:"button",variant:"ghost","data-active-state":h?"on":"off",role:"button",disabled:!f,"data-disabled":!f,tabIndex:-1,"aria-label":g,"aria-pressed":h,tooltip:g,onClick:w,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(G4,{shortcutKeys:b})]})}):null});ji.displayName="CodeBlockButton";const Xi="mod+alt+c";function ir(e,t=!0){return!e||!e.isEditable||!te("codeBlock",e)||ie(e,["image"])?!1:t?xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().toggleNode("codeBlock","paragraph")||e.can().clearNodes():!1:e.can().toggleNode("codeBlock","paragraph")}function K4(e){if(!e||!e.isEditable||!ir(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const r=at(e),s=xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&r.length===1;if((n.selection.empty||n.selection instanceof E.TextSelection)&&s){const d=me({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!X(d))return!1;o=o.setSelection(E.NodeSelection.create(n.doc,d)),t.dispatch(o),n=t.state}const i=n.selection;let a=e.chain().focus();if(i instanceof E.NodeSelection){const d=i.node.firstChild?.firstChild,p=i.node.lastChild?.lastChild,f=d?i.from+d.nodeSize:i.from+1,h=p?i.to-p.nodeSize:i.to-1,C=n.doc.resolve(f),g=n.doc.resolve(h);a=a.setTextSelection(E.TextSelection.between(C,g)).clearNodes()}return(e.isActive("codeBlock")?a.setNode("paragraph"):a.toggleNode("codeBlock","paragraph")).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function Y4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!te("codeBlock",t)?!1:t.isActive("code")?!0:ir(t):!0:!1}function Ji(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:r}=k(t),s=D(),[i,a]=u.useState(!0),c=ir(r),d=r?.isActive("codeBlock")||!1;u.useEffect(()=>{if(!r)return;const f=()=>{a(Y4({editor:r,hideWhenUnavailable:n}))};return f(),r.on("selectionUpdate",f),()=>{r.off("selectionUpdate",f)}},[r,n]);const p=u.useCallback(()=>{if(!r)return!1;const f=K4(r);return f&&o?.(),f},[r,o]);return{isVisible:i,isActive:d,handleToggle:p,canToggle:c,label:s.codeBlock,shortcutKeys:Xi,Icon:yo}}function j4({shortcutKeys:e=cr}){return l.jsx(R,{children:J({shortcutKeys:e})})}const ar=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:r="/",hideWhenUnavailable:s=!1,onTriggered:i,showShortcut:a=!1,onClick:c,children:d,...p},f)=>{const{editor:h}=k(e),{isVisible:C,canInsert:g,handleSlashCommand:b,label:m,shortcutKeys:w,Icon:v}=Q4({editor:h,node:t,nodePos:n,trigger:r,hideWhenUnavailable:s,onTriggered:i}),y=u.useCallback(x=>{c?.(x),!x.defaultPrevented&&b()},[b,c]);return C?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!g,"data-disabled":!g,"aria-label":m,tooltip:m,onClick:y,...p,ref:f,children:d??l.jsxs(l.Fragment,{children:[l.jsx(v,{className:"tiptap-button-icon"}),o&&l.jsx("span",{className:"tiptap-button-text",children:o}),a&&l.jsx(j4,{shortcutKeys:w})]})}):null});ar.displayName="SlashCommandTriggerButton";const Qi=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z",fill:"currentColor"})}));Qi.displayName="PlusIcon";const cr="mod+/";function dr(e,t,n){if(!e||!e.isEditable||ie(e,["image"]))return!1;if(t||X(n)){if(X(n)&&n>=0)return!0;if(t)return me({editor:e,node:t})!==null}return!0}function X4(e,t="/",n,o){if(!e||!e.isEditable||!dr(e,n,o))return!1;try{if(n!=null||X(o)){const d=me({editor:e,node:n||void 0,nodePos:o||void 0});if(!d)return!1;const p=d.node.type.name==="paragraph"&&d.node.content.size===0,f=p?d.pos:d.pos+d.node.nodeSize;e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,f,f));const h=t.length+1,C=p?d.pos+h:d.pos+d.node.nodeSize+h;return e.commands.focus(C),!0}const{$from:r}=e.state.selection,i=r.node().textContent.length===0,a=r.parentOffset===0,c=r.depth===0;if(!i||!a){const d=c?e.state.doc.content.size:r.after();return e.chain().insertContentAt(d,{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}return e.chain().insertContent({type:"text",text:t}).focus().run()}catch{return!1}}function J4(e){const{editor:t,hideWhenUnavailable:n,node:o,nodePos:r}=e;return t?n?t.isEditable?t.isActive("code")?!0:dr(t,o,r):!1:!0:!1}function Q4(e){const{editor:t,node:n,nodePos:o,trigger:r="/",hideWhenUnavailable:s=!1,onTriggered:i}=e||{},{editor:a}=k(t),c=re(),[d,p]=u.useState(!0),f=dr(a,n,o);u.useEffect(()=>{if(!a)return;const C=()=>{p(J4({editor:a,hideWhenUnavailable:s,node:n,nodePos:o}))};return C(),a.on("selectionUpdate",C),()=>{a.off("selectionUpdate",C)}},[a,s,n,o]);const h=u.useCallback(()=>{if(!a)return!1;const C=X4(a,r,n,o);return C&&i?.(r),C},[a,r,n,o,i]);return ue.useHotkeys(cr,C=>{C.preventDefault(),h()},{enabled:d&&f,enableOnContentEditable:!c,enableOnFormTags:!0},[d,f,h]),{isVisible:d,handleSlashCommand:h,canInsert:f,label:"Insert block",shortcutKeys:cr,trigger:r,Icon:Qi}}function ur(e){return!e||!e.isEditable||!_(e,["tocNode"])?!1:ie(e,["tocNode"])}function R4(e){if(!e)return!1;try{const{selection:t}=e.state;return t instanceof E.NodeSelection&&t.node.type.name==="tocNode"?t.node.attrs.showTitle===!0:!1}catch{return!1}}function ef(e){if(!e?.isEditable||!ur(e))return!1;try{const{selection:t}=e.state;if(!(t instanceof E.NodeSelection&&t.node.type.name==="tocNode"))return!1;const r=t.node.attrs.showTitle===!0;return e.chain().focus().updateAttributes("tocNode",{showTitle:!r}).run()}catch{return!1}}function tf(e){const{editor:t,hideWhenUnavailable:n}=e;return!t||!t.isEditable||!_(t,["tocNode"])?!1:n?ur(t):!0}function Ri(e){const{editor:t,hideWhenUnavailable:n=!1,onToggle:o}=e||{},{editor:r}=k(t),[s,i]=u.useState(!0),[a,c]=u.useState(!1),d=ur(r);u.useEffect(()=>{if(!r)return;const f=()=>{i(tf({editor:r,hideWhenUnavailable:n})),c(R4(r))};return f(),r.on("selectionUpdate",f),()=>{r.off("selectionUpdate",f)}},[r,n]);const p=u.useCallback(()=>{if(!r)return!1;const f=ef(r);return f&&o?.(),f},[r,o]);return{isVisible:s,isActive:a,canToggle:d,handleToggle:p,label:"Show title",Icon:Ho}}const nf=At.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggle:o,onClick:r,children:s,...i},a)=>{const{editor:c}=k(e),{isVisible:d,isActive:p,canToggle:f,handleToggle:h,label:C,Icon:g}=Ri({editor:c,hideWhenUnavailable:n,onToggle:o}),b=At.useCallback(m=>{r?.(m),!m.defaultPrevented&&h()},[h,r]);return d?l.jsx(M,{type:"button",variant:"ghost","data-active-state":p?"on":"off",role:"button",tabIndex:-1,disabled:!f,"data-disabled":!f,"aria-label":C,tooltip:C,onClick:b,...i,ref:a,children:s??l.jsxs(l.Fragment,{children:[l.jsx(g,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t})]})}):null});nf.displayName="TocShowTitleButton";const ea=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z",fill:"currentColor"}),l.jsx("path",{d:"M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z",fill:"currentColor"}),l.jsx("path",{d:"M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z",fill:"currentColor"}),l.jsx("path",{d:"M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z",fill:"currentColor"}),l.jsx("path",{d:"M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z",fill:"currentColor"}),l.jsx("path",{d:"M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z",fill:"currentColor"})]}));ea.displayName="GripVerticalIcon";const fr=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.70711 5.29289C5.31658 4.90237 4.68342 4.90237 4.29289 5.29289L1.29289 8.29289C0.902369 8.68342 0.902369 9.31658 1.29289 9.70711C1.68342 10.0976 2.31658 10.0976 2.70711 9.70711L4 8.41421V16C4 16.7956 4.31607 17.5587 4.87868 18.1213C5.44129 18.6839 6.20435 19 7 19H13C13.5523 19 14 18.5523 14 18C14 17.4477 13.5523 17 13 17H7C6.73478 17 6.48043 16.8946 6.29289 16.7071C6.10536 16.5196 6 16.2652 6 16V8.41421L7.29289 9.70711C7.68342 10.0976 8.31658 10.0976 8.70711 9.70711C9.09763 9.31658 9.09763 8.68342 8.70711 8.29289L5.70711 5.29289ZM15.2929 14.2929C15.6834 13.9024 16.3166 13.9024 16.7071 14.2929L18 15.5858V8C18 7.73478 17.8946 7.48043 17.7071 7.29289C17.5196 7.10536 17.2652 7 17 7H11C10.4477 7 10 6.55228 10 6C10 5.44772 10.4477 5 11 5H17C17.7957 5 18.5587 5.31607 19.1213 5.87868C19.6839 6.44129 20 7.20435 20 8V15.5858L21.2929 14.2929C21.6834 13.9024 22.3166 13.9024 22.7071 14.2929C23.0976 14.6834 23.0976 15.3166 22.7071 15.7071L19.7071 18.7071C19.3166 19.0976 18.6834 19.0976 18.2929 18.7071L15.2929 15.7071C14.9024 15.3166 14.9024 14.6834 15.2929 14.2929Z",fill:"currentColor"})}));fr.displayName="Repeat2Icon";const of=()=>{const e=Wi(),t=tn({level:1}),n=tn({level:2}),o=tn({level:3}),r=on({type:"bulletList"}),s=on({type:"orderedList"}),i=on({type:"taskList"}),a=Yi(),c=Ji(),d=h=>({icon:h.Icon,label:h.label,onClick:h.handleToggle,disabled:!h.canToggle,isActive:h.isActive}),p=[d(e),...[t,n,o].map(d),d(r),d(s),d(i),d(a),d(c)];return p.every(h=>h.disabled)?null:p},Se=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:r=!1,shortcutBadge:s})=>l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":r?"on":"off"}),onClick:n,disabled:o,children:[l.jsx(e,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:t}),s]}),rf=({icon:e,label:t,children:n})=>l.jsx(je,{placement:"right",trigger:l.jsx(Ee,{render:l.jsx(Je,{render:l.jsxs(M,{variant:"ghost",children:[l.jsx(e,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:t}),l.jsx(Ct,{}),l.jsx(tt,{className:"tiptap-button-icon"})]})})}),children:l.jsx(Xe,{portal:!0,children:l.jsx(Ye,{children:n})})}),lf=()=>{const e=D(),t=of(),{canReset:n,handleResetFormatting:o,label:r,Icon:s}=Oi({hideWhenUnavailable:!0,preserveMarks:["inlineThread"]});return!t&&!n?null:l.jsxs(l.Fragment,{children:[t&&l.jsx(rf,{icon:fr,label:e.turnInto,children:l.jsxs(de,{children:[l.jsx(ft,{children:e.turnInto}),t.map(i=>l.jsx(Se,{...i},i.label))]})}),n&&l.jsx(Se,{icon:s,label:r,disabled:!n,onClick:o})]})},sf=()=>{const e=D(),{canFitToWidth:t,handleFitToWidth:n,label:o,Icon:r}=ho({hideWhenUnavailable:!0}),s=Qe({resetAttrs:!0});return l.jsxs(l.Fragment,{children:[t&&l.jsx(Se,{icon:r,label:o,disabled:!t,onClick:n}),s.canClearRowColumnContent&&l.jsx(Se,{icon:s.Icon,label:e.clearAllContents,disabled:!s.canClearRowColumnContent,onClick:s.handleClear})]})},af=()=>{const{canToggle:e,handleToggle:t,label:n,Icon:o}=Ri({hideWhenUnavailable:!0});return e?l.jsx(Se,{icon:o,label:n,disabled:!e,onClick:t}):null},cf=()=>{const{canDownload:e,handleDownload:t,label:n,Icon:o}=fi({hideWhenUnavailable:!0});return e?l.jsx(Se,{icon:o,label:n,disabled:!e,onClick:t}):null},df=()=>{const{handleDuplicate:e,canDuplicate:t,label:n,Icon:o}=gi(),{handleCopyToClipboard:r,canCopyToClipboard:s,label:i,Icon:a}=xi(),{handleCopyAnchorLink:c,canCopyAnchorLink:d,label:p,Icon:f}=Hi();return l.jsxs(l.Fragment,{children:[l.jsx(ee,{orientation:"horizontal"}),l.jsxs(de,{children:[l.jsx(Se,{icon:o,label:n,onClick:e,disabled:!t,shortcutBadge:l.jsx(pi,{})}),l.jsx(Se,{icon:a,label:i,onClick:r,disabled:!s,shortcutBadge:l.jsx(bi,{})}),l.jsx(Se,{icon:f,label:p,onClick:c,disabled:!d,shortcutBadge:l.jsx(Ii,{})})]}),l.jsx(ee,{orientation:"horizontal"})]})},uf=()=>{const{handleDeleteNode:e,canDeleteNode:t,label:n,Icon:o}=Ai();return l.jsx(de,{children:l.jsx(Se,{icon:o,label:n,onClick:e,disabled:!t,shortcutBadge:l.jsx(ki,{})})})},ff=({editor:e,withSlashCommandTrigger:t=!0,mobileBreakpoint:n=768,...o})=>{const{editor:r}=k(e),s=D(),{isDragging:i}=gn(r),a=re("max",n),[c,d]=u.useState(!1),[p,f]=u.useState(null),[h,C]=u.useState(-1),g=u.useCallback(S=>{S.node&&f(S.node),C(S.pos)},[]);u.useEffect(()=>{r&&(r.commands.setLockDragHandle(c),r.commands.setMeta("lockDragHandle",c))},[r,c]);const b=16,m=u.useMemo(()=>({middleware:[z.offset(S=>{const{rects:L}=S,I=L.reference.height,V=L.floating.height,K=I/2-V/2;return{mainAxis:b,crossAxis:I>40?0:K}})]}),[]),w=u.useCallback(()=>{r&&r.commands.setMeta("hideDragHandle",!0)},[r]),v=u.useCallback(S=>{S.stopPropagation(),r&&r.commands.setIsDragging(!0)},[r]),y=u.useCallback(S=>{S.stopPropagation(),r&&(r.commands.setIsDragging(!1),setTimeout(()=>{r.view.dom.blur(),r.view.focus()},0))},[r]);if(!r)return null;const x=ks(r,s);return l.jsx("div",{style:{"--drag-handle-main-axis-offset":`${b}px`},children:l.jsx(A1.DragHandle,{editor:r,onNodeChange:g,computePositionConfig:m,onElementDragStart:v,onElementDragEnd:y,...o,children:l.jsxs("div",{style:{display:"flex",flexDirection:"row",...a||Lu(r)?{opacity:0,pointerEvents:"none"}:{},...i?{opacity:0}:{}},children:[t&&l.jsx(ar,{node:p,nodePos:h,"data-weight":"small"}),l.jsx(je,{open:c,onOpenChange:d,placement:"left",trigger:l.jsx(Je,{render:l.jsx(M,{variant:"ghost",tabIndex:-1,tooltip:l.jsxs(l.Fragment,{children:[l.jsx("div",{children:s.clickForOptions}),l.jsx("div",{children:s.holdForDrag})]}),"data-weight":"small",style:{cursor:"grab",...c?{pointerEvents:"none"}:{}},onMouseDown:()=>xn(r,h),children:l.jsx(ea,{className:"tiptap-button-icon"})})}),children:l.jsxs(Xe,{onClose:w,autoFocusOnHide:!1,preventBodyScroll:!0,portal:!0,children:[l.jsx(Hn,{style:mn}),l.jsxs(Ye,{style:{minWidth:"15rem"},children:[l.jsx(ft,{children:x}),l.jsxs(de,{children:[l.jsx(af,{}),l.jsx(Qn,{}),l.jsx(io,{}),l.jsx(sf,{}),l.jsx(lf,{}),l.jsx(cf,{})]}),l.jsx(df,{}),l.jsx(uf,{})]})]})})]})})})},ta=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M12 1C12.5523 1 13 1.44772 13 2V4C13 4.55228 12.5523 5 12 5C11.4477 5 11 4.55228 11 4V2C11 1.44772 11.4477 1 12 1Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 9.23858 9.23858 7 12 7C14.7614 7 17 9.23858 17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12ZM12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9Z",fill:"currentColor"}),l.jsx("path",{d:"M13 20C13 19.4477 12.5523 19 12 19C11.4477 19 11 19.4477 11 20V22C11 22.5523 11.4477 23 12 23C12.5523 23 13 22.5523 13 22V20Z",fill:"currentColor"}),l.jsx("path",{d:"M4.22282 4.22289C4.61335 3.83236 5.24651 3.83236 5.63704 4.22289L7.04704 5.63289C7.43756 6.02341 7.43756 6.65658 7.04704 7.0471C6.65651 7.43762 6.02335 7.43762 5.63283 7.0471L4.22282 5.6371C3.8323 5.24658 3.8323 4.61341 4.22282 4.22289Z",fill:"currentColor"}),l.jsx("path",{d:"M18.367 16.9529C17.9765 16.5623 17.3433 16.5623 16.9528 16.9529C16.5623 17.3434 16.5623 17.9766 16.9528 18.3671L18.3628 19.7771C18.7533 20.1676 19.3865 20.1676 19.777 19.7771C20.1675 19.3866 20.1675 18.7534 19.777 18.3629L18.367 16.9529Z",fill:"currentColor"}),l.jsx("path",{d:"M1 12C1 11.4477 1.44772 11 2 11H4C4.55228 11 5 11.4477 5 12C5 12.5523 4.55228 13 4 13H2C1.44772 13 1 12.5523 1 12Z",fill:"currentColor"}),l.jsx("path",{d:"M20 11C19.4477 11 19 11.4477 19 12C19 12.5523 19.4477 13 20 13H22C22.5523 13 23 12.5523 23 12C23 11.4477 22.5523 11 22 11H20Z",fill:"currentColor"}),l.jsx("path",{d:"M7.04704 16.9529C7.43756 17.3434 7.43756 17.9766 7.04704 18.3671L5.63704 19.7771C5.24651 20.1676 4.61335 20.1676 4.22282 19.7771C3.8323 19.3866 3.8323 18.7534 4.22283 18.3629L5.63283 16.9529C6.02335 16.5623 6.65651 16.5623 7.04704 16.9529Z",fill:"currentColor"}),l.jsx("path",{d:"M19.777 5.6371C20.1675 5.24657 20.1675 4.61341 19.777 4.22289C19.3865 3.83236 18.7533 3.83236 18.3628 4.22289L16.9528 5.63289C16.5623 6.02341 16.5623 6.65658 16.9528 7.0471C17.3433 7.43762 17.9765 7.43762 18.367 7.0471L19.777 5.6371Z",fill:"currentColor"})]}));ta.displayName="SunIcon";const na=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C10.0222 2 8.08879 2.58649 6.4443 3.6853C4.79981 4.78412 3.51809 6.3459 2.76121 8.17317C2.00433 10.0004 1.8063 12.0111 2.19215 13.9509C2.578 15.8907 3.53041 17.6725 4.92894 19.0711C6.32746 20.4696 8.10929 21.422 10.0491 21.8079C11.9889 22.1937 13.9996 21.9957 15.8268 21.2388C17.6541 20.4819 19.2159 19.2002 20.3147 17.5557C21.4135 15.9112 22 13.9778 22 12C22 11.5955 21.7564 11.2309 21.3827 11.0761C21.009 10.9213 20.5789 11.0069 20.2929 11.2929C19.287 12.2988 17.9226 12.864 16.5 12.864C15.0774 12.864 13.713 12.2988 12.7071 11.2929C11.7012 10.287 11.136 8.92261 11.136 7.5C11.136 6.07739 11.7012 4.71304 12.7071 3.70711C12.9931 3.42111 13.0787 2.99099 12.9239 2.61732C12.7691 2.24364 12.4045 2 12 2ZM7.55544 5.34824C8.27036 4.87055 9.05353 4.51389 9.87357 4.28778C9.39271 5.27979 9.13604 6.37666 9.13604 7.5C9.13604 9.45304 9.91189 11.3261 11.2929 12.7071C12.6739 14.0881 14.547 14.864 16.5 14.864C17.6233 14.864 18.7202 14.6073 19.7122 14.1264C19.4861 14.9465 19.1295 15.7296 18.6518 16.4446C17.7727 17.7602 16.5233 18.7855 15.0615 19.391C13.5997 19.9965 11.9911 20.155 10.4393 19.8463C8.88743 19.5376 7.46197 18.7757 6.34315 17.6569C5.22433 16.538 4.4624 15.1126 4.15372 13.5607C3.84504 12.0089 4.00347 10.4003 4.60897 8.93853C5.21447 7.47672 6.23985 6.22729 7.55544 5.34824Z",fill:"currentColor"}),l.jsx("path",{d:"M19 2C19.5523 2 20 2.44772 20 3V4H21C21.5523 4 22 4.44772 22 5C22 5.55228 21.5523 6 21 6H20V7C20 7.55228 19.5523 8 19 8C18.4477 8 18 7.55228 18 7V6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H18V3C18 2.44772 18.4477 2 19 2Z",fill:"currentColor"})]}));na.displayName="MoonStarIcon";function pf(){const{editor:e}=u.useContext(G.EditorContext),[t,n]=u.useState(!1);u.useEffect(()=>{const r=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>n(r.matches);return r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[]),u.useEffect(()=>{const r=!!document.querySelector('meta[name="color-scheme"][content="dark"]')||window.matchMedia("(prefers-color-scheme: dark)").matches;n(r)},[]),u.useEffect(()=>{e?.view.dom.closest(".omnibox-editor-root")?.classList.toggle("dark",t)},[e,t]);const o=()=>n(r=>!r);return l.jsx(M,{onClick:o,"aria-label":`Switch to ${t?"light":"dark"} mode`,variant:"ghost",children:t?l.jsx(na,{className:"tiptap-button-icon"}):l.jsx(ta,{className:"tiptap-button-icon"})})}const oa=u.createContext({user:{color:"",id:"",name:"",avatar:""},mentionUsers:[],onlineUsers:[],setOnlineUsers:()=>{}});function hf(e,t){return e.length!==t.length?!1:e.every((n,o)=>{const r=t[o];return r&&n.id===r.id&&n.name===r.name&&n.color===r.color&&n.avatar===r.avatar&&n.position===r.position})}function Cf({children:e,mentionUsers:t,user:n}){const[o]=u.useState(()=>zu()),[r,s]=u.useState([]),i=u.useMemo(()=>Ns(n)??o,[o,n]),a=u.useMemo(()=>$u(t),[t]),c=u.useCallback(p=>{const f=wo(p);s(h=>hf(h,f)?h:f)},[]),d=u.useMemo(()=>({user:i,onlineUsers:r,setOnlineUsers:c,mentionUsers:wo([...r,...a])}),[a,r,c,i]);return l.jsx(oa.Provider,{value:d,children:e})}const rn=()=>u.useContext(oa);function gf({action:e,shortcutKeys:t=sa[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const pr=u.forwardRef(({editor:e,action:t,text:n,hideWhenUnavailable:o=!1,onExecuted:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:p}=k(e),{isVisible:f,handleAction:h,label:C,canExecute:g,Icon:b,shortcutKeys:m}=yf({editor:p,action:t,hideWhenUnavailable:o,onExecuted:r}),w=u.useCallback(v=>{i?.(v),!v.defaultPrevented&&h()},[h,i]);return f?l.jsx(M,{type:"button",disabled:!g,variant:"ghost","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":C,tooltip:C,onClick:w,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(b,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(gf,{action:t,shortcutKeys:m})]})}):null});pr.displayName="UndoRedoButton";const ra=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.7071 2.29289C15.3166 1.90237 14.6834 1.90237 14.2929 2.29289C13.9024 2.68342 13.9024 3.31658 14.2929 3.70711L17.5858 7H9.5C7.77609 7 6.12279 7.68482 4.90381 8.90381C3.68482 10.1228 3 11.7761 3 13.5C3 14.3536 3.16813 15.1988 3.49478 15.9874C3.82144 16.7761 4.30023 17.4926 4.90381 18.0962C6.12279 19.3152 7.77609 20 9.5 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9.5C8.30653 18 7.16193 17.5259 6.31802 16.682C5.90016 16.2641 5.56869 15.768 5.34254 15.2221C5.1164 14.6761 5 14.0909 5 13.5C5 12.3065 5.47411 11.1619 6.31802 10.318C7.16193 9.47411 8.30653 9 9.5 9H17.5858L14.2929 12.2929C13.9024 12.6834 13.9024 13.3166 14.2929 13.7071C14.6834 14.0976 15.3166 14.0976 15.7071 13.7071L20.7071 8.70711C21.0976 8.31658 21.0976 7.68342 20.7071 7.29289L15.7071 2.29289Z",fill:"currentColor"})}));ra.displayName="Redo2Icon";const la=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 3.70711C10.0976 3.31658 10.0976 2.68342 9.70711 2.29289C9.31658 1.90237 8.68342 1.90237 8.29289 2.29289L3.29289 7.29289C2.90237 7.68342 2.90237 8.31658 3.29289 8.70711L8.29289 13.7071C8.68342 14.0976 9.31658 14.0976 9.70711 13.7071C10.0976 13.3166 10.0976 12.6834 9.70711 12.2929L6.41421 9H14.5C15.0909 9 15.6761 9.1164 16.2221 9.34254C16.768 9.56869 17.2641 9.90016 17.682 10.318C18.0998 10.7359 18.4313 11.232 18.6575 11.7779C18.8836 12.3239 19 12.9091 19 13.5C19 14.0909 18.8836 14.6761 18.6575 15.2221C18.4313 15.768 18.0998 16.2641 17.682 16.682C17.2641 17.0998 16.768 17.4313 16.2221 17.6575C15.6761 17.8836 15.0909 18 14.5 18H11C10.4477 18 10 18.4477 10 19C10 19.5523 10.4477 20 11 20H14.5C15.3536 20 16.1988 19.8319 16.9874 19.5052C17.7761 19.1786 18.4926 18.6998 19.0962 18.0962C19.6998 17.4926 20.1786 16.7761 20.5052 15.9874C20.8319 15.1988 21 14.3536 21 13.5C21 12.6464 20.8319 11.8012 20.5052 11.0126C20.1786 10.2239 19.6998 9.50739 19.0962 8.90381C18.4926 8.30022 17.7761 7.82144 16.9874 7.49478C16.1988 7.16813 15.3536 7 14.5 7H6.41421L9.70711 3.70711Z",fill:"currentColor"})}));la.displayName="Undo2Icon";const sa={undo:"mod+z",redo:"mod+shift+z"},bf={undo:"Undo",redo:"Redo"},mf={undo:la,redo:ra};function hr(e,t){return!e||!e.isEditable||ie(e,["image"])?!1:t==="undo"?e.can().undo():e.can().redo()}function wf(e,t){if(!e||!e.isEditable||!hr(e,t))return!1;const n=e.chain().focus();return t==="undo"?n.undo().run():n.redo().run()}function vf(e){const{editor:t,hideWhenUnavailable:n,action:o}=e;return t?n?t.isEditable?t.isActive("code")?!0:hr(t,o):!1:!0:!1}function yf(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onExecuted:r}=e,{editor:s}=k(t),[i,a]=u.useState(!0),c=hr(s,n);u.useEffect(()=>{if(!s)return;const p=()=>{a(vf({editor:s,hideWhenUnavailable:o,action:n}))};return p(),s.on("transaction",p),()=>{s.off("transaction",p)}},[s,o,n]);const d=u.useCallback(()=>{if(!s)return!1;const p=wf(s,n);return p&&r?.(),p},[s,n,r]);return{isVisible:i,handleAction:d,canExecute:c,label:bf[n],shortcutKeys:sa[n],Icon:mf[n]}}function xf(e){return e[0]?.toUpperCase()??""}function kf(){const{mentionUsers:e,user:t}=rn(),n=e.length?e:[t],o=n.length;return t.name?l.jsxs("div",{className:"omnibox-editor-users",title:n.map(r=>r.name).join(", "),children:[l.jsx(Ds,{maxVisible:4,className:"omnibox-editor-users__avatars",children:n.map(r=>l.jsxs(qt,{size:"sm",userColor:r.color,title:r.name,children:[l.jsx(vo,{src:r.avatar,alt:r.name}),l.jsx(Gt,{children:xf(r.name)})]},r.id))}),l.jsx("span",{className:"omnibox-editor-user__name",children:t.name}),o>1?l.jsx("span",{className:"omnibox-editor-users__count",children:o}):null]}):null}function Sf(){return l.jsxs("header",{className:"omnibox-editor-header",children:[l.jsx(Ct,{}),l.jsxs("div",{className:"omnibox-editor-header__actions",children:[l.jsx(kf,{}),l.jsx(ee,{}),l.jsxs(fe,{children:[l.jsx(fe,{children:l.jsx(pr,{action:"undo"})}),l.jsx(fe,{children:l.jsx(pr,{action:"redo"})})]}),l.jsx(ee,{}),l.jsx(pf,{})]})]})}const Tf=e=>{const t=u.useRef(e);t.current=e,u.useEffect(()=>()=>{t.current()},[])},Af={leading:!1,trailing:!0};function ia(e,t=250,n=[],o=Af){const r=u.useMemo(()=>I1(e,t,o),n);return Tf(()=>{r.cancel()}),r}function aa(){const[e,t]=u.useState({width:0,height:0,offsetTop:0,offsetLeft:0,scale:0}),n=ia(()=>{if(typeof window>"u")return;const o=window.visualViewport;if(!o)return;const{width:r=0,height:s=0,offsetTop:i=0,offsetLeft:a=0,scale:c=0}=o;t(d=>r===d.width&&s===d.height&&i===d.offsetTop&&a===d.offsetLeft&&c===d.scale?d:{width:r,height:s,offsetTop:i,offsetLeft:a,scale:c})},200);return u.useEffect(()=>{const o=window.visualViewport;if(o)return o.addEventListener("resize",n),n(),()=>{o.removeEventListener("resize",n)}},[n]),e}const ca=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.43471 4.01458C4.34773 4.06032 4.26607 4.11977 4.19292 4.19292C4.11977 4.26607 4.06032 4.34773 4.01458 4.43471C2.14611 6.40628 1 9.0693 1 12C1 18.0751 5.92487 23 12 23C14.9306 23 17.5936 21.854 19.5651 19.9856C19.6522 19.9398 19.7339 19.8803 19.8071 19.8071C19.8803 19.7339 19.9398 19.6522 19.9856 19.5651C21.854 17.5936 23 14.9306 23 12C23 5.92487 18.0751 1 12 1C9.0693 1 6.40628 2.14611 4.43471 4.01458ZM6.38231 4.9681C7.92199 3.73647 9.87499 3 12 3C16.9706 3 21 7.02944 21 12C21 14.125 20.2635 16.078 19.0319 17.6177L6.38231 4.9681ZM17.6177 19.0319C16.078 20.2635 14.125 21 12 21C7.02944 21 3 16.9706 3 12C3 9.87499 3.73647 7.92199 4.9681 6.38231L17.6177 19.0319Z",fill:"currentColor"})}));ca.displayName="BanIcon";const Cr=u.forwardRef(({className:e,children:t,...n},o)=>{const r=D();return l.jsx(M,{type:"button",className:e,variant:"ghost","data-appearance":"default",role:"button",tabIndex:-1,"aria-label":r.textHighlighter,tooltip:r.highlightColor,ref:o,...n,children:t??l.jsx(Bt,{className:"tiptap-button-icon"})})});Cr.displayName="ColorHighlightPopoverButton";function da({editor:e,colors:t=Ql(["var(--tt-color-highlight-green)","var(--tt-color-highlight-blue)","var(--tt-color-highlight-red)","var(--tt-color-highlight-purple)","var(--tt-color-highlight-yellow)"]),useColorValue:n=!1}){const o=D(),{handleRemoveHighlight:r}=Dt({editor:e}),s=re(),i=u.useRef(null),a=u.useMemo(()=>[...t,{label:o.removeHighlight,value:"none"}],[t,o.removeHighlight]),{selectedIndex:c}=Ut({containerRef:i,items:a,orientation:"both",onSelect:d=>{if(!i.current)return!1;const p=i.current.querySelector('[data-highlighted="true"]');return p&&p.click(),d.value==="none"&&r(),!0},autoSelectFirstItem:!1});return l.jsx(Ze,{ref:i,tabIndex:0,style:s?{boxShadow:"none",border:0}:{},children:l.jsx(Fe,{style:s?{padding:0}:{},children:l.jsxs(Me,{orientation:"horizontal",children:[l.jsx(fe,{children:t.map((d,p)=>l.jsx(fe,{children:l.jsx(Re,{editor:e,highlightColor:n?d.colorValue:d.value,tooltip:d.label,"aria-label":`${d.label} highlight color`,tabIndex:p===c?0:-1,"data-highlighted":c===p,useColorValue:n})},d.value))}),l.jsx(ee,{}),l.jsx(fe,{children:l.jsx(M,{onClick:r,"aria-label":o.removeHighlight,tooltip:o.removeHighlight,tabIndex:c===t.length?0:-1,type:"button",role:"menuitem",variant:"ghost","data-highlighted":c===t.length,children:l.jsx(ca,{className:"tiptap-button-icon"})})})]})})})}function If({editor:e,colors:t=Ql(["var(--tt-color-highlight-green)","var(--tt-color-highlight-blue)","var(--tt-color-highlight-red)","var(--tt-color-highlight-purple)","var(--tt-color-highlight-yellow)"]),hideWhenUnavailable:n=!1,useColorValue:o=!1,onApplied:r,...s}){const{editor:i}=k(e),a=D(),[c,d]=u.useState(!1),{isVisible:p,canColorHighlight:f,isActive:h,label:C,Icon:g}=Dt({editor:i,hideWhenUnavailable:n,onApplied:r});return p?l.jsxs(Ot,{open:c,onOpenChange:d,children:[l.jsx(Pt,{asChild:!0,children:l.jsx(Cr,{disabled:!f,"data-active-state":h?"on":"off","data-disabled":!f,"aria-pressed":h,"aria-label":C,tooltip:C,...s,children:l.jsx(g,{className:"tiptap-button-icon"})})}),l.jsx(Wt,{"aria-label":a.highlightColors,children:l.jsx(da,{editor:i,colors:t,useColorValue:o})})]}):null}function Lf({shortcutKeys:e=br}){return l.jsx(R,{children:J({shortcutKeys:e})})}const gr=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onInserted:o,showShortcut:r=!1,onClick:s,icon:i,children:a,...c},d)=>{const{editor:p}=k(e),{isVisible:f,canInsert:h,handleImage:C,label:g,isActive:b,shortcutKeys:m,Icon:w}=Hf({editor:p,hideWhenUnavailable:n,onInserted:o}),v=u.useCallback(x=>{s?.(x),!x.defaultPrevented&&C()},[C,s]);if(!f)return null;const y=i??w;return l.jsx(M,{type:"button",variant:"ghost","data-active-state":b?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":g,"aria-pressed":b,tooltip:g,onClick:v,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(y,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(Lf,{shortcutKeys:m})]})})});gr.displayName="ImageUploadButton";const ua=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20 2C20 1.44772 19.5523 1 19 1C18.4477 1 18 1.44772 18 2V4H16C15.4477 4 15 4.44772 15 5C15 5.55228 15.4477 6 16 6H18V8C18 8.55228 18.4477 9 19 9C19.5523 9 20 8.55228 20 8V6H22C22.5523 6 23 5.55228 23 5C23 4.44772 22.5523 4 22 4H20V2ZM5 4C4.73478 4 4.48043 4.10536 4.29289 4.29289C4.10536 4.48043 4 4.73478 4 5V19C4 19.2652 4.10536 19.5196 4.29289 19.7071C4.48043 19.8946 4.73478 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12V14.998C22 14.9994 22 15.0007 22 15.002V19C22 19.7957 21.6839 20.5587 21.1213 21.1213C20.5587 21.6839 19.7957 22 19 22H6.00219C6.00073 22 5.99927 22 5.99781 22H5C4.20435 22 3.44129 21.6839 2.87868 21.1213C2.31607 20.5587 2 19.7957 2 19V5C2 4.20435 2.31607 3.44129 2.87868 2.87868C3.44129 2.31607 4.20435 2 5 2H12C12.5523 2 13 2.44772 13 3C13 3.55228 12.5523 4 12 4H5ZM8.41422 20H19C19.2652 20 19.5196 19.8946 19.7071 19.7071C19.8946 19.5196 20 19.2652 20 19V15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20ZM6.87868 6.87868C7.44129 6.31607 8.20435 6 9 6C9.79565 6 10.5587 6.31607 11.1213 6.87868C11.6839 7.44129 12 8.20435 12 9C12 9.79565 11.6839 10.5587 11.1213 11.1213C10.5587 11.6839 9.79565 12 9 12C8.20435 12 7.44129 11.6839 6.87868 11.1213C6.31607 10.5587 6 9.79565 6 9C6 8.20435 6.31607 7.44129 6.87868 6.87868ZM9 8C8.73478 8 8.48043 8.10536 8.29289 8.29289C8.10536 8.48043 8 8.73478 8 9C8 9.26522 8.10536 9.51957 8.29289 9.70711C8.48043 9.89464 8.73478 10 9 10C9.26522 10 9.51957 9.89464 9.70711 9.70711C9.89464 9.51957 10 9.26522 10 9C10 8.73478 9.89464 8.48043 9.70711 8.29289C9.51957 8.10536 9.26522 8 9 8Z",fill:"currentColor"})}));ua.displayName="ImagePlusIcon";const br="mod+shift+i";function mr(e){return!e||!e.isEditable||!_(e,"imageUpload")?!1:e.can().insertContent({type:"imageUpload"})}function Ef(e){return!e||!e.isEditable?!1:e.isActive("imageUpload")}function Mf(e){if(!e||!e.isEditable||!mr(e))return!1;try{return e.chain().focus().insertContent({type:"imageUpload"}).run()}catch{return!1}}function Nf(e){const{editor:t,hideWhenUnavailable:n}=e;return!t||!t.isEditable?!1:n?_(t,"imageUpload")?t.isActive("code")?!0:mr(t):!1:!0}function Hf(e){const{editor:t,hideWhenUnavailable:n=!1,onInserted:o}=e||{},{editor:r}=k(t),s=D(),i=re(),[a,c]=u.useState(!0),d=mr(r),p=Ef(r);u.useEffect(()=>{if(!r)return;const h=()=>{c(Nf({editor:r,hideWhenUnavailable:n}))};return h(),r.on("selectionUpdate",h),()=>{r.off("selectionUpdate",h)}},[r,n]);const f=u.useCallback(()=>{if(!r)return!1;const h=Mf(r);return h&&o?.(),h},[r,o]);return ue.useHotkeys(br,h=>{h.preventDefault(),f()},{enabled:a&&d,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:a,isActive:p,handleImage:f,canInsert:d,label:s.addImage,shortcutKeys:br,Icon:ua}}const fa=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 4C21 3.44772 20.5523 3 20 3C19.4477 3 19 3.44772 19 4V11C19 11.7956 18.6839 12.5587 18.1213 13.1213C17.5587 13.6839 16.7956 14 16 14H6.41421L9.70711 10.7071C10.0976 10.3166 10.0976 9.68342 9.70711 9.29289C9.31658 8.90237 8.68342 8.90237 8.29289 9.29289L3.29289 14.2929C2.90237 14.6834 2.90237 15.3166 3.29289 15.7071L8.29289 20.7071C8.68342 21.0976 9.31658 21.0976 9.70711 20.7071C10.0976 20.3166 10.0976 19.6834 9.70711 19.2929L6.41421 16H16C17.3261 16 18.5979 15.4732 19.5355 14.5355C20.4732 13.5979 21 12.3261 21 11V4Z",fill:"currentColor"})}));fa.displayName="CornerDownLeftIcon";const pa=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L10.7071 14.7071C10.3166 15.0976 9.68342 15.0976 9.29289 14.7071C8.90237 14.3166 8.90237 13.6834 9.29289 13.2929L18.5858 4H15C14.4477 4 14 3.55228 14 3Z",fill:"currentColor"}),l.jsx("path",{d:"M4.29289 7.29289C4.48043 7.10536 4.73478 7 5 7H11C11.5523 7 12 6.55228 12 6C12 5.44772 11.5523 5 11 5H5C4.20435 5 3.44129 5.31607 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V19C2 19.7957 2.31607 20.5587 2.87868 21.1213C3.44129 21.6839 4.20435 22 5 22H16C16.7957 22 17.5587 21.6839 18.1213 21.1213C18.6839 20.5587 19 19.7957 19 19V13C19 12.4477 18.5523 12 18 12C17.4477 12 17 12.4477 17 13V19C17 19.2652 16.8946 19.5196 16.7071 19.7071C16.5196 19.8946 16.2652 20 16 20H5C4.73478 20 4.48043 19.8946 4.29289 19.7071C4.10536 19.5196 4 19.2652 4 19V8C4 7.73478 4.10536 7.48043 4.29289 7.29289Z",fill:"currentColor"})]}));pa.displayName="ExternalLinkIcon";const wr=u.forwardRef(({className:e,children:t,...n},o)=>{const r=D();return l.jsx(M,{type:"button",className:e,variant:"ghost",role:"button",tabIndex:-1,"aria-label":r.link,tooltip:r.link,ref:o,...n,children:t||l.jsx(xt,{className:"tiptap-button-icon"})})});wr.displayName="LinkButton";const ha=({url:e,setUrl:t,setLink:n,removeLink:o,openLink:r,isActive:s})=>{const i=re(),a=D(),c=d=>{d.key==="Enter"&&(d.preventDefault(),n())};return l.jsx(Ze,{style:{...i?{boxShadow:"none",border:0}:{}},children:l.jsx(Fe,{style:{...i?{padding:0}:{}},children:l.jsxs(Me,{orientation:"horizontal",children:[l.jsx(Tl,{type:"url",placeholder:a.pasteLink,value:e,onChange:d=>t(d.target.value),onKeyDown:c,autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",className:"tiptap-link-input"}),l.jsx(fe,{children:l.jsx(M,{type:"button",onClick:n,title:a.applyLink,disabled:!e&&!s,variant:"ghost",children:l.jsx(fa,{className:"tiptap-button-icon"})})}),l.jsx(ee,{}),l.jsxs(fe,{children:[l.jsx(fe,{children:l.jsx(M,{type:"button",onClick:r,title:a.openLinkInNewWindow,disabled:!e&&!s,variant:"ghost",children:l.jsx(pa,{className:"tiptap-button-icon"})})}),l.jsx(fe,{children:l.jsx(M,{type:"button",onClick:o,title:a.removeLink,disabled:!e&&!s,variant:"ghost",children:l.jsx(ht,{className:"tiptap-button-icon"})})})]})]})})})},Vf=({editor:e})=>{const t=ga({editor:e});return l.jsx(ha,{...t})},vr=u.forwardRef(({editor:e,hideWhenUnavailable:t=!1,onSetLink:n,onOpenChange:o,autoOpenOnLinkActive:r=!0,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),[p,f]=u.useState(!1),{isVisible:h,canSet:C,isActive:g,url:b,setUrl:m,setLink:w,removeLink:v,openLink:y,label:x,Icon:S}=ga({editor:d,hideWhenUnavailable:t,onSetLink:n}),L=u.useCallback(K=>{f(K),o?.(K)},[o]),I=u.useCallback(()=>{w(),f(!1)},[w]),V=u.useCallback(K=>{s?.(K),!K.defaultPrevented&&f(!p)},[s,p]);return u.useEffect(()=>{r&&g&&f(!0)},[r,g]),h?l.jsxs(Ot,{open:p,onOpenChange:L,children:[l.jsx(Pt,{asChild:!0,children:l.jsx(wr,{disabled:!C,"data-active-state":g?"on":"off","data-disabled":!C,"aria-label":x,"aria-pressed":g,onClick:V,...a,ref:c,children:i??l.jsx(S,{className:"tiptap-button-icon"})})}),l.jsx(Wt,{collisionPadding:4,children:l.jsx(ha,{url:b,setUrl:m,setLink:I,removeLink:v,openLink:y,isActive:g})})]}):null});vr.displayName="LinkPopover";function yr(e){if(!e||!e.isEditable||ie(e,["image"],!0))return!1;try{return e.can().setMark("link")}catch{return!1}}function Ca(e){return!e||!e.isEditable?!1:e.isActive("link")}function Bf(e){const{editor:t,hideWhenUnavailable:n}=e;if(!t||!t.isEditable)return!1;const o=Ae("link",t);return n?o?t.isActive("code")?!0:yr(t):!1:!0}function Df(e){const{editor:t,onSetLink:n}=e,[o,r]=u.useState(null);u.useEffect(()=>{if(!t)return;const{href:c}=t.getAttributes("link");Ca(t)&&o===null&&r(c||"")},[t,o]),u.useEffect(()=>{if(!t)return;const c=()=>{const{href:d}=t.getAttributes("link");r(d||"")};return t.on("selectionUpdate",c),()=>{t.off("selectionUpdate",c)}},[t]);const s=u.useCallback(()=>{if(!o||!t)return;const{selection:c}=t.state,d=c.empty;let p=t.chain().focus();p=p.extendMarkRange("link").setLink({href:o}),d&&(p=p.insertContent({type:"text",text:o})),p.run(),r(null),n?.()},[t,n,o]),i=u.useCallback(()=>{t&&(t.chain().focus().extendMarkRange("link").unsetLink().setMeta("preventAutolink",!0).run(),r(""))},[t]),a=u.useCallback((c="_blank",d="noopener,noreferrer")=>{if(!o)return;const p=wn(o,window.location.href);p!=="#"&&window.open(p,c,d)},[o]);return{url:o||"",setUrl:r,setLink:s,removeLink:i,openLink:a}}function Uf(e){const{editor:t,hideWhenUnavailable:n=!1}=e,o=yr(t),r=Ca(t),[s,i]=u.useState(!0);return u.useEffect(()=>{if(!t)return;const a=()=>{i(Bf({editor:t,hideWhenUnavailable:n}))};return a(),t.on("selectionUpdate",a),()=>{t.off("selectionUpdate",a)}},[t,n]),{isVisible:s,canSet:o,isActive:r}}function ga(e){const{editor:t,hideWhenUnavailable:n=!1,onSetLink:o}=e||{},{editor:r}=k(t),s=D(),{isVisible:i,canSet:a,isActive:c}=Uf({editor:r,hideWhenUnavailable:n}),d=Df({editor:r,onSetLink:o});return{isVisible:i,canSet:a,isActive:c,label:s.link,Icon:xt,...d}}function Of({type:e,shortcutKeys:t=Sa[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const he=u.forwardRef(({editor:e,type:t,text:n,hideWhenUnavailable:o=!1,onToggled:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:p}=k(e),{isVisible:f,handleMark:h,label:C,canToggle:g,isActive:b,Icon:m,shortcutKeys:w}=zf({editor:p,type:t,hideWhenUnavailable:o,onToggled:r}),v=u.useCallback(y=>{i?.(y),!y.defaultPrevented&&h()},[h,i]);return f?l.jsx(M,{type:"button",disabled:!g,variant:"ghost","data-active-state":b?"on":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":C,"aria-pressed":b,tooltip:C,onClick:v,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(Of,{type:t,shortcutKeys:w})]})}):null});he.displayName="MarkButton";const ba=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",fill:"currentColor"})}));ba.displayName="BoldIcon";const ma=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M15.4545 4.2983C15.6192 3.77115 15.3254 3.21028 14.7983 3.04554C14.2712 2.88081 13.7103 3.1746 13.5455 3.70175L8.54554 19.7017C8.38081 20.2289 8.6746 20.7898 9.20175 20.9545C9.72889 21.1192 10.2898 20.8254 10.4545 20.2983L15.4545 4.2983Z",fill:"currentColor"}),l.jsx("path",{d:"M6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.70711L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289Z",fill:"currentColor"}),l.jsx("path",{d:"M17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C23.0976 11.6834 23.0976 12.3166 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z",fill:"currentColor"})]}));ma.displayName="Code2Icon";const wa=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",fill:"currentColor"})}));wa.displayName="ItalicIcon";const va=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",fill:"currentColor"}),l.jsx("path",{d:"M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",fill:"currentColor"})]}));va.displayName="StrikeIcon";const ya=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.4079 14.3995C18.0284 14.0487 18.7506 13.9217 19.4536 14.0397C20.1566 14.1578 20.7977 14.5138 21.2696 15.0481L21.2779 15.0574L21.2778 15.0575C21.7439 15.5988 22 16.2903 22 17C22 18.0823 21.3962 18.8401 20.7744 19.3404C20.194 19.8073 19.4858 20.141 18.9828 20.378C18.9638 20.387 18.9451 20.3958 18.9266 20.4045C18.4473 20.6306 18.2804 20.7817 18.1922 20.918C18.1773 20.9412 18.1619 20.9681 18.1467 21H21C21.5523 21 22 21.4477 22 22C22 22.5523 21.5523 23 21 23H17C16.4477 23 16 22.5523 16 22C16 21.1708 16.1176 20.4431 16.5128 19.832C16.9096 19.2184 17.4928 18.8695 18.0734 18.5956C18.6279 18.334 19.138 18.0901 19.5207 17.7821C19.8838 17.49 20 17.2477 20 17C20 16.7718 19.9176 16.5452 19.7663 16.3672C19.5983 16.1792 19.3712 16.0539 19.1224 16.0121C18.8722 15.9701 18.6152 16.015 18.3942 16.1394C18.1794 16.2628 18.0205 16.4549 17.9422 16.675C17.7572 17.1954 17.1854 17.4673 16.665 17.2822C16.1446 17.0972 15.8728 16.5254 16.0578 16.005C16.2993 15.3259 16.7797 14.7584 17.4039 14.4018L17.4079 14.3995L17.4079 14.3995Z",fill:"currentColor"})]}));ya.displayName="SubscriptIcon";const xa=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.405 1.40657C18.0246 1.05456 18.7463 0.92634 19.4492 1.04344C20.1521 1.16054 20.7933 1.51583 21.2652 2.0497L21.2697 2.05469L21.2696 2.05471C21.7431 2.5975 22 3.28922 22 4.00203C22 5.08579 21.3952 5.84326 20.7727 6.34289C20.1966 6.80531 19.4941 7.13675 18.9941 7.37261C18.9714 7.38332 18.9491 7.39383 18.9273 7.40415C18.4487 7.63034 18.2814 7.78152 18.1927 7.91844C18.1778 7.94155 18.1625 7.96834 18.1473 8.00003H21C21.5523 8.00003 22 8.44774 22 9.00003C22 9.55231 21.5523 10 21 10H17C16.4477 10 16 9.55231 16 9.00003C16 8.17007 16.1183 7.44255 16.5138 6.83161C16.9107 6.21854 17.4934 5.86971 18.0728 5.59591C18.6281 5.33347 19.1376 5.09075 19.5208 4.78316C19.8838 4.49179 20 4.25026 20 4.00203C20 3.77192 19.9178 3.54865 19.7646 3.37182C19.5968 3.18324 19.3696 3.05774 19.1205 3.01625C18.8705 2.97459 18.6137 3.02017 18.3933 3.14533C18.1762 3.26898 18.0191 3.45826 17.9406 3.67557C17.7531 4.19504 17.18 4.46414 16.6605 4.27662C16.141 4.0891 15.8719 3.51596 16.0594 2.99649C16.303 2.3219 16.7817 1.76125 17.4045 1.40689L17.405 1.40657Z",fill:"currentColor"})]}));xa.displayName="SuperscriptIcon";const ka=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4V10C5 11.8565 5.7375 13.637 7.05025 14.9497C8.36301 16.2625 10.1435 17 12 17C13.8565 17 15.637 16.2625 16.9497 14.9497C18.2625 13.637 19 11.8565 19 10V4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V10C17 11.3261 16.4732 12.5979 15.5355 13.5355C14.5979 14.4732 13.3261 15 12 15C10.6739 15 9.40215 14.4732 8.46447 13.5355C7.52678 12.5979 7 11.3261 7 10V4ZM4 19C3.44772 19 3 19.4477 3 20C3 20.5523 3.44772 21 4 21H20C20.5523 21 21 20.5523 21 20C21 19.4477 20.5523 19 20 19H4Z",fill:"currentColor"})}));ka.displayName="UnderlineIcon";const Pf={bold:ba,italic:wa,underline:ka,strike:va,code:ma,superscript:xa,subscript:ya},Sa={bold:"mod+b",italic:"mod+i",underline:"mod+u",strike:"mod+shift+s",code:"mod+e",superscript:"mod+.",subscript:"mod+,"};function ln(e,t){return!e||!e.isEditable||!Ae(t,e)||ie(e,["image"])?!1:e.can().toggleMark(t)}function Wf(e,t){return!e||!e.isEditable?!1:e.isActive(t)}function _f(e,t){return!e||!e.isEditable||!ln(e,t)?!1:e.chain().focus().toggleMark(t).run()}function Zf(e){const{editor:t,type:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!Ae(n,t)?!1:t.isActive("code")?!0:ln(t,n):!0:!1}function Ff(e,t){return{bold:t.bold,italic:t.italic,underline:t.underline,strike:t.strike,code:t.code,superscript:t.superscript,subscript:t.subscript}[e]}function zf(e){const{editor:t,type:n,hideWhenUnavailable:o=!1,onToggled:r}=e,{editor:s}=k(t),i=D(),[a,c]=u.useState(!0),d=ln(s,n),p=Wf(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{c(Zf({editor:s,type:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const f=u.useCallback(()=>{if(!s)return!1;const h=_f(s,n);return h&&r?.(),h},[s,n,r]);return{isVisible:a,isActive:p,handleMark:f,canToggle:d,label:Ff(n,i),shortcutKeys:Sa[n],Icon:Pf[n]}}function $f({align:e,shortcutKeys:t=Ta[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const Ne=u.forwardRef(({editor:e,align:t,text:n,hideWhenUnavailable:o=!1,onAligned:r,showShortcut:s=!1,onClick:i,icon:a,children:c,...d},p)=>{const{editor:f}=k(e),{isVisible:h,handleTextAlign:C,label:g,canAlign:b,isActive:m,Icon:w,shortcutKeys:v}=Jf({editor:f,align:t,hideWhenUnavailable:o,onAligned:r}),y=u.useCallback(S=>{i?.(S),!S.defaultPrevented&&C()},[C,i]);if(!h)return null;const x=a??w;return l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":m?"on":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":m,tooltip:g,onClick:y,...d,ref:p,children:c??l.jsxs(l.Fragment,{children:[l.jsx(x,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx($f,{align:t,shortcutKeys:v})]})})});Ne.displayName="TextAlignButton";const Ta={left:"mod+shift+l",center:"mod+shift+e",right:"mod+shift+r",justify:"mod+shift+j"},qf={left:Rn,center:eo,right:to,justify:no};function Gf(e,t){return{left:t.alignLeft,center:t.alignCenter,right:t.alignRight,justify:t.alignJustify}[e]}function sn(e,t){return!e||!e.isEditable||!_(e,"textAlign")||ie(e,["image","horizontalRule"])?!1:e.can().setTextAlign(t)}function Kf(e){return"setTextAlign"in e}function Yf(e,t){return!e||!e.isEditable?!1:e.isActive({textAlign:t})}function jf(e,t){if(!e||!e.isEditable||!sn(e,t))return!1;const n=e.chain().focus();return Kf(n)?n.setTextAlign(t).run():!1}function Xf(e){const{editor:t,hideWhenUnavailable:n,align:o}=e;return t?n?!t.isEditable||!_(t,"textAlign")?!1:t.isActive("code")?!0:sn(t,o):!0:!1}function Jf(e){const{editor:t,align:n,hideWhenUnavailable:o=!1,onAligned:r}=e,{editor:s}=k(t),i=D(),[a,c]=u.useState(!0),d=sn(s,n),p=Yf(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{c(Xf({editor:s,align:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o,n]);const f=u.useCallback(()=>{if(!s)return!1;const h=jf(s,n);return h&&r?.(),h},[s,n,r]);return{isVisible:a,isActive:p,handleTextAlign:f,canAlign:d,label:Gf(n,i),shortcutKeys:Ta[n],Icon:qf[n]}}const Aa=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 5.29289C21.0976 5.68342 21.0976 6.31658 20.7071 6.70711L9.70711 17.7071C9.31658 18.0976 8.68342 18.0976 8.29289 17.7071L3.29289 12.7071C2.90237 12.3166 2.90237 11.6834 3.29289 11.2929C3.68342 10.9024 4.31658 10.9024 4.70711 11.2929L9 15.5858L19.2929 5.29289C19.6834 4.90237 20.3166 4.90237 20.7071 5.29289Z",fill:"currentColor"})}));Aa.displayName="CheckIcon";function Ia({...e}){return l.jsx(ve.Root,{"data-slot":"tiptap-dropdown-menu",...e})}function La({...e}){return l.jsx(ve.Portal,{"data-slot":"tiptap-dropdown-menu-portal",...e})}function Ea({...e}){return l.jsx(ve.Trigger,{"data-slot":"tiptap-dropdown-menu-trigger",...e})}function Ma({className:e,align:t="start",sideOffset:n=4,...o}){return l.jsx(ve.Portal,{children:l.jsx(ve.Content,{"data-slot":"tiptap-dropdown-menu-content",sideOffset:n,align:t,className:$("tiptap-dropdown-menu-content",e),onCloseAutoFocus:r=>r.preventDefault(),...o})})}function qe({className:e,...t}){return l.jsx(ve.Group,{"data-slot":"tiptap-dropdown-menu-group",className:$("tiptap-dropdown-menu-group",e),...t})}function pe({className:e,inset:t,variant:n="default",...o}){return l.jsx(ve.Item,{"data-slot":"tiptap-dropdown-menu-item","data-inset":t,"data-variant":n,className:$("tiptap-dropdown-menu-item",e),...o})}function kt({className:e,inset:t,...n}){return l.jsx(ve.Label,{"data-slot":"tiptap-dropdown-menu-label","data-inset":t,className:$("tiptap-dropdown-menu-label",e),...n})}function Na({...e}){return l.jsx(ve.Sub,{"data-slot":"tiptap-dropdown-menu-sub",...e})}function Ha({className:e,inset:t,children:n,...o}){return l.jsx(ve.SubTrigger,{"data-slot":"tiptap-dropdown-menu-sub-trigger","data-inset":t,className:$("tiptap-dropdown-menu-sub-trigger",e),...o,children:n})}function Va({className:e,...t}){return l.jsx(ve.SubContent,{"data-slot":"tiptap-dropdown-menu-sub-content",className:$("tiptap-dropdown-menu-sub-content",e),...t})}function Ba({blockTypes:e,editor:t}){const n=D(),o=an(e).map(r=>xr(r,n));return l.jsxs(qe,{children:[l.jsx(kt,{children:n.turnInto}),o.map((r,s)=>Qf(r,`${r.type}-${r.level??s}`,t))]})}function Qf(e,t,n){switch(e.type){case"paragraph":return l.jsx(pe,{asChild:!0,children:l.jsx(Pi,{editor:n,showTooltip:!1,text:e.label})},t);case"heading":return e.level?l.jsx(pe,{asChild:!0,children:l.jsx(_i,{editor:n,level:e.level,showTooltip:!1,text:e.label})},t):null;case"bulletList":return l.jsx(pe,{asChild:!0,children:l.jsx(nn,{editor:n,type:"bulletList",showTooltip:!1,text:e.label})},t);case"orderedList":return l.jsx(pe,{asChild:!0,children:l.jsx(nn,{editor:n,type:"orderedList",showTooltip:!1,text:e.label})},t);case"taskList":return l.jsx(pe,{asChild:!0,children:l.jsx(nn,{editor:n,type:"taskList",showTooltip:!1,text:e.label})},t);case"blockquote":return l.jsx(pe,{asChild:!0,children:l.jsx(Gi,{editor:n,showTooltip:!1,text:e.label})},t);case"codeBlock":return l.jsx(pe,{asChild:!0,children:l.jsx(ji,{editor:n,showTooltip:!1,text:e.label})},t);default:return null}}const Da=u.forwardRef(function({editor:t,hideWhenUnavailable:n=!1,blockTypes:o,onOpenChange:r,modal:s=!0,children:i,...a},c){const{editor:d}=k(t),p=D(),{isVisible:f,canToggle:h,isOpen:C,activeBlockType:g,handleOpenChange:b,label:m,Icon:w}=o5({editor:d,hideWhenUnavailable:n,blockTypes:o,onOpenChange:r});return f?l.jsxs(Ia,{modal:s,open:C,onOpenChange:b,children:[l.jsx(Ea,{asChild:!0,children:l.jsx(M,{type:"button",variant:"ghost",disabled:!h,"data-disabled":!h,role:"button",tabIndex:-1,"aria-label":m,tooltip:p.turnInto,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tiptap-button-text",children:g?.label||p.text}),l.jsx(w,{className:"tiptap-button-dropdown-small"})]})})}),l.jsx(Ma,{align:"start",children:l.jsx(Ba,{blockTypes:o,editor:d})})]}):null});Da.displayName="TurnIntoDropdown";const Rf=["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"],Ua=[{type:"paragraph",label:"Text",isActive:e=>e.isActive("paragraph")&&!e.isActive("heading")&&!e.isActive("bulletList")&&!e.isActive("orderedList")&&!e.isActive("taskList")&&!e.isActive("blockquote")&&!e.isActive("codeBlock")},{type:"heading",label:"Heading 1",level:1,isActive:e=>e.isActive("heading",{level:1})},{type:"heading",label:"Heading 2",level:2,isActive:e=>e.isActive("heading",{level:2})},{type:"heading",label:"Heading 3",level:3,isActive:e=>e.isActive("heading",{level:3})},{type:"bulletList",label:"Bulleted list",isActive:e=>e.isActive("bulletList")},{type:"orderedList",label:"Numbered list",isActive:e=>e.isActive("orderedList")},{type:"taskList",label:"To-do list",isActive:e=>e.isActive("taskList")},{type:"blockquote",label:"Blockquote",isActive:e=>e.isActive("blockquote")},{type:"codeBlock",label:"Code block",isActive:e=>e.isActive("codeBlock")}];function e5(e,t){return{1:t.heading1,2:t.heading2,3:t.heading3,4:t.heading4,5:t.heading5,6:t.heading6}[e]}function xr(e,t){const n=(()=>{switch(e.type){case"paragraph":return t.text;case"heading":return e.level?e5(e.level,t):t.heading;case"bulletList":return t.bulletList;case"orderedList":return t.orderedList;case"taskList":return t.taskList;case"blockquote":return t.blockquote;case"codeBlock":return t.codeBlock;default:return e.label}})();return{...e,label:n}}function Oa(e,t){if(!e||!e.isEditable)return!1;const n=t||Rf,{selection:o}=e.state;if(o instanceof E.NodeSelection){const i=o.node.type.name;return n.includes(i)}const{$anchor:r}=o,s=r.parent.type.name;return n.includes(s)}function an(e){return e?Ua.filter(t=>e.includes(t.type)):Ua}function t5(e,t){if(!e)return an(t)[0];const n=an(t);return n.find(r=>r.isActive(e))||n[0]}function n5(e){const{editor:t,hideWhenUnavailable:n,blockTypes:o}=e;return t?n?t.isEditable?t.isActive("code")?!0:Oa(t,o):!1:!0:!1}function o5(e){const{editor:t,hideWhenUnavailable:n=!1,blockTypes:o,onOpenChange:r}=e||{},{editor:s}=k(t),i=D(),[a,c]=u.useState(!1),[d,p]=u.useState(!0),f=Oa(s,o),h=xr(t5(s,o),i),C=an(o).map(b=>xr(b,i)),g=u.useCallback(b=>{!s||!f||(c(b),r?.(b))},[f,s,r]);return u.useEffect(()=>{if(!s)return;const b=()=>{p(n5({editor:s,hideWhenUnavailable:n,blockTypes:o}))};return b(),s.on("selectionUpdate",b),()=>{s.off("selectionUpdate",b)}},[s,n,o]),{isVisible:d,canToggle:f,isOpen:a,setIsOpen:c,activeBlockType:h,handleOpenChange:g,filteredOptions:C,label:i.turnIntoCurrent.replace("{{current}}",h?.label||i.text),Icon:Xn}}function r5({action:e,shortcutKeys:t=_a[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const St=u.forwardRef(({editor:e,action:t,text:n,hideWhenUnavailable:o=!1,onIndented:r,showShortcut:s=!1,onClick:i,icon:a,children:c,...d},p)=>{const{editor:f}=k(e),{isVisible:h,handleIndent:C,label:g,canIndent:b,Icon:m,shortcutKeys:w}=c5({editor:f,action:t,hideWhenUnavailable:o,onIndented:r}),v=u.useCallback(x=>{i?.(x),!x.defaultPrevented&&C()},[C,i]);if(!h)return null;const y=a??m;return l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,tooltip:g,onClick:v,...d,ref:p,children:c??l.jsxs(l.Fragment,{children:[l.jsx(y,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(r5,{action:t,shortcutKeys:w})]})})});St.displayName="IndentButton";const Pa=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M17.0002 18.5C17.5524 18.5 18.0002 18.9477 18.0002 19.5C18.0002 20.0523 17.5524 20.5 17.0002 20.5H11.0002C10.4479 20.5 10.0002 20.0523 10.0002 19.5C10.0002 18.9477 10.4479 18.5 11.0002 18.5H17.0002Z",fill:"currentColor"}),l.jsx("path",{d:"M2.29314 8.29297C2.68366 7.90248 3.31669 7.90246 3.7072 8.29297L6.7072 11.293L6.77556 11.3691C7.09586 11.7619 7.07327 12.3409 6.7072 12.707L3.7072 15.707C3.31669 16.0975 2.68367 16.0975 2.29314 15.707C1.90261 15.3165 1.90261 14.6835 2.29314 14.293L4.58611 12L2.29314 9.70703C1.90261 9.31651 1.90261 8.68349 2.29314 8.29297Z",fill:"currentColor"}),l.jsx("path",{d:"M21.0002 13.5C21.5524 13.5 22.0002 13.9477 22.0002 14.5C22.0002 15.0523 21.5524 15.5 21.0002 15.5H11.0002C10.4479 15.5 10.0002 15.0523 10.0002 14.5C10.0002 13.9477 10.4479 13.5 11.0002 13.5H21.0002Z",fill:"currentColor"}),l.jsx("path",{d:"M21.0002 8.5C21.5524 8.50004 22.0002 8.94774 22.0002 9.5C22.0002 10.0523 21.5524 10.5 21.0002 10.5H11.0002C10.4479 10.5 10.0002 10.0523 10.0002 9.5C10.0002 8.94772 10.4479 8.5 11.0002 8.5H21.0002Z",fill:"currentColor"}),l.jsx("path",{d:"M21.0002 3.5C21.5524 3.50004 22.0002 3.94774 22.0002 4.5C22.0002 5.05226 21.5524 5.49996 21.0002 5.5H11.0002C10.4479 5.5 10.0002 5.05228 10.0002 4.5C10.0002 3.94772 10.4479 3.5 11.0002 3.5H21.0002Z",fill:"currentColor"})]}));Pa.displayName="IndentIncreaseIcon";const Wa=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M9 18.5C9.55228 18.5 10 18.9477 10 19.5C10 20.0523 9.55228 20.5 9 20.5H3C2.44772 20.5 2 20.0523 2 19.5C2 18.9477 2.44772 18.5 3 18.5H9Z",fill:"currentColor"}),l.jsx("path",{d:"M20.293 8.29297C20.6835 7.90244 21.3165 7.90244 21.707 8.29297C22.0976 8.68349 22.0976 9.31651 21.707 9.70703L19.4141 12L21.707 14.293C22.0976 14.6835 22.0976 15.3165 21.707 15.707C21.3165 16.0976 20.6835 16.0976 20.293 15.707L17.293 12.707L17.2246 12.6309C16.9043 12.2381 16.9269 11.6591 17.293 11.293L20.293 8.29297Z",fill:"currentColor"}),l.jsx("path",{d:"M13 13.5C13.5523 13.5 14 13.9477 14 14.5C14 15.0523 13.5523 15.5 13 15.5H3C2.44772 15.5 2 15.0523 2 14.5C2 13.9477 2.44772 13.5 3 13.5H13Z",fill:"currentColor"}),l.jsx("path",{d:"M13 8.5C13.5523 8.5 14 8.94772 14 9.5C14 10.0523 13.5523 10.5 13 10.5H3C2.44772 10.5 2 10.0523 2 9.5C2 8.94772 2.44772 8.5 3 8.5H13Z",fill:"currentColor"}),l.jsx("path",{d:"M13 3.5C13.5523 3.5 14 3.94772 14 4.5C14 5.05228 13.5523 5.5 13 5.5H3C2.44772 5.5 2 5.05228 2 4.5C2 3.94772 2.44772 3.5 3 3.5H13Z",fill:"currentColor"})]}));Wa.displayName="IndentDecreaseIcon";const _a={indent:"Tab",outdent:"Shift-Tab"},l5={indent:Pa,outdent:Wa};function s5(e,t){return{indent:t.increaseIndent,outdent:t.decreaseIndent}[e]}function kr(e,t){return!e||!e.isEditable||!_(e,"indent")?!1:t==="indent"?e.can().indent():e.can().outdent()}function i5(e,t){return!e||!e.isEditable||!kr(e,t)?!1:t==="indent"?e.chain().focus().indent().run():e.chain().focus().outdent().run()}function a5(e){const{editor:t,hideWhenUnavailable:n,action:o}=e;return t?n?!t.isEditable||!_(t,"indent")?!1:kr(t,o):!0:!1}function c5(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onIndented:r}=e,{editor:s}=k(t),i=D(),[a,c]=u.useState(!0),d=kr(s,n);u.useEffect(()=>{if(!s)return;const f=()=>{c(a5({editor:s,action:n,hideWhenUnavailable:o}))};return f(),s.on("selectionUpdate",f),s.on("transaction",f),()=>{s.off("selectionUpdate",f),s.off("transaction",f)}},[s,o,n]);const p=u.useCallback(()=>{if(!s)return!1;const f=i5(s,n);return f&&r?.(),f},[s,n,r]);return{isVisible:a,canIndent:d,handleIndent:p,label:s5(n,i),shortcutKeys:_a[n],Icon:l5[n]}}const d5=e=>{const[t,n]=u.useState([]),o=u.useCallback(()=>e.current?Array.from(e.current.querySelectorAll('button:not([disabled]), [role="button"]:not([disabled]), [tabindex="0"]:not([disabled])')):[],[e]);u.useEffect(()=>{const s=e.current;if(!s)return;const i=()=>n(o());i();const a=new MutationObserver(i);return a.observe(s,{childList:!0,subtree:!0}),()=>a.disconnect()},[o,e]);const{selectedIndex:r}=Ut({containerRef:e,items:t,orientation:"horizontal",onSelect:s=>s.click(),autoSelectFirstItem:!1});u.useEffect(()=>{const s=e.current;if(!s)return;const i=c=>{const d=c.target;s.contains(d)&&d.setAttribute("data-focus-visible","true")},a=c=>{const d=c.target;s.contains(d)&&d.removeAttribute("data-focus-visible")};return s.addEventListener("focus",i,!0),s.addEventListener("blur",a,!0),()=>{s.removeEventListener("focus",i,!0),s.removeEventListener("blur",a,!0)}},[e]),u.useEffect(()=>{r!==void 0&&t[r]&&t[r].focus()},[r,t])},cn=u.forwardRef(({children:e,className:t,variant:n="fixed",...o},r)=>{const s=u.useRef(null),i=Il(s,r);return d5(s),l.jsx("div",{ref:i,role:"toolbar","aria-label":"toolbar","data-variant":n,className:$("tiptap-toolbar",t),...o,children:e})});cn.displayName="Toolbar";const ae=u.forwardRef(({children:e,className:t,...n},o)=>l.jsx("div",{ref:o,role:"group",className:$("tiptap-toolbar-group",t),...n,children:e}));ae.displayName="ToolbarGroup";const Ce=u.forwardRef(({...e},t)=>l.jsx(ee,{ref:t,orientation:"vertical",decorative:!0,...e}));Ce.displayName="ToolbarSeparator";function u5({shortcutKeys:e}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Sr=u.forwardRef(({editor:e,text:t,direction:n,hideWhenUnavailable:o=!1,onMoved:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:p}=k(e),{isVisible:f,handleMoveNode:h,canMoveNode:C,label:g,shortcutKeys:b,Icon:m}=g5({editor:p,direction:n,hideWhenUnavailable:o,onMoved:r}),w=u.useCallback(y=>{i?.(y),!y.defaultPrevented&&h()},[h,i]);if(!f)return null;const v=n==="up"?"Move Up":"Move Down";return l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":g,tooltip:v,disabled:!C,onClick:w,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),s&&l.jsx(u5,{shortcutKeys:b})]})})});Sr.displayName="MoveNodeButton";const f5="mod+shift+ArrowUp",p5="mod+shift+ArrowDown";function Za(e,t){if(!e||!e.isEditable)return!1;const n=ct(e);if(!n)return!1;try{const{pos:o}=n,r=e.state.doc.resolve(o),s=r.parent,i=r.index();return t==="up"?i>0:i<s.childCount-1}catch{return!1}}function h5(e,t){if(!e||!e.isEditable)return!1;const n=ct(e);if(!n)return!1;try{const{pos:o,node:r}=n,s=e.state.tr,i=s.doc.resolve(o),a=i.parent,c=i.index();if(c<0||c>=a.childCount)return!1;if(t==="up"&&c>0){const p=a.child(c-1).nodeSize,f=r.type.create(r.attrs,r.content,r.marks);s.deleteRange(o,o+r.nodeSize);const h=o-p;s.insert(h,f),s.setSelection(E.TextSelection.near(s.doc.resolve(h)))}else if(t==="down"&&c<a.childCount-1){const p=a.child(c+1).nodeSize,f=r.type.create(r.attrs,r.content,r.marks);s.deleteRange(o,o+r.nodeSize);const h=o+p;s.insert(h,f),s.setSelection(E.TextSelection.near(s.doc.resolve(h)))}else return!1;return e.view.dispatch(s),!0}catch(o){return console.error("Error moving node:",o),!1}}function C5(e){const{editor:t,direction:n,hideWhenUnavailable:o}=e;if(!t)return!1;if(!o)return!0;if(!t.isEditable)return!1;const r=!!ct(t),s=Za(t,n);return r&&s}function g5(e){const{editor:t,hideWhenUnavailable:n=!1,direction:o,onMoved:r}=e,{editor:s}=k(t),i=re(),[a,c]=u.useState(!0),[d,p]=u.useState(!1),f=u.useCallback(()=>{if(!d)return!1;const b=h5(s,o);return b&&r?.(o),b},[s,o,r,d]);u.useEffect(()=>{if(!s)return;const b=()=>{c(C5({editor:s,direction:o,hideWhenUnavailable:n})),p(Za(s,o))};return b(),s.on("selectionUpdate",b),()=>{s.off("selectionUpdate",b)}},[s,o,n]);const h=o==="up"?f5:p5;return ue.useHotkeys(h,b=>{b.preventDefault(),f()},{enabled:a&&d,enableOnContentEditable:!i,enableOnFormTags:!0},[f,a,d,i]),{isVisible:a,handleMoveNode:f,canMoveNode:d,label:o==="up"?"Move Up":"Move Down",shortcutKeys:h,Icon:o==="up"?ro:oo}}const dn={x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0},Fa=typeof window>"u",b5=!Fa&&typeof ResizeObserver<"u",un=()=>!Fa;function m5({element:e,enabled:t=!0,throttleMs:n=100,useResizeObserver:o=!0}={}){const[r,s]=u.useState(dn),i=u.useCallback(()=>!t||!un()?null:e?typeof e=="string"?document.querySelector(e):"current"in e?e.current:e:document.body,[e,t]),a=ia(()=>{if(!t||!un())return;const c=i();if(!c){s(dn);return}const d=c.getBoundingClientRect();s({x:d.x,y:d.y,width:d.width,height:d.height,top:d.top,right:d.right,bottom:d.bottom,left:d.left})},n,[t,i],{leading:!0,trailing:!0});return u.useEffect(()=>{if(!t||!un()){s(dn);return}const c=i();if(!c)return;a();const d=[];if(o&&b5){const f=new ResizeObserver(()=>{window.requestAnimationFrame(a)});f.observe(c),d.push(()=>f.disconnect())}const p=()=>a();return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p,!0),d.push(()=>{window.removeEventListener("scroll",p),window.removeEventListener("resize",p)}),()=>{d.forEach(f=>f()),s(dn)}},[t,i,a,o]),r}function w5(e={}){return m5({...e,element:un()?document.body:null})}function v5({editor:e,overlayHeight:t=0}){const{height:n}=aa(),o=w5({enabled:!0,throttleMs:100,useResizeObserver:!0});return u.useEffect(()=>{(()=>{if(!e)return;const{state:s,view:i}=e;if(!i.hasFocus())return;const{from:a}=s.selection,c=i.coordsAtPos(a);if(n<o.height&&c&&n-c.top<t){const p=Math.max(n/2,t),f=window.scrollY,C=c.top+f-p;window.scrollTo({top:Math.max(0,C),behavior:"smooth"})}})()},[e,t,n,o.height]),o}function y5({align:e,shortcutKeys:t=Tr[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const fn=u.forwardRef(({editor:e,align:t,text:n,extensionName:o,attributeName:r="data-align",hideWhenUnavailable:s=!1,onAligned:i,showShortcut:a=!1,onClick:c,children:d,...p},f)=>{const{editor:h}=k(e),{isVisible:C,handleImageAlign:g,label:b,canAlign:m,isActive:w,Icon:v,shortcutKeys:y}=I5({editor:h,align:t,extensionName:o,attributeName:r,hideWhenUnavailable:s,onAligned:i}),x=u.useCallback(S=>{c?.(S),!S.defaultPrevented&&g()},[g,c]);return C?l.jsx(M,{type:"button",disabled:!m,variant:"ghost","data-active-state":w?"on":"off","data-disabled":!m,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":w,tooltip:b,onClick:x,...p,ref:f,children:d??l.jsxs(l.Fragment,{children:[l.jsx(v,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),a?l.jsx(y5,{align:t,shortcutKeys:y}):null]})}):null});fn.displayName="ImageAlignButton";const za=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M12 1C12.5523 1 13 1.44772 13 2V22C13 22.5523 12.5523 23 12 23C11.4477 23 11 22.5523 11 22V2C11 1.44772 11.4477 1 12 1Z",fill:"currentColor"}),l.jsx("path",{d:"M2 7C2 5.34315 3.34315 4 5 4H7C7.55228 4 8 4.44772 8 5C8 5.55228 7.55228 6 7 6H5C4.44772 6 4 6.44772 4 7V17C4 17.5523 4.44772 18 5 18H7C7.55228 18 8 18.4477 8 19C8 19.5523 7.55228 20 7 20H5C3.34315 20 2 18.6569 2 17V7Z",fill:"currentColor"}),l.jsx("path",{d:"M19 4C20.6569 4 22 5.34315 22 7V17C22 18.6569 20.6569 20 19 20H17C16.4477 20 16 19.5523 16 19C16 18.4477 16.4477 18 17 18H19C19.5523 18 20 17.5523 20 17V7C20 6.44772 19.5523 6 19 6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H19Z",fill:"currentColor"})]}));za.displayName="AlignCenterVerticalIcon";const $a=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 1C21.5523 1 22 1.44772 22 2V22C22 22.5523 21.5523 23 21 23C20.4477 23 20 22.5523 20 22V2C20 1.44772 20.4477 1 21 1Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 7C2 5.34315 3.34315 4 5 4H14C15.6569 4 17 5.34315 17 7V17C17 18.6569 15.6569 20 14 20H5C3.34315 20 2 18.6569 2 17V7ZM5 6C4.44772 6 4 6.44772 4 7V17C4 17.5523 4.44772 18 5 18H14C14.5523 18 15 17.5523 15 17V7C15 6.44772 14.5523 6 14 6H5Z",fill:"currentColor"})]}));$a.displayName="AlignEndVerticalIcon";const qa=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M4 2C4 1.44772 3.55228 1 3 1C2.44772 1 2 1.44772 2 2V22C2 22.5523 2.44772 23 3 23C3.55228 23 4 22.5523 4 22V2Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 4C8.34315 4 7 5.34315 7 7V17C7 18.6569 8.34315 20 10 20H19C20.6569 20 22 18.6569 22 17V7C22 5.34315 20.6569 4 19 4H10ZM9 7C9 6.44772 9.44772 6 10 6H19C19.5523 6 20 6.44772 20 7V17C20 17.5523 19.5523 18 19 18H10C9.44772 18 9 17.5523 9 17V7Z",fill:"currentColor"})]}));qa.displayName="AlignStartVerticalIcon";const Tr={left:"alt+shift+l",center:"alt+shift+e",right:"alt+shift+r"},x5={left:qa,center:za,right:$a},k5={left:"Image align left",center:"Image align center",right:"Image align right"};function Ar(e,t,n="image",o="data-align"){return!e||!e.isEditable||!_(e,[n])?!1:e.can().updateAttributes(n,{[o]:t})}function S5(e,t,n="image",o="data-align"){return!e||!e.isEditable||!_(e,[n])?!1:(e.getAttributes(n)[o]||"left")===t}function T5(e,t,n="image",o="data-align"){if(!e?.isEditable||!_(e,[n])||!Ar(e,t,n,o))return!1;try{const{selection:r}=e.state,s=r instanceof E.NodeSelection,i=s?r.from:r.$anchor.pos,a=e.chain().focus().updateAttributes(n,{[o]:t}).run();return a&&s&&e.commands.setNodeSelection(i),a}catch{return!1}}function A5(e){const{editor:t,hideWhenUnavailable:n,align:o,extensionName:r="image",attributeName:s="data-align"}=e;return!t||!t.isEditable?!1:n?_(t,[r])?Ar(t,o,r,s):!1:!0}function I5(e){const{editor:t,align:n,extensionName:o="image",attributeName:r="data-align",hideWhenUnavailable:s=!1,onAligned:i}=e,{editor:a}=k(t),c=re(),[d,p]=u.useState(!0),f=Ar(a,n,o,r),h=S5(a,n,o,r);u.useEffect(()=>{if(!a)return;const g=()=>{p(A5({editor:a,align:n,hideWhenUnavailable:s,extensionName:o,attributeName:r}))};return g(),a.on("selectionUpdate",g),()=>{a.off("selectionUpdate",g)}},[a,s,n,o,r]);const C=u.useCallback(()=>{if(!a)return!1;const g=T5(a,n,o,r);return g&&i?.(),g},[a,n,o,r,i]);return ue.useHotkeys(Tr[n],g=>{g.preventDefault(),C()},{enabled:d&&f,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,isActive:h,handleImageAlign:C,canAlign:f,label:k5[n],shortcutKeys:Tr[n],Icon:x5[n]}}const Ga=At.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onSet:o,onClick:r,children:s,...i},a)=>{const{editor:c}=k(e),{isVisible:d,isActive:p,canToggle:f,handleSetCaption:h,label:C,Icon:g}=N5({editor:c,hideWhenUnavailable:n,onSet:o}),b=At.useCallback(m=>{r?.(m),!m.defaultPrevented&&h()},[h,r]);return d?l.jsx(M,{type:"button",variant:"ghost","data-active-state":p?"on":"off",role:"button",tabIndex:-1,disabled:!f,"data-disabled":!f,"aria-label":C,tooltip:C,onClick:b,...i,ref:a,children:s??l.jsxs(l.Fragment,{children:[l.jsx(g,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t})]})}):null});Ga.displayName="ImageCaptionButton";const Ka=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 22C7 21.4477 7.44772 21 8 21H16C16.5523 21 17 21.4477 17 22C17 22.5523 16.5523 23 16 23H8C7.44772 23 7 22.5523 7 22Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 18C3 17.4477 3.44772 17 4 17H20C20.5523 17 21 17.4477 21 18C21 18.5523 20.5523 19 20 19H4C3.44772 19 3 18.5523 3 18Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 5C3 3.34315 4.34315 2 6 2H18C19.6569 2 21 3.34315 21 5V11C21 12.6569 19.6569 14 18 14H6C4.34315 14 3 12.6569 3 11V5ZM6 4C5.44772 4 5 4.44772 5 5V11C5 11.5523 5.44772 12 6 12H18C18.5523 12 19 11.5523 19 11V5C19 4.44772 18.5523 4 18 4H6Z",fill:"currentColor"})]}));Ka.displayName="ImageCaptionIcon";function Ir(e){return!e||!e.isEditable||!_(e,["image"])?!1:ie(e,["image"])}function L5(e){if(!e)return!1;try{const{selection:t}=e.state;if(!(t instanceof E.NodeSelection&&t.node.type.name==="image"))return!1;const o=t.node;return o.attrs.showCaption===!0||o.content.size>0}catch{return!1}}function E5(e){if(!e?.isEditable||!Ir(e))return!1;try{const{selection:t}=e.state;if(!(t instanceof E.NodeSelection&&t.node.type.name==="image")||!e.chain().focus().updateAttributes("image",{showCaption:!0}).run())return!1;const r=t.from;return e.chain().focus(r+1).selectTextblockEnd().run(),!0}catch{return!1}}function M5(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!_(t,["image"])?!1:Ir(t):!0:!1}function N5(e){const{editor:t,hideWhenUnavailable:n=!1,onSet:o}=e||{},{editor:r}=k(t),[s,i]=u.useState(!0),[a,c]=u.useState(!1),d=Ir(r);u.useEffect(()=>{if(!r)return;const f=()=>{i(M5({editor:r,hideWhenUnavailable:n})),c(L5(r))};return f(),r.on("selectionUpdate",f),()=>{r.off("selectionUpdate",f)}},[r,n]);const p=u.useCallback(()=>{if(!r)return!1;const f=E5(r);return f&&o?.(),f},[r,o]);return{isVisible:s,isActive:a,canToggle:d,handleSetCaption:p,label:"Caption",Icon:Ka}}const Ya=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M4 3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3V8C2 8.55228 2.44772 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41416L5.96091 6.45325C7.58323 4.88786 9.74725 4.00897 12.0018 4.00001C14.1229 4.0005 16.1569 4.8433 17.6568 6.34315C19.1571 7.84344 19.9999 9.87827 19.9999 12C19.9999 12.5523 20.4477 13 20.9999 13C21.5522 13 21.9999 12.5523 21.9999 12C21.9999 9.34784 20.9464 6.8043 19.071 4.92894C17.1956 3.05358 14.6521 2.00001 11.9999 2L11.9962 2.00001C9.22207 2.01045 6.5594 3.0929 4.5649 5.02104L4.55283 5.0329L4 5.58573V3Z",fill:"currentColor"}),l.jsx("path",{d:"M3 11C3.55228 11 4 11.4477 4 12C4 14.1217 4.84285 16.1566 6.34315 17.6569C7.84297 19.1567 9.87701 19.9995 11.998 20C14.2526 19.9911 16.4167 19.1122 18.039 17.5468L18.5858 17H16C15.4477 17 15 16.5523 15 16C15 15.4477 15.4477 15 16 15H21C21.5523 15 22 15.4477 22 16V21C22 21.5523 21.5523 22 21 22C20.4477 22 20 21.5523 20 21V18.4142L19.4471 18.9671L19.435 18.979C17.4405 20.9071 14.7779 21.9896 12.0038 22L12 22C9.34784 22 6.8043 20.9464 4.92893 19.0711C3.05357 17.1957 2 14.6522 2 12C2 11.4477 2.44772 11 3 11Z",fill:"currentColor"})]}));Ya.displayName="RefreshCcwIcon";function ja({editor:e}){const{editor:t}=k(e),n=D(),o=ie(t,["image"]);return!t||!o?null:l.jsxs(l.Fragment,{children:[l.jsx(fn,{align:"left"}),l.jsx(fn,{align:"center"}),l.jsx(fn,{align:"right"}),l.jsx(ee,{}),l.jsx(Ga,{}),l.jsx(ee,{}),l.jsx(si,{}),l.jsx(gr,{icon:Ya,tooltip:n.replaceImage}),l.jsx(ee,{}),l.jsx(Ro,{})]})}const He={MAIN:"main",HIGHLIGHTER:"highlighter",LINK:"link"};function H5(e){const[t,n]=u.useState(He.MAIN);return u.useEffect(()=>{!e&&t!==He.MAIN&&n(He.MAIN)},[e,t]),{viewId:t,setViewId:n,isMainView:t===He.MAIN,showMainView:()=>n(He.MAIN),showView:o=>n(o)}}function V5(e){if(!e||!e.isEditable)return!1;const{selection:t}=e.state;return!t.empty}function B5(e){return{[He.HIGHLIGHTER]:{id:He.HIGHLIGHTER,title:e.textHighlighter,icon:l.jsx(Bt,{className:"tiptap-button-icon"}),content:l.jsx(da,{}),mobileButton:t=>l.jsx(Cr,{onClick:t}),desktopComponent:l.jsx(If,{}),shouldShow(t){return _e(t)}},[He.LINK]:{id:He.LINK,title:e.linkEditor,icon:l.jsx(xt,{className:"tiptap-button-icon"}),content:l.jsx(Vf,{}),mobileButton:t=>l.jsx(wr,{onClick:t}),desktopComponent:l.jsx(vr,{}),shouldShow(t){return yr(t)}}}}function D5(){return l.jsxs(l.Fragment,{children:[l.jsxs(ae,{children:[l.jsx(St,{action:"outdent",hideWhenUnavailable:!0}),l.jsx(St,{action:"indent",hideWhenUnavailable:!0})]}),l.jsx(Ce,{})]})}function U5(){return l.jsxs(l.Fragment,{children:[l.jsxs(ae,{children:[l.jsx(Ne,{align:"left",hideWhenUnavailable:!0}),l.jsx(Ne,{align:"center",hideWhenUnavailable:!0}),l.jsx(Ne,{align:"right",hideWhenUnavailable:!0}),l.jsx(Ne,{align:"justify",hideWhenUnavailable:!0})]}),l.jsx(Ce,{})]})}function O5(){return l.jsxs(l.Fragment,{children:[l.jsxs(ae,{children:[l.jsx(he,{type:"superscript",hideWhenUnavailable:!0}),l.jsx(he,{type:"subscript",hideWhenUnavailable:!0})]}),l.jsx(Ce,{})]})}function P5(){return l.jsxs(l.Fragment,{children:[l.jsxs(ae,{children:[l.jsx(he,{type:"bold",hideWhenUnavailable:!0}),l.jsx(he,{type:"italic",hideWhenUnavailable:!0}),l.jsx(he,{type:"strike",hideWhenUnavailable:!0}),l.jsx(he,{type:"code",hideWhenUnavailable:!0})]}),l.jsx(Ce,{})]})}function W5(){const e=D(),{recentColors:t,isInitialized:n,addRecentColor:o}=mt(),r=()=>!n||t.length===0?null:l.jsxs(l.Fragment,{children:[l.jsxs(qe,{children:[l.jsx(kt,{children:e.recentColors}),t.map(s=>l.jsx(pe,{asChild:!0,children:s.type==="text"?l.jsx(gt,{textColor:s.value,label:s.label,text:s.label,tooltip:s.label,onApplied:({color:i,label:a})=>o({type:"text",label:a,value:i})}):l.jsx(Re,{highlightColor:s.value,text:s.label,tooltip:s.label,onApplied:({color:i,label:a})=>o({type:"highlight",label:a,value:i})})},`${s.type}-${s.value}`))]}),l.jsx(ee,{orientation:"horizontal"})]});return l.jsxs(Na,{children:[l.jsx(Ha,{asChild:!0,children:l.jsxs(M,{variant:"ghost",children:[l.jsx(Jn,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:e.color}),l.jsx(Ct,{}),l.jsx(tt,{className:"tiptap-button-icon"})]})}),l.jsx(La,{children:l.jsxs(Va,{children:[r(),l.jsxs(qe,{children:[l.jsx(kt,{children:e.textColor}),Ht.map(s=>l.jsx(pe,{asChild:!0,children:l.jsx(gt,{textColor:s.value,label:s.label,text:s.label,tooltip:s.label,onApplied:({color:i,label:a})=>o({type:"text",label:a,value:i})})},s.value))]}),l.jsx(ee,{orientation:"horizontal"}),l.jsxs(qe,{children:[l.jsx(kt,{children:e.highlightColor}),et.map(s=>l.jsx(pe,{asChild:!0,children:l.jsx(Re,{highlightColor:s.value,text:s.label,tooltip:s.label,onApplied:({color:i,label:a})=>o({type:"highlight",label:a,value:i})})},s.value))]})]})})]})}function _5(){const e=D();return l.jsxs(Na,{children:[l.jsx(Ha,{asChild:!0,children:l.jsxs(M,{variant:"ghost",children:[l.jsx(fr,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:e.turnInto}),l.jsx(Ct,{}),l.jsx(tt,{className:"tiptap-button-icon"})]})}),l.jsx(La,{children:l.jsx(Va,{children:l.jsx(Ba,{})})})]})}function Z5({editor:e}){const t=re(),n=D();return l.jsxs(l.Fragment,{children:[l.jsxs(qe,{children:[l.jsx(kt,{children:ks(e,n)}),l.jsx(W5,{}),l.jsx(_5,{}),l.jsx(pe,{asChild:!0,children:l.jsx(Vi,{text:n.resetFormatting})})]}),l.jsx(ee,{orientation:"horizontal"}),l.jsxs(qe,{children:[l.jsx(pe,{asChild:!0,children:l.jsx(hi,{text:n.duplicateNode,showShortcut:!t})}),l.jsx(pe,{asChild:!0,children:l.jsx(mi,{text:n.copyToClipboard,showShortcut:!t})}),l.jsx(pe,{asChild:!0,children:l.jsx(Li,{text:n.copyAnchorLink,showShortcut:!t})})]}),l.jsx(qe,{children:l.jsx(pe,{asChild:!0,children:l.jsx(Ro,{text:n.delete,showShortcut:!t})})})]})}function F5({editor:e}){return l.jsxs(Ia,{children:[l.jsx(Ea,{asChild:!0,children:l.jsx(M,{variant:"ghost","data-appearance":"subdued",children:l.jsx(Mt,{className:"tiptap-button-icon"})})}),l.jsx(Ma,{children:l.jsx(Z5,{editor:e})})]})}function z5({view:e,isMobile:t,onViewChange:n}){const o=e.id;return t?e.mobileButton?u.cloneElement(e.mobileButton(()=>n(o)),{key:e.id}):l.jsx(M,{onClick:()=>n(o),children:e.icon},e.id):e.desktopComponent?u.cloneElement(e.desktopComponent,{key:e.id}):null}function $5({toolbarViews:e,isMobile:t,onViewChange:n,editor:o}){const r=Object.values(e).filter(s=>s.shouldShow?s.shouldShow(o):!0);return r.length===0?null:l.jsxs(l.Fragment,{children:[r.map(s=>l.jsx(z5,{view:s,isMobile:t,onViewChange:n},s.id)),l.jsx(Ce,{})]})}function q5({editor:e,isMobile:t,toolbarViews:n,onViewChange:o}){const r=D(),s=V5(e),i=(e?.getText().length??0)>0;return l.jsxs(l.Fragment,{children:[l.jsxs(ae,{children:[l.jsx(ar,{}),l.jsx(F5,{editor:e}),l.jsx(Ce,{})]}),(s||i)&&l.jsxs(l.Fragment,{children:[l.jsx(P5,{}),l.jsx($5,{toolbarViews:n,isMobile:t,onViewChange:o,editor:e}),l.jsx(ja,{}),l.jsx(O5,{}),l.jsx(U5,{}),l.jsx(D5,{}),l.jsxs(ae,{children:[l.jsx(gr,{text:r.add}),l.jsx(Ce,{})]})]}),l.jsxs(ae,{children:[l.jsx(Sr,{direction:"down"}),l.jsx(Sr,{direction:"up"})]})]})}function G5({view:e,onBack:t}){return l.jsxs(l.Fragment,{children:[l.jsx(ae,{children:l.jsxs(M,{variant:"ghost",onClick:t,children:[l.jsx(Dn,{className:"tiptap-button-icon"}),e.icon]})}),l.jsx(Ce,{}),e.content]})}function K5({editor:e}){const{editor:t}=k(e),n=D(),o=re("max",480),r=u.useRef(null),s=H5(o),i=u.useMemo(()=>B5(n),[n]),a=s.isMainView?null:i[s.viewId],{height:c}=aa(),d=v5({editor:t,overlayHeight:r.current?.getBoundingClientRect().height??0});return!o||!t||!t.isEditable?null:l.jsx(cn,{ref:r,style:{...o?{bottom:`calc(100% - ${c-d.y}px)`}:{}},children:s.isMainView?l.jsx(q5,{editor:t,isMobile:o,toolbarViews:i,onViewChange:s.showView}):a&&l.jsx(G5,{view:a,onBack:s.showMainView})})}function Y5(){const{editor:e}=k(),t=re("max",480),{lockDragHandle:n,commentInputVisible:o}=gn(e),{shouldShow:r}=Z1({editor:e,isSelectionValid:Ts,extraHideWhen:!!o});return n||t?null:l.jsx(Kt,{shouldShow:r,children:l.jsxs(cn,{variant:"floating",className:"omnibox-floating-toolbar",children:[l.jsx(ae,{children:l.jsx(Da,{hideWhenUnavailable:!0,className:"omnibox-floating-toolbar-turn-into"})}),l.jsx(Ce,{}),l.jsxs(ae,{children:[l.jsx(he,{type:"bold",hideWhenUnavailable:!0}),l.jsx(he,{type:"italic",hideWhenUnavailable:!0}),l.jsx(he,{type:"underline",hideWhenUnavailable:!0}),l.jsx(he,{type:"strike",hideWhenUnavailable:!0}),l.jsx(he,{type:"code",hideWhenUnavailable:!0})]}),l.jsx(Ce,{}),l.jsx(ae,{children:l.jsx(ja,{})}),l.jsxs(ae,{children:[l.jsx(vr,{autoOpenOnLinkActive:!1,hideWhenUnavailable:!0}),l.jsx(kd,{hideWhenUnavailable:!0})]}),l.jsx(J5,{hideWhenUnavailable:!0})]})})}function j5(e){if(!e)return!1;const t=["left","center","right","justify"].some(o=>sn(e,o));return["superscript","subscript"].some(o=>ln(e,o))||t}function X5(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n&&!t.isActive("code")?j5(t):!!t?.isEditable:!1}function J5({editor:e,hideWhenUnavailable:t=!1,...n}){const{editor:o}=k(e),r=D(),[s,i]=u.useState(!1);return u.useEffect(()=>{if(!o)return;const a=()=>{i(X5({editor:o,hideWhenUnavailable:t}))};return a(),o.on("selectionUpdate",a),()=>{o.off("selectionUpdate",a)}},[o,t]),!s||!o||!o.isEditable?null:l.jsxs(l.Fragment,{children:[l.jsx(Ce,{}),l.jsx(ae,{children:l.jsxs(Ot,{children:[l.jsx(Pt,{asChild:!0,children:l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":r.moreOptions,tooltip:r.moreOptions,...n,children:l.jsx(Mt,{className:"tiptap-button-icon"})})}),l.jsx(Wt,{side:"top",align:"end",alignOffset:4,sideOffset:4,asChild:!0,children:l.jsxs(cn,{variant:"floating",className:"omnibox-floating-toolbar",tabIndex:0,children:[l.jsxs(ae,{children:[l.jsx(he,{type:"superscript"}),l.jsx(he,{type:"subscript"})]}),l.jsx(Ce,{}),l.jsxs(ae,{children:[l.jsx(Ne,{align:"left"}),l.jsx(Ne,{align:"center"}),l.jsx(Ne,{align:"right"}),l.jsx(Ne,{align:"justify"})]}),l.jsx(Ce,{}),l.jsxs(ae,{children:[l.jsx(St,{action:"outdent"}),l.jsx(St,{action:"indent"})]})]})})]})})]})}function Q5({className:e,maxShowCount:t=20,topOffset:n=0,...o}){const{tocContent:r,navigateToHeading:s,normalizeHeadingDepths:i}=kn(),a=u.useRef(!1),c=u.useRef(null),[d,p]=u.useState(null),f=u.useMemo(()=>r??[],[r]),h=u.useMemo(()=>f.slice(0,t),[f,t]),C=u.useMemo(()=>i(h),[h,i]),g=u.useMemo(()=>{const L=new Map;return h.forEach((I,V)=>{L.set(I.id,C[V]??1)}),L},[h,C]),b=u.useMemo(()=>[...f].reverse().find(L=>L.isActive)??null,[f]),m=u.useMemo(()=>f.find(L=>L.isActive)?.id??null,[f]),w=u.useMemo(()=>d||(b?.id?b.id:m||f[0]?.id),[d,b,m,f]),v=u.useCallback((L,I)=>{L.preventDefault(),L.stopPropagation(),p(I.id),c.current=Date.now(),s(I,{topOffset:n})},[s,n]);u.useEffect(()=>{if(typeof window>"u"||a.current||!f.length)return;const L=window.location.hash.replace(/^#/,"");if(!L)return;const I=f.find(V=>V.id===L);I&&(p(I.id),a.current=!0)},[f]);const y=u.useRef(null),x=u.useRef(d);x.current=d,u.useEffect(()=>{if(typeof window>"u")return;const L=()=>{const V=Date.now(),K=c.current;K&&V-K<500||x.current!==null&&p(null)},I=y.current?Jr(y.current):null;return window.addEventListener("scroll",L,{passive:!0}),I&&!(I instanceof Window)&&I.addEventListener("scroll",L,{passive:!0}),()=>{window.removeEventListener("scroll",L),I&&!(I instanceof Window)&&I.removeEventListener("scroll",L)}},[]);const S=f.length>0;return l.jsx("div",{ref:y,className:$("toc-sidebar",e),...o,children:l.jsx("div",{className:"toc-sidebar-wrapper",children:l.jsxs("div",{className:"toc-sidebar-inner",children:[l.jsx("div",{className:"toc-sidebar-progress",children:h.map(L=>{const I=g.get(L.id)??1,V=w===L.id;return l.jsx("div",{className:$("toc-sidebar-progress-line",V&&"toc-sidebar-progress-line--active"),"data-depth":I,style:{"--toc-depth":I}},L.id)})}),l.jsx("nav",{className:$("toc-sidebar-nav",!S&&"toc-sidebar-nav--hidden"),"aria-label":"Table of contents",children:l.jsx("div",{className:"toc-sidebar-popover",children:h.map(L=>{const I=g.get(L.id)??1,V=w===L.id;return l.jsx("a",{href:`#${L.id}`,rel:"noopener noreferrer",className:$("toc-sidebar-item notranslate",V&&"toc-sidebar-item--active"),"data-depth":I,style:{"--toc-depth":I},onClick:K=>v(K,L),"aria-current":V?"location":void 0,children:L.textContent},L.id)})})})]})})})}const R5=we.Extension.create({name:"listNormalization",addKeyboardShortcuts(){const e=["bulletList","orderedList","taskList"];return{Backspace:({editor:n})=>{const{state:o,view:r}=n,{selection:s}=o,{$from:i,empty:a}=s;if(!a||i.parentOffset!==0)return!1;const c=i.parent;if(c.type.name!=="paragraph"||c.content.size>0)return!1;const d=i.depth-1;if(d<0)return!1;const p=i.node(d),f=i.index(d);if(f===0||f>=p.childCount-1)return!1;const h=p.child(f-1),C=p.child(f+1),g=e.includes(h.type.name),b=e.includes(C.type.name);if(!g||!b||h.type.name!==C.type.name)return!1;const m=i.before(d+1),w=i.after(d+1),v=o.doc.resolve(m-1),y=E.TextSelection.findFrom(v,-1,!0);if(!y)return!1;const x=y.from,S=o.tr;S.delete(m,w),Or.canJoin(S.doc,m)&&S.join(m);const L=S.mapping.map(x);return S.setSelection(E.TextSelection.create(S.doc,L)),r.dispatch(S),!0}}}});function e0(e,t,n,o){const r=e.getAttribute("data-indent");if(r){const i=parseInt(r,10);if(!isNaN(i))return yn(i,t,n)}const s=["marginLeft","paddingLeft","textIndent"];for(const i of s){const a=e.style?.[i];if(a){const c=parseFloat(a);if(!isNaN(c)&&c>0&&o>0){const d=Math.round(c/o);return yn(d,t,n)}}}return 0}function pn(e,t){const{$from:n}=e.selection;for(let o=n.depth;o>0;o--){const r=n.node(o).type.name;if(t.has(r))return r}return null}function Xa(e,t,n,o){const{selection:r}=e,{$from:s}=r;if(!r.empty||pn(e,n)!==null)return!1;const i=s.parent;return!t.includes(i.type.name)||i.attrs.indent<=0?!1:o.onlyIfEmpty?i.content.size===0:s.parentOffset===0}const t0=new E.PluginKey("indent"),n0=we.Extension.create({name:"indent",addOptions(){return{types:["paragraph","heading","blockquote"],listItemTypes:["listItem","taskItem"],bypassAncestors:["tableCell","tableHeader"],minLevel:0,maxLevel:8,useStyle:!1,indentUnit:24}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:e=>e0(e,this.options.minLevel,this.options.maxLevel,this.options.indentUnit),renderHTML:e=>{const t=Number(e.indent)||0;if(t===0)return{};const n={"data-indent":String(t),style:`--tt-indent-level: ${t}`};return this.options.useStyle&&this.options.indentUnit>0&&(n.style=`--tt-indent-level: ${t}; margin-left: ${t*this.options.indentUnit}px`),n}}}}]},addCommands(){const e=new Set(this.options.listItemTypes),t=({state:n,tr:o},r)=>{const s=it(n.selection,this.options.types);return s.length===0?!1:vn(o,s,"indent",i=>yn(r(Number(i)||0),this.options.minLevel,this.options.maxLevel))};return{indent:()=>n=>{const o=pn(n.state,e);return o&&"sinkListItem"in n.commands?n.commands.sinkListItem(o):t(n,r=>r+1)},outdent:()=>n=>{const o=pn(n.state,e);return o&&"liftListItem"in n.commands?n.commands.liftListItem(o):t(n,r=>r-1)},setIndent:n=>o=>t(o,()=>n),unsetIndent:()=>n=>t(n,()=>0)}},addProseMirrorPlugins(){const e=this.options.types;return[new E.Plugin({key:t0,appendTransaction(t,n,o){if(!t.some(w=>w.getMeta("uiEvent")==="drop"))return null;const{doc:s,selection:i}=o,{$from:a,$to:c}=i,d=a.depth>0?a.depth:1,p=a.before(d),f=s.resolve(p),h=f.node(f.depth),C=f.index(f.depth);let g=0;if(C>0)g=h.child(C-1).attrs.indent||0;else{const w=c.depth>0?c.depth:1,v=c.after(w),y=s.resolve(v),x=y.indexAfter(y.depth),S=y.node(y.depth);x<S.childCount&&(g=S.child(x).attrs.indent||0)}const{tr:b}=o;let m=!1;return s.nodesBetween(a.pos,c.pos,(w,v)=>(!e.includes(w.type.name)||(w.attrs.indent||0)===g||(b.setNodeMarkup(v,void 0,{...w.attrs,indent:g},w.marks),m=!0),!1)),m?b:null}})]},addKeyboardShortcuts(){const e=new Set(this.options.listItemTypes),t=new Set(this.options.bypassAncestors),n=r=>{if(t.size===0)return!1;const{$from:s}=r.selection;for(let i=s.depth;i>0;i--)if(t.has(s.node(i).type.name))return!0;return!1},o=()=>{const r=this.editor.state;if(n(r))return!1;if(pn(r,e)!==null)return!0;const{$from:s}=r.selection;return this.options.types.includes(s.parent.type.name)};return{Tab:()=>o()?(this.editor.commands.indent(),!0):!1,"Shift-Tab":()=>o()?(this.editor.commands.outdent(),!0):!1,Enter:({editor:r})=>Xa(r.state,this.options.types,e,{onlyIfEmpty:!0})?r.commands.outdent():!1,Backspace:({editor:r})=>Xa(r.state,this.options.types,e,{onlyIfEmpty:!1})?r.commands.outdent():!1}}}),o0=we.Extension.create({name:"tripleClickBlockSelection",addProseMirrorPlugins(){return[new E.Plugin({key:new E.PluginKey("tripleClickBlockSelection"),props:{handleTripleClick:(e,t)=>{const{state:n}=e,{doc:o}=n,r=o.resolve(t);let s=r.depth;for(;s>0&&!r.node(s).isTextblock;)s--;if(s===0||r.node(s).type.spec.selectable===!1)return!1;const a=r.before(s);return e.dispatch(n.tr.setSelection(E.NodeSelection.create(o,a))),!0}}})]}}),r0={type:"doc",content:[{type:"heading",attrs:{id:"11111111-1111-4111-8111-111111111111",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"11111111-1111-4111-8111-111111111111",level:1},content:[{type:"text",text:"Local Omnibox editor"}]},{type:"blockquote",attrs:{id:"22222222-2222-4222-8222-222222222222",backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"paragraph",attrs:{id:"33333333-3333-4333-8333-333333333333",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",marks:[{type:"bold"}],text:"A clean base for your own editor package."},{type:"hardBreak"},{type:"text",text:"It keeps the writing, formatting, slash menu, table, and block editing pieces ready for your package work."}]}]},{type:"paragraph",attrs:{id:"44444444-4444-4444-8444-444444444444",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Type "},{type:"text",marks:[{type:"code"}],text:"/"},{type:"text",text:" to open the command menu, select text for the floating toolbar, or drag blocks from the left handle."}]},{type:"heading",attrs:{id:"55555555-5555-4555-8555-555555555555",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"55555555-5555-4555-8555-555555555555",level:2},content:[{type:"text",text:"Writing basics"}]},{type:"codeBlock",attrs:{id:"66666666-6666-4666-8666-666666666666",language:null},content:[{type:"text",text:`# Headings
|
|
12
|
+
`):Xo(e):Zo.serialize(e)}function Xo(e){return e.type==="table"&&js(e)?S7(e,Xo):Zo.serialize(qo(e)).trim()}function l4(e){return yt(e).content??[]}function si(e){return Array.isArray(e)?Qt(e):e.type==="doc"?Qt(e.content??[]):ii(e)}function Qt(e){return e.flatMap(ii)}function ii(e){return e.type==="blockquote"?Qt(e.content??[]):e.content?.length?[{...e,content:Qt(e.content)}]:[e]}function s4({shortcutKeys:e=Jo}){return l.jsx(R,{children:J({shortcutKeys:e})})}const ai=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDownloaded:o,resolveFileUrl:r,downloadMethod:s,showShortcut:i=!1,onClick:a,children:c,...d},f)=>{const{editor:p}=k(e),{isVisible:h,canDownload:C,handleDownload:g,label:b,shortcutKeys:m,Icon:w}=hi({editor:p,hideWhenUnavailable:n,onDownloaded:o,resolveFileUrl:r,downloadMethod:s}),v=u.useCallback(async y=>{a?.(y),!y.defaultPrevented&&await g()},[g,a]);return h?l.jsx(M,{type:"button",variant:"ghost","data-active-state":"off",role:"button",tabIndex:-1,disabled:!C,"data-disabled":!C,"aria-label":b,tooltip:b,onClick:v,...d,ref:f,children:c??l.jsxs(l.Fragment,{children:[l.jsx(w,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),i&&l.jsx(s4,{shortcutKeys:m})]})}):null});ai.displayName="ImageDownloadButton";const ci=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M12 2C12.5523 2 13 2.44772 13 3V14.5858L17.2929 10.2929C17.6834 9.90237 18.3166 9.90237 18.7071 10.2929C19.0976 10.6834 19.0976 11.3166 18.7071 11.7071L12.7071 17.7071C12.3166 18.0976 11.6834 18.0976 11.2929 17.7071L5.29289 11.7071C4.90237 11.3166 4.90237 10.6834 5.29289 10.2929C5.68342 9.90237 6.31658 9.90237 6.70711 10.2929L11 14.5858V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor"}),l.jsx("path",{d:"M5 20C4.44772 20 4 20.4477 4 21C4 21.5523 4.44772 22 5 22H19C19.5523 22 20 21.5523 20 21C20 20.4477 19.5523 20 19 20H5Z",fill:"currentColor"})]}));ci.displayName="ArrowDownToLineIcon";const Jo="mod+shift+d";function di(e,t){const n=e.match(/\.([a-zA-Z0-9]+)(?:\?|#|$)/);return n&&n[1]?`.${n[1].toLowerCase()}`:t&&{"image/jpeg":".jpg","image/jpg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/svg+xml":".svg","image/bmp":".bmp"}[t.toLowerCase()]||".jpg"}function Rt(e){return!e||!e.isEditable||!_(e,["image"])?!1:ie(e,["image"])}function ui(e){if(!e||!Rt(e))return null;const{selection:t}=e.state;if(t instanceof E.NodeSelection){const n=t.node;if(n.type.name==="image")return{src:n.attrs.src,alt:n.attrs.alt,title:n.attrs.title}}return null}async function fi(e,t){try{const n=await fetch(e);if(!n.ok)return!1;const o=await n.blob(),r=URL.createObjectURL(o),i=/\.[a-zA-Z0-9]+$/.test(t)?t:t+di(e,n.headers.get("content-type")||void 0),a=document.createElement("a");return a.href=r,a.download=i,a.style.display="none",document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(r),0),!0}catch(n){return console.warn("Fetch download failed:",n),!1}}function pi(e,t){try{const o=/\.[a-zA-Z0-9]+$/.test(t)?t:t+di(e),r=document.createElement("a");return r.href=e,r.download=o,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),!0}catch(n){return console.warn("Direct download failed:",n),!1}}function en(e){try{return window.open(e,"_blank"),!0}catch(t){return console.error("Failed to open image:",t),!1}}async function i4(e,t,n,o="auto"){if(!e||!Rt(e))return!1;const r=ui(e);if(!r?.src)return!1;try{let s=r.src;n&&(s=await n(r.src));const i=window.location.href,a=vn(s,i);if(a==="#")return console.error("Invalid or unsafe URL after sanitization"),!1;const c=t||r.alt||r.title||`image-${Date.now()}`;switch(o){case"open":return en(a);case"download":return a.startsWith(window.location.origin)||a.startsWith("data:")?pi(a,c):await fi(a,c)||en(a);default:return a.startsWith("data:")||a.startsWith(window.location.origin)?pi(a,c):await fi(a,c)?!0:en(a)}}catch(s){console.error("Failed to download image:",s);try{const i=window.location.href,a=vn(r.src,i);if(a!=="#")return en(a)}catch{}return!1}}function a4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!_(t,["image","imageUpload"])?!1:Rt(t):!0:!1}function hi(e){const{editor:t,hideWhenUnavailable:n=!1,onDownloaded:o,resolveFileUrl:r,downloadMethod:s="auto"}=e||{},{editor:i}=k(t),a=re(),[c,d]=u.useState(!0),f=Rt(i);u.useEffect(()=>{if(!i)return;const h=()=>{d(a4({editor:i,hideWhenUnavailable:n}))};return h(),i.on("selectionUpdate",h),()=>{i.off("selectionUpdate",h)}},[i,n]);const p=u.useCallback(async()=>{if(!i)return!1;const h=ui(i),C=h?.alt||h?.title,g=await i4(i,C,r,s);return g&&o?.(C),g},[i,o,r,s]);return ue.useHotkeys(Jo,h=>{h.preventDefault(),p()},{enabled:c&&f,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:c,canDownload:f,handleDownload:p,label:"Download image",shortcutKeys:Jo,Icon:ci}}function Ci({shortcutKeys:e=Qo}){return l.jsx(R,{children:J({shortcutKeys:e})})}const gi=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDuplicated:o,showShortcut:r=!1,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:f,handleDuplicate:p,label:h,shortcutKeys:C,Icon:g}=mi({editor:d,hideWhenUnavailable:n,onDuplicated:o}),b=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&p()},[p,s]);return f?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":h,tooltip:h,onClick:b,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(g,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(Ci,{shortcutKeys:C})]})}):null});gi.displayName="DuplicateButton";const Qo="mod+d";function bi(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t;if(n instanceof E.NodeSelection)return!!n.node;const o=n.$anchor;for(let r=1;r<=o.depth;r++){const s=o.node(r);if(!(s.type.name==="doc"||!s.type.spec.group))return!0}return!1}catch{return!1}}function c4(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t,o=e.chain().focus();if(n instanceof E.NodeSelection){const s=n.node,i=n.to;return o.insertContentAt(i,s.toJSON()).run(),!0}const r=n.$anchor;for(let s=1;s<=r.depth;s++){const i=r.node(s);if(i.type.name==="doc"||!i.type.spec.group)continue;const a=r.start(s),c=Math.min(a+i.nodeSize,t.doc.content.size);return o.insertContentAt(c,i.toJSON()).run(),!0}return!1}catch{return!1}}function d4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:bi(t):!1:!0:!1}function mi(e){const{editor:t,hideWhenUnavailable:n=!1,onDuplicated:o}=e||{},{editor:r}=k(t),s=D(),i=re(),[a,c]=u.useState(!0),d=bi(r);u.useEffect(()=>{if(!r)return;const p=()=>{c(d4({editor:r,hideWhenUnavailable:n}))};return p(),r.on("selectionUpdate",p),()=>{r.off("selectionUpdate",p)}},[r,n]);const f=u.useCallback(()=>{if(!r)return!1;const p=c4(r);return p&&o?.(),p},[r,o]);return ue.useHotkeys(Qo,p=>{p.preventDefault(),f()},{enabled:a&&d,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:a,handleDuplicate:f,canDuplicate:d,label:s.duplicateNode,shortcutKeys:Qo,Icon:Bn}}function wi({shortcutKeys:e=Ro}){return l.jsx(R,{children:J({shortcutKeys:e})})}const vi=u.forwardRef(({editor:e,text:t,copyWithFormatting:n=!0,hideWhenUnavailable:o=!1,onCopied:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:f}=k(e),{isVisible:p,handleCopyToClipboard:h,label:C,shortcutKeys:g,Icon:b}=Si({editor:f,copyWithFormatting:n,hideWhenUnavailable:o,onCopied:r}),m=u.useCallback(async w=>{i?.(w),!w.defaultPrevented&&await h()},[h,i]);return p?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":C,tooltip:C,onClick:m,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(b,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),s&&l.jsx(wi,{shortcutKeys:g})]})}):null});vi.displayName="CopyToClipboardButton";function u4(e){return Jt(e,{debug:!1})}function f4(e){return{type:"doc",content:e.content.toJSON()}}function yi(e){return u4(f4(e))}const xi=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M15 1C16.1046 1 17 1.89543 17 3H18C18.7956 3 19.5585 3.3163 20.1211 3.87891C20.6837 4.44151 21 5.20435 21 6V20C21 20.7957 20.6837 21.5585 20.1211 22.1211C19.5585 22.6837 18.7957 23 18 23H6C5.20435 23 4.44151 22.6837 3.87891 22.1211C3.3163 21.5585 3 20.7957 3 20V6C3 5.20435 3.3163 4.44152 3.87891 3.87891C4.44152 3.3163 5.20435 3 6 3H7C7 1.89543 7.89543 1 9 1H15ZM6 5C5.73478 5 5.4805 5.10543 5.29297 5.29297C5.10543 5.4805 5 5.73478 5 6V20L5.00488 20.0986C5.02757 20.3276 5.12883 20.5429 5.29297 20.707C5.48051 20.8946 5.73478 21 6 21H18C18.2652 21 18.5195 20.8946 18.707 20.707C18.8946 20.5195 19 20.2652 19 20V6C19 5.73478 18.8946 5.48051 18.707 5.29297C18.5429 5.12883 18.3276 5.02757 18.0986 5.00488L18 5H17C17 6.10457 16.1046 7 15 7H9C7.89543 7 7 6.10457 7 5H6ZM9 5H15V3H9V5Z",fill:"currentColor"})}));xi.displayName="ClipboardIcon";const Ro="mod+c";async function p4(e,t){try{if(t&&navigator.clipboard&&"write"in navigator.clipboard){const n=new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([e],{type:"text/plain"})});await navigator.clipboard.write([n])}else await navigator.clipboard.writeText(e)}catch{await navigator.clipboard.writeText(e)}}function h4(e){const{selection:t}=e,{empty:n}=t;return!n}function ki(e){if(!e)return!1;const t=e.state.tr;return h4(t)}function C4(e,t=!0){const{selection:n}=e.state,{$anchor:o}=n;let r=n.content();if(n.empty||n instanceof E.TextSelection){const a=o.node(1);r=new _r.Slice(_r.Fragment.from(a),0,0)}const s=yi(r),i=t?e.view.serializeForClipboard(r).dom.innerHTML:void 0;return{textContent:s,htmlContent:i}}async function g4(e,t=!0){if(!e)return!1;try{const{textContent:n,htmlContent:o}=C4(e,t);return await p4(n,o),!0}catch{return!1}}function b4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isActive("code")?!0:ki(t):!0:!1}function Si(e){const{editor:t,copyWithFormatting:n=!0,hideWhenUnavailable:o=!1,onCopied:r}=e||{},{editor:s}=k(t),i=D(),a=re(),[c,d]=u.useState(!0),f=ki(s);u.useEffect(()=>{if(!s)return;const h=()=>{d(b4({editor:s,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o]);const p=u.useCallback(async()=>{if(!s)return!1;const h=await g4(s,n);return h&&r?.(),h},[s,n,r]);return ue.useHotkeys(Ro,h=>{h.preventDefault(),p()},{enabled:c&&f,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:c,handleCopyToClipboard:p,canCopyToClipboard:f,label:i.copyToClipboard,shortcutKeys:Ro,Icon:xi}}function Ti({shortcutKeys:e=tr}){return l.jsx(R,{children:J({shortcutKeys:e})})}const er=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onDeleted:o,showShortcut:r=!1,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:f,handleDeleteNode:p,label:h,shortcutKeys:C,Icon:g}=Li({editor:d,hideWhenUnavailable:n,onDeleted:o}),b=u.useCallback(m=>{s?.(m),!m.defaultPrevented&&p()},[p,s]);return f?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":h,tooltip:h,onClick:b,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(g,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(Ti,{shortcutKeys:C})]})}):null});er.displayName="DeleteNodeButton";const tr="backspace";function Ai(e){if(!e||!e.isEditable)return!1;const{state:t}=e,{selection:n}=t;if(n instanceof E.NodeSelection)return!0;const o=n.$anchor;for(let r=o.depth;r>0;r--){const s=o.node(r),i=o.before(r);if(t.tr.delete(i,i+s.nodeSize).doc!==t.doc)return!0}return!1}function Ii(e,t,n){const o=e.chain().focus();return o.deleteRange({from:t,to:t+n}).run()?!0:o.setNodeSelection(t).deleteSelection().run()}function m4(e){if(!e||!e.isEditable)return!1;try{const{state:t}=e,{selection:n}=t;if(n instanceof E.NodeSelection){const r=n.from,s=n.node;return s?Ii(e,r,s.nodeSize):!1}const o=n.$from;for(let r=o.depth;r>0;r--){const s=n.$from.node(r),i=n.$from.before(r);if(s&&s.isBlock&&s.type.name!=="tableRow"&&s.type.name!=="tableHeader"&&s.type.name!=="tableCell")return Ii(e,i,s.nodeSize)}return!1}catch{return!1}}function w4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?t.isEditable?t.isActive("code")?!0:Ai(t):!1:!0:!1}function Li(e){const{editor:t,hideWhenUnavailable:n=!1,onDeleted:o}=e||{},{editor:r}=k(t),s=D(),i=re(),[a,c]=u.useState(!0),d=Ai(r);u.useEffect(()=>{if(!r)return;const p=()=>{c(w4({editor:r,hideWhenUnavailable:n}))};return p(),r.on("selectionUpdate",p),()=>{r.off("selectionUpdate",p)}},[r,n]);const f=u.useCallback(()=>{if(!r)return!1;const p=m4(r);return p&&o?.(),p},[r,o]);return ue.useHotkeys(tr,p=>{p.preventDefault(),f()},{enabled:a&&d,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:a,handleDeleteNode:f,canDeleteNode:d,label:s.delete,shortcutKeys:tr,Icon:ht}}function Ei({shortcutKeys:e=nr}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Mi=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onNodeIdNotFound:o,onExtractedNodeId:r,onCopied:s,showShortcut:i=!1,onClick:a,children:c,...d},f)=>{const{editor:p}=k(e),{isVisible:h,handleCopyAnchorLink:C,label:g,shortcutKeys:b,Icon:m}=Bi({editor:p,hideWhenUnavailable:n,onNodeIdNotFound:o,onExtractedNodeId:r,onCopied:s}),w=u.useCallback(v=>{a?.(v),!v.defaultPrevented&&C()},[C,a]);return h?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":g,tooltip:g,onClick:w,...d,ref:f,children:c??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),i&&l.jsx(Ei,{shortcutKeys:b})]})}):null});Mi.displayName="CopyAnchorLinkButton";const xt=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",fill:"currentColor"}),l.jsx("path",{d:"M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",fill:"currentColor"})]}));xt.displayName="LinkIcon";const nr="mod+ctrl+l";function Ni(e){return!!(e&&e.isEditable)}function v4(e){return zr(e,"uniqueID")?.options?.attributeName||"data-id"}function Hi(e){if(!Ni(e))return null;const t=ct(e);if(!t)return null;const n=v4(e),o=y4(t.node,n);return{node:t.node,nodeId:o,hasNodeId:o!==null}}function y4(e,t){if(!e?.attrs?.[t])return null;try{return e.attrs[t]}catch{return null}}function Vi(e){return Hi(e)?.hasNodeId??!1}async function x4(e,t,n){const o=Hi(e);if(!o)return!1;const{nodeId:r,hasNodeId:s}=o;if(t?.(r),n?.(!s),!s||!r)return!1;try{const i=new URL(window.location.href);return i.searchParams.set("source","copy_link"),i.hash=r,await navigator.clipboard.writeText(i.toString()),!0}catch(i){return console.error("Failed to copy node ID to clipboard:",i),!1}}function k4(e){const{editor:t,hideWhenUnavailable:n}=e;if(!Ni(t))return!1;const o=!!ct(t);return n?Vi(t):o}function Bi(e){const{editor:t,hideWhenUnavailable:n=!1,onNodeIdNotFound:o,onExtractedNodeId:r,onCopied:s}=e||{},{editor:i}=k(t),a=D(),c=re(),[d,f]=u.useState(!0),p=Vi(i);u.useEffect(()=>{if(!i)return;const C=()=>{f(k4({editor:i,hideWhenUnavailable:n}))};return C(),i.on("selectionUpdate",C),()=>{i.off("selectionUpdate",C)}},[i,n]);const h=u.useCallback(async()=>{const C=await x4(i,r,o);return C&&s?.(),C},[i,r,o,s]);return ue.useHotkeys(nr,C=>{C.preventDefault(),h()},{enabled:d&&p,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,handleCopyAnchorLink:h,canCopyAnchorLink:p,label:a.copyAnchorLink,shortcutKeys:nr,Icon:xt}}function S4({shortcutKeys:e=or}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Di=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,preserveMarks:o=Oi,onResetAllFormatting:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:f}=k(e),{isVisible:p,canReset:h,handleResetFormatting:C,label:g,shortcutKeys:b,Icon:m}=Wi({editor:f,preserveMarks:o,hideWhenUnavailable:n,onResetAllFormatting:r}),w=u.useCallback(v=>{i?.(v),!v.defaultPrevented&&C()},[C,i]);return p?l.jsx(M,{type:"button",variant:"ghost",disabled:!h,"data-disabled":!h,"data-active-state":"off",role:"button",tabIndex:-1,"aria-label":g,tooltip:g,onClick:w,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),s&&l.jsx(S4,{shortcutKeys:b})]})}):null});Di.displayName="ResetAllFormattingButton";const Ui=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M12 2L11.9962 2.00001C9.22213 2.01045 6.55946 3.0929 4.56496 5.02104L4.55289 5.0329L4 5.58579V3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3V8C2 8.55228 2.44772 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41422L5.96097 6.45325C7.58329 4.88786 9.7473 4.00897 12.0019 4.00001C13.5835 4.00038 15.1295 4.46955 16.4446 5.34825C17.7602 6.2273 18.7855 7.47673 19.391 8.93854C19.9965 10.4003 20.155 12.0089 19.8463 13.5607C19.5376 15.1126 18.7757 16.538 17.6569 17.6569C16.538 18.7757 15.1126 19.5376 13.5607 19.8463C12.0089 20.155 10.4003 19.9965 8.93853 19.391C7.47672 18.7855 6.22729 17.7602 5.34824 16.4446C4.46919 15.129 4 13.5823 4 12C4 11.4477 3.55228 11 3 11C2.44772 11 2 11.4477 2 12C2 13.9778 2.58649 15.9112 3.6853 17.5557C4.78412 19.2002 6.3459 20.4819 8.17317 21.2388C10.0004 21.9957 12.0111 22.1937 13.9509 21.8079C15.8907 21.422 17.6725 20.4696 19.0711 19.0711C20.4696 17.6726 21.422 15.8907 21.8079 13.9509C22.1937 12.0111 21.9957 10.0004 21.2388 8.17317C20.4819 6.34591 19.2002 4.78412 17.5557 3.68531C15.9112 2.5865 13.9778 2.00001 12 2Z",fill:"currentColor"})}));Ui.displayName="RotateCcwIcon";const or="mod+r",Oi=["inlineThread"];function T4(e,t=[]){const{selection:n}=e,{empty:o,ranges:r}=n;return o||r.forEach(s=>{const i=s.$from.pos,a=s.$to.pos;e.doc.nodesBetween(i,a,(c,d)=>(c.isInline&&c.marks.forEach(f=>{t.includes(f.type.name)||e.removeMark(d,d+c.nodeSize,f.type)}),!0))}),e}function A4(e,t=[]){const{selection:n}=e,{empty:o,ranges:r}=n;if(o)return!1;for(const s of r){const i=s.$from.pos,a=s.$to.pos;let c=!1;if(e.doc.nodesBetween(i,a,d=>{if(!d.isInline)return!0;for(const f of d.marks)if(!t.includes(f.type.name))return c=!0,!1;return!0}),c)return!0}return!1}function Pi(e,t){if(!e||!e.isEditable)return!1;const n=e.state.tr;return A4(n,t)}function I4(e,t){if(!e||!e.isEditable)return!1;try{const{view:n,state:o}=e,{tr:r}=o,s=T4(r,t);return n.dispatch(s),e.commands.focus(),!0}catch{return!1}}function L4(e){const{editor:t,hideWhenUnavailable:n,preserveMarks:o}=e;return!t||!t.isEditable?!1:n&&!t.isActive("code")?Pi(t,o):!0}function Wi(e){const{editor:t,preserveMarks:n=Oi,hideWhenUnavailable:o=!1,onResetAllFormatting:r}=e||{},{editor:s}=k(t),i=D(),a=re(),[c,d]=u.useState(!0),f=Pi(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{d(L4({editor:s,hideWhenUnavailable:o,preserveMarks:n}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o,n]);const p=u.useCallback(()=>{if(!s)return!1;const h=I4(s,n);return h&&r?.(),h},[s,r,n]);return ue.useHotkeys(or,h=>{h.preventDefault(),p()},{enabled:c&&f,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:c,handleResetFormatting:p,canReset:f,label:i.resetFormatting,shortcutKeys:or,Icon:Ui}}function E4({shortcutKeys:e=rr}){return l.jsx(R,{children:J({shortcutKeys:e})})}const _i=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:r=!1,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:f,canToggle:p,isActive:h,handleToggle:C,label:g,shortcutKeys:b,Icon:m}=Zi({editor:d,hideWhenUnavailable:n,onToggled:o}),w=u.useCallback(v=>{s?.(v),!v.defaultPrevented&&C()},[C,s]);return f?l.jsx(M,{type:"button",variant:"ghost","data-active-state":h?"on":"off",role:"button",tabIndex:-1,disabled:!p,"data-disabled":!p,"aria-label":g,"aria-pressed":h,tooltip:g,onClick:w,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(E4,{shortcutKeys:b})]})}):null});_i.displayName="TextButton";const rr="mod+alt+0";function lr(e,t=!0){return!e||!e.schema.nodes.paragraph?!1:t?xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().setNode("paragraph")||e.can().clearNodes():!1:e.can().setNode("paragraph")}function M4(e){return e?e.isActive("paragraph"):!1}function N4(e){if(!e||!e.isEditable||!lr(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const r=at(e),s=xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&r.length===1;if((n.selection.empty||n.selection instanceof E.TextSelection)&&s){const c=me({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!X(c))return!1;o=o.setSelection(E.NodeSelection.create(n.doc,c)),t.dispatch(o),n=t.state}const i=n.selection;let a=e.chain().focus();if(i instanceof E.NodeSelection){const c=i.node.firstChild?.firstChild,d=i.node.lastChild?.lastChild,f=c?i.from+c.nodeSize:i.from+1,p=d?i.to-d.nodeSize:i.to-1,h=n.doc.resolve(f),C=n.doc.resolve(p);a=a.setTextSelection(E.TextSelection.between(h,C)).clearNodes()}return e.isActive("paragraph")||a.setNode("paragraph").run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function H4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!te("paragraph",t)?!1:t.isActive("code")?!0:lr(t):!0:!1}function Zi(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:r}=k(t),s=D(),i=re(),[a,c]=u.useState(!0),d=lr(r),f=M4(r);u.useEffect(()=>{if(!r)return;const h=()=>{c(H4({editor:r,hideWhenUnavailable:n}))};return h(),r.on("selectionUpdate",h),()=>{r.off("selectionUpdate",h)}},[r,n]);const p=u.useCallback(()=>{if(!r)return!1;const h=N4(r);return h&&o?.(),h},[r,o]);return ue.useHotkeys(rr,h=>{h.preventDefault(),p()},{enabled:a&&d,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:a,isActive:f,handleToggle:p,canToggle:d,label:s.text,shortcutKeys:rr,Icon:Mo}}function V4({level:e,shortcutKeys:t=Gi[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const Fi=u.forwardRef(({editor:e,level:t,text:n,hideWhenUnavailable:o=!1,onToggled:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:f}=k(e),{isVisible:p,canToggle:h,isActive:C,handleToggle:g,label:b,Icon:m,shortcutKeys:w}=nn({editor:f,level:t,hideWhenUnavailable:o,onToggled:r}),v=u.useCallback(y=>{i?.(y),!y.defaultPrevented&&g()},[g,i]);return p?l.jsx(M,{type:"button",variant:"ghost","data-active-state":C?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":b,"aria-pressed":C,tooltip:b,onClick:v,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(V4,{level:t,shortcutKeys:w})]})}):null});Fi.displayName="HeadingButton";const zi=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),l.jsx("path",{d:"M17 9C17.5523 9 18 9.44772 18 10V13H20V10C20 9.44772 20.4477 9 21 9C21.5523 9 22 9.44772 22 10V18C22 18.5523 21.5523 19 21 19C20.4477 19 20 18.5523 20 18V15H17C16.4477 15 16 14.5523 16 14V10C16 9.44772 16.4477 9 17 9Z",fill:"currentColor"})]}));zi.displayName="HeadingFourIcon";const $i=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),l.jsx("path",{d:"M16 10C16 9.44772 16.4477 9 17 9H21C21.5523 9 22 9.44772 22 10C22 10.5523 21.5523 11 21 11H18V12H18.3C20.2754 12 22 13.4739 22 15.5C22 17.5261 20.2754 19 18.3 19C17.6457 19 17.0925 18.8643 16.5528 18.5944C16.0588 18.3474 15.8586 17.7468 16.1055 17.2528C16.3525 16.7588 16.9532 16.5586 17.4472 16.8056C17.7074 16.9357 17.9542 17 18.3 17C19.3246 17 20 16.2739 20 15.5C20 14.7261 19.3246 14 18.3 14H17C16.4477 14 16 13.5523 16 13L16 12.9928V10Z",fill:"currentColor"})]}));$i.displayName="HeadingFiveIcon";const qi=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 9.29289C21.0976 9.68342 21.0976 10.3166 20.7071 10.7071C19.8392 11.575 19.2179 12.2949 18.7889 13.0073C18.8587 13.0025 18.929 13 19 13C20.6569 13 22 14.3431 22 16C22 17.6569 20.6569 19 19 19C17.3431 19 16 17.6569 16 16C16 14.6007 16.2837 13.4368 16.8676 12.3419C17.4384 11.2717 18.2728 10.3129 19.2929 9.29289C19.6834 8.90237 20.3166 8.90237 20.7071 9.29289ZM19 17C18.4477 17 18 16.5523 18 16C18 15.4477 18.4477 15 19 15C19.5523 15 20 15.4477 20 16C20 16.5523 19.5523 17 19 17Z",fill:"currentColor"})]}));qi.displayName="HeadingSixIcon";const B4={1:ko,2:So,3:To,4:zi,5:$i,6:qi},Gi={1:"ctrl+alt+1",2:"ctrl+alt+2",3:"ctrl+alt+3",4:"ctrl+alt+4",5:"ctrl+alt+5",6:"ctrl+alt+6"};function D4(e,t){return{1:t.heading1,2:t.heading2,3:t.heading3,4:t.heading4,5:t.heading5,6:t.heading6}[e]}function tn(e,t,n=!0){return!e||!e.isEditable||!te("heading",e)||ie(e,["image"])?!1:n?xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?t?e.can().setNode("heading",{level:t})||e.can().clearNodes():e.can().setNode("heading")||e.can().clearNodes():!1:t?e.can().setNode("heading",{level:t}):e.can().setNode("heading")}function U4(e,t){return!e||!e.isEditable?!1:Array.isArray(t)?t.some(n=>e.isActive("heading",{level:n})):t?e.isActive("heading",{level:t}):e.isActive("heading")}function O4(e,t){if(!e||!e.isEditable)return!1;const n=Array.isArray(t)?t:[t],o=n.find(r=>tn(e,r));if(!o)return!1;try{const r=e.view;let s=r.state,i=s.tr;const a=at(e),c=xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&a.length===1;if((s.selection.empty||s.selection instanceof E.TextSelection)&&c){const C=me({editor:e,node:s.selection.$anchor.node(1)})?.pos;if(!X(C))return!1;i=i.setSelection(E.NodeSelection.create(s.doc,C)),r.dispatch(i),s=r.state}const d=s.selection;let f=e.chain().focus();if(d instanceof E.NodeSelection){const C=d.node.firstChild?.firstChild,g=d.node.lastChild?.lastChild,b=C?d.from+C.nodeSize:d.from+1,m=g?d.to-g.nodeSize:d.to-1,w=s.doc.resolve(b),v=s.doc.resolve(m);f=f.setTextSelection(E.TextSelection.between(w,v)).clearNodes()}return(n.some(C=>e.isActive("heading",{level:C}))?f.setNode("paragraph"):f.setNode("heading",{level:o})).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function P4(e){const{editor:t,level:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!te("heading",t)?!1:t.isActive("code")?!0:Array.isArray(n)?n.some(r=>tn(t,r)):tn(t,n):!0:!1}function nn(e){const{editor:t,level:n,hideWhenUnavailable:o=!1,onToggled:r}=e,{editor:s}=k(t),i=D(),[a,c]=u.useState(!0),d=tn(s,n),f=U4(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{c(P4({editor:s,level:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const p=u.useCallback(()=>{if(!s)return!1;const h=O4(s,n);return h&&r?.(),h},[s,n,r]);return{isVisible:a,isActive:f,handleToggle:p,canToggle:d,label:D4(n,i),shortcutKeys:Gi[n],Icon:B4[n]}}function W4({type:e,shortcutKeys:t=Ki[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const on=u.forwardRef(({editor:e,type:t,text:n,hideWhenUnavailable:o=!1,onToggled:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:f}=k(e),{isVisible:p,canToggle:h,isActive:C,handleToggle:g,label:b,shortcutKeys:m,Icon:w}=rn({editor:f,type:t,hideWhenUnavailable:o,onToggled:r}),v=u.useCallback(y=>{i?.(y),!y.defaultPrevented&&g()},[g,i]);return p?l.jsx(M,{type:"button",variant:"ghost","data-active-state":C?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":b,"aria-pressed":C,tooltip:b,onClick:v,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(w,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(W4,{type:t,shortcutKeys:m})]})}):null});on.displayName="ListButton";const _4={bulletList:Ao,orderedList:Io,taskList:Eo};function Z4(e){return{bulletList:e.bulletList,orderedList:e.orderedList,taskList:e.taskList}}const Ki={bulletList:"mod+shift+8",orderedList:"mod+shift+7",taskList:"mod+shift+9"};function sr(e,t,n=!0){if(!e||!e.isEditable||!te(t,e)||ie(e,["image"]))return!1;if(!n)switch(t){case"bulletList":return e.can().toggleBulletList();case"orderedList":return e.can().toggleOrderedList();case"taskList":return e.can().toggleList("taskList","taskItem");default:return!1}if(!xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"]))return!1;switch(t){case"bulletList":return e.can().toggleBulletList()||e.can().clearNodes();case"orderedList":return e.can().toggleOrderedList()||e.can().clearNodes();case"taskList":return e.can().toggleList("taskList","taskItem")||e.can().clearNodes();default:return!1}}function F4(e,t){if(!e||!e.isEditable)return!1;switch(t){case"bulletList":return e.isActive("bulletList");case"orderedList":return e.isActive("orderedList");case"taskList":return e.isActive("taskList");default:return!1}}function z4(e,t){if(!e||!e.isEditable||!sr(e,t))return!1;try{const n=e.view;let o=n.state,r=o.tr;const s=at(e),i=xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&s.length===1;if((o.selection.empty||o.selection instanceof E.TextSelection)&&i){const d=me({editor:e,node:o.selection.$anchor.node(1)})?.pos;if(!X(d))return!1;r=r.setSelection(E.NodeSelection.create(o.doc,d)),n.dispatch(r),o=n.state}const a=o.selection;let c=e.chain().focus();if(a instanceof E.NodeSelection){const d=a.node.firstChild?.firstChild,f=a.node.lastChild?.lastChild,p=d?a.from+d.nodeSize:a.from+1,h=f?a.to-f.nodeSize:a.to-1,C=o.doc.resolve(p),g=o.doc.resolve(h);c=c.setTextSelection(E.TextSelection.between(C,g)).clearNodes()}if(e.isActive(t))c.liftListItem("listItem").lift("bulletList").lift("orderedList").lift("taskList").run();else{const f={bulletList:()=>c.toggleBulletList(),orderedList:()=>c.toggleOrderedList(),taskList:()=>c.toggleList("taskList","taskItem")}[t];if(!f)return!1;f().run()}return e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function $4(e){const{editor:t,type:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!te(n,t)?!1:t.isActive("code")?!0:sr(t,n):!0:!1}function rn(e){const{editor:t,type:n,hideWhenUnavailable:o=!1,onToggled:r}=e,{editor:s}=k(t),i=D(),[a,c]=u.useState(!0),d=sr(s,n),f=F4(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{c($4({editor:s,type:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const p=u.useCallback(()=>{if(!s)return!1;const h=z4(s,n);return h&&r?.(),h},[s,n,r]);return{isVisible:a,isActive:f,handleToggle:p,canToggle:d,label:Z4(i)[n],shortcutKeys:Ki[n],Icon:_4[n]}}function q4({shortcutKeys:e=ji}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Yi=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:r=!1,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:f,canToggle:p,isActive:h,handleToggle:C,label:g,shortcutKeys:b,Icon:m}=Xi({editor:d,hideWhenUnavailable:n,onToggled:o}),w=u.useCallback(v=>{s?.(v),!v.defaultPrevented&&C()},[C,s]);return f?l.jsx(M,{type:"button",variant:"ghost","data-active-state":h?"on":"off",role:"button",tabIndex:-1,disabled:!p,"data-disabled":!p,"aria-label":g,"aria-pressed":h,tooltip:g,onClick:w,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(q4,{shortcutKeys:b})]})}):null});Yi.displayName="BlockquoteButton";const ji="mod+shift+b";function ir(e,t=!0){return!e||!e.isEditable||!te("blockquote",e)||ie(e,["image"])?!1:t?xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().toggleWrap("blockquote")||e.can().clearNodes():!1:e.can().toggleWrap("blockquote")}function G4(e){if(!e||!e.isEditable||!ir(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const r=at(e),s=xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&r.length===1;if((n.selection.empty||n.selection instanceof E.TextSelection)&&s){const d=me({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!X(d))return!1;o=o.setSelection(E.NodeSelection.create(n.doc,d)),t.dispatch(o),n=t.state}const i=n.selection;let a=e.chain().focus();if(i instanceof E.NodeSelection){const d=i.node.firstChild?.firstChild,f=i.node.lastChild?.lastChild,p=d?i.from+d.nodeSize:i.from+1,h=f?i.to-f.nodeSize:i.to-1,C=n.doc.resolve(p),g=n.doc.resolve(h);a=a.setTextSelection(E.TextSelection.between(C,g)).clearNodes()}return(e.isActive("blockquote")?a.lift("blockquote"):a.wrapIn("blockquote")).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function K4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!te("blockquote",t)?!1:t.isActive("code")?!0:ir(t):!0:!1}function Xi(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:r}=k(t),s=D(),[i,a]=u.useState(!0),c=ir(r),d=r?.isActive("blockquote")||!1;u.useEffect(()=>{if(!r)return;const p=()=>{a(K4({editor:r,hideWhenUnavailable:n}))};return p(),r.on("selectionUpdate",p),()=>{r.off("selectionUpdate",p)}},[r,n]);const f=u.useCallback(()=>{if(!r)return!1;const p=G4(r);return p&&o?.(),p},[r,o]);return{isVisible:i,isActive:d,handleToggle:f,canToggle:c,label:s.blockquote,shortcutKeys:ji,Icon:Lo}}function Y4({shortcutKeys:e=Qi}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Ji=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggled:o,showShortcut:r=!1,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),{isVisible:f,canToggle:p,isActive:h,handleToggle:C,label:g,shortcutKeys:b,Icon:m}=Ri({editor:d,hideWhenUnavailable:n,onToggled:o}),w=u.useCallback(v=>{s?.(v),!v.defaultPrevented&&C()},[C,s]);return f?l.jsx(M,{type:"button",variant:"ghost","data-active-state":h?"on":"off",role:"button",disabled:!p,"data-disabled":!p,tabIndex:-1,"aria-label":g,"aria-pressed":h,tooltip:g,onClick:w,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(Y4,{shortcutKeys:b})]})}):null});Ji.displayName="CodeBlockButton";const Qi="mod+alt+c";function ar(e,t=!0){return!e||!e.isEditable||!te("codeBlock",e)||ie(e,["image"])?!1:t?xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])?e.can().toggleNode("codeBlock","paragraph")||e.can().clearNodes():!1:e.can().toggleNode("codeBlock","paragraph")}function j4(e){if(!e||!e.isEditable||!ar(e))return!1;try{const t=e.view;let n=t.state,o=n.tr;const r=at(e),s=xe(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&r.length===1;if((n.selection.empty||n.selection instanceof E.TextSelection)&&s){const d=me({editor:e,node:n.selection.$anchor.node(1)})?.pos;if(!X(d))return!1;o=o.setSelection(E.NodeSelection.create(n.doc,d)),t.dispatch(o),n=t.state}const i=n.selection;let a=e.chain().focus();if(i instanceof E.NodeSelection){const d=i.node.firstChild?.firstChild,f=i.node.lastChild?.lastChild,p=d?i.from+d.nodeSize:i.from+1,h=f?i.to-f.nodeSize:i.to-1,C=n.doc.resolve(p),g=n.doc.resolve(h);a=a.setTextSelection(E.TextSelection.between(C,g)).clearNodes()}return(e.isActive("codeBlock")?a.setNode("paragraph"):a.toggleNode("codeBlock","paragraph")).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function X4(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!te("codeBlock",t)?!1:t.isActive("code")?!0:ar(t):!0:!1}function Ri(e){const{editor:t,hideWhenUnavailable:n=!1,onToggled:o}=e||{},{editor:r}=k(t),s=D(),[i,a]=u.useState(!0),c=ar(r),d=r?.isActive("codeBlock")||!1;u.useEffect(()=>{if(!r)return;const p=()=>{a(X4({editor:r,hideWhenUnavailable:n}))};return p(),r.on("selectionUpdate",p),()=>{r.off("selectionUpdate",p)}},[r,n]);const f=u.useCallback(()=>{if(!r)return!1;const p=j4(r);return p&&o?.(),p},[r,o]);return{isVisible:i,isActive:d,handleToggle:f,canToggle:c,label:s.codeBlock,shortcutKeys:Qi,Icon:xo}}function J4({shortcutKeys:e=dr}){return l.jsx(R,{children:J({shortcutKeys:e})})}const cr=u.forwardRef(({editor:e,node:t,nodePos:n,text:o,trigger:r="/",hideWhenUnavailable:s=!1,onTriggered:i,showShortcut:a=!1,onClick:c,children:d,...f},p)=>{const{editor:h}=k(e),{isVisible:C,canInsert:g,handleSlashCommand:b,label:m,shortcutKeys:w,Icon:v}=ef({editor:h,node:t,nodePos:n,trigger:r,hideWhenUnavailable:s,onTriggered:i}),y=u.useCallback(x=>{c?.(x),!x.defaultPrevented&&b()},[b,c]);return C?l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,disabled:!g,"data-disabled":!g,"aria-label":m,tooltip:m,onClick:y,...f,ref:p,children:d??l.jsxs(l.Fragment,{children:[l.jsx(v,{className:"tiptap-button-icon"}),o&&l.jsx("span",{className:"tiptap-button-text",children:o}),a&&l.jsx(J4,{shortcutKeys:w})]})}):null});cr.displayName="SlashCommandTriggerButton";const ea=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z",fill:"currentColor"})}));ea.displayName="PlusIcon";const dr="mod+/";function ur(e,t,n){if(!e||!e.isEditable||ie(e,["image"]))return!1;if(t||X(n)){if(X(n)&&n>=0)return!0;if(t)return me({editor:e,node:t})!==null}return!0}function Q4(e,t="/",n,o){if(!e||!e.isEditable||!ur(e,n,o))return!1;try{if(n!=null||X(o)){const d=me({editor:e,node:n||void 0,nodePos:o||void 0});if(!d)return!1;const f=d.node.type.name==="paragraph"&&d.node.content.size===0,p=f?d.pos:d.pos+d.node.nodeSize;e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,p,p));const h=t.length+1,C=f?d.pos+h:d.pos+d.node.nodeSize+h;return e.commands.focus(C),!0}const{$from:r}=e.state.selection,i=r.node().textContent.length===0,a=r.parentOffset===0,c=r.depth===0;if(!i||!a){const d=c?e.state.doc.content.size:r.after();return e.chain().insertContentAt(d,{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}return e.chain().insertContent({type:"text",text:t}).focus().run()}catch{return!1}}function R4(e){const{editor:t,hideWhenUnavailable:n,node:o,nodePos:r}=e;return t?n?t.isEditable?t.isActive("code")?!0:ur(t,o,r):!1:!0:!1}function ef(e){const{editor:t,node:n,nodePos:o,trigger:r="/",hideWhenUnavailable:s=!1,onTriggered:i}=e||{},{editor:a}=k(t),c=re(),[d,f]=u.useState(!0),p=ur(a,n,o);u.useEffect(()=>{if(!a)return;const C=()=>{f(R4({editor:a,hideWhenUnavailable:s,node:n,nodePos:o}))};return C(),a.on("selectionUpdate",C),()=>{a.off("selectionUpdate",C)}},[a,s,n,o]);const h=u.useCallback(()=>{if(!a)return!1;const C=Q4(a,r,n,o);return C&&i?.(r),C},[a,r,n,o,i]);return ue.useHotkeys(dr,C=>{C.preventDefault(),h()},{enabled:d&&p,enableOnContentEditable:!c,enableOnFormTags:!0},[d,p,h]),{isVisible:d,handleSlashCommand:h,canInsert:p,label:"Insert block",shortcutKeys:dr,trigger:r,Icon:ea}}function fr(e){return!e||!e.isEditable||!_(e,["tocNode"])?!1:ie(e,["tocNode"])}function tf(e){if(!e)return!1;try{const{selection:t}=e.state;return t instanceof E.NodeSelection&&t.node.type.name==="tocNode"?t.node.attrs.showTitle===!0:!1}catch{return!1}}function nf(e){if(!e?.isEditable||!fr(e))return!1;try{const{selection:t}=e.state;if(!(t instanceof E.NodeSelection&&t.node.type.name==="tocNode"))return!1;const r=t.node.attrs.showTitle===!0;return e.chain().focus().updateAttributes("tocNode",{showTitle:!r}).run()}catch{return!1}}function of(e){const{editor:t,hideWhenUnavailable:n}=e;return!t||!t.isEditable||!_(t,["tocNode"])?!1:n?fr(t):!0}function ta(e){const{editor:t,hideWhenUnavailable:n=!1,onToggle:o}=e||{},{editor:r}=k(t),[s,i]=u.useState(!0),[a,c]=u.useState(!1),d=fr(r);u.useEffect(()=>{if(!r)return;const p=()=>{i(of({editor:r,hideWhenUnavailable:n})),c(tf(r))};return p(),r.on("selectionUpdate",p),()=>{r.off("selectionUpdate",p)}},[r,n]);const f=u.useCallback(()=>{if(!r)return!1;const p=nf(r);return p&&o?.(),p},[r,o]);return{isVisible:s,isActive:a,canToggle:d,handleToggle:f,label:"Show title",Icon:Vo}}const rf=At.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onToggle:o,onClick:r,children:s,...i},a)=>{const{editor:c}=k(e),{isVisible:d,isActive:f,canToggle:p,handleToggle:h,label:C,Icon:g}=ta({editor:c,hideWhenUnavailable:n,onToggle:o}),b=At.useCallback(m=>{r?.(m),!m.defaultPrevented&&h()},[h,r]);return d?l.jsx(M,{type:"button",variant:"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!p,"data-disabled":!p,"aria-label":C,tooltip:C,onClick:b,...i,ref:a,children:s??l.jsxs(l.Fragment,{children:[l.jsx(g,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t})]})}):null});rf.displayName="TocShowTitleButton";const na=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z",fill:"currentColor"}),l.jsx("path",{d:"M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z",fill:"currentColor"}),l.jsx("path",{d:"M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z",fill:"currentColor"}),l.jsx("path",{d:"M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z",fill:"currentColor"}),l.jsx("path",{d:"M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z",fill:"currentColor"}),l.jsx("path",{d:"M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z",fill:"currentColor"})]}));na.displayName="GripVerticalIcon";const pr=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.70711 5.29289C5.31658 4.90237 4.68342 4.90237 4.29289 5.29289L1.29289 8.29289C0.902369 8.68342 0.902369 9.31658 1.29289 9.70711C1.68342 10.0976 2.31658 10.0976 2.70711 9.70711L4 8.41421V16C4 16.7956 4.31607 17.5587 4.87868 18.1213C5.44129 18.6839 6.20435 19 7 19H13C13.5523 19 14 18.5523 14 18C14 17.4477 13.5523 17 13 17H7C6.73478 17 6.48043 16.8946 6.29289 16.7071C6.10536 16.5196 6 16.2652 6 16V8.41421L7.29289 9.70711C7.68342 10.0976 8.31658 10.0976 8.70711 9.70711C9.09763 9.31658 9.09763 8.68342 8.70711 8.29289L5.70711 5.29289ZM15.2929 14.2929C15.6834 13.9024 16.3166 13.9024 16.7071 14.2929L18 15.5858V8C18 7.73478 17.8946 7.48043 17.7071 7.29289C17.5196 7.10536 17.2652 7 17 7H11C10.4477 7 10 6.55228 10 6C10 5.44772 10.4477 5 11 5H17C17.7957 5 18.5587 5.31607 19.1213 5.87868C19.6839 6.44129 20 7.20435 20 8V15.5858L21.2929 14.2929C21.6834 13.9024 22.3166 13.9024 22.7071 14.2929C23.0976 14.6834 23.0976 15.3166 22.7071 15.7071L19.7071 18.7071C19.3166 19.0976 18.6834 19.0976 18.2929 18.7071L15.2929 15.7071C14.9024 15.3166 14.9024 14.6834 15.2929 14.2929Z",fill:"currentColor"})}));pr.displayName="Repeat2Icon";const lf=()=>{const e=Zi(),t=nn({level:1}),n=nn({level:2}),o=nn({level:3}),r=rn({type:"bulletList"}),s=rn({type:"orderedList"}),i=rn({type:"taskList"}),a=Xi(),c=Ri(),d=h=>({icon:h.Icon,label:h.label,onClick:h.handleToggle,disabled:!h.canToggle,isActive:h.isActive}),f=[d(e),...[t,n,o].map(d),d(r),d(s),d(i),d(a),d(c)];return f.every(h=>h.disabled)?null:f},Se=({icon:e,label:t,onClick:n,disabled:o=!1,isActive:r=!1,shortcutBadge:s})=>l.jsxs(Ee,{render:l.jsx(M,{variant:"ghost","data-active-state":r?"on":"off"}),onClick:n,disabled:o,children:[l.jsx(e,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:t}),s]}),sf=({icon:e,label:t,children:n})=>l.jsx(je,{placement:"right",trigger:l.jsx(Ee,{render:l.jsx(Je,{render:l.jsxs(M,{variant:"ghost",children:[l.jsx(e,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:t}),l.jsx(Ct,{}),l.jsx(tt,{className:"tiptap-button-icon"})]})})}),children:l.jsx(Xe,{portal:!0,children:l.jsx(Ye,{children:n})})}),af=()=>{const e=D(),t=lf(),{canReset:n,handleResetFormatting:o,label:r,Icon:s}=Wi({hideWhenUnavailable:!0,preserveMarks:["inlineThread"]});return!t&&!n?null:l.jsxs(l.Fragment,{children:[t&&l.jsx(sf,{icon:pr,label:e.turnInto,children:l.jsxs(de,{children:[l.jsx(ft,{children:e.turnInto}),t.map(i=>l.jsx(Se,{...i},i.label))]})}),n&&l.jsx(Se,{icon:s,label:r,disabled:!n,onClick:o})]})},cf=()=>{const e=D(),{canFitToWidth:t,handleFitToWidth:n,label:o,Icon:r}=Co({hideWhenUnavailable:!0}),s=Qe({resetAttrs:!0});return l.jsxs(l.Fragment,{children:[t&&l.jsx(Se,{icon:r,label:o,disabled:!t,onClick:n}),s.canClearRowColumnContent&&l.jsx(Se,{icon:s.Icon,label:e.clearAllContents,disabled:!s.canClearRowColumnContent,onClick:s.handleClear})]})},df=()=>{const{canToggle:e,handleToggle:t,label:n,Icon:o}=ta({hideWhenUnavailable:!0});return e?l.jsx(Se,{icon:o,label:n,disabled:!e,onClick:t}):null},uf=()=>{const{canDownload:e,handleDownload:t,label:n,Icon:o}=hi({hideWhenUnavailable:!0});return e?l.jsx(Se,{icon:o,label:n,disabled:!e,onClick:t}):null},ff=()=>{const{handleDuplicate:e,canDuplicate:t,label:n,Icon:o}=mi(),{handleCopyToClipboard:r,canCopyToClipboard:s,label:i,Icon:a}=Si(),{handleCopyAnchorLink:c,canCopyAnchorLink:d,label:f,Icon:p}=Bi();return l.jsxs(l.Fragment,{children:[l.jsx(ee,{orientation:"horizontal"}),l.jsxs(de,{children:[l.jsx(Se,{icon:o,label:n,onClick:e,disabled:!t,shortcutBadge:l.jsx(Ci,{})}),l.jsx(Se,{icon:a,label:i,onClick:r,disabled:!s,shortcutBadge:l.jsx(wi,{})}),l.jsx(Se,{icon:p,label:f,onClick:c,disabled:!d,shortcutBadge:l.jsx(Ei,{})})]}),l.jsx(ee,{orientation:"horizontal"})]})},pf=()=>{const{handleDeleteNode:e,canDeleteNode:t,label:n,Icon:o}=Li();return l.jsx(de,{children:l.jsx(Se,{icon:o,label:n,onClick:e,disabled:!t,shortcutBadge:l.jsx(Ti,{})})})},hf=({editor:e,withSlashCommandTrigger:t=!0,mobileBreakpoint:n=768,...o})=>{const{editor:r}=k(e),s=D(),{isDragging:i}=bn(r),a=re("max",n),[c,d]=u.useState(!1),[f,p]=u.useState(null),[h,C]=u.useState(-1),g=u.useCallback(S=>{S.node&&p(S.node),C(S.pos)},[]);u.useEffect(()=>{r&&(r.commands.setLockDragHandle(c),r.commands.setMeta("lockDragHandle",c))},[r,c]);const b=16,m=u.useMemo(()=>({middleware:[F.offset(S=>{const{rects:L}=S,I=L.reference.height,V=L.floating.height,K=I/2-V/2;return{mainAxis:b,crossAxis:I>40?0:K}})]}),[]),w=u.useCallback(()=>{r&&r.commands.setMeta("hideDragHandle",!0)},[r]),v=u.useCallback(S=>{S.stopPropagation(),r&&r.commands.setIsDragging(!0)},[r]),y=u.useCallback(S=>{S.stopPropagation(),r&&(r.commands.setIsDragging(!1),setTimeout(()=>{r.view.dom.blur(),r.view.focus()},0))},[r]);if(!r)return null;const x=Ts(r,s);return l.jsx("div",{style:{"--drag-handle-main-axis-offset":`${b}px`},children:l.jsx(L1.DragHandle,{editor:r,onNodeChange:g,computePositionConfig:m,onElementDragStart:v,onElementDragEnd:y,...o,children:l.jsxs("div",{style:{display:"flex",flexDirection:"row",...a||Mu(r)?{opacity:0,pointerEvents:"none"}:{},...i?{opacity:0}:{}},children:[t&&l.jsx(cr,{node:f,nodePos:h,"data-weight":"small"}),l.jsx(je,{open:c,onOpenChange:d,placement:"left",trigger:l.jsx(Je,{render:l.jsx(M,{variant:"ghost",tabIndex:-1,tooltip:l.jsxs(l.Fragment,{children:[l.jsx("div",{children:s.clickForOptions}),l.jsx("div",{children:s.holdForDrag})]}),"data-weight":"small",style:{cursor:"grab",...c?{pointerEvents:"none"}:{}},onMouseDown:()=>kn(r,h),children:l.jsx(na,{className:"tiptap-button-icon"})})}),children:l.jsxs(Xe,{onClose:w,autoFocusOnHide:!1,preventBodyScroll:!0,portal:!0,children:[l.jsx(Vn,{style:wn}),l.jsxs(Ye,{style:{minWidth:"15rem"},children:[l.jsx(ft,{children:x}),l.jsxs(de,{children:[l.jsx(df,{}),l.jsx(Rn,{}),l.jsx(ao,{}),l.jsx(cf,{}),l.jsx(af,{}),l.jsx(uf,{})]}),l.jsx(ff,{}),l.jsx(pf,{})]})]})})]})})})},oa=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M12 1C12.5523 1 13 1.44772 13 2V4C13 4.55228 12.5523 5 12 5C11.4477 5 11 4.55228 11 4V2C11 1.44772 11.4477 1 12 1Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 9.23858 9.23858 7 12 7C14.7614 7 17 9.23858 17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12ZM12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9Z",fill:"currentColor"}),l.jsx("path",{d:"M13 20C13 19.4477 12.5523 19 12 19C11.4477 19 11 19.4477 11 20V22C11 22.5523 11.4477 23 12 23C12.5523 23 13 22.5523 13 22V20Z",fill:"currentColor"}),l.jsx("path",{d:"M4.22282 4.22289C4.61335 3.83236 5.24651 3.83236 5.63704 4.22289L7.04704 5.63289C7.43756 6.02341 7.43756 6.65658 7.04704 7.0471C6.65651 7.43762 6.02335 7.43762 5.63283 7.0471L4.22282 5.6371C3.8323 5.24658 3.8323 4.61341 4.22282 4.22289Z",fill:"currentColor"}),l.jsx("path",{d:"M18.367 16.9529C17.9765 16.5623 17.3433 16.5623 16.9528 16.9529C16.5623 17.3434 16.5623 17.9766 16.9528 18.3671L18.3628 19.7771C18.7533 20.1676 19.3865 20.1676 19.777 19.7771C20.1675 19.3866 20.1675 18.7534 19.777 18.3629L18.367 16.9529Z",fill:"currentColor"}),l.jsx("path",{d:"M1 12C1 11.4477 1.44772 11 2 11H4C4.55228 11 5 11.4477 5 12C5 12.5523 4.55228 13 4 13H2C1.44772 13 1 12.5523 1 12Z",fill:"currentColor"}),l.jsx("path",{d:"M20 11C19.4477 11 19 11.4477 19 12C19 12.5523 19.4477 13 20 13H22C22.5523 13 23 12.5523 23 12C23 11.4477 22.5523 11 22 11H20Z",fill:"currentColor"}),l.jsx("path",{d:"M7.04704 16.9529C7.43756 17.3434 7.43756 17.9766 7.04704 18.3671L5.63704 19.7771C5.24651 20.1676 4.61335 20.1676 4.22282 19.7771C3.8323 19.3866 3.8323 18.7534 4.22283 18.3629L5.63283 16.9529C6.02335 16.5623 6.65651 16.5623 7.04704 16.9529Z",fill:"currentColor"}),l.jsx("path",{d:"M19.777 5.6371C20.1675 5.24657 20.1675 4.61341 19.777 4.22289C19.3865 3.83236 18.7533 3.83236 18.3628 4.22289L16.9528 5.63289C16.5623 6.02341 16.5623 6.65658 16.9528 7.0471C17.3433 7.43762 17.9765 7.43762 18.367 7.0471L19.777 5.6371Z",fill:"currentColor"})]}));oa.displayName="SunIcon";const ra=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C10.0222 2 8.08879 2.58649 6.4443 3.6853C4.79981 4.78412 3.51809 6.3459 2.76121 8.17317C2.00433 10.0004 1.8063 12.0111 2.19215 13.9509C2.578 15.8907 3.53041 17.6725 4.92894 19.0711C6.32746 20.4696 8.10929 21.422 10.0491 21.8079C11.9889 22.1937 13.9996 21.9957 15.8268 21.2388C17.6541 20.4819 19.2159 19.2002 20.3147 17.5557C21.4135 15.9112 22 13.9778 22 12C22 11.5955 21.7564 11.2309 21.3827 11.0761C21.009 10.9213 20.5789 11.0069 20.2929 11.2929C19.287 12.2988 17.9226 12.864 16.5 12.864C15.0774 12.864 13.713 12.2988 12.7071 11.2929C11.7012 10.287 11.136 8.92261 11.136 7.5C11.136 6.07739 11.7012 4.71304 12.7071 3.70711C12.9931 3.42111 13.0787 2.99099 12.9239 2.61732C12.7691 2.24364 12.4045 2 12 2ZM7.55544 5.34824C8.27036 4.87055 9.05353 4.51389 9.87357 4.28778C9.39271 5.27979 9.13604 6.37666 9.13604 7.5C9.13604 9.45304 9.91189 11.3261 11.2929 12.7071C12.6739 14.0881 14.547 14.864 16.5 14.864C17.6233 14.864 18.7202 14.6073 19.7122 14.1264C19.4861 14.9465 19.1295 15.7296 18.6518 16.4446C17.7727 17.7602 16.5233 18.7855 15.0615 19.391C13.5997 19.9965 11.9911 20.155 10.4393 19.8463C8.88743 19.5376 7.46197 18.7757 6.34315 17.6569C5.22433 16.538 4.4624 15.1126 4.15372 13.5607C3.84504 12.0089 4.00347 10.4003 4.60897 8.93853C5.21447 7.47672 6.23985 6.22729 7.55544 5.34824Z",fill:"currentColor"}),l.jsx("path",{d:"M19 2C19.5523 2 20 2.44772 20 3V4H21C21.5523 4 22 4.44772 22 5C22 5.55228 21.5523 6 21 6H20V7C20 7.55228 19.5523 8 19 8C18.4477 8 18 7.55228 18 7V6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H18V3C18 2.44772 18.4477 2 19 2Z",fill:"currentColor"})]}));ra.displayName="MoonStarIcon";function Cf(){const{editor:e}=u.useContext(G.EditorContext),[t,n]=u.useState(!1);u.useEffect(()=>{const r=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>n(r.matches);return r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[]),u.useEffect(()=>{const r=!!document.querySelector('meta[name="color-scheme"][content="dark"]')||window.matchMedia("(prefers-color-scheme: dark)").matches;n(r)},[]),u.useEffect(()=>{e?.view.dom.closest(".omnibox-editor-root")?.classList.toggle("dark",t)},[e,t]);const o=()=>n(r=>!r);return l.jsx(M,{onClick:o,"aria-label":`Switch to ${t?"light":"dark"} mode`,variant:"ghost",children:t?l.jsx(ra,{className:"tiptap-button-icon"}):l.jsx(oa,{className:"tiptap-button-icon"})})}const la=u.createContext({user:{color:"",id:"",name:"",avatar:""},mentionUsers:[],onlineUsers:[],setOnlineUsers:()=>{}});function gf(e,t){return e.length!==t.length?!1:e.every((n,o)=>{const r=t[o];return r&&n.id===r.id&&n.name===r.name&&n.color===r.color&&n.avatar===r.avatar&&n.position===r.position})}function bf({children:e,mentionUsers:t,user:n}){const[o]=u.useState(()=>qu()),[r,s]=u.useState([]),i=u.useMemo(()=>Vs(n)??o,[o,n]),a=u.useMemo(()=>Gu(t),[t]),c=u.useCallback(f=>{const p=vo(f);s(h=>gf(h,p)?h:p)},[]),d=u.useMemo(()=>({user:i,onlineUsers:r,setOnlineUsers:c,mentionUsers:vo([...r,...a])}),[a,r,c,i]);return l.jsx(la.Provider,{value:d,children:e})}const ln=()=>u.useContext(la);function mf({action:e,shortcutKeys:t=aa[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const hr=u.forwardRef(({editor:e,action:t,text:n,hideWhenUnavailable:o=!1,onExecuted:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:f}=k(e),{isVisible:p,handleAction:h,label:C,canExecute:g,Icon:b,shortcutKeys:m}=kf({editor:f,action:t,hideWhenUnavailable:o,onExecuted:r}),w=u.useCallback(v=>{i?.(v),!v.defaultPrevented&&h()},[h,i]);return p?l.jsx(M,{type:"button",disabled:!g,variant:"ghost","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":C,tooltip:C,onClick:w,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(b,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(mf,{action:t,shortcutKeys:m})]})}):null});hr.displayName="UndoRedoButton";const sa=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.7071 2.29289C15.3166 1.90237 14.6834 1.90237 14.2929 2.29289C13.9024 2.68342 13.9024 3.31658 14.2929 3.70711L17.5858 7H9.5C7.77609 7 6.12279 7.68482 4.90381 8.90381C3.68482 10.1228 3 11.7761 3 13.5C3 14.3536 3.16813 15.1988 3.49478 15.9874C3.82144 16.7761 4.30023 17.4926 4.90381 18.0962C6.12279 19.3152 7.77609 20 9.5 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9.5C8.30653 18 7.16193 17.5259 6.31802 16.682C5.90016 16.2641 5.56869 15.768 5.34254 15.2221C5.1164 14.6761 5 14.0909 5 13.5C5 12.3065 5.47411 11.1619 6.31802 10.318C7.16193 9.47411 8.30653 9 9.5 9H17.5858L14.2929 12.2929C13.9024 12.6834 13.9024 13.3166 14.2929 13.7071C14.6834 14.0976 15.3166 14.0976 15.7071 13.7071L20.7071 8.70711C21.0976 8.31658 21.0976 7.68342 20.7071 7.29289L15.7071 2.29289Z",fill:"currentColor"})}));sa.displayName="Redo2Icon";const ia=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 3.70711C10.0976 3.31658 10.0976 2.68342 9.70711 2.29289C9.31658 1.90237 8.68342 1.90237 8.29289 2.29289L3.29289 7.29289C2.90237 7.68342 2.90237 8.31658 3.29289 8.70711L8.29289 13.7071C8.68342 14.0976 9.31658 14.0976 9.70711 13.7071C10.0976 13.3166 10.0976 12.6834 9.70711 12.2929L6.41421 9H14.5C15.0909 9 15.6761 9.1164 16.2221 9.34254C16.768 9.56869 17.2641 9.90016 17.682 10.318C18.0998 10.7359 18.4313 11.232 18.6575 11.7779C18.8836 12.3239 19 12.9091 19 13.5C19 14.0909 18.8836 14.6761 18.6575 15.2221C18.4313 15.768 18.0998 16.2641 17.682 16.682C17.2641 17.0998 16.768 17.4313 16.2221 17.6575C15.6761 17.8836 15.0909 18 14.5 18H11C10.4477 18 10 18.4477 10 19C10 19.5523 10.4477 20 11 20H14.5C15.3536 20 16.1988 19.8319 16.9874 19.5052C17.7761 19.1786 18.4926 18.6998 19.0962 18.0962C19.6998 17.4926 20.1786 16.7761 20.5052 15.9874C20.8319 15.1988 21 14.3536 21 13.5C21 12.6464 20.8319 11.8012 20.5052 11.0126C20.1786 10.2239 19.6998 9.50739 19.0962 8.90381C18.4926 8.30022 17.7761 7.82144 16.9874 7.49478C16.1988 7.16813 15.3536 7 14.5 7H6.41421L9.70711 3.70711Z",fill:"currentColor"})}));ia.displayName="Undo2Icon";const aa={undo:"mod+z",redo:"mod+shift+z"},wf={undo:"Undo",redo:"Redo"},vf={undo:ia,redo:sa};function Cr(e,t){return!e||!e.isEditable||ie(e,["image"])?!1:t==="undo"?e.can().undo():e.can().redo()}function yf(e,t){if(!e||!e.isEditable||!Cr(e,t))return!1;const n=e.chain().focus();return t==="undo"?n.undo().run():n.redo().run()}function xf(e){const{editor:t,hideWhenUnavailable:n,action:o}=e;return t?n?t.isEditable?t.isActive("code")?!0:Cr(t,o):!1:!0:!1}function kf(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onExecuted:r}=e,{editor:s}=k(t),[i,a]=u.useState(!0),c=Cr(s,n);u.useEffect(()=>{if(!s)return;const f=()=>{a(xf({editor:s,hideWhenUnavailable:o,action:n}))};return f(),s.on("transaction",f),()=>{s.off("transaction",f)}},[s,o,n]);const d=u.useCallback(()=>{if(!s)return!1;const f=yf(s,n);return f&&r?.(),f},[s,n,r]);return{isVisible:i,handleAction:d,canExecute:c,label:wf[n],shortcutKeys:aa[n],Icon:vf[n]}}function Sf(e){return e[0]?.toUpperCase()??""}function Tf(){const{mentionUsers:e,user:t}=ln(),n=e.length?e:[t],o=n.length;return t.name?l.jsxs("div",{className:"omnibox-editor-users",title:n.map(r=>r.name).join(", "),children:[l.jsx(Os,{maxVisible:4,className:"omnibox-editor-users__avatars",children:n.map(r=>l.jsxs(Gt,{size:"sm",userColor:r.color,title:r.name,children:[l.jsx(yo,{src:r.avatar,alt:r.name}),l.jsx(Kt,{children:Sf(r.name)})]},r.id))}),l.jsx("span",{className:"omnibox-editor-user__name",children:t.name}),o>1?l.jsx("span",{className:"omnibox-editor-users__count",children:o}):null]}):null}function Af(){return l.jsxs("header",{className:"omnibox-editor-header",children:[l.jsx(Ct,{}),l.jsxs("div",{className:"omnibox-editor-header__actions",children:[l.jsx(Tf,{}),l.jsx(ee,{}),l.jsxs(fe,{children:[l.jsx(fe,{children:l.jsx(hr,{action:"undo"})}),l.jsx(fe,{children:l.jsx(hr,{action:"redo"})})]}),l.jsx(ee,{}),l.jsx(Cf,{})]})]})}const If=e=>{const t=u.useRef(e);t.current=e,u.useEffect(()=>()=>{t.current()},[])},Lf={leading:!1,trailing:!0};function ca(e,t=250,n=[],o=Lf){const r=u.useMemo(()=>E1(e,t,o),n);return If(()=>{r.cancel()}),r}function da(){const[e,t]=u.useState({width:0,height:0,offsetTop:0,offsetLeft:0,scale:0}),n=ca(()=>{if(typeof window>"u")return;const o=window.visualViewport;if(!o)return;const{width:r=0,height:s=0,offsetTop:i=0,offsetLeft:a=0,scale:c=0}=o;t(d=>r===d.width&&s===d.height&&i===d.offsetTop&&a===d.offsetLeft&&c===d.scale?d:{width:r,height:s,offsetTop:i,offsetLeft:a,scale:c})},200);return u.useEffect(()=>{const o=window.visualViewport;if(o)return o.addEventListener("resize",n),n(),()=>{o.removeEventListener("resize",n)}},[n]),e}const ua=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.43471 4.01458C4.34773 4.06032 4.26607 4.11977 4.19292 4.19292C4.11977 4.26607 4.06032 4.34773 4.01458 4.43471C2.14611 6.40628 1 9.0693 1 12C1 18.0751 5.92487 23 12 23C14.9306 23 17.5936 21.854 19.5651 19.9856C19.6522 19.9398 19.7339 19.8803 19.8071 19.8071C19.8803 19.7339 19.9398 19.6522 19.9856 19.5651C21.854 17.5936 23 14.9306 23 12C23 5.92487 18.0751 1 12 1C9.0693 1 6.40628 2.14611 4.43471 4.01458ZM6.38231 4.9681C7.92199 3.73647 9.87499 3 12 3C16.9706 3 21 7.02944 21 12C21 14.125 20.2635 16.078 19.0319 17.6177L6.38231 4.9681ZM17.6177 19.0319C16.078 20.2635 14.125 21 12 21C7.02944 21 3 16.9706 3 12C3 9.87499 3.73647 7.92199 4.9681 6.38231L17.6177 19.0319Z",fill:"currentColor"})}));ua.displayName="BanIcon";const gr=u.forwardRef(({className:e,children:t,...n},o)=>{const r=D();return l.jsx(M,{type:"button",className:e,variant:"ghost","data-appearance":"default",role:"button",tabIndex:-1,"aria-label":r.textHighlighter,tooltip:r.highlightColor,ref:o,...n,children:t??l.jsx(Dt,{className:"tiptap-button-icon"})})});gr.displayName="ColorHighlightPopoverButton";function fa({editor:e,colors:t=es(["var(--tt-color-highlight-green)","var(--tt-color-highlight-blue)","var(--tt-color-highlight-red)","var(--tt-color-highlight-purple)","var(--tt-color-highlight-yellow)"]),useColorValue:n=!1}){const o=D(),{handleRemoveHighlight:r}=Ut({editor:e}),s=re(),i=u.useRef(null),a=u.useMemo(()=>[...t,{label:o.removeHighlight,value:"none"}],[t,o.removeHighlight]),{selectedIndex:c}=Ot({containerRef:i,items:a,orientation:"both",onSelect:d=>{if(!i.current)return!1;const f=i.current.querySelector('[data-highlighted="true"]');return f&&f.click(),d.value==="none"&&r(),!0},autoSelectFirstItem:!1});return l.jsx(_e,{ref:i,tabIndex:0,style:s?{boxShadow:"none",border:0}:{},children:l.jsx(Ze,{style:s?{padding:0}:{},children:l.jsxs(Me,{orientation:"horizontal",children:[l.jsx(fe,{children:t.map((d,f)=>l.jsx(fe,{children:l.jsx(Re,{editor:e,highlightColor:n?d.colorValue:d.value,tooltip:d.label,"aria-label":`${d.label} highlight color`,tabIndex:f===c?0:-1,"data-highlighted":c===f,useColorValue:n})},d.value))}),l.jsx(ee,{}),l.jsx(fe,{children:l.jsx(M,{onClick:r,"aria-label":o.removeHighlight,tooltip:o.removeHighlight,tabIndex:c===t.length?0:-1,type:"button",role:"menuitem",variant:"ghost","data-highlighted":c===t.length,children:l.jsx(ua,{className:"tiptap-button-icon"})})})]})})})}function Ef({editor:e,colors:t=es(["var(--tt-color-highlight-green)","var(--tt-color-highlight-blue)","var(--tt-color-highlight-red)","var(--tt-color-highlight-purple)","var(--tt-color-highlight-yellow)"]),hideWhenUnavailable:n=!1,useColorValue:o=!1,onApplied:r,...s}){const{editor:i}=k(e),a=D(),[c,d]=u.useState(!1),{isVisible:f,canColorHighlight:p,isActive:h,label:C,Icon:g}=Ut({editor:i,hideWhenUnavailable:n,onApplied:r});return f?l.jsxs(Pt,{open:c,onOpenChange:d,children:[l.jsx(Wt,{asChild:!0,children:l.jsx(gr,{disabled:!p,"data-active-state":h?"on":"off","data-disabled":!p,"aria-pressed":h,"aria-label":C,tooltip:C,...s,children:l.jsx(g,{className:"tiptap-button-icon"})})}),l.jsx(_t,{"aria-label":a.highlightColors,children:l.jsx(fa,{editor:i,colors:t,useColorValue:o})})]}):null}function Mf({shortcutKeys:e=mr}){return l.jsx(R,{children:J({shortcutKeys:e})})}const br=u.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onInserted:o,showShortcut:r=!1,onClick:s,icon:i,children:a,...c},d)=>{const{editor:f}=k(e),{isVisible:p,canInsert:h,handleImage:C,label:g,isActive:b,shortcutKeys:m,Icon:w}=Bf({editor:f,hideWhenUnavailable:n,onInserted:o}),v=u.useCallback(x=>{s?.(x),!x.defaultPrevented&&C()},[C,s]);if(!p)return null;const y=i??w;return l.jsx(M,{type:"button",variant:"ghost","data-active-state":b?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":g,"aria-pressed":b,tooltip:g,onClick:v,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(y,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),r&&l.jsx(Mf,{shortcutKeys:m})]})})});br.displayName="ImageUploadButton";const pa=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20 2C20 1.44772 19.5523 1 19 1C18.4477 1 18 1.44772 18 2V4H16C15.4477 4 15 4.44772 15 5C15 5.55228 15.4477 6 16 6H18V8C18 8.55228 18.4477 9 19 9C19.5523 9 20 8.55228 20 8V6H22C22.5523 6 23 5.55228 23 5C23 4.44772 22.5523 4 22 4H20V2ZM5 4C4.73478 4 4.48043 4.10536 4.29289 4.29289C4.10536 4.48043 4 4.73478 4 5V19C4 19.2652 4.10536 19.5196 4.29289 19.7071C4.48043 19.8946 4.73478 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12V14.998C22 14.9994 22 15.0007 22 15.002V19C22 19.7957 21.6839 20.5587 21.1213 21.1213C20.5587 21.6839 19.7957 22 19 22H6.00219C6.00073 22 5.99927 22 5.99781 22H5C4.20435 22 3.44129 21.6839 2.87868 21.1213C2.31607 20.5587 2 19.7957 2 19V5C2 4.20435 2.31607 3.44129 2.87868 2.87868C3.44129 2.31607 4.20435 2 5 2H12C12.5523 2 13 2.44772 13 3C13 3.55228 12.5523 4 12 4H5ZM8.41422 20H19C19.2652 20 19.5196 19.8946 19.7071 19.7071C19.8946 19.5196 20 19.2652 20 19V15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20ZM6.87868 6.87868C7.44129 6.31607 8.20435 6 9 6C9.79565 6 10.5587 6.31607 11.1213 6.87868C11.6839 7.44129 12 8.20435 12 9C12 9.79565 11.6839 10.5587 11.1213 11.1213C10.5587 11.6839 9.79565 12 9 12C8.20435 12 7.44129 11.6839 6.87868 11.1213C6.31607 10.5587 6 9.79565 6 9C6 8.20435 6.31607 7.44129 6.87868 6.87868ZM9 8C8.73478 8 8.48043 8.10536 8.29289 8.29289C8.10536 8.48043 8 8.73478 8 9C8 9.26522 8.10536 9.51957 8.29289 9.70711C8.48043 9.89464 8.73478 10 9 10C9.26522 10 9.51957 9.89464 9.70711 9.70711C9.89464 9.51957 10 9.26522 10 9C10 8.73478 9.89464 8.48043 9.70711 8.29289C9.51957 8.10536 9.26522 8 9 8Z",fill:"currentColor"})}));pa.displayName="ImagePlusIcon";const mr="mod+shift+i";function wr(e){return!e||!e.isEditable||!_(e,"imageUpload")?!1:e.can().insertContent({type:"imageUpload"})}function Nf(e){return!e||!e.isEditable?!1:e.isActive("imageUpload")}function Hf(e){if(!e||!e.isEditable||!wr(e))return!1;try{return e.chain().focus().insertContent({type:"imageUpload"}).run()}catch{return!1}}function Vf(e){const{editor:t,hideWhenUnavailable:n}=e;return!t||!t.isEditable?!1:n?_(t,"imageUpload")?t.isActive("code")?!0:wr(t):!1:!0}function Bf(e){const{editor:t,hideWhenUnavailable:n=!1,onInserted:o}=e||{},{editor:r}=k(t),s=D(),i=re(),[a,c]=u.useState(!0),d=wr(r),f=Nf(r);u.useEffect(()=>{if(!r)return;const h=()=>{c(Vf({editor:r,hideWhenUnavailable:n}))};return h(),r.on("selectionUpdate",h),()=>{r.off("selectionUpdate",h)}},[r,n]);const p=u.useCallback(()=>{if(!r)return!1;const h=Hf(r);return h&&o?.(),h},[r,o]);return ue.useHotkeys(mr,h=>{h.preventDefault(),p()},{enabled:a&&d,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:a,isActive:f,handleImage:p,canInsert:d,label:s.addImage,shortcutKeys:mr,Icon:pa}}const ha=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 4C21 3.44772 20.5523 3 20 3C19.4477 3 19 3.44772 19 4V11C19 11.7956 18.6839 12.5587 18.1213 13.1213C17.5587 13.6839 16.7956 14 16 14H6.41421L9.70711 10.7071C10.0976 10.3166 10.0976 9.68342 9.70711 9.29289C9.31658 8.90237 8.68342 8.90237 8.29289 9.29289L3.29289 14.2929C2.90237 14.6834 2.90237 15.3166 3.29289 15.7071L8.29289 20.7071C8.68342 21.0976 9.31658 21.0976 9.70711 20.7071C10.0976 20.3166 10.0976 19.6834 9.70711 19.2929L6.41421 16H16C17.3261 16 18.5979 15.4732 19.5355 14.5355C20.4732 13.5979 21 12.3261 21 11V4Z",fill:"currentColor"})}));ha.displayName="CornerDownLeftIcon";const Ca=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L10.7071 14.7071C10.3166 15.0976 9.68342 15.0976 9.29289 14.7071C8.90237 14.3166 8.90237 13.6834 9.29289 13.2929L18.5858 4H15C14.4477 4 14 3.55228 14 3Z",fill:"currentColor"}),l.jsx("path",{d:"M4.29289 7.29289C4.48043 7.10536 4.73478 7 5 7H11C11.5523 7 12 6.55228 12 6C12 5.44772 11.5523 5 11 5H5C4.20435 5 3.44129 5.31607 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V19C2 19.7957 2.31607 20.5587 2.87868 21.1213C3.44129 21.6839 4.20435 22 5 22H16C16.7957 22 17.5587 21.6839 18.1213 21.1213C18.6839 20.5587 19 19.7957 19 19V13C19 12.4477 18.5523 12 18 12C17.4477 12 17 12.4477 17 13V19C17 19.2652 16.8946 19.5196 16.7071 19.7071C16.5196 19.8946 16.2652 20 16 20H5C4.73478 20 4.48043 19.8946 4.29289 19.7071C4.10536 19.5196 4 19.2652 4 19V8C4 7.73478 4.10536 7.48043 4.29289 7.29289Z",fill:"currentColor"})]}));Ca.displayName="ExternalLinkIcon";const vr=u.forwardRef(({className:e,children:t,...n},o)=>{const r=D();return l.jsx(M,{type:"button",className:e,variant:"ghost",role:"button",tabIndex:-1,"aria-label":r.link,tooltip:r.link,ref:o,...n,children:t||l.jsx(xt,{className:"tiptap-button-icon"})})});vr.displayName="LinkButton";const ga=({url:e,setUrl:t,setLink:n,removeLink:o,openLink:r,isActive:s})=>{const i=re(),a=D(),c=d=>{d.key==="Enter"&&(d.preventDefault(),n())};return l.jsx(_e,{style:{...i?{boxShadow:"none",border:0}:{}},children:l.jsx(Ze,{style:{...i?{padding:0}:{}},children:l.jsxs(Me,{orientation:"horizontal",children:[l.jsx(Al,{type:"url",placeholder:a.pasteLink,value:e,onChange:d=>t(d.target.value),onKeyDown:c,autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",className:"tiptap-link-input"}),l.jsx(fe,{children:l.jsx(M,{type:"button",onClick:n,title:a.applyLink,disabled:!e&&!s,variant:"ghost",children:l.jsx(ha,{className:"tiptap-button-icon"})})}),l.jsx(ee,{}),l.jsxs(fe,{children:[l.jsx(fe,{children:l.jsx(M,{type:"button",onClick:r,title:a.openLinkInNewWindow,disabled:!e&&!s,variant:"ghost",children:l.jsx(Ca,{className:"tiptap-button-icon"})})}),l.jsx(fe,{children:l.jsx(M,{type:"button",onClick:o,title:a.removeLink,disabled:!e&&!s,variant:"ghost",children:l.jsx(ht,{className:"tiptap-button-icon"})})})]})]})})})},Df=({editor:e})=>{const t=ma({editor:e});return l.jsx(ga,{...t})},yr=u.forwardRef(({editor:e,hideWhenUnavailable:t=!1,onSetLink:n,onOpenChange:o,autoOpenOnLinkActive:r=!0,onClick:s,children:i,...a},c)=>{const{editor:d}=k(e),[f,p]=u.useState(!1),{isVisible:h,canSet:C,isActive:g,url:b,setUrl:m,setLink:w,removeLink:v,openLink:y,label:x,Icon:S}=ma({editor:d,hideWhenUnavailable:t,onSetLink:n}),L=u.useCallback(K=>{p(K),o?.(K)},[o]),I=u.useCallback(()=>{w(),p(!1)},[w]),V=u.useCallback(K=>{s?.(K),!K.defaultPrevented&&p(!f)},[s,f]);return u.useEffect(()=>{r&&g&&p(!0)},[r,g]),h?l.jsxs(Pt,{open:f,onOpenChange:L,children:[l.jsx(Wt,{asChild:!0,children:l.jsx(vr,{disabled:!C,"data-active-state":g?"on":"off","data-disabled":!C,"aria-label":x,"aria-pressed":g,onClick:V,...a,ref:c,children:i??l.jsx(S,{className:"tiptap-button-icon"})})}),l.jsx(_t,{collisionPadding:4,children:l.jsx(ga,{url:b,setUrl:m,setLink:I,removeLink:v,openLink:y,isActive:g})})]}):null});yr.displayName="LinkPopover";function xr(e){if(!e||!e.isEditable||ie(e,["image"],!0))return!1;try{return e.can().setMark("link")}catch{return!1}}function ba(e){return!e||!e.isEditable?!1:e.isActive("link")}function Uf(e){const{editor:t,hideWhenUnavailable:n}=e;if(!t||!t.isEditable)return!1;const o=Ae("link",t);return n?o?t.isActive("code")?!0:xr(t):!1:!0}function Of(e){const{editor:t,onSetLink:n}=e,[o,r]=u.useState(null);u.useEffect(()=>{if(!t)return;const{href:c}=t.getAttributes("link");ba(t)&&o===null&&r(c||"")},[t,o]),u.useEffect(()=>{if(!t)return;const c=()=>{const{href:d}=t.getAttributes("link");r(d||"")};return t.on("selectionUpdate",c),()=>{t.off("selectionUpdate",c)}},[t]);const s=u.useCallback(()=>{if(!o||!t)return;const{selection:c}=t.state,d=c.empty;let f=t.chain().focus();f=f.extendMarkRange("link").setLink({href:o}),d&&(f=f.insertContent({type:"text",text:o})),f.run(),r(null),n?.()},[t,n,o]),i=u.useCallback(()=>{t&&(t.chain().focus().extendMarkRange("link").unsetLink().setMeta("preventAutolink",!0).run(),r(""))},[t]),a=u.useCallback((c="_blank",d="noopener,noreferrer")=>{if(!o)return;const f=vn(o,window.location.href);f!=="#"&&window.open(f,c,d)},[o]);return{url:o||"",setUrl:r,setLink:s,removeLink:i,openLink:a}}function Pf(e){const{editor:t,hideWhenUnavailable:n=!1}=e,o=xr(t),r=ba(t),[s,i]=u.useState(!0);return u.useEffect(()=>{if(!t)return;const a=()=>{i(Uf({editor:t,hideWhenUnavailable:n}))};return a(),t.on("selectionUpdate",a),()=>{t.off("selectionUpdate",a)}},[t,n]),{isVisible:s,canSet:o,isActive:r}}function ma(e){const{editor:t,hideWhenUnavailable:n=!1,onSetLink:o}=e||{},{editor:r}=k(t),s=D(),{isVisible:i,canSet:a,isActive:c}=Pf({editor:r,hideWhenUnavailable:n}),d=Of({editor:r,onSetLink:o});return{isVisible:i,canSet:a,isActive:c,label:s.link,Icon:xt,...d}}function Wf({type:e,shortcutKeys:t=Aa[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const he=u.forwardRef(({editor:e,type:t,text:n,hideWhenUnavailable:o=!1,onToggled:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:f}=k(e),{isVisible:p,handleMark:h,label:C,canToggle:g,isActive:b,Icon:m,shortcutKeys:w}=qf({editor:f,type:t,hideWhenUnavailable:o,onToggled:r}),v=u.useCallback(y=>{i?.(y),!y.defaultPrevented&&h()},[h,i]);return p?l.jsx(M,{type:"button",disabled:!g,variant:"ghost","data-active-state":b?"on":"off","data-disabled":!g,role:"button",tabIndex:-1,"aria-label":C,"aria-pressed":b,tooltip:C,onClick:v,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(Wf,{type:t,shortcutKeys:w})]})}):null});he.displayName="MarkButton";const wa=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",fill:"currentColor"})}));wa.displayName="BoldIcon";const va=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M15.4545 4.2983C15.6192 3.77115 15.3254 3.21028 14.7983 3.04554C14.2712 2.88081 13.7103 3.1746 13.5455 3.70175L8.54554 19.7017C8.38081 20.2289 8.6746 20.7898 9.20175 20.9545C9.72889 21.1192 10.2898 20.8254 10.4545 20.2983L15.4545 4.2983Z",fill:"currentColor"}),l.jsx("path",{d:"M6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.70711L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289Z",fill:"currentColor"}),l.jsx("path",{d:"M17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C23.0976 11.6834 23.0976 12.3166 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z",fill:"currentColor"})]}));va.displayName="Code2Icon";const ya=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{d:"M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",fill:"currentColor"})}));ya.displayName="ItalicIcon";const xa=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",fill:"currentColor"}),l.jsx("path",{d:"M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",fill:"currentColor"})]}));xa.displayName="StrikeIcon";const ka=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.4079 14.3995C18.0284 14.0487 18.7506 13.9217 19.4536 14.0397C20.1566 14.1578 20.7977 14.5138 21.2696 15.0481L21.2779 15.0574L21.2778 15.0575C21.7439 15.5988 22 16.2903 22 17C22 18.0823 21.3962 18.8401 20.7744 19.3404C20.194 19.8073 19.4858 20.141 18.9828 20.378C18.9638 20.387 18.9451 20.3958 18.9266 20.4045C18.4473 20.6306 18.2804 20.7817 18.1922 20.918C18.1773 20.9412 18.1619 20.9681 18.1467 21H21C21.5523 21 22 21.4477 22 22C22 22.5523 21.5523 23 21 23H17C16.4477 23 16 22.5523 16 22C16 21.1708 16.1176 20.4431 16.5128 19.832C16.9096 19.2184 17.4928 18.8695 18.0734 18.5956C18.6279 18.334 19.138 18.0901 19.5207 17.7821C19.8838 17.49 20 17.2477 20 17C20 16.7718 19.9176 16.5452 19.7663 16.3672C19.5983 16.1792 19.3712 16.0539 19.1224 16.0121C18.8722 15.9701 18.6152 16.015 18.3942 16.1394C18.1794 16.2628 18.0205 16.4549 17.9422 16.675C17.7572 17.1954 17.1854 17.4673 16.665 17.2822C16.1446 17.0972 15.8728 16.5254 16.0578 16.005C16.2993 15.3259 16.7797 14.7584 17.4039 14.4018L17.4079 14.3995L17.4079 14.3995Z",fill:"currentColor"})]}));ka.displayName="SubscriptIcon";const Sa=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.405 1.40657C18.0246 1.05456 18.7463 0.92634 19.4492 1.04344C20.1521 1.16054 20.7933 1.51583 21.2652 2.0497L21.2697 2.05469L21.2696 2.05471C21.7431 2.5975 22 3.28922 22 4.00203C22 5.08579 21.3952 5.84326 20.7727 6.34289C20.1966 6.80531 19.4941 7.13675 18.9941 7.37261C18.9714 7.38332 18.9491 7.39383 18.9273 7.40415C18.4487 7.63034 18.2814 7.78152 18.1927 7.91844C18.1778 7.94155 18.1625 7.96834 18.1473 8.00003H21C21.5523 8.00003 22 8.44774 22 9.00003C22 9.55231 21.5523 10 21 10H17C16.4477 10 16 9.55231 16 9.00003C16 8.17007 16.1183 7.44255 16.5138 6.83161C16.9107 6.21854 17.4934 5.86971 18.0728 5.59591C18.6281 5.33347 19.1376 5.09075 19.5208 4.78316C19.8838 4.49179 20 4.25026 20 4.00203C20 3.77192 19.9178 3.54865 19.7646 3.37182C19.5968 3.18324 19.3696 3.05774 19.1205 3.01625C18.8705 2.97459 18.6137 3.02017 18.3933 3.14533C18.1762 3.26898 18.0191 3.45826 17.9406 3.67557C17.7531 4.19504 17.18 4.46414 16.6605 4.27662C16.141 4.0891 15.8719 3.51596 16.0594 2.99649C16.303 2.3219 16.7817 1.76125 17.4045 1.40689L17.405 1.40657Z",fill:"currentColor"})]}));Sa.displayName="SuperscriptIcon";const Ta=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4V10C5 11.8565 5.7375 13.637 7.05025 14.9497C8.36301 16.2625 10.1435 17 12 17C13.8565 17 15.637 16.2625 16.9497 14.9497C18.2625 13.637 19 11.8565 19 10V4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V10C17 11.3261 16.4732 12.5979 15.5355 13.5355C14.5979 14.4732 13.3261 15 12 15C10.6739 15 9.40215 14.4732 8.46447 13.5355C7.52678 12.5979 7 11.3261 7 10V4ZM4 19C3.44772 19 3 19.4477 3 20C3 20.5523 3.44772 21 4 21H20C20.5523 21 21 20.5523 21 20C21 19.4477 20.5523 19 20 19H4Z",fill:"currentColor"})}));Ta.displayName="UnderlineIcon";const _f={bold:wa,italic:ya,underline:Ta,strike:xa,code:va,superscript:Sa,subscript:ka},Aa={bold:"mod+b",italic:"mod+i",underline:"mod+u",strike:"mod+shift+s",code:"mod+e",superscript:"mod+.",subscript:"mod+,"};function sn(e,t){return!e||!e.isEditable||!Ae(t,e)||ie(e,["image"])?!1:e.can().toggleMark(t)}function Zf(e,t){return!e||!e.isEditable?!1:e.isActive(t)}function Ff(e,t){return!e||!e.isEditable||!sn(e,t)?!1:e.chain().focus().toggleMark(t).run()}function zf(e){const{editor:t,type:n,hideWhenUnavailable:o}=e;return t?o?!t.isEditable||!Ae(n,t)?!1:t.isActive("code")?!0:sn(t,n):!0:!1}function $f(e,t){return{bold:t.bold,italic:t.italic,underline:t.underline,strike:t.strike,code:t.code,superscript:t.superscript,subscript:t.subscript}[e]}function qf(e){const{editor:t,type:n,hideWhenUnavailable:o=!1,onToggled:r}=e,{editor:s}=k(t),i=D(),[a,c]=u.useState(!0),d=sn(s,n),f=Zf(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{c(zf({editor:s,type:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,n,o]);const p=u.useCallback(()=>{if(!s)return!1;const h=Ff(s,n);return h&&r?.(),h},[s,n,r]);return{isVisible:a,isActive:f,handleMark:p,canToggle:d,label:$f(n,i),shortcutKeys:Aa[n],Icon:_f[n]}}function Gf({align:e,shortcutKeys:t=Ia[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const Ne=u.forwardRef(({editor:e,align:t,text:n,hideWhenUnavailable:o=!1,onAligned:r,showShortcut:s=!1,onClick:i,icon:a,children:c,...d},f)=>{const{editor:p}=k(e),{isVisible:h,handleTextAlign:C,label:g,canAlign:b,isActive:m,Icon:w,shortcutKeys:v}=Rf({editor:p,align:t,hideWhenUnavailable:o,onAligned:r}),y=u.useCallback(S=>{i?.(S),!S.defaultPrevented&&C()},[C,i]);if(!h)return null;const x=a??w;return l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-active-state":m?"on":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,"aria-pressed":m,tooltip:g,onClick:y,...d,ref:f,children:c??l.jsxs(l.Fragment,{children:[l.jsx(x,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(Gf,{align:t,shortcutKeys:v})]})})});Ne.displayName="TextAlignButton";const Ia={left:"mod+shift+l",center:"mod+shift+e",right:"mod+shift+r",justify:"mod+shift+j"},Kf={left:eo,center:to,right:no,justify:oo};function Yf(e,t){return{left:t.alignLeft,center:t.alignCenter,right:t.alignRight,justify:t.alignJustify}[e]}function an(e,t){return!e||!e.isEditable||!_(e,"textAlign")||ie(e,["image","horizontalRule"])?!1:e.can().setTextAlign(t)}function jf(e){return"setTextAlign"in e}function Xf(e,t){return!e||!e.isEditable?!1:e.isActive({textAlign:t})}function Jf(e,t){if(!e||!e.isEditable||!an(e,t))return!1;const n=e.chain().focus();return jf(n)?n.setTextAlign(t).run():!1}function Qf(e){const{editor:t,hideWhenUnavailable:n,align:o}=e;return t?n?!t.isEditable||!_(t,"textAlign")?!1:t.isActive("code")?!0:an(t,o):!0:!1}function Rf(e){const{editor:t,align:n,hideWhenUnavailable:o=!1,onAligned:r}=e,{editor:s}=k(t),i=D(),[a,c]=u.useState(!0),d=an(s,n),f=Xf(s,n);u.useEffect(()=>{if(!s)return;const h=()=>{c(Qf({editor:s,align:n,hideWhenUnavailable:o}))};return h(),s.on("selectionUpdate",h),()=>{s.off("selectionUpdate",h)}},[s,o,n]);const p=u.useCallback(()=>{if(!s)return!1;const h=Jf(s,n);return h&&r?.(),h},[s,n,r]);return{isVisible:a,isActive:f,handleTextAlign:p,canAlign:d,label:Yf(n,i),shortcutKeys:Ia[n],Icon:Kf[n]}}const La=u.memo(({className:e,...t})=>l.jsx("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 5.29289C21.0976 5.68342 21.0976 6.31658 20.7071 6.70711L9.70711 17.7071C9.31658 18.0976 8.68342 18.0976 8.29289 17.7071L3.29289 12.7071C2.90237 12.3166 2.90237 11.6834 3.29289 11.2929C3.68342 10.9024 4.31658 10.9024 4.70711 11.2929L9 15.5858L19.2929 5.29289C19.6834 4.90237 20.3166 4.90237 20.7071 5.29289Z",fill:"currentColor"})}));La.displayName="CheckIcon";function Ea({...e}){return l.jsx(ve.Root,{"data-slot":"tiptap-dropdown-menu",...e})}function Ma({...e}){return l.jsx(ve.Portal,{"data-slot":"tiptap-dropdown-menu-portal",...e})}function Na({...e}){return l.jsx(ve.Trigger,{"data-slot":"tiptap-dropdown-menu-trigger",...e})}function Ha({className:e,align:t="start",sideOffset:n=4,...o}){return l.jsx(ve.Portal,{children:l.jsx(ve.Content,{"data-slot":"tiptap-dropdown-menu-content",sideOffset:n,align:t,className:z("tiptap-dropdown-menu-content",e),onCloseAutoFocus:r=>r.preventDefault(),...o})})}function $e({className:e,...t}){return l.jsx(ve.Group,{"data-slot":"tiptap-dropdown-menu-group",className:z("tiptap-dropdown-menu-group",e),...t})}function pe({className:e,inset:t,variant:n="default",...o}){return l.jsx(ve.Item,{"data-slot":"tiptap-dropdown-menu-item","data-inset":t,"data-variant":n,className:z("tiptap-dropdown-menu-item",e),...o})}function kt({className:e,inset:t,...n}){return l.jsx(ve.Label,{"data-slot":"tiptap-dropdown-menu-label","data-inset":t,className:z("tiptap-dropdown-menu-label",e),...n})}function Va({...e}){return l.jsx(ve.Sub,{"data-slot":"tiptap-dropdown-menu-sub",...e})}function Ba({className:e,inset:t,children:n,...o}){return l.jsx(ve.SubTrigger,{"data-slot":"tiptap-dropdown-menu-sub-trigger","data-inset":t,className:z("tiptap-dropdown-menu-sub-trigger",e),...o,children:n})}function Da({className:e,...t}){return l.jsx(ve.SubContent,{"data-slot":"tiptap-dropdown-menu-sub-content",className:z("tiptap-dropdown-menu-sub-content",e),...t})}function Ua({blockTypes:e,editor:t}){const n=D(),o=cn(e).map(r=>kr(r,n));return l.jsxs($e,{children:[l.jsx(kt,{children:n.turnInto}),o.map((r,s)=>e5(r,`${r.type}-${r.level??s}`,t))]})}function e5(e,t,n){switch(e.type){case"paragraph":return l.jsx(pe,{asChild:!0,children:l.jsx(_i,{editor:n,showTooltip:!1,text:e.label})},t);case"heading":return e.level?l.jsx(pe,{asChild:!0,children:l.jsx(Fi,{editor:n,level:e.level,showTooltip:!1,text:e.label})},t):null;case"bulletList":return l.jsx(pe,{asChild:!0,children:l.jsx(on,{editor:n,type:"bulletList",showTooltip:!1,text:e.label})},t);case"orderedList":return l.jsx(pe,{asChild:!0,children:l.jsx(on,{editor:n,type:"orderedList",showTooltip:!1,text:e.label})},t);case"taskList":return l.jsx(pe,{asChild:!0,children:l.jsx(on,{editor:n,type:"taskList",showTooltip:!1,text:e.label})},t);case"blockquote":return l.jsx(pe,{asChild:!0,children:l.jsx(Yi,{editor:n,showTooltip:!1,text:e.label})},t);case"codeBlock":return l.jsx(pe,{asChild:!0,children:l.jsx(Ji,{editor:n,showTooltip:!1,text:e.label})},t);default:return null}}const Oa=u.forwardRef(function({editor:t,hideWhenUnavailable:n=!1,blockTypes:o,onOpenChange:r,modal:s=!0,children:i,...a},c){const{editor:d}=k(t),f=D(),{isVisible:p,canToggle:h,isOpen:C,activeBlockType:g,handleOpenChange:b,label:m,Icon:w}=l5({editor:d,hideWhenUnavailable:n,blockTypes:o,onOpenChange:r});return p?l.jsxs(Ea,{modal:s,open:C,onOpenChange:b,children:[l.jsx(Na,{asChild:!0,children:l.jsx(M,{type:"button",variant:"ghost",disabled:!h,"data-disabled":!h,role:"button",tabIndex:-1,"aria-label":m,tooltip:f.turnInto,...a,ref:c,children:i??l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tiptap-button-text",children:g?.label||f.text}),l.jsx(w,{className:"tiptap-button-dropdown-small"})]})})}),l.jsx(Ha,{align:"start",children:l.jsx(Ua,{blockTypes:o,editor:d})})]}):null});Oa.displayName="TurnIntoDropdown";const t5=["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"],Pa=[{type:"paragraph",label:"Text",isActive:e=>e.isActive("paragraph")&&!e.isActive("heading")&&!e.isActive("bulletList")&&!e.isActive("orderedList")&&!e.isActive("taskList")&&!e.isActive("blockquote")&&!e.isActive("codeBlock")},{type:"heading",label:"Heading 1",level:1,isActive:e=>e.isActive("heading",{level:1})},{type:"heading",label:"Heading 2",level:2,isActive:e=>e.isActive("heading",{level:2})},{type:"heading",label:"Heading 3",level:3,isActive:e=>e.isActive("heading",{level:3})},{type:"bulletList",label:"Bulleted list",isActive:e=>e.isActive("bulletList")},{type:"orderedList",label:"Numbered list",isActive:e=>e.isActive("orderedList")},{type:"taskList",label:"To-do list",isActive:e=>e.isActive("taskList")},{type:"blockquote",label:"Blockquote",isActive:e=>e.isActive("blockquote")},{type:"codeBlock",label:"Code block",isActive:e=>e.isActive("codeBlock")}];function n5(e,t){return{1:t.heading1,2:t.heading2,3:t.heading3,4:t.heading4,5:t.heading5,6:t.heading6}[e]}function kr(e,t){const n=(()=>{switch(e.type){case"paragraph":return t.text;case"heading":return e.level?n5(e.level,t):t.heading;case"bulletList":return t.bulletList;case"orderedList":return t.orderedList;case"taskList":return t.taskList;case"blockquote":return t.blockquote;case"codeBlock":return t.codeBlock;default:return e.label}})();return{...e,label:n}}function Wa(e,t){if(!e||!e.isEditable)return!1;const n=t||t5,{selection:o}=e.state;if(o instanceof E.NodeSelection){const i=o.node.type.name;return n.includes(i)}const{$anchor:r}=o,s=r.parent.type.name;return n.includes(s)}function cn(e){return e?Pa.filter(t=>e.includes(t.type)):Pa}function o5(e,t){if(!e)return cn(t)[0];const n=cn(t);return n.find(r=>r.isActive(e))||n[0]}function r5(e){const{editor:t,hideWhenUnavailable:n,blockTypes:o}=e;return t?n?t.isEditable?t.isActive("code")?!0:Wa(t,o):!1:!0:!1}function l5(e){const{editor:t,hideWhenUnavailable:n=!1,blockTypes:o,onOpenChange:r}=e||{},{editor:s}=k(t),i=D(),[a,c]=u.useState(!1),[d,f]=u.useState(!0),p=Wa(s,o),h=kr(o5(s,o),i),C=cn(o).map(b=>kr(b,i)),g=u.useCallback(b=>{!s||!p||(c(b),r?.(b))},[p,s,r]);return u.useEffect(()=>{if(!s)return;const b=()=>{f(r5({editor:s,hideWhenUnavailable:n,blockTypes:o}))};return b(),s.on("selectionUpdate",b),()=>{s.off("selectionUpdate",b)}},[s,n,o]),{isVisible:d,canToggle:p,isOpen:a,setIsOpen:c,activeBlockType:h,handleOpenChange:g,filteredOptions:C,label:i.turnIntoCurrent.replace("{{current}}",h?.label||i.text),Icon:Jn}}function s5({action:e,shortcutKeys:t=Fa[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const St=u.forwardRef(({editor:e,action:t,text:n,hideWhenUnavailable:o=!1,onIndented:r,showShortcut:s=!1,onClick:i,icon:a,children:c,...d},f)=>{const{editor:p}=k(e),{isVisible:h,handleIndent:C,label:g,canIndent:b,Icon:m,shortcutKeys:w}=u5({editor:p,action:t,hideWhenUnavailable:o,onIndented:r}),v=u.useCallback(x=>{i?.(x),!x.defaultPrevented&&C()},[C,i]);if(!h)return null;const y=a??m;return l.jsx(M,{type:"button",disabled:!b,variant:"ghost","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":g,tooltip:g,onClick:v,...d,ref:f,children:c??l.jsxs(l.Fragment,{children:[l.jsx(y,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),s&&l.jsx(s5,{action:t,shortcutKeys:w})]})})});St.displayName="IndentButton";const _a=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M17.0002 18.5C17.5524 18.5 18.0002 18.9477 18.0002 19.5C18.0002 20.0523 17.5524 20.5 17.0002 20.5H11.0002C10.4479 20.5 10.0002 20.0523 10.0002 19.5C10.0002 18.9477 10.4479 18.5 11.0002 18.5H17.0002Z",fill:"currentColor"}),l.jsx("path",{d:"M2.29314 8.29297C2.68366 7.90248 3.31669 7.90246 3.7072 8.29297L6.7072 11.293L6.77556 11.3691C7.09586 11.7619 7.07327 12.3409 6.7072 12.707L3.7072 15.707C3.31669 16.0975 2.68367 16.0975 2.29314 15.707C1.90261 15.3165 1.90261 14.6835 2.29314 14.293L4.58611 12L2.29314 9.70703C1.90261 9.31651 1.90261 8.68349 2.29314 8.29297Z",fill:"currentColor"}),l.jsx("path",{d:"M21.0002 13.5C21.5524 13.5 22.0002 13.9477 22.0002 14.5C22.0002 15.0523 21.5524 15.5 21.0002 15.5H11.0002C10.4479 15.5 10.0002 15.0523 10.0002 14.5C10.0002 13.9477 10.4479 13.5 11.0002 13.5H21.0002Z",fill:"currentColor"}),l.jsx("path",{d:"M21.0002 8.5C21.5524 8.50004 22.0002 8.94774 22.0002 9.5C22.0002 10.0523 21.5524 10.5 21.0002 10.5H11.0002C10.4479 10.5 10.0002 10.0523 10.0002 9.5C10.0002 8.94772 10.4479 8.5 11.0002 8.5H21.0002Z",fill:"currentColor"}),l.jsx("path",{d:"M21.0002 3.5C21.5524 3.50004 22.0002 3.94774 22.0002 4.5C22.0002 5.05226 21.5524 5.49996 21.0002 5.5H11.0002C10.4479 5.5 10.0002 5.05228 10.0002 4.5C10.0002 3.94772 10.4479 3.5 11.0002 3.5H21.0002Z",fill:"currentColor"})]}));_a.displayName="IndentIncreaseIcon";const Za=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M9 18.5C9.55228 18.5 10 18.9477 10 19.5C10 20.0523 9.55228 20.5 9 20.5H3C2.44772 20.5 2 20.0523 2 19.5C2 18.9477 2.44772 18.5 3 18.5H9Z",fill:"currentColor"}),l.jsx("path",{d:"M20.293 8.29297C20.6835 7.90244 21.3165 7.90244 21.707 8.29297C22.0976 8.68349 22.0976 9.31651 21.707 9.70703L19.4141 12L21.707 14.293C22.0976 14.6835 22.0976 15.3165 21.707 15.707C21.3165 16.0976 20.6835 16.0976 20.293 15.707L17.293 12.707L17.2246 12.6309C16.9043 12.2381 16.9269 11.6591 17.293 11.293L20.293 8.29297Z",fill:"currentColor"}),l.jsx("path",{d:"M13 13.5C13.5523 13.5 14 13.9477 14 14.5C14 15.0523 13.5523 15.5 13 15.5H3C2.44772 15.5 2 15.0523 2 14.5C2 13.9477 2.44772 13.5 3 13.5H13Z",fill:"currentColor"}),l.jsx("path",{d:"M13 8.5C13.5523 8.5 14 8.94772 14 9.5C14 10.0523 13.5523 10.5 13 10.5H3C2.44772 10.5 2 10.0523 2 9.5C2 8.94772 2.44772 8.5 3 8.5H13Z",fill:"currentColor"}),l.jsx("path",{d:"M13 3.5C13.5523 3.5 14 3.94772 14 4.5C14 5.05228 13.5523 5.5 13 5.5H3C2.44772 5.5 2 5.05228 2 4.5C2 3.94772 2.44772 3.5 3 3.5H13Z",fill:"currentColor"})]}));Za.displayName="IndentDecreaseIcon";const Fa={indent:"Tab",outdent:"Shift-Tab"},i5={indent:_a,outdent:Za};function a5(e,t){return{indent:t.increaseIndent,outdent:t.decreaseIndent}[e]}function Sr(e,t){return!e||!e.isEditable||!_(e,"indent")?!1:t==="indent"?e.can().indent():e.can().outdent()}function c5(e,t){return!e||!e.isEditable||!Sr(e,t)?!1:t==="indent"?e.chain().focus().indent().run():e.chain().focus().outdent().run()}function d5(e){const{editor:t,hideWhenUnavailable:n,action:o}=e;return t?n?!t.isEditable||!_(t,"indent")?!1:Sr(t,o):!0:!1}function u5(e){const{editor:t,action:n,hideWhenUnavailable:o=!1,onIndented:r}=e,{editor:s}=k(t),i=D(),[a,c]=u.useState(!0),d=Sr(s,n);u.useEffect(()=>{if(!s)return;const p=()=>{c(d5({editor:s,action:n,hideWhenUnavailable:o}))};return p(),s.on("selectionUpdate",p),s.on("transaction",p),()=>{s.off("selectionUpdate",p),s.off("transaction",p)}},[s,o,n]);const f=u.useCallback(()=>{if(!s)return!1;const p=c5(s,n);return p&&r?.(),p},[s,n,r]);return{isVisible:a,canIndent:d,handleIndent:f,label:a5(n,i),shortcutKeys:Fa[n],Icon:i5[n]}}const f5=e=>{const[t,n]=u.useState([]),o=u.useCallback(()=>e.current?Array.from(e.current.querySelectorAll('button:not([disabled]), [role="button"]:not([disabled]), [tabindex="0"]:not([disabled])')):[],[e]);u.useEffect(()=>{const s=e.current;if(!s)return;const i=()=>n(o());i();const a=new MutationObserver(i);return a.observe(s,{childList:!0,subtree:!0}),()=>a.disconnect()},[o,e]);const{selectedIndex:r}=Ot({containerRef:e,items:t,orientation:"horizontal",onSelect:s=>s.click(),autoSelectFirstItem:!1});u.useEffect(()=>{const s=e.current;if(!s)return;const i=c=>{const d=c.target;s.contains(d)&&d.setAttribute("data-focus-visible","true")},a=c=>{const d=c.target;s.contains(d)&&d.removeAttribute("data-focus-visible")};return s.addEventListener("focus",i,!0),s.addEventListener("blur",a,!0),()=>{s.removeEventListener("focus",i,!0),s.removeEventListener("blur",a,!0)}},[e]),u.useEffect(()=>{r!==void 0&&t[r]&&t[r].focus()},[r,t])},dn=u.forwardRef(({children:e,className:t,variant:n="fixed",...o},r)=>{const s=u.useRef(null),i=Ll(s,r);return f5(s),l.jsx("div",{ref:i,role:"toolbar","aria-label":"toolbar","data-variant":n,className:z("tiptap-toolbar",t),...o,children:e})});dn.displayName="Toolbar";const ae=u.forwardRef(({children:e,className:t,...n},o)=>l.jsx("div",{ref:o,role:"group",className:z("tiptap-toolbar-group",t),...n,children:e}));ae.displayName="ToolbarGroup";const Ce=u.forwardRef(({...e},t)=>l.jsx(ee,{ref:t,orientation:"vertical",decorative:!0,...e}));Ce.displayName="ToolbarSeparator";function p5({shortcutKeys:e}){return l.jsx(R,{children:J({shortcutKeys:e})})}const Tr=u.forwardRef(({editor:e,text:t,direction:n,hideWhenUnavailable:o=!1,onMoved:r,showShortcut:s=!1,onClick:i,children:a,...c},d)=>{const{editor:f}=k(e),{isVisible:p,handleMoveNode:h,canMoveNode:C,label:g,shortcutKeys:b,Icon:m}=m5({editor:f,direction:n,hideWhenUnavailable:o,onMoved:r}),w=u.useCallback(y=>{i?.(y),!y.defaultPrevented&&h()},[h,i]);if(!p)return null;const v=n==="up"?"Move Up":"Move Down";return l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":g,tooltip:v,disabled:!C,onClick:w,...c,ref:d,children:a??l.jsxs(l.Fragment,{children:[l.jsx(m,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t}),s&&l.jsx(p5,{shortcutKeys:b})]})})});Tr.displayName="MoveNodeButton";const h5="mod+shift+ArrowUp",C5="mod+shift+ArrowDown";function za(e,t){if(!e||!e.isEditable)return!1;const n=ct(e);if(!n)return!1;try{const{pos:o}=n,r=e.state.doc.resolve(o),s=r.parent,i=r.index();return t==="up"?i>0:i<s.childCount-1}catch{return!1}}function g5(e,t){if(!e||!e.isEditable)return!1;const n=ct(e);if(!n)return!1;try{const{pos:o,node:r}=n,s=e.state.tr,i=s.doc.resolve(o),a=i.parent,c=i.index();if(c<0||c>=a.childCount)return!1;if(t==="up"&&c>0){const f=a.child(c-1).nodeSize,p=r.type.create(r.attrs,r.content,r.marks);s.deleteRange(o,o+r.nodeSize);const h=o-f;s.insert(h,p),s.setSelection(E.TextSelection.near(s.doc.resolve(h)))}else if(t==="down"&&c<a.childCount-1){const f=a.child(c+1).nodeSize,p=r.type.create(r.attrs,r.content,r.marks);s.deleteRange(o,o+r.nodeSize);const h=o+f;s.insert(h,p),s.setSelection(E.TextSelection.near(s.doc.resolve(h)))}else return!1;return e.view.dispatch(s),!0}catch(o){return console.error("Error moving node:",o),!1}}function b5(e){const{editor:t,direction:n,hideWhenUnavailable:o}=e;if(!t)return!1;if(!o)return!0;if(!t.isEditable)return!1;const r=!!ct(t),s=za(t,n);return r&&s}function m5(e){const{editor:t,hideWhenUnavailable:n=!1,direction:o,onMoved:r}=e,{editor:s}=k(t),i=re(),[a,c]=u.useState(!0),[d,f]=u.useState(!1),p=u.useCallback(()=>{if(!d)return!1;const b=g5(s,o);return b&&r?.(o),b},[s,o,r,d]);u.useEffect(()=>{if(!s)return;const b=()=>{c(b5({editor:s,direction:o,hideWhenUnavailable:n})),f(za(s,o))};return b(),s.on("selectionUpdate",b),()=>{s.off("selectionUpdate",b)}},[s,o,n]);const h=o==="up"?h5:C5;return ue.useHotkeys(h,b=>{b.preventDefault(),p()},{enabled:a&&d,enableOnContentEditable:!i,enableOnFormTags:!0},[p,a,d,i]),{isVisible:a,handleMoveNode:p,canMoveNode:d,label:o==="up"?"Move Up":"Move Down",shortcutKeys:h,Icon:o==="up"?lo:ro}}const un={x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0},$a=typeof window>"u",w5=!$a&&typeof ResizeObserver<"u",fn=()=>!$a;function v5({element:e,enabled:t=!0,throttleMs:n=100,useResizeObserver:o=!0}={}){const[r,s]=u.useState(un),i=u.useCallback(()=>!t||!fn()?null:e?typeof e=="string"?document.querySelector(e):"current"in e?e.current:e:document.body,[e,t]),a=ca(()=>{if(!t||!fn())return;const c=i();if(!c){s(un);return}const d=c.getBoundingClientRect();s({x:d.x,y:d.y,width:d.width,height:d.height,top:d.top,right:d.right,bottom:d.bottom,left:d.left})},n,[t,i],{leading:!0,trailing:!0});return u.useEffect(()=>{if(!t||!fn()){s(un);return}const c=i();if(!c)return;a();const d=[];if(o&&w5){const p=new ResizeObserver(()=>{window.requestAnimationFrame(a)});p.observe(c),d.push(()=>p.disconnect())}const f=()=>a();return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f,!0),d.push(()=>{window.removeEventListener("scroll",f),window.removeEventListener("resize",f)}),()=>{d.forEach(p=>p()),s(un)}},[t,i,a,o]),r}function y5(e={}){return v5({...e,element:fn()?document.body:null})}function x5({editor:e,overlayHeight:t=0}){const{height:n}=da(),o=y5({enabled:!0,throttleMs:100,useResizeObserver:!0});return u.useEffect(()=>{(()=>{if(!e)return;const{state:s,view:i}=e;if(!i.hasFocus())return;const{from:a}=s.selection,c=i.coordsAtPos(a);if(n<o.height&&c&&n-c.top<t){const f=Math.max(n/2,t),p=window.scrollY,C=c.top+p-f;window.scrollTo({top:Math.max(0,C),behavior:"smooth"})}})()},[e,t,n,o.height]),o}function k5({align:e,shortcutKeys:t=Ar[e]}){return l.jsx(R,{children:J({shortcutKeys:t})})}const pn=u.forwardRef(({editor:e,align:t,text:n,extensionName:o,attributeName:r="data-align",hideWhenUnavailable:s=!1,onAligned:i,showShortcut:a=!1,onClick:c,children:d,...f},p)=>{const{editor:h}=k(e),{isVisible:C,handleImageAlign:g,label:b,canAlign:m,isActive:w,Icon:v,shortcutKeys:y}=E5({editor:h,align:t,extensionName:o,attributeName:r,hideWhenUnavailable:s,onAligned:i}),x=u.useCallback(S=>{c?.(S),!S.defaultPrevented&&g()},[g,c]);return C?l.jsx(M,{type:"button",disabled:!m,variant:"ghost","data-active-state":w?"on":"off","data-disabled":!m,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":w,tooltip:b,onClick:x,...f,ref:p,children:d??l.jsxs(l.Fragment,{children:[l.jsx(v,{className:"tiptap-button-icon"}),n&&l.jsx("span",{className:"tiptap-button-text",children:n}),a?l.jsx(k5,{align:t,shortcutKeys:y}):null]})}):null});pn.displayName="ImageAlignButton";const qa=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M12 1C12.5523 1 13 1.44772 13 2V22C13 22.5523 12.5523 23 12 23C11.4477 23 11 22.5523 11 22V2C11 1.44772 11.4477 1 12 1Z",fill:"currentColor"}),l.jsx("path",{d:"M2 7C2 5.34315 3.34315 4 5 4H7C7.55228 4 8 4.44772 8 5C8 5.55228 7.55228 6 7 6H5C4.44772 6 4 6.44772 4 7V17C4 17.5523 4.44772 18 5 18H7C7.55228 18 8 18.4477 8 19C8 19.5523 7.55228 20 7 20H5C3.34315 20 2 18.6569 2 17V7Z",fill:"currentColor"}),l.jsx("path",{d:"M19 4C20.6569 4 22 5.34315 22 7V17C22 18.6569 20.6569 20 19 20H17C16.4477 20 16 19.5523 16 19C16 18.4477 16.4477 18 17 18H19C19.5523 18 20 17.5523 20 17V7C20 6.44772 19.5523 6 19 6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H19Z",fill:"currentColor"})]}));qa.displayName="AlignCenterVerticalIcon";const Ga=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 1C21.5523 1 22 1.44772 22 2V22C22 22.5523 21.5523 23 21 23C20.4477 23 20 22.5523 20 22V2C20 1.44772 20.4477 1 21 1Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 7C2 5.34315 3.34315 4 5 4H14C15.6569 4 17 5.34315 17 7V17C17 18.6569 15.6569 20 14 20H5C3.34315 20 2 18.6569 2 17V7ZM5 6C4.44772 6 4 6.44772 4 7V17C4 17.5523 4.44772 18 5 18H14C14.5523 18 15 17.5523 15 17V7C15 6.44772 14.5523 6 14 6H5Z",fill:"currentColor"})]}));Ga.displayName="AlignEndVerticalIcon";const Ka=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M4 2C4 1.44772 3.55228 1 3 1C2.44772 1 2 1.44772 2 2V22C2 22.5523 2.44772 23 3 23C3.55228 23 4 22.5523 4 22V2Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 4C8.34315 4 7 5.34315 7 7V17C7 18.6569 8.34315 20 10 20H19C20.6569 20 22 18.6569 22 17V7C22 5.34315 20.6569 4 19 4H10ZM9 7C9 6.44772 9.44772 6 10 6H19C19.5523 6 20 6.44772 20 7V17C20 17.5523 19.5523 18 19 18H10C9.44772 18 9 17.5523 9 17V7Z",fill:"currentColor"})]}));Ka.displayName="AlignStartVerticalIcon";const Ar={left:"alt+shift+l",center:"alt+shift+e",right:"alt+shift+r"},S5={left:Ka,center:qa,right:Ga},T5={left:"Image align left",center:"Image align center",right:"Image align right"};function Ir(e,t,n="image",o="data-align"){return!e||!e.isEditable||!_(e,[n])?!1:e.can().updateAttributes(n,{[o]:t})}function A5(e,t,n="image",o="data-align"){return!e||!e.isEditable||!_(e,[n])?!1:(e.getAttributes(n)[o]||"left")===t}function I5(e,t,n="image",o="data-align"){if(!e?.isEditable||!_(e,[n])||!Ir(e,t,n,o))return!1;try{const{selection:r}=e.state,s=r instanceof E.NodeSelection,i=s?r.from:r.$anchor.pos,a=e.chain().focus().updateAttributes(n,{[o]:t}).run();return a&&s&&e.commands.setNodeSelection(i),a}catch{return!1}}function L5(e){const{editor:t,hideWhenUnavailable:n,align:o,extensionName:r="image",attributeName:s="data-align"}=e;return!t||!t.isEditable?!1:n?_(t,[r])?Ir(t,o,r,s):!1:!0}function E5(e){const{editor:t,align:n,extensionName:o="image",attributeName:r="data-align",hideWhenUnavailable:s=!1,onAligned:i}=e,{editor:a}=k(t),c=re(),[d,f]=u.useState(!0),p=Ir(a,n,o,r),h=A5(a,n,o,r);u.useEffect(()=>{if(!a)return;const g=()=>{f(L5({editor:a,align:n,hideWhenUnavailable:s,extensionName:o,attributeName:r}))};return g(),a.on("selectionUpdate",g),()=>{a.off("selectionUpdate",g)}},[a,s,n,o,r]);const C=u.useCallback(()=>{if(!a)return!1;const g=I5(a,n,o,r);return g&&i?.(),g},[a,n,o,r,i]);return ue.useHotkeys(Ar[n],g=>{g.preventDefault(),C()},{enabled:d&&p,enableOnContentEditable:!c,enableOnFormTags:!0}),{isVisible:d,isActive:h,handleImageAlign:C,canAlign:p,label:T5[n],shortcutKeys:Ar[n],Icon:S5[n]}}const Ya=At.forwardRef(({editor:e,text:t,hideWhenUnavailable:n=!1,onSet:o,onClick:r,children:s,...i},a)=>{const{editor:c}=k(e),{isVisible:d,isActive:f,canToggle:p,handleSetCaption:h,label:C,Icon:g}=V5({editor:c,hideWhenUnavailable:n,onSet:o}),b=At.useCallback(m=>{r?.(m),!m.defaultPrevented&&h()},[h,r]);return d?l.jsx(M,{type:"button",variant:"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!p,"data-disabled":!p,"aria-label":C,tooltip:C,onClick:b,...i,ref:a,children:s??l.jsxs(l.Fragment,{children:[l.jsx(g,{className:"tiptap-button-icon"}),t&&l.jsx("span",{className:"tiptap-button-text",children:t})]})}):null});Ya.displayName="ImageCaptionButton";const ja=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 22C7 21.4477 7.44772 21 8 21H16C16.5523 21 17 21.4477 17 22C17 22.5523 16.5523 23 16 23H8C7.44772 23 7 22.5523 7 22Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 18C3 17.4477 3.44772 17 4 17H20C20.5523 17 21 17.4477 21 18C21 18.5523 20.5523 19 20 19H4C3.44772 19 3 18.5523 3 18Z",fill:"currentColor"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 5C3 3.34315 4.34315 2 6 2H18C19.6569 2 21 3.34315 21 5V11C21 12.6569 19.6569 14 18 14H6C4.34315 14 3 12.6569 3 11V5ZM6 4C5.44772 4 5 4.44772 5 5V11C5 11.5523 5.44772 12 6 12H18C18.5523 12 19 11.5523 19 11V5C19 4.44772 18.5523 4 18 4H6Z",fill:"currentColor"})]}));ja.displayName="ImageCaptionIcon";function Lr(e){return!e||!e.isEditable||!_(e,["image"])?!1:ie(e,["image"])}function M5(e){if(!e)return!1;try{const{selection:t}=e.state;if(!(t instanceof E.NodeSelection&&t.node.type.name==="image"))return!1;const o=t.node;return o.attrs.showCaption===!0||o.content.size>0}catch{return!1}}function N5(e){if(!e?.isEditable||!Lr(e))return!1;try{const{selection:t}=e.state;if(!(t instanceof E.NodeSelection&&t.node.type.name==="image")||!e.chain().focus().updateAttributes("image",{showCaption:!0}).run())return!1;const r=t.from;return e.chain().focus(r+1).selectTextblockEnd().run(),!0}catch{return!1}}function H5(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n?!t.isEditable||!_(t,["image"])?!1:Lr(t):!0:!1}function V5(e){const{editor:t,hideWhenUnavailable:n=!1,onSet:o}=e||{},{editor:r}=k(t),[s,i]=u.useState(!0),[a,c]=u.useState(!1),d=Lr(r);u.useEffect(()=>{if(!r)return;const p=()=>{i(H5({editor:r,hideWhenUnavailable:n})),c(M5(r))};return p(),r.on("selectionUpdate",p),()=>{r.off("selectionUpdate",p)}},[r,n]);const f=u.useCallback(()=>{if(!r)return!1;const p=N5(r);return p&&o?.(),p},[r,o]);return{isVisible:s,isActive:a,canToggle:d,handleSetCaption:f,label:"Caption",Icon:ja}}const Xa=u.memo(({className:e,...t})=>l.jsxs("svg",{width:"24",height:"24",className:e,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("path",{d:"M4 3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3V8C2 8.55228 2.44772 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41416L5.96091 6.45325C7.58323 4.88786 9.74725 4.00897 12.0018 4.00001C14.1229 4.0005 16.1569 4.8433 17.6568 6.34315C19.1571 7.84344 19.9999 9.87827 19.9999 12C19.9999 12.5523 20.4477 13 20.9999 13C21.5522 13 21.9999 12.5523 21.9999 12C21.9999 9.34784 20.9464 6.8043 19.071 4.92894C17.1956 3.05358 14.6521 2.00001 11.9999 2L11.9962 2.00001C9.22207 2.01045 6.5594 3.0929 4.5649 5.02104L4.55283 5.0329L4 5.58573V3Z",fill:"currentColor"}),l.jsx("path",{d:"M3 11C3.55228 11 4 11.4477 4 12C4 14.1217 4.84285 16.1566 6.34315 17.6569C7.84297 19.1567 9.87701 19.9995 11.998 20C14.2526 19.9911 16.4167 19.1122 18.039 17.5468L18.5858 17H16C15.4477 17 15 16.5523 15 16C15 15.4477 15.4477 15 16 15H21C21.5523 15 22 15.4477 22 16V21C22 21.5523 21.5523 22 21 22C20.4477 22 20 21.5523 20 21V18.4142L19.4471 18.9671L19.435 18.979C17.4405 20.9071 14.7779 21.9896 12.0038 22L12 22C9.34784 22 6.8043 20.9464 4.92893 19.0711C3.05357 17.1957 2 14.6522 2 12C2 11.4477 2.44772 11 3 11Z",fill:"currentColor"})]}));Xa.displayName="RefreshCcwIcon";function Ja({editor:e}){const{editor:t}=k(e),n=D(),o=ie(t,["image"]);return!t||!o?null:l.jsxs(l.Fragment,{children:[l.jsx(pn,{align:"left"}),l.jsx(pn,{align:"center"}),l.jsx(pn,{align:"right"}),l.jsx(ee,{}),l.jsx(Ya,{}),l.jsx(ee,{}),l.jsx(ai,{}),l.jsx(br,{icon:Xa,tooltip:n.replaceImage}),l.jsx(ee,{}),l.jsx(er,{})]})}const He={MAIN:"main",HIGHLIGHTER:"highlighter",LINK:"link"};function B5(e){const[t,n]=u.useState(He.MAIN);return u.useEffect(()=>{!e&&t!==He.MAIN&&n(He.MAIN)},[e,t]),{viewId:t,setViewId:n,isMainView:t===He.MAIN,showMainView:()=>n(He.MAIN),showView:o=>n(o)}}function D5(e){if(!e||!e.isEditable)return!1;const{selection:t}=e.state;return!t.empty}function U5(e){return{[He.HIGHLIGHTER]:{id:He.HIGHLIGHTER,title:e.textHighlighter,icon:l.jsx(Dt,{className:"tiptap-button-icon"}),content:l.jsx(fa,{}),mobileButton:t=>l.jsx(gr,{onClick:t}),desktopComponent:l.jsx(Ef,{}),shouldShow(t){return We(t)}},[He.LINK]:{id:He.LINK,title:e.linkEditor,icon:l.jsx(xt,{className:"tiptap-button-icon"}),content:l.jsx(Df,{}),mobileButton:t=>l.jsx(vr,{onClick:t}),desktopComponent:l.jsx(yr,{}),shouldShow(t){return xr(t)}}}}function O5(){return l.jsxs(l.Fragment,{children:[l.jsxs(ae,{children:[l.jsx(St,{action:"outdent",hideWhenUnavailable:!0}),l.jsx(St,{action:"indent",hideWhenUnavailable:!0})]}),l.jsx(Ce,{})]})}function P5(){return l.jsxs(l.Fragment,{children:[l.jsxs(ae,{children:[l.jsx(Ne,{align:"left",hideWhenUnavailable:!0}),l.jsx(Ne,{align:"center",hideWhenUnavailable:!0}),l.jsx(Ne,{align:"right",hideWhenUnavailable:!0}),l.jsx(Ne,{align:"justify",hideWhenUnavailable:!0})]}),l.jsx(Ce,{})]})}function W5(){return l.jsxs(l.Fragment,{children:[l.jsxs(ae,{children:[l.jsx(he,{type:"superscript",hideWhenUnavailable:!0}),l.jsx(he,{type:"subscript",hideWhenUnavailable:!0})]}),l.jsx(Ce,{})]})}function _5(){return l.jsxs(l.Fragment,{children:[l.jsxs(ae,{children:[l.jsx(he,{type:"bold",hideWhenUnavailable:!0}),l.jsx(he,{type:"italic",hideWhenUnavailable:!0}),l.jsx(he,{type:"strike",hideWhenUnavailable:!0}),l.jsx(he,{type:"code",hideWhenUnavailable:!0})]}),l.jsx(Ce,{})]})}function Z5(){const e=D(),{recentColors:t,isInitialized:n,addRecentColor:o}=mt(),r=()=>!n||t.length===0?null:l.jsxs(l.Fragment,{children:[l.jsxs($e,{children:[l.jsx(kt,{children:e.recentColors}),t.map(s=>l.jsx(pe,{asChild:!0,children:s.type==="text"?l.jsx(gt,{textColor:s.value,label:s.label,text:s.label,tooltip:s.label,onApplied:({color:i,label:a})=>o({type:"text",label:a,value:i})}):l.jsx(Re,{highlightColor:s.value,text:s.label,tooltip:s.label,onApplied:({color:i,label:a})=>o({type:"highlight",label:a,value:i})})},`${s.type}-${s.value}`))]}),l.jsx(ee,{orientation:"horizontal"})]});return l.jsxs(Va,{children:[l.jsx(Ba,{asChild:!0,children:l.jsxs(M,{variant:"ghost",children:[l.jsx(Qn,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:e.color}),l.jsx(Ct,{}),l.jsx(tt,{className:"tiptap-button-icon"})]})}),l.jsx(Ma,{children:l.jsxs(Da,{children:[r(),l.jsxs($e,{children:[l.jsx(kt,{children:e.textColor}),Vt.map(s=>l.jsx(pe,{asChild:!0,children:l.jsx(gt,{textColor:s.value,label:s.label,text:s.label,tooltip:s.label,onApplied:({color:i,label:a})=>o({type:"text",label:a,value:i})})},s.value))]}),l.jsx(ee,{orientation:"horizontal"}),l.jsxs($e,{children:[l.jsx(kt,{children:e.highlightColor}),et.map(s=>l.jsx(pe,{asChild:!0,children:l.jsx(Re,{highlightColor:s.value,text:s.label,tooltip:s.label,onApplied:({color:i,label:a})=>o({type:"highlight",label:a,value:i})})},s.value))]})]})})]})}function F5(){const e=D();return l.jsxs(Va,{children:[l.jsx(Ba,{asChild:!0,children:l.jsxs(M,{variant:"ghost",children:[l.jsx(pr,{className:"tiptap-button-icon"}),l.jsx("span",{className:"tiptap-button-text",children:e.turnInto}),l.jsx(Ct,{}),l.jsx(tt,{className:"tiptap-button-icon"})]})}),l.jsx(Ma,{children:l.jsx(Da,{children:l.jsx(Ua,{})})})]})}function z5({editor:e}){const t=re(),n=D();return l.jsxs(l.Fragment,{children:[l.jsxs($e,{children:[l.jsx(kt,{children:Ts(e,n)}),l.jsx(Z5,{}),l.jsx(F5,{}),l.jsx(pe,{asChild:!0,children:l.jsx(Di,{text:n.resetFormatting})})]}),l.jsx(ee,{orientation:"horizontal"}),l.jsxs($e,{children:[l.jsx(pe,{asChild:!0,children:l.jsx(gi,{text:n.duplicateNode,showShortcut:!t})}),l.jsx(pe,{asChild:!0,children:l.jsx(vi,{text:n.copyToClipboard,showShortcut:!t})}),l.jsx(pe,{asChild:!0,children:l.jsx(Mi,{text:n.copyAnchorLink,showShortcut:!t})})]}),l.jsx($e,{children:l.jsx(pe,{asChild:!0,children:l.jsx(er,{text:n.delete,showShortcut:!t})})})]})}function $5({editor:e}){return l.jsxs(Ea,{children:[l.jsx(Na,{asChild:!0,children:l.jsx(M,{variant:"ghost","data-appearance":"subdued",children:l.jsx(Nt,{className:"tiptap-button-icon"})})}),l.jsx(Ha,{children:l.jsx(z5,{editor:e})})]})}function q5({view:e,isMobile:t,onViewChange:n}){const o=e.id;return t?e.mobileButton?u.cloneElement(e.mobileButton(()=>n(o)),{key:e.id}):l.jsx(M,{onClick:()=>n(o),children:e.icon},e.id):e.desktopComponent?u.cloneElement(e.desktopComponent,{key:e.id}):null}function G5({toolbarViews:e,isMobile:t,onViewChange:n,editor:o}){const r=Object.values(e).filter(s=>s.shouldShow?s.shouldShow(o):!0);return r.length===0?null:l.jsxs(l.Fragment,{children:[r.map(s=>l.jsx(q5,{view:s,isMobile:t,onViewChange:n},s.id)),l.jsx(Ce,{})]})}function K5({editor:e,isMobile:t,toolbarViews:n,onViewChange:o}){const r=D(),s=D5(e),i=(e?.getText().length??0)>0;return l.jsxs(l.Fragment,{children:[l.jsxs(ae,{children:[l.jsx(cr,{}),l.jsx($5,{editor:e}),l.jsx(Ce,{})]}),(s||i)&&l.jsxs(l.Fragment,{children:[l.jsx(_5,{}),l.jsx(G5,{toolbarViews:n,isMobile:t,onViewChange:o,editor:e}),l.jsx(Ja,{}),l.jsx(W5,{}),l.jsx(P5,{}),l.jsx(O5,{}),l.jsxs(ae,{children:[l.jsx(br,{text:r.add}),l.jsx(Ce,{})]})]}),l.jsxs(ae,{children:[l.jsx(Tr,{direction:"down"}),l.jsx(Tr,{direction:"up"})]})]})}function Y5({view:e,onBack:t}){return l.jsxs(l.Fragment,{children:[l.jsx(ae,{children:l.jsxs(M,{variant:"ghost",onClick:t,children:[l.jsx(Un,{className:"tiptap-button-icon"}),e.icon]})}),l.jsx(Ce,{}),e.content]})}function j5({editor:e}){const{editor:t}=k(e),n=D(),o=re("max",480),r=u.useRef(null),s=B5(o),i=u.useMemo(()=>U5(n),[n]),a=s.isMainView?null:i[s.viewId],{height:c}=da(),d=x5({editor:t,overlayHeight:r.current?.getBoundingClientRect().height??0});return!o||!t||!t.isEditable?null:l.jsx(dn,{ref:r,style:{...o?{bottom:`calc(100% - ${c-d.y}px)`}:{}},children:s.isMainView?l.jsx(K5,{editor:t,isMobile:o,toolbarViews:i,onViewChange:s.showView}):a&&l.jsx(Y5,{view:a,onBack:s.showMainView})})}function X5(){const{editor:e}=k(),t=re("max",480),{lockDragHandle:n,commentInputVisible:o}=bn(e),{shouldShow:r}=z1({editor:e,isSelectionValid:Is,extraHideWhen:!!o});return n||t?null:l.jsx(Yt,{shouldShow:r,children:l.jsxs(dn,{variant:"floating",className:"omnibox-floating-toolbar",children:[l.jsx(ae,{children:l.jsx(Oa,{hideWhenUnavailable:!0,className:"omnibox-floating-toolbar-turn-into"})}),l.jsx(Ce,{}),l.jsxs(ae,{children:[l.jsx(he,{type:"bold",hideWhenUnavailable:!0}),l.jsx(he,{type:"italic",hideWhenUnavailable:!0}),l.jsx(he,{type:"underline",hideWhenUnavailable:!0}),l.jsx(he,{type:"strike",hideWhenUnavailable:!0}),l.jsx(he,{type:"code",hideWhenUnavailable:!0})]}),l.jsx(Ce,{}),l.jsx(ae,{children:l.jsx(Ja,{})}),l.jsxs(ae,{children:[l.jsx(yr,{autoOpenOnLinkActive:!1,hideWhenUnavailable:!0}),l.jsx(Td,{hideWhenUnavailable:!0})]}),l.jsx(R5,{hideWhenUnavailable:!0})]})})}function J5(e){if(!e)return!1;const t=["left","center","right","justify"].some(o=>an(e,o));return["superscript","subscript"].some(o=>sn(e,o))||t}function Q5(e){const{editor:t,hideWhenUnavailable:n}=e;return t?n&&!t.isActive("code")?J5(t):!!t?.isEditable:!1}function R5({editor:e,hideWhenUnavailable:t=!1,...n}){const{editor:o}=k(e),r=D(),[s,i]=u.useState(!1);return u.useEffect(()=>{if(!o)return;const a=()=>{i(Q5({editor:o,hideWhenUnavailable:t}))};return a(),o.on("selectionUpdate",a),()=>{o.off("selectionUpdate",a)}},[o,t]),!s||!o||!o.isEditable?null:l.jsxs(l.Fragment,{children:[l.jsx(Ce,{}),l.jsx(ae,{children:l.jsxs(Pt,{children:[l.jsx(Wt,{asChild:!0,children:l.jsx(M,{type:"button",variant:"ghost",role:"button",tabIndex:-1,"aria-label":r.moreOptions,tooltip:r.moreOptions,...n,children:l.jsx(Nt,{className:"tiptap-button-icon"})})}),l.jsx(_t,{side:"top",align:"end",alignOffset:4,sideOffset:4,asChild:!0,children:l.jsxs(dn,{variant:"floating",className:"omnibox-floating-toolbar",tabIndex:0,children:[l.jsxs(ae,{children:[l.jsx(he,{type:"superscript"}),l.jsx(he,{type:"subscript"})]}),l.jsx(Ce,{}),l.jsxs(ae,{children:[l.jsx(Ne,{align:"left"}),l.jsx(Ne,{align:"center"}),l.jsx(Ne,{align:"right"}),l.jsx(Ne,{align:"justify"})]}),l.jsx(Ce,{}),l.jsxs(ae,{children:[l.jsx(St,{action:"outdent"}),l.jsx(St,{action:"indent"})]})]})})]})})]})}function e0({className:e,maxShowCount:t=20,topOffset:n=0,...o}){const{tocContent:r,navigateToHeading:s,normalizeHeadingDepths:i}=Sn(),a=u.useRef(!1),c=u.useRef(null),[d,f]=u.useState(null),p=u.useMemo(()=>r??[],[r]),h=u.useMemo(()=>p.slice(0,t),[p,t]),C=u.useMemo(()=>i(h),[h,i]),g=u.useMemo(()=>{const L=new Map;return h.forEach((I,V)=>{L.set(I.id,C[V]??1)}),L},[h,C]),b=u.useMemo(()=>[...p].reverse().find(L=>L.isActive)??null,[p]),m=u.useMemo(()=>p.find(L=>L.isActive)?.id??null,[p]),w=u.useMemo(()=>d||(b?.id?b.id:m||p[0]?.id),[d,b,m,p]),v=u.useCallback((L,I)=>{L.preventDefault(),L.stopPropagation(),f(I.id),c.current=Date.now(),s(I,{topOffset:n})},[s,n]);u.useEffect(()=>{if(typeof window>"u"||a.current||!p.length)return;const L=window.location.hash.replace(/^#/,"");if(!L)return;const I=p.find(V=>V.id===L);I&&(f(I.id),a.current=!0)},[p]);const y=u.useRef(null),x=u.useRef(d);x.current=d,u.useEffect(()=>{if(typeof window>"u")return;const L=()=>{const V=Date.now(),K=c.current;K&&V-K<500||x.current!==null&&f(null)},I=y.current?Qr(y.current):null;return window.addEventListener("scroll",L,{passive:!0}),I&&!(I instanceof Window)&&I.addEventListener("scroll",L,{passive:!0}),()=>{window.removeEventListener("scroll",L),I&&!(I instanceof Window)&&I.removeEventListener("scroll",L)}},[]);const S=p.length>0;return l.jsx("div",{ref:y,className:z("toc-sidebar",e),...o,children:l.jsx("div",{className:"toc-sidebar-wrapper",children:l.jsxs("div",{className:"toc-sidebar-inner",children:[l.jsx("div",{className:"toc-sidebar-progress",children:h.map(L=>{const I=g.get(L.id)??1,V=w===L.id;return l.jsx("div",{className:z("toc-sidebar-progress-line",V&&"toc-sidebar-progress-line--active"),"data-depth":I,style:{"--toc-depth":I}},L.id)})}),l.jsx("nav",{className:z("toc-sidebar-nav",!S&&"toc-sidebar-nav--hidden"),"aria-label":"Table of contents",children:l.jsx("div",{className:"toc-sidebar-popover",children:h.map(L=>{const I=g.get(L.id)??1,V=w===L.id;return l.jsx("a",{href:`#${L.id}`,rel:"noopener noreferrer",className:z("toc-sidebar-item notranslate",V&&"toc-sidebar-item--active"),"data-depth":I,style:{"--toc-depth":I},onClick:K=>v(K,L),"aria-current":V?"location":void 0,children:L.textContent},L.id)})})})]})})})}const t0=we.Extension.create({name:"listNormalization",addKeyboardShortcuts(){const e=["bulletList","orderedList","taskList"];return{Backspace:({editor:n})=>{const{state:o,view:r}=n,{selection:s}=o,{$from:i,empty:a}=s;if(!a||i.parentOffset!==0)return!1;const c=i.parent;if(c.type.name!=="paragraph"||c.content.size>0)return!1;const d=i.depth-1;if(d<0)return!1;const f=i.node(d),p=i.index(d);if(p===0||p>=f.childCount-1)return!1;const h=f.child(p-1),C=f.child(p+1),g=e.includes(h.type.name),b=e.includes(C.type.name);if(!g||!b||h.type.name!==C.type.name)return!1;const m=i.before(d+1),w=i.after(d+1),v=o.doc.resolve(m-1),y=E.TextSelection.findFrom(v,-1,!0);if(!y)return!1;const x=y.from,S=o.tr;S.delete(m,w),Pr.canJoin(S.doc,m)&&S.join(m);const L=S.mapping.map(x);return S.setSelection(E.TextSelection.create(S.doc,L)),r.dispatch(S),!0}}}});function n0(e,t,n,o){const r=e.getAttribute("data-indent");if(r){const i=parseInt(r,10);if(!isNaN(i))return xn(i,t,n)}const s=["marginLeft","paddingLeft","textIndent"];for(const i of s){const a=e.style?.[i];if(a){const c=parseFloat(a);if(!isNaN(c)&&c>0&&o>0){const d=Math.round(c/o);return xn(d,t,n)}}}return 0}function hn(e,t){const{$from:n}=e.selection;for(let o=n.depth;o>0;o--){const r=n.node(o).type.name;if(t.has(r))return r}return null}function Qa(e,t,n,o){const{selection:r}=e,{$from:s}=r;if(!r.empty||hn(e,n)!==null)return!1;const i=s.parent;return!t.includes(i.type.name)||i.attrs.indent<=0?!1:o.onlyIfEmpty?i.content.size===0:s.parentOffset===0}const o0=new E.PluginKey("indent"),r0=we.Extension.create({name:"indent",addOptions(){return{types:["paragraph","heading","blockquote"],listItemTypes:["listItem","taskItem"],bypassAncestors:["tableCell","tableHeader"],minLevel:0,maxLevel:8,useStyle:!1,indentUnit:24}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:e=>n0(e,this.options.minLevel,this.options.maxLevel,this.options.indentUnit),renderHTML:e=>{const t=Number(e.indent)||0;if(t===0)return{};const n={"data-indent":String(t),style:`--tt-indent-level: ${t}`};return this.options.useStyle&&this.options.indentUnit>0&&(n.style=`--tt-indent-level: ${t}; margin-left: ${t*this.options.indentUnit}px`),n}}}}]},addCommands(){const e=new Set(this.options.listItemTypes),t=({state:n,tr:o},r)=>{const s=it(n.selection,this.options.types);return s.length===0?!1:yn(o,s,"indent",i=>xn(r(Number(i)||0),this.options.minLevel,this.options.maxLevel))};return{indent:()=>n=>{const o=hn(n.state,e);return o&&"sinkListItem"in n.commands?n.commands.sinkListItem(o):t(n,r=>r+1)},outdent:()=>n=>{const o=hn(n.state,e);return o&&"liftListItem"in n.commands?n.commands.liftListItem(o):t(n,r=>r-1)},setIndent:n=>o=>t(o,()=>n),unsetIndent:()=>n=>t(n,()=>0)}},addProseMirrorPlugins(){const e=this.options.types;return[new E.Plugin({key:o0,appendTransaction(t,n,o){if(!t.some(w=>w.getMeta("uiEvent")==="drop"))return null;const{doc:s,selection:i}=o,{$from:a,$to:c}=i,d=a.depth>0?a.depth:1,f=a.before(d),p=s.resolve(f),h=p.node(p.depth),C=p.index(p.depth);let g=0;if(C>0)g=h.child(C-1).attrs.indent||0;else{const w=c.depth>0?c.depth:1,v=c.after(w),y=s.resolve(v),x=y.indexAfter(y.depth),S=y.node(y.depth);x<S.childCount&&(g=S.child(x).attrs.indent||0)}const{tr:b}=o;let m=!1;return s.nodesBetween(a.pos,c.pos,(w,v)=>(!e.includes(w.type.name)||(w.attrs.indent||0)===g||(b.setNodeMarkup(v,void 0,{...w.attrs,indent:g},w.marks),m=!0),!1)),m?b:null}})]},addKeyboardShortcuts(){const e=new Set(this.options.listItemTypes),t=new Set(this.options.bypassAncestors),n=r=>{if(t.size===0)return!1;const{$from:s}=r.selection;for(let i=s.depth;i>0;i--)if(t.has(s.node(i).type.name))return!0;return!1},o=()=>{const r=this.editor.state;if(n(r))return!1;if(hn(r,e)!==null)return!0;const{$from:s}=r.selection;return this.options.types.includes(s.parent.type.name)};return{Tab:()=>o()?(this.editor.commands.indent(),!0):!1,"Shift-Tab":()=>o()?(this.editor.commands.outdent(),!0):!1,Enter:({editor:r})=>Qa(r.state,this.options.types,e,{onlyIfEmpty:!0})?r.commands.outdent():!1,Backspace:({editor:r})=>Qa(r.state,this.options.types,e,{onlyIfEmpty:!1})?r.commands.outdent():!1}}}),l0=we.Extension.create({name:"tripleClickBlockSelection",addProseMirrorPlugins(){return[new E.Plugin({key:new E.PluginKey("tripleClickBlockSelection"),props:{handleTripleClick:(e,t)=>{const{state:n}=e,{doc:o}=n,r=o.resolve(t);let s=r.depth;for(;s>0&&!r.node(s).isTextblock;)s--;if(s===0||r.node(s).type.spec.selectable===!1)return!1;const a=r.before(s);return e.dispatch(n.tr.setSelection(E.NodeSelection.create(o,a))),!0}}})]}}),s0={type:"doc",content:[{type:"heading",attrs:{id:"11111111-1111-4111-8111-111111111111",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"11111111-1111-4111-8111-111111111111",level:1},content:[{type:"text",text:"Local Omnibox editor"}]},{type:"blockquote",attrs:{id:"22222222-2222-4222-8222-222222222222",backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"paragraph",attrs:{id:"33333333-3333-4333-8333-333333333333",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",marks:[{type:"bold"}],text:"A clean base for your own editor package."},{type:"hardBreak"},{type:"text",text:"It keeps the writing, formatting, slash menu, table, and block editing pieces ready for your package work."}]}]},{type:"paragraph",attrs:{id:"44444444-4444-4444-8444-444444444444",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Type "},{type:"text",marks:[{type:"code"}],text:"/"},{type:"text",text:" to open the command menu, select text for the floating toolbar, or drag blocks from the left handle."}]},{type:"heading",attrs:{id:"55555555-5555-4555-8555-555555555555",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"55555555-5555-4555-8555-555555555555",level:2},content:[{type:"text",text:"Writing basics"}]},{type:"codeBlock",attrs:{id:"66666666-6666-4666-8666-666666666666",language:null},content:[{type:"text",text:`# Headings
|
|
13
13
|
- Lists
|
|
14
14
|
> Quotes
|
|
15
|
-
\`Inline code\``}]},{type:"bulletList",attrs:{id:"77777777-7777-4777-8777-777777777777",backgroundColor:null},content:[{type:"listItem",content:[{type:"paragraph",attrs:{id:"88888888-8888-4888-8888-888888888888",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Format text with bold, italic, links, colors, and highlights."}]}]},{type:"listItem",content:[{type:"paragraph",attrs:{id:"99999999-9999-4999-8999-999999999999",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Use local undo and redo from the header toolbar."}]}]}]},{type:"heading",attrs:{id:"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",level:2},content:[{type:"text",text:"Checklist"}]},{type:"taskList",attrs:{id:"bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb",backgroundColor:null},content:[{type:"taskItem",attrs:{checked:!0},content:[{type:"paragraph",attrs:{id:"cccccccc-cccc-4ccc-8ccc-cccccccccccc",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Start from the official Tiptap template"}]}]},{type:"taskItem",attrs:{checked:!0},content:[{type:"paragraph",attrs:{id:"dddddddd-dddd-4ddd-8ddd-dddddddddddd",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Trim optional product features from the base template"}]}]},{type:"taskItem",attrs:{checked:!1},content:[{type:"paragraph",attrs:{id:"eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Extract the editor into a reusable package"}]}]}]},{type:"heading",attrs:{id:"ffffffff-ffff-4fff-8fff-ffffffffffff",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"ffffffff-ffff-4fff-8fff-ffffffffffff",level:2},content:[{type:"text",text:"Simple table"}]},{type:"table",attrs:{id:"12121212-1212-4121-8121-121212121212"},content:[{type:"tableRow",content:[{type:"tableHeader",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"13131313-1313-4131-8131-131313131313",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Area"}]}]},{type:"tableHeader",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"14141414-1414-4141-8141-141414141414",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Status"}]}]}]},{type:"tableRow",content:[{type:"tableCell",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"15151515-1515-4151-8151-151515151515",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Local editing"}]}]},{type:"tableCell",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"16161616-1616-4161-8161-161616161616",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Ready"}]}]}]}]},{type:"heading",attrs:{id:"17171717-1717-4171-8171-171717171717",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"17171717-1717-4171-8171-171717171717",level:2},content:[{type:"text",text:"Table of contents"}]},{type:"tocNode",attrs:{id:"18181818-1818-4181-8181-181818181818",backgroundColor:null,topOffset:null,maxShowCount:null,showTitle:!0}}]};function Ja(e){return!!(e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="string")}function Qa(e,t){return typeof e=="string"?jt(e,t):Array.isArray(e)?{type:"doc",content:e}:Ja(e)&&e.type==="doc"?e:Ja(e)?{type:"doc",content:[e]}:jt("",t)}function l0(e,t,n){const o=Qa(t,n);return e&&JSON.stringify(e)===JSON.stringify(o)?null:o}const Ra={color:"#958df1",name:"Anonymous"};function Lr(e){return!!(e&&typeof e=="object"&&"document"in e&&e.document)}function s0(e){return!Lr(e)}function i0(e){return Lr(e)?!1:void 0}function a0(e,t){return!e||typeof e!="object"?t??Ra:e.user??t??Ra}function c0(e,t,n){return t.type==="blockMath"?e.commands.updateBlockMath({latex:n,pos:t.pos}):e.commands.updateInlineMath({latex:n,pos:t.pos})}function d0({editor:e,target:t,onOpenChange:n}){const o=D(),r=u.useRef(null),[s,i]=u.useState("");u.useEffect(()=>{if(!t){i("");return}i(t.latex),window.requestAnimationFrame(()=>{r.current?.focus(),r.current?.select()})},[t]);const a=s.trim(),c=()=>n(!1),d=()=>{!t||!a||(c0(e,t,a),c())};return l.jsx(Kt,{editor:e,shouldShow:!!t,onOpenChange:n,closeOnEscape:!0,resetTextSelectionOnClose:!1,zIndex:1002,floatingOptions:{placement:"bottom"},className:"tiptap-math-editor",role:"dialog","aria-label":o.editFormula,children:l.jsxs("div",{className:"tiptap-math-editor__body",children:[l.jsx(Tl,{ref:r,className:"tiptap-math-editor__input",value:s,placeholder:"LaTeX",onChange:p=>i(p.target.value),onKeyDown:p=>{p.key==="Escape"&&(p.preventDefault(),c()),p.key==="Enter"&&(p.preventDefault(),d())}}),l.jsxs("div",{className:"tiptap-math-editor__actions",children:[l.jsx("button",{type:"button",className:"tiptap-math-editor__button","aria-label":o.closeFormulaEditor,onClick:c,children:l.jsx(Po,{className:"tiptap-math-editor__icon"})}),l.jsx("button",{type:"button",className:"tiptap-math-editor__button","aria-label":o.applyFormula,disabled:!a,onClick:d,children:l.jsx(Aa,{className:"tiptap-math-editor__icon"})})]})]})})}function u0({text:e="Connecting..."}){return l.jsx("div",{className:"omnibox-editor-loading",children:l.jsxs("div",{className:"omnibox-editor-loading__content",children:[l.jsxs("svg",{className:"omnibox-editor-loading__spinner",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[l.jsx("circle",{className:"omnibox-editor-loading__spinner-track",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{className:"omnibox-editor-loading__spinner-path",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),l.jsx("div",{className:"omnibox-editor-loading__text",children:e})]})})}function f0(e){return typeof e=="boolean"?e:!!e?.enabled}function p0(e){return typeof e=="boolean"?void 0:e?.onSubmit}function h0({ai:e,mathEditTarget:t,onMathEditOpenChange:n}){const{editor:o}=u.useContext(G.EditorContext),{mentionUsers:r}=rn(),{isDragging:s}=gn(o),[i,a]=u.useState(null),c=u.useRef(null),d=u.useRef(null),p=u.useRef(""),f=u.useRef(""),h=u.useRef("ask"),C="var(--tt-brand-color-500)",g=f0(e),b=p0(e),m=D();if(F1(),u.useEffect(()=>{if(!o)return;const A=N=>{o.storage.uiState?.isDragging&&N.stopPropagation()};return document.addEventListener("dragenter",A),document.addEventListener("dragover",A),document.addEventListener("dragleave",A),document.addEventListener("drop",A),()=>{document.removeEventListener("dragenter",A),document.removeEventListener("dragover",A),document.removeEventListener("dragleave",A),document.removeEventListener("drop",A)}},[o]),!o)return null;const w=o;w.storage.aiGenerationWidget.labels={aiIsWriting:m.aiIsWriting,aiReviewPrompt:m.aiReviewPrompt,apply:m.apply,discard:m.discard,submitAiPrompt:m.submitAiPrompt,stopAiGeneration:m.stopAiGeneration,tryAgain:m.tryAgain};const v=()=>{const A=d.current;A&&w.chain().focus().deleteRange({from:A.from,to:A.to}).run(),d.current=null,p.current="",w.commands.clearAiGenerationWidget()},y=(A,N=d.current?.to)=>{N!=null&&w.commands.setAiGenerationWidget({pos:N,status:A})},x=A=>{const N=d.current;if(!N)return N;const U=ri(A),H=w.state.doc.content.size;w.chain().focus().insertContentAt({from:N.from,to:N.to},U).run();const W=w.state.doc.content.size,P={from:N.from,to:Math.max(N.from,N.to+W-H)},q=w.schema.marks.textStyle;return q&&P.to>P.from&&w.view.dispatch(w.state.tr.addMark(P.from,P.to,q.create({color:C}))),d.current=P,y("writing",P.to),P},S=A=>{const N=d.current;if(!N)return N;const U=ri(A),H=w.state.doc.content.size;w.chain().focus().insertContentAt(N.to,U).run();const W=w.state.doc.content.size,P={from:N.from,to:Math.max(N.from,N.to+W-H)},q=w.schema.marks.textStyle;return q&&P.to>P.from&&w.view.dispatch(w.state.tr.addMark(P.from,P.to,q.create({color:C}))),d.current=P,y("writing",P.to),P},L=A=>{if(!A)return;const N=d.current;if(!N)return;p.current+=A,w.chain().focus().insertContentAt(N.to,{type:"text",marks:[{type:"textStyle",attrs:{color:C}}],text:A}).run();const U={from:N.from,to:N.to+A.length};d.current=U,y("writing",U.to)},I=()=>{const A=d.current;if(!A||A.to===A.from)return A;const N=p.current;return N.trim()?x(o4(N)):A},V=()=>{const A=I();if((A?.to===A?.from?"idle":"reviewing")==="reviewing"&&A){y("reviewing",A.to);return}w.commands.clearAiGenerationWidget()},K=()=>{const A=d.current,N=w.schema.marks.textStyle;A&&N&&w.view.dispatch(w.state.tr.removeMark(A.from,A.to,N)),d.current=null,p.current="",w.commands.clearAiGenerationWidget()},se=()=>{c.current?.abort(),c.current=null,V()},O=(A,N="")=>{a(null),c.current?.abort(),c.current=new AbortController;const H=d.current?.from??w.state.selection.to;if(v(),h.current=A,f.current=N,d.current={from:H,to:H},p.current="",y("writing",H),!b){w.commands.clearAiGenerationWidget();return}(async()=>{try{await b({action:A,editor:w,onChunk:L,onContent:W=>{S(W)},onContentPreview:W=>{x(W)},prompt:N,signal:c.current?.signal}),V()}catch(W){if(W instanceof DOMException&&W.name==="AbortError"){V();return}throw w.commands.clearAiGenerationWidget(),W}finally{c.current=null}})()},Y=(A=f.current)=>{O(h.current,A)};return w.storage.aiGenerationWidget.onApply=K,w.storage.aiGenerationWidget.onDiscard=()=>{v()},w.storage.aiGenerationWidget.onRetry=()=>Y(),w.storage.aiGenerationWidget.onStop=se,w.storage.aiGenerationWidget.onSubmitInstruction=A=>Y(A),l.jsxs(G.EditorContent,{editor:o,role:"presentation",className:"omnibox-editor-content",style:{cursor:s?"grabbing":"auto"},children:[l.jsx(ff,{}),l.jsx(Bu,{}),l.jsx(Yu,{users:r}),l.jsx(h7,{config:{aiEnabled:g,onAiAction:A=>{if(A==="continue_writing"){O(A);return}c.current?.abort(),c.current=new AbortController,a(A)}}}),g?l.jsx(b7,{action:i,editor:o,open:!!i,signal:c.current?.signal,onOpenChange:A=>{A||a(null)},onSubmit:A=>{O(A.action,A.prompt)}}):null,l.jsx(d0,{editor:o,target:t,onOpenChange:n}),l.jsx(Y5,{}),i1.createPortal(l.jsx(K5,{}),document.body)]})}function e1(e,t){return t??e}function C0(e){return typeof e=="number"?`${e}px`:e}function g0(e){return!e||typeof e!="object"?null:e.provider}function b0(e){const t=e?.awareness?.getStates?.();return t?Array.from(t.entries()).map(([n,o])=>{const r=o&&typeof o=="object"&&"user"in o?o.user:null;return!r||typeof r!="object"?null:Hs({clientId:n,...r})}).filter(n=>!!n):[]}function m0(e){const t=e?.storage.collaborationCaret?.users;return Array.isArray(t)?t.map(n=>Hs(n)).filter(n=>!!n):[]}function t1(e,t){return e.type.name!=="blockMath"&&e.type.name!=="inlineMath"?null:{type:e.type.name,pos:t,latex:String(e.attrs.latex||"")}}function n1(e,t){e.view.dispatch(e.state.tr.setSelection(E.NodeSelection.create(e.state.doc,t)))}function w0({collaboration:e}){const{setOnlineUsers:t}=rn(),{editor:n}=u.useContext(G.EditorContext);return u.useEffect(()=>{if(!n){t([]);return}const o=g0(e),r=()=>{const s=b0(o);t(s.length?s:m0(n))};return r(),o?.awareness?.on?.("update",r),o?.awareness?.on?.("change",r),()=>{o?.awareness?.off?.("update",r),o?.awareness?.off?.("change",r),t([])}},[e,n,t]),null}function v0(e){const{ai:t,collaboration:n,editable:o=!0,placeholder:r,content:s=r0,linkBase:i,locale:a,translations:c,theme:d,onUpdate:p,imageUpload:f=O1,imageUploadMaxSize:h=bn,imageUploadLimit:C=3,onImageUploadError:g,onImageUploadSuccess:b,contentWidth:m,variant:w="page",showHeader:v,showToc:y}=e,{setTocContent:x}=kn(),{user:S}=rn(),L=w==="embedded",I=e1(!L,v),V=e1(!L,y),K=C0(m),se=Ie(a,c),O=r??se.placeholder,Y=Qa(s,{linkBase:i}),A=u.useRef(Y),N=Lr(n),U=g??(Z=>console.error(`${se.uploadFailed}:`,Z)),[H,W]=u.useState(null),P=u.useRef(null),q=G.useEditor({immediatelyRender:!1,content:Y,editable:o,onUpdate:({editor:Z})=>{const le=Z.getJSON();p?.({editor:Z,json:le,html:Z.getHTML(),markdown:Xt(le)})},editorProps:{attributes:{class:"omnibox-editor"},clipboardTextSerializer:Z=>wi(Z)},extensions:[Mr.StarterKit.configure({codeBlock:!1,horizontalRule:!1,dropcursor:{width:2},link:{openOnClick:!1},undoRedo:i0(n)}),...N&&n&&typeof n=="object"?[a1.configure({document:n.document}),...n.provider?[c1.configure({provider:n.provider,user:a0(n,S)})]:[]]:[],z1,wc.configure({i18n:se}),C1.TextAlign.configure({types:["heading","paragraph"]}),Hr.Placeholder.configure({placeholder:O,emptyNodeClass:"is-empty with-slash"}),d1.Mention,Br.Emoji.configure({emojis:Br.gitHubEmojis.filter(Z=>!Z.name.includes("regional")),forceFallbackImages:!0}),Xc.configure({table:{resizable:!0,cellMinWidth:120}}),Q1.configure({types:["paragraph","heading","blockquote","taskList","bulletList","orderedList","tableCell","tableHeader","tocNode"]}),R1,Nr.TextStyle,Vr.Mathematics.configure({blockOptions:{onClick:(Z,le)=>{const be=P.current;be?.isEditable&&(n1(be,le),W(t1(Z,le)))}},inlineOptions:{onClick:(Z,le)=>{const be=P.current;be?.isEditable&&(n1(be,le),W(t1(Z,le)))}}}),p1.Superscript,h1.Subscript,n0,Nr.Color,Tt.TaskList,Tt.TaskItem.configure({nested:!0}),f1.Highlight.configure({multicolor:!0}),Hr.Selection,X1.configure({i18n:se}),Dr.TableOfContents.configure({getIndex:Dr.getHierarchicalIndexes,onUpdate(Z){x(Z)}}),d2,R5,o0,Bc.configure({accept:"image/*",maxSize:h,limit:C,upload:f,onError:U,onSuccess:b}),g1.UniqueID.configure({types:["table","paragraph","bulletList","orderedList","taskList","heading","blockquote","codeBlock","tocNode"]}),u1.Typography,M1,yc,lc.configure({topOffset:48})]});return u.useEffect(()=>{P.current=q},[q]),u.useEffect(()=>{if(!q||!s0(n))return;const Z=l0(A.current,s,{linkBase:i});Z&&(A.current=Z,q.commands.setContent(Z,{emitUpdate:!1}))},[n,s,q,i]),q?l.jsx("div",{"data-variant":w,"data-theme":d,style:K?{"--omnibox-editor-content-width":K}:void 0,className:$("omnibox-editor-root omnibox-editor-wrapper",d==="dark"&&"dark",L?"omnibox-editor-wrapper--embedded":"omnibox-editor-wrapper--page"),children:l.jsx(qr.Provider,{value:se,children:l.jsxs(G.EditorContext.Provider,{value:{editor:q},children:[l.jsx(w0,{collaboration:n}),I?l.jsx(Sf,{}):null,l.jsxs("div",{className:$("omnibox-editor-layout",L&&"omnibox-editor-layout--embedded"),children:[l.jsx(h0,{ai:t,mathEditTarget:H,onMathEditOpenChange:Z=>{Z||W(null)}}),V?l.jsx(Q5,{topOffset:48}):null]}),l.jsx(Su,{}),l.jsx(us,{}),l.jsx(yu,{editor:q}),l.jsx(Xd,{showResizeHandles:!0,cellMenu:Z=>l.jsx(Cs,{editor:Z.editor,onMouseDown:le=>Z.onResizeStart?.("br")(le)})})]})})}):l.jsx(u0,{text:se.loading})}function y0({ai:e,collaboration:t,mentionUsers:n,user:o,editable:r=!0,placeholder:s,content:i,linkBase:a,locale:c,translations:d,theme:p,contentWidth:f,variant:h,showHeader:C,showToc:g,onUpdate:b,imageUpload:m,imageUploadMaxSize:w,imageUploadLimit:v,onImageUploadError:y,onImageUploadSuccess:x}){const S=t&&typeof t=="object"?t.user:void 0;return l.jsx(Cf,{user:o??S,mentionUsers:n,children:l.jsx(oc,{children:l.jsx(v0,{editable:r,ai:e,collaboration:t,placeholder:s,content:i,linkBase:a,locale:c,translations:d,theme:p,contentWidth:f,variant:h,showHeader:C,showToc:g,onUpdate:b,imageUpload:m,imageUploadMaxSize:w,imageUploadLimit:v,onImageUploadError:y,onImageUploadSuccess:x})})})}B.OmniboxEditor=y0,B.contentToMarkdown=K7,B.contentToTiptapJson=jt,B.getEditorTranslations=Ie,B.htmlTableToTiptapNode=qs,B.markdownToTiptapJson=yt,B.markdownWithHtmlTablesToTiptapJson=qo,B.tiptapJsonToMarkdown=Xt,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})}));
|
|
15
|
+
\`Inline code\``}]},{type:"bulletList",attrs:{id:"77777777-7777-4777-8777-777777777777",backgroundColor:null},content:[{type:"listItem",content:[{type:"paragraph",attrs:{id:"88888888-8888-4888-8888-888888888888",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Format text with bold, italic, links, colors, and highlights."}]}]},{type:"listItem",content:[{type:"paragraph",attrs:{id:"99999999-9999-4999-8999-999999999999",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Use local undo and redo from the header toolbar."}]}]}]},{type:"heading",attrs:{id:"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",level:2},content:[{type:"text",text:"Checklist"}]},{type:"taskList",attrs:{id:"bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb",backgroundColor:null},content:[{type:"taskItem",attrs:{checked:!0},content:[{type:"paragraph",attrs:{id:"cccccccc-cccc-4ccc-8ccc-cccccccccccc",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Start from the official Tiptap template"}]}]},{type:"taskItem",attrs:{checked:!0},content:[{type:"paragraph",attrs:{id:"dddddddd-dddd-4ddd-8ddd-dddddddddddd",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Trim optional product features from the base template"}]}]},{type:"taskItem",attrs:{checked:!1},content:[{type:"paragraph",attrs:{id:"eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Extract the editor into a reusable package"}]}]}]},{type:"heading",attrs:{id:"ffffffff-ffff-4fff-8fff-ffffffffffff",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"ffffffff-ffff-4fff-8fff-ffffffffffff",level:2},content:[{type:"text",text:"Simple table"}]},{type:"table",attrs:{id:"12121212-1212-4121-8121-121212121212"},content:[{type:"tableRow",content:[{type:"tableHeader",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"13131313-1313-4131-8131-131313131313",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Area"}]}]},{type:"tableHeader",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"14141414-1414-4141-8141-141414141414",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Status"}]}]}]},{type:"tableRow",content:[{type:"tableCell",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"15151515-1515-4151-8151-151515151515",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Local editing"}]}]},{type:"tableCell",attrs:{backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,colspan:1,rowspan:1,colwidth:null},content:[{type:"paragraph",attrs:{id:"16161616-1616-4161-8161-161616161616",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null},content:[{type:"text",text:"Ready"}]}]}]}]},{type:"heading",attrs:{id:"17171717-1717-4171-8171-171717171717",textAlign:null,backgroundColor:null,nodeTextAlign:null,nodeVerticalAlign:null,"data-toc-id":"17171717-1717-4171-8171-171717171717",level:2},content:[{type:"text",text:"Table of contents"}]},{type:"tocNode",attrs:{id:"18181818-1818-4181-8181-181818181818",backgroundColor:null,topOffset:null,maxShowCount:null,showTitle:!0}}]};function Ra(e){return!!(e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="string")}function e1(e,t){return typeof e=="string"?Xt(e,t):Array.isArray(e)?{type:"doc",content:e}:Ra(e)&&e.type==="doc"?e:Ra(e)?{type:"doc",content:[e]}:Xt("",t)}function i0(e,t,n){const o=e1(t,n);return e&&JSON.stringify(e)===JSON.stringify(o)?null:o}const t1={color:"#958df1",name:"Anonymous"};function Er(e){return!!(e&&typeof e=="object"&&"document"in e&&e.document)}function a0(e){return!Er(e)}function c0(e){return Er(e)?!1:void 0}function d0(e,t){return!e||typeof e!="object"?t??t1:e.user??t??t1}function u0(e,t,n){return t.type==="blockMath"?e.commands.updateBlockMath({latex:n,pos:t.pos}):e.commands.updateInlineMath({latex:n,pos:t.pos})}function f0({editor:e,target:t,onOpenChange:n}){const o=D(),r=u.useRef(null),[s,i]=u.useState("");u.useEffect(()=>{if(!t){i("");return}i(t.latex),window.requestAnimationFrame(()=>{r.current?.focus(),r.current?.select()})},[t]);const a=s.trim(),c=()=>n(!1),d=()=>{!t||!a||(u0(e,t,a),c())};return l.jsx(Yt,{editor:e,shouldShow:!!t,onOpenChange:n,closeOnEscape:!0,resetTextSelectionOnClose:!1,zIndex:1002,floatingOptions:{placement:"bottom"},className:"tiptap-math-editor",role:"dialog","aria-label":o.editFormula,children:l.jsxs("div",{className:"tiptap-math-editor__body",children:[l.jsx(Al,{ref:r,className:"tiptap-math-editor__input",value:s,placeholder:"LaTeX",onChange:f=>i(f.target.value),onKeyDown:f=>{f.key==="Escape"&&(f.preventDefault(),c()),f.key==="Enter"&&(f.preventDefault(),d())}}),l.jsxs("div",{className:"tiptap-math-editor__actions",children:[l.jsx("button",{type:"button",className:"tiptap-math-editor__button","aria-label":o.closeFormulaEditor,onClick:c,children:l.jsx(Wo,{className:"tiptap-math-editor__icon"})}),l.jsx("button",{type:"button",className:"tiptap-math-editor__button","aria-label":o.applyFormula,disabled:!a,onClick:d,children:l.jsx(La,{className:"tiptap-math-editor__icon"})})]})]})})}function p0({text:e="Connecting..."}){return l.jsx("div",{className:"omnibox-editor-loading",children:l.jsxs("div",{className:"omnibox-editor-loading__content",children:[l.jsxs("svg",{className:"omnibox-editor-loading__spinner",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[l.jsx("circle",{className:"omnibox-editor-loading__spinner-track",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{className:"omnibox-editor-loading__spinner-path",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),l.jsx("div",{className:"omnibox-editor-loading__text",children:e})]})})}function h0(e){return typeof e=="boolean"?e:!!e?.enabled}function C0(e){return typeof e=="boolean"?void 0:e?.onSubmit}function g0({ai:e,mathEditTarget:t,onMathEditOpenChange:n}){const{editor:o}=u.useContext(G.EditorContext),{mentionUsers:r}=ln(),{isDragging:s}=bn(o),[i,a]=u.useState(null),c=u.useRef(null),d=u.useRef(null),f=u.useRef(""),p=u.useRef(""),h=u.useRef("ask"),C="var(--tt-brand-color-500)",g=h0(e),b=C0(e),m=D();if($1(),u.useEffect(()=>{if(!o)return;const A=N=>{o.storage.uiState?.isDragging&&N.stopPropagation()};return document.addEventListener("dragenter",A),document.addEventListener("dragover",A),document.addEventListener("dragleave",A),document.addEventListener("drop",A),()=>{document.removeEventListener("dragenter",A),document.removeEventListener("dragover",A),document.removeEventListener("dragleave",A),document.removeEventListener("drop",A)}},[o]),!o)return null;const w=o;w.storage.aiGenerationWidget.labels={aiIsWriting:m.aiIsWriting,aiReviewPrompt:m.aiReviewPrompt,apply:m.apply,discard:m.discard,submitAiPrompt:m.submitAiPrompt,stopAiGeneration:m.stopAiGeneration,tryAgain:m.tryAgain};const v=()=>{const A=d.current;A&&w.chain().focus().deleteRange({from:A.from,to:A.to}).run(),d.current=null,f.current="",w.commands.clearAiGenerationWidget()},y=(A,N=d.current?.to)=>{N!=null&&w.commands.setAiGenerationWidget({pos:N,status:A})},x=A=>{const N=d.current;if(!N)return N;const U=si(A),H=w.state.doc.content.size;w.chain().focus().insertContentAt({from:N.from,to:N.to},U).run();const W=w.state.doc.content.size,P={from:N.from,to:Math.max(N.from,N.to+W-H)},q=w.schema.marks.textStyle;return q&&P.to>P.from&&w.view.dispatch(w.state.tr.addMark(P.from,P.to,q.create({color:C}))),d.current=P,y("writing",P.to),P},S=A=>{const N=d.current;if(!N)return N;const U=si(A),H=w.state.doc.content.size;w.chain().focus().insertContentAt(N.to,U).run();const W=w.state.doc.content.size,P={from:N.from,to:Math.max(N.from,N.to+W-H)},q=w.schema.marks.textStyle;return q&&P.to>P.from&&w.view.dispatch(w.state.tr.addMark(P.from,P.to,q.create({color:C}))),d.current=P,y("writing",P.to),P},L=A=>{if(!A)return;const N=d.current;if(!N)return;f.current+=A,w.chain().focus().insertContentAt(N.to,{type:"text",marks:[{type:"textStyle",attrs:{color:C}}],text:A}).run();const U={from:N.from,to:N.to+A.length};d.current=U,y("writing",U.to)},I=()=>{const A=d.current;if(!A||A.to===A.from)return A;const N=f.current;return N.trim()?x(l4(N)):A},V=()=>{const A=I();if((A?.to===A?.from?"idle":"reviewing")==="reviewing"&&A){y("reviewing",A.to);return}w.commands.clearAiGenerationWidget()},K=()=>{const A=d.current,N=w.schema.marks.textStyle;A&&N&&w.view.dispatch(w.state.tr.removeMark(A.from,A.to,N)),d.current=null,f.current="",w.commands.clearAiGenerationWidget()},le=()=>{c.current?.abort(),c.current=null,V()},O=(A,N="")=>{a(null),c.current?.abort(),c.current=new AbortController;const H=d.current?.from??w.state.selection.to;if(v(),h.current=A,p.current=N,d.current={from:H,to:H},f.current="",y("writing",H),!b){w.commands.clearAiGenerationWidget();return}(async()=>{try{await b({action:A,editor:w,onChunk:L,onContent:W=>{S(W)},onContentPreview:W=>{x(W)},prompt:N,signal:c.current?.signal}),V()}catch(W){if(W instanceof DOMException&&W.name==="AbortError"){V();return}throw w.commands.clearAiGenerationWidget(),W}finally{c.current=null}})()},Y=(A=p.current)=>{O(h.current,A)};return w.storage.aiGenerationWidget.onApply=K,w.storage.aiGenerationWidget.onDiscard=()=>{v()},w.storage.aiGenerationWidget.onRetry=()=>Y(),w.storage.aiGenerationWidget.onStop=le,w.storage.aiGenerationWidget.onSubmitInstruction=A=>Y(A),l.jsxs(G.EditorContent,{editor:o,role:"presentation",className:"omnibox-editor-content",style:{cursor:s?"grabbing":"auto"},children:[l.jsx(hf,{}),l.jsx(Uu,{}),l.jsx(Xu,{users:r}),l.jsx(g7,{config:{aiEnabled:g,onAiAction:A=>{if(A==="continue_writing"){O(A);return}c.current?.abort(),c.current=new AbortController,a(A)}}}),g?l.jsx(w7,{action:i,editor:o,open:!!i,signal:c.current?.signal,onOpenChange:A=>{A||a(null)},onSubmit:A=>{O(A.action,A.prompt)}}):null,l.jsx(f0,{editor:o,target:t,onOpenChange:n}),l.jsx(X5,{}),c1.createPortal(l.jsx(j5,{}),document.body)]})}function n1(e,t){return t??e}function b0(e){return typeof e=="number"?`${e}px`:e}function m0(e){return!e||typeof e!="object"?null:e.provider}function w0(e){const t=e?.awareness?.getStates?.();return t?Array.from(t.entries()).map(([n,o])=>{const r=o&&typeof o=="object"&&"user"in o?o.user:null;return!r||typeof r!="object"?null:Bs({clientId:n,...r})}).filter(n=>!!n):[]}function v0(e){const t=e?.storage.collaborationCaret?.users;return Array.isArray(t)?t.map(n=>Bs(n)).filter(n=>!!n):[]}function o1(e,t){return e.type.name!=="blockMath"&&e.type.name!=="inlineMath"?null:{type:e.type.name,pos:t,latex:String(e.attrs.latex||"")}}function r1(e,t){e.view.dispatch(e.state.tr.setSelection(E.NodeSelection.create(e.state.doc,t)))}function y0({collaboration:e}){const{setOnlineUsers:t}=ln(),{editor:n}=u.useContext(G.EditorContext);return u.useEffect(()=>{if(!n){t([]);return}const o=m0(e),r=()=>{const s=w0(o);t(s.length?s:v0(n))};return r(),o?.awareness?.on?.("update",r),o?.awareness?.on?.("change",r),()=>{o?.awareness?.off?.("update",r),o?.awareness?.off?.("change",r),t([])}},[e,n,t]),null}function x0(e){const{ai:t,collaboration:n,editable:o=!0,placeholder:r,content:s=s0,linkBase:i,locale:a,translations:c,theme:d,onUpdate:f,imageUpload:p=W1,imageUploadMaxSize:h=mn,imageUploadLimit:C=3,onImageUploadError:g,onImageUploadSuccess:b,contentWidth:m,variant:w="page",showHeader:v,showToc:y}=e,{setTocContent:x}=Sn(),{user:S}=ln(),L=w==="embedded",I=n1(!L,v),V=n1(!L,y),K=b0(m),le=Ie(a,c),O=r??le.placeholder,Y=e1(s,{linkBase:i}),A=u.useRef(Y),N=Er(n),U=g??($=>console.error(`${le.uploadFailed}:`,$)),[H,W]=u.useState(null),P=u.useRef(null),q=G.useEditor({immediatelyRender:!1,content:Y,editable:o,onUpdate:({editor:$})=>{const se=$.getJSON();f?.({editor:$,json:se,html:$.getHTML(),markdown:Jt(se)})},editorProps:{attributes:{class:"omnibox-editor"},clipboardTextSerializer:$=>yi($)},extensions:[Nr.StarterKit.configure({codeBlock:!1,horizontalRule:!1,dropcursor:{width:2},link:{openOnClick:!1},undoRedo:c0(n)}),...N&&n&&typeof n=="object"?[d1.configure({document:n.document}),...n.provider?[u1.configure({provider:n.provider,user:d0(n,S)})]:[]]:[],q1,yc.configure({i18n:le}),b1.TextAlign.configure({types:["heading","paragraph"]}),Vr.Placeholder.configure({placeholder:O,emptyNodeClass:"is-empty with-slash"}),f1.Mention,Dr.Emoji.configure({emojis:Dr.gitHubEmojis.filter($=>!$.name.includes("regional")),forceFallbackImages:!0}),Qc.configure({table:{resizable:!0,cellMinWidth:120}}),ec.configure({types:["paragraph","heading","blockquote","taskList","bulletList","orderedList","tableCell","tableHeader","tocNode"]}),tc,Hr.TextStyle,Br.Mathematics.configure({blockOptions:{onClick:($,se)=>{const be=P.current;be?.isEditable&&(r1(be,se),W(o1($,se)))}},inlineOptions:{onClick:($,se)=>{const be=P.current;be?.isEditable&&(r1(be,se),W(o1($,se)))}}}),C1.Superscript,g1.Subscript,r0,Hr.Color,Tt.TaskList,Tt.TaskItem.configure({nested:!0}),h1.Highlight.configure({multicolor:!0}),Vr.Selection,Q1.configure({i18n:le}),Ur.TableOfContents.configure({getIndex:Ur.getHierarchicalIndexes,onUpdate($){x($)}}),f2,t0,l0,Uc.configure({accept:"image/*",maxSize:h,limit:C,upload:p,onError:U,onSuccess:b}),m1.UniqueID.configure({types:["table","paragraph","bulletList","orderedList","taskList","heading","blockquote","codeBlock","tocNode"]}),p1.Typography,H1,kc,ic.configure({topOffset:48})]});return u.useEffect(()=>{P.current=q},[q]),u.useEffect(()=>{if(!q||!a0(n))return;const $=i0(A.current,s,{linkBase:i});$&&(A.current=$,q.commands.setContent($,{emitUpdate:!1}))},[n,s,q,i]),q?l.jsx("div",{"data-variant":w,"data-theme":d,style:K?{"--omnibox-editor-content-width":K}:void 0,className:z("omnibox-editor-root omnibox-editor-wrapper",d==="dark"&&"dark",L?"omnibox-editor-wrapper--embedded":"omnibox-editor-wrapper--page"),children:l.jsx(Gr.Provider,{value:le,children:l.jsxs(G.EditorContext.Provider,{value:{editor:q},children:[l.jsx(y0,{collaboration:n}),I?l.jsx(Af,{}):null,l.jsxs("div",{className:z("omnibox-editor-layout",L&&"omnibox-editor-layout--embedded"),children:[l.jsx(g0,{ai:t,mathEditTarget:H,onMathEditOpenChange:$=>{$||W(null)}}),V?l.jsx(e0,{topOffset:48}):null]}),l.jsx(Au,{}),l.jsx(ps,{}),l.jsx(ku,{editor:q}),l.jsx(Qd,{showResizeHandles:!0,cellMenu:$=>l.jsx(bs,{editor:$.editor})})]})})}):l.jsx(p0,{text:le.loading})}function k0({ai:e,collaboration:t,mentionUsers:n,user:o,editable:r=!0,placeholder:s,content:i,linkBase:a,locale:c,translations:d,theme:f,contentWidth:p,variant:h,showHeader:C,showToc:g,onUpdate:b,imageUpload:m,imageUploadMaxSize:w,imageUploadLimit:v,onImageUploadError:y,onImageUploadSuccess:x}){const S=t&&typeof t=="object"?t.user:void 0;return l.jsx(bf,{user:o??S,mentionUsers:n,children:l.jsx(lc,{children:l.jsx(x0,{editable:r,ai:e,collaboration:t,placeholder:s,content:i,linkBase:a,locale:c,translations:d,theme:f,contentWidth:p,variant:h,showHeader:C,showToc:g,onUpdate:b,imageUpload:m,imageUploadMaxSize:w,imageUploadLimit:v,onImageUploadError:y,onImageUploadSuccess:x})})})}B.OmniboxEditor=k0,B.contentToMarkdown=j7,B.contentToTiptapJson=Xt,B.getEditorTranslations=Ie,B.htmlTableToTiptapNode=Ks,B.markdownToTiptapJson=yt,B.markdownWithHtmlTablesToTiptapJson=Go,B.tiptapJsonToMarkdown=Jt,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})}));
|