@import-ai/omnibox-editor 0.0.4 → 0.0.5

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.
@@ -9,7 +9,7 @@
9
9
  `);return z7(t)?{language:"echarts",code:t}:$7(t)?{language:"mermaid",code:t}:null}function z7(e){const t=e.trim();return!t.startsWith("{")||!t.endsWith("}")?!1:/"?(series|xAxis|yAxis|tooltip|legend|grid|title)"?\s*:/.test(t)}function $7(e){return/^(mindmap|flowchart|graph|sequenceDiagram|stateDiagram|erDiagram)\b/m.test(e.trim())}function q7(e){return typeof e=="string"?e.trim().toLowerCase():""}function G7(e){let t=e;for(let n=0;n<10;n+=1){const o=t.replace(/\\n/g,`
10
10
  `).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\+(["'`{}[\](),:])/g,"$1");if(o===t)break;t=o}return t}function $o(e){return e.type==="doc"?{...e,content:e.content?.length?e.content:[Rs()]}:{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:zo(String(r.attrs.href),t)}}:r);return n?.href&&(n.href=zo(String(n.href),t)),n?.src&&(n.src=zo(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=_7(W7(P7(e))),o=vt(ni(ti($o(_o.parse(n)))),t);return Fo(t)&&Zo("markdownToTiptapJson",e,o),o}function qo(e,t){const n=Y7(e);if(!n.some(s=>s.type==="table"))return yt(e,t);const o=n.flatMap(s=>{if(s.type==="table"){const i=qs(s.value);return i?[i]:ei(s.value,t)}return ei(s.value,t)}),r=vt({type:"doc",content:o.length?o:[Rs()]},t);return Fo(t)&&Zo("markdownWithHtmlTablesToTiptapJson",e,r),r}function jt(e,t){if(typeof e!="string")return vt($o(e),t);const n=e.trim();if(!n)return yt("",t);try{const o=JSON.parse(n);if(typeof o=="string")return qo(o,t);if(o?.type==="doc"&&Array.isArray(o.content))return vt(o,t)}catch{}return qo(e,t)}function Xt(e,t){const n=n4(e);return Fo(t)&&Zo("tiptapJsonToMarkdown",e,n),n}function K7(e,t){return Xt(jt(e,t),t)}function Y7(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 ei(e,t){return e.trim()?(yt(e,t).content||[]).filter(n=>!j7(n)):[]}function j7(e){return e.type==="paragraph"&&!e.content?.length}function ti(e){return e.type==="table"?X7(e):{...e,...e.content?{content:e.content.map(t=>ti(t))}:{}}}function ni(e){return e.type==="codeBlock"&&V7.has(q7(e.attrs?.language))?{...e,...e.content?{content:e.content.map(t=>t.type==="text"&&typeof t.text=="string"?{...t,text:G7(t.text)}:t)}:{}}:{...e,...e.content?{content:e.content.map(t=>ni(t))}:{}}}function X7(e){const t=e.content||[],n=J7(t);if(!n)return e;const o=Q7(t,n),r=R7(o,n);return{...e,content:r}}function J7(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=>!t4(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 Q7(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,p)=>p===t.fixedColumnCount?Ko(d,{colspan:t.groupColumnCount}):Ko(d,{rowspan:2}));return[{...n,content:c},{...o,content:a},...r]}function R7(e,t){const n=[];let o=[];const r=()=>{if(!o.length)return;const s=Math.max(...o.map((i,a)=>a===0?0:Go(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,p)=>p<s?Ko(d,{rowspan:o.length}):d)});return}if(a>0){const d=Go(c,t);n.push({...i,content:e4(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=Go(i,t);(!o.length||a===0)&&r(),o.push(s)}),r(),n}function Go(e,t){const n=e.findIndex(o=>!nt(o));return n>0?Math.min(n,t.fixedColumnCount):oi(Yo(e[0]))?Math.min(2,t.fixedColumnCount):oi(Yo(e[1]))?Math.min(1,t.fixedColumnCount):0}function e4(e,t){if(t<=0)return e;const n=[...e];for(let o=0;o<t;o+=1)n.pop();return n}function Ko(e,t){return{...e,attrs:{...e.attrs,...t}}}function nt(e){return!Yo(e).trim()}function t4(e){return e?.type==="tableCell"||e?.type==="tableHeader"}function Yo(e){return e&&e.content?.map(t=>t.content?.map(n=>n.text||"").join("")||"").join("")||""}function oi(e){return/^\s*\d+(?:\s*[×xX*]\s*\d+){1,}/.test(e)}function n4(e){return Gs(e)?e.type==="doc"?(e.content||[]).map(jo).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",children:[l.jsx(ae,{children:l.jsx(Da,{hideWhenUnavailable:!0})}),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",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
+ `):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
13
13
  - Lists
14
14
  > Quotes
15
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"})}));