@lyfie/luthor 2.3.5 → 2.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/{ExtensiveEditor-B6-CSbLk.d.ts → ExtensiveEditor-B25Uedf2.d.ts} +1 -0
  2. package/dist/{chunk-ZOJRS76F.js → chunk-DOJY2XR6.js} +1 -1
  3. package/dist/{chunk-2SROC2VV.js → chunk-HSXFJCQA.js} +1 -1
  4. package/dist/{chunk-CVPFQYT5.js → chunk-QR6IHW2C.js} +1 -1
  5. package/dist/{chunk-KONCQ6HU.js → chunk-RLHHVHV7.js} +1 -1
  6. package/dist/{chunk-PS7U4ZTC.js → chunk-TID3K24V.js} +1 -1
  7. package/dist/{chunk-GWK276NY.js → chunk-TTLFSMFF.js} +1 -1
  8. package/dist/{chunk-P62SLPUX.js → chunk-U3MVQLAN.js} +1 -1
  9. package/dist/{chunk-WDHLBTRY.js → chunk-WU54BL4Y.js} +3 -3
  10. package/dist/{index-Gx4quPv5.d.ts → index-CUB1ColU.d.ts} +1 -1
  11. package/dist/index.css +1 -1
  12. package/dist/index.d.ts +4 -4
  13. package/dist/index.js +1 -1
  14. package/dist/presets/chat-window/index.d.ts +1 -1
  15. package/dist/presets/chat-window/index.js +1 -1
  16. package/dist/presets/email-compose/index.d.ts +1 -1
  17. package/dist/presets/email-compose/index.js +1 -1
  18. package/dist/presets/extensive/index.d.ts +2 -2
  19. package/dist/presets/extensive/index.js +1 -1
  20. package/dist/presets/md-text/index.d.ts +1 -1
  21. package/dist/presets/md-text/index.js +1 -1
  22. package/dist/presets/notes/index.d.ts +1 -1
  23. package/dist/presets/notes/index.js +1 -1
  24. package/dist/presets/notion-like/index.d.ts +1 -1
  25. package/dist/presets/notion-like/index.js +1 -1
  26. package/dist/presets/rich-text-box/index.d.ts +1 -1
  27. package/dist/presets/rich-text-box/index.js +1 -1
  28. package/dist/presets/simple-text/index.d.ts +1 -1
  29. package/dist/presets/simple-text/index.js +1 -1
  30. package/package.json +2 -2
@@ -1,3 +1,3 @@
1
- import {a}from'./chunk-MDSRHDWB.js';import {ImageExtension,TableExtension,IframeEmbedExtension,YouTubeEmbedExtension,ContextMenuExtension,CommandPaletteExtension,SlashCommandExtension,EmojiExtension,DraggableBlockExtension,LinkExtension,textColorExtension,textHighlightExtension,createCustomNodeExtension,createEditorSystem,mergeThemes,defaultLuthorTheme,createEditorThemeStyleVars,FloatingToolbarExtension,FontFamilyExtension,FontSizeExtension,LineHeightExtension,codeExtension,codeIntelligenceExtension,boldExtension,italicExtension,underlineExtension,strikethroughExtension,subscriptExtension,superscriptExtension,horizontalRuleExtension,listExtension,historyExtension,blockFormatExtension,codeFormatExtension,tabIndentExtension,enterKeyBehaviorExtension,RichText,clearLexicalSelection,resolveLinkNodeKeyFromAnchor}from'@lyfie/luthor-headless';import Sr,{forwardRef,useState,useMemo,useEffect,useRef,useImperativeHandle,createElement,useLayoutEffect,useCallback}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var Ie=["h1","h2","h3","h4","h5","h6"],yl={sections:[{items:["fontFamily","fontSize","lineHeight","textColor","textHighlight","bold","italic","underline","strikethrough","subscript","superscript","code","link"]},{items:["blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify","codeBlock"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["horizontalRule"]},{items:["table"]},{items:["image"]},{items:["emoji"]},{items:["embed"]},{items:["undo","redo"]},{items:["commandPalette"]},{items:["themeToggle"]}]},Ot={sections:[{items:["fontFamily","fontSize","lineHeight"]},{items:["bold","italic","underline","strikethrough","textColor","textHighlight"]},{items:["subscript","superscript","code","link"]},{items:["blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["table","image","emoji","embed","horizontalRule"]},{items:["codeBlock"]},{items:["undo","redo"]},{items:["commandPalette","themeToggle"]}]};function _n(e){if(!(e instanceof Element))return false;if(e.closest('[contenteditable="true"]'))return true;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"}function $n(e,t){return _n(e.target)?xo(t):false}function xo(e){let t=e.key.toLowerCase();return !(!!e.ctrlKey||!!e.metaKey)||e.altKey?false:t==="b"||t==="i"||t==="u"||t==="k"||(t==="z"||t==="y")}function Eo(e){return typeof e.setCodeLanguage=="function"&&typeof e.autoDetectCodeLanguage=="function"}function Jn(e){return typeof e.toggleSubscript=="function"}function qn(e){return typeof e.toggleSuperscript=="function"}function Yn(e){return typeof e.insertIframeEmbed=="function"}function Gn(e){return typeof e.insertYouTubeEmbed=="function"}function Qn(e){return typeof e.insertEmoji=="function"}function Wn(e){return e.slice(1)}function Xn(e){switch(e){case "h1":return "Convert to large heading";case "h2":return "Convert to medium heading";case "h3":return "Convert to small heading";case "h4":return "Convert to heading level 4";case "h5":return "Convert to heading level 5";case "h6":return "Convert to heading level 6"}}function Zn(e){if(!e||e.length===0)return [...Ie];let t=new Set,n=[];for(let o of e)!Ie.includes(o)||t.has(o)||(t.add(o),n.push(o));return n.length>0?n:[...Ie]}function Gt(e,t){return nr(Qt(t),t?.shortcutConfig).filter(o=>!o.condition||o.condition(e))}function _(e,t){return typeof e[t]=="function"}function Nt(e){if(!e||e.length===0)return new Set;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return new Set(t)}function er(e){if(!e)return {allowlist:new Set,denylist:new Set};if(Array.isArray(e)){let n=[];for(let o of e)for(let[l,r]of Object.entries(o))r&&n.push(l);return {allowlist:Nt(n),denylist:new Set}}let t=e;return {allowlist:Nt(t.allowlist),denylist:Nt(t.denylist)}}function To(e){let t=e.key.trim();return t?{key:t,ctrlKey:!!e.ctrlKey,metaKey:!!e.metaKey,shiftKey:!!e.shiftKey,altKey:!!e.altKey,preventDefault:e.preventDefault}:null}function tr(e){if(e===false||e===null)return [];let t=Array.isArray(e)?e:[e],n=[];for(let o of t){let l=To(o);l&&n.push(l);}return n}function or(e){return [e.key.toLowerCase(),e.ctrlKey?"ctrl":"",e.metaKey?"meta":"",e.shiftKey?"shift":"",e.altKey?"alt":""].join(":")}function nr(e,t){if(!t)return [...e];let n=Nt(t.disabledCommandIds),o=t.bindings,l=t.preventNativeConflicts!==false,r=t.preventCollisions!==false,i=new Set;return e.filter(d=>!n.has(d.id)).map(d=>{let c=d.shortcuts?[...d.shortcuts]:void 0;if(!!o&&Object.prototype.hasOwnProperty.call(o,d.id)&&o){let h=o[d.id],b=h===void 0?[]:tr(h);c=b.length>0?b:void 0;}if(c&&c.length>0){let h=[];for(let b of c){let m=To(b);if(!m||l&&xo(m))continue;let p=or(m);r&&i.has(p)||(i.add(p),h.push(m));}c=h.length>0?h:void 0;}return {...d,shortcuts:c}})}function Qt(e){let t=e?.isFeatureEnabled??(()=>true),n=Zn(e?.headingOptions),o=e?.paragraphLabel?.trim()||"Paragraph",l=n.map(r=>{let i=Wn(r);return {id:`block.heading${i}`,label:`Heading ${i}`,description:Xn(r),category:"Block",action:a=>a.toggleHeading?.(r),shortcuts:[{key:i,ctrlKey:true,altKey:true}],keywords:["heading",r],condition:a=>t("blockFormat")&&_(a,"toggleHeading")}});return [{id:"format.bold",label:"Toggle Bold",description:"Make text bold or remove bold formatting",category:"Format",action:r=>r.toggleBold?.(),shortcuts:[{key:"b",ctrlKey:true}],keywords:["bold","strong","format"],condition:r=>t("bold")&&_(r,"toggleBold")},{id:"format.italic",label:"Toggle Italic",description:"Make text italic or remove italic formatting",category:"Format",action:r=>r.toggleItalic?.(),shortcuts:[{key:"i",ctrlKey:true}],keywords:["italic","emphasis","format"],condition:r=>t("italic")&&_(r,"toggleItalic")},{id:"format.underline",label:"Toggle Underline",description:"Add or remove underline formatting",category:"Format",action:r=>r.toggleUnderline?.(),shortcuts:[{key:"u",ctrlKey:true}],keywords:["underline","format"],condition:r=>t("underline")&&_(r,"toggleUnderline")},{id:"format.strikethrough",label:"Toggle Strikethrough",description:"Add or remove strikethrough formatting",category:"Format",action:r=>r.toggleStrikethrough?.(),keywords:["strikethrough","format"],condition:r=>t("strikethrough")&&_(r,"toggleStrikethrough")},{id:"format.subscript",label:"Toggle Subscript",description:"Format text as subscript",category:"Format",action:r=>r.toggleSubscript?.(),keywords:["subscript","format"],condition:r=>t("subscript")&&Jn(r)},{id:"format.superscript",label:"Toggle Superscript",description:"Format text as superscript",category:"Format",action:r=>r.toggleSuperscript?.(),keywords:["superscript","format"],condition:r=>t("superscript")&&qn(r)},{id:"format.code",label:"Toggle Inline Code",description:"Format text as inline code",category:"Format",action:r=>r.formatText?.("code"),shortcuts:[{key:"`",ctrlKey:true}],keywords:["code","inline","format"],condition:r=>t("codeFormat")&&_(r,"formatText")},{id:"block.paragraph",label:o,description:"Convert to paragraph",category:"Block",action:r=>r.toggleParagraph?.(),shortcuts:[{key:"0",ctrlKey:true,altKey:true}],keywords:["paragraph","text"],condition:r=>t("blockFormat")&&_(r,"toggleParagraph")},...l,{id:"block.quote",label:"Quote",description:"Convert to blockquote",category:"Block",action:r=>r.toggleQuote?.(),keywords:["quote","blockquote"],condition:r=>t("blockFormat")&&_(r,"toggleQuote")},{id:"block.align-left",label:"Align Left",description:"Align selected blocks to the left",category:"Block",action:r=>r.setTextAlignment?.("left"),keywords:["align","left","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.align-center",label:"Align Center",description:"Center-align selected blocks",category:"Block",action:r=>r.setTextAlignment?.("center"),keywords:["align","center","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.align-right",label:"Align Right",description:"Align selected blocks to the right",category:"Block",action:r=>r.setTextAlignment?.("right"),keywords:["align","right","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.align-justify",label:"Justify",description:"Justify selected blocks",category:"Block",action:r=>r.setTextAlignment?.("justify"),keywords:["align","justify","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.codeblock",label:"Code Block",description:"Convert to code block",category:"Block",action:r=>r.toggleCodeBlock?.(),shortcuts:[{key:"`",ctrlKey:true,shiftKey:true}],keywords:["code","block"],condition:r=>t("code")&&_(r,"toggleCodeBlock")},{id:"block.code-language",label:"Set Code Language",description:"Set language for selected code block",category:"Block",action:r=>{if(!r.setCodeLanguage)return;let i=prompt("Code language (e.g. ts, css, python):")?.trim();i&&r.setCodeLanguage(i);},keywords:["code","language","syntax"],condition:r=>t("codeIntelligence")&&Eo(r)},{id:"block.code-language.auto",label:"Auto-Detect Code Language",description:"Detect language from selected code block",category:"Block",action:r=>{r.autoDetectCodeLanguage?.();},keywords:["code","language","auto","detect"],condition:r=>t("codeIntelligence")&&Eo(r)},{id:"list.bullet",label:"Bullet List",description:"Create or toggle bullet list",category:"List",action:r=>r.toggleUnorderedList?.(),shortcuts:[{key:"l",ctrlKey:true,shiftKey:true}],keywords:["list","bullet"],condition:r=>t("list")&&_(r,"toggleUnorderedList")},{id:"list.numbered",label:"Numbered List",description:"Create or toggle numbered list",category:"List",action:r=>r.toggleOrderedList?.(),shortcuts:[{key:"l",ctrlKey:true,altKey:true}],keywords:["list","numbered"],condition:r=>t("list")&&_(r,"toggleOrderedList")},{id:"list.check",label:"Checklist",description:"Create or toggle checklist",category:"List",action:r=>r.toggleCheckList?.(),shortcuts:[{key:"x",ctrlKey:true,shiftKey:true}],keywords:["list","check","todo","task"],condition:r=>t("list")&&_(r,"toggleCheckList")},{id:"link.insert",label:"Insert Link",description:"Insert or edit a link",category:"Insert",action:r=>r.insertLink?.(),shortcuts:[{key:"k",ctrlKey:true}],keywords:["link","url"],condition:r=>t("link")&&_(r,"insertLink")},{id:"link.remove",label:"Remove Link",description:"Remove link formatting",category:"Format",action:r=>r.removeLink?.(),shortcuts:[{key:"k",ctrlKey:true,shiftKey:true}],keywords:["unlink","remove","link"],condition:r=>t("link")&&_(r,"removeLink")},{id:"insert.horizontal-rule",label:"Insert Horizontal Rule",description:"Insert a horizontal line separator",category:"Insert",action:r=>r.insertHorizontalRule?.(),keywords:["horizontal","rule","hr","divider","separator"],condition:r=>t("horizontalRule")&&_(r,"insertHorizontalRule")},{id:"insert.image",label:"Insert Image",description:"Insert an image from URL",category:"Insert",action:r=>{let i=prompt("Enter image URL:");if(i){let a=prompt("Enter alt text:")||"";r.insertImage?.({src:i,alt:a});}},keywords:["image","photo"],condition:r=>t("image")&&_(r,"insertImage")},{id:"insert.gif",label:"Insert GIF",description:"Insert an animated GIF from URL",category:"Insert",action:r=>{let i=prompt("Enter GIF URL:");i&&r.insertImage?.({src:i,alt:"GIF"});},keywords:["gif","animated","image"],condition:r=>t("image")&&_(r,"insertImage")},{id:"insert.emoji",label:"Insert Emoji",description:"Insert an emoji character",category:"Insert",action:r=>{let i=prompt("Enter emoji or shortcode (example :sparkles:):")?.trim();if(!i||typeof r.insertEmoji!="function")return;let a=i.match(/^:([a-z0-9_+-]+):$/i);if(a){let d=a[1];if(!d)return;if(typeof r.resolveEmojiShortcode=="function"){let c=r.resolveEmojiShortcode(d);if(c?.emoji){r.insertEmoji(c.emoji);return}}else if(typeof r.getEmojiSuggestions=="function"){let[c]=r.getEmojiSuggestions(d);if(c?.emoji){r.insertEmoji(c.emoji);return}}}r.insertEmoji(i);},keywords:["emoji","reaction","symbol","smile"],condition:r=>t("emoji")&&Qn(r)},{id:"insert.table",label:"Insert Table",description:"Insert a 3x3 table",category:"Insert",action:r=>r.insertTable?.({rows:3,columns:3,includeHeaders:true}),keywords:["table","grid"],condition:r=>t("table")&&_(r,"insertTable")},{id:"insert.iframe",label:"Insert iframe",description:"Insert an iframe embed from URL",category:"Insert",action:r=>{if(typeof r.insertIframeEmbed!="function")return;let i=prompt("Enter iframe URL:");i&&r.insertIframeEmbed(i);},keywords:["iframe","embed","url"],condition:r=>t("iframeEmbed")&&Yn(r)},{id:"insert.youtube",label:"Insert YouTube Video",description:"Insert an embedded YouTube video",category:"Insert",action:r=>{if(typeof r.insertYouTubeEmbed!="function")return;let i=prompt("Enter YouTube URL:");i&&r.insertYouTubeEmbed(i);},keywords:["youtube","video","embed"],condition:r=>t("youTubeEmbed")&&Gn(r)},{id:"edit.undo",label:"Undo",description:"Undo the last action",category:"Edit",action:r=>r.undo?.(),shortcuts:[{key:"z",ctrlKey:true}],keywords:["undo","revert"],condition:r=>t("history")&&_(r,"undo")},{id:"edit.redo",label:"Redo",description:"Redo the last undone action",category:"Edit",action:r=>r.redo?.(),shortcuts:[{key:"y",ctrlKey:true},{key:"z",ctrlKey:true,shiftKey:true}],keywords:["redo","repeat"],condition:r=>t("history")&&_(r,"redo")},{id:"palette.show",label:"Show Command Palette",description:"Open the command palette",category:"View",action:r=>r.showCommandPalette?.(),shortcuts:[{key:"p",ctrlKey:true,shiftKey:true}],keywords:["command","palette"],condition:r=>t("commandPalette")&&_(r,"showCommandPalette")}]}function So(e,t){let n=t?.commandPaletteShortcutOnly===true;return Gt(e,t).filter(o=>!n||!!o.shortcuts&&o.shortcuts.length>0).map(o=>({id:o.id,label:o.label,description:o.description,category:o.category,action:()=>o.action(e),keywords:o.keywords,shortcut:o.shortcuts?.[0]?Io(o.shortcuts[0]):void 0}))}function Lo(e,t){let n=new Set(["block.paragraph","block.quote","block.codeblock"]),o=a=>a.category==="Insert"||a.category==="List"?true:a.category==="Block"?a.id.startsWith("block.heading")?true:n.has(a.id):false,{allowlist:l,denylist:r}=er(t?.slashCommandVisibility),i=l.size>0;return Gt(e,t).filter(o).filter(a=>r.has(a.id)?false:i?l.has(a.id):true).map(a=>({id:a.id,label:a.label,description:a.description,category:a.category,action:()=>a.action(e),keywords:a.keywords,shortcut:a.shortcuts?.[0]?Io(a.shortcuts[0]):void 0}))}function Io(e){let t=[];return e.ctrlKey&&t.push("Ctrl"),e.metaKey&&t.push("Cmd"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),t.push(e.key.toUpperCase()),t.join("+")}function Fo(e,t=document.body,n){let o=Gt(e,n),l=r=>{let i=typeof n?.scope=="function"?n.scope():n?.scope;if(!(i&&r.target instanceof Node&&!i.contains(r.target))){for(let a of o)if(a.shortcuts){for(let d of a.shortcuts)if(!(n?.shortcutConfig?.preventNativeConflicts!==false&&$n(r,d))&&r.key.toLowerCase()===d.key.toLowerCase()&&!!r.ctrlKey==!!d.ctrlKey&&!!r.metaKey==!!d.metaKey&&!!r.shiftKey==!!d.shiftKey&&!!r.altKey==!!d.altKey){d.preventDefault!==false&&r.preventDefault(),(!a.condition||a.condition(e))&&a.action(e);return}}}};return t.addEventListener("keydown",l),()=>t.removeEventListener("keydown",l)}function w(e,t){let n=forwardRef(function({size:l=24,strokeWidth:r=2,...i},a){return jsx("svg",{ref:a,xmlns:"http://www.w3.org/2000/svg",width:l,height:l,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...i,children:t})});return n.displayName=e,n}var Ht=w("BoldIcon",jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})),Mt=w("ItalicIcon",jsxs(Fragment,{children:[jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})),zt=w("UnderlineIcon",jsxs(Fragment,{children:[jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})),Pt=w("StrikethroughIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})),Rt=w("CodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"m16 18 6-6-6-6"}),jsx("path",{d:"m8 6-6 6 6 6"})]})),wo=w("CodeBlockIcon",jsxs(Fragment,{children:[jsx("path",{d:"m10 9-3 3 3 3"}),jsx("path",{d:"m14 15 3-3-3-3"}),jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})]})),ut=w("LinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})),nt=w("UnlinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"}),jsx("path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"}),jsx("line",{x1:"8",x2:"8",y1:"2",y2:"5"}),jsx("line",{x1:"2",x2:"5",y1:"8",y2:"8"}),jsx("line",{x1:"16",x2:"16",y1:"19",y2:"22"}),jsx("line",{x1:"19",x2:"22",y1:"16",y2:"16"})]})),At=w("ListIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h.01"}),jsx("path",{d:"M3 12h.01"}),jsx("path",{d:"M3 19h.01"}),jsx("path",{d:"M8 5h13"}),jsx("path",{d:"M8 12h13"}),jsx("path",{d:"M8 19h13"})]})),Bt=w("ListCheckIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 5H3"}),jsx("path",{d:"M16 12H3"}),jsx("path",{d:"M11 19H3"}),jsx("path",{d:"m15 18 2 2 4-4"})]})),Dt=w("ListOrderedIcon",jsxs(Fragment,{children:[jsx("path",{d:"M11 5h10"}),jsx("path",{d:"M11 12h10"}),jsx("path",{d:"M11 19h10"}),jsx("path",{d:"M4 4h1v5"}),jsx("path",{d:"M4 9h2"}),jsx("path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02"})]})),Oo=w("UndoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 7v6h6"}),jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})),No=w("RedoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 7v6h-6"}),jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})]})),Wt=w("ImageIcon",jsxs(Fragment,{children:[jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),jsx("circle",{cx:"9",cy:"9",r:"2"}),jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})),ct=w("AlignLeftIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M15 12H3"}),jsx("path",{d:"M17 19H3"})]})),rt=w("AlignCenterIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M17 12H7"}),jsx("path",{d:"M19 19H5"})]})),Ho=w("AlignJustifyIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h18"}),jsx("path",{d:"M3 12h18"}),jsx("path",{d:"M3 19h18"})]})),dt=w("AlignRightIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M21 12H9"}),jsx("path",{d:"M21 19H7"})]})),Xt=w("UploadIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 3v12"}),jsx("path",{d:"m17 8-5-5-5 5"}),jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})),Mo=w("MinusIcon",jsx("path",{d:"M5 12h14"})),zo=w("TableIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 3v18"}),jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),jsx("path",{d:"M3 9h18"}),jsx("path",{d:"M3 15h18"})]})),Po=w("FileCodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}),jsx("path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}),jsx("path",{d:"M10 12.5 8 15l2 2.5"}),jsx("path",{d:"m14 12.5 2 2.5-2 2.5"})]})),xl=w("EyeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),jsx("circle",{cx:"12",cy:"12",r:"3"})]})),Ro=w("HighlighterIcon",jsxs(Fragment,{children:[jsx("path",{d:"m9 11-6 6v3h9l3-3"}),jsx("path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"})]})),Tl=w("PencilIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),jsx("path",{d:"m15 5 4 4"})]})),Kt=w("CommandIcon",jsx("path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3"})),Ao=w("PaletteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"}),jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"})]})),Bo=w("TypeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 4v16"}),jsx("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),jsx("path",{d:"M9 20h6"})]})),Ut=w("QuoteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"}),jsx("path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"})]})),Do=w("IndentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H11"}),jsx("path",{d:"M21 12H11"}),jsx("path",{d:"M21 19H11"}),jsx("path",{d:"m3 8 4 4-4 4"})]})),Ko=w("OutdentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H11"}),jsx("path",{d:"M21 12H11"}),jsx("path",{d:"M21 19H11"}),jsx("path",{d:"m7 8-4 4 4 4"})]})),Uo=w("SunIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v2"}),jsx("path",{d:"M12 20v2"}),jsx("path",{d:"m4.93 4.93 1.41 1.41"}),jsx("path",{d:"m17.66 17.66 1.41 1.41"}),jsx("path",{d:"M2 12h2"}),jsx("path",{d:"M20 12h2"}),jsx("path",{d:"m6.34 17.66-1.41 1.41"}),jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})),jo=w("MoonIcon",jsx("path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"})),Vo=w("SearchIcon",jsxs(Fragment,{children:[jsx("path",{d:"m21 21-4.34-4.34"}),jsx("circle",{cx:"11",cy:"11",r:"8"})]})),Zt=w("EmojiIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),jsx("line",{x1:"9",x2:"9.01",y1:"9",y2:"9"}),jsx("line",{x1:"15",x2:"15.01",y1:"9",y2:"9"})]})),_o=w("SubscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 5 8 8"}),jsx("path",{d:"m12 5-8 8"}),jsx("path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})),$o=w("SuperscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 19 8-8"}),jsx("path",{d:"m12 19-8-8"}),jsx("path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06"})]})),Jo=w("ChevronDownIcon",jsx("path",{d:"m6 9 6 6 6-6"})),qo=w("CloseIcon",jsxs(Fragment,{children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));function Qo({isOpen:e,onClose:t,commands:n}){let[o,l]=useState(""),[r,i]=useState(0),a=useRef(null),d=useRef(null),c=n.filter(b=>`${b.label} ${b.description||""} ${b.keywords?.join(" ")||""}`.toLowerCase().includes(o.toLowerCase())),E=c.reduce((b,m)=>{let p=m.category||"Other";return b[p]||(b[p]=[]),b[p].push(m),b},{}),h=c;return useEffect(()=>{i(0);},[o]),useEffect(()=>{e&&a.current&&(a.current.focus({preventScroll:true}),l(""),i(0));},[e]),useEffect(()=>{if(!e)return;let b=d.current;if(!b)return;b.querySelector(".luthor-command-palette-item.selected")?.scrollIntoView({block:"nearest"});},[e,r,o]),useEffect(()=>{let b=m=>{if(e)switch(m.key){case "Escape":m.preventDefault(),m.stopPropagation(),t();break;case "ArrowDown":m.preventDefault(),m.stopPropagation(),i(p=>Math.min(p+1,h.length-1));break;case "ArrowUp":m.preventDefault(),m.stopPropagation(),i(p=>Math.max(p-1,0));break;case "Enter":m.preventDefault(),m.stopPropagation(),h[r]&&(h[r].action(),t());break}};return document.addEventListener("keydown",b,true),()=>document.removeEventListener("keydown",b,true)},[e,r,h,t]),e?jsx("div",{className:"luthor-command-palette-overlay",onClick:t,children:jsxs("div",{className:"luthor-command-palette",role:"dialog","aria-modal":"true","aria-label":"Command Palette",onClick:b=>b.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(Vo,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:a,type:"text",placeholder:"Type a command or search...",value:o,onChange:b=>l(b.target.value),className:"luthor-command-palette-input"}),jsx("kbd",{className:"luthor-command-palette-kbd",children:"ESC"})]}),jsx("div",{ref:d,className:"luthor-command-palette-list",children:Object.keys(E).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(E).map(([b,m])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:b}),m.map(p=>{let $=h.indexOf(p);return jsxs("div",{className:`luthor-command-palette-item ${$===r?"selected":""}`,onClick:()=>{p.action(),t();},onMouseEnter:()=>i($),children:[jsxs("div",{className:"luthor-command-palette-item-content",children:[jsx("div",{className:"luthor-command-palette-item-title",children:p.label}),p.description&&jsx("div",{className:"luthor-command-palette-item-description",children:p.description})]}),p.shortcut&&jsx("kbd",{className:"luthor-command-palette-item-shortcut",children:p.shortcut})]},p.id)})]},b))}),jsx("div",{className:"luthor-command-palette-footer",children:jsxs("span",{className:"luthor-command-palette-hint",children:[jsx(Kt,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var ir={"--luthor-bg":"#ffffff","--luthor-fg":"#0f172a","--luthor-border":"#e2e8f0","--luthor-border-hover":"#cbd5e1","--luthor-border-active":"#94a3b8","--luthor-accent":"#0f172a","--luthor-accent-hover":"#1e293b","--luthor-shadow":"rgba(0, 0, 0, 0.08)","--luthor-muted":"#f8fafc","--luthor-muted-fg":"#64748b","--luthor-theme-transition":"0.2s ease","--luthor-drag-gutter-width":"56px","--luthor-line-height-ratio":"1","--luthor-toolbar-bg":"#f8fafc","--luthor-toolbar-section-border":"#e2e8f0","--luthor-toolbar-button-fg":"#0f172a","--luthor-toolbar-button-hover-bg":"#f8fafc","--luthor-toolbar-button-hover-border":"#cbd5e1","--luthor-toolbar-button-hover-shadow":"0 4px 12px rgba(0, 0, 0, 0.15)","--luthor-toolbar-button-press-shadow":"0 2px 8px rgba(0, 0, 0, 0.1)","--luthor-toolbar-button-active-bg":"#0f172a","--luthor-toolbar-button-active-border":"#0f172a","--luthor-toolbar-button-active-fg":"#ffffff","--luthor-toolbar-button-active-shadow":"0 2px 8px rgba(0, 0, 0, 0.2)","--luthor-toolbar-button-overlay":"linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%)","--luthor-toolbar-button-active-overlay":"linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%)","--luthor-toolbar-color-indicator-border":"#e2e8f0","--luthor-toolbar-highlight-bg":"#f8fafc","--luthor-quote-bg":"#f8fafc","--luthor-quote-fg":"#0f172a","--luthor-quote-border":"#0f172a","--luthor-syntax-comment":"#64748b","--luthor-syntax-keyword":"#64748b","--luthor-syntax-string":"#64748b","--luthor-syntax-number":"#64748b","--luthor-syntax-function":"#64748b","--luthor-syntax-variable":"#64748b","--luthor-floating-bg":"#ffffff","--luthor-floating-fg":"#0f172a","--luthor-floating-border":"#e2e8f0","--luthor-floating-shadow":"rgba(0, 0, 0, 0.08)","--luthor-floating-muted":"#f8fafc","--luthor-floating-border-hover":"#cbd5e1","--luthor-floating-border-active":"#94a3b8","--luthor-floating-accent":"#0f172a","--luthor-floating-accent-fg":"#ffffff","--luthor-z-dropdown":"20","--luthor-z-popover":"24","--luthor-z-menu":"28","--luthor-z-overlay":"32","--luthor-z-modal":"36","--luthor-preset-bg":"#ffffff","--luthor-preset-fg":"#0f172a","--luthor-preset-border":"#dbe2ea","--luthor-preset-muted":"#f8fafc","--luthor-preset-muted-fg":"#64748b","--luthor-preset-accent":"#2563eb","--luthor-preset-radius":"10px","--luthor-preset-shadow":"0 1px 3px rgba(15, 23, 42, 0.08)","--luthor-preset-content-padding":"16px","--luthor-preset-content-min-height":"180px"};function lr(e){return e?e.closest(".luthor-editor-wrapper"):null}function ar(e){return e?lr(e)??e:null}function sr(e){if(typeof window>"u"||!e)return {};let t=window.getComputedStyle(e),n={};for(let[o,l]of Object.entries(ir)){let r=t.getPropertyValue(o).trim()||l;n[o]=r;}return n}function We(e){return sr(ar(e))}function mt(){if(typeof window>"u")return {};let t=window.getSelection()?.anchorNode;if(!t)return {};let n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return We(n)}function Xo({isOpen:e,query:t,position:n,suggestions:o,onClose:l,onExecute:r}){let[i,a]=useState(0);if(useEffect(()=>{a(0);},[t,e]),useEffect(()=>{if(!e)return;let c=E=>{let h=o.length>0;switch(E.key){case "Escape":E.preventDefault(),E.stopPropagation(),l();break;case "ArrowDown":if(!h)return;E.preventDefault(),E.stopPropagation(),a(b=>Math.min(b+1,Math.max(o.length-1,0)));break;case "ArrowUp":if(!h)return;E.preventDefault(),E.stopPropagation(),a(b=>Math.max(b-1,0));break;case "Enter":case "Tab":if(!h||!o[i])return;E.preventDefault(),E.stopPropagation(),r(o[i].emoji);break}};return document.addEventListener("keydown",c,true),()=>document.removeEventListener("keydown",c,true)},[e,l,r,i,o]),!e||!n)return null;let d=jsxs("div",{className:"luthor-emoji-menu",style:{left:n.x,top:n.y,...mt()},onPointerDown:c=>{c.stopPropagation();},onMouseDown:c=>{c.stopPropagation();},children:[jsxs("div",{className:"luthor-emoji-menu-header",children:[jsx("span",{className:"luthor-emoji-menu-title",children:"Emoji"}),jsxs("span",{className:"luthor-emoji-menu-query",children:[":",t]})]}),jsx("div",{className:"luthor-emoji-menu-list",children:o.length===0?jsx("div",{className:"luthor-emoji-menu-empty",children:"No matching emoji"}):o.map((c,E)=>{let h=E===i,b=c.shortcodes[0]?`:${c.shortcodes[0]}:`:"";return jsxs("button",{type:"button",className:`luthor-emoji-menu-item ${h?"selected":""}`,onMouseEnter:()=>a(E),onMouseDown:m=>{m.preventDefault(),m.stopPropagation();},onClick:m=>{m.preventDefault(),m.stopPropagation(),r(c.emoji);},children:[jsx("span",{className:"luthor-emoji-menu-item-symbol","aria-hidden":"true",children:c.emoji}),jsxs("span",{className:"luthor-emoji-menu-item-content",children:[jsx("span",{className:"luthor-emoji-menu-item-title",children:c.label}),b&&jsx("span",{className:"luthor-emoji-menu-item-shortcode",children:b})]})]},`${c.emoji}-${c.label}`)})})]});return typeof document>"u"?d:createPortal(d,document.body)}function tn({isOpen:e,query:t,position:n,commands:o,onClose:l,onExecute:r}){let[i,a]=useState(0),d=useMemo(()=>{let h=t.trim().toLowerCase();return h?o.filter(b=>`${b.label} ${b.description||""} ${b.keywords?.join(" ")||""}`.toLowerCase().includes(h)):o},[o,t]),c=useMemo(()=>d.reduce((h,b)=>{let m=b.category||"Other";return h[m]||(h[m]=[]),h[m].push(b),h},{}),[d]);if(useEffect(()=>{a(0);},[t,e]),useEffect(()=>{if(!e)return;let h=b=>{let m=d.length>0;switch(b.key){case "Escape":b.preventDefault(),b.stopPropagation(),l();break;case "ArrowDown":if(!m)return;b.preventDefault(),b.stopPropagation(),a(p=>Math.min(p+1,Math.max(d.length-1,0)));break;case "ArrowUp":if(!m)return;b.preventDefault(),b.stopPropagation(),a(p=>Math.max(p-1,0));break;case "Enter":case "Tab":if(!m||!d[i])return;b.preventDefault(),b.stopPropagation(),r(d[i].id);break}};return document.addEventListener("keydown",h,true),()=>document.removeEventListener("keydown",h,true)},[d,e,l,r,i]),!e||!n)return null;let E=jsxs("div",{className:"luthor-slash-menu",style:{left:n.x,top:n.y,...mt()},onPointerDown:h=>{h.stopPropagation();},onMouseDown:h=>{h.stopPropagation();},children:[jsxs("div",{className:"luthor-slash-menu-header",children:[jsx("span",{className:"luthor-slash-menu-title",children:"Insert block"}),jsxs("span",{className:"luthor-slash-menu-query",children:["/",t]})]}),jsx("div",{className:"luthor-slash-menu-list",children:d.length===0?jsx("div",{className:"luthor-slash-menu-empty",children:"No matching commands"}):Object.entries(c).map(([h,b])=>jsxs("div",{className:"luthor-slash-menu-group",children:[jsx("div",{className:"luthor-slash-menu-group-title",children:h}),b.map(m=>{let p=d.indexOf(m);return jsxs("button",{type:"button",className:`luthor-slash-menu-item ${p===i?"selected":""}`,onMouseEnter:()=>a(p),onMouseDown:N=>{N.preventDefault(),N.stopPropagation();},onClick:N=>{N.preventDefault(),N.stopPropagation(),r(m.id);},children:[jsxs("span",{className:"luthor-slash-menu-item-content",children:[jsx("span",{className:"luthor-slash-menu-item-title",children:m.label}),m.description&&jsx("span",{className:"luthor-slash-menu-item-description",children:m.description})]}),m.shortcut&&jsx("kbd",{className:"luthor-slash-menu-item-shortcut",children:m.shortcut})]},m.id)})]},h))})]});return typeof document>"u"?E:createPortal(E,document.body)}function L({children:e,onClick:t,title:n,active:o,disabled:l,className:r,type:i="button"}){return jsx("button",{type:i,className:`luthor-toolbar-button${o?" active":""}${r?` ${r}`:""}`,onClick:t,title:n,disabled:l,children:e})}function to({children:e,onClick:t,variant:n="primary",type:o="button",className:l}){return jsx("button",{type:o,onClick:t,className:`${n==="primary"?"luthor-button-primary":"luthor-button-secondary"}${l?` ${l}`:""}`,children:e})}function kt({value:e,onValueChange:t,options:n,placeholder:o="Select..."}){let[l,r]=useState(false),[i,a]=useState(void 0),d=useRef(null),c=useRef(null);useEffect(()=>{if(!l)return;let h=()=>{let b=d.current?.querySelector(".luthor-select-trigger");if(!b)return;let m=b.getBoundingClientRect();a({position:"fixed",top:m.bottom+4,left:m.left,width:m.width,...We(b)});};return h(),window.addEventListener("resize",h),window.addEventListener("scroll",h,true),()=>{window.removeEventListener("resize",h),window.removeEventListener("scroll",h,true);}},[l]),useEffect(()=>{function h(b){let m=b.target;d.current?.contains(m)||c.current?.contains(m)||r(false);}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);let E=n.find(h=>h.value===e);return jsxs("div",{className:"luthor-select",ref:d,children:[jsxs("button",{className:`luthor-select-trigger ${l?"open":""}`,onClick:()=>r(!l),type:"button",children:[jsx("span",{children:E?.label||o}),jsx(Jo,{size:14})]}),l&&typeof document<"u"&&createPortal(jsx("div",{ref:c,className:"luthor-select-dropdown",style:i,children:n.map(h=>jsx("button",{className:`luthor-select-option ${e===h.value?"selected":""}`,onClick:()=>{t(h.value),r(false);},type:"button",children:h.label},h.value))}),document.body)]})}function Et({trigger:e,children:t,isOpen:n,onOpenChange:o}){let l=useRef(null),r=useRef(null),i=useRef(null),[a,d]=useState(void 0);return useEffect(()=>{if(!n)return;let c=()=>{let E=r.current;if(!E)return;let h=E.getBoundingClientRect();d({position:"fixed",top:h.bottom+4,left:h.left,...We(E)});};return c(),window.addEventListener("resize",c),window.addEventListener("scroll",c,true),()=>{window.removeEventListener("resize",c),window.removeEventListener("scroll",c,true);}},[n]),useEffect(()=>{function c(E){let h=E.target;l.current?.contains(h)||i.current?.contains(h)||o(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]),jsxs("div",{className:"luthor-dropdown",ref:l,children:[jsx("div",{ref:r,onClick:()=>o(!n),children:e}),n&&typeof document<"u"&&createPortal(jsx("div",{ref:i,className:"luthor-dropdown-content",style:a,children:t}),document.body)]})}function nn({isOpen:e,onClose:t,title:n,children:o}){let l=useRef(null);return useEffect(()=>{function r(a){l.current&&!l.current.contains(a.target)&&t();}function i(a){a.key==="Escape"&&t();}return e&&(document.addEventListener("mousedown",r),document.addEventListener("keydown",i)),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",i);}},[e,t]),e?jsx("div",{className:"luthor-dialog-overlay",children:jsxs("div",{className:"luthor-dialog",ref:l,children:[jsxs("div",{className:"luthor-dialog-header",children:[jsx("h3",{className:"luthor-dialog-title",children:n}),jsx("button",{className:"luthor-dialog-close",onClick:t,type:"button",children:jsx(qo,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:o})]})}):null}function rn({isVisible:e,selectionRect:t,commands:n,activeStates:o,editorTheme:l="light",hide:r,isFeatureEnabled:i=()=>true}){let a=useRef(null),[d,c]=useState(""),[E,h]=useState(""),[b,m]=useState(""),[p,$]=useState(""),[N,A]=useState(""),[W,J]=useState(""),[v,ne]=useState(null),[se,Y]=useState(null),[g,O]=useState(null),k=!!o.isIframeEmbedSelected,V=!!o.isYouTubeEmbedSelected,R=i("iframeEmbed"),oe=i("youTubeEmbed"),B=i("image"),be=R&&k||oe&&V;if(useEffect(()=>{if(!e)return;let F=I=>{let q=I.target;q&&(a.current?.contains(q)||r?.());};return document.addEventListener("mousedown",F,true),document.addEventListener("touchstart",F,true),()=>{document.removeEventListener("mousedown",F,true),document.removeEventListener("touchstart",F,true);}},[e,r]),useEffect(()=>{if(!e||!k)return;let F=false;return typeof n.getIframeEmbedCaption=="function"&&n.getIframeEmbedCaption().then(I=>{F||h(I??"");}),typeof n.getIframeEmbedUrl=="function"&&n.getIframeEmbedUrl().then(I=>{F||c(I??"");}),ne(null),()=>{F=true;}},[n,k,e]),useEffect(()=>{if(!e||!o.imageSelected)return;let F=false;return typeof n.getImageCaption=="function"&&n.getImageCaption().then(I=>{F||m(I??"");}),()=>{F=true;}},[o.imageSelected,n,e]),useEffect(()=>{if(!e||!V)return;let F=false;return typeof n.getYouTubeEmbedCaption=="function"&&n.getYouTubeEmbedCaption().then(I=>{F||$(I??"");}),typeof n.getYouTubeEmbedUrl=="function"&&n.getYouTubeEmbedUrl().then(I=>{F||A(I??"");}),Y(null),()=>{F=true;}},[n,e,V]),useEffect(()=>{if(!e||!o.isLink)return;let F=false;return typeof n.getCurrentLink=="function"&&n.getCurrentLink().then(I=>{!F&&I&&J(I.url??"");}),O(null),()=>{F=true;}},[o.isLink,n,e]),!e||!t)return null;let ie={...mt(),position:"absolute",top:t.y,left:t.positionFromRight?"auto":t.x,right:t.positionFromRight?10:"auto",zIndex:9999,pointerEvents:"auto"};if(be){let F=U=>{if(k){n.setIframeEmbedAlignment?.(U);return}V&&n.setYouTubeEmbedAlignment?.(U);},I=k?o.isIframeEmbedAlignedLeft:o.isYouTubeEmbedAlignedLeft,q=k?o.isIframeEmbedAlignedCenter:o.isYouTubeEmbedAlignedCenter,tt=k?o.isIframeEmbedAlignedRight:o.isYouTubeEmbedAlignedRight,ve=k?typeof n.setIframeEmbedCaption=="function":typeof n.setYouTubeEmbedCaption=="function",Te=k?typeof n.updateIframeEmbedUrl=="function":typeof n.updateYouTubeEmbedUrl=="function",Je=k?E:p,Se=k?h:$,Be=k?d:N,ee=k?v:se,Le=()=>{if(ve){if(k){n.setIframeEmbedCaption?.(E);return}n.setYouTubeEmbedCaption?.(p);}},Pe=U=>{k?ne(U):Y(U);},le=U=>{k?c(U):A(U);},Ce=()=>{if(!Te)return;if(!(k?n.updateIframeEmbedUrl?.(d)??false:n.updateYouTubeEmbedUrl?.(N)??false)){Pe(k?"Enter a valid http(s) URL":"Enter a valid YouTube URL"),k&&typeof n.getIframeEmbedUrl=="function"?n.getIframeEmbedUrl().then(Re=>c(Re??"")):!k&&typeof n.getYouTubeEmbedUrl=="function"&&n.getYouTubeEmbedUrl().then(Re=>A(Re??""));return}Pe(null);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:ie,children:[jsx(L,{onClick:()=>F("left"),active:I,title:"Align Left",children:jsx(ct,{size:14})}),jsx(L,{onClick:()=>F("center"),active:q,title:"Align Center",children:jsx(rt,{size:14})}),jsx(L,{onClick:()=>F("right"),active:tt,title:"Align Right",children:jsx(dt,{size:14})}),ve||Te?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-fields",children:[Te?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:Be,className:`luthor-floating-toolbar-input${ee?" is-error":""}`,placeholder:k?"https://example.com/embed":"https://youtube.com/watch?v=...","aria-label":k?"Iframe URL":"YouTube URL","aria-invalid":ee?true:void 0,onChange:U=>{le(U.target.value),ee&&Pe(null);},onBlur:Ce,onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),Ce());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:Ce,children:"Update URL"})]}):null,ve?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:Je,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":k?"Iframe caption":"YouTube caption",onChange:U=>Se(U.target.value),onBlur:Le,onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),Le());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:Le,children:"Update Caption"})]}):null]})]}):null]})}if(B&&o.imageSelected){let F=typeof n.setImageCaption=="function",I=()=>{F&&n.setImageCaption(b);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:ie,children:[jsx(L,{onClick:()=>n.setImageAlignment("left"),active:o.isImageAlignedLeft,title:"Align Left",children:jsx(ct,{size:14})}),jsx(L,{onClick:()=>n.setImageAlignment("center"),active:o.isImageAlignedCenter,title:"Align Center",children:jsx(rt,{size:14})}),jsx(L,{onClick:()=>n.setImageAlignment("right"),active:o.isImageAlignedRight,title:"Align Right",children:jsx(dt,{size:14})}),F?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:b,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":"Image caption",onChange:q=>m(q.target.value),onBlur:I,onKeyDown:q=>{q.key==="Enter"&&(q.preventDefault(),I());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:I,children:"Update Caption"})]})]}):null]})}let Fe=i("bold"),ue=i("italic"),we=i("underline"),Oe=i("strikethrough"),Ne=i("codeFormat"),ge=i("blockFormat"),He=i("link"),Ae=i("list"),Me=Fe||ue||we||Oe,me=Ne||ge||He,ze=Ae,ye=!!o.isLink&&typeof n.updateLink=="function"&&typeof n.removeLink=="function",he=()=>{if(!ye)return;if(!(n.updateLink?.(W)??false)){O("Enter a valid URL"),typeof n.getCurrentLink=="function"&&n.getCurrentLink().then(I=>{J(I?.url??"");});return}O(null);};return !Me&&!me&&!ze?null:jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:ie,children:[Me?jsxs(Fragment,{children:[Fe?jsx(L,{onClick:()=>n.toggleBold(),active:o.bold,title:"Bold",children:jsx(Ht,{size:14})}):null,ue?jsx(L,{onClick:()=>n.toggleItalic(),active:o.italic,title:"Italic",children:jsx(Mt,{size:14})}):null,we?jsx(L,{onClick:()=>n.toggleUnderline(),active:o.underline,title:"Underline",children:jsx(zt,{size:14})}):null,Oe?jsx(L,{onClick:()=>n.toggleStrikethrough(),active:o.strikethrough,title:"Strikethrough",children:jsx(Pt,{size:14})}):null]}):null,Me&&me?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,me?jsxs(Fragment,{children:[Ne?jsx(L,{onClick:()=>n.formatText("code"),active:o.code,title:"Inline Code",children:jsx(Rt,{size:14})}):null,ge?jsx(L,{onClick:()=>n.toggleQuote(),active:o.isQuote,title:"Quote",children:jsx(Ut,{size:14})}):null,He?jsxs(Fragment,{children:[jsx(L,{onClick:()=>o.isLink?n.removeLink():n.insertLink(),active:o.isLink,title:o.isLink?"Remove Link":"Insert Link",children:o.isLink?jsx(nt,{size:14}):jsx(ut,{size:14})}),ye?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:W,className:`luthor-floating-toolbar-input${g?" is-error":""}`,placeholder:"https://example.com","aria-label":"Link URL","aria-invalid":g?true:void 0,onChange:F=>{J(F.target.value),g&&O(null);},onBlur:he,onKeyDown:F=>{F.key==="Enter"&&(F.preventDefault(),he());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:he,children:"Update Link"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-danger",onClick:()=>n.removeLink(),"aria-label":"Unlink",children:jsx(nt,{size:13})})]}):null]}):null]}):null,(Me||me)&&ze?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,ze?jsxs(Fragment,{children:[jsx(L,{onClick:()=>n.toggleUnorderedList(),active:o.unorderedList,title:"Bullet List",children:jsx(At,{size:14})}),jsx(L,{onClick:()=>n.toggleOrderedList(),active:o.orderedList,title:"Numbered List",children:jsx(Dt,{size:14})}),jsx(L,{onClick:()=>n.toggleCheckList(),active:o.checkList,title:"Checklist",children:jsx(Bt,{size:14})})]}):null]})}var Ke={commands:{},activeStates:{},editorTheme:"light",isFeatureEnabled:()=>true};function oo(e,t,n,o=()=>true){Ke.commands=e,Ke.activeStates=t,Ke.editorTheme=n,Ke.isFeatureEnabled=o;}function ln(){let e=rn,t=new FloatingToolbarExtension;return t.config={...t.config,render:n=>createElement(e,{...n,commands:Ke.commands,activeStates:Ke.activeStates,editorTheme:Ke.editorTheme,isFeatureEnabled:Ke.isFeatureEnabled}),getCommands:()=>Ke.commands,getActiveStates:()=>Ke.activeStates},t}var Cr=120,kr=58;function Er(e,t=kr){return e.length<=t?e:`${e.slice(0,t-3)}...`}function sn(){let e=window.getSelection();return !e||e.rangeCount===0?false:!e.getRangeAt(0).collapsed}function un(e,t){if(!(e instanceof Element))return null;let n=e.closest("a");return !(n instanceof HTMLAnchorElement)||!t.contains(n)?null:n}function gn({editor:e,commands:t,editorTheme:n="light",disabled:o=false}){let l=useRef(null),r=useRef(null),[i,a]=useState(null),[d,c]=useState(false),[E,h]=useState(""),[b,m]=useState(null),[p,$]=useState(null),N=useCallback(()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null);},[]),A=useCallback(()=>{N(),a(null),c(false),h(""),m(null),$(null);},[N]),W=useCallback(()=>{N(),r.current=window.setTimeout(()=>{A();},Cr);},[N,A]),J=useCallback(g=>{let O=g.getBoundingClientRect(),k=O.bottom+8,V=Math.max(10,Math.min(O.left,window.innerWidth-340));$({top:k,left:V});},[]),v=useCallback((g,O)=>{if(typeof t.getLinkByKey!="function"){a(k=>!k||k.nodeKey!==g?k:{...k,url:O});return}t.getLinkByKey(g).then(k=>{if(!k){A();return}a(V=>!V||V.nodeKey!==g?V:{...V,url:k.url});});},[t,A]);useEffect(()=>{if(!e||o||typeof window>"u"){A();return}let g=e.getRootElement();if(!g){A();return}let O=oe=>{let B=un(oe.target,g);if(!B)return;if(sn()){A();return}N();let be=resolveLinkNodeKeyFromAnchor(e,B);if(!be)return;let ie=B.getAttribute("href")??B.href;a({nodeKey:be,url:ie,anchorEl:B}),J(B),m(null),d||h(ie),v(be,ie);},k=oe=>{if(!i)return;let B=oe.relatedTarget;B&&l.current?.contains(B)||un(B,g)||W();},V=()=>{sn()&&A();},R=()=>{a(oe=>{if(!oe)return oe;let B=oe.anchorEl.isConnected&&g.contains(oe.anchorEl)?oe.anchorEl:g.querySelector(`a[data-lexical-node-key="${oe.nodeKey}"]`);return B?(J(B),{...oe,anchorEl:B,url:B.getAttribute("href")??B.href}):(A(),null)});};return g.addEventListener("mouseover",O),g.addEventListener("mouseout",k),document.addEventListener("selectionchange",V),window.addEventListener("scroll",R,true),window.addEventListener("resize",R),()=>{g.removeEventListener("mouseover",O),g.removeEventListener("mouseout",k),document.removeEventListener("selectionchange",V),window.removeEventListener("scroll",R,true),window.removeEventListener("resize",R),N();}},[t,o,e,i,d,A,W,v,J,N]);let ne=useMemo(()=>{if(!(!i||!p))return {...We(i.anchorEl),position:"fixed",top:p.top,left:p.left,zIndex:10040}},[i,p]);if(!i||!p||typeof document>"u")return null;let se=()=>{(t.removeLinkByKey?.(i.nodeKey)??false)&&A();},Y=()=>{let g=E.trim();if(!(t.updateLinkByKey?.(i.nodeKey,g)??false)){m("Enter a valid URL"),v(i.nodeKey,i.url);return}a(k=>!k||k.nodeKey!==i.nodeKey?k:{...k,url:g}),m(null),c(false),queueMicrotask(()=>{v(i.nodeKey,g);});};return createPortal(jsx("div",{ref:l,className:"luthor-floating-toolbar luthor-link-hover-bubble","data-theme":n,style:ne,onMouseEnter:N,onMouseLeave:W,children:d?jsxs(Fragment,{children:[jsx("input",{type:"url",value:E,className:`luthor-link-hover-bubble-input${b?" is-error":""}`,placeholder:"https://example.com","aria-label":"Edit link URL","aria-invalid":b?true:void 0,onChange:g=>{h(g.target.value),b&&m(null);},onKeyDown:g=>{if(g.key==="Enter"){g.preventDefault(),Y();return}g.key==="Escape"&&(g.preventDefault(),c(false),h(i.url),m(null));}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-primary",onClick:Y,children:"Update"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{c(false),h(i.url),m(null);},children:"Cancel"})]}):jsxs(Fragment,{children:[jsx("span",{className:"luthor-link-hover-bubble-url",title:i.url,children:Er(i.url)}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{h(i.url),c(true),m(null);},children:"Edit"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-danger",onClick:se,"aria-label":"Unlink",children:jsx(nt,{size:13})})]})}),document.body)}function mn({mode:e,onModeChange:t,labels:n,availableModes:o,isConverting:l}){let r=o??["visual","json"],i={visual:n?.visual??"Visual",json:n?.json??"JSON"};return jsxs("div",{className:"luthor-mode-tabs",children:[r.includes("visual")&&jsxs("button",{className:`luthor-mode-tab ${e==="visual"?"active":""}`,onClick:()=>t("visual"),children:[i.visual,l==="visual"&&jsx("span",{className:"luthor-tab-converting-spinner"})]}),r.includes("json")&&jsxs("button",{className:`luthor-mode-tab ${e==="json"?"active":""}`,onClick:()=>t("json"),children:[i.json,l==="json"&&jsx("span",{className:"luthor-tab-converting-spinner"})]})]})}function hn({value:e,onChange:t,placeholder:n,className:o}){let l=useRef(null);return useLayoutEffect(()=>{let r=l.current;if(!r)return;r.style.height="auto";let i=Math.max(r.scrollHeight,280);r.style.height=`${i}px`;},[e]),jsx("textarea",{ref:l,className:`luthor-source-view${o?` ${o}`:""}`,value:e,onChange:r=>t(r.target.value),placeholder:n,spellCheck:false})}function fn(e){return e.replace(/\r\n?/g,`
2
- `)}function io(e){let t=fn(e).trim();if(!t)return "";try{let n=JSON.parse(t);return JSON.stringify(n,null,2)}catch{return t}}function ha(e){return fn(e).trim()}var lo=6,Fr=["#ffffff","#f2f2f2","#d9d9d9","#bfbfbf","#808080","#404040","#000000","#fbe5d6","#f8cbad","#f4b183","#ed7d31","#c55a11","#fff2cc","#ffe699","#ffd966","#ffc000","#bf9000","#7f6000","#e2f0d9","#c6e0b4","#a9d18e","#70ad47","#548235","#375623","#ddebf7","#bdd7ee","#9dc3e6","#5b9bd5","#2f75b5","#1f4e78","#e4dfec","#d9c2e9","#b4a7d6","#8e7cc3","#674ea7","#351c75"];function _t(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function wr(e,t){let n=_t(t);for(let o of e)if(_t(o.value)===n)return o.color;return null}function Or(e,t,n){if(!e||e==="default")return n;let o=wr(t,e);return o||e}function Nr(e,t){let n=e.trim();return /^#([\da-f]{6})$/i.test(n)?n:/^#([\da-f]{3})$/i.test(n)?`#${n.slice(1).split("").map(l=>`${l}${l}`).join("")}`:t}function Ve(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function bn(e){let t=e.split(",")[0]??"";return Ve(t.replace(/["']/g,""))}function $t(e){let t=e.trim().toLowerCase().match(/^(-?\d*\.?\d+)px$/);if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?n:null}function Vt(){if(typeof window>"u")return null;let t=window.getSelection()?.anchorNode;if(!t)return null;let n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!n||!n.closest(".luthor-content-editable"))return null;let l=window.getComputedStyle(n);return {fontFamily:l.fontFamily,fontSize:l.fontSize,lineHeight:l.lineHeight}}function Hr(e,t){if(!e)return null;let n=bn(e);return n?t.find(l=>Ve(l.value)===n?true:bn(l.fontFamily)===n)?.value??null:null}function Mr(e,t){if(!e)return null;let n=Ve(e),o=t.find(i=>Ve(String(i.value))===n?true:Ve(String(i.fontSize))===n);if(o)return String(o.value);let l=$t(e);if(l==null)return null;let r=null;for(let i of t){let a=$t(String(i.fontSize));if(a==null)continue;let d=Math.abs(a-l);(!r||d<r.distance)&&(r={value:String(i.value),distance:d});}return r?.value??null}function zr(e,t,n){if(!e)return null;let o=Ve(e),l=n.find(c=>Ve(c.value)===o?true:Ve(c.lineHeight)===o);if(l)return l.value;let r=t?$t(t):null,i=$t(e),a=null;if(i!=null&&r!=null&&r>0)a=i/r;else {let c=Number(e);Number.isFinite(c)&&(a=c);}if(a==null)return null;let d=null;for(let c of n){let E=Number(c.lineHeight);if(!Number.isFinite(E))continue;let h=Math.abs(E-a);(!d||h<d.distance)&&(d={value:c.value,distance:h});}return d?.value??null}function yn({title:e,value:t,options:n,recentColors:o,active:l,fallbackColor:r,highlight:i,onChange:a,onClear:d,onAddRecent:c}){let E=useRef(null),h=useRef(null),b=useRef(null),m=useRef(null),p=useRef(null),[$,N]=useState(false),[A,W]=useState(void 0),J=Or(t,n,r),v=useMemo(()=>Fr,[]),ne=useMemo(()=>{let g=[...o].slice(0,lo);for(;g.length<lo;)g.push("");return g},[o]);useEffect(()=>()=>{m.current&&window.cancelAnimationFrame(m.current);},[]);let se=useCallback(g=>{p.current=g,!m.current&&(m.current=window.requestAnimationFrame(()=>{m.current=null,p.current&&(a(p.current),p.current=null);}));},[a]),Y=useCallback(g=>{let O=E.current;if(!O)return;let k=O.getBoundingClientRect();W({position:"fixed",top:k.bottom+6,left:k.left,width:230,visibility:g?"visible":"hidden",...We(O)});},[]);return useLayoutEffect(()=>{if(!$)return;Y(false);let g=window.requestAnimationFrame(()=>{Y(true);});return ()=>{window.cancelAnimationFrame(g);}},[$,Y]),useEffect(()=>{if(!$)return;let g=V=>{let R=V.target;E.current?.contains(R)||h.current?.contains(R)||N(false);},O=V=>{V.key==="Escape"&&N(false);},k=()=>Y(true);return window.addEventListener("resize",k),window.addEventListener("scroll",k,true),document.addEventListener("mousedown",g),document.addEventListener("keydown",O),()=>{window.removeEventListener("resize",k),window.removeEventListener("scroll",k,true),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",O);}},[$,Y]),jsxs(Fragment,{children:[jsxs("button",{ref:E,type:"button",className:`luthor-toolbar-button luthor-color-button${l?" active":""}${i?" is-highlight":""}`,title:e,"aria-label":e,onClick:()=>N(g=>!g),children:[i?jsx(Ro,{size:15,className:"luthor-color-button-highlighter"}):jsx("span",{className:"luthor-color-button-letter",children:"A"}),jsx("span",{className:"luthor-color-button-indicator",style:{backgroundColor:J}})]}),$&&typeof document<"u"&&createPortal(jsxs("div",{ref:h,className:"luthor-color-picker",style:A,children:[jsx("div",{className:"luthor-color-picker-header",children:jsx("span",{className:"luthor-color-picker-title",children:e})}),jsxs("div",{className:"luthor-color-picker-section",children:[jsx("p",{className:"luthor-color-picker-label",children:"Colors"}),jsx("div",{className:"luthor-color-swatch-grid",children:v.map(g=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:g},"aria-label":`Use color ${g}`,onClick:()=>{a(g),c(g),N(false);}},g))})]}),jsxs("div",{className:"luthor-color-picker-section",children:[jsx("p",{className:"luthor-color-picker-label",children:"Recent colors"}),jsx("div",{className:"luthor-color-swatch-row",children:ne.map((g,O)=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:g||"transparent"},"aria-label":g?`Use recent color ${g}`:"Empty recent color slot",disabled:!g,onClick:()=>{g&&(a(g),c(g),N(false));}},`${g||"empty"}-${O}`))})]}),jsxs("div",{className:"luthor-color-picker-footer",children:[jsx("button",{type:"button",className:"luthor-color-picker-clear",onClick:()=>{d(),N(false);},children:"Reset to Default"}),jsxs("button",{type:"button",className:"luthor-color-picker-custom",onClick:()=>b.current?.click(),children:[jsx(Ao,{size:14}),jsx("span",{children:"Custom Color"})]}),jsx("input",{ref:b,type:"color",className:"luthor-color-picker-native luthor-color-picker-native-hidden",value:Nr(J,r),onInput:g=>{se(g.target.value);},onChange:g=>{let O=g.target.value;a(O),c(O);}})]})]}),document.body)]})}function Pr(e,t){let n=useRef(null),o=useRef(null);return {handlers:useMemo(()=>({insertFromUrl:()=>{let r=prompt("Enter image URL:");if(!r)return;let i=prompt("Enter alt text:")||"",a=prompt("Enter caption (optional):")||void 0;e.insertImage({src:r,alt:i,caption:a});},insertFromFile:()=>n.current?.click(),insertGifFromUrl:()=>{let r=prompt("Enter GIF URL:");if(!r)return;let i=prompt("Enter alt text (optional):")||"GIF";e.insertImage({src:r,alt:i});},insertGifFromFile:()=>o.current?.click(),handleUpload:async r=>{let i=r.target.files?.[0];if(!i)return;let a;if(t)try{a=await t(i);}catch{alert("Failed to upload image");return}else a=URL.createObjectURL(i);e.insertImage({src:a,alt:i.name,file:i}),r.target.value="";},handleGifUpload:async r=>{let i=r.target.files?.[0];if(!i)return;if(!(i.type==="image/gif"||i.name.toLowerCase().endsWith(".gif"))){alert("Please select a GIF file."),r.target.value="";return}let d;if(t)try{d=await t(i);}catch{alert("Failed to upload GIF");return}else d=URL.createObjectURL(i);e.insertImage({src:d,alt:i.name||"GIF",file:i}),r.target.value="";},setAlignment:r=>{e.setImageAlignment(r);},setCaption:()=>{let r=prompt("Enter caption:")||"";e.setImageCaption(r);}}),[e,t]),fileInputRef:n,gifInputRef:o}}function Rr(e){return useMemo(()=>({insertIframe:()=>{let t=prompt("Enter iframe URL:");t&&typeof e.insertIframeEmbed=="function"&&e.insertIframeEmbed(t);},insertYouTube:()=>{let t=prompt("Enter YouTube URL:");t&&typeof e.insertYouTubeEmbed=="function"&&e.insertYouTubeEmbed(t);}}),[e])}function Ar(e,t){switch(e){case "fontFamily":return t("fontFamily");case "fontSize":return t("fontSize");case "lineHeight":return t("lineHeight");case "textColor":return t("textColor");case "textHighlight":return t("textHighlight");case "subscript":return t("subscript");case "superscript":return t("superscript");case "blockFormat":case "quote":case "alignLeft":case "alignCenter":case "alignRight":case "alignJustify":return t("blockFormat");case "codeBlock":return t("code");case "unorderedList":case "orderedList":case "checkList":case "indentList":case "outdentList":return t("list");case "horizontalRule":return t("horizontalRule");case "table":return t("table");case "image":return t("image");case "emoji":return t("emoji");case "embed":return t("iframeEmbed")||t("youtubeEmbed");case "undo":case "redo":return t("history");default:return true}}function Br(e,t,n){return Ar(e,t)?n?.[e]!==false:false}function Dr(e,t,n){return {sections:e.sections.map(o=>({...o,items:o.items.filter(l=>Br(l,t,n))})).filter(o=>o.items.length>0)}}function vn({commands:e,hasExtension:t,activeStates:n,isDark:o,toggleTheme:l,onCommandPaletteOpen:r,imageUploadHandler:i,classNames:a,toolbarStyleVars:d,layout:c,toolbarVisibility:E,headingOptions:h,paragraphLabel:b}){let{handlers:m,fileInputRef:p,gifInputRef:$}=Pr(e,i),N=Rr(e),A=t("iframeEmbed")||t("youtubeEmbed"),W=n.isIframeEmbedSelected||n.isYouTubeEmbedSelected,[J,v]=useState(false),[ne,se]=useState(false),[Y,g]=useState(false),[O,k]=useState(false),[V,R]=useState(false),[oe,B]=useState("default"),[be,ie]=useState([{value:"default",label:"Default"}]),[Fe,ue]=useState("default"),[we,Oe]=useState([{value:"default",label:"Default"}]),[Ne,ge]=useState("default"),[He,Ae]=useState([{value:"default",label:"Default"}]),[Me,me]=useState("default"),[ze,ye]=useState([{value:"default",label:"Default",color:"inherit"}]),[he,F]=useState([]),[I,q]=useState("default"),[tt,ve]=useState([{value:"default",label:"Default",color:"transparent"}]),[Te,Je]=useState([]),[Se,Be]=useState(0),[ee,Le]=useState({rows:3,columns:3,includeHeaders:false});useEffect(()=>{if(typeof document>"u")return;let f=()=>{Vt()&&Be(P=>P+1);};return document.addEventListener("selectionchange",f),()=>{document.removeEventListener("selectionchange",f);}},[]);let Pe=useMemo(()=>t("emoji")?typeof e.getEmojiSuggestions=="function"?e.getEmojiSuggestions(""):typeof e.getEmojiCatalog=="function"?e.getEmojiCatalog():[]:[],[e,t]);useEffect(()=>{if(!t("fontFamily")||typeof e.getFontFamilyOptions!="function")return;let f=e.getFontFamilyOptions().map(P=>({value:P.value,label:P.label})),y=f.length>0?f:[{value:"default",label:"Default"}];ie(y),B(P=>y.some(K=>K.value===P)?P:"default");},[e,t]),useEffect(()=>{if(!t("fontFamily")||typeof e.getCurrentFontFamily!="function")return;let f=e.getFontFamilyOptions;if(typeof f!="function")return;let y=false;return e.getCurrentFontFamily().then(P=>{if(y)return;if(P&&P!=="default"){B(P);return}let K=Vt(),ce=Hr(K?.fontFamily,f());B(ce??"default");}),()=>{y=true;}},[n,e,t,Se]),useEffect(()=>{if(!t("fontSize")||typeof e.getFontSizeOptions!="function")return;let f=e.getFontSizeOptions().map(K=>({value:String(K.value).trim(),label:String(K.label).trim()})).filter(K=>K.value.length>0&&K.label.length>0),y=f.some(K=>Ve(K.value)==="default"),P=f.length===0?[{value:"default",label:"Default"}]:y?f:[{value:"default",label:"Default"},...f];Oe(P),ue(K=>P.some(ce=>ce.value===K)?K:"default");},[e,t]),useEffect(()=>{if(!t("fontSize")||typeof e.getCurrentFontSize!="function")return;let f=e.getFontSizeOptions;if(typeof f!="function")return;let y=false;return e.getCurrentFontSize().then(P=>{if(y)return;if(P&&P!=="default"){ue(P);return}let K=Vt(),ce=Mr(K?.fontSize,f());ue(ce??"default");}),()=>{y=true;}},[n,e,t,Se]),useEffect(()=>{if(!t("lineHeight")||typeof e.getLineHeightOptions!="function")return;let f=e.getLineHeightOptions().map(y=>({value:y.value,label:y.label}));f.length>0&&Ae(f);},[e,t]),useEffect(()=>{if(!t("lineHeight")||typeof e.getCurrentLineHeight!="function")return;let f=e.getLineHeightOptions;if(typeof f!="function")return;let y=false;return e.getCurrentLineHeight().then(P=>{if(y)return;if(P){ge(P);return}let K=Vt(),ce=zr(K?.lineHeight,K?.fontSize,f());ge(ce??"default");}),()=>{y=true;}},[n,e,t,Se]),useEffect(()=>{if(!t("textColor")||typeof e.getTextColorOptions!="function")return;let f=e.getTextColorOptions().map(y=>({value:y.value,label:y.label,color:y.color}));f.length>0&&ye(f);},[e,t]),useEffect(()=>{if(!t("textColor")||typeof e.getCurrentTextColor!="function")return;let f=false;return e.getCurrentTextColor().then(y=>{f||me(y??"default");}),()=>{f=true;}},[n,e,t,Se]),useEffect(()=>{if(!t("textHighlight")||typeof e.getTextHighlightOptions!="function")return;let f=e.getTextHighlightOptions().map(y=>({value:y.value,label:y.label,color:y.backgroundColor}));f.length>0&&ve(f);},[e,t]),useEffect(()=>{if(!t("textHighlight")||typeof e.getCurrentTextHighlight!="function")return;let f=false;return e.getCurrentTextHighlight().then(y=>{f||q(y??"default");}),()=>{f=true;}},[n,e,t,Se]);let le=useMemo(()=>{if(!h||h.length===0)return [...Ie];let f=new Set,y=[];for(let P of h)!Ie.includes(P)||f.has(P)||(f.add(P),y.push(P));return y.length>0?y:[...Ie]},[h]),Ce=b?.trim()||"Paragraph",De=useMemo(()=>{let f=le.map(y=>({value:y,label:`Heading ${y.slice(1)}`}));return [{value:"p",label:Ce},...f]},[le,Ce]),U=n.isH1?"h1":n.isH2?"h2":n.isH3?"h3":n.isH4?"h4":n.isH5?"h5":n.isH6?"h6":"p",Re=De.some(f=>f.value===U)?U:"p",ot=f=>{f==="p"?e.toggleParagraph():f.startsWith("h")&&le.includes(f)&&e.toggleHeading(f);},qe=f=>{f==="default"?e.clearFontFamily?.():e.setFontFamily?.(f),B(f);},Ye=f=>{f==="default"?e.clearFontSize?.():e.setFontSize?.(f),ue(f);},Ge=f=>{e.setLineHeight?.(f),ge(f);},C=(f,y)=>{f(P=>{let K=_t(y),ce=P.filter(de=>_t(de)!==K);return [y,...ce].slice(0,lo)});},T=f=>{if(f==="default"){e.clearTextColor?.(),me("default");return}e.setTextColor?.(f),me(f);},D=f=>{if(f==="default"){e.clearTextHighlight?.(),q("default");return}e.setTextHighlight?.(f),q(f);},G=f=>{switch(f){case "fontFamily":return t("fontFamily")?jsx(kt,{value:oe,onValueChange:qe,options:be,placeholder:"Font"},"fontFamily"):null;case "fontSize":return t("fontSize")?jsx(kt,{value:Fe,onValueChange:Ye,options:we,placeholder:"Size"},"fontSize"):null;case "lineHeight":return t("lineHeight")?jsx(kt,{value:Ne,onValueChange:Ge,options:He,placeholder:"Line"},"lineHeight"):null;case "textColor":return t("textColor")?jsx(yn,{title:"Text Color",value:Me,options:ze,recentColors:he,active:n.hasCustomTextColor,fallbackColor:"#0f172a",onChange:T,onClear:()=>T("default"),onAddRecent:y=>C(F,y)},"textColor"):null;case "textHighlight":return t("textHighlight")?jsx(yn,{title:"Text Highlight",value:I,options:tt,recentColors:Te,active:n.hasTextHighlight,fallbackColor:"#fef08a",highlight:true,onChange:D,onClear:()=>D("default"),onAddRecent:y=>C(Je,y)},"textHighlight"):null;case "bold":return jsx(L,{onClick:()=>e.toggleBold(),active:n.bold,title:"Bold (Ctrl+B)",children:jsx(Ht,{size:16})},"bold");case "italic":return jsx(L,{onClick:()=>e.toggleItalic(),active:n.italic,title:"Italic (Ctrl+I)",children:jsx(Mt,{size:16})},"italic");case "underline":return jsx(L,{onClick:()=>e.toggleUnderline(),active:n.underline,title:"Underline (Ctrl+U)",children:jsx(zt,{size:16})},"underline");case "strikethrough":return jsx(L,{onClick:()=>e.toggleStrikethrough(),active:n.strikethrough,title:"Strikethrough",children:jsx(Pt,{size:16})},"strikethrough");case "subscript":return t("subscript")?jsx(L,{onClick:()=>e.toggleSubscript?.(),active:n.subscript,title:"Subscript",children:jsx(_o,{size:16})},"subscript"):null;case "superscript":return t("superscript")?jsx(L,{onClick:()=>e.toggleSuperscript?.(),active:n.superscript,title:"Superscript",children:jsx($o,{size:16})},"superscript"):null;case "code":return jsx(L,{onClick:()=>e.formatText("code"),active:n.code,title:"Inline Code",children:jsx(Rt,{size:16})},"code");case "link":return jsx(L,{onClick:()=>n.isLink?e.removeLink():e.insertLink(),active:n.isLink,title:n.isLink?"Remove Link":"Insert Link",children:n.isLink?jsx(nt,{size:16}):jsx(ut,{size:16})},"link");case "blockFormat":return t("blockFormat")?jsx(kt,{value:Re,onValueChange:ot,options:De,placeholder:"Format"},"blockFormat"):null;case "quote":return t("blockFormat")?jsx(L,{onClick:()=>e.toggleQuote(),active:n.isQuote,title:"Quote",children:jsx(Ut,{size:16})},"quote"):null;case "alignLeft":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("left"),active:n.isTextAlignedLeft,title:"Align Left",children:jsx(ct,{size:16})},"alignLeft"):null;case "alignCenter":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("center"),active:n.isTextAlignedCenter,title:"Align Center",children:jsx(rt,{size:16})},"alignCenter"):null;case "alignRight":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("right"),active:n.isTextAlignedRight,title:"Align Right",children:jsx(dt,{size:16})},"alignRight"):null;case "alignJustify":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("justify"),active:n.isTextAlignedJustify,title:"Justify",children:jsx(Ho,{size:16})},"alignJustify"):null;case "codeBlock":return t("code")?jsx(L,{onClick:()=>e.toggleCodeBlock(),active:n.isInCodeBlock,title:"Code Block",children:jsx(wo,{size:16})},"codeBlock"):null;case "unorderedList":return t("list")?jsx(L,{onClick:()=>e.toggleUnorderedList(),active:n.unorderedList,title:"Bullet List",children:jsx(At,{size:16})},"unorderedList"):null;case "orderedList":return t("list")?jsx(L,{onClick:()=>e.toggleOrderedList(),active:n.orderedList,title:"Numbered List",children:jsx(Dt,{size:16})},"orderedList"):null;case "checkList":return t("list")?jsx(L,{onClick:()=>e.toggleCheckList(),active:n.checkList,title:"Checklist",children:jsx(Bt,{size:16})},"checkList"):null;case "indentList":return t("list")?jsx(L,{onClick:()=>e.indentList(),title:"Indent List",disabled:n.checkList,children:jsx(Do,{size:14})},"indentList"):null;case "outdentList":return t("list")?jsx(L,{onClick:()=>e.outdentList(),title:"Outdent List",disabled:n.checkList,children:jsx(Ko,{size:14})},"outdentList"):null;case "horizontalRule":return t("horizontalRule")?jsx(L,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(Mo,{size:16})},"horizontalRule"):null;case "table":return t("table")?jsx(L,{onClick:()=>R(true),title:"Insert Table",children:jsx(zo,{size:16})},"table"):null;case "image":return t("image")?jsxs(Fragment,{children:[jsxs(Et,{trigger:jsx("button",{className:`luthor-toolbar-button ${n.imageSelected?"active":""}`,title:"Insert Image",children:jsx(Wt,{size:16})}),isOpen:J,onOpenChange:v,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertFromUrl(),v(false);},children:[jsx(ut,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertFromFile(),v(false);},children:[jsx(Xt,{size:16}),jsx("span",{children:"Upload File"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertGifFromUrl(),v(false);},children:[jsx(Zt,{size:16}),jsx("span",{children:"Insert GIF URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertGifFromFile(),v(false);},children:[jsx(Xt,{size:16}),jsx("span",{children:"Upload GIF"})]})]},"image"),n.imageSelected&&jsxs(Et,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(rt,{size:16})}),isOpen:Y,onOpenChange:g,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setAlignment("left"),g(false);},children:[jsx(ct,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setAlignment("center"),g(false);},children:[jsx(rt,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setAlignment("right"),g(false);},children:[jsx(dt,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setCaption(),g(false);},children:[jsx(Bo,{size:16}),jsx("span",{children:"Set Caption"})]})]},"imageAlign")]}):null;case "emoji":return !t("emoji")||Pe.length===0?null:jsx(Et,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Insert Emoji",children:jsx(Zt,{size:16})}),isOpen:ne,onOpenChange:se,children:jsx("div",{className:"luthor-emoji-picker-grid",role:"listbox","aria-label":"Emoji picker",children:Pe.map(y=>jsx("button",{type:"button",className:"luthor-emoji-picker-item",title:y.shortcodes[0]?`${y.label} (:${y.shortcodes[0]}:)`:y.label,onClick:()=>{e.insertEmoji?.(y.emoji),se(false);},children:y.emoji},`${y.emoji}-${y.label}`))})},"emoji");case "embed":return A?jsxs(Et,{trigger:jsx("button",{className:`luthor-toolbar-button ${W?"active":""}`,title:"Insert Embed",children:jsx(Po,{size:16})}),isOpen:O,onOpenChange:k,children:[t("iframeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{N.insertIframe(),k(false);},children:[jsx(ut,{size:16}),jsx("span",{children:"Embed iframe"})]}):null,t("youtubeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{N.insertYouTube(),k(false);},children:[jsx(Wt,{size:16}),jsx("span",{children:"Embed YouTube Video"})]}):null]},"embed"):null;case "undo":return t("history")?jsx(L,{onClick:()=>e.undo(),disabled:!n.canUndo,title:"Undo (Ctrl+Z)",children:jsx(Oo,{size:16})},"undo"):null;case "redo":return t("history")?jsx(L,{onClick:()=>e.redo(),disabled:!n.canRedo,title:"Redo (Ctrl+Y)",children:jsx(No,{size:16})},"redo"):null;case "commandPalette":return jsx(L,{onClick:()=>r?.(),title:"Command Palette (Ctrl+Shift+P)",children:jsx(Kt,{size:16})},"commandPalette");case "themeToggle":return jsx(L,{onClick:l,title:o?"Light Mode":"Dark Mode",children:o?jsx(Uo,{size:16}):jsx(jo,{size:16})},"themeToggle");default:return null}},X=c??Ot,Qe=useMemo(()=>Dr(X,t,E),[X,t,E]);return jsxs(Fragment,{children:[jsx("div",{className:a?.toolbar??"luthor-toolbar",style:d,children:Qe.sections.map((f,y)=>{let P=f.items.map((K,ce)=>{let de=G(K);return de?Array.isArray(de)?de.map((te,wt)=>te&&typeof te=="object"&&"key"in te&&te.key!=null?te:jsx("span",{children:te},`toolbar-item-${y}-${ce}-${wt}`)):de.type===Sr.Fragment?jsx("span",{children:de},`toolbar-item-${y}-${ce}`):de&&typeof de=="object"&&"key"in de&&de.key!=null?de:jsx("span",{children:de},`toolbar-item-${y}-${ce}`):null}).flat().filter(K=>K!==null);return P.length===0?null:jsx("div",{className:a?.section??"luthor-toolbar-section",children:P},y)})}),jsx("input",{ref:p,type:"file",accept:"image/*",onChange:m.handleUpload,className:"luthor-file-input"}),jsx("input",{ref:$,type:"file",accept:"image/gif",onChange:m.handleGifUpload,className:"luthor-file-input"}),jsx(nn,{isOpen:V,onClose:()=>R(false),title:"Insert Table",children:jsxs("div",{className:"luthor-table-dialog",children:[jsxs("div",{className:"luthor-form-group",children:[jsx("label",{htmlFor:"table-rows",children:"Rows:"}),jsx("input",{id:"table-rows",type:"number",min:"1",max:"20",value:ee.rows,onChange:f=>Le(y=>({...y,rows:parseInt(f.target.value)||1})),className:"luthor-input"})]}),jsxs("div",{className:"luthor-form-group",children:[jsx("label",{htmlFor:"table-columns",children:"Columns:"}),jsx("input",{id:"table-columns",type:"number",min:"1",max:"20",value:ee.columns,onChange:f=>Le(y=>({...y,columns:parseInt(f.target.value)||1})),className:"luthor-input"})]}),jsx("div",{className:"luthor-form-group",children:jsxs("label",{className:"luthor-checkbox-label",children:[jsx("input",{type:"checkbox",checked:ee.includeHeaders||false,onChange:f=>Le(y=>({...y,includeHeaders:f.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(to,{variant:"secondary",onClick:()=>R(false),children:"Cancel"}),jsx(to,{variant:"primary",onClick:()=>{e.insertTable(ee),R(false);},children:"Insert Table"})]})]})})]})}var fo=["bold","italic","underline","strikethrough","fontFamily","fontSize","lineHeight","textColor","textHighlight","subscript","superscript","link","horizontalRule","table","list","history","image","blockFormat","code","codeIntelligence","codeFormat","tabIndent","enterKeyBehavior","iframeEmbed","youTubeEmbed","floatingToolbar","contextMenu","commandPalette","slashCommand","emoji","draggableBlock","customNode","themeToggle"],Sn={bold:true,italic:true,underline:true,strikethrough:true,fontFamily:true,fontSize:true,lineHeight:true,textColor:true,textHighlight:true,subscript:true,superscript:true,link:true,horizontalRule:true,table:true,list:true,history:true,image:true,blockFormat:true,code:true,codeIntelligence:true,codeFormat:true,tabIndent:true,enterKeyBehavior:true,iframeEmbed:true,youTubeEmbed:true,floatingToolbar:true,contextMenu:true,commandPalette:true,slashCommand:true,emoji:true,draggableBlock:true,customNode:true,themeToggle:true};function It(e){let t={...Sn};if(!e)return t;for(let n of fo)typeof e[n]=="boolean"&&(t[n]=e[n]);return t}function Ln(e,t){return e[t]!==false}var En=[{value:"default",label:"Default",fontFamily:"inherit"},{value:"inter",label:"Inter",fontFamily:"'Inter', 'Segoe UI', Arial, sans-serif",cssImportUrl:"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"},{value:"merriweather",label:"Merriweather",fontFamily:"'Merriweather', Georgia, 'Times New Roman', serif",cssImportUrl:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700&display=swap"},{value:"jetbrains-mono",label:"JetBrains Mono",fontFamily:"'JetBrains Mono', 'Courier New', monospace",cssImportUrl:"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap"}],fi={value:"default",label:"Default",fontFamily:"inherit"},xn=[{value:"default",label:"Default",fontSize:"inherit"},{value:"12",label:"12px",fontSize:"12px"},{value:"14",label:"14px",fontSize:"14px"},{value:"16",label:"16px",fontSize:"16px"},{value:"18",label:"18px",fontSize:"18px"},{value:"20",label:"20px",fontSize:"20px"},{value:"24",label:"24px",fontSize:"24px"},{value:"32",label:"32px",fontSize:"32px"}],pi={value:"default",label:"Default",fontSize:"inherit"},Tn=[{value:"default",label:"Default",lineHeight:"1.5"},{value:"1",label:"1.0",lineHeight:"1"},{value:"1.15",label:"1.15",lineHeight:"1.15"},{value:"1.5",label:"1.5",lineHeight:"1.5"},{value:"1.75",label:"1.75",lineHeight:"1.75"},{value:"2",label:"2.0",lineHeight:"2"}],bi={value:"default",label:"Default",lineHeight:"1.5"},Lt="1.5",yi=1;function at(e){return e.trim().toLowerCase()}function In(e){return /^[a-z0-9][a-z0-9-]*$/i.test(e)}function vi(e){return at(e)==="default"?true:Jt(e)!==null}function Ci(e){let t=e??En,n=new Set,o=[];for(let r of t){let i=r.value.trim(),a=r.label.trim(),d=r.fontFamily.trim();if(!i||!a||!d||!In(i))continue;let c=at(i);n.has(c)||(n.add(c),o.push({value:i,label:a,fontFamily:d,cssImportUrl:r.cssImportUrl?.trim()||void 0}));}return o.length===0?En:o.some(r=>at(r.value)==="default")?o:[fi,...o]}function ki(e){let t=e??xn,n=new Set,o=[];for(let r of t){let i=String(r.value).trim(),a=String(r.label).trim(),d=String(r.fontSize).trim();if(!i||!a||!d||!In(i))continue;let c=at(i);n.has(c)||(n.add(c),o.push({value:i,label:a,fontSize:d}));}return o.length===0?xn:o.some(r=>at(r.value)==="default")?o:[pi,...o]}function Jt(e){let t=e.trim();if(!/^\d*\.?\d+$/.test(t))return null;let n=Number(t);return !Number.isFinite(n)||n<yi?null:n.toString()}function Ei(e){return typeof e=="number"?Number.isFinite(e)?Jt(e.toString())??Lt:Lt:typeof e=="string"?Jt(e)??Lt:Lt}function xi(e,t=Lt){let n=e??Tn,o=new Set,l=[];for(let i of n){let a=String(i.value).trim(),d=String(i.label).trim();if(!a||!d||!vi(a))continue;let c=at(a);if(o.has(c))continue;if(c==="default"){o.add(c),l.push({value:a,label:d,lineHeight:t});continue}let E=Jt(String(i.lineHeight));E&&(o.add(c),l.push({value:a,label:d,lineHeight:E}));}return l.length===0?Tn:l.some(i=>at(i.value)==="default")?l:[{...bi,lineHeight:t},...l]}function et({children:e}){return jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e})}var Ti=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M10.5 14.5h3"}),jsx("path",{d:"M12 2.8v4.4"}),jsx("path",{d:"M9.8 5h4.4"})]}),Si=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M10.5 8.5h3"}),jsx("path",{d:"M12 16.8v4.4"}),jsx("path",{d:"M9.8 19h4.4"})]}),Li=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M11.5 5v14"}),jsx("path",{d:"M7.5 10.5v3"}),jsx("path",{d:"M2.8 12h4.4"}),jsx("path",{d:"M5 9.8v4.4"})]}),Ii=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M12.5 5v14"}),jsx("path",{d:"M16.5 10.5v3"}),jsx("path",{d:"M16.8 12h4.4"}),jsx("path",{d:"M19 9.8v4.4"})]}),Fi=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M9.8 14.8l4.4 4.4"}),jsx("path",{d:"M14.2 14.8l-4.4 4.4"})]}),wi=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M12 5v14"}),jsx("path",{d:"M14.8 9.8l4.4 4.4"}),jsx("path",{d:"M19.2 9.8l-4.4 4.4"})]}),Oi=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 10.5h17"}),jsx("path",{d:"M10.5 5v14"}),jsx("path",{d:"M14.8 9.8l4.4 4.4"}),jsx("path",{d:"M19.2 9.8l-4.4 4.4"})]}),Ni=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 10.5h17"}),jsx("path",{d:"M10.5 5v14"}),jsx("path",{d:"M3.5 8h17"})]}),qt=new ImageExtension;qt.config={...qt.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var so=new TableExtension;so.config={...so.config,enableContextMenu:true,tableBubbleRenderer:({headersEnabled:e,setHeadersEnabled:t,actions:n})=>jsxs(Fragment,{children:[jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert row above","aria-label":"Insert row above",onClick:n.insertRowAbove,children:jsx(Ti,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert row below","aria-label":"Insert row below",onClick:n.insertRowBelow,children:jsx(Si,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column left","aria-label":"Insert column left",onClick:n.insertColumnLeft,children:jsx(Li,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column right","aria-label":"Insert column right",onClick:n.insertColumnRight,children:jsx(Ii,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected row","aria-label":"Delete selected row",onClick:n.deleteSelectedRow,children:jsx(Fi,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected column","aria-label":"Delete selected column",onClick:n.deleteSelectedColumn,children:jsx(wi,{})}),jsx("label",{className:"luthor-table-bubble-checkbox",title:"Use first row as table headers",children:jsx("button",{type:"button",className:`luthor-table-bubble-button luthor-table-bubble-button-icon${e?" luthor-table-bubble-button-active":""}`,title:"Use first row as table headers","aria-label":"Use first row as table headers","aria-pressed":e,onClick:()=>t(!e),children:jsx(Ni,{})})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon luthor-table-bubble-button-danger",title:"Delete table","aria-label":"Delete table",onClick:n.deleteTable,children:jsx(Oi,{})})]})};var uo=new IframeEmbedExtension;uo.config={...uo.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center"};var co=new YouTubeEmbedExtension;co.config={...co.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center",nocookie:true,controls:true,rel:1};var Hi=ln(),go=new ContextMenuExtension;go.config={...go.config,preventDefault:true};var Mi=new CommandPaletteExtension,zi=new SlashCommandExtension,Pi=new EmojiExtension,mo=new DraggableBlockExtension;mo.config={...mo.config,buttonStackPosition:"left"};var ho=new LinkExtension;ho.config={...ho.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var Ri=textColorExtension.configure({options:[{value:"default",label:"Default",color:"inherit"},{value:"slate",label:"Slate",color:"#334155"},{value:"red",label:"Red",color:"#dc2626"},{value:"orange",label:"Orange",color:"#ea580c"},{value:"green",label:"Green",color:"#16a34a"},{value:"blue",label:"Blue",color:"#2563eb"},{value:"purple",label:"Purple",color:"#7c3aed"}]}),Ai=textHighlightExtension.configure({options:[{value:"default",label:"Default",backgroundColor:"transparent"},{value:"yellow",label:"Yellow",backgroundColor:"#fef08a"},{value:"green",label:"Green",backgroundColor:"#bbf7d0"},{value:"blue",label:"Blue",backgroundColor:"#bfdbfe"},{value:"pink",label:"Pink",backgroundColor:"#fbcfe8"},{value:"orange",label:"Orange",backgroundColor:"#fed7aa"}]}),{extension:Bi}=createCustomNodeExtension({nodeType:"featureCard",defaultPayload:{title:"Headless Custom Node",description:"This block is rendered by createCustomNodeExtension from @lyfie/luthor-headless.",tag:"Custom"},render:({payload:e,isSelected:t})=>jsxs("aside",{className:`luthor-extensive-feature-card${t?" is-selected":""}`,children:[jsx("div",{className:"luthor-extensive-feature-card__tag",children:e.tag??"Custom"}),jsx("h4",{className:"luthor-extensive-feature-card__title",children:e.title??"Custom Node"}),jsx("p",{className:"luthor-extensive-feature-card__description",children:e.description??"Insert strongly typed custom content blocks."})]})});function Fn({fontFamilyOptions:e,fontSizeOptions:t,lineHeightOptions:n,minimumDefaultLineHeight:o,featureFlags:l,isDraggableBoxEnabled:r,scaleByRatio:i,syntaxHighlighting:a,codeHighlightProvider:d,loadCodeHighlightProvider:c,maxAutoDetectCodeLength:E,isCopyAllowed:h,languageOptions:b}={}){let m=It(l),p=ne=>Ln(m,ne),$=(r??true)&&p("draggableBlock"),N=Ei(o),A=new FontFamilyExtension().configure({options:Ci(e),cssLoadStrategy:"on-demand"}),W=new FontSizeExtension().configure({options:ki(t)}),J=new LineHeightExtension().configure({options:xi(n,N),defaultLineHeight:N});qt.configure({scaleByRatio:i??false}),codeExtension.configure({syntaxHighlighting:a??"auto",provider:d??void 0,loadProvider:c}),codeIntelligenceExtension.configure({provider:d??void 0,loadProvider:c,maxAutoDetectLength:E,isCopyAllowed:h??true,languageOptions:b});let v=[];return p("bold")&&v.push(boldExtension),p("italic")&&v.push(italicExtension),p("underline")&&v.push(underlineExtension),p("strikethrough")&&v.push(strikethroughExtension),p("fontFamily")&&v.push(A),p("fontSize")&&v.push(W),p("lineHeight")&&v.push(J),p("textColor")&&v.push(Ri),p("textHighlight")&&v.push(Ai),p("subscript")&&v.push(subscriptExtension),p("superscript")&&v.push(superscriptExtension),p("link")&&v.push(ho),p("horizontalRule")&&v.push(horizontalRuleExtension),p("table")&&v.push(so),p("list")&&v.push(listExtension),p("history")&&v.push(historyExtension),p("image")&&v.push(qt),p("blockFormat")&&v.push(blockFormatExtension),p("code")&&v.push(codeExtension),p("codeIntelligence")&&v.push(codeIntelligenceExtension),p("codeFormat")&&v.push(codeFormatExtension),p("tabIndent")&&v.push(tabIndentExtension),p("enterKeyBehavior")&&v.push(enterKeyBehaviorExtension),p("iframeEmbed")&&v.push(uo),p("youTubeEmbed")&&v.push(co),p("floatingToolbar")&&v.push(Hi),p("contextMenu")&&v.push(go),p("commandPalette")&&v.push(Mi),p("slashCommand")&&v.push(zi),p("emoji")&&v.push(Pi),$&&v.push(mo),p("customNode")&&v.push(Bi),v}function Ft(e){return Fn(e)}var po=Fn();function wn(e){if(!e)return "__default__";let t=Object.entries(e).filter(([,n])=>typeof n=="string"&&n.trim().length>0).sort(([n],[o])=>n.localeCompare(o));return t.length>0?JSON.stringify(t):"__default__"}function On(e){if(!e)return;let t={},n=(o,l)=>{typeof l=="string"&&l.trim().length>0&&(t[o]=l.trim());};return n("--luthor-fg",e.font?.color),n("--luthor-text-bold-color",e.font?.boldColor),n("--luthor-link-color",e.link?.color),n("--luthor-list-marker-color",e.list?.markerColor),n("--luthor-list-checkbox-color",e.list?.checkboxColor),n("--luthor-quote-bg",e.quote?.backgroundColor),n("--luthor-quote-fg",e.quote?.color),n("--luthor-quote-border",e.quote?.indicatorColor),n("--luthor-table-border-color",e.table?.borderColor),n("--luthor-table-header-bg",e.table?.headerBackgroundColor),n("--luthor-hr-color",e.hr?.color),n("--luthor-placeholder-color",e.placeholder?.color),n("--luthor-codeblock-bg",e.codeblock?.backgroundColor),n("--luthor-toolbar-bg",e.toolbar?.backgroundColor),Object.keys(t).length>0?t:void 0}function Nn(e){if(!(e instanceof Element))return false;if(e.closest('[contenteditable="true"]'))return true;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"}function Hn(e,t){if(e.key.toLowerCase()!==t.key.toLowerCase())return false;let n=e.ctrlKey||e.metaKey;return !(!!t.requiresPrimary!==n||!!t.shift!=!!e.shiftKey||!!t.alt!=!!e.altKey)}function Mn(e,t,n){let o={...e??{}};for(let[l,r]of Object.entries(n))(Array.isArray(r)?r:[r]).some(d=>t[d]!==false)||(o[l]=false);return o}function zn(e,t,n){let o={...e},l=(r,i)=>{t[r]===false&&i();};return l("bold",()=>{o.toggleBold=()=>{};}),l("italic",()=>{o.toggleItalic=()=>{};}),l("underline",()=>{o.toggleUnderline=()=>{};}),l("strikethrough",()=>{o.toggleStrikethrough=()=>{};}),l("codeFormat",()=>{o.formatText=()=>{};}),l("fontFamily",()=>{o.setFontFamily=()=>{},o.clearFontFamily=()=>{};}),l("fontSize",()=>{o.setFontSize=()=>{},o.clearFontSize=()=>{};}),l("lineHeight",()=>{o.setLineHeight=()=>{},o.clearLineHeight=()=>{};}),l("textColor",()=>{o.setTextColor=()=>{},o.clearTextColor=()=>{};}),l("textHighlight",()=>{o.setTextHighlight=()=>{},o.clearTextHighlight=()=>{};}),l("subscript",()=>{o.toggleSubscript=()=>{};}),l("superscript",()=>{o.toggleSuperscript=()=>{};}),l("link",()=>{o.insertLink=()=>{},o.removeLink=()=>{},o.updateLink=()=>false,o.getCurrentLink=async()=>null,o.getLinkByKey=async()=>null,o.updateLinkByKey=()=>false,o.removeLinkByKey=()=>false;}),l("blockFormat",()=>{o.toggleParagraph=()=>{},o.toggleHeading=()=>{},o.toggleQuote=()=>{},o.setTextAlignment=()=>{};}),l("code",()=>{o.toggleCodeBlock=()=>{};}),l("codeIntelligence",()=>{o.setCodeLanguage=()=>{},o.autoDetectCodeLanguage=async()=>null,o.copySelectedCodeBlock=async()=>false;}),l("list",()=>{o.toggleUnorderedList=()=>{},o.toggleOrderedList=()=>{},o.toggleCheckList=()=>{},o.indentList=()=>{},o.outdentList=()=>{};}),l("horizontalRule",()=>{o.insertHorizontalRule=()=>{};}),l("table",()=>{o.insertTable=()=>{};}),l("image",()=>{o.insertImage=()=>{},o.setImageAlignment=()=>{},o.setImageCaption=()=>{},o.getImageCaption=async()=>"";}),l("emoji",()=>{o.insertEmoji=()=>{},o.executeEmojiSuggestion=()=>false,o.closeEmojiSuggestions=()=>{},o.getEmojiSuggestions=()=>[],o.getEmojiCatalog=()=>[],o.resolveEmojiShortcode=()=>null,o.setEmojiCatalog=()=>{},o.setEmojiCatalogAdapter=()=>{},o.getEmojiCatalogAdapter=()=>({search:()=>[],resolveShortcode:()=>null,getAll:()=>[]});}),l("iframeEmbed",()=>{o.insertIframeEmbed=()=>{},o.setIframeEmbedAlignment=()=>{},o.resizeIframeEmbed=()=>{},o.setIframeEmbedCaption=()=>{},o.getIframeEmbedCaption=async()=>"",o.updateIframeEmbedUrl=()=>false,o.getIframeEmbedUrl=async()=>"";}),l("youTubeEmbed",()=>{o.insertYouTubeEmbed=()=>{},o.setYouTubeEmbedAlignment=()=>{},o.resizeYouTubeEmbed=()=>{},o.setYouTubeEmbedCaption=()=>{},o.getYouTubeEmbedCaption=async()=>"",o.updateYouTubeEmbedUrl=()=>false,o.getYouTubeEmbedUrl=async()=>"";}),l("history",()=>{o.undo=()=>{},o.redo=()=>{};}),l("commandPalette",()=>{o.showCommandPalette=()=>{},o.hideCommandPalette=()=>{},o.registerCommand=()=>{},o.unregisterCommand=()=>{};}),l("slashCommand",()=>{o.registerSlashCommand=()=>{},o.unregisterSlashCommand=()=>{},o.setSlashCommands=()=>{},o.closeSlashMenu=()=>{},o.executeSlashCommand=()=>false;}),n&&(o.toggleBold=()=>{},o.toggleItalic=()=>{},o.toggleUnderline=()=>{},o.toggleStrikethrough=()=>{},o.formatText=()=>{},o.setFontFamily=()=>{},o.clearFontFamily=()=>{},o.setFontSize=()=>{},o.clearFontSize=()=>{},o.setLineHeight=()=>{},o.clearLineHeight=()=>{},o.setTextColor=()=>{},o.clearTextColor=()=>{},o.setTextHighlight=()=>{},o.clearTextHighlight=()=>{},o.toggleSubscript=()=>{},o.toggleSuperscript=()=>{},o.insertLink=()=>{},o.removeLink=()=>{},o.updateLink=()=>false,o.toggleParagraph=()=>{},o.toggleHeading=()=>{},o.toggleQuote=()=>{},o.setTextAlignment=()=>{},o.toggleUnorderedList=()=>{},o.toggleOrderedList=()=>{},o.toggleCheckList=()=>{},o.indentList=()=>{},o.outdentList=()=>{},o.insertHorizontalRule=()=>{},o.insertTable=()=>{},o.insertImage=()=>{},o.setImageAlignment=()=>{},o.setImageCaption=()=>{},o.insertIframeEmbed=()=>{},o.setIframeEmbedAlignment=()=>{},o.resizeIframeEmbed=()=>{},o.setIframeEmbedCaption=()=>{},o.updateIframeEmbedUrl=()=>false,o.insertYouTubeEmbed=()=>{},o.setYouTubeEmbedAlignment=()=>{},o.resizeYouTubeEmbed=()=>{},o.setYouTubeEmbedCaption=()=>{},o.updateYouTubeEmbedUrl=()=>false),o}function Pn(e){return new Set(e)}function Rn(e,t){e.clear();for(let n of t)e.add(n);}function An(e,t){return e.has(t)}function Bn(e,t){e.add(t);}var H=(e,t=0,n="")=>({type:"text",version:1,text:e,detail:0,format:t,mode:"normal",style:n}),pe=(e,t="",n=0)=>({type:"paragraph",version:1,format:t,indent:n,direction:null,children:e}),bo={root:{type:"root",version:1,format:"",indent:0,direction:null,children:[{type:"heading",version:1,tag:"h1",format:"",indent:0,direction:null,children:[H("Extensive Preset: JSON-First Feature Showcase")]},pe([H("This starter content is now a native "),H("JSON",1),H(" document that demonstrates visual editing without Markdown conversion.")]),{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[H("Inline formatting + typography")]},pe([H("Bold",1),H(" \u2022 "),H("Italic",2),H(" \u2022 "),H("Underline",8),H(" \u2022 "),H("Strikethrough",4),H(" \u2022 "),H("Inline Code",16),H(" \u2022 "),H("Subscript",32),H(" \u2022 "),H("Superscript",64)]),pe([H("Font family + size + color + highlight + line-height can be combined in one sentence.",0,"font-family: 'Inter', 'Segoe UI', Arial, sans-serif; font-size: 18px; line-height: 1.75; color: #2563eb; background-color: #bfdbfe;")]),{type:"paragraph",version:1,format:"center",indent:0,direction:null,children:[H("Centered paragraph with custom style",0,"font-size: 20px; color: #7c3aed;")]},{type:"paragraph",version:1,format:"right",indent:0,direction:null,children:[H("Right-aligned paragraph with highlight",128,"background-color: #fef08a;")]},{type:"quote",version:1,format:"",indent:0,direction:null,children:[H("\u201CEverything in this demo is persisted in JSON and can round-trip via visual mode.\u201D")]},{type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"link",version:1,rel:"noreferrer",target:"_blank",title:"Luthor documentation",url:"https://github.com/facebook/lexical",format:"",indent:0,direction:null,children:[H("Example link node")]},H(" with regular sibling text and emoji support \u{1F389}\u{1F525}\u2705.")]},{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[H("Lists")]},{type:"list",version:1,listType:"bullet",start:1,tag:"ul",format:"",indent:0,direction:null,children:[{type:"listitem",version:1,value:1,format:"",indent:0,direction:null,children:[pe([H("Bullet item with styled text",0,"color: #16a34a;")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[pe([H("Nested formatting in lists",1),H(" works great.")])]}]},{type:"list",version:1,listType:"number",start:1,tag:"ol",format:"",indent:0,direction:null,children:[{type:"listitem",version:1,value:1,format:"",indent:0,direction:null,children:[pe([H("Numbered item 1")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[pe([H("Numbered item 2")])]}]},{type:"list",version:1,listType:"check",start:1,tag:"ul",format:"",indent:0,direction:null,children:[{type:"listitem",version:1,value:1,checked:true,format:"",indent:0,direction:null,children:[pe([H("Checked task item")])]},{type:"listitem",version:1,value:2,checked:false,format:"",indent:0,direction:null,children:[pe([H("Unchecked task item")])]}]},{children:[{detail:0,format:0,mode:"normal",style:"",text:"const",type:"code-highlight",version:1,highlightType:"keyword"},{detail:0,format:0,mode:"normal",style:"",text:" content ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"=",type:"code-highlight",version:1,highlightType:"operator"},{detail:0,format:0,mode:"normal",style:"",text:" exportApi",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"toJSON",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"},{type:"linebreak",version:1},{detail:0,format:0,mode:"normal",style:"",text:"await",type:"code-highlight",version:1,highlightType:"keyword"},{detail:0,format:0,mode:"normal",style:"",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"saveToDatabase",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"{",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:" json",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:":",type:"code-highlight",version:1,highlightType:"operator"},{detail:0,format:0,mode:"normal",style:"",text:" content ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"}",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"},{type:"linebreak",version:1},{detail:0,format:0,mode:"normal",style:"",text:"importApi",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"fromJSON",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"content",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"}],direction:null,format:"",indent:0,type:"code",version:1,language:"typescript"},{type:"horizontalrule",version:1},{type:"featureCard",version:1,payload:{title:"Custom Node: Feature Card",description:"This block is rendered with createCustomNodeExtension and persists as structured payload.",tag:"Custom"},format:"",indent:0,direction:null,children:[]},{type:"image",version:1,src:"https://images.unsplash.com/photo-1461749280684-dccba630e2f6?auto=format&fit=crop&w=1200&q=80",alt:"Code editor on a laptop",caption:"Image node with caption, center alignment, and persisted dimensions.",alignment:"center",width:780,height:420},{type:"youtube-embed",version:1,src:"https://www.youtube.com/embed/dQw4w9WgXcQ",width:720,height:405,alignment:"center",start:0},{type:"iframe-embed",version:1,src:"https://example.com",width:720,height:405,alignment:"center",title:"Iframe embed example"},{type:"table",version:1,format:"",indent:0,direction:null,children:[{type:"tablerow",version:1,children:[{type:"tablecell",version:1,headerState:3,colSpan:1,rowSpan:1,width:240,backgroundColor:null,children:[pe([H("Feature")])]},{type:"tablecell",version:1,headerState:3,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[pe([H("Status")])]}]},{type:"tablerow",version:1,children:[{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:240,backgroundColor:null,children:[pe([H("Visual \u2194 JSON switching")])]},{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[pe([H("Round-trip ready \u2705")])]}]}]},pe([H("Use the toolbar, floating toolbar, slash commands (/), and command palette (Ctrl/Cmd+Shift+P) to explore the full preset.")])]}};JSON.stringify(bo);var{Provider:Yi,useEditor:Gi}=createEditorSystem(),Dn="Write anything...",Kn="Enter JSON document content...";function Qi(e){let n=e.replace(/\r\n?/g,`
3
- `).trim().split(/\n{2,}/).map(l=>l.replace(/\s+/g," ").trim()).filter(l=>l.length>0);return {root:{type:"root",version:1,format:"",indent:0,direction:null,children:(n.length>0?n:[""]).map(l=>({type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"text",version:1,text:l,detail:0,format:0,mode:"normal",style:""}]}))}}}function Wi(e){try{let t=JSON.parse(e);return JSON.stringify(t)}catch{return JSON.stringify(Qi(e))}}function Xi(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:t.value.trim(),label:t.label.trim(),fontFamily:t.fontFamily.trim(),cssImportUrl:t.cssImportUrl?.trim()||""})))}function Zi(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:String(t.value).trim(),label:String(t.label).trim(),fontSize:String(t.fontSize).trim()})))}function el(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:String(t.value).trim(),label:String(t.label).trim(),lineHeight:String(t.lineHeight).trim()})))}function tl(e){if(typeof e=="number")return !Number.isFinite(e)||e<1?"1.5":e.toString();if(typeof e=="string"){let n=e.trim();if(n.length===0)return "1.5";let o=Number(n);return !Number.isFinite(o)||o<1?"1.5":o.toString()}return "1.5"}function yo(e){return wn(e)}function ol(e){if(!e)return "__default__";if(Array.isArray(e))return JSON.stringify({mode:"append",values:e.map(o=>o.trim())});let t=e,n=Array.isArray(t.values)?t.values:[];return JSON.stringify({mode:t.mode??"append",values:n.map(o=>o.trim())})}function nl(e){return On(e)}function rl(e){let t=It(e);return JSON.stringify(fo.map(n=>[n,t[n]]))}function Un(e){return Nn(e)}var il=[{feature:"bold",key:"b",requiresPrimary:true},{feature:"italic",key:"i",requiresPrimary:true},{feature:"underline",key:"u",requiresPrimary:true},{feature:"link",key:"k",requiresPrimary:true},{feature:"history",key:"z",requiresPrimary:true},{feature:"history",key:"y",requiresPrimary:true},{feature:"history",key:"z",requiresPrimary:true,shift:true},{feature:"commandPalette",key:"p",requiresPrimary:true,shift:true},{feature:"codeFormat",key:"`",requiresPrimary:true},{feature:"code",key:"`",requiresPrimary:true,shift:true},{feature:"list",key:"l",requiresPrimary:true,shift:true},{feature:"list",key:"l",requiresPrimary:true,alt:true},{feature:"list",key:"x",requiresPrimary:true,shift:true},{feature:"blockFormat",key:"0",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"1",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"2",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"3",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"4",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"5",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"6",requiresPrimary:true,alt:true}];function ll(e,t){return Hn(e,t)}function al(e,t,n){return zn(e,t,n)}var sl={fontFamily:"fontFamily",fontSize:"fontSize",lineHeight:"lineHeight",textColor:"textColor",textHighlight:"textHighlight",bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",subscript:"subscript",superscript:"superscript",code:"codeFormat",link:"link",blockFormat:"blockFormat",quote:"blockFormat",alignLeft:"blockFormat",alignCenter:"blockFormat",alignRight:"blockFormat",alignJustify:"blockFormat",codeBlock:"code",unorderedList:"list",orderedList:"list",checkList:"list",indentList:"list",outdentList:"list",horizontalRule:"horizontalRule",table:"table",image:"image",emoji:"emoji",embed:["iframeEmbed","youTubeEmbed"],undo:"history",redo:"history",commandPalette:"commandPalette",themeToggle:"themeToggle"};function ul(e,t){return Mn(e,t,sl)}function cl(e){if(!e||e.length===0)return [...Ie];let t=new Set,n=[];for(let o of e)!Ie.includes(o)||t.has(o)||(t.add(o),n.push(o));return n.length>0?n:[...Ie]}function dl(e){if(!e)return "__default__";if(Array.isArray(e)){let r=new Set,i=[];for(let a of e)for(let[d,c]of Object.entries(a)){let E=d.trim();!c||!E||r.has(E)||(r.add(E),i.push(E));}return i.length===0?"__default__":JSON.stringify({allowlist:i,denylist:[]})}let t=r=>{if(!r||r.length===0)return [];let i=new Set,a=[];for(let d of r){let c=d.trim();!c||i.has(c)||(i.add(c),a.push(c));}return a},n=e,o=t(n.allowlist),l=t(n.denylist);return o.length===0&&l.length===0?"__default__":JSON.stringify({allowlist:o,denylist:l})}function gl(e){if(!e||e.length===0)return [];let t=new Set,n=[];for(let o of e){let l=o.trim();!l||t.has(l)||(t.add(l),n.push(l));}return n}function ml(e,t){return e.key.toLowerCase()===t.key.toLowerCase()&&!!e.ctrlKey==!!t.ctrlKey&&!!e.metaKey==!!t.metaKey&&!!e.shiftKey==!!t.shiftKey&&!!e.altKey==!!t.altKey}function hl(e){if(!e)return "__default__";let t=Array.isArray(e.disabledCommandIds)?[...e.disabledCommandIds].map(o=>o.trim()).filter(o=>o.length>0).sort((o,l)=>o.localeCompare(l)):[],n=e.bindings?Object.entries(e.bindings).map(([o,l])=>{if(l===false||l===null)return [o,false];let i=(Array.isArray(l)?l:[l]).map(a=>({key:a.key.trim(),ctrlKey:!!a.ctrlKey,metaKey:!!a.metaKey,shiftKey:!!a.shiftKey,altKey:!!a.altKey,preventDefault:a.preventDefault})).filter(a=>a.key.length>0).sort((a,d)=>{let c=`${a.key}:${a.ctrlKey?1:0}:${a.metaKey?1:0}:${a.shiftKey?1:0}:${a.altKey?1:0}`,E=`${d.key}:${d.ctrlKey?1:0}:${d.metaKey?1:0}:${d.shiftKey?1:0}:${d.altKey?1:0}`;return c.localeCompare(E)});return i.length===0?[o,false]:[o,i]}).sort(([o],[l])=>o.localeCompare(l)):[];return JSON.stringify({disabledCommandIds:t,bindings:n,preventCollisions:e.preventCollisions!==false,preventNativeConflicts:e.preventNativeConflicts!==false})}function fl({isDark:e,toggleTheme:t,visualPlaceholder:n,jsonPlaceholder:o,initialMode:l,availableModes:r,onReady:i,toolbarLayout:a,toolbarVisibility:d,toolbarPosition:c,toolbarAlignment:E,toolbarClassName:h,toolbarStyleVars:b,isToolbarEnabled:m,headingOptions:p,paragraphLabel:$,syncHeadingOptionsWithCommands:N,slashCommandVisibility:A,shortcutConfig:W,commandPaletteShortcutOnly:J,featureFlags:v}){let{commands:ne,hasExtension:se,activeStates:Y,lexical:g,extensions:O,export:k,import:V}=Gi(),[R,oe]=useState(l),[B,be]=useState({json:""}),[ie,Fe]=useState(null),[ue,we]=useState(null),[Oe,Ne]=useState({isOpen:false,commands:[]}),[ge,He]=useState({isOpen:false,query:"",position:null,commands:[]}),[Ae,Me]=useState({isOpen:false,query:"",position:null,suggestions:[]}),me=useRef(false),ze=useMemo(()=>cl(p),[p]),ye=N?ze:void 0,he=N?$:void 0,F=Y.isInCodeBlock===true,I=useMemo(()=>al(ne,v,F),[ne,v,F]),q=useMemo(()=>C=>Object.prototype.hasOwnProperty.call(v,C)?v[C]!==false:true,[v]),tt=useMemo(()=>ul(d,v),[d,v]),ve=v.draggableBlock!==false,Te=dl(A),Je=useRef(A),Se=useRef(Te),Be=hl(W),ee=useRef(W),Le=useRef(Be),Pe=useMemo(()=>gl(W?.disabledCommandIds),[W?.disabledCommandIds]),le=useMemo(()=>new Set(Pe),[Pe]),Ce=useMemo(()=>le.size===0?[]:Qt({headingOptions:ye,paragraphLabel:he,isFeatureEnabled:q}).filter(C=>le.has(C.id)).flatMap(C=>C.shortcuts??[]),[le,ye,he,q]);Se.current!==Te&&(Se.current=Te,Je.current=A),Le.current!==Be&&(Le.current=Be,ee.current=W);let De=useRef(Pn(["visual"])),U=useRef(0);useEffect(()=>{oo(I,Y,e?"dark":"light",q);},[I,Y,e,q]);let Re=useMemo(()=>({injectJSON:D=>{setTimeout(()=>{try{let G=JSON.parse(D);V.fromJSON(G);}catch(G){console.error("Failed to inject JSON:",G);return}},100);},getJSON:()=>io(JSON.stringify(k.toJSON()))}),[k,V]);useEffect(()=>{if(!g||!I)return;let C=I,T=So(C,{headingOptions:ye,paragraphLabel:he,isFeatureEnabled:q,shortcutConfig:ee.current,commandPaletteShortcutOnly:J});typeof C.registerCommand=="function"&&T.forEach(X=>C.registerCommand(X));let D=Lo(C,{headingOptions:ye,paragraphLabel:he,slashCommandVisibility:Je.current,isFeatureEnabled:q,shortcutConfig:ee.current});typeof C.setSlashCommands=="function"?C.setSlashCommands(D):D.forEach(X=>C.registerSlashCommand?.(X));let G=Fo(C,document.body,{headingOptions:ye,paragraphLabel:he,isFeatureEnabled:q,shortcutConfig:ee.current,scope:()=>g.getRootElement()});return me.current||(me.current=true,i?.(Re)),()=>{G(),typeof C.unregisterCommand=="function"&&T.forEach(X=>C.unregisterCommand(X.id)),typeof C.setSlashCommands=="function"?C.setSlashCommands([]):D.forEach(X=>C.unregisterSlashCommand?.(X.id));}},[g,I,Re,i,ye,he,Te,Be,q,J]),useEffect(()=>{let C=()=>g?.getRootElement(),T=il.filter(G=>v[G.feature]===false);if(T.length===0)return;let D=G=>{let X=C();X&&G.target instanceof Node&&!X.contains(G.target)||!Un(G.target)||!T.some(f=>ll(G,f))||(G.preventDefault(),G.stopPropagation());};return document.addEventListener("keydown",D,true),()=>{document.removeEventListener("keydown",D,true);}},[g,v]),useEffect(()=>{let C=O.find(T=>T.name==="commandPalette");if(!(!C||!C.subscribe))return C.subscribe((T,D)=>{let G=D.filter(X=>le.has(X.id)?false:J?typeof X.shortcut=="string"&&X.shortcut.trim().length>0:true);Ne({isOpen:T,commands:G});})},[O,le,J]),useEffect(()=>{if(Ce.length===0)return;let C=()=>g?.getRootElement(),T=D=>{let G=C();G&&D.target instanceof Node&&!G.contains(D.target)||!Un(D.target)||!Ce.some(Qe=>ml(D,Qe))||(D.preventDefault(),D.stopPropagation());};return document.addEventListener("keydown",T,true),()=>{document.removeEventListener("keydown",T,true);}},[g,Ce]),useEffect(()=>{let C=O.find(T=>T.name==="slashCommand");if(!(!C||!C.subscribe))return C.subscribe(T=>{He({isOpen:T.isOpen,query:T.query,position:T.position,commands:T.commands});})},[O]),useEffect(()=>{let C=O.find(T=>T.name==="emoji");if(!(!C||!C.subscribe))return C.subscribe(T=>{Me({isOpen:T.isOpen,query:T.query,position:T.position,suggestions:T.suggestions});})},[O]),useEffect(()=>!g||!k?void 0:g.registerUpdateListener(()=>{U.current+=1,Rn(De.current,["visual"]);}),[g,k]);let ot=async C=>{if(r.includes(C))try{if(we(null),R==="json"&&C!=="json"){let T=JSON.parse(B.json);V.fromJSON(T),await new Promise(D=>setTimeout(D,50));}if(R==="visual"&&C!=="visual"&&(g&&clearLexicalSelection(g),g?.getRootElement()?.blur()),oe(C),C==="json"&&R!=="json"&&!An(De.current,"json")){Fe("json"),await new Promise(T=>setTimeout(T,50));try{let T=io(JSON.stringify(k.toJSON()));be(D=>({...D,json:T})),Bn(De.current,"json");}finally{Fe(null);}}C==="visual"&&setTimeout(()=>g?.focus(),100);}catch(T){let D=T instanceof Error?T.message:"Invalid format - could not parse content";we({mode:R,error:D});}},qe=m?jsx(vn,{commands:I,hasExtension:C=>se(C),activeStates:Y,isDark:e,toggleTheme:t,onCommandPaletteOpen:()=>{v.commandPalette!==false&&I.showCommandPalette();},imageUploadHandler:C=>O.find(T=>T.name==="image")?.config?.uploadHandler?.(C)??Promise.resolve(URL.createObjectURL(C)),layout:a??Ot,toolbarVisibility:tt,toolbarStyleVars:b,headingOptions:ze,paragraphLabel:$,classNames:{toolbar:`luthor-toolbar luthor-toolbar--align-${E}${h?` ${h}`:""}`}}):null,Ye=R==="visual"&&m&&c==="top",Ge=R==="visual"&&m&&c==="bottom";return jsxs(Fragment,{children:[jsxs("div",{className:"luthor-editor-header",children:[jsx(mn,{mode:R,onModeChange:ot,availableModes:r,isConverting:ie}),Ye&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--top",children:qe})]}),jsxs("div",{className:`luthor-editor${ve?"":" luthor-editor--draggable-disabled"}`,"data-mode":R,children:[jsxs("div",{className:`luthor-editor-visual-shell${R==="visual"?"":" is-hidden"}${ve?"":" luthor-editor-visual-shell--no-gutter"}`,"aria-hidden":R!=="visual",children:[ve&&jsx("div",{className:"luthor-editor-visual-gutter","aria-hidden":"true"}),jsx(RichText,{placeholder:n,classNames:{container:"luthor-richtext-container luthor-preset-extensive__container",contentEditable:"luthor-content-editable luthor-preset-extensive__content",placeholder:"luthor-placeholder luthor-preset-extensive__placeholder"}})]}),R!=="visual"&&jsxs("div",{className:"luthor-source-panel",children:[ue&&ue.mode===R&&jsxs("div",{className:"luthor-source-error",children:[jsx("div",{className:"luthor-source-error-icon",children:"\u26A0\uFE0F"}),jsxs("div",{className:"luthor-source-error-message",children:[jsx("strong",{children:"Invalid JSON"}),jsx("p",{children:ue.error}),jsx("small",{children:"Fix the errors above and try switching modes again"})]})]}),R==="json"&&jsx(hn,{value:B.json,onChange:C=>be(T=>({...T,json:C})),placeholder:o})]})]}),jsx(gn,{editor:g,commands:I,editorTheme:e?"dark":"light",disabled:R!=="visual"}),Ge&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--bottom",children:qe}),jsx(Qo,{isOpen:Oe.isOpen,onClose:()=>I.hideCommandPalette(),commands:Oe.commands}),jsx(tn,{isOpen:ge.isOpen,query:ge.query,position:ge.position,commands:ge.commands,onClose:()=>I.closeSlashMenu?.(),onExecute:C=>{I.executeSlashCommand?.(C);}}),jsx(Xo,{isOpen:Ae.isOpen,query:Ae.query,position:Ae.position,suggestions:Ae.suggestions,onClose:()=>I.closeEmojiSuggestions?.(),onExecute:C=>{I.executeEmojiSuggestion?.(C);}})]})}var Yt=forwardRef(({className:e,onReady:t,initialTheme:n="light",theme:o,defaultContent:l,showDefaultContent:r=true,placeholder:i=Dn,initialMode:a="visual",availableModes:d=["visual","json"],variantClassName:c,toolbarLayout:E,toolbarVisibility:h,toolbarPosition:b="top",toolbarAlignment:m="left",toolbarClassName:p,toolbarStyleVars:$,quoteClassName:N,quoteStyleVars:A,defaultSettings:W,editorThemeOverrides:J,isToolbarEnabled:v=true,fontFamilyOptions:ne,fontSizeOptions:se,lineHeightOptions:Y,minimumDefaultLineHeight:g=1.5,scaleByRatio:O=false,headingOptions:k,paragraphLabel:V,syncHeadingOptionsWithCommands:R=true,slashCommandVisibility:oe,shortcutConfig:B,commandPaletteShortcutOnly:be=false,isDraggableBoxEnabled:ie,featureFlags:Fe,syntaxHighlighting:ue,codeHighlightProvider:we,loadCodeHighlightProvider:Oe,maxAutoDetectCodeLength:Ne,isCopyAllowed:ge=true,languageOptions:He},Ae)=>{let[Me,me]=useState(n),ze=Me==="dark",ye=d.includes(a)?a:d[0]??"visual",he=()=>me(ze?"light":"dark"),F=useMemo(()=>typeof i=="string"?{visual:i,json:Kn}:{visual:i.visual??Dn,json:i.json??Kn},[i]);useEffect(()=>{me(n);},[n]);let I=useMemo(()=>Xi(ne),[ne]),q=useMemo(()=>Zi(se),[se]),tt=useMemo(()=>el(Y),[Y]),ve=useMemo(()=>tl(g),[g]),Te=ue??"unset",Je=typeof Ne=="number"?Ne.toString():"unset",Se=useMemo(()=>ol(He),[He]),Be=ge?"copy-on":"copy-off",ee=useMemo(()=>typeof ie!="boolean"?Fe:{...Fe??{},draggableBlock:ie},[Fe,ie]),Le=useMemo(()=>rl(ee),[ee]),Pe=useMemo(()=>It(ee),[ee]),le=`${I}::${q}::${tt}::${ve}::${O?"ratio-on":"ratio-off"}::${Te}::${Je}::${Be}::${Se}::${Le}`,Ce=useRef(ne),De=useRef(se),U=useRef(Y),Re=useRef(g),ot=useRef(ee),qe=useRef(He),Ye=useRef(we),Ge=useRef(Oe),C=useRef(le);(C.current!==le||Ye.current!==we||Ge.current!==Oe)&&(C.current=le,Ce.current=ne,De.current=se,U.current=Y,Re.current=g,ot.current=ee,qe.current=He,Ye.current=we,Ge.current=Oe);let T=useRef(null);if(!T.current||T.current.key!==le){let te={fontFamilyOptions:Ce.current,fontSizeOptions:De.current,lineHeightOptions:U.current,minimumDefaultLineHeight:Re.current,scaleByRatio:O,...ue!==void 0?{syntaxHighlighting:ue}:{},...Ye.current!==void 0?{codeHighlightProvider:Ye.current}:{},...Ge.current!==void 0?{loadCodeHighlightProvider:Ge.current}:{},...Ne!==void 0?{maxAutoDetectCodeLength:Ne}:{},isCopyAllowed:ge,...qe.current!==void 0?{languageOptions:qe.current}:{},...typeof ie=="boolean"?{isDraggableBoxEnabled:ie}:{},...ot.current?{featureFlags:ot.current}:{}};T.current={key:le,value:Ft(te)};}let D=T.current.value,G=useMemo(()=>{let te=mergeThemes(defaultLuthorTheme,o??{});return N?{...te,quote:`${te.quote??""} ${N}`.trim()}:te},[o,N]),X=useMemo(()=>yo(J),[J]),Qe=useMemo(()=>yo(A),[A]),f=useMemo(()=>nl(W),[W]),y=useMemo(()=>yo(f),[f]),P=useMemo(()=>{let te=f,wt=createEditorThemeStyleVars(J),vo=A,Co={"--luthor-default-line-height":ve};return !te&&!wt&&!vo?Co:{...te??{},...wt,...vo??{},...Co}},[ve,f,J,A,y,X,Qe]),[K,ce]=useState(null);useImperativeHandle(Ae,()=>K,[K]);let de=te=>{ce(te),r&&l===void 0?te.injectJSON(JSON.stringify(bo)):l&&te.injectJSON(Wi(l)),t?.(te);};return jsx("div",{className:`luthor-preset luthor-preset-extensive luthor-editor-wrapper ${c||""} ${e||""}`.trim(),"data-editor-theme":Me,style:P,children:jsx(Yi,{extensions:D,config:{theme:G},children:jsx(fl,{isDark:ze,toggleTheme:he,visualPlaceholder:F.visual,jsonPlaceholder:F.json,initialMode:ye,availableModes:d,onReady:de,toolbarLayout:E,toolbarVisibility:h,toolbarPosition:b,toolbarAlignment:m,toolbarClassName:p,toolbarStyleVars:$,isToolbarEnabled:v,headingOptions:k,paragraphLabel:V,syncHeadingOptionsWithCommands:R,slashCommandVisibility:oe,shortcutConfig:B,commandPaletteShortcutOnly:be,featureFlags:Pe})})})});Yt.displayName="ExtensiveEditor";var jn=["undo","redo","heading","fontFamily","fontSize","lineHeight","textColor","textHighlight","bold","italic","underline","strikethrough","subscript","superscript","link","image","table","horizontalRule","iframeEmbed","youtubeEmbed","blockquote","code","codeBlock","bulletedList","numberedList","checkList","commandPalette","floatingToolbar","contextMenu","draggableBlock","customNode","sourceMode","themeToggle"],Vn={id:"extensive",label:"Extensive",description:"All features enabled for power users.",extensions:[...po],components:{Editor:Yt},toolbar:[...jn],config:a("extensive","Write anything..."),css:"extensive/styles.css"};function bl(e={}){return {...Vn,extensions:[...Ft({fontFamilyOptions:e.fontFamilyOptions,fontSizeOptions:e.fontSizeOptions,lineHeightOptions:e.lineHeightOptions,minimumDefaultLineHeight:e.minimumDefaultLineHeight,isCopyAllowed:e.isCopyAllowed,languageOptions:e.languageOptions})]}}export{nn as $,Mo as A,Bn as Aa,zo as B,Yt as Ba,Po as C,jn as Ca,xl as D,Vn as Da,Ro as E,bl as Ea,Tl as F,Kt as G,Ao as H,Bo as I,Ut as J,Do as K,Ko as L,Uo as M,jo as N,Vo as O,Zt as P,_o as Q,$o as R,Jo as S,qo as T,Qo as U,Xo as V,tn as W,L as X,to as Y,kt as Z,Et as _,Ie as a,rn as aa,yl as b,oo as ba,Ot as c,ln as ca,Qt as d,gn as da,So as e,mn as ea,Lo as f,hn as fa,Fo as g,io as ga,Ht as h,ha,Mt as i,Ar as ia,zt as j,Br as ja,Pt as k,Dr as ka,Rt as l,vn as la,wo as m,Sn as ma,ut as n,It as na,nt as o,Ln as oa,At as p,Ft as pa,Bt as q,po as qa,Dt as r,wn as ra,Oo as s,On as sa,No as t,Nn as ta,Wt as u,Hn as ua,ct as v,Mn as va,rt as w,zn as wa,Ho as x,Pn as xa,dt as y,Rn as ya,Xt as z,An as za};
1
+ import {a}from'./chunk-MDSRHDWB.js';import {ImageExtension,TableExtension,IframeEmbedExtension,YouTubeEmbedExtension,ContextMenuExtension,CommandPaletteExtension,SlashCommandExtension,EmojiExtension,DraggableBlockExtension,LinkExtension,textColorExtension,textHighlightExtension,createCustomNodeExtension,createEditorSystem,mergeThemes,defaultLuthorTheme,createEditorThemeStyleVars,FloatingToolbarExtension,FontFamilyExtension,FontSizeExtension,LineHeightExtension,codeExtension,codeIntelligenceExtension,boldExtension,italicExtension,underlineExtension,strikethroughExtension,subscriptExtension,superscriptExtension,horizontalRuleExtension,listExtension,historyExtension,blockFormatExtension,codeFormatExtension,tabIndentExtension,enterKeyBehaviorExtension,RichText,clearLexicalSelection,resolveLinkNodeKeyFromAnchor}from'@lyfie/luthor-headless';import Lr,{forwardRef,useState,useMemo,useEffect,useRef,useImperativeHandle,createElement,useLayoutEffect,useCallback}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var Fe=["h1","h2","h3","h4","h5","h6"],vl={sections:[{items:["fontFamily","fontSize","lineHeight","textColor","textHighlight","bold","italic","underline","strikethrough","subscript","superscript","code","link"]},{items:["blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify","codeBlock"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["horizontalRule"]},{items:["table"]},{items:["image"]},{items:["emoji"]},{items:["embed"]},{items:["undo","redo"]},{items:["commandPalette"]},{items:["themeToggle"]}]},Ot={sections:[{items:["fontFamily","fontSize","lineHeight"]},{items:["bold","italic","underline","strikethrough","textColor","textHighlight"]},{items:["subscript","superscript","code","link"]},{items:["blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["table","image","emoji","embed","horizontalRule"]},{items:["codeBlock"]},{items:["undo","redo"]},{items:["commandPalette","themeToggle"]}]};function $n(e){if(!(e instanceof Element))return false;if(e.closest('[contenteditable="true"]'))return true;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"}function Jn(e,t){return $n(e.target)?To(t):false}function To(e){let t=e.key.toLowerCase();return !(!!e.ctrlKey||!!e.metaKey)||e.altKey?false:t==="b"||t==="i"||t==="u"||t==="k"||(t==="z"||t==="y")}function xo(e){return typeof e.setCodeLanguage=="function"&&typeof e.autoDetectCodeLanguage=="function"}function qn(e){return typeof e.toggleSubscript=="function"}function Yn(e){return typeof e.toggleSuperscript=="function"}function Gn(e){return typeof e.insertIframeEmbed=="function"}function Qn(e){return typeof e.insertYouTubeEmbed=="function"}function Wn(e){return typeof e.insertEmoji=="function"}function Xn(e){return e.slice(1)}function Zn(e){switch(e){case "h1":return "Convert to large heading";case "h2":return "Convert to medium heading";case "h3":return "Convert to small heading";case "h4":return "Convert to heading level 4";case "h5":return "Convert to heading level 5";case "h6":return "Convert to heading level 6"}}function er(e){if(!e||e.length===0)return [...Fe];let t=new Set,n=[];for(let o of e)!Fe.includes(o)||t.has(o)||(t.add(o),n.push(o));return n.length>0?n:[...Fe]}function Gt(e,t){return rr(Qt(t),t?.shortcutConfig).filter(o=>!o.condition||o.condition(e))}function _(e,t){return typeof e[t]=="function"}function Nt(e){if(!e||e.length===0)return new Set;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return new Set(t)}function tr(e){if(!e)return {allowlist:new Set,denylist:new Set};if(Array.isArray(e)){let n=[];for(let o of e)for(let[l,r]of Object.entries(o))r&&n.push(l);return {allowlist:Nt(n),denylist:new Set}}let t=e;return {allowlist:Nt(t.allowlist),denylist:Nt(t.denylist)}}function So(e){let t=e.key.trim();return t?{key:t,ctrlKey:!!e.ctrlKey,metaKey:!!e.metaKey,shiftKey:!!e.shiftKey,altKey:!!e.altKey,preventDefault:e.preventDefault}:null}function or(e){if(e===false||e===null)return [];let t=Array.isArray(e)?e:[e],n=[];for(let o of t){let l=So(o);l&&n.push(l);}return n}function nr(e){return [e.key.toLowerCase(),e.ctrlKey?"ctrl":"",e.metaKey?"meta":"",e.shiftKey?"shift":"",e.altKey?"alt":""].join(":")}function rr(e,t){if(!t)return [...e];let n=Nt(t.disabledCommandIds),o=t.bindings,l=t.preventNativeConflicts!==false,r=t.preventCollisions!==false,i=new Set;return e.filter(d=>!n.has(d.id)).map(d=>{let c=d.shortcuts?[...d.shortcuts]:void 0;if(!!o&&Object.prototype.hasOwnProperty.call(o,d.id)&&o){let h=o[d.id],b=h===void 0?[]:or(h);c=b.length>0?b:void 0;}if(c&&c.length>0){let h=[];for(let b of c){let m=So(b);if(!m||l&&To(m))continue;let p=nr(m);r&&i.has(p)||(i.add(p),h.push(m));}c=h.length>0?h:void 0;}return {...d,shortcuts:c}})}function Qt(e){let t=e?.isFeatureEnabled??(()=>true),n=er(e?.headingOptions),o=e?.paragraphLabel?.trim()||"Paragraph",l=n.map(r=>{let i=Xn(r);return {id:`block.heading${i}`,label:`Heading ${i}`,description:Zn(r),category:"Block",action:a=>a.toggleHeading?.(r),shortcuts:[{key:i,ctrlKey:true,altKey:true}],keywords:["heading",r],condition:a=>t("blockFormat")&&_(a,"toggleHeading")}});return [{id:"format.bold",label:"Toggle Bold",description:"Make text bold or remove bold formatting",category:"Format",action:r=>r.toggleBold?.(),shortcuts:[{key:"b",ctrlKey:true}],keywords:["bold","strong","format"],condition:r=>t("bold")&&_(r,"toggleBold")},{id:"format.italic",label:"Toggle Italic",description:"Make text italic or remove italic formatting",category:"Format",action:r=>r.toggleItalic?.(),shortcuts:[{key:"i",ctrlKey:true}],keywords:["italic","emphasis","format"],condition:r=>t("italic")&&_(r,"toggleItalic")},{id:"format.underline",label:"Toggle Underline",description:"Add or remove underline formatting",category:"Format",action:r=>r.toggleUnderline?.(),shortcuts:[{key:"u",ctrlKey:true}],keywords:["underline","format"],condition:r=>t("underline")&&_(r,"toggleUnderline")},{id:"format.strikethrough",label:"Toggle Strikethrough",description:"Add or remove strikethrough formatting",category:"Format",action:r=>r.toggleStrikethrough?.(),keywords:["strikethrough","format"],condition:r=>t("strikethrough")&&_(r,"toggleStrikethrough")},{id:"format.subscript",label:"Toggle Subscript",description:"Format text as subscript",category:"Format",action:r=>r.toggleSubscript?.(),keywords:["subscript","format"],condition:r=>t("subscript")&&qn(r)},{id:"format.superscript",label:"Toggle Superscript",description:"Format text as superscript",category:"Format",action:r=>r.toggleSuperscript?.(),keywords:["superscript","format"],condition:r=>t("superscript")&&Yn(r)},{id:"format.code",label:"Toggle Inline Code",description:"Format text as inline code",category:"Format",action:r=>r.formatText?.("code"),shortcuts:[{key:"`",ctrlKey:true}],keywords:["code","inline","format"],condition:r=>t("codeFormat")&&_(r,"formatText")},{id:"block.paragraph",label:o,description:"Convert to paragraph",category:"Block",action:r=>r.toggleParagraph?.(),shortcuts:[{key:"0",ctrlKey:true,altKey:true}],keywords:["paragraph","text"],condition:r=>t("blockFormat")&&_(r,"toggleParagraph")},...l,{id:"block.quote",label:"Quote",description:"Convert to blockquote",category:"Block",action:r=>r.toggleQuote?.(),keywords:["quote","blockquote"],condition:r=>t("blockFormat")&&_(r,"toggleQuote")},{id:"block.align-left",label:"Align Left",description:"Align selected blocks to the left",category:"Block",action:r=>r.setTextAlignment?.("left"),keywords:["align","left","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.align-center",label:"Align Center",description:"Center-align selected blocks",category:"Block",action:r=>r.setTextAlignment?.("center"),keywords:["align","center","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.align-right",label:"Align Right",description:"Align selected blocks to the right",category:"Block",action:r=>r.setTextAlignment?.("right"),keywords:["align","right","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.align-justify",label:"Justify",description:"Justify selected blocks",category:"Block",action:r=>r.setTextAlignment?.("justify"),keywords:["align","justify","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.codeblock",label:"Code Block",description:"Convert to code block",category:"Block",action:r=>r.toggleCodeBlock?.(),shortcuts:[{key:"`",ctrlKey:true,shiftKey:true}],keywords:["code","block"],condition:r=>t("code")&&_(r,"toggleCodeBlock")},{id:"block.code-language",label:"Set Code Language",description:"Set language for selected code block",category:"Block",action:r=>{if(!r.setCodeLanguage)return;let i=prompt("Code language (e.g. ts, css, python):")?.trim();i&&r.setCodeLanguage(i);},keywords:["code","language","syntax"],condition:r=>t("codeIntelligence")&&xo(r)},{id:"block.code-language.auto",label:"Auto-Detect Code Language",description:"Detect language from selected code block",category:"Block",action:r=>{r.autoDetectCodeLanguage?.();},keywords:["code","language","auto","detect"],condition:r=>t("codeIntelligence")&&xo(r)},{id:"list.bullet",label:"Bullet List",description:"Create or toggle bullet list",category:"List",action:r=>r.toggleUnorderedList?.(),shortcuts:[{key:"l",ctrlKey:true,shiftKey:true}],keywords:["list","bullet"],condition:r=>t("list")&&_(r,"toggleUnorderedList")},{id:"list.numbered",label:"Numbered List",description:"Create or toggle numbered list",category:"List",action:r=>r.toggleOrderedList?.(),shortcuts:[{key:"l",ctrlKey:true,altKey:true}],keywords:["list","numbered"],condition:r=>t("list")&&_(r,"toggleOrderedList")},{id:"list.check",label:"Checklist",description:"Create or toggle checklist",category:"List",action:r=>r.toggleCheckList?.(),shortcuts:[{key:"x",ctrlKey:true,shiftKey:true}],keywords:["list","check","todo","task"],condition:r=>t("list")&&_(r,"toggleCheckList")},{id:"link.insert",label:"Insert Link",description:"Insert or edit a link",category:"Insert",action:r=>r.insertLink?.(),shortcuts:[{key:"k",ctrlKey:true}],keywords:["link","url"],condition:r=>t("link")&&_(r,"insertLink")},{id:"link.remove",label:"Remove Link",description:"Remove link formatting",category:"Format",action:r=>r.removeLink?.(),shortcuts:[{key:"k",ctrlKey:true,shiftKey:true}],keywords:["unlink","remove","link"],condition:r=>t("link")&&_(r,"removeLink")},{id:"insert.horizontal-rule",label:"Insert Horizontal Rule",description:"Insert a horizontal line separator",category:"Insert",action:r=>r.insertHorizontalRule?.(),keywords:["horizontal","rule","hr","divider","separator"],condition:r=>t("horizontalRule")&&_(r,"insertHorizontalRule")},{id:"insert.image",label:"Insert Image",description:"Insert an image from URL",category:"Insert",action:r=>{let i=prompt("Enter image URL:");if(i){let a=prompt("Enter alt text:")||"";r.insertImage?.({src:i,alt:a});}},keywords:["image","photo"],condition:r=>t("image")&&_(r,"insertImage")},{id:"insert.gif",label:"Insert GIF",description:"Insert an animated GIF from URL",category:"Insert",action:r=>{let i=prompt("Enter GIF URL:");i&&r.insertImage?.({src:i,alt:"GIF"});},keywords:["gif","animated","image"],condition:r=>t("image")&&_(r,"insertImage")},{id:"insert.emoji",label:"Insert Emoji",description:"Insert an emoji character",category:"Insert",action:r=>{let i=prompt("Enter emoji or shortcode (example :sparkles:):")?.trim();if(!i||typeof r.insertEmoji!="function")return;let a=i.match(/^:([a-z0-9_+-]+):$/i);if(a){let d=a[1];if(!d)return;if(typeof r.resolveEmojiShortcode=="function"){let c=r.resolveEmojiShortcode(d);if(c?.emoji){r.insertEmoji(c.emoji);return}}else if(typeof r.getEmojiSuggestions=="function"){let[c]=r.getEmojiSuggestions(d);if(c?.emoji){r.insertEmoji(c.emoji);return}}}r.insertEmoji(i);},keywords:["emoji","reaction","symbol","smile"],condition:r=>t("emoji")&&Wn(r)},{id:"insert.table",label:"Insert Table",description:"Insert a 3x3 table",category:"Insert",action:r=>r.insertTable?.({rows:3,columns:3,includeHeaders:true}),keywords:["table","grid"],condition:r=>t("table")&&_(r,"insertTable")},{id:"insert.iframe",label:"Insert iframe",description:"Insert an iframe embed from URL",category:"Insert",action:r=>{if(typeof r.insertIframeEmbed!="function")return;let i=prompt("Enter iframe URL:");i&&r.insertIframeEmbed(i);},keywords:["iframe","embed","url"],condition:r=>t("iframeEmbed")&&Gn(r)},{id:"insert.youtube",label:"Insert YouTube Video",description:"Insert an embedded YouTube video",category:"Insert",action:r=>{if(typeof r.insertYouTubeEmbed!="function")return;let i=prompt("Enter YouTube URL:");i&&r.insertYouTubeEmbed(i);},keywords:["youtube","video","embed"],condition:r=>t("youTubeEmbed")&&Qn(r)},{id:"edit.undo",label:"Undo",description:"Undo the last action",category:"Edit",action:r=>r.undo?.(),shortcuts:[{key:"z",ctrlKey:true}],keywords:["undo","revert"],condition:r=>t("history")&&_(r,"undo")},{id:"edit.redo",label:"Redo",description:"Redo the last undone action",category:"Edit",action:r=>r.redo?.(),shortcuts:[{key:"y",ctrlKey:true},{key:"z",ctrlKey:true,shiftKey:true}],keywords:["redo","repeat"],condition:r=>t("history")&&_(r,"redo")},{id:"palette.show",label:"Show Command Palette",description:"Open the command palette",category:"View",action:r=>r.showCommandPalette?.(),shortcuts:[{key:"p",ctrlKey:true,shiftKey:true}],keywords:["command","palette"],condition:r=>t("commandPalette")&&_(r,"showCommandPalette")}]}function Lo(e,t){let n=t?.commandPaletteShortcutOnly===true;return Gt(e,t).filter(o=>!n||!!o.shortcuts&&o.shortcuts.length>0).map(o=>({id:o.id,label:o.label,description:o.description,category:o.category,action:()=>o.action(e),keywords:o.keywords,shortcut:o.shortcuts?.[0]?Fo(o.shortcuts[0]):void 0}))}function Io(e,t){let n=new Set(["block.paragraph","block.quote","block.codeblock"]),o=a=>a.category==="Insert"||a.category==="List"?true:a.category==="Block"?a.id.startsWith("block.heading")?true:n.has(a.id):false,{allowlist:l,denylist:r}=tr(t?.slashCommandVisibility),i=l.size>0;return Gt(e,t).filter(o).filter(a=>r.has(a.id)?false:i?l.has(a.id):true).map(a=>({id:a.id,label:a.label,description:a.description,category:a.category,action:()=>a.action(e),keywords:a.keywords,shortcut:a.shortcuts?.[0]?Fo(a.shortcuts[0]):void 0}))}function Fo(e){let t=[];return e.ctrlKey&&t.push("Ctrl"),e.metaKey&&t.push("Cmd"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),t.push(e.key.toUpperCase()),t.join("+")}function wo(e,t=document.body,n){let o=Gt(e,n),l=r=>{let i=typeof n?.scope=="function"?n.scope():n?.scope;if(!(i&&r.target instanceof Node&&!i.contains(r.target))){for(let a of o)if(a.shortcuts){for(let d of a.shortcuts)if(!(n?.shortcutConfig?.preventNativeConflicts!==false&&Jn(r,d))&&r.key.toLowerCase()===d.key.toLowerCase()&&!!r.ctrlKey==!!d.ctrlKey&&!!r.metaKey==!!d.metaKey&&!!r.shiftKey==!!d.shiftKey&&!!r.altKey==!!d.altKey){d.preventDefault!==false&&r.preventDefault(),(!a.condition||a.condition(e))&&a.action(e);return}}}};return t.addEventListener("keydown",l),()=>t.removeEventListener("keydown",l)}function w(e,t){let n=forwardRef(function({size:l=24,strokeWidth:r=2,...i},a){return jsx("svg",{ref:a,xmlns:"http://www.w3.org/2000/svg",width:l,height:l,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...i,children:t})});return n.displayName=e,n}var Ht=w("BoldIcon",jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})),Mt=w("ItalicIcon",jsxs(Fragment,{children:[jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})),zt=w("UnderlineIcon",jsxs(Fragment,{children:[jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})),Pt=w("StrikethroughIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})),Rt=w("CodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"m16 18 6-6-6-6"}),jsx("path",{d:"m8 6-6 6 6 6"})]})),Oo=w("CodeBlockIcon",jsxs(Fragment,{children:[jsx("path",{d:"m10 9-3 3 3 3"}),jsx("path",{d:"m14 15 3-3-3-3"}),jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})]})),ct=w("LinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})),nt=w("UnlinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"}),jsx("path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"}),jsx("line",{x1:"8",x2:"8",y1:"2",y2:"5"}),jsx("line",{x1:"2",x2:"5",y1:"8",y2:"8"}),jsx("line",{x1:"16",x2:"16",y1:"19",y2:"22"}),jsx("line",{x1:"19",x2:"22",y1:"16",y2:"16"})]})),At=w("ListIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h.01"}),jsx("path",{d:"M3 12h.01"}),jsx("path",{d:"M3 19h.01"}),jsx("path",{d:"M8 5h13"}),jsx("path",{d:"M8 12h13"}),jsx("path",{d:"M8 19h13"})]})),Bt=w("ListCheckIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 5H3"}),jsx("path",{d:"M16 12H3"}),jsx("path",{d:"M11 19H3"}),jsx("path",{d:"m15 18 2 2 4-4"})]})),Dt=w("ListOrderedIcon",jsxs(Fragment,{children:[jsx("path",{d:"M11 5h10"}),jsx("path",{d:"M11 12h10"}),jsx("path",{d:"M11 19h10"}),jsx("path",{d:"M4 4h1v5"}),jsx("path",{d:"M4 9h2"}),jsx("path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02"})]})),No=w("UndoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 7v6h6"}),jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})),Ho=w("RedoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 7v6h-6"}),jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})]})),Wt=w("ImageIcon",jsxs(Fragment,{children:[jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),jsx("circle",{cx:"9",cy:"9",r:"2"}),jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})),dt=w("AlignLeftIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M15 12H3"}),jsx("path",{d:"M17 19H3"})]})),rt=w("AlignCenterIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M17 12H7"}),jsx("path",{d:"M19 19H5"})]})),Mo=w("AlignJustifyIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h18"}),jsx("path",{d:"M3 12h18"}),jsx("path",{d:"M3 19h18"})]})),gt=w("AlignRightIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M21 12H9"}),jsx("path",{d:"M21 19H7"})]})),Xt=w("UploadIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 3v12"}),jsx("path",{d:"m17 8-5-5-5 5"}),jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})),zo=w("MinusIcon",jsx("path",{d:"M5 12h14"})),Po=w("TableIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 3v18"}),jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),jsx("path",{d:"M3 9h18"}),jsx("path",{d:"M3 15h18"})]})),Ro=w("FileCodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}),jsx("path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}),jsx("path",{d:"M10 12.5 8 15l2 2.5"}),jsx("path",{d:"m14 12.5 2 2.5-2 2.5"})]})),Tl=w("EyeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),jsx("circle",{cx:"12",cy:"12",r:"3"})]})),Ao=w("HighlighterIcon",jsxs(Fragment,{children:[jsx("path",{d:"m9 11-6 6v3h9l3-3"}),jsx("path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"})]})),Sl=w("PencilIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),jsx("path",{d:"m15 5 4 4"})]})),Kt=w("CommandIcon",jsx("path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3"})),Bo=w("PaletteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"}),jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"})]})),Do=w("TypeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 4v16"}),jsx("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),jsx("path",{d:"M9 20h6"})]})),Ut=w("QuoteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"}),jsx("path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"})]})),Ko=w("IndentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H11"}),jsx("path",{d:"M21 12H11"}),jsx("path",{d:"M21 19H11"}),jsx("path",{d:"m3 8 4 4-4 4"})]})),Uo=w("OutdentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H11"}),jsx("path",{d:"M21 12H11"}),jsx("path",{d:"M21 19H11"}),jsx("path",{d:"m7 8-4 4 4 4"})]})),jo=w("SunIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v2"}),jsx("path",{d:"M12 20v2"}),jsx("path",{d:"m4.93 4.93 1.41 1.41"}),jsx("path",{d:"m17.66 17.66 1.41 1.41"}),jsx("path",{d:"M2 12h2"}),jsx("path",{d:"M20 12h2"}),jsx("path",{d:"m6.34 17.66-1.41 1.41"}),jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})),Vo=w("MoonIcon",jsx("path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"})),_o=w("SearchIcon",jsxs(Fragment,{children:[jsx("path",{d:"m21 21-4.34-4.34"}),jsx("circle",{cx:"11",cy:"11",r:"8"})]})),Zt=w("EmojiIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),jsx("line",{x1:"9",x2:"9.01",y1:"9",y2:"9"}),jsx("line",{x1:"15",x2:"15.01",y1:"9",y2:"9"})]})),$o=w("SubscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 5 8 8"}),jsx("path",{d:"m12 5-8 8"}),jsx("path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})),Jo=w("SuperscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 19 8-8"}),jsx("path",{d:"m12 19-8-8"}),jsx("path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06"})]})),qo=w("ChevronDownIcon",jsx("path",{d:"m6 9 6 6 6-6"})),Yo=w("CloseIcon",jsxs(Fragment,{children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));function Wo({isOpen:e,onClose:t,commands:n}){let[o,l]=useState(""),[r,i]=useState(0),a=useRef(null),d=useRef(null),c=n.filter(b=>`${b.label} ${b.description||""} ${b.keywords?.join(" ")||""}`.toLowerCase().includes(o.toLowerCase())),E=c.reduce((b,m)=>{let p=m.category||"Other";return b[p]||(b[p]=[]),b[p].push(m),b},{}),h=c;return useEffect(()=>{i(0);},[o]),useEffect(()=>{e&&a.current&&(a.current.focus({preventScroll:true}),l(""),i(0));},[e]),useEffect(()=>{if(!e)return;let b=d.current;if(!b)return;b.querySelector(".luthor-command-palette-item.selected")?.scrollIntoView({block:"nearest"});},[e,r,o]),useEffect(()=>{let b=m=>{if(e)switch(m.key){case "Escape":m.preventDefault(),m.stopPropagation(),t();break;case "ArrowDown":m.preventDefault(),m.stopPropagation(),i(p=>Math.min(p+1,h.length-1));break;case "ArrowUp":m.preventDefault(),m.stopPropagation(),i(p=>Math.max(p-1,0));break;case "Enter":m.preventDefault(),m.stopPropagation(),h[r]&&(h[r].action(),t());break}};return document.addEventListener("keydown",b,true),()=>document.removeEventListener("keydown",b,true)},[e,r,h,t]),e?jsx("div",{className:"luthor-command-palette-overlay",onClick:t,children:jsxs("div",{className:"luthor-command-palette",role:"dialog","aria-modal":"true","aria-label":"Command Palette",onClick:b=>b.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(_o,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:a,type:"text",placeholder:"Type a command or search...",value:o,onChange:b=>l(b.target.value),className:"luthor-command-palette-input"}),jsx("kbd",{className:"luthor-command-palette-kbd",children:"ESC"})]}),jsx("div",{ref:d,className:"luthor-command-palette-list",children:Object.keys(E).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(E).map(([b,m])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:b}),m.map(p=>{let $=h.indexOf(p);return jsxs("div",{className:`luthor-command-palette-item ${$===r?"selected":""}`,onClick:()=>{p.action(),t();},onMouseEnter:()=>i($),children:[jsxs("div",{className:"luthor-command-palette-item-content",children:[jsx("div",{className:"luthor-command-palette-item-title",children:p.label}),p.description&&jsx("div",{className:"luthor-command-palette-item-description",children:p.description})]}),p.shortcut&&jsx("kbd",{className:"luthor-command-palette-item-shortcut",children:p.shortcut})]},p.id)})]},b))}),jsx("div",{className:"luthor-command-palette-footer",children:jsxs("span",{className:"luthor-command-palette-hint",children:[jsx(Kt,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var lr={"--luthor-bg":"#ffffff","--luthor-fg":"#0f172a","--luthor-border":"#e2e8f0","--luthor-border-hover":"#cbd5e1","--luthor-border-active":"#94a3b8","--luthor-accent":"#0f172a","--luthor-accent-hover":"#1e293b","--luthor-shadow":"rgba(0, 0, 0, 0.08)","--luthor-muted":"#f8fafc","--luthor-muted-fg":"#64748b","--luthor-theme-transition":"0.2s ease","--luthor-drag-gutter-width":"56px","--luthor-line-height-ratio":"1","--luthor-toolbar-bg":"#f8fafc","--luthor-toolbar-section-border":"#e2e8f0","--luthor-toolbar-button-fg":"#0f172a","--luthor-toolbar-button-hover-bg":"#f8fafc","--luthor-toolbar-button-hover-border":"#cbd5e1","--luthor-toolbar-button-hover-shadow":"0 4px 12px rgba(0, 0, 0, 0.15)","--luthor-toolbar-button-press-shadow":"0 2px 8px rgba(0, 0, 0, 0.1)","--luthor-toolbar-button-active-bg":"#0f172a","--luthor-toolbar-button-active-border":"#0f172a","--luthor-toolbar-button-active-fg":"#ffffff","--luthor-toolbar-button-active-shadow":"0 2px 8px rgba(0, 0, 0, 0.2)","--luthor-toolbar-button-overlay":"linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%)","--luthor-toolbar-button-active-overlay":"linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%)","--luthor-toolbar-color-indicator-border":"#e2e8f0","--luthor-toolbar-highlight-bg":"#f8fafc","--luthor-quote-bg":"#f8fafc","--luthor-quote-fg":"#0f172a","--luthor-quote-border":"#0f172a","--luthor-syntax-comment":"#64748b","--luthor-syntax-keyword":"#64748b","--luthor-syntax-string":"#64748b","--luthor-syntax-number":"#64748b","--luthor-syntax-function":"#64748b","--luthor-syntax-variable":"#64748b","--luthor-floating-bg":"#ffffff","--luthor-floating-fg":"#0f172a","--luthor-floating-border":"#e2e8f0","--luthor-floating-shadow":"rgba(0, 0, 0, 0.08)","--luthor-floating-muted":"#f8fafc","--luthor-floating-border-hover":"#cbd5e1","--luthor-floating-border-active":"#94a3b8","--luthor-floating-accent":"#0f172a","--luthor-floating-accent-fg":"#ffffff","--luthor-z-dropdown":"20","--luthor-z-popover":"24","--luthor-z-menu":"28","--luthor-z-overlay":"32","--luthor-z-modal":"36","--luthor-preset-bg":"#ffffff","--luthor-preset-fg":"#0f172a","--luthor-preset-border":"#dbe2ea","--luthor-preset-muted":"#f8fafc","--luthor-preset-muted-fg":"#64748b","--luthor-preset-accent":"#2563eb","--luthor-preset-radius":"10px","--luthor-preset-shadow":"0 1px 3px rgba(15, 23, 42, 0.08)","--luthor-preset-content-padding":"16px","--luthor-preset-content-min-height":"180px"};function ar(e){return e?e.closest(".luthor-editor-wrapper"):null}function sr(e){return e?ar(e)??e:null}function ur(e){if(typeof window>"u"||!e)return {};let t=window.getComputedStyle(e),n={};for(let[o,l]of Object.entries(lr)){let r=t.getPropertyValue(o).trim()||l;n[o]=r;}return n}function We(e){return ur(sr(e))}function ht(){if(typeof window>"u")return {};let t=window.getSelection()?.anchorNode;if(!t)return {};let n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return We(n)}function Zo({isOpen:e,query:t,position:n,suggestions:o,onClose:l,onExecute:r}){let[i,a]=useState(0);if(useEffect(()=>{a(0);},[t,e]),useEffect(()=>{if(!e)return;let c=E=>{let h=o.length>0;switch(E.key){case "Escape":E.preventDefault(),E.stopPropagation(),l();break;case "ArrowDown":if(!h)return;E.preventDefault(),E.stopPropagation(),a(b=>Math.min(b+1,Math.max(o.length-1,0)));break;case "ArrowUp":if(!h)return;E.preventDefault(),E.stopPropagation(),a(b=>Math.max(b-1,0));break;case "Enter":case "Tab":if(!h||!o[i])return;E.preventDefault(),E.stopPropagation(),r(o[i].emoji);break}};return document.addEventListener("keydown",c,true),()=>document.removeEventListener("keydown",c,true)},[e,l,r,i,o]),!e||!n)return null;let d=jsxs("div",{className:"luthor-emoji-menu",style:{left:n.x,top:n.y,...ht()},onPointerDown:c=>{c.stopPropagation();},onMouseDown:c=>{c.stopPropagation();},children:[jsxs("div",{className:"luthor-emoji-menu-header",children:[jsx("span",{className:"luthor-emoji-menu-title",children:"Emoji"}),jsxs("span",{className:"luthor-emoji-menu-query",children:[":",t]})]}),jsx("div",{className:"luthor-emoji-menu-list",children:o.length===0?jsx("div",{className:"luthor-emoji-menu-empty",children:"No matching emoji"}):o.map((c,E)=>{let h=E===i,b=c.shortcodes[0]?`:${c.shortcodes[0]}:`:"";return jsxs("button",{type:"button",className:`luthor-emoji-menu-item ${h?"selected":""}`,onMouseEnter:()=>a(E),onMouseDown:m=>{m.preventDefault(),m.stopPropagation();},onClick:m=>{m.preventDefault(),m.stopPropagation(),r(c.emoji);},children:[jsx("span",{className:"luthor-emoji-menu-item-symbol","aria-hidden":"true",children:c.emoji}),jsxs("span",{className:"luthor-emoji-menu-item-content",children:[jsx("span",{className:"luthor-emoji-menu-item-title",children:c.label}),b&&jsx("span",{className:"luthor-emoji-menu-item-shortcode",children:b})]})]},`${c.emoji}-${c.label}`)})})]});return typeof document>"u"?d:createPortal(d,document.body)}function on({isOpen:e,query:t,position:n,commands:o,onClose:l,onExecute:r}){let[i,a]=useState(0),d=useMemo(()=>{let h=t.trim().toLowerCase();return h?o.filter(b=>`${b.label} ${b.description||""} ${b.keywords?.join(" ")||""}`.toLowerCase().includes(h)):o},[o,t]),c=useMemo(()=>d.reduce((h,b)=>{let m=b.category||"Other";return h[m]||(h[m]=[]),h[m].push(b),h},{}),[d]);if(useEffect(()=>{a(0);},[t,e]),useEffect(()=>{if(!e)return;let h=b=>{let m=d.length>0;switch(b.key){case "Escape":b.preventDefault(),b.stopPropagation(),l();break;case "ArrowDown":if(!m)return;b.preventDefault(),b.stopPropagation(),a(p=>Math.min(p+1,Math.max(d.length-1,0)));break;case "ArrowUp":if(!m)return;b.preventDefault(),b.stopPropagation(),a(p=>Math.max(p-1,0));break;case "Enter":case "Tab":if(!m||!d[i])return;b.preventDefault(),b.stopPropagation(),r(d[i].id);break}};return document.addEventListener("keydown",h,true),()=>document.removeEventListener("keydown",h,true)},[d,e,l,r,i]),!e||!n)return null;let E=jsxs("div",{className:"luthor-slash-menu",style:{left:n.x,top:n.y,...ht()},onPointerDown:h=>{h.stopPropagation();},onMouseDown:h=>{h.stopPropagation();},children:[jsxs("div",{className:"luthor-slash-menu-header",children:[jsx("span",{className:"luthor-slash-menu-title",children:"Insert block"}),jsxs("span",{className:"luthor-slash-menu-query",children:["/",t]})]}),jsx("div",{className:"luthor-slash-menu-list",children:d.length===0?jsx("div",{className:"luthor-slash-menu-empty",children:"No matching commands"}):Object.entries(c).map(([h,b])=>jsxs("div",{className:"luthor-slash-menu-group",children:[jsx("div",{className:"luthor-slash-menu-group-title",children:h}),b.map(m=>{let p=d.indexOf(m);return jsxs("button",{type:"button",className:`luthor-slash-menu-item ${p===i?"selected":""}`,onMouseEnter:()=>a(p),onMouseDown:H=>{H.preventDefault(),H.stopPropagation();},onClick:H=>{H.preventDefault(),H.stopPropagation(),r(m.id);},children:[jsxs("span",{className:"luthor-slash-menu-item-content",children:[jsx("span",{className:"luthor-slash-menu-item-title",children:m.label}),m.description&&jsx("span",{className:"luthor-slash-menu-item-description",children:m.description})]}),m.shortcut&&jsx("kbd",{className:"luthor-slash-menu-item-shortcut",children:m.shortcut})]},m.id)})]},h))})]});return typeof document>"u"?E:createPortal(E,document.body)}function L({children:e,onClick:t,title:n,active:o,disabled:l,className:r,type:i="button"}){return jsx("button",{type:i,className:`luthor-toolbar-button${o?" active":""}${r?` ${r}`:""}`,onClick:t,title:n,disabled:l,children:e})}function to({children:e,onClick:t,variant:n="primary",type:o="button",className:l}){return jsx("button",{type:o,onClick:t,className:`${n==="primary"?"luthor-button-primary":"luthor-button-secondary"}${l?` ${l}`:""}`,children:e})}function Et({value:e,onValueChange:t,options:n,placeholder:o="Select..."}){let[l,r]=useState(false),[i,a]=useState(void 0),d=useRef(null),c=useRef(null);useEffect(()=>{if(!l)return;let h=()=>{let b=d.current?.querySelector(".luthor-select-trigger");if(!b)return;let m=b.getBoundingClientRect();a({position:"fixed",top:m.bottom+4,left:m.left,width:m.width,...We(b)});};return h(),window.addEventListener("resize",h),window.addEventListener("scroll",h,true),()=>{window.removeEventListener("resize",h),window.removeEventListener("scroll",h,true);}},[l]),useEffect(()=>{function h(b){let m=b.target;d.current?.contains(m)||c.current?.contains(m)||r(false);}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);let E=n.find(h=>h.value===e);return jsxs("div",{className:"luthor-select",ref:d,children:[jsxs("button",{className:`luthor-select-trigger ${l?"open":""}`,onClick:()=>r(!l),type:"button",children:[jsx("span",{children:E?.label||o}),jsx(qo,{size:14})]}),l&&typeof document<"u"&&createPortal(jsx("div",{ref:c,className:"luthor-select-dropdown",style:i,children:n.map(h=>jsx("button",{className:`luthor-select-option ${e===h.value?"selected":""}`,onClick:()=>{t(h.value),r(false);},type:"button",children:h.label},h.value))}),document.body)]})}function xt({trigger:e,children:t,isOpen:n,onOpenChange:o}){let l=useRef(null),r=useRef(null),i=useRef(null),[a,d]=useState(void 0);return useEffect(()=>{if(!n)return;let c=()=>{let E=r.current;if(!E)return;let h=E.getBoundingClientRect();d({position:"fixed",top:h.bottom+4,left:h.left,...We(E)});};return c(),window.addEventListener("resize",c),window.addEventListener("scroll",c,true),()=>{window.removeEventListener("resize",c),window.removeEventListener("scroll",c,true);}},[n]),useEffect(()=>{function c(E){let h=E.target;l.current?.contains(h)||i.current?.contains(h)||o(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]),jsxs("div",{className:"luthor-dropdown",ref:l,children:[jsx("div",{ref:r,onClick:()=>o(!n),children:e}),n&&typeof document<"u"&&createPortal(jsx("div",{ref:i,className:"luthor-dropdown-content",style:a,children:t}),document.body)]})}function rn({isOpen:e,onClose:t,title:n,children:o}){let l=useRef(null);return useEffect(()=>{function r(a){l.current&&!l.current.contains(a.target)&&t();}function i(a){a.key==="Escape"&&t();}return e&&(document.addEventListener("mousedown",r),document.addEventListener("keydown",i)),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",i);}},[e,t]),e?jsx("div",{className:"luthor-dialog-overlay",children:jsxs("div",{className:"luthor-dialog",ref:l,children:[jsxs("div",{className:"luthor-dialog-header",children:[jsx("h3",{className:"luthor-dialog-title",children:n}),jsx("button",{className:"luthor-dialog-close",onClick:t,type:"button",children:jsx(Yo,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:o})]})}):null}function ln({isVisible:e,selectionRect:t,commands:n,activeStates:o,editorTheme:l="light",hide:r,isFeatureEnabled:i=()=>true}){let a=useRef(null),[d,c]=useState(""),[E,h]=useState(""),[b,m]=useState(""),[p,$]=useState(""),[H,B]=useState(""),[q,W]=useState(""),[v,se]=useState(null),[ue,Y]=useState(null),[g,F]=useState(null),k=!!o.isIframeEmbedSelected,V=!!o.isYouTubeEmbedSelected,R=i("iframeEmbed"),ee=i("youTubeEmbed"),D=i("image"),ve=R&&k||ee&&V;if(useEffect(()=>{if(!e)return;let O=I=>{let J=I.target;J&&(a.current?.contains(J)||r?.());};return document.addEventListener("mousedown",O,true),document.addEventListener("touchstart",O,true),()=>{document.removeEventListener("mousedown",O,true),document.removeEventListener("touchstart",O,true);}},[e,r]),useEffect(()=>{if(!e||!k)return;let O=false;return typeof n.getIframeEmbedCaption=="function"&&n.getIframeEmbedCaption().then(I=>{O||h(I??"");}),typeof n.getIframeEmbedUrl=="function"&&n.getIframeEmbedUrl().then(I=>{O||c(I??"");}),se(null),()=>{O=true;}},[n,k,e]),useEffect(()=>{if(!e||!o.imageSelected)return;let O=false;return typeof n.getImageCaption=="function"&&n.getImageCaption().then(I=>{O||m(I??"");}),()=>{O=true;}},[o.imageSelected,n,e]),useEffect(()=>{if(!e||!V)return;let O=false;return typeof n.getYouTubeEmbedCaption=="function"&&n.getYouTubeEmbedCaption().then(I=>{O||$(I??"");}),typeof n.getYouTubeEmbedUrl=="function"&&n.getYouTubeEmbedUrl().then(I=>{O||B(I??"");}),Y(null),()=>{O=true;}},[n,e,V]),useEffect(()=>{if(!e||!o.isLink)return;let O=false;return typeof n.getCurrentLink=="function"&&n.getCurrentLink().then(I=>{!O&&I&&W(I.url??"");}),F(null),()=>{O=true;}},[o.isLink,n,e]),!e||!t)return null;let Ce={...ht(),position:"absolute",top:t.y,left:t.positionFromRight?"auto":t.x,right:t.positionFromRight?10:"auto",zIndex:9999,pointerEvents:"auto"};if(ve){let O=K=>{if(k){n.setIframeEmbedAlignment?.(K);return}V&&n.setYouTubeEmbedAlignment?.(K);},I=k?o.isIframeEmbedAlignedLeft:o.isYouTubeEmbedAlignedLeft,J=k?o.isIframeEmbedAlignedCenter:o.isYouTubeEmbedAlignedCenter,tt=k?o.isIframeEmbedAlignedRight:o.isYouTubeEmbedAlignedRight,He=k?typeof n.setIframeEmbedCaption=="function":typeof n.setYouTubeEmbedCaption=="function",pe=k?typeof n.updateIframeEmbedUrl=="function":typeof n.updateYouTubeEmbedUrl=="function",Je=k?E:p,Ie=k?h:$,Ae=k?d:H,de=k?v:ue,oe=()=>{if(He){if(k){n.setIframeEmbedCaption?.(E);return}n.setYouTubeEmbedCaption?.(p);}},Me=K=>{k?se(K):Y(K);},xe=K=>{k?c(K):B(K);},le=()=>{if(!pe)return;if(!(k?n.updateIframeEmbedUrl?.(d)??false:n.updateYouTubeEmbedUrl?.(H)??false)){Me(k?"Enter a valid http(s) URL":"Enter a valid YouTube URL"),k&&typeof n.getIframeEmbedUrl=="function"?n.getIframeEmbedUrl().then(ze=>c(ze??"")):!k&&typeof n.getYouTubeEmbedUrl=="function"&&n.getYouTubeEmbedUrl().then(ze=>B(ze??""));return}Me(null);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:Ce,children:[jsx(L,{onClick:()=>O("left"),active:I,title:"Align Left",children:jsx(dt,{size:14})}),jsx(L,{onClick:()=>O("center"),active:J,title:"Align Center",children:jsx(rt,{size:14})}),jsx(L,{onClick:()=>O("right"),active:tt,title:"Align Right",children:jsx(gt,{size:14})}),He||pe?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-fields",children:[pe?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:Ae,className:`luthor-floating-toolbar-input${de?" is-error":""}`,placeholder:k?"https://example.com/embed":"https://youtube.com/watch?v=...","aria-label":k?"Iframe URL":"YouTube URL","aria-invalid":de?true:void 0,onChange:K=>{xe(K.target.value),de&&Me(null);},onBlur:le,onKeyDown:K=>{K.key==="Enter"&&(K.preventDefault(),le());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:le,children:"Update URL"})]}):null,He?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:Je,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":k?"Iframe caption":"YouTube caption",onChange:K=>Ie(K.target.value),onBlur:oe,onKeyDown:K=>{K.key==="Enter"&&(K.preventDefault(),oe());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:oe,children:"Update Caption"})]}):null]})]}):null]})}if(D&&o.imageSelected){let O=typeof n.setImageCaption=="function",I=()=>{O&&n.setImageCaption(b);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:Ce,children:[jsx(L,{onClick:()=>n.setImageAlignment("left"),active:o.isImageAlignedLeft,title:"Align Left",children:jsx(dt,{size:14})}),jsx(L,{onClick:()=>n.setImageAlignment("center"),active:o.isImageAlignedCenter,title:"Align Center",children:jsx(rt,{size:14})}),jsx(L,{onClick:()=>n.setImageAlignment("right"),active:o.isImageAlignedRight,title:"Align Right",children:jsx(gt,{size:14})}),O?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:b,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":"Image caption",onChange:J=>m(J.target.value),onBlur:I,onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),I());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:I,children:"Update Caption"})]})]}):null]})}let ke=i("bold"),ce=i("italic"),we=i("underline"),Oe=i("strikethrough"),Pe=i("codeFormat"),re=i("blockFormat"),je=i("link"),Ee=i("list"),Re=ke||ce||we||Oe,ie=Pe||re||je,Ne=Ee,he=!!o.isLink&&typeof n.updateLink=="function"&&typeof n.removeLink=="function",fe=()=>{if(!he)return;if(!(n.updateLink?.(q)??false)){F("Enter a valid URL"),typeof n.getCurrentLink=="function"&&n.getCurrentLink().then(I=>{W(I?.url??"");});return}F(null);};return !Re&&!ie&&!Ne?null:jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:Ce,children:[Re?jsxs(Fragment,{children:[ke?jsx(L,{onClick:()=>n.toggleBold(),active:o.bold,title:"Bold",children:jsx(Ht,{size:14})}):null,ce?jsx(L,{onClick:()=>n.toggleItalic(),active:o.italic,title:"Italic",children:jsx(Mt,{size:14})}):null,we?jsx(L,{onClick:()=>n.toggleUnderline(),active:o.underline,title:"Underline",children:jsx(zt,{size:14})}):null,Oe?jsx(L,{onClick:()=>n.toggleStrikethrough(),active:o.strikethrough,title:"Strikethrough",children:jsx(Pt,{size:14})}):null]}):null,Re&&ie?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,ie?jsxs(Fragment,{children:[Pe?jsx(L,{onClick:()=>n.formatText("code"),active:o.code,title:"Inline Code",children:jsx(Rt,{size:14})}):null,re?jsx(L,{onClick:()=>n.toggleQuote(),active:o.isQuote,title:"Quote",children:jsx(Ut,{size:14})}):null,je?jsxs(Fragment,{children:[jsx(L,{onClick:()=>o.isLink?n.removeLink():n.insertLink(),active:o.isLink,title:o.isLink?"Remove Link":"Insert Link",children:o.isLink?jsx(nt,{size:14}):jsx(ct,{size:14})}),he?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:q,className:`luthor-floating-toolbar-input${g?" is-error":""}`,placeholder:"https://example.com","aria-label":"Link URL","aria-invalid":g?true:void 0,onChange:O=>{W(O.target.value),g&&F(null);},onBlur:fe,onKeyDown:O=>{O.key==="Enter"&&(O.preventDefault(),fe());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:fe,children:"Update Link"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-danger",onClick:()=>n.removeLink(),"aria-label":"Unlink",children:jsx(nt,{size:13})})]}):null]}):null]}):null,(Re||ie)&&Ne?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,Ne?jsxs(Fragment,{children:[jsx(L,{onClick:()=>n.toggleUnorderedList(),active:o.unorderedList,title:"Bullet List",children:jsx(At,{size:14})}),jsx(L,{onClick:()=>n.toggleOrderedList(),active:o.orderedList,title:"Numbered List",children:jsx(Dt,{size:14})}),jsx(L,{onClick:()=>n.toggleCheckList(),active:o.checkList,title:"Checklist",children:jsx(Bt,{size:14})})]}):null]})}var De={commands:{},activeStates:{},editorTheme:"light",isFeatureEnabled:()=>true};function oo(e,t,n,o=()=>true){De.commands=e,De.activeStates=t,De.editorTheme=n,De.isFeatureEnabled=o;}function an(){let e=ln,t=new FloatingToolbarExtension;return t.config={...t.config,render:n=>createElement(e,{...n,commands:De.commands,activeStates:De.activeStates,editorTheme:De.editorTheme,isFeatureEnabled:De.isFeatureEnabled}),getCommands:()=>De.commands,getActiveStates:()=>De.activeStates},t}var kr=120,Er=58;function xr(e,t=Er){return e.length<=t?e:`${e.slice(0,t-3)}...`}function un(){let e=window.getSelection();return !e||e.rangeCount===0?false:!e.getRangeAt(0).collapsed}function cn(e,t){if(!(e instanceof Element))return null;let n=e.closest("a");return !(n instanceof HTMLAnchorElement)||!t.contains(n)?null:n}function mn({editor:e,commands:t,editorTheme:n="light",disabled:o=false}){let l=useRef(null),r=useRef(null),[i,a]=useState(null),[d,c]=useState(false),[E,h]=useState(""),[b,m]=useState(null),[p,$]=useState(null),H=useCallback(()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null);},[]),B=useCallback(()=>{H(),a(null),c(false),h(""),m(null),$(null);},[H]),q=useCallback(()=>{H(),r.current=window.setTimeout(()=>{B();},kr);},[H,B]),W=useCallback(g=>{let F=g.getBoundingClientRect(),k=F.bottom+8,V=Math.max(10,Math.min(F.left,window.innerWidth-340));$({top:k,left:V});},[]),v=useCallback((g,F)=>{if(typeof t.getLinkByKey!="function"){a(k=>!k||k.nodeKey!==g?k:{...k,url:F});return}t.getLinkByKey(g).then(k=>{if(!k){B();return}a(V=>!V||V.nodeKey!==g?V:{...V,url:k.url});});},[t,B]);useEffect(()=>{if(!e||o||typeof window>"u"){B();return}let g=e.getRootElement();if(!g){B();return}let F=ee=>{let D=cn(ee.target,g);if(!D)return;if(un()){B();return}H();let ve=resolveLinkNodeKeyFromAnchor(e,D);if(!ve)return;let Ce=D.getAttribute("href")??D.href;a({nodeKey:ve,url:Ce,anchorEl:D}),W(D),m(null),d||h(Ce),v(ve,Ce);},k=ee=>{if(!i)return;let D=ee.relatedTarget;D&&l.current?.contains(D)||cn(D,g)||q();},V=()=>{un()&&B();},R=()=>{a(ee=>{if(!ee)return ee;let D=ee.anchorEl.isConnected&&g.contains(ee.anchorEl)?ee.anchorEl:g.querySelector(`a[data-lexical-node-key="${ee.nodeKey}"]`);return D?(W(D),{...ee,anchorEl:D,url:D.getAttribute("href")??D.href}):(B(),null)});};return g.addEventListener("mouseover",F),g.addEventListener("mouseout",k),document.addEventListener("selectionchange",V),window.addEventListener("scroll",R,true),window.addEventListener("resize",R),()=>{g.removeEventListener("mouseover",F),g.removeEventListener("mouseout",k),document.removeEventListener("selectionchange",V),window.removeEventListener("scroll",R,true),window.removeEventListener("resize",R),H();}},[t,o,e,i,d,B,q,v,W,H]);let se=useMemo(()=>{if(!(!i||!p))return {...We(i.anchorEl),position:"fixed",top:p.top,left:p.left,zIndex:10040}},[i,p]);if(!i||!p||typeof document>"u")return null;let ue=()=>{(t.removeLinkByKey?.(i.nodeKey)??false)&&B();},Y=()=>{let g=E.trim();if(!(t.updateLinkByKey?.(i.nodeKey,g)??false)){m("Enter a valid URL"),v(i.nodeKey,i.url);return}a(k=>!k||k.nodeKey!==i.nodeKey?k:{...k,url:g}),m(null),c(false),queueMicrotask(()=>{v(i.nodeKey,g);});};return createPortal(jsx("div",{ref:l,className:"luthor-floating-toolbar luthor-link-hover-bubble","data-theme":n,style:se,onMouseEnter:H,onMouseLeave:q,children:d?jsxs(Fragment,{children:[jsx("input",{type:"url",value:E,className:`luthor-link-hover-bubble-input${b?" is-error":""}`,placeholder:"https://example.com","aria-label":"Edit link URL","aria-invalid":b?true:void 0,onChange:g=>{h(g.target.value),b&&m(null);},onKeyDown:g=>{if(g.key==="Enter"){g.preventDefault(),Y();return}g.key==="Escape"&&(g.preventDefault(),c(false),h(i.url),m(null));}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-primary",onClick:Y,children:"Update"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{c(false),h(i.url),m(null);},children:"Cancel"})]}):jsxs(Fragment,{children:[jsx("span",{className:"luthor-link-hover-bubble-url",title:i.url,children:xr(i.url)}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{h(i.url),c(true),m(null);},children:"Edit"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-danger",onClick:ue,"aria-label":"Unlink",children:jsx(nt,{size:13})})]})}),document.body)}function hn({mode:e,onModeChange:t,labels:n,availableModes:o,isConverting:l}){let r=o??["visual","json"],i={visual:n?.visual??"Visual",json:n?.json??"JSON"};return jsxs("div",{className:"luthor-mode-tabs",children:[r.includes("visual")&&jsxs("button",{className:`luthor-mode-tab ${e==="visual"?"active":""}`,onClick:()=>t("visual"),children:[i.visual,l==="visual"&&jsx("span",{className:"luthor-tab-converting-spinner"})]}),r.includes("json")&&jsxs("button",{className:`luthor-mode-tab ${e==="json"?"active":""}`,onClick:()=>t("json"),children:[i.json,l==="json"&&jsx("span",{className:"luthor-tab-converting-spinner"})]})]})}function fn({value:e,onChange:t,placeholder:n,className:o}){let l=useRef(null);return useLayoutEffect(()=>{let r=l.current;if(!r)return;r.style.height="auto";let i=Math.max(r.scrollHeight,280);r.style.height=`${i}px`;},[e]),jsx("textarea",{ref:l,className:`luthor-source-view${o?` ${o}`:""}`,value:e,onChange:r=>t(r.target.value),placeholder:n,spellCheck:false})}function pn(e){return e.replace(/\r\n?/g,`
2
+ `)}function io(e){let t=pn(e).trim();if(!t)return "";try{let n=JSON.parse(t);return JSON.stringify(n,null,2)}catch{return t}}function fa(e){return pn(e).trim()}var lo=6,wr=["#ffffff","#f2f2f2","#d9d9d9","#bfbfbf","#808080","#404040","#000000","#fbe5d6","#f8cbad","#f4b183","#ed7d31","#c55a11","#fff2cc","#ffe699","#ffd966","#ffc000","#bf9000","#7f6000","#e2f0d9","#c6e0b4","#a9d18e","#70ad47","#548235","#375623","#ddebf7","#bdd7ee","#9dc3e6","#5b9bd5","#2f75b5","#1f4e78","#e4dfec","#d9c2e9","#b4a7d6","#8e7cc3","#674ea7","#351c75"];function _t(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Or(e,t){let n=_t(t);for(let o of e)if(_t(o.value)===n)return o.color;return null}function Nr(e,t,n){if(!e||e==="default")return n;let o=Or(t,e);return o||e}function Hr(e,t){let n=e.trim();return /^#([\da-f]{6})$/i.test(n)?n:/^#([\da-f]{3})$/i.test(n)?`#${n.slice(1).split("").map(l=>`${l}${l}`).join("")}`:t}function _e(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function yn(e){let t=e.split(",")[0]??"";return _e(t.replace(/["']/g,""))}function $t(e){let t=e.trim().toLowerCase().match(/^(-?\d*\.?\d+)px$/);if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?n:null}function Vt(){if(typeof window>"u")return null;let t=window.getSelection()?.anchorNode;if(!t)return null;let n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!n||!n.closest(".luthor-content-editable"))return null;let l=window.getComputedStyle(n);return {fontFamily:l.fontFamily,fontSize:l.fontSize,lineHeight:l.lineHeight}}function Mr(e,t){if(!e)return null;let n=yn(e);return n?t.find(l=>_e(l.value)===n?true:yn(l.fontFamily)===n)?.value??null:null}function zr(e,t){if(!e)return null;let n=_e(e),o=t.find(i=>_e(String(i.value))===n?true:_e(String(i.fontSize))===n);if(o)return String(o.value);let l=$t(e);if(l==null)return null;let r=null;for(let i of t){let a=$t(String(i.fontSize));if(a==null)continue;let d=Math.abs(a-l);(!r||d<r.distance)&&(r={value:String(i.value),distance:d});}return r?.value??null}function Pr(e,t,n){if(!e)return null;let o=_e(e),l=n.find(c=>_e(c.value)===o?true:_e(c.lineHeight)===o);if(l)return l.value;let r=t?$t(t):null,i=$t(e),a=null;if(i!=null&&r!=null&&r>0)a=i/r;else {let c=Number(e);Number.isFinite(c)&&(a=c);}if(a==null)return null;let d=null;for(let c of n){let E=Number(c.lineHeight);if(!Number.isFinite(E))continue;let h=Math.abs(E-a);(!d||h<d.distance)&&(d={value:c.value,distance:h});}return d?.value??null}function vn({title:e,value:t,options:n,recentColors:o,active:l,fallbackColor:r,highlight:i,onChange:a,onClear:d,onAddRecent:c}){let E=useRef(null),h=useRef(null),b=useRef(null),m=useRef(null),p=useRef(null),[$,H]=useState(false),[B,q]=useState(void 0),W=Nr(t,n,r),v=useMemo(()=>wr,[]),se=useMemo(()=>{let g=[...o].slice(0,lo);for(;g.length<lo;)g.push("");return g},[o]);useEffect(()=>()=>{m.current&&window.cancelAnimationFrame(m.current);},[]);let ue=useCallback(g=>{p.current=g,!m.current&&(m.current=window.requestAnimationFrame(()=>{m.current=null,p.current&&(a(p.current),p.current=null);}));},[a]),Y=useCallback(g=>{let F=E.current;if(!F)return;let k=F.getBoundingClientRect();q({position:"fixed",top:k.bottom+6,left:k.left,width:230,visibility:g?"visible":"hidden",...We(F)});},[]);return useLayoutEffect(()=>{if(!$)return;Y(false);let g=window.requestAnimationFrame(()=>{Y(true);});return ()=>{window.cancelAnimationFrame(g);}},[$,Y]),useEffect(()=>{if(!$)return;let g=V=>{let R=V.target;E.current?.contains(R)||h.current?.contains(R)||H(false);},F=V=>{V.key==="Escape"&&H(false);},k=()=>Y(true);return window.addEventListener("resize",k),window.addEventListener("scroll",k,true),document.addEventListener("mousedown",g),document.addEventListener("keydown",F),()=>{window.removeEventListener("resize",k),window.removeEventListener("scroll",k,true),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",F);}},[$,Y]),jsxs(Fragment,{children:[jsxs("button",{ref:E,type:"button",className:`luthor-toolbar-button luthor-color-button${l?" active":""}${i?" is-highlight":""}`,title:e,"aria-label":e,onClick:()=>H(g=>!g),children:[i?jsx(Ao,{size:15,className:"luthor-color-button-highlighter"}):jsx("span",{className:"luthor-color-button-letter",children:"A"}),jsx("span",{className:"luthor-color-button-indicator",style:{backgroundColor:W}})]}),$&&typeof document<"u"&&createPortal(jsxs("div",{ref:h,className:"luthor-color-picker",style:B,children:[jsx("div",{className:"luthor-color-picker-header",children:jsx("span",{className:"luthor-color-picker-title",children:e})}),jsxs("div",{className:"luthor-color-picker-section",children:[jsx("p",{className:"luthor-color-picker-label",children:"Colors"}),jsx("div",{className:"luthor-color-swatch-grid",children:v.map(g=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:g},"aria-label":`Use color ${g}`,onClick:()=>{a(g),c(g),H(false);}},g))})]}),jsxs("div",{className:"luthor-color-picker-section",children:[jsx("p",{className:"luthor-color-picker-label",children:"Recent colors"}),jsx("div",{className:"luthor-color-swatch-row",children:se.map((g,F)=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:g||"transparent"},"aria-label":g?`Use recent color ${g}`:"Empty recent color slot",disabled:!g,onClick:()=>{g&&(a(g),c(g),H(false));}},`${g||"empty"}-${F}`))})]}),jsxs("div",{className:"luthor-color-picker-footer",children:[jsx("button",{type:"button",className:"luthor-color-picker-clear",onClick:()=>{d(),H(false);},children:"Reset to Default"}),jsxs("button",{type:"button",className:"luthor-color-picker-custom",onClick:()=>b.current?.click(),children:[jsx(Bo,{size:14}),jsx("span",{children:"Custom Color"})]}),jsx("input",{ref:b,type:"color",className:"luthor-color-picker-native luthor-color-picker-native-hidden",value:Hr(W,r),onInput:g=>{ue(g.target.value);},onChange:g=>{let F=g.target.value;a(F),c(F);}})]})]}),document.body)]})}function Rr(e,t){let n=useRef(null),o=useRef(null);return {handlers:useMemo(()=>({insertFromUrl:()=>{let r=prompt("Enter image URL:");if(!r)return;let i=prompt("Enter alt text:")||"",a=prompt("Enter caption (optional):")||void 0;e.insertImage({src:r,alt:i,caption:a});},insertFromFile:()=>n.current?.click(),insertGifFromUrl:()=>{let r=prompt("Enter GIF URL:");if(!r)return;let i=prompt("Enter alt text (optional):")||"GIF";e.insertImage({src:r,alt:i});},insertGifFromFile:()=>o.current?.click(),handleUpload:async r=>{let i=r.target.files?.[0];if(!i)return;let a;if(t)try{a=await t(i);}catch{alert("Failed to upload image");return}else a=URL.createObjectURL(i);e.insertImage({src:a,alt:i.name,file:i}),r.target.value="";},handleGifUpload:async r=>{let i=r.target.files?.[0];if(!i)return;if(!(i.type==="image/gif"||i.name.toLowerCase().endsWith(".gif"))){alert("Please select a GIF file."),r.target.value="";return}let d;if(t)try{d=await t(i);}catch{alert("Failed to upload GIF");return}else d=URL.createObjectURL(i);e.insertImage({src:d,alt:i.name||"GIF",file:i}),r.target.value="";},setAlignment:r=>{e.setImageAlignment(r);},setCaption:()=>{let r=prompt("Enter caption:")||"";e.setImageCaption(r);}}),[e,t]),fileInputRef:n,gifInputRef:o}}function Ar(e){return useMemo(()=>({insertIframe:()=>{let t=prompt("Enter iframe URL:");t&&typeof e.insertIframeEmbed=="function"&&e.insertIframeEmbed(t);},insertYouTube:()=>{let t=prompt("Enter YouTube URL:");t&&typeof e.insertYouTubeEmbed=="function"&&e.insertYouTubeEmbed(t);}}),[e])}function Br(e,t){switch(e){case "fontFamily":return t("fontFamily");case "fontSize":return t("fontSize");case "lineHeight":return t("lineHeight");case "textColor":return t("textColor");case "textHighlight":return t("textHighlight");case "subscript":return t("subscript");case "superscript":return t("superscript");case "blockFormat":case "quote":case "alignLeft":case "alignCenter":case "alignRight":case "alignJustify":return t("blockFormat");case "codeBlock":return t("code");case "unorderedList":case "orderedList":case "checkList":case "indentList":case "outdentList":return t("list");case "horizontalRule":return t("horizontalRule");case "table":return t("table");case "image":return t("image");case "emoji":return t("emoji");case "embed":return t("iframeEmbed")||t("youtubeEmbed");case "undo":case "redo":return t("history");default:return true}}function Dr(e,t,n){return Br(e,t)?n?.[e]!==false:false}function Kr(e,t,n){return {sections:e.sections.map(o=>({...o,items:o.items.filter(l=>Dr(l,t,n))})).filter(o=>o.items.length>0)}}function Cn({commands:e,hasExtension:t,activeStates:n,isDark:o,toggleTheme:l,onCommandPaletteOpen:r,imageUploadHandler:i,classNames:a,toolbarStyleVars:d,layout:c,toolbarVisibility:E,headingOptions:h,paragraphLabel:b}){let{handlers:m,fileInputRef:p,gifInputRef:$}=Rr(e,i),H=Ar(e),B=t("iframeEmbed")||t("youtubeEmbed"),q=n.isIframeEmbedSelected||n.isYouTubeEmbedSelected,[W,v]=useState(false),[se,ue]=useState(false),[Y,g]=useState(false),[F,k]=useState(false),[V,R]=useState(false),[ee,D]=useState("default"),[ve,Ce]=useState([{value:"default",label:"Default"}]),[ke,ce]=useState("default"),[we,Oe]=useState([{value:"default",label:"Default"}]),[Pe,re]=useState("default"),[je,Ee]=useState([{value:"default",label:"Default"}]),[Re,ie]=useState("default"),[Ne,he]=useState([{value:"default",label:"Default",color:"inherit"}]),[fe,O]=useState([]),[I,J]=useState("default"),[tt,He]=useState([{value:"default",label:"Default",color:"transparent"}]),[pe,Je]=useState([]),[Ie,Ae]=useState(0),[de,oe]=useState({rows:3,columns:3,includeHeaders:false});useEffect(()=>{if(typeof document>"u")return;let f=()=>{Vt()&&Ae(M=>M+1);};return document.addEventListener("selectionchange",f),()=>{document.removeEventListener("selectionchange",f);}},[]);let Me=useMemo(()=>t("emoji")?typeof e.getEmojiSuggestions=="function"?e.getEmojiSuggestions(""):typeof e.getEmojiCatalog=="function"?e.getEmojiCatalog():[]:[],[e,t]);useEffect(()=>{if(!t("fontFamily")||typeof e.getFontFamilyOptions!="function")return;let f=e.getFontFamilyOptions().map(M=>({value:M.value,label:M.label})),y=f.length>0?f:[{value:"default",label:"Default"}];Ce(y),D(M=>y.some(U=>U.value===M)?M:"default");},[e,t]),useEffect(()=>{if(!t("fontFamily")||typeof e.getCurrentFontFamily!="function")return;let f=e.getFontFamilyOptions;if(typeof f!="function")return;let y=false;return e.getCurrentFontFamily().then(M=>{if(y)return;if(M&&M!=="default"){D(M);return}let U=Vt(),ae=Mr(U?.fontFamily,f());D(ae??"default");}),()=>{y=true;}},[n,e,t,Ie]),useEffect(()=>{if(!t("fontSize")||typeof e.getFontSizeOptions!="function")return;let f=e.getFontSizeOptions().map(U=>({value:String(U.value).trim(),label:String(U.label).trim()})).filter(U=>U.value.length>0&&U.label.length>0),y=f.some(U=>_e(U.value)==="default"),M=f.length===0?[{value:"default",label:"Default"}]:y?f:[{value:"default",label:"Default"},...f];Oe(M),ce(U=>M.some(ae=>ae.value===U)?U:"default");},[e,t]),useEffect(()=>{if(!t("fontSize")||typeof e.getCurrentFontSize!="function")return;let f=e.getFontSizeOptions;if(typeof f!="function")return;let y=false;return e.getCurrentFontSize().then(M=>{if(y)return;if(M&&M!=="default"){ce(M);return}let U=Vt(),ae=zr(U?.fontSize,f());ce(ae??"default");}),()=>{y=true;}},[n,e,t,Ie]),useEffect(()=>{if(!t("lineHeight")||typeof e.getLineHeightOptions!="function")return;let f=e.getLineHeightOptions().map(y=>({value:y.value,label:y.label}));f.length>0&&Ee(f);},[e,t]),useEffect(()=>{if(!t("lineHeight")||typeof e.getCurrentLineHeight!="function")return;let f=e.getLineHeightOptions;if(typeof f!="function")return;let y=false;return e.getCurrentLineHeight().then(M=>{if(y)return;if(M){re(M);return}let U=Vt(),ae=Pr(U?.lineHeight,U?.fontSize,f());re(ae??"default");}),()=>{y=true;}},[n,e,t,Ie]),useEffect(()=>{if(!t("textColor")||typeof e.getTextColorOptions!="function")return;let f=e.getTextColorOptions().map(y=>({value:y.value,label:y.label,color:y.color}));f.length>0&&he(f);},[e,t]),useEffect(()=>{if(!t("textColor")||typeof e.getCurrentTextColor!="function")return;let f=false;return e.getCurrentTextColor().then(y=>{f||ie(y??"default");}),()=>{f=true;}},[n,e,t,Ie]),useEffect(()=>{if(!t("textHighlight")||typeof e.getTextHighlightOptions!="function")return;let f=e.getTextHighlightOptions().map(y=>({value:y.value,label:y.label,color:y.backgroundColor}));f.length>0&&He(f);},[e,t]),useEffect(()=>{if(!t("textHighlight")||typeof e.getCurrentTextHighlight!="function")return;let f=false;return e.getCurrentTextHighlight().then(y=>{f||J(y??"default");}),()=>{f=true;}},[n,e,t,Ie]);let xe=useMemo(()=>{if(!h||h.length===0)return [...Fe];let f=new Set,y=[];for(let M of h)!Fe.includes(M)||f.has(M)||(f.add(M),y.push(M));return y.length>0?y:[...Fe]},[h]),le=b?.trim()||"Paragraph",Be=useMemo(()=>{let f=xe.map(y=>({value:y,label:`Heading ${y.slice(1)}`}));return [{value:"p",label:le},...f]},[xe,le]),K=n.isH1?"h1":n.isH2?"h2":n.isH3?"h3":n.isH4?"h4":n.isH5?"h5":n.isH6?"h6":"p",ze=Be.some(f=>f.value===K)?K:"p",ut=f=>{f==="p"?e.toggleParagraph():f.startsWith("h")&&xe.includes(f)&&e.toggleHeading(f);},qe=f=>{f==="default"?e.clearFontFamily?.():e.setFontFamily?.(f),D(f);},ot=f=>{f==="default"?e.clearFontSize?.():e.setFontSize?.(f),ce(f);},Ye=f=>{e.setLineHeight?.(f),re(f);},C=(f,y)=>{f(M=>{let U=_t(y),ae=M.filter(ge=>_t(ge)!==U);return [y,...ae].slice(0,lo)});},S=f=>{if(f==="default"){e.clearTextColor?.(),ie("default");return}e.setTextColor?.(f),ie(f);},A=f=>{if(f==="default"){e.clearTextHighlight?.(),J("default");return}e.setTextHighlight?.(f),J(f);},G=f=>{switch(f){case "fontFamily":return t("fontFamily")?jsx(Et,{value:ee,onValueChange:qe,options:ve,placeholder:"Font"},"fontFamily"):null;case "fontSize":return t("fontSize")?jsx(Et,{value:ke,onValueChange:ot,options:we,placeholder:"Size"},"fontSize"):null;case "lineHeight":return t("lineHeight")?jsx(Et,{value:Pe,onValueChange:Ye,options:je,placeholder:"Line"},"lineHeight"):null;case "textColor":return t("textColor")?jsx(vn,{title:"Text Color",value:Re,options:Ne,recentColors:fe,active:n.hasCustomTextColor,fallbackColor:"#0f172a",onChange:S,onClear:()=>S("default"),onAddRecent:y=>C(O,y)},"textColor"):null;case "textHighlight":return t("textHighlight")?jsx(vn,{title:"Text Highlight",value:I,options:tt,recentColors:pe,active:n.hasTextHighlight,fallbackColor:"#fef08a",highlight:true,onChange:A,onClear:()=>A("default"),onAddRecent:y=>C(Je,y)},"textHighlight"):null;case "bold":return jsx(L,{onClick:()=>e.toggleBold(),active:n.bold,title:"Bold (Ctrl+B)",children:jsx(Ht,{size:16})},"bold");case "italic":return jsx(L,{onClick:()=>e.toggleItalic(),active:n.italic,title:"Italic (Ctrl+I)",children:jsx(Mt,{size:16})},"italic");case "underline":return jsx(L,{onClick:()=>e.toggleUnderline(),active:n.underline,title:"Underline (Ctrl+U)",children:jsx(zt,{size:16})},"underline");case "strikethrough":return jsx(L,{onClick:()=>e.toggleStrikethrough(),active:n.strikethrough,title:"Strikethrough",children:jsx(Pt,{size:16})},"strikethrough");case "subscript":return t("subscript")?jsx(L,{onClick:()=>e.toggleSubscript?.(),active:n.subscript,title:"Subscript",children:jsx($o,{size:16})},"subscript"):null;case "superscript":return t("superscript")?jsx(L,{onClick:()=>e.toggleSuperscript?.(),active:n.superscript,title:"Superscript",children:jsx(Jo,{size:16})},"superscript"):null;case "code":return jsx(L,{onClick:()=>e.formatText("code"),active:n.code,title:"Inline Code",children:jsx(Rt,{size:16})},"code");case "link":return jsx(L,{onClick:()=>n.isLink?e.removeLink():e.insertLink(),active:n.isLink,title:n.isLink?"Remove Link":"Insert Link",children:n.isLink?jsx(nt,{size:16}):jsx(ct,{size:16})},"link");case "blockFormat":return t("blockFormat")?jsx(Et,{value:ze,onValueChange:ut,options:Be,placeholder:"Format"},"blockFormat"):null;case "quote":return t("blockFormat")?jsx(L,{onClick:()=>e.toggleQuote(),active:n.isQuote,title:"Quote",children:jsx(Ut,{size:16})},"quote"):null;case "alignLeft":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("left"),active:n.isTextAlignedLeft,title:"Align Left",children:jsx(dt,{size:16})},"alignLeft"):null;case "alignCenter":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("center"),active:n.isTextAlignedCenter,title:"Align Center",children:jsx(rt,{size:16})},"alignCenter"):null;case "alignRight":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("right"),active:n.isTextAlignedRight,title:"Align Right",children:jsx(gt,{size:16})},"alignRight"):null;case "alignJustify":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("justify"),active:n.isTextAlignedJustify,title:"Justify",children:jsx(Mo,{size:16})},"alignJustify"):null;case "codeBlock":return t("code")?jsx(L,{onClick:()=>e.toggleCodeBlock(),active:n.isInCodeBlock,title:"Code Block",children:jsx(Oo,{size:16})},"codeBlock"):null;case "unorderedList":return t("list")?jsx(L,{onClick:()=>e.toggleUnorderedList(),active:n.unorderedList,title:"Bullet List",children:jsx(At,{size:16})},"unorderedList"):null;case "orderedList":return t("list")?jsx(L,{onClick:()=>e.toggleOrderedList(),active:n.orderedList,title:"Numbered List",children:jsx(Dt,{size:16})},"orderedList"):null;case "checkList":return t("list")?jsx(L,{onClick:()=>e.toggleCheckList(),active:n.checkList,title:"Checklist",children:jsx(Bt,{size:16})},"checkList"):null;case "indentList":return t("list")?jsx(L,{onClick:()=>e.indentList(),title:"Indent List",disabled:n.checkList,children:jsx(Ko,{size:14})},"indentList"):null;case "outdentList":return t("list")?jsx(L,{onClick:()=>e.outdentList(),title:"Outdent List",disabled:n.checkList,children:jsx(Uo,{size:14})},"outdentList"):null;case "horizontalRule":return t("horizontalRule")?jsx(L,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(zo,{size:16})},"horizontalRule"):null;case "table":return t("table")?jsx(L,{onClick:()=>R(true),title:"Insert Table",children:jsx(Po,{size:16})},"table"):null;case "image":return t("image")?jsxs(Fragment,{children:[jsxs(xt,{trigger:jsx("button",{className:`luthor-toolbar-button ${n.imageSelected?"active":""}`,title:"Insert Image",children:jsx(Wt,{size:16})}),isOpen:W,onOpenChange:v,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertFromUrl(),v(false);},children:[jsx(ct,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertFromFile(),v(false);},children:[jsx(Xt,{size:16}),jsx("span",{children:"Upload File"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertGifFromUrl(),v(false);},children:[jsx(Zt,{size:16}),jsx("span",{children:"Insert GIF URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertGifFromFile(),v(false);},children:[jsx(Xt,{size:16}),jsx("span",{children:"Upload GIF"})]})]},"image"),n.imageSelected&&jsxs(xt,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(rt,{size:16})}),isOpen:Y,onOpenChange:g,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setAlignment("left"),g(false);},children:[jsx(dt,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setAlignment("center"),g(false);},children:[jsx(rt,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setAlignment("right"),g(false);},children:[jsx(gt,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setCaption(),g(false);},children:[jsx(Do,{size:16}),jsx("span",{children:"Set Caption"})]})]},"imageAlign")]}):null;case "emoji":return !t("emoji")||Me.length===0?null:jsx(xt,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Insert Emoji",children:jsx(Zt,{size:16})}),isOpen:se,onOpenChange:ue,children:jsx("div",{className:"luthor-emoji-picker-grid",role:"listbox","aria-label":"Emoji picker",children:Me.map(y=>jsx("button",{type:"button",className:"luthor-emoji-picker-item",title:y.shortcodes[0]?`${y.label} (:${y.shortcodes[0]}:)`:y.label,onClick:()=>{e.insertEmoji?.(y.emoji),ue(false);},children:y.emoji},`${y.emoji}-${y.label}`))})},"emoji");case "embed":return B?jsxs(xt,{trigger:jsx("button",{className:`luthor-toolbar-button ${q?"active":""}`,title:"Insert Embed",children:jsx(Ro,{size:16})}),isOpen:F,onOpenChange:k,children:[t("iframeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{H.insertIframe(),k(false);},children:[jsx(ct,{size:16}),jsx("span",{children:"Embed iframe"})]}):null,t("youtubeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{H.insertYouTube(),k(false);},children:[jsx(Wt,{size:16}),jsx("span",{children:"Embed YouTube Video"})]}):null]},"embed"):null;case "undo":return t("history")?jsx(L,{onClick:()=>e.undo(),disabled:!n.canUndo,title:"Undo (Ctrl+Z)",children:jsx(No,{size:16})},"undo"):null;case "redo":return t("history")?jsx(L,{onClick:()=>e.redo(),disabled:!n.canRedo,title:"Redo (Ctrl+Y)",children:jsx(Ho,{size:16})},"redo"):null;case "commandPalette":return jsx(L,{onClick:()=>r?.(),title:"Command Palette (Ctrl+Shift+P)",children:jsx(Kt,{size:16})},"commandPalette");case "themeToggle":return jsx(L,{onClick:l,title:o?"Light Mode":"Dark Mode",children:o?jsx(jo,{size:16}):jsx(Vo,{size:16})},"themeToggle");default:return null}},Z=c??Ot,Ge=useMemo(()=>Kr(Z,t,E),[Z,t,E]);return jsxs(Fragment,{children:[jsx("div",{className:a?.toolbar??"luthor-toolbar",style:d,children:Ge.sections.map((f,y)=>{let M=f.items.map((U,ae)=>{let ge=G(U);return ge?Array.isArray(ge)?ge.map((Qe,me)=>Qe&&typeof Qe=="object"&&"key"in Qe&&Qe.key!=null?Qe:jsx("span",{children:Qe},`toolbar-item-${y}-${ae}-${me}`)):ge.type===Lr.Fragment?jsx("span",{children:ge},`toolbar-item-${y}-${ae}`):ge&&typeof ge=="object"&&"key"in ge&&ge.key!=null?ge:jsx("span",{children:ge},`toolbar-item-${y}-${ae}`):null}).flat().filter(U=>U!==null);return M.length===0?null:jsx("div",{className:a?.section??"luthor-toolbar-section",children:M},y)})}),jsx("input",{ref:p,type:"file",accept:"image/*",onChange:m.handleUpload,className:"luthor-file-input"}),jsx("input",{ref:$,type:"file",accept:"image/gif",onChange:m.handleGifUpload,className:"luthor-file-input"}),jsx(rn,{isOpen:V,onClose:()=>R(false),title:"Insert Table",children:jsxs("div",{className:"luthor-table-dialog",children:[jsxs("div",{className:"luthor-form-group",children:[jsx("label",{htmlFor:"table-rows",children:"Rows:"}),jsx("input",{id:"table-rows",type:"number",min:"1",max:"20",value:de.rows,onChange:f=>oe(y=>({...y,rows:parseInt(f.target.value)||1})),className:"luthor-input"})]}),jsxs("div",{className:"luthor-form-group",children:[jsx("label",{htmlFor:"table-columns",children:"Columns:"}),jsx("input",{id:"table-columns",type:"number",min:"1",max:"20",value:de.columns,onChange:f=>oe(y=>({...y,columns:parseInt(f.target.value)||1})),className:"luthor-input"})]}),jsx("div",{className:"luthor-form-group",children:jsxs("label",{className:"luthor-checkbox-label",children:[jsx("input",{type:"checkbox",checked:de.includeHeaders||false,onChange:f=>oe(y=>({...y,includeHeaders:f.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(to,{variant:"secondary",onClick:()=>R(false),children:"Cancel"}),jsx(to,{variant:"primary",onClick:()=>{e.insertTable(de),R(false);},children:"Insert Table"})]})]})})]})}var fo=["bold","italic","underline","strikethrough","fontFamily","fontSize","lineHeight","textColor","textHighlight","subscript","superscript","link","horizontalRule","table","list","history","image","blockFormat","code","codeIntelligence","codeFormat","tabIndent","enterKeyBehavior","iframeEmbed","youTubeEmbed","floatingToolbar","contextMenu","commandPalette","slashCommand","emoji","draggableBlock","customNode","themeToggle"],Ln={bold:true,italic:true,underline:true,strikethrough:true,fontFamily:true,fontSize:true,lineHeight:true,textColor:true,textHighlight:true,subscript:true,superscript:true,link:true,horizontalRule:true,table:true,list:true,history:true,image:true,blockFormat:true,code:true,codeIntelligence:true,codeFormat:true,tabIndent:true,enterKeyBehavior:true,iframeEmbed:true,youTubeEmbed:true,floatingToolbar:true,contextMenu:true,commandPalette:true,slashCommand:true,emoji:true,draggableBlock:true,customNode:true,themeToggle:true};function Ft(e){let t={...Ln};if(!e)return t;for(let n of fo)typeof e[n]=="boolean"&&(t[n]=e[n]);return t}function In(e,t){return e[t]!==false}var xn=[{value:"default",label:"Default",fontFamily:"inherit"},{value:"inter",label:"Inter",fontFamily:"'Inter', 'Segoe UI', Arial, sans-serif",cssImportUrl:"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"},{value:"merriweather",label:"Merriweather",fontFamily:"'Merriweather', Georgia, 'Times New Roman', serif",cssImportUrl:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700&display=swap"},{value:"jetbrains-mono",label:"JetBrains Mono",fontFamily:"'JetBrains Mono', 'Courier New', monospace",cssImportUrl:"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap"}],pi={value:"default",label:"Default",fontFamily:"inherit"},Tn=[{value:"default",label:"Default",fontSize:"inherit"},{value:"12",label:"12px",fontSize:"12px"},{value:"14",label:"14px",fontSize:"14px"},{value:"16",label:"16px",fontSize:"16px"},{value:"18",label:"18px",fontSize:"18px"},{value:"20",label:"20px",fontSize:"20px"},{value:"24",label:"24px",fontSize:"24px"},{value:"32",label:"32px",fontSize:"32px"}],bi={value:"default",label:"Default",fontSize:"inherit"},Sn=[{value:"default",label:"Default",lineHeight:"1.5"},{value:"1",label:"1.0",lineHeight:"1"},{value:"1.15",label:"1.15",lineHeight:"1.15"},{value:"1.5",label:"1.5",lineHeight:"1.5"},{value:"1.75",label:"1.75",lineHeight:"1.75"},{value:"2",label:"2.0",lineHeight:"2"}],yi={value:"default",label:"Default",lineHeight:"1.5"},It="1.5",vi=1;function at(e){return e.trim().toLowerCase()}function Fn(e){return /^[a-z0-9][a-z0-9-]*$/i.test(e)}function Ci(e){return at(e)==="default"?true:Jt(e)!==null}function ki(e){let t=e??xn,n=new Set,o=[];for(let r of t){let i=r.value.trim(),a=r.label.trim(),d=r.fontFamily.trim();if(!i||!a||!d||!Fn(i))continue;let c=at(i);n.has(c)||(n.add(c),o.push({value:i,label:a,fontFamily:d,cssImportUrl:r.cssImportUrl?.trim()||void 0}));}return o.length===0?xn:o.some(r=>at(r.value)==="default")?o:[pi,...o]}function Ei(e){let t=e??Tn,n=new Set,o=[];for(let r of t){let i=String(r.value).trim(),a=String(r.label).trim(),d=String(r.fontSize).trim();if(!i||!a||!d||!Fn(i))continue;let c=at(i);n.has(c)||(n.add(c),o.push({value:i,label:a,fontSize:d}));}return o.length===0?Tn:o.some(r=>at(r.value)==="default")?o:[bi,...o]}function Jt(e){let t=e.trim();if(!/^\d*\.?\d+$/.test(t))return null;let n=Number(t);return !Number.isFinite(n)||n<vi?null:n.toString()}function xi(e){return typeof e=="number"?Number.isFinite(e)?Jt(e.toString())??It:It:typeof e=="string"?Jt(e)??It:It}function Ti(e,t=It){let n=e??Sn,o=new Set,l=[];for(let i of n){let a=String(i.value).trim(),d=String(i.label).trim();if(!a||!d||!Ci(a))continue;let c=at(a);if(o.has(c))continue;if(c==="default"){o.add(c),l.push({value:a,label:d,lineHeight:t});continue}let E=Jt(String(i.lineHeight));E&&(o.add(c),l.push({value:a,label:d,lineHeight:E}));}return l.length===0?Sn:l.some(i=>at(i.value)==="default")?l:[{...yi,lineHeight:t},...l]}function et({children:e}){return jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e})}var Si=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M10.5 14.5h3"}),jsx("path",{d:"M12 2.8v4.4"}),jsx("path",{d:"M9.8 5h4.4"})]}),Li=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M10.5 8.5h3"}),jsx("path",{d:"M12 16.8v4.4"}),jsx("path",{d:"M9.8 19h4.4"})]}),Ii=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M11.5 5v14"}),jsx("path",{d:"M7.5 10.5v3"}),jsx("path",{d:"M2.8 12h4.4"}),jsx("path",{d:"M5 9.8v4.4"})]}),Fi=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M12.5 5v14"}),jsx("path",{d:"M16.5 10.5v3"}),jsx("path",{d:"M16.8 12h4.4"}),jsx("path",{d:"M19 9.8v4.4"})]}),wi=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M9.8 14.8l4.4 4.4"}),jsx("path",{d:"M14.2 14.8l-4.4 4.4"})]}),Oi=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M12 5v14"}),jsx("path",{d:"M14.8 9.8l4.4 4.4"}),jsx("path",{d:"M19.2 9.8l-4.4 4.4"})]}),Ni=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 10.5h17"}),jsx("path",{d:"M10.5 5v14"}),jsx("path",{d:"M14.8 9.8l4.4 4.4"}),jsx("path",{d:"M19.2 9.8l-4.4 4.4"})]}),Hi=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 10.5h17"}),jsx("path",{d:"M10.5 5v14"}),jsx("path",{d:"M3.5 8h17"})]}),qt=new ImageExtension;qt.config={...qt.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var so=new TableExtension;so.config={...so.config,enableContextMenu:true,tableBubbleRenderer:({headersEnabled:e,setHeadersEnabled:t,actions:n})=>jsxs(Fragment,{children:[jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert row above","aria-label":"Insert row above",onClick:n.insertRowAbove,children:jsx(Si,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert row below","aria-label":"Insert row below",onClick:n.insertRowBelow,children:jsx(Li,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column left","aria-label":"Insert column left",onClick:n.insertColumnLeft,children:jsx(Ii,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column right","aria-label":"Insert column right",onClick:n.insertColumnRight,children:jsx(Fi,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected row","aria-label":"Delete selected row",onClick:n.deleteSelectedRow,children:jsx(wi,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected column","aria-label":"Delete selected column",onClick:n.deleteSelectedColumn,children:jsx(Oi,{})}),jsx("label",{className:"luthor-table-bubble-checkbox",title:"Use first row as table headers",children:jsx("button",{type:"button",className:`luthor-table-bubble-button luthor-table-bubble-button-icon${e?" luthor-table-bubble-button-active":""}`,title:"Use first row as table headers","aria-label":"Use first row as table headers","aria-pressed":e,onClick:()=>t(!e),children:jsx(Hi,{})})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon luthor-table-bubble-button-danger",title:"Delete table","aria-label":"Delete table",onClick:n.deleteTable,children:jsx(Ni,{})})]})};var uo=new IframeEmbedExtension;uo.config={...uo.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center"};var co=new YouTubeEmbedExtension;co.config={...co.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center",nocookie:true,controls:true,rel:1};var Mi=an(),go=new ContextMenuExtension;go.config={...go.config,preventDefault:true};var zi=new CommandPaletteExtension,Pi=new SlashCommandExtension,Ri=new EmojiExtension,mo=new DraggableBlockExtension;mo.config={...mo.config,buttonStackPosition:"left"};var ho=new LinkExtension;ho.config={...ho.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var Ai=textColorExtension.configure({options:[{value:"default",label:"Default",color:"inherit"},{value:"slate",label:"Slate",color:"#334155"},{value:"red",label:"Red",color:"#dc2626"},{value:"orange",label:"Orange",color:"#ea580c"},{value:"green",label:"Green",color:"#16a34a"},{value:"blue",label:"Blue",color:"#2563eb"},{value:"purple",label:"Purple",color:"#7c3aed"}]}),Bi=textHighlightExtension.configure({options:[{value:"default",label:"Default",backgroundColor:"transparent"},{value:"yellow",label:"Yellow",backgroundColor:"#fef08a"},{value:"green",label:"Green",backgroundColor:"#bbf7d0"},{value:"blue",label:"Blue",backgroundColor:"#bfdbfe"},{value:"pink",label:"Pink",backgroundColor:"#fbcfe8"},{value:"orange",label:"Orange",backgroundColor:"#fed7aa"}]}),{extension:Di}=createCustomNodeExtension({nodeType:"featureCard",defaultPayload:{title:"Headless Custom Node",description:"This block is rendered by createCustomNodeExtension from @lyfie/luthor-headless.",tag:"Custom"},render:({payload:e,isSelected:t})=>jsxs("aside",{className:`luthor-extensive-feature-card${t?" is-selected":""}`,children:[jsx("div",{className:"luthor-extensive-feature-card__tag",children:e.tag??"Custom"}),jsx("h4",{className:"luthor-extensive-feature-card__title",children:e.title??"Custom Node"}),jsx("p",{className:"luthor-extensive-feature-card__description",children:e.description??"Insert strongly typed custom content blocks."})]})});function wn({fontFamilyOptions:e,fontSizeOptions:t,lineHeightOptions:n,minimumDefaultLineHeight:o,featureFlags:l,isDraggableBoxEnabled:r,scaleByRatio:i,syntaxHighlighting:a,codeHighlightProvider:d,loadCodeHighlightProvider:c,maxAutoDetectCodeLength:E,isCopyAllowed:h,languageOptions:b}={}){let m=Ft(l),p=se=>In(m,se),$=(r??true)&&p("draggableBlock"),H=xi(o),B=new FontFamilyExtension().configure({options:ki(e),cssLoadStrategy:"on-demand"}),q=new FontSizeExtension().configure({options:Ei(t)}),W=new LineHeightExtension().configure({options:Ti(n,H),defaultLineHeight:H});qt.configure({scaleByRatio:i??false}),codeExtension.configure({syntaxHighlighting:a??"auto",provider:d??void 0,loadProvider:c}),codeIntelligenceExtension.configure({provider:d??void 0,loadProvider:c,maxAutoDetectLength:E,isCopyAllowed:h??true,languageOptions:b});let v=[];return p("bold")&&v.push(boldExtension),p("italic")&&v.push(italicExtension),p("underline")&&v.push(underlineExtension),p("strikethrough")&&v.push(strikethroughExtension),p("fontFamily")&&v.push(B),p("fontSize")&&v.push(q),p("lineHeight")&&v.push(W),p("textColor")&&v.push(Ai),p("textHighlight")&&v.push(Bi),p("subscript")&&v.push(subscriptExtension),p("superscript")&&v.push(superscriptExtension),p("link")&&v.push(ho),p("horizontalRule")&&v.push(horizontalRuleExtension),p("table")&&v.push(so),p("list")&&v.push(listExtension),p("history")&&v.push(historyExtension),p("image")&&v.push(qt),p("blockFormat")&&v.push(blockFormatExtension),p("code")&&v.push(codeExtension),p("codeIntelligence")&&v.push(codeIntelligenceExtension),p("codeFormat")&&v.push(codeFormatExtension),p("tabIndent")&&v.push(tabIndentExtension),p("enterKeyBehavior")&&v.push(enterKeyBehaviorExtension),p("iframeEmbed")&&v.push(uo),p("youTubeEmbed")&&v.push(co),p("floatingToolbar")&&v.push(Mi),p("contextMenu")&&v.push(go),p("commandPalette")&&v.push(zi),p("slashCommand")&&v.push(Pi),p("emoji")&&v.push(Ri),$&&v.push(mo),p("customNode")&&v.push(Di),v}function wt(e){return wn(e)}var po=wn();function On(e){if(!e)return "__default__";let t=Object.entries(e).filter(([,n])=>typeof n=="string"&&n.trim().length>0).sort(([n],[o])=>n.localeCompare(o));return t.length>0?JSON.stringify(t):"__default__"}function Nn(e){if(!e)return;let t={},n=(o,l)=>{typeof l=="string"&&l.trim().length>0&&(t[o]=l.trim());};return n("--luthor-fg",e.font?.color),n("--luthor-text-bold-color",e.font?.boldColor),n("--luthor-link-color",e.link?.color),n("--luthor-list-marker-color",e.list?.markerColor),n("--luthor-list-checkbox-color",e.list?.checkboxColor),n("--luthor-quote-bg",e.quote?.backgroundColor),n("--luthor-quote-fg",e.quote?.color),n("--luthor-quote-border",e.quote?.indicatorColor),n("--luthor-table-border-color",e.table?.borderColor),n("--luthor-table-header-bg",e.table?.headerBackgroundColor),n("--luthor-hr-color",e.hr?.color),n("--luthor-placeholder-color",e.placeholder?.color),n("--luthor-codeblock-bg",e.codeblock?.backgroundColor),n("--luthor-toolbar-bg",e.toolbar?.backgroundColor),Object.keys(t).length>0?t:void 0}function Hn(e){if(!(e instanceof Element))return false;if(e.closest('[contenteditable="true"]'))return true;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"}function Mn(e,t){if(e.key.toLowerCase()!==t.key.toLowerCase())return false;let n=e.ctrlKey||e.metaKey;return !(!!t.requiresPrimary!==n||!!t.shift!=!!e.shiftKey||!!t.alt!=!!e.altKey)}function zn(e,t,n){let o={...e??{}};for(let[l,r]of Object.entries(n))(Array.isArray(r)?r:[r]).some(d=>t[d]!==false)||(o[l]=false);return o}function Pn(e,t,n){let o={...e},l=(r,i)=>{t[r]===false&&i();};return l("bold",()=>{o.toggleBold=()=>{};}),l("italic",()=>{o.toggleItalic=()=>{};}),l("underline",()=>{o.toggleUnderline=()=>{};}),l("strikethrough",()=>{o.toggleStrikethrough=()=>{};}),l("codeFormat",()=>{o.formatText=()=>{};}),l("fontFamily",()=>{o.setFontFamily=()=>{},o.clearFontFamily=()=>{};}),l("fontSize",()=>{o.setFontSize=()=>{},o.clearFontSize=()=>{};}),l("lineHeight",()=>{o.setLineHeight=()=>{},o.clearLineHeight=()=>{};}),l("textColor",()=>{o.setTextColor=()=>{},o.clearTextColor=()=>{};}),l("textHighlight",()=>{o.setTextHighlight=()=>{},o.clearTextHighlight=()=>{};}),l("subscript",()=>{o.toggleSubscript=()=>{};}),l("superscript",()=>{o.toggleSuperscript=()=>{};}),l("link",()=>{o.insertLink=()=>{},o.removeLink=()=>{},o.updateLink=()=>false,o.getCurrentLink=async()=>null,o.getLinkByKey=async()=>null,o.updateLinkByKey=()=>false,o.removeLinkByKey=()=>false;}),l("blockFormat",()=>{o.toggleParagraph=()=>{},o.toggleHeading=()=>{},o.toggleQuote=()=>{},o.setTextAlignment=()=>{};}),l("code",()=>{o.toggleCodeBlock=()=>{};}),l("codeIntelligence",()=>{o.setCodeLanguage=()=>{},o.autoDetectCodeLanguage=async()=>null,o.copySelectedCodeBlock=async()=>false;}),l("list",()=>{o.toggleUnorderedList=()=>{},o.toggleOrderedList=()=>{},o.toggleCheckList=()=>{},o.indentList=()=>{},o.outdentList=()=>{};}),l("horizontalRule",()=>{o.insertHorizontalRule=()=>{};}),l("table",()=>{o.insertTable=()=>{};}),l("image",()=>{o.insertImage=()=>{},o.setImageAlignment=()=>{},o.setImageCaption=()=>{},o.getImageCaption=async()=>"";}),l("emoji",()=>{o.insertEmoji=()=>{},o.executeEmojiSuggestion=()=>false,o.closeEmojiSuggestions=()=>{},o.getEmojiSuggestions=()=>[],o.getEmojiCatalog=()=>[],o.resolveEmojiShortcode=()=>null,o.setEmojiCatalog=()=>{},o.setEmojiCatalogAdapter=()=>{},o.getEmojiCatalogAdapter=()=>({search:()=>[],resolveShortcode:()=>null,getAll:()=>[]});}),l("iframeEmbed",()=>{o.insertIframeEmbed=()=>{},o.setIframeEmbedAlignment=()=>{},o.resizeIframeEmbed=()=>{},o.setIframeEmbedCaption=()=>{},o.getIframeEmbedCaption=async()=>"",o.updateIframeEmbedUrl=()=>false,o.getIframeEmbedUrl=async()=>"";}),l("youTubeEmbed",()=>{o.insertYouTubeEmbed=()=>{},o.setYouTubeEmbedAlignment=()=>{},o.resizeYouTubeEmbed=()=>{},o.setYouTubeEmbedCaption=()=>{},o.getYouTubeEmbedCaption=async()=>"",o.updateYouTubeEmbedUrl=()=>false,o.getYouTubeEmbedUrl=async()=>"";}),l("history",()=>{o.undo=()=>{},o.redo=()=>{};}),l("commandPalette",()=>{o.showCommandPalette=()=>{},o.hideCommandPalette=()=>{},o.registerCommand=()=>{},o.unregisterCommand=()=>{};}),l("slashCommand",()=>{o.registerSlashCommand=()=>{},o.unregisterSlashCommand=()=>{},o.setSlashCommands=()=>{},o.closeSlashMenu=()=>{},o.executeSlashCommand=()=>false;}),n&&(o.toggleBold=()=>{},o.toggleItalic=()=>{},o.toggleUnderline=()=>{},o.toggleStrikethrough=()=>{},o.formatText=()=>{},o.setFontFamily=()=>{},o.clearFontFamily=()=>{},o.setFontSize=()=>{},o.clearFontSize=()=>{},o.setLineHeight=()=>{},o.clearLineHeight=()=>{},o.setTextColor=()=>{},o.clearTextColor=()=>{},o.setTextHighlight=()=>{},o.clearTextHighlight=()=>{},o.toggleSubscript=()=>{},o.toggleSuperscript=()=>{},o.insertLink=()=>{},o.removeLink=()=>{},o.updateLink=()=>false,o.toggleParagraph=()=>{},o.toggleHeading=()=>{},o.toggleQuote=()=>{},o.setTextAlignment=()=>{},o.toggleUnorderedList=()=>{},o.toggleOrderedList=()=>{},o.toggleCheckList=()=>{},o.indentList=()=>{},o.outdentList=()=>{},o.insertHorizontalRule=()=>{},o.insertTable=()=>{},o.insertImage=()=>{},o.setImageAlignment=()=>{},o.setImageCaption=()=>{},o.insertIframeEmbed=()=>{},o.setIframeEmbedAlignment=()=>{},o.resizeIframeEmbed=()=>{},o.setIframeEmbedCaption=()=>{},o.updateIframeEmbedUrl=()=>false,o.insertYouTubeEmbed=()=>{},o.setYouTubeEmbedAlignment=()=>{},o.resizeYouTubeEmbed=()=>{},o.setYouTubeEmbedCaption=()=>{},o.updateYouTubeEmbedUrl=()=>false),o}function Rn(e){return new Set(e)}function An(e,t){e.clear();for(let n of t)e.add(n);}function Bn(e,t){return e.has(t)}function Dn(e,t){e.add(t);}var N=(e,t=0,n="")=>({type:"text",version:1,text:e,detail:0,format:t,mode:"normal",style:n}),ye=(e,t="",n=0)=>({type:"paragraph",version:1,format:t,indent:n,direction:null,children:e}),bo={root:{type:"root",version:1,format:"",indent:0,direction:null,children:[{type:"heading",version:1,tag:"h1",format:"",indent:0,direction:null,children:[N("Extensive Preset: JSON-First Feature Showcase")]},ye([N("This starter content is now a native "),N("JSON",1),N(" document that demonstrates visual editing without Markdown conversion.")]),{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[N("Inline formatting + typography")]},ye([N("Bold",1),N(" \u2022 "),N("Italic",2),N(" \u2022 "),N("Underline",8),N(" \u2022 "),N("Strikethrough",4),N(" \u2022 "),N("Inline Code",16),N(" \u2022 "),N("Subscript",32),N(" \u2022 "),N("Superscript",64)]),ye([N("Font family + size + color + highlight + line-height can be combined in one sentence.",0,"font-family: 'Inter', 'Segoe UI', Arial, sans-serif; font-size: 18px; line-height: 1.75; color: #2563eb; background-color: #bfdbfe;")]),{type:"paragraph",version:1,format:"center",indent:0,direction:null,children:[N("Centered paragraph with custom style",0,"font-size: 20px; color: #7c3aed;")]},{type:"paragraph",version:1,format:"right",indent:0,direction:null,children:[N("Right-aligned paragraph with highlight",128,"background-color: #fef08a;")]},{type:"quote",version:1,format:"",indent:0,direction:null,children:[N("\u201CEverything in this demo is persisted in JSON and can round-trip via visual mode.\u201D")]},{type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"link",version:1,rel:"noreferrer",target:"_blank",title:"Luthor documentation",url:"https://github.com/facebook/lexical",format:"",indent:0,direction:null,children:[N("Example link node")]},N(" with regular sibling text and emoji support \u{1F389}\u{1F525}\u2705.")]},{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[N("Lists")]},{type:"list",version:1,listType:"bullet",start:1,tag:"ul",format:"",indent:0,direction:null,children:[{type:"listitem",version:1,value:1,format:"",indent:0,direction:null,children:[ye([N("Bullet item with styled text",0,"color: #16a34a;")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[ye([N("Nested formatting in lists",1),N(" works great.")])]}]},{type:"list",version:1,listType:"number",start:1,tag:"ol",format:"",indent:0,direction:null,children:[{type:"listitem",version:1,value:1,format:"",indent:0,direction:null,children:[ye([N("Numbered item 1")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[ye([N("Numbered item 2")])]}]},{type:"list",version:1,listType:"check",start:1,tag:"ul",format:"",indent:0,direction:null,children:[{type:"listitem",version:1,value:1,checked:true,format:"",indent:0,direction:null,children:[ye([N("Checked task item")])]},{type:"listitem",version:1,value:2,checked:false,format:"",indent:0,direction:null,children:[ye([N("Unchecked task item")])]}]},{children:[{detail:0,format:0,mode:"normal",style:"",text:"const",type:"code-highlight",version:1,highlightType:"keyword"},{detail:0,format:0,mode:"normal",style:"",text:" content ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"=",type:"code-highlight",version:1,highlightType:"operator"},{detail:0,format:0,mode:"normal",style:"",text:" exportApi",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"toJSON",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"},{type:"linebreak",version:1},{detail:0,format:0,mode:"normal",style:"",text:"await",type:"code-highlight",version:1,highlightType:"keyword"},{detail:0,format:0,mode:"normal",style:"",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"saveToDatabase",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"{",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:" json",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:":",type:"code-highlight",version:1,highlightType:"operator"},{detail:0,format:0,mode:"normal",style:"",text:" content ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"}",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"},{type:"linebreak",version:1},{detail:0,format:0,mode:"normal",style:"",text:"importApi",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"fromJSON",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"content",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"}],direction:null,format:"",indent:0,type:"code",version:1,language:"typescript"},{type:"horizontalrule",version:1},{type:"featureCard",version:1,payload:{title:"Custom Node: Feature Card",description:"This block is rendered with createCustomNodeExtension and persists as structured payload.",tag:"Custom"},format:"",indent:0,direction:null,children:[]},{type:"image",version:1,src:"https://images.unsplash.com/photo-1461749280684-dccba630e2f6?auto=format&fit=crop&w=1200&q=80",alt:"Code editor on a laptop",caption:"Image node with caption, center alignment, and persisted dimensions.",alignment:"center",width:780,height:420},{type:"youtube-embed",version:1,src:"https://www.youtube.com/embed/dQw4w9WgXcQ",width:720,height:405,alignment:"center",start:0},{type:"iframe-embed",version:1,src:"https://example.com",width:720,height:405,alignment:"center",title:"Iframe embed example"},{type:"table",version:1,format:"",indent:0,direction:null,children:[{type:"tablerow",version:1,children:[{type:"tablecell",version:1,headerState:3,colSpan:1,rowSpan:1,width:240,backgroundColor:null,children:[ye([N("Feature")])]},{type:"tablecell",version:1,headerState:3,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[ye([N("Status")])]}]},{type:"tablerow",version:1,children:[{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:240,backgroundColor:null,children:[ye([N("Visual \u2194 JSON switching")])]},{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[ye([N("Round-trip ready \u2705")])]}]}]},ye([N("Use the toolbar, floating toolbar, slash commands (/), and command palette (Ctrl/Cmd+Shift+P) to explore the full preset.")])]}};JSON.stringify(bo);var{Provider:Gi,useEditor:Qi}=createEditorSystem(),Kn="Write anything...",Un="Enter JSON document content...";function Wi(e){let n=e.replace(/\r\n?/g,`
3
+ `).trim().split(/\n{2,}/).map(l=>l.replace(/\s+/g," ").trim()).filter(l=>l.length>0);return {root:{type:"root",version:1,format:"",indent:0,direction:null,children:(n.length>0?n:[""]).map(l=>({type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"text",version:1,text:l,detail:0,format:0,mode:"normal",style:""}]}))}}}function Xi(e){try{let t=JSON.parse(e);return JSON.stringify(t)}catch{return JSON.stringify(Wi(e))}}function Zi(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:t.value.trim(),label:t.label.trim(),fontFamily:t.fontFamily.trim(),cssImportUrl:t.cssImportUrl?.trim()||""})))}function el(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:String(t.value).trim(),label:String(t.label).trim(),fontSize:String(t.fontSize).trim()})))}function tl(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:String(t.value).trim(),label:String(t.label).trim(),lineHeight:String(t.lineHeight).trim()})))}function ol(e){if(typeof e=="number")return !Number.isFinite(e)||e<1?"1.5":e.toString();if(typeof e=="string"){let n=e.trim();if(n.length===0)return "1.5";let o=Number(n);return !Number.isFinite(o)||o<1?"1.5":o.toString()}return "1.5"}function yo(e){return On(e)}function nl(e){if(!e)return "__default__";if(Array.isArray(e))return JSON.stringify({mode:"append",values:e.map(o=>o.trim())});let t=e,n=Array.isArray(t.values)?t.values:[];return JSON.stringify({mode:t.mode??"append",values:n.map(o=>o.trim())})}function rl(e){return Nn(e)}function il(e){let t=Ft(e);return JSON.stringify(fo.map(n=>[n,t[n]]))}function jn(e){return Hn(e)}var ll=[{feature:"bold",key:"b",requiresPrimary:true},{feature:"italic",key:"i",requiresPrimary:true},{feature:"underline",key:"u",requiresPrimary:true},{feature:"link",key:"k",requiresPrimary:true},{feature:"history",key:"z",requiresPrimary:true},{feature:"history",key:"y",requiresPrimary:true},{feature:"history",key:"z",requiresPrimary:true,shift:true},{feature:"commandPalette",key:"p",requiresPrimary:true,shift:true},{feature:"codeFormat",key:"`",requiresPrimary:true},{feature:"code",key:"`",requiresPrimary:true,shift:true},{feature:"list",key:"l",requiresPrimary:true,shift:true},{feature:"list",key:"l",requiresPrimary:true,alt:true},{feature:"list",key:"x",requiresPrimary:true,shift:true},{feature:"blockFormat",key:"0",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"1",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"2",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"3",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"4",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"5",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"6",requiresPrimary:true,alt:true}];function al(e,t){return Mn(e,t)}function sl(e,t,n){return Pn(e,t,n)}var ul={fontFamily:"fontFamily",fontSize:"fontSize",lineHeight:"lineHeight",textColor:"textColor",textHighlight:"textHighlight",bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",subscript:"subscript",superscript:"superscript",code:"codeFormat",link:"link",blockFormat:"blockFormat",quote:"blockFormat",alignLeft:"blockFormat",alignCenter:"blockFormat",alignRight:"blockFormat",alignJustify:"blockFormat",codeBlock:"code",unorderedList:"list",orderedList:"list",checkList:"list",indentList:"list",outdentList:"list",horizontalRule:"horizontalRule",table:"table",image:"image",emoji:"emoji",embed:["iframeEmbed","youTubeEmbed"],undo:"history",redo:"history",commandPalette:"commandPalette",themeToggle:"themeToggle"};function cl(e,t){return zn(e,t,ul)}function dl(e){if(!e||e.length===0)return [...Fe];let t=new Set,n=[];for(let o of e)!Fe.includes(o)||t.has(o)||(t.add(o),n.push(o));return n.length>0?n:[...Fe]}function gl(e){if(!e)return "__default__";if(Array.isArray(e)){let r=new Set,i=[];for(let a of e)for(let[d,c]of Object.entries(a)){let E=d.trim();!c||!E||r.has(E)||(r.add(E),i.push(E));}return i.length===0?"__default__":JSON.stringify({allowlist:i,denylist:[]})}let t=r=>{if(!r||r.length===0)return [];let i=new Set,a=[];for(let d of r){let c=d.trim();!c||i.has(c)||(i.add(c),a.push(c));}return a},n=e,o=t(n.allowlist),l=t(n.denylist);return o.length===0&&l.length===0?"__default__":JSON.stringify({allowlist:o,denylist:l})}function ml(e){if(!e||e.length===0)return [];let t=new Set,n=[];for(let o of e){let l=o.trim();!l||t.has(l)||(t.add(l),n.push(l));}return n}function hl(e,t){return e.key.toLowerCase()===t.key.toLowerCase()&&!!e.ctrlKey==!!t.ctrlKey&&!!e.metaKey==!!t.metaKey&&!!e.shiftKey==!!t.shiftKey&&!!e.altKey==!!t.altKey}function fl(e){if(!e)return "__default__";let t=Array.isArray(e.disabledCommandIds)?[...e.disabledCommandIds].map(o=>o.trim()).filter(o=>o.length>0).sort((o,l)=>o.localeCompare(l)):[],n=e.bindings?Object.entries(e.bindings).map(([o,l])=>{if(l===false||l===null)return [o,false];let i=(Array.isArray(l)?l:[l]).map(a=>({key:a.key.trim(),ctrlKey:!!a.ctrlKey,metaKey:!!a.metaKey,shiftKey:!!a.shiftKey,altKey:!!a.altKey,preventDefault:a.preventDefault})).filter(a=>a.key.length>0).sort((a,d)=>{let c=`${a.key}:${a.ctrlKey?1:0}:${a.metaKey?1:0}:${a.shiftKey?1:0}:${a.altKey?1:0}`,E=`${d.key}:${d.ctrlKey?1:0}:${d.metaKey?1:0}:${d.shiftKey?1:0}:${d.altKey?1:0}`;return c.localeCompare(E)});return i.length===0?[o,false]:[o,i]}).sort(([o],[l])=>o.localeCompare(l)):[];return JSON.stringify({disabledCommandIds:t,bindings:n,preventCollisions:e.preventCollisions!==false,preventNativeConflicts:e.preventNativeConflicts!==false})}function pl({isDark:e,toggleTheme:t,visualPlaceholder:n,jsonPlaceholder:o,initialMode:l,availableModes:r,onReady:i,toolbarLayout:a,toolbarVisibility:d,toolbarPosition:c,toolbarAlignment:E,toolbarClassName:h,toolbarStyleVars:b,isToolbarEnabled:m,headingOptions:p,paragraphLabel:$,syncHeadingOptionsWithCommands:H,slashCommandVisibility:B,shortcutConfig:q,commandPaletteShortcutOnly:W,featureFlags:v}){let{commands:se,hasExtension:ue,activeStates:Y,lexical:g,extensions:F,export:k,import:V}=Qi(),[R,ee]=useState(l),[D,ve]=useState({json:""}),[Ce,ke]=useState(null),[ce,we]=useState(null),[Oe,Pe]=useState({isOpen:false,commands:[]}),[re,je]=useState({isOpen:false,query:"",position:null,commands:[]}),[Ee,Re]=useState({isOpen:false,query:"",position:null,suggestions:[]}),ie=useRef(false),Ne=useMemo(()=>dl(p),[p]),he=H?Ne:void 0,fe=H?$:void 0,O=Y.isInCodeBlock===true,I=useMemo(()=>sl(se,v,O),[se,v,O]),J=useMemo(()=>C=>Object.prototype.hasOwnProperty.call(v,C)?v[C]!==false:true,[v]),tt=useMemo(()=>cl(d,v),[d,v]),He=v.draggableBlock!==false,pe=gl(B),Je=useRef(B),Ie=useRef(pe),Ae=fl(q),de=useRef(q),oe=useRef(Ae),Me=useMemo(()=>ml(q?.disabledCommandIds),[q?.disabledCommandIds]),xe=useMemo(()=>new Set(Me),[Me]),le=useMemo(()=>xe.size===0?[]:Qt({headingOptions:he,paragraphLabel:fe,isFeatureEnabled:J}).filter(C=>xe.has(C.id)).flatMap(C=>C.shortcuts??[]),[xe,he,fe,J]);Ie.current!==pe&&(Ie.current=pe,Je.current=B),oe.current!==Ae&&(oe.current=Ae,de.current=q);let Be=useRef(Rn(["visual"])),K=useRef(0);useEffect(()=>{oo(I,Y,e?"dark":"light",J);},[I,Y,e,J]);let ze=useMemo(()=>({injectJSON:A=>{setTimeout(()=>{try{let G=JSON.parse(A);V.fromJSON(G);}catch(G){console.error("Failed to inject JSON:",G);return}},100);},getJSON:()=>io(JSON.stringify(k.toJSON()))}),[k,V]);useEffect(()=>{if(!g||!I)return;let C=I,S=Lo(C,{headingOptions:he,paragraphLabel:fe,isFeatureEnabled:J,shortcutConfig:de.current,commandPaletteShortcutOnly:W});typeof C.registerCommand=="function"&&S.forEach(Z=>C.registerCommand(Z));let A=Io(C,{headingOptions:he,paragraphLabel:fe,slashCommandVisibility:Je.current,isFeatureEnabled:J,shortcutConfig:de.current});typeof C.setSlashCommands=="function"?C.setSlashCommands(A):A.forEach(Z=>C.registerSlashCommand?.(Z));let G=wo(C,document.body,{headingOptions:he,paragraphLabel:fe,isFeatureEnabled:J,shortcutConfig:de.current,scope:()=>g.getRootElement()});return ie.current||(ie.current=true,i?.(ze)),()=>{G(),typeof C.unregisterCommand=="function"&&S.forEach(Z=>C.unregisterCommand(Z.id)),typeof C.setSlashCommands=="function"?C.setSlashCommands([]):A.forEach(Z=>C.unregisterSlashCommand?.(Z.id));}},[g,I,ze,i,he,fe,pe,Ae,J,W]),useEffect(()=>{let C=()=>g?.getRootElement(),S=ll.filter(G=>v[G.feature]===false);if(S.length===0)return;let A=G=>{let Z=C();Z&&G.target instanceof Node&&!Z.contains(G.target)||!jn(G.target)||!S.some(f=>al(G,f))||(G.preventDefault(),G.stopPropagation());};return document.addEventListener("keydown",A,true),()=>{document.removeEventListener("keydown",A,true);}},[g,v]),useEffect(()=>{let C=F.find(S=>S.name==="commandPalette");if(!(!C||!C.subscribe))return C.subscribe((S,A)=>{let G=A.filter(Z=>xe.has(Z.id)?false:W?typeof Z.shortcut=="string"&&Z.shortcut.trim().length>0:true);Pe({isOpen:S,commands:G});})},[F,xe,W]),useEffect(()=>{if(le.length===0)return;let C=()=>g?.getRootElement(),S=A=>{let G=C();G&&A.target instanceof Node&&!G.contains(A.target)||!jn(A.target)||!le.some(Ge=>hl(A,Ge))||(A.preventDefault(),A.stopPropagation());};return document.addEventListener("keydown",S,true),()=>{document.removeEventListener("keydown",S,true);}},[g,le]),useEffect(()=>{let C=F.find(S=>S.name==="slashCommand");if(!(!C||!C.subscribe))return C.subscribe(S=>{je({isOpen:S.isOpen,query:S.query,position:S.position,commands:S.commands});})},[F]),useEffect(()=>{let C=F.find(S=>S.name==="emoji");if(!(!C||!C.subscribe))return C.subscribe(S=>{Re({isOpen:S.isOpen,query:S.query,position:S.position,suggestions:S.suggestions});})},[F]),useEffect(()=>!g||!k?void 0:g.registerUpdateListener(()=>{K.current+=1,An(Be.current,["visual"]);}),[g,k]);let ut=async C=>{if(r.includes(C))try{if(we(null),R==="json"&&C!=="json"){let S=JSON.parse(D.json);V.fromJSON(S),await new Promise(A=>setTimeout(A,50));}if(R==="visual"&&C!=="visual"&&(g&&clearLexicalSelection(g),g?.getRootElement()?.blur()),ee(C),C==="json"&&R!=="json"&&!Bn(Be.current,"json")){ke("json"),await new Promise(S=>setTimeout(S,50));try{let S=io(JSON.stringify(k.toJSON()));ve(A=>({...A,json:S})),Dn(Be.current,"json");}finally{ke(null);}}C==="visual"&&setTimeout(()=>g?.focus(),100);}catch(S){let A=S instanceof Error?S.message:"Invalid format - could not parse content";we({mode:R,error:A});}},qe=m?jsx(Cn,{commands:I,hasExtension:C=>ue(C),activeStates:Y,isDark:e,toggleTheme:t,onCommandPaletteOpen:()=>{v.commandPalette!==false&&I.showCommandPalette();},imageUploadHandler:C=>F.find(S=>S.name==="image")?.config?.uploadHandler?.(C)??Promise.resolve(URL.createObjectURL(C)),layout:a??Ot,toolbarVisibility:tt,toolbarStyleVars:b,headingOptions:Ne,paragraphLabel:$,classNames:{toolbar:`luthor-toolbar luthor-toolbar--align-${E}${h?` ${h}`:""}`}}):null,ot=R==="visual"&&m&&c==="top",Ye=R==="visual"&&m&&c==="bottom";return jsxs(Fragment,{children:[jsxs("div",{className:"luthor-editor-header",children:[jsx(hn,{mode:R,onModeChange:ut,availableModes:r,isConverting:Ce}),ot&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--top",children:qe})]}),jsxs("div",{className:`luthor-editor${He?"":" luthor-editor--draggable-disabled"}`,"data-mode":R,children:[jsxs("div",{className:`luthor-editor-visual-shell${R==="visual"?"":" is-hidden"}${He?"":" luthor-editor-visual-shell--no-gutter"}`,"aria-hidden":R!=="visual",children:[He&&jsx("div",{className:"luthor-editor-visual-gutter","aria-hidden":"true"}),jsx(RichText,{placeholder:n,classNames:{container:"luthor-richtext-container luthor-preset-extensive__container",contentEditable:"luthor-content-editable luthor-preset-extensive__content",placeholder:"luthor-placeholder luthor-preset-extensive__placeholder"}})]}),R!=="visual"&&jsxs("div",{className:"luthor-source-panel",children:[ce&&ce.mode===R&&jsxs("div",{className:"luthor-source-error",children:[jsx("div",{className:"luthor-source-error-icon",children:"\u26A0\uFE0F"}),jsxs("div",{className:"luthor-source-error-message",children:[jsx("strong",{children:"Invalid JSON"}),jsx("p",{children:ce.error}),jsx("small",{children:"Fix the errors above and try switching modes again"})]})]}),R==="json"&&jsx(fn,{value:D.json,onChange:C=>ve(S=>({...S,json:C})),placeholder:o})]})]}),jsx(mn,{editor:g,commands:I,editorTheme:e?"dark":"light",disabled:R!=="visual"}),Ye&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--bottom",children:qe}),jsx(Wo,{isOpen:Oe.isOpen,onClose:()=>I.hideCommandPalette(),commands:Oe.commands}),jsx(on,{isOpen:re.isOpen,query:re.query,position:re.position,commands:re.commands,onClose:()=>I.closeSlashMenu?.(),onExecute:C=>{I.executeSlashCommand?.(C);}}),jsx(Zo,{isOpen:Ee.isOpen,query:Ee.query,position:Ee.position,suggestions:Ee.suggestions,onClose:()=>I.closeEmojiSuggestions?.(),onExecute:C=>{I.executeEmojiSuggestion?.(C);}})]})}var Yt=forwardRef(({className:e,onReady:t,initialTheme:n="light",onThemeChange:o,theme:l,defaultContent:r,showDefaultContent:i=true,placeholder:a=Kn,initialMode:d="visual",availableModes:c=["visual","json"],variantClassName:E,toolbarLayout:h,toolbarVisibility:b,toolbarPosition:m="top",toolbarAlignment:p="left",toolbarClassName:$,toolbarStyleVars:H,quoteClassName:B,quoteStyleVars:q,defaultSettings:W,editorThemeOverrides:v,isToolbarEnabled:se=true,fontFamilyOptions:ue,fontSizeOptions:Y,lineHeightOptions:g,minimumDefaultLineHeight:F=1.5,scaleByRatio:k=false,headingOptions:V,paragraphLabel:R,syncHeadingOptionsWithCommands:ee=true,slashCommandVisibility:D,shortcutConfig:ve,commandPaletteShortcutOnly:Ce=false,isDraggableBoxEnabled:ke,featureFlags:ce,syntaxHighlighting:we,codeHighlightProvider:Oe,loadCodeHighlightProvider:Pe,maxAutoDetectCodeLength:re,isCopyAllowed:je=true,languageOptions:Ee},Re)=>{let[ie,Ne]=useState(n),he=ie==="dark",fe=c.includes(d)?d:c[0]??"visual",O=()=>Ne(he?"light":"dark"),I=useMemo(()=>typeof a=="string"?{visual:a,json:Un}:{visual:a.visual??Kn,json:a.json??Un},[a]);useEffect(()=>{Ne(n);},[n]),useEffect(()=>{o?.(ie);},[ie,o]);let J=useMemo(()=>Zi(ue),[ue]),tt=useMemo(()=>el(Y),[Y]),He=useMemo(()=>tl(g),[g]),pe=useMemo(()=>ol(F),[F]),Je=we??"unset",Ie=typeof re=="number"?re.toString():"unset",Ae=useMemo(()=>nl(Ee),[Ee]),de=je?"copy-on":"copy-off",oe=useMemo(()=>typeof ke!="boolean"?ce:{...ce??{},draggableBlock:ke},[ce,ke]),Me=useMemo(()=>il(oe),[oe]),xe=useMemo(()=>Ft(oe),[oe]),le=`${J}::${tt}::${He}::${pe}::${k?"ratio-on":"ratio-off"}::${Je}::${Ie}::${de}::${Ae}::${Me}`,Be=useRef(ue),K=useRef(Y),ze=useRef(g),ut=useRef(F),qe=useRef(oe),ot=useRef(Ee),Ye=useRef(Oe),C=useRef(Pe),S=useRef(le);(S.current!==le||Ye.current!==Oe||C.current!==Pe)&&(S.current=le,Be.current=ue,K.current=Y,ze.current=g,ut.current=F,qe.current=oe,ot.current=Ee,Ye.current=Oe,C.current=Pe);let A=useRef(null);if(!A.current||A.current.key!==le){let me={fontFamilyOptions:Be.current,fontSizeOptions:K.current,lineHeightOptions:ze.current,minimumDefaultLineHeight:ut.current,scaleByRatio:k,...we!==void 0?{syntaxHighlighting:we}:{},...Ye.current!==void 0?{codeHighlightProvider:Ye.current}:{},...C.current!==void 0?{loadCodeHighlightProvider:C.current}:{},...re!==void 0?{maxAutoDetectCodeLength:re}:{},isCopyAllowed:je,...ot.current!==void 0?{languageOptions:ot.current}:{},...typeof ke=="boolean"?{isDraggableBoxEnabled:ke}:{},...qe.current?{featureFlags:qe.current}:{}};A.current={key:le,value:wt(me)};}let G=A.current.value,Z=useMemo(()=>{let me=mergeThemes(defaultLuthorTheme,l??{});return B?{...me,quote:`${me.quote??""} ${B}`.trim()}:me},[l,B]),Ge=useMemo(()=>yo(v),[v]),f=useMemo(()=>yo(q),[q]),y=useMemo(()=>rl(W),[W]),M=useMemo(()=>yo(y),[y]),U=useMemo(()=>{let me=y,vo=createEditorThemeStyleVars(v),Co=q,ko={"--luthor-default-line-height":pe};return !me&&!vo&&!Co?ko:{...me??{},...vo,...Co??{},...ko}},[pe,y,v,q,M,Ge,f]),[ae,ge]=useState(null);useImperativeHandle(Re,()=>ae,[ae]);let Qe=me=>{ge(me),i&&r===void 0?me.injectJSON(JSON.stringify(bo)):r&&me.injectJSON(Xi(r)),t?.(me);};return jsx("div",{className:`luthor-preset luthor-preset-extensive luthor-editor-wrapper ${E||""} ${e||""}`.trim(),"data-editor-theme":ie,style:U,children:jsx(Gi,{extensions:G,config:{theme:Z},children:jsx(pl,{isDark:he,toggleTheme:O,visualPlaceholder:I.visual,jsonPlaceholder:I.json,initialMode:fe,availableModes:c,onReady:Qe,toolbarLayout:h,toolbarVisibility:b,toolbarPosition:m,toolbarAlignment:p,toolbarClassName:$,toolbarStyleVars:H,isToolbarEnabled:se,headingOptions:V,paragraphLabel:R,syncHeadingOptionsWithCommands:ee,slashCommandVisibility:D,shortcutConfig:ve,commandPaletteShortcutOnly:Ce,featureFlags:xe})})})});Yt.displayName="ExtensiveEditor";var Vn=["undo","redo","heading","fontFamily","fontSize","lineHeight","textColor","textHighlight","bold","italic","underline","strikethrough","subscript","superscript","link","image","table","horizontalRule","iframeEmbed","youtubeEmbed","blockquote","code","codeBlock","bulletedList","numberedList","checkList","commandPalette","floatingToolbar","contextMenu","draggableBlock","customNode","sourceMode","themeToggle"],_n={id:"extensive",label:"Extensive",description:"All features enabled for power users.",extensions:[...po],components:{Editor:Yt},toolbar:[...Vn],config:a("extensive","Write anything..."),css:"extensive/styles.css"};function yl(e={}){return {..._n,extensions:[...wt({fontFamilyOptions:e.fontFamilyOptions,fontSizeOptions:e.fontSizeOptions,lineHeightOptions:e.lineHeightOptions,minimumDefaultLineHeight:e.minimumDefaultLineHeight,isCopyAllowed:e.isCopyAllowed,languageOptions:e.languageOptions})]}}export{rn as $,zo as A,Dn as Aa,Po as B,Yt as Ba,Ro as C,Vn as Ca,Tl as D,_n as Da,Ao as E,yl as Ea,Sl as F,Kt as G,Bo as H,Do as I,Ut as J,Ko as K,Uo as L,jo as M,Vo as N,_o as O,Zt as P,$o as Q,Jo as R,qo as S,Yo as T,Wo as U,Zo as V,on as W,L as X,to as Y,Et as Z,xt as _,Fe as a,ln as aa,vl as b,oo as ba,Ot as c,an as ca,Qt as d,mn as da,Lo as e,hn as ea,Io as f,fn as fa,wo as g,io as ga,Ht as h,fa as ha,Mt as i,Br as ia,zt as j,Dr as ja,Pt as k,Kr as ka,Rt as l,Cn as la,Oo as m,Ln as ma,ct as n,Ft as na,nt as o,In as oa,At as p,wt as pa,Bt as q,po as qa,Dt as r,On as ra,No as s,Nn as sa,Ho as t,Hn as ta,Wt as u,Mn as ua,dt as v,zn as va,rt as w,Pn as wa,Mo as x,Rn as xa,gt as y,An as ya,Xt as z,Bn as za};