@pubwave/editor 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -6
- package/dist/index.js +551 -529
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const oe=require("@tiptap/core"),Fo=require("@tiptap/extension-placeholder"),Wo=require("@tiptap/extension-history"),Vo=require("@tiptap/extension-dropcursor"),Go=require("@tiptap/extension-gapcursor"),Yo=require("@tiptap/extension-document"),Ko=require("@tiptap/extension-paragraph"),Xo=require("@tiptap/extension-text"),Jo=require("@tiptap/extension-heading"),Zo=require("@tiptap/extension-bullet-list"),Qo=require("@tiptap/extension-ordered-list"),er=require("@tiptap/extension-list-item"),tr=require("@tiptap/extension-task-list"),nr=require("@tiptap/extension-task-item"),or=require("@tiptap/extension-blockquote"),rr=require("@tiptap/extension-code-block"),ar=require("@tiptap/extension-horizontal-rule"),ir=require("@tiptap/extension-hard-break"),sr=require("@tiptap/extension-image"),xe=require("@tiptap/react"),i=require("react/jsx-runtime"),m=require("react"),lr=require("react-dom"),Pt=require("@tiptap/pm/state"),cr=require("@tiptap/extension-bold"),ur=require("@tiptap/extension-italic"),dr=require("@tiptap/extension-underline"),pr=require("@tiptap/extension-strike"),fr=require("@tiptap/extension-code"),hr=require("@tiptap/extension-link"),br=require("@tiptap/suggestion"),vr=[{value:"bar",label:"bar"},{value:"line",label:"line"},{value:"pie",label:"pie"},{value:"doughnut",label:"doughnut"},{value:"radar",label:"radar"},{value:"polarArea",label:"polarArea"}];function gr(e){return{backgroundColor:`rgba(59, 130, 246, ${.5+e%3*.2})`,borderColor:"rgba(59, 130, 246, 1)"}}function mr({initialData:e,onSave:t,onCancel:n,locale:o}){var B,v,T,j,_,z,$,F,U;const[r,a]=m.useState(e.type),[s,c]=m.useState(((T=(v=(B=e.options)==null?void 0:B.plugins)==null?void 0:v.title)==null?void 0:T.text)??""),[l,d]=m.useState(((z=(_=(j=e.options)==null?void 0:j.plugins)==null?void 0:_.legend)==null?void 0:z.display)??!0),[p,x]=m.useState(((U=(F=($=e.options)==null?void 0:$.plugins)==null?void 0:F.legend)==null?void 0:U.position)??"bottom"),[h,b]=m.useState(e.data.labels),[f,g]=m.useState(e.data.datasets),L=m.useRef(null),k=(o==null?void 0:o.chart)||{modal:{title:"Edit Chart",close:"Close",save:"Save",cancel:"Cancel",fields:{chartType:"Chart Type",title:"Title",titlePlaceholder:"Chart title...",showLegend:"Show Legend",legendPosition:"Position",position:{top:"Top",bottom:"Bottom",left:"Left",right:"Right"},labels:"Labels",labelsPlaceholder:"Jan, Feb, Mar, Apr...",datasets:{title:"Datasets",add:"+ Add Dataset",remove:"Remove",datasetLabel:"Label",datasetLabelPlaceholder:"Dataset label...",data:"Data",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Bar Chart",line:"Line Chart",pie:"Pie Chart",doughnut:"Doughnut Chart",radar:"Radar Chart",polarArea:"Polar Area Chart"}};m.useEffect(()=>{const R=N=>{N.key==="Escape"&&n()};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[n]),m.useEffect(()=>{const R=V=>{L.current&&L.current.contains(V.target)},N=setTimeout(()=>{document.addEventListener("mousedown",R)},100);return()=>{clearTimeout(N),document.removeEventListener("mousedown",R)}},[]);const M=m.useCallback((R,N)=>{g(V=>V.map((W,Q)=>Q===R?{...W,label:N}:W))},[]),C=m.useCallback((R,N)=>{g(V=>V.map((W,Q)=>Q===R?{...W,data:N.split(",").map(G=>parseFloat(G.trim())||0)}:W))},[]),u=m.useCallback(()=>{const R=gr(f.length);g(N=>[...N,{label:`${k.modal.fields.datasets.title} ${N.length+1}`,data:h.map(()=>Math.floor(Math.random()*100)),backgroundColor:R.backgroundColor,borderColor:R.borderColor,borderWidth:2}])},[f.length,h,k]),S=m.useCallback(R=>{g(N=>N.filter((V,W)=>W!==R))},[]),w=m.useCallback(R=>{b(R.split(",").map(N=>N.trim()).filter(Boolean))},[]),A=m.useCallback(()=>{const R={type:r,data:{labels:h,datasets:f},options:{...e.options,responsive:!0,maintainAspectRatio:!1,plugins:{title:{display:!!s,text:s,color:"var(--pubwave-text, #37352f)",font:{size:16,weight:"bold"}},legend:{display:l,position:p}}}};t(R)},[r,s,l,p,h,f,e.options,t]),P=m.useCallback(R=>{R.target===R.currentTarget&&n()},[n]),I=i.jsx("div",{className:"pubwave-modal__overlay",onClick:P,children:i.jsxs("div",{ref:L,className:"pubwave-modal__container",role:"dialog","aria-modal":"true","aria-labelledby":"chart-modal-title",children:[i.jsxs("div",{className:"pubwave-modal__header",children:[i.jsx("h2",{id:"chart-modal-title",className:"pubwave-modal__title",children:k.modal.title}),i.jsx("button",{type:"button",className:"pubwave-modal__close",onClick:n,"aria-label":k.modal.close,children:i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),i.jsxs("div",{className:"pubwave-modal__body",children:[i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-type",className:"pubwave-form__label",children:k.modal.fields.chartType}),i.jsx("select",{id:"chart-type",className:"pubwave-form__select",value:r,onChange:R=>a(R.target.value),children:vr.map(R=>i.jsx("option",{value:R.value,children:k.chartTypes[R.value]},R.value))})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-title",className:"pubwave-form__label",children:k.modal.fields.title}),i.jsx("input",{id:"chart-title",type:"text",className:"pubwave-form__input",value:s,onChange:R=>c(R.target.value),placeholder:k.modal.fields.titlePlaceholder})]}),i.jsxs("div",{className:"pubwave-form__row",children:[i.jsx("div",{className:"pubwave-form__field",children:i.jsxs("label",{className:"pubwave-form__checkbox-label",children:[i.jsx("input",{type:"checkbox",className:"pubwave-form__checkbox",checked:l,onChange:R=>d(R.target.checked)}),k.modal.fields.showLegend]})}),l&&i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"legend-position",className:"pubwave-form__label",children:k.modal.fields.legendPosition}),i.jsxs("select",{id:"legend-position",className:"pubwave-form__select",value:p,onChange:R=>x(R.target.value),children:[i.jsx("option",{value:"top",children:k.modal.fields.position.top}),i.jsx("option",{value:"bottom",children:k.modal.fields.position.bottom}),i.jsx("option",{value:"left",children:k.modal.fields.position.left}),i.jsx("option",{value:"right",children:k.modal.fields.position.right})]})]})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-labels",className:"pubwave-form__label",children:k.modal.fields.labels}),i.jsx("input",{id:"chart-labels",type:"text",className:"pubwave-form__input",value:h.join(", "),onChange:R=>w(R.target.value),placeholder:k.modal.fields.labelsPlaceholder})]}),i.jsxs("div",{className:"pubwave-form__section",children:[i.jsxs("div",{className:"pubwave-form__section-header",children:[i.jsx("h3",{className:"pubwave-form__section-title",children:k.modal.fields.datasets.title}),i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--secondary pubwave-button--small",onClick:u,children:k.modal.fields.datasets.add})]}),f.map((R,N)=>i.jsxs("div",{className:"pubwave-form__dataset",children:[i.jsxs("div",{className:"pubwave-form__dataset-header",children:[i.jsxs("span",{className:"pubwave-form__dataset-title",children:[k.modal.fields.datasets.datasetLabel," ",N+1]}),f.length>1&&i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--danger pubwave-button--small",onClick:()=>S(N),"aria-label":`${k.modal.fields.datasets.remove} ${N+1}`,children:k.modal.fields.datasets.remove})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:`dataset-label-${N}`,className:"pubwave-form__label",children:k.modal.fields.datasets.datasetLabel}),i.jsx("input",{id:`dataset-label-${N}`,type:"text",className:"pubwave-form__input",value:R.label??"",onChange:V=>M(N,V.target.value),placeholder:k.modal.fields.datasets.datasetLabelPlaceholder})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:`dataset-data-${N}`,className:"pubwave-form__label",children:k.modal.fields.datasets.data}),i.jsx("input",{id:`dataset-data-${N}`,type:"text",className:"pubwave-form__input",value:R.data.join(", "),onChange:V=>C(N,V.target.value),placeholder:k.modal.fields.datasets.dataPlaceholder})]})]},N))]})]}),i.jsxs("div",{className:"pubwave-modal__footer",children:[i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--secondary",onClick:n,children:k.modal.cancel}),i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--primary",onClick:A,children:k.modal.save})]})]})});return lr.createPortal(I,document.body)}const xr={groups:{basic:"Basic",list:"Lists",media:"Media",advanced:"Advanced",layout:"Layout"},commands:{paragraph:{title:"Text",description:"Plain text block"},heading1:{title:"Heading 1",description:"Large section heading"},heading2:{title:"Heading 2",description:"Medium section heading"},heading3:{title:"Heading 3",description:"Small section heading"},bulletList:{title:"Bullet List",description:"Create a bulleted list"},orderedList:{title:"Numbered List",description:"Create a numbered list"},taskList:{title:"To-do list",description:"Create a todo list with checkboxes"},image:{title:"Image",description:"Upload or paste an image"},blockquote:{title:"Blockquote",description:"Create a quote block"},codeBlock:{title:"Code",description:"Create a code snippet"},horizontalRule:{title:"Divider",description:"Create a horizontal line"},layoutTwoColumn:{title:"Two Column Layout",description:"Split content into two side-by-side columns"},layoutThreeColumn:{title:"Three Column Layout",description:"Split content into three side-by-side columns"}}},yr={bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",code:"Inline Code",link:"Link",turnInto:"Turn Into",colorPicker:"Text and background color",textColor:"Text color",backgroundColor:"Background color",recentlyUsed:"Recently used",openLink:"Open link",removeLink:"Remove link",confirmLink:"Confirm link",clearLink:"Clear link",blockTypes:{text:"Text",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",bulletedList:"Bulleted list",numberedList:"Numbered list"}},wr={editor:"Rich text editor",editorContent:"Editor content area",toolbar:"Text formatting toolbar",boldButton:"Toggle bold formatting",italicButton:"Toggle italic formatting",underlineButton:"Toggle underline formatting",strikeButton:"Toggle strikethrough formatting",codeButton:"Toggle inline code formatting",linkButton:"Add or edit link",turnIntoButton:"Turn into",colorPickerButton:"Text and background color",headingButton:"Set heading level",paragraphButton:"Convert to paragraph",dragHandle:"Drag to reorder block",dropIndicator:"Drop here to move block",blockMenu:"Block options menu",addBlock:"Add new block",deleteBlock:"Delete this block",linkDialog:"Link editor dialog",linkUrlInput:"Link URL input",linkSaveButton:"Save link",linkRemoveButton:"Remove link",linkCancelButton:"Cancel link editing",addBlockBelow:"Add block below",dragToMove:"Drag to reorder block",openLinkInNewTab:"Open link in new tab",linkConfirmButton:"Confirm link",linkOpenButton:"Open link in new tab",linkClearButton:"Clear link input"},kr='Write, type "/" for commands...',Cr="Paste a link...",Lr={modal:{title:"Edit Chart",close:"Close",save:"Save",cancel:"Cancel",fields:{chartType:"Chart Type",title:"Title",titlePlaceholder:"Chart title...",showLegend:"Show Legend",legendPosition:"Position",position:{top:"Top",bottom:"Bottom",left:"Left",right:"Right"},labels:"Labels (comma-separated)",labelsPlaceholder:"Jan, Feb, Mar, Apr...",datasets:{title:"Datasets",add:"+ Add Dataset",remove:"Remove",datasetLabel:"Dataset",datasetLabelPlaceholder:"Dataset label...",data:"Data (comma-separated numbers)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Bar Chart",line:"Line Chart",pie:"Pie Chart",doughnut:"Doughnut Chart",radar:"Radar Chart",polarArea:"Polar Area Chart"}},zn={slashMenu:xr,toolbar:yr,aria:wr,placeholder:kr,linkPlaceholder:Cr,chart:Lr},Tr={groups:{basic:"基礎",list:"列表",media:"媒體",advanced:"高級",layout:"版面配置"},commands:{paragraph:{title:"文本",description:"普通文本塊"},heading1:{title:"標題 1",description:"大標題"},heading2:{title:"標題 2",description:"中標題"},heading3:{title:"標題 3",description:"小標題"},bulletList:{title:"無序列表",description:"創建無序列表"},orderedList:{title:"有序列表",description:"創建有序列表"},taskList:{title:"待辦清單",description:"創建帶複選框的待辦清單"},image:{title:"圖片",description:"上傳或粘貼圖片"},blockquote:{title:"引用",description:"創建引用塊"},codeBlock:{title:"代碼",description:"創建代碼片段"},horizontalRule:{title:"分割線",description:"創建水平分割線"},layoutTwoColumn:{title:"兩欄版面配置",description:"將內容分成兩個並排的欄"},layoutThreeColumn:{title:"三欄版面配置",description:"將內容分成三個並排的欄"}}},Br={bold:"粗體",italic:"斜體",underline:"下劃線",strike:"刪除線",code:"行內代碼",link:"鏈接",turnInto:"轉換為",colorPicker:"文字和背景顏色",textColor:"文字顏色",backgroundColor:"背景顏色",recentlyUsed:"最近使用",openLink:"打開鏈接",removeLink:"移除鏈接",confirmLink:"確認鏈接",clearLink:"清空鏈接",blockTypes:{text:"文本",heading1:"標題 1",heading2:"標題 2",heading3:"標題 3",bulletedList:"無序列表",numberedList:"有序列表"}},Ar={editor:"富文本編輯器",editorContent:"編輯器內容區域",toolbar:"文本格式化工具欄",boldButton:"切換粗體格式",italicButton:"切換斜體格式",underlineButton:"切換下劃線格式",strikeButton:"切換刪除線格式",codeButton:"切換行內代碼格式",linkButton:"添加或編輯鏈接",turnIntoButton:"轉換為",colorPickerButton:"文字和背景顏色",headingButton:"設置標題級別",paragraphButton:"轉換為段落",dragHandle:"拖拽以重新排序塊",dropIndicator:"放置此處以移動塊",blockMenu:"塊選項菜單",addBlock:"添加新塊",deleteBlock:"刪除此塊",linkDialog:"鏈接編輯對話框",linkUrlInput:"鏈接 URL 輸入",linkSaveButton:"保存鏈接",linkRemoveButton:"移除鏈接",linkCancelButton:"取消鏈接編輯",addBlockBelow:"在下方添加塊",dragToMove:"拖拽以重新排序塊",openLinkInNewTab:"在新標籤頁中打開鏈接",linkConfirmButton:"確認鏈接",linkOpenButton:"在新標籤頁中打開鏈接",linkClearButton:"清空鏈接輸入"},jr='開始寫作,輸入 "/" 顯示命令...',Sr="粘貼鏈接...",Mr={modal:{title:"編輯圖表",close:"關閉",save:"保存",cancel:"取消",fields:{chartType:"圖表類型",title:"標題",titlePlaceholder:"圖表標題...",showLegend:"顯示圖例",legendPosition:"位置",position:{top:"頂部",bottom:"底部",left:"左側",right:"右側"},labels:"標籤(逗號分隔)",labelsPlaceholder:"一月, 二月, 三月, 四月...",datasets:{title:"數據集",add:"+ 添加數據集",remove:"移除",datasetLabel:"標籤",datasetLabelPlaceholder:"數據集標籤...",data:"數據(逗號分隔的數字)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"柱狀圖",line:"折線圖",pie:"餅圖",doughnut:"環形圖",radar:"雷達圖",polarArea:"極地圖"}},Pr={slashMenu:Tr,toolbar:Br,aria:Ar,placeholder:jr,linkPlaceholder:Sr,chart:Mr},Dr={groups:{basic:"基础",list:"列表",media:"媒体",advanced:"高级",layout:"版面布局"},commands:{paragraph:{title:"文本",description:"普通文本块"},heading1:{title:"标题 1",description:"大标题"},heading2:{title:"标题 2",description:"中标题"},heading3:{title:"标题 3",description:"小标题"},bulletList:{title:"无序列表",description:"创建无序列表"},orderedList:{title:"有序列表",description:"创建有序列表"},taskList:{title:"待办清单",description:"创建带复选框的待办清单"},image:{title:"图片",description:"上传或粘贴图片"},blockquote:{title:"引用",description:"创建引用块"},codeBlock:{title:"代码",description:"创建代码片段"},horizontalRule:{title:"分割线",description:"创建水平分割线"},layoutTwoColumn:{title:"两栏布局",description:"将内容分成两个并排的栏"},layoutThreeColumn:{title:"三栏布局",description:"将内容分成三个并排的栏"}}},Ir={bold:"粗体",italic:"斜体",underline:"下划线",strike:"删除线",code:"行内代码",link:"链接",turnInto:"转换为",colorPicker:"文字和背景颜色",textColor:"文字颜色",backgroundColor:"背景颜色",recentlyUsed:"最近使用",openLink:"打开链接",removeLink:"移除链接",confirmLink:"确认链接",clearLink:"清空链接",blockTypes:{text:"文本",heading1:"标题 1",heading2:"标题 2",heading3:"标题 3",bulletedList:"无序列表",numberedList:"有序列表"}},Rr={editor:"富文本编辑器",editorContent:"编辑器内容区域",toolbar:"文本格式化工具栏",boldButton:"切换粗体格式",italicButton:"切换斜体格式",underlineButton:"切换下划线格式",strikeButton:"切换删除线格式",codeButton:"切换行内代码格式",linkButton:"添加或编辑链接",turnIntoButton:"转换为",colorPickerButton:"文字和背景颜色",headingButton:"设置标题级别",paragraphButton:"转换为段落",dragHandle:"拖拽以重新排序块",dropIndicator:"放置此处以移动块",blockMenu:"块选项菜单",addBlock:"添加新块",deleteBlock:"删除此块",linkDialog:"链接编辑对话框",linkUrlInput:"链接 URL 输入",linkSaveButton:"保存链接",linkRemoveButton:"移除链接",linkCancelButton:"取消链接编辑",addBlockBelow:"在下方添加块",dragToMove:"拖拽以重新排序块",openLinkInNewTab:"在新标签页中打开链接",linkConfirmButton:"确认链接",linkOpenButton:"在新标签页中打开链接",linkClearButton:"清空链接输入"},Or='开始写作,输入 "/" 显示命令...',Er="粘贴链接...",_r={modal:{title:"编辑图表",close:"关闭",save:"保存",cancel:"取消",fields:{chartType:"图表类型",title:"标题",titlePlaceholder:"图表标题...",showLegend:"显示图例",legendPosition:"位置",position:{top:"顶部",bottom:"底部",left:"左侧",right:"右侧"},labels:"标签(逗号分隔)",labelsPlaceholder:"一月, 二月, 三月, 四月...",datasets:{title:"数据集",add:"+ 添加数据集",remove:"移除",datasetLabel:"标签",datasetLabelPlaceholder:"数据集标签...",data:"数据(逗号分隔的数字)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"柱状图",line:"折线图",pie:"饼图",doughnut:"环形图",radar:"雷达图",polarArea:"极地图"}},Nr={slashMenu:Dr,toolbar:Ir,aria:Rr,placeholder:Or,linkPlaceholder:Er,chart:_r},Hr={groups:{basic:"基本",list:"リスト",media:"メディア",advanced:"高度",layout:"レイアウト"},commands:{paragraph:{title:"テキスト",description:"プレーンテキストブロック"},heading1:{title:"見出し1",description:"大きなセクション見出し"},heading2:{title:"見出し2",description:"中サイズのセクション見出し"},heading3:{title:"見出し3",description:"小さなセクション見出し"},bulletList:{title:"箇条書きリスト",description:"箇条書きリストを作成"},orderedList:{title:"番号付きリスト",description:"番号付きリストを作成"},taskList:{title:"To-doリスト",description:"チェックボックス付きのTo-doリストを作成"},image:{title:"画像",description:"画像をアップロードまたは貼り付け"},blockquote:{title:"引用",description:"引用ブロックを作成"},codeBlock:{title:"コード",description:"コードスニペットを作成"},horizontalRule:{title:"区切り線",description:"水平線を作成"},layoutTwoColumn:{title:"2カラムレイアウト",description:"コンテンツを2つの横並びカラムに分割"},layoutThreeColumn:{title:"3カラムレイアウト",description:"コンテンツを3つの横並びカラムに分割"}}},$r={bold:"太字",italic:"斜体",underline:"下線",strike:"取り消し線",code:"インラインコード",link:"リンク",turnInto:"変換",colorPicker:"テキストと背景色",textColor:"文字色",backgroundColor:"背景色",recentlyUsed:"最近使用",openLink:"リンクを開く",removeLink:"リンクを削除",confirmLink:"リンクを確認",clearLink:"リンクをクリア",blockTypes:{text:"テキスト",heading1:"見出し1",heading2:"見出し2",heading3:"見出し3",bulletedList:"箇条書きリスト",numberedList:"番号付きリスト"}},zr={editor:"リッチテキストエディタ",editorContent:"エディタコンテンツ領域",toolbar:"テキスト書式設定ツールバー",boldButton:"太字書式を切り替え",italicButton:"斜体書式を切り替え",underlineButton:"下線書式を切り替え",strikeButton:"取り消し線書式を切り替え",codeButton:"インラインコード書式を切り替え",linkButton:"リンクを追加または編集",turnIntoButton:"変換",colorPickerButton:"テキストと背景色",headingButton:"見出しレベルを設定",paragraphButton:"段落に変換",dragHandle:"ブロックを並び替えるためにドラッグ",dropIndicator:"ブロックを移動するためにここにドロップ",blockMenu:"ブロックオプションメニュー",addBlock:"新しいブロックを追加",deleteBlock:"このブロックを削除",linkDialog:"リンク編集ダイアログ",linkUrlInput:"リンクURL入力",linkSaveButton:"リンクを保存",linkRemoveButton:"リンクを削除",linkCancelButton:"リンク編集をキャンセル",addBlockBelow:"下にブロックを追加",dragToMove:"ブロックを並び替えるためにドラッグ",openLinkInNewTab:"新しいタブでリンクを開く",linkConfirmButton:"リンクを確認",linkOpenButton:"新しいタブでリンクを開く",linkClearButton:"リンク入力をクリア"},qr='書き始めましょう、コマンドを表示するには "/" を入力...',Ur="リンクを貼り付け...",Fr={modal:{title:"チャート編集",close:"閉じる",save:"保存",cancel:"キャンセル",fields:{chartType:"チャートタイプ",title:"タイトル",titlePlaceholder:"チャートタイトル...",showLegend:"凡例を表示",legendPosition:"位置",position:{top:"上",bottom:"下",left:"左",right:"右"},labels:"ラベル(カンマ区切り)",labelsPlaceholder:"1月, 2月, 3月, 4月...",datasets:{title:"データセット",add:"+ データセットを追加",remove:"削除",datasetLabel:"ラベル",datasetLabelPlaceholder:"データセットラベル...",data:"データ(カンマ区切りの数値)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"棒グラフ",line:"折れ線グラフ",pie:"円グラフ",doughnut:"ドーナツグラフ",radar:"レーダーチャート",polarArea:"極座標グラフ"}},Wr={slashMenu:Hr,toolbar:$r,aria:zr,placeholder:qr,linkPlaceholder:Ur,chart:Fr},Vr={groups:{basic:"기본",list:"목록",media:"미디어",advanced:"고급",layout:"레이아웃"},commands:{paragraph:{title:"텍스트",description:"일반 텍스트 블록"},heading1:{title:"제목 1",description:"큰 섹션 제목"},heading2:{title:"제목 2",description:"중간 섹션 제목"},heading3:{title:"제목 3",description:"작은 섹션 제목"},bulletList:{title:"글머리 기호 목록",description:"글머리 기호 목록 만들기"},orderedList:{title:"번호 매기기 목록",description:"번호 매기기 목록 만들기"},taskList:{title:"할 일 목록",description:"확인란 있는 할 일 목록 만들기"},image:{title:"이미지",description:"이미지 업로드 또는 붙여넣기"},blockquote:{title:"인용",description:"인용 블록 만들기"},codeBlock:{title:"코드",description:"코드 스니펫 만들기"},horizontalRule:{title:"구분선",description:"수평선 만들기"},layoutTwoColumn:{title:"2열 레이아웃",description:"콘텐츠를 두 개의 나란히 있는 열로 분할"},layoutThreeColumn:{title:"3열 레이아웃",description:"콘텐츠를 세 개의 나란히 있는 열로 분할"}}},Gr={bold:"굵게",italic:"기울임",underline:"밑줄",strike:"취소선",code:"인라인 코드",link:"링크",turnInto:"변환",colorPicker:"텍스트 및 배경색",textColor:"텍스트 색상",backgroundColor:"배경 색상",recentlyUsed:"최근 사용",openLink:"링크 열기",removeLink:"링크 제거",confirmLink:"링크 확인",clearLink:"링크 지우기",blockTypes:{text:"텍스트",heading1:"제목 1",heading2:"제목 2",heading3:"제목 3",bulletedList:"글머리 기호 목록",numberedList:"번호 매기기 목록"}},Yr={editor:"리치 텍스트 에디터",editorContent:"에디터 내용 영역",toolbar:"텍스트 서식 도구 모음",boldButton:"굵게 서식 전환",italicButton:"기울임 서식 전환",underlineButton:"밑줄 서식 전환",strikeButton:"취소선 서식 전환",codeButton:"인라인 코드 서식 전환",linkButton:"링크 추가 또는 편집",turnIntoButton:"변환",colorPickerButton:"텍스트 및 배경색",headingButton:"제목 수준 설정",paragraphButton:"단락으로 변환",dragHandle:"블록 재정렬을 위해 드래그",dropIndicator:"블록 이동을 위해 여기에 놓기",blockMenu:"블록 옵션 메뉴",addBlock:"새 블록 추가",deleteBlock:"이 블록 삭제",linkDialog:"링크 편집 대화 상자",linkUrlInput:"링크 URL 입력",linkSaveButton:"링크 저장",linkRemoveButton:"링크 제거",linkCancelButton:"링크 편집 취소",addBlockBelow:"아래에 블록 추가",dragToMove:"블록 재정렬을 위해 드래그",openLinkInNewTab:"새 탭에서 링크 열기",linkConfirmButton:"링크 확인",linkOpenButton:"새 탭에서 링크 열기",linkClearButton:"링크 입력 지우기"},Kr='작성 시작, 명령을 표시하려면 "/" 입력...',Xr="링크 붙여넣기...",Jr={modal:{title:"차트 편집",close:"닫기",save:"저장",cancel:"취소",fields:{chartType:"차트 유형",title:"제목",titlePlaceholder:"차트 제목...",showLegend:"범례 표시",legendPosition:"위치",position:{top:"위",bottom:"아래",left:"왼쪽",right:"오른쪽"},labels:"레이블(쉼표로 구분)",labelsPlaceholder:"1월, 2월, 3월, 4월...",datasets:{title:"데이터 세트",add:"+ 데이터 세트 추가",remove:"제거",datasetLabel:"레이블",datasetLabelPlaceholder:"데이터 세트 레이블...",data:"데이터(쉼표로 구분된 숫자)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"막대형 차트",line:"선형 차트",pie:"원형 차트",doughnut:"도넛형 차트",radar:"레이더 차트",polarArea:"극좌표형 차트"}},Zr={slashMenu:Vr,toolbar:Gr,aria:Yr,placeholder:Kr,linkPlaceholder:Xr,chart:Jr},Qr={groups:{basic:"De base",list:"Listes",media:"Médias",advanced:"Avancé",layout:"Mise en page"},commands:{paragraph:{title:"Texte",description:"Bloc de texte simple"},heading1:{title:"Titre 1",description:"Grand titre de section"},heading2:{title:"Titre 2",description:"Titre de section moyen"},heading3:{title:"Titre 3",description:"Petit titre de section"},bulletList:{title:"Liste à puces",description:"Créer une liste à puces"},orderedList:{title:"Liste numérotée",description:"Créer une liste numérotée"},taskList:{title:"Liste de tâches",description:"Créer une liste de tâches avec cases à cocher"},image:{title:"Image",description:"Télécharger ou coller une image"},blockquote:{title:"Citation",description:"Créer un bloc de citation"},codeBlock:{title:"Code",description:"Créer un extrait de code"},horizontalRule:{title:"Séparateur",description:"Créer une ligne horizontale"},layoutTwoColumn:{title:"Mise en page à deux colonnes",description:"Diviser le contenu en deux colonnes côte à côte"},layoutThreeColumn:{title:"Mise en page à trois colonnes",description:"Diviser le contenu en trois colonnes côte à côte"}}},ea={bold:"Gras",italic:"Italique",underline:"Souligné",strike:"Barré",code:"Code en ligne",link:"Lien",turnInto:"Convertir en",colorPicker:"Couleur du texte et du fond",textColor:"Couleur du texte",backgroundColor:"Couleur de fond",recentlyUsed:"Récemment utilisés",openLink:"Ouvrir le lien",removeLink:"Supprimer le lien",confirmLink:"Confirmer le lien",clearLink:"Effacer le lien",blockTypes:{text:"Texte",heading1:"Titre 1",heading2:"Titre 2",heading3:"Titre 3",bulletedList:"Liste à puces",numberedList:"Liste numérotée"}},ta={editor:"Éditeur de texte riche",editorContent:"Zone de contenu de l'éditeur",toolbar:"Barre d'outils de formatage de texte",boldButton:"Activer/désactiver le formatage en gras",italicButton:"Activer/désactiver le formatage en italique",underlineButton:"Activer/désactiver le soulignement",strikeButton:"Activer/désactiver le texte barré",codeButton:"Activer/désactiver le code en ligne",linkButton:"Ajouter ou modifier un lien",turnIntoButton:"Convertir en",colorPickerButton:"Couleur du texte et du fond",headingButton:"Définir le niveau de titre",paragraphButton:"Convertir en paragraphe",dragHandle:"Glisser pour réorganiser le bloc",dropIndicator:"Déposer ici pour déplacer le bloc",blockMenu:"Menu des options de bloc",addBlock:"Ajouter un nouveau bloc",deleteBlock:"Supprimer ce bloc",linkDialog:"Boîte de dialogue d'édition de lien",linkUrlInput:"Entrée d'URL de lien",linkSaveButton:"Enregistrer le lien",linkRemoveButton:"Supprimer le lien",linkCancelButton:"Annuler l'édition du lien",addBlockBelow:"Ajouter un bloc en dessous",dragToMove:"Glisser pour réorganiser le bloc",openLinkInNewTab:"Ouvrir le lien dans un nouvel onglet",linkConfirmButton:"Confirmer le lien",linkOpenButton:"Ouvrir le lien dans un nouvel onglet",linkClearButton:"Effacer la saisie du lien"},na='Écrivez, tapez "/" pour afficher les commandes...',oa="Collez un lien...",ra={modal:{title:"Modifier le graphique",close:"Fermer",save:"Enregistrer",cancel:"Annuler",fields:{chartType:"Type de graphique",title:"Titre",titlePlaceholder:"Titre du graphique...",showLegend:"Afficher la légende",legendPosition:"Position",position:{top:"Haut",bottom:"Bas",left:"Gauche",right:"Droite"},labels:"Étiquettes (séparées par des virgules)",labelsPlaceholder:"Jan, Fév, Mar, Avr...",datasets:{title:"Jeux de données",add:"+ Ajouter un jeu de données",remove:"Supprimer",datasetLabel:"Étiquette",datasetLabelPlaceholder:"Étiquette du jeu de données...",data:"Données (nombres séparés par des virgules)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Graphique à barres",line:"Graphique linéaire",pie:"Graphique circulaire",doughnut:"Graphique en anneau",radar:"Graphique radar",polarArea:"Graphique en coordonnées polaires"}},aa={slashMenu:Qr,toolbar:ea,aria:ta,placeholder:na,linkPlaceholder:oa,chart:ra},ia={groups:{basic:"Basis",list:"Listen",media:"Medien",advanced:"Erweitert",layout:"Layout"},commands:{paragraph:{title:"Text",description:"Einfacher Textblock"},heading1:{title:"Überschrift 1",description:"Große Abschnittsüberschrift"},heading2:{title:"Überschrift 2",description:"Mittlere Abschnittsüberschrift"},heading3:{title:"Überschrift 3",description:"Kleine Abschnittsüberschrift"},bulletList:{title:"Aufzählungsliste",description:"Aufzählungsliste erstellen"},orderedList:{title:"Nummerierte Liste",description:"Nummerierte Liste erstellen"},taskList:{title:"To-do-Liste",description:"To-do-Liste mit Kontrollkästchen erstellen"},image:{title:"Bild",description:"Bild hochladen oder einfügen"},blockquote:{title:"Zitat",description:"Zitatblock erstellen"},codeBlock:{title:"Code",description:"Codeausschnitt erstellen"},horizontalRule:{title:"Trennlinie",description:"Horizontale Linie erstellen"},layoutTwoColumn:{title:"Zweispaltiges Layout",description:"Inhalt in zwei nebeneinander liegende Spalten aufteilen"},layoutThreeColumn:{title:"Dreispaltiges Layout",description:"Inhalt in drei nebeneinander liegende Spalten aufteilen"}}},sa={bold:"Fett",italic:"Kursiv",underline:"Unterstrichen",strike:"Durchgestrichen",code:"Inline-Code",link:"Link",turnInto:"Umwandeln in",colorPicker:"Text- und Hintergrundfarbe",textColor:"Textfarbe",backgroundColor:"Hintergrundfarbe",recentlyUsed:"Zuletzt verwendet",openLink:"Link öffnen",removeLink:"Link entfernen",confirmLink:"Link bestätigen",clearLink:"Link löschen",blockTypes:{text:"Text",heading1:"Überschrift 1",heading2:"Überschrift 2",heading3:"Überschrift 3",bulletedList:"Aufzählungsliste",numberedList:"Nummerierte Liste"}},la={editor:"Rich-Text-Editor",editorContent:"Editor-Inhaltsbereich",toolbar:"Textformatierungs-Symbolleiste",boldButton:"Fettformatierung ein/aus",italicButton:"Kursivformatierung ein/aus",underlineButton:"Unterstreichung ein/aus",strikeButton:"Durchstreichung ein/aus",codeButton:"Inline-Code-Formatierung ein/aus",linkButton:"Link hinzufügen oder bearbeiten",turnIntoButton:"Umwandeln in",colorPickerButton:"Text- und Hintergrundfarbe",headingButton:"Überschriftsebene festlegen",paragraphButton:"In Absatz umwandeln",dragHandle:"Zum Neuordnen des Blocks ziehen",dropIndicator:"Hier ablegen, um Block zu verschieben",blockMenu:"Block-Optionsmenü",addBlock:"Neuen Block hinzufügen",deleteBlock:"Diesen Block löschen",linkDialog:"Link-Bearbeitungsdialog",linkUrlInput:"Link-URL-Eingabe",linkSaveButton:"Link speichern",linkRemoveButton:"Link entfernen",linkCancelButton:"Link-Bearbeitung abbrechen",addBlockBelow:"Block darunter hinzufügen",dragToMove:"Zum Neuordnen des Blocks ziehen",openLinkInNewTab:"Link in neuem Tab öffnen",linkConfirmButton:"Link bestätigen",linkOpenButton:"Link in neuem Tab öffnen",linkClearButton:"Link-Eingabe löschen"},ca='Schreiben, tippen Sie "/" für Befehle...',ua="Link einfügen...",da={modal:{title:"Chart bearbeiten",close:"Schließen",save:"Speichern",cancel:"Abbrechen",fields:{chartType:"Chart-Typ",title:"Titel",titlePlaceholder:"Chart-Titel...",showLegend:"Legende anzeigen",legendPosition:"Position",position:{top:"Oben",bottom:"Unten",left:"Links",right:"Rechts"},labels:"Beschriftungen (kommagetrennt)",labelsPlaceholder:"Jan, Feb, Mär, Apr...",datasets:{title:"Datensätze",add:"+ Datensatz hinzufügen",remove:"Entfernen",datasetLabel:"Datensatz",datasetLabelPlaceholder:"Datensatz-Beschriftung...",data:"Daten (kommagetrennte Zahlen)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Balkendiagramm",line:"Liniendiagramm",pie:"Kreisdiagramm",doughnut:"Ringdiagramm",radar:"Netzdiagramm",polarArea:"Polärfächen-Diagramm"}},pa={slashMenu:ia,toolbar:sa,aria:la,placeholder:ca,linkPlaceholder:ua,chart:da},fa={groups:{basic:"Básico",list:"Listas",media:"Medios",advanced:"Avanzado",layout:"Diseño"},commands:{paragraph:{title:"Texto",description:"Bloque de texto plano"},heading1:{title:"Título 1",description:"Título de sección grande"},heading2:{title:"Título 2",description:"Título de sección mediano"},heading3:{title:"Título 3",description:"Título de sección pequeño"},bulletList:{title:"Lista con viñetas",description:"Crear una lista con viñetas"},orderedList:{title:"Lista numerada",description:"Crear una lista numerada"},taskList:{title:"Lista de tareas",description:"Crear una lista de tareas con casillas"},image:{title:"Imagen",description:"Subir o pegar una imagen"},blockquote:{title:"Cita",description:"Crear un bloque de cita"},codeBlock:{title:"Código",description:"Crear un fragmento de código"},horizontalRule:{title:"Divisor",description:"Crear una línea horizontal"},layoutTwoColumn:{title:"Diseño de dos columnas",description:"Dividir el contenido en dos columnas una al lado de la otra"},layoutThreeColumn:{title:"Diseño de tres columnas",description:"Dividir el contenido en tres columnas una al lado de la otra"}}},ha={bold:"Negrita",italic:"Cursiva",underline:"Subrayado",strike:"Tachado",code:"Código en línea",link:"Enlace",turnInto:"Convertir en",colorPicker:"Color de texto y fondo",textColor:"Color del texto",backgroundColor:"Color de fondo",recentlyUsed:"Recientemente usados",openLink:"Abrir enlace",removeLink:"Eliminar enlace",confirmLink:"Confirmar enlace",clearLink:"Limpiar enlace",blockTypes:{text:"Texto",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3",bulletedList:"Lista con viñetas",numberedList:"Lista numerada"}},ba={editor:"Editor de texto enriquecido",editorContent:"Área de contenido del editor",toolbar:"Barra de herramientas de formato de texto",boldButton:"Activar/desactivar formato en negrita",italicButton:"Activar/desactivar formato en cursiva",underlineButton:"Activar/desactivar subrayado",strikeButton:"Activar/desactivar tachado",codeButton:"Activar/desactivar código en línea",linkButton:"Añadir o editar enlace",turnIntoButton:"Convertir en",colorPickerButton:"Color de texto y fondo",headingButton:"Establecer nivel de título",paragraphButton:"Convertir a párrafo",dragHandle:"Arrastrar para reorganizar el bloque",dropIndicator:"Soltar aquí para mover el bloque",blockMenu:"Menú de opciones del bloque",addBlock:"Añadir nuevo bloque",deleteBlock:"Eliminar este bloque",linkDialog:"Diálogo de edición de enlace",linkUrlInput:"Entrada de URL del enlace",linkSaveButton:"Guardar enlace",linkRemoveButton:"Eliminar enlace",linkCancelButton:"Cancelar edición de enlace",addBlockBelow:"Añadir bloque debajo",dragToMove:"Arrastrar para reorganizar el bloque",openLinkInNewTab:"Abrir enlace en nueva pestaña",linkConfirmButton:"Confirmar enlace",linkOpenButton:"Abrir enlace en nueva pestaña",linkClearButton:"Limpiar entrada de enlace"},va='Escribe, escribe "/" para comandos...',ga="Pegue un enlace...",ma={modal:{title:"Editar gráfico",close:"Cerrar",save:"Guardar",cancel:"Cancelar",fields:{chartType:"Tipo de gráfico",title:"Título",titlePlaceholder:"Título del gráfico...",showLegend:"Mostrar leyenda",legendPosition:"Posición",position:{top:"Arriba",bottom:"Abajo",left:"Izquierda",right:"Derecha"},labels:"Etiquetas (separadas por comas)",labelsPlaceholder:"Ene, Feb, Mar, Abr...",datasets:{title:"Conjuntos de datos",add:"+ Añadir conjunto de datos",remove:"Eliminar",datasetLabel:"Etiqueta",datasetLabelPlaceholder:"Etiqueta del conjunto de datos...",data:"Datos (números separados por comas)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Gráfico de barras",line:"Gráfico de líneas",pie:"Gráfico circular",doughnut:"Gráfico de anillo",radar:"Gráfico radar",polarArea:"Gráfico de área polar"}},xa={slashMenu:fa,toolbar:ha,aria:ba,placeholder:va,linkPlaceholder:ga,chart:ma},ya={groups:{basic:"Básico",list:"Listas",media:"Mídia",advanced:"Avançado",layout:"Layout"},commands:{paragraph:{title:"Texto",description:"Bloco de texto simples"},heading1:{title:"Título 1",description:"Título de seção grande"},heading2:{title:"Título 2",description:"Título de seção médio"},heading3:{title:"Título 3",description:"Título de seção pequeno"},bulletList:{title:"Lista com marcadores",description:"Criar uma lista com marcadores"},orderedList:{title:"Lista numerada",description:"Criar uma lista numerada"},taskList:{title:"Lista de tarefas",description:"Criar uma lista de tarefas com caixas de seleção"},image:{title:"Imagem",description:"Enviar ou colar uma imagem"},blockquote:{title:"Citação",description:"Criar um bloco de citação"},codeBlock:{title:"Código",description:"Criar um trecho de código"},horizontalRule:{title:"Divisor",description:"Criar uma linha horizontal"},layoutTwoColumn:{title:"Layout de duas colunas",description:"Dividir o conteúdo em duas colunas lado a lado"},layoutThreeColumn:{title:"Layout de três colunas",description:"Dividir o conteúdo em três colunas lado a lado"}}},wa={bold:"Negrito",italic:"Itálico",underline:"Sublinhado",strike:"Tachado",code:"Código inline",link:"Link",turnInto:"Converter em",colorPicker:"Cor do texto e fundo",textColor:"Cor do texto",backgroundColor:"Cor de fundo",recentlyUsed:"Usados recentemente",openLink:"Abrir link",removeLink:"Remover link",confirmLink:"Confirmar link",clearLink:"Limpar link",blockTypes:{text:"Texto",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3",bulletedList:"Lista com marcadores",numberedList:"Lista numerada"}},ka={editor:"Editor de texto rico",editorContent:"Área de conteúdo do editor",toolbar:"Barra de ferramentas de formatação de texto",boldButton:"Alternar formatação em negrito",italicButton:"Alternar formatação em itálico",underlineButton:"Alternar sublinhado",strikeButton:"Alternar tachado",codeButton:"Alternar código inline",linkButton:"Adicionar ou editar link",turnIntoButton:"Converter em",colorPickerButton:"Cor do texto e fundo",headingButton:"Definir nível de título",paragraphButton:"Converter em parágrafo",dragHandle:"Arrastar para reorganizar o bloco",dropIndicator:"Soltar aqui para mover o bloco",blockMenu:"Menu de opções do bloco",addBlock:"Adicionar novo bloco",deleteBlock:"Excluir este bloco",linkDialog:"Diálogo de edição de link",linkUrlInput:"Entrada de URL do link",linkSaveButton:"Salvar link",linkRemoveButton:"Remover link",linkCancelButton:"Cancelar edição de link",addBlockBelow:"Adicionar bloco abaixo",dragToMove:"Arrastar para reorganizar o bloco",openLinkInNewTab:"Abrir link em nova aba",linkConfirmButton:"Confirmar link",linkOpenButton:"Abrir link em nova aba",linkClearButton:"Limpar entrada de link"},Ca='Escreva, digite "/" para comandos...',La="Cole um link...",Ta={modal:{title:"Editar gráfico",close:"Fechar",save:"Salvar",cancel:"Cancelar",fields:{chartType:"Tipo de gráfico",title:"Título",titlePlaceholder:"Título do gráfico...",showLegend:"Mostrar legenda",legendPosition:"Posição",position:{top:"Superior",bottom:"Inferior",left:"Esquerda",right:"Direita"},labels:"Rótulos (separados por vírgula)",labelsPlaceholder:"Jan, Fev, Mar, Abr...",datasets:{title:"Conjuntos de dados",add:"+ Adicionar conjunto de dados",remove:"Remover",datasetLabel:"Rótulo",datasetLabelPlaceholder:"Rótulo do conjunto de dados...",data:"Dados (números separados por vírgula)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Gráfico de barras",line:"Gráfico de linhas",pie:"Gráfico de pizza",doughnut:"Gráfico de rosca",radar:"Gráfico de radar",polarArea:"Gráfico de área polar"}},Ba={slashMenu:ya,toolbar:wa,aria:ka,placeholder:Ca,linkPlaceholder:La,chart:Ta},Wt=zn,Aa={en:zn,zh:Pr,"zh-CN":Nr,ja:Wr,ko:Zr,fr:aa,de:pa,es:xa,pt:Ba};function At(e){return e&&Aa[e]||Wt}const qn=m.createContext({locale:Wt}),pn=qn.Provider;function Re(){return m.useContext(qn).locale}const ja=async()=>Promise.resolve().then(()=>require("./auto-BaSO-_S9.cjs"));function $e(e,t,n){const o=getComputedStyle(e),r=t.replace(/^var\(/,"").replace(/\)$/,"");return o.getPropertyValue(r).trim()||n}function Sa(e){var w;const{node:t,updateAttributes:n,editor:o,selected:r}=e,a=t.attrs.data,[s,c]=m.useState(!1),[l,d]=m.useState(!1),[p,x]=m.useState(null),h=m.useRef(null),b=m.useRef(null),f=m.useRef(null),g=Re(),L=((w=o==null?void 0:o.options)==null?void 0:w.editable)??!0,k=m.useCallback(()=>{if(!p||!f.current||!b.current)return;const A=b.current,P=$e(A,"--pubwave-text","#37352f"),I=$e(A,"--pubwave-text-muted","#9b9a97"),B=$e(A,"--pubwave-border","#e3e2e0"),v=p.options.plugins||{},T=p.options.scales;if(v.legend){const j=v.legend;j.labels?j.labels.color=P:v.legend.labels={color:P},j.onHover=()=>{const _=h.current;_&&(_.style.cursor="pointer")},j.onLeave=()=>{const _=h.current;_&&(_.style.cursor="default")}}v.title&&(v.title.color=P),T&&(T.x&&(T.x.ticks&&(T.x.ticks.color=I),T.x.grid&&(T.x.grid.color=B)),T.y&&(T.y.ticks&&(T.y.ticks.color=I),T.y.grid&&(T.y.grid.color=B))),p.update("none")},[p]);m.useEffect(()=>!h.current||!a||!L?void 0:((async()=>{var P,I,B,v,T,j,_,z,$,F,U,R,N;try{const W=(await ja()).default;if(f.current=W,h.current){const Y=W.getChart(h.current);Y&&Y.destroy()}p&&p.destroy();const Q=(P=h.current)==null?void 0:P.getContext("2d");if(!Q){console.warn("Failed to get 2D context for chart");return}const G=b.current,X=G?$e(G,"--pubwave-text","#37352f"):"#37352f",ae=G?$e(G,"--pubwave-text-muted","#9b9a97"):"#9b9a97",be=G?$e(G,"--pubwave-border","#e3e2e0"):"#e3e2e0",ue={...a.options,responsive:!0,maintainAspectRatio:!1,plugins:{...(I=a.options)==null?void 0:I.plugins,legend:{display:((T=(v=(B=a.options)==null?void 0:B.plugins)==null?void 0:v.legend)==null?void 0:T.display)??!0,position:((z=(_=(j=a.options)==null?void 0:j.plugins)==null?void 0:_.legend)==null?void 0:z.position)??"top",...(U=(F=($=a.options)==null?void 0:$.plugins)==null?void 0:F.legend)!=null&&U.labels?{labels:{...a.options.plugins.legend.labels,color:X}}:{labels:{color:X}},onHover:()=>{const Y=h.current;Y&&(Y.style.cursor="pointer")},onLeave:()=>{const Y=h.current;Y&&(Y.style.cursor="default")}},title:(N=(R=a.options)==null?void 0:R.plugins)!=null&&N.title?{...a.options.plugins.title,color:X,...a.options.plugins.title.font?{font:{...a.options.plugins.title.font}}:{}}:void 0},scales:M(a.type)?{x:{ticks:{color:ae},grid:{color:be}},y:{ticks:{color:ae},grid:{color:be}}}:void 0},we=new W(Q,{type:a.type,data:a.data,options:ue});x(we)}catch(V){console.error("Failed to load Chart.js:",V)}})(),()=>{p&&p.destroy()}),[a,L]),m.useEffect(()=>{if(!p||!b.current)return;const A=()=>{setTimeout(()=>{k()},0)},P=new MutationObserver(B=>{B.forEach(v=>{(v.attributeName==="style"||v.attributeName==="class")&&A()})});let I=b.current;for(;I&&(P.observe(I,{attributes:!0}),!(I.classList.contains("pubwave-editor")||I===document.body));)I=I.parentElement;return P.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>{P.disconnect()}},[p,k]);function M(A){return["bar","line","radar"].includes(A)}const C=m.useCallback(A=>{n({data:A}),c(!1)},[n]),u=m.useCallback(()=>{c(!1)},[]),S=m.useCallback(()=>{c(!0)},[]);return a?i.jsxs(xe.NodeViewWrapper,{ref:b,className:"pubwave-editor__chart","data-selected":r,"data-chart-type":a.type,children:[i.jsxs("div",{className:"pubwave-chart__container",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[i.jsx("div",{className:"pubwave-chart__canvas-wrapper",children:i.jsx("canvas",{ref:h,className:"pubwave-chart__canvas"})}),L&&(l||r)&&i.jsx("button",{type:"button",className:"pubwave-chart__edit-button",onClick:S,"aria-label":"Edit chart",title:"Edit chart",children:i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),i.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]}),s&&a&&i.jsx(mr,{initialData:a,onSave:C,onCancel:u,locale:g})]}):i.jsx(xe.NodeViewWrapper,{className:"pubwave-editor__chart",children:i.jsx("div",{className:"pubwave-chart__placeholder",children:"Invalid chart data"})})}const Ma=oe.Node.create({name:"chart",priority:1e3,group:"block",atom:!0,draggable:!0,addAttributes(){return{data:{default:null,parseHTML:e=>{const t=e.getAttribute("data-chart-data");if(t)try{return JSON.parse(t)}catch{return null}return null},renderHTML:e=>e.data?{"data-chart-data":JSON.stringify(e.data)}:{}}}},parseHTML(){return[{tag:'div[data-type="chart"]'}]},renderHTML({HTMLAttributes:e}){return["div",oe.mergeAttributes({"data-type":"chart"},e)]},addNodeView(){return xe.ReactNodeViewRenderer(Sa)}});function Pa(e){return i.jsx(xe.NodeViewWrapper,{className:"pubwave-layout__column","data-type":"layoutColumn",children:i.jsx(xe.NodeViewContent,{as:"div",className:"pubwave-layout__column-content"})})}const Da=oe.Node.create({name:"layout",priority:1e3,group:"block",draggable:!0,content:"layoutColumn+",addAttributes(){return{columns:{default:2,parseHTML:e=>{const t=e.getAttribute("data-layout-columns");return t?parseInt(t,10):2},renderHTML:e=>({"data-layout-columns":String(e.columns)})}}},parseHTML(){return[{tag:'div[data-type="layout"]',getAttrs:e=>{const t=e.getAttribute("data-layout-columns"),n=t?parseInt(t,10):2;return n!==2&&n!==3?!1:{columns:n}}}]},renderHTML({node:e,HTMLAttributes:t}){const n=e.attrs.columns,o=["pubwave-editor__layout",`pubwave-layout--${n}-cols`];return["div",oe.mergeAttributes({"data-type":"layout","data-layout-columns":String(n),class:o.join(" ")},t),0]}}),Ia=oe.Node.create({name:"layoutColumn",priority:1e3,group:"block",isolating:!0,content:"block+",parseHTML(){return[{tag:'div[data-type="layoutColumn"]'},{tag:"div.pubwave-layout__column"}]},renderHTML({HTMLAttributes:e}){return["div",oe.mergeAttributes({"data-type":"layoutColumn",class:"pubwave-layout__column"},e),0]},addNodeView(){return xe.ReactNodeViewRenderer(Pa)}});async function Ra(e,t){const n=(t==null?void 0:t.maxSize)??10485760;if(e.size>n)throw new Error(`Image file is too large. Maximum size is ${n/1024/1024}MB`);if(t!=null&&t.handler)try{return await t.handler(e)}catch(o){console.warn("Custom image upload failed, falling back to base64:",o)}return new Promise((o,r)=>{const a=new FileReader;a.onload=s=>{var l;const c=(l=s.target)==null?void 0:l.result;c?o(c):r(new Error("Failed to read image file"))},a.onerror=()=>{r(new Error("Failed to read image file"))},a.readAsDataURL(e)})}function Oa(e={}){const{headingLevels:t=[1,2,3],imageUpload:n}=e;return[Yo,Ko.configure({HTMLAttributes:{class:"pubwave-editor__paragraph"}}),Xo,ir,Jo.configure({levels:t,HTMLAttributes:{class:"pubwave-editor__heading"}}),Zo.configure({HTMLAttributes:{class:"pubwave-editor__bullet-list"}}),Qo.configure({HTMLAttributes:{class:"pubwave-editor__ordered-list"}}),er.configure({HTMLAttributes:{class:"pubwave-editor__list-item"}}),tr.configure({HTMLAttributes:{class:"pubwave-editor__task-list"}}),nr.configure({nested:!0,HTMLAttributes:{class:"pubwave-editor__task-item"}}),or.configure({HTMLAttributes:{class:"pubwave-editor__blockquote"}}),rr.configure({HTMLAttributes:{class:"pubwave-editor__code-block"}}),ar.configure({HTMLAttributes:{class:"pubwave-editor__divider"}}),sr.extend({addProseMirrorPlugins(){return[new Pt.Plugin({key:new Pt.PluginKey("imagePasteHandler"),props:{handlePaste:(o,r)=>{var s;const a=Array.from(((s=r.clipboardData)==null?void 0:s.items)||[]);for(const c of a)if(c.type.indexOf("image")===0){r.preventDefault();const l=c.getAsFile();if(l)return Ra(l,n).then(d=>{const{state:p,dispatch:x}=o,h=p.schema.nodes.image;if(h){const b=h.create({src:d}),f=p.tr.replaceSelectionWith(b);x(f)}}).catch(d=>{console.error("Failed to upload image:",d)}),!0}return!1}}})]}}).configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"pubwave-editor__image"}}),Ma.configure({HTMLAttributes:{class:"pubwave-editor__chart"}}),Da.configure({HTMLAttributes:{class:"pubwave-editor__layout"}}),Ia.configure({HTMLAttributes:{class:"pubwave-editor__layout-column"}})]}const Ea=oe.Mark.create({name:"textColor",excludes:"",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{color:{default:null,parseHTML:e=>{if(typeof e=="string")return null;const t=e;return t.style.color||t.getAttribute("data-color")||null},renderHTML:e=>e.color?{style:`color: ${e.color}`,"data-color":e.color}:{}}}},parseHTML(){return[{tag:'span[style*="color"]',getAttrs:e=>{if(typeof e=="string")return!1;const t=e,n=t.style.color||t.getAttribute("data-color");return n?{color:n}:!1}}]},renderHTML({HTMLAttributes:e}){return["span",oe.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setColor:e=>({chain:t,state:n})=>{var r,a,s;const o=((a=(r=n.storedMarks)==null?void 0:r.find(c=>c.type.name===this.name))==null?void 0:a.attrs)||((s=n.selection.$from.marks().find(c=>c.type.name===this.name))==null?void 0:s.attrs);return(o==null?void 0:o.color)===e?!0:n.selection.empty?t().focus().unsetMark(this.name).setMark(this.name,{color:e}).run():t().focus().unsetMark(this.name).setMark(this.name,{color:e}).run()},unsetColor:()=>({chain:e})=>e().unsetMark(this.name).run()}}}),_a=oe.Mark.create({name:"backgroundColor",excludes:"",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{backgroundColor:{default:null,parseHTML:e=>{if(typeof e=="string")return null;const t=e;return t.style.backgroundColor||t.getAttribute("data-background-color")||null},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`,"data-background-color":e.backgroundColor}:{}}}},parseHTML(){return[{tag:'span[style*="background-color"]',getAttrs:e=>{if(typeof e=="string")return!1;const t=e,n=t.style.backgroundColor||t.getAttribute("data-background-color");return n?{backgroundColor:n}:!1}}]},renderHTML({HTMLAttributes:e}){return["span",oe.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBackgroundColor:e=>({chain:t,state:n})=>{var r,a,s;const o=((a=(r=n.storedMarks)==null?void 0:r.find(c=>c.type.name===this.name))==null?void 0:a.attrs)||((s=n.selection.$from.marks().find(c=>c.type.name===this.name))==null?void 0:s.attrs);return(o==null?void 0:o.backgroundColor)===e?!0:n.selection.empty?t().focus().unsetMark(this.name).setMark(this.name,{backgroundColor:e}).run():t().focus().unsetMark(this.name).setMark(this.name,{backgroundColor:e}).run()},unsetBackgroundColor:()=>({chain:e})=>e().unsetMark(this.name).run()}}});function Na(e={}){const{linkOpenInNewTab:t=!0,linkOpenOnClick:n=!0}=e;return[cr.configure({HTMLAttributes:{class:"pubwave-editor__mark--bold"}}),ur.configure({HTMLAttributes:{class:"pubwave-editor__mark--italic"}}),dr.configure({HTMLAttributes:{class:"pubwave-editor__mark--underline"}}),pr.configure({HTMLAttributes:{class:"pubwave-editor__mark--strike"}}),fr.configure({HTMLAttributes:{class:"pubwave-editor__mark--code"}}),hr.configure({openOnClick:n,HTMLAttributes:{class:"pubwave-editor__mark--link",rel:t?"noopener noreferrer":void 0,target:t?"_blank":void 0},validate:o=>{try{return new URL(o),!0}catch{return o.startsWith("/")||o.startsWith("#")}}}),Ea.configure({HTMLAttributes:{class:"pubwave-editor__mark--text-color"}}),_a.configure({HTMLAttributes:{class:"pubwave-editor__mark--background-color"}})]}function Ha(e,t,n){m.useEffect(()=>{if(e>=0&&n.current&&t.current){const o=t.current,r=n.current,a=o.scrollTop,s=o.clientHeight,c=o.scrollHeight,l=r.offsetTop,d=r.offsetHeight,p=o.querySelector(".pubwave-slash-menu__group"),x=o.querySelector(".pubwave-slash-menu__item"),h=Array.from(o.querySelectorAll(".pubwave-slash-menu__item")).pop(),b=l-a,f=b+d;let g=a;if(b<0)g=l-4,p&&g>p.offsetTop&&(g=Math.max(0,p.offsetTop)),x&&g>x.offsetTop-2&&(g=Math.max(0,x.offsetTop-2));else if(f>s){if(g=l-s+d+4,h){const k=h.offsetTop+h.offsetHeight-s+2;g>k&&(g=k)}g=Math.min(c-s,g)}Math.abs(g-a)>.5&&(o.scrollTop=g)}},[e,t,n])}const $a={backgroundColor:"var(--pubwave-bg, #ffffff)",border:"1px solid var(--pubwave-border, #e5e7eb)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",maxHeight:"280px",overflowY:"auto",minWidth:"240px",maxWidth:"300px",padding:"var(--pubwave-spacing-1, 4px)",display:"flex",flexDirection:"column"},za={marginBottom:"0"},qa={padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px) var(--pubwave-spacing-1, 4px)",fontSize:"var(--pubwave-font-size-xs, 11px)",fontWeight:600,color:"var(--pubwave-text-muted, #6b7280)",textTransform:"uppercase",letterSpacing:"0.5px"},Ua={display:"flex",alignItems:"center",gap:"var(--pubwave-spacing-3, 12px)",width:"100%",padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px)",border:"none",background:"none",cursor:"pointer",textAlign:"left",borderRadius:"var(--pubwave-radius-md, 6px)",transition:"background-color 0.1s ease",fontSize:"var(--pubwave-font-size-base, 14px)",color:"var(--pubwave-text, #1a1a1a)"},Fa={display:"flex",alignItems:"center",justifyContent:"center",width:"var(--pubwave-icon-size, 20px)",height:"var(--pubwave-icon-size, 20px)",color:"var(--pubwave-text-tertiary, #4b5563)",flexShrink:0},Wa={fontSize:"var(--pubwave-font-size-base, 14px)",fontWeight:400,color:"var(--pubwave-text, #1a1a1a)"},Va=typeof window>"u",_t=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement=="function";function K(e){return _t?window.requestAnimationFrame(e):0}function ut(){if(!_t)return!1;const e="ontouchstart"in window||navigator.maxTouchPoints>0,t=window.matchMedia("(pointer: coarse)").matches,n=window.matchMedia("(hover: hover)").matches;return e&&t||e&&!n}function Un(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 7V4h16v3M9 20h6M12 4v16"})})}function Fn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M17 10l3-2v12"})})}function Wn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M21 18h-5c0-2.5 5-2.5 5-5 0-1.5-1-3-3-3s-3 1.5-3 3"})})}function Vn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M17 12h3M17 18c2.5 0 4-1 4-3s-1.5-3-4-3"})})}function Gn(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"9",y1:"6",x2:"20",y2:"6"}),i.jsx("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),i.jsx("line",{x1:"9",y1:"18",x2:"20",y2:"18"}),i.jsx("circle",{cx:"4",cy:"6",r:"1.5",fill:"currentColor"}),i.jsx("circle",{cx:"4",cy:"12",r:"1.5",fill:"currentColor"}),i.jsx("circle",{cx:"4",cy:"18",r:"1.5",fill:"currentColor"})]})}function Yn(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),i.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),i.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"}),i.jsx("text",{x:"3",y:"8",fontSize:"8",fill:"currentColor",stroke:"none",children:"1"}),i.jsx("text",{x:"3",y:"14",fontSize:"8",fill:"currentColor",stroke:"none",children:"2"}),i.jsx("text",{x:"3",y:"20",fontSize:"8",fill:"currentColor",stroke:"none",children:"3"})]})}function Ga(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"6,9 12,15 18,9"})})}function Ya(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M4 2h5a3 3 0 0 1 0 6H4V2z"}),i.jsx("path",{d:"M4 8h6a3 3 0 0 1 0 6H4V8z"})]})}function Ka(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"11",y1:"2",x2:"5",y2:"14"}),i.jsx("line",{x1:"6",y1:"2",x2:"12",y2:"2"}),i.jsx("line",{x1:"4",y1:"14",x2:"10",y2:"14"})]})}function Xa(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M4 2v6a4 4 0 0 0 8 0V2"}),i.jsx("line",{x1:"2",y1:"14",x2:"14",y2:"14"})]})}function Ja(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"}),i.jsx("path",{d:"M5 4c0-1 1.5-2 3-2s3 .5 3 2c0 1-1 2-3 2"}),i.jsx("path",{d:"M5 12c0 1 1.5 2 3 2s3-.5 3-2c0-1-1-2-3-2"})]})}function Za(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("polyline",{points:"5 4 1 8 5 12"}),i.jsx("polyline",{points:"11 4 15 8 11 12"})]})}function Qa(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"1.87 0 12.19 16",fill:"currentColor",children:[i.jsx("path",{d:"M12.848 2.8a3.145 3.145 0 0 0-4.448 0L6.918 4.283a.625.625 0 0 0 .884.883l1.482-1.482c.74-.74 1.94-.74 2.68 0l.294.294c.74.74.74 1.94 0 2.68l-1.482 1.483a.625.625 0 1 0 .884.884l1.482-1.482a3.145 3.145 0 0 0 0-4.449z"}),i.jsx("path",{d:"M10.472 5.47a.625.625 0 0 0-.884 0L5.229 9.83a.625.625 0 1 0 .884.883l4.359-4.359a.625.625 0 0 0 0-.883"}),i.jsx("path",{d:"M5.167 6.918a.625.625 0 0 0-.884 0L2.8 8.4a3.146 3.146 0 0 0 0 4.448l.294.294a3.145 3.145 0 0 0 4.449 0l1.482-1.482a.625.625 0 0 0-.884-.884L6.66 12.258c-.74.74-1.94.74-2.68 0l-.295-.294c-.74-.74-.74-1.94 0-2.68L5.167 7.8a.625.625 0 0 0 0-.883"})]})}function ei(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M10 3h4v4M14 3l-7 7M14 11v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3"})})}function ti(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M13 4L6 11l-3-3"})})}function ni(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),i.jsx("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]})}function oi({textColor:e,backgroundColor:t}){const n=t||"transparent",o=!t;return i.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",backgroundColor:n,border:o?"1px solid var(--pubwave-border)":"none",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:e,lineHeight:1},children:"A"})})}function ri(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"3",y:"5",width:"4",height:"4",rx:"0.5"}),i.jsx("rect",{x:"3",y:"14",width:"4",height:"4",rx:"0.5"}),i.jsx("path",{d:"M4 16l1.5 1.5L7 15"}),i.jsx("line",{x1:"10",y1:"7",x2:"21",y2:"7"}),i.jsx("line",{x1:"10",y1:"16",x2:"21",y2:"16"})]})}function ai(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.75-2-2-2H4c-1.25 0-2 .75-2 2v6c0 1.25.75 2 2 2h4"}),i.jsx("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.75-2-2-2h-4c-1.25 0-2 .75-2 2v6c0 1.25.75 2 2 2h4"})]})}function ii(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("polyline",{points:"16,18 22,12 16,6"}),i.jsx("polyline",{points:"8,6 2,12 8,18"})]})}function si(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"})})}function li(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),i.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),i.jsx("polyline",{points:"21,15 16,10 5,21"})]})}function ci(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"2",y:"3",width:"20",height:"18",rx:"2"}),i.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]})}function ui(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"2",y:"3",width:"20",height:"18",rx:"2"}),i.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"21"}),i.jsx("line",{x1:"16",y1:"3",x2:"16",y2:"21"})]})}async function di(e,t){const n=(t==null?void 0:t.maxSize)??10485760;if(e.size>n)throw new Error(`Image file is too large. Maximum size is ${n/1024/1024}MB`);if(t!=null&&t.handler)try{return await t.handler(e)}catch(o){console.warn("Custom image upload failed, falling back to base64:",o)}return new Promise((o,r)=>{const a=new FileReader;a.onload=s=>{var l;const c=(l=s.target)==null?void 0:l.result;c?o(c):r(new Error("Failed to read image file"))},a.onerror=()=>{r(new Error("Failed to read image file"))},a.readAsDataURL(e)})}function pi(e,t,n){if(!((n==null?void 0:n.accept)??["image/*"]).some(a=>a==="image/*"?t.type.startsWith("image/"):t.type===a)){console.warn("Selected file is not an image");return}di(t,n).then(a=>{e.chain().focus().setImage({src:a}).run()}).catch(a=>{console.error("Failed to upload image:",a)})}function fn(e,t){const{state:n,dispatch:o}=e.view,r=n.schema.nodes.layout,a=n.schema.nodes.layoutColumn;if(!r||!a){console.warn("Layout node type not found in schema");return}const s=n.schema.nodes.paragraph;if(!s){console.warn("Paragraph node type not found in schema");return}const c=Array.from({length:t},()=>a.create(null,s.create())),l=r.create({columns:t},c),d=n.tr.replaceSelectionWith(l);o(d);const p=d.selection.$from.before();e.chain().focus().setTextSelection(p+2).run()}function Kn(e,t){var r,a,s,c;const o=(t||{slashMenu:{commands:{paragraph:{title:"Text",description:"Plain text block"},heading1:{title:"Heading 1",description:"Large section heading"},heading2:{title:"Heading 2",description:"Medium section heading"},heading3:{title:"Heading 3",description:"Small section heading"},bulletList:{title:"Bullet List",description:"Create a bulleted list"},orderedList:{title:"Numbered List",description:"Create a numbered list"},taskList:{title:"To-do list",description:"Create a todo list with checkboxes"},image:{title:"Image",description:"Upload or paste an image"},blockquote:{title:"Blockquote",description:"Create a quote block"},codeBlock:{title:"Code",description:"Create a code snippet"},horizontalRule:{title:"Divider",description:"Create a horizontal line"},layoutTwoColumn:{title:"Two Column Layout",description:"Split content into two side-by-side columns"},layoutThreeColumn:{title:"Three Column Layout",description:"Split content into three side-by-side columns"}}}}).slashMenu.commands;return[{id:"paragraph",title:o.paragraph.title,description:o.paragraph.description,icon:i.jsx(Un,{}),aliases:["p","text","paragraph"],group:"basic",action:l=>l.chain().focus().setParagraph().run()},{id:"heading1",title:o.heading1.title,description:o.heading1.description,icon:i.jsx(Fn,{}),aliases:["h1","title"],group:"basic",action:l=>l.chain().focus().toggleHeading({level:1}).run()},{id:"heading2",title:o.heading2.title,description:o.heading2.description,icon:i.jsx(Wn,{}),aliases:["h2","subtitle"],group:"basic",action:l=>l.chain().focus().toggleHeading({level:2}).run()},{id:"heading3",title:o.heading3.title,description:o.heading3.description,icon:i.jsx(Vn,{}),aliases:["h3"],group:"basic",action:l=>l.chain().focus().toggleHeading({level:3}).run()},{id:"bulletList",title:o.bulletList.title,description:o.bulletList.description,icon:i.jsx(Gn,{}),aliases:["ul","bullet","unordered","-"],group:"list",action:l=>l.chain().focus().toggleBulletList().run()},{id:"orderedList",title:o.orderedList.title,description:o.orderedList.description,icon:i.jsx(Yn,{}),aliases:["ol","numbered","ordered","1."],group:"list",action:l=>l.chain().focus().toggleOrderedList().run()},{id:"taskList",title:o.taskList.title,description:o.taskList.description,icon:i.jsx(ri,{}),aliases:["todo","task","checkbox","[]"],group:"list",action:l=>l.chain().focus().toggleTaskList().run()},{id:"image",title:o.image.title,description:o.image.description,icon:i.jsx(li,{}),aliases:["img","picture","photo","pic"],group:"media",action:l=>{const d=document.createElement("input");d.type="file";const p=(e==null?void 0:e.accept)??["image/*"];d.accept=p.join(","),d.style.display="none",d.onchange=x=>{var b;const h=(b=x.target.files)==null?void 0:b[0];h&&pi(l,h,e),document.body.removeChild(d)},document.body.appendChild(d),d.click()}},{id:"blockquote",title:o.blockquote.title,description:o.blockquote.description,icon:i.jsx(ai,{}),aliases:["quote","blockquote",">"],group:"advanced",action:l=>l.chain().focus().toggleBlockquote().run()},{id:"codeBlock",title:o.codeBlock.title,description:o.codeBlock.description,icon:i.jsx(ii,{}),aliases:["code","pre","snippet","```"],group:"advanced",action:l=>l.chain().focus().toggleCodeBlock().run()},{id:"horizontalRule",title:o.horizontalRule.title,description:o.horizontalRule.description,icon:i.jsx(si,{}),aliases:["hr","divider","line","---"],group:"advanced",action:l=>{l.chain().focus().setHorizontalRule().run(),K(()=>{const{state:d}=l.view,{$from:p}=d.selection;let x=-1;const h=p.pos;if(d.doc.descendants((b,f)=>{if(b.type.name==="horizontalRule"){const g=Math.abs(f-h);(x===-1||Math.abs(x-h)>g)&&(x=f)}}),x!==-1){const b=d.doc.nodeAt(x);if(b){const f=x+b.nodeSize;l.chain().setTextSelection(f).insertContent({type:"paragraph"}).focus().run()}}else l.chain().focus().createParagraphNear().run()})}},{id:"layoutTwoColumn",title:((r=o.layoutTwoColumn)==null?void 0:r.title)??"Two Column Layout",description:((a=o.layoutTwoColumn)==null?void 0:a.description)??"Split content into two side-by-side columns",icon:i.jsx(ci,{}),aliases:["layout2","two columns","2 col","columns"],group:"layout",action:l=>fn(l,2)},{id:"layoutThreeColumn",title:((s=o.layoutThreeColumn)==null?void 0:s.title)??"Three Column Layout",description:((c=o.layoutThreeColumn)==null?void 0:c.description)??"Split content into three side-by-side columns",icon:i.jsx(ui,{}),aliases:["layout3","three columns","3 col"],group:"layout",action:l=>fn(l,3)}]}const Dt=Kn();function fi(e,t){if(!t)return e;const n=t.toLowerCase();return e.filter(o=>{var c;const r=o.title.toLowerCase(),a=r.startsWith(n)||r.includes(` ${n}`),s=((c=o.aliases)==null?void 0:c.some(l=>l.toLowerCase().startsWith(n)))??!1;return a||s})}var ee="top",le="bottom",ce="right",te="left",Zt="auto",dt=[ee,le,ce,te],Ue="start",at="end",hi="clippingParents",Xn="viewport",Ze="popper",bi="reference",hn=dt.reduce(function(e,t){return e.concat([t+"-"+Ue,t+"-"+at])},[]),Jn=[].concat(dt,[Zt]).reduce(function(e,t){return e.concat([t,t+"-"+Ue,t+"-"+at])},[]),vi="beforeRead",gi="read",mi="afterRead",xi="beforeMain",yi="main",wi="afterMain",ki="beforeWrite",Ci="write",Li="afterWrite",Ti=[vi,gi,mi,xi,yi,wi,ki,Ci,Li];function fe(e){return e?(e.nodeName||"").toLowerCase():null}function re(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Ie(e){var t=re(e).Element;return e instanceof t||e instanceof Element}function se(e){var t=re(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function Qt(e){if(typeof ShadowRoot>"u")return!1;var t=re(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function Bi(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var o=t.styles[n]||{},r=t.attributes[n]||{},a=t.elements[n];!se(a)||!fe(a)||(Object.assign(a.style,o),Object.keys(r).forEach(function(s){var c=r[s];c===!1?a.removeAttribute(s):a.setAttribute(s,c===!0?"":c)}))})}function Ai(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(o){var r=t.elements[o],a=t.attributes[o]||{},s=Object.keys(t.styles.hasOwnProperty(o)?t.styles[o]:n[o]),c=s.reduce(function(l,d){return l[d]="",l},{});!se(r)||!fe(r)||(Object.assign(r.style,c),Object.keys(a).forEach(function(l){r.removeAttribute(l)}))})}}const Zn={name:"applyStyles",enabled:!0,phase:"write",fn:Bi,effect:Ai,requires:["computeStyles"]};function pe(e){return e.split("-")[0]}var De=Math.max,It=Math.min,Fe=Math.round;function Vt(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function Qn(){return!/^((?!chrome|android).)*safari/i.test(Vt())}function We(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var o=e.getBoundingClientRect(),r=1,a=1;t&&se(e)&&(r=e.offsetWidth>0&&Fe(o.width)/e.offsetWidth||1,a=e.offsetHeight>0&&Fe(o.height)/e.offsetHeight||1);var s=Ie(e)?re(e):window,c=s.visualViewport,l=!Qn()&&n,d=(o.left+(l&&c?c.offsetLeft:0))/r,p=(o.top+(l&&c?c.offsetTop:0))/a,x=o.width/r,h=o.height/a;return{width:x,height:h,top:p,right:d+x,bottom:p+h,left:d,x:d,y:p}}function en(e){var t=We(e),n=e.offsetWidth,o=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-o)<=1&&(o=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:o}}function eo(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Qt(n)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}function ye(e){return re(e).getComputedStyle(e)}function ji(e){return["table","td","th"].indexOf(fe(e))>=0}function Le(e){return((Ie(e)?e.ownerDocument:e.document)||window.document).documentElement}function Nt(e){return fe(e)==="html"?e:e.assignedSlot||e.parentNode||(Qt(e)?e.host:null)||Le(e)}function bn(e){return!se(e)||ye(e).position==="fixed"?null:e.offsetParent}function Si(e){var t=/firefox/i.test(Vt()),n=/Trident/i.test(Vt());if(n&&se(e)){var o=ye(e);if(o.position==="fixed")return null}var r=Nt(e);for(Qt(r)&&(r=r.host);se(r)&&["html","body"].indexOf(fe(r))<0;){var a=ye(r);if(a.transform!=="none"||a.perspective!=="none"||a.contain==="paint"||["transform","perspective"].indexOf(a.willChange)!==-1||t&&a.willChange==="filter"||t&&a.filter&&a.filter!=="none")return r;r=r.parentNode}return null}function pt(e){for(var t=re(e),n=bn(e);n&&ji(n)&&ye(n).position==="static";)n=bn(n);return n&&(fe(n)==="html"||fe(n)==="body"&&ye(n).position==="static")?t:n||Si(e)||t}function tn(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function nt(e,t,n){return De(e,It(t,n))}function Mi(e,t,n){var o=nt(e,t,n);return o>n?n:o}function to(){return{top:0,right:0,bottom:0,left:0}}function no(e){return Object.assign({},to(),e)}function oo(e,t){return t.reduce(function(n,o){return n[o]=e,n},{})}var Pi=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,no(typeof t!="number"?t:oo(t,dt))};function Di(e){var t,n=e.state,o=e.name,r=e.options,a=n.elements.arrow,s=n.modifiersData.popperOffsets,c=pe(n.placement),l=tn(c),d=[te,ce].indexOf(c)>=0,p=d?"height":"width";if(!(!a||!s)){var x=Pi(r.padding,n),h=en(a),b=l==="y"?ee:te,f=l==="y"?le:ce,g=n.rects.reference[p]+n.rects.reference[l]-s[l]-n.rects.popper[p],L=s[l]-n.rects.reference[l],k=pt(a),M=k?l==="y"?k.clientHeight||0:k.clientWidth||0:0,C=g/2-L/2,u=x[b],S=M-h[p]-x[f],w=M/2-h[p]/2+C,A=nt(u,w,S),P=l;n.modifiersData[o]=(t={},t[P]=A,t.centerOffset=A-w,t)}}function Ii(e){var t=e.state,n=e.options,o=n.element,r=o===void 0?"[data-popper-arrow]":o;r!=null&&(typeof r=="string"&&(r=t.elements.popper.querySelector(r),!r)||eo(t.elements.popper,r)&&(t.elements.arrow=r))}const Ri={name:"arrow",enabled:!0,phase:"main",fn:Di,effect:Ii,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Ve(e){return e.split("-")[1]}var Oi={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ei(e,t){var n=e.x,o=e.y,r=t.devicePixelRatio||1;return{x:Fe(n*r)/r||0,y:Fe(o*r)/r||0}}function vn(e){var t,n=e.popper,o=e.popperRect,r=e.placement,a=e.variation,s=e.offsets,c=e.position,l=e.gpuAcceleration,d=e.adaptive,p=e.roundOffsets,x=e.isFixed,h=s.x,b=h===void 0?0:h,f=s.y,g=f===void 0?0:f,L=typeof p=="function"?p({x:b,y:g}):{x:b,y:g};b=L.x,g=L.y;var k=s.hasOwnProperty("x"),M=s.hasOwnProperty("y"),C=te,u=ee,S=window;if(d){var w=pt(n),A="clientHeight",P="clientWidth";if(w===re(n)&&(w=Le(n),ye(w).position!=="static"&&c==="absolute"&&(A="scrollHeight",P="scrollWidth")),w=w,r===ee||(r===te||r===ce)&&a===at){u=le;var I=x&&w===S&&S.visualViewport?S.visualViewport.height:w[A];g-=I-o.height,g*=l?1:-1}if(r===te||(r===ee||r===le)&&a===at){C=ce;var B=x&&w===S&&S.visualViewport?S.visualViewport.width:w[P];b-=B-o.width,b*=l?1:-1}}var v=Object.assign({position:c},d&&Oi),T=p===!0?Ei({x:b,y:g},re(n)):{x:b,y:g};if(b=T.x,g=T.y,l){var j;return Object.assign({},v,(j={},j[u]=M?"0":"",j[C]=k?"0":"",j.transform=(S.devicePixelRatio||1)<=1?"translate("+b+"px, "+g+"px)":"translate3d("+b+"px, "+g+"px, 0)",j))}return Object.assign({},v,(t={},t[u]=M?g+"px":"",t[C]=k?b+"px":"",t.transform="",t))}function _i(e){var t=e.state,n=e.options,o=n.gpuAcceleration,r=o===void 0?!0:o,a=n.adaptive,s=a===void 0?!0:a,c=n.roundOffsets,l=c===void 0?!0:c,d={placement:pe(t.placement),variation:Ve(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:r,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,vn(Object.assign({},d,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:l})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,vn(Object.assign({},d,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const Ni={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:_i,data:{}};var Tt={passive:!0};function Hi(e){var t=e.state,n=e.instance,o=e.options,r=o.scroll,a=r===void 0?!0:r,s=o.resize,c=s===void 0?!0:s,l=re(t.elements.popper),d=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&d.forEach(function(p){p.addEventListener("scroll",n.update,Tt)}),c&&l.addEventListener("resize",n.update,Tt),function(){a&&d.forEach(function(p){p.removeEventListener("scroll",n.update,Tt)}),c&&l.removeEventListener("resize",n.update,Tt)}}const $i={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Hi,data:{}};var zi={left:"right",right:"left",bottom:"top",top:"bottom"};function jt(e){return e.replace(/left|right|bottom|top/g,function(t){return zi[t]})}var qi={start:"end",end:"start"};function gn(e){return e.replace(/start|end/g,function(t){return qi[t]})}function nn(e){var t=re(e),n=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:n,scrollTop:o}}function on(e){return We(Le(e)).left+nn(e).scrollLeft}function Ui(e,t){var n=re(e),o=Le(e),r=n.visualViewport,a=o.clientWidth,s=o.clientHeight,c=0,l=0;if(r){a=r.width,s=r.height;var d=Qn();(d||!d&&t==="fixed")&&(c=r.offsetLeft,l=r.offsetTop)}return{width:a,height:s,x:c+on(e),y:l}}function Fi(e){var t,n=Le(e),o=nn(e),r=(t=e.ownerDocument)==null?void 0:t.body,a=De(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),s=De(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),c=-o.scrollLeft+on(e),l=-o.scrollTop;return ye(r||n).direction==="rtl"&&(c+=De(n.clientWidth,r?r.clientWidth:0)-a),{width:a,height:s,x:c,y:l}}function rn(e){var t=ye(e),n=t.overflow,o=t.overflowX,r=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+r+o)}function ro(e){return["html","body","#document"].indexOf(fe(e))>=0?e.ownerDocument.body:se(e)&&rn(e)?e:ro(Nt(e))}function ot(e,t){var n;t===void 0&&(t=[]);var o=ro(e),r=o===((n=e.ownerDocument)==null?void 0:n.body),a=re(o),s=r?[a].concat(a.visualViewport||[],rn(o)?o:[]):o,c=t.concat(s);return r?c:c.concat(ot(Nt(s)))}function Gt(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function Wi(e,t){var n=We(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function mn(e,t,n){return t===Xn?Gt(Ui(e,n)):Ie(t)?Wi(t,n):Gt(Fi(Le(e)))}function Vi(e){var t=ot(Nt(e)),n=["absolute","fixed"].indexOf(ye(e).position)>=0,o=n&&se(e)?pt(e):e;return Ie(o)?t.filter(function(r){return Ie(r)&&eo(r,o)&&fe(r)!=="body"}):[]}function Gi(e,t,n,o){var r=t==="clippingParents"?Vi(e):[].concat(t),a=[].concat(r,[n]),s=a[0],c=a.reduce(function(l,d){var p=mn(e,d,o);return l.top=De(p.top,l.top),l.right=It(p.right,l.right),l.bottom=It(p.bottom,l.bottom),l.left=De(p.left,l.left),l},mn(e,s,o));return c.width=c.right-c.left,c.height=c.bottom-c.top,c.x=c.left,c.y=c.top,c}function ao(e){var t=e.reference,n=e.element,o=e.placement,r=o?pe(o):null,a=o?Ve(o):null,s=t.x+t.width/2-n.width/2,c=t.y+t.height/2-n.height/2,l;switch(r){case ee:l={x:s,y:t.y-n.height};break;case le:l={x:s,y:t.y+t.height};break;case ce:l={x:t.x+t.width,y:c};break;case te:l={x:t.x-n.width,y:c};break;default:l={x:t.x,y:t.y}}var d=r?tn(r):null;if(d!=null){var p=d==="y"?"height":"width";switch(a){case Ue:l[d]=l[d]-(t[p]/2-n[p]/2);break;case at:l[d]=l[d]+(t[p]/2-n[p]/2);break}}return l}function it(e,t){t===void 0&&(t={});var n=t,o=n.placement,r=o===void 0?e.placement:o,a=n.strategy,s=a===void 0?e.strategy:a,c=n.boundary,l=c===void 0?hi:c,d=n.rootBoundary,p=d===void 0?Xn:d,x=n.elementContext,h=x===void 0?Ze:x,b=n.altBoundary,f=b===void 0?!1:b,g=n.padding,L=g===void 0?0:g,k=no(typeof L!="number"?L:oo(L,dt)),M=h===Ze?bi:Ze,C=e.rects.popper,u=e.elements[f?M:h],S=Gi(Ie(u)?u:u.contextElement||Le(e.elements.popper),l,p,s),w=We(e.elements.reference),A=ao({reference:w,element:C,placement:r}),P=Gt(Object.assign({},C,A)),I=h===Ze?P:w,B={top:S.top-I.top+k.top,bottom:I.bottom-S.bottom+k.bottom,left:S.left-I.left+k.left,right:I.right-S.right+k.right},v=e.modifiersData.offset;if(h===Ze&&v){var T=v[r];Object.keys(B).forEach(function(j){var _=[ce,le].indexOf(j)>=0?1:-1,z=[ee,le].indexOf(j)>=0?"y":"x";B[j]+=T[z]*_})}return B}function Yi(e,t){t===void 0&&(t={});var n=t,o=n.placement,r=n.boundary,a=n.rootBoundary,s=n.padding,c=n.flipVariations,l=n.allowedAutoPlacements,d=l===void 0?Jn:l,p=Ve(o),x=p?c?hn:hn.filter(function(f){return Ve(f)===p}):dt,h=x.filter(function(f){return d.indexOf(f)>=0});h.length===0&&(h=x);var b=h.reduce(function(f,g){return f[g]=it(e,{placement:g,boundary:r,rootBoundary:a,padding:s})[pe(g)],f},{});return Object.keys(b).sort(function(f,g){return b[f]-b[g]})}function Ki(e){if(pe(e)===Zt)return[];var t=jt(e);return[gn(e),t,gn(t)]}function Xi(e){var t=e.state,n=e.options,o=e.name;if(!t.modifiersData[o]._skip){for(var r=n.mainAxis,a=r===void 0?!0:r,s=n.altAxis,c=s===void 0?!0:s,l=n.fallbackPlacements,d=n.padding,p=n.boundary,x=n.rootBoundary,h=n.altBoundary,b=n.flipVariations,f=b===void 0?!0:b,g=n.allowedAutoPlacements,L=t.options.placement,k=pe(L),M=k===L,C=l||(M||!f?[jt(L)]:Ki(L)),u=[L].concat(C).reduce(function(G,X){return G.concat(pe(X)===Zt?Yi(t,{placement:X,boundary:p,rootBoundary:x,padding:d,flipVariations:f,allowedAutoPlacements:g}):X)},[]),S=t.rects.reference,w=t.rects.popper,A=new Map,P=!0,I=u[0],B=0;B<u.length;B++){var v=u[B],T=pe(v),j=Ve(v)===Ue,_=[ee,le].indexOf(T)>=0,z=_?"width":"height",$=it(t,{placement:v,boundary:p,rootBoundary:x,altBoundary:h,padding:d}),F=_?j?ce:te:j?le:ee;S[z]>w[z]&&(F=jt(F));var U=jt(F),R=[];if(a&&R.push($[T]<=0),c&&R.push($[F]<=0,$[U]<=0),R.every(function(G){return G})){I=v,P=!1;break}A.set(v,R)}if(P)for(var N=f?3:1,V=function(X){var ae=u.find(function(be){var ue=A.get(be);if(ue)return ue.slice(0,X).every(function(we){return we})});if(ae)return I=ae,"break"},W=N;W>0;W--){var Q=V(W);if(Q==="break")break}t.placement!==I&&(t.modifiersData[o]._skip=!0,t.placement=I,t.reset=!0)}}const Ji={name:"flip",enabled:!0,phase:"main",fn:Xi,requiresIfExists:["offset"],data:{_skip:!1}};function xn(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function yn(e){return[ee,ce,le,te].some(function(t){return e[t]>=0})}function Zi(e){var t=e.state,n=e.name,o=t.rects.reference,r=t.rects.popper,a=t.modifiersData.preventOverflow,s=it(t,{elementContext:"reference"}),c=it(t,{altBoundary:!0}),l=xn(s,o),d=xn(c,r,a),p=yn(l),x=yn(d);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:d,isReferenceHidden:p,hasPopperEscaped:x},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":x})}const Qi={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Zi};function es(e,t,n){var o=pe(e),r=[te,ee].indexOf(o)>=0?-1:1,a=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,s=a[0],c=a[1];return s=s||0,c=(c||0)*r,[te,ce].indexOf(o)>=0?{x:c,y:s}:{x:s,y:c}}function ts(e){var t=e.state,n=e.options,o=e.name,r=n.offset,a=r===void 0?[0,0]:r,s=Jn.reduce(function(p,x){return p[x]=es(x,t.rects,a),p},{}),c=s[t.placement],l=c.x,d=c.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=d),t.modifiersData[o]=s}const ns={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:ts};function os(e){var t=e.state,n=e.name;t.modifiersData[n]=ao({reference:t.rects.reference,element:t.rects.popper,placement:t.placement})}const rs={name:"popperOffsets",enabled:!0,phase:"read",fn:os,data:{}};function as(e){return e==="x"?"y":"x"}function is(e){var t=e.state,n=e.options,o=e.name,r=n.mainAxis,a=r===void 0?!0:r,s=n.altAxis,c=s===void 0?!1:s,l=n.boundary,d=n.rootBoundary,p=n.altBoundary,x=n.padding,h=n.tether,b=h===void 0?!0:h,f=n.tetherOffset,g=f===void 0?0:f,L=it(t,{boundary:l,rootBoundary:d,padding:x,altBoundary:p}),k=pe(t.placement),M=Ve(t.placement),C=!M,u=tn(k),S=as(u),w=t.modifiersData.popperOffsets,A=t.rects.reference,P=t.rects.popper,I=typeof g=="function"?g(Object.assign({},t.rects,{placement:t.placement})):g,B=typeof I=="number"?{mainAxis:I,altAxis:I}:Object.assign({mainAxis:0,altAxis:0},I),v=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,T={x:0,y:0};if(w){if(a){var j,_=u==="y"?ee:te,z=u==="y"?le:ce,$=u==="y"?"height":"width",F=w[u],U=F+L[_],R=F-L[z],N=b?-P[$]/2:0,V=M===Ue?A[$]:P[$],W=M===Ue?-P[$]:-A[$],Q=t.elements.arrow,G=b&&Q?en(Q):{width:0,height:0},X=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:to(),ae=X[_],be=X[z],ue=nt(0,A[$],G[$]),we=C?A[$]/2-N-ue-ae-B.mainAxis:V-ue-ae-B.mainAxis,Y=C?-A[$]/2+N+ue+be+B.mainAxis:W+ue+be+B.mainAxis,_e=t.elements.arrow&&pt(t.elements.arrow),ht=_e?u==="y"?_e.clientTop||0:_e.clientLeft||0:0,Ge=(j=v==null?void 0:v[u])!=null?j:0,bt=F+we-Ge-ht,vt=F+Y-Ge,Ye=nt(b?It(U,bt):U,F,b?De(R,vt):R);w[u]=Ye,T[u]=Ye-F}if(c){var Ke,gt=u==="x"?ee:te,mt=u==="x"?le:ce,ve=w[S],ke=S==="y"?"height":"width",Xe=ve+L[gt],Ae=ve-L[mt],Je=[ee,te].indexOf(k)!==-1,xt=(Ke=v==null?void 0:v[S])!=null?Ke:0,yt=Je?Xe:ve-A[ke]-P[ke]-xt+B.altAxis,wt=Je?ve+A[ke]+P[ke]-xt-B.altAxis:Ae,kt=b&&Je?Mi(yt,ve,wt):nt(b?yt:Xe,ve,b?wt:Ae);w[S]=kt,T[S]=kt-ve}t.modifiersData[o]=T}}const ss={name:"preventOverflow",enabled:!0,phase:"main",fn:is,requiresIfExists:["offset"]};function ls(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function cs(e){return e===re(e)||!se(e)?nn(e):ls(e)}function us(e){var t=e.getBoundingClientRect(),n=Fe(t.width)/e.offsetWidth||1,o=Fe(t.height)/e.offsetHeight||1;return n!==1||o!==1}function ds(e,t,n){n===void 0&&(n=!1);var o=se(t),r=se(t)&&us(t),a=Le(t),s=We(e,r,n),c={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(o||!o&&!n)&&((fe(t)!=="body"||rn(a))&&(c=cs(t)),se(t)?(l=We(t,!0),l.x+=t.clientLeft,l.y+=t.clientTop):a&&(l.x=on(a))),{x:s.left+c.scrollLeft-l.x,y:s.top+c.scrollTop-l.y,width:s.width,height:s.height}}function ps(e){var t=new Map,n=new Set,o=[];e.forEach(function(a){t.set(a.name,a)});function r(a){n.add(a.name);var s=[].concat(a.requires||[],a.requiresIfExists||[]);s.forEach(function(c){if(!n.has(c)){var l=t.get(c);l&&r(l)}}),o.push(a)}return e.forEach(function(a){n.has(a.name)||r(a)}),o}function fs(e){var t=ps(e);return Ti.reduce(function(n,o){return n.concat(t.filter(function(r){return r.phase===o}))},[])}function hs(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function bs(e){var t=e.reduce(function(n,o){var r=n[o.name];return n[o.name]=r?Object.assign({},r,o,{options:Object.assign({},r.options,o.options),data:Object.assign({},r.data,o.data)}):o,n},{});return Object.keys(t).map(function(n){return t[n]})}var wn={placement:"bottom",modifiers:[],strategy:"absolute"};function kn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(o){return!(o&&typeof o.getBoundingClientRect=="function")})}function vs(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,o=n===void 0?[]:n,r=t.defaultOptions,a=r===void 0?wn:r;return function(c,l,d){d===void 0&&(d=a);var p={placement:"bottom",orderedModifiers:[],options:Object.assign({},wn,a),modifiersData:{},elements:{reference:c,popper:l},attributes:{},styles:{}},x=[],h=!1,b={state:p,setOptions:function(k){var M=typeof k=="function"?k(p.options):k;g(),p.options=Object.assign({},a,p.options,M),p.scrollParents={reference:Ie(c)?ot(c):c.contextElement?ot(c.contextElement):[],popper:ot(l)};var C=fs(bs([].concat(o,p.options.modifiers)));return p.orderedModifiers=C.filter(function(u){return u.enabled}),f(),b.update()},forceUpdate:function(){if(!h){var k=p.elements,M=k.reference,C=k.popper;if(kn(M,C)){p.rects={reference:ds(M,pt(C),p.options.strategy==="fixed"),popper:en(C)},p.reset=!1,p.placement=p.options.placement,p.orderedModifiers.forEach(function(B){return p.modifiersData[B.name]=Object.assign({},B.data)});for(var u=0;u<p.orderedModifiers.length;u++){if(p.reset===!0){p.reset=!1,u=-1;continue}var S=p.orderedModifiers[u],w=S.fn,A=S.options,P=A===void 0?{}:A,I=S.name;typeof w=="function"&&(p=w({state:p,options:P,name:I,instance:b})||p)}}}},update:hs(function(){return new Promise(function(L){b.forceUpdate(),L(p)})}),destroy:function(){g(),h=!0}};if(!kn(c,l))return b;b.setOptions(d).then(function(L){!h&&d.onFirstUpdate&&d.onFirstUpdate(L)});function f(){p.orderedModifiers.forEach(function(L){var k=L.name,M=L.options,C=M===void 0?{}:M,u=L.effect;if(typeof u=="function"){var S=u({state:p,name:k,instance:b,options:C}),w=function(){};x.push(S||w)}})}function g(){x.forEach(function(L){return L()}),x=[]}return b}}var gs=[$i,rs,Ni,Zn,ns,Ji,ss,Ri,Qi],ms=vs({defaultModifiers:gs}),xs="tippy-box",io="tippy-content",ys="tippy-backdrop",so="tippy-arrow",lo="tippy-svg-arrow",Me={passive:!0,capture:!0},co=function(){return document.body};function ws(e,t){return{}.hasOwnProperty.call(e,t)}function zt(e,t,n){if(Array.isArray(e)){var o=e[t];return o??(Array.isArray(n)?n[t]:n)}return e}function an(e,t){var n={}.toString.call(e);return n.indexOf("[object")===0&&n.indexOf(t+"]")>-1}function uo(e,t){return typeof e=="function"?e.apply(void 0,t):e}function Cn(e,t){if(t===0)return e;var n;return function(o){clearTimeout(n),n=setTimeout(function(){e(o)},t)}}function ks(e,t){var n=Object.assign({},e);return t.forEach(function(o){delete n[o]}),n}function Cs(e){return e.split(/\s+/).filter(Boolean)}function qe(e){return[].concat(e)}function Ln(e,t){e.indexOf(t)===-1&&e.push(t)}function Ls(e){return e.filter(function(t,n){return e.indexOf(t)===n})}function Ts(e){return e.split("-")[0]}function Rt(e){return[].slice.call(e)}function Tn(e){return Object.keys(e).reduce(function(t,n){return e[n]!==void 0&&(t[n]=e[n]),t},{})}function rt(){return document.createElement("div")}function st(e){return["Element","Fragment"].some(function(t){return an(e,t)})}function Bs(e){return an(e,"NodeList")}function As(e){return an(e,"MouseEvent")}function js(e){return!!(e&&e._tippy&&e._tippy.reference===e)}function Ss(e){return st(e)?[e]:Bs(e)?Rt(e):Array.isArray(e)?e:Rt(document.querySelectorAll(e))}function qt(e,t){e.forEach(function(n){n&&(n.style.transitionDuration=t+"ms")})}function Bn(e,t){e.forEach(function(n){n&&n.setAttribute("data-state",t)})}function Ms(e){var t,n=qe(e),o=n[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}function Ps(e,t){var n=t.clientX,o=t.clientY;return e.every(function(r){var a=r.popperRect,s=r.popperState,c=r.props,l=c.interactiveBorder,d=Ts(s.placement),p=s.modifiersData.offset;if(!p)return!0;var x=d==="bottom"?p.top.y:0,h=d==="top"?p.bottom.y:0,b=d==="right"?p.left.x:0,f=d==="left"?p.right.x:0,g=a.top-o+x>l,L=o-a.bottom-h>l,k=a.left-n+b>l,M=n-a.right-f>l;return g||L||k||M})}function Ut(e,t,n){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(r){e[o](r,n)})}function An(e,t){for(var n=t;n;){var o;if(e.contains(n))return!0;n=n.getRootNode==null||(o=n.getRootNode())==null?void 0:o.host}return!1}var de={isTouch:!1},jn=0;function Ds(){de.isTouch||(de.isTouch=!0,window.performance&&document.addEventListener("mousemove",po))}function po(){var e=performance.now();e-jn<20&&(de.isTouch=!1,document.removeEventListener("mousemove",po)),jn=e}function Is(){var e=document.activeElement;if(js(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}function Rs(){document.addEventListener("touchstart",Ds,Me),window.addEventListener("blur",Is)}var Os=typeof window<"u"&&typeof document<"u",Es=Os?!!window.msCrypto:!1;function ze(e){var t=e==="destroy"?"n already-":" ";return[e+"() was called on a"+t+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function Sn(e){var t=/[ \t]{2,}/g,n=/^[ \t]*/gm;return e.replace(t," ").replace(n,"").trim()}function _s(e){return Sn(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("@tiptap/core"),Fo=require("@tiptap/extension-placeholder"),Wo=require("@tiptap/extension-history"),Vo=require("@tiptap/extension-dropcursor"),Go=require("@tiptap/extension-gapcursor"),Yo=require("@tiptap/extension-document"),Ko=require("@tiptap/extension-paragraph"),Xo=require("@tiptap/extension-text"),Jo=require("@tiptap/extension-heading"),Zo=require("@tiptap/extension-bullet-list"),Qo=require("@tiptap/extension-ordered-list"),er=require("@tiptap/extension-list-item"),tr=require("@tiptap/extension-task-list"),nr=require("@tiptap/extension-task-item"),or=require("@tiptap/extension-blockquote"),rr=require("@tiptap/extension-code-block"),ar=require("@tiptap/extension-horizontal-rule"),ir=require("@tiptap/extension-hard-break"),sr=require("@tiptap/extension-image"),ye=require("@tiptap/react"),i=require("react/jsx-runtime"),m=require("react"),lr=require("react-dom"),Pt=require("@tiptap/pm/state"),cr=require("@tiptap/extension-bold"),ur=require("@tiptap/extension-italic"),dr=require("@tiptap/extension-underline"),pr=require("@tiptap/extension-strike"),fr=require("@tiptap/extension-code"),hr=require("@tiptap/extension-link"),br=require("@tiptap/suggestion"),vr=[{value:"bar",label:"bar"},{value:"line",label:"line"},{value:"pie",label:"pie"},{value:"doughnut",label:"doughnut"},{value:"radar",label:"radar"},{value:"polarArea",label:"polarArea"}];function gr(e){return{backgroundColor:`rgba(59, 130, 246, ${.5+e%3*.2})`,borderColor:"rgba(59, 130, 246, 1)"}}function mr({initialData:e,onSave:t,onCancel:n,locale:o}){var B,v,T,A,_,H,z,F,U;const[r,a]=m.useState(e.type),[s,c]=m.useState(((T=(v=(B=e.options)==null?void 0:B.plugins)==null?void 0:v.title)==null?void 0:T.text)??""),[l,d]=m.useState(((H=(_=(A=e.options)==null?void 0:A.plugins)==null?void 0:_.legend)==null?void 0:H.display)??!0),[p,x]=m.useState(((U=(F=(z=e.options)==null?void 0:z.plugins)==null?void 0:F.legend)==null?void 0:U.position)??"bottom"),[h,b]=m.useState(e.data.labels),[f,g]=m.useState(e.data.datasets),L=m.useRef(null),k=(o==null?void 0:o.chart)||{modal:{title:"Edit Chart",close:"Close",save:"Save",cancel:"Cancel",fields:{chartType:"Chart Type",title:"Title",titlePlaceholder:"Chart title...",showLegend:"Show Legend",legendPosition:"Position",position:{top:"Top",bottom:"Bottom",left:"Left",right:"Right"},labels:"Labels",labelsPlaceholder:"Jan, Feb, Mar, Apr...",datasets:{title:"Datasets",add:"+ Add Dataset",remove:"Remove",datasetLabel:"Label",datasetLabelPlaceholder:"Dataset label...",data:"Data",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Bar Chart",line:"Line Chart",pie:"Pie Chart",doughnut:"Doughnut Chart",radar:"Radar Chart",polarArea:"Polar Area Chart"}};m.useEffect(()=>{const I=N=>{N.key==="Escape"&&n()};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[n]),m.useEffect(()=>{const I=W=>{L.current&&L.current.contains(W.target)},N=setTimeout(()=>{document.addEventListener("mousedown",I)},100);return()=>{clearTimeout(N),document.removeEventListener("mousedown",I)}},[]);const M=m.useCallback((I,N)=>{g(W=>W.map((V,K)=>K===I?{...V,label:N}:V))},[]),C=m.useCallback((I,N)=>{g(W=>W.map((V,K)=>K===I?{...V,data:N.split(",").map(Q=>parseFloat(Q.trim())||0)}:V))},[]),u=m.useCallback(()=>{const I=gr(f.length);g(N=>[...N,{label:`${k.modal.fields.datasets.title} ${N.length+1}`,data:h.map(()=>Math.floor(Math.random()*100)),backgroundColor:I.backgroundColor,borderColor:I.borderColor,borderWidth:2}])},[f.length,h,k]),j=m.useCallback(I=>{g(N=>N.filter((W,V)=>V!==I))},[]),w=m.useCallback(I=>{b(I.split(",").map(N=>N.trim()).filter(Boolean))},[]),S=m.useCallback(()=>{const I={type:r,data:{labels:h,datasets:f},options:{...e.options,responsive:!0,maintainAspectRatio:!1,plugins:{title:{display:!!s,text:s,color:"var(--pubwave-text, #37352f)",font:{size:16,weight:"bold"}},legend:{display:l,position:p}}}};t(I)},[r,s,l,p,h,f,e.options,t]),P=m.useCallback(I=>{I.target===I.currentTarget&&n()},[n]),R=i.jsx("div",{className:"pubwave-modal__overlay",onClick:P,children:i.jsxs("div",{ref:L,className:"pubwave-modal__container",role:"dialog","aria-modal":"true","aria-labelledby":"chart-modal-title",children:[i.jsxs("div",{className:"pubwave-modal__header",children:[i.jsx("h2",{id:"chart-modal-title",className:"pubwave-modal__title",children:k.modal.title}),i.jsx("button",{type:"button",className:"pubwave-modal__close",onClick:n,"aria-label":k.modal.close,children:i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),i.jsxs("div",{className:"pubwave-modal__body",children:[i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-type",className:"pubwave-form__label",children:k.modal.fields.chartType}),i.jsx("select",{id:"chart-type",className:"pubwave-form__select",value:r,onChange:I=>a(I.target.value),children:vr.map(I=>i.jsx("option",{value:I.value,children:k.chartTypes[I.value]},I.value))})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-title",className:"pubwave-form__label",children:k.modal.fields.title}),i.jsx("input",{id:"chart-title",type:"text",className:"pubwave-form__input",value:s,onChange:I=>c(I.target.value),placeholder:k.modal.fields.titlePlaceholder})]}),i.jsxs("div",{className:"pubwave-form__row",children:[i.jsx("div",{className:"pubwave-form__field",children:i.jsxs("label",{className:"pubwave-form__checkbox-label",children:[i.jsx("input",{type:"checkbox",className:"pubwave-form__checkbox",checked:l,onChange:I=>d(I.target.checked)}),k.modal.fields.showLegend]})}),l&&i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"legend-position",className:"pubwave-form__label",children:k.modal.fields.legendPosition}),i.jsxs("select",{id:"legend-position",className:"pubwave-form__select",value:p,onChange:I=>x(I.target.value),children:[i.jsx("option",{value:"top",children:k.modal.fields.position.top}),i.jsx("option",{value:"bottom",children:k.modal.fields.position.bottom}),i.jsx("option",{value:"left",children:k.modal.fields.position.left}),i.jsx("option",{value:"right",children:k.modal.fields.position.right})]})]})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:"chart-labels",className:"pubwave-form__label",children:k.modal.fields.labels}),i.jsx("input",{id:"chart-labels",type:"text",className:"pubwave-form__input",value:h.join(", "),onChange:I=>w(I.target.value),placeholder:k.modal.fields.labelsPlaceholder})]}),i.jsxs("div",{className:"pubwave-form__section",children:[i.jsxs("div",{className:"pubwave-form__section-header",children:[i.jsx("h3",{className:"pubwave-form__section-title",children:k.modal.fields.datasets.title}),i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--secondary pubwave-button--small",onClick:u,children:k.modal.fields.datasets.add})]}),f.map((I,N)=>i.jsxs("div",{className:"pubwave-form__dataset",children:[i.jsxs("div",{className:"pubwave-form__dataset-header",children:[i.jsxs("span",{className:"pubwave-form__dataset-title",children:[k.modal.fields.datasets.datasetLabel," ",N+1]}),f.length>1&&i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--danger pubwave-button--small",onClick:()=>j(N),"aria-label":`${k.modal.fields.datasets.remove} ${N+1}`,children:k.modal.fields.datasets.remove})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:`dataset-label-${N}`,className:"pubwave-form__label",children:k.modal.fields.datasets.datasetLabel}),i.jsx("input",{id:`dataset-label-${N}`,type:"text",className:"pubwave-form__input",value:I.label??"",onChange:W=>M(N,W.target.value),placeholder:k.modal.fields.datasets.datasetLabelPlaceholder})]}),i.jsxs("div",{className:"pubwave-form__field",children:[i.jsx("label",{htmlFor:`dataset-data-${N}`,className:"pubwave-form__label",children:k.modal.fields.datasets.data}),i.jsx("input",{id:`dataset-data-${N}`,type:"text",className:"pubwave-form__input",value:I.data.join(", "),onChange:W=>C(N,W.target.value),placeholder:k.modal.fields.datasets.dataPlaceholder})]})]},N))]})]}),i.jsxs("div",{className:"pubwave-modal__footer",children:[i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--secondary",onClick:n,children:k.modal.cancel}),i.jsx("button",{type:"button",className:"pubwave-button pubwave-button--primary",onClick:S,children:k.modal.save})]})]})});return lr.createPortal(R,document.body)}const xr={groups:{basic:"Basic",list:"Lists",media:"Media",advanced:"Advanced",layout:"Layout"},commands:{paragraph:{title:"Text",description:"Plain text block"},heading1:{title:"Heading 1",description:"Large section heading"},heading2:{title:"Heading 2",description:"Medium section heading"},heading3:{title:"Heading 3",description:"Small section heading"},bulletList:{title:"Bullet List",description:"Create a bulleted list"},orderedList:{title:"Numbered List",description:"Create a numbered list"},taskList:{title:"To-do list",description:"Create a todo list with checkboxes"},image:{title:"Image",description:"Upload or paste an image"},blockquote:{title:"Blockquote",description:"Create a quote block"},codeBlock:{title:"Code",description:"Create a code snippet"},horizontalRule:{title:"Divider",description:"Create a horizontal line"},layoutTwoColumn:{title:"Two Column Layout",description:"Split content into two side-by-side columns"},layoutThreeColumn:{title:"Three Column Layout",description:"Split content into three side-by-side columns"}}},yr={bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",code:"Inline Code",link:"Link",turnInto:"Turn Into",colorPicker:"Text and background color",textColor:"Text color",backgroundColor:"Background color",recentlyUsed:"Recently used",openLink:"Open link",removeLink:"Remove link",confirmLink:"Confirm link",clearLink:"Clear link",blockTypes:{text:"Text",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",bulletedList:"Bulleted list",numberedList:"Numbered list"}},wr={editor:"Rich text editor",editorContent:"Editor content area",toolbar:"Text formatting toolbar",boldButton:"Toggle bold formatting",italicButton:"Toggle italic formatting",underlineButton:"Toggle underline formatting",strikeButton:"Toggle strikethrough formatting",codeButton:"Toggle inline code formatting",linkButton:"Add or edit link",turnIntoButton:"Turn into",colorPickerButton:"Text and background color",headingButton:"Set heading level",paragraphButton:"Convert to paragraph",dragHandle:"Drag to reorder block",dropIndicator:"Drop here to move block",blockMenu:"Block options menu",addBlock:"Add new block",deleteBlock:"Delete this block",linkDialog:"Link editor dialog",linkUrlInput:"Link URL input",linkSaveButton:"Save link",linkRemoveButton:"Remove link",linkCancelButton:"Cancel link editing",addBlockBelow:"Add block below",dragToMove:"Drag to reorder block",openLinkInNewTab:"Open link in new tab",linkConfirmButton:"Confirm link",linkOpenButton:"Open link in new tab",linkClearButton:"Clear link input"},kr='Write, type "/" for commands...',Cr="Paste a link...",Lr={modal:{title:"Edit Chart",close:"Close",save:"Save",cancel:"Cancel",fields:{chartType:"Chart Type",title:"Title",titlePlaceholder:"Chart title...",showLegend:"Show Legend",legendPosition:"Position",position:{top:"Top",bottom:"Bottom",left:"Left",right:"Right"},labels:"Labels (comma-separated)",labelsPlaceholder:"Jan, Feb, Mar, Apr...",datasets:{title:"Datasets",add:"+ Add Dataset",remove:"Remove",datasetLabel:"Dataset",datasetLabelPlaceholder:"Dataset label...",data:"Data (comma-separated numbers)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Bar Chart",line:"Line Chart",pie:"Pie Chart",doughnut:"Doughnut Chart",radar:"Radar Chart",polarArea:"Polar Area Chart"}},zn={slashMenu:xr,toolbar:yr,aria:wr,placeholder:kr,linkPlaceholder:Cr,chart:Lr},Tr={groups:{basic:"基礎",list:"列表",media:"媒體",advanced:"高級",layout:"版面配置"},commands:{paragraph:{title:"文本",description:"普通文本塊"},heading1:{title:"標題 1",description:"大標題"},heading2:{title:"標題 2",description:"中標題"},heading3:{title:"標題 3",description:"小標題"},bulletList:{title:"無序列表",description:"創建無序列表"},orderedList:{title:"有序列表",description:"創建有序列表"},taskList:{title:"待辦清單",description:"創建帶複選框的待辦清單"},image:{title:"圖片",description:"上傳或粘貼圖片"},blockquote:{title:"引用",description:"創建引用塊"},codeBlock:{title:"代碼",description:"創建代碼片段"},horizontalRule:{title:"分割線",description:"創建水平分割線"},layoutTwoColumn:{title:"兩欄版面配置",description:"將內容分成兩個並排的欄"},layoutThreeColumn:{title:"三欄版面配置",description:"將內容分成三個並排的欄"}}},Br={bold:"粗體",italic:"斜體",underline:"下劃線",strike:"刪除線",code:"行內代碼",link:"鏈接",turnInto:"轉換為",colorPicker:"文字和背景顏色",textColor:"文字顏色",backgroundColor:"背景顏色",recentlyUsed:"最近使用",openLink:"打開鏈接",removeLink:"移除鏈接",confirmLink:"確認鏈接",clearLink:"清空鏈接",blockTypes:{text:"文本",heading1:"標題 1",heading2:"標題 2",heading3:"標題 3",bulletedList:"無序列表",numberedList:"有序列表"}},Ar={editor:"富文本編輯器",editorContent:"編輯器內容區域",toolbar:"文本格式化工具欄",boldButton:"切換粗體格式",italicButton:"切換斜體格式",underlineButton:"切換下劃線格式",strikeButton:"切換刪除線格式",codeButton:"切換行內代碼格式",linkButton:"添加或編輯鏈接",turnIntoButton:"轉換為",colorPickerButton:"文字和背景顏色",headingButton:"設置標題級別",paragraphButton:"轉換為段落",dragHandle:"拖拽以重新排序塊",dropIndicator:"放置此處以移動塊",blockMenu:"塊選項菜單",addBlock:"添加新塊",deleteBlock:"刪除此塊",linkDialog:"鏈接編輯對話框",linkUrlInput:"鏈接 URL 輸入",linkSaveButton:"保存鏈接",linkRemoveButton:"移除鏈接",linkCancelButton:"取消鏈接編輯",addBlockBelow:"在下方添加塊",dragToMove:"拖拽以重新排序塊",openLinkInNewTab:"在新標籤頁中打開鏈接",linkConfirmButton:"確認鏈接",linkOpenButton:"在新標籤頁中打開鏈接",linkClearButton:"清空鏈接輸入"},jr='開始寫作,輸入 "/" 顯示命令...',Sr="粘貼鏈接...",Mr={modal:{title:"編輯圖表",close:"關閉",save:"保存",cancel:"取消",fields:{chartType:"圖表類型",title:"標題",titlePlaceholder:"圖表標題...",showLegend:"顯示圖例",legendPosition:"位置",position:{top:"頂部",bottom:"底部",left:"左側",right:"右側"},labels:"標籤(逗號分隔)",labelsPlaceholder:"一月, 二月, 三月, 四月...",datasets:{title:"數據集",add:"+ 添加數據集",remove:"移除",datasetLabel:"標籤",datasetLabelPlaceholder:"數據集標籤...",data:"數據(逗號分隔的數字)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"柱狀圖",line:"折線圖",pie:"餅圖",doughnut:"環形圖",radar:"雷達圖",polarArea:"極地圖"}},Pr={slashMenu:Tr,toolbar:Br,aria:Ar,placeholder:jr,linkPlaceholder:Sr,chart:Mr},Dr={groups:{basic:"基础",list:"列表",media:"媒体",advanced:"高级",layout:"版面布局"},commands:{paragraph:{title:"文本",description:"普通文本块"},heading1:{title:"标题 1",description:"大标题"},heading2:{title:"标题 2",description:"中标题"},heading3:{title:"标题 3",description:"小标题"},bulletList:{title:"无序列表",description:"创建无序列表"},orderedList:{title:"有序列表",description:"创建有序列表"},taskList:{title:"待办清单",description:"创建带复选框的待办清单"},image:{title:"图片",description:"上传或粘贴图片"},blockquote:{title:"引用",description:"创建引用块"},codeBlock:{title:"代码",description:"创建代码片段"},horizontalRule:{title:"分割线",description:"创建水平分割线"},layoutTwoColumn:{title:"两栏布局",description:"将内容分成两个并排的栏"},layoutThreeColumn:{title:"三栏布局",description:"将内容分成三个并排的栏"}}},Ir={bold:"粗体",italic:"斜体",underline:"下划线",strike:"删除线",code:"行内代码",link:"链接",turnInto:"转换为",colorPicker:"文字和背景颜色",textColor:"文字颜色",backgroundColor:"背景颜色",recentlyUsed:"最近使用",openLink:"打开链接",removeLink:"移除链接",confirmLink:"确认链接",clearLink:"清空链接",blockTypes:{text:"文本",heading1:"标题 1",heading2:"标题 2",heading3:"标题 3",bulletedList:"无序列表",numberedList:"有序列表"}},Rr={editor:"富文本编辑器",editorContent:"编辑器内容区域",toolbar:"文本格式化工具栏",boldButton:"切换粗体格式",italicButton:"切换斜体格式",underlineButton:"切换下划线格式",strikeButton:"切换删除线格式",codeButton:"切换行内代码格式",linkButton:"添加或编辑链接",turnIntoButton:"转换为",colorPickerButton:"文字和背景颜色",headingButton:"设置标题级别",paragraphButton:"转换为段落",dragHandle:"拖拽以重新排序块",dropIndicator:"放置此处以移动块",blockMenu:"块选项菜单",addBlock:"添加新块",deleteBlock:"删除此块",linkDialog:"链接编辑对话框",linkUrlInput:"链接 URL 输入",linkSaveButton:"保存链接",linkRemoveButton:"移除链接",linkCancelButton:"取消链接编辑",addBlockBelow:"在下方添加块",dragToMove:"拖拽以重新排序块",openLinkInNewTab:"在新标签页中打开链接",linkConfirmButton:"确认链接",linkOpenButton:"在新标签页中打开链接",linkClearButton:"清空链接输入"},Or='开始写作,输入 "/" 显示命令...',Er="粘贴链接...",_r={modal:{title:"编辑图表",close:"关闭",save:"保存",cancel:"取消",fields:{chartType:"图表类型",title:"标题",titlePlaceholder:"图表标题...",showLegend:"显示图例",legendPosition:"位置",position:{top:"顶部",bottom:"底部",left:"左侧",right:"右侧"},labels:"标签(逗号分隔)",labelsPlaceholder:"一月, 二月, 三月, 四月...",datasets:{title:"数据集",add:"+ 添加数据集",remove:"移除",datasetLabel:"标签",datasetLabelPlaceholder:"数据集标签...",data:"数据(逗号分隔的数字)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"柱状图",line:"折线图",pie:"饼图",doughnut:"环形图",radar:"雷达图",polarArea:"极地图"}},Nr={slashMenu:Dr,toolbar:Ir,aria:Rr,placeholder:Or,linkPlaceholder:Er,chart:_r},Hr={groups:{basic:"基本",list:"リスト",media:"メディア",advanced:"高度",layout:"レイアウト"},commands:{paragraph:{title:"テキスト",description:"プレーンテキストブロック"},heading1:{title:"見出し1",description:"大きなセクション見出し"},heading2:{title:"見出し2",description:"中サイズのセクション見出し"},heading3:{title:"見出し3",description:"小さなセクション見出し"},bulletList:{title:"箇条書きリスト",description:"箇条書きリストを作成"},orderedList:{title:"番号付きリスト",description:"番号付きリストを作成"},taskList:{title:"To-doリスト",description:"チェックボックス付きのTo-doリストを作成"},image:{title:"画像",description:"画像をアップロードまたは貼り付け"},blockquote:{title:"引用",description:"引用ブロックを作成"},codeBlock:{title:"コード",description:"コードスニペットを作成"},horizontalRule:{title:"区切り線",description:"水平線を作成"},layoutTwoColumn:{title:"2カラムレイアウト",description:"コンテンツを2つの横並びカラムに分割"},layoutThreeColumn:{title:"3カラムレイアウト",description:"コンテンツを3つの横並びカラムに分割"}}},$r={bold:"太字",italic:"斜体",underline:"下線",strike:"取り消し線",code:"インラインコード",link:"リンク",turnInto:"変換",colorPicker:"テキストと背景色",textColor:"文字色",backgroundColor:"背景色",recentlyUsed:"最近使用",openLink:"リンクを開く",removeLink:"リンクを削除",confirmLink:"リンクを確認",clearLink:"リンクをクリア",blockTypes:{text:"テキスト",heading1:"見出し1",heading2:"見出し2",heading3:"見出し3",bulletedList:"箇条書きリスト",numberedList:"番号付きリスト"}},zr={editor:"リッチテキストエディタ",editorContent:"エディタコンテンツ領域",toolbar:"テキスト書式設定ツールバー",boldButton:"太字書式を切り替え",italicButton:"斜体書式を切り替え",underlineButton:"下線書式を切り替え",strikeButton:"取り消し線書式を切り替え",codeButton:"インラインコード書式を切り替え",linkButton:"リンクを追加または編集",turnIntoButton:"変換",colorPickerButton:"テキストと背景色",headingButton:"見出しレベルを設定",paragraphButton:"段落に変換",dragHandle:"ブロックを並び替えるためにドラッグ",dropIndicator:"ブロックを移動するためにここにドロップ",blockMenu:"ブロックオプションメニュー",addBlock:"新しいブロックを追加",deleteBlock:"このブロックを削除",linkDialog:"リンク編集ダイアログ",linkUrlInput:"リンクURL入力",linkSaveButton:"リンクを保存",linkRemoveButton:"リンクを削除",linkCancelButton:"リンク編集をキャンセル",addBlockBelow:"下にブロックを追加",dragToMove:"ブロックを並び替えるためにドラッグ",openLinkInNewTab:"新しいタブでリンクを開く",linkConfirmButton:"リンクを確認",linkOpenButton:"新しいタブでリンクを開く",linkClearButton:"リンク入力をクリア"},qr='書き始めましょう、コマンドを表示するには "/" を入力...',Ur="リンクを貼り付け...",Fr={modal:{title:"チャート編集",close:"閉じる",save:"保存",cancel:"キャンセル",fields:{chartType:"チャートタイプ",title:"タイトル",titlePlaceholder:"チャートタイトル...",showLegend:"凡例を表示",legendPosition:"位置",position:{top:"上",bottom:"下",left:"左",right:"右"},labels:"ラベル(カンマ区切り)",labelsPlaceholder:"1月, 2月, 3月, 4月...",datasets:{title:"データセット",add:"+ データセットを追加",remove:"削除",datasetLabel:"ラベル",datasetLabelPlaceholder:"データセットラベル...",data:"データ(カンマ区切りの数値)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"棒グラフ",line:"折れ線グラフ",pie:"円グラフ",doughnut:"ドーナツグラフ",radar:"レーダーチャート",polarArea:"極座標グラフ"}},Wr={slashMenu:Hr,toolbar:$r,aria:zr,placeholder:qr,linkPlaceholder:Ur,chart:Fr},Vr={groups:{basic:"기본",list:"목록",media:"미디어",advanced:"고급",layout:"레이아웃"},commands:{paragraph:{title:"텍스트",description:"일반 텍스트 블록"},heading1:{title:"제목 1",description:"큰 섹션 제목"},heading2:{title:"제목 2",description:"중간 섹션 제목"},heading3:{title:"제목 3",description:"작은 섹션 제목"},bulletList:{title:"글머리 기호 목록",description:"글머리 기호 목록 만들기"},orderedList:{title:"번호 매기기 목록",description:"번호 매기기 목록 만들기"},taskList:{title:"할 일 목록",description:"확인란 있는 할 일 목록 만들기"},image:{title:"이미지",description:"이미지 업로드 또는 붙여넣기"},blockquote:{title:"인용",description:"인용 블록 만들기"},codeBlock:{title:"코드",description:"코드 스니펫 만들기"},horizontalRule:{title:"구분선",description:"수평선 만들기"},layoutTwoColumn:{title:"2열 레이아웃",description:"콘텐츠를 두 개의 나란히 있는 열로 분할"},layoutThreeColumn:{title:"3열 레이아웃",description:"콘텐츠를 세 개의 나란히 있는 열로 분할"}}},Gr={bold:"굵게",italic:"기울임",underline:"밑줄",strike:"취소선",code:"인라인 코드",link:"링크",turnInto:"변환",colorPicker:"텍스트 및 배경색",textColor:"텍스트 색상",backgroundColor:"배경 색상",recentlyUsed:"최근 사용",openLink:"링크 열기",removeLink:"링크 제거",confirmLink:"링크 확인",clearLink:"링크 지우기",blockTypes:{text:"텍스트",heading1:"제목 1",heading2:"제목 2",heading3:"제목 3",bulletedList:"글머리 기호 목록",numberedList:"번호 매기기 목록"}},Yr={editor:"리치 텍스트 에디터",editorContent:"에디터 내용 영역",toolbar:"텍스트 서식 도구 모음",boldButton:"굵게 서식 전환",italicButton:"기울임 서식 전환",underlineButton:"밑줄 서식 전환",strikeButton:"취소선 서식 전환",codeButton:"인라인 코드 서식 전환",linkButton:"링크 추가 또는 편집",turnIntoButton:"변환",colorPickerButton:"텍스트 및 배경색",headingButton:"제목 수준 설정",paragraphButton:"단락으로 변환",dragHandle:"블록 재정렬을 위해 드래그",dropIndicator:"블록 이동을 위해 여기에 놓기",blockMenu:"블록 옵션 메뉴",addBlock:"새 블록 추가",deleteBlock:"이 블록 삭제",linkDialog:"링크 편집 대화 상자",linkUrlInput:"링크 URL 입력",linkSaveButton:"링크 저장",linkRemoveButton:"링크 제거",linkCancelButton:"링크 편집 취소",addBlockBelow:"아래에 블록 추가",dragToMove:"블록 재정렬을 위해 드래그",openLinkInNewTab:"새 탭에서 링크 열기",linkConfirmButton:"링크 확인",linkOpenButton:"새 탭에서 링크 열기",linkClearButton:"링크 입력 지우기"},Kr='작성 시작, 명령을 표시하려면 "/" 입력...',Xr="링크 붙여넣기...",Jr={modal:{title:"차트 편집",close:"닫기",save:"저장",cancel:"취소",fields:{chartType:"차트 유형",title:"제목",titlePlaceholder:"차트 제목...",showLegend:"범례 표시",legendPosition:"위치",position:{top:"위",bottom:"아래",left:"왼쪽",right:"오른쪽"},labels:"레이블(쉼표로 구분)",labelsPlaceholder:"1월, 2월, 3월, 4월...",datasets:{title:"데이터 세트",add:"+ 데이터 세트 추가",remove:"제거",datasetLabel:"레이블",datasetLabelPlaceholder:"데이터 세트 레이블...",data:"데이터(쉼표로 구분된 숫자)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"막대형 차트",line:"선형 차트",pie:"원형 차트",doughnut:"도넛형 차트",radar:"레이더 차트",polarArea:"극좌표형 차트"}},Zr={slashMenu:Vr,toolbar:Gr,aria:Yr,placeholder:Kr,linkPlaceholder:Xr,chart:Jr},Qr={groups:{basic:"De base",list:"Listes",media:"Médias",advanced:"Avancé",layout:"Mise en page"},commands:{paragraph:{title:"Texte",description:"Bloc de texte simple"},heading1:{title:"Titre 1",description:"Grand titre de section"},heading2:{title:"Titre 2",description:"Titre de section moyen"},heading3:{title:"Titre 3",description:"Petit titre de section"},bulletList:{title:"Liste à puces",description:"Créer une liste à puces"},orderedList:{title:"Liste numérotée",description:"Créer une liste numérotée"},taskList:{title:"Liste de tâches",description:"Créer une liste de tâches avec cases à cocher"},image:{title:"Image",description:"Télécharger ou coller une image"},blockquote:{title:"Citation",description:"Créer un bloc de citation"},codeBlock:{title:"Code",description:"Créer un extrait de code"},horizontalRule:{title:"Séparateur",description:"Créer une ligne horizontale"},layoutTwoColumn:{title:"Mise en page à deux colonnes",description:"Diviser le contenu en deux colonnes côte à côte"},layoutThreeColumn:{title:"Mise en page à trois colonnes",description:"Diviser le contenu en trois colonnes côte à côte"}}},ea={bold:"Gras",italic:"Italique",underline:"Souligné",strike:"Barré",code:"Code en ligne",link:"Lien",turnInto:"Convertir en",colorPicker:"Couleur du texte et du fond",textColor:"Couleur du texte",backgroundColor:"Couleur de fond",recentlyUsed:"Récemment utilisés",openLink:"Ouvrir le lien",removeLink:"Supprimer le lien",confirmLink:"Confirmer le lien",clearLink:"Effacer le lien",blockTypes:{text:"Texte",heading1:"Titre 1",heading2:"Titre 2",heading3:"Titre 3",bulletedList:"Liste à puces",numberedList:"Liste numérotée"}},ta={editor:"Éditeur de texte riche",editorContent:"Zone de contenu de l'éditeur",toolbar:"Barre d'outils de formatage de texte",boldButton:"Activer/désactiver le formatage en gras",italicButton:"Activer/désactiver le formatage en italique",underlineButton:"Activer/désactiver le soulignement",strikeButton:"Activer/désactiver le texte barré",codeButton:"Activer/désactiver le code en ligne",linkButton:"Ajouter ou modifier un lien",turnIntoButton:"Convertir en",colorPickerButton:"Couleur du texte et du fond",headingButton:"Définir le niveau de titre",paragraphButton:"Convertir en paragraphe",dragHandle:"Glisser pour réorganiser le bloc",dropIndicator:"Déposer ici pour déplacer le bloc",blockMenu:"Menu des options de bloc",addBlock:"Ajouter un nouveau bloc",deleteBlock:"Supprimer ce bloc",linkDialog:"Boîte de dialogue d'édition de lien",linkUrlInput:"Entrée d'URL de lien",linkSaveButton:"Enregistrer le lien",linkRemoveButton:"Supprimer le lien",linkCancelButton:"Annuler l'édition du lien",addBlockBelow:"Ajouter un bloc en dessous",dragToMove:"Glisser pour réorganiser le bloc",openLinkInNewTab:"Ouvrir le lien dans un nouvel onglet",linkConfirmButton:"Confirmer le lien",linkOpenButton:"Ouvrir le lien dans un nouvel onglet",linkClearButton:"Effacer la saisie du lien"},na='Écrivez, tapez "/" pour afficher les commandes...',oa="Collez un lien...",ra={modal:{title:"Modifier le graphique",close:"Fermer",save:"Enregistrer",cancel:"Annuler",fields:{chartType:"Type de graphique",title:"Titre",titlePlaceholder:"Titre du graphique...",showLegend:"Afficher la légende",legendPosition:"Position",position:{top:"Haut",bottom:"Bas",left:"Gauche",right:"Droite"},labels:"Étiquettes (séparées par des virgules)",labelsPlaceholder:"Jan, Fév, Mar, Avr...",datasets:{title:"Jeux de données",add:"+ Ajouter un jeu de données",remove:"Supprimer",datasetLabel:"Étiquette",datasetLabelPlaceholder:"Étiquette du jeu de données...",data:"Données (nombres séparés par des virgules)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Graphique à barres",line:"Graphique linéaire",pie:"Graphique circulaire",doughnut:"Graphique en anneau",radar:"Graphique radar",polarArea:"Graphique en coordonnées polaires"}},aa={slashMenu:Qr,toolbar:ea,aria:ta,placeholder:na,linkPlaceholder:oa,chart:ra},ia={groups:{basic:"Basis",list:"Listen",media:"Medien",advanced:"Erweitert",layout:"Layout"},commands:{paragraph:{title:"Text",description:"Einfacher Textblock"},heading1:{title:"Überschrift 1",description:"Große Abschnittsüberschrift"},heading2:{title:"Überschrift 2",description:"Mittlere Abschnittsüberschrift"},heading3:{title:"Überschrift 3",description:"Kleine Abschnittsüberschrift"},bulletList:{title:"Aufzählungsliste",description:"Aufzählungsliste erstellen"},orderedList:{title:"Nummerierte Liste",description:"Nummerierte Liste erstellen"},taskList:{title:"To-do-Liste",description:"To-do-Liste mit Kontrollkästchen erstellen"},image:{title:"Bild",description:"Bild hochladen oder einfügen"},blockquote:{title:"Zitat",description:"Zitatblock erstellen"},codeBlock:{title:"Code",description:"Codeausschnitt erstellen"},horizontalRule:{title:"Trennlinie",description:"Horizontale Linie erstellen"},layoutTwoColumn:{title:"Zweispaltiges Layout",description:"Inhalt in zwei nebeneinander liegende Spalten aufteilen"},layoutThreeColumn:{title:"Dreispaltiges Layout",description:"Inhalt in drei nebeneinander liegende Spalten aufteilen"}}},sa={bold:"Fett",italic:"Kursiv",underline:"Unterstrichen",strike:"Durchgestrichen",code:"Inline-Code",link:"Link",turnInto:"Umwandeln in",colorPicker:"Text- und Hintergrundfarbe",textColor:"Textfarbe",backgroundColor:"Hintergrundfarbe",recentlyUsed:"Zuletzt verwendet",openLink:"Link öffnen",removeLink:"Link entfernen",confirmLink:"Link bestätigen",clearLink:"Link löschen",blockTypes:{text:"Text",heading1:"Überschrift 1",heading2:"Überschrift 2",heading3:"Überschrift 3",bulletedList:"Aufzählungsliste",numberedList:"Nummerierte Liste"}},la={editor:"Rich-Text-Editor",editorContent:"Editor-Inhaltsbereich",toolbar:"Textformatierungs-Symbolleiste",boldButton:"Fettformatierung ein/aus",italicButton:"Kursivformatierung ein/aus",underlineButton:"Unterstreichung ein/aus",strikeButton:"Durchstreichung ein/aus",codeButton:"Inline-Code-Formatierung ein/aus",linkButton:"Link hinzufügen oder bearbeiten",turnIntoButton:"Umwandeln in",colorPickerButton:"Text- und Hintergrundfarbe",headingButton:"Überschriftsebene festlegen",paragraphButton:"In Absatz umwandeln",dragHandle:"Zum Neuordnen des Blocks ziehen",dropIndicator:"Hier ablegen, um Block zu verschieben",blockMenu:"Block-Optionsmenü",addBlock:"Neuen Block hinzufügen",deleteBlock:"Diesen Block löschen",linkDialog:"Link-Bearbeitungsdialog",linkUrlInput:"Link-URL-Eingabe",linkSaveButton:"Link speichern",linkRemoveButton:"Link entfernen",linkCancelButton:"Link-Bearbeitung abbrechen",addBlockBelow:"Block darunter hinzufügen",dragToMove:"Zum Neuordnen des Blocks ziehen",openLinkInNewTab:"Link in neuem Tab öffnen",linkConfirmButton:"Link bestätigen",linkOpenButton:"Link in neuem Tab öffnen",linkClearButton:"Link-Eingabe löschen"},ca='Schreiben, tippen Sie "/" für Befehle...',ua="Link einfügen...",da={modal:{title:"Chart bearbeiten",close:"Schließen",save:"Speichern",cancel:"Abbrechen",fields:{chartType:"Chart-Typ",title:"Titel",titlePlaceholder:"Chart-Titel...",showLegend:"Legende anzeigen",legendPosition:"Position",position:{top:"Oben",bottom:"Unten",left:"Links",right:"Rechts"},labels:"Beschriftungen (kommagetrennt)",labelsPlaceholder:"Jan, Feb, Mär, Apr...",datasets:{title:"Datensätze",add:"+ Datensatz hinzufügen",remove:"Entfernen",datasetLabel:"Datensatz",datasetLabelPlaceholder:"Datensatz-Beschriftung...",data:"Daten (kommagetrennte Zahlen)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Balkendiagramm",line:"Liniendiagramm",pie:"Kreisdiagramm",doughnut:"Ringdiagramm",radar:"Netzdiagramm",polarArea:"Polärfächen-Diagramm"}},pa={slashMenu:ia,toolbar:sa,aria:la,placeholder:ca,linkPlaceholder:ua,chart:da},fa={groups:{basic:"Básico",list:"Listas",media:"Medios",advanced:"Avanzado",layout:"Diseño"},commands:{paragraph:{title:"Texto",description:"Bloque de texto plano"},heading1:{title:"Título 1",description:"Título de sección grande"},heading2:{title:"Título 2",description:"Título de sección mediano"},heading3:{title:"Título 3",description:"Título de sección pequeño"},bulletList:{title:"Lista con viñetas",description:"Crear una lista con viñetas"},orderedList:{title:"Lista numerada",description:"Crear una lista numerada"},taskList:{title:"Lista de tareas",description:"Crear una lista de tareas con casillas"},image:{title:"Imagen",description:"Subir o pegar una imagen"},blockquote:{title:"Cita",description:"Crear un bloque de cita"},codeBlock:{title:"Código",description:"Crear un fragmento de código"},horizontalRule:{title:"Divisor",description:"Crear una línea horizontal"},layoutTwoColumn:{title:"Diseño de dos columnas",description:"Dividir el contenido en dos columnas una al lado de la otra"},layoutThreeColumn:{title:"Diseño de tres columnas",description:"Dividir el contenido en tres columnas una al lado de la otra"}}},ha={bold:"Negrita",italic:"Cursiva",underline:"Subrayado",strike:"Tachado",code:"Código en línea",link:"Enlace",turnInto:"Convertir en",colorPicker:"Color de texto y fondo",textColor:"Color del texto",backgroundColor:"Color de fondo",recentlyUsed:"Recientemente usados",openLink:"Abrir enlace",removeLink:"Eliminar enlace",confirmLink:"Confirmar enlace",clearLink:"Limpiar enlace",blockTypes:{text:"Texto",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3",bulletedList:"Lista con viñetas",numberedList:"Lista numerada"}},ba={editor:"Editor de texto enriquecido",editorContent:"Área de contenido del editor",toolbar:"Barra de herramientas de formato de texto",boldButton:"Activar/desactivar formato en negrita",italicButton:"Activar/desactivar formato en cursiva",underlineButton:"Activar/desactivar subrayado",strikeButton:"Activar/desactivar tachado",codeButton:"Activar/desactivar código en línea",linkButton:"Añadir o editar enlace",turnIntoButton:"Convertir en",colorPickerButton:"Color de texto y fondo",headingButton:"Establecer nivel de título",paragraphButton:"Convertir a párrafo",dragHandle:"Arrastrar para reorganizar el bloque",dropIndicator:"Soltar aquí para mover el bloque",blockMenu:"Menú de opciones del bloque",addBlock:"Añadir nuevo bloque",deleteBlock:"Eliminar este bloque",linkDialog:"Diálogo de edición de enlace",linkUrlInput:"Entrada de URL del enlace",linkSaveButton:"Guardar enlace",linkRemoveButton:"Eliminar enlace",linkCancelButton:"Cancelar edición de enlace",addBlockBelow:"Añadir bloque debajo",dragToMove:"Arrastrar para reorganizar el bloque",openLinkInNewTab:"Abrir enlace en nueva pestaña",linkConfirmButton:"Confirmar enlace",linkOpenButton:"Abrir enlace en nueva pestaña",linkClearButton:"Limpiar entrada de enlace"},va='Escribe, escribe "/" para comandos...',ga="Pegue un enlace...",ma={modal:{title:"Editar gráfico",close:"Cerrar",save:"Guardar",cancel:"Cancelar",fields:{chartType:"Tipo de gráfico",title:"Título",titlePlaceholder:"Título del gráfico...",showLegend:"Mostrar leyenda",legendPosition:"Posición",position:{top:"Arriba",bottom:"Abajo",left:"Izquierda",right:"Derecha"},labels:"Etiquetas (separadas por comas)",labelsPlaceholder:"Ene, Feb, Mar, Abr...",datasets:{title:"Conjuntos de datos",add:"+ Añadir conjunto de datos",remove:"Eliminar",datasetLabel:"Etiqueta",datasetLabelPlaceholder:"Etiqueta del conjunto de datos...",data:"Datos (números separados por comas)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Gráfico de barras",line:"Gráfico de líneas",pie:"Gráfico circular",doughnut:"Gráfico de anillo",radar:"Gráfico radar",polarArea:"Gráfico de área polar"}},xa={slashMenu:fa,toolbar:ha,aria:ba,placeholder:va,linkPlaceholder:ga,chart:ma},ya={groups:{basic:"Básico",list:"Listas",media:"Mídia",advanced:"Avançado",layout:"Layout"},commands:{paragraph:{title:"Texto",description:"Bloco de texto simples"},heading1:{title:"Título 1",description:"Título de seção grande"},heading2:{title:"Título 2",description:"Título de seção médio"},heading3:{title:"Título 3",description:"Título de seção pequeno"},bulletList:{title:"Lista com marcadores",description:"Criar uma lista com marcadores"},orderedList:{title:"Lista numerada",description:"Criar uma lista numerada"},taskList:{title:"Lista de tarefas",description:"Criar uma lista de tarefas com caixas de seleção"},image:{title:"Imagem",description:"Enviar ou colar uma imagem"},blockquote:{title:"Citação",description:"Criar um bloco de citação"},codeBlock:{title:"Código",description:"Criar um trecho de código"},horizontalRule:{title:"Divisor",description:"Criar uma linha horizontal"},layoutTwoColumn:{title:"Layout de duas colunas",description:"Dividir o conteúdo em duas colunas lado a lado"},layoutThreeColumn:{title:"Layout de três colunas",description:"Dividir o conteúdo em três colunas lado a lado"}}},wa={bold:"Negrito",italic:"Itálico",underline:"Sublinhado",strike:"Tachado",code:"Código inline",link:"Link",turnInto:"Converter em",colorPicker:"Cor do texto e fundo",textColor:"Cor do texto",backgroundColor:"Cor de fundo",recentlyUsed:"Usados recentemente",openLink:"Abrir link",removeLink:"Remover link",confirmLink:"Confirmar link",clearLink:"Limpar link",blockTypes:{text:"Texto",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3",bulletedList:"Lista com marcadores",numberedList:"Lista numerada"}},ka={editor:"Editor de texto rico",editorContent:"Área de conteúdo do editor",toolbar:"Barra de ferramentas de formatação de texto",boldButton:"Alternar formatação em negrito",italicButton:"Alternar formatação em itálico",underlineButton:"Alternar sublinhado",strikeButton:"Alternar tachado",codeButton:"Alternar código inline",linkButton:"Adicionar ou editar link",turnIntoButton:"Converter em",colorPickerButton:"Cor do texto e fundo",headingButton:"Definir nível de título",paragraphButton:"Converter em parágrafo",dragHandle:"Arrastar para reorganizar o bloco",dropIndicator:"Soltar aqui para mover o bloco",blockMenu:"Menu de opções do bloco",addBlock:"Adicionar novo bloco",deleteBlock:"Excluir este bloco",linkDialog:"Diálogo de edição de link",linkUrlInput:"Entrada de URL do link",linkSaveButton:"Salvar link",linkRemoveButton:"Remover link",linkCancelButton:"Cancelar edição de link",addBlockBelow:"Adicionar bloco abaixo",dragToMove:"Arrastar para reorganizar o bloco",openLinkInNewTab:"Abrir link em nova aba",linkConfirmButton:"Confirmar link",linkOpenButton:"Abrir link em nova aba",linkClearButton:"Limpar entrada de link"},Ca='Escreva, digite "/" para comandos...',La="Cole um link...",Ta={modal:{title:"Editar gráfico",close:"Fechar",save:"Salvar",cancel:"Cancelar",fields:{chartType:"Tipo de gráfico",title:"Título",titlePlaceholder:"Título do gráfico...",showLegend:"Mostrar legenda",legendPosition:"Posição",position:{top:"Superior",bottom:"Inferior",left:"Esquerda",right:"Direita"},labels:"Rótulos (separados por vírgula)",labelsPlaceholder:"Jan, Fev, Mar, Abr...",datasets:{title:"Conjuntos de dados",add:"+ Adicionar conjunto de dados",remove:"Remover",datasetLabel:"Rótulo",datasetLabelPlaceholder:"Rótulo do conjunto de dados...",data:"Dados (números separados por vírgula)",dataPlaceholder:"10, 20, 30, 40..."}}},chartTypes:{bar:"Gráfico de barras",line:"Gráfico de linhas",pie:"Gráfico de pizza",doughnut:"Gráfico de rosca",radar:"Gráfico de radar",polarArea:"Gráfico de área polar"}},Ba={slashMenu:ya,toolbar:wa,aria:ka,placeholder:Ca,linkPlaceholder:La,chart:Ta},Wt=zn,Aa={en:zn,zh:Pr,"zh-CN":Nr,ja:Wr,ko:Zr,fr:aa,de:pa,es:xa,pt:Ba};function At(e){return e&&Aa[e]||Wt}const qn=m.createContext({locale:Wt}),pn=qn.Provider;function Oe(){return m.useContext(qn).locale}const ja=async()=>Promise.resolve().then(()=>require("./auto-BaSO-_S9.cjs"));function $e(e,t,n){const o=getComputedStyle(e),r=t.replace(/^var\(/,"").replace(/\)$/,"");return o.getPropertyValue(r).trim()||n}function Sa(e){var S;const{node:t,updateAttributes:n,editor:o,selected:r}=e,a=t.attrs.data,[s,c]=m.useState(!1),[l,d]=m.useState(!1),[p,x]=m.useState(null),h=m.useRef(null),b=m.useRef(null),f=m.useRef(null),g=Oe(),L=((S=o==null?void 0:o.options)==null?void 0:S.editable)??!0,k=L?r:!1,M=m.useCallback(()=>{if(!p||!f.current||!b.current)return;const P=b.current,R=$e(P,"--pubwave-text","#37352f"),B=$e(P,"--pubwave-text-muted","#9b9a97"),v=$e(P,"--pubwave-border","#e3e2e0"),T=p.options.plugins||{},A=p.options.scales;if(T.legend){const _=T.legend;_.labels?_.labels.color=R:T.legend.labels={color:R},_.onHover=()=>{const H=h.current;H&&(H.style.cursor="pointer")},_.onLeave=()=>{const H=h.current;H&&(H.style.cursor="default")}}T.title&&(T.title.color=R),A&&(A.x&&(A.x.ticks&&(A.x.ticks.color=B),A.x.grid&&(A.x.grid.color=v)),A.y&&(A.y.ticks&&(A.y.ticks.color=B),A.y.grid&&(A.y.grid.color=v))),p.update("none")},[p]);m.useEffect(()=>!h.current||!a?void 0:((async()=>{var R,B,v,T,A,_,H,z,F,U,I,N,W;try{const K=(await ja()).default;if(f.current=K,h.current){const X=K.getChart(h.current);X&&X.destroy()}p&&p.destroy();const Q=(R=h.current)==null?void 0:R.getContext("2d");if(!Q){console.warn("Failed to get 2D context for chart");return}const G=b.current,ne=G?$e(G,"--pubwave-text","#37352f"):"#37352f",ve=G?$e(G,"--pubwave-text-muted","#9b9a97"):"#9b9a97",ie=G?$e(G,"--pubwave-border","#e3e2e0"):"#e3e2e0",ke={...a.options,responsive:!0,maintainAspectRatio:!1,plugins:{...(B=a.options)==null?void 0:B.plugins,legend:{display:((A=(T=(v=a.options)==null?void 0:v.plugins)==null?void 0:T.legend)==null?void 0:A.display)??!0,position:((z=(H=(_=a.options)==null?void 0:_.plugins)==null?void 0:H.legend)==null?void 0:z.position)??"top",...(I=(U=(F=a.options)==null?void 0:F.plugins)==null?void 0:U.legend)!=null&&I.labels?{labels:{...a.options.plugins.legend.labels,color:ne}}:{labels:{color:ne}},onHover:()=>{const X=h.current;X&&(X.style.cursor="pointer")},onLeave:()=>{const X=h.current;X&&(X.style.cursor="default")}},title:(W=(N=a.options)==null?void 0:N.plugins)!=null&&W.title?{...a.options.plugins.title,color:ne,...a.options.plugins.title.font?{font:{...a.options.plugins.title.font}}:{}}:void 0},scales:C(a.type)?{x:{ticks:{color:ve},grid:{color:ie}},y:{ticks:{color:ve},grid:{color:ie}}}:void 0},de=new K(Q,{type:a.type,data:a.data,options:ke});x(de)}catch(V){console.error("Failed to load Chart.js:",V)}})(),()=>{p&&p.destroy()}),[a,L]),m.useEffect(()=>{if(!p||!b.current)return;const P=()=>{setTimeout(()=>{M()},0)},R=new MutationObserver(v=>{v.forEach(T=>{(T.attributeName==="style"||T.attributeName==="class")&&P()})});let B=b.current;for(;B&&(R.observe(B,{attributes:!0}),!(B.classList.contains("pubwave-editor")||B===document.body));)B=B.parentElement;return R.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>{R.disconnect()}},[p,M]);function C(P){return["bar","line","radar"].includes(P)}const u=m.useCallback(P=>{n({data:P}),c(!1)},[n]),j=m.useCallback(()=>{c(!1)},[]),w=m.useCallback(()=>{c(!0)},[]);return a?i.jsxs(ye.NodeViewWrapper,{ref:b,className:"pubwave-editor__chart","data-selected":k,"data-chart-type":a.type,children:[i.jsxs("div",{className:"pubwave-chart__container",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[i.jsx("div",{className:"pubwave-chart__canvas-wrapper",children:i.jsx("canvas",{ref:h,className:"pubwave-chart__canvas"})}),L&&(l||k)&&i.jsx("button",{type:"button",className:"pubwave-chart__edit-button",onClick:w,"aria-label":"Edit chart",title:"Edit chart",children:i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),i.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]}),s&&a&&i.jsx(mr,{initialData:a,onSave:u,onCancel:j,locale:g})]}):i.jsx(ye.NodeViewWrapper,{className:"pubwave-editor__chart",children:i.jsx("div",{className:"pubwave-chart__placeholder",children:"Invalid chart data"})})}const Ma=re.Node.create({name:"chart",priority:1e3,group:"block",atom:!0,draggable:!0,addAttributes(){return{data:{default:null,parseHTML:e=>{const t=e.getAttribute("data-chart-data");if(t)try{return JSON.parse(t)}catch{return null}return null},renderHTML:e=>e.data?{"data-chart-data":JSON.stringify(e.data)}:{}}}},parseHTML(){return[{tag:'div[data-type="chart"]'}]},renderHTML({HTMLAttributes:e}){return["div",re.mergeAttributes({"data-type":"chart"},e)]},addNodeView(){return ye.ReactNodeViewRenderer(Sa)}});function Pa(e){return i.jsx(ye.NodeViewWrapper,{className:"pubwave-layout__column","data-type":"layoutColumn",children:i.jsx(ye.NodeViewContent,{as:"div",className:"pubwave-layout__column-content"})})}const Da=re.Node.create({name:"layout",priority:1e3,group:"block",draggable:!0,content:"layoutColumn+",addAttributes(){return{columns:{default:2,parseHTML:e=>{const t=e.getAttribute("data-layout-columns");return t?parseInt(t,10):2},renderHTML:e=>({"data-layout-columns":String(e.columns)})}}},parseHTML(){return[{tag:'div[data-type="layout"]',getAttrs:e=>{const t=e.getAttribute("data-layout-columns"),n=t?parseInt(t,10):2;return n!==2&&n!==3?!1:{columns:n}}}]},renderHTML({node:e,HTMLAttributes:t}){const n=e.attrs.columns,o=["pubwave-editor__layout",`pubwave-layout--${n}-cols`];return["div",re.mergeAttributes({"data-type":"layout","data-layout-columns":String(n),class:o.join(" ")},t),0]}}),Ia=re.Node.create({name:"layoutColumn",priority:1e3,group:"block",isolating:!0,content:"block+",parseHTML(){return[{tag:'div[data-type="layoutColumn"]'},{tag:"div.pubwave-layout__column"}]},renderHTML({HTMLAttributes:e}){return["div",re.mergeAttributes({"data-type":"layoutColumn",class:"pubwave-layout__column"},e),0]},addNodeView(){return ye.ReactNodeViewRenderer(Pa)}});async function Ra(e,t){const n=(t==null?void 0:t.maxSize)??10485760;if(e.size>n)throw new Error(`Image file is too large. Maximum size is ${n/1024/1024}MB`);if(t!=null&&t.handler)try{return await t.handler(e)}catch(o){console.warn("Custom image upload failed, falling back to base64:",o)}return new Promise((o,r)=>{const a=new FileReader;a.onload=s=>{var l;const c=(l=s.target)==null?void 0:l.result;c?o(c):r(new Error("Failed to read image file"))},a.onerror=()=>{r(new Error("Failed to read image file"))},a.readAsDataURL(e)})}function Oa(e={}){const{headingLevels:t=[1,2,3],imageUpload:n}=e;return[Yo,Ko.configure({HTMLAttributes:{class:"pubwave-editor__paragraph"}}),Xo,ir,Jo.configure({levels:t,HTMLAttributes:{class:"pubwave-editor__heading"}}),Zo.configure({HTMLAttributes:{class:"pubwave-editor__bullet-list"}}),Qo.configure({HTMLAttributes:{class:"pubwave-editor__ordered-list"}}),er.configure({HTMLAttributes:{class:"pubwave-editor__list-item"}}),tr.configure({HTMLAttributes:{class:"pubwave-editor__task-list"}}),nr.configure({nested:!0,HTMLAttributes:{class:"pubwave-editor__task-item"}}),or.configure({HTMLAttributes:{class:"pubwave-editor__blockquote"}}),rr.configure({HTMLAttributes:{class:"pubwave-editor__code-block"}}),ar.configure({HTMLAttributes:{class:"pubwave-editor__divider"}}),sr.extend({addProseMirrorPlugins(){return[new Pt.Plugin({key:new Pt.PluginKey("imagePasteHandler"),props:{handlePaste:(o,r)=>{var s;const a=Array.from(((s=r.clipboardData)==null?void 0:s.items)||[]);for(const c of a)if(c.type.indexOf("image")===0){r.preventDefault();const l=c.getAsFile();if(l)return Ra(l,n).then(d=>{const{state:p,dispatch:x}=o,h=p.schema.nodes.image;if(h){const b=h.create({src:d}),f=p.tr.replaceSelectionWith(b);x(f)}}).catch(d=>{console.error("Failed to upload image:",d)}),!0}return!1}}})]}}).configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"pubwave-editor__image"}}),Ma.configure({HTMLAttributes:{class:"pubwave-editor__chart"}}),Da.configure({HTMLAttributes:{class:"pubwave-editor__layout"}}),Ia.configure({HTMLAttributes:{class:"pubwave-editor__layout-column"}})]}const Ea=re.Mark.create({name:"textColor",excludes:"",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{color:{default:null,parseHTML:e=>{if(typeof e=="string")return null;const t=e;return t.style.color||t.getAttribute("data-color")||null},renderHTML:e=>e.color?{style:`color: ${e.color}`,"data-color":e.color}:{}}}},parseHTML(){return[{tag:'span[style*="color"]',getAttrs:e=>{if(typeof e=="string")return!1;const t=e,n=t.style.color||t.getAttribute("data-color");return n?{color:n}:!1}}]},renderHTML({HTMLAttributes:e}){return["span",re.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setColor:e=>({chain:t,state:n})=>{var r,a,s;const o=((a=(r=n.storedMarks)==null?void 0:r.find(c=>c.type.name===this.name))==null?void 0:a.attrs)||((s=n.selection.$from.marks().find(c=>c.type.name===this.name))==null?void 0:s.attrs);return(o==null?void 0:o.color)===e?!0:n.selection.empty?t().focus().unsetMark(this.name).setMark(this.name,{color:e}).run():t().focus().unsetMark(this.name).setMark(this.name,{color:e}).run()},unsetColor:()=>({chain:e})=>e().unsetMark(this.name).run()}}}),_a=re.Mark.create({name:"backgroundColor",excludes:"",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{backgroundColor:{default:null,parseHTML:e=>{if(typeof e=="string")return null;const t=e;return t.style.backgroundColor||t.getAttribute("data-background-color")||null},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`,"data-background-color":e.backgroundColor}:{}}}},parseHTML(){return[{tag:'span[style*="background-color"]',getAttrs:e=>{if(typeof e=="string")return!1;const t=e,n=t.style.backgroundColor||t.getAttribute("data-background-color");return n?{backgroundColor:n}:!1}}]},renderHTML({HTMLAttributes:e}){return["span",re.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBackgroundColor:e=>({chain:t,state:n})=>{var r,a,s;const o=((a=(r=n.storedMarks)==null?void 0:r.find(c=>c.type.name===this.name))==null?void 0:a.attrs)||((s=n.selection.$from.marks().find(c=>c.type.name===this.name))==null?void 0:s.attrs);return(o==null?void 0:o.backgroundColor)===e?!0:n.selection.empty?t().focus().unsetMark(this.name).setMark(this.name,{backgroundColor:e}).run():t().focus().unsetMark(this.name).setMark(this.name,{backgroundColor:e}).run()},unsetBackgroundColor:()=>({chain:e})=>e().unsetMark(this.name).run()}}});function Na(e={}){const{linkOpenInNewTab:t=!0,linkOpenOnClick:n=!0}=e;return[cr.configure({HTMLAttributes:{class:"pubwave-editor__mark--bold"}}),ur.configure({HTMLAttributes:{class:"pubwave-editor__mark--italic"}}),dr.configure({HTMLAttributes:{class:"pubwave-editor__mark--underline"}}),pr.configure({HTMLAttributes:{class:"pubwave-editor__mark--strike"}}),fr.configure({HTMLAttributes:{class:"pubwave-editor__mark--code"}}),hr.configure({openOnClick:n,HTMLAttributes:{class:"pubwave-editor__mark--link",rel:t?"noopener noreferrer":void 0,target:t?"_blank":void 0},validate:o=>{try{return new URL(o),!0}catch{return o.startsWith("/")||o.startsWith("#")}}}),Ea.configure({HTMLAttributes:{class:"pubwave-editor__mark--text-color"}}),_a.configure({HTMLAttributes:{class:"pubwave-editor__mark--background-color"}})]}function Ha(e,t,n){m.useEffect(()=>{if(e>=0&&n.current&&t.current){const o=t.current,r=n.current,a=o.scrollTop,s=o.clientHeight,c=o.scrollHeight,l=r.offsetTop,d=r.offsetHeight,p=o.querySelector(".pubwave-slash-menu__group"),x=o.querySelector(".pubwave-slash-menu__item"),h=Array.from(o.querySelectorAll(".pubwave-slash-menu__item")).pop(),b=l-a,f=b+d;let g=a;if(b<0)g=l-4,p&&g>p.offsetTop&&(g=Math.max(0,p.offsetTop)),x&&g>x.offsetTop-2&&(g=Math.max(0,x.offsetTop-2));else if(f>s){if(g=l-s+d+4,h){const k=h.offsetTop+h.offsetHeight-s+2;g>k&&(g=k)}g=Math.min(c-s,g)}Math.abs(g-a)>.5&&(o.scrollTop=g)}},[e,t,n])}const $a={backgroundColor:"var(--pubwave-bg, #ffffff)",border:"1px solid var(--pubwave-border, #e5e7eb)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",maxHeight:"280px",overflowY:"auto",minWidth:"240px",maxWidth:"300px",padding:"var(--pubwave-spacing-1, 4px)",display:"flex",flexDirection:"column"},za={marginBottom:"0"},qa={padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px) var(--pubwave-spacing-1, 4px)",fontSize:"var(--pubwave-font-size-xs, 11px)",fontWeight:600,color:"var(--pubwave-text-muted, #6b7280)",textTransform:"uppercase",letterSpacing:"0.5px"},Ua={display:"flex",alignItems:"center",gap:"var(--pubwave-spacing-3, 12px)",width:"100%",padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px)",border:"none",background:"none",cursor:"pointer",textAlign:"left",borderRadius:"var(--pubwave-radius-md, 6px)",transition:"background-color 0.1s ease",fontSize:"var(--pubwave-font-size-base, 14px)",color:"var(--pubwave-text, #1a1a1a)"},Fa={display:"flex",alignItems:"center",justifyContent:"center",width:"var(--pubwave-icon-size, 20px)",height:"var(--pubwave-icon-size, 20px)",color:"var(--pubwave-text-tertiary, #4b5563)",flexShrink:0},Wa={fontSize:"var(--pubwave-font-size-base, 14px)",fontWeight:400,color:"var(--pubwave-text, #1a1a1a)"},Va=typeof window>"u",_t=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement=="function";function Y(e){return _t?window.requestAnimationFrame(e):0}function ut(){if(!_t)return!1;const e="ontouchstart"in window||navigator.maxTouchPoints>0,t=window.matchMedia("(pointer: coarse)").matches,n=window.matchMedia("(hover: hover)").matches;return e&&t||e&&!n}function Un(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 7V4h16v3M9 20h6M12 4v16"})})}function Fn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M17 10l3-2v12"})})}function Wn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M21 18h-5c0-2.5 5-2.5 5-5 0-1.5-1-3-3-3s-3 1.5-3 3"})})}function Vn(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M4 12h8M4 18V6M12 18V6M17 12h3M17 18c2.5 0 4-1 4-3s-1.5-3-4-3"})})}function Gn(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"9",y1:"6",x2:"20",y2:"6"}),i.jsx("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),i.jsx("line",{x1:"9",y1:"18",x2:"20",y2:"18"}),i.jsx("circle",{cx:"4",cy:"6",r:"1.5",fill:"currentColor"}),i.jsx("circle",{cx:"4",cy:"12",r:"1.5",fill:"currentColor"}),i.jsx("circle",{cx:"4",cy:"18",r:"1.5",fill:"currentColor"})]})}function Yn(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),i.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),i.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"}),i.jsx("text",{x:"3",y:"8",fontSize:"8",fill:"currentColor",stroke:"none",children:"1"}),i.jsx("text",{x:"3",y:"14",fontSize:"8",fill:"currentColor",stroke:"none",children:"2"}),i.jsx("text",{x:"3",y:"20",fontSize:"8",fill:"currentColor",stroke:"none",children:"3"})]})}function Ga(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"6,9 12,15 18,9"})})}function Ya(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M4 2h5a3 3 0 0 1 0 6H4V2z"}),i.jsx("path",{d:"M4 8h6a3 3 0 0 1 0 6H4V8z"})]})}function Ka(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"11",y1:"2",x2:"5",y2:"14"}),i.jsx("line",{x1:"6",y1:"2",x2:"12",y2:"2"}),i.jsx("line",{x1:"4",y1:"14",x2:"10",y2:"14"})]})}function Xa(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M4 2v6a4 4 0 0 0 8 0V2"}),i.jsx("line",{x1:"2",y1:"14",x2:"14",y2:"14"})]})}function Ja(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"}),i.jsx("path",{d:"M5 4c0-1 1.5-2 3-2s3 .5 3 2c0 1-1 2-3 2"}),i.jsx("path",{d:"M5 12c0 1 1.5 2 3 2s3-.5 3-2c0-1-1-2-3-2"})]})}function Za(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("polyline",{points:"5 4 1 8 5 12"}),i.jsx("polyline",{points:"11 4 15 8 11 12"})]})}function Qa(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"1.87 0 12.19 16",fill:"currentColor",children:[i.jsx("path",{d:"M12.848 2.8a3.145 3.145 0 0 0-4.448 0L6.918 4.283a.625.625 0 0 0 .884.883l1.482-1.482c.74-.74 1.94-.74 2.68 0l.294.294c.74.74.74 1.94 0 2.68l-1.482 1.483a.625.625 0 1 0 .884.884l1.482-1.482a3.145 3.145 0 0 0 0-4.449z"}),i.jsx("path",{d:"M10.472 5.47a.625.625 0 0 0-.884 0L5.229 9.83a.625.625 0 1 0 .884.883l4.359-4.359a.625.625 0 0 0 0-.883"}),i.jsx("path",{d:"M5.167 6.918a.625.625 0 0 0-.884 0L2.8 8.4a3.146 3.146 0 0 0 0 4.448l.294.294a3.145 3.145 0 0 0 4.449 0l1.482-1.482a.625.625 0 0 0-.884-.884L6.66 12.258c-.74.74-1.94.74-2.68 0l-.295-.294c-.74-.74-.74-1.94 0-2.68L5.167 7.8a.625.625 0 0 0 0-.883"})]})}function ei(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M10 3h4v4M14 3l-7 7M14 11v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3"})})}function ti(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M13 4L6 11l-3-3"})})}function ni(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"4",y1:"4",x2:"12",y2:"12"}),i.jsx("line",{x1:"12",y1:"4",x2:"4",y2:"12"})]})}function oi({textColor:e,backgroundColor:t}){const n=t||"transparent",o=!t;return i.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",backgroundColor:n,border:o?"1px solid var(--pubwave-border)":"none",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:e,lineHeight:1},children:"A"})})}function ri(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"3",y:"5",width:"4",height:"4",rx:"0.5"}),i.jsx("rect",{x:"3",y:"14",width:"4",height:"4",rx:"0.5"}),i.jsx("path",{d:"M4 16l1.5 1.5L7 15"}),i.jsx("line",{x1:"10",y1:"7",x2:"21",y2:"7"}),i.jsx("line",{x1:"10",y1:"16",x2:"21",y2:"16"})]})}function ai(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.75-2-2-2H4c-1.25 0-2 .75-2 2v6c0 1.25.75 2 2 2h4"}),i.jsx("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.75-2-2-2h-4c-1.25 0-2 .75-2 2v6c0 1.25.75 2 2 2h4"})]})}function ii(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("polyline",{points:"16,18 22,12 16,6"}),i.jsx("polyline",{points:"8,6 2,12 8,18"})]})}function si(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"})})}function li(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),i.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),i.jsx("polyline",{points:"21,15 16,10 5,21"})]})}function ci(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"2",y:"3",width:"20",height:"18",rx:"2"}),i.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]})}function ui(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"2",y:"3",width:"20",height:"18",rx:"2"}),i.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"21"}),i.jsx("line",{x1:"16",y1:"3",x2:"16",y2:"21"})]})}async function di(e,t){const n=(t==null?void 0:t.maxSize)??10485760;if(e.size>n)throw new Error(`Image file is too large. Maximum size is ${n/1024/1024}MB`);if(t!=null&&t.handler)try{return await t.handler(e)}catch(o){console.warn("Custom image upload failed, falling back to base64:",o)}return new Promise((o,r)=>{const a=new FileReader;a.onload=s=>{var l;const c=(l=s.target)==null?void 0:l.result;c?o(c):r(new Error("Failed to read image file"))},a.onerror=()=>{r(new Error("Failed to read image file"))},a.readAsDataURL(e)})}function pi(e,t,n){if(!((n==null?void 0:n.accept)??["image/*"]).some(a=>a==="image/*"?t.type.startsWith("image/"):t.type===a)){console.warn("Selected file is not an image");return}di(t,n).then(a=>{e.chain().focus().setImage({src:a}).run()}).catch(a=>{console.error("Failed to upload image:",a)})}function fn(e,t){const{state:n,dispatch:o}=e.view,r=n.schema.nodes.layout,a=n.schema.nodes.layoutColumn;if(!r||!a){console.warn("Layout node type not found in schema");return}const s=n.schema.nodes.paragraph;if(!s){console.warn("Paragraph node type not found in schema");return}const c=Array.from({length:t},()=>a.create(null,s.create())),l=r.create({columns:t},c),d=n.tr.replaceSelectionWith(l);o(d);const p=d.selection.$from.before();e.chain().focus().setTextSelection(p+2).run()}function Kn(e,t){var r,a,s,c;const o=(t||{slashMenu:{commands:{paragraph:{title:"Text",description:"Plain text block"},heading1:{title:"Heading 1",description:"Large section heading"},heading2:{title:"Heading 2",description:"Medium section heading"},heading3:{title:"Heading 3",description:"Small section heading"},bulletList:{title:"Bullet List",description:"Create a bulleted list"},orderedList:{title:"Numbered List",description:"Create a numbered list"},taskList:{title:"To-do list",description:"Create a todo list with checkboxes"},image:{title:"Image",description:"Upload or paste an image"},blockquote:{title:"Blockquote",description:"Create a quote block"},codeBlock:{title:"Code",description:"Create a code snippet"},horizontalRule:{title:"Divider",description:"Create a horizontal line"},layoutTwoColumn:{title:"Two Column Layout",description:"Split content into two side-by-side columns"},layoutThreeColumn:{title:"Three Column Layout",description:"Split content into three side-by-side columns"}}}}).slashMenu.commands;return[{id:"paragraph",title:o.paragraph.title,description:o.paragraph.description,icon:i.jsx(Un,{}),aliases:["p","text","paragraph"],group:"basic",action:l=>l.chain().focus().setParagraph().run()},{id:"heading1",title:o.heading1.title,description:o.heading1.description,icon:i.jsx(Fn,{}),aliases:["h1","title"],group:"basic",action:l=>l.chain().focus().toggleHeading({level:1}).run()},{id:"heading2",title:o.heading2.title,description:o.heading2.description,icon:i.jsx(Wn,{}),aliases:["h2","subtitle"],group:"basic",action:l=>l.chain().focus().toggleHeading({level:2}).run()},{id:"heading3",title:o.heading3.title,description:o.heading3.description,icon:i.jsx(Vn,{}),aliases:["h3"],group:"basic",action:l=>l.chain().focus().toggleHeading({level:3}).run()},{id:"bulletList",title:o.bulletList.title,description:o.bulletList.description,icon:i.jsx(Gn,{}),aliases:["ul","bullet","unordered","-"],group:"list",action:l=>l.chain().focus().toggleBulletList().run()},{id:"orderedList",title:o.orderedList.title,description:o.orderedList.description,icon:i.jsx(Yn,{}),aliases:["ol","numbered","ordered","1."],group:"list",action:l=>l.chain().focus().toggleOrderedList().run()},{id:"taskList",title:o.taskList.title,description:o.taskList.description,icon:i.jsx(ri,{}),aliases:["todo","task","checkbox","[]"],group:"list",action:l=>l.chain().focus().toggleTaskList().run()},{id:"image",title:o.image.title,description:o.image.description,icon:i.jsx(li,{}),aliases:["img","picture","photo","pic"],group:"media",action:l=>{const d=document.createElement("input");d.type="file";const p=(e==null?void 0:e.accept)??["image/*"];d.accept=p.join(","),d.style.display="none",d.onchange=x=>{var b;const h=(b=x.target.files)==null?void 0:b[0];h&&pi(l,h,e),document.body.removeChild(d)},document.body.appendChild(d),d.click()}},{id:"blockquote",title:o.blockquote.title,description:o.blockquote.description,icon:i.jsx(ai,{}),aliases:["quote","blockquote",">"],group:"advanced",action:l=>l.chain().focus().toggleBlockquote().run()},{id:"codeBlock",title:o.codeBlock.title,description:o.codeBlock.description,icon:i.jsx(ii,{}),aliases:["code","pre","snippet","```"],group:"advanced",action:l=>l.chain().focus().toggleCodeBlock().run()},{id:"horizontalRule",title:o.horizontalRule.title,description:o.horizontalRule.description,icon:i.jsx(si,{}),aliases:["hr","divider","line","---"],group:"advanced",action:l=>{l.chain().focus().setHorizontalRule().run(),Y(()=>{const{state:d}=l.view,{$from:p}=d.selection;let x=-1;const h=p.pos;if(d.doc.descendants((b,f)=>{if(b.type.name==="horizontalRule"){const g=Math.abs(f-h);(x===-1||Math.abs(x-h)>g)&&(x=f)}}),x!==-1){const b=d.doc.nodeAt(x);if(b){const f=x+b.nodeSize;l.chain().setTextSelection(f).insertContent({type:"paragraph"}).focus().run()}}else l.chain().focus().createParagraphNear().run()})}},{id:"layoutTwoColumn",title:((r=o.layoutTwoColumn)==null?void 0:r.title)??"Two Column Layout",description:((a=o.layoutTwoColumn)==null?void 0:a.description)??"Split content into two side-by-side columns",icon:i.jsx(ci,{}),aliases:["layout2","two columns","2 col","columns"],group:"layout",action:l=>fn(l,2)},{id:"layoutThreeColumn",title:((s=o.layoutThreeColumn)==null?void 0:s.title)??"Three Column Layout",description:((c=o.layoutThreeColumn)==null?void 0:c.description)??"Split content into three side-by-side columns",icon:i.jsx(ui,{}),aliases:["layout3","three columns","3 col"],group:"layout",action:l=>fn(l,3)}]}const Dt=Kn();function fi(e,t){if(!t)return e;const n=t.toLowerCase();return e.filter(o=>{var c;const r=o.title.toLowerCase(),a=r.startsWith(n)||r.includes(` ${n}`),s=((c=o.aliases)==null?void 0:c.some(l=>l.toLowerCase().startsWith(n)))??!1;return a||s})}var ee="top",ce="bottom",ue="right",te="left",Zt="auto",dt=[ee,ce,ue,te],Ue="start",at="end",hi="clippingParents",Xn="viewport",Ze="popper",bi="reference",hn=dt.reduce(function(e,t){return e.concat([t+"-"+Ue,t+"-"+at])},[]),Jn=[].concat(dt,[Zt]).reduce(function(e,t){return e.concat([t,t+"-"+Ue,t+"-"+at])},[]),vi="beforeRead",gi="read",mi="afterRead",xi="beforeMain",yi="main",wi="afterMain",ki="beforeWrite",Ci="write",Li="afterWrite",Ti=[vi,gi,mi,xi,yi,wi,ki,Ci,Li];function he(e){return e?(e.nodeName||"").toLowerCase():null}function ae(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Re(e){var t=ae(e).Element;return e instanceof t||e instanceof Element}function le(e){var t=ae(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function Qt(e){if(typeof ShadowRoot>"u")return!1;var t=ae(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function Bi(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var o=t.styles[n]||{},r=t.attributes[n]||{},a=t.elements[n];!le(a)||!he(a)||(Object.assign(a.style,o),Object.keys(r).forEach(function(s){var c=r[s];c===!1?a.removeAttribute(s):a.setAttribute(s,c===!0?"":c)}))})}function Ai(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(o){var r=t.elements[o],a=t.attributes[o]||{},s=Object.keys(t.styles.hasOwnProperty(o)?t.styles[o]:n[o]),c=s.reduce(function(l,d){return l[d]="",l},{});!le(r)||!he(r)||(Object.assign(r.style,c),Object.keys(a).forEach(function(l){r.removeAttribute(l)}))})}}const Zn={name:"applyStyles",enabled:!0,phase:"write",fn:Bi,effect:Ai,requires:["computeStyles"]};function fe(e){return e.split("-")[0]}var Ie=Math.max,It=Math.min,Fe=Math.round;function Vt(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function Qn(){return!/^((?!chrome|android).)*safari/i.test(Vt())}function We(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var o=e.getBoundingClientRect(),r=1,a=1;t&&le(e)&&(r=e.offsetWidth>0&&Fe(o.width)/e.offsetWidth||1,a=e.offsetHeight>0&&Fe(o.height)/e.offsetHeight||1);var s=Re(e)?ae(e):window,c=s.visualViewport,l=!Qn()&&n,d=(o.left+(l&&c?c.offsetLeft:0))/r,p=(o.top+(l&&c?c.offsetTop:0))/a,x=o.width/r,h=o.height/a;return{width:x,height:h,top:p,right:d+x,bottom:p+h,left:d,x:d,y:p}}function en(e){var t=We(e),n=e.offsetWidth,o=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-o)<=1&&(o=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:o}}function eo(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Qt(n)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}function we(e){return ae(e).getComputedStyle(e)}function ji(e){return["table","td","th"].indexOf(he(e))>=0}function Te(e){return((Re(e)?e.ownerDocument:e.document)||window.document).documentElement}function Nt(e){return he(e)==="html"?e:e.assignedSlot||e.parentNode||(Qt(e)?e.host:null)||Te(e)}function bn(e){return!le(e)||we(e).position==="fixed"?null:e.offsetParent}function Si(e){var t=/firefox/i.test(Vt()),n=/Trident/i.test(Vt());if(n&&le(e)){var o=we(e);if(o.position==="fixed")return null}var r=Nt(e);for(Qt(r)&&(r=r.host);le(r)&&["html","body"].indexOf(he(r))<0;){var a=we(r);if(a.transform!=="none"||a.perspective!=="none"||a.contain==="paint"||["transform","perspective"].indexOf(a.willChange)!==-1||t&&a.willChange==="filter"||t&&a.filter&&a.filter!=="none")return r;r=r.parentNode}return null}function pt(e){for(var t=ae(e),n=bn(e);n&&ji(n)&&we(n).position==="static";)n=bn(n);return n&&(he(n)==="html"||he(n)==="body"&&we(n).position==="static")?t:n||Si(e)||t}function tn(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function nt(e,t,n){return Ie(e,It(t,n))}function Mi(e,t,n){var o=nt(e,t,n);return o>n?n:o}function to(){return{top:0,right:0,bottom:0,left:0}}function no(e){return Object.assign({},to(),e)}function oo(e,t){return t.reduce(function(n,o){return n[o]=e,n},{})}var Pi=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,no(typeof t!="number"?t:oo(t,dt))};function Di(e){var t,n=e.state,o=e.name,r=e.options,a=n.elements.arrow,s=n.modifiersData.popperOffsets,c=fe(n.placement),l=tn(c),d=[te,ue].indexOf(c)>=0,p=d?"height":"width";if(!(!a||!s)){var x=Pi(r.padding,n),h=en(a),b=l==="y"?ee:te,f=l==="y"?ce:ue,g=n.rects.reference[p]+n.rects.reference[l]-s[l]-n.rects.popper[p],L=s[l]-n.rects.reference[l],k=pt(a),M=k?l==="y"?k.clientHeight||0:k.clientWidth||0:0,C=g/2-L/2,u=x[b],j=M-h[p]-x[f],w=M/2-h[p]/2+C,S=nt(u,w,j),P=l;n.modifiersData[o]=(t={},t[P]=S,t.centerOffset=S-w,t)}}function Ii(e){var t=e.state,n=e.options,o=n.element,r=o===void 0?"[data-popper-arrow]":o;r!=null&&(typeof r=="string"&&(r=t.elements.popper.querySelector(r),!r)||eo(t.elements.popper,r)&&(t.elements.arrow=r))}const Ri={name:"arrow",enabled:!0,phase:"main",fn:Di,effect:Ii,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Ve(e){return e.split("-")[1]}var Oi={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ei(e,t){var n=e.x,o=e.y,r=t.devicePixelRatio||1;return{x:Fe(n*r)/r||0,y:Fe(o*r)/r||0}}function vn(e){var t,n=e.popper,o=e.popperRect,r=e.placement,a=e.variation,s=e.offsets,c=e.position,l=e.gpuAcceleration,d=e.adaptive,p=e.roundOffsets,x=e.isFixed,h=s.x,b=h===void 0?0:h,f=s.y,g=f===void 0?0:f,L=typeof p=="function"?p({x:b,y:g}):{x:b,y:g};b=L.x,g=L.y;var k=s.hasOwnProperty("x"),M=s.hasOwnProperty("y"),C=te,u=ee,j=window;if(d){var w=pt(n),S="clientHeight",P="clientWidth";if(w===ae(n)&&(w=Te(n),we(w).position!=="static"&&c==="absolute"&&(S="scrollHeight",P="scrollWidth")),w=w,r===ee||(r===te||r===ue)&&a===at){u=ce;var R=x&&w===j&&j.visualViewport?j.visualViewport.height:w[S];g-=R-o.height,g*=l?1:-1}if(r===te||(r===ee||r===ce)&&a===at){C=ue;var B=x&&w===j&&j.visualViewport?j.visualViewport.width:w[P];b-=B-o.width,b*=l?1:-1}}var v=Object.assign({position:c},d&&Oi),T=p===!0?Ei({x:b,y:g},ae(n)):{x:b,y:g};if(b=T.x,g=T.y,l){var A;return Object.assign({},v,(A={},A[u]=M?"0":"",A[C]=k?"0":"",A.transform=(j.devicePixelRatio||1)<=1?"translate("+b+"px, "+g+"px)":"translate3d("+b+"px, "+g+"px, 0)",A))}return Object.assign({},v,(t={},t[u]=M?g+"px":"",t[C]=k?b+"px":"",t.transform="",t))}function _i(e){var t=e.state,n=e.options,o=n.gpuAcceleration,r=o===void 0?!0:o,a=n.adaptive,s=a===void 0?!0:a,c=n.roundOffsets,l=c===void 0?!0:c,d={placement:fe(t.placement),variation:Ve(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:r,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,vn(Object.assign({},d,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:l})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,vn(Object.assign({},d,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const Ni={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:_i,data:{}};var Tt={passive:!0};function Hi(e){var t=e.state,n=e.instance,o=e.options,r=o.scroll,a=r===void 0?!0:r,s=o.resize,c=s===void 0?!0:s,l=ae(t.elements.popper),d=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&d.forEach(function(p){p.addEventListener("scroll",n.update,Tt)}),c&&l.addEventListener("resize",n.update,Tt),function(){a&&d.forEach(function(p){p.removeEventListener("scroll",n.update,Tt)}),c&&l.removeEventListener("resize",n.update,Tt)}}const $i={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Hi,data:{}};var zi={left:"right",right:"left",bottom:"top",top:"bottom"};function jt(e){return e.replace(/left|right|bottom|top/g,function(t){return zi[t]})}var qi={start:"end",end:"start"};function gn(e){return e.replace(/start|end/g,function(t){return qi[t]})}function nn(e){var t=ae(e),n=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:n,scrollTop:o}}function on(e){return We(Te(e)).left+nn(e).scrollLeft}function Ui(e,t){var n=ae(e),o=Te(e),r=n.visualViewport,a=o.clientWidth,s=o.clientHeight,c=0,l=0;if(r){a=r.width,s=r.height;var d=Qn();(d||!d&&t==="fixed")&&(c=r.offsetLeft,l=r.offsetTop)}return{width:a,height:s,x:c+on(e),y:l}}function Fi(e){var t,n=Te(e),o=nn(e),r=(t=e.ownerDocument)==null?void 0:t.body,a=Ie(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),s=Ie(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),c=-o.scrollLeft+on(e),l=-o.scrollTop;return we(r||n).direction==="rtl"&&(c+=Ie(n.clientWidth,r?r.clientWidth:0)-a),{width:a,height:s,x:c,y:l}}function rn(e){var t=we(e),n=t.overflow,o=t.overflowX,r=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+r+o)}function ro(e){return["html","body","#document"].indexOf(he(e))>=0?e.ownerDocument.body:le(e)&&rn(e)?e:ro(Nt(e))}function ot(e,t){var n;t===void 0&&(t=[]);var o=ro(e),r=o===((n=e.ownerDocument)==null?void 0:n.body),a=ae(o),s=r?[a].concat(a.visualViewport||[],rn(o)?o:[]):o,c=t.concat(s);return r?c:c.concat(ot(Nt(s)))}function Gt(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function Wi(e,t){var n=We(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function mn(e,t,n){return t===Xn?Gt(Ui(e,n)):Re(t)?Wi(t,n):Gt(Fi(Te(e)))}function Vi(e){var t=ot(Nt(e)),n=["absolute","fixed"].indexOf(we(e).position)>=0,o=n&&le(e)?pt(e):e;return Re(o)?t.filter(function(r){return Re(r)&&eo(r,o)&&he(r)!=="body"}):[]}function Gi(e,t,n,o){var r=t==="clippingParents"?Vi(e):[].concat(t),a=[].concat(r,[n]),s=a[0],c=a.reduce(function(l,d){var p=mn(e,d,o);return l.top=Ie(p.top,l.top),l.right=It(p.right,l.right),l.bottom=It(p.bottom,l.bottom),l.left=Ie(p.left,l.left),l},mn(e,s,o));return c.width=c.right-c.left,c.height=c.bottom-c.top,c.x=c.left,c.y=c.top,c}function ao(e){var t=e.reference,n=e.element,o=e.placement,r=o?fe(o):null,a=o?Ve(o):null,s=t.x+t.width/2-n.width/2,c=t.y+t.height/2-n.height/2,l;switch(r){case ee:l={x:s,y:t.y-n.height};break;case ce:l={x:s,y:t.y+t.height};break;case ue:l={x:t.x+t.width,y:c};break;case te:l={x:t.x-n.width,y:c};break;default:l={x:t.x,y:t.y}}var d=r?tn(r):null;if(d!=null){var p=d==="y"?"height":"width";switch(a){case Ue:l[d]=l[d]-(t[p]/2-n[p]/2);break;case at:l[d]=l[d]+(t[p]/2-n[p]/2);break}}return l}function it(e,t){t===void 0&&(t={});var n=t,o=n.placement,r=o===void 0?e.placement:o,a=n.strategy,s=a===void 0?e.strategy:a,c=n.boundary,l=c===void 0?hi:c,d=n.rootBoundary,p=d===void 0?Xn:d,x=n.elementContext,h=x===void 0?Ze:x,b=n.altBoundary,f=b===void 0?!1:b,g=n.padding,L=g===void 0?0:g,k=no(typeof L!="number"?L:oo(L,dt)),M=h===Ze?bi:Ze,C=e.rects.popper,u=e.elements[f?M:h],j=Gi(Re(u)?u:u.contextElement||Te(e.elements.popper),l,p,s),w=We(e.elements.reference),S=ao({reference:w,element:C,placement:r}),P=Gt(Object.assign({},C,S)),R=h===Ze?P:w,B={top:j.top-R.top+k.top,bottom:R.bottom-j.bottom+k.bottom,left:j.left-R.left+k.left,right:R.right-j.right+k.right},v=e.modifiersData.offset;if(h===Ze&&v){var T=v[r];Object.keys(B).forEach(function(A){var _=[ue,ce].indexOf(A)>=0?1:-1,H=[ee,ce].indexOf(A)>=0?"y":"x";B[A]+=T[H]*_})}return B}function Yi(e,t){t===void 0&&(t={});var n=t,o=n.placement,r=n.boundary,a=n.rootBoundary,s=n.padding,c=n.flipVariations,l=n.allowedAutoPlacements,d=l===void 0?Jn:l,p=Ve(o),x=p?c?hn:hn.filter(function(f){return Ve(f)===p}):dt,h=x.filter(function(f){return d.indexOf(f)>=0});h.length===0&&(h=x);var b=h.reduce(function(f,g){return f[g]=it(e,{placement:g,boundary:r,rootBoundary:a,padding:s})[fe(g)],f},{});return Object.keys(b).sort(function(f,g){return b[f]-b[g]})}function Ki(e){if(fe(e)===Zt)return[];var t=jt(e);return[gn(e),t,gn(t)]}function Xi(e){var t=e.state,n=e.options,o=e.name;if(!t.modifiersData[o]._skip){for(var r=n.mainAxis,a=r===void 0?!0:r,s=n.altAxis,c=s===void 0?!0:s,l=n.fallbackPlacements,d=n.padding,p=n.boundary,x=n.rootBoundary,h=n.altBoundary,b=n.flipVariations,f=b===void 0?!0:b,g=n.allowedAutoPlacements,L=t.options.placement,k=fe(L),M=k===L,C=l||(M||!f?[jt(L)]:Ki(L)),u=[L].concat(C).reduce(function(Q,G){return Q.concat(fe(G)===Zt?Yi(t,{placement:G,boundary:p,rootBoundary:x,padding:d,flipVariations:f,allowedAutoPlacements:g}):G)},[]),j=t.rects.reference,w=t.rects.popper,S=new Map,P=!0,R=u[0],B=0;B<u.length;B++){var v=u[B],T=fe(v),A=Ve(v)===Ue,_=[ee,ce].indexOf(T)>=0,H=_?"width":"height",z=it(t,{placement:v,boundary:p,rootBoundary:x,altBoundary:h,padding:d}),F=_?A?ue:te:A?ce:ee;j[H]>w[H]&&(F=jt(F));var U=jt(F),I=[];if(a&&I.push(z[T]<=0),c&&I.push(z[F]<=0,z[U]<=0),I.every(function(Q){return Q})){R=v,P=!1;break}S.set(v,I)}if(P)for(var N=f?3:1,W=function(G){var ne=u.find(function(ve){var ie=S.get(ve);if(ie)return ie.slice(0,G).every(function(ke){return ke})});if(ne)return R=ne,"break"},V=N;V>0;V--){var K=W(V);if(K==="break")break}t.placement!==R&&(t.modifiersData[o]._skip=!0,t.placement=R,t.reset=!0)}}const Ji={name:"flip",enabled:!0,phase:"main",fn:Xi,requiresIfExists:["offset"],data:{_skip:!1}};function xn(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function yn(e){return[ee,ue,ce,te].some(function(t){return e[t]>=0})}function Zi(e){var t=e.state,n=e.name,o=t.rects.reference,r=t.rects.popper,a=t.modifiersData.preventOverflow,s=it(t,{elementContext:"reference"}),c=it(t,{altBoundary:!0}),l=xn(s,o),d=xn(c,r,a),p=yn(l),x=yn(d);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:d,isReferenceHidden:p,hasPopperEscaped:x},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":x})}const Qi={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Zi};function es(e,t,n){var o=fe(e),r=[te,ee].indexOf(o)>=0?-1:1,a=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,s=a[0],c=a[1];return s=s||0,c=(c||0)*r,[te,ue].indexOf(o)>=0?{x:c,y:s}:{x:s,y:c}}function ts(e){var t=e.state,n=e.options,o=e.name,r=n.offset,a=r===void 0?[0,0]:r,s=Jn.reduce(function(p,x){return p[x]=es(x,t.rects,a),p},{}),c=s[t.placement],l=c.x,d=c.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=d),t.modifiersData[o]=s}const ns={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:ts};function os(e){var t=e.state,n=e.name;t.modifiersData[n]=ao({reference:t.rects.reference,element:t.rects.popper,placement:t.placement})}const rs={name:"popperOffsets",enabled:!0,phase:"read",fn:os,data:{}};function as(e){return e==="x"?"y":"x"}function is(e){var t=e.state,n=e.options,o=e.name,r=n.mainAxis,a=r===void 0?!0:r,s=n.altAxis,c=s===void 0?!1:s,l=n.boundary,d=n.rootBoundary,p=n.altBoundary,x=n.padding,h=n.tether,b=h===void 0?!0:h,f=n.tetherOffset,g=f===void 0?0:f,L=it(t,{boundary:l,rootBoundary:d,padding:x,altBoundary:p}),k=fe(t.placement),M=Ve(t.placement),C=!M,u=tn(k),j=as(u),w=t.modifiersData.popperOffsets,S=t.rects.reference,P=t.rects.popper,R=typeof g=="function"?g(Object.assign({},t.rects,{placement:t.placement})):g,B=typeof R=="number"?{mainAxis:R,altAxis:R}:Object.assign({mainAxis:0,altAxis:0},R),v=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,T={x:0,y:0};if(w){if(a){var A,_=u==="y"?ee:te,H=u==="y"?ce:ue,z=u==="y"?"height":"width",F=w[u],U=F+L[_],I=F-L[H],N=b?-P[z]/2:0,W=M===Ue?S[z]:P[z],V=M===Ue?-P[z]:-S[z],K=t.elements.arrow,Q=b&&K?en(K):{width:0,height:0},G=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:to(),ne=G[_],ve=G[H],ie=nt(0,S[z],Q[z]),ke=C?S[z]/2-N-ie-ne-B.mainAxis:W-ie-ne-B.mainAxis,de=C?-S[z]/2+N+ie+ve+B.mainAxis:V+ie+ve+B.mainAxis,X=t.elements.arrow&&pt(t.elements.arrow),ht=X?u==="y"?X.clientTop||0:X.clientLeft||0:0,Ge=(A=v==null?void 0:v[u])!=null?A:0,bt=F+ke-Ge-ht,vt=F+de-Ge,Ye=nt(b?It(U,bt):U,F,b?Ie(I,vt):I);w[u]=Ye,T[u]=Ye-F}if(c){var Ke,gt=u==="x"?ee:te,mt=u==="x"?ce:ue,ge=w[j],Ce=j==="y"?"height":"width",Xe=ge+L[gt],je=ge-L[mt],Je=[ee,te].indexOf(k)!==-1,xt=(Ke=v==null?void 0:v[j])!=null?Ke:0,yt=Je?Xe:ge-S[Ce]-P[Ce]-xt+B.altAxis,wt=Je?ge+S[Ce]+P[Ce]-xt-B.altAxis:je,kt=b&&Je?Mi(yt,ge,wt):nt(b?yt:Xe,ge,b?wt:je);w[j]=kt,T[j]=kt-ge}t.modifiersData[o]=T}}const ss={name:"preventOverflow",enabled:!0,phase:"main",fn:is,requiresIfExists:["offset"]};function ls(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function cs(e){return e===ae(e)||!le(e)?nn(e):ls(e)}function us(e){var t=e.getBoundingClientRect(),n=Fe(t.width)/e.offsetWidth||1,o=Fe(t.height)/e.offsetHeight||1;return n!==1||o!==1}function ds(e,t,n){n===void 0&&(n=!1);var o=le(t),r=le(t)&&us(t),a=Te(t),s=We(e,r,n),c={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(o||!o&&!n)&&((he(t)!=="body"||rn(a))&&(c=cs(t)),le(t)?(l=We(t,!0),l.x+=t.clientLeft,l.y+=t.clientTop):a&&(l.x=on(a))),{x:s.left+c.scrollLeft-l.x,y:s.top+c.scrollTop-l.y,width:s.width,height:s.height}}function ps(e){var t=new Map,n=new Set,o=[];e.forEach(function(a){t.set(a.name,a)});function r(a){n.add(a.name);var s=[].concat(a.requires||[],a.requiresIfExists||[]);s.forEach(function(c){if(!n.has(c)){var l=t.get(c);l&&r(l)}}),o.push(a)}return e.forEach(function(a){n.has(a.name)||r(a)}),o}function fs(e){var t=ps(e);return Ti.reduce(function(n,o){return n.concat(t.filter(function(r){return r.phase===o}))},[])}function hs(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function bs(e){var t=e.reduce(function(n,o){var r=n[o.name];return n[o.name]=r?Object.assign({},r,o,{options:Object.assign({},r.options,o.options),data:Object.assign({},r.data,o.data)}):o,n},{});return Object.keys(t).map(function(n){return t[n]})}var wn={placement:"bottom",modifiers:[],strategy:"absolute"};function kn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(o){return!(o&&typeof o.getBoundingClientRect=="function")})}function vs(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,o=n===void 0?[]:n,r=t.defaultOptions,a=r===void 0?wn:r;return function(c,l,d){d===void 0&&(d=a);var p={placement:"bottom",orderedModifiers:[],options:Object.assign({},wn,a),modifiersData:{},elements:{reference:c,popper:l},attributes:{},styles:{}},x=[],h=!1,b={state:p,setOptions:function(k){var M=typeof k=="function"?k(p.options):k;g(),p.options=Object.assign({},a,p.options,M),p.scrollParents={reference:Re(c)?ot(c):c.contextElement?ot(c.contextElement):[],popper:ot(l)};var C=fs(bs([].concat(o,p.options.modifiers)));return p.orderedModifiers=C.filter(function(u){return u.enabled}),f(),b.update()},forceUpdate:function(){if(!h){var k=p.elements,M=k.reference,C=k.popper;if(kn(M,C)){p.rects={reference:ds(M,pt(C),p.options.strategy==="fixed"),popper:en(C)},p.reset=!1,p.placement=p.options.placement,p.orderedModifiers.forEach(function(B){return p.modifiersData[B.name]=Object.assign({},B.data)});for(var u=0;u<p.orderedModifiers.length;u++){if(p.reset===!0){p.reset=!1,u=-1;continue}var j=p.orderedModifiers[u],w=j.fn,S=j.options,P=S===void 0?{}:S,R=j.name;typeof w=="function"&&(p=w({state:p,options:P,name:R,instance:b})||p)}}}},update:hs(function(){return new Promise(function(L){b.forceUpdate(),L(p)})}),destroy:function(){g(),h=!0}};if(!kn(c,l))return b;b.setOptions(d).then(function(L){!h&&d.onFirstUpdate&&d.onFirstUpdate(L)});function f(){p.orderedModifiers.forEach(function(L){var k=L.name,M=L.options,C=M===void 0?{}:M,u=L.effect;if(typeof u=="function"){var j=u({state:p,name:k,instance:b,options:C}),w=function(){};x.push(j||w)}})}function g(){x.forEach(function(L){return L()}),x=[]}return b}}var gs=[$i,rs,Ni,Zn,ns,Ji,ss,Ri,Qi],ms=vs({defaultModifiers:gs}),xs="tippy-box",io="tippy-content",ys="tippy-backdrop",so="tippy-arrow",lo="tippy-svg-arrow",Pe={passive:!0,capture:!0},co=function(){return document.body};function ws(e,t){return{}.hasOwnProperty.call(e,t)}function zt(e,t,n){if(Array.isArray(e)){var o=e[t];return o??(Array.isArray(n)?n[t]:n)}return e}function an(e,t){var n={}.toString.call(e);return n.indexOf("[object")===0&&n.indexOf(t+"]")>-1}function uo(e,t){return typeof e=="function"?e.apply(void 0,t):e}function Cn(e,t){if(t===0)return e;var n;return function(o){clearTimeout(n),n=setTimeout(function(){e(o)},t)}}function ks(e,t){var n=Object.assign({},e);return t.forEach(function(o){delete n[o]}),n}function Cs(e){return e.split(/\s+/).filter(Boolean)}function qe(e){return[].concat(e)}function Ln(e,t){e.indexOf(t)===-1&&e.push(t)}function Ls(e){return e.filter(function(t,n){return e.indexOf(t)===n})}function Ts(e){return e.split("-")[0]}function Rt(e){return[].slice.call(e)}function Tn(e){return Object.keys(e).reduce(function(t,n){return e[n]!==void 0&&(t[n]=e[n]),t},{})}function rt(){return document.createElement("div")}function st(e){return["Element","Fragment"].some(function(t){return an(e,t)})}function Bs(e){return an(e,"NodeList")}function As(e){return an(e,"MouseEvent")}function js(e){return!!(e&&e._tippy&&e._tippy.reference===e)}function Ss(e){return st(e)?[e]:Bs(e)?Rt(e):Array.isArray(e)?e:Rt(document.querySelectorAll(e))}function qt(e,t){e.forEach(function(n){n&&(n.style.transitionDuration=t+"ms")})}function Bn(e,t){e.forEach(function(n){n&&n.setAttribute("data-state",t)})}function Ms(e){var t,n=qe(e),o=n[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}function Ps(e,t){var n=t.clientX,o=t.clientY;return e.every(function(r){var a=r.popperRect,s=r.popperState,c=r.props,l=c.interactiveBorder,d=Ts(s.placement),p=s.modifiersData.offset;if(!p)return!0;var x=d==="bottom"?p.top.y:0,h=d==="top"?p.bottom.y:0,b=d==="right"?p.left.x:0,f=d==="left"?p.right.x:0,g=a.top-o+x>l,L=o-a.bottom-h>l,k=a.left-n+b>l,M=n-a.right-f>l;return g||L||k||M})}function Ut(e,t,n){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(r){e[o](r,n)})}function An(e,t){for(var n=t;n;){var o;if(e.contains(n))return!0;n=n.getRootNode==null||(o=n.getRootNode())==null?void 0:o.host}return!1}var pe={isTouch:!1},jn=0;function Ds(){pe.isTouch||(pe.isTouch=!0,window.performance&&document.addEventListener("mousemove",po))}function po(){var e=performance.now();e-jn<20&&(pe.isTouch=!1,document.removeEventListener("mousemove",po)),jn=e}function Is(){var e=document.activeElement;if(js(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}function Rs(){document.addEventListener("touchstart",Ds,Pe),window.addEventListener("blur",Is)}var Os=typeof window<"u"&&typeof document<"u",Es=Os?!!window.msCrypto:!1;function ze(e){var t=e==="destroy"?"n already-":" ";return[e+"() was called on a"+t+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function Sn(e){var t=/[ \t]{2,}/g,n=/^[ \t]*/gm;return e.replace(t," ").replace(n,"").trim()}function _s(e){return Sn(`
|
|
2
2
|
%ctippy.js
|
|
3
3
|
|
|
4
4
|
%c`+Sn(e)+`
|
|
5
5
|
|
|
6
6
|
%c👷 This is a development-only message. It will be removed in production.
|
|
7
|
-
`)}function fo(e){return[_s(e),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var lt;process.env.NODE_ENV!=="production"&&Ns();function Ns(){lt=new Set}function
|
|
7
|
+
`)}function fo(e){return[_s(e),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var lt;process.env.NODE_ENV!=="production"&&Ns();function Ns(){lt=new Set}function me(e,t){if(e&&!lt.has(t)){var n;lt.add(t),(n=console).warn.apply(n,fo(t))}}function Yt(e,t){if(e&&!lt.has(t)){var n;lt.add(t),(n=console).error.apply(n,fo(t))}}function Hs(e){var t=!e,n=Object.prototype.toString.call(e)==="[object Object]"&&!e.addEventListener;Yt(t,["tippy() was passed","`"+String(e)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),Yt(n,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var ho={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},$s={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},oe=Object.assign({appendTo:co,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},ho,$s),zs=Object.keys(oe),qs=function(t){process.env.NODE_ENV!=="production"&&vo(t,[]);var n=Object.keys(t);n.forEach(function(o){oe[o]=t[o]})};function bo(e){var t=e.plugins||[],n=t.reduce(function(o,r){var a=r.name,s=r.defaultValue;if(a){var c;o[a]=e[a]!==void 0?e[a]:(c=oe[a])!=null?c:s}return o},{});return Object.assign({},e,n)}function Us(e,t){var n=t?Object.keys(bo(Object.assign({},oe,{plugins:t}))):zs,o=n.reduce(function(r,a){var s=(e.getAttribute("data-tippy-"+a)||"").trim();if(!s)return r;if(a==="content")r[a]=s;else try{r[a]=JSON.parse(s)}catch{r[a]=s}return r},{});return o}function Mn(e,t){var n=Object.assign({},t,{content:uo(t.content,[e])},t.ignoreAttributes?{}:Us(e,t.plugins));return n.aria=Object.assign({},oe.aria,n.aria),n.aria={expanded:n.aria.expanded==="auto"?t.interactive:n.aria.expanded,content:n.aria.content==="auto"?t.interactive?null:"describedby":n.aria.content},n}function vo(e,t){e===void 0&&(e={}),t===void 0&&(t=[]);var n=Object.keys(e);n.forEach(function(o){var r=ks(oe,Object.keys(ho)),a=!ws(r,o);a&&(a=t.filter(function(s){return s.name===o}).length===0),me(a,["`"+o+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.",`
|
|
8
8
|
|
|
9
9
|
`,`All props: https://atomiks.github.io/tippyjs/v6/all-props/
|
|
10
|
-
`,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var Fs=function(){return"innerHTML"};function Kt(e,t){e[Fs()]=t}function Pn(e){var t=rt();return e===!0?t.className=so:(t.className=lo,st(e)?t.appendChild(e):Kt(t,e)),t}function Dn(e,t){st(t.content)?(Kt(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Kt(e,t.content):e.textContent=t.content)}function Xt(e){var t=e.firstElementChild,n=Rt(t.children);return{box:t,content:n.find(function(o){return o.classList.contains(io)}),arrow:n.find(function(o){return o.classList.contains(so)||o.classList.contains(lo)}),backdrop:n.find(function(o){return o.classList.contains(ys)})}}function go(e){var t=rt(),n=rt();n.className=xs,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var o=rt();o.className=io,o.setAttribute("data-state","hidden"),Dn(o,e.props),t.appendChild(n),n.appendChild(o),r(e.props,e.props);function r(a,s){var c=Xt(t),l=c.box,d=c.content,p=c.arrow;s.theme?l.setAttribute("data-theme",s.theme):l.removeAttribute("data-theme"),typeof s.animation=="string"?l.setAttribute("data-animation",s.animation):l.removeAttribute("data-animation"),s.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof s.maxWidth=="number"?s.maxWidth+"px":s.maxWidth,s.role?l.setAttribute("role",s.role):l.removeAttribute("role"),(a.content!==s.content||a.allowHTML!==s.allowHTML)&&Dn(d,e.props),s.arrow?p?a.arrow!==s.arrow&&(l.removeChild(p),l.appendChild(Pn(s.arrow))):l.appendChild(Pn(s.arrow)):p&&l.removeChild(p)}return{popper:t,onUpdate:r}}go.$$tippy=!0;var Ws=1,Bt=[],Ft=[];function Vs(e,t){var n=Mn(e,Object.assign({},
|
|
10
|
+
`,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var Fs=function(){return"innerHTML"};function Kt(e,t){e[Fs()]=t}function Pn(e){var t=rt();return e===!0?t.className=so:(t.className=lo,st(e)?t.appendChild(e):Kt(t,e)),t}function Dn(e,t){st(t.content)?(Kt(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Kt(e,t.content):e.textContent=t.content)}function Xt(e){var t=e.firstElementChild,n=Rt(t.children);return{box:t,content:n.find(function(o){return o.classList.contains(io)}),arrow:n.find(function(o){return o.classList.contains(so)||o.classList.contains(lo)}),backdrop:n.find(function(o){return o.classList.contains(ys)})}}function go(e){var t=rt(),n=rt();n.className=xs,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var o=rt();o.className=io,o.setAttribute("data-state","hidden"),Dn(o,e.props),t.appendChild(n),n.appendChild(o),r(e.props,e.props);function r(a,s){var c=Xt(t),l=c.box,d=c.content,p=c.arrow;s.theme?l.setAttribute("data-theme",s.theme):l.removeAttribute("data-theme"),typeof s.animation=="string"?l.setAttribute("data-animation",s.animation):l.removeAttribute("data-animation"),s.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof s.maxWidth=="number"?s.maxWidth+"px":s.maxWidth,s.role?l.setAttribute("role",s.role):l.removeAttribute("role"),(a.content!==s.content||a.allowHTML!==s.allowHTML)&&Dn(d,e.props),s.arrow?p?a.arrow!==s.arrow&&(l.removeChild(p),l.appendChild(Pn(s.arrow))):l.appendChild(Pn(s.arrow)):p&&l.removeChild(p)}return{popper:t,onUpdate:r}}go.$$tippy=!0;var Ws=1,Bt=[],Ft=[];function Vs(e,t){var n=Mn(e,Object.assign({},oe,bo(Tn(t)))),o,r,a,s=!1,c=!1,l=!1,d=!1,p,x,h,b=[],f=Cn(bt,n.interactiveDebounce),g,L=Ws++,k=null,M=Ls(n.plugins),C={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},u={id:L,reference:e,popper:rt(),popperInstance:k,props:n,state:C,plugins:M,clearDelayTimeouts:yt,setProps:wt,setContent:kt,show:No,hide:Ho,hideWithInteractivity:$o,enable:Je,disable:xt,unmount:zo,destroy:qo};if(!n.render)return process.env.NODE_ENV!=="production"&&Yt(!0,"render() function has not been supplied."),u;var j=n.render(u),w=j.popper,S=j.onUpdate;w.setAttribute("data-tippy-root",""),w.id="tippy-"+u.id,u.popper=w,e._tippy=u,w._tippy=u;var P=M.map(function(y){return y.fn(u)}),R=e.hasAttribute("aria-expanded");return X(),N(),F(),U("onCreate",[u]),n.showOnCreate&&Xe(),w.addEventListener("mouseenter",function(){u.props.interactive&&u.state.isVisible&&u.clearDelayTimeouts()}),w.addEventListener("mouseleave",function(){u.props.interactive&&u.props.trigger.indexOf("mouseenter")>=0&&_().addEventListener("mousemove",f)}),u;function B(){var y=u.props.touch;return Array.isArray(y)?y:[y,0]}function v(){return B()[0]==="hold"}function T(){var y;return!!((y=u.props.render)!=null&&y.$$tippy)}function A(){return g||e}function _(){var y=A().parentNode;return y?Ms(y):document}function H(){return Xt(w)}function z(y){return u.state.isMounted&&!u.state.isVisible||pe.isTouch||p&&p.type==="focus"?0:zt(u.props.delay,y?0:1,oe.delay)}function F(y){y===void 0&&(y=!1),w.style.pointerEvents=u.props.interactive&&!y?"":"none",w.style.zIndex=""+u.props.zIndex}function U(y,D,O){if(O===void 0&&(O=!0),P.forEach(function($){$[y]&&$[y].apply($,D)}),O){var q;(q=u.props)[y].apply(q,D)}}function I(){var y=u.props.aria;if(y.content){var D="aria-"+y.content,O=w.id,q=qe(u.props.triggerTarget||e);q.forEach(function($){var J=$.getAttribute(D);if(u.state.isVisible)$.setAttribute(D,J?J+" "+O:O);else{var se=J&&J.replace(O,"").trim();se?$.setAttribute(D,se):$.removeAttribute(D)}})}}function N(){if(!(R||!u.props.aria.expanded)){var y=qe(u.props.triggerTarget||e);y.forEach(function(D){u.props.interactive?D.setAttribute("aria-expanded",u.state.isVisible&&D===A()?"true":"false"):D.removeAttribute("aria-expanded")})}}function W(){_().removeEventListener("mousemove",f),Bt=Bt.filter(function(y){return y!==f})}function V(y){if(!(pe.isTouch&&(l||y.type==="mousedown"))){var D=y.composedPath&&y.composedPath()[0]||y.target;if(!(u.props.interactive&&An(w,D))){if(qe(u.props.triggerTarget||e).some(function(O){return An(O,D)})){if(pe.isTouch||u.state.isVisible&&u.props.trigger.indexOf("click")>=0)return}else U("onClickOutside",[u,y]);u.props.hideOnClick===!0&&(u.clearDelayTimeouts(),u.hide(),c=!0,setTimeout(function(){c=!1}),u.state.isMounted||ne())}}}function K(){l=!0}function Q(){l=!1}function G(){var y=_();y.addEventListener("mousedown",V,!0),y.addEventListener("touchend",V,Pe),y.addEventListener("touchstart",Q,Pe),y.addEventListener("touchmove",K,Pe)}function ne(){var y=_();y.removeEventListener("mousedown",V,!0),y.removeEventListener("touchend",V,Pe),y.removeEventListener("touchstart",Q,Pe),y.removeEventListener("touchmove",K,Pe)}function ve(y,D){ke(y,function(){!u.state.isVisible&&w.parentNode&&w.parentNode.contains(w)&&D()})}function ie(y,D){ke(y,D)}function ke(y,D){var O=H().box;function q($){$.target===O&&(Ut(O,"remove",q),D())}if(y===0)return D();Ut(O,"remove",x),Ut(O,"add",q),x=q}function de(y,D,O){O===void 0&&(O=!1);var q=qe(u.props.triggerTarget||e);q.forEach(function($){$.addEventListener(y,D,O),b.push({node:$,eventType:y,handler:D,options:O})})}function X(){v()&&(de("touchstart",Ge,{passive:!0}),de("touchend",vt,{passive:!0})),Cs(u.props.trigger).forEach(function(y){if(y!=="manual")switch(de(y,Ge),y){case"mouseenter":de("mouseleave",vt);break;case"focus":de(Es?"focusout":"blur",Ye);break;case"focusin":de("focusout",Ye);break}})}function ht(){b.forEach(function(y){var D=y.node,O=y.eventType,q=y.handler,$=y.options;D.removeEventListener(O,q,$)}),b=[]}function Ge(y){var D,O=!1;if(!(!u.state.isEnabled||Ke(y)||c)){var q=((D=p)==null?void 0:D.type)==="focus";p=y,g=y.currentTarget,N(),!u.state.isVisible&&As(y)&&Bt.forEach(function($){return $(y)}),y.type==="click"&&(u.props.trigger.indexOf("mouseenter")<0||s)&&u.props.hideOnClick!==!1&&u.state.isVisible?O=!0:Xe(y),y.type==="click"&&(s=!O),O&&!q&&je(y)}}function bt(y){var D=y.target,O=A().contains(D)||w.contains(D);if(!(y.type==="mousemove"&&O)){var q=Ce().concat(w).map(function($){var J,se=$._tippy,Ne=(J=se.popperInstance)==null?void 0:J.state;return Ne?{popperRect:$.getBoundingClientRect(),popperState:Ne,props:n}:null}).filter(Boolean);Ps(q,y)&&(W(),je(y))}}function vt(y){var D=Ke(y)||u.props.trigger.indexOf("click")>=0&&s;if(!D){if(u.props.interactive){u.hideWithInteractivity(y);return}je(y)}}function Ye(y){u.props.trigger.indexOf("focusin")<0&&y.target!==A()||u.props.interactive&&y.relatedTarget&&w.contains(y.relatedTarget)||je(y)}function Ke(y){return pe.isTouch?v()!==y.type.indexOf("touch")>=0:!1}function gt(){mt();var y=u.props,D=y.popperOptions,O=y.placement,q=y.offset,$=y.getReferenceClientRect,J=y.moveTransition,se=T()?Xt(w).arrow:null,Ne=$?{getBoundingClientRect:$,contextElement:$.contextElement||A()}:e,dn={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Ct){var He=Ct.state;if(T()){var Uo=H(),$t=Uo.box;["placement","reference-hidden","escaped"].forEach(function(Lt){Lt==="placement"?$t.setAttribute("data-placement",He.placement):He.attributes.popper["data-popper-"+Lt]?$t.setAttribute("data-"+Lt,""):$t.removeAttribute("data-"+Lt)}),He.attributes.popper={}}}},Se=[{name:"offset",options:{offset:q}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!J}},dn];T()&&se&&Se.push({name:"arrow",options:{element:se,padding:3}}),Se.push.apply(Se,(D==null?void 0:D.modifiers)||[]),u.popperInstance=ms(Ne,w,Object.assign({},D,{placement:O,onFirstUpdate:h,modifiers:Se}))}function mt(){u.popperInstance&&(u.popperInstance.destroy(),u.popperInstance=null)}function ge(){var y=u.props.appendTo,D,O=A();u.props.interactive&&y===co||y==="parent"?D=O.parentNode:D=uo(y,[O]),D.contains(w)||D.appendChild(w),u.state.isMounted=!0,gt(),process.env.NODE_ENV!=="production"&&me(u.props.interactive&&y===oe.appendTo&&O.nextElementSibling!==w,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",`
|
|
11
11
|
|
|
12
12
|
`,"Using a wrapper <div> or <span> tag around the reference element","solves this by creating a new parentNode context.",`
|
|
13
13
|
|
|
14
14
|
`,"Specifying `appendTo: document.body` silences this warning, but it","assumes you are using a focus management solution to handle","keyboard navigation.",`
|
|
15
15
|
|
|
16
|
-
`,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function
|
|
16
|
+
`,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function Ce(){return Rt(w.querySelectorAll("[data-tippy-root]"))}function Xe(y){u.clearDelayTimeouts(),y&&U("onTrigger",[u,y]),G();var D=z(!0),O=B(),q=O[0],$=O[1];pe.isTouch&&q==="hold"&&$&&(D=$),D?o=setTimeout(function(){u.show()},D):u.show()}function je(y){if(u.clearDelayTimeouts(),U("onUntrigger",[u,y]),!u.state.isVisible){ne();return}if(!(u.props.trigger.indexOf("mouseenter")>=0&&u.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(y.type)>=0&&s)){var D=z(!1);D?r=setTimeout(function(){u.state.isVisible&&u.hide()},D):a=requestAnimationFrame(function(){u.hide()})}}function Je(){u.state.isEnabled=!0}function xt(){u.hide(),u.state.isEnabled=!1}function yt(){clearTimeout(o),clearTimeout(r),cancelAnimationFrame(a)}function wt(y){if(process.env.NODE_ENV!=="production"&&me(u.state.isDestroyed,ze("setProps")),!u.state.isDestroyed){U("onBeforeUpdate",[u,y]),ht();var D=u.props,O=Mn(e,Object.assign({},D,Tn(y),{ignoreAttributes:!0}));u.props=O,X(),D.interactiveDebounce!==O.interactiveDebounce&&(W(),f=Cn(bt,O.interactiveDebounce)),D.triggerTarget&&!O.triggerTarget?qe(D.triggerTarget).forEach(function(q){q.removeAttribute("aria-expanded")}):O.triggerTarget&&e.removeAttribute("aria-expanded"),N(),F(),S&&S(D,O),u.popperInstance&&(gt(),Ce().forEach(function(q){requestAnimationFrame(q._tippy.popperInstance.forceUpdate)})),U("onAfterUpdate",[u,y])}}function kt(y){u.setProps({content:y})}function No(){process.env.NODE_ENV!=="production"&&me(u.state.isDestroyed,ze("show"));var y=u.state.isVisible,D=u.state.isDestroyed,O=!u.state.isEnabled,q=pe.isTouch&&!u.props.touch,$=zt(u.props.duration,0,oe.duration);if(!(y||D||O||q)&&!A().hasAttribute("disabled")&&(U("onShow",[u],!1),u.props.onShow(u)!==!1)){if(u.state.isVisible=!0,T()&&(w.style.visibility="visible"),F(),G(),u.state.isMounted||(w.style.transition="none"),T()){var J=H(),se=J.box,Ne=J.content;qt([se,Ne],0)}h=function(){var Se;if(!(!u.state.isVisible||d)){if(d=!0,w.offsetHeight,w.style.transition=u.props.moveTransition,T()&&u.props.animation){var Ht=H(),Ct=Ht.box,He=Ht.content;qt([Ct,He],$),Bn([Ct,He],"visible")}I(),N(),Ln(Ft,u),(Se=u.popperInstance)==null||Se.forceUpdate(),U("onMount",[u]),u.props.animation&&T()&&ie($,function(){u.state.isShown=!0,U("onShown",[u])})}},ge()}}function Ho(){process.env.NODE_ENV!=="production"&&me(u.state.isDestroyed,ze("hide"));var y=!u.state.isVisible,D=u.state.isDestroyed,O=!u.state.isEnabled,q=zt(u.props.duration,1,oe.duration);if(!(y||D||O)&&(U("onHide",[u],!1),u.props.onHide(u)!==!1)){if(u.state.isVisible=!1,u.state.isShown=!1,d=!1,s=!1,T()&&(w.style.visibility="hidden"),W(),ne(),F(!0),T()){var $=H(),J=$.box,se=$.content;u.props.animation&&(qt([J,se],q),Bn([J,se],"hidden"))}I(),N(),u.props.animation?T()&&ve(q,u.unmount):u.unmount()}}function $o(y){process.env.NODE_ENV!=="production"&&me(u.state.isDestroyed,ze("hideWithInteractivity")),_().addEventListener("mousemove",f),Ln(Bt,f),f(y)}function zo(){process.env.NODE_ENV!=="production"&&me(u.state.isDestroyed,ze("unmount")),u.state.isVisible&&u.hide(),u.state.isMounted&&(mt(),Ce().forEach(function(y){y._tippy.unmount()}),w.parentNode&&w.parentNode.removeChild(w),Ft=Ft.filter(function(y){return y!==u}),u.state.isMounted=!1,U("onHidden",[u]))}function qo(){process.env.NODE_ENV!=="production"&&me(u.state.isDestroyed,ze("destroy")),!u.state.isDestroyed&&(u.clearDelayTimeouts(),u.unmount(),ht(),delete e._tippy,u.state.isDestroyed=!0,U("onDestroy",[u]))}}function Be(e,t){t===void 0&&(t={});var n=oe.plugins.concat(t.plugins||[]);process.env.NODE_ENV!=="production"&&(Hs(e),vo(t,n)),Rs();var o=Object.assign({},t,{plugins:n}),r=Ss(e);if(process.env.NODE_ENV!=="production"){var a=st(o.content),s=r.length>1;me(a&&s,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.",`
|
|
17
17
|
|
|
18
18
|
`,"Instead, pass the .innerHTML of the element, or use a function that","returns a cloned version of the element instead.",`
|
|
19
19
|
|
|
20
20
|
`,`1) content: element.innerHTML
|
|
21
|
-
`,"2) content: () => element.cloneNode(true)"].join(" "))}var c=r.reduce(function(l,d){var p=d&&Vs(d,o);return p&&l.push(p),l},[]);return st(e)?c[0]:c}
|
|
21
|
+
`,"2) content: () => element.cloneNode(true)"].join(" "))}var c=r.reduce(function(l,d){var p=d&&Vs(d,o);return p&&l.push(p),l},[]);return st(e)?c[0]:c}Be.defaultProps=oe;Be.setDefaultProps=qs;Be.currentInput=pe;Object.assign({},Zn,{effect:function(t){var n=t.state,o={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,o.popper),n.styles=o,n.elements.arrow&&Object.assign(n.elements.arrow.style,o.arrow)}});Be.setDefaultProps({render:go});const E={colors:{background:"var(--pubwave-color-background)",surface:"var(--pubwave-color-surface)",text:"var(--pubwave-color-text)",textMuted:"var(--pubwave-color-text-muted)",border:"var(--pubwave-color-border)",borderLight:"var(--pubwave-color-border-light)",hover:"var(--pubwave-color-hover)",focus:"var(--pubwave-color-focus)",selection:"var(--pubwave-color-selection)",selectionBg:"var(--pubwave-color-selection-bg)",primary:"var(--pubwave-color-primary)",primaryFaded:"var(--pubwave-color-primary-faded)",dropIndicator:"var(--pubwave-color-drop-indicator)",dropTarget:"var(--pubwave-color-drop-target)",error:"var(--pubwave-color-error)"},spacing:{xs:"var(--pubwave-spacing-xs)",sm:"var(--pubwave-spacing-sm)",md:"var(--pubwave-spacing-md)",lg:"var(--pubwave-spacing-lg)",xl:"var(--pubwave-spacing-xl)",blockPaddingX:"var(--pubwave-block-padding-x)",blockPaddingY:"var(--pubwave-block-padding-y)",blockMarginY:"var(--pubwave-block-margin-y)",toolbarGap:"var(--pubwave-toolbar-gap)"},typography:{fontFamily:"var(--pubwave-font-family)",fontSizeBase:"var(--pubwave-font-size-base)",fontSizeSmall:"var(--pubwave-font-size-small)",lineHeightBase:"var(--pubwave-line-height-base)",lineHeightHeading:"var(--pubwave-line-height-heading)",fontWeightNormal:"var(--pubwave-font-weight-normal)",fontWeightMedium:"var(--pubwave-font-weight-medium)",fontWeightBold:"var(--pubwave-font-weight-bold)",fontWeightHeading:"var(--pubwave-font-weight-heading)"},borderRadius:{sm:"var(--pubwave-border-radius-sm)",md:"var(--pubwave-border-radius)",lg:"var(--pubwave-border-radius-large)"},shadow:{sm:"var(--pubwave-shadow-sm)",md:"var(--pubwave-shadow-md)",toolbar:"var(--pubwave-shadow-toolbar)",popup:"var(--pubwave-shadow-popup)"},transition:{fast:"var(--pubwave-transition-fast)",normal:"var(--pubwave-transition-normal)"},zIndex:{dragPreview:100,dragHandle:40,toolbar:50,dropdown:60}},Gs=`
|
|
22
22
|
:root {
|
|
23
23
|
/* Colors - Light theme */
|
|
24
24
|
--pubwave-color-background: #ffffff;
|
|
@@ -100,4 +100,4 @@
|
|
|
100
100
|
--pubwave-color-error: #f87171;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
`,Ys=Gs;function Oe(...e){return e.filter(Boolean).join(" ")}const St={padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px) var(--pubwave-spacing-1, 4px)",fontSize:"var(--pubwave-font-size-xs, 11px)",fontWeight:600,color:"var(--pubwave-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"};function mo(e=Dt,t,n){var a;const o=t||n?Kn(t,n):e,r=((a=n==null?void 0:n.slashMenu)==null?void 0:a.groups)||{basic:"Style",list:"Lists",media:"Media",advanced:"Advanced",layout:"Layout"};return oe.Extension.create({name:"slashCommands",addOptions(){return{suggestion:{char:"/",command:({editor:s,range:c,props:l})=>{if(l.id==="taskList"){s.chain().focus().deleteRange(c).toggleTaskList().run();return}s.chain().focus().deleteRange(c).run(),l.action(s)}}}},addProseMirrorPlugins(){const s=this.editor;return[br({editor:this.editor,...this.options.suggestion,allowed:({state:c,range:l})=>{try{if(s.isActive("codeBlock"))return!1;const d=c.doc.resolve(l.from);for(let p=d.depth;p>=1;p--)if(d.node(p).type.name==="codeBlock")return!1;return!0}catch{return!0}},items:({query:c,state:l})=>{let d=o;try{const p=l.doc.resolve(l.selection.from);for(let x=p.depth;x>=0;x--)if(p.node(x).type.name==="layoutColumn"){d=o.filter(b=>b.group!=="layout");break}}catch{}return fi(d,c)},render:()=>{let c,l;return{onStart:d=>{this.editor.isActive("codeBlock")||(c=new xe.ReactRenderer(xo,{props:{...d,query:d.query,editor:this.editor,groupLabels:r},editor:this.editor}),d.clientRect&&(l=Te("body",{getReferenceClientRect:d.clientRect,appendTo:()=>document.body,content:c.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",offset:[0,8],zIndex:E.zIndex.dropdown,arrow:!1,duration:[0,0],animation:!1,popperOptions:{modifiers:[{name:"preventOverflow",options:{boundary:"viewport",padding:8,altAxis:!0}},{name:"flip",options:{fallbackPlacements:["top-start","bottom-end","top"]}}]},onShow(p){const x=p.popper.querySelector(".tippy-box");x&&(x.style.zIndex=String(E.zIndex.dropdown),x.style.backgroundColor="transparent",x.style.background="transparent",x.style.border="none");const h=p.popper.querySelector(".pubwave-slash-menu");if(h){const b=document.querySelector(".ProseMirror");if(b){const f=h.getBoundingClientRect(),L=b.getBoundingClientRect().bottom-f.top-16,k=Math.max(200,Math.min(280,L));h.style.maxHeight=`${k}px`}}}})))},onUpdate(d){var p,x,h;if(c.updateProps({...d,query:d.query,editor:d.editor,groupLabels:r}),d.items.length===0){if(l[0]){l[0].hide();const b=l[0].popper.querySelector(".tippy-box");b&&(b.style.opacity="0",b.style.pointerEvents="none")}return}d.clientRect&&((p=l[0])==null||p.setProps({getReferenceClientRect:d.clientRect}),(x=l[0])!=null&&x.state.isVisible||(h=l[0])==null||h.show())},onKeyDown(d){var p,x;return d.event.key==="Escape"?((p=l[0])==null||p.hide(),!0):((x=c.ref)==null?void 0:x.onKeyDown(d))??!1},onExit(){var d;(d=l[0])==null||d.destroy(),c.destroy()}}}})]}})}const xo=m.forwardRef(function({items:t,command:n,query:o="",groupLabels:r},a){const[s,c]=m.useState(-1),l=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{t.length>0&&o.length>0?c(0):(t.length,c(-1))},[t,o]),Ha(s,l,d);const p=m.useMemo(()=>{const f={};for(const g of t){const L=f[g.group]??[];L.push(g),f[g.group]=L}return f},[t]),x=t,h=m.useCallback(f=>{const g=x[f];g&&n(g)},[x,n]);m.useImperativeHandle(a,()=>({onKeyDown:({event:f})=>x.length===0?!1:f.key==="ArrowUp"?(c(g=>g<0?x.length-1:g<=0?0:g-1),!0):f.key==="ArrowDown"?(c(g=>g<0?0:g>=x.length-1?x.length-1:g+1),!0):f.key==="Enter"&&s>=0&&s<x.length?(h(s),!0):!1}));const b=r||{basic:"Style",list:"Lists",media:"Media",advanced:"Advanced"};return t.length===0?null:i.jsx("div",{className:"pubwave-slash-menu",ref:l,style:$a,"data-testid":"slash-menu",children:i.jsx("div",{style:{padding:"var(--pubwave-spacing-1, 4px) 0"},children:(()=>{let f=0;return["basic","list","media","advanced"].map(L=>{const k=p[L];return!k||k.length===0?null:i.jsxs("div",{className:"pubwave-slash-menu__group",style:za,children:[i.jsx("div",{className:"pubwave-slash-menu__group-label",style:qa,children:b[L]||L}),k.map(M=>{const C=f++,u=C===s;return i.jsxs("button",{ref:u?d:null,className:`pubwave-slash-menu__item ${u?"pubwave-slash-menu__item--selected":""}`,style:{...Ua,backgroundColor:u?"var(--pubwave-hover-bg, #f3f4f6)":"transparent"},onClick:()=>h(C),onMouseEnter:()=>c(C),children:[i.jsx("span",{className:"pubwave-slash-menu__item-icon",style:Fa,children:M.icon}),i.jsx("span",{className:"pubwave-slash-menu__item-title",style:Wa,children:M.title})]},M.id)})]},L)})})()})})}),Z=new Pt.PluginKey("pubwave-dnd"),Ot={draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null,cancelled:!1};function Pe(e,t){switch(t.type){case"START_DRAG":return{...e,draggingBlockId:t.blockId,draggingBlockPos:t.pos,dropTargetPos:null,dropPosition:null,cancelled:!1};case"UPDATE_DROP_TARGET":return{...e,dropTargetPos:t.pos,dropPosition:t.position};case"CANCEL_DRAG":return{...e,cancelled:!0,draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null};case"COMPLETE_DRAG":return{...e,draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null};case"RESET":return Ot;default:return e}}function ct(e,t){const n=Math.max(0,Math.min(t,e.content.size));try{const o=e.resolve(n);if(o.depth>=1){const r=o.node(1);if(["taskList","bulletList","orderedList","blockquote"].includes(r.type.name))return{node:r,pos:o.before(1)}}for(let r=o.depth;r>0;r--){const a=o.node(r);if(a.isBlock)return{node:a,pos:o.before(r)}}if(o.depth===0&&e.childCount>0){let r=0;for(let a=0;a<e.childCount;a++){const s=e.child(a);if(r+s.nodeSize>n)return{node:s,pos:r};r+=s.nodeSize}return{node:e.lastChild,pos:e.content.size-e.lastChild.nodeSize}}return null}catch{let o=null,r=0;for(let a=0;a<e.childCount;a++){const s=e.child(a);if(r<=n&&r+s.nodeSize>n){o={node:s,pos:r};break}r+=s.nodeSize}return o}}function yo(e,t,n,o){const{state:r}=e,{tr:a,doc:s}=r,c=ct(s,t);if(!c)return!1;const l=ct(s,n);if(!l)return!1;let d=l.pos;if(o==="after"&&(d=l.pos+l.node.nodeSize),c.pos===l.pos||d===c.pos||d===c.pos+c.node.nodeSize)return!1;const p=c.node,x=c.pos,h=c.pos+p.nodeSize,b=s.slice(x,h);let f=d;x<d&&(f=d-p.nodeSize),a.delete(x,h);const g=a.doc.content.size;if(f<0?f=0:f>g&&(f=g),f>=0&&f<=g)a.insert(f,b.content);else return!1;return a.setSelection(r.selection.map(a.doc,a.mapping)),e.view.dispatch(a),!0}function In(e,t){const n=e.state.doc;if(n.childCount===0)return null;const o=0,r=e.nodeDOM(o);let a=0;for(let d=0;d<n.childCount-1;d++)a+=n.child(d).nodeSize;const s=e.nodeDOM(a),c=t.clientY;if(r){const d=r.getBoundingClientRect();if(c<d.top+50)return{pos:o,position:"before"}}if(s){const d=s.getBoundingClientRect();if(c>d.bottom-50)return{pos:a,position:"after"}}const l=e.posAtCoords({left:t.clientX,top:t.clientY});if(l){const d=ct(n,l.pos);if(d){const p=e.nodeDOM(d.pos);if(p){const x=p.getBoundingClientRect(),h=x.top+x.height/2;return{pos:d.pos,position:c<h?"before":"after"}}}}return null}function wo(e){let t=Ot;return new Pt.Plugin({key:Z,state:{init(){return Ot},apply(n,o){const r=n.getMeta(Z);return r!==void 0?(t=r,r):(t=o,o)}},props:{handleKeyDown(n,o){return o.key==="Escape"&&t.draggingBlockId?(t=Pe(t,{type:"CANCEL_DRAG"}),n.dispatch(n.state.tr.setMeta(Z,t)),!0):!1},handleDOMEvents:{dragover(n,o){var s;if(!((s=o.dataTransfer)!=null&&s.types.includes("application/x-pubwave-block")))return!1;o.preventDefault(),o.dataTransfer.dropEffect="move",t=Z.getState(n.state)??t;const a=In(n,o);return a?(t=Pe(t,{type:"UPDATE_DROP_TARGET",pos:a.pos,position:a.position}),n.dispatch(n.state.tr.setMeta(Z,t))):t.dropTargetPos!==null&&(t=Pe(t,{type:"UPDATE_DROP_TARGET",pos:null,position:null}),n.dispatch(n.state.tr.setMeta(Z,t))),!0},drop(n,o){var h;const r=(h=o.dataTransfer)==null?void 0:h.getData("application/x-pubwave-block");if(!r)return!1;o.preventDefault(),o.stopPropagation();let c=(Z.getState(n.state)??t).draggingBlockPos;if(c===null&&r.startsWith("block-")){const b=parseInt(r.replace("block-",""),10);isNaN(b)||(c=b)}if(c===null)return!1;const l=In(n,o);if(!l)return!1;const{pos:d,position:p}=l;if(d===c||!e)return!1;const x=yo(e,c,d,p);return t=Pe(t,{type:"COMPLETE_DRAG"}),n.dispatch(n.state.tr.setMeta(Z,t)),x},dragleave(n,o){const r=o.relatedTarget;return r!=null&&r.closest(".pubwave-editor")||(t=Pe(t,{type:"UPDATE_DROP_TARGET",pos:null,position:null}),n.dispatch(n.state.tr.setMeta(Z,t))),!1}}}})}function sn(e){return Z.getState(e.state)??Ot}function ko(e,t,n){const{view:o}=e,r={type:"START_DRAG",blockId:t,pos:n},a=Pe(sn(e),r);o.dispatch(o.state.tr.setMeta(Z,a))}function Ks(e){const{view:t}=e,n={type:"CANCEL_DRAG"},o=Pe(sn(e),n);t.dispatch(t.state.tr.setMeta(Z,o))}const Xs=["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock","horizontalRule","image","chart"],Js=["bold","italic","underline","strike","code","link"];function ln(e={}){const{placeholder:t,historyDepth:n=100,headingLevels:o,linkOpenInNewTab:r,linkOpenOnClick:a,enableSlashCommands:s=!0,slashCommands:c,imageUpload:l,locale:d}=e,p=d?At(d):null,x=t??(p==null?void 0:p.placeholder)??'Write,type "/" for commands...',h=[...Oa({headingLevels:o,imageUpload:l}),...Na({linkOpenInNewTab:r,linkOpenOnClick:a}),Fo.configure({placeholder:x,emptyEditorClass:"pubwave-editor--empty",emptyNodeClass:"pubwave-editor__node--empty"}),Wo.configure({depth:n}),Vo.configure({color:"var(--pubwave-dropcursor-color, #3b82f6)",width:2}),Go,oe.Extension.create({name:"dragAndDrop",addProseMirrorPlugins(){return[wo(this.editor)]}})];if(s){const b=At(d||"en"),f=c?[...Dt,...c]:Dt;h.push(mo(f,l,b))}return h}function Zs(e={}){if(!_t)throw new Error("createEditor() cannot be called server-side. Ensure this function is only called in client-side code (e.g., useEffect, event handlers).");const{content:t,editable:n=!0,placeholder:o,autofocus:r=!1,onUpdate:a,onSelectionUpdate:s,onFocus:c,onBlur:l,onCreate:d,onDestroy:p}=e,h={extensions:ln({placeholder:o,headingLevels:[1,2,3],linkOpenInNewTab:!0,linkOpenOnClick:!0}),content:t,editable:n,autofocus:r,editorProps:{attributes:{class:"pubwave-editor__content","data-placeholder":o??'Write,type "/" for commands...'}},onUpdate:a?({editor:b})=>{a({editor:b})}:void 0,onSelectionUpdate:s?({editor:b})=>{s({editor:b})}:void 0,onFocus:c?({editor:b})=>{c({editor:b})}:void 0,onBlur:l?({editor:b})=>{l({editor:b})}:void 0,onCreate:d?({editor:b})=>{d({editor:b})}:void 0,onDestroy:p?()=>{p()}:void 0};return new oe.Editor(h)}function Qs(e){e&&!e.isDestroyed&&e.destroy()}function el(e){return e!==null&&!e.isDestroyed}function cn(e){const{state:t}=e,{selection:n}=t,{from:o,to:r,empty:a}=n,s=a?"":t.doc.textBetween(o,r," "),c=n instanceof Object&&"node"in n,l=s.length>0,d=e.isActive("bold"),p=e.isActive("italic"),x=e.isActive("underline"),h=e.isActive("strike"),b=e.isActive("code"),f=e.isActive("link"),g=f?e.getAttributes("link").href:null;return{hasSelection:!a||c,isEmpty:a&&!c,hasTextContent:l,isNodeSelection:c,selectedText:s,from:o,to:r,isBold:d,isItalic:p,isUnderline:x,isStrike:h,isCode:b,hasLink:f,linkHref:g}}function tl(e){return e.state.selection.empty}function Mt(e){const t=cn(e);return t.isEmpty?!1:!!t.hasTextContent}function nl(e){if(typeof window>"u")return null;const{view:t}=e,{from:n,to:o}=t.state.selection;if(n===o)return null;const r=t.coordsAtPos(n),a=t.coordsAtPos(o),s=Math.min(r.top,a.top),c=Math.max(r.bottom,a.bottom),l=Math.min(r.left,a.left),d=Math.max(r.right,a.right);return{top:s,left:l,right:d,bottom:c,width:d-l,height:c-s}}function ol(e){return e.chain().focus().toggleBold().run()}function rl(e){return e.chain().focus().toggleItalic().run()}function al(e,t){return t?e.chain().focus().setLink({href:t}).run():e.chain().focus().unsetLink().run()}function il(e){return e.chain().focus().unsetLink().run()}function sl(e){return e.chain().focus().setParagraph().run()}function ll(e,t){return e.chain().focus().setHeading({level:t}).run()}function cl(e,t){return e.chain().focus().toggleHeading({level:t}).run()}function ul(e){return e.chain().focus().undo().run()}function dl(e){return e.chain().focus().redo().run()}function pl(e,t){return e.chain().focus(t).run()}function fl(e){return e.chain().focus().selectAll().run()}function hl(e){return e.chain().focus().unsetAllMarks().run()}function bl(e,t){return e.isActive(t)}function vl(e,t,n){return e.isActive(t,n)}function gl(e){const t=[];return e.isActive("bold")&&t.push("bold"),e.isActive("italic")&&t.push("italic"),e.isActive("link")&&t.push("link"),t}function ml(e){return e.getAttributes("link").href??null}function Co(e){return e?!e.isEditable:!0}function ft(e){return e?e.isEditable:!1}function xl(e){return ft(e)}function yl(e){return ft(e)}function wl(e){return ft(e)}function kl(e){return ft(e)}function Cl(e){return Co(e)?"pubwave-editor--readonly":""}const Et={editor:"Rich text editor",toolbar:"Text formatting toolbar",dragHandle:"Drag to reorder block"},Qe={bold:"Cmd+B",italic:"Cmd+I",underline:"Cmd+U",strike:"Cmd+Shift+X",code:"Cmd+E"};function Ce(e,t){return t?`${e} (${t})`:e}const me=m.forwardRef(({active:e=!1,disabled:t=!1,onClick:n,"data-tooltip":o,"data-testid":r,"aria-label":a,children:s,style:c},l)=>i.jsx("button",{ref:l,type:"button",className:Oe("pubwave-toolbar__button",e&&"pubwave-toolbar__button--active",t&&"pubwave-toolbar__button--disabled"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:(c==null?void 0:c.width)??"var(--pubwave-button-width, 28px)",height:(c==null?void 0:c.height)??"var(--pubwave-button-height, 28px)",minWidth:c==null?void 0:c.minWidth,padding:(c==null?void 0:c.padding)??0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:e?"var(--pubwave-primary)":"var(--pubwave-text)",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,transition:"color 0.1s ease, background-color 0.1s ease",...c},onClick:d=>{d.preventDefault(),d.stopPropagation(),n()},disabled:t,"data-tooltip":o,"data-testid":r,"aria-label":a,"aria-pressed":e,onMouseDown:d=>{d.preventDefault(),d.stopPropagation()},children:s}));me.displayName="ToolbarButton";function Rn(){return i.jsx("div",{className:"pubwave-toolbar__divider",style:{width:"var(--pubwave-divider-width, 1px)",height:"var(--pubwave-divider-height, 20px)",backgroundColor:"var(--pubwave-border)",margin:"0 var(--pubwave-spacing-1, 4px)"},role:"separator","aria-orientation":"vertical"})}function Lo(e,t,n,o=8){const r=e,a=window.innerHeight-t,s=n+o;return r>=s?"top":a>=s?"bottom":r>=a?"top":"bottom"}function Ll(e,t,n=8){return Lo(e.top,e.bottom,t,n)}function To(e,t,n,o="left",r=8){const a=window.innerWidth,s=(e+t)/2,c=e,l=a-t,d=n+r,p=n+r,x=n/2+r;let h=o,b;return o==="left"?(b=e,(b<r||b+n>a-r)&&(l>=p&&t+n<=a-r?(h="right",b=t-n):c>=x&&s-n/2>=r?(h="center",b=s-n/2):(l>=c?(h="right",b=t-n):(h="left",b=e),b=Math.max(r,Math.min(b,a-n-r))))):o==="center"?(b=s-n/2,(b<r||b+n>a-r)&&(l>=p&&t+n<=a-r?(h="right",b=t-n):c>=d&&e+n<=a-r?(h="left",b=e):(l>=c?(h="right",b=t-n):(h="left",b=e),b=Math.max(r,Math.min(b,a-n-r))))):(b=t-n,(b<r||b+n>a-r)&&(c>=d&&e+n<=a-r?(h="left",b=e):c>=x&&s-n/2>=r?(h="center",b=s-n/2):(c>=l?(h="left",b=e):(h="right",b=t-n),b=Math.max(r,Math.min(b,a-n-r))))),b=Math.max(r,Math.min(b,a-n-r)),{align:h,left:b}}function Tl(e,t,n="left",o=8){return To(e.left,e.right,t,n,o)}function un({isOpen:e,buttonRef:t,children:n,className:o,style:r,align:a="left",margin:s=8,onClickOutside:c,onClick:l,"data-testid":d}){const[p,x]=m.useState("top"),[h,b]=m.useState(null),f=m.useRef(null);if(m.useEffect(()=>{if(!e||!t.current)return;const L=()=>{if(!f.current||!t.current)return;const M=t.current.getBoundingClientRect(),C=f.current.offsetHeight||300,u=f.current.offsetWidth||240,S=Ll(M,C,s);x(S);let w=t.current.parentElement;for(;w;){const P=window.getComputedStyle(w);if(P.position==="relative"||P.position==="absolute"||P.position==="fixed")break;w=w.parentElement}const A=Tl(M,u,a,s);if(w){const P=w.getBoundingClientRect(),I=A.left-P.left;b({align:A.align,left:I})}else b(A)};L();const k=requestAnimationFrame(()=>{L()});return()=>cancelAnimationFrame(k)},[e,t,s,a]),m.useEffect(()=>{if(!e||!c)return;const L=k=>{f.current&&!f.current.contains(k.target)&&t.current&&!t.current.contains(k.target)&&c(k)};return document.addEventListener("mousedown",L),()=>{document.removeEventListener("mousedown",L)}},[e,c,t]),!e)return null;const g=()=>{if(h)return{left:`${h.left}px`};switch(a){case"center":return{left:"50%",transform:"translateX(-50%)"};case"right":return{right:0};case"left":default:return{left:0}}};return i.jsx("div",{ref:f,className:o,"data-testid":d,style:{position:"absolute",...p==="top"?{bottom:"100%",marginBottom:`${s}px`}:{top:"100%",marginTop:`${s}px`},...g(),...r},onClick:L=>{L.stopPropagation(),l==null||l(L)},children:n})}function Bl({editor:e,isOpen:t,onToggle:n,onClose:o}){const r=Re(),a=m.useRef(null),s=m.useCallback(()=>e.isActive("heading",{level:1})?"heading1":e.isActive("heading",{level:2})?"heading2":e.isActive("heading",{level:3})?"heading3":e.isActive("bulletList")?"bulletList":e.isActive("orderedList")?"orderedList":e.isActive("taskList")?"taskList":e.isActive("blockquote")?"blockquote":e.isActive("codeBlock")?"codeBlock":"paragraph",[e]),c=m.useMemo(()=>[{id:"paragraph",label:r.toolbar.blockTypes.text,icon:i.jsx(Un,{}),action:h=>h.chain().focus().setParagraph().run(),isActive:h=>h.isActive("paragraph")},{id:"heading1",label:r.toolbar.blockTypes.heading1,icon:i.jsx(Fn,{}),action:h=>h.chain().focus().setHeading({level:1}).run(),isActive:h=>h.isActive("heading",{level:1})},{id:"heading2",label:r.toolbar.blockTypes.heading2,icon:i.jsx(Wn,{}),action:h=>h.chain().focus().setHeading({level:2}).run(),isActive:h=>h.isActive("heading",{level:2})},{id:"heading3",label:r.toolbar.blockTypes.heading3,icon:i.jsx(Vn,{}),action:h=>h.chain().focus().setHeading({level:3}).run(),isActive:h=>h.isActive("heading",{level:3})},{id:"bulletList",label:r.toolbar.blockTypes.bulletedList,icon:i.jsx(Gn,{}),action:h=>h.chain().focus().toggleBulletList().run(),isActive:h=>h.isActive("bulletList")},{id:"orderedList",label:r.toolbar.blockTypes.numberedList,icon:i.jsx(Yn,{}),action:h=>h.chain().focus().toggleOrderedList().run(),isActive:h=>h.isActive("orderedList")}],[r]),l=s(),d=c.find(h=>h.id===l),p=m.useCallback(h=>{h.action(e),o(),setTimeout(()=>{e.chain().blur().run()},0)},[e,o]),x=h=>h===r.toolbar.blockTypes.heading1?r.toolbar.blockTypes.heading1:h===r.toolbar.blockTypes.heading2?r.toolbar.blockTypes.heading2:h===r.toolbar.blockTypes.heading3?r.toolbar.blockTypes.heading3:h===r.toolbar.blockTypes.bulletedList?r.toolbar.blockTypes.bulletedList:h===r.toolbar.blockTypes.numberedList?r.toolbar.blockTypes.numberedList:r.toolbar.blockTypes.text;return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(me,{ref:a,active:t,onClick:n,"data-tooltip":Ce(r.toolbar.turnInto),"data-testid":"toolbar-turnInto","aria-label":r.aria.turnIntoButton,style:{width:"auto",minWidth:"auto",padding:"0 8px",height:"var(--pubwave-button-height, 28px)"},children:i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"4px",whiteSpace:"nowrap"},children:[i.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:d?x(d.label):r.toolbar.blockTypes.text}),i.jsx(Ga,{})]})}),i.jsxs(un,{isOpen:t,buttonRef:a,align:"left",margin:8,onClickOutside:()=>o(),className:"pubwave-turn-into-dropdown","data-testid":"turn-into-dropdown",style:{backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",padding:"var(--pubwave-spacing-1, 4px)",minWidth:"240px",zIndex:E.zIndex.dropdown+1},children:[i.jsx("div",{style:St,children:r.toolbar.turnInto}),c.map(h=>{const b=h.isActive(e);return i.jsxs("button",{type:"button",className:Oe("pubwave-toolbar__turn-into-option",b&&"pubwave-toolbar__turn-into-option--active"),onClick:()=>p(h),style:{width:"100%",display:"flex",alignItems:"center",gap:"var(--pubwave-spacing-2, 8px)",padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px)",border:"none",backgroundColor:b?"var(--pubwave-primary-faded)":"transparent",color:b?"var(--pubwave-primary)":"var(--pubwave-text)",cursor:"pointer",fontSize:"var(--pubwave-font-size-base, 14px)",textAlign:"left",borderRadius:"var(--pubwave-border-radius-sm, 0.25rem)",transition:"background-color 0.1s ease"},children:[i.jsx("span",{style:{display:"flex",alignItems:"center",width:"18px",height:"18px",flexShrink:0},children:h.icon}),i.jsx("span",{children:h.label})]},h.id)})]})]})}function he(e){return!!(e&&!e.isDestroyed)}function Al(e,t){he(e)&&K(()=>{if(he(e))switch(t){case"start":e.commands.focus("start");break;case"end":e.commands.focus("end");break;case"preserve":e.commands.focus();break;default:typeof t=="number"&&(e.commands.setTextSelection(t),e.commands.focus())}})}function Be(e){he(e)&&K(()=>{he(e)&&(e.isFocused||e.commands.focus())})}function jl(e,t){he(e)&&(t.preventDefault(),K(()=>{he(e)&&e.commands.focus()}))}function Sl(e){if(!he(e))return function(){};const t=o=>{const r=o.relatedTarget;if(r){const a=e.view.dom.closest(".pubwave-editor");a&&!a.contains(r)&&r.closest(".pubwave-toolbar, .pubwave-menu, .pubwave-dialog")}},n=e.view.dom;return n.addEventListener("focusout",t),()=>{n.removeEventListener("focusout",t)}}function Bo(e){if(!he(e))return null;const{from:t,to:n,empty:o}=e.state.selection;return{from:t,to:n,empty:o}}function tt(e,t){if(!he(e)||!t)return;const{from:n,to:o}=t,r=e.state.doc.content.size,a=Math.min(n,r),s=Math.min(o,r);e.commands.setTextSelection({from:a,to:s})}function Ml(e){if(!he(e))return;const{selection:t}=e.state;if(t.$anchor.pos>0){e.commands.focus();return}e.commands.focus("end")}function Pl(e){const t=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=t[0],o=t[t.length-1],r=a=>{a.key==="Tab"&&(a.shiftKey?document.activeElement===n&&(a.preventDefault(),o==null||o.focus()):document.activeElement===o&&(a.preventDefault(),n==null||n.focus()))};return{activate(){e.addEventListener("keydown",r),n==null||n.focus()},deactivate(){e.removeEventListener("keydown",r)}}}function Dl({editor:e,isOpen:t,onToggle:n,onClose:o,selectionState:r}){const a=Re(),s=m.useRef(null),c=m.useRef(null),l=m.useRef(null),d=m.useRef([]),p=m.useRef(null),[x,h]=m.useState(""),b=(r==null?void 0:r.hasLink)??!1,f=(r==null?void 0:r.linkHref)??null;m.useEffect(()=>{t?(p.current=Bo(e),h(f||""),setTimeout(()=>{var C,u;(C=c.current)==null||C.focus(),(u=c.current)==null||u.select()},50)):p.current=null},[t,f,e]),m.useEffect(()=>{if(!ut()){if(!t){d.current.forEach(C=>C.destroy()),d.current=[];return}return d.current.forEach(C=>C.destroy()),d.current=[],K(()=>{K(()=>{if(!l.current)return;l.current.querySelectorAll("[data-tooltip]").forEach(u=>{const S=u.getAttribute("data-tooltip");if(S){const w=Te(u,{content:S,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});d.current.push(w)}})})}),()=>{d.current.forEach(C=>C.destroy()),d.current=[]}}},[t,a,x,f]);const g=m.useCallback(C=>{if(C==null||C.preventDefault(),!x.trim()){p.current&&tt(e,p.current),e.chain().focus().unsetLink().run(),p.current&&K(()=>{K(()=>{tt(e,p.current)})}),o();return}let u=x.trim();!/^https?:\/\//i.test(u)&&!u.startsWith("/")&&!u.startsWith("#")&&(u=`https://${u}`),p.current&&tt(e,p.current),e.chain().focus().setLink({href:u}).run(),p.current&&K(()=>{K(()=>{tt(e,p.current)})}),o()},[e,x,o]),L=m.useCallback(()=>{const C=x.trim()||f;if(C){let u=C;!/^https?:\/\//i.test(u)&&!u.startsWith("/")&&!u.startsWith("#")&&(u=`https://${u}`),window.open(u,"_blank","noopener,noreferrer")}},[x,f]),k=m.useCallback(()=>{var C;h(""),(C=c.current)==null||C.focus()},[]),M=m.useCallback(C=>{C.key==="Enter"?(C.preventDefault(),g()):C.key==="Escape"&&(C.preventDefault(),o(),e.chain().focus().run())},[g,o,e]);return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(me,{ref:s,active:b,onClick:n,"data-tooltip":Ce(a.toolbar.link),"data-testid":"toolbar-link","aria-label":a.aria.linkButton,children:i.jsx(Qa,{})}),i.jsx(un,{isOpen:t,buttonRef:s,align:"left",margin:8,onClickOutside:()=>o(),className:"pubwave-link-dropdown",style:{backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",padding:"var(--pubwave-spacing-2, 8px)",minWidth:"280px",zIndex:E.zIndex.dropdown+1},children:i.jsx("div",{ref:l,children:i.jsx("form",{onSubmit:g,style:{display:"flex",flexDirection:"column",gap:"8px"},children:i.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[i.jsx("input",{ref:c,type:"text",value:x,onChange:C=>h(C.target.value),onKeyDown:M,placeholder:a.linkPlaceholder,"data-testid":"link-input","aria-label":a.aria.linkUrlInput,style:{flex:1,padding:"6px 100px 6px 8px",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-sm, 4px)",fontSize:"var(--pubwave-font-size-base, 14px)",backgroundColor:"var(--pubwave-bg)",color:"var(--pubwave-text)",outline:"none"}}),i.jsxs("div",{style:{position:"absolute",right:"4px",display:"flex",alignItems:"center",gap:"2px"},children:[i.jsx("button",{type:"button",onClick:g,"data-tooltip":a.toolbar.confirmLink,"data-testid":"link-confirm-button","aria-label":a.aria.linkConfirmButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent"},children:i.jsx(ti,{})}),(x.trim()||f)&&i.jsx("button",{type:"button",onClick:L,"data-tooltip":a.toolbar.openLink,"data-testid":"link-open-button","aria-label":a.aria.linkOpenButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent"},children:i.jsx(ei,{})}),i.jsx("button",{type:"button",onClick:k,"data-tooltip":a.toolbar.clearLink,"data-testid":"link-clear-button","aria-label":a.aria.linkClearButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent"},children:i.jsx(ni,{})})]})]})})})})]})}const Il=[{name:"Default",value:null,color:"#1f2937"},{name:"Gray",value:"#6b7280",color:"#6b7280"},{name:"Brown",value:"#92400e",color:"#92400e"},{name:"Orange",value:"#ea580c",color:"#ea580c"},{name:"Orange Dark",value:"#c2410c",color:"#c2410c"},{name:"Green",value:"#16a34a",color:"#16a34a"},{name:"Blue",value:"#2563eb",color:"#2563eb"},{name:"Purple",value:"#9333ea",color:"#9333ea"},{name:"Pink",value:"#ec4899",color:"#ec4899"},{name:"Red",value:"#dc2626",color:"#dc2626"}],Rl=[{name:"Default",value:null,color:"#ffffff"},{name:"Gray",value:"#f3f4f6",color:"#f3f4f6"},{name:"Peach",value:"#fed7aa",color:"#fed7aa"},{name:"Orange",value:"#fdba74",color:"#fdba74"},{name:"Yellow",value:"#fde047",color:"#fde047"},{name:"Green",value:"#86efac",color:"#86efac"},{name:"Blue",value:"#93c5fd",color:"#93c5fd"},{name:"Purple",value:"#c084fc",color:"#c084fc"},{name:"Pink",value:"#f9a8d4",color:"#f9a8d4"},{name:"Red",value:"#fca5a5",color:"#fca5a5"}],Ao="pubwave-editor-recent-colors",On=5;function Ol(){if(typeof window>"u")return[];try{const e=localStorage.getItem(Ao);if(e)return JSON.parse(e)}catch{}return[]}function En(e){if(!(typeof window>"u"))try{localStorage.setItem(Ao,JSON.stringify(e))}catch{}}function El({editor:e,onClose:t,buttonRef:n}){const o=Re(),[r,a]=m.useState([]),s=m.useRef(null),c=m.useRef([]);m.useEffect(()=>{const f=Ol();f.length>0&&a(f)},[]);const l=()=>{try{const f=e.getAttributes("textColor");return(f==null?void 0:f.color)||null}catch{return null}},d=()=>{try{const f=e.getAttributes("backgroundColor");return(f==null?void 0:f.backgroundColor)||null}catch{return null}},p=l(),x=d(),h=f=>{f===null?e.chain().focus().unsetColor().run():(e.chain().focus().setColor(f).run(),a(g=>{const k=[{type:"text",value:f},...g.filter(M=>!(M.type==="text"&&M.value===f))].slice(0,On);return En(k),k}))},b=f=>{f===null?e.chain().focus().unsetBackgroundColor().run():(e.chain().focus().setBackgroundColor(f).run(),a(g=>{const k=[{type:"background",value:f},...g.filter(M=>!(M.type==="background"&&M.value===f))].slice(0,On);return En(k),k}))};return m.useEffect(()=>{if(!ut()&&s.current)return c.current.forEach(f=>f.destroy()),c.current=[],requestAnimationFrame(()=>{if(!s.current)return;s.current.querySelectorAll("[data-tooltip]").forEach(g=>{const L=g.getAttribute("data-tooltip");if(L){const k=Te(g,{content:L,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});c.current.push(k)}})}),()=>{c.current.forEach(f=>f.destroy()),c.current=[]}},[r,p,x,o]),i.jsx(un,{isOpen:!0,buttonRef:n,align:"center",margin:8,onClickOutside:()=>t==null?void 0:t(),className:"pubwave-color-picker","data-testid":"color-picker",style:{backgroundColor:"var(--pubwave-bg, #ffffff)",border:"1px solid var(--pubwave-border, #e5e7eb)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1))",padding:"12px",minWidth:"240px",zIndex:E.zIndex.dropdown+1},children:i.jsxs("div",{ref:s,children:[r.length>0&&i.jsxs("div",{style:{marginBottom:"16px"},children:[i.jsx("div",{style:{...St,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.recentlyUsed}),i.jsx("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:r.map((f,g)=>i.jsx("button",{type:"button",onClick:()=>{f.type==="text"?h(f.value):b(f.value)},style:{width:"24px",height:"24px",borderRadius:"4px",border:"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:f.type==="background"?f.value:"#ffffff",cursor:"pointer",padding:f.type==="text"?"4px":0,display:f.type==="text"?"flex":"block",alignItems:f.type==="text"?"center":"normal",justifyContent:f.type==="text"?"center":"normal"},"data-tooltip":f.type==="text"?`${f.value} text`:`${f.value} background`,children:f.type==="text"&&i.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:f.value,lineHeight:1},children:"A"})},`${f.type}-${f.value}-${g}`))})]}),i.jsxs("div",{style:{marginBottom:"16px"},children:[i.jsx("div",{style:{...St,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.textColor}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"6px"},children:Il.map(f=>{const g=p===f.value;return i.jsx("button",{type:"button",onClick:()=>h(f.value),style:{width:"100%",aspectRatio:"1",borderRadius:"4px",border:g?"2px solid var(--pubwave-primary, #3b82f6)":"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:"#ffffff",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center"},"data-tooltip":f.value?`${f.name} text`:"Default text",children:i.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:f.color},children:"A"})},f.name)})})]}),i.jsxs("div",{children:[i.jsx("div",{style:{...St,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.backgroundColor}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"6px"},children:Rl.map(f=>{const g=x===f.value;return i.jsx("button",{type:"button",onClick:()=>b(f.value),style:{width:"100%",aspectRatio:"1",borderRadius:"4px",border:g?"2px solid var(--pubwave-primary, #3b82f6)":"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:f.color,cursor:"pointer",padding:0},"data-tooltip":f.value?`${f.name} background`:"Default background"},f.name)})})]})]})})}function _l({editor:e,isOpen:t,onToggle:n,onClose:o}){const r=Re(),a=m.useRef(null),s=()=>{try{const f=e.getAttributes("textColor");return(f==null?void 0:f.color)||null}catch{return null}},c=()=>{try{if(!e.isActive("backgroundColor"))return null;const f=e.getAttributes("backgroundColor");return(f==null?void 0:f.backgroundColor)||null}catch{return null}},l=s(),d=c(),p=l||d,h=l||(()=>{if(typeof window>"u")return"#1f2937";const f=document.querySelector(".pubwave-editor");return f&&window.getComputedStyle(f).getPropertyValue("--pubwave-text").trim()||"#1f2937"})(),b=d;return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(me,{ref:a,active:!!p,onClick:n,"data-tooltip":Ce(r.toolbar.textColor),"data-testid":"toolbar-colorPicker","aria-label":r.aria.colorPickerButton,children:i.jsx(oi,{textColor:h,backgroundColor:b})}),t&&i.jsx(El,{editor:e,onClose:o,buttonRef:a})]})}function Nl({editor:e,selectionState:t}){const n=Re(),[o,r]=m.useState(null),a=m.useCallback(()=>{r(null),e.chain().focus().toggleBold().run()},[e]),s=m.useCallback(()=>{r(null),e.chain().focus().toggleItalic().run()},[e]),c=m.useCallback(()=>{r(null),e.chain().focus().toggleUnderline().run()},[e]),l=m.useCallback(()=>{r(null),e.chain().focus().toggleStrike().run()},[e]),d=m.useCallback(()=>{r(null),e.chain().focus().toggleCode().run()},[e]),p=m.useCallback(()=>{r(M=>M==="turnInto"?null:"turnInto")},[]),x=m.useCallback(()=>{r(M=>M==="link"?null:"link")},[]),h=m.useCallback(()=>{r(M=>M==="colorPicker"?null:"colorPicker")},[]),b=(t==null?void 0:t.isBold)??!1,f=(t==null?void 0:t.isItalic)??!1,g=(t==null?void 0:t.isUnderline)??!1,L=(t==null?void 0:t.isStrike)??!1,k=(t==null?void 0:t.isCode)??!1;return i.jsxs(i.Fragment,{children:[i.jsx(Bl,{editor:e,isOpen:o==="turnInto",onToggle:p,onClose:()=>r(null)}),i.jsx(Rn,{}),i.jsx(me,{active:b,onClick:a,"data-tooltip":Ce(n.toolbar.bold,Qe.bold),"data-testid":"toolbar-bold","aria-label":n.aria.boldButton,children:i.jsx(Ya,{})}),i.jsx(me,{active:f,onClick:s,"data-tooltip":Ce(n.toolbar.italic,Qe.italic),"data-testid":"toolbar-italic","aria-label":n.aria.italicButton,children:i.jsx(Ka,{})}),i.jsx(me,{active:g,onClick:c,"data-tooltip":Ce(n.toolbar.underline,Qe.underline),"data-testid":"toolbar-underline","aria-label":n.aria.underlineButton,children:i.jsx(Xa,{})}),i.jsx(me,{active:L,onClick:l,"data-tooltip":Ce(n.toolbar.strike,Qe.strike),"data-testid":"toolbar-strike","aria-label":n.aria.strikeButton,children:i.jsx(Ja,{})}),i.jsx(me,{active:k,onClick:d,"data-tooltip":Ce(n.toolbar.code,Qe.code),"data-testid":"toolbar-code","aria-label":n.aria.codeButton,children:i.jsx(Za,{})}),i.jsx(Rn,{}),i.jsx(Dl,{editor:e,isOpen:o==="link",onToggle:x,onClose:()=>r(null),selectionState:t}),i.jsx(_l,{editor:e,isOpen:o==="colorPicker",onToggle:h,onClose:()=>r(null)})]})}const et=8;function Se(e){return!e.isDestroyed}function Hl(e,t){if(!t)return{top:0,left:0,visible:!1};const{view:n}=e,{from:o,to:r}=n.state.selection,a=n.coordsAtPos(o),s=n.coordsAtPos(r),c=Math.min(a.top,s.top),l=Math.min(a.left,s.left),d=Math.max(a.right,s.right),p=t.getBoundingClientRect(),x=p.width,h=p.height,b=Math.max(a.bottom,s.bottom),f=Lo(c,b,h,et);let g;f==="top"?g=c-h-et:g=b+et;const k=To(l,d,x,"center",et).left,M=window.innerWidth,C=window.innerHeight,u=et,S=Math.max(u,Math.min(k,M-x-u));return{top:Math.max(u,Math.min(g,C-h-u)),left:S,visible:!0}}function jo({editor:e,className:t,children:n,onVisibilityChange:o}){const r=m.useRef(null),a=m.useRef(!1),s=m.useRef(0),c=m.useRef(!1),[l,d]=m.useState({top:0,left:0,visible:!1}),[p,x]=m.useState(null),[h,b]=m.useState(!1),f=m.useRef([]),g=m.useMemo(()=>!Se(e)||a.current||!h?!1:Mt(e),[e,p,h]),L=m.useCallback(()=>{if(!Se(e))return;const C=cn(e);x(C)},[e]),k=m.useCallback(()=>{if(!g||!r.current){d(C=>({...C,visible:!1}));return}K(()=>{if(!Se(e))return;const C=Hl(e,r.current);d(C)})},[e,g]);m.useEffect(()=>{if(!Se(e))return;const u=e.view.dom.closest(".pubwave-editor"),S=A=>{const P=A.target,I=r.current;if(I&&P&&I.contains(P)){a.current=!1;return}u&&P&&u.contains(P)?c.current=!0:c.current=!1,a.current=!0,b(!1)},w=A=>{const P=Date.now(),B=P-s.current<300;s.current=P;const v=A.target,T=r.current;if(T&&v&&T.contains(v)){a.current=!1;return}if(a.current=!1,!c.current){b(!1);return}setTimeout(()=>{Se(e)&&(Mt(e)?(L(),b(!0),K(()=>{k()})):(b(!1),d(_=>({..._,visible:!1}))))},B?100:10)};return document.addEventListener("mousedown",S),document.addEventListener("mouseup",w),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("mouseup",w)}},[e,L,k]),m.useEffect(()=>{if(!Se(e))return;L();const C=()=>{!a.current&&h&&L()},u=()=>{a.current||(L(),Mt(e)?b(!0):b(!1),K(()=>{k()}))},S=()=>{setTimeout(()=>{const w=document.activeElement,A=r.current;A&&w&&A.contains(w)||(b(!1),C())},0)};return e.on("update",C),e.on("selectionUpdate",u),e.on("focus",u),e.on("blur",S),()=>{e.off("update",C),e.off("selectionUpdate",u),e.off("focus",u),e.off("blur",S)}},[e,L,k,h]),m.useEffect(()=>{k(),o==null||o(g)},[g,k,o]),m.useEffect(()=>{if(!g)return;const C=()=>{k()};return window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[g,k]);const M=Re();return m.useEffect(()=>{if(!ut()){if(!g||!l.visible||!r.current){f.current.forEach(C=>C.destroy()),f.current=[];return}return f.current.forEach(C=>C.destroy()),f.current=[],K(()=>{if(!r.current)return;r.current.querySelectorAll("[data-tooltip]").forEach(u=>{const S=u.getAttribute("data-tooltip");if(S){const w=Te(u,{content:S,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});f.current.push(w)}})}),()=>{f.current.forEach(C=>C.destroy()),f.current=[]}}},[g,l.visible,M]),Se(e)?i.jsx("div",{ref:r,className:Oe("pubwave-toolbar",g&&l.visible?"pubwave-toolbar--visible":"pubwave-toolbar--hidden",t),style:{position:"fixed",top:l.top,left:l.left,zIndex:E.zIndex.toolbar,opacity:g&&l.visible?1:0,pointerEvents:g&&l.visible?"auto":"none",transform:g&&l.visible?"translateY(0)":"translateY(4px)",transition:`opacity ${E.transition.fast}, transform ${E.transition.fast}`,isolation:"isolate"},role:"toolbar","aria-label":Et.toolbar,"aria-hidden":!g||!l.visible,"data-testid":"bubble-toolbar",children:i.jsx("div",{className:"pubwave-toolbar__content",style:{display:"flex",alignItems:"center",gap:0,padding:"var(--pubwave-spacing-1, 4px)",backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",color:"var(--pubwave-text)",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))"},children:n??i.jsx(Nl,{editor:e,selectionState:p})})}):null}const $l=768;function zl(e,t,n){if(!e||!(e instanceof Node))return null;try{const o=n.view.posAtDOM(e,0),r=n.state.doc.resolve(o);if(r.depth>=1){const a=r.node(1);if(["taskList","bulletList","orderedList","blockquote"].includes(a.type.name)){const c=n.view.nodeDOM(r.before(1));if(c&&t.contains(c))return c}}for(let a=r.depth;a>0;a--)if(r.node(a).isBlock){const c=r.before(a),l=n.view.nodeDOM(c);if(l&&t.contains(l))return l}}catch{let r=e instanceof HTMLElement?e:e.parentElement;for(;r&&r.parentElement;){if(r.parentElement===t)return r;r=r.parentElement}}return null}function So({editor:e}){const t=m.useRef(null),n=m.useRef(null),o=m.useRef(!1),r=m.useRef(null),[a,s]=m.useState(!1),[c,l]=m.useState(!1),[d,p]=m.useState({top:0}),[x,h]=m.useState(!1),[b,f]=m.useState(!1);m.useEffect(()=>{const w=()=>{h(ut()),f(window.innerWidth<$l)};return w(),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w)}},[]);const g=m.useCallback(()=>{const w=t.current,A=n.current;if(!w||!A)return;const P=w.closest(".pubwave-editor");if(!P)return;P.offsetHeight;const I=P.getBoundingClientRect();let B=14,v=A;["UL","OL","BLOCKQUOTE"].includes(A.tagName)&&A.firstElementChild instanceof HTMLElement&&(v=A.firstElementChild),v.offsetHeight;const T=v.getBoundingClientRect();try{const _=window.getComputedStyle(v),z=_.lineHeight;if(z&&z!=="normal"){const $=parseFloat(z);isNaN($)||(B=$/2)}else{const $=parseFloat(_.fontSize);isNaN($)||(B=$*1.5/2)}}catch{}const j=T.top-I.top+B;!isNaN(j)&&isFinite(j)&&j>=0&&p({top:j})},[]),L=m.useCallback(w=>{n.current=w,s(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{g()})})},[g]),k=m.useCallback(()=>{o.current||(n.current=null,s(!1))},[]),M=m.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);m.useEffect(()=>{const w=e.view.dom,A=w.closest(".pubwave-editor");if(!A)return;const P=T=>{if(o.current)return;const j=T.target;if(!j||(M(),j.closest(".pubwave-block-handle"))||!w.contains(j))return;const _=zl(j,w,e);_&&(_!==n.current?L(_):s(!0))},I=T=>{if(o.current)return;const j=T.relatedTarget;if(!j){M(),r.current=setTimeout(()=>{k()},150);return}j.closest(".pubwave-block-handle")||w.contains(j)||j.closest(".pubwave-editor")||(M(),r.current=setTimeout(()=>{k()},150))},B=()=>{o.current||(M(),r.current=setTimeout(()=>{k()},150))};w.addEventListener("mouseover",P),w.addEventListener("mouseout",I),A.addEventListener("mouseleave",B);const v=({transaction:T})=>{T.docChanged&&!o.current&&k()};return e.on("transaction",v),()=>{w.removeEventListener("mouseover",P),w.removeEventListener("mouseout",I),A.removeEventListener("mouseleave",B),e.off("transaction",v),M()}},[e,L,k,M]),m.useEffect(()=>{a&&n.current&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{g()})})},[a,g]),m.useEffect(()=>{if(!a)return;const w=()=>{n.current&&g()};return window.addEventListener("scroll",w,!0),()=>window.removeEventListener("scroll",w,!0)},[a,g]);const C=m.useCallback(()=>{const w=n.current;if(w)try{const A=e.view.posAtDOM(w,0),P=e.state.doc.resolve(A);let I=A;for(let T=P.depth;T>0;T--)if(P.node(T).isBlock){I=P.start(T);break}const v=e.state.doc.resolve(I).after(1);e.chain().focus().insertContentAt(v,{type:"paragraph"}).setTextSelection(v+1).run(),setTimeout(()=>{e.commands.insertContent("/")},10)}catch(A){console.error("Failed to add block:",A)}},[e]),u=m.useCallback(w=>{const A=n.current;if(!A)return;o.current=!0,requestAnimationFrame(()=>{l(!0)});const P=e.view.posAtDOM(A,0),I=ct(e.state.doc,P);if(!I)return;const B=I.pos,v=`block-${B}`;ko(e,v,B),w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("application/x-pubwave-block",v),A.classList.add("pubwave-block--dragging");const T=A.cloneNode(!0);T.classList.add("pubwave-block--drag-preview"),T.style.opacity="1";const j=U=>{U.style.setProperty("color","#9b9a97","important"),U.style.setProperty("border-color","#9b9a97","important"),U.style.setProperty("--pubwave-text","#9b9a97","important"),Array.from(U.children).forEach(R=>{R instanceof HTMLElement&&j(R)})};j(T);const _=A.getBoundingClientRect();T.style.width=`${_.width}px`,T.style.position="static",T.style.transform="none";const z=document.createElement("div");z.className="pubwave-editor";const $=document.createElement("div");$.className="pubwave-editor__content";const F=document.createElement("div");F.className="ProseMirror",F.appendChild(T),$.appendChild(F),z.appendChild($),z.style.position="absolute",z.style.top="-9999px",z.style.left="-9999px",document.body.appendChild(z),w.dataTransfer.setDragImage(T,0,0),setTimeout(()=>{document.body.removeChild(z)},0)},[e]),S=m.useCallback(()=>{o.current=!1,l(!1),n.current&&n.current.classList.remove("pubwave-block--dragging"),s(!1)},[]);return x||b||!a?null:i.jsxs("div",{ref:t,className:"pubwave-block-handle","data-testid":"block-handle",style:{position:"absolute",left:"calc(var(--pubwave-container-padding-left, 140px) - 80px)",top:`${d.top}px`,transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:"2px",pointerEvents:"auto",transition:`opacity ${E.transition.fast}`,zIndex:E.zIndex.dragHandle,opacity:a&&!c?1:0},onMouseEnter:w=>{w.stopPropagation(),r.current&&(clearTimeout(r.current),r.current=null)},onMouseLeave:w=>{w.stopPropagation();const A=w.relatedTarget;A!=null&&A.closest(".pubwave-editor")||(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{k()},150))},children:[i.jsx("button",{type:"button",className:"pubwave-block-handle__add",onClick:C,"data-testid":"add-block-button",style:{width:"var(--pubwave-button-width, 28px)",height:"var(--pubwave-button-height, 28px)",display:"flex",alignItems:"center",justifyContent:"center",border:"none",borderRadius:E.borderRadius.sm,background:"transparent",color:`var(--pubwave-text-muted, ${E.colors.textMuted})`,cursor:"pointer",transition:`background-color ${E.transition.fast}, color ${E.transition.fast}`},title:"Add block","aria-label":"Add block below",children:i.jsx(ql,{})}),i.jsx("div",{className:"pubwave-block-handle__drag",draggable:!0,onDragStart:u,onDragEnd:S,"data-testid":"drag-handle",style:{width:"44px",height:"44px",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:E.borderRadius.sm,background:"transparent",color:`var(--pubwave-text-muted, ${E.colors.textMuted})`,cursor:"grab",transition:`background-color ${E.transition.fast}, color ${E.transition.fast}`},role:"button",tabIndex:0,title:"Drag to move","aria-label":"Drag to reorder block",children:i.jsx(Ul,{})})]})}function ql(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),i.jsx("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]})}function Ul(){return i.jsxs("svg",{width:"12",height:"18",viewBox:"0 0 10 16",fill:"currentColor",children:[i.jsx("circle",{cx:"2",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"2",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"2",cy:"13",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"13",r:"1.5"})]})}function Mo({visible:e,position:t,className:n}){return i.jsxs("div",{className:Oe("pubwave-drop-indicator",e&&"pubwave-drop-indicator--visible",`pubwave-drop-indicator--${t}`,n),"data-testid":"drop-indicator",style:{position:"absolute",left:0,right:0,height:"2px",backgroundColor:`var(--pubwave-drop-indicator-color, ${E.colors.dropIndicator})`,borderRadius:"1px",...t==="before"?{top:"-1px"}:{bottom:"-1px"},opacity:e?1:0,transform:e?"scaleX(1)":"scaleX(0.8)",transition:`opacity ${E.transition.fast}, transform ${E.transition.fast}`,zIndex:10,pointerEvents:"none"},"aria-hidden":"true",children:[i.jsx(_n,{position:"left",visible:e}),i.jsx(_n,{position:"right",visible:e})]})}function _n({position:e,visible:t}){return i.jsx("div",{className:`pubwave-drop-indicator__cap pubwave-drop-indicator__cap--${e}`,style:{position:"absolute",top:"50%",transform:"translateY(-50%)",...e==="left"?{left:"-4px"}:{right:"-4px"},width:"8px",height:"8px",borderRadius:"50%",backgroundColor:`var(--pubwave-drop-indicator-color, ${E.colors.dropIndicator})`,opacity:t?1:0,transition:`opacity ${E.transition.fast}`}})}function Fl({editor:e}){const[t,n]=m.useState(null),[o,r]=m.useState(null);return m.useEffect(()=>{const a=Z.getState(e.state);a&&n(a);const s=()=>{const c=Z.getState(e.state);c&&(c.dropTargetPos!==(t==null?void 0:t.dropTargetPos)||c.dropPosition!==(t==null?void 0:t.dropPosition))&&n(c)};return e.on("transaction",s),()=>{e.off("transaction",s)}},[e,t]),m.useEffect(()=>{if(!(t!=null&&t.dropTargetPos)||!t.dropPosition){r(null);return}const a=requestAnimationFrame(()=>{var b;const s=e.view,c=t.dropTargetPos;if(c===null)return;let l=s.nodeDOM(c);if(!l&&c>0){const f=s.domAtPos(c).node;f instanceof HTMLElement&&(l=f)}if(!l||!(l instanceof HTMLElement))return;const d=l.getBoundingClientRect(),p=(b=s.dom.closest(".pubwave-editor"))==null?void 0:b.getBoundingClientRect();if(!p)return;const x=8;let h=0;t.dropPosition==="before"?h=d.top-p.top-x:h=d.bottom-p.top+x,r({top:h,left:d.left-p.left,width:d.width})});return()=>cancelAnimationFrame(a)},[t,e]),!(t!=null&&t.dropTargetPos)||!t.dropPosition||!o?null:i.jsx("div",{style:{position:"absolute",top:o.top,left:o.left,width:o.width,height:"2px",pointerEvents:"none",zIndex:50},children:i.jsx(Mo,{visible:!0,position:t.dropPosition,className:"pubwave-drop-indicator--overlay"})})}const Wl=m.forwardRef(function(t,n){const{content:o,editable:r=!0,placeholder:a,theme:s,autofocus:c=!1,imageUpload:l,onChange:d,onSelectionChange:p,onFocus:x,onBlur:h,onReady:b,className:f,width:g,height:L,minHeight:k,"data-testid":M="pubwave-editor"}=t,C=At(s==null?void 0:s.locale),u=a??C.placeholder??'Write,type "/" for commands...',S=xe.useEditor({extensions:ln({placeholder:u,headingLevels:[1,2,3],linkOpenInNewTab:!0,linkOpenOnClick:!0,imageUpload:l,locale:s==null?void 0:s.locale}),content:o,editable:r,autofocus:c,immediatelyRender:!1,editorProps:{attributes:{class:`pubwave-editor__content ${(s==null?void 0:s.contentClassName)??""}`.trim(),"data-placeholder":u}},onUpdate:({editor:v})=>{d==null||d(v.getJSON())},onSelectionUpdate:()=>{p==null||p()},onFocus:()=>{x==null||x()},onBlur:()=>{h==null||h()},onCreate:({editor:v})=>{const T=w(v);b==null||b(T)}}),w=m.useCallback(v=>({getState:()=>({selection:{hasSelection:!(v!=null&&v.state.selection.empty),isMultiBlock:!1,from:(v==null?void 0:v.state.selection.from)??0,to:(v==null?void 0:v.state.selection.to)??0,isEmpty:(v==null?void 0:v.state.selection.empty)??!0},marks:{isBold:(v==null?void 0:v.isActive("bold"))??!1,isItalic:(v==null?void 0:v.isActive("italic"))??!1,isLink:(v==null?void 0:v.isActive("link"))??!1,linkHref:v?v.getAttributes("link").href:void 0},isFocused:(v==null?void 0:v.isFocused)??!1,isEditable:(v==null?void 0:v.isEditable)??!1,isEmpty:(v==null?void 0:v.isEmpty)??!0,characterCount:0}),getJSON:()=>(v==null?void 0:v.getJSON())??{type:"doc",content:[]},getHTML:()=>(v==null?void 0:v.getHTML())??"",getText:()=>(v==null?void 0:v.getText())??"",setContent:T=>v==null?void 0:v.commands.setContent(T),clearContent:()=>v==null?void 0:v.commands.clearContent(),setEditable:T=>v==null?void 0:v.setEditable(T),focus:T=>{T==="start"?v==null||v.commands.focus("start"):T==="end"?v==null||v.commands.focus("end"):v==null||v.commands.focus()},blur:()=>v==null?void 0:v.commands.blur(),toggleBold:()=>v==null?void 0:v.chain().focus().toggleBold().run(),toggleItalic:()=>v==null?void 0:v.chain().focus().toggleItalic().run(),setLink:T=>{T?v==null||v.chain().focus().setLink({href:T}).run():v==null||v.chain().focus().unsetLink().run()},destroy:()=>v==null?void 0:v.destroy(),tiptapEditor:v??null}),[]);m.useImperativeHandle(n,()=>S?w(S):null,[S,w]);const[A,P]=m.useState(!1);m.useEffect(()=>{P(!0)},[]),m.useEffect(()=>{var T;if(!((T=S==null?void 0:S.view)!=null&&T.dom))return;const v=S.view.dom;v&&v.setAttribute("data-placeholder",u)},[S,u,s==null?void 0:s.locale]);const I=["pubwave-editor",(s==null?void 0:s.classNamePrefix)??"",(s==null?void 0:s.containerClassName)??"",S?Cl(S):"",L||k?"pubwave-editor--fixed-height":"",f].filter(Boolean).join(" "),B={position:"relative",overflow:L||k?"hidden":"visible",...L||k?{display:"flex",flexDirection:"column"}:{}};if(g&&(B["--pubwave-container-width"]=g,B.width=g,B["--pubwave-container-max-width"]=g,B.maxWidth=g),L&&(B["--pubwave-container-height"]=L,B.height=L),k&&(B["--pubwave-container-min-height"]=k,B.minHeight=k),s!=null&&s.colors){const{colors:v}=s,j=(v.text||"#1f2937").toLowerCase().trim(),_=j.startsWith("#f")||j.startsWith("#e")||j.includes("f1")||j.includes("f3")||j.includes("f0")||j.includes("fdf")||j.includes("ffb")||j.includes("ffc")||j.includes("ffd")||j.includes("ffe")||j.includes("fff")||j.includes("e0")||j.includes("e5")||j.includes("ecf")||j.includes("eef");v.background&&(v.background.includes("gradient")?(B.background=v.background,_?(B["--pubwave-surface"]="rgba(38, 38, 38, 0.95)",B["--pubwave-bg"]="#1a1a1a"):(B["--pubwave-surface"]="rgba(255, 255, 255, 0.95)",B["--pubwave-bg"]="#ffffff")):(B["--pubwave-bg"]=v.background,B["--pubwave-surface"]=v.background)),v.text&&(B["--pubwave-text"]=v.text),v.textMuted&&(B["--pubwave-text-muted"]=v.textMuted),v.border&&(B["--pubwave-border"]=v.border),v.primary&&(B["--pubwave-primary"]=v.primary),v.linkColor&&(B["--pubwave-link-color"]=v.linkColor),_?B["--pubwave-hover"]="rgba(255, 255, 255, 0.1)":B["--pubwave-hover"]="rgba(0, 0, 0, 0.05)"}if(s!=null&&s.backgroundImage){const v=s.backgroundImage,T=s.backgroundImageOptions||{};v.startsWith("url(")||v.includes("gradient")||v.includes("linear-gradient")||v.includes("radial-gradient")?B.backgroundImage=v:B.backgroundImage=`url(${v})`,T.repeat!==void 0?B.backgroundRepeat=T.repeat:B.backgroundRepeat="no-repeat",T.position!==void 0?B.backgroundPosition=T.position:B.backgroundPosition="center",T.size!==void 0?B.backgroundSize=T.size:B.backgroundSize="cover",T.attachment!==void 0?B.backgroundAttachment=T.attachment:B.backgroundAttachment="scroll"}return!A||!S?i.jsx(pn,{value:{locale:C},children:i.jsx("div",{className:I,"data-testid":M,role:"application","aria-label":Et.editor,style:B})}):i.jsx(pn,{value:{locale:C},children:i.jsxs("div",{className:I,"data-testid":M,role:"application","aria-label":Et.editor,style:B,children:[i.jsx(xe.EditorContent,{editor:S}),r&&i.jsx(jo,{editor:S}),r&&i.jsx(So,{editor:S}),r&&i.jsx(Fl,{editor:S})]})})});function Ee(e){return!e.isDestroyed}function Po(e){if(!Ee(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().toggleBold().run();return Be(e),{success:t,message:t?"Bold toggled":"Could not toggle bold"}}function Do(e){if(!Ee(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().toggleItalic().run();return Be(e),{success:t,message:t?"Italic toggled":"Could not toggle italic"}}function Io(e,t){if(!Ee(e))return{success:!1,message:"Editor not available"};if(!t.trim())return{success:!1,message:"URL is required"};let n=t.trim();!/^https?:\/\//i.test(n)&&!n.startsWith("/")&&(n=`https://${n}`);const o=e.chain().focus().setLink({href:n}).run();return Be(e),{success:o,message:o?"Link added":"Could not add link"}}function Ro(e){if(!Ee(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().unsetLink().run();return Be(e),{success:t,message:t?"Link removed":"Could not remove link"}}function Oo(e,t=window.prompt.bind(window)){if(!Ee(e))return{success:!1,message:"Editor not available"};if(e.isActive("link"))return Ro(e);const o=t("Enter URL:");return o?Io(e,o):(Be(e),{success:!1,message:"Link cancelled"})}function Vl(e,t){if(!Ee(e))return{success:!1,message:"Editor not available"};const n=e.chain().focus().setHeading({level:t}).run();Be(e);const o=String(t);return{success:n,message:n?`Heading ${o} applied`:"Could not set heading"}}function Gl(e){if(!Ee(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().setParagraph().run();return Be(e),{success:t,message:t?"Paragraph applied":"Could not set paragraph"}}function Yl(e,t,n){return()=>{const o=t(e);n==null||n(o)}}const Kl=[{id:"bold",label:"Bold",shortcut:"Cmd+B",icon:"bold",action:Po,isActive:e=>e.isActive("bold")},{id:"italic",label:"Italic",shortcut:"Cmd+I",icon:"italic",action:Do,isActive:e=>e.isActive("italic")},{id:"link",label:"Link",icon:"link",action:e=>Oo(e),isActive:e=>e.isActive("link")}],Nn="44px",Hn="20px";function Xl({blockId:e,isHovered:t,isDragging:n=!1,onDragStart:o,onDragEnd:r,className:a}){const s=m.useRef(null),[c,l]=m.useState(!1),d=m.useCallback(f=>{if(f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",e),f.dataTransfer.setData("application/x-pubwave-block",e),s.current){const g=s.current.getBoundingClientRect();f.dataTransfer.setDragImage(s.current,g.width/2,g.height/2)}o==null||o(e,f)},[e,o]),p=m.useCallback(f=>{l(!1),r==null||r(e,f)},[e,r]),x=m.useCallback(()=>{l(!0)},[]),h=m.useCallback(()=>{l(!1)},[]),b=t||n;return i.jsx("div",{ref:s,className:Oe("pubwave-drag-handle",b&&"pubwave-drag-handle--visible",n&&"pubwave-drag-handle--dragging",c&&"pubwave-drag-handle--pressed",a),"data-testid":"drag-handle",style:{position:"absolute",left:"-32px",top:"50%",transform:"translateY(-50%)",width:Nn,height:Nn,display:"flex",alignItems:"center",justifyContent:"center",cursor:n?"grabbing":"grab",opacity:b?1:0,transition:`opacity ${E.transition.fast}`,userSelect:"none",WebkitUserSelect:"none"},draggable:!0,onDragStart:d,onDragEnd:p,onMouseDown:x,onMouseUp:h,role:"button","aria-label":Et.dragHandle,tabIndex:b?0:-1,children:i.jsx("div",{className:"pubwave-drag-handle__visual",style:{width:Hn,height:Hn,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:E.borderRadius.sm,backgroundColor:c?`var(--pubwave-drag-handle-active-bg, ${E.colors.focus})`:"transparent",transition:`background-color ${E.transition.fast}`},children:i.jsx(Jl,{})})})}function Jl(){return i.jsxs("svg",{width:"12",height:"16",viewBox:"0 0 12 16",fill:"currentColor",style:{color:`var(--pubwave-drag-handle-color, ${E.colors.textMuted})`},children:[i.jsx("circle",{cx:"3",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"3",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"3",cy:"13",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"13",r:"1.5"})]})}const Jt=50,Zl=15;function $n(e){const t=1-e/Jt;return Math.round(t*Zl)}function Eo(e){const t={isActive:!1,direction:null,speed:0,animationId:null},n=()=>e??window,o=()=>{if(e){const a=e.getBoundingClientRect();return{top:a.top,bottom:a.bottom}}return{top:0,bottom:window.innerHeight}},r=()=>{if(!t.isActive||t.direction===null)return;const a=n(),s=t.direction==="up"?-t.speed:t.speed;a===window?window.scrollBy(0,s):a instanceof HTMLElement&&(a.scrollTop+=s),t.animationId=K(r)};return{start(){t.isActive=!0},update(a){if(!t.isActive)return;const s=o(),c=a-s.top,l=s.bottom-a;c<Jt?(t.direction="up",t.speed=$n(c)):l<Jt?(t.direction="down",t.speed=$n(l)):(t.direction=null,t.speed=0),t.direction!==null&&t.animationId===null?t.animationId=K(r):t.direction===null&&t.animationId!==null&&(cancelAnimationFrame(t.animationId),t.animationId=null)},stop(){t.isActive=!1,t.direction=null,t.speed=0,t.animationId!==null&&(cancelAnimationFrame(t.animationId),t.animationId=null)}}}function Ql(e){let t=null;const n=()=>(t??(t=Eo(e)),t);return{startAutoScroll(){n().start()},updateAutoScroll(o){n().update(o.clientY)},stopAutoScroll(){n().stop(),t=null}}}const ec=3e3;function _o({message:e,type:t="info",duration:n=ec,onDismiss:o,className:r}){const[a,s]=m.useState(!0);m.useEffect(()=>{if(n<=0)return;const d=setTimeout(()=>{s(!1),o==null||o()},n);return()=>{clearTimeout(d)}},[n,o]);const c=m.useCallback(()=>{s(!1),o==null||o()},[o]),l={info:E.colors.text,success:"var(--pubwave-color-success, #10b981)",error:E.colors.error,warning:"var(--pubwave-color-warning, #f59e0b)"};return i.jsxs("div",{className:Oe("pubwave-toast",`pubwave-toast--${t}`,a?"pubwave-toast--visible":"pubwave-toast--hidden",r),style:{position:"fixed",bottom:"24px",left:"50%",transform:`translateX(-50%) translateY(${a?"0":"16px"})`,padding:`${E.spacing.sm} ${E.spacing.md}`,backgroundColor:`var(--pubwave-toast-bg, ${E.colors.surface})`,border:`1px solid var(--pubwave-toast-border, ${E.colors.border})`,borderRadius:E.borderRadius.md,boxShadow:E.shadow.md,color:l[t],fontSize:E.typography.fontSizeSmall,opacity:a?1:0,transition:`opacity ${E.transition.normal}, transform ${E.transition.normal}`,zIndex:100,maxWidth:"400px",textAlign:"center"},role:"status","aria-live":"polite",children:[i.jsx("span",{className:"pubwave-toast__message",children:e}),i.jsx("button",{type:"button",className:"pubwave-toast__dismiss",onClick:c,style:{marginLeft:E.spacing.sm,padding:"0 4px",background:"none",border:"none",color:E.colors.textMuted,cursor:"pointer",fontSize:"16px",lineHeight:1},"aria-label":"Dismiss",children:"×"})]})}function tc({toasts:e,onDismiss:t}){return i.jsx("div",{className:"pubwave-toast-container",children:e.map((n,o)=>{const r=24+o*56,a=100-o;return i.jsx("div",{style:{position:"fixed",bottom:`${String(r)}px`,left:"50%",transform:"translateX(-50%)",zIndex:a},children:i.jsx(_o,{message:n.message,type:n.type,duration:n.duration,onDismiss:()=>{t(n.id)}})},n.id)})})}function nc(){const e=String(Date.now()),t=Math.random().toString(36).slice(2,9);return`toast-${e}-${t}`}exports.BlockHandle=So;exports.BubbleToolbar=jo;exports.DragHandle=Xl;exports.DropIndicator=Mo;exports.PubwaveEditor=Wl;exports.SUPPORTED_BLOCKS=Xs;exports.SUPPORTED_MARKS=Js;exports.SlashMenuList=xo;exports.Toast=_o;exports.ToastContainer=tc;exports.canUseDOM=_t;exports.cancelDrag=Ks;exports.clearFormatting=hl;exports.cn=Oe;exports.createActionHandler=Yl;exports.createAutoScroller=Eo;exports.createDndPlugin=wo;exports.createEditor=Zs;exports.createExtensions=ln;exports.createFocusTrap=Pl;exports.createSlashCommandsExtension=mo;exports.createToastId=nc;exports.defaultSlashCommands=Dt;exports.defaultTokens=Ys;exports.defaultToolbarActions=Kl;exports.destroyEditor=Qs;exports.dndPluginKey=Z;exports.findBlockAtPos=ct;exports.focusAfterClick=jl;exports.focusAt=Al;exports.focusEditor=pl;exports.getActiveLinkHref=ml;exports.getActiveMarks=gl;exports.getDndState=sn;exports.getSelectionBounds=nl;exports.getSelectionState=cn;exports.handleSelectionClear=Ml;exports.isEditable=ft;exports.isEditorValid=el;exports.isMarkActive=bl;exports.isMobileDevice=ut;exports.isNodeActive=vl;exports.isReadOnly=Co;exports.isSSR=Va;exports.isSelectionEmpty=tl;exports.maintainFocus=Sl;exports.moveBlock=yo;exports.redo=dl;exports.restoreFocus=Be;exports.restoreSelection=tt;exports.saveSelection=Bo;exports.selectAll=fl;exports.setHeading=ll;exports.setLink=al;exports.setParagraph=sl;exports.shouldAllowInteraction=kl;exports.shouldAllowToolbar=yl;exports.shouldRenderEditUI=xl;exports.shouldShowDragHandle=wl;exports.shouldShowToolbar=Mt;exports.startDrag=ko;exports.toggleBold=ol;exports.toggleHeading=cl;exports.toggleItalic=rl;exports.tokens=E;exports.toolbarRemoveLink=Ro;exports.toolbarSetHeading=Vl;exports.toolbarSetLink=Io;exports.toolbarSetParagraph=Gl;exports.toolbarToggleBold=Po;exports.toolbarToggleItalic=Do;exports.toolbarToggleLink=Oo;exports.undo=ul;exports.unsetLink=il;exports.useAutoScroll=Ql;
|
|
103
|
+
`,Ys=Gs;function Ee(...e){return e.filter(Boolean).join(" ")}const St={padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px) var(--pubwave-spacing-1, 4px)",fontSize:"var(--pubwave-font-size-xs, 11px)",fontWeight:600,color:"var(--pubwave-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"};function mo(e=Dt,t,n){var a;const o=t||n?Kn(t,n):e,r=((a=n==null?void 0:n.slashMenu)==null?void 0:a.groups)||{basic:"Style",list:"Lists",media:"Media",advanced:"Advanced",layout:"Layout"};return re.Extension.create({name:"slashCommands",addOptions(){return{suggestion:{char:"/",command:({editor:s,range:c,props:l})=>{if(l.id==="taskList"){s.chain().focus().deleteRange(c).toggleTaskList().run();return}s.chain().focus().deleteRange(c).run(),l.action(s)}}}},addProseMirrorPlugins(){const s=this.editor;return[br({editor:this.editor,...this.options.suggestion,allowed:({state:c,range:l})=>{try{if(s.isActive("codeBlock"))return!1;const d=c.doc.resolve(l.from);for(let p=d.depth;p>=1;p--)if(d.node(p).type.name==="codeBlock")return!1;return!0}catch{return!0}},items:({query:c,state:l})=>{let d=o;try{const p=l.doc.resolve(l.selection.from);for(let x=p.depth;x>=0;x--)if(p.node(x).type.name==="layoutColumn"){d=o.filter(b=>b.group!=="layout");break}}catch{}return fi(d,c)},render:()=>{let c,l;return{onStart:d=>{this.editor.isActive("codeBlock")||(c=new ye.ReactRenderer(xo,{props:{...d,query:d.query,editor:this.editor,groupLabels:r},editor:this.editor}),d.clientRect&&(l=Be("body",{getReferenceClientRect:d.clientRect,appendTo:()=>document.body,content:c.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",offset:[0,8],zIndex:E.zIndex.dropdown,arrow:!1,duration:[0,0],animation:!1,popperOptions:{modifiers:[{name:"preventOverflow",options:{boundary:"viewport",padding:8,altAxis:!0}},{name:"flip",options:{fallbackPlacements:["top-start","bottom-end","top"]}}]},onShow(p){const x=p.popper.querySelector(".tippy-box");x&&(x.style.zIndex=String(E.zIndex.dropdown),x.style.backgroundColor="transparent",x.style.background="transparent",x.style.border="none");const h=p.popper.querySelector(".pubwave-slash-menu");if(h){const b=document.querySelector(".ProseMirror");if(b){const f=h.getBoundingClientRect(),L=b.getBoundingClientRect().bottom-f.top-16,k=Math.max(200,Math.min(280,L));h.style.maxHeight=`${k}px`}}}})))},onUpdate(d){var p,x,h;if(c.updateProps({...d,query:d.query,editor:d.editor,groupLabels:r}),d.items.length===0){if(l[0]){l[0].hide();const b=l[0].popper.querySelector(".tippy-box");b&&(b.style.opacity="0",b.style.pointerEvents="none")}return}d.clientRect&&((p=l[0])==null||p.setProps({getReferenceClientRect:d.clientRect}),(x=l[0])!=null&&x.state.isVisible||(h=l[0])==null||h.show())},onKeyDown(d){var p,x;return d.event.key==="Escape"?((p=l[0])==null||p.hide(),!0):((x=c.ref)==null?void 0:x.onKeyDown(d))??!1},onExit(){var d;(d=l[0])==null||d.destroy(),c.destroy()}}}})]}})}const xo=m.forwardRef(function({items:t,command:n,query:o="",groupLabels:r},a){const[s,c]=m.useState(-1),l=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{t.length>0&&o.length>0?c(0):(t.length,c(-1))},[t,o]),Ha(s,l,d);const p=m.useMemo(()=>{const f={};for(const g of t){const L=f[g.group]??[];L.push(g),f[g.group]=L}return f},[t]),x=t,h=m.useCallback(f=>{const g=x[f];g&&n(g)},[x,n]);m.useImperativeHandle(a,()=>({onKeyDown:({event:f})=>x.length===0?!1:f.key==="ArrowUp"?(c(g=>g<0?x.length-1:g<=0?0:g-1),!0):f.key==="ArrowDown"?(c(g=>g<0?0:g>=x.length-1?x.length-1:g+1),!0):f.key==="Enter"&&s>=0&&s<x.length?(h(s),!0):!1}));const b=r||{basic:"Style",list:"Lists",media:"Media",advanced:"Advanced"};return t.length===0?null:i.jsx("div",{className:"pubwave-slash-menu",ref:l,style:$a,"data-testid":"slash-menu",children:i.jsx("div",{style:{padding:"var(--pubwave-spacing-1, 4px) 0"},children:(()=>{let f=0;return["basic","list","media","advanced"].map(L=>{const k=p[L];return!k||k.length===0?null:i.jsxs("div",{className:"pubwave-slash-menu__group",style:za,children:[i.jsx("div",{className:"pubwave-slash-menu__group-label",style:qa,children:b[L]||L}),k.map(M=>{const C=f++,u=C===s;return i.jsxs("button",{ref:u?d:null,className:`pubwave-slash-menu__item ${u?"pubwave-slash-menu__item--selected":""}`,style:{...Ua,backgroundColor:u?"var(--pubwave-hover-bg, #f3f4f6)":"transparent"},onClick:()=>h(C),onMouseEnter:()=>c(C),children:[i.jsx("span",{className:"pubwave-slash-menu__item-icon",style:Fa,children:M.icon}),i.jsx("span",{className:"pubwave-slash-menu__item-title",style:Wa,children:M.title})]},M.id)})]},L)})})()})})}),Z=new Pt.PluginKey("pubwave-dnd"),Ot={draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null,cancelled:!1};function De(e,t){switch(t.type){case"START_DRAG":return{...e,draggingBlockId:t.blockId,draggingBlockPos:t.pos,dropTargetPos:null,dropPosition:null,cancelled:!1};case"UPDATE_DROP_TARGET":return{...e,dropTargetPos:t.pos,dropPosition:t.position};case"CANCEL_DRAG":return{...e,cancelled:!0,draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null};case"COMPLETE_DRAG":return{...e,draggingBlockId:null,draggingBlockPos:null,dropTargetPos:null,dropPosition:null};case"RESET":return Ot;default:return e}}function ct(e,t){const n=Math.max(0,Math.min(t,e.content.size));try{const o=e.resolve(n);if(o.depth>=1){const r=o.node(1);if(["taskList","bulletList","orderedList","blockquote"].includes(r.type.name))return{node:r,pos:o.before(1)}}for(let r=o.depth;r>0;r--){const a=o.node(r);if(a.isBlock)return{node:a,pos:o.before(r)}}if(o.depth===0&&e.childCount>0){let r=0;for(let a=0;a<e.childCount;a++){const s=e.child(a);if(r+s.nodeSize>n)return{node:s,pos:r};r+=s.nodeSize}return{node:e.lastChild,pos:e.content.size-e.lastChild.nodeSize}}return null}catch{let o=null,r=0;for(let a=0;a<e.childCount;a++){const s=e.child(a);if(r<=n&&r+s.nodeSize>n){o={node:s,pos:r};break}r+=s.nodeSize}return o}}function yo(e,t,n,o){const{state:r}=e,{tr:a,doc:s}=r,c=ct(s,t);if(!c)return!1;const l=ct(s,n);if(!l)return!1;let d=l.pos;if(o==="after"&&(d=l.pos+l.node.nodeSize),c.pos===l.pos||d===c.pos||d===c.pos+c.node.nodeSize)return!1;const p=c.node,x=c.pos,h=c.pos+p.nodeSize,b=s.slice(x,h);let f=d;x<d&&(f=d-p.nodeSize),a.delete(x,h);const g=a.doc.content.size;if(f<0?f=0:f>g&&(f=g),f>=0&&f<=g)a.insert(f,b.content);else return!1;return a.setSelection(r.selection.map(a.doc,a.mapping)),e.view.dispatch(a),!0}function In(e,t){const n=e.state.doc;if(n.childCount===0)return null;const o=0,r=e.nodeDOM(o);let a=0;for(let d=0;d<n.childCount-1;d++)a+=n.child(d).nodeSize;const s=e.nodeDOM(a),c=t.clientY;if(r){const d=r.getBoundingClientRect();if(c<d.top+50)return{pos:o,position:"before"}}if(s){const d=s.getBoundingClientRect();if(c>d.bottom-50)return{pos:a,position:"after"}}const l=e.posAtCoords({left:t.clientX,top:t.clientY});if(l){const d=ct(n,l.pos);if(d){const p=e.nodeDOM(d.pos);if(p){const x=p.getBoundingClientRect(),h=x.top+x.height/2;return{pos:d.pos,position:c<h?"before":"after"}}}}return null}function wo(e){let t=Ot;return new Pt.Plugin({key:Z,state:{init(){return Ot},apply(n,o){const r=n.getMeta(Z);return r!==void 0?(t=r,r):(t=o,o)}},props:{handleKeyDown(n,o){return o.key==="Escape"&&t.draggingBlockId?(t=De(t,{type:"CANCEL_DRAG"}),n.dispatch(n.state.tr.setMeta(Z,t)),!0):!1},handleDOMEvents:{dragover(n,o){var s;if(!((s=o.dataTransfer)!=null&&s.types.includes("application/x-pubwave-block")))return!1;o.preventDefault(),o.dataTransfer.dropEffect="move",t=Z.getState(n.state)??t;const a=In(n,o);return a?(t=De(t,{type:"UPDATE_DROP_TARGET",pos:a.pos,position:a.position}),n.dispatch(n.state.tr.setMeta(Z,t))):t.dropTargetPos!==null&&(t=De(t,{type:"UPDATE_DROP_TARGET",pos:null,position:null}),n.dispatch(n.state.tr.setMeta(Z,t))),!0},drop(n,o){var h;const r=(h=o.dataTransfer)==null?void 0:h.getData("application/x-pubwave-block");if(!r)return!1;o.preventDefault(),o.stopPropagation();let c=(Z.getState(n.state)??t).draggingBlockPos;if(c===null&&r.startsWith("block-")){const b=parseInt(r.replace("block-",""),10);isNaN(b)||(c=b)}if(c===null)return!1;const l=In(n,o);if(!l)return!1;const{pos:d,position:p}=l;if(d===c||!e)return!1;const x=yo(e,c,d,p);return t=De(t,{type:"COMPLETE_DRAG"}),n.dispatch(n.state.tr.setMeta(Z,t)),x},dragleave(n,o){const r=o.relatedTarget;return r!=null&&r.closest(".pubwave-editor")||(t=De(t,{type:"UPDATE_DROP_TARGET",pos:null,position:null}),n.dispatch(n.state.tr.setMeta(Z,t))),!1}}}})}function sn(e){return Z.getState(e.state)??Ot}function ko(e,t,n){const{view:o}=e,r={type:"START_DRAG",blockId:t,pos:n},a=De(sn(e),r);o.dispatch(o.state.tr.setMeta(Z,a))}function Ks(e){const{view:t}=e,n={type:"CANCEL_DRAG"},o=De(sn(e),n);t.dispatch(t.state.tr.setMeta(Z,o))}const Xs=["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock","horizontalRule","image","chart"],Js=["bold","italic","underline","strike","code","link"];function ln(e={}){const{placeholder:t,historyDepth:n=100,headingLevels:o,linkOpenInNewTab:r,linkOpenOnClick:a,enableSlashCommands:s=!0,slashCommands:c,imageUpload:l,locale:d}=e,p=d?At(d):null,x=t??(p==null?void 0:p.placeholder)??'Write,type "/" for commands...',h=[...Oa({headingLevels:o,imageUpload:l}),...Na({linkOpenInNewTab:r,linkOpenOnClick:a}),Fo.configure({placeholder:x,emptyEditorClass:"pubwave-editor--empty",emptyNodeClass:"pubwave-editor__node--empty"}),Wo.configure({depth:n}),Vo.configure({color:"var(--pubwave-dropcursor-color, #3b82f6)",width:2}),Go,re.Extension.create({name:"dragAndDrop",addProseMirrorPlugins(){return[wo(this.editor)]}})];if(s){const b=At(d||"en"),f=c?[...Dt,...c]:Dt;h.push(mo(f,l,b))}return h}function Zs(e={}){if(!_t)throw new Error("createEditor() cannot be called server-side. Ensure this function is only called in client-side code (e.g., useEffect, event handlers).");const{content:t,editable:n=!0,placeholder:o,autofocus:r=!1,onUpdate:a,onSelectionUpdate:s,onFocus:c,onBlur:l,onCreate:d,onDestroy:p}=e,h={extensions:ln({placeholder:o,headingLevels:[1,2,3],linkOpenInNewTab:!0,linkOpenOnClick:!0}),content:t,editable:n,autofocus:r,editorProps:{attributes:{class:"pubwave-editor__content","data-placeholder":o??'Write,type "/" for commands...'}},onUpdate:a?({editor:b})=>{a({editor:b})}:void 0,onSelectionUpdate:s?({editor:b})=>{s({editor:b})}:void 0,onFocus:c?({editor:b})=>{c({editor:b})}:void 0,onBlur:l?({editor:b})=>{l({editor:b})}:void 0,onCreate:d?({editor:b})=>{d({editor:b})}:void 0,onDestroy:p?()=>{p()}:void 0};return new re.Editor(h)}function Qs(e){e&&!e.isDestroyed&&e.destroy()}function el(e){return e!==null&&!e.isDestroyed}function cn(e){const{state:t}=e,{selection:n}=t,{from:o,to:r,empty:a}=n,s=a?"":t.doc.textBetween(o,r," "),c=n instanceof Object&&"node"in n,l=s.length>0,d=e.isActive("bold"),p=e.isActive("italic"),x=e.isActive("underline"),h=e.isActive("strike"),b=e.isActive("code"),f=e.isActive("link"),g=f?e.getAttributes("link").href:null;return{hasSelection:!a||c,isEmpty:a&&!c,hasTextContent:l,isNodeSelection:c,selectedText:s,from:o,to:r,isBold:d,isItalic:p,isUnderline:x,isStrike:h,isCode:b,hasLink:f,linkHref:g}}function tl(e){return e.state.selection.empty}function Mt(e){const t=cn(e);return t.isEmpty?!1:!!t.hasTextContent}function nl(e){if(typeof window>"u")return null;const{view:t}=e,{from:n,to:o}=t.state.selection;if(n===o)return null;const r=t.coordsAtPos(n),a=t.coordsAtPos(o),s=Math.min(r.top,a.top),c=Math.max(r.bottom,a.bottom),l=Math.min(r.left,a.left),d=Math.max(r.right,a.right);return{top:s,left:l,right:d,bottom:c,width:d-l,height:c-s}}function ol(e){return e.chain().focus().toggleBold().run()}function rl(e){return e.chain().focus().toggleItalic().run()}function al(e,t){return t?e.chain().focus().setLink({href:t}).run():e.chain().focus().unsetLink().run()}function il(e){return e.chain().focus().unsetLink().run()}function sl(e){return e.chain().focus().setParagraph().run()}function ll(e,t){return e.chain().focus().setHeading({level:t}).run()}function cl(e,t){return e.chain().focus().toggleHeading({level:t}).run()}function ul(e){return e.chain().focus().undo().run()}function dl(e){return e.chain().focus().redo().run()}function pl(e,t){return e.chain().focus(t).run()}function fl(e){return e.chain().focus().selectAll().run()}function hl(e){return e.chain().focus().unsetAllMarks().run()}function bl(e,t){return e.isActive(t)}function vl(e,t,n){return e.isActive(t,n)}function gl(e){const t=[];return e.isActive("bold")&&t.push("bold"),e.isActive("italic")&&t.push("italic"),e.isActive("link")&&t.push("link"),t}function ml(e){return e.getAttributes("link").href??null}function Co(e){return e?!e.isEditable:!0}function ft(e){return e?e.isEditable:!1}function xl(e){return ft(e)}function yl(e){return ft(e)}function wl(e){return ft(e)}function kl(e){return ft(e)}function Cl(e){return Co(e)?"pubwave-editor--readonly":""}const Et={editor:"Rich text editor",toolbar:"Text formatting toolbar",dragHandle:"Drag to reorder block"},Qe={bold:"Cmd+B",italic:"Cmd+I",underline:"Cmd+U",strike:"Cmd+Shift+X",code:"Cmd+E"};function Le(e,t){return t?`${e} (${t})`:e}const xe=m.forwardRef(({active:e=!1,disabled:t=!1,onClick:n,"data-tooltip":o,"data-testid":r,"aria-label":a,children:s,style:c},l)=>i.jsx("button",{ref:l,type:"button",className:Ee("pubwave-toolbar__button",e&&"pubwave-toolbar__button--active",t&&"pubwave-toolbar__button--disabled"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:(c==null?void 0:c.width)??"var(--pubwave-button-width, 28px)",height:(c==null?void 0:c.height)??"var(--pubwave-button-height, 28px)",minWidth:c==null?void 0:c.minWidth,padding:(c==null?void 0:c.padding)??0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:e?"var(--pubwave-primary)":"var(--pubwave-text)",cursor:t?"not-allowed":"pointer",opacity:t?.5:1,transition:"color 0.1s ease, background-color 0.1s ease",...c},onClick:d=>{d.preventDefault(),d.stopPropagation(),n()},disabled:t,"data-tooltip":o,"data-testid":r,"aria-label":a,"aria-pressed":e,onMouseDown:d=>{d.preventDefault(),d.stopPropagation()},children:s}));xe.displayName="ToolbarButton";function Rn(){return i.jsx("div",{className:"pubwave-toolbar__divider",style:{width:"var(--pubwave-divider-width, 1px)",height:"var(--pubwave-divider-height, 20px)",backgroundColor:"var(--pubwave-border)",margin:"0 var(--pubwave-spacing-1, 4px)"},role:"separator","aria-orientation":"vertical"})}function Lo(e,t,n,o=8){const r=e,a=window.innerHeight-t,s=n+o;return r>=s?"top":a>=s?"bottom":r>=a?"top":"bottom"}function Ll(e,t,n=8){return Lo(e.top,e.bottom,t,n)}function To(e,t,n,o="left",r=8){const a=window.innerWidth,s=(e+t)/2,c=e,l=a-t,d=n+r,p=n+r,x=n/2+r;let h=o,b;return o==="left"?(b=e,(b<r||b+n>a-r)&&(l>=p&&t+n<=a-r?(h="right",b=t-n):c>=x&&s-n/2>=r?(h="center",b=s-n/2):(l>=c?(h="right",b=t-n):(h="left",b=e),b=Math.max(r,Math.min(b,a-n-r))))):o==="center"?(b=s-n/2,(b<r||b+n>a-r)&&(l>=p&&t+n<=a-r?(h="right",b=t-n):c>=d&&e+n<=a-r?(h="left",b=e):(l>=c?(h="right",b=t-n):(h="left",b=e),b=Math.max(r,Math.min(b,a-n-r))))):(b=t-n,(b<r||b+n>a-r)&&(c>=d&&e+n<=a-r?(h="left",b=e):c>=x&&s-n/2>=r?(h="center",b=s-n/2):(c>=l?(h="left",b=e):(h="right",b=t-n),b=Math.max(r,Math.min(b,a-n-r))))),b=Math.max(r,Math.min(b,a-n-r)),{align:h,left:b}}function Tl(e,t,n="left",o=8){return To(e.left,e.right,t,n,o)}function un({isOpen:e,buttonRef:t,children:n,className:o,style:r,align:a="left",margin:s=8,onClickOutside:c,onClick:l,"data-testid":d}){const[p,x]=m.useState("top"),[h,b]=m.useState(null),f=m.useRef(null);if(m.useEffect(()=>{if(!e||!t.current)return;const L=()=>{if(!f.current||!t.current)return;const M=t.current.getBoundingClientRect(),C=f.current.offsetHeight||300,u=f.current.offsetWidth||240,j=Ll(M,C,s);x(j);let w=t.current.parentElement;for(;w;){const P=window.getComputedStyle(w);if(P.position==="relative"||P.position==="absolute"||P.position==="fixed")break;w=w.parentElement}const S=Tl(M,u,a,s);if(w){const P=w.getBoundingClientRect(),R=S.left-P.left;b({align:S.align,left:R})}else b(S)};L();const k=requestAnimationFrame(()=>{L()});return()=>cancelAnimationFrame(k)},[e,t,s,a]),m.useEffect(()=>{if(!e||!c)return;const L=k=>{f.current&&!f.current.contains(k.target)&&t.current&&!t.current.contains(k.target)&&c(k)};return document.addEventListener("mousedown",L),()=>{document.removeEventListener("mousedown",L)}},[e,c,t]),!e)return null;const g=()=>{if(h)return{left:`${h.left}px`};switch(a){case"center":return{left:"50%",transform:"translateX(-50%)"};case"right":return{right:0};case"left":default:return{left:0}}};return i.jsx("div",{ref:f,className:o,"data-testid":d,style:{position:"absolute",...p==="top"?{bottom:"100%",marginBottom:`${s}px`}:{top:"100%",marginTop:`${s}px`},...g(),...r},onClick:L=>{L.stopPropagation(),l==null||l(L)},children:n})}function Bl({editor:e,isOpen:t,onToggle:n,onClose:o}){const r=Oe(),a=m.useRef(null),s=m.useCallback(()=>e.isActive("heading",{level:1})?"heading1":e.isActive("heading",{level:2})?"heading2":e.isActive("heading",{level:3})?"heading3":e.isActive("bulletList")?"bulletList":e.isActive("orderedList")?"orderedList":e.isActive("taskList")?"taskList":e.isActive("blockquote")?"blockquote":e.isActive("codeBlock")?"codeBlock":"paragraph",[e]),c=m.useMemo(()=>[{id:"paragraph",label:r.toolbar.blockTypes.text,icon:i.jsx(Un,{}),action:h=>h.chain().focus().setParagraph().run(),isActive:h=>h.isActive("paragraph")},{id:"heading1",label:r.toolbar.blockTypes.heading1,icon:i.jsx(Fn,{}),action:h=>h.chain().focus().setHeading({level:1}).run(),isActive:h=>h.isActive("heading",{level:1})},{id:"heading2",label:r.toolbar.blockTypes.heading2,icon:i.jsx(Wn,{}),action:h=>h.chain().focus().setHeading({level:2}).run(),isActive:h=>h.isActive("heading",{level:2})},{id:"heading3",label:r.toolbar.blockTypes.heading3,icon:i.jsx(Vn,{}),action:h=>h.chain().focus().setHeading({level:3}).run(),isActive:h=>h.isActive("heading",{level:3})},{id:"bulletList",label:r.toolbar.blockTypes.bulletedList,icon:i.jsx(Gn,{}),action:h=>h.chain().focus().toggleBulletList().run(),isActive:h=>h.isActive("bulletList")},{id:"orderedList",label:r.toolbar.blockTypes.numberedList,icon:i.jsx(Yn,{}),action:h=>h.chain().focus().toggleOrderedList().run(),isActive:h=>h.isActive("orderedList")}],[r]),l=s(),d=c.find(h=>h.id===l),p=m.useCallback(h=>{h.action(e),o(),setTimeout(()=>{e.chain().blur().run()},0)},[e,o]),x=h=>h===r.toolbar.blockTypes.heading1?r.toolbar.blockTypes.heading1:h===r.toolbar.blockTypes.heading2?r.toolbar.blockTypes.heading2:h===r.toolbar.blockTypes.heading3?r.toolbar.blockTypes.heading3:h===r.toolbar.blockTypes.bulletedList?r.toolbar.blockTypes.bulletedList:h===r.toolbar.blockTypes.numberedList?r.toolbar.blockTypes.numberedList:r.toolbar.blockTypes.text;return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(xe,{ref:a,active:t,onClick:n,"data-tooltip":Le(r.toolbar.turnInto),"data-testid":"toolbar-turnInto","aria-label":r.aria.turnIntoButton,style:{width:"auto",minWidth:"auto",padding:"0 8px",height:"var(--pubwave-button-height, 28px)"},children:i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"4px",whiteSpace:"nowrap"},children:[i.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:d?x(d.label):r.toolbar.blockTypes.text}),i.jsx(Ga,{})]})}),i.jsxs(un,{isOpen:t,buttonRef:a,align:"left",margin:8,onClickOutside:()=>o(),className:"pubwave-turn-into-dropdown","data-testid":"turn-into-dropdown",style:{backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",padding:"var(--pubwave-spacing-1, 4px)",minWidth:"240px",zIndex:E.zIndex.dropdown+1},children:[i.jsx("div",{style:St,children:r.toolbar.turnInto}),c.map(h=>{const b=h.isActive(e);return i.jsxs("button",{type:"button",className:Ee("pubwave-toolbar__turn-into-option",b&&"pubwave-toolbar__turn-into-option--active"),onClick:()=>p(h),style:{width:"100%",display:"flex",alignItems:"center",gap:"var(--pubwave-spacing-2, 8px)",padding:"var(--pubwave-spacing-2, 8px) var(--pubwave-spacing-3, 12px)",border:"none",backgroundColor:b?"var(--pubwave-primary-faded)":"transparent",color:b?"var(--pubwave-primary)":"var(--pubwave-text)",cursor:"pointer",fontSize:"var(--pubwave-font-size-base, 14px)",textAlign:"left",borderRadius:"var(--pubwave-border-radius-sm, 0.25rem)",transition:"background-color 0.1s ease"},children:[i.jsx("span",{style:{display:"flex",alignItems:"center",width:"18px",height:"18px",flexShrink:0},children:h.icon}),i.jsx("span",{children:h.label})]},h.id)})]})]})}function be(e){return!!(e&&!e.isDestroyed)}function Al(e,t){be(e)&&Y(()=>{if(be(e))switch(t){case"start":e.commands.focus("start");break;case"end":e.commands.focus("end");break;case"preserve":e.commands.focus();break;default:typeof t=="number"&&(e.commands.setTextSelection(t),e.commands.focus())}})}function Ae(e){be(e)&&Y(()=>{be(e)&&(e.isFocused||e.commands.focus())})}function jl(e,t){be(e)&&(t.preventDefault(),Y(()=>{be(e)&&e.commands.focus()}))}function Sl(e){if(!be(e))return function(){};const t=o=>{const r=o.relatedTarget;if(r){const a=e.view.dom.closest(".pubwave-editor");a&&!a.contains(r)&&r.closest(".pubwave-toolbar, .pubwave-menu, .pubwave-dialog")}},n=e.view.dom;return n.addEventListener("focusout",t),()=>{n.removeEventListener("focusout",t)}}function Bo(e){if(!be(e))return null;const{from:t,to:n,empty:o}=e.state.selection;return{from:t,to:n,empty:o}}function tt(e,t){if(!be(e)||!t)return;const{from:n,to:o}=t,r=e.state.doc.content.size,a=Math.min(n,r),s=Math.min(o,r);e.commands.setTextSelection({from:a,to:s})}function Ml(e){if(!be(e))return;const{selection:t}=e.state;if(t.$anchor.pos>0){e.commands.focus();return}e.commands.focus("end")}function Pl(e){const t=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=t[0],o=t[t.length-1],r=a=>{a.key==="Tab"&&(a.shiftKey?document.activeElement===n&&(a.preventDefault(),o==null||o.focus()):document.activeElement===o&&(a.preventDefault(),n==null||n.focus()))};return{activate(){e.addEventListener("keydown",r),n==null||n.focus()},deactivate(){e.removeEventListener("keydown",r)}}}function Dl({editor:e,isOpen:t,onToggle:n,onClose:o,selectionState:r}){const a=Oe(),s=m.useRef(null),c=m.useRef(null),l=m.useRef(null),d=m.useRef([]),p=m.useRef(null),[x,h]=m.useState(""),b=(r==null?void 0:r.hasLink)??!1,f=(r==null?void 0:r.linkHref)??null;m.useEffect(()=>{t?(p.current=Bo(e),h(f||""),setTimeout(()=>{var C,u;(C=c.current)==null||C.focus(),(u=c.current)==null||u.select()},50)):p.current=null},[t,f,e]),m.useEffect(()=>{if(!ut()){if(!t){d.current.forEach(C=>C.destroy()),d.current=[];return}return d.current.forEach(C=>C.destroy()),d.current=[],Y(()=>{Y(()=>{if(!l.current)return;l.current.querySelectorAll("[data-tooltip]").forEach(u=>{const j=u.getAttribute("data-tooltip");if(j){const w=Be(u,{content:j,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});d.current.push(w)}})})}),()=>{d.current.forEach(C=>C.destroy()),d.current=[]}}},[t,a,x,f]);const g=m.useCallback(C=>{if(C==null||C.preventDefault(),!x.trim()){p.current&&tt(e,p.current),e.chain().focus().unsetLink().run(),p.current&&Y(()=>{Y(()=>{tt(e,p.current)})}),o();return}let u=x.trim();!/^https?:\/\//i.test(u)&&!u.startsWith("/")&&!u.startsWith("#")&&(u=`https://${u}`),p.current&&tt(e,p.current),e.chain().focus().setLink({href:u}).run(),p.current&&Y(()=>{Y(()=>{tt(e,p.current)})}),o()},[e,x,o]),L=m.useCallback(()=>{const C=x.trim()||f;if(C){let u=C;!/^https?:\/\//i.test(u)&&!u.startsWith("/")&&!u.startsWith("#")&&(u=`https://${u}`),window.open(u,"_blank","noopener,noreferrer")}},[x,f]),k=m.useCallback(()=>{var C;h(""),(C=c.current)==null||C.focus()},[]),M=m.useCallback(C=>{C.key==="Enter"?(C.preventDefault(),g()):C.key==="Escape"&&(C.preventDefault(),o(),e.chain().focus().run())},[g,o,e]);return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(xe,{ref:s,active:b,onClick:n,"data-tooltip":Le(a.toolbar.link),"data-testid":"toolbar-link","aria-label":a.aria.linkButton,children:i.jsx(Qa,{})}),i.jsx(un,{isOpen:t,buttonRef:s,align:"left",margin:8,onClickOutside:()=>o(),className:"pubwave-link-dropdown",style:{backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))",padding:"var(--pubwave-spacing-2, 8px)",minWidth:"280px",zIndex:E.zIndex.dropdown+1},children:i.jsx("div",{ref:l,children:i.jsx("form",{onSubmit:g,style:{display:"flex",flexDirection:"column",gap:"8px"},children:i.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[i.jsx("input",{ref:c,type:"text",value:x,onChange:C=>h(C.target.value),onKeyDown:M,placeholder:a.linkPlaceholder,"data-testid":"link-input","aria-label":a.aria.linkUrlInput,style:{flex:1,padding:"6px 100px 6px 8px",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-sm, 4px)",fontSize:"var(--pubwave-font-size-base, 14px)",backgroundColor:"var(--pubwave-bg)",color:"var(--pubwave-text)",outline:"none"}}),i.jsxs("div",{style:{position:"absolute",right:"4px",display:"flex",alignItems:"center",gap:"2px"},children:[i.jsx("button",{type:"button",onClick:g,"data-tooltip":a.toolbar.confirmLink,"data-testid":"link-confirm-button","aria-label":a.aria.linkConfirmButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent"},children:i.jsx(ti,{})}),(x.trim()||f)&&i.jsx("button",{type:"button",onClick:L,"data-tooltip":a.toolbar.openLink,"data-testid":"link-open-button","aria-label":a.aria.linkOpenButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent"},children:i.jsx(ei,{})}),i.jsx("button",{type:"button",onClick:k,"data-tooltip":a.toolbar.clearLink,"data-testid":"link-clear-button","aria-label":a.aria.linkClearButton,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",borderRadius:"var(--pubwave-radius-sm, 4px)",backgroundColor:"transparent",color:"var(--pubwave-text)",cursor:"pointer",transition:"background-color 0.1s ease"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor="var(--pubwave-hover, rgba(0, 0, 0, 0.05))"},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent"},children:i.jsx(ni,{})})]})]})})})})]})}const Il=[{name:"Default",value:null,color:"#1f2937"},{name:"Gray",value:"#6b7280",color:"#6b7280"},{name:"Brown",value:"#92400e",color:"#92400e"},{name:"Orange",value:"#ea580c",color:"#ea580c"},{name:"Orange Dark",value:"#c2410c",color:"#c2410c"},{name:"Green",value:"#16a34a",color:"#16a34a"},{name:"Blue",value:"#2563eb",color:"#2563eb"},{name:"Purple",value:"#9333ea",color:"#9333ea"},{name:"Pink",value:"#ec4899",color:"#ec4899"},{name:"Red",value:"#dc2626",color:"#dc2626"}],Rl=[{name:"Default",value:null,color:"#ffffff"},{name:"Gray",value:"#f3f4f6",color:"#f3f4f6"},{name:"Peach",value:"#fed7aa",color:"#fed7aa"},{name:"Orange",value:"#fdba74",color:"#fdba74"},{name:"Yellow",value:"#fde047",color:"#fde047"},{name:"Green",value:"#86efac",color:"#86efac"},{name:"Blue",value:"#93c5fd",color:"#93c5fd"},{name:"Purple",value:"#c084fc",color:"#c084fc"},{name:"Pink",value:"#f9a8d4",color:"#f9a8d4"},{name:"Red",value:"#fca5a5",color:"#fca5a5"}],Ao="pubwave-editor-recent-colors",On=5;function Ol(){if(typeof window>"u")return[];try{const e=localStorage.getItem(Ao);if(e)return JSON.parse(e)}catch{}return[]}function En(e){if(!(typeof window>"u"))try{localStorage.setItem(Ao,JSON.stringify(e))}catch{}}function El({editor:e,onClose:t,buttonRef:n}){const o=Oe(),[r,a]=m.useState([]),s=m.useRef(null),c=m.useRef([]);m.useEffect(()=>{const f=Ol();f.length>0&&a(f)},[]);const l=()=>{try{const f=e.getAttributes("textColor");return(f==null?void 0:f.color)||null}catch{return null}},d=()=>{try{const f=e.getAttributes("backgroundColor");return(f==null?void 0:f.backgroundColor)||null}catch{return null}},p=l(),x=d(),h=f=>{f===null?e.chain().focus().unsetColor().run():(e.chain().focus().setColor(f).run(),a(g=>{const k=[{type:"text",value:f},...g.filter(M=>!(M.type==="text"&&M.value===f))].slice(0,On);return En(k),k}))},b=f=>{f===null?e.chain().focus().unsetBackgroundColor().run():(e.chain().focus().setBackgroundColor(f).run(),a(g=>{const k=[{type:"background",value:f},...g.filter(M=>!(M.type==="background"&&M.value===f))].slice(0,On);return En(k),k}))};return m.useEffect(()=>{if(!ut()&&s.current)return c.current.forEach(f=>f.destroy()),c.current=[],requestAnimationFrame(()=>{if(!s.current)return;s.current.querySelectorAll("[data-tooltip]").forEach(g=>{const L=g.getAttribute("data-tooltip");if(L){const k=Be(g,{content:L,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});c.current.push(k)}})}),()=>{c.current.forEach(f=>f.destroy()),c.current=[]}},[r,p,x,o]),i.jsx(un,{isOpen:!0,buttonRef:n,align:"center",margin:8,onClickOutside:()=>t==null?void 0:t(),className:"pubwave-color-picker","data-testid":"color-picker",style:{backgroundColor:"var(--pubwave-bg, #ffffff)",border:"1px solid var(--pubwave-border, #e5e7eb)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1))",padding:"12px",minWidth:"240px",zIndex:E.zIndex.dropdown+1},children:i.jsxs("div",{ref:s,children:[r.length>0&&i.jsxs("div",{style:{marginBottom:"16px"},children:[i.jsx("div",{style:{...St,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.recentlyUsed}),i.jsx("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:r.map((f,g)=>i.jsx("button",{type:"button",onClick:()=>{f.type==="text"?h(f.value):b(f.value)},style:{width:"24px",height:"24px",borderRadius:"4px",border:"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:f.type==="background"?f.value:"#ffffff",cursor:"pointer",padding:f.type==="text"?"4px":0,display:f.type==="text"?"flex":"block",alignItems:f.type==="text"?"center":"normal",justifyContent:f.type==="text"?"center":"normal"},"data-tooltip":f.type==="text"?`${f.value} text`:`${f.value} background`,children:f.type==="text"&&i.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:f.value,lineHeight:1},children:"A"})},`${f.type}-${f.value}-${g}`))})]}),i.jsxs("div",{style:{marginBottom:"16px"},children:[i.jsx("div",{style:{...St,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.textColor}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"6px"},children:Il.map(f=>{const g=p===f.value;return i.jsx("button",{type:"button",onClick:()=>h(f.value),style:{width:"100%",aspectRatio:"1",borderRadius:"4px",border:g?"2px solid var(--pubwave-primary, #3b82f6)":"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:"#ffffff",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center"},"data-tooltip":f.value?`${f.name} text`:"Default text",children:i.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:f.color},children:"A"})},f.name)})})]}),i.jsxs("div",{children:[i.jsx("div",{style:{...St,paddingLeft:0,paddingRight:0,marginBottom:"8px"},children:o.toolbar.backgroundColor}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"6px"},children:Rl.map(f=>{const g=x===f.value;return i.jsx("button",{type:"button",onClick:()=>b(f.value),style:{width:"100%",aspectRatio:"1",borderRadius:"4px",border:g?"2px solid var(--pubwave-primary, #3b82f6)":"1px solid var(--pubwave-border, #e5e7eb)",backgroundColor:f.color,cursor:"pointer",padding:0},"data-tooltip":f.value?`${f.name} background`:"Default background"},f.name)})})]})]})})}function _l({editor:e,isOpen:t,onToggle:n,onClose:o}){const r=Oe(),a=m.useRef(null),s=()=>{try{const f=e.getAttributes("textColor");return(f==null?void 0:f.color)||null}catch{return null}},c=()=>{try{if(!e.isActive("backgroundColor"))return null;const f=e.getAttributes("backgroundColor");return(f==null?void 0:f.backgroundColor)||null}catch{return null}},l=s(),d=c(),p=l||d,h=l||(()=>{if(typeof window>"u")return"#1f2937";const f=document.querySelector(".pubwave-editor");return f&&window.getComputedStyle(f).getPropertyValue("--pubwave-text").trim()||"#1f2937"})(),b=d;return i.jsxs("div",{style:{position:"relative"},children:[i.jsx(xe,{ref:a,active:!!p,onClick:n,"data-tooltip":Le(r.toolbar.textColor),"data-testid":"toolbar-colorPicker","aria-label":r.aria.colorPickerButton,children:i.jsx(oi,{textColor:h,backgroundColor:b})}),t&&i.jsx(El,{editor:e,onClose:o,buttonRef:a})]})}function Nl({editor:e,selectionState:t}){const n=Oe(),[o,r]=m.useState(null),a=m.useCallback(()=>{r(null),e.chain().focus().toggleBold().run()},[e]),s=m.useCallback(()=>{r(null),e.chain().focus().toggleItalic().run()},[e]),c=m.useCallback(()=>{r(null),e.chain().focus().toggleUnderline().run()},[e]),l=m.useCallback(()=>{r(null),e.chain().focus().toggleStrike().run()},[e]),d=m.useCallback(()=>{r(null),e.chain().focus().toggleCode().run()},[e]),p=m.useCallback(()=>{r(M=>M==="turnInto"?null:"turnInto")},[]),x=m.useCallback(()=>{r(M=>M==="link"?null:"link")},[]),h=m.useCallback(()=>{r(M=>M==="colorPicker"?null:"colorPicker")},[]),b=(t==null?void 0:t.isBold)??!1,f=(t==null?void 0:t.isItalic)??!1,g=(t==null?void 0:t.isUnderline)??!1,L=(t==null?void 0:t.isStrike)??!1,k=(t==null?void 0:t.isCode)??!1;return i.jsxs(i.Fragment,{children:[i.jsx(Bl,{editor:e,isOpen:o==="turnInto",onToggle:p,onClose:()=>r(null)}),i.jsx(Rn,{}),i.jsx(xe,{active:b,onClick:a,"data-tooltip":Le(n.toolbar.bold,Qe.bold),"data-testid":"toolbar-bold","aria-label":n.aria.boldButton,children:i.jsx(Ya,{})}),i.jsx(xe,{active:f,onClick:s,"data-tooltip":Le(n.toolbar.italic,Qe.italic),"data-testid":"toolbar-italic","aria-label":n.aria.italicButton,children:i.jsx(Ka,{})}),i.jsx(xe,{active:g,onClick:c,"data-tooltip":Le(n.toolbar.underline,Qe.underline),"data-testid":"toolbar-underline","aria-label":n.aria.underlineButton,children:i.jsx(Xa,{})}),i.jsx(xe,{active:L,onClick:l,"data-tooltip":Le(n.toolbar.strike,Qe.strike),"data-testid":"toolbar-strike","aria-label":n.aria.strikeButton,children:i.jsx(Ja,{})}),i.jsx(xe,{active:k,onClick:d,"data-tooltip":Le(n.toolbar.code,Qe.code),"data-testid":"toolbar-code","aria-label":n.aria.codeButton,children:i.jsx(Za,{})}),i.jsx(Rn,{}),i.jsx(Dl,{editor:e,isOpen:o==="link",onToggle:x,onClose:()=>r(null),selectionState:t}),i.jsx(_l,{editor:e,isOpen:o==="colorPicker",onToggle:h,onClose:()=>r(null)})]})}const et=8;function Me(e){return!e.isDestroyed}function Hl(e,t){if(!t)return{top:0,left:0,visible:!1};const{view:n}=e,{from:o,to:r}=n.state.selection,a=n.coordsAtPos(o),s=n.coordsAtPos(r),c=Math.min(a.top,s.top),l=Math.min(a.left,s.left),d=Math.max(a.right,s.right),p=t.getBoundingClientRect(),x=p.width,h=p.height,b=Math.max(a.bottom,s.bottom),f=Lo(c,b,h,et);let g;f==="top"?g=c-h-et:g=b+et;const k=To(l,d,x,"center",et).left,M=window.innerWidth,C=window.innerHeight,u=et,j=Math.max(u,Math.min(k,M-x-u));return{top:Math.max(u,Math.min(g,C-h-u)),left:j,visible:!0}}function jo({editor:e,className:t,children:n,onVisibilityChange:o}){const r=m.useRef(null),a=m.useRef(!1),s=m.useRef(0),c=m.useRef(!1),[l,d]=m.useState({top:0,left:0,visible:!1}),[p,x]=m.useState(null),[h,b]=m.useState(!1),f=m.useRef([]),g=m.useMemo(()=>!Me(e)||a.current||!h?!1:Mt(e),[e,p,h]),L=m.useCallback(()=>{if(!Me(e))return;const C=cn(e);x(C)},[e]),k=m.useCallback(()=>{if(!g||!r.current){d(C=>({...C,visible:!1}));return}Y(()=>{if(!Me(e))return;const C=Hl(e,r.current);d(C)})},[e,g]);m.useEffect(()=>{if(!Me(e))return;const u=e.view.dom.closest(".pubwave-editor"),j=S=>{const P=S.target,R=r.current;if(R&&P&&R.contains(P)){a.current=!1;return}u&&P&&u.contains(P)?c.current=!0:c.current=!1,a.current=!0,b(!1)},w=S=>{const P=Date.now(),B=P-s.current<300;s.current=P;const v=S.target,T=r.current;if(T&&v&&T.contains(v)){a.current=!1;return}if(a.current=!1,!c.current){b(!1);return}setTimeout(()=>{Me(e)&&(Mt(e)?(L(),b(!0),Y(()=>{k()})):(b(!1),d(_=>({..._,visible:!1}))))},B?100:10)};return document.addEventListener("mousedown",j),document.addEventListener("mouseup",w),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("mouseup",w)}},[e,L,k]),m.useEffect(()=>{if(!Me(e))return;L();const C=()=>{!a.current&&h&&L()},u=()=>{a.current||(L(),Mt(e)?b(!0):b(!1),Y(()=>{k()}))},j=()=>{setTimeout(()=>{const w=document.activeElement,S=r.current;S&&w&&S.contains(w)||(b(!1),C())},0)};return e.on("update",C),e.on("selectionUpdate",u),e.on("focus",u),e.on("blur",j),()=>{e.off("update",C),e.off("selectionUpdate",u),e.off("focus",u),e.off("blur",j)}},[e,L,k,h]),m.useEffect(()=>{k(),o==null||o(g)},[g,k,o]),m.useEffect(()=>{if(!g)return;const C=()=>{k()};return window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[g,k]);const M=Oe();return m.useEffect(()=>{if(!ut()){if(!g||!l.visible||!r.current){f.current.forEach(C=>C.destroy()),f.current=[];return}return f.current.forEach(C=>C.destroy()),f.current=[],Y(()=>{if(!r.current)return;r.current.querySelectorAll("[data-tooltip]").forEach(u=>{const j=u.getAttribute("data-tooltip");if(j){const w=Be(u,{content:j,placement:"top",delay:[300,0],duration:[200,150],theme:"light-border"});f.current.push(w)}})}),()=>{f.current.forEach(C=>C.destroy()),f.current=[]}}},[g,l.visible,M]),Me(e)?i.jsx("div",{ref:r,className:Ee("pubwave-toolbar",g&&l.visible?"pubwave-toolbar--visible":"pubwave-toolbar--hidden",t),style:{position:"fixed",top:l.top,left:l.left,zIndex:E.zIndex.toolbar,opacity:g&&l.visible?1:0,pointerEvents:g&&l.visible?"auto":"none",transform:g&&l.visible?"translateY(0)":"translateY(4px)",transition:`opacity ${E.transition.fast}, transform ${E.transition.fast}`,isolation:"isolate"},role:"toolbar","aria-label":Et.toolbar,"aria-hidden":!g||!l.visible,"data-testid":"bubble-toolbar",children:i.jsx("div",{className:"pubwave-toolbar__content",style:{display:"flex",alignItems:"center",gap:0,padding:"var(--pubwave-spacing-1, 4px)",backgroundColor:"var(--pubwave-surface, var(--pubwave-bg))",color:"var(--pubwave-text)",border:"1px solid var(--pubwave-border)",borderRadius:"var(--pubwave-radius-lg, 8px)",boxShadow:"var(--pubwave-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))"},children:n??i.jsx(Nl,{editor:e,selectionState:p})})}):null}const $l=768;function zl(e,t,n){if(!e||!(e instanceof Node))return null;try{const o=n.view.posAtDOM(e,0),r=n.state.doc.resolve(o);if(r.depth>=1){const a=r.node(1);if(["taskList","bulletList","orderedList","blockquote"].includes(a.type.name)){const c=n.view.nodeDOM(r.before(1));if(c&&t.contains(c))return c}}for(let a=r.depth;a>0;a--)if(r.node(a).isBlock){const c=r.before(a),l=n.view.nodeDOM(c);if(l&&t.contains(l))return l}}catch{let r=e instanceof HTMLElement?e:e.parentElement;for(;r&&r.parentElement;){if(r.parentElement===t)return r;r=r.parentElement}}return null}function So({editor:e}){const t=m.useRef(null),n=m.useRef(null),o=m.useRef(!1),r=m.useRef(null),[a,s]=m.useState(!1),[c,l]=m.useState(!1),[d,p]=m.useState({top:0}),[x,h]=m.useState(!1),[b,f]=m.useState(!1);m.useEffect(()=>{const w=()=>{h(ut()),f(window.innerWidth<$l)};return w(),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w)}},[]);const g=m.useCallback(()=>{const w=t.current,S=n.current;if(!w||!S)return;const P=w.closest(".pubwave-editor");if(!P)return;P.offsetHeight;const R=P.getBoundingClientRect();let B=14,v=S;["UL","OL","BLOCKQUOTE"].includes(S.tagName)&&S.firstElementChild instanceof HTMLElement&&(v=S.firstElementChild),v.offsetHeight;const T=v.getBoundingClientRect();try{const _=window.getComputedStyle(v),H=_.lineHeight;if(H&&H!=="normal"){const z=parseFloat(H);isNaN(z)||(B=z/2)}else{const z=parseFloat(_.fontSize);isNaN(z)||(B=z*1.5/2)}}catch{}const A=T.top-R.top+B;!isNaN(A)&&isFinite(A)&&A>=0&&p({top:A})},[]),L=m.useCallback(w=>{n.current=w,s(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{g()})})},[g]),k=m.useCallback(()=>{o.current||(n.current=null,s(!1))},[]),M=m.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);m.useEffect(()=>{const w=e.view.dom,S=w.closest(".pubwave-editor");if(!S)return;const P=T=>{if(o.current)return;const A=T.target;if(!A||(M(),A.closest(".pubwave-block-handle"))||!w.contains(A))return;const _=zl(A,w,e);_&&(_!==n.current?L(_):s(!0))},R=T=>{if(o.current)return;const A=T.relatedTarget;if(!A){M(),r.current=setTimeout(()=>{k()},150);return}A.closest(".pubwave-block-handle")||w.contains(A)||A.closest(".pubwave-editor")||(M(),r.current=setTimeout(()=>{k()},150))},B=()=>{o.current||(M(),r.current=setTimeout(()=>{k()},150))};w.addEventListener("mouseover",P),w.addEventListener("mouseout",R),S.addEventListener("mouseleave",B);const v=({transaction:T})=>{T.docChanged&&!o.current&&k()};return e.on("transaction",v),()=>{w.removeEventListener("mouseover",P),w.removeEventListener("mouseout",R),S.removeEventListener("mouseleave",B),e.off("transaction",v),M()}},[e,L,k,M]),m.useEffect(()=>{a&&n.current&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{g()})})},[a,g]),m.useEffect(()=>{if(!a)return;const w=()=>{n.current&&g()};return window.addEventListener("scroll",w,!0),()=>window.removeEventListener("scroll",w,!0)},[a,g]);const C=m.useCallback(()=>{const w=n.current;if(w)try{const S=e.view.posAtDOM(w,0),P=e.state.doc.resolve(S);let R=S;for(let T=P.depth;T>0;T--)if(P.node(T).isBlock){R=P.start(T);break}const v=e.state.doc.resolve(R).after(1);e.chain().focus().insertContentAt(v,{type:"paragraph"}).setTextSelection(v+1).run(),setTimeout(()=>{e.commands.insertContent("/")},10)}catch(S){console.error("Failed to add block:",S)}},[e]),u=m.useCallback(w=>{const S=n.current;if(!S)return;o.current=!0,requestAnimationFrame(()=>{l(!0)});const P=e.view.posAtDOM(S,0),R=ct(e.state.doc,P);if(!R)return;const B=R.pos,v=`block-${B}`;ko(e,v,B),w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("application/x-pubwave-block",v),S.classList.add("pubwave-block--dragging");const T=S.cloneNode(!0);T.classList.add("pubwave-block--drag-preview"),T.style.opacity="1";const A=U=>{U.style.setProperty("color","#9b9a97","important"),U.style.setProperty("border-color","#9b9a97","important"),U.style.setProperty("--pubwave-text","#9b9a97","important"),Array.from(U.children).forEach(I=>{I instanceof HTMLElement&&A(I)})};A(T);const _=S.getBoundingClientRect();T.style.width=`${_.width}px`,T.style.position="static",T.style.transform="none";const H=document.createElement("div");H.className="pubwave-editor";const z=document.createElement("div");z.className="pubwave-editor__content";const F=document.createElement("div");F.className="ProseMirror",F.appendChild(T),z.appendChild(F),H.appendChild(z),H.style.position="absolute",H.style.top="-9999px",H.style.left="-9999px",document.body.appendChild(H),w.dataTransfer.setDragImage(T,0,0),setTimeout(()=>{document.body.removeChild(H)},0)},[e]),j=m.useCallback(()=>{o.current=!1,l(!1),n.current&&n.current.classList.remove("pubwave-block--dragging"),s(!1)},[]);return x||b||!a?null:i.jsxs("div",{ref:t,className:"pubwave-block-handle","data-testid":"block-handle",style:{position:"absolute",left:"calc(var(--pubwave-container-padding-left, 140px) - 80px)",top:`${d.top}px`,transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:"2px",pointerEvents:"auto",transition:`opacity ${E.transition.fast}`,zIndex:E.zIndex.dragHandle,opacity:a&&!c?1:0},onMouseEnter:w=>{w.stopPropagation(),r.current&&(clearTimeout(r.current),r.current=null)},onMouseLeave:w=>{w.stopPropagation();const S=w.relatedTarget;S!=null&&S.closest(".pubwave-editor")||(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{k()},150))},children:[i.jsx("button",{type:"button",className:"pubwave-block-handle__add",onClick:C,"data-testid":"add-block-button",style:{width:"var(--pubwave-button-width, 28px)",height:"var(--pubwave-button-height, 28px)",display:"flex",alignItems:"center",justifyContent:"center",border:"none",borderRadius:E.borderRadius.sm,background:"transparent",color:`var(--pubwave-text-muted, ${E.colors.textMuted})`,cursor:"pointer",transition:`background-color ${E.transition.fast}, color ${E.transition.fast}`},title:"Add block","aria-label":"Add block below",children:i.jsx(ql,{})}),i.jsx("div",{className:"pubwave-block-handle__drag",draggable:!0,onDragStart:u,onDragEnd:j,"data-testid":"drag-handle",style:{width:"44px",height:"44px",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:E.borderRadius.sm,background:"transparent",color:`var(--pubwave-text-muted, ${E.colors.textMuted})`,cursor:"grab",transition:`background-color ${E.transition.fast}, color ${E.transition.fast}`},role:"button",tabIndex:0,title:"Drag to move","aria-label":"Drag to reorder block",children:i.jsx(Ul,{})})]})}function ql(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),i.jsx("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]})}function Ul(){return i.jsxs("svg",{width:"12",height:"18",viewBox:"0 0 10 16",fill:"currentColor",children:[i.jsx("circle",{cx:"2",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"2",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"2",cy:"13",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"8",cy:"13",r:"1.5"})]})}function Mo({visible:e,position:t,className:n}){return i.jsxs("div",{className:Ee("pubwave-drop-indicator",e&&"pubwave-drop-indicator--visible",`pubwave-drop-indicator--${t}`,n),"data-testid":"drop-indicator",style:{position:"absolute",left:0,right:0,height:"2px",backgroundColor:`var(--pubwave-drop-indicator-color, ${E.colors.dropIndicator})`,borderRadius:"1px",...t==="before"?{top:"-1px"}:{bottom:"-1px"},opacity:e?1:0,transform:e?"scaleX(1)":"scaleX(0.8)",transition:`opacity ${E.transition.fast}, transform ${E.transition.fast}`,zIndex:10,pointerEvents:"none"},"aria-hidden":"true",children:[i.jsx(_n,{position:"left",visible:e}),i.jsx(_n,{position:"right",visible:e})]})}function _n({position:e,visible:t}){return i.jsx("div",{className:`pubwave-drop-indicator__cap pubwave-drop-indicator__cap--${e}`,style:{position:"absolute",top:"50%",transform:"translateY(-50%)",...e==="left"?{left:"-4px"}:{right:"-4px"},width:"8px",height:"8px",borderRadius:"50%",backgroundColor:`var(--pubwave-drop-indicator-color, ${E.colors.dropIndicator})`,opacity:t?1:0,transition:`opacity ${E.transition.fast}`}})}function Fl({editor:e}){const[t,n]=m.useState(null),[o,r]=m.useState(null);return m.useEffect(()=>{const a=Z.getState(e.state);a&&n(a);const s=()=>{const c=Z.getState(e.state);c&&(c.dropTargetPos!==(t==null?void 0:t.dropTargetPos)||c.dropPosition!==(t==null?void 0:t.dropPosition))&&n(c)};return e.on("transaction",s),()=>{e.off("transaction",s)}},[e,t]),m.useEffect(()=>{if(!(t!=null&&t.dropTargetPos)||!t.dropPosition){r(null);return}const a=requestAnimationFrame(()=>{var b;const s=e.view,c=t.dropTargetPos;if(c===null)return;let l=s.nodeDOM(c);if(!l&&c>0){const f=s.domAtPos(c).node;f instanceof HTMLElement&&(l=f)}if(!l||!(l instanceof HTMLElement))return;const d=l.getBoundingClientRect(),p=(b=s.dom.closest(".pubwave-editor"))==null?void 0:b.getBoundingClientRect();if(!p)return;const x=8;let h=0;t.dropPosition==="before"?h=d.top-p.top-x:h=d.bottom-p.top+x,r({top:h,left:d.left-p.left,width:d.width})});return()=>cancelAnimationFrame(a)},[t,e]),!(t!=null&&t.dropTargetPos)||!t.dropPosition||!o?null:i.jsx("div",{style:{position:"absolute",top:o.top,left:o.left,width:o.width,height:"2px",pointerEvents:"none",zIndex:50},children:i.jsx(Mo,{visible:!0,position:t.dropPosition,className:"pubwave-drop-indicator--overlay"})})}const Wl=m.forwardRef(function(t,n){const{content:o,editable:r=!0,placeholder:a,theme:s,autofocus:c=!1,imageUpload:l,onChange:d,onSelectionChange:p,onFocus:x,onBlur:h,onReady:b,className:f,width:g,height:L,minHeight:k,"data-testid":M="pubwave-editor"}=t,C=At(s==null?void 0:s.locale),u=a??C.placeholder??'Write,type "/" for commands...',j=ye.useEditor({extensions:ln({placeholder:u,headingLevels:[1,2,3],linkOpenInNewTab:!0,linkOpenOnClick:!0,imageUpload:l,locale:s==null?void 0:s.locale}),content:o,editable:r,autofocus:c,immediatelyRender:!1,editorProps:{attributes:{class:`pubwave-editor__content ${(s==null?void 0:s.contentClassName)??""}`.trim(),"data-placeholder":u}},onUpdate:({editor:v})=>{d==null||d(v.getJSON())},onSelectionUpdate:()=>{p==null||p()},onFocus:()=>{x==null||x()},onBlur:()=>{h==null||h()},onCreate:({editor:v})=>{const T=w(v);b==null||b(T)}}),w=m.useCallback(v=>({getState:()=>({selection:{hasSelection:!(v!=null&&v.state.selection.empty),isMultiBlock:!1,from:(v==null?void 0:v.state.selection.from)??0,to:(v==null?void 0:v.state.selection.to)??0,isEmpty:(v==null?void 0:v.state.selection.empty)??!0},marks:{isBold:(v==null?void 0:v.isActive("bold"))??!1,isItalic:(v==null?void 0:v.isActive("italic"))??!1,isLink:(v==null?void 0:v.isActive("link"))??!1,linkHref:v?v.getAttributes("link").href:void 0},isFocused:(v==null?void 0:v.isFocused)??!1,isEditable:(v==null?void 0:v.isEditable)??!1,isEmpty:(v==null?void 0:v.isEmpty)??!0,characterCount:0}),getJSON:()=>(v==null?void 0:v.getJSON())??{type:"doc",content:[]},getHTML:()=>(v==null?void 0:v.getHTML())??"",getText:()=>(v==null?void 0:v.getText())??"",setContent:T=>v==null?void 0:v.commands.setContent(T),clearContent:()=>v==null?void 0:v.commands.clearContent(),setEditable:T=>v==null?void 0:v.setEditable(T),focus:T=>{T==="start"?v==null||v.commands.focus("start"):T==="end"?v==null||v.commands.focus("end"):v==null||v.commands.focus()},blur:()=>v==null?void 0:v.commands.blur(),toggleBold:()=>v==null?void 0:v.chain().focus().toggleBold().run(),toggleItalic:()=>v==null?void 0:v.chain().focus().toggleItalic().run(),setLink:T=>{T?v==null||v.chain().focus().setLink({href:T}).run():v==null||v.chain().focus().unsetLink().run()},destroy:()=>v==null?void 0:v.destroy(),tiptapEditor:v??null}),[]);m.useImperativeHandle(n,()=>j?w(j):null,[j,w]);const[S,P]=m.useState(!1);m.useEffect(()=>{P(!0)},[]),m.useEffect(()=>{var T;if(!((T=j==null?void 0:j.view)!=null&&T.dom))return;const v=j.view.dom;v&&v.setAttribute("data-placeholder",u)},[j,u,s==null?void 0:s.locale]);const R=["pubwave-editor",(s==null?void 0:s.classNamePrefix)??"",(s==null?void 0:s.containerClassName)??"",j?Cl(j):"",L||k?"pubwave-editor--fixed-height":"",f].filter(Boolean).join(" "),B={position:"relative",overflow:L||k?"hidden":"visible",...L||k?{display:"flex",flexDirection:"column"}:{}};if(g&&(B["--pubwave-container-width"]=g,B.width=g,B["--pubwave-container-max-width"]=g,B.maxWidth=g),L&&(B["--pubwave-container-height"]=L,B.height=L),k&&(B["--pubwave-container-min-height"]=k,B.minHeight=k),s!=null&&s.colors){const{colors:v}=s,A=(v.text||"#1f2937").toLowerCase().trim(),_=A.startsWith("#f")||A.startsWith("#e")||A.includes("f1")||A.includes("f3")||A.includes("f0")||A.includes("fdf")||A.includes("ffb")||A.includes("ffc")||A.includes("ffd")||A.includes("ffe")||A.includes("fff")||A.includes("e0")||A.includes("e5")||A.includes("ecf")||A.includes("eef");v.background&&(v.background.includes("gradient")?(B.background=v.background,_?(B["--pubwave-surface"]="rgba(38, 38, 38, 0.95)",B["--pubwave-bg"]="#1a1a1a"):(B["--pubwave-surface"]="rgba(255, 255, 255, 0.95)",B["--pubwave-bg"]="#ffffff")):(B["--pubwave-bg"]=v.background,B["--pubwave-surface"]=v.background)),v.text&&(B["--pubwave-text"]=v.text),v.textMuted&&(B["--pubwave-text-muted"]=v.textMuted),v.border&&(B["--pubwave-border"]=v.border),v.primary&&(B["--pubwave-primary"]=v.primary),v.linkColor&&(B["--pubwave-link-color"]=v.linkColor),_?B["--pubwave-hover"]="rgba(255, 255, 255, 0.1)":B["--pubwave-hover"]="rgba(0, 0, 0, 0.05)"}if(s!=null&&s.backgroundImage){const v=s.backgroundImage,T=s.backgroundImageOptions||{};v.startsWith("url(")||v.includes("gradient")||v.includes("linear-gradient")||v.includes("radial-gradient")?B.backgroundImage=v:B.backgroundImage=`url(${v})`,T.repeat!==void 0?B.backgroundRepeat=T.repeat:B.backgroundRepeat="no-repeat",T.position!==void 0?B.backgroundPosition=T.position:B.backgroundPosition="center",T.size!==void 0?B.backgroundSize=T.size:B.backgroundSize="cover",T.attachment!==void 0?B.backgroundAttachment=T.attachment:B.backgroundAttachment="scroll"}return!S||!j?i.jsx(pn,{value:{locale:C},children:i.jsx("div",{className:R,"data-testid":M,role:"application","aria-label":Et.editor,style:B})}):i.jsx(pn,{value:{locale:C},children:i.jsxs("div",{className:R,"data-testid":M,role:"application","aria-label":Et.editor,style:B,children:[i.jsx(ye.EditorContent,{editor:j}),r&&i.jsx(jo,{editor:j}),r&&i.jsx(So,{editor:j}),r&&i.jsx(Fl,{editor:j})]})})});function _e(e){return!e.isDestroyed}function Po(e){if(!_e(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().toggleBold().run();return Ae(e),{success:t,message:t?"Bold toggled":"Could not toggle bold"}}function Do(e){if(!_e(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().toggleItalic().run();return Ae(e),{success:t,message:t?"Italic toggled":"Could not toggle italic"}}function Io(e,t){if(!_e(e))return{success:!1,message:"Editor not available"};if(!t.trim())return{success:!1,message:"URL is required"};let n=t.trim();!/^https?:\/\//i.test(n)&&!n.startsWith("/")&&(n=`https://${n}`);const o=e.chain().focus().setLink({href:n}).run();return Ae(e),{success:o,message:o?"Link added":"Could not add link"}}function Ro(e){if(!_e(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().unsetLink().run();return Ae(e),{success:t,message:t?"Link removed":"Could not remove link"}}function Oo(e,t=window.prompt.bind(window)){if(!_e(e))return{success:!1,message:"Editor not available"};if(e.isActive("link"))return Ro(e);const o=t("Enter URL:");return o?Io(e,o):(Ae(e),{success:!1,message:"Link cancelled"})}function Vl(e,t){if(!_e(e))return{success:!1,message:"Editor not available"};const n=e.chain().focus().setHeading({level:t}).run();Ae(e);const o=String(t);return{success:n,message:n?`Heading ${o} applied`:"Could not set heading"}}function Gl(e){if(!_e(e))return{success:!1,message:"Editor not available"};const t=e.chain().focus().setParagraph().run();return Ae(e),{success:t,message:t?"Paragraph applied":"Could not set paragraph"}}function Yl(e,t,n){return()=>{const o=t(e);n==null||n(o)}}const Kl=[{id:"bold",label:"Bold",shortcut:"Cmd+B",icon:"bold",action:Po,isActive:e=>e.isActive("bold")},{id:"italic",label:"Italic",shortcut:"Cmd+I",icon:"italic",action:Do,isActive:e=>e.isActive("italic")},{id:"link",label:"Link",icon:"link",action:e=>Oo(e),isActive:e=>e.isActive("link")}],Nn="44px",Hn="20px";function Xl({blockId:e,isHovered:t,isDragging:n=!1,onDragStart:o,onDragEnd:r,className:a}){const s=m.useRef(null),[c,l]=m.useState(!1),d=m.useCallback(f=>{if(f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",e),f.dataTransfer.setData("application/x-pubwave-block",e),s.current){const g=s.current.getBoundingClientRect();f.dataTransfer.setDragImage(s.current,g.width/2,g.height/2)}o==null||o(e,f)},[e,o]),p=m.useCallback(f=>{l(!1),r==null||r(e,f)},[e,r]),x=m.useCallback(()=>{l(!0)},[]),h=m.useCallback(()=>{l(!1)},[]),b=t||n;return i.jsx("div",{ref:s,className:Ee("pubwave-drag-handle",b&&"pubwave-drag-handle--visible",n&&"pubwave-drag-handle--dragging",c&&"pubwave-drag-handle--pressed",a),"data-testid":"drag-handle",style:{position:"absolute",left:"-32px",top:"50%",transform:"translateY(-50%)",width:Nn,height:Nn,display:"flex",alignItems:"center",justifyContent:"center",cursor:n?"grabbing":"grab",opacity:b?1:0,transition:`opacity ${E.transition.fast}`,userSelect:"none",WebkitUserSelect:"none"},draggable:!0,onDragStart:d,onDragEnd:p,onMouseDown:x,onMouseUp:h,role:"button","aria-label":Et.dragHandle,tabIndex:b?0:-1,children:i.jsx("div",{className:"pubwave-drag-handle__visual",style:{width:Hn,height:Hn,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:E.borderRadius.sm,backgroundColor:c?`var(--pubwave-drag-handle-active-bg, ${E.colors.focus})`:"transparent",transition:`background-color ${E.transition.fast}`},children:i.jsx(Jl,{})})})}function Jl(){return i.jsxs("svg",{width:"12",height:"16",viewBox:"0 0 12 16",fill:"currentColor",style:{color:`var(--pubwave-drag-handle-color, ${E.colors.textMuted})`},children:[i.jsx("circle",{cx:"3",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"3",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"3",cy:"13",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"3",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"8",r:"1.5"}),i.jsx("circle",{cx:"9",cy:"13",r:"1.5"})]})}const Jt=50,Zl=15;function $n(e){const t=1-e/Jt;return Math.round(t*Zl)}function Eo(e){const t={isActive:!1,direction:null,speed:0,animationId:null},n=()=>e??window,o=()=>{if(e){const a=e.getBoundingClientRect();return{top:a.top,bottom:a.bottom}}return{top:0,bottom:window.innerHeight}},r=()=>{if(!t.isActive||t.direction===null)return;const a=n(),s=t.direction==="up"?-t.speed:t.speed;a===window?window.scrollBy(0,s):a instanceof HTMLElement&&(a.scrollTop+=s),t.animationId=Y(r)};return{start(){t.isActive=!0},update(a){if(!t.isActive)return;const s=o(),c=a-s.top,l=s.bottom-a;c<Jt?(t.direction="up",t.speed=$n(c)):l<Jt?(t.direction="down",t.speed=$n(l)):(t.direction=null,t.speed=0),t.direction!==null&&t.animationId===null?t.animationId=Y(r):t.direction===null&&t.animationId!==null&&(cancelAnimationFrame(t.animationId),t.animationId=null)},stop(){t.isActive=!1,t.direction=null,t.speed=0,t.animationId!==null&&(cancelAnimationFrame(t.animationId),t.animationId=null)}}}function Ql(e){let t=null;const n=()=>(t??(t=Eo(e)),t);return{startAutoScroll(){n().start()},updateAutoScroll(o){n().update(o.clientY)},stopAutoScroll(){n().stop(),t=null}}}const ec=3e3;function _o({message:e,type:t="info",duration:n=ec,onDismiss:o,className:r}){const[a,s]=m.useState(!0);m.useEffect(()=>{if(n<=0)return;const d=setTimeout(()=>{s(!1),o==null||o()},n);return()=>{clearTimeout(d)}},[n,o]);const c=m.useCallback(()=>{s(!1),o==null||o()},[o]),l={info:E.colors.text,success:"var(--pubwave-color-success, #10b981)",error:E.colors.error,warning:"var(--pubwave-color-warning, #f59e0b)"};return i.jsxs("div",{className:Ee("pubwave-toast",`pubwave-toast--${t}`,a?"pubwave-toast--visible":"pubwave-toast--hidden",r),style:{position:"fixed",bottom:"24px",left:"50%",transform:`translateX(-50%) translateY(${a?"0":"16px"})`,padding:`${E.spacing.sm} ${E.spacing.md}`,backgroundColor:`var(--pubwave-toast-bg, ${E.colors.surface})`,border:`1px solid var(--pubwave-toast-border, ${E.colors.border})`,borderRadius:E.borderRadius.md,boxShadow:E.shadow.md,color:l[t],fontSize:E.typography.fontSizeSmall,opacity:a?1:0,transition:`opacity ${E.transition.normal}, transform ${E.transition.normal}`,zIndex:100,maxWidth:"400px",textAlign:"center"},role:"status","aria-live":"polite",children:[i.jsx("span",{className:"pubwave-toast__message",children:e}),i.jsx("button",{type:"button",className:"pubwave-toast__dismiss",onClick:c,style:{marginLeft:E.spacing.sm,padding:"0 4px",background:"none",border:"none",color:E.colors.textMuted,cursor:"pointer",fontSize:"16px",lineHeight:1},"aria-label":"Dismiss",children:"×"})]})}function tc({toasts:e,onDismiss:t}){return i.jsx("div",{className:"pubwave-toast-container",children:e.map((n,o)=>{const r=24+o*56,a=100-o;return i.jsx("div",{style:{position:"fixed",bottom:`${String(r)}px`,left:"50%",transform:"translateX(-50%)",zIndex:a},children:i.jsx(_o,{message:n.message,type:n.type,duration:n.duration,onDismiss:()=>{t(n.id)}})},n.id)})})}function nc(){const e=String(Date.now()),t=Math.random().toString(36).slice(2,9);return`toast-${e}-${t}`}exports.BlockHandle=So;exports.BubbleToolbar=jo;exports.DragHandle=Xl;exports.DropIndicator=Mo;exports.PubwaveEditor=Wl;exports.SUPPORTED_BLOCKS=Xs;exports.SUPPORTED_MARKS=Js;exports.SlashMenuList=xo;exports.Toast=_o;exports.ToastContainer=tc;exports.canUseDOM=_t;exports.cancelDrag=Ks;exports.clearFormatting=hl;exports.cn=Ee;exports.createActionHandler=Yl;exports.createAutoScroller=Eo;exports.createDndPlugin=wo;exports.createEditor=Zs;exports.createExtensions=ln;exports.createFocusTrap=Pl;exports.createSlashCommandsExtension=mo;exports.createToastId=nc;exports.defaultSlashCommands=Dt;exports.defaultTokens=Ys;exports.defaultToolbarActions=Kl;exports.destroyEditor=Qs;exports.dndPluginKey=Z;exports.findBlockAtPos=ct;exports.focusAfterClick=jl;exports.focusAt=Al;exports.focusEditor=pl;exports.getActiveLinkHref=ml;exports.getActiveMarks=gl;exports.getDndState=sn;exports.getSelectionBounds=nl;exports.getSelectionState=cn;exports.handleSelectionClear=Ml;exports.isEditable=ft;exports.isEditorValid=el;exports.isMarkActive=bl;exports.isMobileDevice=ut;exports.isNodeActive=vl;exports.isReadOnly=Co;exports.isSSR=Va;exports.isSelectionEmpty=tl;exports.maintainFocus=Sl;exports.moveBlock=yo;exports.redo=dl;exports.restoreFocus=Ae;exports.restoreSelection=tt;exports.saveSelection=Bo;exports.selectAll=fl;exports.setHeading=ll;exports.setLink=al;exports.setParagraph=sl;exports.shouldAllowInteraction=kl;exports.shouldAllowToolbar=yl;exports.shouldRenderEditUI=xl;exports.shouldShowDragHandle=wl;exports.shouldShowToolbar=Mt;exports.startDrag=ko;exports.toggleBold=ol;exports.toggleHeading=cl;exports.toggleItalic=rl;exports.tokens=E;exports.toolbarRemoveLink=Ro;exports.toolbarSetHeading=Vl;exports.toolbarSetLink=Io;exports.toolbarSetParagraph=Gl;exports.toolbarToggleBold=Po;exports.toolbarToggleItalic=Do;exports.toolbarToggleLink=Oo;exports.undo=ul;exports.unsetLink=il;exports.useAutoScroll=Ql;
|