@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,237 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import React, { useCallback, useEffect, useRef, useState } from "react";
3
+ import { QrCode } from "lucide-react";
4
+ import { Button } from "./custom/button.js";
5
+ import {
6
+ Dialog,
7
+ DialogTrigger,
8
+ DialogContent,
9
+ DialogHeader,
10
+ DialogTitle,
11
+ DialogDescription
12
+ } from "./ui/dialog.js";
13
+ import ZaloLoginStatusModal from "./zalo-login-status-modal.js";
14
+ import { getZaloLoginQr, getZaloLoginStatus } from "@zenify-omni/chat-js/api/settings/channel.js";
15
+ import { checkAccessByPZaloConnection } from "@zenify-omni/chat-js/api/chat.js";
16
+ import { toast } from "sonner";
17
+ import { useQuery, useQueryClient } from "@tanstack/react-query";
18
+ import QUERY_KEY from "@zenify-omni/chat-js/constants/use-query-key.js";
19
+ import { checkIsViewAsMode, getUser } from "@zenify-omni/chat-js/utils/auth.js";
20
+ import useChatStore from "../store/chat-store.js";
21
+ import { useTranslation } from "react-i18next";
22
+ import i18n from "@zenify-omni/chat-js/lib/i18n/index.js";
23
+ function ZaloLoginQr({
24
+ trigger,
25
+ type,
26
+ id,
27
+ onLoginStatus = () => {
28
+ },
29
+ onLoginSuccessAcknowledged = () => {
30
+ }
31
+ }) {
32
+ const { t } = useTranslation();
33
+ const user = getUser();
34
+ const [open, setOpen] = useState(false);
35
+ const [openLoginStatusModal, setOpenLoginStatusModal] = useState(false);
36
+ const [base64QR, setBase64QR] = useState(null);
37
+ const [sessionId, setSessionId] = useState(null);
38
+ const queryClient = useQueryClient();
39
+ const abortControlRef = useRef(new AbortController());
40
+ const setIsZaloConnected = useChatStore((s) => s.setIsZaloConnected);
41
+ const syncZaloPersonalInfo = useCallback(
42
+ (loginStatusInfo) => {
43
+ if (checkIsViewAsMode()) return;
44
+ if (user) {
45
+ const updateUserInfo = {
46
+ ...user,
47
+ zalo_id: loginStatusInfo.zalo_id,
48
+ zalo_phone: loginStatusInfo.zalo_phone,
49
+ zalo_page_name: loginStatusInfo.zalo_page_name
50
+ };
51
+ localStorage.setItem("zenify-sdk-user", JSON.stringify(updateUserInfo));
52
+ }
53
+ },
54
+ [user]
55
+ );
56
+ const { isLoading: isLoadingGetLoginQR, refetch: refetchGetLoginQR } = useQuery({
57
+ enabled: false,
58
+ queryKey: ["getZaloLoginQr"],
59
+ queryFn: async () => {
60
+ try {
61
+ const { data } = await getZaloLoginQr(id, type);
62
+ setBase64QR(data?.image);
63
+ setSessionId(data?.id);
64
+ return data;
65
+ } catch {
66
+ toast.error(
67
+ i18n.t("common:toast.zaloQrFetchError", {
68
+ defaultValue: "\u0110\xE3 c\xF3 l\u1ED7i x\u1EA3y ra khi l\u1EA5y m\xE3 QR \u0111\u0103ng nh\u1EADp Zalo, vui l\xF2ng th\u1EED l\u1EA1i!"
69
+ })
70
+ );
71
+ }
72
+ }
73
+ });
74
+ useEffect(() => {
75
+ if (sessionId) {
76
+ queryClient.fetchQuery({
77
+ queryKey: ["getZaloLoginStatus"],
78
+ queryFn: async () => {
79
+ try {
80
+ const { data } = await getZaloLoginStatus(sessionId, type, {
81
+ signal: abortControlRef.current.signal
82
+ // AbortController supported in Axios v1+
83
+ });
84
+ if (!data.login_status) {
85
+ toast.error(
86
+ i18n.t("common:toast.zaloLoginFailed", {
87
+ defaultValue: "\u0110\u0103ng nh\u1EADp Zalo th\u1EA5t b\u1EA1i, vui l\xF2ng th\u1EED l\u1EA1i!"
88
+ })
89
+ );
90
+ } else {
91
+ setOpenLoginStatusModal({
92
+ open: true,
93
+ status: data.login_status,
94
+ content: data.message || null,
95
+ data
96
+ });
97
+ syncZaloPersonalInfo(data);
98
+ let isZaloConnected = true;
99
+ const isOnChatRoute = window.location.pathname.startsWith("/chat");
100
+ const chatRoomId = useChatStore.getState().currentChatId;
101
+ if (isOnChatRoute && chatRoomId) {
102
+ try {
103
+ const response = await checkAccessByPZaloConnection({
104
+ ticketId: chatRoomId,
105
+ userId: user?._id
106
+ });
107
+ isZaloConnected = !!response?.data?.success;
108
+ } catch {
109
+ }
110
+ }
111
+ setIsZaloConnected(isZaloConnected);
112
+ queryClient.invalidateQueries({
113
+ queryKey: [QUERY_KEY.GET_ZALOS_ALLOCATED]
114
+ });
115
+ onLoginStatus(data);
116
+ }
117
+ return data;
118
+ } catch (error) {
119
+ toast.error(
120
+ i18n.t("common:toast.zaloLoginError", {
121
+ defaultValue: "\u0110\xE3 c\xF3 l\u1ED7i x\u1EA3y ra trong qu\xE1 tr\xECnh \u0111\u0103ng nh\u1EADp Zalo, vui l\xF2ng th\u1EED l\u1EA1i!"
122
+ })
123
+ );
124
+ } finally {
125
+ setBase64QR(null);
126
+ setSessionId(null);
127
+ setOpen(false);
128
+ }
129
+ }
130
+ });
131
+ }
132
+ return () => {
133
+ queryClient.cancelQueries({ queryKey: ["getZaloLoginStatus"] });
134
+ };
135
+ }, [queryClient, sessionId, type]);
136
+ useEffect(() => {
137
+ if (open) {
138
+ abortControlRef.current = new AbortController();
139
+ } else {
140
+ abortControlRef.current.abort();
141
+ }
142
+ }, [open]);
143
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
144
+ /* @__PURE__ */ jsxs(Dialog, { open, onOpenChange: setOpen, children: [
145
+ /* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: trigger ? React.cloneElement(trigger, {
146
+ onClick: () => setOpen(true)
147
+ }) : /* @__PURE__ */ jsx(
148
+ Button,
149
+ {
150
+ variant: "outline",
151
+ className: "relative m-0 scale-95 transform rounded-[10px] px-2 shadow-inner active:scale-90",
152
+ onClick: () => setOpen(true),
153
+ children: /* @__PURE__ */ jsx(QrCode, { size: 18, className: "text-primary" })
154
+ }
155
+ ) }),
156
+ /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-[640px]", children: [
157
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
158
+ /* @__PURE__ */ jsx(DialogTitle, { children: t("common:action.addZaloAccount", {
159
+ defaultValue: "Th\xEAm t\xE0i kho\u1EA3n Zalo"
160
+ }) }),
161
+ /* @__PURE__ */ jsx(
162
+ DialogDescription,
163
+ {
164
+ className: "hidden",
165
+ "aria-describedby": "zalo-login-dialog"
166
+ }
167
+ )
168
+ ] }),
169
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
170
+ /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
171
+ !base64QR && /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsx(
172
+ Button,
173
+ {
174
+ size: "sm",
175
+ leftSection: /* @__PURE__ */ jsx(QrCode, { className: "h-4 w-4 cursor-pointer" }),
176
+ onClick: () => {
177
+ refetchGetLoginQR();
178
+ },
179
+ disabled: isLoadingGetLoginQR,
180
+ children: isLoadingGetLoginQR ? t("common:status.loading", {
181
+ defaultValue: "\u0110ang t\u1EA3i..."
182
+ }) : t("common:action.getZaloLoginQr", {
183
+ defaultValue: "L\u1EA5y m\xE3 QR \u0111\u0103ng nh\u1EADp Zalo"
184
+ })
185
+ }
186
+ ) }),
187
+ base64QR && /* @__PURE__ */ jsx("div", { className: "relative h-[200px] w-[200px]", children: /* @__PURE__ */ jsx(
188
+ "img",
189
+ {
190
+ className: "h-full w-full",
191
+ src: `data:image/png;base64,${base64QR}`
192
+ }
193
+ ) })
194
+ ] }),
195
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col gap-4", children: [
196
+ /* @__PURE__ */ jsx("h1", { className: "text-lg font-medium", children: t("common:message.scanQrConnectZalo", {
197
+ defaultValue: "Qu\xE9t QR \u0111\u1EC3 k\u1EBFt n\u1ED1i Zalo v\u1EDBi Zenify"
198
+ }) }),
199
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
200
+ /* @__PURE__ */ jsx("p", { className: "font-light", children: t("common:message.zaloLoginStep1", {
201
+ defaultValue: "1. M\u1EDF \u1EE9ng d\u1EE5ng Zalo tr\xEAn di \u0111\u1ED9ng"
202
+ }) }),
203
+ /* @__PURE__ */ jsx("p", { className: "font-light", children: t("common:message.zaloLoginStep2", {
204
+ defaultValue: "2. \u1EDE m\u1EE5c C\xE0i \u0111\u1EB7t, nh\u1EA5n n\xFAt qu\xE9t QR"
205
+ }) }),
206
+ /* @__PURE__ */ jsx("p", { className: "font-light", children: t("common:message.zaloLoginStep3", {
207
+ defaultValue: "3. Qu\xE9t m\xE3 QR \u0111\u1EC3 \u0111\u0103ng nh\u1EADp"
208
+ }) })
209
+ ] })
210
+ ] })
211
+ ] })
212
+ ] })
213
+ ] }),
214
+ /* @__PURE__ */ jsx(
215
+ ZaloLoginStatusModal,
216
+ {
217
+ open: openLoginStatusModal?.open || false,
218
+ onOpenChange: (isOpen) => {
219
+ if (!isOpen) {
220
+ queryClient.invalidateQueries({
221
+ queryKey: [QUERY_KEY.GET_LIST_ZALO_GENERAL_ACCOUNT]
222
+ });
223
+ if (openLoginStatusModal?.status) {
224
+ onLoginSuccessAcknowledged(openLoginStatusModal.data);
225
+ }
226
+ }
227
+ setOpenLoginStatusModal(isOpen ? openLoginStatusModal : false);
228
+ },
229
+ status: openLoginStatusModal?.open ? openLoginStatusModal?.status : void 0,
230
+ content: openLoginStatusModal?.open ? openLoginStatusModal?.content : void 0
231
+ }
232
+ )
233
+ ] });
234
+ }
235
+ export {
236
+ ZaloLoginQr as default
237
+ };
@@ -0,0 +1,45 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { CheckCircle, AlertCircle } from "lucide-react";
3
+ import { Dialog, DialogContent } from "./ui/dialog.js";
4
+ function ZaloLoginSuccessModal({
5
+ open = true,
6
+ onOpenChange,
7
+ status = true,
8
+ content = null
9
+ }) {
10
+ const getIcon = () => {
11
+ if (status) {
12
+ return /* @__PURE__ */ jsx(CheckCircle, { className: "h-8 w-8 text-success" });
13
+ }
14
+ return /* @__PURE__ */ jsx(AlertCircle, { className: "h-8 w-8 text-warning" });
15
+ };
16
+ const getIconBgColor = () => {
17
+ if (status) return "bg-[--label-green]";
18
+ return "bg-[--label-red]";
19
+ };
20
+ const getTitle = () => {
21
+ if (status) return "Li\xEAn k\u1EBFt th\xE0nh c\xF4ng!";
22
+ return "Li\xEAn k\u1EBFt th\u1EA5t b\u1EA1i!";
23
+ };
24
+ const getDescription = () => {
25
+ if (content) return content;
26
+ if (status) return "Zalo c\xE1 nh\xE2n c\u1EE7a b\u1EA1n \u0111\xE3 \u0111\u01B0\u1EE3c k\u1EBFt n\u1ED1i v\u1EC1 h\u1EC7 th\u1ED1ng.";
27
+ return "Zalo c\xE1 nh\xE2n c\u1EE7a b\u1EA1n ch\u01B0a \u0111\u01B0\u1EE3c k\u1EBFt n\u1ED1i v\u1EC1 h\u1EC7 th\u1ED1ng.";
28
+ };
29
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsx(DialogContent, { className: "sm:max-w-md", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center space-y-4 py-6", children: [
30
+ /* @__PURE__ */ jsx(
31
+ "div",
32
+ {
33
+ className: `flex h-16 w-16 items-center justify-center rounded-full ${getIconBgColor()}`,
34
+ children: getIcon()
35
+ }
36
+ ),
37
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2 text-center", children: [
38
+ /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-foreground", children: getTitle() }),
39
+ /* @__PURE__ */ jsx("p", { className: "max-w-xs text-sm text-muted-foreground", children: getDescription() })
40
+ ] })
41
+ ] }) }) });
42
+ }
43
+ export {
44
+ ZaloLoginSuccessModal as default
45
+ };
package/config/env.js ADDED
@@ -0,0 +1,27 @@
1
+ import { registerEnvDefaults } from "@zenify-omni/chat-js/config/env.js";
2
+ registerEnvDefaults({
3
+ // --- URL ---
4
+ // socket chat (chat_socket + typing_socket). Không có mặc định.
5
+ CHAT_URL: "https://chat.zenify.vn/chatroom",
6
+ // --- Facebook SDK ---
7
+ // --- Cờ theo tenant ---
8
+ // Nhận cả chuỗi phân tách bằng dấu phẩy lẫn mảng.
9
+ //
10
+ // CHÚ Ý ngữ nghĩa khi để rỗng KHÔNG giống nhau giữa các khoá — giữ nguyên
11
+ // như mã cũ: hai khoá đầu rỗng = BẬT cho mọi tenant, các khoá còn lại rỗng =
12
+ // TẮT với mọi tenant.
13
+ TENANT_ENABLE_FB_HUMAN_TAG: ["646ae9cffe32b43426f45165", "699e5aee1c8e694cd7744529", "68a2cf5739f7509d7ee6b3f2", "688048ee365f35cb45c397da"],
14
+ // rỗng = bật cho mọi tenant
15
+ TENANT_ENABLE_DEAL_NAME_SUGGEST: ["693fafe2beef395b73cc22ac", "646ae9cffe32b43426f45165"],
16
+ // rỗng = tắt
17
+ // --- Khác ---
18
+ SPECIAL_TENANT_ID: "694816f69eba11635c959f07",
19
+ SORT_FIELD_KEY: "ad_str_1"
20
+ });
21
+ import { env, envList, envSet, configureChatEnv } from "@zenify-omni/chat-js/config/env.js";
22
+ export {
23
+ configureChatEnv,
24
+ env,
25
+ envList,
26
+ envSet
27
+ };
package/config/hmr.js ADDED
@@ -0,0 +1,8 @@
1
+ const disposers = /* @__PURE__ */ new Set();
2
+ function onModuleDispose(fn) {
3
+ disposers.add(fn);
4
+ return () => disposers.delete(fn);
5
+ }
6
+ export {
7
+ onModuleDispose
8
+ };
@@ -0,0 +1,54 @@
1
+ import useChatStore from "../store/chat-store.js";
2
+ let navigateFunc = null;
3
+ function setNavigateFunc(fn) {
4
+ navigateFunc = typeof fn === "function" ? fn : null;
5
+ }
6
+ function resetChatNavigation() {
7
+ navigateFunc = null;
8
+ mounted = 0;
9
+ warnedMissingFunc = false;
10
+ }
11
+ function matchChatRoomTarget(target) {
12
+ const to = typeof target === "string" ? target : target?.to;
13
+ if (typeof to !== "string") return void 0;
14
+ if (to === "/chat/$chatRoomId") return target?.params?.chatRoomId ?? null;
15
+ if (to === "/chat" || to === "/chat/") return null;
16
+ const m = to.match(/^\/chat\/([^/?#]+)/);
17
+ return m ? m[1] : void 0;
18
+ }
19
+ function navigate(target) {
20
+ const roomId = matchChatRoomTarget(target);
21
+ if (roomId !== void 0) {
22
+ useChatStore.getState().setCurrentChatId(roomId);
23
+ } else if (!navigateFunc) {
24
+ warnMissingFunc(target);
25
+ }
26
+ navigateFunc?.(target);
27
+ }
28
+ let warnedMissingFunc = false;
29
+ const warnMissingFunc = (target) => {
30
+ if (warnedMissingFunc) return;
31
+ warnedMissingFunc = true;
32
+ console.warn(
33
+ "[chat-ui] SDK mu\u1ED1n \u0111i\u1EC1u h\u01B0\u1EDBng ra ngo\xE0i m\xE0n chat nh\u01B0ng app nh\xFAng ch\u01B0a truy\u1EC1n <ChatProvider navigateFunc={...}>. L\u1EDDi g\u1ECDi b\u1ECB b\u1ECF qua. Target: " + JSON.stringify(target)
34
+ );
35
+ };
36
+ let mounted = 0;
37
+ function markChatSurface() {
38
+ mounted += 1;
39
+ let released = false;
40
+ return () => {
41
+ if (released) return;
42
+ released = true;
43
+ mounted = Math.max(0, mounted - 1);
44
+ };
45
+ }
46
+ const isChatVisible = () => mounted > 0;
47
+ export {
48
+ isChatVisible,
49
+ markChatSurface,
50
+ matchChatRoomTarget,
51
+ navigate,
52
+ resetChatNavigation,
53
+ setNavigateFunc
54
+ };
@@ -0,0 +1,46 @@
1
+ let runtime = { queryClient: null };
2
+ function setChatRuntime(next) {
3
+ for (const key of ["queryClient"]) {
4
+ if (!(key in next)) continue;
5
+ const prev = runtime[key];
6
+ if (prev && prev !== next[key]) {
7
+ console.warn(
8
+ `[chat-ui] setChatRuntime: thay ${key} b\u1EB1ng m\u1ED9t instance kh\xE1c. Th\u01B0\u1EDDng l\xE0 app \u0111\xE3 d\u1EF1ng ${key} hai l\u1EA7n \u2014 ki\u1EC3m tra l\u1EA1i ch\u1ED7 kh\u1EDFi t\u1EA1o.`
9
+ );
10
+ }
11
+ }
12
+ runtime = { ...runtime, ...next };
13
+ }
14
+ function resetChatRuntime() {
15
+ runtime = { queryClient: null };
16
+ }
17
+ const required = (key) => {
18
+ const value = runtime[key];
19
+ if (!value) {
20
+ throw new Error(
21
+ `[chat-ui] ch\u01B0a c\xF3 "${key}". G\u1ECDi setChatRuntime({ ${key} }) l\xFAc app kh\u1EDFi \u0111\u1ED9ng, ho\u1EB7c truy\u1EC1n qua <ChatProvider ${key}={...}>.`
22
+ );
23
+ }
24
+ return value;
25
+ };
26
+ const getQueryClient = () => required("queryClient");
27
+ const hasChatRuntime = () => !!runtime.queryClient;
28
+ const liveBinding = (key) => new Proxy(
29
+ {},
30
+ {
31
+ get(_target, prop) {
32
+ const real = required(key);
33
+ const value = real[prop];
34
+ return typeof value === "function" ? value.bind(real) : value;
35
+ },
36
+ has: (_target, prop) => prop in required(key)
37
+ }
38
+ );
39
+ const queryClient = liveBinding("queryClient");
40
+ export {
41
+ getQueryClient,
42
+ hasChatRuntime,
43
+ queryClient,
44
+ resetChatRuntime,
45
+ setChatRuntime
46
+ };
@@ -0,0 +1,274 @@
1
+ const VAR_FORMAT = Object.freeze({
2
+ // hex trần — dùng qua `bg-[--label-red]`, KHÔNG bọc hsl()
3
+ "label-blue": "hex",
4
+ "label-blue-foreground": "hex",
5
+ "label-green": "hex",
6
+ "label-green-prime": "hex",
7
+ "label-green-foreground": "hex",
8
+ "label-red": "hex",
9
+ "label-red-foreground": "hex",
10
+ "label-orange": "hex",
11
+ "label-orange-foreground": "hex",
12
+ "label-gray": "hex",
13
+ "label-dark-blue": "hex",
14
+ // CSV + alpha — dùng qua `hsl(var(--icon-danger))` kiểu cũ
15
+ "icon-primary": "csv",
16
+ "icon-success": "csv",
17
+ "icon-danger": "csv",
18
+ "icon-eye-viewer": "csv",
19
+ "border-secondary": "csv",
20
+ "border-eye-viewer": "csv",
21
+ // giá trị không phải màu — đi thẳng
22
+ radius: "raw",
23
+ "header-height": "raw",
24
+ "modal-max-height": "raw",
25
+ "body-padding-x": "raw",
26
+ "body-padding-y": "raw",
27
+ // độ mờ của bóng: số trần (0–1), KHÔNG phải màu. '--shadow-color' thì là
28
+ // bộ ba HSL bình thường nên để mặc định 'triplet'.
29
+ "shadow-strength": "raw",
30
+ "shadow-rim": "raw"
31
+ });
32
+ const CHAT_THEME_VARS = Object.freeze([
33
+ "background",
34
+ "foreground",
35
+ "card",
36
+ "card-foreground",
37
+ "popover",
38
+ "popover-foreground",
39
+ "primary",
40
+ "primary-foreground",
41
+ "secondary",
42
+ "secondary-foreground",
43
+ "success",
44
+ "muted",
45
+ "muted-foreground",
46
+ "accent",
47
+ "accent-foreground",
48
+ "destructive",
49
+ "destructive-foreground",
50
+ "border",
51
+ "input",
52
+ "ring",
53
+ "shadow-color",
54
+ "shadow-strength",
55
+ "shadow-rim",
56
+ "radius",
57
+ "header-height",
58
+ "modal-max-height",
59
+ "body-padding-x",
60
+ "body-padding-y",
61
+ "campaign-create-bg",
62
+ "sidebar-background",
63
+ "sidebar-foreground",
64
+ "sidebar-primary",
65
+ "sidebar-primary-foreground",
66
+ "sidebar-accent",
67
+ "sidebar-accent-foreground",
68
+ "sidebar-border",
69
+ "sidebar-ring",
70
+ "icon-primary",
71
+ "icon-success",
72
+ "icon-danger",
73
+ "icon-eye-viewer",
74
+ "border-secondary",
75
+ "border-eye-viewer",
76
+ "label-blue",
77
+ "label-blue-foreground",
78
+ "label-green",
79
+ "label-green-prime",
80
+ "label-green-foreground",
81
+ "label-red",
82
+ "label-red-foreground",
83
+ "label-orange",
84
+ "label-orange-foreground",
85
+ "label-gray",
86
+ "label-dark-blue",
87
+ // Token thêm khi chuyển màu hex cứng sang Tailwind
88
+ "success-foreground",
89
+ "warning",
90
+ "warning-foreground",
91
+ "foreground-secondary",
92
+ "border-subtle",
93
+ "surface-subtle",
94
+ "chat-own-bubble",
95
+ "chat-own-bubble-foreground",
96
+ "chat-thread-bg",
97
+ ...Array.from({ length: 11 }, (_, i) => `chart-${i + 1}`)
98
+ ]);
99
+ const VAR_SET = new Set(CHAT_THEME_VARS);
100
+ const formatOf = (name) => VAR_FORMAT[name] || "triplet";
101
+ const toKebab = (key) => String(key).replace(/^--/, "").replace(/_/g, "-").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
102
+ const clamp = (n, lo, hi) => Math.min(hi, Math.max(lo, n));
103
+ function hexToRgb(hex) {
104
+ const m = /^#?([0-9a-f]{3,8})$/i.exec(String(hex).trim());
105
+ if (!m) return null;
106
+ let h = m[1];
107
+ if (h.length === 3 || h.length === 4) h = [...h].map((c) => c + c).join("");
108
+ if (h.length !== 6 && h.length !== 8) return null;
109
+ return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
110
+ }
111
+ function rgbToHslTriplet([r, g, b]) {
112
+ const [R, G, B] = [r / 255, g / 255, b / 255];
113
+ const max = Math.max(R, G, B);
114
+ const min = Math.min(R, G, B);
115
+ const l = (max + min) / 2;
116
+ let h = 0;
117
+ let s = 0;
118
+ if (max !== min) {
119
+ const d = max - min;
120
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
121
+ if (max === R) h = ((G - B) / d + (G < B ? 6 : 0)) * 60;
122
+ else if (max === G) h = ((B - R) / d + 2) * 60;
123
+ else h = ((R - G) / d + 4) * 60;
124
+ }
125
+ const round = (n) => Number(n.toFixed(1));
126
+ return `${round(h)} ${round(s * 100)}% ${round(l * 100)}%`;
127
+ }
128
+ function toHslTriplet(value) {
129
+ const v = String(value).trim();
130
+ if (/^-?[\d.]+\s+[\d.]+%\s+[\d.]+%$/.test(v)) return v;
131
+ const hsl = /^hsla?\(\s*([-\d.]+)(?:deg)?[\s,]+([\d.]+)%[\s,]+([\d.]+)%/i.exec(v);
132
+ if (hsl) return `${hsl[1]} ${hsl[2]}% ${hsl[3]}%`;
133
+ const rgb = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(v);
134
+ if (rgb) return rgbToHslTriplet(rgb.slice(1, 4).map((n) => clamp(+n, 0, 255)));
135
+ const fromHex = hexToRgb(v);
136
+ if (fromHex) return rgbToHslTriplet(fromHex);
137
+ return v;
138
+ }
139
+ const rgbToHex = ([r, g, b]) => "#" + [r, g, b].map((n) => Math.round(n).toString(16).padStart(2, "0")).join("");
140
+ function anyToRgb(value) {
141
+ const v = String(value).trim();
142
+ const fromHex = hexToRgb(v);
143
+ if (fromHex) return fromHex;
144
+ const rgb = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(v);
145
+ if (rgb) return rgb.slice(1, 4).map((n) => clamp(+n, 0, 255));
146
+ const t = toHslTriplet(v);
147
+ const m = /^(-?[\d.]+)\s+([\d.]+)%\s+([\d.]+)%$/.exec(t);
148
+ if (!m) return null;
149
+ const [h, S, L] = [+m[1], +m[2] / 100, +m[3] / 100];
150
+ const c = (1 - Math.abs(2 * L - 1)) * S;
151
+ const x = c * (1 - Math.abs(h / 60 % 2 - 1));
152
+ const mm = L - c / 2;
153
+ const seg = [[c, x, 0], [x, c, 0], [0, c, x], [0, x, c], [x, 0, c], [c, 0, x]][Math.floor((h % 360 + 360) % 360 / 60)];
154
+ return seg.map((n) => (n + mm) * 255);
155
+ }
156
+ function toVarValue(value, format = "triplet") {
157
+ if (format === "raw") return String(value).trim();
158
+ const triplet = toHslTriplet(value);
159
+ const m = /^(-?[\d.]+)\s+([\d.]+)%\s+([\d.]+)%$/.exec(triplet);
160
+ if (!m) return triplet;
161
+ if (format === "triplet") return triplet;
162
+ if (format === "csv") return `${m[1]}, ${m[2]}%, ${m[3]}%, 1`;
163
+ if (format === "hex") {
164
+ const rgb = anyToRgb(value);
165
+ return rgb ? rgbToHex(rgb) : triplet;
166
+ }
167
+ return triplet;
168
+ }
169
+ const CHAT_SURFACE = {
170
+ // Bong bóng tin của chính mình (agent gửi).
171
+ ownBubble: [".bg-\\[\\#e5f1ff\\]", "background-color"],
172
+ ownBubbleBorder: [".border-\\[\\#e5f1ff\\]", "border-color"],
173
+ // Nền vùng cuộn tin nhắn.
174
+ threadBackground: [".bg-\\[\\#f9f9f9\\]", "background-color"]
175
+ };
176
+ const escapeCssValue = (v) => String(v).replace(/[<>{}\;]/g, "");
177
+ function buildChatTheme(theme = {}) {
178
+ const vars = {};
179
+ const unknown = [];
180
+ const rules = [];
181
+ for (const [rawKey, rawValue] of Object.entries(theme)) {
182
+ if (rawValue == null || rawValue === "") continue;
183
+ if (rawKey === "chat") {
184
+ for (const [k, v] of Object.entries(rawValue || {})) {
185
+ const hit = CHAT_SURFACE[k];
186
+ if (!hit) {
187
+ unknown.push(`chat.${k}`);
188
+ continue;
189
+ }
190
+ const [selector, prop] = hit;
191
+ rules.push(`${selector}{${prop}:${escapeCssValue(v)} !important}`);
192
+ if (k === "ownBubble") {
193
+ const fg = theme.chat?.ownBubbleForeground;
194
+ if (fg) rules.push(`${selector},${selector} *{color:${escapeCssValue(fg)} !important}`);
195
+ }
196
+ }
197
+ continue;
198
+ }
199
+ const name = toKebab(rawKey);
200
+ if (!VAR_SET.has(name)) {
201
+ unknown.push(rawKey);
202
+ continue;
203
+ }
204
+ vars[`--${name}`] = escapeCssValue(toVarValue(rawValue, formatOf(name)));
205
+ }
206
+ const known = /* @__PURE__ */ new Set(["ownBubbleForeground", ...Object.keys(CHAT_SURFACE)]);
207
+ return {
208
+ vars,
209
+ css: rules.join("\n"),
210
+ unknown: unknown.filter((u) => !known.has(u.replace(/^chat\./, "")))
211
+ };
212
+ }
213
+ function applyColorScheme(scheme = "light") {
214
+ if (typeof document === "undefined") return () => {
215
+ };
216
+ const root = document.documentElement;
217
+ const had = root.classList.contains("dark");
218
+ const prevScheme = root.style.colorScheme;
219
+ const isDark = scheme === "dark";
220
+ root.classList.toggle("dark", isDark);
221
+ root.style.colorScheme = isDark ? "dark" : "light";
222
+ return () => {
223
+ root.classList.toggle("dark", had);
224
+ root.style.colorScheme = prevScheme;
225
+ };
226
+ }
227
+ function resolveTheme(theme, isDark) {
228
+ if (!theme) return null;
229
+ const hasModes = "light" in theme || "dark" in theme;
230
+ if (!hasModes) return theme;
231
+ return { ...theme.light || {}, ...isDark ? theme.dark || {} : {} };
232
+ }
233
+ const STYLE_ID = "zenify-chat-theme";
234
+ let warned = false;
235
+ function applyChatTheme(theme) {
236
+ if (typeof document === "undefined") return () => {
237
+ };
238
+ const { vars, css, unknown } = buildChatTheme(theme);
239
+ if (unknown.length && !warned) {
240
+ warned = true;
241
+ console.warn(
242
+ `[chat-ui] theme: kh\xF4ng nh\u1EADn ra ${unknown.map((u) => `"${u}"`).join(", ")}. T\xEAn h\u1EE3p l\u1EC7: ${CHAT_THEME_VARS.slice(0, 8).join(", ")}\u2026 (xem CHAT_THEME_VARS)`
243
+ );
244
+ }
245
+ const root = document.documentElement;
246
+ const previous = /* @__PURE__ */ new Map();
247
+ for (const [name, value] of Object.entries(vars)) {
248
+ previous.set(name, root.style.getPropertyValue(name));
249
+ root.style.setProperty(name, value);
250
+ }
251
+ let styleEl = null;
252
+ if (css) {
253
+ styleEl = document.getElementById(STYLE_ID) || document.createElement("style");
254
+ styleEl.id = STYLE_ID;
255
+ styleEl.textContent = css;
256
+ if (!styleEl.isConnected) document.head.appendChild(styleEl);
257
+ }
258
+ return () => {
259
+ for (const [name, old] of previous) {
260
+ if (old) root.style.setProperty(name, old);
261
+ else root.style.removeProperty(name);
262
+ }
263
+ if (styleEl?.isConnected) styleEl.remove();
264
+ };
265
+ }
266
+ export {
267
+ CHAT_THEME_VARS,
268
+ applyChatTheme,
269
+ applyColorScheme,
270
+ buildChatTheme,
271
+ resolveTheme,
272
+ toHslTriplet,
273
+ toVarValue
274
+ };