@baishuyun/ui-mobile 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/AMap/{AMap-B1GiEoPE.js → AMap-BkfhkrnK.js} +106 -106
  2. package/dist/AMap/index.js +4 -4
  3. package/dist/ActionSheet/{ActionSheet-DVck9uyS.js → ActionSheet-DJyeduZq.js} +7 -7
  4. package/dist/ActionSheet/index.js +6 -6
  5. package/dist/Calendar/{Calendar-B1TwDL1q.js → Calendar-Cf81JVOC.js} +353 -356
  6. package/dist/Calendar/index.js +5 -4
  7. package/dist/Calendar/{cssVars-DNOooryc.js → timeUtils-t4A3-Hr6.js} +1 -3
  8. package/dist/ConfigProvider/{ConfigProvider-xyGx046s.js → ConfigProvider-CNWefxiV.js} +14 -2
  9. package/dist/ConfigProvider/index.js +4 -4
  10. package/dist/ConfigProvider/{useLocale-Bf81I-9U.js → useLocale-DiKogqPs.js} +6 -0
  11. package/dist/Editor/Editor-CfA-ye-u.js +2774 -0
  12. package/dist/Editor/index.js +8 -8
  13. package/dist/Gantt/{Gantt-CbHw9RMw.js → Gantt-Bhvbj3l8.js} +220 -219
  14. package/dist/Gantt/index.js +8 -8
  15. package/dist/Icon/Icon-BKlmJSoE.js +23 -0
  16. package/dist/Icon/index.js +2 -2
  17. package/dist/Overlay/index.js +2 -2
  18. package/dist/Popup/{Popup-BIIDAUmB.js → Popup-Cg3t422z.js} +2 -2
  19. package/dist/Popup/index.js +4 -4
  20. package/dist/Segmented/Segmented-CxQ3Pd05.js +85 -0
  21. package/dist/Segmented/index.js +3 -0
  22. package/dist/components/Editor/{EditorHtml.d.ts → EditorHtmlPreview.d.ts} +1 -1
  23. package/dist/components/Editor/color/EditorColorPicker.d.ts +11 -0
  24. package/dist/components/Editor/color/colorUtils.d.ts +32 -0
  25. package/dist/components/Editor/constants/codeLanguages.d.ts +6 -0
  26. package/dist/components/Editor/hooks/useEditorAiSession.d.ts +20 -0
  27. package/dist/components/Editor/hooks/useEditorFocus.d.ts +1 -0
  28. package/dist/components/Editor/hooks/useEditorImageUpload.d.ts +17 -0
  29. package/dist/components/Editor/hooks/useEditorLink.d.ts +15 -0
  30. package/dist/components/Editor/hooks/useEditorValueBridge.d.ts +10 -0
  31. package/dist/components/Editor/htmlConfig.d.ts +2 -0
  32. package/dist/components/Editor/index.d.ts +1 -1
  33. package/dist/components/Editor/nodes/ExtendedLinkNode.d.ts +9 -0
  34. package/dist/components/Editor/plugins/CodeHighlightPlugin.d.ts +2 -0
  35. package/dist/components/Editor/plugins/EnterKeyPlugin.d.ts +1 -0
  36. package/dist/components/Editor/plugins/TablePlugin.d.ts +2 -0
  37. package/dist/components/Editor/popups/AiResultPopup.d.ts +13 -0
  38. package/dist/components/Editor/popups/ImageUrlPopup.d.ts +7 -0
  39. package/dist/components/Editor/popups/LinkPopup.d.ts +13 -0
  40. package/dist/components/Editor/popups/OptionSheets.d.ts +23 -0
  41. package/dist/components/Editor/popups/index.d.ts +4 -0
  42. package/dist/components/Editor/popups/shared.d.ts +11 -0
  43. package/dist/components/Editor/toolbar/Toolbar.d.ts +7 -1
  44. package/dist/components/Editor/toolbar/useTextFormats.d.ts +2 -15
  45. package/dist/components/Editor/utils/codeHighlighter.d.ts +12 -0
  46. package/dist/components/Editor/utils/placeProgrammaticCaret.d.ts +4 -0
  47. package/dist/components/Editor/utils/readTextFormats.d.ts +21 -0
  48. package/dist/components/Editor/utils/retainCodeSelection.d.ts +3 -0
  49. package/dist/components/Segmented/Segmented.d.ts +7 -0
  50. package/dist/components/Segmented/index.d.ts +2 -0
  51. package/dist/components/Segmented/interface.d.ts +42 -0
  52. package/dist/components/index.d.ts +3 -1
  53. package/dist/index.js +14 -13
  54. package/dist/locale/lang/en-US.json.d.ts +6 -0
  55. package/dist/locale/lang/zh-CN.json.d.ts +6 -0
  56. package/dist/locale/lang/zh-TW.json.d.ts +6 -0
  57. package/dist/style.css +1 -1
  58. package/dist/vendors/cssVars-BbL_cmFM.js +6 -0
  59. package/dist/vendors/{version-CegBK2kS.js → version-C0got4sp.js} +1 -1
  60. package/package.json +7 -1
  61. package/dist/Editor/Editor-COxP3RpF.js +0 -2059
  62. package/dist/Icon/Icon-D3xi1oyo.js +0 -23
  63. package/dist/components/Editor/sheets.d.ts +0 -43
  64. /package/dist/Overlay/{Overlay-CqQWOqO4.js → Overlay-DFiZYsBs.js} +0 -0
@@ -0,0 +1,2774 @@
1
+ import { t as e } from "../ConfigProvider/useLocale-DiKogqPs.js";
2
+ import { t } from "../Popup/Popup-Cg3t422z.js";
3
+ import { t as n } from "../Icon/Icon-BKlmJSoE.js";
4
+ import { t as r } from "../ActionSheet/ActionSheet-DJyeduZq.js";
5
+ import { createContext as i, useCallback as a, useContext as o, useEffect as s, useId as c, useLayoutEffect as l, useRef as u, useState as d } from "react";
6
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
7
+ import { useEventListener as h } from "ahooks";
8
+ import { LexicalComposer as g } from "@lexical/react/LexicalComposer";
9
+ import { $createLinkNode as _, $isLinkNode as v, $toggleLink as y, AutoLinkNode as b, LinkNode as x } from "@lexical/link";
10
+ import { $isListItemNode as S, $isListNode as C, INSERT_ORDERED_LIST_COMMAND as w, INSERT_UNORDERED_LIST_COMMAND as T, ListItemNode as E, ListNode as D, REMOVE_LIST_COMMAND as O } from "@lexical/list";
11
+ import { $createCodeHighlightNode as k, $isCodeHighlightNode as A, $isCodeNode as j, $plainifyCodeContent as ee, CodeHighlightNode as te, CodeNode as M, registerCodeIndentation as ne } from "@lexical/code-core";
12
+ import { $createHeadingNode as re, $isHeadingNode as ie, HeadingNode as ae } from "@lexical/rich-text";
13
+ import { $findCellNode as oe, $isTableCellNode as se, $isTableNode as N, $isTableRowNode as ce, TableCellNode as le, TableNode as ue, TableRowNode as de, registerTableCellUnmergeTransform as fe, registerTablePlugin as pe, registerTableSelectionObserver as me, setScrollableTablesActive as he } from "@lexical/table";
14
+ import { $applyNodeReplacement as ge, $createLineBreakNode as _e, $createParagraphNode as P, $createTabNode as ve, $createTextNode as ye, $getNodeByKey as be, $getRoot as F, $getSelection as I, $insertNodes as xe, $isElementNode as Se, $isLineBreakNode as Ce, $isRangeSelection as L, $isRootOrShadowRoot as we, $isTabNode as Te, $isTextNode as Ee, $nodesOfType as De, $onUpdate as Oe, $setSelection as R, BLUR_COMMAND as ke, COMMAND_PRIORITY_HIGH as Ae, COMMAND_PRIORITY_LOW as je, DROP_COMMAND as Me, DecoratorNode as Ne, FOCUS_COMMAND as Pe, FORMAT_ELEMENT_COMMAND as Fe, FORMAT_TEXT_COMMAND as Ie, HISTORY_MERGE_TAG as Le, INDENT_CONTENT_COMMAND as Re, KEY_ENTER_COMMAND as ze, KEY_TAB_COMMAND as Be, OUTDENT_CONTENT_COMMAND as Ve, PASTE_COMMAND as He, PASTE_TAG as Ue, TextNode as We, isHTMLElement as Ge, mergeRegister as Ke } from "lexical";
15
+ import { ContentEditable as qe } from "@lexical/react/LexicalContentEditable";
16
+ import { HistoryPlugin as Je } from "@lexical/react/LexicalHistoryPlugin";
17
+ import { LinkPlugin as Ye } from "@lexical/react/LexicalLinkPlugin";
18
+ import { ListPlugin as Xe } from "@lexical/react/LexicalListPlugin";
19
+ import { OnChangePlugin as Ze } from "@lexical/react/LexicalOnChangePlugin";
20
+ import { RichTextPlugin as Qe } from "@lexical/react/LexicalRichTextPlugin";
21
+ import { LexicalErrorBoundary as $e } from "@lexical/react/LexicalErrorBoundary";
22
+ import { useLexicalComposerContext as z } from "@lexical/react/LexicalComposerContext";
23
+ import { $generateHtmlFromNodes as et, $generateNodesFromDOM as tt } from "@lexical/html";
24
+ import nt from "dompurify";
25
+ import { $findMatchingParent as B, mergeRegister as rt } from "@lexical/utils";
26
+ import { $getSelectionStyleValueForProperty as it, $patchStyleText as at, $setBlocksType as ot } from "@lexical/selection";
27
+ //#region src/components/Editor/constants.ts
28
+ var st = [
29
+ {
30
+ label: "12",
31
+ value: "12px"
32
+ },
33
+ {
34
+ label: "14",
35
+ value: "14px"
36
+ },
37
+ {
38
+ label: "16",
39
+ value: "16px"
40
+ },
41
+ {
42
+ label: "18",
43
+ value: "18px"
44
+ },
45
+ {
46
+ label: "20",
47
+ value: "20px"
48
+ },
49
+ {
50
+ label: "22",
51
+ value: "22px"
52
+ },
53
+ {
54
+ label: "24",
55
+ value: "24px"
56
+ },
57
+ {
58
+ label: "28",
59
+ value: "28px"
60
+ },
61
+ {
62
+ label: "32",
63
+ value: "32px"
64
+ },
65
+ {
66
+ label: "36",
67
+ value: "36px"
68
+ },
69
+ {
70
+ label: "64",
71
+ value: "64px"
72
+ },
73
+ {
74
+ label: "128",
75
+ value: "128px"
76
+ }
77
+ ], ct = "#000", lt = "transparent", ut = /* @__PURE__ */ "#005eef.#3642e9.#7f43c8.#114bb8.#1379d9.#10a9c4.#119d85.#ffc502.#ff9921.#f06648.#f168b6.#d9e8ff.#dee0ff.#efe2ff.#d5e4ff.#daedff.#ddfaff.#d7fff8.#fff4d0.#ffecd7.#ffe3dd.#ffdef1.#262626.#3c3c3d.#454545.#515152.#5d5c5e.#6c6c6e.#878789.#b0afb1.#d0d0d1.#e6e6e7.#f5f5f6".split("."), dt = [
78
+ "quick",
79
+ "formal",
80
+ "colloquial",
81
+ "lively",
82
+ "literary",
83
+ "retro"
84
+ ], ft = {
85
+ quick: "editor.aiPresetQuick",
86
+ formal: "editor.aiPresetFormal",
87
+ colloquial: "editor.aiPresetColloquial",
88
+ lively: "editor.aiPresetLively",
89
+ literary: "editor.aiPresetLiterary",
90
+ retro: "editor.aiPresetRetro"
91
+ }, pt = [
92
+ {
93
+ key: "ai",
94
+ buttons: ["ai"]
95
+ },
96
+ {
97
+ key: "format",
98
+ buttons: [
99
+ "bold",
100
+ "italic",
101
+ "underline",
102
+ "strikethrough",
103
+ "align"
104
+ ]
105
+ },
106
+ {
107
+ key: "style",
108
+ buttons: [
109
+ "heading",
110
+ "fontSize",
111
+ "fontColor",
112
+ "fill"
113
+ ]
114
+ },
115
+ {
116
+ key: "indent",
117
+ buttons: ["outdent", "indent"]
118
+ },
119
+ {
120
+ key: "list",
121
+ buttons: ["number", "bullet"]
122
+ },
123
+ {
124
+ key: "insert",
125
+ buttons: ["picture", "link"]
126
+ }
127
+ ], mt = [
128
+ "jpg",
129
+ "jpeg",
130
+ "png",
131
+ "gif",
132
+ "bmp",
133
+ "tif"
134
+ ], ht = mt.map((e) => `.${e}`).join(","), gt = "calc(100dvh - 104px)", V = {
135
+ "bsy-mobile-editor": "_bsy-mobile-editor_mpjz5_2",
136
+ "bsy-mobile-editor__label": "_bsy-mobile-editor__label_mpjz5_15",
137
+ "bsy-mobile-editor__label-text": "_bsy-mobile-editor__label-text_mpjz5_20",
138
+ "bsy-mobile-editor__header": "_bsy-mobile-editor__header_mpjz5_29",
139
+ "bsy-mobile-editor__title": "_bsy-mobile-editor__title_mpjz5_39",
140
+ "bsy-mobile-editor__close": "_bsy-mobile-editor__close_mpjz5_49",
141
+ "bsy-mobile-editor__content": "_bsy-mobile-editor__content_mpjz5_63",
142
+ "bsy-mobile-editor__editable": "_bsy-mobile-editor__editable_mpjz5_73",
143
+ "bsy-mobile-editor__image-shell": "_bsy-mobile-editor__image-shell_mpjz5_225",
144
+ "bsy-mobile-editor__image": "_bsy-mobile-editor__image_mpjz5_225",
145
+ "bsy-mobile-editor__image-mask": "_bsy-mobile-editor__image-mask_mpjz5_247",
146
+ "bsy-mobile-editor__image-progress": "_bsy-mobile-editor__image-progress_mpjz5_256",
147
+ "bsy-mobile-editor__image-progress--spin": "_bsy-mobile-editor__image-progress--spin_mpjz5_259",
148
+ "bsy-mobile-editor-progress-spin": "_bsy-mobile-editor-progress-spin_mpjz5_1",
149
+ "bsy-mobile-editor__toolbar": "_bsy-mobile-editor__toolbar_mpjz5_262",
150
+ "bsy-mobile-editor__toolbar-scroller": "_bsy-mobile-editor__toolbar-scroller_mpjz5_277",
151
+ "bsy-mobile-editor__toolbar-track": "_bsy-mobile-editor__toolbar-track_mpjz5_294",
152
+ "bsy-mobile-editor__toolbar-thumb": "_bsy-mobile-editor__toolbar-thumb_mpjz5_306",
153
+ "bsy-mobile-editor__toolbar-group": "_bsy-mobile-editor__toolbar-group_mpjz5_311",
154
+ "bsy-mobile-editor__toolbar-divider": "_bsy-mobile-editor__toolbar-divider_mpjz5_317",
155
+ "bsy-mobile-editor__tool": "_bsy-mobile-editor__tool_mpjz5_262",
156
+ "bsy-mobile-editor__tool--active": "_bsy-mobile-editor__tool--active_mpjz5_338",
157
+ "bsy-mobile-editor__tool--select": "_bsy-mobile-editor__tool--select_mpjz5_345",
158
+ "bsy-mobile-editor__tool--select-align": "_bsy-mobile-editor__tool--select-align_mpjz5_350",
159
+ "bsy-mobile-editor__tool-caret": "_bsy-mobile-editor__tool-caret_mpjz5_353",
160
+ "bsy-mobile-editor__tool-caret--open": "_bsy-mobile-editor__tool-caret--open_mpjz5_356",
161
+ "bsy-mobile-editor__ai-icon": "_bsy-mobile-editor__ai-icon_mpjz5_359",
162
+ "bsy-mobile-editor__tool-text": "_bsy-mobile-editor__tool-text_mpjz5_364",
163
+ "bsy-mobile-editor__color": "_bsy-mobile-editor__color_mpjz5_369",
164
+ "bsy-mobile-editor__color--custom": "_bsy-mobile-editor__color--custom_mpjz5_377",
165
+ "bsy-mobile-editor__color-header": "_bsy-mobile-editor__color-header_mpjz5_380",
166
+ "bsy-mobile-editor__color-header-title": "_bsy-mobile-editor__color-header-title_mpjz5_389",
167
+ "bsy-mobile-editor__color-header-back": "_bsy-mobile-editor__color-header-back_mpjz5_402",
168
+ "bsy-mobile-editor__color-grid": "_bsy-mobile-editor__color-grid_mpjz5_416",
169
+ "bsy-mobile-editor__color-swatch": "_bsy-mobile-editor__color-swatch_mpjz5_423",
170
+ "bsy-mobile-editor__color-none": "_bsy-mobile-editor__color-none_mpjz5_423",
171
+ "bsy-mobile-editor__color-custom-item": "_bsy-mobile-editor__color-custom-item_mpjz5_423",
172
+ "bsy-mobile-editor__color-swatch--selected": "_bsy-mobile-editor__color-swatch--selected_mpjz5_439",
173
+ "bsy-mobile-editor__color-none--selected": "_bsy-mobile-editor__color-none--selected_mpjz5_439",
174
+ "bsy-mobile-editor__color-custom-item--selected": "_bsy-mobile-editor__color-custom-item--selected_mpjz5_439",
175
+ "bsy-mobile-editor__color-swatch-fill": "_bsy-mobile-editor__color-swatch-fill_mpjz5_453",
176
+ "bsy-mobile-editor__color-bar": "_bsy-mobile-editor__color-bar_mpjz5_460",
177
+ "bsy-mobile-editor__color-custom-trigger": "_bsy-mobile-editor__color-custom-trigger_mpjz5_466",
178
+ "bsy-mobile-editor__color-custom-trigger--active": "_bsy-mobile-editor__color-custom-trigger--active_mpjz5_484",
179
+ "bsy-mobile-editor__color-custom-trigger--preview": "_bsy-mobile-editor__color-custom-trigger--preview_mpjz5_489",
180
+ "bsy-mobile-editor__color-custom-list": "_bsy-mobile-editor__color-custom-list_mpjz5_504",
181
+ "bsy-mobile-editor__color-mixer": "_bsy-mobile-editor__color-mixer_mpjz5_524",
182
+ "bsy-mobile-editor__color-spectrum": "_bsy-mobile-editor__color-spectrum_mpjz5_527",
183
+ "bsy-mobile-editor__color-spectrum-canvas": "_bsy-mobile-editor__color-spectrum-canvas_mpjz5_535",
184
+ "bsy-mobile-editor__color-thumb": "_bsy-mobile-editor__color-thumb_mpjz5_542",
185
+ "bsy-mobile-editor__sheet": "_bsy-mobile-editor__sheet_mpjz5_552",
186
+ "bsy-mobile-editor__sheet-body": "_bsy-mobile-editor__sheet-body_mpjz5_558",
187
+ "bsy-mobile-editor__sheet-body--stack": "_bsy-mobile-editor__sheet-body--stack_mpjz5_563",
188
+ "bsy-mobile-editor__sheet-field": "_bsy-mobile-editor__sheet-field_mpjz5_568",
189
+ "bsy-mobile-editor__sheet-label": "_bsy-mobile-editor__sheet-label_mpjz5_573",
190
+ "bsy-mobile-editor__sheet-note": "_bsy-mobile-editor__sheet-note_mpjz5_579",
191
+ "bsy-mobile-editor__sheet-note--hint": "_bsy-mobile-editor__sheet-note--hint_mpjz5_585",
192
+ "bsy-mobile-editor__sheet-error": "_bsy-mobile-editor__sheet-error_mpjz5_588",
193
+ "bsy-mobile-editor__sheet-bar": "_bsy-mobile-editor__sheet-bar_mpjz5_608",
194
+ "bsy-mobile-editor__sheet-ok": "_bsy-mobile-editor__sheet-ok_mpjz5_629",
195
+ "bsy-mobile-editor__check": "_bsy-mobile-editor__check_mpjz5_634",
196
+ "bsy-mobile-editor__check-input": "_bsy-mobile-editor__check-input_mpjz5_646",
197
+ "bsy-mobile-editor__check-box": "_bsy-mobile-editor__check-box_mpjz5_653",
198
+ "bsy-mobile-editor__ai": "_bsy-mobile-editor__ai_mpjz5_359",
199
+ "bsy-mobile-editor__ai-body": "_bsy-mobile-editor__ai-body_mpjz5_675",
200
+ "bsy-mobile-editor__ai-section": "_bsy-mobile-editor__ai-section_mpjz5_683",
201
+ "bsy-mobile-editor__ai-section-head": "_bsy-mobile-editor__ai-section-head_mpjz5_691",
202
+ "bsy-mobile-editor__ai-section-scroll": "_bsy-mobile-editor__ai-section-scroll_mpjz5_699",
203
+ "bsy-mobile-editor__ai-label": "_bsy-mobile-editor__ai-label_mpjz5_706",
204
+ "bsy-mobile-editor__ai-label--after": "_bsy-mobile-editor__ai-label--after_mpjz5_718",
205
+ "bsy-mobile-editor__ai-label--before": "_bsy-mobile-editor__ai-label--before_mpjz5_722",
206
+ "bsy-mobile-editor__ai-dot": "_bsy-mobile-editor__ai-dot_mpjz5_726",
207
+ "bsy-mobile-editor__ai-split": "_bsy-mobile-editor__ai-split_mpjz5_733",
208
+ "bsy-mobile-editor__ai-preset": "_bsy-mobile-editor__ai-preset_mpjz5_739",
209
+ "bsy-mobile-editor__ai-think-pin": "_bsy-mobile-editor__ai-think-pin_mpjz5_759",
210
+ "bsy-mobile-editor__ai-think-head": "_bsy-mobile-editor__ai-think-head_mpjz5_763",
211
+ "bsy-mobile-editor__ai-think-label": "_bsy-mobile-editor__ai-think-label_mpjz5_780",
212
+ "bsy-mobile-editor__ai-think-label--shimmer": "_bsy-mobile-editor__ai-think-label--shimmer_mpjz5_784",
213
+ "bsy-mobile-ai-think-shimmer": "_bsy-mobile-ai-think-shimmer_mpjz5_1",
214
+ "bsy-mobile-editor__ai-think-arrow": "_bsy-mobile-editor__ai-think-arrow_mpjz5_795",
215
+ "bsy-mobile-editor__ai-think-arrow--open": "_bsy-mobile-editor__ai-think-arrow--open_mpjz5_802",
216
+ "bsy-mobile-editor__ai-think-icon": "_bsy-mobile-editor__ai-think-icon_mpjz5_805",
217
+ "bsy-mobile-ai-think": "_bsy-mobile-ai-think_mpjz5_1",
218
+ "bsy-mobile-editor__ai-think-body": "_bsy-mobile-editor__ai-think-body_mpjz5_817",
219
+ "bsy-mobile-editor__ai-error": "_bsy-mobile-editor__ai-error_mpjz5_826",
220
+ "bsy-mobile-editor__ai-footer": "_bsy-mobile-editor__ai-footer_mpjz5_831",
221
+ "bsy-mobile-editor__ai-footer-ok": "_bsy-mobile-editor__ai-footer-ok_mpjz5_853"
222
+ }, _t = [
223
+ "color",
224
+ "background-color",
225
+ "font-size",
226
+ "font-family",
227
+ "font-weight",
228
+ "text-decoration"
229
+ ], vt = (e) => {
230
+ let t = e.body.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, td, th");
231
+ for (let n of Array.from(t)) {
232
+ let t = n, r = [];
233
+ for (let e of _t) {
234
+ let n = t.style.getPropertyValue(e);
235
+ n && (r.push(`${e}: ${n}`), t.style.removeProperty(e));
236
+ }
237
+ if (!r.length) continue;
238
+ let i = r.join("; ");
239
+ for (let n of Array.from(t.childNodes)) {
240
+ if (n.nodeType === Node.TEXT_NODE && n.textContent) {
241
+ let r = e.createElement("span");
242
+ r.setAttribute("style", i), t.insertBefore(r, n), r.appendChild(n);
243
+ continue;
244
+ }
245
+ if (n.nodeType === Node.ELEMENT_NODE) {
246
+ let e = n, t = e.getAttribute("style");
247
+ e.setAttribute("style", t ? `${t}; ${i}` : i);
248
+ }
249
+ }
250
+ }
251
+ }, yt = (e, t) => {
252
+ let n = F();
253
+ if (n.clear(), t.trim()) {
254
+ let r = new DOMParser().parseFromString(t, "text/html");
255
+ vt(r);
256
+ let i = tt(e, r);
257
+ if (i.length) {
258
+ n.select(), xe(i), R(null);
259
+ return;
260
+ }
261
+ }
262
+ let r = P();
263
+ n.append(r), R(null);
264
+ }, bt = (e) => {
265
+ if (e) {
266
+ F().selectStart();
267
+ return;
268
+ }
269
+ R(null);
270
+ }, xt = () => {
271
+ I() === null && F().selectStart();
272
+ }, H = (e) => {
273
+ e.isEditable() || e.setEditable(!0), e.update(() => {
274
+ xt();
275
+ }), e.focus(void 0, { defaultSelection: "rootStart" });
276
+ }, St = (e, t) => !t.trim() && (e === "<p><br></p>" || e === "<p></p>" || e === "" || /^<p>\s*<br>\s*<\/p>$/.test(e)), Ct = /* @__PURE__ */ "p.br.strong.em.b.i.u.s.span.sub.sup.ul.ol.li.a.img.pre.code.table.thead.tbody.tr.td.th.h1.h2.h3.h4.h5.h6".split("."), wt = [
277
+ "href",
278
+ "src",
279
+ "alt",
280
+ "title",
281
+ "target",
282
+ "rel",
283
+ "colspan",
284
+ "rowspan",
285
+ "data-language",
286
+ "data-id",
287
+ "class",
288
+ "style",
289
+ "width",
290
+ "height"
291
+ ], Tt = new Set(/* @__PURE__ */ "color.background-color.font-size.font-family.font-weight.font-style.text-decoration.text-align.max-width.display.vertical-align.width.height.border.margin.padding.padding-inline-start.line-height.list-style-type.list-style-position.list-style.border-collapse.table-layout.overflow-x.white-space.position.top.bottom.tab-size.border-radius.box-sizing.min-width.min-height.cursor".split(".")), Et = /^(?:(?:(?:f|ht)tps?|mailto|blob):|data:image\/[a-z0-9.+-]+[;,].*|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i, Dt = new Set([
292
+ "pre",
293
+ "code",
294
+ "td",
295
+ "th"
296
+ ]), Ot = new Set(["pre", "code"]), kt = new Set(["sup", "sub"]), At = (e, t) => Tt.has(e) ? e === "padding-inline-start" ? !0 : e === "padding" || e.startsWith("padding-") ? Dt.has(t) : e === "border-radius" ? Ot.has(t) : e === "position" || e === "top" || e === "bottom" ? kt.has(t) : !0 : !1, jt = (e, t) => e.split(";").map((e) => e.trim()).filter(Boolean).map((e) => {
297
+ let n = e.indexOf(":");
298
+ if (n === -1) return null;
299
+ let r = e.slice(0, n).trim().toLowerCase(), i = e.slice(n + 1).trim();
300
+ if (r === "background") {
301
+ if (/url\s*\(/i.test(i)) return null;
302
+ r = "background-color";
303
+ }
304
+ return !At(r, t) || /expression|javascript:|url\s*\(\s*['"]?\s*javascript/i.test(i) ? null : `${r}: ${i}`;
305
+ }).filter((e) => e !== null).join("; "), Mt = !1, Nt = () => {
306
+ Mt ||= (nt.addHook("uponSanitizeAttribute", (e, t) => {
307
+ if (t.attrName === "href" && /^data:/i.test(t.attrValue)) {
308
+ t.keepAttr = !1;
309
+ return;
310
+ }
311
+ t.attrName === "style" && (t.attrValue = jt(t.attrValue, e.nodeName.toLowerCase()), t.attrValue || (t.keepAttr = !1));
312
+ }), !0);
313
+ }, U = (e) => e ? (Nt(), nt.sanitize(e, {
314
+ ALLOWED_TAGS: Ct,
315
+ ALLOWED_ATTR: wt,
316
+ ALLOW_DATA_ATTR: !1,
317
+ ADD_ATTR: ["data-language", "data-id"],
318
+ ALLOWED_URI_REGEXP: Et
319
+ })) : "", W = {
320
+ margin: "0.6em 0 0.4em",
321
+ "font-weight": "600",
322
+ "line-height": "1.35"
323
+ }, Pt = {
324
+ h1: {
325
+ ...W,
326
+ "font-size": "2em"
327
+ },
328
+ h2: {
329
+ ...W,
330
+ "font-size": "1.5em"
331
+ },
332
+ h3: {
333
+ ...W,
334
+ "font-size": "1.25em"
335
+ },
336
+ h4: {
337
+ ...W,
338
+ "font-size": "1.125em"
339
+ },
340
+ h5: {
341
+ ...W,
342
+ "font-size": "1em"
343
+ },
344
+ h6: {
345
+ ...W,
346
+ "font-size": "0.875em"
347
+ }
348
+ }, Ft = {
349
+ color: "#0269ff",
350
+ cursor: "pointer"
351
+ }, It = {
352
+ margin: "0",
353
+ "padding-inline-start": "24px",
354
+ "list-style-position": "outside"
355
+ }, Lt = [
356
+ "disc",
357
+ "circle",
358
+ "square"
359
+ ], Rt = {
360
+ margin: "0",
361
+ "list-style": "inherit"
362
+ }, zt = {
363
+ margin: "0",
364
+ "list-style-type": "none"
365
+ }, Bt = {
366
+ display: "block",
367
+ "box-sizing": "border-box",
368
+ "max-width": "100%",
369
+ margin: "8px 0",
370
+ padding: "8px 12px",
371
+ "overflow-x": "auto",
372
+ "font-family": "Menlo, Consolas, Monaco, monospace",
373
+ "font-size": "13px",
374
+ "line-height": "1.53",
375
+ "white-space": "pre",
376
+ "tab-size": "2",
377
+ "border-radius": "4px",
378
+ "background-color": "rgb(240, 242, 245)",
379
+ color: "#1f2328"
380
+ }, Vt = {
381
+ "border-collapse": "collapse",
382
+ "table-layout": "fixed",
383
+ width: "100%",
384
+ "overflow-x": "auto",
385
+ margin: "8px 0"
386
+ }, Ht = {
387
+ "box-sizing": "border-box",
388
+ "min-width": "75px",
389
+ "min-height": "32px",
390
+ padding: "4px 8px",
391
+ border: "1px solid #d9d9d9",
392
+ "vertical-align": "top"
393
+ }, Ut = {
394
+ "font-weight": "600",
395
+ "background-color": "#f2f3f5"
396
+ }, Wt = {
397
+ display: "inline-block",
398
+ position: "static",
399
+ top: "auto",
400
+ bottom: "auto",
401
+ "font-size": "0.75em",
402
+ "line-height": "1"
403
+ }, G = (e, t) => {
404
+ for (let [n, r] of Object.entries(t)) e.style.getPropertyValue(n) || e.style.setProperty(n, r);
405
+ }, Gt = (e) => {
406
+ let t = 0, n = e;
407
+ for (; n;) n.tagName === "UL" && (t += 1), n = n.parentElement;
408
+ return t;
409
+ }, Kt = (e) => {
410
+ for (let t of Array.from(e.querySelectorAll("*"))) {
411
+ if (!(t instanceof HTMLElement)) continue;
412
+ let e = t.tagName.toLowerCase(), n = Pt[e];
413
+ if (n && G(t, n), e === "a" && G(t, Ft), e === "ul") {
414
+ let e = Math.min(Math.max(Gt(t), 1), Lt.length);
415
+ G(t, {
416
+ ...It,
417
+ "list-style-type": Lt[e - 1]
418
+ });
419
+ }
420
+ e === "ol" && G(t, {
421
+ ...It,
422
+ "list-style-type": "decimal"
423
+ }), e === "li" && G(t, t.classList.contains("editor-nested-listitem") ? zt : Rt), e === "pre" && G(t, Bt), (e === "sup" || e === "sub") && G(t, {
424
+ ...Wt,
425
+ "vertical-align": e === "sup" ? "super" : "sub"
426
+ }), e === "table" && G(t, Vt), (e === "td" || e === "th") && (G(t, Ht), (e === "th" || t.classList.contains("editor-table-cell-header")) && G(t, Ut)), t.classList.contains("editor-text-underline-strikethrough") ? G(t, { "text-decoration": "underline line-through" }) : t.classList.contains("editor-text-underline") ? G(t, { "text-decoration": "underline" }) : t.classList.contains("editor-text-strikethrough") && G(t, { "text-decoration": "line-through" });
427
+ for (let e of Array.from(t.classList)) e.startsWith("editor-") && t.classList.remove(e);
428
+ t.classList.length === 0 && t.removeAttribute("class");
429
+ }
430
+ }, qt = (e) => {
431
+ let t = e.parentNode;
432
+ if (t) {
433
+ for (; e.firstChild;) t.insertBefore(e.firstChild, e);
434
+ t.removeChild(e);
435
+ }
436
+ }, Jt = (e) => {
437
+ let t = !0;
438
+ for (; t;) {
439
+ t = !1;
440
+ for (let n of Array.from(e.querySelectorAll("span, b, i"))) {
441
+ if (n.attributes.length > 0) continue;
442
+ let e = n.tagName.toLowerCase();
443
+ if (e === "span") {
444
+ qt(n), t = !0;
445
+ continue;
446
+ }
447
+ if (n.childElementCount !== 1 || n.childNodes.length !== 1) continue;
448
+ let r = n.firstElementChild;
449
+ (e === "b" && r?.tagName === "STRONG" || e === "i" && r?.tagName === "EM") && (qt(n), t = !0);
450
+ }
451
+ }
452
+ }, Yt = (e) => {
453
+ if (!e.trim()) return e;
454
+ let t = new DOMParser().parseFromString(e, "text/html");
455
+ Kt(t.body), Jt(t.body);
456
+ for (let e of Array.from(t.body.querySelectorAll("pre"))) e.textContent?.trim() || e.remove();
457
+ return t.body.innerHTML;
458
+ }, Xt = "<!--bsy-block-->", Zt = "bsy-html-root", Qt = (e) => new DOMParser().parseFromString(`<${Zt}>${e}</${Zt}>`, "text/html").body.querySelector(Zt), $t = (e) => e ? new DOMParser().parseFromString(e, "text/html").body.textContent ?? "" : "", en = (e) => e.includes("<!--bsy-block-->") ? e.split(Xt).map((e) => e.trim()) : [e], tn = (e) => e.split(Xt).join("").trim().length > 0, nn = (e, t) => {
459
+ let n = e.map(() => "");
460
+ if (e.length === 0) return n;
461
+ let r = [], i = [];
462
+ if (e.forEach((e, t) => {
463
+ for (let n of Array.from(e)) i.push(n), r.push(t);
464
+ }), i.length === 0) return n[0] = t, n;
465
+ let a = i, o = Array.from(t), s = a.length, c = o.length, l = Array.from({ length: s + 1 }, () => Array(c + 1).fill(0));
466
+ for (let e = s - 1; e >= 0; e--) for (let t = c - 1; t >= 0; t--) l[e][t] = a[e] === o[t] ? l[e + 1][t + 1] + 1 : Math.max(l[e + 1][t], l[e][t + 1]);
467
+ let u = 0, d = 0, f = r[0];
468
+ for (; u < s && d < c;) a[u] === o[d] ? (f = r[u], n[f] += o[d], u += 1, d += 1) : l[u + 1][d] >= l[u][d + 1] ? (f = r[u], u += 1) : (n[f] += o[d], d += 1);
469
+ for (; d < c;) n[n.length - 1] += o[d], d += 1;
470
+ return n;
471
+ }, rn = new Set([
472
+ "TABLE",
473
+ "THEAD",
474
+ "TBODY",
475
+ "TR",
476
+ "TD",
477
+ "TH",
478
+ "IMG",
479
+ "BR"
480
+ ]), an = (e) => {
481
+ let t = [], n = (e) => {
482
+ if (e.nodeType === Node.ELEMENT_NODE) {
483
+ if (e.tagName === "PRE") return;
484
+ for (let t of Array.from(e.childNodes)) n(t);
485
+ return;
486
+ }
487
+ e.nodeType === Node.TEXT_NODE && t.push(e);
488
+ };
489
+ return n(e), t;
490
+ }, on = (e, t) => {
491
+ let n = e;
492
+ for (; n && n !== t && !rn.has(n.tagName) && !(n.textContent ?? "").trim() && !n.querySelector("img, table, br");) {
493
+ let e = n.parentElement;
494
+ n.remove(), n = e;
495
+ }
496
+ }, sn = (e) => {
497
+ let t = e.tagName;
498
+ return t === "IMG" || t === "TABLE" || t === "PRE";
499
+ }, cn = (e) => {
500
+ let t = Qt(e);
501
+ return t ? Array.from(t.children).filter((e) => !sn(e)).map((e) => e.textContent ?? "") : [];
502
+ }, ln = (e) => e.includes("<!--bsy-block-->") ? e : $t(e) || e, un = (e, t) => {
503
+ let n = an(e);
504
+ if (n.length === 0) {
505
+ t && (e.querySelector("br")?.remove(), e.append(e.ownerDocument.createTextNode(t)));
506
+ return;
507
+ }
508
+ let r = nn(n.map((e) => e.textContent ?? ""), t);
509
+ for (let t = 0; t < n.length; t++) {
510
+ let i = r[t], a = n[t];
511
+ if (i) {
512
+ a.textContent = i;
513
+ continue;
514
+ }
515
+ let o = a.parentElement;
516
+ a.remove(), on(o, e);
517
+ }
518
+ }, dn = (e, t) => {
519
+ let n = ln(t);
520
+ if (!tn(n) || !e.trim()) return "";
521
+ let r = Qt(e);
522
+ if (!r) return "";
523
+ let i = Array.from(r.children).filter((e) => !sn(e));
524
+ if (i.length === 0) return "";
525
+ let a = en(n), o = a.length === i.length ? a : nn(i.map((e) => e.textContent ?? ""), a.join(""));
526
+ for (let e = 0; e < i.length; e++) un(i[e], o[e] ?? "");
527
+ return r.innerHTML;
528
+ }, fn = (e, t) => {
529
+ let n = "";
530
+ e.getEditorState().read(() => {
531
+ n = Yt(U(et(e, null)));
532
+ }, { editor: e });
533
+ let r = U(dn(n, t));
534
+ return !r.trim() || St(r, $t(r)) ? !1 : (e.update(() => {
535
+ yt(e, r), bt(!0);
536
+ }, { discrete: !0 }), !0);
537
+ }, pn = (e) => {
538
+ let t = "", n = "", r = "";
539
+ return e.getEditorState().read(() => {
540
+ n = F().getTextContent(), t = Yt(U(et(e, null))), r = cn(t).join(`\n\n${Xt}\n\n`);
541
+ }, { editor: e }), {
542
+ html: t,
543
+ text: n,
544
+ polishText: r
545
+ };
546
+ }, mn = /^\uFEFF/, hn = /^ {0,3}`{1,3}[A-Za-z]*$/, gn = /^( {0,3})([^`<]*?)```[ \t]*([A-Za-z0-9_-]*)[ \t]*(.*)$/, _n = /^ {0,3}```[ \t]*$/, vn = /<\/?[a-zA-Z]/, yn = /<[a-zA-Z!]/, bn = (e) => yn.test(e), xn = (e) => vn.test(e), Sn = (e) => e.replace(mn, "").replace(/\r\n/g, "\n"), Cn = (e) => {
547
+ let t = e.replace(/\n+$/, ""), n = t.lastIndexOf("\n"), r = n === -1 ? t : t.slice(n + 1);
548
+ return hn.test(r) ? {
549
+ text: n === -1 ? "" : t.slice(0, n),
550
+ withheld: !0
551
+ } : {
552
+ text: e,
553
+ withheld: !1
554
+ };
555
+ }, wn = (e) => {
556
+ let t = gn.exec(e);
557
+ return t ? { sameLineBody: t[4] ?? "" } : null;
558
+ }, Tn = (e) => {
559
+ let t = e.replace(/[ \t]*```[ \t]*$/, "");
560
+ return t === e ? e : t;
561
+ }, En = (e) => bn(e) ? e.replace(/^\n/, "") : "", Dn = (e) => {
562
+ let t = e.split("\n"), n = [], r = 0;
563
+ for (; r < t.length;) {
564
+ let e = t[r], i = wn(e);
565
+ if (i) {
566
+ let e = i.sameLineBody;
567
+ if (e !== Tn(e)) {
568
+ e = Tn(e);
569
+ let i = En(t.slice(r + 1).join("\n"));
570
+ return [
571
+ ...n,
572
+ e,
573
+ i
574
+ ].filter(Boolean).join("\n");
575
+ }
576
+ let a = [];
577
+ for (e && a.push(e), r += 1; r < t.length && !_n.test(t[r]);) a.push(t[r]), r += 1;
578
+ let o = r < t.length ? En(t.slice(r + 1).join("\n")) : "";
579
+ return [
580
+ ...n,
581
+ a.join("\n"),
582
+ o
583
+ ].filter(Boolean).join("\n");
584
+ }
585
+ if (xn(e)) return On([...n, ...t.slice(r)].join("\n"));
586
+ bn(e) && n.push(e), r += 1;
587
+ }
588
+ return n.length ? n.join("\n") : null;
589
+ }, On = (e) => {
590
+ let t = e.split("\n");
591
+ if (!t.length) return e;
592
+ let n = wn(t[0]);
593
+ return n && !xn(t[0].slice(0, t[0].indexOf("```"))) && (t.shift(), n.sameLineBody && t.unshift(Tn(n.sameLineBody))), t.length && _n.test(t[t.length - 1] ?? "") && t.pop(), t.join("\n");
594
+ }, kn = (e) => {
595
+ if (!e) return {
596
+ html: "",
597
+ pending: !1
598
+ };
599
+ let { text: t, withheld: n } = Cn(Sn(e));
600
+ if (!t.trim()) return {
601
+ html: "",
602
+ pending: n || hn.test(Sn(e).trim())
603
+ };
604
+ let r = Dn(t) ?? t, i = Dn(r);
605
+ i !== null && i !== r && (r = i);
606
+ let a = r.trim();
607
+ return bn(a) ? {
608
+ html: a,
609
+ pending: !1
610
+ } : {
611
+ html: "",
612
+ pending: !0
613
+ };
614
+ }, An = ({ editor: e, ai: t }) => {
615
+ let n = u(t);
616
+ n.current = t;
617
+ let [r, i] = d(null), [a, o] = d({
618
+ html: "",
619
+ text: "",
620
+ polishText: ""
621
+ }), [s, c] = d("quick"), l = () => {
622
+ let t = pn(e);
623
+ o(t), i("typeset"), n.current?.typeset?.({
624
+ html: t.html,
625
+ text: t.text
626
+ });
627
+ }, f = (t) => {
628
+ let r = pn(e);
629
+ o(r), c(t), i("polish"), n.current?.stop?.(), n.current?.polish?.({
630
+ text: r.polishText,
631
+ preset: t
632
+ });
633
+ }, p = () => {
634
+ n.current?.stop?.(), i(null);
635
+ };
636
+ return {
637
+ mode: r,
638
+ snapshot: a,
639
+ preset: s,
640
+ startTypeset: l,
641
+ startPolish: f,
642
+ close: p,
643
+ apply: () => {
644
+ let t = n.current?.text ?? "";
645
+ if (r === "typeset") {
646
+ let n = U(kn(t).html);
647
+ if (!n.trim()) return;
648
+ e.update(() => {
649
+ yt(e, n), bt(!0);
650
+ });
651
+ } else r === "polish" && fn(e, t);
652
+ p();
653
+ }
654
+ };
655
+ }, jn = i({}), K = 36, Mn = 14, Nn = 2 * Math.PI * Mn, Pn = ({ nodeKey: e, src: t, altText: n, dataId: r }) => {
656
+ let i = o(jn), a = e in i, s = i[e];
657
+ return /* @__PURE__ */ m("span", {
658
+ className: V["bsy-mobile-editor__image"],
659
+ children: [/* @__PURE__ */ p("img", {
660
+ src: t,
661
+ alt: n,
662
+ "data-id": r
663
+ }), a ? /* @__PURE__ */ p("span", {
664
+ className: V["bsy-mobile-editor__image-mask"],
665
+ role: "progressbar",
666
+ "aria-label": n,
667
+ "aria-valuemin": 0,
668
+ "aria-valuemax": 100,
669
+ "aria-valuenow": s === void 0 ? void 0 : Math.round(s),
670
+ children: /* @__PURE__ */ m("svg", {
671
+ className: s === void 0 ? `${V["bsy-mobile-editor__image-progress"]} ${V["bsy-mobile-editor__image-progress--spin"]}` : V["bsy-mobile-editor__image-progress"],
672
+ width: K,
673
+ height: K,
674
+ viewBox: `0 0 ${K} ${K}`,
675
+ "aria-hidden": "true",
676
+ children: [/* @__PURE__ */ p("circle", {
677
+ cx: K / 2,
678
+ cy: K / 2,
679
+ r: Mn,
680
+ fill: "none",
681
+ stroke: "rgba(255,255,255,0.35)",
682
+ strokeWidth: "3"
683
+ }), /* @__PURE__ */ p("circle", {
684
+ cx: K / 2,
685
+ cy: K / 2,
686
+ r: Mn,
687
+ fill: "none",
688
+ stroke: "#fff",
689
+ strokeWidth: "3",
690
+ strokeLinecap: "round",
691
+ strokeDasharray: s === void 0 ? `${Nn * .25} ${Nn}` : Nn,
692
+ strokeDashoffset: s === void 0 ? 0 : Nn * (1 - s / 100),
693
+ transform: `rotate(-90 ${K / 2} ${K / 2})`
694
+ })]
695
+ })
696
+ }) : null]
697
+ });
698
+ }, Fn = class e extends Ne {
699
+ __src;
700
+ __altText;
701
+ __width;
702
+ __height;
703
+ __dataId;
704
+ static getType() {
705
+ return "image";
706
+ }
707
+ static clone(t) {
708
+ return new e(t.__src, t.__altText, t.__width, t.__height, t.__key, t.__dataId);
709
+ }
710
+ constructor(e, t, n, r, i, a) {
711
+ super(i), this.__src = e, this.__altText = t || "", this.__width = n, this.__height = r, this.__dataId = a;
712
+ }
713
+ createDOM() {
714
+ let e = document.createElement("span");
715
+ return e.className = V["bsy-mobile-editor__image-shell"], e;
716
+ }
717
+ updateDOM() {
718
+ return !1;
719
+ }
720
+ exportDOM() {
721
+ let e = document.createElement("img");
722
+ return e.setAttribute("src", this.__src), e.setAttribute("alt", this.__altText), e.style.maxWidth = "100%", e.style.display = "inline", e.style.verticalAlign = "baseline", this.__width && e.setAttribute("width", this.__width.toString()), this.__height && e.setAttribute("height", this.__height.toString()), this.__dataId && e.setAttribute("data-id", this.__dataId), { element: e };
723
+ }
724
+ getSrc() {
725
+ return this.__src;
726
+ }
727
+ setSrc(e) {
728
+ let t = this.getWritable();
729
+ t.__src = e;
730
+ }
731
+ setDataId(e) {
732
+ let t = this.getWritable();
733
+ t.__dataId = e;
734
+ }
735
+ static importDOM() {
736
+ return { img: () => ({
737
+ conversion: Rn,
738
+ priority: 0
739
+ }) };
740
+ }
741
+ static importJSON(e) {
742
+ let { src: t, altText: n, width: r, height: i, dataId: a } = e;
743
+ return Ln({
744
+ src: t,
745
+ altText: n,
746
+ width: r,
747
+ height: i,
748
+ dataId: a
749
+ });
750
+ }
751
+ exportJSON() {
752
+ return {
753
+ src: this.getSrc(),
754
+ altText: this.__altText,
755
+ width: this.__width,
756
+ height: this.__height,
757
+ dataId: this.__dataId,
758
+ type: "image",
759
+ version: 1
760
+ };
761
+ }
762
+ isInline() {
763
+ return !0;
764
+ }
765
+ decorate() {
766
+ return /* @__PURE__ */ p(Pn, {
767
+ nodeKey: this.getKey(),
768
+ src: this.__src,
769
+ altText: this.__altText,
770
+ dataId: this.__dataId
771
+ });
772
+ }
773
+ }, In = (e) => e instanceof Fn, Ln = ({ src: e, altText: t, width: n, height: r, dataId: i, key: a }) => new Fn(e, t, n, r, a, i), Rn = (e) => {
774
+ if (!(e instanceof HTMLImageElement)) return null;
775
+ let { src: t, alt: n, style: r } = e, i, a;
776
+ if (r.width) {
777
+ let e = parseInt(r.width, 10);
778
+ Number.isNaN(e) || (i = e);
779
+ }
780
+ if (r.height) {
781
+ let e = parseInt(r.height, 10);
782
+ Number.isNaN(e) || (a = e);
783
+ }
784
+ return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node: Ln({
785
+ src: t,
786
+ altText: n,
787
+ width: i,
788
+ height: a,
789
+ dataId: e.getAttribute("data-id") || void 0
790
+ }) };
791
+ }, zn = (e) => mt.includes(e.name.split(".").pop()?.toLowerCase() ?? ""), Bn = (e) => zn(e) ? e.size > 5242880 ? "size" : null : "type", Vn = ({ editor: e, upload: t, savedSelectionRef: n, attachmentsBySrc: r }) => {
792
+ let i = u(null), o = u(null), c = u(!0), [l, f] = d({}), p = a(() => {
793
+ o.current?.abort(), o.current = null;
794
+ }, []);
795
+ s(() => (c.current = !0, () => {
796
+ c.current = !1, p();
797
+ }), [p]);
798
+ let m = a((t, r, i) => {
799
+ let a = "";
800
+ return e.update(() => {
801
+ let e = n.current;
802
+ e !== null && R(e), I() === null && F().selectEnd();
803
+ let o = Ln({
804
+ src: t,
805
+ altText: r,
806
+ dataId: i
807
+ });
808
+ a = o.getKey(), xe([o]);
809
+ for (let e of o.getParent()?.getChildren() ?? []) Ee(e) && e.getTextContentSize() === 0 && e.remove();
810
+ }), a;
811
+ }, [e, n]);
812
+ return {
813
+ fileInputRef: i,
814
+ uploadProgress: l,
815
+ insertImage: m,
816
+ onFileChange: a(async (n) => {
817
+ let i = n.target.files?.[0];
818
+ if (n.target.value = "", !i || Bn(i)) return;
819
+ p();
820
+ let a = new AbortController();
821
+ if (o.current = a, !t?.customRequest) {
822
+ try {
823
+ let e = await new Promise((e, t) => {
824
+ let n = new FileReader();
825
+ n.onload = () => e(String(n.result)), n.onerror = () => t(n.error), n.readAsDataURL(i);
826
+ });
827
+ if (!e || a.signal.aborted) return;
828
+ m(e, i.name);
829
+ } catch {
830
+ return;
831
+ } finally {
832
+ o.current === a && (o.current = null);
833
+ }
834
+ return;
835
+ }
836
+ let s = URL.createObjectURL(i), l = m(s, i.name);
837
+ f((e) => ({
838
+ ...e,
839
+ [l]: void 0
840
+ }));
841
+ let u = !1, d = (t) => {
842
+ u || (u = !0, URL.revokeObjectURL(s), t || e.update(() => {
843
+ be(l)?.remove();
844
+ }, c.current ? void 0 : { discrete: !0 }), c.current && f((e) => {
845
+ let t = { ...e };
846
+ return delete t[l], t;
847
+ }), o.current === a && (o.current = null));
848
+ };
849
+ a.signal.addEventListener("abort", () => d(!1), { once: !0 });
850
+ try {
851
+ let n = await t.customRequest(i, {
852
+ signal: a.signal,
853
+ onProgress: (e) => {
854
+ if (!c.current || !Number.isFinite(e)) return;
855
+ let t = Math.min(100, Math.max(0, e));
856
+ f((e) => l in e ? {
857
+ ...e,
858
+ [l]: t
859
+ } : e);
860
+ }
861
+ });
862
+ if (a.signal.aborted) {
863
+ d(!1);
864
+ return;
865
+ }
866
+ let o = "", s;
867
+ if (typeof n == "string" ? o = n : (o = n.url, n.attachment && (r.set(o, n.attachment), s = n.attachment._id)), !o) {
868
+ d(!1);
869
+ return;
870
+ }
871
+ e.update(() => {
872
+ let e = be(l);
873
+ In(e) && (e.setSrc(o), s && e.setDataId(s));
874
+ }), d(!0);
875
+ } catch {
876
+ d(!1);
877
+ }
878
+ }, [
879
+ p,
880
+ r,
881
+ e,
882
+ m,
883
+ t
884
+ ]),
885
+ abortUpload: p
886
+ };
887
+ }, Hn = ({ editor: e, savedSelectionRef: t, captureSelection: n }) => {
888
+ let [r, i] = d(null);
889
+ return {
890
+ linkForm: r,
891
+ openLink: () => {
892
+ n(), e.getEditorState().read(() => {
893
+ let e = I(), t = L(e) ? e.anchor.getNode() : null, n = t ? B(t, v) : null;
894
+ if (n) {
895
+ i({
896
+ url: n.getURL(),
897
+ text: n.getTextContent(),
898
+ newBlank: n.getTarget() === "_blank"
899
+ });
900
+ return;
901
+ }
902
+ i({
903
+ url: "",
904
+ text: L(e) ? e.getTextContent() : "",
905
+ newBlank: !0
906
+ });
907
+ });
908
+ },
909
+ confirmLink: (n) => {
910
+ let r = n.url.trim();
911
+ if (!r) return;
912
+ let a = r.startsWith("@") || /^https?:\/\//.test(r) ? r : `http://${r}`;
913
+ e.update(() => {
914
+ let e = t.current;
915
+ e !== null && R(e);
916
+ let r = I(), i = n.newBlank ? {
917
+ target: "_blank",
918
+ rel: "noopener noreferrer",
919
+ title: n.url
920
+ } : { title: n.url };
921
+ if (L(r)) {
922
+ let e = n.text.trim() || n.url;
923
+ if (r.getTextContent()) y(a, i);
924
+ else {
925
+ let t = ye(e), n = _(a, i);
926
+ n.append(t), r.insertNodes([n]);
927
+ }
928
+ } else {
929
+ let e = ye(n.text.trim() || n.url), t = _(a, i);
930
+ t.append(e);
931
+ let r = F(), o = r.getLastChild();
932
+ if (Se(o)) o.append(t);
933
+ else {
934
+ let e = P();
935
+ e.append(t), r.append(e);
936
+ }
937
+ }
938
+ }), i(null);
939
+ },
940
+ closeLink: () => i(null)
941
+ };
942
+ }, Un = ({ editor: e, value: t, onChange: n, attachmentsBySrc: r }) => {
943
+ let i = u(null), o = u(n);
944
+ o.current = n;
945
+ let c = a((t) => {
946
+ t.read(() => {
947
+ let n = F().getTextContent(), a = Yt(U(et(e, null))), s = St(a, n) ? null : a;
948
+ i.current = s;
949
+ let c = De(Fn).map((e) => r.get(e.getSrc())).filter((e) => e !== void 0);
950
+ o.current({
951
+ text: n,
952
+ html: s,
953
+ attachments: c
954
+ }, t);
955
+ }, { editor: e });
956
+ }, [r, e]);
957
+ return s(() => {
958
+ t === void 0 || t === i.current || (i.current = t ?? null, e.update(() => {
959
+ yt(e, t?.trim() ? U(t) : ""), bt(!!e.getRootElement()?.contains(document.activeElement));
960
+ }, { onUpdate: () => {
961
+ e.getRootElement() || c(e.getEditorState());
962
+ } }));
963
+ }, [
964
+ e,
965
+ c,
966
+ t
967
+ ]), c;
968
+ }, Wn = 250, Gn = () => {
969
+ let [e] = z(), t = u(0);
970
+ return s(() => e.registerCommand(ze, (e) => {
971
+ let n = Date.now(), r = n - t.current;
972
+ if (t.current = n, r <= 0 || r >= Wn) return !1;
973
+ let i = I();
974
+ if (!L(i) || !i.isCollapsed()) return !1;
975
+ let a = i.anchor.getNode();
976
+ if (B(a, S)) return !1;
977
+ let o = a.getTopLevelElement();
978
+ if (!o || o.getTextContent().trim() !== "") return !1;
979
+ i.setFormat(0);
980
+ let s = P();
981
+ at(i, {
982
+ "background-color": "",
983
+ color: "",
984
+ "font-size": "",
985
+ "font-weight": "",
986
+ "font-style": "",
987
+ "text-decoration": ""
988
+ }), o.replace(s), s.select();
989
+ let c = s.getPreviousSibling();
990
+ return c?.getTextContent().trim() === "" && c.remove(), e?.preventDefault(), !0;
991
+ }, je), [e]), null;
992
+ }, Kn = (e, t) => e.split(";").map((e) => e.trim()).filter((e) => e && e.split(":")[0].trim().toLowerCase() !== t).join("; "), qn = () => {
993
+ let [e] = z();
994
+ return s(() => e.registerNodeTransform(ae, (e) => {
995
+ let t = e.getTag();
996
+ if (t === "h4" || t === "h5" || t === "h6") {
997
+ e.replace(P(), !0);
998
+ return;
999
+ }
1000
+ for (let t of e.getAllTextNodes()) {
1001
+ let e = t.getStyle();
1002
+ if (!e) continue;
1003
+ let n = Kn(e, "font-size");
1004
+ n !== e && t.setStyle(n);
1005
+ }
1006
+ }), [e]), null;
1007
+ }, q = class e extends We {
1008
+ static getType() {
1009
+ return "extended-text";
1010
+ }
1011
+ static clone(t) {
1012
+ return new e(t.__text, t.__key);
1013
+ }
1014
+ static importDOM() {
1015
+ let e = We.importDOM();
1016
+ return {
1017
+ ...e,
1018
+ code: () => ({
1019
+ conversion: J(e?.code),
1020
+ priority: 1
1021
+ }),
1022
+ em: () => ({
1023
+ conversion: J(e?.em),
1024
+ priority: 1
1025
+ }),
1026
+ span: () => ({
1027
+ conversion: J(e?.span),
1028
+ priority: 1
1029
+ }),
1030
+ strong: () => ({
1031
+ conversion: J(e?.strong),
1032
+ priority: 1
1033
+ }),
1034
+ sub: () => ({
1035
+ conversion: J(e?.sub),
1036
+ priority: 1
1037
+ }),
1038
+ sup: () => ({
1039
+ conversion: J(e?.sup),
1040
+ priority: 1
1041
+ })
1042
+ };
1043
+ }
1044
+ static importJSON(e) {
1045
+ return Jn().updateFromJSON(e);
1046
+ }
1047
+ isSimpleText() {
1048
+ return this.__type === "extended-text" && this.__mode === 0;
1049
+ }
1050
+ }, Jn = (e = "") => ge(new q(e)), J = (e) => (t) => {
1051
+ let n = e?.(t);
1052
+ if (!n) return null;
1053
+ let r = n.conversion(t);
1054
+ if (!r) return r;
1055
+ let i = t.style.backgroundColor, a = t.style.color, o = t.style.fontFamily, s = t.style.fontWeight, c = t.style.fontSize, l = t.style.textDecoration;
1056
+ return {
1057
+ ...r,
1058
+ forChild: (e, t) => {
1059
+ let n = (r?.forChild ?? ((e) => e))(e, t);
1060
+ if (Ee(n)) {
1061
+ let e = [
1062
+ i ? `background-color: ${i}` : null,
1063
+ a ? `color: ${a}` : null,
1064
+ o ? `font-family: ${o}` : null,
1065
+ s ? `font-weight: ${s}` : null,
1066
+ c ? `font-size: ${c}` : null,
1067
+ l ? `text-decoration: ${l}` : null
1068
+ ].filter((e) => e !== null).join("; ");
1069
+ if (e.length) return n.setStyle(e);
1070
+ }
1071
+ return n;
1072
+ }
1073
+ };
1074
+ }, Yn = () => {
1075
+ let [e] = z();
1076
+ return s(() => e.registerNodeTransform(q, (e) => {
1077
+ if (!B(e, v)) return;
1078
+ let t = e.getStyle();
1079
+ if (!t) return;
1080
+ let n = Kn(t, "color");
1081
+ n !== t && e.setStyle(n);
1082
+ }), [e]), null;
1083
+ }, Xn = /<img\b|<picture\b/i, Zn = () => {
1084
+ let [e] = z();
1085
+ return s(() => {
1086
+ let t = (t) => {
1087
+ let n = "clipboardData" in t ? t.clipboardData : "dataTransfer" in t ? t.dataTransfer : null;
1088
+ if (!n || n.getData("application/x-lexical-editor") || n.getData("application/x-lexical-drag")) return !1;
1089
+ let r = n.getData("text/html");
1090
+ if (!(Array.from(n.files).some((e) => e.type.startsWith("image/")) || Array.from(n.items).some((e) => e.type.startsWith("image/")) || Xn.test(r))) return !1;
1091
+ t.preventDefault();
1092
+ let i = n.getData("text/plain");
1093
+ return !Xn.test(r) && !i || e.update(() => {
1094
+ let t = I();
1095
+ if (t === null) return;
1096
+ let n = r ? new DOMParser().parseFromString(r, "text/html") : null;
1097
+ if (n?.querySelectorAll("img, picture").forEach((e) => e.remove()), (n?.body.innerHTML ?? "") && n?.body.textContent?.trim()) {
1098
+ let t = tt(e, n);
1099
+ if (t.length) {
1100
+ xe(t);
1101
+ return;
1102
+ }
1103
+ }
1104
+ i && t.insertRawText(i);
1105
+ }, { tag: Ue }), !0;
1106
+ };
1107
+ return rt(e.registerCommand(He, t, Ae), e.registerCommand(Me, t, Ae));
1108
+ }, [e]), null;
1109
+ }, Qn = "data:image/png;base64,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", $n = "data:image/png;base64,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", er = (e, t, n) => Math.min(n, Math.max(t, e)), Y = (e) => er(e, 0, 1), X = (e) => {
1110
+ let t = e.trim().toLowerCase();
1111
+ if (t === "" || t === "transparent") return !0;
1112
+ let n = t.match(/^rgba\([^,]+,[^,]+,[^,]+,\s*([.\d]+)\s*\)$/);
1113
+ return n !== null && Number(n[1]) === 0;
1114
+ }, tr = (e) => {
1115
+ let t = e.trim().replace(/^#/, "");
1116
+ return /^[0-9a-fA-F]{3}$/.test(t) ? `#${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`.toLowerCase() : /^[0-9a-fA-F]{6}$/.test(t) ? `#${t.toLowerCase()}` : null;
1117
+ }, nr = (e) => {
1118
+ let t = e.trim();
1119
+ if (X(t)) return null;
1120
+ let n = tr(t);
1121
+ if (n) return {
1122
+ r: Number.parseInt(n.slice(1, 3), 16),
1123
+ g: Number.parseInt(n.slice(3, 5), 16),
1124
+ b: Number.parseInt(n.slice(5, 7), 16)
1125
+ };
1126
+ let r = t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);
1127
+ return r ? {
1128
+ r: Number(r[1]),
1129
+ g: Number(r[2]),
1130
+ b: Number(r[3])
1131
+ } : null;
1132
+ }, rr = ({ r: e, g: t, b: n }) => `#${[
1133
+ e,
1134
+ t,
1135
+ n
1136
+ ].map((e) => er(Math.round(e), 0, 255).toString(16).padStart(2, "0")).join("")}`, ir = (e, t) => {
1137
+ if (X(e) && X(t)) return !0;
1138
+ let n = nr(e), r = nr(t);
1139
+ return !!(n && r && n.r === r.r && n.g === r.g && n.b === r.b);
1140
+ }, ar = (e) => {
1141
+ let t = e.r / 255, n = e.g / 255, r = e.b / 255, i = Math.max(t, n, r), a = Math.min(t, n, r), o = (i + a) / 2, s = i - a, c = 0;
1142
+ return s !== 0 && (c = i === t ? ((n - r) / s + (n < r ? 6 : 0)) * 60 : i === n ? ((r - t) / s + 2) * 60 : ((t - n) / s + 4) * 60), {
1143
+ h: c,
1144
+ s: s === 0 ? 0 : s / (1 - Math.abs(2 * o - 1)),
1145
+ l: o
1146
+ };
1147
+ }, or = ({ h: e, s: t, l: n }) => {
1148
+ let r = (e % 360 + 360) % 360, i = (1 - Math.abs(2 * n - 1)) * t, a = i * (1 - Math.abs(r / 60 % 2 - 1)), o = n - i / 2, s = 0, c = 0, l = 0;
1149
+ return r < 60 ? (s = i, c = a) : r < 120 ? (s = a, c = i) : r < 180 ? (c = i, l = a) : r < 240 ? (c = a, l = i) : r < 300 ? (s = a, l = i) : (s = i, l = a), {
1150
+ r: Math.round((s + o) * 255),
1151
+ g: Math.round((c + o) * 255),
1152
+ b: Math.round((l + o) * 255)
1153
+ };
1154
+ }, sr = (e) => rr(or(e)), cr = (e, t) => ({
1155
+ h: Y(e) * 360,
1156
+ s: 1,
1157
+ l: Y(1 - t)
1158
+ }), lr = (e) => ({
1159
+ x: Y((e.h % 360 + 360) % 360 / 360),
1160
+ y: Y(1 - e.l)
1161
+ }), ur = (e, t, n) => ({
1162
+ x: Y(n.width === 0 ? 0 : (e - n.left) / n.width),
1163
+ y: Y(n.height === 0 ? 0 : (t - n.top) / n.height)
1164
+ }), dr = (e, t, n = Infinity) => {
1165
+ let r = nr(t);
1166
+ if (!r) return e;
1167
+ let i = rr(r);
1168
+ return [i, ...e.filter((e) => !ir(e, i))].slice(0, n);
1169
+ }, fr = (e, t = 24, n = 8) => Math.max(0, Math.floor((e + n) / (t + n))), pr = (e, t) => {
1170
+ let n = t % 11;
1171
+ return Math.floor(t / 11) === 2 ? e[22] ?? e[t] : e[n] ?? e[t];
1172
+ }, Z = (...e) => e.filter(Boolean).join(" "), mr = (e) => {
1173
+ let t = nr(e) ?? {
1174
+ r: 0,
1175
+ g: 94,
1176
+ b: 239
1177
+ };
1178
+ return {
1179
+ color: rr(t),
1180
+ point: lr(ar(t))
1181
+ };
1182
+ }, hr = ({ mode: t, currentColor: r, customColors: i, onApply: a, onCustomDraftChange: o, onCustomConfirm: c }) => {
1183
+ let { t: l } = e(), [f, h] = d("presets"), [g, _] = d(() => mr(r)), [v, y] = d(!1), [b, x] = d(null), S = u(null), C = u(null), w = u(null), T = (e = r) => {
1184
+ _(mr(e)), y(!1), o(null), h("custom");
1185
+ };
1186
+ s(() => {
1187
+ if (f !== "custom" || typeof ResizeObserver > "u") return;
1188
+ let e = C.current;
1189
+ if (!e) return;
1190
+ let t = () => {
1191
+ let { width: t, height: n } = e.getBoundingClientRect();
1192
+ if (!t || !n) return;
1193
+ let r = window.devicePixelRatio || 1;
1194
+ e.width = Math.round(t * r), e.height = Math.round(n * r);
1195
+ let i = e.getContext("2d");
1196
+ if (!i) return;
1197
+ i.scale(r, r);
1198
+ let a = i.createLinearGradient(0, 0, t, 0);
1199
+ a.addColorStop(0, "#f00"), a.addColorStop(1 / 6, "#ff0"), a.addColorStop(2 / 6, "#0f0"), a.addColorStop(3 / 6, "#0ff"), a.addColorStop(4 / 6, "#00f"), a.addColorStop(5 / 6, "#f0f"), a.addColorStop(1, "#f00"), i.fillStyle = a, i.fillRect(0, 0, t, n);
1200
+ let o = i.createLinearGradient(0, 0, 0, n);
1201
+ o.addColorStop(0, "#fff"), o.addColorStop(.5, "rgba(255, 255, 255, 0)"), o.addColorStop(1, "rgba(255, 255, 255, 0)"), i.fillStyle = o, i.fillRect(0, 0, t, n);
1202
+ let s = i.createLinearGradient(0, 0, 0, n);
1203
+ s.addColorStop(0, "rgba(0, 0, 0, 0)"), s.addColorStop(.5, "rgba(0, 0, 0, 0)"), s.addColorStop(1, "#000"), i.fillStyle = s, i.fillRect(0, 0, t, n);
1204
+ };
1205
+ t();
1206
+ let n = new ResizeObserver(t);
1207
+ return n.observe(e), () => n.disconnect();
1208
+ }, [f]), s(() => {
1209
+ let e = w.current;
1210
+ if (!e) return;
1211
+ let t = () => {
1212
+ let t = e.getBoundingClientRect().width;
1213
+ t > 0 && x(fr(t));
1214
+ };
1215
+ if (t(), typeof ResizeObserver > "u") return;
1216
+ let n = new ResizeObserver(t);
1217
+ return n.observe(e), () => n.disconnect();
1218
+ }, [t]);
1219
+ let E = (e) => {
1220
+ let t = S.current;
1221
+ if (!t) return;
1222
+ let { x: n, y: r } = ur(e.clientX, e.clientY, t.getBoundingClientRect()), i = sr(cr(n, r));
1223
+ _({
1224
+ color: i,
1225
+ point: {
1226
+ x: n,
1227
+ y: r
1228
+ }
1229
+ }), y(!0), o(i);
1230
+ }, D = f === "custom", { color: O, point: k } = g, A = /* @__PURE__ */ m("div", {
1231
+ className: V["bsy-mobile-editor__color-bar"],
1232
+ children: [
1233
+ /* @__PURE__ */ p("button", {
1234
+ type: "button",
1235
+ className: Z(V["bsy-mobile-editor__color-custom-trigger"], D && V["bsy-mobile-editor__color-custom-trigger--active"], v && V["bsy-mobile-editor__color-custom-trigger--preview"]),
1236
+ "aria-label": l("editor.addSwatch"),
1237
+ "aria-pressed": D,
1238
+ style: { backgroundColor: D && v ? O : void 0 },
1239
+ onClick: () => {
1240
+ D || T(r);
1241
+ },
1242
+ children: v ? null : /* @__PURE__ */ p(n, {
1243
+ name: "add",
1244
+ size: 16
1245
+ })
1246
+ }),
1247
+ t === "fill" ? /* @__PURE__ */ p("button", {
1248
+ type: "button",
1249
+ role: "option",
1250
+ "aria-selected": X(r),
1251
+ "aria-label": l("editor.fillNone"),
1252
+ className: Z(V["bsy-mobile-editor__color-none"], X(r) && V["bsy-mobile-editor__color-none--selected"]),
1253
+ onClick: () => a("transparent")
1254
+ }) : null,
1255
+ /* @__PURE__ */ p("div", {
1256
+ ref: w,
1257
+ className: V["bsy-mobile-editor__color-custom-list"],
1258
+ role: "listbox",
1259
+ "aria-label": l("editor.customColors"),
1260
+ children: i.slice(0, b ?? i.length).map((e) => {
1261
+ let t = ir(r, e);
1262
+ return /* @__PURE__ */ p("button", {
1263
+ type: "button",
1264
+ role: "option",
1265
+ "aria-selected": t,
1266
+ "aria-label": e,
1267
+ className: Z(V["bsy-mobile-editor__color-custom-item"], t && V["bsy-mobile-editor__color-custom-item--selected"]),
1268
+ style: {
1269
+ "--swatch-color": e,
1270
+ backgroundColor: e
1271
+ },
1272
+ onClick: () => a(e)
1273
+ }, e);
1274
+ })
1275
+ })
1276
+ ]
1277
+ });
1278
+ return /* @__PURE__ */ m("div", {
1279
+ className: Z(V["bsy-mobile-editor__color"], D && V["bsy-mobile-editor__color--custom"]),
1280
+ children: [
1281
+ /* @__PURE__ */ m("div", {
1282
+ className: V["bsy-mobile-editor__color-header"],
1283
+ children: [D ? /* @__PURE__ */ p("button", {
1284
+ type: "button",
1285
+ className: V["bsy-mobile-editor__color-header-back"],
1286
+ "aria-label": l("editor.colorBack"),
1287
+ onClick: () => {
1288
+ v && c(O), o(null), y(!1), h("presets");
1289
+ },
1290
+ children: /* @__PURE__ */ p(n, {
1291
+ name: "left",
1292
+ size: 18
1293
+ })
1294
+ }) : null, /* @__PURE__ */ p("span", {
1295
+ className: V["bsy-mobile-editor__color-header-title"],
1296
+ children: l(D ? "editor.customColor" : t === "fill" ? "editor.fill" : "editor.fontColor")
1297
+ })]
1298
+ }),
1299
+ D ? /* @__PURE__ */ p("div", {
1300
+ className: V["bsy-mobile-editor__color-mixer"],
1301
+ children: /* @__PURE__ */ m("div", {
1302
+ ref: S,
1303
+ className: V["bsy-mobile-editor__color-spectrum"],
1304
+ role: "slider",
1305
+ "aria-label": l("editor.colorSpectrum"),
1306
+ "aria-valuemin": 0,
1307
+ "aria-valuemax": 100,
1308
+ "aria-valuenow": Math.round(k.x * 100),
1309
+ "aria-valuetext": O,
1310
+ onPointerDown: (e) => {
1311
+ e.currentTarget.setPointerCapture(e.pointerId), E(e);
1312
+ },
1313
+ onPointerMove: (e) => {
1314
+ e.buttons !== 0 && E(e);
1315
+ },
1316
+ onPointerUp: (e) => {
1317
+ E(e);
1318
+ },
1319
+ children: [/* @__PURE__ */ p("canvas", {
1320
+ ref: C,
1321
+ className: V["bsy-mobile-editor__color-spectrum-canvas"],
1322
+ width: 392,
1323
+ height: 192,
1324
+ "aria-hidden": !0
1325
+ }), /* @__PURE__ */ p("span", {
1326
+ className: V["bsy-mobile-editor__color-thumb"],
1327
+ style: {
1328
+ left: `${k.x * 100}%`,
1329
+ top: `${k.y * 100}%`,
1330
+ backgroundColor: O
1331
+ }
1332
+ })]
1333
+ })
1334
+ }) : /* @__PURE__ */ p("div", {
1335
+ className: V["bsy-mobile-editor__color-grid"],
1336
+ role: "listbox",
1337
+ "aria-label": l("editor.presetColors"),
1338
+ children: ut.map((e, t) => {
1339
+ let n = ir(r, e);
1340
+ return /* @__PURE__ */ p("button", {
1341
+ type: "button",
1342
+ role: "option",
1343
+ "aria-selected": n,
1344
+ "aria-label": e,
1345
+ className: Z(V["bsy-mobile-editor__color-swatch"], n && V["bsy-mobile-editor__color-swatch--selected"]),
1346
+ style: {
1347
+ "--swatch-color": e,
1348
+ "--swatch-ring": pr(ut, t)
1349
+ },
1350
+ onClick: () => a(e),
1351
+ children: /* @__PURE__ */ p("span", { className: V["bsy-mobile-editor__color-swatch-fill"] })
1352
+ }, e);
1353
+ })
1354
+ }),
1355
+ A
1356
+ ]
1357
+ });
1358
+ }, gr = (e, t) => {
1359
+ H(e), e.update(() => {
1360
+ ot(I(), () => t === "paragraph" ? P() : re(t));
1361
+ });
1362
+ }, _r = (e, t, n) => {
1363
+ H(e), e.update(() => {
1364
+ n && R(n), xt();
1365
+ let e = I();
1366
+ e && at(e, t);
1367
+ });
1368
+ }, vr = ({ sheet: i, onClose: a, onTypeset: o, onPolishMenu: s, onPickPreset: c, onPicture: l, savedSelectionRef: h, committedColors: g, onColorCommit: _, canTypeset: v, canPolish: y }) => {
1369
+ let [b] = z(), { t: x } = e(), [S, C] = d([]), w = u(null), T = i === "fontColor" || i === "fill" ? i : null, E = T === "fill" ? g.fill : T === "fontColor" ? g.fontColor : ct, D = (e, t = !1, n = !0) => {
1370
+ T && (n && (w.current = null), _r(b, { [T === "fill" ? "background-color" : "color"]: e }, h.current), _(T, e), t && !X(e) && C((t) => dr(t, e)), n && a());
1371
+ }, O = (e) => {
1372
+ w.current = null, D(e, !0, !1);
1373
+ };
1374
+ return /* @__PURE__ */ m(f, { children: [
1375
+ /* @__PURE__ */ p(r, {
1376
+ mode: "menu",
1377
+ open: i === "align",
1378
+ title: x("editor.alignment"),
1379
+ onClose: a,
1380
+ actions: [
1381
+ {
1382
+ key: "left",
1383
+ text: x("editor.leftAlign"),
1384
+ icon: /* @__PURE__ */ p(n, {
1385
+ name: "paragraph",
1386
+ size: 16
1387
+ })
1388
+ },
1389
+ {
1390
+ key: "center",
1391
+ text: x("editor.centerAlign"),
1392
+ icon: /* @__PURE__ */ p(n, {
1393
+ name: "paragraphmiddle",
1394
+ size: 16
1395
+ })
1396
+ },
1397
+ {
1398
+ key: "right",
1399
+ text: x("editor.rightAlign"),
1400
+ icon: /* @__PURE__ */ p(n, {
1401
+ name: "paragraphright",
1402
+ size: 16
1403
+ })
1404
+ }
1405
+ ],
1406
+ onAction: (e) => {
1407
+ H(b), b.dispatchCommand(Fe, e.key);
1408
+ }
1409
+ }),
1410
+ /* @__PURE__ */ p(r, {
1411
+ mode: "menu",
1412
+ open: i === "heading",
1413
+ title: x("editor.heading"),
1414
+ onClose: a,
1415
+ actions: [
1416
+ {
1417
+ key: "paragraph",
1418
+ text: x("editor.paragraph")
1419
+ },
1420
+ {
1421
+ key: "h1",
1422
+ text: x("editor.heading1")
1423
+ },
1424
+ {
1425
+ key: "h2",
1426
+ text: x("editor.heading2")
1427
+ },
1428
+ {
1429
+ key: "h3",
1430
+ text: x("editor.heading3")
1431
+ }
1432
+ ],
1433
+ onAction: (e) => gr(b, e.key)
1434
+ }),
1435
+ /* @__PURE__ */ p(r, {
1436
+ mode: "menu",
1437
+ open: i === "fontSize",
1438
+ title: x("editor.fontSize"),
1439
+ onClose: a,
1440
+ actions: st.map((e) => ({
1441
+ key: e.value,
1442
+ text: e.label
1443
+ })),
1444
+ onAction: (e) => _r(b, { "font-size": e.key })
1445
+ }),
1446
+ /* @__PURE__ */ p(t, {
1447
+ open: T !== null,
1448
+ onClose: () => {
1449
+ let e = w.current;
1450
+ e && O(e), a();
1451
+ },
1452
+ position: "bottom",
1453
+ children: T ? /* @__PURE__ */ p(hr, {
1454
+ mode: T,
1455
+ currentColor: E,
1456
+ customColors: S,
1457
+ onApply: D,
1458
+ onCustomDraftChange: (e) => {
1459
+ w.current = e;
1460
+ },
1461
+ onCustomConfirm: O
1462
+ }, T) : null
1463
+ }),
1464
+ /* @__PURE__ */ p(r, {
1465
+ mode: "menu",
1466
+ open: i === "ai",
1467
+ onClose: a,
1468
+ actions: [{
1469
+ key: "typeset",
1470
+ text: x("editor.aiTypeset"),
1471
+ disabled: !v,
1472
+ icon: /* @__PURE__ */ p("img", {
1473
+ src: Qn,
1474
+ alt: "",
1475
+ width: 16,
1476
+ height: 16,
1477
+ className: V["bsy-mobile-editor__ai-icon"],
1478
+ draggable: !1
1479
+ })
1480
+ }, {
1481
+ key: "polish",
1482
+ text: x("editor.aiPolish"),
1483
+ disabled: !y,
1484
+ icon: /* @__PURE__ */ p("img", {
1485
+ src: $n,
1486
+ alt: "",
1487
+ width: 16,
1488
+ height: 16,
1489
+ className: V["bsy-mobile-editor__ai-icon"],
1490
+ draggable: !1
1491
+ })
1492
+ }],
1493
+ onAction: (e) => {
1494
+ if (e.key === "typeset") {
1495
+ o();
1496
+ return;
1497
+ }
1498
+ s();
1499
+ }
1500
+ }),
1501
+ /* @__PURE__ */ p(r, {
1502
+ mode: "menu",
1503
+ open: i === "aiPreset",
1504
+ title: x("editor.aiPolish"),
1505
+ onClose: a,
1506
+ actions: dt.map((e) => ({
1507
+ key: e,
1508
+ text: x(ft[e])
1509
+ })),
1510
+ onAction: (e) => c(e.key)
1511
+ }),
1512
+ /* @__PURE__ */ p(r, {
1513
+ mode: "menu",
1514
+ open: i === "picture",
1515
+ title: x("editor.picture"),
1516
+ onClose: a,
1517
+ actions: [{
1518
+ key: "upload",
1519
+ text: x("editor.uploadImage"),
1520
+ icon: /* @__PURE__ */ p(n, {
1521
+ name: "picture",
1522
+ size: 16
1523
+ })
1524
+ }, {
1525
+ key: "url",
1526
+ text: x("editor.imageUrl"),
1527
+ icon: /* @__PURE__ */ p(n, {
1528
+ name: "Insertlink",
1529
+ size: 16
1530
+ })
1531
+ }],
1532
+ onAction: (e) => l(e.key)
1533
+ })
1534
+ ] });
1535
+ }, yr = ({ open: r, title: i, bodyClassName: a, onClose: o, onConfirm: s, children: c }) => {
1536
+ let { t: l } = e();
1537
+ return /* @__PURE__ */ p(t, {
1538
+ open: r,
1539
+ onClose: o,
1540
+ position: "bottom",
1541
+ children: /* @__PURE__ */ m("div", {
1542
+ className: V["bsy-mobile-editor__sheet"],
1543
+ children: [
1544
+ /* @__PURE__ */ m("div", {
1545
+ className: V["bsy-mobile-editor__header"],
1546
+ children: [/* @__PURE__ */ p("div", {
1547
+ className: V["bsy-mobile-editor__title"],
1548
+ children: i
1549
+ }), /* @__PURE__ */ p("button", {
1550
+ type: "button",
1551
+ className: V["bsy-mobile-editor__close"],
1552
+ "aria-label": l("popup.close"),
1553
+ onClick: o,
1554
+ children: /* @__PURE__ */ p(n, {
1555
+ name: "close",
1556
+ size: 18
1557
+ })
1558
+ })]
1559
+ }),
1560
+ /* @__PURE__ */ p("div", {
1561
+ className: [V["bsy-mobile-editor__sheet-body"], a].filter(Boolean).join(" "),
1562
+ children: c
1563
+ }),
1564
+ /* @__PURE__ */ m("div", {
1565
+ className: V["bsy-mobile-editor__sheet-bar"],
1566
+ children: [/* @__PURE__ */ p("button", {
1567
+ type: "button",
1568
+ onClick: o,
1569
+ children: l("editor.cancel")
1570
+ }), /* @__PURE__ */ p("button", {
1571
+ type: "button",
1572
+ className: V["bsy-mobile-editor__sheet-ok"],
1573
+ onClick: s,
1574
+ children: l("editor.ok")
1575
+ })]
1576
+ })
1577
+ ]
1578
+ })
1579
+ });
1580
+ }, br = ({ open: t, seed: r, onClose: i, onConfirm: a }) => {
1581
+ let { t: o } = e(), [c, l] = d(""), [u, f] = d(""), [h, g] = d(!0);
1582
+ return s(() => {
1583
+ !t || !r || (l(r.url), f(r.text), g(r.newBlank));
1584
+ }, [t, r]), /* @__PURE__ */ m(yr, {
1585
+ open: t,
1586
+ title: o("editor.link"),
1587
+ bodyClassName: V["bsy-mobile-editor__sheet-body--stack"],
1588
+ onClose: i,
1589
+ onConfirm: () => a({
1590
+ url: c,
1591
+ text: u,
1592
+ newBlank: h
1593
+ }),
1594
+ children: [
1595
+ /* @__PURE__ */ m("label", {
1596
+ className: V["bsy-mobile-editor__sheet-field"],
1597
+ children: [
1598
+ /* @__PURE__ */ p("span", {
1599
+ className: V["bsy-mobile-editor__sheet-label"],
1600
+ children: o("editor.linkUrl")
1601
+ }),
1602
+ /* @__PURE__ */ p("span", {
1603
+ className: `${V["bsy-mobile-editor__sheet-note"]} ${V["bsy-mobile-editor__sheet-note--hint"]}`,
1604
+ children: o("editor.linkAliasTip")
1605
+ }),
1606
+ /* @__PURE__ */ p("input", {
1607
+ value: c,
1608
+ placeholder: o("editor.linkTip"),
1609
+ onChange: (e) => l(e.target.value)
1610
+ })
1611
+ ]
1612
+ }),
1613
+ /* @__PURE__ */ m("label", {
1614
+ className: V["bsy-mobile-editor__sheet-field"],
1615
+ children: [/* @__PURE__ */ p("span", {
1616
+ className: V["bsy-mobile-editor__sheet-label"],
1617
+ children: o("editor.linkText")
1618
+ }), /* @__PURE__ */ p("input", {
1619
+ value: u,
1620
+ onChange: (e) => f(e.target.value)
1621
+ })]
1622
+ }),
1623
+ /* @__PURE__ */ m("label", {
1624
+ className: V["bsy-mobile-editor__check"],
1625
+ children: [
1626
+ /* @__PURE__ */ p("input", {
1627
+ className: V["bsy-mobile-editor__check-input"],
1628
+ type: "checkbox",
1629
+ checked: h,
1630
+ onChange: (e) => g(e.target.checked)
1631
+ }),
1632
+ /* @__PURE__ */ p("span", {
1633
+ className: V["bsy-mobile-editor__check-box"],
1634
+ "aria-hidden": !0,
1635
+ children: h ? /* @__PURE__ */ p(n, {
1636
+ name: "checkthebox",
1637
+ size: 12,
1638
+ color: "#fff"
1639
+ }) : null
1640
+ }),
1641
+ o("editor.linkNewBlank")
1642
+ ]
1643
+ })
1644
+ ]
1645
+ });
1646
+ }, xr = /^https?:\/\/.+/i, Sr = ({ open: t, onClose: n, onConfirm: r }) => {
1647
+ let { t: i } = e(), [o, c] = d(""), [l, u] = d(null), f = a((e) => {
1648
+ e?.focus();
1649
+ }, []);
1650
+ return s(() => {
1651
+ t && (c(""), u(null));
1652
+ }, [t]), /* @__PURE__ */ p(yr, {
1653
+ open: t,
1654
+ title: i("editor.imageUrl"),
1655
+ onClose: n,
1656
+ onConfirm: () => {
1657
+ let e = o.trim();
1658
+ if (!e) {
1659
+ u(i("editor.imageUrlRequired"));
1660
+ return;
1661
+ }
1662
+ if (!xr.test(e)) {
1663
+ u(i("editor.imageUrlInvalid"));
1664
+ return;
1665
+ }
1666
+ r(e);
1667
+ },
1668
+ children: /* @__PURE__ */ m("label", {
1669
+ className: V["bsy-mobile-editor__sheet-field"],
1670
+ children: [
1671
+ /* @__PURE__ */ p("span", {
1672
+ className: V["bsy-mobile-editor__sheet-label"],
1673
+ children: i("editor.enterImageUrl")
1674
+ }),
1675
+ /* @__PURE__ */ p("span", {
1676
+ className: V["bsy-mobile-editor__sheet-note"],
1677
+ children: i("editor.imageUrlNote")
1678
+ }),
1679
+ /* @__PURE__ */ p("input", {
1680
+ ref: f,
1681
+ value: o,
1682
+ placeholder: i("editor.imageUrlPlaceholder"),
1683
+ "aria-invalid": !!l,
1684
+ onChange: (e) => {
1685
+ c(e.target.value), l && u(null);
1686
+ }
1687
+ }),
1688
+ l ? /* @__PURE__ */ p("span", {
1689
+ className: V["bsy-mobile-editor__sheet-error"],
1690
+ children: l
1691
+ }) : null
1692
+ ]
1693
+ })
1694
+ });
1695
+ }, Cr = "\n:host {\n all: initial;\n display: block;\n width: 100%;\n max-width: 100%;\n min-width: 0;\n}\n.bsy-editor-html-preview__body {\n color: #030303;\n font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;\n font-size: 15px;\n line-height: 1.6;\n word-break: break-word;\n}\n.bsy-editor-html-preview__body p {\n margin: 0;\n}\n.bsy-editor-html-preview__body .editor-text-bold {\n font-weight: 700;\n}\n.bsy-editor-html-preview__body .editor-text-italic {\n font-style: italic;\n}\n.bsy-editor-html-preview__body .editor-text-underline {\n text-decoration: underline;\n}\n.bsy-editor-html-preview__body .editor-text-strikethrough {\n text-decoration: line-through;\n}\n.bsy-editor-html-preview__body .editor-text-underline-strikethrough {\n text-decoration: underline line-through;\n}\n.bsy-editor-html-preview__body sup,\n.bsy-editor-html-preview__body sub {\n display: inline-block;\n position: static;\n top: auto;\n bottom: auto;\n font-size: 0.75em;\n line-height: 1;\n}\n.bsy-editor-html-preview__body sup {\n vertical-align: super;\n}\n.bsy-editor-html-preview__body sub {\n vertical-align: sub;\n}\n.bsy-editor-html-preview__body .editor-heading-h1,\n.bsy-editor-html-preview__body .editor-heading-h2,\n.bsy-editor-html-preview__body .editor-heading-h3 {\n margin: 0.6em 0 0.4em;\n font-weight: 600;\n line-height: 1.35;\n}\n.bsy-editor-html-preview__body .editor-heading-h1 {\n font-size: 2em;\n}\n.bsy-editor-html-preview__body .editor-heading-h2 {\n font-size: 1.5em;\n}\n.bsy-editor-html-preview__body .editor-heading-h3 {\n font-size: 1.25em;\n}\n.bsy-editor-html-preview__body .editor-list-ul,\n.bsy-editor-html-preview__body .editor-list-ol {\n margin: 0;\n padding-inline-start: 24px;\n list-style-position: outside;\n}\n.bsy-editor-html-preview__body .editor-list-ul {\n list-style-type: disc;\n}\n.bsy-editor-html-preview__body .editor-list-ol {\n list-style-type: decimal;\n}\n.bsy-editor-html-preview__body .editor-listitem {\n margin: 0;\n list-style: inherit;\n}\n.bsy-editor-html-preview__body .editor-nested-listitem {\n list-style-type: none;\n}\n.bsy-editor-html-preview__body .editor-list-ul .editor-list-ul {\n list-style-type: circle;\n}\n.bsy-editor-html-preview__body .editor-list-ul .editor-list-ul .editor-list-ul {\n list-style-type: square;\n}\n.bsy-editor-html-preview__body .editor-link,\n.bsy-editor-html-preview__body .editor-link:link,\n.bsy-editor-html-preview__body .editor-link:visited,\n.bsy-editor-html-preview__body .editor-link:hover,\n.bsy-editor-html-preview__body .editor-link:active,\n.bsy-editor-html-preview__body .editor-link:focus {\n color: #0269ff;\n cursor: pointer;\n}\n.bsy-editor-html-preview__body .editor-link * {\n color: #0269ff !important;\n}\n.bsy-editor-html-preview__body pre {\n display: block;\n box-sizing: border-box;\n max-width: 100%;\n margin: 8px 0;\n padding: 8px 12px;\n overflow-x: auto;\n border-radius: 4px;\n background: rgb(240, 242, 245);\n color: #1f2328;\n font-family: Menlo, Consolas, Monaco, monospace;\n font-size: 13px;\n line-height: 1.53;\n tab-size: 2;\n white-space: pre;\n}\n.bsy-editor-html-preview__body .editor-table-scrollable-wrapper {\n max-width: 100%;\n margin: 8px 0;\n overflow-x: auto;\n -webkit-overflow-scrolling: touch;\n}\n.bsy-editor-html-preview__body table {\n width: max-content;\n min-width: 100%;\n margin: 0;\n border-collapse: collapse;\n table-layout: fixed;\n}\n.bsy-editor-html-preview__body td,\n.bsy-editor-html-preview__body th {\n box-sizing: border-box;\n min-width: 75px;\n min-height: 32px;\n padding: 4px 8px;\n border: 1px solid #d9d9d9;\n vertical-align: top;\n}\n.bsy-editor-html-preview__body th {\n background: #f2f3f5;\n font-weight: 600;\n}\n.bsy-editor-html-preview__body img {\n max-width: 100%;\n height: auto;\n vertical-align: baseline;\n}\n", wr = ({ html: e }) => {
1696
+ let t = u(null);
1697
+ return l(() => {
1698
+ let n = t.current;
1699
+ if (!n) return;
1700
+ let r = n.shadowRoot ?? n.attachShadow({ mode: "open" }), i = document.createElement("div");
1701
+ i.className = "bsy-editor-html-preview__body", i.innerHTML = U(e);
1702
+ for (let e of Array.from(i.querySelectorAll("table"))) {
1703
+ if (e.parentElement?.classList.contains("editor-table-scrollable-wrapper")) continue;
1704
+ let t = document.createElement("div");
1705
+ t.className = "editor-table-scrollable-wrapper", e.replaceWith(t), t.append(e);
1706
+ }
1707
+ r.replaceChildren();
1708
+ let a = document.createElement("style");
1709
+ a.textContent = Cr, r.append(a, i);
1710
+ }, [e]), /* @__PURE__ */ p("div", {
1711
+ ref: t,
1712
+ className: "bsy-editor-html-preview"
1713
+ });
1714
+ }, Tr = () => {
1715
+ let e = `${c().replace(/:/g, "")}g`;
1716
+ return /* @__PURE__ */ p("span", {
1717
+ className: V["bsy-mobile-editor__ai-think-icon"],
1718
+ "aria-hidden": "true",
1719
+ children: /* @__PURE__ */ m("svg", {
1720
+ xmlns: "http://www.w3.org/2000/svg",
1721
+ width: "16",
1722
+ height: "16",
1723
+ viewBox: "0 0 16 16",
1724
+ fill: "none",
1725
+ children: [/* @__PURE__ */ p("path", {
1726
+ d: "M6.33965 13.3C6.27366 13.4143 6.23082 13.5404 6.21357 13.6712C6.19633 13.802 6.20502 13.9349 6.23914 14.0624C6.30806 14.3198 6.47641 14.5392 6.70715 14.6725C6.93788 14.8058 7.21211 14.8419 7.46951 14.773C7.59696 14.7389 7.71644 14.68 7.82112 14.5997C7.92581 14.5194 8.01366 14.4193 8.07965 14.305C8.21292 14.0743 8.24907 13.8 8.18015 13.5426C8.11123 13.2852 7.94288 13.0658 7.71215 12.9325C7.48141 12.7992 7.20718 12.7631 6.94978 12.832C6.69239 12.9009 6.47292 13.0693 6.33965 13.3ZM8.97265 1C7.44126 0.999778 5.95165 1.4994 4.73011 2.42295C3.69009 3.20927 2.89277 4.26631 2.4213 5.47246C2.33326 5.69768 2.00678 5.72579 1.89765 5.51L1.80165 5.356C1.64959 5.15708 1.42869 5.02215 1.18228 4.97769C0.935881 4.93323 0.681756 4.98244 0.469763 5.11567C0.25777 5.24891 0.103209 5.45654 0.0364008 5.69785C-0.0304072 5.93915 -0.00464041 6.19671 0.108646 6.42L1.34765 8.852L1.45565 9.032C1.86065 9.598 2.61765 9.782 3.23665 9.467L5.62665 8.25L5.78165 8.153C5.98057 8.00094 6.11549 7.78004 6.15995 7.53364C6.20442 7.28723 6.1552 7.03311 6.02197 6.82112C5.88874 6.60912 5.68111 6.45456 5.4398 6.38775C5.19849 6.32095 4.94093 6.34671 4.71765 6.46C4.48237 6.579 4.22662 6.36717 4.32655 6.12317C4.56067 5.55153 4.899 5.02613 5.32623 4.57461C5.90933 3.95836 6.63902 3.49984 7.44723 3.24183C8.25544 2.98382 9.11583 2.93472 9.94815 3.09912C10.7805 3.26352 11.5576 3.63606 12.207 4.18198C12.8564 4.7279 13.357 5.42942 13.662 6.22109C13.967 7.01276 14.0665 7.86879 13.9512 8.70932C13.836 9.54985 13.5097 10.3475 13.0028 11.0278C12.496 11.7082 11.8251 12.249 11.0526 12.6C10.9326 12.654 10.7796 12.71 10.5976 12.766C10.3241 12.8507 10.0934 13.0371 9.95295 13.2867C9.81252 13.5363 9.77305 13.8302 9.84265 14.108C9.90673 14.3421 10.0611 14.5412 10.2718 14.6615C10.4826 14.7819 10.7325 14.8137 10.9666 14.75C11.2736 14.666 11.5226 14.584 11.7136 14.503C13.2066 13.8705 14.435 12.7413 15.1908 11.3067C15.9466 9.87221 16.1832 8.22052 15.8607 6.63149C15.5381 5.04246 14.6762 3.61377 13.4209 2.58747C12.1656 1.56117 10.5941 1.00034 8.97265 1ZM4.16665 10.876C3.90024 10.876 3.64474 10.9818 3.45636 11.1702C3.26798 11.3586 3.16215 11.6141 3.16215 11.8805C3.16215 12.1469 3.26798 12.4024 3.45636 12.5908C3.64474 12.7792 3.90024 12.885 4.16665 12.885C4.43306 12.885 4.68855 12.7792 4.87694 12.5908C5.06532 12.4024 5.17115 12.1469 5.17115 11.8805C5.17115 11.6141 5.06532 11.3586 4.87694 11.1702C4.68855 10.9818 4.43306 10.876 4.16665 10.876Z",
1727
+ fill: `url(#${e})`
1728
+ }), /* @__PURE__ */ p("defs", { children: /* @__PURE__ */ m("linearGradient", {
1729
+ id: e,
1730
+ x1: "8.00059",
1731
+ y1: "1",
1732
+ x2: "8.00059",
1733
+ y2: "14.8072",
1734
+ gradientUnits: "userSpaceOnUse",
1735
+ children: [
1736
+ /* @__PURE__ */ p("stop", { stopColor: "#0265FF" }),
1737
+ /* @__PURE__ */ p("stop", {
1738
+ offset: "1",
1739
+ stopColor: "#A6FFFF"
1740
+ }),
1741
+ /* @__PURE__ */ p("animateTransform", {
1742
+ attributeName: "gradientTransform",
1743
+ type: "rotate",
1744
+ from: "0 8 8",
1745
+ to: "360 8 8",
1746
+ dur: "1.8s",
1747
+ repeatCount: "indefinite"
1748
+ })
1749
+ ]
1750
+ }) })]
1751
+ })
1752
+ });
1753
+ }, Er = (t, n, r) => {
1754
+ let { t: i } = e(), o = t.status === "loading" && !n, [c, l] = d(!0), [f, p] = d(0), m = u(Date.now()), g = u(null), _ = u(!1), v = u(!1), y = t.reasoning ?? "", b = a(() => r.current ?? void 0, [r]);
1755
+ return s(() => {
1756
+ if (!o) {
1757
+ g.current === null && (g.current = Math.max(1, Math.round((Date.now() - m.current) / 1e3)), p(g.current)), l(!1);
1758
+ return;
1759
+ }
1760
+ m.current = Date.now(), g.current = null, l(!0), _.current = !1, v.current = !1;
1761
+ let e = window.setInterval(() => {
1762
+ p(Math.max(1, Math.round((Date.now() - m.current) / 1e3)));
1763
+ }, 500);
1764
+ return () => window.clearInterval(e);
1765
+ }, [o]), h("pointerdown", () => {
1766
+ v.current = !0;
1767
+ }, {
1768
+ target: b,
1769
+ passive: !0,
1770
+ enable: o
1771
+ }), h("scroll", () => {
1772
+ let e = r.current;
1773
+ !e || !v.current || (v.current = !1, e.scrollHeight - e.scrollTop - e.clientHeight > 8 && (_.current = !0));
1774
+ }, {
1775
+ target: b,
1776
+ passive: !0,
1777
+ enable: o
1778
+ }), s(() => {
1779
+ if (!o || _.current || !r.current) return;
1780
+ let e = window.requestAnimationFrame(() => {
1781
+ if (_.current) return;
1782
+ let e = r.current;
1783
+ e && e.scrollHeight - e.scrollTop - e.clientHeight > 1 && (e.scrollTop = e.scrollHeight);
1784
+ });
1785
+ return () => window.cancelAnimationFrame(e);
1786
+ }, [
1787
+ y,
1788
+ r,
1789
+ o
1790
+ ]), {
1791
+ visible: (o || !!y) && !(t.status === "error" && !y),
1792
+ thinking: o,
1793
+ open: o || c,
1794
+ label: o ? i("editor.aiThinking") : i("editor.aiThoughtSeconds", { seconds: f }),
1795
+ reasoning: y,
1796
+ toggle: () => l((e) => !e)
1797
+ };
1798
+ }, Dr = ({ model: e }) => /* @__PURE__ */ m("button", {
1799
+ type: "button",
1800
+ className: V["bsy-mobile-editor__ai-think-head"],
1801
+ disabled: e.thinking,
1802
+ onClick: e.toggle,
1803
+ children: [e.thinking ? /* @__PURE__ */ p(Tr, {}) : /* @__PURE__ */ p(n, {
1804
+ name: "arrow-down",
1805
+ size: 12,
1806
+ className: [V["bsy-mobile-editor__ai-think-arrow"], e.open ? V["bsy-mobile-editor__ai-think-arrow--open"] : ""].filter(Boolean).join(" ")
1807
+ }), /* @__PURE__ */ p("span", {
1808
+ className: e.thinking ? `${V["bsy-mobile-editor__ai-think-label"]} ${V["bsy-mobile-editor__ai-think-label--shimmer"]}` : V["bsy-mobile-editor__ai-think-label"],
1809
+ children: e.label
1810
+ })]
1811
+ }), Or = ({ model: e }) => !e.visible || !e.open || !e.reasoning ? null : /* @__PURE__ */ p("div", {
1812
+ className: V["bsy-mobile-editor__ai-think-body"],
1813
+ children: e.reasoning
1814
+ }), kr = ({ open: i, mode: a, originalHtml: o, ai: s, polishPreset: c, onClose: l, onApply: h, onPickPreset: g }) => {
1815
+ let { t: _ } = e(), v = u(null), [y, b] = d(!1), x = s?.status ?? "idle", S = s?.text ?? "", C = a === "polish" ? U(dn(o, S)) : kn(S).html, w = !!C.trim(), T = Er({
1816
+ status: x,
1817
+ reasoning: s?.reasoning
1818
+ }, w, v), E = x === "ready" && w;
1819
+ return /* @__PURE__ */ m(t, {
1820
+ open: i,
1821
+ onClose: l,
1822
+ position: "bottom",
1823
+ closeOnClickOverlay: !1,
1824
+ children: [/* @__PURE__ */ m("div", {
1825
+ className: V["bsy-mobile-editor__ai"],
1826
+ style: { height: gt },
1827
+ children: [
1828
+ /* @__PURE__ */ m("div", {
1829
+ className: V["bsy-mobile-editor__header"],
1830
+ children: [/* @__PURE__ */ p("div", {
1831
+ className: V["bsy-mobile-editor__title"],
1832
+ children: _(a === "polish" ? "editor.aiPolish" : "editor.aiTypeset")
1833
+ }), /* @__PURE__ */ p("button", {
1834
+ type: "button",
1835
+ className: V["bsy-mobile-editor__close"],
1836
+ "aria-label": _("popup.close"),
1837
+ onClick: l,
1838
+ children: /* @__PURE__ */ p(n, {
1839
+ name: "close",
1840
+ size: 18
1841
+ })
1842
+ })]
1843
+ }),
1844
+ /* @__PURE__ */ m("div", {
1845
+ className: V["bsy-mobile-editor__ai-body"],
1846
+ children: [
1847
+ /* @__PURE__ */ m("section", {
1848
+ className: V["bsy-mobile-editor__ai-section"],
1849
+ children: [
1850
+ /* @__PURE__ */ m("div", {
1851
+ className: V["bsy-mobile-editor__ai-section-head"],
1852
+ children: [/* @__PURE__ */ m("div", {
1853
+ className: `${V["bsy-mobile-editor__ai-label"]} ${V["bsy-mobile-editor__ai-label--after"]}`,
1854
+ children: [/* @__PURE__ */ p("span", { className: V["bsy-mobile-editor__ai-dot"] }), _("editor.aiOptimized")]
1855
+ }), a === "polish" ? /* @__PURE__ */ m("button", {
1856
+ type: "button",
1857
+ className: V["bsy-mobile-editor__ai-preset"],
1858
+ onClick: () => b(!0),
1859
+ children: [_(ft[c]), /* @__PURE__ */ p(n, {
1860
+ name: "arrow-down",
1861
+ size: 16
1862
+ })]
1863
+ }) : null]
1864
+ }),
1865
+ T.visible ? /* @__PURE__ */ p("div", {
1866
+ className: V["bsy-mobile-editor__ai-think-pin"],
1867
+ children: /* @__PURE__ */ p(Dr, { model: T })
1868
+ }) : null,
1869
+ /* @__PURE__ */ p("div", {
1870
+ ref: v,
1871
+ className: V["bsy-mobile-editor__ai-section-scroll"],
1872
+ children: x === "error" ? /* @__PURE__ */ p("p", {
1873
+ className: V["bsy-mobile-editor__ai-error"],
1874
+ children: s?.errorMessage || _("editor.aiError")
1875
+ }) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(Or, { model: T }), w ? /* @__PURE__ */ p(wr, { html: C }) : null] })
1876
+ })
1877
+ ]
1878
+ }),
1879
+ /* @__PURE__ */ p("div", { className: V["bsy-mobile-editor__ai-split"] }),
1880
+ /* @__PURE__ */ m("section", {
1881
+ className: V["bsy-mobile-editor__ai-section"],
1882
+ children: [/* @__PURE__ */ p("div", {
1883
+ className: V["bsy-mobile-editor__ai-section-head"],
1884
+ children: /* @__PURE__ */ m("div", {
1885
+ className: `${V["bsy-mobile-editor__ai-label"]} ${V["bsy-mobile-editor__ai-label--before"]}`,
1886
+ children: [/* @__PURE__ */ p("span", { className: V["bsy-mobile-editor__ai-dot"] }), _("editor.aiOriginal")]
1887
+ })
1888
+ }), /* @__PURE__ */ p("div", {
1889
+ className: V["bsy-mobile-editor__ai-section-scroll"],
1890
+ children: /* @__PURE__ */ p(wr, { html: o })
1891
+ })]
1892
+ })
1893
+ ]
1894
+ }),
1895
+ /* @__PURE__ */ m("div", {
1896
+ className: V["bsy-mobile-editor__ai-footer"],
1897
+ children: [/* @__PURE__ */ p("button", {
1898
+ type: "button",
1899
+ onClick: l,
1900
+ children: _("editor.aiAbandon")
1901
+ }), /* @__PURE__ */ p("button", {
1902
+ type: "button",
1903
+ className: V["bsy-mobile-editor__ai-footer-ok"],
1904
+ disabled: !E,
1905
+ onClick: h,
1906
+ children: _("editor.aiApply")
1907
+ })]
1908
+ })
1909
+ ]
1910
+ }), a === "polish" ? /* @__PURE__ */ p(r, {
1911
+ mode: "menu",
1912
+ open: y,
1913
+ title: _("editor.aiPolish"),
1914
+ onClose: () => b(!1),
1915
+ actions: dt.map((e) => ({
1916
+ key: e,
1917
+ text: _(ft[e])
1918
+ })),
1919
+ onAction: (e) => g(e.key)
1920
+ }) : null]
1921
+ });
1922
+ }, Ar = "M896 860.48V960H128v-99.52h768zM578.944 128l251.648 655.936h-115.2l-59.904-164.48H379.904L320 784H204.8L456.384 128h122.56z m-58.944 115.776h-3.712L412.16 531.2h211.072L520 243.84z", jr = "M766.4 744.32c43.712 0 79.36-36.224 79.36-80.512 0-53.504-79.36-140.8-79.36-140.8s-79.36 87.296-79.36 140.8c0 44.288 35.648 80.512 79.36 80.512z m-377.088-44.16c7.04 7.168 18.56 7.168 25.6 0l256.064-256c7.104-7.04 7.104-18.56 0-25.6l-256-256a16.32 16.32 0 0 0-1.92-1.664L334.72 82.688a9.088 9.088 0 0 0-12.8 0l-48 48a9.088 9.088 0 0 0 0 12.8l67.2 67.2-207.808 207.936c-7.04 7.04-7.04 18.56 0 25.6l255.936 256z m12.864-448.576L581.12 430.528H223.36L402.24 251.52z m501.824 564.416H120a8 8 0 0 0-8 8v80c0 4.416 3.584 8 8 8h784a8 8 0 0 0 8-8v-80a8 8 0 0 0-8-8z", Mr = 860.48, Nr = 99.52, Pr = /rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0(?:\.0+)?\s*\)/, Fr = {
1923
+ fontColor: {
1924
+ path: Ar,
1925
+ clipHeight: Mr,
1926
+ x: 128,
1927
+ width: 768,
1928
+ rx: 0
1929
+ },
1930
+ fill: {
1931
+ path: jr,
1932
+ clipHeight: 816,
1933
+ x: 112,
1934
+ width: 800,
1935
+ rx: 8
1936
+ }
1937
+ }, Ir = (e, t) => {
1938
+ let n = t.trim().toLowerCase();
1939
+ if (e === "fill") return !n || n === "transparent" || Pr.test(n);
1940
+ let r = n.replace(/\s+/g, "");
1941
+ return r === "#000" || r === "#000000" || r === "black" || r === "rgb(0,0,0)" || r === "rgba(0,0,0,1)" || r === "rgba(0,0,0,1.0)";
1942
+ }, Lr = ({ variant: e, barColor: t, size: n }) => {
1943
+ let r = `${c().replace(/:/g, "")}clip`, i = Fr[e];
1944
+ return /* @__PURE__ */ m("svg", {
1945
+ width: n,
1946
+ height: n,
1947
+ viewBox: "0 0 1024 1024",
1948
+ "aria-hidden": "true",
1949
+ children: [
1950
+ /* @__PURE__ */ p("defs", { children: /* @__PURE__ */ p("clipPath", {
1951
+ id: r,
1952
+ children: /* @__PURE__ */ p("rect", {
1953
+ x: 0,
1954
+ y: 0,
1955
+ width: 1024,
1956
+ height: i.clipHeight
1957
+ })
1958
+ }) }),
1959
+ /* @__PURE__ */ p("path", {
1960
+ d: i.path,
1961
+ fill: "currentColor",
1962
+ clipPath: `url(#${r})`
1963
+ }),
1964
+ /* @__PURE__ */ p("rect", {
1965
+ x: i.x,
1966
+ y: Mr,
1967
+ width: i.width,
1968
+ height: Nr,
1969
+ rx: i.rx,
1970
+ fill: Ir(e, t) ? "currentColor" : t
1971
+ })
1972
+ ]
1973
+ });
1974
+ }, Rr = {
1975
+ bold: !1,
1976
+ italic: !1,
1977
+ underline: !1,
1978
+ strikethrough: !1,
1979
+ fontColor: ct,
1980
+ backgroundColor: lt,
1981
+ align: "left",
1982
+ listType: !1,
1983
+ canOutdent: !1,
1984
+ headingTag: !1,
1985
+ hasRangeSelection: !1,
1986
+ hasEditorText: !1
1987
+ }, zr = (e) => e === "center" || e === "right" || e === "left" ? e : e === "end" ? "right" : "left", Br = (e) => {
1988
+ let t = !!F().getTextContent().trim(), n = {
1989
+ ...Rr,
1990
+ hasEditorText: t
1991
+ };
1992
+ if (!e) return n;
1993
+ let r = I();
1994
+ if (!L(r)) return n;
1995
+ let i = it(r, "color", ct), a = it(r, "background-color", lt), o = r.anchor.getNode(), s = o.getKey() === "root" ? o : B(o, (e) => {
1996
+ let t = e.getParent();
1997
+ return t !== null && we(t);
1998
+ });
1999
+ s === null && (s = o.getTopLevelElementOrThrow());
2000
+ let c = B(o, S), l = !1, u = Se(s) ? s.getIndent() : 0;
2001
+ if (S(c)) {
2002
+ u = c.getIndent();
2003
+ let e = c.getParent();
2004
+ if (C(e)) {
2005
+ let t = e.getListType();
2006
+ l = t === "number" || t === "bullet" ? t : !1;
2007
+ }
2008
+ }
2009
+ let d = B(o, ie), f = ie(d) ? d.getTag() : void 0;
2010
+ return {
2011
+ bold: r.hasFormat("bold"),
2012
+ italic: r.hasFormat("italic"),
2013
+ underline: r.hasFormat("underline"),
2014
+ strikethrough: r.hasFormat("strikethrough"),
2015
+ fontColor: i,
2016
+ backgroundColor: a,
2017
+ align: zr(Se(s) ? s.getFormatType() : ""),
2018
+ listType: l,
2019
+ canOutdent: u > 0 || l !== !1,
2020
+ headingTag: f === "h1" || f === "h2" || f === "h3" ? f : !1,
2021
+ hasRangeSelection: !0,
2022
+ hasEditorText: t
2023
+ };
2024
+ }, Vr = (e, t) => {
2025
+ e.isEditable() || e.setEditable(!0), e.update(() => {
2026
+ xt(), t(Br(!0));
2027
+ }), e.focus(void 0, { defaultSelection: "rootStart" });
2028
+ }, Hr = (e) => {
2029
+ let t = Rr;
2030
+ return Vr(e, (e) => {
2031
+ t = e;
2032
+ }), t;
2033
+ }, Ur = (...e) => e.filter(Boolean).join(" "), Wr = (e) => e.buttons.map((e) => ({
2034
+ name: typeof e == "string" ? e : e.name,
2035
+ disabled: typeof e != "string" && !!e.props?.disabled
2036
+ })), Q = 24, Gr = 20, $ = ({ active: e, disabled: t, expanded: n, label: r, select: i, selectAlign: a, onClick: o, children: s }) => /* @__PURE__ */ p("button", {
2037
+ type: "button",
2038
+ className: Ur(V["bsy-mobile-editor__tool"], i && V["bsy-mobile-editor__tool--select"], a && V["bsy-mobile-editor__tool--select-align"], e && V["bsy-mobile-editor__tool--active"]),
2039
+ "aria-label": r,
2040
+ "aria-pressed": e,
2041
+ "aria-expanded": i ? !!n : void 0,
2042
+ disabled: t,
2043
+ onMouseDown: (e) => e.preventDefault(),
2044
+ onClick: o,
2045
+ children: s
2046
+ }), Kr = ({ open: e }) => /* @__PURE__ */ p(n, {
2047
+ name: "arrow-down",
2048
+ size: Gr,
2049
+ className: Ur(V["bsy-mobile-editor__tool-caret"], e && V["bsy-mobile-editor__tool-caret--open"])
2050
+ }), qr = ({ config: t, formats: r, colorValues: i, openSheet: a, onOpenSheet: o, onOpenLink: c }) => {
2051
+ let [l] = z(), { t: d } = e(), f = u(null), h = u(null), g = u(null), _ = () => {
2052
+ let e = f.current, t = h.current, n = g.current;
2053
+ if (!e || !t || !n) return;
2054
+ let { scrollLeft: r, scrollWidth: i, clientWidth: a } = e, o = i > a + 1, s = o ? Math.max(16, a / i * 80) : 46, c = i - a, l = o && c > 0 ? (80 - s) * (r / c) : 0;
2055
+ t.hidden = !o, o && (n.style.width = `${s}px`, n.style.transform = `translateX(${l}px)`);
2056
+ };
2057
+ s(() => {
2058
+ let e = f.current;
2059
+ if (!e) return;
2060
+ _();
2061
+ let t = new ResizeObserver(_);
2062
+ return t.observe(e), () => t.disconnect();
2063
+ }, [t]);
2064
+ let v = ({ name: e, disabled: t }) => {
2065
+ switch (e) {
2066
+ case "bold": return /* @__PURE__ */ p($, {
2067
+ active: r.bold,
2068
+ disabled: t,
2069
+ label: d("editor.bold"),
2070
+ onClick: () => {
2071
+ H(l), l.dispatchCommand(Ie, "bold");
2072
+ },
2073
+ children: /* @__PURE__ */ p(n, {
2074
+ name: "bold",
2075
+ size: Q
2076
+ })
2077
+ }, e);
2078
+ case "italic": return /* @__PURE__ */ p($, {
2079
+ active: r.italic,
2080
+ disabled: t,
2081
+ label: d("editor.italic"),
2082
+ onClick: () => {
2083
+ H(l), l.dispatchCommand(Ie, "italic");
2084
+ },
2085
+ children: /* @__PURE__ */ p(n, {
2086
+ name: "italic",
2087
+ size: Q
2088
+ })
2089
+ }, e);
2090
+ case "underline": return /* @__PURE__ */ p($, {
2091
+ active: r.underline,
2092
+ disabled: t,
2093
+ label: d("editor.underline"),
2094
+ onClick: () => {
2095
+ H(l), l.dispatchCommand(Ie, "underline");
2096
+ },
2097
+ children: /* @__PURE__ */ p(n, {
2098
+ name: "underline",
2099
+ size: Q
2100
+ })
2101
+ }, e);
2102
+ case "strikethrough": return /* @__PURE__ */ p($, {
2103
+ active: r.strikethrough,
2104
+ disabled: t,
2105
+ label: d("editor.strikethrough"),
2106
+ onClick: () => {
2107
+ H(l), l.dispatchCommand(Ie, "strikethrough");
2108
+ },
2109
+ children: /* @__PURE__ */ p(n, {
2110
+ name: "shanchuxian",
2111
+ size: Q
2112
+ })
2113
+ }, e);
2114
+ case "outdent": return /* @__PURE__ */ p($, {
2115
+ disabled: t || r.hasRangeSelection && !r.canOutdent,
2116
+ label: d("editor.outdent"),
2117
+ onClick: () => {
2118
+ H(l), l.dispatchCommand(Ve, void 0);
2119
+ },
2120
+ children: /* @__PURE__ */ p(n, {
2121
+ name: "jianshaosuojin",
2122
+ size: Q
2123
+ })
2124
+ }, e);
2125
+ case "indent": return /* @__PURE__ */ p($, {
2126
+ disabled: t,
2127
+ label: d("editor.indent"),
2128
+ onClick: () => {
2129
+ H(l), l.dispatchCommand(Re, void 0);
2130
+ },
2131
+ children: /* @__PURE__ */ p(n, {
2132
+ name: "zengjiasuojin",
2133
+ size: Q
2134
+ })
2135
+ }, e);
2136
+ case "bullet": return /* @__PURE__ */ p($, {
2137
+ active: r.listType === "bullet",
2138
+ disabled: t,
2139
+ label: d("editor.bulletList"),
2140
+ onClick: () => {
2141
+ let e = Hr(l);
2142
+ l.dispatchCommand(e.listType === "bullet" ? O : T, void 0);
2143
+ },
2144
+ children: /* @__PURE__ */ p(n, {
2145
+ name: "xuhaoliebiao",
2146
+ size: Q
2147
+ })
2148
+ }, e);
2149
+ case "number": return /* @__PURE__ */ p($, {
2150
+ active: r.listType === "number",
2151
+ disabled: t,
2152
+ label: d("editor.numberList"),
2153
+ onClick: () => {
2154
+ let e = Hr(l);
2155
+ l.dispatchCommand(e.listType === "number" ? O : w, void 0);
2156
+ },
2157
+ children: /* @__PURE__ */ p(n, {
2158
+ name: "bianhaoliebiao",
2159
+ size: Q
2160
+ })
2161
+ }, e);
2162
+ case "align": return /* @__PURE__ */ m($, {
2163
+ select: !0,
2164
+ selectAlign: !0,
2165
+ expanded: a === "align",
2166
+ active: a === "align",
2167
+ disabled: t,
2168
+ label: d("editor.alignment"),
2169
+ onClick: () => o("align"),
2170
+ children: [/* @__PURE__ */ p(n, {
2171
+ name: r.align === "center" ? "paragraphmiddle" : r.align === "right" ? "paragraphright" : "paragraph",
2172
+ size: Q
2173
+ }), /* @__PURE__ */ p(Kr, { open: a === "align" })]
2174
+ }, e);
2175
+ case "heading": return /* @__PURE__ */ m($, {
2176
+ select: !0,
2177
+ selectAlign: !0,
2178
+ expanded: a === "heading",
2179
+ active: a === "heading",
2180
+ disabled: t,
2181
+ label: d("editor.heading"),
2182
+ onClick: () => o("heading"),
2183
+ children: [/* @__PURE__ */ p("span", {
2184
+ className: V["bsy-mobile-editor__tool-text"],
2185
+ children: r.headingTag ? r.headingTag.toUpperCase() : d("editor.paragraph")
2186
+ }), /* @__PURE__ */ p(Kr, { open: a === "heading" })]
2187
+ }, e);
2188
+ case "fontSize": return /* @__PURE__ */ p($, {
2189
+ active: a === "fontSize",
2190
+ disabled: t || !!r.headingTag,
2191
+ label: d("editor.fontSize"),
2192
+ onClick: () => o("fontSize"),
2193
+ children: /* @__PURE__ */ p(n, {
2194
+ name: "fontsize",
2195
+ size: Q
2196
+ })
2197
+ }, e);
2198
+ case "fontColor": return /* @__PURE__ */ p($, {
2199
+ active: a === "fontColor",
2200
+ disabled: t,
2201
+ label: d("editor.fontColor"),
2202
+ onClick: () => o("fontColor"),
2203
+ children: /* @__PURE__ */ p(Lr, {
2204
+ variant: "fontColor",
2205
+ barColor: i.fontColor,
2206
+ size: Q
2207
+ })
2208
+ }, e);
2209
+ case "fill": return /* @__PURE__ */ p($, {
2210
+ active: a === "fill",
2211
+ disabled: t,
2212
+ label: d("editor.fill"),
2213
+ onClick: () => o("fill"),
2214
+ children: /* @__PURE__ */ p(Lr, {
2215
+ variant: "fill",
2216
+ barColor: i.fill,
2217
+ size: Q
2218
+ })
2219
+ }, e);
2220
+ case "picture": return /* @__PURE__ */ m($, {
2221
+ select: !0,
2222
+ expanded: a === "picture",
2223
+ active: a === "picture",
2224
+ disabled: t,
2225
+ label: d("editor.picture"),
2226
+ onClick: () => o("picture"),
2227
+ children: [/* @__PURE__ */ p(n, {
2228
+ name: "picture",
2229
+ size: Q
2230
+ }), /* @__PURE__ */ p(Kr, { open: a === "picture" })]
2231
+ }, e);
2232
+ case "link": return /* @__PURE__ */ p($, {
2233
+ disabled: t,
2234
+ label: d("editor.link"),
2235
+ onClick: c,
2236
+ children: /* @__PURE__ */ p(n, {
2237
+ name: "Insertlink",
2238
+ size: Q
2239
+ })
2240
+ }, e);
2241
+ case "ai": {
2242
+ let n = a === "ai" || a === "aiPreset";
2243
+ return /* @__PURE__ */ m($, {
2244
+ select: !0,
2245
+ expanded: n,
2246
+ active: n,
2247
+ disabled: t || !r.hasEditorText,
2248
+ label: d("editor.ai"),
2249
+ onClick: () => o("ai"),
2250
+ children: [/* @__PURE__ */ p("img", {
2251
+ src: Qn,
2252
+ alt: "",
2253
+ width: Q,
2254
+ height: Q,
2255
+ className: V["bsy-mobile-editor__ai-icon"],
2256
+ draggable: !1
2257
+ }), /* @__PURE__ */ p(Kr, { open: n })]
2258
+ }, e);
2259
+ }
2260
+ default: return null;
2261
+ }
2262
+ };
2263
+ return /* @__PURE__ */ m("div", {
2264
+ className: V["bsy-mobile-editor__toolbar"],
2265
+ children: [/* @__PURE__ */ p("div", {
2266
+ ref: f,
2267
+ className: V["bsy-mobile-editor__toolbar-scroller"],
2268
+ onScroll: _,
2269
+ children: t.map((e, t) => {
2270
+ let n = Wr(e);
2271
+ return n.length ? /* @__PURE__ */ m("div", {
2272
+ className: V["bsy-mobile-editor__toolbar-group"],
2273
+ children: [t > 0 ? /* @__PURE__ */ p("span", { className: V["bsy-mobile-editor__toolbar-divider"] }) : null, n.map(v)]
2274
+ }, e.key) : null;
2275
+ })
2276
+ }), /* @__PURE__ */ p("div", {
2277
+ ref: h,
2278
+ className: V["bsy-mobile-editor__toolbar-track"],
2279
+ hidden: !0,
2280
+ "aria-hidden": !0,
2281
+ children: /* @__PURE__ */ p("div", {
2282
+ ref: g,
2283
+ className: V["bsy-mobile-editor__toolbar-thumb"]
2284
+ })
2285
+ })]
2286
+ });
2287
+ }, Jr = () => {
2288
+ let [e] = z(), [t, n] = d(!1);
2289
+ return s(() => rt(e.registerCommand(Pe, () => (n(!0), !1), je), e.registerCommand(ke, () => (n(!1), !1), je)), [e]), t;
2290
+ }, Yr = () => {
2291
+ let [e] = z(), t = Jr(), [n, r] = d(Rr);
2292
+ return s(() => (e.getEditorState().read(() => {
2293
+ r(Br(t));
2294
+ }, { editor: e }), e.registerUpdateListener(({ editorState: n }) => {
2295
+ n.read(() => {
2296
+ r(Br(t));
2297
+ }, { editor: e });
2298
+ })), [e, t]), n;
2299
+ }, Xr = "plaintext", Zr = "github-light", Qr = new Set([
2300
+ "plaintext",
2301
+ "css",
2302
+ "html",
2303
+ "xml",
2304
+ "javascript",
2305
+ "typescript",
2306
+ "jsx",
2307
+ "go",
2308
+ "php",
2309
+ "c",
2310
+ "python",
2311
+ "java",
2312
+ "cpp",
2313
+ "csharp",
2314
+ "vb",
2315
+ "sql",
2316
+ "ruby",
2317
+ "swift",
2318
+ "bash",
2319
+ "lua",
2320
+ "markdown"
2321
+ ]), $r = (e) => e && Qr.has(e) ? e : Xr, ei = {
2322
+ css: () => import("@shikijs/langs/css"),
2323
+ html: () => import("@shikijs/langs/html"),
2324
+ xml: () => import("@shikijs/langs/xml"),
2325
+ javascript: () => import("@shikijs/langs/javascript"),
2326
+ typescript: () => import("@shikijs/langs/typescript"),
2327
+ jsx: () => import("@shikijs/langs/jsx"),
2328
+ go: () => import("@shikijs/langs/go"),
2329
+ php: () => import("@shikijs/langs/php"),
2330
+ c: () => import("@shikijs/langs/c"),
2331
+ python: () => import("@shikijs/langs/python"),
2332
+ java: () => import("@shikijs/langs/java"),
2333
+ cpp: () => import("@shikijs/langs/cpp"),
2334
+ csharp: () => import("@shikijs/langs/csharp"),
2335
+ vb: () => import("@shikijs/langs/vb"),
2336
+ sql: () => import("@shikijs/langs/sql"),
2337
+ ruby: () => import("@shikijs/langs/ruby"),
2338
+ swift: () => import("@shikijs/langs/swift"),
2339
+ bash: () => import("@shikijs/langs/shellscript"),
2340
+ lua: () => import("@shikijs/langs/lua"),
2341
+ markdown: () => import("@shikijs/langs/markdown")
2342
+ }, ti = (e) => e === "bash" ? "shellscript" : e, ni = (e) => e in ei, ri = null, ii = null, ai = /* @__PURE__ */ new Map(), oi = () => (ri ||= Promise.all([import("@shikijs/core"), import("@shikijs/engine-javascript")]).then(([{ createHighlighterCoreSync: e }, { createJavaScriptRegexEngine: t }]) => e({
2343
+ engine: t(),
2344
+ langs: [],
2345
+ themes: []
2346
+ })).catch((e) => {
2347
+ throw ri = null, e;
2348
+ }), ri), si = (e, t) => ni(t) && e.getLoadedLanguages().includes(ti(t)), ci = (e) => {
2349
+ let t = ai.get(e);
2350
+ return t || (t = oi().then(async (t) => {
2351
+ let n = ti(e);
2352
+ if (!t.getLoadedLanguages().includes(n)) {
2353
+ let n = await ei[e]();
2354
+ await t.loadLanguage(n.default);
2355
+ }
2356
+ return t;
2357
+ }).catch((t) => {
2358
+ throw ai.delete(e), t;
2359
+ }), ai.set(e, t)), t;
2360
+ }, li = () => (ii ||= oi().then(async (e) => {
2361
+ if (!e.getLoadedThemes().includes("github-light")) {
2362
+ let t = await import("@shikijs/themes/github-light");
2363
+ await e.loadTheme(t.default);
2364
+ }
2365
+ return e;
2366
+ }).catch((e) => {
2367
+ throw ii = null, e;
2368
+ }), ii), ui = (e, t, n) => {
2369
+ let r = e.getTextContent();
2370
+ if (e.getStyle() && e.setStyle(""), !n || !si(n, t)) return ee(r);
2371
+ let i = n.codeToTokens(r, {
2372
+ lang: ti(t),
2373
+ theme: Zr
2374
+ }).tokens, a = [];
2375
+ return i.forEach((e, t) => {
2376
+ t && a.push(_e()), e.forEach((e) => {
2377
+ e.content.split(" ").forEach((t, n) => {
2378
+ if (n && a.push(ve()), !t) return;
2379
+ let r = k(t), i = typeof e.htmlStyle == "string" ? e.htmlStyle : e.htmlStyle ? Object.entries(e.htmlStyle).map(([e, t]) => `${e}:${t}`).join(";") : e.color ? `color: ${e.color}` : "";
2380
+ i && r.setStyle(i), a.push(r);
2381
+ });
2382
+ });
2383
+ }), a;
2384
+ }, di = (e, t) => {
2385
+ let n = be(e);
2386
+ if (!j(n) || !n.isAttached()) return;
2387
+ let r = I();
2388
+ if (!L(r)) {
2389
+ t();
2390
+ return;
2391
+ }
2392
+ let { anchor: i } = r;
2393
+ if (B(i.getNode(), j) !== n) {
2394
+ t();
2395
+ return;
2396
+ }
2397
+ let a = i.offset, o = i.type === "element" && Ce(n.getChildAtIndex(i.offset - 1)), s = 0;
2398
+ if (o || (s = a + i.getNode().getPreviousSiblings().reduce((e, t) => e + t.getTextContentSize(), 0)), t()) {
2399
+ if (o) {
2400
+ i.getNode().select(a, a);
2401
+ return;
2402
+ }
2403
+ n.getChildren().some((e) => {
2404
+ let t = Ee(e);
2405
+ if (t || Ce(e)) {
2406
+ let n = e.getTextContentSize();
2407
+ if (t && n >= s) return e.select(s, s), !0;
2408
+ s -= n;
2409
+ }
2410
+ return !1;
2411
+ });
2412
+ }
2413
+ }, fi = (e, t) => A(e) && A(t) && e.__text === t.__text && e.__highlightType === t.__highlightType && e.__style === t.__style || Te(e) && Te(t) || Ce(e) && Ce(t), pi = (e, t) => {
2414
+ let n = 0;
2415
+ for (; n < e.length && fi(e[n], t[n]);) n++;
2416
+ let r = 0, i = Math.min(e.length, t.length) - n;
2417
+ for (; r < i && fi(e[e.length - r - 1], t[t.length - r - 1]);) r++;
2418
+ return {
2419
+ from: n,
2420
+ to: e.length - r,
2421
+ replacement: t.slice(n, t.length - r)
2422
+ };
2423
+ }, mi = (e, t, n, r, i) => {
2424
+ let a = i.getKey(), o = $r(i.getLanguage());
2425
+ if (i.getLanguage() !== o && i.setLanguage(o), o === "plaintext") i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1);
2426
+ else {
2427
+ i.getTheme() !== "github-light" && i.setTheme(Zr);
2428
+ let s = t ? t.getLoadedThemes().includes("github-light") ? ni(o) && !si(t, o) ? ci(o) : null : li() : oi();
2429
+ if (s) {
2430
+ i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1), n.pendingKeys.add(a), n.loading !== s && (n.loading = s, s.then((t) => {
2431
+ r(t);
2432
+ let i = [...n.pendingKeys];
2433
+ n.pendingKeys.clear(), n.loading = null, e.update(() => i.forEach((e) => be(e)?.markDirty()), { tag: Le });
2434
+ }, () => {
2435
+ n.pendingKeys.clear(), n.loading = null;
2436
+ }));
2437
+ return;
2438
+ }
2439
+ i.getIsSyntaxHighlightSupported() || i.setIsSyntaxHighlightSupported(!0);
2440
+ }
2441
+ n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0, Oe(() => {
2442
+ n.didTransform = !1, n.nodesCurrentlyHighlighting.clear();
2443
+ })), di(a, () => {
2444
+ let e = be(a);
2445
+ if (!j(e) || !e.isAttached()) return !1;
2446
+ let n = ui(e, $r(e.getLanguage()), t), { from: r, to: i, replacement: o } = pi(e.getChildren(), n);
2447
+ return r === i && o.length === 0 ? !1 : (e.splice(r, i - r, o), !0);
2448
+ }));
2449
+ }, hi = () => {
2450
+ let [e] = z();
2451
+ return s(() => {
2452
+ if (!e.hasNodes([M, te])) throw Error("CodeHighlightPlugin: code nodes are not registered");
2453
+ let t = null, n = {
2454
+ didTransform: !1,
2455
+ nodesCurrentlyHighlighting: /* @__PURE__ */ new Set(),
2456
+ pendingKeys: /* @__PURE__ */ new Set(),
2457
+ loading: null
2458
+ }, r = (r) => mi(e, t, n, (e) => {
2459
+ t = e;
2460
+ }, r), i = (e) => {
2461
+ let t = e.getParent();
2462
+ j(t) ? r(t) : A(e) && e.replace(ye(e.__text));
2463
+ };
2464
+ return Ke(ne(e), e.registerNodeTransform(M, r), e.registerNodeTransform(We, i), e.registerNodeTransform(te, i));
2465
+ }, [e]), null;
2466
+ }, gi = () => {
2467
+ let [e] = z();
2468
+ return s(() => (he(e, !0), rt(pe(e), me(e, !1), fe(e), e.registerNodeTransform(le, (e) => {
2469
+ e.getBackgroundColor() !== null && e.setBackgroundColor(null);
2470
+ }), e.registerCommand(Be, (e) => {
2471
+ let t = I();
2472
+ if (!L(t) || !t.isCollapsed()) return !1;
2473
+ let n = oe(t.anchor.getNode());
2474
+ if (n === null) return !1;
2475
+ let r = e.shiftKey ? "previous" : "next", i = r === "next" ? "getNextSibling" : "getPreviousSibling", a = r === "next" ? "getFirstChild" : "getLastChild", o = n[i](), s = null;
2476
+ if (se(o)) s = o;
2477
+ else {
2478
+ let e = B(n, ce);
2479
+ if (e !== null) for (let t = e[i](); t !== null; t = t[i]()) {
2480
+ if (!ce(t)) continue;
2481
+ let e = t[a]();
2482
+ if (se(e)) {
2483
+ s = e;
2484
+ break;
2485
+ }
2486
+ }
2487
+ }
2488
+ if (e.preventDefault(), s) {
2489
+ let e = s.getFirstDescendant();
2490
+ e ? e.selectStart() : s.selectStart();
2491
+ } else {
2492
+ let e = B(n, N);
2493
+ e && (r === "next" ? e.selectNext() : e.selectPrevious());
2494
+ }
2495
+ return !0;
2496
+ }, Ae))), [e]), null;
2497
+ }, _i = ({ value: n, onChange: r, open: i, onOpenChange: a, toolbar: o, upload: c, ai: l }) => {
2498
+ let [f] = z(), { t: h } = e(), g = Yr(), [_, v] = d(!1), y = i ?? _, b = (e) => {
2499
+ a?.(e), i === void 0 && v(e);
2500
+ }, [x, S] = d(null), [C, w] = d(() => ({
2501
+ fontColor: g.fontColor,
2502
+ fill: g.backgroundColor
2503
+ })), T = u(!1), [E, D] = d(!1), O = u(null), k = () => {
2504
+ f.getEditorState().read(() => {
2505
+ O.current = I()?.clone() ?? null;
2506
+ });
2507
+ }, { linkForm: A, openLink: j, confirmLink: ee, closeLink: te } = Hn({
2508
+ editor: f,
2509
+ savedSelectionRef: O,
2510
+ captureSelection: k
2511
+ }), [M] = d(() => /* @__PURE__ */ new Map()), { fileInputRef: ne, uploadProgress: re, insertImage: ie, onFileChange: ae, abortUpload: oe } = Vn({
2512
+ editor: f,
2513
+ upload: c,
2514
+ savedSelectionRef: O,
2515
+ attachmentsBySrc: M
2516
+ }), se = Un({
2517
+ editor: f,
2518
+ value: n,
2519
+ onChange: r,
2520
+ attachmentsBySrc: M
2521
+ }), N = An({
2522
+ editor: f,
2523
+ ai: l
2524
+ }), [ce, le] = d(0), ue = o?.config ?? pt;
2525
+ s(() => {
2526
+ !g.hasRangeSelection || !g.hasEditorText || w({
2527
+ fontColor: g.fontColor,
2528
+ fill: g.backgroundColor
2529
+ });
2530
+ }, [
2531
+ g.backgroundColor,
2532
+ g.fontColor,
2533
+ g.hasEditorText,
2534
+ g.hasRangeSelection
2535
+ ]);
2536
+ let de = () => {
2537
+ oe(), N.close(), S(null), te(), D(!1), b(!1);
2538
+ };
2539
+ s(() => {
2540
+ if (!y) return;
2541
+ let e = window.visualViewport;
2542
+ if (!e) return;
2543
+ let t = () => {
2544
+ le(Math.max(0, window.innerHeight - e.height - e.offsetTop));
2545
+ };
2546
+ return e.addEventListener("resize", t), e.addEventListener("scroll", t), t(), () => {
2547
+ e.removeEventListener("resize", t), e.removeEventListener("scroll", t);
2548
+ };
2549
+ }, [y]), s(() => {
2550
+ y || oe();
2551
+ }, [oe, y]), s(() => {
2552
+ if (y) return f.setEditable(!0), f.registerRootListener((e) => {
2553
+ e && f.focus(void 0, { defaultSelection: "rootEnd" });
2554
+ });
2555
+ }, [y, f]);
2556
+ let fe = () => {
2557
+ T.current = !0, S(null), N.startTypeset();
2558
+ }, pe = (e) => {
2559
+ x === "aiPreset" && (T.current = !0), S(null), N.startPolish(e);
2560
+ };
2561
+ return /* @__PURE__ */ p(t, {
2562
+ open: y,
2563
+ onClose: de,
2564
+ position: "bottom",
2565
+ closeOnClickOverlay: !0,
2566
+ children: /* @__PURE__ */ p(jn.Provider, {
2567
+ value: re,
2568
+ children: /* @__PURE__ */ m("div", {
2569
+ className: V["bsy-mobile-editor"],
2570
+ style: {
2571
+ height: 300,
2572
+ transform: ce ? `translate3d(0, -${ce}px, 0)` : void 0
2573
+ },
2574
+ children: [
2575
+ /* @__PURE__ */ p("div", {
2576
+ className: V["bsy-mobile-editor__label"],
2577
+ children: /* @__PURE__ */ p("div", {
2578
+ className: V["bsy-mobile-editor__label-text"],
2579
+ children: h("editor.title")
2580
+ })
2581
+ }),
2582
+ /* @__PURE__ */ p("div", {
2583
+ className: V["bsy-mobile-editor__content"],
2584
+ style: { height: 200 },
2585
+ children: /* @__PURE__ */ p(Qe, {
2586
+ contentEditable: /* @__PURE__ */ p(qe, { className: V["bsy-mobile-editor__editable"] }),
2587
+ ErrorBoundary: $e
2588
+ })
2589
+ }),
2590
+ ue.length > 0 ? /* @__PURE__ */ p(qr, {
2591
+ config: ue,
2592
+ formats: g,
2593
+ colorValues: C,
2594
+ openSheet: x,
2595
+ onOpenSheet: (e) => {
2596
+ (e === "fontColor" || e === "fill") && (k(), w((t) => {
2597
+ let n = e === "fill" ? g.backgroundColor : g.fontColor, r = g.hasRangeSelection && g.hasEditorText;
2598
+ return {
2599
+ ...t,
2600
+ [e]: r ? n : t[e]
2601
+ };
2602
+ })), S(e);
2603
+ },
2604
+ onOpenLink: j
2605
+ }) : null,
2606
+ /* @__PURE__ */ p(Je, {}),
2607
+ /* @__PURE__ */ p(Xe, {}),
2608
+ /* @__PURE__ */ p(Ye, {}),
2609
+ /* @__PURE__ */ p(Gn, {}),
2610
+ /* @__PURE__ */ p(Zn, {}),
2611
+ /* @__PURE__ */ p(qn, {}),
2612
+ /* @__PURE__ */ p(Yn, {}),
2613
+ /* @__PURE__ */ p(hi, {}),
2614
+ /* @__PURE__ */ p(gi, {}),
2615
+ /* @__PURE__ */ p(Ze, {
2616
+ onChange: se,
2617
+ ignoreSelectionChange: !0
2618
+ }),
2619
+ /* @__PURE__ */ p("input", {
2620
+ ref: ne,
2621
+ type: "file",
2622
+ accept: ht,
2623
+ hidden: !0,
2624
+ onChange: ae
2625
+ }),
2626
+ /* @__PURE__ */ p(vr, {
2627
+ sheet: x,
2628
+ onClose: () => {
2629
+ if (T.current) {
2630
+ T.current = !1;
2631
+ return;
2632
+ }
2633
+ S(null), window.requestAnimationFrame(() => f.focus());
2634
+ },
2635
+ onTypeset: fe,
2636
+ onPolishMenu: () => {
2637
+ T.current = !0, S("aiPreset");
2638
+ },
2639
+ onPickPreset: pe,
2640
+ savedSelectionRef: O,
2641
+ committedColors: C,
2642
+ onColorCommit: (e, t) => w((n) => ({
2643
+ ...n,
2644
+ [e]: t
2645
+ })),
2646
+ onPicture: (e) => {
2647
+ if (k(), e === "upload") {
2648
+ ne.current?.click();
2649
+ return;
2650
+ }
2651
+ T.current = !0, S(null), D(!0);
2652
+ },
2653
+ canTypeset: !!l?.typeset,
2654
+ canPolish: !!l?.polish
2655
+ }),
2656
+ /* @__PURE__ */ p(br, {
2657
+ open: A !== null,
2658
+ seed: A,
2659
+ onClose: te,
2660
+ onConfirm: ee
2661
+ }),
2662
+ /* @__PURE__ */ p(Sr, {
2663
+ open: E,
2664
+ onClose: () => D(!1),
2665
+ onConfirm: (e) => {
2666
+ ie(e, e), D(!1);
2667
+ }
2668
+ }),
2669
+ /* @__PURE__ */ p(kr, {
2670
+ open: N.mode !== null,
2671
+ mode: N.mode,
2672
+ originalHtml: N.snapshot.html,
2673
+ ai: l,
2674
+ polishPreset: N.preset,
2675
+ onClose: N.close,
2676
+ onApply: N.apply,
2677
+ onPickPreset: pe
2678
+ })
2679
+ ]
2680
+ })
2681
+ })
2682
+ });
2683
+ }, vi = "1px solid #d9d9d9", yi = { export: new Map([[le, (e, t) => {
2684
+ let n = t.exportDOM(e);
2685
+ return Ge(n.element) && (n.element.style.border = vi), n;
2686
+ }]]) }, bi = class e extends x {
2687
+ constructor(e = "", t = {}, n) {
2688
+ super(e, t, n);
2689
+ }
2690
+ static getType() {
2691
+ return "extended-link";
2692
+ }
2693
+ static clone(t) {
2694
+ return new e(t.__url, {
2695
+ rel: t.__rel,
2696
+ target: t.__target,
2697
+ title: t.__title
2698
+ }, t.__key);
2699
+ }
2700
+ static importJSON(e) {
2701
+ return xi().updateFromJSON(e);
2702
+ }
2703
+ sanitizeUrl(e) {
2704
+ return e.startsWith("@") ? e : super.sanitizeUrl(e);
2705
+ }
2706
+ }, xi = (e = "", t = {}) => ge(new bi(e, t)), Si = {
2707
+ namespace: "bsyLexicalEditor",
2708
+ onError: (e) => {
2709
+ console.error("Lexical error", e);
2710
+ },
2711
+ editable: !0,
2712
+ theme: {
2713
+ text: {
2714
+ bold: "editor-text-bold",
2715
+ italic: "editor-text-italic",
2716
+ underline: "editor-text-underline",
2717
+ strikethrough: "editor-text-strikethrough",
2718
+ underlineStrikethrough: "editor-text-underline-strikethrough"
2719
+ },
2720
+ list: {
2721
+ ul: "editor-list-ul",
2722
+ ol: "editor-list-ol",
2723
+ listitem: "editor-listitem",
2724
+ nested: { listitem: "editor-nested-listitem" }
2725
+ },
2726
+ heading: {
2727
+ h1: "editor-heading-h1",
2728
+ h2: "editor-heading-h2",
2729
+ h3: "editor-heading-h3"
2730
+ },
2731
+ code: "editor-code",
2732
+ link: "editor-link",
2733
+ table: "editor-table",
2734
+ tableCell: "editor-table-cell",
2735
+ tableCellHeader: "editor-table-cell-header",
2736
+ tableRow: "editor-table-row",
2737
+ tableScrollableWrapper: "editor-table-scrollable-wrapper"
2738
+ },
2739
+ html: yi,
2740
+ nodes: [
2741
+ bi,
2742
+ {
2743
+ replace: x,
2744
+ with: (e) => new bi(e.__url, {
2745
+ rel: e.__rel,
2746
+ target: e.__target,
2747
+ title: e.__title
2748
+ }),
2749
+ withKlass: bi
2750
+ },
2751
+ b,
2752
+ D,
2753
+ E,
2754
+ ae,
2755
+ M,
2756
+ te,
2757
+ ue,
2758
+ de,
2759
+ le,
2760
+ Fn,
2761
+ q,
2762
+ {
2763
+ replace: We,
2764
+ with: (e) => new q(e.__text),
2765
+ withKlass: q
2766
+ }
2767
+ ]
2768
+ }, Ci = (e) => /* @__PURE__ */ p(g, {
2769
+ initialConfig: Si,
2770
+ children: /* @__PURE__ */ p(_i, { ...e })
2771
+ });
2772
+ Ci.displayName = "BsyMobileEditor";
2773
+ //#endregion
2774
+ export { wr as n, Ci as t };