isometrik-plugin-chat-sdk 1.0.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 (507) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/BlockChatList-720a703e.js +423 -0
  3. package/dist/cjs/BlockChatList-720a703e.js.map +1 -0
  4. package/dist/cjs/DocumentMessageBubble-c79bfbe5.js +493 -0
  5. package/dist/cjs/DocumentMessageBubble-c79bfbe5.js.map +1 -0
  6. package/dist/cjs/Image-67c52acd.js +135 -0
  7. package/dist/cjs/Image-67c52acd.js.map +1 -0
  8. package/dist/cjs/ImageMessageBubble-1218fb66.js +675 -0
  9. package/dist/cjs/ImageMessageBubble-1218fb66.js.map +1 -0
  10. package/dist/cjs/IsometrikLogo-976b1c34.js +44 -0
  11. package/dist/cjs/IsometrikLogo-976b1c34.js.map +1 -0
  12. package/dist/cjs/MessageSearch-5fc9dc00.js +5892 -0
  13. package/dist/cjs/MessageSearch-5fc9dc00.js.map +1 -0
  14. package/dist/cjs/ReactionsContainer-a6ce9059.js +375 -0
  15. package/dist/cjs/ReactionsContainer-a6ce9059.js.map +1 -0
  16. package/dist/cjs/Text-fedf6eab.js +60 -0
  17. package/dist/cjs/Text-fedf6eab.js.map +1 -0
  18. package/dist/cjs/VideoMessageBubble-c4694a78.js +571 -0
  19. package/dist/cjs/VideoMessageBubble-c4694a78.js.map +1 -0
  20. package/dist/cjs/WebChat-403e7ab1.js +2884 -0
  21. package/dist/cjs/WebChat-403e7ab1.js.map +1 -0
  22. package/dist/cjs/app-globals-3a1e7e63.js +7 -0
  23. package/dist/cjs/app-globals-3a1e7e63.js.map +1 -0
  24. package/dist/cjs/audio-bubble_8.cjs.entry.js +21011 -0
  25. package/dist/cjs/audio-bubble_8.cjs.entry.js.map +1 -0
  26. package/dist/cjs/block-chat-list.cjs.entry.js +16 -0
  27. package/dist/cjs/block-chat-list.cjs.entry.js.map +1 -0
  28. package/dist/cjs/chat-app.cjs.entry.js +55 -0
  29. package/dist/cjs/chat-app.cjs.entry.js.map +1 -0
  30. package/dist/cjs/chat-assets-6ab1faa6.js +9 -0
  31. package/dist/cjs/chat-assets-6ab1faa6.js.map +1 -0
  32. package/dist/cjs/chat-creds-f4cbf400.js +38 -0
  33. package/dist/cjs/chat-creds-f4cbf400.js.map +1 -0
  34. package/dist/cjs/chat-document-message-bubble.cjs.entry.js +24 -0
  35. package/dist/cjs/chat-document-message-bubble.cjs.entry.js.map +1 -0
  36. package/dist/cjs/chat-image-message-bubble.cjs.entry.js +26 -0
  37. package/dist/cjs/chat-image-message-bubble.cjs.entry.js.map +1 -0
  38. package/dist/cjs/chat-video-message-bubble.cjs.entry.js +24 -0
  39. package/dist/cjs/chat-video-message-bubble.cjs.entry.js.map +1 -0
  40. package/dist/cjs/content-eca5336c.js +81 -0
  41. package/dist/cjs/content-eca5336c.js.map +1 -0
  42. package/dist/cjs/dialog-drawer-9d04911c.js +5313 -0
  43. package/dist/cjs/dialog-drawer-9d04911c.js.map +1 -0
  44. package/dist/cjs/forward-memebers.cjs.entry.js +128 -0
  45. package/dist/cjs/forward-memebers.cjs.entry.js.map +1 -0
  46. package/dist/cjs/group-members-a60fb1cb.js +41 -0
  47. package/dist/cjs/group-members-a60fb1cb.js.map +1 -0
  48. package/dist/cjs/groupcast-49dae5ab.js +202 -0
  49. package/dist/cjs/groupcast-49dae5ab.js.map +1 -0
  50. package/dist/cjs/imagePlaceholder-030cc566.js +4365 -0
  51. package/dist/cjs/imagePlaceholder-030cc566.js.map +1 -0
  52. package/dist/cjs/index-9afe62b6.js +3129 -0
  53. package/dist/cjs/index-9afe62b6.js.map +1 -0
  54. package/dist/cjs/index.cjs.js +148 -0
  55. package/dist/cjs/index.cjs.js.map +1 -0
  56. package/dist/cjs/isometrik-webchat.cjs.js +54 -0
  57. package/dist/cjs/isometrik-webchat.cjs.js.map +1 -0
  58. package/dist/cjs/loader.cjs.js +17 -0
  59. package/dist/cjs/loader.cjs.js.map +1 -0
  60. package/dist/cjs/login-page.cjs.entry.js +85 -0
  61. package/dist/cjs/login-page.cjs.entry.js.map +1 -0
  62. package/dist/cjs/member-add.cjs.entry.js +122 -0
  63. package/dist/cjs/member-add.cjs.entry.js.map +1 -0
  64. package/dist/cjs/message-reaction-976f6261.js +24 -0
  65. package/dist/cjs/message-reaction-976f6261.js.map +1 -0
  66. package/dist/cjs/my-component.cjs.entry.js +29 -0
  67. package/dist/cjs/my-component.cjs.entry.js.map +1 -0
  68. package/dist/cjs/reaction-container.cjs.entry.js +52 -0
  69. package/dist/cjs/reaction-container.cjs.entry.js.map +1 -0
  70. package/dist/cjs/shadow-css-7c4dbc43.js +336 -0
  71. package/dist/cjs/shadow-css-7c4dbc43.js.map +1 -0
  72. package/dist/cjs/signup-page.cjs.entry.js +143 -0
  73. package/dist/cjs/signup-page.cjs.entry.js.map +1 -0
  74. package/dist/cjs/taguser-aca04ed9.js +512 -0
  75. package/dist/cjs/taguser-aca04ed9.js.map +1 -0
  76. package/dist/cjs/theme-provider_2.cjs.entry.js +113 -0
  77. package/dist/cjs/theme-provider_2.cjs.entry.js.map +1 -0
  78. package/dist/cjs/toast-helper-defae4a5.js +84 -0
  79. package/dist/cjs/toast-helper-defae4a5.js.map +1 -0
  80. package/dist/cjs/utils-bcad3386.js +9 -0
  81. package/dist/cjs/utils-bcad3386.js.map +1 -0
  82. package/dist/collection/api/conversations.js +12 -0
  83. package/dist/collection/api/group-members.js +36 -0
  84. package/dist/collection/api/groupcast.js +183 -0
  85. package/dist/collection/api/membership-control.js +13 -0
  86. package/dist/collection/api/message-reaction.js +16 -0
  87. package/dist/collection/api/social-accounts.js +282 -0
  88. package/dist/collection/app-root.js +51 -0
  89. package/dist/collection/app-root.js.map +1 -0
  90. package/dist/collection/assets/images/avatar.svg +1 -0
  91. package/dist/collection/assets/images/chatdefaultbg.svg +6140 -0
  92. package/dist/collection/assets/images/equalizer.svg +1 -0
  93. package/dist/collection/assets/images/imagePlaceholder.svg +2 -0
  94. package/dist/collection/assets/images/link.svg +1 -0
  95. package/dist/collection/assets/images/videoPlaceholder.svg +4 -0
  96. package/dist/collection/assets/images/videoThumbnail.svg +1 -0
  97. package/dist/collection/assets/svg/ExcelDocument.js +2 -0
  98. package/dist/collection/assets/svg/IsometrikLogo.js +38 -0
  99. package/dist/collection/assets/svg/Moon.svg +1 -0
  100. package/dist/collection/assets/svg/NoChatPlaceholder.js +16 -0
  101. package/dist/collection/assets/svg/NoContactsPlaceholder.js +9 -0
  102. package/dist/collection/assets/svg/NoMessagePlaceholder.svg +13 -0
  103. package/dist/collection/assets/svg/PdfDocument.js +2 -0
  104. package/dist/collection/assets/svg/ProfilePlaceholder.js +1 -0
  105. package/dist/collection/assets/svg/SelectChatPlaceholder.js +13 -0
  106. package/dist/collection/assets/svg/Sun.svg +1 -0
  107. package/dist/collection/assets/svg/broadcast-selected.svg +4 -0
  108. package/dist/collection/assets/svg/broadcst-default.svg +4 -0
  109. package/dist/collection/assets/svg/close.svg +1 -0
  110. package/dist/collection/assets/svg/group.svg +7 -0
  111. package/dist/collection/assets/svg/login.svg +3051 -0
  112. package/dist/collection/assets/svg/message-add.svg +5 -0
  113. package/dist/collection/assets/svg/message-bold.svg +3 -0
  114. package/dist/collection/assets/svg/message-outline.svg +5 -0
  115. package/dist/collection/collection-manifest.json +32 -0
  116. package/dist/collection/components/ChatUIComponent/AddMember.js +144 -0
  117. package/dist/collection/components/ChatUIComponent/AddMember.js.map +1 -0
  118. package/dist/collection/components/ChatUIComponent/AudioBubble.js +528 -0
  119. package/dist/collection/components/ChatUIComponent/AudioBubble.js.map +1 -0
  120. package/dist/collection/components/ChatUIComponent/BlockChatList.js +114 -0
  121. package/dist/collection/components/ChatUIComponent/BlockChatList.js.map +1 -0
  122. package/dist/collection/components/ChatUIComponent/ChatDocumentMessageBubble.js +11 -0
  123. package/dist/collection/components/ChatUIComponent/ChatDocumentMessageBubble.js.map +1 -0
  124. package/dist/collection/components/ChatUIComponent/ChatImageMessageBubble.js +11 -0
  125. package/dist/collection/components/ChatUIComponent/ChatImageMessageBubble.js.map +1 -0
  126. package/dist/collection/components/ChatUIComponent/ChatOwnProfile/Profile.js +540 -0
  127. package/dist/collection/components/ChatUIComponent/ChatOwnProfile/Profile.js.map +1 -0
  128. package/dist/collection/components/ChatUIComponent/ChatOwnProfile/profile-page.css +252 -0
  129. package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js +1175 -0
  130. package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js.map +1 -0
  131. package/dist/collection/components/ChatUIComponent/ChatVideoMessageBubble.js +11 -0
  132. package/dist/collection/components/ChatUIComponent/ChatVideoMessageBubble.js.map +1 -0
  133. package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js +790 -0
  134. package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js.map +1 -0
  135. package/dist/collection/components/ChatUIComponent/ForwardMessageList.js +152 -0
  136. package/dist/collection/components/ChatUIComponent/ForwardMessageList.js.map +1 -0
  137. package/dist/collection/components/ChatUIComponent/GroupCast.js +218 -0
  138. package/dist/collection/components/ChatUIComponent/GroupCast.js.map +1 -0
  139. package/dist/collection/components/ChatUIComponent/Header/WebChatHeader.js +590 -0
  140. package/dist/collection/components/ChatUIComponent/Header/WebChatHeader.js.map +1 -0
  141. package/dist/collection/components/ChatUIComponent/ReactionContainer.js +103 -0
  142. package/dist/collection/components/ChatUIComponent/ReactionContainer.js.map +1 -0
  143. package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js +1352 -0
  144. package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js.map +1 -0
  145. package/dist/collection/components/ChatUIComponent/WebChatBody/web-chat-body.css +277 -0
  146. package/dist/collection/components/Login.js +118 -0
  147. package/dist/collection/components/Login.js.map +1 -0
  148. package/dist/collection/components/Signup.js +177 -0
  149. package/dist/collection/components/Signup.js.map +1 -0
  150. package/dist/collection/components/chat-main.js +131 -0
  151. package/dist/collection/components/chat-main.js.map +1 -0
  152. package/dist/collection/components/my-component/my-component.css +3 -0
  153. package/dist/collection/components/my-component/my-component.js +83 -0
  154. package/dist/collection/components/my-component/my-component.js.map +1 -0
  155. package/dist/collection/components/my-component/web-chat/WebChat.js +2686 -0
  156. package/dist/collection/components/my-component/web-chat/WebChat.js.map +1 -0
  157. package/dist/collection/components/my-component/web-chat/WebchatRightSide.js +675 -0
  158. package/dist/collection/components/my-component/web-chat/WebchatRightSide.js.map +1 -0
  159. package/dist/collection/components/my-component/web-chat/web-chat.css +336 -0
  160. package/dist/collection/components/theme-provider.js +182 -0
  161. package/dist/collection/components/theme-provider.js.map +1 -0
  162. package/dist/collection/constants/chat-assets.js +12 -0
  163. package/dist/collection/constants/chat-creds.js +31 -0
  164. package/dist/collection/constants/content.js +75 -0
  165. package/dist/collection/constants/urls.js +1 -0
  166. package/dist/collection/index.js +135 -0
  167. package/dist/collection/index.js.map +1 -0
  168. package/dist/collection/lib/helpers.js +205 -0
  169. package/dist/collection/lib/taguser.js +123 -0
  170. package/dist/collection/store/conversation.js +25 -0
  171. package/dist/collection/store/conversation.js.map +1 -0
  172. package/dist/collection/store/group-members.js +24 -0
  173. package/dist/collection/store/group-members.js.map +1 -0
  174. package/dist/collection/store/unread-count.js +18 -0
  175. package/dist/collection/store/unread-count.js.map +1 -0
  176. package/dist/collection/stories/Components/ActionsPopup/ActionsPopup.js +222 -0
  177. package/dist/collection/stories/Components/ActionsPopup/ActionsPopup.stories.js +148 -0
  178. package/dist/collection/stories/Components/AttachmentBox/AttachmentBox.js +211 -0
  179. package/dist/collection/stories/Components/AttachmentBox/AttachmentPreview/AttachmentPreview.js +708 -0
  180. package/dist/collection/stories/Components/AttachmentBox/AttachmentPreview/AttachmentPreview.stories.js +57 -0
  181. package/dist/collection/stories/Components/AttachmentBox/Attachmentbox.stories.js +74 -0
  182. package/dist/collection/stories/Components/AttachmentBox/CameraPreview.js +231 -0
  183. package/dist/collection/stories/Components/BlockUsers/BlockUsers.js +337 -0
  184. package/dist/collection/stories/Components/Body/Body.js +48 -0
  185. package/dist/collection/stories/Components/Body/Body.stories.js +33 -0
  186. package/dist/collection/stories/Components/Buttons/Buttons.js +65 -0
  187. package/dist/collection/stories/Components/Buttons/Buttons.stories.js +132 -0
  188. package/dist/collection/stories/Components/ChatSidebar/ChatSidebar.js +951 -0
  189. package/dist/collection/stories/Components/ChatSidebar/ChatSidebar.stories.js +75 -0
  190. package/dist/collection/stories/Components/ChatSidebar/ContextMenu.js +109 -0
  191. package/dist/collection/stories/Components/ChatTile/ChatTile.js +290 -0
  192. package/dist/collection/stories/Components/ChatTile/ChatTile.stories.js +180 -0
  193. package/dist/collection/stories/Components/Chip/Chip.js +111 -0
  194. package/dist/collection/stories/Components/Chip/Chip.stories.js +149 -0
  195. package/dist/collection/stories/Components/ContactInfo/ContactInfo.js +1491 -0
  196. package/dist/collection/stories/Components/ContactInfo/ContactInfo.stories.js +118 -0
  197. package/dist/collection/stories/Components/ContactInfo/MediaList.js +147 -0
  198. package/dist/collection/stories/Components/ContactInfo/ProfileInfo.js +1219 -0
  199. package/dist/collection/stories/Components/ContactTile/ContactTile.js +416 -0
  200. package/dist/collection/stories/Components/ContactTile/ContactTile.stories.js +60 -0
  201. package/dist/collection/stories/Components/Dialog-Drawer/confirm.js +113 -0
  202. package/dist/collection/stories/Components/Dialog-Drawer/deletemessage.js +97 -0
  203. package/dist/collection/stories/Components/Dialog-Drawer/dialog-drawer.js +264 -0
  204. package/dist/collection/stories/Components/EmojiReactions/EmojiReactions.js +179 -0
  205. package/dist/collection/stories/Components/Footer/Footer.js +4 -0
  206. package/dist/collection/stories/Components/Footer/Footer.stories.js +155 -0
  207. package/dist/collection/stories/Components/ForwardMessage/ForwardMessageContainer.js +433 -0
  208. package/dist/collection/stories/Components/ForwardMessage/ForwardMessageContainer.stories.js +110 -0
  209. package/dist/collection/stories/Components/ForwardMessage/ForwardUi.js +46 -0
  210. package/dist/collection/stories/Components/GroupChatContacts/GroupChatContacts.js +546 -0
  211. package/dist/collection/stories/Components/GroupChatContacts/GroupChatContacts.stories.js +56 -0
  212. package/dist/collection/stories/Components/GroupInfo/GroupInfo.js +394 -0
  213. package/dist/collection/stories/Components/GroupInfo/GroupInfo.stories.js +107 -0
  214. package/dist/collection/stories/Components/Head/ClosedHeader/ClosedHead.js +129 -0
  215. package/dist/collection/stories/Components/Head/ClosedHeader/ClosedHead.stories.js +78 -0
  216. package/dist/collection/stories/Components/Head/Head.js +672 -0
  217. package/dist/collection/stories/Components/Head/Head.stories.js +91 -0
  218. package/dist/collection/stories/Components/Icon/Icon.js +115 -0
  219. package/dist/collection/stories/Components/Image/Image.js +41 -0
  220. package/dist/collection/stories/Components/Image/Image.stories.js +49 -0
  221. package/dist/collection/stories/Components/Image/Img.stories.js +178 -0
  222. package/dist/collection/stories/Components/Inputbox/Input.js +206 -0
  223. package/dist/collection/stories/Components/Inputbox/Input.stories.js +87 -0
  224. package/dist/collection/stories/Components/InstagramAccounts/InstagramAccountsPanel.js +605 -0
  225. package/dist/collection/stories/Components/Loader/Spinner/Spinner.js +60 -0
  226. package/dist/collection/stories/Components/Loader/Spinner/Spinner.stories.js +38 -0
  227. package/dist/collection/stories/Components/MainPlaceHolder/MainChatPlaceHolder.js +78 -0
  228. package/dist/collection/stories/Components/MainPlaceHolder/MainPlaceHolder.stories.js +130 -0
  229. package/dist/collection/stories/Components/MediaGallery/MediaGallery.js +868 -0
  230. package/dist/collection/stories/Components/MediaGallery/MediaGallery.stories.js +81 -0
  231. package/dist/collection/stories/Components/MembersList/MembersList.js +348 -0
  232. package/dist/collection/stories/Components/MessageBubble/AudioMessageBubble/AudioMesaageBubble.js +533 -0
  233. package/dist/collection/stories/Components/MessageBubble/DocumentMessageBubble/DocumentMessageBubble.js +484 -0
  234. package/dist/collection/stories/Components/MessageBubble/DocumentMessageBubble/DocumentMessageBubble.stories.js +54 -0
  235. package/dist/collection/stories/Components/MessageBubble/ImageMessageBubble/ImageMessageBubble.js +683 -0
  236. package/dist/collection/stories/Components/MessageBubble/ImageMessageBubble/ImageMessageBubble.stories.js +49 -0
  237. package/dist/collection/stories/Components/MessageBubble/IncomingTextMessageBubble/IncomingTextMessageBubble.js +450 -0
  238. package/dist/collection/stories/Components/MessageBubble/IncomingTextMessageBubble/IncomingTextMessageBubble.stories.js +56 -0
  239. package/dist/collection/stories/Components/MessageBubble/LinkMessageBubble/LinkMessageBubble.js +721 -0
  240. package/dist/collection/stories/Components/MessageBubble/OutgoingTextMessageBubble/OutgoingTextMessageBubble.js +139 -0
  241. package/dist/collection/stories/Components/MessageBubble/OutgoingTextMessageBubble/OutgoingTextMessageBubble.stories.js +63 -0
  242. package/dist/collection/stories/Components/MessageBubble/VideoMessageBubble/VideoMessageBubble.js +576 -0
  243. package/dist/collection/stories/Components/MessageBubble/VideoMessageBubble/VideoMessageBubble.stories.js +50 -0
  244. package/dist/collection/stories/Components/MessageDatePill/MessageDatePill.js +66 -0
  245. package/dist/collection/stories/Components/MessageDatePill/MessageDatePill.stories.js +48 -0
  246. package/dist/collection/stories/Components/MessageInfo/MessageInfo.js +465 -0
  247. package/dist/collection/stories/Components/MessageInfo/MessageInfo.stories.js +111 -0
  248. package/dist/collection/stories/Components/MessageSearch/MessageSearch.js +242 -0
  249. package/dist/collection/stories/Components/MessageSearchBar/SearchBar.js +523 -0
  250. package/dist/collection/stories/Components/MessageSearchBar/SearchBar.stories.js +98 -0
  251. package/dist/collection/stories/Components/MessageUnreadCount/MessageUnreadCount.js +51 -0
  252. package/dist/collection/stories/Components/MessageUnreadCount/MessageUnreadCount.stories.js +79 -0
  253. package/dist/collection/stories/Components/NewChatSidebar/NewChatSidebar.js +560 -0
  254. package/dist/collection/stories/Components/NewChatSidebar/NewChatSidebar.stories.js +56 -0
  255. package/dist/collection/stories/Components/Placeholder/NoContactsPlaceholder.js +57 -0
  256. package/dist/collection/stories/Components/Popup/ConfirmationPopup/DeleteConfirmationPopup/DeletePopup.js +114 -0
  257. package/dist/collection/stories/Components/ProfileSidebar/ProfileSidebar.js +166 -0
  258. package/dist/collection/stories/Components/ProfileSidebar/ProfileSidebar.stories.js +125 -0
  259. package/dist/collection/stories/Components/ProfileTab/ProfileTab.js +939 -0
  260. package/dist/collection/stories/Components/ProfileTab/ProfileTab.stories.js +144 -0
  261. package/dist/collection/stories/Components/ReactionsContainer/ReactionsContainer.js +166 -0
  262. package/dist/collection/stories/Components/ReactionsContainer/ReactionsContainer.stories.js +115 -0
  263. package/dist/collection/stories/Components/ReactionsContainer/ReactionsInfoCard/ReactionsInfoCard.js +98 -0
  264. package/dist/collection/stories/Components/ReactionsContainer/ReactionsInfoCard/ReactionsInfoCard.stories.js +55 -0
  265. package/dist/collection/stories/Components/ReadMark/BlueReadMark/BlueReadMark.js +27 -0
  266. package/dist/collection/stories/Components/ReadMark/BlueReadMark/BlueReadMark.stories.js +28 -0
  267. package/dist/collection/stories/Components/ReadMark/ClockMark/ClockMark.js +26 -0
  268. package/dist/collection/stories/Components/ReadMark/ClockMark/ClockMark.stories.js +33 -0
  269. package/dist/collection/stories/Components/ReadMark/DoubleMark/DoubleMark.js +27 -0
  270. package/dist/collection/stories/Components/ReadMark/DoubleMark/DoubleMark.stories.js +28 -0
  271. package/dist/collection/stories/Components/ReadMark/SingleMark/SingleMark.js +38 -0
  272. package/dist/collection/stories/Components/ReadMark/SingleMark/SingleMark.stories.js +33 -0
  273. package/dist/collection/stories/Components/ReplyBlock/MediaIcons.js +16 -0
  274. package/dist/collection/stories/Components/ReplyBlock/ReplyBlock.js +196 -0
  275. package/dist/collection/stories/Components/ReplyBlock/ReplyBlock.stories.js +57 -0
  276. package/dist/collection/stories/Components/ReplyMessageContainer/ReplyMessageContainer.js +645 -0
  277. package/dist/collection/stories/Components/ReplyMessageContainer/ReplyMessageContainer.stories.js +58 -0
  278. package/dist/collection/stories/Components/SearchableList/SearchableList.js +393 -0
  279. package/dist/collection/stories/Components/SearchableList/SearchableList.stories.js +65 -0
  280. package/dist/collection/stories/Components/SharePopup/SharePopup.js +152 -0
  281. package/dist/collection/stories/Components/SharePopup/SharePopup.stories.js +47 -0
  282. package/dist/collection/stories/Components/Splitscreen/Splitscreen.js +157 -0
  283. package/dist/collection/stories/Components/Splitscreen/Splitscreen.stories.js +100 -0
  284. package/dist/collection/stories/Components/TestFooter/MentionUserList.js +194 -0
  285. package/dist/collection/stories/Components/TestFooter/TestFooter.js +1339 -0
  286. package/dist/collection/stories/Components/TestFooter/TestFooter.stories.js +89 -0
  287. package/dist/collection/stories/Components/Text/Text.js +57 -0
  288. package/dist/collection/stories/Components/Text/Text.stories.js +83 -0
  289. package/dist/collection/stories/Components/TextStyle/TextStyle.js +38 -0
  290. package/dist/collection/stories/Components/TextStyle/TextStyle.stories.js +50 -0
  291. package/dist/collection/stories/Components/Time/Timestamp.js +50 -0
  292. package/dist/collection/stories/Components/Time/Timestamp.stories.js +34 -0
  293. package/dist/collection/stories/Components/Toaster/Toaster.js +94 -0
  294. package/dist/collection/stories/Components/Toaster/Toaster.stories.js +108 -0
  295. package/dist/collection/stories/Components/Toaster/toast-helper.js +79 -0
  296. package/dist/collection/stories/Components/Toaster/toast-helper.js.map +1 -0
  297. package/dist/collection/stories/Components/final/final.js +86 -0
  298. package/dist/collection/stories/Components/final/final.stories.js +30 -0
  299. package/dist/collection/stories/assets/SEARCH ICON.svg +1 -0
  300. package/dist/collection/types/ConversationDetailsTypes.js +2 -0
  301. package/dist/collection/types/ConversationDetailsTypes.js.map +1 -0
  302. package/dist/collection/utils/chatSdk.js +14 -0
  303. package/dist/collection/utils/getFomattedDate.js +34 -0
  304. package/dist/collection/utils/getFomattedDate.js.map +1 -0
  305. package/dist/collection/utils/unixTimeConverter.js +28 -0
  306. package/dist/collection/utils/utils.js +4 -0
  307. package/dist/collection/utils/utils.js.map +1 -0
  308. package/dist/esm/BlockChatList-9fc3a42b.js +421 -0
  309. package/dist/esm/BlockChatList-9fc3a42b.js.map +1 -0
  310. package/dist/esm/DocumentMessageBubble-b67726f2.js +491 -0
  311. package/dist/esm/DocumentMessageBubble-b67726f2.js.map +1 -0
  312. package/dist/esm/Image-bb9efda3.js +121 -0
  313. package/dist/esm/Image-bb9efda3.js.map +1 -0
  314. package/dist/esm/ImageMessageBubble-0e473f6e.js +673 -0
  315. package/dist/esm/ImageMessageBubble-0e473f6e.js.map +1 -0
  316. package/dist/esm/IsometrikLogo-14db76af.js +42 -0
  317. package/dist/esm/IsometrikLogo-14db76af.js.map +1 -0
  318. package/dist/esm/MessageSearch-4101a627.js +5875 -0
  319. package/dist/esm/MessageSearch-4101a627.js.map +1 -0
  320. package/dist/esm/ReactionsContainer-bdd74a3c.js +373 -0
  321. package/dist/esm/ReactionsContainer-bdd74a3c.js.map +1 -0
  322. package/dist/esm/Text-3b0b3898.js +58 -0
  323. package/dist/esm/Text-3b0b3898.js.map +1 -0
  324. package/dist/esm/VideoMessageBubble-88a7a53e.js +569 -0
  325. package/dist/esm/VideoMessageBubble-88a7a53e.js.map +1 -0
  326. package/dist/esm/WebChat-5448d615.js +2882 -0
  327. package/dist/esm/WebChat-5448d615.js.map +1 -0
  328. package/dist/esm/app-globals-0f993ce5.js +5 -0
  329. package/dist/esm/app-globals-0f993ce5.js.map +1 -0
  330. package/dist/esm/audio-bubble_8.entry.js +21001 -0
  331. package/dist/esm/audio-bubble_8.entry.js.map +1 -0
  332. package/dist/esm/block-chat-list.entry.js +8 -0
  333. package/dist/esm/block-chat-list.entry.js.map +1 -0
  334. package/dist/esm/chat-app.entry.js +51 -0
  335. package/dist/esm/chat-app.entry.js.map +1 -0
  336. package/dist/esm/chat-assets-bd8778d5.js +6 -0
  337. package/dist/esm/chat-assets-bd8778d5.js.map +1 -0
  338. package/dist/esm/chat-creds-ff086f05.js +35 -0
  339. package/dist/esm/chat-creds-ff086f05.js.map +1 -0
  340. package/dist/esm/chat-document-message-bubble.entry.js +20 -0
  341. package/dist/esm/chat-document-message-bubble.entry.js.map +1 -0
  342. package/dist/esm/chat-image-message-bubble.entry.js +22 -0
  343. package/dist/esm/chat-image-message-bubble.entry.js.map +1 -0
  344. package/dist/esm/chat-video-message-bubble.entry.js +20 -0
  345. package/dist/esm/chat-video-message-bubble.entry.js.map +1 -0
  346. package/dist/esm/content-5aea5e39.js +79 -0
  347. package/dist/esm/content-5aea5e39.js.map +1 -0
  348. package/dist/esm/dialog-drawer-9fa083b1.js +5304 -0
  349. package/dist/esm/dialog-drawer-9fa083b1.js.map +1 -0
  350. package/dist/esm/forward-memebers.entry.js +124 -0
  351. package/dist/esm/forward-memebers.entry.js.map +1 -0
  352. package/dist/esm/group-members-bb3c8db7.js +37 -0
  353. package/dist/esm/group-members-bb3c8db7.js.map +1 -0
  354. package/dist/esm/groupcast-d1c54a27.js +187 -0
  355. package/dist/esm/groupcast-d1c54a27.js.map +1 -0
  356. package/dist/esm/imagePlaceholder-e544f70b.js +4360 -0
  357. package/dist/esm/imagePlaceholder-e544f70b.js.map +1 -0
  358. package/dist/esm/index-fddf30b7.js +3093 -0
  359. package/dist/esm/index-fddf30b7.js.map +1 -0
  360. package/dist/esm/index.js +139 -0
  361. package/dist/esm/index.js.map +1 -0
  362. package/dist/esm/isometrik-webchat.js +49 -0
  363. package/dist/esm/isometrik-webchat.js.map +1 -0
  364. package/dist/esm/loader.js +13 -0
  365. package/dist/esm/loader.js.map +1 -0
  366. package/dist/esm/login-page.entry.js +81 -0
  367. package/dist/esm/login-page.entry.js.map +1 -0
  368. package/dist/esm/member-add.entry.js +118 -0
  369. package/dist/esm/member-add.entry.js.map +1 -0
  370. package/dist/esm/message-reaction-ad47ea1a.js +20 -0
  371. package/dist/esm/message-reaction-ad47ea1a.js.map +1 -0
  372. package/dist/esm/my-component.entry.js +25 -0
  373. package/dist/esm/my-component.entry.js.map +1 -0
  374. package/dist/esm/reaction-container.entry.js +48 -0
  375. package/dist/esm/reaction-container.entry.js.map +1 -0
  376. package/dist/esm/shadow-css-7ad5caf8.js +334 -0
  377. package/dist/esm/shadow-css-7ad5caf8.js.map +1 -0
  378. package/dist/esm/signup-page.entry.js +139 -0
  379. package/dist/esm/signup-page.entry.js.map +1 -0
  380. package/dist/esm/taguser-e9032d65.js +510 -0
  381. package/dist/esm/taguser-e9032d65.js.map +1 -0
  382. package/dist/esm/theme-provider_2.entry.js +108 -0
  383. package/dist/esm/theme-provider_2.entry.js.map +1 -0
  384. package/dist/esm/toast-helper-840fd8dc.js +82 -0
  385. package/dist/esm/toast-helper-840fd8dc.js.map +1 -0
  386. package/dist/esm/utils-11fcde98.js +7 -0
  387. package/dist/esm/utils-11fcde98.js.map +1 -0
  388. package/dist/index.cjs.js +1 -0
  389. package/dist/index.js +1 -0
  390. package/dist/isometrik-webchat/index.esm.js +2 -0
  391. package/dist/isometrik-webchat/index.esm.js.map +1 -0
  392. package/dist/isometrik-webchat/isometrik-webchat.css +2 -0
  393. package/dist/isometrik-webchat/isometrik-webchat.esm.js +2 -0
  394. package/dist/isometrik-webchat/isometrik-webchat.esm.js.map +1 -0
  395. package/dist/isometrik-webchat/p-12774661.js +2 -0
  396. package/dist/isometrik-webchat/p-12774661.js.map +1 -0
  397. package/dist/isometrik-webchat/p-12e56271.js +549 -0
  398. package/dist/isometrik-webchat/p-12e56271.js.map +1 -0
  399. package/dist/isometrik-webchat/p-1415e589.js +2 -0
  400. package/dist/isometrik-webchat/p-1415e589.js.map +1 -0
  401. package/dist/isometrik-webchat/p-18f8d210.js +13 -0
  402. package/dist/isometrik-webchat/p-18f8d210.js.map +1 -0
  403. package/dist/isometrik-webchat/p-1b2461f4.js +357 -0
  404. package/dist/isometrik-webchat/p-1b2461f4.js.map +1 -0
  405. package/dist/isometrik-webchat/p-229095d4.js +2 -0
  406. package/dist/isometrik-webchat/p-229095d4.js.map +1 -0
  407. package/dist/isometrik-webchat/p-2953d06a.entry.js +2 -0
  408. package/dist/isometrik-webchat/p-2953d06a.entry.js.map +1 -0
  409. package/dist/isometrik-webchat/p-3004a123.js +2 -0
  410. package/dist/isometrik-webchat/p-3004a123.js.map +1 -0
  411. package/dist/isometrik-webchat/p-3044698a.js +2 -0
  412. package/dist/isometrik-webchat/p-3044698a.js.map +1 -0
  413. package/dist/isometrik-webchat/p-40517d7f.js +1098 -0
  414. package/dist/isometrik-webchat/p-40517d7f.js.map +1 -0
  415. package/dist/isometrik-webchat/p-42a62cf2.js +2 -0
  416. package/dist/isometrik-webchat/p-42a62cf2.js.map +1 -0
  417. package/dist/isometrik-webchat/p-48e1d174.js +45 -0
  418. package/dist/isometrik-webchat/p-48e1d174.js.map +1 -0
  419. package/dist/isometrik-webchat/p-48e243ec.entry.js +2 -0
  420. package/dist/isometrik-webchat/p-48e243ec.entry.js.map +1 -0
  421. package/dist/isometrik-webchat/p-4d2aca06.js +257 -0
  422. package/dist/isometrik-webchat/p-4d2aca06.js.map +1 -0
  423. package/dist/isometrik-webchat/p-610bfd8a.js +2 -0
  424. package/dist/isometrik-webchat/p-610bfd8a.js.map +1 -0
  425. package/dist/isometrik-webchat/p-674e4bb0.js +9 -0
  426. package/dist/isometrik-webchat/p-674e4bb0.js.map +1 -0
  427. package/dist/isometrik-webchat/p-8490e13d.js +192 -0
  428. package/dist/isometrik-webchat/p-8490e13d.js.map +1 -0
  429. package/dist/isometrik-webchat/p-858b0da8.entry.js +2 -0
  430. package/dist/isometrik-webchat/p-858b0da8.entry.js.map +1 -0
  431. package/dist/isometrik-webchat/p-89108249.entry.js +5010 -0
  432. package/dist/isometrik-webchat/p-89108249.entry.js.map +1 -0
  433. package/dist/isometrik-webchat/p-8dcdea59.js +2963 -0
  434. package/dist/isometrik-webchat/p-8dcdea59.js.map +1 -0
  435. package/dist/isometrik-webchat/p-92d0b21c.js +2 -0
  436. package/dist/isometrik-webchat/p-92d0b21c.js.map +1 -0
  437. package/dist/isometrik-webchat/p-ada9c8e8.entry.js +2 -0
  438. package/dist/isometrik-webchat/p-ada9c8e8.entry.js.map +1 -0
  439. package/dist/isometrik-webchat/p-adbb398d.entry.js +2 -0
  440. package/dist/isometrik-webchat/p-adbb398d.entry.js.map +1 -0
  441. package/dist/isometrik-webchat/p-b07dd267.js +2 -0
  442. package/dist/isometrik-webchat/p-b07dd267.js.map +1 -0
  443. package/dist/isometrik-webchat/p-bf0aeb22.entry.js +2 -0
  444. package/dist/isometrik-webchat/p-bf0aeb22.entry.js.map +1 -0
  445. package/dist/isometrik-webchat/p-bfd51dd4.entry.js +2 -0
  446. package/dist/isometrik-webchat/p-bfd51dd4.entry.js.map +1 -0
  447. package/dist/isometrik-webchat/p-c50aa410.entry.js +2 -0
  448. package/dist/isometrik-webchat/p-c50aa410.entry.js.map +1 -0
  449. package/dist/isometrik-webchat/p-cd34448c.entry.js +2 -0
  450. package/dist/isometrik-webchat/p-cd34448c.entry.js.map +1 -0
  451. package/dist/isometrik-webchat/p-d4b8ece6.entry.js +2 -0
  452. package/dist/isometrik-webchat/p-d4b8ece6.entry.js.map +1 -0
  453. package/dist/isometrik-webchat/p-de8a8642.js +197 -0
  454. package/dist/isometrik-webchat/p-de8a8642.js.map +1 -0
  455. package/dist/isometrik-webchat/p-e09b32eb.js +591 -0
  456. package/dist/isometrik-webchat/p-e09b32eb.js.map +1 -0
  457. package/dist/isometrik-webchat/p-e1255160.js +2 -0
  458. package/dist/isometrik-webchat/p-e1255160.js.map +1 -0
  459. package/dist/isometrik-webchat/p-e3731295.js +274 -0
  460. package/dist/isometrik-webchat/p-e3731295.js.map +1 -0
  461. package/dist/isometrik-webchat/p-e4efea64.entry.js +2 -0
  462. package/dist/isometrik-webchat/p-e4efea64.entry.js.map +1 -0
  463. package/dist/isometrik-webchat/p-ef6e482a.entry.js +2 -0
  464. package/dist/isometrik-webchat/p-ef6e482a.entry.js.map +1 -0
  465. package/dist/isometrik-webchat/p-f1f5d5bd.js +3 -0
  466. package/dist/isometrik-webchat/p-f1f5d5bd.js.map +1 -0
  467. package/dist/isometrik-webchat/p-ff9f3dfe.js +203 -0
  468. package/dist/isometrik-webchat/p-ff9f3dfe.js.map +1 -0
  469. package/dist/loader/cdn.js +1 -0
  470. package/dist/loader/index.cjs.js +1 -0
  471. package/dist/loader/index.d.ts +24 -0
  472. package/dist/loader/index.es2017.js +1 -0
  473. package/dist/loader/index.js +2 -0
  474. package/dist/loader/package.json +11 -0
  475. package/dist/types/app-root.d.ts +0 -0
  476. package/dist/types/components/ChatUIComponent/AddMember.d.ts +13 -0
  477. package/dist/types/components/ChatUIComponent/AudioBubble.d.ts +39 -0
  478. package/dist/types/components/ChatUIComponent/BlockChatList.d.ts +13 -0
  479. package/dist/types/components/ChatUIComponent/ChatDocumentMessageBubble.d.ts +5 -0
  480. package/dist/types/components/ChatUIComponent/ChatImageMessageBubble.d.ts +5 -0
  481. package/dist/types/components/ChatUIComponent/ChatOwnProfile/Profile.d.ts +42 -0
  482. package/dist/types/components/ChatUIComponent/ChatSidebar/ChatSidebar.d.ts +85 -0
  483. package/dist/types/components/ChatUIComponent/ChatVideoMessageBubble.d.ts +5 -0
  484. package/dist/types/components/ChatUIComponent/Footer/ChatFooter.d.ts +154 -0
  485. package/dist/types/components/ChatUIComponent/ForwardMessageList.d.ts +15 -0
  486. package/dist/types/components/ChatUIComponent/GroupCast.d.ts +26 -0
  487. package/dist/types/components/ChatUIComponent/Header/WebChatHeader.d.ts +45 -0
  488. package/dist/types/components/ChatUIComponent/ReactionContainer.d.ts +12 -0
  489. package/dist/types/components/ChatUIComponent/WebChatBody/WebChatBody.d.ts +120 -0
  490. package/dist/types/components/Login.d.ts +13 -0
  491. package/dist/types/components/Signup.d.ts +17 -0
  492. package/dist/types/components/chat-main.d.ts +15 -0
  493. package/dist/types/components/my-component/my-component.d.ts +16 -0
  494. package/dist/types/components/my-component/web-chat/WebchatRightSide.d.ts +42 -0
  495. package/dist/types/components/theme-provider.d.ts +44 -0
  496. package/dist/types/components.d.ts +838 -0
  497. package/dist/types/index.d.ts +37 -0
  498. package/dist/types/stencil-public-runtime.d.ts +1678 -0
  499. package/dist/types/store/conversation.d.ts +17 -0
  500. package/dist/types/store/group-members.d.ts +18 -0
  501. package/dist/types/store/unread-count.d.ts +10 -0
  502. package/dist/types/stories/Components/Toaster/toast-helper.d.ts +8 -0
  503. package/dist/types/types/ConversationDetailsTypes.d.ts +52 -0
  504. package/dist/types/utils/getFomattedDate.d.ts +1 -0
  505. package/dist/types/utils/utils.d.ts +1 -0
  506. package/package.json +89 -0
  507. package/readme.md +569 -0
@@ -0,0 +1,2686 @@
1
+ import { h, Fragment } from "@stencil/core";
2
+ import ChatSDK from "test-iso-chat-sdk";
3
+ import { CHAT_CREDS, MQTT_CREDS } from "../../../constants/chat-creds";
4
+ import { getDeviceID, getGroupcastUrlQuery } from "../../../lib/helpers";
5
+ import "../../../stories/Components/Loader/Spinner/Spinner";
6
+ import { getConversationEligibleMembers, removeConversationMember } from "../../../api/group-members.js";
7
+ import { showToast } from "../../../stories/Components/Toaster/toast-helper";
8
+ import "../../ChatUIComponent/ChatOwnProfile/Profile";
9
+ import "../../../stories/Components/ProfileSidebar/ProfileSidebar";
10
+ import "../../../stories/Components/InstagramAccounts/InstagramAccountsPanel";
11
+ import "../../../stories/Components/ContactInfo/ContactInfo";
12
+ import "./WebchatRightSide";
13
+ import "../../../stories/Components/MainPlaceHolder/MainChatPlaceHolder";
14
+ import { getTotalUnreadConversationsCount } from "../../../api/conversations.js";
15
+ import { unreadCountStore } from "../../../store/unread-count";
16
+ import { groupMembersStore } from "../../../store/group-members";
17
+ import { WEB_CONTENT } from "../../../constants/content";
18
+ import { getGroupcast, getGroupcastMessage, deleteGroupCast, getGroupcastMembers, removeGroupcastMember } from "../../../api/groupcast.js";
19
+ import { drawerDialogService } from "../../../stories/Components/Dialog-Drawer/dialog-drawer.js";
20
+ import { connectSocialAccountCallback, clearSocialCallbackParamsFromUrl, notifyOpenerIfSocialPopupCallback, parseSocialCallbackParams, getSocialAccounts, hasConnectedInstagramAccounts } from "../../../api/social-accounts.js";
21
+ export class WebChat {
22
+ constructor() {
23
+ this.chatBodyRef = null;
24
+ this.conversationDetailsInterval = null;
25
+ this.SIDEBAR_MIN = 280;
26
+ this.SIDEBAR_MAX = 560;
27
+ this.SIDEBAR_RAIL = 68;
28
+ this.SIDEBAR_WIDTH_KEY = 'isometrik-sidebar-list-width';
29
+ this.sidebarResizeOriginLeft = 0;
30
+ this.clampSidebarWidth = (width) => {
31
+ const maxByViewport = Math.floor(window.innerWidth * 0.55) - this.SIDEBAR_RAIL;
32
+ const max = Math.min(this.SIDEBAR_MAX, Math.max(this.SIDEBAR_MIN, maxByViewport));
33
+ return Math.min(Math.max(Math.round(width), this.SIDEBAR_MIN), max);
34
+ };
35
+ this.onSidebarResizeMove = (e) => {
36
+ if (!this.isResizingSidebar)
37
+ return;
38
+ this.sidebarListWidth = this.clampSidebarWidth(e.clientX - this.sidebarResizeOriginLeft - this.SIDEBAR_RAIL);
39
+ };
40
+ this.onSidebarResizeEnd = () => {
41
+ if (!this.isResizingSidebar)
42
+ return;
43
+ this.isResizingSidebar = false;
44
+ try {
45
+ localStorage.setItem(this.SIDEBAR_WIDTH_KEY, String(this.sidebarListWidth));
46
+ }
47
+ catch (_) { }
48
+ window.removeEventListener('pointermove', this.onSidebarResizeMove);
49
+ window.removeEventListener('pointerup', this.onSidebarResizeEnd);
50
+ };
51
+ this.startSidebarResize = (e) => {
52
+ var _a;
53
+ if (this.isMobileView)
54
+ return;
55
+ e.preventDefault();
56
+ const handle = e.currentTarget;
57
+ const sidebar = handle.closest('.chat-sidebar-container');
58
+ this.sidebarResizeOriginLeft = (_a = sidebar === null || sidebar === void 0 ? void 0 : sidebar.getBoundingClientRect().left) !== null && _a !== void 0 ? _a : 0;
59
+ this.isResizingSidebar = true;
60
+ window.addEventListener('pointermove', this.onSidebarResizeMove);
61
+ window.addEventListener('pointerup', this.onSidebarResizeEnd);
62
+ };
63
+ this.handleReplyMessage = (e) => {
64
+ this.replyMessage = e.detail;
65
+ };
66
+ this.handleremoveReplyMessage = () => {
67
+ this.replyMessage = null;
68
+ };
69
+ this.handleMessageSearchTextChange = (e) => {
70
+ this.messageSearchText = e.detail;
71
+ };
72
+ this.getCookie = (name) => {
73
+ const value = `; ${document.cookie}`;
74
+ const parts = value.split(`; ${name}=`);
75
+ if (parts.length === 2)
76
+ return parts.pop().split(';').shift();
77
+ };
78
+ // Auth from chat-creds (no login UI)
79
+ this.userTokenFromCookie = CHAT_CREDS.userToken;
80
+ this.isometrikUserIdFromCookie = CHAT_CREDS.isometrikUserId;
81
+ this.clearConversationState = () => {
82
+ this.allConversationList = [];
83
+ this.selectedConversationId = null;
84
+ this.initialConversationIdFromURL = '';
85
+ this.allMessages = [];
86
+ this.selectConversationMessages = [];
87
+ this.conversationMetaData = {};
88
+ this.selctConversationMetaData = {};
89
+ this.allAttachments = [];
90
+ this.selectConverSationAttachments = [];
91
+ this.unreadConversationsCount = 0;
92
+ this.hasMoreConversations = false;
93
+ this.isContactInfoOpen = false;
94
+ this.isProfileInfoOpen = false;
95
+ this.showRightSideBar = false;
96
+ unreadCountStore.updateTotalUnreadCount(0);
97
+ if (typeof window !== 'undefined') {
98
+ const url = new URL(window.location.href);
99
+ url.searchParams.delete('conversation');
100
+ url.searchParams.delete('groupcast');
101
+ window.history.replaceState({}, '', url);
102
+ }
103
+ };
104
+ this.applyInstagramAccounts = (accounts = [], options = {}) => {
105
+ const connected = hasConnectedInstagramAccounts(accounts);
106
+ const wasConnected = this.isInstagramConnected;
107
+ this.isInstagramConnected = connected;
108
+ if (!connected) {
109
+ this.clearConversationState();
110
+ this.activeTab = 'Accounts';
111
+ return;
112
+ }
113
+ // After a live connect (not initial boot), switch to Chat and fetch conversations.
114
+ if (!options.bootstrap && !wasConnected) {
115
+ this.activeTab = 'Chat';
116
+ void this.loadConversationsAfterInstagramConnect();
117
+ }
118
+ };
119
+ this.refreshInstagramConnectionGate = async () => {
120
+ const data = await getSocialAccounts({ platform: 'instagram' });
121
+ this.applyInstagramAccounts((data === null || data === void 0 ? void 0 : data.accounts) || [], { bootstrap: true });
122
+ };
123
+ this.loadConversationsAfterInstagramConnect = async () => {
124
+ if (!this.isInstagramConnected)
125
+ return;
126
+ try {
127
+ this.isConversationLoading = true;
128
+ const unreadCount = await getTotalUnreadConversationsCount();
129
+ unreadCountStore.updateTotalUnreadCount(unreadCount);
130
+ this.unreadConversationsCount = unreadCount;
131
+ unreadCountStore.onChange('totalUnreadCount', value => {
132
+ this.unreadConversationsCount = value;
133
+ });
134
+ await this.getConversations();
135
+ }
136
+ catch (error) {
137
+ console.error('Failed to load conversations after Instagram connect:', error);
138
+ }
139
+ finally {
140
+ this.isConversationLoading = false;
141
+ }
142
+ };
143
+ this.handleInstagramAccountsChange = (accounts = []) => {
144
+ this.applyInstagramAccounts(accounts);
145
+ };
146
+ this.openChatTab = () => {
147
+ if (this.isInstagramConnected) {
148
+ this.activeTab = 'Chat';
149
+ return;
150
+ }
151
+ this.activeTab = 'Accounts';
152
+ };
153
+ this.closeAccountsDrawer = () => {
154
+ this.activeTab = this.isInstagramConnected ? 'Chat' : 'Accounts';
155
+ };
156
+ /// for get user details start
157
+ this.getUserDetails = async () => {
158
+ var _a, _b, _c;
159
+ try {
160
+ const res = await ChatSDK.getInstance().user.getUserDetails();
161
+ const userDetails = {
162
+ //@ts-ignore
163
+ userId: (res === null || res === void 0 ? void 0 : res.userId) || '',
164
+ userIdentifier: (res === null || res === void 0 ? void 0 : res.userIdentifier) || '',
165
+ //@ts-ignore
166
+ firstName: ((_a = res === null || res === void 0 ? void 0 : res.metaData) === null || _a === void 0 ? void 0 : _a.firstName) || '',
167
+ //@ts-ignore
168
+ lastName: ((_b = res === null || res === void 0 ? void 0 : res.metaData) === null || _b === void 0 ? void 0 : _b.lastName) || '',
169
+ updatedAt: (res === null || res === void 0 ? void 0 : res.updatedAt) || '',
170
+ userName: (res === null || res === void 0 ? void 0 : res.userName) || '',
171
+ online: (res === null || res === void 0 ? void 0 : res.online) || '',
172
+ userProfileImageUrl: (res === null || res === void 0 ? void 0 : res.userProfileImageUrl) || '',
173
+ //@ts-ignore
174
+ profilePic: ((_c = res === null || res === void 0 ? void 0 : res.metaData) === null || _c === void 0 ? void 0 : _c.profilePic) || '',
175
+ };
176
+ this.userMetaData = userDetails;
177
+ }
178
+ catch (error) {
179
+ console.error(error, 'getUserDetails fetching error');
180
+ }
181
+ };
182
+ /// for get user details end
183
+ /** Completes Instagram OAuth when redirected back with zernioAccountId. */
184
+ this.handleSocialConnectCallback = async () => {
185
+ // Popup return: hand off to opener and close this window
186
+ if (notifyOpenerIfSocialPopupCallback())
187
+ return;
188
+ const payload = parseSocialCallbackParams();
189
+ if (!payload)
190
+ return;
191
+ try {
192
+ await connectSocialAccountCallback({
193
+ platform: payload.platform || 'instagram',
194
+ username: payload.username || '',
195
+ displayName: payload.displayName || '',
196
+ loginMethod: 'instagram_login',
197
+ });
198
+ showToast({
199
+ message: 'Instagram connected',
200
+ type: 'success',
201
+ position: 'bottom-right',
202
+ });
203
+ this.activeTab = 'Chat';
204
+ }
205
+ catch (error) {
206
+ console.error('Social connect callback failed:', error);
207
+ showToast({
208
+ message: (error === null || error === void 0 ? void 0 : error.message) || 'Failed to connect Instagram',
209
+ type: 'error',
210
+ position: 'bottom-right',
211
+ });
212
+ }
213
+ finally {
214
+ clearSocialCallbackParamsFromUrl();
215
+ }
216
+ };
217
+ //get all Conversation
218
+ this.getConversations = async (skip = 0, searchTag = null, showLoader = false) => {
219
+ this.hasMoreConversations = true;
220
+ const queryParamsGetConversations = {
221
+ limit: 20,
222
+ skip: skip,
223
+ includeMembers: true,
224
+ };
225
+ if (searchTag) {
226
+ queryParamsGetConversations['searchTag'] = searchTag;
227
+ }
228
+ if (showLoader) {
229
+ this.isLoadingConversationList = true;
230
+ }
231
+ try {
232
+ const res = await ChatSDK.getInstance().Conversation.getConversations(queryParamsGetConversations);
233
+ const uniqueConversations = res.conversations.filter(newConv => !this.allConversationList.some(existingConv => existingConv.conversationId === newConv.conversationId));
234
+ this.allConversationList = [...this.allConversationList, ...uniqueConversations];
235
+ }
236
+ catch (error) {
237
+ console.error('getConversations fetching error', error);
238
+ if ((error === null || error === void 0 ? void 0 : error.status) === 404 || (error === null || error === void 0 ? void 0 : error.statusCode) === 404) {
239
+ this.hasMoreConversations = false;
240
+ }
241
+ }
242
+ finally {
243
+ this.isLoadingConversationList = false;
244
+ }
245
+ };
246
+ //get all Conversation end
247
+ this.getGroupCastConversationDetails = async (groupcastId) => {
248
+ var _a;
249
+ try {
250
+ const res = await getGroupcast({ ids: groupcastId });
251
+ this.conversationMetaData = (_a = res === null || res === void 0 ? void 0 : res.groupcasts) === null || _a === void 0 ? void 0 : _a[0];
252
+ }
253
+ catch (error) {
254
+ console.error(error, 'GroupCast details fetching error');
255
+ }
256
+ };
257
+ this.getUserConversationDetails = async (conversationId) => {
258
+ const queryParamsGetConversationDetails = {
259
+ conversationId: conversationId || this.selectedConversationId,
260
+ includeMembers: true,
261
+ };
262
+ try {
263
+ const res = await ChatSDK.getInstance().Conversation.getConversationDetails(queryParamsGetConversationDetails, conversationId || this.selectedConversationId);
264
+ if (conversationId) {
265
+ this.selctConversationMetaData = res.conversationDetails;
266
+ }
267
+ else {
268
+ this.conversationMetaData = res.conversationDetails;
269
+ }
270
+ return res.conversationDetails;
271
+ }
272
+ catch (error) {
273
+ console.error(error, 'getConversationDetails fetching error');
274
+ }
275
+ };
276
+ /// for get all messages start
277
+ this.getMessages = async (skip, conversationId) => {
278
+ this.isMessagesLoading = true;
279
+ this.isScrollToTop = true;
280
+ this.isMessageLimitEnd = false;
281
+ try {
282
+ const res = await ChatSDK.getInstance().message.getMessages({ conversationId: conversationId || this.selectedConversationId, limit: 20, skip: skip });
283
+ if (skip == 0) {
284
+ if (conversationId) {
285
+ this.selectConversationMessages = [...res.messages.reverse()];
286
+ }
287
+ else {
288
+ this.allMessages = [...res.messages.reverse()];
289
+ }
290
+ }
291
+ else {
292
+ this.allMessages = [...res.messages.reverse(), ...this.allMessages];
293
+ }
294
+ let messagesWithAttachments = 0;
295
+ this.allMessages.forEach(message => {
296
+ if (message.hasOwnProperty('attachments') && message.attachments !== null) {
297
+ messagesWithAttachments++;
298
+ }
299
+ });
300
+ }
301
+ catch (error) {
302
+ if ((error === null || error === void 0 ? void 0 : error.status) === 404 || (error === null || error === void 0 ? void 0 : error.statusCode) === 404) {
303
+ this.isMessageLimitEnd = true;
304
+ }
305
+ }
306
+ finally {
307
+ this.isMessagesLoading = false;
308
+ }
309
+ };
310
+ ///for get all messages end
311
+ //for get unread Messages Count
312
+ this.getMessageUnreadCount = async () => {
313
+ try {
314
+ const res = await ChatSDK.getInstance().message.getUnreadCount({ converationId: this.selectedConversationId });
315
+ this.unreadMessageCountFromApi = res.count; // Update state with unread count
316
+ }
317
+ catch (error) {
318
+ console.error('Error while getting unread count', error);
319
+ }
320
+ };
321
+ // for get unread Messages Count END
322
+ this.getMessagesByQuery = async (searchText) => {
323
+ const queryParamForMessagesSearch = {
324
+ conversationId: this.selectedConversationId,
325
+ searchTag: searchText,
326
+ skip: 0,
327
+ limit: 20,
328
+ };
329
+ this.isLoadingMessage = true;
330
+ try {
331
+ const res = await ChatSDK.getInstance().message.getMessages(queryParamForMessagesSearch);
332
+ this.searchedMessageDetails = res.messages;
333
+ }
334
+ catch (error) {
335
+ this.searchedMessageDetails = [];
336
+ console.error('Error while searching messages in a chat', error);
337
+ }
338
+ finally {
339
+ this.isLoadingMessage = false;
340
+ }
341
+ };
342
+ this.getAllLinks = async (selectedConversationIDForAttachments) => {
343
+ const queryParamForGetAllAttachments = {
344
+ conversationId: selectedConversationIDForAttachments,
345
+ customTypes: 'AttachmentMessage:Link',
346
+ };
347
+ try {
348
+ const res = await ChatSDK.getInstance().message.getMessages(queryParamForGetAllAttachments);
349
+ this.allLinks = [...res.messages];
350
+ }
351
+ catch (error) {
352
+ console.error('Error while fetching all the links for a particular conversation', error);
353
+ this.allLinks = [];
354
+ }
355
+ };
356
+ this.getGroupcastMembers = async (groupcastId) => {
357
+ try {
358
+ const res = await getGroupcastMembers({ groupcastId });
359
+ this.groupcastMembers = res === null || res === void 0 ? void 0 : res.members;
360
+ }
361
+ catch (error) {
362
+ console.error('Error while fetching all the links for a particular conversation', error);
363
+ this.groupcastMembers = [];
364
+ }
365
+ };
366
+ this.getAllLinksCount = async (selectedConversationIDForAttachments) => {
367
+ const queryParamForGetAllAttachments = {
368
+ conversationId: selectedConversationIDForAttachments,
369
+ customTypes: 'AttachmentMessage:Link,AttachmentMessage:Multiple,AttachmentMessage:Image,AttachmentMessage:Video,AttachmentMessage:Audio,AttachmentMessage:File',
370
+ };
371
+ try {
372
+ const res = await ChatSDK.getInstance().message.getMessagesCount(queryParamForGetAllAttachments);
373
+ this.allLinksCount = res.messagesCount;
374
+ }
375
+ catch (error) {
376
+ console.error('Error while fetching all the links for a particular conversation', error);
377
+ this.allLinksCount = 0;
378
+ }
379
+ };
380
+ this.getAllAttachments = async (selectedConversationIDForAttachments, from) => {
381
+ const queryParamForGetAllAttachments = {
382
+ conversationId: selectedConversationIDForAttachments,
383
+ customTypes: 'AttachmentMessage:Media,AttachmentMessage:Multiple',
384
+ };
385
+ this.loadingMediaGallery = true;
386
+ this.allAttachments = [];
387
+ this.selectConverSationAttachments = [];
388
+ try {
389
+ //@ts-ignore
390
+ const res = await ChatSDK.getInstance().message.getMessages(queryParamForGetAllAttachments);
391
+ if (Array.isArray(res.messages)) {
392
+ const filteredMessages = res.messages.filter(message => {
393
+ if (!message.attachments || !Array.isArray(message.attachments)) {
394
+ return false;
395
+ }
396
+ const validAttachments = message.attachments.filter(attachment => attachment.mimeType && !attachment.mimeType.startsWith('application'));
397
+ return validAttachments.length > 0;
398
+ });
399
+ if (from === 'Profile-info') {
400
+ this.selectConverSationAttachments = [...filteredMessages];
401
+ }
402
+ else {
403
+ this.allAttachments = [...filteredMessages];
404
+ }
405
+ }
406
+ }
407
+ catch (error) {
408
+ console.error('Error while fetching all the attachments for a particular conversation', error);
409
+ this.allAttachments = [];
410
+ this.selectConverSationAttachments = [];
411
+ }
412
+ finally {
413
+ this.loadingMediaGallery = false;
414
+ }
415
+ };
416
+ // for clear all messages in a conversation for self
417
+ this.clearConversation = async (conversationId) => {
418
+ try {
419
+ // Call the API to clear the conversation
420
+ await ChatSDK.getInstance().Conversation.deleteConversationLocal({
421
+ conversationId: conversationId || this.selectedConversationId,
422
+ });
423
+ // Clear messages from local state
424
+ this.allMessages = [];
425
+ // Update the conversation list to remove the last message
426
+ this.allConversationList = this.allConversationList.map(conversation => {
427
+ if (conversation.conversationId === this.selectedConversationId) {
428
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: '', updatedAt: Date.now() }) });
429
+ }
430
+ return conversation;
431
+ });
432
+ }
433
+ catch (error) {
434
+ console.error('Error while clearing conversation:', error);
435
+ }
436
+ finally {
437
+ drawerDialogService.closeDialog('confirm-dialog');
438
+ }
439
+ };
440
+ this.deleteConversation = async (conversationId) => {
441
+ try {
442
+ await ChatSDK.getInstance().Conversation.deleteConversationClear({
443
+ conversationId: conversationId,
444
+ });
445
+ // Check if the deleted conversation ID is the same as the selected conversation ID
446
+ if (this.selectedConversationId === conversationId) {
447
+ // Remove the conversation ID from the URL
448
+ const url = new URL(window.location.href);
449
+ url.searchParams.delete('conversation');
450
+ window.history.pushState({}, '', url);
451
+ // Reset the selected conversation ID
452
+ this.selectedConversationId = null;
453
+ this.showSidebar = true; // Show sidebar if no conversation is selected
454
+ }
455
+ // Remove the conversation from the local state
456
+ this.allConversationList = this.allConversationList.filter(conversation => conversation.conversationId !== conversationId);
457
+ }
458
+ catch (error) {
459
+ console.error('Error while deleting the chat', error);
460
+ }
461
+ finally {
462
+ drawerDialogService.closeDialog('confirm-dialog');
463
+ }
464
+ };
465
+ this.blockUser = async (conversationId, userName) => {
466
+ try {
467
+ await ChatSDK.getInstance().user.postUserBlock({
468
+ opponentId: conversationId,
469
+ });
470
+ this.isBlocked = null;
471
+ showToast({
472
+ message: `${userName} blocked`,
473
+ type: 'info',
474
+ duration: 3000,
475
+ position: 'bottom-left',
476
+ });
477
+ }
478
+ catch (error) {
479
+ this.isConversationLoading = false;
480
+ console.error(`Failed to block user with ID ${conversationId}:`, error);
481
+ }
482
+ finally {
483
+ drawerDialogService.closeDialog('confirm-dialog');
484
+ }
485
+ };
486
+ this.unblockUser = async (conversationId, userName) => {
487
+ try {
488
+ await ChatSDK.getInstance().user.postUserUnblock({
489
+ opponentId: conversationId,
490
+ });
491
+ this.isBlocked = null;
492
+ showToast({
493
+ message: `${userName} unblocked`,
494
+ type: 'success',
495
+ duration: 3000,
496
+ position: 'bottom-left',
497
+ });
498
+ }
499
+ catch (error) {
500
+ this.isConversationLoading = false;
501
+ console.error(`Failed to unblock user with ID ${conversationId}:`, error);
502
+ }
503
+ finally {
504
+ drawerDialogService.closeDialog('confirm-dialog');
505
+ }
506
+ };
507
+ this.changeScrollToBottomState = (newState) => {
508
+ this.isScrollToBottom = newState;
509
+ };
510
+ this.changeScrollToTopState = (newState) => {
511
+ this.isScrollToTop = newState;
512
+ };
513
+ this.updateSkip = () => {
514
+ if (!this.isMessageLimitEnd) {
515
+ this.skip += 20;
516
+ }
517
+ };
518
+ this.updateAllMessages = (newMessages) => {
519
+ this.allMessages = newMessages;
520
+ };
521
+ this.refetchMessages = () => {
522
+ this.isScrollToBottom = true;
523
+ this.isMessageLimitEnd = true;
524
+ this.messageAction = { action: '', initiator: false };
525
+ this.skip = 0;
526
+ this.allMessages = [];
527
+ this.getMessages(0);
528
+ this.getMessageAction();
529
+ };
530
+ this.changeMessageSendingState = (newState) => {
531
+ this.isMessageSending = newState;
532
+ };
533
+ this.getMessageAction = () => {
534
+ var _a, _b, _c, _d, _e;
535
+ const lastMessage = this.isProfileInfoOpen ? (_a = this.selectConversationMessages) === null || _a === void 0 ? void 0 : _a[((_b = this.selectConversationMessages) === null || _b === void 0 ? void 0 : _b.length) - 1] : (_c = this.allMessages) === null || _c === void 0 ? void 0 : _c[((_d = this.allMessages) === null || _d === void 0 ? void 0 : _d.length) - 1];
536
+ if (lastMessage && ['userBlockConversation', 'userUnblockConversation'].includes(lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.action)) {
537
+ this.messageAction = { action: lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.action, initiator: (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.initiatorId) == ((_e = this.userMetaData) === null || _e === void 0 ? void 0 : _e.userId) };
538
+ }
539
+ };
540
+ this.deleteMessageFromSelf = async (payload) => {
541
+ try {
542
+ await ChatSDK.getInstance().message.deleteMessageSelf(payload);
543
+ this.allMessages = this.allMessages.filter((message) => message.messageId !== payload.messageIds);
544
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
545
+ var _a, _b, _c;
546
+ if (conversation.conversationId === payload.conversationId && ((_a = conversation === null || conversation === void 0 ? void 0 : conversation.lastMessageDetails) === null || _a === void 0 ? void 0 : _a.messageId) === payload.messageIds) {
547
+ const remainingMessages = this.allMessages.filter(msg => msg.conversationId === payload.conversationId).sort((a, b) => (a.sentAt || 0) - (b.sentAt || 0));
548
+ const lastMessage = remainingMessages.length > 0 ? remainingMessages[remainingMessages.length - 1] : null;
549
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: lastMessage
550
+ ? Object.assign(Object.assign({}, lastMessage), { body: lastMessage.body, updatedAt: lastMessage.sentAt || Date.now(), action: lastMessage.action || '', senderName: (_b = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _b === void 0 ? void 0 : _b.userName, senderId: (_c = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _c === void 0 ? void 0 : _c.userId }) : null });
551
+ }
552
+ return conversation;
553
+ }));
554
+ }
555
+ catch (error) {
556
+ showToast({
557
+ type: 'error',
558
+ message: (error === null || error === void 0 ? void 0 : error.message) || 'Failed to delete the message',
559
+ position: 'bottom-right',
560
+ });
561
+ }
562
+ finally {
563
+ drawerDialogService.closeDialog('delete-message');
564
+ }
565
+ };
566
+ this.deleteMeassageFromEveryOne = async (payload) => {
567
+ try {
568
+ await ChatSDK.getInstance().message.deleteMessagesEveryone(payload);
569
+ this.allMessages = this.allMessages.filter((message) => message.messageId !== payload.messageIds);
570
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
571
+ var _a, _b, _c;
572
+ if (conversation.conversationId === payload.conversationId && ((_a = conversation === null || conversation === void 0 ? void 0 : conversation.lastMessageDetails) === null || _a === void 0 ? void 0 : _a.messageId) === payload.messageIds) {
573
+ const remainingMessages = this.allMessages.filter(msg => msg.conversationId === payload.conversationId).sort((a, b) => (a.sentAt || 0) - (b.sentAt || 0));
574
+ const lastMessage = remainingMessages.length > 0 ? remainingMessages[remainingMessages.length - 1] : null;
575
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: lastMessage
576
+ ? Object.assign(Object.assign({}, lastMessage), { body: lastMessage.body, updatedAt: lastMessage.sentAt || Date.now(), action: lastMessage.action || '', senderName: (_b = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _b === void 0 ? void 0 : _b.userName, senderId: (_c = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _c === void 0 ? void 0 : _c.userId }) : null });
577
+ }
578
+ return conversation;
579
+ }));
580
+ }
581
+ catch (error) {
582
+ console.error(error, 'delete all error');
583
+ showToast({
584
+ type: 'error',
585
+ message: (error === null || error === void 0 ? void 0 : error.message) || 'Failed to delete the message',
586
+ position: 'bottom-right',
587
+ });
588
+ }
589
+ finally {
590
+ drawerDialogService.closeDialog('delete-message');
591
+ }
592
+ };
593
+ this.typingTimeout = null;
594
+ this.handleChatOpen = () => {
595
+ this.isChatClosed = false;
596
+ };
597
+ this.handleSearchResultClick = async (messageId) => {
598
+ this.highlightedMessageId = messageId;
599
+ const messageExists = this.allMessages.some(message => message.messageId === messageId);
600
+ if (!messageExists) {
601
+ while (!this.allMessages.some(message => message.messageId === messageId)) {
602
+ await this.getMessages(this.skip);
603
+ this.skip += 20;
604
+ }
605
+ }
606
+ // Scroll to the message once it is loaded
607
+ const chatBody = document.querySelector('web-chat-body');
608
+ if (chatBody) {
609
+ // @ts-ignore
610
+ chatBody.scrollToMessage(messageId);
611
+ }
612
+ };
613
+ this.handleCloseChat = () => {
614
+ this.selectedConversationId = null;
615
+ this.showSidebar = true;
616
+ const url = new URL(window.location.href);
617
+ url.searchParams.delete('conversation');
618
+ url.searchParams.delete('groupcast');
619
+ window.history.pushState({}, '', url.toString());
620
+ this.activeTab = 'Chat';
621
+ drawerDialogService.closeDialog('confirm-dialog');
622
+ };
623
+ this.updateConversationList = (updatedList) => {
624
+ // Ensure the list is sorted
625
+ const sortedList = this.sortConversationsByLatestMessage(updatedList);
626
+ // Update the state and return the sorted list
627
+ this.allConversationList = sortedList;
628
+ return sortedList;
629
+ };
630
+ this.getGroupCastContacts = async (skip = 0) => {
631
+ var _a;
632
+ this.activeTab = 'GroupCast';
633
+ if (!this.hasMoreGroupcast || this.isLoadingMoreGroupcast)
634
+ return;
635
+ this.isLoadingMoreGroupcast = true;
636
+ try {
637
+ const response = await getGroupcast({ skip, limit: 20 });
638
+ if (((_a = response === null || response === void 0 ? void 0 : response.groupcasts) === null || _a === void 0 ? void 0 : _a.length) > 0) {
639
+ this.allGroupCastContacts = skip === 0
640
+ ? response.groupcasts
641
+ : [...this.allGroupCastContacts, ...response.groupcasts];
642
+ this.groupcastSkip = skip;
643
+ }
644
+ else {
645
+ this.hasMoreGroupcast = false;
646
+ }
647
+ }
648
+ catch (error) {
649
+ console.error('Error fetching groupcast contacts:', error);
650
+ this.hasMoreGroupcast = false;
651
+ }
652
+ finally {
653
+ this.isLoadingMoreGroupcast = false;
654
+ }
655
+ };
656
+ this.name = undefined;
657
+ this.baseUrl = undefined;
658
+ this.licenseKey = undefined;
659
+ this.appSecret = undefined;
660
+ this.userSecret = undefined;
661
+ this.userToken = undefined;
662
+ this.themeUrl = undefined;
663
+ this.defaultTheme = undefined;
664
+ this.isometrikUserId = undefined;
665
+ this.projectId = undefined;
666
+ this.keysetId = undefined;
667
+ this.accountId = undefined;
668
+ this.conversationId = undefined;
669
+ this.hostUrl = undefined;
670
+ this.groupcastEnabled = undefined;
671
+ this.socialRedirectUrl = undefined;
672
+ this.unreadConversations = [];
673
+ this.allLinks = undefined;
674
+ this.allLinksCount = undefined;
675
+ this.isInitialized = false;
676
+ this.findUserId = {};
677
+ this.mqttClient = null;
678
+ this.mqttInitialized = false;
679
+ this.isMqttConnected = false;
680
+ this.allMessages = [];
681
+ this.selectConversationMessages = [];
682
+ this.userMetaData = null;
683
+ this.allConversationList = [];
684
+ this.conversationMetaData = {};
685
+ this.selctConversationMetaData = {};
686
+ this.isMessageLimitEnd = false;
687
+ this.skip = 0;
688
+ this.isMessagesLoading = false;
689
+ this.isMessageSending = false;
690
+ this.deviceId = '';
691
+ this.isScrollToBottom = true;
692
+ this.isScrollToTop = false;
693
+ this.isConversationLoading = false;
694
+ this.isLoadingConversationList = false;
695
+ this.unreadConversationsCount = 0;
696
+ this.isChatClosed = false;
697
+ this.isChatMinimized = false;
698
+ this.isSubscribedToTopic = false;
699
+ this.isMessageListenerAttached = false;
700
+ this.isInitialCallDone = false;
701
+ this.isTyping = false;
702
+ this.typingUserName = '';
703
+ this.selectedConversationId = null;
704
+ this.unreadMessageCount = null;
705
+ this.unreadMessageCountFromApi = null;
706
+ this.isLoading = true;
707
+ this.loadingProgress = 0;
708
+ this.loadingStatus = 'Initializing...';
709
+ this.isLoadingMessage = false;
710
+ this.hasMoreConversations = false;
711
+ this.eligibleMembers = [];
712
+ this.membersListSkip = 0;
713
+ this.hasMoreEligibleMembers = true;
714
+ this.isMobileView = false;
715
+ this.showSidebar = false;
716
+ this.isContactInfoOpen = false;
717
+ this.isProfileInfoOpen = false;
718
+ this.isOpenSearchBar = false;
719
+ this.isChatFilter = false;
720
+ this.isAllChatButton = true;
721
+ this.isSidebarHeaderLabel = true;
722
+ this.sidebarHeaderLabel = 'Chats';
723
+ this.isSidebarHeaderSearch = true;
724
+ this.sidebarColor = 'var(--bg-primary-color)';
725
+ this.sidebarSelectedColor = 'var(--bg-primary-light)';
726
+ this.messageSearchText = '';
727
+ this.searchedMessageDetails = [];
728
+ this.initialConversationIdFromURL = '';
729
+ this.allAttachments = [];
730
+ this.selectConverSationAttachments = [];
731
+ this.highlightedMessageId = null;
732
+ this.messageAction = { action: '', initiator: false };
733
+ this.replyMessage = null;
734
+ this.loadingMediaGallery = false;
735
+ this.activeTab = 'Chat';
736
+ this.isInstagramConnected = false;
737
+ this.showRightSideBar = false;
738
+ this.conversationIdFromContactinfo = '';
739
+ this.exitedGroupIds = new Set();
740
+ this.conversationCountSkip = 0;
741
+ this.typingConversationId = null;
742
+ this.newMessageNotification = null;
743
+ this.isBlocked = null;
744
+ this.allGroupCastContacts = [];
745
+ this.toggleTheme = undefined;
746
+ this.groupcastSkip = 0;
747
+ this.isLoadingMoreGroupcast = false;
748
+ this.hasMoreGroupcast = true;
749
+ this.groupcastMembers = [];
750
+ this.sidebarListWidth = 360;
751
+ this.isResizingSidebar = false;
752
+ }
753
+ async handleConversationChange() {
754
+ this.replyMessage = null;
755
+ this.isBlocked = null;
756
+ this.conversationMetaData = {};
757
+ this.allAttachments = [];
758
+ }
759
+ checkMobileView() {
760
+ this.isMobileView = window.innerWidth <= 768;
761
+ }
762
+ componentWillLoad() {
763
+ var _a;
764
+ // Instagram OAuth return URL — host page where accounts are linked
765
+ if ((_a = this.socialRedirectUrl) === null || _a === void 0 ? void 0 : _a.trim()) {
766
+ CHAT_CREDS.socialRedirectUrl = this.socialRedirectUrl.trim();
767
+ }
768
+ // OAuth popup return: notify opener ASAP and close (skip full chat boot)
769
+ if (notifyOpenerIfSocialPopupCallback())
770
+ return;
771
+ const urlParams = new URLSearchParams(window.location.search);
772
+ const isGroupcast = urlParams.has('groupcast');
773
+ const conversationId = urlParams.get('conversation');
774
+ const groupcastId = urlParams.get('groupcast');
775
+ this.initialConversationIdFromURL = isGroupcast ? groupcastId : conversationId;
776
+ this.isMobileView = window.innerWidth <= 768;
777
+ this.selectedConversationId = isGroupcast ? groupcastId : conversationId;
778
+ if (this.isMobileView && (conversationId || groupcastId)) {
779
+ this.showSidebar = false;
780
+ }
781
+ else {
782
+ this.showSidebar = true;
783
+ }
784
+ try {
785
+ const saved = localStorage.getItem(this.SIDEBAR_WIDTH_KEY);
786
+ if (saved) {
787
+ this.sidebarListWidth = this.clampSidebarWidth(parseInt(saved, 10) || 360);
788
+ }
789
+ }
790
+ catch (_) { }
791
+ }
792
+ async componentDidLoad() {
793
+ try {
794
+ // Device ID
795
+ // this.loadTheme();
796
+ try {
797
+ this.updateLoading(10, 'Getting device ID...');
798
+ const deviceId = await getDeviceID();
799
+ this.deviceId = deviceId;
800
+ }
801
+ catch (error) {
802
+ console.error('Error getting device ID:', error);
803
+ }
804
+ // Initialize SDK
805
+ try {
806
+ this.updateLoading(25, 'Initializing chat SDK...');
807
+ ChatSDK.initializeInstance({
808
+ baseUrl: CHAT_CREDS.baseUrl,
809
+ licenseKey: CHAT_CREDS.licenseKey,
810
+ appSecret: CHAT_CREDS.appSecret,
811
+ userSecret: CHAT_CREDS.userSecret,
812
+ userToken: this.userTokenFromCookie,
813
+ });
814
+ this.isInitialized = true;
815
+ }
816
+ catch (sdkError) {
817
+ console.error('ChatSDK failed to initialize', sdkError);
818
+ this.isInitialized = false;
819
+ throw new Error('Failed to initialize chat SDK');
820
+ }
821
+ // MQTT setup
822
+ try {
823
+ this.updateLoading(40, 'Setting up MQTT client...');
824
+ await this.setupMqttClient();
825
+ }
826
+ catch (mqttError) {
827
+ console.error('MQTT client setup failed:', mqttError);
828
+ }
829
+ // User details + Instagram OAuth return (if any)
830
+ try {
831
+ this.updateLoading(55, 'Getting user details...');
832
+ await this.getUserDetails();
833
+ await this.handleSocialConnectCallback();
834
+ }
835
+ catch (userError) {
836
+ console.error('Failed to get user details:', userError);
837
+ }
838
+ // Gate chats behind a connected Instagram account
839
+ try {
840
+ this.updateLoading(65, 'Checking Instagram connection...');
841
+ await this.refreshInstagramConnectionGate();
842
+ }
843
+ catch (igError) {
844
+ console.error('Failed to check Instagram accounts:', igError);
845
+ this.applyInstagramAccounts([]);
846
+ }
847
+ if (!this.isInstagramConnected) {
848
+ this.activeTab = 'Accounts';
849
+ this.updateLoading(100, 'Connect Instagram to continue');
850
+ this.checkMobileView();
851
+ window.addEventListener('resize', this.checkMobileView.bind(this));
852
+ return;
853
+ }
854
+ // Conversation details
855
+ if (this.initialConversationIdFromURL) {
856
+ try {
857
+ this.updateLoading(70, 'Loading conversation...');
858
+ this.selectedConversationId = this.initialConversationIdFromURL;
859
+ const urlParams = new URLSearchParams(window.location.search);
860
+ const isGroupCast = urlParams.has('groupcast');
861
+ if (isGroupCast) {
862
+ await this.getGroupCastConversationDetails(this.initialConversationIdFromURL);
863
+ const messages = await getGroupcastMessage(this.initialConversationIdFromURL);
864
+ if (messages === null || messages === void 0 ? void 0 : messages.messages) {
865
+ this.allMessages = messages === null || messages === void 0 ? void 0 : messages.messages.reverse();
866
+ }
867
+ }
868
+ else {
869
+ await this.getUserConversationDetails();
870
+ await this.getMessages(0);
871
+ await this.getAllAttachments(this.initialConversationIdFromURL);
872
+ }
873
+ }
874
+ catch (conversationError) {
875
+ console.error('Failed to load conversation details:', conversationError);
876
+ }
877
+ }
878
+ try {
879
+ this.updateLoading(85, 'Checking unread messages...');
880
+ const unreadCount = await getTotalUnreadConversationsCount();
881
+ unreadCountStore.updateTotalUnreadCount(unreadCount);
882
+ this.unreadConversationsCount = unreadCount;
883
+ unreadCountStore.onChange('totalUnreadCount', value => {
884
+ this.unreadConversationsCount = value;
885
+ });
886
+ }
887
+ catch (unreadError) {
888
+ console.error('Error fetching unread conversations:', unreadError);
889
+ this.unreadConversationsCount = 0;
890
+ unreadCountStore.updateTotalUnreadCount(0);
891
+ }
892
+ // Get all conversations
893
+ try {
894
+ this.updateLoading(95, 'Loading conversations...');
895
+ await this.getConversations();
896
+ }
897
+ catch (conversationsError) {
898
+ console.error('Failed to load conversations:', conversationsError);
899
+ }
900
+ this.checkMobileView();
901
+ window.addEventListener('resize', this.checkMobileView.bind(this));
902
+ this.updateLoading(100, 'Complete!');
903
+ }
904
+ catch (error) {
905
+ console.error('Critical initialization error:', error);
906
+ }
907
+ finally {
908
+ // Short delay to show the 100% state before hiding
909
+ setTimeout(() => {
910
+ this.isLoading = false;
911
+ }, 500);
912
+ }
913
+ }
914
+ updateLoading(progress, status) {
915
+ this.loadingProgress = progress;
916
+ this.loadingStatus = status;
917
+ }
918
+ disconnectedCallback() {
919
+ window.removeEventListener('resize', this.checkMobileView.bind(this));
920
+ window.removeEventListener('pointermove', this.onSidebarResizeMove);
921
+ window.removeEventListener('pointerup', this.onSidebarResizeEnd);
922
+ if (this.conversationDetailsInterval) {
923
+ clearInterval(this.conversationDetailsInterval);
924
+ }
925
+ }
926
+ async setupMqttClient() {
927
+ // let retryToConnect:any = null;
928
+ const deviceID = await getDeviceID();
929
+ const mqttClient = ChatSDK.getInstance().initializeMqtt({
930
+ hostUri: MQTT_CREDS.URL || this.hostUrl,
931
+ clientId: CHAT_CREDS.isometrikUserId,
932
+ licenseKey: CHAT_CREDS.licenseKey,
933
+ projectId: CHAT_CREDS.projectId,
934
+ keysetId: CHAT_CREDS.keysetId,
935
+ accountId: CHAT_CREDS.accountId,
936
+ deviceId: deviceID,
937
+ });
938
+ // const mqttClient = ChatSDK.getInstance().initializeMqtt({
939
+ // hostUri: this.hostUrl,
940
+ // clientId: this.isometrikUserId,
941
+ // licenseKey: this.licenseKey,
942
+ // projectId: this.projectId,
943
+ // keysetId: this.keysetId,
944
+ // accountId: this.accountId,
945
+ // deviceId: deviceID,
946
+ // });
947
+ this.mqttClient = mqttClient;
948
+ let refetchInterval = null;
949
+ this.isMqttConnected = false;
950
+ this.mqttClient.client.on('connect', async () => {
951
+ this.mqttInitialized = true;
952
+ this.isMqttConnected = true;
953
+ this.subscribeToMQTT();
954
+ if (refetchInterval) {
955
+ clearInterval(refetchInterval);
956
+ refetchInterval = null;
957
+ }
958
+ if (!this.isInitialCallDone && this.selectedConversationId) {
959
+ await ChatSDK.getInstance().message.putRead({ conversationId: this.selectedConversationId });
960
+ this.refetchMessages();
961
+ this.isInitialCallDone = true;
962
+ }
963
+ });
964
+ this.mqttClient.client.on('disconnect', () => {
965
+ this.isMqttConnected = false;
966
+ });
967
+ this.mqttClient.client.on('error', (error) => {
968
+ console.error('MQTT connection error:--->', error);
969
+ this.mqttInitialized = false;
970
+ this.isMqttConnected = false;
971
+ this.isInitialCallDone = true;
972
+ if (!refetchInterval) {
973
+ refetchInterval = setInterval(() => {
974
+ console.error('MQTT connection failed, refetching messages...');
975
+ this.refetchMessages();
976
+ }, 30000);
977
+ }
978
+ });
979
+ }
980
+ handleChatSelect(param) {
981
+ const conversationId = typeof param === 'string' ? param : param.groupcastId;
982
+ this.selectedConversationId = conversationId;
983
+ this.isProfileInfoOpen = false;
984
+ this.isContactInfoOpen = false;
985
+ this.isOpenSearchBar = false;
986
+ const targetConversation = this.allConversationList.find(conversation => (conversation === null || conversation === void 0 ? void 0 : conversation.conversationId) === conversationId);
987
+ this.conversationMetaData = targetConversation
988
+ ? {
989
+ isGroup: targetConversation === null || targetConversation === void 0 ? void 0 : targetConversation.isGroup,
990
+ conversationImageUrl: (targetConversation === null || targetConversation === void 0 ? void 0 : targetConversation.isGroup) ? targetConversation === null || targetConversation === void 0 ? void 0 : targetConversation.conversationImageUrl : null,
991
+ conversationTitle: (targetConversation === null || targetConversation === void 0 ? void 0 : targetConversation.isGroup) ? targetConversation === null || targetConversation === void 0 ? void 0 : targetConversation.conversationTitle : null,
992
+ opponentDetails: Object.assign({}, targetConversation.opponentDetails),
993
+ }
994
+ : null;
995
+ if (typeof param === 'string') {
996
+ this.getAllAttachments(conversationId);
997
+ }
998
+ const url = new URL(window.location.href);
999
+ url.search = '';
1000
+ if (typeof param === 'object') {
1001
+ url.searchParams.set('groupcast', param.groupcastId);
1002
+ this.activeTab = 'GroupCast';
1003
+ this.getGroupCastContacts();
1004
+ this.conversationMetaData = null;
1005
+ }
1006
+ else {
1007
+ if (conversationId) {
1008
+ url.searchParams.set('conversation', conversationId);
1009
+ if (this.isMobileView) {
1010
+ this.showSidebar = false;
1011
+ }
1012
+ }
1013
+ else {
1014
+ url.searchParams.delete('conversation');
1015
+ this.showSidebar = true;
1016
+ }
1017
+ }
1018
+ window.history.pushState({}, '', url);
1019
+ // Reset unread count for the selected conversation
1020
+ this.allConversationList = this.allConversationList.map(conversation => {
1021
+ if (conversation.conversationId === conversationId) {
1022
+ conversation.unreadMessagesCount = 0;
1023
+ }
1024
+ return conversation;
1025
+ });
1026
+ // Emit event to update unread message count in the sidebar
1027
+ this.unreadMessageCountUpdated.emit({
1028
+ detail: {
1029
+ conversationId: conversationId,
1030
+ count: 0,
1031
+ },
1032
+ });
1033
+ }
1034
+ handleBackButton() {
1035
+ this.showSidebar = true;
1036
+ this.selectedConversationId = null;
1037
+ const url = new URL(window.location.href);
1038
+ url.searchParams.delete('conversation');
1039
+ window.history.pushState({}, '', url);
1040
+ }
1041
+ sortConversationsByLatestMessage(conversations) {
1042
+ return [...conversations].sort((a, b) => {
1043
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1044
+ if ((((_a = a === null || a === void 0 ? void 0 : a.lastMessageDetails) === null || _a === void 0 ? void 0 : _a.action) == 'chatMessageSent' || ((_b = a === null || a === void 0 ? void 0 : a.lastMessageDetails) === null || _b === void 0 ? void 0 : _b.action) == 'forward') &&
1045
+ (((_c = a === null || a === void 0 ? void 0 : a.lastMessageDetails) === null || _c === void 0 ? void 0 : _c.body) === '' || ((_d = a === null || a === void 0 ? void 0 : a.lastMessageDetails) === null || _d === void 0 ? void 0 : _d.action) === 'clearConversation'))
1046
+ return;
1047
+ if ((((_e = b === null || b === void 0 ? void 0 : b.lastMessageDetails) === null || _e === void 0 ? void 0 : _e.action) == 'chatMessageSent' || ((_f = b === null || b === void 0 ? void 0 : b.lastMessageDetails) === null || _f === void 0 ? void 0 : _f.action) == 'forward') &&
1048
+ (((_g = b === null || b === void 0 ? void 0 : b.lastMessageDetails) === null || _g === void 0 ? void 0 : _g.body) === '' || ((_h = b === null || b === void 0 ? void 0 : b.lastMessageDetails) === null || _h === void 0 ? void 0 : _h.action) === 'clearConversation'))
1049
+ return;
1050
+ const timestampA = (_j = a === null || a === void 0 ? void 0 : a.lastMessageDetails) === null || _j === void 0 ? void 0 : _j.updatedAt;
1051
+ const timestampB = (_k = b === null || b === void 0 ? void 0 : b.lastMessageDetails) === null || _k === void 0 ? void 0 : _k.updatedAt;
1052
+ return timestampB - timestampA;
1053
+ });
1054
+ }
1055
+ subscribeToMQTT() {
1056
+ const topic = `/${CHAT_CREDS.accountId}/${CHAT_CREDS.projectId}/Message/${CHAT_CREDS.isometrikUserId}`;
1057
+ if (!this.isSubscribedToTopic) {
1058
+ this.mqttClient.client.subscribe(topic, (error) => {
1059
+ if (error) {
1060
+ console.error('Subscribed Failed to subscribe:--->', error);
1061
+ }
1062
+ else {
1063
+ console.log(`Subscribed to MQTT topic--->: ${topic}`);
1064
+ this.isSubscribedToTopic = true;
1065
+ }
1066
+ });
1067
+ }
1068
+ if (!this.isMessageListenerAttached) {
1069
+ // Set up the listener for incoming messages
1070
+ this.mqttClient.client.on('message', async (topic, message) => {
1071
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
1072
+ const parsedMessage = JSON.parse(message.toString());
1073
+ console.log(`New Incoming message from ${topic}:`, parsedMessage);
1074
+ if (parsedMessage.action === 'conversationCreated' && parsedMessage.conversationDetails) {
1075
+ const newConversation = Object.assign({ conversationId: parsedMessage.conversationId, lastMessageDetails: {
1076
+ body: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.body,
1077
+ updatedAt: ((_a = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationDetails) === null || _a === void 0 ? void 0 : _a.updatedAt) || Date.now(),
1078
+ userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName,
1079
+ userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderProfileImageUrl,
1080
+ action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action,
1081
+ isDeliveredToAllMembers: false,
1082
+ isReadByAllMembers: false,
1083
+ senderId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId,
1084
+ sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || 0,
1085
+ members: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) || [],
1086
+ senderName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName,
1087
+ messageId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId,
1088
+ }, isGroup: parsedMessage.conversationDetails.isGroup, conversationTitle: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationTitle, conversationImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationImageUrl }, parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationDetails);
1089
+ // Add the new conversation to the list and sort
1090
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
1091
+ }
1092
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === '"deleteConversationLocally"') {
1093
+ this.allConversationList = this.allConversationList.filter(conversation => conversation.conversationId !== parsedMessage.conversationId);
1094
+ if (this.selectedConversationId === parsedMessage.conversationId) {
1095
+ this.selectedConversationId = null;
1096
+ this.showSidebar = true;
1097
+ const url = new URL(window.location.href);
1098
+ url.searchParams.delete('conversation');
1099
+ window.history.pushState({}, '', url);
1100
+ }
1101
+ }
1102
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'forward') {
1103
+ this.handleForwardMessage(parsedMessage);
1104
+ }
1105
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'typingEvent' && parsedMessage.userId != this.userMetaData.userId) {
1106
+ this.isTyping = true;
1107
+ this.typingConversationId = parsedMessage.conversationId;
1108
+ this.typingUserName = parsedMessage.userName;
1109
+ // Add a timeout to reset the typing status after a few seconds
1110
+ setTimeout(() => {
1111
+ if (this.typingConversationId === parsedMessage.conversationId) {
1112
+ this.isTyping = false;
1113
+ this.typingConversationId = null;
1114
+ this.typingUserName = '';
1115
+ }
1116
+ }, 3000); // Reset after 3 seconds
1117
+ }
1118
+ else if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) !== 'typingEvent') {
1119
+ this.isTyping = false;
1120
+ this.typingConversationId = null;
1121
+ this.typingUserName = '';
1122
+ }
1123
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'multipleMessagesRead' && parsedMessage.userId != ((_b = this.userMetaData) === null || _b === void 0 ? void 0 : _b.userId)) {
1124
+ // Update messages read status
1125
+ this.allMessages = (_c = this.allMessages) === null || _c === void 0 ? void 0 : _c.map(message => { var _a, _b; return (message === null || message === void 0 ? void 0 : message.readByAll) != true && ((message === null || message === void 0 ? void 0 : message.senderId) || ((_a = message === null || message === void 0 ? void 0 : message.senderInfo) === null || _a === void 0 ? void 0 : _a.userId)) == ((_b = this.userMetaData) === null || _b === void 0 ? void 0 : _b.userId) ? Object.assign(Object.assign({}, message), { readByAll: true }) : message; });
1126
+ // Emit event for message read status update
1127
+ this.messageReadStatusUpdated.emit({
1128
+ detail: {
1129
+ conversationId: parsedMessage.conversationId,
1130
+ isRead: true,
1131
+ isDelivered: true,
1132
+ messageId: parsedMessage.messageId,
1133
+ },
1134
+ });
1135
+ }
1136
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'messagesDeleteForAll') {
1137
+ this.allMessages = this.allMessages.filter((message) => message.messageId != parsedMessage.messageIds[0]);
1138
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userId) !== ((_d = this.userMetaData) === null || _d === void 0 ? void 0 : _d.userId)) {
1139
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1140
+ var _a, _b, _c, _d;
1141
+ if (conversation.conversationId === parsedMessage.conversationId && ((_a = conversation === null || conversation === void 0 ? void 0 : conversation.lastMessageDetails) === null || _a === void 0 ? void 0 : _a.messageId) === parsedMessage.messageIds[0]) {
1142
+ const lastMessage = conversation === null || conversation === void 0 ? void 0 : conversation.lastMessageDetails;
1143
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: lastMessage
1144
+ ? Object.assign(Object.assign({}, lastMessage), { body: conversation.isGroup
1145
+ ? `This Message Was Deleted`
1146
+ : `${(lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderId) === ((_b = this.userMetaData) === null || _b === void 0 ? void 0 : _b.userId) ? 'You' : lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderName} have Delete message`, updatedAt: parsedMessage.sentAt || Date.now(), action: parsedMessage.action || '', senderName: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName) || ((_c = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _c === void 0 ? void 0 : _c.userName), senderId: (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.userId) || ((_d = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _d === void 0 ? void 0 : _d.userId) }) : null });
1147
+ }
1148
+ if (conversation.conversationId === parsedMessage.conversationId) {
1149
+ return Object.assign(Object.assign({}, conversation), { unreadMessagesCount: conversation.unreadMessagesCount - 1 });
1150
+ }
1151
+ return conversation;
1152
+ }));
1153
+ }
1154
+ }
1155
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId) == ((_e = this.userMetaData) === null || _e === void 0 ? void 0 : _e.userId) && ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'chatMessageSent' || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'forward')) {
1156
+ this.changeMessageSendingState(false);
1157
+ this.allMessages = this.allMessages.map(message => {
1158
+ var _a, _b;
1159
+ if (message.messageId == parsedMessage.messageId) {
1160
+ return Object.assign(Object.assign({}, parsedMessage), { mentionedUsers: ((_a = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.mentionedUsers) === null || _a === void 0 ? void 0 : _a.length)
1161
+ ? (_b = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.mentionedUsers) === null || _b === void 0 ? void 0 : _b.map(pmUser => {
1162
+ const matchingUser = message.mentionedUsers.find(mUser => mUser.userId === pmUser.userId);
1163
+ return Object.assign(Object.assign({}, pmUser), { userName: matchingUser ? matchingUser === null || matchingUser === void 0 ? void 0 : matchingUser.userName : undefined });
1164
+ })
1165
+ : [] });
1166
+ }
1167
+ return message;
1168
+ });
1169
+ }
1170
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'messageDelivered' && parsedMessage.senderId != ((_f = this.userMetaData) === null || _f === void 0 ? void 0 : _f.userId)) {
1171
+ this.allMessages = (_g = this.allMessages) === null || _g === void 0 ? void 0 : _g.map(message => ((message === null || message === void 0 ? void 0 : message.messageId) === (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId) ? Object.assign(Object.assign({}, message), { deliveredToAll: true }) : message));
1172
+ }
1173
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'userBlockConversation' || parsedMessage.action == 'userUnblockConversation' || parsedMessage.action == 'userUnblock') {
1174
+ if (parsedMessage.action === 'userBlockConversation') {
1175
+ if (parsedMessage.conversationId === this.selectedConversationId) {
1176
+ this.conversationMetaData = Object.assign(Object.assign({}, this.conversationMetaData), { messagingDisabled: true, updateBlockStatus: Date.now() });
1177
+ }
1178
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1179
+ var _a;
1180
+ if (conversation.conversationId === parsedMessage.conversationId) {
1181
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === ((_a = this.userMetaData) === null || _a === void 0 ? void 0 : _a.userId)
1182
+ ? `🚫 You blocked ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.opponentName}`
1183
+ : `🚫 ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName} blocked you`}`, updatedAt: parsedMessage.sentAt || Date.now(), action: parsedMessage.action || '', initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName, initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId, opponentName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.opponentName }) });
1184
+ }
1185
+ if (conversation.conversationId === parsedMessage.conversationId) {
1186
+ return Object.assign(Object.assign({}, conversation), { unreadMessagesCount: conversation.unreadMessagesCount - 1 });
1187
+ }
1188
+ return conversation;
1189
+ }));
1190
+ }
1191
+ if (parsedMessage.action == 'userUnblock' || parsedMessage.action === 'userUnblockConversation') {
1192
+ if (parsedMessage.conversationId === this.selectedConversationId) {
1193
+ this.conversationMetaData = Object.assign(Object.assign({}, this.conversationMetaData), { messagingDisabled: false, updateBlockStatus: Date.now() });
1194
+ }
1195
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1196
+ var _a;
1197
+ if (conversation.conversationId === parsedMessage.conversationId) {
1198
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === ((_a = this.userMetaData) === null || _a === void 0 ? void 0 : _a.userId) ? `You unblocked ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.opponentName}` : `${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName} unblocked you`}`, updatedAt: parsedMessage.sentAt || Date.now(), action: parsedMessage.action || '', initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName, initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId, opponentName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.opponentName }) });
1199
+ }
1200
+ if (conversation.conversationId === parsedMessage.conversationId) {
1201
+ return Object.assign(Object.assign({}, conversation), { unreadMessagesCount: conversation.unreadMessagesCount - 1 });
1202
+ }
1203
+ return conversation;
1204
+ }));
1205
+ }
1206
+ }
1207
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'reactionAdd') {
1208
+ // Only process reactions for the currently selected conversation
1209
+ // Check if conversationId matches, or if message exists in current conversation (fallback)
1210
+ const messageExists = this.allMessages.some(msg => msg.messageId === parsedMessage.messageId);
1211
+ const isCurrentConversation = parsedMessage.conversationId === this.selectedConversationId ||
1212
+ (messageExists && this.selectedConversationId);
1213
+ if (isCurrentConversation) {
1214
+ this.allMessages = this.allMessages.map(message => {
1215
+ if (message.messageId === parsedMessage.messageId) {
1216
+ // Create a copy of existing reactions or initialize empty object
1217
+ const existingReactions = Object.assign({}, (message.reactions || {}));
1218
+ // Get existing users array for this reaction type or initialize empty array
1219
+ // Handle both array of userIds and array of user objects
1220
+ let existingUsers = existingReactions[parsedMessage.reactionType] || [];
1221
+ // If it's an array of objects, extract userIds
1222
+ if (Array.isArray(existingUsers) && existingUsers.length > 0 && typeof existingUsers[0] === 'object') {
1223
+ existingUsers = existingUsers.map(u => u.userId || u);
1224
+ }
1225
+ // Check if user already reacted
1226
+ const userAlreadyReacted = existingUsers.includes(parsedMessage.userId);
1227
+ if (!userAlreadyReacted) {
1228
+ // Update reactions to match API structure
1229
+ const updateReaction = Object.assign(Object.assign({}, existingReactions), { [parsedMessage.reactionType]: [...existingUsers, parsedMessage.userId] });
1230
+ return Object.assign(Object.assign({}, message), { reactions: updateReaction });
1231
+ }
1232
+ return message;
1233
+ }
1234
+ return message;
1235
+ });
1236
+ }
1237
+ }
1238
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'reactionRemove') {
1239
+ // Only process reactions for the currently selected conversation
1240
+ if (parsedMessage.conversationId === this.selectedConversationId) {
1241
+ this.allMessages = this.allMessages.map(message => {
1242
+ if (message.messageId === parsedMessage.messageId) {
1243
+ const existingReactions = Object.assign({}, (message.reactions || {}));
1244
+ const existingUsers = existingReactions[parsedMessage.reactionType] || [];
1245
+ // Filter out the user who removed the reaction
1246
+ const updatedUsers = Array.isArray(existingUsers)
1247
+ ? existingUsers.filter(userId => userId !== parsedMessage.userId)
1248
+ : [];
1249
+ if (updatedUsers.length > 0) {
1250
+ existingReactions[parsedMessage.reactionType] = updatedUsers;
1251
+ }
1252
+ else {
1253
+ delete existingReactions[parsedMessage.reactionType];
1254
+ }
1255
+ return Object.assign(Object.assign({}, message), { reactions: existingReactions });
1256
+ }
1257
+ return message;
1258
+ });
1259
+ }
1260
+ }
1261
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'membersAdd') {
1262
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationId));
1263
+ if (parsedMessage.conversationId === this.selectedConversationId) {
1264
+ this.conversationMetaData.members = [
1265
+ ...this.conversationMetaData.members,
1266
+ ...parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members.map(member => ({
1267
+ userId: member.memberId,
1268
+ userName: member.memberName,
1269
+ userProfileImageUrl: member.memberProfileImageUrl,
1270
+ userIdentifier: member.memberIdentifier,
1271
+ isAdmin: member.isAdmin || false,
1272
+ })),
1273
+ ];
1274
+ }
1275
+ const isCurrentUserAdded = (_h = parsedMessage.members) === null || _h === void 0 ? void 0 : _h.some(member => { var _a; return member.memberId === ((_a = this.userMetaData) === null || _a === void 0 ? void 0 : _a.userId); });
1276
+ if (!conversationExists && isCurrentUserAdded) {
1277
+ // Create new conversation object for added member
1278
+ const newConversation = {
1279
+ conversationId: parsedMessage.conversationId,
1280
+ isGroup: true,
1281
+ conversationTitle: parsedMessage.conversationTitle,
1282
+ conversationImageUrl: parsedMessage.conversationImageUrl,
1283
+ lastMessageDetails: {
1284
+ body: `${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName} added you`,
1285
+ sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(),
1286
+ action: 'membersAdd',
1287
+ userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName,
1288
+ userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl,
1289
+ senderId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userId,
1290
+ senderName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName,
1291
+ memberAdded: (_j = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _j === void 0 ? void 0 : _j.map(member => member.memberName),
1292
+ memberAddedUserId: (_k = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _k === void 0 ? void 0 : _k.map(member => member.memberId),
1293
+ },
1294
+ unreadMessagesCount: 1,
1295
+ members: parsedMessage.members || [],
1296
+ };
1297
+ // Add the new conversation to the list and sort
1298
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
1299
+ // Update unread count
1300
+ this.unreadMessageCountUpdated.emit({
1301
+ detail: {
1302
+ conversationId: parsedMessage.conversationId,
1303
+ count: 1,
1304
+ },
1305
+ });
1306
+ }
1307
+ else if (conversationExists) {
1308
+ // Update existing conversation with new member info
1309
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1310
+ var _a, _b, _c, _d;
1311
+ if (conversation.conversationId === parsedMessage.conversationId) {
1312
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName} added ${(_b = (_a = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.memberName}`, sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(), action: 'membersAdd', userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName, userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl, memberAdded: (_c = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _c === void 0 ? void 0 : _c.map(member => member.memberName), memberAddedUserId: (_d = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _d === void 0 ? void 0 : _d.map(member => member.memberId), members: [...(conversation.members || []), ...parsedMessage.members] }), members: [...(conversation.members || []), ...parsedMessage.members] });
1313
+ }
1314
+ return conversation;
1315
+ }));
1316
+ }
1317
+ }
1318
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'membersRemove') {
1319
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationId));
1320
+ if (parsedMessage.conversationId === this.selectedConversationId) {
1321
+ this.conversationMetaData.members = (_m = (_l = this.conversationMetaData) === null || _l === void 0 ? void 0 : _l.members) === null || _m === void 0 ? void 0 : _m.filter(user => { var _a, _b; return (user === null || user === void 0 ? void 0 : user.userId) !== ((_b = (_a = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.memberId); });
1322
+ }
1323
+ if (conversationExists) {
1324
+ // Update existing conversation with new member info
1325
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1326
+ var _a, _b, _c;
1327
+ if (conversation.conversationId === parsedMessage.conversationId) {
1328
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName} removed ${(_a = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members[0]) === null || _a === void 0 ? void 0 : _a.memberName}`, sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(), action: 'membersRemove', userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName, userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl, memberAdded: (_b = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _b === void 0 ? void 0 : _b.map(member => member.memberName), memberAddedUserId: (_c = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _c === void 0 ? void 0 : _c.map(member => member.memberId), members: [...(conversation.members || []), ...parsedMessage.members] }), members: [...(conversation.members || []), ...parsedMessage.members] });
1329
+ }
1330
+ return conversation;
1331
+ }));
1332
+ }
1333
+ }
1334
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'addAdmin') {
1335
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === parsedMessage.conversationId);
1336
+ if (parsedMessage.conversationId === this.selectedConversationId) {
1337
+ this.conversationMetaData.members = (_p = (_o = this.conversationMetaData) === null || _o === void 0 ? void 0 : _o.members) === null || _p === void 0 ? void 0 : _p.map(member => {
1338
+ return Object.assign(Object.assign({}, member), { isAdmin: member.userId === parsedMessage.memberId ? true : member.isAdmin });
1339
+ });
1340
+ }
1341
+ if (conversationExists) {
1342
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1343
+ if (conversation.conversationId === parsedMessage.conversationId) {
1344
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === this.userMetaData.userId ? 'you' : parsedMessage.memberName} made ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName} an admin`, sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(), action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action, userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName, userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl, initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId, initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName, memberName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName }) });
1345
+ }
1346
+ return conversation;
1347
+ }));
1348
+ }
1349
+ else if (!conversationExists) {
1350
+ const newConversation = {
1351
+ conversationId: parsedMessage.conversationId,
1352
+ lastMessageDetails: {
1353
+ body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === this.userMetaData.userId ? 'you' : parsedMessage.memberName} made ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName} an admin`,
1354
+ sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(),
1355
+ action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action,
1356
+ userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName,
1357
+ userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl,
1358
+ initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId,
1359
+ initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName,
1360
+ memberName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName,
1361
+ },
1362
+ isGroup: true,
1363
+ conversationTitle: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationTitle,
1364
+ conversationImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationImageUrl,
1365
+ };
1366
+ // Add the new conversation to the list and sort
1367
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
1368
+ }
1369
+ }
1370
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'removeAdmin') {
1371
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === parsedMessage.conversationId);
1372
+ if (parsedMessage.conversationId === this.selectedConversationId) {
1373
+ this.conversationMetaData.members = (_r = (_q = this.conversationMetaData) === null || _q === void 0 ? void 0 : _q.members) === null || _r === void 0 ? void 0 : _r.map(member => {
1374
+ return Object.assign(Object.assign({}, member), { isAdmin: member.userId === parsedMessage.memberId ? false : member.isAdmin });
1375
+ });
1376
+ }
1377
+ if (conversationExists) {
1378
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1379
+ if (conversation.conversationId === parsedMessage.conversationId) {
1380
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === this.userMetaData.userId ? 'you' : parsedMessage.memberName} removed ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName} as an admin`, sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(), action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action, userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName, userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl, initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId, initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName, memberName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName }) });
1381
+ }
1382
+ return conversation;
1383
+ }));
1384
+ }
1385
+ else if (!conversationExists) {
1386
+ const newConversation = {
1387
+ conversationId: parsedMessage.conversationId,
1388
+ lastMessageDetails: {
1389
+ body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === this.userMetaData.userId ? 'you' : parsedMessage.memberName} removed ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName} as an admin`,
1390
+ sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(),
1391
+ action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action,
1392
+ userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName,
1393
+ userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl,
1394
+ initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId,
1395
+ initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName,
1396
+ memberName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName,
1397
+ },
1398
+ isGroup: true,
1399
+ conversationTitle: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationTitle,
1400
+ conversationImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationImageUrl,
1401
+ };
1402
+ // Add the new conversation to the list and sort
1403
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
1404
+ }
1405
+ }
1406
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'chatMessageSent' || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'forward') {
1407
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === parsedMessage.conversationId);
1408
+ const isGroup = !parsedMessage.privateOneToOne;
1409
+ if (!conversationExists) {
1410
+ // Create a new conversation object from the message data
1411
+ const newConversation = {
1412
+ conversationId: parsedMessage.conversationId,
1413
+ lastMessageDetails: {
1414
+ body: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.body,
1415
+ updatedAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(),
1416
+ userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName,
1417
+ userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderProfileImageUrl,
1418
+ action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action,
1419
+ isDeliveredToAllMembers: false,
1420
+ isReadByAllMembers: false,
1421
+ isPendingAllMembers: false,
1422
+ senderId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId,
1423
+ sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || 0,
1424
+ members: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) || [],
1425
+ senderName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName,
1426
+ messageId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId,
1427
+ },
1428
+ isGroup: isGroup,
1429
+ conversationTitle: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationTitle,
1430
+ conversationImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationImageUrl,
1431
+ opponentDetails: !isGroup
1432
+ ? {
1433
+ // Use the sender's details only if they're not the current user
1434
+ userName: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId) !== ((_s = this.userMetaData) === null || _s === void 0 ? void 0 : _s.userId) ? parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName : (_u = (_t = this.conversationMetaData) === null || _t === void 0 ? void 0 : _t.opponentDetails) === null || _u === void 0 ? void 0 : _u.userName,
1435
+ userProfileImageUrl: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId) !== ((_v = this.userMetaData) === null || _v === void 0 ? void 0 : _v.userId)
1436
+ ? parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderProfileImageUrl
1437
+ : (_x = (_w = this.conversationMetaData) === null || _w === void 0 ? void 0 : _w.opponentDetails) === null || _x === void 0 ? void 0 : _x.userProfileImageUrl,
1438
+ userId: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId) !== ((_y = this.userMetaData) === null || _y === void 0 ? void 0 : _y.userId) ? parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId : (_0 = (_z = this.conversationMetaData) === null || _z === void 0 ? void 0 : _z.opponentDetails) === null || _0 === void 0 ? void 0 : _0.userId,
1439
+ }
1440
+ : null,
1441
+ };
1442
+ // Add the new conversation to the list and sort
1443
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
1444
+ }
1445
+ else {
1446
+ // Update existing conversation
1447
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1448
+ if (conversation.conversationId === parsedMessage.conversationId) {
1449
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: parsedMessage.body, updatedAt: parsedMessage.updatedAt || parsedMessage.sentAt || Date.now(), attachments: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.attachments) || [], action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action, isDeliveredToAllMembers: false, isReadByAllMembers: false, isPendingAllMembers: false, senderId: parsedMessage.senderId, sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || 0, members: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) || [], senderName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName, messageId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId, opponentDetails: conversation.opponentDetails }), isGroup: conversation.isGroup, conversationTitle: conversation.conversationTitle, conversationImageUrl: conversation.conversationImageUrl, opponentDetails: conversation.opponentDetails });
1450
+ }
1451
+ return conversation;
1452
+ }));
1453
+ }
1454
+ // Re-sort the conversations after update
1455
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList);
1456
+ if (parsedMessage.conversationId === this.selectedConversationId) {
1457
+ if (parsedMessage.senderId !== ((_1 = this.userMetaData) === null || _1 === void 0 ? void 0 : _1.userId)) {
1458
+ const currentCount = ((_2 = this.newMessageNotification) === null || _2 === void 0 ? void 0 : _2.count) || 0;
1459
+ this.newMessageNotification = {
1460
+ messageId: parsedMessage.messageId,
1461
+ count: currentCount + 1,
1462
+ conversationId: parsedMessage.conversationId,
1463
+ };
1464
+ }
1465
+ }
1466
+ }
1467
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId) != ((_3 = this.userMetaData) === null || _3 === void 0 ? void 0 : _3.userId) &&
1468
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'typingEvent' &&
1469
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'messageRead' &&
1470
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'multipleMessagesRead' &&
1471
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'messageRead' &&
1472
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'messagesDeleteForAll' &&
1473
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'messagesDeleteLocal' &&
1474
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'messageDelivered' &&
1475
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'conversationCreated') {
1476
+ // if(parsedMessage.conversationId === this.selectedConversationId) {
1477
+ // this.allMessages = [...this.allMessages, parsedMessage];
1478
+ // }
1479
+ if (parsedMessage.conversationId === this.selectedConversationId) {
1480
+ this.allMessages = [...this.allMessages, parsedMessage];
1481
+ }
1482
+ else {
1483
+ this.allConversationList = this.allConversationList.map(conversation => {
1484
+ if (conversation.conversationId === (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationId)) {
1485
+ const currentUnreadCount = parseInt(conversation.unreadMessagesCount) || 0;
1486
+ conversation.unreadMessagesCount = currentUnreadCount + 1;
1487
+ this.unreadMessageCount = conversation.unreadMessagesCount;
1488
+ }
1489
+ return conversation;
1490
+ });
1491
+ }
1492
+ this.unreadMessageCountUpdated.emit({
1493
+ detail: {
1494
+ conversationId: parsedMessage.conversationId,
1495
+ count: 1,
1496
+ },
1497
+ // bubbles: true,
1498
+ // composed: true
1499
+ });
1500
+ try {
1501
+ await ChatSDK.getInstance().message.putIndicateDelivered({ conversationId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationId, messageId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId });
1502
+ }
1503
+ catch (error) {
1504
+ console.error(error, 'putIndicateDelivered request error');
1505
+ }
1506
+ }
1507
+ // Handle message delivery status updates
1508
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'messageDelivered' || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'messageRead') {
1509
+ const isRead = (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'messageRead';
1510
+ const isDelivered = (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'messageDelivered';
1511
+ // Update conversation list with new message status
1512
+ this.allConversationList = this.allConversationList.map(conversation => {
1513
+ var _a, _b, _c;
1514
+ if (conversation.conversationId === parsedMessage.conversationId) {
1515
+ // Only update if the status has actually changed
1516
+ const currentReadStatus = (_a = conversation.lastMessageDetails) === null || _a === void 0 ? void 0 : _a.readByAll;
1517
+ const currentDeliveredStatus = (_b = conversation.lastMessageDetails) === null || _b === void 0 ? void 0 : _b.deliveredToAll;
1518
+ if (currentReadStatus !== isRead || currentDeliveredStatus !== isDelivered) {
1519
+ // Emit event when status changes
1520
+ this.messageReadStatusUpdated.emit({
1521
+ detail: {
1522
+ conversationId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationId,
1523
+ isRead,
1524
+ isDelivered,
1525
+ messageId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId,
1526
+ },
1527
+ bubbles: true,
1528
+ composed: true,
1529
+ });
1530
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { readByAll: isRead, deliveredToAll: isDelivered, senderId: (_c = conversation.lastMessageDetails) === null || _c === void 0 ? void 0 : _c.senderId }) });
1531
+ }
1532
+ }
1533
+ return conversation;
1534
+ });
1535
+ }
1536
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'messageRead' && parsedMessage.senderId != ((_4 = this.userMetaData) === null || _4 === void 0 ? void 0 : _4.userId)) {
1537
+ // Update single message read status
1538
+ this.allMessages = (_5 = this.allMessages) === null || _5 === void 0 ? void 0 : _5.map(message => ((message === null || message === void 0 ? void 0 : message.messageId) === (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId) ? Object.assign(Object.assign({}, message), { readByAll: true }) : message));
1539
+ // Emit event for message read status update
1540
+ this.messageReadStatusUpdated.emit({
1541
+ detail: {
1542
+ conversationId: parsedMessage.conversationId,
1543
+ isRead: true,
1544
+ isDelivered: true,
1545
+ messageId: parsedMessage.messageId,
1546
+ },
1547
+ });
1548
+ }
1549
+ // Update unread count if message is not in current conversation
1550
+ if (((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'chatMessageSent' || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'forward') && parsedMessage.senderId != ((_6 = this.userMetaData) === null || _6 === void 0 ? void 0 : _6.userId)) {
1551
+ const totalUnreadConversation = (_7 = this.allConversationList) === null || _7 === void 0 ? void 0 : _7.filter(conversation => (conversation === null || conversation === void 0 ? void 0 : conversation.unreadMessagesCount) > 0);
1552
+ if ((totalUnreadConversation === null || totalUnreadConversation === void 0 ? void 0 : totalUnreadConversation.length) > 0) {
1553
+ unreadCountStore.updateTotalUnreadCount(totalUnreadConversation === null || totalUnreadConversation === void 0 ? void 0 : totalUnreadConversation.length);
1554
+ }
1555
+ }
1556
+ // Add this to your existing MQTT message handler in subscribeToMQTT()
1557
+ if (topic.includes('/members')) {
1558
+ try {
1559
+ const memberUpdate = JSON.parse(message.toString());
1560
+ if (memberUpdate.type === 'member_removed' && memberUpdate.conversationId === this.selectedConversationId) {
1561
+ // Update conversation metadata and group members store
1562
+ this.conversationMetaData = Object.assign(Object.assign({}, this.conversationMetaData), { members: memberUpdate.updatedMembers });
1563
+ groupMembersStore.initializeMembers(memberUpdate.updatedMembers, memberUpdate.conversationId);
1564
+ // Show toast notification for other members
1565
+ if (memberUpdate.removedByUserId !== CHAT_CREDS.isometrikUserId) {
1566
+ showToast({
1567
+ message: 'A member has been removed from the group',
1568
+ type: 'info',
1569
+ duration: 3000,
1570
+ position: 'bottom-left',
1571
+ });
1572
+ }
1573
+ }
1574
+ }
1575
+ catch (error) {
1576
+ console.error('Error handling member update message:', error);
1577
+ }
1578
+ }
1579
+ });
1580
+ this.isMessageListenerAttached = true;
1581
+ }
1582
+ }
1583
+ ///
1584
+ async handleForwardMessage(parsedMessage) {
1585
+ var _a, _b;
1586
+ try {
1587
+ // Check if the conversation already exists
1588
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === parsedMessage.conversationId);
1589
+ if (!conversationExists) {
1590
+ // Get conversation details first
1591
+ const conversationDetails = await this.getUserConversationDetails(parsedMessage.conversationId);
1592
+ // Use the conversation details to create the new conversation object
1593
+ const newConversation = {
1594
+ conversationId: parsedMessage.conversationId,
1595
+ lastMessageDetails: {
1596
+ body: parsedMessage.body,
1597
+ updatedAt: parsedMessage.updatedAt || Date.now(),
1598
+ // @ts-ignore
1599
+ userName: (_a = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.opponentDetails) === null || _a === void 0 ? void 0 : _a.userName,
1600
+ // @ts-ignore
1601
+ userProfileImageUrl: (_b = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.opponentDetails) === null || _b === void 0 ? void 0 : _b.userProfileImageUrl,
1602
+ },
1603
+ unreadMessagesCount: 0,
1604
+ // Add details from the API response
1605
+ };
1606
+ // Add the new conversation to the list and sort
1607
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
1608
+ await this.getAllAttachments(newConversation.conversationId);
1609
+ }
1610
+ else {
1611
+ // Update existing conversation
1612
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1613
+ if (conversation.conversationId === parsedMessage.conversationId) {
1614
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: parsedMessage.body, updatedAt: parsedMessage.updatedAt || Date.now() }), isGroup: conversation.isGroup, conversationTitle: conversation.conversationTitle, conversationImageUrl: conversation.conversationImageUrl, opponentDetails: conversation.opponentDetails });
1615
+ }
1616
+ return conversation;
1617
+ }));
1618
+ }
1619
+ this.unreadMessageCountUpdated.emit({
1620
+ detail: {
1621
+ conversationId: parsedMessage.conversationId,
1622
+ count: 1,
1623
+ },
1624
+ });
1625
+ }
1626
+ catch (error) {
1627
+ console.error('Error handling forward message:', error);
1628
+ }
1629
+ }
1630
+ async handleRemoveMemberClicked(event) {
1631
+ var _a;
1632
+ const isGroupcast = event.detail.isGroupcast;
1633
+ const memberToRemove = event.detail.userId;
1634
+ const originalMembers = ((_a = this.conversationMetaData) === null || _a === void 0 ? void 0 : _a.members) || [];
1635
+ const groupcastId = event.detail.conversationId;
1636
+ try {
1637
+ if (isGroupcast) {
1638
+ removeGroupcastMember(groupcastId, memberToRemove);
1639
+ }
1640
+ else {
1641
+ await removeConversationMember(this.selectedConversationId, memberToRemove);
1642
+ const updatedMembers = originalMembers.filter(member => member.userId !== memberToRemove);
1643
+ this.conversationMetaData = Object.assign(Object.assign({}, this.conversationMetaData), { members: updatedMembers });
1644
+ groupMembersStore.initializeMembers(updatedMembers, this.selectedConversationId);
1645
+ }
1646
+ showToast({
1647
+ message: 'Member removed successfully',
1648
+ type: 'success',
1649
+ duration: 3000,
1650
+ position: 'bottom-left',
1651
+ });
1652
+ }
1653
+ catch (error) {
1654
+ console.error('Error removing member:', error);
1655
+ showToast({
1656
+ message: 'Failed to remove member',
1657
+ type: 'error',
1658
+ duration: 3000,
1659
+ position: 'bottom-left',
1660
+ });
1661
+ }
1662
+ finally {
1663
+ drawerDialogService.closeDialog('confirm-dialog');
1664
+ }
1665
+ }
1666
+ async onProfileClick(event) {
1667
+ if (event.type === 'profile-clicked') {
1668
+ this.activeTab = 'Profile';
1669
+ }
1670
+ }
1671
+ async handleMembersListScrolledToBottom(event) {
1672
+ try {
1673
+ this.hasMoreEligibleMembers = true;
1674
+ this.membersListSkip += 20;
1675
+ const newMembers = await getConversationEligibleMembers(this.selectedConversationId, null, 20, this.membersListSkip);
1676
+ if (newMembers.conversationEligibleMembers.length < 20) {
1677
+ this.hasMoreEligibleMembers = false;
1678
+ }
1679
+ this.eligibleMembers = [...this.eligibleMembers, ...newMembers.conversationEligibleMembers];
1680
+ const membersList = event.target;
1681
+ membersList.isLoading = false;
1682
+ }
1683
+ catch (error) {
1684
+ console.error('Error loading more members:', error);
1685
+ this.hasMoreEligibleMembers = false;
1686
+ const membersList = event.target;
1687
+ membersList.isLoading = false;
1688
+ }
1689
+ }
1690
+ async handleContactInfo(event) {
1691
+ const { type } = event.detail;
1692
+ if (type === 'close-right-Sidebar') {
1693
+ this.showRightSideBar = false;
1694
+ this.isOpenSearchBar = false;
1695
+ this.isContactInfoOpen = false;
1696
+ this.isProfileInfoOpen = false;
1697
+ this.searchedMessageDetails = [];
1698
+ }
1699
+ }
1700
+ async handleProfileInfo(event) {
1701
+ const { type } = event.detail;
1702
+ if (type === 'close-contact-info') {
1703
+ this.showRightSideBar = true;
1704
+ this.isContactInfoOpen = true;
1705
+ this.isProfileInfoOpen = false;
1706
+ this.searchedMessageDetails = [];
1707
+ }
1708
+ }
1709
+ async handleOpen(event) {
1710
+ const { type, renderComponent, userId, userName } = event.detail;
1711
+ const { isGroupcast, groupcastId } = await getGroupcastUrlQuery();
1712
+ if (type === 'open-right-Sidebar') {
1713
+ this.showRightSideBar = true;
1714
+ if (renderComponent === 'message-search-container') {
1715
+ this.isOpenSearchBar = true;
1716
+ this.isContactInfoOpen = false;
1717
+ this.isProfileInfoOpen = false;
1718
+ }
1719
+ else if (renderComponent === 'contact-info') {
1720
+ this.isContactInfoOpen = true;
1721
+ this.getAllLinksCount(this.selectedConversationId);
1722
+ if (isGroupcast) {
1723
+ this.getGroupcastMembers(groupcastId);
1724
+ }
1725
+ this.isOpenSearchBar = false;
1726
+ }
1727
+ else if (renderComponent === 'profile-info') {
1728
+ this.isContactInfoOpen = false;
1729
+ this.isProfileInfoOpen = true;
1730
+ this.isOpenSearchBar = false;
1731
+ this.getConversationId(userId, userName);
1732
+ }
1733
+ }
1734
+ }
1735
+ async getConversationId(selectedContactId, selectedContactName) {
1736
+ try {
1737
+ const paramsForCreateConversation = {
1738
+ typingEvents: true,
1739
+ readEvents: true,
1740
+ pushNotifications: true,
1741
+ members: [selectedContactId],
1742
+ isGroup: false,
1743
+ conversationType: 0,
1744
+ searchableTags: [selectedContactName],
1745
+ };
1746
+ const res = await ChatSDK.getInstance().Conversation.postConversation(paramsForCreateConversation);
1747
+ if (res.conversationId) {
1748
+ this.conversationIdFromContactinfo = res.conversationId;
1749
+ this.getUserConversationDetails(res.conversationId);
1750
+ this.getAllAttachments(res.conversationId, 'Profile-info');
1751
+ this.getMessages(0, res.conversationId);
1752
+ }
1753
+ }
1754
+ catch (error) {
1755
+ console.error('Error creating conversation:', error);
1756
+ }
1757
+ }
1758
+ async handleGetLinks(event) {
1759
+ const { conversationId } = event.detail;
1760
+ this.getAllLinks(conversationId);
1761
+ }
1762
+ handleSkipChange() {
1763
+ if (!this.isMessageLimitEnd) {
1764
+ this.getMessages(this.skip);
1765
+ }
1766
+ }
1767
+ handleTypingChange() {
1768
+ if (this.isTyping) {
1769
+ if (this.typingTimeout) {
1770
+ clearTimeout(this.typingTimeout);
1771
+ }
1772
+ this.typingTimeout = setTimeout(() => {
1773
+ this.isTyping = false;
1774
+ this.typingUserName = '';
1775
+ }, 10000);
1776
+ }
1777
+ }
1778
+ async handleSelectedConversationChange(newValue) {
1779
+ if (newValue) {
1780
+ this.isConversationLoading = true;
1781
+ const url = new URL(window.location.href);
1782
+ const isGroupcast = url.searchParams.has('groupcast');
1783
+ if (isGroupcast) {
1784
+ const groupcastId = url.searchParams.get('groupcast');
1785
+ try {
1786
+ this.isScrollToBottom = true;
1787
+ this.isMessageLimitEnd = true;
1788
+ this.messageAction = { action: '', initiator: false };
1789
+ this.skip = 0;
1790
+ this.allMessages = [];
1791
+ await this.getGroupCastConversationDetails(groupcastId);
1792
+ const messages = await getGroupcastMessage(groupcastId);
1793
+ if (messages === null || messages === void 0 ? void 0 : messages.messages) {
1794
+ this.allMessages = messages === null || messages === void 0 ? void 0 : messages.messages.reverse();
1795
+ }
1796
+ }
1797
+ catch (error) {
1798
+ console.error('Error while getting groupcast data', error);
1799
+ }
1800
+ }
1801
+ else {
1802
+ this.refetchMessages();
1803
+ this.getUserConversationDetails();
1804
+ }
1805
+ this.isConversationLoading = false;
1806
+ const selectedConversation = this.allConversationList.find(conv => conv.conversationId === newValue);
1807
+ if (selectedConversation && selectedConversation.unreadMessagesCount > 0) {
1808
+ const currentCount = unreadCountStore.getTotalUnreadCount();
1809
+ const newCount = Math.max(0, currentCount - 1);
1810
+ unreadCountStore.updateTotalUnreadCount(newCount);
1811
+ }
1812
+ }
1813
+ else {
1814
+ if (this.conversationDetailsInterval) {
1815
+ clearInterval(this.conversationDetailsInterval);
1816
+ }
1817
+ }
1818
+ }
1819
+ async handlemessageAction() {
1820
+ this.getMessageAction();
1821
+ }
1822
+ handleGroupExited(event) {
1823
+ const { conversationId } = event.detail;
1824
+ // Add the group ID to the set of exited groups
1825
+ this.exitedGroupIds.add(conversationId);
1826
+ }
1827
+ handleTaguserClick(event) {
1828
+ const { userId, userName } = event.detail;
1829
+ if (userId && userName) {
1830
+ this.createConversation(userId, userName);
1831
+ }
1832
+ }
1833
+ async createConversation(selectedContactId, selectedContactName) {
1834
+ try {
1835
+ const paramsForCreateConversation = {
1836
+ typingEvents: true,
1837
+ readEvents: true,
1838
+ pushNotifications: true,
1839
+ members: [selectedContactId],
1840
+ isGroup: false,
1841
+ conversationType: 0,
1842
+ searchableTags: [selectedContactName],
1843
+ };
1844
+ const res = await ChatSDK.getInstance().Conversation.postConversation(paramsForCreateConversation);
1845
+ if (res.conversationId) {
1846
+ this.handleChatSelect(res.conversationId);
1847
+ }
1848
+ }
1849
+ catch (error) {
1850
+ console.error('Error creating conversation:', error);
1851
+ }
1852
+ }
1853
+ handleContactAction(event) {
1854
+ const action = event.detail.action;
1855
+ switch (action) {
1856
+ case 'exit-group':
1857
+ break;
1858
+ case 'block-contact':
1859
+ this.blockUser(event.detail.oppenentId, event.detail.userName);
1860
+ break;
1861
+ case 'unblock-contact':
1862
+ this.unblockUser(event.detail.oppenentId, event.detail.userName);
1863
+ break;
1864
+ case 'delete-chat':
1865
+ this.deleteConversation(event.detail.conversationId);
1866
+ break;
1867
+ case 'clear-chat':
1868
+ // Call clearConversation with the selected conversation ID
1869
+ this.clearConversation(event.detail.conversationId);
1870
+ break;
1871
+ }
1872
+ }
1873
+ handleChatTileScrolledToBottom() {
1874
+ this.conversationCountSkip += 20;
1875
+ if (this.hasMoreConversations) {
1876
+ this.getConversations(this.conversationCountSkip);
1877
+ }
1878
+ }
1879
+ // Add a method to reset notification count
1880
+ resetNewMessageNotification() {
1881
+ this.newMessageNotification = null;
1882
+ }
1883
+ async handleConversationUpdate(event) {
1884
+ const { conversationId, type, value } = event.detail;
1885
+ // Immediately update the conversation in the list (optimistic update)
1886
+ if (type === 'title' && value) {
1887
+ this.allConversationList = this.allConversationList.map(conv => conv.conversationId === conversationId
1888
+ ? Object.assign(Object.assign({}, conv), { conversationTitle: value }) : conv);
1889
+ }
1890
+ else if (type === 'image' && value) {
1891
+ this.allConversationList = this.allConversationList.map(conv => conv.conversationId === conversationId
1892
+ ? Object.assign(Object.assign({}, conv), { conversationImageUrl: value }) : conv);
1893
+ }
1894
+ try {
1895
+ // Fetch updated conversation details from server for consistency
1896
+ const response = await ChatSDK.getInstance().Conversation.getConversationDetails(conversationId, 'true');
1897
+ if (response) {
1898
+ // Update the conversation in the list with server response
1899
+ this.allConversationList = this.allConversationList.map(conv => (conv.conversationId === conversationId ? Object.assign(Object.assign({}, conv), response) : conv));
1900
+ // If this is the currently selected conversation, update conversation metadata
1901
+ if (this.selectedConversationId === conversationId) {
1902
+ this.conversationMetaData = response;
1903
+ }
1904
+ }
1905
+ }
1906
+ catch (error) {
1907
+ console.error('Error refreshing conversation details:', error);
1908
+ }
1909
+ }
1910
+ async watchPropHandler(newValue) {
1911
+ if ((newValue === null || newValue === void 0 ? void 0 : newValue.updateBlockStatus) || ((newValue === null || newValue === void 0 ? void 0 : newValue.messagingDisabled) && this.isBlocked === null)) {
1912
+ await this.findBlokedUser();
1913
+ }
1914
+ }
1915
+ async findBlokedUser() {
1916
+ var _a, _b;
1917
+ this.isBlocked = 'loading';
1918
+ try {
1919
+ const findRes = await ChatSDK.getInstance().user.getUserBlock({
1920
+ searchTag: (_b = (_a = this.conversationMetaData) === null || _a === void 0 ? void 0 : _a.opponentDetails) === null || _b === void 0 ? void 0 : _b.userName,
1921
+ });
1922
+ const users = (findRes === null || findRes === void 0 ? void 0 : findRes.users) || [];
1923
+ const currUser = users === null || users === void 0 ? void 0 : users.find(u => { var _a, _b; return (u === null || u === void 0 ? void 0 : u.userId) === ((_b = (_a = this.conversationMetaData) === null || _a === void 0 ? void 0 : _a.opponentDetails) === null || _b === void 0 ? void 0 : _b.userId); });
1924
+ this.isBlocked = currUser ? true : null;
1925
+ }
1926
+ catch (e) {
1927
+ this.isBlocked = null;
1928
+ }
1929
+ finally {
1930
+ this.isConversationLoading = false;
1931
+ }
1932
+ }
1933
+ handleGroupcastScroll() {
1934
+ if (this.hasMoreGroupcast && !this.isLoadingMoreGroupcast) {
1935
+ this.getGroupCastContacts(this.groupcastSkip + 20);
1936
+ }
1937
+ }
1938
+ async handleDeleteGroupcast(e) {
1939
+ var _a;
1940
+ try {
1941
+ const groupcastId = (_a = e === null || e === void 0 ? void 0 : e.detail) === null || _a === void 0 ? void 0 : _a.groupcastId;
1942
+ await deleteGroupCast(groupcastId);
1943
+ this.allGroupCastContacts = this.allGroupCastContacts.filter(groupcast => groupcast.groupcastId !== groupcastId);
1944
+ const url = new URL(window.location.href);
1945
+ url.searchParams.delete('groupcast');
1946
+ window.history.pushState({}, '', url);
1947
+ this.selectedConversationId = null;
1948
+ this.showSidebar = true;
1949
+ showToast({
1950
+ message: 'Groupcast deleted successfully',
1951
+ type: 'success',
1952
+ duration: 3000,
1953
+ position: 'bottom-left',
1954
+ });
1955
+ }
1956
+ catch (error) {
1957
+ console.error('Error deleting groupcast:', error);
1958
+ showToast({
1959
+ message: 'Error while deleting groupcast',
1960
+ type: 'error',
1961
+ duration: 3000,
1962
+ position: 'bottom-left',
1963
+ });
1964
+ }
1965
+ }
1966
+ render() {
1967
+ var _a, _b, _c, _d, _e;
1968
+ return (h(Fragment, { key: '54bf58235570d4cd19ae3bbc1ac54dda2346d644' }, this.isLoading ? (h("chat-loading-placeholder", { progress: this.loadingProgress, loadingStatus: this.loadingStatus })) : (h(Fragment, null, this.isConversationLoading ? (h("div", { class: "loaderoverlay" }, h("spinner-loader", { height: "30px", width: "30px", spinTime: "1s", spinnerPrimaryColor: "var(--bg-primary-color)", spinnerSecondaryColor: "var(--text-primary-color)", spinnerBorderWidth: "2px" }))) : null, h("div", { class: {
1969
+ 'isometrik-quickchat': true,
1970
+ 'is-resizing': this.isResizingSidebar,
1971
+ 'is-instagram-gate': !this.isInstagramConnected,
1972
+ }, style: { '--sidebar-width': `${this.sidebarListWidth}px` } }, h("div", { class: {
1973
+ 'chat-sidebar-container': true,
1974
+ 'hidden': this.isMobileView && !this.showSidebar,
1975
+ 'is-resizing': this.isResizingSidebar,
1976
+ 'is-full-gate': !this.isInstagramConnected,
1977
+ } }, h("profile-sidebar", { userMetaData: this.userMetaData, activeTab: this.activeTab, openChat: this.openChatTab, openAccounts: () => (this.activeTab = 'Accounts'), isMqttConnected: this.isMqttConnected, unreadConversationsCount: this.isInstagramConnected ? this.unreadConversationsCount : 0 }), h("div", { class: 'sidebar-tab' }, this.activeTab === 'GroupCast' ? (h("group-cast", { isLoadingMore: this.isLoadingMoreGroupcast, groupCastData: this.allGroupCastContacts, onGroupcastTileSelected: (e) => this.handleChatSelect(e.detail) })) : this.activeTab === 'Chat' && this.isInstagramConnected ? (h("chat-side-bar", { conversationDetails: this.conversationMetaData, isMqttConnected: this.isMqttConnected, unreadConversationsCount: this.unreadConversationsCount, hasMoreConversations: this.hasMoreConversations, userMetaData: this.userMetaData, onChatTileSelected: (e) => this.handleChatSelect(e.detail), onDeleteConversation: (conversationId) => this.deleteConversation(conversationId), conversationList: this.allConversationList, isTyping: this.isTyping, typingUserName: this.typingUserName, typingConversationId: this.typingConversationId,
1978
+ // unreadMessageCount={this.unreadMessageCount}
1979
+ //@ts-ignore
1980
+ isChatFilter: this.isChatFilter, customTypes: [
1981
+ { type: 'Test conversations', label: 'Unread' },
1982
+ { type: 'SingleChat', label: 'Past' },
1983
+ { type: 'Chatbot', label: 'Present' },
1984
+ ], isAllChatButton: this.isAllChatButton, filterTabsContainer: {
1985
+ display: 'flex',
1986
+ gap: '10px',
1987
+ width: '100%',
1988
+ flexWrap: 'wrap',
1989
+ marginBottom: '10px',
1990
+ }, filterTab: {
1991
+ padding: '6px 12px',
1992
+ border: '1px solid var(--border-subtle)',
1993
+ borderRadius: 'var(--radius-pill)',
1994
+ backgroundColor: 'transparent',
1995
+ cursor: 'pointer',
1996
+ transition: 'background-color 0.18s, color 0.18s',
1997
+ color: 'var(--text-secondary-color)',
1998
+ fontSize: '13px',
1999
+ fontWeight: '500',
2000
+ }, filterTabHover: {
2001
+ backgroundColor: 'var(--bg-primary-light)',
2002
+ color: 'var(--text-primary-color)',
2003
+ }, isSidebarHeaderLabel: this.isSidebarHeaderLabel, isSidebarHeaderSearch: this.isSidebarHeaderSearch, sidebarHeaderLabel: this.sidebarHeaderLabel, sidebarColor: this.sidebarColor, sidebarSelectedColor: this.sidebarSelectedColor, onGroupExited: (e) => this.handleGroupExited(e), handleSearchData: (searchTag) => this.getConversations(0, searchTag, true), allMessages: this.allMessages, isConversationLoading: this.isLoadingConversationList })) : this.activeTab === 'Accounts' || !this.isInstagramConnected ? (h("instagram-accounts-panel", { agentUserId: (_a = this.userMetaData) === null || _a === void 0 ? void 0 : _a.userId, defaultTheme: this.defaultTheme, toggleTheme: this.toggleTheme, closeDrawer: this.closeAccountsDrawer, hideClose: !this.isInstagramConnected, onInstagramAccountsChange: (e) => this.handleInstagramAccountsChange(e.detail || []) })) : (h("profile-page", { getUserDetails: this.getUserDetails, name: this.userMetaData.userName, profilePhotoUrl: this.userMetaData.userProfileImageUrl, closeDrawer: () => (this.activeTab = this.isInstagramConnected ? 'Chat' : 'Accounts'), toggleTheme: this.toggleTheme, defaultTheme: this.defaultTheme, agentUserId: (_b = this.userMetaData) === null || _b === void 0 ? void 0 : _b.userId, onInstagramAccountsChanged: (e) => this.handleInstagramAccountsChange(e.detail || []) }))), !this.isMobileView && this.isInstagramConnected ? (h("div", { class: {
2004
+ 'sidebar-resize-handle': true,
2005
+ 'active': this.isResizingSidebar,
2006
+ }, role: "separator", "aria-orientation": "vertical", "aria-label": "Resize sidebar", "aria-valuenow": this.sidebarListWidth, "aria-valuemin": this.SIDEBAR_MIN, "aria-valuemax": this.SIDEBAR_MAX, onPointerDown: this.startSidebarResize }, h("span", { class: "sidebar-resize-grip", "aria-hidden": "true" }))) : null), this.isInstagramConnected ? (h("div", { class: {
2007
+ 'chat-body-container': true,
2008
+ 'show': this.isMobileView && this.selectedConversationId && !this.showSidebar,
2009
+ } }, this.selectedConversationId ? (h(Fragment, null, h("web-chat-header", { searchedMessageDetails: this.searchedMessageDetails, onSearchHandler: (text) => this.getMessagesByQuery(text), onSearchResultClick: this.handleSearchResultClick, headerBgColor: "var(--bg-primary-color)", headerLastSeenColor: "var(--text-last-seen)", headerSvgColor: "var(--text-primary-color)", headerUsernameColor: "var(--text-primary-color)", onClearConversation: () => this.clearConversation(), conversationDetails: this.conversationMetaData, isTyping: this.isTyping && this.selectedConversationId === this.typingConversationId, typingUserName: this.typingUserName, chatBodyRef: this.chatBodyRef, onTextClick: () => this.getAllAttachments(this.selectedConversationId), allAttachments: this.allAttachments, lastSeen: (_d = (_c = this.conversationMetaData) === null || _c === void 0 ? void 0 : _c.opponentDetails) === null || _d === void 0 ? void 0 : _d.lastSeen, userMetaData: this.userMetaData, selectedConversationId: this.selectedConversationId, messageAction: this.messageAction, eligibleMembers: this.eligibleMembers, hasMoreEligibleMembers: this.hasMoreEligibleMembers, handleCloseChat: () => this.handleCloseChat(), typingConversationId: this.typingConversationId, isBlocked: this.isBlocked, onBackButtonClick: this.handleBackButton }), h("web-chat-body", { ref: el => (this.chatBodyRef = el), allAttachments: this.allAttachments, isMessagesLoading: this.isMessagesLoading, updateSkip: this.updateSkip, isMessageLimitEnd: this.isMessageLimitEnd, allMessages: this.allMessages, userMetaData: this.userMetaData, skip: this.skip, isScrollToBottom: this.isScrollToBottom, changeScrollToBottomState: this.changeScrollToBottomState, isMessageSending: this.isMessageSending, isScrollToTop: this.isScrollToTop, changeScrollToTopState: this.changeScrollToTopState, deleteForSelf: this.deleteMessageFromSelf, deleteForAll: this.deleteMeassageFromEveryOne, isChatClosed: this.isChatClosed, isChatMinimized: this.isChatMinimized, updateAllMessages: this.updateAllMessages, selectedConversationId: this.selectedConversationId, highlightedMessageId: this.highlightedMessageId, onMediaClick: () => this.getAllAttachments(this.selectedConversationId), onReplyMessageDetails: this.handleReplyMessage, conversationList: this.allConversationList, newMessageNotification: this.newMessageNotification, onNewMessageCountReset: () => this.resetNewMessageNotification(), conversationDetails: this.conversationMetaData, loadingMediaGallery: this.loadingMediaGallery }), this.exitedGroupIds.has(this.selectedConversationId) ? (h("div", { style: {
2010
+ padding: '1rem',
2011
+ textAlign: 'center',
2012
+ backgroundColor: 'var(--bg-primary-color)',
2013
+ color: 'var(--text-secondary-color)',
2014
+ borderTop: '1px solid var(--border-subtle)',
2015
+ fontSize: '13px',
2016
+ } }, "You are no longer a member of this group")) : this.isBlocked === 'loading' ? (h("p", { class: "blockMessageContainer" }, WEB_CONTENT.PLEASE_WAIT)) : ((_e = this.conversationMetaData) === null || _e === void 0 ? void 0 : _e.messagingDisabled) ? (h("p", { class: "blockMessageContainer" }, WEB_CONTENT.BLOCK_CHAT_MESSAGE)) : (h("chat-footer", { userMetaData: this.userMetaData, updateAllMessages: this.updateAllMessages, changeMessageSendingState: this.changeMessageSendingState, changeScrollToBottomState: this.changeScrollToBottomState, refetchMessages: this.refetchMessages, allMessages: this.allMessages, selectedConversationId: this.selectedConversationId, replyMessage: this.replyMessage, handleremoveReplyMessage: this.handleremoveReplyMessage, conversationDetails: this.conversationMetaData, allConversationList: this.allConversationList, updateConversationListProp: this.updateConversationList })))) : (h("div", { class: "noChatSelectedPlaceholder" }, h("div", { class: "empty-mark", "aria-hidden": "true" }, h("span", null), h("span", null)), h("h2", null, "Select a chat"), h("p", null, "Open a thread on the left to get started."))))) : null, this.isInstagramConnected && this.showRightSideBar ? (h("div", { class: 'chat-sidebar-right' }, h("web-chat-right-sidebar", { conversationMetaData: this.isProfileInfoOpen ? this.selctConversationMetaData : this.conversationMetaData, selectedConversationId: this.selectedConversationId, hasMoreEligibleMembers: this.hasMoreEligibleMembers, eligibleMembers: this.eligibleMembers, allAttachments: this.isProfileInfoOpen ? this.selectConverSationAttachments : this.allAttachments, userMetaData: this.userMetaData, messageAction: this.messageAction, searchedMessageDetails: this.searchedMessageDetails, onSearchHandler: (text) => this.getMessagesByQuery(text), onSearchResultClick: this.handleSearchResultClick, isContactInfoOpen: this.isContactInfoOpen, isProfileInfoOpen: this.isProfileInfoOpen, isOpenSearchBar: this.isOpenSearchBar, chatBodyRef: this.chatBodyRef, isLoadingMessage: this.isLoadingMessage, conversationIdFromContactinfo: this.conversationIdFromContactinfo, openOwnProfile: () => (this.activeTab = 'Profile'), handleChatSelect: conversationId => this.handleChatSelect(conversationId), allLinks: this.allLinks, allLinksCount: this.allLinksCount, isBlocked: this.isBlocked, groupcastMembers: this.groupcastMembers }))) : null)))));
2017
+ }
2018
+ static get is() { return "web-chat"; }
2019
+ static get encapsulation() { return "shadow"; }
2020
+ static get originalStyleUrls() {
2021
+ return {
2022
+ "$": ["web-chat.css"]
2023
+ };
2024
+ }
2025
+ static get styleUrls() {
2026
+ return {
2027
+ "$": ["web-chat.css"]
2028
+ };
2029
+ }
2030
+ static get properties() {
2031
+ return {
2032
+ "name": {
2033
+ "type": "string",
2034
+ "mutable": false,
2035
+ "complexType": {
2036
+ "original": "string",
2037
+ "resolved": "string",
2038
+ "references": {}
2039
+ },
2040
+ "required": false,
2041
+ "optional": false,
2042
+ "docs": {
2043
+ "tags": [],
2044
+ "text": ""
2045
+ },
2046
+ "attribute": "name",
2047
+ "reflect": false
2048
+ },
2049
+ "baseUrl": {
2050
+ "type": "string",
2051
+ "mutable": false,
2052
+ "complexType": {
2053
+ "original": "string",
2054
+ "resolved": "string",
2055
+ "references": {}
2056
+ },
2057
+ "required": false,
2058
+ "optional": false,
2059
+ "docs": {
2060
+ "tags": [],
2061
+ "text": ""
2062
+ },
2063
+ "attribute": "base-url",
2064
+ "reflect": false
2065
+ },
2066
+ "licenseKey": {
2067
+ "type": "string",
2068
+ "mutable": false,
2069
+ "complexType": {
2070
+ "original": "string",
2071
+ "resolved": "string",
2072
+ "references": {}
2073
+ },
2074
+ "required": false,
2075
+ "optional": false,
2076
+ "docs": {
2077
+ "tags": [],
2078
+ "text": ""
2079
+ },
2080
+ "attribute": "license-key",
2081
+ "reflect": false
2082
+ },
2083
+ "appSecret": {
2084
+ "type": "string",
2085
+ "mutable": false,
2086
+ "complexType": {
2087
+ "original": "string",
2088
+ "resolved": "string",
2089
+ "references": {}
2090
+ },
2091
+ "required": false,
2092
+ "optional": false,
2093
+ "docs": {
2094
+ "tags": [],
2095
+ "text": ""
2096
+ },
2097
+ "attribute": "app-secret",
2098
+ "reflect": false
2099
+ },
2100
+ "userSecret": {
2101
+ "type": "string",
2102
+ "mutable": false,
2103
+ "complexType": {
2104
+ "original": "string",
2105
+ "resolved": "string",
2106
+ "references": {}
2107
+ },
2108
+ "required": false,
2109
+ "optional": false,
2110
+ "docs": {
2111
+ "tags": [],
2112
+ "text": ""
2113
+ },
2114
+ "attribute": "user-secret",
2115
+ "reflect": false
2116
+ },
2117
+ "userToken": {
2118
+ "type": "string",
2119
+ "mutable": false,
2120
+ "complexType": {
2121
+ "original": "string",
2122
+ "resolved": "string",
2123
+ "references": {}
2124
+ },
2125
+ "required": false,
2126
+ "optional": false,
2127
+ "docs": {
2128
+ "tags": [],
2129
+ "text": ""
2130
+ },
2131
+ "attribute": "user-token",
2132
+ "reflect": false
2133
+ },
2134
+ "themeUrl": {
2135
+ "type": "string",
2136
+ "mutable": false,
2137
+ "complexType": {
2138
+ "original": "string",
2139
+ "resolved": "string",
2140
+ "references": {}
2141
+ },
2142
+ "required": false,
2143
+ "optional": false,
2144
+ "docs": {
2145
+ "tags": [],
2146
+ "text": ""
2147
+ },
2148
+ "attribute": "theme-url",
2149
+ "reflect": false
2150
+ },
2151
+ "defaultTheme": {
2152
+ "type": "string",
2153
+ "mutable": false,
2154
+ "complexType": {
2155
+ "original": "string",
2156
+ "resolved": "string",
2157
+ "references": {}
2158
+ },
2159
+ "required": false,
2160
+ "optional": false,
2161
+ "docs": {
2162
+ "tags": [],
2163
+ "text": ""
2164
+ },
2165
+ "attribute": "default-theme",
2166
+ "reflect": false
2167
+ },
2168
+ "isometrikUserId": {
2169
+ "type": "string",
2170
+ "mutable": false,
2171
+ "complexType": {
2172
+ "original": "string",
2173
+ "resolved": "string",
2174
+ "references": {}
2175
+ },
2176
+ "required": false,
2177
+ "optional": false,
2178
+ "docs": {
2179
+ "tags": [],
2180
+ "text": ""
2181
+ },
2182
+ "attribute": "isometrik-user-id",
2183
+ "reflect": false
2184
+ },
2185
+ "projectId": {
2186
+ "type": "string",
2187
+ "mutable": false,
2188
+ "complexType": {
2189
+ "original": "string",
2190
+ "resolved": "string",
2191
+ "references": {}
2192
+ },
2193
+ "required": false,
2194
+ "optional": false,
2195
+ "docs": {
2196
+ "tags": [],
2197
+ "text": ""
2198
+ },
2199
+ "attribute": "project-id",
2200
+ "reflect": false
2201
+ },
2202
+ "keysetId": {
2203
+ "type": "string",
2204
+ "mutable": false,
2205
+ "complexType": {
2206
+ "original": "string",
2207
+ "resolved": "string",
2208
+ "references": {}
2209
+ },
2210
+ "required": false,
2211
+ "optional": false,
2212
+ "docs": {
2213
+ "tags": [],
2214
+ "text": ""
2215
+ },
2216
+ "attribute": "keyset-id",
2217
+ "reflect": false
2218
+ },
2219
+ "accountId": {
2220
+ "type": "string",
2221
+ "mutable": false,
2222
+ "complexType": {
2223
+ "original": "string",
2224
+ "resolved": "string",
2225
+ "references": {}
2226
+ },
2227
+ "required": false,
2228
+ "optional": false,
2229
+ "docs": {
2230
+ "tags": [],
2231
+ "text": ""
2232
+ },
2233
+ "attribute": "account-id",
2234
+ "reflect": false
2235
+ },
2236
+ "conversationId": {
2237
+ "type": "string",
2238
+ "mutable": false,
2239
+ "complexType": {
2240
+ "original": "string",
2241
+ "resolved": "string",
2242
+ "references": {}
2243
+ },
2244
+ "required": false,
2245
+ "optional": false,
2246
+ "docs": {
2247
+ "tags": [],
2248
+ "text": ""
2249
+ },
2250
+ "attribute": "conversation-id",
2251
+ "reflect": false
2252
+ },
2253
+ "hostUrl": {
2254
+ "type": "string",
2255
+ "mutable": false,
2256
+ "complexType": {
2257
+ "original": "string",
2258
+ "resolved": "string",
2259
+ "references": {}
2260
+ },
2261
+ "required": false,
2262
+ "optional": true,
2263
+ "docs": {
2264
+ "tags": [],
2265
+ "text": ""
2266
+ },
2267
+ "attribute": "host-url",
2268
+ "reflect": false
2269
+ },
2270
+ "groupcastEnabled": {
2271
+ "type": "boolean",
2272
+ "mutable": false,
2273
+ "complexType": {
2274
+ "original": "boolean",
2275
+ "resolved": "boolean",
2276
+ "references": {}
2277
+ },
2278
+ "required": false,
2279
+ "optional": true,
2280
+ "docs": {
2281
+ "tags": [],
2282
+ "text": ""
2283
+ },
2284
+ "attribute": "groupcast-enabled",
2285
+ "reflect": false
2286
+ },
2287
+ "socialRedirectUrl": {
2288
+ "type": "string",
2289
+ "mutable": false,
2290
+ "complexType": {
2291
+ "original": "string",
2292
+ "resolved": "string",
2293
+ "references": {}
2294
+ },
2295
+ "required": false,
2296
+ "optional": true,
2297
+ "docs": {
2298
+ "tags": [],
2299
+ "text": "Instagram/Zernio OAuth return URL (account-link page). Overrides CHAT_CREDS.socialRedirectUrl."
2300
+ },
2301
+ "attribute": "social-redirect-url",
2302
+ "reflect": false
2303
+ },
2304
+ "isChatFilter": {
2305
+ "type": "boolean",
2306
+ "mutable": false,
2307
+ "complexType": {
2308
+ "original": "boolean",
2309
+ "resolved": "boolean",
2310
+ "references": {}
2311
+ },
2312
+ "required": false,
2313
+ "optional": false,
2314
+ "docs": {
2315
+ "tags": [],
2316
+ "text": ""
2317
+ },
2318
+ "attribute": "is-chat-filter",
2319
+ "reflect": false,
2320
+ "defaultValue": "false"
2321
+ },
2322
+ "isAllChatButton": {
2323
+ "type": "boolean",
2324
+ "mutable": false,
2325
+ "complexType": {
2326
+ "original": "boolean",
2327
+ "resolved": "boolean",
2328
+ "references": {}
2329
+ },
2330
+ "required": false,
2331
+ "optional": false,
2332
+ "docs": {
2333
+ "tags": [],
2334
+ "text": ""
2335
+ },
2336
+ "attribute": "is-all-chat-button",
2337
+ "reflect": false,
2338
+ "defaultValue": "true"
2339
+ },
2340
+ "isSidebarHeaderLabel": {
2341
+ "type": "boolean",
2342
+ "mutable": false,
2343
+ "complexType": {
2344
+ "original": "boolean",
2345
+ "resolved": "boolean",
2346
+ "references": {}
2347
+ },
2348
+ "required": false,
2349
+ "optional": false,
2350
+ "docs": {
2351
+ "tags": [],
2352
+ "text": ""
2353
+ },
2354
+ "attribute": "is-sidebar-header-label",
2355
+ "reflect": false,
2356
+ "defaultValue": "true"
2357
+ },
2358
+ "sidebarHeaderLabel": {
2359
+ "type": "string",
2360
+ "mutable": false,
2361
+ "complexType": {
2362
+ "original": "string",
2363
+ "resolved": "string",
2364
+ "references": {}
2365
+ },
2366
+ "required": false,
2367
+ "optional": false,
2368
+ "docs": {
2369
+ "tags": [],
2370
+ "text": ""
2371
+ },
2372
+ "attribute": "sidebar-header-label",
2373
+ "reflect": false,
2374
+ "defaultValue": "'Chats'"
2375
+ },
2376
+ "isSidebarHeaderSearch": {
2377
+ "type": "boolean",
2378
+ "mutable": false,
2379
+ "complexType": {
2380
+ "original": "boolean",
2381
+ "resolved": "boolean",
2382
+ "references": {}
2383
+ },
2384
+ "required": false,
2385
+ "optional": false,
2386
+ "docs": {
2387
+ "tags": [],
2388
+ "text": ""
2389
+ },
2390
+ "attribute": "is-sidebar-header-search",
2391
+ "reflect": false,
2392
+ "defaultValue": "true"
2393
+ },
2394
+ "sidebarColor": {
2395
+ "type": "string",
2396
+ "mutable": false,
2397
+ "complexType": {
2398
+ "original": "string",
2399
+ "resolved": "string",
2400
+ "references": {}
2401
+ },
2402
+ "required": false,
2403
+ "optional": false,
2404
+ "docs": {
2405
+ "tags": [],
2406
+ "text": ""
2407
+ },
2408
+ "attribute": "sidebar-color",
2409
+ "reflect": false,
2410
+ "defaultValue": "'var(--bg-primary-color)'"
2411
+ },
2412
+ "sidebarSelectedColor": {
2413
+ "type": "string",
2414
+ "mutable": false,
2415
+ "complexType": {
2416
+ "original": "string",
2417
+ "resolved": "string",
2418
+ "references": {}
2419
+ },
2420
+ "required": false,
2421
+ "optional": false,
2422
+ "docs": {
2423
+ "tags": [],
2424
+ "text": ""
2425
+ },
2426
+ "attribute": "sidebar-selected-color",
2427
+ "reflect": false,
2428
+ "defaultValue": "'var(--bg-primary-light)'"
2429
+ },
2430
+ "toggleTheme": {
2431
+ "type": "unknown",
2432
+ "mutable": false,
2433
+ "complexType": {
2434
+ "original": "() => void",
2435
+ "resolved": "() => void",
2436
+ "references": {}
2437
+ },
2438
+ "required": false,
2439
+ "optional": false,
2440
+ "docs": {
2441
+ "tags": [],
2442
+ "text": ""
2443
+ }
2444
+ }
2445
+ };
2446
+ }
2447
+ static get states() {
2448
+ return {
2449
+ "unreadConversations": {},
2450
+ "allLinks": {},
2451
+ "allLinksCount": {},
2452
+ "isInitialized": {},
2453
+ "findUserId": {},
2454
+ "mqttClient": {},
2455
+ "mqttInitialized": {},
2456
+ "isMqttConnected": {},
2457
+ "allMessages": {},
2458
+ "selectConversationMessages": {},
2459
+ "userMetaData": {},
2460
+ "allConversationList": {},
2461
+ "conversationMetaData": {},
2462
+ "selctConversationMetaData": {},
2463
+ "isMessageLimitEnd": {},
2464
+ "skip": {},
2465
+ "isMessagesLoading": {},
2466
+ "isMessageSending": {},
2467
+ "deviceId": {},
2468
+ "isScrollToBottom": {},
2469
+ "isScrollToTop": {},
2470
+ "isConversationLoading": {},
2471
+ "isLoadingConversationList": {},
2472
+ "unreadConversationsCount": {},
2473
+ "isChatClosed": {},
2474
+ "isChatMinimized": {},
2475
+ "isSubscribedToTopic": {},
2476
+ "isMessageListenerAttached": {},
2477
+ "isInitialCallDone": {},
2478
+ "isTyping": {},
2479
+ "typingUserName": {},
2480
+ "selectedConversationId": {},
2481
+ "unreadMessageCount": {},
2482
+ "unreadMessageCountFromApi": {},
2483
+ "isLoading": {},
2484
+ "loadingProgress": {},
2485
+ "loadingStatus": {},
2486
+ "isLoadingMessage": {},
2487
+ "hasMoreConversations": {},
2488
+ "eligibleMembers": {},
2489
+ "membersListSkip": {},
2490
+ "hasMoreEligibleMembers": {},
2491
+ "isMobileView": {},
2492
+ "showSidebar": {},
2493
+ "isContactInfoOpen": {},
2494
+ "isProfileInfoOpen": {},
2495
+ "isOpenSearchBar": {},
2496
+ "messageSearchText": {},
2497
+ "searchedMessageDetails": {},
2498
+ "initialConversationIdFromURL": {},
2499
+ "allAttachments": {},
2500
+ "selectConverSationAttachments": {},
2501
+ "highlightedMessageId": {},
2502
+ "messageAction": {},
2503
+ "replyMessage": {},
2504
+ "loadingMediaGallery": {},
2505
+ "activeTab": {},
2506
+ "isInstagramConnected": {},
2507
+ "showRightSideBar": {},
2508
+ "conversationIdFromContactinfo": {},
2509
+ "exitedGroupIds": {},
2510
+ "conversationCountSkip": {},
2511
+ "typingConversationId": {},
2512
+ "newMessageNotification": {},
2513
+ "isBlocked": {},
2514
+ "allGroupCastContacts": {},
2515
+ "groupcastSkip": {},
2516
+ "isLoadingMoreGroupcast": {},
2517
+ "hasMoreGroupcast": {},
2518
+ "groupcastMembers": {},
2519
+ "sidebarListWidth": {},
2520
+ "isResizingSidebar": {}
2521
+ };
2522
+ }
2523
+ static get events() {
2524
+ return [{
2525
+ "method": "unreadMessageCountUpdated",
2526
+ "name": "unreadMessageCountUpdated",
2527
+ "bubbles": true,
2528
+ "cancelable": true,
2529
+ "composed": true,
2530
+ "docs": {
2531
+ "tags": [],
2532
+ "text": ""
2533
+ },
2534
+ "complexType": {
2535
+ "original": "any",
2536
+ "resolved": "any",
2537
+ "references": {}
2538
+ }
2539
+ }, {
2540
+ "method": "conversationNotFound",
2541
+ "name": "conversationNotFound",
2542
+ "bubbles": true,
2543
+ "cancelable": true,
2544
+ "composed": true,
2545
+ "docs": {
2546
+ "tags": [],
2547
+ "text": ""
2548
+ },
2549
+ "complexType": {
2550
+ "original": "any",
2551
+ "resolved": "any",
2552
+ "references": {}
2553
+ }
2554
+ }, {
2555
+ "method": "messageReadStatusUpdated",
2556
+ "name": "messageReadStatusUpdated",
2557
+ "bubbles": true,
2558
+ "cancelable": true,
2559
+ "composed": true,
2560
+ "docs": {
2561
+ "tags": [],
2562
+ "text": ""
2563
+ },
2564
+ "complexType": {
2565
+ "original": "any",
2566
+ "resolved": "any",
2567
+ "references": {}
2568
+ }
2569
+ }];
2570
+ }
2571
+ static get watchers() {
2572
+ return [{
2573
+ "propName": "selectedConversationId",
2574
+ "methodName": "handleConversationChange"
2575
+ }, {
2576
+ "propName": "skip",
2577
+ "methodName": "handleSkipChange"
2578
+ }, {
2579
+ "propName": "isTyping",
2580
+ "methodName": "handleTypingChange"
2581
+ }, {
2582
+ "propName": "selectedConversationId",
2583
+ "methodName": "handleSelectedConversationChange"
2584
+ }, {
2585
+ "propName": "initialConversationIdFromURL",
2586
+ "methodName": "handleSelectedConversationChange"
2587
+ }, {
2588
+ "propName": "allMessages",
2589
+ "methodName": "handlemessageAction"
2590
+ }, {
2591
+ "propName": "selectConversationMessages",
2592
+ "methodName": "handlemessageAction"
2593
+ }, {
2594
+ "propName": "conversationMetaData",
2595
+ "methodName": "watchPropHandler"
2596
+ }];
2597
+ }
2598
+ static get listeners() {
2599
+ return [{
2600
+ "name": "remove-member-clicked",
2601
+ "method": "handleRemoveMemberClicked",
2602
+ "target": undefined,
2603
+ "capture": false,
2604
+ "passive": false
2605
+ }, {
2606
+ "name": "profile-clicked",
2607
+ "method": "onProfileClick",
2608
+ "target": undefined,
2609
+ "capture": false,
2610
+ "passive": false
2611
+ }, {
2612
+ "name": "members-list-scrolled-to-bottom",
2613
+ "method": "handleMembersListScrolledToBottom",
2614
+ "target": undefined,
2615
+ "capture": false,
2616
+ "passive": false
2617
+ }, {
2618
+ "name": "close-right-Sidebar",
2619
+ "method": "handleContactInfo",
2620
+ "target": undefined,
2621
+ "capture": false,
2622
+ "passive": false
2623
+ }, {
2624
+ "name": "close-contact-info",
2625
+ "method": "handleProfileInfo",
2626
+ "target": undefined,
2627
+ "capture": false,
2628
+ "passive": false
2629
+ }, {
2630
+ "name": "open-right-Sidebar",
2631
+ "method": "handleOpen",
2632
+ "target": undefined,
2633
+ "capture": false,
2634
+ "passive": false
2635
+ }, {
2636
+ "name": "get-links",
2637
+ "method": "handleGetLinks",
2638
+ "target": undefined,
2639
+ "capture": false,
2640
+ "passive": false
2641
+ }, {
2642
+ "name": "groupExited",
2643
+ "method": "handleGroupExited",
2644
+ "target": undefined,
2645
+ "capture": false,
2646
+ "passive": false
2647
+ }, {
2648
+ "name": "tagUserClick",
2649
+ "method": "handleTaguserClick",
2650
+ "target": undefined,
2651
+ "capture": false,
2652
+ "passive": false
2653
+ }, {
2654
+ "name": "contact-action",
2655
+ "method": "handleContactAction",
2656
+ "target": "body",
2657
+ "capture": false,
2658
+ "passive": false
2659
+ }, {
2660
+ "name": "chat-tile-list-scrolled-to-bottom",
2661
+ "method": "handleChatTileScrolledToBottom",
2662
+ "target": undefined,
2663
+ "capture": false,
2664
+ "passive": false
2665
+ }, {
2666
+ "name": "conversation-updated",
2667
+ "method": "handleConversationUpdate",
2668
+ "target": undefined,
2669
+ "capture": false,
2670
+ "passive": false
2671
+ }, {
2672
+ "name": "groupcastScrolledToBottom",
2673
+ "method": "handleGroupcastScroll",
2674
+ "target": undefined,
2675
+ "capture": false,
2676
+ "passive": false
2677
+ }, {
2678
+ "name": "delete-groupcast",
2679
+ "method": "handleDeleteGroupcast",
2680
+ "target": undefined,
2681
+ "capture": false,
2682
+ "passive": false
2683
+ }];
2684
+ }
2685
+ }
2686
+ //# sourceMappingURL=WebChat.js.map