autumnnote 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,60 +1,62 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.AutumnNote=t())})(this,function(){var e=Object.defineProperty,t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function r(e,t){let n={};for(let t of Object.keys(e))n[t]=Array.isArray(e[t])?[...e[t]]:e[t];if(a(e)&&a(t))for(let i of Object.keys(t))n[i]=a(t[i])?r(a(e[i])?e[i]:{},t[i]):Array.isArray(t[i])?[...t[i]]:t[i];return n}function i(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>i(e,t[n]));if(a(e)&&a(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&i(e[n],t[n]))}return!1}function a(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var o={toolbar:{bold:`Bold (Ctrl+B)`,italic:`Italic (Ctrl+I)`,underline:`Underline (Ctrl+U)`,strikethrough:`Strikethrough`,superscript:`Superscript`,subscript:`Subscript`,alignLeft:`Align Left`,alignCenter:`Align Center`,alignRight:`Align Right`,alignJustify:`Justify`,ul:`Unordered List`,ol:`Ordered List`,checklist:`Checklist`,indent:`Indent`,outdent:`Outdent`,undo:`Undo (Ctrl+Z)`,redo:`Redo (Ctrl+Y)`,hr:`Horizontal Rule`,link:`Insert Link`,image:`Insert Image`,video:`Insert Video`,emoji:`Insert Emoji`,icon:`Insert FA Icon`,table:`Insert Table`,fontSize:`Font Size`,fontSizePlaceholder:`Size`,removeFormat:`Remove Format`,direction:`Toggle Text Direction (LTR / RTL)`,fontFamily:`Font Family`,paragraphStyle:`Paragraph Style`,paragraphStylePlaceholder:`Style`,lineHeight:`Line Height`,lineHeightPlaceholder:`↕ Line`,codeview:`HTML Code View`,fullscreen:`Fullscreen`,shortcuts:`Keyboard Shortcuts (Ctrl+Shift+/)`,find:`Find (Ctrl+F)`,findReplace:`Find & Replace (Ctrl+H)`,inlineCode:"Inline Code (Ctrl+`)",print:`Print`,foreColor:`Text Color`,backColor:`Highlight Color`,chooseTextColor:`Choose text color`,chooseHighlightColor:`Choose highlight color`,customColor:`Custom color`,insertTableLabel:`Insert Table`,paragraphItems:{p:`Normal`,blockquote:`Quote`,pre:`Code`}},linkDialog:{ariaLabel:`Insert link`,title:`Insert Link`,url:`URL`,urlPlaceholder:`https://`,displayText:`Display Text`,textPlaceholder:`Link text`,openInNewTab:`Open in new tab`,insertBtn:`Insert`,cancelBtn:`Cancel`},imageDialog:{ariaLabel:`Insert image`,title:`Insert Image`,imageUrl:`Image URL`,urlPlaceholder:`https://example.com/image.png`,altText:`Alt Text`,altPlaceholder:`Describe the image`,alignment:`Alignment`,alignNone:`None`,alignLeft:`Left`,alignCenter:`Center`,alignRight:`Right`,uploadLabel:`Or upload a file`,insertBtn:`Insert`,cancelBtn:`Cancel`},videoDialog:{ariaLabel:`Insert video`,title:`Insert Video`,videoUrl:`Video URL`,urlPlaceholder:`YouTube, Vimeo, or direct .mp4 URL`,widthLabel:`Width (px)`,widthPlaceholder:`560`,insertBtn:`Insert`,cancelBtn:`Cancel`,detected:e=>`Detected: ${e}`,unknownFormat:`Unknown format — will try direct video embed`,invalidUrl:`Invalid URL — please enter a valid video link.`},emojiDialog:{ariaLabel:`Insert emoji`,title:`Insert Emoji`,searchPlaceholder:`Search emojis…`,all:`All`,cancelBtn:`Cancel`,close:`Close`,categories:{smileys:`Smileys`,people:`People`,animals:`Animals`,food:`Food`,travel:`Travel`,objects:`Objects`,symbols:`Symbols`}},iconDialog:{ariaLabel:`Insert FA icon`,title:`Insert FA Icon`,searchPlaceholder:`Search icons…`,all:`All`,style:`Style`,size:`Size`,color:`Color`,useColor:` Use color`,selectHint:`Select an icon`,insertBtn:`Insert FA Icon`,cancelBtn:`Cancel`,close:`Close`,categories:{popular:`Popular`,interface:`Interface`,navigation:`Navigation`,media:`Media`,communication:`Communication`,files:`Files`,people:`People`,objects:`Objects`}},findReplace:{findTitle:`Find`,findReplaceTitle:`Find & Replace`,findPlaceholder:`Find…`,searchAriaLabel:`Search text`,caseSensitive:`\xA0Case sensitive`,wholeWord:`Whole Word`,prevBtn:`← Prev`,nextBtn:`Next →`,replacePlaceholder:`Replace with…`,replaceAriaLabel:`Replace with`,replaceBtn:`Replace`,replaceAllBtn:`Replace All`,noResults:`No results`,useRegex:`Use Regular Expression`,prevMatch:`Previous (Shift+Enter)`,nextMatch:`Next (Enter)`,close:`×`},autoSaveRestore:{found:`Draft found. Restore?`,foundAt:`Draft from {date}. Restore?`,restore:`Restore`,discard:`Discard`},shortcutsDialog:{title:`Keyboard Shortcuts`,ariaLabel:`Keyboard Shortcuts`,close:`Close`,customCategory:`Custom`,shortcuts:[{category:`Text Formatting`,items:[{keys:`Ctrl + B`,action:`Bold`},{keys:`Ctrl + I`,action:`Italic`},{keys:`Ctrl + U`,action:`Underline`},{keys:`Ctrl + K`,action:`Insert / edit link`}]},{category:`History`,items:[{keys:`Ctrl + Z`,action:`Undo`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Redo`}]},{category:`Selection & Navigation`,items:[{keys:`Ctrl + A`,action:`Select all content`},{keys:`Tab`,action:`Indent list item / insert spaces`},{keys:`Shift + Tab`,action:`Outdent list item`}]},{category:`Clipboard`,items:[{keys:`Ctrl + Shift + V`,action:`Paste as plain text`}]},{category:`Find & Replace`,items:[{keys:`Ctrl + F`,action:`Find in document`},{keys:`Ctrl + H`,action:`Find & Replace`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Show this keyboard shortcuts dialog`}]}]},contextMenu:{cut:`Cut`,copy:`Copy`,paste:`Paste`,bold:`Bold`,italic:`Italic`,underline:`Underline`,textColor:`Text Color`,highlightColor:`Highlight Color`,copyFormat:`Copy Format`,pasteFormat:`Paste Format`,removeFormat:`Remove Format`,link:`Insert Link`,image:`Insert Image`,video:`Insert Video`,table:`Insert Table`,back:`Back`,noHighlight:`No highlight`,customColor:`Custom color`,customColorLabel:`Custom…`},statusbar:{resizeHandle:`Resize editor`,words:e=>`Words: ${e}`,wordsLimit:(e,t)=>`Words: ${e}/${t}`,chars:e=>`Chars: ${e}`,charsLimit:(e,t)=>`Chars: ${e}/${t}`},a11y:{editor:`Rich text editor`,toolbar:`Editor toolbar`,statistics:`Editor statistics`,tableSize:`Select table size`},tooltips:{link:{ariaLabel:`Link actions`,openLink:`Open link`,copyUrl:`Copy URL`,editLink:`Edit link`,removeLink:`Remove link`},image:{ariaLabel:`Image actions`,label:`Image`,floatLeft:`Float Left`,noFloat:`No Float`,alignCenter:`Align Center`,floatRight:`Float Right`,originalSize:`Original Size`,rotateLeft:`Rotate Left`,rotateRight:`Rotate Right`,cropImage:`Crop Image`,addCaption:`Add / Edit Caption`,deleteImage:`Delete Image`},code:{ariaLabel:`Code block actions`,label:`Code`,syntaxLanguage:`Syntax Language`,syntaxAriaLabel:`Syntax language`,copyCode:`Copy Code`,toggleWordWrap:`Toggle Word Wrap`,enableWordWrap:`Enable Word Wrap`,disableWordWrap:`Disable Word Wrap`,convertToParagraph:`Convert to Paragraph`,deleteCodeBlock:`Delete Code Block`,lineNumbers:`Toggle Line Numbers`},table:{ariaLabel:`Table actions`,label:`Table`,selectCells:`Select Cells`,addRowAbove:`Add Row Above`,addRowBelow:`Add Row Below`,deleteRow:`Delete Row`,addColumnLeft:`Add Column Left`,addColumnRight:`Add Column Right`,deleteColumn:`Delete Column`,mergeCells:`Merge Cells`,unmergeCells:`Unmerge Cells`,columnWidth:`Column Width`,rowHeight:`Row Height`,tableBorderWidth:`Table Border Width`,tableBorderColor:`Table Border Color`,deleteTable:`Delete Table`,cellAlignLeft:`Align Left`,cellAlignCenter:`Align Center`,cellAlignRight:`Align Right`,cellAlignJustify:`Align Justify`,toggleHeaderRow:`Toggle Header Row`,cellBackground:`Cell Background`,noShading:`No Shading`,noBorderColor:`No Border Color`,columnWidthPx:`Column Width (px)`,rowHeightPx:`Row Height (px)`,tableBorderWidthPx:`Table Border Width (px)`,cancelBtn:`Cancel`,applyBtn:`Apply`,sortAsc:`Sort Ascending`,sortDesc:`Sort Descending`,exportCSV:`Export as CSV`,cellPadding:`Cell Padding`,cellPaddingPx:`Cell Padding (px)`},video:{ariaLabel:`Video actions`,label:`Video`,floatLeft:`Float Left`,noFloat:`No Float`,alignCenter:`Align Center`,floatRight:`Float Right`,originalSize:`Original Size`,previewVideo:`Preview Video`,exitPreview:`Exit Preview`,deleteVideo:`Delete Video`}},errors:{imageFormat:e=>`Format "${e}" is not supported for display in web browsers. Please convert to JPEG, PNG, or WebP first.`,imageSize:e=>`Image file is too large. Maximum allowed size is ${e} MB.`},slashMenu:{noResults:`No matching commands`,heading1:`Heading 1`,heading2:`Heading 2`,heading3:`Heading 3`,bulletList:`Bullet List`,numberedList:`Numbered List`,checklist:`Checklist`,blockquote:`Blockquote`,codeBlock:`Code Block`,horizontalRule:`Horizontal Rule`,table:`Table`,image:`Image`}},s={en:o};function c(e,t){if(typeof e!=`string`||!e)throw TypeError(`[AutumnNote] registerLocale: code must be a non-empty string.`);if(!t||typeof t!=`object`)throw TypeError(`[AutumnNote] registerLocale: locale for "${e}" must be an object.`);s[e]=t}function l(e){if(!e||e===`en`)return o;if(typeof e==`string`){let t=s[e];return t?r(r({},o),t):(console.warn(`[AutumnNote] Locale "${e}" is not registered, falling back to English. Import it first: import { ${e} } from 'autumnnote/i18n/${e}'; AutumnNote.registerLocale('${e}', ${e});`),o)}return typeof e==`object`?r(r({},o),e):o}c(`vi`,{toolbar:{bold:`Đậm (Ctrl+B)`,italic:`Nghiêng (Ctrl+I)`,underline:`Gạch chân (Ctrl+U)`,strikethrough:`Gạch ngang`,superscript:`Chỉ số trên`,subscript:`Chỉ số dưới`,alignLeft:`Căn trái`,alignCenter:`Căn giữa`,alignRight:`Căn phải`,alignJustify:`Căn đều`,ul:`Danh sách không thứ tự`,ol:`Danh sách có thứ tự`,checklist:`Danh sách kiểm tra`,indent:`Tăng thụt đầu dòng`,outdent:`Giảm thụt đầu dòng`,undo:`Hoàn tác (Ctrl+Z)`,redo:`Làm lại (Ctrl+Y)`,hr:`Đường kẻ ngang`,link:`Chèn liên kết`,image:`Chèn hình ảnh`,video:`Chèn video`,emoji:`Chèn biểu tượng cảm xúc`,icon:`Chèn biểu tượng FA`,table:`Chèn bảng`,fontSize:`Cỡ chữ`,fontSizePlaceholder:`Cỡ`,removeFormat:`Xóa định dạng`,direction:`Chuyển hướng văn bản (LTR / RTL)`,fontFamily:`Phông chữ`,paragraphStyle:`Kiểu đoạn văn`,paragraphStylePlaceholder:`Kiểu`,lineHeight:`Khoảng cách dòng`,lineHeightPlaceholder:`↕ Dòng`,codeview:`Xem mã HTML`,fullscreen:`Toàn màn hình`,shortcuts:`Phím tắt (Ctrl+Shift+/)`,find:`Tìm kiếm (Ctrl+F)`,findReplace:`Tìm & Thay thế (Ctrl+H)`,inlineCode:"Mã nội tuyến (Ctrl+`)",print:`In`,foreColor:`Màu chữ`,backColor:`Màu nền chữ`,chooseTextColor:`Chọn màu chữ`,chooseHighlightColor:`Chọn màu nền`,customColor:`Màu tùy chỉnh`,insertTableLabel:`Chèn bảng`,paragraphItems:{p:`Bình thường`,blockquote:`Trích dẫn`,pre:`Mã`}},linkDialog:{ariaLabel:`Chèn liên kết`,title:`Chèn liên kết`,url:`Địa chỉ URL`,urlPlaceholder:`https://`,displayText:`Văn bản hiển thị`,textPlaceholder:`Nội dung liên kết`,openInNewTab:`Mở trong tab mới`,insertBtn:`Chèn`,cancelBtn:`Hủy`},imageDialog:{ariaLabel:`Chèn hình ảnh`,title:`Chèn hình ảnh`,imageUrl:`URL hình ảnh`,urlPlaceholder:`https://example.com/anh.png`,altText:`Văn bản thay thế`,altPlaceholder:`Mô tả hình ảnh`,alignment:`Căn chỉnh`,alignNone:`Không`,alignLeft:`Trái`,alignCenter:`Giữa`,alignRight:`Phải`,uploadLabel:`Hoặc tải lên tệp`,insertBtn:`Chèn`,cancelBtn:`Hủy`},videoDialog:{ariaLabel:`Chèn video`,title:`Chèn video`,videoUrl:`URL video`,urlPlaceholder:`YouTube, Vimeo, hoặc URL .mp4 trực tiếp`,widthLabel:`Chiều rộng (px)`,widthPlaceholder:`560`,insertBtn:`Chèn`,cancelBtn:`Hủy`,detected:e=>`Đã phát hiện: ${e}`,unknownFormat:`Định dạng không xác định — sẽ thử nhúng video trực tiếp`,invalidUrl:`URL không hợp lệ — vui lòng nhập đường dẫn video hợp lệ.`},emojiDialog:{ariaLabel:`Chèn biểu tượng cảm xúc`,title:`Chèn biểu tượng cảm xúc`,searchPlaceholder:`Tìm kiếm biểu tượng…`,all:`Tất cả`,cancelBtn:`Hủy`,close:`Đóng`,categories:{smileys:`Mặt cười`,people:`Con người`,animals:`Động vật`,food:`Thức ăn`,travel:`Du lịch`,objects:`Đồ vật`,symbols:`Ký hiệu`}},iconDialog:{ariaLabel:`Chèn biểu tượng FA`,title:`Chèn biểu tượng FA`,searchPlaceholder:`Tìm kiếm biểu tượng…`,all:`Tất cả`,style:`Kiểu`,size:`Kích thước`,color:`Màu sắc`,useColor:` Dùng màu`,selectHint:`Chọn một biểu tượng`,insertBtn:`Chèn biểu tượng FA`,cancelBtn:`Hủy`,close:`Đóng`,categories:{popular:`Phổ biến`,interface:`Giao diện`,navigation:`Điều hướng`,media:`Phương tiện`,communication:`Liên lạc`,files:`Tệp tin`,people:`Con người`,objects:`Đồ vật`}},findReplace:{findTitle:`Tìm kiếm`,findReplaceTitle:`Tìm & Thay thế`,findPlaceholder:`Tìm…`,searchAriaLabel:`Văn bản tìm kiếm`,caseSensitive:`\xA0Phân biệt hoa thường`,wholeWord:`Toàn bộ từ`,prevBtn:`← Trước`,nextBtn:`Tiếp →`,replacePlaceholder:`Thay thế bằng…`,replaceAriaLabel:`Thay thế bằng`,replaceBtn:`Thay thế`,replaceAllBtn:`Thay thế tất cả`,noResults:`Không có kết quả`,useRegex:`Dùng biểu thức chính quy`,prevMatch:`Trước (Shift+Enter)`,nextMatch:`Tiếp (Enter)`,close:`×`},shortcutsDialog:{title:`Phím tắt bàn phím`,ariaLabel:`Phím tắt bàn phím`,close:`Đóng`,customCategory:`Tùy chỉnh`,shortcuts:[{category:`Định dạng văn bản`,items:[{keys:`Ctrl + B`,action:`Đậm`},{keys:`Ctrl + I`,action:`Nghiêng`},{keys:`Ctrl + U`,action:`Gạch chân`},{keys:`Ctrl + K`,action:`Chèn / sửa liên kết`}]},{category:`Lịch sử`,items:[{keys:`Ctrl + Z`,action:`Hoàn tác`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Làm lại`}]},{category:`Chọn & Điều hướng`,items:[{keys:`Ctrl + A`,action:`Chọn tất cả`},{keys:`Tab`,action:`Tăng thụt đầu dòng / chèn khoảng trắng`},{keys:`Shift + Tab`,action:`Giảm thụt đầu dòng`}]},{category:`Bảng nhớ tạm`,items:[{keys:`Ctrl + Shift + V`,action:`Dán dưới dạng văn bản thuần`}]},{category:`Tìm & Thay thế`,items:[{keys:`Ctrl + F`,action:`Tìm trong tài liệu`},{keys:`Ctrl + H`,action:`Tìm & Thay thế`}]},{category:`Trình soạn thảo`,items:[{keys:`Ctrl + Shift + /`,action:`Hiện hộp thoại phím tắt`}]}]},contextMenu:{cut:`Cắt`,copy:`Sao chép`,paste:`Dán`,bold:`Đậm`,italic:`Nghiêng`,underline:`Gạch chân`,textColor:`Màu chữ`,highlightColor:`Màu nền chữ`,copyFormat:`Sao chép định dạng`,pasteFormat:`Dán định dạng`,removeFormat:`Xóa định dạng`,link:`Chèn liên kết`,image:`Chèn hình ảnh`,video:`Chèn video`,table:`Chèn bảng`,back:`Quay lại`,noHighlight:`Không tô màu`,customColor:`Màu tùy chỉnh`,customColorLabel:`Tùy chỉnh…`},statusbar:{resizeHandle:`Kéo để thay đổi kích thước`,words:e=>`Từ: ${e}`,wordsLimit:(e,t)=>`Từ: ${e}/${t}`,chars:e=>`Ký tự: ${e}`,charsLimit:(e,t)=>`Ký tự: ${e}/${t}`},a11y:{editor:`Trình soạn thảo văn bản`,toolbar:`Thanh công cụ soạn thảo`,statistics:`Thống kê văn bản`,tableSize:`Chọn kích thước bảng`},tooltips:{link:{ariaLabel:`Hành động liên kết`,openLink:`Mở liên kết`,copyUrl:`Sao chép URL`,editLink:`Sửa liên kết`,removeLink:`Xóa liên kết`},image:{ariaLabel:`Hành động hình ảnh`,label:`Hình ảnh`,floatLeft:`Nổi trái`,noFloat:`Không nổi`,alignCenter:`Căn giữa`,floatRight:`Nổi phải`,originalSize:`Kích thước gốc`,rotateLeft:`Xoay trái`,rotateRight:`Xoay phải`,cropImage:`Cắt ảnh`,addCaption:`Thêm / Sửa chú thích`,deleteImage:`Xóa hình ảnh`},code:{ariaLabel:`Hành động khối mã`,label:`Mã`,syntaxLanguage:`Ngôn ngữ cú pháp`,syntaxAriaLabel:`Ngôn ngữ cú pháp`,copyCode:`Sao chép mã`,toggleWordWrap:`Chuyển đổi xuống dòng`,enableWordWrap:`Bật xuống dòng`,disableWordWrap:`Tắt xuống dòng`,convertToParagraph:`Chuyển thành đoạn văn`,deleteCodeBlock:`Xóa khối mã`,lineNumbers:`Bật/Tắt số dòng`},table:{ariaLabel:`Hành động bảng`,label:`Bảng`,selectCells:`Chọn ô`,addRowAbove:`Thêm hàng phía trên`,addRowBelow:`Thêm hàng phía dưới`,deleteRow:`Xóa hàng`,addColumnLeft:`Thêm cột bên trái`,addColumnRight:`Thêm cột bên phải`,deleteColumn:`Xóa cột`,mergeCells:`Gộp ô`,unmergeCells:`Tách ô`,columnWidth:`Chiều rộng cột`,rowHeight:`Chiều cao hàng`,tableBorderWidth:`Độ rộng viền bảng`,tableBorderColor:`Màu viền bảng`,deleteTable:`Xóa bảng`,cellAlignLeft:`Căn trái`,cellAlignCenter:`Căn giữa`,cellAlignRight:`Căn phải`,cellAlignJustify:`Căn đều`,toggleHeaderRow:`Bật/tắt hàng tiêu đề`,cellBackground:`Màu Nền Ô`,noShading:`Xóa Màu Nền`,noBorderColor:`Xóa màu viền`,columnWidthPx:`Chiều rộng cột (px)`,rowHeightPx:`Chiều cao hàng (px)`,tableBorderWidthPx:`Độ rộng viền bảng (px)`,cancelBtn:`Hủy`,applyBtn:`Áp dụng`,sortAsc:`Sắp xếp tăng dần`,sortDesc:`Sắp xếp giảm dần`,exportCSV:`Xuất CSV`,cellPadding:`Khoảng đệm ô`,cellPaddingPx:`Khoảng đệm ô (px)`},video:{ariaLabel:`Hành động video`,label:`Video`,floatLeft:`Nổi trái`,noFloat:`Không nổi`,alignCenter:`Căn giữa`,floatRight:`Nổi phải`,originalSize:`Kích thước gốc`,previewVideo:`Xem trước`,exitPreview:`Thoát xem trước`,deleteVideo:`Xóa video`}},errors:{imageFormat:e=>`Định dạng "${e}" không được hỗ trợ hiển thị trên trình duyệt. Vui lòng chuyển đổi sang JPEG, PNG hoặc WebP.`,imageSize:e=>`Tệp hình ảnh quá lớn. Kích thước tối đa cho phép là ${e} MB.`},autoSaveRestore:{found:`Tìm thấy bản nháp. Khôi phục?`,foundAt:`Bản nháp từ {date}. Khôi phục?`,restore:`Khôi phục`,discard:`Bỏ qua`},slashMenu:{noResults:`Không có lệnh phù hợp`,heading1:`Tiêu đề 1`,heading2:`Tiêu đề 2`,heading3:`Tiêu đề 3`,bulletList:`Danh sách không thứ tự`,numberedList:`Danh sách có thứ tự`,checklist:`Danh sách công việc`,blockquote:`Trích dẫn`,codeBlock:`Khối mã`,horizontalRule:`Đường kẻ ngang`,table:`Bảng`,image:`Hình ảnh`}}),c(`ja`,{toolbar:{bold:`太字 (Ctrl+B)`,italic:`斜体 (Ctrl+I)`,underline:`下線 (Ctrl+U)`,strikethrough:`取り消し線`,superscript:`上付き文字`,subscript:`下付き文字`,alignLeft:`左揃え`,alignCenter:`中央揃え`,alignRight:`右揃え`,alignJustify:`両端揃え`,ul:`箇条書きリスト`,ol:`番号付きリスト`,checklist:`チェックリスト`,indent:`インデントを増やす`,outdent:`インデントを減らす`,undo:`元に戻す (Ctrl+Z)`,redo:`やり直す (Ctrl+Y)`,hr:`水平線`,link:`リンクを挿入`,image:`画像を挿入`,video:`動画を挿入`,emoji:`絵文字を挿入`,icon:`FAアイコンを挿入`,table:`テーブルを挿入`,fontSize:`フォントサイズ`,fontSizePlaceholder:`サイズ`,removeFormat:`書式をリセット`,direction:`文字方向を切り替え (LTR / RTL)`,fontFamily:`フォント`,paragraphStyle:`段落スタイル`,paragraphStylePlaceholder:`スタイル`,lineHeight:`行の高さ`,lineHeightPlaceholder:`↕ 行間`,codeview:`HTMLソースを表示`,fullscreen:`全画面表示`,shortcuts:`キーボードショートカット (Ctrl+Shift+/)`,find:`検索 (Ctrl+F)`,findReplace:`検索と置換 (Ctrl+H)`,inlineCode:"インラインコード (Ctrl+`)",print:`印刷`,foreColor:`文字色`,backColor:`ハイライト色`,chooseTextColor:`文字色を選択`,chooseHighlightColor:`ハイライト色を選択`,customColor:`カスタムカラー`,insertTableLabel:`テーブルを挿入`,paragraphItems:{p:`標準`,blockquote:`引用`,pre:`コード`}},linkDialog:{ariaLabel:`リンクを挿入`,title:`リンクを挿入`,url:`URL`,urlPlaceholder:`https://`,displayText:`表示テキスト`,textPlaceholder:`リンクテキスト`,openInNewTab:`新しいタブで開く`,insertBtn:`挿入`,cancelBtn:`キャンセル`},imageDialog:{ariaLabel:`画像を挿入`,title:`画像を挿入`,imageUrl:`画像URL`,urlPlaceholder:`https://example.com/image.png`,altText:`代替テキスト`,altPlaceholder:`画像の説明`,alignment:`配置`,alignNone:`なし`,alignLeft:`左`,alignCenter:`中央`,alignRight:`右`,uploadLabel:`ファイルをアップロード`,insertBtn:`挿入`,cancelBtn:`キャンセル`},videoDialog:{ariaLabel:`動画を挿入`,title:`動画を挿入`,videoUrl:`動画URL`,urlPlaceholder:`YouTube、Vimeo、または直接動画URL`,widthLabel:`幅 (px)`,widthPlaceholder:`560`,insertBtn:`挿入`,cancelBtn:`キャンセル`,detected:e=>`検出: ${e}`,unknownFormat:`不明な形式 — 直接動画埋め込みを試みます`,invalidUrl:`URLが無効です — 有効な動画URLを入力してください。`},emojiDialog:{ariaLabel:`絵文字を挿入`,title:`絵文字を挿入`,searchPlaceholder:`絵文字を検索…`,all:`すべて`,cancelBtn:`キャンセル`,close:`閉じる`,categories:{smileys:`顔文字`,people:`人物`,animals:`動物`,food:`食べ物`,travel:`旅行`,objects:`モノ`,symbols:`記号`}},iconDialog:{ariaLabel:`FAアイコンを挿入`,title:`FAアイコンを挿入`,searchPlaceholder:`アイコンを検索…`,all:`すべて`,style:`スタイル`,size:`サイズ`,color:`カラー`,useColor:` カラーを使用`,selectHint:`アイコンを選択してください`,insertBtn:`FAアイコンを挿入`,cancelBtn:`キャンセル`,close:`閉じる`,categories:{popular:`人気`,interface:`インターフェース`,navigation:`ナビゲーション`,media:`メディア`,communication:`通信`,files:`ファイル`,people:`人物`,objects:`モノ`}},findReplace:{findTitle:`検索`,findReplaceTitle:`検索と置換`,findPlaceholder:`検索…`,searchAriaLabel:`検索テキスト`,caseSensitive:`\xA0大文字/小文字を区別`,wholeWord:`単語単位`,prevBtn:`← 前へ`,nextBtn:`次へ →`,replacePlaceholder:`置換後…`,replaceAriaLabel:`置換後のテキスト`,replaceBtn:`置換`,noResults:`結果なし`,useRegex:`正規表現を使用`,prevMatch:`前へ (Shift+Enter)`,nextMatch:`次へ (Enter)`,replaceAllBtn:`すべて置換`,close:`×`},shortcutsDialog:{title:`キーボードショートカット`,ariaLabel:`キーボードショートカット`,close:`閉じる`,customCategory:`カスタム`,shortcuts:[{category:`テキスト書式`,items:[{keys:`Ctrl + B`,action:`太字`},{keys:`Ctrl + I`,action:`斜体`},{keys:`Ctrl + U`,action:`下線`},{keys:`Ctrl + K`,action:`リンクの挿入 / 編集`}]},{category:`履歴`,items:[{keys:`Ctrl + Z`,action:`元に戻す`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`やり直す`}]},{category:`選択と移動`,items:[{keys:`Ctrl + A`,action:`すべて選択`},{keys:`Tab`,action:`インデント増加 / スペース挿入`},{keys:`Shift + Tab`,action:`インデント減少`}]},{category:`クリップボード`,items:[{keys:`Ctrl + Shift + V`,action:`プレーンテキストとして貼り付け`}]},{category:`検索と置換`,items:[{keys:`Ctrl + F`,action:`文書内を検索`},{keys:`Ctrl + H`,action:`検索と置換`}]},{category:`エディター`,items:[{keys:`Ctrl + Shift + /`,action:`ショートカットダイアログを表示`}]}]},contextMenu:{cut:`切り取り`,copy:`コピー`,paste:`貼り付け`,bold:`太字`,italic:`斜体`,underline:`下線`,textColor:`文字色`,highlightColor:`ハイライト色`,copyFormat:`書式をコピー`,pasteFormat:`書式を貼り付け`,removeFormat:`書式をリセット`,link:`リンクを挿入`,image:`画像を挿入`,video:`動画を挿入`,table:`テーブルを挿入`,back:`戻る`,noHighlight:`ハイライトなし`,customColor:`カスタムカラー`,customColorLabel:`カスタム…`},statusbar:{resizeHandle:`ドラッグしてリサイズ`,words:e=>`単語数: ${e}`,wordsLimit:(e,t)=>`単語数: ${e}/${t}`,chars:e=>`文字数: ${e}`,charsLimit:(e,t)=>`文字数: ${e}/${t}`},a11y:{editor:`リッチテキストエディター`,toolbar:`エディターツールバー`,statistics:`エディターの統計`,tableSize:`表のサイズを選択`},tooltips:{link:{ariaLabel:`リンク操作`,openLink:`リンクを開く`,copyUrl:`URLをコピー`,editLink:`リンクを編集`,removeLink:`リンクを削除`},image:{ariaLabel:`画像操作`,label:`画像`,floatLeft:`左に回り込み`,noFloat:`回り込みなし`,alignCenter:`中央揃え`,floatRight:`右に回り込み`,originalSize:`元のサイズ`,rotateLeft:`左に回転`,rotateRight:`右に回転`,cropImage:`画像をトリミング`,addCaption:`キャプションを追加 / 編集`,deleteImage:`画像を削除`},code:{ariaLabel:`コードブロック操作`,label:`コード`,syntaxLanguage:`言語`,syntaxAriaLabel:`構文言語`,copyCode:`コードをコピー`,toggleWordWrap:`折り返しを切り替え`,enableWordWrap:`折り返しを有効にする`,disableWordWrap:`折り返しを無効にする`,convertToParagraph:`段落に変換`,deleteCodeBlock:`コードブロックを削除`,lineNumbers:`行番号を切り替え`},table:{ariaLabel:`テーブル操作`,label:`テーブル`,selectCells:`セルを選択`,addRowAbove:`上に行を追加`,addRowBelow:`下に行を追加`,deleteRow:`行を削除`,addColumnLeft:`左に列を追加`,addColumnRight:`右に列を追加`,deleteColumn:`列を削除`,mergeCells:`セルを結合`,unmergeCells:`セルの結合を解除`,columnWidth:`列幅`,rowHeight:`行の高さ`,tableBorderWidth:`テーブルの枠幅`,tableBorderColor:`テーブルの枠線色`,deleteTable:`テーブルを削除`,cellAlignLeft:`左揃え`,cellAlignCenter:`中央揃え`,cellAlignRight:`右揃え`,cellAlignJustify:`両端揃え`,toggleHeaderRow:`ヘッダー行の切り替え`,cellBackground:`セル背景色`,noShading:`背景色なし`,noBorderColor:`枠線色なし`,columnWidthPx:`列幅 (px)`,rowHeightPx:`行の高さ (px)`,tableBorderWidthPx:`テーブルの枠幅 (px)`,cancelBtn:`キャンセル`,applyBtn:`適用`,sortAsc:`昇順で並べ替え`,sortDesc:`降順で並べ替え`,exportCSV:`CSVとしてエクスポート`,cellPadding:`セルの余白`,cellPaddingPx:`セルの余白 (px)`},video:{ariaLabel:`動画操作`,label:`動画`,floatLeft:`左に回り込み`,noFloat:`回り込みなし`,alignCenter:`中央揃え`,floatRight:`右に回り込み`,originalSize:`元のサイズ`,previewVideo:`プレビュー`,exitPreview:`プレビューを終了`,deleteVideo:`動画を削除`}},errors:{imageFormat:e=>`形式 "${e}" はブラウザでの表示をサポートしていません。JPEG、PNG、または WebP に変換してください。`,imageSize:e=>`画像ファイルが大きすぎます。最大許容サイズは ${e} MB です。`},autoSaveRestore:{found:`下書きが見つかりました。復元しますか?`,foundAt:`{date} の下書きが見つかりました。復元しますか?`,restore:`復元`,discard:`破棄`},slashMenu:{noResults:`一致するコマンドがありません`,heading1:`見出し1`,heading2:`見出し2`,heading3:`見出し3`,bulletList:`箇条書きリスト`,numberedList:`番号付きリスト`,checklist:`チェックリスト`,blockquote:`引用`,codeBlock:`コードブロック`,horizontalRule:`水平線`,table:`表`,image:`画像`}}),c(`zh`,{toolbar:{bold:`粗体 (Ctrl+B)`,italic:`斜体 (Ctrl+I)`,underline:`下划线 (Ctrl+U)`,strikethrough:`删除线`,superscript:`上标`,subscript:`下标`,alignLeft:`左对齐`,alignCenter:`居中`,alignRight:`右对齐`,alignJustify:`两端对齐`,ul:`无序列表`,ol:`有序列表`,checklist:`待办列表`,indent:`增加缩进`,outdent:`减少缩进`,undo:`撤销 (Ctrl+Z)`,redo:`重做 (Ctrl+Y)`,hr:`水平分割线`,link:`插入链接`,image:`插入图片`,video:`插入视频`,emoji:`插入表情`,icon:`插入 FA 图标`,table:`插入表格`,fontSize:`字号`,fontSizePlaceholder:`大小`,removeFormat:`清除格式`,direction:`切换文字方向 (LTR / RTL)`,fontFamily:`字体`,paragraphStyle:`段落样式`,paragraphStylePlaceholder:`样式`,lineHeight:`行高`,lineHeightPlaceholder:`↕ 行距`,codeview:`查看 HTML 源码`,fullscreen:`全屏`,shortcuts:`键盘快捷键 (Ctrl+Shift+/)`,find:`搜索 (Ctrl+F)`,findReplace:`查找和替换 (Ctrl+H)`,inlineCode:"行内代码 (Ctrl+`)",print:`打印`,foreColor:`文字颜色`,backColor:`高亮颜色`,chooseTextColor:`选择文字颜色`,chooseHighlightColor:`选择高亮颜色`,customColor:`自定义颜色`,insertTableLabel:`插入表格`,paragraphItems:{p:`正文`,blockquote:`引用`,pre:`代码`}},linkDialog:{ariaLabel:`插入链接`,title:`插入链接`,url:`链接地址`,urlPlaceholder:`https://`,displayText:`显示文字`,textPlaceholder:`链接文字`,openInNewTab:`在新标签页中打开`,insertBtn:`插入`,cancelBtn:`取消`},imageDialog:{ariaLabel:`插入图片`,title:`插入图片`,imageUrl:`图片地址`,urlPlaceholder:`https://example.com/image.png`,altText:`替代文字`,altPlaceholder:`图片描述`,alignment:`对齐方式`,alignNone:`无`,alignLeft:`左`,alignCenter:`居中`,alignRight:`右`,uploadLabel:`或上传文件`,insertBtn:`插入`,cancelBtn:`取消`},videoDialog:{ariaLabel:`插入视频`,title:`插入视频`,videoUrl:`视频地址`,urlPlaceholder:`YouTube、Vimeo 或直接 .mp4 链接`,widthLabel:`宽度 (px)`,widthPlaceholder:`560`,insertBtn:`插入`,cancelBtn:`取消`,detected:e=>`已识别: ${e}`,unknownFormat:`未知格式 — 将尝试直接嵌入视频`,invalidUrl:`URL 无效 — 请输入有效的视频链接。`},emojiDialog:{ariaLabel:`插入表情`,title:`插入表情`,searchPlaceholder:`搜索表情…`,all:`全部`,cancelBtn:`取消`,close:`关闭`,categories:{smileys:`笑脸`,people:`人物`,animals:`动物`,food:`食物`,travel:`旅行`,objects:`物品`,symbols:`符号`}},iconDialog:{ariaLabel:`插入 FA 图标`,title:`插入 FA 图标`,searchPlaceholder:`搜索图标…`,all:`全部`,style:`样式`,size:`大小`,color:`颜色`,useColor:` 使用颜色`,selectHint:`请选择一个图标`,insertBtn:`插入 FA 图标`,cancelBtn:`取消`,close:`关闭`,categories:{popular:`热门`,interface:`界面`,navigation:`导航`,media:`媒体`,communication:`通讯`,files:`文件`,people:`人物`,objects:`物品`}},findReplace:{findTitle:`搜索`,findReplaceTitle:`查找和替换`,findPlaceholder:`查找…`,searchAriaLabel:`搜索文字`,caseSensitive:`\xA0区分大小写`,wholeWord:`全字匹配`,prevBtn:`← 上一个`,nextBtn:`下一个 →`,replacePlaceholder:`替换为…`,replaceAriaLabel:`替换为`,replaceBtn:`替换`,noResults:`没有结果`,useRegex:`使用正则表达式`,prevMatch:`上一个 (Shift+Enter)`,nextMatch:`下一个 (Enter)`,replaceAllBtn:`全部替换`,close:`×`},shortcutsDialog:{title:`键盘快捷键`,ariaLabel:`键盘快捷键`,close:`关闭`,customCategory:`自定义`,shortcuts:[{category:`文字格式`,items:[{keys:`Ctrl + B`,action:`粗体`},{keys:`Ctrl + I`,action:`斜体`},{keys:`Ctrl + U`,action:`下划线`},{keys:`Ctrl + K`,action:`插入 / 编辑链接`}]},{category:`历史记录`,items:[{keys:`Ctrl + Z`,action:`撤销`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`重做`}]},{category:`选择与导航`,items:[{keys:`Ctrl + A`,action:`全选`},{keys:`Tab`,action:`增加缩进 / 插入空格`},{keys:`Shift + Tab`,action:`减少缩进`}]},{category:`剪贴板`,items:[{keys:`Ctrl + Shift + V`,action:`粘贴为纯文本`}]},{category:`查找和替换`,items:[{keys:`Ctrl + F`,action:`在文档中搜索`},{keys:`Ctrl + H`,action:`查找和替换`}]},{category:`编辑器`,items:[{keys:`Ctrl + Shift + /`,action:`显示快捷键对话框`}]}]},contextMenu:{cut:`剪切`,copy:`复制`,paste:`粘贴`,bold:`粗体`,italic:`斜体`,underline:`下划线`,textColor:`文字颜色`,highlightColor:`高亮颜色`,copyFormat:`复制格式`,pasteFormat:`粘贴格式`,removeFormat:`清除格式`,link:`插入链接`,image:`插入图片`,video:`插入视频`,table:`插入表格`,back:`返回`,noHighlight:`无高亮`,customColor:`自定义颜色`,customColorLabel:`自定义…`},statusbar:{resizeHandle:`拖动以调整大小`,words:e=>`字数: ${e}`,wordsLimit:(e,t)=>`字数: ${e}/${t}`,chars:e=>`字符数: ${e}`,charsLimit:(e,t)=>`字符数: ${e}/${t}`},a11y:{editor:`富文本编辑器`,toolbar:`编辑器工具栏`,statistics:`编辑器统计`,tableSize:`选择表格大小`},tooltips:{link:{ariaLabel:`链接操作`,openLink:`打开链接`,copyUrl:`复制 URL`,editLink:`编辑链接`,removeLink:`删除链接`},image:{ariaLabel:`图片操作`,label:`图片`,floatLeft:`左浮动`,noFloat:`不浮动`,alignCenter:`居中对齐`,floatRight:`右浮动`,originalSize:`原始尺寸`,rotateLeft:`向左旋转`,rotateRight:`向右旋转`,cropImage:`裁剪图片`,addCaption:`添加 / 编辑说明`,deleteImage:`删除图片`},code:{ariaLabel:`代码块操作`,label:`代码`,syntaxLanguage:`语法语言`,syntaxAriaLabel:`语法语言`,copyCode:`复制代码`,toggleWordWrap:`切换自动换行`,enableWordWrap:`启用自动换行`,disableWordWrap:`禁用自动换行`,convertToParagraph:`转换为段落`,deleteCodeBlock:`删除代码块`,lineNumbers:`切换行号`},table:{ariaLabel:`表格操作`,label:`表格`,selectCells:`选择单元格`,addRowAbove:`在上方插入行`,addRowBelow:`在下方插入行`,deleteRow:`删除行`,addColumnLeft:`在左侧插入列`,addColumnRight:`在右侧插入列`,deleteColumn:`删除列`,mergeCells:`合并单元格`,unmergeCells:`拆分单元格`,columnWidth:`列宽`,rowHeight:`行高`,tableBorderWidth:`表格边框宽度`,tableBorderColor:`表格边框颜色`,deleteTable:`删除表格`,cellAlignLeft:`左对齐`,cellAlignCenter:`居中对齐`,cellAlignRight:`右对齐`,cellAlignJustify:`两端对齐`,toggleHeaderRow:`切换标题行`,cellBackground:`单元格背景`,noShading:`无底纹`,noBorderColor:`无边框颜色`,columnWidthPx:`列宽 (px)`,rowHeightPx:`行高 (px)`,tableBorderWidthPx:`表格边框宽度 (px)`,cancelBtn:`取消`,applyBtn:`应用`,sortAsc:`升序排列`,sortDesc:`降序排列`,exportCSV:`导出为 CSV`,cellPadding:`单元格内边距`,cellPaddingPx:`单元格内边距 (px)`},video:{ariaLabel:`视频操作`,label:`视频`,floatLeft:`左浮动`,noFloat:`不浮动`,alignCenter:`居中对齐`,floatRight:`右浮动`,originalSize:`原始尺寸`,previewVideo:`预览视频`,exitPreview:`退出预览`,deleteVideo:`删除视频`}},errors:{imageFormat:e=>`格式 "${e}" 不支持在浏览器中显示。请转换为 JPEG、PNG 或 WebP。`,imageSize:e=>`图片文件过大。最大允许大小为 ${e} MB。`},autoSaveRestore:{found:`找到草稿。是否恢复?`,foundAt:`发现 {date} 的草稿。是否恢复?`,restore:`恢复`,discard:`放弃`},slashMenu:{noResults:`没有匹配的命令`,heading1:`标题 1`,heading2:`标题 2`,heading3:`标题 3`,bulletList:`项目符号列表`,numberedList:`编号列表`,checklist:`检查清单`,blockquote:`引用`,codeBlock:`代码块`,horizontalRule:`水平线`,table:`表格`,image:`图片`}}),c(`fr`,{toolbar:{bold:`Gras (Ctrl+B)`,italic:`Italique (Ctrl+I)`,underline:`Souligné (Ctrl+U)`,strikethrough:`Barré`,superscript:`Exposant`,subscript:`Indice`,alignLeft:`Aligner à gauche`,alignCenter:`Centrer`,alignRight:`Aligner à droite`,alignJustify:`Justifier`,ul:`Liste à puces`,ol:`Liste numérotée`,checklist:`Liste de tâches`,indent:`Augmenter le retrait`,outdent:`Diminuer le retrait`,undo:`Annuler (Ctrl+Z)`,redo:`Rétablir (Ctrl+Y)`,hr:`Ligne horizontale`,link:`Insérer un lien`,image:`Insérer une image`,video:`Insérer une vidéo`,emoji:`Insérer un emoji`,icon:`Insérer une icône FA`,table:`Insérer un tableau`,fontSize:`Taille de police`,fontSizePlaceholder:`Taille`,removeFormat:`Effacer la mise en forme`,direction:`Basculer la direction du texte (LTR / RTL)`,fontFamily:`Police`,paragraphStyle:`Style de paragraphe`,paragraphStylePlaceholder:`Style`,lineHeight:`Interligne`,lineHeightPlaceholder:`↕ Ligne`,codeview:`Afficher le code HTML`,fullscreen:`Plein écran`,shortcuts:`Raccourcis clavier (Ctrl+Shift+/)`,find:`Rechercher (Ctrl+F)`,findReplace:`Rechercher et remplacer (Ctrl+H)`,inlineCode:"Code inline (Ctrl+`)",print:`Imprimer`,foreColor:`Couleur du texte`,backColor:`Couleur de surbrillance`,chooseTextColor:`Choisir la couleur du texte`,chooseHighlightColor:`Choisir la couleur de surbrillance`,customColor:`Couleur personnalisée`,insertTableLabel:`Insérer un tableau`,paragraphItems:{p:`Normal`,blockquote:`Citation`,pre:`Code`}},linkDialog:{ariaLabel:`Insérer un lien`,title:`Insérer un lien`,url:`URL`,urlPlaceholder:`https://`,displayText:`Texte affiché`,textPlaceholder:`Texte du lien`,openInNewTab:`Ouvrir dans un nouvel onglet`,insertBtn:`Insérer`,cancelBtn:`Annuler`},imageDialog:{ariaLabel:`Insérer une image`,title:`Insérer une image`,imageUrl:`URL de l'image`,urlPlaceholder:`https://example.com/image.png`,altText:`Texte alternatif`,altPlaceholder:`Description de l'image`,alignment:`Alignement`,alignNone:`Aucun`,alignLeft:`Gauche`,alignCenter:`Centre`,alignRight:`Droite`,uploadLabel:`Ou téléverser un fichier`,insertBtn:`Insérer`,cancelBtn:`Annuler`},videoDialog:{ariaLabel:`Insérer une vidéo`,title:`Insérer une vidéo`,videoUrl:`URL de la vidéo`,urlPlaceholder:`YouTube, Vimeo ou URL .mp4 directe`,widthLabel:`Largeur (px)`,widthPlaceholder:`560`,insertBtn:`Insérer`,cancelBtn:`Annuler`,detected:e=>`Détecté\u00a0: ${e}`,unknownFormat:`Format inconnu — tentative d'intégration directe`,invalidUrl:`URL invalide — veuillez saisir un lien vidéo valide.`},emojiDialog:{ariaLabel:`Insérer un emoji`,title:`Insérer un emoji`,searchPlaceholder:`Rechercher des emojis…`,all:`Tout`,cancelBtn:`Annuler`,close:`Fermer`,categories:{smileys:`Smileys`,people:`Personnes`,animals:`Animaux`,food:`Nourriture`,travel:`Voyage`,objects:`Objets`,symbols:`Symboles`}},iconDialog:{ariaLabel:`Insérer une icône FA`,title:`Insérer une icône FA`,searchPlaceholder:`Rechercher des icônes…`,all:`Tout`,style:`Style`,size:`Taille`,color:`Couleur`,useColor:` Utiliser la couleur`,selectHint:`Sélectionner une icône`,insertBtn:`Insérer une icône FA`,cancelBtn:`Annuler`,close:`Fermer`,categories:{popular:`Populaire`,interface:`Interface`,navigation:`Navigation`,media:`Média`,communication:`Communication`,files:`Fichiers`,people:`Personnes`,objects:`Objets`}},findReplace:{findTitle:`Rechercher`,findReplaceTitle:`Rechercher et remplacer`,findPlaceholder:`Rechercher…`,searchAriaLabel:`Texte à rechercher`,caseSensitive:`\xA0Respecter la casse`,wholeWord:`Mot entier`,prevBtn:`← Préc.`,nextBtn:`Suiv. →`,replacePlaceholder:`Remplacer par…`,replaceAriaLabel:`Remplacer par`,replaceBtn:`Remplacer`,noResults:`Aucun résultat`,useRegex:`Utiliser une expression régulière`,prevMatch:`Précédent (Maj+Entrée)`,nextMatch:`Suivant (Entrée)`,replaceAllBtn:`Tout remplacer`,close:`×`},shortcutsDialog:{title:`Raccourcis clavier`,ariaLabel:`Raccourcis clavier`,close:`Fermer`,customCategory:`Personnalisés`,shortcuts:[{category:`Mise en forme du texte`,items:[{keys:`Ctrl + B`,action:`Gras`},{keys:`Ctrl + I`,action:`Italique`},{keys:`Ctrl + U`,action:`Souligné`},{keys:`Ctrl + K`,action:`Insérer / modifier un lien`}]},{category:`Historique`,items:[{keys:`Ctrl + Z`,action:`Annuler`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Rétablir`}]},{category:`Sélection et navigation`,items:[{keys:`Ctrl + A`,action:`Tout sélectionner`},{keys:`Tab`,action:`Augmenter le retrait / insérer des espaces`},{keys:`Shift + Tab`,action:`Diminuer le retrait`}]},{category:`Presse-papiers`,items:[{keys:`Ctrl + Shift + V`,action:`Coller en texte brut`}]},{category:`Rechercher et remplacer`,items:[{keys:`Ctrl + F`,action:`Rechercher dans le document`},{keys:`Ctrl + H`,action:`Rechercher et remplacer`}]},{category:`Éditeur`,items:[{keys:`Ctrl + Shift + /`,action:`Afficher les raccourcis clavier`}]}]},contextMenu:{cut:`Couper`,copy:`Copier`,paste:`Coller`,bold:`Gras`,italic:`Italique`,underline:`Souligné`,textColor:`Couleur du texte`,highlightColor:`Couleur de surbrillance`,copyFormat:`Copier la mise en forme`,pasteFormat:`Coller la mise en forme`,removeFormat:`Effacer la mise en forme`,link:`Insérer un lien`,image:`Insérer une image`,video:`Insérer une vidéo`,table:`Insérer un tableau`,back:`Retour`,noHighlight:`Sans surbrillance`,customColor:`Couleur personnalisée`,customColorLabel:`Personnaliser…`},statusbar:{resizeHandle:`Faire glisser pour redimensionner`,words:e=>`Mots\u00a0: ${e}`,wordsLimit:(e,t)=>`Mots\u00a0: ${e}/${t}`,chars:e=>`Caractères\u00a0: ${e}`,charsLimit:(e,t)=>`Caractères\u00a0: ${e}/${t}`},a11y:{editor:`Éditeur de texte enrichi`,toolbar:`Barre d'outils de l'éditeur`,statistics:`Statistiques de l'éditeur`,tableSize:`Choisir la taille du tableau`},tooltips:{link:{ariaLabel:`Actions du lien`,openLink:`Ouvrir le lien`,copyUrl:`Copier l'URL`,editLink:`Modifier le lien`,removeLink:`Supprimer le lien`},image:{ariaLabel:`Actions de l'image`,label:`Image`,floatLeft:`Flottant à gauche`,noFloat:`Sans flottant`,alignCenter:`Centré`,floatRight:`Flottant à droite`,originalSize:`Taille originale`,rotateLeft:`Rotation à gauche`,rotateRight:`Rotation à droite`,cropImage:`Recadrer l'image`,addCaption:`Ajouter / modifier la légende`,deleteImage:`Supprimer l'image`},code:{ariaLabel:`Actions du bloc de code`,label:`Code`,syntaxLanguage:`Langage de syntaxe`,syntaxAriaLabel:`Langage de syntaxe`,copyCode:`Copier le code`,toggleWordWrap:`Activer/désactiver le retour à la ligne`,enableWordWrap:`Activer le retour à la ligne`,disableWordWrap:`Désactiver le retour à la ligne`,convertToParagraph:`Convertir en paragraphe`,deleteCodeBlock:`Supprimer le bloc de code`,lineNumbers:`Activer/désactiver les numéros de ligne`},table:{ariaLabel:`Actions du tableau`,label:`Tableau`,selectCells:`Sélectionner des cellules`,addRowAbove:`Ajouter une ligne au-dessus`,addRowBelow:`Ajouter une ligne en-dessous`,deleteRow:`Supprimer la ligne`,addColumnLeft:`Ajouter une colonne à gauche`,addColumnRight:`Ajouter une colonne à droite`,deleteColumn:`Supprimer la colonne`,mergeCells:`Fusionner les cellules`,unmergeCells:`Scinder les cellules`,columnWidth:`Largeur de colonne`,rowHeight:`Hauteur de ligne`,tableBorderWidth:`Épaisseur des bordures`,tableBorderColor:`Couleur de bordure`,deleteTable:`Supprimer le tableau`,cellAlignLeft:`Aligner à gauche`,cellAlignCenter:`Centrer`,cellAlignRight:`Aligner à droite`,cellAlignJustify:`Justifier`,toggleHeaderRow:`Ligne d'en-tête`,cellBackground:`Couleur de fond`,noShading:`Aucun fond`,noBorderColor:`Aucune bordure`,columnWidthPx:`Largeur de colonne (px)`,rowHeightPx:`Hauteur de ligne (px)`,tableBorderWidthPx:`Épaisseur des bordures (px)`,cancelBtn:`Annuler`,applyBtn:`Appliquer`,sortAsc:`Trier par ordre croissant`,sortDesc:`Trier par ordre décroissant`,exportCSV:`Exporter en CSV`,cellPadding:`Rembourrage des cellules`,cellPaddingPx:`Rembourrage des cellules (px)`},video:{ariaLabel:`Actions de la vidéo`,label:`Vidéo`,floatLeft:`Flottant à gauche`,noFloat:`Sans flottant`,alignCenter:`Centré`,floatRight:`Flottant à droite`,originalSize:`Taille originale`,previewVideo:`Aperçu`,exitPreview:`Quitter l'aperçu`,deleteVideo:`Supprimer la vidéo`}},errors:{imageFormat:e=>`Le format "${e}" n'est pas pris en charge par le navigateur. Veuillez le convertir en JPEG, PNG ou WebP.`,imageSize:e=>`Le fichier image est trop volumineux. La taille maximale autorisée est de ${e}\u00a0Mo.`},autoSaveRestore:{found:`Brouillon trouvé. Restaurer ?`,foundAt:`Brouillon du {date}. Restaurer ?`,restore:`Restaurer`,discard:`Ignorer`},slashMenu:{noResults:`Aucune commande correspondante`,heading1:`Titre 1`,heading2:`Titre 2`,heading3:`Titre 3`,bulletList:`Liste à puces`,numberedList:`Liste numérotée`,checklist:`Liste de contrôle`,blockquote:`Citation`,codeBlock:`Bloc de code`,horizontalRule:`Ligne horizontale`,table:`Tableau`,image:`Image`}}),c(`de`,{toolbar:{bold:`Fett (Ctrl+B)`,italic:`Kursiv (Ctrl+I)`,underline:`Unterstrichen (Ctrl+U)`,strikethrough:`Durchgestrichen`,superscript:`Hochgestellt`,subscript:`Tiefgestellt`,alignLeft:`Linksbündig`,alignCenter:`Zentriert`,alignRight:`Rechtsbündig`,alignJustify:`Blocksatz`,ul:`Ungeordnete Liste`,ol:`Geordnete Liste`,checklist:`Checkliste`,indent:`Einzug vergrößern`,outdent:`Einzug verkleinern`,undo:`Rückgängig (Ctrl+Z)`,redo:`Wiederholen (Ctrl+Y)`,hr:`Horizontale Linie`,link:`Link einfügen`,image:`Bild einfügen`,video:`Video einfügen`,emoji:`Emoji einfügen`,icon:`FA-Symbol einfügen`,table:`Tabelle einfügen`,fontSize:`Schriftgröße`,fontSizePlaceholder:`Größe`,removeFormat:`Formatierung entfernen`,direction:`Textrichtung umschalten (LTR / RTL)`,fontFamily:`Schriftart`,paragraphStyle:`Absatzstil`,paragraphStylePlaceholder:`Stil`,lineHeight:`Zeilenhöhe`,lineHeightPlaceholder:`↕ Zeile`,codeview:`HTML-Code-Ansicht`,fullscreen:`Vollbild`,shortcuts:`Tastenkürzel (Ctrl+Shift+/)`,find:`Suchen (Ctrl+F)`,findReplace:`Suchen & Ersetzen (Ctrl+H)`,inlineCode:"Inline-Code (Ctrl+`)",print:`Drucken`,foreColor:`Textfarbe`,backColor:`Hervorhebungsfarbe`,chooseTextColor:`Textfarbe auswählen`,chooseHighlightColor:`Hervorhebungsfarbe auswählen`,customColor:`Benutzerdefinierte Farbe`,insertTableLabel:`Tabelle einfügen`,paragraphItems:{p:`Normal`,blockquote:`Zitat`,pre:`Code`}},linkDialog:{ariaLabel:`Link einfügen`,title:`Link einfügen`,url:`URL`,urlPlaceholder:`https://`,displayText:`Anzeigetext`,textPlaceholder:`Linktext`,openInNewTab:`In neuem Tab öffnen`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`},imageDialog:{ariaLabel:`Bild einfügen`,title:`Bild einfügen`,imageUrl:`Bild-URL`,urlPlaceholder:`https://example.com/image.png`,altText:`Alt-Text`,altPlaceholder:`Bild beschreiben`,alignment:`Ausrichtung`,alignNone:`Keine`,alignLeft:`Links`,alignCenter:`Mitte`,alignRight:`Rechts`,uploadLabel:`Oder Datei hochladen`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`},videoDialog:{ariaLabel:`Video einfügen`,title:`Video einfügen`,videoUrl:`Video-URL`,urlPlaceholder:`YouTube, Vimeo oder direkte .mp4-URL`,widthLabel:`Breite (px)`,widthPlaceholder:`560`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`,detected:e=>`Erkannt: ${e}`,unknownFormat:`Unbekanntes Format — direktes Video-Einbetten wird versucht`,invalidUrl:`Ungültige URL — bitte geben Sie einen gültigen Videolink ein.`},emojiDialog:{ariaLabel:`Emoji einfügen`,title:`Emoji einfügen`,searchPlaceholder:`Emojis suchen…`,all:`Alle`,cancelBtn:`Abbrechen`,close:`Schließen`,categories:{smileys:`Smileys`,people:`Menschen`,animals:`Tiere`,food:`Essen`,travel:`Reisen`,objects:`Objekte`,symbols:`Symbole`}},iconDialog:{ariaLabel:`FA-Symbol einfügen`,title:`FA-Symbol einfügen`,searchPlaceholder:`Symbole suchen…`,all:`Alle`,style:`Stil`,size:`Größe`,color:`Farbe`,useColor:` Farbe verwenden`,selectHint:`Symbol auswählen`,insertBtn:`FA-Symbol einfügen`,cancelBtn:`Abbrechen`,close:`Schließen`,categories:{popular:`Beliebt`,interface:`Benutzeroberfläche`,navigation:`Navigation`,media:`Medien`,communication:`Kommunikation`,files:`Dateien`,people:`Menschen`,objects:`Objekte`}},findReplace:{findTitle:`Suchen`,findReplaceTitle:`Suchen & Ersetzen`,findPlaceholder:`Suchen…`,searchAriaLabel:`Suchtext`,caseSensitive:`\xA0Groß-/Kleinschreibung`,wholeWord:`Ganzes Wort`,prevBtn:`← Zurück`,nextBtn:`Weiter →`,replacePlaceholder:`Ersetzen durch…`,replaceAriaLabel:`Ersetzen durch`,replaceBtn:`Ersetzen`,noResults:`Keine Ergebnisse`,useRegex:`Regulären Ausdruck verwenden`,prevMatch:`Zurück (Umschalt+Eingabe)`,nextMatch:`Weiter (Eingabe)`,replaceAllBtn:`Alle ersetzen`,close:`×`},shortcutsDialog:{title:`Tastenkürzel`,ariaLabel:`Tastenkürzel`,close:`Schließen`,customCategory:`Benutzerdefiniert`,shortcuts:[{category:`Textformatierung`,items:[{keys:`Ctrl + B`,action:`Fett`},{keys:`Ctrl + I`,action:`Kursiv`},{keys:`Ctrl + U`,action:`Unterstrichen`},{keys:`Ctrl + K`,action:`Link einfügen / bearbeiten`}]},{category:`Verlauf`,items:[{keys:`Ctrl + Z`,action:`Rückgängig`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Wiederholen`}]},{category:`Auswahl & Navigation`,items:[{keys:`Ctrl + A`,action:`Alles auswählen`},{keys:`Tab`,action:`Listenebene erhöhen / Leerzeichen einfügen`},{keys:`Shift + Tab`,action:`Listenebene verringern`}]},{category:`Zwischenablage`,items:[{keys:`Ctrl + Shift + V`,action:`Als einfachen Text einfügen`}]},{category:`Suchen & Ersetzen`,items:[{keys:`Ctrl + F`,action:`Im Dokument suchen`},{keys:`Ctrl + H`,action:`Suchen & Ersetzen`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Diesen Tastenkürzel-Dialog anzeigen`}]}]},contextMenu:{cut:`Ausschneiden`,copy:`Kopieren`,paste:`Einfügen`,bold:`Fett`,italic:`Kursiv`,underline:`Unterstrichen`,textColor:`Textfarbe`,highlightColor:`Hervorhebungsfarbe`,copyFormat:`Format kopieren`,pasteFormat:`Format einfügen`,removeFormat:`Formatierung entfernen`,link:`Link einfügen`,image:`Bild einfügen`,video:`Video einfügen`,table:`Tabelle einfügen`,back:`Zurück`,noHighlight:`Keine Hervorhebung`,customColor:`Benutzerdefinierte Farbe`,customColorLabel:`Benutzerdefiniert…`},statusbar:{resizeHandle:`Editor-Größe ändern`,words:e=>`Wörter: ${e}`,wordsLimit:(e,t)=>`Wörter: ${e}/${t}`,chars:e=>`Zeichen: ${e}`,charsLimit:(e,t)=>`Zeichen: ${e}/${t}`},a11y:{editor:`Rich-Text-Editor`,toolbar:`Editor-Werkzeugleiste`,statistics:`Editor-Statistik`,tableSize:`Tabellengröße wählen`},tooltips:{link:{ariaLabel:`Link-Aktionen`,openLink:`Link öffnen`,copyUrl:`URL kopieren`,editLink:`Link bearbeiten`,removeLink:`Link entfernen`},image:{ariaLabel:`Bild-Aktionen`,label:`Bild`,floatLeft:`Links umfließen`,noFloat:`Kein Umfluss`,alignCenter:`Zentriert`,floatRight:`Rechts umfließen`,originalSize:`Originalgröße`,rotateLeft:`Links drehen`,rotateRight:`Rechts drehen`,cropImage:`Bild zuschneiden`,addCaption:`Beschriftung hinzufügen / bearbeiten`,deleteImage:`Bild löschen`},code:{ariaLabel:`Codeblock-Aktionen`,label:`Code`,syntaxLanguage:`Syntaxsprache`,syntaxAriaLabel:`Syntaxsprache`,copyCode:`Code kopieren`,toggleWordWrap:`Zeilenumbruch umschalten`,enableWordWrap:`Zeilenumbruch aktivieren`,disableWordWrap:`Zeilenumbruch deaktivieren`,convertToParagraph:`In Absatz umwandeln`,deleteCodeBlock:`Codeblock löschen`,lineNumbers:`Zeilennummern umschalten`},table:{ariaLabel:`Tabellen-Aktionen`,label:`Tabelle`,selectCells:`Zellen auswählen`,addRowAbove:`Zeile oben hinzufügen`,addRowBelow:`Zeile unten hinzufügen`,deleteRow:`Zeile löschen`,addColumnLeft:`Spalte links hinzufügen`,addColumnRight:`Spalte rechts hinzufügen`,deleteColumn:`Spalte löschen`,mergeCells:`Zellen zusammenführen`,unmergeCells:`Zellen trennen`,columnWidth:`Spaltenbreite`,rowHeight:`Zeilenhöhe`,tableBorderWidth:`Tabellenrahmenbreite`,tableBorderColor:`Tabellenrahmenfarbe`,deleteTable:`Tabelle löschen`,cellAlignLeft:`Linksbündig`,cellAlignCenter:`Zentrieren`,cellAlignRight:`Rechtsbündig`,cellAlignJustify:`Blocksatz`,toggleHeaderRow:`Kopfzeile umschalten`,cellBackground:`Zellhintergrund`,noShading:`Kein Hintergrund`,noBorderColor:`Keine Rahmenfarbe`,columnWidthPx:`Spaltenbreite (px)`,rowHeightPx:`Zeilenhöhe (px)`,tableBorderWidthPx:`Tabellenrahmenbreite (px)`,cancelBtn:`Abbrechen`,applyBtn:`Anwenden`,sortAsc:`Aufsteigend sortieren`,sortDesc:`Absteigend sortieren`,exportCSV:`Als CSV exportieren`,cellPadding:`Zellauffüllung`,cellPaddingPx:`Zellauffüllung (px)`},video:{ariaLabel:`Video-Aktionen`,label:`Video`,floatLeft:`Links umfließen`,noFloat:`Kein Umfluss`,alignCenter:`Zentriert`,floatRight:`Rechts umfließen`,originalSize:`Originalgröße`,previewVideo:`Video-Vorschau`,exitPreview:`Vorschau beenden`,deleteVideo:`Video löschen`}},errors:{imageFormat:e=>`Das Format „${e}" wird in Webbrowsern nicht unterstützt. Bitte konvertieren Sie es zuerst in JPEG, PNG oder WebP.`,imageSize:e=>`Die Bilddatei ist zu groß. Die maximal zulässige Größe beträgt ${e} MB.`},autoSaveRestore:{found:`Entwurf gefunden. Wiederherstellen?`,foundAt:`Entwurf vom {date}. Wiederherstellen?`,restore:`Wiederherstellen`,discard:`Verwerfen`},slashMenu:{noResults:`Keine passenden Befehle`,heading1:`Überschrift 1`,heading2:`Überschrift 2`,heading3:`Überschrift 3`,bulletList:`Aufzählungsliste`,numberedList:`Nummerierte Liste`,checklist:`Checkliste`,blockquote:`Zitat`,codeBlock:`Codeblock`,horizontalRule:`Horizontale Linie`,table:`Tabelle`,image:`Bild`}}),c(`es`,{toolbar:{bold:`Negrita (Ctrl+B)`,italic:`Cursiva (Ctrl+I)`,underline:`Subrayado (Ctrl+U)`,strikethrough:`Tachado`,superscript:`Superíndice`,subscript:`Subíndice`,alignLeft:`Alinear a la izquierda`,alignCenter:`Centrar`,alignRight:`Alinear a la derecha`,alignJustify:`Justificar`,ul:`Lista sin orden`,ol:`Lista ordenada`,checklist:`Lista de verificación`,indent:`Aumentar sangría`,outdent:`Reducir sangría`,undo:`Deshacer (Ctrl+Z)`,redo:`Rehacer (Ctrl+Y)`,hr:`Línea horizontal`,link:`Insertar enlace`,image:`Insertar imagen`,video:`Insertar vídeo`,emoji:`Insertar emoji`,icon:`Insertar icono FA`,table:`Insertar tabla`,fontSize:`Tamaño de fuente`,fontSizePlaceholder:`Tamaño`,removeFormat:`Eliminar formato`,direction:`Cambiar dirección del texto (LTR / RTL)`,fontFamily:`Fuente`,paragraphStyle:`Estilo de párrafo`,paragraphStylePlaceholder:`Estilo`,lineHeight:`Interlineado`,lineHeightPlaceholder:`↕ Línea`,codeview:`Vista de código HTML`,fullscreen:`Pantalla completa`,shortcuts:`Atajos de teclado (Ctrl+Shift+/)`,find:`Buscar (Ctrl+F)`,findReplace:`Buscar y reemplazar (Ctrl+H)`,inlineCode:"Código en línea (Ctrl+`)",print:`Imprimir`,foreColor:`Color del texto`,backColor:`Color de resaltado`,chooseTextColor:`Elegir color del texto`,chooseHighlightColor:`Elegir color de resaltado`,customColor:`Color personalizado`,insertTableLabel:`Insertar tabla`,paragraphItems:{p:`Normal`,blockquote:`Cita`,pre:`Código`}},linkDialog:{ariaLabel:`Insertar enlace`,title:`Insertar enlace`,url:`URL`,urlPlaceholder:`https://`,displayText:`Texto a mostrar`,textPlaceholder:`Texto del enlace`,openInNewTab:`Abrir en nueva pestaña`,insertBtn:`Insertar`,cancelBtn:`Cancelar`},imageDialog:{ariaLabel:`Insertar imagen`,title:`Insertar imagen`,imageUrl:`URL de imagen`,urlPlaceholder:`https://example.com/image.png`,altText:`Texto alternativo`,altPlaceholder:`Describir la imagen`,alignment:`Alineación`,alignNone:`Ninguna`,alignLeft:`Izquierda`,alignCenter:`Centro`,alignRight:`Derecha`,uploadLabel:`O subir un archivo`,insertBtn:`Insertar`,cancelBtn:`Cancelar`},videoDialog:{ariaLabel:`Insertar vídeo`,title:`Insertar vídeo`,videoUrl:`URL del vídeo`,urlPlaceholder:`YouTube, Vimeo o URL directa .mp4`,widthLabel:`Ancho (px)`,widthPlaceholder:`560`,insertBtn:`Insertar`,cancelBtn:`Cancelar`,detected:e=>`Detectado: ${e}`,unknownFormat:`Formato desconocido — se intentará incrustar el vídeo directamente`,invalidUrl:`URL no válida — introduzca un enlace de vídeo válido.`},emojiDialog:{ariaLabel:`Insertar emoji`,title:`Insertar emoji`,searchPlaceholder:`Buscar emojis…`,all:`Todos`,cancelBtn:`Cancelar`,close:`Cerrar`,categories:{smileys:`Caritas`,people:`Personas`,animals:`Animales`,food:`Comida`,travel:`Viajes`,objects:`Objetos`,symbols:`Símbolos`}},iconDialog:{ariaLabel:`Insertar icono FA`,title:`Insertar icono FA`,searchPlaceholder:`Buscar iconos…`,all:`Todos`,style:`Estilo`,size:`Tamaño`,color:`Color`,useColor:` Usar color`,selectHint:`Seleccionar un icono`,insertBtn:`Insertar icono FA`,cancelBtn:`Cancelar`,close:`Cerrar`,categories:{popular:`Popular`,interface:`Interfaz`,navigation:`Navegación`,media:`Medios`,communication:`Comunicación`,files:`Archivos`,people:`Personas`,objects:`Objetos`}},findReplace:{findTitle:`Buscar`,findReplaceTitle:`Buscar y reemplazar`,findPlaceholder:`Buscar…`,searchAriaLabel:`Texto de búsqueda`,caseSensitive:`\xA0Distinguir mayúsculas`,wholeWord:`Palabra completa`,prevBtn:`← Anterior`,nextBtn:`Siguiente →`,replacePlaceholder:`Reemplazar con…`,replaceAriaLabel:`Reemplazar con`,replaceBtn:`Reemplazar`,noResults:`Sin resultados`,useRegex:`Usar expresión regular`,prevMatch:`Anterior (Mayús+Intro)`,nextMatch:`Siguiente (Intro)`,replaceAllBtn:`Reemplazar todo`,close:`×`},shortcutsDialog:{title:`Atajos de teclado`,ariaLabel:`Atajos de teclado`,close:`Cerrar`,customCategory:`Personalizados`,shortcuts:[{category:`Formato de texto`,items:[{keys:`Ctrl + B`,action:`Negrita`},{keys:`Ctrl + I`,action:`Cursiva`},{keys:`Ctrl + U`,action:`Subrayado`},{keys:`Ctrl + K`,action:`Insertar / editar enlace`}]},{category:`Historial`,items:[{keys:`Ctrl + Z`,action:`Deshacer`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Rehacer`}]},{category:`Selección y navegación`,items:[{keys:`Ctrl + A`,action:`Seleccionar todo`},{keys:`Tab`,action:`Aumentar sangría / insertar espacios`},{keys:`Shift + Tab`,action:`Reducir sangría`}]},{category:`Portapapeles`,items:[{keys:`Ctrl + Shift + V`,action:`Pegar como texto plano`}]},{category:`Buscar y reemplazar`,items:[{keys:`Ctrl + F`,action:`Buscar en el documento`},{keys:`Ctrl + H`,action:`Buscar y reemplazar`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Mostrar este diálogo de atajos`}]}]},contextMenu:{cut:`Cortar`,copy:`Copiar`,paste:`Pegar`,bold:`Negrita`,italic:`Cursiva`,underline:`Subrayado`,textColor:`Color del texto`,highlightColor:`Color de resaltado`,copyFormat:`Copiar formato`,pasteFormat:`Pegar formato`,removeFormat:`Eliminar formato`,link:`Insertar enlace`,image:`Insertar imagen`,video:`Insertar vídeo`,table:`Insertar tabla`,back:`Atrás`,noHighlight:`Sin resaltado`,customColor:`Color personalizado`,customColorLabel:`Personalizado…`},statusbar:{resizeHandle:`Redimensionar editor`,words:e=>`Palabras: ${e}`,wordsLimit:(e,t)=>`Palabras: ${e}/${t}`,chars:e=>`Caracteres: ${e}`,charsLimit:(e,t)=>`Caracteres: ${e}/${t}`},a11y:{editor:`Editor de texto enriquecido`,toolbar:`Barra de herramientas del editor`,statistics:`Estadísticas del editor`,tableSize:`Seleccionar tamaño de tabla`},tooltips:{link:{ariaLabel:`Acciones de enlace`,openLink:`Abrir enlace`,copyUrl:`Copiar URL`,editLink:`Editar enlace`,removeLink:`Eliminar enlace`},image:{ariaLabel:`Acciones de imagen`,label:`Imagen`,floatLeft:`Flotar a la izquierda`,noFloat:`Sin flotado`,alignCenter:`Centrar`,floatRight:`Flotar a la derecha`,originalSize:`Tamaño original`,rotateLeft:`Rotar a la izquierda`,rotateRight:`Rotar a la derecha`,cropImage:`Recortar imagen`,addCaption:`Añadir / editar pie de foto`,deleteImage:`Eliminar imagen`},code:{ariaLabel:`Acciones de bloque de código`,label:`Código`,syntaxLanguage:`Lenguaje de sintaxis`,syntaxAriaLabel:`Lenguaje de sintaxis`,copyCode:`Copiar código`,toggleWordWrap:`Alternar ajuste de línea`,enableWordWrap:`Activar ajuste de línea`,disableWordWrap:`Desactivar ajuste de línea`,convertToParagraph:`Convertir en párrafo`,deleteCodeBlock:`Eliminar bloque de código`,lineNumbers:`Alternar números de línea`},table:{ariaLabel:`Acciones de tabla`,label:`Tabla`,selectCells:`Seleccionar celdas`,addRowAbove:`Añadir fila encima`,addRowBelow:`Añadir fila debajo`,deleteRow:`Eliminar fila`,addColumnLeft:`Añadir columna a la izquierda`,addColumnRight:`Añadir columna a la derecha`,deleteColumn:`Eliminar columna`,mergeCells:`Combinar celdas`,unmergeCells:`Separar celdas`,columnWidth:`Ancho de columna`,rowHeight:`Alto de fila`,tableBorderWidth:`Grosor del borde de la tabla`,tableBorderColor:`Color del borde de la tabla`,deleteTable:`Eliminar tabla`,cellAlignLeft:`Alinear a la izquierda`,cellAlignCenter:`Centrar`,cellAlignRight:`Alinear a la derecha`,cellAlignJustify:`Justificar`,toggleHeaderRow:`Activar fila de encabezado`,cellBackground:`Fondo de celda`,noShading:`Sin fondo`,noBorderColor:`Sin color de borde`,columnWidthPx:`Ancho de columna (px)`,rowHeightPx:`Alto de fila (px)`,tableBorderWidthPx:`Grosor del borde (px)`,cancelBtn:`Cancelar`,applyBtn:`Aplicar`,sortAsc:`Ordenar ascendente`,sortDesc:`Ordenar descendente`,exportCSV:`Exportar como CSV`,cellPadding:`Relleno de celda`,cellPaddingPx:`Relleno de celda (px)`},video:{ariaLabel:`Acciones de vídeo`,label:`Vídeo`,floatLeft:`Flotar a la izquierda`,noFloat:`Sin flotado`,alignCenter:`Centrar`,floatRight:`Flotar a la derecha`,originalSize:`Tamaño original`,previewVideo:`Vista previa de vídeo`,exitPreview:`Salir de la vista previa`,deleteVideo:`Eliminar vídeo`}},errors:{imageFormat:e=>`El formato "${e}" no es compatible con los navegadores web. Por favor, conviértalo primero a JPEG, PNG o WebP.`,imageSize:e=>`El archivo de imagen es demasiado grande. El tamaño máximo permitido es ${e} MB.`},autoSaveRestore:{found:`Borrador encontrado. ¿Restaurar?`,foundAt:`Borrador del {date}. ¿Restaurar?`,restore:`Restaurar`,discard:`Descartar`},slashMenu:{noResults:`No hay comandos coincidentes`,heading1:`Encabezado 1`,heading2:`Encabezado 2`,heading3:`Encabezado 3`,bulletList:`Lista con viñetas`,numberedList:`Lista numerada`,checklist:`Lista de verificación`,blockquote:`Cita`,codeBlock:`Bloque de código`,horizontalRule:`Línea horizontal`,table:`Tabla`,image:`Imagen`}}),c(`ko`,{toolbar:{bold:`굵게 (Ctrl+B)`,italic:`기울임꼴 (Ctrl+I)`,underline:`밑줄 (Ctrl+U)`,strikethrough:`취소선`,superscript:`위 첨자`,subscript:`아래 첨자`,alignLeft:`왼쪽 정렬`,alignCenter:`가운데 정렬`,alignRight:`오른쪽 정렬`,alignJustify:`양쪽 정렬`,ul:`순서 없는 목록`,ol:`순서 있는 목록`,checklist:`체크리스트`,indent:`들여쓰기`,outdent:`내어쓰기`,undo:`실행 취소 (Ctrl+Z)`,redo:`다시 실행 (Ctrl+Y)`,hr:`수평선`,link:`링크 삽입`,image:`이미지 삽입`,video:`동영상 삽입`,emoji:`이모지 삽입`,icon:`FA 아이콘 삽입`,table:`표 삽입`,fontSize:`글꼴 크기`,fontSizePlaceholder:`크기`,removeFormat:`서식 제거`,direction:`텍스트 방향 전환 (LTR / RTL)`,fontFamily:`글꼴`,paragraphStyle:`단락 스타일`,paragraphStylePlaceholder:`스타일`,lineHeight:`줄 간격`,lineHeightPlaceholder:`↕ 줄`,codeview:`HTML 코드 보기`,fullscreen:`전체 화면`,shortcuts:`키보드 단축키 (Ctrl+Shift+/)`,find:`찾기 (Ctrl+F)`,findReplace:`찾기 및 바꾸기 (Ctrl+H)`,inlineCode:"인라인 코드 (Ctrl+`)",print:`인쇄`,foreColor:`글자 색`,backColor:`강조 색`,chooseTextColor:`글자 색 선택`,chooseHighlightColor:`강조 색 선택`,customColor:`사용자 지정 색`,insertTableLabel:`표 삽입`,paragraphItems:{p:`기본`,blockquote:`인용`,pre:`코드`}},linkDialog:{ariaLabel:`링크 삽입`,title:`링크 삽입`,url:`URL`,urlPlaceholder:`https://`,displayText:`표시 텍스트`,textPlaceholder:`링크 텍스트`,openInNewTab:`새 탭에서 열기`,insertBtn:`삽입`,cancelBtn:`취소`},imageDialog:{ariaLabel:`이미지 삽입`,title:`이미지 삽입`,imageUrl:`이미지 URL`,urlPlaceholder:`https://example.com/image.png`,altText:`대체 텍스트`,altPlaceholder:`이미지 설명`,alignment:`정렬`,alignNone:`없음`,alignLeft:`왼쪽`,alignCenter:`가운데`,alignRight:`오른쪽`,uploadLabel:`또는 파일 업로드`,insertBtn:`삽입`,cancelBtn:`취소`},videoDialog:{ariaLabel:`동영상 삽입`,title:`동영상 삽입`,videoUrl:`동영상 URL`,urlPlaceholder:`YouTube, Vimeo 또는 직접 .mp4 URL`,widthLabel:`너비 (px)`,widthPlaceholder:`560`,insertBtn:`삽입`,cancelBtn:`취소`,detected:e=>`감지됨: ${e}`,unknownFormat:`알 수 없는 형식 — 직접 동영상 임베드를 시도합니다`,invalidUrl:`유효하지 않은 URL — 올바른 동영상 링크를 입력하세요.`},emojiDialog:{ariaLabel:`이모지 삽입`,title:`이모지 삽입`,searchPlaceholder:`이모지 검색…`,all:`전체`,cancelBtn:`취소`,close:`닫기`,categories:{smileys:`스마일`,people:`사람`,animals:`동물`,food:`음식`,travel:`여행`,objects:`사물`,symbols:`기호`}},iconDialog:{ariaLabel:`FA 아이콘 삽입`,title:`FA 아이콘 삽입`,searchPlaceholder:`아이콘 검색…`,all:`전체`,style:`스타일`,size:`크기`,color:`색상`,useColor:` 색상 사용`,selectHint:`아이콘을 선택하세요`,insertBtn:`FA 아이콘 삽입`,cancelBtn:`취소`,close:`닫기`,categories:{popular:`인기`,interface:`인터페이스`,navigation:`탐색`,media:`미디어`,communication:`커뮤니케이션`,files:`파일`,people:`사람`,objects:`사물`}},findReplace:{findTitle:`찾기`,findReplaceTitle:`찾기 및 바꾸기`,findPlaceholder:`찾기…`,searchAriaLabel:`검색 텍스트`,caseSensitive:`\xA0대소문자 구분`,wholeWord:`전체 단어`,prevBtn:`← 이전`,nextBtn:`다음 →`,replacePlaceholder:`바꿀 내용…`,replaceAriaLabel:`바꿀 내용`,replaceBtn:`바꾸기`,noResults:`결과 없음`,useRegex:`정규식 사용`,prevMatch:`이전 (Shift+Enter)`,nextMatch:`다음 (Enter)`,replaceAllBtn:`모두 바꾸기`,close:`×`},shortcutsDialog:{title:`키보드 단축키`,ariaLabel:`키보드 단축키`,close:`닫기`,customCategory:`사용자 지정`,shortcuts:[{category:`텍스트 서식`,items:[{keys:`Ctrl + B`,action:`굵게`},{keys:`Ctrl + I`,action:`기울임꼴`},{keys:`Ctrl + U`,action:`밑줄`},{keys:`Ctrl + K`,action:`링크 삽입 / 편집`}]},{category:`실행 기록`,items:[{keys:`Ctrl + Z`,action:`실행 취소`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`다시 실행`}]},{category:`선택 및 탐색`,items:[{keys:`Ctrl + A`,action:`전체 선택`},{keys:`Tab`,action:`목록 들여쓰기 / 공백 삽입`},{keys:`Shift + Tab`,action:`목록 내어쓰기`}]},{category:`클립보드`,items:[{keys:`Ctrl + Shift + V`,action:`일반 텍스트로 붙여넣기`}]},{category:`찾기 및 바꾸기`,items:[{keys:`Ctrl + F`,action:`문서에서 찾기`},{keys:`Ctrl + H`,action:`찾기 및 바꾸기`}]},{category:`편집기`,items:[{keys:`Ctrl + Shift + /`,action:`이 단축키 대화상자 표시`}]}]},contextMenu:{cut:`잘라내기`,copy:`복사`,paste:`붙여넣기`,bold:`굵게`,italic:`기울임꼴`,underline:`밑줄`,textColor:`글자 색`,highlightColor:`강조 색`,copyFormat:`서식 복사`,pasteFormat:`서식 붙여넣기`,removeFormat:`서식 제거`,link:`링크 삽입`,image:`이미지 삽입`,video:`동영상 삽입`,table:`표 삽입`,back:`뒤로`,noHighlight:`강조 없음`,customColor:`사용자 지정 색`,customColorLabel:`사용자 지정…`},statusbar:{resizeHandle:`편집기 크기 조정`,words:e=>`단어: ${e}`,wordsLimit:(e,t)=>`단어: ${e}/${t}`,chars:e=>`글자: ${e}`,charsLimit:(e,t)=>`글자: ${e}/${t}`},a11y:{editor:`서식 있는 텍스트 편집기`,toolbar:`편집기 도구 모음`,statistics:`편집기 통계`,tableSize:`표 크기 선택`},tooltips:{link:{ariaLabel:`링크 작업`,openLink:`링크 열기`,copyUrl:`URL 복사`,editLink:`링크 편집`,removeLink:`링크 제거`},image:{ariaLabel:`이미지 작업`,label:`이미지`,floatLeft:`왼쪽 배치`,noFloat:`배치 없음`,alignCenter:`가운데 정렬`,floatRight:`오른쪽 배치`,originalSize:`원본 크기`,rotateLeft:`왼쪽 회전`,rotateRight:`오른쪽 회전`,cropImage:`이미지 자르기`,addCaption:`캡션 추가 / 편집`,deleteImage:`이미지 삭제`},code:{ariaLabel:`코드 블록 작업`,label:`코드`,syntaxLanguage:`구문 언어`,syntaxAriaLabel:`구문 언어`,copyCode:`코드 복사`,toggleWordWrap:`줄 바꿈 전환`,enableWordWrap:`줄 바꿈 사용`,disableWordWrap:`줄 바꿈 해제`,convertToParagraph:`단락으로 변환`,deleteCodeBlock:`코드 블록 삭제`,lineNumbers:`줄 번호 전환`},table:{ariaLabel:`표 작업`,label:`표`,selectCells:`셀 선택`,addRowAbove:`위에 행 추가`,addRowBelow:`아래에 행 추가`,deleteRow:`행 삭제`,addColumnLeft:`왼쪽에 열 추가`,addColumnRight:`오른쪽에 열 추가`,deleteColumn:`열 삭제`,mergeCells:`셀 병합`,unmergeCells:`셀 분할`,columnWidth:`열 너비`,rowHeight:`행 높이`,tableBorderWidth:`표 테두리 너비`,tableBorderColor:`표 테두리 색상`,deleteTable:`표 삭제`,cellAlignLeft:`왼쪽 정렬`,cellAlignCenter:`가운데 정렬`,cellAlignRight:`오른쪽 정렬`,cellAlignJustify:`양쪽 정렬`,toggleHeaderRow:`머리글 행 전환`,cellBackground:`셀 배경색`,noShading:`배경 없음`,noBorderColor:`테두리 색 없음`,columnWidthPx:`열 너비 (px)`,rowHeightPx:`행 높이 (px)`,tableBorderWidthPx:`표 테두리 너비 (px)`,cancelBtn:`취소`,applyBtn:`적용`,sortAsc:`오름차순 정렬`,sortDesc:`내림차순 정렬`,exportCSV:`CSV로 내보내기`,cellPadding:`셀 패딩`,cellPaddingPx:`셀 패딩 (px)`},video:{ariaLabel:`동영상 작업`,label:`동영상`,floatLeft:`왼쪽 배치`,noFloat:`배치 없음`,alignCenter:`가운데 정렬`,floatRight:`오른쪽 배치`,originalSize:`원본 크기`,previewVideo:`동영상 미리보기`,exitPreview:`미리보기 종료`,deleteVideo:`동영상 삭제`}},errors:{imageFormat:e=>`"${e}" 형식은 웹 브라우저에서 지원되지 않습니다. JPEG, PNG 또는 WebP로 변환해 주세요.`,imageSize:e=>`이미지 파일이 너무 큽니다. 최대 허용 크기는 ${e} MB입니다.`},autoSaveRestore:{found:`초안을 찾았습니다. 복원하시겠습니까?`,foundAt:`{date}의 초안을 찾았습니다. 복원하시겠습니까?`,restore:`복원`,discard:`삭제`},slashMenu:{noResults:`일치하는 명령이 없습니다`,heading1:`제목 1`,heading2:`제목 2`,heading3:`제목 3`,bulletList:`글머리 기호 목록`,numberedList:`번호 매기기 목록`,checklist:`체크리스트`,blockquote:`인용문`,codeBlock:`코드 블록`,horizontalRule:`가로선`,table:`표`,image:`이미지`}});var u=e=>e?.nodeType===1,d=e=>u(e)&&/^(p|div|li|h[1-6]|blockquote|td|th|pre)$/i.test(e.nodeName),f=e=>u(e)&&/^(li)$/i.test(e.nodeName);function p(e,t,n){let r=e;for(;r&&r!==n;){if(t(r))return r;r=r.parentNode}return null}function m(e,t){return p(e,d,t)}function h(e,t={},n=[]){let r=document.createElement(e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);for(let e of n)typeof e==`string`?r.appendChild(document.createTextNode(e)):r.appendChild(e);return r}function g(e){let t=document.createRange();t.selectNodeContents(e),t.collapse(!1);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function _(e){if(e?.querySelectorAll)for(let t of e.querySelectorAll(`ul > ul, ul > ol, ol > ul, ol > ol`)){let e=t.previousElementSibling;if(e&&e.nodeName===`LI`)e.appendChild(t);else if(t.parentNode){let e=t.ownerDocument.createElement(`li`);t.parentNode.insertBefore(e,t),e.appendChild(t)}}}function v(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function y(e,t){let n=()=>Array.from(e.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.closest(`[style*="display: none"]`)&&!e.closest(`[style*="display:none"]`)),r=e=>{if(e.key===`Escape`){e.stopPropagation(),t?.();return}if(e.key!==`Tab`)return;let r=n();if(!r.length)return;let i=r[0],a=r.at(-1);e.shiftKey?document.activeElement===i&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),i.focus())};return document.addEventListener(`keydown`,r),()=>document.removeEventListener(`keydown`,r)}function b(e,t){e.style.cursor=`grab`;let n=n=>{if(n.button!==0||n.target.closest(`button, input, select, textarea, a`))return;if(n.preventDefault(),!t.dataset.anDragPinned){let e=t.getBoundingClientRect();t.style.position=`fixed`,t.style.margin=`0`,t.style.left=`${e.left}px`,t.style.top=`${e.top}px`,t.dataset.anDragPinned=`1`}let r=n.clientX-Number.parseFloat(t.style.left),i=n.clientY-Number.parseFloat(t.style.top);e.style.cursor=`grabbing`;let a=e=>{let n=t.offsetWidth,a=t.offsetHeight;t.style.left=`${Math.max(0,Math.min(e.clientX-r,globalThis.innerWidth-n))}px`,t.style.top=`${Math.max(0,Math.min(e.clientY-i,globalThis.innerHeight-a))}px`},o=()=>{e.style.cursor=`grab`,document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o)};document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o)};return e.addEventListener(`mousedown`,n),()=>e.removeEventListener(`mousedown`,n)}function x(e){return e?.layoutInfo?.portal||document.body}var S=class{constructor(e,t,n,r){this.sc=e,this.so=t,this.ec=n,this.eo=r}isCollapsed(){return this.sc===this.ec&&this.so===this.eo}toNativeRange(){let e=document.createRange();try{e.setStart(this.sc,this.so),e.setEnd(this.ec,this.eo)}catch{}return e}select(){let e=globalThis.getSelection();e&&(e.removeAllRanges(),e.addRange(this.toNativeRange()))}commonAncestor(){let e=this.toNativeRange().commonAncestorContainer;return u(e)?e:e.parentElement}blockNode(e){return p(this.sc,t=>u(t)&&t!==e,e)}toString(){return this.toNativeRange().toString()}getClientRects(){let e=this.toNativeRange().getClientRects();return e.length>0?e[e.length-1]:null}insertNode(e){this.toNativeRange().insertNode(e)}};function C(e){return new S(e.startContainer,e.startOffset,e.endContainer,e.endOffset)}function w(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return null;let n=t.getRangeAt(0);return e&&!e.contains(n.commonAncestorContainer)?null:C(n)}function ee(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0){e(null);return}let n=t.getRangeAt(0).cloneRange();e(C(n)),t.removeAllRanges(),t.addRange(n)}function T(e){let t=e&&e.nodeType===1?e:e?.parentElement;for(;t;){let e=t.getAttribute?.(`contenteditable`)??t.contentEditable;if(e===`false`)return null;if(e!=null&&e!==`inherit`)return t;t=t.parentElement}return null}function E(e){let t=globalThis.getSelection?.();if(!t||t.rangeCount===0)return null;let n=t.getRangeAt(0);return e&&e!==document?e.contains(n.commonAncestorContainer)?n:null:T(n.commonAncestorContainer)?n:null}function D(e){let t=globalThis.getSelection?.();if(!t)return;let n=document.createRange();n.setStartAfter(e),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}function te(e,t){let n=E(t);if(!n)return!1;let r=document.createElement(`template`);r.innerHTML=e;let i=r.content,a=i.lastChild;return n.deleteContents(),n.insertNode(i),a&&D(a),!0}function ne(e,t){let n=E(t);if(!n)return!1;n.deleteContents();let r=String(e),i=document.createDocumentFragment();!r.includes(`
2
- `)||O(n.startContainer,t)?i.appendChild(document.createTextNode(r)):r.split(`
3
- `).forEach((e,t)=>{t>0&&i.appendChild(document.createElement(`br`)),e&&i.appendChild(document.createTextNode(e))});let a=i.lastChild;return n.insertNode(i),a&&D(a),!0}function re(e){return ne(`
4
- `,e)}function O(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n&&n!==t;){if(n.tagName===`PRE`||n.tagName===`TEXTAREA`)return!0;let e=globalThis.getComputedStyle?.(n)?.whiteSpace;if(e&&e.startsWith(`pre`))return!0;n=n.parentElement}return!1}function ie(e){let t=E(e);if(!t)return!1;let n=document.createElement(`hr`);t.deleteContents();let r=oe(t.startContainer,e);r&&r.parentNode?r.parentNode.insertBefore(n,r.nextSibling):t.insertNode(n);let i=n.nextElementSibling;if(!i||i.tagName===`HR`){let e=document.createElement(`p`);e.appendChild(document.createElement(`br`)),n.parentNode?.insertBefore(e,n.nextSibling),i=e}let a=globalThis.getSelection?.();if(a){let e=document.createRange();e.setStart(i,0),e.collapse(!0),a.removeAllRanges(),a.addRange(e)}return!0}var ae=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`PRE`,`LI`]);function oe(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n&&n!==t;){if(ae.has(n.tagName))return n;n=n.parentElement}return null}function k(e,t=null){return e===`insertHTML`&&te(String(t??``))||e===`insertText`&&ne(String(t??``))||e===`insertLineBreak`&&re()||e===`insertHorizontalRule`&&ie()?!0:document.execCommand(e,!1,t)}var se=()=>k(`bold`),ce=()=>k(`italic`);function le(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`u`),r=document.queryCommandState(`underline`);if(n&&!r){let e=n.parentNode;for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove();return}k(`underline`)}function ue(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).startContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`s`)||t?.closest(`strike`),r=document.queryCommandState(`strikeThrough`);if(n&&!r){let e=n.parentNode;for(;n.firstChild;)e.insertBefore(n.firstChild,n);n.remove();return}k(`strikeThrough`)}var de=()=>k(`superscript`),fe=()=>k(`subscript`),pe=e=>k(`foreColor`,e),me=e=>k(`hiliteColor`,e),he=e=>k(`fontName`,e);function ge(e,t=document){let n=globalThis.getSelection(),r=!n?.rangeCount||n.getRangeAt(0).collapsed;if(r&&n?.rangeCount>0){try{let t=n.getRangeAt(0),r=document.createElement(`span`);r.style.fontSize=e;let i=document.createTextNode(`​`);r.appendChild(i),t.insertNode(r);let a=document.createRange();a.setStart(i,i.textContent.length),a.collapse(!0),n.removeAllRanges(),n.addRange(a)}catch{}return}k(`fontSize`,`7`);let i=t instanceof HTMLElement?t:document,a=[];if(i.querySelectorAll(`font[size="7"]`).forEach(t=>{let n=document.createElement(`span`);for(n.style.fontSize=e,t.parentNode.insertBefore(n,t);t.firstChild;)n.appendChild(t.firstChild);t.remove(),a.push(n)}),!r&&n&&a.length>0){let e=a[0],t=a.at(-1);try{let r=document.createRange(),i=e.firstChild||e,a=t.lastChild||t;r.setStart(i,0),r.setEnd(a,a.nodeType===Node.TEXT_NODE?a.textContent.length:a.childNodes.length),n.removeAllRanges(),n.addRange(r)}catch{}}}var _e=e=>k(`formatBlock`,`<${e}>`),ve=()=>k(`justifyLeft`),ye=()=>k(`justifyCenter`),be=()=>k(`justifyRight`),xe=()=>k(`justifyFull`);function Se(){k(`indent`),_(Ce())}function Ce(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=null;for(let e=t;e;e=e.parentElement)(e.nodeName===`UL`||e.nodeName===`OL`)&&(n=e);return n}function we(){let e=globalThis.getSelection();if(e?.rangeCount){let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`.an-checklist li`);if(n){Ee(n);return}}Te()||k(`outdent`)}function Te(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest?.(`li`);if(!n)return!1;let r=n.parentElement;if(!r||r.nodeName!==`UL`&&r.nodeName!==`OL`)return!1;let i=r.parentElement;if(!i||i.nodeName!==`LI`||!i.parentNode)return!1;let a=[];for(let e=n.nextElementSibling;e;e=e.nextElementSibling)a.push(e);if(a.length){let e=n.ownerDocument.createElement(r.nodeName.toLowerCase());a.forEach(t=>e.appendChild(t)),n.appendChild(e)}return i.parentNode.insertBefore(n,i.nextSibling),r.children.length||r.remove(),!0}function Ee(e){let t=e.closest(`.an-checklist`);if(!t)return;let n=Array.from(t.children),r=n.indexOf(e),i=n.slice(r+1),a=document.createElement(`p`);for(let t of e.childNodes)(t.nodeType!==1||t.tagName!==`INPUT`)&&a.appendChild(t.cloneNode(!0));if(a.innerHTML=a.innerHTML.replaceAll(`​`,``),(!a.hasChildNodes()||!a.textContent.trim())&&(a.innerHTML=``,a.appendChild(document.createTextNode(`\xA0`))),i.length>0){let e=document.createElement(`ul`);e.className=`an-checklist`,i.forEach(t=>e.appendChild(t)),t.parentNode.insertBefore(e,t.nextSibling)}t.parentNode.insertBefore(a,t.nextSibling),e.remove(),t.children.length===0&&t.remove();try{let e=document.createRange(),t=a.firstChild;e.setStart(t?.nodeType===3?t:a,0),e.collapse(!0);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(e))}catch{}}function De(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0).commonAncestorContainer;return t.nodeType===3&&(t=t.parentElement),t?.closest(`ul, ol`)||null}function Oe(e){e.classList.remove(`an-checklist`),e.querySelectorAll(`input[type="checkbox"]`).forEach(e=>e.remove())}function ke(){let e=De();e?e.classList.contains(`an-checklist`)?(Oe(e),e.tagName===`OL`&&Pe(e,`ul`)):e.tagName===`OL`?Pe(e,`ul`):k(`insertUnorderedList`):k(`insertUnorderedList`)}function Ae(){let e=De();e?e.classList.contains(`an-checklist`)?(Oe(e),Pe(e,`ol`)):e.tagName===`UL`?Pe(e,`ol`):k(`insertOrderedList`):k(`insertOrderedList`)}function je(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return;let n=t.getRangeAt(0),r=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`BLOCKQUOTE`,`PRE`,`TD`,`TH`]),i=e=>{let t=e instanceof Element?e:e.parentElement;for(;t;){if(r.has(t.tagName))return t;t=t.parentElement}return null};if(n.collapsed){let t=i(n.startContainer);t&&(t.style.lineHeight=e);return}let a=new Set,o=document.createTreeWalker(n.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:e=>n.intersectsNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}),s;for(;s=o.nextNode();){let e=i(s);e&&a.add(e)}if(a.size===0){let e=i(n.commonAncestorContainer);e&&a.add(e)}a.forEach(t=>{t.style.lineHeight=e})}function Me(e){let t=globalThis.getSelection();if(!t?.rangeCount)return;let n=t.getRangeAt(0),r=n.commonAncestorContainer;r.nodeType===3&&(r=r.parentElement);let i=r?.closest(`code`);if(i&&!i.closest(`pre`)){let e=i.parentNode,n=i.previousSibling,r=Array.from(i.childNodes);for(;i.firstChild;)e.insertBefore(i.firstChild,i);if(i.remove(),e?.normalize(),r.length>0)try{let i=r[0],a=r.at(-1),o=document.createRange(),s=i.parentNode===e?i:n?n.nextSibling:e.firstChild;if(s){o.setStart(s,0);let n=a.parentNode===e?a:s;o.setEnd(n,n.nodeType===Node.TEXT_NODE?n.textContent.length:n.childNodes.length),t.removeAllRanges(),t.addRange(o)}}catch{}}else{if(n.collapsed)return;try{let e=document.createElement(`code`);n.surroundContents(e);let r=document.createRange();r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r)}catch{let e=n.extractContents(),r=document.createElement(`code`);r.appendChild(e),n.insertNode(r);let i=document.createRange();i.selectNodeContents(r),t.removeAllRanges(),t.addRange(i)}}}function Ne(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`code`);return!!(n&&!n.closest(`pre`))}function Pe(e,t){let n=document.createElement(t);for(let t of e.attributes)n.setAttribute(t.name,t.value);for(;e.firstChild;)n.appendChild(e.firstChild);return e.parentNode.replaceChild(n,e),n}function Fe(e){e.querySelectorAll(`li`).forEach(e=>{if(!e.querySelector(`input[type="checkbox"]`)){let t=document.createElement(`input`);t.type=`checkbox`,t.contentEditable=`false`,e.insertBefore(t,e.firstChild)}})}function Ie(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0),n=t.commonAncestorContainer;n.nodeType===3&&(n=n.parentElement);let r=n?.closest(`ul, ol`);if(r){if(r.classList.contains(`an-checklist`)){if(r.parentNode){let t=Array.from(r.children),n=null;if(t.forEach(e=>{let t=document.createElement(`p`);for(let n of e.childNodes)(n.nodeType!==1||n.tagName!==`INPUT`)&&t.appendChild(n.cloneNode(!0));t.innerHTML=t.innerHTML.replaceAll(`​`,``).replaceAll(`​`,``),(!t.hasChildNodes()||!t.textContent.trim())&&(t.innerHTML=``,t.appendChild(document.createTextNode(`\xA0`))),r.before(t),n||=t}),r.remove(),n){let t=document.createRange();t.setStart(n.firstChild||n,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}}}else{let t=Pe(r,`ul`);t.classList.add(`an-checklist`),Fe(t);let n=t.querySelector(`li`);if(n){let t=document.createRange();t.selectNodeContents(n),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}}else{let r=n?.closest(`[contenteditable="true"]`);if(t.collapsed){let t=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`LI`]),i=n;for(;i?.parentNode&&i!==r&&!t.has(i.tagName);)i=i.parentNode;i===r&&(i=null);let a=i&&t.has(i.tagName)?Array.from(i.childNodes).map(e=>e.textContent).join(``).replaceAll(`\xA0`,` `):``,o=document.createElement(`ul`);o.className=`an-checklist`;let s=document.createElement(`li`),c=document.createElement(`input`);if(c.type=`checkbox`,c.contentEditable=`false`,s.appendChild(c),s.appendChild(document.createTextNode(a||`​`)),o.appendChild(s),i&&t.has(i.tagName))i.parentNode.replaceChild(o,i);else{let t=e.getRangeAt(0);t.deleteContents(),t.insertNode(o)}let l=s.lastChild,u=document.createRange(),d=l.nodeType===Node.TEXT_NODE?l.textContent.length:0;u.setStart(l,d),u.collapse(!0),e.removeAllRanges(),e.addRange(u);return}if(!e.toString().replace(/[\u00a0\u200B]/g,` `).trim())return;let i=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`PRE`,`LI`]),a=[],o=new Set,s=t.commonAncestorContainer,c=document.createNodeIterator(s.nodeType===Node.TEXT_NODE?s.parentNode:s,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,null),l;for(;l=c.nextNode();){if(!t.intersectsNode(l))continue;let e=l.nodeType===Node.TEXT_NODE?l.parentElement:l;for(;e&&e!==r&&!i.has(e.tagName);)e=e.parentElement;e===r&&(e=null),e&&!o.has(e)&&(o.add(e),a.push(e))}if(a.length===0)return;let u=document.createElement(`ul`);u.className=`an-checklist`;let d=null;a.forEach(e=>{let t=document.createElement(`li`),n=document.createElement(`input`);n.type=`checkbox`,n.contentEditable=`false`,t.appendChild(n);let r=Array.from(e.childNodes).map(e=>e.textContent).join(``).replace(/[\u00a0\u200B]/g,` `).trim(),i=document.createTextNode(r||`​`);t.appendChild(i),u.appendChild(t),d=i});let f=a[0];if(f.parentNode.insertBefore(u,f),a.forEach(e=>e.remove()),d){let t=document.createRange();t.setStart(d,d.textContent.length),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}}}function Le(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).commonAncestorContainer;return t.nodeType===3&&(t=t.parentElement),!!t?.closest(`.an-checklist li`)}function A(e,t,n,r,i,a){return{name:e,icon:t,tooltip:n,action:r,isActive:i,isDisabled:a}}var Re=new Map;function ze(e){if(!e||typeof e.name!=`string`){console.warn("[AutumnNote] registerButton: btnDef must have a string `name` property.");return}Re.has(e.name)&&console.warn(`[AutumnNote] registerButton: overwriting existing button "${e.name}".`),Re.set(e.name,e)}function Be(e){return Re.get(e)??He().get(e)}var Ve=null;function He(){return Ve??=new Map(Object.values(Lt).filter(e=>e&&!Array.isArray(e)&&typeof e.name==`string`).map(e=>[e.name,e])),Ve}function Ue(e,t){let n=t?.buttons;if(Array.isArray(n)){let t=n.find(t=>t?.name===e);if(t)return t}else if(n&&typeof n==`object`&&n[e])return{name:e,...n[e]};return Be(e)}var We=new Map;function Ge(e,t){if(typeof e!=`string`||typeof t!=`string`){console.warn(`[AutumnNote] registerIcon: name and icon must be strings.`);return}We.set(e,t)}function Ke(e){let t=e.trim();return t.startsWith(`<`)?t:`<i class="${t.replace(/["<>&]/g,``)}" aria-hidden="true"></i>`}function qe(e,t){let n=e?.icons;for(let e of t){if(!e)continue;let t=n&&typeof n[e]==`string`?n[e]:We.get(e);if(typeof t==`string`&&t.trim())return Ke(t)}return null}var Je=[`8px`,`10px`,`11px`,`12px`,`13px`,`14px`,`16px`,`18px`,`20px`,`24px`,`28px`,`32px`,`36px`,`48px`,`72px`],Ye=[`1.0`,`1.15`,`1.5`,`1.75`,`2.0`,`2.5`,`3.0`],Xe=[{value:`p`,label:`Normal`},{value:`h1`,label:`H1`},{value:`h2`,label:`H2`},{value:`h3`,label:`H3`},{value:`h4`,label:`H4`},{value:`h5`,label:`H5`},{value:`h6`,label:`H6`},{value:`blockquote`,label:`Quote`},{value:`pre`,label:`Code`}],Ze=A(`bold`,`bold`,`Bold (Ctrl+B)`,()=>se(),()=>document.queryCommandState(`bold`)),Qe=A(`italic`,`italic`,`Italic (Ctrl+I)`,()=>ce(),()=>document.queryCommandState(`italic`)),$e=A(`underline`,`underline`,`Underline (Ctrl+U)`,()=>le(),()=>{if(document.queryCommandState(`underline`))return!0;let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;return t.nodeType===3&&(t=t.parentElement),!!t?.closest(`u`)}),et=A(`strikethrough`,`strikethrough`,`Strikethrough`,()=>ue(),()=>document.queryCommandState(`strikeThrough`)),tt=A(`superscript`,`superscript`,`Superscript`,()=>de(),()=>document.queryCommandState(`superscript`)),nt=A(`subscript`,`subscript`,`Subscript`,()=>fe(),()=>document.queryCommandState(`subscript`)),rt=A(`alignLeft`,`align-left`,`Align Left`,()=>ve()),it=A(`alignCenter`,`align-center`,`Align Center`,()=>ye()),at=A(`alignRight`,`align-right`,`Align Right`,()=>be()),ot=A(`alignJustify`,`align-justify`,`Justify`,()=>xe()),st=A(`ul`,`list-ul`,`Unordered List`,()=>ke()),ct=A(`ol`,`list-ol`,`Ordered List`,()=>Ae()),lt=A(`indent`,`indent`,`Indent`,()=>Se()),ut=A(`outdent`,`outdent`,`Outdent`,()=>we()),dt=A(`undo`,`undo`,`Undo (Ctrl+Z)`,e=>e.invoke(`editor.undo`),void 0,e=>!e.invoke(`editor.canUndo`)),ft=A(`redo`,`redo`,`Redo (Ctrl+Y)`,e=>e.invoke(`editor.redo`),void 0,e=>!e.invoke(`editor.canRedo`)),pt=A(`hr`,`minus`,`Horizontal Rule`,()=>k(`insertHorizontalRule`)),mt=A(`link`,`link`,`Insert Link`,e=>e.invoke(`linkDialog.show`)),ht=A(`image`,`image`,`Insert Image`,e=>e.invoke(`imageDialog.show`)),gt=A(`video`,`video`,`Insert Video`,e=>e.invoke(`videoDialog.show`)),_t=A(`emoji`,`emoji`,`Insert Emoji`,e=>e.invoke(`emojiDialog.show`)),vt=A(`icon`,`icon`,`Insert FA Icon`,e=>e.invoke(`iconDialog.show`)),yt={name:`table`,type:`grid`,icon:`table`,tooltip:`Insert Table`,action:(e,t,n)=>{e.invoke(`editor.insertTable`,n,t),e.invoke(`editor.afterCommand`)}},bt={name:`fontSize`,type:`select`,tooltip:`Font Size`,placeholder:`Size`,selectClass:`an-select-narrow`,items:Je,action:(e,t)=>ge(t,e.layoutInfo.editable),getValue:e=>{try{let t=globalThis.getSelection();if(t?.rangeCount){let e=t.getRangeAt(0).startContainer;for(e?.nodeType===3&&(e=e.parentElement);e?.nodeType===1&&!e.style.fontSize;)e=e.parentElement;let n=e?.style.fontSize||``;if(n)return n}let n=e?.layoutInfo?.editable;return n&&n.style.fontSize||``}catch{return``}}},xt=A(`removeFormat`,`remove-format`,`Remove Format`,()=>k(`removeFormat`)),St=A(`direction`,`direction`,`Toggle Text Direction (LTR / RTL)`,e=>{let t=e.layoutInfo.editable,n=(t.getAttribute(`dir`)||`ltr`)===`ltr`?`rtl`:`ltr`;t.setAttribute(`dir`,n),t.style.textAlign=n===`rtl`?`right`:`left`,e.invoke(`editor.afterCommand`)}),Ct={name:`fontFamily`,type:`select`,tooltip:`Font Family`,action:(e,t)=>he(t),getValue:()=>{try{return document.queryCommandValue(`fontName`)||``}catch{return``}}},wt={name:`paragraphStyle`,type:`select`,tooltip:`Paragraph Style`,placeholder:`Style`,selectClass:`an-select-style`,items:Xe,action:(e,t)=>_e(t),getValue:()=>{try{let e=document.queryCommandValue(`formatBlock`).toLowerCase().replace(/[<>]/g,``);return e===`div`?`p`:e||`p`}catch{return``}}},Tt={name:`lineHeight`,type:`select`,tooltip:`Line Height`,placeholder:`↕ Line`,selectClass:`an-select-narrow`,items:Ye,action:(e,t)=>je(t),getValue:()=>{try{let e=globalThis.getSelection();if(!e?.rangeCount)return``;let t=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`BLOCKQUOTE`,`PRE`,`TD`,`TH`]),n=e.getRangeAt(0).startContainer;for(n?.nodeType===3&&(n=n.parentElement);n&&!t.has(n.tagName);)n=n.parentElement;return n&&(n.style.lineHeight||getComputedStyle(n).lineHeight)||``}catch{return``}}},Et=A(`codeview`,`code`,`HTML Code View`,e=>e.invoke(`codeview.toggle`),e=>e.invoke(`codeview.isActive`)),Dt=A(`fullscreen`,`expand`,`Fullscreen`,e=>e.invoke(`fullscreen.toggle`),e=>e.invoke(`fullscreen.isActive`)),Ot=A(`shortcuts`,`keyboard`,`Keyboard Shortcuts (Ctrl+Shift+/)`,e=>e.invoke(`shortcutsDialog.show`)),kt=A(`find`,`search`,`Find (Ctrl+F)`,e=>e.invoke(`findReplace.show`,`find`)),At=A(`findReplace`,`find-replace`,`Find & Replace (Ctrl+H)`,e=>e.invoke(`findReplace.show`,`replace`)),jt=A(`inlineCode`,`inline-code`,"Inline Code (Ctrl+`)",e=>e.invoke(`editor.inlineCode`),()=>Ne()),Mt=A(`checklist`,`checklist`,`Checklist`,e=>e.invoke(`editor.toggleChecklist`),()=>Le()),Nt=A(`print`,`print`,`Print`,e=>e.invoke(`editor.print`)),Pt={name:`foreColor`,type:`colorpicker`,icon:`foreColor`,tooltip:`Text Color`,defaultColor:`#e11d48`,action:(e,t)=>pe(t)},Ft={name:`backColor`,type:`colorpicker`,icon:`backColor`,tooltip:`Highlight Color`,defaultColor:`#fbbf24`,action:(e,t)=>me(t)},It=[[wt,Ct,bt,Tt],[dt,ft],[Ze,Qe,$e,et,jt],[tt,nt],[Pt,Ft],[rt,it,at,ot],[st,ct,Mt,lt,ut],[pt,mt,ht,gt,yt,_t,vt],[xt,Et,Dt,kt,Nt,Ot]],Lt={boldBtn:Ze,italicBtn:Qe,underlineBtn:$e,strikeBtn:et,superscriptBtn:tt,subscriptBtn:nt,alignLeftBtn:rt,alignCenterBtn:it,alignRightBtn:at,alignJustifyBtn:ot,ulBtn:st,olBtn:ct,indentBtn:lt,outdentBtn:ut,undoBtn:dt,redoBtn:ft,hrBtn:pt,linkBtn:mt,imageBtn:ht,videoBtn:gt,emojiBtn:_t,iconBtn:vt,tableBtn:yt,fontSizeBtn:bt,removeFormatBtn:xt,directionBtn:St,fontFamilyBtn:Ct,paragraphStyleBtn:wt,lineHeightBtn:Tt,codeviewBtn:Et,fullscreenBtn:Dt,shortcutsBtn:Ot,findBtn:kt,findReplaceBtn:At,inlineCodeBtn:jt,checklistBtn:Mt,printBtn:Nt,foreColorBtn:Pt,backColorBtn:Ft,defaultToolbar:It},j={placeholder:``,height:200,minHeight:100,maxHeight:0,focus:!1,resizable:!0,statusbar:!0,toolbar:It,useBootstrap:!1,toolbarButtonClass:`btn btn-sm btn-light`,useFontAwesome:!0,fontAwesomeClass:`fas`,fontAwesomeAutoInject:!0,fontAwesomeCDN:`https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css`,pasteAsPlainText:!1,pasteCleanHTML:!0,pasteStripAttributes:!1,allowImageUpload:!0,maxImageSize:5,tabSize:4,onChange:null,onFocus:null,onBlur:null,onInit:null,onImageUpload:null,onImageError:null,stickyToolbar:!1,stickyToolbarOffset:0,theme:`light`,themeVars:null,zIndexOffset:0,popupContainer:null,codeHighlight:!0,codeHighlightCDN:`https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0`,cspNonce:``,externalAssetCrossOrigin:`anonymous`,externalAssetReferrerPolicy:`no-referrer`,markdownPaste:!0,historyLimit:100,historyMaxBytes:10485760,defaultFontFamily:`Arial`,defaultFontSize:`14px`,fontSizes:[...Je],lineHeights:[...Ye],paragraphStyles:Xe.map(e=>({...e})),colorPalette:null,icons:null,buttons:null,keyMap:null,linkDefaults:{openInNewTab:!1,rel:`noopener noreferrer`,defaultProtocol:`https://`},videoProviders:null,iframeHosts:null,fontFamilies:[`Arial`,`Arial Black`,`Comic Sans MS`,`Courier New`,`Georgia`,`Impact`,`Tahoma`,`Times New Roman`,`Trebuchet MS`,`Verdana`],readOnly:!1,spellcheck:!0,direction:`ltr`,toolbarOverflow:`wrap`,autoSave:!1,autoSaveKey:`autumnnote-autosave`,autoSaveDelay:400,autoSaveAdapter:null,maxChars:0,maxWords:0,tableHeaderRow:!1,onSelectionChange:null,colorSwatches:[],onPaste:null,onPasteError:null,onDestroy:null,onBeforeCommand:null,onCharLimitReached:null,onWordLimitReached:null,focusColor:null,lang:`en`,autoSaveRestore:!1,autoSaveRestoreTimeout:7,onAutoSaveRestore:null,markdownShortcuts:!0,slashMenu:!0,slashCommands:[],documentAdapters:{},collaborationAdapter:null,imageProcessor:null,blockIds:!1,maxPasteSize:5242880,minImageSize:20,bubbleToolbar:!1,bubbleToolbarItems:[`bold`,`italic`,`underline`,`link`,`foreColor`,`hiliteColor`,`removeFormat`],contextMenu:null,mention:null},Rt=[`script`,`style`,`iframe`,`object`,`embed`,`form`,`base`,`template`,`link`,`meta`,`noscript`,`portal`,`frame`,`frameset`,`applet`,`animate`,`set`,`animatetransform`,`animatemotion`,`mglyph`,`malignmark`,`annotation-xml`],zt=new Set([`button`]),Bt=[`href`,`src`,`action`,`formaction`,`xlink:href`,`poster`,`background`,`srcset`],Vt=new Set([`poster`,`background`,`srcset`]),Ht=new Set([`ping`]),Ut=new Set([`color`,`background-color`,`font-size`,`line-height`,`text-align`,`vertical-align`,`width`,`min-width`,`height`,`min-height`,`border-width`,`border-style`,`border-color`,`padding`,`white-space`]),Wt=/url\s*\(|image-set\s*\(|src\s*\(|expression\s*\(|@import|javascript:|vbscript:|behavior\s*:|-moz-binding/i,Gt=new Set([`www.youtube.com`,`youtube.com`,`m.youtube.com`,`www.youtube-nocookie.com`,`youtube-nocookie.com`,`player.vimeo.com`]),Kt=new Set([`http:`,`https:`,`mailto:`,`tel:`]),qt=new Set([`http:`,`https:`,`blob:`]),Jt=/^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i,Yt=`https://autumnnote.invalid/`;function M(e,t){return Xt(e,t).innerHTML}function Xt(e,{allowIframes:t=!1,iframeHosts:n=null}={}){let r=new DOMParser().parseFromString(`<body>${e||``}</body>`,`text/html`),i=$t(n),a=Array.from(r.querySelectorAll(`*`)),o=new Set(t?Rt.filter(e=>e!==`iframe`):Rt);for(let e of a){let t=e.tagName.toLowerCase();if(zt.has(t)){e.replaceWith(...e.childNodes);continue}if(o.has(t)){e.remove();continue}if(t===`iframe`){let t=e.getAttribute(`src`);if(!t||!en(t,i)){e.remove();continue}}for(let t of Array.from(e.attributes)){if(t.name.startsWith(`on`)){e.removeAttribute(t.name);continue}if(t.name===`style`){let n=Zt(t.value);n?e.setAttribute(`style`,n):e.removeAttribute(`style`);continue}if(Ht.has(t.name)){e.removeAttribute(t.name);continue}if(Bt.includes(t.name)){let n=t.value.trim(),r=Vt.has(t.name)||t.name===`src`&&[`IMG`,`VIDEO`,`AUDIO`,`SOURCE`].includes(e.tagName),i=e.tagName===`IMG`;if(!(t.name===`srcset`?Qt(n,{allowData:i}):nn(n,{media:r,allowData:i}))){e.removeAttribute(t.name);continue}}if(e.tagName===`IFRAME`){if(t.name===`srcdoc`){e.removeAttribute(t.name);continue}t.name===`src`&&!en(t.value,i)&&e.removeAttribute(t.name)}}if(t===`a`&&e.getAttribute(`target`)===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`),t===`input`){if(e.closest(`ul.an-checklist`)===null||e.closest(`li`)===null||e.getAttribute(`type`)!==`checkbox`)e.remove();else for(let t of Array.from(e.attributes))[`type`,`checked`,`contenteditable`].includes(t.name)||e.removeAttribute(t.name)}}return r.body}function Zt(e){let t=[];for(let n of(e||``).split(`;`)){let e=n.indexOf(`:`);if(e===-1)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();!r||!i||Ut.has(r)&&(Wt.test(i)||t.push(`${r}: ${i}`))}return t.join(`; `)}function Qt(e,{allowData:t=!1}={}){let n=(e||``).trim().split(/\s+/).filter(Boolean);for(let e of n){if(/^[\d.]+[xw],?$/i.test(e))continue;let n=e.replace(/,+$/,``);if(n&&!nn(n,{media:!0,allowData:t}))return!1}return!0}function $t(e){let t=new Set;if(!e||typeof e[Symbol.iterator]!=`function`||typeof e==`string`)return t;for(let n of e){let e=typeof n==`string`?n.trim().toLowerCase():``;/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/.test(e)?t.add(e):console.warn(`[AutumnNote] iframeHosts: ignoring "${n}" — use a bare hostname such as "player.example.com".`)}return t}function en(e,t){let n=(e||``).trim();if(!n||n.startsWith(`//`)||n.startsWith(`/`))return!1;try{let e=new URL(n);if(e.protocol!==`https:`)return!1;let r=e.hostname.toLowerCase();return Gt.has(r)||!!t?.has(r)}catch{return!1}}function tn(e,t){return en(e,$t(t))}function N(e,{allowData:t=!1,media:n=t}={}){let r=(e||``).trim();return!r&&e==null?null:nn(r,{media:n,allowData:t})?e:null}function nn(e,{media:t=!1,allowData:n=!1}={}){let r=(e||``).trim();if(!r||n&&Jt.test(r))return!0;try{let e=new URL(r,Yt);return(t?qt:Kt).has(e.protocol)}catch{return!1}}function rn(e,t){let n=h(`div`,{class:`an-container`}),r=h(`div`,{class:`an-editable`,contenteditable:t.readOnly?`false`:`true`,spellcheck:String(t.spellcheck!==!1),"aria-multiline":`true`,"aria-label":`Rich text editor`,role:`textbox`}),i=``;if(t.autoSave&&t.autoSaveKey)try{i=localStorage.getItem(t.autoSaveKey)||``}catch{}i||=e.tagName===`TEXTAREA`?(e.value||``).trim():(e.innerHTML||``).trim(),r.innerHTML=M(i,{allowIframes:!0,iframeHosts:t.iframeHosts});let a=t.defaultFontFamily||t.fontFamilies?.[0];return a&&(r.style.fontFamily=a),t.defaultFontSize&&(r.style.fontSize=t.defaultFontSize),t.height?r.style.minHeight=`${t.height}px`:t.minHeight&&(r.style.minHeight=`${t.minHeight}px`),t.maxHeight&&(r.style.maxHeight=`${t.maxHeight}px`),n.appendChild(r),t.readOnly&&(n.classList.add(`an-disabled`),r.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.setAttribute(`disabled`,``)})),t.direction===`rtl`&&(r.setAttribute(`dir`,`rtl`),n.classList.add(`an-dir-rtl`)),ln(n,null,t),e.style.display=`none`,e.after(n),{container:n,editable:r}}var an=[`an-theme-dark`,`an-theme-auto`];function on(e){return e.startsWith(`--`)?e:`--an-${e}`}function sn(e){let t=h(`div`,{class:`an-portal`,"data-an-portal":``});return cn(e.popupContainer).appendChild(t),t}function cn(e){if(typeof e==`string`&&e){let t=document.querySelector(e);if(t)return t;console.warn(`[AutumnNote] popupContainer "${e}" matched nothing; using document.body.`)}else if(e&&typeof e.appendChild==`function`)return e;return document.body}function ln(e,t,n){let r=t?[e,t]:[e],i=n.theme===`dark`?`an-theme-dark`:n.theme===`auto`?`an-theme-auto`:null;for(let e of r){e.classList.remove(...an),i&&e.classList.add(i);for(let t of Array.from(e.style))t.startsWith(`--an-`)&&e.style.removeProperty(t);let t=n.themeVars;if(t&&typeof t==`object`)for(let[n,r]of Object.entries(t))(typeof r==`string`||typeof r==`number`)&&e.style.setProperty(on(n),String(r));n.focusColor&&e.style.setProperty(`--an-focus-color`,n.focusColor);let r=Number(n.zIndexOffset)||0;r&&e.style.setProperty(`--an-z-offset`,String(Math.trunc(r)))}e.classList.toggle(`an-toolbar-overflow-scroll`,n.toolbarOverflow===`scroll`),e.classList.toggle(`an-sticky-toolbar`,!!n.stickyToolbar),n.stickyToolbar&&n.stickyToolbarOffset&&e.style.setProperty(`--an-sticky-top`,`${n.stickyToolbarOffset}px`)}var un=new Map,dn=[];function fn(e){dn=Array.isArray(e)?e:[]}var pn=[`theme`,`themeVars`,`focusColor`,`zIndexOffset`,`toolbarOverflow`,`stickyToolbar`,`stickyToolbarOffset`],mn=[`toolbar`,`useFontAwesome`,`fontAwesomeClass`,`useBootstrap`,`toolbarButtonClass`,`icons`,`buttons`,`fontFamilies`,`fontSizes`,`lineHeights`,`paragraphStyles`,`colorPalette`,`colorSwatches`],hn=[`lang`],gn=new Map,_n=class{constructor(e,t={}){this.targetEl=e,this.options=r(j,t),this.locale=l(this.options.lang),this.layoutInfo={},this._listeners=new Map,this._modules=new Map,this._plugins=new Map,this._disposers=[],this._alive=!1,this._autoSaveTimer=null,this._pendingAutoSave=null,this._suppressedRemoteHTML=null,this._destroyPromise=null,this._releaseInstance=null}initialize(){let{container:e,editable:t}=rn(this.targetEl,this.options);this.layoutInfo.container=e,this.layoutInfo.editable=t,t.setAttribute(`aria-label`,this.locale.a11y?.editor||`Rich text editor`);let n=sn(this.options);this.layoutInfo.portal=n,ln(e,n,this.options),this._registerModules();let r=this._modules.get(`toolbar`);r?.el&&(e.insertBefore(r.el,t),this.layoutInfo.toolbar=r.el);let i=this._modules.get(`statusbar`);return i?.el&&(e.appendChild(i.el),this.layoutInfo.statusbar=i.el),this._bindEditorEvents(t),this.options.focus&&t.focus(),this._alive=!0,this.invoke(`toolbar.refresh`),this._applyGlobalPlugins(),this.triggerEvent(`init`,this),this}_registerModules(){let e=(e,t)=>{let n=new t(this);this._modules.set(e,n),n.initialize()};for(let{name:t,Class:n,enabled:r}of dn)typeof r==`function`&&!r(this.options)||e(t,n);if(un.size>0)for(let[t,n]of un)e(t,n)}_syncOptionalModules(){for(let{name:e,Class:t,enabled:n}of dn){if(typeof n!=`function`)continue;let r=n(this.options);if(r!==this._modules.has(e)){if(r){let n=new t(this);this._modules.set(e,n),n.initialize()}else{let t=this._modules.get(e);typeof t?.destroy==`function`&&t.destroy(),this._modules.delete(e)}}}}registerModule(e,t){if(this._modules.has(e))return this;let n=new t(this);return n.initialize(),this._modules.set(e,n),this}registerSlashCommand(e){if(!e?.id||typeof e.run!=`function`)throw TypeError(`[AutumnNote] Slash command requires an id and run(context) function.`);let t=this.options.slashCommands||(this.options.slashCommands=[]),n=t.findIndex(t=>t.id===e.id);return n>=0?t[n]=e:t.push(e),this.invoke(`slashMenu.refresh`),this}use(e,t={}){return Array.isArray(e.buttons)&&e.buttons.forEach(e=>ze(e)),this._installPlugin(e,t),this}getPlugin(e){return this._plugins.get(e)?.publicApi??null}_installPlugin(e,t={}){let{name:n}=e;if(!n||typeof n!=`string`){console.warn("[AutumnNote] Plugin must have a string `name` property.");return}if(this._plugins.has(n)){console.warn(`[AutumnNote] Plugin "${n}" already installed on this instance. Skipping.`);return}let r=typeof e.install==`function`?e.install(this,t)??null:null;this._plugins.set(n,{plugin:e,publicApi:r})}_applyGlobalPlugins(){if(gn.size!==0)for(let{plugin:e,options:t}of gn.values())this._installPlugin(e,t)}_bindEditorEvents(e){let t=v(e,`input`,()=>this._syncToTarget()),n=v(e,`focus`,()=>{this.layoutInfo.container.classList.add(`an-focused`),this.triggerEvent(`focus`,this)}),r=v(e,`blur`,()=>{this.layoutInfo.container.classList.remove(`an-focused`),this._syncToTarget(),this.triggerEvent(`blur`,this)}),i=this.on(`change`,e=>this._syncToTarget(e)),a=this.on(`change`,e=>{if(this.options.blockIds&&(this.ensureBlockIds(),e=this.getHTML()),e===this._suppressedRemoteHTML){this._suppressedRemoteHTML=null;return}this.options.collaborationAdapter?.onLocalChange?.(e,this)});if(this._disposers.push(t,n,r,i,a),this.options.autoSave&&this.options.autoSaveKey){let e=this.on(`change`,e=>this._scheduleAutoSave(e));this._disposers.push(e)}}_scheduleAutoSave(e){this._pendingAutoSave=e,clearTimeout(this._autoSaveTimer),this._autoSaveTimer=setTimeout(()=>this.flushAutoSave(),this.options.autoSaveDelay??400)}async flushAutoSave(){if(clearTimeout(this._autoSaveTimer),this._autoSaveTimer=null,this._pendingAutoSave==null)return;let e=this._pendingAutoSave;this._pendingAutoSave=null;let t=this.options.autoSaveKey,n=Date.now();try{let r=this.options.autoSaveAdapter;typeof r?.save==`function`?await r.save({key:t,html:e,savedAt:n,context:this}):(localStorage.setItem(t,e),localStorage.setItem(t+`:asrmeta`,JSON.stringify({savedAt:n}))),this.triggerEvent(`autoSave`,{key:t,html:e,savedAt:n})}catch(e){this.triggerEvent(`autoSaveError`,{key:t,error:e})}}async loadAutoSave(){let e=this.options.autoSaveAdapter;if(typeof e?.load==`function`)return e.load({key:this.options.autoSaveKey,context:this});try{return localStorage.getItem(this.options.autoSaveKey)}catch{return null}}invoke(e,...t){let[n,r]=e.split(`.`),i=this._modules.get(n);if(!i){console.warn(`[AutumnNote] invoke: module "${n}" not found (path: "${e}")`);return}if(typeof i[r]!=`function`){console.warn(`[AutumnNote] invoke: method "${r}" not found on module "${n}" (path: "${e}")`);return}return i[r](...t)}on(e,t){return this._listeners.has(e)||this._listeners.set(e,[]),this._listeners.get(e).push(t),()=>this.off(e,t)}off(e,t){let n=this._listeners.get(e);if(!n)return;let r=n.indexOf(t);r!==-1&&n.splice(r,1)}triggerEvent(e,...t){let n,r=[...this._listeners.get(e)||[]];for(let e of r){let r=e(...t);r!==void 0&&(n=r)}let i=`on`+e.charAt(0).toUpperCase()+e.slice(1);if(typeof this.options[i]==`function`){let e=this.options[i](...t);e!==void 0&&(n=e)}return n}updateOptions(e={}){let t={...this.options},n=r(this.options,e);Object.keys(this.options).forEach(e=>delete this.options[e]),Object.assign(this.options,n);let a=n=>Object.hasOwn(e,n)&&!i(t[n],this.options[n]),{container:o,editable:s}=this.layoutInfo;if(Object.hasOwn(e,`readOnly`)&&this.setDisabled(!!this.options.readOnly),Object.hasOwn(e,`spellcheck`)&&(s.spellcheck=this.options.spellcheck!==!1),Object.hasOwn(e,`placeholder`)&&(s.dataset.placeholder=this.options.placeholder||``),Object.hasOwn(e,`direction`)){let e=this.options.direction===`rtl`;s.setAttribute(`dir`,e?`rtl`:`ltr`),o.classList.toggle(`an-dir-rtl`,e)}if(Object.hasOwn(e,`height`)||Object.hasOwn(e,`minHeight`)){let e=this.options.height||this.options.minHeight||0;s.style.minHeight=e?`${e}px`:``}Object.hasOwn(e,`maxHeight`)&&(s.style.maxHeight=this.options.maxHeight?`${this.options.maxHeight}px`:``),mn.some(a)&&this.invoke(`toolbar.rebuild`),pn.some(a)&&ln(o,this.layoutInfo.portal??null,this.options),a(`popupContainer`)&&this.layoutInfo.portal&&cn(this.options.popupContainer).appendChild(this.layoutInfo.portal),a(`resizable`)&&this.invoke(`statusbar.applyResizable`);let c=hn.filter(a);return c.length&&console.warn(`[AutumnNote] updateOptions: ${c.join(`, `)} only take effect when the editor is created; destroy and re-create it to apply.`),this._syncOptionalModules(),a(`statusbar`)&&this.invoke(`statusbar.applyVisibility`),this.invoke(`statusbar.update`),this.triggerEvent(`optionsChange`,{...e}),this}getHTML(){let e=this.invoke(`editor.getHTML`);return typeof e==`string`?e.replace(/​/g,``):e}setHTML(e){this.invoke(`editor.setHTML`,e)}getText(){return this.invoke(`editor.getText`)}setText(e){this.invoke(`editor.setText`,e)}clear(){this.invoke(`editor.clear`)}clearHistory(){this.invoke(`editor.clearHistory`)}getUndoCount(){return this.invoke(`editor.getUndoCount`)??0}getRedoCount(){return this.invoke(`editor.getRedoCount`)??0}isEmpty(){return this.invoke(`editor.isEmpty`)}insertHTML(e){this.invoke(`editor.insertHTML`,e)}insertText(e){this.invoke(`editor.insertText`,e)}setMarkdown(e){this.invoke(`editor.setMarkdown`,e)}getMarkdown(){return this.invoke(`editor.getMarkdown`)}getSelectionBookmark(){return this.invoke(`editor.getSelectionBookmark`)??null}restoreSelectionBookmark(e){return this.invoke(`editor.restoreSelectionBookmark`,e)}async importDocument(e,t){let n=this.options.documentAdapters?.[e],r;if(typeof n?.import==`function`)r=await n.import(t,this);else if(e===`html`)r=String(t??``);else if(e===`markdown`)return this.setMarkdown(String(t??``)),this;else if(e===`text`)return this.setText(String(t??``)),this;else throw Error(`[AutumnNote] No importer registered for "${e}".`);return this.setHTML(r),this}async exportDocument(e){let t=this.options.documentAdapters?.[e];if(typeof t?.export==`function`)return t.export(this,this.getHTML());if(e===`html`)return this.getHTML();if(e===`markdown`)return this.getMarkdown();if(e===`text`)return this.getText();throw Error(`[AutumnNote] No exporter registered for "${e}".`)}ensureBlockIds(){let e=this.layoutInfo.editable.children;for(let t of e)if(!t.hasAttribute(`data-an-block-id`)){let e=globalThis.crypto?.randomUUID?.()||`an-${Date.now()}-${Math.random().toString(36).slice(2)}`;t.setAttribute(`data-an-block-id`,e)}return this}getDocument(){return this.options.blockIds&&this.ensureBlockIds(),{version:1,html:this.getHTML(),markdown:this.getMarkdown()}}loadDocument(e){return this.setHTML(e?.html||``),this.clearHistory(),this}applyRemoteHTML(e){return this.setHTML(e),this._suppressedRemoteHTML=this.getHTML(),this.clearHistory(),this}getWordCount(){return this.invoke(`statusbar.getWordCount`)??0}getCharCount(){return this.invoke(`statusbar.getCharCount`)??0}downloadHTML(e=`document.html`){this._download(this.getHTML(),e,`text/html`)}downloadText(e=`document.txt`){this._download(this.getText(),e,`text/plain`)}downloadMarkdown(e=`document.md`){this._download(this.getMarkdown(),e,`text/markdown`)}_download(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.style.display=`none`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}print(e=``){let t=this.getHTML(),n=`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>${(e||``).replace(/[<>&"']/g,e=>`&#${e.charCodeAt(0)};`)}</title><style>body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;font-size:14px;line-height:1.6;padding:20mm;color:#111827;}ul.an-checklist{list-style:none;padding-left:0;}ul.an-checklist li{padding-left:24px;position:relative;margin:2px 0;}ul.an-checklist li input[type="checkbox"]{position:absolute;left:0;top:3px;}code{background:#f3f4f6;border-radius:3px;padding:.1em .35em;font-family:monospace;}pre{background:#f3f4f6;padding:.75em 1em;border-radius:4px;overflow-x:auto;}table{border-collapse:collapse;}td,th{border:1px solid #d1d5db;padding:4px 8px;}</style></head><body>${t}</body></html>`,r=new Blob([n],{type:`text/html`}),i=URL.createObjectURL(r),a=globalThis.open(i,`_blank`);if(!a){URL.revokeObjectURL(i);return}a.addEventListener(`load`,()=>{a.print(),URL.revokeObjectURL(i)})}getTableOfContents(){return Array.from(this.layoutInfo.editable.querySelectorAll(`h1,h2,h3,h4,h5,h6`)).map(e=>({level:parseInt(e.tagName[1],10),text:e.textContent?.trim()??``,element:e}))}focus(){this.layoutInfo.editable.focus()}blur(){this.layoutInfo.editable.blur()}isFullscreen(){return this.invoke(`fullscreen.isActive`)===!0}setDisabled(e){let t=this.layoutInfo.editable;e?(t.setAttribute(`contenteditable`,`false`),this.layoutInfo.container.classList.add(`an-disabled`),t.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.setAttribute(`disabled`,``)})):(t.setAttribute(`contenteditable`,`true`),this.layoutInfo.container.classList.remove(`an-disabled`),t.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.removeAttribute(`disabled`)}))}destroy(){if(!this._alive)return this._destroyPromise??Promise.resolve();let e=this._pendingAutoSave==null?null:this.flushAutoSave().catch(()=>{});this._modules.forEach(e=>{typeof e.destroy==`function`&&e.destroy()}),this._modules.clear();for(let{plugin:e}of this._plugins.values())if(typeof e.uninstall==`function`)try{e.uninstall(this)}catch{}this._plugins.clear(),this._disposers.forEach(e=>e()),this._disposers=[];let t=this.layoutInfo.container;return t?.parentNode&&(this.targetEl.style.display=``,t.remove()),this.layoutInfo.portal?.remove(),this.triggerEvent(`destroy`,this),this._alive=!1,this._releaseInstance?.(),this._releaseInstance=null,this._destroyPromise=Promise.resolve(e).then(()=>{this._listeners.clear()}),this._destroyPromise}_syncToTarget(e){(this.targetEl.tagName===`TEXTAREA`||this.targetEl.tagName===`INPUT`)&&(this.targetEl.value=typeof e==`string`?e:this.getHTML())}};function vn(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return r}var yn=class{constructor(e,t=100,n=10485760){this.editable=e,this._limit=t,this._maxBytes=n,this._bytes=0,this.stack=[],this.stackOffset=-1,this._savePoint()}_entrySize(e){let t=e.html.length;if(e.images)for(let n in e.images)t+=e.images[n].length;return t}_serialize(){return this.editable.innerHTML}_serializeSelection(){let e=globalThis.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0);return this.editable.contains(t.startContainer)?{start:this._charOffset(t.startContainer,t.startOffset),end:this._charOffset(t.endContainer,t.endOffset)}:null}_charOffset(e,t){try{let n=document.createRange();return n.selectNodeContents(this.editable),n.setEnd(e,t),n.toString().length}catch{return 0}}_restoreSelection(e){if(!e)return;let t=null,n=0,r=null,i=0,a=0,o=document.createTreeWalker(this.editable,NodeFilter.SHOW_TEXT,null),s;for(;s=o.nextNode();){let o=s.length;if(!t&&a+o>=e.start&&(t=s,n=e.start-a),!r&&a+o>=e.end){r=s,i=e.end-a;break}a+=o}if(!t){let e=document.createTreeWalker(this.editable,NodeFilter.SHOW_TEXT,null),a=null;for(;a=e.nextNode();)t=a;n=t?t.length:0,r=t,i=n}r||(r=t,i=n);try{let e=document.createRange();e.setStart(t,n),e.setEnd(r,i);let a=globalThis.getSelection();a.removeAllRanges(),a.addRange(e)}catch{try{let e=document.createRange();e.setStart(this.editable,0),e.collapse(!0);let t=globalThis.getSelection();t&&(t.removeAllRanges(),t.addRange(e))}catch{}}}_savePoint(){if(this.stackOffset<this.stack.length-1){for(let e of this.stack.slice(this.stackOffset+1))this._bytes-=this._entrySize(e);this.stack=this.stack.slice(0,this.stackOffset+1)}let e=this._serialize(),{html:t,images:n}=this._tokenizeImages(e),r={html:t,images:n,sel:this._serializeSelection()};for(this.stack.push(r),this._bytes+=this._entrySize(r);this.stack.length>1&&(this.stack.length>this._limit||this._bytes>this._maxBytes);)this._bytes-=this._entrySize(this.stack.shift());this.stackOffset=this.stack.length-1}_restore(e){if(!e)return;let t=this.editable.textContent||``;this.editable.innerHTML=this._detokenizeImages(e);let n=e.sel;if(!n){let e=vn(t,this.editable.textContent||``);n={start:e,end:e}}this._restoreSelection(n)}_tokenizeImages(e){if(!e.includes(`data:`))return{html:e,images:{}};let t={},n=0;return{html:e.replace(/data:[^;]+;base64,[^"' >]*/g,e=>{let r=`__asn_img_${n}__`;return t[r]=e,n++,r}),images:t}}_detokenizeImages(e){return!e.images||Object.keys(e.images).length===0?e.html:e.html.replace(/__asn_img_\d+__/g,t=>e.images[t]||t)}recordUndo(){let e=this._serialize(),{html:t}=this._tokenizeImages(e);this.stack[this.stackOffset]?.html!==t&&this._savePoint()}undo(){this.stackOffset<=0||(this.stackOffset--,this._restore(this.stack[this.stackOffset]))}redo(){this.stackOffset>=this.stack.length-1||(this.stackOffset++,this._restore(this.stack[this.stackOffset]))}reset(){this.stack=[],this.stackOffset=-1,this._bytes=0,this._savePoint()}canUndo(){return this.stackOffset>0}canRedo(){return this.stackOffset<this.stack.length-1}getUndoCount(){return Math.max(0,this.stackOffset)}getRedoCount(){return Math.max(0,this.stack.length-1-this.stackOffset)}};function bn(e,t,n={}){let{headerRow:r=!1}=n,i=h(`table`,{class:`an-table`});if(r&&t>0){let t=h(`thead`),n=h(`tr`);for(let t=0;t<e;t++){let e=h(`th`,{},[document.createElement(`br`)]);n.appendChild(e)}t.appendChild(n),i.appendChild(t)}let a=r?Math.max(t-1,1):t,o=h(`tbody`);i.appendChild(o);for(let t=0;t<a;t++){let t=h(`tr`);for(let n=0;n<e;n++){let e=h(`td`,{},[document.createElement(`br`)]);t.appendChild(e)}o.appendChild(t)}return i}function xn(e,t,n={}){if(e<=0||t<=0)return;let r=bn(e,t,n),i=globalThis.getSelection();if(!i||i.rangeCount===0)return;let a=i.getRangeAt(0);try{a.deleteContents()}catch{return}let o=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`LI`,`PRE`]),s=a.startContainer;for(s?.nodeType===3&&(s=s.parentElement);s&&!o.has(s.tagName?.toUpperCase())&&s.parentElement;)s=s.parentElement;if(s&&o.has(s.tagName?.toUpperCase())&&s.parentNode){if(s.after(r),!r.nextElementSibling){let e=document.createElement(`p`);e.appendChild(document.createElement(`br`)),r.after(e)}!s.textContent.trim()&&!s.querySelector(`img, video, table`)&&s.remove()}else try{a.insertNode(r)}catch{return}let c=r.querySelector(`td, th`);if(c){let e=document.createRange();e.setStart(c,0),e.collapse(!0),i.removeAllRanges(),i.addRange(e)}}var Sn=Object.freeze({"Mod+Z":`undo`,"Mod+Shift+Z":`redo`,"Mod+Y":`redo`,"Mod+B":`bold`,"Mod+I":`italic`,"Mod+U":`underline`,"Mod+K":`link`,"Mod+Shift+V":`pastePlainText`,"Mod+F":`find`,"Mod+H":`findReplace`,"Mod+`":`inlineCode`,"Ctrl+Shift+/":`shortcuts`}),Cn={Slash:`/`,Backslash:`\\`,Backquote:"`",Minus:`-`,Equal:`=`,BracketLeft:`[`,BracketRight:`]`,Semicolon:`;`,Quote:`'`,Comma:`,`,Period:`.`,Space:` `};function wn(e){if(typeof e!=`string`)return null;let t=e.trim().split(/\+(?!$)/).map(e=>e.trim()).filter(Boolean);if(!t.length)return null;let n={mod:!1,ctrl:!1,meta:!1,alt:!1,shift:!1,key:``};for(let[e,r]of t.entries()){let i=r.toLowerCase(),a=e===t.length-1;if(!a&&(i===`mod`||i===`cmdorctrl`))n.mod=!0;else if(!a&&(i===`ctrl`||i===`control`))n.ctrl=!0;else if(!a&&(i===`meta`||i===`cmd`||i===`command`))n.meta=!0;else if(!a&&(i===`alt`||i===`option`))n.alt=!0;else if(!a&&i===`shift`)n.shift=!0;else if(a)n.key=i;else return null}return n.key?n:null}function Tn(e,t){if(t.mod){if(!e.ctrlKey&&!e.metaKey)return!1}else if(e.ctrlKey!==t.ctrl||e.metaKey!==t.meta)return!1;if(e.altKey!==t.alt||e.shiftKey!==t.shift)return!1;if((e.key||``).toLowerCase()===t.key)return!0;let n=e.code||``,r=Cn[n];return!r&&/^Key[A-Z]$/.test(n)?r=n.slice(3).toLowerCase():!r&&/^Digit\d$/.test(n)&&(r=n.slice(5)),r===t.key}function En(e){let t=new Map,n=(e,n)=>{let r=wn(e);if(!r){console.warn(`[AutumnNote] keyMap: cannot parse shortcut "${e}".`);return}let i=Dn(r);if(n===!1||n===null){t.set(i,null);return}let a=n,o;if(n&&typeof n==`object`&&typeof n.run==`function`&&(a=n.run,o=typeof n.description==`string`?n.description:void 0),typeof a!=`string`&&typeof a!=`function`){console.warn(`[AutumnNote] keyMap: "${e}" must map to a command name, a function or false.`);return}t.set(i,{combo:e,parsed:r,command:a,description:o})};for(let[e,t]of Object.entries(Sn))n(e,t);if(e&&typeof e==`object`)for(let[t,r]of Object.entries(e))n(t,r);return[...t.values()].filter(Boolean)}function Dn(e){return[e.mod&&`mod`,e.ctrl&&`ctrl`,e.meta&&`meta`,e.alt&&`alt`,e.shift&&`shift`,e.key].filter(Boolean).join(`+`)}function On(e){let t=[];return(e.mod||e.ctrl)&&t.push(`Ctrl`),e.meta&&t.push(`Cmd`),e.alt&&t.push(`Alt`),e.shift&&t.push(`Shift`),t.push(e.key.length===1?e.key.toUpperCase():e.key.charAt(0).toUpperCase()+e.key.slice(1)),t.join(` + `)}var P={BACKSPACE:`Backspace`,TAB:`Tab`,ENTER:`Enter`,ESCAPE:`Escape`,SPACE:` `,PAGE_UP:`PageUp`,PAGE_DOWN:`PageDown`,END:`End`,HOME:`Home`,LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,DOWN:`ArrowDown`,DELETE:`Delete`,NUM0:`0`,NUM1:`1`,NUM2:`2`,NUM3:`3`,NUM4:`4`,NUM5:`5`,NUM6:`6`,NUM7:`7`,NUM8:`8`,B:`b`,E:`e`,I:`i`,J:`j`,K:`k`,L:`l`,R:`r`,S:`s`,U:`u`,V:`v`,Y:`y`,Z:`z`,SLASH:`/`,PERIOD:`.`};function F(e,t){return e.key===t||e.key===t.toUpperCase()}var kn=/\bfa-/,I=e=>!!(e?.nodeName===`I`&&kn.test(e.className||``)),An=e=>!(e?.nodeType!==Node.TEXT_NODE||e.textContent!==`​`&&e.textContent!==``);function jn(e,t,n){let r=(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement??null)?.closest(`td, th`)??null;if(!r||!t.contains(r))return!1;let i=r.closest(`table`);if(!i||!t.contains(i))return!1;let a=Array.from(i.querySelectorAll(`td, th`)),o=a[a.indexOf(r)+(n?-1:1)];if(o)return g(o),!0;if(n)return!0;let s=Mn(r.closest(`tr`))?.firstElementChild??null;return s&&g(s),!0}function Mn(e){if(!e?.parentNode)return null;let t=document.createElement(`tr`);for(let n of e.cells){let e=document.createElement(`td`);e.appendChild(document.createElement(`br`)),n.hasAttribute(`style`)&&e.setAttribute(`style`,n.getAttribute(`style`)),t.appendChild(e)}return e.parentNode.insertBefore(t,e.nextSibling),t}function Nn(e,t){try{let n=document.createRange();return n.setStart(e.startContainer,e.startOffset),n.setEnd(t,t.childNodes.length),n.extractContents()}catch{return document.createDocumentFragment()}}function Pn(e,t,n={}){let r=e=>{let t=globalThis.getSelection();if(!t)return!1;let n=document.createRange();return e(n),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!0};if(F(e,P.BACKSPACE)){let t=globalThis.getSelection();if(t?.rangeCount>0){let n=t.getRangeAt(0);if(n.collapsed&&n.startContainer.nodeType===Node.TEXT_NODE){let r=n.startContainer;if(n.startOffset===0&&I(r.previousSibling))return e.preventDefault(),r.previousSibling.remove(),!0;if(n.startOffset===1&&r.textContent===`​`&&I(r.previousSibling)){e.preventDefault();let n=r.parentNode,i=r.previousSibling,a=i.previousSibling;i.remove(),r.remove();let o=document.createRange();return a?.nodeType===Node.TEXT_NODE?o.setStart(a,a.textContent.length):a?o.setStartAfter(a):n&&o.setStart(n,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}}return!1}if(F(e,P.LEFT)||F(e,P.RIGHT)){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return!1;let n=t.getRangeAt(0);if(!n.collapsed)return!1;let i=n.startContainer,a=F(e,P.LEFT);if(i.nodeType===Node.TEXT_NODE){let t=i;if(a&&n.startOffset===1&&t.textContent===`​`&&I(t.previousSibling)||a&&n.startOffset===0&&I(t.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(t.previousSibling));if(a&&n.startOffset===0&&An(t.previousSibling)&&I(t.previousSibling.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(t.previousSibling.previousSibling));if(!a&&n.startOffset===t.textContent.length&&I(t.nextSibling)){let n=t.nextSibling,i=n.nextSibling;if(e.preventDefault(),i?.nodeType===Node.TEXT_NODE){let e=+!!(i.textContent||``).startsWith(`​`);return r(t=>t.setStart(i,Math.min(e,i.textContent.length)))}return r(e=>e.setStartAfter(n))}if(!a&&n.startOffset===t.textContent.length&&An(t.nextSibling)&&I(t.nextSibling.nextSibling)){let n=t.nextSibling.nextSibling,i=n.nextSibling;if(e.preventDefault(),i?.nodeType===Node.TEXT_NODE){let e=+!!(i.textContent||``).startsWith(`​`);return r(t=>t.setStart(i,Math.min(e,i.textContent.length)))}return r(e=>e.setStartAfter(n))}}if(i.nodeType===Node.ELEMENT_NODE){let t=i;if(a&&n.startOffset>0){let i=t.childNodes[n.startOffset-1];if(I(i))return e.preventDefault(),r(e=>e.setStartBefore(i));if(An(i)&&I(i.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(i.previousSibling))}if(!a&&n.startOffset<t.childNodes.length){let i=t.childNodes[n.startOffset];if(I(i)){let t=i.nextSibling;if(e.preventDefault(),t?.nodeType===Node.TEXT_NODE){let e=+!!(t.textContent||``).startsWith(`​`);return r(n=>n.setStart(t,Math.min(e,t.textContent.length)))}return r(e=>e.setStartAfter(i))}if(An(i)&&I(i.nextSibling)){let t=i.nextSibling,n=t.nextSibling;if(e.preventDefault(),n?.nodeType===Node.TEXT_NODE){let e=+!!(n.textContent||``).startsWith(`​`);return r(t=>t.setStart(n,Math.min(e,n.textContent.length)))}return r(e=>e.setStartAfter(t))}}}}if(F(e,P.TAB)){let r=w(t);if(!r)return!1;if(jn(r.sc,t,e.shiftKey))return e.preventDefault(),!0;let i=m(r.sc,t);if(i&&f(i))return e.preventDefault(),e.shiftKey?we():Se(),!0;if(i?.nodeName.toUpperCase()===`PRE`)return!e.shiftKey&&(e.preventDefault(),k(`insertText`,` `.repeat(n.tabSize||4)),!0);if(n.tabSize)return!e.shiftKey&&(e.preventDefault(),k(`insertText`,` `.repeat(n.tabSize)),!0)}if(F(e,P.ENTER)&&e.shiftKey)return e.preventDefault(),k(`insertLineBreak`),!0;if(F(e,P.ENTER)&&!e.shiftKey){let n=w(t);if(!n)return!1;let r=n.sc,i=r.nodeType===3?r.parentElement:r;if(i?.nodeName===`I`&&/\bfa-/.test(i.className||``)){let e=document.createRange();e.setStartAfter(i),e.collapse(!0);let t=globalThis.getSelection();return t&&(t.removeAllRanges(),t.addRange(e)),!1}let a=i?.closest(`.an-video-wrapper`);if(a){e.preventDefault();let t=document.createElement(`p`);t.innerHTML=`\xA0`,a.parentNode.insertBefore(t,a.nextSibling);let n=document.createRange();n.setStart(t,0),n.collapse(!0);let r=globalThis.getSelection();return r.removeAllRanges(),r.addRange(n),!0}let o=i?.closest(`.an-checklist li`);if(o){e.preventDefault();let t=o.closest(`.an-checklist`),n=globalThis.getSelection(),r=n.getRangeAt(0);if(!(e=>Array.from(e.childNodes).filter(e=>e.nodeType!==1||e.tagName!==`INPUT`).map(e=>e.textContent).join(``).replace(/[\u00a0\u200B]/g,` `).trim())(o)){let e=document.createElement(`p`);e.innerHTML=`\xA0`,t.parentNode.insertBefore(e,t.nextSibling),o.remove(),t.children.length===0&&t.remove();let r=document.createRange();return r.setStart(e.firstChild,0),r.collapse(!0),n.removeAllRanges(),n.addRange(r),!0}if(!r.collapsed){if(r.deleteContents(),n.rangeCount===0||!o.isConnected)return!0;r=n.getRangeAt(0)}let i=Nn(r,o),a=document.createElement(`li`),s=document.createElement(`input`);s.type=`checkbox`,s.setAttribute(`contenteditable`,`false`),a.appendChild(s),i.textContent.replace(/[\u00a0\u200B]/g,``).length>0&&a.appendChild(i);let c=a.childNodes[1];c?.nodeType!==Node.TEXT_NODE&&(c=document.createTextNode(`​`),a.appendChild(c)),o.after(a);let l=document.createRange();return l.setStart(c,0),l.collapse(!0),n.removeAllRanges(),n.addRange(l),!0}let s=m(n.sc,t);if(s?.nodeName.toUpperCase()===`PRE`)return e.preventDefault(),k(`insertText`,`
5
- `),!0;if(s?.nodeName.toUpperCase()===`BLOCKQUOTE`){let t=n.toNativeRange();if(t.setEnd(s,s.childNodes.length),t.toString()===``&&n.isCollapsed())return e.preventDefault(),k(`formatBlock`,`<p>`),!0}}return!1}var Fn=typeof Intl<`u`&&typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`word`}):null;function In(e){let t=e.trim();if(!t)return 0;if(Fn){let e=0;for(let n of Fn.segment(t))n.isWordLike&&e++;return e}return t.split(/\s+/).length}var Ln=new Set(`ADDRESS.ARTICLE.ASIDE.BLOCKQUOTE.BR.DD.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.H1.H2.H3.H4.H5.H6.HEADER.HR.LI.MAIN.NAV.OL.P.PRE.SECTION.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL`.split(`.`));function Rn(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)if(r.nodeType===3){let e=r.data;t.push(e),n.push(e)}else if(r.nodeType===1){let e=Ln.has(r.tagName);e&&t.push(`
6
- `),Rn(r,t,n),e&&t.push(`
7
- `)}}function zn(e){if(e.nodeType===3){let t=e.data;return{lines:t,flat:t}}let t=[],n=[];return Rn(e,t,n),{lines:t.join(``),flat:n.join(``)}}var Bn=class{constructor(){this._cache=new WeakMap}counts(e){let t=0,n=0,r=[],i=[],a=0;for(let o=e.firstChild;o;o=o.nextSibling){let e=this._cache.get(o);if(e&&e.key===(o.textContent||``)){t+=e.words,n+=e.chars;continue}let{lines:s,flat:c}=zn(o);r.push({node:o,key:c,text:s,start:a}),i.push(s),a+=s.length+1}if(r.length){let e=Vn(r,i.join(`
8
- `));r.forEach((r,i)=>{let a={key:r.key,words:e[i],chars:r.key.replaceAll(`
9
- `,``).length};this._cache.set(r.node,a),t+=a.words,n+=a.chars})}return{words:t,chars:n}}};function Vn(e,t){if(!Fn)return e.map(e=>In(e.text));let n=Array(e.length).fill(0),r=0;for(let i of Fn.segment(t))if(i.isWordLike){for(;r<e.length-1&&i.index>=e[r+1].start;)r++;n[r]++}return n}function Hn(e){let t=new DOMParser().parseFromString(`<body>${e||``}</body>`,`text/html`);return _(t.body),Xn(t.body).replace(/\n{3,}/g,`
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.AutumnNote=t())})(this,function(){var e=Object.defineProperty,t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function r(e,t){let n={};for(let t of Object.keys(e))n[t]=Array.isArray(e[t])?[...e[t]]:e[t];if(a(e)&&a(t))for(let i of Object.keys(t))n[i]=a(t[i])?r(a(e[i])?e[i]:{},t[i]):Array.isArray(t[i])?[...t[i]]:t[i];return n}function i(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>i(e,t[n]));if(a(e)&&a(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&i(e[n],t[n]))}return!1}function a(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var o={toolbar:{bold:`Bold (Ctrl+B)`,italic:`Italic (Ctrl+I)`,underline:`Underline (Ctrl+U)`,strikethrough:`Strikethrough`,superscript:`Superscript`,subscript:`Subscript`,alignLeft:`Align Left`,alignCenter:`Align Center`,alignRight:`Align Right`,alignJustify:`Justify`,ul:`Unordered List`,ol:`Ordered List`,checklist:`Checklist`,indent:`Indent`,outdent:`Outdent`,undo:`Undo (Ctrl+Z)`,redo:`Redo (Ctrl+Y)`,hr:`Horizontal Rule`,link:`Insert Link`,image:`Insert Image`,video:`Insert Video`,emoji:`Insert Emoji`,icon:`Insert FA Icon`,table:`Insert Table`,fontSize:`Font Size`,fontSizePlaceholder:`Size`,removeFormat:`Remove Format`,direction:`Toggle Text Direction (LTR / RTL)`,fontFamily:`Font Family`,paragraphStyle:`Paragraph Style`,paragraphStylePlaceholder:`Style`,lineHeight:`Line Height`,lineHeightPlaceholder:`↕ Line`,codeview:`HTML Code View`,fullscreen:`Fullscreen`,shortcuts:`Keyboard Shortcuts (Ctrl+Shift+/)`,find:`Find (Ctrl+F)`,findReplace:`Find & Replace (Ctrl+H)`,inlineCode:"Inline Code (Ctrl+`)",print:`Print`,foreColor:`Text Color`,backColor:`Highlight Color`,chooseTextColor:`Choose text color`,chooseHighlightColor:`Choose highlight color`,customColor:`Custom color`,insertTableLabel:`Insert Table`,paragraphItems:{p:`Normal`,blockquote:`Quote`,pre:`Code`}},linkDialog:{ariaLabel:`Insert link`,title:`Insert Link`,url:`URL`,urlPlaceholder:`https://`,displayText:`Display Text`,textPlaceholder:`Link text`,openInNewTab:`Open in new tab`,insertBtn:`Insert`,cancelBtn:`Cancel`},imageDialog:{ariaLabel:`Insert image`,title:`Insert Image`,imageUrl:`Image URL`,urlPlaceholder:`https://example.com/image.png`,altText:`Alt Text`,altPlaceholder:`Describe the image`,alignment:`Alignment`,alignNone:`None`,alignLeft:`Left`,alignCenter:`Center`,alignRight:`Right`,uploadLabel:`Or upload a file`,insertBtn:`Insert`,cancelBtn:`Cancel`},videoDialog:{ariaLabel:`Insert video`,title:`Insert Video`,videoUrl:`Video URL`,urlPlaceholder:`YouTube, Vimeo, or direct .mp4 URL`,widthLabel:`Width (px)`,widthPlaceholder:`560`,insertBtn:`Insert`,cancelBtn:`Cancel`,detected:e=>`Detected: ${e}`,unknownFormat:`Unknown format — will try direct video embed`,invalidUrl:`Invalid URL — please enter a valid video link.`},emojiDialog:{ariaLabel:`Insert emoji`,title:`Insert Emoji`,searchPlaceholder:`Search emojis…`,all:`All`,cancelBtn:`Cancel`,close:`Close`,categories:{smileys:`Smileys`,people:`People`,animals:`Animals`,food:`Food`,travel:`Travel`,objects:`Objects`,symbols:`Symbols`}},iconDialog:{ariaLabel:`Insert FA icon`,title:`Insert FA Icon`,searchPlaceholder:`Search icons…`,all:`All`,style:`Style`,size:`Size`,color:`Color`,useColor:` Use color`,selectHint:`Select an icon`,insertBtn:`Insert FA Icon`,cancelBtn:`Cancel`,close:`Close`,categories:{popular:`Popular`,interface:`Interface`,navigation:`Navigation`,media:`Media`,communication:`Communication`,files:`Files`,people:`People`,objects:`Objects`}},findReplace:{findTitle:`Find`,findReplaceTitle:`Find & Replace`,findPlaceholder:`Find…`,searchAriaLabel:`Search text`,caseSensitive:`\xA0Case sensitive`,wholeWord:`Whole Word`,prevBtn:`← Prev`,nextBtn:`Next →`,replacePlaceholder:`Replace with…`,replaceAriaLabel:`Replace with`,replaceBtn:`Replace`,replaceAllBtn:`Replace All`,noResults:`No results`,useRegex:`Use Regular Expression`,prevMatch:`Previous (Shift+Enter)`,nextMatch:`Next (Enter)`,close:`×`},autoSaveRestore:{found:`Draft found. Restore?`,foundAt:`Draft from {date}. Restore?`,restore:`Restore`,discard:`Discard`},shortcutsDialog:{title:`Keyboard Shortcuts`,ariaLabel:`Keyboard Shortcuts`,close:`Close`,customCategory:`Custom`,shortcuts:[{category:`Text Formatting`,items:[{keys:`Ctrl + B`,action:`Bold`},{keys:`Ctrl + I`,action:`Italic`},{keys:`Ctrl + U`,action:`Underline`},{keys:`Ctrl + K`,action:`Insert / edit link`}]},{category:`History`,items:[{keys:`Ctrl + Z`,action:`Undo`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Redo`}]},{category:`Selection & Navigation`,items:[{keys:`Ctrl + A`,action:`Select all content`},{keys:`Tab`,action:`Indent list item / insert spaces`},{keys:`Shift + Tab`,action:`Outdent list item`}]},{category:`Clipboard`,items:[{keys:`Ctrl + Shift + V`,action:`Paste as plain text`}]},{category:`Find & Replace`,items:[{keys:`Ctrl + F`,action:`Find in document`},{keys:`Ctrl + H`,action:`Find & Replace`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Show this keyboard shortcuts dialog`}]}]},contextMenu:{cut:`Cut`,copy:`Copy`,paste:`Paste`,bold:`Bold`,italic:`Italic`,underline:`Underline`,textColor:`Text Color`,highlightColor:`Highlight Color`,copyFormat:`Copy Format`,pasteFormat:`Paste Format`,removeFormat:`Remove Format`,link:`Insert Link`,image:`Insert Image`,video:`Insert Video`,table:`Insert Table`,back:`Back`,noHighlight:`No highlight`,customColor:`Custom color`,customColorLabel:`Custom…`},statusbar:{resizeHandle:`Resize editor`,words:e=>`Words: ${e}`,wordsLimit:(e,t)=>`Words: ${e}/${t}`,chars:e=>`Chars: ${e}`,charsLimit:(e,t)=>`Chars: ${e}/${t}`},a11y:{editor:`Rich text editor`,toolbar:`Editor toolbar`,statistics:`Editor statistics`,tableSize:`Select table size`},tooltips:{link:{ariaLabel:`Link actions`,openLink:`Open link`,copyUrl:`Copy URL`,editLink:`Edit link`,removeLink:`Remove link`},image:{ariaLabel:`Image actions`,label:`Image`,floatLeft:`Float Left`,noFloat:`No Float`,alignCenter:`Align Center`,floatRight:`Float Right`,originalSize:`Original Size`,rotateLeft:`Rotate Left`,rotateRight:`Rotate Right`,cropImage:`Crop Image`,addCaption:`Add / Edit Caption`,deleteImage:`Delete Image`},code:{ariaLabel:`Code block actions`,label:`Code`,syntaxLanguage:`Syntax Language`,syntaxAriaLabel:`Syntax language`,copyCode:`Copy Code`,toggleWordWrap:`Toggle Word Wrap`,enableWordWrap:`Enable Word Wrap`,disableWordWrap:`Disable Word Wrap`,convertToParagraph:`Convert to Paragraph`,deleteCodeBlock:`Delete Code Block`,lineNumbers:`Toggle Line Numbers`},table:{ariaLabel:`Table actions`,label:`Table`,selectCells:`Select Cells`,addRowAbove:`Add Row Above`,addRowBelow:`Add Row Below`,deleteRow:`Delete Row`,addColumnLeft:`Add Column Left`,addColumnRight:`Add Column Right`,deleteColumn:`Delete Column`,mergeCells:`Merge Cells`,unmergeCells:`Unmerge Cells`,columnWidth:`Column Width`,rowHeight:`Row Height`,tableBorderWidth:`Table Border Width`,tableBorderColor:`Table Border Color`,deleteTable:`Delete Table`,cellAlignLeft:`Align Left`,cellAlignCenter:`Align Center`,cellAlignRight:`Align Right`,cellAlignJustify:`Align Justify`,toggleHeaderRow:`Toggle Header Row`,cellBackground:`Cell Background`,noShading:`No Shading`,noBorderColor:`No Border Color`,columnWidthPx:`Column Width (px)`,rowHeightPx:`Row Height (px)`,tableBorderWidthPx:`Table Border Width (px)`,cancelBtn:`Cancel`,applyBtn:`Apply`,sortAsc:`Sort Ascending`,sortDesc:`Sort Descending`,exportCSV:`Export as CSV`,cellPadding:`Cell Padding`,cellPaddingPx:`Cell Padding (px)`},video:{ariaLabel:`Video actions`,label:`Video`,floatLeft:`Float Left`,noFloat:`No Float`,alignCenter:`Align Center`,floatRight:`Float Right`,originalSize:`Original Size`,previewVideo:`Preview Video`,exitPreview:`Exit Preview`,deleteVideo:`Delete Video`}},errors:{imageFormat:e=>`Format "${e}" is not supported for display in web browsers. Please convert to JPEG, PNG, or WebP first.`,imageSize:e=>`Image file is too large. Maximum allowed size is ${e} MB.`},slashMenu:{noResults:`No matching commands`,heading1:`Heading 1`,heading2:`Heading 2`,heading3:`Heading 3`,bulletList:`Bullet List`,numberedList:`Numbered List`,checklist:`Checklist`,blockquote:`Blockquote`,codeBlock:`Code Block`,horizontalRule:`Horizontal Rule`,table:`Table`,image:`Image`}},s={en:o};function c(e,t){if(typeof e!=`string`||!e)throw TypeError(`[AutumnNote] registerLocale: code must be a non-empty string.`);if(!t||typeof t!=`object`)throw TypeError(`[AutumnNote] registerLocale: locale for "${e}" must be an object.`);s[e]=t}function l(e){if(!e||e===`en`)return o;if(typeof e==`string`){let t=s[e];return t?r(r({},o),t):(console.warn(`[AutumnNote] Locale "${e}" is not registered, falling back to English. Import it first: import { ${e} } from 'autumnnote/i18n/${e}'; AutumnNote.registerLocale('${e}', ${e});`),o)}return typeof e==`object`?r(r({},o),e):o}c(`vi`,{toolbar:{bold:`Đậm (Ctrl+B)`,italic:`Nghiêng (Ctrl+I)`,underline:`Gạch chân (Ctrl+U)`,strikethrough:`Gạch ngang`,superscript:`Chỉ số trên`,subscript:`Chỉ số dưới`,alignLeft:`Căn trái`,alignCenter:`Căn giữa`,alignRight:`Căn phải`,alignJustify:`Căn đều`,ul:`Danh sách không thứ tự`,ol:`Danh sách có thứ tự`,checklist:`Danh sách kiểm tra`,indent:`Tăng thụt đầu dòng`,outdent:`Giảm thụt đầu dòng`,undo:`Hoàn tác (Ctrl+Z)`,redo:`Làm lại (Ctrl+Y)`,hr:`Đường kẻ ngang`,link:`Chèn liên kết`,image:`Chèn hình ảnh`,video:`Chèn video`,emoji:`Chèn biểu tượng cảm xúc`,icon:`Chèn biểu tượng FA`,table:`Chèn bảng`,fontSize:`Cỡ chữ`,fontSizePlaceholder:`Cỡ`,removeFormat:`Xóa định dạng`,direction:`Chuyển hướng văn bản (LTR / RTL)`,fontFamily:`Phông chữ`,paragraphStyle:`Kiểu đoạn văn`,paragraphStylePlaceholder:`Kiểu`,lineHeight:`Khoảng cách dòng`,lineHeightPlaceholder:`↕ Dòng`,codeview:`Xem mã HTML`,fullscreen:`Toàn màn hình`,shortcuts:`Phím tắt (Ctrl+Shift+/)`,find:`Tìm kiếm (Ctrl+F)`,findReplace:`Tìm & Thay thế (Ctrl+H)`,inlineCode:"Mã nội tuyến (Ctrl+`)",print:`In`,foreColor:`Màu chữ`,backColor:`Màu nền chữ`,chooseTextColor:`Chọn màu chữ`,chooseHighlightColor:`Chọn màu nền`,customColor:`Màu tùy chỉnh`,insertTableLabel:`Chèn bảng`,paragraphItems:{p:`Bình thường`,blockquote:`Trích dẫn`,pre:`Mã`}},linkDialog:{ariaLabel:`Chèn liên kết`,title:`Chèn liên kết`,url:`Địa chỉ URL`,urlPlaceholder:`https://`,displayText:`Văn bản hiển thị`,textPlaceholder:`Nội dung liên kết`,openInNewTab:`Mở trong tab mới`,insertBtn:`Chèn`,cancelBtn:`Hủy`},imageDialog:{ariaLabel:`Chèn hình ảnh`,title:`Chèn hình ảnh`,imageUrl:`URL hình ảnh`,urlPlaceholder:`https://example.com/anh.png`,altText:`Văn bản thay thế`,altPlaceholder:`Mô tả hình ảnh`,alignment:`Căn chỉnh`,alignNone:`Không`,alignLeft:`Trái`,alignCenter:`Giữa`,alignRight:`Phải`,uploadLabel:`Hoặc tải lên tệp`,insertBtn:`Chèn`,cancelBtn:`Hủy`},videoDialog:{ariaLabel:`Chèn video`,title:`Chèn video`,videoUrl:`URL video`,urlPlaceholder:`YouTube, Vimeo, hoặc URL .mp4 trực tiếp`,widthLabel:`Chiều rộng (px)`,widthPlaceholder:`560`,insertBtn:`Chèn`,cancelBtn:`Hủy`,detected:e=>`Đã phát hiện: ${e}`,unknownFormat:`Định dạng không xác định — sẽ thử nhúng video trực tiếp`,invalidUrl:`URL không hợp lệ — vui lòng nhập đường dẫn video hợp lệ.`},emojiDialog:{ariaLabel:`Chèn biểu tượng cảm xúc`,title:`Chèn biểu tượng cảm xúc`,searchPlaceholder:`Tìm kiếm biểu tượng…`,all:`Tất cả`,cancelBtn:`Hủy`,close:`Đóng`,categories:{smileys:`Mặt cười`,people:`Con người`,animals:`Động vật`,food:`Thức ăn`,travel:`Du lịch`,objects:`Đồ vật`,symbols:`Ký hiệu`}},iconDialog:{ariaLabel:`Chèn biểu tượng FA`,title:`Chèn biểu tượng FA`,searchPlaceholder:`Tìm kiếm biểu tượng…`,all:`Tất cả`,style:`Kiểu`,size:`Kích thước`,color:`Màu sắc`,useColor:` Dùng màu`,selectHint:`Chọn một biểu tượng`,insertBtn:`Chèn biểu tượng FA`,cancelBtn:`Hủy`,close:`Đóng`,categories:{popular:`Phổ biến`,interface:`Giao diện`,navigation:`Điều hướng`,media:`Phương tiện`,communication:`Liên lạc`,files:`Tệp tin`,people:`Con người`,objects:`Đồ vật`}},findReplace:{findTitle:`Tìm kiếm`,findReplaceTitle:`Tìm & Thay thế`,findPlaceholder:`Tìm…`,searchAriaLabel:`Văn bản tìm kiếm`,caseSensitive:`\xA0Phân biệt hoa thường`,wholeWord:`Toàn bộ từ`,prevBtn:`← Trước`,nextBtn:`Tiếp →`,replacePlaceholder:`Thay thế bằng…`,replaceAriaLabel:`Thay thế bằng`,replaceBtn:`Thay thế`,replaceAllBtn:`Thay thế tất cả`,noResults:`Không có kết quả`,useRegex:`Dùng biểu thức chính quy`,prevMatch:`Trước (Shift+Enter)`,nextMatch:`Tiếp (Enter)`,close:`×`},shortcutsDialog:{title:`Phím tắt bàn phím`,ariaLabel:`Phím tắt bàn phím`,close:`Đóng`,customCategory:`Tùy chỉnh`,shortcuts:[{category:`Định dạng văn bản`,items:[{keys:`Ctrl + B`,action:`Đậm`},{keys:`Ctrl + I`,action:`Nghiêng`},{keys:`Ctrl + U`,action:`Gạch chân`},{keys:`Ctrl + K`,action:`Chèn / sửa liên kết`}]},{category:`Lịch sử`,items:[{keys:`Ctrl + Z`,action:`Hoàn tác`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Làm lại`}]},{category:`Chọn & Điều hướng`,items:[{keys:`Ctrl + A`,action:`Chọn tất cả`},{keys:`Tab`,action:`Tăng thụt đầu dòng / chèn khoảng trắng`},{keys:`Shift + Tab`,action:`Giảm thụt đầu dòng`}]},{category:`Bảng nhớ tạm`,items:[{keys:`Ctrl + Shift + V`,action:`Dán dưới dạng văn bản thuần`}]},{category:`Tìm & Thay thế`,items:[{keys:`Ctrl + F`,action:`Tìm trong tài liệu`},{keys:`Ctrl + H`,action:`Tìm & Thay thế`}]},{category:`Trình soạn thảo`,items:[{keys:`Ctrl + Shift + /`,action:`Hiện hộp thoại phím tắt`}]}]},contextMenu:{cut:`Cắt`,copy:`Sao chép`,paste:`Dán`,bold:`Đậm`,italic:`Nghiêng`,underline:`Gạch chân`,textColor:`Màu chữ`,highlightColor:`Màu nền chữ`,copyFormat:`Sao chép định dạng`,pasteFormat:`Dán định dạng`,removeFormat:`Xóa định dạng`,link:`Chèn liên kết`,image:`Chèn hình ảnh`,video:`Chèn video`,table:`Chèn bảng`,back:`Quay lại`,noHighlight:`Không tô màu`,customColor:`Màu tùy chỉnh`,customColorLabel:`Tùy chỉnh…`},statusbar:{resizeHandle:`Kéo để thay đổi kích thước`,words:e=>`Từ: ${e}`,wordsLimit:(e,t)=>`Từ: ${e}/${t}`,chars:e=>`Ký tự: ${e}`,charsLimit:(e,t)=>`Ký tự: ${e}/${t}`},a11y:{editor:`Trình soạn thảo văn bản`,toolbar:`Thanh công cụ soạn thảo`,statistics:`Thống kê văn bản`,tableSize:`Chọn kích thước bảng`},tooltips:{link:{ariaLabel:`Hành động liên kết`,openLink:`Mở liên kết`,copyUrl:`Sao chép URL`,editLink:`Sửa liên kết`,removeLink:`Xóa liên kết`},image:{ariaLabel:`Hành động hình ảnh`,label:`Hình ảnh`,floatLeft:`Nổi trái`,noFloat:`Không nổi`,alignCenter:`Căn giữa`,floatRight:`Nổi phải`,originalSize:`Kích thước gốc`,rotateLeft:`Xoay trái`,rotateRight:`Xoay phải`,cropImage:`Cắt ảnh`,addCaption:`Thêm / Sửa chú thích`,deleteImage:`Xóa hình ảnh`},code:{ariaLabel:`Hành động khối mã`,label:`Mã`,syntaxLanguage:`Ngôn ngữ cú pháp`,syntaxAriaLabel:`Ngôn ngữ cú pháp`,copyCode:`Sao chép mã`,toggleWordWrap:`Chuyển đổi xuống dòng`,enableWordWrap:`Bật xuống dòng`,disableWordWrap:`Tắt xuống dòng`,convertToParagraph:`Chuyển thành đoạn văn`,deleteCodeBlock:`Xóa khối mã`,lineNumbers:`Bật/Tắt số dòng`},table:{ariaLabel:`Hành động bảng`,label:`Bảng`,selectCells:`Chọn ô`,addRowAbove:`Thêm hàng phía trên`,addRowBelow:`Thêm hàng phía dưới`,deleteRow:`Xóa hàng`,addColumnLeft:`Thêm cột bên trái`,addColumnRight:`Thêm cột bên phải`,deleteColumn:`Xóa cột`,mergeCells:`Gộp ô`,unmergeCells:`Tách ô`,columnWidth:`Chiều rộng cột`,rowHeight:`Chiều cao hàng`,tableBorderWidth:`Độ rộng viền bảng`,tableBorderColor:`Màu viền bảng`,deleteTable:`Xóa bảng`,cellAlignLeft:`Căn trái`,cellAlignCenter:`Căn giữa`,cellAlignRight:`Căn phải`,cellAlignJustify:`Căn đều`,toggleHeaderRow:`Bật/tắt hàng tiêu đề`,cellBackground:`Màu Nền Ô`,noShading:`Xóa Màu Nền`,noBorderColor:`Xóa màu viền`,columnWidthPx:`Chiều rộng cột (px)`,rowHeightPx:`Chiều cao hàng (px)`,tableBorderWidthPx:`Độ rộng viền bảng (px)`,cancelBtn:`Hủy`,applyBtn:`Áp dụng`,sortAsc:`Sắp xếp tăng dần`,sortDesc:`Sắp xếp giảm dần`,exportCSV:`Xuất CSV`,cellPadding:`Khoảng đệm ô`,cellPaddingPx:`Khoảng đệm ô (px)`},video:{ariaLabel:`Hành động video`,label:`Video`,floatLeft:`Nổi trái`,noFloat:`Không nổi`,alignCenter:`Căn giữa`,floatRight:`Nổi phải`,originalSize:`Kích thước gốc`,previewVideo:`Xem trước`,exitPreview:`Thoát xem trước`,deleteVideo:`Xóa video`}},errors:{imageFormat:e=>`Định dạng "${e}" không được hỗ trợ hiển thị trên trình duyệt. Vui lòng chuyển đổi sang JPEG, PNG hoặc WebP.`,imageSize:e=>`Tệp hình ảnh quá lớn. Kích thước tối đa cho phép là ${e} MB.`},autoSaveRestore:{found:`Tìm thấy bản nháp. Khôi phục?`,foundAt:`Bản nháp từ {date}. Khôi phục?`,restore:`Khôi phục`,discard:`Bỏ qua`},slashMenu:{noResults:`Không có lệnh phù hợp`,heading1:`Tiêu đề 1`,heading2:`Tiêu đề 2`,heading3:`Tiêu đề 3`,bulletList:`Danh sách không thứ tự`,numberedList:`Danh sách có thứ tự`,checklist:`Danh sách công việc`,blockquote:`Trích dẫn`,codeBlock:`Khối mã`,horizontalRule:`Đường kẻ ngang`,table:`Bảng`,image:`Hình ảnh`}}),c(`ja`,{toolbar:{bold:`太字 (Ctrl+B)`,italic:`斜体 (Ctrl+I)`,underline:`下線 (Ctrl+U)`,strikethrough:`取り消し線`,superscript:`上付き文字`,subscript:`下付き文字`,alignLeft:`左揃え`,alignCenter:`中央揃え`,alignRight:`右揃え`,alignJustify:`両端揃え`,ul:`箇条書きリスト`,ol:`番号付きリスト`,checklist:`チェックリスト`,indent:`インデントを増やす`,outdent:`インデントを減らす`,undo:`元に戻す (Ctrl+Z)`,redo:`やり直す (Ctrl+Y)`,hr:`水平線`,link:`リンクを挿入`,image:`画像を挿入`,video:`動画を挿入`,emoji:`絵文字を挿入`,icon:`FAアイコンを挿入`,table:`テーブルを挿入`,fontSize:`フォントサイズ`,fontSizePlaceholder:`サイズ`,removeFormat:`書式をリセット`,direction:`文字方向を切り替え (LTR / RTL)`,fontFamily:`フォント`,paragraphStyle:`段落スタイル`,paragraphStylePlaceholder:`スタイル`,lineHeight:`行の高さ`,lineHeightPlaceholder:`↕ 行間`,codeview:`HTMLソースを表示`,fullscreen:`全画面表示`,shortcuts:`キーボードショートカット (Ctrl+Shift+/)`,find:`検索 (Ctrl+F)`,findReplace:`検索と置換 (Ctrl+H)`,inlineCode:"インラインコード (Ctrl+`)",print:`印刷`,foreColor:`文字色`,backColor:`ハイライト色`,chooseTextColor:`文字色を選択`,chooseHighlightColor:`ハイライト色を選択`,customColor:`カスタムカラー`,insertTableLabel:`テーブルを挿入`,paragraphItems:{p:`標準`,blockquote:`引用`,pre:`コード`}},linkDialog:{ariaLabel:`リンクを挿入`,title:`リンクを挿入`,url:`URL`,urlPlaceholder:`https://`,displayText:`表示テキスト`,textPlaceholder:`リンクテキスト`,openInNewTab:`新しいタブで開く`,insertBtn:`挿入`,cancelBtn:`キャンセル`},imageDialog:{ariaLabel:`画像を挿入`,title:`画像を挿入`,imageUrl:`画像URL`,urlPlaceholder:`https://example.com/image.png`,altText:`代替テキスト`,altPlaceholder:`画像の説明`,alignment:`配置`,alignNone:`なし`,alignLeft:`左`,alignCenter:`中央`,alignRight:`右`,uploadLabel:`ファイルをアップロード`,insertBtn:`挿入`,cancelBtn:`キャンセル`},videoDialog:{ariaLabel:`動画を挿入`,title:`動画を挿入`,videoUrl:`動画URL`,urlPlaceholder:`YouTube、Vimeo、または直接動画URL`,widthLabel:`幅 (px)`,widthPlaceholder:`560`,insertBtn:`挿入`,cancelBtn:`キャンセル`,detected:e=>`検出: ${e}`,unknownFormat:`不明な形式 — 直接動画埋め込みを試みます`,invalidUrl:`URLが無効です — 有効な動画URLを入力してください。`},emojiDialog:{ariaLabel:`絵文字を挿入`,title:`絵文字を挿入`,searchPlaceholder:`絵文字を検索…`,all:`すべて`,cancelBtn:`キャンセル`,close:`閉じる`,categories:{smileys:`顔文字`,people:`人物`,animals:`動物`,food:`食べ物`,travel:`旅行`,objects:`モノ`,symbols:`記号`}},iconDialog:{ariaLabel:`FAアイコンを挿入`,title:`FAアイコンを挿入`,searchPlaceholder:`アイコンを検索…`,all:`すべて`,style:`スタイル`,size:`サイズ`,color:`カラー`,useColor:` カラーを使用`,selectHint:`アイコンを選択してください`,insertBtn:`FAアイコンを挿入`,cancelBtn:`キャンセル`,close:`閉じる`,categories:{popular:`人気`,interface:`インターフェース`,navigation:`ナビゲーション`,media:`メディア`,communication:`通信`,files:`ファイル`,people:`人物`,objects:`モノ`}},findReplace:{findTitle:`検索`,findReplaceTitle:`検索と置換`,findPlaceholder:`検索…`,searchAriaLabel:`検索テキスト`,caseSensitive:`\xA0大文字/小文字を区別`,wholeWord:`単語単位`,prevBtn:`← 前へ`,nextBtn:`次へ →`,replacePlaceholder:`置換後…`,replaceAriaLabel:`置換後のテキスト`,replaceBtn:`置換`,noResults:`結果なし`,useRegex:`正規表現を使用`,prevMatch:`前へ (Shift+Enter)`,nextMatch:`次へ (Enter)`,replaceAllBtn:`すべて置換`,close:`×`},shortcutsDialog:{title:`キーボードショートカット`,ariaLabel:`キーボードショートカット`,close:`閉じる`,customCategory:`カスタム`,shortcuts:[{category:`テキスト書式`,items:[{keys:`Ctrl + B`,action:`太字`},{keys:`Ctrl + I`,action:`斜体`},{keys:`Ctrl + U`,action:`下線`},{keys:`Ctrl + K`,action:`リンクの挿入 / 編集`}]},{category:`履歴`,items:[{keys:`Ctrl + Z`,action:`元に戻す`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`やり直す`}]},{category:`選択と移動`,items:[{keys:`Ctrl + A`,action:`すべて選択`},{keys:`Tab`,action:`インデント増加 / スペース挿入`},{keys:`Shift + Tab`,action:`インデント減少`}]},{category:`クリップボード`,items:[{keys:`Ctrl + Shift + V`,action:`プレーンテキストとして貼り付け`}]},{category:`検索と置換`,items:[{keys:`Ctrl + F`,action:`文書内を検索`},{keys:`Ctrl + H`,action:`検索と置換`}]},{category:`エディター`,items:[{keys:`Ctrl + Shift + /`,action:`ショートカットダイアログを表示`}]}]},contextMenu:{cut:`切り取り`,copy:`コピー`,paste:`貼り付け`,bold:`太字`,italic:`斜体`,underline:`下線`,textColor:`文字色`,highlightColor:`ハイライト色`,copyFormat:`書式をコピー`,pasteFormat:`書式を貼り付け`,removeFormat:`書式をリセット`,link:`リンクを挿入`,image:`画像を挿入`,video:`動画を挿入`,table:`テーブルを挿入`,back:`戻る`,noHighlight:`ハイライトなし`,customColor:`カスタムカラー`,customColorLabel:`カスタム…`},statusbar:{resizeHandle:`ドラッグしてリサイズ`,words:e=>`単語数: ${e}`,wordsLimit:(e,t)=>`単語数: ${e}/${t}`,chars:e=>`文字数: ${e}`,charsLimit:(e,t)=>`文字数: ${e}/${t}`},a11y:{editor:`リッチテキストエディター`,toolbar:`エディターツールバー`,statistics:`エディターの統計`,tableSize:`表のサイズを選択`},tooltips:{link:{ariaLabel:`リンク操作`,openLink:`リンクを開く`,copyUrl:`URLをコピー`,editLink:`リンクを編集`,removeLink:`リンクを削除`},image:{ariaLabel:`画像操作`,label:`画像`,floatLeft:`左に回り込み`,noFloat:`回り込みなし`,alignCenter:`中央揃え`,floatRight:`右に回り込み`,originalSize:`元のサイズ`,rotateLeft:`左に回転`,rotateRight:`右に回転`,cropImage:`画像をトリミング`,addCaption:`キャプションを追加 / 編集`,deleteImage:`画像を削除`},code:{ariaLabel:`コードブロック操作`,label:`コード`,syntaxLanguage:`言語`,syntaxAriaLabel:`構文言語`,copyCode:`コードをコピー`,toggleWordWrap:`折り返しを切り替え`,enableWordWrap:`折り返しを有効にする`,disableWordWrap:`折り返しを無効にする`,convertToParagraph:`段落に変換`,deleteCodeBlock:`コードブロックを削除`,lineNumbers:`行番号を切り替え`},table:{ariaLabel:`テーブル操作`,label:`テーブル`,selectCells:`セルを選択`,addRowAbove:`上に行を追加`,addRowBelow:`下に行を追加`,deleteRow:`行を削除`,addColumnLeft:`左に列を追加`,addColumnRight:`右に列を追加`,deleteColumn:`列を削除`,mergeCells:`セルを結合`,unmergeCells:`セルの結合を解除`,columnWidth:`列幅`,rowHeight:`行の高さ`,tableBorderWidth:`テーブルの枠幅`,tableBorderColor:`テーブルの枠線色`,deleteTable:`テーブルを削除`,cellAlignLeft:`左揃え`,cellAlignCenter:`中央揃え`,cellAlignRight:`右揃え`,cellAlignJustify:`両端揃え`,toggleHeaderRow:`ヘッダー行の切り替え`,cellBackground:`セル背景色`,noShading:`背景色なし`,noBorderColor:`枠線色なし`,columnWidthPx:`列幅 (px)`,rowHeightPx:`行の高さ (px)`,tableBorderWidthPx:`テーブルの枠幅 (px)`,cancelBtn:`キャンセル`,applyBtn:`適用`,sortAsc:`昇順で並べ替え`,sortDesc:`降順で並べ替え`,exportCSV:`CSVとしてエクスポート`,cellPadding:`セルの余白`,cellPaddingPx:`セルの余白 (px)`},video:{ariaLabel:`動画操作`,label:`動画`,floatLeft:`左に回り込み`,noFloat:`回り込みなし`,alignCenter:`中央揃え`,floatRight:`右に回り込み`,originalSize:`元のサイズ`,previewVideo:`プレビュー`,exitPreview:`プレビューを終了`,deleteVideo:`動画を削除`}},errors:{imageFormat:e=>`形式 "${e}" はブラウザでの表示をサポートしていません。JPEG、PNG、または WebP に変換してください。`,imageSize:e=>`画像ファイルが大きすぎます。最大許容サイズは ${e} MB です。`},autoSaveRestore:{found:`下書きが見つかりました。復元しますか?`,foundAt:`{date} の下書きが見つかりました。復元しますか?`,restore:`復元`,discard:`破棄`},slashMenu:{noResults:`一致するコマンドがありません`,heading1:`見出し1`,heading2:`見出し2`,heading3:`見出し3`,bulletList:`箇条書きリスト`,numberedList:`番号付きリスト`,checklist:`チェックリスト`,blockquote:`引用`,codeBlock:`コードブロック`,horizontalRule:`水平線`,table:`表`,image:`画像`}}),c(`zh`,{toolbar:{bold:`粗体 (Ctrl+B)`,italic:`斜体 (Ctrl+I)`,underline:`下划线 (Ctrl+U)`,strikethrough:`删除线`,superscript:`上标`,subscript:`下标`,alignLeft:`左对齐`,alignCenter:`居中`,alignRight:`右对齐`,alignJustify:`两端对齐`,ul:`无序列表`,ol:`有序列表`,checklist:`待办列表`,indent:`增加缩进`,outdent:`减少缩进`,undo:`撤销 (Ctrl+Z)`,redo:`重做 (Ctrl+Y)`,hr:`水平分割线`,link:`插入链接`,image:`插入图片`,video:`插入视频`,emoji:`插入表情`,icon:`插入 FA 图标`,table:`插入表格`,fontSize:`字号`,fontSizePlaceholder:`大小`,removeFormat:`清除格式`,direction:`切换文字方向 (LTR / RTL)`,fontFamily:`字体`,paragraphStyle:`段落样式`,paragraphStylePlaceholder:`样式`,lineHeight:`行高`,lineHeightPlaceholder:`↕ 行距`,codeview:`查看 HTML 源码`,fullscreen:`全屏`,shortcuts:`键盘快捷键 (Ctrl+Shift+/)`,find:`搜索 (Ctrl+F)`,findReplace:`查找和替换 (Ctrl+H)`,inlineCode:"行内代码 (Ctrl+`)",print:`打印`,foreColor:`文字颜色`,backColor:`高亮颜色`,chooseTextColor:`选择文字颜色`,chooseHighlightColor:`选择高亮颜色`,customColor:`自定义颜色`,insertTableLabel:`插入表格`,paragraphItems:{p:`正文`,blockquote:`引用`,pre:`代码`}},linkDialog:{ariaLabel:`插入链接`,title:`插入链接`,url:`链接地址`,urlPlaceholder:`https://`,displayText:`显示文字`,textPlaceholder:`链接文字`,openInNewTab:`在新标签页中打开`,insertBtn:`插入`,cancelBtn:`取消`},imageDialog:{ariaLabel:`插入图片`,title:`插入图片`,imageUrl:`图片地址`,urlPlaceholder:`https://example.com/image.png`,altText:`替代文字`,altPlaceholder:`图片描述`,alignment:`对齐方式`,alignNone:`无`,alignLeft:`左`,alignCenter:`居中`,alignRight:`右`,uploadLabel:`或上传文件`,insertBtn:`插入`,cancelBtn:`取消`},videoDialog:{ariaLabel:`插入视频`,title:`插入视频`,videoUrl:`视频地址`,urlPlaceholder:`YouTube、Vimeo 或直接 .mp4 链接`,widthLabel:`宽度 (px)`,widthPlaceholder:`560`,insertBtn:`插入`,cancelBtn:`取消`,detected:e=>`已识别: ${e}`,unknownFormat:`未知格式 — 将尝试直接嵌入视频`,invalidUrl:`URL 无效 — 请输入有效的视频链接。`},emojiDialog:{ariaLabel:`插入表情`,title:`插入表情`,searchPlaceholder:`搜索表情…`,all:`全部`,cancelBtn:`取消`,close:`关闭`,categories:{smileys:`笑脸`,people:`人物`,animals:`动物`,food:`食物`,travel:`旅行`,objects:`物品`,symbols:`符号`}},iconDialog:{ariaLabel:`插入 FA 图标`,title:`插入 FA 图标`,searchPlaceholder:`搜索图标…`,all:`全部`,style:`样式`,size:`大小`,color:`颜色`,useColor:` 使用颜色`,selectHint:`请选择一个图标`,insertBtn:`插入 FA 图标`,cancelBtn:`取消`,close:`关闭`,categories:{popular:`热门`,interface:`界面`,navigation:`导航`,media:`媒体`,communication:`通讯`,files:`文件`,people:`人物`,objects:`物品`}},findReplace:{findTitle:`搜索`,findReplaceTitle:`查找和替换`,findPlaceholder:`查找…`,searchAriaLabel:`搜索文字`,caseSensitive:`\xA0区分大小写`,wholeWord:`全字匹配`,prevBtn:`← 上一个`,nextBtn:`下一个 →`,replacePlaceholder:`替换为…`,replaceAriaLabel:`替换为`,replaceBtn:`替换`,noResults:`没有结果`,useRegex:`使用正则表达式`,prevMatch:`上一个 (Shift+Enter)`,nextMatch:`下一个 (Enter)`,replaceAllBtn:`全部替换`,close:`×`},shortcutsDialog:{title:`键盘快捷键`,ariaLabel:`键盘快捷键`,close:`关闭`,customCategory:`自定义`,shortcuts:[{category:`文字格式`,items:[{keys:`Ctrl + B`,action:`粗体`},{keys:`Ctrl + I`,action:`斜体`},{keys:`Ctrl + U`,action:`下划线`},{keys:`Ctrl + K`,action:`插入 / 编辑链接`}]},{category:`历史记录`,items:[{keys:`Ctrl + Z`,action:`撤销`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`重做`}]},{category:`选择与导航`,items:[{keys:`Ctrl + A`,action:`全选`},{keys:`Tab`,action:`增加缩进 / 插入空格`},{keys:`Shift + Tab`,action:`减少缩进`}]},{category:`剪贴板`,items:[{keys:`Ctrl + Shift + V`,action:`粘贴为纯文本`}]},{category:`查找和替换`,items:[{keys:`Ctrl + F`,action:`在文档中搜索`},{keys:`Ctrl + H`,action:`查找和替换`}]},{category:`编辑器`,items:[{keys:`Ctrl + Shift + /`,action:`显示快捷键对话框`}]}]},contextMenu:{cut:`剪切`,copy:`复制`,paste:`粘贴`,bold:`粗体`,italic:`斜体`,underline:`下划线`,textColor:`文字颜色`,highlightColor:`高亮颜色`,copyFormat:`复制格式`,pasteFormat:`粘贴格式`,removeFormat:`清除格式`,link:`插入链接`,image:`插入图片`,video:`插入视频`,table:`插入表格`,back:`返回`,noHighlight:`无高亮`,customColor:`自定义颜色`,customColorLabel:`自定义…`},statusbar:{resizeHandle:`拖动以调整大小`,words:e=>`字数: ${e}`,wordsLimit:(e,t)=>`字数: ${e}/${t}`,chars:e=>`字符数: ${e}`,charsLimit:(e,t)=>`字符数: ${e}/${t}`},a11y:{editor:`富文本编辑器`,toolbar:`编辑器工具栏`,statistics:`编辑器统计`,tableSize:`选择表格大小`},tooltips:{link:{ariaLabel:`链接操作`,openLink:`打开链接`,copyUrl:`复制 URL`,editLink:`编辑链接`,removeLink:`删除链接`},image:{ariaLabel:`图片操作`,label:`图片`,floatLeft:`左浮动`,noFloat:`不浮动`,alignCenter:`居中对齐`,floatRight:`右浮动`,originalSize:`原始尺寸`,rotateLeft:`向左旋转`,rotateRight:`向右旋转`,cropImage:`裁剪图片`,addCaption:`添加 / 编辑说明`,deleteImage:`删除图片`},code:{ariaLabel:`代码块操作`,label:`代码`,syntaxLanguage:`语法语言`,syntaxAriaLabel:`语法语言`,copyCode:`复制代码`,toggleWordWrap:`切换自动换行`,enableWordWrap:`启用自动换行`,disableWordWrap:`禁用自动换行`,convertToParagraph:`转换为段落`,deleteCodeBlock:`删除代码块`,lineNumbers:`切换行号`},table:{ariaLabel:`表格操作`,label:`表格`,selectCells:`选择单元格`,addRowAbove:`在上方插入行`,addRowBelow:`在下方插入行`,deleteRow:`删除行`,addColumnLeft:`在左侧插入列`,addColumnRight:`在右侧插入列`,deleteColumn:`删除列`,mergeCells:`合并单元格`,unmergeCells:`拆分单元格`,columnWidth:`列宽`,rowHeight:`行高`,tableBorderWidth:`表格边框宽度`,tableBorderColor:`表格边框颜色`,deleteTable:`删除表格`,cellAlignLeft:`左对齐`,cellAlignCenter:`居中对齐`,cellAlignRight:`右对齐`,cellAlignJustify:`两端对齐`,toggleHeaderRow:`切换标题行`,cellBackground:`单元格背景`,noShading:`无底纹`,noBorderColor:`无边框颜色`,columnWidthPx:`列宽 (px)`,rowHeightPx:`行高 (px)`,tableBorderWidthPx:`表格边框宽度 (px)`,cancelBtn:`取消`,applyBtn:`应用`,sortAsc:`升序排列`,sortDesc:`降序排列`,exportCSV:`导出为 CSV`,cellPadding:`单元格内边距`,cellPaddingPx:`单元格内边距 (px)`},video:{ariaLabel:`视频操作`,label:`视频`,floatLeft:`左浮动`,noFloat:`不浮动`,alignCenter:`居中对齐`,floatRight:`右浮动`,originalSize:`原始尺寸`,previewVideo:`预览视频`,exitPreview:`退出预览`,deleteVideo:`删除视频`}},errors:{imageFormat:e=>`格式 "${e}" 不支持在浏览器中显示。请转换为 JPEG、PNG 或 WebP。`,imageSize:e=>`图片文件过大。最大允许大小为 ${e} MB。`},autoSaveRestore:{found:`找到草稿。是否恢复?`,foundAt:`发现 {date} 的草稿。是否恢复?`,restore:`恢复`,discard:`放弃`},slashMenu:{noResults:`没有匹配的命令`,heading1:`标题 1`,heading2:`标题 2`,heading3:`标题 3`,bulletList:`项目符号列表`,numberedList:`编号列表`,checklist:`检查清单`,blockquote:`引用`,codeBlock:`代码块`,horizontalRule:`水平线`,table:`表格`,image:`图片`}}),c(`fr`,{toolbar:{bold:`Gras (Ctrl+B)`,italic:`Italique (Ctrl+I)`,underline:`Souligné (Ctrl+U)`,strikethrough:`Barré`,superscript:`Exposant`,subscript:`Indice`,alignLeft:`Aligner à gauche`,alignCenter:`Centrer`,alignRight:`Aligner à droite`,alignJustify:`Justifier`,ul:`Liste à puces`,ol:`Liste numérotée`,checklist:`Liste de tâches`,indent:`Augmenter le retrait`,outdent:`Diminuer le retrait`,undo:`Annuler (Ctrl+Z)`,redo:`Rétablir (Ctrl+Y)`,hr:`Ligne horizontale`,link:`Insérer un lien`,image:`Insérer une image`,video:`Insérer une vidéo`,emoji:`Insérer un emoji`,icon:`Insérer une icône FA`,table:`Insérer un tableau`,fontSize:`Taille de police`,fontSizePlaceholder:`Taille`,removeFormat:`Effacer la mise en forme`,direction:`Basculer la direction du texte (LTR / RTL)`,fontFamily:`Police`,paragraphStyle:`Style de paragraphe`,paragraphStylePlaceholder:`Style`,lineHeight:`Interligne`,lineHeightPlaceholder:`↕ Ligne`,codeview:`Afficher le code HTML`,fullscreen:`Plein écran`,shortcuts:`Raccourcis clavier (Ctrl+Shift+/)`,find:`Rechercher (Ctrl+F)`,findReplace:`Rechercher et remplacer (Ctrl+H)`,inlineCode:"Code inline (Ctrl+`)",print:`Imprimer`,foreColor:`Couleur du texte`,backColor:`Couleur de surbrillance`,chooseTextColor:`Choisir la couleur du texte`,chooseHighlightColor:`Choisir la couleur de surbrillance`,customColor:`Couleur personnalisée`,insertTableLabel:`Insérer un tableau`,paragraphItems:{p:`Normal`,blockquote:`Citation`,pre:`Code`}},linkDialog:{ariaLabel:`Insérer un lien`,title:`Insérer un lien`,url:`URL`,urlPlaceholder:`https://`,displayText:`Texte affiché`,textPlaceholder:`Texte du lien`,openInNewTab:`Ouvrir dans un nouvel onglet`,insertBtn:`Insérer`,cancelBtn:`Annuler`},imageDialog:{ariaLabel:`Insérer une image`,title:`Insérer une image`,imageUrl:`URL de l'image`,urlPlaceholder:`https://example.com/image.png`,altText:`Texte alternatif`,altPlaceholder:`Description de l'image`,alignment:`Alignement`,alignNone:`Aucun`,alignLeft:`Gauche`,alignCenter:`Centre`,alignRight:`Droite`,uploadLabel:`Ou téléverser un fichier`,insertBtn:`Insérer`,cancelBtn:`Annuler`},videoDialog:{ariaLabel:`Insérer une vidéo`,title:`Insérer une vidéo`,videoUrl:`URL de la vidéo`,urlPlaceholder:`YouTube, Vimeo ou URL .mp4 directe`,widthLabel:`Largeur (px)`,widthPlaceholder:`560`,insertBtn:`Insérer`,cancelBtn:`Annuler`,detected:e=>`Détecté\u00a0: ${e}`,unknownFormat:`Format inconnu — tentative d'intégration directe`,invalidUrl:`URL invalide — veuillez saisir un lien vidéo valide.`},emojiDialog:{ariaLabel:`Insérer un emoji`,title:`Insérer un emoji`,searchPlaceholder:`Rechercher des emojis…`,all:`Tout`,cancelBtn:`Annuler`,close:`Fermer`,categories:{smileys:`Smileys`,people:`Personnes`,animals:`Animaux`,food:`Nourriture`,travel:`Voyage`,objects:`Objets`,symbols:`Symboles`}},iconDialog:{ariaLabel:`Insérer une icône FA`,title:`Insérer une icône FA`,searchPlaceholder:`Rechercher des icônes…`,all:`Tout`,style:`Style`,size:`Taille`,color:`Couleur`,useColor:` Utiliser la couleur`,selectHint:`Sélectionner une icône`,insertBtn:`Insérer une icône FA`,cancelBtn:`Annuler`,close:`Fermer`,categories:{popular:`Populaire`,interface:`Interface`,navigation:`Navigation`,media:`Média`,communication:`Communication`,files:`Fichiers`,people:`Personnes`,objects:`Objets`}},findReplace:{findTitle:`Rechercher`,findReplaceTitle:`Rechercher et remplacer`,findPlaceholder:`Rechercher…`,searchAriaLabel:`Texte à rechercher`,caseSensitive:`\xA0Respecter la casse`,wholeWord:`Mot entier`,prevBtn:`← Préc.`,nextBtn:`Suiv. →`,replacePlaceholder:`Remplacer par…`,replaceAriaLabel:`Remplacer par`,replaceBtn:`Remplacer`,noResults:`Aucun résultat`,useRegex:`Utiliser une expression régulière`,prevMatch:`Précédent (Maj+Entrée)`,nextMatch:`Suivant (Entrée)`,replaceAllBtn:`Tout remplacer`,close:`×`},shortcutsDialog:{title:`Raccourcis clavier`,ariaLabel:`Raccourcis clavier`,close:`Fermer`,customCategory:`Personnalisés`,shortcuts:[{category:`Mise en forme du texte`,items:[{keys:`Ctrl + B`,action:`Gras`},{keys:`Ctrl + I`,action:`Italique`},{keys:`Ctrl + U`,action:`Souligné`},{keys:`Ctrl + K`,action:`Insérer / modifier un lien`}]},{category:`Historique`,items:[{keys:`Ctrl + Z`,action:`Annuler`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Rétablir`}]},{category:`Sélection et navigation`,items:[{keys:`Ctrl + A`,action:`Tout sélectionner`},{keys:`Tab`,action:`Augmenter le retrait / insérer des espaces`},{keys:`Shift + Tab`,action:`Diminuer le retrait`}]},{category:`Presse-papiers`,items:[{keys:`Ctrl + Shift + V`,action:`Coller en texte brut`}]},{category:`Rechercher et remplacer`,items:[{keys:`Ctrl + F`,action:`Rechercher dans le document`},{keys:`Ctrl + H`,action:`Rechercher et remplacer`}]},{category:`Éditeur`,items:[{keys:`Ctrl + Shift + /`,action:`Afficher les raccourcis clavier`}]}]},contextMenu:{cut:`Couper`,copy:`Copier`,paste:`Coller`,bold:`Gras`,italic:`Italique`,underline:`Souligné`,textColor:`Couleur du texte`,highlightColor:`Couleur de surbrillance`,copyFormat:`Copier la mise en forme`,pasteFormat:`Coller la mise en forme`,removeFormat:`Effacer la mise en forme`,link:`Insérer un lien`,image:`Insérer une image`,video:`Insérer une vidéo`,table:`Insérer un tableau`,back:`Retour`,noHighlight:`Sans surbrillance`,customColor:`Couleur personnalisée`,customColorLabel:`Personnaliser…`},statusbar:{resizeHandle:`Faire glisser pour redimensionner`,words:e=>`Mots\u00a0: ${e}`,wordsLimit:(e,t)=>`Mots\u00a0: ${e}/${t}`,chars:e=>`Caractères\u00a0: ${e}`,charsLimit:(e,t)=>`Caractères\u00a0: ${e}/${t}`},a11y:{editor:`Éditeur de texte enrichi`,toolbar:`Barre d'outils de l'éditeur`,statistics:`Statistiques de l'éditeur`,tableSize:`Choisir la taille du tableau`},tooltips:{link:{ariaLabel:`Actions du lien`,openLink:`Ouvrir le lien`,copyUrl:`Copier l'URL`,editLink:`Modifier le lien`,removeLink:`Supprimer le lien`},image:{ariaLabel:`Actions de l'image`,label:`Image`,floatLeft:`Flottant à gauche`,noFloat:`Sans flottant`,alignCenter:`Centré`,floatRight:`Flottant à droite`,originalSize:`Taille originale`,rotateLeft:`Rotation à gauche`,rotateRight:`Rotation à droite`,cropImage:`Recadrer l'image`,addCaption:`Ajouter / modifier la légende`,deleteImage:`Supprimer l'image`},code:{ariaLabel:`Actions du bloc de code`,label:`Code`,syntaxLanguage:`Langage de syntaxe`,syntaxAriaLabel:`Langage de syntaxe`,copyCode:`Copier le code`,toggleWordWrap:`Activer/désactiver le retour à la ligne`,enableWordWrap:`Activer le retour à la ligne`,disableWordWrap:`Désactiver le retour à la ligne`,convertToParagraph:`Convertir en paragraphe`,deleteCodeBlock:`Supprimer le bloc de code`,lineNumbers:`Activer/désactiver les numéros de ligne`},table:{ariaLabel:`Actions du tableau`,label:`Tableau`,selectCells:`Sélectionner des cellules`,addRowAbove:`Ajouter une ligne au-dessus`,addRowBelow:`Ajouter une ligne en-dessous`,deleteRow:`Supprimer la ligne`,addColumnLeft:`Ajouter une colonne à gauche`,addColumnRight:`Ajouter une colonne à droite`,deleteColumn:`Supprimer la colonne`,mergeCells:`Fusionner les cellules`,unmergeCells:`Scinder les cellules`,columnWidth:`Largeur de colonne`,rowHeight:`Hauteur de ligne`,tableBorderWidth:`Épaisseur des bordures`,tableBorderColor:`Couleur de bordure`,deleteTable:`Supprimer le tableau`,cellAlignLeft:`Aligner à gauche`,cellAlignCenter:`Centrer`,cellAlignRight:`Aligner à droite`,cellAlignJustify:`Justifier`,toggleHeaderRow:`Ligne d'en-tête`,cellBackground:`Couleur de fond`,noShading:`Aucun fond`,noBorderColor:`Aucune bordure`,columnWidthPx:`Largeur de colonne (px)`,rowHeightPx:`Hauteur de ligne (px)`,tableBorderWidthPx:`Épaisseur des bordures (px)`,cancelBtn:`Annuler`,applyBtn:`Appliquer`,sortAsc:`Trier par ordre croissant`,sortDesc:`Trier par ordre décroissant`,exportCSV:`Exporter en CSV`,cellPadding:`Rembourrage des cellules`,cellPaddingPx:`Rembourrage des cellules (px)`},video:{ariaLabel:`Actions de la vidéo`,label:`Vidéo`,floatLeft:`Flottant à gauche`,noFloat:`Sans flottant`,alignCenter:`Centré`,floatRight:`Flottant à droite`,originalSize:`Taille originale`,previewVideo:`Aperçu`,exitPreview:`Quitter l'aperçu`,deleteVideo:`Supprimer la vidéo`}},errors:{imageFormat:e=>`Le format "${e}" n'est pas pris en charge par le navigateur. Veuillez le convertir en JPEG, PNG ou WebP.`,imageSize:e=>`Le fichier image est trop volumineux. La taille maximale autorisée est de ${e}\u00a0Mo.`},autoSaveRestore:{found:`Brouillon trouvé. Restaurer ?`,foundAt:`Brouillon du {date}. Restaurer ?`,restore:`Restaurer`,discard:`Ignorer`},slashMenu:{noResults:`Aucune commande correspondante`,heading1:`Titre 1`,heading2:`Titre 2`,heading3:`Titre 3`,bulletList:`Liste à puces`,numberedList:`Liste numérotée`,checklist:`Liste de contrôle`,blockquote:`Citation`,codeBlock:`Bloc de code`,horizontalRule:`Ligne horizontale`,table:`Tableau`,image:`Image`}}),c(`de`,{toolbar:{bold:`Fett (Ctrl+B)`,italic:`Kursiv (Ctrl+I)`,underline:`Unterstrichen (Ctrl+U)`,strikethrough:`Durchgestrichen`,superscript:`Hochgestellt`,subscript:`Tiefgestellt`,alignLeft:`Linksbündig`,alignCenter:`Zentriert`,alignRight:`Rechtsbündig`,alignJustify:`Blocksatz`,ul:`Ungeordnete Liste`,ol:`Geordnete Liste`,checklist:`Checkliste`,indent:`Einzug vergrößern`,outdent:`Einzug verkleinern`,undo:`Rückgängig (Ctrl+Z)`,redo:`Wiederholen (Ctrl+Y)`,hr:`Horizontale Linie`,link:`Link einfügen`,image:`Bild einfügen`,video:`Video einfügen`,emoji:`Emoji einfügen`,icon:`FA-Symbol einfügen`,table:`Tabelle einfügen`,fontSize:`Schriftgröße`,fontSizePlaceholder:`Größe`,removeFormat:`Formatierung entfernen`,direction:`Textrichtung umschalten (LTR / RTL)`,fontFamily:`Schriftart`,paragraphStyle:`Absatzstil`,paragraphStylePlaceholder:`Stil`,lineHeight:`Zeilenhöhe`,lineHeightPlaceholder:`↕ Zeile`,codeview:`HTML-Code-Ansicht`,fullscreen:`Vollbild`,shortcuts:`Tastenkürzel (Ctrl+Shift+/)`,find:`Suchen (Ctrl+F)`,findReplace:`Suchen & Ersetzen (Ctrl+H)`,inlineCode:"Inline-Code (Ctrl+`)",print:`Drucken`,foreColor:`Textfarbe`,backColor:`Hervorhebungsfarbe`,chooseTextColor:`Textfarbe auswählen`,chooseHighlightColor:`Hervorhebungsfarbe auswählen`,customColor:`Benutzerdefinierte Farbe`,insertTableLabel:`Tabelle einfügen`,paragraphItems:{p:`Normal`,blockquote:`Zitat`,pre:`Code`}},linkDialog:{ariaLabel:`Link einfügen`,title:`Link einfügen`,url:`URL`,urlPlaceholder:`https://`,displayText:`Anzeigetext`,textPlaceholder:`Linktext`,openInNewTab:`In neuem Tab öffnen`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`},imageDialog:{ariaLabel:`Bild einfügen`,title:`Bild einfügen`,imageUrl:`Bild-URL`,urlPlaceholder:`https://example.com/image.png`,altText:`Alt-Text`,altPlaceholder:`Bild beschreiben`,alignment:`Ausrichtung`,alignNone:`Keine`,alignLeft:`Links`,alignCenter:`Mitte`,alignRight:`Rechts`,uploadLabel:`Oder Datei hochladen`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`},videoDialog:{ariaLabel:`Video einfügen`,title:`Video einfügen`,videoUrl:`Video-URL`,urlPlaceholder:`YouTube, Vimeo oder direkte .mp4-URL`,widthLabel:`Breite (px)`,widthPlaceholder:`560`,insertBtn:`Einfügen`,cancelBtn:`Abbrechen`,detected:e=>`Erkannt: ${e}`,unknownFormat:`Unbekanntes Format — direktes Video-Einbetten wird versucht`,invalidUrl:`Ungültige URL — bitte geben Sie einen gültigen Videolink ein.`},emojiDialog:{ariaLabel:`Emoji einfügen`,title:`Emoji einfügen`,searchPlaceholder:`Emojis suchen…`,all:`Alle`,cancelBtn:`Abbrechen`,close:`Schließen`,categories:{smileys:`Smileys`,people:`Menschen`,animals:`Tiere`,food:`Essen`,travel:`Reisen`,objects:`Objekte`,symbols:`Symbole`}},iconDialog:{ariaLabel:`FA-Symbol einfügen`,title:`FA-Symbol einfügen`,searchPlaceholder:`Symbole suchen…`,all:`Alle`,style:`Stil`,size:`Größe`,color:`Farbe`,useColor:` Farbe verwenden`,selectHint:`Symbol auswählen`,insertBtn:`FA-Symbol einfügen`,cancelBtn:`Abbrechen`,close:`Schließen`,categories:{popular:`Beliebt`,interface:`Benutzeroberfläche`,navigation:`Navigation`,media:`Medien`,communication:`Kommunikation`,files:`Dateien`,people:`Menschen`,objects:`Objekte`}},findReplace:{findTitle:`Suchen`,findReplaceTitle:`Suchen & Ersetzen`,findPlaceholder:`Suchen…`,searchAriaLabel:`Suchtext`,caseSensitive:`\xA0Groß-/Kleinschreibung`,wholeWord:`Ganzes Wort`,prevBtn:`← Zurück`,nextBtn:`Weiter →`,replacePlaceholder:`Ersetzen durch…`,replaceAriaLabel:`Ersetzen durch`,replaceBtn:`Ersetzen`,noResults:`Keine Ergebnisse`,useRegex:`Regulären Ausdruck verwenden`,prevMatch:`Zurück (Umschalt+Eingabe)`,nextMatch:`Weiter (Eingabe)`,replaceAllBtn:`Alle ersetzen`,close:`×`},shortcutsDialog:{title:`Tastenkürzel`,ariaLabel:`Tastenkürzel`,close:`Schließen`,customCategory:`Benutzerdefiniert`,shortcuts:[{category:`Textformatierung`,items:[{keys:`Ctrl + B`,action:`Fett`},{keys:`Ctrl + I`,action:`Kursiv`},{keys:`Ctrl + U`,action:`Unterstrichen`},{keys:`Ctrl + K`,action:`Link einfügen / bearbeiten`}]},{category:`Verlauf`,items:[{keys:`Ctrl + Z`,action:`Rückgängig`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Wiederholen`}]},{category:`Auswahl & Navigation`,items:[{keys:`Ctrl + A`,action:`Alles auswählen`},{keys:`Tab`,action:`Listenebene erhöhen / Leerzeichen einfügen`},{keys:`Shift + Tab`,action:`Listenebene verringern`}]},{category:`Zwischenablage`,items:[{keys:`Ctrl + Shift + V`,action:`Als einfachen Text einfügen`}]},{category:`Suchen & Ersetzen`,items:[{keys:`Ctrl + F`,action:`Im Dokument suchen`},{keys:`Ctrl + H`,action:`Suchen & Ersetzen`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Diesen Tastenkürzel-Dialog anzeigen`}]}]},contextMenu:{cut:`Ausschneiden`,copy:`Kopieren`,paste:`Einfügen`,bold:`Fett`,italic:`Kursiv`,underline:`Unterstrichen`,textColor:`Textfarbe`,highlightColor:`Hervorhebungsfarbe`,copyFormat:`Format kopieren`,pasteFormat:`Format einfügen`,removeFormat:`Formatierung entfernen`,link:`Link einfügen`,image:`Bild einfügen`,video:`Video einfügen`,table:`Tabelle einfügen`,back:`Zurück`,noHighlight:`Keine Hervorhebung`,customColor:`Benutzerdefinierte Farbe`,customColorLabel:`Benutzerdefiniert…`},statusbar:{resizeHandle:`Editor-Größe ändern`,words:e=>`Wörter: ${e}`,wordsLimit:(e,t)=>`Wörter: ${e}/${t}`,chars:e=>`Zeichen: ${e}`,charsLimit:(e,t)=>`Zeichen: ${e}/${t}`},a11y:{editor:`Rich-Text-Editor`,toolbar:`Editor-Werkzeugleiste`,statistics:`Editor-Statistik`,tableSize:`Tabellengröße wählen`},tooltips:{link:{ariaLabel:`Link-Aktionen`,openLink:`Link öffnen`,copyUrl:`URL kopieren`,editLink:`Link bearbeiten`,removeLink:`Link entfernen`},image:{ariaLabel:`Bild-Aktionen`,label:`Bild`,floatLeft:`Links umfließen`,noFloat:`Kein Umfluss`,alignCenter:`Zentriert`,floatRight:`Rechts umfließen`,originalSize:`Originalgröße`,rotateLeft:`Links drehen`,rotateRight:`Rechts drehen`,cropImage:`Bild zuschneiden`,addCaption:`Beschriftung hinzufügen / bearbeiten`,deleteImage:`Bild löschen`},code:{ariaLabel:`Codeblock-Aktionen`,label:`Code`,syntaxLanguage:`Syntaxsprache`,syntaxAriaLabel:`Syntaxsprache`,copyCode:`Code kopieren`,toggleWordWrap:`Zeilenumbruch umschalten`,enableWordWrap:`Zeilenumbruch aktivieren`,disableWordWrap:`Zeilenumbruch deaktivieren`,convertToParagraph:`In Absatz umwandeln`,deleteCodeBlock:`Codeblock löschen`,lineNumbers:`Zeilennummern umschalten`},table:{ariaLabel:`Tabellen-Aktionen`,label:`Tabelle`,selectCells:`Zellen auswählen`,addRowAbove:`Zeile oben hinzufügen`,addRowBelow:`Zeile unten hinzufügen`,deleteRow:`Zeile löschen`,addColumnLeft:`Spalte links hinzufügen`,addColumnRight:`Spalte rechts hinzufügen`,deleteColumn:`Spalte löschen`,mergeCells:`Zellen zusammenführen`,unmergeCells:`Zellen trennen`,columnWidth:`Spaltenbreite`,rowHeight:`Zeilenhöhe`,tableBorderWidth:`Tabellenrahmenbreite`,tableBorderColor:`Tabellenrahmenfarbe`,deleteTable:`Tabelle löschen`,cellAlignLeft:`Linksbündig`,cellAlignCenter:`Zentrieren`,cellAlignRight:`Rechtsbündig`,cellAlignJustify:`Blocksatz`,toggleHeaderRow:`Kopfzeile umschalten`,cellBackground:`Zellhintergrund`,noShading:`Kein Hintergrund`,noBorderColor:`Keine Rahmenfarbe`,columnWidthPx:`Spaltenbreite (px)`,rowHeightPx:`Zeilenhöhe (px)`,tableBorderWidthPx:`Tabellenrahmenbreite (px)`,cancelBtn:`Abbrechen`,applyBtn:`Anwenden`,sortAsc:`Aufsteigend sortieren`,sortDesc:`Absteigend sortieren`,exportCSV:`Als CSV exportieren`,cellPadding:`Zellauffüllung`,cellPaddingPx:`Zellauffüllung (px)`},video:{ariaLabel:`Video-Aktionen`,label:`Video`,floatLeft:`Links umfließen`,noFloat:`Kein Umfluss`,alignCenter:`Zentriert`,floatRight:`Rechts umfließen`,originalSize:`Originalgröße`,previewVideo:`Video-Vorschau`,exitPreview:`Vorschau beenden`,deleteVideo:`Video löschen`}},errors:{imageFormat:e=>`Das Format „${e}" wird in Webbrowsern nicht unterstützt. Bitte konvertieren Sie es zuerst in JPEG, PNG oder WebP.`,imageSize:e=>`Die Bilddatei ist zu groß. Die maximal zulässige Größe beträgt ${e} MB.`},autoSaveRestore:{found:`Entwurf gefunden. Wiederherstellen?`,foundAt:`Entwurf vom {date}. Wiederherstellen?`,restore:`Wiederherstellen`,discard:`Verwerfen`},slashMenu:{noResults:`Keine passenden Befehle`,heading1:`Überschrift 1`,heading2:`Überschrift 2`,heading3:`Überschrift 3`,bulletList:`Aufzählungsliste`,numberedList:`Nummerierte Liste`,checklist:`Checkliste`,blockquote:`Zitat`,codeBlock:`Codeblock`,horizontalRule:`Horizontale Linie`,table:`Tabelle`,image:`Bild`}}),c(`es`,{toolbar:{bold:`Negrita (Ctrl+B)`,italic:`Cursiva (Ctrl+I)`,underline:`Subrayado (Ctrl+U)`,strikethrough:`Tachado`,superscript:`Superíndice`,subscript:`Subíndice`,alignLeft:`Alinear a la izquierda`,alignCenter:`Centrar`,alignRight:`Alinear a la derecha`,alignJustify:`Justificar`,ul:`Lista sin orden`,ol:`Lista ordenada`,checklist:`Lista de verificación`,indent:`Aumentar sangría`,outdent:`Reducir sangría`,undo:`Deshacer (Ctrl+Z)`,redo:`Rehacer (Ctrl+Y)`,hr:`Línea horizontal`,link:`Insertar enlace`,image:`Insertar imagen`,video:`Insertar vídeo`,emoji:`Insertar emoji`,icon:`Insertar icono FA`,table:`Insertar tabla`,fontSize:`Tamaño de fuente`,fontSizePlaceholder:`Tamaño`,removeFormat:`Eliminar formato`,direction:`Cambiar dirección del texto (LTR / RTL)`,fontFamily:`Fuente`,paragraphStyle:`Estilo de párrafo`,paragraphStylePlaceholder:`Estilo`,lineHeight:`Interlineado`,lineHeightPlaceholder:`↕ Línea`,codeview:`Vista de código HTML`,fullscreen:`Pantalla completa`,shortcuts:`Atajos de teclado (Ctrl+Shift+/)`,find:`Buscar (Ctrl+F)`,findReplace:`Buscar y reemplazar (Ctrl+H)`,inlineCode:"Código en línea (Ctrl+`)",print:`Imprimir`,foreColor:`Color del texto`,backColor:`Color de resaltado`,chooseTextColor:`Elegir color del texto`,chooseHighlightColor:`Elegir color de resaltado`,customColor:`Color personalizado`,insertTableLabel:`Insertar tabla`,paragraphItems:{p:`Normal`,blockquote:`Cita`,pre:`Código`}},linkDialog:{ariaLabel:`Insertar enlace`,title:`Insertar enlace`,url:`URL`,urlPlaceholder:`https://`,displayText:`Texto a mostrar`,textPlaceholder:`Texto del enlace`,openInNewTab:`Abrir en nueva pestaña`,insertBtn:`Insertar`,cancelBtn:`Cancelar`},imageDialog:{ariaLabel:`Insertar imagen`,title:`Insertar imagen`,imageUrl:`URL de imagen`,urlPlaceholder:`https://example.com/image.png`,altText:`Texto alternativo`,altPlaceholder:`Describir la imagen`,alignment:`Alineación`,alignNone:`Ninguna`,alignLeft:`Izquierda`,alignCenter:`Centro`,alignRight:`Derecha`,uploadLabel:`O subir un archivo`,insertBtn:`Insertar`,cancelBtn:`Cancelar`},videoDialog:{ariaLabel:`Insertar vídeo`,title:`Insertar vídeo`,videoUrl:`URL del vídeo`,urlPlaceholder:`YouTube, Vimeo o URL directa .mp4`,widthLabel:`Ancho (px)`,widthPlaceholder:`560`,insertBtn:`Insertar`,cancelBtn:`Cancelar`,detected:e=>`Detectado: ${e}`,unknownFormat:`Formato desconocido — se intentará incrustar el vídeo directamente`,invalidUrl:`URL no válida — introduzca un enlace de vídeo válido.`},emojiDialog:{ariaLabel:`Insertar emoji`,title:`Insertar emoji`,searchPlaceholder:`Buscar emojis…`,all:`Todos`,cancelBtn:`Cancelar`,close:`Cerrar`,categories:{smileys:`Caritas`,people:`Personas`,animals:`Animales`,food:`Comida`,travel:`Viajes`,objects:`Objetos`,symbols:`Símbolos`}},iconDialog:{ariaLabel:`Insertar icono FA`,title:`Insertar icono FA`,searchPlaceholder:`Buscar iconos…`,all:`Todos`,style:`Estilo`,size:`Tamaño`,color:`Color`,useColor:` Usar color`,selectHint:`Seleccionar un icono`,insertBtn:`Insertar icono FA`,cancelBtn:`Cancelar`,close:`Cerrar`,categories:{popular:`Popular`,interface:`Interfaz`,navigation:`Navegación`,media:`Medios`,communication:`Comunicación`,files:`Archivos`,people:`Personas`,objects:`Objetos`}},findReplace:{findTitle:`Buscar`,findReplaceTitle:`Buscar y reemplazar`,findPlaceholder:`Buscar…`,searchAriaLabel:`Texto de búsqueda`,caseSensitive:`\xA0Distinguir mayúsculas`,wholeWord:`Palabra completa`,prevBtn:`← Anterior`,nextBtn:`Siguiente →`,replacePlaceholder:`Reemplazar con…`,replaceAriaLabel:`Reemplazar con`,replaceBtn:`Reemplazar`,noResults:`Sin resultados`,useRegex:`Usar expresión regular`,prevMatch:`Anterior (Mayús+Intro)`,nextMatch:`Siguiente (Intro)`,replaceAllBtn:`Reemplazar todo`,close:`×`},shortcutsDialog:{title:`Atajos de teclado`,ariaLabel:`Atajos de teclado`,close:`Cerrar`,customCategory:`Personalizados`,shortcuts:[{category:`Formato de texto`,items:[{keys:`Ctrl + B`,action:`Negrita`},{keys:`Ctrl + I`,action:`Cursiva`},{keys:`Ctrl + U`,action:`Subrayado`},{keys:`Ctrl + K`,action:`Insertar / editar enlace`}]},{category:`Historial`,items:[{keys:`Ctrl + Z`,action:`Deshacer`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Rehacer`}]},{category:`Selección y navegación`,items:[{keys:`Ctrl + A`,action:`Seleccionar todo`},{keys:`Tab`,action:`Aumentar sangría / insertar espacios`},{keys:`Shift + Tab`,action:`Reducir sangría`}]},{category:`Portapapeles`,items:[{keys:`Ctrl + Shift + V`,action:`Pegar como texto plano`}]},{category:`Buscar y reemplazar`,items:[{keys:`Ctrl + F`,action:`Buscar en el documento`},{keys:`Ctrl + H`,action:`Buscar y reemplazar`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Mostrar este diálogo de atajos`}]}]},contextMenu:{cut:`Cortar`,copy:`Copiar`,paste:`Pegar`,bold:`Negrita`,italic:`Cursiva`,underline:`Subrayado`,textColor:`Color del texto`,highlightColor:`Color de resaltado`,copyFormat:`Copiar formato`,pasteFormat:`Pegar formato`,removeFormat:`Eliminar formato`,link:`Insertar enlace`,image:`Insertar imagen`,video:`Insertar vídeo`,table:`Insertar tabla`,back:`Atrás`,noHighlight:`Sin resaltado`,customColor:`Color personalizado`,customColorLabel:`Personalizado…`},statusbar:{resizeHandle:`Redimensionar editor`,words:e=>`Palabras: ${e}`,wordsLimit:(e,t)=>`Palabras: ${e}/${t}`,chars:e=>`Caracteres: ${e}`,charsLimit:(e,t)=>`Caracteres: ${e}/${t}`},a11y:{editor:`Editor de texto enriquecido`,toolbar:`Barra de herramientas del editor`,statistics:`Estadísticas del editor`,tableSize:`Seleccionar tamaño de tabla`},tooltips:{link:{ariaLabel:`Acciones de enlace`,openLink:`Abrir enlace`,copyUrl:`Copiar URL`,editLink:`Editar enlace`,removeLink:`Eliminar enlace`},image:{ariaLabel:`Acciones de imagen`,label:`Imagen`,floatLeft:`Flotar a la izquierda`,noFloat:`Sin flotado`,alignCenter:`Centrar`,floatRight:`Flotar a la derecha`,originalSize:`Tamaño original`,rotateLeft:`Rotar a la izquierda`,rotateRight:`Rotar a la derecha`,cropImage:`Recortar imagen`,addCaption:`Añadir / editar pie de foto`,deleteImage:`Eliminar imagen`},code:{ariaLabel:`Acciones de bloque de código`,label:`Código`,syntaxLanguage:`Lenguaje de sintaxis`,syntaxAriaLabel:`Lenguaje de sintaxis`,copyCode:`Copiar código`,toggleWordWrap:`Alternar ajuste de línea`,enableWordWrap:`Activar ajuste de línea`,disableWordWrap:`Desactivar ajuste de línea`,convertToParagraph:`Convertir en párrafo`,deleteCodeBlock:`Eliminar bloque de código`,lineNumbers:`Alternar números de línea`},table:{ariaLabel:`Acciones de tabla`,label:`Tabla`,selectCells:`Seleccionar celdas`,addRowAbove:`Añadir fila encima`,addRowBelow:`Añadir fila debajo`,deleteRow:`Eliminar fila`,addColumnLeft:`Añadir columna a la izquierda`,addColumnRight:`Añadir columna a la derecha`,deleteColumn:`Eliminar columna`,mergeCells:`Combinar celdas`,unmergeCells:`Separar celdas`,columnWidth:`Ancho de columna`,rowHeight:`Alto de fila`,tableBorderWidth:`Grosor del borde de la tabla`,tableBorderColor:`Color del borde de la tabla`,deleteTable:`Eliminar tabla`,cellAlignLeft:`Alinear a la izquierda`,cellAlignCenter:`Centrar`,cellAlignRight:`Alinear a la derecha`,cellAlignJustify:`Justificar`,toggleHeaderRow:`Activar fila de encabezado`,cellBackground:`Fondo de celda`,noShading:`Sin fondo`,noBorderColor:`Sin color de borde`,columnWidthPx:`Ancho de columna (px)`,rowHeightPx:`Alto de fila (px)`,tableBorderWidthPx:`Grosor del borde (px)`,cancelBtn:`Cancelar`,applyBtn:`Aplicar`,sortAsc:`Ordenar ascendente`,sortDesc:`Ordenar descendente`,exportCSV:`Exportar como CSV`,cellPadding:`Relleno de celda`,cellPaddingPx:`Relleno de celda (px)`},video:{ariaLabel:`Acciones de vídeo`,label:`Vídeo`,floatLeft:`Flotar a la izquierda`,noFloat:`Sin flotado`,alignCenter:`Centrar`,floatRight:`Flotar a la derecha`,originalSize:`Tamaño original`,previewVideo:`Vista previa de vídeo`,exitPreview:`Salir de la vista previa`,deleteVideo:`Eliminar vídeo`}},errors:{imageFormat:e=>`El formato "${e}" no es compatible con los navegadores web. Por favor, conviértalo primero a JPEG, PNG o WebP.`,imageSize:e=>`El archivo de imagen es demasiado grande. El tamaño máximo permitido es ${e} MB.`},autoSaveRestore:{found:`Borrador encontrado. ¿Restaurar?`,foundAt:`Borrador del {date}. ¿Restaurar?`,restore:`Restaurar`,discard:`Descartar`},slashMenu:{noResults:`No hay comandos coincidentes`,heading1:`Encabezado 1`,heading2:`Encabezado 2`,heading3:`Encabezado 3`,bulletList:`Lista con viñetas`,numberedList:`Lista numerada`,checklist:`Lista de verificación`,blockquote:`Cita`,codeBlock:`Bloque de código`,horizontalRule:`Línea horizontal`,table:`Tabla`,image:`Imagen`}}),c(`ko`,{toolbar:{bold:`굵게 (Ctrl+B)`,italic:`기울임꼴 (Ctrl+I)`,underline:`밑줄 (Ctrl+U)`,strikethrough:`취소선`,superscript:`위 첨자`,subscript:`아래 첨자`,alignLeft:`왼쪽 정렬`,alignCenter:`가운데 정렬`,alignRight:`오른쪽 정렬`,alignJustify:`양쪽 정렬`,ul:`순서 없는 목록`,ol:`순서 있는 목록`,checklist:`체크리스트`,indent:`들여쓰기`,outdent:`내어쓰기`,undo:`실행 취소 (Ctrl+Z)`,redo:`다시 실행 (Ctrl+Y)`,hr:`수평선`,link:`링크 삽입`,image:`이미지 삽입`,video:`동영상 삽입`,emoji:`이모지 삽입`,icon:`FA 아이콘 삽입`,table:`표 삽입`,fontSize:`글꼴 크기`,fontSizePlaceholder:`크기`,removeFormat:`서식 제거`,direction:`텍스트 방향 전환 (LTR / RTL)`,fontFamily:`글꼴`,paragraphStyle:`단락 스타일`,paragraphStylePlaceholder:`스타일`,lineHeight:`줄 간격`,lineHeightPlaceholder:`↕ 줄`,codeview:`HTML 코드 보기`,fullscreen:`전체 화면`,shortcuts:`키보드 단축키 (Ctrl+Shift+/)`,find:`찾기 (Ctrl+F)`,findReplace:`찾기 및 바꾸기 (Ctrl+H)`,inlineCode:"인라인 코드 (Ctrl+`)",print:`인쇄`,foreColor:`글자 색`,backColor:`강조 색`,chooseTextColor:`글자 색 선택`,chooseHighlightColor:`강조 색 선택`,customColor:`사용자 지정 색`,insertTableLabel:`표 삽입`,paragraphItems:{p:`기본`,blockquote:`인용`,pre:`코드`}},linkDialog:{ariaLabel:`링크 삽입`,title:`링크 삽입`,url:`URL`,urlPlaceholder:`https://`,displayText:`표시 텍스트`,textPlaceholder:`링크 텍스트`,openInNewTab:`새 탭에서 열기`,insertBtn:`삽입`,cancelBtn:`취소`},imageDialog:{ariaLabel:`이미지 삽입`,title:`이미지 삽입`,imageUrl:`이미지 URL`,urlPlaceholder:`https://example.com/image.png`,altText:`대체 텍스트`,altPlaceholder:`이미지 설명`,alignment:`정렬`,alignNone:`없음`,alignLeft:`왼쪽`,alignCenter:`가운데`,alignRight:`오른쪽`,uploadLabel:`또는 파일 업로드`,insertBtn:`삽입`,cancelBtn:`취소`},videoDialog:{ariaLabel:`동영상 삽입`,title:`동영상 삽입`,videoUrl:`동영상 URL`,urlPlaceholder:`YouTube, Vimeo 또는 직접 .mp4 URL`,widthLabel:`너비 (px)`,widthPlaceholder:`560`,insertBtn:`삽입`,cancelBtn:`취소`,detected:e=>`감지됨: ${e}`,unknownFormat:`알 수 없는 형식 — 직접 동영상 임베드를 시도합니다`,invalidUrl:`유효하지 않은 URL — 올바른 동영상 링크를 입력하세요.`},emojiDialog:{ariaLabel:`이모지 삽입`,title:`이모지 삽입`,searchPlaceholder:`이모지 검색…`,all:`전체`,cancelBtn:`취소`,close:`닫기`,categories:{smileys:`스마일`,people:`사람`,animals:`동물`,food:`음식`,travel:`여행`,objects:`사물`,symbols:`기호`}},iconDialog:{ariaLabel:`FA 아이콘 삽입`,title:`FA 아이콘 삽입`,searchPlaceholder:`아이콘 검색…`,all:`전체`,style:`스타일`,size:`크기`,color:`색상`,useColor:` 색상 사용`,selectHint:`아이콘을 선택하세요`,insertBtn:`FA 아이콘 삽입`,cancelBtn:`취소`,close:`닫기`,categories:{popular:`인기`,interface:`인터페이스`,navigation:`탐색`,media:`미디어`,communication:`커뮤니케이션`,files:`파일`,people:`사람`,objects:`사물`}},findReplace:{findTitle:`찾기`,findReplaceTitle:`찾기 및 바꾸기`,findPlaceholder:`찾기…`,searchAriaLabel:`검색 텍스트`,caseSensitive:`\xA0대소문자 구분`,wholeWord:`전체 단어`,prevBtn:`← 이전`,nextBtn:`다음 →`,replacePlaceholder:`바꿀 내용…`,replaceAriaLabel:`바꿀 내용`,replaceBtn:`바꾸기`,noResults:`결과 없음`,useRegex:`정규식 사용`,prevMatch:`이전 (Shift+Enter)`,nextMatch:`다음 (Enter)`,replaceAllBtn:`모두 바꾸기`,close:`×`},shortcutsDialog:{title:`키보드 단축키`,ariaLabel:`키보드 단축키`,close:`닫기`,customCategory:`사용자 지정`,shortcuts:[{category:`텍스트 서식`,items:[{keys:`Ctrl + B`,action:`굵게`},{keys:`Ctrl + I`,action:`기울임꼴`},{keys:`Ctrl + U`,action:`밑줄`},{keys:`Ctrl + K`,action:`링크 삽입 / 편집`}]},{category:`실행 기록`,items:[{keys:`Ctrl + Z`,action:`실행 취소`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`다시 실행`}]},{category:`선택 및 탐색`,items:[{keys:`Ctrl + A`,action:`전체 선택`},{keys:`Tab`,action:`목록 들여쓰기 / 공백 삽입`},{keys:`Shift + Tab`,action:`목록 내어쓰기`}]},{category:`클립보드`,items:[{keys:`Ctrl + Shift + V`,action:`일반 텍스트로 붙여넣기`}]},{category:`찾기 및 바꾸기`,items:[{keys:`Ctrl + F`,action:`문서에서 찾기`},{keys:`Ctrl + H`,action:`찾기 및 바꾸기`}]},{category:`편집기`,items:[{keys:`Ctrl + Shift + /`,action:`이 단축키 대화상자 표시`}]}]},contextMenu:{cut:`잘라내기`,copy:`복사`,paste:`붙여넣기`,bold:`굵게`,italic:`기울임꼴`,underline:`밑줄`,textColor:`글자 색`,highlightColor:`강조 색`,copyFormat:`서식 복사`,pasteFormat:`서식 붙여넣기`,removeFormat:`서식 제거`,link:`링크 삽입`,image:`이미지 삽입`,video:`동영상 삽입`,table:`표 삽입`,back:`뒤로`,noHighlight:`강조 없음`,customColor:`사용자 지정 색`,customColorLabel:`사용자 지정…`},statusbar:{resizeHandle:`편집기 크기 조정`,words:e=>`단어: ${e}`,wordsLimit:(e,t)=>`단어: ${e}/${t}`,chars:e=>`글자: ${e}`,charsLimit:(e,t)=>`글자: ${e}/${t}`},a11y:{editor:`서식 있는 텍스트 편집기`,toolbar:`편집기 도구 모음`,statistics:`편집기 통계`,tableSize:`표 크기 선택`},tooltips:{link:{ariaLabel:`링크 작업`,openLink:`링크 열기`,copyUrl:`URL 복사`,editLink:`링크 편집`,removeLink:`링크 제거`},image:{ariaLabel:`이미지 작업`,label:`이미지`,floatLeft:`왼쪽 배치`,noFloat:`배치 없음`,alignCenter:`가운데 정렬`,floatRight:`오른쪽 배치`,originalSize:`원본 크기`,rotateLeft:`왼쪽 회전`,rotateRight:`오른쪽 회전`,cropImage:`이미지 자르기`,addCaption:`캡션 추가 / 편집`,deleteImage:`이미지 삭제`},code:{ariaLabel:`코드 블록 작업`,label:`코드`,syntaxLanguage:`구문 언어`,syntaxAriaLabel:`구문 언어`,copyCode:`코드 복사`,toggleWordWrap:`줄 바꿈 전환`,enableWordWrap:`줄 바꿈 사용`,disableWordWrap:`줄 바꿈 해제`,convertToParagraph:`단락으로 변환`,deleteCodeBlock:`코드 블록 삭제`,lineNumbers:`줄 번호 전환`},table:{ariaLabel:`표 작업`,label:`표`,selectCells:`셀 선택`,addRowAbove:`위에 행 추가`,addRowBelow:`아래에 행 추가`,deleteRow:`행 삭제`,addColumnLeft:`왼쪽에 열 추가`,addColumnRight:`오른쪽에 열 추가`,deleteColumn:`열 삭제`,mergeCells:`셀 병합`,unmergeCells:`셀 분할`,columnWidth:`열 너비`,rowHeight:`행 높이`,tableBorderWidth:`표 테두리 너비`,tableBorderColor:`표 테두리 색상`,deleteTable:`표 삭제`,cellAlignLeft:`왼쪽 정렬`,cellAlignCenter:`가운데 정렬`,cellAlignRight:`오른쪽 정렬`,cellAlignJustify:`양쪽 정렬`,toggleHeaderRow:`머리글 행 전환`,cellBackground:`셀 배경색`,noShading:`배경 없음`,noBorderColor:`테두리 색 없음`,columnWidthPx:`열 너비 (px)`,rowHeightPx:`행 높이 (px)`,tableBorderWidthPx:`표 테두리 너비 (px)`,cancelBtn:`취소`,applyBtn:`적용`,sortAsc:`오름차순 정렬`,sortDesc:`내림차순 정렬`,exportCSV:`CSV로 내보내기`,cellPadding:`셀 패딩`,cellPaddingPx:`셀 패딩 (px)`},video:{ariaLabel:`동영상 작업`,label:`동영상`,floatLeft:`왼쪽 배치`,noFloat:`배치 없음`,alignCenter:`가운데 정렬`,floatRight:`오른쪽 배치`,originalSize:`원본 크기`,previewVideo:`동영상 미리보기`,exitPreview:`미리보기 종료`,deleteVideo:`동영상 삭제`}},errors:{imageFormat:e=>`"${e}" 형식은 웹 브라우저에서 지원되지 않습니다. JPEG, PNG 또는 WebP로 변환해 주세요.`,imageSize:e=>`이미지 파일이 너무 큽니다. 최대 허용 크기는 ${e} MB입니다.`},autoSaveRestore:{found:`초안을 찾았습니다. 복원하시겠습니까?`,foundAt:`{date}의 초안을 찾았습니다. 복원하시겠습니까?`,restore:`복원`,discard:`삭제`},slashMenu:{noResults:`일치하는 명령이 없습니다`,heading1:`제목 1`,heading2:`제목 2`,heading3:`제목 3`,bulletList:`글머리 기호 목록`,numberedList:`번호 매기기 목록`,checklist:`체크리스트`,blockquote:`인용문`,codeBlock:`코드 블록`,horizontalRule:`가로선`,table:`표`,image:`이미지`}});var u=e=>e?.nodeType===1,d=e=>u(e)&&/^(p|div|li|h[1-6]|blockquote|td|th|pre)$/i.test(e.nodeName),f=e=>u(e)&&/^(li)$/i.test(e.nodeName);function p(e,t,n){let r=e;for(;r&&r!==n;){if(t(r))return r;r=r.parentNode}return null}function m(e,t){return p(e,d,t)}function h(e,t={},n=[]){let r=document.createElement(e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);for(let e of n)typeof e==`string`?r.appendChild(document.createTextNode(e)):r.appendChild(e);return r}function g(e){let t=document.createRange();t.selectNodeContents(e),t.collapse(!1);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function _(e){if(e?.querySelectorAll)for(let t of e.querySelectorAll(`ul > ul, ul > ol, ol > ul, ol > ol`)){let e=t.previousElementSibling;if(e&&e.nodeName===`LI`)e.appendChild(t);else if(t.parentNode){let e=t.ownerDocument.createElement(`li`);t.parentNode.insertBefore(e,t),e.appendChild(t)}}}function v(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function y(e,t){let n=()=>Array.from(e.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.closest(`[style*="display: none"]`)&&!e.closest(`[style*="display:none"]`)),r=e=>{if(e.key===`Escape`){e.stopPropagation(),t?.();return}if(e.key!==`Tab`)return;let r=n();if(!r.length)return;let i=r[0],a=r.at(-1);e.shiftKey?document.activeElement===i&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),i.focus())};return document.addEventListener(`keydown`,r),()=>document.removeEventListener(`keydown`,r)}function ee(e,t){e.style.cursor=`grab`;let n=n=>{if(n.button!==0||n.target.closest(`button, input, select, textarea, a`))return;if(n.preventDefault(),!t.dataset.anDragPinned){let e=t.getBoundingClientRect();t.style.position=`fixed`,t.style.margin=`0`,t.style.left=`${e.left}px`,t.style.top=`${e.top}px`,t.dataset.anDragPinned=`1`}let r=n.clientX-Number.parseFloat(t.style.left),i=n.clientY-Number.parseFloat(t.style.top);e.style.cursor=`grabbing`;let a=e=>{let n=t.offsetWidth,a=t.offsetHeight;t.style.left=`${Math.max(0,Math.min(e.clientX-r,globalThis.innerWidth-n))}px`,t.style.top=`${Math.max(0,Math.min(e.clientY-i,globalThis.innerHeight-a))}px`},o=()=>{e.style.cursor=`grab`,document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o)};document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o)};return e.addEventListener(`mousedown`,n),()=>e.removeEventListener(`mousedown`,n)}function b(e){return e?.layoutInfo?.portal||document.body}var x=class{constructor(e,t,n,r){this.sc=e,this.so=t,this.ec=n,this.eo=r}isCollapsed(){return this.sc===this.ec&&this.so===this.eo}toNativeRange(){let e=document.createRange();try{e.setStart(this.sc,this.so),e.setEnd(this.ec,this.eo)}catch{}return e}select(){let e=globalThis.getSelection();e&&(e.removeAllRanges(),e.addRange(this.toNativeRange()))}commonAncestor(){let e=this.toNativeRange().commonAncestorContainer;return u(e)?e:e.parentElement}blockNode(e){return p(this.sc,t=>u(t)&&t!==e,e)}toString(){return this.toNativeRange().toString()}getClientRects(){let e=this.toNativeRange().getClientRects();return e.length>0?e[e.length-1]:null}insertNode(e){this.toNativeRange().insertNode(e)}};function S(e){return new x(e.startContainer,e.startOffset,e.endContainer,e.endOffset)}function C(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return null;let n=t.getRangeAt(0);return e&&!e.contains(n.commonAncestorContainer)?null:S(n)}function te(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0){e(null);return}let n=t.getRangeAt(0).cloneRange();e(S(n)),t.removeAllRanges(),t.addRange(n)}function ne(e){let t=e&&e.nodeType===1?e:e?.parentElement;for(;t;){let e=t.getAttribute?.(`contenteditable`)??t.contentEditable;if(e===`false`)return null;if(e!=null&&e!==`inherit`)return t;t=t.parentElement}return null}function w(e){let t=globalThis.getSelection?.();if(!t||t.rangeCount===0)return null;let n=t.getRangeAt(0);return e&&e!==document?e.contains(n.commonAncestorContainer)?n:null:ne(n.commonAncestorContainer)?n:null}function re(e){let t=globalThis.getSelection?.();if(!t)return;let n=document.createRange();n.setStartAfter(e),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}function ie(e,t){let n=w(t);if(!n)return!1;let r=document.createElement(`template`);r.innerHTML=e;let i=r.content,a=i.lastChild;return n.deleteContents(),n.insertNode(i),a&&re(a),!0}function ae(e,t){let n=w(t);if(!n)return!1;n.deleteContents();let r=String(e),i=document.createDocumentFragment();!r.includes(`
2
+ `)||T(n.startContainer,t)?i.appendChild(document.createTextNode(r)):r.split(`
3
+ `).forEach((e,t)=>{t>0&&i.appendChild(document.createElement(`br`)),e&&i.appendChild(document.createTextNode(e))});let a=i.lastChild;return n.insertNode(i),a&&re(a),!0}function oe(e){return ae(`
4
+ `,e)}function T(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n&&n!==t;){if(n.tagName===`PRE`||n.tagName===`TEXTAREA`)return!0;let e=globalThis.getComputedStyle?.(n)?.whiteSpace;if(e&&e.startsWith(`pre`))return!0;n=n.parentElement}return!1}function se(e){let t=w(e);if(!t)return!1;let n=document.createElement(`hr`);t.deleteContents();let r=le(t.startContainer,e);r&&r.parentNode?r.parentNode.insertBefore(n,r.nextSibling):t.insertNode(n);let i=n.nextElementSibling;if(!i||i.tagName===`HR`){let e=document.createElement(`p`);e.appendChild(document.createElement(`br`)),n.parentNode?.insertBefore(e,n.nextSibling),i=e}let a=globalThis.getSelection?.();if(a){let e=document.createRange();e.setStart(i,0),e.collapse(!0),a.removeAllRanges(),a.addRange(e)}return!0}var ce=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`PRE`,`LI`]);function le(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n&&n!==t;){if(ce.has(n.tagName))return n;n=n.parentElement}return null}var ue=new Set(`ADDRESS.ARTICLE.ASIDE.BLOCKQUOTE.CAPTION.DD.DETAILS.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.H1.H2.H3.H4.H5.H6.HEADER.HR.LI.MAIN.NAV.OL.P.PRE.SECTION.SUMMARY.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL`.split(`.`)),de=new Set([`A`,`B`,`BIG`,`CITE`,`CODE`,`DFN`,`EM`,`FONT`,`I`,`INS`,`KBD`,`MARK`,`Q`,`S`,`SAMP`,`SMALL`,`SPAN`,`STRIKE`,`STRONG`,`SUB`,`SUP`,`TT`,`U`,`VAR`,`DEL`]),fe=new Set([`B`,`BIG`,`CITE`,`CODE`,`DEL`,`DFN`,`EM`,`FONT`,`I`,`INS`,`KBD`,`MARK`,`Q`,`S`,`SAMP`,`SMALL`,`SPAN`,`STRIKE`,`STRONG`,`SUB`,`SUP`,`TT`,`U`,`VAR`]),pe=new Set([`IMG`,`BR`,`INPUT`,`IFRAME`,`VIDEO`,`AUDIO`,`CANVAS`,`SVG`,`svg`]),me=`​`,E=e=>!!e&&e.nodeType===1,D=e=>E(e)&&ue.has(e.nodeName),he=e=>!e.hasChildNodes()||e.getAttribute(`contenteditable`)===`false`;function O(e){let t=0;for(let n=e.previousSibling;n;n=n.previousSibling)t++;return t}function ge(e,t){let n=E(e)?e:e.parentElement;for(;n&&n!==t;){if(ue.has(n.nodeName))return n;n=n.parentElement}return t}function _e(e,t){for(let n=E(e)?e:e.parentElement;n&&n!==t;n=n.parentElement)if(n.getAttribute(`contenteditable`)===`false`)return!0;return!1}function ve(e,t,n){let r=document.createRange();r.selectNodeContents(e);try{r.setEnd(t,n)}catch{return 0}return r.toString().length}function ye(e,t,n){let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=0,a=null,o;for(;o=r.nextNode();){let e=o.length;if(n?t<i+e:t<=i+e)return[o,t-i];i+=e,a=o}return a?[a,a.length]:null}function k(e,t){return{start:ve(e,t.startContainer,t.startOffset),end:ve(e,t.endContainer,t.endOffset)}}function A(e,t){let n=t.start===t.end,r=ye(e,t.start,!n),i=n?r:ye(e,t.end,!1);if(!r||!i)return;let a=document.createRange();try{a.setStart(r[0],r[1]),a.setEnd(i[0],i[1])}catch{return}be(a)}function be(e){let t=globalThis.getSelection?.();t&&(t.removeAllRanges(),t.addRange(e))}function xe(e,t){let n=document.createRange();n.setStart(e,t),n.collapse(!0),be(n)}function Se(e,t){if(!t.length||t===e.startContainer&&e.startOffset>=t.length||t===e.endContainer&&e.endOffset===0)return!1;try{return e.intersectsNode(t)}catch{return!1}}function Ce(e,t){let n=t.parentNode;if(!n)return!1;let r=O(t);try{return e.comparePoint(n,r)>=0&&e.comparePoint(n,r+1)<=0}catch{return!1}}function we(e,t){let n=e.commonAncestorContainer;if(n.nodeType===3)return Se(e,n)&&!_e(n,t)?[n]:[];let r=[],i=document.createTreeWalker(n,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();)a.nodeType===3?Se(e,a)&&!_e(a,t)&&r.push(a):pe.has(a.nodeName)&&Ce(e,a)&&!_e(a,t)&&r.push(a);return r}function Te(e,t){let n=we(e,t),r=[],i=null;for(let e of n){let n=ge(e,t);!i||i.block!==n?(i={block:n,first:e,last:e},r.push(i)):i.last=e}let{startContainer:a,startOffset:o,endContainer:s,endOffset:c}=e;return r.map(({block:e,first:t,last:n})=>({block:e,start:()=>t===a&&t.nodeType===3?[t,o]:[t.parentNode,O(t)],end:()=>n===s&&n.nodeType===3?[n,c]:[n.parentNode,O(n)+1]}))}function Ee(e,t,n){let r,i;if(e.nodeType===3){let n=e;r=n.parentNode,i=t<=0?O(n):t>=n.length?O(n)+1:O(n.splitText(t))}else r=e,i=t;for(;r&&r!==n;){let e=r.parentNode,t=O(r);if(i<=0)i=t;else if(i>=r.childNodes.length)i=t+1;else{let n=r.cloneNode(!1);for(n.removeAttribute(`id`);r.childNodes.length>i;)n.appendChild(r.childNodes[i]);e.insertBefore(n,r.nextSibling),i=t+1}r=e}return i}function De(e,t,n){let r=Ee(n[0],n[1],e),i=e.childNodes[r]||null,a=Ee(t[0],t[1],e),o=[];for(let t=e.childNodes[a];t&&t!==i;t=t.nextSibling)o.push(t);return o}function Oe(e,t){if(e.nodeName!==t.nodeName||e.attributes.length!==t.attributes.length)return!1;for(let n of e.attributes)if(t.getAttribute(n.name)!==n.value)return!1;return!0}function ke(e){let t=e.firstChild;for(;t;){let e=t.nextSibling;if(E(t)&&de.has(t.nodeName)&&!t.hasChildNodes()&&t.attributes.length===0){t.remove(),t=e;continue}if(E(t)&&E(e)&&de.has(t.nodeName)&&Oe(t,e)&&!he(t)&&!he(e)){for(;e.firstChild;)t.appendChild(e.firstChild);e.remove();continue}E(t)&&!D(t)&&ke(t),t=e}}function j(e){let t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}function Ae(e,t){let n=[],r=null;for(let i of e){if(D(i)){r=null;continue}r||(r=t(),i.parentNode.insertBefore(r,i),n.push(r)),r.appendChild(i)}return n}function je(e,t,n){let r=k(e,t),i=Te(t,e),a=new Set;for(let e of i){let t=De(e.block,e.start(),e.end());for(let e of Ae(t,()=>document.createElement(`span`)))n(e),j(e);a.add(e.block)}return a.forEach(e=>{ke(e),e.normalize()}),A(e,r),i.length>0}function Me(e,t){let n=(e.style.textDecorationLine||e.style.textDecoration||``).split(/\s+/).filter(e=>e&&e!==t&&e!==`none`);e.style.removeProperty(`text-decoration`),e.style.removeProperty(`text-decoration-line`),n.length&&(e.style.textDecorationLine=n.join(` `))}var Ne=(e,t)=>(e.textDecorationLine||e.textDecoration||``).split(/\s+/).includes(t),Pe={bold:{tag:`b`,tags:new Set([`B`,`STRONG`]),styled:e=>/^(bold|bolder|[6-9]00)$/.test(e.fontWeight),unstyle:e=>e.style.removeProperty(`font-weight`)},italic:{tag:`i`,tags:new Set([`I`,`EM`]),styled:e=>e.fontStyle===`italic`||e.fontStyle===`oblique`,unstyle:e=>e.style.removeProperty(`font-style`)},underline:{tag:`u`,tags:new Set([`U`,`INS`]),styled:e=>Ne(e,`underline`),unstyle:e=>Me(e,`underline`)},strikethrough:{tag:`s`,tags:new Set([`S`,`STRIKE`,`DEL`]),styled:e=>Ne(e,`line-through`),unstyle:e=>Me(e,`line-through`)},superscript:{tag:`sup`,tags:new Set([`SUP`]),styled:e=>e.verticalAlign===`super`,unstyle:e=>e.style.removeProperty(`vertical-align`),excludes:`subscript`},subscript:{tag:`sub`,tags:new Set([`SUB`]),styled:e=>e.verticalAlign===`sub`,unstyle:e=>e.style.removeProperty(`vertical-align`),excludes:`superscript`}};function Fe(e,t){if(!E(e))return!1;if(t.tags.has(e.nodeName))return!0;let n=e.style;return!!n&&t.styled(n)}function Ie(e,t,n){for(let r=E(e)?e:e.parentElement;r&&r!==n;r=r.parentElement)if(Fe(r,t))return!0;return!1}function Le(e,t){let n=[...e.querySelectorAll(`*`)].filter(e=>Fe(e,t)).reverse();for(let e of n)Re(e,t)}function Re(e,t){if(!he(e)){if(t.tags.has(e.nodeName)){if(e.getAttribute(`style`)){let n=document.createElement(`span`);for(n.setAttribute(`style`,e.getAttribute(`style`)),e.parentNode.insertBefore(n,e);e.firstChild;)n.appendChild(e.firstChild);e.remove(),t.styled(n.style)&&t.unstyle(n);return}j(e);return}t.unstyle(e),e.getAttribute(`style`)||e.removeAttribute(`style`),(e.nodeName===`SPAN`||e.nodeName===`FONT`)&&e.attributes.length===0&&j(e)}}function ze(e,t){let n=Pe[e],r=w(t);if(!n||!r)return!1;let i=M(r,t);if(!i)return!1;if(r.collapsed)return Ie(r.startContainer,n,i);let a=we(r,i).filter(e=>e.nodeType===3&&/[^\s\u200B]/.test(e.data));return a.length?a.every(e=>Ie(e,n,i)):Ie(r.startContainer,n,i)}function M(e,t){return t&&t!==document?t:ne(e.commonAncestorContainer)}function N(e,t,n){let r=Pe[e],i=w(n);if(!r||!i)return!1;let a=M(i,n);if(!a)return!1;let o=t??!ze(e,n);if(i.collapsed){if(o){if(Ie(i.startContainer,r,a))return!0;Be(i,()=>document.createElement(r.tag),r.excludes?Pe[r.excludes]:null,a)}else We(i,r,a);return!0}let s=r.excludes?Pe[r.excludes]:null;return je(a,i,e=>{if(Le(e,r),s&&o&&Le(e,s),!o)return;let t=document.createElement(r.tag);for(;e.firstChild;)t.appendChild(e.firstChild);e.appendChild(t)})}function Be(e,t,n,r){let i=t(),a=e.startContainer;if(a.nodeType===3&&a.data===me?(a.parentNode.insertBefore(i,a),i.appendChild(a)):(i.appendChild(document.createTextNode(me)),e.insertNode(i)),n){let e=He(i,n,r);e&&Ue(i.firstChild,e,n)}let o=i.ownerDocument.contains(i)?Ve(i):null;o&&xe(o,o.length)}function Ve(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n,r=null;for(;n=t.nextNode();)r=n;return r}function He(e,t,n){let r=null;for(let i=E(e)?e:e.parentElement;i&&i!==n&&!D(i);i=i.parentElement)Fe(i,t)&&(r=i);return r}function Ue(e,t,n){let r=t.parentNode,i=De(r,[e.parentNode,O(e)],[e.parentNode,O(e)+1]);for(let e of i)E(e)&&(Le(e,n),Fe(e,n)&&Re(e,n));ke(r)}function We(e,t,n){let r=e.startContainer;(r.nodeType!==3||r.data!==me)&&(r=document.createTextNode(me),e.insertNode(r));let i=He(r,t,n);i&&Ue(r,i,t),r.parentNode&&xe(r,1)}function Ge(e){let t=w(e);if(!t||!t.collapsed||t.startContainer.nodeType!==3)return;let n=t.startContainer,r=n.data.indexOf(me);if(r===-1||n.data.length<2)return;let i=t.startOffset;n.deleteData(r,1),xe(n,i>r?i-1:i)}var Ke={color:`color`,"font-family":`face`,"font-size":`size`};function P(e,t,n){let r=w(n);if(!r)return!1;let i=M(r,n);if(!i)return!1;let a=()=>{let n=document.createElement(`span`);return n.style.setProperty(e,t),n};return r.collapsed?(Be(r,a,null,i),!0):je(i,r,n=>{for(let t of[...n.querySelectorAll(`*`)].reverse()){let n=t;n.style?.getPropertyValue(e)&&n.style.removeProperty(e),n.nodeName===`FONT`&&Ke[e]&&n.removeAttribute(Ke[e]),n.getAttribute(`style`)||n.removeAttribute(`style`),(n.nodeName===`SPAN`||n.nodeName===`FONT`)&&n.attributes.length===0&&j(n)}let r=n.childNodes.length===1?n.firstChild:null;if(r&&E(r)&&r.nodeName===`SPAN`){r.style.setProperty(e,t);return}let i=a();for(;n.firstChild;)i.appendChild(n.firstChild);n.appendChild(i)})}function qe(e){let t=w(e);if(!t||t.collapsed)return!1;let n=M(t,e);return n?je(n,t,e=>{for(let t of[...e.querySelectorAll(`*`)].reverse())he(t)||(fe.has(t.nodeName)?j(t):D(t)||t.removeAttribute(`style`))}):!1}function Je(e,t){let n=w(t);if(!n||n.collapsed)return[];let r=M(n,t);if(!r)return[];let i=[];return je(r,n,t=>{t.querySelectorAll(`a`).forEach(e=>j(e));let n=document.createElement(`a`);for(n.setAttribute(`href`,e);t.firstChild;)n.appendChild(t.firstChild);t.appendChild(n),i.push(n)}),i.filter(e=>e.isConnected)}function Ye(e){let t=w(e);if(!t)return!1;let n=M(t,e);if(!n)return!1;let r=k(n,t),i=new Set,a=(E(t.startContainer)?t.startContainer:t.startContainer.parentElement)?.closest(`a`);return a&&n.contains(a)&&i.add(a),t.collapsed||n.querySelectorAll(`a`).forEach(e=>{try{t.intersectsNode(e)&&i.add(e)}catch{}}),i.size?(i.forEach(e=>{let t=e.parentElement;j(e),t?.normalize()}),A(n,r),!0):!1}function Xe(e,t){let n=e;for(;n.previousSibling&&!D(n.previousSibling);)n=n.previousSibling;let r=e;for(;r.nextSibling&&!D(r.nextSibling);)r=r.nextSibling;let i=document.createElement(`p`);t.insertBefore(i,n);let a=n;for(;a;){let e=a===r?null:a.nextSibling;i.appendChild(a),a=e}return i}function Ze(e,t){let n=[],r=new Set,i=we(e,t);i.length||(i=[e.startContainer]);for(let e of i){if(e===t||!t.contains(e))continue;let i=ge(e,t);if(i===t){let n=e;for(;n.parentNode!==t;)n=n.parentNode;i=D(n)?n:Xe(n,t)}r.has(i)||(r.add(i),n.push(i))}if(!n.length&&e.startContainer===t){let r=t.childNodes[Math.min(e.startOffset,t.childNodes.length-1)];r&&!D(r)?n.push(Xe(r,t)):r&&!Qe.has(r.nodeName)&&n.push(r)}return n}var Qe=new Set([`UL`,`OL`,`DL`,`TABLE`,`TBODY`,`THEAD`,`TFOOT`,`TR`]);function $e(e){if(!(e.textContent||e.querySelector(`br, img, input, iframe, video, hr, table`))){for(;e.firstChild;)e.firstChild.remove();e.appendChild(document.createElement(`br`))}}var et=[`style`,`dir`,`lang`,`data-an-block-id`];function tt(e,t){let n=document.createElement(t);for(let t of et){let r=e.getAttribute(t);r!=null&&n.setAttribute(t,r)}for(;e.firstChild;)n.appendChild(e.firstChild);return e.parentNode.replaceChild(n,e),n}var nt=new Set([`LI`,`TD`,`TH`,`DD`,`DT`,`CAPTION`,`FIGCAPTION`,`SUMMARY`]);function rt(e,t){let n=w(t);if(!n)return!1;let r=M(n,t);if(!r)return!1;let i=String(e).replace(/[<>]/g,``).toLowerCase();if(!i)return!1;let a=k(r,n),o=[];for(let e of Ze(n,r)){if(e.nodeName.toLowerCase()===i)continue;if(nt.has(e.nodeName)){if(i===`p`)continue;let t=document.createElement(i);for(;e.firstChild&&!D(e.firstChild);)t.appendChild(e.firstChild);e.insertBefore(t,e.firstChild),o.push(t);continue}if(i===`p`&&nt.has(e.parentElement?.nodeName??``)){j(e);continue}e.nodeName===`PRE`&&it(e);let t=tt(e,i);$e(t),o.push(t)}return i===`pre`&&at(o),A(r,a),!0}function it(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],r;for(;r=t.nextNode();)n.push(r);for(let e of n){let t=e.data.split(`
5
+ `);if(t.length===1)continue;let n=document.createDocumentFragment();t.forEach((e,t)=>{t&&n.appendChild(document.createElement(`br`)),e&&n.appendChild(document.createTextNode(e))}),e.parentNode.replaceChild(n,e)}let i=e.querySelector(`:scope > code`);i&&e.childNodes.length===1&&j(i)}function at(e){for(let t=e.length-1;t>0;t--){let n=e[t],r=e[t-1];if(n.previousElementSibling===r&&n.previousSibling===r){for(ot(r),ot(n),r.appendChild(document.createTextNode(`
6
+ `));n.firstChild;)r.appendChild(n.firstChild);n.remove()}}e.forEach(e=>{e.isConnected&&(ot(e),e.normalize())})}function ot(e){e.querySelectorAll(`br`).forEach(e=>e.replaceWith(document.createTextNode(`
7
+ `)))}function F(e,t){let n=w(t);if(!n)return!1;let r=M(n,t);if(!r)return!1;let i=k(r,n);for(let t of Ze(n,r)){let n=t,r=getComputedStyle(n).direction===`rtl`;e===`left`&&!r||e===`right`&&r?n.style.removeProperty(`text-align`):n.style.textAlign=e,n.getAttribute(`style`)||n.removeAttribute(`style`)}return A(r,i),!0}function st(e,t){let n=new Map;for(let r of Ze(e,t)){let e=r.nodeName===`LI`?r:r.closest(`li`);if(!e||!t.contains(e))continue;let i=e.parentElement;n.has(i)||n.set(i,[]);let a=n.get(i);a.includes(e)||a.push(e)}return n}function ct(e,t){let n=w(t);if(!n)return!1;let r=M(n,t);if(!r)return!1;let i=e.toUpperCase(),a=k(r,n),o=st(n,r),s=[...o.keys()];if(s.length&&s.every(e=>e.nodeName===i))for(let[e,t]of o)ut(e,t);else{let e=Ze(n,r).filter(e=>e.nodeName!==`LI`&&!e.closest(`li`));for(let e of s)e.nodeName!==i&&lt(e,i.toLowerCase());dt(e,i.toLowerCase())}return A(r,a),!0}function lt(e,t){let n=document.createElement(t);for(let t of e.attributes)n.setAttribute(t.name,t.value);for(;e.firstChild;)n.appendChild(e.firstChild);e.replaceWith(n)}function ut(e,t){let n=[...e.children],r=n.indexOf(t[0]),i=n.indexOf(t.at(-1));if(r===-1||i===-1)return;let a=n.slice(i+1),o=e;for(let e of n.slice(r,i+1)){let t=document.createElement(`p`),n=[];for(let r of[...e.childNodes])E(r)&&(r.nodeName===`UL`||r.nodeName===`OL`)?n.push(r):E(r)&&r.nodeName===`INPUT`||t.appendChild(r);t.hasChildNodes()||t.appendChild(document.createElement(`br`));let r=e.style.textAlign;r&&(t.style.textAlign=r),o.after(t),o=t;for(let e of n)o.after(e),o=e;e.remove()}if(a.length){let t=e.cloneNode(!1);t.removeAttribute(`id`),a.forEach(e=>t.appendChild(e)),o.after(t)}e.children.length||e.remove()}function dt(e,t){let n=[],r=null;for(let i of e){if(nt.has(i.nodeName)){let e=document.createElement(t),n=document.createElement(`li`);for(;i.firstChild;)n.appendChild(i.firstChild);n.hasChildNodes()||n.appendChild(document.createElement(`br`)),e.appendChild(n),i.appendChild(e),r=null;continue}(!r||r.nextElementSibling!==i||!ft(r,i))&&(r=document.createElement(t),i.parentNode.insertBefore(r,i),n.push(r));let e=document.createElement(`li`),a=i.style?.textAlign;if(a&&(e.style.textAlign=a),i.nodeName===`PRE`||i.nodeName===`BLOCKQUOTE`)e.appendChild(i);else{for(;i.firstChild;)e.appendChild(i.firstChild);i.remove()}$e(e),r.appendChild(e)}n.forEach(pt)}function ft(e,t){for(let n=e.nextSibling;n&&n!==t;n=n.nextSibling)if(n.nodeType!==3||/\S/.test(n.data))return!1;return!0}function pt(e){if(!e.isConnected)return;let t=e.previousElementSibling;if(t&&t.nodeName===e.nodeName&&!t.className&&!e.className&&ft(t,e)){for(;e.firstChild;)t.appendChild(e.firstChild);e.remove(),e=t}let n=e.nextElementSibling;if(n&&n.nodeName===e.nodeName&&!n.className&&!e.className&&ft(e,n)){for(;n.firstChild;)e.appendChild(n.firstChild);n.remove()}}var mt=40,ht=e=>getComputedStyle(e).direction===`rtl`?`margin-right`:`margin-left`;function gt(e){let t=w(e);if(!t)return!1;let n=M(t,e);if(!n)return!1;let r=k(n,t),i=st(t,n);if(i.size)for(let[e,t]of i){let n=t[0].previousElementSibling;if(!n||n.nodeName!==`LI`)continue;let r=n.lastElementChild;(!r||r.nodeName!==e.nodeName)&&(r=e.cloneNode(!1),r.removeAttribute(`id`),r.removeAttribute(`data-an-block-id`),n.appendChild(r));for(let e of t)r.appendChild(e)}else for(let e of Ze(t,n)){let t=e,n=ht(t),r=parseFloat(t.style.getPropertyValue(n))||0;t.style.setProperty(n,`${r+mt}px`)}return A(n,r),!0}function _t(e){let t=w(e);if(!t)return!1;let n=M(t,e);if(!n)return!1;let r=k(n,t),i=st(t,n);if(i.size)for(let[e,t]of i){let n=e.parentElement;n?.nodeName===`LI`?vt(e,t,n):ut(e,t)}else for(let e of Ze(t,n)){let t=e,n=ht(t),r=parseFloat(t.style.getPropertyValue(n))||0;r>mt?t.style.setProperty(n,`${r-mt}px`):t.style.removeProperty(n),t.getAttribute(`style`)||t.removeAttribute(`style`);let i=t.parentElement;r===0&&i?.nodeName===`BLOCKQUOTE`&&/border:\s*none/.test(i.getAttribute(`style`)||``)&&j(i)}return A(n,r),!0}function vt(e,t,n){let r=t.at(-1),i=[];for(let e=r.nextElementSibling;e;e=e.nextElementSibling)i.push(e);if(i.length){let t=e.cloneNode(!1);t.removeAttribute(`id`),i.forEach(e=>t.appendChild(e)),r.appendChild(t)}let a=n;for(let e of t)a.after(e),a=e;e.children.length||e.remove()}function yt(e){let t=w(e);if(!t)return``;let n=M(t,e);if(!n)return``;let r=ge(t.startContainer,n);return r===n||nt.has(r.nodeName)?`p`:r.nodeName.toLowerCase()}function bt(e){let t=w(e);if(!t)return``;let n=t.startContainer,r=E(n)?n:n.parentElement;return r?(getComputedStyle(r).fontFamily||``).split(`,`)[0].replace(/["']/g,``).trim():``}var xt=[`10px`,`13px`,`16px`,`18px`,`24px`,`32px`,`48px`],St={bold:()=>N(`bold`),italic:()=>N(`italic`),underline:()=>N(`underline`),strikeThrough:()=>N(`strikethrough`),superscript:()=>N(`superscript`),subscript:()=>N(`subscript`),foreColor:e=>P(`color`,String(e)),hiliteColor:e=>P(`background-color`,String(e)),backColor:e=>P(`background-color`,String(e)),fontName:e=>P(`font-family`,String(e)),fontSize:e=>P(`font-size`,/^[1-7]$/.test(String(e))?xt[Number(e)-1]:String(e)),formatBlock:e=>rt(String(e)),justifyLeft:()=>F(`left`),justifyCenter:()=>F(`center`),justifyRight:()=>F(`right`),justifyFull:()=>F(`justify`),indent:()=>Rt(),outdent:()=>Bt(),insertUnorderedList:()=>Wt(),insertOrderedList:()=>Gt(),createLink:e=>Je(String(e)).length>0,unlink:()=>Ye(),removeFormat:()=>qe(),insertHTML:e=>ie(String(e??``)),insertText:e=>ae(String(e??``)),insertLineBreak:()=>oe(),insertHorizontalRule:()=>se()};function I(e,t=null){let n=St[e];return n?n(t)!==!1:(console.warn(`[AutumnNote] execCommand: unsupported command "${e}".`),!1)}var Ct=()=>N(`bold`),wt=()=>N(`italic`),Tt=()=>N(`underline`),Et=()=>N(`strikethrough`),Dt=()=>N(`superscript`),Ot=()=>N(`subscript`),kt=e=>P(`color`,e),At=e=>P(`background-color`,e),jt=e=>P(`font-family`,e);function Mt(e,t=document){P(`font-size`,e,t instanceof HTMLElement?t:void 0)}var Nt=e=>rt(e),Pt=()=>F(`left`),Ft=()=>F(`center`),It=()=>F(`right`),Lt=()=>F(`justify`);function Rt(){gt(),_(zt())}function zt(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=null;for(let e=t;e;e=e.parentElement)(e.nodeName===`UL`||e.nodeName===`OL`)&&(n=e);return n}function Bt(){let e=globalThis.getSelection();if(e?.rangeCount){let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`.an-checklist li`);if(n&&!n.parentElement?.closest(`li`)){Vt(n);return}}_t()}function Vt(e){let t=e.closest(`.an-checklist`);if(!t)return;let n=Array.from(t.children),r=n.indexOf(e),i=n.slice(r+1),a=document.createElement(`p`);for(let t of e.childNodes)(t.nodeType!==1||t.tagName!==`INPUT`)&&a.appendChild(t.cloneNode(!0));if(a.innerHTML=a.innerHTML.replaceAll(`​`,``),(!a.hasChildNodes()||!a.textContent.trim())&&(a.innerHTML=``,a.appendChild(document.createTextNode(`\xA0`))),i.length>0){let e=document.createElement(`ul`);e.className=`an-checklist`,i.forEach(t=>e.appendChild(t)),t.parentNode.insertBefore(e,t.nextSibling)}t.parentNode.insertBefore(a,t.nextSibling),e.remove(),t.children.length===0&&t.remove();try{let e=document.createRange(),t=a.firstChild;e.setStart(t?.nodeType===3?t:a,0),e.collapse(!0);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(e))}catch{}}function Ht(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0).commonAncestorContainer;return t.nodeType===3&&(t=t.parentElement),t?.closest(`ul, ol`)||null}function Ut(e){e.classList.remove(`an-checklist`),e.querySelectorAll(`input[type="checkbox"]`).forEach(e=>e.remove())}function Wt(){let e=Ht();e?e.classList.contains(`an-checklist`)?(Ut(e),e.tagName===`OL`&&ct(`ul`)):(e.tagName,ct(`ul`)):ct(`ul`)}function Gt(){let e=Ht();e?e.classList.contains(`an-checklist`)?(Ut(e),e.tagName===`UL`&&ct(`ol`)):(e.tagName,ct(`ol`)):ct(`ol`)}function Kt(e){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return;let n=t.getRangeAt(0),r=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`BLOCKQUOTE`,`PRE`,`TD`,`TH`]),i=e=>{let t=e instanceof Element?e:e.parentElement;for(;t;){if(r.has(t.tagName))return t;t=t.parentElement}return null};if(n.collapsed){let t=i(n.startContainer);t&&(t.style.lineHeight=e);return}let a=new Set,o=document.createTreeWalker(n.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:e=>n.intersectsNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}),s;for(;s=o.nextNode();){let e=i(s);e&&a.add(e)}if(a.size===0){let e=i(n.commonAncestorContainer);e&&a.add(e)}a.forEach(t=>{t.style.lineHeight=e})}function qt(e){let t=globalThis.getSelection();if(!t?.rangeCount)return;let n=t.getRangeAt(0),r=n.commonAncestorContainer;r.nodeType===3&&(r=r.parentElement);let i=r?.closest(`code`);if(i&&!i.closest(`pre`)){let e=i.parentNode,n=i.previousSibling,r=Array.from(i.childNodes);for(;i.firstChild;)e.insertBefore(i.firstChild,i);if(i.remove(),e?.normalize(),r.length>0)try{let i=r[0],a=r.at(-1),o=document.createRange(),s=i.parentNode===e?i:n?n.nextSibling:e.firstChild;if(s){o.setStart(s,0);let n=a.parentNode===e?a:s;o.setEnd(n,n.nodeType===Node.TEXT_NODE?n.textContent.length:n.childNodes.length),t.removeAllRanges(),t.addRange(o)}}catch{}}else{if(n.collapsed)return;try{let e=document.createElement(`code`);n.surroundContents(e);let r=document.createRange();r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r)}catch{let e=n.extractContents(),r=document.createElement(`code`);r.appendChild(e),n.insertNode(r);let i=document.createRange();i.selectNodeContents(r),t.removeAllRanges(),t.addRange(i)}}}function Jt(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`code`);return!!(n&&!n.closest(`pre`))}function Yt(e,t){let n=document.createElement(t);for(let t of e.attributes)n.setAttribute(t.name,t.value);for(;e.firstChild;)n.appendChild(e.firstChild);return e.parentNode.replaceChild(n,e),n}function Xt(e){e.querySelectorAll(`li`).forEach(e=>{if(!e.querySelector(`input[type="checkbox"]`)){let t=document.createElement(`input`);t.type=`checkbox`,t.contentEditable=`false`,e.insertBefore(t,e.firstChild)}})}function Zt(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0),n=t.commonAncestorContainer;n.nodeType===3&&(n=n.parentElement);let r=n?.closest(`ul, ol`);if(r){if(r.classList.contains(`an-checklist`)){if(r.parentNode){let t=Array.from(r.children),n=null;if(t.forEach(e=>{let t=document.createElement(`p`);for(let n of e.childNodes)(n.nodeType!==1||n.tagName!==`INPUT`)&&t.appendChild(n.cloneNode(!0));t.innerHTML=t.innerHTML.replaceAll(`​`,``).replaceAll(`​`,``),(!t.hasChildNodes()||!t.textContent.trim())&&(t.innerHTML=``,t.appendChild(document.createTextNode(`\xA0`))),r.before(t),n||=t}),r.remove(),n){let t=document.createRange();t.setStart(n.firstChild||n,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}}}else{let t=Yt(r,`ul`);t.classList.add(`an-checklist`),Xt(t);let n=t.querySelector(`li`);if(n){let t=document.createRange();t.selectNodeContents(n),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}}else{let r=n?.closest(`[contenteditable="true"]`);if(t.collapsed){let t=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`LI`]),i=n;for(;i?.parentNode&&i!==r&&!t.has(i.tagName);)i=i.parentNode;i===r&&(i=null);let a=i&&t.has(i.tagName)?Array.from(i.childNodes).map(e=>e.textContent).join(``).replaceAll(`\xA0`,` `):``,o=document.createElement(`ul`);o.className=`an-checklist`;let s=document.createElement(`li`),c=document.createElement(`input`);if(c.type=`checkbox`,c.contentEditable=`false`,s.appendChild(c),s.appendChild(document.createTextNode(a||`​`)),o.appendChild(s),i&&t.has(i.tagName))i.parentNode.replaceChild(o,i);else{let t=e.getRangeAt(0);t.deleteContents(),t.insertNode(o)}let l=s.lastChild,u=document.createRange(),d=l.nodeType===Node.TEXT_NODE?l.textContent.length:0;u.setStart(l,d),u.collapse(!0),e.removeAllRanges(),e.addRange(u);return}if(!e.toString().replace(/[\u00a0\u200B]/g,` `).trim())return;let i=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`PRE`,`LI`]),a=[],o=new Set,s=t.commonAncestorContainer,c=document.createNodeIterator(s.nodeType===Node.TEXT_NODE?s.parentNode:s,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,null),l;for(;l=c.nextNode();){if(!t.intersectsNode(l))continue;let e=l.nodeType===Node.TEXT_NODE?l.parentElement:l;for(;e&&e!==r&&!i.has(e.tagName);)e=e.parentElement;e===r&&(e=null),e&&!o.has(e)&&(o.add(e),a.push(e))}if(a.length===0)return;let u=document.createElement(`ul`);u.className=`an-checklist`;let d=null;a.forEach(e=>{let t=document.createElement(`li`),n=document.createElement(`input`);n.type=`checkbox`,n.contentEditable=`false`,t.appendChild(n);let r=Array.from(e.childNodes).map(e=>e.textContent).join(``).replace(/[\u00a0\u200B]/g,` `).trim(),i=document.createTextNode(r||`​`);t.appendChild(i),u.appendChild(t),d=i});let f=a[0];if(f.parentNode.insertBefore(u,f),a.forEach(e=>e.remove()),d){let t=document.createRange();t.setStart(d,d.textContent.length),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}}}function Qt(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).commonAncestorContainer;return t.nodeType===3&&(t=t.parentElement),!!t?.closest(`.an-checklist li`)}function L(e,t,n,r,i,a){return{name:e,icon:t,tooltip:n,action:r,isActive:i,isDisabled:a}}var $t=new Map;function en(e){if(!e||typeof e.name!=`string`){console.warn("[AutumnNote] registerButton: btnDef must have a string `name` property.");return}$t.has(e.name)&&console.warn(`[AutumnNote] registerButton: overwriting existing button "${e.name}".`),$t.set(e.name,e)}function tn(e){return $t.get(e)??rn().get(e)}var nn=null;function rn(){return nn??=new Map(Object.values(er).filter(e=>e&&!Array.isArray(e)&&typeof e.name==`string`).map(e=>[e.name,e])),nn}function an(e,t){let n=t?.buttons;if(Array.isArray(n)){let t=n.find(t=>t?.name===e);if(t)return t}else if(n&&typeof n==`object`&&n[e])return{name:e,...n[e]};return tn(e)}var on=new Map;function sn(e,t){if(typeof e!=`string`||typeof t!=`string`){console.warn(`[AutumnNote] registerIcon: name and icon must be strings.`);return}on.set(e,t)}function cn(e){let t=e.trim();return t.startsWith(`<`)?t:`<i class="${t.replace(/["<>&]/g,``)}" aria-hidden="true"></i>`}function ln(e,t){let n=e?.icons;for(let e of t){if(!e)continue;let t=n&&typeof n[e]==`string`?n[e]:on.get(e);if(typeof t==`string`&&t.trim())return cn(t)}return null}var un=[`8px`,`10px`,`11px`,`12px`,`13px`,`14px`,`16px`,`18px`,`20px`,`24px`,`28px`,`32px`,`36px`,`48px`,`72px`],dn=[`1.0`,`1.15`,`1.5`,`1.75`,`2.0`,`2.5`,`3.0`],fn=[{value:`p`,label:`Normal`},{value:`h1`,label:`H1`},{value:`h2`,label:`H2`},{value:`h3`,label:`H3`},{value:`h4`,label:`H4`},{value:`h5`,label:`H5`},{value:`h6`,label:`H6`},{value:`blockquote`,label:`Quote`},{value:`pre`,label:`Code`}],pn=e=>t=>ze(e,t?.layoutInfo?.editable),mn=L(`bold`,`bold`,`Bold (Ctrl+B)`,()=>Ct(),pn(`bold`)),hn=L(`italic`,`italic`,`Italic (Ctrl+I)`,()=>wt(),pn(`italic`)),gn=L(`underline`,`underline`,`Underline (Ctrl+U)`,()=>Tt(),pn(`underline`)),_n=L(`strikethrough`,`strikethrough`,`Strikethrough`,()=>Et(),pn(`strikethrough`)),vn=L(`superscript`,`superscript`,`Superscript`,()=>Dt(),pn(`superscript`)),yn=L(`subscript`,`subscript`,`Subscript`,()=>Ot(),pn(`subscript`)),bn=L(`alignLeft`,`align-left`,`Align Left`,()=>Pt()),xn=L(`alignCenter`,`align-center`,`Align Center`,()=>Ft()),Sn=L(`alignRight`,`align-right`,`Align Right`,()=>It()),Cn=L(`alignJustify`,`align-justify`,`Justify`,()=>Lt()),wn=L(`ul`,`list-ul`,`Unordered List`,()=>Wt()),Tn=L(`ol`,`list-ol`,`Ordered List`,()=>Gt()),En=L(`indent`,`indent`,`Indent`,()=>Rt()),Dn=L(`outdent`,`outdent`,`Outdent`,()=>Bt()),On=L(`undo`,`undo`,`Undo (Ctrl+Z)`,e=>e.invoke(`editor.undo`),void 0,e=>!e.invoke(`editor.canUndo`)),kn=L(`redo`,`redo`,`Redo (Ctrl+Y)`,e=>e.invoke(`editor.redo`),void 0,e=>!e.invoke(`editor.canRedo`)),An=L(`hr`,`minus`,`Horizontal Rule`,()=>I(`insertHorizontalRule`)),jn=L(`link`,`link`,`Insert Link`,e=>e.invoke(`linkDialog.show`)),Mn=L(`image`,`image`,`Insert Image`,e=>e.invoke(`imageDialog.show`)),Nn=L(`video`,`video`,`Insert Video`,e=>e.invoke(`videoDialog.show`)),Pn=L(`emoji`,`emoji`,`Insert Emoji`,e=>e.invoke(`emojiDialog.show`)),Fn=L(`icon`,`icon`,`Insert FA Icon`,e=>e.invoke(`iconDialog.show`)),In={name:`table`,type:`grid`,icon:`table`,tooltip:`Insert Table`,action:(e,t,n)=>{e.invoke(`editor.insertTable`,n,t),e.invoke(`editor.afterCommand`)}},Ln={name:`fontSize`,type:`select`,tooltip:`Font Size`,placeholder:`Size`,selectClass:`an-select-narrow`,items:un,action:(e,t)=>Mt(t,e.layoutInfo.editable),getValue:e=>{try{let t=globalThis.getSelection();if(t?.rangeCount){let e=t.getRangeAt(0).startContainer;for(e?.nodeType===3&&(e=e.parentElement);e?.nodeType===1&&!e.style.fontSize;)e=e.parentElement;let n=e?.style.fontSize||``;if(n)return n}let n=e?.layoutInfo?.editable;return n&&n.style.fontSize||``}catch{return``}}},Rn=L(`removeFormat`,`remove-format`,`Remove Format`,()=>I(`removeFormat`)),zn=L(`direction`,`direction`,`Toggle Text Direction (LTR / RTL)`,e=>{let t=e.layoutInfo.editable,n=(t.getAttribute(`dir`)||`ltr`)===`ltr`?`rtl`:`ltr`;t.setAttribute(`dir`,n),t.style.textAlign=n===`rtl`?`right`:`left`,e.invoke(`editor.afterCommand`)}),Bn={name:`fontFamily`,type:`select`,tooltip:`Font Family`,action:(e,t)=>jt(t),getValue:e=>bt(e?.layoutInfo?.editable)},Vn={name:`paragraphStyle`,type:`select`,tooltip:`Paragraph Style`,placeholder:`Style`,selectClass:`an-select-style`,items:fn,action:(e,t)=>Nt(t),getValue:e=>{let t=yt(e?.layoutInfo?.editable);return t===`div`?`p`:t}},Hn={name:`lineHeight`,type:`select`,tooltip:`Line Height`,placeholder:`↕ Line`,selectClass:`an-select-narrow`,items:dn,action:(e,t)=>Kt(t),getValue:()=>{try{let e=globalThis.getSelection();if(!e?.rangeCount)return``;let t=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`BLOCKQUOTE`,`PRE`,`TD`,`TH`]),n=e.getRangeAt(0).startContainer;for(n?.nodeType===3&&(n=n.parentElement);n&&!t.has(n.tagName);)n=n.parentElement;return n&&(n.style.lineHeight||getComputedStyle(n).lineHeight)||``}catch{return``}}},Un=L(`codeview`,`code`,`HTML Code View`,e=>e.invoke(`codeview.toggle`),e=>e.invoke(`codeview.isActive`)),Wn=L(`fullscreen`,`expand`,`Fullscreen`,e=>e.invoke(`fullscreen.toggle`),e=>e.invoke(`fullscreen.isActive`)),Gn=L(`shortcuts`,`keyboard`,`Keyboard Shortcuts (Ctrl+Shift+/)`,e=>e.invoke(`shortcutsDialog.show`)),Kn=L(`find`,`search`,`Find (Ctrl+F)`,e=>e.invoke(`findReplace.show`,`find`)),qn=L(`findReplace`,`find-replace`,`Find & Replace (Ctrl+H)`,e=>e.invoke(`findReplace.show`,`replace`)),Jn=L(`inlineCode`,`inline-code`,"Inline Code (Ctrl+`)",e=>e.invoke(`editor.inlineCode`),()=>Jt()),Yn=L(`checklist`,`checklist`,`Checklist`,e=>e.invoke(`editor.toggleChecklist`),()=>Qt()),Xn=L(`print`,`print`,`Print`,e=>e.invoke(`editor.print`)),Zn={name:`foreColor`,type:`colorpicker`,icon:`foreColor`,tooltip:`Text Color`,defaultColor:`#e11d48`,action:(e,t)=>kt(t)},Qn={name:`backColor`,type:`colorpicker`,icon:`backColor`,tooltip:`Highlight Color`,defaultColor:`#fbbf24`,action:(e,t)=>At(t)},$n=[[Vn,Bn,Ln,Hn],[On,kn],[mn,hn,gn,_n,Jn],[vn,yn],[Zn,Qn],[bn,xn,Sn,Cn],[wn,Tn,Yn,En,Dn],[An,jn,Mn,Nn,In,Pn,Fn],[Rn,Un,Wn,Kn,Xn,Gn]],er={boldBtn:mn,italicBtn:hn,underlineBtn:gn,strikeBtn:_n,superscriptBtn:vn,subscriptBtn:yn,alignLeftBtn:bn,alignCenterBtn:xn,alignRightBtn:Sn,alignJustifyBtn:Cn,ulBtn:wn,olBtn:Tn,indentBtn:En,outdentBtn:Dn,undoBtn:On,redoBtn:kn,hrBtn:An,linkBtn:jn,imageBtn:Mn,videoBtn:Nn,emojiBtn:Pn,iconBtn:Fn,tableBtn:In,fontSizeBtn:Ln,removeFormatBtn:Rn,directionBtn:zn,fontFamilyBtn:Bn,paragraphStyleBtn:Vn,lineHeightBtn:Hn,codeviewBtn:Un,fullscreenBtn:Wn,shortcutsBtn:Gn,findBtn:Kn,findReplaceBtn:qn,inlineCodeBtn:Jn,checklistBtn:Yn,printBtn:Xn,foreColorBtn:Zn,backColorBtn:Qn,defaultToolbar:$n},R={placeholder:``,height:200,minHeight:100,maxHeight:0,focus:!1,resizable:!0,statusbar:!0,toolbar:$n,useBootstrap:!1,toolbarButtonClass:`btn btn-sm btn-light`,useFontAwesome:!0,fontAwesomeClass:`fas`,fontAwesomeAutoInject:!0,fontAwesomeCDN:`https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css`,pasteAsPlainText:!1,pasteCleanHTML:!0,pasteStripAttributes:!1,allowImageUpload:!0,maxImageSize:5,tabSize:4,onChange:null,onFocus:null,onBlur:null,onInit:null,onImageUpload:null,onImageError:null,stickyToolbar:!1,stickyToolbarOffset:0,theme:`light`,themeVars:null,zIndexOffset:0,popupContainer:null,codeHighlight:!0,codeHighlightCDN:`https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0`,cspNonce:``,externalAssetCrossOrigin:`anonymous`,externalAssetReferrerPolicy:`no-referrer`,markdownPaste:!0,historyLimit:100,historyMaxBytes:10485760,defaultFontFamily:`Arial`,defaultFontSize:`14px`,fontSizes:[...un],lineHeights:[...dn],paragraphStyles:fn.map(e=>({...e})),colorPalette:null,icons:null,buttons:null,keyMap:null,linkDefaults:{openInNewTab:!1,rel:`noopener noreferrer`,defaultProtocol:`https://`},videoProviders:null,iframeHosts:null,fontFamilies:[`Arial`,`Arial Black`,`Comic Sans MS`,`Courier New`,`Georgia`,`Impact`,`Tahoma`,`Times New Roman`,`Trebuchet MS`,`Verdana`],readOnly:!1,spellcheck:!0,direction:`ltr`,toolbarOverflow:`wrap`,autoSave:!1,autoSaveKey:`autumnnote-autosave`,autoSaveDelay:400,autoSaveAdapter:null,maxChars:0,maxWords:0,tableHeaderRow:!1,onSelectionChange:null,colorSwatches:[],onPaste:null,onPasteError:null,onDestroy:null,onBeforeCommand:null,onCharLimitReached:null,onWordLimitReached:null,focusColor:null,lang:`en`,autoSaveRestore:!1,autoSaveRestoreTimeout:7,onAutoSaveRestore:null,markdownShortcuts:!0,slashMenu:!0,slashCommands:[],documentAdapters:{},collaborationAdapter:null,imageProcessor:null,blockIds:!1,maxPasteSize:5242880,minImageSize:20,bubbleToolbar:!1,bubbleToolbarItems:[`bold`,`italic`,`underline`,`link`,`foreColor`,`hiliteColor`,`removeFormat`],contextMenu:null,mention:null},tr=[`script`,`style`,`iframe`,`object`,`embed`,`form`,`base`,`template`,`link`,`meta`,`noscript`,`portal`,`frame`,`frameset`,`applet`,`animate`,`set`,`animatetransform`,`animatemotion`,`mglyph`,`malignmark`,`annotation-xml`],nr=new Set([`button`]),rr=[`href`,`src`,`action`,`formaction`,`xlink:href`,`poster`,`background`,`srcset`],ir=new Set([`poster`,`background`,`srcset`]),ar=new Set([`ping`]),or=new Set([`color`,`background-color`,`font-size`,`line-height`,`text-align`,`vertical-align`,`font-family`,`margin-left`,`margin-right`,`width`,`min-width`,`height`,`min-height`,`border-width`,`border-style`,`border-color`,`padding`,`white-space`]),sr={"margin-left":/^(0|\d+(\.\d+)?(px|em|rem|%))$/,"margin-right":/^(0|\d+(\.\d+)?(px|em|rem|%))$/},cr=/url\s*\(|image-set\s*\(|src\s*\(|expression\s*\(|@import|javascript:|vbscript:|behavior\s*:|-moz-binding/i,lr=new Set([`www.youtube.com`,`youtube.com`,`m.youtube.com`,`www.youtube-nocookie.com`,`youtube-nocookie.com`,`player.vimeo.com`]),ur=new Set([`http:`,`https:`,`mailto:`,`tel:`]),dr=new Set([`http:`,`https:`,`blob:`]),fr=/^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i,pr=`https://autumnnote.invalid/`;function z(e,t){return mr(e,t).innerHTML}function mr(e,{allowIframes:t=!1,iframeHosts:n=null}={}){let r=new DOMParser().parseFromString(`<body>${e||``}</body>`,`text/html`),i=_r(n),a=Array.from(r.querySelectorAll(`*`)),o=new Set(t?tr.filter(e=>e!==`iframe`):tr);for(let e of a){let t=e.tagName.toLowerCase();if(nr.has(t)){e.replaceWith(...e.childNodes);continue}if(o.has(t)){e.remove();continue}if(t===`iframe`){let t=e.getAttribute(`src`);if(!t||!vr(t,i)){e.remove();continue}}for(let t of Array.from(e.attributes)){if(t.name.startsWith(`on`)){e.removeAttribute(t.name);continue}if(t.name===`style`){let n=hr(t.value);n?e.setAttribute(`style`,n):e.removeAttribute(`style`);continue}if(ar.has(t.name)){e.removeAttribute(t.name);continue}if(rr.includes(t.name)){let n=t.value.trim(),r=ir.has(t.name)||t.name===`src`&&[`IMG`,`VIDEO`,`AUDIO`,`SOURCE`].includes(e.tagName),i=e.tagName===`IMG`;if(!(t.name===`srcset`?gr(n,{allowData:i}):xr(n,{media:r,allowData:i}))){e.removeAttribute(t.name);continue}}if(e.tagName===`IFRAME`){if(t.name===`srcdoc`){e.removeAttribute(t.name);continue}t.name===`src`&&!vr(t.value,i)&&e.removeAttribute(t.name)}}if(t===`a`&&e.getAttribute(`target`)===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`),t===`input`){if(e.closest(`ul.an-checklist`)===null||e.closest(`li`)===null||e.getAttribute(`type`)!==`checkbox`)e.remove();else for(let t of Array.from(e.attributes))[`type`,`checked`,`contenteditable`].includes(t.name)||e.removeAttribute(t.name)}}return r.body}function hr(e){let t=[];for(let n of(e||``).split(`;`)){let e=n.indexOf(`:`);if(e===-1)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();!r||!i||or.has(r)&&(cr.test(i)||i.includes(`\\`)||sr[r]&&!sr[r].test(i)||t.push(`${r}: ${i}`))}return t.join(`; `)}function gr(e,{allowData:t=!1}={}){let n=(e||``).trim().split(/\s+/).filter(Boolean);for(let e of n){if(/^[\d.]+[xw],?$/i.test(e))continue;let n=e.replace(/,+$/,``);if(n&&!xr(n,{media:!0,allowData:t}))return!1}return!0}function _r(e){let t=new Set;if(!e||typeof e[Symbol.iterator]!=`function`||typeof e==`string`)return t;for(let n of e){let e=typeof n==`string`?n.trim().toLowerCase():``;/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/.test(e)?t.add(e):console.warn(`[AutumnNote] iframeHosts: ignoring "${n}" — use a bare hostname such as "player.example.com".`)}return t}function vr(e,t){let n=(e||``).trim();if(!n||n.startsWith(`//`)||n.startsWith(`/`))return!1;try{let e=new URL(n);if(e.protocol!==`https:`)return!1;let r=e.hostname.toLowerCase();return lr.has(r)||!!t?.has(r)}catch{return!1}}function yr(e,t){return vr(e,_r(t))}function br(e,{allowData:t=!1,media:n=t}={}){let r=(e||``).trim();return!r&&e==null?null:xr(r,{media:n,allowData:t})?e:null}function xr(e,{media:t=!1,allowData:n=!1}={}){let r=(e||``).trim();if(!r||n&&fr.test(r))return!0;try{let e=new URL(r,pr);return(t?dr:ur).has(e.protocol)}catch{return!1}}function Sr(e,t){let n=h(`div`,{class:`an-container`}),r=h(`div`,{class:`an-editable`,contenteditable:t.readOnly?`false`:`true`,spellcheck:String(t.spellcheck!==!1),"aria-multiline":`true`,"aria-label":`Rich text editor`,role:`textbox`}),i=``;if(t.autoSave&&t.autoSaveKey)try{i=localStorage.getItem(t.autoSaveKey)||``}catch{}i||=e.tagName===`TEXTAREA`?(e.value||``).trim():(e.innerHTML||``).trim(),r.innerHTML=z(i,{allowIframes:!0,iframeHosts:t.iframeHosts});let a=t.defaultFontFamily||t.fontFamilies?.[0];return a&&(r.style.fontFamily=a),t.defaultFontSize&&(r.style.fontSize=t.defaultFontSize),t.height?r.style.minHeight=`${t.height}px`:t.minHeight&&(r.style.minHeight=`${t.minHeight}px`),t.maxHeight&&(r.style.maxHeight=`${t.maxHeight}px`),n.appendChild(r),t.readOnly&&(n.classList.add(`an-disabled`),r.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.setAttribute(`disabled`,``)})),t.direction===`rtl`&&(r.setAttribute(`dir`,`rtl`),n.classList.add(`an-dir-rtl`)),Dr(n,null,t),e.style.display=`none`,e.after(n),{container:n,editable:r}}var Cr=[`an-theme-dark`,`an-theme-auto`];function wr(e){return e.startsWith(`--`)?e:`--an-${e}`}function Tr(e){let t=h(`div`,{class:`an-portal`,"data-an-portal":``});return Er(e.popupContainer).appendChild(t),t}function Er(e){if(typeof e==`string`&&e){let t=document.querySelector(e);if(t)return t;console.warn(`[AutumnNote] popupContainer "${e}" matched nothing; using document.body.`)}else if(e&&typeof e.appendChild==`function`)return e;return document.body}function Dr(e,t,n){let r=t?[e,t]:[e],i=n.theme===`dark`?`an-theme-dark`:n.theme===`auto`?`an-theme-auto`:null;for(let e of r){e.classList.remove(...Cr),i&&e.classList.add(i);for(let t of Array.from(e.style))t.startsWith(`--an-`)&&e.style.removeProperty(t);let t=n.themeVars;if(t&&typeof t==`object`)for(let[n,r]of Object.entries(t))(typeof r==`string`||typeof r==`number`)&&e.style.setProperty(wr(n),String(r));n.focusColor&&e.style.setProperty(`--an-focus-color`,n.focusColor);let r=Number(n.zIndexOffset)||0;r&&e.style.setProperty(`--an-z-offset`,String(Math.trunc(r)))}e.classList.toggle(`an-toolbar-overflow-scroll`,n.toolbarOverflow===`scroll`),e.classList.toggle(`an-sticky-toolbar`,!!n.stickyToolbar),n.stickyToolbar&&n.stickyToolbarOffset&&e.style.setProperty(`--an-sticky-top`,`${n.stickyToolbarOffset}px`)}var Or=new Map,kr=[];function Ar(e){kr=Array.isArray(e)?e:[]}var jr=[`theme`,`themeVars`,`focusColor`,`zIndexOffset`,`toolbarOverflow`,`stickyToolbar`,`stickyToolbarOffset`],Mr=[`toolbar`,`useFontAwesome`,`fontAwesomeClass`,`useBootstrap`,`toolbarButtonClass`,`icons`,`buttons`,`fontFamilies`,`fontSizes`,`lineHeights`,`paragraphStyles`,`colorPalette`,`colorSwatches`],Nr=[`lang`],Pr=new Map,Fr=class{constructor(e,t={}){this.targetEl=e,this.options=r(R,t),this.locale=l(this.options.lang),this.layoutInfo={},this._listeners=new Map,this._modules=new Map,this._plugins=new Map,this._disposers=[],this._alive=!1,this._autoSaveTimer=null,this._pendingAutoSave=null,this._suppressedRemoteHTML=null,this._destroyPromise=null,this._releaseInstance=null}initialize(){let{container:e,editable:t}=Sr(this.targetEl,this.options);this.layoutInfo.container=e,this.layoutInfo.editable=t,t.setAttribute(`aria-label`,this.locale.a11y?.editor||`Rich text editor`);let n=Tr(this.options);this.layoutInfo.portal=n,Dr(e,n,this.options),this._registerModules();let r=this._modules.get(`toolbar`);r?.el&&(e.insertBefore(r.el,t),this.layoutInfo.toolbar=r.el);let i=this._modules.get(`statusbar`);return i?.el&&(e.appendChild(i.el),this.layoutInfo.statusbar=i.el),this._bindEditorEvents(t),this.options.focus&&t.focus(),this._alive=!0,this.invoke(`toolbar.refresh`),this._applyGlobalPlugins(),this.triggerEvent(`init`,this),this}_registerModules(){let e=(e,t)=>{let n=new t(this);this._modules.set(e,n),n.initialize()};for(let{name:t,Class:n,enabled:r}of kr)typeof r==`function`&&!r(this.options)||e(t,n);if(Or.size>0)for(let[t,n]of Or)e(t,n)}_syncOptionalModules(){for(let{name:e,Class:t,enabled:n}of kr){if(typeof n!=`function`)continue;let r=n(this.options);if(r!==this._modules.has(e)){if(r){let n=new t(this);this._modules.set(e,n),n.initialize()}else{let t=this._modules.get(e);typeof t?.destroy==`function`&&t.destroy(),this._modules.delete(e)}}}}registerModule(e,t){if(this._modules.has(e))return this;let n=new t(this);return n.initialize(),this._modules.set(e,n),this}registerSlashCommand(e){if(!e?.id||typeof e.run!=`function`)throw TypeError(`[AutumnNote] Slash command requires an id and run(context) function.`);let t=this.options.slashCommands||(this.options.slashCommands=[]),n=t.findIndex(t=>t.id===e.id);return n>=0?t[n]=e:t.push(e),this.invoke(`slashMenu.refresh`),this}use(e,t={}){return Array.isArray(e.buttons)&&e.buttons.forEach(e=>en(e)),this._installPlugin(e,t),this}getPlugin(e){return this._plugins.get(e)?.publicApi??null}_installPlugin(e,t={}){let{name:n}=e;if(!n||typeof n!=`string`){console.warn("[AutumnNote] Plugin must have a string `name` property.");return}if(this._plugins.has(n)){console.warn(`[AutumnNote] Plugin "${n}" already installed on this instance. Skipping.`);return}let r=typeof e.install==`function`?e.install(this,t)??null:null;this._plugins.set(n,{plugin:e,publicApi:r})}_applyGlobalPlugins(){if(Pr.size!==0)for(let{plugin:e,options:t}of Pr.values())this._installPlugin(e,t)}_bindEditorEvents(e){let t=v(e,`input`,()=>this._syncToTarget()),n=v(e,`focus`,()=>{this.layoutInfo.container.classList.add(`an-focused`),this.triggerEvent(`focus`,this)}),r=v(e,`blur`,()=>{this.layoutInfo.container.classList.remove(`an-focused`),this._syncToTarget(),this.triggerEvent(`blur`,this)}),i=this.on(`change`,e=>this._syncToTarget(e)),a=this.on(`change`,e=>{if(this.options.blockIds&&(this.ensureBlockIds(),e=this.getHTML()),e===this._suppressedRemoteHTML){this._suppressedRemoteHTML=null;return}this.options.collaborationAdapter?.onLocalChange?.(e,this)});if(this._disposers.push(t,n,r,i,a),this.options.autoSave&&this.options.autoSaveKey){let e=this.on(`change`,e=>this._scheduleAutoSave(e));this._disposers.push(e)}}_scheduleAutoSave(e){this._pendingAutoSave=e,clearTimeout(this._autoSaveTimer),this._autoSaveTimer=setTimeout(()=>this.flushAutoSave(),this.options.autoSaveDelay??400)}async flushAutoSave(){if(clearTimeout(this._autoSaveTimer),this._autoSaveTimer=null,this._pendingAutoSave==null)return;let e=this._pendingAutoSave;this._pendingAutoSave=null;let t=this.options.autoSaveKey,n=Date.now();try{let r=this.options.autoSaveAdapter;typeof r?.save==`function`?await r.save({key:t,html:e,savedAt:n,context:this}):(localStorage.setItem(t,e),localStorage.setItem(t+`:asrmeta`,JSON.stringify({savedAt:n}))),this.triggerEvent(`autoSave`,{key:t,html:e,savedAt:n})}catch(e){this.triggerEvent(`autoSaveError`,{key:t,error:e})}}async loadAutoSave(){let e=this.options.autoSaveAdapter;if(typeof e?.load==`function`)return e.load({key:this.options.autoSaveKey,context:this});try{return localStorage.getItem(this.options.autoSaveKey)}catch{return null}}invoke(e,...t){let[n,r]=e.split(`.`),i=this._modules.get(n);if(!i){console.warn(`[AutumnNote] invoke: module "${n}" not found (path: "${e}")`);return}if(typeof i[r]!=`function`){console.warn(`[AutumnNote] invoke: method "${r}" not found on module "${n}" (path: "${e}")`);return}return i[r](...t)}on(e,t){return this._listeners.has(e)||this._listeners.set(e,[]),this._listeners.get(e).push(t),()=>this.off(e,t)}off(e,t){let n=this._listeners.get(e);if(!n)return;let r=n.indexOf(t);r!==-1&&n.splice(r,1)}triggerEvent(e,...t){let n,r=[...this._listeners.get(e)||[]];for(let e of r){let r=e(...t);r!==void 0&&(n=r)}let i=`on`+e.charAt(0).toUpperCase()+e.slice(1);if(typeof this.options[i]==`function`){let e=this.options[i](...t);e!==void 0&&(n=e)}return n}updateOptions(e={}){let t={...this.options},n=r(this.options,e);Object.keys(this.options).forEach(e=>delete this.options[e]),Object.assign(this.options,n);let a=n=>Object.hasOwn(e,n)&&!i(t[n],this.options[n]),{container:o,editable:s}=this.layoutInfo;if(Object.hasOwn(e,`readOnly`)&&this.setDisabled(!!this.options.readOnly),Object.hasOwn(e,`spellcheck`)&&(s.spellcheck=this.options.spellcheck!==!1),Object.hasOwn(e,`placeholder`)&&(s.dataset.placeholder=this.options.placeholder||``),Object.hasOwn(e,`direction`)){let e=this.options.direction===`rtl`;s.setAttribute(`dir`,e?`rtl`:`ltr`),o.classList.toggle(`an-dir-rtl`,e)}if(Object.hasOwn(e,`height`)||Object.hasOwn(e,`minHeight`)){let e=this.options.height||this.options.minHeight||0;s.style.minHeight=e?`${e}px`:``}Object.hasOwn(e,`maxHeight`)&&(s.style.maxHeight=this.options.maxHeight?`${this.options.maxHeight}px`:``),Mr.some(a)&&this.invoke(`toolbar.rebuild`),jr.some(a)&&Dr(o,this.layoutInfo.portal??null,this.options),a(`popupContainer`)&&this.layoutInfo.portal&&Er(this.options.popupContainer).appendChild(this.layoutInfo.portal),a(`resizable`)&&this.invoke(`statusbar.applyResizable`);let c=Nr.filter(a);return c.length&&console.warn(`[AutumnNote] updateOptions: ${c.join(`, `)} only take effect when the editor is created; destroy and re-create it to apply.`),this._syncOptionalModules(),a(`statusbar`)&&this.invoke(`statusbar.applyVisibility`),this.invoke(`statusbar.update`),this.triggerEvent(`optionsChange`,{...e}),this}getHTML(){let e=this.invoke(`editor.getHTML`);return typeof e==`string`?e.replace(/​/g,``):e}setHTML(e){this.invoke(`editor.setHTML`,e)}getText(){return this.invoke(`editor.getText`)}setText(e){this.invoke(`editor.setText`,e)}clear(){this.invoke(`editor.clear`)}clearHistory(){this.invoke(`editor.clearHistory`)}getUndoCount(){return this.invoke(`editor.getUndoCount`)??0}getRedoCount(){return this.invoke(`editor.getRedoCount`)??0}isEmpty(){return this.invoke(`editor.isEmpty`)}insertHTML(e){this.invoke(`editor.insertHTML`,e)}insertText(e){this.invoke(`editor.insertText`,e)}setMarkdown(e){this.invoke(`editor.setMarkdown`,e)}getMarkdown(){return this.invoke(`editor.getMarkdown`)}getSelectionBookmark(){return this.invoke(`editor.getSelectionBookmark`)??null}restoreSelectionBookmark(e){return this.invoke(`editor.restoreSelectionBookmark`,e)}async importDocument(e,t){let n=this.options.documentAdapters?.[e],r;if(typeof n?.import==`function`)r=await n.import(t,this);else if(e===`html`)r=String(t??``);else if(e===`markdown`)return this.setMarkdown(String(t??``)),this;else if(e===`text`)return this.setText(String(t??``)),this;else throw Error(`[AutumnNote] No importer registered for "${e}".`);return this.setHTML(r),this}async exportDocument(e){let t=this.options.documentAdapters?.[e];if(typeof t?.export==`function`)return t.export(this,this.getHTML());if(e===`html`)return this.getHTML();if(e===`markdown`)return this.getMarkdown();if(e===`text`)return this.getText();throw Error(`[AutumnNote] No exporter registered for "${e}".`)}ensureBlockIds(){let e=this.layoutInfo.editable.children;for(let t of e)if(!t.hasAttribute(`data-an-block-id`)){let e=globalThis.crypto?.randomUUID?.()||`an-${Date.now()}-${Math.random().toString(36).slice(2)}`;t.setAttribute(`data-an-block-id`,e)}return this}getDocument(){return this.options.blockIds&&this.ensureBlockIds(),{version:1,html:this.getHTML(),markdown:this.getMarkdown()}}loadDocument(e){return this.setHTML(e?.html||``),this.clearHistory(),this}applyRemoteHTML(e){return this.setHTML(e),this._suppressedRemoteHTML=this.getHTML(),this.clearHistory(),this}getWordCount(){return this.invoke(`statusbar.getWordCount`)??0}getCharCount(){return this.invoke(`statusbar.getCharCount`)??0}downloadHTML(e=`document.html`){this._download(this.getHTML(),e,`text/html`)}downloadText(e=`document.txt`){this._download(this.getText(),e,`text/plain`)}downloadMarkdown(e=`document.md`){this._download(this.getMarkdown(),e,`text/markdown`)}_download(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.style.display=`none`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}print(e=``){let t=this.getHTML(),n=`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>${(e||``).replace(/[<>&"']/g,e=>`&#${e.charCodeAt(0)};`)}</title><style>body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;font-size:14px;line-height:1.6;padding:20mm;color:#111827;}ul.an-checklist{list-style:none;padding-left:0;}ul.an-checklist li{padding-left:24px;position:relative;margin:2px 0;}ul.an-checklist li input[type="checkbox"]{position:absolute;left:0;top:3px;}code{background:#f3f4f6;border-radius:3px;padding:.1em .35em;font-family:monospace;}pre{background:#f3f4f6;padding:.75em 1em;border-radius:4px;overflow-x:auto;}table{border-collapse:collapse;}td,th{border:1px solid #d1d5db;padding:4px 8px;}</style></head><body>${t}</body></html>`,r=new Blob([n],{type:`text/html`}),i=URL.createObjectURL(r),a=globalThis.open(i,`_blank`);if(!a){URL.revokeObjectURL(i);return}a.addEventListener(`load`,()=>{a.print(),URL.revokeObjectURL(i)})}getTableOfContents(){return Array.from(this.layoutInfo.editable.querySelectorAll(`h1,h2,h3,h4,h5,h6`)).map(e=>({level:parseInt(e.tagName[1],10),text:e.textContent?.trim()??``,element:e}))}focus(){this.layoutInfo.editable.focus()}blur(){this.layoutInfo.editable.blur()}isFullscreen(){return this.invoke(`fullscreen.isActive`)===!0}setDisabled(e){let t=this.layoutInfo.editable;e?(t.setAttribute(`contenteditable`,`false`),this.layoutInfo.container.classList.add(`an-disabled`),t.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.setAttribute(`disabled`,``)})):(t.setAttribute(`contenteditable`,`true`),this.layoutInfo.container.classList.remove(`an-disabled`),t.querySelectorAll(`ul.an-checklist input[type="checkbox"]`).forEach(e=>{e.removeAttribute(`disabled`)}))}destroy(){if(!this._alive)return this._destroyPromise??Promise.resolve();let e=this._pendingAutoSave==null?null:this.flushAutoSave().catch(()=>{});this._modules.forEach(e=>{typeof e.destroy==`function`&&e.destroy()}),this._modules.clear();for(let{plugin:e}of this._plugins.values())if(typeof e.uninstall==`function`)try{e.uninstall(this)}catch{}this._plugins.clear(),this._disposers.forEach(e=>e()),this._disposers=[];let t=this.layoutInfo.container;return t?.parentNode&&(this.targetEl.style.display=``,t.remove()),this.layoutInfo.portal?.remove(),this.triggerEvent(`destroy`,this),this._alive=!1,this._releaseInstance?.(),this._releaseInstance=null,this._destroyPromise=Promise.resolve(e).then(()=>{this._listeners.clear()}),this._destroyPromise}_syncToTarget(e){(this.targetEl.tagName===`TEXTAREA`||this.targetEl.tagName===`INPUT`)&&(this.targetEl.value=typeof e==`string`?e:this.getHTML())}};function Ir(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return r}var Lr=class{constructor(e,t=100,n=10485760){this.editable=e,this._limit=t,this._maxBytes=n,this._bytes=0,this.stack=[],this.stackOffset=-1,this._savePoint()}_entrySize(e){let t=e.html.length;if(e.images)for(let n in e.images)t+=e.images[n].length;return t}_serialize(){return this.editable.innerHTML}_serializeSelection(){let e=globalThis.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0);return this.editable.contains(t.startContainer)?{start:this._charOffset(t.startContainer,t.startOffset),end:this._charOffset(t.endContainer,t.endOffset)}:null}_charOffset(e,t){try{let n=document.createRange();return n.selectNodeContents(this.editable),n.setEnd(e,t),n.toString().length}catch{return 0}}_restoreSelection(e){if(!e)return;let t=null,n=0,r=null,i=0,a=0,o=document.createTreeWalker(this.editable,NodeFilter.SHOW_TEXT,null),s;for(;s=o.nextNode();){let o=s.length;if(!t&&a+o>=e.start&&(t=s,n=e.start-a),!r&&a+o>=e.end){r=s,i=e.end-a;break}a+=o}if(!t){let e=document.createTreeWalker(this.editable,NodeFilter.SHOW_TEXT,null),a=null;for(;a=e.nextNode();)t=a;n=t?t.length:0,r=t,i=n}r||(r=t,i=n);try{let e=document.createRange();e.setStart(t,n),e.setEnd(r,i);let a=globalThis.getSelection();a.removeAllRanges(),a.addRange(e)}catch{try{let e=document.createRange();e.setStart(this.editable,0),e.collapse(!0);let t=globalThis.getSelection();t&&(t.removeAllRanges(),t.addRange(e))}catch{}}}_savePoint(){if(this.stackOffset<this.stack.length-1){for(let e of this.stack.slice(this.stackOffset+1))this._bytes-=this._entrySize(e);this.stack=this.stack.slice(0,this.stackOffset+1)}let e=this._serialize(),{html:t,images:n}=this._tokenizeImages(e),r={html:t,images:n,sel:this._serializeSelection()};for(this.stack.push(r),this._bytes+=this._entrySize(r);this.stack.length>1&&(this.stack.length>this._limit||this._bytes>this._maxBytes);)this._bytes-=this._entrySize(this.stack.shift());this.stackOffset=this.stack.length-1}_restore(e){if(!e)return;let t=this.editable.textContent||``;this.editable.innerHTML=this._detokenizeImages(e);let n=e.sel;if(!n){let e=Ir(t,this.editable.textContent||``);n={start:e,end:e}}this._restoreSelection(n)}_tokenizeImages(e){if(!e.includes(`data:`))return{html:e,images:{}};let t={},n=0;return{html:e.replace(/data:[^;]+;base64,[^"' >]*/g,e=>{let r=`__asn_img_${n}__`;return t[r]=e,n++,r}),images:t}}_detokenizeImages(e){return!e.images||Object.keys(e.images).length===0?e.html:e.html.replace(/__asn_img_\d+__/g,t=>e.images[t]||t)}recordUndo(){let e=this._serialize(),{html:t}=this._tokenizeImages(e);this.stack[this.stackOffset]?.html!==t&&this._savePoint()}undo(){this.stackOffset<=0||(this.stackOffset--,this._restore(this.stack[this.stackOffset]))}redo(){this.stackOffset>=this.stack.length-1||(this.stackOffset++,this._restore(this.stack[this.stackOffset]))}reset(){this.stack=[],this.stackOffset=-1,this._bytes=0,this._savePoint()}canUndo(){return this.stackOffset>0}canRedo(){return this.stackOffset<this.stack.length-1}getUndoCount(){return Math.max(0,this.stackOffset)}getRedoCount(){return Math.max(0,this.stack.length-1-this.stackOffset)}};function Rr(e,t,n={}){let{headerRow:r=!1}=n,i=h(`table`,{class:`an-table`});if(r&&t>0){let t=h(`thead`),n=h(`tr`);for(let t=0;t<e;t++){let e=h(`th`,{},[document.createElement(`br`)]);n.appendChild(e)}t.appendChild(n),i.appendChild(t)}let a=r?Math.max(t-1,1):t,o=h(`tbody`);i.appendChild(o);for(let t=0;t<a;t++){let t=h(`tr`);for(let n=0;n<e;n++){let e=h(`td`,{},[document.createElement(`br`)]);t.appendChild(e)}o.appendChild(t)}return i}function zr(e,t,n={}){if(e<=0||t<=0)return;let r=Rr(e,t,n),i=globalThis.getSelection();if(!i||i.rangeCount===0)return;let a=i.getRangeAt(0);try{a.deleteContents()}catch{return}let o=new Set([`P`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`BLOCKQUOTE`,`LI`,`PRE`]),s=a.startContainer;for(s?.nodeType===3&&(s=s.parentElement);s&&!o.has(s.tagName?.toUpperCase())&&s.parentElement;)s=s.parentElement;if(s&&o.has(s.tagName?.toUpperCase())&&s.parentNode){if(s.after(r),!r.nextElementSibling){let e=document.createElement(`p`);e.appendChild(document.createElement(`br`)),r.after(e)}!s.textContent.trim()&&!s.querySelector(`img, video, table`)&&s.remove()}else try{a.insertNode(r)}catch{return}let c=r.querySelector(`td, th`);if(c){let e=document.createRange();e.setStart(c,0),e.collapse(!0),i.removeAllRanges(),i.addRange(e)}}var Br=Object.freeze({"Mod+Z":`undo`,"Mod+Shift+Z":`redo`,"Mod+Y":`redo`,"Mod+B":`bold`,"Mod+I":`italic`,"Mod+U":`underline`,"Mod+K":`link`,"Mod+Shift+V":`pastePlainText`,"Mod+F":`find`,"Mod+H":`findReplace`,"Mod+`":`inlineCode`,"Ctrl+Shift+/":`shortcuts`}),Vr={Slash:`/`,Backslash:`\\`,Backquote:"`",Minus:`-`,Equal:`=`,BracketLeft:`[`,BracketRight:`]`,Semicolon:`;`,Quote:`'`,Comma:`,`,Period:`.`,Space:` `};function Hr(e){if(typeof e!=`string`)return null;let t=e.trim().split(/\+(?!$)/).map(e=>e.trim()).filter(Boolean);if(!t.length)return null;let n={mod:!1,ctrl:!1,meta:!1,alt:!1,shift:!1,key:``};for(let[e,r]of t.entries()){let i=r.toLowerCase(),a=e===t.length-1;if(!a&&(i===`mod`||i===`cmdorctrl`))n.mod=!0;else if(!a&&(i===`ctrl`||i===`control`))n.ctrl=!0;else if(!a&&(i===`meta`||i===`cmd`||i===`command`))n.meta=!0;else if(!a&&(i===`alt`||i===`option`))n.alt=!0;else if(!a&&i===`shift`)n.shift=!0;else if(a)n.key=i;else return null}return n.key?n:null}function Ur(e,t){if(t.mod){if(!e.ctrlKey&&!e.metaKey)return!1}else if(e.ctrlKey!==t.ctrl||e.metaKey!==t.meta)return!1;if(e.altKey!==t.alt||e.shiftKey!==t.shift)return!1;if((e.key||``).toLowerCase()===t.key)return!0;let n=e.code||``,r=Vr[n];return!r&&/^Key[A-Z]$/.test(n)?r=n.slice(3).toLowerCase():!r&&/^Digit\d$/.test(n)&&(r=n.slice(5)),r===t.key}function Wr(e){let t=new Map,n=(e,n)=>{let r=Hr(e);if(!r){console.warn(`[AutumnNote] keyMap: cannot parse shortcut "${e}".`);return}let i=Gr(r);if(n===!1||n===null){t.set(i,null);return}let a=n,o;if(n&&typeof n==`object`&&typeof n.run==`function`&&(a=n.run,o=typeof n.description==`string`?n.description:void 0),typeof a!=`string`&&typeof a!=`function`){console.warn(`[AutumnNote] keyMap: "${e}" must map to a command name, a function or false.`);return}t.set(i,{combo:e,parsed:r,command:a,description:o})};for(let[e,t]of Object.entries(Br))n(e,t);if(e&&typeof e==`object`)for(let[t,r]of Object.entries(e))n(t,r);return[...t.values()].filter(Boolean)}function Gr(e){return[e.mod&&`mod`,e.ctrl&&`ctrl`,e.meta&&`meta`,e.alt&&`alt`,e.shift&&`shift`,e.key].filter(Boolean).join(`+`)}function Kr(e){let t=[];return(e.mod||e.ctrl)&&t.push(`Ctrl`),e.meta&&t.push(`Cmd`),e.alt&&t.push(`Alt`),e.shift&&t.push(`Shift`),t.push(e.key.length===1?e.key.toUpperCase():e.key.charAt(0).toUpperCase()+e.key.slice(1)),t.join(` + `)}var B={BACKSPACE:`Backspace`,TAB:`Tab`,ENTER:`Enter`,ESCAPE:`Escape`,SPACE:` `,PAGE_UP:`PageUp`,PAGE_DOWN:`PageDown`,END:`End`,HOME:`Home`,LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,DOWN:`ArrowDown`,DELETE:`Delete`,NUM0:`0`,NUM1:`1`,NUM2:`2`,NUM3:`3`,NUM4:`4`,NUM5:`5`,NUM6:`6`,NUM7:`7`,NUM8:`8`,B:`b`,E:`e`,I:`i`,J:`j`,K:`k`,L:`l`,R:`r`,S:`s`,U:`u`,V:`v`,Y:`y`,Z:`z`,SLASH:`/`,PERIOD:`.`};function V(e,t){return e.key===t||e.key===t.toUpperCase()}var qr=/\bfa-/,H=e=>!!(e?.nodeName===`I`&&qr.test(e.className||``)),Jr=e=>!(e?.nodeType!==Node.TEXT_NODE||e.textContent!==`​`&&e.textContent!==``);function Yr(e,t,n){let r=(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement??null)?.closest(`td, th`)??null;if(!r||!t.contains(r))return!1;let i=r.closest(`table`);if(!i||!t.contains(i))return!1;let a=Array.from(i.querySelectorAll(`td, th`)),o=a[a.indexOf(r)+(n?-1:1)];if(o)return g(o),!0;if(n)return!0;let s=Xr(r.closest(`tr`))?.firstElementChild??null;return s&&g(s),!0}function Xr(e){if(!e?.parentNode)return null;let t=document.createElement(`tr`);for(let n of e.cells){let e=document.createElement(`td`);e.appendChild(document.createElement(`br`)),n.hasAttribute(`style`)&&e.setAttribute(`style`,n.getAttribute(`style`)),t.appendChild(e)}return e.parentNode.insertBefore(t,e.nextSibling),t}function Zr(e,t){try{let n=document.createRange();return n.setStart(e.startContainer,e.startOffset),n.setEnd(t,t.childNodes.length),n.extractContents()}catch{return document.createDocumentFragment()}}function Qr(e,t,n={}){let r=e=>{let t=globalThis.getSelection();if(!t)return!1;let n=document.createRange();return e(n),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!0};if(V(e,B.BACKSPACE)){let t=globalThis.getSelection();if(t?.rangeCount>0){let n=t.getRangeAt(0);if(n.collapsed&&n.startContainer.nodeType===Node.TEXT_NODE){let r=n.startContainer;if(n.startOffset===0&&H(r.previousSibling))return e.preventDefault(),r.previousSibling.remove(),!0;if(n.startOffset===1&&r.textContent===`​`&&H(r.previousSibling)){e.preventDefault();let n=r.parentNode,i=r.previousSibling,a=i.previousSibling;i.remove(),r.remove();let o=document.createRange();return a?.nodeType===Node.TEXT_NODE?o.setStart(a,a.textContent.length):a?o.setStartAfter(a):n&&o.setStart(n,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}}return!1}if(V(e,B.LEFT)||V(e,B.RIGHT)){let t=globalThis.getSelection();if(!t||t.rangeCount===0)return!1;let n=t.getRangeAt(0);if(!n.collapsed)return!1;let i=n.startContainer,a=V(e,B.LEFT);if(i.nodeType===Node.TEXT_NODE){let t=i;if(a&&n.startOffset===1&&t.textContent===`​`&&H(t.previousSibling)||a&&n.startOffset===0&&H(t.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(t.previousSibling));if(a&&n.startOffset===0&&Jr(t.previousSibling)&&H(t.previousSibling.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(t.previousSibling.previousSibling));if(!a&&n.startOffset===t.textContent.length&&H(t.nextSibling)){let n=t.nextSibling,i=n.nextSibling;if(e.preventDefault(),i?.nodeType===Node.TEXT_NODE){let e=+!!(i.textContent||``).startsWith(`​`);return r(t=>t.setStart(i,Math.min(e,i.textContent.length)))}return r(e=>e.setStartAfter(n))}if(!a&&n.startOffset===t.textContent.length&&Jr(t.nextSibling)&&H(t.nextSibling.nextSibling)){let n=t.nextSibling.nextSibling,i=n.nextSibling;if(e.preventDefault(),i?.nodeType===Node.TEXT_NODE){let e=+!!(i.textContent||``).startsWith(`​`);return r(t=>t.setStart(i,Math.min(e,i.textContent.length)))}return r(e=>e.setStartAfter(n))}}if(i.nodeType===Node.ELEMENT_NODE){let t=i;if(a&&n.startOffset>0){let i=t.childNodes[n.startOffset-1];if(H(i))return e.preventDefault(),r(e=>e.setStartBefore(i));if(Jr(i)&&H(i.previousSibling))return e.preventDefault(),r(e=>e.setStartBefore(i.previousSibling))}if(!a&&n.startOffset<t.childNodes.length){let i=t.childNodes[n.startOffset];if(H(i)){let t=i.nextSibling;if(e.preventDefault(),t?.nodeType===Node.TEXT_NODE){let e=+!!(t.textContent||``).startsWith(`​`);return r(n=>n.setStart(t,Math.min(e,t.textContent.length)))}return r(e=>e.setStartAfter(i))}if(Jr(i)&&H(i.nextSibling)){let t=i.nextSibling,n=t.nextSibling;if(e.preventDefault(),n?.nodeType===Node.TEXT_NODE){let e=+!!(n.textContent||``).startsWith(`​`);return r(t=>t.setStart(n,Math.min(e,n.textContent.length)))}return r(e=>e.setStartAfter(t))}}}}if(V(e,B.TAB)){let r=C(t);if(!r)return!1;if(Yr(r.sc,t,e.shiftKey))return e.preventDefault(),!0;let i=m(r.sc,t);if(i&&f(i))return e.preventDefault(),e.shiftKey?Bt():Rt(),!0;if(i?.nodeName.toUpperCase()===`PRE`)return!e.shiftKey&&(e.preventDefault(),I(`insertText`,` `.repeat(n.tabSize||4)),!0);if(n.tabSize)return!e.shiftKey&&(e.preventDefault(),I(`insertText`,` `.repeat(n.tabSize)),!0)}if(V(e,B.ENTER)&&e.shiftKey)return e.preventDefault(),I(`insertLineBreak`),!0;if(V(e,B.ENTER)&&!e.shiftKey){let n=C(t);if(!n)return!1;let r=n.sc,i=r.nodeType===3?r.parentElement:r;if(i?.nodeName===`I`&&/\bfa-/.test(i.className||``)){let e=document.createRange();e.setStartAfter(i),e.collapse(!0);let t=globalThis.getSelection();return t&&(t.removeAllRanges(),t.addRange(e)),!1}let a=i?.closest(`.an-video-wrapper`);if(a){e.preventDefault();let t=document.createElement(`p`);t.innerHTML=`\xA0`,a.parentNode.insertBefore(t,a.nextSibling);let n=document.createRange();n.setStart(t,0),n.collapse(!0);let r=globalThis.getSelection();return r.removeAllRanges(),r.addRange(n),!0}let o=i?.closest(`.an-checklist li`);if(o){e.preventDefault();let t=o.closest(`.an-checklist`),n=globalThis.getSelection(),r=n.getRangeAt(0);if(!(e=>Array.from(e.childNodes).filter(e=>e.nodeType!==1||e.tagName!==`INPUT`).map(e=>e.textContent).join(``).replace(/[\u00a0\u200B]/g,` `).trim())(o)){let e=document.createElement(`p`);e.innerHTML=`\xA0`,t.parentNode.insertBefore(e,t.nextSibling),o.remove(),t.children.length===0&&t.remove();let r=document.createRange();return r.setStart(e.firstChild,0),r.collapse(!0),n.removeAllRanges(),n.addRange(r),!0}if(!r.collapsed){if(r.deleteContents(),n.rangeCount===0||!o.isConnected)return!0;r=n.getRangeAt(0)}let i=Zr(r,o),a=document.createElement(`li`),s=document.createElement(`input`);s.type=`checkbox`,s.setAttribute(`contenteditable`,`false`),a.appendChild(s),i.textContent.replace(/[\u00a0\u200B]/g,``).length>0&&a.appendChild(i);let c=a.childNodes[1];c?.nodeType!==Node.TEXT_NODE&&(c=document.createTextNode(`​`),a.appendChild(c)),o.after(a);let l=document.createRange();return l.setStart(c,0),l.collapse(!0),n.removeAllRanges(),n.addRange(l),!0}let s=m(n.sc,t);if(s?.nodeName.toUpperCase()===`PRE`)return e.preventDefault(),I(`insertText`,`
8
+ `),!0;if(s?.nodeName.toUpperCase()===`BLOCKQUOTE`){let t=n.toNativeRange();if(t.setEnd(s,s.childNodes.length),t.toString()===``&&n.isCollapsed())return e.preventDefault(),I(`formatBlock`,`<p>`),!0}}return!1}var $r=typeof Intl<`u`&&typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`word`}):null;function ei(e){let t=e.trim();if(!t)return 0;if($r){let e=0;for(let n of $r.segment(t))n.isWordLike&&e++;return e}return t.split(/\s+/).length}var ti=new Set(`ADDRESS.ARTICLE.ASIDE.BLOCKQUOTE.BR.DD.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.H1.H2.H3.H4.H5.H6.HEADER.HR.LI.MAIN.NAV.OL.P.PRE.SECTION.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL`.split(`.`));function ni(e,t,n){for(let r=e.firstChild;r;r=r.nextSibling)if(r.nodeType===3){let e=r.data;t.push(e),n.push(e)}else if(r.nodeType===1){let e=ti.has(r.tagName);e&&t.push(`
9
+ `),ni(r,t,n),e&&t.push(`
10
+ `)}}function ri(e){if(e.nodeType===3){let t=e.data;return{lines:t,flat:t}}let t=[],n=[];return ni(e,t,n),{lines:t.join(``),flat:n.join(``)}}var ii=class{constructor(){this._cache=new WeakMap}counts(e){let t=0,n=0,r=[],i=[],a=0;for(let o=e.firstChild;o;o=o.nextSibling){let e=this._cache.get(o);if(e&&e.key===(o.textContent||``)){t+=e.words,n+=e.chars;continue}let{lines:s,flat:c}=ri(o);r.push({node:o,key:c,text:s,start:a}),i.push(s),a+=s.length+1}if(r.length){let e=ai(r,i.join(`
11
+ `));r.forEach((r,i)=>{let a={key:r.key,words:e[i],chars:r.key.replace(/[\n\u200B]/g,``).length};this._cache.set(r.node,a),t+=a.words,n+=a.chars})}return{words:t,chars:n}}};function ai(e,t){if(!$r)return e.map(e=>ei(e.text));let n=Array(e.length).fill(0),r=0;for(let i of $r.segment(t))if(i.isWordLike){for(;r<e.length-1&&i.index>=e[r+1].start;)r++;n[r]++}return n}function oi(e){let t=new DOMParser().parseFromString(`<body>${e||``}</body>`,`text/html`);return _(t.body),mi(t.body).replace(/\n{3,}/g,`
10
12
 
11
- `).trim()}function Un(e,t){return Array.from(e.children).filter(e=>e.tagName===t.toUpperCase())}function Wn(e){let t=``;for(let n of e.childNodes){if(n.nodeType===3){t+=n.textContent;continue}if(n.nodeType!==1)continue;let e=n.nodeName.toLowerCase();if(e===`br`){t+=`
13
+ `).trim()}function si(e,t){return Array.from(e.children).filter(e=>e.tagName===t.toUpperCase())}function ci(e){let t=``;for(let n of e.childNodes){if(n.nodeType===3){t+=n.textContent;continue}if(n.nodeType!==1)continue;let e=n.nodeName.toLowerCase();if(e===`br`){t+=`
12
14
  `;continue}if(e===`div`||e===`p`){t&&!t.endsWith(`
13
15
  `)&&(t+=`
14
- `),t+=Wn(n),t+=`
15
- `;continue}t+=Wn(n)}return t}function Gn(e){return e.replaceAll(`\\`,`\\\\`).replace(/&(?=#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g,`&amp;`).replace(/!(?=\[)/g,String.raw`\!`).replace(/([`*[\]])/g,String.raw`\$1`).replace(/(?<!\w)_|_(?!\w)/g,String.raw`\_`).replace(/~(?=~)|(?<=~)~/g,String.raw`\~`)}function Kn(e){return/^\s*(?:-{2,}|={2,}|\*{3,}|_{3,}|(?:[-*_] +){2,}[-*_])\s*$/.test(e)?e.replace(/[-=*_]/,e=>`\\${e}`):e.replace(/^(\s*)(#{1,6})(?=\s|$)/,(e,t,n)=>`${t}\\${n}`).replace(/^(\s*)>/,(e,t)=>`${t}\\>`).replace(/^(\s*)([-*+])(?=\s)/,(e,t,n)=>`${t}\\${n}`).replace(/^(\s*)(\d+)([.)])(?=\s)/,(e,t,n,r)=>`${t}${n}\\${r}`)}function qn(e){return e.split(`
16
- `).map(Kn).join(`
17
- `)}function Jn(e,t){let n=` `.repeat(t+1);return Xn(e,t+1).trim().split(`
16
+ `),t+=ci(n),t+=`
17
+ `;continue}t+=ci(n)}return t}function li(e){return e.replaceAll(`\\`,`\\\\`).replace(/&(?=#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g,`&amp;`).replace(/!(?=\[)/g,String.raw`\!`).replace(/([`*[\]])/g,String.raw`\$1`).replace(/(?<!\w)_|_(?!\w)/g,String.raw`\_`).replace(/~(?=~)|(?<=~)~/g,String.raw`\~`)}function ui(e){return/^\s*(?:-{2,}|={2,}|\*{3,}|_{3,}|(?:[-*_] +){2,}[-*_])\s*$/.test(e)?e.replace(/[-=*_]/,e=>`\\${e}`):e.replace(/^(\s*)(#{1,6})(?=\s|$)/,(e,t,n)=>`${t}\\${n}`).replace(/^(\s*)>/,(e,t)=>`${t}\\>`).replace(/^(\s*)([-*+])(?=\s)/,(e,t,n)=>`${t}\\${n}`).replace(/^(\s*)(\d+)([.)])(?=\s)/,(e,t,n,r)=>`${t}${n}\\${r}`)}function di(e){return e.split(`
18
+ `).map(ui).join(`
19
+ `)}function fi(e,t){let n=` `.repeat(t+1);return mi(e,t+1).trim().split(`
18
20
  `).map((e,t)=>t===0||e.trim()===``||e.startsWith(n)?e:n+e).join(`
19
- `)}function Yn(e,t){let n=e.getAttribute(t)||``,r=/[\s()]/.test(n)?`<${n}>`:n,i=e.getAttribute(`title`);return i?`${r} "${i.replaceAll(`"`,String.raw`\"`)}"`:r}function Xn(e,t=0){if(e.nodeType===3){let t=e.textContent.replace(/\s+/g,` `);return e.parentElement?.closest(`pre, code`)?t:Gn(t)}if(e.nodeType!==1)return``;let n=e,r=n.nodeName.toLowerCase(),i=()=>Array.from(n.childNodes).map(e=>Xn(e,t)).join(``);switch(r){case`p`:case`div`:return`\n\n${qn(i())}\n\n`;case`br`:return`
20
- `;case`h1`:return`\n\n# ${i()}\n\n`;case`h2`:return`\n\n## ${i()}\n\n`;case`h3`:return`\n\n### ${i()}\n\n`;case`h4`:return`\n\n#### ${i()}\n\n`;case`h5`:return`\n\n##### ${i()}\n\n`;case`h6`:return`\n\n###### ${i()}\n\n`;case`strong`:case`b`:return`**${i()}**`;case`em`:case`i`:return`*${i()}*`;case`del`:case`s`:case`strike`:return`~~${i()}~~`;case`sup`:return`^${i()}^`;case`sub`:return`~${i()}~`;case`u`:return`<u>${i()}</u>`;case`span`:{let e=n.getAttribute(`style`)||``;return/\b(color|background-color|font-size)\s*:/.test(e)?`<span style="${B(e)}">${i()}</span>`:i()}case`code`:{if(n.closest(`pre`))return i();let e=i(),t=Math.max(0,...Array.from(e.matchAll(/`+/g),e=>e[0].length)),r="`".repeat(t+1),a=/^`|`$/.test(e)?` `:``;return`${r}${a}${e}${a}${r}`}case`pre`:{let e=n.querySelector(`code`),t=/language-(\S+)/.exec(e?.className||``);return`\n\n\`\`\`${t?t[1]:``}\n${Wn(e||n).replace(/\n$/,``)}\n\`\`\`\n\n`}case`blockquote`:{let e=i().trim().split(`
21
+ `)}function pi(e,t){let n=e.getAttribute(t)||``,r=/[\s()]/.test(n)?`<${n}>`:n,i=e.getAttribute(`title`);return i?`${r} "${i.replaceAll(`"`,String.raw`\"`)}"`:r}function mi(e,t=0){if(e.nodeType===3){let t=e.textContent.replace(/\s+/g,` `);return e.parentElement?.closest(`pre, code`)?t:li(t)}if(e.nodeType!==1)return``;let n=e,r=n.nodeName.toLowerCase(),i=()=>Array.from(n.childNodes).map(e=>mi(e,t)).join(``),a=(e,t=e)=>{let n=i();return n.trim()?`${e}${n}${t}`:n};switch(r){case`p`:case`div`:return`\n\n${di(i())}\n\n`;case`br`:return`
22
+ `;case`h1`:return`\n\n# ${i()}\n\n`;case`h2`:return`\n\n## ${i()}\n\n`;case`h3`:return`\n\n### ${i()}\n\n`;case`h4`:return`\n\n#### ${i()}\n\n`;case`h5`:return`\n\n##### ${i()}\n\n`;case`h6`:return`\n\n###### ${i()}\n\n`;case`strong`:case`b`:return a(`**`);case`em`:case`i`:return a(`*`);case`del`:case`s`:case`strike`:return a(`~~`);case`sup`:return a(`^`);case`sub`:return a(`~`);case`u`:return a(`<u>`,`</u>`);case`span`:{let e=n.getAttribute(`style`)||``;return/\b(color|background-color|font-size|font-family)\s*:/.test(e)?`<span style="${ea(e)}">${i()}</span>`:i()}case`code`:{if(n.closest(`pre`))return i();let e=i(),t=Math.max(0,...Array.from(e.matchAll(/`+/g),e=>e[0].length)),r="`".repeat(t+1),a=/^`|`$/.test(e)?` `:``;return`${r}${a}${e}${a}${r}`}case`pre`:{let e=n.querySelector(`code`),t=/language-(\S+)/.exec(e?.className||``);return`\n\n\`\`\`${t?t[1]:``}\n${ci(e||n).replace(/\n$/,``)}\n\`\`\`\n\n`}case`blockquote`:{let e=i().trim().split(`
21
23
  `);return`\n\n${e.filter((t,n)=>t.trim()!==``||(e[n-1]??``).trim()!==``).map(e=>e.trim()===``?`>`:`> ${e}`).join(`
22
- `)}\n\n`}case`a`:return`[${i()}](${Yn(n,`href`)})`;case`img`:return`![${Gn(n.getAttribute(`alt`)||``)}](${Yn(n,`src`)})`;case`ul`:{let e=Un(n,`li`);if(!e.length)return i();let r=` `.repeat(t),a=n.classList.contains(`an-checklist`),o=e.map(e=>{let n=Un(e,`input`).find(e=>e.getAttribute(`type`)===`checkbox`),i=`- `;return(a||n)&&(i=n&&n.checked?`- [x] `:`- [ ] `),`${r}${i}${Jn(e,t)}`}).join(`
23
- `);return t===0?`\n\n${o}\n\n`:`\n${o}`}case`ol`:{let e=Un(n,`li`);if(!e.length)return i();let r=` `.repeat(t),a=Number.parseInt(n.getAttribute(`start`)||`1`,10),o=Number.isFinite(a)?a:1,s=e.map((e,n)=>`${r}${o+n}. ${Jn(e,t)}`).join(`
24
+ `)}\n\n`}case`a`:return`[${i()}](${pi(n,`href`)})`;case`img`:return`![${li(n.getAttribute(`alt`)||``)}](${pi(n,`src`)})`;case`ul`:{let e=si(n,`li`);if(!e.length)return i();let r=` `.repeat(t),a=n.classList.contains(`an-checklist`),o=e.map(e=>{let n=si(e,`input`).find(e=>e.getAttribute(`type`)===`checkbox`),i=`- `;return(a||n)&&(i=n&&n.checked?`- [x] `:`- [ ] `),`${r}${i}${fi(e,t)}`}).join(`
25
+ `);return t===0?`\n\n${o}\n\n`:`\n${o}`}case`ol`:{let e=si(n,`li`);if(!e.length)return i();let r=` `.repeat(t),a=Number.parseInt(n.getAttribute(`start`)||`1`,10),o=Number.isFinite(a)?a:1,s=e.map((e,n)=>`${r}${o+n}. ${fi(e,t)}`).join(`
24
26
  `);return t===0?`\n\n${s}\n\n`:`\n${s}`}case`li`:return i();case`hr`:return`
25
27
 
26
28
  ---
27
29
 
28
- `;case`table`:{let e=Array.from(n.querySelectorAll(`tr`));if(!e.length)return i();let t=!!Un(n,`thead`)[0]||e[0].children.length>0&&Array.from(e[0].children).every(e=>e.tagName===`TH`),r=e.map(e=>Array.from(e.querySelectorAll(`th, td`)).map(e=>Gn(e.textContent.trim()).replaceAll(`|`,String.raw`\|`))),a=Math.max(...r.map(e=>e.length)),o=e=>{let t=[...e];for(;t.length<a;)t.push(``);return t},s=+!!t,c=t?o(r[0]):Array(a).fill(``),l=Array.from({length:a},(t,n)=>{let r=e[0]?.children[n],i=/text-align:\s*(left|center|right)/.exec(r?.getAttribute(`style`)||``)?.[1];return i===`center`?`:---:`:i===`right`?`---:`:i===`left`?`:---`:`---`}),u=`
30
+ `;case`table`:{let e=Array.from(n.querySelectorAll(`tr`));if(!e.length)return i();let t=!!si(n,`thead`)[0]||e[0].children.length>0&&Array.from(e[0].children).every(e=>e.tagName===`TH`),r=e.map(e=>Array.from(e.querySelectorAll(`th, td`)).map(e=>li(e.textContent.trim()).replaceAll(`|`,String.raw`\|`))),a=Math.max(...r.map(e=>e.length)),o=e=>{let t=[...e];for(;t.length<a;)t.push(``);return t},s=+!!t,c=t?o(r[0]):Array(a).fill(``),l=Array.from({length:a},(t,n)=>{let r=e[0]?.children[n],i=/text-align:\s*(left|center|right)/.exec(r?.getAttribute(`style`)||``)?.[1];return i===`center`?`:---:`:i===`right`?`---:`:i===`left`?`:---`:`---`}),u=`
29
31
 
30
32
  `;u+=`| ${c.join(` | `)} |\n`,u+=`| ${l.join(` | `)} |\n`;for(let e=s;e<r.length;e++)u+=`| ${o(r[e]).join(` | `)} |\n`;return u+`
31
- `}default:return i()}}function Zn(e){return String(e??``).replace(/^\ufeff/,``)}function Qn(e){let t=Zn(e);return/^#{1,6} [^\s]|^[ \t]*[-*+] [^\s]|^[ \t]*\d+[.)] [^\s]|^> ?[^\s]|^ {0,3}(?:`{3,}|~{3,})|^\*{2}[^*\n]+\*{2}/m.test(t)||/^.+\n=+\s*$/m.test(t)||/^.+\n-{2,}\s*$/m.test(t)||/^---[ \t]*\n(?:[\s\S]*?\n)?(?:---|\.\.\.)[ \t]*(?:\n|$)/.test(t)||/^\|.+\|[ \t]*\n\|[ \t:|-]+\|/m.test(t)||/^[^\n|]*\|[^\n]*\n[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)+$/m.test(t)||/!?\[[^\]\n]*\]\([^)\n]*\)/.test(t)&&/`[^`\n]+`|\*\*[^*\n]+\*\*|^#{1,6} |^[-*+] /m.test(t)}var $n=/^ {0,3}>( ?)(.*)$/,er=/^(?: {4}|\t)\s*\S/,tr=/^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`~][^\n]*)?$/;function nr(e){let t=tr.exec(e);if(!t)return null;let[,n,r,i=``]=t;return r[0]==="`"&&i.includes("`")?null:{marker:r[0],length:r.length,indent:n.length,lang:i.trim().split(/\s+/)[0]||``}}function rr(e,t){let n=0,r=0;for(;r<e.length&&n<t;){if(e[r]===` `){n+=1,r+=1;continue}if(e[r]===` `){let e=4-n%4;if(n+e>t)break;n+=e,r+=1;continue}break}return e.slice(r)}var ir=/^ {0,3}([-*_])( *\1){2,}\s*$/,ar=``;function or(e){let t=Zn(e).replaceAll(`\r
33
+ `}default:return i()}}function hi(e){return String(e??``).replace(/^\ufeff/,``)}function gi(e){let t=hi(e);return/^#{1,6} [^\s]|^[ \t]*[-*+] [^\s]|^[ \t]*\d+[.)] [^\s]|^> ?[^\s]|^ {0,3}(?:`{3,}|~{3,})|^\*{2}[^*\n]+\*{2}/m.test(t)||/^.+\n=+\s*$/m.test(t)||/^.+\n-{2,}\s*$/m.test(t)||/^---[ \t]*\n(?:[\s\S]*?\n)?(?:---|\.\.\.)[ \t]*(?:\n|$)/.test(t)||/^\|.+\|[ \t]*\n\|[ \t:|-]+\|/m.test(t)||/^[^\n|]*\|[^\n]*\n[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)+$/m.test(t)||/!?\[[^\]\n]*\]\([^)\n]*\)/.test(t)&&/`[^`\n]+`|\*\*[^*\n]+\*\*|^#{1,6} |^[-*+] /m.test(t)}var _i=/^ {0,3}>( ?)(.*)$/,vi=/^(?: {4}|\t)\s*\S/,yi=/^( {0,3})(`{3,}|~{3,})[ \t]*([^\s`~][^\n]*)?$/;function bi(e){let t=yi.exec(e);if(!t)return null;let[,n,r,i=``]=t;return r[0]==="`"&&i.includes("`")?null:{marker:r[0],length:r.length,indent:n.length,lang:i.trim().split(/\s+/)[0]||``}}function xi(e,t){let n=0,r=0;for(;r<e.length&&n<t;){if(e[r]===` `){n+=1,r+=1;continue}if(e[r]===` `){let e=4-n%4;if(n+e>t)break;n+=e,r+=1;continue}break}return e.slice(r)}var Si=/^ {0,3}([-*_])( *\1){2,}\s*$/,Ci=``;function wi(e){let t=hi(e).replaceAll(`\r
32
34
  `,`
33
35
  `).replaceAll(`\r`,`
34
36
  `).split(`
35
- `);t=ur(t);let n=dr(t);return t=n.clean,cr=n.linkDefs,lr=n.footnoteIds,sr(t)}function sr(e){let t=[],n=0;for(;n<e.length;){let r=e[n],i=nr(r);if(i){let r=RegExp(`^ {0,3}\\${i.marker}{${i.length},}[ \t]*$`),a=[];for(n++;n<e.length&&!r.test(e[n]);)a.push(Nr(rr(e[n],i.indent))),n++;let o=i.lang?` class="language-${B(i.lang)}"`:``;t.push(`<pre><code${o}>${a.join(`
36
- `)}</code></pre>`),n++;continue}if(er.test(r)){let r=[];for(;n<e.length&&(er.test(e[n])||e[n].trim()===``);){if(e[n].trim()===``){let t=n;for(;t<e.length&&e[t].trim()===``;)t++;if(t>=e.length||!er.test(e[t]))break;for(;n<t;n++)r.push(``);continue}r.push(Nr(rr(e[n],4))),n++}t.push(`<pre><code>${r.join(`
37
- `)}</code></pre>`);continue}if(r.trim()&&!ir.test(r)&&!/^#{1,6} /.test(r)&&n+1<e.length){if(/^=+\s*$/.test(e[n+1])){t.push(`<h1>${z(r.trim())}</h1>`),n+=2;continue}if(/^-{2,}\s*$/.test(e[n+1])){t.push(`<h2>${z(r.trim())}</h2>`),n+=2;continue}}if(ir.test(r)){t.push(`<hr>`),n++;continue}let a=/^(#{1,6})[ \t]+(.*)$/.exec(r);if(a){let e=a[1].length,r=a[2].replace(/(?:^|\s)#+\s*$/,``);t.push(`<h${e}>${z(r)}</h${e}>`),n++;continue}if($n.test(r)){let r=[];for(;n<e.length&&$n.test(e[n]);)r.push($n.exec(e[n])[2]),n++;t.push(`<blockquote>${sr(r)}</blockquote>`);continue}if(/^[-*+] /.test(r)){let{html:r,endIdx:i}=gr(e,n);t.push(r),n=i;continue}if(/^\d+[.)] /.test(r)){let{html:r,endIdx:i}=gr(e,n);t.push(r),n=i;continue}if(r.trim()===``){n++;continue}if(hr(e,n)){let i=L(r),a=L(e[n+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:e.startsWith(`:`)?`left`:null);n+=2;let o=[];for(;n<e.length&&e[n].trim()!==``&&mr(e[n]);)o.push(L(e[n])),n++;let s=(e,t,n)=>`<${e}${n?` style="text-align:${n}"`:``}>${z(t)}</${e}>`,c=`<thead><tr>${i.map((e,t)=>s(`th`,e,a[t])).join(``)}</tr></thead>`,l=o.length?`<tbody>${o.map(e=>`<tr>${e.map((e,t)=>s(`td`,e,a[t])).join(``)}</tr>`).join(``)}</tbody>`:``;t.push(`<table>${c}${l}</table>`);continue}let o=[];for(;n<e.length&&e[n].trim()!==``&&!/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n])&&!nr(e[n])&&!$n.test(e[n])&&!ir.test(e[n])&&!hr(e,n)&&!(n+1<e.length&&/^=+\s*$/.test(e[n+1]))&&!(n+1<e.length&&/^-{2,}\s*$/.test(e[n+1]));)o.push(e[n]),n++;o.length?t.push(`<p>${z(fr(o)).replaceAll(ar,`<br>`)}</p>`):(t.push(`<p>${z(r)}</p>`),n++)}return t.join(``)}var cr=new Map,lr=new Set;function ur(e){if((e[0]||``).trim()!==`---`)return e;let t=-1;for(let n=1;n<e.length;n++){let r=e[n].trim();if(r===`---`||r===`...`){t=n;break}}if(t===-1||!e.slice(1,t).every(e=>e.trim()===``||/^[ \t]*[\w$.-]+\s*:(\s|$)/.test(e)||/^[ \t]*-\s+\S/.test(e)||/^[ \t]+\S/.test(e)))return e;let n=t+1;return e[n]!==void 0&&e[n].trim()===``&&n++,e.slice(n)}function dr(e){let t=new Map,n=new Set,r=[],i=!1,a=/^\[([^\]]+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/,o=/^\[\^([^\]]+)\]:[ \t]*(\S.*)$/;for(let s of e){if(i){/^ {0,3}(?:`{3,}|~{3,})[ \t]*$/.test(s)&&(i=!1),r.push(s);continue}if(nr(s)){i=!0,r.push(s);continue}{let e=o.exec(s);if(e){n.add(e[1]);continue}let r=a.exec(s);if(r){t.set(r[1].trim().toLowerCase(),{href:r[2],title:r[3]});continue}}r.push(s)}return{clean:r,linkDefs:t,footnoteIds:n}}function fr(e){let t=``;for(let n=0;n<e.length;n++){let r=n===e.length-1,i=e[n].replace(/^[ \t]+/,``);if(!r&&/\\$/.test(i)){t+=i.replace(/\\$/,``)+ar;continue}if(!r&&/ {2,}$/.test(i)){t+=i.replace(/ {2,}$/,``)+ar;continue}t+=i+(r?``:` `)}return t}function pr(e){return L(e).length}function mr(e){return e.includes(`|`)?/^\s*\|/.test(e)||pr(e)>1:!1}function hr(e,t){let n=e[t],r=e[t+1];if(r===void 0||!n.includes(`|`))return!1;if(/^\|.+\|/.test(n))return/^\|[\s|:-]+\|/.test(r);let i=L(r);return i.length<2||!i.every(e=>/^:?-+:?$/.test(e))?!1:pr(n)===i.length}function L(e){let t=e.replace(/^\|/,``).replace(/\|$/,``),n=[],r=``;for(let e=0;e<t.length;e++){if(t[e]===`\\`&&t[e+1]===`|`){r+=`|`,e++;continue}if(t[e]===`|`){n.push(r),r=``;continue}r+=t[e]}return n.push(r),n.map(e=>e.trim())}function gr(e,t){let n=e[t].match(/^(\s*)/)[1].length,r=/^\s*\d+[.)] /.test(e[t]),i=[],a=null,o=!1,s=!1,c=t;for(;c<e.length;){let t=e[c];if(t.trim()===``){let t=e[c+1],a=t===void 0?-1:t.match(/^(\s*)/)[1].length,l=t!==void 0&&/^\s*(?:[-*+]|\d+[.)]) /.test(t)&&/^\s*\d+[.)] /.test(t)===r&&a===n,u=t!==void 0&&t.trim()!==``&&a>n;if(!i.length||!l&&!u)break;o=!0,s=!0,c++;continue}let l=t.match(/^(\s*)/)[1].length;if(l<n)break;if(l===n){if(!/^\s*(?:[-*+]|\d+[.)]) /.test(t)||/^\s*\d+[.)] /.test(t)!==r)break;let e=r?t.replace(/^\s*\d+[.)] /,``):t.replace(/^\s*[-*+] /,``),n=!r&&/^\[[ xX]\]\s+/.test(e);if(a===null&&(a=n),n!==a)break;let o=n&&e[1].toLowerCase()===`x`,l=n?e.replace(/^\[[ xX]\]\s+/,``):e;i.push({paras:[l],isCB:n,checked:o,sub:``}),s=!1,c++}else{if(!i.length){c++;continue}let n=e=>rr(e,l),r=nr(n(t));if(r){let t=RegExp(`^ {0,3}\\${r.marker}{${r.length},}[ \t]*$`),a=[n(e[c])];for(c++;c<e.length&&!t.test(n(e[c]));)a.push(n(e[c])),c++;c<e.length&&(a.push(n(e[c])),c++),i[i.length-1].sub+=sr(a),s=!1;continue}if(/^\s*(?:[-*+]|\d+[.)]) /.test(t)){let t=gr(e,c);i[i.length-1].sub+=t.html,c=t.endIdx,s=!1}else if(s)i[i.length-1].paras.push(t.trim()),s=!1,c++;else{let e=i[i.length-1].paras;e[e.length-1]+=` `+t.trim(),c++}}}let l=!r&&a===!0,u=r?/^\s*(\d+)[.)] /.exec(e[t]):null,d=u?Number.parseInt(u[1],10):1,f=r?d===1?`<ol>`:`<ol start="${d}">`:l?`<ul class="an-checklist">`:`<ul>`,p=r?`</ol>`:`</ul>`;return{html:`${f}${i.map(({paras:e,isCB:t,checked:n,sub:r})=>{let i=t?`<input type="checkbox" contenteditable="false"${n?` checked`:``}>`:``;return`<li>${o?e.map((e,t)=>`<p>${t===0?i:``}${z(e)}</p>`).join(``):`${i}${z(e[0])}`}${r}</li>`}).join(``)}${p}`,endIdx:c}}var _r=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,R=`\0`,vr=``,yr=/(`+)([^]*?)\1/g;function br(e){let t=[];return{text:e.replace(yr,(e,n,r)=>r===``?e:(t.push(r),`${vr}${t.length-1}${vr}`)),codes:t}}function xr(e,t,n){return e.replace(RegExp(`${vr}(\\d+)${vr}`,`g`),(e,r)=>{let i=t[Number(r)];return i=i.replace(RegExp(`${R}(\\d+)${R}`,`g`),(e,t)=>`\\${n[Number(t)]}`),i.length>2&&i.startsWith(` `)&&i.endsWith(` `)&&i.trim()!==``&&(i=i.slice(1,-1)),`<code>${Nr(i)}</code>`})}function Sr(e){let t=[];return{text:e.replace(_r,(e,n)=>(t.push(n),`${R}${t.length-1}${R}`)),literals:t}}function Cr(e,t){return e.replace(RegExp(`${R}(\\d+)${R}`,`g`),(e,n)=>Mr(t[Number(n)]))}var wr=String.raw`(&lt;.*?&gt;(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`,Tr=new RegExp(String.raw`!\[([^\]]*)\]\(${wr}\)`,`g`),Er=new RegExp(String.raw`\[([^\]]+)\]\(${wr}\)`,`g`);function Dr(e){let t=e.trim(),n=/^&lt;([\s\S]*?)&gt;(?:[ \t]*(?:"([^"]*)"|'([^']*)'))?[ \t]*$/.exec(t);if(n)return{href:n[1],title:n[2]??n[3]??``};let r=/^(\S+)\s+(?:"([^"]*)"|'([^']*)')\s*$/.exec(t);return r?{href:r[1],title:r[2]??r[3]??``}:{href:t,title:``}}function Or(e){return e=e.replace(Tr,(e,t,n)=>{let{href:r,title:i}=Dr(n),a=i?` title="${V(i)}"`:``;return`<img src="${V(r)}" alt="${V(t)}"${a} class="an-image">`}),e=e.replace(Er,(e,t,n)=>{let{href:r,title:i}=Dr(n),a=i?` title="${V(i)}"`:``;return`<a href="${V(r)}"${a}>${t}</a>`}),e=e.replace(/\[([^\]]+)\]\[([^\]]*)\]/g,(e,t,n)=>{let r=cr.get(Pr(n||t).trim().toLowerCase());if(!r)return e;let i=r.title?` title="${B(r.title)}"`:``;return`<a href="${B(r.href)}"${i}>${t}</a>`}),e=e.replace(/\[([^\]]+)\]/g,(e,t)=>{let n=cr.get(Pr(t).trim().toLowerCase());if(!n)return e;let r=n.title?` title="${B(n.title)}"`:``;return`<a href="${B(n.href)}"${r}>${t}</a>`}),e=e.replace(/\[\^([^\]]+)\]/g,(e,t)=>lr.has(Pr(t))?`<sup>[${t}]</sup>`:e),e}function kr(e){return e=e.replace(/&lt;(https?:\/\/[^\s&]+?)&gt;/g,(e,t)=>`<a href="${V(t)}">${t}</a>`),e=e.replace(/&lt;([\w.!#$%&'*+/=?^`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+)&gt;/g,(e,t)=>`<a href="mailto:${V(t)}">${t}</a>`),e=e.replace(/(^|[\s(])(https?:\/\/[^\s()]+)/g,(e,t,n)=>{let r=/[.,;:!?)]+$/.exec(n),i=r?n.slice(0,-r[0].length):n;if(!i)return e;let a=r?r[0]:``;return`${t}<a href="${V(i)}">${i}</a>${a}`}),e}function Ar(e){return e=e.replace(/\*{3}([^*\n]+?)\*{3}/g,(e,t)=>`<strong><em>${t}</em></strong>`),e=e.replace(/(?<!\w)_{3}([^_\n]+?)_{3}(?!\w)/g,(e,t)=>`<strong><em>${t}</em></strong>`),e=e.replace(/\*{2}([^*\n]+?)\*{2}/g,(e,t)=>`<strong>${t}</strong>`),e=e.replace(/(?<!\w)_{2}([^_\n]+?)_{2}(?!\w)/g,(e,t)=>`<strong>${t}</strong>`),e=e.replace(/\*([^*\n]+?)\*/g,(e,t)=>`<em>${t}</em>`),e=e.replace(/(?<!\w)_([^_\n]+?)_(?!\w)/g,(e,t)=>`<em>${t}</em>`),e=e.replace(/~~([^~\n]+?)~~/g,(e,t)=>`<del>${t}</del>`),e}function z(e){let{text:t,literals:n}=Sr(e),{text:r,codes:i}=br(t),a=Mr(r);return a=Or(a),a=kr(a),a=Ar(a),xr(Cr(a,n),i,n)}var jr=/&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;function Mr(e){return String(e).replace(jr,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function Nr(e){return String(e).replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function B(e){return String(e).replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&#39;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function V(e){return String(e).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&#39;`)}function Pr(e){return String(e).replaceAll(`&lt;`,`<`).replaceAll(`&gt;`,`>`).replaceAll(`&amp;`,`&`)}var Fr=5,Ir=2,Lr=[[`typescript`,`javascript`],[`scss`,`css`],[`cpp`,`c`]],Rr=[{lang:`php`,w:10,re:/<\?php\b|<\?=/},{lang:`bash`,w:10,re:/^#!.*\/(?:ba|z|da|fi|k)?sh\b/m},{lang:`rust`,w:10,re:/\b(?:println!|print!|format!|vec!|panic!)\s*[([]/},{lang:`go`,w:10,re:/\bfmt\.(?:Print|Println|Printf|Sprintf|Errorf|Fprintf)\s*\(/},{lang:`java`,w:10,re:/\bSystem\.out\.(?:print|println)\s*\(/},{lang:`csharp`,w:10,re:/\bConsole\.(?:Write|WriteLine)\s*\(/},{lang:`cpp`,w:10,re:/\b(?:cout|cerr)\s*<<|\bcin\s*>>|\busing\s+namespace\s+std\b|\bstd::\w/},{lang:`python`,w:10,re:/\bdef[ \t]+\w+[ \t]*\([^)]*\)[ \t]*(?:->[^:\n]*)?:|\bif[ \t]+__name__[ \t]*==[ \t]*['"]__main__['"]/},{lang:`html`,w:10,re:/^\s*<!DOCTYPE\s+html/i},{lang:`xml`,w:10,re:/^\s*<\?xml\s/i},{lang:`javascript`,w:6,re:/\bconsole\.(?:log|error|warn|info|debug)\s*\(/},{lang:`javascript`,w:6,re:/\b(?:const|let)\s+\w+\s*=|(?:^|\n)\s*var\s+\w+\s*=/},{lang:`javascript`,w:8,re:/\bexport\s+(?:default|const|function|class|async|\{|\*)|\bmodule\.exports\b|\brequire\s*\(\s*['"]/},{lang:`javascript`,w:5,re:/\bfunction(?:[ \t]+\w+)?[ \t]*\([^)]*\)[ \t]*\{|=>[ \t]*[{([`\w'"]/},{lang:`javascript`,w:5,re:/\bimport\b[^'"\n]*[ \t]from[ \t]*['"]/},{lang:`javascript`,w:4,re:/\.(?:map|filter|forEach|reduce|then|catch|find|some|every)\s*\(/},{lang:`javascript`,w:4,re:/\b(?:document|window|globalThis)\.\w/},{lang:`javascript`,w:4,re:/\baddEventListener\s*\(|\bquerySelector(?:All)?\s*\(|\bgetElementById\s*\(/},{lang:`javascript`,w:3,re:/\.(?:innerHTML|textContent|classList|dataset|style)\b|\bJSON\.(?:parse|stringify)\s*\(/},{lang:`javascript`,w:4,re:/\bawait\s+\w|\basync\s+(?:function|\(|\w+\s*=>)|\bnew\s+Promise\s*\(/},{lang:`javascript`,w:3,re:/\bReact\.|\buseState\s*\(|\buseEffect\s*\(/},{lang:`typescript`,w:8,re:/\binterface\s+\w+(?:<[^>]*>)?\s*(?:extends\s[\w<>, ]+)?\{/},{lang:`typescript`,w:8,re:/\btype\s+\w+(?:<[^>]*>)?\s*=/},{lang:`typescript`,w:7,re:/:\s*(?:string|number|boolean|void|never|any|unknown|object)\b/},{lang:`typescript`,w:6,re:/\benum\s+\w+\s*\{|\breadonly\s+\w|\bimplements\s+\w|\bnamespace\s+\w+\s*\{/},{lang:`typescript`,w:6,re:/\b(?:private|public|protected)\s+(?:readonly\s+)?\w+\s*[:?]/},{lang:`typescript`,w:5,re:/\)\s*:\s*[A-Z]\w*(?:<[^>]*>)?\s*(?:\{|=>)|\)\s*:\s*(?:string|number|boolean|void)\b/},{lang:`typescript`,w:4,re:/\bfunction\s+\w+\s*<[^>]+>\s*\(|\bas\s+(?:const\b|[A-Z]\w*)/},{lang:`typescript`,w:3,re:/\w\?\s*:\s*\w|\bimport\s+type\b|\bsatisfies\b/},{lang:`python`,w:6,re:/(?:^|\n)\s*(?:from\s+[\w.]+\s+import\s|import\s+\w+(?:\s*,\s*\w+)*\s*$)/m},{lang:`python`,w:6,re:/(?:^|\n)\s*class\s+\w+(?:\([\w., ]*\))?\s*:/},{lang:`python`,w:5,re:/(?:^|\n)\s*(?:with|elif|except|finally|async\s+def)\b[^\n]*:/},{lang:`python`,w:5,re:/\bself\.\w|\b__init__\b|\bf["'][^"']*\{/},{lang:`python`,w:4,re:/(?:^|\n)[ \t]*for[ \t]+\w+[ \t]+in[ \t][^\n:]*:|\bfor[ \t]+\w+[ \t]+in[ \t]+range[ \t]*\(/},{lang:`python`,w:4,re:/\bprint\s*\(|\blen\s*\(|\brange\s*\(/},{lang:`python`,w:3,re:/\[[^\]\n]*\bfor\s+\w+\s+in\s[^\]\n]*\]|\bNone\b|\bTrue\b|\bFalse\b/},{lang:`python`,w:3,re:/\*\*\w|\bdict[ \t]*\(|\blambda(?:[ \t]+\w+)?[ \t]*:/},{lang:`go`,w:8,re:/(?:^|\n)\s*package\s+\w+\s*$/m},{lang:`go`,w:6,re:/\btype\s+\w+\s+struct\s*\{|\btype\s+\w+\s+interface\s*\{/},{lang:`go`,w:6,re:/\bfunc(?:[ \t]*\([^)]*\))?(?:[ \t]+\w+)?[ \t]*\([^)]*\)[^\n{]{0,40}\{/},{lang:`go`,w:5,re:/\bif\s+err\s*!=\s*nil\b|\berr\s*:=\s|\bdefer\s+\w/},{lang:`go`,w:4,re:/\w+\s*:=\s*\S|\bchan\s+\w|\bgo\s+func\b|\bnil\b/},{lang:`rust`,w:7,re:/\bfn[ \t]+\w+(?:<[^>]*>)?[ \t]*\([^)]*\)[^\n{]{0,40}\{/},{lang:`rust`,w:7,re:/\blet\s+mut\s+\w|\bpub\s+(?:fn|struct|enum|mod|use)\b|\bimpl\s+\w/},{lang:`rust`,w:5,re:/\buse\s+(?:std|crate|self|super)::|\bmatch\s+\w+\s*\{[^}]*=>/},{lang:`rust`,w:4,re:/\b(?:Option|Result|Vec|Box|Rc|Arc|HashMap)\s*<|&(?:mut\s+)?self\b|\b\w+::<|->\s*Result</},{lang:`rust`,w:3,re:/\b(?:i8|i16|i32|i64|u8|u16|u32|u64|usize|isize|f32|f64)\b|\bunwrap\s*\(\)|\bderive\s*\(/},{lang:`java`,w:7,re:/\b(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)?(?:void|int|long|double|boolean|String|[A-Z]\w*(?:<[^>]*>)?)\s+\w+\s*[({]/},{lang:`java`,w:7,re:/\bimport\s+(?:java|javax|org\.springframework)\.[\w.]+;/},{lang:`java`,w:6,re:/@(?:Override|Autowired|Component|Service|Controller|RestController|Entity|Test|SpringBootApplication)\b/},{lang:`java`,w:5,re:/\bnew\s+(?:ArrayList|HashMap|HashSet|LinkedList|StringBuilder)\s*<[^>]*>\s*\(|\bthrows\s+\w*Exception/},{lang:`java`,w:4,re:/\bpublic\s+(?:class|interface|enum)\s+\w|\bextends\s+\w+\s*\{|\bList<\w|\bMap<\w/},{lang:`csharp`,w:8,re:/\busing\s+System(?:\.[\w.]+)?\s*;|\bnamespace\s+[\w.]+\s*[{;]/},{lang:`csharp`,w:8,re:/\{\s*get;\s*(?:private\s+)?set;\s*\}|\b(?:public|private|protected|internal)\s+(?:static\s+)?async\s+Task(?:<[^>]*>)?\s+\w/},{lang:`csharp`,w:6,re:/\basync\s+Task(?:<[^>]*>)?\s+\w|\bawait\s+\w+\.\w+Async\s*\(/},{lang:`csharp`,w:5,re:/\bIEnumerable<|\bvar\s+\w+\s*=\s*new\s+\w|\bpublic\s+override\b|\[\s*(?:HttpGet|HttpPost|Serializable|Required)\s*\]/},{lang:`csharp`,w:3,re:/\.(?:Select|Where|FirstOrDefault|ToList|Any)\s*\(|\bstring\[\]\s+args\b/},{lang:`kotlin`,w:8,re:/\bfun\s+\w+\s*\([^)]*\)\s*(?::\s*[\w<>?.]+\s*)?[={]|\bdata\s+class\s+\w/},{lang:`kotlin`,w:6,re:/\bval[ \t]+\w+(?:[ \t]*:[ \t]*[\w<>?.]+)?[ \t]*=|\bcompanion[ \t]+object\b|\bsuspend[ \t]+fun\b/},{lang:`kotlin`,w:4,re:/\bprintln\s*\(|\bwhen\s*\([^)]*\)\s*\{|\bobject\s+\w+\s*[:{]|\?:\s*\w/},{lang:`swift`,w:8,re:/\bguard\s+(?:let|var)\s[^\n]*\belse\b|\bfunc\s+\w+\s*\([^)]*\)\s*(?:async\s+)?(?:throws\s+)?->\s*[\w<>?[\]]/},{lang:`swift`,w:6,re:/\bprotocol[ \t]+\w+[^\n{]{0,40}\{|\bextension[ \t]+\w+[^\n{]{0,40}\{|\bimport[ \t]+(?:SwiftUI|UIKit|Foundation)\b/},{lang:`swift`,w:6,re:/\b(?:let|var)\s+\w+\s*:\s*(?:Int|String|Double|Float|Bool|Character|Any|\[[A-Z])|@(?:State|Binding|Published|IBOutlet|objc)\b/},{lang:`swift`,w:4,re:/\\\(\w|\bif[ \t]+let[ \t]+\w|\bstruct[ \t]+\w+[ \t]*:[ \t]*View\b|\bfunc[ \t]+\w+[ \t]*\([^)]*:[ \t]*[A-Z]/},{lang:`swift`,w:3,re:/\?\?\s*\w|\b\w+\?\.\w|\bself\.\w+\s*=/},{lang:`cpp`,w:8,re:/#include\s*<(?:iostream|vector|map|set|algorithm|string|memory|utility)>/},{lang:`cpp`,w:6,re:/\btemplate\s*<\s*(?:typename|class)\b|\bnullptr\b|\bnamespace\s+\w+\s*\{/},{lang:`c`,w:8,re:/#include\s*<(?:stdio|stdlib|string|math|time|ctype|unistd)\.h>/},{lang:`c`,w:6,re:/\b(?:printf|scanf|malloc|calloc|free|memcpy|strlen)\s*\(/},{lang:`c`,w:4,re:/\bint\s+main\s*\(\s*(?:void|int\s+argc|\)\s*\{)/},{lang:`c`,w:3,re:/\btypedef\s+struct\b|\bsizeof\s*\(|\bNULL\b/},{lang:`ruby`,w:8,re:/\bdo[ \t]*\|[ \t]*\w[\w, ]*\|/},{lang:`ruby`,w:7,re:/\battr_(?:accessor|reader|writer)\s+:|\brequire(?:_relative)?\s+['"]|\bputs\s+\S/},{lang:`ruby`,w:4,re:/(?:^|\n)[ \t]*def[ \t]+\w/},{lang:`ruby`,w:4,re:/(?:^|\n)[ \t]*end[ \t]*$/m},{lang:`ruby`,w:4,re:/\bnil\?\b|\b\w+\.new\b|=>\s*['"\w]|\bmodule\s+[A-Z]\w*\s*$/m},{lang:`ruby`,w:3,re:/:\w+[ \t]*=>|\bend[ \t]*$/m},{lang:`php`,w:7,re:/\$this->\w|\bfunction\s+\w+\s*\([^)]*\$\w/},{lang:`php`,w:6,re:/\$\w+\s*=\s*\S|\bforeach\s*\(\s*\$\w+\s+as\s+\$/},{lang:`php`,w:5,re:/\becho[ \t][^;\n]*[$'"]|\bnamespace[ \t]+[\w\\]+;|\buse[ \t]+[\w\\]+\\\w+;/},{lang:`php`,w:8,re:/\b(?:public|private|protected)\s+(?:static\s+)?function\s+\w/},{lang:`php`,w:3,re:/->\w+\s*\(|::\w+\s*\(/},{lang:`html`,w:7,re:/<(?:html|head|body|nav|section|article|header|footer|main|form)\b[^>]*>/i},{lang:`html`,w:5,re:/<(?:div|p|span|a|img|ul|ol|li|table|tr|td|input|button|h[1-6])\b[^>]*>[\s\S]*<\/(?:div|p|span|a|ul|ol|li|table|tr|td|button|h[1-6])>/i},{lang:`html`,w:4,re:/<\w+\s+(?:class|id|href|src|type|style)\s*=\s*["']/i},{lang:`xml`,w:6,re:/\bxmlns(?::\w+)?\s*=\s*["']|<\/\w+:\w+>|<\w+:\w+[\s>]/},{lang:`json`,w:8,re:/^\s*[{[][\s\S]*"[\w-]+"\s*:\s*(?:"[^"]*"|-?\d|\{|\[|true|false|null)/},{lang:`json`,w:3,re:/^\s*\{[\s\S]*\}\s*$|^\s*\[[\s\S]*\]\s*$/},{lang:`yaml`,w:8,re:/^---\s*$/m},{lang:`yaml`,w:6,re:/^[ \t]*-\s+\w+\s*:\s*\S/m},{lang:`yaml`,w:5,re:/^[a-z_][\w-]*[ \t]*:(?:[ \t]*$|[ \t]+(?:[|>][-+]?[ \t]*$|['"\w[{]))/im},{lang:`yaml`,w:4,re:/^[ \t]+[a-z_][\w-]*[ \t]*:[ \t]*\S/im},{lang:`yaml`,w:3,re:/^[ \t]*-\s+\S/m},{lang:`markdown`,w:7,re:/^#{1,6}\s+\S/m},{lang:`markdown`,w:6,re:/^```|^\|[^\n|]+\|[^\n]*\n\s*\|[\s:|-]+\|/m},{lang:`markdown`,w:4,re:/\[[^\]\n]+\]\([^)\n]+\)|!\[[^\]\n]*\]\(/},{lang:`markdown`,w:3,re:/\*\*[^*\n]+\*\*|^>\s+\S|^[-*+]\s+\S/m},{lang:`sql`,w:9,re:/(?:^|\n)\s*(?:SELECT\s+[\w*]|INSERT\s+INTO\s|UPDATE\s+\w+\s+SET\s|DELETE\s+FROM\s)/i},{lang:`sql`,w:8,re:/(?:^|\n)\s*(?:CREATE|ALTER|DROP)\s+(?:TABLE|DATABASE|INDEX|VIEW|SCHEMA)\b/i},{lang:`sql`,w:4,re:/\b(?:INNER|LEFT|RIGHT|FULL)\s+(?:OUTER\s+)?JOIN\b|\bGROUP\s+BY\b|\bORDER\s+BY\b|\bWITH\s+\w+\s+AS\s*\(/i},{lang:`scss`,w:9,re:/^[ \t]*\$[\w-]+[ \t]*:[^;\n]+;|@(?:mixin|include|extend|use|forward)[ \t]+[\w"'-]/m},{lang:`scss`,w:7,re:/^[ \t]*&[\s.:[&>+~]|#\{[^}]*\}/m},{lang:`scss`,w:4,re:/^[ \t]*\/\/[ \t]*\S/m},{lang:`css`,w:6,re:/^[ \t]*(?!(?:export|import|return|function|const|let|var|val|if|else|for|while|switch|case|class|new|public|private|protected|internal|def|func|fun|fn|pub|package|type|interface|enum|struct|impl|trait|mod|use|using|namespace|module|data|object|async|await|guard|extension|protocol|template|typedef)\b)[.#]?[\w-]+[^{}\n]{0,60}\{[^{}:]*:[^{};]+[;}]/m},{lang:`css`,w:5,re:/@(?:media|supports|keyframes|font-face|import|charset)\b/},{lang:`css`,w:4,re:/:\s*(?:#[\da-f]{3,8}|\d+(?:px|rem|em|%|vh|vw)|flex|grid|block|none|absolute|relative)\s*[;}]/i},{lang:`css`,w:3,re:/::?(?:hover|focus|active|before|after|first-child|last-child|nth-child)\b/},{lang:`bash`,w:7,re:/(?:^|\n|&&|\|\|)\s*(?:sudo\s+)?(?:apt(?:-get)?|yum|brew|npm|pnpm|yarn|pip3?|docker|kubectl|git|systemctl|curl|wget|chmod|chown|mkdir|rm|cp|mv|tar|ssh|scp)\s+[\w./-]/},{lang:`bash`,w:6,re:/^\s*(?:export|source|alias)\s+\w+|^\s*\w+=\S+\s*$/m},{lang:`bash`,w:6,re:/\bfi[ \t]*$|(?:^|\n)[ \t]*(?:if|for|while)[ \t][^\n]*;[ \t]*(?:then|do)\b|(?:^|\n)[ \t]*done\b/m},{lang:`bash`,w:5,re:/\$\{?\w+\}?[/:]|"\$\w|\becho\s+["'$]|\$\(\w/},{lang:`bash`,w:4,re:/(?:^|\n|\|)\s*(?:grep|awk|sed|cat|ls|cd|pwd|find|xargs|head|tail|sort|uniq|wc)\s+[-\w$'"./]/},{lang:`bash`,w:3,re:/\s\|[ \t]*\w|\s&&\s|\s2>&1|\s-[\w-]+\s/}],zr=4e3;function Br(e){if(e.length<=zr)return e;let t=e.slice(0,zr),n=t.lastIndexOf(`
38
- `);return n>0?t.slice(0,n):t}function Vr(e){if(!e?.trim())return null;let t=Br(e.trim()),n=new Map;for(let{lang:e,re:r,w:i}of Rr)r.test(t)&&n.set(e,(n.get(e)||0)+i);if(n.size===0)return null;for(let[e,t]of Lr){let r=n.get(e);r&&n.set(e,r+(n.get(t)||0))}let r=[...n.entries()].sort((e,t)=>t[1]-e[1]),[i,a]=r[0],o=r[1]?.[1]??0;return a<Fr||a-o<Ir?null:i}var Hr=new Set([`PRE`,`BLOCKQUOTE`,`TABLE`,`FIGURE`,`UL`,`OL`,`HR`]),Ur={undo:{run:e=>e.undo()},redo:{run:e=>e.redo()},bold:{run:e=>e.bold()},italic:{run:e=>e.italic()},underline:{run:e=>e.underline()},inlineCode:{run:e=>e.inlineCode()},link:{run:e=>e.context.invoke(`linkDialog.show`)},find:{run:e=>e.context.invoke(`findReplace.show`,`find`)},findReplace:{run:e=>e.context.invoke(`findReplace.show`,`replace`)},shortcuts:{run:e=>e.context.invoke(`shortcutsDialog.show`)},pastePlainText:{run:e=>e.context.invoke(`clipboard.setForcePlain`,!0),preventDefault:!1}},Wr=class{constructor(e){this.context=e,this.options=e.options,this._history=null,this._disposers=[],this._snapshotTimer=null,this._limitCounter=null}initialize(){let e=this.context.layoutInfo.editable;return this._history=new yn(e,this.options.historyLimit||100,this.options.historyMaxBytes||10485760),this._bindEvents(e),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._history=null,clearTimeout(this._snapshotTimer),this._snapshotTimer=null}_bindEvents(e){let t=e=>this._onKeydown(e),n=()=>this.afterCommand(),r=e=>this._enforceLimit(e),i=()=>{if(!this.context._alive)return;let t=globalThis.getSelection();t?.rangeCount>0&&e.contains(t.anchorNode)&&(this.context.invoke(`toolbar.refresh`),this.context.triggerEvent(`selectionChange`,this.context))},a=e=>{e.target.type===`checkbox`&&e.target.closest(`.an-checklist`)&&this.afterCommand()},o=t=>{let n=globalThis.getSelection();if(!n?.rangeCount)return;let r=n.getRangeAt(0);if(!r.collapsed)return;let i=r.startContainer;if(i.nodeType!==Node.ELEMENT_NODE)return;let a=i,o=a.matches(`.an-checklist li`)?a:null;if(!o)return;let s=o.querySelector(`input[type="checkbox"]`);if(!s)return;if(t?.type===`mouseup`){let r=null;if(document.caretRangeFromPoint)r=document.caretRangeFromPoint(t.clientX,t.clientY);else if(document.caretPositionFromPoint){let e=document.caretPositionFromPoint(t.clientX,t.clientY);e&&(r=document.createRange(),r.setStart(e.offsetNode,e.offset))}if(r&&e.contains(r.startContainer)&&r.startContainer!==o){r.collapse(!0),n.removeAllRanges(),n.addRange(r);return}}let c=document.createRange(),l=null;for(let e of o.childNodes)if(e!==s&&e.nodeType===Node.TEXT_NODE){l=e;break}l?c.setStart(l,0):c.setStartAfter(s),c.collapse(!0),n.removeAllRanges(),n.addRange(c)},s=()=>this.context.layoutInfo.container.classList.contains(`an-disabled`);this._disposers.push(v(e,`keydown`,t),v(e,`beforeinput`,r),v(e,`input`,n),v(document,`selectionchange`,i),v(e,`click`,a),v(e,`mouseup`,o),v(e,`keyup`,o),v(e,`dragstart`,e=>{if(s()){e.preventDefault();return}let t=e.target;t&&(t.nodeName===`IFRAME`||t.closest(`.an-video-wrapper`))&&e.preventDefault()}),v(e,`drop`,e=>{s()&&e.preventDefault()}));let c=null;this._disposers.push(v(e,`compositionstart`,()=>{let e=globalThis.getSelection();if(!e?.rangeCount){c=null;return}let t=e.getRangeAt(0).startContainer;if(t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),t){let e=t;c=e.closest(`sup`)?`superscript`:e.closest(`sub`)?`subscript`:null}}),v(e,`compositionend`,()=>{let e=c;if(c=null,!e)return;let t=globalThis.getSelection();if(!t?.rangeCount)return;let n=t.getRangeAt(0).startContainer;n.nodeType===Node.TEXT_NODE&&(n=n.parentElement);let r=n;(e===`superscript`?r?.closest(`sup`):r?.closest(`sub`))||document.execCommand(e)}))}_onKeydown(e){let t=this.context.layoutInfo.editable;Pn(e,t,this.options)||this._runShortcut(e)}_runShortcut(e){if(!e.ctrlKey&&!e.metaKey&&!e.altKey)return!1;for(let t of this.getKeyBindings()){if(!Tn(e,t.parsed))continue;let{command:n}=t,r=typeof n==`string`?n:t.combo;if(this.context.triggerEvent(`beforeCommand`,{name:r,source:`shortcut`,event:e})===!1)return e.preventDefault(),!0;if(typeof n==`function`)return n(this.context,e)!==!1&&e.preventDefault(),!0;let i=Ur[n];if(i)return i.preventDefault!==!1&&e.preventDefault(),i.run(this),!0;let a=Ue(n,this.options);return a&&typeof a.action==`function`&&!a.type?(e.preventDefault(),a.action(this.context),this.afterCommand(),!0):(console.warn(`[AutumnNote] keyMap: unknown command "${n}".`),!1)}return!1}getKeyBindings(){return(!this._keyBindings||this._keyMapSource!==this.options.keyMap)&&(this._keyMapSource=this.options.keyMap,this._keyBindings=En(this.options.keyMap)),this._keyBindings}_enforceLimit(e){let t=this.options.maxChars||0,n=this.options.maxWords||0;if(!t&&!n)return;this._limitCounter??=new Bn;let r=e.inputType||``;if(r.startsWith(`delete`)||r===`historyUndo`||r===`historyRedo`||r===`insertFromPaste`||r===`insertFromDrop`||!r.startsWith(`insert`))return;let{words:i,chars:a}=this._limitCounter.counts(this.context.layoutInfo.editable);if(t&&a>=t){e.preventDefault(),this.context.triggerEvent(`charLimitReached`,this.context);return}n&&(e.data===` `||r===`insertParagraph`||r===`insertLineBreak`)&&i>=n&&(e.preventDefault(),this.context.triggerEvent(`wordLimitReached`,this.context))}afterCommand(){this._cleanOrphanedFigures(),this._ensureTrailingParagraph(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this._scheduleSnapshot()}_scheduleSnapshot(){clearTimeout(this._snapshotTimer),this._snapshotTimer=setTimeout(()=>{this._snapshotTimer=null,this._history&&this._history.recordUndo(),this.context.triggerEvent(`change`,this.getHTML())},400)}_cleanOrphanedFigures(){this.context.layoutInfo.editable.querySelectorAll(`figure.an-figure`).forEach(e=>{e.querySelector(`img`)||e.remove()})}_ensureTrailingParagraph(){let e=this.context.layoutInfo.editable;if(!e)return;let t=e.lastElementChild;if(t&&Hr.has(t.nodeName)){let t=document.createElement(`p`);t.innerHTML=`<br>`,e.appendChild(t)}}focus(){this.context.layoutInfo.editable.focus()}getHTML(){let e=this.context.layoutInfo.editable.innerHTML.replaceAll(`​`,``);return this.context.invoke(`clipboard.resolveImages`,e)??e}setHTML(e){let t=Xt(e,{allowIframes:!0,iframeHosts:this.options.iframeHosts});this.context.layoutInfo.editable.replaceChildren(...t.childNodes),this._history&&this._history.reset(),this.afterCommand()}getText(){return this.context.layoutInfo.editable.innerText||``}setText(e){this.context.layoutInfo.editable.textContent=e,this._history&&this._history.reset(),this.afterCommand()}clear(){this.setHTML(``)}clearHistory(){this._history&&this._history.reset()}isEmpty(){let e=(this.context.layoutInfo.editable.innerText||``).trim().replaceAll(`\xA0`,``),t=!!this.context.layoutInfo.editable.querySelector(`img, video, iframe, table`);return!e&&!t}insertHTML(e){e&&(k(`insertHTML`,M(e)),this.afterCommand())}insertText(e){e&&(k(`insertText`,e),this.afterCommand())}setMarkdown(e){this.setHTML(or(e||``))}getMarkdown(){return Hn(this.getHTML())}undo(){this._history&&(this._flushPendingSnapshot(),this._history.undo(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this.context.triggerEvent(`change`,this.getHTML()))}redo(){this._history&&(this._flushPendingSnapshot(),this._history.redo(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this.context.triggerEvent(`change`,this.getHTML()))}_flushPendingSnapshot(){this._snapshotTimer!==null&&(clearTimeout(this._snapshotTimer),this._snapshotTimer=null,this._history?.recordUndo())}canUndo(){return this._history?this._history.canUndo():!1}canRedo(){return this._history?this._history.canRedo():!1}getUndoCount(){return this._history?this._history.getUndoCount():0}getRedoCount(){return this._history?this._history.getRedoCount():0}getSelectionBookmark(){return this._history?._serializeSelection()??null}restoreSelectionBookmark(e){return!e||!this._history?!1:(this._history._restoreSelection(e),!0)}bold(){se(),this.afterCommand()}italic(){ce(),this.afterCommand()}underline(){le(),this.afterCommand()}strikethrough(){ue(),this.afterCommand()}superscript(){de(),this.afterCommand()}subscript(){fe(),this.afterCommand()}justifyLeft(){ve(),this.afterCommand()}justifyCenter(){ye(),this.afterCommand()}justifyRight(){be(),this.afterCommand()}justifyFull(){xe(),this.afterCommand()}indent(){Se(),this.afterCommand()}outdent(){we(),this.afterCommand()}insertUL(){ke(),this.afterCommand()}insertOL(){Ae(),this.afterCommand()}inlineCode(){Me(this.context.layoutInfo.editable),this.afterCommand()}toggleChecklist(){Ie(),this.afterCommand()}print(){this.context.print()}formatBlock(e){if(_e(e),e===`pre`){let e=globalThis.getSelection();if(e?.rangeCount>0){let t=e.getRangeAt(0).commonAncestorContainer,n=t.nodeType===1?t.closest(`pre`):t.parentElement?.closest(`pre`);if(n&&!n.dataset.language){let e=Vr(n.textContent||``);if(e){this.context.invoke(`codeTooltip.applyLanguage`,n,e);return}}}}this.afterCommand()}foreColor(e){pe(e),this.afterCommand()}backColor(e){me(e),this.afterCommand()}fontName(e){he(e),this.afterCommand()}fontSize(e){ge(e,this.context.layoutInfo.editable),this.afterCommand()}insertHr(){k(`insertHorizontalRule`),this.afterCommand()}insertLink(e,t,n=!1){let r=globalThis.getSelection();if(!r||r.rangeCount===0)return;let i=N(e);if(!i)return;let a=this._newTabRel();if(r.toString().trim().length>0){if(k(`createLink`,i),n){let e=this._getClosestAnchor();e&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,a))}}else{let e=this._escapeAttr(t||i),r=n?` target="_blank" rel="${this._escapeAttr(a)}"`:``;k(`insertHTML`,`<a href="${this._escapeAttr(i)}"${r}>${e}</a>`)}this.afterCommand()}_newTabRel(){let e=this.options.linkDefaults?.rel,t=new Set((typeof e==`string`?e:`noopener noreferrer`).split(/\s+/).filter(Boolean));return t.add(`noopener`),[...t].join(` `)}unlink(){k(`unlink`),this.afterCommand()}insertImage(e,t=``,n=``){let r=N(e,{allowData:!0});if(!r)return;let i={left:`float:left;margin:0 1em 1em 0`,center:`display:block;margin:0 auto`,right:`float:right;margin:0 0 1em 1em`}[n]||``,a=i?` style="${i}"`:``;k(`insertHTML`,`<img src="${this._escapeAttr(r)}" alt="${this._escapeAttr(t)}" class="an-image"${a}>`),this.afterCommand()}insertVideo(e){e&&(k(`insertHTML`,M(e,{allowIframes:!0,iframeHosts:this.options.iframeHosts})),this.afterCommand())}insertTable(e,t){xn(e,t,{headerRow:this.context.options.tableHeaderRow}),this.afterCommand()}_getClosestAnchor(){let e=globalThis.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0).startContainer;for(;t;){if(t.nodeName===`A`)return t;t=t.parentNode}return null}_escapeAttr(e){return String(e??``).replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}},Gr=Object.freeze([`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`]);function Kr(e){let t=Array.isArray(e?.colorPalette)&&e.colorPalette.length?e.colorPalette:Gr,n=Array.isArray(e?.colorSwatches)?e.colorSwatches:[];return[...new Set([...n,...t].filter(e=>typeof e==`string`&&e))]}var qr=null,Jr=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,H=e=>`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${Jr} style="display:block">${e}</svg>`,U=new Map([[`bold`,H(`<path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/><path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/>`)],[`italic`,H(`<line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/>`)],[`underline`,H(`<path d="M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"/><line x1="4" y1="21" x2="20" y2="21"/>`)],[`strikethrough`,H(`<path d="M17.3 12H6.7"/><path d="M10 6.5C10 5.1 11.1 4 12.5 4c1.4 0 2.5 1.1 2.5 2.5 0 .8-.4 1.5-1 2"/><path d="M14 17.5C14 19 12.9 20 11.5 20 10.1 20 9 18.9 9 17.5c0-.8.4-1.5 1-2"/>`)],[`superscript`,H(`<path d="m4 19 8-8"/><path d="m12 19-8-8"/><path d="M20 12h-4c0-1.5.44-2 1.5-2.5S20 8.33 20 7.25C20 6 19 5 17.5 5S15 6 15 7"/>`)],[`subscript`,H(`<path d="m4 5 8 8"/><path d="m12 5-8 8"/><path d="M20 21h-4c0-1.5.44-2 1.5-2.5S20 17.33 20 16.25C20 15 19 14 17.5 14S15 15 15 16"/>`)],[`align-left`,H(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="15" y1="12" x2="3" y2="12"/><line x1="17" y1="18" x2="3" y2="18"/>`)],[`align-center`,H(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="18" y1="12" x2="6" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/>`)],[`align-right`,H(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="9" y2="12"/><line x1="21" y1="18" x2="7" y2="18"/>`)],[`align-justify`,H(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="3" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/>`)],[`list-ul`,H(`<line x1="9" y1="6" x2="20" y2="6"/><line x1="9" y1="12" x2="20" y2="12"/><line x1="9" y1="18" x2="20" y2="18"/><circle cx="4" cy="6" r="1" fill="currentColor" stroke="none"/><circle cx="4" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="4" cy="18" r="1" fill="currentColor" stroke="none"/>`)],[`list-ol`,H(`<line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1V3"/><path d="M4 10h2l-2 2h2"/><path d="M4 16.5A1.5 1.5 0 0 1 5.5 15a1.5 1.5 0 0 1 0 3H4"/>`)],[`indent`,H(`<polyline points="3 8 7 12 3 16"/><line x1="21" y1="12" x2="11" y2="12"/><line x1="21" y1="6" x2="11" y2="6"/><line x1="21" y1="18" x2="11" y2="18"/>`)],[`outdent`,H(`<polyline points="7 8 3 12 7 16"/><line x1="21" y1="12" x2="11" y2="12"/><line x1="21" y1="6" x2="11" y2="6"/><line x1="21" y1="18" x2="11" y2="18"/>`)],[`undo`,H(`<path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/>`)],[`redo`,H(`<path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"/>`)],[`minus`,H(`<line x1="5" y1="12" x2="19" y2="12"/>`)],[`link`,H(`<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>`)],[`image`,H(`<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/>`)],[`video`,H(`<polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/>`)],[`table`,H(`<rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/>`)],[`emoji`,H(`<circle cx="12" cy="12" r="10"/><path d="M8.5 14.5s1.5 2.5 3.5 2.5 3.5-2.5 3.5-2.5"/><circle cx="9" cy="9" r="1.5" fill="currentColor" stroke="none"/><circle cx="15" cy="9" r="1.5" fill="currentColor" stroke="none"/>`)],[`icon`,H(`<circle cx="8" cy="8" r="3"/><circle cx="16" cy="8" r="3"/><rect x="5" y="13" width="6" height="6" rx="1"/><rect x="13" y="13" width="6" height="6" rx="1"/>`)],[`code`,H(`<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>`)],[`expand`,H(`<polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/>`)],[`foreColor`,H(`<path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/>`)],[`backColor`,H(`<path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/>`)],[`keyboard`,H(`<rect x="2" y="6" width="20" height="12" rx="2"/><line x1="6" y1="10" x2="6" y2="10" stroke-width="2.5"/><line x1="10" y1="10" x2="10" y2="10" stroke-width="2.5"/><line x1="14" y1="10" x2="14" y2="10" stroke-width="2.5"/><line x1="18" y1="10" x2="18" y2="10" stroke-width="2.5"/><line x1="8" y1="14" x2="16" y2="14" stroke-width="2"/>`)],[`caption`,H(`<rect x="3" y="3" width="18" height="11" rx="2"/><line x1="6" y1="18" x2="18" y2="18"/><line x1="9" y1="21" x2="15" y2="21"/>`)],[`remove-format`,H(`<path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/>`)],[`direction`,H(`<path d="M12 20V4"/><path d="m9 7-3 3 3 3"/><path d="M4 10h8"/><path d="m15 7 3 3-3 3"/><path d="M20 10h-8"/>`)],[`search`,H(`<circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>`)],[`find-replace`,H(`<circle cx="10" cy="10" r="6"/><line x1="18" y1="18" x2="14.35" y2="14.35"/><path d="M16 19h6"/><path d="M19 16v6"/>`)],[`inline-code`,H(`<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/><path d="M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1"/>`)],[`checklist`,H(`<rect x="3" y="4" width="5" height="5" rx="1"/><path d="m4 6.5 1 1 2-2"/><rect x="3" y="13" width="5" height="5" rx="1"/><line x1="10" y1="6.5" x2="21" y2="6.5"/><line x1="10" y1="15.5" x2="21" y2="15.5"/>`)],[`print`,H(`<path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/>`)]]),Yr=new Map([[`bold`,`fa-bold`],[`italic`,`fa-italic`],[`underline`,`fa-underline`],[`strikethrough`,`fa-strikethrough`],[`superscript`,`fa-superscript`],[`subscript`,`fa-subscript`],[`align-left`,`fa-align-left`],[`align-center`,`fa-align-center`],[`align-right`,`fa-align-right`],[`align-justify`,`fa-align-justify`],[`list-ul`,`fa-list-ul`],[`list-ol`,`fa-list-ol`],[`indent`,`fa-indent`],[`outdent`,`fa-outdent`],[`undo`,`fa-rotate-left`],[`redo`,`fa-rotate-right`],[`minus`,`fa-minus`],[`link`,`fa-link`],[`image`,`fa-image`],[`code`,`fa-code`],[`expand`,`fa-expand`],[`emoji`,`fa-face-smile`],[`icon`,`fa-icons`],[`foreColor`,`fa-font`],[`backColor`,`fa-highlighter`],[`keyboard`,`fa-keyboard`],[`remove-format`,`fa-remove-format`],[`direction`,`fa-arrow-right-arrow-left`],[`search`,`fa-magnifying-glass`],[`find-replace`,`fa-magnifying-glass-plus`],[`inline-code`,`fa-code`],[`checklist`,`fa-list-check`],[`print`,`fa-print`]]),Xr={fontFamily:`fontFamilies`,fontSize:`fontSizes`,lineHeight:`lineHeights`,paragraphStyle:`paragraphStyles`},Zr=class{constructor(e){this.context=e,this.options=e.options,this.el=null,this._disposers=[],this._colorPickerClosers=[],this._refreshRaf=null}initialize(){return this.el=h(`div`,{class:`an-toolbar`,role:`toolbar`,"aria-orientation":`horizontal`,"aria-label":this.context.locale.a11y?.toolbar||`Editor toolbar`}),this._faReady=this._detectFontAwesome(),this._buildButtons(),this._initRovingFocus(),this._btnMap=new Map((this.options.toolbar||[]).flat().map(e=>this._resolveBtn(e)).filter(Boolean).map(e=>[e.name,e])),this}destroy(){this._refreshRaf&&cancelAnimationFrame(this._refreshRaf),this._refreshRaf=null,this._disposers.forEach(e=>e()),this._disposers=[],this.el?.parentNode&&this.el.remove(),this.el=null}_resolveBtn(e){return typeof e==`string`?Ue(e,this.options):e}_allow(e,t){return this.context.triggerEvent?.(`beforeCommand`,{name:e,value:t,source:`toolbar`})!==!1}_buildButtons(){let e=this.options.toolbar||[],t=document.createDocumentFragment();e.forEach(e=>{let n=h(`div`,{class:`an-btn-group`});e.forEach(e=>{let t=this._resolveBtn(e);if(!t){console.warn(`[AutumnNote] Toolbar: button "${e}" not found in registry. Skipped.`);return}let r;r=t.type===`select`?this._createSelect(t):t.type===`grid`?this._createGridPicker(t):t.type===`colorpicker`?this._createColorPicker(t):this._createButton(t),n.appendChild(r)}),t.appendChild(n)}),this.el.appendChild(t)}_createGridPicker(e){let t=h(`div`,{class:`an-table-picker-wrap`}),n=h(`button`,{type:`button`,class:this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name,"aria-haspopup":`true`,"aria-expanded":`false`});n.innerHTML=qe(this.options,[e.name,e.icon])||(this._faReady?`<i class="${this.options.fontAwesomeClass||`fas`} fa-table" aria-hidden="true"></i>`:`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:block"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>`);let r=h(`div`,{class:`an-table-picker-popup`,role:`dialog`,"aria-label":this.context.locale.a11y?.tableSize||`Select table size`}),i=h(`div`,{class:`an-table-grid`}),a=h(`div`,{class:`an-table-label`});a.textContent=this.context.locale.toolbar.insertTableLabel||`Insert Table`;let o=[];for(let e=1;e<=10;e++)for(let t=1;t<=10;t++){let n=h(`div`,{class:`an-table-cell`,"data-row":String(e),"data-col":String(t)});o.push(n),i.appendChild(n)}r.appendChild(i),r.appendChild(a);let s=!1,c=(e,t)=>{o.forEach(n=>{let r=+n.dataset.row,i=+n.dataset.col;n.classList.toggle(`active`,r<=e&&i<=t)}),a.textContent=e&&t?`${e} × ${t}`:this.context.locale.toolbar.insertTableLabel||`Insert Table`},l=()=>{s=!0;let e=n.getBoundingClientRect();r.style.visibility=`hidden`,r.style.display=`block`;let t=r.offsetWidth,i=r.offsetHeight,a=e.left,o=e.bottom+4;a+t>globalThis.innerWidth-8&&(a=Math.max(8,globalThis.innerWidth-t-8)),o+i>globalThis.innerHeight-8&&(o=e.top-i-4),r.style.left=`${a}px`,r.style.top=`${o}px`,r.style.visibility=``,n.setAttribute(`aria-expanded`,`true`)},u=()=>{s=!1,r.style.display=`none`,n.setAttribute(`aria-expanded`,`false`),c(0,0)},d=v(n,`click`,e=>{e.stopPropagation(),s?u():l()}),f=v(i,`mouseover`,e=>{let t=e.target?.closest(`.an-table-cell`);t&&c(+t.dataset.row,+t.dataset.col)}),p=v(i,`mouseleave`,()=>c(0,0)),m=v(i,`click`,t=>{let n=t.target?.closest(`.an-table-cell`);if(!n)return;let r=+n.dataset.row,i=+n.dataset.col;u(),this._allow(e.name,{rows:r,cols:i})&&(this.context.invoke(`editor.focus`),e.action(this.context,r,i))}),g=v(document,`click`,()=>{s&&u()});return this._disposers.push(d,f,p,m,g,()=>{r.parentNode&&r.remove()}),t.appendChild(n),x(this.context).appendChild(r),t}_createColorPicker(e){let t=e.defaultColor||`#000000`,n=h(`div`,{class:`an-color-picker-wrap`}),r=this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`,i=h(`button`,{type:`button`,class:`${r} an-color-btn`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name}),a=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,o=e.name===`foreColor`?`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${a} style="display:block"><path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/></svg>`:`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${a} style="display:block"><path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/></svg>`;i.innerHTML=qe(this.options,[e.name,e.icon])??o;let s=h(`span`,{class:`an-color-strip`});s.style.background=t,i.appendChild(s);let c=h(`button`,{type:`button`,class:`${r} an-color-arrow`,title:e.name===`foreColor`?this.context.locale.toolbar.chooseTextColor||`Choose text color`:this.context.locale.toolbar.chooseHighlightColor||`Choose highlight color`,"aria-haspopup":`true`,"aria-expanded":`false`});c.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 24 24" fill="currentColor" stroke="none" style="display:block"><path d="M7 10l5 5 5-5H7z"/></svg>`;let l=h(`div`,{class:`an-color-popup`});l.style.display=`none`;let u=h(`div`,{class:`an-color-swatches`});Kr(this.options).forEach(e=>{let t=h(`div`,{class:`an-color-swatch`,title:e,"data-color":e});t.style.background=e,u.appendChild(t)});let d=h(`div`,{class:`an-color-custom`}),f=h(`input`,{type:`color`,value:t,title:this.context.locale.toolbar.customColor||`Custom color`}),p=h(`span`,{},[this.context.locale.toolbar.customColor||`Custom color`]);d.appendChild(f),d.appendChild(p),l.appendChild(u),l.appendChild(d);let m=!1,g=null,_=()=>{let e=globalThis.getSelection();g=e?.rangeCount?e.getRangeAt(0).cloneRange():null},y=()=>{if(g)try{let e=globalThis.getSelection();if(!e)return;e.removeAllRanges(),e.addRange(g)}catch{}},b=()=>{this._colorPickerClosers.forEach(e=>{e!==S&&e()}),_(),m=!0;let e=c.getBoundingClientRect(),t=e.left;t+184>globalThis.innerWidth&&(t=e.right-184),l.style.top=`${e.bottom+4}px`,l.style.left=`${Math.max(4,t)}px`,l.style.display=`block`,c.setAttribute(`aria-expanded`,`true`)},S=()=>{m=!1,l.style.display=`none`,l.style.top=``,l.style.left=``,c.setAttribute(`aria-expanded`,`false`)},C=n=>{if(t=n,s.style.background=n,f.value=n,!this._allow(e.name,n)){S();return}y(),e.action(this.context,n),this.context.invoke(`editor.afterCommand`),S()},w=v(i,`click`,n=>{n.preventDefault(),this._allow(e.name,t)&&(y(),e.action(this.context,t),this.context.invoke(`editor.afterCommand`))}),ee=v(c,`mousedown`,e=>{e.preventDefault()}),T=v(c,`click`,e=>{e.stopPropagation(),m?S():b()}),E=v(u,`mousedown`,e=>{e.preventDefault()}),D=v(u,`click`,e=>{let t=e.target?.closest(`.an-color-swatch`);t&&C(t.dataset.color)}),te=v(f,`change`,e=>{C(e.target.value)}),ne=v(document,`click`,e=>{m&&!n.contains(e.target)&&!l.contains(e.target)&&S()}),re=v(l,`click`,e=>e.stopPropagation()),O=()=>{m&&S()};return document.addEventListener(`scroll`,O,{passive:!0,capture:!0}),globalThis.addEventListener(`resize`,O,{passive:!0}),this._disposers.push(w,ee,T,E,D,te,ne,re,()=>document.removeEventListener(`scroll`,O,{capture:!0}),()=>globalThis.removeEventListener(`resize`,O),()=>{l.parentNode&&l.remove()}),this._colorPickerClosers.push(S),this._disposers.push(()=>{let e=this._colorPickerClosers.indexOf(S);e!==-1&&this._colorPickerClosers.splice(e,1)}),n.appendChild(i),n.appendChild(c),x(this.context).appendChild(l),n}_createSelect(e){let t=Xr[e.name],n=t?this.options[t]:null,r=Array.isArray(n)&&(n.length||e.name===`fontFamily`)?n:e.items||[],i=h(`select`,{class:e.selectClass?`an-select ${e.selectClass}`:`an-select`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name}),a=h(`option`,{value:``,disabled:``,hidden:``},[this.context.locale.toolbar[e.name+`Placeholder`]||e.placeholder||`Font`]);i.appendChild(a),r.forEach(t=>{let n=typeof t==`object`?t.value:t,r;r=typeof t==`object`?e.name===`paragraphStyle`&&this.context.locale.toolbar.paragraphItems?.[t.value]||t.label:t;let a=typeof t==`object`&&!!t.disabled,o={value:n};a&&(o.disabled=``);let s=h(`option`,o,[r]);e.name===`fontFamily`&&!a&&(s.style.fontFamily=n),i.appendChild(s)});let o=null,s=v(i,`mousedown`,()=>{let e=globalThis.getSelection();o=e?.rangeCount?e.getRangeAt(0).cloneRange():null}),c=v(i,`change`,t=>{let n=t.target.value,r=t.target.options[t.target.selectedIndex];if(!(!n||r.disabled)){if(this.context.invoke(`editor.focus`),o)try{let e=globalThis.getSelection();e&&(e.removeAllRanges(),e.addRange(o))}catch{}this._allow(e.name,n)&&(e.action(this.context,n),this.context.invoke(`editor.afterCommand`))}});return this._disposers.push(s,c),i}_createButton(e){let t=h(`button`,{type:`button`,class:`${this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`}${e.className?` ${e.className}`:``}`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name,...typeof e.isActive==`function`?{"aria-pressed":`false`}:{}}),n=this.options.fontAwesomeClass||`fas`,r=this._faReady,i=qe(this.options,[e.name,e.icon]);if(i)t.innerHTML=i;else if(r){let r=Yr.get(e.icon)||Yr.get(e.name)||null;r?t.innerHTML=`<i class="${n} ${r}" aria-hidden="true"></i>`:U.has(e.icon)?t.innerHTML=U.get(e.icon):t.textContent=e.icon||e.name}else U.has(e.icon)?t.innerHTML=U.get(e.icon):U.has(e.name)?t.innerHTML=U.get(e.name):t.textContent=e.icon||e.name;let a=v(t,`click`,t=>{t.preventDefault(),this._allow(e.name)&&(this.context.invoke(`editor.focus`),e.action(this.context),this.context.invoke(`editor.afterCommand`),this.refresh())});return this._disposers.push(a),t}_controls(){return this.el?Array.from(this.el.querySelectorAll(`button, select`)):[]}_navigable(){return this._controls().filter(e=>!e.disabled)}_syncRovingTabindex(e){let t=this._controls(),n=this._navigable();if(!n.length)return;let r=e&&n.includes(e)?e:n.find(e=>e.getAttribute(`tabindex`)===`0`)||n[0];t.forEach(e=>e.setAttribute(`tabindex`,e===r?`0`:`-1`))}_initRovingFocus(){this.el&&(this._syncRovingTabindex(),this._disposers.push(v(this.el,`keydown`,e=>this._onToolbarKeydown(e)),v(this.el,`focusin`,e=>{let t=e.target?.closest?.(`button, select`);t&&this._syncRovingTabindex(t)})))}_onToolbarKeydown(e){if(![`ArrowRight`,`ArrowLeft`,`Home`,`End`].includes(e.key))return;let t=this._navigable(),n=e.target?.closest?.(`button, select`),r=n?t.indexOf(n):-1;if(r===-1)return;let i;if(e.key===`Home`)i=t[0];else if(e.key===`End`)i=t.at(-1);else{let n=this.options.direction===`rtl`;i=t[(r+(e.key===`ArrowRight`===n?-1:1)+t.length)%t.length]}i&&(e.preventDefault(),this._syncRovingTabindex(i),i.focus())}_detectFontAwesome(){if(!this.options.useFontAwesome)return!1;if(qr!==null)return qr;if(document.querySelector(`.fa, .fas, .far, .fal, .fab, .fa-solid`))return qr=!0,!0;let e=Array.from(document.querySelectorAll(`link[rel="stylesheet"]`)).filter(e=>e.id!==`an-fontawesome-css`).map(e=>e.href||``).join(` `);return qr=/fontawesome|font-awesome|use\.fontawesome|all\.css/.test(e),qr}refresh(){this._refreshRaf&&cancelAnimationFrame(this._refreshRaf),this._refreshRaf=requestAnimationFrame(()=>{this._refreshRaf=null,this._doRefresh()})}_doRefresh(){if(!this.el)return;let e=this._btnMap||new Map;this.el.querySelectorAll(`button[data-btn]`).forEach(t=>{let n=e.get(t.dataset.btn);if(n&&typeof n.isActive==`function`){let e=!!n.isActive(this.context);t.classList.toggle(`active`,e),t.setAttribute(`aria-pressed`,String(e))}n&&typeof n.isDisabled==`function`&&(t.disabled=!!n.isDisabled(this.context))}),this._syncRovingTabindex(),this.el.querySelectorAll(`select[data-btn]`).forEach(t=>{let n=e.get(t.dataset.btn);if(!n||typeof n.getValue!=`function`)return;let r=(n.getValue(this.context)||``).replace(/["']/g,``).trim();r||=this.options.defaultFontFamily||this.options.fontFamilies?.[0]||``;let i=t,a=Array.from(i.options).find(e=>e.value?.toLowerCase()===r.toLowerCase());i.value=a?a.value:``})}show(){this.el&&(this.el.style.display=``)}hide(){this.el&&(this.el.style.display=`none`)}rebuild(){this._refreshRaf&&=(cancelAnimationFrame(this._refreshRaf),null),this._disposers.forEach(e=>e()),this._disposers=[],this.el&&(this.el.innerHTML=``),this._faReady=this._detectFontAwesome(),this._buildButtons(),this._initRovingFocus(),this._btnMap=new Map((this.options.toolbar||[]).flat().map(e=>this._resolveBtn(e)).filter(Boolean).map(e=>[e.name,e])),this.refresh()}};function Qr(e,t,n){if(!n){e.classList.remove(`an-count-warn`,`an-count-exceeded`);return}t>n?(e.classList.add(`an-count-exceeded`),e.classList.remove(`an-count-warn`)):t>=n*.9?(e.classList.add(`an-count-warn`),e.classList.remove(`an-count-exceeded`)):e.classList.remove(`an-count-warn`,`an-count-exceeded`)}var $r=class{constructor(e){this.context=e,this.options=e.options,this.el=null,this._disposers=[],this._handle=null,this._handleDisposers=[],this._wordCountEl=null,this._charCountEl=null,this._counter=new Bn}initialize(){this.el=h(`div`,{class:`an-statusbar`}),this._wordCountEl=h(`span`,{class:`an-word-count`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`}),this._charCountEl=h(`span`,{class:`an-char-count`,"aria-live":`polite`,"aria-atomic":`true`});let e=h(`div`,{class:`an-status-info`,"aria-label":this.context.locale.a11y?.statistics||`Editor statistics`});return e.appendChild(this._wordCountEl),e.appendChild(this._charCountEl),this.el.appendChild(e),this.applyResizable(),this.applyVisibility(),this.update(),this}applyResizable(){if(!this.el)return;let e=this.options.resizable!==!1;if(e&&!this._handle){let e=h(`div`,{class:`an-resize-handle`,title:this.context.locale.statusbar.resizeHandle,"aria-hidden":`true`});this._handleDisposers=this._bindResize(e),this.el.prepend(e),this._handle=e}else!e&&this._handle&&(this._handleDisposers.forEach(e=>e()),this._handleDisposers=[],this._handle.remove(),this._handle=null)}applyVisibility(){if(!this.el)return;let e=this.options.statusbar!==!1;this.el.hidden=!e,this.context.layoutInfo.container?.classList.toggle(`an-no-statusbar`,!e)}destroy(){this.context.layoutInfo.container?.classList.remove(`an-no-statusbar`),this._disposers.forEach(e=>e()),this._disposers=[],this._handleDisposers.forEach(e=>e()),this._handleDisposers=[],this._handle=null,this._dragDisposers&&=(this._dragDisposers.forEach(e=>e()),null),this.el?.remove(),this.el=null}_bindResize(e){let t=0,n=0,r=this.context.layoutInfo.container,i=e=>{let i=e-t,a=Array.from(r.children).filter(e=>!e.classList.contains(`an-editable`)).reduce((e,t)=>e+t.offsetHeight,0),o=Math.max(this.options.minHeight||100,a+40);r.style.height=`${Math.max(o,n+i)}px`},a=e=>i(e.clientY),o=()=>{document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o),this._dragDisposers=null},s=e=>{t=e.clientY,n=r.offsetHeight,this.context.layoutInfo.editable.style.minHeight=``,document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o),this._dragDisposers=[()=>document.removeEventListener(`mousemove`,a),()=>document.removeEventListener(`mouseup`,o)],e.preventDefault()},c=e=>{let t=e.touches[0];t&&(e.preventDefault(),i(t.clientY))},l=()=>{document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),this._dragDisposers=null};return[v(e,`mousedown`,s),v(e,`touchstart`,e=>{let i=e.touches[0];i&&(t=i.clientY,n=r.offsetHeight,this.context.layoutInfo.editable.style.minHeight=``,document.addEventListener(`touchmove`,c,{passive:!1}),document.addEventListener(`touchend`,l),this._dragDisposers=[()=>document.removeEventListener(`touchmove`,c),()=>document.removeEventListener(`touchend`,l)])})]}_counts(){return this._counter.counts(this.context.layoutInfo.editable)}update(){if(!this._wordCountEl||!this._charCountEl||this.el?.hidden)return;let{words:e,chars:t}=this._counts(),n=this.options.maxWords||0,r=this.options.maxChars||0,i=this.context.locale.statusbar;this._wordCountEl.textContent=n?i.wordsLimit(e,n):i.words(e),this._charCountEl.textContent=r?i.charsLimit(t,r):i.chars(t),Qr(this._wordCountEl,e,n),Qr(this._charCountEl,t,r)}getWordCount(){return this._counts().words}getCharCount(){return this._counts().chars}},ei=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){this._blobRegistry=new Map,this._forcePlain=!1;let e=this.context.layoutInfo.editable;return this._disposers.push(v(e,`paste`,e=>this._onPaste(e)),v(e,`dragover`,e=>this._onDragover(e)),v(e,`drop`,e=>this._onDrop(e))),this._mutationObserver=new MutationObserver(e=>{for(let t of e)for(let e of t.removedNodes)this._revokeRemovedBlobs(e)}),this._mutationObserver.observe(e,{childList:!0,subtree:!0}),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._mutationObserver&&=(this._mutationObserver.disconnect(),null),this._blobRegistry&&(this._blobRegistry.forEach((e,t)=>URL.revokeObjectURL(t)),this._blobRegistry.clear()),this._uploadPreviews&&(this._uploadPreviews.forEach(({previewUrl:e})=>URL.revokeObjectURL(e)),this._uploadPreviews.clear())}_revokeRemovedBlobs(e){if(!this._blobRegistry?.size)return;let t=[];e.nodeName===`IMG`?t.push(e):e.querySelectorAll&&t.push(...e.querySelectorAll(`img`)),t.forEach(e=>{let t=e.getAttribute(`src`)||``;t.startsWith(`blob:`)&&this._blobRegistry.has(t)&&(URL.revokeObjectURL(t),this._blobRegistry.delete(t))})}_cleanWordHtml(e){return e.replace(/<!--\[if[\s\S]*?\[endif\]-->/gi,``).replace(/<xml[\s\S]*?<\/xml>/gi,``).replace(/<\?xml[\s\S]*?\?>/gi,``).replace(/<\/?(o|w|m|v|st1):[a-z][^>]*>/gi,``).replace(/\s+class="Mso[^"]*"/gi,``).replace(/\s+style="([^"]*)"/gi,(e,t)=>{let n=t.split(`;`).map(e=>e.trim()).filter(e=>e&&!/^mso-/i.test(e)&&!/^(tab-stops|margin-[a-z]+-alt)/i.test(e)).join(`; `);return n?` style="${n}"`:``}).replace(/<p[^>]*>\s*(&nbsp;)?\s*<\/p>/gi,``)}_cleanSocialHtml(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`),n=Array.from(t.querySelectorAll(`span, div`));for(let e=n.length-1;e>=0;e--){let t=n[e];if(!t.parentNode||t.querySelector(`a, strong, em, b, i, ul, ol, li, table, img, blockquote, pre, code, h1, h2, h3, h4, h5, h6`))continue;let r=t.parentNode;for(;t.firstChild;)r.insertBefore(t.firstChild,t);t.remove()}return t.querySelectorAll(`*`).forEach(e=>{e.removeAttribute(`class`),e.removeAttribute(`id`),Array.from(e.attributes).filter(e=>e.name.startsWith(`data-`)||e.name.startsWith(`aria-`)).forEach(t=>e.removeAttribute(t.name))}),t.body.innerHTML}_stripAttributes(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`),n=new Set([`href`,`src`,`alt`,`target`,`rel`,`colspan`,`rowspan`,`type`]);return t.querySelectorAll(`*`).forEach(e=>{Array.from(e.attributes).filter(e=>!n.has(e.name)).forEach(t=>e.removeAttribute(t.name))}),t.body.innerHTML}_normalizeExternalTaskLists(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`);for(let e of t.querySelectorAll(`input[type="checkbox"]`)){let t=e.closest(`li`),n=t?.closest(`ul`);if(!(!t||!n||n.classList.contains(`an-checklist`))){n.classList.add(`an-checklist`),e.removeAttribute(`disabled`),e.setAttribute(`contenteditable`,`false`);for(let t of Array.from(e.attributes))[`type`,`checked`,`contenteditable`].includes(t.name)||e.removeAttribute(t.name)}}return t.body.innerHTML}_isTriviallyPlainHtml(e){return!new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`).body.querySelector(`a,img,table,ul,ol,li,blockquote,pre,code,h1,h2,h3,h4,h5,h6,strong,b,em,i,u,s,del,strike,hr,br`)}setForcePlain(e){this._forcePlain=!!e}_maxPasteBytes(){let e=this.options.maxPasteSize;return typeof e==`number`&&e>=0?e:5242880}_onPaste(e){let t=e.clipboardData||globalThis.clipboardData;if(!t)return;let n=this._forcePlain;this._forcePlain=!1;let r=this._maxPasteBytes();if(r>0){let n=t.getData(`text/plain`)||``,i=t.getData(`text/html`)||``,a=Math.max(n.length,i.length);if(a>r){e.preventDefault();let t=`Pasted content (${a} bytes) exceeds the ${r}-byte paste size limit.`;this.context.triggerEvent(`pasteError`,{size:a,maxBytes:r,message:t}),console.warn(`[AutumnNote] ${t}`);return}}if(t.items){let n=Array.from(t.items).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(n.length>0){e.preventDefault();let t=n.map(e=>e.getAsFile()).filter(Boolean);this._insertImageFiles(t);return}}let i=this.context.triggerEvent(`paste`,{text:t.getData(`text/plain`)||``,html:t.types.includes(`text/html`)?t.getData(`text/html`):null});if(i===!1){e.preventDefault();return}if(typeof i==`string`){e.preventDefault(),k(`insertHTML`,M(i)),this.context.invoke(`editor.afterCommand`);return}if(n||this.options.pasteAsPlainText){e.preventDefault(),k(`insertHTML`,t.getData(`text/plain`).split(/\r?\n/).map(e=>`<p>${this._escapeHTML(e)||`<br>`}</p>`).join(``)),this.context.invoke(`editor.afterCommand`);return}if(this.options.markdownPaste!==!1){let n=t.types.includes(`text/html`),r=n?t.getData(`text/html`):``,i=!n||this._isTriviallyPlainHtml(r),a=t.getData(`text/plain`);if(a&&i&&Qn(a)){e.preventDefault(),k(`insertHTML`,M(or(a))),this.context.invoke(`editor.afterCommand`);return}}if(this.options.pasteCleanHTML!==!1&&t.types.includes(`text/html`)){e.preventDefault();let n=t.getData(`text/html`),r=/<[a-z]+:[a-z]/i.test(n)||/class="Mso/i.test(n)||/\bmso-/i.test(n),i=/class="[^"]*\b(?:x[a-z0-9]{6,}|r-[a-z0-9]{3,})\b/.test(n),a=n;r?a=this._cleanWordHtml(a):i&&(a=this._cleanSocialHtml(a)),a=this._normalizeExternalTaskLists(a),a=M(a),this.options.pasteStripAttributes&&(a=this._stripAttributes(a)),k(`insertHTML`,a),this.context.invoke(`editor.afterCommand`)}}_onDragover(e){e.dataTransfer&&Array.from(e.dataTransfer.types||[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}_onDrop(e){let t=e.dataTransfer;if(!t?.files?.length)return;let n=Array.from(t.files).filter(e=>e.type.startsWith(`image/`));if(n.length>0){e.preventDefault(),e.stopPropagation(),this._placeCaretAtPoint(e.clientX,e.clientY),this._insertImageFiles(n);return}if(this.options.markdownPaste!==!1){let n=Array.from(t.files).find(e=>/\.md$/i.test(e.name)||e.type===`text/markdown`);n&&(e.preventDefault(),e.stopPropagation(),this._placeCaretAtPoint(e.clientX,e.clientY),this._insertMarkdownFile(n))}}_insertMarkdownFile(e){let t=this._maxPasteBytes();if(t>0&&e.size>t){let n=`Dropped file "${e.name}" (${e.size} bytes) exceeds the ${t}-byte paste size limit.`;this.context.triggerEvent(`pasteError`,{size:e.size,maxBytes:t,message:n}),console.warn(`[AutumnNote] ${n}`);return}let n=new FileReader;n.onload=e=>{k(`insertHTML`,M(or(e.target.result||``))),this.context.invoke(`editor.afterCommand`)},n.onerror=()=>{let t=`Failed to read dropped markdown file "${e.name}".`;console.warn(`[AutumnNote] ${t}`),this.context.triggerEvent(`pasteError`,{message:t})},n.readAsText(e)}_insertImageFiles(e){if(!e||e.length===0)return;if(typeof this.options.onImageUpload==`function`){this._runUploadHandler(e);return}let t=new Set([`image/tiff`,`image/x-tiff`,`image/bmp`,`image/x-bmp`,`image/x-ms-bmp`]),n=(this.options.maxImageSize||5)*1024*1024;e.forEach(e=>{if(!e?.type?.startsWith(`image/`))return;if(t.has(e.type)){let t=`Image format "${e.type}" is not supported for display in web browsers. Please convert to PNG, JPEG, or WebP first.`;this.context.triggerEvent(`imageError`,{file:e,message:t}),console.warn(`[AutumnNote]`,t);return}if(e.size>n){let t=`Image "${e.name}" exceeds the ${this.options.maxImageSize||5} MB size limit.`;this.context.triggerEvent(`imageError`,{file:e,message:t}),console.warn(`[AutumnNote] ${t}`);return}let r=e.name.replace(/\.[^.]+$/,``);this.compressAndRegister(e).then(e=>{this.context.invoke(`editor.insertImage`,e,r)}).catch(t=>{let n=`Image "${e.name}" could not be processed.`;this.context.triggerEvent(`imageError`,{file:e,message:n,error:t}),console.warn(`[AutumnNote]`,n,t)})})}_escapeAttr(e){return String(e).replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}async _runUploadHandler(e){let t={context:this.context,setProgress:(e,t)=>this._setUploadProgress(e,t)},n;try{n=this.options.onImageUpload(e,t)}catch(t){this._reportUploadError(e,t);return}if(n===void 0)return;let r=e.map(e=>this._insertUploadPlaceholder(e)),i;try{i=await n}catch(t){r.forEach((n,r)=>this._failUpload(n,e[r],t));return}let a=Array.isArray(i)?i:[i];r.forEach((t,n)=>{let r=a[n];typeof r==`string`&&r?this._resolveUpload(t,r):this._failUpload(t,e[n],Error(`No URL returned for this file.`))})}_insertUploadPlaceholder(e){let t=`an-up-${Date.now().toString(36)}-${this._uploadSeq=(this._uploadSeq||0)+1}`,n=URL.createObjectURL(e);this._uploadPreviews=this._uploadPreviews||new Map,this._uploadPreviews.set(t,{previewUrl:n,file:e});let r=this._escapeAttr(e.name.replace(/\.[^.]+$/,``));return k(`insertHTML`,`<img src="${this._escapeAttr(n)}" alt="${r}" class="an-image an-image-uploading" data-an-upload="${t}">`),this.context.invoke(`editor.afterCommand`),t}_findPlaceholder(e){return this.context.layoutInfo.editable?.querySelector(`img[data-an-upload="${e}"]`)??null}_resolveUpload(e,t){let n=this._findPlaceholder(e),r=this._uploadPreviews?.get(e);if(n){let i=N(t,{allowData:!0});if(i)n.setAttribute(`src`,i),n.classList.remove(`an-image-uploading`),n.removeAttribute(`data-an-upload`),n.style.removeProperty(`--an-upload-progress`);else{this._failUpload(e,r?.file,Error(`Rejected image URL: ${t}`));return}}r&&(URL.revokeObjectURL(r.previewUrl),this._uploadPreviews.delete(e)),this.context.invoke(`editor.afterCommand`)}_failUpload(e,t,n){let r=this._findPlaceholder(e);r&&(r.classList.remove(`an-image-uploading`),r.classList.add(`an-image-failed`),r.style.removeProperty(`--an-upload-progress`));let i=`Image "${t?.name??`unknown`}" could not be uploaded.`;console.warn(`[AutumnNote]`,i,n),this.context.triggerEvent(`imageError`,{file:t,message:i,error:n,retry:()=>{r?.remove(),this._uploadPreviews?.delete(e),t&&this._runUploadHandler([t])}})}_reportUploadError(e,t){let n=`The image upload handler threw before any file was sent.`;console.warn(`[AutumnNote]`,n,t),this.context.triggerEvent(`imageError`,{file:e[0],message:n,error:t})}_setUploadProgress(e,t){if(!this._uploadPreviews)return;let n=Math.max(0,Math.min(1,Number(t)||0));for(let[t,r]of this._uploadPreviews){if(r.file!==e)continue;let i=this._findPlaceholder(t);i&&i.style.setProperty(`--an-upload-progress`,String(n));return}}async compressAndRegister(e){let t=this.options.imageProcessor,n=typeof t==`function`?await t(e,{context:this.context}):await this._compressImage(e),r=this._dataUrlToBlob(n),i=URL.createObjectURL(r);return this._blobRegistry.set(i,n),i}resolveImages(e){return this._blobRegistry?.size?e.replace(/blob:[^"'> \t\n\r]*/g,e=>this._blobRegistry.get(e)||e):e}_dataUrlToBlob(e){let[t,n]=e.split(`,`),r=/:(.*?);/.exec(t)?.[1]??`image/png`,i=atob(n),a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);return new Blob([a],{type:r})}_compressImage(e){let t=1920,n=.85;return new Promise((r,i)=>{let a=URL.createObjectURL(e),o=new Image;o.onload=()=>{URL.revokeObjectURL(a);let{width:s,height:c}=o;(s>t||c>t)&&(s>=c?(c=Math.round(c*t/s),s=t):(s=Math.round(s*t/c),c=t));let l=document.createElement(`canvas`);l.width=s,l.height=c;let u=l.getContext(`2d`);if(!u){let t=new FileReader;t.onload=e=>r(e.target.result),t.onerror=()=>i(Error(`FileReader failed`)),t.readAsDataURL(e);return}u.drawImage(o,0,0,s,c);let d=l.toDataURL(`image/webp`,n);r(d.startsWith(`data:image/webp`)?d:l.toDataURL(`image/jpeg`,n))},o.onerror=()=>{URL.revokeObjectURL(a);let t=new FileReader;t.onload=e=>r(e.target.result),t.onerror=()=>i(Error(`FileReader failed`)),t.readAsDataURL(e)},o.src=a})}_placeCaretAtPoint(e,t){let n;if(document.caretRangeFromPoint)n=document.caretRangeFromPoint(e,t);else if(document.caretPositionFromPoint){let r=document.caretPositionFromPoint(e,t);r&&(n=document.createRange(),n.setStart(r.offsetNode,r.offset),n.collapse(!0))}if(!n)return;let r=globalThis.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}_escapeHTML(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&#039;`)}},W={undo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>`,redo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"/></svg>`,cut:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="20" r="3"/><circle cx="6" cy="4" r="3"/><line x1="19" y1="5" x2="6" y2="19"/><line x1="19" y1="19" x2="13.5" y2="13.5"/></svg>`,copy:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`,paste:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>`,bold:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/><path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/></svg>`,italic:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>`,underline:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"/><line x1="4" y1="21" x2="20" y2="21"/></svg>`,link:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,image:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,video:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteImg:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,videoAlign:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,deleteVideo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,copyFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,pasteFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><rect x="8" y="2" width="8" height="4" rx="1"/><path d="m9 14 2 2 4-4"/></svg>`,removeFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>`,table:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>`,textColor:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/></svg>`,highlightColor:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/><line x1="3" y1="21" x2="21" y2="21"/></svg>`,noColor:`<svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="4" y1="4" x2="20" y2="20"/><line x1="20" y1="4" x2="4" y2="20"/></svg>`,back:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>`};function ti(e){let t=e===`foreColor`?`Text Color`:`Highlight Color`,n=e===`foreColor`?`textColor`:`highlightColor`;return()=>[{back:!0,label:t,localeKey:n,navigate:()=>ni},{colorPalette:!0,colorType:e}]}var ni=[{name:`cut`,label:`Cut`,icon:W.cut,action:()=>document.execCommand(`cut`)},{name:`copy`,label:`Copy`,icon:W.copy,action:()=>document.execCommand(`copy`)},{name:`paste`,label:`Paste`,icon:W.paste,action:e=>{if(!navigator.clipboard)return;let t=e.layoutInfo?.editable;if(!t)return;let n=(n,r)=>{if(t.focus(),n){let e=M(n);document.execCommand(`insertHTML`,!1,e)}else r&&document.execCommand(`insertText`,!1,r);e.invoke(`editor.afterCommand`)};typeof navigator.clipboard.read==`function`?navigator.clipboard.read().then(e=>{for(let t of e)if(t.types.includes(`text/html`)){t.getType(`text/html`).then(e=>e.text()).then(e=>n(e,null)).catch(()=>{});return}navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}).catch(()=>{navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}):typeof navigator.clipboard.readText==`function`&&navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}},{separator:!0},{name:`bold`,label:`Bold`,icon:W.bold,action:e=>e.invoke(`editor.bold`)},{name:`italic`,label:`Italic`,icon:W.italic,action:e=>e.invoke(`editor.italic`)},{name:`underline`,label:`Underline`,icon:W.underline,action:e=>e.invoke(`editor.underline`)},{separator:!0},{name:`textColor`,label:`Text Color`,icon:W.textColor,colorStrip:`foreColor`,navigate:ti(`foreColor`)},{name:`highlightColor`,label:`Highlight Color`,icon:W.highlightColor,colorStrip:`hiliteColor`,navigate:ti(`hiliteColor`)},{separator:!0},{name:`copyFormat`,label:`Copy Format`,icon:W.copyFormat,action:e=>e.invoke(`contextMenu.copyFormat`)},{name:`pasteFormat`,label:`Paste Format`,icon:W.pasteFormat,action:e=>e.invoke(`contextMenu.pasteFormat`),disabled:e=>!e.invoke(`contextMenu.hasCopiedFormat`)},{name:`removeFormat`,label:`Remove Format`,icon:W.removeFormat,action:e=>e.invoke(`contextMenu.removeFormat`)},{separator:!0},{name:`link`,label:`Insert Link`,icon:W.link,action:e=>e.invoke(`linkDialog.show`)},{name:`image`,label:`Insert Image`,icon:W.image,action:e=>e.invoke(`imageDialog.show`)},{name:`video`,label:`Insert Video`,icon:W.video,action:e=>e.invoke(`videoDialog.show`)},{name:`table`,label:`Insert Table`,icon:W.table,tableGrid:!0}],ri=class{constructor(e){this.context=e,this.options=e.options,this._items=this.options.contextMenu?.items||ni,this.el=null,this._disposers=[],this._menuDisposers=[],this._lastX=0,this._lastY=0,this._copiedFormat=null,this._savedRange=null}initialize(){this.el=h(`div`,{class:`an-contextmenu`,role:`menu`,"aria-hidden":`true`}),this.el.style.display=`none`,x(this.context).appendChild(this.el),this._renderItems(this._items);let e=this.context.layoutInfo?.editable;return e&&this._disposers.push(v(e,`contextmenu`,e=>this._onContextMenu(e))),this._disposers.push(v(document,`click`,e=>this._maybeHide(e)),v(document,`keydown`,e=>{e.key===`Escape`&&this.hide()}),v(globalThis,`scroll`,()=>this.hide(),{passive:!0})),this}destroy(){this._menuDisposers.forEach(e=>{try{e()}catch{}}),this._menuDisposers=[],this._disposers.forEach(e=>{try{e()}catch{}}),this._disposers=[],this.el&&this.el.remove(),this.el=null}_renderItems(e){this._menuDisposers.forEach(e=>e()),this._menuDisposers=[],this.el&&(this.el.innerHTML=``,e.forEach(e=>{if(e.separator||e.sep){this.el.appendChild(h(`div`,{class:`an-context-sep`}));return}if(e.back){let t=h(`button`,{type:`button`,class:`an-context-back`}),n=h(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=W.back,t.appendChild(n);let r=e.localeKey&&this.context.locale.contextMenu[e.localeKey]||e.label||this.context.locale.contextMenu.back||`Back`;t.appendChild(h(`span`,{class:`an-context-label`},[r]));let i=v(t,`click`,t=>{t.stopPropagation();let n=Number.parseFloat(this.el.style.left),r=Number.parseFloat(this.el.style.top);this._renderItems(e.navigate()),this._reposition(n,r)});this._menuDisposers.push(i),this.el.appendChild(t);return}if(e.navigate){let t=h(`button`,{type:`button`,class:`an-context-item an-context-submenu`,"data-name":e.name||``});if(e.icon){if(e.colorStrip){let n=h(`span`,{class:`an-context-icon an-context-icon--color`,"aria-hidden":`true`}),r=h(`span`,{class:`an-context-icon-svg`});r.innerHTML=e.icon;let i=h(`span`,{class:`an-context-color-strip`});i.style.background=this._getSelectionColor(e.colorStrip),n.appendChild(r),n.appendChild(i),t.appendChild(n)}else{let n=h(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=e.icon,t.appendChild(n)}}t.appendChild(h(`span`,{class:`an-context-label`},[this.context.locale.contextMenu[e.name]||e.label||e.name]));let n=h(`span`,{class:`an-context-chevron`,"aria-hidden":`true`});n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`,t.appendChild(n);let r=v(t,`click`,t=>{t.stopPropagation();let n=Number.parseFloat(this.el.style.left),r=Number.parseFloat(this.el.style.top);this._renderItems(e.navigate()),this._reposition(n,r)});this._menuDisposers.push(r),this.el.appendChild(t);return}if(e.colorPalette){let t=h(`div`,{class:`an-context-color-palette`});if(Kr(this.options).forEach(n=>{let r=h(`div`,{class:`an-context-color-swatch`,title:n,role:`button`,"aria-label":n});r.style.background=n;let i=v(r,`click`,t=>{t.stopPropagation(),this._applyColor(e.colorType,n)});this._menuDisposers.push(i),t.appendChild(r)}),e.colorType===`hiliteColor`){let e=h(`div`,{class:`an-context-color-swatch an-context-color-none`,title:this.context.locale.contextMenu.noHighlight||`No highlight`,role:`button`,"aria-label":this.context.locale.contextMenu.noHighlight||`No highlight`});e.innerHTML=W.noColor;let n=v(e,`click`,e=>{e.stopPropagation(),this._applyColor(`hiliteColor`,`transparent`)});this._menuDisposers.push(n),t.appendChild(e)}this.el.appendChild(t);let n=h(`div`,{class:`an-context-color-custom`}),r=h(`input`,{type:`color`,value:e.colorType===`foreColor`?`#000000`:`#ffff00`,title:this.context.locale.contextMenu.customColor||`Custom color`,"aria-label":this.context.locale.contextMenu.customColor||`Custom color`}),i=h(`span`,{},[this.context.locale.contextMenu.customColorLabel||`Custom…`]),a=v(r,`change`,()=>this._applyColor(e.colorType,r.value));this._menuDisposers.push(a),n.appendChild(r),n.appendChild(i),this.el.appendChild(n);return}if(e.tableGrid){let t=h(`div`,{class:`an-context-table-wrap`}),n=h(`button`,{type:`button`,class:`an-context-item an-context-submenu`,"data-name":e.name||`table`});if(e.icon){let t=h(`span`,{class:`an-context-icon`,"aria-hidden":`true`});t.innerHTML=e.icon,n.appendChild(t)}n.appendChild(h(`span`,{class:`an-context-label`},[this.context.locale.contextMenu.table||e.label||`Insert Table`]));let r=h(`span`,{class:`an-context-chevron`,"aria-hidden":`true`});r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`,n.appendChild(r);let i=h(`div`,{class:`an-context-table-grid-panel`});i.style.display=`none`;let a=h(`div`,{class:`an-table-grid`});a.style.gridTemplateColumns=`repeat(8, 16px)`;let o=h(`div`,{class:`an-table-label`});o.textContent=`Insert Table`;let s=[];for(let e=1;e<=8;e++)for(let t=1;t<=8;t++){let n=h(`div`,{class:`an-table-cell`,"data-row":String(e),"data-col":String(t)});n.style.width=`16px`,n.style.height=`16px`,s.push(n),a.appendChild(n)}let c=(e,t)=>{s.forEach(n=>{n.classList.toggle(`active`,+n.dataset.row<=e&&+n.dataset.col<=t)}),o.textContent=e&&t?`${e} × ${t}`:this.context.locale.contextMenu.table||`Insert Table`};i.appendChild(a),i.appendChild(o);let l=!1,u=v(n,`click`,e=>{e.stopPropagation(),l=!l,i.style.display=l?``:`none`,r.style.transform=l?`rotate(90deg)`:``,this._reposition()});this._menuDisposers.push(u);let d=v(a,`mousemove`,e=>{let t=e.target?.closest(`[data-row]`);t&&c(+t.dataset.row,+t.dataset.col)}),f=v(a,`mouseleave`,()=>c(0,0)),p=v(a,`click`,e=>{let t=e.target?.closest(`[data-row]`);if(!t)return;let n=+t.dataset.row,r=+t.dataset.col,i=this.context.layoutInfo?.editable;if(i&&this._savedRange){i.focus();let e=globalThis.getSelection();e.removeAllRanges(),e.addRange(this._savedRange.cloneRange())}this.hide(),this.context.invoke(`editor.insertTable`,r,n)});this._menuDisposers.push(d,f,p),t.appendChild(n),t.appendChild(i),this.el.appendChild(t);return}let t=h(`button`,{type:`button`,class:`an-context-item`,"data-name":e.name||``});if((typeof e.disabled==`function`?e.disabled(this.context):e.disabled)&&(t.disabled=!0),e.icon){let n=h(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=e.icon,t.appendChild(n)}t.appendChild(h(`span`,{class:`an-context-label`},[this.context.locale.contextMenu[e.name]||e.label||e.name]));let n=v(t,`click`,t=>{if(t.stopPropagation(),this.hide(),this.context.triggerEvent?.(`beforeCommand`,{name:e.name,source:`contextMenu`})!==!1)try{e.action(this.context)}catch(e){console.error(e)}});this._menuDisposers.push(n),this.el.appendChild(t)}))}_onContextMenu(e){let t=this.context.layoutInfo?.editable;if(!t||!t.contains(e.target)||this.context.layoutInfo.container.classList.contains(`an-disabled`))return;e.preventDefault();let n=globalThis.getSelection();this._savedRange=n?.rangeCount>0?n.getRangeAt(0).cloneRange():null,this._renderItems(this._items);let r=e.clientX,i=e.clientY;if(this._savedRange&&!this._savedRange.collapsed)try{let e=this._savedRange.getBoundingClientRect();e.width>0&&e.height>0&&(i=e.bottom+4)}catch{}this._lastX=r,this._lastY=i,this.showAt(r,i)}_maybeHide(e){this.el&&(this.el.contains(e.target)||this.hide())}showAt(e,t){this.el&&(this.el.style.display=`block`,this._reposition(e,t),this.el.setAttribute(`aria-hidden`,`false`),this.context.triggerEvent(`contextMenu:show`))}_reposition(e,t){if(!this.el)return;let n=e===void 0?this._lastX:e,r=t===void 0?this._lastY:t,i=this.el.offsetWidth,a=this.el.offsetHeight,o=n,s=r;o+i>globalThis.innerWidth-8&&(o=globalThis.innerWidth-i-8),o<8&&(o=8),s+a>globalThis.innerHeight-8&&(s=globalThis.innerHeight-a-8),s<8&&(s=8),this.el.style.left=`${o}px`,this.el.style.top=`${s}px`}hide(){this.el&&(this.el.style.display=`none`,this.el.setAttribute(`aria-hidden`,`true`),this.context.triggerEvent(`contextMenu:hide`))}_getSelectionColor(e){let t=this._savedRange;if(!t)return e===`foreColor`?`#000000`:`transparent`;let n=t.startContainer;if(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement),!n)return e===`foreColor`?`#000000`:`transparent`;let r=globalThis.getComputedStyle(n);if(e===`foreColor`)return r.color||`#000000`;let i=r.backgroundColor;return!i||i===`rgba(0, 0, 0, 0)`||i===`transparent`?`transparent`:i}_applyColor(e,t){let n=this.context.layoutInfo?.editable;if(!n||!this._savedRange)return;n.focus();let r=globalThis.getSelection();r.removeAllRanges(),r.addRange(this._savedRange.cloneRange()),document.execCommand(e,!1,t),this.context.invoke(`editor.afterCommand`),this.hide()}hasCopiedFormat(){return!!this._copiedFormat}copyFormat(){let e=this._savedRange;if(!e)return;let t=this.context.layoutInfo?.editable,n=e.startContainer;if(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement),!n||!t?.contains(n))return;let r=globalThis.getComputedStyle(n),i=this._findExplicitStyle(n,t,`fontFamily`),a=this._findExplicitStyle(n,t,`fontSize`);this._copiedFormat={bold:Number.parseInt(r.fontWeight,10)>=700,italic:r.fontStyle===`italic`||r.fontStyle===`oblique`,underline:(r.textDecorationLine||``).includes(`underline`),strikethrough:(r.textDecorationLine||``).includes(`line-through`),fontFamily:i,fontSize:a,color:this._isDefaultColor(r.color)?null:r.color,backgroundColor:r.backgroundColor}}_findExplicitStyle(e,t,n){let r=e;for(;r&&r!==t&&r!==document.body;){if(r.style?.[n])return r.style[n];if(r.nodeName===`FONT`){if(n===`fontFamily`&&r.getAttribute(`face`))return r.getAttribute(`face`);if(n===`fontSize`&&r.getAttribute(`size`))return null}r=r.parentElement}return null}_isDefaultColor(e){return!e||e===`rgb(0, 0, 0)`||e===`rgba(0, 0, 0, 0)`||e===`transparent`}pasteFormat(){if(!this._copiedFormat||!this._savedRange)return;let e=this._copiedFormat,t=this.context.layoutInfo?.editable;if(!t)return;t.focus();let n=globalThis.getSelection();if(n.removeAllRanges(),n.addRange(this._savedRange.cloneRange()),document.execCommand(`removeFormat`),e.bold&&document.execCommand(`bold`),e.italic&&document.execCommand(`italic`),e.underline&&document.execCommand(`underline`),e.strikethrough&&document.execCommand(`strikeThrough`),e.color&&document.execCommand(`foreColor`,!1,e.color),(e=>!e||e===`rgba(0, 0, 0, 0)`||e===`transparent`)(e.backgroundColor)||document.execCommand(`hiliteColor`,!1,e.backgroundColor),e.fontFamily&&document.execCommand(`fontName`,!1,e.fontFamily),e.fontSize){let n=`fs-${Date.now()}`,r=new Set(t.querySelectorAll(`font[size="7"]`));document.execCommand(`fontSize`,!1,`7`),t.querySelectorAll(`font[size="7"]`).forEach(e=>{r.has(e)||(e.dataset.anTmp=n)}),t.querySelectorAll(`[data-an-tmp="${n}"]`).forEach(t=>{let n=document.createElement(`span`);for(n.style.fontSize=e.fontSize,t.parentNode.insertBefore(n,t);t.firstChild;)n.appendChild(t.firstChild);t.remove()})}this.context.invoke(`editor.afterCommand`)}removeFormat(){if(!this._savedRange)return;let e=this.context.layoutInfo?.editable;if(!e)return;e.focus();let t=globalThis.getSelection();t.removeAllRanges(),t.addRange(this._savedRange.cloneRange()),document.execCommand(`removeFormat`);let n=t.getRangeAt(0),r=n.commonAncestorContainer,i=r.nodeType===Node.TEXT_NODE?r.parentElement:r,a=document.createNodeIterator(i,NodeFilter.SHOW_ELEMENT),o;for(;o=a.nextNode();)if(!(!e.contains(o)||o===e))try{n.intersectsNode(o)&&o.removeAttribute(`style`)}catch{}this.context.invoke(`editor.afterCommand`)}},ii=/[^\s\u200B]/;function ai(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=t.nextNode();e;e=t.nextNode())if(ii.test(e.data))return!0;return!1}var oi=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){let e=this.context.layoutInfo.editable,t=this.options.placeholder||``;t&&(e.dataset.placeholder=t);let n=()=>this._update(),r=v(e,`input`,n),i=v(e,`focus`,n),a=v(e,`blur`,n);return this._disposers.push(r,i,a),this._update(),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[]}_update(){let e=this.context.layoutInfo.editable,t=document.activeElement===e,n=!ai(e)&&!e.querySelector(`img, table, hr, .an-video-wrapper`);e.classList.toggle(`an-placeholder`,n&&!t)}},si=class{constructor(e){this.context=e,this.options=e.options,this._active=!1,this._textarea=null,this._disposers=[]}initialize(){return this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._textarea?.remove(),this._textarea=null}toggle(){this._active?this.deactivate():this.activate()}isActive(){return this._active}activate(){if(this._active)return;let{editable:e}=this.context.layoutInfo,t=e.innerHTML;this._textarea=h(`textarea`,{class:`an-codeview`,spellcheck:`false`,autocomplete:`off`,autocorrect:`off`,autocapitalize:`off`}),this._textarea.value=this._prettyPrint(t),e.style.display=`none`,e.parentNode.insertBefore(this._textarea,e.nextSibling),this._active=!0,this.context.invoke(`toolbar.refresh`)}deactivate(){if(!this._active||!this._textarea)return;let{editable:e}=this.context.layoutInfo;e.innerHTML=M(this._textarea.value,{allowIframes:!0,iframeHosts:this.context.options.iframeHosts}),this._textarea.remove(),this._textarea=null,e.style.display=``,this._active=!1,this.context.invoke(`toolbar.refresh`),this.context.invoke(`editor.afterCommand`)}_prettyPrint(e){let t=/^<(a|abbr|b|bdo|br|button|cite|code|dfn|em|i|img|input|kbd|label|output|q|samp|select|small|span|strong|sub|sup|textarea|time|tt|u|var)([\s>/])/i,n=0;return e.replace(/>\s*</g,(e,n,r)=>{let i=r.slice(n+1);return t.test(i.trimStart())?`><`:`>
37
+ `);t=Oi(t);let n=ki(t);return t=n.clean,Ei=n.linkDefs,Di=n.footnoteIds,Ti(t)}function Ti(e){let t=[],n=0;for(;n<e.length;){let r=e[n],i=bi(r);if(i){let r=RegExp(`^ {0,3}\\${i.marker}{${i.length},}[ \t]*$`),a=[];for(n++;n<e.length&&!r.test(e[n]);)a.push($i(xi(e[n],i.indent))),n++;let o=i.lang?` class="language-${ea(i.lang)}"`:``;t.push(`<pre><code${o}>${a.join(`
38
+ `)}</code></pre>`),n++;continue}if(vi.test(r)){let r=[];for(;n<e.length&&(vi.test(e[n])||e[n].trim()===``);){if(e[n].trim()===``){let t=n;for(;t<e.length&&e[t].trim()===``;)t++;if(t>=e.length||!vi.test(e[t]))break;for(;n<t;n++)r.push(``);continue}r.push($i(xi(e[n],4))),n++}t.push(`<pre><code>${r.join(`
39
+ `)}</code></pre>`);continue}if(r.trim()&&!Si.test(r)&&!/^#{1,6} /.test(r)&&n+1<e.length){if(/^=+\s*$/.test(e[n+1])){t.push(`<h1>${U(r.trim())}</h1>`),n+=2;continue}if(/^-{2,}\s*$/.test(e[n+1])){t.push(`<h2>${U(r.trim())}</h2>`),n+=2;continue}}if(Si.test(r)){t.push(`<hr>`),n++;continue}let a=/^(#{1,6})[ \t]+(.*)$/.exec(r);if(a){let e=a[1].length,r=a[2].replace(/(?:^|\s)#+\s*$/,``);t.push(`<h${e}>${U(r)}</h${e}>`),n++;continue}if(_i.test(r)){let r=[];for(;n<e.length&&_i.test(e[n]);)r.push(_i.exec(e[n])[2]),n++;t.push(`<blockquote>${Ti(r)}</blockquote>`);continue}if(/^[-*+] /.test(r)){let{html:r,endIdx:i}=Fi(e,n);t.push(r),n=i;continue}if(/^\d+[.)] /.test(r)){let{html:r,endIdx:i}=Fi(e,n);t.push(r),n=i;continue}if(r.trim()===``){n++;continue}if(Ni(e,n)){let i=Pi(r),a=Pi(e[n+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:e.startsWith(`:`)?`left`:null);n+=2;let o=[];for(;n<e.length&&e[n].trim()!==``&&Mi(e[n]);)o.push(Pi(e[n])),n++;let s=(e,t,n)=>`<${e}${n?` style="text-align:${n}"`:``}>${U(t)}</${e}>`,c=`<thead><tr>${i.map((e,t)=>s(`th`,e,a[t])).join(``)}</tr></thead>`,l=o.length?`<tbody>${o.map(e=>`<tr>${e.map((e,t)=>s(`td`,e,a[t])).join(``)}</tr>`).join(``)}</tbody>`:``;t.push(`<table>${c}${l}</table>`);continue}let o=[];for(;n<e.length&&e[n].trim()!==``&&!/^(#{1,6} |[-*+] |\d+[.)] )/.test(e[n])&&!bi(e[n])&&!_i.test(e[n])&&!Si.test(e[n])&&!Ni(e,n)&&!(n+1<e.length&&/^=+\s*$/.test(e[n+1]))&&!(n+1<e.length&&/^-{2,}\s*$/.test(e[n+1]));)o.push(e[n]),n++;o.length?t.push(`<p>${U(Ai(o)).replaceAll(Ci,`<br>`)}</p>`):(t.push(`<p>${U(r)}</p>`),n++)}return t.join(``)}var Ei=new Map,Di=new Set;function Oi(e){if((e[0]||``).trim()!==`---`)return e;let t=-1;for(let n=1;n<e.length;n++){let r=e[n].trim();if(r===`---`||r===`...`){t=n;break}}if(t===-1||!e.slice(1,t).every(e=>e.trim()===``||/^[ \t]*[\w$.-]+\s*:(\s|$)/.test(e)||/^[ \t]*-\s+\S/.test(e)||/^[ \t]+\S/.test(e)))return e;let n=t+1;return e[n]!==void 0&&e[n].trim()===``&&n++,e.slice(n)}function ki(e){let t=new Map,n=new Set,r=[],i=!1,a=/^\[([^\]]+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/,o=/^\[\^([^\]]+)\]:[ \t]*(\S.*)$/;for(let s of e){if(i){/^ {0,3}(?:`{3,}|~{3,})[ \t]*$/.test(s)&&(i=!1),r.push(s);continue}if(bi(s)){i=!0,r.push(s);continue}{let e=o.exec(s);if(e){n.add(e[1]);continue}let r=a.exec(s);if(r){t.set(r[1].trim().toLowerCase(),{href:r[2],title:r[3]});continue}}r.push(s)}return{clean:r,linkDefs:t,footnoteIds:n}}function Ai(e){let t=``;for(let n=0;n<e.length;n++){let r=n===e.length-1,i=e[n].replace(/^[ \t]+/,``);if(!r&&/\\$/.test(i)){t+=i.replace(/\\$/,``)+Ci;continue}if(!r&&/ {2,}$/.test(i)){t+=i.replace(/ {2,}$/,``)+Ci;continue}t+=i+(r?``:` `)}return t}function ji(e){return Pi(e).length}function Mi(e){return e.includes(`|`)?/^\s*\|/.test(e)||ji(e)>1:!1}function Ni(e,t){let n=e[t],r=e[t+1];if(r===void 0||!n.includes(`|`))return!1;if(/^\|.+\|/.test(n))return/^\|[\s|:-]+\|/.test(r);let i=Pi(r);return i.length<2||!i.every(e=>/^:?-+:?$/.test(e))?!1:ji(n)===i.length}function Pi(e){let t=e.replace(/^\|/,``).replace(/\|$/,``),n=[],r=``;for(let e=0;e<t.length;e++){if(t[e]===`\\`&&t[e+1]===`|`){r+=`|`,e++;continue}if(t[e]===`|`){n.push(r),r=``;continue}r+=t[e]}return n.push(r),n.map(e=>e.trim())}function Fi(e,t){let n=e[t].match(/^(\s*)/)[1].length,r=/^\s*\d+[.)] /.test(e[t]),i=[],a=null,o=!1,s=!1,c=t;for(;c<e.length;){let t=e[c];if(t.trim()===``){let t=e[c+1],a=t===void 0?-1:t.match(/^(\s*)/)[1].length,l=t!==void 0&&/^\s*(?:[-*+]|\d+[.)]) /.test(t)&&/^\s*\d+[.)] /.test(t)===r&&a===n,u=t!==void 0&&t.trim()!==``&&a>n;if(!i.length||!l&&!u)break;o=!0,s=!0,c++;continue}let l=t.match(/^(\s*)/)[1].length;if(l<n)break;if(l===n){if(!/^\s*(?:[-*+]|\d+[.)]) /.test(t)||/^\s*\d+[.)] /.test(t)!==r)break;let e=r?t.replace(/^\s*\d+[.)] /,``):t.replace(/^\s*[-*+] /,``),n=!r&&/^\[[ xX]\]\s+/.test(e);if(a===null&&(a=n),n!==a)break;let o=n&&e[1].toLowerCase()===`x`,l=n?e.replace(/^\[[ xX]\]\s+/,``):e;i.push({paras:[l],isCB:n,checked:o,sub:``}),s=!1,c++}else{if(!i.length){c++;continue}let n=e=>xi(e,l),r=bi(n(t));if(r){let t=RegExp(`^ {0,3}\\${r.marker}{${r.length},}[ \t]*$`),a=[n(e[c])];for(c++;c<e.length&&!t.test(n(e[c]));)a.push(n(e[c])),c++;c<e.length&&(a.push(n(e[c])),c++),i[i.length-1].sub+=Ti(a),s=!1;continue}if(/^\s*(?:[-*+]|\d+[.)]) /.test(t)){let t=Fi(e,c);i[i.length-1].sub+=t.html,c=t.endIdx,s=!1}else if(s)i[i.length-1].paras.push(t.trim()),s=!1,c++;else{let e=i[i.length-1].paras;e[e.length-1]+=` `+t.trim(),c++}}}let l=!r&&a===!0,u=r?/^\s*(\d+)[.)] /.exec(e[t]):null,d=u?Number.parseInt(u[1],10):1,f=r?d===1?`<ol>`:`<ol start="${d}">`:l?`<ul class="an-checklist">`:`<ul>`,p=r?`</ol>`:`</ul>`;return{html:`${f}${i.map(({paras:e,isCB:t,checked:n,sub:r})=>{let i=t?`<input type="checkbox" contenteditable="false"${n?` checked`:``}>`:``;return`<li>${o?e.map((e,t)=>`<p>${t===0?i:``}${U(e)}</p>`).join(``):`${i}${U(e[0])}`}${r}</li>`}).join(``)}${p}`,endIdx:c}}var Ii=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,Li=`\0`,Ri=``,zi=/(`+)([^]*?)\1/g;function Bi(e){let t=[];return{text:e.replace(zi,(e,n,r)=>r===``?e:(t.push(r),`${Ri}${t.length-1}${Ri}`)),codes:t}}function Vi(e,t,n){return e.replace(RegExp(`${Ri}(\\d+)${Ri}`,`g`),(e,r)=>{let i=t[Number(r)];return i=i.replace(RegExp(`${Li}(\\d+)${Li}`,`g`),(e,t)=>`\\${n[Number(t)]}`),i.length>2&&i.startsWith(` `)&&i.endsWith(` `)&&i.trim()!==``&&(i=i.slice(1,-1)),`<code>${$i(i)}</code>`})}function Hi(e){let t=[];return{text:e.replace(Ii,(e,n)=>(t.push(n),`${Li}${t.length-1}${Li}`)),literals:t}}function Ui(e,t){return e.replace(RegExp(`${Li}(\\d+)${Li}`,`g`),(e,n)=>Qi(t[Number(n)]))}var Wi=String.raw`(&lt;.*?&gt;(?:\s+(?:"[^"]*"|'[^']*'))?|[^)]*)`,Gi=new RegExp(String.raw`!\[([^\]]*)\]\(${Wi}\)`,`g`),Ki=new RegExp(String.raw`\[([^\]]+)\]\(${Wi}\)`,`g`);function qi(e){let t=e.trim(),n=/^&lt;([\s\S]*?)&gt;(?:[ \t]*(?:"([^"]*)"|'([^']*)'))?[ \t]*$/.exec(t);if(n)return{href:n[1],title:n[2]??n[3]??``};let r=/^(\S+)\s+(?:"([^"]*)"|'([^']*)')\s*$/.exec(t);return r?{href:r[1],title:r[2]??r[3]??``}:{href:t,title:``}}function Ji(e){return e=e.replace(Gi,(e,t,n)=>{let{href:r,title:i}=qi(n),a=i?` title="${W(i)}"`:``;return`<img src="${W(r)}" alt="${W(t)}"${a} class="an-image">`}),e=e.replace(Ki,(e,t,n)=>{let{href:r,title:i}=qi(n),a=i?` title="${W(i)}"`:``;return`<a href="${W(r)}"${a}>${t}</a>`}),e=e.replace(/\[([^\]]+)\]\[([^\]]*)\]/g,(e,t,n)=>{let r=Ei.get(ta(n||t).trim().toLowerCase());if(!r)return e;let i=r.title?` title="${ea(r.title)}"`:``;return`<a href="${ea(r.href)}"${i}>${t}</a>`}),e=e.replace(/\[([^\]]+)\]/g,(e,t)=>{let n=Ei.get(ta(t).trim().toLowerCase());if(!n)return e;let r=n.title?` title="${ea(n.title)}"`:``;return`<a href="${ea(n.href)}"${r}>${t}</a>`}),e=e.replace(/\[\^([^\]]+)\]/g,(e,t)=>Di.has(ta(t))?`<sup>[${t}]</sup>`:e),e}function Yi(e){return e=e.replace(/&lt;(https?:\/\/[^\s&]+?)&gt;/g,(e,t)=>`<a href="${W(t)}">${t}</a>`),e=e.replace(/&lt;([\w.!#$%&'*+/=?^`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+)&gt;/g,(e,t)=>`<a href="mailto:${W(t)}">${t}</a>`),e=e.replace(/(^|[\s(])(https?:\/\/[^\s()]+)/g,(e,t,n)=>{let r=/[.,;:!?)]+$/.exec(n),i=r?n.slice(0,-r[0].length):n;if(!i)return e;let a=r?r[0]:``;return`${t}<a href="${W(i)}">${i}</a>${a}`}),e}function Xi(e){return e=e.replace(/\*{3}([^*\n]+?)\*{3}/g,(e,t)=>`<strong><em>${t}</em></strong>`),e=e.replace(/(?<!\w)_{3}([^_\n]+?)_{3}(?!\w)/g,(e,t)=>`<strong><em>${t}</em></strong>`),e=e.replace(/\*{2}([^*\n]+?)\*{2}/g,(e,t)=>`<strong>${t}</strong>`),e=e.replace(/(?<!\w)_{2}([^_\n]+?)_{2}(?!\w)/g,(e,t)=>`<strong>${t}</strong>`),e=e.replace(/\*([^*\n]+?)\*/g,(e,t)=>`<em>${t}</em>`),e=e.replace(/(?<!\w)_([^_\n]+?)_(?!\w)/g,(e,t)=>`<em>${t}</em>`),e=e.replace(/~~([^~\n]+?)~~/g,(e,t)=>`<del>${t}</del>`),e=e.replace(/\^([^\s^]+)\^/g,(e,t)=>`<sup>${t}</sup>`),e=e.replace(/(?<!~)~([^\s~]+)~(?!~)/g,(e,t)=>`<sub>${t}</sub>`),e=e.replace(/&lt;u&gt;(.+?)&lt;\/u&gt;/g,(e,t)=>`<u>${t}</u>`),e=e.replace(/&lt;span style=(?:&quot;|")([^"<>&]*(?:&amp;[^"<>&]*)*)(?:&quot;|")&gt;(.*?)&lt;\/span&gt;/g,(e,t,n)=>`<span style="${t}">${n}</span>`),e}function U(e){let{text:t,literals:n}=Hi(e),{text:r,codes:i}=Bi(t),a=Qi(r);return a=Ji(a),a=Yi(a),a=Xi(a),Vi(Ui(a,n),i,n)}var Zi=/&(?!#\d+;|#[xX][0-9a-fA-F]+;|[a-zA-Z][a-zA-Z0-9]*;)/g;function Qi(e){return String(e).replace(Zi,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function $i(e){return String(e).replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function ea(e){return String(e).replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&#39;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function W(e){return String(e).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&#39;`)}function ta(e){return String(e).replaceAll(`&lt;`,`<`).replaceAll(`&gt;`,`>`).replaceAll(`&amp;`,`&`)}var na=5,ra=2,ia=[[`typescript`,`javascript`],[`scss`,`css`],[`cpp`,`c`]],aa=[{lang:`php`,w:10,re:/<\?php\b|<\?=/},{lang:`bash`,w:10,re:/^#!.*\/(?:ba|z|da|fi|k)?sh\b/m},{lang:`rust`,w:10,re:/\b(?:println!|print!|format!|vec!|panic!)\s*[([]/},{lang:`go`,w:10,re:/\bfmt\.(?:Print|Println|Printf|Sprintf|Errorf|Fprintf)\s*\(/},{lang:`java`,w:10,re:/\bSystem\.out\.(?:print|println)\s*\(/},{lang:`csharp`,w:10,re:/\bConsole\.(?:Write|WriteLine)\s*\(/},{lang:`cpp`,w:10,re:/\b(?:cout|cerr)\s*<<|\bcin\s*>>|\busing\s+namespace\s+std\b|\bstd::\w/},{lang:`python`,w:10,re:/\bdef[ \t]+\w+[ \t]*\([^)]*\)[ \t]*(?:->[^:\n]*)?:|\bif[ \t]+__name__[ \t]*==[ \t]*['"]__main__['"]/},{lang:`html`,w:10,re:/^\s*<!DOCTYPE\s+html/i},{lang:`xml`,w:10,re:/^\s*<\?xml\s/i},{lang:`javascript`,w:6,re:/\bconsole\.(?:log|error|warn|info|debug)\s*\(/},{lang:`javascript`,w:6,re:/\b(?:const|let)\s+\w+\s*=|(?:^|\n)\s*var\s+\w+\s*=/},{lang:`javascript`,w:8,re:/\bexport\s+(?:default|const|function|class|async|\{|\*)|\bmodule\.exports\b|\brequire\s*\(\s*['"]/},{lang:`javascript`,w:5,re:/\bfunction(?:[ \t]+\w+)?[ \t]*\([^)]*\)[ \t]*\{|=>[ \t]*[{([`\w'"]/},{lang:`javascript`,w:5,re:/\bimport\b[^'"\n]*[ \t]from[ \t]*['"]/},{lang:`javascript`,w:4,re:/\.(?:map|filter|forEach|reduce|then|catch|find|some|every)\s*\(/},{lang:`javascript`,w:4,re:/\b(?:document|window|globalThis)\.\w/},{lang:`javascript`,w:4,re:/\baddEventListener\s*\(|\bquerySelector(?:All)?\s*\(|\bgetElementById\s*\(/},{lang:`javascript`,w:3,re:/\.(?:innerHTML|textContent|classList|dataset|style)\b|\bJSON\.(?:parse|stringify)\s*\(/},{lang:`javascript`,w:4,re:/\bawait\s+\w|\basync\s+(?:function|\(|\w+\s*=>)|\bnew\s+Promise\s*\(/},{lang:`javascript`,w:3,re:/\bReact\.|\buseState\s*\(|\buseEffect\s*\(/},{lang:`typescript`,w:8,re:/\binterface\s+\w+(?:<[^>]*>)?\s*(?:extends\s[\w<>, ]+)?\{/},{lang:`typescript`,w:8,re:/\btype\s+\w+(?:<[^>]*>)?\s*=/},{lang:`typescript`,w:7,re:/:\s*(?:string|number|boolean|void|never|any|unknown|object)\b/},{lang:`typescript`,w:6,re:/\benum\s+\w+\s*\{|\breadonly\s+\w|\bimplements\s+\w|\bnamespace\s+\w+\s*\{/},{lang:`typescript`,w:6,re:/\b(?:private|public|protected)\s+(?:readonly\s+)?\w+\s*[:?]/},{lang:`typescript`,w:5,re:/\)\s*:\s*[A-Z]\w*(?:<[^>]*>)?\s*(?:\{|=>)|\)\s*:\s*(?:string|number|boolean|void)\b/},{lang:`typescript`,w:4,re:/\bfunction\s+\w+\s*<[^>]+>\s*\(|\bas\s+(?:const\b|[A-Z]\w*)/},{lang:`typescript`,w:3,re:/\w\?\s*:\s*\w|\bimport\s+type\b|\bsatisfies\b/},{lang:`python`,w:6,re:/(?:^|\n)\s*(?:from\s+[\w.]+\s+import\s|import\s+\w+(?:\s*,\s*\w+)*\s*$)/m},{lang:`python`,w:6,re:/(?:^|\n)\s*class\s+\w+(?:\([\w., ]*\))?\s*:/},{lang:`python`,w:5,re:/(?:^|\n)\s*(?:with|elif|except|finally|async\s+def)\b[^\n]*:/},{lang:`python`,w:5,re:/\bself\.\w|\b__init__\b|\bf["'][^"']*\{/},{lang:`python`,w:4,re:/(?:^|\n)[ \t]*for[ \t]+\w+[ \t]+in[ \t][^\n:]*:|\bfor[ \t]+\w+[ \t]+in[ \t]+range[ \t]*\(/},{lang:`python`,w:4,re:/\bprint\s*\(|\blen\s*\(|\brange\s*\(/},{lang:`python`,w:3,re:/\[[^\]\n]*\bfor\s+\w+\s+in\s[^\]\n]*\]|\bNone\b|\bTrue\b|\bFalse\b/},{lang:`python`,w:3,re:/\*\*\w|\bdict[ \t]*\(|\blambda(?:[ \t]+\w+)?[ \t]*:/},{lang:`go`,w:8,re:/(?:^|\n)\s*package\s+\w+\s*$/m},{lang:`go`,w:6,re:/\btype\s+\w+\s+struct\s*\{|\btype\s+\w+\s+interface\s*\{/},{lang:`go`,w:6,re:/\bfunc(?:[ \t]*\([^)]*\))?(?:[ \t]+\w+)?[ \t]*\([^)]*\)[^\n{]{0,40}\{/},{lang:`go`,w:5,re:/\bif\s+err\s*!=\s*nil\b|\berr\s*:=\s|\bdefer\s+\w/},{lang:`go`,w:4,re:/\w+\s*:=\s*\S|\bchan\s+\w|\bgo\s+func\b|\bnil\b/},{lang:`rust`,w:7,re:/\bfn[ \t]+\w+(?:<[^>]*>)?[ \t]*\([^)]*\)[^\n{]{0,40}\{/},{lang:`rust`,w:7,re:/\blet\s+mut\s+\w|\bpub\s+(?:fn|struct|enum|mod|use)\b|\bimpl\s+\w/},{lang:`rust`,w:5,re:/\buse\s+(?:std|crate|self|super)::|\bmatch\s+\w+\s*\{[^}]*=>/},{lang:`rust`,w:4,re:/\b(?:Option|Result|Vec|Box|Rc|Arc|HashMap)\s*<|&(?:mut\s+)?self\b|\b\w+::<|->\s*Result</},{lang:`rust`,w:3,re:/\b(?:i8|i16|i32|i64|u8|u16|u32|u64|usize|isize|f32|f64)\b|\bunwrap\s*\(\)|\bderive\s*\(/},{lang:`java`,w:7,re:/\b(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)?(?:void|int|long|double|boolean|String|[A-Z]\w*(?:<[^>]*>)?)\s+\w+\s*[({]/},{lang:`java`,w:7,re:/\bimport\s+(?:java|javax|org\.springframework)\.[\w.]+;/},{lang:`java`,w:6,re:/@(?:Override|Autowired|Component|Service|Controller|RestController|Entity|Test|SpringBootApplication)\b/},{lang:`java`,w:5,re:/\bnew\s+(?:ArrayList|HashMap|HashSet|LinkedList|StringBuilder)\s*<[^>]*>\s*\(|\bthrows\s+\w*Exception/},{lang:`java`,w:4,re:/\bpublic\s+(?:class|interface|enum)\s+\w|\bextends\s+\w+\s*\{|\bList<\w|\bMap<\w/},{lang:`csharp`,w:8,re:/\busing\s+System(?:\.[\w.]+)?\s*;|\bnamespace\s+[\w.]+\s*[{;]/},{lang:`csharp`,w:8,re:/\{\s*get;\s*(?:private\s+)?set;\s*\}|\b(?:public|private|protected|internal)\s+(?:static\s+)?async\s+Task(?:<[^>]*>)?\s+\w/},{lang:`csharp`,w:6,re:/\basync\s+Task(?:<[^>]*>)?\s+\w|\bawait\s+\w+\.\w+Async\s*\(/},{lang:`csharp`,w:5,re:/\bIEnumerable<|\bvar\s+\w+\s*=\s*new\s+\w|\bpublic\s+override\b|\[\s*(?:HttpGet|HttpPost|Serializable|Required)\s*\]/},{lang:`csharp`,w:3,re:/\.(?:Select|Where|FirstOrDefault|ToList|Any)\s*\(|\bstring\[\]\s+args\b/},{lang:`kotlin`,w:8,re:/\bfun\s+\w+\s*\([^)]*\)\s*(?::\s*[\w<>?.]+\s*)?[={]|\bdata\s+class\s+\w/},{lang:`kotlin`,w:6,re:/\bval[ \t]+\w+(?:[ \t]*:[ \t]*[\w<>?.]+)?[ \t]*=|\bcompanion[ \t]+object\b|\bsuspend[ \t]+fun\b/},{lang:`kotlin`,w:4,re:/\bprintln\s*\(|\bwhen\s*\([^)]*\)\s*\{|\bobject\s+\w+\s*[:{]|\?:\s*\w/},{lang:`swift`,w:8,re:/\bguard\s+(?:let|var)\s[^\n]*\belse\b|\bfunc\s+\w+\s*\([^)]*\)\s*(?:async\s+)?(?:throws\s+)?->\s*[\w<>?[\]]/},{lang:`swift`,w:6,re:/\bprotocol[ \t]+\w+[^\n{]{0,40}\{|\bextension[ \t]+\w+[^\n{]{0,40}\{|\bimport[ \t]+(?:SwiftUI|UIKit|Foundation)\b/},{lang:`swift`,w:6,re:/\b(?:let|var)\s+\w+\s*:\s*(?:Int|String|Double|Float|Bool|Character|Any|\[[A-Z])|@(?:State|Binding|Published|IBOutlet|objc)\b/},{lang:`swift`,w:4,re:/\\\(\w|\bif[ \t]+let[ \t]+\w|\bstruct[ \t]+\w+[ \t]*:[ \t]*View\b|\bfunc[ \t]+\w+[ \t]*\([^)]*:[ \t]*[A-Z]/},{lang:`swift`,w:3,re:/\?\?\s*\w|\b\w+\?\.\w|\bself\.\w+\s*=/},{lang:`cpp`,w:8,re:/#include\s*<(?:iostream|vector|map|set|algorithm|string|memory|utility)>/},{lang:`cpp`,w:6,re:/\btemplate\s*<\s*(?:typename|class)\b|\bnullptr\b|\bnamespace\s+\w+\s*\{/},{lang:`c`,w:8,re:/#include\s*<(?:stdio|stdlib|string|math|time|ctype|unistd)\.h>/},{lang:`c`,w:6,re:/\b(?:printf|scanf|malloc|calloc|free|memcpy|strlen)\s*\(/},{lang:`c`,w:4,re:/\bint\s+main\s*\(\s*(?:void|int\s+argc|\)\s*\{)/},{lang:`c`,w:3,re:/\btypedef\s+struct\b|\bsizeof\s*\(|\bNULL\b/},{lang:`ruby`,w:8,re:/\bdo[ \t]*\|[ \t]*\w[\w, ]*\|/},{lang:`ruby`,w:7,re:/\battr_(?:accessor|reader|writer)\s+:|\brequire(?:_relative)?\s+['"]|\bputs\s+\S/},{lang:`ruby`,w:4,re:/(?:^|\n)[ \t]*def[ \t]+\w/},{lang:`ruby`,w:4,re:/(?:^|\n)[ \t]*end[ \t]*$/m},{lang:`ruby`,w:4,re:/\bnil\?\b|\b\w+\.new\b|=>\s*['"\w]|\bmodule\s+[A-Z]\w*\s*$/m},{lang:`ruby`,w:3,re:/:\w+[ \t]*=>|\bend[ \t]*$/m},{lang:`php`,w:7,re:/\$this->\w|\bfunction\s+\w+\s*\([^)]*\$\w/},{lang:`php`,w:6,re:/\$\w+\s*=\s*\S|\bforeach\s*\(\s*\$\w+\s+as\s+\$/},{lang:`php`,w:5,re:/\becho[ \t][^;\n]*[$'"]|\bnamespace[ \t]+[\w\\]+;|\buse[ \t]+[\w\\]+\\\w+;/},{lang:`php`,w:8,re:/\b(?:public|private|protected)\s+(?:static\s+)?function\s+\w/},{lang:`php`,w:3,re:/->\w+\s*\(|::\w+\s*\(/},{lang:`html`,w:7,re:/<(?:html|head|body|nav|section|article|header|footer|main|form)\b[^>]*>/i},{lang:`html`,w:5,re:/<(?:div|p|span|a|img|ul|ol|li|table|tr|td|input|button|h[1-6])\b[^>]*>[\s\S]*<\/(?:div|p|span|a|ul|ol|li|table|tr|td|button|h[1-6])>/i},{lang:`html`,w:4,re:/<\w+\s+(?:class|id|href|src|type|style)\s*=\s*["']/i},{lang:`xml`,w:6,re:/\bxmlns(?::\w+)?\s*=\s*["']|<\/\w+:\w+>|<\w+:\w+[\s>]/},{lang:`json`,w:8,re:/^\s*[{[][\s\S]*"[\w-]+"\s*:\s*(?:"[^"]*"|-?\d|\{|\[|true|false|null)/},{lang:`json`,w:3,re:/^\s*\{[\s\S]*\}\s*$|^\s*\[[\s\S]*\]\s*$/},{lang:`yaml`,w:8,re:/^---\s*$/m},{lang:`yaml`,w:6,re:/^[ \t]*-\s+\w+\s*:\s*\S/m},{lang:`yaml`,w:5,re:/^[a-z_][\w-]*[ \t]*:(?:[ \t]*$|[ \t]+(?:[|>][-+]?[ \t]*$|['"\w[{]))/im},{lang:`yaml`,w:4,re:/^[ \t]+[a-z_][\w-]*[ \t]*:[ \t]*\S/im},{lang:`yaml`,w:3,re:/^[ \t]*-\s+\S/m},{lang:`markdown`,w:7,re:/^#{1,6}\s+\S/m},{lang:`markdown`,w:6,re:/^```|^\|[^\n|]+\|[^\n]*\n\s*\|[\s:|-]+\|/m},{lang:`markdown`,w:4,re:/\[[^\]\n]+\]\([^)\n]+\)|!\[[^\]\n]*\]\(/},{lang:`markdown`,w:3,re:/\*\*[^*\n]+\*\*|^>\s+\S|^[-*+]\s+\S/m},{lang:`sql`,w:9,re:/(?:^|\n)\s*(?:SELECT\s+[\w*]|INSERT\s+INTO\s|UPDATE\s+\w+\s+SET\s|DELETE\s+FROM\s)/i},{lang:`sql`,w:8,re:/(?:^|\n)\s*(?:CREATE|ALTER|DROP)\s+(?:TABLE|DATABASE|INDEX|VIEW|SCHEMA)\b/i},{lang:`sql`,w:4,re:/\b(?:INNER|LEFT|RIGHT|FULL)\s+(?:OUTER\s+)?JOIN\b|\bGROUP\s+BY\b|\bORDER\s+BY\b|\bWITH\s+\w+\s+AS\s*\(/i},{lang:`scss`,w:9,re:/^[ \t]*\$[\w-]+[ \t]*:[^;\n]+;|@(?:mixin|include|extend|use|forward)[ \t]+[\w"'-]/m},{lang:`scss`,w:7,re:/^[ \t]*&[\s.:[&>+~]|#\{[^}]*\}/m},{lang:`scss`,w:4,re:/^[ \t]*\/\/[ \t]*\S/m},{lang:`css`,w:6,re:/^[ \t]*(?!(?:export|import|return|function|const|let|var|val|if|else|for|while|switch|case|class|new|public|private|protected|internal|def|func|fun|fn|pub|package|type|interface|enum|struct|impl|trait|mod|use|using|namespace|module|data|object|async|await|guard|extension|protocol|template|typedef)\b)[.#]?[\w-]+[^{}\n]{0,60}\{[^{}:]*:[^{};]+[;}]/m},{lang:`css`,w:5,re:/@(?:media|supports|keyframes|font-face|import|charset)\b/},{lang:`css`,w:4,re:/:\s*(?:#[\da-f]{3,8}|\d+(?:px|rem|em|%|vh|vw)|flex|grid|block|none|absolute|relative)\s*[;}]/i},{lang:`css`,w:3,re:/::?(?:hover|focus|active|before|after|first-child|last-child|nth-child)\b/},{lang:`bash`,w:7,re:/(?:^|\n|&&|\|\|)\s*(?:sudo\s+)?(?:apt(?:-get)?|yum|brew|npm|pnpm|yarn|pip3?|docker|kubectl|git|systemctl|curl|wget|chmod|chown|mkdir|rm|cp|mv|tar|ssh|scp)\s+[\w./-]/},{lang:`bash`,w:6,re:/^\s*(?:export|source|alias)\s+\w+|^\s*\w+=\S+\s*$/m},{lang:`bash`,w:6,re:/\bfi[ \t]*$|(?:^|\n)[ \t]*(?:if|for|while)[ \t][^\n]*;[ \t]*(?:then|do)\b|(?:^|\n)[ \t]*done\b/m},{lang:`bash`,w:5,re:/\$\{?\w+\}?[/:]|"\$\w|\becho\s+["'$]|\$\(\w/},{lang:`bash`,w:4,re:/(?:^|\n|\|)\s*(?:grep|awk|sed|cat|ls|cd|pwd|find|xargs|head|tail|sort|uniq|wc)\s+[-\w$'"./]/},{lang:`bash`,w:3,re:/\s\|[ \t]*\w|\s&&\s|\s2>&1|\s-[\w-]+\s/}],oa=4e3;function sa(e){if(e.length<=oa)return e;let t=e.slice(0,oa),n=t.lastIndexOf(`
40
+ `);return n>0?t.slice(0,n):t}function ca(e){if(!e?.trim())return null;let t=sa(e.trim()),n=new Map;for(let{lang:e,re:r,w:i}of aa)r.test(t)&&n.set(e,(n.get(e)||0)+i);if(n.size===0)return null;for(let[e,t]of ia){let r=n.get(e);r&&n.set(e,r+(n.get(t)||0))}let r=[...n.entries()].sort((e,t)=>t[1]-e[1]),[i,a]=r[0],o=r[1]?.[1]??0;return a<na||a-o<ra?null:i}var la=/<(b|i|u|s|sup|sub|strong|em|strike)><\/\1>|<span(?: style="[^"]*")?><\/span>/g;function ua(e){let t;do t=e,e=e.replace(la,``);while(e!==t);return e}var da=new Set([`PRE`,`BLOCKQUOTE`,`TABLE`,`FIGURE`,`UL`,`OL`,`HR`]),fa={undo:{run:e=>e.undo()},redo:{run:e=>e.redo()},bold:{run:e=>e.bold()},italic:{run:e=>e.italic()},underline:{run:e=>e.underline()},inlineCode:{run:e=>e.inlineCode()},link:{run:e=>e.context.invoke(`linkDialog.show`)},find:{run:e=>e.context.invoke(`findReplace.show`,`find`)},findReplace:{run:e=>e.context.invoke(`findReplace.show`,`replace`)},shortcuts:{run:e=>e.context.invoke(`shortcutsDialog.show`)},pastePlainText:{run:e=>e.context.invoke(`clipboard.setForcePlain`,!0),preventDefault:!1}},pa=class{constructor(e){this.context=e,this.options=e.options,this._history=null,this._disposers=[],this._snapshotTimer=null,this._limitCounter=null}initialize(){let e=this.context.layoutInfo.editable;return this._history=new Lr(e,this.options.historyLimit||100,this.options.historyMaxBytes||10485760),this._bindEvents(e),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._history=null,clearTimeout(this._snapshotTimer),this._snapshotTimer=null}_bindEvents(e){let t=e=>this._onKeydown(e),n=t=>{t?.isComposing||Ge(e),this.afterCommand()},r=e=>this._enforceLimit(e),i=()=>{if(!this.context._alive)return;let t=globalThis.getSelection();t?.rangeCount>0&&e.contains(t.anchorNode)&&(this.context.invoke(`toolbar.refresh`),this.context.triggerEvent(`selectionChange`,this.context))},a=e=>{e.target.type===`checkbox`&&e.target.closest(`.an-checklist`)&&this.afterCommand()},o=t=>{let n=globalThis.getSelection();if(!n?.rangeCount)return;let r=n.getRangeAt(0);if(!r.collapsed)return;let i=r.startContainer;if(i.nodeType!==Node.ELEMENT_NODE)return;let a=i,o=a.matches(`.an-checklist li`)?a:null;if(!o)return;let s=o.querySelector(`input[type="checkbox"]`);if(!s)return;if(t?.type===`mouseup`){let r=null;if(document.caretRangeFromPoint)r=document.caretRangeFromPoint(t.clientX,t.clientY);else if(document.caretPositionFromPoint){let e=document.caretPositionFromPoint(t.clientX,t.clientY);e&&(r=document.createRange(),r.setStart(e.offsetNode,e.offset))}if(r&&e.contains(r.startContainer)&&r.startContainer!==o){r.collapse(!0),n.removeAllRanges(),n.addRange(r);return}}let c=document.createRange(),l=null;for(let e of o.childNodes)if(e!==s&&e.nodeType===Node.TEXT_NODE){l=e;break}l?c.setStart(l,0):c.setStartAfter(s),c.collapse(!0),n.removeAllRanges(),n.addRange(c)},s=()=>this.context.layoutInfo.container.classList.contains(`an-disabled`);this._disposers.push(v(e,`keydown`,t),v(e,`beforeinput`,r),v(e,`input`,n),v(document,`selectionchange`,i),v(e,`click`,a),v(e,`mouseup`,o),v(e,`keyup`,o),v(e,`dragstart`,e=>{if(s()){e.preventDefault();return}let t=e.target;t&&(t.nodeName===`IFRAME`||t.closest(`.an-video-wrapper`))&&e.preventDefault()}),v(e,`drop`,e=>{s()&&e.preventDefault()}));let c=null;this._disposers.push(v(e,`compositionstart`,()=>{let e=globalThis.getSelection();if(!e?.rangeCount){c=null;return}let t=e.getRangeAt(0).startContainer;if(t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),t){let e=t;c=e.closest(`sup`)?`superscript`:e.closest(`sub`)?`subscript`:null}}),v(e,`compositionend`,t=>{let n=c;if(c=null,!n)return;let r=globalThis.getSelection();if(!r?.rangeCount)return;let i=r.getRangeAt(0).startContainer;i.nodeType===Node.TEXT_NODE&&(i=i.parentElement);let a=i;if(!(n===`superscript`?a?.closest(`sup`):a?.closest(`sub`))){let i=r.getRangeAt(0),a=(t?.data||``).length,o=i.startContainer;if(a&&o.nodeType===Node.TEXT_NODE&&i.startOffset>=a){let t=document.createRange();t.setStart(o,i.startOffset-a),t.setEnd(o,i.startOffset),r.removeAllRanges(),r.addRange(t),N(n,!0,e),globalThis.getSelection()?.collapseToEnd()}}}))}_onKeydown(e){let t=this.context.layoutInfo.editable;Qr(e,t,this.options)||this._runShortcut(e)}_runShortcut(e){if(!e.ctrlKey&&!e.metaKey&&!e.altKey)return!1;for(let t of this.getKeyBindings()){if(!Ur(e,t.parsed))continue;let{command:n}=t,r=typeof n==`string`?n:t.combo;if(this.context.triggerEvent(`beforeCommand`,{name:r,source:`shortcut`,event:e})===!1)return e.preventDefault(),!0;if(typeof n==`function`)return n(this.context,e)!==!1&&e.preventDefault(),!0;let i=fa[n];if(i)return i.preventDefault!==!1&&e.preventDefault(),i.run(this),!0;let a=an(n,this.options);return a&&typeof a.action==`function`&&!a.type?(e.preventDefault(),a.action(this.context),this.afterCommand(),!0):(console.warn(`[AutumnNote] keyMap: unknown command "${n}".`),!1)}return!1}getKeyBindings(){return(!this._keyBindings||this._keyMapSource!==this.options.keyMap)&&(this._keyMapSource=this.options.keyMap,this._keyBindings=Wr(this.options.keyMap)),this._keyBindings}_enforceLimit(e){let t=this.options.maxChars||0,n=this.options.maxWords||0;if(!t&&!n)return;this._limitCounter??=new ii;let r=e.inputType||``;if(r.startsWith(`delete`)||r===`historyUndo`||r===`historyRedo`||r===`insertFromPaste`||r===`insertFromDrop`||!r.startsWith(`insert`))return;let{words:i,chars:a}=this._limitCounter.counts(this.context.layoutInfo.editable);if(t&&a>=t){e.preventDefault(),this.context.triggerEvent(`charLimitReached`,this.context);return}n&&(e.data===` `||r===`insertParagraph`||r===`insertLineBreak`)&&i>=n&&(e.preventDefault(),this.context.triggerEvent(`wordLimitReached`,this.context))}afterCommand(){this._cleanOrphanedFigures(),this._ensureTrailingParagraph(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this._scheduleSnapshot()}_scheduleSnapshot(){clearTimeout(this._snapshotTimer),this._snapshotTimer=setTimeout(()=>{this._snapshotTimer=null,this._history&&this._history.recordUndo(),this.context.triggerEvent(`change`,this.getHTML())},400)}_cleanOrphanedFigures(){this.context.layoutInfo.editable.querySelectorAll(`figure.an-figure`).forEach(e=>{e.querySelector(`img`)||e.remove()})}_ensureTrailingParagraph(){let e=this.context.layoutInfo.editable;if(!e)return;let t=e.lastElementChild;if(t&&da.has(t.nodeName)){let t=document.createElement(`p`);t.innerHTML=`<br>`,e.appendChild(t)}}focus(){this.context.layoutInfo.editable.focus()}getHTML(){let e=ua(this.context.layoutInfo.editable.innerHTML.replaceAll(`​`,``));return this.context.invoke(`clipboard.resolveImages`,e)??e}setHTML(e){let t=mr(e,{allowIframes:!0,iframeHosts:this.options.iframeHosts});this.context.layoutInfo.editable.replaceChildren(...t.childNodes),this._history&&this._history.reset(),this.afterCommand()}getText(){return this.context.layoutInfo.editable.innerText||``}setText(e){this.context.layoutInfo.editable.textContent=e,this._history&&this._history.reset(),this.afterCommand()}clear(){this.setHTML(``)}clearHistory(){this._history&&this._history.reset()}isEmpty(){let e=(this.context.layoutInfo.editable.innerText||``).trim().replaceAll(`\xA0`,``),t=!!this.context.layoutInfo.editable.querySelector(`img, video, iframe, table`);return!e&&!t}insertHTML(e){e&&(I(`insertHTML`,z(e)),this.afterCommand())}insertText(e){e&&(I(`insertText`,e),this.afterCommand())}setMarkdown(e){this.setHTML(wi(e||``))}getMarkdown(){return oi(this.getHTML())}undo(){this._history&&(this._flushPendingSnapshot(),this._history.undo(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this.context.triggerEvent(`change`,this.getHTML()))}redo(){this._history&&(this._flushPendingSnapshot(),this._history.redo(),this.context.invoke(`toolbar.refresh`),this.context.invoke(`statusbar.update`),this.context.triggerEvent(`change`,this.getHTML()))}_flushPendingSnapshot(){this._snapshotTimer!==null&&(clearTimeout(this._snapshotTimer),this._snapshotTimer=null,this._history?.recordUndo())}canUndo(){return this._history?this._history.canUndo():!1}canRedo(){return this._history?this._history.canRedo():!1}getUndoCount(){return this._history?this._history.getUndoCount():0}getRedoCount(){return this._history?this._history.getRedoCount():0}getSelectionBookmark(){return this._history?._serializeSelection()??null}restoreSelectionBookmark(e){return!e||!this._history?!1:(this._history._restoreSelection(e),!0)}bold(){Ct(),this.afterCommand()}italic(){wt(),this.afterCommand()}underline(){Tt(),this.afterCommand()}strikethrough(){Et(),this.afterCommand()}superscript(){Dt(),this.afterCommand()}subscript(){Ot(),this.afterCommand()}justifyLeft(){Pt(),this.afterCommand()}justifyCenter(){Ft(),this.afterCommand()}justifyRight(){It(),this.afterCommand()}justifyFull(){Lt(),this.afterCommand()}indent(){Rt(),this.afterCommand()}outdent(){Bt(),this.afterCommand()}insertUL(){Wt(),this.afterCommand()}insertOL(){Gt(),this.afterCommand()}inlineCode(){qt(this.context.layoutInfo.editable),this.afterCommand()}toggleChecklist(){Zt(),this.afterCommand()}print(){this.context.print()}formatBlock(e){if(Nt(e),e===`pre`){let e=globalThis.getSelection();if(e?.rangeCount>0){let t=e.getRangeAt(0).commonAncestorContainer,n=t.nodeType===1?t.closest(`pre`):t.parentElement?.closest(`pre`);if(n&&!n.dataset.language){let e=ca(n.textContent||``);if(e){this.context.invoke(`codeTooltip.applyLanguage`,n,e);return}}}}this.afterCommand()}foreColor(e){kt(e),this.afterCommand()}backColor(e){At(e),this.afterCommand()}fontName(e){jt(e),this.afterCommand()}fontSize(e){Mt(e,this.context.layoutInfo.editable),this.afterCommand()}insertHr(){I(`insertHorizontalRule`),this.afterCommand()}insertLink(e,t,n=!1){let r=globalThis.getSelection();if(!r||r.rangeCount===0)return;let i=br(e);if(!i)return;let a=this._newTabRel();if(r.toString().trim().length>0)for(let e of Je(i,this.context.layoutInfo.editable))n&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,a));else{let e=this._escapeAttr(t||i),r=n?` target="_blank" rel="${this._escapeAttr(a)}"`:``;I(`insertHTML`,`<a href="${this._escapeAttr(i)}"${r}>${e}</a>`)}this.afterCommand()}_newTabRel(){let e=this.options.linkDefaults?.rel,t=new Set((typeof e==`string`?e:`noopener noreferrer`).split(/\s+/).filter(Boolean));return t.add(`noopener`),[...t].join(` `)}unlink(){Ye(this.context.layoutInfo.editable),this.afterCommand()}insertImage(e,t=``,n=``){let r=br(e,{allowData:!0});if(!r)return;let i={left:`float:left;margin:0 1em 1em 0`,center:`display:block;margin:0 auto`,right:`float:right;margin:0 0 1em 1em`}[n]||``,a=i?` style="${i}"`:``;I(`insertHTML`,`<img src="${this._escapeAttr(r)}" alt="${this._escapeAttr(t)}" class="an-image"${a}>`),this.afterCommand()}insertVideo(e){e&&(I(`insertHTML`,z(e,{allowIframes:!0,iframeHosts:this.options.iframeHosts})),this.afterCommand())}insertTable(e,t){zr(e,t,{headerRow:this.context.options.tableHeaderRow}),this.afterCommand()}_escapeAttr(e){return String(e??``).replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}},ma=Object.freeze([`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`]);function ha(e){let t=Array.isArray(e?.colorPalette)&&e.colorPalette.length?e.colorPalette:ma,n=Array.isArray(e?.colorSwatches)?e.colorSwatches:[];return[...new Set([...n,...t].filter(e=>typeof e==`string`&&e))]}var ga=null,_a=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,G=e=>`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${_a} style="display:block">${e}</svg>`,va=new Map([[`bold`,G(`<path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/><path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/>`)],[`italic`,G(`<line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/>`)],[`underline`,G(`<path d="M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"/><line x1="4" y1="21" x2="20" y2="21"/>`)],[`strikethrough`,G(`<path d="M17.3 12H6.7"/><path d="M10 6.5C10 5.1 11.1 4 12.5 4c1.4 0 2.5 1.1 2.5 2.5 0 .8-.4 1.5-1 2"/><path d="M14 17.5C14 19 12.9 20 11.5 20 10.1 20 9 18.9 9 17.5c0-.8.4-1.5 1-2"/>`)],[`superscript`,G(`<path d="m4 19 8-8"/><path d="m12 19-8-8"/><path d="M20 12h-4c0-1.5.44-2 1.5-2.5S20 8.33 20 7.25C20 6 19 5 17.5 5S15 6 15 7"/>`)],[`subscript`,G(`<path d="m4 5 8 8"/><path d="m12 5-8 8"/><path d="M20 21h-4c0-1.5.44-2 1.5-2.5S20 17.33 20 16.25C20 15 19 14 17.5 14S15 15 15 16"/>`)],[`align-left`,G(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="15" y1="12" x2="3" y2="12"/><line x1="17" y1="18" x2="3" y2="18"/>`)],[`align-center`,G(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="18" y1="12" x2="6" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/>`)],[`align-right`,G(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="9" y2="12"/><line x1="21" y1="18" x2="7" y2="18"/>`)],[`align-justify`,G(`<line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="3" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/>`)],[`list-ul`,G(`<line x1="9" y1="6" x2="20" y2="6"/><line x1="9" y1="12" x2="20" y2="12"/><line x1="9" y1="18" x2="20" y2="18"/><circle cx="4" cy="6" r="1" fill="currentColor" stroke="none"/><circle cx="4" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="4" cy="18" r="1" fill="currentColor" stroke="none"/>`)],[`list-ol`,G(`<line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1V3"/><path d="M4 10h2l-2 2h2"/><path d="M4 16.5A1.5 1.5 0 0 1 5.5 15a1.5 1.5 0 0 1 0 3H4"/>`)],[`indent`,G(`<polyline points="3 8 7 12 3 16"/><line x1="21" y1="12" x2="11" y2="12"/><line x1="21" y1="6" x2="11" y2="6"/><line x1="21" y1="18" x2="11" y2="18"/>`)],[`outdent`,G(`<polyline points="7 8 3 12 7 16"/><line x1="21" y1="12" x2="11" y2="12"/><line x1="21" y1="6" x2="11" y2="6"/><line x1="21" y1="18" x2="11" y2="18"/>`)],[`undo`,G(`<path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/>`)],[`redo`,G(`<path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"/>`)],[`minus`,G(`<line x1="5" y1="12" x2="19" y2="12"/>`)],[`link`,G(`<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>`)],[`image`,G(`<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/>`)],[`video`,G(`<polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/>`)],[`table`,G(`<rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/>`)],[`emoji`,G(`<circle cx="12" cy="12" r="10"/><path d="M8.5 14.5s1.5 2.5 3.5 2.5 3.5-2.5 3.5-2.5"/><circle cx="9" cy="9" r="1.5" fill="currentColor" stroke="none"/><circle cx="15" cy="9" r="1.5" fill="currentColor" stroke="none"/>`)],[`icon`,G(`<circle cx="8" cy="8" r="3"/><circle cx="16" cy="8" r="3"/><rect x="5" y="13" width="6" height="6" rx="1"/><rect x="13" y="13" width="6" height="6" rx="1"/>`)],[`code`,G(`<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>`)],[`expand`,G(`<polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/>`)],[`foreColor`,G(`<path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/>`)],[`backColor`,G(`<path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/>`)],[`keyboard`,G(`<rect x="2" y="6" width="20" height="12" rx="2"/><line x1="6" y1="10" x2="6" y2="10" stroke-width="2.5"/><line x1="10" y1="10" x2="10" y2="10" stroke-width="2.5"/><line x1="14" y1="10" x2="14" y2="10" stroke-width="2.5"/><line x1="18" y1="10" x2="18" y2="10" stroke-width="2.5"/><line x1="8" y1="14" x2="16" y2="14" stroke-width="2"/>`)],[`caption`,G(`<rect x="3" y="3" width="18" height="11" rx="2"/><line x1="6" y1="18" x2="18" y2="18"/><line x1="9" y1="21" x2="15" y2="21"/>`)],[`remove-format`,G(`<path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/>`)],[`direction`,G(`<path d="M12 20V4"/><path d="m9 7-3 3 3 3"/><path d="M4 10h8"/><path d="m15 7 3 3-3 3"/><path d="M20 10h-8"/>`)],[`search`,G(`<circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>`)],[`find-replace`,G(`<circle cx="10" cy="10" r="6"/><line x1="18" y1="18" x2="14.35" y2="14.35"/><path d="M16 19h6"/><path d="M19 16v6"/>`)],[`inline-code`,G(`<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/><path d="M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1"/>`)],[`checklist`,G(`<rect x="3" y="4" width="5" height="5" rx="1"/><path d="m4 6.5 1 1 2-2"/><rect x="3" y="13" width="5" height="5" rx="1"/><line x1="10" y1="6.5" x2="21" y2="6.5"/><line x1="10" y1="15.5" x2="21" y2="15.5"/>`)],[`print`,G(`<path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/>`)]]),ya=new Map([[`bold`,`fa-bold`],[`italic`,`fa-italic`],[`underline`,`fa-underline`],[`strikethrough`,`fa-strikethrough`],[`superscript`,`fa-superscript`],[`subscript`,`fa-subscript`],[`align-left`,`fa-align-left`],[`align-center`,`fa-align-center`],[`align-right`,`fa-align-right`],[`align-justify`,`fa-align-justify`],[`list-ul`,`fa-list-ul`],[`list-ol`,`fa-list-ol`],[`indent`,`fa-indent`],[`outdent`,`fa-outdent`],[`undo`,`fa-rotate-left`],[`redo`,`fa-rotate-right`],[`minus`,`fa-minus`],[`link`,`fa-link`],[`image`,`fa-image`],[`code`,`fa-code`],[`expand`,`fa-expand`],[`emoji`,`fa-face-smile`],[`icon`,`fa-icons`],[`foreColor`,`fa-font`],[`backColor`,`fa-highlighter`],[`keyboard`,`fa-keyboard`],[`remove-format`,`fa-remove-format`],[`direction`,`fa-arrow-right-arrow-left`],[`search`,`fa-magnifying-glass`],[`find-replace`,`fa-magnifying-glass-plus`],[`inline-code`,`fa-code`],[`checklist`,`fa-list-check`],[`print`,`fa-print`]]),ba={fontFamily:`fontFamilies`,fontSize:`fontSizes`,lineHeight:`lineHeights`,paragraphStyle:`paragraphStyles`},xa=class{constructor(e){this.context=e,this.options=e.options,this.el=null,this._disposers=[],this._colorPickerClosers=[],this._refreshRaf=null}initialize(){return this.el=h(`div`,{class:`an-toolbar`,role:`toolbar`,"aria-orientation":`horizontal`,"aria-label":this.context.locale.a11y?.toolbar||`Editor toolbar`}),this._faReady=this._detectFontAwesome(),this._buildButtons(),this._initRovingFocus(),this._btnMap=new Map((this.options.toolbar||[]).flat().map(e=>this._resolveBtn(e)).filter(Boolean).map(e=>[e.name,e])),this}destroy(){this._refreshRaf&&cancelAnimationFrame(this._refreshRaf),this._refreshRaf=null,this._disposers.forEach(e=>e()),this._disposers=[],this.el?.parentNode&&this.el.remove(),this.el=null}_resolveBtn(e){return typeof e==`string`?an(e,this.options):e}_allow(e,t){return this.context.triggerEvent?.(`beforeCommand`,{name:e,value:t,source:`toolbar`})!==!1}_buildButtons(){let e=this.options.toolbar||[],t=document.createDocumentFragment();e.forEach(e=>{let n=h(`div`,{class:`an-btn-group`});e.forEach(e=>{let t=this._resolveBtn(e);if(!t){console.warn(`[AutumnNote] Toolbar: button "${e}" not found in registry. Skipped.`);return}let r;r=t.type===`select`?this._createSelect(t):t.type===`grid`?this._createGridPicker(t):t.type===`colorpicker`?this._createColorPicker(t):this._createButton(t),n.appendChild(r)}),t.appendChild(n)}),this.el.appendChild(t)}_createGridPicker(e){let t=h(`div`,{class:`an-table-picker-wrap`}),n=h(`button`,{type:`button`,class:this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name,"aria-haspopup":`true`,"aria-expanded":`false`});n.innerHTML=ln(this.options,[e.name,e.icon])||(this._faReady?`<i class="${this.options.fontAwesomeClass||`fas`} fa-table" aria-hidden="true"></i>`:`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:block"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>`);let r=h(`div`,{class:`an-table-picker-popup`,role:`dialog`,"aria-label":this.context.locale.a11y?.tableSize||`Select table size`}),i=h(`div`,{class:`an-table-grid`}),a=h(`div`,{class:`an-table-label`});a.textContent=this.context.locale.toolbar.insertTableLabel||`Insert Table`;let o=[];for(let e=1;e<=10;e++)for(let t=1;t<=10;t++){let n=h(`div`,{class:`an-table-cell`,"data-row":String(e),"data-col":String(t)});o.push(n),i.appendChild(n)}r.appendChild(i),r.appendChild(a);let s=!1,c=(e,t)=>{o.forEach(n=>{let r=+n.dataset.row,i=+n.dataset.col;n.classList.toggle(`active`,r<=e&&i<=t)}),a.textContent=e&&t?`${e} × ${t}`:this.context.locale.toolbar.insertTableLabel||`Insert Table`},l=()=>{s=!0;let e=n.getBoundingClientRect();r.style.visibility=`hidden`,r.style.display=`block`;let t=r.offsetWidth,i=r.offsetHeight,a=e.left,o=e.bottom+4;a+t>globalThis.innerWidth-8&&(a=Math.max(8,globalThis.innerWidth-t-8)),o+i>globalThis.innerHeight-8&&(o=e.top-i-4),r.style.left=`${a}px`,r.style.top=`${o}px`,r.style.visibility=``,n.setAttribute(`aria-expanded`,`true`)},u=()=>{s=!1,r.style.display=`none`,n.setAttribute(`aria-expanded`,`false`),c(0,0)},d=v(n,`click`,e=>{e.stopPropagation(),s?u():l()}),f=v(i,`mouseover`,e=>{let t=e.target?.closest(`.an-table-cell`);t&&c(+t.dataset.row,+t.dataset.col)}),p=v(i,`mouseleave`,()=>c(0,0)),m=v(i,`click`,t=>{let n=t.target?.closest(`.an-table-cell`);if(!n)return;let r=+n.dataset.row,i=+n.dataset.col;u(),this._allow(e.name,{rows:r,cols:i})&&(this.context.invoke(`editor.focus`),e.action(this.context,r,i))}),g=v(document,`click`,()=>{s&&u()});return this._disposers.push(d,f,p,m,g,()=>{r.parentNode&&r.remove()}),t.appendChild(n),b(this.context).appendChild(r),t}_createColorPicker(e){let t=e.defaultColor||`#000000`,n=h(`div`,{class:`an-color-picker-wrap`}),r=this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`,i=h(`button`,{type:`button`,class:`${r} an-color-btn`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name}),a=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,o=e.name===`foreColor`?`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${a} style="display:block"><path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/></svg>`:`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" ${a} style="display:block"><path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/></svg>`;i.innerHTML=ln(this.options,[e.name,e.icon])??o;let s=h(`span`,{class:`an-color-strip`});s.style.background=t,i.appendChild(s);let c=h(`button`,{type:`button`,class:`${r} an-color-arrow`,title:e.name===`foreColor`?this.context.locale.toolbar.chooseTextColor||`Choose text color`:this.context.locale.toolbar.chooseHighlightColor||`Choose highlight color`,"aria-haspopup":`true`,"aria-expanded":`false`});c.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 24 24" fill="currentColor" stroke="none" style="display:block"><path d="M7 10l5 5 5-5H7z"/></svg>`;let l=h(`div`,{class:`an-color-popup`});l.style.display=`none`;let u=h(`div`,{class:`an-color-swatches`});ha(this.options).forEach(e=>{let t=h(`div`,{class:`an-color-swatch`,title:e,"data-color":e});t.style.background=e,u.appendChild(t)});let d=h(`div`,{class:`an-color-custom`}),f=h(`input`,{type:`color`,value:t,title:this.context.locale.toolbar.customColor||`Custom color`}),p=h(`span`,{},[this.context.locale.toolbar.customColor||`Custom color`]);d.appendChild(f),d.appendChild(p),l.appendChild(u),l.appendChild(d);let m=!1,g=null,_=()=>{let e=globalThis.getSelection();g=e?.rangeCount?e.getRangeAt(0).cloneRange():null},y=()=>{if(g)try{let e=globalThis.getSelection();if(!e)return;e.removeAllRanges(),e.addRange(g)}catch{}},ee=()=>{this._colorPickerClosers.forEach(e=>{e!==x&&e()}),_(),m=!0;let e=c.getBoundingClientRect(),t=e.left;t+184>globalThis.innerWidth&&(t=e.right-184),l.style.top=`${e.bottom+4}px`,l.style.left=`${Math.max(4,t)}px`,l.style.display=`block`,c.setAttribute(`aria-expanded`,`true`)},x=()=>{m=!1,l.style.display=`none`,l.style.top=``,l.style.left=``,c.setAttribute(`aria-expanded`,`false`)},S=n=>{if(t=n,s.style.background=n,f.value=n,!this._allow(e.name,n)){x();return}y(),e.action(this.context,n),this.context.invoke(`editor.afterCommand`),x()},C=v(i,`click`,n=>{n.preventDefault(),this._allow(e.name,t)&&(y(),e.action(this.context,t),this.context.invoke(`editor.afterCommand`))}),te=v(c,`mousedown`,e=>{e.preventDefault()}),ne=v(c,`click`,e=>{e.stopPropagation(),m?x():ee()}),w=v(u,`mousedown`,e=>{e.preventDefault()}),re=v(u,`click`,e=>{let t=e.target?.closest(`.an-color-swatch`);t&&S(t.dataset.color)}),ie=v(f,`change`,e=>{S(e.target.value)}),ae=v(document,`click`,e=>{m&&!n.contains(e.target)&&!l.contains(e.target)&&x()}),oe=v(l,`click`,e=>e.stopPropagation()),T=()=>{m&&x()};return document.addEventListener(`scroll`,T,{passive:!0,capture:!0}),globalThis.addEventListener(`resize`,T,{passive:!0}),this._disposers.push(C,te,ne,w,re,ie,ae,oe,()=>document.removeEventListener(`scroll`,T,{capture:!0}),()=>globalThis.removeEventListener(`resize`,T),()=>{l.parentNode&&l.remove()}),this._colorPickerClosers.push(x),this._disposers.push(()=>{let e=this._colorPickerClosers.indexOf(x);e!==-1&&this._colorPickerClosers.splice(e,1)}),n.appendChild(i),n.appendChild(c),b(this.context).appendChild(l),n}_createSelect(e){let t=ba[e.name],n=t?this.options[t]:null,r=Array.isArray(n)&&(n.length||e.name===`fontFamily`)?n:e.items||[],i=h(`select`,{class:e.selectClass?`an-select ${e.selectClass}`:`an-select`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name}),a=h(`option`,{value:``,disabled:``,hidden:``},[this.context.locale.toolbar[e.name+`Placeholder`]||e.placeholder||`Font`]);i.appendChild(a),r.forEach(t=>{let n=typeof t==`object`?t.value:t,r;r=typeof t==`object`?e.name===`paragraphStyle`&&this.context.locale.toolbar.paragraphItems?.[t.value]||t.label:t;let a=typeof t==`object`&&!!t.disabled,o={value:n};a&&(o.disabled=``);let s=h(`option`,o,[r]);e.name===`fontFamily`&&!a&&(s.style.fontFamily=n),i.appendChild(s)});let o=null,s=v(i,`mousedown`,()=>{let e=globalThis.getSelection();o=e?.rangeCount?e.getRangeAt(0).cloneRange():null}),c=v(i,`change`,t=>{let n=t.target.value,r=t.target.options[t.target.selectedIndex];if(!(!n||r.disabled)){if(this.context.invoke(`editor.focus`),o)try{let e=globalThis.getSelection();e&&(e.removeAllRanges(),e.addRange(o))}catch{}this._allow(e.name,n)&&(e.action(this.context,n),this.context.invoke(`editor.afterCommand`))}});return this._disposers.push(s,c),i}_createButton(e){let t=h(`button`,{type:`button`,class:`${this.options.useBootstrap?this.options.toolbarButtonClass||`btn btn-sm btn-light`:`an-btn`}${e.className?` ${e.className}`:``}`,title:this.context.locale.toolbar[e.name]||e.tooltip||``,"data-btn":e.name,"aria-label":this.context.locale.toolbar[e.name]||e.tooltip||e.name,...typeof e.isActive==`function`?{"aria-pressed":`false`}:{}}),n=this.options.fontAwesomeClass||`fas`,r=this._faReady,i=ln(this.options,[e.name,e.icon]);if(i)t.innerHTML=i;else if(r){let r=ya.get(e.icon)||ya.get(e.name)||null;r?t.innerHTML=`<i class="${n} ${r}" aria-hidden="true"></i>`:va.has(e.icon)?t.innerHTML=va.get(e.icon):t.textContent=e.icon||e.name}else va.has(e.icon)?t.innerHTML=va.get(e.icon):va.has(e.name)?t.innerHTML=va.get(e.name):t.textContent=e.icon||e.name;let a=v(t,`click`,t=>{t.preventDefault(),this._allow(e.name)&&(this.context.invoke(`editor.focus`),e.action(this.context),this.context.invoke(`editor.afterCommand`),this.refresh())});return this._disposers.push(a),t}_controls(){return this.el?Array.from(this.el.querySelectorAll(`button, select`)):[]}_navigable(){return this._controls().filter(e=>!e.disabled)}_syncRovingTabindex(e){let t=this._controls(),n=this._navigable();if(!n.length)return;let r=e&&n.includes(e)?e:n.find(e=>e.getAttribute(`tabindex`)===`0`)||n[0];t.forEach(e=>e.setAttribute(`tabindex`,e===r?`0`:`-1`))}_initRovingFocus(){this.el&&(this._syncRovingTabindex(),this._disposers.push(v(this.el,`keydown`,e=>this._onToolbarKeydown(e)),v(this.el,`focusin`,e=>{let t=e.target?.closest?.(`button, select`);t&&this._syncRovingTabindex(t)})))}_onToolbarKeydown(e){if(![`ArrowRight`,`ArrowLeft`,`Home`,`End`].includes(e.key))return;let t=this._navigable(),n=e.target?.closest?.(`button, select`),r=n?t.indexOf(n):-1;if(r===-1)return;let i;if(e.key===`Home`)i=t[0];else if(e.key===`End`)i=t.at(-1);else{let n=this.options.direction===`rtl`;i=t[(r+(e.key===`ArrowRight`===n?-1:1)+t.length)%t.length]}i&&(e.preventDefault(),this._syncRovingTabindex(i),i.focus())}_detectFontAwesome(){if(!this.options.useFontAwesome)return!1;if(ga!==null)return ga;if(document.querySelector(`.fa, .fas, .far, .fal, .fab, .fa-solid`))return ga=!0,!0;let e=Array.from(document.querySelectorAll(`link[rel="stylesheet"]`)).filter(e=>e.id!==`an-fontawesome-css`).map(e=>e.href||``).join(` `);return ga=/fontawesome|font-awesome|use\.fontawesome|all\.css/.test(e),ga}refresh(){this._refreshRaf&&cancelAnimationFrame(this._refreshRaf),this._refreshRaf=requestAnimationFrame(()=>{this._refreshRaf=null,this._doRefresh()})}_doRefresh(){if(!this.el)return;let e=this._btnMap||new Map;this.el.querySelectorAll(`button[data-btn]`).forEach(t=>{let n=e.get(t.dataset.btn);if(n&&typeof n.isActive==`function`){let e=!!n.isActive(this.context);t.classList.toggle(`active`,e),t.setAttribute(`aria-pressed`,String(e))}n&&typeof n.isDisabled==`function`&&(t.disabled=!!n.isDisabled(this.context))}),this._syncRovingTabindex(),this.el.querySelectorAll(`select[data-btn]`).forEach(t=>{let n=e.get(t.dataset.btn);if(!n||typeof n.getValue!=`function`)return;let r=(n.getValue(this.context)||``).replace(/["']/g,``).trim();r||=this.options.defaultFontFamily||this.options.fontFamilies?.[0]||``;let i=t,a=Array.from(i.options).find(e=>e.value?.toLowerCase()===r.toLowerCase());i.value=a?a.value:``})}show(){this.el&&(this.el.style.display=``)}hide(){this.el&&(this.el.style.display=`none`)}rebuild(){this._refreshRaf&&=(cancelAnimationFrame(this._refreshRaf),null),this._disposers.forEach(e=>e()),this._disposers=[],this.el&&(this.el.innerHTML=``),this._faReady=this._detectFontAwesome(),this._buildButtons(),this._initRovingFocus(),this._btnMap=new Map((this.options.toolbar||[]).flat().map(e=>this._resolveBtn(e)).filter(Boolean).map(e=>[e.name,e])),this.refresh()}};function Sa(e,t,n){if(!n){e.classList.remove(`an-count-warn`,`an-count-exceeded`);return}t>n?(e.classList.add(`an-count-exceeded`),e.classList.remove(`an-count-warn`)):t>=n*.9?(e.classList.add(`an-count-warn`),e.classList.remove(`an-count-exceeded`)):e.classList.remove(`an-count-warn`,`an-count-exceeded`)}var Ca=class{constructor(e){this.context=e,this.options=e.options,this.el=null,this._disposers=[],this._handle=null,this._handleDisposers=[],this._wordCountEl=null,this._charCountEl=null,this._counter=new ii}initialize(){this.el=h(`div`,{class:`an-statusbar`}),this._wordCountEl=h(`span`,{class:`an-word-count`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`}),this._charCountEl=h(`span`,{class:`an-char-count`,"aria-live":`polite`,"aria-atomic":`true`});let e=h(`div`,{class:`an-status-info`,"aria-label":this.context.locale.a11y?.statistics||`Editor statistics`});return e.appendChild(this._wordCountEl),e.appendChild(this._charCountEl),this.el.appendChild(e),this.applyResizable(),this.applyVisibility(),this.update(),this}applyResizable(){if(!this.el)return;let e=this.options.resizable!==!1;if(e&&!this._handle){let e=h(`div`,{class:`an-resize-handle`,title:this.context.locale.statusbar.resizeHandle,"aria-hidden":`true`});this._handleDisposers=this._bindResize(e),this.el.prepend(e),this._handle=e}else!e&&this._handle&&(this._handleDisposers.forEach(e=>e()),this._handleDisposers=[],this._handle.remove(),this._handle=null)}applyVisibility(){if(!this.el)return;let e=this.options.statusbar!==!1;this.el.hidden=!e,this.context.layoutInfo.container?.classList.toggle(`an-no-statusbar`,!e)}destroy(){this.context.layoutInfo.container?.classList.remove(`an-no-statusbar`),this._disposers.forEach(e=>e()),this._disposers=[],this._handleDisposers.forEach(e=>e()),this._handleDisposers=[],this._handle=null,this._dragDisposers&&=(this._dragDisposers.forEach(e=>e()),null),this.el?.remove(),this.el=null}_bindResize(e){let t=0,n=0,r=this.context.layoutInfo.container,i=e=>{let i=e-t,a=Array.from(r.children).filter(e=>!e.classList.contains(`an-editable`)).reduce((e,t)=>e+t.offsetHeight,0),o=Math.max(this.options.minHeight||100,a+40);r.style.height=`${Math.max(o,n+i)}px`},a=e=>i(e.clientY),o=()=>{document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o),this._dragDisposers=null},s=e=>{t=e.clientY,n=r.offsetHeight,this.context.layoutInfo.editable.style.minHeight=``,document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o),this._dragDisposers=[()=>document.removeEventListener(`mousemove`,a),()=>document.removeEventListener(`mouseup`,o)],e.preventDefault()},c=e=>{let t=e.touches[0];t&&(e.preventDefault(),i(t.clientY))},l=()=>{document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),this._dragDisposers=null};return[v(e,`mousedown`,s),v(e,`touchstart`,e=>{let i=e.touches[0];i&&(t=i.clientY,n=r.offsetHeight,this.context.layoutInfo.editable.style.minHeight=``,document.addEventListener(`touchmove`,c,{passive:!1}),document.addEventListener(`touchend`,l),this._dragDisposers=[()=>document.removeEventListener(`touchmove`,c),()=>document.removeEventListener(`touchend`,l)])})]}_counts(){return this._counter.counts(this.context.layoutInfo.editable)}update(){if(!this._wordCountEl||!this._charCountEl||this.el?.hidden)return;let{words:e,chars:t}=this._counts(),n=this.options.maxWords||0,r=this.options.maxChars||0,i=this.context.locale.statusbar;this._wordCountEl.textContent=n?i.wordsLimit(e,n):i.words(e),this._charCountEl.textContent=r?i.charsLimit(t,r):i.chars(t),Sa(this._wordCountEl,e,n),Sa(this._charCountEl,t,r)}getWordCount(){return this._counts().words}getCharCount(){return this._counts().chars}},wa=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){this._blobRegistry=new Map,this._forcePlain=!1;let e=this.context.layoutInfo.editable;return this._disposers.push(v(e,`paste`,e=>this._onPaste(e)),v(e,`dragover`,e=>this._onDragover(e)),v(e,`drop`,e=>this._onDrop(e))),this._mutationObserver=new MutationObserver(e=>{for(let t of e)for(let e of t.removedNodes)this._revokeRemovedBlobs(e)}),this._mutationObserver.observe(e,{childList:!0,subtree:!0}),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._mutationObserver&&=(this._mutationObserver.disconnect(),null),this._blobRegistry&&(this._blobRegistry.forEach((e,t)=>URL.revokeObjectURL(t)),this._blobRegistry.clear()),this._uploadPreviews&&(this._uploadPreviews.forEach(({previewUrl:e})=>URL.revokeObjectURL(e)),this._uploadPreviews.clear())}_revokeRemovedBlobs(e){if(!this._blobRegistry?.size)return;let t=[];e.nodeName===`IMG`?t.push(e):e.querySelectorAll&&t.push(...e.querySelectorAll(`img`)),t.forEach(e=>{let t=e.getAttribute(`src`)||``;t.startsWith(`blob:`)&&this._blobRegistry.has(t)&&(URL.revokeObjectURL(t),this._blobRegistry.delete(t))})}_cleanWordHtml(e){return e.replace(/<!--\[if[\s\S]*?\[endif\]-->/gi,``).replace(/<xml[\s\S]*?<\/xml>/gi,``).replace(/<\?xml[\s\S]*?\?>/gi,``).replace(/<\/?(o|w|m|v|st1):[a-z][^>]*>/gi,``).replace(/\s+class="Mso[^"]*"/gi,``).replace(/\s+style="([^"]*)"/gi,(e,t)=>{let n=t.split(`;`).map(e=>e.trim()).filter(e=>e&&!/^mso-/i.test(e)&&!/^(tab-stops|margin-[a-z]+-alt)/i.test(e)).join(`; `);return n?` style="${n}"`:``}).replace(/<p[^>]*>\s*(&nbsp;)?\s*<\/p>/gi,``)}_cleanSocialHtml(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`),n=Array.from(t.querySelectorAll(`span, div`));for(let e=n.length-1;e>=0;e--){let t=n[e];if(!t.parentNode||t.querySelector(`a, strong, em, b, i, ul, ol, li, table, img, blockquote, pre, code, h1, h2, h3, h4, h5, h6`))continue;let r=t.parentNode;for(;t.firstChild;)r.insertBefore(t.firstChild,t);t.remove()}return t.querySelectorAll(`*`).forEach(e=>{e.removeAttribute(`class`),e.removeAttribute(`id`),Array.from(e.attributes).filter(e=>e.name.startsWith(`data-`)||e.name.startsWith(`aria-`)).forEach(t=>e.removeAttribute(t.name))}),t.body.innerHTML}_stripAttributes(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`),n=new Set([`href`,`src`,`alt`,`target`,`rel`,`colspan`,`rowspan`,`type`]);return t.querySelectorAll(`*`).forEach(e=>{Array.from(e.attributes).filter(e=>!n.has(e.name)).forEach(t=>e.removeAttribute(t.name))}),t.body.innerHTML}_normalizeExternalTaskLists(e){let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`);for(let e of t.querySelectorAll(`input[type="checkbox"]`)){let t=e.closest(`li`),n=t?.closest(`ul`);if(!(!t||!n||n.classList.contains(`an-checklist`))){n.classList.add(`an-checklist`),e.removeAttribute(`disabled`),e.setAttribute(`contenteditable`,`false`);for(let t of Array.from(e.attributes))[`type`,`checked`,`contenteditable`].includes(t.name)||e.removeAttribute(t.name)}}return t.body.innerHTML}_isTriviallyPlainHtml(e){return!new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`).body.querySelector(`a,img,table,ul,ol,li,blockquote,pre,code,h1,h2,h3,h4,h5,h6,strong,b,em,i,u,s,del,strike,hr,br`)}setForcePlain(e){this._forcePlain=!!e}_maxPasteBytes(){let e=this.options.maxPasteSize;return typeof e==`number`&&e>=0?e:5242880}_onPaste(e){let t=e.clipboardData||globalThis.clipboardData;if(!t)return;let n=this._forcePlain;this._forcePlain=!1;let r=this._maxPasteBytes();if(r>0){let n=t.getData(`text/plain`)||``,i=t.getData(`text/html`)||``,a=Math.max(n.length,i.length);if(a>r){e.preventDefault();let t=`Pasted content (${a} bytes) exceeds the ${r}-byte paste size limit.`;this.context.triggerEvent(`pasteError`,{size:a,maxBytes:r,message:t}),console.warn(`[AutumnNote] ${t}`);return}}if(t.items){let n=Array.from(t.items).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(n.length>0){e.preventDefault();let t=n.map(e=>e.getAsFile()).filter(Boolean);this._insertImageFiles(t);return}}let i=this.context.triggerEvent(`paste`,{text:t.getData(`text/plain`)||``,html:t.types.includes(`text/html`)?t.getData(`text/html`):null});if(i===!1){e.preventDefault();return}if(typeof i==`string`){e.preventDefault(),I(`insertHTML`,z(i)),this.context.invoke(`editor.afterCommand`);return}if(n||this.options.pasteAsPlainText){e.preventDefault(),I(`insertHTML`,t.getData(`text/plain`).split(/\r?\n/).map(e=>`<p>${this._escapeHTML(e)||`<br>`}</p>`).join(``)),this.context.invoke(`editor.afterCommand`);return}if(this.options.markdownPaste!==!1){let n=t.types.includes(`text/html`),r=n?t.getData(`text/html`):``,i=!n||this._isTriviallyPlainHtml(r),a=t.getData(`text/plain`);if(a&&i&&gi(a)){e.preventDefault(),I(`insertHTML`,z(wi(a))),this.context.invoke(`editor.afterCommand`);return}}if(this.options.pasteCleanHTML!==!1&&t.types.includes(`text/html`)){e.preventDefault();let n=t.getData(`text/html`),r=/<[a-z]+:[a-z]/i.test(n)||/class="Mso/i.test(n)||/\bmso-/i.test(n),i=/class="[^"]*\b(?:x[a-z0-9]{6,}|r-[a-z0-9]{3,})\b/.test(n),a=n;r?a=this._cleanWordHtml(a):i&&(a=this._cleanSocialHtml(a)),a=this._normalizeExternalTaskLists(a),a=z(a),this.options.pasteStripAttributes&&(a=this._stripAttributes(a)),I(`insertHTML`,a),this.context.invoke(`editor.afterCommand`)}}_onDragover(e){e.dataTransfer&&Array.from(e.dataTransfer.types||[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}_onDrop(e){let t=e.dataTransfer;if(!t?.files?.length)return;let n=Array.from(t.files).filter(e=>e.type.startsWith(`image/`));if(n.length>0){e.preventDefault(),e.stopPropagation(),this._placeCaretAtPoint(e.clientX,e.clientY),this._insertImageFiles(n);return}if(this.options.markdownPaste!==!1){let n=Array.from(t.files).find(e=>/\.md$/i.test(e.name)||e.type===`text/markdown`);n&&(e.preventDefault(),e.stopPropagation(),this._placeCaretAtPoint(e.clientX,e.clientY),this._insertMarkdownFile(n))}}_insertMarkdownFile(e){let t=this._maxPasteBytes();if(t>0&&e.size>t){let n=`Dropped file "${e.name}" (${e.size} bytes) exceeds the ${t}-byte paste size limit.`;this.context.triggerEvent(`pasteError`,{size:e.size,maxBytes:t,message:n}),console.warn(`[AutumnNote] ${n}`);return}let n=new FileReader;n.onload=e=>{I(`insertHTML`,z(wi(e.target.result||``))),this.context.invoke(`editor.afterCommand`)},n.onerror=()=>{let t=`Failed to read dropped markdown file "${e.name}".`;console.warn(`[AutumnNote] ${t}`),this.context.triggerEvent(`pasteError`,{message:t})},n.readAsText(e)}_insertImageFiles(e){if(!e||e.length===0)return;if(typeof this.options.onImageUpload==`function`){this._runUploadHandler(e);return}let t=new Set([`image/tiff`,`image/x-tiff`,`image/bmp`,`image/x-bmp`,`image/x-ms-bmp`]),n=(this.options.maxImageSize||5)*1024*1024;e.forEach(e=>{if(!e?.type?.startsWith(`image/`))return;if(t.has(e.type)){let t=`Image format "${e.type}" is not supported for display in web browsers. Please convert to PNG, JPEG, or WebP first.`;this.context.triggerEvent(`imageError`,{file:e,message:t}),console.warn(`[AutumnNote]`,t);return}if(e.size>n){let t=`Image "${e.name}" exceeds the ${this.options.maxImageSize||5} MB size limit.`;this.context.triggerEvent(`imageError`,{file:e,message:t}),console.warn(`[AutumnNote] ${t}`);return}let r=e.name.replace(/\.[^.]+$/,``);this.compressAndRegister(e).then(e=>{this.context.invoke(`editor.insertImage`,e,r)}).catch(t=>{let n=`Image "${e.name}" could not be processed.`;this.context.triggerEvent(`imageError`,{file:e,message:n,error:t}),console.warn(`[AutumnNote]`,n,t)})})}_escapeAttr(e){return String(e).replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}async _runUploadHandler(e){let t={context:this.context,setProgress:(e,t)=>this._setUploadProgress(e,t)},n;try{n=this.options.onImageUpload(e,t)}catch(t){this._reportUploadError(e,t);return}if(n===void 0)return;let r=e.map(e=>this._insertUploadPlaceholder(e)),i;try{i=await n}catch(t){r.forEach((n,r)=>this._failUpload(n,e[r],t));return}let a=Array.isArray(i)?i:[i];r.forEach((t,n)=>{let r=a[n];typeof r==`string`&&r?this._resolveUpload(t,r):this._failUpload(t,e[n],Error(`No URL returned for this file.`))})}_insertUploadPlaceholder(e){let t=`an-up-${Date.now().toString(36)}-${this._uploadSeq=(this._uploadSeq||0)+1}`,n=URL.createObjectURL(e);this._uploadPreviews=this._uploadPreviews||new Map,this._uploadPreviews.set(t,{previewUrl:n,file:e});let r=this._escapeAttr(e.name.replace(/\.[^.]+$/,``));return I(`insertHTML`,`<img src="${this._escapeAttr(n)}" alt="${r}" class="an-image an-image-uploading" data-an-upload="${t}">`),this.context.invoke(`editor.afterCommand`),t}_findPlaceholder(e){return this.context.layoutInfo.editable?.querySelector(`img[data-an-upload="${e}"]`)??null}_resolveUpload(e,t){let n=this._findPlaceholder(e),r=this._uploadPreviews?.get(e);if(n){let i=br(t,{allowData:!0});if(i)n.setAttribute(`src`,i),n.classList.remove(`an-image-uploading`),n.removeAttribute(`data-an-upload`),n.style.removeProperty(`--an-upload-progress`);else{this._failUpload(e,r?.file,Error(`Rejected image URL: ${t}`));return}}r&&(URL.revokeObjectURL(r.previewUrl),this._uploadPreviews.delete(e)),this.context.invoke(`editor.afterCommand`)}_failUpload(e,t,n){let r=this._findPlaceholder(e);r&&(r.classList.remove(`an-image-uploading`),r.classList.add(`an-image-failed`),r.style.removeProperty(`--an-upload-progress`));let i=`Image "${t?.name??`unknown`}" could not be uploaded.`;console.warn(`[AutumnNote]`,i,n),this.context.triggerEvent(`imageError`,{file:t,message:i,error:n,retry:()=>{r?.remove(),this._uploadPreviews?.delete(e),t&&this._runUploadHandler([t])}})}_reportUploadError(e,t){let n=`The image upload handler threw before any file was sent.`;console.warn(`[AutumnNote]`,n,t),this.context.triggerEvent(`imageError`,{file:e[0],message:n,error:t})}_setUploadProgress(e,t){if(!this._uploadPreviews)return;let n=Math.max(0,Math.min(1,Number(t)||0));for(let[t,r]of this._uploadPreviews){if(r.file!==e)continue;let i=this._findPlaceholder(t);i&&i.style.setProperty(`--an-upload-progress`,String(n));return}}async compressAndRegister(e){let t=this.options.imageProcessor,n=typeof t==`function`?await t(e,{context:this.context}):await this._compressImage(e),r=this._dataUrlToBlob(n),i=URL.createObjectURL(r);return this._blobRegistry.set(i,n),i}resolveImages(e){return this._blobRegistry?.size?e.replace(/blob:[^"'> \t\n\r]*/g,e=>this._blobRegistry.get(e)||e):e}_dataUrlToBlob(e){let[t,n]=e.split(`,`),r=/:(.*?);/.exec(t)?.[1]??`image/png`,i=atob(n),a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);return new Blob([a],{type:r})}_compressImage(e){let t=1920,n=.85;return new Promise((r,i)=>{let a=URL.createObjectURL(e),o=new Image;o.onload=()=>{URL.revokeObjectURL(a);let{width:s,height:c}=o;(s>t||c>t)&&(s>=c?(c=Math.round(c*t/s),s=t):(s=Math.round(s*t/c),c=t));let l=document.createElement(`canvas`);l.width=s,l.height=c;let u=l.getContext(`2d`);if(!u){let t=new FileReader;t.onload=e=>r(e.target.result),t.onerror=()=>i(Error(`FileReader failed`)),t.readAsDataURL(e);return}u.drawImage(o,0,0,s,c);let d=l.toDataURL(`image/webp`,n);r(d.startsWith(`data:image/webp`)?d:l.toDataURL(`image/jpeg`,n))},o.onerror=()=>{URL.revokeObjectURL(a);let t=new FileReader;t.onload=e=>r(e.target.result),t.onerror=()=>i(Error(`FileReader failed`)),t.readAsDataURL(e)},o.src=a})}_placeCaretAtPoint(e,t){let n;if(document.caretRangeFromPoint)n=document.caretRangeFromPoint(e,t);else if(document.caretPositionFromPoint){let r=document.caretPositionFromPoint(e,t);r&&(n=document.createRange(),n.setStart(r.offsetNode,r.offset),n.collapse(!0))}if(!n)return;let r=globalThis.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}_escapeHTML(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&#039;`)}};async function Ta({text:e,html:t}){let n=globalThis.navigator?.clipboard;if(!n)throw Error(`Clipboard API unavailable`);if(t&&typeof n.write==`function`&&typeof globalThis.ClipboardItem==`function`)try{await n.write([new globalThis.ClipboardItem({"text/plain":new Blob([e],{type:`text/plain`}),"text/html":new Blob([t],{type:`text/html`})})]);return}catch{}if(typeof n.writeText!=`function`)throw Error(`Clipboard API unavailable`);await n.writeText(e)}function Ea(){let e=globalThis.getSelection?.();if(!e||e.rangeCount===0||e.isCollapsed)return null;let t=e.getRangeAt(0),n=document.createElement(`div`);return n.appendChild(t.cloneContents()),{text:e.toString(),html:n.innerHTML,range:t}}async function Da(){let e=Ea();if(!e)return!1;try{return await Ta(e),!0}catch{return!1}}async function Oa(e){let t=Ea();if(!t)return!1;try{await Ta(t)}catch{return!1}return t.range.deleteContents(),e?.(),!0}var K={undo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>`,redo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"/></svg>`,cut:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="20" r="3"/><circle cx="6" cy="4" r="3"/><line x1="19" y1="5" x2="6" y2="19"/><line x1="19" y1="19" x2="13.5" y2="13.5"/></svg>`,copy:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`,paste:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>`,bold:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/><path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/></svg>`,italic:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>`,underline:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"/><line x1="4" y1="21" x2="20" y2="21"/></svg>`,link:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,image:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,video:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteImg:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,videoAlign:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,deleteVideo:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,copyFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,pasteFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><rect x="8" y="2" width="8" height="4" rx="1"/><path d="m9 14 2 2 4-4"/></svg>`,removeFormat:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>`,table:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>`,textColor:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/></svg>`,highlightColor:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/><line x1="3" y1="21" x2="21" y2="21"/></svg>`,noColor:`<svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="4" y1="4" x2="20" y2="20"/><line x1="20" y1="4" x2="4" y2="20"/></svg>`,back:`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>`};function ka(e){let t=e===`foreColor`?`Text Color`:`Highlight Color`,n=e===`foreColor`?`textColor`:`highlightColor`;return()=>[{back:!0,label:t,localeKey:n,navigate:()=>Aa},{colorPalette:!0,colorType:e}]}var Aa=[{name:`cut`,label:`Cut`,icon:K.cut,action:e=>{Oa(()=>e.invoke(`editor.afterCommand`))}},{name:`copy`,label:`Copy`,icon:K.copy,action:()=>{Da()}},{name:`paste`,label:`Paste`,icon:K.paste,action:e=>{if(!navigator.clipboard)return;let t=e.layoutInfo?.editable;if(!t)return;let n=(n,r)=>{t.focus(),n?ie(z(n),t):r&&ae(r,t),e.invoke(`editor.afterCommand`)};typeof navigator.clipboard.read==`function`?navigator.clipboard.read().then(e=>{for(let t of e)if(t.types.includes(`text/html`)){t.getType(`text/html`).then(e=>e.text()).then(e=>n(e,null)).catch(()=>{});return}navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}).catch(()=>{navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}):typeof navigator.clipboard.readText==`function`&&navigator.clipboard.readText().then(e=>n(null,e)).catch(()=>{})}},{separator:!0},{name:`bold`,label:`Bold`,icon:K.bold,action:e=>e.invoke(`editor.bold`)},{name:`italic`,label:`Italic`,icon:K.italic,action:e=>e.invoke(`editor.italic`)},{name:`underline`,label:`Underline`,icon:K.underline,action:e=>e.invoke(`editor.underline`)},{separator:!0},{name:`textColor`,label:`Text Color`,icon:K.textColor,colorStrip:`foreColor`,navigate:ka(`foreColor`)},{name:`highlightColor`,label:`Highlight Color`,icon:K.highlightColor,colorStrip:`hiliteColor`,navigate:ka(`hiliteColor`)},{separator:!0},{name:`copyFormat`,label:`Copy Format`,icon:K.copyFormat,action:e=>e.invoke(`contextMenu.copyFormat`)},{name:`pasteFormat`,label:`Paste Format`,icon:K.pasteFormat,action:e=>e.invoke(`contextMenu.pasteFormat`),disabled:e=>!e.invoke(`contextMenu.hasCopiedFormat`)},{name:`removeFormat`,label:`Remove Format`,icon:K.removeFormat,action:e=>e.invoke(`contextMenu.removeFormat`)},{separator:!0},{name:`link`,label:`Insert Link`,icon:K.link,action:e=>e.invoke(`linkDialog.show`)},{name:`image`,label:`Insert Image`,icon:K.image,action:e=>e.invoke(`imageDialog.show`)},{name:`video`,label:`Insert Video`,icon:K.video,action:e=>e.invoke(`videoDialog.show`)},{name:`table`,label:`Insert Table`,icon:K.table,tableGrid:!0}],ja=class{constructor(e){this.context=e,this.options=e.options,this._items=this.options.contextMenu?.items||Aa,this.el=null,this._disposers=[],this._menuDisposers=[],this._lastX=0,this._lastY=0,this._copiedFormat=null,this._savedRange=null}initialize(){this.el=h(`div`,{class:`an-contextmenu`,role:`menu`,"aria-hidden":`true`}),this.el.style.display=`none`,b(this.context).appendChild(this.el),this._renderItems(this._items);let e=this.context.layoutInfo?.editable;return e&&this._disposers.push(v(e,`contextmenu`,e=>this._onContextMenu(e))),this._disposers.push(v(document,`click`,e=>this._maybeHide(e)),v(document,`keydown`,e=>{e.key===`Escape`&&this.hide()}),v(globalThis,`scroll`,()=>this.hide(),{passive:!0})),this}destroy(){this._menuDisposers.forEach(e=>{try{e()}catch{}}),this._menuDisposers=[],this._disposers.forEach(e=>{try{e()}catch{}}),this._disposers=[],this.el&&this.el.remove(),this.el=null}_renderItems(e){this._menuDisposers.forEach(e=>e()),this._menuDisposers=[],this.el&&(this.el.innerHTML=``,e.forEach(e=>{if(e.separator||e.sep){this.el.appendChild(h(`div`,{class:`an-context-sep`}));return}if(e.back){let t=h(`button`,{type:`button`,class:`an-context-back`}),n=h(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=K.back,t.appendChild(n);let r=e.localeKey&&this.context.locale.contextMenu[e.localeKey]||e.label||this.context.locale.contextMenu.back||`Back`;t.appendChild(h(`span`,{class:`an-context-label`},[r]));let i=v(t,`click`,t=>{t.stopPropagation();let n=Number.parseFloat(this.el.style.left),r=Number.parseFloat(this.el.style.top);this._renderItems(e.navigate()),this._reposition(n,r)});this._menuDisposers.push(i),this.el.appendChild(t);return}if(e.navigate){let t=h(`button`,{type:`button`,class:`an-context-item an-context-submenu`,"data-name":e.name||``});if(e.icon){if(e.colorStrip){let n=h(`span`,{class:`an-context-icon an-context-icon--color`,"aria-hidden":`true`}),r=h(`span`,{class:`an-context-icon-svg`});r.innerHTML=e.icon;let i=h(`span`,{class:`an-context-color-strip`});i.style.background=this._getSelectionColor(e.colorStrip),n.appendChild(r),n.appendChild(i),t.appendChild(n)}else{let n=h(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=e.icon,t.appendChild(n)}}t.appendChild(h(`span`,{class:`an-context-label`},[this.context.locale.contextMenu[e.name]||e.label||e.name]));let n=h(`span`,{class:`an-context-chevron`,"aria-hidden":`true`});n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`,t.appendChild(n);let r=v(t,`click`,t=>{t.stopPropagation();let n=Number.parseFloat(this.el.style.left),r=Number.parseFloat(this.el.style.top);this._renderItems(e.navigate()),this._reposition(n,r)});this._menuDisposers.push(r),this.el.appendChild(t);return}if(e.colorPalette){let t=h(`div`,{class:`an-context-color-palette`});if(ha(this.options).forEach(n=>{let r=h(`div`,{class:`an-context-color-swatch`,title:n,role:`button`,"aria-label":n});r.style.background=n;let i=v(r,`click`,t=>{t.stopPropagation(),this._applyColor(e.colorType,n)});this._menuDisposers.push(i),t.appendChild(r)}),e.colorType===`hiliteColor`){let e=h(`div`,{class:`an-context-color-swatch an-context-color-none`,title:this.context.locale.contextMenu.noHighlight||`No highlight`,role:`button`,"aria-label":this.context.locale.contextMenu.noHighlight||`No highlight`});e.innerHTML=K.noColor;let n=v(e,`click`,e=>{e.stopPropagation(),this._applyColor(`hiliteColor`,`transparent`)});this._menuDisposers.push(n),t.appendChild(e)}this.el.appendChild(t);let n=h(`div`,{class:`an-context-color-custom`}),r=h(`input`,{type:`color`,value:e.colorType===`foreColor`?`#000000`:`#ffff00`,title:this.context.locale.contextMenu.customColor||`Custom color`,"aria-label":this.context.locale.contextMenu.customColor||`Custom color`}),i=h(`span`,{},[this.context.locale.contextMenu.customColorLabel||`Custom…`]),a=v(r,`change`,()=>this._applyColor(e.colorType,r.value));this._menuDisposers.push(a),n.appendChild(r),n.appendChild(i),this.el.appendChild(n);return}if(e.tableGrid){let t=h(`div`,{class:`an-context-table-wrap`}),n=h(`button`,{type:`button`,class:`an-context-item an-context-submenu`,"data-name":e.name||`table`});if(e.icon){let t=h(`span`,{class:`an-context-icon`,"aria-hidden":`true`});t.innerHTML=e.icon,n.appendChild(t)}n.appendChild(h(`span`,{class:`an-context-label`},[this.context.locale.contextMenu.table||e.label||`Insert Table`]));let r=h(`span`,{class:`an-context-chevron`,"aria-hidden":`true`});r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`,n.appendChild(r);let i=h(`div`,{class:`an-context-table-grid-panel`});i.style.display=`none`;let a=h(`div`,{class:`an-table-grid`});a.style.gridTemplateColumns=`repeat(8, 16px)`;let o=h(`div`,{class:`an-table-label`});o.textContent=`Insert Table`;let s=[];for(let e=1;e<=8;e++)for(let t=1;t<=8;t++){let n=h(`div`,{class:`an-table-cell`,"data-row":String(e),"data-col":String(t)});n.style.width=`16px`,n.style.height=`16px`,s.push(n),a.appendChild(n)}let c=(e,t)=>{s.forEach(n=>{n.classList.toggle(`active`,+n.dataset.row<=e&&+n.dataset.col<=t)}),o.textContent=e&&t?`${e} × ${t}`:this.context.locale.contextMenu.table||`Insert Table`};i.appendChild(a),i.appendChild(o);let l=!1,u=v(n,`click`,e=>{e.stopPropagation(),l=!l,i.style.display=l?``:`none`,r.style.transform=l?`rotate(90deg)`:``,this._reposition()});this._menuDisposers.push(u);let d=v(a,`mousemove`,e=>{let t=e.target?.closest(`[data-row]`);t&&c(+t.dataset.row,+t.dataset.col)}),f=v(a,`mouseleave`,()=>c(0,0)),p=v(a,`click`,e=>{let t=e.target?.closest(`[data-row]`);if(!t)return;let n=+t.dataset.row,r=+t.dataset.col,i=this.context.layoutInfo?.editable;if(i&&this._savedRange){i.focus();let e=globalThis.getSelection();e.removeAllRanges(),e.addRange(this._savedRange.cloneRange())}this.hide(),this.context.invoke(`editor.insertTable`,r,n)});this._menuDisposers.push(d,f,p),t.appendChild(n),t.appendChild(i),this.el.appendChild(t);return}let t=h(`button`,{type:`button`,class:`an-context-item`,"data-name":e.name||``});if((typeof e.disabled==`function`?e.disabled(this.context):e.disabled)&&(t.disabled=!0),e.icon){let n=h(`span`,{class:`an-context-icon`,"aria-hidden":`true`});n.innerHTML=e.icon,t.appendChild(n)}t.appendChild(h(`span`,{class:`an-context-label`},[this.context.locale.contextMenu[e.name]||e.label||e.name]));let n=v(t,`click`,t=>{if(t.stopPropagation(),this.hide(),this.context.triggerEvent?.(`beforeCommand`,{name:e.name,source:`contextMenu`})!==!1)try{e.action(this.context)}catch(e){console.error(e)}});this._menuDisposers.push(n),this.el.appendChild(t)}))}_onContextMenu(e){let t=this.context.layoutInfo?.editable;if(!t||!t.contains(e.target)||this.context.layoutInfo.container.classList.contains(`an-disabled`))return;e.preventDefault();let n=globalThis.getSelection();this._savedRange=n?.rangeCount>0?n.getRangeAt(0).cloneRange():null,this._renderItems(this._items);let r=e.clientX,i=e.clientY;if(this._savedRange&&!this._savedRange.collapsed)try{let e=this._savedRange.getBoundingClientRect();e.width>0&&e.height>0&&(i=e.bottom+4)}catch{}this._lastX=r,this._lastY=i,this.showAt(r,i)}_maybeHide(e){this.el&&(this.el.contains(e.target)||this.hide())}showAt(e,t){this.el&&(this.el.style.display=`block`,this._reposition(e,t),this.el.setAttribute(`aria-hidden`,`false`),this.context.triggerEvent(`contextMenu:show`))}_reposition(e,t){if(!this.el)return;let n=e===void 0?this._lastX:e,r=t===void 0?this._lastY:t,i=this.el.offsetWidth,a=this.el.offsetHeight,o=n,s=r;o+i>globalThis.innerWidth-8&&(o=globalThis.innerWidth-i-8),o<8&&(o=8),s+a>globalThis.innerHeight-8&&(s=globalThis.innerHeight-a-8),s<8&&(s=8),this.el.style.left=`${o}px`,this.el.style.top=`${s}px`}hide(){this.el&&(this.el.style.display=`none`,this.el.setAttribute(`aria-hidden`,`true`),this.context.triggerEvent(`contextMenu:hide`))}_getSelectionColor(e){let t=this._savedRange;if(!t)return e===`foreColor`?`#000000`:`transparent`;let n=t.startContainer;if(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement),!n)return e===`foreColor`?`#000000`:`transparent`;let r=globalThis.getComputedStyle(n);if(e===`foreColor`)return r.color||`#000000`;let i=r.backgroundColor;return!i||i===`rgba(0, 0, 0, 0)`||i===`transparent`?`transparent`:i}_applyColor(e,t){let n=this.context.layoutInfo?.editable;if(!n||!this._savedRange)return;n.focus();let r=globalThis.getSelection();r.removeAllRanges(),r.addRange(this._savedRange.cloneRange()),P(e===`foreColor`?`color`:`background-color`,t,n),this.context.invoke(`editor.afterCommand`),this.hide()}hasCopiedFormat(){return!!this._copiedFormat}copyFormat(){let e=this._savedRange;if(!e)return;let t=this.context.layoutInfo?.editable,n=e.startContainer;if(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement),!n||!t?.contains(n))return;let r=globalThis.getComputedStyle(n),i=this._findExplicitStyle(n,t,`fontFamily`),a=this._findExplicitStyle(n,t,`fontSize`);this._copiedFormat={bold:Number.parseInt(r.fontWeight,10)>=700,italic:r.fontStyle===`italic`||r.fontStyle===`oblique`,underline:(r.textDecorationLine||``).includes(`underline`),strikethrough:(r.textDecorationLine||``).includes(`line-through`),fontFamily:i,fontSize:a,color:this._isDefaultColor(r.color)?null:r.color,backgroundColor:r.backgroundColor}}_findExplicitStyle(e,t,n){let r=e;for(;r&&r!==t&&r!==document.body;){if(r.style?.[n])return r.style[n];if(r.nodeName===`FONT`){if(n===`fontFamily`&&r.getAttribute(`face`))return r.getAttribute(`face`);if(n===`fontSize`&&r.getAttribute(`size`))return null}r=r.parentElement}return null}_isDefaultColor(e){return!e||e===`rgb(0, 0, 0)`||e===`rgba(0, 0, 0, 0)`||e===`transparent`}pasteFormat(){if(!this._copiedFormat||!this._savedRange)return;let e=this._copiedFormat,t=this.context.layoutInfo?.editable;if(!t)return;t.focus();let n=globalThis.getSelection();n.removeAllRanges(),n.addRange(this._savedRange.cloneRange()),qe(t);for(let n of[`bold`,`italic`,`underline`,`strikethrough`])e[n]&&N(n,!0,t);e.color&&P(`color`,e.color,t),(e=>!e||e===`rgba(0, 0, 0, 0)`||e===`transparent`)(e.backgroundColor)||P(`background-color`,e.backgroundColor,t),e.fontFamily&&P(`font-family`,e.fontFamily,t),e.fontSize&&P(`font-size`,e.fontSize,t),this.context.invoke(`editor.afterCommand`)}removeFormat(){if(!this._savedRange)return;let e=this.context.layoutInfo?.editable;if(!e)return;e.focus();let t=globalThis.getSelection();t.removeAllRanges(),t.addRange(this._savedRange.cloneRange()),qe(e);let n=t.getRangeAt(0),r=n.commonAncestorContainer,i=r.nodeType===Node.TEXT_NODE?r.parentElement:r,a=document.createNodeIterator(i,NodeFilter.SHOW_ELEMENT),o;for(;o=a.nextNode();)if(!(!e.contains(o)||o===e))try{n.intersectsNode(o)&&o.removeAttribute(`style`)}catch{}this.context.invoke(`editor.afterCommand`)}},Ma=/[^\s\u200B]/;function Na(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=t.nextNode();e;e=t.nextNode())if(Ma.test(e.data))return!0;return!1}var Pa=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){let e=this.context.layoutInfo.editable,t=this.options.placeholder||``;t&&(e.dataset.placeholder=t);let n=()=>this._update(),r=v(e,`input`,n),i=v(e,`focus`,n),a=v(e,`blur`,n);return this._disposers.push(r,i,a),this._update(),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[]}_update(){let e=this.context.layoutInfo.editable,t=document.activeElement===e,n=!Na(e)&&!e.querySelector(`img, table, hr, .an-video-wrapper`);e.classList.toggle(`an-placeholder`,n&&!t)}},Fa=class{constructor(e){this.context=e,this.options=e.options,this._active=!1,this._textarea=null,this._disposers=[]}initialize(){return this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._textarea?.remove(),this._textarea=null}toggle(){this._active?this.deactivate():this.activate()}isActive(){return this._active}activate(){if(this._active)return;let{editable:e}=this.context.layoutInfo,t=e.innerHTML;this._textarea=h(`textarea`,{class:`an-codeview`,spellcheck:`false`,autocomplete:`off`,autocorrect:`off`,autocapitalize:`off`}),this._textarea.value=this._prettyPrint(t),e.style.display=`none`,e.parentNode.insertBefore(this._textarea,e.nextSibling),this._active=!0,this.context.invoke(`toolbar.refresh`)}deactivate(){if(!this._active||!this._textarea)return;let{editable:e}=this.context.layoutInfo;e.innerHTML=z(this._textarea.value,{allowIframes:!0,iframeHosts:this.context.options.iframeHosts}),this._textarea.remove(),this._textarea=null,e.style.display=``,this._active=!1,this.context.invoke(`toolbar.refresh`),this.context.invoke(`editor.afterCommand`)}_prettyPrint(e){let t=/^<(a|abbr|b|bdo|br|button|cite|code|dfn|em|i|img|input|kbd|label|output|q|samp|select|small|span|strong|sub|sup|textarea|time|tt|u|var)([\s>/])/i,n=0;return e.replace(/>\s*</g,(e,n,r)=>{let i=r.slice(n+1);return t.test(i.trimStart())?`><`:`>
39
41
  <`}).split(`
40
42
  `).map(e=>{let r=e.trim();if(!r)return``;r.startsWith(`</`)&&(n=Math.max(0,n-1));let i=` `.repeat(n)+r;return/^<[^/!][^>]*[^/]>/.test(r)&&!t.test(r)&&!/^<(br|hr|img|input|link|meta)/.test(r)&&n++,i}).filter(Boolean).join(`
41
- `)}},ci=class{constructor(e){this.context=e,this._active=!1,this._disposers=[],this._prevHeight=``}initialize(){let e=v(document,`keydown`,e=>{this._active&&F(e,P.ESCAPE)&&this.deactivate()});return this._disposers.push(e),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._active&&this.deactivate()}toggle(){this._active?this.deactivate():this.activate()}isActive(){return this._active}activate(){if(this._active)return;let e=this.context.layoutInfo.container;this._prevHeight=e.style.height,e.classList.add(`an-fullscreen`),e.style.height=``,document.body.style.overflow=`hidden`,this._active=!0,this.context.invoke(`toolbar.refresh`)}deactivate(){if(!this._active)return;let e=this.context.layoutInfo.container;e.classList.remove(`an-fullscreen`),e.style.height=this._prevHeight,document.body.style.overflow=``,this._active=!1,this.context.invoke(`toolbar.refresh`)}},G=class{constructor(e){this.context=e,this.options=e.options,this._dialog=null,this._disposers=[],this._savedRange=null,this._firstInput=null,this._removeTrap=null}_buildDialog(){throw Error(`_buildDialog() must be implemented by subclass`)}initialize(){return this._dialog=this._buildDialog(),x(this.context).appendChild(this._dialog),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._dialog?.parentNode&&this._dialog.remove(),this._dialog=null}_saveRange(){ee(e=>{this._savedRange=e})}_open(){this._dialog&&(this._dialog.style.display=`flex`,this._removeTrap=y(this._dialog,()=>this._close()),setTimeout(()=>this._firstInput?.focus(),50))}_close(){this._dialog&&(this._dialog.style.display=`none`),this._removeTrap&&=(this._removeTrap(),null),this._savedRange=null}_buildDialogShell(e,t,n){let r=h(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e}),i=h(`div`,{class:`an-dialog-box`}),a=h(`div`,{class:`an-dialog-header`}),o=h(`span`,{class:`an-dialog-icon`});o.innerHTML=t;let s=h(`h3`,{class:`an-dialog-title`});s.textContent=n,a.appendChild(o),a.appendChild(s),i.appendChild(a),r.appendChild(i),b(a,i);let c=v(r,`click`,e=>{e.target===r&&this._close()});return this._disposers.push(c),{overlay:r,box:i}}_buildButtonRow(e,t,n){let r=h(`div`,{class:`an-dialog-actions`}),i=h(`button`,{type:`button`,class:`an-btn an-btn-primary`});i.textContent=e;let a=h(`button`,{type:`button`,class:`an-btn`});a.textContent=t,r.appendChild(i),r.appendChild(a);let o=v(i,`click`,n),s=v(a,`click`,()=>this._close());return this._disposers.push(o,s),r}},li=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,ui=class extends G{show(){this._saveRange(),this._prefill(),this._open()}_buildDialog(){let e=this.context.locale.linkDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,li,e.title),r=h(`label`,{class:`an-label`});r.textContent=e.url;let i=h(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,id:`an-link-url`,name:`url`,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=h(`label`,{class:`an-label`});a.textContent=e.displayText;let o=h(`input`,{type:`text`,class:`an-input`,placeholder:e.textPlaceholder,id:`an-link-text`,name:`linkText`,autocomplete:`off`});this._textInput=o;let s=h(`label`,{class:`an-label an-label-inline`}),c=h(`input`,{type:`checkbox`,id:`an-link-newtab`,name:`openInNewTab`});this._tabCheckbox=c,s.appendChild(c),s.appendChild(document.createTextNode(` `+e.openInNewTab));let l=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(r,i,a,o,s,l);let u=v(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())}),d=v(o,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(u,d),t}_prefill(){let e=globalThis.getSelection(),t=null;if(e?.rangeCount>0){let n=e.getRangeAt(0).startContainer;for(;n;){if(n.nodeName===`A`){t=n;break}n=n.parentNode}}t?(this._urlInput.value=t.getAttribute(`href`)||``,this._textInput.value=t.textContent||``,this._tabCheckbox.checked=t.getAttribute(`target`)===`_blank`):(this._urlInput.value=``,this._textInput.value=e?e.toString():``,this._tabCheckbox.checked=!!this.context.options.linkDefaults?.openInNewTab)}_onInsert(){let e=this._urlInput.value.trim(),t=this._textInput.value.trim(),n=this._tabCheckbox.checked;if(!e){this._urlInput.focus();return}let r=this.context.options.linkDefaults?.defaultProtocol??`https://`,i=/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e),a=/^[/#?.]/.test(e);if(r&&!i&&!a&&(e=r+e),!N(e)){this._urlInput.focus();return}this._savedRange&&this._savedRange.select(),this.context.invoke(`editor.insertLink`,e,t,n),this._close()}},di=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,fi=class extends G{show({beforeInsert:e}={}){this._beforeInsert=typeof e==`function`?e:null,this._saveRange(),this._urlInput.value=``,this._altInput.value=``,this._fileInput&&(this._fileInput.value=``),this._open()}_buildDialog(){let e=this.context.locale.imageDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,di,e.title),r=h(`label`,{class:`an-label`});r.textContent=e.imageUrl;let i=h(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=h(`label`,{class:`an-label`});a.textContent=e.altText;let o=h(`input`,{type:`text`,class:`an-input`,placeholder:e.altPlaceholder,autocomplete:`off`});this._altInput=o,n.append(r,i,a,o);let s=h(`label`,{class:`an-label`});s.textContent=e.alignment;let c=h(`div`,{class:`an-align-row`});if([{value:``,label:e.alignNone},{value:`left`,label:e.alignLeft},{value:`center`,label:e.alignCenter},{value:`right`,label:e.alignRight}].forEach(({value:e,label:t})=>{let n=`an-align-${e||`none`}`,r=h(`input`,{type:`radio`,name:`an-img-align`,id:n,value:e});e===``&&(r.checked=!0);let i=h(`label`,{for:n,class:`an-align-label`});i.textContent=t,c.append(r,i)}),this._alignRow=c,n.append(s,c),this.options.allowImageUpload!==!1){let t=h(`label`,{class:`an-label`});t.textContent=e.uploadLabel;let r=h(`input`,{type:`file`,class:`an-input`,accept:`image/jpeg,image/png,image/gif,image/webp,image/svg+xml,image/avif`});this._fileInput=r;let i=h(`p`,{class:`an-dialog-hint`});this._fileHint=i;let a=v(r,`change`,()=>this._onFileChange());this._disposers.push(a),n.append(t,r,i)}let l=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(l);let u=v(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())}),d=v(o,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(u,d),t}_onFileChange(){if(this.context._alive===!1)return;let e=this._fileInput?.files?.[0];if(!e?.type?.startsWith(`image/`))return;if(!new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`,`image/avif`]).has(e.type)){let t=this.context.locale.errors.imageFormat(e.type);this._fileHint&&(this._fileHint.textContent=t),this.context.triggerEvent(`imageError`,{file:e,message:t}),this._fileInput.value=``;return}this._fileHint&&(this._fileHint.textContent=``);let t=(this.options.maxImageSize||5)*1024*1024;if(e.size>t){let t=this.context.locale.errors.imageSize(this.options.maxImageSize||5);this._fileHint&&(this._fileHint.textContent=t),console.warn(`[AutumnNote] ImageDialog:`,t),this.context.triggerEvent(`imageError`,{file:e,message:t}),this._fileInput.value=``;return}this.context.invoke(`clipboard.compressAndRegister`,e).then(e=>{this.context._alive!==!1&&(this._urlInput.value=e)}).catch(t=>{if(this.context._alive===!1)return;console.warn(`[AutumnNote] ImageDialog: image compression failed, using original file.`,t);let n=new FileReader;n.onload=e=>{this._urlInput.value=e.target.result},n.readAsDataURL(e)})}_onInsert(){let e=this._urlInput.value.trim(),t=this._altInput.value.trim(),n=this._alignRow?.querySelector(`input[name="an-img-align"]:checked`),r=n?n.value:``;if(!e){this._urlInput.focus();return}this._savedRange&&this._savedRange.select();let i=this._beforeInsert;this._beforeInsert=null,i?.(),this.context.invoke(`editor.insertImage`,e,t,r),this._close()}_close(){this._beforeInsert=null,super._close()}},pi=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,mi=class extends G{show(){this._saveRange(),this._urlInput.value=``,this._widthInput.value=`560`,this._hintEl.textContent=``,this._open()}_buildDialog(){let e=this.context.locale.videoDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,pi,e.title),r=h(`label`,{class:`an-label`});r.textContent=e.videoUrl;let i=h(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=h(`p`,{class:`an-dialog-hint`});this._hintEl=a;let o=h(`label`,{class:`an-label`});o.textContent=e.widthLabel;let s=h(`input`,{type:`number`,class:`an-input`,placeholder:`560`,min:`80`,max:`1920`,value:`560`});this._widthInput=s;let c=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(r,i,a,o,s,c);let l=v(i,`input`,()=>{let e=this._parseVideoUrl(i.value.trim()),t=``;e?t=this.context.locale.videoDialog.detected(e.type):i.value&&(t=this.context.locale.videoDialog.unknownFormat),a.textContent=t}),u=v(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(l,u),t}_onInsert(){let e=this._urlInput.value.trim(),t=Math.max(80,Number.parseInt(this._widthInput.value,10)||560);if(!e){this._urlInput.focus();return}let n=this._buildEmbedHtml(e,t);if(!n){this._hintEl.textContent=this.context.locale.videoDialog.invalidUrl,this._urlInput.focus();return}this._savedRange&&this._savedRange.select(),this.context.invoke(`editor.insertVideo`,n),this._close()}_parseVideoUrl(e){if(!e||!N(e,{media:!0}))return null;let t=this.context.options.videoProviders;if(Array.isArray(t))for(let n of t){let t=n?.match instanceof RegExp?n.match.exec(e):null;if(!t||typeof n.embed!=`function`)continue;let r=n.embed(t,e);if(typeof r==`string`&&tn(r,this.context.options.iframeHosts))return{type:String(n.name||`Video`),embedUrl:r,iframe:!0};console.warn(`[AutumnNote] videoProviders: "${n.name}" returned an embed URL whose host is not in iframeHosts; ignoring it.`)}let n=/(?:youtube\.com\/watch\?(?:.*&)?v=|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/.exec(e);if(n)return{type:`YouTube`,embedUrl:`https://www.youtube.com/embed/${n[1]}`,iframe:!0};let r=/youtu\.be\/([a-zA-Z0-9_-]{11})/.exec(e);if(r)return{type:`YouTube`,embedUrl:`https://www.youtube.com/embed/${r[1]}`,iframe:!0};let i=/youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/.exec(e);if(i)return{type:`YouTube Shorts`,embedUrl:`https://www.youtube.com/embed/${i[1]}`,iframe:!0};let a=/vimeo\.com\/(\d+)/.exec(e);return a?{type:`Vimeo`,embedUrl:`https://player.vimeo.com/video/${a[1]}`,iframe:!0}:/\.(mp4|webm|ogg|ogv|mov)(#.*|\?.*)?$/i.test(e)?{type:`Direct video`,embedUrl:e}:null}_buildEmbedHtml(e,t){let n=this._parseVideoUrl(e),r=Math.round(t*9/16);if(n?.iframe){let e=e=>String(e).replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`),i=e(`${n.type} video player`);return`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><iframe src="${e(n.embedUrl)}" width="${t}" height="${r}" title="${i}" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" style="display:block;max-width:100%"></iframe><div class="an-video-shield"></div></div>`}if(n?.type===`Direct video`)return`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><video src="${n.embedUrl.replaceAll(`"`,`%22`)}" width="${t}" height="${r}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>`;let i=N(e,{media:!0});return i?`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><video src="${i.replaceAll(`"`,`%22`)}" width="${t}" height="${r}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>`:null}},hi=[{pos:`nw`,cursor:`nw-resize`},{pos:`n`,cursor:`n-resize`},{pos:`ne`,cursor:`ne-resize`},{pos:`e`,cursor:`e-resize`},{pos:`se`,cursor:`se-resize`},{pos:`s`,cursor:`s-resize`},{pos:`sw`,cursor:`sw-resize`},{pos:`w`,cursor:`w-resize`}],gi=class{constructor(e){this.context=e,this._active=null,this._overlay=null,this._disposers=[],this._positionRaf=null,this._lastOverlayPos=null}get _overlayClass(){return`an-resizer`}get _selectedClass(){return`an-selected`}_findTarget(e){return null}_getStartSize(e){return{w:0,h:0}}_getMinSize(){return{minW:20,minH:20}}_applySize(e,t,n){}_extraListeners(){return[]}initialize(){this._overlay=this._buildOverlay();let e=this.context.layoutInfo.editable.closest(`.an-container`)||document.body;e.appendChild(this._overlay),this._container=e;let t=this.context.layoutInfo.editable,n=null;return this._disposers.push(v(t,`click`,e=>this._onEditorClick(e)),v(t,`contextmenu`,e=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let t=this._findTarget(e.target);t&&this._select(t)}),v(document,`click`,e=>this._onDocClick(e)),v(globalThis,`scroll`,()=>this._updateOverlayPosition(),{passive:!0}),v(globalThis,`resize`,()=>{clearTimeout(n),n=setTimeout(()=>this._updateOverlayPosition(),100)},{passive:!0}),v(t,`scroll`,()=>this._updateOverlayPosition(),{passive:!0}),...this._extraListeners()),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._dragDisposers&&=(this._dragDisposers.forEach(e=>e()),null),this._positionRaf&&=(cancelAnimationFrame(this._positionRaf),null),this._deselect(),this._overlay?.remove(),this._overlay=null}updateOverlay(){this._updateOverlayPosition()}deselect(){this._deselect()}_buildOverlay(){let e=document.createElement(`div`);return e.className=this._overlayClass,e.style.display=`none`,hi.forEach(({pos:t})=>{let n=document.createElement(`div`);n.className=`an-resize-handle an-resize-${t}`,n.dataset.handle=t,this._disposers.push(v(n,`pointerdown`,e=>{e.preventDefault(),e.stopPropagation(),this._startResize(e,t)})),e.appendChild(n)}),e}_onEditorClick(e){if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let t=this._findTarget(e.target);t&&(e.preventDefault(),this._select(t))}_onDocClick(e){this._active&&(this._active.contains(e.target)||this._overlay?.contains(e.target)||e.target.closest?.(`.an-contextmenu`)||this._deselect())}_select(e){this._active&&this._active!==e&&this._active.classList.remove(this._selectedClass),this._active=e,this._lastOverlayPos=null,e.classList.add(this._selectedClass),this._updateOverlayPosition(),this._overlay.style.display=`block`}_deselect(){this._active&&=(this._active.classList.remove(this._selectedClass),null),this._overlay&&(this._overlay.style.display=`none`)}_updateOverlayPosition(){this._positionRaf&&cancelAnimationFrame(this._positionRaf),this._positionRaf=requestAnimationFrame(()=>{this._positionRaf=null,this._updateOverlayPositionNow()})}_updateOverlayPositionNow(){if(!this._active||!this._overlay)return;let e=this._overlay.offsetParent||this._container,t=e.getBoundingClientRect(),n=this._active.getBoundingClientRect(),r=this._lastOverlayPos;if(r?.l===n.left&&r.t===n.top&&r.w===n.width&&r.h===n.height)return;this._lastOverlayPos={l:n.left,t:n.top,w:n.width,h:n.height};let i=n.left-t.left+e.scrollLeft,a=n.top-t.top+e.scrollTop;this._overlay.style.left=`${i}px`,this._overlay.style.top=`${a}px`,this._overlay.style.width=`${n.width}px`,this._overlay.style.height=`${n.height}px`}_startResize(e,t){let n=this._active;if(!n)return;let r=e.clientX,i=e.clientY,{w:a,h:o}=this._getStartSize(n),{minW:s,minH:c}=this._getMinSize(),l=a/(o||1),u=t.length===2,d=this.context.layoutInfo.editable,f=null,p=e=>{if(f!==null)return;let p=e.clientX,m=e.clientY;f=requestAnimationFrame(()=>{f=null;let e=p-r,h=m-i,g=d.clientWidth||1/0,_=a,v=o;t.includes(`e`)&&(_=Math.max(s,a+e)),t.includes(`w`)&&(_=Math.max(s,a-e)),t.includes(`s`)&&(v=Math.max(c,o+h)),t.includes(`n`)&&(v=Math.max(c,o-h)),_=Math.min(_,g),u&&(Math.abs(e)>=Math.abs(h)||(_=Math.min(Math.max(s,Math.round(v*l)),g)),v=Math.max(c,Math.round(_/l))),this._applySize(n,_,v),this._updateOverlayPosition()})},m=()=>{document.removeEventListener(`pointermove`,p),document.removeEventListener(`pointerup`,h),document.removeEventListener(`pointercancel`,h)},h=()=>{f!==null&&(cancelAnimationFrame(f),f=null),m(),this._dragDisposers=null,this.context.invoke(`editor.afterCommand`)};document.addEventListener(`pointermove`,p),document.addEventListener(`pointerup`,h),document.addEventListener(`pointercancel`,h),this._dragDisposers=[m]}},_i=class extends gi{get _overlayClass(){return`an-image-resizer`}get _selectedClass(){return`an-image-selected`}_findTarget(e){return e instanceof Element?e.closest(`img`):null}_getStartSize(e){return{w:e.offsetWidth||e.naturalWidth||100,h:e.offsetHeight||e.naturalHeight||100}}_getMinSize(){let e=this.context.options?.minImageSize??20;return{minW:e,minH:e}}_applySize(e,t,n){e.style.width=`${t}px`,e.style.height=`${n}px`}getActiveImage(){return this._active}},vi=class extends gi{get _overlayClass(){return`an-video-resizer`}get _selectedClass(){return`an-video-selected`}_findTarget(e){return!e||!(e instanceof Element)?null:e.classList?.contains(`an-video-wrapper`)?e:e.closest(`.an-video-wrapper`)}_getStartSize(e){return{w:e.offsetWidth||560,h:e.offsetHeight||315}}_getMinSize(){return{minW:80,minH:45}}_applySize(e,t,n){e.style.width=`${t}px`,e.style.height=`${n}px`;let r=e.querySelector(`iframe, video`);r&&(r.style.width=`${t}px`,r.style.height=`${n}px`)}_extraListeners(){let e=this.context.layoutInfo.editable;return[v(e,`dragstart`,e=>{e.target instanceof Element&&e.target.closest(`.an-video-wrapper`)&&e.preventDefault()})]}getActiveWrapper(){return this._active}},yi={open:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>`,edit:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,unlink:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" y1="2" x2="8" y2="5"/><line x1="2" y1="8" x2="5" y2="8"/><line x1="16" y1="19" x2="16" y2="22"/><line x1="19" y1="16" x2="22" y2="16"/></svg>`,copy:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`},bi=120,xi=200,Si=class{constructor(e){this.context=e,this._el=null,this._activeAnchor=null,this._showTimer=null,this._hideTimer=null,this._disposers=[]}initialize(){this._el=this._buildTooltip(),x(this.context).appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(v(e,`mouseover`,t=>{let n=t.target?.closest(`a[href]`);n&&e.contains(n)&&this._scheduleShow(n)}),v(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()}),v(globalThis,`scroll`,()=>this._hide(),{passive:!0}),v(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.parentNode&&this._el.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.link,t=h(`div`,{class:`an-link-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._urlLabel=h(`span`,{class:`an-link-tooltip-url`}),t.appendChild(this._urlLabel),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._openBtn=this._makeBtn(yi.open,e.openLink,()=>this._openLink()),this._copyBtn=this._makeBtn(yi.copy,e.copyUrl,()=>this._copyLink()),this._editBtn=this._makeBtn(yi.edit,e.editLink,()=>this._editLink()),this._unlinkBtn=this._makeBtn(yi.unlink,e.removeLink,()=>this._unlink()),t.appendChild(this._openBtn),t.appendChild(this._copyBtn),t.appendChild(this._editBtn),t.appendChild(this._unlinkBtn),this._disposers.push(v(t,`mouseenter`,()=>this._clearTimers()),v(t,`mouseleave`,()=>this._scheduleHide())),t}_makeBtn(e,t,n){let r=h(`button`,{type:`button`,class:`an-link-tooltip-btn`,title:t});return r.innerHTML=e,this._disposers.push(v(r,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),r}_scheduleShow(e){(this._activeAnchor!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._activeAnchor=e,this._show(e)},bi))}_scheduleHide(){clearTimeout(this._showTimer),this._showTimer=null,!this._hideTimer&&(this._hideTimer=setTimeout(()=>{this._hide()},xi))}_show(e){let t=this.context.layoutInfo.container.classList.contains(`an-disabled`),n=e.getAttribute(`href`)||``;this._urlLabel.textContent=this._truncateUrl(n),this._urlLabel.title=n,this._editBtn.style.display=t?`none`:``,this._unlinkBtn.style.display=t?`none`:``,this._el.style.display=`flex`,this._positionNear(e)}_hide(){this._el.style.display=`none`,this._activeAnchor=null,this._clearTimers()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){let t=e.getBoundingClientRect(),n=this._el.offsetWidth||260,r=this._el.offsetHeight||34,i=t.bottom+6,a=t.left;i+r>globalThis.innerHeight-6&&(i=t.top-r-6),a+n>globalThis.innerWidth-6&&(a=globalThis.innerWidth-n-6),a<6&&(a=6),this._el.style.top=`${i}px`,this._el.style.left=`${a}px`}_truncateUrl(e){try{let t=new URL(e),n=t.host+(t.pathname===`/`?``:t.pathname);return n.length>48?n.slice(0,48)+`…`:n}catch{return e.length>48?e.slice(0,48)+`…`:e}}_openLink(){let e=this._activeAnchor?.getAttribute(`href`);e&&globalThis.open(e,`_blank`,`noopener,noreferrer`),this._hide()}_copyLink(){let e=this._activeAnchor?.getAttribute(`href`);e&&navigator.clipboard.writeText(e).catch(()=>{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),t.remove()}),this._copyBtn&&(this._copyBtn.classList.add(`an-link-tooltip-btn--copied`),setTimeout(()=>this._copyBtn?.classList.remove(`an-link-tooltip-btn--copied`),1e3))}_editLink(){let e=this._activeAnchor;if(!e)return;this._hide();let t=globalThis.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),this.context.invoke(`linkDialog.show`)}_unlink(){let e=this._activeAnchor;if(!e)return;this._hide();let t=globalThis.getSelection(),n=document.createRange();n.selectNode(e),t.removeAllRanges(),t.addRange(n),document.execCommand(`unlink`),this.context.invoke(`editor.afterCommand`)}},Ci=class{constructor(e){this.context=e,this.options=e.options,this._el=null,this._active=null,this._showTimer=null,this._hideTimer=null,this._disposers=[]}_canHide(){return!0}_beforeHide(){}_makeBtn(e,t,n,r=!1){let i=h(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(v(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){(this._active!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._active=e,this._show(e)},100))}_scheduleHide(){this._canHide()&&(clearTimeout(this._showTimer),this._showTimer=null,clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>this._hide(),180))}_show(e){this._el.style.display=`flex`,requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_hide(){this._beforeHide(),this._el.style.display=`none`,this._active=null,this._clearTimers()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){let t=e.getBoundingClientRect(),n=this._el.offsetWidth||220,r=this._el.offsetHeight||32,i=t.bottom+6,a=t.left+(t.width-n)/2;i+r>globalThis.innerHeight-6&&(i=t.top-r-6),a+n>globalThis.innerWidth-6&&(a=globalThis.innerWidth-n-6),a<6&&(a=6),this._el.style.top=`${i}px`,this._el.style.left=`${a}px`}},K={floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="4" width="10" height="8" rx="1"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="6" y1="20" x2="18" y2="20"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteImg:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,caption:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="11" rx="2"/><line x1="6" y1="18" x2="18" y2="18"/><line x1="9" y1="21" x2="15" y2="21"/></svg>`,rotateLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><polyline points="3 3 3 8 8 8"/></svg>`,rotateRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><polyline points="21 3 21 8 16 8"/></svg>`,crop:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 2 6 18 22 18"/><polyline points="2 6 18 6 18 22"/></svg>`},wi=class extends Ci{initialize(){this._el=this._buildTooltip(),x(this.context).appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(v(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`img`);n&&e.contains(n)&&!n.closest(`a[href]`)&&this._scheduleShow(n)},{passive:!0}),v(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()},{passive:!0}),v(document,`click`,e=>{let t=e.target;this._active&&!this._active.contains(t)&&!this._el.contains(t)&&this._hide()}),v(globalThis,`scroll`,()=>this._hide(),{passive:!0}),v(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.image,t=h(`div`,{class:`an-link-tooltip an-image-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=h(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._floatLeftBtn=this._makeBtn(K.floatLeft,e.floatLeft,()=>this._setFloat(`left`)),this._floatNoneBtn=this._makeBtn(K.floatNone,e.noFloat,()=>this._setFloat(``)),this._alignCenterBtn=this._makeBtn(K.alignCenter,e.alignCenter,()=>this._setCenter()),this._floatRightBtn=this._makeBtn(K.floatRight,e.floatRight,()=>this._setFloat(`right`)),t.appendChild(this._floatLeftBtn),t.appendChild(this._floatNoneBtn),t.appendChild(this._alignCenterBtn),t.appendChild(this._floatRightBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._originalBtn=this._makeBtn(K.originalSize,e.originalSize,()=>this._resetSize()),t.appendChild(this._originalBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),t.appendChild(this._makeBtn(K.rotateLeft,e.rotateLeft,()=>this._rotate(-90))),t.appendChild(this._makeBtn(K.rotateRight,e.rotateRight,()=>this._rotate(90))),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._cropBtn=this._makeBtn(K.crop,e.cropImage,()=>this._crop()),t.appendChild(this._cropBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._captionBtn=this._makeBtn(K.caption,e.addCaption,()=>this._toggleCaption()),t.appendChild(this._captionBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._deleteBtn=this._makeBtn(K.deleteImg,e.deleteImage,()=>this._delete(),!0),t.appendChild(this._deleteBtn),this._disposers.push(v(t,`mouseenter`,()=>this._clearTimers()),v(t,`mouseleave`,()=>this._scheduleHide())),t}_setFloat(e){let t=this._active;if(!t)return;let n=t.closest(`figure.an-figure`)||t;n.style.float=e,n.style.display=``,n!==t&&(n.style.width=``),n.style.marginLeft=e===`right`?`12px`:``,n.style.marginRight=e===`left`?`12px`:``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_setCenter(){let e=this._active;if(!e)return;let t=e.closest(`figure.an-figure`)||e;t.style.float=``,t.style.display=`block`,t!==e&&(t.style.width=`fit-content`),t.style.marginLeft=`auto`,t.style.marginRight=`auto`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_resetSize(){let e=this._active;e&&(e.style.width=``,e.style.height=``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_rotate(e){let t=this._active;if(!t)return;let n=t.style.transform||``,r=/rotate\((-?[\d.]+)deg\)/.exec(n),i=((r?Number.parseFloat(r[1]):0)+e+360)%360,a=n.replace(/rotate\(-?[\d.]+deg\)/,``).trim();a?t.style.transform=`${a} rotate(${i}deg)`:t.style.transform=i===0?``:`rotate(${i}deg)`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_delete(){let e=this._active;if(!e)return;this._hide(),this.context.invoke(`imageResizer.deselect`);let t=e.closest(`figure.an-figure`);t?t.remove():e.remove(),this.context.invoke(`editor.afterCommand`)}_crop(){let e=this._active;e&&(this._hide(),this.context.invoke(`imageCropOverlay.open`,e))}_toggleCaption(){let e=this._active;if(!e)return;let t=e.closest(`figure.an-figure`);if(t){let e=t.querySelector(`figcaption.an-figcaption`);if(e){this._hide();let t=document.createRange();t.selectNodeContents(e);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}return}let n=document.createElement(`figure`);n.className=`an-figure`,e.style.float?(n.style.float=e.style.float,n.style.marginLeft=e.style.marginLeft,n.style.marginRight=e.style.marginRight,e.style.float=``,e.style.marginLeft=``,e.style.marginRight=``):e.style.display===`block`&&e.style.marginLeft===`auto`&&(n.style.display=`block`,n.style.width=`fit-content`,n.style.marginLeft=`auto`,n.style.marginRight=`auto`,e.style.display=``,e.style.marginLeft=``,e.style.marginRight=``);let r=document.createElement(`figcaption`);r.className=`an-figcaption`,r.textContent=`Caption`,e.parentNode.insertBefore(n,e),n.appendChild(e),n.appendChild(r);let i=document.createRange();i.selectNodeContents(r);let a=globalThis.getSelection();a&&(a.removeAllRanges(),a.addRange(i)),this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),this._hide()}},q={floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="4" width="10" height="8" rx="1"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="6" y1="20" x2="18" y2="20"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteVideo:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,preview:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="5 3 19 12 5 21 5 3"/></svg>`},Ti=class extends Ci{initialize(){this._el=this._buildTooltip(),x(this.context).appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(v(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`.an-video-wrapper`);n&&e.contains(n)&&this._scheduleShow(n)},{passive:!0}),v(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()},{passive:!0}),v(document,`click`,e=>{let t=e.target;this._active&&!this._active.contains(t)&&!this._el.contains(t)&&this._hide()}),v(globalThis,`scroll`,()=>this._hide(),{passive:!0}),v(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._previewMode&&this._exitPreview(),this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_canHide(){return!this._previewMode}_beforeHide(){this._previewMode&&this._exitPreview()}_buildTooltip(){let e=this.context.locale.tooltips.video,t=h(`div`,{class:`an-link-tooltip an-video-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=h(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._floatLeftBtn=this._makeBtn(q.floatLeft,e.floatLeft,()=>this._setFloat(`left`)),this._floatNoneBtn=this._makeBtn(q.floatNone,e.noFloat,()=>this._setFloat(``)),this._alignCenterBtn=this._makeBtn(q.alignCenter,e.alignCenter,()=>this._setCenter()),this._floatRightBtn=this._makeBtn(q.floatRight,e.floatRight,()=>this._setFloat(`right`)),t.appendChild(this._floatLeftBtn),t.appendChild(this._floatNoneBtn),t.appendChild(this._alignCenterBtn),t.appendChild(this._floatRightBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._originalBtn=this._makeBtn(q.originalSize,e.originalSize,()=>this._resetSize()),t.appendChild(this._originalBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._previewBtn=this._makeBtn(q.preview,e.previewVideo,()=>this._togglePreview()),t.appendChild(this._previewBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._deleteBtn=this._makeBtn(q.deleteVideo,e.deleteVideo,()=>this._delete(),!0),t.appendChild(this._deleteBtn),this._disposers.push(v(t,`mouseenter`,()=>this._clearTimers()),v(t,`mouseleave`,()=>this._scheduleHide())),t}_setFloat(e){let t=this._active;t&&(t.style.float=e,t.style.display=e?`inline-block`:``,t.style.marginLeft=e===`right`?`12px`:``,t.style.marginRight=e===`left`?`12px`:``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_setCenter(){let e=this._active;e&&(e.style.float=``,e.style.display=`block`,e.style.marginLeft=`auto`,e.style.marginRight=`auto`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_resetSize(){let e=this._active;if(!e)return;let t=e.querySelector(`iframe, video`);e.style.width=``,e.style.height=``,t&&(t.removeAttribute(`width`),t.removeAttribute(`height`),t.style.width=``,t.style.height=``),this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_delete(){let e=this._active;e&&(this._hide(),this.context.invoke(`videoResizer.deselect`),e.remove(),this.context.invoke(`editor.afterCommand`))}_togglePreview(){this._previewMode?this._exitPreview():this._enterPreview()}_enterPreview(){let e=this._active;if(!e)return;this._previewMode=!0;let t=e.querySelector(`.an-video-shield`);t&&(t.style.display=`none`),this.context.invoke(`videoResizer.deselect`),this._previewBtn.classList.add(`an-link-tooltip-btn--copied`),this._previewBtn.title=this.context.locale.tooltips.video.exitPreview,this._previewClickOff=t=>{!e.contains(t.target)&&!this._el.contains(t.target)&&this._exitPreview()},document.addEventListener(`mousedown`,this._previewClickOff,!0)}_exitPreview(){this._previewMode=!1;let e=this._active;if(e){let t=e.querySelector(`.an-video-shield`);t&&(t.style.display=``)}this._previewBtn.classList.remove(`an-link-tooltip-btn--copied`),this._previewBtn.title=this.context.locale.tooltips.video.previewVideo,this._previewClickOff&&=(document.removeEventListener(`mousedown`,this._previewClickOff,!0),null)}},J={rowAbove:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><path d="M12 3v7"/><path d="M9 7l3-4 3 4"/></svg>`,rowBelow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><path d="M12 12v7"/><path d="M9 17l3 4 3-4"/></svg>`,deleteRow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="15" y1="15" x2="21" y2="21"/><line x1="21" y1="15" x2="15" y2="21"/></svg>`,colLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><path d="M3 12h7"/><path d="M7 8l-4 4 4 4"/></svg>`,colRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><path d="M12 12h9"/><path d="M17 8l4 4-4 4"/></svg>`,deleteCol:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><line x1="15" y1="6" x2="21" y2="12"/><line x1="21" y1="6" x2="15" y2="12"/></svg>`,mergeCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="8" height="10" rx="1"/><rect x="14" y="7" width="8" height="10" rx="1"/><path d="M10 12h4"/><path d="M12 10l2 2-2 2"/></svg>`,unmergeCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="5" width="20" height="14" rx="1"/><line x1="12" y1="5" x2="12" y2="19" stroke-dasharray="2.5 2"/><line x1="2" y1="12" x2="22" y2="12" stroke-dasharray="2.5 2"/><path d="M9 9 L6 12 L9 15"/><path d="M15 9 L18 12 L15 15"/></svg>`,colWidth:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="4" x2="7" y2="20"/><line x1="17" y1="4" x2="17" y2="20"/><line x1="7" y1="12" x2="17" y2="12"/><path d="M10 9l-3 3 3 3"/><path d="M14 9l3 3-3 3"/></svg>`,rowHeight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="7" x2="20" y2="7"/><line x1="4" y1="17" x2="20" y2="17"/><line x1="12" y1="7" x2="12" y2="17"/><path d="M9 10l3-3 3 3"/><path d="M9 14l3 3 3-3"/></svg>`,tableBorder:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="3" y1="6" x2="21" y2="6" stroke-width="1"/><line x1="3" y1="13" x2="21" y2="13" stroke-width="2"/><line x1="3" y1="20" x2="21" y2="20" stroke-width="3"/></svg>`,deleteTable:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/><line x1="16" y1="16" x2="22" y2="22" stroke="#ef4444"/><line x1="22" y1="16" x2="16" y2="22" stroke="#ef4444"/></svg>`,selectCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4 L4 20 L9 15 L12 21 L14 20 L11 14 L17 14 Z" fill="currentColor" opacity="0.15"/><path d="M4 4 L4 20 L9 15 L12 21 L14 20 L11 14 L17 14 Z"/></svg>`,cellShade:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 11L8.93 3.36a1 1 0 0 0-1.29.08L3.22 7.8a1 1 0 0 0-.07 1.29L11 20"/><path d="m5 14 5-5"/><path d="M22 22a2 2 0 0 1-2 2h-3a2 2 0 0 1-2-2c0-1.5 2.5-5 3.5-5s3.5 3.5 3.5 5z"/></svg>`,borderColor:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="14" rx="1"/><line x1="3" y1="10" x2="21" y2="10" stroke-width="1.5"/><line x1="12" y1="3" x2="12" y2="17" stroke-width="1.5"/><path d="M3 21h18" stroke-width="3"/></svg>`,alignLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="15" y1="12" x2="3" y2="12"/><line x1="17" y1="18" x2="3" y2="18"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="17" y1="12" x2="7" y2="12"/><line x1="19" y1="18" x2="5" y2="18"/></svg>`,alignRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="9" y2="12"/><line x1="21" y1="18" x2="7" y2="18"/></svg>`,alignJustify:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="3" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/></svg>`,headerRow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><rect x="3" y="3" width="18" height="8" rx="1" fill="currentColor" opacity="0.2"/><line x1="3" y1="11" x2="21" y2="11"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="9" y1="11" x2="9" y2="21"/><line x1="15" y1="11" x2="15" y2="21"/></svg>`,sortAsc:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="6" x2="11" y2="6"/><line x1="4" y1="12" x2="11" y2="12"/><line x1="4" y1="18" x2="13" y2="18"/><path d="M15 9l3-3 3 3"/><line x1="18" y1="6" x2="18" y2="18"/></svg>`,sortDesc:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="6" x2="13" y2="6"/><line x1="4" y1="12" x2="11" y2="12"/><line x1="4" y1="18" x2="11" y2="18"/><path d="M15 15l3 3 3-3"/><line x1="18" y1="6" x2="18" y2="18"/></svg>`,exportCSV:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`,cellPadding:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><rect x="7" y="7" width="10" height="10" rx="0.5" stroke-dasharray="2 1.5"/></svg>`};function Ei(e){let t=e.closest(`tr`);if(!t)return-1;let n=0;for(let r of t.cells){if(r===e)return n;n+=r.colSpan||1}return-1}function Y(e,t){let n=0;for(let r of e.cells){if(n===t)return r;if(n>t)break;n+=r.colSpan||1}return null}function Di(e,t){let n=0;for(let r of e.cells)if(n+=r.colSpan||1,n>t){let e=r.nextElementSibling;return e?.tagName===`TD`||e?.tagName===`TH`?e:null}return null}function Oi(e){let t=Array.from(e.rows),n={},r=new WeakMap;return t.forEach((e,t)=>{n[t]||(n[t]={});let i=0;for(let a of e.cells){for(;n[t][i];)i++;let e=a.rowSpan||1,o=a.colSpan||1;r.set(a,{r:t,c:i,rs:e,cs:o});for(let r=0;r<e;r++){n[t+r]||(n[t+r]={});for(let e=0;e<o;e++)n[t+r][i+e]=a}i+=o}}),{gridMap:n,cellPos:r}}var ki=120,Ai=200,ji=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`],Mi=class{constructor(e){this.context=e,this._el=null,this._activeTable=null,this._activeCell=null,this._showTimer=null,this._hideTimer=null,this._disposers=[],this._sizePopover=null,this._sizeApply=null,this._sizeTitleEl=null,this._sizeInputEl=null,this._shadePopover=null,this._shadeTitleEl=null,this._shadeColorStrip=null,this._borderColorPopover=null,this._borderColorTitleEl=null,this._borderColorStrip=null,this._borderColorNoBtn=null,this._selectMode=!1,this._selectedCells=[],this._selectStart=null,this._selectDragging=!1,this._selectBtn=null,this._editable=null}initialize(){this._el=this._buildTooltip(),x(this.context).appendChild(this._el),this._sizePopover=this._buildSizePopover(),x(this.context).appendChild(this._sizePopover),this._shadePopover=this._buildCellShadePopover(),x(this.context).appendChild(this._shadePopover),this._borderColorPopover=this._buildBorderColorPopover(),x(this.context).appendChild(this._borderColorPopover);let e=this.context.layoutInfo.editable;return this._editable=e,this._disposers.push(v(e,`mousedown`,t=>{if(!this._selectMode)return;let n=t.target.closest(`td, th`);!n||!e.contains(n)||n.style.cursor!==`col-resize`&&n.style.cursor!==`row-resize`&&(t.preventDefault(),this._activeTable=n.closest(`table`),this._selectStart=n,this._selectDragging=!0,this._setSelection([n]))}),v(e,`mousemove`,t=>{if(!this._selectMode||!this._selectDragging||!this._selectStart)return;let n=t.target.closest(`td, th`);!n||!e.contains(n)||n.closest(`table`)===this._activeTable&&this._setSelection(this._getRectCells(this._selectStart,n))}),v(document,`mouseup`,()=>{this._selectDragging=!1}),v(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`table`);if(n&&e.contains(n)){let e=t.target?.closest(`td, th`);e&&(this._activeCell=e,this._syncShadeStrip()),this._scheduleShow(n)}},{passive:!0}),v(e,`mouseout`,t=>{if(this._selectMode)return;let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n)&&!this._sizePopover?.contains(n))&&this._scheduleHide()},{passive:!0}),v(document,`click`,e=>{let t=e.target;this._selectMode&&this._activeTable?.contains(t)||this._activeTable&&!this._activeTable.contains(t)&&!this._el.contains(t)&&!this._sizePopover?.contains(t)&&!this._shadePopover?.contains(t)&&!this._borderColorPopover?.contains(t)&&this._hide()}),v(document,`selectionchange`,()=>this._syncShadeStrip()),v(globalThis,`scroll`,()=>this._hide(),{passive:!0}),v(globalThis,`resize`,()=>this._hide(),{passive:!0})),this._initResize(),this}_initResize(){let e=this.context.layoutInfo.editable,t=null,n=null,r=!1,i=null,a=0,o=0,s=0,c=0,l=-1,u=null,d=null,f=null,p=null,m=null,h=()=>{t&&=(t.style.cursor=``,null),n=null};this._disposers.push(v(e,`mousemove`,i=>{if(r)return;if(this.context.layoutInfo.container.classList.contains(`an-disabled`)){h();return}if(m!==null)return;let a=i.target,o=i.clientX,s=i.clientY;m=requestAnimationFrame(()=>{m=null;let r=a.closest(`td, th`);if(!r||!e.contains(r)){h();return}t&&t!==r&&(t.style.cursor=``);let i=r.getBoundingClientRect(),c=Math.abs(o-i.right)<6,l=Math.abs(s-i.bottom)<6;c?(r.style.cursor=`col-resize`,t=r,n=`col`):l?(r.style.cursor=`row-resize`,t=r,n=`row`):h()})}),v(e,`mousedown`,e=>{if(!this.context.layoutInfo.container.classList.contains(`an-disabled`)&&!(!t||!n)){if(r=!0,i=n,a=e.clientX,o=e.clientY,f=t.closest(`table`),i===`col`)l=Ei(t)+(t.colSpan||1)-1,u=l>=0?Array.from(f.querySelectorAll(`tr`)).map(e=>Y(e,l)).filter(Boolean).filter(e=>(e.colSpan||1)===1):[],s=u.length>0?u[0].offsetWidth:Math.max(30,Math.round(t.offsetWidth/(t.colSpan||1))),document.body.style.cursor=`col-resize`;else{let e=t.closest(`tr`),n=(e?Array.from(f.rows).indexOf(e):0)+(t.rowSpan||1)-1;d=f.rows[n]||e,c=d?d.offsetHeight:40,document.body.style.cursor=`row-resize`}document.body.style.userSelect=`none`,e.preventDefault(),e.stopPropagation()}}),v(document,`mousemove`,e=>{if(!r||p!==null)return;let t=e.clientX,n=e.clientY;p=requestAnimationFrame(()=>{if(p=null,i===`col`){let e=Math.max(30,s+(t-a));for(let t of u)t.style.width=`${e}px`,t.style.minWidth=`${e}px`}else{let e=Math.max(20,c+(n-o));if(d)for(let t of d.cells)t.style.height=`${e}px`,t.style.minHeight=`${e}px`}})}),v(document,`mouseup`,()=>{r&&(p!==null&&(cancelAnimationFrame(p),p=null),r=!1,document.body.style.userSelect=``,document.body.style.cursor=``,i=null,f=null,d=null,l=-1,u=null,this.context.invoke(`editor.afterCommand`))}))}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.parentNode&&this._el.remove(),this._el=null,this._sizePopover?.parentNode&&this._sizePopover.remove(),this._sizePopover=null,this._shadePopover?.parentNode&&this._shadePopover.remove(),this._shadePopover=null,this._borderColorPopover?.parentNode&&this._borderColorPopover.remove(),this._borderColorPopover=null}_buildTooltip(){let e=this.context.locale.tooltips.table,t=h(`div`,{class:`an-link-tooltip an-table-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});t.style.display=`none`,this._label=h(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(this._sep()),this._selectBtn=this._makeBtn(J.selectCells,e.selectCells,()=>this._toggleSelectMode()),t.appendChild(this._selectBtn),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.rowAbove,e.addRowAbove,()=>this._addRow(`above`))),t.appendChild(this._makeBtn(J.rowBelow,e.addRowBelow,()=>this._addRow(`below`))),t.appendChild(this._makeBtn(J.deleteRow,e.deleteRow,()=>this._deleteRow())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.colLeft,e.addColumnLeft,()=>this._addColumn(`left`))),t.appendChild(this._makeBtn(J.colRight,e.addColumnRight,()=>this._addColumn(`right`))),t.appendChild(this._makeBtn(J.deleteCol,e.deleteColumn,()=>this._deleteColumn())),t.appendChild(this._makeBtn(J.sortAsc,e.sortAsc,()=>this._sortColumn(`asc`))),t.appendChild(this._makeBtn(J.sortDesc,e.sortDesc,()=>this._sortColumn(`desc`))),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.mergeCells,e.mergeCells,()=>this._mergeCells())),t.appendChild(this._makeBtn(J.unmergeCells,e.unmergeCells,()=>this._unmergeCells())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.alignLeft,e.cellAlignLeft,()=>this._applyCellAlign(`left`))),t.appendChild(this._makeBtn(J.alignCenter,e.cellAlignCenter,()=>this._applyCellAlign(`center`))),t.appendChild(this._makeBtn(J.alignRight,e.cellAlignRight,()=>this._applyCellAlign(`right`))),t.appendChild(this._makeBtn(J.alignJustify,e.cellAlignJustify,()=>this._applyCellAlign(`justify`))),t.appendChild(this._makeBtn(J.headerRow,e.toggleHeaderRow,()=>this._toggleHeaderRow())),t.appendChild(this._sep());let n=h(`button`,{type:`button`,class:`an-link-tooltip-btn an-link-tooltip-btn--shade`,title:e.cellBackground}),r=h(`span`,{class:`an-bubble-btn-svg`});r.innerHTML=J.cellShade;let i=h(`span`,{class:`an-link-tooltip-color-strip`});n.appendChild(r),n.appendChild(i),this._shadeColorStrip=i,this._disposers.push(v(n,`click`,e=>{e.preventDefault(),e.stopPropagation(),this._openCellShadePopover()})),t.appendChild(n),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.colWidth,e.columnWidth,()=>this._openSizePopover(`col`))),t.appendChild(this._makeBtn(J.rowHeight,e.rowHeight,()=>this._openSizePopover(`row`))),t.appendChild(this._makeBtn(J.tableBorder,e.tableBorderWidth,()=>this._openSizePopover(`border`))),t.appendChild(this._makeBtn(J.cellPadding,e.cellPadding,()=>this._openSizePopover(`cellPadding`)));let a=h(`button`,{type:`button`,class:`an-link-tooltip-btn an-link-tooltip-btn--shade`,title:e.tableBorderColor}),o=h(`span`,{class:`an-bubble-btn-svg`});o.innerHTML=J.borderColor;let s=h(`span`,{class:`an-link-tooltip-color-strip`});return a.appendChild(o),a.appendChild(s),this._borderColorStrip=s,this._disposers.push(v(a,`click`,e=>{e.preventDefault(),e.stopPropagation(),this._openBorderColorPopover()})),t.appendChild(a),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.deleteTable,e.deleteTable,()=>this._deleteTable(),!0)),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.exportCSV,e.exportCSV,()=>this._exportTableCSV())),this._disposers.push(v(t,`mouseenter`,()=>this._clearTimers()),v(t,`mouseleave`,()=>{this._selectMode||this._sizePopover&&this._sizePopover.style.display!==`none`||this._shadePopover&&this._shadePopover.style.display!==`none`||this._borderColorPopover&&this._borderColorPopover.style.display!==`none`||this._scheduleHide()})),t}_sep(){return h(`div`,{class:`an-link-tooltip-sep`})}_makeBtn(e,t,n,r=!1){let i=h(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(v(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){(this._activeTable!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._activeTable=e,this._show()},ki))}_scheduleHide(){clearTimeout(this._showTimer),this._showTimer=null,!this._hideTimer&&(this._hideTimer=setTimeout(()=>this._hide(),Ai))}_show(){this._activeTable&&(this._el.style.display=`flex`,this._syncShadeStrip(),this._syncBorderColorStrip(),requestAnimationFrame(()=>{this._activeTable&&this._positionNear(this._activeTable)}))}_syncShadeStrip(){if(!this._shadeColorStrip||!this._el||this._el.style.display===`none`)return;let e=this._getCell();this._shadeColorStrip.style.background=e?.style.backgroundColor||`transparent`}_hide(){this._el.style.display=`none`,this._activeTable=null,this._activeCell=null,this._selectMode&&(this._selectMode=!1,this._selectBtn&&this._selectBtn.classList.remove(`an-link-tooltip-btn--active`),this._editable&&this._editable.classList.remove(`an-table-select-mode`)),this._clearSelection(),this._clearTimers(),this._hideSizePopover(),this._hideBorderColorPopover()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){if(!e)return;let t=e.getBoundingClientRect(),n=this._el.offsetWidth||400,r=this._el.offsetHeight||30,i=t.left+(t.width-n)/2,a=t.top-r-6;a<6&&(a=t.bottom+6),i+n>globalThis.innerWidth-6&&(i=globalThis.innerWidth-n-6),i<6&&(i=6),this._el.style.left=`${i}px`,this._el.style.top=`${a}px`}_getCell(){let e=globalThis.getSelection();if(e?.rangeCount){let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`td, th`);if(n&&this._activeTable?.contains(n))return n}return this._activeCell||this._activeTable?.querySelector(`td, th`)}_toggleSelectMode(){this._selectMode=!this._selectMode,this._selectBtn&&this._selectBtn.classList.toggle(`an-link-tooltip-btn--active`,this._selectMode),this._editable&&this._editable.classList.toggle(`an-table-select-mode`,this._selectMode),this._selectMode||this._clearSelection()}_clearSelection(){this._selectedCells.forEach(e=>e.classList.remove(`an-cell-selected`)),this._selectedCells=[],this._selectStart=null}_setSelection(e){this._selectedCells.forEach(t=>{e.includes(t)||t.classList.remove(`an-cell-selected`)}),this._selectedCells=e,e.forEach(e=>e.classList.add(`an-cell-selected`))}_getRectCells(e,t){if(!e)return[];if(!t||e===t)return[e];let n=e.closest(`table`);if(!n?.contains(t))return[e];let{gridMap:r,cellPos:i}=Oi(n),a=i.get(e),o=i.get(t);if(!a||!o)return[e];let s=Math.min(a.r,o.r),c=Math.max(a.r+a.rs-1,o.r+o.rs-1),l=Math.min(a.c,o.c),u=Math.max(a.c+a.cs-1,o.c+o.cs-1),d=!0;for(;d;){d=!1;for(let e=s;e<=c;e++){let t=r[e];if(t)for(let e=l;e<=u;e++){let n=t[e];if(!n)continue;let r=i.get(n);r&&(r.r<s&&(s=r.r,d=!0),r.r+r.rs-1>c&&(c=r.r+r.rs-1,d=!0),r.c<l&&(l=r.c,d=!0),r.c+r.cs-1>u&&(u=r.c+r.cs-1,d=!0))}}}let f=new Set,p=[];for(let e=s;e<=c;e++){let t=r[e];if(t)for(let e=l;e<=u;e++){let n=t[e];n&&!f.has(n)&&(f.add(n),p.push(n))}}return p.length>0?p:[e]}_getSelectedCells(){return this._selectedCells.length>0?this._selectedCells:[this._getCell()].filter(Boolean)}_addRow(e){let t=this._getSelectedCells();if(!t.length)return;let n=t[0].closest(`table`);if(!n)return;let r=Array.from(n.querySelectorAll(`tr`)),i=[...new Set(t.map(e=>e.closest(`tr`)).filter(Boolean))],a=i.reduce((t,n)=>{let i=r.indexOf(t),a=r.indexOf(n);return e===`above`?a<i?n:t:a>i?n:t},i[0]),o=Array.from(a.cells).reduce((e,t)=>e+(t.colSpan||1),0),s=document.createElement(`tr`),c=Array.from(a.cells);for(let e=0;e<o;e++){let t=h(`td`,{},[`\xA0`]),n=c[e];n?.style.width&&(t.style.width=n.style.width),n?.style.minWidth&&(t.style.minWidth=n.style.minWidth),s.appendChild(t)}e===`above`?a.parentElement?.insertBefore(s,a):a.after(s),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_addColumn(e){let t=this._getSelectedCells();if(!t.length)return;let n=t[0].closest(`table`);if(!n)return;let r=t.map(e=>Ei(e)),i=e===`left`?Math.min(...r):Math.max(...r),a=Array.from(n.querySelectorAll(`tr`)),o=a.map(t=>e===`left`?Y(t,i):Di(t,i)),s=a.map(e=>e.closest(`thead`)!==null);a.forEach((e,t)=>{e.insertBefore(h(s[t]?`th`:`td`,{},[`\xA0`]),o[t])}),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_deleteRow(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=t.querySelector(`tbody`),r=n?n.querySelectorAll(`tr`).length:t.querySelectorAll(`tr`).length,i=[...new Set(e.map(e=>e.closest(`tr`)).filter(Boolean))];i.filter(e=>e.closest(`tbody`)).length>=r||(this._activeCell=null,this._clearSelection(),i.forEach(e=>e.remove()),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`))}_deleteColumn(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=Array.from(t.querySelectorAll(`tr`));if(n[0]&&n[0].cells.length<=1)return;let r=[...new Set(e.map(e=>Ei(e)))];if(r.length>=(n[0]?.cells.length??1))return;let i=[];r.forEach(e=>{n.forEach(t=>{let n=Y(t,e);n&&i.push(n)})}),this._activeCell=null,this._clearSelection(),i.forEach(e=>e.remove()),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_mergeCells(){let e=this._getCell();if(!e)return;let t=e.closest(`table`);if(!t)return;let n=this._getSelectedCells().filter(e=>t.contains(e));if(n.length<2){let e=globalThis.getSelection();if(!e||e.rangeCount===0)return;let r=e.getRangeAt(0);if(n=Array.from(t.querySelectorAll(`td, th`)).filter(e=>{try{return r.intersectsNode(e)}catch{return!1}}),n.length<2)return}let{gridMap:r,cellPos:i}=Oi(t),a=1/0,o=-1/0,s=1/0,c=-1/0;if(n.forEach(e=>{let t=i.get(e);t&&(t.r<a&&(a=t.r),t.r+t.rs-1>o&&(o=t.r+t.rs-1),t.c<s&&(s=t.c),t.c+t.cs-1>c&&(c=t.c+t.cs-1))}),a===1/0)return;let l=new Set,u=[];for(let e=a;e<=o;e++){let t=r[e];if(t)for(let e=s;e<=c;e++){let n=t[e];n&&!l.has(n)&&(l.add(n),u.push(n))}}if(u.length<2)return;let d=u[0];d.colSpan=c-s+1,d.rowSpan=o-a+1,d.style.verticalAlign=`middle`,d.style.height=``,d.style.minHeight=``;let f=u.map(e=>e.innerHTML.replace(/^(<br\s*\/?>|\s)+$/i,``).trim()).filter(e=>e!==``);d.innerHTML=f.length?f.join(`<br>`):`<br>`,u.slice(1).forEach(e=>{let t=e.parentElement;e.remove(),t&&t.cells.length===0&&t.remove()}),this._clearSelection(),this.context.invoke(`editor.afterCommand`)}_deleteTable(){let e=this._activeTable;e&&(this._hide(),e.parentNode&&e.remove(),this.context.invoke(`editor.afterCommand`))}_unmergeCells(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=e.filter(e=>t.contains(e)&&((e.colSpan||1)>1||(e.rowSpan||1)>1));n.length&&(n.forEach(e=>{t.contains(e)&&this._unmergeOne(e,t)}),this._clearSelection(),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`))}_unmergeOne(e,t){let n=e.colSpan||1,r=e.rowSpan||1;if(n===1&&r===1)return;let{cellPos:i}=Oi(t),a=i.get(e);if(!a)return;let{r:o,c:s}=a,c=Array.from(t.rows),l=e.tagName.toLowerCase();if(e.rowSpan=1,e.colSpan=1,e.style.verticalAlign=``,n>1){let t=e.nextElementSibling;for(let e=1;e<n;e++)c[o].insertBefore(h(l,{},[`\xA0`]),t)}for(let e=1;e<r;e++){let t=c[o+e];if(!t)continue;let r=null;for(let e of t.cells)if(i.get(e)?.c>s){r=e;break}for(let e=0;e<n;e++)t.insertBefore(h(l,{},[`\xA0`]),r)}}_buildSizePopover(){let e=h(`div`,{class:`an-size-popover`});e.style.display=`none`;let t=h(`div`,{class:`an-size-popover-title`}),n=h(`div`,{class:`an-size-popover-body`}),r=h(`input`,{type:`number`,class:`an-size-input`,min:`1`,max:`2000`,step:`1`}),i=h(`span`,{class:`an-size-unit`},[`px`]);n.appendChild(r),n.appendChild(i);let a=h(`div`,{class:`an-size-popover-actions`}),o=h(`button`,{type:`button`,class:`an-btn`});o.textContent=this.context.locale.tooltips.table.cancelBtn;let s=h(`button`,{type:`button`,class:`an-btn an-btn-primary`});s.textContent=this.context.locale.tooltips.table.applyBtn,a.appendChild(o),a.appendChild(s),e.appendChild(t),e.appendChild(n),e.appendChild(a),this._sizeTitleEl=t,this._sizeInputEl=r,this._sizeApply=null;let c=v(s,`click`,()=>{let e=Number.parseInt(this._sizeInputEl.value,10);e>=0&&typeof this._sizeApply==`function`&&this._sizeApply(e),this._hideSizePopover()}),l=v(o,`click`,()=>this._hideSizePopover()),u=v(r,`keydown`,e=>{let t=e;t.key===`Enter`&&(e.preventDefault(),s.click()),t.key===`Escape`&&this._hideSizePopover()}),d=v(document,`click`,e=>{let t=e.target;this._sizePopover&&this._sizePopover.style.display!==`none`&&!this._sizePopover.contains(t)&&!this._el.contains(t)&&this._hideSizePopover()}),f=v(e,`mouseenter`,()=>this._clearTimers()),p=v(e,`mouseleave`,()=>this._scheduleHide());return this._disposers.push(c,l,u,d,f,p),e}_openSizePopover(e){let t=this._getCell();if(!(!t||!this._sizePopover)){if(e===`border`){let e=t.closest(`table`);if(!e)return;let n=e.querySelector(`td, th`),r=n&&(Number.parseInt(n.style.borderWidth,10)||Number.parseInt(globalThis.getComputedStyle(n).borderWidth,10))||1;this._sizeTitleEl.textContent=this.context.locale.tooltips.table.tableBorderWidthPx,this._sizeInputEl.min=`0`,this._sizeInputEl.max=`10`,this._sizeInputEl.value=String(r),this._sizeApply=t=>{let n=Array.from(e.querySelectorAll(`td, th`));t===0?n.forEach(e=>{e.style.borderWidth=`0`,e.style.borderStyle=`none`}):n.forEach(e=>{e.style.borderWidth=`${t}px`,e.style.borderStyle=`solid`}),this.context.invoke(`editor.afterCommand`)}}else if(e===`cellPadding`){let e=this._getSelectedCells()[0]||this._getCell(),t=e&&(Number.parseInt(e.style.padding,10)||Number.parseInt(e.style.paddingTop,10))||4;this._sizeTitleEl.textContent=this.context.locale.tooltips.table.cellPaddingPx,this._sizeInputEl.min=`0`,this._sizeInputEl.max=`40`,this._sizeInputEl.value=String(t),this._sizeApply=e=>{this._getSelectedCells().forEach(t=>{t&&(t.style.padding=`${e}px`)}),this.context.invoke(`editor.afterCommand`)}}else{let n=e===`col`,r=this._getSelectedCells().filter(e=>{let n=e.closest(`table`);return n&&n===t.closest(`table`)});if(this._sizeTitleEl.textContent=n?this.context.locale.tooltips.table.columnWidthPx:this.context.locale.tooltips.table.rowHeightPx,this._sizeInputEl.min=`1`,this._sizeInputEl.max=`2000`,n)this._sizeInputEl.value=t.offsetWidth||120;else{let e=t.closest(`tr`);this._sizeInputEl.value=e&&e.offsetHeight||40}this._sizeApply=e=>{let i=t.closest(`table`);if(i){if(n){let t=[...new Set(r.map(e=>Ei(e)))],n=Array.from(i.querySelectorAll(`tr`));t.forEach(t=>{n.forEach(n=>{let r=Y(n,t);r&&(r.colSpan||1)===1&&(r.style.width=`${e}px`,r.style.minWidth=`${e}px`)})})}else[...new Set(r.map(e=>e.closest(`tr`)).filter(Boolean))].forEach(t=>{for(let n of t.cells)n.style.height=`${e}px`,n.style.minHeight=`${e}px`});this.context.invoke(`editor.afterCommand`)}}}this._sizePopover.style.display=`block`,requestAnimationFrame(()=>{if(!this._sizePopover||!this._el)return;let e=this._el.getBoundingClientRect(),t=this._sizePopover.offsetWidth||220,n=this._sizePopover.offsetHeight||110,r=e.left,i=e.bottom+6;r+t>globalThis.innerWidth-8&&(r=globalThis.innerWidth-t-8),i+n>globalThis.innerHeight-8&&(i=e.top-n-6),this._sizePopover.style.left=`${r}px`,this._sizePopover.style.top=`${i}px`,this._sizeInputEl&&(this._sizeInputEl.focus(),this._sizeInputEl.select())})}}_hideSizePopover(){this._sizePopover&&(this._sizePopover.style.display=`none`),this._sizeApply=null}_buildColorPopover({defaultColor:e,apply:t,getPopover:n,hide:r}){let i=h(`div`,{class:`an-cell-shade-popover`});i.style.display=`none`;let a=h(`div`,{class:`an-size-popover-title`});i.appendChild(a);let o=h(`div`,{class:`an-context-color-palette`});ji.forEach(e=>{let n=h(`div`,{class:`an-context-color-swatch`,title:e});n.style.background=e,this._disposers.push(v(n,`click`,n=>{n.stopPropagation(),t(e)})),o.appendChild(n)}),i.appendChild(o);let s=h(`div`,{class:`an-context-color-custom`}),c=h(`button`,{type:`button`,class:`an-shade-no-color`});this._disposers.push(v(c,`click`,()=>t(``))),s.appendChild(c),i.appendChild(s);let l=h(`div`,{class:`an-context-color-custom`}),u=h(`input`,{type:`color`,class:`an-shade-color-input`,value:e}),d=h(`span`);return d.textContent=this.context.locale.contextMenu.customColorLabel,this._disposers.push(v(u,`change`,()=>t(u.value))),l.appendChild(u),l.appendChild(d),i.appendChild(l),this._disposers.push(v(i,`mousedown`,e=>e.preventDefault()),v(i,`mouseenter`,()=>this._clearTimers()),v(i,`mouseleave`,()=>this._scheduleHide()),v(document,`click`,e=>{let t=e.target,i=n();i&&i.style.display!==`none`&&!i.contains(t)&&!this._el?.contains(t)&&r()})),{el:i,titleEl:a,noColorBtn:c}}_showColorPopover(e){let t=e();t&&(t.style.display=`block`,requestAnimationFrame(()=>{let t=e();if(!t||!this._el)return;let n=t.offsetWidth||170,r=t.offsetHeight||120,i=this._el.getBoundingClientRect(),a=i.left,o=i.bottom+6;a+n>globalThis.innerWidth-8&&(a=globalThis.innerWidth-n-8),o+r>globalThis.innerHeight-8&&(o=i.top-r-6),t.style.left=`${Math.max(8,a)}px`,t.style.top=`${Math.max(8,o)}px`}))}_buildCellShadePopover(){let{el:e,titleEl:t,noColorBtn:n}=this._buildColorPopover({defaultColor:`#ffffff`,apply:e=>this._applyCellShade(e),getPopover:()=>this._shadePopover,hide:()=>this._hideCellShadePopover()});return this._shadeTitleEl=t,this._shadeNoBtn=n,e}_openCellShadePopover(){if(!this._shadePopover)return;let e=this.context.locale.tooltips.table;this._shadeTitleEl&&(this._shadeTitleEl.textContent=e.cellBackground),this._shadeNoBtn&&(this._shadeNoBtn.textContent=e.noShading),this._showColorPopover(()=>this._shadePopover)}_hideCellShadePopover(){this._shadePopover&&(this._shadePopover.style.display=`none`)}_applyCellShade(e){(this._selectMode?this._selectedCells:[this._getCell()]).forEach(t=>{t&&(t.style.backgroundColor=e)}),this._shadeColorStrip&&(this._shadeColorStrip.style.background=e||`transparent`),this._hideCellShadePopover(),this.context.invoke(`editor.afterCommand`)}_buildBorderColorPopover(){let{el:e,titleEl:t,noColorBtn:n}=this._buildColorPopover({defaultColor:`#000000`,apply:e=>this._applyBorderColor(e),getPopover:()=>this._borderColorPopover,hide:()=>this._hideBorderColorPopover()});return this._borderColorTitleEl=t,this._borderColorNoBtn=n,e}_openBorderColorPopover(){if(!this._borderColorPopover)return;let e=this.context.locale.tooltips.table;this._borderColorTitleEl&&(this._borderColorTitleEl.textContent=e.tableBorderColor),this._borderColorNoBtn&&(this._borderColorNoBtn.textContent=e.noBorderColor),this._showColorPopover(()=>this._borderColorPopover)}_hideBorderColorPopover(){this._borderColorPopover&&(this._borderColorPopover.style.display=`none`)}_applyBorderColor(e){let t=this._activeTable;t&&(Array.from(t.querySelectorAll(`td, th`)).forEach(t=>{t.style.borderColor=e}),this._borderColorStrip&&(this._borderColorStrip.style.background=e||`transparent`),this._hideBorderColorPopover(),this.context.invoke(`editor.afterCommand`))}_syncBorderColorStrip(){if(!this._borderColorStrip||!this._el||this._el.style.display===`none`)return;let e=this._activeTable?.querySelector(`td, th`);this._borderColorStrip.style.background=e?.style.borderColor||`transparent`}_applyCellAlign(e){this._getSelectedCells().forEach(t=>{t&&(t.style.textAlign=e)}),this.context.invoke(`editor.afterCommand`)}_toggleHeaderRow(){let e=this._activeTable;if(!e)return;let t=e.querySelector(`tr`);if(t){if(t.closest(`thead`)!==null){let n=e.querySelector(`tbody`);n||(n=document.createElement(`tbody`),e.appendChild(n)),Array.from(t.cells).forEach(e=>{let n=document.createElement(`td`);n.innerHTML=e.innerHTML,n.style.cssText=e.style.cssText,t.replaceChild(n,e)}),n.insertBefore(t,n.firstChild);let r=e.querySelector(`thead`);r&&r.rows.length===0&&r.remove()}else{let n=e.querySelector(`thead`);n||(n=document.createElement(`thead`),e.insertBefore(n,e.firstChild)),Array.from(t.cells).forEach(e=>{let n=document.createElement(`th`);n.innerHTML=e.innerHTML,n.style.cssText=e.style.cssText,t.replaceChild(n,e)}),n.appendChild(t)}this.context.invoke(`editor.afterCommand`)}}_sortColumn(e){let t=this._activeTable;if(!t)return;let n=this._getCell();if(!n)return;let r=Ei(n);if(r===-1)return;let i=t.querySelector(`tbody`)||t,a=Array.from(i.querySelectorAll(`:scope > tr`));a.length<2||(a.sort((t,n)=>{let i=Y(t,r),a=Y(n,r),o=(i?.textContent||``).trim(),s=(a?.textContent||``).trim(),c=parseFloat(o),l=parseFloat(s);return!isNaN(c)&&!isNaN(l)?e===`asc`?c-l:l-c:e===`asc`?o.localeCompare(s):s.localeCompare(o)}),a.forEach(e=>i.appendChild(e)),this._markSortIndicator(t,r,e),this.context.invoke(`editor.afterCommand`))}_markSortIndicator(e,t,n){let r=e.querySelector(`thead`);if(!r)return;r.querySelectorAll(`.an-sort-asc, .an-sort-desc`).forEach(e=>{e.classList.remove(`an-sort-asc`,`an-sort-desc`)});let i=r.querySelector(`tr`);if(!i)return;let a=Y(i,t);a&&a.classList.add(n===`asc`?`an-sort-asc`:`an-sort-desc`)}_exportTableCSV(){let e=this._activeTable;if(!e)return;let t=Array.from(e.querySelectorAll(`tr`)).map(e=>Array.from(e.querySelectorAll(`td, th`)).map(e=>`"${(e.textContent||``).trim().replace(/"/g,`""`)}"`).join(`,`)).join(`
42
- `),n=new Blob([``+t],{type:`text/csv;charset=utf-8;`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`table.csv`,i.style.display=`none`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}};function Ni(e,t={}){t.cspNonce&&(e.nonce=t.cspNonce);let n=t.externalAssetCrossOrigin??`anonymous`,r=t.externalAssetReferrerPolicy??`no-referrer`;return n&&(e.crossOrigin=n),r&&(e.referrerPolicy=r),e}var Pi=100,Fi=180,Ii=/language-(\S+)/,Li={copy:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`,wrapOn:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><path d="M3 12h15a3 3 0 0 1 0 6H3"/><polyline points="6 15 3 18 6 21"/></svg>`,toParagraph:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 4v16"/><path d="M17 4v16"/><path d="M9 4h8a4 4 0 0 1 0 8H9V4z"/></svg>`,deleteCode:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,lineNumbers:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-2-2-2"/></svg>`},Ri=[[``,`Plain text`],[`javascript`,`JavaScript`],[`typescript`,`TypeScript`],[`python`,`Python`],[`html`,`HTML`],[`css`,`CSS`],[`scss`,`SCSS`],[`json`,`JSON`],[`yaml`,`YAML`],[`markdown`,`Markdown`],[`xml`,`XML`],[`bash`,`Bash / Shell`],[`sql`,`SQL`],[`java`,`Java`],[`csharp`,`C#`],[`php`,`PHP`],[`ruby`,`Ruby`],[`go`,`Go`],[`rust`,`Rust`],[`cpp`,`C++`],[`c`,`C`],[`kotlin`,`Kotlin`],[`swift`,`Swift`]];function zi(e,t){[...e.classList].forEach(t=>{t.startsWith(`language-`)&&e.classList.remove(t)}),t&&e.classList.add(`language-${t}`)}var Bi=class{constructor(e){this.context=e,this._el=null,this._activePre=null,this._showTimer=null,this._hideTimer=null,this._disposers=[],this._copyBtn=null,this._wrapBtn=null,this._lineNumbersBtn=null,this._langSelect=null,this._prismScript=null,this._asyncDisposers=[]}initialize(){this._el=this._buildTooltip(),x(this.context).appendChild(this._el),this._ensurePrism();let e=this.context.layoutInfo.editable;return this._disposers.push(v(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`pre`);n&&e.contains(n)&&this._scheduleShow(n)}),v(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()}),v(document,`click`,e=>{let t=e.target;this._activePre&&!this._activePre.contains(t)&&!this._el.contains(t)&&this._hide()})),this}destroy(){this._clearTimers(),this._asyncDisposers.forEach(e=>e()),this._asyncDisposers=[],this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.code,t=h(`div`,{class:`an-link-tooltip an-code-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=h(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(this._sep()),this._langSelect=h(`select`,{class:`an-code-lang-select`,title:e.syntaxLanguage,"aria-label":e.syntaxAriaLabel}),Ri.forEach(([e,t])=>{let n=h(`option`,{value:e});n.textContent=t,this._langSelect.appendChild(n)}),this._disposers.push(v(this._langSelect,`change`,()=>this._onLangChange())),t.appendChild(this._langSelect),t.appendChild(this._sep()),this._copyBtn=this._makeBtn(Li.copy,e.copyCode,()=>this._copyCode()),t.appendChild(this._copyBtn),t.appendChild(this._sep()),this._wrapBtn=this._makeBtn(Li.wrapOn,e.toggleWordWrap,()=>this._toggleWrap()),t.appendChild(this._wrapBtn),this._lineNumbersBtn=this._makeBtn(Li.lineNumbers,e.lineNumbers,()=>this._toggleLineNumbers()),t.appendChild(this._lineNumbersBtn),t.appendChild(this._sep()),t.appendChild(this._makeBtn(Li.toParagraph,e.convertToParagraph,()=>this._toParagraph())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(Li.deleteCode,e.deleteCodeBlock,()=>this._delete(),!0)),this._disposers.push(v(t,`mouseenter`,()=>this._clearTimers()),v(t,`mouseleave`,()=>this._scheduleHide())),t}_sep(){return h(`div`,{class:`an-link-tooltip-sep`})}_makeBtn(e,t,n,r=!1){let i=h(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(v(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){(this._activePre!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._activePre=e,this._syncWrapBtn(),this._syncLineNumbersBtn(),this._syncLangSelect(),this._show(e)},Pi))}_scheduleHide(){clearTimeout(this._showTimer),this._showTimer=null,clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>this._hide(),Fi)}_show(e){this._el.style.display=`flex`,this._positionNear(e)}_hide(){this._el.style.display=`none`,this._activePre=null,this._clearTimers()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){let t=e.getBoundingClientRect(),n=this._el.offsetWidth||260,r=this._el.offsetHeight||32,i=t.top-r-6,a=t.left+(t.width-n)/2;i<6&&(i=t.bottom+6),a+n>globalThis.innerWidth-6&&(a=globalThis.innerWidth-n-6),a<6&&(a=6),this._el.style.top=`${i}px`,this._el.style.left=`${a}px`}_syncWrapBtn(){if(!this._activePre||!this._wrapBtn)return;let e=(this._activePre.style.whiteSpace||``).includes(`pre-wrap`)||globalThis.getComputedStyle(this._activePre).whiteSpace===`pre-wrap`;this._wrapBtn.classList.toggle(`active`,e),this._wrapBtn.title=e?this.context.locale.tooltips.code.disableWordWrap:this.context.locale.tooltips.code.enableWordWrap}_syncLineNumbersBtn(){if(!this._activePre||!this._lineNumbersBtn)return;let e=this._activePre.classList.contains(`an-code-line-numbers`);this._lineNumbersBtn.classList.toggle(`active`,e),this._lineNumbersBtn.title=this.context.locale.tooltips.code.lineNumbers}_syncLangSelect(){if(!this._activePre||!this._langSelect)return;let e=this._activePre.querySelector(`code`),t=this._activePre.dataset.language||``,n=e&&(Ii.exec(e.className)||[])[1]||``;this._langSelect.value=t||n||``}_copyCode(){let e=this._activePre;if(!e)return;let t=e.textContent||``;if(navigator.clipboard)navigator.clipboard.writeText(t).then(()=>this._flashCopied()).catch(()=>{});else{let e=document.createElement(`textarea`);e.value=t,e.style.cssText=`position:fixed;opacity:0;top:0;left:0`,document.body.appendChild(e),e.select();try{document.execCommand(`copy`),this._flashCopied()}catch{}e.remove()}}_flashCopied(){if(!this._copyBtn)return;let e=this._copyBtn.innerHTML;this._copyBtn.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`,this._copyBtn.classList.add(`an-link-tooltip-btn--copied`),setTimeout(()=>{this._copyBtn&&(this._copyBtn.innerHTML=e,this._copyBtn.classList.remove(`an-link-tooltip-btn--copied`))},1400)}_toggleWrap(){let e=this._activePre;if(!e)return;let t=e.style.whiteSpace===`pre-wrap`;e.style.whiteSpace=t?`pre`:`pre-wrap`,this._syncWrapBtn(),this.context.invoke(`editor.afterCommand`),this._positionNear(e)}_toggleLineNumbers(){let e=this._activePre;e&&(e.classList.toggle(`an-code-line-numbers`),this._syncLineNumbersBtn(),this.context.invoke(`editor.afterCommand`))}applyLanguage(e,t){if(!e||!t)return;let n=this._activePre;this._activePre=e,this._langSelect&&(this._langSelect.value=t),this._onLangChange(),this._langSelect&&(this._langSelect.value=t),this._activePre=n||e}_onLangChange(){let e=this._activePre;if(!e)return;let t=this._langSelect.value,n=globalThis,r=e.querySelector(`code`);r||(r=document.createElement(`code`),r.innerHTML=e.innerHTML,e.innerHTML=``,e.appendChild(r)),zi(r,t),zi(e,t),t?e.dataset.language=t:delete e.dataset.language;let i=()=>{!this.context._alive||!r.isConnected||!n.Prism||(r.querySelectorAll(`br`).forEach(e=>e.replaceWith(`
43
- `)),n.Prism.highlightElement(r),this.context.invoke(`editor.afterCommand`))};if(t){if(n.Prism!==void 0){if(n.Prism.languages[t]){i();return}this._loadPrismComponent(t,i);return}if(this._prismScript){this._onScriptLoad(this._prismScript,()=>{n.Prism.languages[t]?i():this._loadPrismComponent(t,i)});return}}this.context.invoke(`editor.afterCommand`)}_cdnBase(){return String(this.context.options.codeHighlightCDN??``).replace(/\/+$/,``)}_ensurePrism(){let e=globalThis;if(!this.context.options.codeHighlight||e.Prism)return;let t=this._cdnBase(),n=`${t}/themes/prism-tomorrow.min.css`,r=`${t}/prism.min.js`;if(!document.querySelector(`link[href="${n}"]`)){let e=document.createElement(`link`);e.rel=`stylesheet`,e.href=n,Ni(e,this.context.options),document.head.appendChild(e)}let i=document.querySelector(`script[src="${r}"]`);if(i){this._prismScript=e.Prism?null:i;return}let a=document.createElement(`script`);a.dataset.manual=``,a.src=r,Ni(a,this.context.options),this._prismScript=a,this._onScriptLoad(a,()=>{this._prismScript=null}),document.head.appendChild(a)}_onScriptLoad(e,t){let n=()=>{this.context._alive&&t()};e.addEventListener(`load`,n,{once:!0}),this._asyncDisposers.push(()=>e.removeEventListener(`load`,n))}_loadPrismComponent(e,t){let n=globalThis,r=`${this._cdnBase()}/components/prism-${e}.min.js`;if(document.querySelector(`script[src="${r}"]`)){let r=setInterval(()=>{if(!this.context._alive){clearInterval(r);return}n.Prism?.languages[e]&&(clearInterval(r),t())},50),i=setTimeout(()=>clearInterval(r),3e3);this._asyncDisposers.push(()=>{clearInterval(r),clearTimeout(i)});return}let i=document.createElement(`script`);i.src=r,Ni(i,this.context.options),this._onScriptLoad(i,t),document.head.appendChild(i)}_toParagraph(){let e=this._activePre;if(!e||!this.context.layoutInfo.editable)return;let t=(e.textContent||``).split(`
44
- `),n=document.createElement(`p`);t.forEach((e,t)=>{t>0&&n.appendChild(document.createElement(`br`)),n.appendChild(document.createTextNode(e))}),e.parentNode.replaceChild(n,e),this._hide(),this.context.invoke(`editor.afterCommand`)}_delete(){let e=this._activePre;e&&(this._hide(),e.remove(),this.context.invoke(`editor.afterCommand`))}},Vi=n({EMOJI_CATS:()=>Hi,EMOJI_LIST:()=>Ui}),Hi,Ui,Wi=t((()=>{Hi=[{id:`smileys`,label:`Smileys`},{id:`people`,label:`People`},{id:`animals`,label:`Animals`},{id:`food`,label:`Food`},{id:`travel`,label:`Travel`},{id:`objects`,label:`Objects`},{id:`symbols`,label:`Symbols`}],Ui=[[`😀`,`grin smile happy face`,`smileys`],[`😃`,`happy smile big eyes`,`smileys`],[`😄`,`grinning smile laugh`,`smileys`],[`😁`,`beaming smile grin`,`smileys`],[`😆`,`laughing lol`,`smileys`],[`😅`,`sweat grin awkward`,`smileys`],[`🤣`,`rolling laugh rofl`,`smileys`],[`😂`,`tears laugh cry joy`,`smileys`],[`🙂`,`slight smile`,`smileys`],[`🙃`,`upside down smile`,`smileys`],[`😉`,`wink`,`smileys`],[`😊`,`blush smile happy`,`smileys`],[`😇`,`innocent halo angel`,`smileys`],[`🥰`,`hearts love adore`,`smileys`],[`😍`,`heart eyes love`,`smileys`],[`🤩`,`star eyes excited wow`,`smileys`],[`😘`,`kiss blow love`,`smileys`],[`😋`,`yum delicious tongue`,`smileys`],[`😛`,`tongue stuck out`,`smileys`],[`😜`,`wink tongue crazy`,`smileys`],[`🤪`,`zany crazy wild`,`smileys`],[`😝`,`squint tongue`,`smileys`],[`🤑`,`money mouth`,`smileys`],[`🤗`,`hugging hug`,`smileys`],[`🤔`,`thinking hmm`,`smileys`],[`🤨`,`raised eyebrow`,`smileys`],[`😐`,`neutral face`,`smileys`],[`😶`,`no mouth`,`smileys`],[`😏`,`smirk`,`smileys`],[`😒`,`unamused`,`smileys`],[`🙄`,`roll eyes`,`smileys`],[`😬`,`grimace`,`smileys`],[`😔`,`pensive sad`,`smileys`],[`😪`,`sleepy tired`,`smileys`],[`😴`,`sleeping zzz`,`smileys`],[`🤤`,`drool`,`smileys`],[`😷`,`mask sick`,`smileys`],[`🤒`,`sick thermometer`,`smileys`],[`🤕`,`hurt bandage`,`smileys`],[`🤢`,`nausea sick`,`smileys`],[`🤮`,`vomit sick`,`smileys`],[`🤧`,`sneeze cold`,`smileys`],[`🥵`,`hot sweat`,`smileys`],[`🥶`,`cold freeze`,`smileys`],[`😵`,`dizzy dead`,`smileys`],[`🤯`,`mind blown`,`smileys`],[`🤠`,`cowboy hat`,`smileys`],[`🥳`,`party celebrate`,`smileys`],[`😎`,`cool sunglasses`,`smileys`],[`🤓`,`nerd glasses`,`smileys`],[`🧐`,`monocle curious`,`smileys`],[`😕`,`confused`,`smileys`],[`😟`,`worried`,`smileys`],[`🙁`,`frown sad`,`smileys`],[`☹️`,`sad frown`,`smileys`],[`😮`,`surprised open mouth`,`smileys`],[`😲`,`astonished`,`smileys`],[`🥺`,`pleading begging puppy eyes`,`smileys`],[`😢`,`cry sad tear`,`smileys`],[`😭`,`sob cry loudly`,`smileys`],[`😱`,`scream horror fear`,`smileys`],[`😡`,`angry red pouting`,`smileys`],[`😠`,`angry mad`,`smileys`],[`🤬`,`cursing swear`,`smileys`],[`😈`,`devil evil smile`,`smileys`],[`👿`,`devil angry evil`,`smileys`],[`💀`,`skull death`,`smileys`],[`☠️`,`skull crossbones`,`smileys`],[`💩`,`poop`,`smileys`],[`🤡`,`clown`,`smileys`],[`👻`,`ghost boo`,`smileys`],[`👽`,`alien ufo`,`smileys`],[`🤖`,`robot`,`smileys`],[`👋`,`wave hello hi hand`,`people`],[`🤚`,`raised back hand`,`people`],[`✋`,`raised hand stop`,`people`],[`🖖`,`vulcan salute spock`,`people`],[`👌`,`ok perfect fine`,`people`],[`✌️`,`peace victory fingers`,`people`],[`🤞`,`fingers crossed luck`,`people`],[`🤟`,`love you gesture`,`people`],[`🤘`,`sign of horns rock`,`people`],[`🤙`,`call me hand`,`people`],[`👈`,`point left`,`people`],[`👉`,`point right`,`people`],[`👆`,`point up`,`people`],[`👇`,`point down`,`people`],[`☝️`,`index pointing up`,`people`],[`👍`,`thumbs up like good`,`people`],[`👎`,`thumbs down dislike bad`,`people`],[`✊`,`raised fist punch`,`people`],[`👊`,`oncoming fist punch`,`people`],[`👏`,`clap applause`,`people`],[`🙌`,`celebrate raise hands`,`people`],[`🤝`,`handshake deal`,`people`],[`🙏`,`pray hope please thanks`,`people`],[`💅`,`nail polish`,`people`],[`💪`,`flexed bicep strong muscle`,`people`],[`👀`,`eyes look see`,`people`],[`👁️`,`eye`,`people`],[`👅`,`tongue`,`people`],[`👶`,`baby`,`people`],[`🧒`,`child`,`people`],[`👦`,`boy`,`people`],[`👧`,`girl`,`people`],[`🧑`,`person adult`,`people`],[`👨`,`man`,`people`],[`👩`,`woman`,`people`],[`🧔`,`beard man`,`people`],[`🧓`,`older person`,`people`],[`👴`,`old man`,`people`],[`👵`,`old woman`,`people`],[`❤️`,`heart love red`,`people`],[`🧡`,`orange heart love`,`people`],[`💛`,`yellow heart love`,`people`],[`💚`,`green heart love`,`people`],[`💙`,`blue heart love`,`people`],[`💜`,`purple heart love`,`people`],[`🖤`,`black heart`,`people`],[`🤍`,`white heart`,`people`],[`🤎`,`brown heart`,`people`],[`💔`,`broken heart`,`people`],[`❣️`,`exclamation heart`,`people`],[`💕`,`two hearts love`,`people`],[`💞`,`revolving hearts`,`people`],[`💓`,`beating heart`,`people`],[`💗`,`growing heart`,`people`],[`💖`,`sparkling heart`,`people`],[`💘`,`heart arrow`,`people`],[`💝`,`heart ribbon`,`people`],[`💬`,`speech bubble comment chat`,`people`],[`💭`,`thought bubble`,`people`],[`💯`,`100 hundred percent perfect`,`people`],[`💢`,`anger symbol mad`,`people`],[`💤`,`zzz sleep`,`people`],[`🐶`,`dog puppy`,`animals`],[`🐱`,`cat kitten`,`animals`],[`🐭`,`mouse`,`animals`],[`🐹`,`hamster`,`animals`],[`🐰`,`rabbit bunny`,`animals`],[`🦊`,`fox`,`animals`],[`🐻`,`bear`,`animals`],[`🐼`,`panda`,`animals`],[`🐨`,`koala`,`animals`],[`🐯`,`tiger`,`animals`],[`🦁`,`lion`,`animals`],[`🐮`,`cow`,`animals`],[`🐷`,`pig`,`animals`],[`🐸`,`frog`,`animals`],[`🐵`,`monkey`,`animals`],[`🙈`,`see no evil monkey`,`animals`],[`🙉`,`hear no evil monkey`,`animals`],[`🙊`,`speak no evil monkey`,`animals`],[`🐔`,`chicken hen`,`animals`],[`🐧`,`penguin`,`animals`],[`🐦`,`bird`,`animals`],[`🦆`,`duck`,`animals`],[`🦅`,`eagle`,`animals`],[`🦉`,`owl`,`animals`],[`🦇`,`bat`,`animals`],[`🐺`,`wolf`,`animals`],[`🐴`,`horse`,`animals`],[`🦄`,`unicorn`,`animals`],[`🐝`,`bee`,`animals`],[`🦋`,`butterfly`,`animals`],[`🐌`,`snail`,`animals`],[`🐞`,`ladybug`,`animals`],[`🐢`,`turtle`,`animals`],[`🐍`,`snake`,`animals`],[`🦎`,`lizard`,`animals`],[`🐊`,`crocodile`,`animals`],[`🐟`,`fish`,`animals`],[`🐠`,`tropical fish`,`animals`],[`🦈`,`shark`,`animals`],[`🐬`,`dolphin`,`animals`],[`🐳`,`whale`,`animals`],[`🐙`,`octopus`,`animals`],[`🦑`,`squid`,`animals`],[`🦀`,`crab`,`animals`],[`🌸`,`cherry blossom flower`,`animals`],[`🌺`,`hibiscus flower`,`animals`],[`🌻`,`sunflower`,`animals`],[`🌹`,`rose flower`,`animals`],[`🌷`,`tulip flower`,`animals`],[`🍀`,`four leaf clover luck`,`animals`],[`🌿`,`herb leaf green`,`animals`],[`🌱`,`seedling sprout`,`animals`],[`🌲`,`evergreen tree pine`,`animals`],[`🌳`,`deciduous tree`,`animals`],[`🌴`,`palm tree`,`animals`],[`🍄`,`mushroom`,`animals`],[`🌾`,`sheaf wheat`,`animals`],[`🐾`,`paw prints animal`,`animals`],[`🍎`,`apple red`,`food`],[`🍊`,`orange tangerine`,`food`],[`🍋`,`lemon yellow`,`food`],[`🍇`,`grapes`,`food`],[`🍓`,`strawberry`,`food`],[`🫐`,`blueberry`,`food`],[`🍒`,`cherry`,`food`],[`🍑`,`peach`,`food`],[`🥭`,`mango`,`food`],[`🍍`,`pineapple`,`food`],[`🥥`,`coconut`,`food`],[`🥝`,`kiwi`,`food`],[`🍅`,`tomato`,`food`],[`🥑`,`avocado`,`food`],[`🍆`,`eggplant aubergine`,`food`],[`🥕`,`carrot`,`food`],[`🌽`,`corn`,`food`],[`🥦`,`broccoli`,`food`],[`🥬`,`leafy green`,`food`],[`🧄`,`garlic`,`food`],[`🥜`,`peanut nut`,`food`],[`🍞`,`bread loaf`,`food`],[`🥐`,`croissant`,`food`],[`🧀`,`cheese`,`food`],[`🍳`,`egg fry cooking`,`food`],[`🥚`,`egg`,`food`],[`🥞`,`pancake`,`food`],[`🧇`,`waffle`,`food`],[`🥓`,`bacon`,`food`],[`🥩`,`meat steak`,`food`],[`🍗`,`chicken leg`,`food`],[`🌭`,`hotdog`,`food`],[`🍔`,`burger hamburger`,`food`],[`🍟`,`fries french`,`food`],[`🍕`,`pizza`,`food`],[`🌮`,`taco`,`food`],[`🌯`,`burrito wrap`,`food`],[`🍜`,`noodles ramen`,`food`],[`🍝`,`spaghetti pasta`,`food`],[`🍣`,`sushi`,`food`],[`🍱`,`bento box`,`food`],[`🍦`,`ice cream soft serve`,`food`],[`🍩`,`donut`,`food`],[`🍪`,`cookie`,`food`],[`🎂`,`birthday cake`,`food`],[`🍰`,`cake slice`,`food`],[`🧁`,`cupcake`,`food`],[`🍫`,`chocolate`,`food`],[`🍬`,`candy`,`food`],[`🍭`,`lollipop`,`food`],[`☕`,`coffee hot`,`food`],[`🍵`,`tea hot`,`food`],[`🧋`,`bubble tea boba`,`food`],[`🥤`,`cup straw drink`,`food`],[`🍷`,`wine red`,`food`],[`🍸`,`cocktail martini`,`food`],[`🍺`,`beer mug`,`food`],[`🍻`,`clinking beer mugs`,`food`],[`🥂`,`champagne toast celebrate`,`food`],[`🧃`,`juice box`,`food`],[`🧊`,`ice cube`,`food`],[`🚀`,`rocket space`,`travel`],[`🛸`,`ufo flying saucer`,`travel`],[`✈️`,`airplane plane fly`,`travel`],[`🚁`,`helicopter`,`travel`],[`🚂`,`train locomotive`,`travel`],[`🚄`,`bullet train fast`,`travel`],[`🚇`,`subway metro`,`travel`],[`🚌`,`bus`,`travel`],[`🚑`,`ambulance`,`travel`],[`🚒`,`fire truck`,`travel`],[`🚓`,`police car`,`travel`],[`🚕`,`taxi cab`,`travel`],[`🚗`,`car automobile red`,`travel`],[`🚙`,`suv car`,`travel`],[`🚚`,`truck delivery`,`travel`],[`🚜`,`tractor farm`,`travel`],[`🏎️`,`racing car fast`,`travel`],[`🏍️`,`motorcycle`,`travel`],[`🚲`,`bicycle bike`,`travel`],[`🛴`,`scooter kick`,`travel`],[`⛵`,`sailboat boat`,`travel`],[`🚢`,`ship cruise`,`travel`],[`🏠`,`house home`,`travel`],[`🏢`,`office building`,`travel`],[`🏥`,`hospital`,`travel`],[`🏦`,`bank`,`travel`],[`🏪`,`store shop convenience`,`travel`],[`🏫`,`school`,`travel`],[`🏰`,`castle european`,`travel`],[`🏯`,`japanese castle`,`travel`],[`🗼`,`tokyo tower`,`travel`],[`🗽`,`statue liberty new york`,`travel`],[`⛪`,`church`,`travel`],[`🕌`,`mosque`,`travel`],[`⛩️`,`shinto shrine`,`travel`],[`⛲`,`fountain`,`travel`],[`⛺`,`tent camping`,`travel`],[`🌁`,`fog foggy bridge`,`travel`],[`🌃`,`night city stars`,`travel`],[`🏙️`,`cityscape city buildings`,`travel`],[`🌅`,`sunrise morning`,`travel`],[`🌈`,`rainbow colorful`,`travel`],[`⛰️`,`mountain`,`travel`],[`🏔️`,`snow mountain`,`travel`],[`🗻`,`mount fuji`,`travel`],[`🏕️`,`camping tent`,`travel`],[`🗺️`,`world map`,`travel`],[`🧭`,`compass navigation`,`travel`],[`🌍`,`earth europe africa globe`,`travel`],[`🌎`,`earth americas globe`,`travel`],[`🌏`,`earth asia globe`,`travel`],[`🌐`,`globe internet web`,`travel`],[`💎`,`diamond gem jewel`,`objects`],[`💍`,`ring engagement`,`objects`],[`👑`,`crown royal king queen`,`objects`],[`🎩`,`top hat magic`,`objects`],[`💼`,`briefcase work business`,`objects`],[`👜`,`handbag purse`,`objects`],[`🎒`,`backpack bag school`,`objects`],[`👓`,`glasses eyewear`,`objects`],[`🕶️`,`sunglasses cool`,`objects`],[`💡`,`light bulb idea`,`objects`],[`🔦`,`flashlight torch`,`objects`],[`🕯️`,`candle light`,`objects`],[`🔋`,`battery charge`,`objects`],[`💻`,`laptop computer`,`objects`],[`🖥️`,`desktop monitor computer`,`objects`],[`📱`,`phone mobile cell`,`objects`],[`⌨️`,`keyboard type`,`objects`],[`🖱️`,`mouse computer click`,`objects`],[`📺`,`television tv`,`objects`],[`📷`,`camera photo`,`objects`],[`📹`,`video camera`,`objects`],[`🎥`,`movie camera film`,`objects`],[`☎️`,`telephone phone`,`objects`],[`⏰`,`alarm clock wake`,`objects`],[`⌚`,`watch time`,`objects`],[`🔑`,`key`,`objects`],[`🗝️`,`old key`,`objects`],[`🔒`,`lock closed`,`objects`],[`🔓`,`unlock open`,`objects`],[`🔨`,`hammer tool`,`objects`],[`🔧`,`wrench tool`,`objects`],[`🔩`,`bolt nut`,`objects`],[`⚙️`,`gear setting`,`objects`],[`🧲`,`magnet attract`,`objects`],[`📚`,`books stack library`,`objects`],[`📖`,`book open read`,`objects`],[`📝`,`memo write note`,`objects`],[`✏️`,`pencil write edit`,`objects`],[`📌`,`pushpin tack`,`objects`],[`📎`,`paperclip attach`,`objects`],[`📊`,`bar chart graph`,`objects`],[`📈`,`chart up growth trend`,`objects`],[`📉`,`chart down loss decline`,`objects`],[`📅`,`calendar date`,`objects`],[`📦`,`package box`,`objects`],[`📫`,`mailbox closed`,`objects`],[`📧`,`email envelope`,`objects`],[`🎁`,`gift present`,`objects`],[`🎀`,`ribbon bow`,`objects`],[`🎉`,`party celebrate confetti`,`objects`],[`🎊`,`confetti celebrate`,`objects`],[`🔮`,`crystal ball magic fortune`,`objects`],[`🪄`,`magic wand`,`objects`],[`🎯`,`target bullseye dart`,`objects`],[`🎲`,`dice game board`,`objects`],[`🎮`,`video game controller`,`objects`],[`🎭`,`theater masks drama`,`objects`],[`🎨`,`art palette paint`,`objects`],[`🎬`,`clapper film movie`,`objects`],[`🎤`,`microphone sing karaoke`,`objects`],[`🎧`,`headphones music listen`,`objects`],[`🎵`,`music note`,`objects`],[`🎶`,`music notes`,`objects`],[`🎸`,`guitar electric`,`objects`],[`🎹`,`piano keyboard music`,`objects`],[`🥁`,`drum percussion`,`objects`],[`🎷`,`saxophone jazz`,`objects`],[`🎺`,`trumpet`,`objects`],[`🎻`,`violin`,`objects`],[`⚽`,`soccer ball football`,`objects`],[`🏀`,`basketball`,`objects`],[`🏈`,`american football`,`objects`],[`⚾`,`baseball`,`objects`],[`🎾`,`tennis`,`objects`],[`🏐`,`volleyball`,`objects`],[`🏆`,`trophy winner award`,`objects`],[`🥇`,`gold medal first`,`objects`],[`🏅`,`sports medal`,`objects`],[`✅`,`check green done success`,`symbols`],[`❌`,`cross x no cancel`,`symbols`],[`⭕`,`circle red`,`symbols`],[`⛔`,`no entry stop`,`symbols`],[`🚫`,`prohibited no banned`,`symbols`],[`⚠️`,`warning caution danger`,`symbols`],[`❗`,`exclamation red important`,`symbols`],[`❓`,`question mark`,`symbols`],[`‼️`,`double exclamation`,`symbols`],[`💯`,`100 hundred percent perfect`,`symbols`],[`🔴`,`red circle dot`,`symbols`],[`🟠`,`orange circle`,`symbols`],[`🟡`,`yellow circle`,`symbols`],[`🟢`,`green circle`,`symbols`],[`🔵`,`blue circle`,`symbols`],[`🟣`,`purple circle`,`symbols`],[`⚫`,`black circle`,`symbols`],[`⚪`,`white circle`,`symbols`],[`🟤`,`brown circle`,`symbols`],[`🔺`,`red triangle up`,`symbols`],[`🔻`,`red triangle down`,`symbols`],[`🔷`,`blue diamond large`,`symbols`],[`🔶`,`orange diamond large`,`symbols`],[`🔹`,`blue diamond small`,`symbols`],[`🔸`,`orange diamond small`,`symbols`],[`⭐`,`star yellow`,`symbols`],[`🌟`,`glowing star shine`,`symbols`],[`✨`,`sparkles shine`,`symbols`],[`💫`,`dizzy star spin`,`symbols`],[`⚡`,`lightning bolt energy power`,`symbols`],[`🔥`,`fire hot flame`,`symbols`],[`💥`,`explosion boom`,`symbols`],[`❄️`,`snowflake cold ice winter`,`symbols`],[`🌊`,`wave water ocean sea`,`symbols`],[`💨`,`wind blow dash`,`symbols`],[`🌀`,`cyclone tornado spiral`,`symbols`],[`♻️`,`recycle loop green`,`symbols`],[`✔️`,`check tick done`,`symbols`],[`➕`,`plus add`,`symbols`],[`➖`,`minus subtract`,`symbols`],[`➗`,`divide division`,`symbols`],[`✖️`,`multiply times cross`,`symbols`],[`▶️`,`play button right`,`symbols`],[`⏸️`,`pause`,`symbols`],[`⏹️`,`stop square`,`symbols`],[`⏩`,`fast forward`,`symbols`],[`⏪`,`rewind fast backward`,`symbols`],[`🔔`,`bell notification`,`symbols`],[`🔕`,`bell slash mute`,`symbols`],[`🔊`,`speaker volume high`,`symbols`],[`🔇`,`mute silent no sound`,`symbols`],[`📢`,`loudspeaker announcement`,`symbols`],[`📣`,`megaphone cheer`,`symbols`],[`🏳️`,`white flag`,`symbols`],[`🏴`,`black flag`,`symbols`],[`🚩`,`red flag`,`symbols`],[`🏁`,`checkered flag finish race`,`symbols`],[`🆕`,`new badge`,`symbols`],[`🆓`,`free badge`,`symbols`],[`🆒`,`cool badge`,`symbols`],[`🔝`,`top arrow`,`symbols`],[`🔙`,`back arrow`,`symbols`],[`ℹ️`,`information info`,`symbols`],[`📍`,`pin location map`,`symbols`],[`🔗`,`link chain`,`symbols`],[`©️`,`copyright`,`symbols`],[`®️`,`registered trademark`,`symbols`],[`™️`,`trademark`,`symbols`],[`#️⃣`,`hash number`,`symbols`],[`0️⃣`,`zero number`,`symbols`],[`1️⃣`,`one number`,`symbols`],[`2️⃣`,`two number`,`symbols`],[`3️⃣`,`three number`,`symbols`],[`4️⃣`,`four number`,`symbols`],[`5️⃣`,`five number`,`symbols`]]})),Gi=null,Ki=null;function qi(){return Gi?Promise.resolve(Gi):(Ki??=Promise.resolve().then(()=>(Wi(),Vi)).then(e=>(Gi={EMOJI_CATS:e.EMOJI_CATS,EMOJI_LIST:e.EMOJI_LIST},Gi)),Ki)}var Ji=class extends G{_activeCat=`all`;initialize(){return this}async show(){if(this._saveRange(),!this._dialog){let{EMOJI_CATS:e,EMOJI_LIST:t}=await qi();this._dialog||(this._cats=e,this._list=t,this._dialog=this._buildDialog(),x(this.context).appendChild(this._dialog))}this._activeCat=`all`,this._searchInput.value=``,this._updateCatTabs(),this._filterEmojis(``,`all`),this._open()}_buildDialog(){let e=this.context.locale.emojiDialog,t=h(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e.ariaLabel}),n=h(`div`,{class:`an-dialog-box an-emoji-box`}),r=h(`div`,{class:`an-icon-title-row`}),i=h(`div`,{class:`an-dialog-title-group`}),a=h(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M8 13s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`;let o=h(`h3`,{class:`an-dialog-title`});o.textContent=e.title,i.append(a,o);let s=h(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close});s.innerHTML=`&times;`,r.append(i,s);let c=h(`input`,{type:`search`,class:`an-input an-icon-search`,placeholder:e.searchPlaceholder,autocomplete:`off`});this._searchInput=c;let l=h(`div`,{class:`an-icon-cats`}),u=h(`button`,{type:`button`,class:`an-icon-cat active`,"data-cat":`all`});u.textContent=e.all,l.appendChild(u),this._cats.forEach(({id:t,label:n})=>{let r=h(`button`,{type:`button`,class:`an-icon-cat`,"data-cat":t});r.textContent=e.categories?.[t]||n,l.appendChild(r)}),this._catBar=l;let d=h(`div`,{class:`an-emoji-grid`});this._list.forEach(([e,t,n])=>{let r=h(`button`,{type:`button`,class:`an-emoji-cell`,"data-char":e,"data-keywords":t,"data-cat":n,title:t.split(` `).slice(0,2).join(` `)});r.textContent=e,d.appendChild(r)}),this._grid=d,this._firstInput=c;let f=h(`div`,{class:`an-dialog-actions`}),p=h(`button`,{type:`button`,class:`an-btn`});p.textContent=e.cancelBtn,f.appendChild(p),n.append(r,c,l,d,f),t.appendChild(n),b(r,n);let m=v(s,`click`,()=>this._close()),g=v(p,`click`,()=>this._close()),_=v(t,`click`,e=>{e.target===t&&this._close()}),y=v(c,`input`,()=>this._filterEmojis(c.value,this._activeCat)),x=v(l,`click`,e=>{let t=e.target?.closest(`[data-cat]`);t&&(this._activeCat=t.dataset.cat,this._updateCatTabs(),this._filterEmojis(this._searchInput.value,this._activeCat))}),S=v(d,`click`,e=>{let t=e.target?.closest(`.an-emoji-cell`);t&&this._onEmojiClick(t.dataset.char)});return this._disposers.push(m,g,_,y,x,S),t}_updateCatTabs(){this._catBar.querySelectorAll(`.an-icon-cat`).forEach(e=>{e.classList.toggle(`active`,e.dataset.cat===this._activeCat)})}_filterEmojis(e,t){let n=(e||``).trim().toLowerCase(),r=0;this._grid.querySelectorAll(`.an-emoji-cell`).forEach(e=>{let i=e,a=!t||t===`all`||i.dataset.cat===t,o=!n||i.dataset.keywords.includes(n)||i.dataset.char===n,s=a&&o;i.style.display=s?``:`none`,s&&r++});let i=this._grid.querySelector(`.an-icon-empty`);i||(i=h(`div`,{class:`an-icon-empty`}),i.textContent=`No emojis found`,this._grid.appendChild(i)),i.style.display=r>0?`none`:``}_onEmojiClick(e){let t=this._savedRange,n=this.context.layoutInfo.editable;t&&t.select();let r=globalThis.getSelection(),i=r?.rangeCount>0?r.getRangeAt(0):null;i||(i=document.createRange(),i.selectNodeContents(n),i.collapse(!1));let a=i.startContainer,o=(a.nodeType===1?a:a.parentElement)?.closest(`td, th`);i.deleteContents(),o?.isConnected&&!o.contains(i.startContainer)&&(i.setStart(o,0),i.collapse(!0));let s=document.createTextNode(e);i.insertNode(s),i.setStartAfter(s),i.collapse(!0),r&&(r.removeAllRanges(),r.addRange(i)),this._close(),n.focus(),this.context.invoke(`editor.afterCommand`)}},Yi=n({ICON_CATEGORIES:()=>Xi,ICON_LIST:()=>Zi}),Xi,Zi,Qi=t((()=>{Xi=[{id:`popular`,label:`Popular`},{id:`interface`,label:`Interface`},{id:`navigation`,label:`Navigation`},{id:`media`,label:`Media`},{id:`communication`,label:`Communication`},{id:`files`,label:`Files`},{id:`people`,label:`People`},{id:`objects`,label:`Objects`}],Zi=[[`house`,`popular`],[`star`,`popular`],[`heart`,`popular`],[`check`,`popular`],[`xmark`,`popular`],[`plus`,`popular`],[`minus`,`popular`],[`magnifying-glass`,`popular`],[`gear`,`popular`],[`bell`,`popular`],[`user`,`popular`],[`envelope`,`popular`],[`phone`,`popular`],[`calendar`,`popular`],[`clock`,`popular`],[`lock`,`popular`],[`eye`,`popular`],[`eye-slash`,`popular`],[`trash`,`popular`],[`pen`,`popular`],[`bookmark`,`popular`],[`flag`,`popular`],[`thumbs-up`,`popular`],[`thumbs-down`,`popular`],[`circle-info`,`popular`],[`triangle-exclamation`,`popular`],[`circle-check`,`popular`],[`circle-xmark`,`popular`],[`share`,`popular`],[`download`,`popular`],[`upload`,`popular`],[`tag`,`popular`],[`bars`,`interface`],[`ellipsis`,`interface`],[`ellipsis-vertical`,`interface`],[`list`,`interface`],[`table-cells`,`interface`],[`table-list`,`interface`],[`grip`,`interface`],[`filter`,`interface`],[`sort`,`interface`],[`arrows-rotate`,`interface`],[`rotate`,`interface`],[`rotate-left`,`interface`],[`rotate-right`,`interface`],[`copy`,`interface`],[`floppy-disk`,`interface`],[`print`,`interface`],[`link`,`interface`],[`code`,`interface`],[`expand`,`interface`],[`compress`,`interface`],[`cloud`,`interface`],[`lock-open`,`interface`],[`key`,`interface`],[`shield`,`interface`],[`shield-halved`,`interface`],[`sliders`,`interface`],[`toggle-on`,`interface`],[`square-check`,`interface`],[`circle-plus`,`interface`],[`circle-minus`,`interface`],[`arrow-right`,`navigation`],[`arrow-left`,`navigation`],[`arrow-up`,`navigation`],[`arrow-down`,`navigation`],[`chevron-right`,`navigation`],[`chevron-left`,`navigation`],[`chevron-up`,`navigation`],[`chevron-down`,`navigation`],[`angle-right`,`navigation`],[`angle-left`,`navigation`],[`angle-up`,`navigation`],[`angle-down`,`navigation`],[`angles-right`,`navigation`],[`angles-left`,`navigation`],[`location-dot`,`navigation`],[`compass`,`navigation`],[`map`,`navigation`],[`map-pin`,`navigation`],[`route`,`navigation`],[`circle-arrow-right`,`navigation`],[`circle-arrow-left`,`navigation`],[`arrow-trend-up`,`navigation`],[`arrow-trend-down`,`navigation`],[`right-from-bracket`,`navigation`],[`right-to-bracket`,`navigation`],[`play`,`media`],[`pause`,`media`],[`stop`,`media`],[`forward`,`media`],[`backward`,`media`],[`forward-step`,`media`],[`backward-step`,`media`],[`volume-high`,`media`],[`volume-low`,`media`],[`volume-xmark`,`media`],[`volume-off`,`media`],[`music`,`media`],[`headphones`,`media`],[`microphone`,`media`],[`microphone-slash`,`media`],[`film`,`media`],[`camera`,`media`],[`camera-rotate`,`media`],[`video`,`media`],[`image`,`media`],[`images`,`media`],[`photo-film`,`media`],[`podcast`,`media`],[`radio`,`media`],[`comment`,`communication`],[`comments`,`communication`],[`comment-dots`,`communication`],[`message`,`communication`],[`paper-plane`,`communication`],[`reply`,`communication`],[`reply-all`,`communication`],[`at`,`communication`],[`hashtag`,`communication`],[`wifi`,`communication`],[`signal`,`communication`],[`rss`,`communication`],[`share-nodes`,`communication`],[`inbox`,`communication`],[`phone-volume`,`communication`],[`mobile`,`communication`],[`mobile-screen`,`communication`],[`laptop`,`communication`],[`desktop`,`communication`],[`tower-broadcast`,`communication`],[`file`,`files`],[`file-lines`,`files`],[`folder`,`files`],[`folder-open`,`files`],[`folder-plus`,`files`],[`folder-minus`,`files`],[`file-image`,`files`],[`file-pdf`,`files`],[`file-code`,`files`],[`file-zipper`,`files`],[`file-audio`,`files`],[`file-video`,`files`],[`file-arrow-up`,`files`],[`file-arrow-down`,`files`],[`database`,`files`],[`box`,`files`],[`box-open`,`files`],[`hard-drive`,`files`],[`server`,`files`],[`user`,`people`],[`users`,`people`],[`user-group`,`people`],[`user-plus`,`people`],[`user-minus`,`people`],[`user-check`,`people`],[`user-xmark`,`people`],[`user-tie`,`people`],[`user-shield`,`people`],[`user-secret`,`people`],[`person`,`people`],[`person-running`,`people`],[`person-walking`,`people`],[`child`,`people`],[`handshake`,`people`],[`hand`,`people`],[`hands-holding`,`people`],[`people-group`,`people`],[`pencil`,`objects`],[`paintbrush`,`objects`],[`eraser`,`objects`],[`scissors`,`objects`],[`wrench`,`objects`],[`screwdriver`,`objects`],[`hammer`,`objects`],[`toolbox`,`objects`],[`graduation-cap`,`objects`],[`book`,`objects`],[`book-open`,`objects`],[`glasses`,`objects`],[`microscope`,`objects`],[`flask`,`objects`],[`stethoscope`,`objects`],[`hospital`,`objects`],[`building`,`objects`],[`city`,`objects`],[`car`,`objects`],[`truck`,`objects`],[`plane`,`objects`],[`train`,`objects`],[`bicycle`,`objects`],[`bus`,`objects`],[`rocket`,`objects`],[`briefcase`,`objects`],[`cart-shopping`,`objects`],[`bag-shopping`,`objects`],[`credit-card`,`objects`],[`money-bill`,`objects`],[`chart-bar`,`objects`],[`chart-line`,`objects`],[`chart-pie`,`objects`],[`bolt`,`objects`],[`sun`,`objects`],[`moon`,`objects`],[`snowflake`,`objects`],[`fire`,`objects`],[`droplet`,`objects`],[`leaf`,`objects`],[`tree`,`objects`],[`earth-americas`,`objects`],[`globe`,`objects`],[`award`,`objects`],[`trophy`,`objects`],[`gift`,`objects`],[`puzzle-piece`,`objects`]]})),$i=`https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css`,ea=null,ta=null;function na(){return ea?Promise.resolve(ea):(ta??=Promise.resolve().then(()=>(Qi(),Yi)).then(e=>(ea={ICON_CATEGORIES:e.ICON_CATEGORIES,ICON_LIST:e.ICON_LIST},ea)),ta)}var ra=class extends G{_selectedIcon=null;_activeCat=`all`;initialize(){return this}_ensureFontAwesome(){if(this.context.options.fontAwesomeAutoInject===!1)return;let e=this.context.options.fontAwesomeCDN||$i;if(!e||document.getElementById(`an-fontawesome-css`))return;let t=Array.from(document.querySelectorAll(`link[rel="stylesheet"]`)).map(e=>e.href||``).join(` `);if(/fontawesome|font-awesome/.test(t)||document.querySelector(`.fa-solid, .fas, .far, .fab`))return;let n=document.createElement(`link`);n.id=`an-fontawesome-css`,n.rel=`stylesheet`,n.href=e,Ni(n,this.context.options),document.head.appendChild(n)}async show(){if(this._saveRange(),this._ensureFontAwesome(),!this._dialog){let{ICON_CATEGORIES:e,ICON_LIST:t}=await na();this._dialog||(this._cats=e,this._list=t,this._dialog=this._buildDialog(),x(this.context).appendChild(this._dialog))}this._selectedIcon=null,this._activeCat=`all`,this._searchInput.value=``,this._grid.querySelectorAll(`.an-icon-cell.active`).forEach(e=>e.classList.remove(`active`)),this._insertBtn.setAttribute(`disabled`,``),this._updateCatTabs(),this._filterIcons(``,`all`),this._updatePreview(null),this._open()}_buildDialog(){let e=this.context.locale.iconDialog,t=h(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e.ariaLabel}),n=h(`div`,{class:`an-dialog-box an-icon-box`}),r=h(`div`,{class:`an-icon-title-row`}),i=h(`div`,{class:`an-dialog-title-group`}),a=h(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>`;let o=h(`h3`,{class:`an-dialog-title`});o.textContent=e.title,i.append(a,o);let s=h(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close});s.innerHTML=`&times;`,r.append(i,s);let c=h(`input`,{type:`search`,class:`an-input an-icon-search`,placeholder:e.searchPlaceholder,autocomplete:`off`});this._searchInput=c,this._firstInput=c;let l=h(`div`,{class:`an-icon-cats`}),u=h(`button`,{type:`button`,class:`an-icon-cat active`,"data-cat":`all`});u.textContent=e.all,l.appendChild(u),this._cats.forEach(({id:t,label:n})=>{let r=h(`button`,{type:`button`,class:`an-icon-cat`,"data-cat":t});r.textContent=e.categories?.[t]||n,l.appendChild(r)}),this._catBar=l;let d=h(`div`,{class:`an-icon-grid`});this._list.forEach(([e,t])=>{let n=h(`button`,{type:`button`,class:`an-icon-cell`,"data-name":e,"data-cat":t,title:e}),r=h(`i`,{class:`fa-solid fa-`+e,"aria-hidden":`true`}),i=h(`span`);i.textContent=e,n.append(r,i),d.appendChild(n)}),this._grid=d;let f=h(`div`,{class:`an-icon-options`}),p=h(`label`,{class:`an-label`});p.textContent=e.style;let m=h(`select`,{class:`an-input an-icon-option-select`});[[`fa-solid`,`Solid`],[`fa-regular`,`Regular`],[`fa-light`,`Light (Pro)`]].forEach(([e,t])=>{let n=h(`option`,{value:e});n.textContent=t,m.appendChild(n)}),m.value=`fa-solid`,this._styleSelect=m;let g=h(`label`,{class:`an-label`});g.textContent=e.size;let _=h(`select`,{class:`an-input an-icon-option-select`});[[``,`Inherit`],[`0.75em`,`0.75em`],[`1em`,`1em`],[`1.25em`,`1.25em`],[`1.5em`,`1.5em`],[`2em`,`2em`],[`3em`,`3em`]].forEach(([e,t])=>{let n=h(`option`,{value:e});e===`1em`&&(n.selected=!0),n.textContent=t,_.appendChild(n)}),this._sizeSelect=_;let y=h(`label`,{class:`an-label`});y.textContent=e.color;let x=h(`input`,{type:`color`,class:`an-icon-color`,value:`#000000`});this._colorInput=x;let S=h(`label`,{class:`an-label an-label-inline an-icon-use-color`}),C=h(`input`,{type:`checkbox`,checked:``});this._useColorCb=C,S.append(C,document.createTextNode(e.useColor)),f.append(p,m,g,_,y,x,S);let w=h(`div`,{class:`an-icon-preview`}),ee=h(`span`,{class:`an-icon-preview-hint`});ee.textContent=e.selectHint,w.appendChild(ee),this._preview=w;let T=h(`div`,{class:`an-dialog-actions`}),E=h(`button`,{type:`button`,class:`an-btn an-btn-primary`,disabled:``});E.textContent=e.insertBtn;let D=h(`button`,{type:`button`,class:`an-btn`});D.textContent=e.cancelBtn,T.append(E,D),this._insertBtn=E,n.append(r,c,l,d,f,w,T),t.appendChild(n),b(r,n);let te=v(s,`click`,()=>this._close()),ne=v(D,`click`,()=>this._close()),re=v(E,`click`,()=>this._onInsert()),O=v(t,`click`,e=>{e.target===t&&this._close()}),ie=v(c,`input`,()=>this._filterIcons(c.value,this._activeCat)),ae=v(l,`click`,e=>{let t=e.target?.closest(`[data-cat]`);t&&(this._activeCat=t.dataset.cat,this._updateCatTabs(),this._filterIcons(this._searchInput.value,this._activeCat))}),oe=v(d,`click`,e=>{let t=e.target?.closest(`.an-icon-cell`);t&&this._selectIcon(t.dataset.name)}),k=v(m,`change`,()=>this._updatePreview(this._selectedIcon)),se=v(_,`change`,()=>this._updatePreview(this._selectedIcon)),ce=v(x,`input`,()=>this._updatePreview(this._selectedIcon)),le=v(C,`change`,()=>this._updatePreview(this._selectedIcon));return this._disposers.push(te,ne,re,O,ie,ae,oe,k,se,ce,le),t}_updateCatTabs(){this._catBar.querySelectorAll(`.an-icon-cat`).forEach(e=>{e.classList.toggle(`active`,e.dataset.cat===this._activeCat)})}_filterIcons(e,t){let n=(e||``).trim().toLowerCase(),r=0;this._grid.querySelectorAll(`.an-icon-cell`).forEach(e=>{let i=e,a=i.dataset.name,o=i.dataset.cat,s=!t||t===`all`||o===t,c=!n||a.includes(n),l=s&&c;i.style.display=l?``:`none`,l&&r++});let i=this._grid.querySelector(`.an-icon-empty`);i||(i=h(`div`,{class:`an-icon-empty`}),i.textContent=`No icons found`,this._grid.appendChild(i)),i.style.display=r>0?`none`:``}_selectIcon(e){this._selectedIcon=e,this._grid.querySelectorAll(`.an-icon-cell`).forEach(t=>{t.classList.toggle(`active`,t.dataset.name===e)}),this._insertBtn.removeAttribute(`disabled`),this._updatePreview(e)}_updatePreview(e){if(!this._preview)return;if(!e){this._preview.innerHTML=`<span class="an-icon-preview-hint">Select an icon</span>`;return}let t=this._styleSelect?.value||`fa-solid`,n=this._sizeSelect?.value||`1em`,r=this._useColorCb?.checked??!1?this._colorInput?.value??``:``,i=[n?`font-size:${n}`:``,r?`color:${r}`:``].filter(Boolean).join(`;`);this._preview.innerHTML=`<i class="${t} fa-${e}" aria-hidden="true"${i?` style="${i}"`:``}></i><div class="an-icon-preview-name">${t} fa-${e}</div>`}_onInsert(){if(!this._selectedIcon)return;let e=this._styleSelect?.value||`fa-solid`,t=this._sizeSelect?.value||``,n=this._useColorCb?.checked??!1?this._colorInput?.value??``:``,r=[t?`font-size:${t}`:``,n?`color:${n}`:``].filter(Boolean),i=document.createElement(`i`);i.className=`${e} fa-${this._selectedIcon}`,i.setAttribute(`aria-hidden`,`true`),i.setAttribute(`contenteditable`,`false`),r.length&&i.setAttribute(`style`,r.join(`;`));let a=this._savedRange,o=this.context.layoutInfo.editable;a&&a.select();let s=globalThis.getSelection(),c=(s?.rangeCount??0)>0?s.getRangeAt(0):null;c||(c=document.createRange(),c.selectNodeContents(o),c.collapse(!1));let l=c.startContainer,u=(l.nodeType===1?l:l.parentElement)?.closest(`td, th`);c.deleteContents(),u?.isConnected&&!u.contains(c.startContainer)&&(c.setStart(u,0),c.collapse(!0)),c.insertNode(i);let d=i.nextSibling;d?.nodeType===Node.TEXT_NODE?d.textContent||(d.textContent=`​`):(d=document.createTextNode(`​`),i.parentNode.insertBefore(d,i.nextSibling));let f=+!!(d.textContent||``).startsWith(`​`),p=document.createRange();p.setStart(d,Math.min(f,d.textContent.length)),p.collapse(!0),s&&(s.removeAllRanges(),s.addRange(p)),this._close(),o.focus(),s&&(s.removeAllRanges(),s.addRange(p)),this.context.invoke(`editor.afterCommand`)}_close(){this._selectedIcon=null,super._close()}};function ia(e){return Dn({...e,mod:e.mod||e.ctrl,ctrl:!1})}var aa=[{category:`Text Formatting`,items:[{keys:`Ctrl + B`,action:`Bold`},{keys:`Ctrl + I`,action:`Italic`},{keys:`Ctrl + U`,action:`Underline`},{keys:`Ctrl + K`,action:`Insert / edit link`}]},{category:`History`,items:[{keys:`Ctrl + Z`,action:`Undo`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Redo`}]},{category:`Selection & Navigation`,items:[{keys:`Ctrl + A`,action:`Select all content`},{keys:`Tab`,action:`Indent list item / insert spaces`},{keys:`Shift + Tab`,action:`Outdent list item`}]},{category:`Clipboard`,items:[{keys:`Ctrl + Shift + V`,action:`Paste as plain text`}]},{category:`Find & Replace`,items:[{keys:`Ctrl + F`,action:`Find in document`},{keys:`Ctrl + H`,action:`Find & Replace`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Show this keyboard shortcuts dialog`}]}],oa=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="20" height="14" rx="2"/><path d="M6 11h.01M10 11h.01M14 11h.01M18 11h.01M6 15h.01M18 15h.01M10 15h4"/><path d="M7 3l5 4 5-4"/></svg>`,sa=class extends G{show(){this._listEl&&this._renderShortcuts(this._listEl),this._open()}_buildDialog(){let e=this.context.locale.shortcutsDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,oa,e.title);n.classList.add(`an-shortcuts-box`);let r=h(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close,style:`margin-left:auto`});r.textContent=`×`,this._closeBtn=r,this._firstInput=r,n.querySelector(`.an-dialog-header`).appendChild(r),this._listEl=h(`div`,{class:`an-shortcuts-list`}),this._renderShortcuts(this._listEl),n.appendChild(this._listEl);let i=v(r,`click`,()=>this._close());return this._disposers.push(i),t}_renderShortcuts(e){e.textContent=``;let t=this.context.locale.shortcutsDialog,n=this.context.invoke?.(`editor.getKeyBindings`)||En(null),r=new Map(n.map(e=>[ia(e.parsed),e.command])),i=new Set;for(let[e,t]of Object.entries(Sn)){let n=ia(wn(e));r.get(n)!==t&&i.add(n)}let a=(t.shortcuts||aa).map(({category:e,items:t})=>({category:e,items:t.flatMap(({keys:e,action:t})=>{let n=e.split(/\s+\/\s+/).map(e=>e.trim()).filter(e=>{let t=wn(e.replace(/\s+/g,``));return!t||!i.has(ia(t))});return n.length?[{keys:n.join(` / `),action:t}]:[]})})),o=new Map(Object.entries(Sn).map(([e,t])=>[Dn(wn(e)),t])),s=n.filter(e=>o.get(Dn(e.parsed))!==e.command).map(e=>({keys:On(e.parsed),action:this._describe(e)}));s.length&&a.push({category:t.customCategory||`Custom`,items:s});for(let{category:t,items:n}of a){if(!n.length)continue;let r=h(`div`,{class:`an-shortcuts-cat`});r.textContent=t,e.appendChild(r);let i=h(`div`,{class:`an-shortcuts-table`});for(let{keys:e,action:t}of n){let n=h(`div`,{class:`an-shortcuts-row`}),r=h(`span`,{class:`an-shortcuts-key`});r.textContent=e;let a=h(`span`,{class:`an-shortcuts-action`});a.textContent=t,n.append(r,a),i.appendChild(n)}e.appendChild(i)}}_describe(e){if(e.description)return e.description;if(typeof e.command==`string`){let t=this.context.locale.toolbar?.[e.command];return typeof t==`string`?t:e.command}return this.context.locale.shortcutsDialog.customCategory||`Custom`}},ca=class extends G{constructor(e){super(e),this._findInput=null,this._replaceInput=null,this._caseCheckbox=null,this._counterEl=null,this._closeBtn=null,this._matches=[],this._currentIndex=-1,this._caseSensitive=!1,this._useRegex=!1,this._wholeWord=!1,this._mode=`find`,this._queryRegex=null,this._lastQuery=null,this._lastCaseSensitive=null,this._lastUseRegex=null,this._lastWholeWord=null,this._focusTimer=null}destroy(){clearTimeout(this._focusTimer),this._focusTimer=null,this._clearHighlights(),super.destroy()}show(e=`find`){this._mode=e,this._updateMode(),this._open(),clearTimeout(this._focusTimer),this._focusTimer=setTimeout(()=>{this._findInput&&(this._findInput.select(),this._findInput.focus())},50)}_open(){if(this._dialog){if(this._dialog.style.display===`flex`){this._findInput&&this._findInput.focus();return}this._dialog.style.display=`flex`,this._removeTrap&&=(this._removeTrap(),null),this._removeTrap=y(this._dialog,()=>this._close())}}_close(){this._clearHighlights(),this._dialog&&(this._dialog.style.display=`none`),this._removeTrap&&=(this._removeTrap(),null),this.context.invoke(`editor.focus`)}_updateMode(){if(!this._dialog)return;let e=this._dialog.querySelector(`.an-fr-replace-row`),t=this._dialog.querySelector(`.an-fr-replace-actions`),n=this._dialog.querySelector(`.an-dialog-title`),r=this._mode===`replace`;e&&(e.style.display=r?``:`none`),t&&(t.style.display=r?``:`none`),n&&(n.textContent=r?this.context.locale.findReplace.findReplaceTitle:this.context.locale.findReplace.findTitle)}_buildDialog(){let e=this.context.locale.findReplace,t=h(`div`,{class:`an-dialog-overlay an-fr-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":e.findReplaceTitle}),n=h(`div`,{class:`an-dialog-box an-fr-box`}),r=h(`div`,{class:`an-fr-header`}),i=h(`div`,{class:`an-dialog-title-group`}),a=h(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>`;let o=h(`h3`,{class:`an-dialog-title`});o.textContent=e.findTitle,i.append(a,o);let s=h(`button`,{type:`button`,class:`an-icon-close`,title:e.close,"aria-label":e.close});s.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`,this._closeBtn=s,r.append(i,s),n.appendChild(r);let c=h(`div`,{class:`an-fr-search-bar`}),l=h(`input`,{type:`text`,class:`an-input an-fr-input`,placeholder:e.findPlaceholder,"aria-label":e.searchAriaLabel});this._findInput=l;let u=h(`input`,{type:`checkbox`,style:`display:none`,"aria-hidden":`true`});this._caseCheckbox=u;let d=h(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.caseSensitive.trim(),"aria-label":e.caseSensitive.trim()});d.textContent=`Aa`;let f=h(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.useRegex,"aria-label":e.useRegex});f.textContent=`.*`;let p=h(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.wholeWord,"aria-label":e.wholeWord});p.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="7" width="18" height="10" rx="2"/><line x1="7" y1="21" x2="7" y2="17"/><line x1="17" y1="21" x2="17" y2="17"/></svg>`;let m=h(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.prevMatch,"aria-label":e.prevMatch});m.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="18 15 12 9 6 15"/></svg>`;let g=h(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.nextMatch,"aria-label":e.nextMatch});g.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>`;let _=h(`span`,{class:`an-fr-counter`});this._counterEl=_,c.append(l,u,d,f,p,m,g,_),n.appendChild(c);let y=h(`div`,{class:`an-fr-replace-row`});y.style.display=`none`;let x=h(`input`,{type:`text`,class:`an-input an-fr-input`,placeholder:e.replacePlaceholder,"aria-label":e.replaceAriaLabel});this._replaceInput=x;let S=h(`button`,{type:`button`,class:`an-btn an-fr-replace-btn`});S.textContent=e.replaceBtn;let C=h(`button`,{type:`button`,class:`an-btn an-btn-primary an-fr-replace-btn`});C.textContent=e.replaceAllBtn,y.append(x,S,C),n.appendChild(y);let w=h(`div`,{class:`an-fr-replace-actions`});w.style.display=`none`,n.appendChild(w),t.appendChild(n),b(r,n);let ee=v(s,`click`,()=>this._close()),T=v(t,`click`,e=>{e.target===t&&this._close()}),E=v(l,`input`,()=>this._onSearch()),D=v(d,`click`,()=>{this._caseSensitive=!this._caseSensitive,u.checked=this._caseSensitive,d.classList.toggle(`an-fr-icon-btn--active`,this._caseSensitive),this._onSearch()}),te=v(u,`change`,()=>{this._caseSensitive=u.checked,d.classList.toggle(`an-fr-icon-btn--active`,this._caseSensitive),this._onSearch()}),ne=v(g,`click`,()=>this._next()),re=v(m,`click`,()=>this._prev()),O=v(S,`click`,()=>this._replace()),ie=v(C,`click`,()=>this._replaceAll()),ae=v(l,`keydown`,e=>{let t=e;t.key===`Enter`&&(e.preventDefault(),t.shiftKey?this._prev():this._next())}),oe=v(x,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._replace())}),k=v(f,`click`,()=>{this._useRegex=!this._useRegex,f.classList.toggle(`an-fr-icon-btn--active`,this._useRegex),this._queryRegex=null,this._lastQuery=null,this._onSearch()}),se=v(p,`click`,()=>{this._wholeWord=!this._wholeWord,p.classList.toggle(`an-fr-icon-btn--active`,this._wholeWord),this._queryRegex=null,this._lastQuery=null,this._onSearch()});return this._disposers.push(ee,T,E,D,te,ne,re,O,ie,ae,oe,k,se),t}_onSearch(){this._clearHighlights();let e=this._findInput?this._findInput.value:``;if(!e){this._updateCounter();return}this._findAndHighlight(e),this._updateCounter()}_findAndHighlight(e){let t=this.context.layoutInfo.editable;if(!t)return;let n=this._findRawMatches(e,t);if(n.length!==0){for(let e=n.length-1;e>=0;e--){let{node:t,start:r,end:i}=n[e];try{let e=document.createRange();e.setStart(t,r),e.setEnd(t,i);let n=document.createElement(`mark`);n.className=`an-highlight`,e.surroundContents(n),this._matches.push({mark:n})}catch{this._matches.push({mark:null})}}this._matches.reverse(),this._matches=this._matches.filter(e=>e.mark),this._currentIndex=0,this._matches.length!==0&&this._matches[0]?.mark&&(this._matches[0].mark.className=`an-highlight an-highlight-current`,this._matches[0].mark.scrollIntoView({block:`center`,behavior:`smooth`}))}}_findRawMatches(e,t){let n=[];if(this._lastQuery!==e||this._lastCaseSensitive!==this._caseSensitive||this._lastUseRegex!==this._useRegex||this._lastWholeWord!==this._wholeWord){let t=this._caseSensitive?`g`:`gi`;try{let n=this._useRegex?e:e.replace(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);this._wholeWord&&(n=`\\b${n}\\b`),this._queryRegex=new RegExp(n,t)}catch{this._queryRegex=null}this._lastQuery=e,this._lastCaseSensitive=this._caseSensitive,this._lastUseRegex=this._useRegex,this._lastWholeWord=this._wholeWord}if(!this._queryRegex)return n;let r=this._queryRegex,i=document.createTreeWalker(t,4),a=i.nextNode();for(;a&&n.length<500;){r.lastIndex=0;let e;for(;(e=r.exec(a.textContent))!==null&&n.length<500;)n.push({node:a,start:e.index,end:e.index+e[0].length});a=i.nextNode()}return n}_next(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex+1)%this._matches.length,this._scrollToMatch(this._currentIndex),this._updateCounter())}_prev(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex-1+this._matches.length)%this._matches.length,this._scrollToMatch(this._currentIndex),this._updateCounter())}_scrollToMatch(e){let t=this._matches[e];t?.mark&&(this._matches.forEach((t,n)=>{t.mark&&(t.mark.className=n===e?`an-highlight an-highlight-current`:`an-highlight`)}),t.mark.scrollIntoView({block:`center`,behavior:`smooth`}))}_replace(){if(this._matches.length===0||this._currentIndex<0)return;let e=this._matches[this._currentIndex];if(!e?.mark?.parentNode)return;let t=this._replaceInput?this._replaceInput.value:``,n=e.mark.parentNode,r=document.createTextNode(t);n.insertBefore(r,e.mark),e.mark.remove(),n.normalize(),this.context.invoke(`editor.afterCommand`);let i=this._currentIndex;this._onSearch(),this._matches.length>0&&(this._currentIndex=Math.min(i,this._matches.length-1),this._scrollToMatch(this._currentIndex),this._updateCounter())}_replaceAll(){if(this._matches.length===0)return;let e=this._replaceInput?this._replaceInput.value:``;this._matches.forEach(({mark:t})=>{if(!t?.parentNode)return;let n=document.createTextNode(e);t.parentNode.insertBefore(n,t),t.remove()}),this.context.layoutInfo.editable&&this.context.layoutInfo.editable.normalize(),this._matches=[],this._currentIndex=-1,this.context.invoke(`editor.afterCommand`),this._onSearch()}_clearHighlights(){let e=this.context.layoutInfo.editable;e&&(e.querySelectorAll(`mark.an-highlight`).forEach(e=>{let t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}),e.normalize(),this._matches=[],this._currentIndex=-1)}_updateCounter(){if(!this._counterEl)return;let e=this._matches.length;if(e===0){let e=this._findInput?this._findInput.value:``;this._counterEl.textContent=e?this.context.locale.findReplace.noResults:``}else this._counterEl.textContent=`${this._currentIndex+1} / ${e}`}},X=20,la=`#3b82f6`,Z=(e,t,n)=>Math.min(Math.max(e,t),n);function ua(e,t,n,r){return new Promise(i=>{let a=e=>{let a=document.createElement(`canvas`);a.width=Math.round(n),a.height=Math.round(r);let o=a.getContext(`2d`);if(!o){i(null);return}try{o.drawImage(e,t.x,t.y,t.width,t.height,0,0,a.width,a.height),o.getImageData(0,0,1,1),i(a)}catch{i(null)}};if(e.src.startsWith(`data:`)||e.src.startsWith(`blob:`)||e.src.startsWith(globalThis.location.origin)){a(e);return}let o=new Image;o.crossOrigin=`anonymous`,o.onload=()=>a(o),o.onerror=()=>i(null),o.src=e.src+(e.src.includes(`?`)?`&`:`?`)+`_an=`+Date.now()})}var da=class{constructor(e){this.context=e,this._img=null,this._box=null,this._imgRect=null,this._scrim=null,this._cropBox=null,this._handles={},this._toolbar=null,this._infoEl=null,this._dragDisposers=null,this._disposers=[]}initialize(){return this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._close(!1)}open(e){this._scrim&&this._close(!1),this._img=e;let t=e.getBoundingClientRect();this._imgRect=t;let n=Math.min(12,t.width*.1,t.height*.1);this._box={x:t.left+n,y:t.top+n,w:t.width-n*2,h:t.height-n*2},this._buildDOM(),this._updateDOM(),this._bindEsc()}_buildDOM(){let e=document.createElement(`div`);e.className=`an-crop-scrim`,e.style.cssText=`
43
+ `)}},Ia=class{constructor(e){this.context=e,this._active=!1,this._disposers=[],this._prevHeight=``}initialize(){let e=v(document,`keydown`,e=>{this._active&&V(e,B.ESCAPE)&&this.deactivate()});return this._disposers.push(e),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._active&&this.deactivate()}toggle(){this._active?this.deactivate():this.activate()}isActive(){return this._active}activate(){if(this._active)return;let e=this.context.layoutInfo.container;this._prevHeight=e.style.height,e.classList.add(`an-fullscreen`),e.style.height=``,document.body.style.overflow=`hidden`,this._active=!0,this.context.invoke(`toolbar.refresh`)}deactivate(){if(!this._active)return;let e=this.context.layoutInfo.container;e.classList.remove(`an-fullscreen`),e.style.height=this._prevHeight,document.body.style.overflow=``,this._active=!1,this.context.invoke(`toolbar.refresh`)}},La=class{constructor(e){this.context=e,this.options=e.options,this._dialog=null,this._disposers=[],this._savedRange=null,this._firstInput=null,this._removeTrap=null}_buildDialog(){throw Error(`_buildDialog() must be implemented by subclass`)}initialize(){return this._dialog=this._buildDialog(),b(this.context).appendChild(this._dialog),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._dialog?.parentNode&&this._dialog.remove(),this._dialog=null}_saveRange(){te(e=>{this._savedRange=e})}_open(){this._dialog&&(this._dialog.style.display=`flex`,this._removeTrap=y(this._dialog,()=>this._close()),setTimeout(()=>this._firstInput?.focus(),50))}_close(){this._dialog&&(this._dialog.style.display=`none`),this._removeTrap&&=(this._removeTrap(),null),this._savedRange=null}_buildDialogShell(e,t,n){let r=h(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e}),i=h(`div`,{class:`an-dialog-box`}),a=h(`div`,{class:`an-dialog-header`}),o=h(`span`,{class:`an-dialog-icon`});o.innerHTML=t;let s=h(`h3`,{class:`an-dialog-title`});s.textContent=n,a.appendChild(o),a.appendChild(s),i.appendChild(a),r.appendChild(i),ee(a,i);let c=v(r,`click`,e=>{e.target===r&&this._close()});return this._disposers.push(c),{overlay:r,box:i}}_buildButtonRow(e,t,n){let r=h(`div`,{class:`an-dialog-actions`}),i=h(`button`,{type:`button`,class:`an-btn an-btn-primary`});i.textContent=e;let a=h(`button`,{type:`button`,class:`an-btn`});a.textContent=t,r.appendChild(i),r.appendChild(a);let o=v(i,`click`,n),s=v(a,`click`,()=>this._close());return this._disposers.push(o,s),r}},Ra=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,za=class extends La{show(){this._saveRange(),this._prefill(),this._open()}_buildDialog(){let e=this.context.locale.linkDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,Ra,e.title),r=h(`label`,{class:`an-label`});r.textContent=e.url;let i=h(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,id:`an-link-url`,name:`url`,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=h(`label`,{class:`an-label`});a.textContent=e.displayText;let o=h(`input`,{type:`text`,class:`an-input`,placeholder:e.textPlaceholder,id:`an-link-text`,name:`linkText`,autocomplete:`off`});this._textInput=o;let s=h(`label`,{class:`an-label an-label-inline`}),c=h(`input`,{type:`checkbox`,id:`an-link-newtab`,name:`openInNewTab`});this._tabCheckbox=c,s.appendChild(c),s.appendChild(document.createTextNode(` `+e.openInNewTab));let l=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(r,i,a,o,s,l);let u=v(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())}),d=v(o,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(u,d),t}_prefill(){let e=globalThis.getSelection(),t=null;if(e?.rangeCount>0){let n=e.getRangeAt(0).startContainer;for(;n;){if(n.nodeName===`A`){t=n;break}n=n.parentNode}}t?(this._urlInput.value=t.getAttribute(`href`)||``,this._textInput.value=t.textContent||``,this._tabCheckbox.checked=t.getAttribute(`target`)===`_blank`):(this._urlInput.value=``,this._textInput.value=e?e.toString():``,this._tabCheckbox.checked=!!this.context.options.linkDefaults?.openInNewTab)}_onInsert(){let e=this._urlInput.value.trim(),t=this._textInput.value.trim(),n=this._tabCheckbox.checked;if(!e){this._urlInput.focus();return}let r=this.context.options.linkDefaults?.defaultProtocol??`https://`,i=/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e),a=/^[/#?.]/.test(e);if(r&&!i&&!a&&(e=r+e),!br(e)){this._urlInput.focus();return}this._savedRange&&this._savedRange.select(),this.context.invoke(`editor.insertLink`,e,t,n),this._close()}},Ba=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,Va=class extends La{show({beforeInsert:e}={}){this._beforeInsert=typeof e==`function`?e:null,this._saveRange(),this._urlInput.value=``,this._altInput.value=``,this._fileInput&&(this._fileInput.value=``),this._open()}_buildDialog(){let e=this.context.locale.imageDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,Ba,e.title),r=h(`label`,{class:`an-label`});r.textContent=e.imageUrl;let i=h(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=h(`label`,{class:`an-label`});a.textContent=e.altText;let o=h(`input`,{type:`text`,class:`an-input`,placeholder:e.altPlaceholder,autocomplete:`off`});this._altInput=o,n.append(r,i,a,o);let s=h(`label`,{class:`an-label`});s.textContent=e.alignment;let c=h(`div`,{class:`an-align-row`});if([{value:``,label:e.alignNone},{value:`left`,label:e.alignLeft},{value:`center`,label:e.alignCenter},{value:`right`,label:e.alignRight}].forEach(({value:e,label:t})=>{let n=`an-align-${e||`none`}`,r=h(`input`,{type:`radio`,name:`an-img-align`,id:n,value:e});e===``&&(r.checked=!0);let i=h(`label`,{for:n,class:`an-align-label`});i.textContent=t,c.append(r,i)}),this._alignRow=c,n.append(s,c),this.options.allowImageUpload!==!1){let t=h(`label`,{class:`an-label`});t.textContent=e.uploadLabel;let r=h(`input`,{type:`file`,class:`an-input`,accept:`image/jpeg,image/png,image/gif,image/webp,image/svg+xml,image/avif`});this._fileInput=r;let i=h(`p`,{class:`an-dialog-hint`});this._fileHint=i;let a=v(r,`change`,()=>this._onFileChange());this._disposers.push(a),n.append(t,r,i)}let l=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(l);let u=v(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())}),d=v(o,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(u,d),t}_onFileChange(){if(this.context._alive===!1)return;let e=this._fileInput?.files?.[0];if(!e?.type?.startsWith(`image/`))return;if(!new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`,`image/avif`]).has(e.type)){let t=this.context.locale.errors.imageFormat(e.type);this._fileHint&&(this._fileHint.textContent=t),this.context.triggerEvent(`imageError`,{file:e,message:t}),this._fileInput.value=``;return}this._fileHint&&(this._fileHint.textContent=``);let t=(this.options.maxImageSize||5)*1024*1024;if(e.size>t){let t=this.context.locale.errors.imageSize(this.options.maxImageSize||5);this._fileHint&&(this._fileHint.textContent=t),console.warn(`[AutumnNote] ImageDialog:`,t),this.context.triggerEvent(`imageError`,{file:e,message:t}),this._fileInput.value=``;return}this.context.invoke(`clipboard.compressAndRegister`,e).then(e=>{this.context._alive!==!1&&(this._urlInput.value=e)}).catch(t=>{if(this.context._alive===!1)return;console.warn(`[AutumnNote] ImageDialog: image compression failed, using original file.`,t);let n=new FileReader;n.onload=e=>{this._urlInput.value=e.target.result},n.readAsDataURL(e)})}_onInsert(){let e=this._urlInput.value.trim(),t=this._altInput.value.trim(),n=this._alignRow?.querySelector(`input[name="an-img-align"]:checked`),r=n?n.value:``;if(!e){this._urlInput.focus();return}this._savedRange&&this._savedRange.select();let i=this._beforeInsert;this._beforeInsert=null,i?.(),this.context.invoke(`editor.insertImage`,e,t,r),this._close()}_close(){this._beforeInsert=null,super._close()}},Ha=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>`,Ua=class extends La{show(){this._saveRange(),this._urlInput.value=``,this._widthInput.value=`560`,this._hintEl.textContent=``,this._open()}_buildDialog(){let e=this.context.locale.videoDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,Ha,e.title),r=h(`label`,{class:`an-label`});r.textContent=e.videoUrl;let i=h(`input`,{type:`url`,class:`an-input`,placeholder:e.urlPlaceholder,autocomplete:`off`});this._urlInput=i,this._firstInput=i;let a=h(`p`,{class:`an-dialog-hint`});this._hintEl=a;let o=h(`label`,{class:`an-label`});o.textContent=e.widthLabel;let s=h(`input`,{type:`number`,class:`an-input`,placeholder:`560`,min:`80`,max:`1920`,value:`560`});this._widthInput=s;let c=this._buildButtonRow(e.insertBtn,e.cancelBtn,()=>this._onInsert());n.append(r,i,a,o,s,c);let l=v(i,`input`,()=>{let e=this._parseVideoUrl(i.value.trim()),t=``;e?t=this.context.locale.videoDialog.detected(e.type):i.value&&(t=this.context.locale.videoDialog.unknownFormat),a.textContent=t}),u=v(i,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._onInsert())});return this._disposers.push(l,u),t}_onInsert(){let e=this._urlInput.value.trim(),t=Math.max(80,Number.parseInt(this._widthInput.value,10)||560);if(!e){this._urlInput.focus();return}let n=this._buildEmbedHtml(e,t);if(!n){this._hintEl.textContent=this.context.locale.videoDialog.invalidUrl,this._urlInput.focus();return}this._savedRange&&this._savedRange.select(),this.context.invoke(`editor.insertVideo`,n),this._close()}_parseVideoUrl(e){if(!e||!br(e,{media:!0}))return null;let t=this.context.options.videoProviders;if(Array.isArray(t))for(let n of t){let t=n?.match instanceof RegExp?n.match.exec(e):null;if(!t||typeof n.embed!=`function`)continue;let r=n.embed(t,e);if(typeof r==`string`&&yr(r,this.context.options.iframeHosts))return{type:String(n.name||`Video`),embedUrl:r,iframe:!0};console.warn(`[AutumnNote] videoProviders: "${n.name}" returned an embed URL whose host is not in iframeHosts; ignoring it.`)}let n=/(?:youtube\.com\/watch\?(?:.*&)?v=|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/.exec(e);if(n)return{type:`YouTube`,embedUrl:`https://www.youtube.com/embed/${n[1]}`,iframe:!0};let r=/youtu\.be\/([a-zA-Z0-9_-]{11})/.exec(e);if(r)return{type:`YouTube`,embedUrl:`https://www.youtube.com/embed/${r[1]}`,iframe:!0};let i=/youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/.exec(e);if(i)return{type:`YouTube Shorts`,embedUrl:`https://www.youtube.com/embed/${i[1]}`,iframe:!0};let a=/vimeo\.com\/(\d+)/.exec(e);return a?{type:`Vimeo`,embedUrl:`https://player.vimeo.com/video/${a[1]}`,iframe:!0}:/\.(mp4|webm|ogg|ogv|mov)(#.*|\?.*)?$/i.test(e)?{type:`Direct video`,embedUrl:e}:null}_buildEmbedHtml(e,t){let n=this._parseVideoUrl(e),r=Math.round(t*9/16);if(n?.iframe){let e=e=>String(e).replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`),i=e(`${n.type} video player`);return`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><iframe src="${e(n.embedUrl)}" width="${t}" height="${r}" title="${i}" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" style="display:block;max-width:100%"></iframe><div class="an-video-shield"></div></div>`}if(n?.type===`Direct video`)return`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><video src="${n.embedUrl.replaceAll(`"`,`%22`)}" width="${t}" height="${r}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>`;let i=br(e,{media:!0});return i?`<div class="an-video-wrapper" style="position:relative;display:block;width:${t}px;max-width:100%"><video src="${i.replaceAll(`"`,`%22`)}" width="${t}" height="${r}" controls style="display:block;max-width:100%"></video><div class="an-video-shield"></div></div>`:null}},Wa=[{pos:`nw`,cursor:`nw-resize`},{pos:`n`,cursor:`n-resize`},{pos:`ne`,cursor:`ne-resize`},{pos:`e`,cursor:`e-resize`},{pos:`se`,cursor:`se-resize`},{pos:`s`,cursor:`s-resize`},{pos:`sw`,cursor:`sw-resize`},{pos:`w`,cursor:`w-resize`}],Ga=class{constructor(e){this.context=e,this._active=null,this._overlay=null,this._disposers=[],this._positionRaf=null,this._lastOverlayPos=null}get _overlayClass(){return`an-resizer`}get _selectedClass(){return`an-selected`}_findTarget(e){return null}_getStartSize(e){return{w:0,h:0}}_getMinSize(){return{minW:20,minH:20}}_applySize(e,t,n){}_extraListeners(){return[]}initialize(){this._overlay=this._buildOverlay();let e=this.context.layoutInfo.editable.closest(`.an-container`)||document.body;e.appendChild(this._overlay),this._container=e;let t=this.context.layoutInfo.editable,n=null;return this._disposers.push(v(t,`click`,e=>this._onEditorClick(e)),v(t,`contextmenu`,e=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let t=this._findTarget(e.target);t&&this._select(t)}),v(document,`click`,e=>this._onDocClick(e)),v(globalThis,`scroll`,()=>this._updateOverlayPosition(),{passive:!0}),v(globalThis,`resize`,()=>{clearTimeout(n),n=setTimeout(()=>this._updateOverlayPosition(),100)},{passive:!0}),v(t,`scroll`,()=>this._updateOverlayPosition(),{passive:!0}),...this._extraListeners()),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._dragDisposers&&=(this._dragDisposers.forEach(e=>e()),null),this._positionRaf&&=(cancelAnimationFrame(this._positionRaf),null),this._deselect(),this._overlay?.remove(),this._overlay=null}updateOverlay(){this._updateOverlayPosition()}deselect(){this._deselect()}_buildOverlay(){let e=document.createElement(`div`);return e.className=this._overlayClass,e.style.display=`none`,Wa.forEach(({pos:t})=>{let n=document.createElement(`div`);n.className=`an-resize-handle an-resize-${t}`,n.dataset.handle=t,this._disposers.push(v(n,`pointerdown`,e=>{e.preventDefault(),e.stopPropagation(),this._startResize(e,t)})),e.appendChild(n)}),e}_onEditorClick(e){if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let t=this._findTarget(e.target);t&&(e.preventDefault(),this._select(t))}_onDocClick(e){this._active&&(this._active.contains(e.target)||this._overlay?.contains(e.target)||e.target.closest?.(`.an-contextmenu`)||this._deselect())}_select(e){this._active&&this._active!==e&&this._active.classList.remove(this._selectedClass),this._active=e,this._lastOverlayPos=null,e.classList.add(this._selectedClass),this._updateOverlayPosition(),this._overlay.style.display=`block`}_deselect(){this._active&&=(this._active.classList.remove(this._selectedClass),null),this._overlay&&(this._overlay.style.display=`none`)}_updateOverlayPosition(){this._positionRaf&&cancelAnimationFrame(this._positionRaf),this._positionRaf=requestAnimationFrame(()=>{this._positionRaf=null,this._updateOverlayPositionNow()})}_updateOverlayPositionNow(){if(!this._active||!this._overlay)return;let e=this._overlay.offsetParent||this._container,t=e.getBoundingClientRect(),n=this._active.getBoundingClientRect(),r=this._lastOverlayPos;if(r?.l===n.left&&r.t===n.top&&r.w===n.width&&r.h===n.height)return;this._lastOverlayPos={l:n.left,t:n.top,w:n.width,h:n.height};let i=n.left-t.left+e.scrollLeft,a=n.top-t.top+e.scrollTop;this._overlay.style.left=`${i}px`,this._overlay.style.top=`${a}px`,this._overlay.style.width=`${n.width}px`,this._overlay.style.height=`${n.height}px`}_startResize(e,t){let n=this._active;if(!n)return;let r=e.clientX,i=e.clientY,{w:a,h:o}=this._getStartSize(n),{minW:s,minH:c}=this._getMinSize(),l=a/(o||1),u=t.length===2,d=this.context.layoutInfo.editable,f=null,p=e=>{if(f!==null)return;let p=e.clientX,m=e.clientY;f=requestAnimationFrame(()=>{f=null;let e=p-r,h=m-i,g=d.clientWidth||1/0,_=a,v=o;t.includes(`e`)&&(_=Math.max(s,a+e)),t.includes(`w`)&&(_=Math.max(s,a-e)),t.includes(`s`)&&(v=Math.max(c,o+h)),t.includes(`n`)&&(v=Math.max(c,o-h)),_=Math.min(_,g),u&&(Math.abs(e)>=Math.abs(h)||(_=Math.min(Math.max(s,Math.round(v*l)),g)),v=Math.max(c,Math.round(_/l))),this._applySize(n,_,v),this._updateOverlayPosition()})},m=()=>{document.removeEventListener(`pointermove`,p),document.removeEventListener(`pointerup`,h),document.removeEventListener(`pointercancel`,h)},h=()=>{f!==null&&(cancelAnimationFrame(f),f=null),m(),this._dragDisposers=null,this.context.invoke(`editor.afterCommand`)};document.addEventListener(`pointermove`,p),document.addEventListener(`pointerup`,h),document.addEventListener(`pointercancel`,h),this._dragDisposers=[m]}},Ka=class extends Ga{get _overlayClass(){return`an-image-resizer`}get _selectedClass(){return`an-image-selected`}_findTarget(e){return e instanceof Element?e.closest(`img`):null}_getStartSize(e){return{w:e.offsetWidth||e.naturalWidth||100,h:e.offsetHeight||e.naturalHeight||100}}_getMinSize(){let e=this.context.options?.minImageSize??20;return{minW:e,minH:e}}_applySize(e,t,n){e.style.width=`${t}px`,e.style.height=`${n}px`}getActiveImage(){return this._active}},qa=class extends Ga{get _overlayClass(){return`an-video-resizer`}get _selectedClass(){return`an-video-selected`}_findTarget(e){return!e||!(e instanceof Element)?null:e.classList?.contains(`an-video-wrapper`)?e:e.closest(`.an-video-wrapper`)}_getStartSize(e){return{w:e.offsetWidth||560,h:e.offsetHeight||315}}_getMinSize(){return{minW:80,minH:45}}_applySize(e,t,n){e.style.width=`${t}px`,e.style.height=`${n}px`;let r=e.querySelector(`iframe, video`);r&&(r.style.width=`${t}px`,r.style.height=`${n}px`)}_extraListeners(){let e=this.context.layoutInfo.editable;return[v(e,`dragstart`,e=>{e.target instanceof Element&&e.target.closest(`.an-video-wrapper`)&&e.preventDefault()})]}getActiveWrapper(){return this._active}},Ja={open:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>`,edit:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,unlink:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" y1="2" x2="8" y2="5"/><line x1="2" y1="8" x2="5" y2="8"/><line x1="16" y1="19" x2="16" y2="22"/><line x1="19" y1="16" x2="22" y2="16"/></svg>`,copy:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`},Ya=120,Xa=200,Za=class{constructor(e){this.context=e,this._el=null,this._activeAnchor=null,this._showTimer=null,this._hideTimer=null,this._disposers=[]}initialize(){this._el=this._buildTooltip(),b(this.context).appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(v(e,`mouseover`,t=>{let n=t.target?.closest(`a[href]`);n&&e.contains(n)&&this._scheduleShow(n)}),v(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()}),v(globalThis,`scroll`,()=>this._hide(),{passive:!0}),v(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.parentNode&&this._el.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.link,t=h(`div`,{class:`an-link-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._urlLabel=h(`span`,{class:`an-link-tooltip-url`}),t.appendChild(this._urlLabel),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._openBtn=this._makeBtn(Ja.open,e.openLink,()=>this._openLink()),this._copyBtn=this._makeBtn(Ja.copy,e.copyUrl,()=>this._copyLink()),this._editBtn=this._makeBtn(Ja.edit,e.editLink,()=>this._editLink()),this._unlinkBtn=this._makeBtn(Ja.unlink,e.removeLink,()=>this._unlink()),t.appendChild(this._openBtn),t.appendChild(this._copyBtn),t.appendChild(this._editBtn),t.appendChild(this._unlinkBtn),this._disposers.push(v(t,`mouseenter`,()=>this._clearTimers()),v(t,`mouseleave`,()=>this._scheduleHide())),t}_makeBtn(e,t,n){let r=h(`button`,{type:`button`,class:`an-link-tooltip-btn`,title:t});return r.innerHTML=e,this._disposers.push(v(r,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),r}_scheduleShow(e){(this._activeAnchor!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._activeAnchor=e,this._show(e)},Ya))}_scheduleHide(){clearTimeout(this._showTimer),this._showTimer=null,!this._hideTimer&&(this._hideTimer=setTimeout(()=>{this._hide()},Xa))}_show(e){let t=this.context.layoutInfo.container.classList.contains(`an-disabled`),n=e.getAttribute(`href`)||``;this._urlLabel.textContent=this._truncateUrl(n),this._urlLabel.title=n,this._editBtn.style.display=t?`none`:``,this._unlinkBtn.style.display=t?`none`:``,this._el.style.display=`flex`,this._positionNear(e)}_hide(){this._el.style.display=`none`,this._activeAnchor=null,this._clearTimers()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){let t=e.getBoundingClientRect(),n=this._el.offsetWidth||260,r=this._el.offsetHeight||34,i=t.bottom+6,a=t.left;i+r>globalThis.innerHeight-6&&(i=t.top-r-6),a+n>globalThis.innerWidth-6&&(a=globalThis.innerWidth-n-6),a<6&&(a=6),this._el.style.top=`${i}px`,this._el.style.left=`${a}px`}_truncateUrl(e){try{let t=new URL(e),n=t.host+(t.pathname===`/`?``:t.pathname);return n.length>48?n.slice(0,48)+`…`:n}catch{return e.length>48?e.slice(0,48)+`…`:e}}_openLink(){let e=this._activeAnchor?.getAttribute(`href`);e&&globalThis.open(e,`_blank`,`noopener,noreferrer`),this._hide()}_copyLink(){let e=this._activeAnchor?.getAttribute(`href`);e&&Ta({text:e}).catch(()=>{}),this._copyBtn&&(this._copyBtn.classList.add(`an-link-tooltip-btn--copied`),setTimeout(()=>this._copyBtn?.classList.remove(`an-link-tooltip-btn--copied`),1e3))}_editLink(){let e=this._activeAnchor;if(!e)return;this._hide();let t=globalThis.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),this.context.invoke(`linkDialog.show`)}_unlink(){let e=this._activeAnchor;if(!e)return;this._hide();let t=globalThis.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),Ye(this.context.layoutInfo.editable),this.context.invoke(`editor.afterCommand`)}},Qa=class{constructor(e){this.context=e,this.options=e.options,this._el=null,this._active=null,this._showTimer=null,this._hideTimer=null,this._disposers=[]}_canHide(){return!0}_beforeHide(){}_makeBtn(e,t,n,r=!1){let i=h(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(v(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){(this._active!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._active=e,this._show(e)},100))}_scheduleHide(){this._canHide()&&(clearTimeout(this._showTimer),this._showTimer=null,clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>this._hide(),180))}_show(e){this._el.style.display=`flex`,requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_hide(){this._beforeHide(),this._el.style.display=`none`,this._active=null,this._clearTimers()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){let t=e.getBoundingClientRect(),n=this._el.offsetWidth||220,r=this._el.offsetHeight||32,i=t.bottom+6,a=t.left+(t.width-n)/2;i+r>globalThis.innerHeight-6&&(i=t.top-r-6),a+n>globalThis.innerWidth-6&&(a=globalThis.innerWidth-n-6),a<6&&(a=6),this._el.style.top=`${i}px`,this._el.style.left=`${a}px`}},q={floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="4" width="10" height="8" rx="1"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="6" y1="20" x2="18" y2="20"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteImg:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,caption:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="11" rx="2"/><line x1="6" y1="18" x2="18" y2="18"/><line x1="9" y1="21" x2="15" y2="21"/></svg>`,rotateLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><polyline points="3 3 3 8 8 8"/></svg>`,rotateRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><polyline points="21 3 21 8 16 8"/></svg>`,crop:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 2 6 18 22 18"/><polyline points="2 6 18 6 18 22"/></svg>`},$a=class extends Qa{initialize(){this._el=this._buildTooltip(),b(this.context).appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(v(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`img`);n&&e.contains(n)&&!n.closest(`a[href]`)&&this._scheduleShow(n)},{passive:!0}),v(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()},{passive:!0}),v(document,`click`,e=>{let t=e.target;this._active&&!this._active.contains(t)&&!this._el.contains(t)&&this._hide()}),v(globalThis,`scroll`,()=>this._hide(),{passive:!0}),v(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.image,t=h(`div`,{class:`an-link-tooltip an-image-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=h(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._floatLeftBtn=this._makeBtn(q.floatLeft,e.floatLeft,()=>this._setFloat(`left`)),this._floatNoneBtn=this._makeBtn(q.floatNone,e.noFloat,()=>this._setFloat(``)),this._alignCenterBtn=this._makeBtn(q.alignCenter,e.alignCenter,()=>this._setCenter()),this._floatRightBtn=this._makeBtn(q.floatRight,e.floatRight,()=>this._setFloat(`right`)),t.appendChild(this._floatLeftBtn),t.appendChild(this._floatNoneBtn),t.appendChild(this._alignCenterBtn),t.appendChild(this._floatRightBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._originalBtn=this._makeBtn(q.originalSize,e.originalSize,()=>this._resetSize()),t.appendChild(this._originalBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),t.appendChild(this._makeBtn(q.rotateLeft,e.rotateLeft,()=>this._rotate(-90))),t.appendChild(this._makeBtn(q.rotateRight,e.rotateRight,()=>this._rotate(90))),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._cropBtn=this._makeBtn(q.crop,e.cropImage,()=>this._crop()),t.appendChild(this._cropBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._captionBtn=this._makeBtn(q.caption,e.addCaption,()=>this._toggleCaption()),t.appendChild(this._captionBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._deleteBtn=this._makeBtn(q.deleteImg,e.deleteImage,()=>this._delete(),!0),t.appendChild(this._deleteBtn),this._disposers.push(v(t,`mouseenter`,()=>this._clearTimers()),v(t,`mouseleave`,()=>this._scheduleHide())),t}_setFloat(e){let t=this._active;if(!t)return;let n=t.closest(`figure.an-figure`)||t;n.style.float=e,n.style.display=``,n!==t&&(n.style.width=``),n.style.marginLeft=e===`right`?`12px`:``,n.style.marginRight=e===`left`?`12px`:``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_setCenter(){let e=this._active;if(!e)return;let t=e.closest(`figure.an-figure`)||e;t.style.float=``,t.style.display=`block`,t!==e&&(t.style.width=`fit-content`),t.style.marginLeft=`auto`,t.style.marginRight=`auto`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_resetSize(){let e=this._active;e&&(e.style.width=``,e.style.height=``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_rotate(e){let t=this._active;if(!t)return;let n=t.style.transform||``,r=/rotate\((-?[\d.]+)deg\)/.exec(n),i=((r?Number.parseFloat(r[1]):0)+e+360)%360,a=n.replace(/rotate\(-?[\d.]+deg\)/,``).trim();a?t.style.transform=`${a} rotate(${i}deg)`:t.style.transform=i===0?``:`rotate(${i}deg)`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_delete(){let e=this._active;if(!e)return;this._hide(),this.context.invoke(`imageResizer.deselect`);let t=e.closest(`figure.an-figure`);t?t.remove():e.remove(),this.context.invoke(`editor.afterCommand`)}_crop(){let e=this._active;e&&(this._hide(),this.context.invoke(`imageCropOverlay.open`,e))}_toggleCaption(){let e=this._active;if(!e)return;let t=e.closest(`figure.an-figure`);if(t){let e=t.querySelector(`figcaption.an-figcaption`);if(e){this._hide();let t=document.createRange();t.selectNodeContents(e);let n=globalThis.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}return}let n=document.createElement(`figure`);n.className=`an-figure`,e.style.float?(n.style.float=e.style.float,n.style.marginLeft=e.style.marginLeft,n.style.marginRight=e.style.marginRight,e.style.float=``,e.style.marginLeft=``,e.style.marginRight=``):e.style.display===`block`&&e.style.marginLeft===`auto`&&(n.style.display=`block`,n.style.width=`fit-content`,n.style.marginLeft=`auto`,n.style.marginRight=`auto`,e.style.display=``,e.style.marginLeft=``,e.style.marginRight=``);let r=document.createElement(`figcaption`);r.className=`an-figcaption`,r.textContent=`Caption`,e.parentNode.insertBefore(n,e),n.appendChild(e),n.appendChild(r);let i=document.createRange();i.selectNodeContents(r);let a=globalThis.getSelection();a&&(a.removeAllRanges(),a.addRange(i)),this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`),this._hide()}},eo={floatLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="8" height="8" rx="1"/><line x1="12" y1="6" x2="22" y2="6"/><line x1="12" y1="9" x2="22" y2="9"/><line x1="12" y1="12" x2="22" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="14" y="4" width="8" height="8" rx="1"/><line x1="2" y1="6" x2="12" y2="6"/><line x1="2" y1="9" x2="12" y2="9"/><line x1="2" y1="12" x2="12" y2="12"/><line x1="2" y1="16" x2="22" y2="16"/><line x1="2" y1="20" x2="18" y2="20"/></svg>`,floatNone:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="3" y1="19" x2="17" y2="19"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="4" width="10" height="8" rx="1"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="6" y1="20" x2="18" y2="20"/></svg>`,originalSize:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,deleteVideo:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,preview:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="5 3 19 12 5 21 5 3"/></svg>`},to=class extends Qa{initialize(){this._el=this._buildTooltip(),b(this.context).appendChild(this._el);let e=this.context.layoutInfo.editable;return this._disposers.push(v(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`.an-video-wrapper`);n&&e.contains(n)&&this._scheduleShow(n)},{passive:!0}),v(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()},{passive:!0}),v(document,`click`,e=>{let t=e.target;this._active&&!this._active.contains(t)&&!this._el.contains(t)&&this._hide()}),v(globalThis,`scroll`,()=>this._hide(),{passive:!0}),v(globalThis,`resize`,()=>this._hide(),{passive:!0})),this}destroy(){this._previewMode&&this._exitPreview(),this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_canHide(){return!this._previewMode}_beforeHide(){this._previewMode&&this._exitPreview()}_buildTooltip(){let e=this.context.locale.tooltips.video,t=h(`div`,{class:`an-link-tooltip an-video-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=h(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._floatLeftBtn=this._makeBtn(eo.floatLeft,e.floatLeft,()=>this._setFloat(`left`)),this._floatNoneBtn=this._makeBtn(eo.floatNone,e.noFloat,()=>this._setFloat(``)),this._alignCenterBtn=this._makeBtn(eo.alignCenter,e.alignCenter,()=>this._setCenter()),this._floatRightBtn=this._makeBtn(eo.floatRight,e.floatRight,()=>this._setFloat(`right`)),t.appendChild(this._floatLeftBtn),t.appendChild(this._floatNoneBtn),t.appendChild(this._alignCenterBtn),t.appendChild(this._floatRightBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._originalBtn=this._makeBtn(eo.originalSize,e.originalSize,()=>this._resetSize()),t.appendChild(this._originalBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._previewBtn=this._makeBtn(eo.preview,e.previewVideo,()=>this._togglePreview()),t.appendChild(this._previewBtn),t.appendChild(h(`div`,{class:`an-link-tooltip-sep`})),this._deleteBtn=this._makeBtn(eo.deleteVideo,e.deleteVideo,()=>this._delete(),!0),t.appendChild(this._deleteBtn),this._disposers.push(v(t,`mouseenter`,()=>this._clearTimers()),v(t,`mouseleave`,()=>this._scheduleHide())),t}_setFloat(e){let t=this._active;t&&(t.style.float=e,t.style.display=e?`inline-block`:``,t.style.marginLeft=e===`right`?`12px`:``,t.style.marginRight=e===`left`?`12px`:``,this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_setCenter(){let e=this._active;e&&(e.style.float=``,e.style.display=`block`,e.style.marginLeft=`auto`,e.style.marginRight=`auto`,this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)}))}_resetSize(){let e=this._active;if(!e)return;let t=e.querySelector(`iframe, video`);e.style.width=``,e.style.height=``,t&&(t.removeAttribute(`width`),t.removeAttribute(`height`),t.style.width=``,t.style.height=``),this.context.invoke(`editor.afterCommand`),this.context.invoke(`videoResizer.updateOverlay`),requestAnimationFrame(()=>{this._active&&this._positionNear(this._active)})}_delete(){let e=this._active;e&&(this._hide(),this.context.invoke(`videoResizer.deselect`),e.remove(),this.context.invoke(`editor.afterCommand`))}_togglePreview(){this._previewMode?this._exitPreview():this._enterPreview()}_enterPreview(){let e=this._active;if(!e)return;this._previewMode=!0;let t=e.querySelector(`.an-video-shield`);t&&(t.style.display=`none`),this.context.invoke(`videoResizer.deselect`),this._previewBtn.classList.add(`an-link-tooltip-btn--copied`),this._previewBtn.title=this.context.locale.tooltips.video.exitPreview,this._previewClickOff=t=>{!e.contains(t.target)&&!this._el.contains(t.target)&&this._exitPreview()},document.addEventListener(`mousedown`,this._previewClickOff,!0)}_exitPreview(){this._previewMode=!1;let e=this._active;if(e){let t=e.querySelector(`.an-video-shield`);t&&(t.style.display=``)}this._previewBtn.classList.remove(`an-link-tooltip-btn--copied`),this._previewBtn.title=this.context.locale.tooltips.video.previewVideo,this._previewClickOff&&=(document.removeEventListener(`mousedown`,this._previewClickOff,!0),null)}},J={rowAbove:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><path d="M12 3v7"/><path d="M9 7l3-4 3 4"/></svg>`,rowBelow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><path d="M12 12v7"/><path d="M9 17l3 4 3-4"/></svg>`,deleteRow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="15" y1="15" x2="21" y2="21"/><line x1="21" y1="15" x2="15" y2="21"/></svg>`,colLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><path d="M3 12h7"/><path d="M7 8l-4 4 4 4"/></svg>`,colRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><path d="M12 12h9"/><path d="M17 8l4 4-4 4"/></svg>`,deleteCol:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><line x1="15" y1="6" x2="21" y2="12"/><line x1="21" y1="6" x2="15" y2="12"/></svg>`,mergeCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="8" height="10" rx="1"/><rect x="14" y="7" width="8" height="10" rx="1"/><path d="M10 12h4"/><path d="M12 10l2 2-2 2"/></svg>`,unmergeCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="5" width="20" height="14" rx="1"/><line x1="12" y1="5" x2="12" y2="19" stroke-dasharray="2.5 2"/><line x1="2" y1="12" x2="22" y2="12" stroke-dasharray="2.5 2"/><path d="M9 9 L6 12 L9 15"/><path d="M15 9 L18 12 L15 15"/></svg>`,colWidth:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="4" x2="7" y2="20"/><line x1="17" y1="4" x2="17" y2="20"/><line x1="7" y1="12" x2="17" y2="12"/><path d="M10 9l-3 3 3 3"/><path d="M14 9l3 3-3 3"/></svg>`,rowHeight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="7" x2="20" y2="7"/><line x1="4" y1="17" x2="20" y2="17"/><line x1="12" y1="7" x2="12" y2="17"/><path d="M9 10l3-3 3 3"/><path d="M9 14l3 3 3-3"/></svg>`,tableBorder:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="3" y1="6" x2="21" y2="6" stroke-width="1"/><line x1="3" y1="13" x2="21" y2="13" stroke-width="2"/><line x1="3" y1="20" x2="21" y2="20" stroke-width="3"/></svg>`,deleteTable:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/><line x1="16" y1="16" x2="22" y2="22" stroke="#ef4444"/><line x1="22" y1="16" x2="16" y2="22" stroke="#ef4444"/></svg>`,selectCells:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4 L4 20 L9 15 L12 21 L14 20 L11 14 L17 14 Z" fill="currentColor" opacity="0.15"/><path d="M4 4 L4 20 L9 15 L12 21 L14 20 L11 14 L17 14 Z"/></svg>`,cellShade:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 11L8.93 3.36a1 1 0 0 0-1.29.08L3.22 7.8a1 1 0 0 0-.07 1.29L11 20"/><path d="m5 14 5-5"/><path d="M22 22a2 2 0 0 1-2 2h-3a2 2 0 0 1-2-2c0-1.5 2.5-5 3.5-5s3.5 3.5 3.5 5z"/></svg>`,borderColor:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="14" rx="1"/><line x1="3" y1="10" x2="21" y2="10" stroke-width="1.5"/><line x1="12" y1="3" x2="12" y2="17" stroke-width="1.5"/><path d="M3 21h18" stroke-width="3"/></svg>`,alignLeft:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="15" y1="12" x2="3" y2="12"/><line x1="17" y1="18" x2="3" y2="18"/></svg>`,alignCenter:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="17" y1="12" x2="7" y2="12"/><line x1="19" y1="18" x2="5" y2="18"/></svg>`,alignRight:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="9" y2="12"/><line x1="21" y1="18" x2="7" y2="18"/></svg>`,alignJustify:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="12" x2="3" y2="12"/><line x1="21" y1="18" x2="3" y2="18"/></svg>`,headerRow:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><rect x="3" y="3" width="18" height="8" rx="1" fill="currentColor" opacity="0.2"/><line x1="3" y1="11" x2="21" y2="11"/><line x1="3" y1="16" x2="21" y2="16"/><line x1="9" y1="11" x2="9" y2="21"/><line x1="15" y1="11" x2="15" y2="21"/></svg>`,sortAsc:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="6" x2="11" y2="6"/><line x1="4" y1="12" x2="11" y2="12"/><line x1="4" y1="18" x2="13" y2="18"/><path d="M15 9l3-3 3 3"/><line x1="18" y1="6" x2="18" y2="18"/></svg>`,sortDesc:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="6" x2="13" y2="6"/><line x1="4" y1="12" x2="11" y2="12"/><line x1="4" y1="18" x2="11" y2="18"/><path d="M15 15l3 3 3-3"/><line x1="18" y1="6" x2="18" y2="18"/></svg>`,exportCSV:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`,cellPadding:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><rect x="7" y="7" width="10" height="10" rx="0.5" stroke-dasharray="2 1.5"/></svg>`};function no(e){let t=e.closest(`tr`);if(!t)return-1;let n=0;for(let r of t.cells){if(r===e)return n;n+=r.colSpan||1}return-1}function Y(e,t){let n=0;for(let r of e.cells){if(n===t)return r;if(n>t)break;n+=r.colSpan||1}return null}function ro(e,t){let n=0;for(let r of e.cells)if(n+=r.colSpan||1,n>t){let e=r.nextElementSibling;return e?.tagName===`TD`||e?.tagName===`TH`?e:null}return null}function io(e){let t=Array.from(e.rows),n={},r=new WeakMap;return t.forEach((e,t)=>{n[t]||(n[t]={});let i=0;for(let a of e.cells){for(;n[t][i];)i++;let e=a.rowSpan||1,o=a.colSpan||1;r.set(a,{r:t,c:i,rs:e,cs:o});for(let r=0;r<e;r++){n[t+r]||(n[t+r]={});for(let e=0;e<o;e++)n[t+r][i+e]=a}i+=o}}),{gridMap:n,cellPos:r}}var ao=120,oo=200,so=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#cccccc`,`#efefef`,`#ffffff`,`#ff0000`,`#ff9900`,`#ffff00`,`#00ff00`,`#00ffff`,`#4a86e8`,`#9900ff`,`#ff00ff`,`#f4cccc`,`#fce5cd`,`#fff2cc`,`#d9ead3`,`#d0e0e3`,`#c9daf8`,`#d9d2e9`,`#ead1dc`],co=class{constructor(e){this.context=e,this._el=null,this._activeTable=null,this._activeCell=null,this._showTimer=null,this._hideTimer=null,this._disposers=[],this._sizePopover=null,this._sizeApply=null,this._sizeTitleEl=null,this._sizeInputEl=null,this._shadePopover=null,this._shadeTitleEl=null,this._shadeColorStrip=null,this._borderColorPopover=null,this._borderColorTitleEl=null,this._borderColorStrip=null,this._borderColorNoBtn=null,this._selectMode=!1,this._selectedCells=[],this._selectStart=null,this._selectDragging=!1,this._selectBtn=null,this._editable=null}initialize(){this._el=this._buildTooltip(),b(this.context).appendChild(this._el),this._sizePopover=this._buildSizePopover(),b(this.context).appendChild(this._sizePopover),this._shadePopover=this._buildCellShadePopover(),b(this.context).appendChild(this._shadePopover),this._borderColorPopover=this._buildBorderColorPopover(),b(this.context).appendChild(this._borderColorPopover);let e=this.context.layoutInfo.editable;return this._editable=e,this._disposers.push(v(e,`mousedown`,t=>{if(!this._selectMode)return;let n=t.target.closest(`td, th`);!n||!e.contains(n)||n.style.cursor!==`col-resize`&&n.style.cursor!==`row-resize`&&(t.preventDefault(),this._activeTable=n.closest(`table`),this._selectStart=n,this._selectDragging=!0,this._setSelection([n]))}),v(e,`mousemove`,t=>{if(!this._selectMode||!this._selectDragging||!this._selectStart)return;let n=t.target.closest(`td, th`);!n||!e.contains(n)||n.closest(`table`)===this._activeTable&&this._setSelection(this._getRectCells(this._selectStart,n))}),v(document,`mouseup`,()=>{this._selectDragging=!1}),v(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`table`);if(n&&e.contains(n)){let e=t.target?.closest(`td, th`);e&&(this._activeCell=e,this._syncShadeStrip()),this._scheduleShow(n)}},{passive:!0}),v(e,`mouseout`,t=>{if(this._selectMode)return;let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n)&&!this._sizePopover?.contains(n))&&this._scheduleHide()},{passive:!0}),v(document,`click`,e=>{let t=e.target;this._selectMode&&this._activeTable?.contains(t)||this._activeTable&&!this._activeTable.contains(t)&&!this._el.contains(t)&&!this._sizePopover?.contains(t)&&!this._shadePopover?.contains(t)&&!this._borderColorPopover?.contains(t)&&this._hide()}),v(document,`selectionchange`,()=>this._syncShadeStrip()),v(globalThis,`scroll`,()=>this._hide(),{passive:!0}),v(globalThis,`resize`,()=>this._hide(),{passive:!0})),this._initResize(),this}_initResize(){let e=this.context.layoutInfo.editable,t=null,n=null,r=!1,i=null,a=0,o=0,s=0,c=0,l=-1,u=null,d=null,f=null,p=null,m=null,h=()=>{t&&=(t.style.cursor=``,null),n=null};this._disposers.push(v(e,`mousemove`,i=>{if(r)return;if(this.context.layoutInfo.container.classList.contains(`an-disabled`)){h();return}if(m!==null)return;let a=i.target,o=i.clientX,s=i.clientY;m=requestAnimationFrame(()=>{m=null;let r=a.closest(`td, th`);if(!r||!e.contains(r)){h();return}t&&t!==r&&(t.style.cursor=``);let i=r.getBoundingClientRect(),c=Math.abs(o-i.right)<6,l=Math.abs(s-i.bottom)<6;c?(r.style.cursor=`col-resize`,t=r,n=`col`):l?(r.style.cursor=`row-resize`,t=r,n=`row`):h()})}),v(e,`mousedown`,e=>{if(!this.context.layoutInfo.container.classList.contains(`an-disabled`)&&!(!t||!n)){if(r=!0,i=n,a=e.clientX,o=e.clientY,f=t.closest(`table`),i===`col`)l=no(t)+(t.colSpan||1)-1,u=l>=0?Array.from(f.querySelectorAll(`tr`)).map(e=>Y(e,l)).filter(Boolean).filter(e=>(e.colSpan||1)===1):[],s=u.length>0?u[0].offsetWidth:Math.max(30,Math.round(t.offsetWidth/(t.colSpan||1))),document.body.style.cursor=`col-resize`;else{let e=t.closest(`tr`),n=(e?Array.from(f.rows).indexOf(e):0)+(t.rowSpan||1)-1;d=f.rows[n]||e,c=d?d.offsetHeight:40,document.body.style.cursor=`row-resize`}document.body.style.userSelect=`none`,e.preventDefault(),e.stopPropagation()}}),v(document,`mousemove`,e=>{if(!r||p!==null)return;let t=e.clientX,n=e.clientY;p=requestAnimationFrame(()=>{if(p=null,i===`col`){let e=Math.max(30,s+(t-a));for(let t of u)t.style.width=`${e}px`,t.style.minWidth=`${e}px`}else{let e=Math.max(20,c+(n-o));if(d)for(let t of d.cells)t.style.height=`${e}px`,t.style.minHeight=`${e}px`}})}),v(document,`mouseup`,()=>{r&&(p!==null&&(cancelAnimationFrame(p),p=null),r=!1,document.body.style.userSelect=``,document.body.style.cursor=``,i=null,f=null,d=null,l=-1,u=null,this.context.invoke(`editor.afterCommand`))}))}destroy(){this._clearTimers(),this._disposers.forEach(e=>e()),this._disposers=[],this._el?.parentNode&&this._el.remove(),this._el=null,this._sizePopover?.parentNode&&this._sizePopover.remove(),this._sizePopover=null,this._shadePopover?.parentNode&&this._shadePopover.remove(),this._shadePopover=null,this._borderColorPopover?.parentNode&&this._borderColorPopover.remove(),this._borderColorPopover=null}_buildTooltip(){let e=this.context.locale.tooltips.table,t=h(`div`,{class:`an-link-tooltip an-table-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});t.style.display=`none`,this._label=h(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(this._sep()),this._selectBtn=this._makeBtn(J.selectCells,e.selectCells,()=>this._toggleSelectMode()),t.appendChild(this._selectBtn),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.rowAbove,e.addRowAbove,()=>this._addRow(`above`))),t.appendChild(this._makeBtn(J.rowBelow,e.addRowBelow,()=>this._addRow(`below`))),t.appendChild(this._makeBtn(J.deleteRow,e.deleteRow,()=>this._deleteRow())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.colLeft,e.addColumnLeft,()=>this._addColumn(`left`))),t.appendChild(this._makeBtn(J.colRight,e.addColumnRight,()=>this._addColumn(`right`))),t.appendChild(this._makeBtn(J.deleteCol,e.deleteColumn,()=>this._deleteColumn())),t.appendChild(this._makeBtn(J.sortAsc,e.sortAsc,()=>this._sortColumn(`asc`))),t.appendChild(this._makeBtn(J.sortDesc,e.sortDesc,()=>this._sortColumn(`desc`))),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.mergeCells,e.mergeCells,()=>this._mergeCells())),t.appendChild(this._makeBtn(J.unmergeCells,e.unmergeCells,()=>this._unmergeCells())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.alignLeft,e.cellAlignLeft,()=>this._applyCellAlign(`left`))),t.appendChild(this._makeBtn(J.alignCenter,e.cellAlignCenter,()=>this._applyCellAlign(`center`))),t.appendChild(this._makeBtn(J.alignRight,e.cellAlignRight,()=>this._applyCellAlign(`right`))),t.appendChild(this._makeBtn(J.alignJustify,e.cellAlignJustify,()=>this._applyCellAlign(`justify`))),t.appendChild(this._makeBtn(J.headerRow,e.toggleHeaderRow,()=>this._toggleHeaderRow())),t.appendChild(this._sep());let n=h(`button`,{type:`button`,class:`an-link-tooltip-btn an-link-tooltip-btn--shade`,title:e.cellBackground}),r=h(`span`,{class:`an-bubble-btn-svg`});r.innerHTML=J.cellShade;let i=h(`span`,{class:`an-link-tooltip-color-strip`});n.appendChild(r),n.appendChild(i),this._shadeColorStrip=i,this._disposers.push(v(n,`click`,e=>{e.preventDefault(),e.stopPropagation(),this._openCellShadePopover()})),t.appendChild(n),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.colWidth,e.columnWidth,()=>this._openSizePopover(`col`))),t.appendChild(this._makeBtn(J.rowHeight,e.rowHeight,()=>this._openSizePopover(`row`))),t.appendChild(this._makeBtn(J.tableBorder,e.tableBorderWidth,()=>this._openSizePopover(`border`))),t.appendChild(this._makeBtn(J.cellPadding,e.cellPadding,()=>this._openSizePopover(`cellPadding`)));let a=h(`button`,{type:`button`,class:`an-link-tooltip-btn an-link-tooltip-btn--shade`,title:e.tableBorderColor}),o=h(`span`,{class:`an-bubble-btn-svg`});o.innerHTML=J.borderColor;let s=h(`span`,{class:`an-link-tooltip-color-strip`});return a.appendChild(o),a.appendChild(s),this._borderColorStrip=s,this._disposers.push(v(a,`click`,e=>{e.preventDefault(),e.stopPropagation(),this._openBorderColorPopover()})),t.appendChild(a),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.deleteTable,e.deleteTable,()=>this._deleteTable(),!0)),t.appendChild(this._sep()),t.appendChild(this._makeBtn(J.exportCSV,e.exportCSV,()=>this._exportTableCSV())),this._disposers.push(v(t,`mouseenter`,()=>this._clearTimers()),v(t,`mouseleave`,()=>{this._selectMode||this._sizePopover&&this._sizePopover.style.display!==`none`||this._shadePopover&&this._shadePopover.style.display!==`none`||this._borderColorPopover&&this._borderColorPopover.style.display!==`none`||this._scheduleHide()})),t}_sep(){return h(`div`,{class:`an-link-tooltip-sep`})}_makeBtn(e,t,n,r=!1){let i=h(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(v(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){(this._activeTable!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._activeTable=e,this._show()},ao))}_scheduleHide(){clearTimeout(this._showTimer),this._showTimer=null,!this._hideTimer&&(this._hideTimer=setTimeout(()=>this._hide(),oo))}_show(){this._activeTable&&(this._el.style.display=`flex`,this._syncShadeStrip(),this._syncBorderColorStrip(),requestAnimationFrame(()=>{this._activeTable&&this._positionNear(this._activeTable)}))}_syncShadeStrip(){if(!this._shadeColorStrip||!this._el||this._el.style.display===`none`)return;let e=this._getCell();this._shadeColorStrip.style.background=e?.style.backgroundColor||`transparent`}_hide(){this._el.style.display=`none`,this._activeTable=null,this._activeCell=null,this._selectMode&&(this._selectMode=!1,this._selectBtn&&this._selectBtn.classList.remove(`an-link-tooltip-btn--active`),this._editable&&this._editable.classList.remove(`an-table-select-mode`)),this._clearSelection(),this._clearTimers(),this._hideSizePopover(),this._hideBorderColorPopover()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){if(!e)return;let t=e.getBoundingClientRect(),n=this._el.offsetWidth||400,r=this._el.offsetHeight||30,i=t.left+(t.width-n)/2,a=t.top-r-6;a<6&&(a=t.bottom+6),i+n>globalThis.innerWidth-6&&(i=globalThis.innerWidth-n-6),i<6&&(i=6),this._el.style.left=`${i}px`,this._el.style.top=`${a}px`}_getCell(){let e=globalThis.getSelection();if(e?.rangeCount){let t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===3&&(t=t.parentElement);let n=t?.closest(`td, th`);if(n&&this._activeTable?.contains(n))return n}return this._activeCell||this._activeTable?.querySelector(`td, th`)}_toggleSelectMode(){this._selectMode=!this._selectMode,this._selectBtn&&this._selectBtn.classList.toggle(`an-link-tooltip-btn--active`,this._selectMode),this._editable&&this._editable.classList.toggle(`an-table-select-mode`,this._selectMode),this._selectMode||this._clearSelection()}_clearSelection(){this._selectedCells.forEach(e=>e.classList.remove(`an-cell-selected`)),this._selectedCells=[],this._selectStart=null}_setSelection(e){this._selectedCells.forEach(t=>{e.includes(t)||t.classList.remove(`an-cell-selected`)}),this._selectedCells=e,e.forEach(e=>e.classList.add(`an-cell-selected`))}_getRectCells(e,t){if(!e)return[];if(!t||e===t)return[e];let n=e.closest(`table`);if(!n?.contains(t))return[e];let{gridMap:r,cellPos:i}=io(n),a=i.get(e),o=i.get(t);if(!a||!o)return[e];let s=Math.min(a.r,o.r),c=Math.max(a.r+a.rs-1,o.r+o.rs-1),l=Math.min(a.c,o.c),u=Math.max(a.c+a.cs-1,o.c+o.cs-1),d=!0;for(;d;){d=!1;for(let e=s;e<=c;e++){let t=r[e];if(t)for(let e=l;e<=u;e++){let n=t[e];if(!n)continue;let r=i.get(n);r&&(r.r<s&&(s=r.r,d=!0),r.r+r.rs-1>c&&(c=r.r+r.rs-1,d=!0),r.c<l&&(l=r.c,d=!0),r.c+r.cs-1>u&&(u=r.c+r.cs-1,d=!0))}}}let f=new Set,p=[];for(let e=s;e<=c;e++){let t=r[e];if(t)for(let e=l;e<=u;e++){let n=t[e];n&&!f.has(n)&&(f.add(n),p.push(n))}}return p.length>0?p:[e]}_getSelectedCells(){return this._selectedCells.length>0?this._selectedCells:[this._getCell()].filter(Boolean)}_addRow(e){let t=this._getSelectedCells();if(!t.length)return;let n=t[0].closest(`table`);if(!n)return;let r=Array.from(n.querySelectorAll(`tr`)),i=[...new Set(t.map(e=>e.closest(`tr`)).filter(Boolean))],a=i.reduce((t,n)=>{let i=r.indexOf(t),a=r.indexOf(n);return e===`above`?a<i?n:t:a>i?n:t},i[0]),o=Array.from(a.cells).reduce((e,t)=>e+(t.colSpan||1),0),s=document.createElement(`tr`),c=Array.from(a.cells);for(let e=0;e<o;e++){let t=h(`td`,{},[`\xA0`]),n=c[e];n?.style.width&&(t.style.width=n.style.width),n?.style.minWidth&&(t.style.minWidth=n.style.minWidth),s.appendChild(t)}e===`above`?a.parentElement?.insertBefore(s,a):a.after(s),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_addColumn(e){let t=this._getSelectedCells();if(!t.length)return;let n=t[0].closest(`table`);if(!n)return;let r=t.map(e=>no(e)),i=e===`left`?Math.min(...r):Math.max(...r),a=Array.from(n.querySelectorAll(`tr`)),o=a.map(t=>e===`left`?Y(t,i):ro(t,i)),s=a.map(e=>e.closest(`thead`)!==null);a.forEach((e,t)=>{e.insertBefore(h(s[t]?`th`:`td`,{},[`\xA0`]),o[t])}),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_deleteRow(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=t.querySelector(`tbody`),r=n?n.querySelectorAll(`tr`).length:t.querySelectorAll(`tr`).length,i=[...new Set(e.map(e=>e.closest(`tr`)).filter(Boolean))];i.filter(e=>e.closest(`tbody`)).length>=r||(this._activeCell=null,this._clearSelection(),i.forEach(e=>e.remove()),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`))}_deleteColumn(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=Array.from(t.querySelectorAll(`tr`));if(n[0]&&n[0].cells.length<=1)return;let r=[...new Set(e.map(e=>no(e)))];if(r.length>=(n[0]?.cells.length??1))return;let i=[];r.forEach(e=>{n.forEach(t=>{let n=Y(t,e);n&&i.push(n)})}),this._activeCell=null,this._clearSelection(),i.forEach(e=>e.remove()),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`)}_mergeCells(){let e=this._getCell();if(!e)return;let t=e.closest(`table`);if(!t)return;let n=this._getSelectedCells().filter(e=>t.contains(e));if(n.length<2){let e=globalThis.getSelection();if(!e||e.rangeCount===0)return;let r=e.getRangeAt(0);if(n=Array.from(t.querySelectorAll(`td, th`)).filter(e=>{try{return r.intersectsNode(e)}catch{return!1}}),n.length<2)return}let{gridMap:r,cellPos:i}=io(t),a=1/0,o=-1/0,s=1/0,c=-1/0;if(n.forEach(e=>{let t=i.get(e);t&&(t.r<a&&(a=t.r),t.r+t.rs-1>o&&(o=t.r+t.rs-1),t.c<s&&(s=t.c),t.c+t.cs-1>c&&(c=t.c+t.cs-1))}),a===1/0)return;let l=new Set,u=[];for(let e=a;e<=o;e++){let t=r[e];if(t)for(let e=s;e<=c;e++){let n=t[e];n&&!l.has(n)&&(l.add(n),u.push(n))}}if(u.length<2)return;let d=u[0];d.colSpan=c-s+1,d.rowSpan=o-a+1,d.style.verticalAlign=`middle`,d.style.height=``,d.style.minHeight=``;let f=u.map(e=>e.innerHTML.replace(/^(<br\s*\/?>|\s)+$/i,``).trim()).filter(e=>e!==``);d.innerHTML=f.length?f.join(`<br>`):`<br>`,u.slice(1).forEach(e=>{let t=e.parentElement;e.remove(),t&&t.cells.length===0&&t.remove()}),this._clearSelection(),this.context.invoke(`editor.afterCommand`)}_deleteTable(){let e=this._activeTable;e&&(this._hide(),e.parentNode&&e.remove(),this.context.invoke(`editor.afterCommand`))}_unmergeCells(){let e=this._getSelectedCells();if(!e.length)return;let t=e[0].closest(`table`);if(!t)return;let n=e.filter(e=>t.contains(e)&&((e.colSpan||1)>1||(e.rowSpan||1)>1));n.length&&(n.forEach(e=>{t.contains(e)&&this._unmergeOne(e,t)}),this._clearSelection(),requestAnimationFrame(()=>this._positionNear(this._activeTable)),this.context.invoke(`editor.afterCommand`))}_unmergeOne(e,t){let n=e.colSpan||1,r=e.rowSpan||1;if(n===1&&r===1)return;let{cellPos:i}=io(t),a=i.get(e);if(!a)return;let{r:o,c:s}=a,c=Array.from(t.rows),l=e.tagName.toLowerCase();if(e.rowSpan=1,e.colSpan=1,e.style.verticalAlign=``,n>1){let t=e.nextElementSibling;for(let e=1;e<n;e++)c[o].insertBefore(h(l,{},[`\xA0`]),t)}for(let e=1;e<r;e++){let t=c[o+e];if(!t)continue;let r=null;for(let e of t.cells)if(i.get(e)?.c>s){r=e;break}for(let e=0;e<n;e++)t.insertBefore(h(l,{},[`\xA0`]),r)}}_buildSizePopover(){let e=h(`div`,{class:`an-size-popover`});e.style.display=`none`;let t=h(`div`,{class:`an-size-popover-title`}),n=h(`div`,{class:`an-size-popover-body`}),r=h(`input`,{type:`number`,class:`an-size-input`,min:`1`,max:`2000`,step:`1`}),i=h(`span`,{class:`an-size-unit`},[`px`]);n.appendChild(r),n.appendChild(i);let a=h(`div`,{class:`an-size-popover-actions`}),o=h(`button`,{type:`button`,class:`an-btn`});o.textContent=this.context.locale.tooltips.table.cancelBtn;let s=h(`button`,{type:`button`,class:`an-btn an-btn-primary`});s.textContent=this.context.locale.tooltips.table.applyBtn,a.appendChild(o),a.appendChild(s),e.appendChild(t),e.appendChild(n),e.appendChild(a),this._sizeTitleEl=t,this._sizeInputEl=r,this._sizeApply=null;let c=v(s,`click`,()=>{let e=Number.parseInt(this._sizeInputEl.value,10);e>=0&&typeof this._sizeApply==`function`&&this._sizeApply(e),this._hideSizePopover()}),l=v(o,`click`,()=>this._hideSizePopover()),u=v(r,`keydown`,e=>{let t=e;t.key===`Enter`&&(e.preventDefault(),s.click()),t.key===`Escape`&&this._hideSizePopover()}),d=v(document,`click`,e=>{let t=e.target;this._sizePopover&&this._sizePopover.style.display!==`none`&&!this._sizePopover.contains(t)&&!this._el.contains(t)&&this._hideSizePopover()}),f=v(e,`mouseenter`,()=>this._clearTimers()),p=v(e,`mouseleave`,()=>this._scheduleHide());return this._disposers.push(c,l,u,d,f,p),e}_openSizePopover(e){let t=this._getCell();if(!(!t||!this._sizePopover)){if(e===`border`){let e=t.closest(`table`);if(!e)return;let n=e.querySelector(`td, th`),r=n&&(Number.parseInt(n.style.borderWidth,10)||Number.parseInt(globalThis.getComputedStyle(n).borderWidth,10))||1;this._sizeTitleEl.textContent=this.context.locale.tooltips.table.tableBorderWidthPx,this._sizeInputEl.min=`0`,this._sizeInputEl.max=`10`,this._sizeInputEl.value=String(r),this._sizeApply=t=>{let n=Array.from(e.querySelectorAll(`td, th`));t===0?n.forEach(e=>{e.style.borderWidth=`0`,e.style.borderStyle=`none`}):n.forEach(e=>{e.style.borderWidth=`${t}px`,e.style.borderStyle=`solid`}),this.context.invoke(`editor.afterCommand`)}}else if(e===`cellPadding`){let e=this._getSelectedCells()[0]||this._getCell(),t=e&&(Number.parseInt(e.style.padding,10)||Number.parseInt(e.style.paddingTop,10))||4;this._sizeTitleEl.textContent=this.context.locale.tooltips.table.cellPaddingPx,this._sizeInputEl.min=`0`,this._sizeInputEl.max=`40`,this._sizeInputEl.value=String(t),this._sizeApply=e=>{this._getSelectedCells().forEach(t=>{t&&(t.style.padding=`${e}px`)}),this.context.invoke(`editor.afterCommand`)}}else{let n=e===`col`,r=this._getSelectedCells().filter(e=>{let n=e.closest(`table`);return n&&n===t.closest(`table`)});if(this._sizeTitleEl.textContent=n?this.context.locale.tooltips.table.columnWidthPx:this.context.locale.tooltips.table.rowHeightPx,this._sizeInputEl.min=`1`,this._sizeInputEl.max=`2000`,n)this._sizeInputEl.value=t.offsetWidth||120;else{let e=t.closest(`tr`);this._sizeInputEl.value=e&&e.offsetHeight||40}this._sizeApply=e=>{let i=t.closest(`table`);if(i){if(n){let t=[...new Set(r.map(e=>no(e)))],n=Array.from(i.querySelectorAll(`tr`));t.forEach(t=>{n.forEach(n=>{let r=Y(n,t);r&&(r.colSpan||1)===1&&(r.style.width=`${e}px`,r.style.minWidth=`${e}px`)})})}else[...new Set(r.map(e=>e.closest(`tr`)).filter(Boolean))].forEach(t=>{for(let n of t.cells)n.style.height=`${e}px`,n.style.minHeight=`${e}px`});this.context.invoke(`editor.afterCommand`)}}}this._sizePopover.style.display=`block`,requestAnimationFrame(()=>{if(!this._sizePopover||!this._el)return;let e=this._el.getBoundingClientRect(),t=this._sizePopover.offsetWidth||220,n=this._sizePopover.offsetHeight||110,r=e.left,i=e.bottom+6;r+t>globalThis.innerWidth-8&&(r=globalThis.innerWidth-t-8),i+n>globalThis.innerHeight-8&&(i=e.top-n-6),this._sizePopover.style.left=`${r}px`,this._sizePopover.style.top=`${i}px`,this._sizeInputEl&&(this._sizeInputEl.focus(),this._sizeInputEl.select())})}}_hideSizePopover(){this._sizePopover&&(this._sizePopover.style.display=`none`),this._sizeApply=null}_buildColorPopover({defaultColor:e,apply:t,getPopover:n,hide:r}){let i=h(`div`,{class:`an-cell-shade-popover`});i.style.display=`none`;let a=h(`div`,{class:`an-size-popover-title`});i.appendChild(a);let o=h(`div`,{class:`an-context-color-palette`});so.forEach(e=>{let n=h(`div`,{class:`an-context-color-swatch`,title:e});n.style.background=e,this._disposers.push(v(n,`click`,n=>{n.stopPropagation(),t(e)})),o.appendChild(n)}),i.appendChild(o);let s=h(`div`,{class:`an-context-color-custom`}),c=h(`button`,{type:`button`,class:`an-shade-no-color`});this._disposers.push(v(c,`click`,()=>t(``))),s.appendChild(c),i.appendChild(s);let l=h(`div`,{class:`an-context-color-custom`}),u=h(`input`,{type:`color`,class:`an-shade-color-input`,value:e}),d=h(`span`);return d.textContent=this.context.locale.contextMenu.customColorLabel,this._disposers.push(v(u,`change`,()=>t(u.value))),l.appendChild(u),l.appendChild(d),i.appendChild(l),this._disposers.push(v(i,`mousedown`,e=>e.preventDefault()),v(i,`mouseenter`,()=>this._clearTimers()),v(i,`mouseleave`,()=>this._scheduleHide()),v(document,`click`,e=>{let t=e.target,i=n();i&&i.style.display!==`none`&&!i.contains(t)&&!this._el?.contains(t)&&r()})),{el:i,titleEl:a,noColorBtn:c}}_showColorPopover(e){let t=e();t&&(t.style.display=`block`,requestAnimationFrame(()=>{let t=e();if(!t||!this._el)return;let n=t.offsetWidth||170,r=t.offsetHeight||120,i=this._el.getBoundingClientRect(),a=i.left,o=i.bottom+6;a+n>globalThis.innerWidth-8&&(a=globalThis.innerWidth-n-8),o+r>globalThis.innerHeight-8&&(o=i.top-r-6),t.style.left=`${Math.max(8,a)}px`,t.style.top=`${Math.max(8,o)}px`}))}_buildCellShadePopover(){let{el:e,titleEl:t,noColorBtn:n}=this._buildColorPopover({defaultColor:`#ffffff`,apply:e=>this._applyCellShade(e),getPopover:()=>this._shadePopover,hide:()=>this._hideCellShadePopover()});return this._shadeTitleEl=t,this._shadeNoBtn=n,e}_openCellShadePopover(){if(!this._shadePopover)return;let e=this.context.locale.tooltips.table;this._shadeTitleEl&&(this._shadeTitleEl.textContent=e.cellBackground),this._shadeNoBtn&&(this._shadeNoBtn.textContent=e.noShading),this._showColorPopover(()=>this._shadePopover)}_hideCellShadePopover(){this._shadePopover&&(this._shadePopover.style.display=`none`)}_applyCellShade(e){(this._selectMode?this._selectedCells:[this._getCell()]).forEach(t=>{t&&(t.style.backgroundColor=e)}),this._shadeColorStrip&&(this._shadeColorStrip.style.background=e||`transparent`),this._hideCellShadePopover(),this.context.invoke(`editor.afterCommand`)}_buildBorderColorPopover(){let{el:e,titleEl:t,noColorBtn:n}=this._buildColorPopover({defaultColor:`#000000`,apply:e=>this._applyBorderColor(e),getPopover:()=>this._borderColorPopover,hide:()=>this._hideBorderColorPopover()});return this._borderColorTitleEl=t,this._borderColorNoBtn=n,e}_openBorderColorPopover(){if(!this._borderColorPopover)return;let e=this.context.locale.tooltips.table;this._borderColorTitleEl&&(this._borderColorTitleEl.textContent=e.tableBorderColor),this._borderColorNoBtn&&(this._borderColorNoBtn.textContent=e.noBorderColor),this._showColorPopover(()=>this._borderColorPopover)}_hideBorderColorPopover(){this._borderColorPopover&&(this._borderColorPopover.style.display=`none`)}_applyBorderColor(e){let t=this._activeTable;t&&(Array.from(t.querySelectorAll(`td, th`)).forEach(t=>{t.style.borderColor=e}),this._borderColorStrip&&(this._borderColorStrip.style.background=e||`transparent`),this._hideBorderColorPopover(),this.context.invoke(`editor.afterCommand`))}_syncBorderColorStrip(){if(!this._borderColorStrip||!this._el||this._el.style.display===`none`)return;let e=this._activeTable?.querySelector(`td, th`);this._borderColorStrip.style.background=e?.style.borderColor||`transparent`}_applyCellAlign(e){this._getSelectedCells().forEach(t=>{t&&(t.style.textAlign=e)}),this.context.invoke(`editor.afterCommand`)}_toggleHeaderRow(){let e=this._activeTable;if(!e)return;let t=e.querySelector(`tr`);if(t){if(t.closest(`thead`)!==null){let n=e.querySelector(`tbody`);n||(n=document.createElement(`tbody`),e.appendChild(n)),Array.from(t.cells).forEach(e=>{let n=document.createElement(`td`);n.innerHTML=e.innerHTML,n.style.cssText=e.style.cssText,t.replaceChild(n,e)}),n.insertBefore(t,n.firstChild);let r=e.querySelector(`thead`);r&&r.rows.length===0&&r.remove()}else{let n=e.querySelector(`thead`);n||(n=document.createElement(`thead`),e.insertBefore(n,e.firstChild)),Array.from(t.cells).forEach(e=>{let n=document.createElement(`th`);n.innerHTML=e.innerHTML,n.style.cssText=e.style.cssText,t.replaceChild(n,e)}),n.appendChild(t)}this.context.invoke(`editor.afterCommand`)}}_sortColumn(e){let t=this._activeTable;if(!t)return;let n=this._getCell();if(!n)return;let r=no(n);if(r===-1)return;let i=t.querySelector(`tbody`)||t,a=Array.from(i.querySelectorAll(`:scope > tr`));a.length<2||(a.sort((t,n)=>{let i=Y(t,r),a=Y(n,r),o=(i?.textContent||``).trim(),s=(a?.textContent||``).trim(),c=parseFloat(o),l=parseFloat(s);return!isNaN(c)&&!isNaN(l)?e===`asc`?c-l:l-c:e===`asc`?o.localeCompare(s):s.localeCompare(o)}),a.forEach(e=>i.appendChild(e)),this._markSortIndicator(t,r,e),this.context.invoke(`editor.afterCommand`))}_markSortIndicator(e,t,n){let r=e.querySelector(`thead`);if(!r)return;r.querySelectorAll(`.an-sort-asc, .an-sort-desc`).forEach(e=>{e.classList.remove(`an-sort-asc`,`an-sort-desc`)});let i=r.querySelector(`tr`);if(!i)return;let a=Y(i,t);a&&a.classList.add(n===`asc`?`an-sort-asc`:`an-sort-desc`)}_exportTableCSV(){let e=this._activeTable;if(!e)return;let t=Array.from(e.querySelectorAll(`tr`)).map(e=>Array.from(e.querySelectorAll(`td, th`)).map(e=>`"${(e.textContent||``).trim().replace(/"/g,`""`)}"`).join(`,`)).join(`
44
+ `),n=new Blob([``+t],{type:`text/csv;charset=utf-8;`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`table.csv`,i.style.display=`none`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}};function lo(e,t={}){t.cspNonce&&(e.nonce=t.cspNonce);let n=t.externalAssetCrossOrigin??`anonymous`,r=t.externalAssetReferrerPolicy??`no-referrer`;return n&&(e.crossOrigin=n),r&&(e.referrerPolicy=r),e}var uo=100,fo=180,po=/language-(\S+)/,mo={copy:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`,wrapOn:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><path d="M3 12h15a3 3 0 0 1 0 6H3"/><polyline points="6 15 3 18 6 21"/></svg>`,toParagraph:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 4v16"/><path d="M17 4v16"/><path d="M9 4h8a4 4 0 0 1 0 8H9V4z"/></svg>`,deleteCode:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>`,lineNumbers:`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-2-2-2"/></svg>`},ho=[[``,`Plain text`],[`javascript`,`JavaScript`],[`typescript`,`TypeScript`],[`python`,`Python`],[`html`,`HTML`],[`css`,`CSS`],[`scss`,`SCSS`],[`json`,`JSON`],[`yaml`,`YAML`],[`markdown`,`Markdown`],[`xml`,`XML`],[`bash`,`Bash / Shell`],[`sql`,`SQL`],[`java`,`Java`],[`csharp`,`C#`],[`php`,`PHP`],[`ruby`,`Ruby`],[`go`,`Go`],[`rust`,`Rust`],[`cpp`,`C++`],[`c`,`C`],[`kotlin`,`Kotlin`],[`swift`,`Swift`]];function go(e,t){[...e.classList].forEach(t=>{t.startsWith(`language-`)&&e.classList.remove(t)}),t&&e.classList.add(`language-${t}`)}var _o=class{constructor(e){this.context=e,this._el=null,this._activePre=null,this._showTimer=null,this._hideTimer=null,this._disposers=[],this._copyBtn=null,this._wrapBtn=null,this._lineNumbersBtn=null,this._langSelect=null,this._prismScript=null,this._asyncDisposers=[]}initialize(){this._el=this._buildTooltip(),b(this.context).appendChild(this._el),this._ensurePrism();let e=this.context.layoutInfo.editable;return this._disposers.push(v(e,`mouseover`,t=>{if(this.context.layoutInfo.container.classList.contains(`an-disabled`))return;let n=t.target?.closest(`pre`);n&&e.contains(n)&&this._scheduleShow(n)}),v(e,`mouseout`,t=>{let n=t.relatedTarget;(!n||!e.contains(n)&&!this._el.contains(n))&&this._scheduleHide()}),v(document,`click`,e=>{let t=e.target;this._activePre&&!this._activePre.contains(t)&&!this._el.contains(t)&&this._hide()})),this}destroy(){this._clearTimers(),this._asyncDisposers.forEach(e=>e()),this._asyncDisposers=[],this._disposers.forEach(e=>e()),this._disposers=[],this._el?.remove(),this._el=null}_buildTooltip(){let e=this.context.locale.tooltips.code,t=h(`div`,{class:`an-link-tooltip an-code-tooltip`,role:`toolbar`,"aria-label":e.ariaLabel});return t.style.display=`none`,this._label=h(`span`,{class:`an-link-tooltip-url`}),this._label.textContent=e.label,t.appendChild(this._label),t.appendChild(this._sep()),this._langSelect=h(`select`,{class:`an-code-lang-select`,title:e.syntaxLanguage,"aria-label":e.syntaxAriaLabel}),ho.forEach(([e,t])=>{let n=h(`option`,{value:e});n.textContent=t,this._langSelect.appendChild(n)}),this._disposers.push(v(this._langSelect,`change`,()=>this._onLangChange())),t.appendChild(this._langSelect),t.appendChild(this._sep()),this._copyBtn=this._makeBtn(mo.copy,e.copyCode,()=>this._copyCode()),t.appendChild(this._copyBtn),t.appendChild(this._sep()),this._wrapBtn=this._makeBtn(mo.wrapOn,e.toggleWordWrap,()=>this._toggleWrap()),t.appendChild(this._wrapBtn),this._lineNumbersBtn=this._makeBtn(mo.lineNumbers,e.lineNumbers,()=>this._toggleLineNumbers()),t.appendChild(this._lineNumbersBtn),t.appendChild(this._sep()),t.appendChild(this._makeBtn(mo.toParagraph,e.convertToParagraph,()=>this._toParagraph())),t.appendChild(this._sep()),t.appendChild(this._makeBtn(mo.deleteCode,e.deleteCodeBlock,()=>this._delete(),!0)),this._disposers.push(v(t,`mouseenter`,()=>this._clearTimers()),v(t,`mouseleave`,()=>this._scheduleHide())),t}_sep(){return h(`div`,{class:`an-link-tooltip-sep`})}_makeBtn(e,t,n,r=!1){let i=h(`button`,{type:`button`,class:r?`an-link-tooltip-btn an-link-tooltip-btn--danger`:`an-link-tooltip-btn`,title:t});return i.innerHTML=e,this._disposers.push(v(i,`click`,e=>{e.preventDefault(),e.stopPropagation(),n()})),i}_scheduleShow(e){(this._activePre!==e||this._el.style.display===`none`)&&(clearTimeout(this._hideTimer),this._hideTimer=null,clearTimeout(this._showTimer),this._showTimer=setTimeout(()=>{this._activePre=e,this._syncWrapBtn(),this._syncLineNumbersBtn(),this._syncLangSelect(),this._show(e)},uo))}_scheduleHide(){clearTimeout(this._showTimer),this._showTimer=null,clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>this._hide(),fo)}_show(e){this._el.style.display=`flex`,this._positionNear(e)}_hide(){this._el.style.display=`none`,this._activePre=null,this._clearTimers()}_clearTimers(){clearTimeout(this._showTimer),clearTimeout(this._hideTimer),this._showTimer=null,this._hideTimer=null}_positionNear(e){let t=e.getBoundingClientRect(),n=this._el.offsetWidth||260,r=this._el.offsetHeight||32,i=t.top-r-6,a=t.left+(t.width-n)/2;i<6&&(i=t.bottom+6),a+n>globalThis.innerWidth-6&&(a=globalThis.innerWidth-n-6),a<6&&(a=6),this._el.style.top=`${i}px`,this._el.style.left=`${a}px`}_syncWrapBtn(){if(!this._activePre||!this._wrapBtn)return;let e=(this._activePre.style.whiteSpace||``).includes(`pre-wrap`)||globalThis.getComputedStyle(this._activePre).whiteSpace===`pre-wrap`;this._wrapBtn.classList.toggle(`active`,e),this._wrapBtn.title=e?this.context.locale.tooltips.code.disableWordWrap:this.context.locale.tooltips.code.enableWordWrap}_syncLineNumbersBtn(){if(!this._activePre||!this._lineNumbersBtn)return;let e=this._activePre.classList.contains(`an-code-line-numbers`);this._lineNumbersBtn.classList.toggle(`active`,e),this._lineNumbersBtn.title=this.context.locale.tooltips.code.lineNumbers}_syncLangSelect(){if(!this._activePre||!this._langSelect)return;let e=this._activePre.querySelector(`code`),t=this._activePre.dataset.language||``,n=e&&(po.exec(e.className)||[])[1]||``;this._langSelect.value=t||n||``}_copyCode(){let e=this._activePre;e&&Ta({text:e.textContent||``}).then(()=>this._flashCopied()).catch(()=>{})}_flashCopied(){if(!this._copyBtn)return;let e=this._copyBtn.innerHTML;this._copyBtn.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`,this._copyBtn.classList.add(`an-link-tooltip-btn--copied`),setTimeout(()=>{this._copyBtn&&(this._copyBtn.innerHTML=e,this._copyBtn.classList.remove(`an-link-tooltip-btn--copied`))},1400)}_toggleWrap(){let e=this._activePre;if(!e)return;let t=e.style.whiteSpace===`pre-wrap`;e.style.whiteSpace=t?`pre`:`pre-wrap`,this._syncWrapBtn(),this.context.invoke(`editor.afterCommand`),this._positionNear(e)}_toggleLineNumbers(){let e=this._activePre;e&&(e.classList.toggle(`an-code-line-numbers`),this._syncLineNumbersBtn(),this.context.invoke(`editor.afterCommand`))}applyLanguage(e,t){if(!e||!t)return;let n=this._activePre;this._activePre=e,this._langSelect&&(this._langSelect.value=t),this._onLangChange(),this._langSelect&&(this._langSelect.value=t),this._activePre=n||e}_onLangChange(){let e=this._activePre;if(!e)return;let t=this._langSelect.value,n=globalThis,r=e.querySelector(`code`);r||(r=document.createElement(`code`),r.innerHTML=e.innerHTML,e.innerHTML=``,e.appendChild(r)),go(r,t),go(e,t),t?e.dataset.language=t:delete e.dataset.language;let i=()=>{!this.context._alive||!r.isConnected||!n.Prism||(r.querySelectorAll(`br`).forEach(e=>e.replaceWith(`
45
+ `)),n.Prism.highlightElement(r),this.context.invoke(`editor.afterCommand`))};if(t){if(n.Prism!==void 0){if(n.Prism.languages[t]){i();return}this._loadPrismComponent(t,i);return}if(this._prismScript){this._onScriptLoad(this._prismScript,()=>{n.Prism.languages[t]?i():this._loadPrismComponent(t,i)});return}}this.context.invoke(`editor.afterCommand`)}_cdnBase(){return String(this.context.options.codeHighlightCDN??``).replace(/\/+$/,``)}_ensurePrism(){let e=globalThis;if(!this.context.options.codeHighlight||e.Prism)return;let t=this._cdnBase(),n=`${t}/themes/prism-tomorrow.min.css`,r=`${t}/prism.min.js`;if(!document.querySelector(`link[href="${n}"]`)){let e=document.createElement(`link`);e.rel=`stylesheet`,e.href=n,lo(e,this.context.options),document.head.appendChild(e)}let i=document.querySelector(`script[src="${r}"]`);if(i){this._prismScript=e.Prism?null:i;return}let a=document.createElement(`script`);a.dataset.manual=``,a.src=r,lo(a,this.context.options),this._prismScript=a,this._onScriptLoad(a,()=>{this._prismScript=null}),document.head.appendChild(a)}_onScriptLoad(e,t){let n=()=>{this.context._alive&&t()};e.addEventListener(`load`,n,{once:!0}),this._asyncDisposers.push(()=>e.removeEventListener(`load`,n))}_loadPrismComponent(e,t){let n=globalThis,r=`${this._cdnBase()}/components/prism-${e}.min.js`;if(document.querySelector(`script[src="${r}"]`)){let r=setInterval(()=>{if(!this.context._alive){clearInterval(r);return}n.Prism?.languages[e]&&(clearInterval(r),t())},50),i=setTimeout(()=>clearInterval(r),3e3);this._asyncDisposers.push(()=>{clearInterval(r),clearTimeout(i)});return}let i=document.createElement(`script`);i.src=r,lo(i,this.context.options),this._onScriptLoad(i,t),document.head.appendChild(i)}_toParagraph(){let e=this._activePre;if(!e||!this.context.layoutInfo.editable)return;let t=(e.textContent||``).split(`
46
+ `),n=document.createElement(`p`);t.forEach((e,t)=>{t>0&&n.appendChild(document.createElement(`br`)),n.appendChild(document.createTextNode(e))}),e.parentNode.replaceChild(n,e),this._hide(),this.context.invoke(`editor.afterCommand`)}_delete(){let e=this._activePre;e&&(this._hide(),e.remove(),this.context.invoke(`editor.afterCommand`))}},vo=n({EMOJI_CATS:()=>yo,EMOJI_LIST:()=>bo}),yo,bo,xo=t((()=>{yo=[{id:`smileys`,label:`Smileys`},{id:`people`,label:`People`},{id:`animals`,label:`Animals`},{id:`food`,label:`Food`},{id:`travel`,label:`Travel`},{id:`objects`,label:`Objects`},{id:`symbols`,label:`Symbols`}],bo=[[`😀`,`grin smile happy face`,`smileys`],[`😃`,`happy smile big eyes`,`smileys`],[`😄`,`grinning smile laugh`,`smileys`],[`😁`,`beaming smile grin`,`smileys`],[`😆`,`laughing lol`,`smileys`],[`😅`,`sweat grin awkward`,`smileys`],[`🤣`,`rolling laugh rofl`,`smileys`],[`😂`,`tears laugh cry joy`,`smileys`],[`🙂`,`slight smile`,`smileys`],[`🙃`,`upside down smile`,`smileys`],[`😉`,`wink`,`smileys`],[`😊`,`blush smile happy`,`smileys`],[`😇`,`innocent halo angel`,`smileys`],[`🥰`,`hearts love adore`,`smileys`],[`😍`,`heart eyes love`,`smileys`],[`🤩`,`star eyes excited wow`,`smileys`],[`😘`,`kiss blow love`,`smileys`],[`😋`,`yum delicious tongue`,`smileys`],[`😛`,`tongue stuck out`,`smileys`],[`😜`,`wink tongue crazy`,`smileys`],[`🤪`,`zany crazy wild`,`smileys`],[`😝`,`squint tongue`,`smileys`],[`🤑`,`money mouth`,`smileys`],[`🤗`,`hugging hug`,`smileys`],[`🤔`,`thinking hmm`,`smileys`],[`🤨`,`raised eyebrow`,`smileys`],[`😐`,`neutral face`,`smileys`],[`😶`,`no mouth`,`smileys`],[`😏`,`smirk`,`smileys`],[`😒`,`unamused`,`smileys`],[`🙄`,`roll eyes`,`smileys`],[`😬`,`grimace`,`smileys`],[`😔`,`pensive sad`,`smileys`],[`😪`,`sleepy tired`,`smileys`],[`😴`,`sleeping zzz`,`smileys`],[`🤤`,`drool`,`smileys`],[`😷`,`mask sick`,`smileys`],[`🤒`,`sick thermometer`,`smileys`],[`🤕`,`hurt bandage`,`smileys`],[`🤢`,`nausea sick`,`smileys`],[`🤮`,`vomit sick`,`smileys`],[`🤧`,`sneeze cold`,`smileys`],[`🥵`,`hot sweat`,`smileys`],[`🥶`,`cold freeze`,`smileys`],[`😵`,`dizzy dead`,`smileys`],[`🤯`,`mind blown`,`smileys`],[`🤠`,`cowboy hat`,`smileys`],[`🥳`,`party celebrate`,`smileys`],[`😎`,`cool sunglasses`,`smileys`],[`🤓`,`nerd glasses`,`smileys`],[`🧐`,`monocle curious`,`smileys`],[`😕`,`confused`,`smileys`],[`😟`,`worried`,`smileys`],[`🙁`,`frown sad`,`smileys`],[`☹️`,`sad frown`,`smileys`],[`😮`,`surprised open mouth`,`smileys`],[`😲`,`astonished`,`smileys`],[`🥺`,`pleading begging puppy eyes`,`smileys`],[`😢`,`cry sad tear`,`smileys`],[`😭`,`sob cry loudly`,`smileys`],[`😱`,`scream horror fear`,`smileys`],[`😡`,`angry red pouting`,`smileys`],[`😠`,`angry mad`,`smileys`],[`🤬`,`cursing swear`,`smileys`],[`😈`,`devil evil smile`,`smileys`],[`👿`,`devil angry evil`,`smileys`],[`💀`,`skull death`,`smileys`],[`☠️`,`skull crossbones`,`smileys`],[`💩`,`poop`,`smileys`],[`🤡`,`clown`,`smileys`],[`👻`,`ghost boo`,`smileys`],[`👽`,`alien ufo`,`smileys`],[`🤖`,`robot`,`smileys`],[`👋`,`wave hello hi hand`,`people`],[`🤚`,`raised back hand`,`people`],[`✋`,`raised hand stop`,`people`],[`🖖`,`vulcan salute spock`,`people`],[`👌`,`ok perfect fine`,`people`],[`✌️`,`peace victory fingers`,`people`],[`🤞`,`fingers crossed luck`,`people`],[`🤟`,`love you gesture`,`people`],[`🤘`,`sign of horns rock`,`people`],[`🤙`,`call me hand`,`people`],[`👈`,`point left`,`people`],[`👉`,`point right`,`people`],[`👆`,`point up`,`people`],[`👇`,`point down`,`people`],[`☝️`,`index pointing up`,`people`],[`👍`,`thumbs up like good`,`people`],[`👎`,`thumbs down dislike bad`,`people`],[`✊`,`raised fist punch`,`people`],[`👊`,`oncoming fist punch`,`people`],[`👏`,`clap applause`,`people`],[`🙌`,`celebrate raise hands`,`people`],[`🤝`,`handshake deal`,`people`],[`🙏`,`pray hope please thanks`,`people`],[`💅`,`nail polish`,`people`],[`💪`,`flexed bicep strong muscle`,`people`],[`👀`,`eyes look see`,`people`],[`👁️`,`eye`,`people`],[`👅`,`tongue`,`people`],[`👶`,`baby`,`people`],[`🧒`,`child`,`people`],[`👦`,`boy`,`people`],[`👧`,`girl`,`people`],[`🧑`,`person adult`,`people`],[`👨`,`man`,`people`],[`👩`,`woman`,`people`],[`🧔`,`beard man`,`people`],[`🧓`,`older person`,`people`],[`👴`,`old man`,`people`],[`👵`,`old woman`,`people`],[`❤️`,`heart love red`,`people`],[`🧡`,`orange heart love`,`people`],[`💛`,`yellow heart love`,`people`],[`💚`,`green heart love`,`people`],[`💙`,`blue heart love`,`people`],[`💜`,`purple heart love`,`people`],[`🖤`,`black heart`,`people`],[`🤍`,`white heart`,`people`],[`🤎`,`brown heart`,`people`],[`💔`,`broken heart`,`people`],[`❣️`,`exclamation heart`,`people`],[`💕`,`two hearts love`,`people`],[`💞`,`revolving hearts`,`people`],[`💓`,`beating heart`,`people`],[`💗`,`growing heart`,`people`],[`💖`,`sparkling heart`,`people`],[`💘`,`heart arrow`,`people`],[`💝`,`heart ribbon`,`people`],[`💬`,`speech bubble comment chat`,`people`],[`💭`,`thought bubble`,`people`],[`💯`,`100 hundred percent perfect`,`people`],[`💢`,`anger symbol mad`,`people`],[`💤`,`zzz sleep`,`people`],[`🐶`,`dog puppy`,`animals`],[`🐱`,`cat kitten`,`animals`],[`🐭`,`mouse`,`animals`],[`🐹`,`hamster`,`animals`],[`🐰`,`rabbit bunny`,`animals`],[`🦊`,`fox`,`animals`],[`🐻`,`bear`,`animals`],[`🐼`,`panda`,`animals`],[`🐨`,`koala`,`animals`],[`🐯`,`tiger`,`animals`],[`🦁`,`lion`,`animals`],[`🐮`,`cow`,`animals`],[`🐷`,`pig`,`animals`],[`🐸`,`frog`,`animals`],[`🐵`,`monkey`,`animals`],[`🙈`,`see no evil monkey`,`animals`],[`🙉`,`hear no evil monkey`,`animals`],[`🙊`,`speak no evil monkey`,`animals`],[`🐔`,`chicken hen`,`animals`],[`🐧`,`penguin`,`animals`],[`🐦`,`bird`,`animals`],[`🦆`,`duck`,`animals`],[`🦅`,`eagle`,`animals`],[`🦉`,`owl`,`animals`],[`🦇`,`bat`,`animals`],[`🐺`,`wolf`,`animals`],[`🐴`,`horse`,`animals`],[`🦄`,`unicorn`,`animals`],[`🐝`,`bee`,`animals`],[`🦋`,`butterfly`,`animals`],[`🐌`,`snail`,`animals`],[`🐞`,`ladybug`,`animals`],[`🐢`,`turtle`,`animals`],[`🐍`,`snake`,`animals`],[`🦎`,`lizard`,`animals`],[`🐊`,`crocodile`,`animals`],[`🐟`,`fish`,`animals`],[`🐠`,`tropical fish`,`animals`],[`🦈`,`shark`,`animals`],[`🐬`,`dolphin`,`animals`],[`🐳`,`whale`,`animals`],[`🐙`,`octopus`,`animals`],[`🦑`,`squid`,`animals`],[`🦀`,`crab`,`animals`],[`🌸`,`cherry blossom flower`,`animals`],[`🌺`,`hibiscus flower`,`animals`],[`🌻`,`sunflower`,`animals`],[`🌹`,`rose flower`,`animals`],[`🌷`,`tulip flower`,`animals`],[`🍀`,`four leaf clover luck`,`animals`],[`🌿`,`herb leaf green`,`animals`],[`🌱`,`seedling sprout`,`animals`],[`🌲`,`evergreen tree pine`,`animals`],[`🌳`,`deciduous tree`,`animals`],[`🌴`,`palm tree`,`animals`],[`🍄`,`mushroom`,`animals`],[`🌾`,`sheaf wheat`,`animals`],[`🐾`,`paw prints animal`,`animals`],[`🍎`,`apple red`,`food`],[`🍊`,`orange tangerine`,`food`],[`🍋`,`lemon yellow`,`food`],[`🍇`,`grapes`,`food`],[`🍓`,`strawberry`,`food`],[`🫐`,`blueberry`,`food`],[`🍒`,`cherry`,`food`],[`🍑`,`peach`,`food`],[`🥭`,`mango`,`food`],[`🍍`,`pineapple`,`food`],[`🥥`,`coconut`,`food`],[`🥝`,`kiwi`,`food`],[`🍅`,`tomato`,`food`],[`🥑`,`avocado`,`food`],[`🍆`,`eggplant aubergine`,`food`],[`🥕`,`carrot`,`food`],[`🌽`,`corn`,`food`],[`🥦`,`broccoli`,`food`],[`🥬`,`leafy green`,`food`],[`🧄`,`garlic`,`food`],[`🥜`,`peanut nut`,`food`],[`🍞`,`bread loaf`,`food`],[`🥐`,`croissant`,`food`],[`🧀`,`cheese`,`food`],[`🍳`,`egg fry cooking`,`food`],[`🥚`,`egg`,`food`],[`🥞`,`pancake`,`food`],[`🧇`,`waffle`,`food`],[`🥓`,`bacon`,`food`],[`🥩`,`meat steak`,`food`],[`🍗`,`chicken leg`,`food`],[`🌭`,`hotdog`,`food`],[`🍔`,`burger hamburger`,`food`],[`🍟`,`fries french`,`food`],[`🍕`,`pizza`,`food`],[`🌮`,`taco`,`food`],[`🌯`,`burrito wrap`,`food`],[`🍜`,`noodles ramen`,`food`],[`🍝`,`spaghetti pasta`,`food`],[`🍣`,`sushi`,`food`],[`🍱`,`bento box`,`food`],[`🍦`,`ice cream soft serve`,`food`],[`🍩`,`donut`,`food`],[`🍪`,`cookie`,`food`],[`🎂`,`birthday cake`,`food`],[`🍰`,`cake slice`,`food`],[`🧁`,`cupcake`,`food`],[`🍫`,`chocolate`,`food`],[`🍬`,`candy`,`food`],[`🍭`,`lollipop`,`food`],[`☕`,`coffee hot`,`food`],[`🍵`,`tea hot`,`food`],[`🧋`,`bubble tea boba`,`food`],[`🥤`,`cup straw drink`,`food`],[`🍷`,`wine red`,`food`],[`🍸`,`cocktail martini`,`food`],[`🍺`,`beer mug`,`food`],[`🍻`,`clinking beer mugs`,`food`],[`🥂`,`champagne toast celebrate`,`food`],[`🧃`,`juice box`,`food`],[`🧊`,`ice cube`,`food`],[`🚀`,`rocket space`,`travel`],[`🛸`,`ufo flying saucer`,`travel`],[`✈️`,`airplane plane fly`,`travel`],[`🚁`,`helicopter`,`travel`],[`🚂`,`train locomotive`,`travel`],[`🚄`,`bullet train fast`,`travel`],[`🚇`,`subway metro`,`travel`],[`🚌`,`bus`,`travel`],[`🚑`,`ambulance`,`travel`],[`🚒`,`fire truck`,`travel`],[`🚓`,`police car`,`travel`],[`🚕`,`taxi cab`,`travel`],[`🚗`,`car automobile red`,`travel`],[`🚙`,`suv car`,`travel`],[`🚚`,`truck delivery`,`travel`],[`🚜`,`tractor farm`,`travel`],[`🏎️`,`racing car fast`,`travel`],[`🏍️`,`motorcycle`,`travel`],[`🚲`,`bicycle bike`,`travel`],[`🛴`,`scooter kick`,`travel`],[`⛵`,`sailboat boat`,`travel`],[`🚢`,`ship cruise`,`travel`],[`🏠`,`house home`,`travel`],[`🏢`,`office building`,`travel`],[`🏥`,`hospital`,`travel`],[`🏦`,`bank`,`travel`],[`🏪`,`store shop convenience`,`travel`],[`🏫`,`school`,`travel`],[`🏰`,`castle european`,`travel`],[`🏯`,`japanese castle`,`travel`],[`🗼`,`tokyo tower`,`travel`],[`🗽`,`statue liberty new york`,`travel`],[`⛪`,`church`,`travel`],[`🕌`,`mosque`,`travel`],[`⛩️`,`shinto shrine`,`travel`],[`⛲`,`fountain`,`travel`],[`⛺`,`tent camping`,`travel`],[`🌁`,`fog foggy bridge`,`travel`],[`🌃`,`night city stars`,`travel`],[`🏙️`,`cityscape city buildings`,`travel`],[`🌅`,`sunrise morning`,`travel`],[`🌈`,`rainbow colorful`,`travel`],[`⛰️`,`mountain`,`travel`],[`🏔️`,`snow mountain`,`travel`],[`🗻`,`mount fuji`,`travel`],[`🏕️`,`camping tent`,`travel`],[`🗺️`,`world map`,`travel`],[`🧭`,`compass navigation`,`travel`],[`🌍`,`earth europe africa globe`,`travel`],[`🌎`,`earth americas globe`,`travel`],[`🌏`,`earth asia globe`,`travel`],[`🌐`,`globe internet web`,`travel`],[`💎`,`diamond gem jewel`,`objects`],[`💍`,`ring engagement`,`objects`],[`👑`,`crown royal king queen`,`objects`],[`🎩`,`top hat magic`,`objects`],[`💼`,`briefcase work business`,`objects`],[`👜`,`handbag purse`,`objects`],[`🎒`,`backpack bag school`,`objects`],[`👓`,`glasses eyewear`,`objects`],[`🕶️`,`sunglasses cool`,`objects`],[`💡`,`light bulb idea`,`objects`],[`🔦`,`flashlight torch`,`objects`],[`🕯️`,`candle light`,`objects`],[`🔋`,`battery charge`,`objects`],[`💻`,`laptop computer`,`objects`],[`🖥️`,`desktop monitor computer`,`objects`],[`📱`,`phone mobile cell`,`objects`],[`⌨️`,`keyboard type`,`objects`],[`🖱️`,`mouse computer click`,`objects`],[`📺`,`television tv`,`objects`],[`📷`,`camera photo`,`objects`],[`📹`,`video camera`,`objects`],[`🎥`,`movie camera film`,`objects`],[`☎️`,`telephone phone`,`objects`],[`⏰`,`alarm clock wake`,`objects`],[`⌚`,`watch time`,`objects`],[`🔑`,`key`,`objects`],[`🗝️`,`old key`,`objects`],[`🔒`,`lock closed`,`objects`],[`🔓`,`unlock open`,`objects`],[`🔨`,`hammer tool`,`objects`],[`🔧`,`wrench tool`,`objects`],[`🔩`,`bolt nut`,`objects`],[`⚙️`,`gear setting`,`objects`],[`🧲`,`magnet attract`,`objects`],[`📚`,`books stack library`,`objects`],[`📖`,`book open read`,`objects`],[`📝`,`memo write note`,`objects`],[`✏️`,`pencil write edit`,`objects`],[`📌`,`pushpin tack`,`objects`],[`📎`,`paperclip attach`,`objects`],[`📊`,`bar chart graph`,`objects`],[`📈`,`chart up growth trend`,`objects`],[`📉`,`chart down loss decline`,`objects`],[`📅`,`calendar date`,`objects`],[`📦`,`package box`,`objects`],[`📫`,`mailbox closed`,`objects`],[`📧`,`email envelope`,`objects`],[`🎁`,`gift present`,`objects`],[`🎀`,`ribbon bow`,`objects`],[`🎉`,`party celebrate confetti`,`objects`],[`🎊`,`confetti celebrate`,`objects`],[`🔮`,`crystal ball magic fortune`,`objects`],[`🪄`,`magic wand`,`objects`],[`🎯`,`target bullseye dart`,`objects`],[`🎲`,`dice game board`,`objects`],[`🎮`,`video game controller`,`objects`],[`🎭`,`theater masks drama`,`objects`],[`🎨`,`art palette paint`,`objects`],[`🎬`,`clapper film movie`,`objects`],[`🎤`,`microphone sing karaoke`,`objects`],[`🎧`,`headphones music listen`,`objects`],[`🎵`,`music note`,`objects`],[`🎶`,`music notes`,`objects`],[`🎸`,`guitar electric`,`objects`],[`🎹`,`piano keyboard music`,`objects`],[`🥁`,`drum percussion`,`objects`],[`🎷`,`saxophone jazz`,`objects`],[`🎺`,`trumpet`,`objects`],[`🎻`,`violin`,`objects`],[`⚽`,`soccer ball football`,`objects`],[`🏀`,`basketball`,`objects`],[`🏈`,`american football`,`objects`],[`⚾`,`baseball`,`objects`],[`🎾`,`tennis`,`objects`],[`🏐`,`volleyball`,`objects`],[`🏆`,`trophy winner award`,`objects`],[`🥇`,`gold medal first`,`objects`],[`🏅`,`sports medal`,`objects`],[`✅`,`check green done success`,`symbols`],[`❌`,`cross x no cancel`,`symbols`],[`⭕`,`circle red`,`symbols`],[`⛔`,`no entry stop`,`symbols`],[`🚫`,`prohibited no banned`,`symbols`],[`⚠️`,`warning caution danger`,`symbols`],[`❗`,`exclamation red important`,`symbols`],[`❓`,`question mark`,`symbols`],[`‼️`,`double exclamation`,`symbols`],[`💯`,`100 hundred percent perfect`,`symbols`],[`🔴`,`red circle dot`,`symbols`],[`🟠`,`orange circle`,`symbols`],[`🟡`,`yellow circle`,`symbols`],[`🟢`,`green circle`,`symbols`],[`🔵`,`blue circle`,`symbols`],[`🟣`,`purple circle`,`symbols`],[`⚫`,`black circle`,`symbols`],[`⚪`,`white circle`,`symbols`],[`🟤`,`brown circle`,`symbols`],[`🔺`,`red triangle up`,`symbols`],[`🔻`,`red triangle down`,`symbols`],[`🔷`,`blue diamond large`,`symbols`],[`🔶`,`orange diamond large`,`symbols`],[`🔹`,`blue diamond small`,`symbols`],[`🔸`,`orange diamond small`,`symbols`],[`⭐`,`star yellow`,`symbols`],[`🌟`,`glowing star shine`,`symbols`],[`✨`,`sparkles shine`,`symbols`],[`💫`,`dizzy star spin`,`symbols`],[`⚡`,`lightning bolt energy power`,`symbols`],[`🔥`,`fire hot flame`,`symbols`],[`💥`,`explosion boom`,`symbols`],[`❄️`,`snowflake cold ice winter`,`symbols`],[`🌊`,`wave water ocean sea`,`symbols`],[`💨`,`wind blow dash`,`symbols`],[`🌀`,`cyclone tornado spiral`,`symbols`],[`♻️`,`recycle loop green`,`symbols`],[`✔️`,`check tick done`,`symbols`],[`➕`,`plus add`,`symbols`],[`➖`,`minus subtract`,`symbols`],[`➗`,`divide division`,`symbols`],[`✖️`,`multiply times cross`,`symbols`],[`▶️`,`play button right`,`symbols`],[`⏸️`,`pause`,`symbols`],[`⏹️`,`stop square`,`symbols`],[`⏩`,`fast forward`,`symbols`],[`⏪`,`rewind fast backward`,`symbols`],[`🔔`,`bell notification`,`symbols`],[`🔕`,`bell slash mute`,`symbols`],[`🔊`,`speaker volume high`,`symbols`],[`🔇`,`mute silent no sound`,`symbols`],[`📢`,`loudspeaker announcement`,`symbols`],[`📣`,`megaphone cheer`,`symbols`],[`🏳️`,`white flag`,`symbols`],[`🏴`,`black flag`,`symbols`],[`🚩`,`red flag`,`symbols`],[`🏁`,`checkered flag finish race`,`symbols`],[`🆕`,`new badge`,`symbols`],[`🆓`,`free badge`,`symbols`],[`🆒`,`cool badge`,`symbols`],[`🔝`,`top arrow`,`symbols`],[`🔙`,`back arrow`,`symbols`],[`ℹ️`,`information info`,`symbols`],[`📍`,`pin location map`,`symbols`],[`🔗`,`link chain`,`symbols`],[`©️`,`copyright`,`symbols`],[`®️`,`registered trademark`,`symbols`],[`™️`,`trademark`,`symbols`],[`#️⃣`,`hash number`,`symbols`],[`0️⃣`,`zero number`,`symbols`],[`1️⃣`,`one number`,`symbols`],[`2️⃣`,`two number`,`symbols`],[`3️⃣`,`three number`,`symbols`],[`4️⃣`,`four number`,`symbols`],[`5️⃣`,`five number`,`symbols`]]})),So=null,Co=null;function wo(){return So?Promise.resolve(So):(Co??=Promise.resolve().then(()=>(xo(),vo)).then(e=>(So={EMOJI_CATS:e.EMOJI_CATS,EMOJI_LIST:e.EMOJI_LIST},So)),Co)}var To=class extends La{_activeCat=`all`;initialize(){return this}async show(){if(this._saveRange(),!this._dialog){let{EMOJI_CATS:e,EMOJI_LIST:t}=await wo();this._dialog||(this._cats=e,this._list=t,this._dialog=this._buildDialog(),b(this.context).appendChild(this._dialog))}this._activeCat=`all`,this._searchInput.value=``,this._updateCatTabs(),this._filterEmojis(``,`all`),this._open()}_buildDialog(){let e=this.context.locale.emojiDialog,t=h(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e.ariaLabel}),n=h(`div`,{class:`an-dialog-box an-emoji-box`}),r=h(`div`,{class:`an-icon-title-row`}),i=h(`div`,{class:`an-dialog-title-group`}),a=h(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M8 13s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`;let o=h(`h3`,{class:`an-dialog-title`});o.textContent=e.title,i.append(a,o);let s=h(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close});s.innerHTML=`&times;`,r.append(i,s);let c=h(`input`,{type:`search`,class:`an-input an-icon-search`,placeholder:e.searchPlaceholder,autocomplete:`off`});this._searchInput=c;let l=h(`div`,{class:`an-icon-cats`}),u=h(`button`,{type:`button`,class:`an-icon-cat active`,"data-cat":`all`});u.textContent=e.all,l.appendChild(u),this._cats.forEach(({id:t,label:n})=>{let r=h(`button`,{type:`button`,class:`an-icon-cat`,"data-cat":t});r.textContent=e.categories?.[t]||n,l.appendChild(r)}),this._catBar=l;let d=h(`div`,{class:`an-emoji-grid`});this._list.forEach(([e,t,n])=>{let r=h(`button`,{type:`button`,class:`an-emoji-cell`,"data-char":e,"data-keywords":t,"data-cat":n,title:t.split(` `).slice(0,2).join(` `)});r.textContent=e,d.appendChild(r)}),this._grid=d,this._firstInput=c;let f=h(`div`,{class:`an-dialog-actions`}),p=h(`button`,{type:`button`,class:`an-btn`});p.textContent=e.cancelBtn,f.appendChild(p),n.append(r,c,l,d,f),t.appendChild(n),ee(r,n);let m=v(s,`click`,()=>this._close()),g=v(p,`click`,()=>this._close()),_=v(t,`click`,e=>{e.target===t&&this._close()}),y=v(c,`input`,()=>this._filterEmojis(c.value,this._activeCat)),b=v(l,`click`,e=>{let t=e.target?.closest(`[data-cat]`);t&&(this._activeCat=t.dataset.cat,this._updateCatTabs(),this._filterEmojis(this._searchInput.value,this._activeCat))}),x=v(d,`click`,e=>{let t=e.target?.closest(`.an-emoji-cell`);t&&this._onEmojiClick(t.dataset.char)});return this._disposers.push(m,g,_,y,b,x),t}_updateCatTabs(){this._catBar.querySelectorAll(`.an-icon-cat`).forEach(e=>{e.classList.toggle(`active`,e.dataset.cat===this._activeCat)})}_filterEmojis(e,t){let n=(e||``).trim().toLowerCase(),r=0;this._grid.querySelectorAll(`.an-emoji-cell`).forEach(e=>{let i=e,a=!t||t===`all`||i.dataset.cat===t,o=!n||i.dataset.keywords.includes(n)||i.dataset.char===n,s=a&&o;i.style.display=s?``:`none`,s&&r++});let i=this._grid.querySelector(`.an-icon-empty`);i||(i=h(`div`,{class:`an-icon-empty`}),i.textContent=`No emojis found`,this._grid.appendChild(i)),i.style.display=r>0?`none`:``}_onEmojiClick(e){let t=this._savedRange,n=this.context.layoutInfo.editable;t&&t.select();let r=globalThis.getSelection(),i=r?.rangeCount>0?r.getRangeAt(0):null;if(i&&!n.contains(i.commonAncestorContainer)&&(i=null),!i){let e=n.lastElementChild;i=document.createRange(),i.selectNodeContents(e&&/^(P|H[1-6]|DIV|BLOCKQUOTE)$/.test(e.nodeName)?e:n),i.collapse(!1)}let a=i.startContainer,o=(a.nodeType===1?a:a.parentElement)?.closest(`td, th`);i.deleteContents(),o?.isConnected&&!o.contains(i.startContainer)&&(i.setStart(o,0),i.collapse(!0));let s=document.createTextNode(e);i.insertNode(s),i.setStartAfter(s),i.collapse(!0),r&&(r.removeAllRanges(),r.addRange(i)),this._close(),n.focus(),this.context.invoke(`editor.afterCommand`)}},Eo=n({ICON_CATEGORIES:()=>Do,ICON_LIST:()=>Oo}),Do,Oo,ko=t((()=>{Do=[{id:`popular`,label:`Popular`},{id:`interface`,label:`Interface`},{id:`navigation`,label:`Navigation`},{id:`media`,label:`Media`},{id:`communication`,label:`Communication`},{id:`files`,label:`Files`},{id:`people`,label:`People`},{id:`objects`,label:`Objects`}],Oo=[[`house`,`popular`],[`star`,`popular`],[`heart`,`popular`],[`check`,`popular`],[`xmark`,`popular`],[`plus`,`popular`],[`minus`,`popular`],[`magnifying-glass`,`popular`],[`gear`,`popular`],[`bell`,`popular`],[`user`,`popular`],[`envelope`,`popular`],[`phone`,`popular`],[`calendar`,`popular`],[`clock`,`popular`],[`lock`,`popular`],[`eye`,`popular`],[`eye-slash`,`popular`],[`trash`,`popular`],[`pen`,`popular`],[`bookmark`,`popular`],[`flag`,`popular`],[`thumbs-up`,`popular`],[`thumbs-down`,`popular`],[`circle-info`,`popular`],[`triangle-exclamation`,`popular`],[`circle-check`,`popular`],[`circle-xmark`,`popular`],[`share`,`popular`],[`download`,`popular`],[`upload`,`popular`],[`tag`,`popular`],[`bars`,`interface`],[`ellipsis`,`interface`],[`ellipsis-vertical`,`interface`],[`list`,`interface`],[`table-cells`,`interface`],[`table-list`,`interface`],[`grip`,`interface`],[`filter`,`interface`],[`sort`,`interface`],[`arrows-rotate`,`interface`],[`rotate`,`interface`],[`rotate-left`,`interface`],[`rotate-right`,`interface`],[`copy`,`interface`],[`floppy-disk`,`interface`],[`print`,`interface`],[`link`,`interface`],[`code`,`interface`],[`expand`,`interface`],[`compress`,`interface`],[`cloud`,`interface`],[`lock-open`,`interface`],[`key`,`interface`],[`shield`,`interface`],[`shield-halved`,`interface`],[`sliders`,`interface`],[`toggle-on`,`interface`],[`square-check`,`interface`],[`circle-plus`,`interface`],[`circle-minus`,`interface`],[`arrow-right`,`navigation`],[`arrow-left`,`navigation`],[`arrow-up`,`navigation`],[`arrow-down`,`navigation`],[`chevron-right`,`navigation`],[`chevron-left`,`navigation`],[`chevron-up`,`navigation`],[`chevron-down`,`navigation`],[`angle-right`,`navigation`],[`angle-left`,`navigation`],[`angle-up`,`navigation`],[`angle-down`,`navigation`],[`angles-right`,`navigation`],[`angles-left`,`navigation`],[`location-dot`,`navigation`],[`compass`,`navigation`],[`map`,`navigation`],[`map-pin`,`navigation`],[`route`,`navigation`],[`circle-arrow-right`,`navigation`],[`circle-arrow-left`,`navigation`],[`arrow-trend-up`,`navigation`],[`arrow-trend-down`,`navigation`],[`right-from-bracket`,`navigation`],[`right-to-bracket`,`navigation`],[`play`,`media`],[`pause`,`media`],[`stop`,`media`],[`forward`,`media`],[`backward`,`media`],[`forward-step`,`media`],[`backward-step`,`media`],[`volume-high`,`media`],[`volume-low`,`media`],[`volume-xmark`,`media`],[`volume-off`,`media`],[`music`,`media`],[`headphones`,`media`],[`microphone`,`media`],[`microphone-slash`,`media`],[`film`,`media`],[`camera`,`media`],[`camera-rotate`,`media`],[`video`,`media`],[`image`,`media`],[`images`,`media`],[`photo-film`,`media`],[`podcast`,`media`],[`radio`,`media`],[`comment`,`communication`],[`comments`,`communication`],[`comment-dots`,`communication`],[`message`,`communication`],[`paper-plane`,`communication`],[`reply`,`communication`],[`reply-all`,`communication`],[`at`,`communication`],[`hashtag`,`communication`],[`wifi`,`communication`],[`signal`,`communication`],[`rss`,`communication`],[`share-nodes`,`communication`],[`inbox`,`communication`],[`phone-volume`,`communication`],[`mobile`,`communication`],[`mobile-screen`,`communication`],[`laptop`,`communication`],[`desktop`,`communication`],[`tower-broadcast`,`communication`],[`file`,`files`],[`file-lines`,`files`],[`folder`,`files`],[`folder-open`,`files`],[`folder-plus`,`files`],[`folder-minus`,`files`],[`file-image`,`files`],[`file-pdf`,`files`],[`file-code`,`files`],[`file-zipper`,`files`],[`file-audio`,`files`],[`file-video`,`files`],[`file-arrow-up`,`files`],[`file-arrow-down`,`files`],[`database`,`files`],[`box`,`files`],[`box-open`,`files`],[`hard-drive`,`files`],[`server`,`files`],[`user`,`people`],[`users`,`people`],[`user-group`,`people`],[`user-plus`,`people`],[`user-minus`,`people`],[`user-check`,`people`],[`user-xmark`,`people`],[`user-tie`,`people`],[`user-shield`,`people`],[`user-secret`,`people`],[`person`,`people`],[`person-running`,`people`],[`person-walking`,`people`],[`child`,`people`],[`handshake`,`people`],[`hand`,`people`],[`hands-holding`,`people`],[`people-group`,`people`],[`pencil`,`objects`],[`paintbrush`,`objects`],[`eraser`,`objects`],[`scissors`,`objects`],[`wrench`,`objects`],[`screwdriver`,`objects`],[`hammer`,`objects`],[`toolbox`,`objects`],[`graduation-cap`,`objects`],[`book`,`objects`],[`book-open`,`objects`],[`glasses`,`objects`],[`microscope`,`objects`],[`flask`,`objects`],[`stethoscope`,`objects`],[`hospital`,`objects`],[`building`,`objects`],[`city`,`objects`],[`car`,`objects`],[`truck`,`objects`],[`plane`,`objects`],[`train`,`objects`],[`bicycle`,`objects`],[`bus`,`objects`],[`rocket`,`objects`],[`briefcase`,`objects`],[`cart-shopping`,`objects`],[`bag-shopping`,`objects`],[`credit-card`,`objects`],[`money-bill`,`objects`],[`chart-bar`,`objects`],[`chart-line`,`objects`],[`chart-pie`,`objects`],[`bolt`,`objects`],[`sun`,`objects`],[`moon`,`objects`],[`snowflake`,`objects`],[`fire`,`objects`],[`droplet`,`objects`],[`leaf`,`objects`],[`tree`,`objects`],[`earth-americas`,`objects`],[`globe`,`objects`],[`award`,`objects`],[`trophy`,`objects`],[`gift`,`objects`],[`puzzle-piece`,`objects`]]})),Ao=`https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css`,jo=null,Mo=null;function No(){return jo?Promise.resolve(jo):(Mo??=Promise.resolve().then(()=>(ko(),Eo)).then(e=>(jo={ICON_CATEGORIES:e.ICON_CATEGORIES,ICON_LIST:e.ICON_LIST},jo)),Mo)}var Po=class extends La{_selectedIcon=null;_activeCat=`all`;initialize(){return this}_ensureFontAwesome(){if(this.context.options.fontAwesomeAutoInject===!1)return;let e=this.context.options.fontAwesomeCDN||Ao;if(!e||document.getElementById(`an-fontawesome-css`))return;let t=Array.from(document.querySelectorAll(`link[rel="stylesheet"]`)).map(e=>e.href||``).join(` `);if(/fontawesome|font-awesome/.test(t)||document.querySelector(`.fa-solid, .fas, .far, .fab`))return;let n=document.createElement(`link`);n.id=`an-fontawesome-css`,n.rel=`stylesheet`,n.href=e,lo(n,this.context.options),document.head.appendChild(n)}async show(){if(this._saveRange(),this._ensureFontAwesome(),!this._dialog){let{ICON_CATEGORIES:e,ICON_LIST:t}=await No();this._dialog||(this._cats=e,this._list=t,this._dialog=this._buildDialog(),b(this.context).appendChild(this._dialog))}this._selectedIcon=null,this._activeCat=`all`,this._searchInput.value=``,this._grid.querySelectorAll(`.an-icon-cell.active`).forEach(e=>e.classList.remove(`active`)),this._insertBtn.setAttribute(`disabled`,``),this._updateCatTabs(),this._filterIcons(``,`all`),this._updatePreview(null),this._open()}_buildDialog(){let e=this.context.locale.iconDialog,t=h(`div`,{class:`an-dialog-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":e.ariaLabel}),n=h(`div`,{class:`an-dialog-box an-icon-box`}),r=h(`div`,{class:`an-icon-title-row`}),i=h(`div`,{class:`an-dialog-title-group`}),a=h(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>`;let o=h(`h3`,{class:`an-dialog-title`});o.textContent=e.title,i.append(a,o);let s=h(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close});s.innerHTML=`&times;`,r.append(i,s);let c=h(`input`,{type:`search`,class:`an-input an-icon-search`,placeholder:e.searchPlaceholder,autocomplete:`off`});this._searchInput=c,this._firstInput=c;let l=h(`div`,{class:`an-icon-cats`}),u=h(`button`,{type:`button`,class:`an-icon-cat active`,"data-cat":`all`});u.textContent=e.all,l.appendChild(u),this._cats.forEach(({id:t,label:n})=>{let r=h(`button`,{type:`button`,class:`an-icon-cat`,"data-cat":t});r.textContent=e.categories?.[t]||n,l.appendChild(r)}),this._catBar=l;let d=h(`div`,{class:`an-icon-grid`});this._list.forEach(([e,t])=>{let n=h(`button`,{type:`button`,class:`an-icon-cell`,"data-name":e,"data-cat":t,title:e}),r=h(`i`,{class:`fa-solid fa-`+e,"aria-hidden":`true`}),i=h(`span`);i.textContent=e,n.append(r,i),d.appendChild(n)}),this._grid=d;let f=h(`div`,{class:`an-icon-options`}),p=h(`label`,{class:`an-label`});p.textContent=e.style;let m=h(`select`,{class:`an-input an-icon-option-select`});[[`fa-solid`,`Solid`],[`fa-regular`,`Regular`],[`fa-light`,`Light (Pro)`]].forEach(([e,t])=>{let n=h(`option`,{value:e});n.textContent=t,m.appendChild(n)}),m.value=`fa-solid`,this._styleSelect=m;let g=h(`label`,{class:`an-label`});g.textContent=e.size;let _=h(`select`,{class:`an-input an-icon-option-select`});[[``,`Inherit`],[`0.75em`,`0.75em`],[`1em`,`1em`],[`1.25em`,`1.25em`],[`1.5em`,`1.5em`],[`2em`,`2em`],[`3em`,`3em`]].forEach(([e,t])=>{let n=h(`option`,{value:e});e===`1em`&&(n.selected=!0),n.textContent=t,_.appendChild(n)}),this._sizeSelect=_;let y=h(`label`,{class:`an-label`});y.textContent=e.color;let b=h(`input`,{type:`color`,class:`an-icon-color`,value:`#000000`});this._colorInput=b;let x=h(`label`,{class:`an-label an-label-inline an-icon-use-color`}),S=h(`input`,{type:`checkbox`,checked:``});this._useColorCb=S,x.append(S,document.createTextNode(e.useColor)),f.append(p,m,g,_,y,b,x);let C=h(`div`,{class:`an-icon-preview`}),te=h(`span`,{class:`an-icon-preview-hint`});te.textContent=e.selectHint,C.appendChild(te),this._preview=C;let ne=h(`div`,{class:`an-dialog-actions`}),w=h(`button`,{type:`button`,class:`an-btn an-btn-primary`,disabled:``});w.textContent=e.insertBtn;let re=h(`button`,{type:`button`,class:`an-btn`});re.textContent=e.cancelBtn,ne.append(w,re),this._insertBtn=w,n.append(r,c,l,d,f,C,ne),t.appendChild(n),ee(r,n);let ie=v(s,`click`,()=>this._close()),ae=v(re,`click`,()=>this._close()),oe=v(w,`click`,()=>this._onInsert()),T=v(t,`click`,e=>{e.target===t&&this._close()}),se=v(c,`input`,()=>this._filterIcons(c.value,this._activeCat)),ce=v(l,`click`,e=>{let t=e.target?.closest(`[data-cat]`);t&&(this._activeCat=t.dataset.cat,this._updateCatTabs(),this._filterIcons(this._searchInput.value,this._activeCat))}),le=v(d,`click`,e=>{let t=e.target?.closest(`.an-icon-cell`);t&&this._selectIcon(t.dataset.name)}),ue=v(m,`change`,()=>this._updatePreview(this._selectedIcon)),de=v(_,`change`,()=>this._updatePreview(this._selectedIcon)),fe=v(b,`input`,()=>this._updatePreview(this._selectedIcon)),pe=v(S,`change`,()=>this._updatePreview(this._selectedIcon));return this._disposers.push(ie,ae,oe,T,se,ce,le,ue,de,fe,pe),t}_updateCatTabs(){this._catBar.querySelectorAll(`.an-icon-cat`).forEach(e=>{e.classList.toggle(`active`,e.dataset.cat===this._activeCat)})}_filterIcons(e,t){let n=(e||``).trim().toLowerCase(),r=0;this._grid.querySelectorAll(`.an-icon-cell`).forEach(e=>{let i=e,a=i.dataset.name,o=i.dataset.cat,s=!t||t===`all`||o===t,c=!n||a.includes(n),l=s&&c;i.style.display=l?``:`none`,l&&r++});let i=this._grid.querySelector(`.an-icon-empty`);i||(i=h(`div`,{class:`an-icon-empty`}),i.textContent=`No icons found`,this._grid.appendChild(i)),i.style.display=r>0?`none`:``}_selectIcon(e){this._selectedIcon=e,this._grid.querySelectorAll(`.an-icon-cell`).forEach(t=>{t.classList.toggle(`active`,t.dataset.name===e)}),this._insertBtn.removeAttribute(`disabled`),this._updatePreview(e)}_updatePreview(e){if(!this._preview)return;if(!e){this._preview.innerHTML=`<span class="an-icon-preview-hint">Select an icon</span>`;return}let t=this._styleSelect?.value||`fa-solid`,n=this._sizeSelect?.value||`1em`,r=this._useColorCb?.checked??!1?this._colorInput?.value??``:``,i=[n?`font-size:${n}`:``,r?`color:${r}`:``].filter(Boolean).join(`;`);this._preview.innerHTML=`<i class="${t} fa-${e}" aria-hidden="true"${i?` style="${i}"`:``}></i><div class="an-icon-preview-name">${t} fa-${e}</div>`}_onInsert(){if(!this._selectedIcon)return;let e=this._styleSelect?.value||`fa-solid`,t=this._sizeSelect?.value||``,n=this._useColorCb?.checked??!1?this._colorInput?.value??``:``,r=[t?`font-size:${t}`:``,n?`color:${n}`:``].filter(Boolean),i=document.createElement(`i`);i.className=`${e} fa-${this._selectedIcon}`,i.setAttribute(`aria-hidden`,`true`),i.setAttribute(`contenteditable`,`false`),r.length&&i.setAttribute(`style`,r.join(`;`));let a=this._savedRange,o=this.context.layoutInfo.editable;a&&a.select();let s=globalThis.getSelection(),c=(s?.rangeCount??0)>0?s.getRangeAt(0):null;if(c&&!o.contains(c.commonAncestorContainer)&&(c=null),!c){let e=o.lastElementChild;c=document.createRange(),c.selectNodeContents(e&&/^(P|H[1-6]|DIV|BLOCKQUOTE)$/.test(e.nodeName)?e:o),c.collapse(!1)}let l=c.startContainer,u=(l.nodeType===1?l:l.parentElement)?.closest(`td, th`);c.deleteContents(),u?.isConnected&&!u.contains(c.startContainer)&&(c.setStart(u,0),c.collapse(!0)),c.insertNode(i);let d=i.nextSibling;d?.nodeType===Node.TEXT_NODE?d.textContent||(d.textContent=`​`):(d=document.createTextNode(`​`),i.parentNode.insertBefore(d,i.nextSibling));let f=+!!(d.textContent||``).startsWith(`​`),p=document.createRange();p.setStart(d,Math.min(f,d.textContent.length)),p.collapse(!0),s&&(s.removeAllRanges(),s.addRange(p)),this._close(),o.focus(),s&&(s.removeAllRanges(),s.addRange(p)),this.context.invoke(`editor.afterCommand`)}_close(){this._selectedIcon=null,super._close()}};function Fo(e){return Gr({...e,mod:e.mod||e.ctrl,ctrl:!1})}var Io=[{category:`Text Formatting`,items:[{keys:`Ctrl + B`,action:`Bold`},{keys:`Ctrl + I`,action:`Italic`},{keys:`Ctrl + U`,action:`Underline`},{keys:`Ctrl + K`,action:`Insert / edit link`}]},{category:`History`,items:[{keys:`Ctrl + Z`,action:`Undo`},{keys:`Ctrl + Y / Ctrl + Shift + Z`,action:`Redo`}]},{category:`Selection & Navigation`,items:[{keys:`Ctrl + A`,action:`Select all content`},{keys:`Tab`,action:`Indent list item / insert spaces`},{keys:`Shift + Tab`,action:`Outdent list item`}]},{category:`Clipboard`,items:[{keys:`Ctrl + Shift + V`,action:`Paste as plain text`}]},{category:`Find & Replace`,items:[{keys:`Ctrl + F`,action:`Find in document`},{keys:`Ctrl + H`,action:`Find & Replace`}]},{category:`Editor`,items:[{keys:`Ctrl + Shift + /`,action:`Show this keyboard shortcuts dialog`}]}],Lo=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="7" width="20" height="14" rx="2"/><path d="M6 11h.01M10 11h.01M14 11h.01M18 11h.01M6 15h.01M18 15h.01M10 15h4"/><path d="M7 3l5 4 5-4"/></svg>`,Ro=class extends La{show(){this._listEl&&this._renderShortcuts(this._listEl),this._open()}_buildDialog(){let e=this.context.locale.shortcutsDialog,{overlay:t,box:n}=this._buildDialogShell(e.ariaLabel,Lo,e.title);n.classList.add(`an-shortcuts-box`);let r=h(`button`,{type:`button`,class:`an-icon-close`,"aria-label":e.close,style:`margin-left:auto`});r.textContent=`×`,this._closeBtn=r,this._firstInput=r,n.querySelector(`.an-dialog-header`).appendChild(r),this._listEl=h(`div`,{class:`an-shortcuts-list`}),this._renderShortcuts(this._listEl),n.appendChild(this._listEl);let i=v(r,`click`,()=>this._close());return this._disposers.push(i),t}_renderShortcuts(e){e.textContent=``;let t=this.context.locale.shortcutsDialog,n=this.context.invoke?.(`editor.getKeyBindings`)||Wr(null),r=new Map(n.map(e=>[Fo(e.parsed),e.command])),i=new Set;for(let[e,t]of Object.entries(Br)){let n=Fo(Hr(e));r.get(n)!==t&&i.add(n)}let a=(t.shortcuts||Io).map(({category:e,items:t})=>({category:e,items:t.flatMap(({keys:e,action:t})=>{let n=e.split(/\s+\/\s+/).map(e=>e.trim()).filter(e=>{let t=Hr(e.replace(/\s+/g,``));return!t||!i.has(Fo(t))});return n.length?[{keys:n.join(` / `),action:t}]:[]})})),o=new Map(Object.entries(Br).map(([e,t])=>[Gr(Hr(e)),t])),s=n.filter(e=>o.get(Gr(e.parsed))!==e.command).map(e=>({keys:Kr(e.parsed),action:this._describe(e)}));s.length&&a.push({category:t.customCategory||`Custom`,items:s});for(let{category:t,items:n}of a){if(!n.length)continue;let r=h(`div`,{class:`an-shortcuts-cat`});r.textContent=t,e.appendChild(r);let i=h(`div`,{class:`an-shortcuts-table`});for(let{keys:e,action:t}of n){let n=h(`div`,{class:`an-shortcuts-row`}),r=h(`span`,{class:`an-shortcuts-key`});r.textContent=e;let a=h(`span`,{class:`an-shortcuts-action`});a.textContent=t,n.append(r,a),i.appendChild(n)}e.appendChild(i)}}_describe(e){if(e.description)return e.description;if(typeof e.command==`string`){let t=this.context.locale.toolbar?.[e.command];return typeof t==`string`?t:e.command}return this.context.locale.shortcutsDialog.customCategory||`Custom`}},zo=class extends La{constructor(e){super(e),this._findInput=null,this._replaceInput=null,this._caseCheckbox=null,this._counterEl=null,this._closeBtn=null,this._matches=[],this._currentIndex=-1,this._caseSensitive=!1,this._useRegex=!1,this._wholeWord=!1,this._mode=`find`,this._queryRegex=null,this._lastQuery=null,this._lastCaseSensitive=null,this._lastUseRegex=null,this._lastWholeWord=null,this._focusTimer=null}destroy(){clearTimeout(this._focusTimer),this._focusTimer=null,this._clearHighlights(),super.destroy()}show(e=`find`){this._mode=e,this._updateMode(),this._open(),clearTimeout(this._focusTimer),this._focusTimer=setTimeout(()=>{this._findInput&&(this._findInput.select(),this._findInput.focus())},50)}_open(){if(this._dialog){if(this._dialog.style.display===`flex`){this._findInput&&this._findInput.focus();return}this._dialog.style.display=`flex`,this._removeTrap&&=(this._removeTrap(),null),this._removeTrap=y(this._dialog,()=>this._close())}}_close(){this._clearHighlights(),this._dialog&&(this._dialog.style.display=`none`),this._removeTrap&&=(this._removeTrap(),null),this.context.invoke(`editor.focus`)}_updateMode(){if(!this._dialog)return;let e=this._dialog.querySelector(`.an-fr-replace-row`),t=this._dialog.querySelector(`.an-fr-replace-actions`),n=this._dialog.querySelector(`.an-dialog-title`),r=this._mode===`replace`;e&&(e.style.display=r?``:`none`),t&&(t.style.display=r?``:`none`),n&&(n.textContent=r?this.context.locale.findReplace.findReplaceTitle:this.context.locale.findReplace.findTitle)}_buildDialog(){let e=this.context.locale.findReplace,t=h(`div`,{class:`an-dialog-overlay an-fr-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":e.findReplaceTitle}),n=h(`div`,{class:`an-dialog-box an-fr-box`}),r=h(`div`,{class:`an-fr-header`}),i=h(`div`,{class:`an-dialog-title-group`}),a=h(`span`,{class:`an-dialog-icon an-dialog-icon--sm`});a.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>`;let o=h(`h3`,{class:`an-dialog-title`});o.textContent=e.findTitle,i.append(a,o);let s=h(`button`,{type:`button`,class:`an-icon-close`,title:e.close,"aria-label":e.close});s.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`,this._closeBtn=s,r.append(i,s),n.appendChild(r);let c=h(`div`,{class:`an-fr-search-bar`}),l=h(`input`,{type:`text`,class:`an-input an-fr-input`,placeholder:e.findPlaceholder,"aria-label":e.searchAriaLabel});this._findInput=l;let u=h(`input`,{type:`checkbox`,style:`display:none`,"aria-hidden":`true`});this._caseCheckbox=u;let d=h(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.caseSensitive.trim(),"aria-label":e.caseSensitive.trim()});d.textContent=`Aa`;let f=h(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.useRegex,"aria-label":e.useRegex});f.textContent=`.*`;let p=h(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.wholeWord,"aria-label":e.wholeWord});p.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="7" width="18" height="10" rx="2"/><line x1="7" y1="21" x2="7" y2="17"/><line x1="17" y1="21" x2="17" y2="17"/></svg>`;let m=h(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.prevMatch,"aria-label":e.prevMatch});m.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="18 15 12 9 6 15"/></svg>`;let g=h(`button`,{type:`button`,class:`an-fr-icon-btn`,title:e.nextMatch,"aria-label":e.nextMatch});g.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>`;let _=h(`span`,{class:`an-fr-counter`});this._counterEl=_,c.append(l,u,d,f,p,m,g,_),n.appendChild(c);let y=h(`div`,{class:`an-fr-replace-row`});y.style.display=`none`;let b=h(`input`,{type:`text`,class:`an-input an-fr-input`,placeholder:e.replacePlaceholder,"aria-label":e.replaceAriaLabel});this._replaceInput=b;let x=h(`button`,{type:`button`,class:`an-btn an-fr-replace-btn`});x.textContent=e.replaceBtn;let S=h(`button`,{type:`button`,class:`an-btn an-btn-primary an-fr-replace-btn`});S.textContent=e.replaceAllBtn,y.append(b,x,S),n.appendChild(y);let C=h(`div`,{class:`an-fr-replace-actions`});C.style.display=`none`,n.appendChild(C),t.appendChild(n),ee(r,n);let te=v(s,`click`,()=>this._close()),ne=v(t,`click`,e=>{e.target===t&&this._close()}),w=v(l,`input`,()=>this._onSearch()),re=v(d,`click`,()=>{this._caseSensitive=!this._caseSensitive,u.checked=this._caseSensitive,d.classList.toggle(`an-fr-icon-btn--active`,this._caseSensitive),this._onSearch()}),ie=v(u,`change`,()=>{this._caseSensitive=u.checked,d.classList.toggle(`an-fr-icon-btn--active`,this._caseSensitive),this._onSearch()}),ae=v(g,`click`,()=>this._next()),oe=v(m,`click`,()=>this._prev()),T=v(x,`click`,()=>this._replace()),se=v(S,`click`,()=>this._replaceAll()),ce=v(l,`keydown`,e=>{let t=e;t.key===`Enter`&&(e.preventDefault(),t.shiftKey?this._prev():this._next())}),le=v(b,`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._replace())}),ue=v(f,`click`,()=>{this._useRegex=!this._useRegex,f.classList.toggle(`an-fr-icon-btn--active`,this._useRegex),this._queryRegex=null,this._lastQuery=null,this._onSearch()}),de=v(p,`click`,()=>{this._wholeWord=!this._wholeWord,p.classList.toggle(`an-fr-icon-btn--active`,this._wholeWord),this._queryRegex=null,this._lastQuery=null,this._onSearch()});return this._disposers.push(te,ne,w,re,ie,ae,oe,T,se,ce,le,ue,de),t}_onSearch(){this._clearHighlights();let e=this._findInput?this._findInput.value:``;if(!e){this._updateCounter();return}this._findAndHighlight(e),this._updateCounter()}_findAndHighlight(e){let t=this.context.layoutInfo.editable;if(!t)return;let n=this._findRawMatches(e,t);if(n.length!==0){for(let e=n.length-1;e>=0;e--){let{node:t,start:r,end:i}=n[e];try{let e=document.createRange();e.setStart(t,r),e.setEnd(t,i);let n=document.createElement(`mark`);n.className=`an-highlight`,e.surroundContents(n),this._matches.push({mark:n})}catch{this._matches.push({mark:null})}}this._matches.reverse(),this._matches=this._matches.filter(e=>e.mark),this._currentIndex=0,this._matches.length!==0&&this._matches[0]?.mark&&(this._matches[0].mark.className=`an-highlight an-highlight-current`,this._matches[0].mark.scrollIntoView({block:`center`,behavior:`smooth`}))}}_findRawMatches(e,t){let n=[];if(this._lastQuery!==e||this._lastCaseSensitive!==this._caseSensitive||this._lastUseRegex!==this._useRegex||this._lastWholeWord!==this._wholeWord){let t=this._caseSensitive?`g`:`gi`;try{let n=this._useRegex?e:e.replace(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);this._wholeWord&&(n=`\\b${n}\\b`),this._queryRegex=new RegExp(n,t)}catch{this._queryRegex=null}this._lastQuery=e,this._lastCaseSensitive=this._caseSensitive,this._lastUseRegex=this._useRegex,this._lastWholeWord=this._wholeWord}if(!this._queryRegex)return n;let r=this._queryRegex,i=document.createTreeWalker(t,4),a=i.nextNode();for(;a&&n.length<500;){r.lastIndex=0;let e;for(;(e=r.exec(a.textContent))!==null&&n.length<500;)n.push({node:a,start:e.index,end:e.index+e[0].length});a=i.nextNode()}return n}_next(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex+1)%this._matches.length,this._scrollToMatch(this._currentIndex),this._updateCounter())}_prev(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex-1+this._matches.length)%this._matches.length,this._scrollToMatch(this._currentIndex),this._updateCounter())}_scrollToMatch(e){let t=this._matches[e];t?.mark&&(this._matches.forEach((t,n)=>{t.mark&&(t.mark.className=n===e?`an-highlight an-highlight-current`:`an-highlight`)}),t.mark.scrollIntoView({block:`center`,behavior:`smooth`}))}_replace(){if(this._matches.length===0||this._currentIndex<0)return;let e=this._matches[this._currentIndex];if(!e?.mark?.parentNode)return;let t=this._replaceInput?this._replaceInput.value:``,n=e.mark.parentNode,r=document.createTextNode(t);n.insertBefore(r,e.mark),e.mark.remove(),n.normalize(),this.context.invoke(`editor.afterCommand`);let i=this._currentIndex;this._onSearch(),this._matches.length>0&&(this._currentIndex=Math.min(i,this._matches.length-1),this._scrollToMatch(this._currentIndex),this._updateCounter())}_replaceAll(){if(this._matches.length===0)return;let e=this._replaceInput?this._replaceInput.value:``;this._matches.forEach(({mark:t})=>{if(!t?.parentNode)return;let n=document.createTextNode(e);t.parentNode.insertBefore(n,t),t.remove()}),this.context.layoutInfo.editable&&this.context.layoutInfo.editable.normalize(),this._matches=[],this._currentIndex=-1,this.context.invoke(`editor.afterCommand`),this._onSearch()}_clearHighlights(){let e=this.context.layoutInfo.editable;e&&(e.querySelectorAll(`mark.an-highlight`).forEach(e=>{let t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}),e.normalize(),this._matches=[],this._currentIndex=-1)}_updateCounter(){if(!this._counterEl)return;let e=this._matches.length;if(e===0){let e=this._findInput?this._findInput.value:``;this._counterEl.textContent=e?this.context.locale.findReplace.noResults:``}else this._counterEl.textContent=`${this._currentIndex+1} / ${e}`}},X=20,Bo=`#3b82f6`,Z=(e,t,n)=>Math.min(Math.max(e,t),n);function Vo(e,t,n,r){return new Promise(i=>{let a=e=>{let a=document.createElement(`canvas`);a.width=Math.round(n),a.height=Math.round(r);let o=a.getContext(`2d`);if(!o){i(null);return}try{o.drawImage(e,t.x,t.y,t.width,t.height,0,0,a.width,a.height),o.getImageData(0,0,1,1),i(a)}catch{i(null)}};if(e.src.startsWith(`data:`)||e.src.startsWith(`blob:`)||e.src.startsWith(globalThis.location.origin)){a(e);return}let o=new Image;o.crossOrigin=`anonymous`,o.onload=()=>a(o),o.onerror=()=>i(null),o.src=e.src+(e.src.includes(`?`)?`&`:`?`)+`_an=`+Date.now()})}var Ho=class{constructor(e){this.context=e,this._img=null,this._box=null,this._imgRect=null,this._scrim=null,this._cropBox=null,this._handles={},this._toolbar=null,this._infoEl=null,this._dragDisposers=null,this._disposers=[]}initialize(){return this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[],this._close(!1)}open(e){this._scrim&&this._close(!1),this._img=e;let t=e.getBoundingClientRect();this._imgRect=t;let n=Math.min(12,t.width*.1,t.height*.1);this._box={x:t.left+n,y:t.top+n,w:t.width-n*2,h:t.height-n*2},this._buildDOM(),this._updateDOM(),this._bindEsc()}_buildDOM(){let e=document.createElement(`div`);e.className=`an-crop-scrim`,e.style.cssText=`
45
47
  position:fixed; inset:0; z-index:calc(10100 + var(--an-z-offset, 0));
46
48
  cursor:crosshair;
47
49
  background: rgba(0,0,0,0.55);
48
50
  `,this._disposers.push(v(e,`mousedown`,t=>{t.target===e&&this._close(!1)}));let t=document.createElement(`div`);t.className=`an-crop-box`,t.style.cssText=`
49
51
  position:fixed; z-index:calc(10101 + var(--an-z-offset, 0));
50
52
  box-sizing:border-box;
51
- border:2px solid ${la};
53
+ border:2px solid ${Bo};
52
54
  cursor:move;
53
55
  outline: none;
54
56
  `;let n=document.createElement(`div`);n.className=`an-crop-grid`,n.style.cssText=`
55
57
  position:absolute; inset:0; pointer-events:none;
56
58
  opacity:0.35;
57
- `,[`33.33%`,`66.66%`].forEach(e=>{let t=document.createElement(`div`);t.style.cssText=`position:absolute;top:0;bottom:0;left:${e};width:1px;background:#fff;`;let r=document.createElement(`div`);r.style.cssText=`position:absolute;left:0;right:0;top:${e};height:1px;background:#fff;`,n.appendChild(t),n.appendChild(r)}),t.appendChild(n),[{id:`nw`,cur:`nw-resize`,top:`-5px`,left:`-5px`},{id:`n`,cur:`n-resize`,top:`-5px`,left:`calc(50% - 5px)`},{id:`ne`,cur:`ne-resize`,top:`-5px`,right:`-5px`},{id:`e`,cur:`e-resize`,top:`calc(50% - 5px)`,right:`-5px`},{id:`se`,cur:`se-resize`,bottom:`-5px`,right:`-5px`},{id:`s`,cur:`s-resize`,bottom:`-5px`,left:`calc(50% - 5px)`},{id:`sw`,cur:`sw-resize`,bottom:`-5px`,left:`-5px`},{id:`w`,cur:`w-resize`,top:`calc(50% - 5px)`,left:`-5px`}].forEach(({id:e,cur:n,...r})=>{let i=document.createElement(`div`);i.className=`an-crop-handle an-crop-handle-${e}`,i.style.cssText=[`position:absolute`,`width:10px`,`height:10px`,`background:${la}`,`border:2px solid #fff`,`border-radius:2px`,`box-sizing:border-box`,`cursor:${n}`,...Object.entries(r).map(([e,t])=>`${e}:${t}`)].join(`;`),this._disposers.push(v(i,`mousedown`,t=>{t.preventDefault(),t.stopPropagation(),this._startHandleDrag(t,e)}),v(i,`touchstart`,t=>{t.preventDefault(),t.stopPropagation();let n=t;this._startHandleDrag({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY},e)},{passive:!1})),this._handles[e]=i,t.appendChild(i)}),this._disposers.push(v(t,`mousedown`,e=>{e.target.classList.contains(`an-crop-handle`)||(e.target===t||e.target===n)&&(e.preventDefault(),e.stopPropagation(),this._startBoxMove(e))}),v(t,`touchstart`,e=>{if(e.target.classList.contains(`an-crop-handle`)||e.target!==t&&e.target!==n)return;e.preventDefault(),e.stopPropagation();let r=e;this._startBoxMove({clientX:r.touches[0].clientX,clientY:r.touches[0].clientY})},{passive:!1}));let r=document.createElement(`div`);r.className=`an-crop-info`,r.style.cssText=`
59
+ `,[`33.33%`,`66.66%`].forEach(e=>{let t=document.createElement(`div`);t.style.cssText=`position:absolute;top:0;bottom:0;left:${e};width:1px;background:#fff;`;let r=document.createElement(`div`);r.style.cssText=`position:absolute;left:0;right:0;top:${e};height:1px;background:#fff;`,n.appendChild(t),n.appendChild(r)}),t.appendChild(n),[{id:`nw`,cur:`nw-resize`,top:`-5px`,left:`-5px`},{id:`n`,cur:`n-resize`,top:`-5px`,left:`calc(50% - 5px)`},{id:`ne`,cur:`ne-resize`,top:`-5px`,right:`-5px`},{id:`e`,cur:`e-resize`,top:`calc(50% - 5px)`,right:`-5px`},{id:`se`,cur:`se-resize`,bottom:`-5px`,right:`-5px`},{id:`s`,cur:`s-resize`,bottom:`-5px`,left:`calc(50% - 5px)`},{id:`sw`,cur:`sw-resize`,bottom:`-5px`,left:`-5px`},{id:`w`,cur:`w-resize`,top:`calc(50% - 5px)`,left:`-5px`}].forEach(({id:e,cur:n,...r})=>{let i=document.createElement(`div`);i.className=`an-crop-handle an-crop-handle-${e}`,i.style.cssText=[`position:absolute`,`width:10px`,`height:10px`,`background:${Bo}`,`border:2px solid #fff`,`border-radius:2px`,`box-sizing:border-box`,`cursor:${n}`,...Object.entries(r).map(([e,t])=>`${e}:${t}`)].join(`;`),this._disposers.push(v(i,`mousedown`,t=>{t.preventDefault(),t.stopPropagation(),this._startHandleDrag(t,e)}),v(i,`touchstart`,t=>{t.preventDefault(),t.stopPropagation();let n=t;this._startHandleDrag({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY},e)},{passive:!1})),this._handles[e]=i,t.appendChild(i)}),this._disposers.push(v(t,`mousedown`,e=>{e.target.classList.contains(`an-crop-handle`)||(e.target===t||e.target===n)&&(e.preventDefault(),e.stopPropagation(),this._startBoxMove(e))}),v(t,`touchstart`,e=>{if(e.target.classList.contains(`an-crop-handle`)||e.target!==t&&e.target!==n)return;e.preventDefault(),e.stopPropagation();let r=e;this._startBoxMove({clientX:r.touches[0].clientX,clientY:r.touches[0].clientY})},{passive:!1}));let r=document.createElement(`div`);r.className=`an-crop-info`,r.style.cssText=`
58
60
  position:absolute; bottom:-28px; left:0;
59
61
  font:bold 11px/20px system-ui,sans-serif;
60
62
  color:#fff; white-space:nowrap;
@@ -67,10 +69,10 @@
67
69
  align-items:center;
68
70
  box-shadow:0 4px 16px rgba(0,0,0,.4);
69
71
  font:13px system-ui,sans-serif;
70
- `;let a=this._makeToolbarBtn(`✓ Crop`,`#22c55e`,()=>this._confirm()),o=this._makeToolbarBtn(`✕ Cancel`,`#94a3b8`,()=>this._close(!1)),s=document.createElement(`label`);s.style.cssText=`color:#94a3b8;font-size:11px;cursor:pointer;display:flex;align-items:center;gap:4px;`;let c=document.createElement(`input`);c.type=`checkbox`,c.style.accentColor=la,s.appendChild(c),s.appendChild(document.createTextNode(`Lock ratio`)),this._arCheck=c,i.appendChild(a),i.appendChild(o),i.appendChild(s),this._toolbar=i,this._disposers.push(v(i,`mousedown`,e=>e.stopPropagation())),x(this.context).appendChild(e),x(this.context).appendChild(t),x(this.context).appendChild(i),this._scrim=e,this._cropBox=t}_makeToolbarBtn(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.textContent=e,r.style.cssText=`
72
+ `;let a=this._makeToolbarBtn(`✓ Crop`,`#22c55e`,()=>this._confirm()),o=this._makeToolbarBtn(`✕ Cancel`,`#94a3b8`,()=>this._close(!1)),s=document.createElement(`label`);s.style.cssText=`color:#94a3b8;font-size:11px;cursor:pointer;display:flex;align-items:center;gap:4px;`;let c=document.createElement(`input`);c.type=`checkbox`,c.style.accentColor=Bo,s.appendChild(c),s.appendChild(document.createTextNode(`Lock ratio`)),this._arCheck=c,i.appendChild(a),i.appendChild(o),i.appendChild(s),this._toolbar=i,this._disposers.push(v(i,`mousedown`,e=>e.stopPropagation())),b(this.context).appendChild(e),b(this.context).appendChild(t),b(this.context).appendChild(i),this._scrim=e,this._cropBox=t}_makeToolbarBtn(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.textContent=e,r.style.cssText=`
71
73
  background:none; border:1px solid ${t}; border-radius:4px;
72
74
  color:${t}; padding:3px 10px; cursor:pointer; font-size:12px;
73
75
  font-family:inherit;
74
76
  transition:background 0.12s;
75
- `,r.addEventListener(`mouseover`,()=>{r.style.background=t+`22`}),r.addEventListener(`mouseout`,()=>{r.style.background=`none`}),this._disposers.push(v(r,`click`,e=>{e.stopPropagation(),n()})),r}_updateDOM(){let{x:e,y:t,w:n,h:r}=this._box;this._cropBox.style.left=`${e}px`,this._cropBox.style.top=`${t}px`,this._cropBox.style.width=`${n}px`,this._cropBox.style.height=`${r}px`;let i=globalThis.innerWidth,a=globalThis.innerHeight;if(this._scrim.style.clipPath=[`polygon(`,`0 0, ${i}px 0, ${i}px ${a}px, 0 ${a}px, 0 0,`,`${e}px ${t}px, ${e}px ${t+r}px, ${e+n}px ${t+r}px, ${e+n}px ${t}px, ${e}px ${t}px`,`)`].join(``),this._img){let i=this._img.naturalWidth||0,a=this._img.naturalHeight||0,o=this._imgRect.width||1,s=this._imgRect.height||1,c={x:i/o,y:a/s},l=Z(e-this._imgRect.left,0,o),u=Z(t-this._imgRect.top,0,s),d=Z(n,0,o-l),f=Z(r,0,s-u);this._infoEl.textContent=`${Math.round(d*c.x)} × ${Math.round(f*c.y)} px`}let o=t+r+8;o+40>globalThis.innerHeight-8&&(o=t-40-8),this._toolbar.style.left=`${e}px`,this._toolbar.style.top=`${o}px`}_startBoxMove(e){let t=e.clientX-this._box.x,n=e.clientY-this._box.y,r=this._imgRect;this._attachDocDrag(e=>{this._box.x=Z(e.clientX-t,r.left,r.right-this._box.w),this._box.y=Z(e.clientY-n,r.top,r.bottom-this._box.h),this._updateDOM()})}_startHandleDrag(e,t){let n=e.clientX,r=e.clientY,i={...this._box},a=this._imgRect,o=this._arCheck?.checked,s=i.w/(i.h||1);this._attachDocDrag(e=>{let c=e.clientX-n,l=e.clientY-r,{x:u,y:d,w:f,h:p}=i;t.includes(`e`)&&(f=Math.max(X,i.w+c)),t.includes(`s`)&&(p=Math.max(X,i.h+l)),t.includes(`w`)&&(u=Math.min(i.x+i.w-X,i.x+c),f=i.x+i.w-u),t.includes(`n`)&&(d=Math.min(i.y+i.h-X,i.y+l),p=i.y+i.h-d),o&&t.length===2&&(Math.abs(c)>=Math.abs(l)?(p=f/s,t.includes(`n`)&&(d=i.y+i.h-p)):(f=p*s,t.includes(`w`)&&(u=i.x+i.w-f))),u=Z(u,a.left,a.right-X),d=Z(d,a.top,a.bottom-X),f=Z(f,X,a.right-u),p=Z(p,X,a.bottom-d),this._box={x:u,y:d,w:f,h:p},this._updateDOM()})}_attachDocDrag(e){this._dragDisposers?.();let t=t=>{t.preventDefault();let n=t;e({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY})},n=()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,n),document.removeEventListener(`touchmove`,t),document.removeEventListener(`touchend`,n),document.body.style.userSelect=``,document.body.style.cursor=``,this._dragDisposers=null};this._dragDisposers=n,document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,n,{once:!0}),document.addEventListener(`touchmove`,t,{passive:!1}),document.addEventListener(`touchend`,n,{once:!0})}_bindEsc(){let e=e=>{e.key===`Escape`&&(e.preventDefault(),this._close(!1)),e.key===`Enter`&&(e.preventDefault(),this._confirm())};document.addEventListener(`keydown`,e),this._disposers.push(()=>document.removeEventListener(`keydown`,e))}async _confirm(){let e=this._img;if(!e){this._close(!1);return}let t=this._imgRect,{x:n,y:r,w:i,h:a}=this._box,o=(e.naturalWidth||e.width||1)/(t.width||1),s=(e.naturalHeight||e.height||1)/(t.height||1),c=Math.round(Z(n-t.left,0,t.width)*o),l=Math.round(Z(r-t.top,0,t.height)*s),u=Math.round(Z(i,0,t.width-(n-t.left))*o),d=Math.round(Z(a,0,t.height-(r-t.top))*s);if(u<=0||d<=0){this._close(!1);return}let f=await ua(e,{x:c,y:l,width:u,height:d},i,a);if(!f){this._showCropError(`Cannot crop this image: the image server does not allow cross-origin access. Upload the image directly to use the crop tool.`),this._close(!1);return}let p=/^data:image\/(jpe?g)/i.exec(e.src)?`image/jpeg`:`image/png`,m=p===`image/jpeg`?.92:void 0,h=f.toDataURL(p,m);this._close(!1),e.src=h,e.style.width=``,e.style.height=``,e.removeAttribute(`width`),e.removeAttribute(`height`),this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`)}_showCropError(e){let t=document.createElement(`div`);t.setAttribute(`role`,`alert`),t.style.cssText=[`position:fixed`,`bottom:24px`,`left:50%`,`transform:translateX(-50%)`,`z-index:calc(10200 + var(--an-z-offset, 0))`,`max-width:420px`,`width:max-content`,`background:#7f1d1d`,`color:#fecaca`,`border:1px solid #b91c1c`,`border-radius:8px`,`padding:12px 18px`,`font:13px/1.5 system-ui,sans-serif`,`box-shadow:0 4px 16px rgba(0,0,0,.4)`,`pointer-events:auto`].join(`;`),t.textContent=e,x(this.context).appendChild(t),setTimeout(()=>{t.remove()},4e3)}_close(e){this._dragDisposers?.(),this._dragDisposers=null,this._disposers.forEach(e=>e()),this._disposers=[],[this._scrim,this._cropBox,this._toolbar].forEach(e=>{e?.remove()}),this._scrim=null,this._cropBox=null,this._toolbar=null,this._infoEl=null,this._handles={},this._img=null,this._box=null,this._imgRect=null,this._arCheck=null}},fa=class{constructor(e){this.context=e,this.options=e.options,this._banner=null}initialize(){if(!this.options.autoSave||!this.options.autoSaveRestore)return this;let e=this.options.autoSaveKey,t=e+`:asrmeta`,n,r;try{n=localStorage.getItem(e),r=JSON.parse(localStorage.getItem(t)||`{}`)}catch{return this}if(!n)return this;let i=this.options.autoSaveRestoreTimeout;if(i>0&&Date.now()-(r.savedAt||0)>i*864e5){try{localStorage.removeItem(e),localStorage.removeItem(t)}catch{}return this}return this._showBanner(n,r),this}destroy(){this._removeBanner()}_showBanner(e,t){let n=this.context.locale.autoSaveRestore||{},r=n.found||`Draft found. Restore?`,i=n.restore||`Restore`,a=n.discard||`Discard`,o=document.createElement(`div`);o.className=`an-asr-banner`,o.setAttribute(`role`,`alert`);let s=document.createElement(`span`);if(s.className=`an-asr-msg`,t.savedAt){let e=new Date(t.savedAt).toLocaleString();s.textContent=(n.foundAt||`Draft from {date}. Restore?`).replace(`{date}`,e)}else s.textContent=r;let c=document.createElement(`button`);c.type=`button`,c.className=`an-btn an-asr-btn-restore`,c.textContent=i,c.addEventListener(`click`,()=>this._restore(e));let l=document.createElement(`button`);l.type=`button`,l.className=`an-btn an-asr-btn-discard`,l.textContent=a,l.addEventListener(`click`,()=>this._discard()),o.appendChild(s),o.appendChild(c),o.appendChild(l),this._banner=o;let u=this.context.layoutInfo.container;u.insertBefore(o,u.firstChild)}_restore(e){this.context.setHTML(e),this.context.clearHistory(),this._removeBanner(),this.context.triggerEvent(`autoSaveRestore`,e,this.context)}_discard(){let e=this.options.autoSaveKey;try{localStorage.removeItem(e),localStorage.removeItem(e+`:asrmeta`)}catch{}this._removeBanner()}_removeBanner(){this._banner?.remove(),this._banner=null}},pa=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){if(!this.options.markdownShortcuts)return this;let e=this.context.layoutInfo.editable,t=v(e,`keydown`,e=>this._onKeydown(e)),n=v(e,`input`,()=>this._onInput());return this._disposers.push(t,n),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[]}_onKeydown(e){this._inCodeContext()||(e.key===` `?this._applyBlockRule()&&e.preventDefault():e.key===`Enter`&&this._applyEnterRule()&&e.preventDefault())}_inCodeContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;return!!(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(`pre, code`)}_getLineContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=this.context.layoutInfo.editable;if(!n.contains(t.startContainer))return null;let r=t.startContainer;for(;r&&r!==n&&!this._isBlock(r);)r=r.parentNode;(!r||r===n)&&(r=t.startContainer);let i=document.createRange();return i.setStart(r,0),i.setEnd(t.startContainer,t.startOffset),{text:i.toString(),range:t,lineNode:r}}_isBlock(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=globalThis.getComputedStyle(e).display;return t===`block`||t===`list-item`||t===`table-cell`}_applyBlockRule(){let e=this._getLineContext();if(!e)return!1;let{text:t}=e,n=[{re:/^(#{1,6})$/,handler:e=>this._convertToHeading(e[1].length)},{re:/^>$/,handler:()=>this._convertToBlockquote()},{re:/^[-*+]$/,handler:()=>this._convertToList(`ul`)},{re:/^1[.)]$/,handler:()=>this._convertToList(`ol`)},{re:/^\[([ xX])\]$/,handler:e=>this._convertToChecklist(e[1].toLowerCase()===`x`)}];for(let{re:e,handler:r}of n){let n=e.exec(t);if(n)return r(n),!0}return!1}_applyEnterRule(){let e=this._getLineContext();if(!e)return!1;let{text:t}=e;return/^(?:-{3,}|\*{3,}|_{3,})$/.test(t)?(this._convertToHr(),!0):/^(?:`{3}|~{3})/.test(t)?(this._convertToCodeBlock(),!0):!1}_selectLineAndDelete(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0),n=document.createRange();n.setStart(t.startContainer.parentNode||t.startContainer,0),n.setEnd(t.startContainer,t.startOffset),n.deleteContents()}_convertToHeading(e){this._selectLineAndDelete(),document.execCommand(`formatBlock`,!1,`h${e}`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToBlockquote(){this._selectLineAndDelete(),document.execCommand(`formatBlock`,!1,`blockquote`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToList(e){this._selectLineAndDelete(),document.execCommand(e===`ul`?`insertUnorderedList`:`insertOrderedList`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToChecklist(e=!1){if(this._selectLineAndDelete(),this.context.invoke(`editor.toggleChecklist`),e){let e=globalThis.getSelection(),t=e?.rangeCount?e.getRangeAt(0).startContainer:null,n=(t?.nodeType===Node.ELEMENT_NODE?t:t?.parentElement??null)?.closest(`li`)?.querySelector(`input[type="checkbox"]`)??null;n&&(n.checked=!0)}this.context.triggerEvent(`change`,this.context.getHTML())}_convertToHr(){this._selectLineAndDelete(),this.context.invoke(`editor.insertHr`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToCodeBlock(){this._selectLineAndDelete(),document.execCommand(`formatBlock`,!1,`pre`),this.context.triggerEvent(`change`,this.context.getHTML())}_onInput(){if(this._inCodeContext())return;let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0);if(!t.collapsed||!this.context.layoutInfo.editable.contains(t.startContainer))return;let n=t.startContainer;if(n.nodeType!==Node.TEXT_NODE)return;let r=n.textContent,i=t.startOffset,a=[{re:/\*\*(.+?)\*\*$/,tag:`strong`},{re:/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)$/,tag:`em`},{re:/~~(.+?)~~$/,tag:`s`},{re:/`([^`]+)`$/,tag:`code`}],o=r.slice(0,i);for(let{re:t,tag:s}of a){let a=t.exec(o);if(!a)continue;let c=o.length-a[0].length,l=i,u=a[1],d=r.slice(0,c),f=r.slice(l),p=document.createElement(s);p.textContent=u;let m=document.createTextNode(d),h=document.createTextNode(`​`+f);n.before(m,p,h),n.remove();let g=document.createRange();g.setStart(h,1),g.collapse(!0),e.removeAllRanges(),e.addRange(g),this.context.triggerEvent(`change`,this.context.getHTML());break}}},ma=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,Q=e=>`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" ${ma} style="display:block">${e}</svg>`,ha={bold:Q(`<path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/><path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/>`),italic:Q(`<line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/>`),underline:Q(`<path d="M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"/><line x1="4" y1="21" x2="20" y2="21"/>`),strikethrough:Q(`<path d="M17.3 12H6.7"/><path d="M10 6.5C10 5.1 11.1 4 12.5 4c1.4 0 2.5 1.1 2.5 2.5 0 .8-.4 1.5-1 2"/><path d="M14 17.5C14 19 12.9 20 11.5 20 10.1 20 9 18.9 9 17.5c0-.8.4-1.5 1-2"/>`),link:Q(`<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>`),foreColor:Q(`<path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/>`),hiliteColor:Q(`<path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/><line x1="3" y1="21" x2="21" y2="21"/>`),removeFormat:Q(`<path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/>`),inlineCode:Q(`<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/><path d="M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1"/>`)},ga={bold:e=>e.invoke(`editor.bold`),italic:e=>e.invoke(`editor.italic`),underline:e=>e.invoke(`editor.underline`),strikethrough:e=>e.invoke(`editor.strikethrough`),link:e=>e.invoke(`linkDialog.show`),removeFormat:e=>{let t=e.layoutInfo?.editable;if(!t)return;t.focus(),document.execCommand(`removeFormat`);let n=globalThis.getSelection();if(n?.rangeCount>0&&!n.getRangeAt(0).collapsed){let e=n.getRangeAt(0),t=e.commonAncestorContainer,r=t.nodeType===1?t:t.parentElement;if(r){let t=[r,...r.querySelectorAll(`[style]`)];for(let n of t)n.hasAttribute(`style`)&&e.intersectsNode(n)&&n.removeAttribute(`style`)}}e.invoke(`editor.afterCommand`)},inlineCode:e=>e.invoke(`editor.inlineCode`)},_a={bold:()=>document.queryCommandState(`bold`),italic:()=>document.queryCommandState(`italic`),underline:()=>document.queryCommandState(`underline`),strikethrough:()=>document.queryCommandState(`strikeThrough`)},va={foreColor:!0,hiliteColor:!0},ya=[{name:`editor`,Class:Wr},{name:`toolbar`,Class:Zr},{name:`statusbar`,Class:$r},{name:`clipboard`,Class:ei},{name:`placeholder`,Class:oi},{name:`contextMenu`,Class:ri},{name:`codeview`,Class:si},{name:`fullscreen`,Class:ci},{name:`linkDialog`,Class:ui},{name:`imageDialog`,Class:fi},{name:`videoDialog`,Class:mi},{name:`imageResizer`,Class:_i},{name:`videoResizer`,Class:vi},{name:`linkTooltip`,Class:Si},{name:`imageTooltip`,Class:wi},{name:`videoTooltip`,Class:Ti},{name:`tableTooltip`,Class:Mi},{name:`codeTooltip`,Class:Bi},{name:`emojiDialog`,Class:Ji},{name:`iconDialog`,Class:ra},{name:`shortcutsDialog`,Class:sa},{name:`findReplace`,Class:ca},{name:`imageCropOverlay`,Class:da},{name:`autoSaveRestore`,Class:fa,enabled:e=>!!e.autoSaveRestore},{name:`markdownShortcuts`,Class:pa,enabled:e=>e.markdownShortcuts!==!1},{name:`bubbleToolbar`,Class:class{constructor(e){this.context=e,this.options=e.options,this._el=null,this._picker=null,this._pickerType=null,this._savedRange=null,this._visible=!1,this._rafId=null,this._contextMenuOpen=!1,this._disposers=[],this._onSelectionChange=this._onSelectionChange.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onContextMenu=this._onContextMenu.bind(this)}initialize(){if(!this.options.bubbleToolbar)return this;this._build(),this._buildColorPicker();let e=v(document,`selectionchange`,this._onSelectionChange),t=v(document,`mousedown`,this._onMousedown),n=v(document,`keydown`,this._onKeydown),r=v(document,`contextmenu`,this._onContextMenu),i=this.context.on(`contextMenu:show`,()=>{this._contextMenuOpen=!0,this._hide()}),a=this.context.on(`contextMenu:hide`,()=>{this._contextMenuOpen=!1}),o=v(globalThis,`scroll`,()=>this._hide(),{passive:!0}),s=v(globalThis,`resize`,()=>this._hide(),{passive:!0});return this._disposers.push(e,t,n,r,i,a,o,s),this}destroy(){this._el?.remove(),this._el=null,this._picker?.remove(),this._picker=null,this._disposers.forEach(e=>e()),this._disposers=[],cancelAnimationFrame(this._rafId)}_build(){let e=document.createElement(`div`);e.className=`an-bubble-toolbar`,e.setAttribute(`role`,`toolbar`),e.setAttribute(`aria-label`,`Formatting`);let t=this.options.bubbleToolbarItems||[`bold`,`italic`,`underline`,`link`,`foreColor`,`hiliteColor`,`removeFormat`];for(let n of t){if(!ha[n])continue;let t=qe(this.options,[n])??ha[n],r=document.createElement(`button`);r.type=`button`,r.dataset.name=n;let i=this.context.locale?.toolbar?.[n];if(r.setAttribute(`aria-label`,typeof i==`string`?i:n),va[n]){r.className=`an-bubble-btn an-bubble-btn--color`;let e=document.createElement(`span`);e.className=`an-bubble-btn-svg`,e.innerHTML=t;let i=document.createElement(`span`);i.className=`an-bubble-color-strip`,i.style.background=n===`foreColor`?`#000000`:`transparent`,r.appendChild(e),r.appendChild(i)}else r.className=`an-bubble-btn`,r.innerHTML=t;r.addEventListener(`mousedown`,e=>{e.preventDefault()}),r.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),va[n]){this._openColorPicker(n,r);return}this.context.triggerEvent?.(`beforeCommand`,{name:n,source:`bubbleToolbar`})!==!1&&(this.context.invoke(`editor.focus`),ga[n]&&ga[n](this.context),this._syncActive())}),e.appendChild(r)}x(this.context).appendChild(e),this._el=e,this._btnCache=Array.from(e.querySelectorAll(`.an-bubble-btn`))}_buildColorPicker(){let e=document.createElement(`div`);e.className=`an-bubble-color-picker`,e.style.display=`none`,e.addEventListener(`mousedown`,e=>e.preventDefault());let t=document.createElement(`div`);t.className=`an-context-color-palette`,Kr(this.options).forEach(e=>{let n=document.createElement(`div`);n.className=`an-context-color-swatch`,n.title=e,n.style.background=e,n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,e),n.addEventListener(`click`,t=>{t.stopPropagation(),this._applyColor(this._pickerType,e)}),t.appendChild(n)});let n=document.createElement(`div`);n.className=`an-context-color-swatch an-context-color-none`,n.title=`No highlight`,n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,`No highlight`),n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="4" y1="4" x2="20" y2="20"/><line x1="20" y1="4" x2="4" y2="20"/></svg>`,n.addEventListener(`click`,e=>{e.stopPropagation(),this._applyColor(`hiliteColor`,`transparent`)});let r=document.createElement(`div`);r.className=`an-context-color-custom`;let i=document.createElement(`input`);i.type=`color`,i.value=`#000000`,i.title=`Custom color`,i.addEventListener(`mousedown`,e=>e.stopPropagation()),i.addEventListener(`change`,()=>{this._applyColor(this._pickerType,i.value)});let a=document.createElement(`span`);a.textContent=`Custom…`,r.appendChild(i),r.appendChild(a),e.appendChild(t),e.appendChild(r),x(this.context).appendChild(e),this._picker=e;let o=e;o._paletteEl=t,o._noColorBtn=n,o._colorInput=i}_openColorPicker(e,t){let n=globalThis.getSelection();n?.rangeCount>0&&(this._savedRange=n.getRangeAt(0).cloneRange()),this._pickerType=e;let r=this._picker,i=r._paletteEl,a=r._noColorBtn;e===`hiliteColor`?i.contains(a)||i.appendChild(a):i.contains(a)&&a.remove(),this._picker._colorInput.value=e===`foreColor`?`#000000`:`#ffff00`,this._picker.style.display=`block`;let o=this._picker.offsetWidth,s=this._picker.offsetHeight,c=this._el.getBoundingClientRect(),l=c.top-s-6;l<8&&(l=c.bottom+6);let u=t.getBoundingClientRect().left;u=Math.max(8,Math.min(u,globalThis.innerWidth-o-8)),this._picker.style.left=`${u}px`,this._picker.style.top=`${l}px`}_closeColorPicker(){this._picker&&(this._picker.style.display=`none`),this._pickerType=null}_applyColor(e,t){let n=this.context.layoutInfo?.editable;if(!n||!this._savedRange)return;n.focus();let r=globalThis.getSelection();r.removeAllRanges();try{r.addRange(this._savedRange.cloneRange())}catch{return}let i=e===`hiliteColor`?`hiliteColor`:e;!document.execCommand(i,!1,t)&&i===`hiliteColor`&&document.execCommand(`backColor`,!1,t),this.context.invoke(`editor.afterCommand`);let a=e===`hiliteColor`?`hiliteColor`:`foreColor`,o=(this._el?.querySelector(`[data-name="${a}"]`))?.querySelector(`.an-bubble-color-strip`);o&&(o.style.background=t===`transparent`?`transparent`:t),this._closeColorPicker(),this._syncActive()}_show(e){if(!this._el)return;let t=this._el;t.style.visibility=`hidden`,t.style.display=`flex`;let n=t.offsetWidth,r=t.offsetHeight,i=e.left+e.width/2-n/2,a=e.top-r-8;i=Math.max(8,Math.min(i,globalThis.innerWidth-n-8)),a<8&&(a=e.bottom+8);let o=document.querySelector(`.an-table-tooltip`);if(o&&o.style.display!==`none`){let t=o.getBoundingClientRect();a<t.bottom+8&&a+r>t.top-8&&(a=e.bottom+8,a+r>globalThis.innerHeight-8&&(a=t.bottom+8))}t.style.top=`${a}px`,t.style.left=`${i}px`,t.style.visibility=``,this._syncActive(),this._syncColorStrips(),this._visible=!0}_hide(){this._el&&(this._el.style.display=`none`,this._visible=!1,this._closeColorPicker())}_syncActive(){this._btnCache&&this._btnCache.forEach(e=>{let t=_a[e.dataset.name];e.classList.toggle(`an-active`,!!t?.())})}_syncColorStrips(){if(!this._el)return;let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).startContainer;if(t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),!t)return;let n=globalThis.getComputedStyle(t),r=this._el.querySelector(`[data-name="foreColor"]`)?.querySelector(`.an-bubble-color-strip`);r&&(r.style.background=n.color||`#000000`);let i=this._el.querySelector(`[data-name="hiliteColor"]`)?.querySelector(`.an-bubble-color-strip`);if(i){let e=n.backgroundColor;i.style.background=!e||e===`rgba(0, 0, 0, 0)`||e===`transparent`?`transparent`:e}}_onSelectionChange(){cancelAnimationFrame(this._rafId),this._rafId=requestAnimationFrame(()=>{if(this._contextMenuOpen||this._picker&&this._picker.style.display!==`none`)return;let e=globalThis.getSelection();if(!e||e.isCollapsed||!e.rangeCount){this._hide();return}if(!this.context.layoutInfo.editable.contains(e.anchorNode)){this._hide();return}if(this.context.options.readOnly){this._hide();return}let t=e.getRangeAt(0).getBoundingClientRect();if(!t||t.width===0){this._hide();return}this._show(t)})}_onMousedown(e){this._visible&&(this._el?.contains(e.target)||this._picker?.contains(e.target)||this.context.layoutInfo.editable.contains(e.target)||this._hide())}_onKeydown(e){e.key===`Escape`&&(this._picker&&this._picker.style.display!==`none`?this._closeColorPicker():this._visible&&this._hide())}_onContextMenu(){this._hide()}},enabled:e=>!!e.bubbleToolbar},{name:`mention`,Class:class{constructor(e){this.context=e,this._dropdown=null,this._query=``,this._debounceTimer=null,this._activeIndex=-1,this._items=[],this._open=!1,this._triggerNode=null,this._triggerOffset=0,this._caretRect=null,this._disposers=[]}initialize(){let e=this.context.options.mention;if(!e||typeof e.onSearch!=`function`)return this;this._cfg={trigger:e.trigger||`@`,minChars:e.minChars??0,maxResults:e.maxResults??8,debounce:e.debounce??200,onSearch:e.onSearch,onInsert:e.onInsert||null,onError:e.onError||null,mentionClass:e.mentionClass||`an-mention`,allowSpaces:e.allowSpaces||!1},this._buildDropdown();let t=this.context.layoutInfo.editable,n=v(t,`keydown`,e=>this._onKeydown(e)),r=v(t,`input`,()=>this._onInput()),i=v(document,`click`,e=>this._onDocClick(e));return this._disposers.push(n,r,i),this}destroy(){clearTimeout(this._debounceTimer),this._dropdown?.remove(),this._dropdown=null,this._disposers.forEach(e=>e()),this._disposers=[]}_buildDropdown(){let e=document.createElement(`div`);e.className=`an-mention-dropdown`,e.setAttribute(`role`,`listbox`),e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,e=>{let t=e.target?.closest(`.an-mention-item`);t&&this._select(+t.dataset.index)}),e.addEventListener(`mousemove`,e=>{let t=e.target?.closest(`.an-mention-item`);t&&this._highlightItem(+t.dataset.index)}),x(this.context).appendChild(e),this._dropdown=e}_renderItems(e){let t=this._dropdown;this._items=e.slice(0,this._cfg.maxResults),this._activeIndex=this._items.length>0?0:-1;let n=document.createDocumentFragment();this._items.forEach((e,t)=>{let r=document.createElement(`div`);if(r.className=`an-mention-item`,r.setAttribute(`role`,`option`),r.dataset.index=String(t),e.avatar){let t=document.createElement(`img`);t.src=e.avatar,t.className=`an-mention-avatar`,t.alt=``,r.appendChild(t)}let i=document.createElement(`span`);i.textContent=e.label,r.appendChild(i),n.appendChild(r)}),t.innerHTML=``,t.appendChild(n),this._highlightItem(this._activeIndex)}_highlightItem(e){this._dropdown&&(this._dropdown.querySelectorAll(`.an-mention-item`).forEach((t,n)=>{t.classList.toggle(`an-mention-active`,n===e)}),this._activeIndex=e)}_positionDropdown(){let e=this._dropdown,t=this._caretRect;if(!t||t.height===0)return;e.style.visibility=`hidden`,e.style.display=`block`;let n=e.offsetHeight,r=e.offsetWidth,i=t.bottom+4,a=t.left;t.bottom+n+8>globalThis.innerHeight&&(i=t.top-n-4),a=Math.max(8,Math.min(a,globalThis.innerWidth-r-8)),e.style.top=`${i}px`,e.style.left=`${a}px`,e.style.visibility=``}_showDropdown(){this._open=!0,this._positionDropdown()}_hideDropdown(){this._dropdown&&(this._dropdown.style.display=`none`),this._open=!1,this._items=[],this._activeIndex=-1,this._triggerNode=null,this._caretRect=null,this._query=``}_captureCaretRect(){if(this._triggerNode?.isConnected)try{let e=document.createRange(),t=Math.min(this._triggerOffset+1,this._triggerNode.textContent.length);e.setStart(this._triggerNode,this._triggerOffset),e.setEnd(this._triggerNode,t);let n=e.getBoundingClientRect();if(n.height>0){this._caretRect=n;return}}catch{}let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).getClientRects();t.length>0&&(this._caretRect=t[t.length-1])}_getQueryAtCursor(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=t.startContainer;if(n.nodeType!==Node.TEXT_NODE)return null;let r=n.textContent.slice(0,t.startOffset),i=this._cfg.trigger,a=r.lastIndexOf(i);if(a===-1)return null;let o=r.slice(a+i.length);return!this._cfg.allowSpaces&&/\s/.test(o)||o.length<this._cfg.minChars?null:(this._triggerNode=n,this._triggerOffset=a,o)}_onInput(){if(!this._cfg)return;let e=this._getQueryAtCursor();if(e===null){this._hideDropdown();return}this._captureCaretRect(),this._query=e,clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{let e=e=>{if(!Array.isArray(e)||e.length===0){this._hideDropdown();return}this._renderItems(e),this._showDropdown()},t;try{t=this._cfg.onSearch(this._query,e)}catch(e){this._hideDropdown(),typeof this._cfg.onError==`function`&&this._cfg.onError(e);return}t&&typeof t.then==`function`&&t.then(e).catch(e=>{this._hideDropdown(),typeof this._cfg.onError==`function`&&this._cfg.onError(e)})},this._cfg.debounce)}_onKeydown(e){if(!(!this._cfg||!this._open)){if(e.key===`ArrowDown`){e.preventDefault();let t=(this._activeIndex+1)%this._items.length;this._highlightItem(t)}else if(e.key===`ArrowUp`){e.preventDefault();let t=(this._activeIndex-1+this._items.length)%this._items.length;this._highlightItem(t)}else e.key===`Enter`||e.key===`Tab`?this._activeIndex>=0&&(e.preventDefault(),this._select(this._activeIndex)):e.key===`Escape`&&this._hideDropdown()}}_onDocClick(e){this._open&&(this._dropdown?.contains(e.target)||this._hideDropdown())}_select(e){let t=this._items[e];if(!t)return;if(this._triggerNode){let e=this._triggerNode;e.textContent=e.textContent.slice(0,this._triggerOffset)+e.textContent.slice(this._triggerOffset+this._cfg.trigger.length+this._query.length);let t=globalThis.getSelection(),n=document.createRange();n.setStart(e,this._triggerOffset),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}let n;typeof this._cfg.onInsert==`function`&&(n=this._cfg.onInsert(t)),n||=`<span class="${this._cfg.mentionClass}" data-mention-id="${t.id}" contenteditable="false">@${t.label}</span>`,this.context.invoke(`editor.insertHTML`,n+`&#8203;`),this._hideDropdown(),this.context.triggerEvent(`change`,this.context.getHTML())}},enabled:e=>!!e.mention},{name:`slashMenu`,Class:class{constructor(e){this.context=e,this.options=e.options,this._disposers=[],this._menu=null,this._filtered=[],this._activeIndex=-1,this._open=!1,this._query=``,this._textNode=null,this._triggerOffset=0,this._caretRect=null}initialize(){if(this.options.slashMenu===!1)return this;let e=this.context.layoutInfo.editable,t=v(e,`input`,()=>this._onInput()),n=v(e,`keydown`,e=>this._onKeydown(e)),r=v(document,`click`,e=>this._onDocClick(e));return this._disposers.push(t,n,r),this}destroy(){this._menu?.remove(),this._menu=null,this._disposers.forEach(e=>e()),this._disposers=[]}_commands(){let e=this.context.locale.slashMenu,t=this.context,n=[{id:`h1`,label:e.heading1,keywords:`h1 heading title`,run:()=>t.invoke(`editor.formatBlock`,`h1`)},{id:`h2`,label:e.heading2,keywords:`h2 heading subtitle`,run:()=>t.invoke(`editor.formatBlock`,`h2`)},{id:`h3`,label:e.heading3,keywords:`h3 heading`,run:()=>t.invoke(`editor.formatBlock`,`h3`)},{id:`ul`,label:e.bulletList,keywords:`ul bullet list unordered`,run:()=>t.invoke(`editor.insertUL`)},{id:`ol`,label:e.numberedList,keywords:`ol numbered list ordered`,run:()=>t.invoke(`editor.insertOL`)},{id:`checklist`,label:e.checklist,keywords:`checklist todo checkbox task`,run:()=>t.invoke(`editor.toggleChecklist`)},{id:`quote`,label:e.blockquote,keywords:`quote blockquote`,run:()=>t.invoke(`editor.formatBlock`,`blockquote`)},{id:`code`,label:e.codeBlock,keywords:`code pre block`,run:()=>t.invoke(`editor.formatBlock`,`pre`)},{id:`hr`,label:e.horizontalRule,keywords:`hr divider rule line`,run:()=>t.invoke(`editor.insertHr`)},{id:`table`,label:e.table,keywords:`table grid`,run:()=>t.invoke(`editor.insertTable`,3,3)},{id:`image`,label:e.image,keywords:`image picture photo upload`,run:()=>t.invoke(`imageDialog.show`)}],r=(this.options.slashCommands||[]).map(e=>({id:e.id,label:e.label||e.id,keywords:e.keywords||``,run:()=>e.run(t)}));return[...n,...r]}refresh(){this._open&&this._filterAndRender()}_buildMenu(){let e=document.createElement(`div`);return e.className=`an-slash-menu`,e.setAttribute(`role`,`listbox`),e.style.display=`none`,e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,e=>{let t=e.target?.closest(`.an-slash-menu-item`);t&&this._select(+t.dataset.index)}),e.addEventListener(`mousemove`,e=>{let t=e.target?.closest(`.an-slash-menu-item`);t&&this._highlight(+t.dataset.index)}),x(this.context).appendChild(e),this._menu=e,e}_renderItems(){this._menu||this._buildMenu();let e=this._menu,t=this.context.locale.slashMenu;if(this._filtered.length===0){e.innerHTML=``;let n=document.createElement(`div`);n.className=`an-slash-menu-empty`,n.textContent=t.noResults,e.appendChild(n),this._activeIndex=-1;return}let n=document.createDocumentFragment();this._filtered.forEach((e,t)=>{let r=document.createElement(`div`);r.className=`an-slash-menu-item`,r.setAttribute(`role`,`option`),r.id=`an-slash-option-${e.id}`,r.dataset.index=String(t),r.textContent=e.label,n.appendChild(r)}),e.innerHTML=``,e.appendChild(n),this._highlight(0)}_highlight(e){this._menu&&(this._menu.querySelectorAll(`.an-slash-menu-item`).forEach((t,n)=>{let r=n===e;t.classList.toggle(`an-slash-menu-active`,r),t.setAttribute(`aria-selected`,String(r)),r&&this._menu.setAttribute(`aria-activedescendant`,t.id)}),this._activeIndex=e)}_position(){let e=this._menu,t=this._caretRect;if(!e||!t||t.height===0)return;e.style.visibility=`hidden`,e.style.display=`block`;let n=e.offsetHeight,r=e.offsetWidth,i=t.bottom+4,a=t.left;t.bottom+n+8>globalThis.innerHeight&&(i=t.top-n-4),a=Math.max(8,Math.min(a,globalThis.innerWidth-r-8)),e.style.top=`${i}px`,e.style.left=`${a}px`,e.style.visibility=``}_open_(){this._open=!0,this._filterAndRender(),this._position()}_close(){this._menu&&(this._menu.style.display=`none`),this._open=!1,this._filtered=[],this._activeIndex=-1,this._menu?.removeAttribute(`aria-activedescendant`),this._textNode=null,this._caretRect=null,this._query=``}_isBlock(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=globalThis.getComputedStyle(e).display;return t===`block`||t===`list-item`||t===`table-cell`}_getTriggerContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=this.context.layoutInfo.editable;if(!n.contains(t.startContainer)||t.startContainer.nodeType!==Node.TEXT_NODE)return null;let r=t.startContainer.parentNode;for(;r&&r!==n&&!this._isBlock(r);)r=r.parentNode;if(!r||r===n)return null;let i=r.textContent||``,a=document.createRange();a.setStart(r,0),a.setEnd(t.startContainer,t.startOffset);let o=a.toString(),s=/^\/(\S*)$/.exec(o);return!s||i.length>o.length?null:{query:s[1],textNode:t.startContainer,triggerOffset:t.startOffset-s[0].length}}_captureCaretRect(e,t){try{let n=document.createRange(),r=Math.min(t+1,e.textContent.length);n.setStart(e,t),n.setEnd(e,r);let i=n.getBoundingClientRect();if(i.height>0)return i}catch{}let n=globalThis.getSelection();if(!n?.rangeCount)return null;let r=n.getRangeAt(0).getClientRects();return r.length>0?r[r.length-1]:null}_filterAndRender(){let e=this._query.toLowerCase();this._filtered=e?this._commands().filter(t=>t.keywords.includes(e)||t.label.toLowerCase().includes(e)):this._commands(),this._renderItems()}_onInput(){let e=this._getTriggerContext();if(!e){this._open&&this._close();return}this._textNode=e.textNode,this._triggerOffset=e.triggerOffset,this._query=e.query,this._caretRect=this._captureCaretRect(e.textNode,e.triggerOffset),this._open?(this._filterAndRender(),this._position()):this._open_()}_onKeydown(e){if(this._open){if(e.key===`ArrowDown`){if(e.preventDefault(),this._filtered.length===0)return;this._highlight((this._activeIndex+1)%this._filtered.length)}else if(e.key===`ArrowUp`){if(e.preventDefault(),this._filtered.length===0)return;this._highlight((this._activeIndex-1+this._filtered.length)%this._filtered.length)}else e.key===`Enter`||e.key===`Tab`?this._activeIndex>=0&&(e.preventDefault(),this._select(this._activeIndex)):e.key===`Escape`&&(e.preventDefault(),this._close())}}_onDocClick(e){this._open&&(this._menu?.contains(e.target)||this._close())}_deleteTriggerText(){let e=this._textNode;if(!e?.isConnected)return;e.textContent=e.textContent.slice(0,this._triggerOffset)+e.textContent.slice(this._triggerOffset+1+this._query.length);let t=globalThis.getSelection();if(!t)return;let n=document.createRange();n.setStart(e,this._triggerOffset),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}_makeTriggerRemover(){let e=this._textNode,t=this._triggerOffset,n=this._query;return()=>{if(!e?.isConnected)return;let r=e.textContent.slice(0,t),i=e.textContent.slice(t+1+n.length);e.textContent=r+i;let a=globalThis.getSelection();if(!a)return;let o=document.createRange();o.setStart(e,t),o.collapse(!0),a.removeAllRanges(),a.addRange(o)}}_select(e){let t=this._filtered[e];if(t){if(t.id===`image`){let e=this._makeTriggerRemover();this._close(),this.context.invoke(`imageDialog.show`,{beforeInsert:e});return}this._deleteTriggerText(),this._close(),t.run()}}},enabled:e=>e.slashMenu!==!1}],ba=`3.0.1`,xa={...j},$=new WeakMap,Sa={create(e,t={}){let n=Ca(e).map(e=>{if($.has(e))return $.get(e);let n=new _n(e,t);return n._releaseInstance=()=>{$.get(e)===n&&$.delete(e)},n.initialize(),$.set(e,n),n});return n.length===1?n[0]:n},destroy(e){Ca(e).forEach(e=>{let t=$.get(e);t&&(t.destroy(),$.delete(e))})},getInstance(e){let t=typeof e==`string`?document.querySelector(e):e;return t&&$.get(t)||null},get defaults(){return{...j}},setDefaults(e){Object.assign(j,e)},resetDefaults(){Object.keys(j).forEach(e=>delete j[e]),Object.assign(j,xa)},registerModule(e,t){un.set(e,t)},use(e,t={}){if(!e||typeof e.name!=`string`)throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");return gn.has(e.name)?(console.warn(`[AutumnNote] Plugin "${e.name}" already registered globally. Skipping.`),this):(Array.isArray(e.buttons)&&e.buttons.forEach(e=>ze(e)),gn.set(e.name,{plugin:e,options:t}),this)},hasPlugin(e){return gn.has(e)},registerButton(e){return ze(e),this},registerIcon(e,t){return Ge(e,t),this},registerLocale(e,t){return c(e,t),this},registerSlashCommand(e){if(!e?.id||typeof e.run!=`function`)throw TypeError(`[AutumnNote] Slash command requires an id and run(context) function.`);let t=j.slashCommands,n=t.findIndex(t=>t.id===e.id);return n>=0?t[n]=e:t.push(e),this},buttons:Lt,version:ba};function Ca(e){return typeof e==`string`?Array.from(document.querySelectorAll(e)):e instanceof Element?[e]:e instanceof NodeList||Array.isArray(e)?Array.from(e):[]}return fn(ya),Sa});
77
+ `,r.addEventListener(`mouseover`,()=>{r.style.background=t+`22`}),r.addEventListener(`mouseout`,()=>{r.style.background=`none`}),this._disposers.push(v(r,`click`,e=>{e.stopPropagation(),n()})),r}_updateDOM(){let{x:e,y:t,w:n,h:r}=this._box;this._cropBox.style.left=`${e}px`,this._cropBox.style.top=`${t}px`,this._cropBox.style.width=`${n}px`,this._cropBox.style.height=`${r}px`;let i=globalThis.innerWidth,a=globalThis.innerHeight;if(this._scrim.style.clipPath=[`polygon(`,`0 0, ${i}px 0, ${i}px ${a}px, 0 ${a}px, 0 0,`,`${e}px ${t}px, ${e}px ${t+r}px, ${e+n}px ${t+r}px, ${e+n}px ${t}px, ${e}px ${t}px`,`)`].join(``),this._img){let i=this._img.naturalWidth||0,a=this._img.naturalHeight||0,o=this._imgRect.width||1,s=this._imgRect.height||1,c={x:i/o,y:a/s},l=Z(e-this._imgRect.left,0,o),u=Z(t-this._imgRect.top,0,s),d=Z(n,0,o-l),f=Z(r,0,s-u);this._infoEl.textContent=`${Math.round(d*c.x)} × ${Math.round(f*c.y)} px`}let o=t+r+8;o+40>globalThis.innerHeight-8&&(o=t-40-8),this._toolbar.style.left=`${e}px`,this._toolbar.style.top=`${o}px`}_startBoxMove(e){let t=e.clientX-this._box.x,n=e.clientY-this._box.y,r=this._imgRect;this._attachDocDrag(e=>{this._box.x=Z(e.clientX-t,r.left,r.right-this._box.w),this._box.y=Z(e.clientY-n,r.top,r.bottom-this._box.h),this._updateDOM()})}_startHandleDrag(e,t){let n=e.clientX,r=e.clientY,i={...this._box},a=this._imgRect,o=this._arCheck?.checked,s=i.w/(i.h||1);this._attachDocDrag(e=>{let c=e.clientX-n,l=e.clientY-r,{x:u,y:d,w:f,h:p}=i;t.includes(`e`)&&(f=Math.max(X,i.w+c)),t.includes(`s`)&&(p=Math.max(X,i.h+l)),t.includes(`w`)&&(u=Math.min(i.x+i.w-X,i.x+c),f=i.x+i.w-u),t.includes(`n`)&&(d=Math.min(i.y+i.h-X,i.y+l),p=i.y+i.h-d),o&&t.length===2&&(Math.abs(c)>=Math.abs(l)?(p=f/s,t.includes(`n`)&&(d=i.y+i.h-p)):(f=p*s,t.includes(`w`)&&(u=i.x+i.w-f))),u=Z(u,a.left,a.right-X),d=Z(d,a.top,a.bottom-X),f=Z(f,X,a.right-u),p=Z(p,X,a.bottom-d),this._box={x:u,y:d,w:f,h:p},this._updateDOM()})}_attachDocDrag(e){this._dragDisposers?.();let t=t=>{t.preventDefault();let n=t;e({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY})},n=()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,n),document.removeEventListener(`touchmove`,t),document.removeEventListener(`touchend`,n),document.body.style.userSelect=``,document.body.style.cursor=``,this._dragDisposers=null};this._dragDisposers=n,document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,n,{once:!0}),document.addEventListener(`touchmove`,t,{passive:!1}),document.addEventListener(`touchend`,n,{once:!0})}_bindEsc(){let e=e=>{e.key===`Escape`&&(e.preventDefault(),this._close(!1)),e.key===`Enter`&&(e.preventDefault(),this._confirm())};document.addEventListener(`keydown`,e),this._disposers.push(()=>document.removeEventListener(`keydown`,e))}async _confirm(){let e=this._img;if(!e){this._close(!1);return}let t=this._imgRect,{x:n,y:r,w:i,h:a}=this._box,o=(e.naturalWidth||e.width||1)/(t.width||1),s=(e.naturalHeight||e.height||1)/(t.height||1),c=Math.round(Z(n-t.left,0,t.width)*o),l=Math.round(Z(r-t.top,0,t.height)*s),u=Math.round(Z(i,0,t.width-(n-t.left))*o),d=Math.round(Z(a,0,t.height-(r-t.top))*s);if(u<=0||d<=0){this._close(!1);return}let f=await Vo(e,{x:c,y:l,width:u,height:d},i,a);if(!f){this._showCropError(`Cannot crop this image: the image server does not allow cross-origin access. Upload the image directly to use the crop tool.`),this._close(!1);return}let p=/^data:image\/(jpe?g)/i.exec(e.src)?`image/jpeg`:`image/png`,m=p===`image/jpeg`?.92:void 0,h=f.toDataURL(p,m);this._close(!1),e.src=h,e.style.width=``,e.style.height=``,e.removeAttribute(`width`),e.removeAttribute(`height`),this.context.invoke(`editor.afterCommand`),this.context.invoke(`imageResizer.updateOverlay`)}_showCropError(e){let t=document.createElement(`div`);t.setAttribute(`role`,`alert`),t.style.cssText=[`position:fixed`,`bottom:24px`,`left:50%`,`transform:translateX(-50%)`,`z-index:calc(10200 + var(--an-z-offset, 0))`,`max-width:420px`,`width:max-content`,`background:#7f1d1d`,`color:#fecaca`,`border:1px solid #b91c1c`,`border-radius:8px`,`padding:12px 18px`,`font:13px/1.5 system-ui,sans-serif`,`box-shadow:0 4px 16px rgba(0,0,0,.4)`,`pointer-events:auto`].join(`;`),t.textContent=e,b(this.context).appendChild(t),setTimeout(()=>{t.remove()},4e3)}_close(e){this._dragDisposers?.(),this._dragDisposers=null,this._disposers.forEach(e=>e()),this._disposers=[],[this._scrim,this._cropBox,this._toolbar].forEach(e=>{e?.remove()}),this._scrim=null,this._cropBox=null,this._toolbar=null,this._infoEl=null,this._handles={},this._img=null,this._box=null,this._imgRect=null,this._arCheck=null}},Uo=class{constructor(e){this.context=e,this.options=e.options,this._banner=null}initialize(){if(!this.options.autoSave||!this.options.autoSaveRestore)return this;let e=this.options.autoSaveKey,t=e+`:asrmeta`,n,r;try{n=localStorage.getItem(e),r=JSON.parse(localStorage.getItem(t)||`{}`)}catch{return this}if(!n)return this;let i=this.options.autoSaveRestoreTimeout;if(i>0&&Date.now()-(r.savedAt||0)>i*864e5){try{localStorage.removeItem(e),localStorage.removeItem(t)}catch{}return this}return this._showBanner(n,r),this}destroy(){this._removeBanner()}_showBanner(e,t){let n=this.context.locale.autoSaveRestore||{},r=n.found||`Draft found. Restore?`,i=n.restore||`Restore`,a=n.discard||`Discard`,o=document.createElement(`div`);o.className=`an-asr-banner`,o.setAttribute(`role`,`alert`);let s=document.createElement(`span`);if(s.className=`an-asr-msg`,t.savedAt){let e=new Date(t.savedAt).toLocaleString();s.textContent=(n.foundAt||`Draft from {date}. Restore?`).replace(`{date}`,e)}else s.textContent=r;let c=document.createElement(`button`);c.type=`button`,c.className=`an-btn an-asr-btn-restore`,c.textContent=i,c.addEventListener(`click`,()=>this._restore(e));let l=document.createElement(`button`);l.type=`button`,l.className=`an-btn an-asr-btn-discard`,l.textContent=a,l.addEventListener(`click`,()=>this._discard()),o.appendChild(s),o.appendChild(c),o.appendChild(l),this._banner=o;let u=this.context.layoutInfo.container;u.insertBefore(o,u.firstChild)}_restore(e){this.context.setHTML(e),this.context.clearHistory(),this._removeBanner(),this.context.triggerEvent(`autoSaveRestore`,e,this.context)}_discard(){let e=this.options.autoSaveKey;try{localStorage.removeItem(e),localStorage.removeItem(e+`:asrmeta`)}catch{}this._removeBanner()}_removeBanner(){this._banner?.remove(),this._banner=null}},Wo=class{constructor(e){this.context=e,this.options=e.options,this._disposers=[]}initialize(){if(!this.options.markdownShortcuts)return this;let e=this.context.layoutInfo.editable,t=v(e,`keydown`,e=>this._onKeydown(e)),n=v(e,`input`,()=>this._onInput());return this._disposers.push(t,n),this}destroy(){this._disposers.forEach(e=>e()),this._disposers=[]}_onKeydown(e){this._inCodeContext()||(e.key===` `?this._applyBlockRule()&&e.preventDefault():e.key===`Enter`&&this._applyEnterRule()&&e.preventDefault())}_inCodeContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;return!!(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(`pre, code`)}_getLineContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=this.context.layoutInfo.editable;if(!n.contains(t.startContainer))return null;let r=t.startContainer;for(;r&&r!==n&&!this._isBlock(r);)r=r.parentNode;(!r||r===n)&&(r=t.startContainer);let i=document.createRange();return i.setStart(r,0),i.setEnd(t.startContainer,t.startOffset),{text:i.toString(),range:t,lineNode:r}}_isBlock(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=globalThis.getComputedStyle(e).display;return t===`block`||t===`list-item`||t===`table-cell`}_applyBlockRule(){let e=this._getLineContext();if(!e)return!1;let{text:t}=e,n=[{re:/^(#{1,6})$/,handler:e=>this._convertToHeading(e[1].length)},{re:/^>$/,handler:()=>this._convertToBlockquote()},{re:/^[-*+]$/,handler:()=>this._convertToList(`ul`)},{re:/^1[.)]$/,handler:()=>this._convertToList(`ol`)},{re:/^\[([ xX])\]$/,handler:e=>this._convertToChecklist(e[1].toLowerCase()===`x`)}];for(let{re:e,handler:r}of n){let n=e.exec(t);if(n)return r(n),!0}return!1}_applyEnterRule(){let e=this._getLineContext();if(!e)return!1;let{text:t}=e;return/^(?:-{3,}|\*{3,}|_{3,})$/.test(t)?(this._convertToHr(),!0):/^(?:`{3}|~{3})/.test(t)?(this._convertToCodeBlock(),!0):!1}_selectLineAndDelete(){let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0),n=document.createRange();n.setStart(t.startContainer.parentNode||t.startContainer,0),n.setEnd(t.startContainer,t.startOffset),n.deleteContents()}_convertToHeading(e){this._selectLineAndDelete(),Nt(`h${e}`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToBlockquote(){this._selectLineAndDelete(),Nt(`blockquote`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToList(e){this._selectLineAndDelete(),e===`ul`?Wt():Gt(),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToChecklist(e=!1){if(this._selectLineAndDelete(),this.context.invoke(`editor.toggleChecklist`),e){let e=globalThis.getSelection(),t=e?.rangeCount?e.getRangeAt(0).startContainer:null,n=(t?.nodeType===Node.ELEMENT_NODE?t:t?.parentElement??null)?.closest(`li`)?.querySelector(`input[type="checkbox"]`)??null;n&&(n.checked=!0)}this.context.triggerEvent(`change`,this.context.getHTML())}_convertToHr(){this._selectLineAndDelete(),this.context.invoke(`editor.insertHr`),this.context.triggerEvent(`change`,this.context.getHTML())}_convertToCodeBlock(){this._selectLineAndDelete(),Nt(`pre`),this.context.triggerEvent(`change`,this.context.getHTML())}_onInput(){if(this._inCodeContext())return;let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0);if(!t.collapsed||!this.context.layoutInfo.editable.contains(t.startContainer))return;let n=t.startContainer;if(n.nodeType!==Node.TEXT_NODE)return;let r=n.textContent,i=t.startOffset,a=[{re:/\*\*(.+?)\*\*$/,tag:`strong`},{re:/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)$/,tag:`em`},{re:/~~(.+?)~~$/,tag:`s`},{re:/`([^`]+)`$/,tag:`code`}],o=r.slice(0,i);for(let{re:t,tag:s}of a){let a=t.exec(o);if(!a)continue;let c=o.length-a[0].length,l=i,u=a[1],d=r.slice(0,c),f=r.slice(l),p=document.createElement(s);p.textContent=u;let m=document.createTextNode(d),h=document.createTextNode(`​`+f);n.before(m,p,h),n.remove();let g=document.createRange();g.setStart(h,1),g.collapse(!0),e.removeAllRanges(),e.addRange(g),this.context.triggerEvent(`change`,this.context.getHTML());break}}},Go=`stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,Q=e=>`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" ${Go} style="display:block">${e}</svg>`,Ko={bold:Q(`<path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/><path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/>`),italic:Q(`<line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/>`),underline:Q(`<path d="M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"/><line x1="4" y1="21" x2="20" y2="21"/>`),strikethrough:Q(`<path d="M17.3 12H6.7"/><path d="M10 6.5C10 5.1 11.1 4 12.5 4c1.4 0 2.5 1.1 2.5 2.5 0 .8-.4 1.5-1 2"/><path d="M14 17.5C14 19 12.9 20 11.5 20 10.1 20 9 18.9 9 17.5c0-.8.4-1.5 1-2"/>`),link:Q(`<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>`),foreColor:Q(`<path d="M4 20L12 4L20 20"/><line x1="7.5" y1="14" x2="16.5" y2="14"/>`),hiliteColor:Q(`<path d="M3 21v-4l9-9 4 4-9 9z"/><path d="M12 8l4 4"/><line x1="3" y1="21" x2="21" y2="21"/>`),removeFormat:Q(`<path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/>`),inlineCode:Q(`<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/><path d="M16 3h1a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2a2 2 0 0 1-2 2v5a2 2 0 0 1-2 2h-1"/>`)},qo={bold:e=>e.invoke(`editor.bold`),italic:e=>e.invoke(`editor.italic`),underline:e=>e.invoke(`editor.underline`),strikethrough:e=>e.invoke(`editor.strikethrough`),link:e=>e.invoke(`linkDialog.show`),removeFormat:e=>{let t=e.layoutInfo?.editable;if(!t)return;t.focus(),qe(t);let n=globalThis.getSelection();if(n?.rangeCount>0&&!n.getRangeAt(0).collapsed){let e=n.getRangeAt(0),t=e.commonAncestorContainer,r=t.nodeType===1?t:t.parentElement;if(r){let t=[r,...r.querySelectorAll(`[style]`)];for(let n of t)n.hasAttribute(`style`)&&e.intersectsNode(n)&&n.removeAttribute(`style`)}}e.invoke(`editor.afterCommand`)},inlineCode:e=>e.invoke(`editor.inlineCode`)},Jo={bold:e=>ze(`bold`,e?.layoutInfo?.editable),italic:e=>ze(`italic`,e?.layoutInfo?.editable),underline:e=>ze(`underline`,e?.layoutInfo?.editable),strikethrough:e=>ze(`strikethrough`,e?.layoutInfo?.editable)},Yo={foreColor:!0,hiliteColor:!0},Xo=[{name:`editor`,Class:pa},{name:`toolbar`,Class:xa},{name:`statusbar`,Class:Ca},{name:`clipboard`,Class:wa},{name:`placeholder`,Class:Pa},{name:`contextMenu`,Class:ja},{name:`codeview`,Class:Fa},{name:`fullscreen`,Class:Ia},{name:`linkDialog`,Class:za},{name:`imageDialog`,Class:Va},{name:`videoDialog`,Class:Ua},{name:`imageResizer`,Class:Ka},{name:`videoResizer`,Class:qa},{name:`linkTooltip`,Class:Za},{name:`imageTooltip`,Class:$a},{name:`videoTooltip`,Class:to},{name:`tableTooltip`,Class:co},{name:`codeTooltip`,Class:_o},{name:`emojiDialog`,Class:To},{name:`iconDialog`,Class:Po},{name:`shortcutsDialog`,Class:Ro},{name:`findReplace`,Class:zo},{name:`imageCropOverlay`,Class:Ho},{name:`autoSaveRestore`,Class:Uo,enabled:e=>!!e.autoSaveRestore},{name:`markdownShortcuts`,Class:Wo,enabled:e=>e.markdownShortcuts!==!1},{name:`bubbleToolbar`,Class:class{constructor(e){this.context=e,this.options=e.options,this._el=null,this._picker=null,this._pickerType=null,this._savedRange=null,this._visible=!1,this._rafId=null,this._contextMenuOpen=!1,this._disposers=[],this._onSelectionChange=this._onSelectionChange.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onContextMenu=this._onContextMenu.bind(this)}initialize(){if(!this.options.bubbleToolbar)return this;this._build(),this._buildColorPicker();let e=v(document,`selectionchange`,this._onSelectionChange),t=v(document,`mousedown`,this._onMousedown),n=v(document,`keydown`,this._onKeydown),r=v(document,`contextmenu`,this._onContextMenu),i=this.context.on(`contextMenu:show`,()=>{this._contextMenuOpen=!0,this._hide()}),a=this.context.on(`contextMenu:hide`,()=>{this._contextMenuOpen=!1}),o=v(globalThis,`scroll`,()=>this._hide(),{passive:!0}),s=v(globalThis,`resize`,()=>this._hide(),{passive:!0});return this._disposers.push(e,t,n,r,i,a,o,s),this}destroy(){this._el?.remove(),this._el=null,this._picker?.remove(),this._picker=null,this._disposers.forEach(e=>e()),this._disposers=[],cancelAnimationFrame(this._rafId)}_build(){let e=document.createElement(`div`);e.className=`an-bubble-toolbar`,e.setAttribute(`role`,`toolbar`),e.setAttribute(`aria-label`,`Formatting`);let t=this.options.bubbleToolbarItems||[`bold`,`italic`,`underline`,`link`,`foreColor`,`hiliteColor`,`removeFormat`];for(let n of t){if(!Ko[n])continue;let t=ln(this.options,[n])??Ko[n],r=document.createElement(`button`);r.type=`button`,r.dataset.name=n;let i=this.context.locale?.toolbar?.[n];if(r.setAttribute(`aria-label`,typeof i==`string`?i:n),Yo[n]){r.className=`an-bubble-btn an-bubble-btn--color`;let e=document.createElement(`span`);e.className=`an-bubble-btn-svg`,e.innerHTML=t;let i=document.createElement(`span`);i.className=`an-bubble-color-strip`,i.style.background=n===`foreColor`?`#000000`:`transparent`,r.appendChild(e),r.appendChild(i)}else r.className=`an-bubble-btn`,r.innerHTML=t;r.addEventListener(`mousedown`,e=>{e.preventDefault()}),r.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),Yo[n]){this._openColorPicker(n,r);return}this.context.triggerEvent?.(`beforeCommand`,{name:n,source:`bubbleToolbar`})!==!1&&(this.context.invoke(`editor.focus`),qo[n]&&qo[n](this.context),this._syncActive())}),e.appendChild(r)}b(this.context).appendChild(e),this._el=e,this._btnCache=Array.from(e.querySelectorAll(`.an-bubble-btn`))}_buildColorPicker(){let e=document.createElement(`div`);e.className=`an-bubble-color-picker`,e.style.display=`none`,e.addEventListener(`mousedown`,e=>e.preventDefault());let t=document.createElement(`div`);t.className=`an-context-color-palette`,ha(this.options).forEach(e=>{let n=document.createElement(`div`);n.className=`an-context-color-swatch`,n.title=e,n.style.background=e,n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,e),n.addEventListener(`click`,t=>{t.stopPropagation(),this._applyColor(this._pickerType,e)}),t.appendChild(n)});let n=document.createElement(`div`);n.className=`an-context-color-swatch an-context-color-none`,n.title=`No highlight`,n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,`No highlight`),n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="4" y1="4" x2="20" y2="20"/><line x1="20" y1="4" x2="4" y2="20"/></svg>`,n.addEventListener(`click`,e=>{e.stopPropagation(),this._applyColor(`hiliteColor`,`transparent`)});let r=document.createElement(`div`);r.className=`an-context-color-custom`;let i=document.createElement(`input`);i.type=`color`,i.value=`#000000`,i.title=`Custom color`,i.addEventListener(`mousedown`,e=>e.stopPropagation()),i.addEventListener(`change`,()=>{this._applyColor(this._pickerType,i.value)});let a=document.createElement(`span`);a.textContent=`Custom…`,r.appendChild(i),r.appendChild(a),e.appendChild(t),e.appendChild(r),b(this.context).appendChild(e),this._picker=e;let o=e;o._paletteEl=t,o._noColorBtn=n,o._colorInput=i}_openColorPicker(e,t){let n=globalThis.getSelection();n?.rangeCount>0&&(this._savedRange=n.getRangeAt(0).cloneRange()),this._pickerType=e;let r=this._picker,i=r._paletteEl,a=r._noColorBtn;e===`hiliteColor`?i.contains(a)||i.appendChild(a):i.contains(a)&&a.remove(),this._picker._colorInput.value=e===`foreColor`?`#000000`:`#ffff00`,this._picker.style.display=`block`;let o=this._picker.offsetWidth,s=this._picker.offsetHeight,c=this._el.getBoundingClientRect(),l=c.top-s-6;l<8&&(l=c.bottom+6);let u=t.getBoundingClientRect().left;u=Math.max(8,Math.min(u,globalThis.innerWidth-o-8)),this._picker.style.left=`${u}px`,this._picker.style.top=`${l}px`}_closeColorPicker(){this._picker&&(this._picker.style.display=`none`),this._pickerType=null}_applyColor(e,t){let n=this.context.layoutInfo?.editable;if(!n||!this._savedRange)return;n.focus();let r=globalThis.getSelection();r.removeAllRanges();try{r.addRange(this._savedRange.cloneRange())}catch{return}P(e===`hiliteColor`?`background-color`:`color`,t,n),this.context.invoke(`editor.afterCommand`);let i=e===`hiliteColor`?`hiliteColor`:`foreColor`,a=(this._el?.querySelector(`[data-name="${i}"]`))?.querySelector(`.an-bubble-color-strip`);a&&(a.style.background=t===`transparent`?`transparent`:t),this._closeColorPicker(),this._syncActive()}_show(e){if(!this._el)return;let t=this._el;t.style.visibility=`hidden`,t.style.display=`flex`;let n=t.offsetWidth,r=t.offsetHeight,i=e.left+e.width/2-n/2,a=e.top-r-8;i=Math.max(8,Math.min(i,globalThis.innerWidth-n-8)),a<8&&(a=e.bottom+8);let o=document.querySelector(`.an-table-tooltip`);if(o&&o.style.display!==`none`){let t=o.getBoundingClientRect();a<t.bottom+8&&a+r>t.top-8&&(a=e.bottom+8,a+r>globalThis.innerHeight-8&&(a=t.bottom+8))}t.style.top=`${a}px`,t.style.left=`${i}px`,t.style.visibility=``,this._syncActive(),this._syncColorStrips(),this._visible=!0}_hide(){this._el&&(this._el.style.display=`none`,this._visible=!1,this._closeColorPicker())}_syncActive(){this._btnCache&&this._btnCache.forEach(e=>{let t=Jo[e.dataset.name];e.classList.toggle(`an-active`,!!t?.(this.context))})}_syncColorStrips(){if(!this._el)return;let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).startContainer;if(t.nodeType===Node.TEXT_NODE&&(t=t.parentElement),!t)return;let n=globalThis.getComputedStyle(t),r=this._el.querySelector(`[data-name="foreColor"]`)?.querySelector(`.an-bubble-color-strip`);r&&(r.style.background=n.color||`#000000`);let i=this._el.querySelector(`[data-name="hiliteColor"]`)?.querySelector(`.an-bubble-color-strip`);if(i){let e=n.backgroundColor;i.style.background=!e||e===`rgba(0, 0, 0, 0)`||e===`transparent`?`transparent`:e}}_onSelectionChange(){cancelAnimationFrame(this._rafId),this._rafId=requestAnimationFrame(()=>{if(this._contextMenuOpen||this._picker&&this._picker.style.display!==`none`)return;let e=globalThis.getSelection();if(!e||e.isCollapsed||!e.rangeCount){this._hide();return}if(!this.context.layoutInfo.editable.contains(e.anchorNode)){this._hide();return}if(this.context.options.readOnly){this._hide();return}let t=e.getRangeAt(0).getBoundingClientRect();if(!t||t.width===0){this._hide();return}this._show(t)})}_onMousedown(e){this._visible&&(this._el?.contains(e.target)||this._picker?.contains(e.target)||this.context.layoutInfo.editable.contains(e.target)||this._hide())}_onKeydown(e){e.key===`Escape`&&(this._picker&&this._picker.style.display!==`none`?this._closeColorPicker():this._visible&&this._hide())}_onContextMenu(){this._hide()}},enabled:e=>!!e.bubbleToolbar},{name:`mention`,Class:class{constructor(e){this.context=e,this._dropdown=null,this._query=``,this._debounceTimer=null,this._activeIndex=-1,this._items=[],this._open=!1,this._triggerNode=null,this._triggerOffset=0,this._caretRect=null,this._disposers=[]}initialize(){let e=this.context.options.mention;if(!e||typeof e.onSearch!=`function`)return this;this._cfg={trigger:e.trigger||`@`,minChars:e.minChars??0,maxResults:e.maxResults??8,debounce:e.debounce??200,onSearch:e.onSearch,onInsert:e.onInsert||null,onError:e.onError||null,mentionClass:e.mentionClass||`an-mention`,allowSpaces:e.allowSpaces||!1},this._buildDropdown();let t=this.context.layoutInfo.editable,n=v(t,`keydown`,e=>this._onKeydown(e)),r=v(t,`input`,()=>this._onInput()),i=v(document,`click`,e=>this._onDocClick(e));return this._disposers.push(n,r,i),this}destroy(){clearTimeout(this._debounceTimer),this._dropdown?.remove(),this._dropdown=null,this._disposers.forEach(e=>e()),this._disposers=[]}_buildDropdown(){let e=document.createElement(`div`);e.className=`an-mention-dropdown`,e.setAttribute(`role`,`listbox`),e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,e=>{let t=e.target?.closest(`.an-mention-item`);t&&this._select(+t.dataset.index)}),e.addEventListener(`mousemove`,e=>{let t=e.target?.closest(`.an-mention-item`);t&&this._highlightItem(+t.dataset.index)}),b(this.context).appendChild(e),this._dropdown=e}_renderItems(e){let t=this._dropdown;this._items=e.slice(0,this._cfg.maxResults),this._activeIndex=this._items.length>0?0:-1;let n=document.createDocumentFragment();this._items.forEach((e,t)=>{let r=document.createElement(`div`);if(r.className=`an-mention-item`,r.setAttribute(`role`,`option`),r.dataset.index=String(t),e.avatar){let t=document.createElement(`img`);t.src=e.avatar,t.className=`an-mention-avatar`,t.alt=``,r.appendChild(t)}let i=document.createElement(`span`);i.textContent=e.label,r.appendChild(i),n.appendChild(r)}),t.innerHTML=``,t.appendChild(n),this._highlightItem(this._activeIndex)}_highlightItem(e){this._dropdown&&(this._dropdown.querySelectorAll(`.an-mention-item`).forEach((t,n)=>{t.classList.toggle(`an-mention-active`,n===e)}),this._activeIndex=e)}_positionDropdown(){let e=this._dropdown,t=this._caretRect;if(!t||t.height===0)return;e.style.visibility=`hidden`,e.style.display=`block`;let n=e.offsetHeight,r=e.offsetWidth,i=t.bottom+4,a=t.left;t.bottom+n+8>globalThis.innerHeight&&(i=t.top-n-4),a=Math.max(8,Math.min(a,globalThis.innerWidth-r-8)),e.style.top=`${i}px`,e.style.left=`${a}px`,e.style.visibility=``}_showDropdown(){this._open=!0,this._positionDropdown()}_hideDropdown(){this._dropdown&&(this._dropdown.style.display=`none`),this._open=!1,this._items=[],this._activeIndex=-1,this._triggerNode=null,this._caretRect=null,this._query=``}_captureCaretRect(){if(this._triggerNode?.isConnected)try{let e=document.createRange(),t=Math.min(this._triggerOffset+1,this._triggerNode.textContent.length);e.setStart(this._triggerNode,this._triggerOffset),e.setEnd(this._triggerNode,t);let n=e.getBoundingClientRect();if(n.height>0){this._caretRect=n;return}}catch{}let e=globalThis.getSelection();if(!e?.rangeCount)return;let t=e.getRangeAt(0).getClientRects();t.length>0&&(this._caretRect=t[t.length-1])}_getQueryAtCursor(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=t.startContainer;if(n.nodeType!==Node.TEXT_NODE)return null;let r=n.textContent.slice(0,t.startOffset),i=this._cfg.trigger,a=r.lastIndexOf(i);if(a===-1)return null;let o=r.slice(a+i.length);return!this._cfg.allowSpaces&&/\s/.test(o)||o.length<this._cfg.minChars?null:(this._triggerNode=n,this._triggerOffset=a,o)}_onInput(){if(!this._cfg)return;let e=this._getQueryAtCursor();if(e===null){this._hideDropdown();return}this._captureCaretRect(),this._query=e,clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{let e=e=>{if(!Array.isArray(e)||e.length===0){this._hideDropdown();return}this._renderItems(e),this._showDropdown()},t;try{t=this._cfg.onSearch(this._query,e)}catch(e){this._hideDropdown(),typeof this._cfg.onError==`function`&&this._cfg.onError(e);return}t&&typeof t.then==`function`&&t.then(e).catch(e=>{this._hideDropdown(),typeof this._cfg.onError==`function`&&this._cfg.onError(e)})},this._cfg.debounce)}_onKeydown(e){if(!(!this._cfg||!this._open)){if(e.key===`ArrowDown`){e.preventDefault();let t=(this._activeIndex+1)%this._items.length;this._highlightItem(t)}else if(e.key===`ArrowUp`){e.preventDefault();let t=(this._activeIndex-1+this._items.length)%this._items.length;this._highlightItem(t)}else e.key===`Enter`||e.key===`Tab`?this._activeIndex>=0&&(e.preventDefault(),this._select(this._activeIndex)):e.key===`Escape`&&this._hideDropdown()}}_onDocClick(e){this._open&&(this._dropdown?.contains(e.target)||this._hideDropdown())}_select(e){let t=this._items[e];if(!t)return;if(this._triggerNode){let e=this._triggerNode;e.textContent=e.textContent.slice(0,this._triggerOffset)+e.textContent.slice(this._triggerOffset+this._cfg.trigger.length+this._query.length);let t=globalThis.getSelection(),n=document.createRange();n.setStart(e,this._triggerOffset),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}let n;typeof this._cfg.onInsert==`function`&&(n=this._cfg.onInsert(t)),n||=`<span class="${this._cfg.mentionClass}" data-mention-id="${t.id}" contenteditable="false">@${t.label}</span>`,this.context.invoke(`editor.insertHTML`,n+`&#8203;`),this._hideDropdown(),this.context.triggerEvent(`change`,this.context.getHTML())}},enabled:e=>!!e.mention},{name:`slashMenu`,Class:class{constructor(e){this.context=e,this.options=e.options,this._disposers=[],this._menu=null,this._filtered=[],this._activeIndex=-1,this._open=!1,this._query=``,this._textNode=null,this._triggerOffset=0,this._caretRect=null}initialize(){if(this.options.slashMenu===!1)return this;let e=this.context.layoutInfo.editable,t=v(e,`input`,()=>this._onInput()),n=v(e,`keydown`,e=>this._onKeydown(e)),r=v(document,`click`,e=>this._onDocClick(e));return this._disposers.push(t,n,r),this}destroy(){this._menu?.remove(),this._menu=null,this._disposers.forEach(e=>e()),this._disposers=[]}_commands(){let e=this.context.locale.slashMenu,t=this.context,n=[{id:`h1`,label:e.heading1,keywords:`h1 heading title`,run:()=>t.invoke(`editor.formatBlock`,`h1`)},{id:`h2`,label:e.heading2,keywords:`h2 heading subtitle`,run:()=>t.invoke(`editor.formatBlock`,`h2`)},{id:`h3`,label:e.heading3,keywords:`h3 heading`,run:()=>t.invoke(`editor.formatBlock`,`h3`)},{id:`ul`,label:e.bulletList,keywords:`ul bullet list unordered`,run:()=>t.invoke(`editor.insertUL`)},{id:`ol`,label:e.numberedList,keywords:`ol numbered list ordered`,run:()=>t.invoke(`editor.insertOL`)},{id:`checklist`,label:e.checklist,keywords:`checklist todo checkbox task`,run:()=>t.invoke(`editor.toggleChecklist`)},{id:`quote`,label:e.blockquote,keywords:`quote blockquote`,run:()=>t.invoke(`editor.formatBlock`,`blockquote`)},{id:`code`,label:e.codeBlock,keywords:`code pre block`,run:()=>t.invoke(`editor.formatBlock`,`pre`)},{id:`hr`,label:e.horizontalRule,keywords:`hr divider rule line`,run:()=>t.invoke(`editor.insertHr`)},{id:`table`,label:e.table,keywords:`table grid`,run:()=>t.invoke(`editor.insertTable`,3,3)},{id:`image`,label:e.image,keywords:`image picture photo upload`,run:()=>t.invoke(`imageDialog.show`)}],r=(this.options.slashCommands||[]).map(e=>({id:e.id,label:e.label||e.id,keywords:e.keywords||``,run:()=>e.run(t)}));return[...n,...r]}refresh(){this._open&&this._filterAndRender()}_buildMenu(){let e=document.createElement(`div`);return e.className=`an-slash-menu`,e.setAttribute(`role`,`listbox`),e.style.display=`none`,e.addEventListener(`mousedown`,e=>e.preventDefault()),e.addEventListener(`click`,e=>{let t=e.target?.closest(`.an-slash-menu-item`);t&&this._select(+t.dataset.index)}),e.addEventListener(`mousemove`,e=>{let t=e.target?.closest(`.an-slash-menu-item`);t&&this._highlight(+t.dataset.index)}),b(this.context).appendChild(e),this._menu=e,e}_renderItems(){this._menu||this._buildMenu();let e=this._menu,t=this.context.locale.slashMenu;if(this._filtered.length===0){e.innerHTML=``;let n=document.createElement(`div`);n.className=`an-slash-menu-empty`,n.textContent=t.noResults,e.appendChild(n),this._activeIndex=-1;return}let n=document.createDocumentFragment();this._filtered.forEach((e,t)=>{let r=document.createElement(`div`);r.className=`an-slash-menu-item`,r.setAttribute(`role`,`option`),r.id=`an-slash-option-${e.id}`,r.dataset.index=String(t),r.textContent=e.label,n.appendChild(r)}),e.innerHTML=``,e.appendChild(n),this._highlight(0)}_highlight(e){this._menu&&(this._menu.querySelectorAll(`.an-slash-menu-item`).forEach((t,n)=>{let r=n===e;t.classList.toggle(`an-slash-menu-active`,r),t.setAttribute(`aria-selected`,String(r)),r&&this._menu.setAttribute(`aria-activedescendant`,t.id)}),this._activeIndex=e)}_position(){let e=this._menu,t=this._caretRect;if(!e||!t||t.height===0)return;e.style.visibility=`hidden`,e.style.display=`block`;let n=e.offsetHeight,r=e.offsetWidth,i=t.bottom+4,a=t.left;t.bottom+n+8>globalThis.innerHeight&&(i=t.top-n-4),a=Math.max(8,Math.min(a,globalThis.innerWidth-r-8)),e.style.top=`${i}px`,e.style.left=`${a}px`,e.style.visibility=``}_open_(){this._open=!0,this._filterAndRender(),this._position()}_close(){this._menu&&(this._menu.style.display=`none`),this._open=!1,this._filtered=[],this._activeIndex=-1,this._menu?.removeAttribute(`aria-activedescendant`),this._textNode=null,this._caretRect=null,this._query=``}_isBlock(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=globalThis.getComputedStyle(e).display;return t===`block`||t===`list-item`||t===`table-cell`}_getTriggerContext(){let e=globalThis.getSelection();if(!e?.rangeCount)return null;let t=e.getRangeAt(0);if(!t.collapsed)return null;let n=this.context.layoutInfo.editable;if(!n.contains(t.startContainer)||t.startContainer.nodeType!==Node.TEXT_NODE)return null;let r=t.startContainer.parentNode;for(;r&&r!==n&&!this._isBlock(r);)r=r.parentNode;if(!r||r===n)return null;let i=r.textContent||``,a=document.createRange();a.setStart(r,0),a.setEnd(t.startContainer,t.startOffset);let o=a.toString(),s=/^\/(\S*)$/.exec(o);return!s||i.length>o.length?null:{query:s[1],textNode:t.startContainer,triggerOffset:t.startOffset-s[0].length}}_captureCaretRect(e,t){try{let n=document.createRange(),r=Math.min(t+1,e.textContent.length);n.setStart(e,t),n.setEnd(e,r);let i=n.getBoundingClientRect();if(i.height>0)return i}catch{}let n=globalThis.getSelection();if(!n?.rangeCount)return null;let r=n.getRangeAt(0).getClientRects();return r.length>0?r[r.length-1]:null}_filterAndRender(){let e=this._query.toLowerCase();this._filtered=e?this._commands().filter(t=>t.keywords.includes(e)||t.label.toLowerCase().includes(e)):this._commands(),this._renderItems()}_onInput(){let e=this._getTriggerContext();if(!e){this._open&&this._close();return}this._textNode=e.textNode,this._triggerOffset=e.triggerOffset,this._query=e.query,this._caretRect=this._captureCaretRect(e.textNode,e.triggerOffset),this._open?(this._filterAndRender(),this._position()):this._open_()}_onKeydown(e){if(this._open){if(e.key===`ArrowDown`){if(e.preventDefault(),this._filtered.length===0)return;this._highlight((this._activeIndex+1)%this._filtered.length)}else if(e.key===`ArrowUp`){if(e.preventDefault(),this._filtered.length===0)return;this._highlight((this._activeIndex-1+this._filtered.length)%this._filtered.length)}else e.key===`Enter`||e.key===`Tab`?this._activeIndex>=0&&(e.preventDefault(),this._select(this._activeIndex)):e.key===`Escape`&&(e.preventDefault(),this._close())}}_onDocClick(e){this._open&&(this._menu?.contains(e.target)||this._close())}_deleteTriggerText(){let e=this._textNode;if(!e?.isConnected)return;e.textContent=e.textContent.slice(0,this._triggerOffset)+e.textContent.slice(this._triggerOffset+1+this._query.length);let t=globalThis.getSelection();if(!t)return;let n=document.createRange();n.setStart(e,this._triggerOffset),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}_makeTriggerRemover(){let e=this._textNode,t=this._triggerOffset,n=this._query;return()=>{if(!e?.isConnected)return;let r=e.textContent.slice(0,t),i=e.textContent.slice(t+1+n.length);e.textContent=r+i;let a=globalThis.getSelection();if(!a)return;let o=document.createRange();o.setStart(e,t),o.collapse(!0),a.removeAllRanges(),a.addRange(o)}}_select(e){let t=this._filtered[e];if(t){if(t.id===`image`){let e=this._makeTriggerRemover();this._close(),this.context.invoke(`imageDialog.show`,{beforeInsert:e});return}this._deleteTriggerText(),this._close(),t.run()}}},enabled:e=>e.slashMenu!==!1}],Zo=`3.1.0`,Qo={...R},$=new WeakMap,$o={create(e,t={}){let n=es(e).map(e=>{if($.has(e))return $.get(e);let n=new Fr(e,t);return n._releaseInstance=()=>{$.get(e)===n&&$.delete(e)},n.initialize(),$.set(e,n),n});return n.length===1?n[0]:n},destroy(e){es(e).forEach(e=>{let t=$.get(e);t&&(t.destroy(),$.delete(e))})},getInstance(e){let t=typeof e==`string`?document.querySelector(e):e;return t&&$.get(t)||null},get defaults(){return{...R}},setDefaults(e){Object.assign(R,e)},resetDefaults(){Object.keys(R).forEach(e=>delete R[e]),Object.assign(R,Qo)},registerModule(e,t){Or.set(e,t)},use(e,t={}){if(!e||typeof e.name!=`string`)throw TypeError("[AutumnNote] AutumnNote.use: plugin must have a string `name` property.");return Pr.has(e.name)?(console.warn(`[AutumnNote] Plugin "${e.name}" already registered globally. Skipping.`),this):(Array.isArray(e.buttons)&&e.buttons.forEach(e=>en(e)),Pr.set(e.name,{plugin:e,options:t}),this)},hasPlugin(e){return Pr.has(e)},registerButton(e){return en(e),this},registerIcon(e,t){return sn(e,t),this},registerLocale(e,t){return c(e,t),this},registerSlashCommand(e){if(!e?.id||typeof e.run!=`function`)throw TypeError(`[AutumnNote] Slash command requires an id and run(context) function.`);let t=R.slashCommands,n=t.findIndex(t=>t.id===e.id);return n>=0?t[n]=e:t.push(e),this},buttons:er,version:Zo};function es(e){return typeof e==`string`?Array.from(document.querySelectorAll(e)):e instanceof Element?[e]:e instanceof NodeList||Array.isArray(e)?Array.from(e):[]}return Ar(Xo),$o});
76
78
  //# sourceMappingURL=autumnnote.umd.js.map