@lyfie/luthor 2.3.1 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-5KKKDUJW.js +3 -0
- package/dist/chunk-CFX2B2AM.js +1 -0
- package/dist/chunk-CRS52AWJ.js +1 -0
- package/dist/chunk-EY5S5M6E.js +1 -0
- package/dist/chunk-GM3JMQAK.js +1 -0
- package/dist/chunk-MDSRHDWB.js +1 -0
- package/dist/chunk-UF2XGVNR.js +1 -0
- package/dist/chunk-USP5DTF7.js +1 -0
- package/dist/chunk-YA4LF3BW.js +1 -0
- package/dist/chunk-YI6UVUPP.js +1 -0
- package/dist/index.d.ts +157 -41
- package/dist/index.js +1 -3
- package/dist/presets/chat-window/index.js +1 -3
- package/dist/presets/email-compose/index.js +1 -3
- package/dist/presets/extensive/index.js +1 -3
- package/dist/presets/headless-editor/index.js +1 -1
- package/dist/presets/md-text/index.js +1 -3
- package/dist/presets/notes/index.js +1 -3
- package/dist/presets/notion-like/index.js +1 -3
- package/dist/presets/rich-text-box/index.js +1 -3
- package/dist/presets/simple-text/index.js +1 -3
- package/package.json +4 -5
- package/dist/presets/chat-window/index.css +0 -1
- package/dist/presets/email-compose/index.css +0 -1
- package/dist/presets/extensive/index.css +0 -1
- package/dist/presets/headless-editor/index.css +0 -1
- package/dist/presets/md-text/index.css +0 -1
- package/dist/presets/notes/index.css +0 -1
- package/dist/presets/notion-like/index.css +0 -1
- package/dist/presets/rich-text-box/index.css +0 -1
- package/dist/presets/simple-text/index.css +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {a}from'./chunk-MDSRHDWB.js';import {ImageExtension,TableExtension,IframeEmbedExtension,YouTubeEmbedExtension,ContextMenuExtension,CommandPaletteExtension,SlashCommandExtension,EmojiExtension,DraggableBlockExtension,LinkExtension,textColorExtension,textHighlightExtension,createCustomNodeExtension,createEditorSystem,mergeThemes,defaultLuthorTheme,createEditorThemeStyleVars,FloatingToolbarExtension,FontFamilyExtension,FontSizeExtension,LineHeightExtension,codeExtension,codeIntelligenceExtension,boldExtension,italicExtension,underlineExtension,strikethroughExtension,subscriptExtension,superscriptExtension,horizontalRuleExtension,listExtension,historyExtension,blockFormatExtension,codeFormatExtension,tabIndentExtension,enterKeyBehaviorExtension,RichText,clearLexicalSelection,resolveLinkNodeKeyFromAnchor}from'@lyfie/luthor-headless';import xr,{forwardRef,useState,useMemo,useEffect,useRef,useImperativeHandle,createElement,useLayoutEffect,useCallback}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var Ie=["h1","h2","h3","h4","h5","h6"],yl={sections:[{items:["fontFamily","fontSize","lineHeight","textColor","textHighlight","bold","italic","underline","strikethrough","subscript","superscript","code","link"]},{items:["blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify","codeBlock"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["horizontalRule"]},{items:["table"]},{items:["image"]},{items:["emoji"]},{items:["embed"]},{items:["undo","redo"]},{items:["commandPalette"]},{items:["themeToggle"]}]},Ot={sections:[{items:["fontFamily","fontSize","lineHeight"]},{items:["bold","italic","underline","strikethrough","textColor","textHighlight"]},{items:["subscript","superscript","code","link"]},{items:["blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["table","image","emoji","embed","horizontalRule"]},{items:["codeBlock"]},{items:["undo","redo"]},{items:["commandPalette","themeToggle"]}]};function _n(e){if(!(e instanceof Element))return false;if(e.closest('[contenteditable="true"]'))return true;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"}function $n(e,t){return _n(e.target)?To(t):false}function To(e){let t=e.key.toLowerCase();return !(!!e.ctrlKey||!!e.metaKey)||e.altKey?false:t==="b"||t==="i"||t==="u"||t==="k"||(t==="z"||t==="y")}function Eo(e){return typeof e.setCodeLanguage=="function"&&typeof e.autoDetectCodeLanguage=="function"}function Jn(e){return typeof e.toggleSubscript=="function"}function qn(e){return typeof e.toggleSuperscript=="function"}function Yn(e){return typeof e.insertIframeEmbed=="function"}function Gn(e){return typeof e.insertYouTubeEmbed=="function"}function Qn(e){return typeof e.insertEmoji=="function"}function Wn(e){return e.slice(1)}function Xn(e){switch(e){case "h1":return "Convert to large heading";case "h2":return "Convert to medium heading";case "h3":return "Convert to small heading";case "h4":return "Convert to heading level 4";case "h5":return "Convert to heading level 5";case "h6":return "Convert to heading level 6"}}function Zn(e){if(!e||e.length===0)return [...Ie];let t=new Set,n=[];for(let o of e)!Ie.includes(o)||t.has(o)||(t.add(o),n.push(o));return n.length>0?n:[...Ie]}function Gt(e,t){return nr(Qt(t),t?.shortcutConfig).filter(o=>!o.condition||o.condition(e))}function _(e,t){return typeof e[t]=="function"}function Nt(e){if(!e||e.length===0)return new Set;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return new Set(t)}function er(e){if(!e)return {allowlist:new Set,denylist:new Set};if(Array.isArray(e)){let n=[];for(let o of e)for(let[l,r]of Object.entries(o))r&&n.push(l);return {allowlist:Nt(n),denylist:new Set}}let t=e;return {allowlist:Nt(t.allowlist),denylist:Nt(t.denylist)}}function So(e){let t=e.key.trim();return t?{key:t,ctrlKey:!!e.ctrlKey,metaKey:!!e.metaKey,shiftKey:!!e.shiftKey,altKey:!!e.altKey,preventDefault:e.preventDefault}:null}function tr(e){if(e===false||e===null)return [];let t=Array.isArray(e)?e:[e],n=[];for(let o of t){let l=So(o);l&&n.push(l);}return n}function or(e){return [e.key.toLowerCase(),e.ctrlKey?"ctrl":"",e.metaKey?"meta":"",e.shiftKey?"shift":"",e.altKey?"alt":""].join(":")}function nr(e,t){if(!t)return [...e];let n=Nt(t.disabledCommandIds),o=t.bindings,l=t.preventNativeConflicts!==false,r=t.preventCollisions!==false,i=new Set;return e.filter(d=>!n.has(d.id)).map(d=>{let c=d.shortcuts?[...d.shortcuts]:void 0;if(!!o&&Object.prototype.hasOwnProperty.call(o,d.id)&&o){let h=o[d.id],b=h===void 0?[]:tr(h);c=b.length>0?b:void 0;}if(c&&c.length>0){let h=[];for(let b of c){let m=So(b);if(!m||l&&To(m))continue;let p=or(m);r&&i.has(p)||(i.add(p),h.push(m));}c=h.length>0?h:void 0;}return {...d,shortcuts:c}})}function Qt(e){let t=e?.isFeatureEnabled??(()=>true),n=Zn(e?.headingOptions),o=e?.paragraphLabel?.trim()||"Paragraph",l=n.map(r=>{let i=Wn(r);return {id:`block.heading${i}`,label:`Heading ${i}`,description:Xn(r),category:"Block",action:a=>a.toggleHeading?.(r),shortcuts:[{key:i,ctrlKey:true,altKey:true}],keywords:["heading",r],condition:a=>t("blockFormat")&&_(a,"toggleHeading")}});return [{id:"format.bold",label:"Toggle Bold",description:"Make text bold or remove bold formatting",category:"Format",action:r=>r.toggleBold?.(),shortcuts:[{key:"b",ctrlKey:true}],keywords:["bold","strong","format"],condition:r=>t("bold")&&_(r,"toggleBold")},{id:"format.italic",label:"Toggle Italic",description:"Make text italic or remove italic formatting",category:"Format",action:r=>r.toggleItalic?.(),shortcuts:[{key:"i",ctrlKey:true}],keywords:["italic","emphasis","format"],condition:r=>t("italic")&&_(r,"toggleItalic")},{id:"format.underline",label:"Toggle Underline",description:"Add or remove underline formatting",category:"Format",action:r=>r.toggleUnderline?.(),shortcuts:[{key:"u",ctrlKey:true}],keywords:["underline","format"],condition:r=>t("underline")&&_(r,"toggleUnderline")},{id:"format.strikethrough",label:"Toggle Strikethrough",description:"Add or remove strikethrough formatting",category:"Format",action:r=>r.toggleStrikethrough?.(),keywords:["strikethrough","format"],condition:r=>t("strikethrough")&&_(r,"toggleStrikethrough")},{id:"format.subscript",label:"Toggle Subscript",description:"Format text as subscript",category:"Format",action:r=>r.toggleSubscript?.(),keywords:["subscript","format"],condition:r=>t("subscript")&&Jn(r)},{id:"format.superscript",label:"Toggle Superscript",description:"Format text as superscript",category:"Format",action:r=>r.toggleSuperscript?.(),keywords:["superscript","format"],condition:r=>t("superscript")&&qn(r)},{id:"format.code",label:"Toggle Inline Code",description:"Format text as inline code",category:"Format",action:r=>r.formatText?.("code"),shortcuts:[{key:"`",ctrlKey:true}],keywords:["code","inline","format"],condition:r=>t("codeFormat")&&_(r,"formatText")},{id:"block.paragraph",label:o,description:"Convert to paragraph",category:"Block",action:r=>r.toggleParagraph?.(),shortcuts:[{key:"0",ctrlKey:true,altKey:true}],keywords:["paragraph","text"],condition:r=>t("blockFormat")&&_(r,"toggleParagraph")},...l,{id:"block.quote",label:"Quote",description:"Convert to blockquote",category:"Block",action:r=>r.toggleQuote?.(),keywords:["quote","blockquote"],condition:r=>t("blockFormat")&&_(r,"toggleQuote")},{id:"block.align-left",label:"Align Left",description:"Align selected blocks to the left",category:"Block",action:r=>r.setTextAlignment?.("left"),keywords:["align","left","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.align-center",label:"Align Center",description:"Center-align selected blocks",category:"Block",action:r=>r.setTextAlignment?.("center"),keywords:["align","center","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.align-right",label:"Align Right",description:"Align selected blocks to the right",category:"Block",action:r=>r.setTextAlignment?.("right"),keywords:["align","right","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.align-justify",label:"Justify",description:"Justify selected blocks",category:"Block",action:r=>r.setTextAlignment?.("justify"),keywords:["align","justify","text"],condition:r=>t("blockFormat")&&_(r,"setTextAlignment")},{id:"block.codeblock",label:"Code Block",description:"Convert to code block",category:"Block",action:r=>r.toggleCodeBlock?.(),shortcuts:[{key:"`",ctrlKey:true,shiftKey:true}],keywords:["code","block"],condition:r=>t("code")&&_(r,"toggleCodeBlock")},{id:"block.code-language",label:"Set Code Language",description:"Set language for selected code block",category:"Block",action:r=>{if(!r.setCodeLanguage)return;let i=prompt("Code language (e.g. ts, css, python):")?.trim();i&&r.setCodeLanguage(i);},keywords:["code","language","syntax"],condition:r=>t("codeIntelligence")&&Eo(r)},{id:"block.code-language.auto",label:"Auto-Detect Code Language",description:"Detect language from selected code block",category:"Block",action:r=>{r.autoDetectCodeLanguage?.();},keywords:["code","language","auto","detect"],condition:r=>t("codeIntelligence")&&Eo(r)},{id:"list.bullet",label:"Bullet List",description:"Create or toggle bullet list",category:"List",action:r=>r.toggleUnorderedList?.(),shortcuts:[{key:"l",ctrlKey:true,shiftKey:true}],keywords:["list","bullet"],condition:r=>t("list")&&_(r,"toggleUnorderedList")},{id:"list.numbered",label:"Numbered List",description:"Create or toggle numbered list",category:"List",action:r=>r.toggleOrderedList?.(),shortcuts:[{key:"l",ctrlKey:true,altKey:true}],keywords:["list","numbered"],condition:r=>t("list")&&_(r,"toggleOrderedList")},{id:"list.check",label:"Checklist",description:"Create or toggle checklist",category:"List",action:r=>r.toggleCheckList?.(),shortcuts:[{key:"x",ctrlKey:true,shiftKey:true}],keywords:["list","check","todo","task"],condition:r=>t("list")&&_(r,"toggleCheckList")},{id:"link.insert",label:"Insert Link",description:"Insert or edit a link",category:"Insert",action:r=>r.insertLink?.(),shortcuts:[{key:"k",ctrlKey:true}],keywords:["link","url"],condition:r=>t("link")&&_(r,"insertLink")},{id:"link.remove",label:"Remove Link",description:"Remove link formatting",category:"Format",action:r=>r.removeLink?.(),shortcuts:[{key:"k",ctrlKey:true,shiftKey:true}],keywords:["unlink","remove","link"],condition:r=>t("link")&&_(r,"removeLink")},{id:"insert.horizontal-rule",label:"Insert Horizontal Rule",description:"Insert a horizontal line separator",category:"Insert",action:r=>r.insertHorizontalRule?.(),keywords:["horizontal","rule","hr","divider","separator"],condition:r=>t("horizontalRule")&&_(r,"insertHorizontalRule")},{id:"insert.image",label:"Insert Image",description:"Insert an image from URL",category:"Insert",action:r=>{let i=prompt("Enter image URL:");if(i){let a=prompt("Enter alt text:")||"";r.insertImage?.({src:i,alt:a});}},keywords:["image","photo"],condition:r=>t("image")&&_(r,"insertImage")},{id:"insert.gif",label:"Insert GIF",description:"Insert an animated GIF from URL",category:"Insert",action:r=>{let i=prompt("Enter GIF URL:");i&&r.insertImage?.({src:i,alt:"GIF"});},keywords:["gif","animated","image"],condition:r=>t("image")&&_(r,"insertImage")},{id:"insert.emoji",label:"Insert Emoji",description:"Insert an emoji character",category:"Insert",action:r=>{let i=prompt("Enter emoji or shortcode (example :sparkles:):")?.trim();if(!i||typeof r.insertEmoji!="function")return;let a=i.match(/^:([a-z0-9_+-]+):$/i);if(a){let d=a[1];if(!d)return;if(typeof r.resolveEmojiShortcode=="function"){let c=r.resolveEmojiShortcode(d);if(c?.emoji){r.insertEmoji(c.emoji);return}}else if(typeof r.getEmojiSuggestions=="function"){let[c]=r.getEmojiSuggestions(d);if(c?.emoji){r.insertEmoji(c.emoji);return}}}r.insertEmoji(i);},keywords:["emoji","reaction","symbol","smile"],condition:r=>t("emoji")&&Qn(r)},{id:"insert.table",label:"Insert Table",description:"Insert a 3x3 table",category:"Insert",action:r=>r.insertTable?.({rows:3,columns:3,includeHeaders:true}),keywords:["table","grid"],condition:r=>t("table")&&_(r,"insertTable")},{id:"insert.iframe",label:"Insert iframe",description:"Insert an iframe embed from URL",category:"Insert",action:r=>{if(typeof r.insertIframeEmbed!="function")return;let i=prompt("Enter iframe URL:");i&&r.insertIframeEmbed(i);},keywords:["iframe","embed","url"],condition:r=>t("iframeEmbed")&&Yn(r)},{id:"insert.youtube",label:"Insert YouTube Video",description:"Insert an embedded YouTube video",category:"Insert",action:r=>{if(typeof r.insertYouTubeEmbed!="function")return;let i=prompt("Enter YouTube URL:");i&&r.insertYouTubeEmbed(i);},keywords:["youtube","video","embed"],condition:r=>t("youTubeEmbed")&&Gn(r)},{id:"edit.undo",label:"Undo",description:"Undo the last action",category:"Edit",action:r=>r.undo?.(),shortcuts:[{key:"z",ctrlKey:true}],keywords:["undo","revert"],condition:r=>t("history")&&_(r,"undo")},{id:"edit.redo",label:"Redo",description:"Redo the last undone action",category:"Edit",action:r=>r.redo?.(),shortcuts:[{key:"y",ctrlKey:true},{key:"z",ctrlKey:true,shiftKey:true}],keywords:["redo","repeat"],condition:r=>t("history")&&_(r,"redo")},{id:"palette.show",label:"Show Command Palette",description:"Open the command palette",category:"View",action:r=>r.showCommandPalette?.(),shortcuts:[{key:"p",ctrlKey:true,shiftKey:true}],keywords:["command","palette"],condition:r=>t("commandPalette")&&_(r,"showCommandPalette")}]}function xo(e,t){let n=t?.commandPaletteShortcutOnly===true;return Gt(e,t).filter(o=>!n||!!o.shortcuts&&o.shortcuts.length>0).map(o=>({id:o.id,label:o.label,description:o.description,category:o.category,action:()=>o.action(e),keywords:o.keywords,shortcut:o.shortcuts?.[0]?Io(o.shortcuts[0]):void 0}))}function Lo(e,t){let n=new Set(["block.paragraph","block.quote","block.codeblock"]),o=a=>a.category==="Insert"||a.category==="List"?true:a.category==="Block"?a.id.startsWith("block.heading")?true:n.has(a.id):false,{allowlist:l,denylist:r}=er(t?.slashCommandVisibility),i=l.size>0;return Gt(e,t).filter(o).filter(a=>r.has(a.id)?false:i?l.has(a.id):true).map(a=>({id:a.id,label:a.label,description:a.description,category:a.category,action:()=>a.action(e),keywords:a.keywords,shortcut:a.shortcuts?.[0]?Io(a.shortcuts[0]):void 0}))}function Io(e){let t=[];return e.ctrlKey&&t.push("Ctrl"),e.metaKey&&t.push("Cmd"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),t.push(e.key.toUpperCase()),t.join("+")}function Fo(e,t=document.body,n){let o=Gt(e,n),l=r=>{let i=typeof n?.scope=="function"?n.scope():n?.scope;if(!(i&&r.target instanceof Node&&!i.contains(r.target))){for(let a of o)if(a.shortcuts){for(let d of a.shortcuts)if(!(n?.shortcutConfig?.preventNativeConflicts!==false&&$n(r,d))&&r.key.toLowerCase()===d.key.toLowerCase()&&!!r.ctrlKey==!!d.ctrlKey&&!!r.metaKey==!!d.metaKey&&!!r.shiftKey==!!d.shiftKey&&!!r.altKey==!!d.altKey){d.preventDefault!==false&&r.preventDefault(),(!a.condition||a.condition(e))&&a.action(e);return}}}};return t.addEventListener("keydown",l),()=>t.removeEventListener("keydown",l)}function w(e,t){let n=forwardRef(function({size:l=24,strokeWidth:r=2,...i},a){return jsx("svg",{ref:a,xmlns:"http://www.w3.org/2000/svg",width:l,height:l,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...i,children:t})});return n.displayName=e,n}var Mt=w("BoldIcon",jsx("path",{d:"M7 5h6a3 3 0 0 1 0 6H7zm0 6h7a3 3 0 1 1 0 6H7z"})),Ht=w("ItalicIcon",jsx("path",{d:"M10 4h8M6 20h8m-2-16-4 16"})),zt=w("UnderlineIcon",jsxs(Fragment,{children:[jsx("path",{d:"M8 4v7a4 4 0 1 0 8 0V4"}),jsx("path",{d:"M4 20h16"})]})),Pt=w("StrikethroughIcon",jsxs(Fragment,{children:[jsx("path",{d:"M17 5H9a3 3 0 0 0 0 6h6a3 3 0 1 1 0 6H7"}),jsx("path",{d:"M4 12h16"})]})),Rt=w("CodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"m8 9-4 3 4 3"}),jsx("path",{d:"m16 9 4 3-4 3"})]})),wo=w("CodeBlockIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 6h18v12H3z"}),jsx("path",{d:"m10 10-2 2 2 2"}),jsx("path",{d:"m14 10 2 2-2 2"})]})),ut=w("LinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"M10 14a4 4 0 0 1 0-6l1-1a4 4 0 0 1 6 6l-1 1"}),jsx("path",{d:"M14 10a4 4 0 0 1 0 6l-1 1a4 4 0 0 1-6-6l1-1"})]})),nt=w("UnlinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"M10 14a4 4 0 0 1 0-6l1-1"}),jsx("path",{d:"M14 10a4 4 0 0 1 0 6l-1 1"}),jsx("path",{d:"m3 3 18 18"})]})),At=w("ListIcon",jsxs(Fragment,{children:[jsx("path",{d:"M9 6h12"}),jsx("path",{d:"M9 12h12"}),jsx("path",{d:"M9 18h12"}),jsx("path",{d:"M4 6h.01"}),jsx("path",{d:"M4 12h.01"}),jsx("path",{d:"M4 18h.01"})]})),Bt=w("ListCheckIcon",jsxs(Fragment,{children:[jsx("path",{d:"M9 6h12"}),jsx("path",{d:"M9 12h12"}),jsx("path",{d:"M9 18h12"}),jsx("path",{d:"m4 6 1 1 2-2"}),jsx("path",{d:"m4 12 1 1 2-2"}),jsx("path",{d:"m4 18 1 1 2-2"})]})),Dt=w("ListOrderedIcon",jsxs(Fragment,{children:[jsx("path",{d:"M10 6h11"}),jsx("path",{d:"M10 12h11"}),jsx("path",{d:"M10 18h11"}),jsx("path",{d:"M4 6h1v4"}),jsx("path",{d:"M4 12h2l-2 2h2"}),jsx("path",{d:"M4 18h2"})]})),Oo=w("UndoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 8v5h5"}),jsx("path",{d:"M21 16a8 8 0 0 0-13-6L3 13"})]})),No=w("RedoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 8v5h-5"}),jsx("path",{d:"M3 16a8 8 0 0 1 13-6l5 3"})]})),Wt=w("ImageIcon",jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsx("circle",{cx:"8.5",cy:"9.5",r:"1.5"}),jsx("path",{d:"m21 15-5-5-8 8"})]})),ct=w("AlignLeftIcon",jsxs(Fragment,{children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M4 10h10"}),jsx("path",{d:"M4 14h16"}),jsx("path",{d:"M4 18h10"})]})),rt=w("AlignCenterIcon",jsxs(Fragment,{children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M7 10h10"}),jsx("path",{d:"M4 14h16"}),jsx("path",{d:"M7 18h10"})]})),Mo=w("AlignJustifyIcon",jsxs(Fragment,{children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M4 10h16"}),jsx("path",{d:"M4 14h16"}),jsx("path",{d:"M4 18h16"})]})),dt=w("AlignRightIcon",jsxs(Fragment,{children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M10 10h10"}),jsx("path",{d:"M4 14h16"}),jsx("path",{d:"M10 18h10"})]})),Xt=w("UploadIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 16V6"}),jsx("path",{d:"m8 10 4-4 4 4"}),jsx("path",{d:"M4 18h16"})]})),Ho=w("MinusIcon",jsx("path",{d:"M5 12h14"})),zo=w("TableIcon",jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsx("path",{d:"M3 10h18M9 4v16M15 4v16"})]})),Po=w("FileCodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),jsx("path",{d:"M14 2v5h5"}),jsx("path",{d:"m10 13-2 2 2 2"}),jsx("path",{d:"m14 13 2 2-2 2"})]})),Tl=w("EyeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6S2 12 2 12z"}),jsx("circle",{cx:"12",cy:"12",r:"2.5"})]})),Ro=w("HighlighterIcon",jsxs(Fragment,{children:[jsx("path",{d:"m9 15-4 4 2 2 4-4"}),jsx("path",{d:"m14 4 6 6-7 7-6-6z"})]})),Sl=w("PencilIcon",jsxs(Fragment,{children:[jsx("path",{d:"m3 21 3.5-.7L19 7.8a2.1 2.1 0 0 0 0-3L17.2 3a2.1 2.1 0 0 0-3 0L1.7 15.5z"}),jsx("path",{d:"m14 4 6 6"})]})),Kt=w("CommandIcon",jsx(Fragment,{children:jsx("path",{d:"M8 4a3 3 0 1 0 0 6h8a3 3 0 1 0 0-6 3 3 0 0 0-3 3v10a3 3 0 1 0 6 0v-8a3 3 0 1 0-6 0 3 3 0 0 0 3 3H8a3 3 0 1 0 0 6 3 3 0 0 0 3-3V7a3 3 0 1 0-6 0v8a3 3 0 1 0 6 0"})})),Ao=w("PaletteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 3a9 9 0 1 0 0 18h1a2 2 0 0 0 0-4h-1a2 2 0 0 1 0-4h2a5 5 0 0 0 0-10z"}),jsx("circle",{cx:"7.5",cy:"10",r:"1"}),jsx("circle",{cx:"10",cy:"7.5",r:"1"}),jsx("circle",{cx:"14",cy:"7.5",r:"1"}),jsx("circle",{cx:"16.5",cy:"11",r:"1"})]})),Bo=w("TypeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M12 6v12"}),jsx("path",{d:"M8 18h8"})]})),Ut=w("QuoteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M7 17H4a2 2 0 0 1-2-2v-3a5 5 0 0 1 5-5h1v3H7a2 2 0 0 0-2 2v1h2z"}),jsx("path",{d:"M17 17h-3a2 2 0 0 1-2-2v-3a5 5 0 0 1 5-5h1v3h-1a2 2 0 0 0-2 2v1h2z"})]})),Do=w("IndentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 6h14"}),jsx("path",{d:"M3 10h10"}),jsx("path",{d:"M3 14h14"}),jsx("path",{d:"M3 18h10"}),jsx("path",{d:"m16 11 4 3-4 3"})]})),Ko=w("OutdentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 6h14"}),jsx("path",{d:"M3 10h10"}),jsx("path",{d:"M3 14h14"}),jsx("path",{d:"M3 18h10"}),jsx("path",{d:"m20 11-4 3 4 3"})]})),Uo=w("SunIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]})),jo=w("MoonIcon",jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 1 0 9.8 9.8z"})),Vo=w("SearchIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"11",cy:"11",r:"7"}),jsx("path",{d:"m21 21-4.3-4.3"})]})),Zt=w("EmojiIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"9"}),jsx("path",{d:"M8.5 10h.01M15.5 10h.01"}),jsx("path",{d:"M8 15c1 1 2.2 1.5 4 1.5s3-.5 4-1.5"})]})),_o=w("SubscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 6 6 8"}),jsx("path",{d:"m10 6-6 8"}),jsx("path",{d:"M14 18h6"}),jsx("path",{d:"m16 15 2 3-2 3"})]})),$o=w("SuperscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 6 6 8"}),jsx("path",{d:"m10 6-6 8"}),jsx("path",{d:"M14 9h6"}),jsx("path",{d:"m16 12 2-3-2-3"})]})),Jo=w("ChevronDownIcon",jsx("path",{d:"m6 9 6 6 6-6"})),qo=w("CloseIcon",jsxs(Fragment,{children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));function Qo({isOpen:e,onClose:t,commands:n}){let[o,l]=useState(""),[r,i]=useState(0),a=useRef(null),d=useRef(null),c=n.filter(b=>`${b.label} ${b.description||""} ${b.keywords?.join(" ")||""}`.toLowerCase().includes(o.toLowerCase())),E=c.reduce((b,m)=>{let p=m.category||"Other";return b[p]||(b[p]=[]),b[p].push(m),b},{}),h=c;return useEffect(()=>{i(0);},[o]),useEffect(()=>{e&&a.current&&(a.current.focus({preventScroll:true}),l(""),i(0));},[e]),useEffect(()=>{if(!e)return;let b=d.current;if(!b)return;b.querySelector(".luthor-command-palette-item.selected")?.scrollIntoView({block:"nearest"});},[e,r,o]),useEffect(()=>{let b=m=>{if(e)switch(m.key){case "Escape":m.preventDefault(),m.stopPropagation(),t();break;case "ArrowDown":m.preventDefault(),m.stopPropagation(),i(p=>Math.min(p+1,h.length-1));break;case "ArrowUp":m.preventDefault(),m.stopPropagation(),i(p=>Math.max(p-1,0));break;case "Enter":m.preventDefault(),m.stopPropagation(),h[r]&&(h[r].action(),t());break}};return document.addEventListener("keydown",b,true),()=>document.removeEventListener("keydown",b,true)},[e,r,h,t]),e?jsx("div",{className:"luthor-command-palette-overlay",onClick:t,children:jsxs("div",{className:"luthor-command-palette",role:"dialog","aria-modal":"true","aria-label":"Command Palette",onClick:b=>b.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(Vo,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:a,type:"text",placeholder:"Type a command or search...",value:o,onChange:b=>l(b.target.value),className:"luthor-command-palette-input"}),jsx("kbd",{className:"luthor-command-palette-kbd",children:"ESC"})]}),jsx("div",{ref:d,className:"luthor-command-palette-list",children:Object.keys(E).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(E).map(([b,m])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:b}),m.map(p=>{let $=h.indexOf(p);return jsxs("div",{className:`luthor-command-palette-item ${$===r?"selected":""}`,onClick:()=>{p.action(),t();},onMouseEnter:()=>i($),children:[jsxs("div",{className:"luthor-command-palette-item-content",children:[jsx("div",{className:"luthor-command-palette-item-title",children:p.label}),p.description&&jsx("div",{className:"luthor-command-palette-item-description",children:p.description})]}),p.shortcut&&jsx("kbd",{className:"luthor-command-palette-item-shortcut",children:p.shortcut})]},p.id)})]},b))}),jsx("div",{className:"luthor-command-palette-footer",children:jsxs("span",{className:"luthor-command-palette-hint",children:[jsx(Kt,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var ir={"--luthor-bg":"#ffffff","--luthor-fg":"#0f172a","--luthor-border":"#e2e8f0","--luthor-border-hover":"#cbd5e1","--luthor-border-active":"#94a3b8","--luthor-accent":"#0f172a","--luthor-accent-hover":"#1e293b","--luthor-shadow":"rgba(0, 0, 0, 0.08)","--luthor-muted":"#f8fafc","--luthor-muted-fg":"#64748b","--luthor-theme-transition":"0.2s ease","--luthor-drag-gutter-width":"56px","--luthor-line-height-ratio":"1","--luthor-toolbar-bg":"#f8fafc","--luthor-toolbar-section-border":"#e2e8f0","--luthor-toolbar-button-fg":"#0f172a","--luthor-toolbar-button-hover-bg":"#f8fafc","--luthor-toolbar-button-hover-border":"#cbd5e1","--luthor-toolbar-button-hover-shadow":"0 4px 12px rgba(0, 0, 0, 0.15)","--luthor-toolbar-button-press-shadow":"0 2px 8px rgba(0, 0, 0, 0.1)","--luthor-toolbar-button-active-bg":"#0f172a","--luthor-toolbar-button-active-border":"#0f172a","--luthor-toolbar-button-active-fg":"#ffffff","--luthor-toolbar-button-active-shadow":"0 2px 8px rgba(0, 0, 0, 0.2)","--luthor-toolbar-button-overlay":"linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%)","--luthor-toolbar-button-active-overlay":"linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%)","--luthor-toolbar-color-indicator-border":"#e2e8f0","--luthor-toolbar-highlight-bg":"#f8fafc","--luthor-quote-bg":"#f8fafc","--luthor-quote-fg":"#0f172a","--luthor-quote-border":"#0f172a","--luthor-syntax-comment":"#64748b","--luthor-syntax-keyword":"#64748b","--luthor-syntax-string":"#64748b","--luthor-syntax-number":"#64748b","--luthor-syntax-function":"#64748b","--luthor-syntax-variable":"#64748b","--luthor-floating-bg":"#ffffff","--luthor-floating-fg":"#0f172a","--luthor-floating-border":"#e2e8f0","--luthor-floating-shadow":"rgba(0, 0, 0, 0.08)","--luthor-floating-muted":"#f8fafc","--luthor-floating-border-hover":"#cbd5e1","--luthor-floating-border-active":"#94a3b8","--luthor-floating-accent":"#0f172a","--luthor-floating-accent-fg":"#ffffff","--luthor-z-dropdown":"20","--luthor-z-popover":"24","--luthor-z-menu":"28","--luthor-z-overlay":"32","--luthor-z-modal":"36","--luthor-preset-bg":"#ffffff","--luthor-preset-fg":"#0f172a","--luthor-preset-border":"#dbe2ea","--luthor-preset-muted":"#f8fafc","--luthor-preset-muted-fg":"#64748b","--luthor-preset-accent":"#2563eb","--luthor-preset-radius":"10px","--luthor-preset-shadow":"0 1px 3px rgba(15, 23, 42, 0.08)","--luthor-preset-content-padding":"16px","--luthor-preset-content-min-height":"180px"};function lr(e){return e?e.closest(".luthor-editor-wrapper"):null}function ar(e){return e?lr(e)??e:null}function sr(e){if(typeof window>"u"||!e)return {};let t=window.getComputedStyle(e),n={};for(let[o,l]of Object.entries(ir)){let r=t.getPropertyValue(o).trim()||l;n[o]=r;}return n}function We(e){return sr(ar(e))}function mt(){if(typeof window>"u")return {};let t=window.getSelection()?.anchorNode;if(!t)return {};let n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return We(n)}function Xo({isOpen:e,query:t,position:n,suggestions:o,onClose:l,onExecute:r}){let[i,a]=useState(0);if(useEffect(()=>{a(0);},[t,e]),useEffect(()=>{if(!e)return;let c=E=>{let h=o.length>0;switch(E.key){case "Escape":E.preventDefault(),E.stopPropagation(),l();break;case "ArrowDown":if(!h)return;E.preventDefault(),E.stopPropagation(),a(b=>Math.min(b+1,Math.max(o.length-1,0)));break;case "ArrowUp":if(!h)return;E.preventDefault(),E.stopPropagation(),a(b=>Math.max(b-1,0));break;case "Enter":case "Tab":if(!h||!o[i])return;E.preventDefault(),E.stopPropagation(),r(o[i].emoji);break}};return document.addEventListener("keydown",c,true),()=>document.removeEventListener("keydown",c,true)},[e,l,r,i,o]),!e||!n)return null;let d=jsxs("div",{className:"luthor-emoji-menu",style:{left:n.x,top:n.y,...mt()},onPointerDown:c=>{c.stopPropagation();},onMouseDown:c=>{c.stopPropagation();},children:[jsxs("div",{className:"luthor-emoji-menu-header",children:[jsx("span",{className:"luthor-emoji-menu-title",children:"Emoji"}),jsxs("span",{className:"luthor-emoji-menu-query",children:[":",t]})]}),jsx("div",{className:"luthor-emoji-menu-list",children:o.length===0?jsx("div",{className:"luthor-emoji-menu-empty",children:"No matching emoji"}):o.map((c,E)=>{let h=E===i,b=c.shortcodes[0]?`:${c.shortcodes[0]}:`:"";return jsxs("button",{type:"button",className:`luthor-emoji-menu-item ${h?"selected":""}`,onMouseEnter:()=>a(E),onMouseDown:m=>{m.preventDefault(),m.stopPropagation();},onClick:m=>{m.preventDefault(),m.stopPropagation(),r(c.emoji);},children:[jsx("span",{className:"luthor-emoji-menu-item-symbol","aria-hidden":"true",children:c.emoji}),jsxs("span",{className:"luthor-emoji-menu-item-content",children:[jsx("span",{className:"luthor-emoji-menu-item-title",children:c.label}),b&&jsx("span",{className:"luthor-emoji-menu-item-shortcode",children:b})]})]},`${c.emoji}-${c.label}`)})})]});return typeof document>"u"?d:createPortal(d,document.body)}function tn({isOpen:e,query:t,position:n,commands:o,onClose:l,onExecute:r}){let[i,a]=useState(0),d=useMemo(()=>{let h=t.trim().toLowerCase();return h?o.filter(b=>`${b.label} ${b.description||""} ${b.keywords?.join(" ")||""}`.toLowerCase().includes(h)):o},[o,t]),c=useMemo(()=>d.reduce((h,b)=>{let m=b.category||"Other";return h[m]||(h[m]=[]),h[m].push(b),h},{}),[d]);if(useEffect(()=>{a(0);},[t,e]),useEffect(()=>{if(!e)return;let h=b=>{let m=d.length>0;switch(b.key){case "Escape":b.preventDefault(),b.stopPropagation(),l();break;case "ArrowDown":if(!m)return;b.preventDefault(),b.stopPropagation(),a(p=>Math.min(p+1,Math.max(d.length-1,0)));break;case "ArrowUp":if(!m)return;b.preventDefault(),b.stopPropagation(),a(p=>Math.max(p-1,0));break;case "Enter":case "Tab":if(!m||!d[i])return;b.preventDefault(),b.stopPropagation(),r(d[i].id);break}};return document.addEventListener("keydown",h,true),()=>document.removeEventListener("keydown",h,true)},[d,e,l,r,i]),!e||!n)return null;let E=jsxs("div",{className:"luthor-slash-menu",style:{left:n.x,top:n.y,...mt()},onPointerDown:h=>{h.stopPropagation();},onMouseDown:h=>{h.stopPropagation();},children:[jsxs("div",{className:"luthor-slash-menu-header",children:[jsx("span",{className:"luthor-slash-menu-title",children:"Insert block"}),jsxs("span",{className:"luthor-slash-menu-query",children:["/",t]})]}),jsx("div",{className:"luthor-slash-menu-list",children:d.length===0?jsx("div",{className:"luthor-slash-menu-empty",children:"No matching commands"}):Object.entries(c).map(([h,b])=>jsxs("div",{className:"luthor-slash-menu-group",children:[jsx("div",{className:"luthor-slash-menu-group-title",children:h}),b.map(m=>{let p=d.indexOf(m);return jsxs("button",{type:"button",className:`luthor-slash-menu-item ${p===i?"selected":""}`,onMouseEnter:()=>a(p),onMouseDown:N=>{N.preventDefault(),N.stopPropagation();},onClick:N=>{N.preventDefault(),N.stopPropagation(),r(m.id);},children:[jsxs("span",{className:"luthor-slash-menu-item-content",children:[jsx("span",{className:"luthor-slash-menu-item-title",children:m.label}),m.description&&jsx("span",{className:"luthor-slash-menu-item-description",children:m.description})]}),m.shortcut&&jsx("kbd",{className:"luthor-slash-menu-item-shortcut",children:m.shortcut})]},m.id)})]},h))})]});return typeof document>"u"?E:createPortal(E,document.body)}function L({children:e,onClick:t,title:n,active:o,disabled:l,className:r,type:i="button"}){return jsx("button",{type:i,className:`luthor-toolbar-button${o?" active":""}${r?` ${r}`:""}`,onClick:t,title:n,disabled:l,children:e})}function to({children:e,onClick:t,variant:n="primary",type:o="button",className:l}){return jsx("button",{type:o,onClick:t,className:`${n==="primary"?"luthor-button-primary":"luthor-button-secondary"}${l?` ${l}`:""}`,children:e})}function kt({value:e,onValueChange:t,options:n,placeholder:o="Select..."}){let[l,r]=useState(false),[i,a]=useState(void 0),d=useRef(null),c=useRef(null);useEffect(()=>{if(!l)return;let h=()=>{let b=d.current?.querySelector(".luthor-select-trigger");if(!b)return;let m=b.getBoundingClientRect();a({position:"fixed",top:m.bottom+4,left:m.left,width:m.width,...We(b)});};return h(),window.addEventListener("resize",h),window.addEventListener("scroll",h,true),()=>{window.removeEventListener("resize",h),window.removeEventListener("scroll",h,true);}},[l]),useEffect(()=>{function h(b){let m=b.target;d.current?.contains(m)||c.current?.contains(m)||r(false);}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);let E=n.find(h=>h.value===e);return jsxs("div",{className:"luthor-select",ref:d,children:[jsxs("button",{className:`luthor-select-trigger ${l?"open":""}`,onClick:()=>r(!l),type:"button",children:[jsx("span",{children:E?.label||o}),jsx(Jo,{size:14})]}),l&&typeof document<"u"&&createPortal(jsx("div",{ref:c,className:"luthor-select-dropdown",style:i,children:n.map(h=>jsx("button",{className:`luthor-select-option ${e===h.value?"selected":""}`,onClick:()=>{t(h.value),r(false);},type:"button",children:h.label},h.value))}),document.body)]})}function Et({trigger:e,children:t,isOpen:n,onOpenChange:o}){let l=useRef(null),r=useRef(null),i=useRef(null),[a,d]=useState(void 0);return useEffect(()=>{if(!n)return;let c=()=>{let E=r.current;if(!E)return;let h=E.getBoundingClientRect();d({position:"fixed",top:h.bottom+4,left:h.left,...We(E)});};return c(),window.addEventListener("resize",c),window.addEventListener("scroll",c,true),()=>{window.removeEventListener("resize",c),window.removeEventListener("scroll",c,true);}},[n]),useEffect(()=>{function c(E){let h=E.target;l.current?.contains(h)||i.current?.contains(h)||o(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]),jsxs("div",{className:"luthor-dropdown",ref:l,children:[jsx("div",{ref:r,onClick:()=>o(!n),children:e}),n&&typeof document<"u"&&createPortal(jsx("div",{ref:i,className:"luthor-dropdown-content",style:a,children:t}),document.body)]})}function nn({isOpen:e,onClose:t,title:n,children:o}){let l=useRef(null);return useEffect(()=>{function r(a){l.current&&!l.current.contains(a.target)&&t();}function i(a){a.key==="Escape"&&t();}return e&&(document.addEventListener("mousedown",r),document.addEventListener("keydown",i)),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",i);}},[e,t]),e?jsx("div",{className:"luthor-dialog-overlay",children:jsxs("div",{className:"luthor-dialog",ref:l,children:[jsxs("div",{className:"luthor-dialog-header",children:[jsx("h3",{className:"luthor-dialog-title",children:n}),jsx("button",{className:"luthor-dialog-close",onClick:t,type:"button",children:jsx(qo,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:o})]})}):null}function rn({isVisible:e,selectionRect:t,commands:n,activeStates:o,editorTheme:l="light",hide:r,isFeatureEnabled:i=()=>true}){let a=useRef(null),[d,c]=useState(""),[E,h]=useState(""),[b,m]=useState(""),[p,$]=useState(""),[N,A]=useState(""),[Q,J]=useState(""),[C,ne]=useState(null),[se,Y]=useState(null),[g,O]=useState(null),k=!!o.isIframeEmbedSelected,j=!!o.isYouTubeEmbedSelected,R=i("iframeEmbed"),te=i("youTubeEmbed"),B=i("image"),be=R&&k||te&&j;if(useEffect(()=>{if(!e)return;let F=I=>{let q=I.target;q&&(a.current?.contains(q)||r?.());};return document.addEventListener("mousedown",F,true),document.addEventListener("touchstart",F,true),()=>{document.removeEventListener("mousedown",F,true),document.removeEventListener("touchstart",F,true);}},[e,r]),useEffect(()=>{if(!e||!k)return;let F=false;return typeof n.getIframeEmbedCaption=="function"&&n.getIframeEmbedCaption().then(I=>{F||h(I??"");}),typeof n.getIframeEmbedUrl=="function"&&n.getIframeEmbedUrl().then(I=>{F||c(I??"");}),ne(null),()=>{F=true;}},[n,k,e]),useEffect(()=>{if(!e||!o.imageSelected)return;let F=false;return typeof n.getImageCaption=="function"&&n.getImageCaption().then(I=>{F||m(I??"");}),()=>{F=true;}},[o.imageSelected,n,e]),useEffect(()=>{if(!e||!j)return;let F=false;return typeof n.getYouTubeEmbedCaption=="function"&&n.getYouTubeEmbedCaption().then(I=>{F||$(I??"");}),typeof n.getYouTubeEmbedUrl=="function"&&n.getYouTubeEmbedUrl().then(I=>{F||A(I??"");}),Y(null),()=>{F=true;}},[n,e,j]),useEffect(()=>{if(!e||!o.isLink)return;let F=false;return typeof n.getCurrentLink=="function"&&n.getCurrentLink().then(I=>{!F&&I&&J(I.url??"");}),O(null),()=>{F=true;}},[o.isLink,n,e]),!e||!t)return null;let ie={...mt(),position:"absolute",top:t.y,left:t.positionFromRight?"auto":t.x,right:t.positionFromRight?10:"auto",zIndex:9999,pointerEvents:"auto"};if(be){let F=K=>{if(k){n.setIframeEmbedAlignment?.(K);return}j&&n.setYouTubeEmbedAlignment?.(K);},I=k?o.isIframeEmbedAlignedLeft:o.isYouTubeEmbedAlignedLeft,q=k?o.isIframeEmbedAlignedCenter:o.isYouTubeEmbedAlignedCenter,tt=k?o.isIframeEmbedAlignedRight:o.isYouTubeEmbedAlignedRight,ve=k?typeof n.setIframeEmbedCaption=="function":typeof n.setYouTubeEmbedCaption=="function",Se=k?typeof n.updateIframeEmbedUrl=="function":typeof n.updateYouTubeEmbedUrl=="function",Je=k?E:p,xe=k?h:$,Be=k?d:N,Z=k?C:se,Le=()=>{if(ve){if(k){n.setIframeEmbedCaption?.(E);return}n.setYouTubeEmbedCaption?.(p);}},Pe=K=>{k?ne(K):Y(K);},le=K=>{k?c(K):A(K);},Ce=()=>{if(!Se)return;if(!(k?n.updateIframeEmbedUrl?.(d)??false:n.updateYouTubeEmbedUrl?.(N)??false)){Pe(k?"Enter a valid http(s) URL":"Enter a valid YouTube URL"),k&&typeof n.getIframeEmbedUrl=="function"?n.getIframeEmbedUrl().then(Re=>c(Re??"")):!k&&typeof n.getYouTubeEmbedUrl=="function"&&n.getYouTubeEmbedUrl().then(Re=>A(Re??""));return}Pe(null);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:ie,children:[jsx(L,{onClick:()=>F("left"),active:I,title:"Align Left",children:jsx(ct,{size:14})}),jsx(L,{onClick:()=>F("center"),active:q,title:"Align Center",children:jsx(rt,{size:14})}),jsx(L,{onClick:()=>F("right"),active:tt,title:"Align Right",children:jsx(dt,{size:14})}),ve||Se?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-fields",children:[Se?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:Be,className:`luthor-floating-toolbar-input${Z?" is-error":""}`,placeholder:k?"https://example.com/embed":"https://youtube.com/watch?v=...","aria-label":k?"Iframe URL":"YouTube URL","aria-invalid":Z?true:void 0,onChange:K=>{le(K.target.value),Z&&Pe(null);},onBlur:Ce,onKeyDown:K=>{K.key==="Enter"&&(K.preventDefault(),Ce());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:Ce,children:"Update URL"})]}):null,ve?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:Je,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":k?"Iframe caption":"YouTube caption",onChange:K=>xe(K.target.value),onBlur:Le,onKeyDown:K=>{K.key==="Enter"&&(K.preventDefault(),Le());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:Le,children:"Update Caption"})]}):null]})]}):null]})}if(B&&o.imageSelected){let F=typeof n.setImageCaption=="function",I=()=>{F&&n.setImageCaption(b);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:ie,children:[jsx(L,{onClick:()=>n.setImageAlignment("left"),active:o.isImageAlignedLeft,title:"Align Left",children:jsx(ct,{size:14})}),jsx(L,{onClick:()=>n.setImageAlignment("center"),active:o.isImageAlignedCenter,title:"Align Center",children:jsx(rt,{size:14})}),jsx(L,{onClick:()=>n.setImageAlignment("right"),active:o.isImageAlignedRight,title:"Align Right",children:jsx(dt,{size:14})}),F?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:b,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":"Image caption",onChange:q=>m(q.target.value),onBlur:I,onKeyDown:q=>{q.key==="Enter"&&(q.preventDefault(),I());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:I,children:"Update Caption"})]})]}):null]})}let Fe=i("bold"),ue=i("italic"),we=i("underline"),Oe=i("strikethrough"),Ne=i("codeFormat"),ge=i("blockFormat"),Me=i("link"),Ae=i("list"),He=Fe||ue||we||Oe,me=Ne||ge||Me,ze=Ae,ye=!!o.isLink&&typeof n.updateLink=="function"&&typeof n.removeLink=="function",he=()=>{if(!ye)return;if(!(n.updateLink?.(Q)??false)){O("Enter a valid URL"),typeof n.getCurrentLink=="function"&&n.getCurrentLink().then(I=>{J(I?.url??"");});return}O(null);};return !He&&!me&&!ze?null:jsxs("div",{className:"luthor-floating-toolbar","data-theme":l,ref:a,style:ie,children:[He?jsxs(Fragment,{children:[Fe?jsx(L,{onClick:()=>n.toggleBold(),active:o.bold,title:"Bold",children:jsx(Mt,{size:14})}):null,ue?jsx(L,{onClick:()=>n.toggleItalic(),active:o.italic,title:"Italic",children:jsx(Ht,{size:14})}):null,we?jsx(L,{onClick:()=>n.toggleUnderline(),active:o.underline,title:"Underline",children:jsx(zt,{size:14})}):null,Oe?jsx(L,{onClick:()=>n.toggleStrikethrough(),active:o.strikethrough,title:"Strikethrough",children:jsx(Pt,{size:14})}):null]}):null,He&&me?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,me?jsxs(Fragment,{children:[Ne?jsx(L,{onClick:()=>n.formatText("code"),active:o.code,title:"Inline Code",children:jsx(Rt,{size:14})}):null,ge?jsx(L,{onClick:()=>n.toggleQuote(),active:o.isQuote,title:"Quote",children:jsx(Ut,{size:14})}):null,Me?jsxs(Fragment,{children:[jsx(L,{onClick:()=>o.isLink?n.removeLink():n.insertLink(),active:o.isLink,title:o.isLink?"Remove Link":"Insert Link",children:o.isLink?jsx(nt,{size:14}):jsx(ut,{size:14})}),ye?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:Q,className:`luthor-floating-toolbar-input${g?" is-error":""}`,placeholder:"https://example.com","aria-label":"Link URL","aria-invalid":g?true:void 0,onChange:F=>{J(F.target.value),g&&O(null);},onBlur:he,onKeyDown:F=>{F.key==="Enter"&&(F.preventDefault(),he());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:he,children:"Update Link"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-danger",onClick:()=>n.removeLink(),"aria-label":"Unlink",children:jsx(nt,{size:13})})]}):null]}):null]}):null,(He||me)&&ze?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,ze?jsxs(Fragment,{children:[jsx(L,{onClick:()=>n.toggleUnorderedList(),active:o.unorderedList,title:"Bullet List",children:jsx(At,{size:14})}),jsx(L,{onClick:()=>n.toggleOrderedList(),active:o.orderedList,title:"Numbered List",children:jsx(Dt,{size:14})}),jsx(L,{onClick:()=>n.toggleCheckList(),active:o.checkList,title:"Checklist",children:jsx(Bt,{size:14})})]}):null]})}var Ke={commands:{},activeStates:{},editorTheme:"light",isFeatureEnabled:()=>true};function oo(e,t,n,o=()=>true){Ke.commands=e,Ke.activeStates=t,Ke.editorTheme=n,Ke.isFeatureEnabled=o;}function ln(){let e=rn,t=new FloatingToolbarExtension;return t.config={...t.config,render:n=>createElement(e,{...n,commands:Ke.commands,activeStates:Ke.activeStates,editorTheme:Ke.editorTheme,isFeatureEnabled:Ke.isFeatureEnabled}),getCommands:()=>Ke.commands,getActiveStates:()=>Ke.activeStates},t}var Cr=120,kr=58;function Er(e,t=kr){return e.length<=t?e:`${e.slice(0,t-3)}...`}function sn(){let e=window.getSelection();return !e||e.rangeCount===0?false:!e.getRangeAt(0).collapsed}function un(e,t){if(!(e instanceof Element))return null;let n=e.closest("a");return !(n instanceof HTMLAnchorElement)||!t.contains(n)?null:n}function gn({editor:e,commands:t,editorTheme:n="light",disabled:o=false}){let l=useRef(null),r=useRef(null),[i,a]=useState(null),[d,c]=useState(false),[E,h]=useState(""),[b,m]=useState(null),[p,$]=useState(null),N=useCallback(()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null);},[]),A=useCallback(()=>{N(),a(null),c(false),h(""),m(null),$(null);},[N]),Q=useCallback(()=>{N(),r.current=window.setTimeout(()=>{A();},Cr);},[N,A]),J=useCallback(g=>{let O=g.getBoundingClientRect(),k=O.bottom+8,j=Math.max(10,Math.min(O.left,window.innerWidth-340));$({top:k,left:j});},[]),C=useCallback((g,O)=>{if(typeof t.getLinkByKey!="function"){a(k=>!k||k.nodeKey!==g?k:{...k,url:O});return}t.getLinkByKey(g).then(k=>{if(!k){A();return}a(j=>!j||j.nodeKey!==g?j:{...j,url:k.url});});},[t,A]);useEffect(()=>{if(!e||o||typeof window>"u"){A();return}let g=e.getRootElement();if(!g){A();return}let O=te=>{let B=un(te.target,g);if(!B)return;if(sn()){A();return}N();let be=resolveLinkNodeKeyFromAnchor(e,B);if(!be)return;let ie=B.getAttribute("href")??B.href;a({nodeKey:be,url:ie,anchorEl:B}),J(B),m(null),d||h(ie),C(be,ie);},k=te=>{if(!i)return;let B=te.relatedTarget;B&&l.current?.contains(B)||un(B,g)||Q();},j=()=>{sn()&&A();},R=()=>{a(te=>{if(!te)return te;let B=te.anchorEl.isConnected&&g.contains(te.anchorEl)?te.anchorEl:g.querySelector(`a[data-lexical-node-key="${te.nodeKey}"]`);return B?(J(B),{...te,anchorEl:B,url:B.getAttribute("href")??B.href}):(A(),null)});};return g.addEventListener("mouseover",O),g.addEventListener("mouseout",k),document.addEventListener("selectionchange",j),window.addEventListener("scroll",R,true),window.addEventListener("resize",R),()=>{g.removeEventListener("mouseover",O),g.removeEventListener("mouseout",k),document.removeEventListener("selectionchange",j),window.removeEventListener("scroll",R,true),window.removeEventListener("resize",R),N();}},[t,o,e,i,d,A,Q,C,J,N]);let ne=useMemo(()=>{if(!(!i||!p))return {...We(i.anchorEl),position:"fixed",top:p.top,left:p.left,zIndex:10040}},[i,p]);if(!i||!p||typeof document>"u")return null;let se=()=>{(t.removeLinkByKey?.(i.nodeKey)??false)&&A();},Y=()=>{let g=E.trim();if(!(t.updateLinkByKey?.(i.nodeKey,g)??false)){m("Enter a valid URL"),C(i.nodeKey,i.url);return}a(k=>!k||k.nodeKey!==i.nodeKey?k:{...k,url:g}),m(null),c(false),queueMicrotask(()=>{C(i.nodeKey,g);});};return createPortal(jsx("div",{ref:l,className:"luthor-floating-toolbar luthor-link-hover-bubble","data-theme":n,style:ne,onMouseEnter:N,onMouseLeave:Q,children:d?jsxs(Fragment,{children:[jsx("input",{type:"url",value:E,className:`luthor-link-hover-bubble-input${b?" is-error":""}`,placeholder:"https://example.com","aria-label":"Edit link URL","aria-invalid":b?true:void 0,onChange:g=>{h(g.target.value),b&&m(null);},onKeyDown:g=>{if(g.key==="Enter"){g.preventDefault(),Y();return}g.key==="Escape"&&(g.preventDefault(),c(false),h(i.url),m(null));}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-primary",onClick:Y,children:"Update"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{c(false),h(i.url),m(null);},children:"Cancel"})]}):jsxs(Fragment,{children:[jsx("span",{className:"luthor-link-hover-bubble-url",title:i.url,children:Er(i.url)}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{h(i.url),c(true),m(null);},children:"Edit"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-danger",onClick:se,"aria-label":"Unlink",children:jsx(nt,{size:13})})]})}),document.body)}function mn({mode:e,onModeChange:t,labels:n,availableModes:o,isConverting:l}){let r=o??["visual","jsonb"],i={visual:n?.visual??"Visual",jsonb:n?.jsonb??"JSONB"};return jsxs("div",{className:"luthor-mode-tabs",children:[r.includes("visual")&&jsxs("button",{className:`luthor-mode-tab ${e==="visual"?"active":""}`,onClick:()=>t("visual"),children:[i.visual,l==="visual"&&jsx("span",{className:"luthor-tab-converting-spinner"})]}),r.includes("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 hn({value:e,onChange:t,placeholder:n,className:o}){let l=useRef(null);return useLayoutEffect(()=>{let r=l.current;if(!r)return;r.style.height="auto";let i=Math.max(r.scrollHeight,280);r.style.height=`${i}px`;},[e]),jsx("textarea",{ref:l,className:`luthor-source-view${o?` ${o}`:""}`,value:e,onChange:r=>t(r.target.value),placeholder:n,spellCheck:false})}function fn(e){return e.replace(/\r\n?/g,`
|
|
2
|
+
`)}function io(e){let t=fn(e).trim();if(!t)return "";try{let n=JSON.parse(t);return JSON.stringify(n,null,2)}catch{return t}}function ha(e){return fn(e).trim()}var lo=6,Fr=["#ffffff","#f2f2f2","#d9d9d9","#bfbfbf","#808080","#404040","#000000","#fbe5d6","#f8cbad","#f4b183","#ed7d31","#c55a11","#fff2cc","#ffe699","#ffd966","#ffc000","#bf9000","#7f6000","#e2f0d9","#c6e0b4","#a9d18e","#70ad47","#548235","#375623","#ddebf7","#bdd7ee","#9dc3e6","#5b9bd5","#2f75b5","#1f4e78","#e4dfec","#d9c2e9","#b4a7d6","#8e7cc3","#674ea7","#351c75"];function _t(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function wr(e,t){let n=_t(t);for(let o of e)if(_t(o.value)===n)return o.color;return null}function Or(e,t,n){if(!e||e==="default")return n;let o=wr(t,e);return o||e}function Nr(e,t){let n=e.trim();return /^#([\da-f]{6})$/i.test(n)?n:/^#([\da-f]{3})$/i.test(n)?`#${n.slice(1).split("").map(l=>`${l}${l}`).join("")}`:t}function Ve(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function bn(e){let t=e.split(",")[0]??"";return Ve(t.replace(/["']/g,""))}function $t(e){let t=e.trim().toLowerCase().match(/^(-?\d*\.?\d+)px$/);if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?n:null}function Vt(){if(typeof window>"u")return null;let t=window.getSelection()?.anchorNode;if(!t)return null;let n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!n||!n.closest(".luthor-content-editable"))return null;let l=window.getComputedStyle(n);return {fontFamily:l.fontFamily,fontSize:l.fontSize,lineHeight:l.lineHeight}}function Mr(e,t){if(!e)return null;let n=bn(e);return n?t.find(l=>Ve(l.value)===n?true:bn(l.fontFamily)===n)?.value??null:null}function Hr(e,t){if(!e)return null;let n=Ve(e),o=t.find(i=>Ve(String(i.value))===n?true:Ve(String(i.fontSize))===n);if(o)return String(o.value);let l=$t(e);if(l==null)return null;let r=null;for(let i of t){let a=$t(String(i.fontSize));if(a==null)continue;let d=Math.abs(a-l);(!r||d<r.distance)&&(r={value:String(i.value),distance:d});}return r?.value??null}function zr(e,t,n){if(!e)return null;let o=Ve(e),l=n.find(c=>Ve(c.value)===o?true:Ve(c.lineHeight)===o);if(l)return l.value;let r=t?$t(t):null,i=$t(e),a=null;if(i!=null&&r!=null&&r>0)a=i/r;else {let c=Number(e);Number.isFinite(c)&&(a=c);}if(a==null)return null;let d=null;for(let c of n){let E=Number(c.lineHeight);if(!Number.isFinite(E))continue;let h=Math.abs(E-a);(!d||h<d.distance)&&(d={value:c.value,distance:h});}return d?.value??null}function yn({title:e,value:t,options:n,recentColors:o,active:l,fallbackColor:r,highlight:i,onChange:a,onClear:d,onAddRecent:c}){let E=useRef(null),h=useRef(null),b=useRef(null),m=useRef(null),p=useRef(null),[$,N]=useState(false),[A,Q]=useState(void 0),J=Or(t,n,r),C=useMemo(()=>Fr,[]),ne=useMemo(()=>{let g=[...o].slice(0,lo);for(;g.length<lo;)g.push("");return g},[o]);useEffect(()=>()=>{m.current&&window.cancelAnimationFrame(m.current);},[]);let se=useCallback(g=>{p.current=g,!m.current&&(m.current=window.requestAnimationFrame(()=>{m.current=null,p.current&&(a(p.current),p.current=null);}));},[a]),Y=useCallback(g=>{let O=E.current;if(!O)return;let k=O.getBoundingClientRect();Q({position:"fixed",top:k.bottom+6,left:k.left,width:230,visibility:g?"visible":"hidden",...We(O)});},[]);return useLayoutEffect(()=>{if(!$)return;Y(false);let g=window.requestAnimationFrame(()=>{Y(true);});return ()=>{window.cancelAnimationFrame(g);}},[$,Y]),useEffect(()=>{if(!$)return;let g=j=>{let R=j.target;E.current?.contains(R)||h.current?.contains(R)||N(false);},O=j=>{j.key==="Escape"&&N(false);},k=()=>Y(true);return window.addEventListener("resize",k),window.addEventListener("scroll",k,true),document.addEventListener("mousedown",g),document.addEventListener("keydown",O),()=>{window.removeEventListener("resize",k),window.removeEventListener("scroll",k,true),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",O);}},[$,Y]),jsxs(Fragment,{children:[jsxs("button",{ref:E,type:"button",className:`luthor-toolbar-button luthor-color-button${l?" active":""}${i?" is-highlight":""}`,title:e,"aria-label":e,onClick:()=>N(g=>!g),children:[i?jsx(Ro,{size:15,className:"luthor-color-button-highlighter"}):jsx("span",{className:"luthor-color-button-letter",children:"A"}),jsx("span",{className:"luthor-color-button-indicator",style:{backgroundColor:J}})]}),$&&typeof document<"u"&&createPortal(jsxs("div",{ref:h,className:"luthor-color-picker",style:A,children:[jsx("div",{className:"luthor-color-picker-header",children:jsx("span",{className:"luthor-color-picker-title",children:e})}),jsxs("div",{className:"luthor-color-picker-section",children:[jsx("p",{className:"luthor-color-picker-label",children:"Colors"}),jsx("div",{className:"luthor-color-swatch-grid",children:C.map(g=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:g},"aria-label":`Use color ${g}`,onClick:()=>{a(g),c(g),N(false);}},g))})]}),jsxs("div",{className:"luthor-color-picker-section",children:[jsx("p",{className:"luthor-color-picker-label",children:"Recent colors"}),jsx("div",{className:"luthor-color-swatch-row",children:ne.map((g,O)=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:g||"transparent"},"aria-label":g?`Use recent color ${g}`:"Empty recent color slot",disabled:!g,onClick:()=>{g&&(a(g),c(g),N(false));}},`${g||"empty"}-${O}`))})]}),jsxs("div",{className:"luthor-color-picker-footer",children:[jsx("button",{type:"button",className:"luthor-color-picker-clear",onClick:()=>{d(),N(false);},children:"Reset to Default"}),jsxs("button",{type:"button",className:"luthor-color-picker-custom",onClick:()=>b.current?.click(),children:[jsx(Ao,{size:14}),jsx("span",{children:"Custom Color"})]}),jsx("input",{ref:b,type:"color",className:"luthor-color-picker-native luthor-color-picker-native-hidden",value:Nr(J,r),onInput:g=>{se(g.target.value);},onChange:g=>{let O=g.target.value;a(O),c(O);}})]})]}),document.body)]})}function Pr(e,t){let n=useRef(null),o=useRef(null);return {handlers:useMemo(()=>({insertFromUrl:()=>{let r=prompt("Enter image URL:");if(!r)return;let i=prompt("Enter alt text:")||"",a=prompt("Enter caption (optional):")||void 0;e.insertImage({src:r,alt:i,caption:a});},insertFromFile:()=>n.current?.click(),insertGifFromUrl:()=>{let r=prompt("Enter GIF URL:");if(!r)return;let i=prompt("Enter alt text (optional):")||"GIF";e.insertImage({src:r,alt:i});},insertGifFromFile:()=>o.current?.click(),handleUpload:async r=>{let i=r.target.files?.[0];if(!i)return;let a;if(t)try{a=await t(i);}catch{alert("Failed to upload image");return}else a=URL.createObjectURL(i);e.insertImage({src:a,alt:i.name,file:i}),r.target.value="";},handleGifUpload:async r=>{let i=r.target.files?.[0];if(!i)return;if(!(i.type==="image/gif"||i.name.toLowerCase().endsWith(".gif"))){alert("Please select a GIF file."),r.target.value="";return}let d;if(t)try{d=await t(i);}catch{alert("Failed to upload GIF");return}else d=URL.createObjectURL(i);e.insertImage({src:d,alt:i.name||"GIF",file:i}),r.target.value="";},setAlignment:r=>{e.setImageAlignment(r);},setCaption:()=>{let r=prompt("Enter caption:")||"";e.setImageCaption(r);}}),[e,t]),fileInputRef:n,gifInputRef:o}}function Rr(e){return useMemo(()=>({insertIframe:()=>{let t=prompt("Enter iframe URL:");t&&typeof e.insertIframeEmbed=="function"&&e.insertIframeEmbed(t);},insertYouTube:()=>{let t=prompt("Enter YouTube URL:");t&&typeof e.insertYouTubeEmbed=="function"&&e.insertYouTubeEmbed(t);}}),[e])}function Ar(e,t){switch(e){case "fontFamily":return t("fontFamily");case "fontSize":return t("fontSize");case "lineHeight":return t("lineHeight");case "textColor":return t("textColor");case "textHighlight":return t("textHighlight");case "subscript":return t("subscript");case "superscript":return t("superscript");case "blockFormat":case "quote":case "alignLeft":case "alignCenter":case "alignRight":case "alignJustify":return t("blockFormat");case "codeBlock":return t("code");case "unorderedList":case "orderedList":case "checkList":case "indentList":case "outdentList":return t("list");case "horizontalRule":return t("horizontalRule");case "table":return t("table");case "image":return t("image");case "emoji":return t("emoji");case "embed":return t("iframeEmbed")||t("youtubeEmbed");case "undo":case "redo":return t("history");default:return true}}function Br(e,t,n){return Ar(e,t)?n?.[e]!==false:false}function Dr(e,t,n){return {sections:e.sections.map(o=>({...o,items:o.items.filter(l=>Br(l,t,n))})).filter(o=>o.items.length>0)}}function vn({commands:e,hasExtension:t,activeStates:n,isDark:o,toggleTheme:l,onCommandPaletteOpen:r,imageUploadHandler:i,classNames:a,toolbarStyleVars:d,layout:c,toolbarVisibility:E,headingOptions:h,paragraphLabel:b}){let{handlers:m,fileInputRef:p,gifInputRef:$}=Pr(e,i),N=Rr(e),A=t("iframeEmbed")||t("youtubeEmbed"),Q=n.isIframeEmbedSelected||n.isYouTubeEmbedSelected,[J,C]=useState(false),[ne,se]=useState(false),[Y,g]=useState(false),[O,k]=useState(false),[j,R]=useState(false),[te,B]=useState("default"),[be,ie]=useState([{value:"default",label:"Default"}]),[Fe,ue]=useState("default"),[we,Oe]=useState([{value:"default",label:"Default"}]),[Ne,ge]=useState("default"),[Me,Ae]=useState([{value:"default",label:"Default"}]),[He,me]=useState("default"),[ze,ye]=useState([{value:"default",label:"Default",color:"inherit"}]),[he,F]=useState([]),[I,q]=useState("default"),[tt,ve]=useState([{value:"default",label:"Default",color:"transparent"}]),[Se,Je]=useState([]),[xe,Be]=useState(0),[Z,Le]=useState({rows:3,columns:3,includeHeaders:false});useEffect(()=>{if(typeof document>"u")return;let f=()=>{Vt()&&Be(z=>z+1);};return document.addEventListener("selectionchange",f),()=>{document.removeEventListener("selectionchange",f);}},[]);let Pe=useMemo(()=>t("emoji")?typeof e.getEmojiSuggestions=="function"?e.getEmojiSuggestions(""):typeof e.getEmojiCatalog=="function"?e.getEmojiCatalog():[]:[],[e,t]);useEffect(()=>{if(!t("fontFamily")||typeof e.getFontFamilyOptions!="function")return;let f=e.getFontFamilyOptions().map(z=>({value:z.value,label:z.label})),y=f.length>0?f:[{value:"default",label:"Default"}];ie(y),B(z=>y.some(D=>D.value===z)?z:"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(z=>{if(y)return;if(z&&z!=="default"){B(z);return}let D=Vt(),ce=Mr(D?.fontFamily,f());B(ce??"default");}),()=>{y=true;}},[n,e,t,xe]),useEffect(()=>{if(!t("fontSize")||typeof e.getFontSizeOptions!="function")return;let f=e.getFontSizeOptions().map(D=>({value:String(D.value).trim(),label:String(D.label).trim()})).filter(D=>D.value.length>0&&D.label.length>0),y=f.some(D=>Ve(D.value)==="default"),z=f.length===0?[{value:"default",label:"Default"}]:y?f:[{value:"default",label:"Default"},...f];Oe(z),ue(D=>z.some(ce=>ce.value===D)?D:"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(z=>{if(y)return;if(z&&z!=="default"){ue(z);return}let D=Vt(),ce=Hr(D?.fontSize,f());ue(ce??"default");}),()=>{y=true;}},[n,e,t,xe]),useEffect(()=>{if(!t("lineHeight")||typeof e.getLineHeightOptions!="function")return;let f=e.getLineHeightOptions().map(y=>({value:y.value,label:y.label}));f.length>0&&Ae(f);},[e,t]),useEffect(()=>{if(!t("lineHeight")||typeof e.getCurrentLineHeight!="function")return;let f=e.getLineHeightOptions;if(typeof f!="function")return;let y=false;return e.getCurrentLineHeight().then(z=>{if(y)return;if(z){ge(z);return}let D=Vt(),ce=zr(D?.lineHeight,D?.fontSize,f());ge(ce??"default");}),()=>{y=true;}},[n,e,t,xe]),useEffect(()=>{if(!t("textColor")||typeof e.getTextColorOptions!="function")return;let f=e.getTextColorOptions().map(y=>({value:y.value,label:y.label,color:y.color}));f.length>0&&ye(f);},[e,t]),useEffect(()=>{if(!t("textColor")||typeof e.getCurrentTextColor!="function")return;let f=false;return e.getCurrentTextColor().then(y=>{f||me(y??"default");}),()=>{f=true;}},[n,e,t,xe]),useEffect(()=>{if(!t("textHighlight")||typeof e.getTextHighlightOptions!="function")return;let f=e.getTextHighlightOptions().map(y=>({value:y.value,label:y.label,color:y.backgroundColor}));f.length>0&&ve(f);},[e,t]),useEffect(()=>{if(!t("textHighlight")||typeof e.getCurrentTextHighlight!="function")return;let f=false;return e.getCurrentTextHighlight().then(y=>{f||q(y??"default");}),()=>{f=true;}},[n,e,t,xe]);let le=useMemo(()=>{if(!h||h.length===0)return [...Ie];let f=new Set,y=[];for(let z of h)!Ie.includes(z)||f.has(z)||(f.add(z),y.push(z));return y.length>0?y:[...Ie]},[h]),Ce=b?.trim()||"Paragraph",De=useMemo(()=>{let f=le.map(y=>({value:y,label:`Heading ${y.slice(1)}`}));return [{value:"p",label:Ce},...f]},[le,Ce]),K=n.isH1?"h1":n.isH2?"h2":n.isH3?"h3":n.isH4?"h4":n.isH5?"h5":n.isH6?"h6":"p",Re=De.some(f=>f.value===K)?K:"p",ot=f=>{f==="p"?e.toggleParagraph():f.startsWith("h")&&le.includes(f)&&e.toggleHeading(f);},qe=f=>{f==="default"?e.clearFontFamily?.():e.setFontFamily?.(f),B(f);},Ye=f=>{f==="default"?e.clearFontSize?.():e.setFontSize?.(f),ue(f);},Ge=f=>{e.setLineHeight?.(f),ge(f);},v=(f,y)=>{f(z=>{let D=_t(y),ce=z.filter(de=>_t(de)!==D);return [y,...ce].slice(0,lo)});},S=f=>{if(f==="default"){e.clearTextColor?.(),me("default");return}e.setTextColor?.(f),me(f);},V=f=>{if(f==="default"){e.clearTextHighlight?.(),q("default");return}e.setTextHighlight?.(f),q(f);},oe=f=>{switch(f){case "fontFamily":return t("fontFamily")?jsx(kt,{value:te,onValueChange:qe,options:be,placeholder:"Font"},"fontFamily"):null;case "fontSize":return t("fontSize")?jsx(kt,{value:Fe,onValueChange:Ye,options:we,placeholder:"Size"},"fontSize"):null;case "lineHeight":return t("lineHeight")?jsx(kt,{value:Ne,onValueChange:Ge,options:Me,placeholder:"Line"},"lineHeight"):null;case "textColor":return t("textColor")?jsx(yn,{title:"Text Color",value:He,options:ze,recentColors:he,active:n.hasCustomTextColor,fallbackColor:"#0f172a",onChange:S,onClear:()=>S("default"),onAddRecent:y=>v(F,y)},"textColor"):null;case "textHighlight":return t("textHighlight")?jsx(yn,{title:"Text Highlight",value:I,options:tt,recentColors:Se,active:n.hasTextHighlight,fallbackColor:"#fef08a",highlight:true,onChange:V,onClear:()=>V("default"),onAddRecent:y=>v(Je,y)},"textHighlight"):null;case "bold":return jsx(L,{onClick:()=>e.toggleBold(),active:n.bold,title:"Bold (Ctrl+B)",children:jsx(Mt,{size:16})},"bold");case "italic":return jsx(L,{onClick:()=>e.toggleItalic(),active:n.italic,title:"Italic (Ctrl+I)",children:jsx(Ht,{size:16})},"italic");case "underline":return jsx(L,{onClick:()=>e.toggleUnderline(),active:n.underline,title:"Underline (Ctrl+U)",children:jsx(zt,{size:16})},"underline");case "strikethrough":return jsx(L,{onClick:()=>e.toggleStrikethrough(),active:n.strikethrough,title:"Strikethrough",children:jsx(Pt,{size:16})},"strikethrough");case "subscript":return t("subscript")?jsx(L,{onClick:()=>e.toggleSubscript?.(),active:n.subscript,title:"Subscript",children:jsx(_o,{size:16})},"subscript"):null;case "superscript":return t("superscript")?jsx(L,{onClick:()=>e.toggleSuperscript?.(),active:n.superscript,title:"Superscript",children:jsx($o,{size:16})},"superscript"):null;case "code":return jsx(L,{onClick:()=>e.formatText("code"),active:n.code,title:"Inline Code",children:jsx(Rt,{size:16})},"code");case "link":return jsx(L,{onClick:()=>n.isLink?e.removeLink():e.insertLink(),active:n.isLink,title:n.isLink?"Remove Link":"Insert Link",children:n.isLink?jsx(nt,{size:16}):jsx(ut,{size:16})},"link");case "blockFormat":return t("blockFormat")?jsx(kt,{value:Re,onValueChange:ot,options:De,placeholder:"Format"},"blockFormat"):null;case "quote":return t("blockFormat")?jsx(L,{onClick:()=>e.toggleQuote(),active:n.isQuote,title:"Quote",children:jsx(Ut,{size:16})},"quote"):null;case "alignLeft":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("left"),active:n.isTextAlignedLeft,title:"Align Left",children:jsx(ct,{size:16})},"alignLeft"):null;case "alignCenter":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("center"),active:n.isTextAlignedCenter,title:"Align Center",children:jsx(rt,{size:16})},"alignCenter"):null;case "alignRight":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("right"),active:n.isTextAlignedRight,title:"Align Right",children:jsx(dt,{size:16})},"alignRight"):null;case "alignJustify":return t("blockFormat")?jsx(L,{onClick:()=>e.setTextAlignment("justify"),active:n.isTextAlignedJustify,title:"Justify",children:jsx(Mo,{size:16})},"alignJustify"):null;case "codeBlock":return t("code")?jsx(L,{onClick:()=>e.toggleCodeBlock(),active:n.isInCodeBlock,title:"Code Block",children:jsx(wo,{size:16})},"codeBlock"):null;case "unorderedList":return t("list")?jsx(L,{onClick:()=>e.toggleUnorderedList(),active:n.unorderedList,title:"Bullet List",children:jsx(At,{size:16})},"unorderedList"):null;case "orderedList":return t("list")?jsx(L,{onClick:()=>e.toggleOrderedList(),active:n.orderedList,title:"Numbered List",children:jsx(Dt,{size:16})},"orderedList"):null;case "checkList":return t("list")?jsx(L,{onClick:()=>e.toggleCheckList(),active:n.checkList,title:"Checklist",children:jsx(Bt,{size:16})},"checkList"):null;case "indentList":return t("list")?jsx(L,{onClick:()=>e.indentList(),title:"Indent List",disabled:n.checkList,children:jsx(Do,{size:14})},"indentList"):null;case "outdentList":return t("list")?jsx(L,{onClick:()=>e.outdentList(),title:"Outdent List",disabled:n.checkList,children:jsx(Ko,{size:14})},"outdentList"):null;case "horizontalRule":return t("horizontalRule")?jsx(L,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(Ho,{size:16})},"horizontalRule"):null;case "table":return t("table")?jsx(L,{onClick:()=>R(true),title:"Insert Table",children:jsx(zo,{size:16})},"table"):null;case "image":return t("image")?jsxs(Fragment,{children:[jsxs(Et,{trigger:jsx("button",{className:`luthor-toolbar-button ${n.imageSelected?"active":""}`,title:"Insert Image",children:jsx(Wt,{size:16})}),isOpen:J,onOpenChange:C,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertFromUrl(),C(false);},children:[jsx(ut,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertFromFile(),C(false);},children:[jsx(Xt,{size:16}),jsx("span",{children:"Upload File"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertGifFromUrl(),C(false);},children:[jsx(Zt,{size:16}),jsx("span",{children:"Insert GIF URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.insertGifFromFile(),C(false);},children:[jsx(Xt,{size:16}),jsx("span",{children:"Upload GIF"})]})]},"image"),n.imageSelected&&jsxs(Et,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(rt,{size:16})}),isOpen:Y,onOpenChange:g,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setAlignment("left"),g(false);},children:[jsx(ct,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setAlignment("center"),g(false);},children:[jsx(rt,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setAlignment("right"),g(false);},children:[jsx(dt,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{m.setCaption(),g(false);},children:[jsx(Bo,{size:16}),jsx("span",{children:"Set Caption"})]})]},"imageAlign")]}):null;case "emoji":return !t("emoji")||Pe.length===0?null:jsx(Et,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Insert Emoji",children:jsx(Zt,{size:16})}),isOpen:ne,onOpenChange:se,children:jsx("div",{className:"luthor-emoji-picker-grid",role:"listbox","aria-label":"Emoji picker",children:Pe.map(y=>jsx("button",{type:"button",className:"luthor-emoji-picker-item",title:y.shortcodes[0]?`${y.label} (:${y.shortcodes[0]}:)`:y.label,onClick:()=>{e.insertEmoji?.(y.emoji),se(false);},children:y.emoji},`${y.emoji}-${y.label}`))})},"emoji");case "embed":return A?jsxs(Et,{trigger:jsx("button",{className:`luthor-toolbar-button ${Q?"active":""}`,title:"Insert Embed",children:jsx(Po,{size:16})}),isOpen:O,onOpenChange:k,children:[t("iframeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{N.insertIframe(),k(false);},children:[jsx(ut,{size:16}),jsx("span",{children:"Embed iframe"})]}):null,t("youtubeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{N.insertYouTube(),k(false);},children:[jsx(Wt,{size:16}),jsx("span",{children:"Embed YouTube Video"})]}):null]},"embed"):null;case "undo":return t("history")?jsx(L,{onClick:()=>e.undo(),disabled:!n.canUndo,title:"Undo (Ctrl+Z)",children:jsx(Oo,{size:16})},"undo"):null;case "redo":return t("history")?jsx(L,{onClick:()=>e.redo(),disabled:!n.canRedo,title:"Redo (Ctrl+Y)",children:jsx(No,{size:16})},"redo"):null;case "commandPalette":return jsx(L,{onClick:()=>r?.(),title:"Command Palette (Ctrl+Shift+P)",children:jsx(Kt,{size:16})},"commandPalette");case "themeToggle":return jsx(L,{onClick:l,title:o?"Light Mode":"Dark Mode",children:o?jsx(Uo,{size:16}):jsx(jo,{size:16})},"themeToggle");default:return null}},W=c??Ot,Qe=useMemo(()=>Dr(W,t,E),[W,t,E]);return jsxs(Fragment,{children:[jsx("div",{className:a?.toolbar??"luthor-toolbar",style:d,children:Qe.sections.map((f,y)=>{let z=f.items.map((D,ce)=>{let de=oe(D);return de?Array.isArray(de)?de.map((ee,wt)=>ee&&typeof ee=="object"&&"key"in ee&&ee.key!=null?ee:jsx("span",{children:ee},`toolbar-item-${y}-${ce}-${wt}`)):de.type===xr.Fragment?jsx("span",{children:de},`toolbar-item-${y}-${ce}`):de&&typeof de=="object"&&"key"in de&&de.key!=null?de:jsx("span",{children:de},`toolbar-item-${y}-${ce}`):null}).flat().filter(D=>D!==null);return z.length===0?null:jsx("div",{className:a?.section??"luthor-toolbar-section",children:z},y)})}),jsx("input",{ref:p,type:"file",accept:"image/*",onChange:m.handleUpload,className:"luthor-file-input"}),jsx("input",{ref:$,type:"file",accept:"image/gif",onChange:m.handleGifUpload,className:"luthor-file-input"}),jsx(nn,{isOpen:j,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:Z.rows,onChange:f=>Le(y=>({...y,rows:parseInt(f.target.value)||1})),className:"luthor-input"})]}),jsxs("div",{className:"luthor-form-group",children:[jsx("label",{htmlFor:"table-columns",children:"Columns:"}),jsx("input",{id:"table-columns",type:"number",min:"1",max:"20",value:Z.columns,onChange:f=>Le(y=>({...y,columns:parseInt(f.target.value)||1})),className:"luthor-input"})]}),jsx("div",{className:"luthor-form-group",children:jsxs("label",{className:"luthor-checkbox-label",children:[jsx("input",{type:"checkbox",checked:Z.includeHeaders||false,onChange:f=>Le(y=>({...y,includeHeaders:f.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(to,{variant:"secondary",onClick:()=>R(false),children:"Cancel"}),jsx(to,{variant:"primary",onClick:()=>{e.insertTable(Z),R(false);},children:"Insert Table"})]})]})})]})}var fo=["bold","italic","underline","strikethrough","fontFamily","fontSize","lineHeight","textColor","textHighlight","subscript","superscript","link","horizontalRule","table","list","history","image","blockFormat","code","codeIntelligence","codeFormat","tabIndent","enterKeyBehavior","iframeEmbed","youTubeEmbed","floatingToolbar","contextMenu","commandPalette","slashCommand","emoji","draggableBlock","customNode","themeToggle"],xn={bold:true,italic:true,underline:true,strikethrough:true,fontFamily:true,fontSize:true,lineHeight:true,textColor:true,textHighlight:true,subscript:true,superscript:true,link:true,horizontalRule:true,table:true,list:true,history:true,image:true,blockFormat:true,code:true,codeIntelligence:true,codeFormat:true,tabIndent:true,enterKeyBehavior:true,iframeEmbed:true,youTubeEmbed:true,floatingToolbar:true,contextMenu:true,commandPalette:true,slashCommand:true,emoji:true,draggableBlock:true,customNode:true,themeToggle:true};function It(e){let t={...xn};if(!e)return t;for(let n of fo)typeof e[n]=="boolean"&&(t[n]=e[n]);return t}function Ln(e,t){return e[t]!==false}var En=[{value:"default",label:"Default",fontFamily:"inherit"},{value:"inter",label:"Inter",fontFamily:"'Inter', 'Segoe UI', Arial, sans-serif",cssImportUrl:"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"},{value:"merriweather",label:"Merriweather",fontFamily:"'Merriweather', Georgia, 'Times New Roman', serif",cssImportUrl:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700&display=swap"},{value:"jetbrains-mono",label:"JetBrains Mono",fontFamily:"'JetBrains Mono', 'Courier New', monospace",cssImportUrl:"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap"}],fi={value:"default",label:"Default",fontFamily:"inherit"},Tn=[{value:"default",label:"Default",fontSize:"inherit"},{value:"12",label:"12px",fontSize:"12px"},{value:"14",label:"14px",fontSize:"14px"},{value:"16",label:"16px",fontSize:"16px"},{value:"18",label:"18px",fontSize:"18px"},{value:"20",label:"20px",fontSize:"20px"},{value:"24",label:"24px",fontSize:"24px"},{value:"32",label:"32px",fontSize:"32px"}],pi={value:"default",label:"Default",fontSize:"inherit"},Sn=[{value:"default",label:"Default",lineHeight:"1.5"},{value:"1",label:"1.0",lineHeight:"1"},{value:"1.15",label:"1.15",lineHeight:"1.15"},{value:"1.5",label:"1.5",lineHeight:"1.5"},{value:"1.75",label:"1.75",lineHeight:"1.75"},{value:"2",label:"2.0",lineHeight:"2"}],bi={value:"default",label:"Default",lineHeight:"1.5"},Lt="1.5",yi=1;function at(e){return e.trim().toLowerCase()}function In(e){return /^[a-z0-9][a-z0-9-]*$/i.test(e)}function vi(e){return at(e)==="default"?true:Jt(e)!==null}function Ci(e){let t=e??En,n=new Set,o=[];for(let r of t){let i=r.value.trim(),a=r.label.trim(),d=r.fontFamily.trim();if(!i||!a||!d||!In(i))continue;let c=at(i);n.has(c)||(n.add(c),o.push({value:i,label:a,fontFamily:d,cssImportUrl:r.cssImportUrl?.trim()||void 0}));}return o.length===0?En:o.some(r=>at(r.value)==="default")?o:[fi,...o]}function ki(e){let t=e??Tn,n=new Set,o=[];for(let r of t){let i=String(r.value).trim(),a=String(r.label).trim(),d=String(r.fontSize).trim();if(!i||!a||!d||!In(i))continue;let c=at(i);n.has(c)||(n.add(c),o.push({value:i,label:a,fontSize:d}));}return o.length===0?Tn:o.some(r=>at(r.value)==="default")?o:[pi,...o]}function Jt(e){let t=e.trim();if(!/^\d*\.?\d+$/.test(t))return null;let n=Number(t);return !Number.isFinite(n)||n<yi?null:n.toString()}function Ei(e){return typeof e=="number"?Number.isFinite(e)?Jt(e.toString())??Lt:Lt:typeof e=="string"?Jt(e)??Lt:Lt}function Ti(e,t=Lt){let n=e??Sn,o=new Set,l=[];for(let i of n){let a=String(i.value).trim(),d=String(i.label).trim();if(!a||!d||!vi(a))continue;let c=at(a);if(o.has(c))continue;if(c==="default"){o.add(c),l.push({value:a,label:d,lineHeight:t});continue}let E=Jt(String(i.lineHeight));E&&(o.add(c),l.push({value:a,label:d,lineHeight:E}));}return l.length===0?Sn:l.some(i=>at(i.value)==="default")?l:[{...bi,lineHeight:t},...l]}function et({children:e}){return jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e})}var Si=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M10.5 14.5h3"}),jsx("path",{d:"M12 2.8v4.4"}),jsx("path",{d:"M9.8 5h4.4"})]}),xi=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M10.5 8.5h3"}),jsx("path",{d:"M12 16.8v4.4"}),jsx("path",{d:"M9.8 19h4.4"})]}),Li=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M11.5 5v14"}),jsx("path",{d:"M7.5 10.5v3"}),jsx("path",{d:"M2.8 12h4.4"}),jsx("path",{d:"M5 9.8v4.4"})]}),Ii=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M12.5 5v14"}),jsx("path",{d:"M16.5 10.5v3"}),jsx("path",{d:"M16.8 12h4.4"}),jsx("path",{d:"M19 9.8v4.4"})]}),Fi=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M9.8 14.8l4.4 4.4"}),jsx("path",{d:"M14.2 14.8l-4.4 4.4"})]}),wi=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M12 5v14"}),jsx("path",{d:"M14.8 9.8l4.4 4.4"}),jsx("path",{d:"M19.2 9.8l-4.4 4.4"})]}),Oi=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 10.5h17"}),jsx("path",{d:"M10.5 5v14"}),jsx("path",{d:"M14.8 9.8l4.4 4.4"}),jsx("path",{d:"M19.2 9.8l-4.4 4.4"})]}),Ni=()=>jsxs(et,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 10.5h17"}),jsx("path",{d:"M10.5 5v14"}),jsx("path",{d:"M3.5 8h17"})]}),qt=new ImageExtension;qt.config={...qt.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var so=new TableExtension;so.config={...so.config,enableContextMenu:true,tableBubbleRenderer:({headersEnabled:e,setHeadersEnabled:t,actions:n})=>jsxs(Fragment,{children:[jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert row above","aria-label":"Insert row above",onClick:n.insertRowAbove,children:jsx(Si,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert row below","aria-label":"Insert row below",onClick:n.insertRowBelow,children:jsx(xi,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column left","aria-label":"Insert column left",onClick:n.insertColumnLeft,children:jsx(Li,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column right","aria-label":"Insert column right",onClick:n.insertColumnRight,children:jsx(Ii,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected row","aria-label":"Delete selected row",onClick:n.deleteSelectedRow,children:jsx(Fi,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected column","aria-label":"Delete selected column",onClick:n.deleteSelectedColumn,children:jsx(wi,{})}),jsx("label",{className:"luthor-table-bubble-checkbox",title:"Use first row as table headers",children:jsx("button",{type:"button",className:`luthor-table-bubble-button luthor-table-bubble-button-icon${e?" luthor-table-bubble-button-active":""}`,title:"Use first row as table headers","aria-label":"Use first row as table headers","aria-pressed":e,onClick:()=>t(!e),children:jsx(Ni,{})})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon luthor-table-bubble-button-danger",title:"Delete table","aria-label":"Delete table",onClick:n.deleteTable,children:jsx(Oi,{})})]})};var uo=new IframeEmbedExtension;uo.config={...uo.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center"};var co=new YouTubeEmbedExtension;co.config={...co.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center",nocookie:true,controls:true,rel:1};var Mi=ln(),go=new ContextMenuExtension;go.config={...go.config,preventDefault:true};var Hi=new CommandPaletteExtension,zi=new SlashCommandExtension,Pi=new EmojiExtension,mo=new DraggableBlockExtension;mo.config={...mo.config,buttonStackPosition:"left"};var ho=new LinkExtension;ho.config={...ho.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var Ri=textColorExtension.configure({options:[{value:"default",label:"Default",color:"inherit"},{value:"slate",label:"Slate",color:"#334155"},{value:"red",label:"Red",color:"#dc2626"},{value:"orange",label:"Orange",color:"#ea580c"},{value:"green",label:"Green",color:"#16a34a"},{value:"blue",label:"Blue",color:"#2563eb"},{value:"purple",label:"Purple",color:"#7c3aed"}]}),Ai=textHighlightExtension.configure({options:[{value:"default",label:"Default",backgroundColor:"transparent"},{value:"yellow",label:"Yellow",backgroundColor:"#fef08a"},{value:"green",label:"Green",backgroundColor:"#bbf7d0"},{value:"blue",label:"Blue",backgroundColor:"#bfdbfe"},{value:"pink",label:"Pink",backgroundColor:"#fbcfe8"},{value:"orange",label:"Orange",backgroundColor:"#fed7aa"}]}),{extension:Bi}=createCustomNodeExtension({nodeType:"featureCard",defaultPayload:{title:"Headless Custom Node",description:"This block is rendered by createCustomNodeExtension from @lyfie/luthor-headless.",tag:"Custom"},render:({payload:e,isSelected:t})=>jsxs("aside",{className:`luthor-extensive-feature-card${t?" is-selected":""}`,children:[jsx("div",{className:"luthor-extensive-feature-card__tag",children:e.tag??"Custom"}),jsx("h4",{className:"luthor-extensive-feature-card__title",children:e.title??"Custom Node"}),jsx("p",{className:"luthor-extensive-feature-card__description",children:e.description??"Insert strongly typed custom content blocks."})]})});function Fn({fontFamilyOptions:e,fontSizeOptions:t,lineHeightOptions:n,minimumDefaultLineHeight:o,featureFlags:l,isDraggableBoxEnabled:r,scaleByRatio:i,syntaxHighlighting:a,codeHighlightProvider:d,loadCodeHighlightProvider:c,maxAutoDetectCodeLength:E,isCopyAllowed:h,languageOptions:b}={}){let m=It(l),p=ne=>Ln(m,ne),$=(r??true)&&p("draggableBlock"),N=Ei(o),A=new FontFamilyExtension().configure({options:Ci(e),cssLoadStrategy:"on-demand"}),Q=new FontSizeExtension().configure({options:ki(t)}),J=new LineHeightExtension().configure({options:Ti(n,N),defaultLineHeight:N});qt.configure({scaleByRatio:i??false}),codeExtension.configure({syntaxHighlighting:a??"auto",provider:d??void 0,loadProvider:c}),codeIntelligenceExtension.configure({provider:d??void 0,loadProvider:c,maxAutoDetectLength:E,isCopyAllowed:h??true,languageOptions:b});let C=[];return p("bold")&&C.push(boldExtension),p("italic")&&C.push(italicExtension),p("underline")&&C.push(underlineExtension),p("strikethrough")&&C.push(strikethroughExtension),p("fontFamily")&&C.push(A),p("fontSize")&&C.push(Q),p("lineHeight")&&C.push(J),p("textColor")&&C.push(Ri),p("textHighlight")&&C.push(Ai),p("subscript")&&C.push(subscriptExtension),p("superscript")&&C.push(superscriptExtension),p("link")&&C.push(ho),p("horizontalRule")&&C.push(horizontalRuleExtension),p("table")&&C.push(so),p("list")&&C.push(listExtension),p("history")&&C.push(historyExtension),p("image")&&C.push(qt),p("blockFormat")&&C.push(blockFormatExtension),p("code")&&C.push(codeExtension),p("codeIntelligence")&&C.push(codeIntelligenceExtension),p("codeFormat")&&C.push(codeFormatExtension),p("tabIndent")&&C.push(tabIndentExtension),p("enterKeyBehavior")&&C.push(enterKeyBehaviorExtension),p("iframeEmbed")&&C.push(uo),p("youTubeEmbed")&&C.push(co),p("floatingToolbar")&&C.push(Mi),p("contextMenu")&&C.push(go),p("commandPalette")&&C.push(Hi),p("slashCommand")&&C.push(zi),p("emoji")&&C.push(Pi),$&&C.push(mo),p("customNode")&&C.push(Bi),C}function Ft(e){return Fn(e)}var po=Fn();function wn(e){if(!e)return "__default__";let t=Object.entries(e).filter(([,n])=>typeof n=="string"&&n.trim().length>0).sort(([n],[o])=>n.localeCompare(o));return t.length>0?JSON.stringify(t):"__default__"}function On(e){if(!e)return;let t={},n=(o,l)=>{typeof l=="string"&&l.trim().length>0&&(t[o]=l.trim());};return n("--luthor-fg",e.font?.color),n("--luthor-text-bold-color",e.font?.boldColor),n("--luthor-link-color",e.link?.color),n("--luthor-list-marker-color",e.list?.markerColor),n("--luthor-list-checkbox-color",e.list?.checkboxColor),n("--luthor-quote-bg",e.quote?.backgroundColor),n("--luthor-quote-fg",e.quote?.color),n("--luthor-quote-border",e.quote?.indicatorColor),n("--luthor-table-border-color",e.table?.borderColor),n("--luthor-table-header-bg",e.table?.headerBackgroundColor),n("--luthor-hr-color",e.hr?.color),n("--luthor-placeholder-color",e.placeholder?.color),n("--luthor-codeblock-bg",e.codeblock?.backgroundColor),n("--luthor-toolbar-bg",e.toolbar?.backgroundColor),Object.keys(t).length>0?t:void 0}function Nn(e){if(!(e instanceof Element))return false;if(e.closest('[contenteditable="true"]'))return true;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"}function Mn(e,t){if(e.key.toLowerCase()!==t.key.toLowerCase())return false;let n=e.ctrlKey||e.metaKey;return !(!!t.requiresPrimary!==n||!!t.shift!=!!e.shiftKey||!!t.alt!=!!e.altKey)}function Hn(e,t,n){let o={...e??{}};for(let[l,r]of Object.entries(n))(Array.isArray(r)?r:[r]).some(d=>t[d]!==false)||(o[l]=false);return o}function zn(e,t,n){let o={...e},l=(r,i)=>{t[r]===false&&i();};return l("bold",()=>{o.toggleBold=()=>{};}),l("italic",()=>{o.toggleItalic=()=>{};}),l("underline",()=>{o.toggleUnderline=()=>{};}),l("strikethrough",()=>{o.toggleStrikethrough=()=>{};}),l("codeFormat",()=>{o.formatText=()=>{};}),l("fontFamily",()=>{o.setFontFamily=()=>{},o.clearFontFamily=()=>{};}),l("fontSize",()=>{o.setFontSize=()=>{},o.clearFontSize=()=>{};}),l("lineHeight",()=>{o.setLineHeight=()=>{},o.clearLineHeight=()=>{};}),l("textColor",()=>{o.setTextColor=()=>{},o.clearTextColor=()=>{};}),l("textHighlight",()=>{o.setTextHighlight=()=>{},o.clearTextHighlight=()=>{};}),l("subscript",()=>{o.toggleSubscript=()=>{};}),l("superscript",()=>{o.toggleSuperscript=()=>{};}),l("link",()=>{o.insertLink=()=>{},o.removeLink=()=>{},o.updateLink=()=>false,o.getCurrentLink=async()=>null,o.getLinkByKey=async()=>null,o.updateLinkByKey=()=>false,o.removeLinkByKey=()=>false;}),l("blockFormat",()=>{o.toggleParagraph=()=>{},o.toggleHeading=()=>{},o.toggleQuote=()=>{},o.setTextAlignment=()=>{};}),l("code",()=>{o.toggleCodeBlock=()=>{};}),l("codeIntelligence",()=>{o.setCodeLanguage=()=>{},o.autoDetectCodeLanguage=async()=>null,o.copySelectedCodeBlock=async()=>false;}),l("list",()=>{o.toggleUnorderedList=()=>{},o.toggleOrderedList=()=>{},o.toggleCheckList=()=>{},o.indentList=()=>{},o.outdentList=()=>{};}),l("horizontalRule",()=>{o.insertHorizontalRule=()=>{};}),l("table",()=>{o.insertTable=()=>{};}),l("image",()=>{o.insertImage=()=>{},o.setImageAlignment=()=>{},o.setImageCaption=()=>{},o.getImageCaption=async()=>"";}),l("emoji",()=>{o.insertEmoji=()=>{},o.executeEmojiSuggestion=()=>false,o.closeEmojiSuggestions=()=>{},o.getEmojiSuggestions=()=>[],o.getEmojiCatalog=()=>[],o.resolveEmojiShortcode=()=>null,o.setEmojiCatalog=()=>{},o.setEmojiCatalogAdapter=()=>{},o.getEmojiCatalogAdapter=()=>({search:()=>[],resolveShortcode:()=>null,getAll:()=>[]});}),l("iframeEmbed",()=>{o.insertIframeEmbed=()=>{},o.setIframeEmbedAlignment=()=>{},o.resizeIframeEmbed=()=>{},o.setIframeEmbedCaption=()=>{},o.getIframeEmbedCaption=async()=>"",o.updateIframeEmbedUrl=()=>false,o.getIframeEmbedUrl=async()=>"";}),l("youTubeEmbed",()=>{o.insertYouTubeEmbed=()=>{},o.setYouTubeEmbedAlignment=()=>{},o.resizeYouTubeEmbed=()=>{},o.setYouTubeEmbedCaption=()=>{},o.getYouTubeEmbedCaption=async()=>"",o.updateYouTubeEmbedUrl=()=>false,o.getYouTubeEmbedUrl=async()=>"";}),l("history",()=>{o.undo=()=>{},o.redo=()=>{};}),l("commandPalette",()=>{o.showCommandPalette=()=>{},o.hideCommandPalette=()=>{},o.registerCommand=()=>{},o.unregisterCommand=()=>{};}),l("slashCommand",()=>{o.registerSlashCommand=()=>{},o.unregisterSlashCommand=()=>{},o.setSlashCommands=()=>{},o.closeSlashMenu=()=>{},o.executeSlashCommand=()=>false;}),n&&(o.toggleBold=()=>{},o.toggleItalic=()=>{},o.toggleUnderline=()=>{},o.toggleStrikethrough=()=>{},o.formatText=()=>{},o.setFontFamily=()=>{},o.clearFontFamily=()=>{},o.setFontSize=()=>{},o.clearFontSize=()=>{},o.setLineHeight=()=>{},o.clearLineHeight=()=>{},o.setTextColor=()=>{},o.clearTextColor=()=>{},o.setTextHighlight=()=>{},o.clearTextHighlight=()=>{},o.toggleSubscript=()=>{},o.toggleSuperscript=()=>{},o.insertLink=()=>{},o.removeLink=()=>{},o.updateLink=()=>false,o.toggleParagraph=()=>{},o.toggleHeading=()=>{},o.toggleQuote=()=>{},o.setTextAlignment=()=>{},o.toggleUnorderedList=()=>{},o.toggleOrderedList=()=>{},o.toggleCheckList=()=>{},o.indentList=()=>{},o.outdentList=()=>{},o.insertHorizontalRule=()=>{},o.insertTable=()=>{},o.insertImage=()=>{},o.setImageAlignment=()=>{},o.setImageCaption=()=>{},o.insertIframeEmbed=()=>{},o.setIframeEmbedAlignment=()=>{},o.resizeIframeEmbed=()=>{},o.setIframeEmbedCaption=()=>{},o.updateIframeEmbedUrl=()=>false,o.insertYouTubeEmbed=()=>{},o.setYouTubeEmbedAlignment=()=>{},o.resizeYouTubeEmbed=()=>{},o.setYouTubeEmbedCaption=()=>{},o.updateYouTubeEmbedUrl=()=>false),o}function Pn(e){return new Set(e)}function Rn(e,t){e.clear();for(let n of t)e.add(n);}function An(e,t){return e.has(t)}function Bn(e,t){e.add(t);}var M=(e,t=0,n="")=>({type:"text",version:1,text:e,detail:0,format:t,mode:"normal",style:n}),pe=(e,t="",n=0)=>({type:"paragraph",version:1,format:t,indent:n,direction:null,children:e}),bo={root:{type:"root",version:1,format:"",indent:0,direction:null,children:[{type:"heading",version:1,tag:"h1",format:"",indent:0,direction:null,children:[M("Extensive Preset: JSONB-First Feature Showcase")]},pe([M("This starter content is now a native "),M("JSONB",1),M(" document that demonstrates visual editing without Markdown conversion.")]),{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[M("Inline formatting + typography")]},pe([M("Bold",1),M(" \u2022 "),M("Italic",2),M(" \u2022 "),M("Underline",8),M(" \u2022 "),M("Strikethrough",4),M(" \u2022 "),M("Inline Code",16),M(" \u2022 "),M("Subscript",32),M(" \u2022 "),M("Superscript",64)]),pe([M("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:[M("Centered paragraph with custom style",0,"font-size: 20px; color: #7c3aed;")]},{type:"paragraph",version:1,format:"right",indent:0,direction:null,children:[M("Right-aligned paragraph with highlight",128,"background-color: #fef08a;")]},{type:"quote",version:1,format:"",indent:0,direction:null,children:[M("\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:[M("Example link node")]},M(" with regular sibling text and emoji support \u{1F389}\u{1F525}\u2705.")]},{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[M("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([M("Bullet item with styled text",0,"color: #16a34a;")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[pe([M("Nested formatting in lists",1),M(" 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([M("Numbered item 1")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[pe([M("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([M("Checked task item")])]},{type:"listitem",version:1,value:2,checked:false,format:"",indent:0,direction:null,children:[pe([M("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([M("Feature")])]},{type:"tablecell",version:1,headerState:3,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[pe([M("Status")])]}]},{type:"tablerow",version:1,children:[{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:240,backgroundColor:null,children:[pe([M("Visual \u2194 JSONB switching")])]},{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[pe([M("Round-trip ready \u2705")])]}]}]},pe([M("Use the toolbar, floating toolbar, slash commands (/), and command palette (Ctrl/Cmd+Shift+P) to explore the full preset.")])]}};JSON.stringify(bo);var{Provider:Yi,useEditor:Gi}=createEditorSystem(),Dn="Write anything...",Kn="Enter JSONB document content...";function Qi(e){let n=e.replace(/\r\n?/g,`
|
|
3
|
+
`).trim().split(/\n{2,}/).map(l=>l.replace(/\s+/g," ").trim()).filter(l=>l.length>0);return {root:{type:"root",version:1,format:"",indent:0,direction:null,children:(n.length>0?n:[""]).map(l=>({type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"text",version:1,text:l,detail:0,format:0,mode:"normal",style:""}]}))}}}function Wi(e){try{let t=JSON.parse(e);return JSON.stringify(t)}catch{return JSON.stringify(Qi(e))}}function Xi(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:t.value.trim(),label:t.label.trim(),fontFamily:t.fontFamily.trim(),cssImportUrl:t.cssImportUrl?.trim()||""})))}function Zi(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:String(t.value).trim(),label:String(t.label).trim(),fontSize:String(t.fontSize).trim()})))}function el(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:String(t.value).trim(),label:String(t.label).trim(),lineHeight:String(t.lineHeight).trim()})))}function tl(e){if(typeof e=="number")return !Number.isFinite(e)||e<1?"1.5":e.toString();if(typeof e=="string"){let n=e.trim();if(n.length===0)return "1.5";let o=Number(n);return !Number.isFinite(o)||o<1?"1.5":o.toString()}return "1.5"}function yo(e){return wn(e)}function ol(e){if(!e)return "__default__";if(Array.isArray(e))return JSON.stringify({mode:"append",values:e.map(o=>o.trim())});let t=e,n=Array.isArray(t.values)?t.values:[];return JSON.stringify({mode:t.mode??"append",values:n.map(o=>o.trim())})}function nl(e){return On(e)}function rl(e){let t=It(e);return JSON.stringify(fo.map(n=>[n,t[n]]))}function Un(e){return Nn(e)}var il=[{feature:"bold",key:"b",requiresPrimary:true},{feature:"italic",key:"i",requiresPrimary:true},{feature:"underline",key:"u",requiresPrimary:true},{feature:"link",key:"k",requiresPrimary:true},{feature:"history",key:"z",requiresPrimary:true},{feature:"history",key:"y",requiresPrimary:true},{feature:"history",key:"z",requiresPrimary:true,shift:true},{feature:"commandPalette",key:"p",requiresPrimary:true,shift:true},{feature:"codeFormat",key:"`",requiresPrimary:true},{feature:"code",key:"`",requiresPrimary:true,shift:true},{feature:"list",key:"l",requiresPrimary:true,shift:true},{feature:"list",key:"l",requiresPrimary:true,alt:true},{feature:"list",key:"x",requiresPrimary:true,shift:true},{feature:"blockFormat",key:"0",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"1",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"2",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"3",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"4",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"5",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"6",requiresPrimary:true,alt:true}];function ll(e,t){return Mn(e,t)}function al(e,t,n){return zn(e,t,n)}var sl={fontFamily:"fontFamily",fontSize:"fontSize",lineHeight:"lineHeight",textColor:"textColor",textHighlight:"textHighlight",bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",subscript:"subscript",superscript:"superscript",code:"codeFormat",link:"link",blockFormat:"blockFormat",quote:"blockFormat",alignLeft:"blockFormat",alignCenter:"blockFormat",alignRight:"blockFormat",alignJustify:"blockFormat",codeBlock:"code",unorderedList:"list",orderedList:"list",checkList:"list",indentList:"list",outdentList:"list",horizontalRule:"horizontalRule",table:"table",image:"image",emoji:"emoji",embed:["iframeEmbed","youTubeEmbed"],undo:"history",redo:"history",commandPalette:"commandPalette",themeToggle:"themeToggle"};function ul(e,t){return Hn(e,t,sl)}function cl(e){if(!e||e.length===0)return [...Ie];let t=new Set,n=[];for(let o of e)!Ie.includes(o)||t.has(o)||(t.add(o),n.push(o));return n.length>0?n:[...Ie]}function dl(e){if(!e)return "__default__";if(Array.isArray(e)){let r=new Set,i=[];for(let a of e)for(let[d,c]of Object.entries(a)){let E=d.trim();!c||!E||r.has(E)||(r.add(E),i.push(E));}return i.length===0?"__default__":JSON.stringify({allowlist:i,denylist:[]})}let t=r=>{if(!r||r.length===0)return [];let i=new Set,a=[];for(let d of r){let c=d.trim();!c||i.has(c)||(i.add(c),a.push(c));}return a},n=e,o=t(n.allowlist),l=t(n.denylist);return o.length===0&&l.length===0?"__default__":JSON.stringify({allowlist:o,denylist:l})}function gl(e){if(!e||e.length===0)return [];let t=new Set,n=[];for(let o of e){let l=o.trim();!l||t.has(l)||(t.add(l),n.push(l));}return n}function ml(e,t){return e.key.toLowerCase()===t.key.toLowerCase()&&!!e.ctrlKey==!!t.ctrlKey&&!!e.metaKey==!!t.metaKey&&!!e.shiftKey==!!t.shiftKey&&!!e.altKey==!!t.altKey}function hl(e){if(!e)return "__default__";let t=Array.isArray(e.disabledCommandIds)?[...e.disabledCommandIds].map(o=>o.trim()).filter(o=>o.length>0).sort((o,l)=>o.localeCompare(l)):[],n=e.bindings?Object.entries(e.bindings).map(([o,l])=>{if(l===false||l===null)return [o,false];let i=(Array.isArray(l)?l:[l]).map(a=>({key:a.key.trim(),ctrlKey:!!a.ctrlKey,metaKey:!!a.metaKey,shiftKey:!!a.shiftKey,altKey:!!a.altKey,preventDefault:a.preventDefault})).filter(a=>a.key.length>0).sort((a,d)=>{let c=`${a.key}:${a.ctrlKey?1:0}:${a.metaKey?1:0}:${a.shiftKey?1:0}:${a.altKey?1:0}`,E=`${d.key}:${d.ctrlKey?1:0}:${d.metaKey?1:0}:${d.shiftKey?1:0}:${d.altKey?1:0}`;return c.localeCompare(E)});return i.length===0?[o,false]:[o,i]}).sort(([o],[l])=>o.localeCompare(l)):[];return JSON.stringify({disabledCommandIds:t,bindings:n,preventCollisions:e.preventCollisions!==false,preventNativeConflicts:e.preventNativeConflicts!==false})}function fl({isDark:e,toggleTheme:t,visualPlaceholder:n,jsonbPlaceholder:o,initialMode:l,availableModes:r,onReady:i,toolbarLayout:a,toolbarVisibility:d,toolbarPosition:c,toolbarAlignment:E,toolbarClassName:h,toolbarStyleVars:b,isToolbarEnabled:m,headingOptions:p,paragraphLabel:$,syncHeadingOptionsWithCommands:N,slashCommandVisibility:A,shortcutConfig:Q,commandPaletteShortcutOnly:J,featureFlags:C}){let{commands:ne,hasExtension:se,activeStates:Y,lexical:g,extensions:O,export:k,import:j}=Gi(),[R,te]=useState(l),[B,be]=useState({jsonb:""}),[ie,Fe]=useState(null),[ue,we]=useState(null),[Oe,Ne]=useState({isOpen:false,commands:[]}),[ge,Me]=useState({isOpen:false,query:"",position:null,commands:[]}),[Ae,He]=useState({isOpen:false,query:"",position:null,suggestions:[]}),me=useRef(false),ze=useMemo(()=>cl(p),[p]),ye=N?ze:void 0,he=N?$:void 0,F=Y.isInCodeBlock===true,I=useMemo(()=>al(ne,C,F),[ne,C,F]),q=useMemo(()=>v=>Object.prototype.hasOwnProperty.call(C,v)?C[v]!==false:true,[C]),tt=useMemo(()=>ul(d,C),[d,C]),ve=C.draggableBlock!==false,Se=dl(A),Je=useRef(A),xe=useRef(Se),Be=hl(Q),Z=useRef(Q),Le=useRef(Be),Pe=useMemo(()=>gl(Q?.disabledCommandIds),[Q?.disabledCommandIds]),le=useMemo(()=>new Set(Pe),[Pe]),Ce=useMemo(()=>le.size===0?[]:Qt({headingOptions:ye,paragraphLabel:he,isFeatureEnabled:q}).filter(v=>le.has(v.id)).flatMap(v=>v.shortcuts??[]),[le,ye,he,q]);xe.current!==Se&&(xe.current=Se,Je.current=A),Le.current!==Be&&(Le.current=Be,Z.current=Q);let De=useRef(Pn(["visual"])),K=useRef(0);useEffect(()=>{oo(I,Y,e?"dark":"light",q);},[I,Y,e,q]);let Re=useMemo(()=>({injectJSONB:v=>{setTimeout(()=>{try{let S=JSON.parse(v);j.fromJSON(S);}catch(S){console.error("Failed to inject JSONB:",S);return}},100);},getJSONB:()=>io(JSON.stringify(k.toJSON()))}),[k,j]);useEffect(()=>{if(!g||!I)return;let v=I,S=xo(v,{headingOptions:ye,paragraphLabel:he,isFeatureEnabled:q,shortcutConfig:Z.current,commandPaletteShortcutOnly:J});typeof v.registerCommand=="function"&&S.forEach(W=>v.registerCommand(W));let V=Lo(v,{headingOptions:ye,paragraphLabel:he,slashCommandVisibility:Je.current,isFeatureEnabled:q,shortcutConfig:Z.current});typeof v.setSlashCommands=="function"?v.setSlashCommands(V):V.forEach(W=>v.registerSlashCommand?.(W));let oe=Fo(v,document.body,{headingOptions:ye,paragraphLabel:he,isFeatureEnabled:q,shortcutConfig:Z.current,scope:()=>g.getRootElement()});return me.current||(me.current=true,i?.(Re)),()=>{oe(),typeof v.unregisterCommand=="function"&&S.forEach(W=>v.unregisterCommand(W.id)),typeof v.setSlashCommands=="function"?v.setSlashCommands([]):V.forEach(W=>v.unregisterSlashCommand?.(W.id));}},[g,I,Re,i,ye,he,Se,Be,q,J]),useEffect(()=>{let v=()=>g?.getRootElement(),S=il.filter(oe=>C[oe.feature]===false);if(S.length===0)return;let V=oe=>{let W=v();W&&oe.target instanceof Node&&!W.contains(oe.target)||!Un(oe.target)||!S.some(f=>ll(oe,f))||(oe.preventDefault(),oe.stopPropagation());};return document.addEventListener("keydown",V,true),()=>{document.removeEventListener("keydown",V,true);}},[g,C]),useEffect(()=>{let v=O.find(S=>S.name==="commandPalette");if(!(!v||!v.subscribe))return v.subscribe((S,V)=>{let oe=V.filter(W=>le.has(W.id)?false:J?typeof W.shortcut=="string"&&W.shortcut.trim().length>0:true);Ne({isOpen:S,commands:oe});})},[O,le,J]),useEffect(()=>{if(Ce.length===0)return;let v=()=>g?.getRootElement(),S=V=>{let oe=v();oe&&V.target instanceof Node&&!oe.contains(V.target)||!Un(V.target)||!Ce.some(Qe=>ml(V,Qe))||(V.preventDefault(),V.stopPropagation());};return document.addEventListener("keydown",S,true),()=>{document.removeEventListener("keydown",S,true);}},[g,Ce]),useEffect(()=>{let v=O.find(S=>S.name==="slashCommand");if(!(!v||!v.subscribe))return v.subscribe(S=>{Me({isOpen:S.isOpen,query:S.query,position:S.position,commands:S.commands});})},[O]),useEffect(()=>{let v=O.find(S=>S.name==="emoji");if(!(!v||!v.subscribe))return v.subscribe(S=>{He({isOpen:S.isOpen,query:S.query,position:S.position,suggestions:S.suggestions});})},[O]),useEffect(()=>!g||!k?void 0:g.registerUpdateListener(()=>{K.current+=1,Rn(De.current,["visual"]);}),[g,k]);let ot=async v=>{if(r.includes(v))try{if(we(null),R==="jsonb"&&v!=="jsonb"){let S=JSON.parse(B.jsonb);j.fromJSON(S),await new Promise(V=>setTimeout(V,50));}if(R==="visual"&&v!=="visual"&&(g&&clearLexicalSelection(g),g?.getRootElement()?.blur()),te(v),v==="jsonb"&&R!=="jsonb"&&!An(De.current,"jsonb")){Fe("jsonb"),await new Promise(S=>setTimeout(S,50));try{let S=io(JSON.stringify(k.toJSON()));be(V=>({...V,jsonb:S})),Bn(De.current,"jsonb");}finally{Fe(null);}}v==="visual"&&setTimeout(()=>g?.focus(),100);}catch(S){let V=S instanceof Error?S.message:"Invalid format - could not parse content";we({mode:R,error:V});}},qe=m?jsx(vn,{commands:I,hasExtension:v=>se(v),activeStates:Y,isDark:e,toggleTheme:t,onCommandPaletteOpen:()=>{C.commandPalette!==false&&I.showCommandPalette();},imageUploadHandler:v=>O.find(S=>S.name==="image")?.config?.uploadHandler?.(v)??Promise.resolve(URL.createObjectURL(v)),layout:a??Ot,toolbarVisibility:tt,toolbarStyleVars:b,headingOptions:ze,paragraphLabel:$,classNames:{toolbar:`luthor-toolbar luthor-toolbar--align-${E}${h?` ${h}`:""}`}}):null,Ye=R==="visual"&&m&&c==="top",Ge=R==="visual"&&m&&c==="bottom";return jsxs(Fragment,{children:[jsxs("div",{className:"luthor-editor-header",children:[jsx(mn,{mode:R,onModeChange:ot,availableModes:r,isConverting:ie}),Ye&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--top",children:qe})]}),jsxs("div",{className:`luthor-editor${ve?"":" luthor-editor--draggable-disabled"}`,"data-mode":R,children:[jsxs("div",{className:`luthor-editor-visual-shell${R==="visual"?"":" is-hidden"}${ve?"":" luthor-editor-visual-shell--no-gutter"}`,"aria-hidden":R!=="visual",children:[ve&&jsx("div",{className:"luthor-editor-visual-gutter","aria-hidden":"true"}),jsx(RichText,{placeholder:n,classNames:{container:"luthor-richtext-container luthor-preset-extensive__container",contentEditable:"luthor-content-editable luthor-preset-extensive__content",placeholder:"luthor-placeholder luthor-preset-extensive__placeholder"}})]}),R!=="visual"&&jsxs("div",{className:"luthor-source-panel",children:[ue&&ue.mode===R&&jsxs("div",{className:"luthor-source-error",children:[jsx("div",{className:"luthor-source-error-icon",children:"\u26A0\uFE0F"}),jsxs("div",{className:"luthor-source-error-message",children:[jsx("strong",{children:"Invalid JSONB"}),jsx("p",{children:ue.error}),jsx("small",{children:"Fix the errors above and try switching modes again"})]})]}),R==="jsonb"&&jsx(hn,{value:B.jsonb,onChange:v=>be(S=>({...S,jsonb:v})),placeholder:o})]})]}),jsx(gn,{editor:g,commands:I,editorTheme:e?"dark":"light",disabled:R!=="visual"}),Ge&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--bottom",children:qe}),jsx(Qo,{isOpen:Oe.isOpen,onClose:()=>I.hideCommandPalette(),commands:Oe.commands}),jsx(tn,{isOpen:ge.isOpen,query:ge.query,position:ge.position,commands:ge.commands,onClose:()=>I.closeSlashMenu?.(),onExecute:v=>{I.executeSlashCommand?.(v);}}),jsx(Xo,{isOpen:Ae.isOpen,query:Ae.query,position:Ae.position,suggestions:Ae.suggestions,onClose:()=>I.closeEmojiSuggestions?.(),onExecute:v=>{I.executeEmojiSuggestion?.(v);}})]})}var Yt=forwardRef(({className:e,onReady:t,initialTheme:n="light",theme:o,defaultContent:l,showDefaultContent:r=true,placeholder:i=Dn,initialMode:a="visual",availableModes:d=["visual","jsonb"],variantClassName:c,toolbarLayout:E,toolbarVisibility:h,toolbarPosition:b="top",toolbarAlignment:m="left",toolbarClassName:p,toolbarStyleVars:$,quoteClassName:N,quoteStyleVars:A,defaultSettings:Q,editorThemeOverrides:J,isToolbarEnabled:C=true,fontFamilyOptions:ne,fontSizeOptions:se,lineHeightOptions:Y,minimumDefaultLineHeight:g=1.5,scaleByRatio:O=false,headingOptions:k,paragraphLabel:j,syncHeadingOptionsWithCommands:R=true,slashCommandVisibility:te,shortcutConfig:B,commandPaletteShortcutOnly:be=false,isDraggableBoxEnabled:ie,featureFlags:Fe,syntaxHighlighting:ue,codeHighlightProvider:we,loadCodeHighlightProvider:Oe,maxAutoDetectCodeLength:Ne,isCopyAllowed:ge=true,languageOptions:Me},Ae)=>{let[He,me]=useState(n),ze=He==="dark",ye=d.includes(a)?a:d[0]??"visual",he=()=>me(ze?"light":"dark"),F=useMemo(()=>typeof i=="string"?{visual:i,jsonb:Kn}:{visual:i.visual??Dn,jsonb:i.jsonb??Kn},[i]);useEffect(()=>{me(n);},[n]);let I=useMemo(()=>Xi(ne),[ne]),q=useMemo(()=>Zi(se),[se]),tt=useMemo(()=>el(Y),[Y]),ve=useMemo(()=>tl(g),[g]),Se=ue??"unset",Je=typeof Ne=="number"?Ne.toString():"unset",xe=useMemo(()=>ol(Me),[Me]),Be=ge?"copy-on":"copy-off",Z=useMemo(()=>typeof ie!="boolean"?Fe:{...Fe??{},draggableBlock:ie},[Fe,ie]),Le=useMemo(()=>rl(Z),[Z]),Pe=useMemo(()=>It(Z),[Z]),le=`${I}::${q}::${tt}::${ve}::${O?"ratio-on":"ratio-off"}::${Se}::${Je}::${Be}::${xe}::${Le}`,Ce=useRef(ne),De=useRef(se),K=useRef(Y),Re=useRef(g),ot=useRef(Z),qe=useRef(Me),Ye=useRef(we),Ge=useRef(Oe),v=useRef(le);(v.current!==le||Ye.current!==we||Ge.current!==Oe)&&(v.current=le,Ce.current=ne,De.current=se,K.current=Y,Re.current=g,ot.current=Z,qe.current=Me,Ye.current=we,Ge.current=Oe);let S=useRef(null);if(!S.current||S.current.key!==le){let ee={fontFamilyOptions:Ce.current,fontSizeOptions:De.current,lineHeightOptions:K.current,minimumDefaultLineHeight:Re.current,scaleByRatio:O,...ue!==void 0?{syntaxHighlighting:ue}:{},...Ye.current!==void 0?{codeHighlightProvider:Ye.current}:{},...Ge.current!==void 0?{loadCodeHighlightProvider:Ge.current}:{},...Ne!==void 0?{maxAutoDetectCodeLength:Ne}:{},isCopyAllowed:ge,...qe.current!==void 0?{languageOptions:qe.current}:{},...typeof ie=="boolean"?{isDraggableBoxEnabled:ie}:{},...ot.current?{featureFlags:ot.current}:{}};S.current={key:le,value:Ft(ee)};}let V=S.current.value,oe=useMemo(()=>{let ee=mergeThemes(defaultLuthorTheme,o??{});return N?{...ee,quote:`${ee.quote??""} ${N}`.trim()}:ee},[o,N]),W=useMemo(()=>yo(J),[J]),Qe=useMemo(()=>yo(A),[A]),f=useMemo(()=>nl(Q),[Q]),y=useMemo(()=>yo(f),[f]),z=useMemo(()=>{let ee=f,wt=createEditorThemeStyleVars(J),vo=A,Co={"--luthor-default-line-height":ve};return !ee&&!wt&&!vo?Co:{...ee??{},...wt,...vo??{},...Co}},[ve,f,J,A,y,W,Qe]),[D,ce]=useState(null);useImperativeHandle(Ae,()=>D,[D]);let de=ee=>{ce(ee),r&&l===void 0?ee.injectJSONB(JSON.stringify(bo)):l&&ee.injectJSONB(Wi(l)),t?.(ee);};return jsx("div",{className:`luthor-preset luthor-preset-extensive luthor-editor-wrapper ${c||""} ${e||""}`.trim(),"data-editor-theme":He,style:z,children:jsx(Yi,{extensions:V,config:{theme:oe},children:jsx(fl,{isDark:ze,toggleTheme:he,visualPlaceholder:F.visual,jsonbPlaceholder:F.jsonb,initialMode:ye,availableModes:d,onReady:de,toolbarLayout:E,toolbarVisibility:h,toolbarPosition:b,toolbarAlignment:m,toolbarClassName:p,toolbarStyleVars:$,isToolbarEnabled:C,headingOptions:k,paragraphLabel:j,syncHeadingOptionsWithCommands:R,slashCommandVisibility:te,shortcutConfig:B,commandPaletteShortcutOnly:be,featureFlags:Pe})})})});Yt.displayName="ExtensiveEditor";var jn=["undo","redo","heading","fontFamily","fontSize","lineHeight","textColor","textHighlight","bold","italic","underline","strikethrough","subscript","superscript","link","image","table","horizontalRule","iframeEmbed","youtubeEmbed","blockquote","code","codeBlock","bulletedList","numberedList","checkList","commandPalette","floatingToolbar","contextMenu","draggableBlock","customNode","sourceMode","themeToggle"],Vn={id:"extensive",label:"Extensive",description:"All features enabled for power users.",extensions:[...po],components:{Editor:Yt},toolbar:[...jn],config:a("extensive","Write anything..."),css:"extensive/styles.css"};function bl(e={}){return {...Vn,extensions:[...Ft({fontFamilyOptions:e.fontFamilyOptions,fontSizeOptions:e.fontSizeOptions,lineHeightOptions:e.lineHeightOptions,minimumDefaultLineHeight:e.minimumDefaultLineHeight,isCopyAllowed:e.isCopyAllowed,languageOptions:e.languageOptions})]}}export{nn as $,Ho as A,Bn as Aa,zo as B,Yt as Ba,Po as C,jn as Ca,Tl as D,Vn as Da,Ro as E,bl as Ea,Sl as F,Kt as G,Ao as H,Bo as I,Ut as J,Do as K,Ko as L,Uo as M,jo as N,Vo as O,Zt as P,_o as Q,$o as R,Jo as S,qo as T,Qo as U,Xo as V,tn as W,L as X,to as Y,kt as Z,Et as _,Ie as a,rn as aa,yl as b,oo as ba,Ot as c,ln as ca,Qt as d,gn as da,xo as e,mn as ea,Lo as f,hn as fa,Fo as g,io as ga,Mt as h,ha,Ht as i,Ar as ia,zt as j,Br as ja,Pt as k,Dr as ka,Rt as l,vn as la,wo as m,xn as ma,ut as n,It as na,nt as o,Ln as oa,At as p,Ft as pa,Bt as q,po as qa,Dt as r,wn as ra,Oo as s,On as sa,No as t,Nn as ta,Wt as u,Mn as ua,ct as v,Hn as va,rt as w,zn as wa,Mo as x,Pn as xa,dt as y,Rn as ya,Xt as z,An as za};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {Ba,pa}from'./chunk-5KKKDUJW.js';import {a}from'./chunk-MDSRHDWB.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var d={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},e=forwardRef(({className:s,variantClassName:i,hideToolbarByDefault:o=true,isToolbarEnabled:r,...f},m)=>jsx(Ba,{ref:m,...f,className:["luthor-preset-simple-text",s].filter(Boolean).join(" "),variantClassName:["luthor-preset-simple-text__variant",i].filter(Boolean).join(" "),availableModes:["visual"],initialMode:"visual",isToolbarEnabled:o?false:r,featureFlags:d}));e.displayName="SimpleTextEditor";var x={id:"simple-text",label:"Simple Text",description:"Plain text writing with rich formatting disabled.",extensions:pa({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:e},toolbar:[],config:a("simple-text","Write plain text..."),css:"simple-text/styles.css"};export{e as a,x as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {pa,xa,Ba,Aa,ya,za,ha}from'./chunk-5KKKDUJW.js';import {a}from'./chunk-MDSRHDWB.js';import {useRef,useState}from'react';import {jsonbToMarkdown,markdownToJSONB}from'@lyfie/luthor-headless';import {jsxs,jsx}from'react/jsx-runtime';function p({className:C,variantClassName:D,initialMode:P="visual",...S}){let n=useRef(null),a=useRef(xa(["visual"])),d=useRef(""),i=useRef(null),[r,O]=useState(P),[x,l]=useState(""),[E,v]=useState(null),M=e=>{if(e!==r)try{if(v(null),e==="markdown")if(za(a.current,"markdown"))l(d.current);else {let t=n.current?.getJSONB()??"",u=t?JSON.parse(t):void 0,k=ha(jsonbToMarkdown(u));d.current=k,l(k),Aa(a.current,"markdown");}if(e==="visual"){let t=markdownToJSONB(x);i.current=JSON.stringify(t);}O(e),e==="visual"&&setTimeout(()=>{i.current&&(n.current?.injectJSONB(i.current),i.current=null);},0);}catch(t){let u=t instanceof Error?t.message:"Failed to parse markdown";v(u);}};return jsxs("div",{className:["luthor-preset-md-text",C].filter(Boolean).join(" "),onInputCapture:()=>{r==="visual"&&ya(a.current,["visual"]);},children:[jsxs("div",{className:"luthor-md-text-tabs",children:[jsx("button",{type:"button",className:r==="visual"?"active":"",onClick:()=>M("visual"),children:"Visual"}),jsx("button",{type:"button",className:r==="markdown"?"active":"",onClick:()=>M("markdown"),children:"Markdown"})]}),r==="visual"&&jsx(Ba,{ref:n,...S,className:"luthor-preset-md-text__editor",variantClassName:["luthor-preset-md-text__variant",D].filter(Boolean).join(" "),availableModes:["visual"],initialMode:"visual",featureFlags:{table:false,image:false,iframeEmbed:false,youTubeEmbed:false,customNode:false}}),r==="markdown"&&jsxs("div",{className:"luthor-md-text-source-shell",children:[jsx("textarea",{className:"luthor-md-text-source",value:x,onChange:e=>{l(e.target.value),d.current=e.target.value,Aa(a.current,"markdown");},placeholder:"Write markdown..."}),E&&jsx("p",{className:"luthor-md-text-error",children:E})]})]})}var B={id:"md-text",label:"MD Text",description:"Visual and markdown editing with conversion bridge.",extensions:pa({featureFlags:{table:false,image:false,iframeEmbed:false,youTubeEmbed:false,customNode:false}}),components:{Editor:p},toolbar:["bold","italic","underline","strikethrough","link","unorderedList","orderedList"],config:a("md-text","Write markdown..."),css:"md-text/styles.css"};export{p as a,B as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {pa,Ba}from'./chunk-5KKKDUJW.js';import {a}from'./chunk-MDSRHDWB.js';import {jsx}from'react/jsx-runtime';var f={slashCommand:true,draggableBlock:true,commandPalette:true,floatingToolbar:false,contextMenu:false};function o({className:r,variantClassName:a,slashVisibility:s,isDraggableEnabled:l=true,featureFlags:n,isToolbarEnabled:d=false,...m}){return jsx(Ba,{...m,className:["luthor-preset-notion-like",r].filter(Boolean).join(" "),variantClassName:["luthor-preset-notion-like__variant",a].filter(Boolean).join(" "),isToolbarEnabled:d,slashCommandVisibility:s,featureFlags:{...f,draggableBlock:l,...n??{}}})}var b={id:"notion-like",label:"Notion Like",description:"Slash-first writing with draggable block defaults.",extensions:pa({featureFlags:{slashCommand:true,draggableBlock:true,floatingToolbar:false,contextMenu:false}}),components:{Editor:o},toolbar:[],config:a("notion-like","Type '/' for commands..."),css:"notion-like/styles.css"};export{o as a,b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {pa,Ba}from'./chunk-5KKKDUJW.js';import {a}from'./chunk-MDSRHDWB.js';import {useRef,useCallback}from'react';import {jsxs,jsx}from'react/jsx-runtime';function i({className:m,variantClassName:h,onSend:o,submitOnEnter:s=true,allowShiftEnter:l=true,showVoiceButton:b=false,showImageButton:p=true,showSendButton:w=true,...E}){let n=useRef(null),a=useCallback(()=>{o&&o({jsonb:n.current?.getJSONB()??""});},[o]),g=useCallback(e=>{!s||e.key!=="Enter"||e.nativeEvent.isComposing||e.shiftKey&&l||(e.preventDefault(),a());},[l,a,s]);return jsxs("div",{className:["luthor-preset-chat-window",m].filter(Boolean).join(" "),onKeyDownCapture:g,children:[jsx(Ba,{ref:n,...E,variantClassName:["luthor-preset-chat-window__variant",h].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:[b&&jsx("button",{type:"button",className:"luthor-chat-window-action","data-testid":"chat-voice-button","aria-label":"Voice input",children:"Voice"}),p&&jsx("button",{type:"button",className:"luthor-chat-window-action","data-testid":"chat-image-button","aria-label":"Add image",children:"Image"}),w&&jsx("button",{type:"button",className:"luthor-chat-window-action luthor-chat-window-action-send","data-testid":"chat-send-button",onClick:a,"aria-label":"Send message",children:"Send"})]})]})}var C={id:"chat-window",label:"Chat Window",description:"Chat composer with action row and send controls.",extensions:pa({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:i},toolbar:[],config:a("chat-window","Write a message..."),css:"chat-window/styles.css"};export{i as a,C as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(t,r){let e=`luthor-preset-${t}`;return {placeholder:r,classNames:{container:`luthor-preset ${e} ${e}__container`,contentEditable:`luthor-content-editable ${e}__content`,placeholder:`luthor-placeholder ${e}__placeholder`}}}export{o as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {Ba,pa}from'./chunk-5KKKDUJW.js';import {a}from'./chunk-MDSRHDWB.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var n={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},e=forwardRef(({className:a,variantClassName:s,compactToolbar:t=false,toolbarClassName:l,featureFlags:d,...f},x)=>jsx(Ba,{ref:x,...f,className:["luthor-preset-rich-text-box",a].filter(Boolean).join(" "),variantClassName:[t?"luthor-preset-rich-text-box--compact":"",s].filter(Boolean).join(" "),toolbarClassName:[t?"luthor-preset-rich-text-box__toolbar--compact":"",l].filter(Boolean).join(" "),featureFlags:{...n,...d??{}}}));e.displayName="RichTextBoxEditor";var u={id:"rich-text-box",label:"Rich Text Box",description:"Inline formatting and list-focused rich text editing.",extensions:pa({featureFlags:{image:false,table:false,iframeEmbed:false,youTubeEmbed:false,emoji:false,commandPalette:false,slashCommand:false,draggableBlock:false}}),components:{Editor:e},toolbar:["bold","italic","underline","strikethrough","unorderedList","orderedList","checkList","undo","redo"],config:a("rich-text-box","Write rich text..."),css:"rich-text-box/styles.css"};export{e as a,u as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {pa,Ba}from'./chunk-5KKKDUJW.js';import {a}from'./chunk-MDSRHDWB.js';import {jsxs,jsx}from'react/jsx-runtime';function t({className:r,variantClassName:i,showTo:m=true,showCc:p=false,showBcc:n=false,showSubject:d=true,...u}){return jsxs("div",{className:["luthor-preset-email-compose",r].filter(Boolean).join(" "),children:[jsxs("div",{className:"luthor-email-compose-shell",children:[m&&jsxs("label",{className:"luthor-email-compose-row","data-testid":"email-row-to",children:[jsx("span",{children:"To"}),jsx("input",{type:"text",readOnly:true,value:""})]}),p&&jsxs("label",{className:"luthor-email-compose-row","data-testid":"email-row-cc",children:[jsx("span",{children:"Cc"}),jsx("input",{type:"text",readOnly:true,value:""})]}),n&&jsxs("label",{className:"luthor-email-compose-row","data-testid":"email-row-bcc",children:[jsx("span",{children:"Bcc"}),jsx("input",{type:"text",readOnly:true,value:""})]}),d&&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(Ba,{...u,variantClassName:["luthor-preset-email-compose__variant",i].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 c={id:"email-compose",label:"Email Compose",description:"Compose shell with rich email body editing.",extensions:pa({featureFlags:{table:false,image:false,iframeEmbed:false,youTubeEmbed:false,customNode:false}}),components:{Editor:t},toolbar:["bold","italic","underline","link","unorderedList","orderedList","undo","redo"],config:a("email-compose","Write your email..."),css:"email-compose/styles.css"};export{t as a,c as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {pa,Ba}from'./chunk-5KKKDUJW.js';import {a}from'./chunk-MDSRHDWB.js';import {jsxs,jsx}from'react/jsx-runtime';function o({className:l,variantClassName:n,showTitle:d=true,title:f="",onTitleChange:m,showActions:c=true,onPin:u,onArchive:p,onColorChange:b,colorOptions:g=["#fef3c7","#dbeafe","#dcfce7"],...E}){return jsxs("div",{className:["luthor-preset-notes",l].filter(Boolean).join(" "),children:[d&&jsx("input",{"data-testid":"notes-title",className:"luthor-notes-title",placeholder:"Title",value:f,onChange:e=>m?.(e.target.value)}),c&&jsxs("div",{className:"luthor-notes-actions","data-testid":"notes-actions",children:[jsx("button",{type:"button",onClick:u,"aria-label":"Pin note",children:"Pin"}),jsx("button",{type:"button",onClick:p,"aria-label":"Archive note",children:"Archive"}),jsx("select",{"aria-label":"Change note color",onChange:e=>b?.(e.target.value),children:g.map(e=>jsx("option",{value:e,children:e},e))})]}),jsx(Ba,{...E,variantClassName:["luthor-preset-notes__variant",n].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 v={id:"notes",label:"Notes",description:"Compact notes editor with title and actions.",extensions:pa({featureFlags:{list:true,image:false,table:false,iframeEmbed:false,youTubeEmbed:false,commandPalette:false,slashCommand:false,draggableBlock:false,customNode:false}}),components:{Editor:o},toolbar:[],config:a("notes","Take a note..."),css:"notes/styles.css"};export{o as a,v as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a}from'./chunk-MDSRHDWB.js';import {createEditorSystem,richTextExtension,historyExtension,boldExtension,italicExtension,underlineExtension,listExtension,RichText}from'@lyfie/luthor-headless';import {jsx,jsxs}from'react/jsx-runtime';var h=[richTextExtension,historyExtension,boldExtension,italicExtension,underlineExtension,listExtension],{Provider:E,useEditor:m}=createEditorSystem();function P(){let{commands:t,activeStates:o}=m();return jsxs("div",{className:"luthor-headless-controls",role:"toolbar","aria-label":"Headless editor controls",children:[jsx("button",{type:"button",onClick:()=>t.toggleBold?.(),"aria-pressed":o.bold===true,children:"bold"}),jsx("button",{type:"button",onClick:()=>t.toggleItalic?.(),"aria-pressed":o.italic===true,children:"italic"}),jsx("button",{type:"button",onClick:()=>t.toggleUnderline?.(),"aria-pressed":o.underline===true,children:"underline"}),jsx("button",{type:"button",onClick:()=>t.toggleUnorderedList?.(),children:"bullet list"}),jsx("button",{type:"button",onClick:()=>t.undo?.(),children:"undo"}),jsx("button",{type:"button",onClick:()=>t.redo?.(),children:"redo"})]})}function s({className:t,placeholder:o="Start writing..."}){return jsx("div",{className:["luthor-headless-preset",t].filter(Boolean).join(" "),children:jsxs(E,{extensions:h,children:[jsx(P,{}),jsx(RichText,{placeholder:o,classNames:{container:"luthor-headless-editor-container",contentEditable:"luthor-headless-editor-content",placeholder:"luthor-headless-editor-placeholder"}})]})})}var x={id:"headless-editor",label:"Headless Editor",description:"Minimal plain-control preset for customization starters.",components:{Editor:s},toolbar:["bold","italic","underline","unorderedList","undo","redo"],config:a("headless-editor","Start writing..."),css:"headless-editor/styles.css"};export{s as a,x as b};
|