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