@zenify-omni/chat-ui-react-js 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -0
  3. package/assets/asset-url.js +6 -0
  4. package/assets/icons/chatter_agent.js +27 -0
  5. package/assets/icons/chatter_chatbot.js +43 -0
  6. package/assets/icons/chatter_contact.js +36 -0
  7. package/assets/icons/email_icon.png +0 -0
  8. package/assets/icons/emoji/angry.svg +56 -0
  9. package/assets/icons/emoji/haha.svg +20 -0
  10. package/assets/icons/emoji/like.svg +10 -0
  11. package/assets/icons/emoji/like_out_line.png +0 -0
  12. package/assets/icons/emoji/love.svg +10 -0
  13. package/assets/icons/emoji/sad.svg +46 -0
  14. package/assets/icons/emoji/wow.svg +51 -0
  15. package/assets/icons/instagram.js +29 -0
  16. package/assets/icons/not_found.png +0 -0
  17. package/assets/icons/not_found_template.svg +9 -0
  18. package/assets/icons/phone_icon.png +0 -0
  19. package/assets/icons/shopee.js +17 -0
  20. package/assets/icons/sms_icon.png +0 -0
  21. package/assets/icons/tiktok.js +17 -0
  22. package/assets/icons/whatsapp.js +28 -0
  23. package/assets/icons/zalo.js +17 -0
  24. package/assets/icons/zalo_icon.png +0 -0
  25. package/assets/icons/zns_icon.png +0 -0
  26. package/assets/images/emoji.webp +0 -0
  27. package/assets/images/error.png +0 -0
  28. package/assets/images/menu.png +0 -0
  29. package/assets/images/money.png +0 -0
  30. package/assets/images/success.png +0 -0
  31. package/assets/public-urls.js +78 -0
  32. package/components/campaign-detail-route/select/group.js +38 -0
  33. package/components/campaign-detail-route/select/multi-groups.js +43 -0
  34. package/components/chat-route/chat-box/ads-context-card.js +143 -0
  35. package/components/chat-route/chat-box/chat-drop-file.js +18 -0
  36. package/components/chat-route/chat-box/chat-feedback/chat-insight.js +214 -0
  37. package/components/chat-route/chat-box/chat-feedback/index.js +127 -0
  38. package/components/chat-route/chat-box/chat-header-actions-inline.js +1055 -0
  39. package/components/chat-route/chat-box/chat-header.js +465 -0
  40. package/components/chat-route/chat-box/chat-input.js +1164 -0
  41. package/components/chat-route/chat-box/chat-message-action.js +399 -0
  42. package/components/chat-route/chat-box/chat-message-list.js +995 -0
  43. package/components/chat-route/chat-box/chat-message.js +2099 -0
  44. package/components/chat-route/chat-box/chat-reply-preview.js +317 -0
  45. package/components/chat-route/chat-box/common-groups-modal.js +430 -0
  46. package/components/chat-route/chat-box/constants.js +29 -0
  47. package/components/chat-route/chat-box/contact-card/index.js +87 -0
  48. package/components/chat-route/chat-box/edit-customer-alias-dialog.js +197 -0
  49. package/components/chat-route/chat-box/emoji-picker-combined.js +91 -0
  50. package/components/chat-route/chat-box/emoji-sprite.js +45 -0
  51. package/components/chat-route/chat-box/emojiMap.js +92 -0
  52. package/components/chat-route/chat-box/facebook-reconnect-notice.js +49 -0
  53. package/components/chat-route/chat-box/forward-message-modal.js +659 -0
  54. package/components/chat-route/chat-box/index.js +165 -0
  55. package/components/chat-route/chat-box/message-time.js +44 -0
  56. package/components/chat-route/chat-box/message-viewers.js +114 -0
  57. package/components/chat-route/chat-box/pasted-file-preview.js +138 -0
  58. package/components/chat-route/chat-box/pinned-messages.js +255 -0
  59. package/components/chat-route/chat-box/react-message/react-preview.js +83 -0
  60. package/components/chat-route/chat-box/react-message/reaction-button.js +200 -0
  61. package/components/chat-route/chat-box/right-side/chat-history.js +142 -0
  62. package/components/chat-route/chat-box/right-side/chat-tag-selector.js +232 -0
  63. package/components/chat-route/chat-box/right-side/create-personal-tag-modal.js +458 -0
  64. package/components/chat-route/chat-box/right-side/customer/customer-info-item.js +60 -0
  65. package/components/chat-route/chat-box/right-side/in-room-dialog.js +225 -0
  66. package/components/chat-route/chat-box/right-side/zalo-group/add-friend-dialog.js +154 -0
  67. package/components/chat-route/chat-box/right-side/zalo-group/send-message-dialog.js +165 -0
  68. package/components/chat-route/chat-box/send-contact-card-modal.js +102 -0
  69. package/components/chat-route/chat-box/send-contact-card.js +80 -0
  70. package/components/chat-route/chat-box/text-content.js +400 -0
  71. package/components/chat-route/chat-box/use-facebook-page-invalid.js +22 -0
  72. package/components/chat-route/chat-box/zalo-emoji-decoration.js +98 -0
  73. package/components/chat-route/chat-box/zalo-emoji-picker.js +74 -0
  74. package/components/chat-route/chat-box/zalo-personal-editor.js +590 -0
  75. package/components/chat-route/chat-box/zalo-reminder/create-zalo-reminder.js +868 -0
  76. package/components/chat-route/chat-box/zalo-reminder/use-send-zalo-reminder.js +98 -0
  77. package/components/chat-route/chat-box/zalo-reminder/zalo-reminder-content.js +294 -0
  78. package/components/chat-route/chat-box/zalo-rtf-utils.js +422 -0
  79. package/components/chat-route/chat-list/action-chat-item.js +116 -0
  80. package/components/chat-route/chat-list/assign-agent-dialog.js +170 -0
  81. package/components/chat-route/chat-list/assign-tag-dialog.js +242 -0
  82. package/components/chat-route/chat-list/chat-item-tags.js +105 -0
  83. package/components/chat-route/chat-list/chat-item.js +749 -0
  84. package/components/chat-route/chat-list/chat-list-item.js +370 -0
  85. package/components/chat-route/chat-list/chat-list-selection-bar.js +426 -0
  86. package/components/chat-route/chat-list/chat-search-preview.js +48 -0
  87. package/components/chat-route/chat-list/chat-sort-menu.js +89 -0
  88. package/components/chat-route/chat-list/edit-filter-modal.js +468 -0
  89. package/components/chat-route/chat-list/filter-chat-sources.js +222 -0
  90. package/components/chat-route/chat-list/filter-chat.js +501 -0
  91. package/components/chat-route/chat-list/filter-criteria-rows.js +845 -0
  92. package/components/chat-route/chat-list/filter-group-select.js +66 -0
  93. package/components/chat-route/chat-list/filter-pin-menu.js +165 -0
  94. package/components/chat-route/chat-list/friend-request/list-friend-request.js +287 -0
  95. package/components/chat-route/chat-list/index.js +243 -0
  96. package/components/chat-route/chat-list/inline-search-results.js +178 -0
  97. package/components/chat-route/chat-list/post-ids-field.js +104 -0
  98. package/components/chat-route/chat-list/quick-filter-bar.js +391 -0
  99. package/components/chat-route/chat-list/save-filter-popover.js +258 -0
  100. package/components/chat-route/chat-list/search-messages/index.js +225 -0
  101. package/components/chat-route/chat-list/search-result-header.js +51 -0
  102. package/components/chat-route/chat-list/util.js +604 -0
  103. package/components/chat-route/chat-toolbar.js +108 -0
  104. package/components/chat-route/hooks/use-reassign.js +111 -0
  105. package/components/chat-route/shared/close-conversation-dialog.js +111 -0
  106. package/components/chat-route/shared/force-transfer-dialog.js +109 -0
  107. package/components/chat-route/shared/in-queue-confirm-dialog.js +40 -0
  108. package/components/chat-route/util.js +146 -0
  109. package/components/chat-route/zalo/modal-action-zalo.js +76 -0
  110. package/components/chat-route/zalo/modal-add-friend-zalo.js +277 -0
  111. package/components/custom/SafeHTML.js +45 -0
  112. package/components/custom/audio-player.js +81 -0
  113. package/components/custom/avatar.js +95 -0
  114. package/components/custom/between-date-picker/index.js +86 -0
  115. package/components/custom/button-close.js +28 -0
  116. package/components/custom/button.js +80 -0
  117. package/components/custom/color-picker.js +81 -0
  118. package/components/custom/combobox.js +168 -0
  119. package/components/custom/custom-dialog.js +44 -0
  120. package/components/custom/custom-select.js +256 -0
  121. package/components/custom/cycle-value-helpers.js +11 -0
  122. package/components/custom/cycle-value.js +93 -0
  123. package/components/custom/date-time-picker/components/date-time-group.js +44 -0
  124. package/components/custom/date-time-picker/components/date-time-input.js +383 -0
  125. package/components/custom/date-time-picker/components/date-time-unit-input.js +138 -0
  126. package/components/custom/date-time-picker/components/month-year-picker.js +232 -0
  127. package/components/custom/date-time-picker/hooks/use-merge-refs.js +18 -0
  128. package/components/custom/date-time-picker/hooks/use-scroll-to-center.js +18 -0
  129. package/components/custom/date-time-picker/index.js +348 -0
  130. package/components/custom/field-file-upload/files-upload.js +87 -0
  131. package/components/custom/field-file-upload/image-upload.js +115 -0
  132. package/components/custom/field-file-upload/preview-images-modal.js +284 -0
  133. package/components/custom/field-file-upload/preview-list-file.js +134 -0
  134. package/components/custom/field-file-upload/preview-list-image.js +108 -0
  135. package/components/custom/field-file-upload/upload-custom.js +222 -0
  136. package/components/custom/field-generator.js +639 -0
  137. package/components/custom/field-layout-popover.js +304 -0
  138. package/components/custom/file-preview-modal.js +351 -0
  139. package/components/custom/html-edtior.js +100 -0
  140. package/components/custom/icon.js +49 -0
  141. package/components/custom/infinite-scroll-combobox.js +253 -0
  142. package/components/custom/inline-edit-popover.js +90 -0
  143. package/components/custom/inputs/calendar-input.js +0 -0
  144. package/components/custom/inputs/chip-input.js +136 -0
  145. package/components/custom/inputs/file-input.js +71 -0
  146. package/components/custom/inputs/mask-data/mask-data-input.js +80 -0
  147. package/components/custom/inputs/mask-data/mask-data-select.js +78 -0
  148. package/components/custom/inputs/mask-data/mask-data-textarea.js +75 -0
  149. package/components/custom/inputs/mask-data/reconcile-masked-edit.js +20 -0
  150. package/components/custom/jxl-decode.js +34 -0
  151. package/components/custom/jxl-image.js +68 -0
  152. package/components/custom/jxl-worker.js +12 -0
  153. package/components/custom/label.js +55 -0
  154. package/components/custom/layout.js +30 -0
  155. package/components/custom/multi-select-search-cc.js +179 -0
  156. package/components/custom/multiple-select-setting-tags.js +404 -0
  157. package/components/custom/multiple-selector.js +821 -0
  158. package/components/custom/pagination.js +95 -0
  159. package/components/custom/popup-confirm.js +120 -0
  160. package/components/custom/previews/facebook/facebook-appointment-booking-preview.js +83 -0
  161. package/components/custom/previews/facebook/facebook-audio-preview.js +130 -0
  162. package/components/custom/previews/facebook/facebook-event-preview.js +72 -0
  163. package/components/custom/previews/facebook/facebook-file-preview.js +95 -0
  164. package/components/custom/previews/facebook/facebook-group-preview.js +103 -0
  165. package/components/custom/previews/facebook/facebook-image-preview.js +81 -0
  166. package/components/custom/previews/facebook/facebook-page-preview.js +85 -0
  167. package/components/custom/previews/facebook/facebook-post-preview.js +77 -0
  168. package/components/custom/previews/facebook/facebook-reel-preview.js +83 -0
  169. package/components/custom/previews/facebook/facebook-sticker-preview.js +23 -0
  170. package/components/custom/previews/facebook/facebook-video-preview.js +114 -0
  171. package/components/custom/previews/facebook/index.js +24 -0
  172. package/components/custom/previews/file-preview.js +747 -0
  173. package/components/custom/previews/image-preview.js +288 -0
  174. package/components/custom/previews/instagram/index.js +4 -0
  175. package/components/custom/previews/instagram/instagram-share-post-preview.js +77 -0
  176. package/components/custom/previews/link-preview.js +166 -0
  177. package/components/custom/previews/product-preview.js +334 -0
  178. package/components/custom/previews/tiktok-order-preview.js +278 -0
  179. package/components/custom/previews/tiktok-product-preview.js +321 -0
  180. package/components/custom/previews/tiktok-voucher-preview.js +151 -0
  181. package/components/custom/previews/whatsapp/index.js +10 -0
  182. package/components/custom/previews/whatsapp/whatsapp-contact-card-preview.js +150 -0
  183. package/components/custom/previews/whatsapp/whatsapp-order-preview.js +38 -0
  184. package/components/custom/previews/whatsapp/whatsapp-poll-preview.js +29 -0
  185. package/components/custom/previews/whatsapp/whatsapp-product-preview.js +29 -0
  186. package/components/custom/retry-image.js +44 -0
  187. package/components/custom/search-input.js +26 -0
  188. package/components/custom/separator-with-text.js +14 -0
  189. package/components/custom/showToast.js +21 -0
  190. package/components/custom/sortable-header.js +62 -0
  191. package/components/custom/table-resize-line.js +92 -0
  192. package/components/custom/time-picker/index.js +73 -0
  193. package/components/custom/time-picker/time-picker-input.js +159 -0
  194. package/components/custom/time-picker/time-picker-utils.js +152 -0
  195. package/components/custom/viewers/audio-player.js +192 -0
  196. package/components/custom/viewers/code-viewer.js +140 -0
  197. package/components/custom/viewers/csv-viewer.js +174 -0
  198. package/components/custom/viewers/docx-viewer.js +145 -0
  199. package/components/custom/viewers/image-viewer.js +104 -0
  200. package/components/custom/viewers/markdown-viewer.js +124 -0
  201. package/components/custom/viewers/pdf-viewer.js +333 -0
  202. package/components/custom/viewers/spreadsheet-viewer.js +232 -0
  203. package/components/custom/viewers/unsupported-viewer.js +85 -0
  204. package/components/custom/viewers/video-player.js +241 -0
  205. package/components/customers-route/change-owner-modal.js +430 -0
  206. package/components/customers-route/contact-note-button.js +212 -0
  207. package/components/customers-route/customer-source.js +37 -0
  208. package/components/customers-route/table/columns.js +675 -0
  209. package/components/customers-route/table/edit-fields.js +125 -0
  210. package/components/customers-route/table/editable-cell.js +218 -0
  211. package/components/customers-route/table/note-cell.js +77 -0
  212. package/components/dialogs/invite-agent.js +677 -0
  213. package/components/error-boundary.js +53 -0
  214. package/components/leads-route/duplicate-phone-warning-toast.js +96 -0
  215. package/components/leads-route/table/columns.js +523 -0
  216. package/components/leads-route/table/contact-cell-name.js +82 -0
  217. package/components/leads-route/table/edit-fields.js +142 -0
  218. package/components/leads-route/table/editable-cell.js +228 -0
  219. package/components/org-tree/group-name-display.js +36 -0
  220. package/components/org-tree/group-tree-multi-select.js +208 -0
  221. package/components/org-tree/group-tree-select.js +220 -0
  222. package/components/posts-route/dialog-select-posts.js +284 -0
  223. package/components/reports-route/agents/multi-select-agents.js +55 -0
  224. package/components/reports-route/agents/multi-select-search-agents.js +43 -0
  225. package/components/settings-route/chat-layout/detail/constants.js +353 -0
  226. package/components/settings-route/chat-layout/detail/form.js +43 -0
  227. package/components/settings-route/chat-timeout/channel-multi-select.js +119 -0
  228. package/components/settings-route/multi-channel/facebook/hooks/use-facebook-sdk.js +3 -0
  229. package/components/settings-route/object-rule/util.js +79 -0
  230. package/components/settings-route/routing/settings-dialog.js +561 -0
  231. package/components/settings-route/switchboard/queue-new/constant.js +9 -0
  232. package/components/shared/linked-customer-fields/LinkedCustomerFields.js +91 -0
  233. package/components/shared/linked-customer-fields/use-linked-customer-fields.js +123 -0
  234. package/components/smartqc-route/qc-form/controls/multi-select-search-agents.js +50 -0
  235. package/components/ui/alert-dialog.js +112 -0
  236. package/components/ui/avatar.js +44 -0
  237. package/components/ui/badge.js +54 -0
  238. package/components/ui/button.js +48 -0
  239. package/components/ui/calendar.js +70 -0
  240. package/components/ui/card.js +58 -0
  241. package/components/ui/carousel.js +238 -0
  242. package/components/ui/checkbox.js +27 -0
  243. package/components/ui/command.js +111 -0
  244. package/components/ui/context-menu.js +154 -0
  245. package/components/ui/dialog.js +104 -0
  246. package/components/ui/dropdown-menu.js +169 -0
  247. package/components/ui/form.js +104 -0
  248. package/components/ui/input.js +115 -0
  249. package/components/ui/label.js +20 -0
  250. package/components/ui/popover.js +29 -0
  251. package/components/ui/radio-group.js +53 -0
  252. package/components/ui/scroll-area.js +38 -0
  253. package/components/ui/select.js +147 -0
  254. package/components/ui/separator.js +24 -0
  255. package/components/ui/sheet.js +113 -0
  256. package/components/ui/skeleton.js +17 -0
  257. package/components/ui/slider.js +26 -0
  258. package/components/ui/sonner.js +76 -0
  259. package/components/ui/switch.js +54 -0
  260. package/components/ui/table-v2.js +269 -0
  261. package/components/ui/table.js +245 -0
  262. package/components/ui/tabs.js +89 -0
  263. package/components/ui/textarea.js +33 -0
  264. package/components/ui/tooltip.js +40 -0
  265. package/components/workflow-editor/nodes/ticket/picker-field.js +233 -0
  266. package/components/zalo-login-qr.js +237 -0
  267. package/components/zalo-login-status-modal.js +45 -0
  268. package/config/env.js +27 -0
  269. package/config/hmr.js +8 -0
  270. package/config/navigation.js +54 -0
  271. package/config/runtime.js +46 -0
  272. package/config/theme.js +274 -0
  273. package/constants/brand-colors.js +32 -0
  274. package/constants/chat-icon.js +34 -0
  275. package/dist/chat.css +1 -0
  276. package/exceptions/throw-exception.js +15 -0
  277. package/hooks/use-chat-attachments.js +106 -0
  278. package/hooks/use-chat-configs.js +62 -0
  279. package/hooks/use-chat-customer.js +33 -0
  280. package/hooks/use-chat-display-config-sync.js +72 -0
  281. package/hooks/use-chat-permission.js +68 -0
  282. package/hooks/use-chat-room-detail.js +44 -0
  283. package/hooks/use-chat-selection.js +26 -0
  284. package/hooks/use-chat-sort.js +69 -0
  285. package/hooks/use-chat-surface.js +8 -0
  286. package/hooks/use-common-filter-options.js +70 -0
  287. package/hooks/use-crm-organization-filter-options.js +0 -0
  288. package/hooks/use-crm-organizations-data.js +23 -0
  289. package/hooks/use-debounce.js +14 -0
  290. package/hooks/use-dynamic-fields.js +7 -0
  291. package/hooks/use-facebook-notice.js +24 -0
  292. package/hooks/use-feature-flags.js +6 -0
  293. package/hooks/use-field-layout-override.js +46 -0
  294. package/hooks/use-file-upload.js +119 -0
  295. package/hooks/use-file-viewer.js +93 -0
  296. package/hooks/use-frozen-columns.js +29 -0
  297. package/hooks/use-horizontal-scroll.js +41 -0
  298. package/hooks/use-image-preview-queue.js +101 -0
  299. package/hooks/use-inline-editable-cell.js +97 -0
  300. package/hooks/use-intersection-observer.js +24 -0
  301. package/hooks/use-interval.js +20 -0
  302. package/hooks/use-latest-message-id.js +13 -0
  303. package/hooks/use-lead-filter-options.js +0 -0
  304. package/hooks/use-logout-listener.js +43 -0
  305. package/hooks/use-org-tree.js +43 -0
  306. package/hooks/use-permission.js +33 -0
  307. package/hooks/use-quick-filters.js +175 -0
  308. package/hooks/use-resizable-table.js +0 -0
  309. package/hooks/use-setting-common.js +389 -0
  310. package/hooks/use-settings.js +41 -0
  311. package/hooks/use-sort-bindings.js +24 -0
  312. package/hooks/use-table-display-config.js +0 -0
  313. package/hooks/use-tenant-config.js +99 -0
  314. package/hooks/use-update-user-config.js +150 -0
  315. package/hooks/use-zalo-connection.js +57 -0
  316. package/hooks/use-zalo-mention-list.js +31 -0
  317. package/index.css +624 -0
  318. package/index.js +100 -0
  319. package/lib/deal-name.js +27 -0
  320. package/lib/i18n/react.js +7 -0
  321. package/lib/i18n/use-language.js +0 -0
  322. package/lib/query-client.js +34 -0
  323. package/lib/utils.js +25 -0
  324. package/package.json +108 -0
  325. package/provider/chat-context.js +9 -0
  326. package/provider/chat-provider.js +177 -0
  327. package/provider/chat-room-context.js +9 -0
  328. package/provider/chat-room-hooks.js +8 -0
  329. package/provider/chat-room-provider.js +84 -0
  330. package/provider/hooks.js +22 -0
  331. package/provider/index.js +42 -0
  332. package/public/contact-card-user.svg +25 -0
  333. package/public/images/icons/facebook.svg +1 -0
  334. package/public/images/icons/instagram.svg +1 -0
  335. package/public/images/icons/shopee.svg +1 -0
  336. package/public/images/icons/whatsapp.svg +1 -0
  337. package/public/images/icons/zalo.png +0 -0
  338. package/public/images/images.jpg +0 -0
  339. package/public/images/ticket_sources/api.png +0 -0
  340. package/public/images/ticket_sources/email.png +0 -0
  341. package/public/images/ticket_sources/facebook.png +0 -0
  342. package/public/images/ticket_sources/hand.png +0 -0
  343. package/public/images/ticket_sources/instagram.png +0 -0
  344. package/public/images/ticket_sources/livechat.png +0 -0
  345. package/public/images/ticket_sources/shopee.svg +1 -0
  346. package/public/images/ticket_sources/sms.png +0 -0
  347. package/public/images/ticket_sources/telephone-call-in.png +0 -0
  348. package/public/images/ticket_sources/telephone-call-out.png +0 -0
  349. package/public/images/ticket_sources/tiktok.png +0 -0
  350. package/public/images/ticket_sources/tiktok_shop.png +0 -0
  351. package/public/images/ticket_sources/whatsapp.png +0 -0
  352. package/public/images/ticket_sources/whatsapp.svg +1 -0
  353. package/public/images/ticket_sources/zalo.png +0 -0
  354. package/public/placeholder.svg +13 -0
  355. package/store/app-status-store.js +17 -0
  356. package/store/chat-display-config-store.js +182 -0
  357. package/store/chat-display-config.resolvers.js +88 -0
  358. package/store/chat-store-helpers.js +62 -0
  359. package/store/chat-store.js +931 -0
  360. package/store/crm-organization-list-filter-store.js +126 -0
  361. package/store/customer-list-filter-store.js +139 -0
  362. package/store/devtools.js +9 -0
  363. package/store/duplicate-phone-warning-store.js +18 -0
  364. package/store/entity-extract-store.js +72 -0
  365. package/store/file-preview-store.js +27 -0
  366. package/store/filter-store.js +289 -0
  367. package/store/index.js +22 -0
  368. package/store/knowledge-crawl-store.js +53 -0
  369. package/store/lead-list-filter-store.js +142 -0
  370. package/store/list-pagination-state.js +44 -0
  371. package/store/lumi-learn-from-chat-store.js +69 -0
  372. package/store/merge-suggestion-store.js +27 -0
  373. package/store/notification-store.js +63 -0
  374. package/store/preview-image-store.js +22 -0
  375. package/store/settings-store/multi-channel/email-list-store.js +20 -0
  376. package/store/settings-store/multi-channel/facebook-list-store.js +22 -0
  377. package/store/settings-store/multi-channel/google-list-store.js +20 -0
  378. package/store/settings-store/multi-channel/instagram-list-store.js +20 -0
  379. package/store/settings-store/multi-channel/misa-list-store.js +20 -0
  380. package/store/settings-store/multi-channel/nhanhvn-list-store.js +20 -0
  381. package/store/settings-store/multi-channel/shopee-list-store.js +20 -0
  382. package/store/settings-store/multi-channel/shopee-order-list-store.js +20 -0
  383. package/store/settings-store/multi-channel/sms-list-store.js +20 -0
  384. package/store/settings-store/multi-channel/tiktok-business-list-store.js +20 -0
  385. package/store/settings-store/multi-channel/tiktok-list-store.js +20 -0
  386. package/store/settings-store/multi-channel/zalo-list-store.js +22 -0
  387. package/store/settings-store/multi-channel/zalo-user-list-store.js +25 -0
  388. package/store/smart-qc-store/smart-qc-list-filter-store.js +70 -0
  389. package/store/tenant-config-store.js +21 -0
  390. package/store/user-detail-store.js +17 -0
  391. package/store/user-status-store.js +33 -0
  392. package/store/workflow-store.js +24 -0
  393. package/store/workspace-store.js +32 -0
  394. package/tailwind-preset.js +129 -0
  395. package/utils/chat-actions.js +414 -0
  396. package/utils/chat_socket.js +1225 -0
  397. package/utils/extra-columns.js +108 -0
  398. package/utils/file.js +316 -0
  399. package/utils/html-to-plain-text.js +12 -0
  400. package/utils/notification.js +71 -0
  401. package/utils/replaceZaloSprite.js +64 -0
  402. package/utils/show-be-error.js +17 -0
  403. package/utils/typing_socket.js +101 -0
@@ -0,0 +1,2099 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import {
3
+ User,
4
+ Bot,
5
+ AlarmClock,
6
+ Send,
7
+ CircleAlert,
8
+ ExternalLink,
9
+ ImageIcon,
10
+ MapPin,
11
+ Eye,
12
+ EyeOff,
13
+ Forward,
14
+ Check,
15
+ Copy
16
+ } from "lucide-react";
17
+ import { cn } from "../../../lib/utils.js";
18
+ import { Avatar, AvatarFallback, AvatarImage } from "../../custom/avatar.js";
19
+ import { AudioPlayer } from "../../custom/audio-player.js";
20
+ import { Skeleton } from "../../ui/skeleton.js";
21
+ import { LinkPreview } from "../../custom/previews/link-preview.js";
22
+ import { FilePreview } from "../../custom/previews/file-preview.js";
23
+ import { ImagePreview } from "../../custom/previews/image-preview.js";
24
+ import {
25
+ FacebookPostPreview,
26
+ FacebookReelPreview,
27
+ FacebookEventPreview,
28
+ FacebookGroupPreview,
29
+ FacebookPagePreview,
30
+ FacebookStickerPreview,
31
+ FacebookImagePreview,
32
+ FacebookFilePreview,
33
+ FacebookAppointmentBookingPreview,
34
+ FacebookVideoPreview,
35
+ FacebookAudioPreview
36
+ } from "../../custom/previews/facebook/index.js";
37
+ import {
38
+ formatDayWithTime,
39
+ formatTime,
40
+ generateReminderTimeText
41
+ } from "@zenify-omni/chat-js/utils/date.js";
42
+ import {
43
+ MessageType,
44
+ ActionMessageTypes,
45
+ MessageTypeContext,
46
+ ReminderMessageTypes,
47
+ PinMessageTypes
48
+ } from "@zenify-omni/chat-js/constants/chat-message.js";
49
+ import { getUser } from "@zenify-omni/chat-js/utils/auth.js";
50
+ import { TextContent } from "./text-content.js";
51
+ import ProductPreview from "../../custom/previews/product-preview.js";
52
+ import TiktokProductPreview from "../../custom/previews/tiktok-product-preview.js";
53
+ import TiktokOrderPreview from "../../custom/previews/tiktok-order-preview.js";
54
+ import TiktokVoucherPreview from "../../custom/previews/tiktok-voucher-preview.js";
55
+ import { parseMessageUrl, withMentionsHighlighted } from "@zenify-omni/chat-js/utils/string.js";
56
+ import { maskData } from "@zenify-omni/chat-js/utils/data.js";
57
+ import { isImageFile, getVideoMimeType, isVideoFile } from "../../../utils/file.js";
58
+ import { CHATTER_TYPES } from "./constants.js";
59
+ import { convertURLsToLinks } from "@zenify-omni/chat-js/utils/string.js";
60
+ import SafeHTML from "../../custom/SafeHTML.js";
61
+ import { ZaloReminderContent } from "./zalo-reminder/zalo-reminder-content.js";
62
+ import ZaloContactCardContent from "./contact-card/index.js";
63
+ import {
64
+ isZalo,
65
+ isTiktok,
66
+ isZaloGeneralChannel,
67
+ isZaloGroup,
68
+ isZaloPersonal,
69
+ isZaloPersonChannel,
70
+ isFacebook
71
+ } from "../util.js";
72
+ import useChatStore from "../../../store/chat-store.js";
73
+ import { parseMessageUrls } from "@zenify-omni/chat-js/utils/string.js";
74
+ import { FriendRequestCard } from "../chat-list/friend-request/list-friend-request.js";
75
+ import { useMutation, useQuery } from "@tanstack/react-query";
76
+ import QUERY_KEY from "@zenify-omni/chat-js/constants/use-query-key.js";
77
+ import { BrandColor } from "../../../constants/brand-colors.js";
78
+ import {
79
+ fetchMicrolinkPreview,
80
+ LINK_PREVIEW_QUERY_OPTIONS
81
+ } from "@zenify-omni/chat-js/utils/microlink.js";
82
+ import { acceptFriendRequest, rejectFriendRequest } from "@zenify-omni/chat-js/api/chat.js";
83
+ import { showSuccessToast } from "../../ui/sonner.js";
84
+ import { throwException } from "../../../exceptions/throw-exception.js";
85
+ import { memo, useCallback, useMemo, useState } from "react";
86
+ import { MessageContext } from "./message-viewers.js";
87
+ import { sendMessage } from "../../../utils/chat_socket.js";
88
+ import ReactionPreview from "./react-message/react-preview.js";
89
+ import { ChatMessageActions, IsMessageAction } from "./chat-message-action.js";
90
+ import ReactionButton from "./react-message/reaction-button.js";
91
+ import { MessageTime } from "./message-time.js";
92
+ import AdsContextCard from "./ads-context-card.js";
93
+ import {
94
+ WhatsAppContactCardPreview,
95
+ WhatsAppOrderPreview,
96
+ WhatsAppPollPreview,
97
+ WhatsAppProductPreview
98
+ } from "../../custom/previews/whatsapp/index.js";
99
+ import { InstagramSharePostPreview } from "../../custom/previews/instagram/index.js";
100
+ import {
101
+ Carousel,
102
+ CarouselContent,
103
+ CarouselItem,
104
+ CarouselPrevious,
105
+ CarouselNext
106
+ } from "../../ui/carousel.js";
107
+ import { useTranslation } from "react-i18next";
108
+ import i18n from "@zenify-omni/chat-js/lib/i18n/index.js";
109
+ import { translateServerLabel } from "@zenify-omni/chat-js/lib/i18n/server-label.js";
110
+ const isMessageFromSelf = ({ message, ticket, user, isAgent }) => {
111
+ if ((message?.source_id || message?.sub_source_id) && ticket?.source_id && (message.source_id === ticket.source_id || isZaloGroup(ticket) && message.sub_source_id === ticket.source_id && message.chatter_type === "agent")) {
112
+ return true;
113
+ }
114
+ return (!isZaloGroup(ticket) || isZaloGeneralChannel(ticket)) && isAgent || isZaloPersonChannel(ticket) && user?._id === message.chatter_id;
115
+ };
116
+ const ImageContent = ({
117
+ msg,
118
+ className,
119
+ isZalo: isZalo2,
120
+ isTiktok: isTiktok2,
121
+ isChatAllowed,
122
+ ticket,
123
+ timeText
124
+ }) => {
125
+ const user = getUser();
126
+ const isSelf = isMessageFromSelf({
127
+ message: msg,
128
+ ticket,
129
+ user,
130
+ isAgent: msg.chatter_type === CHATTER_TYPES.AGENT
131
+ });
132
+ return /* @__PURE__ */ jsx(
133
+ ImagePreview,
134
+ {
135
+ ticket,
136
+ isZalo: isZalo2,
137
+ isTiktok: isTiktok2,
138
+ isChatAllowed,
139
+ msg,
140
+ className,
141
+ url: msg.content.src,
142
+ title: formatDayWithTime(msg.date || msg.created_at),
143
+ timeText,
144
+ isMasked: !isSelf
145
+ }
146
+ );
147
+ };
148
+ const FileContent = ({ msg, className, ticket, timeText }) => {
149
+ return /* @__PURE__ */ jsx(
150
+ FilePreview,
151
+ {
152
+ msg,
153
+ ticket,
154
+ className,
155
+ url: msg.content.src,
156
+ title: formatDayWithTime(msg.date || msg.created_at),
157
+ showImage: !isZalo(ticket),
158
+ timeText
159
+ }
160
+ );
161
+ };
162
+ const ReelContent = ({ msg, className, timeText }) => {
163
+ const url = msg.content.src;
164
+ const { data: preview, isLoading: loading } = useQuery({
165
+ queryKey: [QUERY_KEY.GET_LINK_PREVIEW, url],
166
+ queryFn: () => fetchMicrolinkPreview(url),
167
+ enabled: !!url,
168
+ ...LINK_PREVIEW_QUERY_OPTIONS
169
+ });
170
+ const thumbnail = preview?.image?.url || preview?.video?.poster || null;
171
+ return /* @__PURE__ */ jsxs(
172
+ "div",
173
+ {
174
+ className: cn("w-[200px]", className),
175
+ title: formatDayWithTime(msg.date || msg.created_at),
176
+ children: [
177
+ /* @__PURE__ */ jsxs(
178
+ "a",
179
+ {
180
+ href: url,
181
+ target: "_blank",
182
+ rel: "noopener noreferrer",
183
+ className: "block overflow-hidden rounded-lg shadow-md",
184
+ children: [
185
+ /* @__PURE__ */ jsxs("div", { className: "relative aspect-[9/16] overflow-hidden bg-foreground", children: [
186
+ loading ? /* @__PURE__ */ jsx(Skeleton, { className: "h-full w-full" }) : thumbnail ? /* @__PURE__ */ jsx(
187
+ "img",
188
+ {
189
+ src: thumbnail,
190
+ alt: "Reel",
191
+ className: "h-full w-full object-cover",
192
+ referrerPolicy: "no-referrer"
193
+ }
194
+ ) : /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center bg-gradient-to-b from-gray-700 to-gray-900" }),
195
+ /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-black/40", children: /* @__PURE__ */ jsx(
196
+ "svg",
197
+ {
198
+ xmlns: "http://www.w3.org/2000/svg",
199
+ viewBox: "0 0 24 24",
200
+ fill: "white",
201
+ className: "ml-1 h-6 w-6",
202
+ children: /* @__PURE__ */ jsx("path", { d: "M8 5v14l11-7z" })
203
+ }
204
+ ) }) }),
205
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 left-2 rounded bg-black/50 px-1.5 py-0.5 text-[10px] text-white", children: "Reel" })
206
+ ] }),
207
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 bg-card p-2", children: [
208
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs text-muted-foreground", children: url }),
209
+ /* @__PURE__ */ jsx(ExternalLink, { size: 14, className: "flex-shrink-0 text-primary" })
210
+ ] })
211
+ ]
212
+ }
213
+ ),
214
+ /* @__PURE__ */ jsx(
215
+ MessageTime,
216
+ {
217
+ timeText,
218
+ status: msg?.status,
219
+ agentReads: msg?.agent_reads
220
+ }
221
+ )
222
+ ]
223
+ }
224
+ );
225
+ };
226
+ const LinkContent = ({ msg, className, isReply, timeText, ticket }) => {
227
+ const user = getUser();
228
+ const isSelf = isMessageFromSelf({
229
+ message: msg,
230
+ ticket,
231
+ user,
232
+ isAgent: msg.chatter_type === CHATTER_TYPES.AGENT
233
+ });
234
+ const bubbleClass = !isReply && (isSelf ? "border border-chat-own-bubble bg-chat-own-bubble px-4 py-2 text-accent-foreground shadow-md" : "bg-card px-4 py-2 text-foreground shadow-md");
235
+ return /* @__PURE__ */ jsx(
236
+ "div",
237
+ {
238
+ className: cn("cursor-pointer rounded-[8px]", bubbleClass, className),
239
+ title: formatDayWithTime(msg.date || msg.created_at),
240
+ children: /* @__PURE__ */ jsx(
241
+ LinkPreview,
242
+ {
243
+ url: msg.content?.text || msg.content?.src,
244
+ isReply,
245
+ isMasked: !isSelf,
246
+ children: /* @__PURE__ */ jsx(
247
+ MessageTime,
248
+ {
249
+ timeText,
250
+ status: msg?.status,
251
+ className: "justify-start",
252
+ agentReads: msg?.agent_reads
253
+ }
254
+ )
255
+ }
256
+ )
257
+ }
258
+ );
259
+ };
260
+ const VideoContent = ({ msg, className, ticket, timeText }) => {
261
+ const user = getUser();
262
+ const rawContent = msg?.content?.meta?.content;
263
+ let link = rawContent?.href || msg?.content.src;
264
+ const { afterText } = parseMessageUrl(link);
265
+ if (afterText && link.endsWith(afterText)) {
266
+ link = link.slice(0, -afterText.length);
267
+ }
268
+ const isSelf = isMessageFromSelf({
269
+ message: msg,
270
+ ticket,
271
+ user,
272
+ isAgent: msg.chatter_type === "agent"
273
+ });
274
+ return /* @__PURE__ */ jsxs(
275
+ "div",
276
+ {
277
+ className: cn("max-w-[360px]", className),
278
+ title: formatDayWithTime(msg.date || msg.created_at),
279
+ children: [
280
+ /* @__PURE__ */ jsx(
281
+ "div",
282
+ {
283
+ className: cn(
284
+ "overflow-hidden rounded-xl shadow-md",
285
+ isSelf ? "bg-chat-own-bubble" : "bg-card"
286
+ ),
287
+ children: /* @__PURE__ */ jsx("video", { controls: true, className: "block max-h-[400px] min-h-[200px] w-full", children: /* @__PURE__ */ jsx("source", { src: link, type: getVideoMimeType(link) }) })
288
+ }
289
+ ),
290
+ /* @__PURE__ */ jsx(
291
+ MessageTime,
292
+ {
293
+ timeText,
294
+ status: msg?.status,
295
+ agentReads: msg?.agent_reads
296
+ }
297
+ )
298
+ ]
299
+ }
300
+ );
301
+ };
302
+ const AudioContent = ({ msg, className, timeText }) => /* @__PURE__ */ jsxs(
303
+ "div",
304
+ {
305
+ className: cn("w-[300px]", className),
306
+ title: formatDayWithTime(msg.date || msg.created_at),
307
+ children: [
308
+ /* @__PURE__ */ jsx(AudioPlayer, { src: msg.content.src }),
309
+ /* @__PURE__ */ jsx(
310
+ MessageTime,
311
+ {
312
+ timeText,
313
+ status: msg?.status,
314
+ agentReads: msg?.agent_reads
315
+ }
316
+ )
317
+ ]
318
+ }
319
+ );
320
+ const LocationContent = ({ msg, className, timeText }) => {
321
+ const { t } = useTranslation();
322
+ const { latitude, longitude, src } = msg?.content || {};
323
+ const lat = parseFloat(latitude);
324
+ const lng = parseFloat(longitude);
325
+ const hasCoords = Number.isFinite(lat) && Number.isFinite(lng);
326
+ const url = src || (hasCoords ? `https://www.google.com/maps?q=${lat},${lng}` : null);
327
+ if (!hasCoords && !url) {
328
+ return null;
329
+ }
330
+ const mapUrl = hasCoords ? `https://maps.google.com/maps?q=${lat},${lng}&z=15&output=embed` : null;
331
+ return /* @__PURE__ */ jsxs(
332
+ "div",
333
+ {
334
+ className: cn("w-[260px]", className),
335
+ title: formatDayWithTime(msg.date || msg.created_at),
336
+ children: [
337
+ /* @__PURE__ */ jsxs(
338
+ "a",
339
+ {
340
+ href: url,
341
+ target: "_blank",
342
+ rel: "noopener noreferrer",
343
+ className: "block overflow-hidden rounded-lg bg-card shadow-md",
344
+ children: [
345
+ mapUrl && /* @__PURE__ */ jsx("div", { className: "relative aspect-[16/10] overflow-hidden bg-muted", children: /* @__PURE__ */ jsx(
346
+ "iframe",
347
+ {
348
+ src: mapUrl,
349
+ className: "pointer-events-none h-full w-full border-0",
350
+ title: t("chat:label.locationMap", {
351
+ defaultValue: "B\u1EA3n \u0111\u1ED3 v\u1ECB tr\xED"
352
+ }),
353
+ loading: "lazy"
354
+ }
355
+ ) }),
356
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 p-2", children: [
357
+ /* @__PURE__ */ jsx(MapPin, { size: 16, className: "flex-shrink-0 text-primary" }),
358
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
359
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs font-medium text-foreground", children: t("chat:label.location", { defaultValue: "V\u1ECB tr\xED" }) }),
360
+ hasCoords && /* @__PURE__ */ jsxs("p", { className: "truncate text-[11px] text-muted-foreground", children: [
361
+ lat.toFixed(6),
362
+ ", ",
363
+ lng.toFixed(6)
364
+ ] })
365
+ ] }),
366
+ /* @__PURE__ */ jsx(ExternalLink, { size: 14, className: "flex-shrink-0 text-primary" })
367
+ ] })
368
+ ]
369
+ }
370
+ ),
371
+ /* @__PURE__ */ jsx(
372
+ MessageTime,
373
+ {
374
+ timeText,
375
+ status: msg?.status,
376
+ agentReads: msg?.agent_reads
377
+ }
378
+ )
379
+ ]
380
+ }
381
+ );
382
+ };
383
+ const UnsupportedContent = ({ msg, className, timeText }) => {
384
+ const { t } = useTranslation();
385
+ return /* @__PURE__ */ jsxs(
386
+ "div",
387
+ {
388
+ className: cn(
389
+ "w-full break-words rounded-[0_8px_8px_8px] bg-muted px-4 py-2 italic text-muted-foreground shadow-md",
390
+ className
391
+ ),
392
+ title: formatDayWithTime(msg.date || msg.created_at),
393
+ children: [
394
+ t("chat:message.unsupportedMessage", {
395
+ defaultValue: "Tin nh\u1EAFn ch\u01B0a \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3"
396
+ }),
397
+ /* @__PURE__ */ jsx(
398
+ MessageTime,
399
+ {
400
+ timeText,
401
+ status: msg?.status,
402
+ className: "not-italic",
403
+ agentReads: msg?.agent_reads,
404
+ messageId: msg?._id
405
+ }
406
+ )
407
+ ]
408
+ }
409
+ );
410
+ };
411
+ const ForwardContent = ({ msg, className, timeText }) => {
412
+ const { t } = useTranslation();
413
+ const original = msg.content?.original;
414
+ const caption = msg.content?.text;
415
+ const renderOriginalPreview = () => {
416
+ if (!original)
417
+ return /* @__PURE__ */ jsx("span", { className: "text-xs italic text-muted-foreground", children: t("chat:status.forwardedMessage", {
418
+ defaultValue: "Tin nh\u1EAFn \u0111\xE3 chuy\u1EC3n ti\u1EBFp"
419
+ }) });
420
+ switch (original.type) {
421
+ case "image":
422
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
423
+ original.src && /* @__PURE__ */ jsx(
424
+ "img",
425
+ {
426
+ src: original.src.split(" \n ")[0],
427
+ className: "h-10 w-10 flex-shrink-0 rounded object-cover",
428
+ alt: ""
429
+ }
430
+ ),
431
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: original.text || i18n.t("chat:message.imageBracket", {
432
+ defaultValue: "[H\xECnh \u1EA3nh]"
433
+ }) })
434
+ ] });
435
+ case "video":
436
+ return /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
437
+ "[Video] ",
438
+ original.filename || original.text || ""
439
+ ] });
440
+ case "audio":
441
+ return /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
442
+ "[Audio] ",
443
+ original.filename || ""
444
+ ] });
445
+ case "file":
446
+ return /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
447
+ "[File] ",
448
+ original.filename || original.text || ""
449
+ ] });
450
+ case "sticker":
451
+ return /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "[Sticker]" });
452
+ default:
453
+ return /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: original.text || i18n.t("chat:message.messageBracket", {
454
+ defaultValue: "[Tin nh\u1EAFn]"
455
+ }) });
456
+ }
457
+ };
458
+ return /* @__PURE__ */ jsxs(
459
+ "div",
460
+ {
461
+ className: cn(
462
+ "break-words rounded-[0_8px_8px_8px] px-3 py-2 shadow-md",
463
+ className
464
+ ),
465
+ title: formatDayWithTime(msg.date || msg.created_at),
466
+ children: [
467
+ /* @__PURE__ */ jsxs("div", { className: "mb-1.5 flex items-center gap-1 border-l-2 border-primary pl-2", children: [
468
+ /* @__PURE__ */ jsx(Forward, { size: 12, className: "flex-shrink-0 text-primary" }),
469
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-primary", children: t("chat:status.forwardedMessage", {
470
+ defaultValue: "Tin nh\u1EAFn \u0111\xE3 chuy\u1EC3n ti\u1EBFp"
471
+ }) })
472
+ ] }),
473
+ /* @__PURE__ */ jsx("div", { className: "mb-1.5 rounded bg-black/5 px-2 py-1.5", children: renderOriginalPreview() }),
474
+ caption && /* @__PURE__ */ jsx("p", { className: "text-sm", children: caption }),
475
+ /* @__PURE__ */ jsx(
476
+ MessageTime,
477
+ {
478
+ timeText,
479
+ status: msg?.status,
480
+ agentReads: msg?.agent_reads
481
+ }
482
+ )
483
+ ]
484
+ }
485
+ );
486
+ };
487
+ const getContentObj = (msg) => {
488
+ if (!msg?.content?.meta?.content_obj) return null;
489
+ return msg.content.meta.content_obj;
490
+ };
491
+ const FriendEventContent = ({ msg, className, ticket, timeText }) => {
492
+ const user = getUser();
493
+ const contentObj = getContentObj(msg);
494
+ const friendRequest = useMemo(() => {
495
+ if (!contentObj) return null;
496
+ if (contentObj.zalo_id) {
497
+ return contentObj;
498
+ }
499
+ if (Array.isArray(contentObj.received) && contentObj.received.length > 0) {
500
+ return contentObj.received[0];
501
+ }
502
+ if (Array.isArray(contentObj) && contentObj.length > 0) {
503
+ return contentObj[0];
504
+ }
505
+ return null;
506
+ }, [contentObj]);
507
+ const acceptMutate = useMutation({
508
+ mutationFn: async ({ zaloId, parentZaloId }) => {
509
+ const { data } = await acceptFriendRequest(
510
+ user?._id,
511
+ zaloId,
512
+ parentZaloId
513
+ );
514
+ return data;
515
+ },
516
+ onSuccess: () => {
517
+ showSuccessToast(
518
+ i18n.t("chat:toast.acceptFriendRequestSuccess", {
519
+ defaultValue: "Ch\u1EA5p nh\u1EADn l\u1EDDi m\u1EDDi k\u1EBFt b\u1EA1n th\xE0nh c\xF4ng"
520
+ })
521
+ );
522
+ },
523
+ onError: throwException
524
+ });
525
+ const rejectMutate = useMutation({
526
+ mutationFn: async ({ zaloId, parentZaloId }) => {
527
+ const { data } = await rejectFriendRequest(
528
+ user?._id,
529
+ zaloId,
530
+ parentZaloId
531
+ );
532
+ return data;
533
+ },
534
+ onSuccess: () => {
535
+ showSuccessToast(
536
+ i18n.t("chat:toast.rejectFriendRequestSuccess", {
537
+ defaultValue: "T\u1EEB ch\u1ED1i l\u1EDDi m\u1EDDi k\u1EBFt b\u1EA1n th\xE0nh c\xF4ng"
538
+ })
539
+ );
540
+ },
541
+ onError: throwException
542
+ });
543
+ const handleAccept = useCallback(
544
+ (zaloId) => {
545
+ let parentZaloId = null;
546
+ parentZaloId = ticket?.source_id || null;
547
+ acceptMutate.mutate({ zaloId, parentZaloId });
548
+ },
549
+ [ticket?.pzalo_type, ticket?.page_id, ticket?.source_id, acceptMutate]
550
+ );
551
+ const handleReject = useCallback(
552
+ (zaloId) => {
553
+ let parentZaloId = null;
554
+ parentZaloId = ticket?.source_id || null;
555
+ rejectMutate.mutate({ zaloId, parentZaloId });
556
+ },
557
+ [ticket?.pzalo_type, ticket?.page_id, ticket?.source_id, rejectMutate]
558
+ );
559
+ return /* @__PURE__ */ jsxs(
560
+ "div",
561
+ {
562
+ className: cn(
563
+ "w-full rounded-[8px] bg-card px-4 py-2 shadow-md",
564
+ className
565
+ ),
566
+ title: formatDayWithTime(msg.date || msg.created_at),
567
+ children: [
568
+ friendRequest && /* @__PURE__ */ jsx(
569
+ FriendRequestCard,
570
+ {
571
+ data: friendRequest,
572
+ type: "received",
573
+ onAccept: handleAccept,
574
+ onReject: handleReject
575
+ }
576
+ ),
577
+ /* @__PURE__ */ jsx(
578
+ MessageTime,
579
+ {
580
+ timeText,
581
+ status: msg?.status,
582
+ agentReads: msg?.agent_reads
583
+ }
584
+ )
585
+ ]
586
+ }
587
+ );
588
+ };
589
+ const ChatFormContent = ({
590
+ msg,
591
+ className,
592
+ ticket,
593
+ isChatAllowed,
594
+ timeText
595
+ }) => {
596
+ const isAgent = useMemo(() => {
597
+ return msg?.chatter_type === "agent" || msg?.chatter_type === "chatbot";
598
+ }, [msg?.chatter_type]);
599
+ const greeting = useMemo(() => {
600
+ return msg?.content?.text || "";
601
+ }, [msg?.content?.text]);
602
+ const buttons = useMemo(() => {
603
+ return msg?.content?.buttons;
604
+ }, [msg?.content?.buttons]);
605
+ const options = useMemo(() => {
606
+ if (!buttons) return [];
607
+ if (Array.isArray(buttons)) {
608
+ return buttons;
609
+ }
610
+ return [];
611
+ }, [buttons]);
612
+ const handleOptionClick = useCallback(
613
+ (optionValue, optionLabel) => {
614
+ if (!isChatAllowed || !ticket) return;
615
+ const messageText = optionValue || optionLabel;
616
+ sendMessage(ticket, messageText, MessageType.TEXT, {
617
+ is_personal_zalo: ticket?.is_personal_zalo
618
+ });
619
+ },
620
+ [ticket, isChatAllowed]
621
+ );
622
+ if (!isAgent) {
623
+ return null;
624
+ }
625
+ if (!buttons || !Array.isArray(buttons) || buttons.length === 0) {
626
+ return null;
627
+ }
628
+ if (!greeting && (!options || options.length === 0)) {
629
+ return null;
630
+ }
631
+ return /* @__PURE__ */ jsxs(
632
+ "div",
633
+ {
634
+ className: cn(
635
+ "w-full rounded-[8px] bg-card px-4 py-3 shadow-md",
636
+ className
637
+ ),
638
+ title: formatDayWithTime(msg.date || msg.created_at),
639
+ children: [
640
+ greeting && /* @__PURE__ */ jsx("div", { className: "mb-3 text-sm text-foreground", children: greeting }),
641
+ options && options.length > 0 && /* @__PURE__ */ jsx("div", { className: "space-y-0", children: options.map((option, index) => {
642
+ const optionValue = option?.value || option?.text;
643
+ const optionLabel = option?.label || option?.text || option;
644
+ if (!optionLabel) return null;
645
+ return /* @__PURE__ */ jsxs("div", { children: [
646
+ index > 0 && /* @__PURE__ */ jsx("div", { className: "my-2 border-t border-border-subtle" }),
647
+ /* @__PURE__ */ jsxs(
648
+ "button",
649
+ {
650
+ onClick: () => handleOptionClick(optionValue, optionLabel),
651
+ disabled: !isChatAllowed,
652
+ className: cn(
653
+ "flex w-full items-center justify-between rounded-md bg-muted px-3 py-2 text-left text-sm text-foreground transition-colors",
654
+ isChatAllowed ? "cursor-pointer hover:bg-muted hover:text-primary" : "cursor-not-allowed opacity-50"
655
+ ),
656
+ children: [
657
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: optionLabel }),
658
+ /* @__PURE__ */ jsx(
659
+ Send,
660
+ {
661
+ size: 16,
662
+ className: cn(
663
+ "ml-2 flex-shrink-0",
664
+ isChatAllowed ? "text-primary" : "text-muted-foreground"
665
+ )
666
+ }
667
+ )
668
+ ]
669
+ }
670
+ )
671
+ ] }, index);
672
+ }) }),
673
+ /* @__PURE__ */ jsx(
674
+ MessageTime,
675
+ {
676
+ timeText,
677
+ status: msg?.status,
678
+ agentReads: msg?.agent_reads
679
+ }
680
+ )
681
+ ]
682
+ }
683
+ );
684
+ };
685
+ const UtilityMessageContent = ({ msg, className, timeText }) => {
686
+ const content = msg?.content || {};
687
+ const title = content.title || content.text || "";
688
+ const body = content.subtitle || content.body || "";
689
+ const buttons = Array.isArray(content.buttons) ? content.buttons : [];
690
+ const imageUrl = content.media_url || null;
691
+ const isFailed = msg?.status === "failed";
692
+ const errorMessage = translateServerLabel(msg?.extra_data?.send_error?.message) || translateServerLabel(msg?.extra_data?.send_error?.exception_message) || i18n.t("chat:label.failedToSendMessage", {
693
+ defaultValue: "G\u1EEDi tin nh\u1EAFn th\u1EA5t b\u1EA1i"
694
+ });
695
+ return /* @__PURE__ */ jsxs(
696
+ "div",
697
+ {
698
+ className: cn("w-[320px]", className),
699
+ title: formatDayWithTime(msg.date || msg.created_at),
700
+ children: [
701
+ /* @__PURE__ */ jsxs(
702
+ "div",
703
+ {
704
+ className: cn(
705
+ "overflow-hidden rounded-xl shadow-md",
706
+ isFailed ? "bg-destructive/10" : "bg-muted"
707
+ ),
708
+ children: [
709
+ imageUrl && /* @__PURE__ */ jsx(
710
+ "img",
711
+ {
712
+ src: imageUrl,
713
+ alt: "",
714
+ className: "h-[150px] w-full object-cover",
715
+ referrerPolicy: "no-referrer"
716
+ }
717
+ ),
718
+ (title || body) && /* @__PURE__ */ jsxs("div", { className: cn("px-4 py-3", isFailed ? "bg-[--label-red]" : "bg-card"), children: [
719
+ title && /* @__PURE__ */ jsx("p", { className: "text-[15px] font-bold text-foreground", children: title }),
720
+ body && /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: body })
721
+ ] }),
722
+ buttons.length > 0 && /* @__PURE__ */ jsx("div", { className: "border-t border-border-subtle py-1", children: buttons.map((btn, index) => {
723
+ const label = btn.title || btn.text || btn.label || "";
724
+ const url = btn.url || btn.href || null;
725
+ const phone = btn.phone_number || btn.phone || null;
726
+ const btnContent = /* @__PURE__ */ jsx(
727
+ "div",
728
+ {
729
+ className: cn(
730
+ "flex items-center justify-center rounded-md py-2 text-center text-[15px] font-semibold",
731
+ index > 0 && "border-t border-border-subtle",
732
+ isFailed ? "bg-[--label-red] text-muted-foreground" : "bg-card text-foreground",
733
+ !isFailed && (url || phone) && "cursor-pointer hover:bg-muted"
734
+ ),
735
+ children: label
736
+ },
737
+ index
738
+ );
739
+ if (!isFailed && url) {
740
+ return /* @__PURE__ */ jsx(
741
+ "a",
742
+ {
743
+ href: url,
744
+ target: "_blank",
745
+ className: "block p-2",
746
+ rel: "noopener noreferrer",
747
+ children: btnContent
748
+ },
749
+ index
750
+ );
751
+ }
752
+ if (!isFailed && phone) {
753
+ return /* @__PURE__ */ jsx("a", { href: `tel:${phone}`, className: "block p-2", children: btnContent }, index);
754
+ }
755
+ return /* @__PURE__ */ jsx("div", { className: "px-2 py-1", children: btnContent }, index);
756
+ }) }),
757
+ isFailed && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 border-t border-destructive/30 bg-[--label-red] px-3 py-2", children: [
758
+ /* @__PURE__ */ jsx(CircleAlert, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive" }),
759
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: errorMessage })
760
+ ] })
761
+ ]
762
+ }
763
+ ),
764
+ /* @__PURE__ */ jsx(
765
+ MessageTime,
766
+ {
767
+ timeText,
768
+ status: msg?.status,
769
+ agentReads: msg?.agent_reads
770
+ }
771
+ )
772
+ ]
773
+ }
774
+ );
775
+ };
776
+ const ORDER_STATUS_LABELS = {
777
+ UNPAID: {
778
+ get label() {
779
+ return i18n.t("chat:label.awaitingPayment", {
780
+ defaultValue: "Ch\u1EDD thanh to\xE1n"
781
+ });
782
+ },
783
+ color: "text-warning"
784
+ },
785
+ READY_TO_SHIP: {
786
+ get label() {
787
+ return i18n.t("chat:label.awaitingPickup", {
788
+ defaultValue: "Ch\u1EDD l\u1EA5y h\xE0ng"
789
+ });
790
+ },
791
+ color: "text-primary"
792
+ },
793
+ SHIPPED: {
794
+ get label() {
795
+ return i18n.t("chat:label.delivering", {
796
+ defaultValue: "\u0110ang giao"
797
+ });
798
+ },
799
+ color: "text-primary"
800
+ },
801
+ CANCELLED: {
802
+ get label() {
803
+ return i18n.t("common:status.cancelled", {
804
+ defaultValue: "\u0110\xE3 h\u1EE7y"
805
+ });
806
+ },
807
+ color: "text-destructive"
808
+ },
809
+ TO_RETURN: {
810
+ get label() {
811
+ return i18n.t("chat:label.returnRefund", {
812
+ defaultValue: "Tr\u1EA3 h\xE0ng Ho\xE0n ti\u1EC1n"
813
+ });
814
+ },
815
+ color: "text-destructive"
816
+ },
817
+ COMPLETED: {
818
+ get label() {
819
+ return i18n.t("common:status.finished", {
820
+ defaultValue: "Ho\xE0n th\xE0nh"
821
+ });
822
+ },
823
+ color: "text-success"
824
+ },
825
+ IN_CANCEL: {
826
+ get label() {
827
+ return i18n.t("chat:label.canceling", {
828
+ defaultValue: "\u0110ang h\u1EE7y"
829
+ });
830
+ },
831
+ color: "text-muted-foreground"
832
+ }
833
+ };
834
+ const formatVND = (amount) => Number(amount).toLocaleString("vi-VN") + " \u20AB";
835
+ const formatOrderDate = (unixTs) => {
836
+ const d = new Date(unixTs * 1e3);
837
+ const hh = d.getHours().toString().padStart(2, "0");
838
+ const mm = d.getMinutes().toString().padStart(2, "0");
839
+ const dd = d.getDate().toString().padStart(2, "0");
840
+ const mo = (d.getMonth() + 1).toString().padStart(2, "0");
841
+ const yy = d.getFullYear();
842
+ return `${hh}:${mm} ${dd}-${mo}-${yy}`;
843
+ };
844
+ const OrderContent = ({ msg, className, timeText }) => {
845
+ const { t } = useTranslation();
846
+ const order = msg?.extra_data?.order;
847
+ const [copied, setCopied] = useState(false);
848
+ if (!order) return null;
849
+ const {
850
+ order_sn,
851
+ order_status,
852
+ total_amount,
853
+ create_time,
854
+ ship_by_date,
855
+ buyer_username,
856
+ shipping_carrier,
857
+ actual_shipping_fee,
858
+ items = []
859
+ } = order;
860
+ const statusInfo = ORDER_STATUS_LABELS[order_status] || {
861
+ label: order_status,
862
+ color: "text-muted-foreground"
863
+ };
864
+ const firstItem = items[0];
865
+ const handleCopy = () => {
866
+ navigator.clipboard.writeText(order_sn);
867
+ setCopied(true);
868
+ setTimeout(() => setCopied(false), 2e3);
869
+ };
870
+ return /* @__PURE__ */ jsxs(
871
+ "div",
872
+ {
873
+ className: cn("w-[300px]", className),
874
+ title: formatDayWithTime(msg.date || msg.created_at),
875
+ children: [
876
+ /* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-xl bg-card shadow-md", children: [
877
+ /* @__PURE__ */ jsx("div", { className: "px-3 pb-2 pt-3", children: /* @__PURE__ */ jsx("p", { className: "text-xs font-normal text-muted-foreground", children: t("chat:message.askingAboutOrder", {
878
+ defaultValue: "B\u1EA1n \u0111ang h\u1ECFi th\xF4ng tin v\u1EC1 \u0111\u01A1n h\xE0ng..."
879
+ }) }) }),
880
+ firstItem && /* @__PURE__ */ jsxs("div", { className: "mx-3 mb-3 flex gap-3 rounded-lg border border-border-subtle p-2", children: [
881
+ firstItem.image_url && /* @__PURE__ */ jsx(
882
+ "img",
883
+ {
884
+ src: firstItem.image_url,
885
+ alt: firstItem.item_name,
886
+ className: "h-[72px] w-[72px] flex-shrink-0 rounded object-cover",
887
+ referrerPolicy: "no-referrer"
888
+ }
889
+ ),
890
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
891
+ /* @__PURE__ */ jsx("p", { className: "line-clamp-1 text-sm font-medium text-foreground", children: firstItem.item_name }),
892
+ /* @__PURE__ */ jsxs("p", { className: "mt-0.5 line-clamp-1 text-xs text-muted-foreground", children: [
893
+ items.length,
894
+ " ",
895
+ t("chat:label.productsTotalOrderValue", {
896
+ defaultValue: "s\u1EA3n ph\u1EA9m, T\u1ED5ng \u0111\u01A1n h\xE0ng"
897
+ }),
898
+ " ",
899
+ formatVND(total_amount)
900
+ ] }),
901
+ /* @__PURE__ */ jsx("p", { className: cn("mt-1.5 text-sm font-medium", statusInfo.color), children: statusInfo.label })
902
+ ] })
903
+ ] }),
904
+ /* @__PURE__ */ jsxs("div", { className: "divide-y divide-border-subtle border-t border-border-subtle", children: [
905
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-2", children: [
906
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("common:label.orderCode", { defaultValue: "M\xE3 \u0111\u01A1n h\xE0ng" }) }),
907
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
908
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-foreground", children: order_sn.length > 12 ? `${order_sn.slice(0, 12)}...` : order_sn }),
909
+ /* @__PURE__ */ jsx(
910
+ "button",
911
+ {
912
+ onClick: handleCopy,
913
+ className: "flex-shrink-0 text-muted-foreground hover:text-primary",
914
+ children: copied ? /* @__PURE__ */ jsx(Check, { size: 13 }) : /* @__PURE__ */ jsx(Copy, { size: 13 })
915
+ }
916
+ )
917
+ ] })
918
+ ] }),
919
+ create_time && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-2", children: [
920
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("chat:label.orderTime", {
921
+ defaultValue: "Th\u1EDDi gian \u0111\u1EB7t h\xE0ng"
922
+ }) }),
923
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-foreground", children: formatOrderDate(create_time) })
924
+ ] }),
925
+ ship_by_date && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-2", children: [
926
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("chat:label.deliverBefore", { defaultValue: "Giao tr\u01B0\u1EDBc" }) }),
927
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-foreground", children: formatOrderDate(ship_by_date) })
928
+ ] }),
929
+ total_amount && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-2", children: [
930
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("chat:label.orderValue", {
931
+ defaultValue: "Gi\xE1 tr\u1ECB \u0111\u01A1n h\xE0ng"
932
+ }) }),
933
+ /* @__PURE__ */ jsx(
934
+ "span",
935
+ {
936
+ className: "text-xs font-semibold",
937
+ style: { color: BrandColor.shopee.fg },
938
+ children: formatVND(total_amount)
939
+ }
940
+ )
941
+ ] }),
942
+ buyer_username && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-2", children: [
943
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("chat:label.buyer", { defaultValue: "Ng\u01B0\u1EDDi mua" }) }),
944
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-foreground", children: buyer_username })
945
+ ] }),
946
+ shipping_carrier && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-2", children: [
947
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: t("common:label.shipping", { defaultValue: "V\u1EADn chuy\u1EC3n" }) }),
948
+ /* @__PURE__ */ jsxs("span", { className: "ml-4 line-clamp-1 text-right text-xs font-medium text-foreground", children: [
949
+ shipping_carrier,
950
+ Number(actual_shipping_fee) > 0 && ` \xB7 ${formatVND(actual_shipping_fee)}`
951
+ ] })
952
+ ] })
953
+ ] })
954
+ ] }),
955
+ /* @__PURE__ */ jsx(
956
+ MessageTime,
957
+ {
958
+ timeText,
959
+ status: msg?.status,
960
+ agentReads: msg?.agent_reads
961
+ }
962
+ )
963
+ ]
964
+ }
965
+ );
966
+ };
967
+ const getTikTokEmbedUrls = (rawUrl) => {
968
+ try {
969
+ const match = rawUrl?.match(/\/player\/v\d+\/(\d+)/);
970
+ if (match) {
971
+ const videoId = match[1];
972
+ return {
973
+ embedUrl: `https://www.tiktok.com/embed/v2/${videoId}`,
974
+ shareUrl: `https://www.tiktok.com/video/${videoId}`
975
+ };
976
+ }
977
+ } catch {
978
+ }
979
+ return { embedUrl: rawUrl, shareUrl: rawUrl };
980
+ };
981
+ const SharePostContent = ({ msg, className, timeText }) => {
982
+ const rawUrl = msg.content?.url || msg.content?.src;
983
+ if (!rawUrl) return null;
984
+ const { embedUrl, shareUrl } = getTikTokEmbedUrls(rawUrl);
985
+ return /* @__PURE__ */ jsxs(
986
+ "div",
987
+ {
988
+ className: cn("w-[280px]", className),
989
+ title: formatDayWithTime(msg.date || msg.created_at),
990
+ children: [
991
+ /* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-xl shadow-md", children: [
992
+ /* @__PURE__ */ jsx(
993
+ "iframe",
994
+ {
995
+ src: embedUrl,
996
+ className: "block w-full",
997
+ style: { height: "498px", border: "none" },
998
+ allow: "autoplay; encrypted-media",
999
+ allowFullScreen: true,
1000
+ title: "TikTok video"
1001
+ }
1002
+ ),
1003
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 bg-card px-2 py-1.5", children: [
1004
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs text-muted-foreground", children: "TikTok" }),
1005
+ /* @__PURE__ */ jsx(
1006
+ "a",
1007
+ {
1008
+ href: shareUrl,
1009
+ target: "_blank",
1010
+ rel: "noopener noreferrer",
1011
+ className: "flex-shrink-0 text-primary",
1012
+ children: /* @__PURE__ */ jsx(ExternalLink, { size: 14 })
1013
+ }
1014
+ )
1015
+ ] })
1016
+ ] }),
1017
+ /* @__PURE__ */ jsx(
1018
+ MessageTime,
1019
+ {
1020
+ timeText,
1021
+ status: msg?.status,
1022
+ agentReads: msg?.agent_reads
1023
+ }
1024
+ )
1025
+ ]
1026
+ }
1027
+ );
1028
+ };
1029
+ const TiktokSharePostPreview = ({ msg, className, timeText }) => {
1030
+ const rawUrl = msg?.content?.src || msg?.content?.url;
1031
+ if (!rawUrl) return null;
1032
+ return /* @__PURE__ */ jsxs(
1033
+ "div",
1034
+ {
1035
+ className: cn("w-[280px]", className),
1036
+ title: formatDayWithTime(msg.date || msg.created_at),
1037
+ children: [
1038
+ /* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-xl shadow-md", children: [
1039
+ /* @__PURE__ */ jsx(
1040
+ "iframe",
1041
+ {
1042
+ src: rawUrl,
1043
+ className: "block w-full",
1044
+ style: { height: "498px", border: "none" },
1045
+ allow: "autoplay; encrypted-media",
1046
+ allowFullScreen: true,
1047
+ title: "TikTok video"
1048
+ }
1049
+ ),
1050
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 bg-card px-2 py-1.5", children: [
1051
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs text-muted-foreground", children: "TikTok" }),
1052
+ /* @__PURE__ */ jsx(
1053
+ "a",
1054
+ {
1055
+ href: rawUrl,
1056
+ target: "_blank",
1057
+ rel: "noopener noreferrer",
1058
+ className: "flex-shrink-0 text-primary",
1059
+ children: /* @__PURE__ */ jsx(ExternalLink, { size: 14 })
1060
+ }
1061
+ )
1062
+ ] })
1063
+ ] }),
1064
+ /* @__PURE__ */ jsx(MessageTime, { timeText, status: msg?.status })
1065
+ ]
1066
+ }
1067
+ );
1068
+ };
1069
+ const GenericTemplateCard = ({ el }) => /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden rounded-xl bg-card", children: [
1070
+ el.image_url && /* @__PURE__ */ jsx(
1071
+ "img",
1072
+ {
1073
+ src: el.image_url,
1074
+ alt: el.title,
1075
+ className: "h-[200px] w-full object-cover",
1076
+ referrerPolicy: "no-referrer"
1077
+ }
1078
+ ),
1079
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col px-3 py-2", children: [
1080
+ el.title && /* @__PURE__ */ jsx("p", { className: "line-clamp-2 text-sm font-semibold text-foreground", children: el.title }),
1081
+ el.subtitle && /* @__PURE__ */ jsx("p", { className: "mt-1 line-clamp-3 whitespace-pre-line text-xs text-muted-foreground", children: el.subtitle })
1082
+ ] }),
1083
+ Array.isArray(el.buttons) && el.buttons.length > 0 && /* @__PURE__ */ jsx("div", { className: "divide-y divide-border-subtle border-t border-border-subtle", children: el.buttons.map((btn, bi) => {
1084
+ const label = btn.title || btn.text || btn.label || "";
1085
+ const url = btn.url || btn.href || null;
1086
+ const phone = btn.phone_number || btn.phone || null;
1087
+ const linkClass = "flex items-center justify-center px-3 py-2 text-center text-sm font-semibold text-primary hover:bg-surface-subtle";
1088
+ if (url)
1089
+ return /* @__PURE__ */ jsx(
1090
+ "a",
1091
+ {
1092
+ href: url,
1093
+ target: "_blank",
1094
+ rel: "noopener noreferrer",
1095
+ className: linkClass,
1096
+ children: label
1097
+ },
1098
+ bi
1099
+ );
1100
+ if (phone)
1101
+ return /* @__PURE__ */ jsx("a", { href: `tel:${phone}`, className: linkClass, children: label }, bi);
1102
+ return /* @__PURE__ */ jsx(
1103
+ "div",
1104
+ {
1105
+ className: "flex items-center justify-center px-3 py-2 text-center text-sm font-semibold text-foreground",
1106
+ children: label
1107
+ },
1108
+ bi
1109
+ );
1110
+ }) })
1111
+ ] });
1112
+ const GenericTemplateContent = ({ msg, className, timeText }) => {
1113
+ const elements = msg?.content?.elements;
1114
+ if (!Array.isArray(elements) || elements.length === 0) return null;
1115
+ if (elements.length === 1) {
1116
+ return /* @__PURE__ */ jsxs(
1117
+ "div",
1118
+ {
1119
+ className: cn("w-[300px]", className),
1120
+ title: formatDayWithTime(msg.date || msg.created_at),
1121
+ children: [
1122
+ /* @__PURE__ */ jsx(GenericTemplateCard, { el: elements[0] }),
1123
+ /* @__PURE__ */ jsx(
1124
+ MessageTime,
1125
+ {
1126
+ timeText,
1127
+ status: msg?.status,
1128
+ agentReads: msg?.agent_reads
1129
+ }
1130
+ )
1131
+ ]
1132
+ }
1133
+ );
1134
+ }
1135
+ return /* @__PURE__ */ jsxs(
1136
+ "div",
1137
+ {
1138
+ className: cn("w-[500px] px-6", className),
1139
+ title: formatDayWithTime(msg.date || msg.created_at),
1140
+ children: [
1141
+ /* @__PURE__ */ jsxs(
1142
+ Carousel,
1143
+ {
1144
+ opts: { align: "start", slidesToScroll: 1, containScroll: "trimSnaps" },
1145
+ children: [
1146
+ /* @__PURE__ */ jsx(CarouselContent, { className: "-ml-2", children: elements.map((el, i) => /* @__PURE__ */ jsx(CarouselItem, { className: "basis-[57%] pl-2", children: /* @__PURE__ */ jsx(GenericTemplateCard, { el }) }, i)) }),
1147
+ /* @__PURE__ */ jsx(CarouselPrevious, { className: "-left-5 z-10 h-9 w-9" }),
1148
+ /* @__PURE__ */ jsx(CarouselNext, { className: "-right-5 z-10 h-9 w-9" })
1149
+ ]
1150
+ }
1151
+ ),
1152
+ /* @__PURE__ */ jsx(
1153
+ MessageTime,
1154
+ {
1155
+ timeText,
1156
+ status: msg?.status,
1157
+ agentReads: msg?.agent_reads
1158
+ }
1159
+ )
1160
+ ]
1161
+ }
1162
+ );
1163
+ };
1164
+ const TemplateButtonList = ({ buttons }) => /* @__PURE__ */ jsx("div", { className: "divide-y divide-border-subtle border-t border-border-subtle", children: buttons.map((btn, bi) => {
1165
+ const label = btn.title || btn.text || btn.label || "";
1166
+ const url = btn.url || btn.href || null;
1167
+ const phone = btn.phone_number || btn.phone || null;
1168
+ const linkClass = "flex items-center justify-center px-3 py-2 text-center text-sm font-semibold text-primary hover:bg-surface-subtle";
1169
+ if (url)
1170
+ return /* @__PURE__ */ jsx(
1171
+ "a",
1172
+ {
1173
+ href: url,
1174
+ target: "_blank",
1175
+ rel: "noopener noreferrer",
1176
+ className: linkClass,
1177
+ children: label
1178
+ },
1179
+ bi
1180
+ );
1181
+ if (phone)
1182
+ return /* @__PURE__ */ jsx("a", { href: `tel:${phone}`, className: linkClass, children: label }, bi);
1183
+ return /* @__PURE__ */ jsx(
1184
+ "div",
1185
+ {
1186
+ className: "flex items-center justify-center px-3 py-2 text-center text-sm font-semibold text-foreground",
1187
+ children: label
1188
+ },
1189
+ bi
1190
+ );
1191
+ }) });
1192
+ const ButtonTemplateCard = ({ doc }) => /* @__PURE__ */ jsxs("div", { className: "flex w-[280px] flex-col overflow-hidden rounded-xl bg-card", children: [
1193
+ doc.text && /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-sm text-foreground", children: doc.text }),
1194
+ Array.isArray(doc.buttons) && doc.buttons.length > 0 && /* @__PURE__ */ jsx(TemplateButtonList, { buttons: doc.buttons })
1195
+ ] });
1196
+ const ButtonTemplateContent = ({ msg, className, timeText }) => {
1197
+ const doc = msg?.content;
1198
+ if (!doc) return null;
1199
+ return /* @__PURE__ */ jsxs(
1200
+ "div",
1201
+ {
1202
+ className: cn("w-[280px]", className),
1203
+ title: formatDayWithTime(msg.date || msg.created_at),
1204
+ children: [
1205
+ /* @__PURE__ */ jsx(ButtonTemplateCard, { doc }),
1206
+ /* @__PURE__ */ jsx(
1207
+ MessageTime,
1208
+ {
1209
+ timeText,
1210
+ status: msg?.status,
1211
+ agentReads: msg?.agent_reads
1212
+ }
1213
+ )
1214
+ ]
1215
+ }
1216
+ );
1217
+ };
1218
+ const ElementsTemplateContent = ({ msg, className, timeText }) => {
1219
+ const doc = msg?.content;
1220
+ const elements = doc?.elements;
1221
+ if (!Array.isArray(elements) || elements.length === 0) return null;
1222
+ const topTitle = doc?.title;
1223
+ const topButtons = Array.isArray(doc?.buttons) ? doc.buttons : [];
1224
+ if (elements.length === 1 && !topTitle && topButtons.length === 0) {
1225
+ return /* @__PURE__ */ jsxs(
1226
+ "div",
1227
+ {
1228
+ className: cn("w-[300px]", className),
1229
+ title: formatDayWithTime(msg.date || msg.created_at),
1230
+ children: [
1231
+ /* @__PURE__ */ jsx(GenericTemplateCard, { el: elements[0] }),
1232
+ /* @__PURE__ */ jsx(
1233
+ MessageTime,
1234
+ {
1235
+ timeText,
1236
+ status: msg?.status,
1237
+ agentReads: msg?.agent_reads
1238
+ }
1239
+ )
1240
+ ]
1241
+ }
1242
+ );
1243
+ }
1244
+ return /* @__PURE__ */ jsxs(
1245
+ "div",
1246
+ {
1247
+ className: cn("w-[500px] px-6", className),
1248
+ title: formatDayWithTime(msg.date || msg.created_at),
1249
+ children: [
1250
+ topTitle && /* @__PURE__ */ jsx("p", { className: "mb-2 text-sm font-semibold text-foreground", children: topTitle }),
1251
+ /* @__PURE__ */ jsxs(
1252
+ Carousel,
1253
+ {
1254
+ opts: { align: "start", slidesToScroll: 1, containScroll: "trimSnaps" },
1255
+ children: [
1256
+ /* @__PURE__ */ jsx(CarouselContent, { className: "-ml-2", children: elements.map((el, i) => /* @__PURE__ */ jsx(CarouselItem, { className: "basis-[57%] pl-2", children: /* @__PURE__ */ jsx(GenericTemplateCard, { el }) }, i)) }),
1257
+ /* @__PURE__ */ jsx(CarouselPrevious, { className: "-left-5 z-10 h-9 w-9" }),
1258
+ /* @__PURE__ */ jsx(CarouselNext, { className: "-right-5 z-10 h-9 w-9" })
1259
+ ]
1260
+ }
1261
+ ),
1262
+ topButtons.length > 0 && /* @__PURE__ */ jsx("div", { className: "mt-2 overflow-hidden rounded-xl bg-card", children: /* @__PURE__ */ jsx(TemplateButtonList, { buttons: topButtons }) }),
1263
+ /* @__PURE__ */ jsx(
1264
+ MessageTime,
1265
+ {
1266
+ timeText,
1267
+ status: msg?.status,
1268
+ agentReads: msg?.agent_reads
1269
+ }
1270
+ )
1271
+ ]
1272
+ }
1273
+ );
1274
+ };
1275
+ const ReceiptTemplateContent = ({ msg, className, timeText }) => {
1276
+ const doc = msg?.content;
1277
+ if (!doc) return null;
1278
+ const {
1279
+ recipient_name,
1280
+ order_number,
1281
+ currency,
1282
+ payment_method,
1283
+ address,
1284
+ summary,
1285
+ adjustments,
1286
+ elements
1287
+ } = doc;
1288
+ const money = (v) => typeof v === "number" ? `${v.toLocaleString()}${currency ? ` ${currency}` : ""}` : v;
1289
+ const addressLine = address ? [
1290
+ address.street_1,
1291
+ address.street_2,
1292
+ address.city,
1293
+ address.state,
1294
+ address.postal_code,
1295
+ address.country
1296
+ ].filter(Boolean).join(", ") : "";
1297
+ return /* @__PURE__ */ jsxs(
1298
+ "div",
1299
+ {
1300
+ className: cn("w-[320px]", className),
1301
+ title: formatDayWithTime(msg.date || msg.created_at),
1302
+ children: [
1303
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col overflow-hidden rounded-2xl border border-border-subtle bg-card shadow-sm", children: [
1304
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2 bg-surface-subtle px-4 py-3", children: [
1305
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
1306
+ /* @__PURE__ */ jsx("p", { className: "line-clamp-1 text-sm font-semibold text-foreground", children: recipient_name || "Receipt" }),
1307
+ order_number && /* @__PURE__ */ jsxs("p", { className: "mt-0.5 text-xs text-muted-foreground", children: [
1308
+ "Order #",
1309
+ order_number
1310
+ ] })
1311
+ ] }),
1312
+ payment_method && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 rounded-full bg-card px-2 py-1 text-[11px] font-medium text-muted-foreground shadow-sm", children: payment_method })
1313
+ ] }),
1314
+ Array.isArray(elements) && elements.length > 0 && /* @__PURE__ */ jsx("div", { className: "divide-y divide-border-subtle px-4", children: elements.map((el, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 py-3", children: [
1315
+ /* @__PURE__ */ jsx("div", { className: "h-11 w-11 flex-shrink-0 overflow-hidden rounded-lg bg-muted", children: el.image_url && /* @__PURE__ */ jsx(
1316
+ "img",
1317
+ {
1318
+ src: el.image_url,
1319
+ alt: "",
1320
+ className: "h-full w-full object-cover",
1321
+ referrerPolicy: "no-referrer",
1322
+ onError: (e) => {
1323
+ e.currentTarget.style.display = "none";
1324
+ }
1325
+ }
1326
+ ) }),
1327
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
1328
+ /* @__PURE__ */ jsx("p", { className: "line-clamp-1 text-[13px] font-medium text-foreground", children: el.title }),
1329
+ el.subtitle && /* @__PURE__ */ jsx("p", { className: "line-clamp-1 text-xs text-muted-foreground", children: el.subtitle }),
1330
+ el.quantity != null && /* @__PURE__ */ jsxs("p", { className: "mt-0.5 text-xs text-muted-foreground", children: [
1331
+ "Qty ",
1332
+ el.quantity
1333
+ ] })
1334
+ ] }),
1335
+ el.price != null && /* @__PURE__ */ jsx("p", { className: "flex-shrink-0 text-xs font-medium text-foreground", children: money(el.price) })
1336
+ ] }, i)) }),
1337
+ Array.isArray(adjustments) && adjustments.length > 0 && /* @__PURE__ */ jsx("div", { className: "space-y-1 border-t border-border-subtle px-4 py-2.5", children: adjustments.map((adj, i) => /* @__PURE__ */ jsxs(
1338
+ "div",
1339
+ {
1340
+ className: "flex items-center justify-between text-xs text-muted-foreground",
1341
+ children: [
1342
+ /* @__PURE__ */ jsx("span", { className: "line-clamp-1", children: adj.name }),
1343
+ /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 pl-2", children: money(adj.amount) })
1344
+ ]
1345
+ },
1346
+ i
1347
+ )) }),
1348
+ summary && /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 border-t border-border-subtle px-4 py-2.5 text-xs", children: [
1349
+ summary.subtotal != null && /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-muted-foreground", children: [
1350
+ /* @__PURE__ */ jsx("span", { children: "Subtotal" }),
1351
+ /* @__PURE__ */ jsx("span", { children: money(summary.subtotal) })
1352
+ ] }),
1353
+ summary.shipping_cost != null && /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-muted-foreground", children: [
1354
+ /* @__PURE__ */ jsx("span", { children: "Shipping" }),
1355
+ /* @__PURE__ */ jsx("span", { children: money(summary.shipping_cost) })
1356
+ ] }),
1357
+ summary.total_tax != null && /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-muted-foreground", children: [
1358
+ /* @__PURE__ */ jsx("span", { children: "Tax" }),
1359
+ /* @__PURE__ */ jsx("span", { children: money(summary.total_tax) })
1360
+ ] }),
1361
+ summary.total_cost != null && /* @__PURE__ */ jsxs("div", { className: "flex justify-between border-t border-dashed border-border-subtle pt-1.5 text-sm font-semibold text-foreground", children: [
1362
+ /* @__PURE__ */ jsx("span", { children: "Total" }),
1363
+ /* @__PURE__ */ jsx("span", { children: money(summary.total_cost) })
1364
+ ] })
1365
+ ] }),
1366
+ addressLine && /* @__PURE__ */ jsx("div", { className: "border-t border-border-subtle bg-surface-subtle px-4 py-2.5 text-xs text-muted-foreground", children: addressLine })
1367
+ ] }),
1368
+ /* @__PURE__ */ jsx(
1369
+ MessageTime,
1370
+ {
1371
+ timeText,
1372
+ status: msg?.status,
1373
+ agentReads: msg?.agent_reads
1374
+ }
1375
+ )
1376
+ ]
1377
+ }
1378
+ );
1379
+ };
1380
+ const TEMPLATE_DOC_HANDLERS = {
1381
+ [MessageType.GENERIC_TEMPLATE]: GenericTemplateContent,
1382
+ [MessageType.BUTTON_TEMPLATE]: ButtonTemplateContent,
1383
+ [MessageType.MEDIA_TEMPLATE]: ElementsTemplateContent,
1384
+ [MessageType.PRODUCT_TEMPLATE]: ElementsTemplateContent,
1385
+ [MessageType.IMAGE_GRID_TEMPLATE]: ElementsTemplateContent,
1386
+ [MessageType.RECEIPT_TEMPLATE]: ReceiptTemplateContent
1387
+ };
1388
+ const TemplateFallbackContent = ({ msg, className, timeText }) => {
1389
+ const text = msg?.content?.text;
1390
+ if (!text) return null;
1391
+ return /* @__PURE__ */ jsxs(
1392
+ "div",
1393
+ {
1394
+ className: cn(
1395
+ "max-w-[300px] rounded-xl bg-card px-3 py-2 text-sm text-foreground",
1396
+ className
1397
+ ),
1398
+ title: formatDayWithTime(msg.date || msg.created_at),
1399
+ children: [
1400
+ /* @__PURE__ */ jsx("p", { className: "whitespace-pre-line", children: text }),
1401
+ /* @__PURE__ */ jsx(
1402
+ MessageTime,
1403
+ {
1404
+ timeText,
1405
+ status: msg?.status,
1406
+ agentReads: msg?.agent_reads
1407
+ }
1408
+ )
1409
+ ]
1410
+ }
1411
+ );
1412
+ };
1413
+ const TemplateContent = ({ msg, className, timeText }) => {
1414
+ const templates = msg?.extra_data?.templates;
1415
+ if (!Array.isArray(templates) || templates.length <= 1) {
1416
+ return /* @__PURE__ */ jsx(
1417
+ TemplateFallbackContent,
1418
+ {
1419
+ msg,
1420
+ className,
1421
+ timeText
1422
+ }
1423
+ );
1424
+ }
1425
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: templates.map((doc, i) => {
1426
+ const DocHandler = TEMPLATE_DOC_HANDLERS[doc?.type] || TemplateFallbackContent;
1427
+ return /* @__PURE__ */ jsx(
1428
+ DocHandler,
1429
+ {
1430
+ msg: { ...msg, content: doc },
1431
+ className,
1432
+ timeText: i === templates.length - 1 ? timeText : ""
1433
+ },
1434
+ i
1435
+ );
1436
+ }) });
1437
+ };
1438
+ const CONTENT_HANDLERS = {
1439
+ image: ImageContent,
1440
+ images: ImageContent,
1441
+ file: FileContent,
1442
+ link: LinkContent,
1443
+ fallback: LinkContent,
1444
+ video: VideoContent,
1445
+ audio: AudioContent,
1446
+ text: TextContent,
1447
+ sticker: ImageContent,
1448
+ product: ProductPreview,
1449
+ tiktok_product: TiktokProductPreview,
1450
+ reel: ReelContent,
1451
+ unsupported: UnsupportedContent,
1452
+ contact_card: ZaloContactCardContent,
1453
+ location: LocationContent,
1454
+ friend_request: FriendEventContent,
1455
+ chat_form: ChatFormContent,
1456
+ "utility-messages": UtilityMessageContent,
1457
+ forward: ForwardContent,
1458
+ order: OrderContent,
1459
+ tiktok_order: TiktokOrderPreview,
1460
+ tiktok_voucher: TiktokVoucherPreview,
1461
+ share_post: SharePostContent,
1462
+ [MessageType.GENERIC_TEMPLATE]: GenericTemplateContent,
1463
+ [MessageType.BUTTON_TEMPLATE]: ButtonTemplateContent,
1464
+ [MessageType.MEDIA_TEMPLATE]: ElementsTemplateContent,
1465
+ [MessageType.PRODUCT_TEMPLATE]: ElementsTemplateContent,
1466
+ [MessageType.IMAGE_GRID_TEMPLATE]: ElementsTemplateContent,
1467
+ [MessageType.RECEIPT_TEMPLATE]: ReceiptTemplateContent,
1468
+ [MessageType.TEMPLATE]: TemplateContent,
1469
+ default: () => ""
1470
+ };
1471
+ const FACEBOOK_CONTENT_HANDLERS = {
1472
+ ...CONTENT_HANDLERS,
1473
+ image: FacebookImagePreview,
1474
+ images: FacebookImagePreview,
1475
+ file: FacebookFilePreview,
1476
+ share_post: FacebookPostPreview,
1477
+ reel: FacebookReelPreview,
1478
+ share_event: FacebookEventPreview,
1479
+ share_page: FacebookPagePreview,
1480
+ share_group: FacebookGroupPreview,
1481
+ sticker: FacebookStickerPreview,
1482
+ appointment_booking: FacebookAppointmentBookingPreview,
1483
+ video: FacebookVideoPreview,
1484
+ audio: FacebookAudioPreview
1485
+ };
1486
+ const INSTAGRAM_CONTENT_HANDLERS = {
1487
+ ...CONTENT_HANDLERS,
1488
+ share_post: InstagramSharePostPreview
1489
+ };
1490
+ const TIKTOK_CONTENT_HANDLERS = {
1491
+ ...CONTENT_HANDLERS,
1492
+ share_post: TiktokSharePostPreview
1493
+ };
1494
+ const WHATSAPP_CONTENT_HANDLERS = {
1495
+ ...CONTENT_HANDLERS,
1496
+ contact_card: WhatsAppContactCardPreview,
1497
+ order: WhatsAppOrderPreview,
1498
+ poll_creation: WhatsAppPollPreview,
1499
+ product: WhatsAppProductPreview
1500
+ };
1501
+ const areMessageBubblePropsEqual = (prev, next) => {
1502
+ const pm = prev.msg;
1503
+ const nm = next.msg;
1504
+ return pm._id === nm._id && pm.updated_at === nm.updated_at && pm.status === nm.status && pm.agent_reads === nm.agent_reads && pm.extra_data?.reactions === nm.extra_data?.reactions && pm.extra_data?.is_undo === nm.extra_data?.is_undo && pm.extra_data?.is_deleted === nm.extra_data?.is_deleted && prev.isChatAllowed === next.isChatAllowed && prev.requester === next.requester;
1505
+ };
1506
+ const MessageBubbleBase = ({
1507
+ msg,
1508
+ isReply = false,
1509
+ isZalo: isZalo2,
1510
+ isTiktok: isTiktok2,
1511
+ isChatAllowed,
1512
+ ...props
1513
+ }) => {
1514
+ const { t } = useTranslation();
1515
+ const [showOriginal, setShowOriginal] = useState(false);
1516
+ const isUndone = msg?.extra_data?.is_undo === true;
1517
+ const undoOriginalContent = msg?.extra_data?.undo_original?.content;
1518
+ const isDeleted = msg?.extra_data?.is_deleted === true;
1519
+ const deletedOriginalContent = msg?.extra_data?.deleted_original?.content;
1520
+ const canShowOriginal = (isUndone && !!undoOriginalContent || isDeleted && !!deletedOriginalContent) && !isReply;
1521
+ const undoByName = msg?.extra_data?.undo_by || "";
1522
+ const effectiveMsg = useMemo(() => {
1523
+ if (canShowOriginal && showOriginal) {
1524
+ const originalContent = isUndone ? undoOriginalContent : deletedOriginalContent;
1525
+ return { ...msg, content: originalContent };
1526
+ }
1527
+ return msg;
1528
+ }, [
1529
+ msg,
1530
+ canShowOriginal,
1531
+ showOriginal,
1532
+ isUndone,
1533
+ undoOriginalContent,
1534
+ deletedOriginalContent
1535
+ ]);
1536
+ const contentType = effectiveMsg?.content?.type || (Array.isArray(effectiveMsg?.extra_data?.products) && effectiveMsg.extra_data.products.length > 0 ? "product" : void 0);
1537
+ let ContentHandler = contentType ? CONTENT_HANDLERS[contentType] || CONTENT_HANDLERS.default : CONTENT_HANDLERS.default;
1538
+ if (effectiveMsg?.ticket_source === "facebook") {
1539
+ ContentHandler = FACEBOOK_CONTENT_HANDLERS[contentType] || CONTENT_HANDLERS.default;
1540
+ }
1541
+ if (effectiveMsg?.ticket_source === "instagram") {
1542
+ ContentHandler = INSTAGRAM_CONTENT_HANDLERS[contentType] || CONTENT_HANDLERS.default;
1543
+ }
1544
+ if (effectiveMsg?.ticket_source === "tiktok" || effectiveMsg?.ticket_source === "tiktok_shop") {
1545
+ ContentHandler = TIKTOK_CONTENT_HANDLERS[contentType] || CONTENT_HANDLERS.default;
1546
+ }
1547
+ if (effectiveMsg?.ticket_source === "whatsapp") {
1548
+ ContentHandler = WHATSAPP_CONTENT_HANDLERS[contentType] || CONTENT_HANDLERS.default;
1549
+ }
1550
+ if (contentType === "product" && effectiveMsg.extra_data.type === "tiktok-shop") {
1551
+ ContentHandler = CONTENT_HANDLERS["tiktok_product"];
1552
+ }
1553
+ if (contentType === "order" && effectiveMsg?.extra_data?.type === "tiktok-shop") {
1554
+ ContentHandler = CONTENT_HANDLERS["tiktok_order"];
1555
+ }
1556
+ if (contentType === "coupon" && effectiveMsg?.extra_data?.type === "tiktok-shop") {
1557
+ ContentHandler = CONTENT_HANDLERS["tiktok_voucher"];
1558
+ }
1559
+ if (contentType === "file") {
1560
+ const firstSrc = effectiveMsg.content?.src?.split("||")[0];
1561
+ if (firstSrc && isImageFile(firstSrc)) {
1562
+ ContentHandler = CONTENT_HANDLERS["image"];
1563
+ } else if (firstSrc && isVideoFile(firstSrc)) {
1564
+ ContentHandler = CONTENT_HANDLERS["video"];
1565
+ }
1566
+ }
1567
+ if (!ContentHandler) {
1568
+ return null;
1569
+ }
1570
+ const timeText = !isReply ? formatTime(effectiveMsg.date || effectiveMsg.created_at) : "";
1571
+ let className = "";
1572
+ switch (effectiveMsg.status) {
1573
+ case "pending":
1574
+ className += " opacity-60";
1575
+ break;
1576
+ case "failed":
1577
+ if (contentType === "product") {
1578
+ return /* @__PURE__ */ jsx(
1579
+ ContentHandler,
1580
+ {
1581
+ isZalo: isZalo2,
1582
+ isTiktok: isTiktok2,
1583
+ isChatAllowed,
1584
+ className: cn("min-w-[80px]", props.className),
1585
+ isReply,
1586
+ msg,
1587
+ ...props,
1588
+ timeText
1589
+ }
1590
+ );
1591
+ }
1592
+ if (contentType === "utility-messages") {
1593
+ return /* @__PURE__ */ jsx(
1594
+ ContentHandler,
1595
+ {
1596
+ isZalo: isZalo2,
1597
+ isTiktok: isTiktok2,
1598
+ isChatAllowed,
1599
+ className: cn("mb-2 min-w-[80px]", props.className),
1600
+ isReply,
1601
+ msg,
1602
+ ...props,
1603
+ timeText
1604
+ }
1605
+ );
1606
+ }
1607
+ return /* @__PURE__ */ jsxs("div", { className: "relative overflow-hidden rounded-xl shadow-md", children: [
1608
+ /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-0 z-10 bg-destructive/20" }),
1609
+ /* @__PURE__ */ jsx(
1610
+ ContentHandler,
1611
+ {
1612
+ isZalo: isZalo2,
1613
+ isTiktok: isTiktok2,
1614
+ isChatAllowed,
1615
+ className: cn("relative z-0 min-w-[80px]", props.className),
1616
+ isReply,
1617
+ msg,
1618
+ ...props,
1619
+ timeText
1620
+ }
1621
+ )
1622
+ ] });
1623
+ }
1624
+ if (!contentType) {
1625
+ return "";
1626
+ }
1627
+ const isUndoPlaceholder = canShowOriginal && !showOriginal;
1628
+ const undoToggle = canShowOriginal ? /* @__PURE__ */ jsx(
1629
+ "button",
1630
+ {
1631
+ type: "button",
1632
+ onClick: () => setShowOriginal((v) => !v),
1633
+ title: showOriginal ? t("chat:action.hideOriginalMessage", {
1634
+ defaultValue: "\u1EA8n tin nh\u1EAFn g\u1ED1c"
1635
+ }) : t("chat:action.viewOriginalMessage", {
1636
+ defaultValue: "Xem tin nh\u1EAFn g\u1ED1c"
1637
+ }),
1638
+ className: "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-primary hover:bg-secondary",
1639
+ children: showOriginal ? /* @__PURE__ */ jsx(EyeOff, { size: 20 }) : /* @__PURE__ */ jsx(Eye, { size: 20 })
1640
+ }
1641
+ ) : null;
1642
+ const handlerSupportsInlineToggle = contentType === "text";
1643
+ const renderedContent = /* @__PURE__ */ jsx(
1644
+ ContentHandler,
1645
+ {
1646
+ isZalo: isZalo2,
1647
+ isTiktok: isTiktok2,
1648
+ isChatAllowed,
1649
+ className: cn("mb-2 min-w-[80px]" + className, props.className),
1650
+ isReply,
1651
+ msg: effectiveMsg,
1652
+ ...props,
1653
+ timeText,
1654
+ undoToggle: handlerSupportsInlineToggle ? undoToggle : void 0,
1655
+ isUndoPlaceholder: handlerSupportsInlineToggle ? isUndoPlaceholder : void 0,
1656
+ undoByName: handlerSupportsInlineToggle ? undoByName : void 0
1657
+ }
1658
+ );
1659
+ if (canShowOriginal && !handlerSupportsInlineToggle) {
1660
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-end gap-1", children: [
1661
+ /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-1.5", children: [
1662
+ renderedContent,
1663
+ undoToggle
1664
+ ] }),
1665
+ undoByName && isUndoPlaceholder && /* @__PURE__ */ jsx("span", { className: "text-[11px] italic text-muted-foreground", children: t("chat:label.performedBy", {
1666
+ undoByName,
1667
+ defaultValue: "Th\u1EF1c hi\u1EC7n b\u1EDFi: {undoByName}"
1668
+ }) })
1669
+ ] });
1670
+ }
1671
+ return renderedContent;
1672
+ };
1673
+ const MessageBubble = memo(MessageBubbleBase, areMessageBubblePropsEqual);
1674
+ const FbCommentActionMessage = ({ message }) => {
1675
+ const { t } = useTranslation();
1676
+ const comment = message.extra_data?.comment;
1677
+ const postMessage = comment?.post?.message || "";
1678
+ const postImage = comment?.post?.attachments?.data?.[0]?.media?.image?.src || "";
1679
+ const createdTime = comment?.post?.created_time ? formatDayWithTime(comment.post.created_time) : "";
1680
+ const permalinkUrl = (() => {
1681
+ try {
1682
+ const src = message.content?.src;
1683
+ if (src) {
1684
+ const parsed = JSON.parse(src);
1685
+ return parsed?.permalink_url || "";
1686
+ }
1687
+ } catch {
1688
+ }
1689
+ return "";
1690
+ })();
1691
+ return /* @__PURE__ */ jsxs("div", { className: "mx-auto my-3 flex w-[calc(100%-82px)] items-center gap-2 rounded-lg border border-border-subtle bg-card p-3 text-sm shadow-lg", children: [
1692
+ postImage && /* @__PURE__ */ jsx(
1693
+ "img",
1694
+ {
1695
+ src: postImage,
1696
+ alt: "",
1697
+ className: "h-10 w-10 shrink-0 rounded object-cover",
1698
+ referrerPolicy: "no-referrer"
1699
+ }
1700
+ ),
1701
+ !postImage && /* @__PURE__ */ jsx("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded bg-muted", children: /* @__PURE__ */ jsx(ImageIcon, { className: "h-5 w-5" }) }),
1702
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5 overflow-hidden text-foreground", children: [
1703
+ /* @__PURE__ */ jsx("span", { className: "line-clamp-1 font-medium", children: postMessage }),
1704
+ createdTime && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("chat:label.createdTimeValue", {
1705
+ createdTime,
1706
+ defaultValue: "Th\u1EDDi gian t\u1EA1o: {createdTime}"
1707
+ }) })
1708
+ ] }),
1709
+ permalinkUrl && /* @__PURE__ */ jsx(
1710
+ "a",
1711
+ {
1712
+ href: permalinkUrl,
1713
+ target: "_blank",
1714
+ rel: "noopener noreferrer",
1715
+ className: "ml-auto flex-shrink-0 text-foreground hover:text-primary",
1716
+ children: /* @__PURE__ */ jsx(ExternalLink, { size: 14 })
1717
+ }
1718
+ )
1719
+ ] });
1720
+ };
1721
+ const ActionMessage = ({ message, ...props }) => {
1722
+ const { t } = useTranslation();
1723
+ const user = getUser();
1724
+ const chatterName = message.chatter_id === user?._id ? t("chat:label.you", { defaultValue: "B\u1EA1n" }) : message.chatter_name;
1725
+ if (ReminderMessageTypes.includes(message.content?.type)) {
1726
+ return /* @__PURE__ */ jsx(ZaloReminderContent, { msg: message, ...props });
1727
+ }
1728
+ if (message.content?.type === MessageType.REMINDER_RECEIVE) {
1729
+ const { content, date } = message;
1730
+ const reminder = getContentObj(message);
1731
+ return /* @__PURE__ */ jsxs(
1732
+ "div",
1733
+ {
1734
+ className: cn(
1735
+ "mx-auto my-3 flex w-fit max-w-[50%] flex-col items-center justify-center gap-1 rounded-lg border border-warning/40 bg-[--label-orange] p-2 px-6 text-center text-sm text-[--label-orange-foreground] shadow-lg"
1736
+ ),
1737
+ children: [
1738
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-1 p-1", children: [
1739
+ /* @__PURE__ */ jsx(AlarmClock, { className: "h-4 w-4 pb-0.5" }),
1740
+ " ",
1741
+ t("chat:label.reminderPrefix", { defaultValue: "Nh\u1EAFc h\u1EB9n:" }),
1742
+ " ",
1743
+ reminder?.title || content
1744
+ ] }),
1745
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center gap-1 p-1 text-xs", children: generateReminderTimeText(reminder?.start_time || date) || formatDayWithTime(date) })
1746
+ ]
1747
+ }
1748
+ );
1749
+ }
1750
+ let text = "";
1751
+ switch (message.content.type) {
1752
+ case MessageType.ACTION_RECEIVE:
1753
+ text = t("common:message.conversationAcceptedBy", {
1754
+ name: `<strong>${chatterName}</strong>`,
1755
+ defaultValue: "{name} \u0111\xE3 ti\u1EBFp nh\u1EADn cu\u1ED9c h\u1ED9i tho\u1EA1i."
1756
+ });
1757
+ break;
1758
+ case MessageType.ACTION_JOIN:
1759
+ text = t("common:message.conversationJoinedBy", {
1760
+ name: `<strong>${chatterName}</strong>`,
1761
+ defaultValue: "{name} \u0111\xE3 tham gia cu\u1ED9c h\u1ED9i tho\u1EA1i."
1762
+ });
1763
+ break;
1764
+ case MessageType.ACTION_OPT_IN:
1765
+ text = t("common:message.conversationActionBy", {
1766
+ name: `<strong>${chatterName}</strong>`,
1767
+ action: MessageTypeContext[MessageType.ACTION_OPT_IN],
1768
+ defaultValue: "{name} \u0111\xE3 {action}"
1769
+ });
1770
+ break;
1771
+ case MessageType.ACTION_STARTED:
1772
+ text = t("common:message.conversationStartedBy", {
1773
+ name: `<strong>${maskData(String(chatterName))}</strong>`,
1774
+ defaultValue: "{name} \u0111\xE3 b\u1EAFt \u0111\u1EA7u cu\u1ED9c h\u1ED9i tho\u1EA1i."
1775
+ });
1776
+ break;
1777
+ case MessageType.ACTION_LEAVE: {
1778
+ const removedById = message.content?.removed_by_id;
1779
+ const actorName = removedById && String(removedById) === String(user?._id) ? t("chat:label.you", { defaultValue: "B\u1EA1n" }) : message.content?.removed_by_name;
1780
+ text = message.content?.removed_by_name ? t("common:message.conversationMemberRemovedBy", {
1781
+ name: `<strong>${chatterName}</strong>`,
1782
+ actor: `<strong>${actorName}</strong>`,
1783
+ defaultValue: "{actor} \u0111\xE3 x\xF3a {name} ra kh\u1ECFi \u0111o\u1EA1n chat."
1784
+ }) : t("common:message.conversationLeftBy", {
1785
+ name: `<strong>${chatterName}</strong>`,
1786
+ defaultValue: "{name} \u0111\xE3 r\u1EDDi cu\u1ED9c h\u1ED9i tho\u1EA1i."
1787
+ });
1788
+ break;
1789
+ }
1790
+ case MessageType.ACTION_END: {
1791
+ const timeValue = message?.created_at ? formatDayWithTime(message.created_at) : "";
1792
+ text = timeValue ? t("common:message.conversationClosedByAt", {
1793
+ name: `<strong>${chatterName}</strong>`,
1794
+ timeValue,
1795
+ defaultValue: "{name} \u0111\xE3 \u0111\xF3ng h\u1ED9i tho\u1EA1i n\xE0y l\xFAc <span>{timeValue}</span>."
1796
+ }) : t("common:message.conversationClosedBy", {
1797
+ name: `<strong>${chatterName}</strong>`,
1798
+ defaultValue: "{name} \u0111\xE3 \u0111\xF3ng h\u1ED9i tho\u1EA1i n\xE0y."
1799
+ });
1800
+ break;
1801
+ }
1802
+ case MessageType.ACTION_REOPEN:
1803
+ text = t("common:message.conversationReopenedBy", {
1804
+ name: `<strong>${chatterName}</strong>`,
1805
+ defaultValue: "{name} \u0111\xE3 m\u1EDF l\u1EA1i cu\u1ED9c h\u1ED9i tho\u1EA1i."
1806
+ });
1807
+ break;
1808
+ case MessageType.ACTION_TIKTOK_END_SESSION:
1809
+ text = t("common:message.tiktokEndSessionSuccess", {
1810
+ defaultValue: "\u0110\xE3 g\u1EEDi kh\u1EA3o s\xE1t m\u1EE9c \u0111\u1ED9 h\xE0i l\xF2ng \u0111\u1EBFn kh\xE1ch h\xE0ng."
1811
+ });
1812
+ break;
1813
+ case MessageType.ZALO_ACCEPT_FRIEND:
1814
+ case MessageType.ZALO_CREATE_GROUP:
1815
+ case MessageType.CHAT_SIGNAL:
1816
+ case MessageType.PIN:
1817
+ case MessageType.UN_PIN:
1818
+ text = message.content.text || message.content.src;
1819
+ break;
1820
+ }
1821
+ return /* @__PURE__ */ jsx(
1822
+ "div",
1823
+ {
1824
+ className: "my-2 text-center text-xs italic text-muted-foreground",
1825
+ title: formatDayWithTime(message.date),
1826
+ style: { whiteSpace: "pre-wrap" },
1827
+ children: /* @__PURE__ */ jsx(
1828
+ SafeHTML,
1829
+ {
1830
+ html: [MessageType.PIN, MessageType.UN_PIN].includes(message.content.type) ? text : convertURLsToLinks(text)
1831
+ }
1832
+ )
1833
+ }
1834
+ );
1835
+ };
1836
+ const ChatMessage = ({
1837
+ message,
1838
+ isChatAllowed,
1839
+ nextMessage,
1840
+ pinnedData,
1841
+ zaloAllocatedList,
1842
+ isSelectMode,
1843
+ isSelected,
1844
+ onSelect,
1845
+ ticketSource,
1846
+ ...props
1847
+ }) => {
1848
+ const isHighlighted = useChatStore(
1849
+ (s) => s.highlightMessageId === message?._id
1850
+ );
1851
+ const displayContent = useMemo(
1852
+ () => withMentionsHighlighted(message),
1853
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1854
+ [message._id, message.updated_at]
1855
+ );
1856
+ const user = getUser();
1857
+ const isAgent = message.chatter_type === "agent" || message.chatter_type === "chatbot";
1858
+ if (message.content?.type === MessageType.ACTION_COMMENT_FB) {
1859
+ return /* @__PURE__ */ jsx(FbCommentActionMessage, { message });
1860
+ }
1861
+ if (message.content?.type === "ads_content") {
1862
+ const adData = props.ticket?.extra_data?.ad_data;
1863
+ const postLinkUrl = adData?.post_id ? props.ticket?.source_id ? `https://www.facebook.com/${props.ticket.source_id}/posts/${adData.post_id}` : `https://www.facebook.com/${adData.post_id}` : void 0;
1864
+ return /* @__PURE__ */ jsx("div", { className: "my-3 flex w-full justify-end", children: /* @__PURE__ */ jsx("div", { className: "mr-[44px] w-full max-w-[420px]", children: /* @__PURE__ */ jsx(AdsContextCard, { payload: message.content, postLinkUrl }) }) });
1865
+ }
1866
+ if (ActionMessageTypes.includes(message.content?.type) || ReminderMessageTypes.includes(message.content?.type) || PinMessageTypes.includes(message.content?.type)) {
1867
+ return /* @__PURE__ */ jsx(ActionMessage, { message, ...props });
1868
+ }
1869
+ const isReplyInMessage = () => {
1870
+ if (!isChatAllowed) {
1871
+ return false;
1872
+ }
1873
+ if (message?.extra_data?.is_undo || message?.extra_data?.is_deleted) {
1874
+ return false;
1875
+ }
1876
+ if (message?.content?.type === "friend_request") {
1877
+ return false;
1878
+ }
1879
+ if (nextMessage?.content?.type === "friend_request" || nextMessage?.extra_data?.old_type === "friend_request") {
1880
+ return false;
1881
+ }
1882
+ if (message?.content?.type == "image") {
1883
+ const contentImage = parseMessageUrls(message?.content.src);
1884
+ if (contentImage?.previewUrls?.length !== 1) {
1885
+ return false;
1886
+ }
1887
+ }
1888
+ return true;
1889
+ };
1890
+ const isPinInMessage = () => {
1891
+ if (!isChatAllowed) {
1892
+ return false;
1893
+ }
1894
+ if (message?.extra_data?.is_undo || message?.extra_data?.is_deleted) {
1895
+ return false;
1896
+ }
1897
+ if (message?.content?.type === "friend_request") {
1898
+ return false;
1899
+ }
1900
+ if (nextMessage?.content?.type === "friend_request" || nextMessage?.extra_data?.old_type === "friend_request") {
1901
+ return false;
1902
+ }
1903
+ if (message?.content?.type == "image") {
1904
+ const contentImage = parseMessageUrls(message?.content.src);
1905
+ if (contentImage?.previewUrls?.length !== 1) {
1906
+ return false;
1907
+ }
1908
+ }
1909
+ return true;
1910
+ };
1911
+ const isForwardInMessage = () => {
1912
+ if (!isChatAllowed) return false;
1913
+ if (message?.extra_data?.is_undo || message?.extra_data?.is_deleted)
1914
+ return false;
1915
+ if (message?.content?.type === "friend_request") return false;
1916
+ if (!message?.content?.meta?.msgId) return false;
1917
+ return true;
1918
+ };
1919
+ const isMychat = isMessageFromSelf({
1920
+ message,
1921
+ ticket: props.ticket,
1922
+ user,
1923
+ isAgent
1924
+ });
1925
+ const getIsMychat = () => isMychat;
1926
+ return /* @__PURE__ */ jsx(
1927
+ MessageContext.Provider,
1928
+ {
1929
+ value: {
1930
+ messageId: message._id,
1931
+ roomId: props.ticket?._id,
1932
+ messageSeq: message.seq ?? null,
1933
+ messageCreatedAt: message.created_at ?? null,
1934
+ isAgent,
1935
+ readReceipt: message?.read_receipt ?? null
1936
+ },
1937
+ children: /* @__PURE__ */ jsxs(
1938
+ "div",
1939
+ {
1940
+ className: cn(
1941
+ "relative flex w-full items-start gap-3 overflow-hidden",
1942
+ isMychat && "flex-row-reverse",
1943
+ message.showUserName && "mt-2",
1944
+ isHighlighted && "rounded-lg bg-secondary"
1945
+ ),
1946
+ children: [
1947
+ isSelectMode && onSelect && /* @__PURE__ */ jsx(
1948
+ "div",
1949
+ {
1950
+ className: "absolute inset-0 z-10 cursor-pointer",
1951
+ onClick: () => onSelect(message)
1952
+ }
1953
+ ),
1954
+ /* @__PURE__ */ jsxs(
1955
+ Avatar,
1956
+ {
1957
+ className: cn(
1958
+ "size-8 self-start",
1959
+ !message.showUserName && "invisible"
1960
+ ),
1961
+ children: [
1962
+ /* @__PURE__ */ jsx(
1963
+ AvatarImage,
1964
+ {
1965
+ src: message.chatter_avatar,
1966
+ alt: message.chatter_name
1967
+ }
1968
+ ),
1969
+ /* @__PURE__ */ jsx(AvatarFallback, { className: "bg-muted", children: message.chatter_type === "chatbot" ? /* @__PURE__ */ jsx(Bot, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(User, { className: "h-4 w-4" }) })
1970
+ ]
1971
+ }
1972
+ ),
1973
+ /* @__PURE__ */ jsxs(
1974
+ "div",
1975
+ {
1976
+ className: cn(
1977
+ "flex min-w-0 max-w-[70%] flex-col gap-1",
1978
+ isMychat ? "items-end" : "items-start"
1979
+ ),
1980
+ children: [
1981
+ message.showUserName && (isAgent || isZaloGroup(props.ticket)) && /* @__PURE__ */ jsx(
1982
+ "span",
1983
+ {
1984
+ className: cn(
1985
+ "max-w-full truncate"
1986
+ // isAgent ? 'text-right' : 'text-left',
1987
+ ),
1988
+ children: message.chatter_name
1989
+ }
1990
+ ),
1991
+ /* @__PURE__ */ jsxs(
1992
+ "div",
1993
+ {
1994
+ className: cn(
1995
+ "group relative flex min-w-0 max-w-full flex-row items-center",
1996
+ isAgent ? "flex-row-reverse justify-end" : "justify-start"
1997
+ ),
1998
+ children: [
1999
+ /* @__PURE__ */ jsx(
2000
+ MessageBubble,
2001
+ {
2002
+ isZalo: isZalo(props.ticket),
2003
+ isTiktok: message?.source === "tiktok" || message?.source === "tiktok_shop" || isTiktok(props.ticket),
2004
+ isAgent,
2005
+ isChatAllowed,
2006
+ msg: {
2007
+ ...message,
2008
+ content: displayContent,
2009
+ ticket_source: message.ticket_source ?? ticketSource
2010
+ },
2011
+ ...props
2012
+ }
2013
+ ),
2014
+ /* @__PURE__ */ jsx(
2015
+ ReactionPreview,
2016
+ {
2017
+ ticket: props.ticket,
2018
+ reactions: message.extra_data?.reactions,
2019
+ isPending: "_pendingReactionTs" in message
2020
+ }
2021
+ ),
2022
+ isChatAllowed && message.status === "success" && (isZaloPersonal(props.ticket) || isFacebook(props.ticket)) && IsMessageAction(message) && !message?.extra_data?.is_undo && !message?.extra_data?.is_deleted && /* @__PURE__ */ jsx(
2023
+ "div",
2024
+ {
2025
+ className: cn(
2026
+ "inset-shadow-sm absolute -bottom-1.5 -right-3 flex -translate-y-1 cursor-pointer items-center justify-center rounded-full p-[4px] hover:text-primary"
2027
+ ),
2028
+ children: /* @__PURE__ */ jsx(
2029
+ ReactionButton,
2030
+ {
2031
+ chatRoom: props.ticket,
2032
+ isMychat: getIsMychat(),
2033
+ message
2034
+ }
2035
+ )
2036
+ }
2037
+ ),
2038
+ !isSelectMode && /* @__PURE__ */ jsx(
2039
+ ChatMessageActions,
2040
+ {
2041
+ ticket: props.ticket,
2042
+ isAgent,
2043
+ isChatAllowed,
2044
+ isReplyInMessage,
2045
+ isPinInMessage,
2046
+ isForwardInMessage,
2047
+ message,
2048
+ isReply: isZaloPersonal(props.ticket) || isFacebook(props.ticket) || isZalo(props.ticket),
2049
+ isPin: isZaloPersonal(props.ticket),
2050
+ isForward: isZaloPersonal(props.ticket) || isZaloGroup(props.ticket),
2051
+ isMychat: getIsMychat(),
2052
+ pinnedData,
2053
+ zaloAllocatedList,
2054
+ className: cn(
2055
+ "opacity-0 transition-opacity duration-200 group-hover:opacity-100",
2056
+ !isAgent && "scale-x-[-1]"
2057
+ )
2058
+ }
2059
+ ),
2060
+ isSelectMode && onSelect && /* @__PURE__ */ jsx(
2061
+ "div",
2062
+ {
2063
+ className: cn(
2064
+ "relative z-[9] order-last mx-2.5 flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full border-2 transition-colors",
2065
+ isSelected ? "border-primary bg-primary" : "border-border bg-card"
2066
+ ),
2067
+ children: isSelected && /* @__PURE__ */ jsx(Check, { className: "h-3 w-3 text-white" })
2068
+ }
2069
+ )
2070
+ ]
2071
+ }
2072
+ ),
2073
+ message.status === "failed" && message?.content?.type !== "utility-messages" && /* @__PURE__ */ jsx("div", { className: "text-end text-xs text-destructive", children: translateServerLabel(
2074
+ message?.extra_data?.send_error?.message
2075
+ ) || translateServerLabel(
2076
+ message?.extra_data?.send_error?.exception_message
2077
+ ) || i18n.t("chat:label.failedToSendMessage", {
2078
+ defaultValue: "G\u1EEDi tin nh\u1EAFn th\u1EA5t b\u1EA1i"
2079
+ }) })
2080
+ ]
2081
+ }
2082
+ )
2083
+ ]
2084
+ }
2085
+ )
2086
+ }
2087
+ );
2088
+ };
2089
+ const messageRenderEqual = (a, b) => {
2090
+ if (a === b) return true;
2091
+ if (!a || !b) return false;
2092
+ return a._id === b._id && a.status === b.status && a.updated_at === b.updated_at && a.content === b.content && a.extra_data === b.extra_data && a.dateLabel === b.dateLabel && a.showUserName === b.showUserName;
2093
+ };
2094
+ const chatMessagePropsAreEqual = (prev, next) => prev.isChatAllowed === next.isChatAllowed && prev.ticket === next.ticket && prev.chatRoom === next.chatRoom && prev.ticketSource === next.ticketSource && prev.requester === next.requester && prev.pinnedData?.data?.data === next.pinnedData?.data?.data && prev.zaloAllocatedList === next.zaloAllocatedList && prev.reminderAction === next.reminderAction && prev.isSelectMode === next.isSelectMode && prev.isSelected === next.isSelected && prev.onSelect === next.onSelect && messageRenderEqual(prev.message, next.message) && messageRenderEqual(prev.nextMessage, next.nextMessage);
2095
+ var chat_message_default = memo(ChatMessage, chatMessagePropsAreEqual);
2096
+ export {
2097
+ MessageBubble,
2098
+ chat_message_default as default
2099
+ };