@alfadocs/ui-kit-debug 0.65.0 → 0.67.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 (270) hide show
  1. package/dist/_chunks/{agenda-card-Bl-SBiCh.js → agenda-card-BxSFkqgY.js} +2 -2
  2. package/dist/_chunks/{agenda-card-Bl-SBiCh.js.map → agenda-card-BxSFkqgY.js.map} +1 -1
  3. package/dist/_chunks/{agenda-tray-Bh1KfEOG.js → agenda-tray-T-BumlGZ.js} +2 -2
  4. package/dist/_chunks/{agenda-tray-Bh1KfEOG.js.map → agenda-tray-T-BumlGZ.js.map} +1 -1
  5. package/dist/_chunks/{ai-consent-banner-Btzmk8OH.js → ai-consent-banner-Dxtx_WAh.js} +2 -2
  6. package/dist/_chunks/{ai-consent-banner-Btzmk8OH.js.map → ai-consent-banner-Dxtx_WAh.js.map} +1 -1
  7. package/dist/_chunks/{ai-tools-rail-JnlTqfS4.js → ai-tools-rail-DfmewPUN.js} +92 -76
  8. package/dist/_chunks/ai-tools-rail-DfmewPUN.js.map +1 -0
  9. package/dist/_chunks/{alia-sidebar-CN8pA6c-.js → alia-sidebar-Ckv0yCKi.js} +2 -2
  10. package/dist/_chunks/{alia-sidebar-CN8pA6c-.js.map → alia-sidebar-Ckv0yCKi.js.map} +1 -1
  11. package/dist/_chunks/{anamnesis-card-qeLYRG79.js → anamnesis-card-N8pIKWuS.js} +2 -2
  12. package/dist/_chunks/{anamnesis-card-qeLYRG79.js.map → anamnesis-card-N8pIKWuS.js.map} +1 -1
  13. package/dist/_chunks/{antenatal-schedule-timeline-BfzFjEyb.js → antenatal-schedule-timeline-35ebkcZT.js} +2 -2
  14. package/dist/_chunks/{antenatal-schedule-timeline-BfzFjEyb.js.map → antenatal-schedule-timeline-35ebkcZT.js.map} +1 -1
  15. package/dist/_chunks/{appointment-tray-BQnJEora.js → appointment-tray-CQJ3Nbi5.js} +4 -4
  16. package/dist/_chunks/{appointment-tray-BQnJEora.js.map → appointment-tray-CQJ3Nbi5.js.map} +1 -1
  17. package/dist/_chunks/{badge-zsf5i5bH.js → badge-CqGsX32l.js} +46 -42
  18. package/dist/_chunks/badge-CqGsX32l.js.map +1 -0
  19. package/dist/_chunks/{bishop-score-x2fNqbuZ.js → bishop-score-CjsB9bM-.js} +3 -3
  20. package/dist/_chunks/{bishop-score-x2fNqbuZ.js.map → bishop-score-CjsB9bM-.js.map} +1 -1
  21. package/dist/_chunks/{bmi-calculator-C3roxbqD.js → bmi-calculator-n-823_1V.js} +3 -3
  22. package/dist/_chunks/{bmi-calculator-C3roxbqD.js.map → bmi-calculator-n-823_1V.js.map} +1 -1
  23. package/dist/_chunks/{care-plan-card-D42WD4-T.js → care-plan-card-CJei-nl9.js} +4 -4
  24. package/dist/_chunks/{care-plan-card-D42WD4-T.js.map → care-plan-card-CJei-nl9.js.map} +1 -1
  25. package/dist/_chunks/{care-plan-entry-card-BukNI7Uy.js → care-plan-entry-card-EmfrbHu8.js} +4 -4
  26. package/dist/_chunks/{care-plan-entry-card-BukNI7Uy.js.map → care-plan-entry-card-EmfrbHu8.js.map} +1 -1
  27. package/dist/_chunks/{clinical-note-card-BYo437dU.js → clinical-note-card-gtrxv6zn.js} +2 -2
  28. package/dist/_chunks/{clinical-note-card-BYo437dU.js.map → clinical-note-card-gtrxv6zn.js.map} +1 -1
  29. package/dist/_chunks/{color-picker-9tL7pz5y.js → color-picker-B7xsn6tX.js} +186 -167
  30. package/dist/_chunks/color-picker-B7xsn6tX.js.map +1 -0
  31. package/dist/_chunks/columns-2-BTOBZbep.js +15 -0
  32. package/dist/_chunks/columns-2-BTOBZbep.js.map +1 -0
  33. package/dist/_chunks/{contact-profile-card-CCeJmjbd.js → contact-profile-card-7BMB85T6.js} +2 -2
  34. package/dist/_chunks/{contact-profile-card-CCeJmjbd.js.map → contact-profile-card-7BMB85T6.js.map} +1 -1
  35. package/dist/_chunks/{cycle-calculator-DrVXbIB4.js → cycle-calculator-BF0ointe.js} +3 -3
  36. package/dist/_chunks/{cycle-calculator-DrVXbIB4.js.map → cycle-calculator-BF0ointe.js.map} +1 -1
  37. package/dist/_chunks/{dependent-selector-CRWgieHm.js → dependent-selector-DpzGtr_J.js} +2 -2
  38. package/dist/_chunks/{dependent-selector-CRWgieHm.js.map → dependent-selector-DpzGtr_J.js.map} +1 -1
  39. package/dist/_chunks/{document-scanner-biBS_f6c.js → document-scanner-D2qehl3-.js} +53 -53
  40. package/dist/_chunks/{document-scanner-biBS_f6c.js.map → document-scanner-D2qehl3-.js.map} +1 -1
  41. package/dist/_chunks/{due-date-calculator-D4K1BnE2.js → due-date-calculator-DU9AEWNy.js} +4 -4
  42. package/dist/_chunks/{due-date-calculator-D4K1BnE2.js.map → due-date-calculator-DU9AEWNy.js.map} +1 -1
  43. package/dist/_chunks/{editable-currency-cell-renderer-CFqQc56y.js → editable-currency-cell-renderer-BVJ04DkB.js} +914 -865
  44. package/dist/_chunks/editable-currency-cell-renderer-BVJ04DkB.js.map +1 -0
  45. package/dist/_chunks/{fetal-weight-B_pBjlO7.js → fetal-weight-BVSzOhuR.js} +3 -3
  46. package/dist/_chunks/{fetal-weight-B_pBjlO7.js.map → fetal-weight-BVSzOhuR.js.map} +1 -1
  47. package/dist/_chunks/{gestational-age-calculator-BETQAVkA.js → gestational-age-calculator-DBlFdoiP.js} +4 -4
  48. package/dist/_chunks/{gestational-age-calculator-BETQAVkA.js.map → gestational-age-calculator-DBlFdoiP.js.map} +1 -1
  49. package/dist/_chunks/{hcg-doubling-8zXCJgAQ.js → hcg-doubling-if4Q8aSX.js} +3 -3
  50. package/dist/_chunks/{hcg-doubling-8zXCJgAQ.js.map → hcg-doubling-if4Q8aSX.js.map} +1 -1
  51. package/dist/_chunks/{type-DZ5OMRA2.js → image-C6RM5hfF.js} +4 -16
  52. package/dist/_chunks/image-C6RM5hfF.js.map +1 -0
  53. package/dist/_chunks/{insert-result-DIAG3ltJ.js → insert-result-njqBthzT.js} +68 -57
  54. package/dist/_chunks/insert-result-njqBthzT.js.map +1 -0
  55. package/dist/_chunks/{marketplace-app-shell-BXfRMiRk.js → marketplace-app-shell-Bu-HD3fy.js} +3 -3
  56. package/dist/_chunks/{marketplace-app-shell-BXfRMiRk.js.map → marketplace-app-shell-Bu-HD3fy.js.map} +1 -1
  57. package/dist/_chunks/{message-card-Bgcvfj6-.js → message-card-Bx4GmLvf.js} +9 -9
  58. package/dist/_chunks/{message-card-Bgcvfj6-.js.map → message-card-Bx4GmLvf.js.map} +1 -1
  59. package/dist/_chunks/{message-tray-saAVMeHP.js → message-tray-CVyJajVJ.js} +2 -2
  60. package/dist/_chunks/{message-tray-saAVMeHP.js.map → message-tray-CVyJajVJ.js.map} +1 -1
  61. package/dist/_chunks/{operator-hero-CM8949Hd.js → operator-hero-f_KaRhw5.js} +2 -2
  62. package/dist/_chunks/{operator-hero-CM8949Hd.js.map → operator-hero-f_KaRhw5.js.map} +1 -1
  63. package/dist/_chunks/{patient-search-Bw9ONucF.js → patient-search-DR9XUYRQ.js} +2 -2
  64. package/dist/_chunks/{patient-search-Bw9ONucF.js.map → patient-search-DR9XUYRQ.js.map} +1 -1
  65. package/dist/_chunks/{patient-shell-CF_qon7C.js → patient-shell-DrV_iekt.js} +2 -2
  66. package/dist/_chunks/{patient-shell-CF_qon7C.js.map → patient-shell-DrV_iekt.js.map} +1 -1
  67. package/dist/_chunks/{patient-summary-card-Bgso0p_l.js → patient-summary-card-ByfIU8N0.js} +4 -4
  68. package/dist/_chunks/{patient-summary-card-Bgso0p_l.js.map → patient-summary-card-ByfIU8N0.js.map} +1 -1
  69. package/dist/_chunks/{payment-request-card-DBz3hVDz.js → payment-request-card-yTjzKQCU.js} +3 -3
  70. package/dist/_chunks/{payment-request-card-DBz3hVDz.js.map → payment-request-card-yTjzKQCU.js.map} +1 -1
  71. package/dist/_chunks/{periodontal-chart-card-AYyHtU9K.js → periodontal-chart-card-Dh3KgvYG.js} +2 -2
  72. package/dist/_chunks/{periodontal-chart-card-AYyHtU9K.js.map → periodontal-chart-card-Dh3KgvYG.js.map} +1 -1
  73. package/dist/_chunks/{practice-results-CVAgY2RZ.js → practice-results-DND2SAt7.js} +2 -2
  74. package/dist/_chunks/{practice-results-CVAgY2RZ.js.map → practice-results-DND2SAt7.js.map} +1 -1
  75. package/dist/_chunks/{pregnancy-dating-BuzLTwjy.js → pregnancy-dating-QY-sqpvj.js} +4 -4
  76. package/dist/_chunks/{pregnancy-dating-BuzLTwjy.js.map → pregnancy-dating-QY-sqpvj.js.map} +1 -1
  77. package/dist/_chunks/{pregnancy-weight-gain-aicn7qs7.js → pregnancy-weight-gain-DOJXXNYP.js} +3 -3
  78. package/dist/_chunks/{pregnancy-weight-gain-aicn7qs7.js.map → pregnancy-weight-gain-DOJXXNYP.js.map} +1 -1
  79. package/dist/_chunks/rich-text-editor-BOQr5lHx.js +1970 -0
  80. package/dist/_chunks/rich-text-editor-BOQr5lHx.js.map +1 -0
  81. package/dist/_chunks/{scroll-area-BWqCkEGz.js → scroll-area-eccd_Uf-.js} +38 -28
  82. package/dist/_chunks/scroll-area-eccd_Uf-.js.map +1 -0
  83. package/dist/_chunks/{sidebar-DPEHzxLZ.js → sidebar-CGjIk_FQ.js} +36 -22
  84. package/dist/_chunks/sidebar-CGjIk_FQ.js.map +1 -0
  85. package/dist/_chunks/{suggestion-chip-C4kxWUIs.js → suggestion-chip-Bk4PmYTg.js} +30 -30
  86. package/dist/_chunks/suggestion-chip-Bk4PmYTg.js.map +1 -0
  87. package/dist/_chunks/{tab-bar-Xetknddo.js → tab-bar-B1ovILzh.js} +2 -2
  88. package/dist/_chunks/{tab-bar-Xetknddo.js.map → tab-bar-B1ovILzh.js.map} +1 -1
  89. package/dist/_chunks/{tag-CdA0s_VV.js → tag-BQXwuJq1.js} +41 -38
  90. package/dist/_chunks/tag-BQXwuJq1.js.map +1 -0
  91. package/dist/_chunks/{transaction-chip-BZCa6XDn.js → transaction-chip-BrW8P50O.js} +19 -19
  92. package/dist/_chunks/transaction-chip-BrW8P50O.js.map +1 -0
  93. package/dist/_chunks/trash-2-rPAKaRgB.js +18 -0
  94. package/dist/_chunks/trash-2-rPAKaRgB.js.map +1 -0
  95. package/dist/_chunks/{unit-converter-CHN2cZ4b.js → unit-converter-C1V3ACM9.js} +2 -2
  96. package/dist/_chunks/{unit-converter-CHN2cZ4b.js.map → unit-converter-C1V3ACM9.js.map} +1 -1
  97. package/dist/_chunks/{workflow-map-BX3JY1Bu.js → workflow-map-JAZryZJr.js} +137 -149
  98. package/dist/_chunks/workflow-map-JAZryZJr.js.map +1 -0
  99. package/dist/agent-catalog.json +1 -1
  100. package/dist/components/agenda-card/index.js +1 -1
  101. package/dist/components/agenda-tray/index.js +1 -1
  102. package/dist/components/ai-consent-banner/index.js +1 -1
  103. package/dist/components/ai-tools-rail/ai-tools-rail.d.ts.map +1 -1
  104. package/dist/components/ai-tools-rail/index.js +1 -1
  105. package/dist/components/anamnesis-card/index.js +1 -1
  106. package/dist/components/appointment-card/index.js +1 -1
  107. package/dist/components/badge/badge.d.ts.map +1 -1
  108. package/dist/components/badge/index.js +1 -1
  109. package/dist/components/bishop-score/index.js +1 -1
  110. package/dist/components/bmi-calculator/index.js +1 -1
  111. package/dist/components/care-plan-card/index.js +1 -1
  112. package/dist/components/care-plan-entry-card/index.js +1 -1
  113. package/dist/components/clinical-note-card/index.js +1 -1
  114. package/dist/components/color-picker/color-picker.d.ts.map +1 -1
  115. package/dist/components/color-picker/index.js +1 -1
  116. package/dist/components/contact-profile-card/index.js +1 -1
  117. package/dist/components/cycle-calculator/index.js +1 -1
  118. package/dist/components/data-table/cell-renderers/actions-cell-renderer.d.ts +16 -0
  119. package/dist/components/data-table/cell-renderers/actions-cell-renderer.d.ts.map +1 -1
  120. package/dist/components/data-table/cell-renderers/tooth-cell-renderer.d.ts +12 -0
  121. package/dist/components/data-table/cell-renderers/tooth-cell-renderer.d.ts.map +1 -0
  122. package/dist/components/data-table/data-table.d.ts +1 -1
  123. package/dist/components/data-table/index.d.ts +2 -0
  124. package/dist/components/data-table/index.d.ts.map +1 -1
  125. package/dist/components/data-table/index.js +13 -12
  126. package/dist/components/data-table/toolbar.d.ts +5 -1
  127. package/dist/components/data-table/toolbar.d.ts.map +1 -1
  128. package/dist/components/dependent-selector/index.js +1 -1
  129. package/dist/components/document-scanner/index.js +1 -1
  130. package/dist/components/due-date-calculator/index.js +2 -2
  131. package/dist/components/fetal-weight/index.js +1 -1
  132. package/dist/components/gestational-age-calculator/index.js +1 -1
  133. package/dist/components/hcg-doubling/index.js +1 -1
  134. package/dist/components/message-card/index.js +1 -1
  135. package/dist/components/message-tray/index.js +1 -1
  136. package/dist/components/operator-hero/index.js +1 -1
  137. package/dist/components/patient-search/index.js +1 -1
  138. package/dist/components/patient-summary-card/index.js +1 -1
  139. package/dist/components/payment-card/index.js +1 -1
  140. package/dist/components/periodontal-chart-card/index.js +1 -1
  141. package/dist/components/practice-results/index.js +1 -1
  142. package/dist/components/pregnancy-dating/index.js +1 -1
  143. package/dist/components/pregnancy-weight-gain/index.js +1 -1
  144. package/dist/components/rich-text-editor/editor-toolbar.d.ts +36 -2
  145. package/dist/components/rich-text-editor/editor-toolbar.d.ts.map +1 -1
  146. package/dist/components/rich-text-editor/index.js +1 -1
  147. package/dist/components/rich-text-editor/rich-text-editor.d.ts +2 -0
  148. package/dist/components/rich-text-editor/rich-text-editor.d.ts.map +1 -1
  149. package/dist/components/scroll-area/index.js +1 -1
  150. package/dist/components/scroll-area/scroll-area.d.ts.map +1 -1
  151. package/dist/components/sidebar/index.js +1 -1
  152. package/dist/components/sidebar/sidebar.d.ts.map +1 -1
  153. package/dist/components/suggestion-chip/index.js +1 -1
  154. package/dist/components/tab-bar/index.js +1 -1
  155. package/dist/components/tag/index.js +1 -1
  156. package/dist/components/tag/tag.d.ts.map +1 -1
  157. package/dist/components/transaction-chip/index.js +1 -1
  158. package/dist/components/transaction-chip/transaction-chip.d.ts.map +1 -1
  159. package/dist/components/unit-converter/index.js +1 -1
  160. package/dist/components/workflow/index.js +1 -1
  161. package/dist/i18n/locales/ar.d.ts +26 -0
  162. package/dist/i18n/locales/ar.d.ts.map +1 -1
  163. package/dist/i18n/locales/ar.js +27 -1
  164. package/dist/i18n/locales/ar.js.map +1 -1
  165. package/dist/i18n/locales/de.d.ts +26 -0
  166. package/dist/i18n/locales/de.d.ts.map +1 -1
  167. package/dist/i18n/locales/de.js +27 -1
  168. package/dist/i18n/locales/de.js.map +1 -1
  169. package/dist/i18n/locales/el.d.ts +26 -0
  170. package/dist/i18n/locales/el.d.ts.map +1 -1
  171. package/dist/i18n/locales/el.js +27 -1
  172. package/dist/i18n/locales/el.js.map +1 -1
  173. package/dist/i18n/locales/en.d.ts +26 -0
  174. package/dist/i18n/locales/en.d.ts.map +1 -1
  175. package/dist/i18n/locales/en.js +27 -1
  176. package/dist/i18n/locales/en.js.map +1 -1
  177. package/dist/i18n/locales/es.d.ts +26 -0
  178. package/dist/i18n/locales/es.d.ts.map +1 -1
  179. package/dist/i18n/locales/es.js +27 -1
  180. package/dist/i18n/locales/es.js.map +1 -1
  181. package/dist/i18n/locales/fr.d.ts +26 -0
  182. package/dist/i18n/locales/fr.d.ts.map +1 -1
  183. package/dist/i18n/locales/fr.js +27 -1
  184. package/dist/i18n/locales/fr.js.map +1 -1
  185. package/dist/i18n/locales/hi.d.ts +26 -0
  186. package/dist/i18n/locales/hi.d.ts.map +1 -1
  187. package/dist/i18n/locales/hi.js +27 -1
  188. package/dist/i18n/locales/hi.js.map +1 -1
  189. package/dist/i18n/locales/it.d.ts +26 -0
  190. package/dist/i18n/locales/it.d.ts.map +1 -1
  191. package/dist/i18n/locales/it.js +27 -1
  192. package/dist/i18n/locales/it.js.map +1 -1
  193. package/dist/i18n/locales/ja.d.ts +26 -0
  194. package/dist/i18n/locales/ja.d.ts.map +1 -1
  195. package/dist/i18n/locales/ja.js +27 -1
  196. package/dist/i18n/locales/ja.js.map +1 -1
  197. package/dist/i18n/locales/nl.d.ts +26 -0
  198. package/dist/i18n/locales/nl.d.ts.map +1 -1
  199. package/dist/i18n/locales/nl.js +25 -1
  200. package/dist/i18n/locales/nl.js.map +1 -1
  201. package/dist/i18n/locales/pl.d.ts +26 -0
  202. package/dist/i18n/locales/pl.d.ts.map +1 -1
  203. package/dist/i18n/locales/pl.js +27 -1
  204. package/dist/i18n/locales/pl.js.map +1 -1
  205. package/dist/i18n/locales/pt.d.ts +26 -0
  206. package/dist/i18n/locales/pt.d.ts.map +1 -1
  207. package/dist/i18n/locales/pt.js +27 -1
  208. package/dist/i18n/locales/pt.js.map +1 -1
  209. package/dist/i18n/locales/ro.d.ts +26 -0
  210. package/dist/i18n/locales/ro.d.ts.map +1 -1
  211. package/dist/i18n/locales/ro.js +27 -1
  212. package/dist/i18n/locales/ro.js.map +1 -1
  213. package/dist/i18n/locales/ru.d.ts +26 -0
  214. package/dist/i18n/locales/ru.d.ts.map +1 -1
  215. package/dist/i18n/locales/ru.js +27 -1
  216. package/dist/i18n/locales/ru.js.map +1 -1
  217. package/dist/i18n/locales/sq.d.ts +26 -0
  218. package/dist/i18n/locales/sq.d.ts.map +1 -1
  219. package/dist/i18n/locales/sq.js +27 -1
  220. package/dist/i18n/locales/sq.js.map +1 -1
  221. package/dist/i18n/locales/sv.d.ts +26 -0
  222. package/dist/i18n/locales/sv.d.ts.map +1 -1
  223. package/dist/i18n/locales/sv.js +25 -1
  224. package/dist/i18n/locales/sv.js.map +1 -1
  225. package/dist/i18n/locales/tr.d.ts +26 -0
  226. package/dist/i18n/locales/tr.d.ts.map +1 -1
  227. package/dist/i18n/locales/tr.js +27 -1
  228. package/dist/i18n/locales/tr.js.map +1 -1
  229. package/dist/i18n/locales/zh.d.ts +26 -0
  230. package/dist/i18n/locales/zh.d.ts.map +1 -1
  231. package/dist/i18n/locales/zh.js +25 -1
  232. package/dist/i18n/locales/zh.js.map +1 -1
  233. package/dist/index.js +509 -508
  234. package/dist/locales/ar.json +27 -1
  235. package/dist/locales/de.json +27 -1
  236. package/dist/locales/el.json +27 -1
  237. package/dist/locales/en.json +27 -1
  238. package/dist/locales/es.json +27 -1
  239. package/dist/locales/fr.json +27 -1
  240. package/dist/locales/hi.json +27 -1
  241. package/dist/locales/it.json +27 -1
  242. package/dist/locales/ja.json +27 -1
  243. package/dist/locales/nl.json +27 -1
  244. package/dist/locales/pl.json +27 -1
  245. package/dist/locales/pt.json +27 -1
  246. package/dist/locales/ro.json +27 -1
  247. package/dist/locales/ru.json +27 -1
  248. package/dist/locales/sq.json +27 -1
  249. package/dist/locales/sv.json +27 -1
  250. package/dist/locales/tr.json +27 -1
  251. package/dist/locales/zh.json +27 -1
  252. package/dist/patterns/alia-assistant/index.js +1 -1
  253. package/dist/patterns/marketplace-app-shell/index.js +1 -1
  254. package/dist/patterns/patient-shell/index.js +1 -1
  255. package/dist/tokens.css +6 -3
  256. package/package.json +1 -1
  257. package/dist/_chunks/ai-tools-rail-JnlTqfS4.js.map +0 -1
  258. package/dist/_chunks/badge-zsf5i5bH.js.map +0 -1
  259. package/dist/_chunks/color-picker-9tL7pz5y.js.map +0 -1
  260. package/dist/_chunks/editable-currency-cell-renderer-CFqQc56y.js.map +0 -1
  261. package/dist/_chunks/insert-result-DIAG3ltJ.js.map +0 -1
  262. package/dist/_chunks/rich-text-editor-u36FqSWz.js +0 -1190
  263. package/dist/_chunks/rich-text-editor-u36FqSWz.js.map +0 -1
  264. package/dist/_chunks/scroll-area-BWqCkEGz.js.map +0 -1
  265. package/dist/_chunks/sidebar-DPEHzxLZ.js.map +0 -1
  266. package/dist/_chunks/suggestion-chip-C4kxWUIs.js.map +0 -1
  267. package/dist/_chunks/tag-CdA0s_VV.js.map +0 -1
  268. package/dist/_chunks/transaction-chip-BZCa6XDn.js.map +0 -1
  269. package/dist/_chunks/type-DZ5OMRA2.js.map +0 -1
  270. package/dist/_chunks/workflow-map-BX3JY1Bu.js.map +0 -1
@@ -0,0 +1,1970 @@
1
+ import { jsx as e, jsxs as v, Fragment as Ae } from "react/jsx-runtime";
2
+ import { useId as ae, useState as _, useRef as D, useCallback as z, useEffect as K, Fragment as mt, forwardRef as ht, useMemo as Fe, useImperativeHandle as ft } from "react";
3
+ import { c as He } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as X } from "react-i18next";
5
+ import { SafeHtml as gt, sanitiseHtml as pt } from "../safe-html/index.js";
6
+ import { u as bt } from "./registry-nPAVE19X.js";
7
+ import { I as q } from "./icon-button-LqoiKcUN.js";
8
+ import { S as vt } from "./spinner-hbwuKwMf.js";
9
+ import { T as yt } from "./text-area-BIx0tZ05.js";
10
+ import { E as wt } from "./editor-overlay-wYm22wZK.js";
11
+ import { R as kt } from "./rotate-ccw-BWANpitO.js";
12
+ import { C as xt } from "./check-DPdL_Sm7.js";
13
+ import { S as _e } from "./square-CZoGU14v.js";
14
+ import { M as Se } from "./mic-B4Gog3Gi.js";
15
+ import { S as Ct } from "./send-CySZIRPJ.js";
16
+ import { S as Ee } from "./sparkles-CuYXqQLg.js";
17
+ import { B as re } from "./button-DD_0Xdmr.js";
18
+ import { a as Nt } from "./tooltip-DvmfrNvB.js";
19
+ import { P } from "./popover-DTbfAuR0.js";
20
+ import { D as ye } from "./dropdown-menu-DwwPovMZ.js";
21
+ import { D as j } from "./dialog-DMGnSelc.js";
22
+ import { C as Ie } from "./color-picker-B7xsn6tX.js";
23
+ import { T as ke } from "./text-input-BaClJL8Y.js";
24
+ import { C as zt } from "./checkbox-DRcOdmXv.js";
25
+ import { F as Tt } from "./file-upload-BosbPDb1.js";
26
+ import { c as S } from "./createLucideIcon-CrFbzy84.js";
27
+ import { C as Mt } from "./chevron-down-BX_NP2Yh.js";
28
+ import { I as Rt } from "./image-C6RM5hfF.js";
29
+ import { C as _t } from "./columns-2-BTOBZbep.js";
30
+ import { T as St } from "./trash-2-rPAKaRgB.js";
31
+ /**
32
+ * @license lucide-react v1.8.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */
37
+ const Et = [
38
+ ["rect", { width: "13", height: "7", x: "3", y: "3", rx: "1", key: "11xb64" }],
39
+ ["path", { d: "m22 15-3-3 3-3", key: "26chmm" }],
40
+ ["rect", { width: "13", height: "7", x: "3", y: "14", rx: "1", key: "k6ky7n" }]
41
+ ], At = S("between-horizontal-end", Et);
42
+ /**
43
+ * @license lucide-react v1.8.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */
48
+ const Ht = [
49
+ ["rect", { width: "13", height: "7", x: "8", y: "3", rx: "1", key: "pkso9a" }],
50
+ ["path", { d: "m2 9 3 3-3 3", key: "1agib5" }],
51
+ ["rect", { width: "13", height: "7", x: "8", y: "14", rx: "1", key: "1q5fc1" }]
52
+ ], It = S("between-horizontal-start", Ht);
53
+ /**
54
+ * @license lucide-react v1.8.0 - ISC
55
+ *
56
+ * This source code is licensed under the ISC license.
57
+ * See the LICENSE file in the root directory of this source tree.
58
+ */
59
+ const $t = [
60
+ ["rect", { width: "7", height: "13", x: "3", y: "3", rx: "1", key: "1fdu0f" }],
61
+ ["path", { d: "m9 22 3-3 3 3", key: "17z65a" }],
62
+ ["rect", { width: "7", height: "13", x: "14", y: "3", rx: "1", key: "1squn4" }]
63
+ ], Lt = S("between-vertical-end", $t);
64
+ /**
65
+ * @license lucide-react v1.8.0 - ISC
66
+ *
67
+ * This source code is licensed under the ISC license.
68
+ * See the LICENSE file in the root directory of this source tree.
69
+ */
70
+ const Ot = [
71
+ ["rect", { width: "7", height: "13", x: "3", y: "8", rx: "1", key: "1fjrkv" }],
72
+ ["path", { d: "m15 2-3 3-3-3", key: "1uh6eb" }],
73
+ ["rect", { width: "7", height: "13", x: "14", y: "8", rx: "1", key: "w3fjg8" }]
74
+ ], Dt = S("between-vertical-start", Ot);
75
+ /**
76
+ * @license lucide-react v1.8.0 - ISC
77
+ *
78
+ * This source code is licensed under the ISC license.
79
+ * See the LICENSE file in the root directory of this source tree.
80
+ */
81
+ const jt = [
82
+ [
83
+ "path",
84
+ { 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" }
85
+ ]
86
+ ], qt = S("bold", jt);
87
+ /**
88
+ * @license lucide-react v1.8.0 - ISC
89
+ *
90
+ * This source code is licensed under the ISC license.
91
+ * See the LICENSE file in the root directory of this source tree.
92
+ */
93
+ const Pt = [
94
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
95
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
96
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
97
+ ["path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1", key: "9jr5yi" }]
98
+ ], Bt = S("heading-2", Pt);
99
+ /**
100
+ * @license lucide-react v1.8.0 - ISC
101
+ *
102
+ * This source code is licensed under the ISC license.
103
+ * See the LICENSE file in the root directory of this source tree.
104
+ */
105
+ const Ft = [
106
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
107
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
108
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
109
+ ["path", { d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2", key: "68ncm8" }],
110
+ ["path", { d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2", key: "1ejuhz" }]
111
+ ], Vt = S("heading-3", Ft);
112
+ /**
113
+ * @license lucide-react v1.8.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 Gt = [
119
+ ["path", { d: "m9 11-6 6v3h9l3-3", key: "1a3l36" }],
120
+ ["path", { d: "m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4", key: "14a9rk" }]
121
+ ], Wt = S("highlighter", Gt);
122
+ /**
123
+ * @license lucide-react v1.8.0 - ISC
124
+ *
125
+ * This source code is licensed under the ISC license.
126
+ * See the LICENSE file in the root directory of this source tree.
127
+ */
128
+ const Ut = [
129
+ ["line", { x1: "19", x2: "10", y1: "4", y2: "4", key: "15jd3p" }],
130
+ ["line", { x1: "14", x2: "5", y1: "20", y2: "20", key: "bu0au3" }],
131
+ ["line", { x1: "15", x2: "9", y1: "4", y2: "20", key: "uljnxc" }]
132
+ ], Xt = S("italic", Ut);
133
+ /**
134
+ * @license lucide-react v1.8.0 - ISC
135
+ *
136
+ * This source code is licensed under the ISC license.
137
+ * See the LICENSE file in the root directory of this source tree.
138
+ */
139
+ const Qt = [
140
+ ["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" }],
141
+ ["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" }]
142
+ ], Yt = S("link", Qt);
143
+ /**
144
+ * @license lucide-react v1.8.0 - ISC
145
+ *
146
+ * This source code is licensed under the ISC license.
147
+ * See the LICENSE file in the root directory of this source tree.
148
+ */
149
+ const Zt = [
150
+ ["path", { d: "M11 5h10", key: "1cz7ny" }],
151
+ ["path", { d: "M11 12h10", key: "1438ji" }],
152
+ ["path", { d: "M11 19h10", key: "11t30w" }],
153
+ ["path", { d: "M4 4h1v5", key: "10yrso" }],
154
+ ["path", { d: "M4 9h2", key: "r1h2o0" }],
155
+ ["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" }]
156
+ ], Jt = S("list-ordered", Zt);
157
+ /**
158
+ * @license lucide-react v1.8.0 - ISC
159
+ *
160
+ * This source code is licensed under the ISC license.
161
+ * See the LICENSE file in the root directory of this source tree.
162
+ */
163
+ const Kt = [
164
+ ["path", { d: "M3 5h.01", key: "18ugdj" }],
165
+ ["path", { d: "M3 12h.01", key: "nlz23k" }],
166
+ ["path", { d: "M3 19h.01", key: "noohij" }],
167
+ ["path", { d: "M8 5h13", key: "1pao27" }],
168
+ ["path", { d: "M8 12h13", key: "1za7za" }],
169
+ ["path", { d: "M8 19h13", key: "m83p4d" }]
170
+ ], er = S("list", Kt);
171
+ /**
172
+ * @license lucide-react v1.8.0 - ISC
173
+ *
174
+ * This source code is licensed under the ISC license.
175
+ * See the LICENSE file in the root directory of this source tree.
176
+ */
177
+ const tr = [
178
+ ["path", { d: "M11 7 6 2", key: "1jwth8" }],
179
+ ["path", { d: "M18.992 12H2.041", key: "xw1gg" }],
180
+ [
181
+ "path",
182
+ {
183
+ 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",
184
+ key: "1nkol4"
185
+ }
186
+ ],
187
+ [
188
+ "path",
189
+ {
190
+ 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",
191
+ key: "1nk1rd"
192
+ }
193
+ ]
194
+ ], rr = S("paint-bucket", tr);
195
+ /**
196
+ * @license lucide-react v1.8.0 - ISC
197
+ *
198
+ * This source code is licensed under the ISC license.
199
+ * See the LICENSE file in the root directory of this source tree.
200
+ */
201
+ const nr = [
202
+ ["rect", { width: "16", height: "6", x: "2", y: "2", rx: "2", key: "jcyz7m" }],
203
+ ["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" }],
204
+ ["rect", { width: "4", height: "6", x: "8", y: "16", rx: "1", key: "d6e7yl" }]
205
+ ], or = S("paint-roller", nr);
206
+ /**
207
+ * @license lucide-react v1.8.0 - ISC
208
+ *
209
+ * This source code is licensed under the ISC license.
210
+ * See the LICENSE file in the root directory of this source tree.
211
+ */
212
+ const ar = [
213
+ [
214
+ "path",
215
+ {
216
+ 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",
217
+ key: "e79jfc"
218
+ }
219
+ ],
220
+ ["circle", { cx: "13.5", cy: "6.5", r: ".5", fill: "currentColor", key: "1okk4w" }],
221
+ ["circle", { cx: "17.5", cy: "10.5", r: ".5", fill: "currentColor", key: "f64h9f" }],
222
+ ["circle", { cx: "6.5", cy: "12.5", r: ".5", fill: "currentColor", key: "qy21gx" }],
223
+ ["circle", { cx: "8.5", cy: "7.5", r: ".5", fill: "currentColor", key: "fotxhn" }]
224
+ ], ir = S("palette", ar);
225
+ /**
226
+ * @license lucide-react v1.8.0 - ISC
227
+ *
228
+ * This source code is licensed under the ISC license.
229
+ * See the LICENSE file in the root directory of this source tree.
230
+ */
231
+ const sr = [
232
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
233
+ ["path", { d: "M14 9h1", key: "l0svgy" }],
234
+ ["path", { d: "M19 9h2", key: "te2zfg" }],
235
+ ["path", { d: "M3 9h2", key: "1h4ldw" }],
236
+ ["path", { d: "M9 9h1", key: "15jzuz" }]
237
+ ], lr = S("panel-top-dashed", sr);
238
+ /**
239
+ * @license lucide-react v1.8.0 - ISC
240
+ *
241
+ * This source code is licensed under the ISC license.
242
+ * See the LICENSE file in the root directory of this source tree.
243
+ */
244
+ const dr = [
245
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
246
+ ["path", { d: "M3 9h18", key: "1pudct" }]
247
+ ], cr = S("panel-top", dr);
248
+ /**
249
+ * @license lucide-react v1.8.0 - ISC
250
+ *
251
+ * This source code is licensed under the ISC license.
252
+ * See the LICENSE file in the root directory of this source tree.
253
+ */
254
+ const ur = [
255
+ ["path", { d: "M13 4v16", key: "8vvj80" }],
256
+ ["path", { d: "M17 4v16", key: "7dpous" }],
257
+ ["path", { d: "M19 4H9.5a4.5 4.5 0 0 0 0 9H13", key: "sh4n9v" }]
258
+ ], mr = S("pilcrow", ur);
259
+ /**
260
+ * @license lucide-react v1.8.0 - ISC
261
+ *
262
+ * This source code is licensed under the ISC license.
263
+ * See the LICENSE file in the root directory of this source tree.
264
+ */
265
+ const hr = [
266
+ [
267
+ "path",
268
+ {
269
+ 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",
270
+ key: "rib7q0"
271
+ }
272
+ ],
273
+ [
274
+ "path",
275
+ {
276
+ 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",
277
+ key: "1ymkrd"
278
+ }
279
+ ]
280
+ ], fr = S("quote", hr);
281
+ /**
282
+ * @license lucide-react v1.8.0 - ISC
283
+ *
284
+ * This source code is licensed under the ISC license.
285
+ * See the LICENSE file in the root directory of this source tree.
286
+ */
287
+ const gr = [
288
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
289
+ ["path", { d: "M3 12h18", key: "1i2n21" }]
290
+ ], pr = S("rows-2", gr);
291
+ /**
292
+ * @license lucide-react v1.8.0 - ISC
293
+ *
294
+ * This source code is licensed under the ISC license.
295
+ * See the LICENSE file in the root directory of this source tree.
296
+ */
297
+ const br = [
298
+ ["path", { d: "M16 4H9a3 3 0 0 0-2.83 4", key: "43sutm" }],
299
+ ["path", { d: "M14 12a4 4 0 0 1 0 8H6", key: "nlfj13" }],
300
+ ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }]
301
+ ], vr = S("strikethrough", br);
302
+ /**
303
+ * @license lucide-react v1.8.0 - ISC
304
+ *
305
+ * This source code is licensed under the ISC license.
306
+ * See the LICENSE file in the root directory of this source tree.
307
+ */
308
+ const yr = [
309
+ ["path", { d: "M12 3v18", key: "108xh3" }],
310
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
311
+ ["path", { d: "M3 9h18", key: "1pudct" }],
312
+ ["path", { d: "M3 15h18", key: "5xshup" }]
313
+ ], wr = S("table", yr);
314
+ /**
315
+ * @license lucide-react v1.8.0 - ISC
316
+ *
317
+ * This source code is licensed under the ISC license.
318
+ * See the LICENSE file in the root directory of this source tree.
319
+ */
320
+ const kr = [
321
+ ["path", { d: "M6 4v6a6 6 0 0 0 12 0V4", key: "9kb039" }],
322
+ ["line", { x1: "4", x2: "20", y1: "20", y2: "20", key: "nun2al" }]
323
+ ], xr = S("underline", kr);
324
+ /**
325
+ * @license lucide-react v1.8.0 - ISC
326
+ *
327
+ * This source code is licensed under the ISC license.
328
+ * See the LICENSE file in the root directory of this source tree.
329
+ */
330
+ const Cr = [
331
+ [
332
+ "path",
333
+ {
334
+ 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",
335
+ key: "1ngwbx"
336
+ }
337
+ ]
338
+ ], Nr = S("wrench", Cr), zr = {
339
+ id: "rich-text-editor",
340
+ capabilities: ["edit_inline"],
341
+ state: {
342
+ html: {
343
+ type: "string",
344
+ description: "Sanitised HTML representation of the editor content.",
345
+ read: (n) => n.getHTML()
346
+ },
347
+ text: {
348
+ type: "string",
349
+ description: "Plain-text content of the editor (tags stripped).",
350
+ read: (n) => n.getText()
351
+ },
352
+ markdown: {
353
+ type: "string",
354
+ description: "Markdown representation of the editor content. The Redactor engine has no native Markdown serialiser, so this is always empty — read `html` instead.",
355
+ read: (n) => n.getMarkdown()
356
+ }
357
+ },
358
+ actions: {
359
+ set_content: {
360
+ safety: "destructive",
361
+ argsType: "{ html: string }",
362
+ description: "Replace the editor content. Loses unsaved input.",
363
+ invoke: (n, a) => {
364
+ n.setContent(a.html);
365
+ }
366
+ },
367
+ insert_at_cursor: {
368
+ safety: "destructive",
369
+ argsType: "{ content: string; asHtml?: boolean }",
370
+ 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.",
371
+ invoke: (n, a) => {
372
+ n.insertAtCursor(a.content, { asHtml: a.asHtml });
373
+ }
374
+ },
375
+ apply_format: {
376
+ safety: "destructive",
377
+ argsType: "{ format: 'bold' | 'italic' | 'strikethrough' | 'bulletedList' | 'numberedList' | 'heading' | 'quote' | 'paragraph' }",
378
+ description: "Toggle/apply a block or inline format on the current selection (bold, italic, strikethrough, bulleted/numbered list, heading, quote, paragraph).",
379
+ invoke: (n, a) => {
380
+ n.applyFormat(a.format);
381
+ }
382
+ },
383
+ clear: {
384
+ safety: "destructive",
385
+ description: "Empty the editor. Loses unsaved input.",
386
+ invoke: (n) => {
387
+ n.clear();
388
+ }
389
+ },
390
+ focus: {
391
+ safety: "read",
392
+ description: "Move keyboard focus to the editor surface.",
393
+ invoke: (n) => {
394
+ n.focus();
395
+ }
396
+ }
397
+ },
398
+ domHooks: {
399
+ root: { attr: "data-component", value: "rich-text-editor" },
400
+ instanceId: {
401
+ attr: "data-component-id",
402
+ sourceProp: "id",
403
+ description: "Sourced from the id prop."
404
+ }
405
+ }
406
+ }, Tr = "ds:aria-pressed:!bg-[var(--destructive)] ds:aria-pressed:!text-[var(--destructive-foreground)]", Mr = "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", Rr = "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--destructive)]", Ve = [
407
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
408
+ "ds:bg-[color-mix(in_srgb,var(--background)_70%,transparent)]",
409
+ "ds:p-[var(--spacing-sm)] ds:[max-block-size:10rem] ds:overflow-y-auto",
410
+ "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--foreground)]"
411
+ ].join(" ");
412
+ function Ge(n, a) {
413
+ return a ? n ? /\s$/.test(n) ? `${n}${a}` : `${n} ${a}` : a : n;
414
+ }
415
+ function _r({
416
+ open: n,
417
+ onClose: a,
418
+ onRequestAiDraft: c,
419
+ onInsert: i,
420
+ previewAsHtml: s = !0,
421
+ privacyNotice: h,
422
+ onDictate: g
423
+ }) {
424
+ const { t: l } = X(), p = ae(), y = ae(), [T, $] = _(""), [E, k] = _(!1), [L, u] = _(!1), [m, b] = _(null), A = D(null), [M, H] = _(!1), [Z, C] = _(""), I = D(null), Q = z(() => {
425
+ var x;
426
+ (x = I.current) == null || x.abort();
427
+ }, []), ne = z(() => {
428
+ if (!g) return;
429
+ const x = new AbortController();
430
+ I.current = x, H(!0), C(""), g({
431
+ signal: x.signal,
432
+ onPartialTranscript: (O) => {
433
+ x.signal.aborted || C(O);
434
+ },
435
+ onFinalTranscript: (O) => {
436
+ if (x.signal.aborted) return;
437
+ const F = O.trim();
438
+ C(""), F && $((G) => Ge(G, F));
439
+ }
440
+ }).catch(() => {
441
+ }).finally(() => {
442
+ C(""), I.current === x && (I.current = null, H(!1));
443
+ });
444
+ }, [g]), N = z(() => {
445
+ M ? Q() : ne();
446
+ }, [M, ne, Q]);
447
+ K(() => {
448
+ var x, O;
449
+ n ? ($(""), k(!1), u(!1), b(null), C("")) : ((x = A.current) == null || x.abort(), A.current = null, (O = I.current) == null || O.abort());
450
+ }, [n]), K(
451
+ () => () => {
452
+ var x, O;
453
+ (x = A.current) == null || x.abort(), (O = I.current) == null || O.abort();
454
+ },
455
+ []
456
+ );
457
+ const V = z(() => {
458
+ var F;
459
+ const x = T.trim();
460
+ if (!x || E) return;
461
+ Q(), (F = A.current) == null || F.abort();
462
+ const O = new AbortController();
463
+ A.current = O, u(!1), k(!0), c({ prompt: x, signal: O.signal }).then((G) => {
464
+ O.signal.aborted || (b(G), k(!1));
465
+ }).catch((G) => {
466
+ O.signal.aborted || G && typeof G == "object" && "name" in G && G.name === "AbortError" || (u(!0), k(!1));
467
+ });
468
+ }, [T, E, c, Q]), B = z(() => {
469
+ m != null && (i(m), a());
470
+ }, [m, i, a]), ie = m != null, me = M ? Ge(T, Z) : T;
471
+ return /* @__PURE__ */ e(
472
+ wt,
473
+ {
474
+ open: n,
475
+ onClose: a,
476
+ title: /* @__PURE__ */ v("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
477
+ /* @__PURE__ */ e(Ee, { "aria-hidden": "true", className: "ds:size-4" }),
478
+ l("editor.ai.dialogTitle")
479
+ ] }),
480
+ ariaLabel: l("editor.ai.dialogTitle"),
481
+ children: ie ? /* @__PURE__ */ v("div", { className: "ds:flex ds:items-end ds:gap-[var(--spacing-xs)]", children: [
482
+ /* @__PURE__ */ e("div", { className: "ds:min-w-0 ds:flex-1", children: s ? /* @__PURE__ */ e(
483
+ gt,
484
+ {
485
+ html: m,
486
+ profile: "rich-text",
487
+ className: Ve,
488
+ tabIndex: 0,
489
+ "aria-label": l("editor.ai.dialogTitle")
490
+ }
491
+ ) : (
492
+ // Focusable so a keyboard user can scroll a long draft preview
493
+ // (mirrors the SafeHtml preview branch above). The lint rule's
494
+ // tabIndex allowlist doesn't cover a scrollable, non-interactive
495
+ // text region.
496
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
497
+ /* @__PURE__ */ e("p", { className: Ve, tabIndex: 0, children: m })
498
+ ) }),
499
+ /* @__PURE__ */ e(
500
+ q,
501
+ {
502
+ size: "sm",
503
+ intent: "ghost",
504
+ className: "ds:rounded-full",
505
+ icon: /* @__PURE__ */ e(kt, {}),
506
+ "aria-label": l("editor.ai.retry"),
507
+ onClick: () => b(null)
508
+ }
509
+ ),
510
+ /* @__PURE__ */ e(
511
+ q,
512
+ {
513
+ size: "sm",
514
+ intent: "primary",
515
+ className: "ds:rounded-full",
516
+ icon: /* @__PURE__ */ e(xt, {}),
517
+ "aria-label": l("common.confirm"),
518
+ onClick: B
519
+ }
520
+ )
521
+ ] }) : /* @__PURE__ */ v(Ae, { children: [
522
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:items-end ds:gap-[var(--spacing-xs)]", children: [
523
+ /* @__PURE__ */ e("div", { className: "ds:min-w-0 ds:flex-1", children: /* @__PURE__ */ e(
524
+ yt,
525
+ {
526
+ id: p,
527
+ size: "md",
528
+ value: me,
529
+ onChange: (x) => $(x.target.value),
530
+ placeholder: l("editor.ai.promptPlaceholder"),
531
+ "aria-label": l("editor.ai.promptLabel"),
532
+ autoResize: !0,
533
+ minRows: 1,
534
+ maxRows: 3,
535
+ readOnly: M,
536
+ tone: L ? "error" : "default",
537
+ "aria-describedby": L ? y : void 0
538
+ }
539
+ ) }),
540
+ g ? /* @__PURE__ */ e(
541
+ q,
542
+ {
543
+ size: "sm",
544
+ intent: "ghost",
545
+ className: M ? Tr : void 0,
546
+ icon: M ? /* @__PURE__ */ e(_e, { className: "ds:fill-current" }) : /* @__PURE__ */ e(Se, {}),
547
+ "aria-pressed": M,
548
+ "aria-label": l(M ? "editor.ai.dictateStop" : "editor.ai.dictateStart"),
549
+ onClick: N
550
+ }
551
+ ) : null,
552
+ /* @__PURE__ */ e(
553
+ q,
554
+ {
555
+ size: "sm",
556
+ intent: "primary",
557
+ icon: E ? /* @__PURE__ */ e(vt, { size: "sm", variant: "pulse" }) : /* @__PURE__ */ e(Ct, {}),
558
+ className: "ds:rounded-full",
559
+ disabled: E || !T.trim(),
560
+ "aria-busy": E || void 0,
561
+ "aria-label": l("editor.ai.generate"),
562
+ onClick: V
563
+ }
564
+ )
565
+ ] }),
566
+ L ? /* @__PURE__ */ e("p", { id: y, role: "alert", className: Rr, children: l("editor.ai.error") }) : h ? /* @__PURE__ */ e("p", { className: Mr, children: h }) : null
567
+ ] })
568
+ }
569
+ );
570
+ }
571
+ const Sr = {
572
+ bold: {
573
+ id: "bold",
574
+ icon: /* @__PURE__ */ e(qt, {}),
575
+ label: ["editor.bold", "Bold"],
576
+ command: ["module.inline.format", { tag: "b" }],
577
+ toggle: "bold"
578
+ },
579
+ italic: {
580
+ id: "italic",
581
+ icon: /* @__PURE__ */ e(Xt, {}),
582
+ label: ["editor.italic", "Italic"],
583
+ command: ["module.inline.format", { tag: "i" }],
584
+ toggle: "italic"
585
+ },
586
+ underline: {
587
+ id: "underline",
588
+ icon: /* @__PURE__ */ e(xr, {}),
589
+ label: ["editor.underline", "Underline"],
590
+ command: ["module.inline.format", { tag: "u" }],
591
+ toggle: "underline"
592
+ },
593
+ strike: {
594
+ id: "strike",
595
+ icon: /* @__PURE__ */ e(vr, {}),
596
+ label: ["editor.strike", "Strikethrough"],
597
+ command: ["module.inline.format", { tag: "del" }],
598
+ toggle: "strike"
599
+ },
600
+ ul: {
601
+ id: "ul",
602
+ icon: /* @__PURE__ */ e(er, {}),
603
+ label: ["editor.list.bullet", "Bulleted list"],
604
+ command: ["module.list.toggle", "ul"],
605
+ toggle: "ul"
606
+ },
607
+ ol: {
608
+ id: "ol",
609
+ icon: /* @__PURE__ */ e(Jt, {}),
610
+ label: ["editor.list.ordered", "Numbered list"],
611
+ command: ["module.list.toggle", "ol"],
612
+ toggle: "ol"
613
+ }
614
+ }, Me = [
615
+ {
616
+ id: "paragraph",
617
+ tag: "p",
618
+ icon: /* @__PURE__ */ e(mr, {}),
619
+ label: ["editor.paragraph", "Paragraph"]
620
+ },
621
+ {
622
+ id: "h2",
623
+ tag: "h2",
624
+ icon: /* @__PURE__ */ e(Bt, {}),
625
+ label: ["editor.heading2", "Heading 2"]
626
+ },
627
+ {
628
+ id: "h3",
629
+ tag: "h3",
630
+ icon: /* @__PURE__ */ e(Vt, {}),
631
+ label: ["editor.heading3", "Heading 3"]
632
+ },
633
+ {
634
+ id: "quote",
635
+ tag: "blockquote",
636
+ icon: /* @__PURE__ */ e(fr, {}),
637
+ label: ["editor.quote", "Quote"]
638
+ }
639
+ ], Er = {
640
+ minimal: ["bold", "italic", "link"],
641
+ standard: [
642
+ "format",
643
+ "bold",
644
+ "italic",
645
+ "underline",
646
+ "strike",
647
+ "ul",
648
+ "ol",
649
+ "link"
650
+ ],
651
+ full: ["format", "bold", "italic", "underline", "strike", "ul", "ol", "link"]
652
+ }, Xe = [
653
+ {
654
+ id: "rowAbove",
655
+ command: "plugin.table.addRowAbove",
656
+ icon: /* @__PURE__ */ e(It, {}),
657
+ label: ["editor.table.rowAbove", "Add row above"]
658
+ },
659
+ {
660
+ id: "rowBelow",
661
+ command: "plugin.table.addRowBelow",
662
+ icon: /* @__PURE__ */ e(At, {}),
663
+ label: ["editor.table.rowBelow", "Add row below"]
664
+ },
665
+ {
666
+ id: "colLeft",
667
+ command: "plugin.table.addColumnLeft",
668
+ icon: /* @__PURE__ */ e(Dt, {}),
669
+ label: ["editor.table.columnLeft", "Add column left"]
670
+ },
671
+ {
672
+ id: "colRight",
673
+ command: "plugin.table.addColumnRight",
674
+ icon: /* @__PURE__ */ e(Lt, {}),
675
+ label: ["editor.table.columnRight", "Add column right"]
676
+ },
677
+ {
678
+ id: "addHead",
679
+ command: "plugin.table.addHead",
680
+ icon: /* @__PURE__ */ e(cr, {}),
681
+ label: ["editor.table.addHeader", "Add header row"]
682
+ },
683
+ {
684
+ id: "deleteHead",
685
+ command: "plugin.table.deleteHead",
686
+ icon: /* @__PURE__ */ e(lr, {}),
687
+ label: ["editor.table.deleteHeader", "Remove header row"]
688
+ },
689
+ {
690
+ id: "deleteRow",
691
+ command: "plugin.table.deleteRow",
692
+ icon: /* @__PURE__ */ e(pr, {}),
693
+ label: ["editor.table.deleteRow", "Delete row"]
694
+ },
695
+ {
696
+ id: "deleteColumn",
697
+ command: "plugin.table.deleteColumn",
698
+ icon: /* @__PURE__ */ e(_t, {}),
699
+ label: ["editor.table.deleteColumn", "Delete column"]
700
+ },
701
+ {
702
+ id: "deleteTable",
703
+ command: "plugin.table.deleteTable",
704
+ icon: /* @__PURE__ */ e(St, {}),
705
+ label: ["editor.table.deleteTable", "Delete table"]
706
+ }
707
+ ], we = 6, Ar = He(
708
+ [
709
+ "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]",
710
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
711
+ "ds:bg-[var(--background)] ds:p-[var(--spacing-xs)]",
712
+ "ds:shadow-[var(--shadow-md)]"
713
+ ].join(" ")
714
+ ), Qe = "ds:self-stretch ds:[inline-size:var(--border-width-sm)] ds:bg-[var(--border)] ds:[margin-inline:var(--spacing-2xs)]", ue = "ds:text-[length:var(--font-size-sm)] ds:font-medium ds:text-[color:var(--foreground)]";
715
+ function xe(n) {
716
+ return n.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
717
+ }
718
+ function Hr({
719
+ run: n,
720
+ active: a,
721
+ onTriggerDown: c
722
+ }) {
723
+ const { t: i } = X(), s = Me.find((h) => a.has(h.id)) ?? Me[0];
724
+ return /* @__PURE__ */ v(ye.Root, { children: [
725
+ /* @__PURE__ */ e(ye.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
726
+ re,
727
+ {
728
+ size: "sm",
729
+ intent: "ghost",
730
+ startIcon: s.icon,
731
+ endIcon: /* @__PURE__ */ e(Mt, {}),
732
+ "aria-label": i("editor.format", "Paragraph style"),
733
+ onMouseDown: c,
734
+ children: i(s.label[0], s.label[1])
735
+ }
736
+ ) }),
737
+ /* @__PURE__ */ e(ye.Content, { align: "start", children: Me.map((h) => /* @__PURE__ */ e(
738
+ ye.Item,
739
+ {
740
+ startIcon: h.icon,
741
+ onSelect: () => n("module.block.format", { tag: h.tag }),
742
+ children: i(h.label[0], h.label[1])
743
+ },
744
+ h.id
745
+ )) })
746
+ ] });
747
+ }
748
+ function Ir({
749
+ insertHtml: n,
750
+ saveSelection: a,
751
+ restoreSelection: c,
752
+ getSelectedText: i
753
+ }) {
754
+ const { t: s } = X(), [h, g] = _(!1), [l, p] = _(""), [y, T] = _(""), [$, E] = _(!1), k = ae(), L = ae(), u = () => {
755
+ p(""), T(""), E(!1);
756
+ }, m = () => {
757
+ const b = l.trim();
758
+ if (!b) return;
759
+ const A = y.trim() || b, M = $ ? ' target="_blank" rel="noopener noreferrer"' : "", H = `<a href="${xe(b)}"${M}>${xe(A)}</a>`;
760
+ g(!1), u(), window.requestAnimationFrame(() => {
761
+ c(), n(H);
762
+ });
763
+ };
764
+ return /* @__PURE__ */ v(j.Root, { open: h, onOpenChange: g, children: [
765
+ /* @__PURE__ */ e(j.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
766
+ q,
767
+ {
768
+ size: "sm",
769
+ intent: "ghost",
770
+ icon: /* @__PURE__ */ e(Yt, {}),
771
+ "aria-label": s("editor.link.insert", "Insert link"),
772
+ onMouseDown: () => {
773
+ a(), T(i());
774
+ }
775
+ }
776
+ ) }),
777
+ /* @__PURE__ */ v(j.Content, { children: [
778
+ /* @__PURE__ */ e(j.Header, { children: /* @__PURE__ */ e(j.Title, { children: s("editor.link.insert", "Insert link") }) }),
779
+ /* @__PURE__ */ v(j.Body, { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
780
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
781
+ /* @__PURE__ */ e("label", { htmlFor: k, className: ue, children: s("editor.link.url", "URL") }),
782
+ /* @__PURE__ */ e(
783
+ ke,
784
+ {
785
+ id: k,
786
+ type: "url",
787
+ value: l,
788
+ onChange: (b) => p(b.target.value),
789
+ placeholder: "https://…"
790
+ }
791
+ )
792
+ ] }),
793
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
794
+ /* @__PURE__ */ e("label", { htmlFor: L, className: ue, children: s("editor.link.text", "Text to display") }),
795
+ /* @__PURE__ */ e(
796
+ ke,
797
+ {
798
+ id: L,
799
+ value: y,
800
+ onChange: (b) => T(b.target.value),
801
+ placeholder: s("editor.link.textPlaceholder", "Link text")
802
+ }
803
+ )
804
+ ] }),
805
+ /* @__PURE__ */ e(
806
+ zt,
807
+ {
808
+ checked: $,
809
+ onCheckedChange: (b) => E(b === !0),
810
+ label: s("editor.link.newTab", "Open in new tab")
811
+ }
812
+ )
813
+ ] }),
814
+ /* @__PURE__ */ v(j.Footer, { children: [
815
+ /* @__PURE__ */ e(j.Close, { asChild: !0, children: /* @__PURE__ */ e(re, { intent: "secondary", children: s("editor.ai.cancel", "Cancel") }) }),
816
+ /* @__PURE__ */ e(re, { onClick: m, disabled: !l.trim(), children: s("editor.link.insertAction", "Insert") })
817
+ ] })
818
+ ] })
819
+ ] });
820
+ }
821
+ function $r({
822
+ insertHtml: n,
823
+ saveSelection: a,
824
+ restoreSelection: c,
825
+ uploadImage: i
826
+ }) {
827
+ const { t: s } = X(), [h, g] = _(!1), [l, p] = _(""), [y, T] = _(""), $ = ae(), E = ae(), k = (u, m) => {
828
+ const b = `<img src="${xe(u)}" alt="${xe(m)}" loading="lazy">`;
829
+ g(!1), p(""), T(""), window.requestAnimationFrame(() => {
830
+ c(), n(b);
831
+ });
832
+ }, L = () => {
833
+ const u = l.trim();
834
+ u && k(u, y.trim());
835
+ };
836
+ return /* @__PURE__ */ v(j.Root, { open: h, onOpenChange: g, children: [
837
+ /* @__PURE__ */ e(j.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
838
+ q,
839
+ {
840
+ size: "sm",
841
+ intent: "ghost",
842
+ icon: /* @__PURE__ */ e(Rt, {}),
843
+ "aria-label": s("editor.image.insert", "Insert image"),
844
+ onMouseDown: () => a()
845
+ }
846
+ ) }),
847
+ /* @__PURE__ */ v(j.Content, { children: [
848
+ /* @__PURE__ */ e(j.Header, { children: /* @__PURE__ */ e(j.Title, { children: s("editor.image.insert", "Insert image") }) }),
849
+ /* @__PURE__ */ v(j.Body, { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
850
+ i ? /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
851
+ /* @__PURE__ */ e("span", { className: ue, children: s("editor.image.upload", "Upload") }),
852
+ /* @__PURE__ */ e(
853
+ Tt,
854
+ {
855
+ variant: "dropzone",
856
+ accept: {
857
+ "image/*": [".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg"]
858
+ },
859
+ maxFiles: 1,
860
+ onUpload: async (u, { signal: m }) => {
861
+ const b = await i(u, m);
862
+ k(b, u.name);
863
+ }
864
+ }
865
+ ),
866
+ /* @__PURE__ */ e("span", { className: "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", children: s("editor.image.orUrl", "Or paste an image URL") })
867
+ ] }) : null,
868
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
869
+ /* @__PURE__ */ e("label", { htmlFor: $, className: ue, children: s("editor.image.url", "Image URL") }),
870
+ /* @__PURE__ */ e(
871
+ ke,
872
+ {
873
+ id: $,
874
+ type: "url",
875
+ value: l,
876
+ onChange: (u) => p(u.target.value),
877
+ placeholder: "https://…"
878
+ }
879
+ )
880
+ ] }),
881
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
882
+ /* @__PURE__ */ e("label", { htmlFor: E, className: ue, children: s("editor.image.alt", "Alt text") }),
883
+ /* @__PURE__ */ e(
884
+ ke,
885
+ {
886
+ id: E,
887
+ value: y,
888
+ onChange: (u) => T(u.target.value),
889
+ placeholder: s(
890
+ "editor.image.altPlaceholder",
891
+ "Describe the image"
892
+ )
893
+ }
894
+ )
895
+ ] })
896
+ ] }),
897
+ /* @__PURE__ */ v(j.Footer, { children: [
898
+ /* @__PURE__ */ e(j.Close, { asChild: !0, children: /* @__PURE__ */ e(re, { intent: "secondary", children: s("editor.ai.cancel", "Cancel") }) }),
899
+ /* @__PURE__ */ e(re, { onClick: L, disabled: !l.trim(), children: s("editor.link.insertAction", "Insert") })
900
+ ] })
901
+ ] })
902
+ ] });
903
+ }
904
+ function Lr({
905
+ run: n,
906
+ saveSelection: a,
907
+ restoreSelection: c
908
+ }) {
909
+ const { t: i } = X(), [s, h] = _("#1f2a5c"), g = (p) => {
910
+ h(p), c(), n("module.inline.format", {
911
+ tag: "span",
912
+ style: { color: p },
913
+ type: "toggle"
914
+ });
915
+ }, l = () => {
916
+ c(), n("module.inline.remove", { style: "color" });
917
+ };
918
+ return /* @__PURE__ */ v(P, { onOpenChange: (p) => p && a(), children: [
919
+ /* @__PURE__ */ e(P.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
920
+ q,
921
+ {
922
+ size: "sm",
923
+ intent: "ghost",
924
+ icon: /* @__PURE__ */ e(ir, {}),
925
+ "aria-label": i("editor.textColor", "Text colour"),
926
+ onMouseDown: (p) => {
927
+ p.preventDefault(), a();
928
+ }
929
+ }
930
+ ) }),
931
+ /* @__PURE__ */ v(P.Content, { side: "bottom", align: "start", children: [
932
+ /* @__PURE__ */ e(P.Heading, { children: i("editor.textColor", "Text colour") }),
933
+ /* @__PURE__ */ e("div", { className: "ds:pt-[var(--spacing-sm)]", children: /* @__PURE__ */ e(
934
+ Ie,
935
+ {
936
+ variant: "inline",
937
+ size: "sm",
938
+ value: s,
939
+ onChange: g
940
+ }
941
+ ) }),
942
+ /* @__PURE__ */ e("div", { className: "ds:mt-[var(--spacing-sm)] ds:flex ds:items-center ds:justify-end", children: /* @__PURE__ */ e(re, { size: "sm", intent: "secondary", onClick: l, children: i("editor.color.remove", "Remove colour") }) })
943
+ ] })
944
+ ] });
945
+ }
946
+ function Or({
947
+ run: n,
948
+ saveSelection: a,
949
+ restoreSelection: c
950
+ }) {
951
+ const { t: i } = X(), [s, h] = _("#fff3a3"), g = (p) => {
952
+ h(p), c(), n("module.inline.format", {
953
+ tag: "span",
954
+ style: { "background-color": p },
955
+ type: "toggle"
956
+ });
957
+ }, l = () => {
958
+ c(), n("module.inline.remove", { style: "background-color" });
959
+ };
960
+ return /* @__PURE__ */ v(P, { onOpenChange: (p) => p && a(), children: [
961
+ /* @__PURE__ */ e(P.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
962
+ q,
963
+ {
964
+ size: "sm",
965
+ intent: "ghost",
966
+ icon: /* @__PURE__ */ e(Wt, {}),
967
+ "aria-label": i("editor.highlightColor", "Highlight"),
968
+ onMouseDown: (p) => {
969
+ p.preventDefault(), a();
970
+ }
971
+ }
972
+ ) }),
973
+ /* @__PURE__ */ v(P.Content, { side: "bottom", align: "start", children: [
974
+ /* @__PURE__ */ e(P.Heading, { children: i("editor.highlightColor", "Highlight") }),
975
+ /* @__PURE__ */ e("div", { className: "ds:pt-[var(--spacing-sm)]", children: /* @__PURE__ */ e(
976
+ Ie,
977
+ {
978
+ variant: "inline",
979
+ size: "sm",
980
+ value: s,
981
+ onChange: g
982
+ }
983
+ ) }),
984
+ /* @__PURE__ */ e("div", { className: "ds:mt-[var(--spacing-sm)] ds:flex ds:items-center ds:justify-end", children: /* @__PURE__ */ e(re, { size: "sm", intent: "secondary", onClick: l, children: i("editor.highlight.remove", "Remove highlight") }) })
985
+ ] })
986
+ ] });
987
+ }
988
+ function Dr(n, a) {
989
+ const c = Array.from({ length: a }, () => "<td><br></td>").join("");
990
+ return `<table><tbody>${Array.from({ length: n }, () => `<tr>${c}</tr>`).join("")}</tbody></table>`;
991
+ }
992
+ function jr({
993
+ run: n,
994
+ insertTable: a,
995
+ active: c
996
+ }) {
997
+ const { t: i } = X(), [s, h] = _({ r: 0, c: 0 }), g = c.has("table");
998
+ return /* @__PURE__ */ v(P, { onOpenChange: (l) => !l && h({ r: 0, c: 0 }), children: [
999
+ /* @__PURE__ */ e(P.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
1000
+ q,
1001
+ {
1002
+ size: "sm",
1003
+ intent: "ghost",
1004
+ icon: /* @__PURE__ */ e(wr, {}),
1005
+ "aria-label": i("editor.table.insert", "Insert table"),
1006
+ onMouseDown: (l) => l.preventDefault()
1007
+ }
1008
+ ) }),
1009
+ /* @__PURE__ */ e(P.Content, { side: "bottom", align: "start", children: g ? (
1010
+ // Caret is already inside a table — offer the manage ops only, never
1011
+ // a nested-table insert (mirrors Redactor's native dropdown, which
1012
+ // disables "insert table" while the caret is in a table).
1013
+ /* @__PURE__ */ e("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]", children: Xe.map((l) => /* @__PURE__ */ v(
1014
+ "button",
1015
+ {
1016
+ type: "button",
1017
+ onClick: () => n(l.command),
1018
+ 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)]",
1019
+ children: [
1020
+ /* @__PURE__ */ e(
1021
+ "span",
1022
+ {
1023
+ "aria-hidden": "true",
1024
+ className: "ds:inline-flex ds:size-4 ds:shrink-0 ds:items-center ds:justify-center ds:text-[color:var(--muted-foreground)]",
1025
+ children: l.icon
1026
+ }
1027
+ ),
1028
+ i(l.label[0], l.label[1])
1029
+ ]
1030
+ },
1031
+ l.id
1032
+ )) })
1033
+ ) : /* @__PURE__ */ v(Ae, { children: [
1034
+ /* @__PURE__ */ e(P.Heading, { children: i("editor.table.insert", "Insert table") }),
1035
+ /* @__PURE__ */ e(
1036
+ "div",
1037
+ {
1038
+ role: "group",
1039
+ "aria-label": i("editor.table.sizePicker", "Table size"),
1040
+ className: "ds:mt-[var(--spacing-sm)] ds:grid ds:w-fit ds:grid-cols-6 ds:gap-[var(--spacing-2xs)]",
1041
+ onMouseLeave: () => h({ r: 0, c: 0 }),
1042
+ children: Array.from({ length: we * we }, (l, p) => {
1043
+ const y = Math.floor(p / we) + 1, T = p % we + 1, $ = y <= s.r && T <= s.c;
1044
+ return /* @__PURE__ */ e(
1045
+ "button",
1046
+ {
1047
+ type: "button",
1048
+ "aria-label": i("editor.table.sizeCell", "{{r}}×{{c}}", {
1049
+ r: y,
1050
+ c: T
1051
+ }),
1052
+ onMouseEnter: () => h({ r: y, c: T }),
1053
+ onClick: () => a(Dr(y, T)),
1054
+ className: `ds:size-5 ds:rounded-[var(--radius-sm)] ds:border ds:border-[color:var(--border)] ${$ ? "ds:bg-[var(--primary)]" : "ds:bg-[var(--muted)]"}`
1055
+ },
1056
+ p
1057
+ );
1058
+ })
1059
+ }
1060
+ ),
1061
+ /* @__PURE__ */ e("p", { className: "ds:mt-[var(--spacing-xs)] ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", children: s.r > 0 ? i("editor.table.sizeCell", "{{r}}×{{c}}", {
1062
+ r: s.r,
1063
+ c: s.c
1064
+ }) : i("editor.table.sizeHint", "Pick a size") })
1065
+ ] }) })
1066
+ ] });
1067
+ }
1068
+ const qr = Object.fromEntries(Xe.map((n) => [n.id, n])), Pr = [
1069
+ "ds:absolute ds:z-20 ds:flex ds:items-center ds:gap-[var(--spacing-2xs)]",
1070
+ "ds:[inset-block-start:var(--rte-tt-top)] ds:[inset-inline-start:var(--rte-tt-start)]",
1071
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
1072
+ "ds:bg-[var(--popover)] ds:p-[var(--spacing-2xs)] ds:shadow-[var(--shadow-lg)]"
1073
+ ].join(" "), Br = "#fde68a";
1074
+ function We({
1075
+ scope: n,
1076
+ icon: a,
1077
+ label: c,
1078
+ onOpenChange: i,
1079
+ saveTableCell: s,
1080
+ applyTableBackground: h
1081
+ }) {
1082
+ const { t: g } = X(), [l, p] = _(Br);
1083
+ return /* @__PURE__ */ v(
1084
+ P,
1085
+ {
1086
+ onOpenChange: (y) => {
1087
+ i(y), y && s();
1088
+ },
1089
+ children: [
1090
+ /* @__PURE__ */ e(P.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
1091
+ q,
1092
+ {
1093
+ size: "sm",
1094
+ intent: "ghost",
1095
+ icon: a,
1096
+ tooltip: c,
1097
+ onMouseDown: (y) => y.preventDefault()
1098
+ }
1099
+ ) }),
1100
+ /* @__PURE__ */ v(P.Content, { side: "bottom", align: "center", children: [
1101
+ /* @__PURE__ */ e(
1102
+ Ie,
1103
+ {
1104
+ variant: "inline",
1105
+ size: "sm",
1106
+ value: l,
1107
+ onChange: (y) => {
1108
+ p(y), h(n, y);
1109
+ }
1110
+ }
1111
+ ),
1112
+ /* @__PURE__ */ e(
1113
+ re,
1114
+ {
1115
+ size: "sm",
1116
+ intent: "ghost",
1117
+ className: "ds:mt-[var(--spacing-xs)] ds:w-full",
1118
+ onClick: () => h(n, null),
1119
+ children: g("editor.table.clearColor", "Clear colour")
1120
+ }
1121
+ )
1122
+ ] })
1123
+ ]
1124
+ }
1125
+ );
1126
+ }
1127
+ function Fr({
1128
+ active: n,
1129
+ run: a,
1130
+ areaRef: c,
1131
+ getActiveTableEl: i,
1132
+ enableColor: s = !1,
1133
+ saveTableCell: h,
1134
+ applyTableBackground: g
1135
+ }) {
1136
+ const { t: l } = X(), p = n.has("table"), [y, T] = _(null), $ = D(0), [E, k] = _(!1), L = z((m) => {
1137
+ $.current = Math.max(
1138
+ 0,
1139
+ $.current + (m ? 1 : -1)
1140
+ ), k($.current > 0);
1141
+ }, []);
1142
+ if (K(() => {
1143
+ if (E) return;
1144
+ if (!p || typeof window > "u") {
1145
+ T(null);
1146
+ return;
1147
+ }
1148
+ const m = () => {
1149
+ const H = c.current, Z = i();
1150
+ if (!H || !Z) {
1151
+ T(null);
1152
+ return;
1153
+ }
1154
+ const C = H.getBoundingClientRect(), I = Z.getBoundingClientRect(), Q = getComputedStyle(H).direction === "rtl", ne = Math.max(0, I.top - C.top - 44), N = Q ? C.right - I.right + I.width / 2 : I.left - C.left + I.width / 2;
1155
+ T({ top: ne, start: Math.max(0, N), rtl: Q });
1156
+ };
1157
+ m();
1158
+ const b = new ResizeObserver(m), A = c.current, M = i();
1159
+ return A && b.observe(A), M && b.observe(M), window.addEventListener("scroll", m, !0), window.addEventListener("resize", m), () => {
1160
+ b.disconnect(), window.removeEventListener("scroll", m, !0), window.removeEventListener("resize", m);
1161
+ };
1162
+ }, [p, E, c, i]), !p && !E || !y) return null;
1163
+ const u = [
1164
+ ["rowAbove", "rowBelow"],
1165
+ ["colLeft", "colRight"],
1166
+ ["addHead"],
1167
+ ...s ? ["colour"] : [],
1168
+ ["deleteRow", "deleteColumn"],
1169
+ ["deleteTable"]
1170
+ ];
1171
+ return (
1172
+ // Tooltips disambiguate the icon-only ops on hover (and provide each
1173
+ // button's accessible name via IconButton's `tooltip` prop). Radix Tooltip
1174
+ // needs a provider ancestor, so scope one to the bar.
1175
+ /* @__PURE__ */ e(Nt, { children: /* @__PURE__ */ e(
1176
+ "div",
1177
+ {
1178
+ role: "toolbar",
1179
+ "aria-label": l("editor.table.toolbar", "Table tools"),
1180
+ className: `${Pr} ${y.rtl ? "ds:translate-x-1/2" : "ds:-translate-x-1/2"}`,
1181
+ style: {
1182
+ "--rte-tt-top": `${y.top}px`,
1183
+ "--rte-tt-start": `${y.start}px`
1184
+ },
1185
+ children: u.map((m, b) => /* @__PURE__ */ v(mt, { children: [
1186
+ b > 0 ? /* @__PURE__ */ e("span", { "aria-hidden": "true", className: Qe }) : null,
1187
+ m === "colour" ? /* @__PURE__ */ v(Ae, { children: [
1188
+ /* @__PURE__ */ e(
1189
+ We,
1190
+ {
1191
+ scope: "cell",
1192
+ icon: /* @__PURE__ */ e(rr, {}),
1193
+ label: l("editor.table.cellColor", "Cell colour"),
1194
+ onOpenChange: L,
1195
+ saveTableCell: h,
1196
+ applyTableBackground: g
1197
+ }
1198
+ ),
1199
+ /* @__PURE__ */ e(
1200
+ We,
1201
+ {
1202
+ scope: "row",
1203
+ icon: /* @__PURE__ */ e(or, {}),
1204
+ label: l("editor.table.rowColor", "Row colour"),
1205
+ onOpenChange: L,
1206
+ saveTableCell: h,
1207
+ applyTableBackground: g
1208
+ }
1209
+ )
1210
+ ] }) : m.map((A) => {
1211
+ const M = qr[A];
1212
+ return /* @__PURE__ */ e(
1213
+ q,
1214
+ {
1215
+ size: "sm",
1216
+ intent: "ghost",
1217
+ icon: M.icon,
1218
+ tooltip: l(M.label[0], M.label[1]),
1219
+ onMouseDown: (H) => H.preventDefault(),
1220
+ onClick: () => a(M.command)
1221
+ },
1222
+ A
1223
+ );
1224
+ })
1225
+ ] }, m === "colour" ? "colour" : m[0]))
1226
+ }
1227
+ ) })
1228
+ );
1229
+ }
1230
+ function Vr({
1231
+ run: n,
1232
+ active: a,
1233
+ preset: c,
1234
+ insertHtml: i,
1235
+ insertTable: s,
1236
+ saveSelection: h,
1237
+ restoreSelection: g,
1238
+ getSelectedText: l,
1239
+ uploadImage: p,
1240
+ enableColor: y = !1,
1241
+ enableImage: T = !1,
1242
+ enableTable: $ = !1,
1243
+ showExtensions: E = !1
1244
+ }) {
1245
+ const { t: k } = X(), L = (C) => C.preventDefault(), u = (C) => Er[c].includes(C), m = (C) => {
1246
+ if (!u(C)) return null;
1247
+ const I = Sr[C];
1248
+ return /* @__PURE__ */ e(
1249
+ q,
1250
+ {
1251
+ size: "sm",
1252
+ intent: "ghost",
1253
+ icon: I.icon,
1254
+ "aria-label": k(I.label[0], I.label[1]),
1255
+ "aria-pressed": I.toggle ? a.has(I.toggle) : void 0,
1256
+ onMouseDown: L,
1257
+ onClick: () => n(...I.command)
1258
+ },
1259
+ I.id
1260
+ );
1261
+ }, b = () => /* @__PURE__ */ e("span", { "aria-hidden": "true", className: Qe }), A = u("format"), M = u("bold") || u("italic") || u("underline") || u("strike") || y, H = u("ul") || u("ol"), Z = u("link") || T || $;
1262
+ return /* @__PURE__ */ v(
1263
+ "div",
1264
+ {
1265
+ role: "toolbar",
1266
+ "aria-label": k("editor.toolbarLabel"),
1267
+ className: Ar(),
1268
+ "data-component": "editor-toolbar",
1269
+ children: [
1270
+ A ? /* @__PURE__ */ e(Hr, { run: n, active: a, onTriggerDown: L }) : null,
1271
+ A && M ? /* @__PURE__ */ e(b, {}) : null,
1272
+ m("bold"),
1273
+ m("italic"),
1274
+ m("underline"),
1275
+ m("strike"),
1276
+ y ? /* @__PURE__ */ e(
1277
+ Lr,
1278
+ {
1279
+ run: n,
1280
+ saveSelection: h,
1281
+ restoreSelection: g
1282
+ }
1283
+ ) : null,
1284
+ y ? /* @__PURE__ */ e(
1285
+ Or,
1286
+ {
1287
+ run: n,
1288
+ saveSelection: h,
1289
+ restoreSelection: g
1290
+ }
1291
+ ) : null,
1292
+ (A || M) && H ? /* @__PURE__ */ e(b, {}) : null,
1293
+ m("ul"),
1294
+ m("ol"),
1295
+ (A || M || H) && Z ? /* @__PURE__ */ e(b, {}) : null,
1296
+ u("link") ? /* @__PURE__ */ e(
1297
+ Ir,
1298
+ {
1299
+ insertHtml: i,
1300
+ saveSelection: h,
1301
+ restoreSelection: g,
1302
+ getSelectedText: l
1303
+ }
1304
+ ) : null,
1305
+ T ? /* @__PURE__ */ e(
1306
+ $r,
1307
+ {
1308
+ insertHtml: i,
1309
+ saveSelection: h,
1310
+ restoreSelection: g,
1311
+ uploadImage: p
1312
+ }
1313
+ ) : null,
1314
+ $ ? /* @__PURE__ */ e(jr, { run: n, insertTable: s, active: a }) : null,
1315
+ E && (A || M || H || Z) ? /* @__PURE__ */ e(b, {}) : null,
1316
+ E ? /* @__PURE__ */ e(
1317
+ q,
1318
+ {
1319
+ size: "sm",
1320
+ intent: "ghost",
1321
+ icon: /* @__PURE__ */ e(Nr, {}),
1322
+ "aria-label": k("editor.extensions", "Editor extensions"),
1323
+ onMouseDown: L
1324
+ }
1325
+ ) : null
1326
+ ]
1327
+ }
1328
+ );
1329
+ }
1330
+ function te(n) {
1331
+ return pt(n, "rich-text");
1332
+ }
1333
+ function Re(n = "") {
1334
+ const a = String(n).trim();
1335
+ if (a === "" || a === "<p><br></p>" || a === "<p>&nbsp;</p>")
1336
+ return "";
1337
+ const c = a.replace(/<br\s*\/?>/gi, "").replace(/&nbsp;/gi, "").replace(/<[^>]+>/g, "").trim();
1338
+ return c === "" && /<img\b[^>]*>/i.test(a) ? a : c === "" ? "" : a;
1339
+ }
1340
+ function Gr(n) {
1341
+ return n.replace(
1342
+ /<img(?![^>]*\sloading=)([^>]*)>/gi,
1343
+ '<img loading="lazy"$1>'
1344
+ );
1345
+ }
1346
+ function Wr(n) {
1347
+ if (!n || typeof n != "object") return;
1348
+ const a = n, c = (i) => {
1349
+ if (i && typeof i == "object" && "url" in i) {
1350
+ const s = i.url;
1351
+ return typeof s == "string" ? s : void 0;
1352
+ }
1353
+ };
1354
+ return typeof a.url == "string" ? a.url : c(a.file) ?? c(a.data) ?? Object.values(a).map(c).find(Boolean);
1355
+ }
1356
+ function Ur(n) {
1357
+ if (n) return n;
1358
+ if (typeof window > "u") return null;
1359
+ const a = window;
1360
+ return a.$R ?? a.Redactor ?? null;
1361
+ }
1362
+ const Xr = {
1363
+ bold: ["module.inline.format", { tag: "b" }],
1364
+ italic: ["module.inline.format", { tag: "i" }],
1365
+ strikethrough: ["module.inline.format", { tag: "del" }],
1366
+ bulletedList: ["module.list.toggle", "ul"],
1367
+ numberedList: ["module.list.toggle", "ol"],
1368
+ heading: ["module.block.format", { tag: "h2" }],
1369
+ quote: ["module.block.format", { tag: "blockquote" }],
1370
+ paragraph: ["module.block.format", { tag: "p" }]
1371
+ }, Qr = {
1372
+ zh: "zh_cn",
1373
+ pt: "pt_br"
1374
+ };
1375
+ function Yr(n) {
1376
+ const a = n.split("-")[0];
1377
+ return Qr[a] ?? a ?? "en";
1378
+ }
1379
+ const Zr = He(
1380
+ "redactor-theme-alfadocs ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]"
1381
+ ), Jr = He(
1382
+ [
1383
+ "ds:block ds:[inline-size:100%]",
1384
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
1385
+ "ds:bg-[var(--background)] ds:text-[var(--foreground)]",
1386
+ "ds:shadow-[var(--shadow-md)]",
1387
+ "ds:font-[family-name:var(--font-sans)] ds:text-[length:var(--font-size-base)]",
1388
+ "ds:p-[var(--spacing-md)] ds:[min-block-size:var(--rich-text-editor-min-block-size)]",
1389
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
1390
+ "ds:focus-visible:outline-solid",
1391
+ "ds:focus-visible:outline-[var(--ring)]",
1392
+ "ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
1393
+ "ds:forced-colors:focus-visible:outline-[CanvasText]"
1394
+ ].join(" ")
1395
+ ), Ye = [
1396
+ "ds:inline-flex ds:items-center ds:justify-center",
1397
+ "ds:[min-block-size:var(--min-target-size)] ds:[min-inline-size:var(--min-target-size)]",
1398
+ "ds:text-[color:var(--primary-foreground)]",
1399
+ "ds:transition-colors",
1400
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
1401
+ "ds:focus-visible:outline-solid",
1402
+ "ds:focus-visible:outline-[var(--primary-foreground)]",
1403
+ "ds:focus-visible:[outline-offset:calc(var(--focus-ring-width)*-1)]"
1404
+ ].join(" "), Ue = `${Ye} ds:hover:bg-[color-mix(in_srgb,var(--primary-foreground)_15%,transparent)]`, Kr = `${Ye} ds:bg-[var(--destructive)] ds:hover:bg-[color-mix(in_srgb,var(--destructive)_88%,var(--primary-foreground))]`, en = "ds:aria-pressed:!bg-[var(--destructive)] ds:aria-pressed:!text-[var(--destructive-foreground)]", tn = ht(
1405
+ ({
1406
+ id: n,
1407
+ defaultValue: a,
1408
+ value: c,
1409
+ onChange: i,
1410
+ toolbar: s = "standard",
1411
+ placeholder: h,
1412
+ readOnly: g = !1,
1413
+ ariaLabel: l,
1414
+ minHeight: p,
1415
+ showExtensions: y,
1416
+ className: T,
1417
+ redactor: $,
1418
+ options: E,
1419
+ plugins: k,
1420
+ lang: L,
1421
+ imageUploadUrl: u,
1422
+ onKeyDown: m,
1423
+ onRequestAiDraft: b,
1424
+ aiDraftFormat: A = "html",
1425
+ aiPrivacyNotice: M,
1426
+ onDictate: H
1427
+ }, Z) => {
1428
+ const { t: C, i18n: I } = X(), Q = ae(), ne = Fe(
1429
+ () => `rte-${Q.replace(/[^a-zA-Z0-9-_]/g, "")}`,
1430
+ [Q]
1431
+ ), N = `#${ne}`, V = D(null), B = D(null), ie = D(!1), me = D(g), x = D(null), O = D(null), [F, G] = _(!1), [Ze, Ce] = _(!1), [$e, Je] = _(
1432
+ () => /* @__PURE__ */ new Set()
1433
+ ), se = D(null), W = D(i), he = D(m);
1434
+ K(() => {
1435
+ W.current = i, he.current = m;
1436
+ }, [i, m]);
1437
+ const Ke = D(
1438
+ (() => {
1439
+ const t = c ?? a ?? "";
1440
+ return t ? te(t) : "";
1441
+ })()
1442
+ ), le = z(() => {
1443
+ var r;
1444
+ const t = B.current;
1445
+ if (t)
1446
+ try {
1447
+ const o = t(N, "source.getCode");
1448
+ if (typeof o == "string") return o;
1449
+ } catch {
1450
+ }
1451
+ return ((r = V.current) == null ? void 0 : r.value) ?? "";
1452
+ }, [N]), J = z(
1453
+ (t, ...r) => {
1454
+ const o = B.current;
1455
+ if (!o) return !1;
1456
+ const d = me.current;
1457
+ if (d)
1458
+ try {
1459
+ o(N, "disableReadOnly");
1460
+ } catch {
1461
+ }
1462
+ try {
1463
+ return o(N, t, ...r), !0;
1464
+ } catch {
1465
+ return !1;
1466
+ } finally {
1467
+ if (d)
1468
+ try {
1469
+ o(N, "enableReadOnly");
1470
+ } catch {
1471
+ }
1472
+ }
1473
+ },
1474
+ [N]
1475
+ ), oe = z(
1476
+ (t, r) => {
1477
+ var ce;
1478
+ const o = (r == null ? void 0 : r.asHtml) ?? !0, d = o ? te(t) : t;
1479
+ if (J(o ? "insertion.insertHtml" : "insertion.insertText", d)) return;
1480
+ const w = V.current;
1481
+ if (!w) return;
1482
+ const R = w.selectionStart ?? w.value.length, U = w.selectionEnd ?? w.value.length;
1483
+ w.value = w.value.slice(0, R) + d + w.value.slice(U);
1484
+ const ve = R + d.length;
1485
+ try {
1486
+ w.setSelectionRange(ve, ve);
1487
+ } catch {
1488
+ }
1489
+ (ce = W.current) == null || ce.call(W, { html: te(w.value), markdown: "" });
1490
+ },
1491
+ [J]
1492
+ ), Ne = D(null), ee = z(() => {
1493
+ var d;
1494
+ const t = (d = x.current) == null ? void 0 : d.querySelector(".redactor-in"), r = typeof window < "u" ? window.getSelection() : null, o = /* @__PURE__ */ new Set();
1495
+ if (t && r && r.anchorNode && t.contains(r.anchorNode) && typeof document.queryCommandState == "function") {
1496
+ r.rangeCount > 0 && (Ne.current = r.getRangeAt(0).cloneRange());
1497
+ try {
1498
+ document.queryCommandState("bold") && o.add("bold"), document.queryCommandState("italic") && o.add("italic"), document.queryCommandState("underline") && o.add("underline"), document.queryCommandState("strikeThrough") && o.add("strike"), document.queryCommandState("insertUnorderedList") && o.add("ul"), document.queryCommandState("insertOrderedList") && o.add("ol");
1499
+ const f = String(
1500
+ document.queryCommandValue("formatBlock") || ""
1501
+ ).toLowerCase();
1502
+ /^h[1-6]$/.test(f) ? (o.add("heading"), o.add(f)) : f === "blockquote" ? o.add("quote") : o.add("paragraph");
1503
+ const w = r.anchorNode.nodeType === Node.TEXT_NODE ? r.anchorNode.parentElement : r.anchorNode;
1504
+ w && t.contains(w) && w.closest("table") && o.add("table");
1505
+ } catch {
1506
+ }
1507
+ }
1508
+ Je(
1509
+ (f) => f.size === o.size && [...o].every((w) => f.has(w)) ? f : o
1510
+ );
1511
+ }, []), fe = z(
1512
+ (t, ...r) => {
1513
+ J(t, ...r), typeof window < "u" ? window.requestAnimationFrame(() => ee()) : ee();
1514
+ },
1515
+ [J, ee]
1516
+ ), ze = z(
1517
+ (t) => {
1518
+ oe(t, { asHtml: !0 }), typeof window < "u" && window.requestAnimationFrame(() => ee());
1519
+ },
1520
+ [oe, ee]
1521
+ ), et = z(() => {
1522
+ var r;
1523
+ if (typeof window < "u") {
1524
+ const o = (r = x.current) == null ? void 0 : r.querySelector(".redactor-in"), d = window.getSelection();
1525
+ o && d && d.rangeCount > 0 && d.anchorNode && o.contains(d.anchorNode) && (Ne.current = d.getRangeAt(0).cloneRange());
1526
+ }
1527
+ const t = B.current;
1528
+ if (t)
1529
+ try {
1530
+ t(N, "selection.save");
1531
+ } catch {
1532
+ }
1533
+ }, [N]), tt = z(() => {
1534
+ const t = B.current;
1535
+ if (!t) return;
1536
+ const r = Ne.current;
1537
+ try {
1538
+ t(N, "editor.focus");
1539
+ } catch {
1540
+ }
1541
+ if (r && typeof window < "u") {
1542
+ const o = window.getSelection();
1543
+ if (o)
1544
+ try {
1545
+ o.removeAllRanges(), o.addRange(r);
1546
+ return;
1547
+ } catch {
1548
+ }
1549
+ }
1550
+ try {
1551
+ t(N, "selection.restore");
1552
+ } catch {
1553
+ }
1554
+ }, [N]), rt = z(() => {
1555
+ var o;
1556
+ if (typeof window > "u") return "";
1557
+ const t = (o = x.current) == null ? void 0 : o.querySelector(".redactor-in"), r = window.getSelection();
1558
+ return !t || !r || !r.anchorNode || !t.contains(r.anchorNode) ? "" : r.toString();
1559
+ }, []), nt = z(() => {
1560
+ var f;
1561
+ if (typeof window > "u") return null;
1562
+ const t = (f = x.current) == null ? void 0 : f.querySelector(".redactor-in"), r = window.getSelection();
1563
+ if (!t || !r || r.rangeCount === 0) return null;
1564
+ const o = r.anchorNode, d = o && o.nodeType === Node.TEXT_NODE ? o.parentElement : o;
1565
+ return !d || !t.contains(d) ? null : d.closest("table");
1566
+ }, []), Le = D(null), ge = z(() => {
1567
+ var f;
1568
+ if (typeof window > "u") return null;
1569
+ const t = (f = x.current) == null ? void 0 : f.querySelector(".redactor-in"), r = window.getSelection();
1570
+ if (!t || !r || r.rangeCount === 0) return null;
1571
+ const o = r.anchorNode, d = o && o.nodeType === Node.TEXT_NODE ? o.parentElement : o;
1572
+ return !d || !t.contains(d) ? null : d.closest("td,th");
1573
+ }, []), ot = z(() => {
1574
+ Le.current = ge();
1575
+ }, [ge]), at = z(
1576
+ (t, r) => {
1577
+ var w;
1578
+ const o = Le.current ?? ge();
1579
+ if (!o) return;
1580
+ const d = t === "row" ? Array.from(((w = o.closest("tr")) == null ? void 0 : w.children) ?? [o]).filter(
1581
+ (R) => R instanceof HTMLElement && (R.tagName === "TD" || R.tagName === "TH")
1582
+ ) : [o], f = B.current;
1583
+ if (f)
1584
+ try {
1585
+ f(N, "module.buffer.trigger");
1586
+ } catch {
1587
+ }
1588
+ for (const R of d)
1589
+ r ? R.style.setProperty("background-color", r) : R.style.removeProperty("background-color");
1590
+ if (f)
1591
+ try {
1592
+ f(N, "broadcast", "hardsync");
1593
+ } catch {
1594
+ }
1595
+ typeof window < "u" && window.requestAnimationFrame(() => ee());
1596
+ },
1597
+ [ge, N, ee]
1598
+ ), it = z(
1599
+ (t) => {
1600
+ var o;
1601
+ const r = B.current;
1602
+ if (r && typeof window < "u") {
1603
+ const d = (o = x.current) == null ? void 0 : o.querySelector(".redactor-in"), f = window.getSelection(), w = f == null ? void 0 : f.anchorNode, R = w && w.nodeType === Node.TEXT_NODE ? w.parentElement : w, U = R && (d != null && d.contains(R)) ? R.closest("ul,ol") : null;
1604
+ if (U)
1605
+ try {
1606
+ r(N, "caret.setAfter", U);
1607
+ } catch {
1608
+ }
1609
+ }
1610
+ ze(t), typeof window < "u" && window.requestAnimationFrame(() => {
1611
+ var f;
1612
+ const d = (f = x.current) == null ? void 0 : f.querySelector(".redactor-in");
1613
+ d == null || d.querySelectorAll("table td, table th").forEach((w) => {
1614
+ let R = w.lastChild;
1615
+ for (; R && R.nodeType === Node.TEXT_NODE && !(R.textContent ?? "").trim(); ) {
1616
+ const U = R.previousSibling;
1617
+ w.removeChild(R), R = U;
1618
+ }
1619
+ });
1620
+ });
1621
+ },
1622
+ [ze, N]
1623
+ ), st = z(
1624
+ async (t, r) => {
1625
+ if (!u) throw new Error("No image upload URL configured.");
1626
+ const o = new FormData();
1627
+ o.append("file", t);
1628
+ const d = await fetch(u, {
1629
+ method: "POST",
1630
+ body: o,
1631
+ credentials: "same-origin",
1632
+ signal: r
1633
+ });
1634
+ if (!d.ok) throw new Error(`Image upload failed (${d.status}).`);
1635
+ const f = Wr(await d.json());
1636
+ if (!f) throw new Error("Image upload response contained no URL.");
1637
+ return f;
1638
+ },
1639
+ [u]
1640
+ ), de = D(null), pe = D(null), [Y, Oe] = _(!1), [lt, De] = _(!1), be = z(() => {
1641
+ const t = pe.current;
1642
+ t != null && t.parentNode && t.parentNode.removeChild(t), pe.current = null;
1643
+ }, []), je = z((t) => {
1644
+ var d;
1645
+ const r = (d = x.current) == null ? void 0 : d.querySelector(
1646
+ ".redactor-in"
1647
+ );
1648
+ if (!r) return;
1649
+ let o = pe.current;
1650
+ if (!o || !r.contains(o)) {
1651
+ o = document.createElement("span"), o.setAttribute("data-rte-interim", ""), o.setAttribute("contenteditable", "false");
1652
+ const f = window.getSelection();
1653
+ if (f && f.rangeCount > 0 && r.contains(f.anchorNode)) {
1654
+ const w = f.getRangeAt(0);
1655
+ w.collapse(!1), w.insertNode(o);
1656
+ } else
1657
+ r.appendChild(o);
1658
+ pe.current = o;
1659
+ }
1660
+ o.textContent = t;
1661
+ }, []), qe = z(() => {
1662
+ var t;
1663
+ (t = de.current) == null || t.abort();
1664
+ }, []), Pe = z(() => {
1665
+ if (!H) return;
1666
+ const t = new AbortController();
1667
+ de.current = t, De(!1), Oe(!0), be(), H({
1668
+ signal: t.signal,
1669
+ // Interim text shows live in the editor (grey + caret); each final
1670
+ // replaces it with committed text at the caret.
1671
+ onPartialTranscript: (r) => {
1672
+ t.signal.aborted || je(r);
1673
+ },
1674
+ onFinalTranscript: (r) => {
1675
+ if (t.signal.aborted) return;
1676
+ be();
1677
+ const o = r.trim();
1678
+ o && oe(`${o} `, { asHtml: !1 });
1679
+ }
1680
+ }).catch((r) => {
1681
+ t.signal.aborted || r && typeof r == "object" && "name" in r && r.name === "AbortError" || De(!0);
1682
+ }).finally(() => {
1683
+ be(), de.current === t && (de.current = null, Oe(!1));
1684
+ });
1685
+ }, [H, oe, be, je]), Be = z(() => {
1686
+ Y ? qe() : Pe();
1687
+ }, [Y, Pe, qe]);
1688
+ K(() => () => {
1689
+ var t;
1690
+ return (t = de.current) == null ? void 0 : t.abort();
1691
+ }, []), K(() => {
1692
+ const t = V.current;
1693
+ if (!t) return;
1694
+ t.value = Ke.current;
1695
+ const r = Ur($);
1696
+ if (!r) {
1697
+ G(!0);
1698
+ return;
1699
+ }
1700
+ B.current = r;
1701
+ const o = {
1702
+ lang: L ?? Yr(I.language || "en"),
1703
+ // The kit renders its OWN toolbar (EditorToolbar) and drives Redactor
1704
+ // via the command API, so Redactor's native toolbar is suppressed.
1705
+ toolbar: !1,
1706
+ plugins: k ?? [],
1707
+ placeholder: h ?? C("editor.placeholder"),
1708
+ toolbarFixed: !1,
1709
+ // Platform parity (RedactorWysiwyg.js:84): no inline shortcode expansion.
1710
+ shortcodes: !1,
1711
+ imageEditable: !1,
1712
+ imageResizable: !0
1713
+ }, d = u ? { imageUpload: u } : {}, f = (E == null ? void 0 : E.callbacks) ?? {}, w = {
1714
+ ...o,
1715
+ ...d,
1716
+ ...E ?? {},
1717
+ // Re-pin safety-critical keys LAST so consumer `options` can't override
1718
+ // the sanitising change handler, re-enable image editing, or turn off
1719
+ // drag-resize (platform re-pins both image flags — RedactorWysiwyg.js:115-116).
1720
+ imageEditable: !1,
1721
+ imageResizable: !0,
1722
+ callbacks: {
1723
+ ...f,
1724
+ changed(R) {
1725
+ const U = Re(Gr(R)), ve = te(U);
1726
+ ie.current = !0, W.current && (se.current && clearTimeout(se.current), se.current = setTimeout(() => {
1727
+ var ce;
1728
+ (ce = W.current) == null || ce.call(W, { html: ve, markdown: "" });
1729
+ }, 100));
1730
+ },
1731
+ keydown(R) {
1732
+ var U;
1733
+ (U = he.current) == null || U.call(he, R);
1734
+ },
1735
+ observe() {
1736
+ ee();
1737
+ }
1738
+ }
1739
+ };
1740
+ try {
1741
+ if (r(N, w), g)
1742
+ try {
1743
+ r(N, "enableReadOnly");
1744
+ } catch {
1745
+ }
1746
+ } catch {
1747
+ G(!0);
1748
+ }
1749
+ return () => {
1750
+ se.current && clearTimeout(se.current);
1751
+ try {
1752
+ r(N, "destroy");
1753
+ } catch {
1754
+ }
1755
+ B.current = null;
1756
+ };
1757
+ }, []), K(() => {
1758
+ if (!B.current || c === void 0) return;
1759
+ if (ie.current) {
1760
+ ie.current = !1;
1761
+ return;
1762
+ }
1763
+ const t = te(Re(c));
1764
+ Re(le()) !== t && J("source.setCode", t);
1765
+ }, [c, le, J]), K(() => {
1766
+ me.current = g;
1767
+ const t = B.current;
1768
+ if (t)
1769
+ try {
1770
+ t(N, g ? "enableReadOnly" : "disableReadOnly");
1771
+ } catch {
1772
+ }
1773
+ }, [g, N]), K(() => {
1774
+ if (!F || c === void 0) return;
1775
+ const t = V.current;
1776
+ if (!t) return;
1777
+ const r = te(c);
1778
+ t.value !== r && document.activeElement !== t && (t.value = r);
1779
+ }, [F, c]);
1780
+ const Te = Fe(
1781
+ () => ({
1782
+ getHTML() {
1783
+ return le();
1784
+ },
1785
+ getText() {
1786
+ return le().replace(/<[^>]*>/g, " ").replace(/&nbsp;/gi, " ").replace(/\s+/g, " ").trim();
1787
+ },
1788
+ getMarkdown() {
1789
+ return "";
1790
+ },
1791
+ setContent(t) {
1792
+ const r = te(t);
1793
+ J("source.setCode", r) || V.current && (V.current.value = r);
1794
+ },
1795
+ insertAtCursor: oe,
1796
+ applyFormat(t) {
1797
+ const r = Xr[t];
1798
+ r && fe(...r);
1799
+ },
1800
+ focus() {
1801
+ var r;
1802
+ const t = B.current;
1803
+ if (t)
1804
+ try {
1805
+ t(N, "editor.focus");
1806
+ return;
1807
+ } catch {
1808
+ }
1809
+ (r = V.current) == null || r.focus();
1810
+ },
1811
+ clear() {
1812
+ J("source.setCode", "") || V.current && (V.current.value = "");
1813
+ }
1814
+ }),
1815
+ [N, le, J, oe, fe]
1816
+ );
1817
+ ft(Z, () => Te, [Te]), bt(zr, Te, n);
1818
+ const dt = z(
1819
+ (t) => {
1820
+ var r;
1821
+ (r = W.current) == null || r.call(W, {
1822
+ html: te(t.target.value),
1823
+ markdown: ""
1824
+ });
1825
+ },
1826
+ []
1827
+ ), ct = l ?? C("editor.regionLabel"), ut = h ?? C("editor.placeholder");
1828
+ return /* @__PURE__ */ v(
1829
+ "div",
1830
+ {
1831
+ ref: x,
1832
+ className: [Zr(), T].filter(Boolean).join(" "),
1833
+ "data-component": "rich-text-editor",
1834
+ "data-component-id": n,
1835
+ "data-min-height": p,
1836
+ children: [
1837
+ !F && !g ? /* @__PURE__ */ e(
1838
+ Vr,
1839
+ {
1840
+ run: fe,
1841
+ active: $e,
1842
+ preset: s,
1843
+ insertHtml: ze,
1844
+ insertTable: it,
1845
+ saveSelection: et,
1846
+ restoreSelection: tt,
1847
+ getSelectedText: rt,
1848
+ uploadImage: u ? st : void 0,
1849
+ enableColor: (k == null ? void 0 : k.includes("fontcolor")) ?? !1,
1850
+ enableImage: !!u,
1851
+ enableTable: (k == null ? void 0 : k.includes("table")) ?? !1,
1852
+ showExtensions: y
1853
+ }
1854
+ ) : null,
1855
+ /* @__PURE__ */ v("div", { className: "ds:relative", ref: O, children: [
1856
+ /* @__PURE__ */ e(
1857
+ "textarea",
1858
+ {
1859
+ ref: V,
1860
+ id: ne,
1861
+ "aria-label": ct,
1862
+ "aria-multiline": "true",
1863
+ placeholder: ut,
1864
+ onChange: F ? dt : void 0,
1865
+ readOnly: F ? g : void 0,
1866
+ className: F ? Jr() : void 0
1867
+ }
1868
+ ),
1869
+ b && H ? /* @__PURE__ */ v("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:shadow-[var(--shadow-lg)]", children: [
1870
+ /* @__PURE__ */ e(
1871
+ "button",
1872
+ {
1873
+ type: "button",
1874
+ onClick: Be,
1875
+ "aria-pressed": Y,
1876
+ "aria-label": C(Y ? "editor.ai.dictateStop" : "editor.ai.dictateStart"),
1877
+ className: Y ? Kr : Ue,
1878
+ children: Y ? /* @__PURE__ */ e(
1879
+ _e,
1880
+ {
1881
+ "aria-hidden": "true",
1882
+ className: "ds:size-5 ds:fill-current"
1883
+ }
1884
+ ) : /* @__PURE__ */ e(Se, { "aria-hidden": "true", className: "ds:size-5" })
1885
+ }
1886
+ ),
1887
+ /* @__PURE__ */ e(
1888
+ "span",
1889
+ {
1890
+ "aria-hidden": "true",
1891
+ className: "ds:self-stretch ds:[inline-size:var(--border-width-sm)] ds:bg-[color-mix(in_srgb,var(--primary-foreground)_35%,transparent)]"
1892
+ }
1893
+ ),
1894
+ /* @__PURE__ */ e(
1895
+ "button",
1896
+ {
1897
+ type: "button",
1898
+ onClick: () => Ce(!0),
1899
+ "aria-label": C("editor.ai.helpMeWrite"),
1900
+ className: Ue,
1901
+ children: /* @__PURE__ */ e(Ee, { "aria-hidden": "true", className: "ds:size-5" })
1902
+ }
1903
+ )
1904
+ ] }) : H ? /* @__PURE__ */ e("div", { className: "ds:absolute ds:[inset-block-end:var(--spacing-md)] ds:[inset-inline-end:var(--spacing-md)] ds:z-10", children: /* @__PURE__ */ e(
1905
+ q,
1906
+ {
1907
+ size: "lg",
1908
+ intent: "primary",
1909
+ icon: Y ? /* @__PURE__ */ e(_e, { className: "ds:fill-current" }) : /* @__PURE__ */ e(Se, {}),
1910
+ "aria-pressed": Y,
1911
+ "aria-label": C(Y ? "editor.ai.dictateStop" : "editor.ai.dictateStart"),
1912
+ onClick: Be,
1913
+ className: Y ? `${en} ds:rounded-full ds:shadow-[var(--shadow-lg)]` : "ds:rounded-full ds:shadow-[var(--shadow-lg)]"
1914
+ }
1915
+ ) }) : b ? /* @__PURE__ */ e("div", { className: "ds:absolute ds:[inset-block-end:var(--spacing-md)] ds:[inset-inline-end:var(--spacing-md)] ds:z-10", children: /* @__PURE__ */ e(
1916
+ q,
1917
+ {
1918
+ size: "lg",
1919
+ intent: "primary",
1920
+ icon: /* @__PURE__ */ e(Ee, {}),
1921
+ "aria-label": C("editor.ai.helpMeWrite"),
1922
+ onClick: () => Ce(!0),
1923
+ className: "ds:rounded-full ds:shadow-[var(--shadow-lg)]"
1924
+ }
1925
+ ) }) : null,
1926
+ b ? /* @__PURE__ */ e(
1927
+ _r,
1928
+ {
1929
+ open: Ze,
1930
+ onClose: () => Ce(!1),
1931
+ onRequestAiDraft: b,
1932
+ onInsert: (t) => oe(t, { asHtml: A !== "text" }),
1933
+ previewAsHtml: A !== "text",
1934
+ privacyNotice: M,
1935
+ onDictate: H
1936
+ }
1937
+ ) : null,
1938
+ !F && !g && ((k == null ? void 0 : k.includes("table")) ?? !1) ? /* @__PURE__ */ e(
1939
+ Fr,
1940
+ {
1941
+ active: $e,
1942
+ run: fe,
1943
+ areaRef: O,
1944
+ getActiveTableEl: nt,
1945
+ enableColor: (k == null ? void 0 : k.includes("fontcolor")) ?? !1,
1946
+ saveTableCell: ot,
1947
+ applyTableBackground: at
1948
+ }
1949
+ ) : null
1950
+ ] }),
1951
+ H && lt ? /* @__PURE__ */ e(
1952
+ "p",
1953
+ {
1954
+ role: "alert",
1955
+ className: "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--destructive)]",
1956
+ children: C("editor.ai.dictationError")
1957
+ }
1958
+ ) : null
1959
+ ]
1960
+ }
1961
+ );
1962
+ }
1963
+ );
1964
+ tn.displayName = "RichTextEditor";
1965
+ export {
1966
+ tn as R,
1967
+ zr as r,
1968
+ Zr as w
1969
+ };
1970
+ //# sourceMappingURL=rich-text-editor-BOQr5lHx.js.map