@swisper.ai/web-chat-ui 0.0.2

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 (609) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +251 -0
  3. package/dist/components/canvas-shell/canvas-shell.d.ts +64 -0
  4. package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -0
  5. package/dist/components/canvas-shell/canvas-shell.stories.d.ts +26 -0
  6. package/dist/components/canvas-shell/canvas-shell.stories.d.ts.map +1 -0
  7. package/dist/components/canvas-shell/index.d.ts +2 -0
  8. package/dist/components/canvas-shell/index.d.ts.map +1 -0
  9. package/dist/components/card-item-picker/card-item-picker-context.d.ts +21 -0
  10. package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +1 -0
  11. package/dist/components/card-item-picker/card-item-picker-list.d.ts +24 -0
  12. package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +1 -0
  13. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +28 -0
  14. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +1 -0
  15. package/dist/components/card-item-picker/card-item-picker-row.d.ts +12 -0
  16. package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +1 -0
  17. package/dist/components/card-item-picker/card-item-picker.stories.d.ts +19 -0
  18. package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +1 -0
  19. package/dist/components/card-item-picker/index.d.ts +9 -0
  20. package/dist/components/card-item-picker/index.d.ts.map +1 -0
  21. package/dist/components/chat-card/chat-card.d.ts +4 -0
  22. package/dist/components/chat-card/chat-card.d.ts.map +1 -0
  23. package/dist/components/chat-card/chat-card.stories.d.ts +11 -0
  24. package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -0
  25. package/dist/components/chat-card/components/chat-card-body.d.ts +22 -0
  26. package/dist/components/chat-card/components/chat-card-body.d.ts.map +1 -0
  27. package/dist/components/chat-card/components/chat-card-footer.d.ts +20 -0
  28. package/dist/components/chat-card/components/chat-card-footer.d.ts.map +1 -0
  29. package/dist/components/chat-card/components/chat-card-form.d.ts +28 -0
  30. package/dist/components/chat-card/components/chat-card-form.d.ts.map +1 -0
  31. package/dist/components/chat-card/components/chat-card-header.d.ts +36 -0
  32. package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -0
  33. package/dist/components/chat-card/components/index.d.ts +5 -0
  34. package/dist/components/chat-card/components/index.d.ts.map +1 -0
  35. package/dist/components/chat-card/context.d.ts +13 -0
  36. package/dist/components/chat-card/context.d.ts.map +1 -0
  37. package/dist/components/chat-card/contexts.d.ts +16 -0
  38. package/dist/components/chat-card/contexts.d.ts.map +1 -0
  39. package/dist/components/chat-card/hooks.d.ts +13 -0
  40. package/dist/components/chat-card/hooks.d.ts.map +1 -0
  41. package/dist/components/chat-card/index.d.ts +6 -0
  42. package/dist/components/chat-card/index.d.ts.map +1 -0
  43. package/dist/components/chat-card/types.d.ts +21 -0
  44. package/dist/components/chat-card/types.d.ts.map +1 -0
  45. package/dist/components/chat-card-container/chat-card-container.d.ts +43 -0
  46. package/dist/components/chat-card-container/chat-card-container.d.ts.map +1 -0
  47. package/dist/components/chat-card-container/chat-card-container.stories.d.ts +17 -0
  48. package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -0
  49. package/dist/components/chat-card-container/index.d.ts +3 -0
  50. package/dist/components/chat-card-container/index.d.ts.map +1 -0
  51. package/dist/components/chat-container/chat-container.d.ts +51 -0
  52. package/dist/components/chat-container/chat-container.d.ts.map +1 -0
  53. package/dist/components/chat-container/chat-container.stories.d.ts +21 -0
  54. package/dist/components/chat-container/chat-container.stories.d.ts.map +1 -0
  55. package/dist/components/chat-container/index.d.ts +3 -0
  56. package/dist/components/chat-container/index.d.ts.map +1 -0
  57. package/dist/components/chat-input/chat-input.d.ts +35 -0
  58. package/dist/components/chat-input/chat-input.d.ts.map +1 -0
  59. package/dist/components/chat-input/chat-input.stories.d.ts +14 -0
  60. package/dist/components/chat-input/chat-input.stories.d.ts.map +1 -0
  61. package/dist/components/chat-input/index.d.ts +3 -0
  62. package/dist/components/chat-input/index.d.ts.map +1 -0
  63. package/dist/components/chat-input/plugins/auto-focus-plugin.d.ts +8 -0
  64. package/dist/components/chat-input/plugins/auto-focus-plugin.d.ts.map +1 -0
  65. package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts +6 -0
  66. package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts.map +1 -0
  67. package/dist/components/chat-input/plugins/disabled-plugin.d.ts +7 -0
  68. package/dist/components/chat-input/plugins/disabled-plugin.d.ts.map +1 -0
  69. package/dist/components/chat-input/plugins/focus-plugin.d.ts +6 -0
  70. package/dist/components/chat-input/plugins/focus-plugin.d.ts.map +1 -0
  71. package/dist/components/chat-input/plugins/has-value-plugin.d.ts +6 -0
  72. package/dist/components/chat-input/plugins/has-value-plugin.d.ts.map +1 -0
  73. package/dist/components/chat-input/plugins/hooks.d.ts +2 -0
  74. package/dist/components/chat-input/plugins/hooks.d.ts.map +1 -0
  75. package/dist/components/chat-input/plugins/index.d.ts +8 -0
  76. package/dist/components/chat-input/plugins/index.d.ts.map +1 -0
  77. package/dist/components/chat-input/plugins/markdown-plain-paste-plugin.d.ts +2 -0
  78. package/dist/components/chat-input/plugins/markdown-plain-paste-plugin.d.ts.map +1 -0
  79. package/dist/components/chat-input/plugins/utils.d.ts +4 -0
  80. package/dist/components/chat-input/plugins/utils.d.ts.map +1 -0
  81. package/dist/components/chat-input/plugins/value-plugin.d.ts +6 -0
  82. package/dist/components/chat-input/plugins/value-plugin.d.ts.map +1 -0
  83. package/dist/components/chat-input/transformers.d.ts +3 -0
  84. package/dist/components/chat-input/transformers.d.ts.map +1 -0
  85. package/dist/components/chat-list/chat-list-item.d.ts +8 -0
  86. package/dist/components/chat-list/chat-list-item.d.ts.map +1 -0
  87. package/dist/components/chat-list/chat-list-items.d.ts +11 -0
  88. package/dist/components/chat-list/chat-list-items.d.ts.map +1 -0
  89. package/dist/components/chat-list/chat-list.d.ts +63 -0
  90. package/dist/components/chat-list/chat-list.d.ts.map +1 -0
  91. package/dist/components/chat-list/chat-list.stories.d.ts +13 -0
  92. package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -0
  93. package/dist/components/chat-list/index.d.ts +4 -0
  94. package/dist/components/chat-list/index.d.ts.map +1 -0
  95. package/dist/components/chat-message/chat-message.d.ts +17 -0
  96. package/dist/components/chat-message/chat-message.d.ts.map +1 -0
  97. package/dist/components/chat-message/chat-message.stories.d.ts +11 -0
  98. package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -0
  99. package/dist/components/chat-message/index.d.ts +2 -0
  100. package/dist/components/chat-message/index.d.ts.map +1 -0
  101. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +9 -0
  102. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -0
  103. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +30 -0
  104. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -0
  105. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +11 -0
  106. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -0
  107. package/dist/components/chat-message-attachment-card/index.d.ts +4 -0
  108. package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -0
  109. package/dist/components/chat-message-attachment-card/utils.d.ts +5 -0
  110. package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -0
  111. package/dist/components/chat-message-history/chat-message-history.d.ts +48 -0
  112. package/dist/components/chat-message-history/chat-message-history.d.ts.map +1 -0
  113. package/dist/components/chat-message-history/chat-message-history.stories.d.ts +7 -0
  114. package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +1 -0
  115. package/dist/components/chat-message-history/index.d.ts +2 -0
  116. package/dist/components/chat-message-history/index.d.ts.map +1 -0
  117. package/dist/components/chat-message-response/chat-message-response.d.ts +7 -0
  118. package/dist/components/chat-message-response/chat-message-response.d.ts.map +1 -0
  119. package/dist/components/chat-message-response/chat-message-response.stories.d.ts +7 -0
  120. package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -0
  121. package/dist/components/chat-message-response/index.d.ts +2 -0
  122. package/dist/components/chat-message-response/index.d.ts.map +1 -0
  123. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +25 -0
  124. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -0
  125. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +7 -0
  126. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -0
  127. package/dist/components/chat-message-toolbar/index.d.ts +2 -0
  128. package/dist/components/chat-message-toolbar/index.d.ts.map +1 -0
  129. package/dist/components/chat-messages/chat-messages.d.ts +24 -0
  130. package/dist/components/chat-messages/chat-messages.d.ts.map +1 -0
  131. package/dist/components/chat-messages/chat-messages.stories.d.ts +8 -0
  132. package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -0
  133. package/dist/components/chat-messages/index.d.ts +2 -0
  134. package/dist/components/chat-messages/index.d.ts.map +1 -0
  135. package/dist/components/chat-notification-card/chat-notification-card.d.ts +114 -0
  136. package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -0
  137. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +10 -0
  138. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -0
  139. package/dist/components/chat-notification-card/index.d.ts +4 -0
  140. package/dist/components/chat-notification-card/index.d.ts.map +1 -0
  141. package/dist/components/chat-notification-card/types.d.ts +2 -0
  142. package/dist/components/chat-notification-card/types.d.ts.map +1 -0
  143. package/dist/components/chat-notification-card/utils.d.ts +3 -0
  144. package/dist/components/chat-notification-card/utils.d.ts.map +1 -0
  145. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +12 -0
  146. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -0
  147. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +8 -0
  148. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -0
  149. package/dist/components/chat-notification-popup/index.d.ts +2 -0
  150. package/dist/components/chat-notification-popup/index.d.ts.map +1 -0
  151. package/dist/components/chat-prompt-box/chat-prompt-box-context.d.ts +17 -0
  152. package/dist/components/chat-prompt-box/chat-prompt-box-context.d.ts.map +1 -0
  153. package/dist/components/chat-prompt-box/chat-prompt-box-focus-plugin.d.ts +2 -0
  154. package/dist/components/chat-prompt-box/chat-prompt-box-focus-plugin.d.ts.map +1 -0
  155. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +27 -0
  156. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -0
  157. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +9 -0
  158. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -0
  159. package/dist/components/chat-prompt-box/index.d.ts +3 -0
  160. package/dist/components/chat-prompt-box/index.d.ts.map +1 -0
  161. package/dist/components/chat-reply/chat-reply.d.ts +23 -0
  162. package/dist/components/chat-reply/chat-reply.d.ts.map +1 -0
  163. package/dist/components/chat-reply/chat-reply.stories.d.ts +7 -0
  164. package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -0
  165. package/dist/components/chat-reply/index.d.ts +2 -0
  166. package/dist/components/chat-reply/index.d.ts.map +1 -0
  167. package/dist/components/chat-suggestion/chat-suggestion.d.ts +37 -0
  168. package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -0
  169. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +9 -0
  170. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -0
  171. package/dist/components/chat-suggestion/index.d.ts +2 -0
  172. package/dist/components/chat-suggestion/index.d.ts.map +1 -0
  173. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +47 -0
  174. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -0
  175. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +10 -0
  176. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -0
  177. package/dist/components/chat-thinking-process/index.d.ts +2 -0
  178. package/dist/components/chat-thinking-process/index.d.ts.map +1 -0
  179. package/dist/components/chat-thread/chat-thread.d.ts +78 -0
  180. package/dist/components/chat-thread/chat-thread.d.ts.map +1 -0
  181. package/dist/components/chat-thread/chat-thread.stories.d.ts +14 -0
  182. package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -0
  183. package/dist/components/chat-thread/index.d.ts +2 -0
  184. package/dist/components/chat-thread/index.d.ts.map +1 -0
  185. package/dist/components/deprecated-empty-state.d.ts +22 -0
  186. package/dist/components/deprecated-empty-state.d.ts.map +1 -0
  187. package/dist/components/index.d.ts +27 -0
  188. package/dist/components/index.d.ts.map +1 -0
  189. package/dist/components/markdown-viewer/hooks.d.ts +9 -0
  190. package/dist/components/markdown-viewer/hooks.d.ts.map +1 -0
  191. package/dist/components/markdown-viewer/index.d.ts +3 -0
  192. package/dist/components/markdown-viewer/index.d.ts.map +1 -0
  193. package/dist/components/markdown-viewer/markdown-viewer.d.ts +10 -0
  194. package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -0
  195. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +9 -0
  196. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -0
  197. package/dist/components/markdown-viewer/types.d.ts +9 -0
  198. package/dist/components/markdown-viewer/types.d.ts.map +1 -0
  199. package/dist/components/markdown-viewer/utils.d.ts +3 -0
  200. package/dist/components/markdown-viewer/utils.d.ts.map +1 -0
  201. package/dist/components/new-chat-trigger/index.d.ts +2 -0
  202. package/dist/components/new-chat-trigger/index.d.ts.map +1 -0
  203. package/dist/components/new-chat-trigger/new-chat-trigger.d.ts +8 -0
  204. package/dist/components/new-chat-trigger/new-chat-trigger.d.ts.map +1 -0
  205. package/dist/components/rich-text-area/constants/index.d.ts +3 -0
  206. package/dist/components/rich-text-area/constants/index.d.ts.map +1 -0
  207. package/dist/components/rich-text-area/hooks.d.ts +3 -0
  208. package/dist/components/rich-text-area/hooks.d.ts.map +1 -0
  209. package/dist/components/rich-text-area/html-config.d.ts +4 -0
  210. package/dist/components/rich-text-area/html-config.d.ts.map +1 -0
  211. package/dist/components/rich-text-area/index.d.ts +7 -0
  212. package/dist/components/rich-text-area/index.d.ts.map +1 -0
  213. package/dist/components/rich-text-area/nodes/div-block-node.d.ts +18 -0
  214. package/dist/components/rich-text-area/nodes/div-block-node.d.ts.map +1 -0
  215. package/dist/components/rich-text-area/nodes/image-node.d.ts +24 -0
  216. package/dist/components/rich-text-area/nodes/image-node.d.ts.map +1 -0
  217. package/dist/components/rich-text-area/plugins/blur-plugin.d.ts +6 -0
  218. package/dist/components/rich-text-area/plugins/blur-plugin.d.ts.map +1 -0
  219. package/dist/components/rich-text-area/plugins/controlled-plugin.d.ts +7 -0
  220. package/dist/components/rich-text-area/plugins/controlled-plugin.d.ts.map +1 -0
  221. package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts +7 -0
  222. package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts.map +1 -0
  223. package/dist/components/rich-text-area/plugins/disabled-plugin.d.ts +6 -0
  224. package/dist/components/rich-text-area/plugins/disabled-plugin.d.ts.map +1 -0
  225. package/dist/components/rich-text-area/plugins/file-attachment-plugin.d.ts +10 -0
  226. package/dist/components/rich-text-area/plugins/file-attachment-plugin.d.ts.map +1 -0
  227. package/dist/components/rich-text-area/plugins/focus-plugin.d.ts +6 -0
  228. package/dist/components/rich-text-area/plugins/focus-plugin.d.ts.map +1 -0
  229. package/dist/components/rich-text-area/plugins/html-paste-plugin.d.ts +19 -0
  230. package/dist/components/rich-text-area/plugins/html-paste-plugin.d.ts.map +1 -0
  231. package/dist/components/rich-text-area/plugins/image-drop-plugin.d.ts +12 -0
  232. package/dist/components/rich-text-area/plugins/image-drop-plugin.d.ts.map +1 -0
  233. package/dist/components/rich-text-area/plugins/index.d.ts +11 -0
  234. package/dist/components/rich-text-area/plugins/index.d.ts.map +1 -0
  235. package/dist/components/rich-text-area/plugins/markdown-plain-paste-plugin.d.ts +2 -0
  236. package/dist/components/rich-text-area/plugins/markdown-plain-paste-plugin.d.ts.map +1 -0
  237. package/dist/components/rich-text-area/plugins/value-plugin.d.ts +7 -0
  238. package/dist/components/rich-text-area/plugins/value-plugin.d.ts.map +1 -0
  239. package/dist/components/rich-text-area/rich-text-area.d.ts +20 -0
  240. package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -0
  241. package/dist/components/rich-text-area/rich-text-area.stories.d.ts +7 -0
  242. package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -0
  243. package/dist/components/rich-text-area/styled.d.ts +3 -0
  244. package/dist/components/rich-text-area/styled.d.ts.map +1 -0
  245. package/dist/components/rich-text-area/transformers.d.ts +16 -0
  246. package/dist/components/rich-text-area/transformers.d.ts.map +1 -0
  247. package/dist/components/rich-text-area/types.d.ts +8 -0
  248. package/dist/components/rich-text-area/types.d.ts.map +1 -0
  249. package/dist/components/rich-text-area/utils/index.d.ts +6 -0
  250. package/dist/components/rich-text-area/utils/index.d.ts.map +1 -0
  251. package/dist/components/rich-text-field/components/alignment-select.d.ts +5 -0
  252. package/dist/components/rich-text-field/components/alignment-select.d.ts.map +1 -0
  253. package/dist/components/rich-text-field/components/attachment-button.d.ts +3 -0
  254. package/dist/components/rich-text-field/components/attachment-button.d.ts.map +1 -0
  255. package/dist/components/rich-text-field/components/bold-button.d.ts +3 -0
  256. package/dist/components/rich-text-field/components/bold-button.d.ts.map +1 -0
  257. package/dist/components/rich-text-field/components/clean-format-button.d.ts +3 -0
  258. package/dist/components/rich-text-field/components/clean-format-button.d.ts.map +1 -0
  259. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +11 -0
  260. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -0
  261. package/dist/components/rich-text-field/components/image-button.d.ts +3 -0
  262. package/dist/components/rich-text-field/components/image-button.d.ts.map +1 -0
  263. package/dist/components/rich-text-field/components/index.d.ts +14 -0
  264. package/dist/components/rich-text-field/components/index.d.ts.map +1 -0
  265. package/dist/components/rich-text-field/components/italic-button.d.ts +3 -0
  266. package/dist/components/rich-text-field/components/italic-button.d.ts.map +1 -0
  267. package/dist/components/rich-text-field/components/link-button.d.ts +3 -0
  268. package/dist/components/rich-text-field/components/link-button.d.ts.map +1 -0
  269. package/dist/components/rich-text-field/components/size-select.d.ts +5 -0
  270. package/dist/components/rich-text-field/components/size-select.d.ts.map +1 -0
  271. package/dist/components/rich-text-field/components/text-color-button.d.ts +3 -0
  272. package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -0
  273. package/dist/components/rich-text-field/components/toolbar-button.d.ts +6 -0
  274. package/dist/components/rich-text-field/components/toolbar-button.d.ts.map +1 -0
  275. package/dist/components/rich-text-field/components/toolbar-select.d.ts +5 -0
  276. package/dist/components/rich-text-field/components/toolbar-select.d.ts.map +1 -0
  277. package/dist/components/rich-text-field/components/typography-select.d.ts +5 -0
  278. package/dist/components/rich-text-field/components/typography-select.d.ts.map +1 -0
  279. package/dist/components/rich-text-field/components/underline-button.d.ts +3 -0
  280. package/dist/components/rich-text-field/components/underline-button.d.ts.map +1 -0
  281. package/dist/components/rich-text-field/constants.d.ts +57 -0
  282. package/dist/components/rich-text-field/constants.d.ts.map +1 -0
  283. package/dist/components/rich-text-field/context.d.ts +26 -0
  284. package/dist/components/rich-text-field/context.d.ts.map +1 -0
  285. package/dist/components/rich-text-field/index.d.ts +3 -0
  286. package/dist/components/rich-text-field/index.d.ts.map +1 -0
  287. package/dist/components/rich-text-field/rich-text-field.d.ts +17 -0
  288. package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -0
  289. package/dist/components/rich-text-field/rich-text-field.stories.d.ts +10 -0
  290. package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -0
  291. package/dist/components/rich-text-field/utils.d.ts +1759 -0
  292. package/dist/components/rich-text-field/utils.d.ts.map +1 -0
  293. package/dist/components/spinner/index.d.ts +2 -0
  294. package/dist/components/spinner/index.d.ts.map +1 -0
  295. package/dist/components/spinner/spinner.d.ts +9 -0
  296. package/dist/components/spinner/spinner.d.ts.map +1 -0
  297. package/dist/components/spinner/spinner.stories.d.ts +8 -0
  298. package/dist/components/spinner/spinner.stories.d.ts.map +1 -0
  299. package/dist/contexts/chat-context/chat-context.d.ts +20 -0
  300. package/dist/contexts/chat-context/chat-context.d.ts.map +1 -0
  301. package/dist/contexts/chat-context/index.d.ts +2 -0
  302. package/dist/contexts/chat-context/index.d.ts.map +1 -0
  303. package/dist/contexts/chat-context/utils.d.ts +3 -0
  304. package/dist/contexts/chat-context/utils.d.ts.map +1 -0
  305. package/dist/contexts/chat-conversation-context/chat-conversation-context.d.ts +20 -0
  306. package/dist/contexts/chat-conversation-context/chat-conversation-context.d.ts.map +1 -0
  307. package/dist/contexts/chat-conversation-context/index.d.ts +2 -0
  308. package/dist/contexts/chat-conversation-context/index.d.ts.map +1 -0
  309. package/dist/contexts/index.d.ts +3 -0
  310. package/dist/contexts/index.d.ts.map +1 -0
  311. package/dist/docs/agent.stories.d.ts +41 -0
  312. package/dist/docs/agent.stories.d.ts.map +1 -0
  313. package/dist/docs/chat-panel.d.ts +33 -0
  314. package/dist/docs/chat-panel.d.ts.map +1 -0
  315. package/dist/docs/chatbot-panel.d.ts +20 -0
  316. package/dist/docs/chatbot-panel.d.ts.map +1 -0
  317. package/dist/docs/chatbot.stories.d.ts +11 -0
  318. package/dist/docs/chatbot.stories.d.ts.map +1 -0
  319. package/dist/domain/actions/constants.d.ts +2 -0
  320. package/dist/domain/actions/constants.d.ts.map +1 -0
  321. package/dist/domain/actions/hooks/index.d.ts +3 -0
  322. package/dist/domain/actions/hooks/index.d.ts.map +1 -0
  323. package/dist/domain/actions/index.d.ts +5 -0
  324. package/dist/domain/actions/index.d.ts.map +1 -0
  325. package/dist/domain/actions/types.d.ts +7 -0
  326. package/dist/domain/actions/types.d.ts.map +1 -0
  327. package/dist/domain/actions/utils/index.d.ts +11 -0
  328. package/dist/domain/actions/utils/index.d.ts.map +1 -0
  329. package/dist/domain/index.d.ts +2 -0
  330. package/dist/domain/index.d.ts.map +1 -0
  331. package/dist/hooks/index.d.ts +7 -0
  332. package/dist/hooks/index.d.ts.map +1 -0
  333. package/dist/hooks/use-chat-prompt-placeholder.d.ts +6 -0
  334. package/dist/hooks/use-chat-prompt-placeholder.d.ts.map +1 -0
  335. package/dist/hooks/use-chat-stream-message.d.ts +42 -0
  336. package/dist/hooks/use-chat-stream-message.d.ts.map +1 -0
  337. package/dist/hooks/use-current-chat-id.d.ts +2 -0
  338. package/dist/hooks/use-current-chat-id.d.ts.map +1 -0
  339. package/dist/hooks/use-is-current-chat-new.d.ts +2 -0
  340. package/dist/hooks/use-is-current-chat-new.d.ts.map +1 -0
  341. package/dist/hooks/use-loaded-chat-ids.d.ts +9 -0
  342. package/dist/hooks/use-loaded-chat-ids.d.ts.map +1 -0
  343. package/dist/hooks/use-on-chat-changed.d.ts +9 -0
  344. package/dist/hooks/use-on-chat-changed.d.ts.map +1 -0
  345. package/dist/index.css +2 -0
  346. package/dist/index.d.ts +7 -0
  347. package/dist/index.d.ts.map +1 -0
  348. package/dist/index.es.js +4404 -0
  349. package/dist/index.es.js.map +1 -0
  350. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +95 -0
  351. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -0
  352. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +24 -0
  353. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -0
  354. package/dist/layouts/chat-card-list-layout/index.d.ts +3 -0
  355. package/dist/layouts/chat-card-list-layout/index.d.ts.map +1 -0
  356. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts +84 -0
  357. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts.map +1 -0
  358. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts +45 -0
  359. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts.map +1 -0
  360. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +37 -0
  361. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -0
  362. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts +81 -0
  363. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts.map +1 -0
  364. package/dist/layouts/chat-card-three-column-layout/index.d.ts +5 -0
  365. package/dist/layouts/chat-card-three-column-layout/index.d.ts.map +1 -0
  366. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +31 -0
  367. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -0
  368. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts +12 -0
  369. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts.map +1 -0
  370. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +19 -0
  371. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -0
  372. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts +35 -0
  373. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts.map +1 -0
  374. package/dist/layouts/chat-card-two-column-layout/index.d.ts +4 -0
  375. package/dist/layouts/chat-card-two-column-layout/index.d.ts.map +1 -0
  376. package/dist/layouts/index.d.ts +4 -0
  377. package/dist/layouts/index.d.ts.map +1 -0
  378. package/dist/types.d.ts +22 -0
  379. package/dist/types.d.ts.map +1 -0
  380. package/dist/utils/use-streaming-markdown.d.ts +18 -0
  381. package/dist/utils/use-streaming-markdown.d.ts.map +1 -0
  382. package/package.json +155 -0
  383. package/src/__tests__/setup.ts +5 -0
  384. package/src/components/canvas-shell/canvas-shell.json +126 -0
  385. package/src/components/canvas-shell/canvas-shell.stories.tsx +194 -0
  386. package/src/components/canvas-shell/canvas-shell.test.tsx +205 -0
  387. package/src/components/canvas-shell/canvas-shell.tsx +250 -0
  388. package/src/components/canvas-shell/index.ts +19 -0
  389. package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +279 -0
  390. package/src/components/card-item-picker/card-item-picker-context.tsx +44 -0
  391. package/src/components/card-item-picker/card-item-picker-list.tsx +95 -0
  392. package/src/components/card-item-picker/card-item-picker-row-parts.tsx +96 -0
  393. package/src/components/card-item-picker/card-item-picker-row.tsx +109 -0
  394. package/src/components/card-item-picker/card-item-picker.json +147 -0
  395. package/src/components/card-item-picker/card-item-picker.stories.tsx +158 -0
  396. package/src/components/card-item-picker/index.ts +24 -0
  397. package/src/components/chat-card/__tests__/chat-card.spec.tsx +118 -0
  398. package/src/components/chat-card/chat-card.json +162 -0
  399. package/src/components/chat-card/chat-card.stories.tsx +349 -0
  400. package/src/components/chat-card/chat-card.tsx +106 -0
  401. package/src/components/chat-card/components/chat-card-body.tsx +115 -0
  402. package/src/components/chat-card/components/chat-card-footer.tsx +95 -0
  403. package/src/components/chat-card/components/chat-card-form.tsx +120 -0
  404. package/src/components/chat-card/components/chat-card-header.tsx +240 -0
  405. package/src/components/chat-card/components/index.ts +4 -0
  406. package/src/components/chat-card/context.tsx +34 -0
  407. package/src/components/chat-card/contexts.tsx +42 -0
  408. package/src/components/chat-card/hooks.ts +51 -0
  409. package/src/components/chat-card/index.ts +5 -0
  410. package/src/components/chat-card/types.ts +23 -0
  411. package/src/components/chat-card-container/chat-card-container.json +84 -0
  412. package/src/components/chat-card-container/chat-card-container.stories.tsx +149 -0
  413. package/src/components/chat-card-container/chat-card-container.tsx +75 -0
  414. package/src/components/chat-card-container/index.ts +2 -0
  415. package/src/components/chat-container/chat-container.json +93 -0
  416. package/src/components/chat-container/chat-container.stories.tsx +179 -0
  417. package/src/components/chat-container/chat-container.tsx +231 -0
  418. package/src/components/chat-container/index.ts +2 -0
  419. package/src/components/chat-input/chat-input.json +106 -0
  420. package/src/components/chat-input/chat-input.stories.tsx +291 -0
  421. package/src/components/chat-input/chat-input.tsx +220 -0
  422. package/src/components/chat-input/index.ts +2 -0
  423. package/src/components/chat-input/plugins/auto-focus-plugin.tsx +43 -0
  424. package/src/components/chat-input/plugins/controlled-value-plugin.tsx +47 -0
  425. package/src/components/chat-input/plugins/disabled-plugin.tsx +18 -0
  426. package/src/components/chat-input/plugins/focus-plugin.tsx +44 -0
  427. package/src/components/chat-input/plugins/has-value-plugin.tsx +51 -0
  428. package/src/components/chat-input/plugins/hooks.ts +7 -0
  429. package/src/components/chat-input/plugins/index.ts +7 -0
  430. package/src/components/chat-input/plugins/markdown-plain-paste-plugin.tsx +63 -0
  431. package/src/components/chat-input/plugins/utils.ts +48 -0
  432. package/src/components/chat-input/plugins/value-plugin.tsx +35 -0
  433. package/src/components/chat-input/transformers.ts +4 -0
  434. package/src/components/chat-list/chat-list-item.tsx +33 -0
  435. package/src/components/chat-list/chat-list-items.tsx +144 -0
  436. package/src/components/chat-list/chat-list.json +117 -0
  437. package/src/components/chat-list/chat-list.stories.tsx +332 -0
  438. package/src/components/chat-list/chat-list.tsx +278 -0
  439. package/src/components/chat-list/index.ts +18 -0
  440. package/src/components/chat-message/chat-message.json +105 -0
  441. package/src/components/chat-message/chat-message.stories.tsx +95 -0
  442. package/src/components/chat-message/chat-message.tsx +66 -0
  443. package/src/components/chat-message/index.ts +1 -0
  444. package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +74 -0
  445. package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +110 -0
  446. package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +131 -0
  447. package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +142 -0
  448. package/src/components/chat-message-attachment-card/index.ts +12 -0
  449. package/src/components/chat-message-attachment-card/utils.ts +41 -0
  450. package/src/components/chat-message-history/chat-message-history.json +99 -0
  451. package/src/components/chat-message-history/chat-message-history.stories.tsx +136 -0
  452. package/src/components/chat-message-history/chat-message-history.tsx +277 -0
  453. package/src/components/chat-message-history/index.ts +13 -0
  454. package/src/components/chat-message-response/chat-message-response.json +68 -0
  455. package/src/components/chat-message-response/chat-message-response.stories.tsx +63 -0
  456. package/src/components/chat-message-response/chat-message-response.tsx +24 -0
  457. package/src/components/chat-message-response/index.ts +1 -0
  458. package/src/components/chat-message-toolbar/chat-message-toolbar.json +100 -0
  459. package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +62 -0
  460. package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +97 -0
  461. package/src/components/chat-message-toolbar/index.ts +6 -0
  462. package/src/components/chat-messages/chat-messages.json +95 -0
  463. package/src/components/chat-messages/chat-messages.stories.tsx +284 -0
  464. package/src/components/chat-messages/chat-messages.tsx +264 -0
  465. package/src/components/chat-messages/index.ts +10 -0
  466. package/src/components/chat-notification-card/chat-notification-card.json +135 -0
  467. package/src/components/chat-notification-card/chat-notification-card.stories.tsx +290 -0
  468. package/src/components/chat-notification-card/chat-notification-card.tsx +684 -0
  469. package/src/components/chat-notification-card/index.ts +3 -0
  470. package/src/components/chat-notification-card/types.ts +1 -0
  471. package/src/components/chat-notification-card/utils.ts +34 -0
  472. package/src/components/chat-notification-popup/chat-notification-popup.json +97 -0
  473. package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +80 -0
  474. package/src/components/chat-notification-popup/chat-notification-popup.tsx +36 -0
  475. package/src/components/chat-notification-popup/index.ts +1 -0
  476. package/src/components/chat-prompt-box/chat-prompt-box-context.tsx +62 -0
  477. package/src/components/chat-prompt-box/chat-prompt-box-focus-plugin.tsx +22 -0
  478. package/src/components/chat-prompt-box/chat-prompt-box.json +106 -0
  479. package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +117 -0
  480. package/src/components/chat-prompt-box/chat-prompt-box.tsx +296 -0
  481. package/src/components/chat-prompt-box/index.ts +16 -0
  482. package/src/components/chat-reply/chat-reply.json +79 -0
  483. package/src/components/chat-reply/chat-reply.stories.tsx +72 -0
  484. package/src/components/chat-reply/chat-reply.tsx +103 -0
  485. package/src/components/chat-reply/index.ts +1 -0
  486. package/src/components/chat-suggestion/chat-suggestion.json +108 -0
  487. package/src/components/chat-suggestion/chat-suggestion.stories.tsx +147 -0
  488. package/src/components/chat-suggestion/chat-suggestion.tsx +184 -0
  489. package/src/components/chat-suggestion/index.ts +8 -0
  490. package/src/components/chat-thinking-process/chat-thinking-process.json +110 -0
  491. package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +202 -0
  492. package/src/components/chat-thinking-process/chat-thinking-process.tsx +268 -0
  493. package/src/components/chat-thinking-process/index.ts +9 -0
  494. package/src/components/chat-thread/__tests__/chat-thread.spec.tsx +385 -0
  495. package/src/components/chat-thread/chat-thread.json +120 -0
  496. package/src/components/chat-thread/chat-thread.stories.tsx +218 -0
  497. package/src/components/chat-thread/chat-thread.tsx +549 -0
  498. package/src/components/chat-thread/index.ts +18 -0
  499. package/src/components/deprecated-empty-state.ts +39 -0
  500. package/src/components/index.ts +26 -0
  501. package/src/components/markdown-viewer/hooks.ts +59 -0
  502. package/src/components/markdown-viewer/index.ts +2 -0
  503. package/src/components/markdown-viewer/markdown-viewer.json +84 -0
  504. package/src/components/markdown-viewer/markdown-viewer.stories.tsx +110 -0
  505. package/src/components/markdown-viewer/markdown-viewer.tsx +95 -0
  506. package/src/components/markdown-viewer/types.ts +10 -0
  507. package/src/components/markdown-viewer/utils.ts +5 -0
  508. package/src/components/new-chat-trigger/index.ts +1 -0
  509. package/src/components/new-chat-trigger/new-chat-trigger.tsx +29 -0
  510. package/src/components/rich-text-area/constants/index.ts +10 -0
  511. package/src/components/rich-text-area/hooks.ts +24 -0
  512. package/src/components/rich-text-area/html-config.ts +195 -0
  513. package/src/components/rich-text-area/index.ts +6 -0
  514. package/src/components/rich-text-area/nodes/div-block-node.tsx +145 -0
  515. package/src/components/rich-text-area/nodes/image-node.tsx +100 -0
  516. package/src/components/rich-text-area/plugins/blur-plugin.tsx +36 -0
  517. package/src/components/rich-text-area/plugins/controlled-plugin.tsx +23 -0
  518. package/src/components/rich-text-area/plugins/controlled-value-plugin.tsx +101 -0
  519. package/src/components/rich-text-area/plugins/disabled-plugin.tsx +17 -0
  520. package/src/components/rich-text-area/plugins/file-attachment-plugin.tsx +57 -0
  521. package/src/components/rich-text-area/plugins/focus-plugin.tsx +44 -0
  522. package/src/components/rich-text-area/plugins/html-paste-plugin.tsx +104 -0
  523. package/src/components/rich-text-area/plugins/image-drop-plugin.tsx +56 -0
  524. package/src/components/rich-text-area/plugins/index.ts +10 -0
  525. package/src/components/rich-text-area/plugins/markdown-plain-paste-plugin.tsx +63 -0
  526. package/src/components/rich-text-area/plugins/value-plugin.tsx +46 -0
  527. package/src/components/rich-text-area/rich-text-area.json +102 -0
  528. package/src/components/rich-text-area/rich-text-area.stories.tsx +140 -0
  529. package/src/components/rich-text-area/rich-text-area.tsx +156 -0
  530. package/src/components/rich-text-area/styled.tsx +20 -0
  531. package/src/components/rich-text-area/transformers.ts +175 -0
  532. package/src/components/rich-text-area/types.ts +8 -0
  533. package/src/components/rich-text-area/utils/index.ts +77 -0
  534. package/src/components/rich-text-field/components/alignment-select.tsx +103 -0
  535. package/src/components/rich-text-field/components/attachment-button.tsx +25 -0
  536. package/src/components/rich-text-field/components/bold-button.tsx +21 -0
  537. package/src/components/rich-text-field/components/clean-format-button.tsx +44 -0
  538. package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +69 -0
  539. package/src/components/rich-text-field/components/image-button.tsx +11 -0
  540. package/src/components/rich-text-field/components/index.ts +14 -0
  541. package/src/components/rich-text-field/components/italic-button.tsx +21 -0
  542. package/src/components/rich-text-field/components/link-button.tsx +11 -0
  543. package/src/components/rich-text-field/components/size-select.tsx +27 -0
  544. package/src/components/rich-text-field/components/text-color-button.tsx +41 -0
  545. package/src/components/rich-text-field/components/toolbar-button.tsx +27 -0
  546. package/src/components/rich-text-field/components/toolbar-select.tsx +19 -0
  547. package/src/components/rich-text-field/components/typography-select.tsx +27 -0
  548. package/src/components/rich-text-field/components/underline-button.tsx +21 -0
  549. package/src/components/rich-text-field/constants.ts +33 -0
  550. package/src/components/rich-text-field/context.tsx +251 -0
  551. package/src/components/rich-text-field/index.tsx +6 -0
  552. package/src/components/rich-text-field/rich-text-field.json +118 -0
  553. package/src/components/rich-text-field/rich-text-field.stories.tsx +218 -0
  554. package/src/components/rich-text-field/rich-text-field.tsx +93 -0
  555. package/src/components/rich-text-field/utils.ts +532 -0
  556. package/src/components/spinner/index.ts +1 -0
  557. package/src/components/spinner/spinner.json +73 -0
  558. package/src/components/spinner/spinner.stories.tsx +41 -0
  559. package/src/components/spinner/spinner.tsx +32 -0
  560. package/src/contexts/chat-context/chat-context.tsx +97 -0
  561. package/src/contexts/chat-context/index.ts +1 -0
  562. package/src/contexts/chat-context/utils.ts +7 -0
  563. package/src/contexts/chat-conversation-context/chat-conversation-context.tsx +608 -0
  564. package/src/contexts/chat-conversation-context/index.ts +1 -0
  565. package/src/contexts/index.ts +2 -0
  566. package/src/docs/agent.stories.tsx +567 -0
  567. package/src/docs/chat-panel.tsx +174 -0
  568. package/src/docs/chatbot-panel.tsx +381 -0
  569. package/src/docs/chatbot.mdx +144 -0
  570. package/src/docs/chatbot.stories.tsx +63 -0
  571. package/src/domain/actions/constants.ts +1 -0
  572. package/src/domain/actions/hooks/index.ts +22 -0
  573. package/src/domain/actions/index.ts +4 -0
  574. package/src/domain/actions/types.ts +6 -0
  575. package/src/domain/actions/utils/index.ts +112 -0
  576. package/src/domain/index.ts +1 -0
  577. package/src/hooks/index.tsx +10 -0
  578. package/src/hooks/use-chat-prompt-placeholder.ts +7 -0
  579. package/src/hooks/use-chat-stream-message.ts +189 -0
  580. package/src/hooks/use-current-chat-id.ts +6 -0
  581. package/src/hooks/use-is-current-chat-new.ts +6 -0
  582. package/src/hooks/use-loaded-chat-ids.ts +32 -0
  583. package/src/hooks/use-on-chat-changed.ts +33 -0
  584. package/src/index.css +1 -0
  585. package/src/index.ts +6 -0
  586. package/src/layouts/chat-card-list-layout/__tests__/chat-card-list-layout.spec.tsx +204 -0
  587. package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +116 -0
  588. package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +190 -0
  589. package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +250 -0
  590. package/src/layouts/chat-card-list-layout/index.ts +11 -0
  591. package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.sizing.test.ts +73 -0
  592. package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.spec.tsx +282 -0
  593. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +131 -0
  594. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.ts +78 -0
  595. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +273 -0
  596. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.tsx +291 -0
  597. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.ts +135 -0
  598. package/src/layouts/chat-card-three-column-layout/index.ts +24 -0
  599. package/src/layouts/chat-card-two-column-layout/__tests__/chat-card-two-column-layout.spec.tsx +109 -0
  600. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +97 -0
  601. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.ts +21 -0
  602. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +138 -0
  603. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +132 -0
  604. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.ts +65 -0
  605. package/src/layouts/chat-card-two-column-layout/index.ts +17 -0
  606. package/src/layouts/index.ts +3 -0
  607. package/src/types.ts +29 -0
  608. package/src/utils/use-streaming-markdown.ts +113 -0
  609. package/tailwind.css +7 -0
@@ -0,0 +1,4404 @@
1
+ import { Slot as e } from "@radix-ui/react-slot";
2
+ import t, { Children as n, cloneElement as r, createContext as i, forwardRef as a, isValidElement as o, memo as s, useCallback as c, useContext as l, useEffect as u, useId as d, useImperativeHandle as f, useLayoutEffect as p, useMemo as m, useRef as h, useState as g } from "react";
3
+ import { Button as _, Checkbox as v, Chip as y, Collapsible as b, CollapsibleContent as x, CollapsibleTrigger as S, Divider as C, EmptyState as w, EmptyStateActionRow as T, EmptyStateDescription as E, EmptyStateIcon as ee, EmptyStateTitle as te, IconButton as D, Menu as O, MenuProvider as k, MenuTrigger as A, Popover as ne, PopoverContent as re, PopoverTrigger as j, ScrollArea as ie, SelectField as M, Skeleton as ae, Tooltip as N, Typography as P, cn as F, useIsResolution as oe } from "@swisper.ai/ui";
4
+ import { cn as I, useElementMeasure as L } from "@swisper.ai/web-core";
5
+ import { Fragment as R, jsx as z, jsxs as B } from "react/jsx-runtime";
6
+ import { cva as V } from "class-variance-authority";
7
+ import { AttachmentsIcon as se, ChevronDownIcon as H, ChevronUpIcon as ce, CloseIcon as U, CodeIcon as le, DeleteIcon as ue, DocIcon as de, DraftIcon as fe, FormatAlignCenterIcon as pe, FormatAlignLeftIcon as me, FormatAlignRightIcon as he, FormatBoldIcon as ge, FormatCleanIcon as _e, FormatColorIcon as ve, FormatItalicIcon as ye, FormatUnderlineIcon as be, ImageIcon as xe, LinkOffIcon as Se, LinkOnIcon as Ce, MoreHorizontalIcon as we, OpenInFullIcon as Te, PdfIcon as Ee, PptIcon as De, SignalReadIcon as Oe, SignalUnreadIcon as ke, SnoozeIcon as Ae, XlsIcon as je } from "@swisper.ai/icons";
8
+ import { CodeNode as Me } from "@lexical/code";
9
+ import { $isLinkNode as Ne, LinkNode as Pe, TOGGLE_LINK_COMMAND as Fe } from "@lexical/link";
10
+ import { $createListItemNode as Ie, $createListNode as Le, ListItemNode as Re, ListNode as ze } from "@lexical/list";
11
+ import { LexicalComposer as Be } from "@lexical/react/LexicalComposer";
12
+ import { ContentEditable as Ve } from "@lexical/react/LexicalContentEditable";
13
+ import { LexicalErrorBoundary as He } from "@lexical/react/LexicalErrorBoundary";
14
+ import { HistoryPlugin as Ue } from "@lexical/react/LexicalHistoryPlugin";
15
+ import { RichTextPlugin as We } from "@lexical/react/LexicalRichTextPlugin";
16
+ import { $createHeadingNode as Ge, HeadingNode as Ke, QuoteNode as qe } from "@lexical/rich-text";
17
+ import { useLexicalComposerContext as Je } from "@lexical/react/LexicalComposerContext";
18
+ import { $convertFromMarkdownString as Ye, $convertToMarkdownString as Xe, TRANSFORMERS as Ze, TRANSFORMERS as Qe } from "@lexical/markdown";
19
+ import { $addUpdateTag as $e, $createParagraphNode as et, $createRangeSelection as tt, $createTextNode as nt, $getPreviousSelection as rt, $getRoot as W, $getSelection as G, $insertNodes as it, $isElementNode as at, $isParagraphNode as ot, $isRangeSelection as K, $isTextNode as q, $selectAll as st, $setSelection as ct, $setState as lt, COMMAND_PRIORITY_CRITICAL as ut, COMMAND_PRIORITY_EDITOR as dt, COMMAND_PRIORITY_LOW as ft, DecoratorNode as pt, ElementNode as mt, FORMAT_ELEMENT_COMMAND as ht, FORMAT_TEXT_COMMAND as gt, PASTE_COMMAND as _t, SELECTION_CHANGE_COMMAND as vt, SKIP_DOM_SELECTION_TAG as yt, SKIP_SELECTION_FOCUS_TAG as bt, createCommand as xt, createState as St, isHTMLElement as Ct, setNodeIndentFromDOM as wt } from "lexical";
20
+ import { OnChangePlugin as Tt } from "@lexical/react/LexicalOnChangePlugin";
21
+ import { createPortal as Et } from "react-dom";
22
+ import { useVirtualizer as Dt } from "@tanstack/react-virtual";
23
+ import * as J from "@radix-ui/react-scroll-area";
24
+ import { nanoid as Ot } from "nanoid";
25
+ import kt from "mime";
26
+ import { Streamdown as At, defaultRehypePlugins as jt, defaultRemarkPlugins as Mt } from "streamdown";
27
+ import Nt, { defaultSchema as Pt } from "rehype-sanitize";
28
+ import "katex/dist/katex.min.css";
29
+ import { StickToBottom as Ft, useStickToBottom as It } from "use-stick-to-bottom";
30
+ import { MessageScroller as Lt, useMessageScroller as Rt, useMessageScrollerScrollable as zt } from "@shadcn/react/message-scroller";
31
+ import * as Bt from "@radix-ui/react-roving-focus";
32
+ import { AnimatePresence as Vt, motion as Ht } from "motion/react";
33
+ import { TablePlugin as Ut } from "@lexical/react/LexicalTablePlugin";
34
+ import { TableCellNode as Wt, TableNode as Gt, TableRowNode as Kt } from "@lexical/table";
35
+ import { $generateHtmlFromNodes as qt, $generateNodesFromDOM as Jt } from "@lexical/html";
36
+ import { EditorRefPlugin as Yt } from "@lexical/react/LexicalEditorRefPlugin";
37
+ import { $getNearestBlockElementAncestorOrThrow as Xt, mergeRegister as Zt } from "@lexical/utils";
38
+ import { $forEachSelectedTextNode as Qt, $getSelectionStyleValueForProperty as $t, $isAtNodeEnd as en, $patchStyleText as tn } from "@lexical/selection";
39
+ import "@lexical/react/LexicalDecoratorBlockNode";
40
+ import nn from "inline-style-parser";
41
+ import { DotLottieReact as rn } from "@lottiefiles/dotlottie-react";
42
+ import an from "remark-gfm";
43
+ import on from "remark-parse";
44
+ import { unified as sn } from "unified";
45
+ import { visit as cn } from "unist-util-visit";
46
+ import { createParser as ln } from "eventsource-parser";
47
+ //#region src/layouts/chat-card-list-layout/chat-card-list-layout.tsx
48
+ var un = 3, dn = i(null);
49
+ function fn() {
50
+ let e = l(dn);
51
+ if (!e) throw Error("[web-chat-ui] \"useChatCardListLayoutContext\" must be used within a ChatCardListLayout. ChatCardListLayoutItems and ChatCardListLayoutShowMore both read it, so both must be rendered inside the ChatCardListLayout element, not as siblings of it.");
52
+ return e;
53
+ }
54
+ var pn = a(function({ children: t, className: n, visibleCount: r = un, defaultExpanded: i = !1, expanded: a, onExpandedChange: o, asChild: s = !1, ...l }, u) {
55
+ let [d, f] = g(i), [p, h] = g(0), _ = a ?? d, v = c(() => {
56
+ a === void 0 && f(!0), o?.(!0);
57
+ }, [a, o]), y = m(() => ({
58
+ visibleCount: Math.max(0, r),
59
+ isExpanded: _,
60
+ expand: v,
61
+ hiddenCount: p,
62
+ setHiddenCount: h
63
+ }), [
64
+ r,
65
+ _,
66
+ v,
67
+ p
68
+ ]), b = s ? e : "div";
69
+ return /* @__PURE__ */ z(dn.Provider, {
70
+ value: y,
71
+ children: /* @__PURE__ */ z(b, {
72
+ ref: u,
73
+ "data-testid": "chat-card-list-layout",
74
+ "data-expanded": _,
75
+ className: I("group/chat-card-list-layout", "flex flex-col items-start gap-[8px]", n),
76
+ ...l,
77
+ children: t
78
+ })
79
+ });
80
+ });
81
+ pn.displayName = "ChatCardListLayout";
82
+ function mn({ children: e }) {
83
+ let { visibleCount: t, isExpanded: r, setHiddenCount: i } = fn(), a = n.toArray(e), o = r ? 0 : Math.max(0, a.length - t);
84
+ return p(() => {
85
+ i(o);
86
+ }, [o, i]), /* @__PURE__ */ z(R, { children: r ? a : a.slice(0, t) });
87
+ }
88
+ var hn = a(function({ children: e, onClick: t, className: n, ...r }, i) {
89
+ let { isExpanded: a, hiddenCount: o, expand: s } = fn();
90
+ function c(e) {
91
+ s(), t?.(e);
92
+ }
93
+ return a || o === 0 ? null : /* @__PURE__ */ z(_, {
94
+ ref: i,
95
+ variant: "tertiary",
96
+ size: "sm",
97
+ "data-testid": "chat-card-list-layout-show-more",
98
+ onClick: c,
99
+ className: I("mx-auto", n),
100
+ ...r,
101
+ children: e
102
+ });
103
+ });
104
+ hn.displayName = "ChatCardListLayoutShowMore";
105
+ function gn(e) {
106
+ return e >= 1132 ? "xl" : e >= 698 ? "lg" : e >= 640 ? "md" : "sm";
107
+ }
108
+ function _n(e, t) {
109
+ let n = e === "unset" ? "xl" : gn(e);
110
+ return {
111
+ size: n,
112
+ isListFloating: n === "sm" || n === "md",
113
+ isDetailsFloating: t === "floating" || n !== "xl",
114
+ isDetailsSheet: n === "sm"
115
+ };
116
+ }
117
+ //#endregion
118
+ //#region src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.ts
119
+ var vn = "responsive", yn = V([
120
+ "relative grid gap-[8px]",
121
+ "grid-cols-[1fr] [grid-template-areas:'main']",
122
+ "data-[size=lg]:grid-cols-[290px_1fr] data-[size=lg]:[grid-template-areas:'list_main']",
123
+ "data-[size=xl]:grid-cols-[358px_1fr] data-[size=xl]:[grid-template-areas:'list_main']",
124
+ "data-[details-floating=false]:has-[>[data-slot=chat-card-three-column-layout-details]]:grid-cols-[358px_1fr_358px]",
125
+ "data-[details-floating=false]:has-[>[data-slot=chat-card-three-column-layout-details]]:[grid-template-areas:'list_main_details']"
126
+ ]), bn = V([
127
+ "min-w-0",
128
+ "data-[floating=true]:absolute data-[floating=true]:bottom-0 data-[floating=true]:inset-x-0 data-[floating=true]:z-10",
129
+ "data-[floating=false]:[grid-area:list] data-[floating=false]:min-h-0 data-[floating=false]:h-full data-[floating=false]:overflow-hidden"
130
+ ]), xn = V(["[grid-area:main] relative min-w-0 min-h-0 h-full"]), Sn = V([
131
+ "min-h-0 min-w-0 max-w-full",
132
+ "data-[floating=false]:[grid-area:details] data-[floating=false]:h-full",
133
+ "data-[floating=true]:z-20 data-[floating=true]:[grid-area:main]",
134
+ "data-[floating=true]:data-[sheet=false]:w-[358px] data-[floating=true]:data-[sheet=false]:h-full data-[floating=true]:data-[sheet=false]:justify-self-end data-[floating=true]:data-[sheet=false]:self-stretch data-[floating=true]:data-[sheet=false]:p-[12px]",
135
+ "data-[sheet=true]:w-full data-[sheet=true]:h-[85%] data-[sheet=true]:justify-self-start data-[sheet=true]:self-end"
136
+ ]), Cn = V([
137
+ "relative z-30 min-w-0 min-h-0 h-full p-[12px] row-1",
138
+ "data-[list-floating=false]:col-[2/-1]",
139
+ "data-[list-floating=true]:col-span-full"
140
+ ]), wn = V(["data-[state=open]:w-(--message-list-content-width) data-[state=open]:mx-0", "data-[state=open]:min-w-[min(1432px,calc(var(--chat-window-width,100%)-var(--spacing-message)*2))]"]), Tn = i(null);
141
+ function En(e) {
142
+ let t = l(Tn);
143
+ if (!t) throw Error(`[web-chat-ui] "${e}" must be used within a ChatCardThreeColumnLayout. It reads its floating state from the layout, so render it as a child of the ChatCardThreeColumnLayout element, not as a sibling of it.`);
144
+ return t;
145
+ }
146
+ function Dn(e, t) {
147
+ return typeof e == "function" ? e(t) : e;
148
+ }
149
+ function On(e, t) {
150
+ return c((n) => {
151
+ e(n), typeof t == "function" ? t(n) : t && (t.current = n);
152
+ }, [e, t]);
153
+ }
154
+ var kn = a(function({ children: t, className: n, detailsPlacement: r = vn, asChild: i = !1, ...a }, o) {
155
+ let { ref: s, width: c } = L(), l = On(s, o), { size: u, isListFloating: d, isDetailsFloating: f, isDetailsSheet: p } = _n(c, r), h = m(() => ({
156
+ isListFloating: d,
157
+ isDetailsFloating: f,
158
+ isDetailsSheet: p
159
+ }), [
160
+ d,
161
+ f,
162
+ p
163
+ ]), g = i ? e : "div";
164
+ return /* @__PURE__ */ z(Tn.Provider, {
165
+ value: h,
166
+ children: /* @__PURE__ */ z(g, {
167
+ ref: l,
168
+ "data-testid": "chat-card-three-column-layout",
169
+ "data-slot": "chat-card-three-column-layout",
170
+ "data-details-placement": r,
171
+ "data-size": u,
172
+ "data-list-floating": d,
173
+ "data-details-floating": f,
174
+ className: I(yn(), n),
175
+ ...a,
176
+ children: t
177
+ })
178
+ });
179
+ });
180
+ kn.displayName = "ChatCardThreeColumnLayout";
181
+ var An = a(function({ children: t, className: n, asChild: r = !1, ...i }, a) {
182
+ let { isListFloating: o } = En("ChatCardThreeColumnLayoutList");
183
+ return /* @__PURE__ */ z(r ? e : "aside", {
184
+ ref: a,
185
+ "data-testid": "chat-card-three-column-layout-list",
186
+ "data-slot": "chat-card-three-column-layout-list",
187
+ "data-floating": o,
188
+ className: I(bn(), n),
189
+ ...i,
190
+ children: Dn(t, o)
191
+ });
192
+ });
193
+ An.displayName = "ChatCardThreeColumnLayoutList";
194
+ var jn = a(function({ children: t, className: n, asChild: r = !1, ...i }, a) {
195
+ return En("ChatCardThreeColumnLayoutMain"), /* @__PURE__ */ z(r ? e : "main", {
196
+ ref: a,
197
+ "data-testid": "chat-card-three-column-layout-main",
198
+ "data-slot": "chat-card-three-column-layout-main",
199
+ className: I(xn(), n),
200
+ ...i,
201
+ children: t
202
+ });
203
+ });
204
+ jn.displayName = "ChatCardThreeColumnLayoutMain";
205
+ var Mn = a(function({ children: t, className: n, asChild: r = !1, ...i }, a) {
206
+ let { isDetailsFloating: o, isDetailsSheet: s } = En("ChatCardThreeColumnLayoutDetails");
207
+ return /* @__PURE__ */ z(r ? e : "aside", {
208
+ ref: a,
209
+ "data-testid": "chat-card-three-column-layout-details",
210
+ "data-slot": "chat-card-three-column-layout-details",
211
+ "data-floating": o,
212
+ "data-sheet": s,
213
+ className: I(Sn(), n),
214
+ ...i,
215
+ children: Dn(t, o)
216
+ });
217
+ });
218
+ Mn.displayName = "ChatCardThreeColumnLayoutDetails";
219
+ var Nn = a(function({ children: t, className: n, asChild: r = !1, ...i }, a) {
220
+ let { isListFloating: o } = En("ChatCardThreeColumnLayoutPanel");
221
+ return /* @__PURE__ */ z(r ? e : "section", {
222
+ ref: a,
223
+ "data-testid": "chat-card-three-column-layout-panel",
224
+ "data-slot": "chat-card-three-column-layout-panel",
225
+ "data-list-floating": o,
226
+ className: I(Cn(), n),
227
+ ...i,
228
+ children: t
229
+ });
230
+ });
231
+ Nn.displayName = "ChatCardThreeColumnLayoutPanel";
232
+ //#endregion
233
+ //#region src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.ts
234
+ var Pn = V(["@container/chat-card-two-column-layout"]), Fn = V([
235
+ "grid h-full gap-16",
236
+ "grid-cols-[minmax(0,1fr)] grid-rows-[auto_1fr]",
237
+ "@[744px]/chat-card-two-column-layout:grid-cols-[336px_minmax(0,1fr)] @[744px]/chat-card-two-column-layout:grid-rows-[minmax(0,1fr)]"
238
+ ]), In = V(["min-w-0 min-h-0", "@[744px]/chat-card-two-column-layout:h-full @[744px]/chat-card-two-column-layout:overflow-hidden"]), Ln = V(["relative min-w-0 min-h-0 h-full"]), Rn = V(["data-[state=open]:w-full data-[state=open]:mx-0", "data-[state=open]:min-w-[min(1130px,calc(var(--chat-window-width,100%)-var(--spacing-message)*2))]"]), zn = i(!1);
239
+ function Bn(e) {
240
+ if (!l(zn)) throw Error(`[web-chat-ui] "${e}" must be used within a ChatCardTwoColumnLayout. Its columns come from the layout’s container query, so render it as a child of the ChatCardTwoColumnLayout element, not as a sibling of it.`);
241
+ }
242
+ var Vn = a(function({ children: t, className: n, asChild: r = !1, ...i }, a) {
243
+ let o = r ? e : "div";
244
+ return /* @__PURE__ */ z(zn.Provider, {
245
+ value: !0,
246
+ children: /* @__PURE__ */ z(o, {
247
+ ref: a,
248
+ "data-testid": "chat-card-two-column-layout",
249
+ "data-slot": "chat-card-two-column-layout",
250
+ className: I(Pn(), n),
251
+ ...i,
252
+ children: /* @__PURE__ */ z("div", {
253
+ "data-testid": "chat-card-two-column-layout-grid",
254
+ "data-slot": "chat-card-two-column-layout-grid",
255
+ className: Fn(),
256
+ children: t
257
+ })
258
+ })
259
+ });
260
+ });
261
+ Vn.displayName = "ChatCardTwoColumnLayout";
262
+ var Hn = a(function({ children: t, className: n, asChild: r = !1, ...i }, a) {
263
+ return Bn("ChatCardTwoColumnLayoutAside"), /* @__PURE__ */ z(r ? e : "aside", {
264
+ ref: a,
265
+ "data-testid": "chat-card-two-column-layout-aside",
266
+ "data-slot": "chat-card-two-column-layout-aside",
267
+ className: I(In(), n),
268
+ ...i,
269
+ children: t
270
+ });
271
+ });
272
+ Hn.displayName = "ChatCardTwoColumnLayoutAside";
273
+ var Un = a(function({ children: t, className: n, asChild: r = !1, ...i }, a) {
274
+ return Bn("ChatCardTwoColumnLayoutMain"), /* @__PURE__ */ z(r ? e : "main", {
275
+ ref: a,
276
+ "data-testid": "chat-card-two-column-layout-main",
277
+ "data-slot": "chat-card-two-column-layout-main",
278
+ className: I(Ln(), n),
279
+ ...i,
280
+ children: t
281
+ });
282
+ });
283
+ Un.displayName = "ChatCardTwoColumnLayoutMain";
284
+ //#endregion
285
+ //#region src/components/chat-card/context.tsx
286
+ var Wn = i(null);
287
+ function Y() {
288
+ let e = l(Wn);
289
+ if (!e) throw Error("[web-chat-ui] useChatCardContext() called outside ChatCard. Wrap this component in <ChatCard>, or the provider and the caller resolved two copies of the package.");
290
+ return e;
291
+ }
292
+ function Gn({ value: e, children: t }) {
293
+ return /* @__PURE__ */ z(Wn.Provider, {
294
+ value: e,
295
+ children: t
296
+ });
297
+ }
298
+ //#endregion
299
+ //#region src/components/chat-card/components/chat-card-header.tsx
300
+ function Kn({ className: e, children: t, ...n }) {
301
+ let { isCollapsible: r, level: i } = Y(), a = /* @__PURE__ */ z("div", {
302
+ "data-slot": "chat-card-header-hover-area",
303
+ className: I("w-full", "flex flex-row items-start", "gap-card-header-gap", i === 1 && "px-card-header-hover-area rounded-card-header", i === 1 && r && "hover:bg-layout-accent-low-background-hover-base", i === 1 && "group-hover/chat-card:bg-layout-accent-low-background-hover-base", !r && "cursor-default"),
304
+ children: t
305
+ });
306
+ return /* @__PURE__ */ z("header", {
307
+ "data-slot": "chat-card-header",
308
+ className: I("flex items-start", i === 1 ? "p-card-header-lvl-1" : "px-card-header-lvl-2", e),
309
+ ...n,
310
+ children: r ? /* @__PURE__ */ z(S, {
311
+ className: "w-full",
312
+ asChild: !0,
313
+ children: a
314
+ }) : a
315
+ });
316
+ }
317
+ function qn({ className: e, children: t, ...n }) {
318
+ let { level: r } = Y();
319
+ return /* @__PURE__ */ z("div", {
320
+ "data-testid": "chat-card-icon",
321
+ className: I("shrink-0", "inline-flex items-center justify-center self-center", "size-[32px]", "bg-avatar-background", "rounded-full overflow-hidden", r === 1 ? "my-[14px]" : "my-4", e),
322
+ ...n,
323
+ children: t
324
+ });
325
+ }
326
+ function Jn({ className: e, children: t, ...n }) {
327
+ let { level: r } = Y();
328
+ return /* @__PURE__ */ z("div", {
329
+ "data-testid": "chat-card-header-content",
330
+ className: I("flex-1", "flex flex-col gap-0 items-start justify-center", r === 1 ? "min-h-[60px] py-1.5" : "min-h-[40px] py-4", e),
331
+ ...n,
332
+ children: t
333
+ });
334
+ }
335
+ function Yn({ className: e, children: t, ...n }) {
336
+ return /* @__PURE__ */ z(P, {
337
+ "data-testid": "chat-card-title",
338
+ variant: "body-medium",
339
+ className: I(e),
340
+ ...n,
341
+ children: t
342
+ });
343
+ }
344
+ function Xn({ className: e, children: t, ...n }) {
345
+ return /* @__PURE__ */ z(P, {
346
+ "data-testid": "chat-card-sub-title",
347
+ variant: "body-small-high",
348
+ className: I("text-text-secondary", e),
349
+ ...n,
350
+ children: t
351
+ });
352
+ }
353
+ function Zn({ className: e, children: t, ...n }) {
354
+ let { level: r } = Y();
355
+ return /* @__PURE__ */ z("div", {
356
+ role: "group",
357
+ "data-testid": "chat-card-actions",
358
+ className: I("ml-auto shrink-0", "flex items-center self-center gap-card-header-gap-icon-buttons", "min-h-[32px]", "[&>button]:text-secondary-main!", r === 1 ? "my-[14px]" : "my-4", e),
359
+ ...n,
360
+ children: t
361
+ });
362
+ }
363
+ function Qn({ className: e, children: t, shouldPreventCollapse: n = !0, tooltip: r, onClick: i, ...a }) {
364
+ function o(e) {
365
+ n && e.stopPropagation(), i?.(e);
366
+ }
367
+ let s = /* @__PURE__ */ z(D, {
368
+ variant: "tertiary",
369
+ size: "sm",
370
+ className: I(e),
371
+ onClick: o,
372
+ ...a,
373
+ children: t
374
+ });
375
+ return r ? /* @__PURE__ */ z(N, {
376
+ tooltip: r,
377
+ children: s
378
+ }) : s;
379
+ }
380
+ function $n({ className: e, ...t }) {
381
+ let { isCollapsible: n } = Y();
382
+ if (n) return /* @__PURE__ */ z(Qn, {
383
+ shouldPreventCollapse: !1,
384
+ isSemantic: !1,
385
+ className: I(e, "transition-transform duration-300", "group-data-[state=open]/collapsible:rotate-180"),
386
+ ...t,
387
+ children: /* @__PURE__ */ z(H, {})
388
+ });
389
+ }
390
+ //#endregion
391
+ //#region src/components/chat-card/components/chat-card-body.tsx
392
+ function er({ className: e, children: t, ...n }) {
393
+ return /* @__PURE__ */ z("figure", {
394
+ "data-testid": "chat-card-media",
395
+ className: I("min-h-0 shrink-0 h-[222px]", e),
396
+ ...n,
397
+ children: t
398
+ });
399
+ }
400
+ function tr({ className: t, children: n, asChild: r = !1, ...i }) {
401
+ let a = r ? e : "div";
402
+ return /* @__PURE__ */ z(x, {
403
+ "data-testid": "chat-card-body",
404
+ className: I("flex flex-1 flex-col", "min-h-0", "md:group-data-[collapsible=true]/chat-card:max-h-[90vh]", "overflow-hidden", t),
405
+ asChild: !0,
406
+ ...i,
407
+ children: /* @__PURE__ */ z(a, { children: n })
408
+ });
409
+ }
410
+ function nr({ className: t, children: n, asChild: r = !1, hasPadding: i = !0, hasHeaderPadding: a = !0, ...o }) {
411
+ let { level: s } = Y();
412
+ return /* @__PURE__ */ z(r ? e : "div", {
413
+ "data-testid": "chat-card-content",
414
+ "data-padding": i,
415
+ "data-has-header-padding": a,
416
+ "data-level": s,
417
+ className: I("overflow-auto", "gap-card-slots-gap", "data-[level=1]:p-card-slots-lvl-1", "data-[level=2]:p-card-slots-lvl-2", "data-[has-header-padding=false]:pt-0", "data-[padding=false]:p-0", t),
418
+ ...o,
419
+ children: n
420
+ });
421
+ }
422
+ function rr({ className: e, children: t, ...n }) {
423
+ let { level: r } = Y();
424
+ return /* @__PURE__ */ z("div", {
425
+ "data-testid": "chat-card-preview",
426
+ "data-level": r,
427
+ className: I("group-data-[state=open]/collapsible:hidden", "overflow-auto", "pt-0", "data-[level=1]:p-card-slots-lvl-1", "data-[level=2]:p-card-slots-lvl-2", e),
428
+ ...n,
429
+ children: t
430
+ });
431
+ }
432
+ //#endregion
433
+ //#region src/components/chat-card/components/chat-card-footer.tsx
434
+ function ir({ className: e, children: t, ...n }) {
435
+ let { level: r } = Y();
436
+ return /* @__PURE__ */ z("footer", {
437
+ "data-slot": "chat-card-footer",
438
+ "data-level": r,
439
+ className: I("mt-auto", "flex flex-row items-center justify-end", "gap-card-footer-gap", "w-full", "data-[level=1]:p-card-footer-lvl-1", "data-[level=2]:p-card-footer-lvl-2", e),
440
+ ...n,
441
+ children: t
442
+ });
443
+ }
444
+ function ar({ className: e, children: t }) {
445
+ return /* @__PURE__ */ z("div", {
446
+ "data-testid": "chat-card-footer-notes",
447
+ className: I("mr-auto shrink-0", "flex flex-col items-start justify-center", "gap-card-footer-gap-left-notes", e),
448
+ children: t
449
+ });
450
+ }
451
+ function or({ className: e, children: t }) {
452
+ return /* @__PURE__ */ z("div", {
453
+ "data-testid": "chat-card-footer-price",
454
+ className: I("flex flex-col items-end justify-center", "gap-card-footer-gap-prices", "shrink-0", e),
455
+ children: t
456
+ });
457
+ }
458
+ function sr({ className: e, children: t, ...n }) {
459
+ return /* @__PURE__ */ z("div", {
460
+ role: "group",
461
+ "data-testid": "chat-card-footer-actions",
462
+ className: I("flex items-center gap-card-footer-gap shrink-0", e),
463
+ ...n,
464
+ children: t
465
+ });
466
+ }
467
+ //#endregion
468
+ //#region src/components/chat-card/components/chat-card-form.tsx
469
+ var cr = a(function({ className: t, children: n, asChild: r, ...i }, a) {
470
+ return /* @__PURE__ */ z(r ? e : "form", {
471
+ ref: a,
472
+ "data-testid": "chat-card-form",
473
+ className: I("bg-steel-900 border border-steel-700", "rounded-[12px]", "m-8 mb-16 p-[12px]", "overflow-hidden", t),
474
+ ...i,
475
+ children: n
476
+ });
477
+ });
478
+ function lr({ className: e, children: t }) {
479
+ return /* @__PURE__ */ z("ul", {
480
+ "data-testid": "chat-card-attributes",
481
+ className: I("flex flex-col justify-start items-start gap-8", "mb-24", e),
482
+ children: t
483
+ });
484
+ }
485
+ function ur({ className: e, children: t, ...n }) {
486
+ return /* @__PURE__ */ z("li", {
487
+ "data-testid": "chat-card-attribute-item",
488
+ className: I("grid grid-cols-[66px_1fr] gap-8", "w-full", "min-h-24", e),
489
+ ...n,
490
+ children: t
491
+ });
492
+ }
493
+ function dr({ className: e, children: t, hasPadding: n = !1, ...r }) {
494
+ return /* @__PURE__ */ z(y, {
495
+ variant: "outlined",
496
+ size: "md",
497
+ color: "info",
498
+ "data-has-padding": n,
499
+ className: I("w-full", "data-[has-padding=true]:my-[5px]", e),
500
+ "data-testid": "chat-card-attribute-label",
501
+ ...r,
502
+ children: t
503
+ });
504
+ }
505
+ function fr({ className: t, children: n, asChild: r = !1, ...i }) {
506
+ return /* @__PURE__ */ z(r ? e : P, {
507
+ "data-testid": "chat-card-attribute-value",
508
+ variant: "body-sm",
509
+ className: I("flex-1 text-text-secondary", t),
510
+ ...i,
511
+ children: n
512
+ });
513
+ }
514
+ //#endregion
515
+ //#region src/components/chat-card/chat-card.tsx
516
+ var pr = a(function({ className: e, variant: t = "default", level: n = 1, children: r, fullWidth: i = !1, defaultOpen: a = !0, open: o, isRounded: s = !0, isCollapsible: l = !0, isSelected: u = !1, onOpenChange: d, onClick: f, ...p }, h) {
517
+ let _ = o !== void 0, [v, y] = g(a), x = _ ? o : v, S = c((e) => {
518
+ _ || y(e), d?.(e);
519
+ }, [_, d]), C = m(() => ({
520
+ isCollapsible: l,
521
+ level: n,
522
+ open: x
523
+ }), [
524
+ l,
525
+ n,
526
+ x
527
+ ]);
528
+ function w(e) {
529
+ f?.(e), !e.defaultPrevented && l && !x && S(!0);
530
+ }
531
+ return /* @__PURE__ */ z(Gn, {
532
+ value: C,
533
+ children: /* @__PURE__ */ z(b, {
534
+ isDisabled: !l,
535
+ open: x,
536
+ onOpenChange: S,
537
+ asChild: !0,
538
+ children: /* @__PURE__ */ z("section", {
539
+ ref: h,
540
+ role: "region",
541
+ "aria-current": u,
542
+ "data-testid": "chat-card",
543
+ "data-variant": t,
544
+ "data-level": n,
545
+ "data-full-width": i,
546
+ "data-rounded": s,
547
+ "data-selected": u,
548
+ "data-collapsible": l,
549
+ onClick: w,
550
+ className: I("group/chat-card", "w-full data-[state=closed]:max-w-(--message-list-content-width) data-[state=closed]:mx-auto", "flex flex-col", "relative overflow-hidden", "border border-solid border-card-border-base", "data-[level=1]:bg-card-background-base", "data-[level=2]:bg-card-background-lvl-2", "data-[full-width=true]:w-full", "data-[level=1]:data-[rounded=true]:rounded-card-lvl-1", "data-[level=2]:data-[rounded=true]:rounded-card-lvl-2", "data-[selected=true]:border-primary-main", "hover:data-[variant=action]:bg-secondary-states-hover", "data-[collapsible=true]:data-[state=closed]:cursor-pointer", e),
551
+ ...p,
552
+ children: r
553
+ })
554
+ })
555
+ });
556
+ });
557
+ pr.displayName = "ChatCard";
558
+ //#endregion
559
+ //#region src/components/chat-card/hooks.ts
560
+ function mr({ isEditable: e, defaultEditing: t = !1 }) {
561
+ let [n, r] = g(t);
562
+ function i() {
563
+ return e ? !0 : (console.warn("Chat card is not editable"), !1);
564
+ }
565
+ function a() {
566
+ i() && r(!0);
567
+ }
568
+ function o() {
569
+ i() && r(!1);
570
+ }
571
+ function s() {
572
+ i() && r((e) => !e);
573
+ }
574
+ return {
575
+ isEditable: e,
576
+ isEditing: n,
577
+ startEdit: a,
578
+ discard: o,
579
+ toggleEdit: s
580
+ };
581
+ }
582
+ //#endregion
583
+ //#region src/components/chat-card/contexts.tsx
584
+ var hr = i(null);
585
+ function gr() {
586
+ let e = l(hr);
587
+ if (!e) throw Error("\"useEditableChatCardContext\" must be used within a EditableChatCardContextProvider");
588
+ return e;
589
+ }
590
+ function _r({ children: e, defaultEditing: t = !1, isEditable: n = !1 }) {
591
+ let r = mr({
592
+ isEditable: n,
593
+ defaultEditing: t
594
+ });
595
+ return /* @__PURE__ */ z(hr.Provider, {
596
+ value: r,
597
+ children: e
598
+ });
599
+ }
600
+ //#endregion
601
+ //#region src/components/chat-card-container/chat-card-container.tsx
602
+ function vr({ children: e, variant: t = "fixed", inline: n = !1, className: r, ...i }) {
603
+ return /* @__PURE__ */ z("div", {
604
+ "data-testid": "chat-card-container",
605
+ "data-variant": t,
606
+ "data-inline": n,
607
+ className: I("mx-auto w-full", "max-w-[calc(var(--chat-window-width,100%)-var(--spacing-message))]", "md:data-[variant=fixed]:max-w-[calc(var(--message-list-content-width,var(--spacing-chat-area))-var(--spacing-message))]", "md:data-[variant=fluid]:min-w-[calc(var(--message-list-content-width,var(--spacing-chat-area))-var(--spacing-message))]", "md:data-[variant=fluid]:w-fit", "md:data-[variant=full]:max-w-full", "data-[inline=true]:max-w-[var(--chat-window-width,100%)]", "data-[inline=true]:px-message", r),
608
+ ...i,
609
+ children: e
610
+ });
611
+ }
612
+ //#endregion
613
+ //#region src/components/chat-container/chat-container.tsx
614
+ var yr = "var(--spacing-chat-area)", br = {
615
+ prompt: "--type-window-height",
616
+ welcome: "--welcome-screen-box-height"
617
+ };
618
+ function xr(e) {
619
+ return e === "unset" ? "unset" : `${e}px`;
620
+ }
621
+ var Sr = i(null);
622
+ function Cr() {
623
+ let e = l(Sr);
624
+ if (!e) throw Error("[web-chat-ui] ChatContainer slot rendered outside a ChatContainer. ChatContainerPrompt and ChatContainerWelcome report their measured height up to the container, so one must be mounted above them. If it is mounted, check the slot is not rendered through a portal that escapes the provider.");
625
+ return e;
626
+ }
627
+ function wr({ asChild: t = !1, children: n, className: r, contentWidth: i = yr, style: a, ...o }) {
628
+ let s = t ? e : "section", { ref: l, width: u, height: d } = L(), [f, p] = g({
629
+ prompt: "unset",
630
+ welcome: "unset"
631
+ }), h = c((e, t) => {
632
+ p((n) => n[e] === t ? n : {
633
+ ...n,
634
+ [e]: t
635
+ });
636
+ }, []), _ = m(() => ({ setSlotHeight: h }), [h]), v = m(() => ({
637
+ "--chat-window-width": u === "unset" ? "100%" : `${u}px`,
638
+ "--chat-window-height": d === "unset" ? "100%" : `${d}px`,
639
+ "--message-list-content-width": `min(${i}, var(--chat-window-width))`,
640
+ [br.prompt]: xr(f.prompt),
641
+ [br.welcome]: xr(f.welcome),
642
+ ...a
643
+ }), [
644
+ u,
645
+ d,
646
+ i,
647
+ f,
648
+ a
649
+ ]);
650
+ return /* @__PURE__ */ z(Sr.Provider, {
651
+ value: _,
652
+ children: /* @__PURE__ */ z(s, {
653
+ ref: l,
654
+ "data-testid": "chat-container",
655
+ className: I("relative flex h-full min-h-0 w-full flex-col", r),
656
+ style: v,
657
+ ...o,
658
+ children: n
659
+ })
660
+ });
661
+ }
662
+ function Tr(e) {
663
+ let { setSlotHeight: t } = Cr(), { ref: n, height: r } = L();
664
+ return p(() => (t(e, r), () => t(e, "unset")), [
665
+ e,
666
+ r,
667
+ t
668
+ ]), n;
669
+ }
670
+ function Er({ asChild: t = !1, children: n, className: r, ...i }) {
671
+ let a = Tr("prompt");
672
+ return /* @__PURE__ */ z(t ? e : "div", {
673
+ ref: a,
674
+ "data-testid": "chat-container-prompt",
675
+ className: I("shrink-0", r),
676
+ ...i,
677
+ children: n
678
+ });
679
+ }
680
+ function Dr({ asChild: t = !1, children: n, className: r, ...i }) {
681
+ let a = Tr("welcome");
682
+ return /* @__PURE__ */ z(t ? e : "div", {
683
+ ref: a,
684
+ "data-testid": "chat-container-welcome",
685
+ className: I("shrink-0", r),
686
+ ...i,
687
+ children: n
688
+ });
689
+ }
690
+ //#endregion
691
+ //#region src/components/chat-input/plugins/auto-focus-plugin.tsx
692
+ function Or({ defaultSelection: e = "rootEnd", autoFocus: t, isDisabled: n }) {
693
+ let [r] = Je();
694
+ return u(() => {
695
+ t && !n && r.focus(() => {
696
+ let e = document.activeElement, t = r.getRootElement();
697
+ t !== null && (e === null || !t.contains(e)) && t.focus({ preventScroll: !0 });
698
+ }, { defaultSelection: e });
699
+ }, [
700
+ e,
701
+ r,
702
+ t,
703
+ n
704
+ ]), null;
705
+ }
706
+ //#endregion
707
+ //#region src/components/chat-input/transformers.ts
708
+ var kr = Ze, Ar = Ze;
709
+ //#endregion
710
+ //#region src/components/chat-input/plugins/hooks.ts
711
+ function jr() {
712
+ let [e] = Je();
713
+ return e;
714
+ }
715
+ //#endregion
716
+ //#region src/components/chat-input/plugins/utils.ts
717
+ function Mr() {
718
+ return W().getTextContent();
719
+ }
720
+ function Nr() {
721
+ let e = W().getLastDescendant();
722
+ if (e && q(e)) {
723
+ let t = tt(), n = e.getTextContentSize();
724
+ t.anchor.set(e.getKey(), n, "text"), t.focus.set(e.getKey(), n, "text"), ct(t);
725
+ } else {
726
+ st();
727
+ let e = G();
728
+ if (K(e)) {
729
+ let t = e.focus.getNode(), n = q(t) ? t.getTextContentSize() : 0;
730
+ e.anchor.set(e.focus.key, e.focus.offset, e.focus.type), e.focus.set(e.focus.key, n, e.focus.type), ct(e);
731
+ }
732
+ }
733
+ }
734
+ //#endregion
735
+ //#region src/components/chat-input/plugins/controlled-value-plugin.tsx
736
+ function Pr({ value: e }) {
737
+ let t = jr(), n = h();
738
+ return u(() => {
739
+ if (!t || e === n.current) return;
740
+ n.current = e;
741
+ let r = "";
742
+ t.getEditorState().read(() => {
743
+ r = Xe(kr);
744
+ }), e !== void 0 && e !== r && t.update(() => {
745
+ $e(yt), Ye(e ?? "", Ar), Nr();
746
+ }, { discrete: !0 });
747
+ }, [t, e]), null;
748
+ }
749
+ //#endregion
750
+ //#region src/components/chat-input/plugins/disabled-plugin.tsx
751
+ function Fr({ isDisabled: e, isReadOnly: t }) {
752
+ let n = jr();
753
+ return u(() => {
754
+ n.setEditable(!e && !t);
755
+ }, [
756
+ n,
757
+ e,
758
+ t
759
+ ]), null;
760
+ }
761
+ //#endregion
762
+ //#region src/components/chat-input/plugins/focus-plugin.tsx
763
+ function Ir({ onFocusChange: e }) {
764
+ let t = jr();
765
+ return u(() => {
766
+ if (!e) return;
767
+ let n = t.getRootElement();
768
+ if (!n) return;
769
+ function r() {
770
+ n && e && e(!0);
771
+ }
772
+ function i(t) {
773
+ n && e && !n.contains(t.relatedTarget) && e(!1);
774
+ }
775
+ return n.addEventListener("focus", r, !0), n.addEventListener("blur", i, !0), () => {
776
+ n.removeEventListener("focus", r, !0), n.removeEventListener("blur", i, !0);
777
+ };
778
+ }, [t, e]), null;
779
+ }
780
+ //#endregion
781
+ //#region src/components/chat-input/plugins/has-value-plugin.tsx
782
+ function Lr(e) {
783
+ let t = !1;
784
+ return e.getEditorState().read(() => {
785
+ t = Mr().length > 0;
786
+ }), t;
787
+ }
788
+ function Rr(e, t, n) {
789
+ let r = Lr(e);
790
+ n.current !== r && (n.current = r, t?.(r));
791
+ }
792
+ function zr({ onHasValueChange: e }) {
793
+ let t = jr(), n = h();
794
+ return u(() => {
795
+ if (t) return Rr(t, e, n), t.registerUpdateListener(() => {
796
+ Rr(t, e, n);
797
+ });
798
+ }, [t, e]), null;
799
+ }
800
+ //#endregion
801
+ //#region src/components/chat-input/plugins/markdown-plain-paste-plugin.tsx
802
+ function Br() {
803
+ let e = jr();
804
+ return u(() => e.registerCommand(_t, (t) => {
805
+ let { clipboardData: n } = t;
806
+ if (!n) return !1;
807
+ let r = n.getData("text/plain");
808
+ return r ? (t.preventDefault(), e.update(() => {
809
+ let e = G();
810
+ if (K(e)) {
811
+ e.insertText(r);
812
+ return;
813
+ }
814
+ let t = W();
815
+ t.clear(), r.split(/\r?\n/).forEach((e) => {
816
+ let n = et();
817
+ e.length > 0 && n.append(nt(e)), t.append(n);
818
+ });
819
+ }), !0) : !1;
820
+ }, ut), [e]), null;
821
+ }
822
+ //#endregion
823
+ //#region src/components/chat-input/plugins/value-plugin.tsx
824
+ function Vr({ onChange: e }) {
825
+ let t = c((t, n, r) => {
826
+ if (!r.has("focus") && e) try {
827
+ t.read(() => {
828
+ e(Xe(kr));
829
+ });
830
+ } catch (e) {
831
+ console.error("ValuePlugin error:", e);
832
+ }
833
+ }, [e]);
834
+ return /* @__PURE__ */ z(Tt, { onChange: t });
835
+ }
836
+ //#endregion
837
+ //#region src/components/chat-input/chat-input.tsx
838
+ var Hr = i(null);
839
+ function Ur() {
840
+ let e = l(Hr);
841
+ if (!e) throw Error("\"useChatInputContext\" must be used within a ChatInputContextProvider");
842
+ return e;
843
+ }
844
+ var Wr = {
845
+ namespace: "chat-input",
846
+ editable: !0,
847
+ nodes: [
848
+ Ke,
849
+ qe,
850
+ ze,
851
+ Re,
852
+ Me,
853
+ Pe
854
+ ],
855
+ theme: {
856
+ paragraph: "m-0 min-h-[26px]",
857
+ text: {
858
+ bold: "font-bold",
859
+ italic: "italic",
860
+ underline: "underline"
861
+ }
862
+ },
863
+ onError: (e) => {
864
+ console.error("ChatInput Lexical error:", e);
865
+ }
866
+ }, Gr = a(function({ className: e, children: t, initialConfig: n = Wr, ...r }, i) {
867
+ let [a, o] = g(!1), [s, c] = g(!1), [l, u] = g(!1), d = m(() => ({
868
+ hasError: a,
869
+ hasValue: s,
870
+ isFocused: l,
871
+ setHasError: o,
872
+ setHasValue: c,
873
+ setIsFocused: u
874
+ }), [
875
+ a,
876
+ s,
877
+ l
878
+ ]);
879
+ return /* @__PURE__ */ z(Hr.Provider, {
880
+ value: d,
881
+ children: /* @__PURE__ */ z(Be, {
882
+ initialConfig: n,
883
+ children: /* @__PURE__ */ z("div", {
884
+ ref: i,
885
+ "data-testid": "chat-input",
886
+ "data-focused": l,
887
+ "data-empty": !s,
888
+ "data-error": a,
889
+ "aria-invalid": a,
890
+ className: I("group/chat-input", "relative", e),
891
+ ...r,
892
+ children: t
893
+ })
894
+ })
895
+ });
896
+ });
897
+ Gr.displayName = "ChatInput";
898
+ var Kr = a(function({ className: e, children: t, ...n }, r) {
899
+ return /* @__PURE__ */ z(P, {
900
+ ref: r,
901
+ variant: "body",
902
+ className: I("pointer-events-none absolute inset-0 z-0", "min-h-[26px]", "text-text-tertiary", e),
903
+ ...n,
904
+ children: t
905
+ });
906
+ });
907
+ Kr.displayName = "ChatInputPlaceholder";
908
+ var qr = a(function({ className: e, style: t, placeholderClassName: n, placeholder: r = "Input your message...", children: i, value: a, autoFocus: o = !0, isDisabled: s = !1, isReadOnly: c = !1, onChange: l, onKeyDown: u, ...d }, f) {
909
+ let { setHasValue: p, setIsFocused: m } = Ur();
910
+ return /* @__PURE__ */ B("div", {
911
+ "data-testid": "chat-input-textarea",
912
+ "data-disabled": s,
913
+ "aria-disabled": s,
914
+ "aria-readonly": c && !s,
915
+ className: I("group/chat-input-textarea", "relative", "data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-80 data-[disabled=true]:select-none", "data-[readonly=true]:text-text-secondary"),
916
+ style: t,
917
+ ...d,
918
+ children: [
919
+ /* @__PURE__ */ z(We, {
920
+ contentEditable: /* @__PURE__ */ z(Ve, {
921
+ ref: f,
922
+ className: I("min-h-[26px]!", "overflow-y-auto text-wrap outline-none", e),
923
+ "aria-label": "Chat input",
924
+ "aria-placeholder": r,
925
+ placeholder: /* @__PURE__ */ z(Kr, {
926
+ className: n,
927
+ children: r
928
+ }),
929
+ onKeyDown: u
930
+ }),
931
+ ErrorBoundary: He
932
+ }),
933
+ /* @__PURE__ */ z(Ue, {}),
934
+ /* @__PURE__ */ z(Fr, {
935
+ isDisabled: s,
936
+ isReadOnly: c
937
+ }),
938
+ /* @__PURE__ */ z(Pr, { value: a }),
939
+ /* @__PURE__ */ z(Vr, { onChange: l }),
940
+ /* @__PURE__ */ z(Br, {}),
941
+ /* @__PURE__ */ z(zr, { onHasValueChange: p }),
942
+ /* @__PURE__ */ z(Ir, { onFocusChange: m }),
943
+ /* @__PURE__ */ z(Or, {
944
+ autoFocus: o,
945
+ isDisabled: s || c
946
+ }),
947
+ i
948
+ ]
949
+ });
950
+ });
951
+ qr.displayName = "ChatInputTextarea";
952
+ //#endregion
953
+ //#region src/components/chat-list/chat-list.tsx
954
+ var Jr = i(null);
955
+ function Yr() {
956
+ let e = l(Jr);
957
+ if (!e) throw Error("\"useChatListContext\" must be used within a ChatList");
958
+ return e;
959
+ }
960
+ function Xr({ children: e, className: t, loadedCount: n, totalCount: r, hasMore: i, isLoading: a = !1, isLoadingMore: o = !1, hasError: s = !1, onLoadMore: l, getItemKey: u, "aria-label": d = "Chat list" }) {
961
+ let f = h(null), p = h(null), [_, v] = g(0), [y, b] = g(null), [, x] = g(0), S = c((e) => {
962
+ f.current = e, x((e) => e + 1);
963
+ }, []), C = c(() => {
964
+ v((e) => e + 1);
965
+ }, []), w = i ?? (r != null && n < r), T = n === 0 && !a && !s, E = m(() => ({
966
+ loadedCount: n,
967
+ totalCount: r,
968
+ hasMore: w,
969
+ isLoading: a,
970
+ isLoadingMore: o,
971
+ isEmpty: T,
972
+ hasError: s,
973
+ onLoadMore: l,
974
+ getItemKey: u,
975
+ scrollElementRef: f,
976
+ setScrollElement: S,
977
+ loadMoreContentRef: p,
978
+ loadMoreVersion: _,
979
+ bumpLoadMore: C,
980
+ skeletonContainer: y,
981
+ setSkeletonContainer: b
982
+ }), [
983
+ n,
984
+ r,
985
+ w,
986
+ a,
987
+ o,
988
+ T,
989
+ s,
990
+ l,
991
+ u,
992
+ S,
993
+ _,
994
+ C,
995
+ y
996
+ ]);
997
+ return /* @__PURE__ */ z(Jr.Provider, {
998
+ value: E,
999
+ children: /* @__PURE__ */ z("div", {
1000
+ "data-slot": "chat-list",
1001
+ "data-testid": "chat-list",
1002
+ "data-loading": a,
1003
+ "data-loading-more": o,
1004
+ "data-empty": T,
1005
+ "data-error": s,
1006
+ role: "navigation",
1007
+ "aria-label": d,
1008
+ className: I("group/chat-list relative flex min-h-0 flex-1 flex-col", t),
1009
+ children: e
1010
+ })
1011
+ });
1012
+ }
1013
+ var Zr = ["w-2/3", "w-1/2"], Qr = ["w-full", "w-4/5"];
1014
+ function $r({ children: e, rows: t = 16, className: n }) {
1015
+ let { isLoading: r, loadedCount: i, skeletonContainer: a } = Yr();
1016
+ return !(r && i === 0) || !a ? null : Et(/* @__PURE__ */ z("div", {
1017
+ "data-slot": "chat-list-skeleton",
1018
+ "data-testid": "chat-list-skeleton",
1019
+ role: "status",
1020
+ "aria-busy": "true",
1021
+ "aria-label": "Loading chats",
1022
+ className: I("flex min-h-0 flex-1 flex-col gap-4 overflow-hidden", n),
1023
+ children: e ?? Array.from({ length: t }, (e, t) => /* @__PURE__ */ B("div", {
1024
+ "data-slot": "chat-list-skeleton-row",
1025
+ className: "flex shrink-0 flex-col gap-4 px-12 py-8",
1026
+ children: [/* @__PURE__ */ z("div", {
1027
+ className: "flex h-20 items-center",
1028
+ children: /* @__PURE__ */ z(ae, { className: I("h-12", Zr[t % 2]) })
1029
+ }), /* @__PURE__ */ z("div", {
1030
+ className: "flex h-16 items-center",
1031
+ children: /* @__PURE__ */ z(ae, { className: I("h-10", Qr[t % 2]) })
1032
+ })]
1033
+ }, t))
1034
+ }), a);
1035
+ }
1036
+ function ei({ children: e, className: t }) {
1037
+ let { isEmpty: n } = Yr();
1038
+ return n ? /* @__PURE__ */ z("div", {
1039
+ "data-slot": "chat-list-empty-state",
1040
+ "data-testid": "chat-list-empty-state",
1041
+ role: "status",
1042
+ "aria-live": "polite",
1043
+ "aria-label": "No chats",
1044
+ className: I("flex flex-1 items-center justify-center", t),
1045
+ children: e
1046
+ }) : null;
1047
+ }
1048
+ function ti({ children: e, error: t, className: n }) {
1049
+ let { hasError: r, loadedCount: i } = Yr();
1050
+ return r && i === 0 ? /* @__PURE__ */ z("div", {
1051
+ "data-slot": "chat-list-error",
1052
+ "data-testid": "chat-list-error",
1053
+ role: "alert",
1054
+ "aria-live": "assertive",
1055
+ "aria-label": "Error loading chats",
1056
+ className: I("flex flex-1 items-center justify-center", n),
1057
+ children: e || /* @__PURE__ */ z("div", {
1058
+ className: "text-text-error-main",
1059
+ children: t instanceof Error ? t.message : t || "An error occurred"
1060
+ })
1061
+ }) : null;
1062
+ }
1063
+ function ni({ children: e }) {
1064
+ let { loadMoreContentRef: t, bumpLoadMore: n } = Yr();
1065
+ return t.current = e ?? null, p(() => (n(), () => {
1066
+ t.current = null, n();
1067
+ }), [n, t]), null;
1068
+ }
1069
+ //#endregion
1070
+ //#region src/components/chat-list/chat-list-items.tsx
1071
+ var ri = "chat-list-load-more", ii = s(function({ children: e, className: t, listClassName: n, estimateSize: r = 54, overscan: i = 6, gap: a = 4 }) {
1072
+ let { loadedCount: o, hasMore: s, isLoading: l, isLoadingMore: d, onLoadMore: f, getItemKey: p, scrollElementRef: m, setScrollElement: h, loadMoreContentRef: g, loadMoreVersion: _, setSkeletonContainer: v } = Yr(), y = _ >= 0 ? g.current : null, b = l && o === 0, x = s ? o + 1 : o, S = c((e) => e >= o ? ri : p(e), [p, o]), C = Dt({
1073
+ count: b ? 0 : x,
1074
+ getScrollElement: () => m.current,
1075
+ estimateSize: () => r,
1076
+ overscan: i,
1077
+ gap: a,
1078
+ getItemKey: S
1079
+ }), w = C.getVirtualItems();
1080
+ return u(() => {
1081
+ if (b) return;
1082
+ let [e] = [...w].reverse();
1083
+ e && e.index >= o - 1 && s && !d && f?.();
1084
+ }, [
1085
+ w,
1086
+ o,
1087
+ s,
1088
+ d,
1089
+ f,
1090
+ b
1091
+ ]), b ? /* @__PURE__ */ z("div", {
1092
+ ref: v,
1093
+ "data-slot": "chat-list-items",
1094
+ "data-testid": "chat-list-items",
1095
+ className: I("flex min-h-0 flex-1 flex-col overflow-hidden", t)
1096
+ }) : /* @__PURE__ */ z(ie, {
1097
+ ref: h,
1098
+ "data-slot": "chat-list-items",
1099
+ "data-testid": "chat-list-items",
1100
+ className: I("min-h-0 flex-1", "overflow-auto", t),
1101
+ children: /* @__PURE__ */ z("ul", {
1102
+ role: "list",
1103
+ "aria-label": "Chats",
1104
+ className: I("table relative w-full transform-gpu table-fixed", "space-y-[4px]", n),
1105
+ style: { height: `${C.getTotalSize()}px` },
1106
+ children: w.map((t) => {
1107
+ let n = t.index >= o;
1108
+ return /* @__PURE__ */ z("li", {
1109
+ "data-index": t.index,
1110
+ ref: C.measureElement,
1111
+ role: n ? "status" : "listitem",
1112
+ "aria-live": n ? "polite" : void 0,
1113
+ "aria-busy": n ? d : void 0,
1114
+ style: {
1115
+ position: "absolute",
1116
+ top: 0,
1117
+ left: 0,
1118
+ width: "100%",
1119
+ transform: `translateY(${t.start}px)`
1120
+ },
1121
+ children: n ? y : e(t.index)
1122
+ }, t.key);
1123
+ })
1124
+ })
1125
+ });
1126
+ }), ai = a(function({ children: t, className: n, asChild: r = !1, isSelected: i = !1, ...a }, o) {
1127
+ return /* @__PURE__ */ z(r ? e : "div", {
1128
+ ref: o,
1129
+ "data-slot": "chat-list-item",
1130
+ "data-testid": "chat-list-item",
1131
+ "data-selected": i,
1132
+ "aria-selected": i || void 0,
1133
+ className: I("cursor-pointer outline-none", n),
1134
+ ...a,
1135
+ children: t
1136
+ });
1137
+ });
1138
+ ai.displayName = "ChatListItem";
1139
+ //#endregion
1140
+ //#region src/components/chat-prompt-box/chat-prompt-box-context.tsx
1141
+ var oi = i(null);
1142
+ function si() {
1143
+ let e = l(oi);
1144
+ if (!e) throw Error("\"useChatPromptBoxContext\" must be used within a ChatPromptBox");
1145
+ return e;
1146
+ }
1147
+ function ci({ children: e, reportInputHeight: t, resetCompact: n }) {
1148
+ let r = h(null), i = c((e) => {
1149
+ r.current = e;
1150
+ }, []), a = c(() => {
1151
+ r.current = null;
1152
+ }, []), o = c(() => {
1153
+ r.current?.();
1154
+ }, []), s = m(() => ({
1155
+ reportInputHeight: t,
1156
+ resetCompact: n,
1157
+ registerFocusInput: i,
1158
+ unregisterFocusInput: a,
1159
+ focusInput: o
1160
+ }), [
1161
+ t,
1162
+ n,
1163
+ i,
1164
+ a,
1165
+ o
1166
+ ]);
1167
+ return /* @__PURE__ */ z(oi.Provider, {
1168
+ value: s,
1169
+ children: e
1170
+ });
1171
+ }
1172
+ //#endregion
1173
+ //#region src/components/chat-prompt-box/chat-prompt-box-focus-plugin.tsx
1174
+ function li() {
1175
+ let e = jr(), { registerFocusInput: t, unregisterFocusInput: n } = si();
1176
+ return u(() => (t(() => {
1177
+ e.focus();
1178
+ }), () => {
1179
+ n();
1180
+ }), [
1181
+ e,
1182
+ t,
1183
+ n
1184
+ ]), null;
1185
+ }
1186
+ //#endregion
1187
+ //#region src/components/chat-prompt-box/chat-prompt-box.tsx
1188
+ var ui = 40, di = "button, a, input, select, textarea, [role=\"button\"]";
1189
+ function fi(e) {
1190
+ return e instanceof HTMLElement && !!e.closest(di);
1191
+ }
1192
+ var pi = a(function(e, t) {
1193
+ let [n, r] = g(!0), i = c((e) => {
1194
+ e > ui && r(!1);
1195
+ }, []), a = c(() => {
1196
+ r(!0);
1197
+ }, []);
1198
+ return /* @__PURE__ */ z(ci, {
1199
+ reportInputHeight: i,
1200
+ resetCompact: a,
1201
+ children: /* @__PURE__ */ z(mi, {
1202
+ ref: t,
1203
+ "data-compact": n,
1204
+ ...e
1205
+ })
1206
+ });
1207
+ });
1208
+ pi.displayName = "ChatPromptBox";
1209
+ var mi = a(function({ className: e, onMouseDown: t, children: n, ...r }, i) {
1210
+ let { focusInput: a } = si(), o = c((e) => {
1211
+ fi(e.target) || a(), t?.(e);
1212
+ }, [a, t]);
1213
+ return /* @__PURE__ */ B(Gr, {
1214
+ ref: i,
1215
+ className: I("group/chat-prompt-box", "relative overflow-hidden", "cursor-text", "p-px", "rounded-[16px]", "bg-transparent", "hover:bg-promptbox-background-border-base", "data-[focused=true]:bg-promptbox-background-border-base", e),
1216
+ onMouseDown: o,
1217
+ ...r,
1218
+ children: [/* @__PURE__ */ z("div", {
1219
+ className: I("rounded-[15px]", "p-[4px]", "bg-[#171A20]", "group-hover/chat-prompt-box:bg-[#252931]", "group-data-[focused=true]/chat-prompt-box:bg-[linear-gradient(var(--color-promptbox-background-hover),var(--color-promptbox-background-hover)),var(--color-promptbox-background-base)]", "group-data-[focused=true]/chat-prompt-box:group-hover/chat-prompt-box:bg-[linear-gradient(var(--color-promptbox-background-hover),var(--color-promptbox-background-hover)),var(--color-promptbox-background-base)]"),
1220
+ children: n
1221
+ }), /* @__PURE__ */ z(hi, {})]
1222
+ });
1223
+ });
1224
+ function hi() {
1225
+ return /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z("div", {
1226
+ className: I("absolute left-1/2 top-[-40px]", "translate-x-[-50%]", "pointer-events-none", "w-[380px] h-[72px]", "opacity-0 group-data-[focused=true]/chat-prompt-box:opacity-50"),
1227
+ style: {
1228
+ borderRadius: "380px",
1229
+ background: "gradient(50% 50% at 50% 50%, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.00) 100%)"
1230
+ }
1231
+ }), /* @__PURE__ */ z("div", {
1232
+ className: I("absolute left-1/2 -bottom-22", "translate-x-[-50%]", "pointer-events-none", "w-[1082px] h-[172px]", "opacity-0 group-data-[focused=true]/chat-prompt-box:opacity-5"),
1233
+ style: {
1234
+ borderRadius: "1082px",
1235
+ background: "radial-gradient(50% 50% at 50% 50%, rgba(255, 255, 255, 0.80) 0%, #2979FF 28%, rgba(63, 70, 88, 0.00) 100%)"
1236
+ }
1237
+ })] });
1238
+ }
1239
+ function gi({ children: e, className: t }) {
1240
+ return /* @__PURE__ */ z("div", {
1241
+ "data-testid": "chat-prompt-box-toolbar",
1242
+ className: I(t),
1243
+ children: e
1244
+ });
1245
+ }
1246
+ function _i({ children: e, className: t }) {
1247
+ return /* @__PURE__ */ z("div", {
1248
+ "data-testid": "chat-prompt-box-content",
1249
+ className: I("relative", "px-[8px] py-[8px]", "flex flex-row gap-[8px]", "group-data-[compact=false]/chat-prompt-box:pb-[calc(8px+4px+40px)]", t),
1250
+ children: e
1251
+ });
1252
+ }
1253
+ var vi = a(function({ className: e, placeholderClassName: t, ...n }, r) {
1254
+ let { reportInputHeight: i, resetCompact: a } = si(), { hasValue: o } = Ur(), { ref: s, height: l } = L();
1255
+ p(() => {
1256
+ typeof l == "number" && i(l);
1257
+ }, [l, i]), p(() => () => {
1258
+ a();
1259
+ }, [a]), p(() => {
1260
+ o || a();
1261
+ }, [o, a]);
1262
+ let u = c((e) => {
1263
+ s(e), typeof r == "function" ? r(e) : r && (r.current = e);
1264
+ }, [s, r]);
1265
+ return /* @__PURE__ */ z("div", {
1266
+ "data-testid": "chat-prompt-box-input",
1267
+ className: I("min-h-[40px]", "inline-flex justify-center items-center", "group-data-[compact=false]/chat-prompt-box:items-start", "group-data-[compact=false]/chat-prompt-box:min-h-[48px]", "order-2 grow min-w-0 flex-1", "[&>div]:flex-1 [&>div]:min-w-0", e),
1268
+ children: /* @__PURE__ */ z(qr, {
1269
+ ref: u,
1270
+ className: "max-h-[72px]!",
1271
+ placeholderClassName: I("leading-[24px]!", t),
1272
+ ...n,
1273
+ children: /* @__PURE__ */ z(li, {})
1274
+ })
1275
+ });
1276
+ });
1277
+ vi.displayName = "ChatPromptBoxInput";
1278
+ function yi({ children: e, className: t }) {
1279
+ return /* @__PURE__ */ z("div", {
1280
+ "data-testid": "chat-prompt-box-actions-left",
1281
+ role: "group",
1282
+ className: I("order-1 shrink-0", "group-data-[compact=false]/chat-prompt-box:absolute", "group-data-[compact=false]/chat-prompt-box:bottom-[8px]", "group-data-[compact=false]/chat-prompt-box:left-[8px]", "flex items-center gap-[8px]", "[grid-area:left]", t),
1283
+ children: e
1284
+ });
1285
+ }
1286
+ function bi({ children: e, className: t }) {
1287
+ return /* @__PURE__ */ z("div", {
1288
+ "data-testid": "chat-prompt-box-actions-right",
1289
+ role: "group",
1290
+ className: I("order-3 shrink-0", "group-data-[compact=false]/chat-prompt-box:order-3", "group-data-[compact=false]/chat-prompt-box:absolute", "group-data-[compact=false]/chat-prompt-box:bottom-[8px]", "group-data-[compact=false]/chat-prompt-box:right-[8px]", "flex items-center justify-end gap-[8px]", "[grid-area:right]", t),
1291
+ children: e
1292
+ });
1293
+ }
1294
+ //#endregion
1295
+ //#region src/components/chat-message/chat-message.tsx
1296
+ function xi({ children: e, className: t, isQuestion: n }) {
1297
+ return /* @__PURE__ */ z("div", {
1298
+ "data-question": n,
1299
+ className: I("group/message", "flex flex-col", "data-[question=true]:items-end", "gap-8", t),
1300
+ children: e
1301
+ });
1302
+ }
1303
+ function Si({ children: e }) {
1304
+ return /* @__PURE__ */ z("div", {
1305
+ "data-bubble": !0,
1306
+ className: I("w-fit", "min-w-message-mobile-min md:min-w-auto", "group-data-[question=true]/message:data-[bubble=true]:p-16", "group-data-[question=true]/message:data-[bubble=true]:rounded-[20px]", "group-data-[question=true]/message:data-[bubble=true]:bg-[#22283499]"),
1307
+ children: e
1308
+ });
1309
+ }
1310
+ function Ci({ children: e, className: t }) {
1311
+ return /* @__PURE__ */ z("div", {
1312
+ className: I("transition-opacity duration-300", "md:opacity-0 group-hover/message:opacity-100", t),
1313
+ children: e
1314
+ });
1315
+ }
1316
+ //#endregion
1317
+ //#region src/contexts/chat-context/utils.ts
1318
+ function wi() {
1319
+ return `__${Ot()}__`;
1320
+ }
1321
+ //#endregion
1322
+ //#region src/contexts/chat-context/chat-context.tsx
1323
+ var Ti = i(null);
1324
+ function X() {
1325
+ let e = l(Ti);
1326
+ if (!e) throw Error("\"useChatContext\" must be used within a ChatProvider");
1327
+ return e;
1328
+ }
1329
+ function Ei({ children: e, chatId: t }) {
1330
+ let [n, r] = g(wi()), [i, a] = g(void 0), o = h(/* @__PURE__ */ new Set()), s = t || n, l = s === n, d = c(() => {
1331
+ let e = wi();
1332
+ return r(e), e;
1333
+ }, [r]), f = c((e) => {
1334
+ a(e);
1335
+ }, []), p = c(() => {
1336
+ a(void 0);
1337
+ }, []);
1338
+ u(function() {
1339
+ p();
1340
+ }, [
1341
+ s,
1342
+ n,
1343
+ p
1344
+ ]);
1345
+ let _ = m(() => ({
1346
+ newChatId: n,
1347
+ chatId: s,
1348
+ loadedChatIdsRef: o,
1349
+ isNewChat: l,
1350
+ goToNewChat: d,
1351
+ promptPlaceholder: i,
1352
+ setPromptPlaceholder: f,
1353
+ clearPromptPlaceholder: p
1354
+ }), [
1355
+ s,
1356
+ o,
1357
+ n,
1358
+ l,
1359
+ d,
1360
+ i,
1361
+ f,
1362
+ p
1363
+ ]);
1364
+ return /* @__PURE__ */ z(Ti.Provider, {
1365
+ value: _,
1366
+ children: e
1367
+ });
1368
+ }
1369
+ //#endregion
1370
+ //#region src/contexts/chat-conversation-context/chat-conversation-context.tsx
1371
+ var Di = 3, Oi = 250, ki = i(null);
1372
+ function Ai() {
1373
+ let e = l(ki);
1374
+ if (!e) throw Error("\"useChatConversationContext\" must be used within a ChatConversationProvider");
1375
+ return e;
1376
+ }
1377
+ function ji({ children: e, chatId: t, debug: n = !1 }) {
1378
+ let [r, i] = g(!0), [a, o] = g({
1379
+ isAtBottom: !0,
1380
+ isSmoothScroll: !1,
1381
+ hasUserEscaped: !1,
1382
+ isProgrammaticScroll: !1,
1383
+ userScrollIntent: !1,
1384
+ scrollStrategy: "lastItem"
1385
+ }), s = h(null), l = h(null), u = h(null), d = h(null), f = h(null), p = h(null), _ = h(0), v = h(!0), y = h(!1), b = h(!1), x = h(!1), S = h(!1), C = h(null), w = h(null), T = h("lastItem"), E = h(0), ee = h(() => {}), te = h(() => {}), D = h(() => {}), O = h(() => {});
1386
+ O.current = c(() => {
1387
+ n && o({
1388
+ isAtBottom: v.current,
1389
+ isSmoothScroll: y.current,
1390
+ hasUserEscaped: b.current,
1391
+ isProgrammaticScroll: x.current,
1392
+ userScrollIntent: S.current,
1393
+ scrollStrategy: T.current
1394
+ });
1395
+ }, [n]);
1396
+ let k = c(() => {
1397
+ d.current?.disconnect(), d.current = null;
1398
+ }, []);
1399
+ D.current = k;
1400
+ let A = c(() => {
1401
+ p.current?.disconnect(), p.current = null;
1402
+ }, []), ne = c(() => {
1403
+ f.current?.disconnect(), f.current = null;
1404
+ }, []), re = h(() => {}), j = c(() => {
1405
+ requestAnimationFrame(() => {
1406
+ requestAnimationFrame(() => {
1407
+ x.current = !1, re.current(), O.current();
1408
+ });
1409
+ });
1410
+ }, []), ie = c(() => {
1411
+ C.current &&= (clearTimeout(C.current), null), S.current && (S.current = !1, O.current());
1412
+ }, []), M = c(() => {
1413
+ S.current = !0, C.current && clearTimeout(C.current), C.current = setTimeout(() => {
1414
+ C.current = null, S.current = !1, O.current();
1415
+ }, Oi), O.current();
1416
+ }, []), ae = c(() => {
1417
+ T.current = "lastItem", D.current(), O.current();
1418
+ }, []), N = c((e) => {
1419
+ b.current !== e && (b.current = e, e && re.current(), O.current());
1420
+ }, []), P = c(() => {
1421
+ if (b.current) return;
1422
+ x.current = !0, O.current();
1423
+ let e = y.current ? "smooth" : "instant";
1424
+ y.current = !0, requestAnimationFrame(() => {
1425
+ if (b.current) {
1426
+ j();
1427
+ return;
1428
+ }
1429
+ T.current === "lastItem" ? u.current?.scrollIntoView({
1430
+ behavior: e,
1431
+ block: "start",
1432
+ inline: "start"
1433
+ }) : s.current?.scrollTo({
1434
+ top: s.current.scrollHeight,
1435
+ behavior: e
1436
+ }), j(), O.current();
1437
+ });
1438
+ }, [j]);
1439
+ ee.current = P;
1440
+ let F = c(() => {
1441
+ let e = s.current;
1442
+ if (!e) return;
1443
+ let t = e.scrollHeight;
1444
+ t - e.clientHeight - e.scrollTop <= 1 && t === E.current || (E.current = t, x.current = !0, O.current(), requestAnimationFrame(() => {
1445
+ e.scrollTo({
1446
+ top: t,
1447
+ behavior: "instant"
1448
+ }), E.current = e.scrollHeight, j(), O.current();
1449
+ }));
1450
+ }, [j]), oe = c(() => {
1451
+ let e = s.current;
1452
+ if (!e) return;
1453
+ let t = e.scrollHeight - e.clientHeight - e.scrollTop <= 1;
1454
+ (t || b.current) && (v.current = t, i(t), T.current === "end" && t && F(), O.current());
1455
+ }, [F]);
1456
+ re.current = oe;
1457
+ let I = c(() => {
1458
+ ne();
1459
+ let e = s.current;
1460
+ if (!e) return;
1461
+ let t = new ResizeObserver(() => {
1462
+ re.current();
1463
+ });
1464
+ t.observe(e), f.current = t;
1465
+ }, [ne]), L = c((e) => {
1466
+ if (k(), T.current !== "end") return;
1467
+ let t = new ResizeObserver(() => {
1468
+ T.current === "end" && F();
1469
+ });
1470
+ t.observe(e), d.current = t;
1471
+ }, [k, F]);
1472
+ te.current = L;
1473
+ let R = c(() => {
1474
+ if (!S.current || T.current === "end") return;
1475
+ T.current = "end", ie();
1476
+ let e = u.current;
1477
+ e && te.current(e), O.current();
1478
+ }, [ie]), V = c((e) => {
1479
+ if (!e && !b.current) {
1480
+ O.current();
1481
+ return;
1482
+ }
1483
+ if (v.current = e, i(e), x.current) {
1484
+ O.current();
1485
+ return;
1486
+ }
1487
+ e && (N(!1), R()), O.current();
1488
+ }, [R, N]), se = c((e) => {
1489
+ if (e.target !== s.current) return;
1490
+ let t = e.target, n = w.current ?? t.scrollTop, r = t.scrollTop;
1491
+ if (w.current = r, x.current || !S.current) return;
1492
+ let i = r < n;
1493
+ if (t.scrollHeight - t.clientHeight - r <= 1) {
1494
+ T.current !== "end" && V(!0);
1495
+ return;
1496
+ }
1497
+ i && (N(!0), ae());
1498
+ }, [
1499
+ ae,
1500
+ V,
1501
+ N
1502
+ ]), H = c((e) => {
1503
+ let t = s.current;
1504
+ e.deltaY < 0 && t && t.scrollHeight > t.clientHeight && (N(!0), ae()), M();
1505
+ }, [
1506
+ ae,
1507
+ M,
1508
+ N
1509
+ ]), ce = c(() => {
1510
+ M();
1511
+ }, [M]), U = c(() => {
1512
+ M();
1513
+ }, [M]), le = c(() => {
1514
+ A();
1515
+ let e = s.current, t = l.current;
1516
+ if (!e || !t) return;
1517
+ let n = new IntersectionObserver(([e]) => {
1518
+ e && V(e.isIntersecting);
1519
+ }, {
1520
+ root: e,
1521
+ threshold: 0
1522
+ });
1523
+ n.observe(t), p.current = n;
1524
+ }, [A, V]), ue = c((e) => {
1525
+ s.current && (s.current.removeEventListener("scroll", se), s.current.removeEventListener("wheel", H), s.current.removeEventListener("touchstart", ce), s.current.removeEventListener("pointerdown", U), ne()), s.current = e, e ? (w.current = e.scrollTop, E.current = e.scrollHeight, e.addEventListener("scroll", se, { passive: !0 }), e.addEventListener("wheel", H, { passive: !0 }), e.addEventListener("touchstart", ce, { passive: !0 }), e.addEventListener("pointerdown", U), le(), I(), oe()) : (ie(), A(), ne());
1526
+ }, [
1527
+ le,
1528
+ I,
1529
+ ie,
1530
+ A,
1531
+ ne,
1532
+ U,
1533
+ se,
1534
+ ce,
1535
+ H,
1536
+ oe
1537
+ ]), de = c((e) => {
1538
+ l.current = e, e ? le() : A();
1539
+ }, [le, A]), fe = c((e) => {
1540
+ let t = u.current;
1541
+ if (e === null) {
1542
+ k(), u.current = null, O.current();
1543
+ return;
1544
+ }
1545
+ if (e === t) {
1546
+ T.current === "end" && L(e);
1547
+ return;
1548
+ }
1549
+ k(), u.current = e, N(!1), v.current = !0, i(!0), T.current = "lastItem", e && L(e), O.current();
1550
+ }, [
1551
+ L,
1552
+ k,
1553
+ N
1554
+ ]), pe = c((e) => {
1555
+ if (_.current = e, e < Di) T.current = "lastItem", k();
1556
+ else if (T.current === "end") {
1557
+ let e = u.current;
1558
+ e && L(e);
1559
+ }
1560
+ O.current();
1561
+ }, [L, k]), me = c(() => {
1562
+ N(!1), _.current < Di && (T.current = "lastItem", k()), O.current();
1563
+ }, [k, N]), he = c(() => {
1564
+ me(), M(), R(), x.current = !0, O.current();
1565
+ let e = y.current ? "smooth" : "instant";
1566
+ y.current = !0, requestAnimationFrame(() => {
1567
+ s.current?.scrollTo({
1568
+ top: s.current.scrollHeight,
1569
+ behavior: e
1570
+ }), j(), O.current();
1571
+ });
1572
+ }, [
1573
+ R,
1574
+ j,
1575
+ M,
1576
+ me
1577
+ ]), ge = c(() => {
1578
+ P();
1579
+ }, [P]), _e = m(() => ({
1580
+ viewportRef: ue,
1581
+ bottomTriggerRef: de,
1582
+ lastItemRef: fe,
1583
+ isAtBottom: r,
1584
+ setMessageCount: pe,
1585
+ scrollBottom: he,
1586
+ scrollToLatest: ge
1587
+ }), [
1588
+ ue,
1589
+ de,
1590
+ fe,
1591
+ r,
1592
+ pe,
1593
+ he,
1594
+ ge
1595
+ ]);
1596
+ return /* @__PURE__ */ B(ki.Provider, {
1597
+ value: _e,
1598
+ children: [n && /* @__PURE__ */ z("code", {
1599
+ className: "absolute top-0 left-0 z-50 w-full bg-red-500/90 p-8 text-white pointer-events-none",
1600
+ children: JSON.stringify(a, null, 2)
1601
+ }), e]
1602
+ });
1603
+ }
1604
+ //#endregion
1605
+ //#region src/components/chat-messages/chat-messages.tsx
1606
+ var Mi = i(null), Ni = i(!1);
1607
+ function Pi() {
1608
+ let e = l(Mi);
1609
+ if (!e) throw Error("\"ChatMessagesList\" must be used within a ChatMessages");
1610
+ return e;
1611
+ }
1612
+ function Fi({ children: e, className: t, messageCount: n = 0, gap: r = 16 }) {
1613
+ let { setMessageCount: i } = Ai(), a = m(() => ({ messageCount: n }), [n]);
1614
+ return p(() => {
1615
+ i(n);
1616
+ }, [n, i]), /* @__PURE__ */ z(Mi.Provider, {
1617
+ value: a,
1618
+ children: /* @__PURE__ */ z("div", {
1619
+ "data-testid": "chat-messages",
1620
+ className: I("relative flex min-h-0 flex-1 flex-col", t),
1621
+ style: { "--chat-messages-gap": `${r}px` },
1622
+ children: e
1623
+ })
1624
+ });
1625
+ }
1626
+ function Ii({ children: e, className: t, bottomTriggerClassName: n }) {
1627
+ let { viewportRef: r, bottomTriggerRef: i, scrollToLatest: a } = Ai(), { messageCount: o } = Pi(), s = m(() => Array.from({ length: o }, (e, t) => t), [o]), c = o - 1;
1628
+ return p(() => {
1629
+ a();
1630
+ }, [o, a]), /* @__PURE__ */ B(J.Root, {
1631
+ className: I("min-h-0 flex-1", "relative group/scroll-area", "overflow-y-hidden", "transform-gpu"),
1632
+ children: [/* @__PURE__ */ z(J.Viewport, {
1633
+ ref: r,
1634
+ className: I("@container-[size]", "will-change-scroll h-full w-full"),
1635
+ style: { scrollbarGutter: "stable both-edges" },
1636
+ children: /* @__PURE__ */ B("ul", {
1637
+ "data-testid": "chat-messages-list",
1638
+ role: "log",
1639
+ "aria-label": "Message list",
1640
+ "aria-atomic": "false",
1641
+ className: I("m-0 flex flex-col gap-(--chat-messages-gap) p-0", t),
1642
+ children: [s.map((t) => /* @__PURE__ */ z(Li, {
1643
+ index: t,
1644
+ isLast: t === c,
1645
+ children: e
1646
+ }, t)), /* @__PURE__ */ z("li", {
1647
+ ref: i,
1648
+ className: I("h-px -mt-(--chat-messages-gap)", n),
1649
+ "aria-hidden": "true"
1650
+ })]
1651
+ })
1652
+ }), /* @__PURE__ */ z(zi, { orientation: "vertical" })]
1653
+ });
1654
+ }
1655
+ var Li = s(function({ children: e, index: t, isLast: n }) {
1656
+ return /* @__PURE__ */ z("li", { children: /* @__PURE__ */ z(Ni.Provider, {
1657
+ value: n,
1658
+ children: e(t)
1659
+ }) });
1660
+ });
1661
+ function Ri({ children: e, className: t, ...n }) {
1662
+ let r = l(Ni), { lastItemRef: i } = Ai();
1663
+ return /* @__PURE__ */ z("div", {
1664
+ ref: r ? i : void 0,
1665
+ "data-is-last": r,
1666
+ className: I("flex flex-col gap-(--chat-messages-gap)", "data-[is-last=true]:min-h-[calc(100cqh-var(--chat-messages-gap))]", t),
1667
+ ...n,
1668
+ children: e
1669
+ });
1670
+ }
1671
+ function zi({ className: e, orientation: t = "vertical", ...n }) {
1672
+ return /* @__PURE__ */ z(J.ScrollAreaScrollbar, {
1673
+ "data-slot": "scroll-area-scrollbar",
1674
+ orientation: t,
1675
+ className: I("opacity-0 group-hover/scroll-area:opacity-100", "rounded-[8px]", "bg-scrollbar-track hover:bg-scrollbar-track-hover", "transition-opacity duration-200 ease-in-out", "flextouch-none select-none transition-colors", t === "vertical" && "h-full w-scrollbar border-l border-l-transparent px-4 py-[12px]", t === "horizontal" && "h-scrollbar w-full border-t border-t-transparent px-[12px] py-4", e),
1676
+ ...n,
1677
+ children: /* @__PURE__ */ z(J.ScrollAreaThumb, {
1678
+ "data-slot": "scroll-area-thumb",
1679
+ className: I("relative flex-1 rounded-full", "bg-scrollbar-thumb hover:bg-scrollbar-thumb-hover", t === "vertical" && "w-scrollbar-thumb!", t === "horizontal" && "h-scrollbar-thumb!")
1680
+ })
1681
+ });
1682
+ }
1683
+ var Bi = s(function({ className: e, tooltip: t, children: n }) {
1684
+ let { isAtBottom: r, scrollBottom: i } = Ai();
1685
+ return /* @__PURE__ */ z("div", {
1686
+ "data-testid": "chat-message-history-scroll-button",
1687
+ "data-hidden": r,
1688
+ "aria-hidden": r ? !0 : void 0,
1689
+ className: I("absolute", "px-[12px]", "bottom-0", "right-0 -translate-x-[12px]", "md:right-auto md:left-1/2 md:-translate-x-1/2", "-translate-y-[12px]", "flex items-center justify-center", "transition-opacity duration-200 ease-in-out", "data-[hidden=true]:pointer-events-none", "data-[hidden=true]:opacity-0 data-[hidden=false]:opacity-100", e),
1690
+ children: /* @__PURE__ */ z(N, {
1691
+ tooltip: t,
1692
+ side: "top",
1693
+ children: /* @__PURE__ */ z(D, {
1694
+ className: "bg-paper-elevation-2",
1695
+ color: "primary",
1696
+ size: "md",
1697
+ onClick: () => i(),
1698
+ tabIndex: -1,
1699
+ "aria-label": t,
1700
+ children: n || /* @__PURE__ */ z(H, {})
1701
+ })
1702
+ })
1703
+ });
1704
+ });
1705
+ //#endregion
1706
+ //#region src/components/chat-message-attachment-card/chat-message-attachment-card.tsx
1707
+ function Vi({ className: e, children: t, isPreview: n, isInteractive: r = !0 }) {
1708
+ return /* @__PURE__ */ z("div", {
1709
+ role: "group",
1710
+ "data-testid": "chat-message-attachment-card",
1711
+ "data-preview": n,
1712
+ "data-interactive": r,
1713
+ className: I("group/chat-message-attachment-card", "relative", "flex flex-row gap-8", "p-8 rounded-promptbox-attachment", "bg-promptbox-attachment-background", "data-[interactive=true]:cursor-pointer", "data-[interactive=true]:hover:bg-[linear-gradient(var(--color-promptbox-attachment-background-hover),var(--color-promptbox-attachment-background-hover)),linear-gradient(var(--color-promptbox-attachment-background),var(--color-promptbox-attachment-background))]", "data-[preview=true]:m-px", "data-[preview=true]:size-[56px]", e),
1714
+ children: t
1715
+ });
1716
+ }
1717
+ function Hi({ className: e, children: t }) {
1718
+ return /* @__PURE__ */ z("div", {
1719
+ "data-testid": "chat-message-attachment-card-content",
1720
+ className: I("flex-1", "flex items-center", "overflow-hidden", e),
1721
+ children: t
1722
+ });
1723
+ }
1724
+ function Ui({ className: e, children: t }) {
1725
+ return /* @__PURE__ */ z(P, {
1726
+ variant: "body-sm",
1727
+ "data-testid": "chat-message-attachment-card-title",
1728
+ className: I("truncate", e),
1729
+ children: t
1730
+ });
1731
+ }
1732
+ function Wi({ className: e, previewSrc: t }) {
1733
+ return /* @__PURE__ */ z("figure", {
1734
+ "data-testid": "chat-message-attachment-card-preview",
1735
+ className: I("absolute top-0 left-0", "inset-0 w-full h-full", "overflow-hidden rounded-promptbox-attachment", "pointer-events-none", e),
1736
+ children: /* @__PURE__ */ z("img", {
1737
+ src: t,
1738
+ alt: "Preview",
1739
+ className: "w-full h-full object-cover"
1740
+ })
1741
+ });
1742
+ }
1743
+ function Gi({ className: e, onDelete: t }) {
1744
+ return /* @__PURE__ */ z("div", {
1745
+ role: "group",
1746
+ "data-testid": "chat-message-attachment-card-actions",
1747
+ className: I("absolute top-0 right-0", "translate-x-1/2 -translate-y-1/2", "hidden", "group-data-[interactive=true]/chat-message-attachment-card:group-hover/chat-message-attachment-card:flex", "rounded-overlay-tools-wrapper", "bg-overlay-tools-background-base", e),
1748
+ children: /* @__PURE__ */ z(D, {
1749
+ variant: "tertiary",
1750
+ isSemantic: !1,
1751
+ onClick: t,
1752
+ size: "xs",
1753
+ className: I("size-[24px]", "text-icon-button-tertiary-icon", e),
1754
+ children: /* @__PURE__ */ z(U, {})
1755
+ })
1756
+ });
1757
+ }
1758
+ //#endregion
1759
+ //#region src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx
1760
+ var Ki = {
1761
+ spreadsheet: {
1762
+ component: je,
1763
+ className: "bg-data-d"
1764
+ },
1765
+ pdf: {
1766
+ component: Ee,
1767
+ className: "bg-data-a"
1768
+ },
1769
+ presentation: {
1770
+ component: De,
1771
+ className: "bg-data-e"
1772
+ },
1773
+ document: {
1774
+ component: de,
1775
+ className: "bg-data-c"
1776
+ },
1777
+ code: {
1778
+ component: le,
1779
+ className: "bg-data-f"
1780
+ },
1781
+ unknown: {
1782
+ component: fe,
1783
+ className: "bg-data-f"
1784
+ }
1785
+ };
1786
+ function qi({ icon: e, className: t, ...n }) {
1787
+ let { component: r, className: i } = Ki[e];
1788
+ return /* @__PURE__ */ z("span", {
1789
+ "data-testid": "chat-attachment-icon",
1790
+ "data-icon": e,
1791
+ className: I("inline-flex items-center justify-center", "rounded-[8px]", "p-8", "size-promptbox-attachment-size-icon-container", "text-icon-fill-inverse", "[&_svg]:size-[24px]", i, t),
1792
+ children: /* @__PURE__ */ z(r, { ...n })
1793
+ });
1794
+ }
1795
+ //#endregion
1796
+ //#region src/components/chat-message-attachment-card/utils.ts
1797
+ var Ji = {
1798
+ "application/pdf": "pdf",
1799
+ "application/vnd.ms-excel": "spreadsheet",
1800
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "spreadsheet",
1801
+ "text/csv": "spreadsheet",
1802
+ "application/vnd.ms-powerpoint": "presentation",
1803
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": "presentation",
1804
+ "application/msword": "document",
1805
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "document",
1806
+ "text/plain": "document",
1807
+ "application/rtf": "document",
1808
+ "application/vnd.oasis.opendocument.text": "document"
1809
+ };
1810
+ function Yi(e) {
1811
+ let t = kt.getType(e.name);
1812
+ return t ? t in Ji ? Ji[t] : t.startsWith("text/") || t.includes("javascript") || t.includes("json") ? "code" : "unknown" : "unknown";
1813
+ }
1814
+ //#endregion
1815
+ //#region src/components/markdown-viewer/utils.ts
1816
+ function Xi(e) {
1817
+ return e.startsWith("swi-");
1818
+ }
1819
+ //#endregion
1820
+ //#region src/components/markdown-viewer/hooks.ts
1821
+ function Zi({ customComponents: e }) {
1822
+ let t = m(() => Object.keys(e).filter((e) => Xi(e) ? !0 : (console.warn(`[MarkdownViewer] Invalid custom component tag: ${e}`), !1)), [e]);
1823
+ return {
1824
+ components: e,
1825
+ remarkPlugins: m(() => [...Object.values(Mt)], []),
1826
+ rehypePlugins: m(() => [...Object.values(jt), [Nt, {
1827
+ ...Pt,
1828
+ tagNames: [...Pt?.tagNames || [], ...t],
1829
+ protocols: {
1830
+ ...Pt?.protocols,
1831
+ href: [
1832
+ ...Pt?.protocols?.href ?? [],
1833
+ "swisper",
1834
+ "swisper://"
1835
+ ]
1836
+ }
1837
+ }]], [t])
1838
+ };
1839
+ }
1840
+ //#endregion
1841
+ //#region src/components/markdown-viewer/markdown-viewer.tsx
1842
+ function Qi({ markdown: e, isStreaming: t = !1, hasCaret: n = !1, customComponents: r = {} }) {
1843
+ let { components: i, remarkPlugins: a, rehypePlugins: o } = Zi({ customComponents: r });
1844
+ return /* @__PURE__ */ z(At, {
1845
+ caret: n ? "block" : void 0,
1846
+ isAnimating: t,
1847
+ components: i,
1848
+ remarkPlugins: a,
1849
+ rehypePlugins: o,
1850
+ linkSafety: { enabled: !1 },
1851
+ remend: { handlers: [{
1852
+ name: "swi-tag-filter",
1853
+ handle: $i,
1854
+ priority: 0
1855
+ }] },
1856
+ children: e
1857
+ });
1858
+ }
1859
+ function $i(e, t = "|") {
1860
+ let [n, r] = /<swi-(\w+)([^>]*)$/gm.exec(e) ?? [];
1861
+ if (e.endsWith("<swi-")) return e + ">";
1862
+ if (n) return e.replace(n, `<swi-${r}>`);
1863
+ if (e.endsWith(t)) return e.slice(0, -1) + `</swi-${r}>`;
1864
+ let i = /<swi-(\w+)([^>]*)>/g, a = [], o;
1865
+ for (i.lastIndex = 0; (o = i.exec(e)) !== null;) {
1866
+ let e = o[1];
1867
+ o[2].trim().endsWith("/") || a.push({
1868
+ name: e,
1869
+ index: o.index
1870
+ });
1871
+ }
1872
+ if (a.length > 0) {
1873
+ let t = a[a.length - 1], n = `</swi-${t.name}>`;
1874
+ if (!e.substring(t.index).includes(n)) return e + n;
1875
+ }
1876
+ return e;
1877
+ }
1878
+ //#endregion
1879
+ //#region src/components/chat-message-response/chat-message-response.tsx
1880
+ function ea({ message: e, isStreaming: t }) {
1881
+ let n = m(() => ({}), []);
1882
+ return /* @__PURE__ */ z(Qi, {
1883
+ hasCaret: !1,
1884
+ markdown: e,
1885
+ isStreaming: t,
1886
+ customComponents: n
1887
+ });
1888
+ }
1889
+ //#endregion
1890
+ //#region src/components/chat-message-history/chat-message-history.tsx
1891
+ var ta = i(null);
1892
+ function na() {
1893
+ let e = l(ta);
1894
+ if (!e) throw Error("\"useChatMessageHistoryContext\" must be used within a ChatMessageHistoryContextProvider");
1895
+ return e;
1896
+ }
1897
+ function ra({ children: e, className: t, totalMessages: n, isLoading: r = !1, hasError: i = !1 }) {
1898
+ let a = n === 0, { contentRef: o, scrollRef: s, isAtBottom: c, scrollToBottom: l } = It(), u = m(() => ({
1899
+ isCurrentScrollBottom: c,
1900
+ isLoading: r,
1901
+ isEmpty: a,
1902
+ hasError: i,
1903
+ scrollToLastMessage: l
1904
+ }), [
1905
+ c,
1906
+ r,
1907
+ a,
1908
+ i,
1909
+ l
1910
+ ]);
1911
+ return /* @__PURE__ */ z(ta.Provider, {
1912
+ value: u,
1913
+ children: /* @__PURE__ */ z(Ft, {
1914
+ "data-testid": "chat-message-history",
1915
+ className: I("flex", t),
1916
+ initial: "instant",
1917
+ resize: "instant",
1918
+ "aria-label": "Chat message history",
1919
+ "data-loading": r,
1920
+ "data-empty": a,
1921
+ "data-error": i,
1922
+ children: /* @__PURE__ */ B(J.Root, {
1923
+ className: I("flex-1", "relative group/scroll-area", "overflow-y-hidden", "transform-gpu"),
1924
+ children: [/* @__PURE__ */ z(J.Viewport, {
1925
+ ref: s,
1926
+ className: I("will-change-scroll"),
1927
+ style: {
1928
+ height: "100%",
1929
+ width: "100%",
1930
+ scrollbarGutter: "stable both-edges"
1931
+ },
1932
+ children: /* @__PURE__ */ z("div", {
1933
+ ref: o,
1934
+ children: e
1935
+ })
1936
+ }), /* @__PURE__ */ z(ca, { orientation: "vertical" })]
1937
+ })
1938
+ })
1939
+ });
1940
+ }
1941
+ var ia = s(function({ children: e, className: t }) {
1942
+ return /* @__PURE__ */ z("ul", {
1943
+ "data-testid": "chat-message-history-list",
1944
+ role: "log",
1945
+ "aria-label": "Message list",
1946
+ "aria-atomic": "false",
1947
+ className: I("flex flex-col p-0 m-0", "relative gap-16", t),
1948
+ children: e
1949
+ });
1950
+ });
1951
+ function aa({ children: e, className: t }) {
1952
+ let { hasError: n, isLoading: r } = na();
1953
+ return !n && !r ? null : /* @__PURE__ */ z("div", {
1954
+ "data-testid": "chat-message-history-empty-state",
1955
+ role: "status",
1956
+ "aria-live": "polite",
1957
+ "aria-label": "No messages",
1958
+ className: I("flex-1 flex items-center justify-center", t),
1959
+ children: e
1960
+ });
1961
+ }
1962
+ function oa({ children: e, error: t, className: n }) {
1963
+ let { hasError: r, isLoading: i } = na();
1964
+ return r && !i ? null : /* @__PURE__ */ z("div", {
1965
+ "data-testid": "chat-message-history-error-state",
1966
+ role: "alert",
1967
+ "aria-live": "assertive",
1968
+ "aria-label": "Error loading messages",
1969
+ className: I("flex-1 flex items-center justify-center", n),
1970
+ children: e || /* @__PURE__ */ z("div", {
1971
+ className: "text-text-error-main",
1972
+ children: t instanceof Error ? t.message : t || "An error occurred"
1973
+ })
1974
+ });
1975
+ }
1976
+ var sa = s(function({ className: e, tooltip: t }) {
1977
+ let { isCurrentScrollBottom: n, scrollToLastMessage: r } = na();
1978
+ return /* @__PURE__ */ z("div", {
1979
+ "data-testid": "chat-message-history-scroll-button",
1980
+ "data-hidden": n,
1981
+ "aria-hidden": n ? !0 : void 0,
1982
+ className: I("absolute", "px-[12px]", "bottom-0", "right-0 -translate-x-[12px]", "md:right-auto md:left-1/2 md:-translate-x-1/2", "-translate-y-[12px]", "flex items-center justify-center", "transition-opacity duration-200 ease-in-out", "data-[hidden=true]:pointer-events-none", "data-[hidden=true]:opacity-0 data-[hidden=false]:opacity-100", e),
1983
+ children: /* @__PURE__ */ z(N, {
1984
+ tooltip: t,
1985
+ side: "top",
1986
+ children: /* @__PURE__ */ z(D, {
1987
+ className: "bg-paper-elevation-2",
1988
+ color: "primary",
1989
+ size: "md",
1990
+ onClick: () => r(),
1991
+ tabIndex: -1,
1992
+ "aria-label": t,
1993
+ children: /* @__PURE__ */ z(H, {})
1994
+ })
1995
+ })
1996
+ });
1997
+ });
1998
+ function ca({ className: e, orientation: t = "vertical", ...n }) {
1999
+ return /* @__PURE__ */ z(J.ScrollAreaScrollbar, {
2000
+ "data-slot": "scroll-area-scrollbar",
2001
+ orientation: t,
2002
+ className: I("opacity-0 group-hover/scroll-area:opacity-100", "rounded-[8px]", "bg-scrollbar-track hover:bg-scrollbar-track-hover", "transition-opacity duration-200 ease-in-out", "flextouch-none select-none transition-colors", t === "vertical" && "h-full w-scrollbar border-l border-l-transparent px-4 py-[12px]", t === "horizontal" && "h-scrollbar w-full border-t border-t-transparent px-[12px] py-4", e),
2003
+ ...n,
2004
+ children: /* @__PURE__ */ z(J.ScrollAreaThumb, {
2005
+ "data-slot": "scroll-area-thumb",
2006
+ className: I("relative flex-1 rounded-full", "bg-scrollbar-thumb hover:bg-scrollbar-thumb-hover", t === "vertical" && "w-scrollbar-thumb!", t === "horizontal" && "h-scrollbar-thumb!")
2007
+ })
2008
+ });
2009
+ }
2010
+ //#endregion
2011
+ //#region src/components/chat-message-toolbar/chat-message-toolbar.tsx
2012
+ function la({ children: e, className: t, reverse: n = !1, ...r }) {
2013
+ return /* @__PURE__ */ z("div", {
2014
+ "data-testid": "chat-message-toolbar",
2015
+ "data-reverse": n,
2016
+ className: I("flex items-center justify-between", "gap-16", "h-24", "data-[reverse=true]:flex-row-reverse", t),
2017
+ ...r,
2018
+ children: e
2019
+ });
2020
+ }
2021
+ function ua({ children: e, className: t }) {
2022
+ return /* @__PURE__ */ z("div", {
2023
+ "data-testid": "chat-message-toolbar-actions",
2024
+ role: "group",
2025
+ className: I("flex items-center gap-8", t),
2026
+ children: e
2027
+ });
2028
+ }
2029
+ function da({ children: e, className: t, tooltip: n, ...r }) {
2030
+ let i = /* @__PURE__ */ z(D, {
2031
+ variant: "tertiary",
2032
+ isSemantic: !1,
2033
+ size: "xs",
2034
+ className: I("text-action-active", t),
2035
+ ...r,
2036
+ children: e
2037
+ });
2038
+ return n ? /* @__PURE__ */ z(N, {
2039
+ tooltip: n,
2040
+ children: i
2041
+ }) : i;
2042
+ }
2043
+ function fa({ className: e, children: t }) {
2044
+ return /* @__PURE__ */ z("div", {
2045
+ className: I("text-action-active", e),
2046
+ children: t
2047
+ });
2048
+ }
2049
+ //#endregion
2050
+ //#region src/components/chat-notification-card/utils.ts
2051
+ function pa(e) {
2052
+ return new Date(Date.now() + e * 60 * 1e3);
2053
+ }
2054
+ var ma = 60, ha = 1440, ga = 6e4;
2055
+ function _a(e, t) {
2056
+ return `${e} ${t}${e === 1 ? "" : "s"}`;
2057
+ }
2058
+ function va(e, t = "in", n = /* @__PURE__ */ new Date()) {
2059
+ let r = Math.max(0, Math.ceil((e.getTime() - n.getTime()) / ga)), i = Math.floor(r / ha), a = Math.floor(r % ha / ma), o = r % ma, s = [];
2060
+ return i > 0 && s.push(_a(i, "day")), a > 0 && s.push(_a(a, "hour")), s.push(_a(o, "minute")), [t, ...s].filter(Boolean).join(" ");
2061
+ }
2062
+ //#endregion
2063
+ //#region src/components/chat-notification-card/chat-notification-card.tsx
2064
+ var ya = i(null);
2065
+ function ba() {
2066
+ let e = l(ya);
2067
+ if (!e) throw Error("\"useChatNotificationCardContext\" must be used within a ChatNotificationCard");
2068
+ return e;
2069
+ }
2070
+ function xa({ children: e, className: t, defaultExpanded: n = !1, expanded: r, onExpandedChange: i, onClick: a }) {
2071
+ let [o, s] = g(n), l = r ?? o, u = c((e) => {
2072
+ r === void 0 && s(e), i?.(e);
2073
+ }, [r, i]), d = c(() => {
2074
+ u(!l);
2075
+ }, [l, u]), f = m(() => ({
2076
+ isExpanded: l,
2077
+ setExpanded: u,
2078
+ toggleExpanded: d
2079
+ }), [
2080
+ l,
2081
+ u,
2082
+ d
2083
+ ]);
2084
+ return /* @__PURE__ */ z(ya.Provider, {
2085
+ value: f,
2086
+ children: /* @__PURE__ */ B("div", {
2087
+ role: "alert",
2088
+ "data-testid": "chat-notification-card",
2089
+ "data-expanded": l,
2090
+ "aria-expanded": l,
2091
+ className: I("group/chat-notification-card", "relative", "p-[12px]", "rounded-[12px] overflow-hidden", "bg-paper-elevation-2", "flex flex-col gap-8", "bg-paper-elevation-2", "data-[variant=floating]:border data-[variant=floating]:border-component-divider", t),
2092
+ onClick: a,
2093
+ children: [e, /* @__PURE__ */ z("div", { className: "absolute inset-0 pointer-events-none bg-secondary-states-hover opacity-0 group-hover/chat-notification-card:opacity-100 transition-opacity duration-200 ease-in-out" })]
2094
+ })
2095
+ });
2096
+ }
2097
+ function Sa({ children: e, className: t }) {
2098
+ return /* @__PURE__ */ z("header", {
2099
+ "data-testid": "chat-notification-card-head",
2100
+ className: I("grid grid-cols-[minmax(0,1fr)_auto] items-center gap-8", "min-h-[32px]", t),
2101
+ children: e
2102
+ });
2103
+ }
2104
+ function Ca({ children: e, className: t }) {
2105
+ return /* @__PURE__ */ z("div", {
2106
+ "data-testid": "chat-notification-card-header",
2107
+ className: I("min-w-0 flex items-center gap-8 overflow-hidden", "text-layout-feedback-info-background-default", t),
2108
+ children: e
2109
+ });
2110
+ }
2111
+ function wa({ children: e, className: t }) {
2112
+ return /* @__PURE__ */ z("div", {
2113
+ "data-testid": "chat-notification-card-header-icon",
2114
+ className: I("shrink-0", "inline-flex items-center justify-center", "pointer-events-none", "[&_svg]:size-[20px]!", t),
2115
+ children: e
2116
+ });
2117
+ }
2118
+ function Ta({ children: e, className: t }) {
2119
+ return /* @__PURE__ */ z("div", {
2120
+ "data-testid": "chat-notification-card-header-title",
2121
+ className: I("min-w-0 flex flex-1 items-center gap-8 overflow-hidden", t),
2122
+ children: e
2123
+ });
2124
+ }
2125
+ function Ea({ children: e, className: t }) {
2126
+ return /* @__PURE__ */ z(P, {
2127
+ variant: "body-sm",
2128
+ fontWeight: "semibold",
2129
+ "data-testid": "chat-notification-card-header-title-label",
2130
+ className: I("min-w-0 truncate", "text-left text-inherit uppercase", t),
2131
+ asChild: !0,
2132
+ children: /* @__PURE__ */ z("span", { children: e })
2133
+ });
2134
+ }
2135
+ var Da = {
2136
+ low: "info",
2137
+ medium: "warning",
2138
+ high: "error"
2139
+ };
2140
+ function Oa({ children: e, priority: t = "medium", className: n, ...r }) {
2141
+ let i = Da[t];
2142
+ return t === "low" ? null : /* @__PURE__ */ z(y, {
2143
+ "data-testid": "chat-notification-card-header-status",
2144
+ className: I("text-text-secondary", "shrink-0", n),
2145
+ size: "2xs",
2146
+ color: i,
2147
+ variant: "outlined",
2148
+ ...r,
2149
+ children: e
2150
+ });
2151
+ }
2152
+ function ka({ children: e, className: t }) {
2153
+ return /* @__PURE__ */ z("div", {
2154
+ "data-testid": "chat-notification-card-actions",
2155
+ role: "group",
2156
+ className: I("flex flex-row items-center justify-end", "shrink-0 justify-self-end", t),
2157
+ children: e
2158
+ });
2159
+ }
2160
+ function Aa({ children: e, className: t }) {
2161
+ return /* @__PURE__ */ z(P, {
2162
+ variant: "caption",
2163
+ "data-testid": "chat-notification-card-timestamp",
2164
+ className: I("text-text-secondary", "inline-flex px-8", "leading-[32px]", t),
2165
+ children: e
2166
+ });
2167
+ }
2168
+ function ja({ children: e, className: t }) {
2169
+ function n(e) {
2170
+ e.stopPropagation();
2171
+ }
2172
+ function r(e) {
2173
+ e.stopPropagation();
2174
+ }
2175
+ return /* @__PURE__ */ z("div", {
2176
+ "data-testid": "chat-notification-card-buttons",
2177
+ role: "group",
2178
+ className: I("flex flex-row items-center justify-end", "gap-8", t),
2179
+ onMouseDown: n,
2180
+ onClick: r,
2181
+ children: e
2182
+ });
2183
+ }
2184
+ var Ma = a(function({ className: e, isRead: t = !1, onRead: n, ...r }, i) {
2185
+ function a() {
2186
+ n?.(!t);
2187
+ }
2188
+ return /* @__PURE__ */ z(D, {
2189
+ ref: i,
2190
+ "aria-label": "Mark notifications as read",
2191
+ size: "sm",
2192
+ variant: "tertiary",
2193
+ className: e,
2194
+ onClick: a,
2195
+ ...r,
2196
+ children: z(t ? ke : Oe, {})
2197
+ });
2198
+ });
2199
+ Ma.displayName = "ChatNotificationCardReadActionButton";
2200
+ var Na = a(function({ className: e, snoozeUntilDate: t, cancelLabel: n = "Cancel", formatDate: r = va, onCancel: i, onClick: a, onMouseEnter: o, onMouseLeave: s, ...c }, l) {
2201
+ let [d, f] = g(!1), p = t && t > /* @__PURE__ */ new Date();
2202
+ u(() => {
2203
+ p || f(!1);
2204
+ }, [p]);
2205
+ function m(e) {
2206
+ f(!0), o?.(e);
2207
+ }
2208
+ function h(e) {
2209
+ f(!1), s?.(e);
2210
+ }
2211
+ function v() {
2212
+ f(!1), i?.();
2213
+ }
2214
+ return p ? /* @__PURE__ */ B(_, {
2215
+ ref: l,
2216
+ "data-hover": d,
2217
+ startIcon: z(d ? U : Ae, {}),
2218
+ variant: "tertiary",
2219
+ size: "md",
2220
+ onMouseEnter: m,
2221
+ onMouseLeave: h,
2222
+ onClick: v,
2223
+ className: I("group/snooze-button", "text-chip-outlined-warning-text h-[32px]!", e),
2224
+ ...c,
2225
+ children: [/* @__PURE__ */ z("span", {
2226
+ className: I("group-data-[hover=true]/snooze-button:opacity-0", "transition-opacity duration-200 ease-in-out"),
2227
+ children: r(t)
2228
+ }), /* @__PURE__ */ z("span", {
2229
+ className: I("absolute left-0 w-full text-center pl-[16px]", "transition-opacity duration-200 ease-in-out", "opacity-0", "group-data-[hover=true]/snooze-button:opacity-100"),
2230
+ children: n
2231
+ })]
2232
+ }) : /* @__PURE__ */ z(D, {
2233
+ ref: l,
2234
+ "aria-label": "Snooze notification",
2235
+ size: "sm",
2236
+ variant: "tertiary",
2237
+ className: I("group/snooze-button", e),
2238
+ onClick: a,
2239
+ ...c,
2240
+ children: /* @__PURE__ */ z(Ae, {})
2241
+ });
2242
+ });
2243
+ Na.displayName = "ChatNotificationCardSnoozeButton";
2244
+ var Pa = a(function({ className: e, ...t }, n) {
2245
+ return /* @__PURE__ */ z(D, {
2246
+ ref: n,
2247
+ "aria-label": "Delete notification",
2248
+ size: "sm",
2249
+ variant: "tertiary",
2250
+ className: e,
2251
+ ...t,
2252
+ children: /* @__PURE__ */ z(ue, {})
2253
+ });
2254
+ });
2255
+ Pa.displayName = "ChatNotificationCardDeleteButton";
2256
+ var Fa = a(function({ className: e, ...t }, n) {
2257
+ return /* @__PURE__ */ z(D, {
2258
+ ref: n,
2259
+ "aria-label": "Close notification",
2260
+ size: "sm",
2261
+ variant: "tertiary",
2262
+ className: e,
2263
+ ...t,
2264
+ children: /* @__PURE__ */ z(U, {})
2265
+ });
2266
+ });
2267
+ Fa.displayName = "ChatNotificationCardCloseButton";
2268
+ function Ia({ children: e, className: t }) {
2269
+ return /* @__PURE__ */ B("div", {
2270
+ "data-testid": "chat-notification-card-content",
2271
+ className: I("flex flex-col items-start text-left gap-4", "relative pr-[40px]", t),
2272
+ children: [e, /* @__PURE__ */ z(Ba, {})]
2273
+ });
2274
+ }
2275
+ function La({ children: e, className: t }) {
2276
+ return /* @__PURE__ */ z(P, {
2277
+ variant: "body-sm",
2278
+ fontWeight: "semibold",
2279
+ "data-testid": "chat-notification-card-content-title",
2280
+ className: I("text-text-primary", "text-left", t),
2281
+ asChild: !0,
2282
+ children: /* @__PURE__ */ z("span", { children: e })
2283
+ });
2284
+ }
2285
+ function Ra({ children: e, className: t }) {
2286
+ return /* @__PURE__ */ z(P, {
2287
+ variant: "body-sm",
2288
+ "data-testid": "chat-notification-card-content-description",
2289
+ className: I("text-text-primary", "mt-8", "group-data-[expanded=false]/chat-notification-card:line-clamp-2", "w-full [&>div>*]:wrap-break-word", t),
2290
+ asChild: !0,
2291
+ children: /* @__PURE__ */ z("div", { children: e })
2292
+ });
2293
+ }
2294
+ function za({ children: e, className: t }) {
2295
+ return /* @__PURE__ */ z("div", {
2296
+ "data-testid": "chat-notification-card-content-actions",
2297
+ role: "group",
2298
+ className: I("hidden", "group-data-[expanded=true]/chat-notification-card:flex", "flex-row items-center gap-8", "mt-4", t),
2299
+ children: e
2300
+ });
2301
+ }
2302
+ var Ba = a(function({ className: e, onMouseDown: t, onClick: n, ...r }, i) {
2303
+ let { isExpanded: a, toggleExpanded: o } = ba();
2304
+ function s(e) {
2305
+ e.stopPropagation(), t?.(e);
2306
+ }
2307
+ function c(e) {
2308
+ e.stopPropagation(), o(), n?.(e);
2309
+ }
2310
+ return /* @__PURE__ */ z(D, {
2311
+ ref: i,
2312
+ "data-testid": "chat-notification-card-expand-button",
2313
+ size: "sm",
2314
+ variant: "tertiary",
2315
+ "aria-expanded": a,
2316
+ className: I("my-4", "h-auto! px-0!", "absolute bottom-0 right-0", "transition-opacity duration-200 ease-in", "opacity-0 group-data-[expanded=true]/chat-notification-card:opacity-100 group-hover/chat-notification-card:opacity-100", e),
2317
+ onMouseDown: s,
2318
+ onClick: c,
2319
+ ...r,
2320
+ children: z(a ? ce : H, {})
2321
+ });
2322
+ });
2323
+ Ba.displayName = "ChatNotificationCardExpandButton";
2324
+ var Va = wa, Ha = Ra, Ua = Aa;
2325
+ //#endregion
2326
+ //#region src/components/chat-notification-popup/chat-notification-popup.tsx
2327
+ function Wa({ children: e, ...t }) {
2328
+ return /* @__PURE__ */ z(ne, {
2329
+ ...t,
2330
+ children: e
2331
+ });
2332
+ }
2333
+ var Ga = a(function(e, t) {
2334
+ return /* @__PURE__ */ z(j, {
2335
+ ref: t,
2336
+ ...e
2337
+ });
2338
+ });
2339
+ Ga.displayName = "ChatNotificationPopupTrigger";
2340
+ var Ka = a(function({ children: e, className: t, ...n }, r) {
2341
+ return /* @__PURE__ */ z(re, {
2342
+ ref: r,
2343
+ className: I("md:w-[467px]", t),
2344
+ ...n,
2345
+ children: e
2346
+ });
2347
+ });
2348
+ Ka.displayName = "ChatNotificationPopupContent";
2349
+ //#endregion
2350
+ //#region src/components/chat-reply/chat-reply.tsx
2351
+ function qa({ className: e, children: t, hasPadding: n = !0 }) {
2352
+ return /* @__PURE__ */ z("ul", {
2353
+ "data-testid": "chat-replies",
2354
+ "data-padding": n,
2355
+ className: I("flex flex-col justify-start items-start gap-8", "data-[padding=true]:py-8 data-[padding=true]:px-16", e),
2356
+ children: t
2357
+ });
2358
+ }
2359
+ function Ja({ className: e, children: t, isMultiline: n = !1, ...r }) {
2360
+ return /* @__PURE__ */ z("li", {
2361
+ "data-testid": "chat-reply",
2362
+ "data-multiline": n,
2363
+ className: I("group/chat-reply", "flex gap-8 w-full min-h-[24px]", "data-[multiline=false]:flex-row items-center", "data-[multiline=true]:flex-wrap items-start", e),
2364
+ ...r,
2365
+ children: t
2366
+ });
2367
+ }
2368
+ function Ya({ className: e, children: t, ...n }) {
2369
+ return /* @__PURE__ */ z(y, {
2370
+ variant: "outlined",
2371
+ size: "sm",
2372
+ color: "secondary",
2373
+ "data-testid": "chat-reply-label",
2374
+ className: I("shrink-0", e),
2375
+ ...n,
2376
+ children: t
2377
+ });
2378
+ }
2379
+ function Xa({ className: e, children: t, asChild: n = !1, ...r }) {
2380
+ return /* @__PURE__ */ z(P, {
2381
+ "data-testid": "chat-reply-value",
2382
+ variant: "body-sm",
2383
+ className: I("leading-[24px]", "flex flex-1 min-w-0 text-text-secondary", "items-start", "group-data-[multiline=false]/chat-reply:flex-1 truncate", "group-data-[multiline=true]/chat-reply:flex-wrap", "group-data-[multiline=true]/chat-reply:gap-4", e),
2384
+ asChild: !0,
2385
+ ...r,
2386
+ children: /* @__PURE__ */ z("div", { children: t })
2387
+ });
2388
+ }
2389
+ //#endregion
2390
+ //#region src/components/chat-suggestion/chat-suggestion.tsx
2391
+ var Za = i(null);
2392
+ function Qa() {
2393
+ let e = l(Za);
2394
+ if (!e) throw Error("\"useChatSuggestionContext\" must be used within a ChatSuggestion");
2395
+ return e;
2396
+ }
2397
+ function $a({ children: e, className: t, onMouseLeave: i }) {
2398
+ return /* @__PURE__ */ z("div", {
2399
+ role: "list",
2400
+ "data-testid": "chat-suggestions",
2401
+ className: I("list-none flex flex-col flex-wrap align-start items-stretch gap-0", t),
2402
+ onMouseLeave: i,
2403
+ children: n.map(e, (e, t) => o(e) ? r(e, { index: t }) : e)
2404
+ });
2405
+ }
2406
+ function eo({ index: e, children: t, className: n, onHover: r, onClick: i }) {
2407
+ let a = m(() => ({ index: e }), [e]);
2408
+ return /* @__PURE__ */ z(Za.Provider, {
2409
+ value: a,
2410
+ children: /* @__PURE__ */ z("div", {
2411
+ role: "listitem",
2412
+ onClick: i,
2413
+ onMouseEnter: r,
2414
+ className: I("cursor-pointer", "inline-flex flex-row max-w-full", "items-start", "p-4 gap-0 rounded-[12px]", "group/suggestion", "text-typography-text-secondary", "hover:bg-layout-accent-low-background-hover-default", "focus-visible:bg-layout-accent-low-background-hover-default", n),
2415
+ children: t
2416
+ })
2417
+ });
2418
+ }
2419
+ function to({ children: e, className: t }) {
2420
+ let { index: n = 0 } = Qa();
2421
+ return /* @__PURE__ */ z("span", {
2422
+ "aria-hidden": "true",
2423
+ className: I("inline-flex flex-row justify-center items-center shrink-0 size-auto text-inherit", t),
2424
+ children: /* @__PURE__ */ z("span", {
2425
+ "aria-hidden": "true",
2426
+ className: I("size-[32px]", "inline-flex items-center justify-center", "px-8 py-[7px]", "[&_svg]:size-[18px]!"),
2427
+ children: e || /* @__PURE__ */ z(P, {
2428
+ variant: "caption-md",
2429
+ fontWeight: "normal",
2430
+ className: "text-inherit",
2431
+ children: n + 1
2432
+ })
2433
+ })
2434
+ });
2435
+ }
2436
+ function no({ children: e, className: t, isMultiline: n = !0 }) {
2437
+ return /* @__PURE__ */ z(P, {
2438
+ variant: "body-small-low",
2439
+ "data-multiline": n,
2440
+ className: I("gap-0 px-4 my-[7px]", "h-full flex-1 items-center justify-center text-left text-inherit", "data-[multiline=false]:truncate", "data-[multiline=true]:line-clamp-3", t),
2441
+ children: e
2442
+ });
2443
+ }
2444
+ function ro({ children: e, className: t }) {
2445
+ return /* @__PURE__ */ z("div", {
2446
+ role: "group",
2447
+ className: I("shrink-0 flex items-center justify-center gap-8", "self-start", "min-w-[32px] h-[32px]", "*:text-secondary-main", "[&>svg]:size-[18px]!", "opacity-0", "group-hover/suggestion:opacity-100", "group-focus-visible/suggestion:opacity-100", t),
2448
+ children: e
2449
+ });
2450
+ }
2451
+ //#endregion
2452
+ //#region src/components/chat-thread/chat-thread.tsx
2453
+ function io(e, t) {
2454
+ let n = a((t, n) => e({
2455
+ ...t,
2456
+ ref: n
2457
+ }));
2458
+ return n.displayName = t, n;
2459
+ }
2460
+ var ao = io(Lt.Viewport, "ChatThreadViewportPrimitive"), oo = io(Lt.Content, "ChatThreadContentPrimitive"), so = io(Lt.Item, "ChatThreadItemPrimitive");
2461
+ function co(e, t) {
2462
+ typeof e == "function" ? e(t) : e && (e.current = t);
2463
+ }
2464
+ var lo = 12, uo = "--chat-thread-group-min-height", fo = {
2465
+ scrollToEnd: () => !1,
2466
+ scrollToMessage: () => !1,
2467
+ scrollToStart: () => !1
2468
+ }, po = i(null);
2469
+ function mo() {
2470
+ return l(po) ?? fo;
2471
+ }
2472
+ function ho({ children: e }) {
2473
+ let { scrollToEnd: t, scrollToMessage: n, scrollToStart: r } = Rt(), i = m(() => ({
2474
+ scrollToEnd: t,
2475
+ scrollToMessage: n,
2476
+ scrollToStart: r
2477
+ }), [
2478
+ t,
2479
+ n,
2480
+ r
2481
+ ]);
2482
+ return /* @__PURE__ */ z(po.Provider, {
2483
+ value: i,
2484
+ children: e
2485
+ });
2486
+ }
2487
+ var go = i(null);
2488
+ function _o(e) {
2489
+ let t = l(go);
2490
+ if (!t) throw Error(`[web-chat-ui] <${e}> must be rendered inside <ChatThreadProvider>`);
2491
+ return t;
2492
+ }
2493
+ function vo(e, t, n) {
2494
+ return {
2495
+ id: e,
2496
+ conversationId: t ?? null,
2497
+ knownGroupIds: n.length === 0 ? null : new Set(n)
2498
+ };
2499
+ }
2500
+ function yo({ children: e, conversationId: t, groupIds: n, isStreaming: r = !1, scrollMode: i = "anchor", autoScroll: a = i === "follow" || !r, defaultScrollPosition: o = "end", scrollPreviousItemPeek: s = 0, scrollMargin: c = lo, ...l }) {
2501
+ let [u, d] = g(() => vo(0, t, n));
2502
+ (u.conversationId !== (t ?? null) || u.knownGroupIds === null != (n.length === 0)) && d(vo(u.id + 1, t, n));
2503
+ let { knownGroupIds: f } = u, p = m(() => ({
2504
+ isStreaming: r,
2505
+ scrollMargin: c,
2506
+ scrollMode: i,
2507
+ knownGroupIds: f
2508
+ }), [
2509
+ r,
2510
+ c,
2511
+ i,
2512
+ f
2513
+ ]);
2514
+ return /* @__PURE__ */ z(Lt.Provider, {
2515
+ autoScroll: a,
2516
+ scrollPreviousItemPeek: s,
2517
+ scrollMargin: c,
2518
+ defaultScrollPosition: o,
2519
+ ...l,
2520
+ children: /* @__PURE__ */ B(go.Provider, {
2521
+ value: p,
2522
+ children: [i === "follow" && /* @__PURE__ */ z(bo, {
2523
+ groupIds: n,
2524
+ knownGroupIds: f
2525
+ }), /* @__PURE__ */ z(ho, { children: e })]
2526
+ })
2527
+ }, u.id);
2528
+ }
2529
+ function bo({ groupIds: e, knownGroupIds: t }) {
2530
+ let { scrollToEnd: n } = Rt(), r = e.at(-1);
2531
+ return p(() => {
2532
+ r === void 0 || t === null || t.has(r) || n({ behavior: "auto" });
2533
+ }, [
2534
+ r,
2535
+ t,
2536
+ n
2537
+ ]), null;
2538
+ }
2539
+ var xo = a(function({ children: e, className: t, contentClassName: n, viewportRef: r, contentRef: i, scrollButton: a = !0, scrollButtonClassName: o, scrollButtonTooltip: s, isLoading: l = !1, hasError: u = !1, error: d, renderError: f, ...p }, m) {
2540
+ let { isStreaming: g, scrollMargin: _, scrollMode: v } = _o("ChatThread"), y = v === "anchor", b = h(null), x = h(null), S = c((e) => {
2541
+ b.current = e, co(r, e), co(m, e?.parentElement ?? null);
2542
+ }, [r, m]), C = c((e) => {
2543
+ x.current = e, co(i, e);
2544
+ }, [i]);
2545
+ return So(b, x, _, y), /* @__PURE__ */ B(Lt.Root, {
2546
+ "data-testid": "chat-thread",
2547
+ "data-scroll-mode": v,
2548
+ "data-loading": l,
2549
+ "data-error": u,
2550
+ className: I("relative flex flex-col flex-1 min-h-0 overflow-hidden", t),
2551
+ ...p,
2552
+ children: [
2553
+ /* @__PURE__ */ z(ao, {
2554
+ ref: S,
2555
+ "aria-label": "Chat message history",
2556
+ className: I("size-full overflow-x-hidden overflow-y-auto outline-none", "will-change-scroll transform-gpu", y && g && "scroll-smooth"),
2557
+ style: {
2558
+ scrollbarGutter: "stable both-edges",
2559
+ scrollbarWidth: "thin",
2560
+ scrollbarColor: "var(--color-scrollbar-thumb) transparent"
2561
+ },
2562
+ children: /* @__PURE__ */ z(oo, {
2563
+ ref: C,
2564
+ "aria-busy": g,
2565
+ "data-testid": "chat-thread-content",
2566
+ className: I("relative flex flex-col gap-16", y ? "[&>[data-chat-thread-group]:nth-last-child(2)]:min-h-(--chat-thread-group-min-height)" : "min-h-full justify-end", n),
2567
+ children: e
2568
+ })
2569
+ }),
2570
+ u && !l && /* @__PURE__ */ z(Do, {
2571
+ error: d,
2572
+ children: f?.(d)
2573
+ }),
2574
+ a && /* @__PURE__ */ z(Eo, {
2575
+ className: o,
2576
+ tooltip: s
2577
+ })
2578
+ ]
2579
+ });
2580
+ });
2581
+ function So(e, t, n, r) {
2582
+ p(() => {
2583
+ let i = e.current, a = t.current;
2584
+ if (!i || !a) return;
2585
+ if (!r) {
2586
+ a.style.removeProperty(uo);
2587
+ return;
2588
+ }
2589
+ let o = () => {
2590
+ let { paddingTop: e, paddingBottom: t } = window.getComputedStyle(a), r = i.clientHeight - (Number.parseFloat(e) || 0) - (Number.parseFloat(t) || 0) - n;
2591
+ a.style.setProperty(uo, `${Math.max(0, r)}px`);
2592
+ };
2593
+ if (o(), typeof ResizeObserver > "u") return;
2594
+ let s = new ResizeObserver(o);
2595
+ return s.observe(i), s.observe(a), () => s.disconnect();
2596
+ }, [
2597
+ e,
2598
+ t,
2599
+ n,
2600
+ r
2601
+ ]);
2602
+ }
2603
+ var Co = a(function({ groupId: e, className: t, ...n }, r) {
2604
+ let { knownGroupIds: i, scrollMode: a } = _o("ChatThreadGroup"), o = a === "anchor" && i !== null && !i.has(e);
2605
+ return /* @__PURE__ */ z(so, {
2606
+ ref: r,
2607
+ messageId: `chat-thread-group-${e}`,
2608
+ scrollAnchor: o,
2609
+ "data-chat-thread-group": "",
2610
+ className: I("flex flex-col gap-16 w-full min-h-px mx-auto", t),
2611
+ ...n
2612
+ });
2613
+ }), wo = a(function({ messageId: e, ...t }, n) {
2614
+ return /* @__PURE__ */ z("div", {
2615
+ ref: n,
2616
+ "data-chat-thread-question": "",
2617
+ "data-chat-thread-message-id": e,
2618
+ ...t
2619
+ });
2620
+ }), To = a(function({ messageId: e, ...t }, n) {
2621
+ return /* @__PURE__ */ z("div", {
2622
+ ref: n,
2623
+ "data-chat-thread-answer": "",
2624
+ "data-chat-thread-message-id": e,
2625
+ ...t
2626
+ });
2627
+ });
2628
+ function Eo({ className: e, tooltip: t }) {
2629
+ let { end: n } = zt();
2630
+ return /* @__PURE__ */ z("div", {
2631
+ "data-testid": "chat-message-history-scroll-button",
2632
+ "data-hidden": !n,
2633
+ "aria-hidden": !n || void 0,
2634
+ className: I("absolute", "px-[12px]", "bottom-0", "right-0 -translate-x-[12px]", "md:right-auto md:left-1/2 md:-translate-x-1/2", "-translate-y-[12px]", "flex items-center justify-center", "transition-opacity duration-200 ease-in-out", "data-[hidden=true]:pointer-events-none", "data-[hidden=true]:opacity-0 data-[hidden=false]:opacity-100", e),
2635
+ children: /* @__PURE__ */ z(Lt.Button, {
2636
+ direction: "end",
2637
+ render: ({ inert: e, children: n, ...r }) => /* @__PURE__ */ z(N, {
2638
+ tooltip: t,
2639
+ side: "top",
2640
+ children: /* @__PURE__ */ z(D, {
2641
+ ...r,
2642
+ inert: e ? "" : void 0,
2643
+ className: "bg-paper-elevation-2",
2644
+ color: "primary",
2645
+ size: "md",
2646
+ tabIndex: -1,
2647
+ "aria-label": t,
2648
+ children: /* @__PURE__ */ z(H, {})
2649
+ })
2650
+ })
2651
+ })
2652
+ });
2653
+ }
2654
+ function Do({ children: e, error: t, className: n }) {
2655
+ return /* @__PURE__ */ z("div", {
2656
+ "data-testid": "chat-message-history-error-state",
2657
+ role: "alert",
2658
+ "aria-live": "assertive",
2659
+ "aria-label": "Error loading messages",
2660
+ className: I("absolute inset-0 flex items-center justify-center", n),
2661
+ children: e || /* @__PURE__ */ z("div", {
2662
+ className: "text-text-error-main",
2663
+ children: t instanceof Error ? t.message : t || "An error occurred"
2664
+ })
2665
+ });
2666
+ }
2667
+ //#endregion
2668
+ //#region src/components/canvas-shell/canvas-shell.tsx
2669
+ function Oo({ className: e, ...t }) {
2670
+ return /* @__PURE__ */ z("section", {
2671
+ "data-slot": "canvas-shell",
2672
+ className: F("grid grid-rows-[auto_minmax(0,1fr)_auto]", "h-full overflow-hidden", e),
2673
+ ...t
2674
+ });
2675
+ }
2676
+ function ko({ className: e, hasBorder: t = !0, ...n }) {
2677
+ return /* @__PURE__ */ z("header", {
2678
+ "data-slot": "canvas-shell-header",
2679
+ "data-separator": t,
2680
+ className: F("row-start-1", "flex items-center gap-[8px]", "p-[12px] md:p-[16px]", "data-[separator=true]:border-b data-[separator=true]:border-brand-secondary-700", e),
2681
+ ...n
2682
+ });
2683
+ }
2684
+ function Ao({ className: e, ...t }) {
2685
+ return /* @__PURE__ */ z(P, {
2686
+ "data-slot": "canvas-shell-title",
2687
+ variant: "label-xl",
2688
+ fontWeight: "normal",
2689
+ className: F("flex-1 min-w-0 truncate", e),
2690
+ ...t
2691
+ });
2692
+ }
2693
+ function jo({ className: e, children: t, ...n }) {
2694
+ return /* @__PURE__ */ z(D, {
2695
+ "data-slot": "canvas-shell-close-trigger",
2696
+ type: "button",
2697
+ variant: "tertiary",
2698
+ size: "md",
2699
+ "aria-label": "Close panel",
2700
+ className: F("shrink-0", e),
2701
+ ...n,
2702
+ children: t || /* @__PURE__ */ z(U, {})
2703
+ });
2704
+ }
2705
+ function Mo({ className: e, children: t, isFullScreen: n, labels: r, ...i }) {
2706
+ return /* @__PURE__ */ z(D, {
2707
+ "data-slot": "canvas-shell-full-screen-trigger",
2708
+ type: "button",
2709
+ variant: "tertiary",
2710
+ size: "md",
2711
+ "aria-pressed": n,
2712
+ "aria-label": n ? r?.exit ?? "Exit full screen" : r?.enter ?? "Full screen",
2713
+ className: F("shrink-0 max-md:hidden", e),
2714
+ ...i,
2715
+ children: t || /* @__PURE__ */ z(Te, {})
2716
+ });
2717
+ }
2718
+ function No({ className: e, children: t, menuClassName: n, onOpenChange: r, ...i }) {
2719
+ let [a, o] = g(!1);
2720
+ function s(e) {
2721
+ o(e), r?.(e);
2722
+ }
2723
+ return /* @__PURE__ */ B(k, {
2724
+ modal: !1,
2725
+ onOpenChange: s,
2726
+ children: [/* @__PURE__ */ z(A, {
2727
+ asChild: !0,
2728
+ children: /* @__PURE__ */ z(D, {
2729
+ "data-slot": "canvas-shell-options-button",
2730
+ type: "button",
2731
+ variant: "tertiary",
2732
+ size: "md",
2733
+ isActive: a,
2734
+ "aria-label": "More options",
2735
+ className: F("shrink-0", e),
2736
+ ...i,
2737
+ children: /* @__PURE__ */ z(we, {})
2738
+ })
2739
+ }), /* @__PURE__ */ z(O, {
2740
+ className: F("w-[200px]", n),
2741
+ children: t
2742
+ })]
2743
+ });
2744
+ }
2745
+ var Po = "px-[12px] md:px-[16px]";
2746
+ function Fo({ className: e, hasPadding: t = !0, hasScroll: n = !0, children: r, ...i }) {
2747
+ return /* @__PURE__ */ z("div", {
2748
+ "data-slot": "canvas-shell-content",
2749
+ "data-has-scroll": n,
2750
+ className: F("row-start-2", "relative min-w-0 overflow-hidden", e),
2751
+ ...i,
2752
+ children: /* @__PURE__ */ z("div", {
2753
+ "data-slot": "canvas-shell-content-body",
2754
+ "data-spacing": t,
2755
+ className: F("size-full", "py-[16px]", t && "px-[12px] md:px-[16px]", n ? "overflow-auto" : "overflow-hidden"),
2756
+ children: r
2757
+ })
2758
+ });
2759
+ }
2760
+ function Io({ className: e, ...t }) {
2761
+ return /* @__PURE__ */ z("footer", {
2762
+ "data-slot": "canvas-shell-footer",
2763
+ className: F("row-start-3", "flex items-center justify-end gap-[8px]", "p-[12px] md:p-[16px]", "pb-[20px]", e),
2764
+ ...t
2765
+ });
2766
+ }
2767
+ //#endregion
2768
+ //#region src/components/card-item-picker/card-item-picker-context.tsx
2769
+ var Lo = i(null);
2770
+ function Ro() {
2771
+ let e = l(Lo);
2772
+ if (!e) throw Error("useCardItemPickerListContext must be used within a CardItemPickerList");
2773
+ return e;
2774
+ }
2775
+ var zo = i(null);
2776
+ function Bo() {
2777
+ let e = l(zo);
2778
+ if (!e) throw Error("useCardItemPickerRowContext must be used within a CardItemPickerRow");
2779
+ return e;
2780
+ }
2781
+ //#endregion
2782
+ //#region src/components/card-item-picker/card-item-picker-list.tsx
2783
+ function Vo({ value: e, hoveredValue: t = null, onValueChange: n, onHoverChange: r, orientation: i = "vertical", className: a, children: o, ...s }) {
2784
+ let [l, u] = g(null), d = l ?? (e == null ? null : String(e)), f = h(r);
2785
+ f.current = r;
2786
+ let p = h(n);
2787
+ p.current = n;
2788
+ let _ = c((e) => p.current(e), []), v = c((e) => f.current?.(e), []), y = m(() => ({
2789
+ value: e,
2790
+ hoveredValue: t,
2791
+ orientation: i,
2792
+ select: _,
2793
+ hover: v
2794
+ }), [
2795
+ e,
2796
+ t,
2797
+ i,
2798
+ _,
2799
+ v
2800
+ ]);
2801
+ return /* @__PURE__ */ z(Lo.Provider, {
2802
+ value: y,
2803
+ children: /* @__PURE__ */ z(Bt.Root, {
2804
+ asChild: !0,
2805
+ orientation: i,
2806
+ currentTabStopId: d,
2807
+ onCurrentTabStopIdChange: u,
2808
+ children: /* @__PURE__ */ z("ul", {
2809
+ ...s,
2810
+ role: "listbox",
2811
+ "aria-orientation": i,
2812
+ className: F("flex gap-[4px]", i === "vertical" ? "flex-col" : "flex-row", a),
2813
+ children: o
2814
+ })
2815
+ })
2816
+ });
2817
+ }
2818
+ //#endregion
2819
+ //#region src/components/card-item-picker/card-item-picker-row.tsx
2820
+ var Ho = a(function({ value: e, className: t, children: n, onClick: r, onKeyDown: i, onMouseEnter: a, onMouseLeave: o, ...s }, c) {
2821
+ let l = Ro(), u = d(), [f, p] = g(!1), [h, _] = g(!1), v = l.value === e, y = l.hoveredValue === e, b = m(() => ({
2822
+ isSelected: v,
2823
+ titleId: `${u}-title`,
2824
+ descriptionId: `${u}-description`,
2825
+ registerTitle: () => (p(!0), () => p(!1)),
2826
+ registerDescription: () => (_(!0), () => _(!1))
2827
+ }), [u, v]);
2828
+ function x(t) {
2829
+ i?.(t), !t.defaultPrevented && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), l.select(e));
2830
+ }
2831
+ return /* @__PURE__ */ z(zo.Provider, {
2832
+ value: b,
2833
+ children: /* @__PURE__ */ z(Bt.Item, {
2834
+ asChild: !0,
2835
+ tabStopId: String(e),
2836
+ children: /* @__PURE__ */ z("li", {
2837
+ ...s,
2838
+ ref: c,
2839
+ role: "option",
2840
+ "aria-selected": v,
2841
+ "aria-labelledby": f ? b.titleId : void 0,
2842
+ "aria-describedby": h ? b.descriptionId : void 0,
2843
+ "data-selected": v,
2844
+ "data-hovered": y,
2845
+ className: F("relative flex flex-row items-start gap-4", "w-full cursor-pointer rounded-(--st-border-radius-md) p-8", "transition-colors duration-150", "hover:bg-layout-accent-low-background-hover-base", "data-[selected=true]:bg-layout-accent-low-background-pressed-base", "data-[selected=true]:not-focus-visible:ring-1 data-[selected=true]:not-focus-visible:ring-inset", "data-[selected=true]:not-focus-visible:ring-brand-secondary-700", "outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-secondary-focus-visible", t),
2846
+ onClick: (t) => {
2847
+ r?.(t), t.defaultPrevented || l.select(e);
2848
+ },
2849
+ onKeyDown: x,
2850
+ onMouseEnter: (t) => {
2851
+ a?.(t), l.hover(e);
2852
+ },
2853
+ onMouseLeave: (e) => {
2854
+ o?.(e), l.hover(null);
2855
+ },
2856
+ children: n
2857
+ })
2858
+ })
2859
+ });
2860
+ });
2861
+ //#endregion
2862
+ //#region src/components/card-item-picker/card-item-picker-row-parts.tsx
2863
+ function Uo({ className: e, ...t }) {
2864
+ return Bo(), /* @__PURE__ */ z("div", {
2865
+ "aria-hidden": !0,
2866
+ className: F("shrink-0 aspect-square h-[64px] rounded-[4px] overflow-hidden bg-secondary-states-hover", e),
2867
+ ...t
2868
+ });
2869
+ }
2870
+ function Wo({ className: e, ...t }) {
2871
+ return Bo(), /* @__PURE__ */ z("div", {
2872
+ className: F("flex-1 min-w-0 flex flex-col", e),
2873
+ ...t
2874
+ });
2875
+ }
2876
+ function Go({ children: e, className: t }) {
2877
+ let { titleId: n, registerTitle: r } = Bo();
2878
+ return p(r, [r]), /* @__PURE__ */ z(P, {
2879
+ id: n,
2880
+ variant: "body",
2881
+ fontWeight: "semibold",
2882
+ className: F("line-clamp-1", t),
2883
+ title: e,
2884
+ children: e
2885
+ });
2886
+ }
2887
+ function Ko({ className: e, ...t }) {
2888
+ let { descriptionId: n, registerDescription: r } = Bo();
2889
+ return p(r, [r]), /* @__PURE__ */ z("div", {
2890
+ ...t,
2891
+ id: n,
2892
+ className: e
2893
+ });
2894
+ }
2895
+ function qo({ className: e }) {
2896
+ let { isSelected: t } = Bo();
2897
+ return /* @__PURE__ */ z("div", {
2898
+ "aria-hidden": !0,
2899
+ "data-testid": "card-item-picker-row-checkbox",
2900
+ className: F("pointer-events-none absolute top-[8px] right-[8px]", e),
2901
+ children: /* @__PURE__ */ z(v, {
2902
+ checked: t,
2903
+ tabIndex: -1
2904
+ })
2905
+ });
2906
+ }
2907
+ //#endregion
2908
+ //#region src/components/new-chat-trigger/new-chat-trigger.tsx
2909
+ var Jo = a(({ asChild: t = !1, children: n, onClick: r, ...i }, a) => {
2910
+ let { goToNewChat: o } = X(), s = t ? e : "button";
2911
+ function c(e) {
2912
+ r?.(e), o();
2913
+ }
2914
+ return /* @__PURE__ */ z(s, {
2915
+ ref: a,
2916
+ "data-testid": "new-chat-trigger",
2917
+ onClick: c,
2918
+ ...i,
2919
+ children: n
2920
+ });
2921
+ });
2922
+ Jo.displayName = "NewChatTrigger";
2923
+ //#endregion
2924
+ //#region src/components/chat-thinking-process/chat-thinking-process.tsx
2925
+ var Yo = a(function({ children: e, className: t, defaultOpen: n = !1, isStreaming: r = !1, ...i }, a) {
2926
+ return /* @__PURE__ */ z(b, {
2927
+ defaultOpen: n,
2928
+ asChild: !0,
2929
+ ...i,
2930
+ children: /* @__PURE__ */ z("div", {
2931
+ ref: a,
2932
+ "data-testid": "chat-thinking-process",
2933
+ "data-streaming": r,
2934
+ className: I("group/thinking-process", "flex flex-col", t),
2935
+ children: e
2936
+ })
2937
+ });
2938
+ });
2939
+ Yo.displayName = "ChatThinkingProcess";
2940
+ function Xo({ children: e, className: t, ...n }) {
2941
+ return /* @__PURE__ */ B(S, {
2942
+ "data-testid": "chat-thinking-process-trigger",
2943
+ className: I("flex w-full items-center gap-4", "cursor-pointer text-left", t),
2944
+ ...n,
2945
+ children: [e, /* @__PURE__ */ z("style", { children: "\n @keyframes shimmer {\n 100% {\n mask-position: left;\n }\n }\n " })]
2946
+ });
2947
+ }
2948
+ function Zo({ children: e, className: t, ...n }) {
2949
+ return /* @__PURE__ */ z("span", {
2950
+ "data-testid": "chat-thinking-process-trigger-icon",
2951
+ className: I("inline-flex shrink-0 items-center justify-center", t),
2952
+ ...n,
2953
+ children: e
2954
+ });
2955
+ }
2956
+ function Qo({ children: e, className: t, ...n }) {
2957
+ return /* @__PURE__ */ z(P, {
2958
+ asChild: !0,
2959
+ variant: "body-sm",
2960
+ "data-testid": "chat-thinking-process-trigger-label",
2961
+ className: I("text-text-secondary", "font-semibold", "group-data-[streaming=true]/thinking-process:mask-[linear-gradient(-60deg,#000_30%,rgba(0,0,0,0.2),#192029_70%)]", "group-data-[streaming=true]/thinking-process:mask-size-[300%_100%]", "group-data-[streaming=true]/thinking-process:mask-right", "group-data-[streaming=true]/thinking-process:animate-[shimmer_3.2s_infinite]", t),
2962
+ children: /* @__PURE__ */ z("span", {
2963
+ ...n,
2964
+ children: e
2965
+ })
2966
+ });
2967
+ }
2968
+ function $o({ className: e, ...t }) {
2969
+ return /* @__PURE__ */ z("span", {
2970
+ "data-testid": "chat-thinking-process-trigger-arrow",
2971
+ "aria-hidden": !0,
2972
+ className: I("inline-flex shrink-0 items-center justify-center text-text-secondary", "transition-transform duration-300", "group-data-[state=open]/collapsible:rotate-180", e),
2973
+ ...t,
2974
+ children: /* @__PURE__ */ z(H, {})
2975
+ });
2976
+ }
2977
+ function es({ children: e, className: n, itemsClassName: r, hasLastMessagePreview: i = !0, ...a }) {
2978
+ let { lastItemContent: o, lastItemIndex: s } = m(() => {
2979
+ let n = t.Children.toArray(e);
2980
+ return {
2981
+ lastItemContent: n.at(-1),
2982
+ lastItemIndex: String(n.length)
2983
+ };
2984
+ }, [e]);
2985
+ return /* @__PURE__ */ B("div", {
2986
+ "data-testid": "chat-thinking-process-content",
2987
+ "data-preview": i,
2988
+ className: I("pt-8", n),
2989
+ children: [i && o && /* @__PURE__ */ z(Vt, {
2990
+ mode: "wait",
2991
+ children: /* @__PURE__ */ z(ts, {
2992
+ contentId: s,
2993
+ children: o
2994
+ })
2995
+ }), /* @__PURE__ */ z(x, {
2996
+ "data-testid": "chat-thinking-process-content-items",
2997
+ className: I("flex flex-col", r),
2998
+ ...a,
2999
+ children: t.Children.map(e, (e) => /* @__PURE__ */ B("div", {
3000
+ className: I("relative flex gap-8 text-text-secondary text-sm last:pb-0", "pl-8", "last:[&>div:first-child>span:last-child]:hidden"),
3001
+ ...a,
3002
+ children: [/* @__PURE__ */ B("div", {
3003
+ className: "relative flex w-8 shrink-0 flex-col items-center self-stretch",
3004
+ "aria-hidden": !0,
3005
+ children: [/* @__PURE__ */ z("span", { className: "mt-[7px] size-[6px] shrink-0 rounded-full bg-text-secondary" }), /* @__PURE__ */ z("span", { className: "absolute top-[16px] bottom-[-4px] left-1/2 w-px -translate-x-1/2 bg-component-divider" })]
3006
+ }), /* @__PURE__ */ z("div", {
3007
+ className: "min-w-0 flex-1 pb-8",
3008
+ children: e
3009
+ })]
3010
+ }))
3011
+ })]
3012
+ });
3013
+ }
3014
+ function ts({ children: e, className: t, contentId: n }) {
3015
+ return /* @__PURE__ */ z(Ht.div, {
3016
+ "data-testid": "chat-thinking-process-content-preview",
3017
+ initial: { opacity: 0 },
3018
+ animate: { opacity: .7 },
3019
+ exit: { opacity: 0 },
3020
+ transition: {
3021
+ duration: .25,
3022
+ ease: "easeOut"
3023
+ },
3024
+ className: I("group-data-[streaming=false]/thinking-process:hidden", "group-data-[state=open]/thinking-process:hidden", "px-4", t),
3025
+ children: e
3026
+ }, n);
3027
+ }
3028
+ function ns({ children: e, className: t, ...n }) {
3029
+ return /* @__PURE__ */ z("div", {
3030
+ "data-testid": "chat-thinking-process-content-item",
3031
+ className: I("text-text-secondary text-sm", t),
3032
+ ...n,
3033
+ children: e
3034
+ });
3035
+ }
3036
+ //#endregion
3037
+ //#region src/components/deprecated-empty-state.ts
3038
+ var rs = w, is = ee, as = te, os = E, ss = T, cs = {
3039
+ paragraph: "editor-paragraph",
3040
+ text: {
3041
+ bold: "editor-text-bold",
3042
+ italic: "editor-text-italic",
3043
+ underline: "editor-text-underline"
3044
+ }
3045
+ }, ls = class e extends pt {
3046
+ __src;
3047
+ __altText;
3048
+ static getType() {
3049
+ return "image";
3050
+ }
3051
+ static clone(t) {
3052
+ return new e(t.__src, t.__altText, t.__key);
3053
+ }
3054
+ constructor(e, t, n) {
3055
+ super(n), this.__src = e, this.__altText = t;
3056
+ }
3057
+ createDOM() {
3058
+ let e = document.createElement("span");
3059
+ return e.style.display = "inline-block", e;
3060
+ }
3061
+ updateDOM() {
3062
+ return !1;
3063
+ }
3064
+ decorate() {
3065
+ return /* @__PURE__ */ z("img", {
3066
+ src: this.__src,
3067
+ alt: this.__altText,
3068
+ style: {
3069
+ maxWidth: "100%",
3070
+ display: "block"
3071
+ },
3072
+ draggable: !1
3073
+ });
3074
+ }
3075
+ exportDOM() {
3076
+ let e = document.createElement("img");
3077
+ return e.setAttribute("src", this.__src), e.setAttribute("alt", this.__altText), e.style.maxWidth = "100%", { element: e };
3078
+ }
3079
+ static importDOM() {
3080
+ return { img: () => ({
3081
+ conversion: (e) => {
3082
+ let t = e.getAttribute("src") || "", n = e.getAttribute("alt") || "";
3083
+ return t ? { node: us(t, n) } : null;
3084
+ },
3085
+ priority: 0
3086
+ }) };
3087
+ }
3088
+ exportJSON() {
3089
+ return {
3090
+ ...super.exportJSON(),
3091
+ src: this.__src,
3092
+ altText: this.__altText,
3093
+ type: "image",
3094
+ version: 1
3095
+ };
3096
+ }
3097
+ static importJSON(e) {
3098
+ return us(e.src, e.altText);
3099
+ }
3100
+ isInline() {
3101
+ return !1;
3102
+ }
3103
+ };
3104
+ function us(e, t) {
3105
+ return new ls(e, t);
3106
+ }
3107
+ function ds(e) {
3108
+ return e instanceof ls;
3109
+ }
3110
+ //#endregion
3111
+ //#region src/components/rich-text-area/transformers.ts
3112
+ function fs(e) {
3113
+ let t = /font-size\s*:\s*([^;]+)/i, n = /font-family\s*:\s*([^;]+)/i, r = /(?<![\w-])color\s*:\s*([^;]+)/i, i = t.exec(e), a = n.exec(e), o = r.exec(e);
3114
+ return {
3115
+ fontSize: i ? i[1].trim() : null,
3116
+ fontFamily: a ? a[1].trim() : null,
3117
+ color: o ? o[1].trim() : null
3118
+ };
3119
+ }
3120
+ var ps = {
3121
+ type: "text-match",
3122
+ trigger: "",
3123
+ regExp: /./,
3124
+ importRegExp: /./,
3125
+ dependencies: [],
3126
+ export: (e) => {
3127
+ if (!q(e)) return null;
3128
+ let t = e.getStyle() ?? "", n = e.getTextContent(), r = fs(t);
3129
+ if (r.fontSize || r.fontFamily || r.color) {
3130
+ let e = "";
3131
+ return r.fontSize && (e += `font-size: ${r.fontSize};`), r.fontFamily && (e += `font-family: ${r.fontFamily};`), r.color && (e += `color: ${r.color};`), `<span style="${e}">${n}</span>`;
3132
+ }
3133
+ return null;
3134
+ }
3135
+ }, ms = {
3136
+ type: "text-match",
3137
+ trigger: "",
3138
+ regExp: /<span\s+style="([^"]+)">(.+?)<\/span>/,
3139
+ importRegExp: /<span\s+style="([^"]+)">(.+?)<\/span>/,
3140
+ dependencies: [],
3141
+ replace: (e, t) => {
3142
+ let [, n, r] = t, i = nt(r);
3143
+ return i.setFormat(e.getFormat()), i.setStyle(n), e.replace(i), i;
3144
+ }
3145
+ }, hs = {
3146
+ type: "text-match",
3147
+ trigger: "",
3148
+ regExp: /<ins>(.*?)<\/ins>/,
3149
+ importRegExp: /<ins>(.*?)<\/ins>/,
3150
+ dependencies: [],
3151
+ replace: (e, t) => {
3152
+ let n = nt(t[1]);
3153
+ return n.setFormat(e.getFormat()), n.hasFormat("underline") || n.toggleFormat("underline"), e.replace(n), n;
3154
+ },
3155
+ export: (e) => !q(e) || !e.hasFormat("underline") ? null : `<ins>${e.getTextContent()}</ins>`
3156
+ }, gs = (e) => {
3157
+ let t = /text-align:\s*(\w+)/i.exec(e);
3158
+ return t ? t[1].trim() : null;
3159
+ }, _s = {
3160
+ type: "element",
3161
+ dependencies: [],
3162
+ regExp: /<div\s+style="([^"]+)">(.*?)<\/div>/,
3163
+ replace: (e, t, n) => {
3164
+ let r = gs(n[1]);
3165
+ if (!r) return !1;
3166
+ if (!n[2]) return;
3167
+ let i = t[0];
3168
+ q(i) && i.setTextContent(n[2]), e.setFormat(r), e.append(...t);
3169
+ },
3170
+ export: (e, t) => {
3171
+ if (!ot(e)) return null;
3172
+ let n = e.getFormatType();
3173
+ return !n || n === "left" ? null : `<div style="text-align: ${n}">${t(e)}</div>`;
3174
+ }
3175
+ }, vs = {
3176
+ type: "text-match",
3177
+ trigger: "",
3178
+ regExp: /./,
3179
+ importRegExp: /./,
3180
+ dependencies: [ls],
3181
+ export: (e) => ds(e) ? `<img src="${e.__src}" alt="${e.__altText}" />` : null
3182
+ }, ys = {
3183
+ type: "text-match",
3184
+ trigger: "",
3185
+ regExp: /<img\s+src="([^"]+)"\s+alt="([^"]*)"[^>]*\/?>/,
3186
+ importRegExp: /<img\s+src="([^"]+)"\s+alt="([^"]*)"[^>]*\/?>/,
3187
+ dependencies: [ls],
3188
+ replace: (e, t) => {
3189
+ let [, n, r] = t, i = us(n, r);
3190
+ e.replace(i);
3191
+ }
3192
+ }, bs = [
3193
+ ...Qe,
3194
+ ps,
3195
+ hs,
3196
+ _s,
3197
+ vs
3198
+ ], xs = [
3199
+ ...Qe,
3200
+ ms,
3201
+ hs,
3202
+ _s,
3203
+ ys
3204
+ ];
3205
+ //#endregion
3206
+ //#region src/components/rich-text-area/html-config.ts
3207
+ function Ss(e) {
3208
+ let t = e.nodeName.toLowerCase();
3209
+ if (t !== "h1" && t !== "h2" && t !== "h3" && t !== "h4" && t !== "h5" && t !== "h6") return null;
3210
+ let n = Ge(t), r = e.getAttribute("style") ?? "";
3211
+ if (n.setStyle(r), e.style) {
3212
+ let t = e.style.textAlign;
3213
+ (t === "left" || t === "right" || t === "center" || t === "justify" || t === "start" || t === "end") && n.setFormat(t), wt(e, n);
3214
+ }
3215
+ return { node: n };
3216
+ }
3217
+ function Cs(e) {
3218
+ if (e.getAttribute("__lexicallisttype") === "check" || e.classList.contains("contains-task-list")) return !0;
3219
+ for (let t of e.childNodes) if (Ct(t) && t.hasAttribute("aria-checked")) return !0;
3220
+ return !1;
3221
+ }
3222
+ function ws(e) {
3223
+ let t = e.nodeName.toLowerCase(), n = null;
3224
+ if (t === "ol") {
3225
+ let t = e.start;
3226
+ n = Le("number", t);
3227
+ } else t === "ul" && (n = Cs(e) ? Le("check") : Le("bullet"));
3228
+ if (!n) return null;
3229
+ let r = e.getAttribute("style") ?? "";
3230
+ return n.setStyle(r), { node: n };
3231
+ }
3232
+ function Ts(e) {
3233
+ if (e.classList.contains("task-list-item")) {
3234
+ for (let t of e.children) if (t.tagName === "INPUT") {
3235
+ let n = t;
3236
+ if (n.getAttribute("type") === "checkbox") {
3237
+ let t = n.hasAttribute("checked"), r = Ie(t), i = e.getAttribute("style") ?? "";
3238
+ return r.setStyle(i), { node: r };
3239
+ }
3240
+ }
3241
+ }
3242
+ let t = e.getAttribute("aria-checked"), n = Ie(t === "true" || t !== "false" && void 0), r = e.getAttribute("style") ?? "";
3243
+ return n.setStyle(r), { node: n };
3244
+ }
3245
+ var Z = 4;
3246
+ function Es(e) {
3247
+ let { color: t, fontSize: n, fontFamily: r } = fs(e.getAttribute("style") ?? "");
3248
+ if (!t && !n && !r) return null;
3249
+ let i = e.style;
3250
+ return {
3251
+ forChild: (e) => {
3252
+ if (!q(e)) return e;
3253
+ let a = i.fontWeight, o = (i.textDecoration || "").split(" ");
3254
+ (a === "700" || a === "bold") && !e.hasFormat("bold") && e.toggleFormat("bold"), o.includes("line-through") && !e.hasFormat("strikethrough") && e.toggleFormat("strikethrough"), i.fontStyle === "italic" && !e.hasFormat("italic") && e.toggleFormat("italic"), o.includes("underline") && !e.hasFormat("underline") && e.toggleFormat("underline"), i.verticalAlign === "sub" && !e.hasFormat("subscript") && e.toggleFormat("subscript"), i.verticalAlign === "super" && !e.hasFormat("superscript") && e.toggleFormat("superscript");
3255
+ let s = "";
3256
+ return n && (s += `font-size: ${n};`), r && (s += `font-family: ${r};`), t && (s += `color: ${t};`), e.setStyle(s), e;
3257
+ },
3258
+ node: null
3259
+ };
3260
+ }
3261
+ var Ds = {
3262
+ h1: () => ({
3263
+ conversion: Ss,
3264
+ priority: Z
3265
+ }),
3266
+ h2: () => ({
3267
+ conversion: Ss,
3268
+ priority: Z
3269
+ }),
3270
+ h3: () => ({
3271
+ conversion: Ss,
3272
+ priority: Z
3273
+ }),
3274
+ h4: () => ({
3275
+ conversion: Ss,
3276
+ priority: Z
3277
+ }),
3278
+ h5: () => ({
3279
+ conversion: Ss,
3280
+ priority: Z
3281
+ }),
3282
+ h6: () => ({
3283
+ conversion: Ss,
3284
+ priority: Z
3285
+ }),
3286
+ ul: () => ({
3287
+ conversion: ws,
3288
+ priority: Z
3289
+ }),
3290
+ ol: () => ({
3291
+ conversion: ws,
3292
+ priority: Z
3293
+ }),
3294
+ li: () => ({
3295
+ conversion: Ts,
3296
+ priority: Z
3297
+ }),
3298
+ span: () => ({
3299
+ conversion: Es,
3300
+ priority: Z
3301
+ })
3302
+ };
3303
+ function Os(e) {
3304
+ return (t, n) => {
3305
+ let r = e.prototype.exportDOM.call(n, t), i = n.getStyle();
3306
+ return r.element && i && r.element.setAttribute("style", i), r;
3307
+ };
3308
+ }
3309
+ var ks = /* @__PURE__ */ new Map([
3310
+ [Ke, Os(Ke)],
3311
+ [ze, Os(ze)],
3312
+ [Re, Os(Re)]
3313
+ ]), As = class e extends mt {
3314
+ static getType() {
3315
+ return "div-block";
3316
+ }
3317
+ static clone(t) {
3318
+ return new e(t.__key);
3319
+ }
3320
+ createDOM(e) {
3321
+ let t = document.createElement("div"), n = this.getStyle();
3322
+ return n && (t.style.cssText = n), t;
3323
+ }
3324
+ updateDOM(e, t) {
3325
+ let n = e.getStyle(), r = this.getStyle();
3326
+ return n !== r && (t.style.cssText = r, !0);
3327
+ }
3328
+ static importDOM() {
3329
+ return { div: () => ({
3330
+ conversion: js,
3331
+ priority: 4
3332
+ }) };
3333
+ }
3334
+ exportJSON() {
3335
+ let e = super.exportJSON(), t = this.getStyle();
3336
+ return t ? {
3337
+ ...e,
3338
+ style: t
3339
+ } : e;
3340
+ }
3341
+ static importJSON(e) {
3342
+ let t = Ms().updateFromJSON(e);
3343
+ return e.style !== void 0 && t.setStyle(e.style), t;
3344
+ }
3345
+ updateFromJSON(e) {
3346
+ let t = super.updateFromJSON(e);
3347
+ return e.style !== void 0 && t.setStyle(e.style), t;
3348
+ }
3349
+ collapseAtStart(e) {
3350
+ let t = this.getChildren();
3351
+ if (t.length === 0 || q(t[0]) && t[0].getTextContent().trim() === "") {
3352
+ if (this.getNextSibling() !== null) return this.selectNext(), this.remove(), !0;
3353
+ if (this.getPreviousSibling() !== null) return this.selectPrevious(), this.remove(), !0;
3354
+ } else {
3355
+ let e = et();
3356
+ return e.setFormat(this.getFormatType()), e.setStyle(this.getStyle()), e.setIndent(this.getIndent()), e.setDirection(this.getDirection()), t.forEach((t) => e.append(t)), this.replace(e), !0;
3357
+ }
3358
+ return !1;
3359
+ }
3360
+ };
3361
+ function js(e) {
3362
+ let t = Ms(), n = e.getAttribute("style") ?? "";
3363
+ if (t.setStyle(n), e.style) {
3364
+ let n = e.style.textAlign;
3365
+ (n === "left" || n === "right" || n === "center" || n === "justify" || n === "start" || n === "end") && t.setFormat(n), wt(e, t);
3366
+ }
3367
+ return { node: t };
3368
+ }
3369
+ function Ms() {
3370
+ return new As();
3371
+ }
3372
+ //#endregion
3373
+ //#region src/components/rich-text-area/plugins/value-plugin.tsx
3374
+ function Ns({ onChange: e, source: t = "markdown" }) {
3375
+ let n = c((n, r, i) => {
3376
+ if (!i.has("focus") && e) try {
3377
+ n.read(() => {
3378
+ e(t === "html" ? qt(r) : Xe(bs));
3379
+ });
3380
+ } catch {}
3381
+ }, [e, t]);
3382
+ return /* @__PURE__ */ z(Tt, { onChange: n });
3383
+ }
3384
+ //#endregion
3385
+ //#region src/components/rich-text-area/hooks.ts
3386
+ function Q() {
3387
+ let [e] = Je();
3388
+ return e;
3389
+ }
3390
+ function Ps() {
3391
+ let [e] = Je();
3392
+ return c(() => {
3393
+ let t = "";
3394
+ return e.getEditorState().read(() => {
3395
+ t = G()?.getTextContent() ?? "";
3396
+ }), t;
3397
+ }, [e]);
3398
+ }
3399
+ //#endregion
3400
+ //#region src/components/rich-text-area/plugins/disabled-plugin.tsx
3401
+ function Fs({ isDisabled: e }) {
3402
+ let t = Q();
3403
+ return u(() => {
3404
+ t.setEditable(!e);
3405
+ }, [t, e]), null;
3406
+ }
3407
+ //#endregion
3408
+ //#region src/components/rich-text-area/plugins/controlled-plugin.tsx
3409
+ function Is({ controlledRef: e }) {
3410
+ let t = h(null);
3411
+ return f(e, () => ({ focus: () => {
3412
+ Promise.resolve().then(() => {
3413
+ t.current?.focus();
3414
+ });
3415
+ } }), []), /* @__PURE__ */ z(Yt, { editorRef: t });
3416
+ }
3417
+ //#endregion
3418
+ //#region src/components/rich-text-area/utils/index.ts
3419
+ function Ls(e) {
3420
+ let t = e.getRootElement();
3421
+ t && (t.scrollTop = t.scrollHeight);
3422
+ }
3423
+ function Rs() {
3424
+ let e = W().getLastDescendant();
3425
+ if (e && q(e)) {
3426
+ let t = tt(), n = e.getTextContentSize();
3427
+ t.anchor.set(e.getKey(), n, "text"), t.focus.set(e.getKey(), n, "text"), ct(t);
3428
+ } else {
3429
+ st();
3430
+ let e = G();
3431
+ if (K(e)) {
3432
+ let t = e.focus.getNode(), n = q(t) ? t.getTextContentSize() : 0;
3433
+ e.anchor.set(e.focus.key, e.focus.offset, e.focus.type), e.focus.set(e.focus.key, n, e.focus.type), ct(e);
3434
+ }
3435
+ }
3436
+ }
3437
+ function zs(e, t) {
3438
+ let n = new DOMParser().parseFromString(t, "text/html");
3439
+ return Jt(e, n).map((e) => {
3440
+ if (q(e)) {
3441
+ let t = et();
3442
+ return t.append(e), t;
3443
+ }
3444
+ return e;
3445
+ });
3446
+ }
3447
+ function Bs(e, t) {
3448
+ let n = W();
3449
+ n.clear(), zs(e, t).forEach((e) => n.append(e));
3450
+ }
3451
+ function Vs(e, t) {
3452
+ let n = G(), r = zs(e, t);
3453
+ if (K(n)) n.insertNodes(r);
3454
+ else {
3455
+ let e = W();
3456
+ e.clear(), r.forEach((t) => e.append(t));
3457
+ }
3458
+ }
3459
+ //#endregion
3460
+ //#region src/components/rich-text-area/plugins/controlled-value-plugin.tsx
3461
+ function Hs({ value: e, source: t = "markdown" }) {
3462
+ let n = Q(), r = h(), i = h(!!e?.trim()), a = oe("desktop");
3463
+ return u(() => {
3464
+ if (!n || e === r.current) return;
3465
+ r.current = e;
3466
+ let o = "";
3467
+ if (n.getEditorState().read(() => {
3468
+ o = t === "html" ? qt(n) : Xe(bs);
3469
+ }), e !== void 0 && e !== o) {
3470
+ if (e === "") {
3471
+ n.update(() => {
3472
+ $e(yt), t === "html" ? W().clear() : Ye("", xs), Rs();
3473
+ }, { discrete: !0 }), Promise.resolve().then(() => {
3474
+ a ? n.focus() : n.blur();
3475
+ });
3476
+ return;
3477
+ }
3478
+ n.update(() => {
3479
+ $e(yt), t === "html" ? Bs(n, e) : Ye(e, xs), Rs();
3480
+ }), i.current && (i.current = !1, Promise.resolve().then(() => {
3481
+ requestAnimationFrame(() => Ls(n));
3482
+ })), a && Promise.resolve().then(() => {
3483
+ n.focus();
3484
+ });
3485
+ }
3486
+ }, [
3487
+ n,
3488
+ e,
3489
+ t,
3490
+ a
3491
+ ]), null;
3492
+ }
3493
+ //#endregion
3494
+ //#region src/components/rich-text-area/plugins/blur-plugin.tsx
3495
+ function Us({ onBlur: e }) {
3496
+ let t = Q();
3497
+ return u(() => {
3498
+ if (!e) return;
3499
+ let n = t.getRootElement();
3500
+ if (!n) return;
3501
+ function r(t) {
3502
+ n && e && !n.contains(t.relatedTarget) && e();
3503
+ }
3504
+ return n.addEventListener("blur", r, !0), () => {
3505
+ n.removeEventListener("blur", r, !0);
3506
+ };
3507
+ }, [t, e]), null;
3508
+ }
3509
+ //#endregion
3510
+ //#region src/components/rich-text-area/plugins/focus-plugin.tsx
3511
+ function Ws({ onFocusChange: e }) {
3512
+ let t = Q();
3513
+ return u(() => {
3514
+ if (!e) return;
3515
+ let n = t.getRootElement();
3516
+ if (!n) return;
3517
+ function r() {
3518
+ n && e && e(!0);
3519
+ }
3520
+ function i(t) {
3521
+ n && e && !n.contains(t.relatedTarget) && e(!1);
3522
+ }
3523
+ return n.addEventListener("focus", r, !0), n.addEventListener("blur", i, !0), () => {
3524
+ n.removeEventListener("focus", r, !0), n.removeEventListener("blur", i, !0);
3525
+ };
3526
+ }, [t, e]), null;
3527
+ }
3528
+ //#endregion
3529
+ //#region src/components/rich-text-area/plugins/image-drop-plugin.tsx
3530
+ var Gs = xt("INSERT_IMAGE_COMMAND"), Ks = "helvetiq:insert-image", qs = class extends CustomEvent {
3531
+ constructor(e) {
3532
+ super(Ks, { detail: e });
3533
+ }
3534
+ };
3535
+ function Js() {
3536
+ let e = Q();
3537
+ return u(() => e.registerCommand(Gs, (t) => (e.update(() => {
3538
+ let e = us(t.src, t.altText);
3539
+ it([e]);
3540
+ }), !0), dt), [e]), u(() => {
3541
+ if (!e.getRootElement()) return;
3542
+ function t(t) {
3543
+ let n = t;
3544
+ e.dispatchCommand(Gs, n.detail);
3545
+ }
3546
+ return document.addEventListener(Ks, t), () => {
3547
+ document.removeEventListener(Ks, t);
3548
+ };
3549
+ }, [e]), null;
3550
+ }
3551
+ //#endregion
3552
+ //#region src/components/rich-text-area/plugins/html-paste-plugin.tsx
3553
+ var Ys = xt("PASTE_HTML_COMMAND"), Xs = xt("INSERT_HTML_COMMAND"), Zs = "helvetiq:paste-html", Qs = "helvetiq:insert-html", $s = class extends CustomEvent {
3554
+ constructor(e) {
3555
+ super(Zs, { detail: e });
3556
+ }
3557
+ }, ec = class extends CustomEvent {
3558
+ constructor(e) {
3559
+ super(Qs, { detail: e });
3560
+ }
3561
+ };
3562
+ function tc() {
3563
+ let e = Q();
3564
+ return u(() => e.registerCommand(Ys, (t) => (e.update(() => {
3565
+ let n = W();
3566
+ n.clear();
3567
+ let r = new DOMParser().parseFromString(t.html, "text/html"), i = Jt(e, r);
3568
+ n.append(...i);
3569
+ }), !0), dt), [e]), u(() => e.registerCommand(Xs, (t) => (e.update(() => {
3570
+ let n = new DOMParser().parseFromString(t.html, "text/html"), r = Jt(e, n);
3571
+ it(r);
3572
+ }), !0), dt), [e]), u(() => {
3573
+ if (!e.getRootElement()) return;
3574
+ function t(t) {
3575
+ let n = t;
3576
+ e.dispatchCommand(Ys, n.detail);
3577
+ }
3578
+ function n(t) {
3579
+ let n = t;
3580
+ e.dispatchCommand(Xs, n.detail);
3581
+ }
3582
+ return document.addEventListener(Zs, t), document.addEventListener(Qs, n), () => {
3583
+ document.removeEventListener(Zs, t), document.removeEventListener(Qs, n);
3584
+ };
3585
+ }, [e]), null;
3586
+ }
3587
+ //#endregion
3588
+ //#region src/components/rich-text-area/plugins/markdown-plain-paste-plugin.tsx
3589
+ function nc() {
3590
+ let e = Q();
3591
+ return u(() => e.registerCommand(_t, (t) => {
3592
+ let { clipboardData: n } = t;
3593
+ if (!n) return !1;
3594
+ let r = n.getData("text/plain");
3595
+ return r ? (t.preventDefault(), e.update(() => {
3596
+ let e = G();
3597
+ if (K(e)) {
3598
+ e.insertText(r);
3599
+ return;
3600
+ }
3601
+ let t = W();
3602
+ t.clear(), r.split(/\r?\n/).forEach((e) => {
3603
+ let n = et();
3604
+ e.length > 0 && n.append(nt(e)), t.append(n);
3605
+ });
3606
+ }), !0) : !1;
3607
+ }, ut), [e]), null;
3608
+ }
3609
+ //#endregion
3610
+ //#region src/components/rich-text-area/plugins/file-attachment-plugin.tsx
3611
+ var rc = xt("ATTACH_FILE_COMMAND");
3612
+ function ic({ acceptedFiles: e = [], isMultiple: t = !1, onFileAttach: n }) {
3613
+ let r = Q(), i = h(null);
3614
+ u(() => r.registerCommand(rc, () => (i.current?.click(), !0), dt), [r]);
3615
+ function a(e) {
3616
+ let r = Array.from(e.target.files ?? []);
3617
+ if (t) n?.(r);
3618
+ else {
3619
+ let e = r[0];
3620
+ n?.([e]);
3621
+ }
3622
+ e.target.value = "";
3623
+ }
3624
+ return /* @__PURE__ */ z("input", {
3625
+ ref: i,
3626
+ type: "file",
3627
+ multiple: t,
3628
+ "aria-hidden": "true",
3629
+ className: "hidden",
3630
+ accept: e?.join(","),
3631
+ onChange: a
3632
+ });
3633
+ }
3634
+ //#endregion
3635
+ //#region src/components/rich-text-area/styled.tsx
3636
+ var ac = a(({ className: e, ...t }, n) => /* @__PURE__ */ z("div", {
3637
+ ref: n,
3638
+ className: I("w-full resize-none border-none outline-none bg-transparent font-[inherit] text-[inherit] flex items-center [&_.editor-paragraph]:m-0 [&_.editor-paragraph]:min-h-[26px] [&_.editor-text-bold]:font-bold [&_.editor-text-italic]:italic [&_.editor-text-underline]:underline", e),
3639
+ ...t
3640
+ }));
3641
+ ac.displayName = "Wrapper";
3642
+ //#endregion
3643
+ //#region src/components/rich-text-area/rich-text-area.tsx
3644
+ var oc = {
3645
+ namespace: "helvetiq",
3646
+ theme: cs,
3647
+ editable: !0,
3648
+ nodes: [
3649
+ ze,
3650
+ Re,
3651
+ Ke,
3652
+ qe,
3653
+ Me,
3654
+ Pe,
3655
+ ls,
3656
+ As,
3657
+ Gt,
3658
+ Wt,
3659
+ Kt
3660
+ ],
3661
+ html: {
3662
+ import: Ds,
3663
+ export: ks
3664
+ },
3665
+ onError: (e) => {
3666
+ console.error("Lexical error:", e);
3667
+ }
3668
+ };
3669
+ function sc({ children: e, name: t, value: n, source: r = "markdown", className: i, containerClassName: a, placeholderClassName: o, placeholder: s = "", isDisabled: c = !1, onChange: l, onBlur: u, onKeyDown: d, onFocusChange: f, forwardedRef: p, ...m }) {
3670
+ return /* @__PURE__ */ z(Be, {
3671
+ initialConfig: oc,
3672
+ children: /* @__PURE__ */ B(ac, {
3673
+ "data-testid": "rich-text-area",
3674
+ "aria-disabled": c,
3675
+ "data-disabled": c,
3676
+ className: I("relative size-full overflow-hidden", "data-[disabled=true]:opacity-80", "data-[disabled=true]:cursor-not-allowed data-[disabled=true]:select-none", a),
3677
+ ...m,
3678
+ children: [
3679
+ /* @__PURE__ */ z(We, {
3680
+ contentEditable: /* @__PURE__ */ z(Ve, {
3681
+ className: I("relative inset-0 overflow-y-auto", i),
3682
+ "data-name": t,
3683
+ "aria-placeholder": s,
3684
+ placeholder: /* @__PURE__ */ z(P, {
3685
+ variant: "body",
3686
+ className: I("absolute left-0 top-0", "text-text-tertiary", "pointer-events-none user-select-none", o),
3687
+ children: s
3688
+ }),
3689
+ onKeyDownCapture: d,
3690
+ style: {
3691
+ outline: "none",
3692
+ minHeight: "20px"
3693
+ }
3694
+ }),
3695
+ ErrorBoundary: He
3696
+ }),
3697
+ /* @__PURE__ */ z(Fs, { isDisabled: c }),
3698
+ /* @__PURE__ */ z(Hs, {
3699
+ value: n,
3700
+ source: r
3701
+ }),
3702
+ /* @__PURE__ */ z(Ns, {
3703
+ onChange: l,
3704
+ source: r
3705
+ }),
3706
+ /* @__PURE__ */ z(Us, { onBlur: u }),
3707
+ /* @__PURE__ */ z(Ue, {}),
3708
+ /* @__PURE__ */ z(Is, { controlledRef: p ?? null }),
3709
+ /* @__PURE__ */ z(Ws, { onFocusChange: f }),
3710
+ /* @__PURE__ */ z(Ut, {}),
3711
+ r === "markdown" && /* @__PURE__ */ z(nc, {}),
3712
+ e
3713
+ ]
3714
+ })
3715
+ });
3716
+ }
3717
+ var cc = a((e, t) => /* @__PURE__ */ z(sc, {
3718
+ ...e,
3719
+ forwardedRef: t
3720
+ }));
3721
+ cc.displayName = "RichTextArea";
3722
+ //#endregion
3723
+ //#region src/components/rich-text-field/constants.ts
3724
+ var lc = "Arial, sans-serif", uc = [
3725
+ {
3726
+ value: "Arial, sans-serif",
3727
+ label: "Arial"
3728
+ },
3729
+ {
3730
+ value: "Verdana, sans-serif",
3731
+ label: "Verdana"
3732
+ },
3733
+ {
3734
+ value: "Tahoma, sans-serif",
3735
+ label: "Tahoma"
3736
+ },
3737
+ {
3738
+ value: "\"Trebuchet MS\", sans-serif",
3739
+ label: "Trebuchet MS"
3740
+ },
3741
+ {
3742
+ value: "\"Times New Roman\", serif",
3743
+ label: "Times New Roman"
3744
+ },
3745
+ {
3746
+ value: "Georgia, serif",
3747
+ label: "Georgia"
3748
+ },
3749
+ {
3750
+ value: "Garamond, serif",
3751
+ label: "Garamond"
3752
+ },
3753
+ {
3754
+ value: "\"Courier New\", monospace",
3755
+ label: "Courier New"
3756
+ },
3757
+ {
3758
+ value: "\"Brush Script MT\", cursive",
3759
+ label: "Brush Script MT"
3760
+ }
3761
+ ], dc = lc, fc = [
3762
+ {
3763
+ label: "10",
3764
+ value: "10"
3765
+ },
3766
+ {
3767
+ label: "12",
3768
+ value: "12"
3769
+ },
3770
+ {
3771
+ label: "16",
3772
+ value: "16"
3773
+ },
3774
+ {
3775
+ label: "20",
3776
+ value: "20"
3777
+ },
3778
+ {
3779
+ label: "24",
3780
+ value: "24"
3781
+ },
3782
+ {
3783
+ label: "34",
3784
+ value: "34"
3785
+ },
3786
+ {
3787
+ label: "48",
3788
+ value: "48"
3789
+ }
3790
+ ], pc = "left", mc = "#000000";
3791
+ //#endregion
3792
+ //#region src/components/rich-text-field/components/toolbar-select.tsx
3793
+ function hc({ className: e, selectItemClassName: t, ...n }) {
3794
+ return /* @__PURE__ */ z(M, {
3795
+ fullWidth: !1,
3796
+ size: "small",
3797
+ className: I(e),
3798
+ labelClassName: "border-none group-data-[state=open]/select:bg-secondary-states-hover!",
3799
+ ...n
3800
+ });
3801
+ }
3802
+ //#endregion
3803
+ //#region src/components/rich-text-field/components/alignment-select.tsx
3804
+ function gc(e) {
3805
+ return e === "center" || e === "right" ? e : e === "end" ? "right" : "left";
3806
+ }
3807
+ var _c = {
3808
+ left: {
3809
+ label: "Left",
3810
+ icon: /* @__PURE__ */ z(me, { fontSize: "inherit" })
3811
+ },
3812
+ center: {
3813
+ label: "Center",
3814
+ icon: /* @__PURE__ */ z(pe, { fontSize: "inherit" })
3815
+ },
3816
+ right: {
3817
+ label: "Right",
3818
+ icon: /* @__PURE__ */ z(he, { fontSize: "inherit" })
3819
+ }
3820
+ };
3821
+ function vc({ className: e }) {
3822
+ let t = Q(), [n, r] = g(pc), i = m(() => Object.entries(_c).map(([e, { label: t, icon: n }]) => ({
3823
+ value: e,
3824
+ label: t,
3825
+ icon: n
3826
+ })), []), a = c(() => {
3827
+ let e = G();
3828
+ if (K(e)) {
3829
+ let t = e.anchor.getNode(), n = t.getParent(), i = at(t) ? t : n;
3830
+ at(i) && r(gc(i.getFormatType() || "left"));
3831
+ }
3832
+ }, []);
3833
+ u(() => Zt(t.registerUpdateListener(({ editorState: e }) => {
3834
+ e.read(() => {
3835
+ a();
3836
+ });
3837
+ }), t.registerCommand(vt, () => (a(), !1), ft)), [t, a]);
3838
+ function o(e) {
3839
+ t.dispatchCommand(ht, e);
3840
+ }
3841
+ return /* @__PURE__ */ z(hc, {
3842
+ shouldShowOnlyIcon: !0,
3843
+ options: i,
3844
+ value: n,
3845
+ onChange: o,
3846
+ className: I("w-[56px]!", e)
3847
+ });
3848
+ }
3849
+ //#endregion
3850
+ //#region src/components/rich-text-field/components/toolbar-button.tsx
3851
+ function $({ className: e, children: t, isActive: n, isDisabled: r = !1, ...i }) {
3852
+ return /* @__PURE__ */ z(D, {
3853
+ isActive: n,
3854
+ className: I("border-none bg-transparent", e),
3855
+ size: "sm",
3856
+ variant: "tertiary",
3857
+ isDisabled: r,
3858
+ ...i,
3859
+ children: t
3860
+ });
3861
+ }
3862
+ //#endregion
3863
+ //#region src/components/rich-text-field/components/attachment-button.tsx
3864
+ function yc(e) {
3865
+ let t = Q();
3866
+ function n() {
3867
+ t.dispatchCommand(rc, void 0);
3868
+ }
3869
+ return /* @__PURE__ */ z($, {
3870
+ "data-testid": "attachment-button",
3871
+ "aria-label": "Add Attachment",
3872
+ onClick: n,
3873
+ ...e,
3874
+ children: /* @__PURE__ */ z(se, {})
3875
+ });
3876
+ }
3877
+ //#endregion
3878
+ //#region src/components/rich-text-field/utils.ts
3879
+ function bc(e) {
3880
+ let t;
3881
+ for (let n of nn(e, { silent: !0 })) n.type === "declaration" && n.value && (t ||= {}, t[n.property] = n.value);
3882
+ return t || xc;
3883
+ }
3884
+ var xc = Object.freeze({});
3885
+ function Sc(e) {
3886
+ return typeof e == "string" ? bc(e) : xc;
3887
+ }
3888
+ function Cc(e) {
3889
+ let t = [];
3890
+ for (let [n, r] of Object.entries(e)) n && r && t.push(`${n}: ${r};`);
3891
+ return t.sort().join(" ");
3892
+ }
3893
+ function wc(e, t) {
3894
+ return e === t || !e && !t;
3895
+ }
3896
+ function Tc(e, t) {
3897
+ if (e === t) return !0;
3898
+ for (let n in e) if (!(n in t && wc(e[n], t[n]))) return !1;
3899
+ for (let n in t) if (!(n in e)) return !1;
3900
+ return !0;
3901
+ }
3902
+ var Ec = St("style", {
3903
+ isEqual: Tc,
3904
+ parse: Sc,
3905
+ unparse: Cc
3906
+ });
3907
+ function Dc(e, t) {
3908
+ return lt(e, Ec, t);
3909
+ }
3910
+ function Oc(e, t) {
3911
+ return e === xc || e === t ? t : {
3912
+ ...e,
3913
+ ...t
3914
+ };
3915
+ }
3916
+ xt("PATCH_TEXT_STYLE_COMMAND");
3917
+ function kc(e) {
3918
+ let t = G();
3919
+ if (!t) {
3920
+ let e = rt();
3921
+ if (!e) return !1;
3922
+ t = e.clone(), ct(t);
3923
+ }
3924
+ let n = typeof e == "function" ? e : (t) => Oc(t, e);
3925
+ if (K(t) && t.isCollapsed()) {
3926
+ let e = t.focus.getNode();
3927
+ q(e) && Dc(e, n);
3928
+ } else Qt((e) => Dc(e, n));
3929
+ return !0;
3930
+ }
3931
+ function Ac(e) {
3932
+ let t = e.anchor, n = e.focus, r = e.anchor.getNode(), i = e.focus.getNode();
3933
+ return r === i ? r : e.isBackward() ? en(n) ? r : i : en(t) ? r : i;
3934
+ }
3935
+ var jc = (e, t, n, r) => {
3936
+ e.update(() => {
3937
+ if (r && $e(yt), e.isEditable()) {
3938
+ let e = G();
3939
+ e !== null && tn(e, { "font-size": t + "px" });
3940
+ }
3941
+ });
3942
+ }, Mc = (e) => e.startsWith("http") ? e : `https://${e}`, Nc = i(null);
3943
+ function Pc() {
3944
+ let e = l(Nc);
3945
+ if (!e) throw Error("\"useRichTextFieldContext\" must be used within a RichTextFieldContextProvider");
3946
+ return e;
3947
+ }
3948
+ function Fc(e) {
3949
+ let t = e.trim(), n = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);
3950
+ if (n) {
3951
+ let e = n[1];
3952
+ if (e.length === 3) {
3953
+ let [t, n, r] = e;
3954
+ return `#${t}${t}${n}${n}${r}${r}`.toLowerCase();
3955
+ }
3956
+ return `#${e.toLowerCase()}`;
3957
+ }
3958
+ let r = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})/i.exec(t);
3959
+ if (r) {
3960
+ let e = (e) => Math.max(0, Math.min(255, e)), [t, n, i] = r.slice(1, 4).map((t) => e(Number.parseInt(t, 10))), a = (e) => e.toString(16).padStart(2, "0");
3961
+ return `#${a(t)}${a(n)}${a(i)}`;
3962
+ }
3963
+ return mc;
3964
+ }
3965
+ function Ic({ children: e }) {
3966
+ let t = Q(), [n, r] = g(dc), [i, a] = g("16"), [o, s] = g(!1), [l, d] = g(!1), [f, p] = g(!1), [h, _] = g(mc), [v, y] = g(!1), b = c(() => {
3967
+ let e = G();
3968
+ if (K(e)) {
3969
+ r($t(e, "font-family", dc));
3970
+ let t = $t(e, "font-size", "16px");
3971
+ a(t ? t.replace("px", "") : "16"), s(e.hasFormat("bold")), d(e.hasFormat("italic")), p(e.hasFormat("underline"));
3972
+ let n = $t(e, "color", "#000000") || "#000000";
3973
+ _(Fc(n));
3974
+ let i = Ac(e), o = i.getParent(), c = Ne(o) || Ne(i);
3975
+ y(c);
3976
+ }
3977
+ }, []);
3978
+ u(() => Zt(t.registerUpdateListener(({ editorState: e }) => {
3979
+ e.read(() => {
3980
+ b();
3981
+ });
3982
+ }), t.registerCommand(vt, () => (b(), !1), ft)), [t, b]);
3983
+ let x = c((e) => {
3984
+ t.update(() => {
3985
+ $e(bt);
3986
+ let t = G();
3987
+ t !== null && tn(t, { "font-family": e });
3988
+ });
3989
+ }, [t]), S = c((e) => {
3990
+ jc(t, e, null, !1);
3991
+ }, [t]), C = c(() => {
3992
+ t.dispatchCommand(gt, "bold");
3993
+ }, [t]), w = c(() => {
3994
+ t.dispatchCommand(gt, "italic");
3995
+ }, [t]), T = c(() => {
3996
+ t.dispatchCommand(gt, "underline");
3997
+ }, [t]), E = c((e) => {
3998
+ t.update(() => {
3999
+ $e(bt);
4000
+ let t = G();
4001
+ t !== null && tn(t, { color: e });
4002
+ });
4003
+ }, [t]), ee = c(() => {
4004
+ v ? (y(!1), t.dispatchCommand(Fe, null)) : (y(!0), t.dispatchCommand(Fe, Mc("https://")));
4005
+ }, [v, y]), te = m(() => ({
4006
+ fontFamily: n,
4007
+ fontSize: i,
4008
+ textColor: h,
4009
+ isBold: o,
4010
+ isItalic: l,
4011
+ isUnderline: f,
4012
+ isLink: v,
4013
+ onFontFamily: x,
4014
+ onFontSize: S,
4015
+ onTextColor: E,
4016
+ onBold: C,
4017
+ onItalic: w,
4018
+ onUnderline: T,
4019
+ onLink: ee
4020
+ }), [
4021
+ n,
4022
+ i,
4023
+ h,
4024
+ o,
4025
+ l,
4026
+ f,
4027
+ v,
4028
+ x,
4029
+ S,
4030
+ E,
4031
+ C,
4032
+ w,
4033
+ T,
4034
+ ee
4035
+ ]);
4036
+ return /* @__PURE__ */ z(Nc.Provider, {
4037
+ value: te,
4038
+ children: e
4039
+ });
4040
+ }
4041
+ //#endregion
4042
+ //#region src/components/rich-text-field/components/bold-button.tsx
4043
+ function Lc({ ...e }) {
4044
+ let { isBold: t, onBold: n } = Pc();
4045
+ return /* @__PURE__ */ z($, {
4046
+ "data-testid": "bold-button",
4047
+ "aria-label": "Format Bold",
4048
+ isActive: t,
4049
+ onClick: n,
4050
+ ...e,
4051
+ children: /* @__PURE__ */ z(ge, {})
4052
+ });
4053
+ }
4054
+ //#endregion
4055
+ //#region src/components/rich-text-field/components/clean-format-button.tsx
4056
+ function Rc({ ...e }) {
4057
+ let t = Q(), n = c(() => {
4058
+ t.update(() => {
4059
+ let e = G();
4060
+ if (K(e)) {
4061
+ kc(() => xc);
4062
+ for (let t of e.extract()) q(t) && (t.setFormat(0), t.setStyle(""), Xt(t).setFormat(""));
4063
+ }
4064
+ });
4065
+ }, [t]);
4066
+ return /* @__PURE__ */ z($, {
4067
+ "data-testid": "clean-format-button",
4068
+ "aria-label": "Reset Formatting",
4069
+ onClick: n,
4070
+ ...e,
4071
+ children: /* @__PURE__ */ z(_e, {})
4072
+ });
4073
+ }
4074
+ //#endregion
4075
+ //#region src/components/rich-text-field/components/image-button.tsx
4076
+ function zc({ ...e }) {
4077
+ return /* @__PURE__ */ z($, {
4078
+ "data-testid": "image-button",
4079
+ "aria-label": "Add Image",
4080
+ ...e,
4081
+ children: /* @__PURE__ */ z(xe, {})
4082
+ });
4083
+ }
4084
+ //#endregion
4085
+ //#region src/components/rich-text-field/components/italic-button.tsx
4086
+ function Bc({ ...e }) {
4087
+ let { isItalic: t, onItalic: n } = Pc();
4088
+ return /* @__PURE__ */ z($, {
4089
+ "data-testid": "italic-button",
4090
+ "aria-label": "Format Italics",
4091
+ isActive: t,
4092
+ onClick: n,
4093
+ ...e,
4094
+ children: /* @__PURE__ */ z(ye, {})
4095
+ });
4096
+ }
4097
+ //#endregion
4098
+ //#region src/components/rich-text-field/components/link-button.tsx
4099
+ function Vc({ isActive: e, ...t }) {
4100
+ return /* @__PURE__ */ z($, {
4101
+ "data-testid": "link-button",
4102
+ "aria-label": "Add Link",
4103
+ ...t,
4104
+ children: z(e ? Ce : Se, {})
4105
+ });
4106
+ }
4107
+ //#endregion
4108
+ //#region src/components/rich-text-field/components/size-select.tsx
4109
+ function Hc({ className: e }) {
4110
+ let { fontSize: t, onFontSize: n } = Pc(), r = m(() => [...fc], []);
4111
+ return /* @__PURE__ */ z(hc, {
4112
+ "data-testid": "size-select",
4113
+ options: r,
4114
+ value: t,
4115
+ onChange: n,
4116
+ className: I("w-[72px] gap-0", e)
4117
+ });
4118
+ }
4119
+ //#endregion
4120
+ //#region src/components/rich-text-field/components/text-color-button.tsx
4121
+ function Uc({ ...e }) {
4122
+ let { textColor: t, onTextColor: n } = Pc(), r = t === mc;
4123
+ function i(e) {
4124
+ n(e.target.value);
4125
+ }
4126
+ return /* @__PURE__ */ B("div", {
4127
+ style: { position: "relative" },
4128
+ children: [/* @__PURE__ */ z($, {
4129
+ "data-testid": "text-color-button",
4130
+ "aria-label": "Text Color",
4131
+ ...e,
4132
+ children: /* @__PURE__ */ z("span", {
4133
+ style: r ? {} : { color: t },
4134
+ children: /* @__PURE__ */ z(ve, {})
4135
+ })
4136
+ }), /* @__PURE__ */ z("input", {
4137
+ type: "color",
4138
+ value: t,
4139
+ onChange: i,
4140
+ tabIndex: -1,
4141
+ style: {
4142
+ position: "absolute",
4143
+ inset: 0,
4144
+ width: "100%",
4145
+ height: "100%",
4146
+ opacity: 0,
4147
+ cursor: "pointer"
4148
+ }
4149
+ })]
4150
+ });
4151
+ }
4152
+ //#endregion
4153
+ //#region src/components/rich-text-field/components/typography-select.tsx
4154
+ function Wc({ className: e }) {
4155
+ let { fontFamily: t, onFontFamily: n } = Pc(), r = m(() => [...uc], []);
4156
+ return /* @__PURE__ */ z(hc, {
4157
+ "data-testid": "typography-select",
4158
+ options: r,
4159
+ value: t,
4160
+ onChange: n,
4161
+ className: I("w-[90px]", e)
4162
+ });
4163
+ }
4164
+ //#endregion
4165
+ //#region src/components/rich-text-field/components/underline-button.tsx
4166
+ function Gc({ ...e }) {
4167
+ let { isUnderline: t, onUnderline: n } = Pc();
4168
+ return /* @__PURE__ */ z($, {
4169
+ "data-testid": "underline-button",
4170
+ "aria-label": "Format Underline",
4171
+ isActive: t,
4172
+ onClick: n,
4173
+ ...e,
4174
+ children: /* @__PURE__ */ z(be, {})
4175
+ });
4176
+ }
4177
+ //#endregion
4178
+ //#region src/components/rich-text-field/components/formatting-toolbar-plugin.tsx
4179
+ var Kc = ({ hasAttachments: e }) => /* @__PURE__ */ B(R, { children: [
4180
+ /* @__PURE__ */ z(Wc, {}),
4181
+ /* @__PURE__ */ z(Hc, {}),
4182
+ /* @__PURE__ */ z(C, { orientation: "vertical" }),
4183
+ /* @__PURE__ */ z(Lc, {}),
4184
+ /* @__PURE__ */ z(Bc, {}),
4185
+ /* @__PURE__ */ z(Gc, {}),
4186
+ /* @__PURE__ */ z(Uc, {}),
4187
+ /* @__PURE__ */ z(C, { orientation: "vertical" }),
4188
+ /* @__PURE__ */ z(Vc, { isDisabled: !0 }),
4189
+ /* @__PURE__ */ z(yc, { isDisabled: !e }),
4190
+ /* @__PURE__ */ z(zc, { isDisabled: !0 }),
4191
+ /* @__PURE__ */ z(C, { orientation: "vertical" }),
4192
+ /* @__PURE__ */ z(vc, {}),
4193
+ /* @__PURE__ */ z(C, { orientation: "vertical" }),
4194
+ /* @__PURE__ */ z(Rc, {})
4195
+ ] });
4196
+ function qc({ className: e, children: t = Kc, hasAttachments: n = !1 }) {
4197
+ return /* @__PURE__ */ z("div", {
4198
+ "data-testid": "formatting-toolbar",
4199
+ className: I("flex items-center gap-[2px]", "px-[16px] py-[8px] overflow-x-auto", "bg-paper-elevation-1 border-b border-divider-border-base", e),
4200
+ children: t({ hasAttachments: n })
4201
+ });
4202
+ }
4203
+ //#endregion
4204
+ //#region src/components/rich-text-field/rich-text-field.tsx
4205
+ var Jc = a(({ children: e, className: t, placeholderClassName: n, containerClassName: r, toolbarPlacement: i = "top", toolbarChildren: a, toolbarClassName: o, isMultipleAttachments: s, enableAttachments: c, acceptedFiles: l, onFileAttach: u, ...d }, f) => {
4206
+ let p = i === "top";
4207
+ return /* @__PURE__ */ B(cc, {
4208
+ ref: f,
4209
+ "data-testid": "rich-text-field",
4210
+ "data-toolbar-placement": i,
4211
+ placeholderClassName: I("left-(--rich-text-field-editor-padding)", p ? "top-[calc(var(--rich-text-field-toolbar-height)+var(--rich-text-field-editor-padding))]" : "top-rich-text-field-editor-padding", n),
4212
+ containerClassName: I("h-rich-text-field-height", "rounded-rich-text-field-toolbar", p ? "pt-rich-text-field-toolbar-height" : "pb-rich-text-field-toolbar-height", r),
4213
+ className: I("p-rich-text-field-editor-padding", "bg-rich-text-field-background", "size-full", t),
4214
+ ...d,
4215
+ children: [/* @__PURE__ */ z(Ic, { children: /* @__PURE__ */ z(qc, {
4216
+ hasAttachments: c,
4217
+ className: I("absolute right-0 w-full", p ? "top-0" : "bottom-0", o),
4218
+ children: a
4219
+ }) }), /* @__PURE__ */ z(ic, {
4220
+ acceptedFiles: l,
4221
+ onFileAttach: u,
4222
+ isMultiple: s
4223
+ })]
4224
+ });
4225
+ });
4226
+ Jc.displayName = "RichTextField";
4227
+ //#endregion
4228
+ //#region src/components/spinner/spinner.tsx
4229
+ var Yc = "https://lottie.host/444a46a4-65b4-4483-b3a8-675160a79dad/LgQ8IVLAzA.lottie";
4230
+ function Xc({ size: e = "md", autoplay: t = !0 }) {
4231
+ return /* @__PURE__ */ z("span", {
4232
+ "data-testid": "spinner",
4233
+ "data-size": e,
4234
+ className: I("pointer-events-none", "inline-flex items-center justify-center", "data-[size=sm]:size-16", "data-[size=md]:size-24", "data-[size=lg]:size-32", "data-[size=xl]:size-[96px]"),
4235
+ children: /* @__PURE__ */ z(rn, {
4236
+ src: Yc,
4237
+ loop: t,
4238
+ autoplay: t
4239
+ })
4240
+ });
4241
+ }
4242
+ //#endregion
4243
+ //#region src/domain/actions/constants.ts
4244
+ var Zc = "swisper";
4245
+ //#endregion
4246
+ //#region src/domain/actions/utils/index.ts
4247
+ function Qc(e, t) {
4248
+ let n = `${Zc}://action/${e}`;
4249
+ return t ? `${n}?${new URLSearchParams(t).toString()}` : n;
4250
+ }
4251
+ function $c({ action: e, label: t, params: n }) {
4252
+ return `[${t}](${Qc(e, n)})`;
4253
+ }
4254
+ function el(e) {
4255
+ if (!e?.startsWith("swisper://")) return !1;
4256
+ let t = new URL(e);
4257
+ return t.protocol === "swisper:" && t.hostname === "action" && t.pathname.startsWith("/") && t.pathname.split("/").length === 2;
4258
+ }
4259
+ function tl(e) {
4260
+ let t;
4261
+ try {
4262
+ t = new URL(e);
4263
+ } catch {
4264
+ return null;
4265
+ }
4266
+ return el(e) ? {
4267
+ option: t.pathname.replace("/", ""),
4268
+ payload: Object.fromEntries(t.searchParams.entries())
4269
+ } : null;
4270
+ }
4271
+ function nl(e) {
4272
+ for (let t of e) if (t.type === "text" && typeof t.value == "string") return t.value;
4273
+ return null;
4274
+ }
4275
+ function rl(e) {
4276
+ let t = sn().use(on).use(an).parse(e), n = null;
4277
+ return cn(t, (e) => {
4278
+ if (e.type !== "link") return;
4279
+ let t = tl(e.url), r = nl(e.children);
4280
+ if (t && r) {
4281
+ n = {
4282
+ label: r,
4283
+ option: t.option,
4284
+ payload: t.payload,
4285
+ raw: e.url
4286
+ };
4287
+ return;
4288
+ }
4289
+ }), n;
4290
+ }
4291
+ //#endregion
4292
+ //#region src/domain/actions/hooks/index.ts
4293
+ function il(e) {
4294
+ return m(() => e.map((e) => rl(e) || { label: e }).filter((e) => e !== null), [e]);
4295
+ }
4296
+ //#endregion
4297
+ //#region src/hooks/use-chat-stream-message.ts
4298
+ function al(e) {
4299
+ return JSON.parse(e);
4300
+ }
4301
+ function ol(e) {
4302
+ return e instanceof Error ? e.name === "AbortError" || e.name === "TimeoutError" : !1;
4303
+ }
4304
+ function sl(e, t) {
4305
+ return e instanceof Error ? e : Error(t);
4306
+ }
4307
+ function cl() {
4308
+ return { streamMessage: c(async ({ stream: e, abortController: t, timeout: n = 2e4, tokenParser: r, onChunkReceived: i, onAbort: a, onFinish: o, onError: s }) => {
4309
+ let c = r ?? al, l, u = !1, d = () => {
4310
+ l !== void 0 && (clearTimeout(l), l = void 0);
4311
+ }, f = (e) => {
4312
+ u || (u = !0, d(), a?.(e));
4313
+ }, p = () => {
4314
+ n !== void 0 && (d(), l = setTimeout(() => {
4315
+ let e = new DOMException(`Stream timed out after ${n}ms of inactivity`, "TimeoutError");
4316
+ t?.abort(e), t || f(e);
4317
+ }, n));
4318
+ };
4319
+ try {
4320
+ let n = "", r = new TextDecoder("utf-8"), a = ln({
4321
+ onEvent(e) {
4322
+ try {
4323
+ n += e.data;
4324
+ let r = c(e.data);
4325
+ if (!r) throw Error(`Failed to parse SSE chunk: ${e.data}`);
4326
+ t?.signal.aborted || (i(r), p());
4327
+ } catch (n) {
4328
+ t?.abort(n), console.warn("Failed to parse SSE chunk:", e.data, n);
4329
+ }
4330
+ },
4331
+ onError(e) {
4332
+ t?.abort(e), console.error("Error while parsing stream:", e);
4333
+ }
4334
+ });
4335
+ for (t?.signal.addEventListener("abort", () => {
4336
+ let e = sl(t.signal.reason, "Stream aborted");
4337
+ f(e);
4338
+ }, { once: !0 }), p(); !u;) {
4339
+ let { value: t, done: n } = await e.read(), i = r.decode(t, { stream: !0 });
4340
+ if (a.feed(i), n) break;
4341
+ }
4342
+ d(), !u && !t?.signal.aborted && o?.(n);
4343
+ } catch (e) {
4344
+ let n = e;
4345
+ if (u || t?.signal.aborted || ol(n)) {
4346
+ u || f(sl(n, "Stream aborted"));
4347
+ return;
4348
+ }
4349
+ t?.abort(n), console.error("Error while reading stream:", n), s?.(n);
4350
+ }
4351
+ }, []) };
4352
+ }
4353
+ //#endregion
4354
+ //#region src/hooks/use-on-chat-changed.ts
4355
+ function ll(e) {
4356
+ let { chatId: t, isNewChat: n } = X(), r = h(n), i = h(t), a = h(e);
4357
+ a.current = e, r.current = n, u(() => {
4358
+ i.current !== t && (a.current({
4359
+ chatId: t,
4360
+ prevChatId: i.current,
4361
+ isNewChat: r.current
4362
+ }), i.current = t);
4363
+ }, [t]);
4364
+ }
4365
+ //#endregion
4366
+ //#region src/hooks/use-current-chat-id.ts
4367
+ function ul() {
4368
+ let { chatId: e } = X();
4369
+ return e;
4370
+ }
4371
+ //#endregion
4372
+ //#region src/hooks/use-is-current-chat-new.ts
4373
+ function dl() {
4374
+ let { isNewChat: e } = X();
4375
+ return e;
4376
+ }
4377
+ //#endregion
4378
+ //#region src/hooks/use-loaded-chat-ids.ts
4379
+ function fl() {
4380
+ let { loadedChatIdsRef: e } = X();
4381
+ return {
4382
+ getIsChatLoaded: c((t) => e.current?.has(t) ?? !1, []),
4383
+ markAsLoaded: c((t) => {
4384
+ e.current?.add(t);
4385
+ }, []),
4386
+ markAsUnloaded: c((t) => {
4387
+ e.current?.delete(t);
4388
+ }, [])
4389
+ };
4390
+ }
4391
+ //#endregion
4392
+ //#region src/hooks/use-chat-prompt-placeholder.ts
4393
+ function pl() {
4394
+ let { promptPlaceholder: e, setPromptPlaceholder: t, clearPromptPlaceholder: n } = X();
4395
+ return {
4396
+ promptPlaceholder: e,
4397
+ setPromptPlaceholder: t,
4398
+ clearPromptPlaceholder: n
4399
+ };
4400
+ }
4401
+ //#endregion
4402
+ export { Bs as $replaceEditorHTMLContent, Vs as $replaceEditorSelectionHTMLContent, Rs as $setSelectionToEnd, vc as AlignmentSelect, yc as AttachmentButton, Lc as BoldButton, Zc as CHAT_ACTION_PROTOCOL, Oo as CanvasShell, jo as CanvasShellCloseTrigger, Fo as CanvasShellContent, Io as CanvasShellFooter, Mo as CanvasShellFullScreenTrigger, ko as CanvasShellHeader, No as CanvasShellOptionsButton, Ao as CanvasShellTitle, Vo as CardItemPickerList, Ho as CardItemPickerRow, qo as CardItemPickerRowCheckbox, Wo as CardItemPickerRowContent, Ko as CardItemPickerRowDescription, Uo as CardItemPickerRowMedia, Go as CardItemPickerRowTitle, pr as ChatCard, Qn as ChatCardActionButton, Zn as ChatCardActions, ur as ChatCardAttribute, dr as ChatCardAttributeLabel, fr as ChatCardAttributeValue, lr as ChatCardAttributes, tr as ChatCardBody, $n as ChatCardCollapsibleButton, vr as ChatCardContainer, nr as ChatCardContent, ir as ChatCardFooter, sr as ChatCardFooterActions, ar as ChatCardFooterNotes, or as ChatCardFooterPrice, cr as ChatCardForm, Kn as ChatCardHeader, Jn as ChatCardHeaderContent, qn as ChatCardIcon, pn as ChatCardListLayout, mn as ChatCardListLayoutItems, hn as ChatCardListLayoutShowMore, er as ChatCardMedia, rr as ChatCardPreview, Xn as ChatCardSubTitle, kn as ChatCardThreeColumnLayout, Mn as ChatCardThreeColumnLayoutDetails, An as ChatCardThreeColumnLayoutList, jn as ChatCardThreeColumnLayoutMain, Nn as ChatCardThreeColumnLayoutPanel, Yn as ChatCardTitle, Vn as ChatCardTwoColumnLayout, Hn as ChatCardTwoColumnLayoutAside, Un as ChatCardTwoColumnLayoutMain, wr as ChatContainer, Er as ChatContainerPrompt, Dr as ChatContainerWelcome, ji as ChatConversationProvider, Gr as ChatInput, qr as ChatInputTextarea, Xr as ChatList, ei as ChatListEmptyState, ti as ChatListError, ai as ChatListItem, ii as ChatListItems, ni as ChatListLoadMore, $r as ChatListSkeleton, xi as ChatMessage, Ci as ChatMessageActions, Vi as ChatMessageAttachmentCard, Gi as ChatMessageAttachmentCardActions, Hi as ChatMessageAttachmentCardContent, qi as ChatMessageAttachmentCardIcon, Wi as ChatMessageAttachmentCardPreview, Ui as ChatMessageAttachmentCardTitle, Si as ChatMessageContent, ra as ChatMessageHistory, aa as ChatMessageHistoryEmptyState, oa as ChatMessageHistoryErrorState, ia as ChatMessageHistoryList, sa as ChatMessageHistoryScrollButton, Ri as ChatMessageListGroup, ea as ChatMessageResponse, la as ChatMessageToolbar, da as ChatMessageToolbarActionButton, ua as ChatMessageToolbarActions, fa as ChatMessageToolbarTimestamp, Fi as ChatMessages, Ii as ChatMessagesList, Bi as ChatMessagesScrollButton, xa as ChatNotificationCard, ka as ChatNotificationCardActions, ja as ChatNotificationCardButtons, Fa as ChatNotificationCardCloseButton, Ia as ChatNotificationCardContent, za as ChatNotificationCardContentActions, Ra as ChatNotificationCardContentDescription, La as ChatNotificationCardContentTitle, Pa as ChatNotificationCardDeleteButton, Ha as ChatNotificationCardDescription, Ba as ChatNotificationCardExpandButton, Sa as ChatNotificationCardHead, Ca as ChatNotificationCardHeader, wa as ChatNotificationCardHeaderIcon, Oa as ChatNotificationCardHeaderStatus, Ta as ChatNotificationCardHeaderTitle, Ea as ChatNotificationCardHeaderTitleLabel, Va as ChatNotificationCardIcon, Ma as ChatNotificationCardReadActionButton, Na as ChatNotificationCardSnoozeButton, Ua as ChatNotificationCardTimeStamp, Aa as ChatNotificationCardTimestamp, Wa as ChatNotificationPopup, Ka as ChatNotificationPopupContent, Ga as ChatNotificationPopupTrigger, pi as ChatPromptBox, yi as ChatPromptBoxActionsLeft, bi as ChatPromptBoxActionsRight, _i as ChatPromptBoxContent, vi as ChatPromptBoxInput, gi as ChatPromptBoxToolbar, Ei as ChatProvider, qa as ChatReplies, Ja as ChatReply, Ya as ChatReplyLabel, Xa as ChatReplyValue, eo as ChatSuggestion, ro as ChatSuggestionActions, no as ChatSuggestionLabel, to as ChatSuggestionLabelIcon, $a as ChatSuggestions, Yo as ChatThinkingProcess, es as ChatThinkingProcessContent, ns as ChatThinkingProcessContentItem, Xo as ChatThinkingProcessTrigger, $o as ChatThinkingProcessTriggerArrow, Zo as ChatThinkingProcessTriggerIcon, Qo as ChatThinkingProcessTriggerLabel, xo as ChatThread, To as ChatThreadAnswer, Do as ChatThreadErrorState, Co as ChatThreadGroup, yo as ChatThreadProvider, wo as ChatThreadQuestion, Rc as CleanFormatButton, _r as EditableChatCardContextProvider, rs as EmptyState, ss as EmptyStateActionRow, os as EmptyStateDescription, is as EmptyStateIcon, as as EmptyStateTitle, qc as FormattingToolbarPlugin, tc as HtmlPastePlugin, Xs as INSERT_HTML_COMMAND, Qs as INSERT_HTML_EVENT, Gs as INSERT_IMAGE_COMMAND, Ks as INSERT_IMAGE_EVENT_NAME, qs as ImageAddedEvent, zc as ImageButton, Js as ImageDropPlugin, ec as InsertHtmlEvent, Bc as ItalicButton, Vc as LinkButton, Qi as MarkdownViewer, Jo as NewChatTrigger, Ys as PASTE_HTML_COMMAND, Zs as PASTE_HTML_EVENT, $s as PasteHtmlEvent, cc as RichTextArea, Jc as RichTextField, Yc as SOURCE_ANIMATION, Hc as SizeSelect, Xc as Spinner, Uc as TextColorButton, $ as ToolbarButton, Wc as TypographySelect, Gc as UnderlineButton, Po as canvasShellContentPadding, wn as chatCardThreeColumnLayoutCardVariants, Sn as chatCardThreeColumnLayoutDetailsVariants, bn as chatCardThreeColumnLayoutListVariants, xn as chatCardThreeColumnLayoutMainVariants, Cn as chatCardThreeColumnLayoutPanelVariants, yn as chatCardThreeColumnLayoutVariants, In as chatCardTwoColumnLayoutAsideVariants, Rn as chatCardTwoColumnLayoutCardVariants, Fn as chatCardTwoColumnLayoutGridVariants, Ln as chatCardTwoColumnLayoutMainVariants, Pn as chatCardTwoColumnLayoutVariants, $c as createChatActionLink, rl as extractChatActionFromLink, va as formatSnoozeDate, Yi as getAttachmentIcon, pa as getSnoozeUntilDate, el as isChatActionURL, Ls as scrollRichTextAreaToBottom, Ro as useCardItemPickerListContext, Bo as useCardItemPickerRowContext, il as useChatActions, fn as useChatCardListLayoutContext, X as useChatContext, Ai as useChatConversationContext, Ur as useChatInputContext, Yr as useChatListContext, fl as useChatLoadedIds, na as useChatMessageHistoryContext, ba as useChatNotificationCardContext, pl as useChatPromptPlaceholder, cl as useChatStreamMessage, Qa as useChatSuggestionContext, mo as useChatThread, zt as useChatThreadScrollable, ul as useCurrentChatId, mr as useEditChatCard, gr as useEditableChatCardContext, dl as useIsCurrentChatNew, ll as useOnChatChanged, Q as useRichTextAreaEditor, Ps as useRichTextAreaSelectedText };
4403
+
4404
+ //# sourceMappingURL=index.es.js.map