@lyfie/luthor 2.2.0 → 2.3.1

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 (35) hide show
  1. package/README.md +228 -475
  2. package/dist/ExtensiveEditor-Cn84lsVT.d.ts +448 -0
  3. package/dist/index-BtdZVw3X.d.ts +17 -0
  4. package/dist/index-DFnca6tP.d.ts +30 -0
  5. package/dist/index.css +1 -1
  6. package/dist/index.d.ts +203 -53
  7. package/dist/index.js +3 -16
  8. package/dist/presets/chat-window/index.css +1 -0
  9. package/dist/presets/chat-window/index.d.ts +22 -0
  10. package/dist/presets/chat-window/index.js +3 -0
  11. package/dist/presets/email-compose/index.css +1 -0
  12. package/dist/presets/email-compose/index.d.ts +17 -0
  13. package/dist/presets/email-compose/index.js +3 -0
  14. package/dist/presets/extensive/index.css +1 -0
  15. package/dist/presets/extensive/index.d.ts +5 -0
  16. package/dist/presets/extensive/index.js +3 -0
  17. package/dist/presets/headless-editor/index.css +1 -0
  18. package/dist/presets/headless-editor/index.d.ts +13 -0
  19. package/dist/presets/headless-editor/index.js +1 -0
  20. package/dist/presets/md-text/index.css +1 -0
  21. package/dist/presets/md-text/index.d.ts +15 -0
  22. package/dist/presets/md-text/index.js +3 -0
  23. package/dist/presets/notes/index.css +1 -0
  24. package/dist/presets/notes/index.d.ts +21 -0
  25. package/dist/presets/notes/index.js +3 -0
  26. package/dist/presets/notion-like/index.css +1 -0
  27. package/dist/presets/notion-like/index.d.ts +17 -0
  28. package/dist/presets/notion-like/index.js +3 -0
  29. package/dist/presets/rich-text-box/index.css +1 -0
  30. package/dist/presets/rich-text-box/index.d.ts +17 -0
  31. package/dist/presets/rich-text-box/index.js +3 -0
  32. package/dist/presets/simple-text/index.css +1 -0
  33. package/dist/presets/simple-text/index.d.ts +15 -0
  34. package/dist/presets/simple-text/index.js +3 -0
  35. package/package.json +76 -20
package/dist/index.js CHANGED
@@ -1,16 +1,3 @@
1
- import {MarkdownExtension,ALL_MARKDOWN_TRANSFORMERS,ImageExtension,TableExtension,HTMLEmbedExtension,FloatingToolbarExtension,ContextMenuExtension,CommandPaletteExtension,DraggableBlockExtension,LinkExtension,createEditorSystem,boldExtension,italicExtension,underlineExtension,strikethroughExtension,horizontalRuleExtension,listExtension,historyExtension,blockFormatExtension,htmlExtension,codeExtension,codeFormatExtension,RichText}from'@lyfie/luthor-headless';import {AlignLeft,AlignCenter,AlignRight,Quote,Bold,Italic,Underline,Strikethrough,Code,Unlink,Link,List,ListOrdered,Code2,IndentIncrease,IndentDecrease,Minus,Table,Upload,Image,Type,FileCode,Eye,Pencil,Undo2,Redo2,Command,Sun,Moon,Search,ChevronDown,X}from'lucide-react';import so,{forwardRef,useState,useRef,useEffect,useMemo}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';function b(e,o){let r=`luthor-preset-${e}`;return {placeholder:o,classNames:{container:`luthor-preset ${r} ${r}__container`,contentEditable:`luthor-content-editable ${r}__content`,placeholder:`luthor-placeholder ${r}__placeholder`}}}var J={id:"blog",label:"Blog",description:"Long form publishing with media and quotes.",toolbar:["heading","bold","italic","link","image","blockquote","bulletedList","numberedList"],config:b("blog","Tell your story..."),css:"blog/styles.css"};var ee={id:"chat",label:"Chat",description:"Compact composer with mentions and quick formatting.",toolbar:["bold","italic","link","emoji","mention"],config:b("chat","Write a message..."),css:"chat/styles.css"};var te={id:"classic",label:"Classic",description:"Full featured WYSIWYG default.",toolbar:["undo","redo","bold","italic","underline","link","image","table","bulletedList","numberedList"],config:b("classic","Start writing..."),css:"classic/styles.css"};var oe={id:"cms",label:"CMS",description:"Structured content with validation and schema rules.",toolbar:["heading","bold","italic","link","image"],config:b("cms","Compose structured content..."),css:"cms/styles.css"};var re={id:"code",label:"Code",description:"Developer focused editing with code as a first class block.",toolbar:["code","codeBlock","copy","link"],config:b("code","Paste or write code..."),css:"code/styles.css"};var ne={id:"default",label:"Default",description:"Balanced general purpose editor preset.",toolbar:["heading","bold","italic","link","image","table"],config:b("default","Start writing..."),css:"default/styles.css"};var ie={id:"docs",label:"Docs",description:"Documentation focused with code and callouts.",toolbar:["heading","bold","italic","code","codeBlock","link"],config:b("docs","Write documentation..."),css:"docs/styles.css"};var le={id:"email",label:"Email",description:"Email safe markup with stricter rules.",toolbar:["bold","italic","link","button","table"],config:b("email","Write an email..."),css:"email/styles.css"};var U=Bold,A=Italic,O=Underline,$=Strikethrough,j=Code,we=Code2,R=Link,Q=Unlink,_=List,q=ListOrdered,Ce=Undo2,Ee=Redo2,Ie=Image,W=AlignLeft,N=AlignCenter,V=AlignRight,Le=Upload,Pe=Minus,ze=Table,Te=FileCode,Re=Eye,Ne=Pencil,Y=Command,Me=Type,Be=Quote,He=IndentIncrease,Ke=IndentDecrease,Se=Sun,Fe=Moon,De=Search,Ue=ChevronDown,Ae=X;function d({children:e,onClick:o,title:r,active:i,disabled:n,className:l,type:a="button"}){return jsx("button",{type:a,className:`luthor-toolbar-button${i?" active":""}${l?` ${l}`:""}`,onClick:o,title:r,disabled:n,children:e})}function de({children:e,onClick:o,variant:r="primary",type:i="button",className:n}){return jsx("button",{type:i,onClick:o,className:`${r==="primary"?"luthor-button-primary":"luthor-button-secondary"}${n?` ${n}`:""}`,children:e})}function Oe({value:e,onValueChange:o,options:r,placeholder:i="Select..."}){let[n,l]=useState(false),a=useRef(null);useEffect(()=>{function f(v){a.current&&!a.current.contains(v.target)&&l(false);}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);let s=r.find(f=>f.value===e);return jsxs("div",{className:"luthor-select",ref:a,children:[jsxs("button",{className:`luthor-select-trigger ${n?"open":""}`,onClick:()=>l(!n),type:"button",children:[jsx("span",{children:s?.label||i}),jsx(Ue,{size:14})]}),n&&jsx("div",{className:"luthor-select-dropdown",children:r.map(f=>jsx("button",{className:`luthor-select-option ${e===f.value?"selected":""}`,onClick:()=>{o(f.value),l(false);},type:"button",children:f.label},f.value))})]})}function ce({trigger:e,children:o,isOpen:r,onOpenChange:i}){let n=useRef(null);return useEffect(()=>{function l(a){n.current&&!n.current.contains(a.target)&&i(false);}return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[i]),jsxs("div",{className:"luthor-dropdown",ref:n,children:[jsx("div",{onClick:()=>i(!r),children:e}),r&&jsx("div",{className:"luthor-dropdown-content",children:o})]})}function $e({isOpen:e,onClose:o,title:r,children:i}){let n=useRef(null);return useEffect(()=>{function l(s){n.current&&!n.current.contains(s.target)&&o();}function a(s){s.key==="Escape"&&o();}return e&&(document.addEventListener("mousedown",l),document.addEventListener("keydown",a),document.body.style.overflow="hidden"),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",a),document.body.style.overflow="unset";}},[e,o]),e?jsx("div",{className:"luthor-dialog-overlay",children:jsxs("div",{className:"luthor-dialog",ref:n,children:[jsxs("div",{className:"luthor-dialog-header",children:[jsx("h3",{className:"luthor-dialog-title",children:r}),jsx("button",{className:"luthor-dialog-close",onClick:o,type:"button",children:jsx(Ae,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:i})]})}):null}function Qe(e){let{isVisible:o,selectionRect:r,commands:i,activeStates:n}=e;if(!o||!r)return null;let l={position:"absolute",top:r.y,left:r.positionFromRight?"auto":r.x,right:r.positionFromRight?10:"auto",zIndex:9999,pointerEvents:"auto"};return n?.imageSelected?jsxs("div",{className:"luthor-floating-toolbar",style:l,children:[jsx(d,{onClick:()=>i.setImageAlignment("left"),active:n.isImageAlignedLeft,title:"Align Left",children:jsx(W,{size:14})}),jsx(d,{onClick:()=>i.setImageAlignment("center"),active:n.isImageAlignedCenter,title:"Align Center",children:jsx(N,{size:14})}),jsx(d,{onClick:()=>i.setImageAlignment("right"),active:n.isImageAlignedRight,title:"Align Right",children:jsx(V,{size:14})}),jsx("div",{className:"luthor-floating-toolbar-separator"}),jsx(d,{onClick:()=>i.setImageCaption(prompt("Enter caption:")||""),title:"Edit Caption",children:jsx(Be,{size:14})})]}):jsxs("div",{className:"luthor-floating-toolbar",style:l,children:[jsx(d,{onClick:()=>i.toggleBold(),active:n.bold,title:"Bold",children:jsx(U,{size:14})}),jsx(d,{onClick:()=>i.toggleItalic(),active:n.italic,title:"Italic",children:jsx(A,{size:14})}),jsx(d,{onClick:()=>i.toggleUnderline(),active:n.underline,title:"Underline",children:jsx(O,{size:14})}),jsx(d,{onClick:()=>i.toggleStrikethrough(),active:n.strikethrough,title:"Strikethrough",children:jsx($,{size:14})}),jsx("div",{className:"luthor-floating-toolbar-separator"}),jsx(d,{onClick:()=>i.formatText("code"),active:n.code,title:"Inline Code",children:jsx(j,{size:14})}),jsx(d,{onClick:()=>n.isLink?i.removeLink():i.insertLink(),active:n.isLink,title:n.isLink?"Remove Link":"Insert Link",children:n.isLink?jsx(Q,{size:14}):jsx(R,{size:14})}),jsx("div",{className:"luthor-floating-toolbar-separator"}),jsx(d,{onClick:()=>i.toggleUnorderedList(),active:n.unorderedList,title:"Bullet List",children:jsx(_,{size:14})}),jsx(d,{onClick:()=>i.toggleOrderedList(),active:n.orderedList,title:"Numbered List",children:jsx(q,{size:14})})]})}var B=new MarkdownExtension;B.config={...B.config,customTransformers:ALL_MARKDOWN_TRANSFORMERS};var H=new ImageExtension;H.config={...H.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var ue=new TableExtension;ue.config={...ue.config,enableContextMenu:true,markdownExtension:B};var pe=new HTMLEmbedExtension;pe.config={...pe.config,markdownExtension:B};var G={commands:{},activeStates:{}};function _e(e,o){G.commands=e,G.activeStates=o;}var me=new FloatingToolbarExtension;me.config={...me.config,render:e=>jsx(Qe,{...e}),getCommands:()=>G.commands,getActiveStates:()=>G.activeStates};var he=new ContextMenuExtension;he.config={...he.config,preventDefault:true};var to=new CommandPaletteExtension,ge=new DraggableBlockExtension;ge.config={...ge.config,showMoveButtons:true,showUpButton:true,showDownButton:true,buttonStackPosition:"left"};var be=new LinkExtension;be.config={...be.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var z=[boldExtension,italicExtension,underlineExtension,strikethroughExtension,be,horizontalRuleExtension,ue,listExtension,historyExtension,H,blockFormatExtension,htmlExtension,B,codeExtension,codeFormatExtension,pe,me,he,to,ge];function qe(){return [{id:"format.bold",label:"Toggle Bold",description:"Make text bold or remove bold formatting",category:"Format",action:e=>e.toggleBold(),shortcuts:[{key:"b",ctrlKey:true}],keywords:["bold","strong","format"]},{id:"format.italic",label:"Toggle Italic",description:"Make text italic or remove italic formatting",category:"Format",action:e=>e.toggleItalic(),shortcuts:[{key:"i",ctrlKey:true}],keywords:["italic","emphasis","format"]},{id:"format.underline",label:"Toggle Underline",description:"Add or remove underline formatting",category:"Format",action:e=>e.toggleUnderline(),shortcuts:[{key:"u",ctrlKey:true}],keywords:["underline","format"]},{id:"format.strikethrough",label:"Toggle Strikethrough",description:"Add or remove strikethrough formatting",category:"Format",action:e=>e.toggleStrikethrough(),keywords:["strikethrough","format"]},{id:"format.code",label:"Toggle Inline Code",description:"Format text as inline code",category:"Format",action:e=>e.formatText("code"),shortcuts:[{key:"`",ctrlKey:true}],keywords:["code","inline","format"]},{id:"block.heading1",label:"Heading 1",description:"Convert to large heading",category:"Block",action:e=>e.toggleHeading("h1"),shortcuts:[{key:"1",ctrlKey:true,altKey:true}],keywords:["heading","h1"]},{id:"block.heading2",label:"Heading 2",description:"Convert to medium heading",category:"Block",action:e=>e.toggleHeading("h2"),shortcuts:[{key:"2",ctrlKey:true,altKey:true}],keywords:["heading","h2"]},{id:"block.heading3",label:"Heading 3",description:"Convert to small heading",category:"Block",action:e=>e.toggleHeading("h3"),shortcuts:[{key:"3",ctrlKey:true,altKey:true}],keywords:["heading","h3"]},{id:"block.paragraph",label:"Paragraph",description:"Convert to paragraph",category:"Block",action:e=>e.toggleParagraph(),shortcuts:[{key:"0",ctrlKey:true,altKey:true}],keywords:["paragraph","text"]},{id:"block.quote",label:"Quote",description:"Convert to blockquote",category:"Block",action:e=>e.toggleQuote(),keywords:["quote","blockquote"]},{id:"block.codeblock",label:"Code Block",description:"Convert to code block",category:"Block",action:e=>e.toggleCodeBlock(),shortcuts:[{key:"`",ctrlKey:true,shiftKey:true}],keywords:["code","block"]},{id:"list.bullet",label:"Bullet List",description:"Create or toggle bullet list",category:"List",action:e=>e.toggleUnorderedList(),shortcuts:[{key:"l",ctrlKey:true,shiftKey:true}],keywords:["list","bullet"]},{id:"list.numbered",label:"Numbered List",description:"Create or toggle numbered list",category:"List",action:e=>e.toggleOrderedList(),shortcuts:[{key:"l",ctrlKey:true,altKey:true}],keywords:["list","numbered"]},{id:"link.insert",label:"Insert Link",description:"Insert or edit a link",category:"Insert",action:e=>e.insertLink(),shortcuts:[{key:"k",ctrlKey:true}],keywords:["link","url"]},{id:"link.remove",label:"Remove Link",description:"Remove link formatting",category:"Format",action:e=>e.removeLink(),shortcuts:[{key:"k",ctrlKey:true,shiftKey:true}],keywords:["unlink","remove","link"]},{id:"insert.horizontal-rule",label:"Insert Horizontal Rule",description:"Insert a horizontal line separator",category:"Insert",action:e=>e.insertHorizontalRule(),keywords:["horizontal","rule"]},{id:"insert.image",label:"Insert Image",description:"Insert an image from URL",category:"Insert",action:e=>{let o=prompt("Enter image URL:");if(o){let r=prompt("Enter alt text:")||"";e.insertImage({src:o,alt:r});}},keywords:["image","photo"]},{id:"insert.table",label:"Insert Table",description:"Insert a 3x3 table",category:"Insert",action:e=>e.insertTable({rows:3,columns:3,includeHeaders:true}),keywords:["table","grid"]},{id:"insert.html-embed",label:"Insert HTML Embed",description:"Insert a custom HTML block",category:"Insert",action:e=>e.insertHTMLEmbed(),keywords:["html","embed"]},{id:"edit.undo",label:"Undo",description:"Undo the last action",category:"Edit",action:e=>e.undo(),shortcuts:[{key:"z",ctrlKey:true}],keywords:["undo","revert"]},{id:"edit.redo",label:"Redo",description:"Redo the last undone action",category:"Edit",action:e=>e.redo(),shortcuts:[{key:"y",ctrlKey:true},{key:"z",ctrlKey:true,shiftKey:true}],keywords:["redo","repeat"]},{id:"palette.show",label:"Show Command Palette",description:"Open the command palette",category:"View",action:e=>e.showCommandPalette(),shortcuts:[{key:"p",ctrlKey:true,shiftKey:true}],keywords:["command","palette"]}]}function We(e){return qe().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]?ro(o.shortcuts[0]):void 0}))}function ro(e){let o=[];return e.ctrlKey&&o.push("Ctrl"),e.metaKey&&o.push("Cmd"),e.altKey&&o.push("Alt"),e.shiftKey&&o.push("Shift"),o.push(e.key.toUpperCase()),o.join("+")}function Ve(e,o=document.body){let r=qe(),i=n=>{for(let l of r)if(l.shortcuts){for(let a of l.shortcuts)if(n.key.toLowerCase()===a.key.toLowerCase()&&!!n.ctrlKey==!!a.ctrlKey&&!!n.metaKey==!!a.metaKey&&!!n.shiftKey==!!a.shiftKey&&!!n.altKey==!!a.altKey){a.preventDefault!==false&&n.preventDefault(),(!l.condition||l.condition(e))&&l.action(e);return}}};return o.addEventListener("keydown",i),()=>o.removeEventListener("keydown",i)}function lo(e,o){let r=useRef(null),i=H.config;return {handlers:useMemo(()=>({insertFromUrl:()=>{let l=prompt("Enter image URL:");if(!l)return;let a=prompt("Enter alt text:")||"",s=prompt("Enter caption (optional):")||void 0;e.insertImage({src:l,alt:a,caption:s});},insertFromFile:()=>r.current?.click(),handleUpload:async l=>{let a=l.target.files?.[0];if(!a)return;let s;if(i.uploadHandler)try{s=await i.uploadHandler(a);}catch{alert("Failed to upload image");return}else s=URL.createObjectURL(a);e.insertImage({src:s,alt:a.name,file:a}),l.target.value="";},setAlignment:l=>{e.setImageAlignment(l);},setCaption:()=>{let l=prompt("Enter caption:")||"";e.setImageCaption(l);}}),[e,i]),fileInputRef:r}}function Ge({commands:e,hasExtension:o,activeStates:r,isDark:i,toggleTheme:n,onCommandPaletteOpen:l,editor:a}){let{handlers:s,fileInputRef:f}=lo(e),[v,y]=useState(false),[p,h]=useState(false),[g,w]=useState(false),[L,P]=useState({rows:3,columns:3,includeHeaders:false}),D=[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"},{value:"h5",label:"Heading 5"},{value:"h6",label:"Heading 6"},{value:"quote",label:"Quote"}],ye=r.isH1?"h1":r.isH2?"h2":r.isH3?"h3":r.isH4?"h4":r.isH5?"h5":r.isH6?"h6":r.isQuote?"quote":"p",m=c=>{c==="p"?e.toggleParagraph():c.startsWith("h")?e.toggleHeading(c):c==="quote"&&e.toggleQuote();};return jsxs(Fragment,{children:[jsxs("div",{className:"luthor-toolbar",children:[jsxs("div",{className:"luthor-toolbar-section",children:[jsx(d,{onClick:()=>e.toggleBold(),active:r.bold,title:"Bold (Ctrl+B)",children:jsx(U,{size:16})}),jsx(d,{onClick:()=>e.toggleItalic(),active:r.italic,title:"Italic (Ctrl+I)",children:jsx(A,{size:16})}),jsx(d,{onClick:()=>e.toggleUnderline(),active:r.underline,title:"Underline (Ctrl+U)",children:jsx(O,{size:16})}),jsx(d,{onClick:()=>e.toggleStrikethrough(),active:r.strikethrough,title:"Strikethrough",children:jsx($,{size:16})}),jsx(d,{onClick:()=>e.formatText("code"),active:r.code,title:"Inline Code",children:jsx(j,{size:16})}),jsx(d,{onClick:()=>r.isLink?e.removeLink():e.insertLink(),active:r.isLink,title:r.isLink?"Remove Link":"Insert Link",children:r.isLink?jsx(Q,{size:16}):jsx(R,{size:16})})]}),o("blockFormat")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(Oe,{value:ye,onValueChange:m,options:D,placeholder:"Format"}),o("code")&&jsx(d,{onClick:()=>e.toggleCodeBlock(),active:r.isInCodeBlock,title:"Code Block",children:jsx(we,{size:16})})]}),o("list")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(d,{onClick:()=>e.toggleUnorderedList(),active:r.unorderedList,title:"Bullet List",children:jsx(_,{size:16})}),jsx(d,{onClick:()=>e.toggleOrderedList(),active:r.orderedList,title:"Numbered List",children:jsx(q,{size:16})}),(r.unorderedList||r.orderedList)&&jsxs(Fragment,{children:[jsx(d,{onClick:()=>e.indentList(),title:"Indent List",children:jsx(He,{size:14})}),jsx(d,{onClick:()=>e.outdentList(),title:"Outdent List",children:jsx(Ke,{size:14})})]})]}),o("horizontalRule")&&jsx("div",{className:"luthor-toolbar-section",children:jsx(d,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(Pe,{size:16})})}),o("table")&&jsx("div",{className:"luthor-toolbar-section",children:jsx(d,{onClick:()=>w(true),title:"Insert Table",children:jsx(ze,{size:16})})}),o("image")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsxs(ce,{trigger:jsx("button",{className:`luthor-toolbar-button ${r.imageSelected?"active":""}`,title:"Insert Image",children:jsx(Ie,{size:16})}),isOpen:v,onOpenChange:y,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{s.insertFromUrl(),y(false);},children:[jsx(R,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{s.insertFromFile(),y(false);},children:[jsx(Le,{size:16}),jsx("span",{children:"Upload File"})]})]}),r.imageSelected&&jsxs(ce,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(N,{size:16})}),isOpen:p,onOpenChange:h,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{s.setAlignment("left"),h(false);},children:[jsx(W,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{s.setAlignment("center"),h(false);},children:[jsx(N,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{s.setAlignment("right"),h(false);},children:[jsx(V,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{s.setCaption(),h(false);},children:[jsx(Me,{size:16}),jsx("span",{children:"Set Caption"})]})]}),jsx("input",{ref:f,type:"file",accept:"image/*",onChange:s.handleUpload,className:"luthor-file-input"})]}),o("htmlEmbed")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(d,{onClick:()=>e.insertHTMLEmbed(),active:r.isHTMLEmbedSelected,title:"Insert HTML Embed",children:jsx(Te,{size:16})}),r.isHTMLEmbedSelected&&jsx(d,{onClick:()=>e.toggleHTMLPreview(),title:"Toggle Preview/Edit",children:r.isHTMLPreviewMode?jsx(Re,{size:16}):jsx(Ne,{size:16})})]}),o("history")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(d,{onClick:()=>e.undo(),disabled:!r.canUndo,title:"Undo (Ctrl+Z)",children:jsx(Ce,{size:16})}),jsx(d,{onClick:()=>e.redo(),disabled:!r.canRedo,title:"Redo (Ctrl+Y)",children:jsx(Ee,{size:16})})]}),jsx("div",{className:"luthor-toolbar-section",children:jsx(d,{onClick:l,title:"Command Palette (Ctrl+Shift+P)",children:jsx(Y,{size:16})})}),jsx("div",{className:"luthor-toolbar-section",children:jsx(d,{onClick:n,title:i?"Light Mode":"Dark Mode",children:i?jsx(Se,{size:16}):jsx(Fe,{size:16})})})]}),jsx($e,{isOpen:g,onClose:()=>w(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:L.rows,onChange:c=>P(k=>({...k,rows:parseInt(c.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:L.columns,onChange:c=>P(k=>({...k,columns:parseInt(c.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:L.includeHeaders||false,onChange:c=>P(k=>({...k,includeHeaders:c.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(de,{variant:"secondary",onClick:()=>w(false),children:"Cancel"}),jsx(de,{variant:"primary",onClick:()=>{e.insertTable(L),w(false);},children:"Insert Table"})]})]})})]})}function Ze({isOpen:e,onClose:o,commands:r}){let[i,n]=useState(""),[l,a]=useState(0),s=useRef(null),f=r.filter(p=>`${p.label} ${p.description||""} ${p.keywords?.join(" ")||""}`.toLowerCase().includes(i.toLowerCase())),v=f.reduce((p,h)=>{let g=h.category||"Other";return p[g]||(p[g]=[]),p[g].push(h),p},{}),y=f;return useEffect(()=>{a(0);},[i]),useEffect(()=>{e&&s.current&&(s.current.focus(),n(""),a(0));},[e]),useEffect(()=>{let p=h=>{if(e)switch(h.key){case "Escape":h.preventDefault(),o();break;case "ArrowDown":h.preventDefault(),a(g=>Math.min(g+1,y.length-1));break;case "ArrowUp":h.preventDefault(),a(g=>Math.max(g-1,0));break;case "Enter":h.preventDefault(),y[l]&&(y[l].action(),o());break}};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[e,l,y,o]),e?jsx("div",{className:"luthor-command-palette-overlay",onClick:o,children:jsxs("div",{className:"luthor-command-palette",onClick:p=>p.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(De,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:s,type:"text",placeholder:"Type a command or search...",value:i,onChange:p=>n(p.target.value),className:"luthor-command-palette-input"}),jsx("kbd",{className:"luthor-command-palette-kbd",children:"ESC"})]}),jsx("div",{className:"luthor-command-palette-list",children:Object.keys(v).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(v).map(([p,h])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:p}),h.map(g=>{let w=y.indexOf(g);return jsxs("div",{className:`luthor-command-palette-item ${w===l?"selected":""}`,onClick:()=>{g.action(),o();},onMouseEnter:()=>a(w),children:[jsxs("div",{className:"luthor-command-palette-item-content",children:[jsx("div",{className:"luthor-command-palette-item-title",children:g.label}),g.description&&jsx("div",{className:"luthor-command-palette-item-description",children:g.description})]}),g.shortcut&&jsx("kbd",{className:"luthor-command-palette-item-shortcut",children:g.shortcut})]},g.id)})]},p))}),jsx("div",{className:"luthor-command-palette-footer",children:jsxs("span",{className:"luthor-command-palette-hint",children:[jsx(Y,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var{Provider:ho,useEditor:go}=createEditorSystem();function bo({mode:e,onModeChange:o}){return jsxs("div",{className:"luthor-mode-tabs",children:[jsx("button",{className:`luthor-mode-tab ${e==="visual"?"active":""}`,onClick:()=>o("visual"),children:"Visual"}),jsx("button",{className:`luthor-mode-tab ${e==="html"?"active":""}`,onClick:()=>o("html"),children:"HTML"}),jsx("button",{className:`luthor-mode-tab ${e==="markdown"?"active":""}`,onClick:()=>o("markdown"),children:"Markdown"})]})}function et({value:e,onChange:o,placeholder:r}){return jsx("textarea",{className:"luthor-source-view",value:e,onChange:i=>o(i.target.value),placeholder:r,spellCheck:false})}function xo({className:e,isDark:o,toggleTheme:r,onReady:i}){let{commands:n,hasExtension:l,activeStates:a,lexical:s,extensions:f}=go(),[v,y]=useState("visual"),[p,h]=useState({html:"",markdown:""}),[g,w]=useState({isOpen:false,commands:[]}),L=useRef(n),P=useRef(false);useEffect(()=>{L.current=n;},[n]),useEffect(()=>{_e(n,a);},[n,a]);let D=useMemo(()=>({injectMarkdown:m=>{setTimeout(()=>{s&&s.update(()=>{L.current.importFromMarkdown(m,{immediate:true,preventFocus:true});});},100);},injectHTML:m=>{setTimeout(()=>{s&&s.update(()=>{L.current.importFromHTML(m,{preventFocus:true});});},100);},getMarkdown:()=>L.current.exportToMarkdown(),getHTML:()=>L.current.exportToHTML()}),[s]);return useEffect(()=>{if(!s||!n)return;let m=We(n);m.forEach(k=>n.registerCommand(k));let c=Ve(n,document.body);return P.current||(P.current=true,i?.(D)),()=>{c(),m.forEach(k=>n.unregisterCommand(k.id));}},[s,n,D,i]),useEffect(()=>{let m=f.find(c=>c.name==="commandPalette");if(!(!m||!m.subscribe))return m.subscribe((c,k)=>{w({isOpen:c,commands:k});})},[f]),jsxs(Fragment,{children:[jsxs("div",{className:"luthor-editor-header",children:[jsx(bo,{mode:v,onModeChange:async m=>{if(v==="markdown"&&m!=="markdown"&&l("markdown")&&(await n.importFromMarkdown(p.markdown,{immediate:true}),await new Promise(c=>setTimeout(c,50))),v==="html"&&m!=="html"&&l("html")&&(await n.importFromHTML(p.html),await new Promise(c=>setTimeout(c,50))),m==="markdown"&&v!=="markdown"&&l("markdown")){await new Promise(k=>setTimeout(k,50));let c=n.exportToMarkdown();h(k=>({...k,markdown:c}));}if(m==="html"&&v!=="html"&&l("html")){await new Promise(k=>setTimeout(k,50));let c=n.exportToHTML();h(k=>({...k,html:c}));}y(m),m==="visual"&&setTimeout(()=>s?.focus(),100);}}),v==="visual"&&jsx(Ge,{commands:n,hasExtension:m=>l(m),activeStates:a,isDark:o,toggleTheme:r,onCommandPaletteOpen:()=>n.showCommandPalette(),editor:s})]}),jsxs("div",{className:"luthor-editor","data-mode":v,children:[v==="visual"&&jsx(RichText,{placeholder:"Write anything...",classNames:{container:"luthor-richtext-container luthor-preset-extensive__container",contentEditable:"luthor-content-editable luthor-preset-extensive__content",placeholder:"luthor-placeholder luthor-preset-extensive__placeholder"}}),v!=="visual"&&jsxs("div",{className:"luthor-source-panel",children:[v==="html"&&jsx(et,{value:p.html,onChange:m=>h(c=>({...c,html:m})),placeholder:"Enter HTML content..."}),v==="markdown"&&jsx(et,{value:p.markdown,onChange:m=>h(c=>({...c,markdown:m})),placeholder:"Enter Markdown content..."})]})]}),jsx(Ze,{isOpen:g.isOpen,onClose:()=>n.hideCommandPalette(),commands:g.commands})]})}var F=forwardRef(({className:e,onReady:o,initialTheme:r="light",defaultContent:i,showDefaultContent:n=true},l)=>{let[a,s]=useState(r),f=a==="dark",v=()=>s(f?"light":"dark"),[y,p]=useState(null);so.useImperativeHandle(l,()=>y,[y]);let h=`# (Default Content) Welcome to Luthor Editor
2
-
3
- **Build amazing React-based rich text editors with ease**
4
-
5
- Luthor is a modern, type-safe React framework built on top of Meta's Lexical that makes creating powerful text editors simple and enjoyable.
6
-
7
- ## \u2728 Quick Start
8
-
9
- - \u{1F680} Lightning Fast - Optimized performance with minimal bundle size
10
- - \u{1F6E1}\uFE0F Type-Safe - Full TypeScript support with auto-completion
11
- - \u{1F9E9} Extensible - 25+ built-in extensions for common features
12
- - \u{1F3A8} Customizable - Framework-agnostic styling with CSS custom properties
13
-
14
- ## \u{1F4DD} Try It Out
15
-
16
- Start typing or use the toolbar above to format your text. Press \`Cmd+K\` (Mac) or \`Ctrl+K\` (Windows/Linux) to open the command palette.`,g=w=>{p(w),n&&i===void 0?w.injectMarkdown(h):i&&w.injectMarkdown(i),o?.(w);};return jsx("div",{className:`luthor-preset luthor-preset-extensive luthor-editor-wrapper ${e||""}`,"data-editor-theme":a,children:jsx(ho,{extensions:z,children:jsx(xo,{className:e,isDark:f,toggleTheme:v,onReady:g})})})});F.displayName="ExtensiveEditor";var fe={id:"extensive",label:"Extensive",description:"All features enabled for power users.",extensions:[...z],components:{Editor:F},toolbar:["undo","redo","heading","bold","italic","underline","strikethrough","link","image","table","blockquote","code","codeBlock","bulletedList","numberedList"],config:b("extensive","Write anything..."),css:"extensive/styles.css"};var ve={id:"markdown",label:"Markdown",description:"Markdown first editing with predictable output.",toolbar:["bold","italic","link","code","codeBlock"],config:b("markdown","Write in markdown..."),css:"markdown/styles.css"};var ke={id:"minimal",label:"Minimal",description:"Lightweight editor for short text and embeds.",toolbar:["bold","italic","link"],config:b("minimal","Write something..."),css:"minimal/styles.css"};var pn={minimal:ke,classic:te,docs:ie,blog:J,cms:oe,chat:ee,email:le,markdown:ve,code:re,default:ne,extensive:fe};export{F as ExtensiveEditor,J as blogPreset,ee as chatPreset,te as classicPreset,oe as cmsPreset,re as codePreset,b as createPresetEditorConfig,ne as defaultPreset,ie as docsPreset,le as emailPreset,z as extensiveExtensions,fe as extensivePreset,ve as markdownPreset,ke as minimalPreset,pn as presetRegistry};
1
+ 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,richTextExtension,jsonbToMarkdown,markdownToJSONB}from'@lyfie/luthor-headless';import*as luthorHeadless from'@lyfie/luthor-headless';export{luthorHeadless as headless };export{CodeIntelligenceExtension,codeIntelligenceExtension}from'@lyfie/luthor-headless';import zi,{forwardRef,useState,useMemo,useEffect,useRef,useImperativeHandle,createElement,useLayoutEffect,useCallback}from'react';import {AlignLeft,AlignCenter,AlignRight,Bold,Italic,Underline,Strikethrough,Code,Quote,Unlink,Link,List,ListOrdered,ListChecks,Search,Command,Sun,Moon,Redo2,Undo2,Image,FileCode,Smile,Upload,Type,Table,Minus,IndentDecrease,IndentIncrease,Code2,AlignJustify,Superscript,Subscript,X,ChevronDown,Highlighter,Palette,Eye,Pencil}from'lucide-react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {createPortal}from'react-dom';var Le=["h1","h2","h3","h4","h5","h6"],Qa={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"]}]},zt={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 bn(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 yn(e,t){return bn(e.target)?Go(t):false}function Go(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 Yo(e){return typeof e.setCodeLanguage=="function"&&typeof e.autoDetectCodeLanguage=="function"}function vn(e){return typeof e.toggleSubscript=="function"}function Cn(e){return typeof e.toggleSuperscript=="function"}function En(e){return typeof e.insertIframeEmbed=="function"}function xn(e){return typeof e.insertYouTubeEmbed=="function"}function kn(e){return typeof e.insertEmoji=="function"}function Tn(e){return e.slice(1)}function Sn(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 Ln(e){if(!e||e.length===0)return [...Le];let t=new Set,r=[];for(let o of e)!Le.includes(o)||t.has(o)||(t.add(o),r.push(o));return r.length>0?r:[...Le]}function fo(e,t){return Nn(po(t),t?.shortcutConfig).filter(o=>!o.condition||o.condition(e))}function j(e,t){return typeof e[t]=="function"}function Mt(e){if(!e||e.length===0)return new Set;let t=e.map(r=>r.trim()).filter(r=>r.length>0);return new Set(t)}function wn(e){if(!e)return {allowlist:new Set,denylist:new Set};if(Array.isArray(e)){let r=[];for(let o of e)for(let[l,n]of Object.entries(o))n&&r.push(l);return {allowlist:Mt(r),denylist:new Set}}let t=e;return {allowlist:Mt(t.allowlist),denylist:Mt(t.denylist)}}function Wo(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 Fn(e){if(e===false||e===null)return [];let t=Array.isArray(e)?e:[e],r=[];for(let o of t){let l=Wo(o);l&&r.push(l);}return r}function In(e){return [e.key.toLowerCase(),e.ctrlKey?"ctrl":"",e.metaKey?"meta":"",e.shiftKey?"shift":"",e.altKey?"alt":""].join(":")}function Nn(e,t){if(!t)return [...e];let r=Mt(t.disabledCommandIds),o=t.bindings,l=t.preventNativeConflicts!==false,n=t.preventCollisions!==false,i=new Set;return e.filter(u=>!r.has(u.id)).map(u=>{let d=u.shortcuts?[...u.shortcuts]:void 0;if(!!o&&Object.prototype.hasOwnProperty.call(o,u.id)&&o){let c=o[u.id],p=c===void 0?[]:Fn(c);d=p.length>0?p:void 0;}if(d&&d.length>0){let c=[];for(let p of d){let m=Wo(p);if(!m||l&&Go(m))continue;let h=In(m);n&&i.has(h)||(i.add(h),c.push(m));}d=c.length>0?c:void 0;}return {...u,shortcuts:d}})}function po(e){let t=e?.isFeatureEnabled??(()=>true),r=Ln(e?.headingOptions),o=e?.paragraphLabel?.trim()||"Paragraph",l=r.map(n=>{let i=Tn(n);return {id:`block.heading${i}`,label:`Heading ${i}`,description:Sn(n),category:"Block",action:a=>a.toggleHeading?.(n),shortcuts:[{key:i,ctrlKey:true,altKey:true}],keywords:["heading",n],condition:a=>t("blockFormat")&&j(a,"toggleHeading")}});return [{id:"format.bold",label:"Toggle Bold",description:"Make text bold or remove bold formatting",category:"Format",action:n=>n.toggleBold?.(),shortcuts:[{key:"b",ctrlKey:true}],keywords:["bold","strong","format"],condition:n=>t("bold")&&j(n,"toggleBold")},{id:"format.italic",label:"Toggle Italic",description:"Make text italic or remove italic formatting",category:"Format",action:n=>n.toggleItalic?.(),shortcuts:[{key:"i",ctrlKey:true}],keywords:["italic","emphasis","format"],condition:n=>t("italic")&&j(n,"toggleItalic")},{id:"format.underline",label:"Toggle Underline",description:"Add or remove underline formatting",category:"Format",action:n=>n.toggleUnderline?.(),shortcuts:[{key:"u",ctrlKey:true}],keywords:["underline","format"],condition:n=>t("underline")&&j(n,"toggleUnderline")},{id:"format.strikethrough",label:"Toggle Strikethrough",description:"Add or remove strikethrough formatting",category:"Format",action:n=>n.toggleStrikethrough?.(),keywords:["strikethrough","format"],condition:n=>t("strikethrough")&&j(n,"toggleStrikethrough")},{id:"format.subscript",label:"Toggle Subscript",description:"Format text as subscript",category:"Format",action:n=>n.toggleSubscript?.(),keywords:["subscript","format"],condition:n=>t("subscript")&&vn(n)},{id:"format.superscript",label:"Toggle Superscript",description:"Format text as superscript",category:"Format",action:n=>n.toggleSuperscript?.(),keywords:["superscript","format"],condition:n=>t("superscript")&&Cn(n)},{id:"format.code",label:"Toggle Inline Code",description:"Format text as inline code",category:"Format",action:n=>n.formatText?.("code"),shortcuts:[{key:"`",ctrlKey:true}],keywords:["code","inline","format"],condition:n=>t("codeFormat")&&j(n,"formatText")},{id:"block.paragraph",label:o,description:"Convert to paragraph",category:"Block",action:n=>n.toggleParagraph?.(),shortcuts:[{key:"0",ctrlKey:true,altKey:true}],keywords:["paragraph","text"],condition:n=>t("blockFormat")&&j(n,"toggleParagraph")},...l,{id:"block.quote",label:"Quote",description:"Convert to blockquote",category:"Block",action:n=>n.toggleQuote?.(),keywords:["quote","blockquote"],condition:n=>t("blockFormat")&&j(n,"toggleQuote")},{id:"block.align-left",label:"Align Left",description:"Align selected blocks to the left",category:"Block",action:n=>n.setTextAlignment?.("left"),keywords:["align","left","text"],condition:n=>t("blockFormat")&&j(n,"setTextAlignment")},{id:"block.align-center",label:"Align Center",description:"Center-align selected blocks",category:"Block",action:n=>n.setTextAlignment?.("center"),keywords:["align","center","text"],condition:n=>t("blockFormat")&&j(n,"setTextAlignment")},{id:"block.align-right",label:"Align Right",description:"Align selected blocks to the right",category:"Block",action:n=>n.setTextAlignment?.("right"),keywords:["align","right","text"],condition:n=>t("blockFormat")&&j(n,"setTextAlignment")},{id:"block.align-justify",label:"Justify",description:"Justify selected blocks",category:"Block",action:n=>n.setTextAlignment?.("justify"),keywords:["align","justify","text"],condition:n=>t("blockFormat")&&j(n,"setTextAlignment")},{id:"block.codeblock",label:"Code Block",description:"Convert to code block",category:"Block",action:n=>n.toggleCodeBlock?.(),shortcuts:[{key:"`",ctrlKey:true,shiftKey:true}],keywords:["code","block"],condition:n=>t("code")&&j(n,"toggleCodeBlock")},{id:"block.code-language",label:"Set Code Language",description:"Set language for selected code block",category:"Block",action:n=>{if(!n.setCodeLanguage)return;let i=prompt("Code language (e.g. ts, css, python):")?.trim();i&&n.setCodeLanguage(i);},keywords:["code","language","syntax"],condition:n=>t("codeIntelligence")&&Yo(n)},{id:"block.code-language.auto",label:"Auto-Detect Code Language",description:"Detect language from selected code block",category:"Block",action:n=>{n.autoDetectCodeLanguage?.();},keywords:["code","language","auto","detect"],condition:n=>t("codeIntelligence")&&Yo(n)},{id:"list.bullet",label:"Bullet List",description:"Create or toggle bullet list",category:"List",action:n=>n.toggleUnorderedList?.(),shortcuts:[{key:"l",ctrlKey:true,shiftKey:true}],keywords:["list","bullet"],condition:n=>t("list")&&j(n,"toggleUnorderedList")},{id:"list.numbered",label:"Numbered List",description:"Create or toggle numbered list",category:"List",action:n=>n.toggleOrderedList?.(),shortcuts:[{key:"l",ctrlKey:true,altKey:true}],keywords:["list","numbered"],condition:n=>t("list")&&j(n,"toggleOrderedList")},{id:"list.check",label:"Checklist",description:"Create or toggle checklist",category:"List",action:n=>n.toggleCheckList?.(),shortcuts:[{key:"x",ctrlKey:true,shiftKey:true}],keywords:["list","check","todo","task"],condition:n=>t("list")&&j(n,"toggleCheckList")},{id:"link.insert",label:"Insert Link",description:"Insert or edit a link",category:"Insert",action:n=>n.insertLink?.(),shortcuts:[{key:"k",ctrlKey:true}],keywords:["link","url"],condition:n=>t("link")&&j(n,"insertLink")},{id:"link.remove",label:"Remove Link",description:"Remove link formatting",category:"Format",action:n=>n.removeLink?.(),shortcuts:[{key:"k",ctrlKey:true,shiftKey:true}],keywords:["unlink","remove","link"],condition:n=>t("link")&&j(n,"removeLink")},{id:"insert.horizontal-rule",label:"Insert Horizontal Rule",description:"Insert a horizontal line separator",category:"Insert",action:n=>n.insertHorizontalRule?.(),keywords:["horizontal","rule","hr","divider","separator"],condition:n=>t("horizontalRule")&&j(n,"insertHorizontalRule")},{id:"insert.image",label:"Insert Image",description:"Insert an image from URL",category:"Insert",action:n=>{let i=prompt("Enter image URL:");if(i){let a=prompt("Enter alt text:")||"";n.insertImage?.({src:i,alt:a});}},keywords:["image","photo"],condition:n=>t("image")&&j(n,"insertImage")},{id:"insert.gif",label:"Insert GIF",description:"Insert an animated GIF from URL",category:"Insert",action:n=>{let i=prompt("Enter GIF URL:");i&&n.insertImage?.({src:i,alt:"GIF"});},keywords:["gif","animated","image"],condition:n=>t("image")&&j(n,"insertImage")},{id:"insert.emoji",label:"Insert Emoji",description:"Insert an emoji character",category:"Insert",action:n=>{let i=prompt("Enter emoji or shortcode (example :sparkles:):")?.trim();if(!i||typeof n.insertEmoji!="function")return;let a=i.match(/^:([a-z0-9_+-]+):$/i);if(a){let u=a[1];if(!u)return;if(typeof n.resolveEmojiShortcode=="function"){let d=n.resolveEmojiShortcode(u);if(d?.emoji){n.insertEmoji(d.emoji);return}}else if(typeof n.getEmojiSuggestions=="function"){let[d]=n.getEmojiSuggestions(u);if(d?.emoji){n.insertEmoji(d.emoji);return}}}n.insertEmoji(i);},keywords:["emoji","reaction","symbol","smile"],condition:n=>t("emoji")&&kn(n)},{id:"insert.table",label:"Insert Table",description:"Insert a 3x3 table",category:"Insert",action:n=>n.insertTable?.({rows:3,columns:3,includeHeaders:true}),keywords:["table","grid"],condition:n=>t("table")&&j(n,"insertTable")},{id:"insert.iframe",label:"Insert iframe",description:"Insert an iframe embed from URL",category:"Insert",action:n=>{if(typeof n.insertIframeEmbed!="function")return;let i=prompt("Enter iframe URL:");i&&n.insertIframeEmbed(i);},keywords:["iframe","embed","url"],condition:n=>t("iframeEmbed")&&En(n)},{id:"insert.youtube",label:"Insert YouTube Video",description:"Insert an embedded YouTube video",category:"Insert",action:n=>{if(typeof n.insertYouTubeEmbed!="function")return;let i=prompt("Enter YouTube URL:");i&&n.insertYouTubeEmbed(i);},keywords:["youtube","video","embed"],condition:n=>t("youTubeEmbed")&&xn(n)},{id:"edit.undo",label:"Undo",description:"Undo the last action",category:"Edit",action:n=>n.undo?.(),shortcuts:[{key:"z",ctrlKey:true}],keywords:["undo","revert"],condition:n=>t("history")&&j(n,"undo")},{id:"edit.redo",label:"Redo",description:"Redo the last undone action",category:"Edit",action:n=>n.redo?.(),shortcuts:[{key:"y",ctrlKey:true},{key:"z",ctrlKey:true,shiftKey:true}],keywords:["redo","repeat"],condition:n=>t("history")&&j(n,"redo")},{id:"palette.show",label:"Show Command Palette",description:"Open the command palette",category:"View",action:n=>n.showCommandPalette?.(),shortcuts:[{key:"p",ctrlKey:true,shiftKey:true}],keywords:["command","palette"],condition:n=>t("commandPalette")&&j(n,"showCommandPalette")}]}function Qo(e,t){let r=t?.commandPaletteShortcutOnly===true;return fo(e,t).filter(o=>!r||!!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]?Zo(o.shortcuts[0]):void 0}))}function Xo(e,t){let r=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:r.has(a.id):false,{allowlist:l,denylist:n}=wn(t?.slashCommandVisibility),i=l.size>0;return fo(e,t).filter(o).filter(a=>n.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]?Zo(a.shortcuts[0]):void 0}))}function Zo(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 er(e,t=document.body,r){let o=fo(e,r),l=n=>{let i=typeof r?.scope=="function"?r.scope():r?.scope;if(!(i&&n.target instanceof Node&&!i.contains(n.target))){for(let a of o)if(a.shortcuts){for(let u of a.shortcuts)if(!(r?.shortcutConfig?.preventNativeConflicts!==false&&yn(n,u))&&n.key.toLowerCase()===u.key.toLowerCase()&&!!n.ctrlKey==!!u.ctrlKey&&!!n.metaKey==!!u.metaKey&&!!n.shiftKey==!!u.shiftKey&&!!n.altKey==!!u.altKey){u.preventDefault!==false&&n.preventDefault(),(!a.condition||a.condition(e))&&a.action(e);return}}}};return t.addEventListener("keydown",l),()=>t.removeEventListener("keydown",l)}var At=Bold,Dt=Italic,Kt=Underline,jt=Strikethrough,Ut=Code,tr=Code2,dt=Link,nt=Unlink,_t=List,Vt=ListChecks,$t=ListOrdered,or=Undo2,rr=Redo2,ho=Image,ct=AlignLeft,it=AlignCenter,nr=AlignJustify,mt=AlignRight,bo=Upload,ir=Minus,lr=Table,ar=FileCode,ls=Eye,sr=Highlighter,as=Pencil,Jt=Command,ur=Palette,dr=Type,qt=Quote,cr=IndentIncrease,mr=IndentDecrease,gr=Sun,fr=Moon,pr=Search,yo=Smile,hr=Subscript,br=Superscript,yr=ChevronDown,vr=X;function xr({isOpen:e,onClose:t,commands:r}){let[o,l]=useState(""),[n,i]=useState(0),a=useRef(null),u=useRef(null),d=r.filter(p=>`${p.label} ${p.description||""} ${p.keywords?.join(" ")||""}`.toLowerCase().includes(o.toLowerCase())),b=d.reduce((p,m)=>{let h=m.category||"Other";return p[h]||(p[h]=[]),p[h].push(m),p},{}),c=d;return useEffect(()=>{i(0);},[o]),useEffect(()=>{e&&a.current&&(a.current.focus({preventScroll:true}),l(""),i(0));},[e]),useEffect(()=>{if(!e)return;let p=u.current;if(!p)return;p.querySelector(".luthor-command-palette-item.selected")?.scrollIntoView({block:"nearest"});},[e,n,o]),useEffect(()=>{let p=m=>{if(e)switch(m.key){case "Escape":m.preventDefault(),m.stopPropagation(),t();break;case "ArrowDown":m.preventDefault(),m.stopPropagation(),i(h=>Math.min(h+1,c.length-1));break;case "ArrowUp":m.preventDefault(),m.stopPropagation(),i(h=>Math.max(h-1,0));break;case "Enter":m.preventDefault(),m.stopPropagation(),c[n]&&(c[n].action(),t());break}};return document.addEventListener("keydown",p,true),()=>document.removeEventListener("keydown",p,true)},[e,n,c,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:p=>p.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(pr,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:a,type:"text",placeholder:"Type a command or search...",value:o,onChange:p=>l(p.target.value),className:"luthor-command-palette-input"}),jsx("kbd",{className:"luthor-command-palette-kbd",children:"ESC"})]}),jsx("div",{ref:u,className:"luthor-command-palette-list",children:Object.keys(b).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(b).map(([p,m])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:p}),m.map(h=>{let O=c.indexOf(h);return jsxs("div",{className:`luthor-command-palette-item ${O===n?"selected":""}`,onClick:()=>{h.action(),t();},onMouseEnter:()=>i(O),children:[jsxs("div",{className:"luthor-command-palette-item-content",children:[jsx("div",{className:"luthor-command-palette-item-title",children:h.label}),h.description&&jsx("div",{className:"luthor-command-palette-item-description",children:h.description})]}),h.shortcut&&jsx("kbd",{className:"luthor-command-palette-item-shortcut",children:h.shortcut})]},h.id)})]},p))}),jsx("div",{className:"luthor-command-palette-footer",children:jsxs("span",{className:"luthor-command-palette-hint",children:[jsx(Jt,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var hi={"--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 bi(e){return e?e.closest(".luthor-editor-wrapper"):null}function yi(e){return e?bi(e)??e:null}function vi(e){if(typeof window>"u"||!e)return {};let t=window.getComputedStyle(e),r={};for(let[o,l]of Object.entries(hi)){let n=t.getPropertyValue(o).trim()||l;r[o]=n;}return r}function Xe(e){return vi(yi(e))}function ft(){if(typeof window>"u")return {};let t=window.getSelection()?.anchorNode;if(!t)return {};let r=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return Xe(r)}function Tr({isOpen:e,query:t,position:r,suggestions:o,onClose:l,onExecute:n}){let[i,a]=useState(0);if(useEffect(()=>{a(0);},[t,e]),useEffect(()=>{if(!e)return;let d=b=>{let c=o.length>0;switch(b.key){case "Escape":b.preventDefault(),b.stopPropagation(),l();break;case "ArrowDown":if(!c)return;b.preventDefault(),b.stopPropagation(),a(p=>Math.min(p+1,Math.max(o.length-1,0)));break;case "ArrowUp":if(!c)return;b.preventDefault(),b.stopPropagation(),a(p=>Math.max(p-1,0));break;case "Enter":case "Tab":if(!c||!o[i])return;b.preventDefault(),b.stopPropagation(),n(o[i].emoji);break}};return document.addEventListener("keydown",d,true),()=>document.removeEventListener("keydown",d,true)},[e,l,n,i,o]),!e||!r)return null;let u=jsxs("div",{className:"luthor-emoji-menu",style:{left:r.x,top:r.y,...ft()},onPointerDown:d=>{d.stopPropagation();},onMouseDown:d=>{d.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((d,b)=>{let c=b===i,p=d.shortcodes[0]?`:${d.shortcodes[0]}:`:"";return jsxs("button",{type:"button",className:`luthor-emoji-menu-item ${c?"selected":""}`,onMouseEnter:()=>a(b),onMouseDown:m=>{m.preventDefault(),m.stopPropagation();},onClick:m=>{m.preventDefault(),m.stopPropagation(),n(d.emoji);},children:[jsx("span",{className:"luthor-emoji-menu-item-symbol","aria-hidden":"true",children:d.emoji}),jsxs("span",{className:"luthor-emoji-menu-item-content",children:[jsx("span",{className:"luthor-emoji-menu-item-title",children:d.label}),p&&jsx("span",{className:"luthor-emoji-menu-item-shortcode",children:p})]})]},`${d.emoji}-${d.label}`)})})]});return typeof document>"u"?u:createPortal(u,document.body)}function wr({isOpen:e,query:t,position:r,commands:o,onClose:l,onExecute:n}){let[i,a]=useState(0),u=useMemo(()=>{let c=t.trim().toLowerCase();return c?o.filter(p=>`${p.label} ${p.description||""} ${p.keywords?.join(" ")||""}`.toLowerCase().includes(c)):o},[o,t]),d=useMemo(()=>u.reduce((c,p)=>{let m=p.category||"Other";return c[m]||(c[m]=[]),c[m].push(p),c},{}),[u]);if(useEffect(()=>{a(0);},[t,e]),useEffect(()=>{if(!e)return;let c=p=>{let m=u.length>0;switch(p.key){case "Escape":p.preventDefault(),p.stopPropagation(),l();break;case "ArrowDown":if(!m)return;p.preventDefault(),p.stopPropagation(),a(h=>Math.min(h+1,Math.max(u.length-1,0)));break;case "ArrowUp":if(!m)return;p.preventDefault(),p.stopPropagation(),a(h=>Math.max(h-1,0));break;case "Enter":case "Tab":if(!m||!u[i])return;p.preventDefault(),p.stopPropagation(),n(u[i].id);break}};return document.addEventListener("keydown",c,true),()=>document.removeEventListener("keydown",c,true)},[u,e,l,n,i]),!e||!r)return null;let b=jsxs("div",{className:"luthor-slash-menu",style:{left:r.x,top:r.y,...ft()},onPointerDown:c=>{c.stopPropagation();},onMouseDown:c=>{c.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:u.length===0?jsx("div",{className:"luthor-slash-menu-empty",children:"No matching commands"}):Object.entries(d).map(([c,p])=>jsxs("div",{className:"luthor-slash-menu-group",children:[jsx("div",{className:"luthor-slash-menu-group-title",children:c}),p.map(m=>{let h=u.indexOf(m);return jsxs("button",{type:"button",className:`luthor-slash-menu-item ${h===i?"selected":""}`,onMouseEnter:()=>a(h),onMouseDown:S=>{S.preventDefault(),S.stopPropagation();},onClick:S=>{S.preventDefault(),S.stopPropagation(),n(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)})]},c))})]});return typeof document>"u"?b:createPortal(b,document.body)}function L({children:e,onClick:t,title:r,active:o,disabled:l,className:n,type:i="button"}){return jsx("button",{type:i,className:`luthor-toolbar-button${o?" active":""}${n?` ${n}`:""}`,onClick:t,title:r,disabled:l,children:e})}function Co({children:e,onClick:t,variant:r="primary",type:o="button",className:l}){return jsx("button",{type:o,onClick:t,className:`${r==="primary"?"luthor-button-primary":"luthor-button-secondary"}${l?` ${l}`:""}`,children:e})}function Tt({value:e,onValueChange:t,options:r,placeholder:o="Select..."}){let[l,n]=useState(false),[i,a]=useState(void 0),u=useRef(null),d=useRef(null);useEffect(()=>{if(!l)return;let c=()=>{let p=u.current?.querySelector(".luthor-select-trigger");if(!p)return;let m=p.getBoundingClientRect();a({position:"fixed",top:m.bottom+4,left:m.left,width:m.width,...Xe(p)});};return c(),window.addEventListener("resize",c),window.addEventListener("scroll",c,true),()=>{window.removeEventListener("resize",c),window.removeEventListener("scroll",c,true);}},[l]),useEffect(()=>{function c(p){let m=p.target;u.current?.contains(m)||d.current?.contains(m)||n(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]);let b=r.find(c=>c.value===e);return jsxs("div",{className:"luthor-select",ref:u,children:[jsxs("button",{className:`luthor-select-trigger ${l?"open":""}`,onClick:()=>n(!l),type:"button",children:[jsx("span",{children:b?.label||o}),jsx(yr,{size:14})]}),l&&typeof document<"u"&&createPortal(jsx("div",{ref:d,className:"luthor-select-dropdown",style:i,children:r.map(c=>jsx("button",{className:`luthor-select-option ${e===c.value?"selected":""}`,onClick:()=>{t(c.value),n(false);},type:"button",children:c.label},c.value))}),document.body)]})}function St({trigger:e,children:t,isOpen:r,onOpenChange:o}){let l=useRef(null),n=useRef(null),i=useRef(null),[a,u]=useState(void 0);return useEffect(()=>{if(!r)return;let d=()=>{let b=n.current;if(!b)return;let c=b.getBoundingClientRect();u({position:"fixed",top:c.bottom+4,left:c.left,...Xe(b)});};return d(),window.addEventListener("resize",d),window.addEventListener("scroll",d,true),()=>{window.removeEventListener("resize",d),window.removeEventListener("scroll",d,true);}},[r]),useEffect(()=>{function d(b){let c=b.target;l.current?.contains(c)||i.current?.contains(c)||o(false);}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[o]),jsxs("div",{className:"luthor-dropdown",ref:l,children:[jsx("div",{ref:n,onClick:()=>o(!r),children:e}),r&&typeof document<"u"&&createPortal(jsx("div",{ref:i,className:"luthor-dropdown-content",style:a,children:t}),document.body)]})}function Ir({isOpen:e,onClose:t,title:r,children:o}){let l=useRef(null);return useEffect(()=>{function n(a){l.current&&!l.current.contains(a.target)&&t();}function i(a){a.key==="Escape"&&t();}return e&&(document.addEventListener("mousedown",n),document.addEventListener("keydown",i)),()=>{document.removeEventListener("mousedown",n),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:r}),jsx("button",{className:"luthor-dialog-close",onClick:t,type:"button",children:jsx(vr,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:o})]})}):null}function Nr({isVisible:e,selectionRect:t,commands:r,activeStates:o,editorTheme:l="light",hide:n,isFeatureEnabled:i=()=>true}){let a=useRef(null),[u,d]=useState(""),[b,c]=useState(""),[p,m]=useState(""),[h,O]=useState(""),[S,P]=useState(""),[U,_]=useState(""),[C,oe]=useState(null),[ae,$]=useState(null),[g,I]=useState(null),E=!!o.isIframeEmbedSelected,D=!!o.isYouTubeEmbedSelected,R=i("iframeEmbed"),X=i("youTubeEmbed"),B=i("image"),he=R&&E||X&&D;if(useEffect(()=>{if(!e)return;let F=w=>{let V=w.target;V&&(a.current?.contains(V)||n?.());};return document.addEventListener("mousedown",F,true),document.addEventListener("touchstart",F,true),()=>{document.removeEventListener("mousedown",F,true),document.removeEventListener("touchstart",F,true);}},[e,n]),useEffect(()=>{if(!e||!E)return;let F=false;return typeof r.getIframeEmbedCaption=="function"&&r.getIframeEmbedCaption().then(w=>{F||c(w??"");}),typeof r.getIframeEmbedUrl=="function"&&r.getIframeEmbedUrl().then(w=>{F||d(w??"");}),oe(null),()=>{F=true;}},[r,E,e]),useEffect(()=>{if(!e||!o.imageSelected)return;let F=false;return typeof r.getImageCaption=="function"&&r.getImageCaption().then(w=>{F||m(w??"");}),()=>{F=true;}},[o.imageSelected,r,e]),useEffect(()=>{if(!e||!D)return;let F=false;return typeof r.getYouTubeEmbedCaption=="function"&&r.getYouTubeEmbedCaption().then(w=>{F||O(w??"");}),typeof r.getYouTubeEmbedUrl=="function"&&r.getYouTubeEmbedUrl().then(w=>{F||P(w??"");}),$(null),()=>{F=true;}},[r,e,D]),useEffect(()=>{if(!e||!o.isLink)return;let F=false;return typeof r.getCurrentLink=="function"&&r.getCurrentLink().then(w=>{!F&&w&&_(w.url??"");}),I(null),()=>{F=true;}},[o.isLink,r,e]),!e||!t)return null;let ne={...ft(),position:"absolute",top:t.y,left:t.positionFromRight?"auto":t.x,right:t.positionFromRight?10:"auto",zIndex:9999,pointerEvents:"auto"};if(he){let F=M=>{if(E){r.setIframeEmbedAlignment?.(M);return}D&&r.setYouTubeEmbedAlignment?.(M);},w=E?o.isIframeEmbedAlignedLeft:o.isYouTubeEmbedAlignedLeft,V=E?o.isIframeEmbedAlignedCenter:o.isYouTubeEmbedAlignedCenter,ot=E?o.isIframeEmbedAlignedRight:o.isYouTubeEmbedAlignedRight,ye=E?typeof r.setIframeEmbedCaption=="function":typeof r.setYouTubeEmbedCaption=="function",ke=E?typeof r.updateIframeEmbedUrl=="function":typeof r.updateYouTubeEmbedUrl=="function",qe=E?b:h,Te=E?c:O,Me=E?u:S,G=E?C:ae,Se=()=>{if(ye){if(E){r.setIframeEmbedCaption?.(b);return}r.setYouTubeEmbedCaption?.(h);}},Re=M=>{E?oe(M):$(M);},ie=M=>{E?d(M):P(M);},ve=()=>{if(!ke)return;if(!(E?r.updateIframeEmbedUrl?.(u)??false:r.updateYouTubeEmbedUrl?.(S)??false)){Re(E?"Enter a valid http(s) URL":"Enter a valid YouTube URL"),E&&typeof r.getIframeEmbedUrl=="function"?r.getIframeEmbedUrl().then(Be=>d(Be??"")):!E&&typeof r.getYouTubeEmbedUrl=="function"&&r.getYouTubeEmbedUrl().then(Be=>P(Be??""));return}Re(null);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:ne,children:[jsx(L,{onClick:()=>F("left"),active:w,title:"Align Left",children:jsx(ct,{size:14})}),jsx(L,{onClick:()=>F("center"),active:V,title:"Align Center",children:jsx(it,{size:14})}),jsx(L,{onClick:()=>F("right"),active:ot,title:"Align Right",children:jsx(mt,{size:14})}),ye||ke?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-fields",children:[ke?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:Me,className:`luthor-floating-toolbar-input${G?" is-error":""}`,placeholder:E?"https://example.com/embed":"https://youtube.com/watch?v=...","aria-label":E?"Iframe URL":"YouTube URL","aria-invalid":G?true:void 0,onChange:M=>{ie(M.target.value),G&&Re(null);},onBlur:ve,onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),ve());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:ve,children:"Update URL"})]}):null,ye?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:qe,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":E?"Iframe caption":"YouTube caption",onChange:M=>Te(M.target.value),onBlur:Se,onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),Se());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:Se,children:"Update Caption"})]}):null]})]}):null]})}if(B&&o.imageSelected){let F=typeof r.setImageCaption=="function",w=()=>{F&&r.setImageCaption(p);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:ne,children:[jsx(L,{onClick:()=>r.setImageAlignment("left"),active:o.isImageAlignedLeft,title:"Align Left",children:jsx(ct,{size:14})}),jsx(L,{onClick:()=>r.setImageAlignment("center"),active:o.isImageAlignedCenter,title:"Align Center",children:jsx(it,{size:14})}),jsx(L,{onClick:()=>r.setImageAlignment("right"),active:o.isImageAlignedRight,title:"Align Right",children:jsx(mt,{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:p,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":"Image caption",onChange:V=>m(V.target.value),onBlur:w,onKeyDown:V=>{V.key==="Enter"&&(V.preventDefault(),w());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:w,children:"Update Caption"})]})]}):null]})}let we=i("bold"),se=i("italic"),Fe=i("underline"),Ie=i("strikethrough"),Ne=i("codeFormat"),ce=i("blockFormat"),Pe=i("link"),ze=i("list"),Oe=we||se||Fe||Ie,me=Ne||ce||Pe,He=ze,be=!!o.isLink&&typeof r.updateLink=="function"&&typeof r.removeLink=="function",ge=()=>{if(!be)return;if(!(r.updateLink?.(U)??false)){I("Enter a valid URL"),typeof r.getCurrentLink=="function"&&r.getCurrentLink().then(w=>{_(w?.url??"");});return}I(null);};return !Oe&&!me&&!He?null:jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:ne,children:[Oe?jsxs(Fragment,{children:[we?jsx(L,{onClick:()=>r.toggleBold(),active:o.bold,title:"Bold",children:jsx(At,{size:14})}):null,se?jsx(L,{onClick:()=>r.toggleItalic(),active:o.italic,title:"Italic",children:jsx(Dt,{size:14})}):null,Fe?jsx(L,{onClick:()=>r.toggleUnderline(),active:o.underline,title:"Underline",children:jsx(Kt,{size:14})}):null,Ie?jsx(L,{onClick:()=>r.toggleStrikethrough(),active:o.strikethrough,title:"Strikethrough",children:jsx(jt,{size:14})}):null]}):null,Oe&&me?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,me?jsxs(Fragment,{children:[Ne?jsx(L,{onClick:()=>r.formatText("code"),active:o.code,title:"Inline Code",children:jsx(Ut,{size:14})}):null,ce?jsx(L,{onClick:()=>r.toggleQuote(),active:o.isQuote,title:"Quote",children:jsx(qt,{size:14})}):null,Pe?jsxs(Fragment,{children:[jsx(L,{onClick:()=>o.isLink?r.removeLink():r.insertLink(),active:o.isLink,title:o.isLink?"Remove Link":"Insert Link",children:o.isLink?jsx(nt,{size:14}):jsx(dt,{size:14})}),be?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:U,className:`luthor-floating-toolbar-input${g?" is-error":""}`,placeholder:"https://example.com","aria-label":"Link URL","aria-invalid":g?true:void 0,onChange:F=>{_(F.target.value),g&&I(null);},onBlur:ge,onKeyDown:F=>{F.key==="Enter"&&(F.preventDefault(),ge());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:ge,children:"Update Link"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-danger",onClick:()=>r.removeLink(),"aria-label":"Unlink",children:jsx(nt,{size:13})})]}):null]}):null]}):null,(Oe||me)&&He?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,He?jsxs(Fragment,{children:[jsx(L,{onClick:()=>r.toggleUnorderedList(),active:o.unorderedList,title:"Bullet List",children:jsx(_t,{size:14})}),jsx(L,{onClick:()=>r.toggleOrderedList(),active:o.orderedList,title:"Numbered List",children:jsx($t,{size:14})}),jsx(L,{onClick:()=>r.toggleCheckList(),active:o.checkList,title:"Checklist",children:jsx(Vt,{size:14})})]}):null]})}var De={commands:{},activeStates:{},editorTheme:"light",isFeatureEnabled:()=>true};function Eo(e,t,r,o=()=>true){De.commands=e,De.activeStates=t,De.editorTheme=r,De.isFeatureEnabled=o;}function Pr(){let e=Nr,t=new FloatingToolbarExtension;return t.config={...t.config,render:r=>createElement(e,{...r,commands:De.commands,activeStates:De.activeStates,editorTheme:De.editorTheme,isFeatureEnabled:De.isFeatureEnabled}),getCommands:()=>De.commands,getActiveStates:()=>De.activeStates},t}var Pi=120,Oi=58;function Hi(e,t=Oi){return e.length<=t?e:`${e.slice(0,t-3)}...`}function Hr(){let e=window.getSelection();return !e||e.rangeCount===0?false:!e.getRangeAt(0).collapsed}function Rr(e,t){if(!(e instanceof Element))return null;let r=e.closest("a");return !(r instanceof HTMLAnchorElement)||!t.contains(r)?null:r}function Mr({editor:e,commands:t,editorTheme:r="light",disabled:o=false}){let l=useRef(null),n=useRef(null),[i,a]=useState(null),[u,d]=useState(false),[b,c]=useState(""),[p,m]=useState(null),[h,O]=useState(null),S=useCallback(()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null);},[]),P=useCallback(()=>{S(),a(null),d(false),c(""),m(null),O(null);},[S]),U=useCallback(()=>{S(),n.current=window.setTimeout(()=>{P();},Pi);},[S,P]),_=useCallback(g=>{let I=g.getBoundingClientRect(),E=I.bottom+8,D=Math.max(10,Math.min(I.left,window.innerWidth-340));O({top:E,left:D});},[]),C=useCallback((g,I)=>{if(typeof t.getLinkByKey!="function"){a(E=>!E||E.nodeKey!==g?E:{...E,url:I});return}t.getLinkByKey(g).then(E=>{if(!E){P();return}a(D=>!D||D.nodeKey!==g?D:{...D,url:E.url});});},[t,P]);useEffect(()=>{if(!e||o||typeof window>"u"){P();return}let g=e.getRootElement();if(!g){P();return}let I=X=>{let B=Rr(X.target,g);if(!B)return;if(Hr()){P();return}S();let he=resolveLinkNodeKeyFromAnchor(e,B);if(!he)return;let ne=B.getAttribute("href")??B.href;a({nodeKey:he,url:ne,anchorEl:B}),_(B),m(null),u||c(ne),C(he,ne);},E=X=>{if(!i)return;let B=X.relatedTarget;B&&l.current?.contains(B)||Rr(B,g)||U();},D=()=>{Hr()&&P();},R=()=>{a(X=>{if(!X)return X;let B=X.anchorEl.isConnected&&g.contains(X.anchorEl)?X.anchorEl:g.querySelector(`a[data-lexical-node-key="${X.nodeKey}"]`);return B?(_(B),{...X,anchorEl:B,url:B.getAttribute("href")??B.href}):(P(),null)});};return g.addEventListener("mouseover",I),g.addEventListener("mouseout",E),document.addEventListener("selectionchange",D),window.addEventListener("scroll",R,true),window.addEventListener("resize",R),()=>{g.removeEventListener("mouseover",I),g.removeEventListener("mouseout",E),document.removeEventListener("selectionchange",D),window.removeEventListener("scroll",R,true),window.removeEventListener("resize",R),S();}},[t,o,e,i,u,P,U,C,_,S]);let oe=useMemo(()=>{if(!(!i||!h))return {...Xe(i.anchorEl),position:"fixed",top:h.top,left:h.left,zIndex:10040}},[i,h]);if(!i||!h||typeof document>"u")return null;let ae=()=>{(t.removeLinkByKey?.(i.nodeKey)??false)&&P();},$=()=>{let g=b.trim();if(!(t.updateLinkByKey?.(i.nodeKey,g)??false)){m("Enter a valid URL"),C(i.nodeKey,i.url);return}a(E=>!E||E.nodeKey!==i.nodeKey?E:{...E,url:g}),m(null),d(false),queueMicrotask(()=>{C(i.nodeKey,g);});};return createPortal(jsx("div",{ref:l,className:"luthor-floating-toolbar luthor-link-hover-bubble","data-theme":r,style:oe,onMouseEnter:S,onMouseLeave:U,children:u?jsxs(Fragment,{children:[jsx("input",{type:"url",value:b,className:`luthor-link-hover-bubble-input${p?" is-error":""}`,placeholder:"https://example.com","aria-label":"Edit link URL","aria-invalid":p?true:void 0,onChange:g=>{c(g.target.value),p&&m(null);},onKeyDown:g=>{if(g.key==="Enter"){g.preventDefault(),$();return}g.key==="Escape"&&(g.preventDefault(),d(false),c(i.url),m(null));}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-primary",onClick:$,children:"Update"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{d(false),c(i.url),m(null);},children:"Cancel"})]}):jsxs(Fragment,{children:[jsx("span",{className:"luthor-link-hover-bubble-url",title:i.url,children:Hi(i.url)}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{c(i.url),d(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:ae,"aria-label":"Unlink",children:jsx(nt,{size:13})})]})}),document.body)}function Ar({mode:e,onModeChange:t,labels:r,availableModes:o,isConverting:l}){let n=o??["visual","jsonb"],i={visual:r?.visual??"Visual",jsonb:r?.jsonb??"JSONB"};return jsxs("div",{className:"luthor-mode-tabs",children:[n.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"})]}),n.includes("jsonb")&&jsxs("button",{className:`luthor-mode-tab ${e==="jsonb"?"active":""}`,onClick:()=>t("jsonb"),children:[i.jsonb,l==="jsonb"&&jsx("span",{className:"luthor-tab-converting-spinner"})]})]})}function Dr({value:e,onChange:t,placeholder:r,className:o}){let l=useRef(null);return useLayoutEffect(()=>{let n=l.current;if(!n)return;n.style.height="auto";let i=Math.max(n.scrollHeight,280);n.style.height=`${i}px`;},[e]),jsx("textarea",{ref:l,className:`luthor-source-view${o?` ${o}`:""}`,value:e,onChange:n=>t(n.target.value),placeholder:r,spellCheck:false})}function ee(e,t){let r=`luthor-preset-${e}`;return {placeholder:t,classNames:{container:`luthor-preset ${r} ${r}__container`,contentEditable:`luthor-content-editable ${r}__content`,placeholder:`luthor-placeholder ${r}__placeholder`}}}function Kr(e){return e.replace(/\r\n?/g,`
2
+ `)}function To(e){let t=Kr(e).trim();if(!t)return "";try{let r=JSON.parse(t);return JSON.stringify(r,null,2)}catch{return t}}function jr(e){return Kr(e).trim()}var So=6,Di=["#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 Wt(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Ki(e,t){let r=Wt(t);for(let o of e)if(Wt(o.value)===r)return o.color;return null}function ji(e,t,r){if(!e||e==="default")return r;let o=Ki(t,e);return o||e}function Ui(e,t){let r=e.trim();return /^#([\da-f]{6})$/i.test(r)?r:/^#([\da-f]{3})$/i.test(r)?`#${r.slice(1).split("").map(l=>`${l}${l}`).join("")}`:t}function Ue(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function _r(e){let t=e.split(",")[0]??"";return Ue(t.replace(/["']/g,""))}function Qt(e){let t=e.trim().toLowerCase().match(/^(-?\d*\.?\d+)px$/);if(!t)return null;let r=Number(t[1]);return Number.isFinite(r)?r:null}function Gt(){if(typeof window>"u")return null;let t=window.getSelection()?.anchorNode;if(!t)return null;let r=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!r||!r.closest(".luthor-content-editable"))return null;let l=window.getComputedStyle(r);return {fontFamily:l.fontFamily,fontSize:l.fontSize,lineHeight:l.lineHeight}}function _i(e,t){if(!e)return null;let r=_r(e);return r?t.find(l=>Ue(l.value)===r?true:_r(l.fontFamily)===r)?.value??null:null}function Vi(e,t){if(!e)return null;let r=Ue(e),o=t.find(i=>Ue(String(i.value))===r?true:Ue(String(i.fontSize))===r);if(o)return String(o.value);let l=Qt(e);if(l==null)return null;let n=null;for(let i of t){let a=Qt(String(i.fontSize));if(a==null)continue;let u=Math.abs(a-l);(!n||u<n.distance)&&(n={value:String(i.value),distance:u});}return n?.value??null}function $i(e,t,r){if(!e)return null;let o=Ue(e),l=r.find(d=>Ue(d.value)===o?true:Ue(d.lineHeight)===o);if(l)return l.value;let n=t?Qt(t):null,i=Qt(e),a=null;if(i!=null&&n!=null&&n>0)a=i/n;else {let d=Number(e);Number.isFinite(d)&&(a=d);}if(a==null)return null;let u=null;for(let d of r){let b=Number(d.lineHeight);if(!Number.isFinite(b))continue;let c=Math.abs(b-a);(!u||c<u.distance)&&(u={value:d.value,distance:c});}return u?.value??null}function Vr({title:e,value:t,options:r,recentColors:o,active:l,fallbackColor:n,highlight:i,onChange:a,onClear:u,onAddRecent:d}){let b=useRef(null),c=useRef(null),p=useRef(null),m=useRef(null),h=useRef(null),[O,S]=useState(false),[P,U]=useState(void 0),_=ji(t,r,n),C=useMemo(()=>Di,[]),oe=useMemo(()=>{let g=[...o].slice(0,So);for(;g.length<So;)g.push("");return g},[o]);useEffect(()=>()=>{m.current&&window.cancelAnimationFrame(m.current);},[]);let ae=useCallback(g=>{h.current=g,!m.current&&(m.current=window.requestAnimationFrame(()=>{m.current=null,h.current&&(a(h.current),h.current=null);}));},[a]),$=useCallback(g=>{let I=b.current;if(!I)return;let E=I.getBoundingClientRect();U({position:"fixed",top:E.bottom+6,left:E.left,width:230,visibility:g?"visible":"hidden",...Xe(I)});},[]);return useLayoutEffect(()=>{if(!O)return;$(false);let g=window.requestAnimationFrame(()=>{$(true);});return ()=>{window.cancelAnimationFrame(g);}},[O,$]),useEffect(()=>{if(!O)return;let g=D=>{let R=D.target;b.current?.contains(R)||c.current?.contains(R)||S(false);},I=D=>{D.key==="Escape"&&S(false);},E=()=>$(true);return window.addEventListener("resize",E),window.addEventListener("scroll",E,true),document.addEventListener("mousedown",g),document.addEventListener("keydown",I),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,true),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",I);}},[O,$]),jsxs(Fragment,{children:[jsxs("button",{ref:b,type:"button",className:`luthor-toolbar-button luthor-color-button${l?" active":""}${i?" is-highlight":""}`,title:e,"aria-label":e,onClick:()=>S(g=>!g),children:[i?jsx(sr,{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:_}})]}),O&&typeof document<"u"&&createPortal(jsxs("div",{ref:c,className:"luthor-color-picker",style:P,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:C.map(g=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:g},"aria-label":`Use color ${g}`,onClick:()=>{a(g),d(g),S(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:oe.map((g,I)=>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),d(g),S(false));}},`${g||"empty"}-${I}`))})]}),jsxs("div",{className:"luthor-color-picker-footer",children:[jsx("button",{type:"button",className:"luthor-color-picker-clear",onClick:()=>{u(),S(false);},children:"Reset to Default"}),jsxs("button",{type:"button",className:"luthor-color-picker-custom",onClick:()=>p.current?.click(),children:[jsx(ur,{size:14}),jsx("span",{children:"Custom Color"})]}),jsx("input",{ref:p,type:"color",className:"luthor-color-picker-native luthor-color-picker-native-hidden",value:Ui(_,n),onInput:g=>{ae(g.target.value);},onChange:g=>{let I=g.target.value;a(I),d(I);}})]})]}),document.body)]})}function Ji(e,t){let r=useRef(null),o=useRef(null);return {handlers:useMemo(()=>({insertFromUrl:()=>{let n=prompt("Enter image URL:");if(!n)return;let i=prompt("Enter alt text:")||"",a=prompt("Enter caption (optional):")||void 0;e.insertImage({src:n,alt:i,caption:a});},insertFromFile:()=>r.current?.click(),insertGifFromUrl:()=>{let n=prompt("Enter GIF URL:");if(!n)return;let i=prompt("Enter alt text (optional):")||"GIF";e.insertImage({src:n,alt:i});},insertGifFromFile:()=>o.current?.click(),handleUpload:async n=>{let i=n.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}),n.target.value="";},handleGifUpload:async n=>{let i=n.target.files?.[0];if(!i)return;if(!(i.type==="image/gif"||i.name.toLowerCase().endsWith(".gif"))){alert("Please select a GIF file."),n.target.value="";return}let u;if(t)try{u=await t(i);}catch{alert("Failed to upload GIF");return}else u=URL.createObjectURL(i);e.insertImage({src:u,alt:i.name||"GIF",file:i}),n.target.value="";},setAlignment:n=>{e.setImageAlignment(n);},setCaption:()=>{let n=prompt("Enter caption:")||"";e.setImageCaption(n);}}),[e,t]),fileInputRef:r,gifInputRef:o}}function qi(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 Yi(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 Gi(e,t,r){return Yi(e,t)?r?.[e]!==false:false}function Wi(e,t,r){return {sections:e.sections.map(o=>({...o,items:o.items.filter(l=>Gi(l,t,r))})).filter(o=>o.items.length>0)}}function $r({commands:e,hasExtension:t,activeStates:r,isDark:o,toggleTheme:l,onCommandPaletteOpen:n,imageUploadHandler:i,classNames:a,toolbarStyleVars:u,layout:d,toolbarVisibility:b,headingOptions:c,paragraphLabel:p}){let{handlers:m,fileInputRef:h,gifInputRef:O}=Ji(e,i),S=qi(e),P=t("iframeEmbed")||t("youtubeEmbed"),U=r.isIframeEmbedSelected||r.isYouTubeEmbedSelected,[_,C]=useState(false),[oe,ae]=useState(false),[$,g]=useState(false),[I,E]=useState(false),[D,R]=useState(false),[X,B]=useState("default"),[he,ne]=useState([{value:"default",label:"Default"}]),[we,se]=useState("default"),[Fe,Ie]=useState([{value:"default",label:"Default"}]),[Ne,ce]=useState("default"),[Pe,ze]=useState([{value:"default",label:"Default"}]),[Oe,me]=useState("default"),[He,be]=useState([{value:"default",label:"Default",color:"inherit"}]),[ge,F]=useState([]),[w,V]=useState("default"),[ot,ye]=useState([{value:"default",label:"Default",color:"transparent"}]),[ke,qe]=useState([]),[Te,Me]=useState(0),[G,Se]=useState({rows:3,columns:3,includeHeaders:false});useEffect(()=>{if(typeof document>"u")return;let f=()=>{Gt()&&Me(H=>H+1);};return document.addEventListener("selectionchange",f),()=>{document.removeEventListener("selectionchange",f);}},[]);let Re=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(H=>({value:H.value,label:H.label})),y=f.length>0?f:[{value:"default",label:"Default"}];ne(y),B(H=>y.some(z=>z.value===H)?H:"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(H=>{if(y)return;if(H&&H!=="default"){B(H);return}let z=Gt(),ue=_i(z?.fontFamily,f());B(ue??"default");}),()=>{y=true;}},[r,e,t,Te]),useEffect(()=>{if(!t("fontSize")||typeof e.getFontSizeOptions!="function")return;let f=e.getFontSizeOptions().map(z=>({value:String(z.value).trim(),label:String(z.label).trim()})).filter(z=>z.value.length>0&&z.label.length>0),y=f.some(z=>Ue(z.value)==="default"),H=f.length===0?[{value:"default",label:"Default"}]:y?f:[{value:"default",label:"Default"},...f];Ie(H),se(z=>H.some(ue=>ue.value===z)?z:"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(H=>{if(y)return;if(H&&H!=="default"){se(H);return}let z=Gt(),ue=Vi(z?.fontSize,f());se(ue??"default");}),()=>{y=true;}},[r,e,t,Te]),useEffect(()=>{if(!t("lineHeight")||typeof e.getLineHeightOptions!="function")return;let f=e.getLineHeightOptions().map(y=>({value:y.value,label:y.label}));f.length>0&&ze(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(H=>{if(y)return;if(H){ce(H);return}let z=Gt(),ue=$i(z?.lineHeight,z?.fontSize,f());ce(ue??"default");}),()=>{y=true;}},[r,e,t,Te]),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&&be(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;}},[r,e,t,Te]),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&&ye(f);},[e,t]),useEffect(()=>{if(!t("textHighlight")||typeof e.getCurrentTextHighlight!="function")return;let f=false;return e.getCurrentTextHighlight().then(y=>{f||V(y??"default");}),()=>{f=true;}},[r,e,t,Te]);let ie=useMemo(()=>{if(!c||c.length===0)return [...Le];let f=new Set,y=[];for(let H of c)!Le.includes(H)||f.has(H)||(f.add(H),y.push(H));return y.length>0?y:[...Le]},[c]),ve=p?.trim()||"Paragraph",Ae=useMemo(()=>{let f=ie.map(y=>({value:y,label:`Heading ${y.slice(1)}`}));return [{value:"p",label:ve},...f]},[ie,ve]),M=r.isH1?"h1":r.isH2?"h2":r.isH3?"h3":r.isH4?"h4":r.isH5?"h5":r.isH6?"h6":"p",Be=Ae.some(f=>f.value===M)?M:"p",rt=f=>{f==="p"?e.toggleParagraph():f.startsWith("h")&&ie.includes(f)&&e.toggleHeading(f);},Ye=f=>{f==="default"?e.clearFontFamily?.():e.setFontFamily?.(f),B(f);},Ge=f=>{f==="default"?e.clearFontSize?.():e.setFontSize?.(f),se(f);},We=f=>{e.setLineHeight?.(f),ce(f);},v=(f,y)=>{f(H=>{let z=Wt(y),ue=H.filter(de=>Wt(de)!==z);return [y,...ue].slice(0,So)});},k=f=>{if(f==="default"){e.clearTextColor?.(),me("default");return}e.setTextColor?.(f),me(f);},K=f=>{if(f==="default"){e.clearTextHighlight?.(),V("default");return}e.setTextHighlight?.(f),V(f);},Z=f=>{switch(f){case "fontFamily":return t("fontFamily")?jsx(Tt,{value:X,onValueChange:Ye,options:he,placeholder:"Font"},"fontFamily"):null;case "fontSize":return t("fontSize")?jsx(Tt,{value:we,onValueChange:Ge,options:Fe,placeholder:"Size"},"fontSize"):null;case "lineHeight":return t("lineHeight")?jsx(Tt,{value:Ne,onValueChange:We,options:Pe,placeholder:"Line"},"lineHeight"):null;case "textColor":return t("textColor")?jsx(Vr,{title:"Text Color",value:Oe,options:He,recentColors:ge,active:r.hasCustomTextColor,fallbackColor:"#0f172a",onChange:k,onClear:()=>k("default"),onAddRecent:y=>v(F,y)},"textColor"):null;case "textHighlight":return t("textHighlight")?jsx(Vr,{title:"Text Highlight",value:w,options:ot,recentColors:ke,active:r.hasTextHighlight,fallbackColor:"#fef08a",highlight:true,onChange:K,onClear:()=>K("default"),onAddRecent:y=>v(qe,y)},"textHighlight"):null;case "bold":return jsx(L,{onClick:()=>e.toggleBold(),active:r.bold,title:"Bold (Ctrl+B)",children:jsx(At,{size:16})},"bold");case "italic":return jsx(L,{onClick:()=>e.toggleItalic(),active:r.italic,title:"Italic (Ctrl+I)",children:jsx(Dt,{size:16})},"italic");case "underline":return jsx(L,{onClick:()=>e.toggleUnderline(),active:r.underline,title:"Underline (Ctrl+U)",children:jsx(Kt,{size:16})},"underline");case "strikethrough":return jsx(L,{onClick:()=>e.toggleStrikethrough(),active:r.strikethrough,title:"Strikethrough",children:jsx(jt,{size:16})},"strikethrough");case "subscript":return t("subscript")?jsx(L,{onClick:()=>e.toggleSubscript?.(),active:r.subscript,title:"Subscript",children:jsx(hr,{size:16})},"subscript"):null;case "superscript":return t("superscript")?jsx(L,{onClick:()=>e.toggleSuperscript?.(),active:r.superscript,title:"Superscript",children:jsx(br,{size:16})},"superscript"):null;case "code":return jsx(L,{onClick:()=>e.formatText("code"),active:r.code,title:"Inline Code",children:jsx(Ut,{size:16})},"code");case "link":return jsx(L,{onClick:()=>r.isLink?e.removeLink():e.insertLink(),active:r.isLink,title:r.isLink?"Remove Link":"Insert Link",children:r.isLink?jsx(nt,{size:16}):jsx(dt,{size:16})},"link");case "blockFormat":return t("blockFormat")?jsx(Tt,{value:Be,onValueChange:rt,options:Ae,placeholder:"Format"},"blockFormat"):null;case "quote":return t("blockFormat")?jsx(L,{onClick:()=>e.toggleQuote(),active:r.isQuote,title:"Quote",children:jsx(qt,{size:16})},"quote"):null;case "alignLeft":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("left"),active:r.isTextAlignedLeft,title:"Align Left",children:jsx(ct,{size:16})},"alignLeft"):null;case "alignCenter":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("center"),active:r.isTextAlignedCenter,title:"Align Center",children:jsx(it,{size:16})},"alignCenter"):null;case "alignRight":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("right"),active:r.isTextAlignedRight,title:"Align Right",children:jsx(mt,{size:16})},"alignRight"):null;case "alignJustify":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("justify"),active:r.isTextAlignedJustify,title:"Justify",children:jsx(nr,{size:16})},"alignJustify"):null;case "codeBlock":return t("code")?jsx(L,{onClick:()=>e.toggleCodeBlock(),active:r.isInCodeBlock,title:"Code Block",children:jsx(tr,{size:16})},"codeBlock"):null;case "unorderedList":return t("list")?jsx(L,{onClick:()=>e.toggleUnorderedList(),active:r.unorderedList,title:"Bullet List",children:jsx(_t,{size:16})},"unorderedList"):null;case "orderedList":return t("list")?jsx(L,{onClick:()=>e.toggleOrderedList(),active:r.orderedList,title:"Numbered List",children:jsx($t,{size:16})},"orderedList"):null;case "checkList":return t("list")?jsx(L,{onClick:()=>e.toggleCheckList(),active:r.checkList,title:"Checklist",children:jsx(Vt,{size:16})},"checkList"):null;case "indentList":return t("list")?jsx(L,{onClick:()=>e.indentList(),title:"Indent List",disabled:r.checkList,children:jsx(cr,{size:14})},"indentList"):null;case "outdentList":return t("list")?jsx(L,{onClick:()=>e.outdentList(),title:"Outdent List",disabled:r.checkList,children:jsx(mr,{size:14})},"outdentList"):null;case "horizontalRule":return t("horizontalRule")?jsx(L,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(ir,{size:16})},"horizontalRule"):null;case "table":return t("table")?jsx(L,{onClick:()=>R(true),title:"Insert Table",children:jsx(lr,{size:16})},"table"):null;case "image":return t("image")?jsxs(Fragment,{children:[jsxs(St,{trigger:jsx("button",{className:`luthor-toolbar-button ${r.imageSelected?"active":""}`,title:"Insert Image",children:jsx(ho,{size:16})}),isOpen:_,onOpenChange:C,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertFromUrl(),C(false);},children:[jsx(dt,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertFromFile(),C(false);},children:[jsx(bo,{size:16}),jsx("span",{children:"Upload File"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertGifFromUrl(),C(false);},children:[jsx(yo,{size:16}),jsx("span",{children:"Insert GIF URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertGifFromFile(),C(false);},children:[jsx(bo,{size:16}),jsx("span",{children:"Upload GIF"})]})]},"image"),r.imageSelected&&jsxs(St,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(it,{size:16})}),isOpen:$,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(it,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setAlignment("right"),g(false);},children:[jsx(mt,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setCaption(),g(false);},children:[jsx(dr,{size:16}),jsx("span",{children:"Set Caption"})]})]},"imageAlign")]}):null;case "emoji":return !t("emoji")||Re.length===0?null:jsx(St,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Insert Emoji",children:jsx(yo,{size:16})}),isOpen:oe,onOpenChange:ae,children:jsx("div",{className:"luthor-emoji-picker-grid",role:"listbox","aria-label":"Emoji picker",children:Re.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),ae(false);},children:y.emoji},`${y.emoji}-${y.label}`))})},"emoji");case "embed":return P?jsxs(St,{trigger:jsx("button",{className:`luthor-toolbar-button ${U?"active":""}`,title:"Insert Embed",children:jsx(ar,{size:16})}),isOpen:I,onOpenChange:E,children:[t("iframeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{S.insertIframe(),E(false);},children:[jsx(dt,{size:16}),jsx("span",{children:"Embed iframe"})]}):null,t("youtubeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{S.insertYouTube(),E(false);},children:[jsx(ho,{size:16}),jsx("span",{children:"Embed YouTube Video"})]}):null]},"embed"):null;case "undo":return t("history")?jsx(L,{onClick:()=>e.undo(),disabled:!r.canUndo,title:"Undo (Ctrl+Z)",children:jsx(or,{size:16})},"undo"):null;case "redo":return t("history")?jsx(L,{onClick:()=>e.redo(),disabled:!r.canRedo,title:"Redo (Ctrl+Y)",children:jsx(rr,{size:16})},"redo"):null;case "commandPalette":return jsx(L,{onClick:()=>n?.(),title:"Command Palette (Ctrl+Shift+P)",children:jsx(Jt,{size:16})},"commandPalette");case "themeToggle":return jsx(L,{onClick:l,title:o?"Light Mode":"Dark Mode",children:o?jsx(gr,{size:16}):jsx(fr,{size:16})},"themeToggle");default:return null}},q=d??zt,Qe=useMemo(()=>Wi(q,t,b),[q,t,b]);return jsxs(Fragment,{children:[jsx("div",{className:a?.toolbar??"luthor-toolbar",style:u,children:Qe.sections.map((f,y)=>{let H=f.items.map((z,ue)=>{let de=Z(z);return de?Array.isArray(de)?de.map((W,Bt)=>W&&typeof W=="object"&&"key"in W&&W.key!=null?W:jsx("span",{children:W},`toolbar-item-${y}-${ue}-${Bt}`)):de.type===zi.Fragment?jsx("span",{children:de},`toolbar-item-${y}-${ue}`):de&&typeof de=="object"&&"key"in de&&de.key!=null?de:jsx("span",{children:de},`toolbar-item-${y}-${ue}`):null}).flat().filter(z=>z!==null);return H.length===0?null:jsx("div",{className:a?.section??"luthor-toolbar-section",children:H},y)})}),jsx("input",{ref:h,type:"file",accept:"image/*",onChange:m.handleUpload,className:"luthor-file-input"}),jsx("input",{ref:O,type:"file",accept:"image/gif",onChange:m.handleGifUpload,className:"luthor-file-input"}),jsx(Ir,{isOpen:D,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:G.rows,onChange:f=>Se(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:G.columns,onChange:f=>Se(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:G.includeHeaders||false,onChange:f=>Se(y=>({...y,includeHeaders:f.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(Co,{variant:"secondary",onClick:()=>R(false),children:"Cancel"}),jsx(Co,{variant:"primary",onClick:()=>{e.insertTable(G),R(false);},children:"Insert Table"})]})]})})]})}var Ho=["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"],Qr={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 Nt(e){let t={...Qr};if(!e)return t;for(let r of Ho)typeof e[r]=="boolean"&&(t[r]=e[r]);return t}function Xr(e,t){return e[t]!==false}var Yr=[{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"}],Ll={value:"default",label:"Default",fontFamily:"inherit"},Gr=[{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"}],wl={value:"default",label:"Default",fontSize:"inherit"},Wr=[{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"}],Fl={value:"default",label:"Default",lineHeight:"1.5"},It="1.5",Il=1;function st(e){return e.trim().toLowerCase()}function Zr(e){return /^[a-z0-9][a-z0-9-]*$/i.test(e)}function Nl(e){return st(e)==="default"?true:Xt(e)!==null}function Pl(e){let t=e??Yr,r=new Set,o=[];for(let n of t){let i=n.value.trim(),a=n.label.trim(),u=n.fontFamily.trim();if(!i||!a||!u||!Zr(i))continue;let d=st(i);r.has(d)||(r.add(d),o.push({value:i,label:a,fontFamily:u,cssImportUrl:n.cssImportUrl?.trim()||void 0}));}return o.length===0?Yr:o.some(n=>st(n.value)==="default")?o:[Ll,...o]}function Ol(e){let t=e??Gr,r=new Set,o=[];for(let n of t){let i=String(n.value).trim(),a=String(n.label).trim(),u=String(n.fontSize).trim();if(!i||!a||!u||!Zr(i))continue;let d=st(i);r.has(d)||(r.add(d),o.push({value:i,label:a,fontSize:u}));}return o.length===0?Gr:o.some(n=>st(n.value)==="default")?o:[wl,...o]}function Xt(e){let t=e.trim();if(!/^\d*\.?\d+$/.test(t))return null;let r=Number(t);return !Number.isFinite(r)||r<Il?null:r.toString()}function Hl(e){return typeof e=="number"?Number.isFinite(e)?Xt(e.toString())??It:It:typeof e=="string"?Xt(e)??It:It}function Rl(e,t=It){let r=e??Wr,o=new Set,l=[];for(let i of r){let a=String(i.value).trim(),u=String(i.label).trim();if(!a||!u||!Nl(a))continue;let d=st(a);if(o.has(d))continue;if(d==="default"){o.add(d),l.push({value:a,label:u,lineHeight:t});continue}let b=Xt(String(i.lineHeight));b&&(o.add(d),l.push({value:a,label:u,lineHeight:b}));}return l.length===0?Wr:l.some(i=>st(i.value)==="default")?l:[{...Fl,lineHeight:t},...l]}function tt({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 Bl=()=>jsxs(tt,{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"})]}),zl=()=>jsxs(tt,{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"})]}),Ml=()=>jsxs(tt,{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"})]}),Al=()=>jsxs(tt,{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"})]}),Dl=()=>jsxs(tt,{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"})]}),Kl=()=>jsxs(tt,{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"})]}),jl=()=>jsxs(tt,{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"})]}),Ul=()=>jsxs(tt,{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"})]}),Zt=new ImageExtension;Zt.config={...Zt.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var wo=new TableExtension;wo.config={...wo.config,enableContextMenu:true,tableBubbleRenderer:({headersEnabled:e,setHeadersEnabled:t,actions:r})=>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:r.insertRowAbove,children:jsx(Bl,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert row below","aria-label":"Insert row below",onClick:r.insertRowBelow,children:jsx(zl,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column left","aria-label":"Insert column left",onClick:r.insertColumnLeft,children:jsx(Ml,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column right","aria-label":"Insert column right",onClick:r.insertColumnRight,children:jsx(Al,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected row","aria-label":"Delete selected row",onClick:r.deleteSelectedRow,children:jsx(Dl,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected column","aria-label":"Delete selected column",onClick:r.deleteSelectedColumn,children:jsx(Kl,{})}),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(Ul,{})})}),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:r.deleteTable,children:jsx(jl,{})})]})};var Fo=new IframeEmbedExtension;Fo.config={...Fo.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center"};var Io=new YouTubeEmbedExtension;Io.config={...Io.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center",nocookie:true,controls:true,rel:1};var _l=Pr(),No=new ContextMenuExtension;No.config={...No.config,preventDefault:true};var Vl=new CommandPaletteExtension,$l=new SlashCommandExtension,Jl=new EmojiExtension,Po=new DraggableBlockExtension;Po.config={...Po.config,buttonStackPosition:"left"};var Oo=new LinkExtension;Oo.config={...Oo.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var ql=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"}]}),Yl=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:Gl}=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 en({fontFamilyOptions:e,fontSizeOptions:t,lineHeightOptions:r,minimumDefaultLineHeight:o,featureFlags:l,isDraggableBoxEnabled:n,scaleByRatio:i,syntaxHighlighting:a,codeHighlightProvider:u,loadCodeHighlightProvider:d,maxAutoDetectCodeLength:b,isCopyAllowed:c,languageOptions:p}={}){let m=Nt(l),h=oe=>Xr(m,oe),O=(n??true)&&h("draggableBlock"),S=Hl(o),P=new FontFamilyExtension().configure({options:Pl(e),cssLoadStrategy:"on-demand"}),U=new FontSizeExtension().configure({options:Ol(t)}),_=new LineHeightExtension().configure({options:Rl(r,S),defaultLineHeight:S});Zt.configure({scaleByRatio:i??false}),codeExtension.configure({syntaxHighlighting:a??"auto",provider:u??void 0,loadProvider:d}),codeIntelligenceExtension.configure({provider:u??void 0,loadProvider:d,maxAutoDetectLength:b,isCopyAllowed:c??true,languageOptions:p});let C=[];return h("bold")&&C.push(boldExtension),h("italic")&&C.push(italicExtension),h("underline")&&C.push(underlineExtension),h("strikethrough")&&C.push(strikethroughExtension),h("fontFamily")&&C.push(P),h("fontSize")&&C.push(U),h("lineHeight")&&C.push(_),h("textColor")&&C.push(ql),h("textHighlight")&&C.push(Yl),h("subscript")&&C.push(subscriptExtension),h("superscript")&&C.push(superscriptExtension),h("link")&&C.push(Oo),h("horizontalRule")&&C.push(horizontalRuleExtension),h("table")&&C.push(wo),h("list")&&C.push(listExtension),h("history")&&C.push(historyExtension),h("image")&&C.push(Zt),h("blockFormat")&&C.push(blockFormatExtension),h("code")&&C.push(codeExtension),h("codeIntelligence")&&C.push(codeIntelligenceExtension),h("codeFormat")&&C.push(codeFormatExtension),h("tabIndent")&&C.push(tabIndentExtension),h("enterKeyBehavior")&&C.push(enterKeyBehaviorExtension),h("iframeEmbed")&&C.push(Fo),h("youTubeEmbed")&&C.push(Io),h("floatingToolbar")&&C.push(_l),h("contextMenu")&&C.push(No),h("commandPalette")&&C.push(Vl),h("slashCommand")&&C.push($l),h("emoji")&&C.push(Jl),O&&C.push(Po),h("customNode")&&C.push(Gl),C}function Q(e){return en(e)}var eo=en();function tn(e){if(!e)return "__default__";let t=Object.entries(e).filter(([,r])=>typeof r=="string"&&r.trim().length>0).sort(([r],[o])=>r.localeCompare(o));return t.length>0?JSON.stringify(t):"__default__"}function on(e){if(!e)return;let t={},r=(o,l)=>{typeof l=="string"&&l.trim().length>0&&(t[o]=l.trim());};return r("--luthor-fg",e.font?.color),r("--luthor-text-bold-color",e.font?.boldColor),r("--luthor-link-color",e.link?.color),r("--luthor-list-marker-color",e.list?.markerColor),r("--luthor-list-checkbox-color",e.list?.checkboxColor),r("--luthor-quote-bg",e.quote?.backgroundColor),r("--luthor-quote-fg",e.quote?.color),r("--luthor-quote-border",e.quote?.indicatorColor),r("--luthor-table-border-color",e.table?.borderColor),r("--luthor-table-header-bg",e.table?.headerBackgroundColor),r("--luthor-hr-color",e.hr?.color),r("--luthor-placeholder-color",e.placeholder?.color),r("--luthor-codeblock-bg",e.codeblock?.backgroundColor),r("--luthor-toolbar-bg",e.toolbar?.backgroundColor),Object.keys(t).length>0?t:void 0}function rn(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 nn(e,t){if(e.key.toLowerCase()!==t.key.toLowerCase())return false;let r=e.ctrlKey||e.metaKey;return !(!!t.requiresPrimary!==r||!!t.shift!=!!e.shiftKey||!!t.alt!=!!e.altKey)}function ln(e,t,r){let o={...e??{}};for(let[l,n]of Object.entries(r))(Array.isArray(n)?n:[n]).some(u=>t[u]!==false)||(o[l]=false);return o}function an(e,t,r){let o={...e},l=(n,i)=>{t[n]===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;}),r&&(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 to(e){return new Set(e)}function oo(e,t){e.clear();for(let r of t)e.add(r);}function ro(e,t){return e.has(t)}function Pt(e,t){e.add(t);}var N=(e,t=0,r="")=>({type:"text",version:1,text:e,detail:0,format:t,mode:"normal",style:r}),pe=(e,t="",r=0)=>({type:"paragraph",version:1,format:t,indent:r,direction:null,children:e}),Ro={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: JSONB-First Feature Showcase")]},pe([N("This starter content is now a native "),N("JSONB",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")]},pe([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)]),pe([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 JSONB 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:[pe([N("Bullet item with styled text",0,"color: #16a34a;")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[pe([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:[pe([N("Numbered item 1")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[pe([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:[pe([N("Checked task item")])]},{type:"listitem",version:1,value:2,checked:false,format:"",indent:0,direction:null,children:[pe([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:" jsonb",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([N("Feature")])]},{type:"tablecell",version:1,headerState:3,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[pe([N("Status")])]}]},{type:"tablerow",version:1,children:[{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:240,backgroundColor:null,children:[pe([N("Visual \u2194 JSONB switching")])]},{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[pe([N("Round-trip ready \u2705")])]}]}]},pe([N("Use the toolbar, floating toolbar, slash commands (/), and command palette (Ctrl/Cmd+Shift+P) to explore the full preset.")])]}};JSON.stringify(Ro);var{Provider:ia,useEditor:la}=createEditorSystem(),sn="Write anything...",un="Enter JSONB document content...";function aa(e){let r=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:(r.length>0?r:[""]).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 sa(e){try{let t=JSON.parse(e);return JSON.stringify(t)}catch{return JSON.stringify(aa(e))}}function ua(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 da(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 ca(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 ma(e){if(typeof e=="number")return !Number.isFinite(e)||e<1?"1.5":e.toString();if(typeof e=="string"){let r=e.trim();if(r.length===0)return "1.5";let o=Number(r);return !Number.isFinite(o)||o<1?"1.5":o.toString()}return "1.5"}function Bo(e){return tn(e)}function ga(e){if(!e)return "__default__";if(Array.isArray(e))return JSON.stringify({mode:"append",values:e.map(o=>o.trim())});let t=e,r=Array.isArray(t.values)?t.values:[];return JSON.stringify({mode:t.mode??"append",values:r.map(o=>o.trim())})}function fa(e){return on(e)}function pa(e){let t=Nt(e);return JSON.stringify(Ho.map(r=>[r,t[r]]))}function dn(e){return rn(e)}var ha=[{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 ba(e,t){return nn(e,t)}function ya(e,t,r){return an(e,t,r)}var va={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 Ca(e,t){return ln(e,t,va)}function Ea(e){if(!e||e.length===0)return [...Le];let t=new Set,r=[];for(let o of e)!Le.includes(o)||t.has(o)||(t.add(o),r.push(o));return r.length>0?r:[...Le]}function xa(e){if(!e)return "__default__";if(Array.isArray(e)){let n=new Set,i=[];for(let a of e)for(let[u,d]of Object.entries(a)){let b=u.trim();!d||!b||n.has(b)||(n.add(b),i.push(b));}return i.length===0?"__default__":JSON.stringify({allowlist:i,denylist:[]})}let t=n=>{if(!n||n.length===0)return [];let i=new Set,a=[];for(let u of n){let d=u.trim();!d||i.has(d)||(i.add(d),a.push(d));}return a},r=e,o=t(r.allowlist),l=t(r.denylist);return o.length===0&&l.length===0?"__default__":JSON.stringify({allowlist:o,denylist:l})}function ka(e){if(!e||e.length===0)return [];let t=new Set,r=[];for(let o of e){let l=o.trim();!l||t.has(l)||(t.add(l),r.push(l));}return r}function Ta(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 Sa(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)):[],r=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,u)=>{let d=`${a.key}:${a.ctrlKey?1:0}:${a.metaKey?1:0}:${a.shiftKey?1:0}:${a.altKey?1:0}`,b=`${u.key}:${u.ctrlKey?1:0}:${u.metaKey?1:0}:${u.shiftKey?1:0}:${u.altKey?1:0}`;return d.localeCompare(b)});return i.length===0?[o,false]:[o,i]}).sort(([o],[l])=>o.localeCompare(l)):[];return JSON.stringify({disabledCommandIds:t,bindings:r,preventCollisions:e.preventCollisions!==false,preventNativeConflicts:e.preventNativeConflicts!==false})}function La({isDark:e,toggleTheme:t,visualPlaceholder:r,jsonbPlaceholder:o,initialMode:l,availableModes:n,onReady:i,toolbarLayout:a,toolbarVisibility:u,toolbarPosition:d,toolbarAlignment:b,toolbarClassName:c,toolbarStyleVars:p,isToolbarEnabled:m,headingOptions:h,paragraphLabel:O,syncHeadingOptionsWithCommands:S,slashCommandVisibility:P,shortcutConfig:U,commandPaletteShortcutOnly:_,featureFlags:C}){let{commands:oe,hasExtension:ae,activeStates:$,lexical:g,extensions:I,export:E,import:D}=la(),[R,X]=useState(l),[B,he]=useState({jsonb:""}),[ne,we]=useState(null),[se,Fe]=useState(null),[Ie,Ne]=useState({isOpen:false,commands:[]}),[ce,Pe]=useState({isOpen:false,query:"",position:null,commands:[]}),[ze,Oe]=useState({isOpen:false,query:"",position:null,suggestions:[]}),me=useRef(false),He=useMemo(()=>Ea(h),[h]),be=S?He:void 0,ge=S?O:void 0,F=$.isInCodeBlock===true,w=useMemo(()=>ya(oe,C,F),[oe,C,F]),V=useMemo(()=>v=>Object.prototype.hasOwnProperty.call(C,v)?C[v]!==false:true,[C]),ot=useMemo(()=>Ca(u,C),[u,C]),ye=C.draggableBlock!==false,ke=xa(P),qe=useRef(P),Te=useRef(ke),Me=Sa(U),G=useRef(U),Se=useRef(Me),Re=useMemo(()=>ka(U?.disabledCommandIds),[U?.disabledCommandIds]),ie=useMemo(()=>new Set(Re),[Re]),ve=useMemo(()=>ie.size===0?[]:po({headingOptions:be,paragraphLabel:ge,isFeatureEnabled:V}).filter(v=>ie.has(v.id)).flatMap(v=>v.shortcuts??[]),[ie,be,ge,V]);Te.current!==ke&&(Te.current=ke,qe.current=P),Se.current!==Me&&(Se.current=Me,G.current=U);let Ae=useRef(to(["visual"])),M=useRef(0);useEffect(()=>{Eo(w,$,e?"dark":"light",V);},[w,$,e,V]);let Be=useMemo(()=>({injectJSONB:v=>{setTimeout(()=>{try{let k=JSON.parse(v);D.fromJSON(k);}catch(k){console.error("Failed to inject JSONB:",k);return}},100);},getJSONB:()=>To(JSON.stringify(E.toJSON()))}),[E,D]);useEffect(()=>{if(!g||!w)return;let v=w,k=Qo(v,{headingOptions:be,paragraphLabel:ge,isFeatureEnabled:V,shortcutConfig:G.current,commandPaletteShortcutOnly:_});typeof v.registerCommand=="function"&&k.forEach(q=>v.registerCommand(q));let K=Xo(v,{headingOptions:be,paragraphLabel:ge,slashCommandVisibility:qe.current,isFeatureEnabled:V,shortcutConfig:G.current});typeof v.setSlashCommands=="function"?v.setSlashCommands(K):K.forEach(q=>v.registerSlashCommand?.(q));let Z=er(v,document.body,{headingOptions:be,paragraphLabel:ge,isFeatureEnabled:V,shortcutConfig:G.current,scope:()=>g.getRootElement()});return me.current||(me.current=true,i?.(Be)),()=>{Z(),typeof v.unregisterCommand=="function"&&k.forEach(q=>v.unregisterCommand(q.id)),typeof v.setSlashCommands=="function"?v.setSlashCommands([]):K.forEach(q=>v.unregisterSlashCommand?.(q.id));}},[g,w,Be,i,be,ge,ke,Me,V,_]),useEffect(()=>{let v=()=>g?.getRootElement(),k=ha.filter(Z=>C[Z.feature]===false);if(k.length===0)return;let K=Z=>{let q=v();q&&Z.target instanceof Node&&!q.contains(Z.target)||!dn(Z.target)||!k.some(f=>ba(Z,f))||(Z.preventDefault(),Z.stopPropagation());};return document.addEventListener("keydown",K,true),()=>{document.removeEventListener("keydown",K,true);}},[g,C]),useEffect(()=>{let v=I.find(k=>k.name==="commandPalette");if(!(!v||!v.subscribe))return v.subscribe((k,K)=>{let Z=K.filter(q=>ie.has(q.id)?false:_?typeof q.shortcut=="string"&&q.shortcut.trim().length>0:true);Ne({isOpen:k,commands:Z});})},[I,ie,_]),useEffect(()=>{if(ve.length===0)return;let v=()=>g?.getRootElement(),k=K=>{let Z=v();Z&&K.target instanceof Node&&!Z.contains(K.target)||!dn(K.target)||!ve.some(Qe=>Ta(K,Qe))||(K.preventDefault(),K.stopPropagation());};return document.addEventListener("keydown",k,true),()=>{document.removeEventListener("keydown",k,true);}},[g,ve]),useEffect(()=>{let v=I.find(k=>k.name==="slashCommand");if(!(!v||!v.subscribe))return v.subscribe(k=>{Pe({isOpen:k.isOpen,query:k.query,position:k.position,commands:k.commands});})},[I]),useEffect(()=>{let v=I.find(k=>k.name==="emoji");if(!(!v||!v.subscribe))return v.subscribe(k=>{Oe({isOpen:k.isOpen,query:k.query,position:k.position,suggestions:k.suggestions});})},[I]),useEffect(()=>!g||!E?void 0:g.registerUpdateListener(()=>{M.current+=1,oo(Ae.current,["visual"]);}),[g,E]);let rt=async v=>{if(n.includes(v))try{if(Fe(null),R==="jsonb"&&v!=="jsonb"){let k=JSON.parse(B.jsonb);D.fromJSON(k),await new Promise(K=>setTimeout(K,50));}if(R==="visual"&&v!=="visual"&&(g&&clearLexicalSelection(g),g?.getRootElement()?.blur()),X(v),v==="jsonb"&&R!=="jsonb"&&!ro(Ae.current,"jsonb")){we("jsonb"),await new Promise(k=>setTimeout(k,50));try{let k=To(JSON.stringify(E.toJSON()));he(K=>({...K,jsonb:k})),Pt(Ae.current,"jsonb");}finally{we(null);}}v==="visual"&&setTimeout(()=>g?.focus(),100);}catch(k){let K=k instanceof Error?k.message:"Invalid format - could not parse content";Fe({mode:R,error:K});}},Ye=m?jsx($r,{commands:w,hasExtension:v=>ae(v),activeStates:$,isDark:e,toggleTheme:t,onCommandPaletteOpen:()=>{C.commandPalette!==false&&w.showCommandPalette();},imageUploadHandler:v=>I.find(k=>k.name==="image")?.config?.uploadHandler?.(v)??Promise.resolve(URL.createObjectURL(v)),layout:a??zt,toolbarVisibility:ot,toolbarStyleVars:p,headingOptions:He,paragraphLabel:O,classNames:{toolbar:`luthor-toolbar luthor-toolbar--align-${b}${c?` ${c}`:""}`}}):null,Ge=R==="visual"&&m&&d==="top",We=R==="visual"&&m&&d==="bottom";return jsxs(Fragment,{children:[jsxs("div",{className:"luthor-editor-header",children:[jsx(Ar,{mode:R,onModeChange:rt,availableModes:n,isConverting:ne}),Ge&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--top",children:Ye})]}),jsxs("div",{className:`luthor-editor${ye?"":" luthor-editor--draggable-disabled"}`,"data-mode":R,children:[jsxs("div",{className:`luthor-editor-visual-shell${R==="visual"?"":" is-hidden"}${ye?"":" luthor-editor-visual-shell--no-gutter"}`,"aria-hidden":R!=="visual",children:[ye&&jsx("div",{className:"luthor-editor-visual-gutter","aria-hidden":"true"}),jsx(RichText,{placeholder:r,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:[se&&se.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 JSONB"}),jsx("p",{children:se.error}),jsx("small",{children:"Fix the errors above and try switching modes again"})]})]}),R==="jsonb"&&jsx(Dr,{value:B.jsonb,onChange:v=>he(k=>({...k,jsonb:v})),placeholder:o})]})]}),jsx(Mr,{editor:g,commands:w,editorTheme:e?"dark":"light",disabled:R!=="visual"}),We&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--bottom",children:Ye}),jsx(xr,{isOpen:Ie.isOpen,onClose:()=>w.hideCommandPalette(),commands:Ie.commands}),jsx(wr,{isOpen:ce.isOpen,query:ce.query,position:ce.position,commands:ce.commands,onClose:()=>w.closeSlashMenu?.(),onExecute:v=>{w.executeSlashCommand?.(v);}}),jsx(Tr,{isOpen:ze.isOpen,query:ze.query,position:ze.position,suggestions:ze.suggestions,onClose:()=>w.closeEmojiSuggestions?.(),onExecute:v=>{w.executeEmojiSuggestion?.(v);}})]})}var te=forwardRef(({className:e,onReady:t,initialTheme:r="light",theme:o,defaultContent:l,showDefaultContent:n=true,placeholder:i=sn,initialMode:a="visual",availableModes:u=["visual","jsonb"],variantClassName:d,toolbarLayout:b,toolbarVisibility:c,toolbarPosition:p="top",toolbarAlignment:m="left",toolbarClassName:h,toolbarStyleVars:O,quoteClassName:S,quoteStyleVars:P,defaultSettings:U,editorThemeOverrides:_,isToolbarEnabled:C=true,fontFamilyOptions:oe,fontSizeOptions:ae,lineHeightOptions:$,minimumDefaultLineHeight:g=1.5,scaleByRatio:I=false,headingOptions:E,paragraphLabel:D,syncHeadingOptionsWithCommands:R=true,slashCommandVisibility:X,shortcutConfig:B,commandPaletteShortcutOnly:he=false,isDraggableBoxEnabled:ne,featureFlags:we,syntaxHighlighting:se,codeHighlightProvider:Fe,loadCodeHighlightProvider:Ie,maxAutoDetectCodeLength:Ne,isCopyAllowed:ce=true,languageOptions:Pe},ze)=>{let[Oe,me]=useState(r),He=Oe==="dark",be=u.includes(a)?a:u[0]??"visual",ge=()=>me(He?"light":"dark"),F=useMemo(()=>typeof i=="string"?{visual:i,jsonb:un}:{visual:i.visual??sn,jsonb:i.jsonb??un},[i]);useEffect(()=>{me(r);},[r]);let w=useMemo(()=>ua(oe),[oe]),V=useMemo(()=>da(ae),[ae]),ot=useMemo(()=>ca($),[$]),ye=useMemo(()=>ma(g),[g]),ke=se??"unset",qe=typeof Ne=="number"?Ne.toString():"unset",Te=useMemo(()=>ga(Pe),[Pe]),Me=ce?"copy-on":"copy-off",G=useMemo(()=>typeof ne!="boolean"?we:{...we??{},draggableBlock:ne},[we,ne]),Se=useMemo(()=>pa(G),[G]),Re=useMemo(()=>Nt(G),[G]),ie=`${w}::${V}::${ot}::${ye}::${I?"ratio-on":"ratio-off"}::${ke}::${qe}::${Me}::${Te}::${Se}`,ve=useRef(oe),Ae=useRef(ae),M=useRef($),Be=useRef(g),rt=useRef(G),Ye=useRef(Pe),Ge=useRef(Fe),We=useRef(Ie),v=useRef(ie);(v.current!==ie||Ge.current!==Fe||We.current!==Ie)&&(v.current=ie,ve.current=oe,Ae.current=ae,M.current=$,Be.current=g,rt.current=G,Ye.current=Pe,Ge.current=Fe,We.current=Ie);let k=useRef(null);if(!k.current||k.current.key!==ie){let W={fontFamilyOptions:ve.current,fontSizeOptions:Ae.current,lineHeightOptions:M.current,minimumDefaultLineHeight:Be.current,scaleByRatio:I,...se!==void 0?{syntaxHighlighting:se}:{},...Ge.current!==void 0?{codeHighlightProvider:Ge.current}:{},...We.current!==void 0?{loadCodeHighlightProvider:We.current}:{},...Ne!==void 0?{maxAutoDetectCodeLength:Ne}:{},isCopyAllowed:ce,...Ye.current!==void 0?{languageOptions:Ye.current}:{},...typeof ne=="boolean"?{isDraggableBoxEnabled:ne}:{},...rt.current?{featureFlags:rt.current}:{}};k.current={key:ie,value:Q(W)};}let K=k.current.value,Z=useMemo(()=>{let W=mergeThemes(defaultLuthorTheme,o??{});return S?{...W,quote:`${W.quote??""} ${S}`.trim()}:W},[o,S]),q=useMemo(()=>Bo(_),[_]),Qe=useMemo(()=>Bo(P),[P]),f=useMemo(()=>fa(U),[U]),y=useMemo(()=>Bo(f),[f]),H=useMemo(()=>{let W=f,Bt=createEditorThemeStyleVars(_),Jo=P,qo={"--luthor-default-line-height":ye};return !W&&!Bt&&!Jo?qo:{...W??{},...Bt,...Jo??{},...qo}},[ye,f,_,P,y,q,Qe]),[z,ue]=useState(null);useImperativeHandle(ze,()=>z,[z]);let de=W=>{ue(W),n&&l===void 0?W.injectJSONB(JSON.stringify(Ro)):l&&W.injectJSONB(sa(l)),t?.(W);};return jsx("div",{className:`luthor-preset luthor-preset-extensive luthor-editor-wrapper ${d||""} ${e||""}`.trim(),"data-editor-theme":Oe,style:H,children:jsx(ia,{extensions:K,config:{theme:Z},children:jsx(La,{isDark:He,toggleTheme:ge,visualPlaceholder:F.visual,jsonbPlaceholder:F.jsonb,initialMode:be,availableModes:u,onReady:de,toolbarLayout:b,toolbarVisibility:c,toolbarPosition:p,toolbarAlignment:m,toolbarClassName:h,toolbarStyleVars:O,isToolbarEnabled:C,headingOptions:E,paragraphLabel:D,syncHeadingOptionsWithCommands:R,slashCommandVisibility:X,shortcutConfig:B,commandPaletteShortcutOnly:he,featureFlags:Re})})})});te.displayName="ExtensiveEditor";var cn=["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"],no={id:"extensive",label:"Extensive",description:"All features enabled for power users.",extensions:[...eo],components:{Editor:te},toolbar:[...cn],config:ee("extensive","Write anything..."),css:"extensive/styles.css"};function mn(e={}){return {...no,extensions:[...Q({fontFamilyOptions:e.fontFamilyOptions,fontSizeOptions:e.fontSizeOptions,lineHeightOptions:e.lineHeightOptions,minimumDefaultLineHeight:e.minimumDefaultLineHeight,isCopyAllowed:e.isCopyAllowed,languageOptions:e.languageOptions})]}}var Ia={bold:false,italic:false,underline:false,strikethrough:false,fontFamily:false,fontSize:false,lineHeight:false,textColor:false,textHighlight:false,subscript:false,superscript:false,link:false,horizontalRule:false,table:false,list:false,image:false,blockFormat:false,code:false,codeIntelligence:false,codeFormat:false,iframeEmbed:false,youTubeEmbed:false,floatingToolbar:false,contextMenu:false,commandPalette:false,slashCommand:false,emoji:false,draggableBlock:false,customNode:false,themeToggle:false},Ot=forwardRef(({className:e,variantClassName:t,hideToolbarByDefault:r=true,isToolbarEnabled:o,...l},n)=>jsx(te,{ref:n,...l,className:["luthor-preset-simple-text",e].filter(Boolean).join(" "),variantClassName:["luthor-preset-simple-text__variant",t].filter(Boolean).join(" "),availableModes:["visual"],initialMode:"visual",isToolbarEnabled:r?false:o,featureFlags:Ia}));Ot.displayName="SimpleTextEditor";var zo={id:"simple-text",label:"Simple Text",description:"Plain text writing with rich formatting disabled.",extensions:Q({featureFlags:{bold:false,italic:false,underline:false,strikethrough:false,link:false,list:false,blockFormat:false,image:false,table:false,code:false,codeFormat:false,commandPalette:false,slashCommand:false,emoji:false,draggableBlock:false}}),components:{Editor:Ot},toolbar:[],config:ee("simple-text","Write plain text..."),css:"simple-text/styles.css"};var Oa={bold:true,italic:true,underline:true,strikethrough:true,list:true,history:true,link:true,blockFormat:true,codeFormat:true,image:false,table:false,iframeEmbed:false,youTubeEmbed:false,emoji:false,floatingToolbar:false,contextMenu:false,commandPalette:false,slashCommand:false,draggableBlock:false,customNode:false},Ht=forwardRef(({className:e,variantClassName:t,compactToolbar:r=false,toolbarClassName:o,featureFlags:l,...n},i)=>jsx(te,{ref:i,...n,className:["luthor-preset-rich-text-box",e].filter(Boolean).join(" "),variantClassName:[r?"luthor-preset-rich-text-box--compact":"",t].filter(Boolean).join(" "),toolbarClassName:[r?"luthor-preset-rich-text-box__toolbar--compact":"",o].filter(Boolean).join(" "),featureFlags:{...Oa,...l??{}}}));Ht.displayName="RichTextBoxEditor";var Mo={id:"rich-text-box",label:"Rich Text Box",description:"Inline formatting and list-focused rich text editing.",extensions:Q({featureFlags:{image:false,table:false,iframeEmbed:false,youTubeEmbed:false,emoji:false,commandPalette:false,slashCommand:false,draggableBlock:false}}),components:{Editor:Ht},toolbar:["bold","italic","underline","strikethrough","unorderedList","orderedList","checkList","undo","redo"],config:ee("rich-text-box","Write rich text..."),css:"rich-text-box/styles.css"};function lo({className:e,variantClassName:t,onSend:r,submitOnEnter:o=true,allowShiftEnter:l=true,showVoiceButton:n=false,showImageButton:i=true,showSendButton:a=true,...u}){let d=useRef(null),b=useCallback(()=>{r&&r({jsonb:d.current?.getJSONB()??""});},[r]),c=useCallback(p=>{!o||p.key!=="Enter"||p.nativeEvent.isComposing||p.shiftKey&&l||(p.preventDefault(),b());},[l,b,o]);return jsxs("div",{className:["luthor-preset-chat-window",e].filter(Boolean).join(" "),onKeyDownCapture:c,children:[jsx(te,{ref:d,...u,variantClassName:["luthor-preset-chat-window__variant",t].filter(Boolean).join(" "),isToolbarEnabled:false,availableModes:["visual"],initialMode:"visual",featureFlags:{bold:false,italic:false,underline:false,strikethrough:false,fontFamily:false,fontSize:false,lineHeight:false,textColor:false,textHighlight:false,subscript:false,superscript:false,link:true,horizontalRule:false,table:false,list:true,image:false,blockFormat:false,code:false,codeIntelligence:false,codeFormat:false,iframeEmbed:false,youTubeEmbed:false,floatingToolbar:false,contextMenu:false,commandPalette:false,slashCommand:false,emoji:true,draggableBlock:false,customNode:false,themeToggle:false}}),jsxs("div",{className:"luthor-chat-window-actions","data-testid":"chat-actions",children:[n&&jsx("button",{type:"button",className:"luthor-chat-window-action","data-testid":"chat-voice-button","aria-label":"Voice input",children:"Voice"}),i&&jsx("button",{type:"button",className:"luthor-chat-window-action","data-testid":"chat-image-button","aria-label":"Add image",children:"Image"}),a&&jsx("button",{type:"button",className:"luthor-chat-window-action luthor-chat-window-action-send","data-testid":"chat-send-button",onClick:b,"aria-label":"Send message",children:"Send"})]})]})}var Ao={id:"chat-window",label:"Chat Window",description:"Chat composer with action row and send controls.",extensions:Q({featureFlags:{bold:false,italic:false,underline:false,strikethrough:false,table:false,image:false,blockFormat:false,code:false,codeIntelligence:false,codeFormat:false,iframeEmbed:false,youTubeEmbed:false,commandPalette:false,slashCommand:false,draggableBlock:false,customNode:false}}),components:{Editor:lo},toolbar:[],config:ee("chat-window","Write a message..."),css:"chat-window/styles.css"};function ao({className:e,variantClassName:t,showTo:r=true,showCc:o=false,showBcc:l=false,showSubject:n=true,...i}){return jsxs("div",{className:["luthor-preset-email-compose",e].filter(Boolean).join(" "),children:[jsxs("div",{className:"luthor-email-compose-shell",children:[r&&jsxs("label",{className:"luthor-email-compose-row","data-testid":"email-row-to",children:[jsx("span",{children:"To"}),jsx("input",{type:"text",readOnly:true,value:""})]}),o&&jsxs("label",{className:"luthor-email-compose-row","data-testid":"email-row-cc",children:[jsx("span",{children:"Cc"}),jsx("input",{type:"text",readOnly:true,value:""})]}),l&&jsxs("label",{className:"luthor-email-compose-row","data-testid":"email-row-bcc",children:[jsx("span",{children:"Bcc"}),jsx("input",{type:"text",readOnly:true,value:""})]}),n&&jsxs("label",{className:"luthor-email-compose-row","data-testid":"email-row-subject",children:[jsx("span",{children:"Subject"}),jsx("input",{type:"text",readOnly:true,value:""})]})]}),jsx(te,{...i,variantClassName:["luthor-preset-email-compose__variant",t].filter(Boolean).join(" "),featureFlags:{bold:true,italic:true,underline:true,strikethrough:false,link:true,list:true,history:true,blockFormat:true,table:false,image:false,iframeEmbed:false,youTubeEmbed:false,emoji:true,customNode:false}})]})}var Do={id:"email-compose",label:"Email Compose",description:"Compose shell with rich email body editing.",extensions:Q({featureFlags:{table:false,image:false,iframeEmbed:false,youTubeEmbed:false,customNode:false}}),components:{Editor:ao},toolbar:["bold","italic","underline","link","unorderedList","orderedList","undo","redo"],config:ee("email-compose","Write your email..."),css:"email-compose/styles.css"};function uo({className:e,variantClassName:t,initialMode:r="visual",...o}){let l=useRef(null),n=useRef(to(["visual"])),i=useRef(""),a=useRef(null),[u,d]=useState(r),[b,c]=useState(""),[p,m]=useState(null),h=O=>{if(O!==u)try{if(m(null),O==="markdown")if(ro(n.current,"markdown"))c(i.current);else {let S=l.current?.getJSONB()??"",P=S?JSON.parse(S):void 0,U=jr(jsonbToMarkdown(P));i.current=U,c(U),Pt(n.current,"markdown");}if(O==="visual"){let S=markdownToJSONB(b);a.current=JSON.stringify(S);}d(O),O==="visual"&&setTimeout(()=>{a.current&&(l.current?.injectJSONB(a.current),a.current=null);},0);}catch(S){let P=S instanceof Error?S.message:"Failed to parse markdown";m(P);}};return jsxs("div",{className:["luthor-preset-md-text",e].filter(Boolean).join(" "),onInputCapture:()=>{u==="visual"&&oo(n.current,["visual"]);},children:[jsxs("div",{className:"luthor-md-text-tabs",children:[jsx("button",{type:"button",className:u==="visual"?"active":"",onClick:()=>h("visual"),children:"Visual"}),jsx("button",{type:"button",className:u==="markdown"?"active":"",onClick:()=>h("markdown"),children:"Markdown"})]}),u==="visual"&&jsx(te,{ref:l,...o,className:"luthor-preset-md-text__editor",variantClassName:["luthor-preset-md-text__variant",t].filter(Boolean).join(" "),availableModes:["visual"],initialMode:"visual",featureFlags:{table:false,image:false,iframeEmbed:false,youTubeEmbed:false,customNode:false}}),u==="markdown"&&jsxs("div",{className:"luthor-md-text-source-shell",children:[jsx("textarea",{className:"luthor-md-text-source",value:b,onChange:O=>{c(O.target.value),i.current=O.target.value,Pt(n.current,"markdown");},placeholder:"Write markdown..."}),p&&jsx("p",{className:"luthor-md-text-error",children:p})]})]})}var Uo={id:"md-text",label:"MD Text",description:"Visual and markdown editing with conversion bridge.",extensions:Q({featureFlags:{table:false,image:false,iframeEmbed:false,youTubeEmbed:false,customNode:false}}),components:{Editor:uo},toolbar:["bold","italic","underline","strikethrough","link","unorderedList","orderedList"],config:ee("md-text","Write markdown..."),css:"md-text/styles.css"};var Ma={slashCommand:true,draggableBlock:true,commandPalette:true,floatingToolbar:false,contextMenu:false};function co({className:e,variantClassName:t,slashVisibility:r,isDraggableEnabled:o=true,featureFlags:l,isToolbarEnabled:n=false,...i}){return jsx(te,{...i,className:["luthor-preset-notion-like",e].filter(Boolean).join(" "),variantClassName:["luthor-preset-notion-like__variant",t].filter(Boolean).join(" "),isToolbarEnabled:n,slashCommandVisibility:r,featureFlags:{...Ma,draggableBlock:o,...l??{}}})}var _o={id:"notion-like",label:"Notion Like",description:"Slash-first writing with draggable block defaults.",extensions:Q({featureFlags:{slashCommand:true,draggableBlock:true,floatingToolbar:false,contextMenu:false}}),components:{Editor:co},toolbar:[],config:ee("notion-like","Type '/' for commands..."),css:"notion-like/styles.css"};var qa=[richTextExtension,historyExtension,boldExtension,italicExtension,underlineExtension,listExtension],{Provider:Ya,useEditor:Ga}=createEditorSystem();function Wa(){let{commands:e,activeStates:t}=Ga();return jsxs("div",{className:"luthor-headless-controls",role:"toolbar","aria-label":"Headless editor controls",children:[jsx("button",{type:"button",onClick:()=>e.toggleBold?.(),"aria-pressed":t.bold===true,children:"bold"}),jsx("button",{type:"button",onClick:()=>e.toggleItalic?.(),"aria-pressed":t.italic===true,children:"italic"}),jsx("button",{type:"button",onClick:()=>e.toggleUnderline?.(),"aria-pressed":t.underline===true,children:"underline"}),jsx("button",{type:"button",onClick:()=>e.toggleUnorderedList?.(),children:"bullet list"}),jsx("button",{type:"button",onClick:()=>e.undo?.(),children:"undo"}),jsx("button",{type:"button",onClick:()=>e.redo?.(),children:"redo"})]})}function mo({className:e,placeholder:t="Start writing..."}){return jsx("div",{className:["luthor-headless-preset",e].filter(Boolean).join(" "),children:jsxs(Ya,{extensions:qa,children:[jsx(Wa,{}),jsx(RichText,{placeholder:t,classNames:{container:"luthor-headless-editor-container",contentEditable:"luthor-headless-editor-content",placeholder:"luthor-headless-editor-placeholder"}})]})})}var Vo={id:"headless-editor",label:"Headless Editor",description:"Minimal plain-control preset for customization starters.",components:{Editor:mo},toolbar:["bold","italic","underline","unorderedList","undo","redo"],config:ee("headless-editor","Start writing..."),css:"headless-editor/styles.css"};function go({className:e,variantClassName:t,showTitle:r=true,title:o="",onTitleChange:l,showActions:n=true,onPin:i,onArchive:a,onColorChange:u,colorOptions:d=["#fef3c7","#dbeafe","#dcfce7"],...b}){return jsxs("div",{className:["luthor-preset-notes",e].filter(Boolean).join(" "),children:[r&&jsx("input",{"data-testid":"notes-title",className:"luthor-notes-title",placeholder:"Title",value:o,onChange:c=>l?.(c.target.value)}),n&&jsxs("div",{className:"luthor-notes-actions","data-testid":"notes-actions",children:[jsx("button",{type:"button",onClick:i,"aria-label":"Pin note",children:"Pin"}),jsx("button",{type:"button",onClick:a,"aria-label":"Archive note",children:"Archive"}),jsx("select",{"aria-label":"Change note color",onChange:c=>u?.(c.target.value),children:d.map(c=>jsx("option",{value:c,children:c},c))})]}),jsx(te,{...b,variantClassName:["luthor-preset-notes__variant",t].filter(Boolean).join(" "),featureFlags:{bold:true,italic:true,underline:true,strikethrough:false,link:true,list:true,blockFormat:false,table:false,image:false,iframeEmbed:false,youTubeEmbed:false,commandPalette:false,slashCommand:false,draggableBlock:false,customNode:false,emoji:false},isToolbarEnabled:false})]})}var $o={id:"notes",label:"Notes",description:"Compact notes editor with title and actions.",extensions:Q({featureFlags:{list:true,image:false,table:false,iframeEmbed:false,youTubeEmbed:false,commandPalette:false,slashCommand:false,draggableBlock:false,customNode:false}}),components:{Editor:go},toolbar:[],config:ee("notes","Take a note..."),css:"notes/styles.css"};var qc={extensive:no,"simple-text":zo,"rich-text-box":Mo,"chat-window":Ao,"email-compose":Do,"md-text":Uo,"notion-like":_o,"headless-editor":Vo,notes:$o};export{it as AlignCenterIcon,nr as AlignJustifyIcon,ct as AlignLeftIcon,mt as AlignRightIcon,Le as BLOCK_HEADING_LEVELS,At as BoldIcon,Co as Button,lo as ChatWindowEditor,yr as ChevronDownIcon,vr as CloseIcon,tr as CodeBlockIcon,Ut as CodeIcon,Jt as CommandIcon,xr as CommandPalette,Qa as DEFAULT_TOOLBAR_LAYOUT,Ir as Dialog,St as Dropdown,ao as EmailComposeEditor,yo as EmojiIcon,Tr as EmojiSuggestionMenu,te as ExtensiveEditor,ls as EyeIcon,ar as FileCodeIcon,Nr as FloatingToolbar,mo as HeadlessEditorPreset,sr as HighlighterIcon,L as IconButton,ho as ImageIcon,cr as IndentIcon,Dt as ItalicIcon,Mr as LinkHoverBubble,dt as LinkIcon,Vt as ListCheckIcon,_t as ListIcon,$t as ListOrderedIcon,uo as MDTextEditor,ir as MinusIcon,Ar as ModeTabs,fr as MoonIcon,go as NotesEditor,co as NotionLikeEditor,mr as OutdentIcon,ur as PaletteIcon,as as PencilIcon,qt as QuoteIcon,rr as RedoIcon,Ht as RichTextBoxEditor,pr as SearchIcon,Tt as Select,Ot as SimpleTextEditor,wr as SlashCommandMenu,Dr as SourceView,jt as StrikethroughIcon,hr as SubscriptIcon,gr as SunIcon,br as SuperscriptIcon,zt as TRADITIONAL_TOOLBAR_LAYOUT,lr as TableIcon,$r as Toolbar,dr as TypeIcon,Kt as UnderlineIcon,or as UndoIcon,nt as UnlinkIcon,bo as UploadIcon,Ao as chatWindowPreset,Qo as commandsToCommandPaletteItems,Xo as commandsToSlashCommandItems,on as createDefaultSettingsStyleVarRecord,Q as createExtensiveExtensions,mn as createExtensivePreset,an as createFeatureGuardedCommands,Pr as createFloatingToolbarExtension,to as createModeCache,ee as createPresetEditorConfig,Do as emailComposePreset,eo as extensiveExtensions,no as extensivePreset,Wi as filterToolbarLayout,To as formatJSONBSource,jr as formatMarkdownSource,po as generateCommands,Vo as headlessEditorPreset,oo as invalidateModeCache,rn as isEditableCommandTarget,ro as isModeCached,nn as isShortcutMatch,Yi as isToolbarItemSupported,Gi as isToolbarItemVisible,Pt as markModeCached,Uo as mdTextPreset,ln as mergeToolbarVisibilityWithFeatures,tn as normalizeStyleVarsKey,$o as notesPreset,_o as notionLikePreset,qc as presetRegistry,er as registerKeyboardShortcuts,Mo as richTextBoxPreset,Eo as setFloatingToolbarContext,zo as simpleTextPreset};
@@ -0,0 +1 @@
1
+ .luthor-preset-extensive.luthor-editor-wrapper[data-editor-theme=light]{--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, .08);--luthor-muted: #f8fafc;--luthor-muted-fg: #64748b;--luthor-toolbar-bg: var(--luthor-muted);--luthor-toolbar-section-border: var(--luthor-border);--luthor-toolbar-button-fg: var(--luthor-fg);--luthor-toolbar-button-hover-bg: var(--luthor-muted);--luthor-toolbar-button-hover-border: var(--luthor-border-hover);--luthor-toolbar-button-hover-shadow: 0 4px 12px rgba(0, 0, 0, .15);--luthor-toolbar-button-press-shadow: 0 2px 8px rgba(0, 0, 0, .1);--luthor-toolbar-button-active-bg: var(--luthor-accent);--luthor-toolbar-button-active-border: var(--luthor-accent);--luthor-toolbar-button-active-fg: var(--luthor-bg);--luthor-toolbar-button-active-shadow: 0 2px 8px rgba(0, 0, 0, .2);--luthor-toolbar-button-overlay: linear-gradient(135deg, rgba(255, 255, 255, .1) 0%, rgba(255, 255, 255, .05) 100%);--luthor-toolbar-button-active-overlay: linear-gradient(135deg, rgba(255, 255, 255, .2) 0%, rgba(255, 255, 255, .1) 100%);--luthor-toolbar-color-indicator-border: var(--luthor-border);--luthor-toolbar-highlight-bg: var(--luthor-muted);--luthor-quote-bg: var(--luthor-muted);--luthor-quote-fg: var(--luthor-fg);--luthor-quote-border: var(--luthor-accent);--luthor-text-bold-color: var(--luthor-fg);--luthor-link-color: var(--luthor-accent);--luthor-list-marker-color: var(--luthor-fg);--luthor-list-checkbox-color: var(--luthor-accent);--luthor-table-border-color: var(--luthor-border);--luthor-table-header-bg: var(--luthor-muted);--luthor-hr-color: var(--luthor-border);--luthor-placeholder-color: var(--luthor-muted-fg);--luthor-codeblock-bg: var(--luthor-muted);--luthor-floating-bg: var(--luthor-bg);--luthor-floating-fg: var(--luthor-fg);--luthor-floating-border: var(--luthor-border);--luthor-floating-shadow: var(--luthor-shadow);--luthor-floating-muted: var(--luthor-muted);--luthor-floating-border-hover: var(--luthor-border-hover);--luthor-floating-border-active: var(--luthor-border-active);--luthor-floating-accent: var(--luthor-accent);--luthor-floating-accent-fg: var(--luthor-bg);--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-preset-extensive.luthor-editor-wrapper[data-editor-theme=dark]{--luthor-bg: #0a0a0a;--luthor-fg: #ededed;--luthor-border: #262626;--luthor-border-hover: #404040;--luthor-border-active: #525252;--luthor-accent: #ededed;--luthor-accent-hover: #d4d4d8;--luthor-shadow: rgba(0, 0, 0, .5);--luthor-muted: #171717;--luthor-muted-fg: #a3a3a3;--luthor-toolbar-bg: var(--luthor-muted);--luthor-toolbar-section-border: var(--luthor-border);--luthor-toolbar-button-fg: var(--luthor-fg);--luthor-toolbar-button-hover-bg: var(--luthor-muted);--luthor-toolbar-button-hover-border: var(--luthor-border-hover);--luthor-toolbar-button-hover-shadow: 0 4px 12px rgba(0, 0, 0, .35);--luthor-toolbar-button-press-shadow: 0 2px 8px rgba(0, 0, 0, .3);--luthor-toolbar-button-active-bg: var(--luthor-accent);--luthor-toolbar-button-active-border: var(--luthor-accent);--luthor-toolbar-button-active-fg: var(--luthor-bg);--luthor-toolbar-button-active-shadow: 0 2px 8px rgba(0, 0, 0, .5);--luthor-toolbar-button-overlay: linear-gradient(135deg, rgba(255, 255, 255, .08) 0%, rgba(255, 255, 255, .03) 100%);--luthor-toolbar-button-active-overlay: linear-gradient(135deg, rgba(255, 255, 255, .14) 0%, rgba(255, 255, 255, .06) 100%);--luthor-toolbar-color-indicator-border: var(--luthor-border);--luthor-toolbar-highlight-bg: var(--luthor-muted);--luthor-quote-bg: color-mix(in srgb, var(--luthor-muted) 92%, #ffffff 8%);--luthor-quote-fg: var(--luthor-fg);--luthor-quote-border: color-mix(in srgb, var(--luthor-accent) 78%, #ffffff 22%);--luthor-text-bold-color: var(--luthor-fg);--luthor-link-color: var(--luthor-accent);--luthor-list-marker-color: var(--luthor-fg);--luthor-list-checkbox-color: var(--luthor-accent);--luthor-table-border-color: var(--luthor-border);--luthor-table-header-bg: var(--luthor-muted);--luthor-hr-color: var(--luthor-border);--luthor-placeholder-color: var(--luthor-muted-fg);--luthor-codeblock-bg: var(--luthor-muted);--luthor-floating-bg: var(--luthor-bg);--luthor-floating-fg: var(--luthor-fg);--luthor-floating-border: var(--luthor-border);--luthor-floating-shadow: var(--luthor-shadow);--luthor-floating-muted: var(--luthor-muted);--luthor-floating-border-hover: var(--luthor-border-hover);--luthor-floating-border-active: var(--luthor-border-active);--luthor-floating-accent: var(--luthor-accent);--luthor-floating-accent-fg: var(--luthor-bg);--luthor-syntax-comment: #8b949e;--luthor-syntax-keyword: #8b949e;--luthor-syntax-string: #8b949e;--luthor-syntax-number: #8b949e;--luthor-syntax-function: #8b949e;--luthor-syntax-variable: #8b949e}.luthor-preset-extensive.luthor-editor-wrapper{border:1px solid var(--luthor-border);border-radius:8px;background-color:var(--luthor-bg);overflow:hidden;display:flex;flex-direction:column;position:relative;--luthor-theme-transition: .2s ease;width:100%;max-width:100%;min-height:500px;height:auto;isolation:isolate;--luthor-z-dropdown: 20;--luthor-z-popover: 24;--luthor-z-menu: 28;--luthor-z-overlay: 32;--luthor-z-modal: 36;transition:background-color var(--luthor-theme-transition),border-color var(--luthor-theme-transition),color var(--luthor-theme-transition),box-shadow var(--luthor-theme-transition)}.luthor-preset-extensive.luthor-editor-wrapper,.luthor-preset-extensive.luthor-editor-wrapper *,.luthor-preset-extensive.luthor-editor-wrapper *:before,.luthor-preset-extensive.luthor-editor-wrapper *:after{box-sizing:border-box}.luthor-editor-header{background-color:var(--luthor-muted);border-bottom:1px solid var(--luthor-border);transition:background-color var(--luthor-theme-transition),border-color var(--luthor-theme-transition),color var(--luthor-theme-transition)}.luthor-editor-toolbar-slot{background-color:var(--luthor-toolbar-bg, var(--luthor-muted));transition:background-color var(--luthor-theme-transition),border-color var(--luthor-theme-transition),color var(--luthor-theme-transition)}.luthor-editor-toolbar-slot--bottom{border-top:1px solid var(--luthor-border)}.luthor-mode-tabs{display:flex;border-bottom:1px solid var(--luthor-border);transition:border-color var(--luthor-theme-transition),background-color var(--luthor-theme-transition)}.luthor-mode-tab{padding:10px 20px;background:none;border:none;cursor:pointer;color:var(--luthor-muted-fg);font-size:14px;font-weight:500;transition:all .2s cubic-bezier(.4,0,.2,1);border-bottom:2px solid transparent;position:relative}.luthor-mode-tab:hover{color:var(--luthor-fg);background-color:var(--luthor-muted)}.luthor-mode-tab.active{color:var(--luthor-accent);border-bottom-color:var(--luthor-accent);background-color:#0f172a0d}.luthor-tab-converting-spinner{display:inline-block;width:12px;height:12px;margin-left:6px;border:2px solid var(--luthor-muted-fg);border-top-color:var(--luthor-accent);border-radius:50%;animation:luthor-spin .6s linear infinite;vertical-align:middle}@keyframes luthor-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.luthor-toolbar{display:flex;align-items:center;gap:4px;padding:8px;flex-wrap:wrap;overflow-x:hidden;overflow-y:visible;row-gap:6px;min-height:48px;transition:background-color var(--luthor-theme-transition),border-color var(--luthor-theme-transition),color var(--luthor-theme-transition)}.luthor-toolbar--align-left{justify-content:flex-start}.luthor-toolbar--align-center{justify-content:center}.luthor-toolbar--align-right{justify-content:flex-end}.luthor-toolbar-section{display:flex;align-items:center;flex-wrap:wrap;gap:2px;padding:0 4px;min-width:0}.luthor-toolbar-section:not(:last-child){border-right:1px solid var(--luthor-toolbar-section-border, var(--luthor-border));margin-right:8px;padding-right:8px;transition:border-color var(--luthor-theme-transition)}.luthor-toolbar-button{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid transparent;border-radius:6px;background-color:transparent;color:var(--luthor-toolbar-button-fg, var(--luthor-fg));cursor:pointer;transition:all .2s cubic-bezier(.4,0,.2,1);font-size:16px;position:relative;overflow:hidden}.luthor-toolbar-button:before{content:"";position:absolute;inset:0;background:var(--luthor-toolbar-button-overlay);opacity:0;transition:opacity .2s ease}.luthor-toolbar-button:hover{background-color:var(--luthor-toolbar-button-hover-bg, var(--luthor-muted));border-color:var(--luthor-toolbar-button-hover-border, var(--luthor-border-hover));transform:translateY(-1px);box-shadow:var(--luthor-toolbar-button-hover-shadow)}.luthor-toolbar-button:hover:before{opacity:1}.luthor-toolbar-button:active{transform:translateY(0) scale(.98);box-shadow:var(--luthor-toolbar-button-press-shadow)}.luthor-toolbar-button.active{background-color:var(--luthor-toolbar-button-active-bg, var(--luthor-accent));border-color:var(--luthor-toolbar-button-active-border, var(--luthor-accent));color:var(--luthor-toolbar-button-active-fg, var(--luthor-bg));box-shadow:var(--luthor-toolbar-button-active-shadow)}.luthor-toolbar-button.active:before{background:var(--luthor-toolbar-button-active-overlay);opacity:1}.luthor-toolbar-button:disabled{opacity:.5;cursor:not-allowed;transform:none;box-shadow:none}.luthor-toolbar-button:disabled:hover{background-color:transparent;border-color:transparent;transform:none;box-shadow:none}.luthor-toolbar-button:disabled:before{opacity:0}.luthor-color-button{padding-bottom:4px}.luthor-color-button-letter{font-size:14px;line-height:1;font-weight:700;position:relative;z-index:1}.luthor-color-button-indicator{position:absolute;left:7px;right:7px;bottom:5px;height:3px;border-radius:999px;border:1px solid var(--luthor-toolbar-color-indicator-border, var(--luthor-border));box-shadow:inset 0 0 0 1px #fff3;z-index:1}.luthor-color-button.is-highlight .luthor-color-button-letter{padding:0 2px;border-radius:3px;background-color:var(--luthor-toolbar-highlight-bg, var(--luthor-muted))}.luthor-color-button-highlighter{position:relative;z-index:1}.luthor-color-picker{z-index:var(--luthor-z-popover, 440);background-color:var(--luthor-bg, #ffffff);border:1px solid var(--luthor-border, #e2e8f0);border-radius:10px;box-shadow:0 12px 28px #0f172a2e;padding:10px;display:grid;gap:9px;max-width:90vw;width:248px;color:var(--luthor-fg, #0f172a)}.luthor-color-picker-header{display:flex;align-items:center;justify-content:space-between;gap:10px}.luthor-color-picker-title{font-size:12px;font-weight:600;color:var(--luthor-fg)}.luthor-color-picker-native-hidden{position:absolute;width:0;height:0;opacity:0;pointer-events:none}.luthor-color-picker-clear{border:1px solid var(--luthor-border);border-radius:6px;background:var(--luthor-muted);color:var(--luthor-fg);font-size:12px;font-weight:500;padding:4px 8px;cursor:pointer}.luthor-color-picker-clear:hover{border-color:var(--luthor-border-hover)}.luthor-color-picker-section{display:grid;gap:6px}.luthor-color-picker-label{margin:0;font-size:11px;font-weight:600;color:var(--luthor-muted-fg);text-transform:uppercase;letter-spacing:.03em}.luthor-color-swatch-grid,.luthor-color-swatch-row{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px}.luthor-color-swatch{width:100%;aspect-ratio:1;border:1px solid var(--luthor-border);border-radius:6px;background-clip:padding-box;cursor:pointer;transition:transform .15s ease,border-color .15s ease;box-shadow:inset 0 0 0 1px #0f172a14}.luthor-color-swatch:hover:enabled{border-color:var(--luthor-border-hover);transform:translateY(-1px)}.luthor-color-swatch:disabled{cursor:not-allowed;background-image:repeating-linear-gradient(45deg,transparent,transparent 4px,var(--luthor-muted) 4px,var(--luthor-muted) 8px);opacity:.7}.luthor-color-picker-footer{display:flex;justify-content:space-between;align-items:center;gap:8px;padding-top:2px}.luthor-color-picker-custom{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--luthor-border);border-radius:6px;background:var(--luthor-muted);color:var(--luthor-fg);font-size:12px;font-weight:500;padding:4px 8px;cursor:pointer}.luthor-color-picker-custom:hover{border-color:var(--luthor-border-hover)}.luthor-preset-extensive.luthor-editor-wrapper[data-editor-theme=dark] .luthor-color-picker{box-shadow:0 14px 32px #0009}.luthor-preset-extensive.luthor-editor-wrapper[data-editor-theme=dark] .luthor-color-swatch{box-shadow:inset 0 0 0 1px #ffffff14}.luthor-preset-extensive.luthor-editor-wrapper[data-editor-theme=dark] .luthor-color-picker-clear,.luthor-preset-extensive.luthor-editor-wrapper[data-editor-theme=dark] .luthor-color-picker-custom{background:#ffffff0a}.luthor-select{position:relative;display:inline-block}.luthor-select-trigger{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:8px 12px;border:1px solid var(--luthor-border);border-radius:6px;background-color:var(--luthor-bg);color:var(--luthor-fg);cursor:pointer;font-size:14px;min-width:120px;max-width:180px;height:36px;transition:all .2s cubic-bezier(.4,0,.2,1);box-shadow:0 1px 3px #0000001a}.luthor-select-trigger span{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:left}.luthor-select-trigger:hover{border-color:var(--luthor-border-hover);box-shadow:0 2px 8px #00000026}.luthor-select-trigger.open{border-color:var(--luthor-accent);box-shadow:0 0 0 3px #0f172a1a}.luthor-select-dropdown{position:fixed;z-index:var(--luthor-z-dropdown, 420);background-color:var(--luthor-bg, #ffffff);border:1px solid var(--luthor-border, #e2e8f0);border-radius:6px;box-shadow:0 8px 32px #0000001f;max-height:200px;overflow-y:auto}.luthor-select-option{display:block;width:100%;padding:10px 14px;border:none;background:none;color:var(--luthor-fg);cursor:pointer;font-size:14px;text-align:left;transition:all .15s ease}.luthor-select-option:hover{background-color:var(--luthor-muted)}.luthor-select-option.selected{background-color:var(--luthor-accent);color:var(--luthor-bg);font-weight:500}.luthor-dropdown{position:relative;display:inline-flex}.luthor-dropdown-content{position:fixed;z-index:var(--luthor-z-dropdown, 420);background-color:var(--luthor-bg, #ffffff);border:1px solid var(--luthor-border, #e2e8f0);border-radius:4px;box-shadow:0 4px 6px -1px var(--luthor-shadow);margin-top:2px;min-width:160px;padding:4px 0}.luthor-dropdown-item{display:flex;align-items:center;gap:8px;width:100%;padding:8px 12px;border:none;background:none;color:var(--luthor-fg);cursor:pointer;font-size:14px;text-align:left;transition:background-color .15s}.luthor-dropdown-item:hover{background-color:var(--luthor-muted)}.luthor-file-input{display:none}.luthor-editor{flex:1;display:flex;flex-direction:column;min-height:400px;position:relative;--luthor-drag-gutter-width: 56px;background-color:var(--luthor-bg);transition:background-color var(--luthor-theme-transition),border-color var(--luthor-theme-transition),color var(--luthor-theme-transition)}.luthor-editor-visual-shell{display:grid;grid-template-columns:var(--luthor-drag-gutter-width) minmax(0,1fr);grid-template-rows:minmax(0,1fr);flex:1;min-height:0}.luthor-editor-visual-shell--no-gutter{grid-template-columns:minmax(0,1fr)}.luthor-editor-visual-shell.is-hidden{position:absolute;inset:0;visibility:hidden;pointer-events:none}.luthor-editor-visual-gutter{grid-column:1;grid-row:1;pointer-events:none;background-color:var(--luthor-bg);transition:background-color var(--luthor-theme-transition),border-color var(--luthor-theme-transition),color var(--luthor-theme-transition)}.luthor-editor--draggable-disabled{--luthor-drag-gutter-width: 0px}.luthor-editor--draggable-disabled .luthor-editor-visual-gutter{display:none}.luthor-richtext-container{position:relative;flex:1;--luthor-editor-content-padding-y: 20px;--luthor-editor-content-padding-x: 20px;--luthor-first-block-offset: calc(8px * var(--luthor-line-height-ratio, 1));background-color:var(--luthor-bg);transition:background-color var(--luthor-theme-transition),border-color var(--luthor-theme-transition),color var(--luthor-theme-transition)}.luthor-editor-visual-shell .luthor-richtext-container{grid-column:2;grid-row:1;min-width:0}.luthor-editor-visual-shell--no-gutter .luthor-richtext-container{grid-column:1}.luthor-content-editable{flex:1;padding:var(--luthor-editor-content-padding-y) var(--luthor-editor-content-padding-x);outline:none;color:var(--luthor-fg);line-height:1;font-size:16px;background-color:var(--luthor-bg);transition:background-color var(--luthor-theme-transition),color var(--luthor-theme-transition),border-color var(--luthor-theme-transition)}.luthor-content-editable:focus{outline:none;background-color:var(--luthor-bg)}.luthor-content-editable a,.luthor-content-editable a:hover,.luthor-content-editable a:focus-visible{cursor:pointer}.luthor-placeholder{color:var(--luthor-placeholder-color, var(--luthor-muted-fg));pointer-events:none;position:absolute;top:calc(var(--luthor-editor-content-padding-y) + var(--luthor-first-block-offset));left:var(--luthor-editor-content-padding-x);font-size:16px;line-height:var(--luthor-default-line-height, 1.5);z-index:1;transition:color var(--luthor-theme-transition),background-color var(--luthor-theme-transition),border-color var(--luthor-theme-transition)}.luthor-source-panel{padding:20px;flex:1;overflow-y:auto;background-color:var(--luthor-bg);transition:background-color var(--luthor-theme-transition),border-color var(--luthor-theme-transition),color var(--luthor-theme-transition)}.luthor-source-view{width:100%;min-height:280px;padding:12px;border:1px solid var(--luthor-border);font-family:SF Mono,Monaco,Inconsolata,Roboto Mono,Consolas,Courier New,monospace;font-size:14px;line-height:1.6;background-color:var(--luthor-bg);color:var(--luthor-fg);border-radius:0;resize:vertical;overflow-x:auto;overflow-y:auto;white-space:pre;tab-size:2;transition:background-color var(--luthor-theme-transition),color var(--luthor-theme-transition),border-color var(--luthor-theme-transition)}.luthor-source-error{display:flex;gap:12px;padding:12px;margin-bottom:12px;background-color:#dc26261a;border:1px solid rgba(220,38,38,.3);border-radius:6px;color:#dc2626;transition:background-color var(--luthor-theme-transition),border-color var(--luthor-theme-transition),color var(--luthor-theme-transition)}.luthor-preset-extensive.luthor-editor-wrapper[data-editor-theme=dark] .luthor-source-error{background-color:#ef444426;border-color:#ef444466;color:#fca5a5}.luthor-source-error-icon{flex-shrink:0;font-size:18px;line-height:1}.luthor-source-error-message{flex:1}.luthor-source-error-message strong{display:block;margin-bottom:4px;font-weight:600}.luthor-source-error-message p{margin:4px 0;font-size:13px;line-height:1.4;white-space:pre-wrap;word-break:break-word}.luthor-source-error-message small{display:block;margin-top:6px;font-size:12px;opacity:.7}.luthor-command-palette-overlay{position:absolute;inset:0;background:#00000080;display:flex;align-items:flex-start;justify-content:center;padding:min(20vh,120px) 16px 16px;z-index:var(--luthor-z-overlay, 480);overscroll-behavior:contain}.luthor-command-palette{background:var(--luthor-bg, #ffffff);border:1px solid var(--luthor-border, #e2e8f0);border-radius:12px;box-shadow:0 12px 48px #0000001f;width:min(640px,100%);max-width:100%;max-height:min(560px,calc(100% - min(20vh,120px) - 16px));display:flex;flex-direction:column;overflow:hidden;overscroll-behavior:contain}.luthor-command-palette-header{display:flex;align-items:center;padding:16px 20px;border-bottom:1px solid var(--luthor-border);gap:12px}.luthor-command-palette-icon{color:var(--luthor-muted-fg);flex-shrink:0}.luthor-command-palette-input{flex:1;background:transparent;border:none;outline:none;font-size:16px;color:var(--luthor-fg);font-family:inherit}.luthor-command-palette-input::placeholder{color:var(--luthor-muted-fg)}.luthor-command-palette-kbd{background:var(--luthor-muted);border:1px solid var(--luthor-border);border-radius:4px;padding:2px 6px;font-size:11px;color:var(--luthor-muted-fg);font-family:monospace}.luthor-command-palette-list{flex:1;overflow-y:auto;padding:8px 0;overscroll-behavior:contain}.luthor-command-palette-group{margin-bottom:8px}.luthor-command-palette-group-title{padding:8px 20px 4px;font-size:11px;font-weight:600;color:var(--luthor-muted-fg);text-transform:uppercase;letter-spacing:.5px}.luthor-command-palette-item{display:flex;align-items:center;padding:12px 20px;cursor:pointer;border:none;background:none;width:100%;text-align:left;transition:background-color .1s}.luthor-command-palette-item:hover,.luthor-command-palette-item.selected{background:var(--luthor-muted)}.luthor-command-palette-item-content{flex:1;min-width:0}.luthor-command-palette-item-title{font-size:14px;color:var(--luthor-fg);font-weight:500;margin-bottom:2px}.luthor-command-palette-item-description{font-size:12px;color:var(--luthor-muted-fg);line-height:1.4}.luthor-command-palette-item-shortcut{background:var(--luthor-muted);border:1px solid var(--luthor-border);border-radius:4px;padding:2px 6px;font-size:10px;color:var(--luthor-muted-fg);font-family:monospace;margin-left:12px;flex-shrink:0}.luthor-command-palette-footer{padding:12px 20px;border-top:1px solid var(--luthor-border);background:var(--luthor-muted)}.luthor-command-palette-hint{font-size:11px;color:var(--luthor-muted-fg);display:flex;align-items:center;gap:8px}.luthor-command-palette-hint kbd{background:var(--luthor-bg);border:1px solid var(--luthor-border);border-radius:3px;padding:1px 4px;font-size:10px;font-family:monospace}.luthor-command-palette-empty{padding:40px 20px;text-align:center;color:var(--luthor-muted-fg);font-size:14px}.luthor-slash-menu{position:fixed;z-index:var(--luthor-z-menu, 460);background:var(--luthor-bg, #ffffff);border:1px solid var(--luthor-border, #e2e8f0);border-radius:10px;box-shadow:0 12px 36px #00000024;width:min(420px,calc(100vw - 24px));max-height:min(55vh,420px);overflow:hidden;display:flex;flex-direction:column}.luthor-slash-menu-header{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:10px 12px;border-bottom:1px solid var(--luthor-border);background:var(--luthor-muted)}.luthor-slash-menu-title{font-size:12px;font-weight:600;color:var(--luthor-muted-fg);text-transform:uppercase;letter-spacing:.4px}.luthor-slash-menu-query{font-size:12px;font-family:monospace;color:var(--luthor-muted-fg);background:var(--luthor-bg);border:1px solid var(--luthor-border);padding:1px 6px;border-radius:4px}.luthor-slash-menu-list{overflow-y:auto;padding:8px 0}.luthor-slash-menu-group{margin-bottom:6px}.luthor-slash-menu-group-title{padding:6px 12px 4px;font-size:11px;font-weight:600;color:var(--luthor-muted-fg);text-transform:uppercase;letter-spacing:.5px}.luthor-slash-menu-item{width:100%;display:flex;align-items:center;gap:12px;padding:10px 12px;border:none;background:none;text-align:left;cursor:pointer;color:var(--luthor-fg);transition:background-color .12s}.luthor-slash-menu-item:hover,.luthor-slash-menu-item.selected{background:var(--luthor-muted)}.luthor-slash-menu-item-content{min-width:0;display:flex;flex-direction:column;gap:2px;flex:1}.luthor-slash-menu-item-title{font-size:14px;font-weight:500;color:var(--luthor-fg)}.luthor-slash-menu-item-description{font-size:12px;line-height:1.35;color:var(--luthor-muted-fg)}.luthor-slash-menu-item-shortcut{background:var(--luthor-muted);border:1px solid var(--luthor-border);border-radius:4px;padding:2px 6px;font-size:10px;font-family:monospace;color:var(--luthor-muted-fg);flex-shrink:0}.luthor-slash-menu-empty{padding:20px 12px;font-size:13px;color:var(--luthor-muted-fg);text-align:center}.luthor-emoji-picker-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px;padding:8px;width:220px}.luthor-emoji-picker-item{display:inline-flex;align-items:center;justify-content:center;height:32px;border:1px solid transparent;border-radius:6px;background:transparent;cursor:pointer;font-size:18px;line-height:1}.luthor-emoji-picker-item:hover{background:var(--luthor-muted);border-color:var(--luthor-border)}.luthor-emoji-menu{position:fixed;z-index:var(--luthor-z-menu, 460);background:var(--luthor-bg, #ffffff);border:1px solid var(--luthor-border, #e2e8f0);border-radius:10px;box-shadow:0 12px 36px #00000024;width:min(320px,calc(100vw - 24px));max-height:min(45vh,320px);overflow:hidden;display:flex;flex-direction:column}.luthor-emoji-menu-header{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:10px 12px;border-bottom:1px solid var(--luthor-border);background:var(--luthor-muted)}.luthor-emoji-menu-title{font-size:12px;font-weight:600;color:var(--luthor-muted-fg);text-transform:uppercase;letter-spacing:.4px}.luthor-emoji-menu-query{font-size:12px;font-family:monospace;color:var(--luthor-muted-fg);background:var(--luthor-bg);border:1px solid var(--luthor-border);padding:1px 6px;border-radius:4px}.luthor-emoji-menu-list{overflow-y:auto;padding:6px 0}.luthor-emoji-menu-item{width:100%;display:flex;align-items:center;gap:10px;padding:8px 10px;border:none;background:none;text-align:left;cursor:pointer;color:var(--luthor-fg);transition:background-color .12s}.luthor-emoji-menu-item:hover,.luthor-emoji-menu-item.selected{background:var(--luthor-muted)}.luthor-emoji-menu-item-symbol{font-size:20px;line-height:1;width:24px;text-align:center;flex-shrink:0}.luthor-emoji-menu-item-content{min-width:0;display:flex;flex-direction:column;gap:1px;flex:1}.luthor-emoji-menu-item-title{font-size:13px;font-weight:500;color:var(--luthor-fg)}.luthor-emoji-menu-item-shortcode{font-size:12px;line-height:1.25;color:var(--luthor-muted-fg);font-family:monospace}.luthor-emoji-menu-empty{padding:18px 12px;font-size:13px;color:var(--luthor-muted-fg);text-align:center}.luthor-dialog-overlay{position:fixed;inset:0;background-color:#00000080;display:flex;align-items:center;justify-content:center;z-index:var(--luthor-z-modal, 500);overscroll-behavior:contain}.luthor-dialog{background-color:var(--luthor-bg);border-radius:10px;box-shadow:0 20px 30px var(--luthor-shadow);min-width:360px;max-width:520px;max-height:90vh;overflow:hidden}.luthor-dialog-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--luthor-border)}.luthor-dialog-title{margin:0;font-size:16px;font-weight:600;color:var(--luthor-fg)}.luthor-dialog-close{background:none;border:none;color:var(--luthor-muted-fg);cursor:pointer;padding:4px;border-radius:6px}.luthor-dialog-close:hover{background-color:var(--luthor-muted);color:var(--luthor-fg)}.luthor-dialog-content{padding:18px 20px}.luthor-table-dialog{display:flex;flex-direction:column;gap:14px}.luthor-form-group{display:flex;flex-direction:column;gap:6px}.luthor-form-group label{font-size:13px;font-weight:600;color:var(--luthor-fg)}.luthor-input{padding:8px 12px;border:1px solid var(--luthor-border);border-radius:6px;background-color:var(--luthor-bg);color:var(--luthor-fg);font-size:13px}.luthor-input:focus{outline:none;border-color:var(--luthor-accent);box-shadow:0 0 0 3px #3b82f61f}.luthor-checkbox-label{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--luthor-fg)}.luthor-checkbox{width:16px;height:16px;accent-color:var(--luthor-accent)}.luthor-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:4px}.luthor-button-primary,.luthor-button-secondary{padding:8px 14px;border-radius:6px;font-size:13px;font-weight:600;cursor:pointer;border:1px solid}.luthor-button-primary{background-color:var(--luthor-accent);border-color:var(--luthor-accent);color:var(--luthor-bg)}.luthor-button-primary:hover{background-color:var(--luthor-accent-hover);border-color:var(--luthor-accent-hover)}.luthor-button-secondary{background-color:transparent;border-color:var(--luthor-border);color:var(--luthor-fg)}.luthor-button-secondary:hover{background-color:var(--luthor-muted);border-color:var(--luthor-border-hover)}.luthor-text-bold{font-weight:700;color:var(--luthor-text-bold-color, var(--luthor-fg))}.luthor-text-italic{font-style:italic}.luthor-text-underline{text-decoration:underline}.luthor-text-strikethrough{text-decoration:line-through}.luthor-text-code,.luthor-content-editable code,.luthor-code-block{font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;background-color:var(--luthor-codeblock-bg, var(--luthor-muted));border:1px solid var(--luthor-border);color:var(--luthor-syntax-string, var(--luthor-muted-fg));border-radius:4px}.luthor-content-editable .luthor-text-code,.luthor-content-editable code,.luthor-content-editable code.luthor-text-code,.luthor-preset .luthor-content-editable code,.luthor-preset-extensive .luthor-content-editable code{color:var(--luthor-syntax-string, var(--luthor-muted-fg));font-weight:500}.luthor-code-block{display:block;padding:12px;margin:12px 0;line-height:1.6;overflow-x:auto;max-width:min(100%,880px);width:100%;tab-size:2;white-space:pre-wrap;overflow-wrap:normal;word-break:normal}.luthor-code-block--interactive{position:relative;margin-top:40px;border-top-left-radius:0;border-top-right-radius:0;border-top:0}.luthor-codeblock-controls-layer{position:absolute;inset:0;pointer-events:none;z-index:25}.luthor-codeblock-controls{position:absolute;display:flex;align-items:center;justify-content:space-between;z-index:26;pointer-events:auto;margin:0;max-width:none;padding:8px 10px;border:1px solid var(--luthor-border);border-top-left-radius:8px;border-top-right-radius:8px;border-bottom:1px solid var(--luthor-border);background:var(--luthor-codeblock-bg, var(--luthor-muted))}.luthor-codeblock-controls-left,.luthor-codeblock-controls-right{display:inline-flex;align-items:center;gap:6px}.luthor-codeblock-language,.luthor-codeblock-copy{font-size:11px;line-height:1.2;height:24px;border-radius:6px;border:1px solid var(--luthor-border);background:var(--luthor-bg);color:var(--luthor-fg);padding:0 8px}.luthor-codeblock-language{min-width:88px;appearance:none}.luthor-codeblock-language option{background:var(--luthor-bg);color:var(--luthor-fg)}.luthor-codeblock-copy{cursor:pointer;font-weight:600;width:26px;height:24px;padding:0;display:inline-flex;align-items:center;justify-content:center;position:relative;background:var(--luthor-bg)}.luthor-codeblock-copy svg{width:14px;height:14px;fill:currentColor}.luthor-codeblock-copy:after{content:attr(data-tooltip);position:absolute;top:-28px;right:0;padding:2px 6px;font-size:10px;line-height:1.2;white-space:nowrap;border-radius:4px;border:1px solid var(--luthor-border);background:var(--luthor-bg);color:var(--luthor-fg);opacity:0;pointer-events:none;transform:translateY(4px);transition:opacity .15s ease,transform .15s ease}.luthor-codeblock-copy:hover:after,.luthor-codeblock-copy:focus-visible:after{opacity:1;transform:translateY(0)}.luthor-codeblock-copy:hover,.luthor-codeblock-language:hover,.luthor-codeblock-copy.is-copied{border-color:var(--luthor-border-hover);background:var(--luthor-codeblock-bg, var(--luthor-muted))}.luthor-codeblock-copy.is-copy-error{border-color:var(--luthor-syntax-variable);color:var(--luthor-syntax-variable)}.luthor-code-block[data-theme=plain]{--luthor-syntax-keyword: var(--luthor-muted-fg);--luthor-syntax-string: var(--luthor-muted-fg);--luthor-syntax-number: var(--luthor-muted-fg);--luthor-syntax-function: var(--luthor-muted-fg);--luthor-syntax-variable: var(--luthor-muted-fg)}:where(.luthor-code-comment),:where(.luthor-code-prolog),:where(.luthor-code-doctype),:where(.luthor-code-cdata),:where(.luthor-code-punctuation),:where(.luthor-code-operator),:where(.luthor-code-namespace),:where(.luthor-code-property),:where(.luthor-code-tag),:where(.luthor-code-constant),:where(.luthor-code-symbol),:where(.luthor-code-deleted),:where(.luthor-code-boolean),:where(.luthor-code-number),:where(.luthor-code-attr),:where(.luthor-code-selector),:where(.luthor-code-string),:where(.luthor-code-char),:where(.luthor-code-builtin),:where(.luthor-code-inserted),:where(.luthor-code-function),:where(.luthor-code-class),:where(.luthor-code-class-name),:where(.luthor-code-keyword),:where(.luthor-code-atrule),:where(.luthor-code-regex),:where(.luthor-code-variable),:where(.luthor-code-important){color:var(--luthor-syntax-string, var(--luthor-muted-fg));font-weight:inherit}.luthor-paragraph{margin:var(--luthor-first-block-offset) 0;line-height:var(--luthor-default-line-height, 1.5)}.luthor-heading-h1,.luthor-heading-h2,.luthor-heading-h3,.luthor-heading-h4,.luthor-heading-h5,.luthor-heading-h6{margin:calc(16px * var(--luthor-line-height-ratio, 1)) 0 calc(8px * var(--luthor-line-height-ratio, 1));line-height:var(--luthor-default-line-height, 1.5);font-weight:700}.luthor-heading-h1{font-size:28px}.luthor-heading-h2{font-size:24px}.luthor-heading-h3{font-size:20px}.luthor-heading-h4{font-size:18px}.luthor-heading-h5{font-size:16px}.luthor-heading-h6{font-size:14px}.luthor-list-ul,.luthor-list-ol{margin:10px 0 10px 20px}.luthor-list-li{margin:calc(4px * var(--luthor-line-height-ratio, 1)) 0;line-height:var(--luthor-default-line-height, 1.5)}.luthor-list-ul .luthor-list-li::marker,.luthor-list-ol .luthor-list-li::marker{color:var(--luthor-list-marker-color, var(--luthor-fg))}.luthor-list-item-unchecked,.luthor-list-item-checked{position:relative;list-style:none;margin-left:0;padding-left:28px;min-height:22px;cursor:pointer}.luthor-list-item-unchecked::marker,.luthor-list-item-checked::marker{content:""}.luthor-list-item-unchecked:before,.luthor-list-item-checked:before{content:"";position:absolute;left:0;top:.1em;width:16px;height:16px;border-radius:4px;border:1.5px solid var(--luthor-list-checkbox-color, var(--luthor-accent));background-color:var(--luthor-bg);box-sizing:border-box;transition:all .15s ease}.luthor-list-item-unchecked:hover:before{border-color:var(--luthor-list-checkbox-color, var(--luthor-accent))}.luthor-list-item-checked:before{content:"\2713";display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;line-height:1;color:var(--luthor-bg);border-color:var(--luthor-list-checkbox-color, var(--luthor-accent));background-color:var(--luthor-list-checkbox-color, var(--luthor-accent))}.luthor-list-item-checked{text-decoration:line-through;opacity:.85}.luthor-list-item-checked>ul,.luthor-list-item-checked>ol{text-decoration:none;opacity:1}.luthor-quote{border-left:4px solid var(--luthor-quote-border, var(--luthor-accent));background-color:var(--luthor-quote-bg, var(--luthor-muted));padding:10px 14px;margin:12px 0;color:var(--luthor-quote-fg, var(--luthor-fg));line-height:var(--luthor-default-line-height, 1.5)}.luthor-link{color:var(--luthor-link-color, var(--luthor-accent));text-decoration:underline}.luthor-link:hover{color:var(--luthor-accent-hover)}.luthor-hr{margin:16px 0;border:none;border-top:1px solid var(--luthor-hr-color, var(--luthor-border));height:1px}.luthor-preset-extensive .lexical-image{margin:1em 0;display:block;position:relative}.luthor-preset-extensive .lexical-image img{max-width:100%;height:auto;border-radius:6px;display:block}.luthor-preset-extensive .lexical-image.align-left{float:left;margin-right:1em;margin-bottom:1em}.luthor-preset-extensive .lexical-image.align-right{float:right;margin-left:1em;margin-bottom:1em}.luthor-preset-extensive .lexical-image.align-center{text-align:center;margin:1em auto}.luthor-preset-extensive .lexical-image.align-center img{margin:0 auto}.luthor-preset-extensive .lexical-image figcaption{margin-top:.5em;font-size:12px;color:var(--luthor-muted-fg);text-align:center;font-style:italic}.luthor-preset-extensive .lexical-image.selected{outline:none}.luthor-preset-extensive .resizer{position:absolute;width:8px;height:8px;background:var(--luthor-accent);border:1px solid white;border-radius:50%}.luthor-preset-extensive .resizer.ne{top:-4px;right:-4px;cursor:nesw-resize}.luthor-preset-extensive .resizer.nw{top:-4px;left:-4px;cursor:nwse-resize}.luthor-preset-extensive .resizer.se{bottom:-4px;right:-4px;cursor:nwse-resize}.luthor-preset-extensive .resizer.sw{bottom:-4px;left:-4px;cursor:nesw-resize}.luthor-table{border-collapse:collapse;width:100%;margin:16px 0;border:1px solid var(--luthor-table-border-color, var(--luthor-border))}.luthor-table-cell,.luthor-table-cell-header{border:1px solid var(--luthor-table-border-color, var(--luthor-border));padding:8px 12px;text-align:left;min-width:80px;background-color:var(--luthor-bg)}.luthor-table-cell-header{background-color:var(--luthor-table-header-bg, var(--luthor-muted));font-weight:600}.luthor-preset-extensive table[data-lexical-table-selection]{box-shadow:0 0 0 2px var(--luthor-accent)}.luthor-preset-extensive table td[data-lexical-table-cell-selection]{background-color:#3b82f61a}.luthor-table-bubble-menu{display:flex;align-items:center;gap:6px;padding:8px;border:1px solid var(--luthor-border);border-radius:10px;background:var(--luthor-bg);box-shadow:0 8px 24px var(--luthor-shadow);pointer-events:auto;white-space:nowrap}.luthor-table-bubble-button{height:30px;min-width:30px;padding:0 10px;display:inline-flex;align-items:center;justify-content:center;border-radius:6px;border:1px solid var(--luthor-border);background:var(--luthor-muted);color:var(--luthor-fg);font-size:12px;font-weight:600;line-height:1;cursor:pointer;transition:all .16s ease}.luthor-table-bubble-button svg{display:block}.luthor-table-bubble-button-icon{width:30px;padding:0}.luthor-table-bubble-button:hover{border-color:var(--luthor-border-hover);background:color-mix(in srgb,var(--luthor-muted) 58%,var(--luthor-accent) 42%);color:var(--luthor-bg)}.luthor-table-bubble-button-active{background:var(--luthor-accent);border-color:var(--luthor-accent);color:var(--luthor-bg)}.luthor-table-bubble-button-danger:hover{background:#dc2626;border-color:#dc2626;color:#fff}.luthor-table-bubble-checkbox{display:inline-flex;align-items:center;gap:6px;padding:0 6px;height:28px;font-size:12px;font-weight:600;color:var(--luthor-fg);user-select:none}.luthor-table-bubble-checkbox input{margin:0;accent-color:var(--luthor-accent)}.luthor-context-menu{position:fixed;background:var(--luthor-bg);border:1px solid var(--luthor-border);border-radius:8px;box-shadow:0 10px 30px var(--luthor-shadow);z-index:var(--luthor-z-menu, 460);min-width:160px;padding:6px 0;font-size:13px}.luthor-context-menu-item{padding:8px 14px;cursor:pointer;user-select:none}.luthor-context-menu-item:hover{background-color:var(--luthor-muted)}.luthor-context-menu-item-disabled{opacity:.5;cursor:not-allowed}.luthor-floating-toolbar{--luthor-floating-bg: #ffffff;--luthor-floating-fg: #0f172a;--luthor-floating-border: #e2e8f0;--luthor-floating-shadow: rgba(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;display:flex;align-items:center;gap:4px;padding:6px;background-color:var(--luthor-floating-bg);color:var(--luthor-floating-fg);border:1px solid var(--luthor-floating-border);border-radius:8px;box-shadow:0 8px 24px var(--luthor-floating-shadow)}.luthor-floating-toolbar[data-theme=dark]{--luthor-floating-bg: #0a0a0a;--luthor-floating-fg: #ededed;--luthor-floating-border: #262626;--luthor-floating-shadow: rgba(0, 0, 0, .5);--luthor-floating-muted: #171717;--luthor-floating-border-hover: #404040;--luthor-floating-border-active: #525252;--luthor-floating-accent: #ededed;--luthor-floating-accent-fg: #0a0a0a}.luthor-floating-toolbar .luthor-toolbar-button{color:var(--luthor-floating-fg);border-color:transparent}.luthor-floating-toolbar .luthor-toolbar-button:hover{background-color:var(--luthor-floating-muted);border-color:var(--luthor-floating-border-hover)}.luthor-floating-toolbar .luthor-toolbar-button.active{background-color:var(--luthor-floating-accent);border-color:var(--luthor-floating-accent);color:var(--luthor-floating-accent-fg)}.luthor-floating-toolbar-separator{width:1px;height:18px;background-color:var(--luthor-floating-border);margin:0 4px}.luthor-floating-toolbar-input{height:30px;min-width:140px;max-width:220px;padding:4px 8px;font-size:12px;color:var(--luthor-floating-fg);background-color:var(--luthor-floating-bg);border:1px solid var(--luthor-floating-border);border-radius:6px;outline:none}.luthor-floating-toolbar-fields{display:flex;flex-direction:column;gap:6px}.luthor-floating-toolbar-field-row{display:flex;align-items:center;gap:6px}.luthor-floating-toolbar-action{height:30px;min-width:30px;width:auto;padding:0 10px;font-size:12px;font-weight:600;border-color:var(--luthor-floating-border);background:var(--luthor-floating-muted);color:var(--luthor-floating-fg);transform:none;box-shadow:none}.luthor-floating-toolbar .luthor-floating-toolbar-action:hover{border-color:var(--luthor-floating-border-hover);background:var(--luthor-floating-muted);color:var(--luthor-floating-fg);transform:none;box-shadow:none}.luthor-floating-toolbar-action-primary,.luthor-floating-toolbar .luthor-floating-toolbar-action-primary:hover{border-color:var(--luthor-floating-accent);background:var(--luthor-floating-accent);color:var(--luthor-floating-accent-fg)}.luthor-floating-toolbar-action-danger:hover{border-color:#dc2626;background:#dc2626;color:#fff}.luthor-floating-toolbar-input:focus{border-color:var(--luthor-floating-border-active);box-shadow:0 0 0 2px color-mix(in srgb,var(--luthor-floating-accent) 18%,transparent)}.luthor-floating-toolbar-input.is-error{border-color:#dc2626}.luthor-link-hover-bubble{gap:6px;max-width:min(680px,calc(100vw - 20px));border-radius:10px;box-shadow:0 8px 24px var(--luthor-floating-shadow)}.luthor-link-hover-bubble-url{min-width:160px;max-width:360px;padding:0 4px;font-size:12px;line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.luthor-link-hover-bubble-button{height:30px;min-width:30px;padding:0 10px;width:auto;font-size:12px;font-weight:600;border-color:var(--luthor-floating-border);background:var(--luthor-floating-muted);transform:none;box-shadow:none}.luthor-link-hover-bubble .luthor-link-hover-bubble-button:hover{border-color:var(--luthor-floating-border-hover);background:var(--luthor-floating-muted);transform:none;box-shadow:none}.luthor-link-hover-bubble-button-primary,.luthor-link-hover-bubble .luthor-link-hover-bubble-button-primary:hover{border-color:var(--luthor-floating-accent);background:var(--luthor-floating-accent);color:var(--luthor-floating-accent-fg)}.luthor-link-hover-bubble-button-danger:hover{border-color:#dc2626;background:#dc2626;color:#fff}.luthor-link-hover-bubble-input{height:28px;min-width:220px;max-width:360px;padding:4px 8px;font-size:12px;border:1px solid var(--luthor-floating-border);border-radius:6px;color:var(--luthor-floating-fg);background:var(--luthor-floating-bg);outline:none}.luthor-link-hover-bubble-input:focus{border-color:var(--luthor-floating-border-active);box-shadow:0 0 0 2px color-mix(in srgb,var(--luthor-floating-accent) 18%,transparent)}.luthor-link-hover-bubble-input.is-error{border-color:#dc2626}.luthor-media-embed-shell{position:relative;border:2px solid var(--luthor-border);border-radius:12px;overflow:hidden;background:var(--luthor-bg);transition:border-color var(--luthor-theme-transition),box-shadow var(--luthor-theme-transition),background-color var(--luthor-theme-transition)}.luthor-media-embed-shell:hover{border-color:var(--luthor-border-active)}.luthor-media-embed-shell.is-selected{border-color:var(--luthor-accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--luthor-accent) 28%,transparent)}.luthor-media-embed-shell.is-resizing{user-select:none}.luthor-media-embed-controls{position:absolute;top:8px;right:8px;display:inline-flex;gap:4px;padding:4px;border:1px solid var(--luthor-border-hover);border-radius:8px;background:color-mix(in srgb,var(--luthor-bg) 92%,black 8%);z-index:2}.luthor-media-embed-control{border:1px solid var(--luthor-border);background:var(--luthor-muted);color:var(--luthor-fg);border-radius:6px;padding:2px 8px;font-size:11px;line-height:1.4;cursor:pointer}.luthor-media-embed-control:hover{border-color:var(--luthor-border-hover)}.luthor-media-embed-control.is-active{background:var(--luthor-accent);border-color:var(--luthor-accent);color:var(--luthor-bg)}.luthor-media-embed-resize-handle-width,.luthor-media-embed-resize-handle-height{position:absolute;border:1px solid var(--luthor-accent);background:color-mix(in srgb,var(--luthor-muted) 85%,var(--luthor-bg) 15%);border-radius:999px;z-index:2;opacity:.95;transition:background-color var(--luthor-theme-transition),border-color var(--luthor-theme-transition),transform .12s ease}.luthor-media-embed-resize-handle-width{top:50%;right:-7px;transform:translateY(-50%);width:14px;height:30px;cursor:ew-resize;border-radius:999px}.luthor-media-embed-resize-handle-height{left:50%;bottom:-7px;transform:translate(-50%);width:30px;height:14px;cursor:ns-resize;border-radius:999px}.luthor-media-embed-resize-handle-width:hover,.luthor-media-embed-resize-handle-height:hover{transform:translateY(-50%) scale(1.06)}.luthor-media-embed-resize-handle-height:hover{transform:translate(-50%) scale(1.06)}.luthor-media-embed-shell.is-resizing .luthor-media-embed-resize-handle-width,.luthor-media-embed-shell.is-resizing .luthor-media-embed-resize-handle-height{background:color-mix(in srgb,var(--luthor-accent) 28%,var(--luthor-bg) 72%);border:1px solid var(--luthor-accent)}.luthor-draggable-handle,.luthor-draggable-add-button{width:24px;height:24px;border-radius:0;border:none;background:transparent;color:var(--luthor-muted-fg);fill:currentColor;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:color .16s ease,transform .16s ease;outline:none}.luthor-draggable-add-button{width:20px;height:20px;font-size:14px;line-height:1;font-weight:500;padding:0}.luthor-draggable-handle svg{width:14px;height:14px;stroke:currentColor;fill:none}.luthor-draggable-handle:hover,.luthor-draggable-add-button:hover{color:var(--luthor-fg);transform:scale(1.04)}.luthor-draggable-handle:active,.luthor-draggable-add-button:active,.luthor-draggable-handle-active{background:transparent;color:var(--luthor-accent);transform:scale(.96)}.luthor-draggable-button-stack{display:flex;flex-direction:column;gap:6px;align-items:center;padding:0;border:none;background:transparent}.luthor-draggable-drop-indicator{height:3px;background:var(--luthor-accent);border-radius:999px}.luthor-draggable-block-dragging,.luthor-draggable-block-is-dragging{opacity:.6}.luthor-editor--draggable-disabled .luthor-draggable-button-stack,.luthor-editor--draggable-disabled .luthor-draggable-handle,.luthor-editor--draggable-disabled .luthor-draggable-add-button,.luthor-editor--draggable-disabled .luthor-draggable-drop-indicator{display:none!important}@media(max-width:768px){.luthor-preset-extensive.luthor-editor-wrapper{min-height:400px}.luthor-toolbar{padding:6px}.luthor-toolbar--align-right{justify-content:flex-start}.luthor-toolbar-button{width:32px;height:32px;font-size:14px}.luthor-toolbar-section{padding:0 2px}.luthor-toolbar-section:not(:last-child){margin-right:6px;padding-right:6px}.luthor-richtext-container{--luthor-editor-content-padding-y: 16px;--luthor-editor-content-padding-x: 16px}.luthor-content-editable{font-size:16px}.luthor-select-trigger{min-width:100px;font-size:13px}.luthor-mode-tab{padding:8px 12px;font-size:13px}}.luthor-extensive-feature-card{border:1px solid var(--luthor-border-active);border-radius:12px;padding:12px;margin:10px 0;background-color:var(--luthor-muted)}.luthor-extensive-feature-card.is-selected{box-shadow:0 0 0 2px var(--luthor-accent)}.luthor-extensive-feature-card__tag{display:inline-flex;align-items:center;font-size:10px;letter-spacing:.04em;text-transform:uppercase;color:var(--luthor-accent);border:1px solid var(--luthor-border-active);background-color:var(--luthor-bg);border-radius:999px;padding:2px 8px;margin-bottom:8px}.luthor-extensive-feature-card__title{margin:0;font-size:14px;color:var(--luthor-fg);line-height:1.35}.luthor-extensive-feature-card__description{margin:6px 0 0;font-size:12px;line-height:1.45;color:var(--luthor-muted-fg)}.luthor-preset-chat-window{display:flex;flex-direction:column;gap:10px}.luthor-chat-window-actions{display:flex;justify-content:flex-end;align-items:center;gap:8px}.luthor-chat-window-action{border:1px solid var(--luthor-border);background:var(--luthor-muted);color:var(--luthor-fg);border-radius:8px;height:32px;padding:0 12px;cursor:pointer}.luthor-chat-window-action-send{border-color:var(--luthor-accent);background:var(--luthor-accent);color:var(--luthor-bg)}
@@ -0,0 +1,22 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { o as ExtensiveEditorProps } from '../../ExtensiveEditor-Cn84lsVT.js';
3
+ import { E as EditorPreset } from '../../index-BtdZVw3X.js';
4
+ import 'react';
5
+ import '@lyfie/luthor-headless';
6
+
7
+ type ChatWindowEditorSendPayload = {
8
+ jsonb: string;
9
+ };
10
+ type ChatWindowEditorProps = Omit<ExtensiveEditorProps, "featureFlags" | "isToolbarEnabled"> & {
11
+ onSend?: (payload: ChatWindowEditorSendPayload) => void;
12
+ submitOnEnter?: boolean;
13
+ allowShiftEnter?: boolean;
14
+ showVoiceButton?: boolean;
15
+ showImageButton?: boolean;
16
+ showSendButton?: boolean;
17
+ };
18
+ declare function ChatWindowEditor({ className, variantClassName, onSend, submitOnEnter, allowShiftEnter, showVoiceButton, showImageButton, showSendButton, ...props }: ChatWindowEditorProps): react_jsx_runtime.JSX.Element;
19
+
20
+ declare const chatWindowPreset: EditorPreset;
21
+
22
+ export { ChatWindowEditor, type ChatWindowEditorProps, type ChatWindowEditorSendPayload, chatWindowPreset };