@lyfie/luthor 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +6 -4
  2. package/dist/LegacyRichEditor-Hzt4pYS-.d.ts +24 -0
  3. package/dist/chunk-4DOFRI6R.js +1 -0
  4. package/dist/chunk-7KHDV6HL.js +1 -0
  5. package/dist/chunk-I7ETX4BN.js +1 -0
  6. package/dist/{chunk-ONBHJIZQ.js → chunk-LG5WRRFQ.js} +3 -3
  7. package/dist/chunk-MYQMH4OW.js +1 -0
  8. package/dist/chunk-PAUOCZCW.js +1 -0
  9. package/dist/chunk-QCGA72CH.js +1 -0
  10. package/dist/chunk-YWKRMBRS.js +13 -0
  11. package/dist/{ExtensiveEditor-6OT-Dmr1.d.ts → index-BjlX1b8G.d.ts} +16 -2
  12. package/dist/{index-DZPcit31.d.ts → index-CtyjH6lX.d.ts} +1 -2
  13. package/dist/index.css +1 -1
  14. package/dist/index.d.ts +10 -8
  15. package/dist/index.js +1 -1
  16. package/dist/presets/compose/index.d.ts +1 -12
  17. package/dist/presets/compose/index.js +1 -1
  18. package/dist/presets/extensive/index.d.ts +2 -3
  19. package/dist/presets/extensive/index.js +1 -1
  20. package/dist/presets/headless-editor/index.d.ts +13 -6
  21. package/dist/presets/headless-editor/index.js +1 -1
  22. package/dist/presets/html-editor/index.d.ts +18 -0
  23. package/dist/presets/html-editor/index.js +1 -0
  24. package/dist/presets/legacy-rich/index.d.ts +8 -0
  25. package/dist/presets/legacy-rich/index.js +1 -0
  26. package/dist/presets/md-editor/index.d.ts +19 -0
  27. package/dist/presets/md-editor/index.js +1 -0
  28. package/dist/presets/{composer → simple-editor}/index.d.ts +14 -15
  29. package/dist/presets/simple-editor/index.js +1 -0
  30. package/dist/presets/slash-editor/index.d.ts +16 -0
  31. package/dist/presets/slash-editor/index.js +1 -0
  32. package/package.json +4 -4
  33. package/dist/chunk-42NSZXCX.js +0 -1
  34. package/dist/chunk-AHHU2IZS.js +0 -1
  35. package/dist/chunk-MDSRHDWB.js +0 -1
  36. package/dist/chunk-MGWT45KA.js +0 -1
  37. package/dist/chunk-TRGIRBLU.js +0 -1
  38. package/dist/chunk-VITE7CVN.js +0 -1
  39. package/dist/index-BtdZVw3X.d.ts +0 -17
  40. package/dist/presets/composer/index.js +0 -1
  41. package/dist/presets/md-friendly/index.d.ts +0 -19
  42. package/dist/presets/md-friendly/index.js +0 -1
  43. package/dist/presets/notion-like/index.d.ts +0 -17
  44. package/dist/presets/notion-like/index.js +0 -1
@@ -1,6 +1,6 @@
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,ListExtension,TabIndentExtension,boldExtension,italicExtension,underlineExtension,strikethroughExtension,subscriptExtension,superscriptExtension,horizontalRuleExtension,historyExtension,blockFormatExtension,codeFormatExtension,enterKeyBehaviorExtension,RichText,clearLexicalSelection,markdownToJSON,htmlToJSON,jsonToMarkdown,jsonToHTML,resolveLinkNodeKeyFromAnchor}from'@lyfie/luthor-headless';import Si,{forwardRef,useState,useRef,useMemo,useEffect,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"],za={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:["customComponent"]},{items:["undo","redo"]},{items:["commandPalette"]},{items:["themeToggle"]}]},qt={sections:[{items:["undo","redo"]},{items:["fontFamily","blockFormat","fontSize","lineHeight"]},{items:["bold","italic","underline","strikethrough","textColor","textHighlight"]},{items:["alignLeft","alignCenter","alignRight","alignJustify"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["link"]},{items:["image","table","code","codeBlock","horizontalRule","quote"]},{items:["subscript","superscript","emoji","embed","customComponent"]},{items:["commandPalette","themeToggle"]}]};function wr(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 Sr(e,t){return wr(e.target)?Wo(t):false}function Wo(e){let t=e.key.toLowerCase();return !(!!e.ctrlKey||!!e.metaKey)||e.altKey?false:t==="b"||t==="i"||t==="u"||t==="k"}function Go(e){return typeof e.setCodeLanguage=="function"&&typeof e.autoDetectCodeLanguage=="function"}function xr(e){return typeof e.toggleSubscript=="function"}function Ir(e){return typeof e.toggleSuperscript=="function"}function Fr(e){return typeof e.insertIframeEmbed=="function"}function Or(e){return typeof e.insertYouTubeEmbed=="function"}function Nr(e){return typeof e.insertEmoji=="function"}function Mr(e){return e.slice(1)}function Hr(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 Rr(e){if(!e||e.length===0)return [...Ie];let t=new Set,o=[];for(let n of e)!Ie.includes(n)||t.has(n)||(t.add(n),o.push(n));return o.length>0?o:[...Ie]}function vo(e,t){return Br(Co(t),t?.shortcutConfig).filter(n=>!n.condition||n.condition(e))}function Q(e,t){return typeof e[t]=="function"}function Yt(e){if(!e||e.length===0)return new Set;let t=e.map(o=>o.trim()).filter(o=>o.length>0);return new Set(t)}function Ar(e){if(!e)return {allowlist:new Set,denylist:new Set};if(Array.isArray(e)){let o=[];for(let n of e)for(let[i,r]of Object.entries(n))r&&o.push(i);return {allowlist:Yt(o),denylist:new Set}}let t=e;return {allowlist:Yt(t.allowlist),denylist:Yt(t.denylist)}}function Xo(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 Pr(e){if(e===false||e===null)return [];let t=Array.isArray(e)?e:[e],o=[];for(let n of t){let i=Xo(n);i&&o.push(i);}return o}function zr(e){return [e.key.toLowerCase(),e.ctrlKey?"ctrl":"",e.metaKey?"meta":"",e.shiftKey?"shift":"",e.altKey?"alt":""].join(":")}function Br(e,t){if(!t)return [...e];let o=Yt(t.disabledCommandIds),n=t.bindings,i=t.preventNativeConflicts!==false,r=t.preventCollisions!==false,l=new Set;return e.filter(u=>!o.has(u.id)).map(u=>{let m=u.shortcuts?[...u.shortcuts]:void 0;if(!!n&&Object.prototype.hasOwnProperty.call(n,u.id)&&n){let C=n[u.id],b=C===void 0?[]:Pr(C);m=b.length>0?b:void 0;}if(m&&m.length>0){let C=[];for(let b of m){let f=Xo(b);if(!f||i&&Wo(f))continue;let p=zr(f);r&&l.has(p)||(l.add(p),C.push(f));}m=C.length>0?C:void 0;}return {...u,shortcuts:m}})}function Co(e){let t=e?.isFeatureEnabled??(()=>true),o=Rr(e?.headingOptions),n=e?.paragraphLabel?.trim()||"Paragraph",i=o.map(r=>{let l=Mr(r);return {id:`block.heading${l}`,label:`Heading ${l}`,description:Hr(r),category:"Block",action:s=>s.toggleHeading?.(r),shortcuts:[{key:l,ctrlKey:true,altKey:true}],keywords:["heading",r],condition:s=>t("blockFormat")&&Q(s,"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")&&Q(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")&&Q(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")&&Q(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")&&Q(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")&&xr(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")&&Ir(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")&&Q(r,"formatText")},{id:"block.paragraph",label:n,description:"Convert to paragraph",category:"Block",action:r=>r.toggleParagraph?.(),shortcuts:[{key:"0",ctrlKey:true,altKey:true}],keywords:["paragraph","text"],condition:r=>t("blockFormat")&&Q(r,"toggleParagraph")},...i,{id:"block.quote",label:"Quote",description:"Convert to blockquote",category:"Block",action:r=>r.toggleQuote?.(),keywords:["quote","blockquote"],condition:r=>t("blockFormat")&&Q(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")&&Q(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")&&Q(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")&&Q(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")&&Q(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")&&Q(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 l=prompt("Code language (e.g. ts, css, python):")?.trim();l&&r.setCodeLanguage(l);},keywords:["code","language","syntax"],condition:r=>t("codeIntelligence")&&Go(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")&&Go(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")&&Q(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")&&Q(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")&&Q(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")&&Q(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")&&Q(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")&&Q(r,"insertHorizontalRule")},{id:"insert.image",label:"Insert Image",description:"Insert an image from URL",category:"Insert",action:r=>{let l=prompt("Enter image URL:");if(l){let s=prompt("Enter alt text:")||"";r.insertImage?.({src:l,alt:s});}},keywords:["image","photo"],condition:r=>t("image")&&Q(r,"insertImage")},{id:"insert.gif",label:"Insert GIF",description:"Insert an animated GIF from URL",category:"Insert",action:r=>{let l=prompt("Enter GIF URL:");l&&r.insertImage?.({src:l,alt:"GIF"});},keywords:["gif","animated","image"],condition:r=>t("image")&&Q(r,"insertImage")},{id:"insert.emoji",label:"Insert Emoji",description:"Insert an emoji character",category:"Insert",action:r=>{let l=prompt("Enter emoji or shortcode (example :sparkles:):")?.trim();if(!l||typeof r.insertEmoji!="function")return;let s=l.match(/^:([a-z0-9_+-]+):$/i);if(s){let u=s[1];if(!u)return;if(typeof r.resolveEmojiShortcode=="function"){let m=r.resolveEmojiShortcode(u);if(m?.emoji){r.insertEmoji(m.emoji);return}}else if(typeof r.getEmojiSuggestions=="function"){let[m]=r.getEmojiSuggestions(u);if(m?.emoji){r.insertEmoji(m.emoji);return}}}r.insertEmoji(l);},keywords:["emoji","reaction","symbol","smile"],condition:r=>t("emoji")&&Nr(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")&&Q(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 l=prompt("Enter iframe URL:");l&&r.insertIframeEmbed(l);},keywords:["iframe","embed","url"],condition:r=>t("iframeEmbed")&&Fr(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 l=prompt("Enter YouTube URL:");l&&r.insertYouTubeEmbed(l);},keywords:["youtube","video","embed"],condition:r=>t("youTubeEmbed")&&Or(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")&&Q(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")&&Q(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")&&Q(r,"showCommandPalette")}]}function Qo(e,t){let o=t?.commandPaletteShortcutOnly===true;return vo(e,t).filter(n=>!o||!!n.shortcuts&&n.shortcuts.length>0).map(n=>({id:n.id,label:n.label,description:n.description,category:n.category,action:()=>n.action(e),keywords:n.keywords,shortcut:n.shortcuts?.[0]?en(n.shortcuts[0]):void 0}))}function Zo(e,t){let o=new Set(["block.paragraph","block.quote","block.codeblock"]),n=s=>s.category==="Insert"||s.category==="List"?true:s.category==="Block"?s.id.startsWith("block.heading")?true:o.has(s.id):false,{allowlist:i,denylist:r}=Ar(t?.slashCommandVisibility),l=i.size>0;return vo(e,t).filter(n).filter(s=>r.has(s.id)?false:l?i.has(s.id):true).map(s=>({id:s.id,label:s.label,description:s.description,category:s.category,action:()=>s.action(e),keywords:s.keywords,shortcut:s.shortcuts?.[0]?en(s.shortcuts[0]):void 0}))}function en(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 tn(e,t=document.body,o){let n=vo(e,o),i=(l,s)=>l.key.toLowerCase()===s.key.toLowerCase()||s.key==="`"&&l.code==="Backquote",r=l=>{let s=typeof o?.scope=="function"?o.scope():o?.scope;if(!(s&&l.target instanceof Node&&!s.contains(l.target))){for(let u of n)if(u.shortcuts){for(let m of u.shortcuts)if(!(o?.shortcutConfig?.preventNativeConflicts!==false&&Sr(l,m))&&i(l,m)&&!!l.ctrlKey==!!m.ctrlKey&&!!l.metaKey==!!m.metaKey&&!!l.shiftKey==!!m.shiftKey&&!!l.altKey==!!m.altKey){m.preventDefault!==false&&l.preventDefault(),(!u.condition||u.condition(e))&&u.action(e);return}}}};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)}function H(e,t){let o=forwardRef(function({size:i=24,strokeWidth:r=2,...l},s){return jsx("svg",{ref:s,xmlns:"http://www.w3.org/2000/svg",width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...l,children:t})});return o.displayName=e,o}var Jt=H("BoldIcon",jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})),Gt=H("ItalicIcon",jsxs(Fragment,{children:[jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})),Wt=H("UnderlineIcon",jsxs(Fragment,{children:[jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})),Xt=H("StrikethroughIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})),Qt=H("CodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"m16 18 6-6-6-6"}),jsx("path",{d:"m8 6-6 6 6 6"})]})),on=H("CodeBlockIcon",jsxs(Fragment,{children:[jsx("path",{d:"m10 9-3 3 3 3"}),jsx("path",{d:"m14 15 3-3-3-3"}),jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})]})),Lt=H("LinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})),ht=H("UnlinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"}),jsx("path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"}),jsx("line",{x1:"8",x2:"8",y1:"2",y2:"5"}),jsx("line",{x1:"2",x2:"5",y1:"8",y2:"8"}),jsx("line",{x1:"16",x2:"16",y1:"19",y2:"22"}),jsx("line",{x1:"19",x2:"22",y1:"16",y2:"16"})]})),Zt=H("ListIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h.01"}),jsx("path",{d:"M3 12h.01"}),jsx("path",{d:"M3 19h.01"}),jsx("path",{d:"M8 5h13"}),jsx("path",{d:"M8 12h13"}),jsx("path",{d:"M8 19h13"})]})),eo=H("ListCheckIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 5H3"}),jsx("path",{d:"M16 12H3"}),jsx("path",{d:"M11 19H3"}),jsx("path",{d:"m15 18 2 2 4-4"})]})),to=H("ListOrderedIcon",jsxs(Fragment,{children:[jsx("path",{d:"M11 5h10"}),jsx("path",{d:"M11 12h10"}),jsx("path",{d:"M11 19h10"}),jsx("path",{d:"M4 4h1v5"}),jsx("path",{d:"M4 9h2"}),jsx("path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02"})]})),nn=H("UndoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 7v6h6"}),jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})),rn=H("RedoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 7v6h-6"}),jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})]})),ko=H("ImageIcon",jsxs(Fragment,{children:[jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),jsx("circle",{cx:"9",cy:"9",r:"2"}),jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})),Tt=H("AlignLeftIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M15 12H3"}),jsx("path",{d:"M17 19H3"})]})),ft=H("AlignCenterIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M17 12H7"}),jsx("path",{d:"M19 19H5"})]})),ln=H("AlignJustifyIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h18"}),jsx("path",{d:"M3 12h18"}),jsx("path",{d:"M3 19h18"})]})),wt=H("AlignRightIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M21 12H9"}),jsx("path",{d:"M21 19H7"})]})),Eo=H("UploadIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 3v12"}),jsx("path",{d:"m17 8-5-5-5 5"}),jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})),an=H("MinusIcon",jsx("path",{d:"M5 12h14"})),sn=H("TableIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 3v18"}),jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),jsx("path",{d:"M3 9h18"}),jsx("path",{d:"M3 15h18"})]})),un=H("FileCodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}),jsx("path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}),jsx("path",{d:"M10 12.5 8 15l2 2.5"}),jsx("path",{d:"m14 12.5 2 2.5-2 2.5"})]})),Va=H("EyeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),jsx("circle",{cx:"12",cy:"12",r:"3"})]})),cn=H("HighlighterIcon",jsxs(Fragment,{children:[jsx("path",{d:"m9 11-6 6v3h9l3-3"}),jsx("path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"})]})),_a=H("PencilIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),jsx("path",{d:"m15 5 4 4"})]})),oo=H("CommandIcon",jsx("path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3"})),dn=H("PaletteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"}),jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"})]})),mn=H("TypeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 4v16"}),jsx("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),jsx("path",{d:"M9 20h6"})]})),no=H("QuoteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"}),jsx("path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"})]})),gn=H("IndentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H11"}),jsx("path",{d:"M21 12H11"}),jsx("path",{d:"M21 19H11"}),jsx("path",{d:"m3 8 4 4-4 4"})]})),hn=H("OutdentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H11"}),jsx("path",{d:"M21 12H11"}),jsx("path",{d:"M21 19H11"}),jsx("path",{d:"m7 8-4 4 4 4"})]})),fn=H("SunIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v2"}),jsx("path",{d:"M12 20v2"}),jsx("path",{d:"m4.93 4.93 1.41 1.41"}),jsx("path",{d:"m17.66 17.66 1.41 1.41"}),jsx("path",{d:"M2 12h2"}),jsx("path",{d:"M20 12h2"}),jsx("path",{d:"m6.34 17.66-1.41 1.41"}),jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})),pn=H("MoonIcon",jsx("path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"})),bn=H("SearchIcon",jsxs(Fragment,{children:[jsx("path",{d:"m21 21-4.34-4.34"}),jsx("circle",{cx:"11",cy:"11",r:"8"})]})),Lo=H("EmojiIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),jsx("line",{x1:"9",x2:"9.01",y1:"9",y2:"9"}),jsx("line",{x1:"15",x2:"15.01",y1:"9",y2:"9"})]})),yn=H("SubscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 5 8 8"}),jsx("path",{d:"m12 5-8 8"}),jsx("path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})),vn=H("SuperscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 19 8-8"}),jsx("path",{d:"m12 19-8-8"}),jsx("path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06"})]})),St=H("ChevronDownIcon",jsx("path",{d:"m6 9 6 6 6-6"})),Cn=H("CloseIcon",jsxs(Fragment,{children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));function Ln({isOpen:e,onClose:t,commands:o}){let[n,i]=useState(""),[r,l]=useState(0),s=useRef(null),u=useRef(null),m=o.filter(b=>`${b.label} ${b.description||""} ${b.keywords?.join(" ")||""}`.toLowerCase().includes(n.toLowerCase())),E=m.reduce((b,f)=>{let p=f.category||"Other";return b[p]||(b[p]=[]),b[p].push(f),b},{}),C=m;return useEffect(()=>{l(0);},[n]),useEffect(()=>{e&&s.current&&(s.current.focus({preventScroll:true}),i(""),l(0));},[e]),useEffect(()=>{if(!e)return;let b=u.current;if(!b)return;b.querySelector(".luthor-command-palette-item.selected")?.scrollIntoView({block:"nearest"});},[e,r,n]),useEffect(()=>{let b=f=>{if(e)switch(f.key){case "Escape":f.preventDefault(),f.stopPropagation(),t();break;case "ArrowDown":f.preventDefault(),f.stopPropagation(),l(p=>Math.min(p+1,C.length-1));break;case "ArrowUp":f.preventDefault(),f.stopPropagation(),l(p=>Math.max(p-1,0));break;case "Enter":f.preventDefault(),f.stopPropagation(),C[r]&&(C[r].action(),t());break}};return document.addEventListener("keydown",b,true),()=>document.removeEventListener("keydown",b,true)},[e,r,C,t]),e?jsx("div",{className:"luthor-command-palette-overlay",onClick:t,children:jsxs("div",{className:"luthor-command-palette",role:"dialog","aria-modal":"true","aria-label":"Command Palette",onClick:b=>b.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(bn,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:s,type:"text",placeholder:"Type a command or search...",value:n,onChange:b=>i(b.target.value),className:"luthor-command-palette-input"}),jsx("kbd",{className:"luthor-command-palette-kbd",children:"ESC"})]}),jsx("div",{ref:u,className:"luthor-command-palette-list",children:Object.keys(E).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(E).map(([b,f])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:b}),f.map(p=>{let h=C.indexOf(p);return jsxs("div",{className:`luthor-command-palette-item ${h===r?"selected":""}`,onClick:()=>{p.action(),t();},onMouseEnter:()=>l(h),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(oo,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var Ur={"--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":"#000000","--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 Kr(e){return e?e.closest(".luthor-editor-wrapper"):null}function Vr(e){return e?Kr(e)??e:null}function _r(e){if(typeof window>"u"||!e)return {};let t=window.getComputedStyle(e),o={};for(let[n,i]of Object.entries(Ur)){let r=t.getPropertyValue(n).trim()||i;o[n]=r;}return o}function Fe(e){return _r(Vr(e))}function It(){if(typeof window>"u")return {};let t=window.getSelection()?.anchorNode;if(!t)return {};let o=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return Fe(o)}function pt(e){return e?e.closest(".luthor-editor-wrapper")??null:null}function Tn(e,t,o){return e<t?t:e>o?o:e}function jr(e){if(!e||typeof window>"u"){let o=typeof window>"u"?0:window.innerWidth,n=typeof window>"u"?0:window.innerHeight;return {left:0,top:0,right:o,bottom:n}}let t=e.getBoundingClientRect();return {left:t.left,top:t.top,right:t.right,bottom:t.bottom}}function $r(e,t,o,n,i,r){let l=i==="end"?e.right-t:i==="center"?e.left+e.width/2-t/2:e.left,s=i==="end"?e.left:i==="center"?e.left+e.width/2-t/2:e.right-t,u=l,m=o.left+n,E=Math.max(m,o.right-t-n);if(r){let C=u<m||u>E,b=s>=m&&s<=E;C&&b&&(u=s);}return Tn(u,m,E)}function qr(e,t,o,n,i,r,l){let s=r==="top"?e.top-t-n:e.bottom+n,u=r==="top"?e.bottom+n:e.top-t-n,m=s,E=o.top+i,C=Math.max(E,o.bottom-t-i);if(l){let b=m<E||m>C,f=u>=E&&u<=C;b&&f&&(m=u);}return Tn(m,E,C)}function be({anchorRect:e,overlay:t,portalContainer:o=null,gap:n=4,margin:i=8,preferredX:r="start",preferredY:l="bottom",flipX:s=true,flipY:u=true}){let m=jr(o),E=Math.max(0,t.width),C=Math.max(0,t.height),b=$r(e,E,m,i,r,s),f=qr(e,C,m,n,i,l,u);if(o){let p=o.getBoundingClientRect();return {position:"absolute",left:b-p.left,top:f-p.top}}return {position:"fixed",left:b,top:f}}function io(e,t){return {x:e,y:t,width:1,height:1,left:e,right:e+1,top:t,bottom:t+1,toJSON:()=>({})}}function Sn({isOpen:e,query:t,position:o,portalContainer:n,suggestions:i,onClose:r,onExecute:l}){let[s,u]=useState(0),m=useRef(null),[E,C]=useState(void 0);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let p=h=>{let v=i.length>0;switch(h.key){case "Escape":h.preventDefault(),h.stopPropagation(),r();break;case "ArrowDown":if(!v)return;h.preventDefault(),h.stopPropagation(),u(x=>Math.min(x+1,Math.max(i.length-1,0)));break;case "ArrowUp":if(!v)return;h.preventDefault(),h.stopPropagation(),u(x=>Math.max(x-1,0));break;case "Enter":case "Tab":if(!v||!i[s])return;h.preventDefault(),h.stopPropagation(),l(i[s].emoji);break}};return document.addEventListener("keydown",p,true),()=>document.removeEventListener("keydown",p,true)},[e,r,l,s,i]);let b=useCallback(p=>{if(!o)return;let h=m.current?.getBoundingClientRect(),v=be({anchorRect:io(o.x,o.y),overlay:{width:h?.width??320,height:h?.height??280},portalContainer:n??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});C({...v,visibility:p?"visible":"hidden",...It()});},[n,o]);if(useLayoutEffect(()=>{if(!e||!o)return;b(false);let p=window.requestAnimationFrame(()=>b(true));return ()=>window.cancelAnimationFrame(p)},[e,o,b]),useEffect(()=>{if(!e||!o)return;let p=()=>b(true);return window.addEventListener("resize",p),window.addEventListener("scroll",p,true),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,true);}},[e,o,b]),!e||!o)return null;let f=jsxs("div",{className:"luthor-emoji-menu",ref:m,style:E,onPointerDown:p=>{p.stopPropagation();},onMouseDown:p=>{p.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:i.length===0?jsx("div",{className:"luthor-emoji-menu-empty",children:"No matching emoji"}):i.map((p,h)=>{let v=h===s,x=p.shortcodes[0]?`:${p.shortcodes[0]}:`:"";return jsxs("button",{type:"button",className:`luthor-emoji-menu-item ${v?"selected":""}`,onMouseEnter:()=>u(h),onMouseDown:F=>{F.preventDefault(),F.stopPropagation();},onClick:F=>{F.preventDefault(),F.stopPropagation(),l(p.emoji);},children:[jsx("span",{className:"luthor-emoji-menu-item-symbol","aria-hidden":"true",children:p.emoji}),jsxs("span",{className:"luthor-emoji-menu-item-content",children:[jsx("span",{className:"luthor-emoji-menu-item-title",children:p.label}),x&&jsx("span",{className:"luthor-emoji-menu-item-shortcode",children:x})]})]},`${p.emoji}-${p.label}`)})})]});return typeof document>"u"?f:createPortal(f,n??document.body)}function Fn({isOpen:e,query:t,position:o,portalContainer:n,commands:i,onClose:r,onExecute:l}){let[s,u]=useState(0),m=useRef(null),[E,C]=useState(void 0),b=useMemo(()=>{let v=t.trim().toLowerCase();return v?i.filter(x=>`${x.label} ${x.description||""} ${x.keywords?.join(" ")||""}`.toLowerCase().includes(v)):i},[i,t]),f=useMemo(()=>b.reduce((v,x)=>{let F=x.category||"Other";return v[F]||(v[F]=[]),v[F].push(x),v},{}),[b]);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let v=x=>{let F=b.length>0;switch(x.key){case "Escape":x.preventDefault(),x.stopPropagation(),r();break;case "ArrowDown":if(!F)return;x.preventDefault(),x.stopPropagation(),u(J=>Math.min(J+1,Math.max(b.length-1,0)));break;case "ArrowUp":if(!F)return;x.preventDefault(),x.stopPropagation(),u(J=>Math.max(J-1,0));break;case "Enter":case "Tab":if(!F||!b[s])return;x.preventDefault(),x.stopPropagation(),l(b[s].id);break}};return document.addEventListener("keydown",v,true),()=>document.removeEventListener("keydown",v,true)},[b,e,r,l,s]);let p=useCallback(v=>{if(!o)return;let x=m.current?.getBoundingClientRect(),F=be({anchorRect:io(o.x,o.y),overlay:{width:x?.width??420,height:x?.height??360},portalContainer:n??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});C({...F,visibility:v?"visible":"hidden",...It()});},[n,o]);if(useLayoutEffect(()=>{if(!e||!o)return;p(false);let v=window.requestAnimationFrame(()=>p(true));return ()=>window.cancelAnimationFrame(v)},[e,o,p]),useEffect(()=>{if(!e||!o)return;let v=()=>p(true);return window.addEventListener("resize",v),window.addEventListener("scroll",v,true),()=>{window.removeEventListener("resize",v),window.removeEventListener("scroll",v,true);}},[e,o,p]),!e||!o)return null;let h=jsxs("div",{className:"luthor-slash-menu",ref:m,style:E,onPointerDown:v=>{v.stopPropagation();},onMouseDown:v=>{v.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:b.length===0?jsx("div",{className:"luthor-slash-menu-empty",children:"No matching commands"}):Object.entries(f).map(([v,x])=>jsxs("div",{className:"luthor-slash-menu-group",children:[jsx("div",{className:"luthor-slash-menu-group-title",children:v}),x.map(F=>{let J=b.indexOf(F);return jsxs("button",{type:"button",className:`luthor-slash-menu-item ${J===s?"selected":""}`,onMouseEnter:()=>u(J),onMouseDown:R=>{R.preventDefault(),R.stopPropagation();},onClick:R=>{R.preventDefault(),R.stopPropagation(),l(F.id);},children:[jsxs("span",{className:"luthor-slash-menu-item-content",children:[jsx("span",{className:"luthor-slash-menu-item-title",children:F.label}),F.description&&jsx("span",{className:"luthor-slash-menu-item-description",children:F.description})]}),F.shortcut&&jsx("kbd",{className:"luthor-slash-menu-item-shortcut",children:F.shortcut})]},F.id)})]},v))})]});return typeof document>"u"?h:createPortal(h,n??document.body)}function N({children:e,onClick:t,title:o,active:n,disabled:i,className:r,type:l="button"}){return jsx("button",{type:l,className:`luthor-toolbar-button${n?" active":""}${r?` ${r}`:""}`,onClick:t,title:o,disabled:i,children:e})}function So({children:e,onClick:t,variant:o="primary",type:n="button",className:i}){return jsx("button",{type:n,onClick:t,className:`${o==="primary"?"luthor-button-primary":"luthor-button-secondary"}${i?` ${i}`:""}`,children:e})}function Dt({value:e,onValueChange:t,options:o,placeholder:n="Select..."}){let[i,r]=useState(false),[l,s]=useState(void 0),[u,m]=useState(null),E=useRef(null),C=useRef(null);useEffect(()=>{if(!i)return;let f=()=>{let h=E.current?.querySelector(".luthor-select-trigger");if(!h)return;let v=h.getBoundingClientRect(),x=C.current?.getBoundingClientRect(),F=pt(h);m(F);let J=Math.max(v.width,x?.width??0),$=x?.height??220,R=be({anchorRect:v,overlay:{width:J,height:$},portalContainer:F,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});s({...R,width:v.width,...Fe(h)});},p=()=>f();return window.addEventListener("resize",p),window.addEventListener("scroll",p,true),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,true),m(null);}},[i]),useLayoutEffect(()=>{if(!i)return;let f=E.current?.querySelector(".luthor-select-trigger");if(!f)return;let p=f.getBoundingClientRect(),h=pt(f);m(h);let v=be({anchorRect:p,overlay:{width:p.width,height:220},portalContainer:h,gap:4,margin:8});s({...v,width:p.width,...Fe(f)});let x=window.requestAnimationFrame(()=>{let F=C.current?.getBoundingClientRect(),J=be({anchorRect:p,overlay:{width:Math.max(p.width,F?.width??0),height:F?.height??220},portalContainer:h,gap:4,margin:8});s({...J,width:p.width,...Fe(f)});});return ()=>window.cancelAnimationFrame(x)},[i]),useEffect(()=>{function f(p){let h=p.target;E.current?.contains(h)||C.current?.contains(h)||r(false);}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);let b=o.find(f=>f.value===e);return jsxs("div",{className:"luthor-select",ref:E,children:[jsxs("button",{className:`luthor-select-trigger ${i?"open":""}`,onClick:()=>r(!i),type:"button",children:[jsx("span",{children:b?.label||n}),jsx(St,{size:14})]}),i&&typeof document<"u"&&createPortal(jsx("div",{ref:C,className:"luthor-select-dropdown",style:l,children:o.map(f=>jsx("button",{className:`luthor-select-option ${e===f.value?"selected":""}`,onClick:()=>{t(f.value),r(false);},type:"button",children:f.label},f.value))}),u??document.body)]})}function rt({trigger:e,children:t,isOpen:o,onOpenChange:n}){let i=useRef(null),r=useRef(null),l=useRef(null),[s,u]=useState(void 0),[m,E]=useState(null);return useEffect(()=>{if(!o)return;let C=()=>{let f=r.current;if(!f)return;let p=f.getBoundingClientRect(),h=l.current?.getBoundingClientRect(),v=pt(f);E(v);let x=be({anchorRect:p,overlay:{width:h?.width??220,height:h?.height??200},portalContainer:v,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});u({...x,...Fe(f)});},b=()=>C();return window.addEventListener("resize",b),window.addEventListener("scroll",b,true),()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,true),E(null);}},[o]),useLayoutEffect(()=>{if(!o)return;let C=r.current;if(!C)return;let b=C.getBoundingClientRect(),f=pt(C);E(f);let p=be({anchorRect:b,overlay:{width:220,height:200},portalContainer:f,gap:4,margin:8});u({...p,...Fe(C)});let h=window.requestAnimationFrame(()=>{let v=l.current?.getBoundingClientRect(),x=be({anchorRect:b,overlay:{width:v?.width??220,height:v?.height??200},portalContainer:f,gap:4,margin:8});u({...x,...Fe(C)});});return ()=>window.cancelAnimationFrame(h)},[o]),useEffect(()=>{function C(b){let f=b.target;i.current?.contains(f)||l.current?.contains(f)||n(false);}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[n]),jsxs("div",{className:"luthor-dropdown",ref:i,children:[jsx("div",{ref:r,onClick:()=>n(!o),children:e}),o&&typeof document<"u"&&createPortal(jsx("div",{ref:l,className:"luthor-dropdown-content",style:s,children:t}),m??document.body)]})}function Mn({isOpen:e,onClose:t,title:o,children:n}){let i=useRef(null);return useEffect(()=>{function r(s){i.current&&!i.current.contains(s.target)&&t();}function l(s){s.key==="Escape"&&t();}return e&&(document.addEventListener("mousedown",r),document.addEventListener("keydown",l)),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",l);}},[e,t]),e?jsx("div",{className:"luthor-dialog-overlay",children:jsxs("div",{className:"luthor-dialog",ref:i,children:[jsxs("div",{className:"luthor-dialog-header",children:[jsx("h3",{className:"luthor-dialog-title",children:o}),jsx("button",{className:"luthor-dialog-close",onClick:t,type:"button",children:jsx(Cn,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:n})]})}):null}function Hn({isVisible:e,selectionRect:t,commands:o,activeStates:n,editorTheme:i="light",hide:r,isFeatureEnabled:l=()=>true}){let s=useRef(null),[u,m]=useState(""),[E,C]=useState(""),[b,f]=useState(""),[p,h]=useState(""),[v,x]=useState(""),[F,J]=useState(""),[$,R]=useState(null),[re,ee]=useState(null),[L,te]=useState(null),k=!!n.isIframeEmbedSelected,V=!!n.isYouTubeEmbedSelected,T=l("iframeEmbed"),q=l("youTubeEmbed"),A=l("image"),X=T&&k||q&&V;if(useEffect(()=>{if(!e)return;let M=B=>{let ie=B.target;ie&&(s.current?.contains(ie)||r?.());};return document.addEventListener("mousedown",M,true),document.addEventListener("touchstart",M,true),()=>{document.removeEventListener("mousedown",M,true),document.removeEventListener("touchstart",M,true);}},[e,r]),useEffect(()=>{if(!e||!k)return;let M=false;return typeof o.getIframeEmbedCaption=="function"&&o.getIframeEmbedCaption().then(B=>{M||C(B??"");}),typeof o.getIframeEmbedUrl=="function"&&o.getIframeEmbedUrl().then(B=>{M||m(B??"");}),R(null),()=>{M=true;}},[o,k,e]),useEffect(()=>{if(!e||!n.imageSelected)return;let M=false;return typeof o.getImageCaption=="function"&&o.getImageCaption().then(B=>{M||f(B??"");}),()=>{M=true;}},[n.imageSelected,o,e]),useEffect(()=>{if(!e||!V)return;let M=false;return typeof o.getYouTubeEmbedCaption=="function"&&o.getYouTubeEmbedCaption().then(B=>{M||h(B??"");}),typeof o.getYouTubeEmbedUrl=="function"&&o.getYouTubeEmbedUrl().then(B=>{M||x(B??"");}),ee(null),()=>{M=true;}},[o,e,V]),useEffect(()=>{if(!e||!n.isLink)return;let M=false;return typeof o.getCurrentLink=="function"&&o.getCurrentLink().then(B=>{!M&&B&&J(B.url??"");}),te(null),()=>{M=true;}},[n.isLink,o,e]),!e||!t)return null;let G={...It(),position:"absolute",top:t.y,left:t.positionFromRight?"auto":t.x,right:t.positionFromRight?10:"auto",zIndex:"var(--luthor-z-menu, 460)",pointerEvents:"auto"};if(X){let M=Y=>{if(k){o.setIframeEmbedAlignment?.(Y);return}V&&o.setYouTubeEmbedAlignment?.(Y);},B=k?n.isIframeEmbedAlignedLeft:n.isYouTubeEmbedAlignedLeft,ie=k?n.isIframeEmbedAlignedCenter:n.isYouTubeEmbedAlignedCenter,Ye=k?n.isIframeEmbedAlignedRight:n.isYouTubeEmbedAlignedRight,ne=k?typeof o.setIframeEmbedCaption=="function":typeof o.setYouTubeEmbedCaption=="function",he=k?typeof o.updateIframeEmbedUrl=="function":typeof o.updateYouTubeEmbedUrl=="function",st=k?E:p,Me=k?C:h,Ee=k?u:v,Be=k?$:re,De=()=>{if(ne){if(k){o.setIframeEmbedCaption?.(E);return}o.setYouTubeEmbedCaption?.(p);}},xe=Y=>{k?R(Y):ee(Y);},fe=Y=>{k?m(Y):x(Y);},He=()=>{if(!he)return;if(!(k?o.updateIframeEmbedUrl?.(u)??false:o.updateYouTubeEmbedUrl?.(v)??false)){xe(k?"Enter a valid http(s) URL":"Enter a valid YouTube URL"),k&&typeof o.getIframeEmbedUrl=="function"?o.getIframeEmbedUrl().then(pe=>m(pe??"")):!k&&typeof o.getYouTubeEmbedUrl=="function"&&o.getYouTubeEmbedUrl().then(pe=>x(pe??""));return}xe(null);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:s,style:G,children:[jsx(N,{onClick:()=>M("left"),active:B,title:"Align Left",children:jsx(Tt,{size:14})}),jsx(N,{onClick:()=>M("center"),active:ie,title:"Align Center",children:jsx(ft,{size:14})}),jsx(N,{onClick:()=>M("right"),active:Ye,title:"Align Right",children:jsx(wt,{size:14})}),ne||he?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-fields",children:[he?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:Ee,className:`luthor-floating-toolbar-input${Be?" is-error":""}`,placeholder:k?"https://example.com/embed":"https://youtube.com/watch?v=...","aria-label":k?"Iframe URL":"YouTube URL","aria-invalid":Be?true:void 0,onChange:Y=>{fe(Y.target.value),Be&&xe(null);},onBlur:He,onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),He());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:He,children:"Update URL"})]}):null,ne?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:st,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":k?"Iframe caption":"YouTube caption",onChange:Y=>Me(Y.target.value),onBlur:De,onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),De());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:De,children:"Update Caption"})]}):null]})]}):null]})}if(A&&n.imageSelected){let M=typeof o.setImageCaption=="function",B=()=>{M&&o.setImageCaption(b);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:s,style:G,children:[jsx(N,{onClick:()=>o.setImageAlignment("left"),active:n.isImageAlignedLeft,title:"Align Left",children:jsx(Tt,{size:14})}),jsx(N,{onClick:()=>o.setImageAlignment("center"),active:n.isImageAlignedCenter,title:"Align Center",children:jsx(ft,{size:14})}),jsx(N,{onClick:()=>o.setImageAlignment("right"),active:n.isImageAlignedRight,title:"Align Right",children:jsx(wt,{size:14})}),M?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:ie=>f(ie.target.value),onBlur:B,onKeyDown:ie=>{ie.key==="Enter"&&(ie.preventDefault(),B());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:B,children:"Update Caption"})]})]}):null]})}let Pe=l("bold"),se=l("italic"),ae=l("underline"),W=l("strikethrough"),ce=l("codeFormat"),me=!!(n.unorderedList||n.orderedList||n.checkList),Oe=l("blockFormat")&&!me,ve=l("link"),$e=l("list")&&!me,ge=Pe||se||ae||W,Ne=ce||Oe||ve,de=$e,qe=!!n.isLink&&typeof o.updateLink=="function"&&typeof o.removeLink=="function",ze=()=>{if(!qe)return;if(!(o.updateLink?.(F)??false)){te("Enter a valid URL"),typeof o.getCurrentLink=="function"&&o.getCurrentLink().then(B=>{J(B?.url??"");});return}te(null);};return !ge&&!Ne&&!de?null:jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:s,style:G,children:[ge?jsxs(Fragment,{children:[Pe?jsx(N,{onClick:()=>o.toggleBold(),active:n.bold,title:"Bold",children:jsx(Jt,{size:14})}):null,se?jsx(N,{onClick:()=>o.toggleItalic(),active:n.italic,title:"Italic",children:jsx(Gt,{size:14})}):null,ae?jsx(N,{onClick:()=>o.toggleUnderline(),active:n.underline,title:"Underline",children:jsx(Wt,{size:14})}):null,W?jsx(N,{onClick:()=>o.toggleStrikethrough(),active:n.strikethrough,title:"Strikethrough",children:jsx(Xt,{size:14})}):null]}):null,ge&&Ne?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,Ne?jsxs(Fragment,{children:[ce?jsx(N,{onClick:()=>o.formatText("code"),active:n.code,title:"Inline Code",children:jsx(Qt,{size:14})}):null,Oe?jsx(N,{onClick:()=>o.toggleQuote(),active:n.isQuote,title:"Quote",children:jsx(no,{size:14})}):null,ve?jsxs(Fragment,{children:[jsx(N,{onClick:()=>n.isLink?o.removeLink():o.insertLink(),active:n.isLink,title:n.isLink?"Remove Link":"Insert Link",children:n.isLink?jsx(ht,{size:14}):jsx(Lt,{size:14})}),qe?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:F,className:`luthor-floating-toolbar-input${L?" is-error":""}`,placeholder:"https://example.com","aria-label":"Link URL","aria-invalid":L?true:void 0,onChange:M=>{J(M.target.value),L&&te(null);},onBlur:ze,onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),ze());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:ze,children:"Update Link"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-danger",onClick:()=>o.removeLink(),"aria-label":"Unlink",children:jsx(ht,{size:13})})]}):null]}):null]}):null,(ge||Ne)&&de?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,de?jsxs(Fragment,{children:[jsx(N,{onClick:()=>o.toggleUnorderedList(),active:n.unorderedList,title:"Bullet List",children:jsx(Zt,{size:14})}),jsx(N,{onClick:()=>o.toggleOrderedList(),active:n.orderedList,title:"Numbered List",children:jsx(to,{size:14})}),jsx(N,{onClick:()=>o.toggleCheckList(),active:n.checkList,title:"Checklist",children:jsx(eo,{size:14})})]}):null]})}var _e={commands:{},activeStates:{},editorTheme:"light",isFeatureEnabled:()=>true};function xo(e,t,o,n=()=>true){_e.commands=e,_e.activeStates=t,_e.editorTheme=o,_e.isFeatureEnabled=n;}function Rn(){let e=Hn,t=new FloatingToolbarExtension;return t.config={...t.config,render:o=>createElement(e,{...o,commands:_e.commands,activeStates:_e.activeStates,editorTheme:_e.editorTheme,isFeatureEnabled:_e.isFeatureEnabled}),getCommands:()=>_e.commands,getActiveStates:()=>_e.activeStates},t}var ui=120,ci=58;function di(e,t=ci){return e.length<=t?e:`${e.slice(0,t-3)}...`}function An(){let e=window.getSelection();return !e||e.rangeCount===0?false:!e.getRangeAt(0).collapsed}function Pn(e,t){if(!(e instanceof Element))return null;let o=e.closest("a");return !(o instanceof HTMLAnchorElement)||!t.contains(o)?null:o}function Dn({editor:e,commands:t,editorTheme:o="light",disabled:n=false}){let i=useRef(null),r=useRef(null),l=useRef(null),s=useRef(null),[u,m]=useState(null),[E,C]=useState(false),[b,f]=useState(""),[p,h]=useState(null),[v,x]=useState(null),[F,J]=useState(null),$=useCallback(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null);},[]),R=useCallback(()=>{$(),m(null),C(false),f(""),h(null),x(null);},[$]),re=useCallback(()=>{$(),s.current=window.setTimeout(()=>{R();},ui);},[$,R]),ee=useCallback((T,q)=>{let A=T.getBoundingClientRect(),X=i.current?.getBoundingClientRect(),G=be({anchorRect:A,overlay:{width:X?.width??340,height:X?.height??48},portalContainer:q,gap:8,margin:10,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});x({top:typeof G.top=="number"?G.top:0,left:typeof G.left=="number"?G.left:0});},[]),L=useCallback((T,q)=>{if(typeof t.getLinkByKey!="function"){m(A=>!A||A.nodeKey!==T?A:{...A,url:q});return}t.getLinkByKey(T).then(A=>{if(!A){R();return}m(X=>!X||X.nodeKey!==T?X:{...X,url:A.url});});},[t,R]);useEffect(()=>{if(!e||n||typeof window>"u"){R(),J(null),r.current=null;return}let T=e.getRootElement();if(!T){R(),J(null),r.current=null;return}let q=T.closest(".luthor-editor-wrapper")??null;J(q),r.current=q;let A=ae=>{let W=Pn(ae.target,T);if(!W)return;if(An()){R();return}$();let ce=resolveLinkNodeKeyFromAnchor(e,W);if(!ce)return;let me=W.getAttribute("href")??W.href;m({nodeKey:ce,url:me,anchorEl:W}),ee(W,r.current),h(null),E||f(me),L(ce,me);},X=ae=>{if(!u)return;let W=ae.relatedTarget;W&&i.current?.contains(W)||Pn(W,T)||re();},G=()=>{An()&&R();},Pe=()=>{m(ae=>{if(!ae)return ae;let W=ae.anchorEl.isConnected&&T.contains(ae.anchorEl)?ae.anchorEl:T.querySelector(`a[data-lexical-node-key="${ae.nodeKey}"]`);return W?(ee(W,r.current),{...ae,anchorEl:W,url:W.getAttribute("href")??W.href}):(R(),null)});},se=()=>{l.current===null&&(l.current=window.requestAnimationFrame(()=>{l.current=null,Pe();}));};return T.addEventListener("mouseover",A),T.addEventListener("mouseout",X),document.addEventListener("selectionchange",G),window.addEventListener("scroll",se,true),window.addEventListener("resize",se),()=>{T.removeEventListener("mouseover",A),T.removeEventListener("mouseout",X),document.removeEventListener("selectionchange",G),window.removeEventListener("scroll",se,true),window.removeEventListener("resize",se),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),$();}},[t,n,e,u,E,R,re,L,ee,$]),useLayoutEffect(()=>{u&&ee(u.anchorEl,r.current);},[u,E,ee]);let te=useMemo(()=>{if(!(!u||!v))return {...Fe(u.anchorEl),position:F?"absolute":"fixed",top:v.top,left:v.left,zIndex:"var(--luthor-z-menu, 460)"}},[u,v,F]);if(!u||!v||typeof document>"u")return null;let k=()=>{(t.removeLinkByKey?.(u.nodeKey)??false)&&R();},V=()=>{let T=b.trim();if(!(t.updateLinkByKey?.(u.nodeKey,T)??false)){h("Enter a valid URL"),L(u.nodeKey,u.url);return}m(A=>!A||A.nodeKey!==u.nodeKey?A:{...A,url:T}),h(null),C(false),queueMicrotask(()=>{L(u.nodeKey,T);});};return createPortal(jsx("div",{ref:i,className:"luthor-floating-toolbar luthor-link-hover-bubble","data-theme":o,style:te,onMouseEnter:$,onMouseLeave:re,children:E?jsxs(Fragment,{children:[jsx("input",{type:"url",value:b,className:`luthor-link-hover-bubble-input${p?" is-error":""}`,placeholder:"https://example.com","aria-label":"Edit link URL","aria-invalid":p?true:void 0,onChange:T=>{f(T.target.value),p&&h(null);},onKeyDown:T=>{if(T.key==="Enter"){T.preventDefault(),V();return}T.key==="Escape"&&(T.preventDefault(),C(false),f(u.url),h(null));}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-primary",onClick:V,children:"Update"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{C(false),f(u.url),h(null);},children:"Cancel"})]}):jsxs(Fragment,{children:[jsx("span",{className:"luthor-link-hover-bubble-url",title:u.url,children:di(u.url)}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{f(u.url),C(true),h(null);},children:"Edit"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-danger",onClick:k,"aria-label":"Unlink",children:jsx(ht,{size:13})})]})}),F??document.body)}function Un({mode:e,onModeChange:t,labels:o,availableModes:n,isConverting:i}){let r=["visual","json","markdown","html"],l=new Set(n??["visual","json","markdown","html"]),s=r.filter(m=>l.has(m)),u={visual:o?.visual??"Visual",json:o?.json??"JSON",markdown:o?.markdown??"Markdown",html:o?.html??"HTML"};return jsx("div",{className:"luthor-mode-tabs",children:s.map(m=>jsxs("button",{className:`luthor-mode-tab ${e===m?"active":""}`,onClick:()=>t(m),children:[u[m],i===m&&jsx("span",{className:"luthor-tab-converting-spinner"})]},m))})}function ao({value:e,onChange:t,placeholder:o,className:n,wrap:i}){let r=useRef(null);return useLayoutEffect(()=>{let l=r.current;if(!l)return;l.style.height="auto";let s=Math.max(l.scrollHeight,280);l.style.height=`${s}px`;},[e]),jsx("textarea",{ref:r,className:`luthor-source-view${n?` ${n}`:""}`,value:e,onChange:l=>t(l.target.value),placeholder:o,spellCheck:false,wrap:i??"off"})}function uo(e){return e.replace(/\r\n?/g,`
1
+ import {ImageExtension,TableExtension,IframeEmbedExtension,YouTubeEmbedExtension,ContextMenuExtension,CommandPaletteExtension,SlashCommandExtension,EmojiExtension,DraggableBlockExtension,LinkExtension,textColorExtension,textHighlightExtension,createCustomNodeExtension,createEditorSystem,mergeThemes,defaultLuthorTheme,createEditorThemeStyleVars,FloatingToolbarExtension,FontFamilyExtension,FontSizeExtension,LineHeightExtension,codeExtension,codeIntelligenceExtension,ListExtension,TabIndentExtension,boldExtension,italicExtension,underlineExtension,strikethroughExtension,subscriptExtension,superscriptExtension,horizontalRuleExtension,historyExtension,blockFormatExtension,codeFormatExtension,enterKeyBehaviorExtension,RichText,clearLexicalSelection,markdownToJSON,htmlToJSON,jsonToMarkdown,jsonToHTML,resolveLinkNodeKeyFromAnchor}from'@lyfie/luthor-headless';import Si,{forwardRef,useState,useRef,useMemo,useEffect,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"],za={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:["customComponent"]},{items:["undo","redo"]},{items:["commandPalette"]},{items:["themeToggle"]}]},qt={sections:[{items:["undo","redo"]},{items:["fontFamily","blockFormat","fontSize","lineHeight"]},{items:["bold","italic","underline","strikethrough","textColor","textHighlight"]},{items:["alignLeft","alignCenter","alignRight","alignJustify"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["link"]},{items:["image","table","code","codeBlock","horizontalRule","quote"]},{items:["subscript","superscript","emoji","embed","customComponent"]},{items:["commandPalette","themeToggle"]}]};function wr(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 Sr(e,t){return wr(e.target)?Go(t):false}function Go(e){let t=e.key.toLowerCase();return !(!!e.ctrlKey||!!e.metaKey)||e.altKey?false:t==="b"||t==="i"||t==="u"||t==="k"}function Jo(e){return typeof e.setCodeLanguage=="function"&&typeof e.autoDetectCodeLanguage=="function"}function xr(e){return typeof e.toggleSubscript=="function"}function Ir(e){return typeof e.toggleSuperscript=="function"}function Fr(e){return typeof e.insertIframeEmbed=="function"}function Or(e){return typeof e.insertYouTubeEmbed=="function"}function Nr(e){return typeof e.insertEmoji=="function"}function Mr(e){return e.slice(1)}function Hr(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 Rr(e){if(!e||e.length===0)return [...Ie];let t=new Set,o=[];for(let n of e)!Ie.includes(n)||t.has(n)||(t.add(n),o.push(n));return o.length>0?o:[...Ie]}function vo(e,t){return Br(Co(t),t?.shortcutConfig).filter(n=>!n.condition||n.condition(e))}function Q(e,t){return typeof e[t]=="function"}function Yt(e){if(!e||e.length===0)return new Set;let t=e.map(o=>o.trim()).filter(o=>o.length>0);return new Set(t)}function Ar(e){if(!e)return {allowlist:new Set,denylist:new Set};if(Array.isArray(e)){let o=[];for(let n of e)for(let[i,r]of Object.entries(n))r&&o.push(i);return {allowlist:Yt(o),denylist:new Set}}let t=e;return {allowlist:Yt(t.allowlist),denylist:Yt(t.denylist)}}function Wo(e){let t=e.key.trim();return t?{key:t,ctrlKey:!!e.ctrlKey,metaKey:!!e.metaKey,shiftKey:!!e.shiftKey,altKey:!!e.altKey,preventDefault:e.preventDefault}:null}function Pr(e){if(e===false||e===null)return [];let t=Array.isArray(e)?e:[e],o=[];for(let n of t){let i=Wo(n);i&&o.push(i);}return o}function zr(e){return [e.key.toLowerCase(),e.ctrlKey?"ctrl":"",e.metaKey?"meta":"",e.shiftKey?"shift":"",e.altKey?"alt":""].join(":")}function Br(e,t){if(!t)return [...e];let o=Yt(t.disabledCommandIds),n=t.bindings,i=t.preventNativeConflicts!==false,r=t.preventCollisions!==false,l=new Set;return e.filter(u=>!o.has(u.id)).map(u=>{let m=u.shortcuts?[...u.shortcuts]:void 0;if(!!n&&Object.prototype.hasOwnProperty.call(n,u.id)&&n){let C=n[u.id],b=C===void 0?[]:Pr(C);m=b.length>0?b:void 0;}if(m&&m.length>0){let C=[];for(let b of m){let f=Wo(b);if(!f||i&&Go(f))continue;let p=zr(f);r&&l.has(p)||(l.add(p),C.push(f));}m=C.length>0?C:void 0;}return {...u,shortcuts:m}})}function Co(e){let t=e?.isFeatureEnabled??(()=>true),o=Rr(e?.headingOptions),n=e?.paragraphLabel?.trim()||"Paragraph",i=o.map(r=>{let l=Mr(r);return {id:`block.heading${l}`,label:`Heading ${l}`,description:Hr(r),category:"Block",action:s=>s.toggleHeading?.(r),shortcuts:[{key:l,ctrlKey:true,altKey:true}],keywords:["heading",r],condition:s=>t("blockFormat")&&Q(s,"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")&&Q(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")&&Q(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")&&Q(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")&&Q(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")&&xr(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")&&Ir(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")&&Q(r,"formatText")},{id:"block.paragraph",label:n,description:"Convert to paragraph",category:"Block",action:r=>r.toggleParagraph?.(),shortcuts:[{key:"0",ctrlKey:true,altKey:true}],keywords:["paragraph","text"],condition:r=>t("blockFormat")&&Q(r,"toggleParagraph")},...i,{id:"block.quote",label:"Quote",description:"Convert to blockquote",category:"Block",action:r=>r.toggleQuote?.(),keywords:["quote","blockquote"],condition:r=>t("blockFormat")&&Q(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")&&Q(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")&&Q(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")&&Q(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")&&Q(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")&&Q(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 l=prompt("Code language (e.g. ts, css, python):")?.trim();l&&r.setCodeLanguage(l);},keywords:["code","language","syntax"],condition:r=>t("codeIntelligence")&&Jo(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")&&Jo(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")&&Q(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")&&Q(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")&&Q(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")&&Q(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")&&Q(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")&&Q(r,"insertHorizontalRule")},{id:"insert.image",label:"Insert Image",description:"Insert an image from URL",category:"Insert",action:r=>{let l=prompt("Enter image URL:");if(l){let s=prompt("Enter alt text:")||"";r.insertImage?.({src:l,alt:s});}},keywords:["image","photo"],condition:r=>t("image")&&Q(r,"insertImage")},{id:"insert.gif",label:"Insert GIF",description:"Insert an animated GIF from URL",category:"Insert",action:r=>{let l=prompt("Enter GIF URL:");l&&r.insertImage?.({src:l,alt:"GIF"});},keywords:["gif","animated","image"],condition:r=>t("image")&&Q(r,"insertImage")},{id:"insert.emoji",label:"Insert Emoji",description:"Insert an emoji character",category:"Insert",action:r=>{let l=prompt("Enter emoji or shortcode (example :sparkles:):")?.trim();if(!l||typeof r.insertEmoji!="function")return;let s=l.match(/^:([a-z0-9_+-]+):$/i);if(s){let u=s[1];if(!u)return;if(typeof r.resolveEmojiShortcode=="function"){let m=r.resolveEmojiShortcode(u);if(m?.emoji){r.insertEmoji(m.emoji);return}}else if(typeof r.getEmojiSuggestions=="function"){let[m]=r.getEmojiSuggestions(u);if(m?.emoji){r.insertEmoji(m.emoji);return}}}r.insertEmoji(l);},keywords:["emoji","reaction","symbol","smile"],condition:r=>t("emoji")&&Nr(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")&&Q(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 l=prompt("Enter iframe URL:");l&&r.insertIframeEmbed(l);},keywords:["iframe","embed","url"],condition:r=>t("iframeEmbed")&&Fr(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 l=prompt("Enter YouTube URL:");l&&r.insertYouTubeEmbed(l);},keywords:["youtube","video","embed"],condition:r=>t("youTubeEmbed")&&Or(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")&&Q(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")&&Q(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")&&Q(r,"showCommandPalette")}]}function Xo(e,t){let o=t?.commandPaletteShortcutOnly===true;return vo(e,t).filter(n=>!o||!!n.shortcuts&&n.shortcuts.length>0).map(n=>({id:n.id,label:n.label,description:n.description,category:n.category,action:()=>n.action(e),keywords:n.keywords,shortcut:n.shortcuts?.[0]?Zo(n.shortcuts[0]):void 0}))}function Qo(e,t){let o=new Set(["block.paragraph","block.quote","block.codeblock"]),n=s=>s.category==="Insert"||s.category==="List"?true:s.category==="Block"?s.id.startsWith("block.heading")?true:o.has(s.id):false,{allowlist:i,denylist:r}=Ar(t?.slashCommandVisibility),l=i.size>0;return vo(e,t).filter(s=>r.has(s.id)?false:l?i.has(s.id):n(s)).map(s=>({id:s.id,label:s.label,description:s.description,category:s.category,action:()=>s.action(e),keywords:s.keywords,shortcut:s.shortcuts?.[0]?Zo(s.shortcuts[0]):void 0}))}function Zo(e){let t=[];return e.ctrlKey&&t.push("Ctrl"),e.metaKey&&t.push("Cmd"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),t.push(e.key.toUpperCase()),t.join("+")}function en(e,t=document.body,o){let n=vo(e,o),i=(l,s)=>l.key.toLowerCase()===s.key.toLowerCase()||s.key==="`"&&l.code==="Backquote",r=l=>{let s=typeof o?.scope=="function"?o.scope():o?.scope;if(!(s&&l.target instanceof Node&&!s.contains(l.target))){for(let u of n)if(u.shortcuts){for(let m of u.shortcuts)if(!(o?.shortcutConfig?.preventNativeConflicts!==false&&Sr(l,m))&&i(l,m)&&!!l.ctrlKey==!!m.ctrlKey&&!!l.metaKey==!!m.metaKey&&!!l.shiftKey==!!m.shiftKey&&!!l.altKey==!!m.altKey){m.preventDefault!==false&&l.preventDefault(),(!u.condition||u.condition(e))&&u.action(e);return}}}};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)}function H(e,t){let o=forwardRef(function({size:i=24,strokeWidth:r=2,...l},s){return jsx("svg",{ref:s,xmlns:"http://www.w3.org/2000/svg",width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...l,children:t})});return o.displayName=e,o}var Jt=H("BoldIcon",jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})),Gt=H("ItalicIcon",jsxs(Fragment,{children:[jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})),Wt=H("UnderlineIcon",jsxs(Fragment,{children:[jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})),Xt=H("StrikethroughIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})),Qt=H("CodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"m16 18 6-6-6-6"}),jsx("path",{d:"m8 6-6 6 6 6"})]})),tn=H("CodeBlockIcon",jsxs(Fragment,{children:[jsx("path",{d:"m10 9-3 3 3 3"}),jsx("path",{d:"m14 15 3-3-3-3"}),jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})]})),Lt=H("LinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})),ht=H("UnlinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"}),jsx("path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"}),jsx("line",{x1:"8",x2:"8",y1:"2",y2:"5"}),jsx("line",{x1:"2",x2:"5",y1:"8",y2:"8"}),jsx("line",{x1:"16",x2:"16",y1:"19",y2:"22"}),jsx("line",{x1:"19",x2:"22",y1:"16",y2:"16"})]})),Zt=H("ListIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h.01"}),jsx("path",{d:"M3 12h.01"}),jsx("path",{d:"M3 19h.01"}),jsx("path",{d:"M8 5h13"}),jsx("path",{d:"M8 12h13"}),jsx("path",{d:"M8 19h13"})]})),eo=H("ListCheckIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 5H3"}),jsx("path",{d:"M16 12H3"}),jsx("path",{d:"M11 19H3"}),jsx("path",{d:"m15 18 2 2 4-4"})]})),to=H("ListOrderedIcon",jsxs(Fragment,{children:[jsx("path",{d:"M11 5h10"}),jsx("path",{d:"M11 12h10"}),jsx("path",{d:"M11 19h10"}),jsx("path",{d:"M4 4h1v5"}),jsx("path",{d:"M4 9h2"}),jsx("path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02"})]})),on=H("UndoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 7v6h6"}),jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})),nn=H("RedoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 7v6h-6"}),jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})]})),ko=H("ImageIcon",jsxs(Fragment,{children:[jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),jsx("circle",{cx:"9",cy:"9",r:"2"}),jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})),Tt=H("AlignLeftIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M15 12H3"}),jsx("path",{d:"M17 19H3"})]})),ft=H("AlignCenterIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M17 12H7"}),jsx("path",{d:"M19 19H5"})]})),rn=H("AlignJustifyIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h18"}),jsx("path",{d:"M3 12h18"}),jsx("path",{d:"M3 19h18"})]})),wt=H("AlignRightIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M21 12H9"}),jsx("path",{d:"M21 19H7"})]})),Eo=H("UploadIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 3v12"}),jsx("path",{d:"m17 8-5-5-5 5"}),jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})),ln=H("MinusIcon",jsx("path",{d:"M5 12h14"})),an=H("TableIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 3v18"}),jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),jsx("path",{d:"M3 9h18"}),jsx("path",{d:"M3 15h18"})]})),sn=H("FileCodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}),jsx("path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}),jsx("path",{d:"M10 12.5 8 15l2 2.5"}),jsx("path",{d:"m14 12.5 2 2.5-2 2.5"})]})),Va=H("EyeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),jsx("circle",{cx:"12",cy:"12",r:"3"})]})),un=H("HighlighterIcon",jsxs(Fragment,{children:[jsx("path",{d:"m9 11-6 6v3h9l3-3"}),jsx("path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"})]})),_a=H("PencilIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),jsx("path",{d:"m15 5 4 4"})]})),oo=H("CommandIcon",jsx("path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3"})),cn=H("PaletteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"}),jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"})]})),dn=H("TypeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 4v16"}),jsx("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),jsx("path",{d:"M9 20h6"})]})),no=H("QuoteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"}),jsx("path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"})]})),mn=H("IndentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H11"}),jsx("path",{d:"M21 12H11"}),jsx("path",{d:"M21 19H11"}),jsx("path",{d:"m3 8 4 4-4 4"})]})),gn=H("OutdentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H11"}),jsx("path",{d:"M21 12H11"}),jsx("path",{d:"M21 19H11"}),jsx("path",{d:"m7 8-4 4 4 4"})]})),hn=H("SunIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v2"}),jsx("path",{d:"M12 20v2"}),jsx("path",{d:"m4.93 4.93 1.41 1.41"}),jsx("path",{d:"m17.66 17.66 1.41 1.41"}),jsx("path",{d:"M2 12h2"}),jsx("path",{d:"M20 12h2"}),jsx("path",{d:"m6.34 17.66-1.41 1.41"}),jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})),fn=H("MoonIcon",jsx("path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"})),pn=H("SearchIcon",jsxs(Fragment,{children:[jsx("path",{d:"m21 21-4.34-4.34"}),jsx("circle",{cx:"11",cy:"11",r:"8"})]})),Lo=H("EmojiIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),jsx("line",{x1:"9",x2:"9.01",y1:"9",y2:"9"}),jsx("line",{x1:"15",x2:"15.01",y1:"9",y2:"9"})]})),bn=H("SubscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 5 8 8"}),jsx("path",{d:"m12 5-8 8"}),jsx("path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})),yn=H("SuperscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 19 8-8"}),jsx("path",{d:"m12 19-8-8"}),jsx("path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06"})]})),St=H("ChevronDownIcon",jsx("path",{d:"m6 9 6 6 6-6"})),vn=H("CloseIcon",jsxs(Fragment,{children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));function En({isOpen:e,onClose:t,commands:o}){let[n,i]=useState(""),[r,l]=useState(0),s=useRef(null),u=useRef(null),m=o.filter(b=>`${b.label} ${b.description||""} ${b.keywords?.join(" ")||""}`.toLowerCase().includes(n.toLowerCase())),E=m.reduce((b,f)=>{let p=f.category||"Other";return b[p]||(b[p]=[]),b[p].push(f),b},{}),C=m;return useEffect(()=>{l(0);},[n]),useEffect(()=>{e&&s.current&&(s.current.focus({preventScroll:true}),i(""),l(0));},[e]),useEffect(()=>{if(!e)return;let b=u.current;if(!b)return;b.querySelector(".luthor-command-palette-item.selected")?.scrollIntoView({block:"nearest"});},[e,r,n]),useEffect(()=>{let b=f=>{if(e)switch(f.key){case "Escape":f.preventDefault(),f.stopPropagation(),t();break;case "ArrowDown":f.preventDefault(),f.stopPropagation(),l(p=>Math.min(p+1,C.length-1));break;case "ArrowUp":f.preventDefault(),f.stopPropagation(),l(p=>Math.max(p-1,0));break;case "Enter":f.preventDefault(),f.stopPropagation(),C[r]&&(C[r].action(),t());break}};return document.addEventListener("keydown",b,true),()=>document.removeEventListener("keydown",b,true)},[e,r,C,t]),e?jsx("div",{className:"luthor-command-palette-overlay",onClick:t,children:jsxs("div",{className:"luthor-command-palette",role:"dialog","aria-modal":"true","aria-label":"Command Palette",onClick:b=>b.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(pn,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:s,type:"text",placeholder:"Type a command or search...",value:n,onChange:b=>i(b.target.value),className:"luthor-command-palette-input"}),jsx("kbd",{className:"luthor-command-palette-kbd",children:"ESC"})]}),jsx("div",{ref:u,className:"luthor-command-palette-list",children:Object.keys(E).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(E).map(([b,f])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:b}),f.map(p=>{let h=C.indexOf(p);return jsxs("div",{className:`luthor-command-palette-item ${h===r?"selected":""}`,onClick:()=>{p.action(),t();},onMouseEnter:()=>l(h),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(oo,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var Ur={"--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":"#000000","--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 Kr(e){return e?e.closest(".luthor-editor-wrapper"):null}function Vr(e){return e?Kr(e)??e:null}function _r(e){if(typeof window>"u"||!e)return {};let t=window.getComputedStyle(e),o={};for(let[n,i]of Object.entries(Ur)){let r=t.getPropertyValue(n).trim()||i;o[n]=r;}return o}function Fe(e){return _r(Vr(e))}function It(){if(typeof window>"u")return {};let t=window.getSelection()?.anchorNode;if(!t)return {};let o=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return Fe(o)}function pt(e){return e?e.closest(".luthor-editor-wrapper")??null:null}function Ln(e,t,o){return e<t?t:e>o?o:e}function jr(e){if(!e||typeof window>"u"){let o=typeof window>"u"?0:window.innerWidth,n=typeof window>"u"?0:window.innerHeight;return {left:0,top:0,right:o,bottom:n}}let t=e.getBoundingClientRect();return {left:t.left,top:t.top,right:t.right,bottom:t.bottom}}function $r(e,t,o,n,i,r){let l=i==="end"?e.right-t:i==="center"?e.left+e.width/2-t/2:e.left,s=i==="end"?e.left:i==="center"?e.left+e.width/2-t/2:e.right-t,u=l,m=o.left+n,E=Math.max(m,o.right-t-n);if(r){let C=u<m||u>E,b=s>=m&&s<=E;C&&b&&(u=s);}return Ln(u,m,E)}function qr(e,t,o,n,i,r,l){let s=r==="top"?e.top-t-n:e.bottom+n,u=r==="top"?e.bottom+n:e.top-t-n,m=s,E=o.top+i,C=Math.max(E,o.bottom-t-i);if(l){let b=m<E||m>C,f=u>=E&&u<=C;b&&f&&(m=u);}return Ln(m,E,C)}function be({anchorRect:e,overlay:t,portalContainer:o=null,gap:n=4,margin:i=8,preferredX:r="start",preferredY:l="bottom",flipX:s=true,flipY:u=true}){let m=jr(o),E=Math.max(0,t.width),C=Math.max(0,t.height),b=$r(e,E,m,i,r,s),f=qr(e,C,m,n,i,l,u);if(o){let p=o.getBoundingClientRect();return {position:"absolute",left:b-p.left,top:f-p.top}}return {position:"fixed",left:b,top:f}}function io(e,t){return {x:e,y:t,width:1,height:1,left:e,right:e+1,top:t,bottom:t+1,toJSON:()=>({})}}function wn({isOpen:e,query:t,position:o,portalContainer:n,suggestions:i,onClose:r,onExecute:l}){let[s,u]=useState(0),m=useRef(null),[E,C]=useState(void 0);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let p=h=>{let v=i.length>0;switch(h.key){case "Escape":h.preventDefault(),h.stopPropagation(),r();break;case "ArrowDown":if(!v)return;h.preventDefault(),h.stopPropagation(),u(x=>Math.min(x+1,Math.max(i.length-1,0)));break;case "ArrowUp":if(!v)return;h.preventDefault(),h.stopPropagation(),u(x=>Math.max(x-1,0));break;case "Enter":case "Tab":if(!v||!i[s])return;h.preventDefault(),h.stopPropagation(),l(i[s].emoji);break}};return document.addEventListener("keydown",p,true),()=>document.removeEventListener("keydown",p,true)},[e,r,l,s,i]);let b=useCallback(p=>{if(!o)return;let h=m.current?.getBoundingClientRect(),v=be({anchorRect:io(o.x,o.y),overlay:{width:h?.width??320,height:h?.height??280},portalContainer:n??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});C({...v,visibility:p?"visible":"hidden",...It()});},[n,o]);if(useLayoutEffect(()=>{if(!e||!o)return;b(false);let p=window.requestAnimationFrame(()=>b(true));return ()=>window.cancelAnimationFrame(p)},[e,o,b]),useEffect(()=>{if(!e||!o)return;let p=()=>b(true);return window.addEventListener("resize",p),window.addEventListener("scroll",p,true),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,true);}},[e,o,b]),!e||!o)return null;let f=jsxs("div",{className:"luthor-emoji-menu",ref:m,style:E,onPointerDown:p=>{p.stopPropagation();},onMouseDown:p=>{p.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:i.length===0?jsx("div",{className:"luthor-emoji-menu-empty",children:"No matching emoji"}):i.map((p,h)=>{let v=h===s,x=p.shortcodes[0]?`:${p.shortcodes[0]}:`:"";return jsxs("button",{type:"button",className:`luthor-emoji-menu-item ${v?"selected":""}`,onMouseEnter:()=>u(h),onMouseDown:F=>{F.preventDefault(),F.stopPropagation();},onClick:F=>{F.preventDefault(),F.stopPropagation(),l(p.emoji);},children:[jsx("span",{className:"luthor-emoji-menu-item-symbol","aria-hidden":"true",children:p.emoji}),jsxs("span",{className:"luthor-emoji-menu-item-content",children:[jsx("span",{className:"luthor-emoji-menu-item-title",children:p.label}),x&&jsx("span",{className:"luthor-emoji-menu-item-shortcode",children:x})]})]},`${p.emoji}-${p.label}`)})})]});return typeof document>"u"?f:createPortal(f,n??document.body)}function In({isOpen:e,query:t,position:o,portalContainer:n,commands:i,onClose:r,onExecute:l}){let[s,u]=useState(0),m=useRef(null),[E,C]=useState(void 0),b=useMemo(()=>{let v=t.trim().toLowerCase();return v?i.filter(x=>`${x.label} ${x.description||""} ${x.keywords?.join(" ")||""}`.toLowerCase().includes(v)):i},[i,t]),f=useMemo(()=>b.reduce((v,x)=>{let F=x.category||"Other";return v[F]||(v[F]=[]),v[F].push(x),v},{}),[b]);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let v=x=>{let F=b.length>0;switch(x.key){case "Escape":x.preventDefault(),x.stopPropagation(),r();break;case "ArrowDown":if(!F)return;x.preventDefault(),x.stopPropagation(),u(J=>Math.min(J+1,Math.max(b.length-1,0)));break;case "ArrowUp":if(!F)return;x.preventDefault(),x.stopPropagation(),u(J=>Math.max(J-1,0));break;case "Enter":case "Tab":if(!F||!b[s])return;x.preventDefault(),x.stopPropagation(),l(b[s].id);break}};return document.addEventListener("keydown",v,true),()=>document.removeEventListener("keydown",v,true)},[b,e,r,l,s]);let p=useCallback(v=>{if(!o)return;let x=m.current?.getBoundingClientRect(),F=be({anchorRect:io(o.x,o.y),overlay:{width:x?.width??420,height:x?.height??360},portalContainer:n??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});C({...F,visibility:v?"visible":"hidden",...It()});},[n,o]);if(useLayoutEffect(()=>{if(!e||!o)return;p(false);let v=window.requestAnimationFrame(()=>p(true));return ()=>window.cancelAnimationFrame(v)},[e,o,p]),useEffect(()=>{if(!e||!o)return;let v=()=>p(true);return window.addEventListener("resize",v),window.addEventListener("scroll",v,true),()=>{window.removeEventListener("resize",v),window.removeEventListener("scroll",v,true);}},[e,o,p]),!e||!o)return null;let h=jsxs("div",{className:"luthor-slash-menu",ref:m,style:E,onPointerDown:v=>{v.stopPropagation();},onMouseDown:v=>{v.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:b.length===0?jsx("div",{className:"luthor-slash-menu-empty",children:"No matching commands"}):Object.entries(f).map(([v,x])=>jsxs("div",{className:"luthor-slash-menu-group",children:[jsx("div",{className:"luthor-slash-menu-group-title",children:v}),x.map(F=>{let J=b.indexOf(F);return jsxs("button",{type:"button",className:`luthor-slash-menu-item ${J===s?"selected":""}`,onMouseEnter:()=>u(J),onMouseDown:R=>{R.preventDefault(),R.stopPropagation();},onClick:R=>{R.preventDefault(),R.stopPropagation(),l(F.id);},children:[jsxs("span",{className:"luthor-slash-menu-item-content",children:[jsx("span",{className:"luthor-slash-menu-item-title",children:F.label}),F.description&&jsx("span",{className:"luthor-slash-menu-item-description",children:F.description})]}),F.shortcut&&jsx("kbd",{className:"luthor-slash-menu-item-shortcut",children:F.shortcut})]},F.id)})]},v))})]});return typeof document>"u"?h:createPortal(h,n??document.body)}function N({children:e,onClick:t,title:o,active:n,disabled:i,className:r,type:l="button"}){return jsx("button",{type:l,className:`luthor-toolbar-button${n?" active":""}${r?` ${r}`:""}`,onClick:t,title:o,disabled:i,children:e})}function So({children:e,onClick:t,variant:o="primary",type:n="button",className:i}){return jsx("button",{type:n,onClick:t,className:`${o==="primary"?"luthor-button-primary":"luthor-button-secondary"}${i?` ${i}`:""}`,children:e})}function Dt({value:e,onValueChange:t,options:o,placeholder:n="Select..."}){let[i,r]=useState(false),[l,s]=useState(void 0),[u,m]=useState(null),E=useRef(null),C=useRef(null);useEffect(()=>{if(!i)return;let f=()=>{let h=E.current?.querySelector(".luthor-select-trigger");if(!h)return;let v=h.getBoundingClientRect(),x=C.current?.getBoundingClientRect(),F=pt(h);m(F);let J=Math.max(v.width,x?.width??0),$=x?.height??220,R=be({anchorRect:v,overlay:{width:J,height:$},portalContainer:F,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});s({...R,width:v.width,...Fe(h)});},p=()=>f();return window.addEventListener("resize",p),window.addEventListener("scroll",p,true),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,true),m(null);}},[i]),useLayoutEffect(()=>{if(!i)return;let f=E.current?.querySelector(".luthor-select-trigger");if(!f)return;let p=f.getBoundingClientRect(),h=pt(f);m(h);let v=be({anchorRect:p,overlay:{width:p.width,height:220},portalContainer:h,gap:4,margin:8});s({...v,width:p.width,...Fe(f)});let x=window.requestAnimationFrame(()=>{let F=C.current?.getBoundingClientRect(),J=be({anchorRect:p,overlay:{width:Math.max(p.width,F?.width??0),height:F?.height??220},portalContainer:h,gap:4,margin:8});s({...J,width:p.width,...Fe(f)});});return ()=>window.cancelAnimationFrame(x)},[i]),useEffect(()=>{function f(p){let h=p.target;E.current?.contains(h)||C.current?.contains(h)||r(false);}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);let b=o.find(f=>f.value===e);return jsxs("div",{className:"luthor-select",ref:E,children:[jsxs("button",{className:`luthor-select-trigger ${i?"open":""}`,onClick:()=>r(!i),type:"button",children:[jsx("span",{children:b?.label||n}),jsx(St,{size:14})]}),i&&typeof document<"u"&&createPortal(jsx("div",{ref:C,className:"luthor-select-dropdown",style:l,children:o.map(f=>jsx("button",{className:`luthor-select-option ${e===f.value?"selected":""}`,onClick:()=>{t(f.value),r(false);},type:"button",children:f.label},f.value))}),u??document.body)]})}function rt({trigger:e,children:t,isOpen:o,onOpenChange:n}){let i=useRef(null),r=useRef(null),l=useRef(null),[s,u]=useState(void 0),[m,E]=useState(null);return useEffect(()=>{if(!o)return;let C=()=>{let f=r.current;if(!f)return;let p=f.getBoundingClientRect(),h=l.current?.getBoundingClientRect(),v=pt(f);E(v);let x=be({anchorRect:p,overlay:{width:h?.width??220,height:h?.height??200},portalContainer:v,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});u({...x,...Fe(f)});},b=()=>C();return window.addEventListener("resize",b),window.addEventListener("scroll",b,true),()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,true),E(null);}},[o]),useLayoutEffect(()=>{if(!o)return;let C=r.current;if(!C)return;let b=C.getBoundingClientRect(),f=pt(C);E(f);let p=be({anchorRect:b,overlay:{width:220,height:200},portalContainer:f,gap:4,margin:8});u({...p,...Fe(C)});let h=window.requestAnimationFrame(()=>{let v=l.current?.getBoundingClientRect(),x=be({anchorRect:b,overlay:{width:v?.width??220,height:v?.height??200},portalContainer:f,gap:4,margin:8});u({...x,...Fe(C)});});return ()=>window.cancelAnimationFrame(h)},[o]),useEffect(()=>{function C(b){let f=b.target;i.current?.contains(f)||l.current?.contains(f)||n(false);}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[n]),jsxs("div",{className:"luthor-dropdown",ref:i,children:[jsx("div",{ref:r,onClick:()=>n(!o),children:e}),o&&typeof document<"u"&&createPortal(jsx("div",{ref:l,className:"luthor-dropdown-content",style:s,children:t}),m??document.body)]})}function Nn({isOpen:e,onClose:t,title:o,children:n}){let i=useRef(null);return useEffect(()=>{function r(s){i.current&&!i.current.contains(s.target)&&t();}function l(s){s.key==="Escape"&&t();}return e&&(document.addEventListener("mousedown",r),document.addEventListener("keydown",l)),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",l);}},[e,t]),e?jsx("div",{className:"luthor-dialog-overlay",children:jsxs("div",{className:"luthor-dialog",ref:i,children:[jsxs("div",{className:"luthor-dialog-header",children:[jsx("h3",{className:"luthor-dialog-title",children:o}),jsx("button",{className:"luthor-dialog-close",onClick:t,type:"button",children:jsx(vn,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:n})]})}):null}function Mn({isVisible:e,selectionRect:t,commands:o,activeStates:n,editorTheme:i="light",hide:r,isFeatureEnabled:l=()=>true}){let s=useRef(null),[u,m]=useState(""),[E,C]=useState(""),[b,f]=useState(""),[p,h]=useState(""),[v,x]=useState(""),[F,J]=useState(""),[$,R]=useState(null),[re,ee]=useState(null),[L,te]=useState(null),k=!!n.isIframeEmbedSelected,V=!!n.isYouTubeEmbedSelected,T=l("iframeEmbed"),q=l("youTubeEmbed"),A=l("image"),X=T&&k||q&&V;if(useEffect(()=>{if(!e)return;let M=B=>{let ie=B.target;ie&&(s.current?.contains(ie)||r?.());};return document.addEventListener("mousedown",M,true),document.addEventListener("touchstart",M,true),()=>{document.removeEventListener("mousedown",M,true),document.removeEventListener("touchstart",M,true);}},[e,r]),useEffect(()=>{if(!e||!k)return;let M=false;return typeof o.getIframeEmbedCaption=="function"&&o.getIframeEmbedCaption().then(B=>{M||C(B??"");}),typeof o.getIframeEmbedUrl=="function"&&o.getIframeEmbedUrl().then(B=>{M||m(B??"");}),R(null),()=>{M=true;}},[o,k,e]),useEffect(()=>{if(!e||!n.imageSelected)return;let M=false;return typeof o.getImageCaption=="function"&&o.getImageCaption().then(B=>{M||f(B??"");}),()=>{M=true;}},[n.imageSelected,o,e]),useEffect(()=>{if(!e||!V)return;let M=false;return typeof o.getYouTubeEmbedCaption=="function"&&o.getYouTubeEmbedCaption().then(B=>{M||h(B??"");}),typeof o.getYouTubeEmbedUrl=="function"&&o.getYouTubeEmbedUrl().then(B=>{M||x(B??"");}),ee(null),()=>{M=true;}},[o,e,V]),useEffect(()=>{if(!e||!n.isLink)return;let M=false;return typeof o.getCurrentLink=="function"&&o.getCurrentLink().then(B=>{!M&&B&&J(B.url??"");}),te(null),()=>{M=true;}},[n.isLink,o,e]),!e||!t)return null;let G={...It(),position:"absolute",top:t.y,left:t.positionFromRight?"auto":t.x,right:t.positionFromRight?10:"auto",zIndex:"var(--luthor-z-menu, 460)",pointerEvents:"auto"};if(X){let M=Y=>{if(k){o.setIframeEmbedAlignment?.(Y);return}V&&o.setYouTubeEmbedAlignment?.(Y);},B=k?n.isIframeEmbedAlignedLeft:n.isYouTubeEmbedAlignedLeft,ie=k?n.isIframeEmbedAlignedCenter:n.isYouTubeEmbedAlignedCenter,Ye=k?n.isIframeEmbedAlignedRight:n.isYouTubeEmbedAlignedRight,ne=k?typeof o.setIframeEmbedCaption=="function":typeof o.setYouTubeEmbedCaption=="function",he=k?typeof o.updateIframeEmbedUrl=="function":typeof o.updateYouTubeEmbedUrl=="function",st=k?E:p,Me=k?C:h,Ee=k?u:v,Be=k?$:re,De=()=>{if(ne){if(k){o.setIframeEmbedCaption?.(E);return}o.setYouTubeEmbedCaption?.(p);}},xe=Y=>{k?R(Y):ee(Y);},fe=Y=>{k?m(Y):x(Y);},He=()=>{if(!he)return;if(!(k?o.updateIframeEmbedUrl?.(u)??false:o.updateYouTubeEmbedUrl?.(v)??false)){xe(k?"Enter a valid http(s) URL":"Enter a valid YouTube URL"),k&&typeof o.getIframeEmbedUrl=="function"?o.getIframeEmbedUrl().then(pe=>m(pe??"")):!k&&typeof o.getYouTubeEmbedUrl=="function"&&o.getYouTubeEmbedUrl().then(pe=>x(pe??""));return}xe(null);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:s,style:G,children:[jsx(N,{onClick:()=>M("left"),active:B,title:"Align Left",children:jsx(Tt,{size:14})}),jsx(N,{onClick:()=>M("center"),active:ie,title:"Align Center",children:jsx(ft,{size:14})}),jsx(N,{onClick:()=>M("right"),active:Ye,title:"Align Right",children:jsx(wt,{size:14})}),ne||he?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-fields",children:[he?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:Ee,className:`luthor-floating-toolbar-input${Be?" is-error":""}`,placeholder:k?"https://example.com/embed":"https://youtube.com/watch?v=...","aria-label":k?"Iframe URL":"YouTube URL","aria-invalid":Be?true:void 0,onChange:Y=>{fe(Y.target.value),Be&&xe(null);},onBlur:He,onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),He());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:He,children:"Update URL"})]}):null,ne?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:st,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":k?"Iframe caption":"YouTube caption",onChange:Y=>Me(Y.target.value),onBlur:De,onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),De());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:De,children:"Update Caption"})]}):null]})]}):null]})}if(A&&n.imageSelected){let M=typeof o.setImageCaption=="function",B=()=>{M&&o.setImageCaption(b);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:s,style:G,children:[jsx(N,{onClick:()=>o.setImageAlignment("left"),active:n.isImageAlignedLeft,title:"Align Left",children:jsx(Tt,{size:14})}),jsx(N,{onClick:()=>o.setImageAlignment("center"),active:n.isImageAlignedCenter,title:"Align Center",children:jsx(ft,{size:14})}),jsx(N,{onClick:()=>o.setImageAlignment("right"),active:n.isImageAlignedRight,title:"Align Right",children:jsx(wt,{size:14})}),M?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:ie=>f(ie.target.value),onBlur:B,onKeyDown:ie=>{ie.key==="Enter"&&(ie.preventDefault(),B());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:B,children:"Update Caption"})]})]}):null]})}let Pe=l("bold"),se=l("italic"),ae=l("underline"),W=l("strikethrough"),ce=l("codeFormat"),me=!!(n.unorderedList||n.orderedList||n.checkList),Oe=l("blockFormat")&&!me,ve=l("link"),$e=l("list")&&!me,ge=Pe||se||ae||W,Ne=ce||Oe||ve,de=$e,qe=!!n.isLink&&typeof o.updateLink=="function"&&typeof o.removeLink=="function",ze=()=>{if(!qe)return;if(!(o.updateLink?.(F)??false)){te("Enter a valid URL"),typeof o.getCurrentLink=="function"&&o.getCurrentLink().then(B=>{J(B?.url??"");});return}te(null);};return !ge&&!Ne&&!de?null:jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:s,style:G,children:[ge?jsxs(Fragment,{children:[Pe?jsx(N,{onClick:()=>o.toggleBold(),active:n.bold,title:"Bold",children:jsx(Jt,{size:14})}):null,se?jsx(N,{onClick:()=>o.toggleItalic(),active:n.italic,title:"Italic",children:jsx(Gt,{size:14})}):null,ae?jsx(N,{onClick:()=>o.toggleUnderline(),active:n.underline,title:"Underline",children:jsx(Wt,{size:14})}):null,W?jsx(N,{onClick:()=>o.toggleStrikethrough(),active:n.strikethrough,title:"Strikethrough",children:jsx(Xt,{size:14})}):null]}):null,ge&&Ne?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,Ne?jsxs(Fragment,{children:[ce?jsx(N,{onClick:()=>o.formatText("code"),active:n.code,title:"Inline Code",children:jsx(Qt,{size:14})}):null,Oe?jsx(N,{onClick:()=>o.toggleQuote(),active:n.isQuote,title:"Quote",children:jsx(no,{size:14})}):null,ve?jsxs(Fragment,{children:[jsx(N,{onClick:()=>n.isLink?o.removeLink():o.insertLink(),active:n.isLink,title:n.isLink?"Remove Link":"Insert Link",children:n.isLink?jsx(ht,{size:14}):jsx(Lt,{size:14})}),qe?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:F,className:`luthor-floating-toolbar-input${L?" is-error":""}`,placeholder:"https://example.com","aria-label":"Link URL","aria-invalid":L?true:void 0,onChange:M=>{J(M.target.value),L&&te(null);},onBlur:ze,onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),ze());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:ze,children:"Update Link"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-danger",onClick:()=>o.removeLink(),"aria-label":"Unlink",children:jsx(ht,{size:13})})]}):null]}):null]}):null,(ge||Ne)&&de?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,de?jsxs(Fragment,{children:[jsx(N,{onClick:()=>o.toggleUnorderedList(),active:n.unorderedList,title:"Bullet List",children:jsx(Zt,{size:14})}),jsx(N,{onClick:()=>o.toggleOrderedList(),active:n.orderedList,title:"Numbered List",children:jsx(to,{size:14})}),jsx(N,{onClick:()=>o.toggleCheckList(),active:n.checkList,title:"Checklist",children:jsx(eo,{size:14})})]}):null]})}var _e={commands:{},activeStates:{},editorTheme:"light",isFeatureEnabled:()=>true};function xo(e,t,o,n=()=>true){_e.commands=e,_e.activeStates=t,_e.editorTheme=o,_e.isFeatureEnabled=n;}function Hn(){let e=Mn,t=new FloatingToolbarExtension;return t.config={...t.config,render:o=>createElement(e,{...o,commands:_e.commands,activeStates:_e.activeStates,editorTheme:_e.editorTheme,isFeatureEnabled:_e.isFeatureEnabled}),getCommands:()=>_e.commands,getActiveStates:()=>_e.activeStates},t}var ui=120,ci=58;function di(e,t=ci){return e.length<=t?e:`${e.slice(0,t-3)}...`}function Rn(){let e=window.getSelection();return !e||e.rangeCount===0?false:!e.getRangeAt(0).collapsed}function An(e,t){if(!(e instanceof Element))return null;let o=e.closest("a");return !(o instanceof HTMLAnchorElement)||!t.contains(o)?null:o}function Bn({editor:e,commands:t,editorTheme:o="light",disabled:n=false}){let i=useRef(null),r=useRef(null),l=useRef(null),s=useRef(null),[u,m]=useState(null),[E,C]=useState(false),[b,f]=useState(""),[p,h]=useState(null),[v,x]=useState(null),[F,J]=useState(null),$=useCallback(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null);},[]),R=useCallback(()=>{$(),m(null),C(false),f(""),h(null),x(null);},[$]),re=useCallback(()=>{$(),s.current=window.setTimeout(()=>{R();},ui);},[$,R]),ee=useCallback((T,q)=>{let A=T.getBoundingClientRect(),X=i.current?.getBoundingClientRect(),G=be({anchorRect:A,overlay:{width:X?.width??340,height:X?.height??48},portalContainer:q,gap:8,margin:10,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});x({top:typeof G.top=="number"?G.top:0,left:typeof G.left=="number"?G.left:0});},[]),L=useCallback((T,q)=>{if(typeof t.getLinkByKey!="function"){m(A=>!A||A.nodeKey!==T?A:{...A,url:q});return}t.getLinkByKey(T).then(A=>{if(!A){R();return}m(X=>!X||X.nodeKey!==T?X:{...X,url:A.url});});},[t,R]);useEffect(()=>{if(!e||n||typeof window>"u"){R(),J(null),r.current=null;return}let T=e.getRootElement();if(!T){R(),J(null),r.current=null;return}let q=T.closest(".luthor-editor-wrapper")??null;J(q),r.current=q;let A=ae=>{let W=An(ae.target,T);if(!W)return;if(Rn()){R();return}$();let ce=resolveLinkNodeKeyFromAnchor(e,W);if(!ce)return;let me=W.getAttribute("href")??W.href;m({nodeKey:ce,url:me,anchorEl:W}),ee(W,r.current),h(null),E||f(me),L(ce,me);},X=ae=>{if(!u)return;let W=ae.relatedTarget;W&&i.current?.contains(W)||An(W,T)||re();},G=()=>{Rn()&&R();},Pe=()=>{m(ae=>{if(!ae)return ae;let W=ae.anchorEl.isConnected&&T.contains(ae.anchorEl)?ae.anchorEl:T.querySelector(`a[data-lexical-node-key="${ae.nodeKey}"]`);return W?(ee(W,r.current),{...ae,anchorEl:W,url:W.getAttribute("href")??W.href}):(R(),null)});},se=()=>{l.current===null&&(l.current=window.requestAnimationFrame(()=>{l.current=null,Pe();}));};return T.addEventListener("mouseover",A),T.addEventListener("mouseout",X),document.addEventListener("selectionchange",G),window.addEventListener("scroll",se,true),window.addEventListener("resize",se),()=>{T.removeEventListener("mouseover",A),T.removeEventListener("mouseout",X),document.removeEventListener("selectionchange",G),window.removeEventListener("scroll",se,true),window.removeEventListener("resize",se),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),$();}},[t,n,e,u,E,R,re,L,ee,$]),useLayoutEffect(()=>{u&&ee(u.anchorEl,r.current);},[u,E,ee]);let te=useMemo(()=>{if(!(!u||!v))return {...Fe(u.anchorEl),position:F?"absolute":"fixed",top:v.top,left:v.left,zIndex:"var(--luthor-z-menu, 460)"}},[u,v,F]);if(!u||!v||typeof document>"u")return null;let k=()=>{(t.removeLinkByKey?.(u.nodeKey)??false)&&R();},V=()=>{let T=b.trim();if(!(t.updateLinkByKey?.(u.nodeKey,T)??false)){h("Enter a valid URL"),L(u.nodeKey,u.url);return}m(A=>!A||A.nodeKey!==u.nodeKey?A:{...A,url:T}),h(null),C(false),queueMicrotask(()=>{L(u.nodeKey,T);});};return createPortal(jsx("div",{ref:i,className:"luthor-floating-toolbar luthor-link-hover-bubble","data-theme":o,style:te,onMouseEnter:$,onMouseLeave:re,children:E?jsxs(Fragment,{children:[jsx("input",{type:"url",value:b,className:`luthor-link-hover-bubble-input${p?" is-error":""}`,placeholder:"https://example.com","aria-label":"Edit link URL","aria-invalid":p?true:void 0,onChange:T=>{f(T.target.value),p&&h(null);},onKeyDown:T=>{if(T.key==="Enter"){T.preventDefault(),V();return}T.key==="Escape"&&(T.preventDefault(),C(false),f(u.url),h(null));}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-primary",onClick:V,children:"Update"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{C(false),f(u.url),h(null);},children:"Cancel"})]}):jsxs(Fragment,{children:[jsx("span",{className:"luthor-link-hover-bubble-url",title:u.url,children:di(u.url)}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{f(u.url),C(true),h(null);},children:"Edit"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-danger",onClick:k,"aria-label":"Unlink",children:jsx(ht,{size:13})})]})}),F??document.body)}function Dn({mode:e,onModeChange:t,labels:o,availableModes:n,isConverting:i}){let r=["visual","json","markdown","html"],l=new Set(n??["visual","json","markdown","html"]),s=r.filter(m=>l.has(m)),u={visual:o?.visual??"Visual",json:o?.json??"JSON",markdown:o?.markdown??"Markdown",html:o?.html??"HTML"};return jsx("div",{className:"luthor-mode-tabs",children:s.map(m=>jsxs("button",{className:`luthor-mode-tab ${e===m?"active":""}`,onClick:()=>t(m),children:[u[m],i===m&&jsx("span",{className:"luthor-tab-converting-spinner"})]},m))})}function ao({value:e,onChange:t,placeholder:o,className:n,wrap:i}){let r=useRef(null);return useLayoutEffect(()=>{let l=r.current;if(!l)return;l.style.height="auto";let s=Math.max(l.scrollHeight,280);l.style.height=`${s}px`;},[e]),jsx("textarea",{ref:r,className:`luthor-source-view${n?` ${n}`:""}`,value:e,onChange:l=>t(l.target.value),placeholder:o,spellCheck:false,wrap:i??"off"})}function Un(e,t){let o=`luthor-preset-${e}`;return {placeholder:t,classNames:{container:`luthor-preset ${o} ${o}__container`,contentEditable:`luthor-content-editable ${o}__content`,placeholder:`luthor-placeholder ${o}__placeholder`}}}function uo(e){return e.replace(/\r\n?/g,`
2
2
  `)}function fi(e){return e.replace(/&#(9|10|13|32|160);/g,(t,o)=>{switch(o){case "9":return " ";case "10":return `
3
3
  `;case "13":return "\r";case "32":return " ";case "160":return " ";default:return t}})}function pi(e,t){let o=t.replace(/([*~])/g,"\\$1"),n=e;return n=n.replace(new RegExp(`${o}(\\s+)([^\\n]+?)${o}`,"g"),(i,r,l)=>`${r}${t}${l}${t}`),n=n.replace(new RegExp(`${o}([^\\n]+?)(\\s+)${o}`,"g"),(i,r,l)=>`${t}${r}${t}${l}`),n}function bi(e){return ["***","**","~~","*"].reduce((o,n)=>pi(o,n),e)}var yi=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),vi=new Set(["pre","script","style","textarea"]),Ci=new Set(["address","article","aside","blockquote","details","dialog","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","menu","nav","ol","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"]),ki=1,co=3,Ei=8;function Kn(e){return e.nodeType===ki}function Fo(e){return e.nodeType===co&&(e.textContent??"").trim().length>0}function so(e){return e.tagName.toLowerCase()}function Vn(e){return Array.from(e.childNodes).filter(t=>t.nodeType!==co?true:Fo(t))}function Li(e){let t=e.outerHTML,o=t.indexOf(">");return o===-1?`<${so(e)}>`:t.slice(0,o+1)}function Ti(e){let t=so(e);if(yi.has(t)||vi.has(t))return false;let o=Vn(e);if(o.length===0||o.some(Fo))return false;let n=o.filter(Kn);return n.length===0?false:n.every(i=>Ci.has(so(i)))}function _n(e,t){let o=" ".repeat(Math.max(t,0));if(e.nodeType===Ei)return `${o}<!--${e.data}-->`;if(e.nodeType===co){let r=uo(e.textContent??"");return r.trim()?`${o}${r.trim()}`:null}if(!Kn(e))return null;if(!Ti(e))return `${o}${e.outerHTML}`;let n=so(e),i=[`${o}${Li(e)}`];for(let r of Vn(e)){let l=_n(r,t+1);l&&i.push(l);}return i.push(`${o}</${n}>`),i.join(`
4
4
  `)}function wi(e){if(typeof DOMParser>"u")return e;let t=new DOMParser().parseFromString(e,"text/html"),n=Array.from(t.body.childNodes).filter(i=>i.nodeType!==co?true:Fo(i)).map(i=>_n(i,0)).filter(i=>typeof i=="string"&&i.length>0);return n.length===0?t.body.innerHTML.trim()||e:n.join(`
5
- `)}function Oo(e){let t=uo(e).trim();if(!t)return "";try{let o=JSON.parse(t);return JSON.stringify(o,null,2)}catch{return t}}function jn(e){return bi(fi(uo(e))).trim()}function $n(e){let t=uo(e).trim();if(!t)return "";try{return wi(t)}catch{return t}}var Mo=6,Fi=["#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"],Oi=[{title:"1. a. i. style",pattern:"decimal-alpha-roman"},{title:"A. a. i. style",pattern:"upper-alpha-lower-alpha"},{title:"1. 1.1 1.2 style",pattern:"decimal-hierarchical"},{title:"I. A. 1. style",pattern:"upper-roman-upper-alpha"}],Ni=[{title:"Dot / Circle / Square",pattern:"disc-circle-square"},{title:"Arrow / Diamond / Dot",pattern:"arrow-diamond-disc"},{title:"Square / Square / Square",pattern:"square-square-square"},{title:"Arrow / Circle / Square",pattern:"arrow-circle-square"}];function Mi(e){switch(e){case "disc-circle-square":return ["disc","circle","square"];case "arrow-diamond-disc":return ["arrow","diamond","disc"];case "square-square-square":return ["square","square","square"];case "arrow-circle-square":return ["arrow","circle","square"]}}function Hi({type:e,cy:t}){switch(e){case "disc":return jsx("circle",{cx:"16",cy:t,r:"3.2",className:"luthor-unordered-variant-marker"});case "circle":return jsx("circle",{cx:"16",cy:t,r:"3.2",className:"luthor-unordered-variant-marker-open"});case "square":return jsx("rect",{x:"12.8",y:t-3.2,width:"6.4",height:"6.4",className:"luthor-unordered-variant-marker"});case "diamond":return jsx("path",{d:`M16 ${t-3.8} L19.8 ${t} L16 ${t+3.8} L12.2 ${t} Z`,className:"luthor-unordered-variant-marker"});case "arrow":return jsx("path",{d:`M11.6 ${t-2.8} L16.8 ${t} L11.6 ${t+2.8} M11.6 ${t} H19.6`,className:"luthor-unordered-variant-arrow"})}}function Ri({pattern:e}){let t=Mi(e),o=[12.5,24.5,36.5,48.5,60.5],n=e==="disc-circle-square"?[0,1,1,2,0]:e==="arrow-diamond-disc"?[0,1,1,2,0]:e==="square-square-square"?[0,1,2,1,0]:[0,1,1,2,0],i=[t[0],t[1],t[1],t[2],t[0]];return jsxs("svg",{width:"94",height:"74",viewBox:"0 0 94 74",role:"img","aria-hidden":"true",className:"luthor-unordered-variant-svg",children:[jsx("rect",{x:"0.5",y:"0.5",width:"93",height:"73",rx:"3",className:"luthor-unordered-variant-frame"}),o.map((r,l)=>{let s=n[l]??0,u=12+s*12,m=24+s*12,E=57-s*10;return jsxs("g",{children:[jsx("g",{transform:`translate(${u-16}, 0)`,children:jsx(Hi,{type:i[l]??t[0],cy:r})}),jsx("rect",{x:m,y:r-2.5,width:E,height:"5",rx:"2.5",className:"luthor-unordered-variant-line"})]},`${e}-row-${l}`)})]})}function Yn({variant:e}){return jsxs("svg",{width:"78",height:"42",viewBox:"0 0 78 42",role:"img","aria-hidden":"true",className:"luthor-checklist-variant-svg",children:[jsx("rect",{x:"0.5",y:"0.5",width:"77",height:"41",rx:"3",className:"luthor-checklist-variant-frame"}),jsx("rect",{x:"10.5",y:"10.5",width:"10",height:"10",rx:"1.5",className:"luthor-checklist-variant-box"}),jsx("rect",{x:"10.5",y:"24.5",width:"10",height:"10",rx:"1.5",className:"luthor-checklist-variant-box"}),jsx("path",{d:"M12.6 29.2l2 2.2 3.8-4.3",className:"luthor-checklist-variant-check"}),jsx("rect",{x:"26.5",y:"11.8",width:"40",height:"6",rx:"2",className:"luthor-checklist-variant-line"}),jsx("rect",{x:"26.5",y:"25.8",width:"40",height:"6",rx:"2",className:"luthor-checklist-variant-line"}),e==="strikethrough"?jsx(Fragment,{children:jsx("line",{x1:"26.5",y1:"28.8",x2:"66.5",y2:"28.8",className:"luthor-checklist-variant-strike"})}):null]})}function Ai({pattern:e}){let t=[12.5,24.5,36.5,48.5,60.5],o=[0,1,1,2,0],n=e==="decimal-alpha-roman"?["1.","a.","b.","i.","2."]:e==="upper-alpha-lower-alpha"?["A.","a.","b.","i.","B."]:e==="decimal-hierarchical"?["1.","1.1.","1.2.","1.2.1.","2."]:["I.","A.","B.","1.","II."];return jsxs("svg",{width:"94",height:"74",viewBox:"0 0 94 74",role:"img","aria-hidden":"true",className:"luthor-ordered-variant-svg",children:[jsx("rect",{x:"0.5",y:"0.5",width:"93",height:"73",rx:"3",className:"luthor-ordered-variant-frame"}),t.map((i,r)=>{let l=o[r]??0,s=9+l*12,u=26+l*12,m=56-l*10;return jsxs("g",{children:[jsx("text",{x:s,y:i+2.8,className:"luthor-ordered-variant-label",children:n[r]}),jsx("rect",{x:u,y:i-2.5,width:m,height:"5",rx:"2.5",className:"luthor-ordered-variant-line"})]},`${e}-ordered-row-${r}`)})]})}function go(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Pi(e,t){let o=go(t);for(let n of e)if(go(n.value)===o)return n.color;return null}function zi(e,t,o){if(!e||e==="default")return o;let n=Pi(t,e);return n||e}function Bi(e,t){let o=e.trim();return /^#([\da-f]{6})$/i.test(o)?o:/^#([\da-f]{3})$/i.test(o)?`#${o.slice(1).split("").map(i=>`${i}${i}`).join("")}`:t}var Ho="Inherited",mo="16px",Ro="1.5";function ye(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Jn(e){let t=e.split(",")[0]??"";return ye(t.replace(/["']/g,""))}function ho(e){let t=e.trim().toLowerCase().match(/^(-?\d*\.?\d+)px$/);if(!t)return null;let o=Number(t[1]);return Number.isFinite(o)?o:null}function yt(){if(typeof window>"u")return null;let t=window.getSelection()?.anchorNode;if(!t)return null;let o=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!o||!o.closest(".luthor-content-editable"))return null;let i=window.getComputedStyle(o);return {fontFamily:i.fontFamily,fontSize:i.fontSize,lineHeight:i.lineHeight}}function No(){if(typeof window>"u"||typeof document>"u")return null;let e=document.querySelector(".luthor-content-editable");if(!(e instanceof HTMLElement))return null;let t=window.getComputedStyle(e);return {fontFamily:t.fontFamily,fontSize:t.fontSize,lineHeight:t.lineHeight}}function Gn(e){return (e.split(",")[0]?.trim()??"").replace(/^['"]|['"]$/g,"").trim()}function Di(e,t){let o=ye(e);if(o&&o!=="inherit"){let i=Gn(e);if(i)return i}return Gn(t?.fontFamily??"")||Ho}function Ui(e,t){let o=ye(e);return o&&o!=="inherit"?e.trim():(t?.fontSize??"").trim()||mo}function Ki(e,t){let o=ye(e);return o&&o!=="normal"?e.trim():(t?.lineHeight??"").trim()||Ro}function Vi(e,t){if(!e)return null;let o=Jn(e);return o?t.find(i=>ye(i.value)===o?true:Jn(i.fontFamily)===o)?.value??null:null}function _i(e,t){if(!e)return null;let o=ye(e),n=t.find(l=>ye(String(l.value))===o?true:ye(String(l.fontSize))===o);if(n)return String(n.value);let i=ho(e);if(i==null)return null;let r=null;for(let l of t){let s=ho(String(l.fontSize));if(s==null)continue;let u=Math.abs(s-i);(!r||u<r.distance)&&(r={value:String(l.value),distance:u});}return r?.value??null}function ji(e,t,o){if(!e)return null;let n=ye(e),i=o.find(m=>ye(m.value)===n?true:ye(m.lineHeight)===n);if(i)return i.value;let r=t?ho(t):null,l=ho(e),s=null;if(l!=null&&r!=null&&r>0)s=l/r;else {let m=Number(e);Number.isFinite(m)&&(s=m);}if(s==null)return null;let u=null;for(let m of o){let E=Number(m.lineHeight);if(!Number.isFinite(E))continue;let C=Math.abs(E-s);(!u||C<u.distance)&&(u={value:m.value,distance:C});}return u?.value??null}function Wn({title:e,value:t,options:o,recentColors:n,active:i,fallbackColor:r,highlight:l,onChange:s,onClear:u,onAddRecent:m}){let E=useRef(null),C=useRef(null),b=useRef(null),f=useRef(null),p=useRef(null),[h,v]=useState(false),[x,F]=useState(void 0),[J,$]=useState(null),R=zi(t,o,r),re=useMemo(()=>Fi,[]),ee=useMemo(()=>{let k=[...n].slice(0,Mo);for(;k.length<Mo;)k.push("");return k},[n]);useEffect(()=>()=>{f.current&&window.cancelAnimationFrame(f.current);},[]);let L=useCallback(k=>{p.current=k,!f.current&&(f.current=window.requestAnimationFrame(()=>{f.current=null,p.current&&(s(p.current),p.current=null);}));},[s]),te=useCallback(k=>{let V=E.current;if(!V)return;let T=V.getBoundingClientRect(),q=C.current?.getBoundingClientRect(),A=pt(V);$(A);let X=be({anchorRect:T,overlay:{width:q?.width??248,height:q?.height??340},portalContainer:A,gap:6,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});F({...X,visibility:k?"visible":"hidden",...Fe(V)});},[]);return useLayoutEffect(()=>{if(!h)return;te(false);let k=window.requestAnimationFrame(()=>{te(true);});return ()=>{window.cancelAnimationFrame(k);}},[h,te]),useEffect(()=>{if(!h)return;let k=q=>{let A=q.target;E.current?.contains(A)||C.current?.contains(A)||v(false);},V=q=>{q.key==="Escape"&&v(false);},T=()=>te(true);return window.addEventListener("resize",T),window.addEventListener("scroll",T,true),document.addEventListener("mousedown",k),document.addEventListener("keydown",V),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,true),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",V),$(null);}},[h,te]),jsxs(Fragment,{children:[jsxs("button",{ref:E,type:"button",className:`luthor-toolbar-button luthor-color-button${i?" active":""}${l?" is-highlight":""}`,title:e,"aria-label":e,onClick:()=>v(k=>!k),children:[l?jsx(cn,{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:R}})]}),h&&typeof document<"u"&&createPortal(jsxs("div",{ref:C,className:"luthor-color-picker",style:x,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:re.map(k=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:k},"aria-label":`Use color ${k}`,onClick:()=>{s(k),m(k),v(false);}},k))})]}),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:ee.map((k,V)=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:k||"transparent"},"aria-label":k?`Use recent color ${k}`:"Empty recent color slot",disabled:!k,onClick:()=>{k&&(s(k),m(k),v(false));}},`${k||"empty"}-${V}`))})]}),jsxs("div",{className:"luthor-color-picker-footer",children:[jsx("button",{type:"button",className:"luthor-color-picker-clear",onClick:()=>{u(),v(false);},children:"Reset to Default"}),jsxs("button",{type:"button",className:"luthor-color-picker-custom",onClick:()=>b.current?.click(),children:[jsx(dn,{size:14}),jsx("span",{children:"Custom Color"})]}),jsx("input",{ref:b,type:"color",className:"luthor-color-picker-native luthor-color-picker-native-hidden",value:Bi(R,r),onInput:k=>{L(k.target.value);},onChange:k=>{let V=k.target.value;s(V),m(V);}})]})]}),J??document.body)]})}function $i(e,t){let o=useRef(null),n=useRef(null);return {handlers:useMemo(()=>({insertFromUrl:()=>{let r=prompt("Enter image URL:");if(!r)return;let l=prompt("Enter alt text:")||"",s=prompt("Enter caption (optional):")||void 0;e.insertImage({src:r,alt:l,caption:s});},insertFromFile:()=>o.current?.click(),insertGifFromUrl:()=>{let r=prompt("Enter GIF URL:");if(!r)return;let l=prompt("Enter alt text (optional):")||"GIF";e.insertImage({src:r,alt:l});},insertGifFromFile:()=>n.current?.click(),handleUpload:async r=>{let l=r.target.files?.[0];if(!l)return;let s;if(t)try{s=await t(l);}catch{alert("Failed to upload image");return}else s=URL.createObjectURL(l);e.insertImage({src:s,alt:l.name,file:l}),r.target.value="";},handleGifUpload:async r=>{let l=r.target.files?.[0];if(!l)return;if(!(l.type==="image/gif"||l.name.toLowerCase().endsWith(".gif"))){alert("Please select a GIF file."),r.target.value="";return}let u;if(t)try{u=await t(l);}catch{alert("Failed to upload GIF");return}else u=URL.createObjectURL(l);e.insertImage({src:u,alt:l.name||"GIF",file:l}),r.target.value="";},setAlignment:r=>{e.setImageAlignment(r);},setCaption:()=>{let r=prompt("Enter caption:")||"";e.setImageCaption(r);}}),[e,t]),fileInputRef:o,gifInputRef:n}}function qi(e){return useMemo(()=>({insertIframe:()=>{let t=prompt("Enter iframe URL:");t&&typeof e.insertIframeEmbed=="function"&&e.insertIframeEmbed(t);},insertYouTube:()=>{let t=prompt("Enter YouTube URL:");t&&typeof e.insertYouTubeEmbed=="function"&&e.insertYouTubeEmbed(t);}}),[e])}function Yi(e,t){switch(e){case "fontFamily":return t("fontFamily");case "fontSize":return t("fontSize");case "lineHeight":return t("lineHeight");case "textColor":return t("textColor");case "textHighlight":return t("textHighlight");case "subscript":return t("subscript");case "superscript":return t("superscript");case "blockFormat":case "quote":case "alignLeft":case "alignCenter":case "alignRight":case "alignJustify":return t("blockFormat");case "codeBlock":return t("code");case "unorderedList":case "orderedList":case "checkList":case "indentList":case "outdentList":return t("list");case "horizontalRule":return t("horizontalRule");case "table":return t("table");case "image":return t("image");case "emoji":return t("emoji");case "embed":return t("iframeEmbed")||t("youtubeEmbed");case "undo":case "redo":return t("history");default:return true}}function Ji(e,t,o){return Yi(e,t)?o?.[e]!==false:false}function Gi(e,t,o){return {sections:e.sections.map(n=>({...n,items:n.items.filter(i=>Ji(i,t,o))})).filter(n=>n.items.length>0)}}function Xn({commands:e,hasExtension:t,activeStates:o,isDark:n,toggleTheme:i,onCommandPaletteOpen:r,imageUploadHandler:l,classNames:s,toolbarStyleVars:u,layout:m,toolbarVisibility:E,headingOptions:C,paragraphLabel:b}){let{handlers:f,fileInputRef:p,gifInputRef:h}=$i(e,l),v=qi(e),x=t("iframeEmbed")||t("youtubeEmbed"),F=o.isIframeEmbedSelected||o.isYouTubeEmbedSelected,[J,$]=useState(false),[R,re]=useState(false),[ee,L]=useState(false),[te,k]=useState(false),[V,T]=useState(false),[q,A]=useState(false),[X,G]=useState(false),[Pe,se]=useState(false),[ae,W]=useState("default"),[ce,me]=useState([{value:"default",label:Ho}]),[Oe,ve]=useState("default"),[$e,ge]=useState([{value:"default",label:mo}]),[Ne,de]=useState("default"),[qe,ze]=useState([{value:"default",label:Ro}]),[M,B]=useState("default"),[ie,Ye]=useState([{value:"default",label:"Default",color:"inherit"}]),[ne,he]=useState([]),[st,Me]=useState("default"),[Ee,Be]=useState([{value:"default",label:"Default",color:"transparent"}]),[De,xe]=useState([]),[fe,He]=useState(0),[Ue,Y]=useState({rows:3,columns:3,includeHeaders:false}),pe=useRef(null),Je=useRef("");useEffect(()=>{if(typeof document>"u")return;let g=()=>{pe.current===null&&(pe.current=window.requestAnimationFrame(()=>{pe.current=null;let d=window.getSelection();if(!d||d.rangeCount===0||!d.getRangeAt(0).collapsed)return;let w=yt();if(!w)return;let P=`${w.fontFamily}|${w.fontSize}|${w.lineHeight}`;P!==Je.current&&(Je.current=P,He(_=>_+1));}));};return document.addEventListener("selectionchange",g),()=>{document.removeEventListener("selectionchange",g),pe.current!==null&&(cancelAnimationFrame(pe.current),pe.current=null);}},[]);let Le=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 g=yt()??No(),d=e.getFontFamilyOptions().map(P=>({value:P.value,label:ye(P.value)==="default"?Di(P.fontFamily,g):P.label})),w=d.length>0?d:[{value:"default",label:Ho}];me(w),W(P=>w.some(_=>_.value===P)?P:"default");},[e,t]),useEffect(()=>{if(!t("fontFamily")||typeof e.getCurrentFontFamily!="function")return;let g=e.getFontFamilyOptions;if(typeof g!="function")return;let d=false;return e.getCurrentFontFamily().then(w=>{if(d)return;if(w&&w!=="default"){W(w);return}let P=yt(),_=Vi(P?.fontFamily,g());W(_??"default");}),()=>{d=true;}},[o,e,t,fe]),useEffect(()=>{if(!t("fontSize")||typeof e.getFontSizeOptions!="function")return;let g=yt()??No(),d=e.getFontSizeOptions().map(_=>({value:String(_.value).trim(),label:ye(String(_.value))==="default"?Ui(String(_.fontSize),g):String(_.label).trim()})).filter(_=>_.value.length>0&&_.label.length>0),w=d.some(_=>ye(_.value)==="default"),P=d.length===0?[{value:"default",label:mo}]:w?d:[{value:"default",label:mo},...d];ge(P),ve(_=>P.some(j=>j.value===_)?_:"default");},[e,t]),useEffect(()=>{if(!t("fontSize")||typeof e.getCurrentFontSize!="function")return;let g=e.getFontSizeOptions;if(typeof g!="function")return;let d=false;return e.getCurrentFontSize().then(w=>{if(d)return;if(w&&w!=="default"){ve(w);return}let P=yt(),_=_i(P?.fontSize,g());ve(_??"default");}),()=>{d=true;}},[o,e,t,fe]),useEffect(()=>{if(!t("lineHeight")||typeof e.getLineHeightOptions!="function")return;let g=yt()??No(),d=e.getLineHeightOptions().map(P=>({value:P.value,label:ye(P.value)==="default"?Ki(P.lineHeight,g):P.label})),w=d.length>0?d:[{value:"default",label:Ro}];ze(w);},[e,t]),useEffect(()=>{if(!t("lineHeight")||typeof e.getCurrentLineHeight!="function")return;let g=e.getLineHeightOptions;if(typeof g!="function")return;let d=false;return e.getCurrentLineHeight().then(w=>{if(d)return;if(w){de(w);return}let P=yt(),_=ji(P?.lineHeight,P?.fontSize,g());de(_??"default");}),()=>{d=true;}},[o,e,t,fe]),useEffect(()=>{if(!t("textColor")||typeof e.getTextColorOptions!="function")return;let g=e.getTextColorOptions().map(d=>({value:d.value,label:d.label,color:d.color}));g.length>0&&Ye(g);},[e,t]),useEffect(()=>{if(!t("textColor")||typeof e.getCurrentTextColor!="function")return;let g=false;return e.getCurrentTextColor().then(d=>{g||B(d??"default");}),()=>{g=true;}},[o,e,t,fe]),useEffect(()=>{if(!t("textHighlight")||typeof e.getTextHighlightOptions!="function")return;let g=e.getTextHighlightOptions().map(d=>({value:d.value,label:d.label,color:d.backgroundColor}));g.length>0&&Be(g);},[e,t]),useEffect(()=>{if(!t("textHighlight")||typeof e.getCurrentTextHighlight!="function")return;let g=false;return e.getCurrentTextHighlight().then(d=>{g||Me(d??"default");}),()=>{g=true;}},[o,e,t,fe]);let ut=useMemo(()=>{if(!C||C.length===0)return [...Ie];let g=new Set,d=[];for(let w of C)!Ie.includes(w)||g.has(w)||(g.add(w),d.push(w));return d.length>0?d:[...Ie]},[C]),ct=b?.trim()||"Paragraph",Ke=useMemo(()=>{let g=ut.map(d=>({value:d,label:`Heading ${d.slice(1)}`}));return [{value:"p",label:ct},...g]},[ut,ct]),dt=o.isH1?"h1":o.isH2?"h2":o.isH3?"h3":o.isH4?"h4":o.isH5?"h5":o.isH6?"h6":"p",Ge=Ke.some(g=>g.value===dt)?dt:"p",kt=g=>{g==="p"?e.toggleParagraph():g.startsWith("h")&&ut.includes(g)&&e.toggleHeading(g);},mt=g=>{g==="default"?e.clearFontFamily?.():e.setFontFamily?.(g),W(g);},Ve=g=>{g==="default"?e.clearFontSize?.():e.setFontSize?.(g),ve(g);},We=g=>{e.setLineHeight?.(g),de(g);},ot=(g,d)=>{g(w=>{let P=go(d),_=w.filter(j=>go(j)!==P);return [d,..._].slice(0,Mo)});},Xe=g=>{if(g==="default"){e.clearTextColor?.(),B("default");return}e.setTextColor?.(g),B(g);},Et=g=>{if(g==="default"){e.clearTextHighlight?.(),Me("default");return}e.setTextHighlight?.(g),Me(g);},nt=g=>{if(typeof e.setOrderedListPattern=="function"){e.setOrderedListPattern(g);return}e.toggleOrderedList();},Rt=g=>{if(typeof e.setUnorderedListPattern=="function"){e.setUnorderedListPattern(g);return}e.toggleUnorderedList();},gt=g=>{if(typeof e.setCheckListVariant=="function"){e.setCheckListVariant(g);return}e.toggleCheckList();},Re=g=>{switch(g){case "fontFamily":return t("fontFamily")?jsx(Dt,{value:ae,onValueChange:mt,options:ce,placeholder:"Font"},"fontFamily"):null;case "fontSize":return t("fontSize")?jsx(Dt,{value:Oe,onValueChange:Ve,options:$e,placeholder:"Size"},"fontSize"):null;case "lineHeight":return t("lineHeight")?jsx(Dt,{value:Ne,onValueChange:We,options:qe,placeholder:"Line"},"lineHeight"):null;case "textColor":return t("textColor")?jsx(Wn,{title:"Text Color",value:M,options:ie,recentColors:ne,active:o.hasCustomTextColor,fallbackColor:"#0f172a",onChange:Xe,onClear:()=>Xe("default"),onAddRecent:d=>ot(he,d)},"textColor"):null;case "textHighlight":return t("textHighlight")?jsx(Wn,{title:"Text Highlight",value:st,options:Ee,recentColors:De,active:o.hasTextHighlight,fallbackColor:"#fef08a",highlight:true,onChange:Et,onClear:()=>Et("default"),onAddRecent:d=>ot(xe,d)},"textHighlight"):null;case "bold":return jsx(N,{onClick:()=>e.toggleBold(),active:o.bold,title:"Bold (Ctrl+B)",children:jsx(Jt,{size:16})},"bold");case "italic":return jsx(N,{onClick:()=>e.toggleItalic(),active:o.italic,title:"Italic (Ctrl+I)",children:jsx(Gt,{size:16})},"italic");case "underline":return jsx(N,{onClick:()=>e.toggleUnderline(),active:o.underline,title:"Underline (Ctrl+U)",children:jsx(Wt,{size:16})},"underline");case "strikethrough":return jsx(N,{onClick:()=>e.toggleStrikethrough(),active:o.strikethrough,title:"Strikethrough",children:jsx(Xt,{size:16})},"strikethrough");case "subscript":return t("subscript")?jsx(N,{onClick:()=>e.toggleSubscript?.(),active:o.subscript,title:"Subscript",children:jsx(yn,{size:16})},"subscript"):null;case "superscript":return t("superscript")?jsx(N,{onClick:()=>e.toggleSuperscript?.(),active:o.superscript,title:"Superscript",children:jsx(vn,{size:16})},"superscript"):null;case "code":return jsx(N,{onClick:()=>e.formatText("code"),active:o.code,title:"Inline Code",children:jsx(Qt,{size:16})},"code");case "link":return jsx(N,{onClick:()=>o.isLink?e.removeLink():e.insertLink(),active:o.isLink,title:o.isLink?"Remove Link":"Insert Link",children:o.isLink?jsx(ht,{size:16}):jsx(Lt,{size:16})},"link");case "blockFormat":return t("blockFormat")?jsx(Dt,{value:Ge,onValueChange:kt,options:Ke,placeholder:"Format"},"blockFormat"):null;case "quote":return t("blockFormat")?jsx(N,{onClick:()=>e.toggleQuote(),active:o.isQuote,title:"Quote",children:jsx(no,{size:16})},"quote"):null;case "alignLeft":return t("blockFormat")?jsx(N,{onClick:()=>e.setTextAlignment("left"),active:o.isTextAlignedLeft,title:"Align Left",children:jsx(Tt,{size:16})},"alignLeft"):null;case "alignCenter":return t("blockFormat")?jsx(N,{onClick:()=>e.setTextAlignment("center"),active:o.isTextAlignedCenter,title:"Align Center",children:jsx(ft,{size:16})},"alignCenter"):null;case "alignRight":return t("blockFormat")?jsx(N,{onClick:()=>e.setTextAlignment("right"),active:o.isTextAlignedRight,title:"Align Right",children:jsx(wt,{size:16})},"alignRight"):null;case "alignJustify":return t("blockFormat")?jsx(N,{onClick:()=>e.setTextAlignment("justify"),active:o.isTextAlignedJustify,title:"Justify",children:jsx(ln,{size:16})},"alignJustify"):null;case "codeBlock":return t("code")?jsx(N,{onClick:()=>e.toggleCodeBlock(),active:o.isInCodeBlock,title:"Code Block",children:jsx(on,{size:16})},"codeBlock"):null;case "unorderedList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(N,{onClick:()=>e.toggleUnorderedList(),active:o.unorderedList,title:"Bullet List",children:jsx(Zt,{size:16})}),jsx(rt,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${o.unorderedList?" active":""}`,title:"Bullet List Styles","aria-label":"Bullet List Styles",children:jsx(St,{size:12})}),isOpen:V,onOpenChange:T,children:jsx("div",{className:"luthor-unordered-variant-grid",children:Ni.map(d=>jsx("button",{className:"luthor-unordered-variant-option",type:"button",title:d.title,"aria-label":d.title,onClick:()=>{Rt(d.pattern),T(false);},children:jsx(Ri,{pattern:d.pattern})},d.pattern))})})]},"unorderedList"):null;case "orderedList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(N,{onClick:()=>e.toggleOrderedList(),active:o.orderedList,title:"Numbered List",children:jsx(to,{size:16})}),jsx(rt,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${o.orderedList?" active":""}`,title:"Numbered List Styles","aria-label":"Numbered List Styles",children:jsx(St,{size:12})}),isOpen:q,onOpenChange:A,children:jsx("div",{className:"luthor-ordered-variant-grid",children:Oi.map(d=>jsx("button",{className:"luthor-ordered-variant-option",type:"button",title:d.title,"aria-label":d.title,onClick:()=>{nt(d.pattern),A(false);},children:jsx(Ai,{pattern:d.pattern})},d.pattern))})})]},"orderedList"):null;case "checkList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(N,{onClick:()=>e.toggleCheckList(),active:o.checkList,title:"Checklist",children:jsx(eo,{size:16})}),jsx(rt,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${o.checkList?" active":""}`,title:"Checklist Styles","aria-label":"Checklist Styles",children:jsx(St,{size:12})}),isOpen:X,onOpenChange:G,children:jsxs("div",{className:"luthor-checklist-variant-grid",children:[jsx("button",{className:"luthor-checklist-variant-option",type:"button",title:"Checked = Strike through","aria-label":"Checked = Strike through",onClick:()=>{gt("strikethrough"),G(false);},children:jsx(Yn,{variant:"strikethrough"})}),jsx("button",{className:"luthor-checklist-variant-option",type:"button",title:"Checked = Keep text","aria-label":"Checked = Keep text",onClick:()=>{gt("plain"),G(false);},children:jsx(Yn,{variant:"plain"})})]})})]},"checkList"):null;case "indentList":return t("list")?jsx(N,{onClick:()=>e.indentList(),title:"Indent List",children:jsx(gn,{size:14})},"indentList"):null;case "outdentList":return t("list")?jsx(N,{onClick:()=>e.outdentList(),title:"Outdent List",children:jsx(hn,{size:14})},"outdentList"):null;case "horizontalRule":return t("horizontalRule")?jsx(N,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(an,{size:16})},"horizontalRule"):null;case "table":return t("table")?jsx(N,{onClick:()=>se(true),title:"Insert Table",children:jsx(sn,{size:16})},"table"):null;case "image":return t("image")?jsxs(Fragment,{children:[jsxs(rt,{trigger:jsx("button",{className:`luthor-toolbar-button ${o.imageSelected?"active":""}`,title:"Insert Image",children:jsx(ko,{size:16})}),isOpen:J,onOpenChange:$,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertFromUrl(),$(false);},children:[jsx(Lt,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertFromFile(),$(false);},children:[jsx(Eo,{size:16}),jsx("span",{children:"Upload File"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertGifFromUrl(),$(false);},children:[jsx(Lo,{size:16}),jsx("span",{children:"Insert GIF URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertGifFromFile(),$(false);},children:[jsx(Eo,{size:16}),jsx("span",{children:"Upload GIF"})]})]},"image"),o.imageSelected&&jsxs(rt,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(ft,{size:16})}),isOpen:ee,onOpenChange:L,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("left"),L(false);},children:[jsx(Tt,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("center"),L(false);},children:[jsx(ft,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("right"),L(false);},children:[jsx(wt,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setCaption(),L(false);},children:[jsx(mn,{size:16}),jsx("span",{children:"Set Caption"})]})]},"imageAlign")]}):null;case "emoji":return !t("emoji")||Le.length===0?null:jsx(rt,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Insert Emoji",children:jsx(Lo,{size:16})}),isOpen:R,onOpenChange:re,children:jsx("div",{className:"luthor-emoji-picker-grid",role:"listbox","aria-label":"Emoji picker",children:Le.map(d=>jsx("button",{type:"button",className:"luthor-emoji-picker-item",title:d.shortcodes[0]?`${d.label} (:${d.shortcodes[0]}:)`:d.label,onClick:()=>{e.insertEmoji?.(d.emoji),re(false);},children:d.emoji},`${d.emoji}-${d.label}`))})},"emoji");case "embed":return x?jsxs(rt,{trigger:jsx("button",{className:`luthor-toolbar-button ${F?"active":""}`,title:"Insert Embed",children:jsx(un,{size:16})}),isOpen:te,onOpenChange:k,children:[t("iframeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{v.insertIframe(),k(false);},children:[jsx(Lt,{size:16}),jsx("span",{children:"Embed iframe"})]}):null,t("youtubeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{v.insertYouTube(),k(false);},children:[jsx(ko,{size:16}),jsx("span",{children:"Embed YouTube Video"})]}):null]},"embed"):null;case "undo":return t("history")?jsx(N,{onClick:()=>e.undo(),disabled:!o.canUndo,title:"Undo (Ctrl+Z)",children:jsx(nn,{size:16})},"undo"):null;case "redo":return t("history")?jsx(N,{onClick:()=>e.redo(),disabled:!o.canRedo,title:"Redo (Ctrl+Y)",children:jsx(rn,{size:16})},"redo"):null;case "commandPalette":return jsx(N,{onClick:()=>r?.(),title:"Command Palette (Ctrl+Shift+P)",children:jsx(oo,{size:16})},"commandPalette");case "themeToggle":return jsx(N,{onClick:i,title:n?"Light Mode":"Dark Mode",children:n?jsx(fn,{size:16}):jsx(pn,{size:16})},"themeToggle");default:return null}},y=m??qt,I=useMemo(()=>Gi(y,t,E),[y,t,E]);return jsxs(Fragment,{children:[jsx("div",{className:s?.toolbar??"luthor-toolbar",style:u,children:I.sections.map((g,d)=>{let w=g.items.map((P,_)=>{let j=Re(P);return j?Array.isArray(j)?j.map((Qe,$t)=>Qe&&typeof Qe=="object"&&"key"in Qe&&Qe.key!=null?Qe:jsx("span",{children:Qe},`toolbar-item-${d}-${_}-${$t}`)):j.type===Si.Fragment?jsx("span",{children:j},`toolbar-item-${d}-${_}`):j&&typeof j=="object"&&"key"in j&&j.key!=null?j:jsx("span",{children:j},`toolbar-item-${d}-${_}`):null}).flat().filter(P=>P!==null);return w.length===0?null:jsx("div",{className:s?.section??"luthor-toolbar-section",children:w},d)})}),jsx("input",{ref:p,type:"file",accept:"image/*",onChange:f.handleUpload,className:"luthor-file-input"}),jsx("input",{ref:h,type:"file",accept:"image/gif",onChange:f.handleGifUpload,className:"luthor-file-input"}),jsx(Mn,{isOpen:Pe,onClose:()=>se(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:Ue.rows,onChange:g=>Y(d=>({...d,rows:parseInt(g.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:Ue.columns,onChange:g=>Y(d=>({...d,columns:parseInt(g.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:Ue.includeHeaders||false,onChange:g=>Y(d=>({...d,includeHeaders:g.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(So,{variant:"secondary",onClick:()=>se(false),children:"Cancel"}),jsx(So,{variant:"primary",onClick:()=>{e.insertTable(Ue),se(false);},children:"Insert Table"})]})]})})]})}var Ko=["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"],rr={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 _t(e){let t={...rr};if(!e)return t;for(let o of Ko)typeof e[o]=="boolean"&&(t[o]=e[o]);return t}function ir(e,t){return e[t]!==false}var er=8,tr=[{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"}],wl={value:"default",label:"Default",fontFamily:"inherit"},or=[{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"}],Sl={value:"default",label:"Default",fontSize:"inherit"},nr=[{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"}],xl={value:"default",label:"Default",lineHeight:"1.5"},Vt="1.5",Il=1;function vt(e){return e.trim().toLowerCase()}function lr(e){return /^[a-z0-9][a-z0-9-]*$/i.test(e)}function Fl(e){return vt(e)==="default"?true:po(e)!==null}function Ol(e){let t=e??tr,o=new Set,n=[];for(let r of t){let l=r.value.trim(),s=r.label.trim(),u=r.fontFamily.trim();if(!l||!s||!u||!lr(l))continue;let m=vt(l);o.has(m)||(o.add(m),n.push({value:l,label:s,fontFamily:u,cssImportUrl:r.cssImportUrl?.trim()||void 0}));}return n.length===0?tr:n.some(r=>vt(r.value)==="default")?n:[wl,...n]}function Nl(e){let t=e??or,o=new Set,n=[];for(let r of t){let l=String(r.value).trim(),s=String(r.label).trim(),u=String(r.fontSize).trim();if(!l||!s||!u||!lr(l))continue;let m=vt(l);o.has(m)||(o.add(m),n.push({value:l,label:s,fontSize:u}));}return n.length===0?or:n.some(r=>vt(r.value)==="default")?n:[Sl,...n]}function po(e){let t=e.trim();if(!/^\d*\.?\d+$/.test(t))return null;let o=Number(t);return !Number.isFinite(o)||o<Il?null:o.toString()}function Ml(e){if(!Number.isFinite(e))return er;let t=Math.floor(e);return t>=0?t:er}function Hl(e){return typeof e=="number"?Number.isFinite(e)?po(e.toString())??Vt:Vt:typeof e=="string"?po(e)??Vt:Vt}function Rl(e,t=Vt){let o=e??nr,n=new Set,i=[];for(let l of o){let s=String(l.value).trim(),u=String(l.label).trim();if(!s||!u||!Fl(s))continue;let m=vt(s);if(n.has(m))continue;if(m==="default"){n.add(m),i.push({value:s,label:u,lineHeight:t});continue}let E=po(String(l.lineHeight));E&&(n.add(m),i.push({value:s,label:u,lineHeight:E}));}return i.length===0?nr:i.some(l=>vt(l.value)==="default")?i:[{...xl,lineHeight:t},...i]}function at({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 Al=()=>jsxs(at,{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"})]}),Pl=()=>jsxs(at,{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"})]}),zl=()=>jsxs(at,{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"})]}),Bl=()=>jsxs(at,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M12.5 5v14"}),jsx("path",{d:"M16.5 10.5v3"}),jsx("path",{d:"M16.8 12h4.4"}),jsx("path",{d:"M19 9.8v4.4"})]}),Dl=()=>jsxs(at,{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"})]}),Ul=()=>jsxs(at,{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"})]}),Kl=()=>jsxs(at,{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"})]}),Vl=()=>jsxs(at,{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"})]}),bo=new ImageExtension;bo.config={...bo.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var Ao=new TableExtension;Ao.config={...Ao.config,enableContextMenu:true,tableBubbleRenderer:({headersEnabled:e,setHeadersEnabled:t,actions:o})=>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:o.insertRowAbove,children:jsx(Al,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert row below","aria-label":"Insert row below",onClick:o.insertRowBelow,children:jsx(Pl,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column left","aria-label":"Insert column left",onClick:o.insertColumnLeft,children:jsx(zl,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column right","aria-label":"Insert column right",onClick:o.insertColumnRight,children:jsx(Bl,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected row","aria-label":"Delete selected row",onClick:o.deleteSelectedRow,children:jsx(Dl,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected column","aria-label":"Delete selected column",onClick:o.deleteSelectedColumn,children:jsx(Ul,{})}),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(Vl,{})})}),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:o.deleteTable,children:jsx(Kl,{})})]})};var Po=new IframeEmbedExtension;Po.config={...Po.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center"};var zo=new YouTubeEmbedExtension;zo.config={...zo.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center",nocookie:true,controls:true,rel:1};var _l=Rn(),Bo=new ContextMenuExtension;Bo.config={...Bo.config,preventDefault:true};var jl=new CommandPaletteExtension,$l=new SlashCommandExtension,ql=new EmojiExtension,Do=new DraggableBlockExtension;Do.config={...Do.config,buttonStackPosition:"left"};var Uo=new LinkExtension;Uo.config={...Uo.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var Yl=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"}]}),Jl=textHighlightExtension.configure({options:[{value:"default",label:"Default",backgroundColor:"transparent"},{value:"yellow",label:"Yellow",backgroundColor:"#fef08a"},{value:"green",label:"Green",backgroundColor:"#bbf7d0"},{value:"blue",label:"Blue",backgroundColor:"#bfdbfe"},{value:"pink",label:"Pink",backgroundColor:"#fbcfe8"},{value:"orange",label:"Orange",backgroundColor:"#fed7aa"}]}),{extension:Gl}=createCustomNodeExtension({nodeType:"featureCard",defaultPayload:{title:"AI Draft Block",description:"AI-generated first draft. Review and edit before publishing to customers.",tag:"AI Draft"},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??"AI Draft"}),jsx("h4",{className:"luthor-extensive-feature-card__title",children:e.title??"Generated Draft"}),jsx("p",{className:"luthor-extensive-feature-card__description",children:e.description??"AI-generated first pass. Review and finalize before sharing."})]})});function ar({fontFamilyOptions:e,fontSizeOptions:t,lineHeightOptions:o,minimumDefaultLineHeight:n,featureFlags:i,isDraggableBoxEnabled:r,scaleByRatio:l,syntaxHighlighting:s,codeHighlightProvider:u,loadCodeHighlightProvider:m,maxAutoDetectCodeLength:E,isCopyAllowed:C,languageOptions:b,maxListIndentation:f}={}){let p=_t(i),h=te=>ir(p,te),v=(r??true)&&h("draggableBlock"),x=Hl(n),F=Ml(f),J=new FontFamilyExtension().configure({options:Ol(e),cssLoadStrategy:"on-demand"}),$=new FontSizeExtension().configure({options:Nl(t)}),R=new LineHeightExtension().configure({options:Rl(o,x),defaultLineHeight:x});bo.configure({scaleByRatio:l??false}),codeExtension.configure({syntaxHighlighting:s??"auto",provider:u??void 0,loadProvider:m}),codeIntelligenceExtension.configure({provider:u??void 0,loadProvider:m,maxAutoDetectLength:E,isCopyAllowed:C??true,languageOptions:b});let re=new ListExtension({maxDepth:F+1}),ee=new TabIndentExtension({maxListDepth:F+1}),L=[];return h("bold")&&L.push(boldExtension),h("italic")&&L.push(italicExtension),h("underline")&&L.push(underlineExtension),h("strikethrough")&&L.push(strikethroughExtension),h("fontFamily")&&L.push(J),h("fontSize")&&L.push($),h("lineHeight")&&L.push(R),h("textColor")&&L.push(Yl),h("textHighlight")&&L.push(Jl),h("subscript")&&L.push(subscriptExtension),h("superscript")&&L.push(superscriptExtension),h("link")&&L.push(Uo),h("horizontalRule")&&L.push(horizontalRuleExtension),h("table")&&L.push(Ao),h("list")&&L.push(re),h("history")&&L.push(historyExtension),h("image")&&L.push(bo),h("blockFormat")&&L.push(blockFormatExtension),h("code")&&L.push(codeExtension),h("codeIntelligence")&&L.push(codeIntelligenceExtension),h("codeFormat")&&L.push(codeFormatExtension),h("tabIndent")&&L.push(ee),h("enterKeyBehavior")&&L.push(enterKeyBehaviorExtension),h("iframeEmbed")&&L.push(Po),h("youTubeEmbed")&&L.push(zo),h("floatingToolbar")&&L.push(_l),h("contextMenu")&&L.push(Bo),h("commandPalette")&&L.push(jl),h("slashCommand")&&L.push($l),h("emoji")&&L.push(ql),v&&L.push(Do),h("customNode")&&L.push(Gl),L}function jt(e){return ar(e)}var Vo=ar();function sr(e){if(!e)return "__default__";let t=Object.entries(e).filter(([,o])=>typeof o=="string"&&o.trim().length>0).sort(([o],[n])=>o.localeCompare(n));return t.length>0?JSON.stringify(t):"__default__"}function ur(e){if(!e)return;let t={},o=(n,i)=>{typeof i=="string"&&i.trim().length>0&&(t[n]=i.trim());};return o("--luthor-fg",e.font?.color),o("--luthor-text-bold-color",e.font?.boldColor),o("--luthor-link-color",e.link?.color),o("--luthor-list-marker-color",e.list?.markerColor),o("--luthor-list-checkbox-color",e.list?.checkboxColor),o("--luthor-quote-bg",e.quote?.backgroundColor),o("--luthor-quote-fg",e.quote?.color),o("--luthor-quote-border",e.quote?.indicatorColor),o("--luthor-table-border-color",e.table?.borderColor),o("--luthor-table-header-bg",e.table?.headerBackgroundColor),o("--luthor-hr-color",e.hr?.color),o("--luthor-placeholder-color",e.placeholder?.color),o("--luthor-codeblock-bg",e.codeblock?.backgroundColor),o("--luthor-toolbar-bg",e.toolbar?.backgroundColor),Object.keys(t).length>0?t:void 0}function cr(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 dr(e,t){if(e.key.toLowerCase()!==t.key.toLowerCase())return false;let o=e.ctrlKey||e.metaKey;return !(!!t.requiresPrimary!==o||!!t.shift!=!!e.shiftKey||!!t.alt!=!!e.altKey)}function mr(e,t,o){let n={...e??{}};for(let[i,r]of Object.entries(o))(Array.isArray(r)?r:[r]).some(u=>t[u]!==false)||(n[i]=false);return n}function gr(e,t,o){let n={...e},i=(r,l)=>{t[r]===false&&l();};return i("bold",()=>{n.toggleBold=()=>{};}),i("italic",()=>{n.toggleItalic=()=>{};}),i("underline",()=>{n.toggleUnderline=()=>{};}),i("strikethrough",()=>{n.toggleStrikethrough=()=>{};}),i("codeFormat",()=>{n.formatText=()=>{};}),i("fontFamily",()=>{n.setFontFamily=()=>{},n.clearFontFamily=()=>{};}),i("fontSize",()=>{n.setFontSize=()=>{},n.clearFontSize=()=>{};}),i("lineHeight",()=>{n.setLineHeight=()=>{},n.clearLineHeight=()=>{};}),i("textColor",()=>{n.setTextColor=()=>{},n.clearTextColor=()=>{};}),i("textHighlight",()=>{n.setTextHighlight=()=>{},n.clearTextHighlight=()=>{};}),i("subscript",()=>{n.toggleSubscript=()=>{};}),i("superscript",()=>{n.toggleSuperscript=()=>{};}),i("link",()=>{n.insertLink=()=>{},n.removeLink=()=>{},n.updateLink=()=>false,n.getCurrentLink=async()=>null,n.getLinkByKey=async()=>null,n.updateLinkByKey=()=>false,n.removeLinkByKey=()=>false;}),i("blockFormat",()=>{n.toggleParagraph=()=>{},n.toggleHeading=()=>{},n.toggleQuote=()=>{},n.setTextAlignment=()=>{};}),i("code",()=>{n.toggleCodeBlock=()=>{};}),i("codeIntelligence",()=>{n.setCodeLanguage=()=>{},n.autoDetectCodeLanguage=async()=>null,n.copySelectedCodeBlock=async()=>false;}),i("list",()=>{n.toggleUnorderedList=()=>{},n.toggleOrderedList=()=>{},n.toggleCheckList=()=>{},n.indentList=()=>{},n.outdentList=()=>{};}),i("horizontalRule",()=>{n.insertHorizontalRule=()=>{};}),i("table",()=>{n.insertTable=()=>{};}),i("image",()=>{n.insertImage=()=>{},n.setImageAlignment=()=>{},n.setImageCaption=()=>{},n.getImageCaption=async()=>"";}),i("emoji",()=>{n.insertEmoji=()=>{},n.executeEmojiSuggestion=()=>false,n.closeEmojiSuggestions=()=>{},n.getEmojiSuggestions=()=>[],n.getEmojiCatalog=()=>[],n.resolveEmojiShortcode=()=>null,n.setEmojiCatalog=()=>{},n.setEmojiCatalogAdapter=()=>{},n.getEmojiCatalogAdapter=()=>({search:()=>[],resolveShortcode:()=>null,getAll:()=>[]});}),i("iframeEmbed",()=>{n.insertIframeEmbed=()=>{},n.setIframeEmbedAlignment=()=>{},n.resizeIframeEmbed=()=>{},n.setIframeEmbedCaption=()=>{},n.getIframeEmbedCaption=async()=>"",n.updateIframeEmbedUrl=()=>false,n.getIframeEmbedUrl=async()=>"";}),i("youTubeEmbed",()=>{n.insertYouTubeEmbed=()=>{},n.setYouTubeEmbedAlignment=()=>{},n.resizeYouTubeEmbed=()=>{},n.setYouTubeEmbedCaption=()=>{},n.getYouTubeEmbedCaption=async()=>"",n.updateYouTubeEmbedUrl=()=>false,n.getYouTubeEmbedUrl=async()=>"";}),i("history",()=>{n.undo=()=>{},n.redo=()=>{};}),i("commandPalette",()=>{n.showCommandPalette=()=>{},n.hideCommandPalette=()=>{},n.registerCommand=()=>{},n.unregisterCommand=()=>{};}),i("slashCommand",()=>{n.registerSlashCommand=()=>{},n.unregisterSlashCommand=()=>{},n.setSlashCommands=()=>{},n.closeSlashMenu=()=>{},n.executeSlashCommand=()=>false;}),o&&(n.toggleBold=()=>{},n.toggleItalic=()=>{},n.toggleUnderline=()=>{},n.toggleStrikethrough=()=>{},n.formatText=()=>{},n.setFontFamily=()=>{},n.clearFontFamily=()=>{},n.setFontSize=()=>{},n.clearFontSize=()=>{},n.setLineHeight=()=>{},n.clearLineHeight=()=>{},n.setTextColor=()=>{},n.clearTextColor=()=>{},n.setTextHighlight=()=>{},n.clearTextHighlight=()=>{},n.toggleSubscript=()=>{},n.toggleSuperscript=()=>{},n.insertLink=()=>{},n.removeLink=()=>{},n.updateLink=()=>false,n.toggleParagraph=()=>{},n.toggleHeading=()=>{},n.toggleQuote=()=>{},n.setTextAlignment=()=>{},n.toggleUnorderedList=()=>{},n.toggleOrderedList=()=>{},n.toggleCheckList=()=>{},n.indentList=()=>{},n.outdentList=()=>{},n.insertHorizontalRule=()=>{},n.insertTable=()=>{},n.insertImage=()=>{},n.setImageAlignment=()=>{},n.setImageCaption=()=>{},n.insertIframeEmbed=()=>{},n.setIframeEmbedAlignment=()=>{},n.resizeIframeEmbed=()=>{},n.setIframeEmbedCaption=()=>{},n.updateIframeEmbedUrl=()=>false,n.insertYouTubeEmbed=()=>{},n.setYouTubeEmbedAlignment=()=>{},n.resizeYouTubeEmbed=()=>{},n.setYouTubeEmbedCaption=()=>{},n.updateYouTubeEmbedUrl=()=>false),n}function hr(e){return new Set(e)}function _o(e,t){e.clear();for(let o of t)e.add(o);}function fr(e,t){return e.has(t)}function pr(e,t){e.add(t);}var z=(e,t=0,o="")=>({type:"text",version:1,text:e,detail:0,format:t,mode:"normal",style:o}),ke=(e,t="",o=0)=>({type:"paragraph",version:1,format:t,indent:o,direction:null,children:e}),jo={root:{type:"root",version:1,format:"",indent:0,direction:null,children:[{type:"heading",version:1,tag:"h1",format:"",indent:0,direction:null,children:[z("Extensive Preset: JSON-First Feature Showcase")]},ke([z("This starter content is now a native "),z("JSON",1),z(" document that demonstrates visual editing without Markdown conversion.")]),{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[z("Inline formatting + typography")]},ke([z("Bold",1),z(" \u2022 "),z("Italic",2),z(" \u2022 "),z("Underline",8),z(" \u2022 "),z("Strikethrough",4),z(" \u2022 "),z("Inline Code",16),z(" \u2022 "),z("Subscript",32),z(" \u2022 "),z("Superscript",64)]),ke([z("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:[z("Centered paragraph with custom style",0,"font-size: 20px; color: #7c3aed;")]},{type:"paragraph",version:1,format:"right",indent:0,direction:null,children:[z("Right-aligned paragraph with highlight",128,"background-color: #fef08a;")]},{type:"quote",version:1,format:"",indent:0,direction:null,children:[z("\u201CEverything in this demo is persisted in JSON and can round-trip via visual mode.\u201D")]},{type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"link",version:1,rel:"noreferrer",target:"_blank",title:"Luthor documentation",url:"https://github.com/facebook/lexical",format:"",indent:0,direction:null,children:[z("Example link node")]},z(" with regular sibling text and emoji support \u{1F389}\u{1F525}\u2705.")]},{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[z("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:[ke([z("Bullet item with styled text",0,"color: #16a34a;")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[ke([z("Nested formatting in lists",1),z(" 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:[ke([z("Numbered item 1")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[ke([z("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:[ke([z("Checked task item")])]},{type:"listitem",version:1,value:2,checked:false,format:"",indent:0,direction:null,children:[ke([z("Unchecked task item")])]}]},{children:[{detail:0,format:0,mode:"normal",style:"",text:"const",type:"code-highlight",version:1,highlightType:"keyword"},{detail:0,format:0,mode:"normal",style:"",text:" content ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"=",type:"code-highlight",version:1,highlightType:"operator"},{detail:0,format:0,mode:"normal",style:"",text:" exportApi",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"toJSON",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"},{type:"linebreak",version:1},{detail:0,format:0,mode:"normal",style:"",text:"await",type:"code-highlight",version:1,highlightType:"keyword"},{detail:0,format:0,mode:"normal",style:"",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"saveToDatabase",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"{",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:" json",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:":",type:"code-highlight",version:1,highlightType:"operator"},{detail:0,format:0,mode:"normal",style:"",text:" content ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"}",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"},{type:"linebreak",version:1},{detail:0,format:0,mode:"normal",style:"",text:"importApi",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"fromJSON",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"content",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"}],direction:null,format:"",indent:0,type:"code",version:1,language:"typescript"},{type:"horizontalrule",version:1},{type:"featureCard",version:1,payload:{title:"AI Draft: Weekly Product Update",description:"This structured block can hold AI-generated draft content that reviewers can quickly edit and approve.",tag:"AI Draft"},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:[ke([z("Feature")])]},{type:"tablecell",version:1,headerState:3,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[ke([z("Status")])]}]},{type:"tablerow",version:1,children:[{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:240,backgroundColor:null,children:[ke([z("Visual \u2194 JSON switching")])]},{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[ke([z("Round-trip ready \u2705")])]}]}]},ke([z("Use the toolbar, floating toolbar, slash commands (/), and command palette (Ctrl/Cmd+Shift+P) to explore the full preset.")])]}};JSON.stringify(jo);var{Provider:ua,useEditor:ca}=createEditorSystem(),br="Write anything...",yr="Enter JSON document content...",vr="Enter Markdown content...",Cr="Enter HTML content...",da=new Set(["auto","scroll","overlay"]),ma={json:"Invalid JSON",markdown:"Invalid Markdown",html:"Invalid HTML"};function ga(e){let t=e.overflowY;return t&&t!=="visible"?t:e.overflow||t||"visible"}function kr(e){if(typeof window>"u")return ()=>{};let t=[],o=e.parentElement;for(;o&&o!==document.body&&o!==document.documentElement;){let n=window.getComputedStyle(o),i=ga(n);if(!da.has(i)){o=o.parentElement;continue}if(o.scrollHeight>o.clientHeight+1)break;if(i==="auto"||i==="overlay"){t.push({element:o,overflowY:o.style.overflowY}),o.style.overflowY="visible",o=o.parentElement;continue}break}return ()=>{for(let n=t.length-1;n>=0;n-=1){let i=t[n];i&&(i.element.style.overflowY=i.overflowY);}}}function ha(e){if(typeof window>"u")return ()=>{};let t=kr(e),o=()=>{t(),t=kr(e);};return window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),t();}}function qo(e){let o=e.replace(/\r\n?/g,`
6
- `).trim().split(/\n{2,}/).map(i=>i.replace(/\s+/g," ").trim()).filter(i=>i.length>0);return {root:{type:"root",version:1,format:"",indent:0,direction:null,children:(o.length>0?o:[""]).map(i=>({type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"text",version:1,text:i,detail:0,format:0,mode:"normal",style:""}]}))}}}function fa(e){try{let t=JSON.parse(e);return JSON.stringify(t)}catch{return JSON.stringify(qo(e))}}function pa(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 ba(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 ya(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 va(e){if(typeof e=="number")return !Number.isFinite(e)||e<1?"1.5":e.toString();if(typeof e=="string"){let o=e.trim();if(o.length===0)return "1.5";let n=Number(o);return !Number.isFinite(n)||n<1?"1.5":n.toString()}return "1.5"}function Ca(e){if(!Number.isFinite(e))return "8";let t=Math.floor(e);return t<0?"8":t.toString()}function $o(e){return sr(e)}function ka(e){if(!e)return "__default__";if(Array.isArray(e))return JSON.stringify({mode:"append",values:e.map(n=>n.trim())});let t=e,o=Array.isArray(t.values)?t.values:[];return JSON.stringify({mode:t.mode??"append",values:o.map(n=>n.trim())})}function Ea(e){return ur(e)}function La(e){let t=_t(e);return JSON.stringify(Ko.map(o=>[o,t[o]]))}function Er(e){return cr(e)}var Ta=[{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 wa(e,t){return dr(e,t)}function Sa(e,t,o){return gr(e,t,o)}var xa={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 Ia(e,t){return mr(e,t,xa)}function Fa(e){if(!e||e.length===0)return [...Ie];let t=new Set,o=[];for(let n of e)!Ie.includes(n)||t.has(n)||(t.add(n),o.push(n));return o.length>0?o:[...Ie]}function Oa(e){if(!e)return "__default__";if(Array.isArray(e)){let r=new Set,l=[];for(let s of e)for(let[u,m]of Object.entries(s)){let E=u.trim();!m||!E||r.has(E)||(r.add(E),l.push(E));}return l.length===0?"__default__":JSON.stringify({allowlist:l,denylist:[]})}let t=r=>{if(!r||r.length===0)return [];let l=new Set,s=[];for(let u of r){let m=u.trim();!m||l.has(m)||(l.add(m),s.push(m));}return s},o=e,n=t(o.allowlist),i=t(o.denylist);return n.length===0&&i.length===0?"__default__":JSON.stringify({allowlist:n,denylist:i})}function Na(e){if(!e||e.length===0)return [];let t=new Set,o=[];for(let n of e){let i=n.trim();!i||t.has(i)||(t.add(i),o.push(i));}return o}function Ma(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 Ha(e){if(!e)return "__default__";let t=Array.isArray(e.disabledCommandIds)?[...e.disabledCommandIds].map(n=>n.trim()).filter(n=>n.length>0).sort((n,i)=>n.localeCompare(i)):[],o=e.bindings?Object.entries(e.bindings).map(([n,i])=>{if(i===false||i===null)return [n,false];let l=(Array.isArray(i)?i:[i]).map(s=>({key:s.key.trim(),ctrlKey:!!s.ctrlKey,metaKey:!!s.metaKey,shiftKey:!!s.shiftKey,altKey:!!s.altKey,preventDefault:s.preventDefault})).filter(s=>s.key.length>0).sort((s,u)=>{let m=`${s.key}:${s.ctrlKey?1:0}:${s.metaKey?1:0}:${s.shiftKey?1:0}:${s.altKey?1:0}`,E=`${u.key}:${u.ctrlKey?1:0}:${u.metaKey?1:0}:${u.shiftKey?1:0}:${u.altKey?1:0}`;return m.localeCompare(E)});return l.length===0?[n,false]:[n,l]}).sort(([n],[i])=>n.localeCompare(i)):[];return JSON.stringify({disabledCommandIds:t,bindings:o,preventCollisions:e.preventCollisions!==false,preventNativeConflicts:e.preventNativeConflicts!==false})}function Ra({isDark:e,toggleTheme:t,visualPlaceholder:o,jsonPlaceholder:n,markdownPlaceholder:i,htmlPlaceholder:r,initialMode:l,availableModes:s,onReady:u,toolbarLayout:m,toolbarVisibility:E,toolbarPosition:C,toolbarAlignment:b,toolbarClassName:f,toolbarStyleVars:p,isToolbarEnabled:h,isToolbarPinned:v,isEditorViewTabsVisible:x,headingOptions:F,paragraphLabel:J,syncHeadingOptionsWithCommands:$,slashCommandVisibility:R,shortcutConfig:re,commandPaletteShortcutOnly:ee,featureFlags:L}){let{commands:te,hasExtension:k,activeStates:V,lexical:T,extensions:q,export:A,import:X}=ca(),[G,Pe]=useState(l),[se,ae]=useState({json:"",markdown:"",html:""}),[W,ce]=useState(null),[me,Oe]=useState(null),[ve,$e]=useState({isOpen:false,commands:[]}),[ge,Ne]=useState({isOpen:false,query:"",position:null,commands:[]}),[de,qe]=useState({isOpen:false,query:"",position:null,suggestions:[]}),ze=useRef(false),M=useMemo(()=>Fa(F),[F]),B=$?M:void 0,ie=$?J:void 0,Ye=V.isInCodeBlock===true,ne=useMemo(()=>Sa(te,L,Ye),[te,L,Ye]),he=useMemo(()=>y=>Object.prototype.hasOwnProperty.call(L,y)?L[y]!==false:true,[L]),st=useMemo(()=>Ia(E,L),[E,L]),Me=L.draggableBlock!==false,Ee=Oa(R),Be=useRef(R),De=useRef(Ee),xe=Ha(re),fe=useRef(re),He=useRef(xe),Ue=useMemo(()=>Na(re?.disabledCommandIds),[re?.disabledCommandIds]),Y=useMemo(()=>new Set(Ue),[Ue]),pe=useMemo(()=>Y.size===0?[]:Co({headingOptions:B,paragraphLabel:ie,isFeatureEnabled:he}).filter(y=>Y.has(y.id)).flatMap(y=>y.shortcuts??[]),[Y,B,ie,he]);De.current!==Ee&&(De.current=Ee,Be.current=R),He.current!==xe&&(He.current=xe,fe.current=re);let Je=useRef(hr(["visual"])),Le=useRef({json:false,markdown:false,html:false}),ut=useRef(0);useEffect(()=>{xo(ne,V,e?"dark":"light",he);},[ne,V,e,he]);let ct=useMemo(()=>({injectJSON:g=>{setTimeout(()=>{try{let d=JSON.parse(g);X.fromJSON(d);}catch(d){console.error("Failed to inject JSON:",d);return}},100);},getJSON:()=>Oo(JSON.stringify(A.toJSON()))}),[A,X]);useEffect(()=>{if(!T||!ne)return;let y=ne,I=Qo(y,{headingOptions:B,paragraphLabel:ie,isFeatureEnabled:he,shortcutConfig:fe.current,commandPaletteShortcutOnly:ee});typeof y.registerCommand=="function"&&I.forEach(w=>y.registerCommand(w));let g=Zo(y,{headingOptions:B,paragraphLabel:ie,slashCommandVisibility:Be.current,isFeatureEnabled:he,shortcutConfig:fe.current});typeof y.setSlashCommands=="function"?y.setSlashCommands(g):g.forEach(w=>y.registerSlashCommand?.(w));let d=tn(y,document.body,{headingOptions:B,paragraphLabel:ie,isFeatureEnabled:he,shortcutConfig:fe.current,scope:()=>T.getRootElement()});return ze.current||(ze.current=true,u?.(ct)),()=>{d(),typeof y.unregisterCommand=="function"&&I.forEach(w=>y.unregisterCommand(w.id)),typeof y.setSlashCommands=="function"?y.setSlashCommands([]):g.forEach(w=>y.unregisterSlashCommand?.(w.id));}},[T,ne,ct,u,B,ie,Ee,xe,he,ee]),useEffect(()=>{let y=()=>T?.getRootElement(),I=Ta.filter(d=>L[d.feature]===false);if(I.length===0)return;let g=d=>{let w=y();w&&d.target instanceof Node&&!w.contains(d.target)||!Er(d.target)||!I.some(_=>wa(d,_))||(d.preventDefault(),d.stopPropagation());};return document.addEventListener("keydown",g,true),()=>{document.removeEventListener("keydown",g,true);}},[T,L]),useEffect(()=>{let y=q.find(I=>I.name==="commandPalette");if(!(!y||!y.subscribe))return y.subscribe((I,g)=>{let d=g.filter(w=>Y.has(w.id)?false:ee?typeof w.shortcut=="string"&&w.shortcut.trim().length>0:true);$e({isOpen:I,commands:d});})},[q,Y,ee]),useEffect(()=>{if(pe.length===0)return;let y=()=>T?.getRootElement(),I=g=>{let d=y();d&&g.target instanceof Node&&!d.contains(g.target)||!Er(g.target)||!pe.some(P=>Ma(g,P))||(g.preventDefault(),g.stopPropagation());};return document.addEventListener("keydown",I,true),()=>{document.removeEventListener("keydown",I,true);}},[T,pe]),useEffect(()=>{let y=q.find(I=>I.name==="slashCommand");if(!(!y||!y.subscribe))return y.subscribe(I=>{Ne({isOpen:I.isOpen,query:I.query,position:I.position,commands:I.commands});})},[q]),useEffect(()=>{let y=q.find(I=>I.name==="emoji");if(!(!y||!y.subscribe))return y.subscribe(I=>{qe({isOpen:I.isOpen,query:I.query,position:I.position,suggestions:I.suggestions});})},[q]),useEffect(()=>!T||!A?void 0:T.registerUpdateListener(()=>{ut.current+=1,_o(Je.current,["visual"]);}),[T,A]);let Ke=y=>{let I=se[y];if(y==="json"){if(!I.trim()){X.fromJSON(qo(""));return}let g=JSON.parse(I);X.fromJSON(g);return}y==="markdown"?X.fromJSON(markdownToJSON(I)):X.fromJSON(htmlToJSON(I)),Le.current[y]=false,_o(Je.current,["visual"]);},dt=y=>{let I=A.toJSON()??qo("");return y==="json"?Oo(JSON.stringify(I)):y==="markdown"?jn(jsonToMarkdown(I)):$n(jsonToHTML(I))},Ge=(y,I,g)=>{ae(d=>({...d,[y]:I})),Le.current[y]=g?.dirty===true;},kt=async y=>{if(y===G||!s.includes(y))return;let I=G,g=null;try{if(Oe(null),I!=="visual"){let d=I;Le.current[d]&&(g=d,Ke(d),await new Promise(w=>setTimeout(w,50)),g=null);}if(I==="visual"&&y!=="visual"&&(T&&clearLexicalSelection(T),T?.getRootElement()?.blur()),Pe(y),y!=="visual"){let d=y;if(!fr(Je.current,d)){ce(d),await new Promise(w=>setTimeout(w,50));try{g=d;let w=dt(d);Ge(d,w),pr(Je.current,d),g=null;}finally{ce(null);}}}y==="visual"&&setTimeout(()=>T?.focus(),100);}catch(d){let w=d instanceof Error?d.message:"Invalid format - could not parse content";g&&Oe({mode:g,error:w});}},mt=h?jsx(Xn,{commands:ne,hasExtension:y=>k(y),activeStates:V,isDark:e,toggleTheme:t,onCommandPaletteOpen:()=>{L.commandPalette!==false&&ne.showCommandPalette();},imageUploadHandler:y=>q.find(I=>I.name==="image")?.config?.uploadHandler?.(y)??Promise.resolve(URL.createObjectURL(y)),layout:m??qt,toolbarVisibility:st,toolbarStyleVars:p,headingOptions:M,paragraphLabel:J,classNames:{toolbar:`luthor-toolbar luthor-toolbar--align-${b}${f?` ${f}`:""}`}}):null,Ve=x,We=G==="visual"&&h&&C==="top",Xe=["luthor-editor-top-region",v&&C==="top"&&Ve?"luthor-editor-top-region--pinned":""].filter(Boolean).join(" "),nt=["luthor-editor-toolbar-slot","luthor-editor-toolbar-slot--top",We&&(v&&C==="top"&&!Ve)?"luthor-editor-toolbar-slot--pinned":""].filter(Boolean).join(" "),Rt=G==="visual"&&h&&C==="bottom",gt=T?.getRootElement()?.closest(".luthor-editor-wrapper")??null,Re=G==="visual"?null:G;return jsxs(Fragment,{children:[jsxs("div",{className:`luthor-editor${Me?"":" luthor-editor--draggable-disabled"}`,"data-mode":G,children:[(Ve||We)&&jsxs("div",{className:Xe,children:[Ve&&jsx("div",{className:"luthor-editor-header",children:jsx(Un,{mode:G,onModeChange:kt,availableModes:s,isConverting:W})}),We&&jsx("div",{className:nt,children:mt})]}),jsxs("div",{className:`luthor-editor-visual-shell${G==="visual"?"":" is-hidden"}${Me?"":" luthor-editor-visual-shell--no-gutter"}`,"aria-hidden":G!=="visual",children:[Me&&jsx("div",{className:"luthor-editor-visual-gutter","aria-hidden":"true"}),jsx(RichText,{placeholder:o,classNames:{container:"luthor-richtext-container luthor-preset-extensive__container",contentEditable:"luthor-content-editable luthor-preset-extensive__content",placeholder:"luthor-placeholder luthor-preset-extensive__placeholder"}})]}),Re&&jsxs("div",{className:"luthor-source-panel",children:[me&&me.mode===Re&&jsxs("div",{className:"luthor-source-error",children:[jsx("div",{className:"luthor-source-error-icon",children:"!"}),jsxs("div",{className:"luthor-source-error-message",children:[jsx("strong",{children:ma[Re]}),jsx("p",{children:me.error}),jsx("small",{children:"Fix the errors above and try switching modes again"})]})]}),Re==="json"&&jsx(ao,{value:se.json,onChange:y=>Ge("json",y,{dirty:true}),placeholder:n}),Re==="markdown"&&jsx(ao,{value:se.markdown,onChange:y=>Ge("markdown",y,{dirty:true}),placeholder:i,className:"luthor-source-view--wrapped",wrap:"soft"}),Re==="html"&&jsx(ao,{value:se.html,onChange:y=>Ge("html",y,{dirty:true}),placeholder:r,className:"luthor-source-view--wrapped",wrap:"soft"})]})]}),jsx(Dn,{editor:T,commands:ne,editorTheme:e?"dark":"light",disabled:G!=="visual"}),Rt&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--bottom",children:mt}),jsx(Ln,{isOpen:ve.isOpen,onClose:()=>ne.hideCommandPalette(),commands:ve.commands}),jsx(Fn,{isOpen:ge.isOpen,query:ge.query,position:ge.position,portalContainer:gt,commands:ge.commands,onClose:()=>ne.closeSlashMenu?.(),onExecute:y=>{ne.executeSlashCommand?.(y);}}),jsx(Sn,{isOpen:de.isOpen,query:de.query,position:de.position,portalContainer:gt,suggestions:de.suggestions,onClose:()=>ne.closeEmojiSuggestions?.(),onExecute:y=>{ne.executeEmojiSuggestion?.(y);}})]})}var yo=forwardRef(({className:e,onReady:t,initialTheme:o="light",onThemeChange:n,theme:i,defaultContent:r,showDefaultContent:l=true,placeholder:s=br,defaultEditorView:u,initialMode:m="visual",isEditorViewTabsVisible:E,isEditorViewsTabVisible:C,availableModes:b=["visual","json","markdown","html"],variantClassName:f,toolbarLayout:p,toolbarVisibility:h,toolbarPosition:v="top",toolbarAlignment:x="left",toolbarClassName:F,toolbarStyleVars:J,quoteClassName:$,quoteStyleVars:R,defaultSettings:re,editorThemeOverrides:ee,isToolbarEnabled:L=true,isToolbarPinned:te=false,fontFamilyOptions:k,fontSizeOptions:V,lineHeightOptions:T,minimumDefaultLineHeight:q=1.5,scaleByRatio:A=false,headingOptions:X,paragraphLabel:G,syncHeadingOptionsWithCommands:Pe=true,slashCommandVisibility:se,shortcutConfig:ae,commandPaletteShortcutOnly:W=false,isDraggableBoxEnabled:ce,featureFlags:me,syntaxHighlighting:Oe,codeHighlightProvider:ve,loadCodeHighlightProvider:$e,maxAutoDetectCodeLength:ge,isCopyAllowed:Ne=true,languageOptions:de,maxListIndentation:qe=8},ze)=>{let[M,B]=useState(o),ie=useRef(null),Ye=M==="dark",ne=u??m,he=b.includes(ne)?ne:b[0]??"visual",st=E??C??true,Me=()=>B(Ye?"light":"dark"),Ee=useMemo(()=>typeof s=="string"?{visual:s,json:yr,markdown:vr,html:Cr}:{visual:s.visual??br,json:s.json??yr,markdown:s.markdown??vr,html:s.html??Cr},[s]);useEffect(()=>{B(o);},[o]),useEffect(()=>{n?.(M);},[M,n]),useEffect(()=>{if(!te||v!=="top")return;let j=ie.current;if(j)return ha(j)},[te,v]);let Be=useMemo(()=>pa(k),[k]),De=useMemo(()=>ba(V),[V]),xe=useMemo(()=>ya(T),[T]),fe=useMemo(()=>va(q),[q]),He=useMemo(()=>Ca(qe),[qe]),Ue=Oe??"unset",Y=typeof ge=="number"?ge.toString():"unset",pe=useMemo(()=>ka(de),[de]),Je=Ne?"copy-on":"copy-off",Le=useMemo(()=>typeof ce!="boolean"?me:{...me??{},draggableBlock:ce},[me,ce]),ut=useMemo(()=>La(Le),[Le]),ct=useMemo(()=>_t(Le),[Le]),Ke=`${Be}::${De}::${xe}::${fe}::${He}::${A?"ratio-on":"ratio-off"}::${Ue}::${Y}::${Je}::${pe}::${ut}`,dt=useRef(k),Ge=useRef(V),kt=useRef(T),mt=useRef(q),Ve=useRef(Le),We=useRef(de),ot=useRef(ve),Xe=useRef($e),Et=useRef(Ke);(Et.current!==Ke||ot.current!==ve||Xe.current!==$e)&&(Et.current=Ke,dt.current=k,Ge.current=V,kt.current=T,mt.current=q,Ve.current=Le,We.current=de,ot.current=ve,Xe.current=$e);let nt=useRef(null);if(!nt.current||nt.current.key!==Ke){let j={fontFamilyOptions:dt.current,fontSizeOptions:Ge.current,lineHeightOptions:kt.current,minimumDefaultLineHeight:mt.current,maxListIndentation:Number(He),scaleByRatio:A,...Oe!==void 0?{syntaxHighlighting:Oe}:{},...ot.current!==void 0?{codeHighlightProvider:ot.current}:{},...Xe.current!==void 0?{loadCodeHighlightProvider:Xe.current}:{},...ge!==void 0?{maxAutoDetectCodeLength:ge}:{},isCopyAllowed:Ne,...We.current!==void 0?{languageOptions:We.current}:{},...typeof ce=="boolean"?{isDraggableBoxEnabled:ce}:{},...Ve.current?{featureFlags:Ve.current}:{}};nt.current={key:Ke,value:jt(j)};}let Rt=nt.current.value,gt=useMemo(()=>{let j=mergeThemes(defaultLuthorTheme,i??{});return $?{...j,quote:`${j.quote??""} ${$}`.trim()}:j},[i,$]),Re=useMemo(()=>$o(ee),[ee]),y=useMemo(()=>$o(R),[R]),I=useMemo(()=>Ea(re),[re]),g=useMemo(()=>$o(I),[I]),d=useMemo(()=>{let j=I,Qe=createEditorThemeStyleVars(ee),$t=R,Yo={"--luthor-default-line-height":fe};return !j&&!Qe&&!$t?Yo:{...j??{},...Qe,...$t??{},...Yo}},[fe,I,ee,R,g,Re,y]),[w,P]=useState(null);useImperativeHandle(ze,()=>w,[w]);let _=j=>{P(j),l&&r===void 0?j.injectJSON(JSON.stringify(jo)):r&&j.injectJSON(fa(r)),t?.(j);};return jsx("div",{ref:ie,className:`luthor-preset luthor-preset-extensive luthor-editor-wrapper${te?" luthor-editor-wrapper--toolbar-pinned":""} ${f||""} ${e||""}`.trim(),"data-editor-theme":M,style:d,children:jsx(ua,{extensions:Rt,config:{theme:gt},children:jsx(Ra,{isDark:Ye,toggleTheme:Me,visualPlaceholder:Ee.visual,jsonPlaceholder:Ee.json,markdownPlaceholder:Ee.markdown,htmlPlaceholder:Ee.html,initialMode:he,availableModes:b,onReady:_,toolbarLayout:p,toolbarVisibility:h,toolbarPosition:v,toolbarAlignment:x,toolbarClassName:F,toolbarStyleVars:J,isToolbarEnabled:L,isToolbarPinned:te,isEditorViewTabsVisible:st,headingOptions:X,paragraphLabel:G,syncHeadingOptionsWithCommands:Pe,slashCommandVisibility:se,shortcutConfig:ae,commandPaletteShortcutOnly:W,featureFlags:ct})})})});yo.displayName="ExtensiveEditor";var Lr=["undo","redo","fontFamily","heading","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"],Tr={id:"extensive",label:"Extensive Editor",description:"Complete editing preset with all core features enabled.",extensions:[...Vo],components:{Editor:yo},toolbar:[...Lr],config:a("extensive","Write anything..."),css:"extensive/styles.css"};function Pa(e={}){return {...Tr,extensions:[...jt({fontFamilyOptions:e.fontFamilyOptions,fontSizeOptions:e.fontSizeOptions,lineHeightOptions:e.lineHeightOptions,minimumDefaultLineHeight:e.minimumDefaultLineHeight,maxListIndentation:e.maxListIndentation,isCopyAllowed:e.isCopyAllowed,languageOptions:e.languageOptions})]}}export{Mn as $,an as A,fr as Aa,sn as B,pr as Ba,un as C,yo as Ca,Va as D,Lr as Da,cn as E,Tr as Ea,_a as F,Pa as Fa,oo as G,dn as H,mn as I,no as J,gn as K,hn as L,fn as M,pn as N,bn as O,Lo as P,yn as Q,vn as R,St as S,Cn as T,Ln as U,Sn as V,Fn as W,N as X,So as Y,Dt as Z,rt as _,Ie as a,Hn as aa,za as b,xo as ba,qt as c,Rn as ca,Co as d,Dn as da,Qo as e,Un as ea,Zo as f,ao as fa,tn as g,Oo as ga,Jt as h,jn as ha,Gt as i,$n as ia,Wt as j,Yi as ja,Xt as k,Ji as ka,Qt as l,Gi as la,on as m,Xn as ma,Lt as n,rr as na,ht as o,_t as oa,Zt as p,ir as pa,eo as q,jt as qa,to as r,Vo as ra,nn as s,sr as sa,rn as t,ur as ta,ko as u,cr as ua,Tt as v,dr as va,ft as w,mr as wa,ln as x,gr as xa,wt as y,hr as ya,Eo as z,_o as za};
5
+ `)}function Oo(e){let t=uo(e).trim();if(!t)return "";try{let o=JSON.parse(t);return JSON.stringify(o,null,2)}catch{return t}}function jn(e){return bi(fi(uo(e))).trim()}function $n(e){let t=uo(e).trim();if(!t)return "";try{return wi(t)}catch{return t}}var Mo=6,Fi=["#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"],Oi=[{title:"1. a. i. style",pattern:"decimal-alpha-roman"},{title:"A. a. i. style",pattern:"upper-alpha-lower-alpha"},{title:"1. 1.1 1.2 style",pattern:"decimal-hierarchical"},{title:"I. A. 1. style",pattern:"upper-roman-upper-alpha"}],Ni=[{title:"Dot / Circle / Square",pattern:"disc-circle-square"},{title:"Arrow / Diamond / Dot",pattern:"arrow-diamond-disc"},{title:"Square / Square / Square",pattern:"square-square-square"},{title:"Arrow / Circle / Square",pattern:"arrow-circle-square"}];function Mi(e){switch(e){case "disc-circle-square":return ["disc","circle","square"];case "arrow-diamond-disc":return ["arrow","diamond","disc"];case "square-square-square":return ["square","square","square"];case "arrow-circle-square":return ["arrow","circle","square"]}}function Hi({type:e,cy:t}){switch(e){case "disc":return jsx("circle",{cx:"16",cy:t,r:"3.2",className:"luthor-unordered-variant-marker"});case "circle":return jsx("circle",{cx:"16",cy:t,r:"3.2",className:"luthor-unordered-variant-marker-open"});case "square":return jsx("rect",{x:"12.8",y:t-3.2,width:"6.4",height:"6.4",className:"luthor-unordered-variant-marker"});case "diamond":return jsx("path",{d:`M16 ${t-3.8} L19.8 ${t} L16 ${t+3.8} L12.2 ${t} Z`,className:"luthor-unordered-variant-marker"});case "arrow":return jsx("path",{d:`M11.6 ${t-2.8} L16.8 ${t} L11.6 ${t+2.8} M11.6 ${t} H19.6`,className:"luthor-unordered-variant-arrow"})}}function Ri({pattern:e}){let t=Mi(e),o=[12.5,24.5,36.5,48.5,60.5],n=e==="disc-circle-square"?[0,1,1,2,0]:e==="arrow-diamond-disc"?[0,1,1,2,0]:e==="square-square-square"?[0,1,2,1,0]:[0,1,1,2,0],i=[t[0],t[1],t[1],t[2],t[0]];return jsxs("svg",{width:"94",height:"74",viewBox:"0 0 94 74",role:"img","aria-hidden":"true",className:"luthor-unordered-variant-svg",children:[jsx("rect",{x:"0.5",y:"0.5",width:"93",height:"73",rx:"3",className:"luthor-unordered-variant-frame"}),o.map((r,l)=>{let s=n[l]??0,u=12+s*12,m=24+s*12,E=57-s*10;return jsxs("g",{children:[jsx("g",{transform:`translate(${u-16}, 0)`,children:jsx(Hi,{type:i[l]??t[0],cy:r})}),jsx("rect",{x:m,y:r-2.5,width:E,height:"5",rx:"2.5",className:"luthor-unordered-variant-line"})]},`${e}-row-${l}`)})]})}function Yn({variant:e}){return jsxs("svg",{width:"78",height:"42",viewBox:"0 0 78 42",role:"img","aria-hidden":"true",className:"luthor-checklist-variant-svg",children:[jsx("rect",{x:"0.5",y:"0.5",width:"77",height:"41",rx:"3",className:"luthor-checklist-variant-frame"}),jsx("rect",{x:"10.5",y:"10.5",width:"10",height:"10",rx:"1.5",className:"luthor-checklist-variant-box"}),jsx("rect",{x:"10.5",y:"24.5",width:"10",height:"10",rx:"1.5",className:"luthor-checklist-variant-box"}),jsx("path",{d:"M12.6 29.2l2 2.2 3.8-4.3",className:"luthor-checklist-variant-check"}),jsx("rect",{x:"26.5",y:"11.8",width:"40",height:"6",rx:"2",className:"luthor-checklist-variant-line"}),jsx("rect",{x:"26.5",y:"25.8",width:"40",height:"6",rx:"2",className:"luthor-checklist-variant-line"}),e==="strikethrough"?jsx(Fragment,{children:jsx("line",{x1:"26.5",y1:"28.8",x2:"66.5",y2:"28.8",className:"luthor-checklist-variant-strike"})}):null]})}function Ai({pattern:e}){let t=[12.5,24.5,36.5,48.5,60.5],o=[0,1,1,2,0],n=e==="decimal-alpha-roman"?["1.","a.","b.","i.","2."]:e==="upper-alpha-lower-alpha"?["A.","a.","b.","i.","B."]:e==="decimal-hierarchical"?["1.","1.1.","1.2.","1.2.1.","2."]:["I.","A.","B.","1.","II."];return jsxs("svg",{width:"94",height:"74",viewBox:"0 0 94 74",role:"img","aria-hidden":"true",className:"luthor-ordered-variant-svg",children:[jsx("rect",{x:"0.5",y:"0.5",width:"93",height:"73",rx:"3",className:"luthor-ordered-variant-frame"}),t.map((i,r)=>{let l=o[r]??0,s=9+l*12,u=26+l*12,m=56-l*10;return jsxs("g",{children:[jsx("text",{x:s,y:i+2.8,className:"luthor-ordered-variant-label",children:n[r]}),jsx("rect",{x:u,y:i-2.5,width:m,height:"5",rx:"2.5",className:"luthor-ordered-variant-line"})]},`${e}-ordered-row-${r}`)})]})}function go(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Pi(e,t){let o=go(t);for(let n of e)if(go(n.value)===o)return n.color;return null}function zi(e,t,o){if(!e||e==="default")return o;let n=Pi(t,e);return n||e}function Bi(e,t){let o=e.trim();return /^#([\da-f]{6})$/i.test(o)?o:/^#([\da-f]{3})$/i.test(o)?`#${o.slice(1).split("").map(i=>`${i}${i}`).join("")}`:t}var Ho="Inherited",mo="16px",Ro="1.5";function ye(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Jn(e){let t=e.split(",")[0]??"";return ye(t.replace(/["']/g,""))}function ho(e){let t=e.trim().toLowerCase().match(/^(-?\d*\.?\d+)px$/);if(!t)return null;let o=Number(t[1]);return Number.isFinite(o)?o:null}function yt(){if(typeof window>"u")return null;let t=window.getSelection()?.anchorNode;if(!t)return null;let o=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!o||!o.closest(".luthor-content-editable"))return null;let i=window.getComputedStyle(o);return {fontFamily:i.fontFamily,fontSize:i.fontSize,lineHeight:i.lineHeight}}function No(){if(typeof window>"u"||typeof document>"u")return null;let e=document.querySelector(".luthor-content-editable");if(!(e instanceof HTMLElement))return null;let t=window.getComputedStyle(e);return {fontFamily:t.fontFamily,fontSize:t.fontSize,lineHeight:t.lineHeight}}function Gn(e){return (e.split(",")[0]?.trim()??"").replace(/^['"]|['"]$/g,"").trim()}function Di(e,t){let o=ye(e);if(o&&o!=="inherit"){let i=Gn(e);if(i)return i}return Gn(t?.fontFamily??"")||Ho}function Ui(e,t){let o=ye(e);return o&&o!=="inherit"?e.trim():(t?.fontSize??"").trim()||mo}function Ki(e,t){let o=ye(e);return o&&o!=="normal"?e.trim():(t?.lineHeight??"").trim()||Ro}function Vi(e,t){if(!e)return null;let o=Jn(e);return o?t.find(i=>ye(i.value)===o?true:Jn(i.fontFamily)===o)?.value??null:null}function _i(e,t){if(!e)return null;let o=ye(e),n=t.find(l=>ye(String(l.value))===o?true:ye(String(l.fontSize))===o);if(n)return String(n.value);let i=ho(e);if(i==null)return null;let r=null;for(let l of t){let s=ho(String(l.fontSize));if(s==null)continue;let u=Math.abs(s-i);(!r||u<r.distance)&&(r={value:String(l.value),distance:u});}return r?.value??null}function ji(e,t,o){if(!e)return null;let n=ye(e),i=o.find(m=>ye(m.value)===n?true:ye(m.lineHeight)===n);if(i)return i.value;let r=t?ho(t):null,l=ho(e),s=null;if(l!=null&&r!=null&&r>0)s=l/r;else {let m=Number(e);Number.isFinite(m)&&(s=m);}if(s==null)return null;let u=null;for(let m of o){let E=Number(m.lineHeight);if(!Number.isFinite(E))continue;let C=Math.abs(E-s);(!u||C<u.distance)&&(u={value:m.value,distance:C});}return u?.value??null}function Wn({title:e,value:t,options:o,recentColors:n,active:i,fallbackColor:r,highlight:l,onChange:s,onClear:u,onAddRecent:m}){let E=useRef(null),C=useRef(null),b=useRef(null),f=useRef(null),p=useRef(null),[h,v]=useState(false),[x,F]=useState(void 0),[J,$]=useState(null),R=zi(t,o,r),re=useMemo(()=>Fi,[]),ee=useMemo(()=>{let k=[...n].slice(0,Mo);for(;k.length<Mo;)k.push("");return k},[n]);useEffect(()=>()=>{f.current&&window.cancelAnimationFrame(f.current);},[]);let L=useCallback(k=>{p.current=k,!f.current&&(f.current=window.requestAnimationFrame(()=>{f.current=null,p.current&&(s(p.current),p.current=null);}));},[s]),te=useCallback(k=>{let V=E.current;if(!V)return;let T=V.getBoundingClientRect(),q=C.current?.getBoundingClientRect(),A=pt(V);$(A);let X=be({anchorRect:T,overlay:{width:q?.width??248,height:q?.height??340},portalContainer:A,gap:6,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});F({...X,visibility:k?"visible":"hidden",...Fe(V)});},[]);return useLayoutEffect(()=>{if(!h)return;te(false);let k=window.requestAnimationFrame(()=>{te(true);});return ()=>{window.cancelAnimationFrame(k);}},[h,te]),useEffect(()=>{if(!h)return;let k=q=>{let A=q.target;E.current?.contains(A)||C.current?.contains(A)||v(false);},V=q=>{q.key==="Escape"&&v(false);},T=()=>te(true);return window.addEventListener("resize",T),window.addEventListener("scroll",T,true),document.addEventListener("mousedown",k),document.addEventListener("keydown",V),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,true),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",V),$(null);}},[h,te]),jsxs(Fragment,{children:[jsxs("button",{ref:E,type:"button",className:`luthor-toolbar-button luthor-color-button${i?" active":""}${l?" is-highlight":""}`,title:e,"aria-label":e,onClick:()=>v(k=>!k),children:[l?jsx(un,{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:R}})]}),h&&typeof document<"u"&&createPortal(jsxs("div",{ref:C,className:"luthor-color-picker",style:x,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:re.map(k=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:k},"aria-label":`Use color ${k}`,onClick:()=>{s(k),m(k),v(false);}},k))})]}),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:ee.map((k,V)=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:k||"transparent"},"aria-label":k?`Use recent color ${k}`:"Empty recent color slot",disabled:!k,onClick:()=>{k&&(s(k),m(k),v(false));}},`${k||"empty"}-${V}`))})]}),jsxs("div",{className:"luthor-color-picker-footer",children:[jsx("button",{type:"button",className:"luthor-color-picker-clear",onClick:()=>{u(),v(false);},children:"Reset to Default"}),jsxs("button",{type:"button",className:"luthor-color-picker-custom",onClick:()=>b.current?.click(),children:[jsx(cn,{size:14}),jsx("span",{children:"Custom Color"})]}),jsx("input",{ref:b,type:"color",className:"luthor-color-picker-native luthor-color-picker-native-hidden",value:Bi(R,r),onInput:k=>{L(k.target.value);},onChange:k=>{let V=k.target.value;s(V),m(V);}})]})]}),J??document.body)]})}function $i(e,t){let o=useRef(null),n=useRef(null);return {handlers:useMemo(()=>({insertFromUrl:()=>{let r=prompt("Enter image URL:");if(!r)return;let l=prompt("Enter alt text:")||"",s=prompt("Enter caption (optional):")||void 0;e.insertImage({src:r,alt:l,caption:s});},insertFromFile:()=>o.current?.click(),insertGifFromUrl:()=>{let r=prompt("Enter GIF URL:");if(!r)return;let l=prompt("Enter alt text (optional):")||"GIF";e.insertImage({src:r,alt:l});},insertGifFromFile:()=>n.current?.click(),handleUpload:async r=>{let l=r.target.files?.[0];if(!l)return;let s;if(t)try{s=await t(l);}catch{alert("Failed to upload image");return}else s=URL.createObjectURL(l);e.insertImage({src:s,alt:l.name,file:l}),r.target.value="";},handleGifUpload:async r=>{let l=r.target.files?.[0];if(!l)return;if(!(l.type==="image/gif"||l.name.toLowerCase().endsWith(".gif"))){alert("Please select a GIF file."),r.target.value="";return}let u;if(t)try{u=await t(l);}catch{alert("Failed to upload GIF");return}else u=URL.createObjectURL(l);e.insertImage({src:u,alt:l.name||"GIF",file:l}),r.target.value="";},setAlignment:r=>{e.setImageAlignment(r);},setCaption:()=>{let r=prompt("Enter caption:")||"";e.setImageCaption(r);}}),[e,t]),fileInputRef:o,gifInputRef:n}}function qi(e){return useMemo(()=>({insertIframe:()=>{let t=prompt("Enter iframe URL:");t&&typeof e.insertIframeEmbed=="function"&&e.insertIframeEmbed(t);},insertYouTube:()=>{let t=prompt("Enter YouTube URL:");t&&typeof e.insertYouTubeEmbed=="function"&&e.insertYouTubeEmbed(t);}}),[e])}function Yi(e,t){switch(e){case "fontFamily":return t("fontFamily");case "fontSize":return t("fontSize");case "lineHeight":return t("lineHeight");case "textColor":return t("textColor");case "textHighlight":return t("textHighlight");case "subscript":return t("subscript");case "superscript":return t("superscript");case "blockFormat":case "quote":case "alignLeft":case "alignCenter":case "alignRight":case "alignJustify":return t("blockFormat");case "codeBlock":return t("code");case "unorderedList":case "orderedList":case "checkList":case "indentList":case "outdentList":return t("list");case "horizontalRule":return t("horizontalRule");case "table":return t("table");case "image":return t("image");case "emoji":return t("emoji");case "embed":return t("iframeEmbed")||t("youtubeEmbed");case "undo":case "redo":return t("history");default:return true}}function Ji(e,t,o){return Yi(e,t)?o?.[e]!==false:false}function Gi(e,t,o){return {sections:e.sections.map(n=>({...n,items:n.items.filter(i=>Ji(i,t,o))})).filter(n=>n.items.length>0)}}function Xn({commands:e,hasExtension:t,activeStates:o,isDark:n,toggleTheme:i,onCommandPaletteOpen:r,imageUploadHandler:l,classNames:s,toolbarStyleVars:u,layout:m,toolbarVisibility:E,headingOptions:C,paragraphLabel:b}){let{handlers:f,fileInputRef:p,gifInputRef:h}=$i(e,l),v=qi(e),x=t("iframeEmbed")||t("youtubeEmbed"),F=o.isIframeEmbedSelected||o.isYouTubeEmbedSelected,[J,$]=useState(false),[R,re]=useState(false),[ee,L]=useState(false),[te,k]=useState(false),[V,T]=useState(false),[q,A]=useState(false),[X,G]=useState(false),[Pe,se]=useState(false),[ae,W]=useState("default"),[ce,me]=useState([{value:"default",label:Ho}]),[Oe,ve]=useState("default"),[$e,ge]=useState([{value:"default",label:mo}]),[Ne,de]=useState("default"),[qe,ze]=useState([{value:"default",label:Ro}]),[M,B]=useState("default"),[ie,Ye]=useState([{value:"default",label:"Default",color:"inherit"}]),[ne,he]=useState([]),[st,Me]=useState("default"),[Ee,Be]=useState([{value:"default",label:"Default",color:"transparent"}]),[De,xe]=useState([]),[fe,He]=useState(0),[Ue,Y]=useState({rows:3,columns:3,includeHeaders:false}),pe=useRef(null),Je=useRef("");useEffect(()=>{if(typeof document>"u")return;let g=()=>{pe.current===null&&(pe.current=window.requestAnimationFrame(()=>{pe.current=null;let d=window.getSelection();if(!d||d.rangeCount===0||!d.getRangeAt(0).collapsed)return;let w=yt();if(!w)return;let P=`${w.fontFamily}|${w.fontSize}|${w.lineHeight}`;P!==Je.current&&(Je.current=P,He(_=>_+1));}));};return document.addEventListener("selectionchange",g),()=>{document.removeEventListener("selectionchange",g),pe.current!==null&&(cancelAnimationFrame(pe.current),pe.current=null);}},[]);let Le=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 g=yt()??No(),d=e.getFontFamilyOptions().map(P=>({value:P.value,label:ye(P.value)==="default"?Di(P.fontFamily,g):P.label})),w=d.length>0?d:[{value:"default",label:Ho}];me(w),W(P=>w.some(_=>_.value===P)?P:"default");},[e,t]),useEffect(()=>{if(!t("fontFamily")||typeof e.getCurrentFontFamily!="function")return;let g=e.getFontFamilyOptions;if(typeof g!="function")return;let d=false;return e.getCurrentFontFamily().then(w=>{if(d)return;if(w&&w!=="default"){W(w);return}let P=yt(),_=Vi(P?.fontFamily,g());W(_??"default");}),()=>{d=true;}},[o,e,t,fe]),useEffect(()=>{if(!t("fontSize")||typeof e.getFontSizeOptions!="function")return;let g=yt()??No(),d=e.getFontSizeOptions().map(_=>({value:String(_.value).trim(),label:ye(String(_.value))==="default"?Ui(String(_.fontSize),g):String(_.label).trim()})).filter(_=>_.value.length>0&&_.label.length>0),w=d.some(_=>ye(_.value)==="default"),P=d.length===0?[{value:"default",label:mo}]:w?d:[{value:"default",label:mo},...d];ge(P),ve(_=>P.some(j=>j.value===_)?_:"default");},[e,t]),useEffect(()=>{if(!t("fontSize")||typeof e.getCurrentFontSize!="function")return;let g=e.getFontSizeOptions;if(typeof g!="function")return;let d=false;return e.getCurrentFontSize().then(w=>{if(d)return;if(w&&w!=="default"){ve(w);return}let P=yt(),_=_i(P?.fontSize,g());ve(_??"default");}),()=>{d=true;}},[o,e,t,fe]),useEffect(()=>{if(!t("lineHeight")||typeof e.getLineHeightOptions!="function")return;let g=yt()??No(),d=e.getLineHeightOptions().map(P=>({value:P.value,label:ye(P.value)==="default"?Ki(P.lineHeight,g):P.label})),w=d.length>0?d:[{value:"default",label:Ro}];ze(w);},[e,t]),useEffect(()=>{if(!t("lineHeight")||typeof e.getCurrentLineHeight!="function")return;let g=e.getLineHeightOptions;if(typeof g!="function")return;let d=false;return e.getCurrentLineHeight().then(w=>{if(d)return;if(w){de(w);return}let P=yt(),_=ji(P?.lineHeight,P?.fontSize,g());de(_??"default");}),()=>{d=true;}},[o,e,t,fe]),useEffect(()=>{if(!t("textColor")||typeof e.getTextColorOptions!="function")return;let g=e.getTextColorOptions().map(d=>({value:d.value,label:d.label,color:d.color}));g.length>0&&Ye(g);},[e,t]),useEffect(()=>{if(!t("textColor")||typeof e.getCurrentTextColor!="function")return;let g=false;return e.getCurrentTextColor().then(d=>{g||B(d??"default");}),()=>{g=true;}},[o,e,t,fe]),useEffect(()=>{if(!t("textHighlight")||typeof e.getTextHighlightOptions!="function")return;let g=e.getTextHighlightOptions().map(d=>({value:d.value,label:d.label,color:d.backgroundColor}));g.length>0&&Be(g);},[e,t]),useEffect(()=>{if(!t("textHighlight")||typeof e.getCurrentTextHighlight!="function")return;let g=false;return e.getCurrentTextHighlight().then(d=>{g||Me(d??"default");}),()=>{g=true;}},[o,e,t,fe]);let ut=useMemo(()=>{if(!C||C.length===0)return [...Ie];let g=new Set,d=[];for(let w of C)!Ie.includes(w)||g.has(w)||(g.add(w),d.push(w));return d.length>0?d:[...Ie]},[C]),ct=b?.trim()||"Paragraph",Ke=useMemo(()=>{let g=ut.map(d=>({value:d,label:`Heading ${d.slice(1)}`}));return [{value:"p",label:ct},...g]},[ut,ct]),dt=o.isH1?"h1":o.isH2?"h2":o.isH3?"h3":o.isH4?"h4":o.isH5?"h5":o.isH6?"h6":"p",Ge=Ke.some(g=>g.value===dt)?dt:"p",kt=g=>{g==="p"?e.toggleParagraph():g.startsWith("h")&&ut.includes(g)&&e.toggleHeading(g);},mt=g=>{g==="default"?e.clearFontFamily?.():e.setFontFamily?.(g),W(g);},Ve=g=>{g==="default"?e.clearFontSize?.():e.setFontSize?.(g),ve(g);},We=g=>{e.setLineHeight?.(g),de(g);},ot=(g,d)=>{g(w=>{let P=go(d),_=w.filter(j=>go(j)!==P);return [d,..._].slice(0,Mo)});},Xe=g=>{if(g==="default"){e.clearTextColor?.(),B("default");return}e.setTextColor?.(g),B(g);},Et=g=>{if(g==="default"){e.clearTextHighlight?.(),Me("default");return}e.setTextHighlight?.(g),Me(g);},nt=g=>{if(typeof e.setOrderedListPattern=="function"){e.setOrderedListPattern(g);return}e.toggleOrderedList();},Rt=g=>{if(typeof e.setUnorderedListPattern=="function"){e.setUnorderedListPattern(g);return}e.toggleUnorderedList();},gt=g=>{if(typeof e.setCheckListVariant=="function"){e.setCheckListVariant(g);return}e.toggleCheckList();},Re=g=>{switch(g){case "fontFamily":return t("fontFamily")?jsx(Dt,{value:ae,onValueChange:mt,options:ce,placeholder:"Font"},"fontFamily"):null;case "fontSize":return t("fontSize")?jsx(Dt,{value:Oe,onValueChange:Ve,options:$e,placeholder:"Size"},"fontSize"):null;case "lineHeight":return t("lineHeight")?jsx(Dt,{value:Ne,onValueChange:We,options:qe,placeholder:"Line"},"lineHeight"):null;case "textColor":return t("textColor")?jsx(Wn,{title:"Text Color",value:M,options:ie,recentColors:ne,active:o.hasCustomTextColor,fallbackColor:"#0f172a",onChange:Xe,onClear:()=>Xe("default"),onAddRecent:d=>ot(he,d)},"textColor"):null;case "textHighlight":return t("textHighlight")?jsx(Wn,{title:"Text Highlight",value:st,options:Ee,recentColors:De,active:o.hasTextHighlight,fallbackColor:"#fef08a",highlight:true,onChange:Et,onClear:()=>Et("default"),onAddRecent:d=>ot(xe,d)},"textHighlight"):null;case "bold":return jsx(N,{onClick:()=>e.toggleBold(),active:o.bold,title:"Bold (Ctrl+B)",children:jsx(Jt,{size:16})},"bold");case "italic":return jsx(N,{onClick:()=>e.toggleItalic(),active:o.italic,title:"Italic (Ctrl+I)",children:jsx(Gt,{size:16})},"italic");case "underline":return jsx(N,{onClick:()=>e.toggleUnderline(),active:o.underline,title:"Underline (Ctrl+U)",children:jsx(Wt,{size:16})},"underline");case "strikethrough":return jsx(N,{onClick:()=>e.toggleStrikethrough(),active:o.strikethrough,title:"Strikethrough",children:jsx(Xt,{size:16})},"strikethrough");case "subscript":return t("subscript")?jsx(N,{onClick:()=>e.toggleSubscript?.(),active:o.subscript,title:"Subscript",children:jsx(bn,{size:16})},"subscript"):null;case "superscript":return t("superscript")?jsx(N,{onClick:()=>e.toggleSuperscript?.(),active:o.superscript,title:"Superscript",children:jsx(yn,{size:16})},"superscript"):null;case "code":return jsx(N,{onClick:()=>e.formatText("code"),active:o.code,title:"Inline Code",children:jsx(Qt,{size:16})},"code");case "link":return jsx(N,{onClick:()=>o.isLink?e.removeLink():e.insertLink(),active:o.isLink,title:o.isLink?"Remove Link":"Insert Link",children:o.isLink?jsx(ht,{size:16}):jsx(Lt,{size:16})},"link");case "blockFormat":return t("blockFormat")?jsx(Dt,{value:Ge,onValueChange:kt,options:Ke,placeholder:"Format"},"blockFormat"):null;case "quote":return t("blockFormat")?jsx(N,{onClick:()=>e.toggleQuote(),active:o.isQuote,title:"Quote",children:jsx(no,{size:16})},"quote"):null;case "alignLeft":return t("blockFormat")?jsx(N,{onClick:()=>e.setTextAlignment("left"),active:o.isTextAlignedLeft,title:"Align Left",children:jsx(Tt,{size:16})},"alignLeft"):null;case "alignCenter":return t("blockFormat")?jsx(N,{onClick:()=>e.setTextAlignment("center"),active:o.isTextAlignedCenter,title:"Align Center",children:jsx(ft,{size:16})},"alignCenter"):null;case "alignRight":return t("blockFormat")?jsx(N,{onClick:()=>e.setTextAlignment("right"),active:o.isTextAlignedRight,title:"Align Right",children:jsx(wt,{size:16})},"alignRight"):null;case "alignJustify":return t("blockFormat")?jsx(N,{onClick:()=>e.setTextAlignment("justify"),active:o.isTextAlignedJustify,title:"Justify",children:jsx(rn,{size:16})},"alignJustify"):null;case "codeBlock":return t("code")?jsx(N,{onClick:()=>e.toggleCodeBlock(),active:o.isInCodeBlock,title:"Code Block",children:jsx(tn,{size:16})},"codeBlock"):null;case "unorderedList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(N,{onClick:()=>e.toggleUnorderedList(),active:o.unorderedList,title:"Bullet List",children:jsx(Zt,{size:16})}),jsx(rt,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${o.unorderedList?" active":""}`,title:"Bullet List Styles","aria-label":"Bullet List Styles",children:jsx(St,{size:12})}),isOpen:V,onOpenChange:T,children:jsx("div",{className:"luthor-unordered-variant-grid",children:Ni.map(d=>jsx("button",{className:"luthor-unordered-variant-option",type:"button",title:d.title,"aria-label":d.title,onClick:()=>{Rt(d.pattern),T(false);},children:jsx(Ri,{pattern:d.pattern})},d.pattern))})})]},"unorderedList"):null;case "orderedList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(N,{onClick:()=>e.toggleOrderedList(),active:o.orderedList,title:"Numbered List",children:jsx(to,{size:16})}),jsx(rt,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${o.orderedList?" active":""}`,title:"Numbered List Styles","aria-label":"Numbered List Styles",children:jsx(St,{size:12})}),isOpen:q,onOpenChange:A,children:jsx("div",{className:"luthor-ordered-variant-grid",children:Oi.map(d=>jsx("button",{className:"luthor-ordered-variant-option",type:"button",title:d.title,"aria-label":d.title,onClick:()=>{nt(d.pattern),A(false);},children:jsx(Ai,{pattern:d.pattern})},d.pattern))})})]},"orderedList"):null;case "checkList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(N,{onClick:()=>e.toggleCheckList(),active:o.checkList,title:"Checklist",children:jsx(eo,{size:16})}),jsx(rt,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${o.checkList?" active":""}`,title:"Checklist Styles","aria-label":"Checklist Styles",children:jsx(St,{size:12})}),isOpen:X,onOpenChange:G,children:jsxs("div",{className:"luthor-checklist-variant-grid",children:[jsx("button",{className:"luthor-checklist-variant-option",type:"button",title:"Checked = Strike through","aria-label":"Checked = Strike through",onClick:()=>{gt("strikethrough"),G(false);},children:jsx(Yn,{variant:"strikethrough"})}),jsx("button",{className:"luthor-checklist-variant-option",type:"button",title:"Checked = Keep text","aria-label":"Checked = Keep text",onClick:()=>{gt("plain"),G(false);},children:jsx(Yn,{variant:"plain"})})]})})]},"checkList"):null;case "indentList":return t("list")?jsx(N,{onClick:()=>e.indentList(),title:"Indent List",children:jsx(mn,{size:14})},"indentList"):null;case "outdentList":return t("list")?jsx(N,{onClick:()=>e.outdentList(),title:"Outdent List",children:jsx(gn,{size:14})},"outdentList"):null;case "horizontalRule":return t("horizontalRule")?jsx(N,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(ln,{size:16})},"horizontalRule"):null;case "table":return t("table")?jsx(N,{onClick:()=>se(true),title:"Insert Table",children:jsx(an,{size:16})},"table"):null;case "image":return t("image")?jsxs(Fragment,{children:[jsxs(rt,{trigger:jsx("button",{className:`luthor-toolbar-button ${o.imageSelected?"active":""}`,title:"Insert Image",children:jsx(ko,{size:16})}),isOpen:J,onOpenChange:$,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertFromUrl(),$(false);},children:[jsx(Lt,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertFromFile(),$(false);},children:[jsx(Eo,{size:16}),jsx("span",{children:"Upload File"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertGifFromUrl(),$(false);},children:[jsx(Lo,{size:16}),jsx("span",{children:"Insert GIF URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertGifFromFile(),$(false);},children:[jsx(Eo,{size:16}),jsx("span",{children:"Upload GIF"})]})]},"image"),o.imageSelected&&jsxs(rt,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(ft,{size:16})}),isOpen:ee,onOpenChange:L,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("left"),L(false);},children:[jsx(Tt,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("center"),L(false);},children:[jsx(ft,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("right"),L(false);},children:[jsx(wt,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setCaption(),L(false);},children:[jsx(dn,{size:16}),jsx("span",{children:"Set Caption"})]})]},"imageAlign")]}):null;case "emoji":return !t("emoji")||Le.length===0?null:jsx(rt,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Insert Emoji",children:jsx(Lo,{size:16})}),isOpen:R,onOpenChange:re,children:jsx("div",{className:"luthor-emoji-picker-grid",role:"listbox","aria-label":"Emoji picker",children:Le.map(d=>jsx("button",{type:"button",className:"luthor-emoji-picker-item",title:d.shortcodes[0]?`${d.label} (:${d.shortcodes[0]}:)`:d.label,onClick:()=>{e.insertEmoji?.(d.emoji),re(false);},children:d.emoji},`${d.emoji}-${d.label}`))})},"emoji");case "embed":return x?jsxs(rt,{trigger:jsx("button",{className:`luthor-toolbar-button ${F?"active":""}`,title:"Insert Embed",children:jsx(sn,{size:16})}),isOpen:te,onOpenChange:k,children:[t("iframeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{v.insertIframe(),k(false);},children:[jsx(Lt,{size:16}),jsx("span",{children:"Embed iframe"})]}):null,t("youtubeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{v.insertYouTube(),k(false);},children:[jsx(ko,{size:16}),jsx("span",{children:"Embed YouTube Video"})]}):null]},"embed"):null;case "undo":return t("history")?jsx(N,{onClick:()=>e.undo(),disabled:!o.canUndo,title:"Undo (Ctrl+Z)",children:jsx(on,{size:16})},"undo"):null;case "redo":return t("history")?jsx(N,{onClick:()=>e.redo(),disabled:!o.canRedo,title:"Redo (Ctrl+Y)",children:jsx(nn,{size:16})},"redo"):null;case "commandPalette":return jsx(N,{onClick:()=>r?.(),title:"Command Palette (Ctrl+Shift+P)",children:jsx(oo,{size:16})},"commandPalette");case "themeToggle":return jsx(N,{onClick:i,title:n?"Light Mode":"Dark Mode",children:n?jsx(hn,{size:16}):jsx(fn,{size:16})},"themeToggle");default:return null}},y=m??qt,I=useMemo(()=>Gi(y,t,E),[y,t,E]);return jsxs(Fragment,{children:[jsx("div",{className:s?.toolbar??"luthor-toolbar",style:u,children:I.sections.map((g,d)=>{let w=g.items.map((P,_)=>{let j=Re(P);return j?Array.isArray(j)?j.map((Qe,$t)=>Qe&&typeof Qe=="object"&&"key"in Qe&&Qe.key!=null?Qe:jsx("span",{children:Qe},`toolbar-item-${d}-${_}-${$t}`)):j.type===Si.Fragment?jsx("span",{children:j},`toolbar-item-${d}-${_}`):j&&typeof j=="object"&&"key"in j&&j.key!=null?j:jsx("span",{children:j},`toolbar-item-${d}-${_}`):null}).flat().filter(P=>P!==null);return w.length===0?null:jsx("div",{className:s?.section??"luthor-toolbar-section",children:w},d)})}),jsx("input",{ref:p,type:"file",accept:"image/*",onChange:f.handleUpload,className:"luthor-file-input"}),jsx("input",{ref:h,type:"file",accept:"image/gif",onChange:f.handleGifUpload,className:"luthor-file-input"}),jsx(Nn,{isOpen:Pe,onClose:()=>se(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:Ue.rows,onChange:g=>Y(d=>({...d,rows:parseInt(g.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:Ue.columns,onChange:g=>Y(d=>({...d,columns:parseInt(g.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:Ue.includeHeaders||false,onChange:g=>Y(d=>({...d,includeHeaders:g.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(So,{variant:"secondary",onClick:()=>se(false),children:"Cancel"}),jsx(So,{variant:"primary",onClick:()=>{e.insertTable(Ue),se(false);},children:"Insert Table"})]})]})})]})}var Ko=["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"],rr={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 _t(e){let t={...rr};if(!e)return t;for(let o of Ko)typeof e[o]=="boolean"&&(t[o]=e[o]);return t}function ir(e,t){return e[t]!==false}var er=8,tr=[{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"}],wl={value:"default",label:"Default",fontFamily:"inherit"},or=[{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"}],Sl={value:"default",label:"Default",fontSize:"inherit"},nr=[{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"}],xl={value:"default",label:"Default",lineHeight:"1.5"},Vt="1.5",Il=1;function vt(e){return e.trim().toLowerCase()}function lr(e){return /^[a-z0-9][a-z0-9-]*$/i.test(e)}function Fl(e){return vt(e)==="default"?true:po(e)!==null}function Ol(e){let t=e??tr,o=new Set,n=[];for(let r of t){let l=r.value.trim(),s=r.label.trim(),u=r.fontFamily.trim();if(!l||!s||!u||!lr(l))continue;let m=vt(l);o.has(m)||(o.add(m),n.push({value:l,label:s,fontFamily:u,cssImportUrl:r.cssImportUrl?.trim()||void 0}));}return n.length===0?tr:n.some(r=>vt(r.value)==="default")?n:[wl,...n]}function Nl(e){let t=e??or,o=new Set,n=[];for(let r of t){let l=String(r.value).trim(),s=String(r.label).trim(),u=String(r.fontSize).trim();if(!l||!s||!u||!lr(l))continue;let m=vt(l);o.has(m)||(o.add(m),n.push({value:l,label:s,fontSize:u}));}return n.length===0?or:n.some(r=>vt(r.value)==="default")?n:[Sl,...n]}function po(e){let t=e.trim();if(!/^\d*\.?\d+$/.test(t))return null;let o=Number(t);return !Number.isFinite(o)||o<Il?null:o.toString()}function Ml(e){if(!Number.isFinite(e))return er;let t=Math.floor(e);return t>=0?t:er}function Hl(e){return typeof e=="number"?Number.isFinite(e)?po(e.toString())??Vt:Vt:typeof e=="string"?po(e)??Vt:Vt}function Rl(e,t=Vt){let o=e??nr,n=new Set,i=[];for(let l of o){let s=String(l.value).trim(),u=String(l.label).trim();if(!s||!u||!Fl(s))continue;let m=vt(s);if(n.has(m))continue;if(m==="default"){n.add(m),i.push({value:s,label:u,lineHeight:t});continue}let E=po(String(l.lineHeight));E&&(n.add(m),i.push({value:s,label:u,lineHeight:E}));}return i.length===0?nr:i.some(l=>vt(l.value)==="default")?i:[{...xl,lineHeight:t},...i]}function at({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 Al=()=>jsxs(at,{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"})]}),Pl=()=>jsxs(at,{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"})]}),zl=()=>jsxs(at,{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"})]}),Bl=()=>jsxs(at,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M12.5 5v14"}),jsx("path",{d:"M16.5 10.5v3"}),jsx("path",{d:"M16.8 12h4.4"}),jsx("path",{d:"M19 9.8v4.4"})]}),Dl=()=>jsxs(at,{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"})]}),Ul=()=>jsxs(at,{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"})]}),Kl=()=>jsxs(at,{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"})]}),Vl=()=>jsxs(at,{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"})]}),bo=new ImageExtension;bo.config={...bo.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var Ao=new TableExtension;Ao.config={...Ao.config,enableContextMenu:true,tableBubbleRenderer:({headersEnabled:e,setHeadersEnabled:t,actions:o})=>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:o.insertRowAbove,children:jsx(Al,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert row below","aria-label":"Insert row below",onClick:o.insertRowBelow,children:jsx(Pl,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column left","aria-label":"Insert column left",onClick:o.insertColumnLeft,children:jsx(zl,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column right","aria-label":"Insert column right",onClick:o.insertColumnRight,children:jsx(Bl,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected row","aria-label":"Delete selected row",onClick:o.deleteSelectedRow,children:jsx(Dl,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected column","aria-label":"Delete selected column",onClick:o.deleteSelectedColumn,children:jsx(Ul,{})}),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(Vl,{})})}),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:o.deleteTable,children:jsx(Kl,{})})]})};var Po=new IframeEmbedExtension;Po.config={...Po.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center"};var zo=new YouTubeEmbedExtension;zo.config={...zo.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center",nocookie:true,controls:true,rel:1};var _l=Hn(),Bo=new ContextMenuExtension;Bo.config={...Bo.config,preventDefault:true};var jl=new CommandPaletteExtension,$l=new SlashCommandExtension,ql=new EmojiExtension,Do=new DraggableBlockExtension;Do.config={...Do.config,buttonStackPosition:"left"};var Uo=new LinkExtension;Uo.config={...Uo.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var Yl=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"}]}),Jl=textHighlightExtension.configure({options:[{value:"default",label:"Default",backgroundColor:"transparent"},{value:"yellow",label:"Yellow",backgroundColor:"#fef08a"},{value:"green",label:"Green",backgroundColor:"#bbf7d0"},{value:"blue",label:"Blue",backgroundColor:"#bfdbfe"},{value:"pink",label:"Pink",backgroundColor:"#fbcfe8"},{value:"orange",label:"Orange",backgroundColor:"#fed7aa"}]}),{extension:Gl}=createCustomNodeExtension({nodeType:"featureCard",defaultPayload:{title:"AI Draft Block",description:"AI-generated first draft. Review and edit before publishing to customers.",tag:"AI Draft"},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??"AI Draft"}),jsx("h4",{className:"luthor-extensive-feature-card__title",children:e.title??"Generated Draft"}),jsx("p",{className:"luthor-extensive-feature-card__description",children:e.description??"AI-generated first pass. Review and finalize before sharing."})]})});function ar({fontFamilyOptions:e,fontSizeOptions:t,lineHeightOptions:o,minimumDefaultLineHeight:n,featureFlags:i,isDraggableBoxEnabled:r,scaleByRatio:l,syntaxHighlighting:s,codeHighlightProvider:u,loadCodeHighlightProvider:m,maxAutoDetectCodeLength:E,isCopyAllowed:C,languageOptions:b,maxListIndentation:f}={}){let p=_t(i),h=te=>ir(p,te),v=(r??true)&&h("draggableBlock"),x=Hl(n),F=Ml(f),J=new FontFamilyExtension().configure({options:Ol(e),cssLoadStrategy:"on-demand"}),$=new FontSizeExtension().configure({options:Nl(t)}),R=new LineHeightExtension().configure({options:Rl(o,x),defaultLineHeight:x});bo.configure({scaleByRatio:l??false}),codeExtension.configure({syntaxHighlighting:s??"auto",provider:u??void 0,loadProvider:m}),codeIntelligenceExtension.configure({provider:u??void 0,loadProvider:m,maxAutoDetectLength:E,isCopyAllowed:C??true,languageOptions:b});let re=new ListExtension({maxDepth:F+1}),ee=new TabIndentExtension({maxListDepth:F+1}),L=[];return h("bold")&&L.push(boldExtension),h("italic")&&L.push(italicExtension),h("underline")&&L.push(underlineExtension),h("strikethrough")&&L.push(strikethroughExtension),h("fontFamily")&&L.push(J),h("fontSize")&&L.push($),h("lineHeight")&&L.push(R),h("textColor")&&L.push(Yl),h("textHighlight")&&L.push(Jl),h("subscript")&&L.push(subscriptExtension),h("superscript")&&L.push(superscriptExtension),h("link")&&L.push(Uo),h("horizontalRule")&&L.push(horizontalRuleExtension),h("table")&&L.push(Ao),h("list")&&L.push(re),h("history")&&L.push(historyExtension),h("image")&&L.push(bo),h("blockFormat")&&L.push(blockFormatExtension),h("code")&&L.push(codeExtension),h("codeIntelligence")&&L.push(codeIntelligenceExtension),h("codeFormat")&&L.push(codeFormatExtension),h("tabIndent")&&L.push(ee),h("enterKeyBehavior")&&L.push(enterKeyBehaviorExtension),h("iframeEmbed")&&L.push(Po),h("youTubeEmbed")&&L.push(zo),h("floatingToolbar")&&L.push(_l),h("contextMenu")&&L.push(Bo),h("commandPalette")&&L.push(jl),h("slashCommand")&&L.push($l),h("emoji")&&L.push(ql),v&&L.push(Do),h("customNode")&&L.push(Gl),L}function jt(e){return ar(e)}var Vo=ar();function sr(e){if(!e)return "__default__";let t=Object.entries(e).filter(([,o])=>typeof o=="string"&&o.trim().length>0).sort(([o],[n])=>o.localeCompare(n));return t.length>0?JSON.stringify(t):"__default__"}function ur(e){if(!e)return;let t={},o=(n,i)=>{typeof i=="string"&&i.trim().length>0&&(t[n]=i.trim());};return o("--luthor-fg",e.font?.color),o("--luthor-text-bold-color",e.font?.boldColor),o("--luthor-link-color",e.link?.color),o("--luthor-list-marker-color",e.list?.markerColor),o("--luthor-list-checkbox-color",e.list?.checkboxColor),o("--luthor-quote-bg",e.quote?.backgroundColor),o("--luthor-quote-fg",e.quote?.color),o("--luthor-quote-border",e.quote?.indicatorColor),o("--luthor-table-border-color",e.table?.borderColor),o("--luthor-table-header-bg",e.table?.headerBackgroundColor),o("--luthor-hr-color",e.hr?.color),o("--luthor-placeholder-color",e.placeholder?.color),o("--luthor-codeblock-bg",e.codeblock?.backgroundColor),o("--luthor-toolbar-bg",e.toolbar?.backgroundColor),Object.keys(t).length>0?t:void 0}function cr(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 dr(e,t){if(e.key.toLowerCase()!==t.key.toLowerCase())return false;let o=e.ctrlKey||e.metaKey;return !(!!t.requiresPrimary!==o||!!t.shift!=!!e.shiftKey||!!t.alt!=!!e.altKey)}function mr(e,t,o){let n={...e??{}};for(let[i,r]of Object.entries(o))(Array.isArray(r)?r:[r]).some(u=>t[u]!==false)||(n[i]=false);return n}function gr(e,t,o){let n={...e},i=(r,l)=>{t[r]===false&&l();};return i("bold",()=>{n.toggleBold=()=>{};}),i("italic",()=>{n.toggleItalic=()=>{};}),i("underline",()=>{n.toggleUnderline=()=>{};}),i("strikethrough",()=>{n.toggleStrikethrough=()=>{};}),i("codeFormat",()=>{n.formatText=()=>{};}),i("fontFamily",()=>{n.setFontFamily=()=>{},n.clearFontFamily=()=>{};}),i("fontSize",()=>{n.setFontSize=()=>{},n.clearFontSize=()=>{};}),i("lineHeight",()=>{n.setLineHeight=()=>{},n.clearLineHeight=()=>{};}),i("textColor",()=>{n.setTextColor=()=>{},n.clearTextColor=()=>{};}),i("textHighlight",()=>{n.setTextHighlight=()=>{},n.clearTextHighlight=()=>{};}),i("subscript",()=>{n.toggleSubscript=()=>{};}),i("superscript",()=>{n.toggleSuperscript=()=>{};}),i("link",()=>{n.insertLink=()=>{},n.removeLink=()=>{},n.updateLink=()=>false,n.getCurrentLink=async()=>null,n.getLinkByKey=async()=>null,n.updateLinkByKey=()=>false,n.removeLinkByKey=()=>false;}),i("blockFormat",()=>{n.toggleParagraph=()=>{},n.toggleHeading=()=>{},n.toggleQuote=()=>{},n.setTextAlignment=()=>{};}),i("code",()=>{n.toggleCodeBlock=()=>{};}),i("codeIntelligence",()=>{n.setCodeLanguage=()=>{},n.autoDetectCodeLanguage=async()=>null,n.copySelectedCodeBlock=async()=>false;}),i("list",()=>{n.toggleUnorderedList=()=>{},n.toggleOrderedList=()=>{},n.toggleCheckList=()=>{},n.indentList=()=>{},n.outdentList=()=>{};}),i("horizontalRule",()=>{n.insertHorizontalRule=()=>{};}),i("table",()=>{n.insertTable=()=>{};}),i("image",()=>{n.insertImage=()=>{},n.setImageAlignment=()=>{},n.setImageCaption=()=>{},n.getImageCaption=async()=>"";}),i("emoji",()=>{n.insertEmoji=()=>{},n.executeEmojiSuggestion=()=>false,n.closeEmojiSuggestions=()=>{},n.getEmojiSuggestions=()=>[],n.getEmojiCatalog=()=>[],n.resolveEmojiShortcode=()=>null,n.setEmojiCatalog=()=>{},n.setEmojiCatalogAdapter=()=>{},n.getEmojiCatalogAdapter=()=>({search:()=>[],resolveShortcode:()=>null,getAll:()=>[]});}),i("iframeEmbed",()=>{n.insertIframeEmbed=()=>{},n.setIframeEmbedAlignment=()=>{},n.resizeIframeEmbed=()=>{},n.setIframeEmbedCaption=()=>{},n.getIframeEmbedCaption=async()=>"",n.updateIframeEmbedUrl=()=>false,n.getIframeEmbedUrl=async()=>"";}),i("youTubeEmbed",()=>{n.insertYouTubeEmbed=()=>{},n.setYouTubeEmbedAlignment=()=>{},n.resizeYouTubeEmbed=()=>{},n.setYouTubeEmbedCaption=()=>{},n.getYouTubeEmbedCaption=async()=>"",n.updateYouTubeEmbedUrl=()=>false,n.getYouTubeEmbedUrl=async()=>"";}),i("history",()=>{n.undo=()=>{},n.redo=()=>{};}),i("commandPalette",()=>{n.showCommandPalette=()=>{},n.hideCommandPalette=()=>{},n.registerCommand=()=>{},n.unregisterCommand=()=>{};}),i("slashCommand",()=>{n.registerSlashCommand=()=>{},n.unregisterSlashCommand=()=>{},n.setSlashCommands=()=>{},n.closeSlashMenu=()=>{},n.executeSlashCommand=()=>false;}),o&&(n.toggleBold=()=>{},n.toggleItalic=()=>{},n.toggleUnderline=()=>{},n.toggleStrikethrough=()=>{},n.formatText=()=>{},n.setFontFamily=()=>{},n.clearFontFamily=()=>{},n.setFontSize=()=>{},n.clearFontSize=()=>{},n.setLineHeight=()=>{},n.clearLineHeight=()=>{},n.setTextColor=()=>{},n.clearTextColor=()=>{},n.setTextHighlight=()=>{},n.clearTextHighlight=()=>{},n.toggleSubscript=()=>{},n.toggleSuperscript=()=>{},n.insertLink=()=>{},n.removeLink=()=>{},n.updateLink=()=>false,n.toggleParagraph=()=>{},n.toggleHeading=()=>{},n.toggleQuote=()=>{},n.setTextAlignment=()=>{},n.toggleUnorderedList=()=>{},n.toggleOrderedList=()=>{},n.toggleCheckList=()=>{},n.indentList=()=>{},n.outdentList=()=>{},n.insertHorizontalRule=()=>{},n.insertTable=()=>{},n.insertImage=()=>{},n.setImageAlignment=()=>{},n.setImageCaption=()=>{},n.insertIframeEmbed=()=>{},n.setIframeEmbedAlignment=()=>{},n.resizeIframeEmbed=()=>{},n.setIframeEmbedCaption=()=>{},n.updateIframeEmbedUrl=()=>false,n.insertYouTubeEmbed=()=>{},n.setYouTubeEmbedAlignment=()=>{},n.resizeYouTubeEmbed=()=>{},n.setYouTubeEmbedCaption=()=>{},n.updateYouTubeEmbedUrl=()=>false),n}function hr(e){return new Set(e)}function _o(e,t){e.clear();for(let o of t)e.add(o);}function fr(e,t){return e.has(t)}function pr(e,t){e.add(t);}var z=(e,t=0,o="")=>({type:"text",version:1,text:e,detail:0,format:t,mode:"normal",style:o}),ke=(e,t="",o=0)=>({type:"paragraph",version:1,format:t,indent:o,direction:null,children:e}),jo={root:{type:"root",version:1,format:"",indent:0,direction:null,children:[{type:"heading",version:1,tag:"h1",format:"",indent:0,direction:null,children:[z("Extensive Preset: JSON-First Feature Showcase")]},ke([z("This starter content is now a native "),z("JSON",1),z(" document that demonstrates visual editing without Markdown conversion.")]),{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[z("Inline formatting + typography")]},ke([z("Bold",1),z(" \u2022 "),z("Italic",2),z(" \u2022 "),z("Underline",8),z(" \u2022 "),z("Strikethrough",4),z(" \u2022 "),z("Inline Code",16),z(" \u2022 "),z("Subscript",32),z(" \u2022 "),z("Superscript",64)]),ke([z("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:[z("Centered paragraph with custom style",0,"font-size: 20px; color: #7c3aed;")]},{type:"paragraph",version:1,format:"right",indent:0,direction:null,children:[z("Right-aligned paragraph with highlight",128,"background-color: #fef08a;")]},{type:"quote",version:1,format:"",indent:0,direction:null,children:[z("\u201CEverything in this demo is persisted in JSON and can round-trip via visual mode.\u201D")]},{type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"link",version:1,rel:"noreferrer",target:"_blank",title:"Luthor documentation",url:"https://github.com/facebook/lexical",format:"",indent:0,direction:null,children:[z("Example link node")]},z(" with regular sibling text and emoji support \u{1F389}\u{1F525}\u2705.")]},{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[z("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:[ke([z("Bullet item with styled text",0,"color: #16a34a;")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[ke([z("Nested formatting in lists",1),z(" 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:[ke([z("Numbered item 1")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[ke([z("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:[ke([z("Checked task item")])]},{type:"listitem",version:1,value:2,checked:false,format:"",indent:0,direction:null,children:[ke([z("Unchecked task item")])]}]},{children:[{detail:0,format:0,mode:"normal",style:"",text:"const",type:"code-highlight",version:1,highlightType:"keyword"},{detail:0,format:0,mode:"normal",style:"",text:" content ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"=",type:"code-highlight",version:1,highlightType:"operator"},{detail:0,format:0,mode:"normal",style:"",text:" exportApi",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"toJSON",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"},{type:"linebreak",version:1},{detail:0,format:0,mode:"normal",style:"",text:"await",type:"code-highlight",version:1,highlightType:"keyword"},{detail:0,format:0,mode:"normal",style:"",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"saveToDatabase",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"{",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:" json",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:":",type:"code-highlight",version:1,highlightType:"operator"},{detail:0,format:0,mode:"normal",style:"",text:" content ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"}",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"},{type:"linebreak",version:1},{detail:0,format:0,mode:"normal",style:"",text:"importApi",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"fromJSON",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"content",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"}],direction:null,format:"",indent:0,type:"code",version:1,language:"typescript"},{type:"horizontalrule",version:1},{type:"featureCard",version:1,payload:{title:"AI Draft: Weekly Product Update",description:"This structured block can hold AI-generated draft content that reviewers can quickly edit and approve.",tag:"AI Draft"},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:[ke([z("Feature")])]},{type:"tablecell",version:1,headerState:3,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[ke([z("Status")])]}]},{type:"tablerow",version:1,children:[{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:240,backgroundColor:null,children:[ke([z("Visual \u2194 JSON switching")])]},{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[ke([z("Round-trip ready \u2705")])]}]}]},ke([z("Use the toolbar, floating toolbar, slash commands (/), and command palette (Ctrl/Cmd+Shift+P) to explore the full preset.")])]}};JSON.stringify(jo);var{Provider:ua,useEditor:ca}=createEditorSystem(),br="Write anything...",yr="Enter JSON document content...",vr="Enter Markdown content...",Cr="Enter HTML content...",da=new Set(["auto","scroll","overlay"]),ma={json:"Invalid JSON",markdown:"Invalid Markdown",html:"Invalid HTML"};function ga(e){let t=e.overflowY;return t&&t!=="visible"?t:e.overflow||t||"visible"}function kr(e){if(typeof window>"u")return ()=>{};let t=[],o=e.parentElement;for(;o&&o!==document.body&&o!==document.documentElement;){let n=window.getComputedStyle(o),i=ga(n);if(!da.has(i)){o=o.parentElement;continue}if(o.scrollHeight>o.clientHeight+1)break;if(i==="auto"||i==="overlay"){t.push({element:o,overflowY:o.style.overflowY}),o.style.overflowY="visible",o=o.parentElement;continue}break}return ()=>{for(let n=t.length-1;n>=0;n-=1){let i=t[n];i&&(i.element.style.overflowY=i.overflowY);}}}function ha(e){if(typeof window>"u")return ()=>{};let t=kr(e),o=()=>{t(),t=kr(e);};return window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),t();}}function qo(e){let o=e.replace(/\r\n?/g,`
6
+ `).trim().split(/\n{2,}/).map(i=>i.replace(/\s+/g," ").trim()).filter(i=>i.length>0);return {root:{type:"root",version:1,format:"",indent:0,direction:null,children:(o.length>0?o:[""]).map(i=>({type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"text",version:1,text:i,detail:0,format:0,mode:"normal",style:""}]}))}}}function fa(e){try{let t=JSON.parse(e);return JSON.stringify(t)}catch{return JSON.stringify(qo(e))}}function pa(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 ba(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 ya(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 va(e){if(typeof e=="number")return !Number.isFinite(e)||e<1?"1.5":e.toString();if(typeof e=="string"){let o=e.trim();if(o.length===0)return "1.5";let n=Number(o);return !Number.isFinite(n)||n<1?"1.5":n.toString()}return "1.5"}function Ca(e){if(!Number.isFinite(e))return "8";let t=Math.floor(e);return t<0?"8":t.toString()}function $o(e){return sr(e)}function ka(e){if(!e)return "__default__";if(Array.isArray(e))return JSON.stringify({mode:"append",values:e.map(n=>n.trim())});let t=e,o=Array.isArray(t.values)?t.values:[];return JSON.stringify({mode:t.mode??"append",values:o.map(n=>n.trim())})}function Ea(e){return ur(e)}function La(e){let t=_t(e);return JSON.stringify(Ko.map(o=>[o,t[o]]))}function Er(e){return cr(e)}var Ta=[{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 wa(e,t){return dr(e,t)}function Sa(e,t,o){return gr(e,t,o)}var xa={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 Ia(e,t){return mr(e,t,xa)}function Fa(e){if(!e||e.length===0)return [...Ie];let t=new Set,o=[];for(let n of e)!Ie.includes(n)||t.has(n)||(t.add(n),o.push(n));return o.length>0?o:[...Ie]}function Oa(e){if(!e)return "__default__";if(Array.isArray(e)){let r=new Set,l=[];for(let s of e)for(let[u,m]of Object.entries(s)){let E=u.trim();!m||!E||r.has(E)||(r.add(E),l.push(E));}return l.length===0?"__default__":JSON.stringify({allowlist:l,denylist:[]})}let t=r=>{if(!r||r.length===0)return [];let l=new Set,s=[];for(let u of r){let m=u.trim();!m||l.has(m)||(l.add(m),s.push(m));}return s},o=e,n=t(o.allowlist),i=t(o.denylist);return n.length===0&&i.length===0?"__default__":JSON.stringify({allowlist:n,denylist:i})}function Na(e){if(!e||e.length===0)return [];let t=new Set,o=[];for(let n of e){let i=n.trim();!i||t.has(i)||(t.add(i),o.push(i));}return o}function Ma(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 Ha(e){if(!e)return "__default__";let t=Array.isArray(e.disabledCommandIds)?[...e.disabledCommandIds].map(n=>n.trim()).filter(n=>n.length>0).sort((n,i)=>n.localeCompare(i)):[],o=e.bindings?Object.entries(e.bindings).map(([n,i])=>{if(i===false||i===null)return [n,false];let l=(Array.isArray(i)?i:[i]).map(s=>({key:s.key.trim(),ctrlKey:!!s.ctrlKey,metaKey:!!s.metaKey,shiftKey:!!s.shiftKey,altKey:!!s.altKey,preventDefault:s.preventDefault})).filter(s=>s.key.length>0).sort((s,u)=>{let m=`${s.key}:${s.ctrlKey?1:0}:${s.metaKey?1:0}:${s.shiftKey?1:0}:${s.altKey?1:0}`,E=`${u.key}:${u.ctrlKey?1:0}:${u.metaKey?1:0}:${u.shiftKey?1:0}:${u.altKey?1:0}`;return m.localeCompare(E)});return l.length===0?[n,false]:[n,l]}).sort(([n],[i])=>n.localeCompare(i)):[];return JSON.stringify({disabledCommandIds:t,bindings:o,preventCollisions:e.preventCollisions!==false,preventNativeConflicts:e.preventNativeConflicts!==false})}function Ra({isDark:e,toggleTheme:t,visualPlaceholder:o,jsonPlaceholder:n,markdownPlaceholder:i,htmlPlaceholder:r,initialMode:l,availableModes:s,onReady:u,toolbarLayout:m,toolbarVisibility:E,toolbarPosition:C,toolbarAlignment:b,toolbarClassName:f,toolbarStyleVars:p,isToolbarEnabled:h,isToolbarPinned:v,isEditorViewTabsVisible:x,headingOptions:F,paragraphLabel:J,syncHeadingOptionsWithCommands:$,slashCommandVisibility:R,shortcutConfig:re,commandPaletteShortcutOnly:ee,featureFlags:L}){let{commands:te,hasExtension:k,activeStates:V,lexical:T,extensions:q,export:A,import:X}=ca(),[G,Pe]=useState(l),[se,ae]=useState({json:"",markdown:"",html:""}),[W,ce]=useState(null),[me,Oe]=useState(null),[ve,$e]=useState({isOpen:false,commands:[]}),[ge,Ne]=useState({isOpen:false,query:"",position:null,commands:[]}),[de,qe]=useState({isOpen:false,query:"",position:null,suggestions:[]}),ze=useRef(false),M=useMemo(()=>Fa(F),[F]),B=$?M:void 0,ie=$?J:void 0,Ye=V.isInCodeBlock===true,ne=useMemo(()=>Sa(te,L,Ye),[te,L,Ye]),he=useMemo(()=>y=>Object.prototype.hasOwnProperty.call(L,y)?L[y]!==false:true,[L]),st=useMemo(()=>Ia(E,L),[E,L]),Me=L.draggableBlock!==false,Ee=Oa(R),Be=useRef(R),De=useRef(Ee),xe=Ha(re),fe=useRef(re),He=useRef(xe),Ue=useMemo(()=>Na(re?.disabledCommandIds),[re?.disabledCommandIds]),Y=useMemo(()=>new Set(Ue),[Ue]),pe=useMemo(()=>Y.size===0?[]:Co({headingOptions:B,paragraphLabel:ie,isFeatureEnabled:he}).filter(y=>Y.has(y.id)).flatMap(y=>y.shortcuts??[]),[Y,B,ie,he]);De.current!==Ee&&(De.current=Ee,Be.current=R),He.current!==xe&&(He.current=xe,fe.current=re);let Je=useRef(hr(["visual"])),Le=useRef({json:false,markdown:false,html:false}),ut=useRef(0);useEffect(()=>{xo(ne,V,e?"dark":"light",he);},[ne,V,e,he]);let ct=useMemo(()=>({injectJSON:g=>{setTimeout(()=>{try{let d=JSON.parse(g);X.fromJSON(d);}catch(d){console.error("Failed to inject JSON:",d);return}},100);},getJSON:()=>Oo(JSON.stringify(A.toJSON()))}),[A,X]);useEffect(()=>{if(!T||!ne)return;let y=ne,I=Xo(y,{headingOptions:B,paragraphLabel:ie,isFeatureEnabled:he,shortcutConfig:fe.current,commandPaletteShortcutOnly:ee});typeof y.registerCommand=="function"&&I.forEach(w=>y.registerCommand(w));let g=Qo(y,{headingOptions:B,paragraphLabel:ie,slashCommandVisibility:Be.current,isFeatureEnabled:he,shortcutConfig:fe.current});typeof y.setSlashCommands=="function"?y.setSlashCommands(g):g.forEach(w=>y.registerSlashCommand?.(w));let d=en(y,document.body,{headingOptions:B,paragraphLabel:ie,isFeatureEnabled:he,shortcutConfig:fe.current,scope:()=>T.getRootElement()});return ze.current||(ze.current=true,u?.(ct)),()=>{d(),typeof y.unregisterCommand=="function"&&I.forEach(w=>y.unregisterCommand(w.id)),typeof y.setSlashCommands=="function"?y.setSlashCommands([]):g.forEach(w=>y.unregisterSlashCommand?.(w.id));}},[T,ne,ct,u,B,ie,Ee,xe,he,ee]),useEffect(()=>{let y=()=>T?.getRootElement(),I=Ta.filter(d=>L[d.feature]===false);if(I.length===0)return;let g=d=>{let w=y();w&&d.target instanceof Node&&!w.contains(d.target)||!Er(d.target)||!I.some(_=>wa(d,_))||(d.preventDefault(),d.stopPropagation());};return document.addEventListener("keydown",g,true),()=>{document.removeEventListener("keydown",g,true);}},[T,L]),useEffect(()=>{let y=q.find(I=>I.name==="commandPalette");if(!(!y||!y.subscribe))return y.subscribe((I,g)=>{let d=g.filter(w=>Y.has(w.id)?false:ee?typeof w.shortcut=="string"&&w.shortcut.trim().length>0:true);$e({isOpen:I,commands:d});})},[q,Y,ee]),useEffect(()=>{if(pe.length===0)return;let y=()=>T?.getRootElement(),I=g=>{let d=y();d&&g.target instanceof Node&&!d.contains(g.target)||!Er(g.target)||!pe.some(P=>Ma(g,P))||(g.preventDefault(),g.stopPropagation());};return document.addEventListener("keydown",I,true),()=>{document.removeEventListener("keydown",I,true);}},[T,pe]),useEffect(()=>{let y=q.find(I=>I.name==="slashCommand");if(!(!y||!y.subscribe))return y.subscribe(I=>{Ne({isOpen:I.isOpen,query:I.query,position:I.position,commands:I.commands});})},[q]),useEffect(()=>{let y=q.find(I=>I.name==="emoji");if(!(!y||!y.subscribe))return y.subscribe(I=>{qe({isOpen:I.isOpen,query:I.query,position:I.position,suggestions:I.suggestions});})},[q]),useEffect(()=>!T||!A?void 0:T.registerUpdateListener(()=>{ut.current+=1,_o(Je.current,["visual"]);}),[T,A]);let Ke=y=>{let I=se[y];if(y==="json"){if(!I.trim()){X.fromJSON(qo(""));return}let g=JSON.parse(I);X.fromJSON(g);return}y==="markdown"?X.fromJSON(markdownToJSON(I)):X.fromJSON(htmlToJSON(I)),Le.current[y]=false,_o(Je.current,["visual"]);},dt=y=>{let I=A.toJSON()??qo("");return y==="json"?Oo(JSON.stringify(I)):y==="markdown"?jn(jsonToMarkdown(I)):$n(jsonToHTML(I))},Ge=(y,I,g)=>{ae(d=>({...d,[y]:I})),Le.current[y]=g?.dirty===true;},kt=async y=>{if(y===G||!s.includes(y))return;let I=G,g=null;try{if(Oe(null),I!=="visual"){let d=I;Le.current[d]&&(g=d,Ke(d),await new Promise(w=>setTimeout(w,50)),g=null);}if(I==="visual"&&y!=="visual"&&(T&&clearLexicalSelection(T),T?.getRootElement()?.blur()),Pe(y),y!=="visual"){let d=y;if(!fr(Je.current,d)){ce(d),await new Promise(w=>setTimeout(w,50));try{g=d;let w=dt(d);Ge(d,w),pr(Je.current,d),g=null;}finally{ce(null);}}}y==="visual"&&setTimeout(()=>T?.focus(),100);}catch(d){let w=d instanceof Error?d.message:"Invalid format - could not parse content";g&&Oe({mode:g,error:w});}},mt=h?jsx(Xn,{commands:ne,hasExtension:y=>k(y),activeStates:V,isDark:e,toggleTheme:t,onCommandPaletteOpen:()=>{L.commandPalette!==false&&ne.showCommandPalette();},imageUploadHandler:y=>q.find(I=>I.name==="image")?.config?.uploadHandler?.(y)??Promise.resolve(URL.createObjectURL(y)),layout:m??qt,toolbarVisibility:st,toolbarStyleVars:p,headingOptions:M,paragraphLabel:J,classNames:{toolbar:`luthor-toolbar luthor-toolbar--align-${b}${f?` ${f}`:""}`}}):null,Ve=x,We=G==="visual"&&h&&C==="top",Xe=["luthor-editor-top-region",v&&C==="top"&&Ve?"luthor-editor-top-region--pinned":""].filter(Boolean).join(" "),nt=["luthor-editor-toolbar-slot","luthor-editor-toolbar-slot--top",We&&(v&&C==="top"&&!Ve)?"luthor-editor-toolbar-slot--pinned":""].filter(Boolean).join(" "),Rt=G==="visual"&&h&&C==="bottom",gt=T?.getRootElement()?.closest(".luthor-editor-wrapper")??null,Re=G==="visual"?null:G;return jsxs(Fragment,{children:[jsxs("div",{className:`luthor-editor${Me?"":" luthor-editor--draggable-disabled"}`,"data-mode":G,children:[(Ve||We)&&jsxs("div",{className:Xe,children:[Ve&&jsx("div",{className:"luthor-editor-header",children:jsx(Dn,{mode:G,onModeChange:kt,availableModes:s,isConverting:W})}),We&&jsx("div",{className:nt,children:mt})]}),jsxs("div",{className:`luthor-editor-visual-shell${G==="visual"?"":" is-hidden"}${Me?"":" luthor-editor-visual-shell--no-gutter"}`,"aria-hidden":G!=="visual",children:[Me&&jsx("div",{className:"luthor-editor-visual-gutter","aria-hidden":"true"}),jsx(RichText,{placeholder:o,classNames:{container:"luthor-richtext-container luthor-preset-extensive__container",contentEditable:"luthor-content-editable luthor-preset-extensive__content",placeholder:"luthor-placeholder luthor-preset-extensive__placeholder"}})]}),Re&&jsxs("div",{className:"luthor-source-panel",children:[me&&me.mode===Re&&jsxs("div",{className:"luthor-source-error",children:[jsx("div",{className:"luthor-source-error-icon",children:"!"}),jsxs("div",{className:"luthor-source-error-message",children:[jsx("strong",{children:ma[Re]}),jsx("p",{children:me.error}),jsx("small",{children:"Fix the errors above and try switching modes again"})]})]}),Re==="json"&&jsx(ao,{value:se.json,onChange:y=>Ge("json",y,{dirty:true}),placeholder:n}),Re==="markdown"&&jsx(ao,{value:se.markdown,onChange:y=>Ge("markdown",y,{dirty:true}),placeholder:i,className:"luthor-source-view--wrapped",wrap:"soft"}),Re==="html"&&jsx(ao,{value:se.html,onChange:y=>Ge("html",y,{dirty:true}),placeholder:r,className:"luthor-source-view--wrapped",wrap:"soft"})]})]}),jsx(Bn,{editor:T,commands:ne,editorTheme:e?"dark":"light",disabled:G!=="visual"}),Rt&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--bottom",children:mt}),jsx(En,{isOpen:ve.isOpen,onClose:()=>ne.hideCommandPalette(),commands:ve.commands}),jsx(In,{isOpen:ge.isOpen,query:ge.query,position:ge.position,portalContainer:gt,commands:ge.commands,onClose:()=>ne.closeSlashMenu?.(),onExecute:y=>{ne.executeSlashCommand?.(y);}}),jsx(wn,{isOpen:de.isOpen,query:de.query,position:de.position,portalContainer:gt,suggestions:de.suggestions,onClose:()=>ne.closeEmojiSuggestions?.(),onExecute:y=>{ne.executeEmojiSuggestion?.(y);}})]})}var yo=forwardRef(({className:e,onReady:t,initialTheme:o="light",onThemeChange:n,theme:i,defaultContent:r,showDefaultContent:l=true,placeholder:s=br,defaultEditorView:u,initialMode:m="visual",isEditorViewTabsVisible:E,isEditorViewsTabVisible:C,availableModes:b=["visual","json","markdown","html"],variantClassName:f,toolbarLayout:p,toolbarVisibility:h,toolbarPosition:v="top",toolbarAlignment:x="left",toolbarClassName:F,toolbarStyleVars:J,quoteClassName:$,quoteStyleVars:R,defaultSettings:re,editorThemeOverrides:ee,isToolbarEnabled:L=true,isToolbarPinned:te=false,fontFamilyOptions:k,fontSizeOptions:V,lineHeightOptions:T,minimumDefaultLineHeight:q=1.5,scaleByRatio:A=false,headingOptions:X,paragraphLabel:G,syncHeadingOptionsWithCommands:Pe=true,slashCommandVisibility:se,shortcutConfig:ae,commandPaletteShortcutOnly:W=false,isDraggableBoxEnabled:ce,featureFlags:me,syntaxHighlighting:Oe,codeHighlightProvider:ve,loadCodeHighlightProvider:$e,maxAutoDetectCodeLength:ge,isCopyAllowed:Ne=true,languageOptions:de,maxListIndentation:qe=8},ze)=>{let[M,B]=useState(o),ie=useRef(null),Ye=M==="dark",ne=u??m,he=b.includes(ne)?ne:b[0]??"visual",st=E??C??true,Me=()=>B(Ye?"light":"dark"),Ee=useMemo(()=>typeof s=="string"?{visual:s,json:yr,markdown:vr,html:Cr}:{visual:s.visual??br,json:s.json??yr,markdown:s.markdown??vr,html:s.html??Cr},[s]);useEffect(()=>{B(o);},[o]),useEffect(()=>{n?.(M);},[M,n]),useEffect(()=>{if(!te||v!=="top")return;let j=ie.current;if(j)return ha(j)},[te,v]);let Be=useMemo(()=>pa(k),[k]),De=useMemo(()=>ba(V),[V]),xe=useMemo(()=>ya(T),[T]),fe=useMemo(()=>va(q),[q]),He=useMemo(()=>Ca(qe),[qe]),Ue=Oe??"unset",Y=typeof ge=="number"?ge.toString():"unset",pe=useMemo(()=>ka(de),[de]),Je=Ne?"copy-on":"copy-off",Le=useMemo(()=>typeof ce!="boolean"?me:{...me??{},draggableBlock:ce},[me,ce]),ut=useMemo(()=>La(Le),[Le]),ct=useMemo(()=>_t(Le),[Le]),Ke=`${Be}::${De}::${xe}::${fe}::${He}::${A?"ratio-on":"ratio-off"}::${Ue}::${Y}::${Je}::${pe}::${ut}`,dt=useRef(k),Ge=useRef(V),kt=useRef(T),mt=useRef(q),Ve=useRef(Le),We=useRef(de),ot=useRef(ve),Xe=useRef($e),Et=useRef(Ke);(Et.current!==Ke||ot.current!==ve||Xe.current!==$e)&&(Et.current=Ke,dt.current=k,Ge.current=V,kt.current=T,mt.current=q,Ve.current=Le,We.current=de,ot.current=ve,Xe.current=$e);let nt=useRef(null);if(!nt.current||nt.current.key!==Ke){let j={fontFamilyOptions:dt.current,fontSizeOptions:Ge.current,lineHeightOptions:kt.current,minimumDefaultLineHeight:mt.current,maxListIndentation:Number(He),scaleByRatio:A,...Oe!==void 0?{syntaxHighlighting:Oe}:{},...ot.current!==void 0?{codeHighlightProvider:ot.current}:{},...Xe.current!==void 0?{loadCodeHighlightProvider:Xe.current}:{},...ge!==void 0?{maxAutoDetectCodeLength:ge}:{},isCopyAllowed:Ne,...We.current!==void 0?{languageOptions:We.current}:{},...typeof ce=="boolean"?{isDraggableBoxEnabled:ce}:{},...Ve.current?{featureFlags:Ve.current}:{}};nt.current={key:Ke,value:jt(j)};}let Rt=nt.current.value,gt=useMemo(()=>{let j=mergeThemes(defaultLuthorTheme,i??{});return $?{...j,quote:`${j.quote??""} ${$}`.trim()}:j},[i,$]),Re=useMemo(()=>$o(ee),[ee]),y=useMemo(()=>$o(R),[R]),I=useMemo(()=>Ea(re),[re]),g=useMemo(()=>$o(I),[I]),d=useMemo(()=>{let j=I,Qe=createEditorThemeStyleVars(ee),$t=R,Yo={"--luthor-default-line-height":fe};return !j&&!Qe&&!$t?Yo:{...j??{},...Qe,...$t??{},...Yo}},[fe,I,ee,R,g,Re,y]),[w,P]=useState(null);useImperativeHandle(ze,()=>w,[w]);let _=j=>{P(j),l&&r===void 0?j.injectJSON(JSON.stringify(jo)):r&&j.injectJSON(fa(r)),t?.(j);};return jsx("div",{ref:ie,className:`luthor-preset luthor-preset-extensive luthor-editor-wrapper${te?" luthor-editor-wrapper--toolbar-pinned":""} ${f||""} ${e||""}`.trim(),"data-editor-theme":M,style:d,children:jsx(ua,{extensions:Rt,config:{theme:gt},children:jsx(Ra,{isDark:Ye,toggleTheme:Me,visualPlaceholder:Ee.visual,jsonPlaceholder:Ee.json,markdownPlaceholder:Ee.markdown,htmlPlaceholder:Ee.html,initialMode:he,availableModes:b,onReady:_,toolbarLayout:p,toolbarVisibility:h,toolbarPosition:v,toolbarAlignment:x,toolbarClassName:F,toolbarStyleVars:J,isToolbarEnabled:L,isToolbarPinned:te,isEditorViewTabsVisible:st,headingOptions:X,paragraphLabel:G,syncHeadingOptionsWithCommands:Pe,slashCommandVisibility:se,shortcutConfig:ae,commandPaletteShortcutOnly:W,featureFlags:ct})})})});yo.displayName="ExtensiveEditor";var Lr=["undo","redo","fontFamily","heading","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"],Tr={id:"extensive",label:"Extensive Editor",description:"Complete editing preset with all core features enabled.",extensions:[...Vo],components:{Editor:yo},toolbar:[...Lr],config:Un("extensive","Write anything..."),css:"extensive/styles.css"};function Pa(e={}){return {...Tr,extensions:[...jt({fontFamilyOptions:e.fontFamilyOptions,fontSizeOptions:e.fontSizeOptions,lineHeightOptions:e.lineHeightOptions,minimumDefaultLineHeight:e.minimumDefaultLineHeight,maxListIndentation:e.maxListIndentation,isCopyAllowed:e.isCopyAllowed,languageOptions:e.languageOptions})]}}export{Nn as $,ln as A,_o as Aa,an as B,fr as Ba,sn as C,pr as Ca,Va as D,yo as Da,un as E,Lr as Ea,_a as F,Tr as Fa,oo as G,Pa as Ga,cn as H,dn as I,no as J,mn as K,gn as L,hn as M,fn as N,pn as O,Lo as P,bn as Q,yn as R,St as S,vn as T,En as U,wn as V,In as W,N as X,So as Y,Dt as Z,rt as _,Ie as a,Mn as aa,za as b,xo as ba,qt as c,Hn as ca,Co as d,Bn as da,Xo as e,Dn as ea,Qo as f,ao as fa,en as g,Un as ga,Jt as h,Oo as ha,Gt as i,jn as ia,Wt as j,$n as ja,Xt as k,Yi as ka,Qt as l,Ji as la,tn as m,Gi as ma,Lt as n,Xn as na,ht as o,rr as oa,Zt as p,_t as pa,eo as q,ir as qa,to as r,jt as ra,on as s,Vo as sa,nn as t,sr as ta,ko as u,ur as ua,Tt as v,cr as va,ft as w,dr as wa,rn as x,mr as xa,wt as y,gr as ya,Eo as z,hr as za};