@alfadocs/ui-kit-debug 1.39.0 → 1.41.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 (201) hide show
  1. package/dist/_chunks/{ai-consent-banner-DvtaM3yg.js → ai-consent-banner-D7I2U-cz.js} +37 -36
  2. package/dist/_chunks/ai-consent-banner-D7I2U-cz.js.map +1 -0
  3. package/dist/_chunks/arrow-left-BfaGqVam.js +15 -0
  4. package/dist/_chunks/arrow-left-BfaGqVam.js.map +1 -0
  5. package/dist/_chunks/{booking-Dn3jvv3K.js → booking-D43ASl8y.js} +1109 -1103
  6. package/dist/_chunks/booking-D43ASl8y.js.map +1 -0
  7. package/dist/_chunks/{calendar-workspace-B-fUbm62.js → calendar-workspace-UllCER2k.js} +2170 -2163
  8. package/dist/_chunks/calendar-workspace-UllCER2k.js.map +1 -0
  9. package/dist/_chunks/{contact-profile-card-Zt6WNg1u.js → contact-profile-card-C0WpwpVV.js} +38 -33
  10. package/dist/_chunks/contact-profile-card-C0WpwpVV.js.map +1 -0
  11. package/dist/_chunks/editor-overlay-DwNKaI22.js +93 -0
  12. package/dist/_chunks/editor-overlay-DwNKaI22.js.map +1 -0
  13. package/dist/_chunks/format-price-DAbh61Lz.js +51 -0
  14. package/dist/_chunks/format-price-DAbh61Lz.js.map +1 -0
  15. package/dist/_chunks/help-me-write-templates-GB70jnV9.js +764 -0
  16. package/dist/_chunks/help-me-write-templates-GB70jnV9.js.map +1 -0
  17. package/dist/_chunks/{marketplace-app-shell-d2EtcUbe.js → marketplace-app-shell-D_g9BaDI.js} +2 -2
  18. package/dist/_chunks/{marketplace-app-shell-d2EtcUbe.js.map → marketplace-app-shell-D_g9BaDI.js.map} +1 -1
  19. package/dist/_chunks/{money-BY-HmKhZ.js → money-BXLBIRVO.js} +2 -2
  20. package/dist/_chunks/{money-BY-HmKhZ.js.map → money-BXLBIRVO.js.map} +1 -1
  21. package/dist/_chunks/{notes-panel-CAD1Ytcj.js → notes-panel-_diLt8Cj.js} +76 -73
  22. package/dist/_chunks/notes-panel-_diLt8Cj.js.map +1 -0
  23. package/dist/_chunks/{panel-subview-Cc2Wtt7D.js → panel-subview-PMBRPFOa.js} +49 -59
  24. package/dist/_chunks/panel-subview-PMBRPFOa.js.map +1 -0
  25. package/dist/_chunks/{practice-results-D_jjzwgf.js → practice-results-D11Zpt27.js} +50 -45
  26. package/dist/_chunks/practice-results-D11Zpt27.js.map +1 -0
  27. package/dist/_chunks/rich-text-editor-D7AKKAQ2.js +3119 -0
  28. package/dist/_chunks/rich-text-editor-D7AKKAQ2.js.map +1 -0
  29. package/dist/_chunks/{sidebar-C-Gr2LL-.js → sidebar-ClTY9lLI.js} +160 -169
  30. package/dist/_chunks/sidebar-ClTY9lLI.js.map +1 -0
  31. package/dist/_chunks/{treatment-receipt-dUm99mdn.js → treatment-receipt-DU0OewqH.js} +2 -2
  32. package/dist/_chunks/{treatment-receipt-dUm99mdn.js.map → treatment-receipt-DU0OewqH.js.map} +1 -1
  33. package/dist/_chunks/trending-up-C_luYBzS.js +15 -0
  34. package/dist/_chunks/trending-up-C_luYBzS.js.map +1 -0
  35. package/dist/_chunks/wand-sparkles-DAjKyhz7.js +27 -0
  36. package/dist/_chunks/wand-sparkles-DAjKyhz7.js.map +1 -0
  37. package/dist/agent-catalog.json +87 -1
  38. package/dist/agent-i18n/en.json +7 -0
  39. package/dist/components/_shared/format-price.d.ts +6 -0
  40. package/dist/components/_shared/format-price.d.ts.map +1 -1
  41. package/dist/components/_shared/index.d.ts +1 -1
  42. package/dist/components/_shared/index.d.ts.map +1 -1
  43. package/dist/components/ai-consent-banner/ai-consent-banner.d.ts +9 -0
  44. package/dist/components/ai-consent-banner/ai-consent-banner.d.ts.map +1 -1
  45. package/dist/components/ai-consent-banner/index.d.ts +1 -1
  46. package/dist/components/ai-consent-banner/index.d.ts.map +1 -1
  47. package/dist/components/ai-consent-banner/index.js +1 -1
  48. package/dist/components/booking/booking-types.d.ts +6 -0
  49. package/dist/components/booking/booking-types.d.ts.map +1 -1
  50. package/dist/components/booking/booking.d.ts.map +1 -1
  51. package/dist/components/booking/cascade.d.ts +6 -0
  52. package/dist/components/booking/cascade.d.ts.map +1 -1
  53. package/dist/components/booking/index.js +1 -1
  54. package/dist/components/contact-profile-card/contact-profile-card.d.ts +2 -2
  55. package/dist/components/contact-profile-card/contact-profile-card.d.ts.map +1 -1
  56. package/dist/components/contact-profile-card/index.js +1 -1
  57. package/dist/components/editor-overlay/editor-overlay.d.ts.map +1 -1
  58. package/dist/components/editor-overlay/index.js +1 -1
  59. package/dist/components/index.d.ts +1 -0
  60. package/dist/components/index.d.ts.map +1 -1
  61. package/dist/components/money/index.js +1 -1
  62. package/dist/components/notes-panel/index.d.ts +1 -0
  63. package/dist/components/notes-panel/index.d.ts.map +1 -1
  64. package/dist/components/notes-panel/index.js +1 -1
  65. package/dist/components/notes-panel/notes-panel.d.ts +8 -1
  66. package/dist/components/notes-panel/notes-panel.d.ts.map +1 -1
  67. package/dist/components/panel-subview/index.js +1 -1
  68. package/dist/components/practice-results/index.js +1 -1
  69. package/dist/components/practice-results/practice-results.d.ts +2 -1
  70. package/dist/components/practice-results/practice-results.d.ts.map +1 -1
  71. package/dist/components/rich-text-editor/editor-toolbar.d.ts +6 -1
  72. package/dist/components/rich-text-editor/editor-toolbar.d.ts.map +1 -1
  73. package/dist/components/rich-text-editor/index.d.ts +1 -1
  74. package/dist/components/rich-text-editor/index.d.ts.map +1 -1
  75. package/dist/components/rich-text-editor/index.js +1 -1
  76. package/dist/components/rich-text-editor/rich-text-editor.d.ts +122 -0
  77. package/dist/components/rich-text-editor/rich-text-editor.d.ts.map +1 -1
  78. package/dist/components/sidebar/index.js +1 -1
  79. package/dist/components/treatment-receipt/index.js +1 -1
  80. package/dist/host-compat.css +13 -1
  81. package/dist/i18n/locales/ar.d.ts +92 -11
  82. package/dist/i18n/locales/ar.d.ts.map +1 -1
  83. package/dist/i18n/locales/ar.js +94 -13
  84. package/dist/i18n/locales/ar.js.map +1 -1
  85. package/dist/i18n/locales/de.d.ts +92 -11
  86. package/dist/i18n/locales/de.d.ts.map +1 -1
  87. package/dist/i18n/locales/de.js +94 -13
  88. package/dist/i18n/locales/de.js.map +1 -1
  89. package/dist/i18n/locales/el.d.ts +92 -11
  90. package/dist/i18n/locales/el.d.ts.map +1 -1
  91. package/dist/i18n/locales/el.js +94 -13
  92. package/dist/i18n/locales/el.js.map +1 -1
  93. package/dist/i18n/locales/en.d.ts +81 -0
  94. package/dist/i18n/locales/en.d.ts.map +1 -1
  95. package/dist/i18n/locales/en.js +83 -2
  96. package/dist/i18n/locales/en.js.map +1 -1
  97. package/dist/i18n/locales/es.d.ts +92 -11
  98. package/dist/i18n/locales/es.d.ts.map +1 -1
  99. package/dist/i18n/locales/es.js +94 -13
  100. package/dist/i18n/locales/es.js.map +1 -1
  101. package/dist/i18n/locales/fr.d.ts +92 -11
  102. package/dist/i18n/locales/fr.d.ts.map +1 -1
  103. package/dist/i18n/locales/fr.js +94 -13
  104. package/dist/i18n/locales/fr.js.map +1 -1
  105. package/dist/i18n/locales/hi.d.ts +92 -11
  106. package/dist/i18n/locales/hi.d.ts.map +1 -1
  107. package/dist/i18n/locales/hi.js +94 -13
  108. package/dist/i18n/locales/hi.js.map +1 -1
  109. package/dist/i18n/locales/it.d.ts +92 -11
  110. package/dist/i18n/locales/it.d.ts.map +1 -1
  111. package/dist/i18n/locales/it.js +94 -13
  112. package/dist/i18n/locales/it.js.map +1 -1
  113. package/dist/i18n/locales/ja.d.ts +92 -11
  114. package/dist/i18n/locales/ja.d.ts.map +1 -1
  115. package/dist/i18n/locales/ja.js +94 -13
  116. package/dist/i18n/locales/ja.js.map +1 -1
  117. package/dist/i18n/locales/nl.d.ts +92 -11
  118. package/dist/i18n/locales/nl.d.ts.map +1 -1
  119. package/dist/i18n/locales/nl.js +94 -13
  120. package/dist/i18n/locales/nl.js.map +1 -1
  121. package/dist/i18n/locales/pl.d.ts +92 -11
  122. package/dist/i18n/locales/pl.d.ts.map +1 -1
  123. package/dist/i18n/locales/pl.js +94 -13
  124. package/dist/i18n/locales/pl.js.map +1 -1
  125. package/dist/i18n/locales/pt.d.ts +92 -11
  126. package/dist/i18n/locales/pt.d.ts.map +1 -1
  127. package/dist/i18n/locales/pt.js +94 -13
  128. package/dist/i18n/locales/pt.js.map +1 -1
  129. package/dist/i18n/locales/ro.d.ts +92 -11
  130. package/dist/i18n/locales/ro.d.ts.map +1 -1
  131. package/dist/i18n/locales/ro.js +94 -13
  132. package/dist/i18n/locales/ro.js.map +1 -1
  133. package/dist/i18n/locales/ru.d.ts +92 -11
  134. package/dist/i18n/locales/ru.d.ts.map +1 -1
  135. package/dist/i18n/locales/ru.js +94 -13
  136. package/dist/i18n/locales/ru.js.map +1 -1
  137. package/dist/i18n/locales/sq.d.ts +92 -11
  138. package/dist/i18n/locales/sq.d.ts.map +1 -1
  139. package/dist/i18n/locales/sq.js +94 -13
  140. package/dist/i18n/locales/sq.js.map +1 -1
  141. package/dist/i18n/locales/sv.d.ts +92 -11
  142. package/dist/i18n/locales/sv.d.ts.map +1 -1
  143. package/dist/i18n/locales/sv.js +94 -13
  144. package/dist/i18n/locales/sv.js.map +1 -1
  145. package/dist/i18n/locales/tr.d.ts +92 -11
  146. package/dist/i18n/locales/tr.d.ts.map +1 -1
  147. package/dist/i18n/locales/tr.js +94 -13
  148. package/dist/i18n/locales/tr.js.map +1 -1
  149. package/dist/i18n/locales/zh.d.ts +92 -11
  150. package/dist/i18n/locales/zh.d.ts.map +1 -1
  151. package/dist/i18n/locales/zh.js +94 -13
  152. package/dist/i18n/locales/zh.js.map +1 -1
  153. package/dist/index.js +143 -136
  154. package/dist/index.js.map +1 -1
  155. package/dist/locales/ar.json +94 -13
  156. package/dist/locales/de.json +94 -13
  157. package/dist/locales/el.json +94 -13
  158. package/dist/locales/en.json +83 -2
  159. package/dist/locales/es.json +94 -13
  160. package/dist/locales/fr.json +94 -13
  161. package/dist/locales/hi.json +94 -13
  162. package/dist/locales/it.json +94 -13
  163. package/dist/locales/ja.json +94 -13
  164. package/dist/locales/nl.json +94 -13
  165. package/dist/locales/pl.json +94 -13
  166. package/dist/locales/pt.json +94 -13
  167. package/dist/locales/ro.json +94 -13
  168. package/dist/locales/ru.json +94 -13
  169. package/dist/locales/sq.json +94 -13
  170. package/dist/locales/sv.json +94 -13
  171. package/dist/locales/tr.json +94 -13
  172. package/dist/locales/zh.json +94 -13
  173. package/dist/patterns/calendar/calendar-workspace.d.ts.map +1 -1
  174. package/dist/patterns/calendar/calendar.journey.d.ts +9 -1
  175. package/dist/patterns/calendar/calendar.journey.d.ts.map +1 -1
  176. package/dist/patterns/calendar/calendar.sheets.d.ts +6 -1
  177. package/dist/patterns/calendar/calendar.sheets.d.ts.map +1 -1
  178. package/dist/patterns/calendar/index.js +1 -1
  179. package/dist/patterns/help-me-write-templates/help-me-write-templates.d.ts +164 -0
  180. package/dist/patterns/help-me-write-templates/help-me-write-templates.d.ts.map +1 -0
  181. package/dist/patterns/help-me-write-templates/index.d.ts +3 -0
  182. package/dist/patterns/help-me-write-templates/index.d.ts.map +1 -0
  183. package/dist/patterns/help-me-write-templates/index.js +10 -0
  184. package/dist/patterns/help-me-write-templates/index.js.map +1 -0
  185. package/dist/patterns/marketplace-app-shell/index.js +1 -1
  186. package/dist/tokens.css +51 -42
  187. package/package.json +5 -1
  188. package/dist/_chunks/ai-consent-banner-DvtaM3yg.js.map +0 -1
  189. package/dist/_chunks/booking-Dn3jvv3K.js.map +0 -1
  190. package/dist/_chunks/calendar-workspace-B-fUbm62.js.map +0 -1
  191. package/dist/_chunks/contact-profile-card-Zt6WNg1u.js.map +0 -1
  192. package/dist/_chunks/editor-overlay-9tcPXNWt.js +0 -89
  193. package/dist/_chunks/editor-overlay-9tcPXNWt.js.map +0 -1
  194. package/dist/_chunks/format-price-BkMEbeW3.js +0 -47
  195. package/dist/_chunks/format-price-BkMEbeW3.js.map +0 -1
  196. package/dist/_chunks/notes-panel-CAD1Ytcj.js.map +0 -1
  197. package/dist/_chunks/panel-subview-Cc2Wtt7D.js.map +0 -1
  198. package/dist/_chunks/practice-results-D_jjzwgf.js.map +0 -1
  199. package/dist/_chunks/rich-text-editor-C6fE-uP4.js +0 -2627
  200. package/dist/_chunks/rich-text-editor-C6fE-uP4.js.map +0 -1
  201. package/dist/_chunks/sidebar-C-Gr2LL-.js.map +0 -1
@@ -0,0 +1,3119 @@
1
+ import { jsx as t, jsxs as k, Fragment as Me } from "react/jsx-runtime";
2
+ import { useId as _e, useState as A, useRef as M, useCallback as x, useEffect as I, Fragment as pt, forwardRef as Qr, useMemo as qe, useImperativeHandle as Yr } from "react";
3
+ import { c as Ot } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as ne } from "react-i18next";
5
+ import { SafeHtml as Jr, sanitiseHtml as en } from "../safe-html/index.js";
6
+ import { u as tn } from "./registry-DvAUVLHh.js";
7
+ import { S as pr } from "./spinner-hbwuKwMf.js";
8
+ import { B as pe } from "./button-CaUe1uyd.js";
9
+ import { A as rn } from "./ai-consent-banner-D7I2U-cz.js";
10
+ import { I as G } from "./icon-button-CehAeZoP.js";
11
+ import { T as nn } from "./text-area-Bt3p7Pt0.js";
12
+ import { E as br } from "./editor-overlay-DwNKaI22.js";
13
+ import { X as lr } from "./x-B5YnXwCz.js";
14
+ import { R as on } from "./rotate-ccw-BBQnIVTr.js";
15
+ import { C as an } from "./check-DrFSN__t.js";
16
+ import { S as gt } from "./square-DASBRZ0U.js";
17
+ import { M as yr } from "./mic-CUklMZGF.js";
18
+ import { S as sn } from "./send-C5kDJ-Mz.js";
19
+ import { a as vr } from "./tooltip-Cp-PLePW.js";
20
+ import { P as V } from "./popover-DO-pssF3.js";
21
+ import { D as he } from "./dropdown-menu-DU-Hrf33.js";
22
+ import { D as Z } from "./dialog-BJiLqhx6.js";
23
+ import { C as Pt } from "./color-picker-Bl5f0iK1.js";
24
+ import { T as ft } from "./text-input-CUvCb6ST.js";
25
+ import { C as ln } from "./checkbox-CZkipDn7.js";
26
+ import { F as cn } from "./file-upload-BDpb08GM.js";
27
+ import { c as R } from "./createLucideIcon-DhHxpK9K.js";
28
+ import { E as dn } from "./ellipsis-dRo9ouSU.js";
29
+ import { H as un } from "./highlighter-DSkckT2Q.js";
30
+ import { I as mn } from "./image-B_5MNK0x.js";
31
+ import { C as gn } from "./chevron-down-DWE7GSq9.js";
32
+ import { T as fn } from "./trash-2-uumy3fy1.js";
33
+ import { W as hn } from "./wand-sparkles-DAjKyhz7.js";
34
+ import { A as pn } from "./astroid-BN4f5VXU.js";
35
+ /**
36
+ * @license lucide-react v1.22.0 - ISC
37
+ *
38
+ * This source code is licensed under the ISC license.
39
+ * See the LICENSE file in the root directory of this source tree.
40
+ */
41
+ const bn = [
42
+ ["path", { d: "M4 20h16", key: "14thso" }],
43
+ ["path", { d: "m6 16 6-12 6 12", key: "1b4byz" }],
44
+ ["path", { d: "M8 12h8", key: "1wcyev" }]
45
+ ], yn = R("baseline", bn);
46
+ /**
47
+ * @license lucide-react v1.22.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */
52
+ const vn = [
53
+ ["rect", { width: "13", height: "7", x: "3", y: "3", rx: "1", key: "11xb64" }],
54
+ ["path", { d: "m22 15-3-3 3-3", key: "26chmm" }],
55
+ ["rect", { width: "13", height: "7", x: "3", y: "14", rx: "1", key: "k6ky7n" }]
56
+ ], wn = R("between-horizontal-end", vn);
57
+ /**
58
+ * @license lucide-react v1.22.0 - ISC
59
+ *
60
+ * This source code is licensed under the ISC license.
61
+ * See the LICENSE file in the root directory of this source tree.
62
+ */
63
+ const xn = [
64
+ ["rect", { width: "13", height: "7", x: "8", y: "3", rx: "1", key: "pkso9a" }],
65
+ ["path", { d: "m2 9 3 3-3 3", key: "1agib5" }],
66
+ ["rect", { width: "13", height: "7", x: "8", y: "14", rx: "1", key: "1q5fc1" }]
67
+ ], kn = R("between-horizontal-start", xn);
68
+ /**
69
+ * @license lucide-react v1.22.0 - ISC
70
+ *
71
+ * This source code is licensed under the ISC license.
72
+ * See the LICENSE file in the root directory of this source tree.
73
+ */
74
+ const Cn = [
75
+ ["rect", { width: "7", height: "13", x: "3", y: "3", rx: "1", key: "1fdu0f" }],
76
+ ["path", { d: "m9 22 3-3 3 3", key: "17z65a" }],
77
+ ["rect", { width: "7", height: "13", x: "14", y: "3", rx: "1", key: "1squn4" }]
78
+ ], Nn = R("between-vertical-end", Cn);
79
+ /**
80
+ * @license lucide-react v1.22.0 - ISC
81
+ *
82
+ * This source code is licensed under the ISC license.
83
+ * See the LICENSE file in the root directory of this source tree.
84
+ */
85
+ const Tn = [
86
+ ["rect", { width: "7", height: "13", x: "3", y: "8", rx: "1", key: "1fjrkv" }],
87
+ ["path", { d: "m15 2-3 3-3-3", key: "1uh6eb" }],
88
+ ["rect", { width: "7", height: "13", x: "14", y: "8", rx: "1", key: "w3fjg8" }]
89
+ ], An = R("between-vertical-start", Tn);
90
+ /**
91
+ * @license lucide-react v1.22.0 - ISC
92
+ *
93
+ * This source code is licensed under the ISC license.
94
+ * See the LICENSE file in the root directory of this source tree.
95
+ */
96
+ const zn = [
97
+ [
98
+ "path",
99
+ { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8", key: "mg9rjx" }
100
+ ]
101
+ ], Mn = R("bold", zn);
102
+ /**
103
+ * @license lucide-react v1.22.0 - ISC
104
+ *
105
+ * This source code is licensed under the ISC license.
106
+ * See the LICENSE file in the root directory of this source tree.
107
+ */
108
+ const _n = [
109
+ [
110
+ "path",
111
+ { d: "M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1", key: "ezmyqa" }
112
+ ],
113
+ [
114
+ "path",
115
+ {
116
+ d: "M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",
117
+ key: "e1hn23"
118
+ }
119
+ ]
120
+ ], En = R("braces", _n);
121
+ /**
122
+ * @license lucide-react v1.22.0 - ISC
123
+ *
124
+ * This source code is licensed under the ISC license.
125
+ * See the LICENSE file in the root directory of this source tree.
126
+ */
127
+ const Rn = [
128
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
129
+ ["path", { d: "M12 3v18", key: "108xh3" }]
130
+ ], Sn = R("columns-2", Rn);
131
+ /**
132
+ * @license lucide-react v1.22.0 - ISC
133
+ *
134
+ * This source code is licensed under the ISC license.
135
+ * See the LICENSE file in the root directory of this source tree.
136
+ */
137
+ const Ln = [
138
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
139
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
140
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
141
+ ["path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1", key: "9jr5yi" }]
142
+ ], In = R("heading-2", Ln);
143
+ /**
144
+ * @license lucide-react v1.22.0 - ISC
145
+ *
146
+ * This source code is licensed under the ISC license.
147
+ * See the LICENSE file in the root directory of this source tree.
148
+ */
149
+ const $n = [
150
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
151
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
152
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
153
+ ["path", { d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2", key: "68ncm8" }],
154
+ ["path", { d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2", key: "1ejuhz" }]
155
+ ], Hn = R("heading-3", $n);
156
+ /**
157
+ * @license lucide-react v1.22.0 - ISC
158
+ *
159
+ * This source code is licensed under the ISC license.
160
+ * See the LICENSE file in the root directory of this source tree.
161
+ */
162
+ const Dn = [
163
+ ["line", { x1: "19", x2: "10", y1: "4", y2: "4", key: "15jd3p" }],
164
+ ["line", { x1: "14", x2: "5", y1: "20", y2: "20", key: "bu0au3" }],
165
+ ["line", { x1: "15", x2: "9", y1: "4", y2: "20", key: "uljnxc" }]
166
+ ], qn = R("italic", Dn);
167
+ /**
168
+ * @license lucide-react v1.22.0 - ISC
169
+ *
170
+ * This source code is licensed under the ISC license.
171
+ * See the LICENSE file in the root directory of this source tree.
172
+ */
173
+ const On = [
174
+ ["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
175
+ ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
176
+ ], Pn = R("link", On);
177
+ /**
178
+ * @license lucide-react v1.22.0 - ISC
179
+ *
180
+ * This source code is licensed under the ISC license.
181
+ * See the LICENSE file in the root directory of this source tree.
182
+ */
183
+ const jn = [
184
+ ["path", { d: "M11 5h10", key: "1cz7ny" }],
185
+ ["path", { d: "M11 12h10", key: "1438ji" }],
186
+ ["path", { d: "M11 19h10", key: "11t30w" }],
187
+ ["path", { d: "M4 4h1v5", key: "10yrso" }],
188
+ ["path", { d: "M4 9h2", key: "r1h2o0" }],
189
+ ["path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02", key: "xtkcd5" }]
190
+ ], Bn = R("list-ordered", jn);
191
+ /**
192
+ * @license lucide-react v1.22.0 - ISC
193
+ *
194
+ * This source code is licensed under the ISC license.
195
+ * See the LICENSE file in the root directory of this source tree.
196
+ */
197
+ const Fn = [
198
+ ["path", { d: "M3 5h.01", key: "18ugdj" }],
199
+ ["path", { d: "M3 12h.01", key: "nlz23k" }],
200
+ ["path", { d: "M3 19h.01", key: "noohij" }],
201
+ ["path", { d: "M8 5h13", key: "1pao27" }],
202
+ ["path", { d: "M8 12h13", key: "1za7za" }],
203
+ ["path", { d: "M8 19h13", key: "m83p4d" }]
204
+ ], Gn = R("list", Fn);
205
+ /**
206
+ * @license lucide-react v1.22.0 - ISC
207
+ *
208
+ * This source code is licensed under the ISC license.
209
+ * See the LICENSE file in the root directory of this source tree.
210
+ */
211
+ const Vn = [
212
+ ["path", { d: "M11 7 6 2", key: "1jwth8" }],
213
+ ["path", { d: "M18.992 12H2.041", key: "xw1gg" }],
214
+ [
215
+ "path",
216
+ {
217
+ d: "M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595",
218
+ key: "1nkol4"
219
+ }
220
+ ],
221
+ [
222
+ "path",
223
+ {
224
+ d: "m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33",
225
+ key: "1nk1rd"
226
+ }
227
+ ]
228
+ ], Kn = R("paint-bucket", Vn);
229
+ /**
230
+ * @license lucide-react v1.22.0 - ISC
231
+ *
232
+ * This source code is licensed under the ISC license.
233
+ * See the LICENSE file in the root directory of this source tree.
234
+ */
235
+ const Wn = [
236
+ ["rect", { width: "16", height: "6", x: "2", y: "2", rx: "2", key: "jcyz7m" }],
237
+ ["path", { d: "M10 16v-2a2 2 0 0 1 2-2h8a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2", key: "1b9h7c" }],
238
+ ["rect", { width: "4", height: "6", x: "8", y: "16", rx: "1", key: "d6e7yl" }]
239
+ ], Xn = R("paint-roller", Wn);
240
+ /**
241
+ * @license lucide-react v1.22.0 - ISC
242
+ *
243
+ * This source code is licensed under the ISC license.
244
+ * See the LICENSE file in the root directory of this source tree.
245
+ */
246
+ const Zn = [
247
+ [
248
+ "path",
249
+ {
250
+ d: "M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",
251
+ key: "e79jfc"
252
+ }
253
+ ],
254
+ ["circle", { cx: "13.5", cy: "6.5", r: ".5", fill: "currentColor", key: "1okk4w" }],
255
+ ["circle", { cx: "17.5", cy: "10.5", r: ".5", fill: "currentColor", key: "f64h9f" }],
256
+ ["circle", { cx: "6.5", cy: "12.5", r: ".5", fill: "currentColor", key: "qy21gx" }],
257
+ ["circle", { cx: "8.5", cy: "7.5", r: ".5", fill: "currentColor", key: "fotxhn" }]
258
+ ], Un = R("palette", Zn);
259
+ /**
260
+ * @license lucide-react v1.22.0 - ISC
261
+ *
262
+ * This source code is licensed under the ISC license.
263
+ * See the LICENSE file in the root directory of this source tree.
264
+ */
265
+ const Qn = [
266
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
267
+ ["path", { d: "M9 3v18", key: "fh3hqa" }]
268
+ ], Yn = R("panel-left", Qn);
269
+ /**
270
+ * @license lucide-react v1.22.0 - ISC
271
+ *
272
+ * This source code is licensed under the ISC license.
273
+ * See the LICENSE file in the root directory of this source tree.
274
+ */
275
+ const Jn = [
276
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
277
+ ["path", { d: "M15 3v18", key: "14nvp0" }]
278
+ ], eo = R("panel-right", Jn);
279
+ /**
280
+ * @license lucide-react v1.22.0 - ISC
281
+ *
282
+ * This source code is licensed under the ISC license.
283
+ * See the LICENSE file in the root directory of this source tree.
284
+ */
285
+ const to = [
286
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
287
+ ["path", { d: "M14 9h1", key: "l0svgy" }],
288
+ ["path", { d: "M19 9h2", key: "te2zfg" }],
289
+ ["path", { d: "M3 9h2", key: "1h4ldw" }],
290
+ ["path", { d: "M9 9h1", key: "15jzuz" }]
291
+ ], ro = R("panel-top-dashed", to);
292
+ /**
293
+ * @license lucide-react v1.22.0 - ISC
294
+ *
295
+ * This source code is licensed under the ISC license.
296
+ * See the LICENSE file in the root directory of this source tree.
297
+ */
298
+ const no = [
299
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
300
+ ["path", { d: "M3 9h18", key: "1pudct" }]
301
+ ], oo = R("panel-top", no);
302
+ /**
303
+ * @license lucide-react v1.22.0 - ISC
304
+ *
305
+ * This source code is licensed under the ISC license.
306
+ * See the LICENSE file in the root directory of this source tree.
307
+ */
308
+ const ao = [
309
+ ["path", { d: "M13 4v16", key: "8vvj80" }],
310
+ ["path", { d: "M17 4v16", key: "7dpous" }],
311
+ ["path", { d: "M19 4H9.5a4.5 4.5 0 0 0 0 9H13", key: "sh4n9v" }]
312
+ ], io = R("pilcrow", ao);
313
+ /**
314
+ * @license lucide-react v1.22.0 - ISC
315
+ *
316
+ * This source code is licensed under the ISC license.
317
+ * See the LICENSE file in the root directory of this source tree.
318
+ */
319
+ const so = [
320
+ [
321
+ "path",
322
+ {
323
+ d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
324
+ key: "rib7q0"
325
+ }
326
+ ],
327
+ [
328
+ "path",
329
+ {
330
+ d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
331
+ key: "1ymkrd"
332
+ }
333
+ ]
334
+ ], lo = R("quote", so);
335
+ /**
336
+ * @license lucide-react v1.22.0 - ISC
337
+ *
338
+ * This source code is licensed under the ISC license.
339
+ * See the LICENSE file in the root directory of this source tree.
340
+ */
341
+ const co = [
342
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
343
+ ["path", { d: "M3 12h18", key: "1i2n21" }]
344
+ ], uo = R("rows-2", co);
345
+ /**
346
+ * @license lucide-react v1.22.0 - ISC
347
+ *
348
+ * This source code is licensed under the ISC license.
349
+ * See the LICENSE file in the root directory of this source tree.
350
+ */
351
+ const mo = [
352
+ ["path", { d: "m6 16 6-12 6 12", key: "1b4byz" }],
353
+ ["path", { d: "M8 12h8", key: "1wcyev" }],
354
+ ["path", { d: "m16 20 2 2 4-4", key: "13tcca" }]
355
+ ], go = R("spell-check", mo);
356
+ /**
357
+ * @license lucide-react v1.22.0 - ISC
358
+ *
359
+ * This source code is licensed under the ISC license.
360
+ * See the LICENSE file in the root directory of this source tree.
361
+ */
362
+ const fo = [
363
+ ["path", { d: "M16 4H9a3 3 0 0 0-2.83 4", key: "43sutm" }],
364
+ ["path", { d: "M14 12a4 4 0 0 1 0 8H6", key: "nlfj13" }],
365
+ ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }]
366
+ ], ho = R("strikethrough", fo);
367
+ /**
368
+ * @license lucide-react v1.22.0 - ISC
369
+ *
370
+ * This source code is licensed under the ISC license.
371
+ * See the LICENSE file in the root directory of this source tree.
372
+ */
373
+ const po = [
374
+ ["path", { d: "M12 3v18", key: "108xh3" }],
375
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
376
+ ["path", { d: "M3 9h18", key: "1pudct" }],
377
+ ["path", { d: "M3 15h18", key: "5xshup" }]
378
+ ], bo = R("table", po);
379
+ /**
380
+ * @license lucide-react v1.22.0 - ISC
381
+ *
382
+ * This source code is licensed under the ISC license.
383
+ * See the LICENSE file in the root directory of this source tree.
384
+ */
385
+ const yo = [
386
+ ["path", { d: "M21 5H3", key: "1fi0y6" }],
387
+ ["path", { d: "M17 12H7", key: "16if0g" }],
388
+ ["path", { d: "M19 19H5", key: "vjpgq2" }]
389
+ ], vo = R("text-align-center", yo);
390
+ /**
391
+ * @license lucide-react v1.22.0 - ISC
392
+ *
393
+ * This source code is licensed under the ISC license.
394
+ * See the LICENSE file in the root directory of this source tree.
395
+ */
396
+ const wo = [
397
+ ["path", { d: "M21 5H3", key: "1fi0y6" }],
398
+ ["path", { d: "M21 12H9", key: "dn1m92" }],
399
+ ["path", { d: "M21 19H7", key: "4cu937" }]
400
+ ], xo = R("text-align-end", wo);
401
+ /**
402
+ * @license lucide-react v1.22.0 - ISC
403
+ *
404
+ * This source code is licensed under the ISC license.
405
+ * See the LICENSE file in the root directory of this source tree.
406
+ */
407
+ const ko = [
408
+ ["path", { d: "M21 5H3", key: "1fi0y6" }],
409
+ ["path", { d: "M15 12H3", key: "6jk70r" }],
410
+ ["path", { d: "M17 19H3", key: "z6ezky" }]
411
+ ], Co = R("text-align-start", ko);
412
+ /**
413
+ * @license lucide-react v1.22.0 - ISC
414
+ *
415
+ * This source code is licensed under the ISC license.
416
+ * See the LICENSE file in the root directory of this source tree.
417
+ */
418
+ const No = [
419
+ ["path", { d: "M6 4v6a6 6 0 0 0 12 0V4", key: "9kb039" }],
420
+ ["line", { x1: "4", x2: "20", y1: "20", y2: "20", key: "nun2al" }]
421
+ ], To = R("underline", No);
422
+ /**
423
+ * @license lucide-react v1.22.0 - ISC
424
+ *
425
+ * This source code is licensed under the ISC license.
426
+ * See the LICENSE file in the root directory of this source tree.
427
+ */
428
+ const Ao = [
429
+ [
430
+ "path",
431
+ {
432
+ d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",
433
+ key: "1ngwbx"
434
+ }
435
+ ]
436
+ ], zo = R("wrench", Ao), Mo = {
437
+ id: "rich-text-editor",
438
+ capabilities: ["edit_inline"],
439
+ state: {
440
+ html: {
441
+ type: "string",
442
+ descriptionKey: "ui.agent.richTextEditor.state.html",
443
+ description: "Sanitised HTML representation of the editor content.",
444
+ read: (o) => o.getHTML()
445
+ },
446
+ text: {
447
+ type: "string",
448
+ descriptionKey: "ui.agent.richTextEditor.state.text",
449
+ description: "Plain-text content of the editor (tags stripped).",
450
+ read: (o) => o.getText()
451
+ },
452
+ markdown: {
453
+ type: "string",
454
+ descriptionKey: "ui.agent.richTextEditor.state.markdown",
455
+ description: "Markdown representation of the editor content. The Redactor engine has no native Markdown serialiser, so this is always empty — read `html` instead.",
456
+ read: (o) => o.getMarkdown()
457
+ }
458
+ },
459
+ // Image wrap/align/resize are intentionally NOT agent actions — they target
460
+ // the ephemeral click-selected image the handle can't address. Agents emit
461
+ // `<img class="wysiwyg-img-*" style="width:N%">` via set_content instead.
462
+ actions: {
463
+ set_content: {
464
+ // Replaces the whole document — discards whatever the user had typed.
465
+ safety: "destructive",
466
+ argsType: "{ html: string }",
467
+ argsSchema: {
468
+ type: "object",
469
+ properties: {
470
+ html: {
471
+ type: "string",
472
+ description: "Replacement HTML (sanitised via DOMPurify)."
473
+ }
474
+ },
475
+ required: ["html"]
476
+ },
477
+ idempotent: !0,
478
+ descriptionKey: "ui.agent.richTextEditor.actions.setContent",
479
+ description: "Replace the editor content. Loses unsaved input.",
480
+ invoke: (o, i) => {
481
+ o.setContent(i.html);
482
+ }
483
+ },
484
+ insert_at_cursor: {
485
+ // Reversible via the editor's own undo stack — write, not destructive.
486
+ safety: "write",
487
+ argsType: "{ content: string; asHtml?: boolean }",
488
+ argsSchema: {
489
+ type: "object",
490
+ properties: {
491
+ content: {
492
+ type: "string",
493
+ description: "Content to insert at the caret."
494
+ },
495
+ asHtml: {
496
+ type: "boolean",
497
+ description: "Treat content as HTML (sanitised). Pass false for plain text. Defaults to true."
498
+ }
499
+ },
500
+ required: ["content"]
501
+ },
502
+ descriptionKey: "ui.agent.richTextEditor.actions.insertAtCursor",
503
+ description: "Insert content at the caret (replacing any selection). HTML is sanitised; pass asHtml:false for plain text. Seam for merge/template variables and AI-generated drafts.",
504
+ examples: [
505
+ {
506
+ args: { content: "{{patient.firstName}}", asHtml: !1 },
507
+ note: "Insert a merge variable as plain text."
508
+ }
509
+ ],
510
+ invoke: (o, i) => {
511
+ o.insertAtCursor(i.content, { asHtml: i.asHtml });
512
+ }
513
+ },
514
+ apply_format: {
515
+ // Reversible via undo — write, not destructive.
516
+ safety: "write",
517
+ argsType: "{ format: 'bold' | 'italic' | 'strikethrough' | 'bulletedList' | 'numberedList' | 'heading' | 'quote' | 'paragraph' }",
518
+ argsSchema: {
519
+ type: "object",
520
+ properties: {
521
+ format: {
522
+ type: "string",
523
+ enum: [
524
+ "bold",
525
+ "italic",
526
+ "strikethrough",
527
+ "bulletedList",
528
+ "numberedList",
529
+ "heading",
530
+ "quote",
531
+ "paragraph"
532
+ ],
533
+ description: "Block or inline format to toggle/apply."
534
+ }
535
+ },
536
+ required: ["format"]
537
+ },
538
+ descriptionKey: "ui.agent.richTextEditor.actions.applyFormat",
539
+ description: "Toggle/apply a block or inline format on the current selection (bold, italic, strikethrough, bulleted/numbered list, heading, quote, paragraph).",
540
+ examples: [{ args: { format: "bold" }, note: "Bold the selection." }],
541
+ invoke: (o, i) => {
542
+ o.applyFormat(i.format);
543
+ }
544
+ },
545
+ clear: {
546
+ // Empties the document — loses unsaved input.
547
+ safety: "destructive",
548
+ idempotent: !0,
549
+ descriptionKey: "ui.agent.richTextEditor.actions.clear",
550
+ description: "Empty the editor. Loses unsaved input.",
551
+ invoke: (o) => {
552
+ o.clear();
553
+ }
554
+ },
555
+ focus: {
556
+ safety: "read",
557
+ idempotent: !0,
558
+ descriptionKey: "ui.agent.richTextEditor.actions.focus",
559
+ description: "Move keyboard focus to the editor surface.",
560
+ invoke: (o) => {
561
+ o.focus();
562
+ }
563
+ }
564
+ },
565
+ domHooks: {
566
+ root: { attr: "data-component", value: "rich-text-editor" },
567
+ instanceId: {
568
+ attr: "data-component-id",
569
+ sourceProp: "id",
570
+ description: "Sourced from the id prop."
571
+ }
572
+ }
573
+ }, _o = "ds:aria-pressed:!bg-[var(--destructive)] ds:aria-pressed:!text-[var(--destructive-foreground)]", ze = "ds:!size-[var(--min-target-size)]", Eo = "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", Ro = "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--destructive)]", cr = [
574
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
575
+ "ds:bg-[color-mix(in_srgb,var(--background)_70%,transparent)]",
576
+ "ds:p-[var(--spacing-sm)] ds:[max-block-size:10rem] ds:overflow-y-auto",
577
+ "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--foreground)]",
578
+ // The preview renders arbitrary model-generated rich text, and the
579
+ // `rich-text` SafeHtml profile allows ul/ol/li. Inside a
580
+ // [data-component] preflight's list reset still applies and the host
581
+ // undo deliberately does not reach, so markers and indent have to be
582
+ // asked for explicitly — otherwise a generated bullet list previews as
583
+ // flush, marker-less lines.
584
+ "ds:[&_ul]:list-disc ds:[&_ol]:list-decimal",
585
+ "ds:[&_ul]:ps-[var(--spacing-md)] ds:[&_ol]:ps-[var(--spacing-md)]"
586
+ ].join(" ");
587
+ function dr(o, i) {
588
+ return i ? o ? /\s$/.test(o) ? `${o}${i}` : `${o} ${i}` : i : o;
589
+ }
590
+ function So({
591
+ open: o,
592
+ onClose: i,
593
+ onRequestAiDraft: h,
594
+ onInsert: g,
595
+ previewAsHtml: f = !0,
596
+ privacyNotice: l,
597
+ onDictate: v
598
+ }) {
599
+ const { t: u } = ne(), b = _e(), C = _e(), [z, $] = A(""), [L, _] = A(!1), [F, m] = A(!1), [c, p] = A(null), E = M(null), [T, H] = A(!1), [y, q] = A(""), [O, U] = A(""), X = M(null), P = x(() => {
600
+ var j;
601
+ (j = X.current) == null || j.abort();
602
+ }, []), ae = x(() => {
603
+ if (!v) return;
604
+ const j = new AbortController();
605
+ X.current = j, H(!0), q(""), U(u("editor.ai.listening")), v({
606
+ signal: j.signal,
607
+ onPartialTranscript: (K) => {
608
+ j.signal.aborted || q(K);
609
+ },
610
+ onFinalTranscript: (K) => {
611
+ if (j.signal.aborted) return;
612
+ const ee = K.trim();
613
+ q(""), ee && ($((N) => dr(N, ee)), U(ee));
614
+ }
615
+ }).catch(() => {
616
+ }).finally(() => {
617
+ q(""), X.current === j && (X.current = null, H(!1), U(""));
618
+ });
619
+ }, [v, u]), be = x(() => {
620
+ T ? P() : ae();
621
+ }, [T, ae, P]);
622
+ I(() => {
623
+ var j, K;
624
+ o ? ($(""), _(!1), m(!1), p(null), q(""), U("")) : ((j = E.current) == null || j.abort(), E.current = null, (K = X.current) == null || K.abort());
625
+ }, [o]), I(
626
+ () => () => {
627
+ var j, K;
628
+ (j = E.current) == null || j.abort(), (K = X.current) == null || K.abort();
629
+ },
630
+ []
631
+ );
632
+ const B = x(() => {
633
+ var ee;
634
+ const j = z.trim();
635
+ if (!j || L) return;
636
+ P(), (ee = E.current) == null || ee.abort();
637
+ const K = new AbortController();
638
+ E.current = K, m(!1), _(!0), h({ prompt: j, signal: K.signal }).then((N) => {
639
+ K.signal.aborted || (p(N), _(!1));
640
+ }).catch((N) => {
641
+ K.signal.aborted || N && typeof N == "object" && "name" in N && N.name === "AbortError" || (m(!0), _(!1));
642
+ });
643
+ }, [z, L, h, P]), Q = x(() => {
644
+ c != null && (g(c), i());
645
+ }, [c, g, i]), Ee = c != null, D = T ? dr(z, y) : z;
646
+ return /* @__PURE__ */ t(
647
+ br,
648
+ {
649
+ open: o,
650
+ onClose: i,
651
+ ariaLabel: u("editor.ai.dialogTitle"),
652
+ children: Ee ? /* @__PURE__ */ k("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
653
+ /* @__PURE__ */ t(
654
+ G,
655
+ {
656
+ size: "md",
657
+ intent: "outline",
658
+ className: ze,
659
+ icon: /* @__PURE__ */ t(lr, {}),
660
+ "aria-label": u("common.close"),
661
+ onClick: i
662
+ }
663
+ ),
664
+ /* @__PURE__ */ t("div", { className: "ds:min-w-0 ds:flex-1", children: f ? /* @__PURE__ */ t(
665
+ Jr,
666
+ {
667
+ html: c,
668
+ profile: "rich-text",
669
+ className: cr,
670
+ tabIndex: 0,
671
+ "aria-label": u("editor.ai.dialogTitle")
672
+ }
673
+ ) : (
674
+ // Focusable so a keyboard user can scroll a long draft preview
675
+ // (mirrors the SafeHtml preview branch above). The lint rule's
676
+ // tabIndex allowlist doesn't cover a scrollable, non-interactive
677
+ // text region.
678
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
679
+ /* @__PURE__ */ t("p", { className: cr, tabIndex: 0, children: c })
680
+ ) }),
681
+ /* @__PURE__ */ t(
682
+ G,
683
+ {
684
+ size: "md",
685
+ intent: "outline",
686
+ className: `${ze} ds:rounded-full`,
687
+ icon: /* @__PURE__ */ t(on, {}),
688
+ "aria-label": u("editor.ai.retry"),
689
+ onClick: () => p(null)
690
+ }
691
+ ),
692
+ /* @__PURE__ */ t(
693
+ G,
694
+ {
695
+ size: "md",
696
+ intent: "primary",
697
+ className: `${ze} ds:bg-[image:var(--gradient-brand)] ds:rounded-full`,
698
+ icon: /* @__PURE__ */ t(an, {}),
699
+ "aria-label": u("common.confirm"),
700
+ onClick: Q
701
+ }
702
+ )
703
+ ] }) : /* @__PURE__ */ k(Me, { children: [
704
+ /* @__PURE__ */ k("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
705
+ /* @__PURE__ */ t(
706
+ G,
707
+ {
708
+ size: "md",
709
+ intent: "outline",
710
+ className: ze,
711
+ icon: /* @__PURE__ */ t(lr, {}),
712
+ "aria-label": u("common.close"),
713
+ onClick: i
714
+ }
715
+ ),
716
+ /* @__PURE__ */ t("div", { className: "ds:min-w-0 ds:flex-1", children: /* @__PURE__ */ t(
717
+ nn,
718
+ {
719
+ id: b,
720
+ size: "md",
721
+ value: D,
722
+ onChange: (j) => $(j.target.value),
723
+ placeholder: u("editor.ai.promptPlaceholder"),
724
+ "aria-label": u("editor.ai.promptLabel"),
725
+ autoResize: !0,
726
+ minRows: 1,
727
+ maxRows: 3,
728
+ readOnly: T,
729
+ tone: F ? "error" : "default",
730
+ "aria-describedby": F ? C : void 0
731
+ }
732
+ ) }),
733
+ v ? /* @__PURE__ */ t(
734
+ G,
735
+ {
736
+ size: "md",
737
+ intent: "outline",
738
+ className: T ? `${ze} ${_o}` : ze,
739
+ icon: T ? /* @__PURE__ */ t(gt, { className: "ds:fill-current" }) : /* @__PURE__ */ t(yr, {}),
740
+ "aria-pressed": T,
741
+ "aria-label": u(T ? "editor.ai.dictateStop" : "editor.ai.dictateStart"),
742
+ onClick: be
743
+ }
744
+ ) : null,
745
+ /* @__PURE__ */ t(
746
+ G,
747
+ {
748
+ size: "md",
749
+ intent: "primary",
750
+ icon: L ? /* @__PURE__ */ t(pr, { size: "sm", variant: "pulse" }) : /* @__PURE__ */ t(sn, {}),
751
+ className: `${ze} ds:bg-[image:var(--gradient-brand)] ds:rounded-full`,
752
+ disabled: L || !z.trim(),
753
+ "aria-busy": L || void 0,
754
+ "aria-label": u("editor.ai.generate"),
755
+ onClick: B
756
+ }
757
+ )
758
+ ] }),
759
+ v ? /* @__PURE__ */ t("p", { className: "ds:sr-only", role: "status", "aria-live": "polite", children: O }) : null,
760
+ F ? /* @__PURE__ */ t("p", { id: C, role: "alert", className: Ro, children: u("editor.ai.error") }) : l ? /* @__PURE__ */ t("p", { className: Eo, children: l }) : null
761
+ ] })
762
+ }
763
+ );
764
+ }
765
+ const Lo = {
766
+ bold: {
767
+ id: "bold",
768
+ icon: /* @__PURE__ */ t(Mn, {}),
769
+ label: ["editor.bold", "Bold"],
770
+ command: ["module.inline.format", { tag: "b" }],
771
+ toggle: "bold"
772
+ },
773
+ italic: {
774
+ id: "italic",
775
+ icon: /* @__PURE__ */ t(qn, {}),
776
+ label: ["editor.italic", "Italic"],
777
+ command: ["module.inline.format", { tag: "i" }],
778
+ toggle: "italic"
779
+ },
780
+ underline: {
781
+ id: "underline",
782
+ icon: /* @__PURE__ */ t(To, {}),
783
+ label: ["editor.underline", "Underline"],
784
+ command: ["module.inline.format", { tag: "u" }],
785
+ toggle: "underline"
786
+ },
787
+ strike: {
788
+ id: "strike",
789
+ icon: /* @__PURE__ */ t(ho, {}),
790
+ label: ["editor.strike", "Strikethrough"],
791
+ command: ["module.inline.format", { tag: "del" }],
792
+ toggle: "strike"
793
+ },
794
+ ul: {
795
+ id: "ul",
796
+ icon: /* @__PURE__ */ t(Gn, {}),
797
+ label: ["editor.list.bullet", "Bulleted list"],
798
+ command: ["module.list.toggle", "ul"],
799
+ toggle: "ul"
800
+ },
801
+ ol: {
802
+ id: "ol",
803
+ icon: /* @__PURE__ */ t(Bn, {}),
804
+ label: ["editor.list.ordered", "Numbered list"],
805
+ command: ["module.list.toggle", "ol"],
806
+ toggle: "ol"
807
+ }
808
+ }, St = [
809
+ {
810
+ id: "paragraph",
811
+ tag: "p",
812
+ icon: /* @__PURE__ */ t(io, {}),
813
+ label: ["editor.paragraph", "Paragraph"]
814
+ },
815
+ {
816
+ id: "h2",
817
+ tag: "h2",
818
+ icon: /* @__PURE__ */ t(In, {}),
819
+ label: ["editor.heading2", "Heading 2"]
820
+ },
821
+ {
822
+ id: "h3",
823
+ tag: "h3",
824
+ icon: /* @__PURE__ */ t(Hn, {}),
825
+ label: ["editor.heading3", "Heading 3"]
826
+ },
827
+ {
828
+ id: "quote",
829
+ tag: "blockquote",
830
+ icon: /* @__PURE__ */ t(lo, {}),
831
+ label: ["editor.quote", "Quote"]
832
+ }
833
+ ], Io = {
834
+ minimal: ["bold", "italic", "underline", "link"],
835
+ standard: [
836
+ "format",
837
+ "bold",
838
+ "italic",
839
+ "underline",
840
+ "strike",
841
+ "ul",
842
+ "ol",
843
+ "link"
844
+ ],
845
+ full: ["format", "bold", "italic", "underline", "strike", "ul", "ol", "link"]
846
+ }, wr = [
847
+ {
848
+ id: "rowAbove",
849
+ command: "plugin.table.addRowAbove",
850
+ icon: /* @__PURE__ */ t(kn, {}),
851
+ label: ["editor.table.rowAbove", "Add row above"]
852
+ },
853
+ {
854
+ id: "rowBelow",
855
+ command: "plugin.table.addRowBelow",
856
+ icon: /* @__PURE__ */ t(wn, {}),
857
+ label: ["editor.table.rowBelow", "Add row below"]
858
+ },
859
+ {
860
+ id: "colLeft",
861
+ command: "plugin.table.addColumnLeft",
862
+ icon: /* @__PURE__ */ t(An, {}),
863
+ label: ["editor.table.columnLeft", "Add column left"]
864
+ },
865
+ {
866
+ id: "colRight",
867
+ command: "plugin.table.addColumnRight",
868
+ icon: /* @__PURE__ */ t(Nn, {}),
869
+ label: ["editor.table.columnRight", "Add column right"]
870
+ },
871
+ {
872
+ id: "addHead",
873
+ command: "plugin.table.addHead",
874
+ icon: /* @__PURE__ */ t(oo, {}),
875
+ label: ["editor.table.addHeader", "Add header row"]
876
+ },
877
+ {
878
+ id: "deleteHead",
879
+ command: "plugin.table.deleteHead",
880
+ icon: /* @__PURE__ */ t(ro, {}),
881
+ label: ["editor.table.deleteHeader", "Remove header row"]
882
+ },
883
+ {
884
+ id: "deleteRow",
885
+ command: "plugin.table.deleteRow",
886
+ icon: /* @__PURE__ */ t(uo, {}),
887
+ label: ["editor.table.deleteRow", "Delete row"]
888
+ },
889
+ {
890
+ id: "deleteColumn",
891
+ command: "plugin.table.deleteColumn",
892
+ icon: /* @__PURE__ */ t(Sn, {}),
893
+ label: ["editor.table.deleteColumn", "Delete column"]
894
+ },
895
+ {
896
+ id: "deleteTable",
897
+ command: "plugin.table.deleteTable",
898
+ icon: /* @__PURE__ */ t(fn, {}),
899
+ label: ["editor.table.deleteTable", "Delete table"]
900
+ }
901
+ ], mt = 6, $o = Ot(
902
+ [
903
+ "ds:@container/toolbar",
904
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
905
+ "ds:bg-[var(--background)] ds:p-[var(--spacing-xs)]",
906
+ "ds:shadow-[var(--shadow-md)]"
907
+ ].join(" ")
908
+ ), Ho = "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]", jt = "ds:self-stretch ds:[inline-size:var(--border-width-sm)] ds:bg-[var(--border)] ds:[margin-inline:var(--spacing-2xs)]", Ge = "ds:text-[length:var(--font-size-sm)] ds:font-medium ds:text-[color:var(--foreground)]";
909
+ function ht(o) {
910
+ return o.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
911
+ }
912
+ function Do({
913
+ variables: o,
914
+ insertVariable: i,
915
+ saveSelection: h
916
+ }) {
917
+ const { t: g } = ne(), f = M(!1);
918
+ return /* @__PURE__ */ k(
919
+ he.Root,
920
+ {
921
+ onOpenChange: (l) => {
922
+ l && h();
923
+ },
924
+ children: [
925
+ /* @__PURE__ */ t(he.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
926
+ G,
927
+ {
928
+ size: "sm",
929
+ intent: "ghost",
930
+ icon: /* @__PURE__ */ t(En, {}),
931
+ "aria-label": g("editor.insertVariable", "Insert variable")
932
+ }
933
+ ) }),
934
+ /* @__PURE__ */ k(
935
+ he.Content,
936
+ {
937
+ align: "start",
938
+ onCloseAutoFocus: (l) => {
939
+ f.current && l.preventDefault(), f.current = !1;
940
+ },
941
+ children: [
942
+ /* @__PURE__ */ t(he.Label, { children: g("editor.variables", "Variables") }),
943
+ o.map((l) => /* @__PURE__ */ t(
944
+ he.Item,
945
+ {
946
+ description: l.description ?? `[[${l.token}]]`,
947
+ onSelect: () => {
948
+ f.current = !0, i(l.token);
949
+ },
950
+ children: l.label
951
+ },
952
+ l.token
953
+ ))
954
+ ]
955
+ }
956
+ )
957
+ ]
958
+ }
959
+ );
960
+ }
961
+ function qo({
962
+ run: o,
963
+ active: i,
964
+ onTriggerDown: h
965
+ }) {
966
+ const { t: g } = ne(), f = St.find((l) => i.has(l.id)) ?? St[0];
967
+ return /* @__PURE__ */ k(he.Root, { children: [
968
+ /* @__PURE__ */ t(he.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
969
+ pe,
970
+ {
971
+ size: "sm",
972
+ intent: "ghost",
973
+ startIcon: f.icon,
974
+ endIcon: /* @__PURE__ */ t(gn, {}),
975
+ "aria-label": `${g("editor.format", "Paragraph style")}: ${g(
976
+ f.label[0],
977
+ f.label[1]
978
+ )}`,
979
+ onMouseDown: h,
980
+ children: /* @__PURE__ */ t("span", { className: "ds:hidden ds:@[448px]/toolbar:inline", children: g(f.label[0], f.label[1]) })
981
+ }
982
+ ) }),
983
+ /* @__PURE__ */ t(he.Content, { align: "start", children: St.map((l) => /* @__PURE__ */ t(
984
+ he.Item,
985
+ {
986
+ startIcon: l.icon,
987
+ onSelect: () => o("module.block.format", { tag: l.tag }),
988
+ children: g(l.label[0], l.label[1])
989
+ },
990
+ l.id
991
+ )) })
992
+ ] });
993
+ }
994
+ function Oo({
995
+ insertHtml: o,
996
+ saveSelection: i,
997
+ restoreSelection: h,
998
+ getSelectedText: g
999
+ }) {
1000
+ const { t: f } = ne(), [l, v] = A(!1), [u, b] = A(""), [C, z] = A(""), [$, L] = A(!1), _ = _e(), F = _e(), m = () => {
1001
+ b(""), z(""), L(!1);
1002
+ }, c = () => {
1003
+ const p = u.trim();
1004
+ if (!p) return;
1005
+ const E = C.trim() || p, T = $ ? ' target="_blank" rel="noopener noreferrer"' : "", H = `<a href="${ht(p)}"${T}>${ht(E)}</a>`;
1006
+ v(!1), m(), window.requestAnimationFrame(() => {
1007
+ h(), o(H);
1008
+ });
1009
+ };
1010
+ return /* @__PURE__ */ k(Z.Root, { open: l, onOpenChange: v, children: [
1011
+ /* @__PURE__ */ t(Z.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1012
+ G,
1013
+ {
1014
+ size: "sm",
1015
+ intent: "ghost",
1016
+ icon: /* @__PURE__ */ t(Pn, {}),
1017
+ "aria-label": f("editor.link.insert", "Insert link"),
1018
+ onMouseDown: () => {
1019
+ i(), z(g());
1020
+ }
1021
+ }
1022
+ ) }),
1023
+ /* @__PURE__ */ k(Z.Content, { children: [
1024
+ /* @__PURE__ */ t(Z.Header, { children: /* @__PURE__ */ t(Z.Title, { children: f("editor.link.insert", "Insert link") }) }),
1025
+ /* @__PURE__ */ k(Z.Body, { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
1026
+ /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1027
+ /* @__PURE__ */ t("label", { htmlFor: _, className: Ge, children: f("editor.link.url", "URL") }),
1028
+ /* @__PURE__ */ t(
1029
+ ft,
1030
+ {
1031
+ id: _,
1032
+ type: "url",
1033
+ value: u,
1034
+ onChange: (p) => b(p.target.value),
1035
+ placeholder: "https://…"
1036
+ }
1037
+ )
1038
+ ] }),
1039
+ /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1040
+ /* @__PURE__ */ t("label", { htmlFor: F, className: Ge, children: f("editor.link.text", "Text to display") }),
1041
+ /* @__PURE__ */ t(
1042
+ ft,
1043
+ {
1044
+ id: F,
1045
+ value: C,
1046
+ onChange: (p) => z(p.target.value),
1047
+ placeholder: f("editor.link.textPlaceholder", "Link text")
1048
+ }
1049
+ )
1050
+ ] }),
1051
+ /* @__PURE__ */ t(
1052
+ ln,
1053
+ {
1054
+ checked: $,
1055
+ onCheckedChange: (p) => L(p === !0),
1056
+ label: f("editor.link.newTab", "Open in new tab")
1057
+ }
1058
+ )
1059
+ ] }),
1060
+ /* @__PURE__ */ k(Z.Footer, { children: [
1061
+ /* @__PURE__ */ t(Z.Close, { asChild: !0, children: /* @__PURE__ */ t(pe, { intent: "secondary", children: f("common.cancel") }) }),
1062
+ /* @__PURE__ */ t(pe, { onClick: c, disabled: !u.trim(), children: f("editor.link.insertAction", "Insert") })
1063
+ ] })
1064
+ ] })
1065
+ ] });
1066
+ }
1067
+ function Po({
1068
+ insertHtml: o,
1069
+ saveSelection: i,
1070
+ restoreSelection: h,
1071
+ uploadImage: g
1072
+ }) {
1073
+ const { t: f } = ne(), [l, v] = A(!1), [u, b] = A(""), [C, z] = A(""), $ = _e(), L = _e(), _ = (m, c) => {
1074
+ const p = `<img src="${ht(m)}" alt="${ht(c)}" loading="lazy">`;
1075
+ v(!1), b(""), z(""), window.requestAnimationFrame(() => {
1076
+ h(), o(p);
1077
+ });
1078
+ }, F = () => {
1079
+ const m = u.trim();
1080
+ m && _(m, C.trim());
1081
+ };
1082
+ return /* @__PURE__ */ k(Z.Root, { open: l, onOpenChange: v, children: [
1083
+ /* @__PURE__ */ t(Z.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1084
+ G,
1085
+ {
1086
+ size: "sm",
1087
+ intent: "ghost",
1088
+ icon: /* @__PURE__ */ t(mn, {}),
1089
+ "aria-label": f("editor.image.insert", "Insert image"),
1090
+ onMouseDown: () => i()
1091
+ }
1092
+ ) }),
1093
+ /* @__PURE__ */ k(Z.Content, { children: [
1094
+ /* @__PURE__ */ t(Z.Header, { children: /* @__PURE__ */ t(Z.Title, { children: f("editor.image.insert", "Insert image") }) }),
1095
+ /* @__PURE__ */ k(Z.Body, { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
1096
+ g ? /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1097
+ /* @__PURE__ */ t("span", { className: Ge, children: f("editor.image.upload", "Upload") }),
1098
+ /* @__PURE__ */ t(
1099
+ cn,
1100
+ {
1101
+ variant: "dropzone",
1102
+ accept: {
1103
+ "image/*": [".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg"]
1104
+ },
1105
+ maxFiles: 1,
1106
+ onUpload: async (m, { signal: c }) => {
1107
+ const p = await g(m, c);
1108
+ _(p, m.name);
1109
+ }
1110
+ }
1111
+ ),
1112
+ /* @__PURE__ */ t("span", { className: "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", children: f("editor.image.orUrl", "Or paste an image URL") })
1113
+ ] }) : null,
1114
+ /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1115
+ /* @__PURE__ */ t("label", { htmlFor: $, className: Ge, children: f("editor.image.url", "Image URL") }),
1116
+ /* @__PURE__ */ t(
1117
+ ft,
1118
+ {
1119
+ id: $,
1120
+ type: "url",
1121
+ value: u,
1122
+ onChange: (m) => b(m.target.value),
1123
+ placeholder: "https://…"
1124
+ }
1125
+ )
1126
+ ] }),
1127
+ /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1128
+ /* @__PURE__ */ t("label", { htmlFor: L, className: Ge, children: f("editor.image.alt", "Alt text") }),
1129
+ /* @__PURE__ */ t(
1130
+ ft,
1131
+ {
1132
+ id: L,
1133
+ value: C,
1134
+ onChange: (m) => z(m.target.value),
1135
+ placeholder: f(
1136
+ "editor.image.altPlaceholder",
1137
+ "Describe the image"
1138
+ )
1139
+ }
1140
+ )
1141
+ ] })
1142
+ ] }),
1143
+ /* @__PURE__ */ k(Z.Footer, { children: [
1144
+ /* @__PURE__ */ t(Z.Close, { asChild: !0, children: /* @__PURE__ */ t(pe, { intent: "secondary", children: f("common.cancel") }) }),
1145
+ /* @__PURE__ */ t(pe, { onClick: F, disabled: !u.trim(), children: f("editor.image.insertAction", "Insert") })
1146
+ ] })
1147
+ ] })
1148
+ ] });
1149
+ }
1150
+ function jo({
1151
+ run: o,
1152
+ saveSelection: i,
1153
+ restoreSelection: h
1154
+ }) {
1155
+ const { t: g } = ne(), [f, l] = A("#1f2a5c"), v = (b) => {
1156
+ l(b), h(), o("module.inline.format", {
1157
+ tag: "span",
1158
+ style: { color: b },
1159
+ type: "toggle"
1160
+ });
1161
+ }, u = () => {
1162
+ h(), o("module.inline.remove", { style: "color" });
1163
+ };
1164
+ return /* @__PURE__ */ k(V, { onOpenChange: (b) => b && i(), children: [
1165
+ /* @__PURE__ */ t(V.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1166
+ G,
1167
+ {
1168
+ size: "sm",
1169
+ intent: "ghost",
1170
+ icon: /* @__PURE__ */ t(Un, {}),
1171
+ "aria-label": g("editor.textColor", "Text colour"),
1172
+ onMouseDown: (b) => {
1173
+ b.preventDefault(), i();
1174
+ }
1175
+ }
1176
+ ) }),
1177
+ /* @__PURE__ */ k(V.Content, { side: "bottom", align: "start", children: [
1178
+ /* @__PURE__ */ t(V.Heading, { children: g("editor.textColor", "Text colour") }),
1179
+ /* @__PURE__ */ t("div", { className: "ds:pt-[var(--spacing-sm)]", children: /* @__PURE__ */ t(
1180
+ Pt,
1181
+ {
1182
+ variant: "inline",
1183
+ size: "sm",
1184
+ value: f,
1185
+ onChange: v
1186
+ }
1187
+ ) }),
1188
+ /* @__PURE__ */ t("div", { className: "ds:mt-[var(--spacing-sm)] ds:flex ds:items-center ds:justify-end", children: /* @__PURE__ */ t(pe, { size: "sm", intent: "secondary", onClick: u, children: g("editor.color.remove", "Remove colour") }) })
1189
+ ] })
1190
+ ] });
1191
+ }
1192
+ function Bo({
1193
+ run: o,
1194
+ saveSelection: i,
1195
+ restoreSelection: h
1196
+ }) {
1197
+ const { t: g } = ne(), [f, l] = A("#fff3a3"), v = (b) => {
1198
+ l(b), h(), o("module.inline.format", {
1199
+ tag: "span",
1200
+ style: { "background-color": b },
1201
+ type: "toggle"
1202
+ });
1203
+ }, u = () => {
1204
+ h(), o("module.inline.remove", { style: "background-color" });
1205
+ };
1206
+ return /* @__PURE__ */ k(V, { onOpenChange: (b) => b && i(), children: [
1207
+ /* @__PURE__ */ t(V.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1208
+ G,
1209
+ {
1210
+ size: "sm",
1211
+ intent: "ghost",
1212
+ icon: /* @__PURE__ */ t(un, {}),
1213
+ "aria-label": g("editor.highlightColor", "Highlight"),
1214
+ onMouseDown: (b) => {
1215
+ b.preventDefault(), i();
1216
+ }
1217
+ }
1218
+ ) }),
1219
+ /* @__PURE__ */ k(V.Content, { side: "bottom", align: "start", children: [
1220
+ /* @__PURE__ */ t(V.Heading, { children: g("editor.highlightColor", "Highlight") }),
1221
+ /* @__PURE__ */ t("div", { className: "ds:pt-[var(--spacing-sm)]", children: /* @__PURE__ */ t(
1222
+ Pt,
1223
+ {
1224
+ variant: "inline",
1225
+ size: "sm",
1226
+ value: f,
1227
+ onChange: v
1228
+ }
1229
+ ) }),
1230
+ /* @__PURE__ */ t("div", { className: "ds:mt-[var(--spacing-sm)] ds:flex ds:items-center ds:justify-end", children: /* @__PURE__ */ t(pe, { size: "sm", intent: "secondary", onClick: u, children: g("editor.highlight.remove", "Remove highlight") }) })
1231
+ ] })
1232
+ ] });
1233
+ }
1234
+ function Fo(o, i) {
1235
+ const h = Array.from({ length: i }, () => "<td><br></td>").join("");
1236
+ return `<table><tbody>${Array.from({ length: o }, () => `<tr>${h}</tr>`).join("")}</tbody></table>`;
1237
+ }
1238
+ function Go({
1239
+ run: o,
1240
+ insertTable: i,
1241
+ active: h
1242
+ }) {
1243
+ const { t: g } = ne(), [f, l] = A({ r: 0, c: 0 }), v = h.has("table");
1244
+ return /* @__PURE__ */ k(V, { onOpenChange: (u) => !u && l({ r: 0, c: 0 }), children: [
1245
+ /* @__PURE__ */ t(V.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1246
+ G,
1247
+ {
1248
+ size: "sm",
1249
+ intent: "ghost",
1250
+ icon: /* @__PURE__ */ t(bo, {}),
1251
+ "aria-label": g("editor.table.insert", "Insert table"),
1252
+ onMouseDown: (u) => u.preventDefault()
1253
+ }
1254
+ ) }),
1255
+ /* @__PURE__ */ t(V.Content, { side: "bottom", align: "start", children: v ? (
1256
+ // Caret is already inside a table — offer the manage ops only, never
1257
+ // a nested-table insert (mirrors Redactor's native dropdown, which
1258
+ // disables "insert table" while the caret is in a table).
1259
+ /* @__PURE__ */ t("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]", children: wr.map((u) => /* @__PURE__ */ k(
1260
+ "button",
1261
+ {
1262
+ type: "button",
1263
+ onClick: () => o(u.command),
1264
+ className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)] ds:rounded-[var(--radius-sm)] ds:px-[var(--spacing-sm)] ds:py-[var(--spacing-2xs)] ds:text-start ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--foreground)] ds:hover:bg-[var(--muted)]",
1265
+ children: [
1266
+ /* @__PURE__ */ t(
1267
+ "span",
1268
+ {
1269
+ "aria-hidden": "true",
1270
+ className: "ds:inline-flex ds:size-4 ds:shrink-0 ds:items-center ds:justify-center ds:text-[color:var(--muted-foreground)]",
1271
+ children: u.icon
1272
+ }
1273
+ ),
1274
+ g(u.label[0], u.label[1])
1275
+ ]
1276
+ },
1277
+ u.id
1278
+ )) })
1279
+ ) : /* @__PURE__ */ k(Me, { children: [
1280
+ /* @__PURE__ */ t(V.Heading, { children: g("editor.table.insert", "Insert table") }),
1281
+ /* @__PURE__ */ t(
1282
+ "div",
1283
+ {
1284
+ role: "group",
1285
+ "aria-label": g("editor.table.sizePicker", "Table size"),
1286
+ className: "ds:mt-[var(--spacing-sm)] ds:grid ds:w-fit ds:grid-cols-6 ds:gap-[var(--spacing-2xs)]",
1287
+ onMouseLeave: () => l({ r: 0, c: 0 }),
1288
+ children: Array.from({ length: mt * mt }, (u, b) => {
1289
+ const C = Math.floor(b / mt) + 1, z = b % mt + 1, $ = C <= f.r && z <= f.c;
1290
+ return /* @__PURE__ */ t(
1291
+ "button",
1292
+ {
1293
+ type: "button",
1294
+ "aria-label": g("editor.table.sizeCell", "{{r}}×{{c}}", {
1295
+ r: C,
1296
+ c: z
1297
+ }),
1298
+ onMouseEnter: () => l({ r: C, c: z }),
1299
+ onClick: () => i(Fo(C, z)),
1300
+ className: `ds:size-5 ds:rounded-[var(--radius-sm)] ds:border ds:border-[color:var(--border)] ${$ ? "ds:bg-[var(--primary)]" : "ds:bg-[var(--muted)]"}`
1301
+ },
1302
+ b
1303
+ );
1304
+ })
1305
+ }
1306
+ ),
1307
+ /* @__PURE__ */ t("p", { className: "ds:mt-[var(--spacing-xs)] ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", children: f.r > 0 ? g("editor.table.sizeCell", "{{r}}×{{c}}", {
1308
+ r: f.r,
1309
+ c: f.c
1310
+ }) : g("editor.table.sizeHint", "Pick a size") })
1311
+ ] }) })
1312
+ ] });
1313
+ }
1314
+ const Vo = Object.fromEntries(wr.map((o) => [o.id, o])), Ko = [
1315
+ "ds:absolute ds:z-20 ds:flex ds:items-center ds:gap-[var(--spacing-2xs)]",
1316
+ "ds:[inset-block-start:var(--rte-tt-top)] ds:[inset-inline-start:var(--rte-tt-start)]",
1317
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
1318
+ "ds:bg-[var(--popover)] ds:p-[var(--spacing-2xs)] ds:shadow-[var(--shadow-lg)]"
1319
+ ].join(" "), Wo = "#fde68a";
1320
+ function ur({
1321
+ scope: o,
1322
+ icon: i,
1323
+ label: h,
1324
+ onOpenChange: g,
1325
+ saveTableCell: f,
1326
+ applyTableBackground: l
1327
+ }) {
1328
+ const { t: v } = ne(), [u, b] = A(Wo);
1329
+ return /* @__PURE__ */ k(
1330
+ V,
1331
+ {
1332
+ onOpenChange: (C) => {
1333
+ g(C), C && f();
1334
+ },
1335
+ children: [
1336
+ /* @__PURE__ */ t(V.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1337
+ G,
1338
+ {
1339
+ size: "sm",
1340
+ intent: "ghost",
1341
+ icon: i,
1342
+ tooltip: h,
1343
+ onMouseDown: (C) => C.preventDefault()
1344
+ }
1345
+ ) }),
1346
+ /* @__PURE__ */ k(V.Content, { side: "bottom", align: "center", children: [
1347
+ /* @__PURE__ */ t(
1348
+ Pt,
1349
+ {
1350
+ variant: "inline",
1351
+ size: "sm",
1352
+ value: u,
1353
+ onChange: (C) => {
1354
+ b(C), l(o, C);
1355
+ }
1356
+ }
1357
+ ),
1358
+ /* @__PURE__ */ t(
1359
+ pe,
1360
+ {
1361
+ size: "sm",
1362
+ intent: "ghost",
1363
+ className: "ds:mt-[var(--spacing-xs)] ds:w-full",
1364
+ onClick: () => l(o, null),
1365
+ children: v("editor.table.clearColor", "Clear colour")
1366
+ }
1367
+ )
1368
+ ] })
1369
+ ]
1370
+ }
1371
+ );
1372
+ }
1373
+ function Xo({
1374
+ active: o,
1375
+ run: i,
1376
+ areaRef: h,
1377
+ getActiveTableEl: g,
1378
+ enableColor: f = !1,
1379
+ saveTableCell: l,
1380
+ applyTableBackground: v
1381
+ }) {
1382
+ const { t: u } = ne(), b = o.has("table"), [C, z] = A(null), $ = M(0), [L, _] = A(!1), F = x((c) => {
1383
+ $.current = Math.max(
1384
+ 0,
1385
+ $.current + (c ? 1 : -1)
1386
+ ), _($.current > 0);
1387
+ }, []);
1388
+ if (I(() => {
1389
+ if (L) return;
1390
+ if (!b || typeof window > "u") {
1391
+ z(null);
1392
+ return;
1393
+ }
1394
+ const c = () => {
1395
+ const H = h.current, y = g();
1396
+ if (!H || !y) {
1397
+ z(null);
1398
+ return;
1399
+ }
1400
+ const q = H.getBoundingClientRect(), O = y.getBoundingClientRect(), U = getComputedStyle(H).direction === "rtl", X = Math.max(0, O.top - q.top - 44), P = U ? q.right - O.right + O.width / 2 : O.left - q.left + O.width / 2;
1401
+ z({ top: X, start: Math.max(0, P), rtl: U });
1402
+ };
1403
+ c();
1404
+ const p = new ResizeObserver(c), E = h.current, T = g();
1405
+ return E && p.observe(E), T && p.observe(T), window.addEventListener("scroll", c, !0), window.addEventListener("resize", c), () => {
1406
+ p.disconnect(), window.removeEventListener("scroll", c, !0), window.removeEventListener("resize", c);
1407
+ };
1408
+ }, [b, L, h, g]), !b && !L || !C) return null;
1409
+ const m = [
1410
+ ["rowAbove", "rowBelow"],
1411
+ ["colLeft", "colRight"],
1412
+ ["addHead"],
1413
+ ...f ? ["colour"] : [],
1414
+ ["deleteRow", "deleteColumn"],
1415
+ ["deleteTable"]
1416
+ ];
1417
+ return (
1418
+ // Tooltips disambiguate the icon-only ops on hover (and provide each
1419
+ // button's accessible name via IconButton's `tooltip` prop). Radix Tooltip
1420
+ // needs a provider ancestor, so scope one to the bar.
1421
+ /* @__PURE__ */ t(vr, { children: /* @__PURE__ */ t(
1422
+ "div",
1423
+ {
1424
+ role: "group",
1425
+ "aria-label": u("editor.table.toolbar", "Table tools"),
1426
+ className: `${Ko} ${C.rtl ? "ds:translate-x-1/2" : "ds:-translate-x-1/2"}`,
1427
+ style: {
1428
+ "--rte-tt-top": `${C.top}px`,
1429
+ "--rte-tt-start": `${C.start}px`
1430
+ },
1431
+ children: m.map((c, p) => /* @__PURE__ */ k(pt, { children: [
1432
+ p > 0 ? /* @__PURE__ */ t("span", { "aria-hidden": "true", className: jt }) : null,
1433
+ c === "colour" ? /* @__PURE__ */ k(Me, { children: [
1434
+ /* @__PURE__ */ t(
1435
+ ur,
1436
+ {
1437
+ scope: "cell",
1438
+ icon: /* @__PURE__ */ t(Kn, {}),
1439
+ label: u("editor.table.cellColor", "Cell colour"),
1440
+ onOpenChange: F,
1441
+ saveTableCell: l,
1442
+ applyTableBackground: v
1443
+ }
1444
+ ),
1445
+ /* @__PURE__ */ t(
1446
+ ur,
1447
+ {
1448
+ scope: "row",
1449
+ icon: /* @__PURE__ */ t(Xn, {}),
1450
+ label: u("editor.table.rowColor", "Row colour"),
1451
+ onOpenChange: F,
1452
+ saveTableCell: l,
1453
+ applyTableBackground: v
1454
+ }
1455
+ )
1456
+ ] }) : c.map((E) => {
1457
+ const T = Vo[E];
1458
+ return /* @__PURE__ */ t(
1459
+ G,
1460
+ {
1461
+ size: "sm",
1462
+ intent: "ghost",
1463
+ icon: T.icon,
1464
+ tooltip: u(T.label[0], T.label[1]),
1465
+ onMouseDown: (H) => H.preventDefault(),
1466
+ onClick: () => i(T.command)
1467
+ },
1468
+ E
1469
+ );
1470
+ })
1471
+ ] }, c === "colour" ? "colour" : c[0]))
1472
+ }
1473
+ ) })
1474
+ );
1475
+ }
1476
+ const Ht = [
1477
+ "wysiwyg-img-inline",
1478
+ "wysiwyg-img-wrap-left",
1479
+ "wysiwyg-img-wrap-right"
1480
+ ], xr = [
1481
+ "wysiwyg-img-align-left",
1482
+ "wysiwyg-img-align-center",
1483
+ "wysiwyg-img-align-right"
1484
+ ];
1485
+ function mr(o, i) {
1486
+ return i.find((h) => o.classList.contains(h)) ?? "";
1487
+ }
1488
+ function Zo(o) {
1489
+ const i = o.closest(".redactor-in"), h = i instanceof HTMLElement ? i.clientWidth : 0, g = o.getBoundingClientRect().width;
1490
+ return h <= 0 || g <= 0 ? Ve : Math.round(Math.min(Ve, g / h * 100));
1491
+ }
1492
+ const Dt = 10, Ve = 100, Uo = 5, Qo = 10, gr = (o) => Math.min(Ve, Math.max(Dt, Math.round(o))), Yo = [
1493
+ {
1494
+ id: "wysiwyg-img-inline",
1495
+ icon: /* @__PURE__ */ t(yn, {}),
1496
+ label: ["editor.image.inline", "Inline with text"]
1497
+ },
1498
+ {
1499
+ id: "wysiwyg-img-wrap-left",
1500
+ icon: /* @__PURE__ */ t(Yn, {}),
1501
+ label: ["editor.image.wrapLeft", "Wrap left"]
1502
+ },
1503
+ {
1504
+ id: "wysiwyg-img-wrap-right",
1505
+ icon: /* @__PURE__ */ t(eo, {}),
1506
+ label: ["editor.image.wrapRight", "Wrap right"]
1507
+ }
1508
+ ], Jo = [
1509
+ {
1510
+ id: "wysiwyg-img-align-left",
1511
+ icon: /* @__PURE__ */ t(Co, {}),
1512
+ label: ["editor.image.alignLeft", "Align left"]
1513
+ },
1514
+ {
1515
+ id: "wysiwyg-img-align-center",
1516
+ icon: /* @__PURE__ */ t(vo, {}),
1517
+ label: ["editor.image.alignCenter", "Align centre"]
1518
+ },
1519
+ {
1520
+ id: "wysiwyg-img-align-right",
1521
+ icon: /* @__PURE__ */ t(xo, {}),
1522
+ label: ["editor.image.alignRight", "Align right"]
1523
+ }
1524
+ ], ea = [
1525
+ {
1526
+ id: "tl",
1527
+ pos: "ds:[inset-block-start:calc(var(--spacing-md)*-0.5)] ds:[inset-inline-start:calc(var(--spacing-md)*-0.5)]",
1528
+ cursor: "ds:cursor-nwse-resize",
1529
+ sign: -1,
1530
+ labelKey: "editor.image.resizeTopStart",
1531
+ labelFallback: "Resize image, top-start corner"
1532
+ },
1533
+ {
1534
+ id: "tr",
1535
+ pos: "ds:[inset-block-start:calc(var(--spacing-md)*-0.5)] ds:[inset-inline-end:calc(var(--spacing-md)*-0.5)]",
1536
+ cursor: "ds:cursor-nesw-resize",
1537
+ sign: 1,
1538
+ labelKey: "editor.image.resizeTopEnd",
1539
+ labelFallback: "Resize image, top-end corner"
1540
+ },
1541
+ {
1542
+ id: "bl",
1543
+ pos: "ds:[inset-block-end:calc(var(--spacing-md)*-0.5)] ds:[inset-inline-start:calc(var(--spacing-md)*-0.5)]",
1544
+ cursor: "ds:cursor-nesw-resize",
1545
+ sign: -1,
1546
+ labelKey: "editor.image.resizeBottomStart",
1547
+ labelFallback: "Resize image, bottom-start corner"
1548
+ },
1549
+ {
1550
+ id: "br",
1551
+ pos: "ds:[inset-block-end:calc(var(--spacing-md)*-0.5)] ds:[inset-inline-end:calc(var(--spacing-md)*-0.5)]",
1552
+ cursor: "ds:cursor-nwse-resize",
1553
+ sign: 1,
1554
+ labelKey: "editor.image.resizeBottomEnd",
1555
+ labelFallback: "Resize image, bottom-end corner"
1556
+ }
1557
+ ], ta = [
1558
+ "ds:absolute ds:z-20 ds:pointer-events-none",
1559
+ "ds:[inset-block-start:var(--rte-img-top)] ds:[inset-inline-start:var(--rte-img-start)]",
1560
+ "ds:[inline-size:var(--rte-img-width)] ds:[block-size:var(--rte-img-height)]",
1561
+ "ds:rounded-[var(--radius-2xs)]",
1562
+ "ds:[outline-style:solid] ds:[outline-width:var(--border-width-md)]",
1563
+ "ds:[outline-color:var(--accent)] ds:[outline-offset:var(--focus-ring-offset)]"
1564
+ ].join(" "), ra = [
1565
+ "ds:absolute ds:pointer-events-auto ds:touch-none",
1566
+ "ds:[inline-size:var(--spacing-md)] ds:[block-size:var(--spacing-md)]",
1567
+ "ds:rounded-[var(--radius-2xs)] ds:shadow-[var(--shadow-sm)]",
1568
+ "ds:bg-[var(--accent)] ds:border ds:border-[color:var(--background)]",
1569
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
1570
+ "ds:focus-visible:outline-solid ds:focus-visible:outline-[var(--ring)]",
1571
+ "ds:focus-visible:[outline-offset:var(--focus-ring-offset)]",
1572
+ "ds:forced-colors:bg-[CanvasText]"
1573
+ ].join(" "), na = [
1574
+ "ds:absolute ds:z-20 ds:flex ds:items-center ds:gap-[var(--spacing-2xs)]",
1575
+ "ds:[inset-block-start:var(--rte-img-bar-top)] ds:[inset-inline-start:var(--rte-img-center)]",
1576
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
1577
+ "ds:bg-[var(--popover)] ds:p-[var(--spacing-2xs)] ds:shadow-[var(--shadow-lg)]"
1578
+ ].join(" ");
1579
+ function oa({
1580
+ areaRef: o,
1581
+ activeImageEl: i,
1582
+ applyImageClass: h,
1583
+ setImageWidth: g
1584
+ }) {
1585
+ const { t: f } = ne(), [l, v] = A(null), u = M(null);
1586
+ I(() => {
1587
+ if (!i || typeof window > "u") {
1588
+ v(null);
1589
+ return;
1590
+ }
1591
+ const m = () => {
1592
+ const H = o.current;
1593
+ if (!H) {
1594
+ v(null);
1595
+ return;
1596
+ }
1597
+ const y = H.getBoundingClientRect(), q = i.getBoundingClientRect(), O = getComputedStyle(H).direction === "rtl", U = q.top - y.top, X = O ? y.right - q.right : q.left - y.left, P = X + q.width / 2, ae = Math.max(0, U - 44);
1598
+ v({
1599
+ top: U,
1600
+ start: Math.max(0, X),
1601
+ width: q.width,
1602
+ height: q.height,
1603
+ center: Math.max(0, P),
1604
+ barTop: ae,
1605
+ pct: Zo(i),
1606
+ rtl: O
1607
+ });
1608
+ };
1609
+ m();
1610
+ const c = new ResizeObserver(m);
1611
+ c.observe(i);
1612
+ const p = o.current;
1613
+ p && c.observe(p);
1614
+ const E = i.closest(".redactor-in");
1615
+ let T = null;
1616
+ return E && (T = new MutationObserver(m), T.observe(E, {
1617
+ subtree: !0,
1618
+ childList: !0,
1619
+ characterData: !0,
1620
+ attributes: !0,
1621
+ attributeFilter: ["class", "style", "width", "height", "src"]
1622
+ })), window.addEventListener("scroll", m, !0), window.addEventListener("resize", m), () => {
1623
+ c.disconnect(), T == null || T.disconnect(), window.removeEventListener("scroll", m, !0), window.removeEventListener("resize", m);
1624
+ };
1625
+ }, [i, o]);
1626
+ const b = x(
1627
+ (m) => (c) => {
1628
+ !c.isPrimary || !l || (c.preventDefault(), c.currentTarget.setPointerCapture(c.pointerId), u.current = {
1629
+ pointerId: c.pointerId,
1630
+ startX: c.clientX,
1631
+ startPct: l.pct,
1632
+ sign: m.sign * (l.rtl ? -1 : 1)
1633
+ });
1634
+ },
1635
+ [l]
1636
+ ), C = x(
1637
+ (m) => {
1638
+ const c = u.current;
1639
+ if (!c || m.pointerId !== c.pointerId || !i) return;
1640
+ const p = i.closest(".redactor-in"), E = p instanceof HTMLElement ? p.clientWidth : 0;
1641
+ if (E <= 0) return;
1642
+ const T = c.sign * (m.clientX - c.startX) / E * 100;
1643
+ g(gr(c.startPct + T));
1644
+ },
1645
+ [i, g]
1646
+ ), z = x(
1647
+ (m) => {
1648
+ const c = u.current;
1649
+ !c || m.pointerId !== c.pointerId || (m.currentTarget.releasePointerCapture(m.pointerId), u.current = null);
1650
+ },
1651
+ []
1652
+ ), $ = x(
1653
+ (m) => {
1654
+ if (!l) return;
1655
+ let c = null;
1656
+ const p = m.shiftKey ? Qo : Uo;
1657
+ switch (m.key) {
1658
+ // Up / right always grow; down / left always shrink — independent of
1659
+ // which corner has focus, so the gesture reads the same everywhere.
1660
+ case "ArrowRight":
1661
+ case "ArrowUp":
1662
+ c = l.pct + p;
1663
+ break;
1664
+ case "ArrowLeft":
1665
+ case "ArrowDown":
1666
+ c = l.pct - p;
1667
+ break;
1668
+ case "Home":
1669
+ c = Dt;
1670
+ break;
1671
+ case "End":
1672
+ c = Ve;
1673
+ break;
1674
+ default:
1675
+ return;
1676
+ }
1677
+ m.preventDefault(), g(gr(c));
1678
+ },
1679
+ [l, g]
1680
+ );
1681
+ if (!i || !l) return null;
1682
+ const L = mr(i, Ht), _ = mr(i, xr), F = f("editor.image.widthAnnounce", {
1683
+ width: l.pct,
1684
+ defaultValue: "{{width}} percent"
1685
+ });
1686
+ return /* @__PURE__ */ k(Me, { children: [
1687
+ /* @__PURE__ */ t(
1688
+ "div",
1689
+ {
1690
+ className: ta,
1691
+ style: {
1692
+ "--rte-img-top": `${l.top}px`,
1693
+ "--rte-img-start": `${l.start}px`,
1694
+ "--rte-img-width": `${l.width}px`,
1695
+ "--rte-img-height": `${l.height}px`
1696
+ },
1697
+ children: ea.map((m) => /* @__PURE__ */ t(
1698
+ "div",
1699
+ {
1700
+ role: "slider",
1701
+ tabIndex: 0,
1702
+ "aria-label": f(m.labelKey, m.labelFallback),
1703
+ "aria-orientation": "horizontal",
1704
+ "aria-valuemin": Dt,
1705
+ "aria-valuemax": Ve,
1706
+ "aria-valuenow": l.pct,
1707
+ "aria-valuetext": F,
1708
+ className: `${ra} ${m.pos} ${m.cursor}`,
1709
+ onPointerDown: b(m),
1710
+ onPointerMove: C,
1711
+ onPointerUp: z,
1712
+ onPointerCancel: z,
1713
+ onKeyDown: $
1714
+ },
1715
+ m.id
1716
+ ))
1717
+ }
1718
+ ),
1719
+ /* @__PURE__ */ t(vr, { children: /* @__PURE__ */ t(
1720
+ "div",
1721
+ {
1722
+ role: "group",
1723
+ "aria-label": f("editor.image.toolbar", "Image tools"),
1724
+ className: `${na} ${l.rtl ? "ds:translate-x-1/2" : "ds:-translate-x-1/2"}`,
1725
+ style: {
1726
+ "--rte-img-bar-top": `${l.barTop}px`,
1727
+ "--rte-img-center": `${l.center}px`
1728
+ },
1729
+ children: [Yo, Jo].map((m, c) => /* @__PURE__ */ k(pt, { children: [
1730
+ c > 0 ? /* @__PURE__ */ t("span", { "aria-hidden": "true", className: jt }) : null,
1731
+ m.map((p) => {
1732
+ const E = c === 0 ? L === p.id : _ === p.id;
1733
+ return /* @__PURE__ */ t(
1734
+ G,
1735
+ {
1736
+ size: "sm",
1737
+ intent: "ghost",
1738
+ icon: p.icon,
1739
+ "aria-pressed": E,
1740
+ tooltip: f(p.label[0], p.label[1]),
1741
+ onMouseDown: (T) => T.preventDefault(),
1742
+ onClick: () => h(p.id)
1743
+ },
1744
+ p.id
1745
+ );
1746
+ })
1747
+ ] }, c === 0 ? "flow" : "align"))
1748
+ }
1749
+ ) })
1750
+ ] });
1751
+ }
1752
+ function aa({
1753
+ run: o,
1754
+ active: i,
1755
+ preset: h,
1756
+ insertHtml: g,
1757
+ insertTable: f,
1758
+ saveSelection: l,
1759
+ restoreSelection: v,
1760
+ getSelectedText: u,
1761
+ uploadImage: b,
1762
+ enableColor: C = !1,
1763
+ enableImage: z = !1,
1764
+ enableTable: $ = !1,
1765
+ showExtensions: L = !1,
1766
+ variables: _,
1767
+ insertVariable: F
1768
+ }) {
1769
+ const { t: m } = ne(), c = (B) => B.preventDefault(), p = (B) => Io[h].includes(B), E = (B) => {
1770
+ if (!p(B)) return null;
1771
+ const Q = Lo[B];
1772
+ return /* @__PURE__ */ t(
1773
+ G,
1774
+ {
1775
+ size: "sm",
1776
+ intent: "ghost",
1777
+ icon: Q.icon,
1778
+ "aria-label": m(Q.label[0], Q.label[1]),
1779
+ "aria-pressed": Q.toggle ? i.has(Q.toggle) : void 0,
1780
+ onMouseDown: c,
1781
+ onClick: () => o(...Q.command)
1782
+ },
1783
+ Q.id
1784
+ );
1785
+ }, T = () => /* @__PURE__ */ t("span", { "aria-hidden": "true", className: jt }), H = p("format"), y = [
1786
+ E("bold"),
1787
+ E("italic"),
1788
+ E("underline"),
1789
+ E("strike"),
1790
+ C ? /* @__PURE__ */ t(
1791
+ jo,
1792
+ {
1793
+ run: o,
1794
+ saveSelection: l,
1795
+ restoreSelection: v
1796
+ },
1797
+ "colour"
1798
+ ) : null,
1799
+ C ? /* @__PURE__ */ t(
1800
+ Bo,
1801
+ {
1802
+ run: o,
1803
+ saveSelection: l,
1804
+ restoreSelection: v
1805
+ },
1806
+ "highlight"
1807
+ ) : null
1808
+ ].filter(Boolean), q = H || y.length > 0, O = [E("ul"), E("ol")].filter(Boolean), U = [
1809
+ p("link") ? /* @__PURE__ */ t(
1810
+ Oo,
1811
+ {
1812
+ insertHtml: g,
1813
+ saveSelection: l,
1814
+ restoreSelection: v,
1815
+ getSelectedText: u
1816
+ },
1817
+ "link"
1818
+ ) : null,
1819
+ z ? /* @__PURE__ */ t(
1820
+ Po,
1821
+ {
1822
+ insertHtml: g,
1823
+ saveSelection: l,
1824
+ restoreSelection: v,
1825
+ uploadImage: b
1826
+ },
1827
+ "image"
1828
+ ) : null,
1829
+ $ ? /* @__PURE__ */ t(
1830
+ Go,
1831
+ {
1832
+ run: o,
1833
+ insertTable: f,
1834
+ active: i
1835
+ },
1836
+ "table"
1837
+ ) : null,
1838
+ _ && _.length > 0 && F ? /* @__PURE__ */ t(
1839
+ Do,
1840
+ {
1841
+ variables: _,
1842
+ insertVariable: F,
1843
+ saveSelection: l
1844
+ },
1845
+ "variables"
1846
+ ) : null
1847
+ ].filter(Boolean), X = L ? [
1848
+ /* @__PURE__ */ t(
1849
+ G,
1850
+ {
1851
+ size: "sm",
1852
+ intent: "ghost",
1853
+ icon: /* @__PURE__ */ t(zo, {}),
1854
+ "aria-label": m("editor.extensions", "Editor extensions"),
1855
+ disabled: !0,
1856
+ onMouseDown: c
1857
+ },
1858
+ "extensions"
1859
+ )
1860
+ ] : [], P = [O, U, X].filter(
1861
+ (B) => B.length > 0
1862
+ ), ae = P.length > 0, be = (B) => P.map((Q, Ee) => /* @__PURE__ */ k(pt, { children: [
1863
+ Ee > 0 || B ? /* @__PURE__ */ t(T, {}) : null,
1864
+ Q
1865
+ ] }, Ee));
1866
+ return (
1867
+ // Outer element is the query container + visual chrome; the flex row is an
1868
+ // inner child so `container-type` never lands on the flex parent (which
1869
+ // would blockify the inline controls).
1870
+ /* @__PURE__ */ t("div", { className: $o(), "data-component": "editor-toolbar", children: /* @__PURE__ */ k(
1871
+ "div",
1872
+ {
1873
+ role: "group",
1874
+ "aria-label": m("editor.toolbarLabel"),
1875
+ className: Ho,
1876
+ children: [
1877
+ H ? /* @__PURE__ */ t(qo, { run: o, active: i, onTriggerDown: c }) : null,
1878
+ H && y.length > 0 ? /* @__PURE__ */ t(T, {}) : null,
1879
+ y,
1880
+ ae ? /* @__PURE__ */ k(Me, { children: [
1881
+ /* @__PURE__ */ t("div", { className: "ds:hidden ds:@[384px]/toolbar:contents", children: be(q) }),
1882
+ /* @__PURE__ */ k("div", { className: "ds:contents ds:@[384px]/toolbar:hidden", children: [
1883
+ q ? /* @__PURE__ */ t(T, {}) : null,
1884
+ /* @__PURE__ */ k(V, { children: [
1885
+ /* @__PURE__ */ t(V.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
1886
+ G,
1887
+ {
1888
+ size: "sm",
1889
+ intent: "ghost",
1890
+ icon: /* @__PURE__ */ t(dn, {}),
1891
+ "aria-label": m("editor.more", "More options"),
1892
+ onMouseDown: c
1893
+ }
1894
+ ) }),
1895
+ /* @__PURE__ */ t(V.Content, { side: "bottom", align: "end", children: /* @__PURE__ */ t("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)]", children: be(!1) }) })
1896
+ ] })
1897
+ ] })
1898
+ ] }) : null
1899
+ ]
1900
+ }
1901
+ ) })
1902
+ );
1903
+ }
1904
+ function fe(o) {
1905
+ return en(o, "rich-text");
1906
+ }
1907
+ function Lt(o = "") {
1908
+ const i = String(o).trim();
1909
+ if (i === "" || i === "<p><br></p>" || i === "<p>&nbsp;</p>")
1910
+ return "";
1911
+ const h = i.replace(/<br\s*\/?>/gi, "").replace(/&nbsp;/gi, "").replace(/<[^>]+>/g, "").trim();
1912
+ return h === "" && /<img\b[^>]*>/i.test(i) ? i : h === "" ? "" : i;
1913
+ }
1914
+ function ia(o) {
1915
+ return o.replace(
1916
+ /<img(?![^>]*\sloading=)([^>]*)>/gi,
1917
+ '<img loading="lazy"$1>'
1918
+ );
1919
+ }
1920
+ const It = /^[A-Za-z0-9_]+$/, kr = /\[\[([A-Za-z0-9_]+)\]\]/g, qt = "rte-variable-invalid", sa = new RegExp(
1921
+ `\\s*\\b${qt}\\b`,
1922
+ "g"
1923
+ );
1924
+ function fr(o) {
1925
+ return o.includes('data-redactor-type="variable"') ? o.replace(
1926
+ /<span\b[^>]*data-redactor-type="variable"[^>]*>/g,
1927
+ (i) => i.replace(/\s(?:data-label|title)="[^"]*"/g, "").replace(sa, "").replace(/\sclass=""/g, "")
1928
+ ) : o;
1929
+ }
1930
+ function la(o) {
1931
+ const i = o.replace(/<[^>]*>/g, " ");
1932
+ return Array.from(i.matchAll(kr), (h) => h[1]);
1933
+ }
1934
+ function ca(o) {
1935
+ return typeof o == "object" && o !== null && "name" in o && o.name === "AiCreditsExhaustedError";
1936
+ }
1937
+ function hr(o) {
1938
+ return `<span data-redactor-type="variable">[[${o}]]</span>`;
1939
+ }
1940
+ function $t(o, i) {
1941
+ var v;
1942
+ if (i.size === 0 || !o.includes("[[") || typeof DOMParser > "u")
1943
+ return o;
1944
+ const h = new DOMParser().parseFromString(
1945
+ `<body>${o}</body>`,
1946
+ "text/html"
1947
+ ), g = h.createTreeWalker(h.body, NodeFilter.SHOW_TEXT), f = [];
1948
+ for (let u = g.nextNode(); u; u = g.nextNode()) {
1949
+ const b = u;
1950
+ (v = b.parentElement) != null && v.closest('[data-redactor-type="variable"]') || b.data.includes("[[") && f.push(b);
1951
+ }
1952
+ let l = !1;
1953
+ for (const u of f) {
1954
+ const b = h.createDocumentFragment();
1955
+ let C = 0;
1956
+ for (const z of u.data.matchAll(kr)) {
1957
+ const $ = i.get(z[1].toLowerCase());
1958
+ if (!$ || z.index === void 0) continue;
1959
+ b.append(u.data.slice(C, z.index));
1960
+ const L = h.createElement("span");
1961
+ L.setAttribute("data-redactor-type", "variable"), L.textContent = `[[${$}]]`, b.append(L), C = z.index + z[0].length;
1962
+ }
1963
+ C !== 0 && (b.append(u.data.slice(C)), u.replaceWith(b), l = !0);
1964
+ }
1965
+ return l ? h.body.innerHTML : o;
1966
+ }
1967
+ function da(o) {
1968
+ if (!o || typeof o != "object") return;
1969
+ const i = o, h = (g) => {
1970
+ if (g && typeof g == "object" && "url" in g) {
1971
+ const f = g.url;
1972
+ return typeof f == "string" ? f : void 0;
1973
+ }
1974
+ };
1975
+ return typeof i.url == "string" ? i.url : h(i.file) ?? h(i.data) ?? Object.values(i).map(h).find(Boolean);
1976
+ }
1977
+ function ua(o) {
1978
+ if (o) return o;
1979
+ if (typeof window > "u") return null;
1980
+ const i = window;
1981
+ return i.$R ?? i.Redactor ?? null;
1982
+ }
1983
+ const ma = {
1984
+ bold: ["module.inline.format", { tag: "b" }],
1985
+ italic: ["module.inline.format", { tag: "i" }],
1986
+ strikethrough: ["module.inline.format", { tag: "del" }],
1987
+ bulletedList: ["module.list.toggle", "ul"],
1988
+ numberedList: ["module.list.toggle", "ol"],
1989
+ heading: ["module.block.format", { tag: "h2" }],
1990
+ quote: ["module.block.format", { tag: "blockquote" }],
1991
+ paragraph: ["module.block.format", { tag: "p" }]
1992
+ }, ga = {
1993
+ zh: "zh_cn",
1994
+ pt: "pt_br"
1995
+ };
1996
+ function fa(o) {
1997
+ const i = o.split("-")[0];
1998
+ return ga[i] ?? i ?? "en";
1999
+ }
2000
+ const ha = Ot(
2001
+ "redactor-theme-alfadocs ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]"
2002
+ ), pa = [
2003
+ "ds:absolute ds:z-30 ds:flex ds:flex-col ds:p-[var(--spacing-2xs)]",
2004
+ "ds:[inset-inline-start:var(--rte-typeahead-x)] ds:[inset-block-start:var(--rte-typeahead-y)]",
2005
+ "ds:min-w-[16rem] ds:[max-block-size:16rem] ds:overflow-y-auto",
2006
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
2007
+ "ds:bg-[var(--popover)] ds:text-[color:var(--popover-foreground)] ds:shadow-[var(--shadow-lg)]"
2008
+ ].join(" "), ba = [
2009
+ "ds:group ds:flex ds:items-baseline ds:gap-[var(--spacing-sm)] ds:cursor-pointer",
2010
+ "ds:rounded-[var(--radius-sm)] ds:px-[var(--spacing-sm)] ds:py-[var(--spacing-xs)]",
2011
+ "ds:text-[length:var(--font-size-sm)]",
2012
+ "ds:aria-selected:bg-[var(--accent)] ds:aria-selected:text-[color:var(--accent-foreground)]"
2013
+ ].join(" "), ya = Ot(
2014
+ [
2015
+ "ds:block ds:[inline-size:100%]",
2016
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
2017
+ "ds:bg-[var(--background)] ds:text-[var(--foreground)]",
2018
+ "ds:shadow-[var(--shadow-md)]",
2019
+ "ds:font-[family-name:var(--font-sans)] ds:text-[length:var(--font-size-base)]",
2020
+ "ds:p-[var(--spacing-md)] ds:[min-block-size:var(--rich-text-editor-min-block-size)]",
2021
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
2022
+ "ds:focus-visible:outline-solid",
2023
+ "ds:focus-visible:outline-[var(--ring)]",
2024
+ "ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
2025
+ "ds:forced-colors:focus-visible:outline-[CanvasText]"
2026
+ ].join(" ")
2027
+ ), Cr = [
2028
+ "ds:inline-flex ds:items-center ds:justify-center",
2029
+ "ds:[min-block-size:var(--min-target-size)] ds:[min-inline-size:var(--min-target-size)]",
2030
+ "ds:text-[color:var(--primary-foreground)]",
2031
+ "ds:transition-colors",
2032
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
2033
+ "ds:focus-visible:outline-solid",
2034
+ "ds:focus-visible:outline-[var(--primary-foreground)]",
2035
+ "ds:focus-visible:[outline-offset:calc(var(--focus-ring-width)*-1)]"
2036
+ ].join(" "), va = `${Cr} ds:hover:bg-[color-mix(in_srgb,var(--primary-foreground)_15%,transparent)]`, wa = `${Cr} ds:bg-[var(--destructive)] ds:hover:bg-[color-mix(in_srgb,var(--destructive)_88%,var(--primary-foreground))]`, xa = Qr(
2037
+ ({
2038
+ id: o,
2039
+ defaultValue: i,
2040
+ value: h,
2041
+ onChange: g,
2042
+ toolbar: f = "standard",
2043
+ placeholder: l,
2044
+ readOnly: v = !1,
2045
+ ariaLabel: u,
2046
+ minHeight: b,
2047
+ showExtensions: C,
2048
+ className: z,
2049
+ redactor: $,
2050
+ options: L,
2051
+ plugins: _,
2052
+ lang: F,
2053
+ imageUploadUrl: m,
2054
+ onUploadImage: c,
2055
+ onKeyDown: p,
2056
+ onRequestAiDraft: E,
2057
+ aiDraftFormat: T = "html",
2058
+ aiPrivacyNotice: H,
2059
+ aiConsent: y,
2060
+ aiConsentHeadingLevel: q,
2061
+ onDictate: O,
2062
+ onProofread: U,
2063
+ onAutoFormat: X,
2064
+ variables: P,
2065
+ validateVariable: ae,
2066
+ onVariableValidityChange: be,
2067
+ renderHelpMeWrite: B,
2068
+ onAiCreditsExhausted: Q
2069
+ }, Ee) => {
2070
+ const { t: D, i18n: j } = ne(), K = _e(), ee = qe(
2071
+ () => `rte-${K.replace(/[^a-zA-Z0-9-_]/g, "")}`,
2072
+ [K]
2073
+ ), N = `#${ee}`, ie = M(null), te = M(null), bt = M(!1), yt = M(v), W = M(null), Ke = M(null), [re, Bt] = A(!1), [Ft, Re] = A(!1), [Nr, Tr] = A(""), [Ar, Gt] = A(!1), We = M(Q), Vt = M(B);
2074
+ I(() => {
2075
+ We.current = Q, Vt.current = B;
2076
+ }, [Q, B]);
2077
+ const Xe = M(null), ye = qe(
2078
+ () => new Map(
2079
+ (P ?? []).map((e) => e.token).filter((e) => It.test(e)).map((e) => [e.toLowerCase(), e])
2080
+ ),
2081
+ [P]
2082
+ ), Kt = qe(
2083
+ () => new Map(
2084
+ (P ?? []).map(
2085
+ (e) => [e.token.toLowerCase(), e.label]
2086
+ )
2087
+ ),
2088
+ [P]
2089
+ ), Ze = M(ye);
2090
+ I(() => {
2091
+ Ze.current = ye;
2092
+ }, [ye]);
2093
+ const vt = M(ae);
2094
+ I(() => {
2095
+ vt.current = ae;
2096
+ }, [ae]);
2097
+ const wt = ae !== void 0, xt = x(
2098
+ (e) => wt && vt.current ? vt.current(e) : ye.has(e.toLowerCase()),
2099
+ [wt, ye]
2100
+ ), Se = ye.size > 0 || wt, [Le, Wt] = A([]), Ue = M(be);
2101
+ I(() => {
2102
+ Ue.current = be;
2103
+ }, [be]);
2104
+ const xe = M(() => {
2105
+ }), [Xt, zr] = A(
2106
+ () => /* @__PURE__ */ new Set()
2107
+ ), Qe = M(null), [Mr, _r] = A(
2108
+ null
2109
+ ), Ye = x((e) => {
2110
+ Qe.current = e, _r(e);
2111
+ }, []), Oe = M(null), J = M(g), Je = M(p);
2112
+ I(() => {
2113
+ J.current = g, Je.current = p;
2114
+ }, [g, p]);
2115
+ const Er = M(
2116
+ (() => {
2117
+ const e = h ?? i ?? "";
2118
+ return e ? fe(e) : "";
2119
+ })()
2120
+ ), ue = x(() => {
2121
+ var r;
2122
+ const e = te.current;
2123
+ if (e)
2124
+ try {
2125
+ const n = e(N, "source.getCode");
2126
+ if (typeof n == "string") return fr(n);
2127
+ } catch {
2128
+ }
2129
+ return ((r = ie.current) == null ? void 0 : r.value) ?? "";
2130
+ }, [N]);
2131
+ I(() => {
2132
+ xe.current = () => {
2133
+ var n;
2134
+ if (!Se) {
2135
+ Wt((a) => a.length ? [] : a);
2136
+ return;
2137
+ }
2138
+ const e = (n = W.current) == null ? void 0 : n.querySelector(".redactor-in");
2139
+ e == null || e.querySelectorAll('[data-redactor-type="variable"]').forEach((a) => {
2140
+ const s = /^\[\[([A-Za-z0-9_]+)\]\]$/.exec(
2141
+ a.textContent ?? ""
2142
+ ), d = !s || !xt(s[1]);
2143
+ a.classList.contains(qt) !== d && a.classList.toggle(qt, d);
2144
+ const w = s ? Kt.get(s[1].toLowerCase()) ?? s[1] : a.textContent ?? "";
2145
+ a.getAttribute("data-label") !== w && a.setAttribute("data-label", w);
2146
+ const S = a.textContent ?? "";
2147
+ a.getAttribute("title") !== S && a.setAttribute("title", S);
2148
+ });
2149
+ const r = Array.from(
2150
+ new Set(
2151
+ la(ue()).filter(
2152
+ (a) => !xt(a)
2153
+ )
2154
+ )
2155
+ );
2156
+ Wt(
2157
+ (a) => a.length === r.length && a.every((s, d) => s === r[d]) ? a : r
2158
+ );
2159
+ }, xe.current();
2160
+ }, [Se, xt, Kt, ue]), I(() => {
2161
+ var n;
2162
+ const r = ((n = W.current) == null ? void 0 : n.querySelector(".redactor-in")) ?? ie.current;
2163
+ r && (Le.length > 0 ? (r.setAttribute("aria-invalid", "true"), r.setAttribute("aria-describedby", `${ee}-variables-error`)) : (r.removeAttribute("aria-invalid"), r.removeAttribute("aria-describedby")));
2164
+ }, [Le, ee, re]), I(() => {
2165
+ var e;
2166
+ Se && ((e = Ue.current) == null || e.call(Ue, Le));
2167
+ }, [Le, Se]);
2168
+ const se = x(
2169
+ (e, ...r) => {
2170
+ const n = te.current;
2171
+ if (!n) return !1;
2172
+ const a = yt.current;
2173
+ if (a)
2174
+ try {
2175
+ n(N, "disableReadOnly");
2176
+ } catch {
2177
+ }
2178
+ try {
2179
+ return n(N, e, ...r), !0;
2180
+ } catch {
2181
+ return !1;
2182
+ } finally {
2183
+ if (a)
2184
+ try {
2185
+ n(N, "enableReadOnly");
2186
+ } catch {
2187
+ }
2188
+ }
2189
+ },
2190
+ [N]
2191
+ ), le = x(
2192
+ (e, r) => {
2193
+ var we;
2194
+ const n = (r == null ? void 0 : r.asHtml) ?? !0, a = n ? fe(e) : e;
2195
+ if (se(n ? "insertion.insertHtml" : "insertion.insertText", a)) return;
2196
+ const d = ie.current;
2197
+ if (!d) return;
2198
+ const w = d.selectionStart ?? d.value.length, S = d.selectionEnd ?? d.value.length;
2199
+ d.value = d.value.slice(0, w) + a + d.value.slice(S);
2200
+ const de = w + a.length;
2201
+ try {
2202
+ d.setSelectionRange(de, de);
2203
+ } catch {
2204
+ }
2205
+ (we = J.current) == null || we.call(J, { html: fe(d.value), markdown: "" });
2206
+ },
2207
+ [se]
2208
+ ), ke = M(null), oe = x(() => {
2209
+ var a;
2210
+ const e = (a = W.current) == null ? void 0 : a.querySelector(".redactor-in"), r = typeof window < "u" ? window.getSelection() : null, n = /* @__PURE__ */ new Set();
2211
+ if (e && r && r.anchorNode && e.contains(r.anchorNode) && typeof document.queryCommandState == "function") {
2212
+ r.rangeCount > 0 && (ke.current = r.getRangeAt(0).cloneRange());
2213
+ try {
2214
+ document.queryCommandState("bold") && n.add("bold"), document.queryCommandState("italic") && n.add("italic"), document.queryCommandState("underline") && n.add("underline"), document.queryCommandState("strikeThrough") && n.add("strike"), document.queryCommandState("insertUnorderedList") && n.add("ul"), document.queryCommandState("insertOrderedList") && n.add("ol");
2215
+ const s = String(
2216
+ document.queryCommandValue("formatBlock") || ""
2217
+ ).toLowerCase();
2218
+ /^h[1-6]$/.test(s) ? (n.add("heading"), n.add(s)) : s === "blockquote" ? n.add("quote") : n.add("paragraph");
2219
+ const d = r.anchorNode.nodeType === Node.TEXT_NODE ? r.anchorNode.parentElement : r.anchorNode;
2220
+ d && e.contains(d) && d.closest("table") && n.add("table");
2221
+ } catch {
2222
+ }
2223
+ }
2224
+ zr(
2225
+ (s) => s.size === n.size && [...n].every((d) => s.has(d)) ? s : n
2226
+ );
2227
+ }, []), Ie = x(
2228
+ (e, ...r) => {
2229
+ se(e, ...r), typeof window < "u" ? window.requestAnimationFrame(() => oe()) : oe();
2230
+ },
2231
+ [se, oe]
2232
+ );
2233
+ I(() => {
2234
+ const e = W.current;
2235
+ if (!e) return;
2236
+ const r = {
2237
+ b: ["module.inline.format", { tag: "b" }],
2238
+ i: ["module.inline.format", { tag: "i" }],
2239
+ u: ["module.inline.format", { tag: "u" }]
2240
+ }, n = (a) => {
2241
+ if (!(a.metaKey || a.ctrlKey) || a.altKey || a.shiftKey || a.isComposing) return;
2242
+ const s = r[a.key.toLowerCase()];
2243
+ if (!s) return;
2244
+ const d = e.querySelector(".redactor-in");
2245
+ !d || !(a.target instanceof Node) || !d.contains(a.target) || yt.current || (a.preventDefault(), a.stopImmediatePropagation(), Ie(...s));
2246
+ };
2247
+ return e.addEventListener("keydown", n, !0), () => e.removeEventListener("keydown", n, !0);
2248
+ }, [Ie]);
2249
+ const Ce = x(
2250
+ (e) => {
2251
+ le(e, { asHtml: !0 }), typeof window < "u" && window.requestAnimationFrame(() => oe());
2252
+ },
2253
+ [le, oe]
2254
+ ), [Y, kt] = A(null), Pe = M(null), je = `${ee}-variables`, Ne = qe(() => {
2255
+ if (!Y) return [];
2256
+ const e = Y.query.trim().toLowerCase(), r = e.replace(/\s+/g, "_");
2257
+ return (P ?? []).filter(
2258
+ (n) => It.test(n.token) && (!e || n.token.toLowerCase().includes(r) || n.label.toLowerCase().includes(e))
2259
+ );
2260
+ }, [Y, P]), me = x(() => {
2261
+ Pe.current = null, kt(null);
2262
+ }, []), et = x(
2263
+ (e, r) => {
2264
+ const n = window.getSelection();
2265
+ if (!n) return;
2266
+ const a = document.createRange();
2267
+ a.setStart(r.node, r.start), a.setEnd(r.node, r.end), n.removeAllRanges(), n.addRange(a), Ce(hr(e)), window.requestAnimationFrame(() => xe.current());
2268
+ },
2269
+ [Ce]
2270
+ );
2271
+ I(() => {
2272
+ const e = W.current;
2273
+ if (!e || !Se) return;
2274
+ const r = () => {
2275
+ var sr;
2276
+ const s = e.querySelector(".redactor-in"), d = window.getSelection();
2277
+ if (!s || !d || d.rangeCount === 0 || !d.isCollapsed) {
2278
+ me();
2279
+ return;
2280
+ }
2281
+ const { startContainer: w, startOffset: S } = d.getRangeAt(0);
2282
+ if (w.nodeType !== Node.TEXT_NODE || !s.contains(w) || (((sr = w.parentElement) == null ? void 0 : sr.closest(
2283
+ '[data-redactor-type="variable"]'
2284
+ )) ?? null) !== null) {
2285
+ me();
2286
+ return;
2287
+ }
2288
+ const de = w, we = de.data.slice(0, S), dt = /\[\[([A-Za-z0-9_]+)\]\]$/.exec(we);
2289
+ if (dt) {
2290
+ me(), et(
2291
+ ye.get(dt[1].toLowerCase()) ?? dt[1],
2292
+ { node: de, start: S - dt[0].length, end: S }
2293
+ );
2294
+ return;
2295
+ }
2296
+ const ut = /\[\[([A-Za-z0-9_ ]{0,40})$/.exec(we), At = Ke.current;
2297
+ if (!ut || !At || (P ?? []).length === 0) {
2298
+ me();
2299
+ return;
2300
+ }
2301
+ const zt = {
2302
+ node: de,
2303
+ start: S - ut[0].length,
2304
+ end: S
2305
+ };
2306
+ Pe.current = zt;
2307
+ const Mt = document.createRange();
2308
+ Mt.setStart(de, zt.start), Mt.setEnd(de, zt.end);
2309
+ const _t = Mt.getBoundingClientRect(), Et = At.getBoundingClientRect(), Ur = getComputedStyle(At).direction === "rtl";
2310
+ kt((Rt) => ({
2311
+ query: ut[1],
2312
+ index: Rt && Rt.query === ut[1] ? Rt.index : 0,
2313
+ left: Ur ? Et.right - _t.right : _t.left - Et.left,
2314
+ top: _t.bottom - Et.top + 4
2315
+ }));
2316
+ }, n = (s) => {
2317
+ if (!Pe.current) return;
2318
+ const d = tt.current.length;
2319
+ if (s.key === "ArrowDown" || s.key === "ArrowUp") {
2320
+ if (!d) return;
2321
+ s.preventDefault(), s.stopImmediatePropagation();
2322
+ const w = s.key === "ArrowDown" ? 1 : d - 1;
2323
+ kt(
2324
+ (S) => S && { ...S, index: (S.index + w) % d }
2325
+ );
2326
+ } else if ((s.key === "Enter" || s.key === "Tab") && d) {
2327
+ s.preventDefault(), s.stopImmediatePropagation();
2328
+ const w = tt.current[Zt.current] ?? tt.current[0], S = Pe.current;
2329
+ me(), et(w.token, S);
2330
+ } else s.key === "Escape" && (s.preventDefault(), s.stopImmediatePropagation(), me());
2331
+ }, a = () => me();
2332
+ return e.addEventListener("input", r), e.addEventListener("keydown", n, !0), e.addEventListener("focusout", a), () => {
2333
+ e.removeEventListener("input", r), e.removeEventListener("keydown", n, !0), e.removeEventListener("focusout", a);
2334
+ };
2335
+ }, [
2336
+ Se,
2337
+ ye,
2338
+ P,
2339
+ et,
2340
+ me
2341
+ ]);
2342
+ const tt = M(Ne), Zt = M(0);
2343
+ I(() => {
2344
+ tt.current = Ne, Zt.current = (Y == null ? void 0 : Y.index) ?? 0;
2345
+ }, [Ne, Y]), I(() => {
2346
+ var r;
2347
+ const e = (r = W.current) == null ? void 0 : r.querySelector(".redactor-in");
2348
+ if (e)
2349
+ if (Y) {
2350
+ e.setAttribute("aria-expanded", "true"), e.setAttribute("aria-controls", je);
2351
+ const n = Ne[Y.index];
2352
+ n ? e.setAttribute(
2353
+ "aria-activedescendant",
2354
+ `${je}-${n.token}`
2355
+ ) : e.removeAttribute("aria-activedescendant");
2356
+ } else
2357
+ e.removeAttribute("aria-expanded"), e.removeAttribute("aria-controls"), e.removeAttribute("aria-activedescendant");
2358
+ }, [Y, Ne, je]);
2359
+ const Be = x(() => {
2360
+ var r;
2361
+ if (typeof window < "u") {
2362
+ const n = (r = W.current) == null ? void 0 : r.querySelector(".redactor-in"), a = window.getSelection();
2363
+ n && a && a.rangeCount > 0 && a.anchorNode && n.contains(a.anchorNode) && (ke.current = a.getRangeAt(0).cloneRange());
2364
+ }
2365
+ const e = te.current;
2366
+ if (e)
2367
+ try {
2368
+ e(N, "selection.save");
2369
+ } catch {
2370
+ }
2371
+ }, [N]), ve = x(() => {
2372
+ const e = te.current;
2373
+ if (!e) return;
2374
+ const r = ke.current;
2375
+ try {
2376
+ e(N, "editor.focus");
2377
+ } catch {
2378
+ }
2379
+ if (r && typeof window < "u") {
2380
+ const n = window.getSelection();
2381
+ if (n)
2382
+ try {
2383
+ n.removeAllRanges(), n.addRange(r);
2384
+ return;
2385
+ } catch {
2386
+ }
2387
+ }
2388
+ try {
2389
+ e(N, "selection.restore");
2390
+ } catch {
2391
+ }
2392
+ }, [N]), Rr = x(() => {
2393
+ var n;
2394
+ if (typeof window > "u") return "";
2395
+ const e = (n = W.current) == null ? void 0 : n.querySelector(".redactor-in"), r = window.getSelection();
2396
+ return !e || !r || !r.anchorNode || !e.contains(r.anchorNode) ? "" : r.toString();
2397
+ }, []), Sr = x(() => {
2398
+ var s;
2399
+ if (typeof window > "u") return null;
2400
+ const e = (s = W.current) == null ? void 0 : s.querySelector(".redactor-in"), r = window.getSelection();
2401
+ if (!e || !r || r.rangeCount === 0) return null;
2402
+ const n = r.anchorNode, a = n && n.nodeType === Node.TEXT_NODE ? n.parentElement : n;
2403
+ return !a || !e.contains(a) ? null : a.closest("table");
2404
+ }, []), Ut = M(null), rt = x(() => {
2405
+ var s;
2406
+ if (typeof window > "u") return null;
2407
+ const e = (s = W.current) == null ? void 0 : s.querySelector(".redactor-in"), r = window.getSelection();
2408
+ if (!e || !r || r.rangeCount === 0) return null;
2409
+ const n = r.anchorNode, a = n && n.nodeType === Node.TEXT_NODE ? n.parentElement : n;
2410
+ return !a || !e.contains(a) ? null : a.closest("td,th");
2411
+ }, []), Lr = x(() => {
2412
+ Ut.current = rt();
2413
+ }, [rt]), Ir = x(
2414
+ (e, r) => {
2415
+ var d;
2416
+ const n = Ut.current ?? rt();
2417
+ if (!n) return;
2418
+ const a = e === "row" ? Array.from(((d = n.closest("tr")) == null ? void 0 : d.children) ?? [n]).filter(
2419
+ (w) => w instanceof HTMLElement && (w.tagName === "TD" || w.tagName === "TH")
2420
+ ) : [n], s = te.current;
2421
+ if (s)
2422
+ try {
2423
+ s(N, "module.buffer.trigger");
2424
+ } catch {
2425
+ }
2426
+ for (const w of a)
2427
+ r ? w.style.setProperty("background-color", r) : w.style.removeProperty("background-color");
2428
+ if (s)
2429
+ try {
2430
+ s(N, "broadcast", "hardsync");
2431
+ } catch {
2432
+ }
2433
+ typeof window < "u" && window.requestAnimationFrame(() => oe());
2434
+ },
2435
+ [rt, N, oe]
2436
+ );
2437
+ I(() => {
2438
+ const e = W.current;
2439
+ if (typeof window > "u" || !e) return;
2440
+ const r = (s) => {
2441
+ const d = e.querySelector(".redactor-in"), w = s.target;
2442
+ if (!d || !(w instanceof Node) || !d.contains(w))
2443
+ return;
2444
+ const S = w instanceof Element ? w.closest("img") : null;
2445
+ Ye(S && d.contains(S) ? S : null);
2446
+ }, n = (s) => {
2447
+ s.key === "Escape" && Qe.current && Ye(null);
2448
+ }, a = (s) => {
2449
+ const d = s.relatedTarget;
2450
+ (!(d instanceof Node) || !e.contains(d)) && Ye(null);
2451
+ };
2452
+ return e.addEventListener("click", r), e.addEventListener("keydown", n), e.addEventListener("focusout", a), () => {
2453
+ e.removeEventListener("click", r), e.removeEventListener("keydown", n), e.removeEventListener("focusout", a);
2454
+ };
2455
+ }, [Ye]);
2456
+ const $r = x(
2457
+ (e) => {
2458
+ const r = Qe.current;
2459
+ if (!r) return;
2460
+ const n = Ht.includes(
2461
+ e
2462
+ ) ? Ht : xr, a = te.current;
2463
+ if (a)
2464
+ try {
2465
+ a(N, "module.buffer.trigger");
2466
+ } catch {
2467
+ }
2468
+ for (const s of n) r.classList.remove(s);
2469
+ if (r.classList.add(e), a)
2470
+ try {
2471
+ a(N, "broadcast", "hardsync");
2472
+ } catch {
2473
+ }
2474
+ typeof window < "u" && window.requestAnimationFrame(() => oe());
2475
+ },
2476
+ [N, oe]
2477
+ ), Hr = x(
2478
+ (e) => {
2479
+ const r = Qe.current;
2480
+ if (!r) return;
2481
+ const n = te.current;
2482
+ if (n)
2483
+ try {
2484
+ n(N, "module.buffer.trigger");
2485
+ } catch {
2486
+ }
2487
+ if (r.style.setProperty("width", `${e}%`), n)
2488
+ try {
2489
+ n(N, "broadcast", "hardsync");
2490
+ } catch {
2491
+ }
2492
+ typeof window < "u" && window.requestAnimationFrame(() => oe());
2493
+ },
2494
+ [N, oe]
2495
+ ), Dr = x(
2496
+ (e) => {
2497
+ var n;
2498
+ const r = te.current;
2499
+ if (r && typeof window < "u") {
2500
+ const a = (n = W.current) == null ? void 0 : n.querySelector(".redactor-in"), s = window.getSelection(), d = s == null ? void 0 : s.anchorNode, w = d && d.nodeType === Node.TEXT_NODE ? d.parentElement : d, S = w && (a != null && a.contains(w)) ? w.closest("ul,ol") : null;
2501
+ if (S)
2502
+ try {
2503
+ r(N, "caret.setAfter", S);
2504
+ } catch {
2505
+ }
2506
+ }
2507
+ Ce(e), typeof window < "u" && window.requestAnimationFrame(() => {
2508
+ var s;
2509
+ const a = (s = W.current) == null ? void 0 : s.querySelector(".redactor-in");
2510
+ a == null || a.querySelectorAll("table td, table th").forEach((d) => {
2511
+ let w = d.lastChild;
2512
+ for (; w && w.nodeType === Node.TEXT_NODE && !(w.textContent ?? "").trim(); ) {
2513
+ const S = w.previousSibling;
2514
+ d.removeChild(w), w = S;
2515
+ }
2516
+ });
2517
+ });
2518
+ },
2519
+ [Ce, N]
2520
+ ), qr = x(
2521
+ async (e, r) => {
2522
+ if (c) return c(e, r);
2523
+ if (!m) throw new Error("No image upload URL configured.");
2524
+ const n = new FormData();
2525
+ n.append("file", e);
2526
+ const a = await fetch(m, {
2527
+ method: "POST",
2528
+ body: n,
2529
+ credentials: "same-origin",
2530
+ signal: r
2531
+ });
2532
+ if (!a.ok) throw new Error(`Image upload failed (${a.status}).`);
2533
+ const s = da(await a.json());
2534
+ if (!s) throw new Error("Image upload response contained no URL.");
2535
+ return s;
2536
+ },
2537
+ [m, c]
2538
+ ), Fe = M(null), nt = M(null), [Te, Qt] = A(!1), [Or, Yt] = A(!1), [Pr, Ct] = A(""), ot = x(() => {
2539
+ const e = nt.current;
2540
+ e != null && e.parentNode && e.parentNode.removeChild(e), nt.current = null;
2541
+ }, []), Jt = x((e) => {
2542
+ var a;
2543
+ const r = (a = W.current) == null ? void 0 : a.querySelector(
2544
+ ".redactor-in"
2545
+ );
2546
+ if (!r) return;
2547
+ let n = nt.current;
2548
+ if (!n || !r.contains(n)) {
2549
+ n = document.createElement("span"), n.setAttribute("data-rte-interim", ""), n.setAttribute("contenteditable", "false");
2550
+ const s = window.getSelection();
2551
+ if (s && s.rangeCount > 0 && r.contains(s.anchorNode)) {
2552
+ const d = s.getRangeAt(0);
2553
+ d.collapse(!1), d.insertNode(n);
2554
+ } else
2555
+ r.appendChild(n);
2556
+ nt.current = n;
2557
+ }
2558
+ n.textContent = e;
2559
+ }, []), at = x(() => {
2560
+ var e;
2561
+ (e = Fe.current) == null || e.abort();
2562
+ }, []), er = x(() => {
2563
+ var d;
2564
+ if (typeof window > "u") return !1;
2565
+ const e = window.getSelection(), r = (d = W.current) == null ? void 0 : d.querySelector(".redactor-in");
2566
+ if (!e || e.rangeCount === 0 || !r) return !1;
2567
+ const { startContainer: n, startOffset: a } = e.getRangeAt(0);
2568
+ if (!r.contains(n) || n.nodeType !== Node.TEXT_NODE || a === 0)
2569
+ return !1;
2570
+ const s = n.data.charAt(a - 1);
2571
+ return /\S/.test(s) && s !== " ";
2572
+ }, []), ce = y !== void 0 && !y.granted, it = x(() => {
2573
+ if (!O || ce) return;
2574
+ const e = new AbortController();
2575
+ Fe.current = e, Yt(!1), Qt(!0), Ct(D("editor.ai.listening")), ot(), O({
2576
+ signal: e.signal,
2577
+ // Interim text shows live in the editor (grey + caret); each final
2578
+ // replaces it with committed text at the caret.
2579
+ onPartialTranscript: (r) => {
2580
+ e.signal.aborted || Jt(r);
2581
+ },
2582
+ onFinalTranscript: (r) => {
2583
+ if (e.signal.aborted) return;
2584
+ ot();
2585
+ const n = r.trim();
2586
+ if (n) {
2587
+ const a = er() ? " " : "";
2588
+ le(`${a}${n} `, { asHtml: !1 }), Ct(n);
2589
+ }
2590
+ }
2591
+ }).catch((r) => {
2592
+ var n;
2593
+ if (!(e.signal.aborted || r && typeof r == "object" && "name" in r && r.name === "AbortError")) {
2594
+ if (ca(r) && ((n = We.current) == null || n.call(We), Vt.current)) {
2595
+ Gt(!0), Re(!0);
2596
+ return;
2597
+ }
2598
+ Yt(!0);
2599
+ }
2600
+ }).finally(() => {
2601
+ ot(), Fe.current === e && (Fe.current = null, Qt(!1), Ct(""));
2602
+ });
2603
+ }, [
2604
+ O,
2605
+ ce,
2606
+ le,
2607
+ ot,
2608
+ Jt,
2609
+ er,
2610
+ D
2611
+ ]);
2612
+ I(() => () => {
2613
+ var e;
2614
+ return (e = Fe.current) == null ? void 0 : e.abort();
2615
+ }, []);
2616
+ const [jr, st] = A(null), $e = M(null), [Br, tr] = A(!1), Fr = ((y == null ? void 0 : y.pending) ?? !1) || Br, lt = M(!1), rr = x(() => {
2617
+ $e.current = null, lt.current = !1, st(null);
2618
+ }, []), Gr = x(() => {
2619
+ var r;
2620
+ lt.current = !0;
2621
+ const e = (r = y == null ? void 0 : y.onGrant) == null ? void 0 : r.call(y);
2622
+ e && typeof e.then == "function" && (tr(!0), Promise.resolve(e).catch(() => {
2623
+ }).finally(() => tr(!1)));
2624
+ }, [y]), nr = M((y == null ? void 0 : y.granted) ?? !0);
2625
+ I(() => {
2626
+ const e = nr.current;
2627
+ if (nr.current = (y == null ? void 0 : y.granted) ?? !0, !e && (y != null && y.granted) && $e.current) {
2628
+ const r = $e.current, n = lt.current;
2629
+ if ($e.current = null, lt.current = !1, st(null), !n) return;
2630
+ r === "write" ? Re(!0) : (ve(), it());
2631
+ }
2632
+ }, [y == null ? void 0 : y.granted, ve, it]), I(() => {
2633
+ ce && (Re(!1), Te && at());
2634
+ }, [ce, Te, at]);
2635
+ const Vr = x(() => {
2636
+ if (Te) {
2637
+ at();
2638
+ return;
2639
+ }
2640
+ if (ce) {
2641
+ Be(), $e.current = "dictate", st("dictate");
2642
+ return;
2643
+ }
2644
+ it();
2645
+ }, [Te, at, ce, Be, it]), Kr = x(() => {
2646
+ Be();
2647
+ const e = ke.current;
2648
+ if (Xe.current = e ? e.cloneRange() : null, Tr(e && !e.collapsed ? e.toString() : ""), ce) {
2649
+ $e.current = "write", st("write");
2650
+ return;
2651
+ }
2652
+ Re(!0);
2653
+ }, [Be, ce]), or = qe(() => y != null && y.granted ? /* @__PURE__ */ k(Me, { children: [
2654
+ D(
2655
+ "editor.ai.consentRecorded",
2656
+ "AI assistance consent has been recorded."
2657
+ ),
2658
+ H ? /* @__PURE__ */ k(Me, { children: [
2659
+ " ",
2660
+ H
2661
+ ] }) : null
2662
+ ] }) : H, [y, H, D]), [ge, Nt] = A(null), Ae = M(null), ar = x(
2663
+ (e, r) => {
2664
+ if (Ae.current) return;
2665
+ const n = new AbortController();
2666
+ Ae.current = n, Nt(e);
2667
+ const a = ue();
2668
+ Promise.resolve(r({ html: a, signal: n.signal })).then((s) => {
2669
+ var w;
2670
+ if (n.signal.aborted) return;
2671
+ const d = fe(String(s ?? ""));
2672
+ se("source.setCode", d), (w = J.current) == null || w.call(J, { html: d, markdown: "" });
2673
+ }).catch(() => {
2674
+ }).finally(() => {
2675
+ Ae.current === n && (Ae.current = null, Nt(null));
2676
+ });
2677
+ },
2678
+ [ue, se]
2679
+ ), ir = x(() => {
2680
+ var e;
2681
+ (e = Ae.current) == null || e.abort(), Ae.current = null, Nt(null);
2682
+ }, []);
2683
+ I(() => () => {
2684
+ var e;
2685
+ return (e = Ae.current) == null ? void 0 : e.abort();
2686
+ }, []), I(() => {
2687
+ const e = ie.current;
2688
+ if (!e) return;
2689
+ e.value = Er.current, xe.current();
2690
+ const r = ua($);
2691
+ if (!r) {
2692
+ Bt(!0);
2693
+ return;
2694
+ }
2695
+ te.current = r, e.value = $t(e.value, Ze.current);
2696
+ const n = {
2697
+ lang: F ?? fa(j.language || "en"),
2698
+ // The kit renders its OWN toolbar (EditorToolbar) and drives Redactor
2699
+ // via the command API, so Redactor's native toolbar is suppressed.
2700
+ toolbar: !1,
2701
+ plugins: _ ?? [],
2702
+ placeholder: l ?? D("editor.placeholder"),
2703
+ toolbarFixed: !1,
2704
+ // Platform parity (RedactorWysiwyg.js:84): no inline shortcode expansion.
2705
+ shortcodes: !1,
2706
+ // The kit owns image editing: ImageFloatingToolbar provides DS-native,
2707
+ // keyboard-accessible resize + wrap/align, so Redactor's own image
2708
+ // popup AND its single-handle drag-resizer are both disabled to avoid a
2709
+ // second, untokenised, mouse-only UI competing with ours.
2710
+ imageEditable: !1,
2711
+ imageResizable: !1
2712
+ }, a = m ? { imageUpload: m } : {}, s = (L == null ? void 0 : L.callbacks) ?? {}, d = {
2713
+ ...n,
2714
+ ...a,
2715
+ ...L ?? {},
2716
+ // Re-pin safety-critical keys LAST so consumer `options` can't override
2717
+ // the sanitising change handler or re-enable Redactor's native image UI
2718
+ // (the kit's ImageFloatingToolbar replaces both — see kitDefaults above).
2719
+ imageEditable: !1,
2720
+ imageResizable: !1,
2721
+ callbacks: {
2722
+ ...s,
2723
+ changed(w) {
2724
+ xe.current();
2725
+ const S = Lt(
2726
+ ia(fr(w))
2727
+ ), de = fe(S);
2728
+ bt.current = !0, J.current && (Oe.current && clearTimeout(Oe.current), Oe.current = setTimeout(() => {
2729
+ var we;
2730
+ (we = J.current) == null || we.call(J, { html: de, markdown: "" });
2731
+ }, 100));
2732
+ },
2733
+ keydown(w) {
2734
+ var S;
2735
+ (S = Je.current) == null || S.call(Je, w);
2736
+ },
2737
+ observe() {
2738
+ oe();
2739
+ }
2740
+ }
2741
+ };
2742
+ try {
2743
+ if (r(N, d), xe.current(), v)
2744
+ try {
2745
+ r(N, "enableReadOnly");
2746
+ } catch {
2747
+ }
2748
+ } catch {
2749
+ Bt(!0);
2750
+ }
2751
+ return () => {
2752
+ Oe.current && clearTimeout(Oe.current);
2753
+ try {
2754
+ r(N, "destroy");
2755
+ } catch {
2756
+ }
2757
+ te.current = null;
2758
+ };
2759
+ }, []), I(() => {
2760
+ if (!te.current || h === void 0) return;
2761
+ if (bt.current) {
2762
+ bt.current = !1;
2763
+ return;
2764
+ }
2765
+ const e = $t(
2766
+ fe(Lt(h)),
2767
+ Ze.current
2768
+ );
2769
+ Lt(ue()) !== e && se("source.setCode", e);
2770
+ }, [h, ue, se]), I(() => {
2771
+ yt.current = v;
2772
+ const e = te.current;
2773
+ if (e)
2774
+ try {
2775
+ e(N, v ? "enableReadOnly" : "disableReadOnly");
2776
+ } catch {
2777
+ }
2778
+ }, [v, N]), I(() => {
2779
+ if (!re || h === void 0) return;
2780
+ const e = ie.current;
2781
+ if (!e) return;
2782
+ const r = fe(h);
2783
+ e.value !== r && document.activeElement !== e && (e.value = r);
2784
+ }, [re, h]);
2785
+ const He = qe(
2786
+ () => ({
2787
+ getHTML() {
2788
+ return ue();
2789
+ },
2790
+ getText() {
2791
+ return ue().replace(/<[^>]*>/g, " ").replace(/&nbsp;/gi, " ").replace(/\s+/g, " ").trim();
2792
+ },
2793
+ getMarkdown() {
2794
+ return "";
2795
+ },
2796
+ setContent(e) {
2797
+ const r = fe(e);
2798
+ se(
2799
+ "source.setCode",
2800
+ $t(r, Ze.current)
2801
+ ) || ie.current && (ie.current.value = r);
2802
+ },
2803
+ insertAtCursor: le,
2804
+ applyFormat(e) {
2805
+ const r = ma[e];
2806
+ r && Ie(...r);
2807
+ },
2808
+ focus() {
2809
+ var r;
2810
+ const e = te.current;
2811
+ if (e)
2812
+ try {
2813
+ e(N, "editor.focus");
2814
+ return;
2815
+ } catch {
2816
+ }
2817
+ (r = ie.current) == null || r.focus();
2818
+ },
2819
+ clear() {
2820
+ se("source.setCode", "") || ie.current && (ie.current.value = "");
2821
+ }
2822
+ }),
2823
+ [N, ue, se, le, Ie]
2824
+ );
2825
+ Yr(Ee, () => He, [He]), tn(Mo, He, o);
2826
+ const Wr = x(
2827
+ (e) => {
2828
+ var r;
2829
+ xe.current(), (r = J.current) == null || r.call(J, {
2830
+ html: fe(e.target.value),
2831
+ markdown: ""
2832
+ });
2833
+ },
2834
+ []
2835
+ ), ct = u ?? D("editor.regionLabel"), Xr = l ?? D("editor.placeholder");
2836
+ I(() => {
2837
+ var a;
2838
+ if (re) return;
2839
+ const e = (a = W.current) == null ? void 0 : a.querySelector(".redactor-in");
2840
+ if (!e) return;
2841
+ const r = () => {
2842
+ e.getAttribute("role") !== "textbox" && e.setAttribute("role", "textbox"), e.getAttribute("aria-multiline") !== "true" && e.setAttribute("aria-multiline", "true"), e.getAttribute("aria-label") !== ct && e.setAttribute("aria-label", ct), e.hasAttribute("aria-labelledby") && e.removeAttribute("aria-labelledby");
2843
+ };
2844
+ r();
2845
+ const n = new MutationObserver(r);
2846
+ return n.observe(e, {
2847
+ attributes: !0,
2848
+ attributeFilter: ["role", "aria-labelledby"]
2849
+ }), () => n.disconnect();
2850
+ }, [re, ct]);
2851
+ const Tt = ge !== null, Zr = x(
2852
+ (e) => {
2853
+ if (It.test(e)) {
2854
+ if (re) {
2855
+ le(`[[${e}]]`, { asHtml: !1 });
2856
+ return;
2857
+ }
2858
+ ve(), Ce(hr(e));
2859
+ }
2860
+ },
2861
+ [re, le, ve, Ce]
2862
+ ), De = [];
2863
+ return O && De.push({
2864
+ key: "dictate",
2865
+ icon: Te ? /* @__PURE__ */ t(gt, { "aria-hidden": "true", className: "ds:size-5 ds:fill-current" }) : /* @__PURE__ */ t(yr, { "aria-hidden": "true", className: "ds:size-5" }),
2866
+ label: D(Te ? "editor.ai.dictateStop" : "editor.ai.dictateStart"),
2867
+ onClick: Vr,
2868
+ recording: Te
2869
+ }), U && De.push({
2870
+ key: "proofread",
2871
+ // While running, the segment becomes a STOP/cancel button (progress is
2872
+ // shown by the scrim spinner).
2873
+ icon: ge === "proofread" ? /* @__PURE__ */ t(gt, { "aria-hidden": "true", className: "ds:size-5 ds:fill-current" }) : /* @__PURE__ */ t(go, { "aria-hidden": "true", className: "ds:size-5" }),
2874
+ label: ge === "proofread" ? D("common.cancel") : D("editor.ai.proofread", "Check spelling & grammar"),
2875
+ onClick: ge === "proofread" ? ir : () => ar("proofread", U),
2876
+ running: ge === "proofread"
2877
+ }), X && De.push({
2878
+ key: "format",
2879
+ icon: ge === "format" ? /* @__PURE__ */ t(gt, { "aria-hidden": "true", className: "ds:size-5 ds:fill-current" }) : /* @__PURE__ */ t(hn, { "aria-hidden": "true", className: "ds:size-5" }),
2880
+ label: ge === "format" ? D("common.cancel") : D("editor.ai.autoFormat", "Auto-format document"),
2881
+ onClick: ge === "format" ? ir : () => ar("format", X),
2882
+ running: ge === "format"
2883
+ }), (E || B) && De.push({
2884
+ key: "write",
2885
+ icon: /* @__PURE__ */ t(pn, { "aria-hidden": "true", className: "ds:size-5" }),
2886
+ label: D("editor.ai.helpMeWrite"),
2887
+ onClick: Kr
2888
+ }), /* @__PURE__ */ k(
2889
+ "div",
2890
+ {
2891
+ ref: W,
2892
+ className: [ha(), z].filter(Boolean).join(" "),
2893
+ "data-component": "rich-text-editor",
2894
+ "data-component-id": o,
2895
+ "data-min-height": b,
2896
+ children: [
2897
+ !re && !v ? /* @__PURE__ */ t(
2898
+ aa,
2899
+ {
2900
+ run: Ie,
2901
+ active: Xt,
2902
+ preset: f,
2903
+ insertHtml: Ce,
2904
+ insertTable: Dr,
2905
+ saveSelection: Be,
2906
+ restoreSelection: ve,
2907
+ getSelectedText: Rr,
2908
+ uploadImage: m || c ? qr : void 0,
2909
+ enableColor: (_ == null ? void 0 : _.includes("fontcolor")) ?? !1,
2910
+ enableImage: !!(m || c),
2911
+ enableTable: (_ == null ? void 0 : _.includes("table")) ?? !1,
2912
+ showExtensions: C,
2913
+ variables: P,
2914
+ insertVariable: Zr
2915
+ }
2916
+ ) : null,
2917
+ /* @__PURE__ */ k("div", { className: "ds:relative", ref: Ke, children: [
2918
+ /* @__PURE__ */ t(
2919
+ "textarea",
2920
+ {
2921
+ ref: ie,
2922
+ id: ee,
2923
+ "aria-label": ct,
2924
+ "aria-multiline": "true",
2925
+ "aria-busy": Tt || void 0,
2926
+ placeholder: Xr,
2927
+ onChange: re ? Wr : void 0,
2928
+ readOnly: re ? v : void 0,
2929
+ className: re ? ya() : void 0
2930
+ }
2931
+ ),
2932
+ Tt ? /* @__PURE__ */ t(
2933
+ "div",
2934
+ {
2935
+ "aria-hidden": "true",
2936
+ className: "ds:absolute ds:inset-0 ds:z-[5] ds:flex ds:items-center ds:justify-center ds:cursor-wait ds:rounded-[var(--radius-md)] ds:bg-[color-mix(in_srgb,var(--background)_40%,transparent)]",
2937
+ children: /* @__PURE__ */ t(pr, { size: "lg", variant: "prism" })
2938
+ }
2939
+ ) : null,
2940
+ /* @__PURE__ */ k("div", { className: "ds:sticky ds:bottom-0 ds:z-10", children: [
2941
+ De.length > 0 ? /* @__PURE__ */ t("div", { className: "ds:absolute ds:[inset-block-end:var(--spacing-md)] ds:[inset-inline-end:var(--spacing-md)] ds:z-10 ds:flex ds:items-center ds:overflow-hidden ds:rounded-full ds:bg-[var(--primary)] ds:bg-[image:var(--gradient-brand)] ds:shadow-[0_8px_24px_color-mix(in_srgb,var(--primary)_35%,transparent)]", children: De.map((e, r) => /* @__PURE__ */ k(pt, { children: [
2942
+ r > 0 ? /* @__PURE__ */ t(
2943
+ "span",
2944
+ {
2945
+ "aria-hidden": "true",
2946
+ className: "ds:self-stretch ds:[inline-size:var(--border-width-sm)] ds:bg-[color-mix(in_srgb,var(--primary-foreground)_35%,transparent)]"
2947
+ }
2948
+ ) : null,
2949
+ /* @__PURE__ */ t(
2950
+ "button",
2951
+ {
2952
+ type: "button",
2953
+ onClick: e.onClick,
2954
+ "aria-pressed": e.recording || void 0,
2955
+ "aria-busy": e.running || void 0,
2956
+ disabled: Tt && !e.running || void 0,
2957
+ "aria-label": e.label,
2958
+ className: e.recording ? wa : va,
2959
+ children: e.icon
2960
+ }
2961
+ )
2962
+ ] }, e.key)) }) : null,
2963
+ B ? B({
2964
+ open: Ft && !ce,
2965
+ onClose: () => {
2966
+ Re(!1), Gt(!1);
2967
+ },
2968
+ selectionText: Nr,
2969
+ creditsExhausted: Ar,
2970
+ getHTML: He.getHTML,
2971
+ getText: He.getText,
2972
+ insertAtSelection: (e) => {
2973
+ Xe.current && (ke.current = Xe.current.cloneRange()), ve(), le(e, { asHtml: !0 });
2974
+ },
2975
+ insertAfterSelection: (e) => {
2976
+ const r = Xe.current ?? ke.current;
2977
+ if (r) {
2978
+ const n = r.cloneRange();
2979
+ n.collapse(!1), ke.current = n;
2980
+ }
2981
+ ve(), le(e, { asHtml: !0 });
2982
+ },
2983
+ setContent: He.setContent,
2984
+ onDictate: O,
2985
+ privacyNotice: or
2986
+ }) : E ? /* @__PURE__ */ t(
2987
+ So,
2988
+ {
2989
+ open: Ft && !ce,
2990
+ onClose: () => Re(!1),
2991
+ onRequestAiDraft: E,
2992
+ onInsert: (e) => {
2993
+ ve(), le(e, { asHtml: T !== "text" });
2994
+ },
2995
+ previewAsHtml: T !== "text",
2996
+ privacyNotice: or,
2997
+ onDictate: O
2998
+ }
2999
+ ) : null,
3000
+ y ? /* @__PURE__ */ t(
3001
+ br,
3002
+ {
3003
+ open: jr !== null,
3004
+ onClose: rr,
3005
+ ariaLabel: D(
3006
+ "editor.ai.consentRegionLabel",
3007
+ "AI assistance consent for this document"
3008
+ ),
3009
+ footer: /* @__PURE__ */ t(pe, { intent: "ghost", size: "sm", onClick: rr, children: D("common.close") }),
3010
+ children: /* @__PURE__ */ t(
3011
+ rn,
3012
+ {
3013
+ granted: y.granted,
3014
+ grantedAt: y.grantedAt,
3015
+ grantedBy: y.grantedBy,
3016
+ canGrant: (y.canGrant ?? !0) && y.onGrant !== void 0,
3017
+ pending: Fr,
3018
+ onGrantConsent: Gr,
3019
+ headingLevel: q,
3020
+ "aria-label": D(
3021
+ "editor.ai.consentRegionLabel",
3022
+ "AI assistance consent for this document"
3023
+ )
3024
+ }
3025
+ )
3026
+ }
3027
+ ) : null
3028
+ ] }),
3029
+ !re && !v && ((_ == null ? void 0 : _.includes("table")) ?? !1) ? /* @__PURE__ */ t(
3030
+ Xo,
3031
+ {
3032
+ active: Xt,
3033
+ run: Ie,
3034
+ areaRef: Ke,
3035
+ getActiveTableEl: Sr,
3036
+ enableColor: (_ == null ? void 0 : _.includes("fontcolor")) ?? !1,
3037
+ saveTableCell: Lr,
3038
+ applyTableBackground: Ir
3039
+ }
3040
+ ) : null,
3041
+ !re && !v ? /* @__PURE__ */ t(
3042
+ oa,
3043
+ {
3044
+ areaRef: Ke,
3045
+ activeImageEl: Mr,
3046
+ applyImageClass: $r,
3047
+ setImageWidth: Hr
3048
+ }
3049
+ ) : null,
3050
+ Y ? /* @__PURE__ */ t(
3051
+ "div",
3052
+ {
3053
+ id: je,
3054
+ role: "listbox",
3055
+ "aria-label": D("editor.variables", "Variables"),
3056
+ "data-component": "variable-typeahead",
3057
+ className: pa,
3058
+ style: {
3059
+ "--rte-typeahead-x": `${Y.left}px`,
3060
+ "--rte-typeahead-y": `${Y.top}px`
3061
+ },
3062
+ children: Ne.length === 0 ? /* @__PURE__ */ t("p", { className: "ds:m-0 ds:px-[var(--spacing-sm)] ds:py-[var(--spacing-xs)] ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", children: D("editor.variableNoMatch", {
3063
+ query: Y.query,
3064
+ defaultValue: "No variable matches “{{query}}”"
3065
+ }) }) : Ne.map((e, r) => /* @__PURE__ */ k(
3066
+ "div",
3067
+ {
3068
+ id: `${je}-${e.token}`,
3069
+ role: "option",
3070
+ tabIndex: -1,
3071
+ "aria-selected": r === Y.index,
3072
+ className: ba,
3073
+ onMouseDown: (n) => {
3074
+ n.preventDefault();
3075
+ const a = Pe.current;
3076
+ me(), a && et(e.token, a);
3077
+ },
3078
+ children: [
3079
+ /* @__PURE__ */ t("span", { className: "ds:truncate", children: e.label }),
3080
+ /* @__PURE__ */ t("span", { className: "ds:ms-auto ds:text-[length:var(--font-size-xs)] ds:text-[color:var(--muted-foreground)] ds:group-aria-selected:text-[color:var(--accent-foreground)]", children: `[[${e.token}]]` })
3081
+ ]
3082
+ },
3083
+ e.token
3084
+ ))
3085
+ }
3086
+ ) : null
3087
+ ] }),
3088
+ O ? /* @__PURE__ */ t("p", { className: "ds:sr-only", role: "status", "aria-live": "polite", children: Pr }) : null,
3089
+ Le.length > 0 ? /* @__PURE__ */ t(
3090
+ "p",
3091
+ {
3092
+ id: `${ee}-variables-error`,
3093
+ role: "alert",
3094
+ className: "ds:m-0 ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--destructive)]",
3095
+ children: D("editor.variableInvalid", {
3096
+ tokens: Le.map((e) => `[[${e}]]`).join(", ")
3097
+ })
3098
+ }
3099
+ ) : null,
3100
+ O && Or ? /* @__PURE__ */ t(
3101
+ "p",
3102
+ {
3103
+ role: "alert",
3104
+ className: "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--destructive)]",
3105
+ children: D("editor.ai.dictationError")
3106
+ }
3107
+ ) : null
3108
+ ]
3109
+ }
3110
+ );
3111
+ }
3112
+ );
3113
+ xa.displayName = "RichTextEditor";
3114
+ export {
3115
+ xa as R,
3116
+ Mo as r,
3117
+ ha as w
3118
+ };
3119
+ //# sourceMappingURL=rich-text-editor-D7AKKAQ2.js.map