@devalok/shilp-sutra 0.38.0 → 0.40.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 (361) hide show
  1. package/AGENTS.md +151 -0
  2. package/MIGRATION.md +255 -0
  3. package/README.md +3 -0
  4. package/dist/_chunks/badge-group.js +76 -75
  5. package/dist/_chunks/badge-group.js.map +1 -1
  6. package/dist/_chunks/chart-container.js +50 -0
  7. package/dist/_chunks/chart-container.js.map +1 -0
  8. package/dist/_chunks/chat.js +236 -228
  9. package/dist/_chunks/chat.js.map +1 -1
  10. package/dist/_chunks/colors.js +30 -0
  11. package/dist/_chunks/colors.js.map +1 -0
  12. package/dist/_chunks/document-preview.js +2 -2
  13. package/dist/_chunks/document-preview.js.map +1 -1
  14. package/dist/_chunks/emoji-data.js +45 -0
  15. package/dist/_chunks/emoji-data.js.map +1 -0
  16. package/dist/_chunks/grid-lines.js +72 -0
  17. package/dist/_chunks/grid-lines.js.map +1 -0
  18. package/dist/_chunks/image-preview.js +2 -2
  19. package/dist/_chunks/image-preview.js.map +1 -1
  20. package/dist/_chunks/mention-suggestion.js +35 -263
  21. package/dist/_chunks/mention-suggestion.js.map +1 -1
  22. package/dist/_chunks/normalize-icon.js +18 -0
  23. package/dist/_chunks/normalize-icon.js.map +1 -0
  24. package/dist/_chunks/oauth-button.js +227 -0
  25. package/dist/_chunks/oauth-button.js.map +1 -0
  26. package/dist/_chunks/popover.js +3 -3
  27. package/dist/_chunks/popover.js.map +1 -1
  28. package/dist/_chunks/primitives.js +107 -107
  29. package/dist/_chunks/primitives.js.map +1 -1
  30. package/dist/_chunks/shared.js +5 -5
  31. package/dist/_chunks/shared.js.map +1 -1
  32. package/dist/_chunks/{text.js → success.js} +26 -63
  33. package/dist/_chunks/success.js.map +1 -0
  34. package/dist/_chunks/tiptap.js +1952 -1949
  35. package/dist/_chunks/tiptap.js.map +1 -1
  36. package/dist/_chunks/tooltip.js +58 -0
  37. package/dist/_chunks/tooltip.js.map +1 -0
  38. package/dist/_chunks/tree-view.js +101 -96
  39. package/dist/_chunks/tree-view.js.map +1 -1
  40. package/dist/_chunks/use-calendar.js +5 -5
  41. package/dist/_chunks/use-calendar.js.map +1 -1
  42. package/dist/ai/ai-command-provider.d.ts +3 -2
  43. package/dist/ai/ai-command-provider.d.ts.map +1 -1
  44. package/dist/ai/ai-command-provider.js.map +1 -1
  45. package/dist/ai/block-renderer.js +11 -9
  46. package/dist/ai/block-renderer.js.map +1 -1
  47. package/dist/ai/blocks/error.js +31 -0
  48. package/dist/ai/blocks/error.js.map +1 -0
  49. package/dist/ai/blocks/index.d.ts +0 -2
  50. package/dist/ai/blocks/index.d.ts.map +1 -1
  51. package/dist/ai/blocks/index.js +2 -2
  52. package/dist/ai/blocks/text.js +19 -0
  53. package/dist/ai/blocks/text.js.map +1 -0
  54. package/dist/ai/command-bar.d.ts.map +1 -1
  55. package/dist/ai/command-bar.js +198 -193
  56. package/dist/ai/command-bar.js.map +1 -1
  57. package/dist/ai/conversation.d.ts +2 -1
  58. package/dist/ai/conversation.d.ts.map +1 -1
  59. package/dist/ai/conversation.js +92 -87
  60. package/dist/ai/conversation.js.map +1 -1
  61. package/dist/ai/index.d.ts +0 -4
  62. package/dist/ai/index.d.ts.map +1 -1
  63. package/dist/ai/index.js +45 -46
  64. package/dist/ai/index.js.map +1 -1
  65. package/dist/composed/activity-feed.d.ts +2 -1
  66. package/dist/composed/activity-feed.d.ts.map +1 -1
  67. package/dist/composed/activity-feed.js +5 -5
  68. package/dist/composed/activity-feed.js.map +1 -1
  69. package/dist/composed/avatar-group.js +4 -4
  70. package/dist/composed/avatar-group.js.map +1 -1
  71. package/dist/composed/bulk-action-bar.d.ts +2 -2
  72. package/dist/composed/bulk-action-bar.d.ts.map +1 -1
  73. package/dist/composed/bulk-action-bar.js +12 -12
  74. package/dist/composed/bulk-action-bar.js.map +1 -1
  75. package/dist/composed/command-palette.d.ts +2 -1
  76. package/dist/composed/command-palette.d.ts.map +1 -1
  77. package/dist/composed/command-palette.js +106 -101
  78. package/dist/composed/command-palette.js.map +1 -1
  79. package/dist/composed/content-card.js +1 -1
  80. package/dist/composed/content-card.js.map +1 -1
  81. package/dist/composed/date-picker/index.js +747 -3
  82. package/dist/composed/date-picker/index.js.map +1 -0
  83. package/dist/composed/emoji-picker.js +4 -4
  84. package/dist/composed/emoji-picker.js.map +1 -1
  85. package/dist/composed/empty-state.d.ts +3 -3
  86. package/dist/composed/empty-state.d.ts.map +1 -1
  87. package/dist/composed/empty-state.js +40 -31
  88. package/dist/composed/empty-state.js.map +1 -1
  89. package/dist/composed/error-boundary.js +3 -3
  90. package/dist/composed/error-boundary.js.map +1 -1
  91. package/dist/composed/extensions/emoji-node.js +81 -0
  92. package/dist/composed/extensions/emoji-node.js.map +1 -0
  93. package/dist/composed/extensions/emoji-suggestion.js +117 -0
  94. package/dist/composed/extensions/emoji-suggestion.js.map +1 -0
  95. package/dist/composed/file-preview.js +498 -2
  96. package/dist/composed/file-preview.js.map +1 -0
  97. package/dist/composed/filter-bar.js +1 -1
  98. package/dist/composed/filter-bar.js.map +1 -1
  99. package/dist/composed/index.d.ts +0 -15
  100. package/dist/composed/index.d.ts.map +1 -1
  101. package/dist/composed/index.js +16 -24
  102. package/dist/composed/inline-edit.js +1 -1
  103. package/dist/composed/inline-edit.js.map +1 -1
  104. package/dist/composed/loading-skeleton.js +9 -9
  105. package/dist/composed/loading-skeleton.js.map +1 -1
  106. package/dist/composed/markdown-viewer.js +3 -3
  107. package/dist/composed/markdown-viewer.js.map +1 -1
  108. package/dist/composed/multi-select-popover.js +1 -1
  109. package/dist/composed/multi-select-popover.js.map +1 -1
  110. package/dist/composed/page-header.js +1 -1
  111. package/dist/composed/page-header.js.map +1 -1
  112. package/dist/composed/page-skeletons.js +15 -15
  113. package/dist/composed/page-skeletons.js.map +1 -1
  114. package/dist/composed/priority-indicator.js +3 -3
  115. package/dist/composed/priority-indicator.js.map +1 -1
  116. package/dist/composed/rich-chat-input.js +2073 -2
  117. package/dist/composed/rich-chat-input.js.map +1 -0
  118. package/dist/composed/rich-text-editor.js +75 -72
  119. package/dist/composed/rich-text-editor.js.map +1 -1
  120. package/dist/composed/schedule-view.js +3 -3
  121. package/dist/composed/schedule-view.js.map +1 -1
  122. package/dist/composed/status-badge.d.ts +3 -2
  123. package/dist/composed/status-badge.d.ts.map +1 -1
  124. package/dist/composed/status-badge.js +58 -53
  125. package/dist/composed/status-badge.js.map +1 -1
  126. package/dist/shell/app-command-palette.d.ts +2 -1
  127. package/dist/shell/app-command-palette.d.ts.map +1 -1
  128. package/dist/shell/app-command-palette.js.map +1 -1
  129. package/dist/shell/bottom-navbar.d.ts +3 -1
  130. package/dist/shell/bottom-navbar.d.ts.map +1 -1
  131. package/dist/shell/bottom-navbar.js +94 -86
  132. package/dist/shell/bottom-navbar.js.map +1 -1
  133. package/dist/shell/command-registry.d.ts +2 -1
  134. package/dist/shell/command-registry.d.ts.map +1 -1
  135. package/dist/shell/command-registry.js.map +1 -1
  136. package/dist/shell/notification-center.js +8 -8
  137. package/dist/shell/notification-center.js.map +1 -1
  138. package/dist/shell/notification-preferences.js +1 -1
  139. package/dist/shell/notification-preferences.js.map +1 -1
  140. package/dist/shell/sidebar.d.ts +7 -4
  141. package/dist/shell/sidebar.d.ts.map +1 -1
  142. package/dist/shell/sidebar.js +148 -134
  143. package/dist/shell/sidebar.js.map +1 -1
  144. package/dist/shell/top-bar.d.ts +4 -3
  145. package/dist/shell/top-bar.d.ts.map +1 -1
  146. package/dist/shell/top-bar.js +116 -108
  147. package/dist/shell/top-bar.js.map +1 -1
  148. package/dist/tokens/semantic.css +82 -9
  149. package/dist/ui/accordion.js +1 -1
  150. package/dist/ui/accordion.js.map +1 -1
  151. package/dist/ui/alert-dialog.js +3 -3
  152. package/dist/ui/alert-dialog.js.map +1 -1
  153. package/dist/ui/alert.js +2 -2
  154. package/dist/ui/alert.js.map +1 -1
  155. package/dist/ui/autocomplete.js +2 -2
  156. package/dist/ui/autocomplete.js.map +1 -1
  157. package/dist/ui/avatar.js +11 -11
  158. package/dist/ui/avatar.js.map +1 -1
  159. package/dist/ui/badge-indicator.js +1 -1
  160. package/dist/ui/badge-indicator.js.map +1 -1
  161. package/dist/ui/badge.d.ts +3 -2
  162. package/dist/ui/badge.d.ts.map +1 -1
  163. package/dist/ui/banner.js +1 -1
  164. package/dist/ui/banner.js.map +1 -1
  165. package/dist/ui/breadcrumb.js +1 -1
  166. package/dist/ui/breadcrumb.js.map +1 -1
  167. package/dist/ui/button.d.ts +5 -4
  168. package/dist/ui/button.d.ts.map +1 -1
  169. package/dist/ui/button.js +66 -65
  170. package/dist/ui/button.js.map +1 -1
  171. package/dist/ui/card.js +5 -5
  172. package/dist/ui/card.js.map +1 -1
  173. package/dist/ui/charts/area-chart.js +177 -0
  174. package/dist/ui/charts/area-chart.js.map +1 -0
  175. package/dist/ui/charts/bar-chart.js +127 -0
  176. package/dist/ui/charts/bar-chart.js.map +1 -0
  177. package/dist/ui/charts/chart-container.js +3 -0
  178. package/dist/ui/charts/gauge-chart.js +72 -0
  179. package/dist/ui/charts/gauge-chart.js.map +1 -0
  180. package/dist/ui/charts/index.js +10 -1035
  181. package/dist/ui/charts/line-chart.js +135 -0
  182. package/dist/ui/charts/line-chart.js.map +1 -0
  183. package/dist/ui/charts/pie-chart.js +111 -0
  184. package/dist/ui/charts/pie-chart.js.map +1 -0
  185. package/dist/ui/charts/radar-chart.js +170 -0
  186. package/dist/ui/charts/radar-chart.js.map +1 -0
  187. package/dist/ui/charts/sparkline.js +119 -0
  188. package/dist/ui/charts/sparkline.js.map +1 -0
  189. package/dist/ui/chat/message.d.ts +3 -3
  190. package/dist/ui/chat/message.d.ts.map +1 -1
  191. package/dist/ui/chat/system-message.d.ts +2 -1
  192. package/dist/ui/chat/system-message.d.ts.map +1 -1
  193. package/dist/ui/checkbox.js +1 -1
  194. package/dist/ui/checkbox.js.map +1 -1
  195. package/dist/ui/code.js +2 -2
  196. package/dist/ui/code.js.map +1 -1
  197. package/dist/ui/color-input.js +10 -10
  198. package/dist/ui/color-input.js.map +1 -1
  199. package/dist/ui/color-swatch.js +3 -3
  200. package/dist/ui/color-swatch.js.map +1 -1
  201. package/dist/ui/combobox.d.ts +2 -1
  202. package/dist/ui/combobox.d.ts.map +1 -1
  203. package/dist/ui/combobox.js +100 -95
  204. package/dist/ui/combobox.js.map +1 -1
  205. package/dist/ui/container.d.ts +6 -1
  206. package/dist/ui/container.d.ts.map +1 -1
  207. package/dist/ui/container.js +2 -1
  208. package/dist/ui/container.js.map +1 -1
  209. package/dist/ui/context-menu.js +6 -6
  210. package/dist/ui/context-menu.js.map +1 -1
  211. package/dist/ui/data-table-body.js +1 -1
  212. package/dist/ui/data-table-body.js.map +1 -1
  213. package/dist/ui/data-table-bulk-actions.js +2 -2
  214. package/dist/ui/data-table-bulk-actions.js.map +1 -1
  215. package/dist/ui/data-table-card.js +2 -2
  216. package/dist/ui/data-table-card.js.map +1 -1
  217. package/dist/ui/data-table-header.js +2 -2
  218. package/dist/ui/data-table-header.js.map +1 -1
  219. package/dist/ui/data-table-pagination.js +3 -3
  220. package/dist/ui/data-table-pagination.js.map +1 -1
  221. package/dist/ui/data-table-toolbar.js +1 -1
  222. package/dist/ui/data-table-toolbar.js.map +1 -1
  223. package/dist/ui/data-table.js +1 -1
  224. package/dist/ui/data-table.js.map +1 -1
  225. package/dist/ui/devalok-grain.d.ts +1 -1
  226. package/dist/ui/devalok-grain.js.map +1 -1
  227. package/dist/ui/dialog.js +2 -2
  228. package/dist/ui/dialog.js.map +1 -1
  229. package/dist/ui/dropdown-menu.js +6 -6
  230. package/dist/ui/dropdown-menu.js.map +1 -1
  231. package/dist/ui/file-upload.js +4 -4
  232. package/dist/ui/file-upload.js.map +1 -1
  233. package/dist/ui/hover-card.js +1 -1
  234. package/dist/ui/hover-card.js.map +1 -1
  235. package/dist/ui/icon-button.d.ts +9 -2
  236. package/dist/ui/icon-button.d.ts.map +1 -1
  237. package/dist/ui/icon-button.js +14 -13
  238. package/dist/ui/icon-button.js.map +1 -1
  239. package/dist/ui/index.d.ts +1 -3
  240. package/dist/ui/index.d.ts.map +1 -1
  241. package/dist/ui/index.js +31 -33
  242. package/dist/ui/index.js.map +1 -1
  243. package/dist/ui/input-otp.js +1 -1
  244. package/dist/ui/input-otp.js.map +1 -1
  245. package/dist/ui/input.js +2 -2
  246. package/dist/ui/input.js.map +1 -1
  247. package/dist/ui/lib/icon-input.d.ts +42 -0
  248. package/dist/ui/lib/icon-input.d.ts.map +1 -0
  249. package/dist/ui/lib/normalize-icon.d.ts +39 -0
  250. package/dist/ui/lib/normalize-icon.d.ts.map +1 -0
  251. package/dist/ui/link.js +1 -1
  252. package/dist/ui/link.js.map +1 -1
  253. package/dist/ui/menubar.js +8 -8
  254. package/dist/ui/menubar.js.map +1 -1
  255. package/dist/ui/navigation-menu.js +3 -3
  256. package/dist/ui/navigation-menu.js.map +1 -1
  257. package/dist/ui/number-input.js +3 -3
  258. package/dist/ui/number-input.js.map +1 -1
  259. package/dist/ui/oauth-button/index.d.ts +3 -0
  260. package/dist/ui/oauth-button/index.d.ts.map +1 -0
  261. package/dist/ui/oauth-button/index.js +3 -0
  262. package/dist/ui/oauth-button/oauth-button.d.ts +208 -0
  263. package/dist/ui/oauth-button/oauth-button.d.ts.map +1 -0
  264. package/dist/ui/pagination.js +1 -1
  265. package/dist/ui/pagination.js.map +1 -1
  266. package/dist/ui/progress.js +2 -2
  267. package/dist/ui/progress.js.map +1 -1
  268. package/dist/ui/radio.js +1 -1
  269. package/dist/ui/radio.js.map +1 -1
  270. package/dist/ui/segmented-control.d.ts +3 -4
  271. package/dist/ui/segmented-control.d.ts.map +1 -1
  272. package/dist/ui/segmented-control.js +53 -45
  273. package/dist/ui/segmented-control.js.map +1 -1
  274. package/dist/ui/select.js +3 -3
  275. package/dist/ui/select.js.map +1 -1
  276. package/dist/ui/sheet.js +2 -2
  277. package/dist/ui/sheet.js.map +1 -1
  278. package/dist/ui/sidebar.js +11 -11
  279. package/dist/ui/sidebar.js.map +1 -1
  280. package/dist/ui/skeleton.js +9 -9
  281. package/dist/ui/skeleton.js.map +1 -1
  282. package/dist/ui/slider.js +2 -2
  283. package/dist/ui/slider.js.map +1 -1
  284. package/dist/ui/split-button.js +7 -7
  285. package/dist/ui/split-button.js.map +1 -1
  286. package/dist/ui/stack.d.ts +6 -1
  287. package/dist/ui/stack.d.ts.map +1 -1
  288. package/dist/ui/stack.js +2 -1
  289. package/dist/ui/stack.js.map +1 -1
  290. package/dist/ui/stat-card.d.ts +2 -3
  291. package/dist/ui/stat-card.d.ts.map +1 -1
  292. package/dist/ui/stat-card.js +118 -116
  293. package/dist/ui/stat-card.js.map +1 -1
  294. package/dist/ui/status-dot.js +2 -2
  295. package/dist/ui/status-dot.js.map +1 -1
  296. package/dist/ui/stepper.d.ts +2 -1
  297. package/dist/ui/stepper.d.ts.map +1 -1
  298. package/dist/ui/stepper.js +74 -69
  299. package/dist/ui/stepper.js.map +1 -1
  300. package/dist/ui/switch.js +2 -2
  301. package/dist/ui/switch.js.map +1 -1
  302. package/dist/ui/tabs.js +3 -3
  303. package/dist/ui/tabs.js.map +1 -1
  304. package/dist/ui/text.d.ts +7 -2
  305. package/dist/ui/text.d.ts.map +1 -1
  306. package/dist/ui/text.js +2 -1
  307. package/dist/ui/text.js.map +1 -1
  308. package/dist/ui/textarea.js +1 -1
  309. package/dist/ui/textarea.js.map +1 -1
  310. package/dist/ui/toast.js +8 -8
  311. package/dist/ui/toast.js.map +1 -1
  312. package/dist/ui/toaster.d.ts +11 -2
  313. package/dist/ui/toaster.d.ts.map +1 -1
  314. package/dist/ui/toaster.js.map +1 -1
  315. package/dist/ui/toggle.js +1 -1
  316. package/dist/ui/toggle.js.map +1 -1
  317. package/dist/ui/tooltip.js +12 -12
  318. package/dist/ui/tooltip.js.map +1 -1
  319. package/dist/ui/tree-view/tree-item.d.ts +3 -2
  320. package/dist/ui/tree-view/tree-item.d.ts.map +1 -1
  321. package/dist/ui/tree-view/use-tree.d.ts +2 -1
  322. package/dist/ui/tree-view/use-tree.d.ts.map +1 -1
  323. package/docs/components/_header.md +90 -1
  324. package/docs/components/ui/oauth-button.md +86 -0
  325. package/docs/recipes/customize-brand.md +100 -4
  326. package/docs/recipes/index.md +5 -1
  327. package/docs/recipes/install-astro.md +15 -0
  328. package/docs/recipes/install-next-app-router.md +21 -5
  329. package/docs/recipes/install-next-pages.md +2 -0
  330. package/docs/recipes/install-remix.md +15 -0
  331. package/docs/recipes/install-tanstack-start.md +15 -0
  332. package/docs/recipes/install-vite.md +15 -0
  333. package/docs/recipes/troubleshoot.md +22 -0
  334. package/llms-full.txt +177 -2
  335. package/llms-quick.txt +247 -0
  336. package/llms.txt +116 -3
  337. package/package.json +80 -2
  338. package/scripts/welcome.mjs +219 -0
  339. package/skill/README.md +99 -0
  340. package/skill/SKILL.md +163 -0
  341. package/skill/install.sh +59 -0
  342. package/skill/references/components-full.md +7083 -0
  343. package/skill/references/components.md +778 -0
  344. package/skill/references/customize-brand.md +314 -0
  345. package/skill/references/server-components.md +211 -0
  346. package/skill/references/setup-astro.md +195 -0
  347. package/skill/references/setup-next-app-router.md +248 -0
  348. package/skill/references/setup-next-pages.md +127 -0
  349. package/skill/references/setup-remix.md +188 -0
  350. package/skill/references/setup-tanstack-start.md +160 -0
  351. package/skill/references/setup-vite.md +187 -0
  352. package/skill/references/troubleshoot.md +241 -0
  353. package/dist/_chunks/date-picker.js +0 -748
  354. package/dist/_chunks/date-picker.js.map +0 -1
  355. package/dist/_chunks/file-preview.js +0 -499
  356. package/dist/_chunks/file-preview.js.map +0 -1
  357. package/dist/_chunks/rich-chat-input.js +0 -2071
  358. package/dist/_chunks/rich-chat-input.js.map +0 -1
  359. package/dist/_chunks/text.js.map +0 -1
  360. package/dist/ui/charts/index.js.map +0 -1
  361. /package/{LICENSE → skill/LICENSE} +0 -0
@@ -1,2071 +0,0 @@
1
- "use client";
2
- import { ln as e, mn as t, pn as n, un as r } from "./primitives.js";
3
- import { durations as i } from "../ui/lib/motion.js";
4
- import { cn as a } from "../ui/lib/utils.js";
5
- import { Spinner as o } from "../ui/spinner.js";
6
- import { Icon as s } from "../ui/icon.js";
7
- import { useIsMobile as c } from "../hooks/use-mobile.js";
8
- import { Button as l } from "../ui/button.js";
9
- import { Dialog as u, DialogContent as d, DialogFooter as f, DialogHeader as p, DialogTitle as m } from "../ui/dialog.js";
10
- import { SplitButton as h } from "../ui/split-button.js";
11
- import { emojiDataLoaders as g } from "../composed/emoji-picker.js";
12
- import { n as _, t as v } from "./use-calendar.js";
13
- import { a as y, c as b, d as x, g as S, h as C, i as w, l as ee, m as te, n as ne, o as re, s as ie, u as ae, y as oe } from "./tiptap.js";
14
- import { a as se, i as ce, n as le, o as ue, r as de, t as fe } from "./mention-suggestion.js";
15
- import { useColorMode as pe } from "../hooks/use-color-mode.js";
16
- import * as T from "react";
17
- import { useCallback as E, useEffect as me, useRef as D, useState as O } from "react";
18
- import { Fragment as he, jsx as k, jsxs as A } from "react/jsx-runtime";
19
- import * as ge from "react-dom";
20
- import { IconAt as _e, IconBlockquote as ve, IconBold as j, IconCalendarEvent as ye, IconChevronDown as be, IconClock as xe, IconCode as Se, IconFile as Ce, IconHighlight as we, IconItalic as Te, IconLink as M, IconList as Ee, IconListNumbers as N, IconMicrophone as De, IconMoodSmile as Oe, IconPencil as ke, IconPlayerPause as Ae, IconPlayerPlay as je, IconPlus as Me, IconSend as Ne, IconSlash as P, IconSquare as Pe, IconStrikethrough as F, IconTextSize as Fe, IconTrash as Ie, IconUnderline as I, IconX as L } from "@tabler/icons-react";
21
- import { AnimatePresence as R, motion as z, useReducedMotion as Le } from "framer-motion";
22
- import { createRoot as Re } from "react-dom/client";
23
- //#region src/composed/extensions/slash-command.tsx
24
- var B = T.forwardRef(({ groups: e, query: t, command: n }, r) => {
25
- let [i, o] = T.useState(0), s = T.useMemo(() => {
26
- let n = t.toLowerCase(), r = [];
27
- return e.forEach((e, t) => {
28
- e.commands.forEach((e) => {
29
- (!n || e.label.toLowerCase().includes(n) || e.description?.toLowerCase().includes(n)) && r.push({
30
- command: e,
31
- groupIndex: t
32
- });
33
- });
34
- }), r;
35
- }, [e, t]);
36
- if (T.useEffect(() => o(0), [s]), T.useImperativeHandle(r, () => ({ onKeyDown: ({ event: e }) => e.key === "ArrowUp" ? (o((e) => (e + s.length - 1) % s.length), !0) : e.key === "ArrowDown" ? (o((e) => (e + 1) % s.length), !0) : e.key === "Enter" ? (s[i] && n(s[i].command), !0) : !1 })), !s.length) return null;
37
- let c = [], l = 0;
38
- for (let t of s) {
39
- let n = e[t.groupIndex].label, r = c[c.length - 1];
40
- (!r || r.label !== n) && (r = {
41
- label: n,
42
- items: []
43
- }, c.push(r)), r.items.push({
44
- command: t.command,
45
- flatIndex: l
46
- }), l++;
47
- }
48
- return /* @__PURE__ */ k("div", {
49
- role: "listbox",
50
- "aria-label": "Slash commands",
51
- className: "z-popover max-h-[320px] min-w-[220px] overflow-x-hidden overflow-y-auto rounded-ds-lg border border-surface-border-strong bg-surface-overlay p-ds-02 shadow-floating",
52
- children: c.map((e, t) => /* @__PURE__ */ A("div", {
53
- role: "group",
54
- "aria-label": e.label,
55
- children: [
56
- t > 0 && /* @__PURE__ */ k("div", { className: "my-ds-01 border-t border-surface-border" }),
57
- /* @__PURE__ */ k("div", {
58
- className: "px-ds-03 py-ds-01 text-ds-xs font-medium text-surface-fg-subtle",
59
- children: e.label
60
- }),
61
- e.items.map(({ command: e, flatIndex: t }) => {
62
- let r = e.icon;
63
- return /* @__PURE__ */ A("button", {
64
- type: "button",
65
- role: "option",
66
- "aria-selected": t === i,
67
- onClick: () => n(e),
68
- className: a("flex w-full items-center gap-ds-03 rounded-ds-md px-ds-03 py-ds-02 text-left cursor-pointer", t === i ? "bg-surface-raised-hover" : "hover:bg-surface-raised-hover"),
69
- children: [r && /* @__PURE__ */ k("span", {
70
- className: "flex h-4 w-4 shrink-0 items-center justify-center text-surface-fg-muted",
71
- children: /* @__PURE__ */ k(r, { className: "h-4 w-4" })
72
- }), /* @__PURE__ */ A("div", {
73
- className: "flex flex-col",
74
- children: [/* @__PURE__ */ k("span", {
75
- className: "text-ds-sm text-surface-fg",
76
- children: e.label
77
- }), e.description && /* @__PURE__ */ k("span", {
78
- className: "text-ds-xs text-surface-fg-subtle",
79
- children: e.description
80
- })]
81
- })]
82
- }, e.id);
83
- })
84
- ]
85
- }, e.label))
86
- });
87
- });
88
- B.displayName = "SlashCommandList";
89
- function ze(e) {
90
- return () => {
91
- let t = null, n = null, r = null;
92
- return {
93
- onStart: (i) => {
94
- n = document.createElement("div"), n.style.position = "absolute", n.style.zIndex = "1400";
95
- let a = i.clientRect?.();
96
- a && (n.style.left = `${a.left}px`, n.style.top = `${a.bottom + 4}px`), document.body.appendChild(n), t = Re(n), t.render(/* @__PURE__ */ k(B, {
97
- ref: (e) => {
98
- r = e;
99
- },
100
- groups: e,
101
- query: i.query,
102
- command: (e) => i.command(e)
103
- }));
104
- },
105
- onUpdate: (i) => {
106
- if (!t || !n) return;
107
- let a = i.clientRect?.();
108
- a && (n.style.left = `${a.left}px`, n.style.top = `${a.bottom + 4}px`), t.render(/* @__PURE__ */ k(B, {
109
- ref: (e) => {
110
- r = e;
111
- },
112
- groups: e,
113
- query: i.query,
114
- command: (e) => i.command(e)
115
- }));
116
- },
117
- onKeyDown: (e) => e.event.key === "Escape" ? (n && (t?.unmount(), n.remove(), n = null, t = null), !0) : r?.onKeyDown(e) ?? !1,
118
- onExit: () => {
119
- n && (t?.unmount(), n.remove(), n = null, t = null);
120
- }
121
- };
122
- };
123
- }
124
- function Be(e) {
125
- let t = e.flatMap((e) => e.commands);
126
- return S.create({
127
- name: "slashCommand",
128
- addProseMirrorPlugins() {
129
- return [ae({
130
- pluginKey: new oe("slashCommand"),
131
- editor: this.editor,
132
- char: "/",
133
- startOfLine: !0,
134
- allowSpaces: !1,
135
- items: ({ query: e }) => {
136
- if (!e) return t.slice(0, 8);
137
- let n = e.toLowerCase();
138
- return t.filter((e) => e.label.toLowerCase().includes(n) || e.description?.toLowerCase().includes(n)).slice(0, 8);
139
- },
140
- command: ({ editor: e, range: t, props: n }) => {
141
- e.chain().focus().deleteRange(t).run(), n.action(e);
142
- },
143
- render: ze(e)
144
- })];
145
- }
146
- });
147
- }
148
- //#endregion
149
- //#region src/composed/rich-chat-input/attachment-strip.tsx
150
- function Ve(e) {
151
- return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`;
152
- }
153
- function He({ attachments: e, onRemoveAttachment: t }) {
154
- return /* @__PURE__ */ k(z.div, {
155
- initial: {
156
- height: 0,
157
- opacity: 0
158
- },
159
- animate: {
160
- height: "auto",
161
- opacity: 1
162
- },
163
- exit: {
164
- height: 0,
165
- opacity: 0
166
- },
167
- transition: {
168
- duration: i.moderate02,
169
- ease: [
170
- .2,
171
- 0,
172
- .38,
173
- .9
174
- ]
175
- },
176
- className: "overflow-hidden",
177
- children: /* @__PURE__ */ k("div", {
178
- role: "list",
179
- "aria-label": "Attachments",
180
- className: "flex gap-ds-02 overflow-x-auto px-ds-04 py-ds-02b border-b border-surface-border",
181
- children: /* @__PURE__ */ k(R, {
182
- initial: !1,
183
- children: e.map((e) => e.type === "image" ? /* @__PURE__ */ A(z.div, {
184
- role: "listitem",
185
- "aria-label": `Image: ${e.name}`,
186
- layout: !0,
187
- initial: {
188
- scale: 0,
189
- opacity: 0
190
- },
191
- animate: {
192
- scale: 1,
193
- opacity: 1
194
- },
195
- exit: {
196
- scale: .95,
197
- opacity: 0
198
- },
199
- transition: {
200
- layout: {
201
- type: "spring",
202
- stiffness: 400,
203
- damping: 30
204
- },
205
- scale: {
206
- type: "spring",
207
- stiffness: 400,
208
- damping: 30
209
- },
210
- opacity: { duration: i.fast02 }
211
- },
212
- className: "relative h-12 w-12 shrink-0 group",
213
- children: [
214
- /* @__PURE__ */ k("img", {
215
- src: e.url,
216
- alt: e.name,
217
- className: "h-full w-full rounded-ds-md object-cover"
218
- }),
219
- /* @__PURE__ */ k("button", {
220
- onClick: () => t(e.id),
221
- className: "absolute -top-1 -right-1 h-ico-sm w-ico-sm rounded-full bg-error-9 text-error-fg flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-fast-02",
222
- "aria-label": `Remove ${e.name}`,
223
- title: "Remove",
224
- children: /* @__PURE__ */ k(s, {
225
- icon: L,
226
- size: "xs"
227
- })
228
- }),
229
- e.uploading && /* @__PURE__ */ k("div", {
230
- className: "absolute inset-0 rounded-ds-md bg-surface-overlay/50 flex items-center justify-center",
231
- children: /* @__PURE__ */ k(o, { size: "sm" })
232
- })
233
- ]
234
- }, e.id) : /* @__PURE__ */ A(z.div, {
235
- role: "listitem",
236
- "aria-label": `File: ${e.name}, ${Ve(e.size)}`,
237
- layout: !0,
238
- initial: {
239
- scale: 0,
240
- opacity: 0
241
- },
242
- animate: {
243
- scale: 1,
244
- opacity: 1
245
- },
246
- exit: {
247
- scale: .95,
248
- opacity: 0
249
- },
250
- transition: {
251
- layout: {
252
- type: "spring",
253
- stiffness: 400,
254
- damping: 30
255
- },
256
- scale: {
257
- type: "spring",
258
- stiffness: 400,
259
- damping: 30
260
- },
261
- opacity: { duration: i.fast02 }
262
- },
263
- className: "flex items-center gap-ds-02 shrink-0 rounded-ds-md bg-surface-raised px-ds-03 py-ds-01 group",
264
- children: [
265
- /* @__PURE__ */ k(s, {
266
- icon: Ce,
267
- size: "xs",
268
- className: "text-surface-fg-muted"
269
- }),
270
- /* @__PURE__ */ k("span", {
271
- className: "text-ds-xs text-surface-fg-muted truncate max-w-[120px]",
272
- children: e.name
273
- }),
274
- /* @__PURE__ */ k("span", {
275
- className: "text-ds-xs text-surface-fg-subtle",
276
- children: Ve(e.size)
277
- }),
278
- /* @__PURE__ */ k("button", {
279
- onClick: () => t(e.id),
280
- className: "text-surface-fg-subtle hover:text-error-11 opacity-0 group-hover:opacity-100 transition-opacity duration-fast-02",
281
- "aria-label": `Remove ${e.name}`,
282
- title: "Remove",
283
- children: /* @__PURE__ */ k(s, {
284
- icon: L,
285
- size: "xs"
286
- })
287
- })
288
- ]
289
- }, e.id))
290
- })
291
- })
292
- });
293
- }
294
- //#endregion
295
- //#region src/composed/rich-chat-input/audio-waveform.tsx
296
- var V = T.forwardRef(function({ mode: e, analyserNode: t, data: n, progress: r = 0, barWidth: i = 3, barGap: o = 2, barCount: s = 40, height: c = 32, className: l, ...u }, d) {
297
- let [f, p] = T.useState(() => Array(s).fill(.05)), m = T.useRef(0), h = T.useRef(f);
298
- T.useEffect(() => {
299
- if (e !== "live" || !t) return;
300
- let n = new Uint8Array(t.frequencyBinCount), r = () => {
301
- t.getByteFrequencyData(n);
302
- let e = Math.floor(n.length / s), i = Array(s);
303
- for (let t = 0; t < s; t++) {
304
- let r = 0;
305
- for (let i = 0; i < e; i++) r += n[t * e + i];
306
- let a = r / (e * 255);
307
- i[t] = h.current[t] + (a - h.current[t]) * .3;
308
- }
309
- h.current = i, p(i), m.current = requestAnimationFrame(r);
310
- };
311
- return m.current = requestAnimationFrame(r), () => cancelAnimationFrame(m.current);
312
- }, [
313
- e,
314
- t,
315
- s
316
- ]), T.useEffect(() => {
317
- if (!(e !== "static" || !n)) if (n.length === s) p(n);
318
- else {
319
- let e = Array(s), t = n.length / s;
320
- for (let r = 0; r < s; r++) {
321
- let i = Math.floor(r * t);
322
- e[r] = n[Math.min(i, n.length - 1)];
323
- }
324
- p(e);
325
- }
326
- }, [
327
- e,
328
- n,
329
- s
330
- ]);
331
- let g = s * (i + o) - o, _ = T.useMemo(() => f.map((t, n) => {
332
- let a = Math.max(2, t * c), l = n * (i + o), u = (c - a) / 2, d = e === "static" && r > 0 && n / s <= r;
333
- return /* @__PURE__ */ k("rect", {
334
- x: l,
335
- y: u,
336
- width: i,
337
- height: a,
338
- rx: i / 2,
339
- fill: d ? "var(--color-accent-9)" : "var(--color-surface-border)"
340
- }, n);
341
- }), [
342
- f,
343
- r,
344
- e,
345
- i,
346
- o,
347
- s,
348
- c
349
- ]);
350
- return /* @__PURE__ */ k("svg", {
351
- ref: d,
352
- height: c,
353
- viewBox: `0 0 ${g} ${c}`,
354
- preserveAspectRatio: "none",
355
- "aria-hidden": "true",
356
- className: a("shrink-0", l),
357
- ...u,
358
- children: _
359
- });
360
- });
361
- V.displayName = "AudioWaveform";
362
- //#endregion
363
- //#region src/composed/rich-chat-input/audio-player.tsx
364
- var Ue = [
365
- 1,
366
- 1.5,
367
- 2
368
- ];
369
- function We(e) {
370
- return `${Math.floor(e / 60)}:${Math.floor(e % 60).toString().padStart(2, "0")}`;
371
- }
372
- var Ge = T.forwardRef(function({ src: e, duration: t, waveformData: n, className: r, ...i }, o) {
373
- let s = T.useRef(null), c = T.useRef(null), [l, u] = T.useState(!1), [d, f] = T.useState(0), [p, m] = T.useState(0), [h, g] = T.useState(null), _ = T.useMemo(() => {
374
- if (typeof e == "string") return e;
375
- let t = URL.createObjectURL(e);
376
- return g(t), t;
377
- }, [e]);
378
- T.useEffect(() => () => {
379
- h && URL.revokeObjectURL(h);
380
- }, [h]), T.useEffect(() => {
381
- let e = s.current;
382
- if (!e) return;
383
- let t = () => f(e.currentTime), n = () => {
384
- u(!1), f(0);
385
- };
386
- return e.addEventListener("timeupdate", t), e.addEventListener("ended", n), () => {
387
- e.removeEventListener("timeupdate", t), e.removeEventListener("ended", n);
388
- };
389
- }, []);
390
- let v = T.useCallback(() => {
391
- let e = s.current;
392
- e && (l ? (e.pause(), u(!1)) : (e.play(), u(!0)));
393
- }, [l]), y = T.useCallback((e) => {
394
- (e.key === " " || e.key === "Enter") && (e.preventDefault(), v());
395
- }, [v]), b = T.useCallback((e) => {
396
- let n = s.current, r = c.current;
397
- if (!n || !r || t <= 0) return;
398
- let i = r.getBoundingClientRect(), a = e.clientX - i.left;
399
- n.currentTime = Math.max(0, Math.min(1, a / i.width)) * t, f(n.currentTime);
400
- }, [t]), x = T.useCallback(() => {
401
- let e = (p + 1) % Ue.length;
402
- m(e), s.current && (s.current.playbackRate = Ue[e]);
403
- }, [p]), S = t > 0 ? d / t : 0, C = Ue[p];
404
- return /* @__PURE__ */ A("div", {
405
- ref: o,
406
- role: "group",
407
- "aria-label": "Voice message player",
408
- className: a("flex items-center gap-ds-03", r),
409
- ...i,
410
- children: [
411
- /* @__PURE__ */ k("audio", {
412
- ref: s,
413
- src: _,
414
- preload: "metadata"
415
- }),
416
- /* @__PURE__ */ k("button", {
417
- type: "button",
418
- onClick: v,
419
- onKeyDown: y,
420
- "aria-label": l ? "Pause voice message" : "Play voice message",
421
- className: "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-ds-full bg-accent-9 text-accent-fg hover:bg-accent-10 active:scale-95 transition-colors duration-fast-01 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
422
- children: k(l ? Ae : je, {
423
- size: 16,
424
- stroke: 2,
425
- "aria-hidden": "true"
426
- })
427
- }),
428
- /* @__PURE__ */ k(V, {
429
- ref: c,
430
- mode: "static",
431
- data: n,
432
- progress: S,
433
- className: "cursor-pointer",
434
- onClick: b
435
- }),
436
- /* @__PURE__ */ A("span", {
437
- className: "text-ds-xs tabular-nums text-surface-fg-subtle whitespace-nowrap",
438
- children: [
439
- We(d),
440
- " / ",
441
- We(t)
442
- ]
443
- }),
444
- /* @__PURE__ */ A("button", {
445
- type: "button",
446
- onClick: x,
447
- "aria-label": `Playback speed ${C}x`,
448
- className: "shrink-0 text-ds-xs bg-surface-raised rounded-ds-full px-ds-02 py-[1px] hover:bg-surface-raised-hover tabular-nums transition-colors duration-fast-01 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2",
449
- children: [C, "x"]
450
- })
451
- ]
452
- });
453
- });
454
- Ge.displayName = "AudioPlayer";
455
- //#endregion
456
- //#region src/composed/rich-chat-input/chat-toolbar.tsx
457
- var Ke = T.createContext(null);
458
- function H() {
459
- let e = T.useContext(Ke);
460
- if (!e) throw Error("Toolbar primitives must be used inside <ChatToolbar>");
461
- return e;
462
- }
463
- function U({ onClick: e, isActive: t, disabled: n, title: r, children: i, className: o }) {
464
- let { disabled: s } = H();
465
- return /* @__PURE__ */ k("button", {
466
- type: "button",
467
- onClick: e,
468
- disabled: n ?? s,
469
- title: r,
470
- "aria-label": r,
471
- "aria-pressed": t,
472
- className: a("inline-flex h-ds-xs-plus items-center justify-center rounded-ds-md touch-target", !o?.includes("w-") && "w-ds-xs-plus", "transition-[color,background-color,transform] duration-fast-01 ease-productive-standard", "hover:bg-surface-raised-hover hover:text-surface-fg", "active:scale-95", "disabled:pointer-events-none disabled:opacity-action-disabled", t ? "bg-surface-raised-hover text-accent-11" : "text-surface-fg-subtle", o),
473
- children: i
474
- });
475
- }
476
- function W() {
477
- return /* @__PURE__ */ k("div", { className: "h-4 w-px bg-surface-border-subtle mx-ds-01" });
478
- }
479
- function G({ children: e, className: t }) {
480
- return /* @__PURE__ */ k("div", {
481
- className: a("flex items-center gap-ds-01", t),
482
- children: e
483
- });
484
- }
485
- function K() {
486
- let { editor: e } = H(), { isActive: t } = C({
487
- editor: e,
488
- selector: ({ editor: e }) => ({ isActive: e.isActive("bold") })
489
- });
490
- return /* @__PURE__ */ k(U, {
491
- onClick: () => e.chain().focus().toggleBold().run(),
492
- isActive: t,
493
- title: "Bold",
494
- children: /* @__PURE__ */ k(s, {
495
- icon: j,
496
- size: "xs"
497
- })
498
- });
499
- }
500
- function q() {
501
- let { editor: e } = H(), { isActive: t } = C({
502
- editor: e,
503
- selector: ({ editor: e }) => ({ isActive: e.isActive("italic") })
504
- });
505
- return /* @__PURE__ */ k(U, {
506
- onClick: () => e.chain().focus().toggleItalic().run(),
507
- isActive: t,
508
- title: "Italic",
509
- children: /* @__PURE__ */ k(s, {
510
- icon: Te,
511
- size: "xs"
512
- })
513
- });
514
- }
515
- function qe() {
516
- let { editor: e } = H(), { isActive: t } = C({
517
- editor: e,
518
- selector: ({ editor: e }) => ({ isActive: e.isActive("underline") })
519
- });
520
- return /* @__PURE__ */ k(U, {
521
- onClick: () => e.chain().focus().toggleUnderline().run(),
522
- isActive: t,
523
- title: "Underline",
524
- children: /* @__PURE__ */ k(s, {
525
- icon: I,
526
- size: "xs"
527
- })
528
- });
529
- }
530
- function Je() {
531
- let { editor: e } = H(), { isActive: t } = C({
532
- editor: e,
533
- selector: ({ editor: e }) => ({ isActive: e.isActive("strike") })
534
- });
535
- return /* @__PURE__ */ k(U, {
536
- onClick: () => e.chain().focus().toggleStrike().run(),
537
- isActive: t,
538
- title: "Strikethrough",
539
- children: /* @__PURE__ */ k(s, {
540
- icon: F,
541
- size: "xs"
542
- })
543
- });
544
- }
545
- function Ye() {
546
- let { editor: e } = H(), { isActive: t } = C({
547
- editor: e,
548
- selector: ({ editor: e }) => ({ isActive: e.isActive("highlight") })
549
- });
550
- return /* @__PURE__ */ k(U, {
551
- onClick: () => e.chain().focus().toggleHighlight().run(),
552
- isActive: t,
553
- title: "Highlight",
554
- children: /* @__PURE__ */ k(s, {
555
- icon: we,
556
- size: "xs"
557
- })
558
- });
559
- }
560
- function Xe() {
561
- let { editor: e } = H(), { isActive: t } = C({
562
- editor: e,
563
- selector: ({ editor: e }) => ({ isActive: e.isActive("code") })
564
- });
565
- return /* @__PURE__ */ k(U, {
566
- onClick: () => e.chain().focus().toggleCode().run(),
567
- isActive: t,
568
- title: "Inline code",
569
- children: /* @__PURE__ */ k(s, {
570
- icon: Se,
571
- size: "xs"
572
- })
573
- });
574
- }
575
- function Ze() {
576
- let { editor: e } = H(), { isActive: t } = C({
577
- editor: e,
578
- selector: ({ editor: e }) => ({ isActive: e.isActive("bulletList") })
579
- });
580
- return /* @__PURE__ */ k(U, {
581
- onClick: () => e.chain().focus().toggleBulletList().run(),
582
- isActive: t,
583
- title: "Bullet list",
584
- children: /* @__PURE__ */ k(s, {
585
- icon: Ee,
586
- size: "xs"
587
- })
588
- });
589
- }
590
- function Qe() {
591
- let { editor: e } = H(), { isActive: t } = C({
592
- editor: e,
593
- selector: ({ editor: e }) => ({ isActive: e.isActive("orderedList") })
594
- });
595
- return /* @__PURE__ */ k(U, {
596
- onClick: () => e.chain().focus().toggleOrderedList().run(),
597
- isActive: t,
598
- title: "Ordered list",
599
- children: /* @__PURE__ */ k(s, {
600
- icon: N,
601
- size: "xs"
602
- })
603
- });
604
- }
605
- function $e() {
606
- let { editor: e } = H(), { isActive: t } = C({
607
- editor: e,
608
- selector: ({ editor: e }) => ({ isActive: e.isActive("blockquote") })
609
- });
610
- return /* @__PURE__ */ k(U, {
611
- onClick: () => e.chain().focus().toggleBlockquote().run(),
612
- isActive: t,
613
- title: "Quote",
614
- children: /* @__PURE__ */ k(s, {
615
- icon: ve,
616
- size: "xs"
617
- })
618
- });
619
- }
620
- function et() {
621
- let { editor: e } = H(), { isActive: t } = C({
622
- editor: e,
623
- selector: ({ editor: e }) => ({ isActive: e.isActive("link") })
624
- });
625
- return /* @__PURE__ */ k(U, {
626
- onClick: () => {
627
- let t = window.prompt("URL");
628
- t && e.chain().focus().setLink({ href: t }).run();
629
- },
630
- isActive: t,
631
- title: "Link",
632
- children: /* @__PURE__ */ k(s, {
633
- icon: M,
634
- size: "xs"
635
- })
636
- });
637
- }
638
- function tt() {
639
- let { editor: e } = H();
640
- return /* @__PURE__ */ k(U, {
641
- onClick: () => e.chain().focus().insertContent("@").run(),
642
- title: "Mention",
643
- children: /* @__PURE__ */ k(s, {
644
- icon: _e,
645
- size: "xs"
646
- })
647
- });
648
- }
649
- function J() {
650
- let { editor: e } = H();
651
- return /* @__PURE__ */ k(U, {
652
- onClick: () => e.chain().focus().insertContent(":").run(),
653
- title: "Emoji",
654
- children: /* @__PURE__ */ k(s, {
655
- icon: Oe,
656
- size: "xs"
657
- })
658
- });
659
- }
660
- function nt() {
661
- let { editor: e } = H();
662
- return /* @__PURE__ */ k(U, {
663
- onClick: () => e.chain().focus().insertContent("/").run(),
664
- title: "Slash command",
665
- children: /* @__PURE__ */ k(s, {
666
- icon: P,
667
- size: "xs"
668
- })
669
- });
670
- }
671
- function Y({ items: e, isMobile: t, hasMentions: n, hasSlashCommands: r }) {
672
- let i = (t) => !e || e.includes(t);
673
- return /* @__PURE__ */ A(he, { children: [
674
- !t && /* @__PURE__ */ A(G, { children: [
675
- i("bold") && /* @__PURE__ */ k(K, {}),
676
- i("italic") && /* @__PURE__ */ k(q, {}),
677
- i("underline") && /* @__PURE__ */ k(qe, {}),
678
- i("strike") && /* @__PURE__ */ k(Je, {}),
679
- i("highlight") && /* @__PURE__ */ k(Ye, {})
680
- ] }),
681
- !t && /* @__PURE__ */ k(W, {}),
682
- !t && /* @__PURE__ */ A(G, { children: [i("bulletList") && /* @__PURE__ */ k(Ze, {}), i("orderedList") && /* @__PURE__ */ k(Qe, {})] }),
683
- !t && (i("blockquote") || i("link") || i("code")) && /* @__PURE__ */ k(W, {}),
684
- !t && /* @__PURE__ */ A(G, { children: [
685
- i("blockquote") && /* @__PURE__ */ k($e, {}),
686
- i("link") && /* @__PURE__ */ k(et, {}),
687
- i("code") && /* @__PURE__ */ k(Xe, {})
688
- ] }),
689
- !t && (n || r) && /* @__PURE__ */ k(W, {}),
690
- /* @__PURE__ */ A(G, { children: [
691
- n && i("mention") && /* @__PURE__ */ k(tt, {}),
692
- i("emoji") && /* @__PURE__ */ k(J, {}),
693
- r && i("slash") && /* @__PURE__ */ k(nt, {})
694
- ] })
695
- ] });
696
- }
697
- function rt({ editor: e, toolbar: t, isMobile: n, hasMentions: r, hasSlashCommands: i, disabled: a }) {
698
- if (t === !1) return null;
699
- let o = typeof t != "boolean" && !Array.isArray(t), s = Array.isArray(t) ? t : null;
700
- return /* @__PURE__ */ k(Ke.Provider, {
701
- value: {
702
- editor: e,
703
- disabled: a
704
- },
705
- children: /* @__PURE__ */ k("div", {
706
- role: "toolbar",
707
- "aria-label": "Text formatting",
708
- className: "flex flex-wrap items-center gap-ds-01 border-t border-surface-border px-ds-04 py-ds-02b",
709
- children: o ? t : /* @__PURE__ */ k(Y, {
710
- items: s,
711
- isMobile: n,
712
- hasMentions: r,
713
- hasSlashCommands: i
714
- })
715
- })
716
- });
717
- }
718
- //#endregion
719
- //#region src/composed/rich-chat-input/recording-overlay.tsx
720
- function it(e) {
721
- let t = Math.floor(e / 60), n = Math.floor(e % 60);
722
- return {
723
- minutes: String(t),
724
- separator: ":",
725
- secs: n.toString().padStart(2, "0")
726
- };
727
- }
728
- function at({ duration: e, analyserNode: t, maxDuration: n, onCancel: r }) {
729
- let i = Le();
730
- T.useEffect(() => {
731
- let e = (e) => {
732
- e.key === "Escape" && r();
733
- };
734
- return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
735
- }, [r]);
736
- let o = n != null && n > 0 && e >= n - 10, s = n != null && n > 0 && e >= n - 5, c = s ? "animate-[pulse_500ms_ease-in-out_infinite]" : "animate-[pulse_1s_ease-in-out_infinite]", l = it(e), u = s ? "text-error-11" : o ? "text-warning-11" : "text-surface-fg";
737
- return /* @__PURE__ */ A("div", {
738
- role: "status",
739
- "aria-live": "polite",
740
- "aria-label": "Recording voice message",
741
- className: "absolute inset-0 flex items-center gap-ds-03 px-ds-04 py-ds-03 bg-surface-raised-hover rounded-ds-lg z-10",
742
- children: [
743
- /* @__PURE__ */ k("span", {
744
- className: a("w-ds-02b h-ds-02b shrink-0 rounded-ds-full bg-error-9", i ? "opacity-100" : c),
745
- "aria-hidden": "true"
746
- }),
747
- /* @__PURE__ */ A("span", {
748
- className: a("text-ds-sm font-mono tabular-nums whitespace-nowrap", u),
749
- "aria-label": `${l.minutes} minutes ${l.secs} seconds`,
750
- children: [
751
- l.minutes,
752
- /* @__PURE__ */ k("span", {
753
- className: i ? void 0 : "animate-[blink_1s_step-end_infinite]",
754
- "aria-hidden": "true",
755
- children: l.separator
756
- }),
757
- l.secs
758
- ]
759
- }),
760
- /* @__PURE__ */ k("div", {
761
- className: "flex-1 min-w-0 overflow-hidden",
762
- children: /* @__PURE__ */ k(V, {
763
- mode: "live",
764
- analyserNode: t,
765
- height: 24,
766
- barCount: 60,
767
- className: "w-full"
768
- })
769
- })
770
- ]
771
- });
772
- }
773
- at.displayName = "RecordingOverlay";
774
- //#endregion
775
- //#region src/composed/rich-chat-input/reply-banner.tsx
776
- function ot({ author: e, preview: t, onDismiss: n }) {
777
- return /* @__PURE__ */ k(z.div, {
778
- initial: {
779
- height: 0,
780
- opacity: 0
781
- },
782
- animate: {
783
- height: "auto",
784
- opacity: 1
785
- },
786
- exit: {
787
- height: 0,
788
- opacity: 0
789
- },
790
- transition: {
791
- duration: i.moderate02,
792
- ease: [
793
- .2,
794
- 0,
795
- .38,
796
- .9
797
- ]
798
- },
799
- className: "overflow-hidden",
800
- children: /* @__PURE__ */ A("div", {
801
- role: "status",
802
- "aria-label": `Replying to ${e}`,
803
- className: "flex items-center gap-ds-03 border-b border-surface-border px-ds-04 py-ds-02b",
804
- children: [/* @__PURE__ */ A("div", {
805
- className: "flex-1 min-w-0",
806
- children: [
807
- /* @__PURE__ */ A("span", {
808
- className: "text-ds-sm font-semibold text-surface-fg",
809
- children: ["Replying to ", e]
810
- }),
811
- /* @__PURE__ */ k("span", {
812
- className: "mx-ds-02 text-surface-fg-subtle",
813
- children: "·"
814
- }),
815
- /* @__PURE__ */ k("span", {
816
- className: "text-ds-sm text-surface-fg-muted truncate",
817
- children: t
818
- })
819
- ]
820
- }), /* @__PURE__ */ k("button", {
821
- type: "button",
822
- onClick: n,
823
- className: a("inline-flex h-ds-xs-plus w-ds-xs-plus items-center justify-center rounded-ds-md touch-target", "text-surface-fg-subtle hover:text-surface-fg hover:bg-surface-raised-hover", "transition-colors duration-fast-01 ease-productive-standard", "active:scale-95"),
824
- "aria-label": "Cancel reply",
825
- title: "Cancel reply",
826
- children: /* @__PURE__ */ k(s, {
827
- icon: L,
828
- size: "xs"
829
- })
830
- })]
831
- })
832
- });
833
- }
834
- //#endregion
835
- //#region src/composed/rich-chat-input/schedule-send.tsx
836
- function st() {
837
- let e = /* @__PURE__ */ new Date(), t = e.getHours(), n = [], r = (t, n = 0) => {
838
- let r = new Date(e);
839
- return r.setDate(r.getDate() + n), r.setHours(t, 0, 0, 0), r;
840
- }, i = (t) => {
841
- let n = new Date(e), r = n.getDay(), i = r === 0 ? 1 : r === 1 ? 7 : 8 - r;
842
- return n.setDate(n.getDate() + i), n.setHours(t, 0, 0, 0), n;
843
- };
844
- t < 9 ? (n.push({
845
- label: "Later this morning · 9:00 AM",
846
- date: r(9)
847
- }), n.push({
848
- label: "This afternoon · 1:00 PM",
849
- date: r(13)
850
- }), n.push({
851
- label: "This evening · 6:00 PM",
852
- date: r(18)
853
- })) : t < 13 ? (n.push({
854
- label: "This afternoon · 1:00 PM",
855
- date: r(13)
856
- }), n.push({
857
- label: "This evening · 6:00 PM",
858
- date: r(18)
859
- }), n.push({
860
- label: "Tomorrow morning · 9:00 AM",
861
- date: r(9, 1)
862
- })) : t < 18 ? (n.push({
863
- label: "This evening · 6:00 PM",
864
- date: r(18)
865
- }), n.push({
866
- label: "Tomorrow morning · 9:00 AM",
867
- date: r(9, 1)
868
- }), n.push({
869
- label: "Tomorrow afternoon · 1:00 PM",
870
- date: r(13, 1)
871
- })) : (n.push({
872
- label: "Tomorrow morning · 9:00 AM",
873
- date: r(9, 1)
874
- }), n.push({
875
- label: "Tomorrow afternoon · 1:00 PM",
876
- date: r(13, 1)
877
- }));
878
- let a = i(9);
879
- return a.getTime() - e.getTime() > 2880 * 60 * 1e3 && n.push({
880
- label: "Next Monday · 9:00 AM",
881
- date: a
882
- }), n;
883
- }
884
- function ct({ value: e, onChange: t }) {
885
- let n = e.getHours() % 12 || 12, r = e.getMinutes(), i = e.getHours() >= 12, o = (n) => {
886
- let r = new Date(e);
887
- r.setHours(i ? n % 12 + 12 : n % 12), t(r);
888
- }, s = (n) => {
889
- let r = new Date(e);
890
- r.setMinutes(n), t(r);
891
- }, c = (n) => {
892
- let r = new Date(e), i = r.getHours();
893
- n && i < 12 ? r.setHours(i + 12) : !n && i >= 12 && r.setHours(i - 12), t(r);
894
- };
895
- return /* @__PURE__ */ A("div", {
896
- className: "flex items-center gap-ds-02",
897
- children: [
898
- /* @__PURE__ */ k("select", {
899
- value: n,
900
- onChange: (e) => o(Number(e.target.value)),
901
- className: "h-ds-sm rounded-ds-md border border-surface-border-strong bg-surface-raised px-ds-02 text-ds-sm text-surface-fg focus:outline-hidden focus:ring-2 focus:ring-accent-9",
902
- "aria-label": "Hour",
903
- children: Array.from({ length: 12 }, (e, t) => t + 1).map((e) => /* @__PURE__ */ k("option", {
904
- value: e,
905
- children: e
906
- }, e))
907
- }),
908
- /* @__PURE__ */ k("span", {
909
- className: "text-ds-sm text-surface-fg-subtle font-medium",
910
- children: ":"
911
- }),
912
- /* @__PURE__ */ k("select", {
913
- value: r - r % 5,
914
- onChange: (e) => s(Number(e.target.value)),
915
- className: "h-ds-sm rounded-ds-md border border-surface-border-strong bg-surface-raised px-ds-02 text-ds-sm text-surface-fg focus:outline-hidden focus:ring-2 focus:ring-accent-9",
916
- "aria-label": "Minute",
917
- children: Array.from({ length: 12 }, (e, t) => t * 5).map((e) => /* @__PURE__ */ k("option", {
918
- value: e,
919
- children: String(e).padStart(2, "0")
920
- }, e))
921
- }),
922
- /* @__PURE__ */ A("div", {
923
- className: "inline-flex rounded-ds-md border border-surface-border-strong overflow-hidden",
924
- children: [/* @__PURE__ */ k("button", {
925
- type: "button",
926
- onClick: () => c(!1),
927
- className: a("px-ds-02b py-ds-01 text-ds-xs font-medium transition-colors duration-fast-01", i ? "bg-surface-raised text-surface-fg-subtle hover:bg-surface-raised-hover" : "bg-accent-9 text-white"),
928
- children: "AM"
929
- }), /* @__PURE__ */ k("button", {
930
- type: "button",
931
- onClick: () => c(!0),
932
- className: a("px-ds-02b py-ds-01 text-ds-xs font-medium transition-colors duration-fast-01", i ? "bg-accent-9 text-white" : "bg-surface-raised text-surface-fg-subtle hover:bg-surface-raised-hover"),
933
- children: "PM"
934
- })]
935
- })
936
- ]
937
- });
938
- }
939
- function X({ value: e, onChange: t, minDate: n }) {
940
- let r = /* @__PURE__ */ new Date(), i = e ?? (() => {
941
- let e = new Date(r);
942
- return e.setHours(e.getHours() + 1, 0, 0, 0), e;
943
- })(), a = `${i.getFullYear()}-${String(i.getMonth() + 1).padStart(2, "0")}-${String(i.getDate()).padStart(2, "0")}`, o = (e) => {
944
- let n = e.target.value.split("-");
945
- if (n.length !== 3) return;
946
- let r = new Date(i);
947
- r.setFullYear(Number(n[0]), Number(n[1]) - 1, Number(n[2])), t(r);
948
- }, s = n ? `${n.getFullYear()}-${String(n.getMonth() + 1).padStart(2, "0")}-${String(n.getDate()).padStart(2, "0")}` : void 0;
949
- return /* @__PURE__ */ A("div", {
950
- className: "space-y-ds-03",
951
- children: [/* @__PURE__ */ A("div", {
952
- className: "flex items-center justify-between",
953
- children: [/* @__PURE__ */ k("span", {
954
- className: "text-ds-xs font-medium text-surface-fg-subtle",
955
- children: "Date"
956
- }), /* @__PURE__ */ k("input", {
957
- type: "date",
958
- value: a,
959
- min: s,
960
- onChange: o,
961
- className: "h-ds-sm rounded-ds-md border border-surface-border-strong bg-surface-raised px-ds-03 text-ds-sm text-surface-fg focus:outline-hidden focus:ring-2 focus:ring-accent-9"
962
- })]
963
- }), /* @__PURE__ */ A("div", {
964
- className: "flex items-center justify-between",
965
- children: [/* @__PURE__ */ k("span", {
966
- className: "text-ds-xs font-medium text-surface-fg-subtle",
967
- children: "Time"
968
- }), /* @__PURE__ */ k(ct, {
969
- value: i,
970
- onChange: t
971
- })]
972
- })]
973
- });
974
- }
975
- function lt({ value: e, onChange: t, minDate: n }) {
976
- let r = /* @__PURE__ */ new Date(), i = e ?? (() => {
977
- let e = new Date(r);
978
- return e.setHours(e.getHours() + 1, 0, 0, 0), e;
979
- })(), { currentMonth: a, goToPreviousMonth: o, goToNextMonth: s } = v(i);
980
- return /* @__PURE__ */ A("div", {
981
- className: "space-y-ds-03",
982
- children: [/* @__PURE__ */ k(_, {
983
- currentMonth: a,
984
- selected: i,
985
- onSelect: (e) => {
986
- let n = new Date(e);
987
- n.setHours(i.getHours(), i.getMinutes(), 0, 0), t(n);
988
- },
989
- onMonthChange: (e) => {
990
- e < a ? o() : s();
991
- },
992
- minDate: n,
993
- className: "w-full"
994
- }), /* @__PURE__ */ A("div", {
995
- className: "flex items-center justify-between border-t border-surface-border pt-ds-03",
996
- children: [/* @__PURE__ */ k("span", {
997
- className: "text-ds-xs font-medium text-surface-fg-subtle",
998
- children: "Time"
999
- }), /* @__PURE__ */ k(ct, {
1000
- value: i,
1001
- onChange: t
1002
- })]
1003
- })]
1004
- });
1005
- }
1006
- function ut({ onSchedule: e, onClose: t, onOpenDialog: n }) {
1007
- let [r, i] = T.useState(!1), [a, o] = T.useState(null), c = T.useMemo(() => st(), []), u = (n) => {
1008
- e(n), t();
1009
- };
1010
- return r ? /* @__PURE__ */ A("div", {
1011
- className: "p-ds-04",
1012
- style: { minWidth: 270 },
1013
- children: [
1014
- /* @__PURE__ */ A("div", {
1015
- className: "mb-ds-03 flex items-center justify-between",
1016
- children: [/* @__PURE__ */ k("p", {
1017
- className: "text-ds-sm font-medium text-surface-fg",
1018
- children: "Pick date & time"
1019
- }), /* @__PURE__ */ k("button", {
1020
- type: "button",
1021
- onClick: () => i(!1),
1022
- className: "inline-flex items-center justify-center rounded-ds-md p-ds-01 text-surface-fg-subtle hover:bg-surface-raised-hover hover:text-surface-fg transition-colors",
1023
- "aria-label": "Back to presets",
1024
- children: /* @__PURE__ */ k(s, {
1025
- icon: L,
1026
- size: "sm"
1027
- })
1028
- })]
1029
- }),
1030
- /* @__PURE__ */ k(X, {
1031
- value: a,
1032
- onChange: o,
1033
- minDate: /* @__PURE__ */ new Date()
1034
- }),
1035
- /* @__PURE__ */ k("div", {
1036
- className: "mt-ds-03 flex justify-end",
1037
- children: /* @__PURE__ */ k(l, {
1038
- variant: "solid",
1039
- size: "sm",
1040
- onClick: () => {
1041
- a && a > /* @__PURE__ */ new Date() && (e(a), t(), o(null), i(!1));
1042
- },
1043
- disabled: !a || a <= /* @__PURE__ */ new Date(),
1044
- children: "Confirm"
1045
- })
1046
- })
1047
- ]
1048
- }) : /* @__PURE__ */ A("div", {
1049
- className: "p-ds-02",
1050
- style: { minWidth: 260 },
1051
- children: [
1052
- /* @__PURE__ */ k("p", {
1053
- className: "px-ds-03 py-ds-01 text-ds-xs font-medium text-surface-fg-subtle",
1054
- children: "Schedule send"
1055
- }),
1056
- c.map((e, t) => /* @__PURE__ */ A("button", {
1057
- type: "button",
1058
- onClick: () => u(e.date),
1059
- className: "flex w-full items-center gap-ds-03 rounded-ds-md px-ds-03 py-ds-02b text-ds-sm text-surface-fg hover:bg-surface-raised-hover transition-colors duration-fast-01",
1060
- children: [/* @__PURE__ */ k(s, {
1061
- icon: xe,
1062
- size: "sm",
1063
- className: "shrink-0 text-surface-fg-muted"
1064
- }), e.label]
1065
- }, t)),
1066
- /* @__PURE__ */ k("div", { className: "mx-ds-02 my-ds-02 h-px bg-surface-border" }),
1067
- /* @__PURE__ */ A("button", {
1068
- type: "button",
1069
- onClick: () => i(!0),
1070
- className: "flex w-full items-center gap-ds-03 rounded-ds-md px-ds-03 py-ds-02b text-ds-sm text-surface-fg hover:bg-surface-raised-hover transition-colors duration-fast-01",
1071
- children: [/* @__PURE__ */ k(s, {
1072
- icon: ye,
1073
- size: "sm",
1074
- className: "shrink-0 text-accent-11"
1075
- }), "Pick date & time..."]
1076
- }),
1077
- n && /* @__PURE__ */ A("button", {
1078
- type: "button",
1079
- onClick: () => {
1080
- n(), t();
1081
- },
1082
- className: "flex w-full items-center gap-ds-03 rounded-ds-md px-ds-03 py-ds-02b text-ds-sm text-surface-fg hover:bg-surface-raised-hover transition-colors duration-fast-01",
1083
- children: [/* @__PURE__ */ k(s, {
1084
- icon: ye,
1085
- size: "sm",
1086
- className: "shrink-0 text-surface-fg-muted"
1087
- }), "Open full picker..."]
1088
- })
1089
- ]
1090
- });
1091
- }
1092
- function dt({ open: e, onOpenChange: t, onSchedule: n, initialDate: r }) {
1093
- let [i, a] = T.useState(r ?? null);
1094
- return T.useEffect(() => {
1095
- e && a(r ?? null);
1096
- }, [e, r]), /* @__PURE__ */ k(u, {
1097
- open: e,
1098
- onOpenChange: t,
1099
- children: /* @__PURE__ */ A(d, {
1100
- className: "sm:max-w-[380px]",
1101
- children: [
1102
- /* @__PURE__ */ k(p, { children: /* @__PURE__ */ k(m, { children: r ? "Reschedule message" : "Schedule send" }) }),
1103
- /* @__PURE__ */ k(lt, {
1104
- value: i,
1105
- onChange: a,
1106
- minDate: /* @__PURE__ */ new Date()
1107
- }),
1108
- /* @__PURE__ */ A(f, {
1109
- className: "gap-ds-02",
1110
- children: [/* @__PURE__ */ k(l, {
1111
- variant: "soft",
1112
- onClick: () => t(!1),
1113
- children: "Cancel"
1114
- }), /* @__PURE__ */ k(l, {
1115
- variant: "solid",
1116
- onClick: () => {
1117
- i && i > /* @__PURE__ */ new Date() && (n(i), t(!1));
1118
- },
1119
- disabled: !i || i <= /* @__PURE__ */ new Date(),
1120
- children: r ? "Reschedule" : "Schedule"
1121
- })]
1122
- })
1123
- ]
1124
- })
1125
- });
1126
- }
1127
- function Z(e) {
1128
- let t = /* @__PURE__ */ new Date(), n = new Date(t);
1129
- n.setDate(n.getDate() + 1);
1130
- let r = e.toDateString() === t.toDateString(), i = e.toDateString() === n.toDateString(), a = e.toLocaleTimeString(void 0, {
1131
- hour: "numeric",
1132
- minute: "2-digit"
1133
- });
1134
- return r ? `Today at ${a}` : i ? `Tomorrow at ${a}` : `${e.toLocaleDateString(void 0, {
1135
- weekday: "short",
1136
- month: "short",
1137
- day: "numeric"
1138
- })} at ${a}`;
1139
- }
1140
- function ft({ date: e, onClear: t, onEdit: n }) {
1141
- return /* @__PURE__ */ k(z.div, {
1142
- initial: {
1143
- height: 0,
1144
- opacity: 0
1145
- },
1146
- animate: {
1147
- height: "auto",
1148
- opacity: 1
1149
- },
1150
- exit: {
1151
- height: 0,
1152
- opacity: 0
1153
- },
1154
- transition: { duration: i.moderate01 },
1155
- className: "overflow-hidden",
1156
- children: /* @__PURE__ */ A("div", {
1157
- className: "flex items-center gap-ds-03 px-ds-04 py-ds-02b text-ds-xs text-accent-11 bg-accent-2 border-b border-accent-4",
1158
- children: [
1159
- /* @__PURE__ */ k(s, {
1160
- icon: xe,
1161
- size: "xs",
1162
- className: "shrink-0"
1163
- }),
1164
- /* @__PURE__ */ A("span", {
1165
- className: "flex-1 truncate",
1166
- children: ["Scheduled for ", Z(e)]
1167
- }),
1168
- n && /* @__PURE__ */ k("button", {
1169
- type: "button",
1170
- onClick: n,
1171
- className: "inline-flex shrink-0 items-center justify-center rounded-ds-sm p-ds-01 hover:bg-accent-3 transition-colors",
1172
- "aria-label": "Edit schedule",
1173
- children: /* @__PURE__ */ k(s, {
1174
- icon: ke,
1175
- size: "xs"
1176
- })
1177
- }),
1178
- /* @__PURE__ */ k("button", {
1179
- type: "button",
1180
- onClick: t,
1181
- className: "inline-flex shrink-0 items-center justify-center rounded-ds-sm p-ds-01 hover:bg-accent-3 transition-colors",
1182
- "aria-label": "Cancel schedule",
1183
- children: /* @__PURE__ */ k(s, {
1184
- icon: L,
1185
- size: "xs"
1186
- })
1187
- })
1188
- ]
1189
- })
1190
- });
1191
- }
1192
- //#endregion
1193
- //#region src/composed/rich-chat-input/use-voice-recorder.ts
1194
- function pt() {
1195
- return typeof MediaRecorder < "u" && MediaRecorder.isTypeSupported("audio/webm;codecs=opus") ? "audio/webm;codecs=opus" : typeof MediaRecorder < "u" && MediaRecorder.isTypeSupported("audio/mp4") ? "audio/mp4" : "";
1196
- }
1197
- function mt(e) {
1198
- let { maxDuration: t, onComplete: n } = e, [r, i] = O("idle"), [a, o] = O(0), [s, c] = O(null), [l, u] = O([]), d = D(null), f = D(null), p = D(null), m = D([]), h = D(null), g = D(null), _ = D(null), v = D(null), y = D(0), b = D([]), x = D(!1), S = D(n);
1199
- S.current = n;
1200
- let C = E(() => {
1201
- h.current !== null && (clearInterval(h.current), h.current = null), g.current !== null && (clearInterval(g.current), g.current = null), _.current !== null && (clearTimeout(_.current), _.current = null), p.current &&= (p.current.getTracks().forEach((e) => e.stop()), null), f.current &&= (f.current.close().catch(() => {}), null), v.current = null, c(null), d.current = null, m.current = [];
1202
- }, []), w = E(async () => {
1203
- if (typeof MediaRecorder > "u") throw Error("MediaRecorder is not supported in this browser. Voice recording requires a modern browser with MediaRecorder support.");
1204
- let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
1205
- p.current = e;
1206
- let n = pt(), r = n ? new MediaRecorder(e, { mimeType: n }) : new MediaRecorder(e);
1207
- d.current = r, m.current = [], x.current = !1;
1208
- let a = new AudioContext();
1209
- f.current = a;
1210
- let s = a.createMediaStreamSource(e), l = a.createAnalyser();
1211
- l.fftSize = 256, l.smoothingTimeConstant = .7, s.connect(l), v.current = l, c(l), r.ondataavailable = (e) => {
1212
- e.data.size > 0 && m.current.push(e.data);
1213
- }, r.onstop = () => {
1214
- if (x.current) C(), i("idle"), o(0), u([]);
1215
- else {
1216
- let e = new Blob(m.current, { type: r.mimeType || "audio/webm" }), t = y.current, n = b.current;
1217
- C(), i("idle"), o(0), u([]), S.current(e, t, n);
1218
- }
1219
- }, r.start(), o(0), y.current = 0, h.current = setInterval(() => {
1220
- y.current += 1, o((e) => e + 1);
1221
- }, 1e3);
1222
- let w = new Uint8Array(l.frequencyBinCount);
1223
- u([]), b.current = [], g.current = setInterval(() => {
1224
- if (v.current) {
1225
- v.current.getByteFrequencyData(w);
1226
- let e = 0;
1227
- for (let t = 0; t < w.length; t++) e += w[t];
1228
- let t = e / w.length / 255;
1229
- b.current = [...b.current, t], u((e) => [...e, t]);
1230
- }
1231
- }, 100), t !== void 0 && t > 0 && (_.current = setTimeout(() => {
1232
- d.current && d.current.state !== "inactive" && d.current.stop();
1233
- }, t * 1e3)), i("recording");
1234
- }, [t, C]), ee = E(() => {
1235
- d.current && d.current.state !== "inactive" && (x.current = !1, d.current.stop());
1236
- }, []), te = E(() => {
1237
- d.current && d.current.state !== "inactive" ? (x.current = !0, d.current.stop()) : (C(), i("idle"), o(0), u([]));
1238
- }, [C]), ne = E(() => {
1239
- d.current && d.current.state === "recording" && (d.current.pause(), h.current !== null && (clearInterval(h.current), h.current = null), g.current !== null && (clearInterval(g.current), g.current = null), i("paused"));
1240
- }, []), re = E(() => {
1241
- if (d.current && d.current.state === "paused") {
1242
- d.current.resume(), h.current = setInterval(() => {
1243
- y.current += 1, o((e) => e + 1);
1244
- }, 1e3);
1245
- let e = new Uint8Array(v.current?.frequencyBinCount ?? 128);
1246
- g.current = setInterval(() => {
1247
- if (v.current) {
1248
- v.current.getByteFrequencyData(e);
1249
- let t = 0;
1250
- for (let n = 0; n < e.length; n++) t += e[n];
1251
- let n = t / e.length / 255;
1252
- b.current = [...b.current, n], u((e) => [...e, n]);
1253
- }
1254
- }, 100), i("recording");
1255
- }
1256
- }, []);
1257
- return me(() => () => {
1258
- h.current !== null && clearInterval(h.current), g.current !== null && clearInterval(g.current), _.current !== null && clearTimeout(_.current), d.current && d.current.state !== "inactive" && d.current.stop(), p.current && p.current.getTracks().forEach((e) => e.stop()), f.current && f.current.close().catch(() => {});
1259
- }, []), {
1260
- state: r,
1261
- duration: a,
1262
- analyserNode: s,
1263
- waveformData: l,
1264
- start: w,
1265
- stop: ee,
1266
- cancel: te,
1267
- pause: ne,
1268
- resume: re
1269
- };
1270
- }
1271
- //#endregion
1272
- //#region src/composed/rich-chat-input.tsx
1273
- var ht = {
1274
- compact: {
1275
- minHeight: 44,
1276
- maxHeight: 256,
1277
- showToolbar: !0,
1278
- toolbarPosition: "bottom"
1279
- },
1280
- expanded: {
1281
- minHeight: 96,
1282
- maxHeight: 384,
1283
- showToolbar: !0,
1284
- toolbarPosition: "bottom"
1285
- },
1286
- minimal: {
1287
- minHeight: 44,
1288
- maxHeight: 128,
1289
- showToolbar: !1,
1290
- toolbarPosition: "bottom"
1291
- },
1292
- inline: {
1293
- minHeight: 40,
1294
- maxHeight: 160,
1295
- showToolbar: !1,
1296
- toolbarPosition: "top"
1297
- }
1298
- }, gt = [
1299
- "prose prose-sm max-w-none focus:outline-hidden",
1300
- "font-body text-ds-md leading-relaxed text-surface-fg",
1301
- "[&_p.is-editor-empty:first-child]:relative",
1302
- "[&_p.is-editor-empty:first-child::before]:text-surface-fg-subtle [&_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_p.is-editor-empty:first-child::before]:pointer-events-none [&_p.is-editor-empty:first-child::before]:absolute [&_p.is-editor-empty:first-child::before]:left-0 [&_p.is-editor-empty:first-child::before]:top-0 [&_p.is-editor-empty:first-child::before]:w-full [&_p.is-editor-empty:first-child::before]:truncate",
1303
- "[&_p]:mb-ds-01 [&_p]:text-surface-fg",
1304
- "[&_p:last-child]:mb-0",
1305
- "[&_ul]:ml-ds-04 [&_ul]:list-disc [&_ol]:ml-ds-04 [&_ol]:list-decimal",
1306
- "[&_li]:text-surface-fg",
1307
- "[&_code]:rounded [&_code]:bg-surface-raised [&_code]:px-ds-02 [&_code]:py-[1px] [&_code]:text-ds-md [&_code]:text-accent-11",
1308
- "[&_strong]:font-semibold [&_strong]:text-surface-fg",
1309
- "[&_mark]:rounded-xs [&_mark]:bg-warning-3 [&_mark]:px-[2px]",
1310
- "[&_a]:text-accent-11 [&_a]:underline",
1311
- "[&_.mention]:rounded-ds-sm [&_.mention]:bg-accent-2 [&_.mention]:px-ds-02 [&_.mention]:py-[1px] [&_.mention]:font-medium [&_.mention]:text-accent-11"
1312
- ].join(" ");
1313
- function _t({ options: e }) {
1314
- let [t, n] = T.useState(!1), r = T.useRef(null);
1315
- return T.useEffect(() => {
1316
- if (!t) return;
1317
- let e = (e) => {
1318
- r.current && !r.current.contains(e.target) && n(!1);
1319
- };
1320
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
1321
- }, [t]), /* @__PURE__ */ A("div", {
1322
- ref: r,
1323
- className: "relative",
1324
- children: [/* @__PURE__ */ k("button", {
1325
- type: "button",
1326
- onClick: () => n((e) => !e),
1327
- title: "More send options",
1328
- "aria-label": "More send options",
1329
- "aria-expanded": t,
1330
- className: a("inline-flex h-ds-xs-plus w-5 items-center justify-center rounded-ds-md touch-target", "text-surface-fg-subtle hover:bg-surface-raised-hover hover:text-surface-fg", "transition-colors duration-fast-01 ease-productive-standard", t && "bg-surface-raised-hover text-surface-fg"),
1331
- children: /* @__PURE__ */ k(s, {
1332
- icon: be,
1333
- size: "xs"
1334
- })
1335
- }), t && /* @__PURE__ */ A("div", {
1336
- className: "absolute bottom-full right-0 mb-ds-02 min-w-[200px] rounded-ds-lg border border-surface-border-strong bg-surface-overlay p-ds-02 shadow-floating z-popover",
1337
- children: [/* @__PURE__ */ k("p", {
1338
- className: "px-ds-03 py-ds-01 text-ds-xs font-medium text-surface-fg-subtle",
1339
- children: "Send options"
1340
- }), e.map((e, t) => /* @__PURE__ */ A("button", {
1341
- type: "button",
1342
- onClick: () => {
1343
- e.onSelect(), n(!1);
1344
- },
1345
- className: "flex w-full items-center gap-ds-03 rounded-ds-md px-ds-03 py-ds-02 text-ds-sm text-surface-fg hover:bg-surface-raised-hover transition-colors duration-fast-01",
1346
- children: [e.icon && /* @__PURE__ */ k(e.icon, { className: "h-ico-sm w-ico-sm text-surface-fg-muted" }), e.label]
1347
- }, t))]
1348
- })]
1349
- });
1350
- }
1351
- var vt = T.lazy(() => import("@emoji-mart/react"));
1352
- function yt({ set: e = "native", onSelect: t, onClose: n }) {
1353
- let [r, i] = T.useState(null), { colorMode: a } = pe(), o = T.useRef(null);
1354
- T.useEffect(() => {
1355
- (g[e] ?? g.native)().then((e) => i(e.default));
1356
- }, [e]), T.useEffect(() => {
1357
- let e = (e) => {
1358
- o.current && !o.current.contains(e.target) && n();
1359
- };
1360
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
1361
- }, [n]), T.useEffect(() => {
1362
- let e = (e) => {
1363
- e.key === "Escape" && n();
1364
- };
1365
- return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
1366
- }, [n]);
1367
- let s = /* @__PURE__ */ k("div", {
1368
- className: "flex h-[350px] w-[352px] items-center justify-center rounded-ds-lg border border-surface-border-strong bg-surface-overlay shadow-floating",
1369
- children: /* @__PURE__ */ k("span", {
1370
- className: "text-ds-sm text-surface-fg-subtle",
1371
- children: "Loading..."
1372
- })
1373
- });
1374
- return /* @__PURE__ */ k("div", {
1375
- ref: o,
1376
- className: "rounded-ds-lg border border-surface-border-strong bg-surface-overlay shadow-floating overflow-hidden",
1377
- children: r ? /* @__PURE__ */ k(T.Suspense, {
1378
- fallback: s,
1379
- children: /* @__PURE__ */ k(vt, {
1380
- data: r,
1381
- set: e,
1382
- onEmojiSelect: (e) => t({
1383
- id: e.id,
1384
- native: e.native
1385
- }),
1386
- theme: a === "dark" ? "dark" : "light",
1387
- previewPosition: "none",
1388
- skinTonePosition: "none"
1389
- })
1390
- }) : s
1391
- });
1392
- }
1393
- function Q({ onClick: e, isActive: t = !1, title: n, children: r }) {
1394
- return /* @__PURE__ */ k("button", {
1395
- type: "button",
1396
- onClick: e,
1397
- title: n,
1398
- "aria-label": n,
1399
- "aria-pressed": t,
1400
- className: a("inline-flex h-ds-xs-plus w-ds-xs-plus items-center justify-center rounded-ds-md touch-target", "transition-colors duration-fast-01 ease-productive-standard", "hover:bg-surface-raised-hover", t ? "bg-surface-raised-hover text-accent-11" : "text-surface-fg-subtle"),
1401
- children: r
1402
- });
1403
- }
1404
- function bt({ editor: e }) {
1405
- let t = C({
1406
- editor: e,
1407
- selector: ({ editor: e }) => ({
1408
- isBold: e.isActive("bold"),
1409
- isItalic: e.isActive("italic"),
1410
- isUnderline: e.isActive("underline"),
1411
- isStrike: e.isActive("strike"),
1412
- isHighlight: e.isActive("highlight"),
1413
- isCode: e.isActive("code")
1414
- })
1415
- });
1416
- return /* @__PURE__ */ A(w, {
1417
- editor: e,
1418
- className: "flex gap-ds-01 rounded-ds-lg border border-surface-border-strong bg-surface-overlay p-ds-02 shadow-floating",
1419
- children: [
1420
- /* @__PURE__ */ k(Q, {
1421
- onClick: () => e.chain().focus().toggleBold().run(),
1422
- isActive: t.isBold,
1423
- title: "Bold",
1424
- children: /* @__PURE__ */ k(s, {
1425
- icon: j,
1426
- size: "xs"
1427
- })
1428
- }),
1429
- /* @__PURE__ */ k(Q, {
1430
- onClick: () => e.chain().focus().toggleItalic().run(),
1431
- isActive: t.isItalic,
1432
- title: "Italic",
1433
- children: /* @__PURE__ */ k(s, {
1434
- icon: Te,
1435
- size: "xs"
1436
- })
1437
- }),
1438
- /* @__PURE__ */ k(Q, {
1439
- onClick: () => e.chain().focus().toggleUnderline().run(),
1440
- isActive: t.isUnderline,
1441
- title: "Underline",
1442
- children: /* @__PURE__ */ k(s, {
1443
- icon: I,
1444
- size: "xs"
1445
- })
1446
- }),
1447
- /* @__PURE__ */ k(Q, {
1448
- onClick: () => e.chain().focus().toggleStrike().run(),
1449
- isActive: t.isStrike,
1450
- title: "Strikethrough",
1451
- children: /* @__PURE__ */ k(s, {
1452
- icon: F,
1453
- size: "xs"
1454
- })
1455
- }),
1456
- /* @__PURE__ */ k(Q, {
1457
- onClick: () => e.chain().focus().toggleHighlight().run(),
1458
- isActive: t.isHighlight,
1459
- title: "Highlight",
1460
- children: /* @__PURE__ */ k(s, {
1461
- icon: we,
1462
- size: "xs"
1463
- })
1464
- }),
1465
- /* @__PURE__ */ k(Q, {
1466
- onClick: () => e.chain().focus().toggleCode().run(),
1467
- isActive: t.isCode,
1468
- title: "Code",
1469
- children: /* @__PURE__ */ k(s, {
1470
- icon: Se,
1471
- size: "xs"
1472
- })
1473
- })
1474
- ]
1475
- });
1476
- }
1477
- var xt = T.forwardRef(function({ onSubmit: o, placeholder: u = "Type a message...", disabled: d = !1, content: f = "", variant: p = "compact", enterBehavior: m = "send", maxLength: g, charCountDisplay: _ = "near-limit", mentions: v, onMentionSearch: w, onMentionSelect: ae, onFileUpload: oe, onImageUpload: pe, slashCommands: E, onVoiceRecord: me, onTranscribe: D, maxDuration: O, replyTo: he, onTyping: _e, onEmpty: ve, isStreaming: j = !1, onCancel: ye, leadingSlot: be, trailingSlot: Se, disclaimer: Ce, toolbar: we = !0, sendOptions: Te, onSchedule: M, actionButton: Ee, emojiSet: N = "native", className: ke, ...Ae }, je) {
1478
- let [P, F] = T.useState("idle"), [I, L] = T.useState(!1), [Le, Re] = T.useState(!1), [B, ze] = T.useState(null), [Ve, V] = T.useState(!1), [Ue, We] = T.useState(!1), [Ke, H] = T.useState(0), U = T.useRef(null), W = T.useRef(null);
1479
- T.useEffect(() => {
1480
- if (!Le || !U.current || !W.current) return;
1481
- let i = U.current, a = W.current, o = () => {
1482
- e(i, a, {
1483
- placement: "top-end",
1484
- middleware: [
1485
- n(8),
1486
- r(),
1487
- t({ padding: 8 })
1488
- ]
1489
- }).then(({ x: e, y: t }) => {
1490
- Object.assign(a.style, {
1491
- left: `${e}px`,
1492
- top: `${t}px`
1493
- });
1494
- });
1495
- };
1496
- return o(), window.addEventListener("scroll", o, !0), window.addEventListener("resize", o), () => {
1497
- window.removeEventListener("scroll", o, !0), window.removeEventListener("resize", o);
1498
- };
1499
- }, [Le]);
1500
- let [G, K] = T.useState([]), [q, qe] = T.useState(null), [Je, Ye] = T.useState(!1), Xe = T.useRef(null), Ze = T.useRef(null), Qe = T.useRef(void 0), $e = T.useRef(void 0), et = T.useRef(m);
1501
- et.current = m;
1502
- let tt = c(), J = ht[p], nt = J.maxHeight, Y = mt({
1503
- maxDuration: O,
1504
- onComplete: async (e, t, n) => {
1505
- if (me?.(e, t), D) {
1506
- let n = await D(e, t);
1507
- if (n != null) {
1508
- X?.chain().focus().insertContent(n).run(), F("idle");
1509
- return;
1510
- }
1511
- }
1512
- qe({
1513
- blob: e,
1514
- duration: t,
1515
- waveformData: n
1516
- }), F("review");
1517
- }
1518
- }), it = T.useCallback(() => {
1519
- Y.start(), F("recording");
1520
- }, [Y]), st = T.useCallback(() => {
1521
- Y.stop();
1522
- }, [Y]), ct = T.useCallback(() => {
1523
- Y.cancel(), F("idle");
1524
- }, [Y]), X = te({
1525
- immediatelyRender: !1,
1526
- extensions: T.useMemo(() => {
1527
- let e = [
1528
- ne.configure({
1529
- heading: !1,
1530
- horizontalRule: !1,
1531
- codeBlock: !1,
1532
- blockquote: !1,
1533
- link: {
1534
- openOnClick: !1,
1535
- HTMLAttributes: { class: "text-accent-11 underline" }
1536
- }
1537
- }),
1538
- re.configure({ placeholder: u }),
1539
- ee.configure({ multicolor: !1 }),
1540
- b,
1541
- y.configure({ limit: g || void 0 }),
1542
- le,
1543
- ce,
1544
- de(N),
1545
- S.create({
1546
- name: "enterToSend",
1547
- addKeyboardShortcuts() {
1548
- return {
1549
- Enter: () => et.current === "send" ? ($e.current?.(), !0) : !1,
1550
- "Shift-Enter": () => et.current === "send" ? (this.editor.commands.splitBlock(), !0) : !1,
1551
- "Mod-Enter": () => ($e.current?.(), !0)
1552
- };
1553
- }
1554
- })
1555
- ];
1556
- return (v || w) && e.push(ie.configure({
1557
- HTMLAttributes: { class: "mention" },
1558
- suggestion: {
1559
- items: async ({ query: e }) => w ? await w(e) : v ? v.filter((t) => t.label.toLowerCase().includes(e.toLowerCase())).slice(0, 8) : [],
1560
- render: fe(ae)
1561
- }
1562
- })), E && e.push(Be(E)), e;
1563
- }, [
1564
- u,
1565
- g,
1566
- N,
1567
- !!v,
1568
- !!w,
1569
- !!E
1570
- ]),
1571
- content: f || void 0,
1572
- editable: !d,
1573
- editorProps: {
1574
- attributes: { class: gt },
1575
- handlePaste: (e, t) => {
1576
- let n = Array.from(t.clipboardData?.files ?? []);
1577
- return n.length > 0 ? (n.forEach(Z), !0) : !1;
1578
- }
1579
- }
1580
- }), lt = T.useCallback(() => {
1581
- if (!X) return;
1582
- let e = !X.isEmpty, t = G.length > 0, n = !!q;
1583
- if (!e && !t && !n || j) return;
1584
- let r = {
1585
- html: e ? X.getHTML() : "",
1586
- plainText: e ? X.getText() : ""
1587
- };
1588
- t && (r.attachments = G.filter((e) => !e.uploading && e.url).map((e) => ({
1589
- url: e.url,
1590
- name: e.name,
1591
- size: e.size,
1592
- type: e.type
1593
- }))), n && (r.voiceNote = {
1594
- blob: q.blob,
1595
- duration: q.duration
1596
- }), B && M ? M(r, B) : o(r), X.commands.clearContent(), K([]), qe(null), ze(null), F("idle");
1597
- }, [
1598
- X,
1599
- G,
1600
- q,
1601
- j,
1602
- o,
1603
- M,
1604
- B
1605
- ]);
1606
- $e.current = lt, T.useEffect(() => {
1607
- if (!X || !_e) return;
1608
- let e = () => {
1609
- _e(!0), clearTimeout(Qe.current), Qe.current = setTimeout(() => _e(!1), 2e3);
1610
- };
1611
- return X.on("update", e), () => {
1612
- X.off("update", e), clearTimeout(Qe.current);
1613
- };
1614
- }, [X, _e]), T.useEffect(() => {
1615
- if (!X || !ve) return;
1616
- let e = () => {
1617
- ve(X.isEmpty);
1618
- };
1619
- return X.on("update", e), e(), () => {
1620
- X.off("update", e);
1621
- };
1622
- }, [X, ve]);
1623
- let Z = T.useCallback(async (e) => {
1624
- let t = Math.random().toString(36).slice(2), n = e.type.startsWith("image/");
1625
- K((r) => [...r, {
1626
- id: t,
1627
- name: e.name,
1628
- size: e.size,
1629
- type: n ? "image" : "file",
1630
- uploading: !0
1631
- }]);
1632
- try {
1633
- if (n && pe) {
1634
- let n = await pe(e);
1635
- K((e) => e.map((e) => e.id === t ? {
1636
- ...e,
1637
- url: n,
1638
- uploading: !1
1639
- } : e));
1640
- } else if (oe) {
1641
- let n = await oe(e);
1642
- K((e) => e.map((e) => e.id === t ? {
1643
- ...e,
1644
- url: n.url,
1645
- name: n.name,
1646
- size: n.size,
1647
- uploading: !1
1648
- } : e));
1649
- } else if (n) {
1650
- let n = URL.createObjectURL(e);
1651
- K((e) => e.map((e) => e.id === t ? {
1652
- ...e,
1653
- url: n,
1654
- uploading: !1
1655
- } : e));
1656
- } else K((e) => e.filter((e) => e.id !== t));
1657
- } catch {
1658
- K((e) => e.filter((e) => e.id !== t));
1659
- }
1660
- }, [oe, pe]), pt = T.useCallback((e) => {
1661
- K((t) => t.filter((t) => t.id !== e));
1662
- }, []), vt = T.useCallback((e) => {
1663
- e.preventDefault(), Ye(!1), Array.from(e.dataTransfer.files).forEach(Z);
1664
- }, [Z]), Q = T.useCallback((e) => {
1665
- Array.from(e.target.files || []).forEach(Z), e.target.value = "";
1666
- }, [Z]), xt = T.useCallback(() => {
1667
- qe(null), F("idle");
1668
- }, []), St = C({
1669
- editor: X,
1670
- selector: ({ editor: e }) => e ? { editorIsEmpty: e.isEmpty } : null
1671
- })?.editorIsEmpty ?? !0;
1672
- T.useEffect(() => {
1673
- if (!X) return;
1674
- let e = () => {
1675
- H(X.state.doc.textBetween(0, X.state.doc.content.size, void 0, " ").length);
1676
- };
1677
- return e(), X.on("update", e), () => {
1678
- X.off("update", e);
1679
- };
1680
- }, [X]);
1681
- let Ct = !St || G.length > 0 || !!q, wt = I || P === "review" || p === "expanded", $ = "icon-md";
1682
- return /* @__PURE__ */ A("div", {
1683
- ref: je,
1684
- className: a("border-t border-surface-border-subtle px-ds-05 py-ds-04", "flex items-center gap-ds-03", ke),
1685
- ...Ae,
1686
- children: [
1687
- Ee !== !1 && (Ee ?? (oe || pe ? /* @__PURE__ */ k(l, {
1688
- variant: "solid",
1689
- size: "icon-md",
1690
- onClick: () => Xe.current?.click(),
1691
- title: "Attach",
1692
- "aria-label": "Attach file",
1693
- className: "shrink-0",
1694
- children: /* @__PURE__ */ k(s, {
1695
- icon: Me,
1696
- size: "md"
1697
- })
1698
- }) : null)),
1699
- /* @__PURE__ */ A("div", {
1700
- role: "region",
1701
- "aria-label": "Message composer",
1702
- className: a("flex-1 min-w-0 overflow-hidden rounded-ds-lg border border-surface-border-strong bg-surface-raised-hover", "transition-[color,background-color,border-color,box-shadow] duration-fast-02 ease-productive-standard", "hover:bg-surface-raised-active", "focus-within:ring-2 focus-within:ring-accent-9 focus-within:ring-offset-2 focus-within:border-accent-9", P === "recording" && "border-error-7/30", Je && "border-dashed border-accent-7 bg-accent-2", d && "opacity-action-disabled cursor-not-allowed"),
1703
- onFocus: () => We(!0),
1704
- onBlur: (e) => {
1705
- e.currentTarget.contains(e.relatedTarget) || We(!1);
1706
- },
1707
- onDragOver: (e) => {
1708
- e.preventDefault(), Ye(!0);
1709
- },
1710
- onDragLeave: () => Ye(!1),
1711
- onDrop: vt,
1712
- children: [
1713
- be,
1714
- /* @__PURE__ */ k(R, { children: he && /* @__PURE__ */ k(ot, {
1715
- author: he.author,
1716
- preview: he.preview,
1717
- onDismiss: he.onDismiss
1718
- }, "reply") }),
1719
- /* @__PURE__ */ k(R, { children: B && /* @__PURE__ */ k(ft, {
1720
- date: B,
1721
- onEdit: () => V(!0),
1722
- onClear: () => ze(null)
1723
- }, "schedule") }),
1724
- /* @__PURE__ */ k(R, { children: G.length > 0 && /* @__PURE__ */ k(He, {
1725
- attachments: G,
1726
- onRemoveAttachment: pt
1727
- }, "attachments") }),
1728
- J.toolbarPosition === "top" && X && /* @__PURE__ */ k("div", {
1729
- className: a("grid transition-[grid-template-rows,opacity] duration-moderate-01 ease-productive-standard", I ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0 pointer-events-none"),
1730
- children: /* @__PURE__ */ k("div", {
1731
- className: "overflow-hidden",
1732
- children: /* @__PURE__ */ k(rt, {
1733
- editor: X,
1734
- toolbar: we,
1735
- isMobile: !1,
1736
- hasMentions: !!(v || w),
1737
- hasSlashCommands: !!E,
1738
- disabled: d
1739
- })
1740
- })
1741
- }),
1742
- /* @__PURE__ */ A("div", {
1743
- className: "relative",
1744
- children: [P === "recording" && /* @__PURE__ */ k(at, {
1745
- duration: Y.duration,
1746
- analyserNode: Y.analyserNode,
1747
- maxDuration: O,
1748
- onCancel: ct
1749
- }), /* @__PURE__ */ A("div", {
1750
- ref: Ze,
1751
- className: a("flex items-center px-ds-04 py-ds-03 cursor-text [&_.tiptap]:w-full [&_.tiptap]:outline-hidden", P === "recording" && "invisible"),
1752
- style: {
1753
- minHeight: J.minHeight,
1754
- maxHeight: nt,
1755
- overflowY: "auto"
1756
- },
1757
- onClick: () => X?.commands.focus(),
1758
- children: [/* @__PURE__ */ k("div", {
1759
- className: "flex-1 min-w-0",
1760
- children: /* @__PURE__ */ k(x, { editor: X })
1761
- }), X && P !== "recording" && /* @__PURE__ */ A("div", {
1762
- className: "flex items-center gap-ds-01 shrink-0 ml-ds-03",
1763
- children: [/* @__PURE__ */ k("button", {
1764
- type: "button",
1765
- onClick: () => L((e) => !e),
1766
- title: I ? "Hide formatting" : "Show formatting",
1767
- "aria-label": I ? "Hide formatting" : "Show formatting",
1768
- "aria-pressed": I,
1769
- className: a("inline-flex h-ds-xs-plus w-ds-xs-plus items-center justify-center rounded-ds-md touch-target", "transition-colors duration-fast-01 ease-productive-standard", "hover:bg-surface-raised-hover", I ? "bg-surface-raised-hover text-accent-11" : "text-surface-fg-subtle"),
1770
- children: /* @__PURE__ */ k(s, {
1771
- icon: Fe,
1772
- size: "xs"
1773
- })
1774
- }), /* @__PURE__ */ A("div", {
1775
- className: "relative",
1776
- children: [/* @__PURE__ */ k("button", {
1777
- ref: U,
1778
- type: "button",
1779
- onClick: () => Re((e) => !e),
1780
- title: "Emoji",
1781
- "aria-label": "Emoji",
1782
- className: a("inline-flex h-ds-xs-plus w-ds-xs-plus items-center justify-center rounded-ds-md touch-target transition-colors duration-fast-01", Le ? "bg-surface-raised-hover text-accent-11" : "text-surface-fg-subtle hover:bg-surface-raised-hover hover:text-surface-fg"),
1783
- children: /* @__PURE__ */ k(s, {
1784
- icon: Oe,
1785
- size: "xs"
1786
- })
1787
- }), Le && ge.createPortal(/* @__PURE__ */ k("div", {
1788
- ref: W,
1789
- className: "absolute z-popover",
1790
- style: {
1791
- top: 0,
1792
- left: 0
1793
- },
1794
- children: /* @__PURE__ */ k(yt, {
1795
- set: N,
1796
- onSelect: async ({ id: e, native: t }) => {
1797
- let n = ue(await se(N), e);
1798
- n ? X.chain().focus().insertContent({
1799
- type: "emojiNode",
1800
- attrs: {
1801
- id: e,
1802
- native: n.native,
1803
- set: N,
1804
- x: n.x,
1805
- y: n.y
1806
- }
1807
- }).run() : X.chain().focus().insertContent(t).run(), Re(!1);
1808
- },
1809
- onClose: () => Re(!1)
1810
- })
1811
- }), document.body)]
1812
- })]
1813
- })]
1814
- })]
1815
- }),
1816
- P === "review" && q && /* @__PURE__ */ A("div", {
1817
- className: "flex items-center gap-ds-03 px-ds-04 py-ds-02b border-b border-surface-border",
1818
- children: [/* @__PURE__ */ k(Ge, {
1819
- src: q.blob,
1820
- duration: q.duration,
1821
- waveformData: q.waveformData,
1822
- className: "flex-1"
1823
- }), /* @__PURE__ */ k(l, {
1824
- variant: "ghost",
1825
- size: "icon-sm",
1826
- onClick: xt,
1827
- "aria-label": "Discard voice note",
1828
- title: "Discard voice note",
1829
- className: "text-surface-fg-subtle hover:text-error-11",
1830
- children: /* @__PURE__ */ k(s, {
1831
- icon: Ie,
1832
- size: "sm"
1833
- })
1834
- })]
1835
- }),
1836
- tt && X && !St && /* @__PURE__ */ k(bt, { editor: X }),
1837
- J.toolbarPosition === "bottom" && X && /* @__PURE__ */ k("div", {
1838
- className: a("grid transition-[grid-template-rows,opacity] duration-moderate-01 ease-productive-standard", wt ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0 pointer-events-none"),
1839
- children: /* @__PURE__ */ k("div", {
1840
- className: "overflow-hidden",
1841
- children: /* @__PURE__ */ k(rt, {
1842
- editor: X,
1843
- toolbar: we,
1844
- isMobile: tt,
1845
- hasMentions: !!(v || w),
1846
- hasSlashCommands: !!E,
1847
- disabled: d
1848
- })
1849
- })
1850
- }),
1851
- g && _ !== "hidden" && (() => {
1852
- let e = Ke / g;
1853
- return _ === "always" || _ === "focus" && Ue || (_ === "near-limit" || !_) && e >= .8 || e >= 1 ? /* @__PURE__ */ A("div", {
1854
- className: a("flex justify-end px-ds-04 pb-ds-02 text-ds-xs tabular-nums transition-opacity duration-fast-01", e >= 1 ? "text-error-11 font-medium" : e >= .9 ? "text-warning-11" : "text-surface-fg-subtle"),
1855
- children: [
1856
- Ke,
1857
- "/",
1858
- g
1859
- ]
1860
- }) : null;
1861
- })(),
1862
- Se,
1863
- /* @__PURE__ */ k("input", {
1864
- ref: Xe,
1865
- type: "file",
1866
- multiple: !0,
1867
- className: "hidden",
1868
- onChange: Q
1869
- })
1870
- ]
1871
- }),
1872
- /* @__PURE__ */ A("div", {
1873
- className: "flex items-center gap-ds-02 shrink-0",
1874
- children: [Te && Te.length > 0 && P !== "recording" && /* @__PURE__ */ k(_t, { options: Te }), /* @__PURE__ */ A(R, {
1875
- mode: "popLayout",
1876
- initial: !1,
1877
- children: [
1878
- P === "recording" && /* @__PURE__ */ A(z.div, {
1879
- initial: {
1880
- scale: .8,
1881
- opacity: 0
1882
- },
1883
- animate: {
1884
- scale: 1,
1885
- opacity: 1
1886
- },
1887
- exit: {
1888
- scale: .8,
1889
- opacity: 0
1890
- },
1891
- transition: { duration: i.moderate01 },
1892
- className: "flex items-center gap-ds-02",
1893
- children: [/* @__PURE__ */ k(l, {
1894
- variant: "soft",
1895
- size: $,
1896
- onClick: ct,
1897
- "aria-label": "Cancel recording",
1898
- title: "Cancel recording",
1899
- className: "text-surface-fg-subtle hover:text-error-11",
1900
- children: /* @__PURE__ */ k(s, {
1901
- icon: Ie,
1902
- size: "md"
1903
- })
1904
- }), /* @__PURE__ */ k(l, {
1905
- variant: "solid",
1906
- size: $,
1907
- color: "error",
1908
- onClick: st,
1909
- "aria-label": "Stop recording",
1910
- title: "Stop recording",
1911
- children: /* @__PURE__ */ k(s, {
1912
- icon: Pe,
1913
- size: "md"
1914
- })
1915
- })]
1916
- }, "recording"),
1917
- j && P !== "recording" && /* @__PURE__ */ k(z.div, {
1918
- initial: {
1919
- scale: .8,
1920
- opacity: 0
1921
- },
1922
- animate: {
1923
- scale: 1,
1924
- opacity: 1
1925
- },
1926
- exit: {
1927
- scale: .8,
1928
- opacity: 0
1929
- },
1930
- transition: { duration: i.moderate01 },
1931
- children: /* @__PURE__ */ k(l, {
1932
- variant: "solid",
1933
- size: $,
1934
- color: "error",
1935
- onClick: ye,
1936
- "aria-label": "Stop",
1937
- title: "Stop",
1938
- children: /* @__PURE__ */ k(s, {
1939
- icon: Pe,
1940
- size: "md"
1941
- })
1942
- })
1943
- }, "streaming"),
1944
- !j && P !== "recording" && Ct && M && /* @__PURE__ */ k(z.div, {
1945
- initial: {
1946
- scale: .8,
1947
- opacity: 0
1948
- },
1949
- animate: {
1950
- scale: 1,
1951
- opacity: 1
1952
- },
1953
- exit: {
1954
- scale: .8,
1955
- opacity: 0
1956
- },
1957
- transition: { duration: i.moderate01 },
1958
- children: /* @__PURE__ */ k(h, {
1959
- onClick: lt,
1960
- disabled: d,
1961
- "aria-label": B ? "Schedule send" : "Send",
1962
- size: $,
1963
- dropdownContent: /* @__PURE__ */ k(ut, {
1964
- onSchedule: (e) => ze(e),
1965
- onClose: () => {},
1966
- onOpenDialog: () => V(!0)
1967
- }),
1968
- children: /* @__PURE__ */ k(s, {
1969
- icon: B ? xe : Ne,
1970
- size: "md"
1971
- })
1972
- })
1973
- }, "split-send"),
1974
- !j && P !== "recording" && Ct && !M && /* @__PURE__ */ k(z.div, {
1975
- initial: {
1976
- scale: .8,
1977
- opacity: 0
1978
- },
1979
- animate: {
1980
- scale: 1,
1981
- opacity: 1
1982
- },
1983
- exit: {
1984
- scale: .8,
1985
- opacity: 0
1986
- },
1987
- transition: { duration: i.moderate01 },
1988
- children: /* @__PURE__ */ k(l, {
1989
- variant: "solid",
1990
- size: $,
1991
- onClick: lt,
1992
- disabled: d,
1993
- "aria-label": "Send",
1994
- title: "Send",
1995
- children: /* @__PURE__ */ k(s, {
1996
- icon: Ne,
1997
- size: "md"
1998
- })
1999
- })
2000
- }, "send"),
2001
- !j && P !== "recording" && !Ct && me && /* @__PURE__ */ k(z.div, {
2002
- initial: {
2003
- scale: .8,
2004
- opacity: 0
2005
- },
2006
- animate: {
2007
- scale: 1,
2008
- opacity: 1
2009
- },
2010
- exit: {
2011
- scale: .8,
2012
- opacity: 0
2013
- },
2014
- transition: { duration: i.moderate01 },
2015
- children: /* @__PURE__ */ k(l, {
2016
- variant: "soft",
2017
- size: $,
2018
- onClick: it,
2019
- "aria-label": "Record voice message",
2020
- title: "Record voice message",
2021
- children: /* @__PURE__ */ k(s, {
2022
- icon: De,
2023
- size: "md"
2024
- })
2025
- })
2026
- }, "mic"),
2027
- !j && P !== "recording" && !Ct && !me && /* @__PURE__ */ k(z.div, {
2028
- initial: {
2029
- scale: .8,
2030
- opacity: 0
2031
- },
2032
- animate: {
2033
- scale: 1,
2034
- opacity: 1
2035
- },
2036
- exit: {
2037
- scale: .8,
2038
- opacity: 0
2039
- },
2040
- transition: { duration: i.moderate01 },
2041
- children: /* @__PURE__ */ k(l, {
2042
- variant: "solid",
2043
- size: $,
2044
- disabled: !0,
2045
- "aria-label": "Send",
2046
- title: "Send",
2047
- children: /* @__PURE__ */ k(s, {
2048
- icon: Ne,
2049
- size: "md"
2050
- })
2051
- })
2052
- }, "send-disabled")
2053
- ]
2054
- })]
2055
- }),
2056
- Ce && /* @__PURE__ */ k("p", {
2057
- className: "mt-ds-02 text-center text-ds-xs text-surface-fg-subtle/50",
2058
- children: Ce
2059
- }),
2060
- M && /* @__PURE__ */ k(dt, {
2061
- open: Ve,
2062
- onOpenChange: V,
2063
- onSchedule: (e) => ze(e),
2064
- initialDate: B
2065
- })
2066
- ]
2067
- });
2068
- });
2069
- xt.displayName = "RichChatInput";
2070
- //#endregion
2071
- export { G as _, Ze as a, V as b, Ye as c, tt as d, Qe as f, W as g, U as h, K as i, q as l, Je as m, mt as n, Xe as o, nt as p, $e as r, J as s, xt as t, et as u, qe as v, Ge as y };