@messenger-box/tailwind-ui-inbox 10.0.3-alpha.100

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 (373) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/LICENSE +21 -0
  3. package/jest.config.js +9 -0
  4. package/lib/cdm-locales/en/translations.json +31 -0
  5. package/lib/cdm-locales/es/translations.json +31 -0
  6. package/lib/components/AIAgent/AIAgent.d.ts +21 -0
  7. package/lib/components/AIAgent/AIAgent.d.ts.map +1 -0
  8. package/lib/components/AIAgent/AIAgent.js +904 -0
  9. package/lib/components/AIAgent/AIAgent.js.map +1 -0
  10. package/lib/components/AIAgent/index.d.ts +2 -0
  11. package/lib/components/AIAgent/index.d.ts.map +1 -0
  12. package/lib/components/InboxMessage/CommonMessage.d.ts +8 -0
  13. package/lib/components/InboxMessage/CommonMessage.d.ts.map +1 -0
  14. package/lib/components/InboxMessage/CommonMessage.js +35 -0
  15. package/lib/components/InboxMessage/CommonMessage.js.map +1 -0
  16. package/lib/components/InboxMessage/ConversationItem.d.ts +14 -0
  17. package/lib/components/InboxMessage/ConversationItem.d.ts.map +1 -0
  18. package/lib/components/InboxMessage/ConversationItem.js +200 -0
  19. package/lib/components/InboxMessage/ConversationItem.js.map +1 -0
  20. package/lib/components/InboxMessage/InputComponent.d.ts +12 -0
  21. package/lib/components/InboxMessage/InputComponent.d.ts.map +1 -0
  22. package/lib/components/InboxMessage/InputComponent.js +359 -0
  23. package/lib/components/InboxMessage/InputComponent.js.map +1 -0
  24. package/lib/components/InboxMessage/LeftSidebar.d.ts +20 -0
  25. package/lib/components/InboxMessage/LeftSidebar.d.ts.map +1 -0
  26. package/lib/components/InboxMessage/LeftSidebar.js +102 -0
  27. package/lib/components/InboxMessage/LeftSidebar.js.map +1 -0
  28. package/lib/components/InboxMessage/MessageInput.d.ts +9 -0
  29. package/lib/components/InboxMessage/MessageInput.d.ts.map +1 -0
  30. package/lib/components/InboxMessage/MessageInput.js +154 -0
  31. package/lib/components/InboxMessage/MessageInput.js.map +1 -0
  32. package/lib/components/InboxMessage/MessageInputComponent.d.ts +9 -0
  33. package/lib/components/InboxMessage/MessageInputComponent.d.ts.map +1 -0
  34. package/lib/components/InboxMessage/Messages.d.ts +17 -0
  35. package/lib/components/InboxMessage/Messages.d.ts.map +1 -0
  36. package/lib/components/InboxMessage/Messages.js +99 -0
  37. package/lib/components/InboxMessage/Messages.js.map +1 -0
  38. package/lib/components/InboxMessage/MessagesBuilderUi.d.ts +17 -0
  39. package/lib/components/InboxMessage/MessagesBuilderUi.d.ts.map +1 -0
  40. package/lib/components/InboxMessage/Popover.d.ts +3 -0
  41. package/lib/components/InboxMessage/Popover.d.ts.map +1 -0
  42. package/lib/components/InboxMessage/Popover.js +31 -0
  43. package/lib/components/InboxMessage/Popover.js.map +1 -0
  44. package/lib/components/InboxMessage/RightSidebar.d.ts +9 -0
  45. package/lib/components/InboxMessage/RightSidebar.d.ts.map +1 -0
  46. package/lib/components/InboxMessage/RightSidebar.js +9 -0
  47. package/lib/components/InboxMessage/RightSidebar.js.map +1 -0
  48. package/lib/components/InboxMessage/RightSidebarAi.d.ts +23 -0
  49. package/lib/components/InboxMessage/RightSidebarAi.d.ts.map +1 -0
  50. package/lib/components/InboxMessage/RightSidebarAi.js +9 -0
  51. package/lib/components/InboxMessage/RightSidebarAi.js.map +1 -0
  52. package/lib/components/InboxMessage/ServiceConversationItem.d.ts +12 -0
  53. package/lib/components/InboxMessage/ServiceConversationItem.d.ts.map +1 -0
  54. package/lib/components/InboxMessage/ServiceConversationItem.js +185 -0
  55. package/lib/components/InboxMessage/ServiceConversationItem.js.map +1 -0
  56. package/lib/components/InboxMessage/ServiceInboxItem.d.ts +12 -0
  57. package/lib/components/InboxMessage/ServiceInboxItem.d.ts.map +1 -0
  58. package/lib/components/InboxMessage/ServiceInboxItem.js +182 -0
  59. package/lib/components/InboxMessage/ServiceInboxItem.js.map +1 -0
  60. package/lib/components/InboxMessage/SubscriptionHandler.d.ts +19 -0
  61. package/lib/components/InboxMessage/SubscriptionHandler.d.ts.map +1 -0
  62. package/lib/components/InboxMessage/SubscriptionHandler.js +41 -0
  63. package/lib/components/InboxMessage/SubscriptionHandler.js.map +1 -0
  64. package/lib/components/InboxMessage/UploadImageButton.d.ts +7 -0
  65. package/lib/components/InboxMessage/UploadImageButton.d.ts.map +1 -0
  66. package/lib/components/InboxMessage/UploadImageButton.js +34 -0
  67. package/lib/components/InboxMessage/UploadImageButton.js.map +1 -0
  68. package/lib/components/InboxMessage/UserModalContent.d.ts +3 -0
  69. package/lib/components/InboxMessage/UserModalContent.d.ts.map +1 -0
  70. package/lib/components/InboxMessage/UserModalContent.js +60 -0
  71. package/lib/components/InboxMessage/UserModalContent.js.map +1 -0
  72. package/lib/components/InboxMessage/index.d.ts +17 -0
  73. package/lib/components/InboxMessage/index.d.ts.map +1 -0
  74. package/lib/components/InboxMessage/message-widgets/CommonMessage.d.ts +11 -0
  75. package/lib/components/InboxMessage/message-widgets/CommonMessage.d.ts.map +1 -0
  76. package/lib/components/InboxMessage/message-widgets/CommonMessage.js +44 -0
  77. package/lib/components/InboxMessage/message-widgets/CommonMessage.js.map +1 -0
  78. package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts +11 -0
  79. package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts.map +1 -0
  80. package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js +194 -0
  81. package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js.map +1 -0
  82. package/lib/components/InboxMessage/message-widgets/MessageCard.d.ts +8 -0
  83. package/lib/components/InboxMessage/message-widgets/MessageCard.d.ts.map +1 -0
  84. package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.d.ts +12 -0
  85. package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.d.ts.map +1 -0
  86. package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.js +37 -0
  87. package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.js.map +1 -0
  88. package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts +18 -0
  89. package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts.map +1 -0
  90. package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js +1082 -0
  91. package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js.map +1 -0
  92. package/lib/components/InboxMessage/message-widgets/PlainMessage.d.ts +8 -0
  93. package/lib/components/InboxMessage/message-widgets/PlainMessage.d.ts.map +1 -0
  94. package/lib/components/InboxMessage/message-widgets/PlainMessage.js +14 -0
  95. package/lib/components/InboxMessage/message-widgets/PlainMessage.js.map +1 -0
  96. package/lib/components/InboxMessage/message-widgets/PropertyMessageWidget.d.ts +9 -0
  97. package/lib/components/InboxMessage/message-widgets/PropertyMessageWidget.d.ts.map +1 -0
  98. package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts +14 -0
  99. package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts.map +1 -0
  100. package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js +333 -0
  101. package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js.map +1 -0
  102. package/lib/components/InboxMessage/message-widgets/index.d.ts +4 -0
  103. package/lib/components/InboxMessage/message-widgets/index.d.ts.map +1 -0
  104. package/lib/components/ModelConfigPanel.d.ts +37 -0
  105. package/lib/components/ModelConfigPanel.d.ts.map +1 -0
  106. package/lib/components/ModelConfigPanel.js +317 -0
  107. package/lib/components/ModelConfigPanel.js.map +1 -0
  108. package/lib/components/filler-components/RightSiderBar.d.ts +24 -0
  109. package/lib/components/filler-components/RightSiderBar.d.ts.map +1 -0
  110. package/lib/components/filler-components/RightSiderBar.js +335 -0
  111. package/lib/components/filler-components/RightSiderBar.js.map +1 -0
  112. package/lib/components/inbox/FilesList.d.ts +20 -0
  113. package/lib/components/inbox/FilesList.d.ts.map +1 -0
  114. package/lib/components/inbox/FilesList.js +68 -0
  115. package/lib/components/inbox/FilesList.js.map +1 -0
  116. package/lib/components/inbox/MessageItem.d.ts +17 -0
  117. package/lib/components/inbox/MessageItem.d.ts.map +1 -0
  118. package/lib/components/inbox/MessageItem.js +50 -0
  119. package/lib/components/inbox/MessageItem.js.map +1 -0
  120. package/lib/components/inbox/ThreadItem.d.ts +11 -0
  121. package/lib/components/inbox/ThreadItem.d.ts.map +1 -0
  122. package/lib/components/inbox/ThreadItem.js +147 -0
  123. package/lib/components/inbox/ThreadItem.js.map +1 -0
  124. package/lib/components/inbox/index.d.ts +4 -0
  125. package/lib/components/inbox/index.d.ts.map +1 -0
  126. package/lib/components/index.d.ts +7 -0
  127. package/lib/components/index.d.ts.map +1 -0
  128. package/lib/components/live-code-editor/hybrid-live-editor.d.ts +20 -0
  129. package/lib/components/live-code-editor/hybrid-live-editor.d.ts.map +1 -0
  130. package/lib/components/live-code-editor/hybrid-live-editor.js +68 -0
  131. package/lib/components/live-code-editor/hybrid-live-editor.js.map +1 -0
  132. package/lib/components/live-code-editor/index.d.ts +4 -0
  133. package/lib/components/live-code-editor/index.d.ts.map +1 -0
  134. package/lib/components/live-code-editor/live-code-editor.d.ts +14 -0
  135. package/lib/components/live-code-editor/live-code-editor.d.ts.map +1 -0
  136. package/lib/components/live-code-editor/live-code-editor.js +207 -0
  137. package/lib/components/live-code-editor/live-code-editor.js.map +1 -0
  138. package/lib/components/slot-fill/chat-message-filler.d.ts +4 -0
  139. package/lib/components/slot-fill/chat-message-filler.d.ts.map +1 -0
  140. package/lib/components/slot-fill/chat-message-filler.js +5 -0
  141. package/lib/components/slot-fill/chat-message-filler.js.map +1 -0
  142. package/lib/components/slot-fill/chat-message-slot.d.ts +11 -0
  143. package/lib/components/slot-fill/chat-message-slot.d.ts.map +1 -0
  144. package/lib/components/slot-fill/chat-message-slot.js +6 -0
  145. package/lib/components/slot-fill/chat-message-slot.js.map +1 -0
  146. package/lib/components/slot-fill/index.d.ts +4 -0
  147. package/lib/components/slot-fill/index.d.ts.map +1 -0
  148. package/lib/components/slot-fill/right-sidebar-filler.d.ts +4 -0
  149. package/lib/components/slot-fill/right-sidebar-filler.d.ts.map +1 -0
  150. package/lib/components/slot-fill/right-sidebar-filler.js +13 -0
  151. package/lib/components/slot-fill/right-sidebar-filler.js.map +1 -0
  152. package/lib/components/ui/button.d.ts +9 -0
  153. package/lib/components/ui/button.d.ts.map +1 -0
  154. package/lib/compute.d.ts +8 -0
  155. package/lib/compute.d.ts.map +1 -0
  156. package/lib/compute.js +137 -0
  157. package/lib/compute.js.map +1 -0
  158. package/lib/config/env-config.d.ts +13 -0
  159. package/lib/config/env-config.d.ts.map +1 -0
  160. package/lib/config/env-config.js +34 -0
  161. package/lib/config/env-config.js.map +1 -0
  162. package/lib/config/index.d.ts +2 -0
  163. package/lib/config/index.d.ts.map +1 -0
  164. package/lib/constants/breakpoints.d.ts +8 -0
  165. package/lib/constants/breakpoints.d.ts.map +1 -0
  166. package/lib/constants/index.d.ts +3 -0
  167. package/lib/constants/index.d.ts.map +1 -0
  168. package/lib/container/AiInbox.d.ts +15 -0
  169. package/lib/container/AiInbox.d.ts.map +1 -0
  170. package/lib/container/AiInboxWithLoader.d.ts +36 -0
  171. package/lib/container/AiInboxWithLoader.d.ts.map +1 -0
  172. package/lib/container/AiLandingInput.d.ts +4 -0
  173. package/lib/container/AiLandingInput.d.ts.map +1 -0
  174. package/lib/container/AiLandingInput.js +101 -0
  175. package/lib/container/AiLandingInput.js.map +1 -0
  176. package/lib/container/Inbox.d.ts +15 -0
  177. package/lib/container/Inbox.d.ts.map +1 -0
  178. package/lib/container/Inbox.js +955 -0
  179. package/lib/container/Inbox.js.map +1 -0
  180. package/lib/container/InboxAiMessagesLoader.d.ts +15 -0
  181. package/lib/container/InboxAiMessagesLoader.d.ts.map +1 -0
  182. package/lib/container/InboxAiMessagesLoader.js +30 -0
  183. package/lib/container/InboxAiMessagesLoader.js.map +1 -0
  184. package/lib/container/InboxContainer.d.ts +12 -0
  185. package/lib/container/InboxContainer.d.ts.map +1 -0
  186. package/lib/container/InboxContainer.js +31 -0
  187. package/lib/container/InboxContainer.js.map +1 -0
  188. package/lib/container/InboxTemplate1.d.ts +15 -0
  189. package/lib/container/InboxTemplate1.d.ts.map +1 -0
  190. package/lib/container/InboxTemplate1WithLoader.d.ts +36 -0
  191. package/lib/container/InboxTemplate1WithLoader.d.ts.map +1 -0
  192. package/lib/container/InboxTemplate2.d.ts +15 -0
  193. package/lib/container/InboxTemplate2.d.ts.map +1 -0
  194. package/lib/container/InboxWithAiLoader.d.ts +15 -0
  195. package/lib/container/InboxWithAiLoader.d.ts.map +1 -0
  196. package/lib/container/InboxWithAiLoader.js +56 -0
  197. package/lib/container/InboxWithAiLoader.js.map +1 -0
  198. package/lib/container/InboxWithLoader.d.ts +36 -0
  199. package/lib/container/InboxWithLoader.d.ts.map +1 -0
  200. package/lib/container/InboxWithLoader.js +277 -0
  201. package/lib/container/InboxWithLoader.js.map +1 -0
  202. package/lib/container/ServiceInbox.d.ts +9 -0
  203. package/lib/container/ServiceInbox.d.ts.map +1 -0
  204. package/lib/container/ServiceInbox.js +144 -0
  205. package/lib/container/ServiceInbox.js.map +1 -0
  206. package/lib/container/ThreadMessages.d.ts +13 -0
  207. package/lib/container/ThreadMessages.d.ts.map +1 -0
  208. package/lib/container/ThreadMessages.js +314 -0
  209. package/lib/container/ThreadMessages.js.map +1 -0
  210. package/lib/container/ThreadMessagesInbox.d.ts +14 -0
  211. package/lib/container/ThreadMessagesInbox.d.ts.map +1 -0
  212. package/lib/container/ThreadMessagesInbox.js +341 -0
  213. package/lib/container/ThreadMessagesInbox.js.map +1 -0
  214. package/lib/container/Threads.d.ts +8 -0
  215. package/lib/container/Threads.d.ts.map +1 -0
  216. package/lib/container/Threads.js +231 -0
  217. package/lib/container/Threads.js.map +1 -0
  218. package/lib/container/ThreadsInbox.d.ts +21 -0
  219. package/lib/container/ThreadsInbox.d.ts.map +1 -0
  220. package/lib/container/ThreadsInbox.js +244 -0
  221. package/lib/container/ThreadsInbox.js.map +1 -0
  222. package/lib/container/apply-footer-styles.d.ts +2 -0
  223. package/lib/container/apply-footer-styles.d.ts.map +1 -0
  224. package/lib/container/apply-footer-styles.js +16 -0
  225. package/lib/container/apply-footer-styles.js.map +1 -0
  226. package/lib/container/index.d.ts +13 -0
  227. package/lib/container/index.d.ts.map +1 -0
  228. package/lib/enums/index.d.ts +2 -0
  229. package/lib/enums/index.d.ts.map +1 -0
  230. package/lib/enums/messenger-slot-fill-name-enum.d.ts +5 -0
  231. package/lib/enums/messenger-slot-fill-name-enum.d.ts.map +1 -0
  232. package/lib/enums/messenger-slot-fill-name-enum.js +5 -0
  233. package/lib/enums/messenger-slot-fill-name-enum.js.map +1 -0
  234. package/lib/hooks/index.d.ts +3 -0
  235. package/lib/hooks/index.d.ts.map +1 -0
  236. package/lib/hooks/use-file-sync.d.ts +16 -0
  237. package/lib/hooks/use-file-sync.d.ts.map +1 -0
  238. package/lib/hooks/use-file-sync.js +63 -0
  239. package/lib/hooks/use-file-sync.js.map +1 -0
  240. package/lib/hooks/usePersistentModelConfig.d.ts +15 -0
  241. package/lib/hooks/usePersistentModelConfig.d.ts.map +1 -0
  242. package/lib/hooks/usePersistentModelConfig.js +46 -0
  243. package/lib/hooks/usePersistentModelConfig.js.map +1 -0
  244. package/lib/index.d.ts +10 -0
  245. package/lib/index.d.ts.map +1 -0
  246. package/lib/index.js +1 -0
  247. package/lib/index.js.map +1 -0
  248. package/lib/interfaces/index.d.ts +2 -0
  249. package/lib/interfaces/index.d.ts.map +1 -0
  250. package/lib/interfaces/message-widgets.interface.d.ts +21 -0
  251. package/lib/interfaces/message-widgets.interface.d.ts.map +1 -0
  252. package/lib/machines/aiAgentMachine.d.ts +3 -0
  253. package/lib/machines/aiAgentMachine.d.ts.map +1 -0
  254. package/lib/machines/aiAgentMachine.js +1083 -0
  255. package/lib/machines/aiAgentMachine.js.map +1 -0
  256. package/lib/machines/aiAgentMachine.simple.d.ts +3 -0
  257. package/lib/machines/aiAgentMachine.simple.d.ts.map +1 -0
  258. package/lib/machines/aiAgentMachine.simple.js +108 -0
  259. package/lib/machines/aiAgentMachine.simple.js.map +1 -0
  260. package/lib/machines/index.d.ts +3 -0
  261. package/lib/machines/index.d.ts.map +1 -0
  262. package/lib/machines/types.d.ts +77 -0
  263. package/lib/machines/types.d.ts.map +1 -0
  264. package/lib/module.d.ts +7 -0
  265. package/lib/module.d.ts.map +1 -0
  266. package/lib/module.js +26 -0
  267. package/lib/module.js.map +1 -0
  268. package/lib/routes.json +98 -0
  269. package/lib/styles/responsive.css +76 -0
  270. package/lib/templates/InboxWithAi.d.ts +15 -0
  271. package/lib/templates/InboxWithAi.d.ts.map +1 -0
  272. package/lib/templates/InboxWithAi.js +440 -0
  273. package/lib/templates/InboxWithAi.js.map +1 -0
  274. package/lib/templates/InboxWithAi.tsx +533 -0
  275. package/lib/templates/index.d.ts +2 -0
  276. package/lib/templates/index.d.ts.map +1 -0
  277. package/lib/templates/index.ts +1 -0
  278. package/lib/utils/utils.d.ts +2 -0
  279. package/lib/utils/utils.d.ts.map +1 -0
  280. package/lib/utils/utils.js +3 -0
  281. package/lib/utils/utils.js.map +1 -0
  282. package/package.json +62 -0
  283. package/rollup.config.mjs +35 -0
  284. package/src/cdm-locales/en/translations.json +31 -0
  285. package/src/cdm-locales/es/translations.json +31 -0
  286. package/src/components/AIAgent/AIAgent.tsx +1103 -0
  287. package/src/components/AIAgent/AIAgent.tsx.bk +1365 -0
  288. package/src/components/AIAgent/README.md +82 -0
  289. package/src/components/AIAgent/index.ts +1 -0
  290. package/src/components/InboxMessage/CommonMessage.tsx +40 -0
  291. package/src/components/InboxMessage/ConversationItem.tsx +255 -0
  292. package/src/components/InboxMessage/InputComponent.tsx +462 -0
  293. package/src/components/InboxMessage/LeftSidebar.tsx +140 -0
  294. package/src/components/InboxMessage/MessageInput.tsx +209 -0
  295. package/src/components/InboxMessage/MessageInputComponent.tsx +245 -0
  296. package/src/components/InboxMessage/Messages.tsx +137 -0
  297. package/src/components/InboxMessage/MessagesBuilderUi.tsx +205 -0
  298. package/src/components/InboxMessage/Popover.tsx +42 -0
  299. package/src/components/InboxMessage/RightSidebar.tsx +22 -0
  300. package/src/components/InboxMessage/RightSidebarAi.tsx +37 -0
  301. package/src/components/InboxMessage/ServiceConversationItem.tsx +234 -0
  302. package/src/components/InboxMessage/ServiceInboxItem.tsx +223 -0
  303. package/src/components/InboxMessage/SubscriptionHandler.tsx +55 -0
  304. package/src/components/InboxMessage/UploadImageButton.tsx +46 -0
  305. package/src/components/InboxMessage/UserModalContent.tsx +60 -0
  306. package/src/components/InboxMessage/index.ts +16 -0
  307. package/src/components/InboxMessage/message-widgets/CommonMessage.tsx +69 -0
  308. package/src/components/InboxMessage/message-widgets/ErrorFixCard.tsx +240 -0
  309. package/src/components/InboxMessage/message-widgets/MessageCard.tsx +127 -0
  310. package/src/components/InboxMessage/message-widgets/MessageSliceRenderer.tsx +40 -0
  311. package/src/components/InboxMessage/message-widgets/ModernMessageGroup.tsx +1295 -0
  312. package/src/components/InboxMessage/message-widgets/PlainMessage.tsx +18 -0
  313. package/src/components/InboxMessage/message-widgets/PropertyMessageWidget.tsx +29 -0
  314. package/src/components/InboxMessage/message-widgets/SlackLikeMessageGroup.tsx +492 -0
  315. package/src/components/InboxMessage/message-widgets/index.ts +3 -0
  316. package/src/components/ModelConfigPanel.tsx +345 -0
  317. package/src/components/filler-components/RightSiderBar.tsx +408 -0
  318. package/src/components/inbox/FilesList.tsx +89 -0
  319. package/src/components/inbox/MessageItem.tsx +50 -0
  320. package/src/components/inbox/ThreadItem.tsx +295 -0
  321. package/src/components/inbox/index.ts +3 -0
  322. package/src/components/index.ts +22 -0
  323. package/src/components/live-code-editor/hybrid-live-editor.tsx +105 -0
  324. package/src/components/live-code-editor/index.ts +3 -0
  325. package/src/components/live-code-editor/live-code-editor.tsx +257 -0
  326. package/src/components/slot-fill/chat-message-filler.tsx +18 -0
  327. package/src/components/slot-fill/chat-message-slot.tsx +18 -0
  328. package/src/components/slot-fill/index.ts +3 -0
  329. package/src/components/slot-fill/right-sidebar-filler.tsx +39 -0
  330. package/src/components/ui/button.tsx +32 -0
  331. package/src/compute.ts +134 -0
  332. package/src/config/env-config.ts +17 -0
  333. package/src/config/index.ts +1 -0
  334. package/src/constants/breakpoints.ts +7 -0
  335. package/src/constants/index.ts +5 -0
  336. package/src/container/AiInbox.tsx +1819 -0
  337. package/src/container/AiInboxWithLoader.tsx +356 -0
  338. package/src/container/AiLandingInput.tsx +221 -0
  339. package/src/container/Inbox.tsx +1092 -0
  340. package/src/container/InboxAiMessagesLoader.tsx +44 -0
  341. package/src/container/InboxContainer.tsx +35 -0
  342. package/src/container/InboxTemplate1.tsx +1542 -0
  343. package/src/container/InboxTemplate1WithLoader.tsx +338 -0
  344. package/src/container/InboxTemplate2.tsx +1606 -0
  345. package/src/container/InboxWithAiLoader.tsx +76 -0
  346. package/src/container/InboxWithLoader.tsx +341 -0
  347. package/src/container/ServiceInbox.tsx +190 -0
  348. package/src/container/ThreadMessages.tsx +371 -0
  349. package/src/container/ThreadMessagesInbox.tsx +450 -0
  350. package/src/container/Threads.tsx +270 -0
  351. package/src/container/ThreadsInbox.tsx +354 -0
  352. package/src/container/apply-footer-styles.ts +17 -0
  353. package/src/container/index.ts +31 -0
  354. package/src/enums/index.ts +1 -0
  355. package/src/enums/messenger-slot-fill-name-enum.ts +4 -0
  356. package/src/hooks/index.ts +2 -0
  357. package/src/hooks/use-file-sync.ts +91 -0
  358. package/src/hooks/usePersistentModelConfig.ts +63 -0
  359. package/src/index.ts +37 -0
  360. package/src/interfaces/index.ts +1 -0
  361. package/src/interfaces/message-widgets.interface.ts +21 -0
  362. package/src/machines/aiAgentMachine.simple.ts +89 -0
  363. package/src/machines/aiAgentMachine.ts +1296 -0
  364. package/src/machines/aiAgentMachine.ts.bk +1296 -0
  365. package/src/machines/index.ts +2 -0
  366. package/src/machines/types.ts +59 -0
  367. package/src/module.tsx +32 -0
  368. package/src/styles/responsive.css +76 -0
  369. package/src/templates/InboxWithAi.tsx +533 -0
  370. package/src/templates/index.ts +1 -0
  371. package/src/utils/utils.ts +3 -0
  372. package/tsconfig.json +14 -0
  373. package/webpack.config.js +92 -0
@@ -0,0 +1,904 @@
1
+ import React__default,{useState,useRef,useEffect,useCallback,useMemo}from'react';import {useMachine}from'@xstate/react';import {aiAgentMachine}from'../../machines/aiAgentMachine.simple.js';import {InputComponent}from'../InboxMessage/InputComponent.js';import {isToday,isYesterday,format}from'date-fns';import {useTranslation}from'react-i18next';import {ModernMessageGroupComponent}from'../InboxMessage/message-widgets/ModernMessageGroup.js';import {useUploadFiles}from'@messenger-box/platform-client';import {useSelector,shallowEqual}from'react-redux';import {userSelector}from'@adminide-stack/user-auth0-client';import {objectId}from'@messenger-box/core';import {useApolloClient}from'@apollo/client/index.js';import {useSendMessagesMutation,useGenerateAiCodeMutation,useRecreateSandboxMutation,useOnChatMessageAddedSubscription,useSandboxErrorSubscription,useMessagesQuery,MessagesDocument,OnChatMessageAddedDocument}from'common/graphql';import {config}from'../../config/env-config.js';import {orderBy,uniqBy}from'lodash-es';import {useParams,useNavigate}from'@remix-run/react';import {SubscriptionHandler}from'../InboxMessage/SubscriptionHandler.js';import {usePersistentModelConfig}from'../../hooks/usePersistentModelConfig.js';const {
2
+ MESSAGES_PER_PAGE
3
+ } = config;
4
+ const AIAgent = ({
5
+ channelId,
6
+ onSendMessage,
7
+ placeholder = 'Ask me anything...',
8
+ className = '',
9
+ currentUser,
10
+ isDesktopView = false,
11
+ isSmallScreen = false,
12
+ setMessages,
13
+ setSelectedPost,
14
+ messages,
15
+ selectedPost,
16
+ setIsLoading,
17
+ isLoading
18
+ }) => {
19
+ const [state, send] = useMachine(aiAgentMachine);
20
+ useApolloClient();
21
+ const {
22
+ startUpload
23
+ } = useUploadFiles();
24
+ const [sendMsg] = useSendMessagesMutation();
25
+ const auth = useSelector(userSelector, shallowEqual);
26
+ const {
27
+ id: pathChannelId
28
+ } = useParams();
29
+ useNavigate();
30
+ const {
31
+ modelConfig,
32
+ updateModelConfig,
33
+ getValidatedConfig,
34
+ hasApiKey
35
+ } = usePersistentModelConfig();
36
+ // const [isLoading, setIsLoading] = useState(false);
37
+ const [errorData, setError] = useState(null);
38
+ // Get channelId from props or path params
39
+ const actualChannelId = channelId || pathChannelId;
40
+ const [generateAiCode] = useGenerateAiCodeMutation();
41
+ const [recreateSandbox] = useRecreateSandboxMutation();
42
+ const {
43
+ data: chatMessageAddedData
44
+ } = useOnChatMessageAddedSubscription({
45
+ variables: {
46
+ channelId: actualChannelId?.toString() || ''
47
+ },
48
+ skip: !actualChannelId
49
+ });
50
+ // Subscribe to sandbox errors if projectId is provided
51
+ const {
52
+ data: sandboxErrorData
53
+ } = useSandboxErrorSubscription({
54
+ variables: {
55
+ projectId: actualChannelId?.toString() || ''
56
+ },
57
+ skip: !actualChannelId
58
+ });
59
+ // Direct message query from InboxWithAiLoader.tsx
60
+ const messagesQuery = useMessagesQuery({
61
+ variables: {
62
+ props: {
63
+ projectId: actualChannelId?.toString()
64
+ },
65
+ parentId: null,
66
+ limit: MESSAGES_PER_PAGE
67
+ },
68
+ skip: !actualChannelId,
69
+ fetchPolicy: 'cache-and-network',
70
+ errorPolicy: 'all',
71
+ notifyOnNetworkStatusChange: true,
72
+ returnPartialData: true,
73
+ pollInterval: 0,
74
+ context: {
75
+ cacheKey: 'messages-list'
76
+ }
77
+ });
78
+ const {
79
+ messages: aiMessages,
80
+ error,
81
+ isTyping
82
+ } = state.context;
83
+ const {
84
+ t
85
+ } = useTranslation('translations');
86
+ const [isOpen, setIsOpen] = useState(false);
87
+ const [selectedElement, setSelectedElement] = useState(null);
88
+ const [activeTab, setActiveTab] = useState('chat');
89
+ const bottomRef = useRef(null);
90
+ const [sandboxErrors, setSandboxErrors] = useState([]);
91
+ const [currentFiles, setCurrentFiles] = useState({});
92
+ const [canvasLayers, setCanvasLayers] = useState([]);
93
+ // New state variables for message display control
94
+ const [isSuccessThinking, setIsSuccessThinking] = useState(false);
95
+ const successThinkingTimeoutRef = useRef(null);
96
+ // Get regular messages from direct query
97
+ const {
98
+ data: messagesData,
99
+ loading: messageLoading,
100
+ refetch: refetchMessages,
101
+ fetchMore: fetchMoreMessages,
102
+ subscribeToMore
103
+ } = messagesQuery;
104
+ useEffect(() => {
105
+ if (actualChannelId) {
106
+ refetchMessages({
107
+ limit: MESSAGES_PER_PAGE,
108
+ props: {
109
+ projectId: actualChannelId?.toString()
110
+ }
111
+ });
112
+ }
113
+ }, [actualChannelId, refetchMessages]);
114
+ useEffect(() => {
115
+ if (chatMessageAddedData?.chatMessageAdded) {
116
+ console.log('chatMessageAddedData?.chatMessageAdded', JSON.stringify(chatMessageAddedData?.chatMessageAdded, null, 2));
117
+ // handleGenerateAiCode(chatMessageAddedData.chatMessageAdded.id);
118
+ // Stop the success thinking loader once a new message arrives
119
+ if (isSuccessThinking) {
120
+ setIsSuccessThinking(false);
121
+ if (successThinkingTimeoutRef.current) {
122
+ clearTimeout(successThinkingTimeoutRef.current);
123
+ successThinkingTimeoutRef.current = null;
124
+ }
125
+ }
126
+ }
127
+ }, [chatMessageAddedData?.chatMessageAdded]);
128
+ useEffect(() => {
129
+ if (messagesData?.messages?.data?.length == 1) {
130
+ handleGenerateAiCode(messagesData.messages.data[0].id);
131
+ }
132
+ // console.log('messagesData?.messages?.data',JSON.stringify(messagesData?.messages?.data,null,2))
133
+ }, [messagesData?.messages?.data]);
134
+ // Handle sandbox error subscription updates
135
+ useEffect(() => {
136
+ if (sandboxErrorData?.sandboxError) {
137
+ const errorData = sandboxErrorData.sandboxError;
138
+ console.log('Sandbox error received:', errorData);
139
+ setSandboxErrors(prev => [...prev, errorData.error]);
140
+ }
141
+ }, [sandboxErrorData]);
142
+ const regularMessages = useMemo(() => {
143
+ if (!messagesData?.messages?.data) return [];
144
+ return orderBy(uniqBy(messagesData.messages.data || [], 'id'), ['createdAt'], ['asc']);
145
+ }, [messagesData?.messages?.data]);
146
+ // Send regular messages to AI agent machine for context
147
+ useEffect(() => {
148
+ if (regularMessages && regularMessages.length > 0) {
149
+ send({
150
+ type: 'UPDATE_REGULAR_MESSAGES',
151
+ messages: regularMessages
152
+ });
153
+ setMessages(regularMessages);
154
+ const currentMessage = regularMessages?.[regularMessages.length - 1];
155
+ setSelectedPost(regularMessages[regularMessages.length - 1]);
156
+ setCurrentFiles(currentMessage?.propsConfiguration?.contents?.fragment?.files ?? {});
157
+ let canvasLayers = currentMessage?.propsConfiguration?.contents?.fragment?.canvasLayers ?? [];
158
+ const summary = currentMessage?.propsConfiguration?.contents?.fragment?.summary ?? null;
159
+ // If not in direct field, try to extract from summary
160
+ if (!canvasLayers && summary) {
161
+ const canvasLayersMatch = summary?.match(/<canvas_layers>([\s\S]*?)<\/canvas_layers>/);
162
+ if (canvasLayersMatch) {
163
+ try {
164
+ canvasLayers = JSON.parse(canvasLayersMatch[1]);
165
+ } catch (error) {
166
+ console.error('Failed to parse canvas layers from summary:', error);
167
+ }
168
+ }
169
+ }
170
+ // Update canvas layers if available
171
+ if (canvasLayers && Array.isArray(canvasLayers)) {
172
+ setCanvasLayers(canvasLayers);
173
+ }
174
+ console.log('currenmessage', currentMessage);
175
+ if (currentMessage?.propsConfiguration?.contents?.role === 'ASSISTANT') ;
176
+ scrollToBottom('smooth', 0);
177
+ }
178
+ }, [regularMessages, send]);
179
+ const handleGenerateAiCode = useCallback(messageId => {
180
+ generateAiCode({
181
+ variables: {
182
+ messageId: messageId,
183
+ modelConfig: modelConfig
184
+ },
185
+ onCompleted: res => {
186
+ if (res.generateAiCode.success) {
187
+ console.log('generated_result', res);
188
+ // Show AI is thinking loader on success
189
+ if (successThinkingTimeoutRef.current) {
190
+ clearTimeout(successThinkingTimeoutRef.current);
191
+ successThinkingTimeoutRef.current = null;
192
+ }
193
+ setIsSuccessThinking(true);
194
+ // Fallback auto-hide after 15s in case no subsequent event arrives
195
+ successThinkingTimeoutRef.current = setTimeout(() => {
196
+ setIsSuccessThinking(false);
197
+ // setIsLoading(false);
198
+ successThinkingTimeoutRef.current = null;
199
+ }, 15000);
200
+ }
201
+ },
202
+ onError: err => {
203
+ console.log('err', JSON.stringify(err, null, 2));
204
+ // Also ensure loader is hidden on error
205
+ if (successThinkingTimeoutRef.current) {
206
+ clearTimeout(successThinkingTimeoutRef.current);
207
+ successThinkingTimeoutRef.current = null;
208
+ }
209
+ setIsSuccessThinking(false);
210
+ }
211
+ });
212
+ }, [generateAiCode, modelConfig]);
213
+ const onOpen = element => {
214
+ setSelectedElement(element);
215
+ setIsOpen(true);
216
+ };
217
+ const onClose = () => {
218
+ setIsOpen(false);
219
+ setSelectedElement(null);
220
+ };
221
+ // Enhanced scroll to bottom function
222
+ const scrollToBottom = useCallback((behavior = 'smooth', delay = 0) => {
223
+ setTimeout(() => {
224
+ if (bottomRef.current) {
225
+ bottomRef.current.scrollIntoView({
226
+ behavior,
227
+ block: 'end',
228
+ inline: 'nearest'
229
+ });
230
+ }
231
+ }, delay);
232
+ }, []);
233
+ const recreateSandboxForFragment = useCallback(async messageId => {
234
+ if (!actualChannelId) {
235
+ console.error('No project ID available for sandbox recreation');
236
+ return;
237
+ }
238
+ try {
239
+ setIsLoading(true);
240
+ setError(null);
241
+ const response = await recreateSandbox({
242
+ variables: {
243
+ projectId: actualChannelId,
244
+ messageId
245
+ }
246
+ });
247
+ if (response.data?.recreateSandbox?.success) {
248
+ console.log('Sandbox recreation initiated successfully');
249
+ // The subscription will handle updating the UI with the new sandbox URL
250
+ } else {
251
+ const errorMsg = response.data?.recreateSandbox?.message || 'Failed to recreate sandbox';
252
+ throw new Error(errorMsg);
253
+ }
254
+ } catch (err) {
255
+ console.error('Error recreating sandbox:', err);
256
+ setError(err instanceof Error ? err.message : 'Failed to recreate sandbox');
257
+ setIsLoading(false);
258
+ }
259
+ }, [recreateSandbox, actualChannelId]);
260
+ // Updated handleSend function from InboxWithAi.tsx
261
+ const handleSend = useCallback(async (message, files = []) => {
262
+ // Allow sending if there's either a message or files
263
+ if ((!message || !message.trim()) && (!files || files.length === 0)) return;
264
+ const validated = getValidatedConfig();
265
+ if (!validated && !hasApiKey) {
266
+ // No API key/config; do nothing (AiLandingInput would prompt config UI)
267
+ return;
268
+ }
269
+ // Start the AI thinking loader immediately on send
270
+ if (successThinkingTimeoutRef.current) {
271
+ clearTimeout(successThinkingTimeoutRef.current);
272
+ successThinkingTimeoutRef.current = null;
273
+ }
274
+ setIsSuccessThinking(true);
275
+ setIsLoading(true);
276
+ // Safety auto-stop in case no event arrives
277
+ successThinkingTimeoutRef.current = setTimeout(() => {
278
+ setIsSuccessThinking(false);
279
+ successThinkingTimeoutRef.current = null;
280
+ }, 15000);
281
+ // If we already have a channel, send message (with optional file upload) similar to Inbox
282
+ if (actualChannelId) {
283
+ try {
284
+ const postId = objectId();
285
+ const channelId = objectId();
286
+ const currentDate = new Date();
287
+ const createOptimisticMessage = uploadedFiles => ({
288
+ __typename: 'Post',
289
+ id: postId,
290
+ message,
291
+ createdAt: currentDate.toISOString(),
292
+ updatedAt: currentDate.toISOString(),
293
+ author: {
294
+ __typename: 'UserAccount',
295
+ id: auth?.id,
296
+ givenName: auth?.profile?.given_name || '',
297
+ familyName: auth?.profile?.family_name || '',
298
+ email: auth?.profile?.email || '',
299
+ username: auth?.profile?.nickname || '',
300
+ fullName: auth?.profile?.name || '',
301
+ picture: auth?.profile?.picture || '',
302
+ alias: [auth?.authUserId ?? ''],
303
+ tokens: []
304
+ },
305
+ isDelivered: false,
306
+ isRead: false,
307
+ type: 'TEXT',
308
+ parentId: null,
309
+ fromServer: false,
310
+ channel: {
311
+ __typename: 'Channel',
312
+ id: actualChannelId
313
+ },
314
+ propsConfiguration: {
315
+ __typename: 'MachineConfiguration',
316
+ id: null,
317
+ resource: '',
318
+ contents: null,
319
+ keys: null,
320
+ target: null,
321
+ overrides: null
322
+ },
323
+ props: {},
324
+ files: {
325
+ __typename: 'FilesInfo',
326
+ data: uploadedFiles || [],
327
+ totalCount: uploadedFiles?.length || 0
328
+ },
329
+ replies: {
330
+ __typename: 'Messages',
331
+ data: [],
332
+ totalCount: 0
333
+ }
334
+ });
335
+ const cacheMessagesQuery = {
336
+ query: MessagesDocument,
337
+ variables: {
338
+ // Match variables used in useMessagesQuery above
339
+ props: {
340
+ projectId: actualChannelId.toString()
341
+ },
342
+ parentId: null,
343
+ limit: MESSAGES_PER_PAGE
344
+ }
345
+ };
346
+ const extraProps = {
347
+ projectId: actualChannelId,
348
+ template: modelConfig?.template || 'vite-react',
349
+ role: 'USER',
350
+ sendNotificationWithProjectId: true
351
+ };
352
+ if (files?.length > 0) {
353
+ const uploadResponse = await startUpload({
354
+ file: files,
355
+ saveUploadedFile: {
356
+ variables: {
357
+ postId
358
+ }
359
+ },
360
+ createUploadLink: {
361
+ variables: {
362
+ postId
363
+ }
364
+ }
365
+ });
366
+ const uploadedFiles = uploadResponse.data;
367
+ const fileIds = (uploadedFiles || []).map(f => f.id);
368
+ await sendMsg({
369
+ variables: {
370
+ postId,
371
+ channelId: actualChannelId,
372
+ content: message,
373
+ files: fileIds,
374
+ extraProps
375
+ },
376
+ optimisticResponse: {
377
+ __typename: 'Mutation',
378
+ sendMessage: createOptimisticMessage(uploadedFiles)
379
+ },
380
+ update: (cache, {
381
+ data: mutationData
382
+ }) => {
383
+ if (!mutationData?.sendMessage) return;
384
+ if (mutationData?.sendMessage?.id) {
385
+ handleGenerateAiCode(mutationData.sendMessage.id);
386
+ }
387
+ }
388
+ });
389
+ } else {
390
+ await sendMsg({
391
+ variables: {
392
+ channelId: actualChannelId,
393
+ content: message,
394
+ extraProps
395
+ },
396
+ optimisticResponse: {
397
+ __typename: 'Mutation',
398
+ sendMessage: createOptimisticMessage()
399
+ },
400
+ update: (cache, {
401
+ data: mutationData
402
+ }) => {
403
+ if (!mutationData?.sendMessage) return;
404
+ console.log('mutationData', JSON.stringify(mutationData, null, 2));
405
+ if (mutationData?.sendMessage?.id) {
406
+ handleGenerateAiCode(mutationData.sendMessage.id);
407
+ }
408
+ }
409
+ });
410
+ }
411
+ // Scroll to bottom after send
412
+ scrollToBottom('smooth', 0);
413
+ } catch (error) {
414
+ console.error('Error sending message from AIAgent:', error);
415
+ setIsLoading(false);
416
+ }
417
+ return;
418
+ }
419
+ // If no channelId, we skip sending here.
420
+ }, [actualChannelId, auth, startUpload, sendMsg, scrollToBottom, getValidatedConfig, hasApiKey, modelConfig]);
421
+ const fixError = useCallback(errorMessage => {
422
+ // Use sendMessage to fix the error, which will use createProject flow
423
+ return handleSend(errorMessage);
424
+ }, [handleSend]);
425
+ const handleRetry = useCallback(() => {
426
+ send({
427
+ type: 'RETRY'
428
+ });
429
+ }, [send]);
430
+ const handleClearError = useCallback(() => {
431
+ send({
432
+ type: 'CLEAR_ERROR'
433
+ });
434
+ }, [send]);
435
+ // Use only default/regular messages and ignore AI messages
436
+ const allMessages = useMemo(() => {
437
+ if (!regularMessages) return [];
438
+ const regularMessagesFormatted = (regularMessages || []).map((m, idx) => ({
439
+ id: m.id || `regular-${idx}`,
440
+ message: m.message || m.content || '',
441
+ createdAt: new Date(m.createdAt || Date.now()),
442
+ propsConfiguration: m.propsConfiguration,
443
+ props: m.props,
444
+ files: m.files,
445
+ sender: 'user',
446
+ author: m.author,
447
+ isUserMessage: true
448
+ }));
449
+ return regularMessagesFormatted;
450
+ }, [regularMessages, currentUser]);
451
+ // Build list with date separators similar to MessagesBuilderUi
452
+ const messageListWithDates = useMemo(() => {
453
+ let currentDate = '';
454
+ const res = [];
455
+ allMessages?.forEach(msg => {
456
+ const date = new Date(msg.createdAt);
457
+ let msgDate;
458
+ if (isToday(date)) msgDate = t('tailwind_ui_inbox.today');else if (isYesterday(date)) msgDate = t('tailwind_ui_inbox.yesterday');else msgDate = format(date, 'eee, do MMMM');
459
+ if (msgDate !== currentDate) {
460
+ res.push({
461
+ type: 'date',
462
+ content: msgDate
463
+ });
464
+ currentDate = msgDate;
465
+ }
466
+ res.push(msg);
467
+ });
468
+ if (allMessages && allMessages.length > 0) {
469
+ const todayLabel = t('tailwind_ui_inbox.today');
470
+ if (currentDate !== todayLabel) {
471
+ res.push({
472
+ type: 'date',
473
+ content: todayLabel
474
+ });
475
+ }
476
+ }
477
+ return res;
478
+ }, [allMessages, t]);
479
+ // Group messages by date sections for Slack-like rendering
480
+ const messagesByDate = useMemo(() => {
481
+ const sections = [];
482
+ let currentSection = {
483
+ date: null,
484
+ messages: []
485
+ };
486
+ messageListWithDates.forEach(item => {
487
+ if (item?.type === 'date') {
488
+ if (currentSection.messages.length > 0) {
489
+ sections.push(currentSection);
490
+ }
491
+ currentSection = {
492
+ date: item.content,
493
+ messages: []
494
+ };
495
+ } else {
496
+ currentSection.messages.push(item);
497
+ }
498
+ });
499
+ if (currentSection.messages.length > 0) {
500
+ sections.push(currentSection);
501
+ }
502
+ return sections;
503
+ }, [messageListWithDates]);
504
+ // Show all messages without limiting
505
+ const limitedMessagesByDate = useMemo(() => {
506
+ if (!messagesByDate || messagesByDate.length === 0) return [];
507
+ return messagesByDate;
508
+ }, [messagesByDate]);
509
+ // Ensure we show complete conversation pairs (user message + AI response)
510
+ const completeConversationMessages = useMemo(() => {
511
+ if (!limitedMessagesByDate || limitedMessagesByDate.length === 0) return [];
512
+ const completeSections = [];
513
+ limitedMessagesByDate.forEach(section => {
514
+ const completeMessages = [];
515
+ const sectionMessages = [...section.messages];
516
+ console.log('🔄 Processing section for complete conversations:', {
517
+ sectionDate: section.date,
518
+ totalMessages: sectionMessages.length,
519
+ messages: sectionMessages.map(m => ({
520
+ sender: m.sender,
521
+ isUserMessage: m.isUserMessage,
522
+ message: m.message?.substring(0, 30) + '...'
523
+ }))
524
+ });
525
+ // Group messages into conversation pairs
526
+ for (let i = 0; i < sectionMessages.length; i++) {
527
+ const currentMsg = sectionMessages[i];
528
+ // If this is a user message, look for its AI response
529
+ if (currentMsg.sender === 'user' || currentMsg.isUserMessage) {
530
+ completeMessages.push(currentMsg);
531
+ // Look for the corresponding AI response (next message should be AI)
532
+ if (i + 1 < sectionMessages.length) {
533
+ const nextMsg = sectionMessages[i + 1];
534
+ if (nextMsg.sender === 'ai' || !nextMsg.isUserMessage) {
535
+ completeMessages.push(nextMsg);
536
+ i++; // Skip the next message since we've already added it
537
+ }
538
+ }
539
+ } else if (currentMsg.sender === 'ai' || !currentMsg.isUserMessage) {
540
+ // If this is an AI message without a preceding user message, still show it
541
+ completeMessages.push(currentMsg);
542
+ }
543
+ }
544
+ console.log('🔄 Complete messages for section:', {
545
+ sectionDate: section.date,
546
+ completeMessages: completeMessages.map(m => ({
547
+ sender: m.sender,
548
+ isUserMessage: m.isUserMessage,
549
+ message: m.message?.substring(0, 30) + '...'
550
+ }))
551
+ });
552
+ if (completeMessages.length > 0) {
553
+ completeSections.push({
554
+ ...section,
555
+ messages: completeMessages
556
+ });
557
+ }
558
+ });
559
+ return completeSections;
560
+ }, [limitedMessagesByDate]);
561
+ // Auto scroll to bottom when messages, typing status, or AI responses change
562
+ useEffect(() => {
563
+ // scrollToBottom('smooth', 100);
564
+ }, [completeConversationMessages?.length, isTyping, aiMessages.length, scrollToBottom]);
565
+ // Cleanup any pending timeout on unmount
566
+ useEffect(() => {
567
+ return () => {
568
+ if (successThinkingTimeoutRef.current) {
569
+ clearTimeout(successThinkingTimeoutRef.current);
570
+ }
571
+ };
572
+ }, []);
573
+ const extractCleanContent = useCallback(summary => {
574
+ console.log('summary...........', summary);
575
+ if (!summary) return 'Project generated successfully!';
576
+ const summeryData = summary.replace(/<canvas_layers>[\s\S]*?<\/canvas_layers>/g, '').replace(/<task_summary>([\s\S]*?)<\/task_summary>/g, '');
577
+ if (summeryData && summeryData.trim() !== '' && summeryData.trim()?.length > 0) {
578
+ return summeryData || 'Project generated successfully!';
579
+ }
580
+ // Extract content from <task_summary> tags
581
+ const taskSummaryMatch = summary.match(/<task_summary>([\s\S]*?)<\/task_summary>/);
582
+ if (taskSummaryMatch) {
583
+ // const removedCanvasLayers = summary.replace(/<canvas_layers>[\s\S]*?<\/canvas_layers>/g, '').replace(/<task_summary>([\s\S]*?)<\/task_summary>/g, '');
584
+ return taskSummaryMatch?.[1]?.trim() ?? 'Project generated successfully!';
585
+ }
586
+ // If no task_summary tags, remove canvas_layers and return the rest
587
+ const withoutCanvasLayers = summary.replace(/<canvas_layers>[\s\S]*?<\/canvas_layers>/g, '').trim();
588
+ return withoutCanvasLayers || 'Project generated successfully!';
589
+ }, []);
590
+ return React__default.createElement("div", {
591
+ className: `flex flex-col h-full ${className}`
592
+ }, React__default.createElement("div", {
593
+ className: "border-b border-gray-200 bg-white"
594
+ }, React__default.createElement("div", {
595
+ className: "flex items-center justify-between px-4 py-3"
596
+ }, React__default.createElement("div", {
597
+ className: "flex space-x-6"
598
+ }, React__default.createElement("button", {
599
+ onClick: () => setActiveTab('chat'),
600
+ className: `relative ${activeTab === 'chat' ? 'text-blue-600 font-medium' : 'text-gray-500 hover:text-gray-700'} text-sm transition-colors`
601
+ }, React__default.createElement("span", null, "Chat"), activeTab === 'chat' && React__default.createElement("div", {
602
+ className: "absolute bottom-0 left-0 w-full h-0.5 bg-blue-600"
603
+ })), React__default.createElement("button", {
604
+ onClick: () => setActiveTab('history'),
605
+ className: `relative ${activeTab === 'history' ? 'text-blue-600 font-medium' : 'text-gray-500 hover:text-gray-700'} text-sm transition-colors`
606
+ }, React__default.createElement("span", null, "History"), activeTab === 'history' && React__default.createElement("div", {
607
+ className: "absolute bottom-0 left-0 w-full h-0.5 bg-blue-600"
608
+ }))))), activeTab === 'history' ? (/* History Tab Content */
609
+ React__default.createElement("div", {
610
+ className: "flex-1 overflow-y-auto bg-white"
611
+ }, React__default.createElement("div", {
612
+ className: "px-4 py-3 border-b border-gray-200"
613
+ }, React__default.createElement("div", {
614
+ className: "relative"
615
+ }, React__default.createElement("div", {
616
+ className: "absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"
617
+ }, React__default.createElement("svg", {
618
+ className: "h-5 w-5 text-gray-400",
619
+ fill: "none",
620
+ viewBox: "0 0 24 24",
621
+ stroke: "currentColor"
622
+ }, React__default.createElement("path", {
623
+ strokeLinecap: "round",
624
+ strokeLinejoin: "round",
625
+ strokeWidth: 2,
626
+ d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
627
+ }))), React__default.createElement("input", {
628
+ type: "text",
629
+ placeholder: "Search messages...",
630
+ className: "block w-full pl-10 pr-12 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm"
631
+ }), React__default.createElement("div", {
632
+ className: "absolute inset-y-0 right-0 pr-3 flex items-center"
633
+ }, React__default.createElement("button", {
634
+ className: "text-gray-400 hover:text-gray-600"
635
+ }, React__default.createElement("svg", {
636
+ className: "h-5 w-5",
637
+ fill: "none",
638
+ viewBox: "0 0 24 24",
639
+ stroke: "currentColor"
640
+ }, React__default.createElement("path", {
641
+ strokeLinecap: "round",
642
+ strokeLinejoin: "round",
643
+ strokeWidth: 2,
644
+ d: "M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"
645
+ })))))), React__default.createElement("div", {
646
+ className: "px-4 py-2"
647
+ }, regularMessages && regularMessages.length > 0 ? regularMessages.filter(msg => msg?.propsConfiguration?.contents?.role === 'USER').map((msg, index) => {
648
+ new Date(msg.createdAt);
649
+ return React__default.createElement("div", {
650
+ key: msg.id || index,
651
+ className: "mb-4"
652
+ }, React__default.createElement("div", {
653
+ className: "flex items-center justify-end mb-2"
654
+ }, React__default.createElement("button", {
655
+ className: "text-blue-600 text-sm underline hover:text-blue-800 flex items-center"
656
+ }, React__default.createElement("svg", {
657
+ className: "w-4 h-4 mr-1",
658
+ fill: "none",
659
+ viewBox: "0 0 24 24",
660
+ stroke: "currentColor"
661
+ }, React__default.createElement("path", {
662
+ strokeLinecap: "round",
663
+ strokeLinejoin: "round",
664
+ strokeWidth: 2,
665
+ d: "M15 19l-7-7 7-7"
666
+ })), "Restore to this point")), React__default.createElement(ModernMessageGroupComponent, {
667
+ messages: [{
668
+ id: msg.id,
669
+ //message: msg.message || msg.content || 'No message content',
670
+ message: msg?.propsConfiguration?.contents?.role === 'ASSISTANT' ? msg.propsConfiguration?.contents?.fragment?.summary ? extractCleanContent(msg.propsConfiguration?.contents?.fragment?.summary) : msg.message : msg.message,
671
+ author: msg.author || {
672
+ id: 'user',
673
+ givenName: 'User',
674
+ familyName: '',
675
+ fullName: 'User',
676
+ username: 'user',
677
+ email: '',
678
+ picture: null,
679
+ alias: [],
680
+ tokens: []
681
+ },
682
+ createdAt: msg.createdAt,
683
+ type: 'Simple',
684
+ isDelivered: false,
685
+ isRead: false,
686
+ parentId: null,
687
+ fromServer: null,
688
+ updatedAt: msg.createdAt,
689
+ propsConfiguration: msg.propsConfiguration,
690
+ props: msg.props,
691
+ files: msg.files,
692
+ replies: null,
693
+ channel: null,
694
+ isPinned: false
695
+ }],
696
+ currentUser: currentUser,
697
+ onOpen: onOpen,
698
+ onMessageClick: msg => setSelectedPost(msg),
699
+ isDesktopView: isDesktopView,
700
+ isSmallScreen: isSmallScreen
701
+ }));
702
+ }) :
703
+ // Fallback entries when no messages
704
+ React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
705
+ className: "mb-4"
706
+ }, React__default.createElement("div", {
707
+ className: "flex items-center justify-end mb-2"
708
+ }, React__default.createElement("button", {
709
+ className: "text-blue-600 text-sm underline hover:text-blue-800 flex items-center"
710
+ }, React__default.createElement("svg", {
711
+ className: "w-4 h-4 mr-1",
712
+ fill: "none",
713
+ viewBox: "0 0 24 24",
714
+ stroke: "currentColor"
715
+ }, React__default.createElement("path", {
716
+ strokeLinecap: "round",
717
+ strokeLinejoin: "round",
718
+ strokeWidth: 2,
719
+ d: "M15 19l-7-7 7-7"
720
+ })), "Restore to this point")), React__default.createElement("div", {
721
+ className: "bg-gray-100 rounded-lg p-3"
722
+ }, React__default.createElement("p", {
723
+ className: "text-sm text-gray-900"
724
+ }, "Sample message for demonstration"))))))) : (/* Chat Tab Content */
725
+ React__default.createElement("div", {
726
+ className: "flex-1 overflow-y-auto bg-white"
727
+ }, React__default.createElement("div", {
728
+ className: `w-full pb-4 pt-2 ${isDesktopView ? 'space-y-3 max-w-full mx-auto' : isSmallScreen ? 'space-y-2' : 'space-y-2'}`
729
+ }, (!completeConversationMessages || completeConversationMessages.length === 0) && React__default.createElement("div", {
730
+ className: "px-4 py-8 text-center"
731
+ }, React__default.createElement("div", {
732
+ className: "text-gray-500 text-lg font-medium mb-2"
733
+ }, "Describe your idea and I'll help you create it step by step"), React__default.createElement("div", {
734
+ className: "text-gray-400 text-sm"
735
+ }, "Start a new conversation by typing your message below")), completeConversationMessages?.map((section, sectionIndex) => React__default.createElement("div", {
736
+ key: `section-${sectionIndex}`,
737
+ className: "w-full px-4"
738
+ }, section.date && React__default.createElement("div", {
739
+ className: "flex items-center justify-center my-3"
740
+ }, React__default.createElement("div", {
741
+ className: "flex-grow border-t border-gray-200"
742
+ }), React__default.createElement("div", {
743
+ className: "mx-4 px-3 py-1 bg-white border border-gray-200 rounded-full text-xs font-medium text-gray-600"
744
+ }, section.date), React__default.createElement("div", {
745
+ className: "flex-grow border-t border-gray-200"
746
+ })), React__default.createElement("div", {
747
+ className: `${isDesktopView ? 'mb-2' : 'mb-1'}`
748
+ }, section.messages.map((msg, msgIndex) => React__default.createElement("div", {
749
+ key: msg.id || msgIndex,
750
+ className: "mb-3"
751
+ }, msg.isAIMessage && React__default.createElement("div", {
752
+ className: "flex items-center mb-2"
753
+ }, React__default.createElement("div", {
754
+ className: "w-2 h-2 bg-blue-500 rounded-full mr-2"
755
+ }), React__default.createElement("span", {
756
+ className: "text-xs text-blue-600 font-medium"
757
+ }, "AI Assistant")), msg.isLoading ?
758
+ // Show loader for loading messages
759
+ React__default.createElement("div", {
760
+ className: "flex items-center space-x-2 bg-gray-50 border border-gray-200 px-4 py-3 rounded-lg"
761
+ }, React__default.createElement("div", {
762
+ className: "w-4 h-4 border-2 border-gray-300 border-t-gray-500 rounded-full animate-spin"
763
+ }), React__default.createElement("span", {
764
+ className: "text-sm text-gray-600"
765
+ }, msg.isProcessing ? 'Thinking...' : 'Thinking...')) :
766
+ // Show normal message for non-loading messages
767
+ React__default.createElement(ModernMessageGroupComponent, {
768
+ messages: [{
769
+ id: msg.id,
770
+ // message: msg.message,
771
+ message: msg?.propsConfiguration?.contents?.role === 'ASSISTANT' ? msg.propsConfiguration?.contents?.fragment?.summary ? extractCleanContent(msg.propsConfiguration?.contents?.fragment?.summary) : msg.message : msg.message,
772
+ author: msg.sender === 'user' ? msg.author : {
773
+ id: 'ai-assistant',
774
+ givenName: 'AI',
775
+ familyName: 'Assistant',
776
+ fullName: 'AI Assistant',
777
+ username: 'ai-assistant',
778
+ email: 'ai@assistant.com',
779
+ picture: null,
780
+ alias: [],
781
+ tokens: []
782
+ },
783
+ createdAt: msg.createdAt,
784
+ type: 'Simple',
785
+ isDelivered: false,
786
+ isRead: false,
787
+ parentId: null,
788
+ fromServer: null,
789
+ updatedAt: msg.createdAt,
790
+ propsConfiguration: msg.propsConfiguration,
791
+ props: msg.props,
792
+ files: msg.files,
793
+ replies: null,
794
+ channel: null,
795
+ isPinned: false
796
+ }],
797
+ currentUser: currentUser,
798
+ onOpen: onOpen,
799
+ onMessageClick: msg => setSelectedPost(msg),
800
+ isDesktopView: isDesktopView,
801
+ isSmallScreen: isSmallScreen,
802
+ sandboxErrors: sandboxErrors,
803
+ currentFiles: currentFiles,
804
+ onFixError: fixError,
805
+ onRecreateSandbox: recreateSandboxForFragment
806
+ })))))), (isTyping || isSuccessThinking || isLoading) && React__default.createElement("div", {
807
+ className: "px-4"
808
+ }, React__default.createElement("div", {
809
+ className: "flex justify-start"
810
+ }, React__default.createElement("div", {
811
+ className: "bg-gray-50 border border-gray-200 px-4 py-3 rounded-lg"
812
+ }, React__default.createElement("div", {
813
+ className: "flex items-center space-x-2"
814
+ }, React__default.createElement("div", {
815
+ className: "w-4 h-4 border-2 border-gray-300 border-t-gray-500 rounded-full animate-spin"
816
+ }), React__default.createElement("span", {
817
+ className: "text-sm text-gray-600"
818
+ }, "Thinking..."))))), React__default.createElement("div", {
819
+ ref: bottomRef
820
+ })), React__default.createElement(SubscriptionHandler, {
821
+ subscribeToMore: subscribeToMore,
822
+ document: OnChatMessageAddedDocument,
823
+ variables: {
824
+ channelId: actualChannelId?.toString()
825
+ },
826
+ enabled: !!actualChannelId && !!subscribeToMore,
827
+ updateQuery: (prev, {
828
+ subscriptionData
829
+ }) => {
830
+ console.log('Subscription updateQuery called:', {
831
+ prev,
832
+ subscriptionData
833
+ });
834
+ if (!subscriptionData.data) {
835
+ console.log('No subscription data, returning prev');
836
+ return prev;
837
+ }
838
+ const newMessage = subscriptionData.data.chatMessageAdded;
839
+ console.log('New message received via subscription:', newMessage);
840
+ return {
841
+ ...prev,
842
+ messages: {
843
+ ...prev?.messages,
844
+ data: uniqBy([...(prev?.messages?.data || []), newMessage], 'id'),
845
+ totalCount: (prev?.messages?.totalCount || 0) + 1
846
+ }
847
+ };
848
+ },
849
+ onError: error => {
850
+ console.error('Subscription error:', error);
851
+ }
852
+ }))), error && React__default.createElement("div", {
853
+ className: "mx-4 mb-4 p-3 bg-red-50 border border-red-200 rounded-lg"
854
+ }, React__default.createElement("div", {
855
+ className: "flex items-center justify-between"
856
+ }, React__default.createElement("div", {
857
+ className: "text-red-800 text-sm"
858
+ }, error), React__default.createElement("div", {
859
+ className: "flex space-x-2"
860
+ }, React__default.createElement("button", {
861
+ onClick: handleRetry,
862
+ className: "px-2 py-1 text-xs bg-red-100 text-red-700 rounded hover:bg-red-200 transition-colors"
863
+ }, "Retry"), React__default.createElement("button", {
864
+ onClick: handleClearError,
865
+ className: "px-2 py-1 text-xs bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors"
866
+ }, "Dismiss")))), activeTab === 'chat' && React__default.createElement("div", {
867
+ className: "border-t border-gray-200 bg-white"
868
+ }, React__default.createElement(InputComponent, {
869
+ channelId: actualChannelId,
870
+ handleSend: handleSend,
871
+ placeholder: placeholder,
872
+ modelConfig: modelConfig,
873
+ onModelConfigChange: updateModelConfig
874
+ })), isOpen ? React__default.createElement("div", null, React__default.createElement("div", {
875
+ className: "fixed inset-0 bg-black bg-opacity-50 z-40",
876
+ onClick: onClose
877
+ }), React__default.createElement("div", {
878
+ className: "fixed z-50 left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2"
879
+ }, React__default.createElement("div", {
880
+ className: "bg-white w-[1036px] h-[700px] rounded-lg shadow-xl",
881
+ style: {
882
+ boxShadow: '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)'
883
+ }
884
+ }, React__default.createElement("div", {
885
+ className: "flex justify-between border-b border-gray-300 pb-4 pt-4"
886
+ }, React__default.createElement("button", {
887
+ onClick: onClose,
888
+ className: "w-8 ml-3 text-black hover:text-black focus:outline-none"
889
+ }, React__default.createElement("svg", {
890
+ className: "w-6 h-6",
891
+ fill: "none",
892
+ stroke: "currentColor",
893
+ viewBox: "0 0 24 24"
894
+ }, React__default.createElement("path", {
895
+ strokeLinecap: "round",
896
+ strokeLinejoin: "round",
897
+ strokeWidth: 2,
898
+ d: "M6 18L18 6M6 6l12 12"
899
+ })))), React__default.createElement("div", {
900
+ className: "p-4"
901
+ }, React__default.createElement("div", {
902
+ className: "text-sm text-gray-700"
903
+ }, selectedElement?.author?.username))))) : null);
904
+ };export{AIAgent};//# sourceMappingURL=AIAgent.js.map