@baishuyun/ui-mobile 0.9.1 → 0.11.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 (65) 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-CZ4Tz-N2.js +2785 -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/nodes/ImageNode.d.ts +5 -2
  35. package/dist/components/Editor/plugins/CodeHighlightPlugin.d.ts +2 -0
  36. package/dist/components/Editor/plugins/EnterKeyPlugin.d.ts +1 -0
  37. package/dist/components/Editor/plugins/TablePlugin.d.ts +2 -0
  38. package/dist/components/Editor/popups/AiResultPopup.d.ts +13 -0
  39. package/dist/components/Editor/popups/ImageUrlPopup.d.ts +7 -0
  40. package/dist/components/Editor/popups/LinkPopup.d.ts +13 -0
  41. package/dist/components/Editor/popups/OptionSheets.d.ts +23 -0
  42. package/dist/components/Editor/popups/index.d.ts +4 -0
  43. package/dist/components/Editor/popups/shared.d.ts +11 -0
  44. package/dist/components/Editor/toolbar/Toolbar.d.ts +7 -1
  45. package/dist/components/Editor/toolbar/useTextFormats.d.ts +2 -15
  46. package/dist/components/Editor/utils/codeHighlighter.d.ts +12 -0
  47. package/dist/components/Editor/utils/placeProgrammaticCaret.d.ts +4 -0
  48. package/dist/components/Editor/utils/readTextFormats.d.ts +21 -0
  49. package/dist/components/Editor/utils/retainCodeSelection.d.ts +3 -0
  50. package/dist/components/Segmented/Segmented.d.ts +7 -0
  51. package/dist/components/Segmented/index.d.ts +2 -0
  52. package/dist/components/Segmented/interface.d.ts +42 -0
  53. package/dist/components/index.d.ts +3 -1
  54. package/dist/index.js +14 -13
  55. package/dist/locale/lang/en-US.json.d.ts +6 -0
  56. package/dist/locale/lang/zh-CN.json.d.ts +6 -0
  57. package/dist/locale/lang/zh-TW.json.d.ts +6 -0
  58. package/dist/style.css +1 -1
  59. package/dist/vendors/cssVars-BbL_cmFM.js +6 -0
  60. package/dist/vendors/{version-CegBK2kS.js → version-CMSvw03J.js} +1 -1
  61. package/package.json +7 -1
  62. package/dist/Editor/Editor-COxP3RpF.js +0 -2059
  63. package/dist/Icon/Icon-D3xi1oyo.js +0 -23
  64. package/dist/components/Editor/sheets.d.ts +0 -43
  65. /package/dist/Overlay/{Overlay-CqQWOqO4.js → Overlay-DFiZYsBs.js} +0 -0
@@ -0,0 +1,2785 @@
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
+ "data-src",
288
+ "class",
289
+ "style",
290
+ "width",
291
+ "height"
292
+ ], 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([
293
+ "pre",
294
+ "code",
295
+ "td",
296
+ "th"
297
+ ]), 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) => {
298
+ let n = e.indexOf(":");
299
+ if (n === -1) return null;
300
+ let r = e.slice(0, n).trim().toLowerCase(), i = e.slice(n + 1).trim();
301
+ if (r === "background") {
302
+ if (/url\s*\(/i.test(i)) return null;
303
+ r = "background-color";
304
+ }
305
+ return !At(r, t) || /expression|javascript:|url\s*\(\s*['"]?\s*javascript/i.test(i) ? null : `${r}: ${i}`;
306
+ }).filter((e) => e !== null).join("; "), Mt = !1, Nt = () => {
307
+ Mt ||= (nt.addHook("uponSanitizeAttribute", (e, t) => {
308
+ if (t.attrName === "href" && /^data:/i.test(t.attrValue)) {
309
+ t.keepAttr = !1;
310
+ return;
311
+ }
312
+ t.attrName === "style" && (t.attrValue = jt(t.attrValue, e.nodeName.toLowerCase()), t.attrValue || (t.keepAttr = !1));
313
+ }), !0);
314
+ }, U = (e) => e ? (Nt(), nt.sanitize(e, {
315
+ ALLOWED_TAGS: Ct,
316
+ ALLOWED_ATTR: wt,
317
+ ALLOW_DATA_ATTR: !1,
318
+ ADD_ATTR: [
319
+ "data-language",
320
+ "data-id",
321
+ "data-src"
322
+ ],
323
+ ALLOWED_URI_REGEXP: Et
324
+ })) : "", W = {
325
+ margin: "0.6em 0 0.4em",
326
+ "font-weight": "600",
327
+ "line-height": "1.35"
328
+ }, Pt = {
329
+ h1: {
330
+ ...W,
331
+ "font-size": "2em"
332
+ },
333
+ h2: {
334
+ ...W,
335
+ "font-size": "1.5em"
336
+ },
337
+ h3: {
338
+ ...W,
339
+ "font-size": "1.25em"
340
+ },
341
+ h4: {
342
+ ...W,
343
+ "font-size": "1.125em"
344
+ },
345
+ h5: {
346
+ ...W,
347
+ "font-size": "1em"
348
+ },
349
+ h6: {
350
+ ...W,
351
+ "font-size": "0.875em"
352
+ }
353
+ }, Ft = {
354
+ color: "#0269ff",
355
+ cursor: "pointer"
356
+ }, It = {
357
+ margin: "0",
358
+ "padding-inline-start": "24px",
359
+ "list-style-position": "outside"
360
+ }, Lt = [
361
+ "disc",
362
+ "circle",
363
+ "square"
364
+ ], Rt = {
365
+ margin: "0",
366
+ "list-style": "inherit"
367
+ }, zt = {
368
+ margin: "0",
369
+ "list-style-type": "none"
370
+ }, Bt = {
371
+ display: "block",
372
+ "box-sizing": "border-box",
373
+ "max-width": "100%",
374
+ margin: "8px 0",
375
+ padding: "8px 12px",
376
+ "overflow-x": "auto",
377
+ "font-family": "Menlo, Consolas, Monaco, monospace",
378
+ "font-size": "13px",
379
+ "line-height": "1.53",
380
+ "white-space": "pre",
381
+ "tab-size": "2",
382
+ "border-radius": "4px",
383
+ "background-color": "rgb(240, 242, 245)",
384
+ color: "#1f2328"
385
+ }, Vt = {
386
+ "border-collapse": "collapse",
387
+ "table-layout": "fixed",
388
+ width: "100%",
389
+ "overflow-x": "auto",
390
+ margin: "8px 0"
391
+ }, Ht = {
392
+ "box-sizing": "border-box",
393
+ "min-width": "75px",
394
+ "min-height": "32px",
395
+ padding: "4px 8px",
396
+ border: "1px solid #d9d9d9",
397
+ "vertical-align": "top"
398
+ }, Ut = {
399
+ "font-weight": "600",
400
+ "background-color": "#f2f3f5"
401
+ }, Wt = {
402
+ display: "inline-block",
403
+ position: "static",
404
+ top: "auto",
405
+ bottom: "auto",
406
+ "font-size": "0.75em",
407
+ "line-height": "1"
408
+ }, G = (e, t) => {
409
+ for (let [n, r] of Object.entries(t)) e.style.getPropertyValue(n) || e.style.setProperty(n, r);
410
+ }, Gt = (e) => {
411
+ let t = 0, n = e;
412
+ for (; n;) n.tagName === "UL" && (t += 1), n = n.parentElement;
413
+ return t;
414
+ }, Kt = (e) => {
415
+ for (let t of Array.from(e.querySelectorAll("*"))) {
416
+ if (!(t instanceof HTMLElement)) continue;
417
+ let e = t.tagName.toLowerCase(), n = Pt[e];
418
+ if (n && G(t, n), e === "a" && G(t, Ft), e === "ul") {
419
+ let e = Math.min(Math.max(Gt(t), 1), Lt.length);
420
+ G(t, {
421
+ ...It,
422
+ "list-style-type": Lt[e - 1]
423
+ });
424
+ }
425
+ e === "ol" && G(t, {
426
+ ...It,
427
+ "list-style-type": "decimal"
428
+ }), e === "li" && G(t, t.classList.contains("editor-nested-listitem") ? zt : Rt), e === "pre" && G(t, Bt), (e === "sup" || e === "sub") && G(t, {
429
+ ...Wt,
430
+ "vertical-align": e === "sup" ? "super" : "sub"
431
+ }), 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" });
432
+ for (let e of Array.from(t.classList)) e.startsWith("editor-") && t.classList.remove(e);
433
+ t.classList.length === 0 && t.removeAttribute("class");
434
+ }
435
+ }, qt = (e) => {
436
+ let t = e.parentNode;
437
+ if (t) {
438
+ for (; e.firstChild;) t.insertBefore(e.firstChild, e);
439
+ t.removeChild(e);
440
+ }
441
+ }, Jt = (e) => {
442
+ let t = !0;
443
+ for (; t;) {
444
+ t = !1;
445
+ for (let n of Array.from(e.querySelectorAll("span, b, i"))) {
446
+ if (n.attributes.length > 0) continue;
447
+ let e = n.tagName.toLowerCase();
448
+ if (e === "span") {
449
+ qt(n), t = !0;
450
+ continue;
451
+ }
452
+ if (n.childElementCount !== 1 || n.childNodes.length !== 1) continue;
453
+ let r = n.firstElementChild;
454
+ (e === "b" && r?.tagName === "STRONG" || e === "i" && r?.tagName === "EM") && (qt(n), t = !0);
455
+ }
456
+ }
457
+ }, Yt = (e) => {
458
+ if (!e.trim()) return e;
459
+ let t = new DOMParser().parseFromString(e, "text/html");
460
+ Kt(t.body), Jt(t.body);
461
+ for (let e of Array.from(t.body.querySelectorAll("pre"))) e.textContent?.trim() || e.remove();
462
+ return t.body.innerHTML;
463
+ }, 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) => {
464
+ let n = e.map(() => "");
465
+ if (e.length === 0) return n;
466
+ let r = [], i = [];
467
+ if (e.forEach((e, t) => {
468
+ for (let n of Array.from(e)) i.push(n), r.push(t);
469
+ }), i.length === 0) return n[0] = t, n;
470
+ let a = i, o = Array.from(t), s = a.length, c = o.length, l = Array.from({ length: s + 1 }, () => Array(c + 1).fill(0));
471
+ 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]);
472
+ let u = 0, d = 0, f = r[0];
473
+ 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);
474
+ for (; d < c;) n[n.length - 1] += o[d], d += 1;
475
+ return n;
476
+ }, rn = new Set([
477
+ "TABLE",
478
+ "THEAD",
479
+ "TBODY",
480
+ "TR",
481
+ "TD",
482
+ "TH",
483
+ "IMG",
484
+ "BR"
485
+ ]), an = (e) => {
486
+ let t = [], n = (e) => {
487
+ if (e.nodeType === Node.ELEMENT_NODE) {
488
+ if (e.tagName === "PRE") return;
489
+ for (let t of Array.from(e.childNodes)) n(t);
490
+ return;
491
+ }
492
+ e.nodeType === Node.TEXT_NODE && t.push(e);
493
+ };
494
+ return n(e), t;
495
+ }, on = (e, t) => {
496
+ let n = e;
497
+ for (; n && n !== t && !rn.has(n.tagName) && !(n.textContent ?? "").trim() && !n.querySelector("img, table, br");) {
498
+ let e = n.parentElement;
499
+ n.remove(), n = e;
500
+ }
501
+ }, sn = (e) => {
502
+ let t = e.tagName;
503
+ return t === "IMG" || t === "TABLE" || t === "PRE";
504
+ }, cn = (e) => {
505
+ let t = Qt(e);
506
+ return t ? Array.from(t.children).filter((e) => !sn(e)).map((e) => e.textContent ?? "") : [];
507
+ }, ln = (e) => e.includes("<!--bsy-block-->") ? e : $t(e) || e, un = (e, t) => {
508
+ let n = an(e);
509
+ if (n.length === 0) {
510
+ t && (e.querySelector("br")?.remove(), e.append(e.ownerDocument.createTextNode(t)));
511
+ return;
512
+ }
513
+ let r = nn(n.map((e) => e.textContent ?? ""), t);
514
+ for (let t = 0; t < n.length; t++) {
515
+ let i = r[t], a = n[t];
516
+ if (i) {
517
+ a.textContent = i;
518
+ continue;
519
+ }
520
+ let o = a.parentElement;
521
+ a.remove(), on(o, e);
522
+ }
523
+ }, dn = (e, t) => {
524
+ let n = ln(t);
525
+ if (!tn(n) || !e.trim()) return "";
526
+ let r = Qt(e);
527
+ if (!r) return "";
528
+ let i = Array.from(r.children).filter((e) => !sn(e));
529
+ if (i.length === 0) return "";
530
+ let a = en(n), o = a.length === i.length ? a : nn(i.map((e) => e.textContent ?? ""), a.join(""));
531
+ for (let e = 0; e < i.length; e++) un(i[e], o[e] ?? "");
532
+ return r.innerHTML;
533
+ }, fn = (e, t) => {
534
+ let n = "";
535
+ e.getEditorState().read(() => {
536
+ n = Yt(U(et(e, null)));
537
+ }, { editor: e });
538
+ let r = U(dn(n, t));
539
+ return !r.trim() || St(r, $t(r)) ? !1 : (e.update(() => {
540
+ yt(e, r), bt(!0);
541
+ }, { discrete: !0 }), !0);
542
+ }, pn = (e) => {
543
+ let t = "", n = "", r = "";
544
+ return e.getEditorState().read(() => {
545
+ n = F().getTextContent(), t = Yt(U(et(e, null))), r = cn(t).join(`\n\n${Xt}\n\n`);
546
+ }, { editor: e }), {
547
+ html: t,
548
+ text: n,
549
+ polishText: r
550
+ };
551
+ }, 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) => {
552
+ let t = e.replace(/\n+$/, ""), n = t.lastIndexOf("\n"), r = n === -1 ? t : t.slice(n + 1);
553
+ return hn.test(r) ? {
554
+ text: n === -1 ? "" : t.slice(0, n),
555
+ withheld: !0
556
+ } : {
557
+ text: e,
558
+ withheld: !1
559
+ };
560
+ }, wn = (e) => {
561
+ let t = gn.exec(e);
562
+ return t ? { sameLineBody: t[4] ?? "" } : null;
563
+ }, Tn = (e) => {
564
+ let t = e.replace(/[ \t]*```[ \t]*$/, "");
565
+ return t === e ? e : t;
566
+ }, En = (e) => bn(e) ? e.replace(/^\n/, "") : "", Dn = (e) => {
567
+ let t = e.split("\n"), n = [], r = 0;
568
+ for (; r < t.length;) {
569
+ let e = t[r], i = wn(e);
570
+ if (i) {
571
+ let e = i.sameLineBody;
572
+ if (e !== Tn(e)) {
573
+ e = Tn(e);
574
+ let i = En(t.slice(r + 1).join("\n"));
575
+ return [
576
+ ...n,
577
+ e,
578
+ i
579
+ ].filter(Boolean).join("\n");
580
+ }
581
+ let a = [];
582
+ for (e && a.push(e), r += 1; r < t.length && !_n.test(t[r]);) a.push(t[r]), r += 1;
583
+ let o = r < t.length ? En(t.slice(r + 1).join("\n")) : "";
584
+ return [
585
+ ...n,
586
+ a.join("\n"),
587
+ o
588
+ ].filter(Boolean).join("\n");
589
+ }
590
+ if (xn(e)) return On([...n, ...t.slice(r)].join("\n"));
591
+ bn(e) && n.push(e), r += 1;
592
+ }
593
+ return n.length ? n.join("\n") : null;
594
+ }, On = (e) => {
595
+ let t = e.split("\n");
596
+ if (!t.length) return e;
597
+ let n = wn(t[0]);
598
+ 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");
599
+ }, kn = (e) => {
600
+ if (!e) return {
601
+ html: "",
602
+ pending: !1
603
+ };
604
+ let { text: t, withheld: n } = Cn(Sn(e));
605
+ if (!t.trim()) return {
606
+ html: "",
607
+ pending: n || hn.test(Sn(e).trim())
608
+ };
609
+ let r = Dn(t) ?? t, i = Dn(r);
610
+ i !== null && i !== r && (r = i);
611
+ let a = r.trim();
612
+ return bn(a) ? {
613
+ html: a,
614
+ pending: !1
615
+ } : {
616
+ html: "",
617
+ pending: !0
618
+ };
619
+ }, An = ({ editor: e, ai: t }) => {
620
+ let n = u(t);
621
+ n.current = t;
622
+ let [r, i] = d(null), [a, o] = d({
623
+ html: "",
624
+ text: "",
625
+ polishText: ""
626
+ }), [s, c] = d("quick"), l = () => {
627
+ let t = pn(e);
628
+ o(t), i("typeset"), n.current?.typeset?.({
629
+ html: t.html,
630
+ text: t.text
631
+ });
632
+ }, f = (t) => {
633
+ let r = pn(e);
634
+ o(r), c(t), i("polish"), n.current?.stop?.(), n.current?.polish?.({
635
+ text: r.polishText,
636
+ preset: t
637
+ });
638
+ }, p = () => {
639
+ n.current?.stop?.(), i(null);
640
+ };
641
+ return {
642
+ mode: r,
643
+ snapshot: a,
644
+ preset: s,
645
+ startTypeset: l,
646
+ startPolish: f,
647
+ close: p,
648
+ apply: () => {
649
+ let t = n.current?.text ?? "";
650
+ if (r === "typeset") {
651
+ let n = U(kn(t).html);
652
+ if (!n.trim()) return;
653
+ e.update(() => {
654
+ yt(e, n), bt(!0);
655
+ });
656
+ } else r === "polish" && fn(e, t);
657
+ p();
658
+ }
659
+ };
660
+ }, jn = i({}), K = 36, Mn = 14, Nn = 2 * Math.PI * Mn, Pn = ({ nodeKey: e, src: t, altText: n, dataId: r, dataSrc: i }) => {
661
+ let a = o(jn), s = e in a, c = a[e];
662
+ return /* @__PURE__ */ m("span", {
663
+ className: V["bsy-mobile-editor__image"],
664
+ children: [/* @__PURE__ */ p("img", {
665
+ src: t,
666
+ alt: n,
667
+ "data-id": r,
668
+ "data-src": i
669
+ }), s ? /* @__PURE__ */ p("span", {
670
+ className: V["bsy-mobile-editor__image-mask"],
671
+ role: "progressbar",
672
+ "aria-label": n,
673
+ "aria-valuemin": 0,
674
+ "aria-valuemax": 100,
675
+ "aria-valuenow": c === void 0 ? void 0 : Math.round(c),
676
+ children: /* @__PURE__ */ m("svg", {
677
+ className: c === void 0 ? `${V["bsy-mobile-editor__image-progress"]} ${V["bsy-mobile-editor__image-progress--spin"]}` : V["bsy-mobile-editor__image-progress"],
678
+ width: K,
679
+ height: K,
680
+ viewBox: `0 0 ${K} ${K}`,
681
+ "aria-hidden": "true",
682
+ children: [/* @__PURE__ */ p("circle", {
683
+ cx: K / 2,
684
+ cy: K / 2,
685
+ r: Mn,
686
+ fill: "none",
687
+ stroke: "rgba(255,255,255,0.35)",
688
+ strokeWidth: "3"
689
+ }), /* @__PURE__ */ p("circle", {
690
+ cx: K / 2,
691
+ cy: K / 2,
692
+ r: Mn,
693
+ fill: "none",
694
+ stroke: "#fff",
695
+ strokeWidth: "3",
696
+ strokeLinecap: "round",
697
+ strokeDasharray: c === void 0 ? `${Nn * .25} ${Nn}` : Nn,
698
+ strokeDashoffset: c === void 0 ? 0 : Nn * (1 - c / 100),
699
+ transform: `rotate(-90 ${K / 2} ${K / 2})`
700
+ })]
701
+ })
702
+ }) : null]
703
+ });
704
+ }, Fn = class e extends Ne {
705
+ __src;
706
+ __altText;
707
+ __width;
708
+ __height;
709
+ __dataId;
710
+ __dataSrc;
711
+ static getType() {
712
+ return "image";
713
+ }
714
+ static clone(t) {
715
+ return new e(t.__src, t.__altText, t.__width, t.__height, t.__key, t.__dataId, t.__dataSrc);
716
+ }
717
+ constructor(e, t, n, r, i, a, o) {
718
+ super(i), this.__src = e, this.__altText = t || "", this.__width = n, this.__height = r, this.__dataId = a, this.__dataSrc = o;
719
+ }
720
+ createDOM() {
721
+ let e = document.createElement("span");
722
+ return e.className = V["bsy-mobile-editor__image-shell"], e;
723
+ }
724
+ updateDOM() {
725
+ return !1;
726
+ }
727
+ exportDOM() {
728
+ let e = document.createElement("img");
729
+ 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), this.__dataSrc && e.setAttribute("data-src", this.__dataSrc), { element: e };
730
+ }
731
+ getSrc() {
732
+ return this.__src;
733
+ }
734
+ setSrc(e) {
735
+ let t = this.getWritable();
736
+ t.__src = e;
737
+ }
738
+ setDataId(e) {
739
+ let t = this.getWritable();
740
+ t.__dataId = e;
741
+ }
742
+ static importDOM() {
743
+ return { img: () => ({
744
+ conversion: Rn,
745
+ priority: 0
746
+ }) };
747
+ }
748
+ static importJSON(e) {
749
+ let { src: t, altText: n, width: r, height: i, dataId: a, dataSrc: o } = e;
750
+ return Ln({
751
+ src: t,
752
+ altText: n,
753
+ width: r,
754
+ height: i,
755
+ dataId: a,
756
+ dataSrc: o
757
+ });
758
+ }
759
+ exportJSON() {
760
+ return {
761
+ src: this.getSrc(),
762
+ altText: this.__altText,
763
+ width: this.__width,
764
+ height: this.__height,
765
+ dataId: this.__dataId,
766
+ dataSrc: this.__dataSrc,
767
+ type: "image",
768
+ version: 1
769
+ };
770
+ }
771
+ isInline() {
772
+ return !0;
773
+ }
774
+ decorate() {
775
+ return /* @__PURE__ */ p(Pn, {
776
+ nodeKey: this.getKey(),
777
+ src: this.__src,
778
+ altText: this.__altText,
779
+ dataId: this.__dataId,
780
+ dataSrc: this.__dataSrc
781
+ });
782
+ }
783
+ }, In = (e) => e instanceof Fn, Ln = ({ src: e, altText: t, width: n, height: r, dataId: i, dataSrc: a, key: o }) => new Fn(e, t, n, r, o, i, a), Rn = (e) => {
784
+ if (!(e instanceof HTMLImageElement)) return null;
785
+ let { src: t, alt: n, style: r } = e, i, a;
786
+ if (r.width) {
787
+ let e = parseInt(r.width, 10);
788
+ Number.isNaN(e) || (i = e);
789
+ }
790
+ if (r.height) {
791
+ let e = parseInt(r.height, 10);
792
+ Number.isNaN(e) || (a = e);
793
+ }
794
+ return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node: Ln({
795
+ src: t,
796
+ altText: n,
797
+ width: i,
798
+ height: a,
799
+ dataId: e.getAttribute("data-id") || void 0,
800
+ dataSrc: e.getAttribute("data-src") || void 0
801
+ }) };
802
+ }, 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 }) => {
803
+ let i = u(null), o = u(null), c = u(!0), [l, f] = d({}), p = a(() => {
804
+ o.current?.abort(), o.current = null;
805
+ }, []);
806
+ s(() => (c.current = !0, () => {
807
+ c.current = !1, p();
808
+ }), [p]);
809
+ let m = a((t, r, i) => {
810
+ let a = "";
811
+ return e.update(() => {
812
+ let e = n.current;
813
+ e !== null && R(e), I() === null && F().selectEnd();
814
+ let o = Ln({
815
+ src: t,
816
+ altText: r,
817
+ dataSrc: i
818
+ });
819
+ a = o.getKey(), xe([o]);
820
+ for (let e of o.getParent()?.getChildren() ?? []) Ee(e) && e.getTextContentSize() === 0 && e.remove();
821
+ }), a;
822
+ }, [e, n]);
823
+ return {
824
+ fileInputRef: i,
825
+ uploadProgress: l,
826
+ insertImage: m,
827
+ onFileChange: a(async (n) => {
828
+ let i = n.target.files?.[0];
829
+ if (n.target.value = "", !i || Bn(i)) return;
830
+ p();
831
+ let a = new AbortController();
832
+ if (o.current = a, !t?.customRequest) {
833
+ try {
834
+ let e = await new Promise((e, t) => {
835
+ let n = new FileReader();
836
+ n.onload = () => e(String(n.result)), n.onerror = () => t(n.error), n.readAsDataURL(i);
837
+ });
838
+ if (!e || a.signal.aborted) return;
839
+ m(e, i.name);
840
+ } catch {
841
+ return;
842
+ } finally {
843
+ o.current === a && (o.current = null);
844
+ }
845
+ return;
846
+ }
847
+ let s = URL.createObjectURL(i), l = m(s, i.name);
848
+ f((e) => ({
849
+ ...e,
850
+ [l]: void 0
851
+ }));
852
+ let u = !1, d = (t) => {
853
+ u || (u = !0, URL.revokeObjectURL(s), t || e.update(() => {
854
+ be(l)?.remove();
855
+ }, c.current ? void 0 : { discrete: !0 }), c.current && f((e) => {
856
+ let t = { ...e };
857
+ return delete t[l], t;
858
+ }), o.current === a && (o.current = null));
859
+ };
860
+ a.signal.addEventListener("abort", () => d(!1), { once: !0 });
861
+ try {
862
+ let n = await t.customRequest(i, {
863
+ signal: a.signal,
864
+ onProgress: (e) => {
865
+ if (!c.current || !Number.isFinite(e)) return;
866
+ let t = Math.min(100, Math.max(0, e));
867
+ f((e) => l in e ? {
868
+ ...e,
869
+ [l]: t
870
+ } : e);
871
+ }
872
+ });
873
+ if (a.signal.aborted) {
874
+ d(!1);
875
+ return;
876
+ }
877
+ let o = "", s;
878
+ if (typeof n == "string" ? o = n : (o = n.url, n.attachment && (r.set(o, n.attachment), s = n.attachment._id)), !o) {
879
+ d(!1);
880
+ return;
881
+ }
882
+ e.update(() => {
883
+ let e = be(l);
884
+ In(e) && (e.setSrc(o), s && e.setDataId(s));
885
+ }), d(!0);
886
+ } catch {
887
+ d(!1);
888
+ }
889
+ }, [
890
+ p,
891
+ r,
892
+ e,
893
+ m,
894
+ t
895
+ ]),
896
+ abortUpload: p
897
+ };
898
+ }, Hn = ({ editor: e, savedSelectionRef: t, captureSelection: n }) => {
899
+ let [r, i] = d(null);
900
+ return {
901
+ linkForm: r,
902
+ openLink: () => {
903
+ n(), e.getEditorState().read(() => {
904
+ let e = I(), t = L(e) ? e.anchor.getNode() : null, n = t ? B(t, v) : null;
905
+ if (n) {
906
+ i({
907
+ url: n.getURL(),
908
+ text: n.getTextContent(),
909
+ newBlank: n.getTarget() === "_blank"
910
+ });
911
+ return;
912
+ }
913
+ i({
914
+ url: "",
915
+ text: L(e) ? e.getTextContent() : "",
916
+ newBlank: !0
917
+ });
918
+ });
919
+ },
920
+ confirmLink: (n) => {
921
+ let r = n.url.trim();
922
+ if (!r) return;
923
+ let a = r.startsWith("@") || /^https?:\/\//.test(r) ? r : `http://${r}`;
924
+ e.update(() => {
925
+ let e = t.current;
926
+ e !== null && R(e);
927
+ let r = I(), i = n.newBlank ? {
928
+ target: "_blank",
929
+ rel: "noopener noreferrer",
930
+ title: n.url
931
+ } : { title: n.url };
932
+ if (L(r)) {
933
+ let e = n.text.trim() || n.url;
934
+ if (r.getTextContent()) y(a, i);
935
+ else {
936
+ let t = ye(e), n = _(a, i);
937
+ n.append(t), r.insertNodes([n]);
938
+ }
939
+ } else {
940
+ let e = ye(n.text.trim() || n.url), t = _(a, i);
941
+ t.append(e);
942
+ let r = F(), o = r.getLastChild();
943
+ if (Se(o)) o.append(t);
944
+ else {
945
+ let e = P();
946
+ e.append(t), r.append(e);
947
+ }
948
+ }
949
+ }), i(null);
950
+ },
951
+ closeLink: () => i(null)
952
+ };
953
+ }, Un = ({ editor: e, value: t, onChange: n, attachmentsBySrc: r }) => {
954
+ let i = u(null), o = u(n);
955
+ o.current = n;
956
+ let c = a((t) => {
957
+ t.read(() => {
958
+ let n = F().getTextContent(), a = Yt(U(et(e, null))), s = St(a, n) ? null : a;
959
+ i.current = s;
960
+ let c = De(Fn).map((e) => r.get(e.getSrc())).filter((e) => e !== void 0);
961
+ o.current({
962
+ text: n,
963
+ html: s,
964
+ attachments: c
965
+ }, t);
966
+ }, { editor: e });
967
+ }, [r, e]);
968
+ return s(() => {
969
+ t === void 0 || t === i.current || (i.current = t ?? null, e.update(() => {
970
+ yt(e, t?.trim() ? U(t) : ""), bt(!!e.getRootElement()?.contains(document.activeElement));
971
+ }, { onUpdate: () => {
972
+ e.getRootElement() || c(e.getEditorState());
973
+ } }));
974
+ }, [
975
+ e,
976
+ c,
977
+ t
978
+ ]), c;
979
+ }, Wn = 250, Gn = () => {
980
+ let [e] = z(), t = u(0);
981
+ return s(() => e.registerCommand(ze, (e) => {
982
+ let n = Date.now(), r = n - t.current;
983
+ if (t.current = n, r <= 0 || r >= Wn) return !1;
984
+ let i = I();
985
+ if (!L(i) || !i.isCollapsed()) return !1;
986
+ let a = i.anchor.getNode();
987
+ if (B(a, S)) return !1;
988
+ let o = a.getTopLevelElement();
989
+ if (!o || o.getTextContent().trim() !== "") return !1;
990
+ i.setFormat(0);
991
+ let s = P();
992
+ at(i, {
993
+ "background-color": "",
994
+ color: "",
995
+ "font-size": "",
996
+ "font-weight": "",
997
+ "font-style": "",
998
+ "text-decoration": ""
999
+ }), o.replace(s), s.select();
1000
+ let c = s.getPreviousSibling();
1001
+ return c?.getTextContent().trim() === "" && c.remove(), e?.preventDefault(), !0;
1002
+ }, je), [e]), null;
1003
+ }, Kn = (e, t) => e.split(";").map((e) => e.trim()).filter((e) => e && e.split(":")[0].trim().toLowerCase() !== t).join("; "), qn = () => {
1004
+ let [e] = z();
1005
+ return s(() => e.registerNodeTransform(ae, (e) => {
1006
+ let t = e.getTag();
1007
+ if (t === "h4" || t === "h5" || t === "h6") {
1008
+ e.replace(P(), !0);
1009
+ return;
1010
+ }
1011
+ for (let t of e.getAllTextNodes()) {
1012
+ let e = t.getStyle();
1013
+ if (!e) continue;
1014
+ let n = Kn(e, "font-size");
1015
+ n !== e && t.setStyle(n);
1016
+ }
1017
+ }), [e]), null;
1018
+ }, q = class e extends We {
1019
+ static getType() {
1020
+ return "extended-text";
1021
+ }
1022
+ static clone(t) {
1023
+ return new e(t.__text, t.__key);
1024
+ }
1025
+ static importDOM() {
1026
+ let e = We.importDOM();
1027
+ return {
1028
+ ...e,
1029
+ code: () => ({
1030
+ conversion: J(e?.code),
1031
+ priority: 1
1032
+ }),
1033
+ em: () => ({
1034
+ conversion: J(e?.em),
1035
+ priority: 1
1036
+ }),
1037
+ span: () => ({
1038
+ conversion: J(e?.span),
1039
+ priority: 1
1040
+ }),
1041
+ strong: () => ({
1042
+ conversion: J(e?.strong),
1043
+ priority: 1
1044
+ }),
1045
+ sub: () => ({
1046
+ conversion: J(e?.sub),
1047
+ priority: 1
1048
+ }),
1049
+ sup: () => ({
1050
+ conversion: J(e?.sup),
1051
+ priority: 1
1052
+ })
1053
+ };
1054
+ }
1055
+ static importJSON(e) {
1056
+ return Jn().updateFromJSON(e);
1057
+ }
1058
+ isSimpleText() {
1059
+ return this.__type === "extended-text" && this.__mode === 0;
1060
+ }
1061
+ }, Jn = (e = "") => ge(new q(e)), J = (e) => (t) => {
1062
+ let n = e?.(t);
1063
+ if (!n) return null;
1064
+ let r = n.conversion(t);
1065
+ if (!r) return r;
1066
+ 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;
1067
+ return {
1068
+ ...r,
1069
+ forChild: (e, t) => {
1070
+ let n = (r?.forChild ?? ((e) => e))(e, t);
1071
+ if (Ee(n)) {
1072
+ let e = [
1073
+ i ? `background-color: ${i}` : null,
1074
+ a ? `color: ${a}` : null,
1075
+ o ? `font-family: ${o}` : null,
1076
+ s ? `font-weight: ${s}` : null,
1077
+ c ? `font-size: ${c}` : null,
1078
+ l ? `text-decoration: ${l}` : null
1079
+ ].filter((e) => e !== null).join("; ");
1080
+ if (e.length) return n.setStyle(e);
1081
+ }
1082
+ return n;
1083
+ }
1084
+ };
1085
+ }, Yn = () => {
1086
+ let [e] = z();
1087
+ return s(() => e.registerNodeTransform(q, (e) => {
1088
+ if (!B(e, v)) return;
1089
+ let t = e.getStyle();
1090
+ if (!t) return;
1091
+ let n = Kn(t, "color");
1092
+ n !== t && e.setStyle(n);
1093
+ }), [e]), null;
1094
+ }, Xn = /<img\b|<picture\b/i, Zn = () => {
1095
+ let [e] = z();
1096
+ return s(() => {
1097
+ let t = (t) => {
1098
+ let n = "clipboardData" in t ? t.clipboardData : "dataTransfer" in t ? t.dataTransfer : null;
1099
+ if (!n || n.getData("application/x-lexical-editor") || n.getData("application/x-lexical-drag")) return !1;
1100
+ let r = n.getData("text/html");
1101
+ 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;
1102
+ t.preventDefault();
1103
+ let i = n.getData("text/plain");
1104
+ return !Xn.test(r) && !i || e.update(() => {
1105
+ let t = I();
1106
+ if (t === null) return;
1107
+ let n = r ? new DOMParser().parseFromString(r, "text/html") : null;
1108
+ if (n?.querySelectorAll("img, picture").forEach((e) => e.remove()), (n?.body.innerHTML ?? "") && n?.body.textContent?.trim()) {
1109
+ let t = tt(e, n);
1110
+ if (t.length) {
1111
+ xe(t);
1112
+ return;
1113
+ }
1114
+ }
1115
+ i && t.insertRawText(i);
1116
+ }, { tag: Ue }), !0;
1117
+ };
1118
+ return rt(e.registerCommand(He, t, Ae), e.registerCommand(Me, t, Ae));
1119
+ }, [e]), null;
1120
+ }, Qn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAYAAACohjseAAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAADNBJREFUeAG1WuuvXUUV/619dqEPaG+pUFqg3AKFIoFWkKeKLWLRaKD6vVGMMcYQC8EPmBge/4A0fpEQEkmMz0QjH8CoIa3WUGwQ2oAiFWiFthb77qXvy1nOY83MWrP3qY2hk3vu3mfPzJr1+K3HzD6EqrXf5GVg3MPASncdd4+YCMTsvgHk7sEcx/r71Hy/H6e+Q49Nj/00RTPTSfOreXpN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wk4UCe4H5DJUqofpVwONXaEgo8YzOHqsYH4EtlnTgM0+COFl26gyD5hiLPIizPicP2fKkc4whGOcCjwKViIGaRSStOhAAAAAElFTkSuQmCC", er = (e, t, n) => Math.min(n, Math.max(t, e)), Y = (e) => er(e, 0, 1), X = (e) => {
1121
+ let t = e.trim().toLowerCase();
1122
+ if (t === "" || t === "transparent") return !0;
1123
+ let n = t.match(/^rgba\([^,]+,[^,]+,[^,]+,\s*([.\d]+)\s*\)$/);
1124
+ return n !== null && Number(n[1]) === 0;
1125
+ }, tr = (e) => {
1126
+ let t = e.trim().replace(/^#/, "");
1127
+ 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;
1128
+ }, nr = (e) => {
1129
+ let t = e.trim();
1130
+ if (X(t)) return null;
1131
+ let n = tr(t);
1132
+ if (n) return {
1133
+ r: Number.parseInt(n.slice(1, 3), 16),
1134
+ g: Number.parseInt(n.slice(3, 5), 16),
1135
+ b: Number.parseInt(n.slice(5, 7), 16)
1136
+ };
1137
+ let r = t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);
1138
+ return r ? {
1139
+ r: Number(r[1]),
1140
+ g: Number(r[2]),
1141
+ b: Number(r[3])
1142
+ } : null;
1143
+ }, rr = ({ r: e, g: t, b: n }) => `#${[
1144
+ e,
1145
+ t,
1146
+ n
1147
+ ].map((e) => er(Math.round(e), 0, 255).toString(16).padStart(2, "0")).join("")}`, ir = (e, t) => {
1148
+ if (X(e) && X(t)) return !0;
1149
+ let n = nr(e), r = nr(t);
1150
+ return !!(n && r && n.r === r.r && n.g === r.g && n.b === r.b);
1151
+ }, ar = (e) => {
1152
+ 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;
1153
+ 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), {
1154
+ h: c,
1155
+ s: s === 0 ? 0 : s / (1 - Math.abs(2 * o - 1)),
1156
+ l: o
1157
+ };
1158
+ }, or = ({ h: e, s: t, l: n }) => {
1159
+ 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;
1160
+ 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), {
1161
+ r: Math.round((s + o) * 255),
1162
+ g: Math.round((c + o) * 255),
1163
+ b: Math.round((l + o) * 255)
1164
+ };
1165
+ }, sr = (e) => rr(or(e)), cr = (e, t) => ({
1166
+ h: Y(e) * 360,
1167
+ s: 1,
1168
+ l: Y(1 - t)
1169
+ }), lr = (e) => ({
1170
+ x: Y((e.h % 360 + 360) % 360 / 360),
1171
+ y: Y(1 - e.l)
1172
+ }), ur = (e, t, n) => ({
1173
+ x: Y(n.width === 0 ? 0 : (e - n.left) / n.width),
1174
+ y: Y(n.height === 0 ? 0 : (t - n.top) / n.height)
1175
+ }), dr = (e, t, n = Infinity) => {
1176
+ let r = nr(t);
1177
+ if (!r) return e;
1178
+ let i = rr(r);
1179
+ return [i, ...e.filter((e) => !ir(e, i))].slice(0, n);
1180
+ }, fr = (e, t = 24, n = 8) => Math.max(0, Math.floor((e + n) / (t + n))), pr = (e, t) => {
1181
+ let n = t % 11;
1182
+ return Math.floor(t / 11) === 2 ? e[22] ?? e[t] : e[n] ?? e[t];
1183
+ }, Z = (...e) => e.filter(Boolean).join(" "), mr = (e) => {
1184
+ let t = nr(e) ?? {
1185
+ r: 0,
1186
+ g: 94,
1187
+ b: 239
1188
+ };
1189
+ return {
1190
+ color: rr(t),
1191
+ point: lr(ar(t))
1192
+ };
1193
+ }, hr = ({ mode: t, currentColor: r, customColors: i, onApply: a, onCustomDraftChange: o, onCustomConfirm: c }) => {
1194
+ 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) => {
1195
+ _(mr(e)), y(!1), o(null), h("custom");
1196
+ };
1197
+ s(() => {
1198
+ if (f !== "custom" || typeof ResizeObserver > "u") return;
1199
+ let e = C.current;
1200
+ if (!e) return;
1201
+ let t = () => {
1202
+ let { width: t, height: n } = e.getBoundingClientRect();
1203
+ if (!t || !n) return;
1204
+ let r = window.devicePixelRatio || 1;
1205
+ e.width = Math.round(t * r), e.height = Math.round(n * r);
1206
+ let i = e.getContext("2d");
1207
+ if (!i) return;
1208
+ i.scale(r, r);
1209
+ let a = i.createLinearGradient(0, 0, t, 0);
1210
+ 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);
1211
+ let o = i.createLinearGradient(0, 0, 0, n);
1212
+ 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);
1213
+ let s = i.createLinearGradient(0, 0, 0, n);
1214
+ 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);
1215
+ };
1216
+ t();
1217
+ let n = new ResizeObserver(t);
1218
+ return n.observe(e), () => n.disconnect();
1219
+ }, [f]), s(() => {
1220
+ let e = w.current;
1221
+ if (!e) return;
1222
+ let t = () => {
1223
+ let t = e.getBoundingClientRect().width;
1224
+ t > 0 && x(fr(t));
1225
+ };
1226
+ if (t(), typeof ResizeObserver > "u") return;
1227
+ let n = new ResizeObserver(t);
1228
+ return n.observe(e), () => n.disconnect();
1229
+ }, [t]);
1230
+ let E = (e) => {
1231
+ let t = S.current;
1232
+ if (!t) return;
1233
+ let { x: n, y: r } = ur(e.clientX, e.clientY, t.getBoundingClientRect()), i = sr(cr(n, r));
1234
+ _({
1235
+ color: i,
1236
+ point: {
1237
+ x: n,
1238
+ y: r
1239
+ }
1240
+ }), y(!0), o(i);
1241
+ }, D = f === "custom", { color: O, point: k } = g, A = /* @__PURE__ */ m("div", {
1242
+ className: V["bsy-mobile-editor__color-bar"],
1243
+ children: [
1244
+ /* @__PURE__ */ p("button", {
1245
+ type: "button",
1246
+ 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"]),
1247
+ "aria-label": l("editor.addSwatch"),
1248
+ "aria-pressed": D,
1249
+ style: { backgroundColor: D && v ? O : void 0 },
1250
+ onClick: () => {
1251
+ D || T(r);
1252
+ },
1253
+ children: v ? null : /* @__PURE__ */ p(n, {
1254
+ name: "add",
1255
+ size: 16
1256
+ })
1257
+ }),
1258
+ t === "fill" ? /* @__PURE__ */ p("button", {
1259
+ type: "button",
1260
+ role: "option",
1261
+ "aria-selected": X(r),
1262
+ "aria-label": l("editor.fillNone"),
1263
+ className: Z(V["bsy-mobile-editor__color-none"], X(r) && V["bsy-mobile-editor__color-none--selected"]),
1264
+ onClick: () => a("transparent")
1265
+ }) : null,
1266
+ /* @__PURE__ */ p("div", {
1267
+ ref: w,
1268
+ className: V["bsy-mobile-editor__color-custom-list"],
1269
+ role: "listbox",
1270
+ "aria-label": l("editor.customColors"),
1271
+ children: i.slice(0, b ?? i.length).map((e) => {
1272
+ let t = ir(r, e);
1273
+ return /* @__PURE__ */ p("button", {
1274
+ type: "button",
1275
+ role: "option",
1276
+ "aria-selected": t,
1277
+ "aria-label": e,
1278
+ className: Z(V["bsy-mobile-editor__color-custom-item"], t && V["bsy-mobile-editor__color-custom-item--selected"]),
1279
+ style: {
1280
+ "--swatch-color": e,
1281
+ backgroundColor: e
1282
+ },
1283
+ onClick: () => a(e)
1284
+ }, e);
1285
+ })
1286
+ })
1287
+ ]
1288
+ });
1289
+ return /* @__PURE__ */ m("div", {
1290
+ className: Z(V["bsy-mobile-editor__color"], D && V["bsy-mobile-editor__color--custom"]),
1291
+ children: [
1292
+ /* @__PURE__ */ m("div", {
1293
+ className: V["bsy-mobile-editor__color-header"],
1294
+ children: [D ? /* @__PURE__ */ p("button", {
1295
+ type: "button",
1296
+ className: V["bsy-mobile-editor__color-header-back"],
1297
+ "aria-label": l("editor.colorBack"),
1298
+ onClick: () => {
1299
+ v && c(O), o(null), y(!1), h("presets");
1300
+ },
1301
+ children: /* @__PURE__ */ p(n, {
1302
+ name: "left",
1303
+ size: 18
1304
+ })
1305
+ }) : null, /* @__PURE__ */ p("span", {
1306
+ className: V["bsy-mobile-editor__color-header-title"],
1307
+ children: l(D ? "editor.customColor" : t === "fill" ? "editor.fill" : "editor.fontColor")
1308
+ })]
1309
+ }),
1310
+ D ? /* @__PURE__ */ p("div", {
1311
+ className: V["bsy-mobile-editor__color-mixer"],
1312
+ children: /* @__PURE__ */ m("div", {
1313
+ ref: S,
1314
+ className: V["bsy-mobile-editor__color-spectrum"],
1315
+ role: "slider",
1316
+ "aria-label": l("editor.colorSpectrum"),
1317
+ "aria-valuemin": 0,
1318
+ "aria-valuemax": 100,
1319
+ "aria-valuenow": Math.round(k.x * 100),
1320
+ "aria-valuetext": O,
1321
+ onPointerDown: (e) => {
1322
+ e.currentTarget.setPointerCapture(e.pointerId), E(e);
1323
+ },
1324
+ onPointerMove: (e) => {
1325
+ e.buttons !== 0 && E(e);
1326
+ },
1327
+ onPointerUp: (e) => {
1328
+ E(e);
1329
+ },
1330
+ children: [/* @__PURE__ */ p("canvas", {
1331
+ ref: C,
1332
+ className: V["bsy-mobile-editor__color-spectrum-canvas"],
1333
+ width: 392,
1334
+ height: 192,
1335
+ "aria-hidden": !0
1336
+ }), /* @__PURE__ */ p("span", {
1337
+ className: V["bsy-mobile-editor__color-thumb"],
1338
+ style: {
1339
+ left: `${k.x * 100}%`,
1340
+ top: `${k.y * 100}%`,
1341
+ backgroundColor: O
1342
+ }
1343
+ })]
1344
+ })
1345
+ }) : /* @__PURE__ */ p("div", {
1346
+ className: V["bsy-mobile-editor__color-grid"],
1347
+ role: "listbox",
1348
+ "aria-label": l("editor.presetColors"),
1349
+ children: ut.map((e, t) => {
1350
+ let n = ir(r, e);
1351
+ return /* @__PURE__ */ p("button", {
1352
+ type: "button",
1353
+ role: "option",
1354
+ "aria-selected": n,
1355
+ "aria-label": e,
1356
+ className: Z(V["bsy-mobile-editor__color-swatch"], n && V["bsy-mobile-editor__color-swatch--selected"]),
1357
+ style: {
1358
+ "--swatch-color": e,
1359
+ "--swatch-ring": pr(ut, t)
1360
+ },
1361
+ onClick: () => a(e),
1362
+ children: /* @__PURE__ */ p("span", { className: V["bsy-mobile-editor__color-swatch-fill"] })
1363
+ }, e);
1364
+ })
1365
+ }),
1366
+ A
1367
+ ]
1368
+ });
1369
+ }, gr = (e, t) => {
1370
+ H(e), e.update(() => {
1371
+ ot(I(), () => t === "paragraph" ? P() : re(t));
1372
+ });
1373
+ }, _r = (e, t, n) => {
1374
+ H(e), e.update(() => {
1375
+ n && R(n), xt();
1376
+ let e = I();
1377
+ e && at(e, t);
1378
+ });
1379
+ }, vr = ({ sheet: i, onClose: a, onTypeset: o, onPolishMenu: s, onPickPreset: c, onPicture: l, savedSelectionRef: h, committedColors: g, onColorCommit: _, canTypeset: v, canPolish: y }) => {
1380
+ 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) => {
1381
+ 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());
1382
+ }, O = (e) => {
1383
+ w.current = null, D(e, !0, !1);
1384
+ };
1385
+ return /* @__PURE__ */ m(f, { children: [
1386
+ /* @__PURE__ */ p(r, {
1387
+ mode: "menu",
1388
+ open: i === "align",
1389
+ title: x("editor.alignment"),
1390
+ onClose: a,
1391
+ actions: [
1392
+ {
1393
+ key: "left",
1394
+ text: x("editor.leftAlign"),
1395
+ icon: /* @__PURE__ */ p(n, {
1396
+ name: "paragraph",
1397
+ size: 16
1398
+ })
1399
+ },
1400
+ {
1401
+ key: "center",
1402
+ text: x("editor.centerAlign"),
1403
+ icon: /* @__PURE__ */ p(n, {
1404
+ name: "paragraphmiddle",
1405
+ size: 16
1406
+ })
1407
+ },
1408
+ {
1409
+ key: "right",
1410
+ text: x("editor.rightAlign"),
1411
+ icon: /* @__PURE__ */ p(n, {
1412
+ name: "paragraphright",
1413
+ size: 16
1414
+ })
1415
+ }
1416
+ ],
1417
+ onAction: (e) => {
1418
+ H(b), b.dispatchCommand(Fe, e.key);
1419
+ }
1420
+ }),
1421
+ /* @__PURE__ */ p(r, {
1422
+ mode: "menu",
1423
+ open: i === "heading",
1424
+ title: x("editor.heading"),
1425
+ onClose: a,
1426
+ actions: [
1427
+ {
1428
+ key: "paragraph",
1429
+ text: x("editor.paragraph")
1430
+ },
1431
+ {
1432
+ key: "h1",
1433
+ text: x("editor.heading1")
1434
+ },
1435
+ {
1436
+ key: "h2",
1437
+ text: x("editor.heading2")
1438
+ },
1439
+ {
1440
+ key: "h3",
1441
+ text: x("editor.heading3")
1442
+ }
1443
+ ],
1444
+ onAction: (e) => gr(b, e.key)
1445
+ }),
1446
+ /* @__PURE__ */ p(r, {
1447
+ mode: "menu",
1448
+ open: i === "fontSize",
1449
+ title: x("editor.fontSize"),
1450
+ onClose: a,
1451
+ actions: st.map((e) => ({
1452
+ key: e.value,
1453
+ text: e.label
1454
+ })),
1455
+ onAction: (e) => _r(b, { "font-size": e.key })
1456
+ }),
1457
+ /* @__PURE__ */ p(t, {
1458
+ open: T !== null,
1459
+ onClose: () => {
1460
+ let e = w.current;
1461
+ e && O(e), a();
1462
+ },
1463
+ position: "bottom",
1464
+ children: T ? /* @__PURE__ */ p(hr, {
1465
+ mode: T,
1466
+ currentColor: E,
1467
+ customColors: S,
1468
+ onApply: D,
1469
+ onCustomDraftChange: (e) => {
1470
+ w.current = e;
1471
+ },
1472
+ onCustomConfirm: O
1473
+ }, T) : null
1474
+ }),
1475
+ /* @__PURE__ */ p(r, {
1476
+ mode: "menu",
1477
+ open: i === "ai",
1478
+ onClose: a,
1479
+ actions: [{
1480
+ key: "typeset",
1481
+ text: x("editor.aiTypeset"),
1482
+ disabled: !v,
1483
+ icon: /* @__PURE__ */ p("img", {
1484
+ src: Qn,
1485
+ alt: "",
1486
+ width: 16,
1487
+ height: 16,
1488
+ className: V["bsy-mobile-editor__ai-icon"],
1489
+ draggable: !1
1490
+ })
1491
+ }, {
1492
+ key: "polish",
1493
+ text: x("editor.aiPolish"),
1494
+ disabled: !y,
1495
+ icon: /* @__PURE__ */ p("img", {
1496
+ src: $n,
1497
+ alt: "",
1498
+ width: 16,
1499
+ height: 16,
1500
+ className: V["bsy-mobile-editor__ai-icon"],
1501
+ draggable: !1
1502
+ })
1503
+ }],
1504
+ onAction: (e) => {
1505
+ if (e.key === "typeset") {
1506
+ o();
1507
+ return;
1508
+ }
1509
+ s();
1510
+ }
1511
+ }),
1512
+ /* @__PURE__ */ p(r, {
1513
+ mode: "menu",
1514
+ open: i === "aiPreset",
1515
+ title: x("editor.aiPolish"),
1516
+ onClose: a,
1517
+ actions: dt.map((e) => ({
1518
+ key: e,
1519
+ text: x(ft[e])
1520
+ })),
1521
+ onAction: (e) => c(e.key)
1522
+ }),
1523
+ /* @__PURE__ */ p(r, {
1524
+ mode: "menu",
1525
+ open: i === "picture",
1526
+ title: x("editor.picture"),
1527
+ onClose: a,
1528
+ actions: [{
1529
+ key: "upload",
1530
+ text: x("editor.uploadImage"),
1531
+ icon: /* @__PURE__ */ p(n, {
1532
+ name: "picture",
1533
+ size: 16
1534
+ })
1535
+ }, {
1536
+ key: "url",
1537
+ text: x("editor.imageUrl"),
1538
+ icon: /* @__PURE__ */ p(n, {
1539
+ name: "Insertlink",
1540
+ size: 16
1541
+ })
1542
+ }],
1543
+ onAction: (e) => l(e.key)
1544
+ })
1545
+ ] });
1546
+ }, yr = ({ open: r, title: i, bodyClassName: a, onClose: o, onConfirm: s, children: c }) => {
1547
+ let { t: l } = e();
1548
+ return /* @__PURE__ */ p(t, {
1549
+ open: r,
1550
+ onClose: o,
1551
+ position: "bottom",
1552
+ children: /* @__PURE__ */ m("div", {
1553
+ className: V["bsy-mobile-editor__sheet"],
1554
+ children: [
1555
+ /* @__PURE__ */ m("div", {
1556
+ className: V["bsy-mobile-editor__header"],
1557
+ children: [/* @__PURE__ */ p("div", {
1558
+ className: V["bsy-mobile-editor__title"],
1559
+ children: i
1560
+ }), /* @__PURE__ */ p("button", {
1561
+ type: "button",
1562
+ className: V["bsy-mobile-editor__close"],
1563
+ "aria-label": l("popup.close"),
1564
+ onClick: o,
1565
+ children: /* @__PURE__ */ p(n, {
1566
+ name: "close",
1567
+ size: 18
1568
+ })
1569
+ })]
1570
+ }),
1571
+ /* @__PURE__ */ p("div", {
1572
+ className: [V["bsy-mobile-editor__sheet-body"], a].filter(Boolean).join(" "),
1573
+ children: c
1574
+ }),
1575
+ /* @__PURE__ */ m("div", {
1576
+ className: V["bsy-mobile-editor__sheet-bar"],
1577
+ children: [/* @__PURE__ */ p("button", {
1578
+ type: "button",
1579
+ onClick: o,
1580
+ children: l("editor.cancel")
1581
+ }), /* @__PURE__ */ p("button", {
1582
+ type: "button",
1583
+ className: V["bsy-mobile-editor__sheet-ok"],
1584
+ onClick: s,
1585
+ children: l("editor.ok")
1586
+ })]
1587
+ })
1588
+ ]
1589
+ })
1590
+ });
1591
+ }, br = ({ open: t, seed: r, onClose: i, onConfirm: a }) => {
1592
+ let { t: o } = e(), [c, l] = d(""), [u, f] = d(""), [h, g] = d(!0);
1593
+ return s(() => {
1594
+ !t || !r || (l(r.url), f(r.text), g(r.newBlank));
1595
+ }, [t, r]), /* @__PURE__ */ m(yr, {
1596
+ open: t,
1597
+ title: o("editor.link"),
1598
+ bodyClassName: V["bsy-mobile-editor__sheet-body--stack"],
1599
+ onClose: i,
1600
+ onConfirm: () => a({
1601
+ url: c,
1602
+ text: u,
1603
+ newBlank: h
1604
+ }),
1605
+ children: [
1606
+ /* @__PURE__ */ m("label", {
1607
+ className: V["bsy-mobile-editor__sheet-field"],
1608
+ children: [
1609
+ /* @__PURE__ */ p("span", {
1610
+ className: V["bsy-mobile-editor__sheet-label"],
1611
+ children: o("editor.linkUrl")
1612
+ }),
1613
+ /* @__PURE__ */ p("span", {
1614
+ className: `${V["bsy-mobile-editor__sheet-note"]} ${V["bsy-mobile-editor__sheet-note--hint"]}`,
1615
+ children: o("editor.linkAliasTip")
1616
+ }),
1617
+ /* @__PURE__ */ p("input", {
1618
+ value: c,
1619
+ placeholder: o("editor.linkTip"),
1620
+ onChange: (e) => l(e.target.value)
1621
+ })
1622
+ ]
1623
+ }),
1624
+ /* @__PURE__ */ m("label", {
1625
+ className: V["bsy-mobile-editor__sheet-field"],
1626
+ children: [/* @__PURE__ */ p("span", {
1627
+ className: V["bsy-mobile-editor__sheet-label"],
1628
+ children: o("editor.linkText")
1629
+ }), /* @__PURE__ */ p("input", {
1630
+ value: u,
1631
+ onChange: (e) => f(e.target.value)
1632
+ })]
1633
+ }),
1634
+ /* @__PURE__ */ m("label", {
1635
+ className: V["bsy-mobile-editor__check"],
1636
+ children: [
1637
+ /* @__PURE__ */ p("input", {
1638
+ className: V["bsy-mobile-editor__check-input"],
1639
+ type: "checkbox",
1640
+ checked: h,
1641
+ onChange: (e) => g(e.target.checked)
1642
+ }),
1643
+ /* @__PURE__ */ p("span", {
1644
+ className: V["bsy-mobile-editor__check-box"],
1645
+ "aria-hidden": !0,
1646
+ children: h ? /* @__PURE__ */ p(n, {
1647
+ name: "checkthebox",
1648
+ size: 12,
1649
+ color: "#fff"
1650
+ }) : null
1651
+ }),
1652
+ o("editor.linkNewBlank")
1653
+ ]
1654
+ })
1655
+ ]
1656
+ });
1657
+ }, xr = /^https?:\/\/.+/i, Sr = ({ open: t, onClose: n, onConfirm: r }) => {
1658
+ let { t: i } = e(), [o, c] = d(""), [l, u] = d(null), f = a((e) => {
1659
+ e?.focus();
1660
+ }, []);
1661
+ return s(() => {
1662
+ t && (c(""), u(null));
1663
+ }, [t]), /* @__PURE__ */ p(yr, {
1664
+ open: t,
1665
+ title: i("editor.imageUrl"),
1666
+ onClose: n,
1667
+ onConfirm: () => {
1668
+ let e = o.trim();
1669
+ if (!e) {
1670
+ u(i("editor.imageUrlRequired"));
1671
+ return;
1672
+ }
1673
+ if (!xr.test(e)) {
1674
+ u(i("editor.imageUrlInvalid"));
1675
+ return;
1676
+ }
1677
+ r(e);
1678
+ },
1679
+ children: /* @__PURE__ */ m("label", {
1680
+ className: V["bsy-mobile-editor__sheet-field"],
1681
+ children: [
1682
+ /* @__PURE__ */ p("span", {
1683
+ className: V["bsy-mobile-editor__sheet-label"],
1684
+ children: i("editor.enterImageUrl")
1685
+ }),
1686
+ /* @__PURE__ */ p("span", {
1687
+ className: V["bsy-mobile-editor__sheet-note"],
1688
+ children: i("editor.imageUrlNote")
1689
+ }),
1690
+ /* @__PURE__ */ p("input", {
1691
+ ref: f,
1692
+ value: o,
1693
+ placeholder: i("editor.imageUrlPlaceholder"),
1694
+ "aria-invalid": !!l,
1695
+ onChange: (e) => {
1696
+ c(e.target.value), l && u(null);
1697
+ }
1698
+ }),
1699
+ l ? /* @__PURE__ */ p("span", {
1700
+ className: V["bsy-mobile-editor__sheet-error"],
1701
+ children: l
1702
+ }) : null
1703
+ ]
1704
+ })
1705
+ });
1706
+ }, 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 }) => {
1707
+ let t = u(null);
1708
+ return l(() => {
1709
+ let n = t.current;
1710
+ if (!n) return;
1711
+ let r = n.shadowRoot ?? n.attachShadow({ mode: "open" }), i = document.createElement("div");
1712
+ i.className = "bsy-editor-html-preview__body", i.innerHTML = U(e);
1713
+ for (let e of Array.from(i.querySelectorAll("table"))) {
1714
+ if (e.parentElement?.classList.contains("editor-table-scrollable-wrapper")) continue;
1715
+ let t = document.createElement("div");
1716
+ t.className = "editor-table-scrollable-wrapper", e.replaceWith(t), t.append(e);
1717
+ }
1718
+ r.replaceChildren();
1719
+ let a = document.createElement("style");
1720
+ a.textContent = Cr, r.append(a, i);
1721
+ }, [e]), /* @__PURE__ */ p("div", {
1722
+ ref: t,
1723
+ className: "bsy-editor-html-preview"
1724
+ });
1725
+ }, Tr = () => {
1726
+ let e = `${c().replace(/:/g, "")}g`;
1727
+ return /* @__PURE__ */ p("span", {
1728
+ className: V["bsy-mobile-editor__ai-think-icon"],
1729
+ "aria-hidden": "true",
1730
+ children: /* @__PURE__ */ m("svg", {
1731
+ xmlns: "http://www.w3.org/2000/svg",
1732
+ width: "16",
1733
+ height: "16",
1734
+ viewBox: "0 0 16 16",
1735
+ fill: "none",
1736
+ children: [/* @__PURE__ */ p("path", {
1737
+ 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",
1738
+ fill: `url(#${e})`
1739
+ }), /* @__PURE__ */ p("defs", { children: /* @__PURE__ */ m("linearGradient", {
1740
+ id: e,
1741
+ x1: "8.00059",
1742
+ y1: "1",
1743
+ x2: "8.00059",
1744
+ y2: "14.8072",
1745
+ gradientUnits: "userSpaceOnUse",
1746
+ children: [
1747
+ /* @__PURE__ */ p("stop", { stopColor: "#0265FF" }),
1748
+ /* @__PURE__ */ p("stop", {
1749
+ offset: "1",
1750
+ stopColor: "#A6FFFF"
1751
+ }),
1752
+ /* @__PURE__ */ p("animateTransform", {
1753
+ attributeName: "gradientTransform",
1754
+ type: "rotate",
1755
+ from: "0 8 8",
1756
+ to: "360 8 8",
1757
+ dur: "1.8s",
1758
+ repeatCount: "indefinite"
1759
+ })
1760
+ ]
1761
+ }) })]
1762
+ })
1763
+ });
1764
+ }, Er = (t, n, r) => {
1765
+ 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]);
1766
+ return s(() => {
1767
+ if (!o) {
1768
+ g.current === null && (g.current = Math.max(1, Math.round((Date.now() - m.current) / 1e3)), p(g.current)), l(!1);
1769
+ return;
1770
+ }
1771
+ m.current = Date.now(), g.current = null, l(!0), _.current = !1, v.current = !1;
1772
+ let e = window.setInterval(() => {
1773
+ p(Math.max(1, Math.round((Date.now() - m.current) / 1e3)));
1774
+ }, 500);
1775
+ return () => window.clearInterval(e);
1776
+ }, [o]), h("pointerdown", () => {
1777
+ v.current = !0;
1778
+ }, {
1779
+ target: b,
1780
+ passive: !0,
1781
+ enable: o
1782
+ }), h("scroll", () => {
1783
+ let e = r.current;
1784
+ !e || !v.current || (v.current = !1, e.scrollHeight - e.scrollTop - e.clientHeight > 8 && (_.current = !0));
1785
+ }, {
1786
+ target: b,
1787
+ passive: !0,
1788
+ enable: o
1789
+ }), s(() => {
1790
+ if (!o || _.current || !r.current) return;
1791
+ let e = window.requestAnimationFrame(() => {
1792
+ if (_.current) return;
1793
+ let e = r.current;
1794
+ e && e.scrollHeight - e.scrollTop - e.clientHeight > 1 && (e.scrollTop = e.scrollHeight);
1795
+ });
1796
+ return () => window.cancelAnimationFrame(e);
1797
+ }, [
1798
+ y,
1799
+ r,
1800
+ o
1801
+ ]), {
1802
+ visible: (o || !!y) && !(t.status === "error" && !y),
1803
+ thinking: o,
1804
+ open: o || c,
1805
+ label: o ? i("editor.aiThinking") : i("editor.aiThoughtSeconds", { seconds: f }),
1806
+ reasoning: y,
1807
+ toggle: () => l((e) => !e)
1808
+ };
1809
+ }, Dr = ({ model: e }) => /* @__PURE__ */ m("button", {
1810
+ type: "button",
1811
+ className: V["bsy-mobile-editor__ai-think-head"],
1812
+ disabled: e.thinking,
1813
+ onClick: e.toggle,
1814
+ children: [e.thinking ? /* @__PURE__ */ p(Tr, {}) : /* @__PURE__ */ p(n, {
1815
+ name: "arrow-down",
1816
+ size: 12,
1817
+ className: [V["bsy-mobile-editor__ai-think-arrow"], e.open ? V["bsy-mobile-editor__ai-think-arrow--open"] : ""].filter(Boolean).join(" ")
1818
+ }), /* @__PURE__ */ p("span", {
1819
+ 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"],
1820
+ children: e.label
1821
+ })]
1822
+ }), Or = ({ model: e }) => !e.visible || !e.open || !e.reasoning ? null : /* @__PURE__ */ p("div", {
1823
+ className: V["bsy-mobile-editor__ai-think-body"],
1824
+ children: e.reasoning
1825
+ }), kr = ({ open: i, mode: a, originalHtml: o, ai: s, polishPreset: c, onClose: l, onApply: h, onPickPreset: g }) => {
1826
+ 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({
1827
+ status: x,
1828
+ reasoning: s?.reasoning
1829
+ }, w, v), E = x === "ready" && w;
1830
+ return /* @__PURE__ */ m(t, {
1831
+ open: i,
1832
+ onClose: l,
1833
+ position: "bottom",
1834
+ closeOnClickOverlay: !1,
1835
+ children: [/* @__PURE__ */ m("div", {
1836
+ className: V["bsy-mobile-editor__ai"],
1837
+ style: { height: gt },
1838
+ children: [
1839
+ /* @__PURE__ */ m("div", {
1840
+ className: V["bsy-mobile-editor__header"],
1841
+ children: [/* @__PURE__ */ p("div", {
1842
+ className: V["bsy-mobile-editor__title"],
1843
+ children: _(a === "polish" ? "editor.aiPolish" : "editor.aiTypeset")
1844
+ }), /* @__PURE__ */ p("button", {
1845
+ type: "button",
1846
+ className: V["bsy-mobile-editor__close"],
1847
+ "aria-label": _("popup.close"),
1848
+ onClick: l,
1849
+ children: /* @__PURE__ */ p(n, {
1850
+ name: "close",
1851
+ size: 18
1852
+ })
1853
+ })]
1854
+ }),
1855
+ /* @__PURE__ */ m("div", {
1856
+ className: V["bsy-mobile-editor__ai-body"],
1857
+ children: [
1858
+ /* @__PURE__ */ m("section", {
1859
+ className: V["bsy-mobile-editor__ai-section"],
1860
+ children: [
1861
+ /* @__PURE__ */ m("div", {
1862
+ className: V["bsy-mobile-editor__ai-section-head"],
1863
+ children: [/* @__PURE__ */ m("div", {
1864
+ className: `${V["bsy-mobile-editor__ai-label"]} ${V["bsy-mobile-editor__ai-label--after"]}`,
1865
+ children: [/* @__PURE__ */ p("span", { className: V["bsy-mobile-editor__ai-dot"] }), _("editor.aiOptimized")]
1866
+ }), a === "polish" ? /* @__PURE__ */ m("button", {
1867
+ type: "button",
1868
+ className: V["bsy-mobile-editor__ai-preset"],
1869
+ onClick: () => b(!0),
1870
+ children: [_(ft[c]), /* @__PURE__ */ p(n, {
1871
+ name: "arrow-down",
1872
+ size: 16
1873
+ })]
1874
+ }) : null]
1875
+ }),
1876
+ T.visible ? /* @__PURE__ */ p("div", {
1877
+ className: V["bsy-mobile-editor__ai-think-pin"],
1878
+ children: /* @__PURE__ */ p(Dr, { model: T })
1879
+ }) : null,
1880
+ /* @__PURE__ */ p("div", {
1881
+ ref: v,
1882
+ className: V["bsy-mobile-editor__ai-section-scroll"],
1883
+ children: x === "error" ? /* @__PURE__ */ p("p", {
1884
+ className: V["bsy-mobile-editor__ai-error"],
1885
+ children: s?.errorMessage || _("editor.aiError")
1886
+ }) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(Or, { model: T }), w ? /* @__PURE__ */ p(wr, { html: C }) : null] })
1887
+ })
1888
+ ]
1889
+ }),
1890
+ /* @__PURE__ */ p("div", { className: V["bsy-mobile-editor__ai-split"] }),
1891
+ /* @__PURE__ */ m("section", {
1892
+ className: V["bsy-mobile-editor__ai-section"],
1893
+ children: [/* @__PURE__ */ p("div", {
1894
+ className: V["bsy-mobile-editor__ai-section-head"],
1895
+ children: /* @__PURE__ */ m("div", {
1896
+ className: `${V["bsy-mobile-editor__ai-label"]} ${V["bsy-mobile-editor__ai-label--before"]}`,
1897
+ children: [/* @__PURE__ */ p("span", { className: V["bsy-mobile-editor__ai-dot"] }), _("editor.aiOriginal")]
1898
+ })
1899
+ }), /* @__PURE__ */ p("div", {
1900
+ className: V["bsy-mobile-editor__ai-section-scroll"],
1901
+ children: /* @__PURE__ */ p(wr, { html: o })
1902
+ })]
1903
+ })
1904
+ ]
1905
+ }),
1906
+ /* @__PURE__ */ m("div", {
1907
+ className: V["bsy-mobile-editor__ai-footer"],
1908
+ children: [/* @__PURE__ */ p("button", {
1909
+ type: "button",
1910
+ onClick: l,
1911
+ children: _("editor.aiAbandon")
1912
+ }), /* @__PURE__ */ p("button", {
1913
+ type: "button",
1914
+ className: V["bsy-mobile-editor__ai-footer-ok"],
1915
+ disabled: !E,
1916
+ onClick: h,
1917
+ children: _("editor.aiApply")
1918
+ })]
1919
+ })
1920
+ ]
1921
+ }), a === "polish" ? /* @__PURE__ */ p(r, {
1922
+ mode: "menu",
1923
+ open: y,
1924
+ title: _("editor.aiPolish"),
1925
+ onClose: () => b(!1),
1926
+ actions: dt.map((e) => ({
1927
+ key: e,
1928
+ text: _(ft[e])
1929
+ })),
1930
+ onAction: (e) => g(e.key)
1931
+ }) : null]
1932
+ });
1933
+ }, 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 = {
1934
+ fontColor: {
1935
+ path: Ar,
1936
+ clipHeight: Mr,
1937
+ x: 128,
1938
+ width: 768,
1939
+ rx: 0
1940
+ },
1941
+ fill: {
1942
+ path: jr,
1943
+ clipHeight: 816,
1944
+ x: 112,
1945
+ width: 800,
1946
+ rx: 8
1947
+ }
1948
+ }, Ir = (e, t) => {
1949
+ let n = t.trim().toLowerCase();
1950
+ if (e === "fill") return !n || n === "transparent" || Pr.test(n);
1951
+ let r = n.replace(/\s+/g, "");
1952
+ 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)";
1953
+ }, Lr = ({ variant: e, barColor: t, size: n }) => {
1954
+ let r = `${c().replace(/:/g, "")}clip`, i = Fr[e];
1955
+ return /* @__PURE__ */ m("svg", {
1956
+ width: n,
1957
+ height: n,
1958
+ viewBox: "0 0 1024 1024",
1959
+ "aria-hidden": "true",
1960
+ children: [
1961
+ /* @__PURE__ */ p("defs", { children: /* @__PURE__ */ p("clipPath", {
1962
+ id: r,
1963
+ children: /* @__PURE__ */ p("rect", {
1964
+ x: 0,
1965
+ y: 0,
1966
+ width: 1024,
1967
+ height: i.clipHeight
1968
+ })
1969
+ }) }),
1970
+ /* @__PURE__ */ p("path", {
1971
+ d: i.path,
1972
+ fill: "currentColor",
1973
+ clipPath: `url(#${r})`
1974
+ }),
1975
+ /* @__PURE__ */ p("rect", {
1976
+ x: i.x,
1977
+ y: Mr,
1978
+ width: i.width,
1979
+ height: Nr,
1980
+ rx: i.rx,
1981
+ fill: Ir(e, t) ? "currentColor" : t
1982
+ })
1983
+ ]
1984
+ });
1985
+ }, Rr = {
1986
+ bold: !1,
1987
+ italic: !1,
1988
+ underline: !1,
1989
+ strikethrough: !1,
1990
+ fontColor: ct,
1991
+ backgroundColor: lt,
1992
+ align: "left",
1993
+ listType: !1,
1994
+ canOutdent: !1,
1995
+ headingTag: !1,
1996
+ hasRangeSelection: !1,
1997
+ hasEditorText: !1
1998
+ }, zr = (e) => e === "center" || e === "right" || e === "left" ? e : e === "end" ? "right" : "left", Br = (e) => {
1999
+ let t = !!F().getTextContent().trim(), n = {
2000
+ ...Rr,
2001
+ hasEditorText: t
2002
+ };
2003
+ if (!e) return n;
2004
+ let r = I();
2005
+ if (!L(r)) return n;
2006
+ let i = it(r, "color", ct), a = it(r, "background-color", lt), o = r.anchor.getNode(), s = o.getKey() === "root" ? o : B(o, (e) => {
2007
+ let t = e.getParent();
2008
+ return t !== null && we(t);
2009
+ });
2010
+ s === null && (s = o.getTopLevelElementOrThrow());
2011
+ let c = B(o, S), l = !1, u = Se(s) ? s.getIndent() : 0;
2012
+ if (S(c)) {
2013
+ u = c.getIndent();
2014
+ let e = c.getParent();
2015
+ if (C(e)) {
2016
+ let t = e.getListType();
2017
+ l = t === "number" || t === "bullet" ? t : !1;
2018
+ }
2019
+ }
2020
+ let d = B(o, ie), f = ie(d) ? d.getTag() : void 0;
2021
+ return {
2022
+ bold: r.hasFormat("bold"),
2023
+ italic: r.hasFormat("italic"),
2024
+ underline: r.hasFormat("underline"),
2025
+ strikethrough: r.hasFormat("strikethrough"),
2026
+ fontColor: i,
2027
+ backgroundColor: a,
2028
+ align: zr(Se(s) ? s.getFormatType() : ""),
2029
+ listType: l,
2030
+ canOutdent: u > 0 || l !== !1,
2031
+ headingTag: f === "h1" || f === "h2" || f === "h3" ? f : !1,
2032
+ hasRangeSelection: !0,
2033
+ hasEditorText: t
2034
+ };
2035
+ }, Vr = (e, t) => {
2036
+ e.isEditable() || e.setEditable(!0), e.update(() => {
2037
+ xt(), t(Br(!0));
2038
+ }), e.focus(void 0, { defaultSelection: "rootStart" });
2039
+ }, Hr = (e) => {
2040
+ let t = Rr;
2041
+ return Vr(e, (e) => {
2042
+ t = e;
2043
+ }), t;
2044
+ }, Ur = (...e) => e.filter(Boolean).join(" "), Wr = (e) => e.buttons.map((e) => ({
2045
+ name: typeof e == "string" ? e : e.name,
2046
+ disabled: typeof e != "string" && !!e.props?.disabled
2047
+ })), Q = 24, Gr = 20, $ = ({ active: e, disabled: t, expanded: n, label: r, select: i, selectAlign: a, onClick: o, children: s }) => /* @__PURE__ */ p("button", {
2048
+ type: "button",
2049
+ 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"]),
2050
+ "aria-label": r,
2051
+ "aria-pressed": e,
2052
+ "aria-expanded": i ? !!n : void 0,
2053
+ disabled: t,
2054
+ onMouseDown: (e) => e.preventDefault(),
2055
+ onClick: o,
2056
+ children: s
2057
+ }), Kr = ({ open: e }) => /* @__PURE__ */ p(n, {
2058
+ name: "arrow-down",
2059
+ size: Gr,
2060
+ className: Ur(V["bsy-mobile-editor__tool-caret"], e && V["bsy-mobile-editor__tool-caret--open"])
2061
+ }), qr = ({ config: t, formats: r, colorValues: i, openSheet: a, onOpenSheet: o, onOpenLink: c }) => {
2062
+ let [l] = z(), { t: d } = e(), f = u(null), h = u(null), g = u(null), _ = () => {
2063
+ let e = f.current, t = h.current, n = g.current;
2064
+ if (!e || !t || !n) return;
2065
+ 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;
2066
+ t.hidden = !o, o && (n.style.width = `${s}px`, n.style.transform = `translateX(${l}px)`);
2067
+ };
2068
+ s(() => {
2069
+ let e = f.current;
2070
+ if (!e) return;
2071
+ _();
2072
+ let t = new ResizeObserver(_);
2073
+ return t.observe(e), () => t.disconnect();
2074
+ }, [t]);
2075
+ let v = ({ name: e, disabled: t }) => {
2076
+ switch (e) {
2077
+ case "bold": return /* @__PURE__ */ p($, {
2078
+ active: r.bold,
2079
+ disabled: t,
2080
+ label: d("editor.bold"),
2081
+ onClick: () => {
2082
+ H(l), l.dispatchCommand(Ie, "bold");
2083
+ },
2084
+ children: /* @__PURE__ */ p(n, {
2085
+ name: "bold",
2086
+ size: Q
2087
+ })
2088
+ }, e);
2089
+ case "italic": return /* @__PURE__ */ p($, {
2090
+ active: r.italic,
2091
+ disabled: t,
2092
+ label: d("editor.italic"),
2093
+ onClick: () => {
2094
+ H(l), l.dispatchCommand(Ie, "italic");
2095
+ },
2096
+ children: /* @__PURE__ */ p(n, {
2097
+ name: "italic",
2098
+ size: Q
2099
+ })
2100
+ }, e);
2101
+ case "underline": return /* @__PURE__ */ p($, {
2102
+ active: r.underline,
2103
+ disabled: t,
2104
+ label: d("editor.underline"),
2105
+ onClick: () => {
2106
+ H(l), l.dispatchCommand(Ie, "underline");
2107
+ },
2108
+ children: /* @__PURE__ */ p(n, {
2109
+ name: "underline",
2110
+ size: Q
2111
+ })
2112
+ }, e);
2113
+ case "strikethrough": return /* @__PURE__ */ p($, {
2114
+ active: r.strikethrough,
2115
+ disabled: t,
2116
+ label: d("editor.strikethrough"),
2117
+ onClick: () => {
2118
+ H(l), l.dispatchCommand(Ie, "strikethrough");
2119
+ },
2120
+ children: /* @__PURE__ */ p(n, {
2121
+ name: "shanchuxian",
2122
+ size: Q
2123
+ })
2124
+ }, e);
2125
+ case "outdent": return /* @__PURE__ */ p($, {
2126
+ disabled: t || r.hasRangeSelection && !r.canOutdent,
2127
+ label: d("editor.outdent"),
2128
+ onClick: () => {
2129
+ H(l), l.dispatchCommand(Ve, void 0);
2130
+ },
2131
+ children: /* @__PURE__ */ p(n, {
2132
+ name: "jianshaosuojin",
2133
+ size: Q
2134
+ })
2135
+ }, e);
2136
+ case "indent": return /* @__PURE__ */ p($, {
2137
+ disabled: t,
2138
+ label: d("editor.indent"),
2139
+ onClick: () => {
2140
+ H(l), l.dispatchCommand(Re, void 0);
2141
+ },
2142
+ children: /* @__PURE__ */ p(n, {
2143
+ name: "zengjiasuojin",
2144
+ size: Q
2145
+ })
2146
+ }, e);
2147
+ case "bullet": return /* @__PURE__ */ p($, {
2148
+ active: r.listType === "bullet",
2149
+ disabled: t,
2150
+ label: d("editor.bulletList"),
2151
+ onClick: () => {
2152
+ let e = Hr(l);
2153
+ l.dispatchCommand(e.listType === "bullet" ? O : T, void 0);
2154
+ },
2155
+ children: /* @__PURE__ */ p(n, {
2156
+ name: "xuhaoliebiao",
2157
+ size: Q
2158
+ })
2159
+ }, e);
2160
+ case "number": return /* @__PURE__ */ p($, {
2161
+ active: r.listType === "number",
2162
+ disabled: t,
2163
+ label: d("editor.numberList"),
2164
+ onClick: () => {
2165
+ let e = Hr(l);
2166
+ l.dispatchCommand(e.listType === "number" ? O : w, void 0);
2167
+ },
2168
+ children: /* @__PURE__ */ p(n, {
2169
+ name: "bianhaoliebiao",
2170
+ size: Q
2171
+ })
2172
+ }, e);
2173
+ case "align": return /* @__PURE__ */ m($, {
2174
+ select: !0,
2175
+ selectAlign: !0,
2176
+ expanded: a === "align",
2177
+ active: a === "align",
2178
+ disabled: t,
2179
+ label: d("editor.alignment"),
2180
+ onClick: () => o("align"),
2181
+ children: [/* @__PURE__ */ p(n, {
2182
+ name: r.align === "center" ? "paragraphmiddle" : r.align === "right" ? "paragraphright" : "paragraph",
2183
+ size: Q
2184
+ }), /* @__PURE__ */ p(Kr, { open: a === "align" })]
2185
+ }, e);
2186
+ case "heading": return /* @__PURE__ */ m($, {
2187
+ select: !0,
2188
+ selectAlign: !0,
2189
+ expanded: a === "heading",
2190
+ active: a === "heading",
2191
+ disabled: t,
2192
+ label: d("editor.heading"),
2193
+ onClick: () => o("heading"),
2194
+ children: [/* @__PURE__ */ p("span", {
2195
+ className: V["bsy-mobile-editor__tool-text"],
2196
+ children: r.headingTag ? r.headingTag.toUpperCase() : d("editor.paragraph")
2197
+ }), /* @__PURE__ */ p(Kr, { open: a === "heading" })]
2198
+ }, e);
2199
+ case "fontSize": return /* @__PURE__ */ p($, {
2200
+ active: a === "fontSize",
2201
+ disabled: t || !!r.headingTag,
2202
+ label: d("editor.fontSize"),
2203
+ onClick: () => o("fontSize"),
2204
+ children: /* @__PURE__ */ p(n, {
2205
+ name: "fontsize",
2206
+ size: Q
2207
+ })
2208
+ }, e);
2209
+ case "fontColor": return /* @__PURE__ */ p($, {
2210
+ active: a === "fontColor",
2211
+ disabled: t,
2212
+ label: d("editor.fontColor"),
2213
+ onClick: () => o("fontColor"),
2214
+ children: /* @__PURE__ */ p(Lr, {
2215
+ variant: "fontColor",
2216
+ barColor: i.fontColor,
2217
+ size: Q
2218
+ })
2219
+ }, e);
2220
+ case "fill": return /* @__PURE__ */ p($, {
2221
+ active: a === "fill",
2222
+ disabled: t,
2223
+ label: d("editor.fill"),
2224
+ onClick: () => o("fill"),
2225
+ children: /* @__PURE__ */ p(Lr, {
2226
+ variant: "fill",
2227
+ barColor: i.fill,
2228
+ size: Q
2229
+ })
2230
+ }, e);
2231
+ case "picture": return /* @__PURE__ */ m($, {
2232
+ select: !0,
2233
+ expanded: a === "picture",
2234
+ active: a === "picture",
2235
+ disabled: t,
2236
+ label: d("editor.picture"),
2237
+ onClick: () => o("picture"),
2238
+ children: [/* @__PURE__ */ p(n, {
2239
+ name: "picture",
2240
+ size: Q
2241
+ }), /* @__PURE__ */ p(Kr, { open: a === "picture" })]
2242
+ }, e);
2243
+ case "link": return /* @__PURE__ */ p($, {
2244
+ disabled: t,
2245
+ label: d("editor.link"),
2246
+ onClick: c,
2247
+ children: /* @__PURE__ */ p(n, {
2248
+ name: "Insertlink",
2249
+ size: Q
2250
+ })
2251
+ }, e);
2252
+ case "ai": {
2253
+ let n = a === "ai" || a === "aiPreset";
2254
+ return /* @__PURE__ */ m($, {
2255
+ select: !0,
2256
+ expanded: n,
2257
+ active: n,
2258
+ disabled: t || !r.hasEditorText,
2259
+ label: d("editor.ai"),
2260
+ onClick: () => o("ai"),
2261
+ children: [/* @__PURE__ */ p("img", {
2262
+ src: Qn,
2263
+ alt: "",
2264
+ width: Q,
2265
+ height: Q,
2266
+ className: V["bsy-mobile-editor__ai-icon"],
2267
+ draggable: !1
2268
+ }), /* @__PURE__ */ p(Kr, { open: n })]
2269
+ }, e);
2270
+ }
2271
+ default: return null;
2272
+ }
2273
+ };
2274
+ return /* @__PURE__ */ m("div", {
2275
+ className: V["bsy-mobile-editor__toolbar"],
2276
+ children: [/* @__PURE__ */ p("div", {
2277
+ ref: f,
2278
+ className: V["bsy-mobile-editor__toolbar-scroller"],
2279
+ onScroll: _,
2280
+ children: t.map((e, t) => {
2281
+ let n = Wr(e);
2282
+ return n.length ? /* @__PURE__ */ m("div", {
2283
+ className: V["bsy-mobile-editor__toolbar-group"],
2284
+ children: [t > 0 ? /* @__PURE__ */ p("span", { className: V["bsy-mobile-editor__toolbar-divider"] }) : null, n.map(v)]
2285
+ }, e.key) : null;
2286
+ })
2287
+ }), /* @__PURE__ */ p("div", {
2288
+ ref: h,
2289
+ className: V["bsy-mobile-editor__toolbar-track"],
2290
+ hidden: !0,
2291
+ "aria-hidden": !0,
2292
+ children: /* @__PURE__ */ p("div", {
2293
+ ref: g,
2294
+ className: V["bsy-mobile-editor__toolbar-thumb"]
2295
+ })
2296
+ })]
2297
+ });
2298
+ }, Jr = () => {
2299
+ let [e] = z(), [t, n] = d(!1);
2300
+ return s(() => rt(e.registerCommand(Pe, () => (n(!0), !1), je), e.registerCommand(ke, () => (n(!1), !1), je)), [e]), t;
2301
+ }, Yr = () => {
2302
+ let [e] = z(), t = Jr(), [n, r] = d(Rr);
2303
+ return s(() => (e.getEditorState().read(() => {
2304
+ r(Br(t));
2305
+ }, { editor: e }), e.registerUpdateListener(({ editorState: n }) => {
2306
+ n.read(() => {
2307
+ r(Br(t));
2308
+ }, { editor: e });
2309
+ })), [e, t]), n;
2310
+ }, Xr = "plaintext", Zr = "github-light", Qr = new Set([
2311
+ "plaintext",
2312
+ "css",
2313
+ "html",
2314
+ "xml",
2315
+ "javascript",
2316
+ "typescript",
2317
+ "jsx",
2318
+ "go",
2319
+ "php",
2320
+ "c",
2321
+ "python",
2322
+ "java",
2323
+ "cpp",
2324
+ "csharp",
2325
+ "vb",
2326
+ "sql",
2327
+ "ruby",
2328
+ "swift",
2329
+ "bash",
2330
+ "lua",
2331
+ "markdown"
2332
+ ]), $r = (e) => e && Qr.has(e) ? e : Xr, ei = {
2333
+ css: () => import("@shikijs/langs/css"),
2334
+ html: () => import("@shikijs/langs/html"),
2335
+ xml: () => import("@shikijs/langs/xml"),
2336
+ javascript: () => import("@shikijs/langs/javascript"),
2337
+ typescript: () => import("@shikijs/langs/typescript"),
2338
+ jsx: () => import("@shikijs/langs/jsx"),
2339
+ go: () => import("@shikijs/langs/go"),
2340
+ php: () => import("@shikijs/langs/php"),
2341
+ c: () => import("@shikijs/langs/c"),
2342
+ python: () => import("@shikijs/langs/python"),
2343
+ java: () => import("@shikijs/langs/java"),
2344
+ cpp: () => import("@shikijs/langs/cpp"),
2345
+ csharp: () => import("@shikijs/langs/csharp"),
2346
+ vb: () => import("@shikijs/langs/vb"),
2347
+ sql: () => import("@shikijs/langs/sql"),
2348
+ ruby: () => import("@shikijs/langs/ruby"),
2349
+ swift: () => import("@shikijs/langs/swift"),
2350
+ bash: () => import("@shikijs/langs/shellscript"),
2351
+ lua: () => import("@shikijs/langs/lua"),
2352
+ markdown: () => import("@shikijs/langs/markdown")
2353
+ }, 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({
2354
+ engine: t(),
2355
+ langs: [],
2356
+ themes: []
2357
+ })).catch((e) => {
2358
+ throw ri = null, e;
2359
+ }), ri), si = (e, t) => ni(t) && e.getLoadedLanguages().includes(ti(t)), ci = (e) => {
2360
+ let t = ai.get(e);
2361
+ return t || (t = oi().then(async (t) => {
2362
+ let n = ti(e);
2363
+ if (!t.getLoadedLanguages().includes(n)) {
2364
+ let n = await ei[e]();
2365
+ await t.loadLanguage(n.default);
2366
+ }
2367
+ return t;
2368
+ }).catch((t) => {
2369
+ throw ai.delete(e), t;
2370
+ }), ai.set(e, t)), t;
2371
+ }, li = () => (ii ||= oi().then(async (e) => {
2372
+ if (!e.getLoadedThemes().includes("github-light")) {
2373
+ let t = await import("@shikijs/themes/github-light");
2374
+ await e.loadTheme(t.default);
2375
+ }
2376
+ return e;
2377
+ }).catch((e) => {
2378
+ throw ii = null, e;
2379
+ }), ii), ui = (e, t, n) => {
2380
+ let r = e.getTextContent();
2381
+ if (e.getStyle() && e.setStyle(""), !n || !si(n, t)) return ee(r);
2382
+ let i = n.codeToTokens(r, {
2383
+ lang: ti(t),
2384
+ theme: Zr
2385
+ }).tokens, a = [];
2386
+ return i.forEach((e, t) => {
2387
+ t && a.push(_e()), e.forEach((e) => {
2388
+ e.content.split(" ").forEach((t, n) => {
2389
+ if (n && a.push(ve()), !t) return;
2390
+ 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}` : "";
2391
+ i && r.setStyle(i), a.push(r);
2392
+ });
2393
+ });
2394
+ }), a;
2395
+ }, di = (e, t) => {
2396
+ let n = be(e);
2397
+ if (!j(n) || !n.isAttached()) return;
2398
+ let r = I();
2399
+ if (!L(r)) {
2400
+ t();
2401
+ return;
2402
+ }
2403
+ let { anchor: i } = r;
2404
+ if (B(i.getNode(), j) !== n) {
2405
+ t();
2406
+ return;
2407
+ }
2408
+ let a = i.offset, o = i.type === "element" && Ce(n.getChildAtIndex(i.offset - 1)), s = 0;
2409
+ if (o || (s = a + i.getNode().getPreviousSiblings().reduce((e, t) => e + t.getTextContentSize(), 0)), t()) {
2410
+ if (o) {
2411
+ i.getNode().select(a, a);
2412
+ return;
2413
+ }
2414
+ n.getChildren().some((e) => {
2415
+ let t = Ee(e);
2416
+ if (t || Ce(e)) {
2417
+ let n = e.getTextContentSize();
2418
+ if (t && n >= s) return e.select(s, s), !0;
2419
+ s -= n;
2420
+ }
2421
+ return !1;
2422
+ });
2423
+ }
2424
+ }, 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) => {
2425
+ let n = 0;
2426
+ for (; n < e.length && fi(e[n], t[n]);) n++;
2427
+ let r = 0, i = Math.min(e.length, t.length) - n;
2428
+ for (; r < i && fi(e[e.length - r - 1], t[t.length - r - 1]);) r++;
2429
+ return {
2430
+ from: n,
2431
+ to: e.length - r,
2432
+ replacement: t.slice(n, t.length - r)
2433
+ };
2434
+ }, mi = (e, t, n, r, i) => {
2435
+ let a = i.getKey(), o = $r(i.getLanguage());
2436
+ if (i.getLanguage() !== o && i.setLanguage(o), o === "plaintext") i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1);
2437
+ else {
2438
+ i.getTheme() !== "github-light" && i.setTheme(Zr);
2439
+ let s = t ? t.getLoadedThemes().includes("github-light") ? ni(o) && !si(t, o) ? ci(o) : null : li() : oi();
2440
+ if (s) {
2441
+ i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1), n.pendingKeys.add(a), n.loading !== s && (n.loading = s, s.then((t) => {
2442
+ r(t);
2443
+ let i = [...n.pendingKeys];
2444
+ n.pendingKeys.clear(), n.loading = null, e.update(() => i.forEach((e) => be(e)?.markDirty()), { tag: Le });
2445
+ }, () => {
2446
+ n.pendingKeys.clear(), n.loading = null;
2447
+ }));
2448
+ return;
2449
+ }
2450
+ i.getIsSyntaxHighlightSupported() || i.setIsSyntaxHighlightSupported(!0);
2451
+ }
2452
+ n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0, Oe(() => {
2453
+ n.didTransform = !1, n.nodesCurrentlyHighlighting.clear();
2454
+ })), di(a, () => {
2455
+ let e = be(a);
2456
+ if (!j(e) || !e.isAttached()) return !1;
2457
+ let n = ui(e, $r(e.getLanguage()), t), { from: r, to: i, replacement: o } = pi(e.getChildren(), n);
2458
+ return r === i && o.length === 0 ? !1 : (e.splice(r, i - r, o), !0);
2459
+ }));
2460
+ }, hi = () => {
2461
+ let [e] = z();
2462
+ return s(() => {
2463
+ if (!e.hasNodes([M, te])) throw Error("CodeHighlightPlugin: code nodes are not registered");
2464
+ let t = null, n = {
2465
+ didTransform: !1,
2466
+ nodesCurrentlyHighlighting: /* @__PURE__ */ new Set(),
2467
+ pendingKeys: /* @__PURE__ */ new Set(),
2468
+ loading: null
2469
+ }, r = (r) => mi(e, t, n, (e) => {
2470
+ t = e;
2471
+ }, r), i = (e) => {
2472
+ let t = e.getParent();
2473
+ j(t) ? r(t) : A(e) && e.replace(ye(e.__text));
2474
+ };
2475
+ return Ke(ne(e), e.registerNodeTransform(M, r), e.registerNodeTransform(We, i), e.registerNodeTransform(te, i));
2476
+ }, [e]), null;
2477
+ }, gi = () => {
2478
+ let [e] = z();
2479
+ return s(() => (he(e, !0), rt(pe(e), me(e, !1), fe(e), e.registerNodeTransform(le, (e) => {
2480
+ e.getBackgroundColor() !== null && e.setBackgroundColor(null);
2481
+ }), e.registerCommand(Be, (e) => {
2482
+ let t = I();
2483
+ if (!L(t) || !t.isCollapsed()) return !1;
2484
+ let n = oe(t.anchor.getNode());
2485
+ if (n === null) return !1;
2486
+ let r = e.shiftKey ? "previous" : "next", i = r === "next" ? "getNextSibling" : "getPreviousSibling", a = r === "next" ? "getFirstChild" : "getLastChild", o = n[i](), s = null;
2487
+ if (se(o)) s = o;
2488
+ else {
2489
+ let e = B(n, ce);
2490
+ if (e !== null) for (let t = e[i](); t !== null; t = t[i]()) {
2491
+ if (!ce(t)) continue;
2492
+ let e = t[a]();
2493
+ if (se(e)) {
2494
+ s = e;
2495
+ break;
2496
+ }
2497
+ }
2498
+ }
2499
+ if (e.preventDefault(), s) {
2500
+ let e = s.getFirstDescendant();
2501
+ e ? e.selectStart() : s.selectStart();
2502
+ } else {
2503
+ let e = B(n, N);
2504
+ e && (r === "next" ? e.selectNext() : e.selectPrevious());
2505
+ }
2506
+ return !0;
2507
+ }, Ae))), [e]), null;
2508
+ }, _i = ({ value: n, onChange: r, open: i, onOpenChange: a, toolbar: o, upload: c, ai: l }) => {
2509
+ let [f] = z(), { t: h } = e(), g = Yr(), [_, v] = d(!1), y = i ?? _, b = (e) => {
2510
+ a?.(e), i === void 0 && v(e);
2511
+ }, [x, S] = d(null), [C, w] = d(() => ({
2512
+ fontColor: g.fontColor,
2513
+ fill: g.backgroundColor
2514
+ })), T = u(!1), [E, D] = d(!1), O = u(null), k = () => {
2515
+ f.getEditorState().read(() => {
2516
+ O.current = I()?.clone() ?? null;
2517
+ });
2518
+ }, { linkForm: A, openLink: j, confirmLink: ee, closeLink: te } = Hn({
2519
+ editor: f,
2520
+ savedSelectionRef: O,
2521
+ captureSelection: k
2522
+ }), [M] = d(() => /* @__PURE__ */ new Map()), { fileInputRef: ne, uploadProgress: re, insertImage: ie, onFileChange: ae, abortUpload: oe } = Vn({
2523
+ editor: f,
2524
+ upload: c,
2525
+ savedSelectionRef: O,
2526
+ attachmentsBySrc: M
2527
+ }), se = Un({
2528
+ editor: f,
2529
+ value: n,
2530
+ onChange: r,
2531
+ attachmentsBySrc: M
2532
+ }), N = An({
2533
+ editor: f,
2534
+ ai: l
2535
+ }), [ce, le] = d(0), ue = o?.config ?? pt;
2536
+ s(() => {
2537
+ !g.hasRangeSelection || !g.hasEditorText || w({
2538
+ fontColor: g.fontColor,
2539
+ fill: g.backgroundColor
2540
+ });
2541
+ }, [
2542
+ g.backgroundColor,
2543
+ g.fontColor,
2544
+ g.hasEditorText,
2545
+ g.hasRangeSelection
2546
+ ]);
2547
+ let de = () => {
2548
+ oe(), N.close(), S(null), te(), D(!1), b(!1);
2549
+ };
2550
+ s(() => {
2551
+ if (!y) return;
2552
+ let e = window.visualViewport;
2553
+ if (!e) return;
2554
+ let t = () => {
2555
+ le(Math.max(0, window.innerHeight - e.height - e.offsetTop));
2556
+ };
2557
+ return e.addEventListener("resize", t), e.addEventListener("scroll", t), t(), () => {
2558
+ e.removeEventListener("resize", t), e.removeEventListener("scroll", t);
2559
+ };
2560
+ }, [y]), s(() => {
2561
+ y || oe();
2562
+ }, [oe, y]), s(() => {
2563
+ if (y) return f.setEditable(!0), f.registerRootListener((e) => {
2564
+ e && f.focus(void 0, { defaultSelection: "rootEnd" });
2565
+ });
2566
+ }, [y, f]);
2567
+ let fe = () => {
2568
+ T.current = !0, S(null), N.startTypeset();
2569
+ }, pe = (e) => {
2570
+ x === "aiPreset" && (T.current = !0), S(null), N.startPolish(e);
2571
+ };
2572
+ return /* @__PURE__ */ p(t, {
2573
+ open: y,
2574
+ onClose: de,
2575
+ position: "bottom",
2576
+ closeOnClickOverlay: !0,
2577
+ children: /* @__PURE__ */ p(jn.Provider, {
2578
+ value: re,
2579
+ children: /* @__PURE__ */ m("div", {
2580
+ className: V["bsy-mobile-editor"],
2581
+ style: {
2582
+ height: 300,
2583
+ transform: ce ? `translate3d(0, -${ce}px, 0)` : void 0
2584
+ },
2585
+ children: [
2586
+ /* @__PURE__ */ p("div", {
2587
+ className: V["bsy-mobile-editor__label"],
2588
+ children: /* @__PURE__ */ p("div", {
2589
+ className: V["bsy-mobile-editor__label-text"],
2590
+ children: h("editor.title")
2591
+ })
2592
+ }),
2593
+ /* @__PURE__ */ p("div", {
2594
+ className: V["bsy-mobile-editor__content"],
2595
+ style: { height: 200 },
2596
+ children: /* @__PURE__ */ p(Qe, {
2597
+ contentEditable: /* @__PURE__ */ p(qe, { className: V["bsy-mobile-editor__editable"] }),
2598
+ ErrorBoundary: $e
2599
+ })
2600
+ }),
2601
+ ue.length > 0 ? /* @__PURE__ */ p(qr, {
2602
+ config: ue,
2603
+ formats: g,
2604
+ colorValues: C,
2605
+ openSheet: x,
2606
+ onOpenSheet: (e) => {
2607
+ (e === "fontColor" || e === "fill") && (k(), w((t) => {
2608
+ let n = e === "fill" ? g.backgroundColor : g.fontColor, r = g.hasRangeSelection && g.hasEditorText;
2609
+ return {
2610
+ ...t,
2611
+ [e]: r ? n : t[e]
2612
+ };
2613
+ })), S(e);
2614
+ },
2615
+ onOpenLink: j
2616
+ }) : null,
2617
+ /* @__PURE__ */ p(Je, {}),
2618
+ /* @__PURE__ */ p(Xe, {}),
2619
+ /* @__PURE__ */ p(Ye, {}),
2620
+ /* @__PURE__ */ p(Gn, {}),
2621
+ /* @__PURE__ */ p(Zn, {}),
2622
+ /* @__PURE__ */ p(qn, {}),
2623
+ /* @__PURE__ */ p(Yn, {}),
2624
+ /* @__PURE__ */ p(hi, {}),
2625
+ /* @__PURE__ */ p(gi, {}),
2626
+ /* @__PURE__ */ p(Ze, {
2627
+ onChange: se,
2628
+ ignoreSelectionChange: !0
2629
+ }),
2630
+ /* @__PURE__ */ p("input", {
2631
+ ref: ne,
2632
+ type: "file",
2633
+ accept: ht,
2634
+ hidden: !0,
2635
+ onChange: ae
2636
+ }),
2637
+ /* @__PURE__ */ p(vr, {
2638
+ sheet: x,
2639
+ onClose: () => {
2640
+ if (T.current) {
2641
+ T.current = !1;
2642
+ return;
2643
+ }
2644
+ S(null), window.requestAnimationFrame(() => f.focus());
2645
+ },
2646
+ onTypeset: fe,
2647
+ onPolishMenu: () => {
2648
+ T.current = !0, S("aiPreset");
2649
+ },
2650
+ onPickPreset: pe,
2651
+ savedSelectionRef: O,
2652
+ committedColors: C,
2653
+ onColorCommit: (e, t) => w((n) => ({
2654
+ ...n,
2655
+ [e]: t
2656
+ })),
2657
+ onPicture: (e) => {
2658
+ if (k(), e === "upload") {
2659
+ ne.current?.click();
2660
+ return;
2661
+ }
2662
+ T.current = !0, S(null), D(!0);
2663
+ },
2664
+ canTypeset: !!l?.typeset,
2665
+ canPolish: !!l?.polish
2666
+ }),
2667
+ /* @__PURE__ */ p(br, {
2668
+ open: A !== null,
2669
+ seed: A,
2670
+ onClose: te,
2671
+ onConfirm: ee
2672
+ }),
2673
+ /* @__PURE__ */ p(Sr, {
2674
+ open: E,
2675
+ onClose: () => D(!1),
2676
+ onConfirm: (e) => {
2677
+ ie(e, "", e), D(!1);
2678
+ }
2679
+ }),
2680
+ /* @__PURE__ */ p(kr, {
2681
+ open: N.mode !== null,
2682
+ mode: N.mode,
2683
+ originalHtml: N.snapshot.html,
2684
+ ai: l,
2685
+ polishPreset: N.preset,
2686
+ onClose: N.close,
2687
+ onApply: N.apply,
2688
+ onPickPreset: pe
2689
+ })
2690
+ ]
2691
+ })
2692
+ })
2693
+ });
2694
+ }, vi = "1px solid #d9d9d9", yi = { export: new Map([[le, (e, t) => {
2695
+ let n = t.exportDOM(e);
2696
+ return Ge(n.element) && (n.element.style.border = vi), n;
2697
+ }]]) }, bi = class e extends x {
2698
+ constructor(e = "", t = {}, n) {
2699
+ super(e, t, n);
2700
+ }
2701
+ static getType() {
2702
+ return "extended-link";
2703
+ }
2704
+ static clone(t) {
2705
+ return new e(t.__url, {
2706
+ rel: t.__rel,
2707
+ target: t.__target,
2708
+ title: t.__title
2709
+ }, t.__key);
2710
+ }
2711
+ static importJSON(e) {
2712
+ return xi().updateFromJSON(e);
2713
+ }
2714
+ sanitizeUrl(e) {
2715
+ return e.startsWith("@") ? e : super.sanitizeUrl(e);
2716
+ }
2717
+ }, xi = (e = "", t = {}) => ge(new bi(e, t)), Si = {
2718
+ namespace: "bsyLexicalEditor",
2719
+ onError: (e) => {
2720
+ console.error("Lexical error", e);
2721
+ },
2722
+ editable: !0,
2723
+ theme: {
2724
+ text: {
2725
+ bold: "editor-text-bold",
2726
+ italic: "editor-text-italic",
2727
+ underline: "editor-text-underline",
2728
+ strikethrough: "editor-text-strikethrough",
2729
+ underlineStrikethrough: "editor-text-underline-strikethrough"
2730
+ },
2731
+ list: {
2732
+ ul: "editor-list-ul",
2733
+ ol: "editor-list-ol",
2734
+ listitem: "editor-listitem",
2735
+ nested: { listitem: "editor-nested-listitem" }
2736
+ },
2737
+ heading: {
2738
+ h1: "editor-heading-h1",
2739
+ h2: "editor-heading-h2",
2740
+ h3: "editor-heading-h3"
2741
+ },
2742
+ code: "editor-code",
2743
+ link: "editor-link",
2744
+ table: "editor-table",
2745
+ tableCell: "editor-table-cell",
2746
+ tableCellHeader: "editor-table-cell-header",
2747
+ tableRow: "editor-table-row",
2748
+ tableScrollableWrapper: "editor-table-scrollable-wrapper"
2749
+ },
2750
+ html: yi,
2751
+ nodes: [
2752
+ bi,
2753
+ {
2754
+ replace: x,
2755
+ with: (e) => new bi(e.__url, {
2756
+ rel: e.__rel,
2757
+ target: e.__target,
2758
+ title: e.__title
2759
+ }),
2760
+ withKlass: bi
2761
+ },
2762
+ b,
2763
+ D,
2764
+ E,
2765
+ ae,
2766
+ M,
2767
+ te,
2768
+ ue,
2769
+ de,
2770
+ le,
2771
+ Fn,
2772
+ q,
2773
+ {
2774
+ replace: We,
2775
+ with: (e) => new q(e.__text),
2776
+ withKlass: q
2777
+ }
2778
+ ]
2779
+ }, Ci = (e) => /* @__PURE__ */ p(g, {
2780
+ initialConfig: Si,
2781
+ children: /* @__PURE__ */ p(_i, { ...e })
2782
+ });
2783
+ Ci.displayName = "BsyMobileEditor";
2784
+ //#endregion
2785
+ export { wr as n, Ci as t };