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,4360 @@
1
+ import { h, i, k as ke } from './Image-bb9efda3.js';
2
+ import { a as drawerDialogService } from './dialog-drawer-9fa083b1.js';
3
+ import './index-fddf30b7.js';
4
+ import './taguser-e9032d65.js';
5
+ import './ReactionsContainer-bdd74a3c.js';
6
+ import { W as WEB_CONTENT } from './content-5aea5e39.js';
7
+
8
+ const videoPlaceholderSvg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE2IDE2IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTE2IDJIMFYxNEgxNlYyWk02LjUgNVYxMUg3LjVMMTEgOEw3LjUgNUg2LjVaIiBmaWxsPSIjMDAwMDAwIi8+Cjwvc3ZnPg==';
9
+
10
+ const equalizerSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iNDhweCIgdmlld0JveD0iMCAtOTYwIDk2MCA5NjAiIHdpZHRoPSI0OHB4IiBmaWxsPSIjZThlYWVkIj48cGF0aCBkPSJNMjg1LTI0MHYtNDgwaDYwdjQ4MGgtNjBaTTQ1MC04MHYtODAwaDYwdjgwMGgtNjBaTTEyMC00MDB2LTE2MGg2MHYxNjBoLTYwWm00OTUgMTYwdi00ODBoNjB2NDgwaC02MFptMTY1LTE2MHYtMTYwaDYwdjE2MGgtNjBaIi8+PC9zdmc+';
11
+
12
+ /** A simple event emitter that can be used to listen to and emit events. */
13
+ class EventEmitter {
14
+ constructor() {
15
+ this.listeners = {};
16
+ }
17
+ /** Subscribe to an event. Returns an unsubscribe function. */
18
+ on(event, listener, options) {
19
+ if (!this.listeners[event]) {
20
+ this.listeners[event] = new Set();
21
+ }
22
+ if (options === null || options === void 0 ? void 0 : options.once) {
23
+ // Create a wrapper that removes itself after being called once
24
+ const onceWrapper = (...args) => {
25
+ this.un(event, onceWrapper);
26
+ listener(...args);
27
+ };
28
+ this.listeners[event].add(onceWrapper);
29
+ return () => this.un(event, onceWrapper);
30
+ }
31
+ this.listeners[event].add(listener);
32
+ return () => this.un(event, listener);
33
+ }
34
+ /** Unsubscribe from an event */
35
+ un(event, listener) {
36
+ var _a;
37
+ (_a = this.listeners[event]) === null || _a === void 0 ? void 0 : _a.delete(listener);
38
+ }
39
+ /** Subscribe to an event only once */
40
+ once(event, listener) {
41
+ return this.on(event, listener, { once: true });
42
+ }
43
+ /** Clear all events */
44
+ unAll() {
45
+ this.listeners = {};
46
+ }
47
+ /** Emit an event */
48
+ emit(eventName, ...args) {
49
+ if (this.listeners[eventName]) {
50
+ this.listeners[eventName].forEach((listener) => listener(...args));
51
+ }
52
+ }
53
+ }
54
+
55
+ /** Base class for wavesurfer plugins */
56
+ class BasePlugin extends EventEmitter {
57
+ /** Create a plugin instance */
58
+ constructor(options) {
59
+ super();
60
+ this.subscriptions = [];
61
+ this.isDestroyed = false;
62
+ this.options = options;
63
+ }
64
+ /** Called after this.wavesurfer is available */
65
+ onInit() {
66
+ return;
67
+ }
68
+ /** Do not call directly, only called by WavesSurfer internally */
69
+ _init(wavesurfer) {
70
+ // Reset state if plugin was previously destroyed
71
+ if (this.isDestroyed) {
72
+ this.subscriptions = [];
73
+ this.isDestroyed = false;
74
+ }
75
+ this.wavesurfer = wavesurfer;
76
+ this.onInit();
77
+ }
78
+ /** Destroy the plugin and unsubscribe from all events */
79
+ destroy() {
80
+ this.emit('destroy');
81
+ this.subscriptions.forEach((unsubscribe) => unsubscribe());
82
+ this.subscriptions = [];
83
+ this.isDestroyed = true;
84
+ this.wavesurfer = undefined;
85
+ }
86
+ }
87
+
88
+ var __awaiter$5 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
89
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
90
+ return new (P || (P = Promise))(function (resolve, reject) {
91
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
92
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
93
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
94
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
95
+ });
96
+ };
97
+ /** Decode an array buffer into an audio buffer */
98
+ function decode(audioData, sampleRate) {
99
+ return __awaiter$5(this, void 0, void 0, function* () {
100
+ const audioCtx = new AudioContext({ sampleRate });
101
+ try {
102
+ return yield audioCtx.decodeAudioData(audioData);
103
+ }
104
+ finally {
105
+ // Ensure AudioContext is always closed, even on synchronous errors
106
+ if (audioCtx.state !== 'closed') {
107
+ yield audioCtx.close().catch(() => undefined);
108
+ }
109
+ }
110
+ });
111
+ }
112
+ /** Normalize peaks to -1..1 */
113
+ function normalize(channelData) {
114
+ const firstChannel = channelData[0];
115
+ if (firstChannel.some((n) => n > 1 || n < -1)) {
116
+ const length = firstChannel.length;
117
+ let max = 0;
118
+ for (let i = 0; i < length; i++) {
119
+ const absN = Math.abs(firstChannel[i]);
120
+ if (absN > max)
121
+ max = absN;
122
+ }
123
+ for (const channel of channelData) {
124
+ for (let i = 0; i < length; i++) {
125
+ channel[i] /= max;
126
+ }
127
+ }
128
+ }
129
+ return channelData;
130
+ }
131
+ /** Create an audio buffer from pre-decoded audio data */
132
+ function createBuffer(channelData, duration) {
133
+ // Validate inputs
134
+ if (!channelData || channelData.length === 0) {
135
+ throw new Error('channelData must be a non-empty array');
136
+ }
137
+ if (duration <= 0) {
138
+ throw new Error('duration must be greater than 0');
139
+ }
140
+ // If a single array of numbers is passed, make it an array of arrays
141
+ if (typeof channelData[0] === 'number')
142
+ channelData = [channelData];
143
+ // Validate channel data after conversion
144
+ if (!channelData[0] || channelData[0].length === 0) {
145
+ throw new Error('channelData must contain non-empty channel arrays');
146
+ }
147
+ // Normalize to -1..1
148
+ normalize(channelData);
149
+ // Convert to Float32Array for consistency
150
+ const float32Channels = channelData.map((channel) => channel instanceof Float32Array ? channel : Float32Array.from(channel));
151
+ return {
152
+ duration,
153
+ length: float32Channels[0].length,
154
+ sampleRate: float32Channels[0].length / duration,
155
+ numberOfChannels: float32Channels.length,
156
+ getChannelData: (i) => {
157
+ const channel = float32Channels[i];
158
+ if (!channel) {
159
+ throw new Error(`Channel ${i} not found`);
160
+ }
161
+ return channel;
162
+ },
163
+ copyFromChannel: AudioBuffer.prototype.copyFromChannel,
164
+ copyToChannel: AudioBuffer.prototype.copyToChannel,
165
+ };
166
+ }
167
+ const Decoder = {
168
+ decode,
169
+ createBuffer,
170
+ };
171
+
172
+ function renderNode(tagName, content) {
173
+ const element = content.xmlns
174
+ ? document.createElementNS(content.xmlns, tagName)
175
+ : document.createElement(tagName);
176
+ for (const [key, value] of Object.entries(content)) {
177
+ if (key === 'children' && value) {
178
+ for (const [childTag, childValue] of Object.entries(value)) {
179
+ if (childValue instanceof Node) {
180
+ element.appendChild(childValue);
181
+ }
182
+ else if (typeof childValue === 'string') {
183
+ element.appendChild(document.createTextNode(childValue));
184
+ }
185
+ else {
186
+ element.appendChild(renderNode(childTag, childValue));
187
+ }
188
+ }
189
+ }
190
+ else if (key === 'style') {
191
+ Object.assign(element.style, value);
192
+ }
193
+ else if (key === 'textContent') {
194
+ element.textContent = value;
195
+ }
196
+ else {
197
+ element.setAttribute(key, value.toString());
198
+ }
199
+ }
200
+ return element;
201
+ }
202
+ function createElement(tagName, content, container) {
203
+ const el = renderNode(tagName, content || {});
204
+ container === null || container === void 0 ? void 0 : container.appendChild(el);
205
+ return el;
206
+ }
207
+ /**
208
+ * Check if a value is an HTML element, including elements from other realms
209
+ * (e.g. an iframe), for which `instanceof HTMLElement` returns false
210
+ */
211
+ function isHTMLElement(value) {
212
+ if (value instanceof HTMLElement)
213
+ return true;
214
+ return (typeof value === 'object' &&
215
+ value !== null &&
216
+ value.nodeType === Node.ELEMENT_NODE &&
217
+ typeof value.style === 'object');
218
+ }
219
+
220
+ const dom = /*#__PURE__*/Object.freeze({
221
+ __proto__: null,
222
+ createElement: createElement,
223
+ isHTMLElement: isHTMLElement,
224
+ 'default': createElement
225
+ });
226
+
227
+ var __awaiter$4 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
228
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
229
+ return new (P || (P = Promise))(function (resolve, reject) {
230
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
231
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
232
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
233
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
234
+ });
235
+ };
236
+ function watchProgress(response, progressCallback, signal) {
237
+ return __awaiter$4(this, void 0, void 0, function* () {
238
+ var _a;
239
+ if (!response.body || !response.headers)
240
+ return;
241
+ const reader = response.body.getReader();
242
+ const contentLength = Number(response.headers.get('Content-Length')) || 0;
243
+ let receivedLength = 0;
244
+ // Abort the reader when the signal fires
245
+ const onAbort = () => {
246
+ reader.cancel();
247
+ };
248
+ if (signal) {
249
+ if (signal.aborted) {
250
+ reader.cancel();
251
+ return;
252
+ }
253
+ signal.addEventListener('abort', onAbort, { once: true });
254
+ }
255
+ // Use iteration instead of recursion to avoid stack issues
256
+ try {
257
+ while (true) {
258
+ const data = yield reader.read();
259
+ if (data.done) {
260
+ break;
261
+ }
262
+ receivedLength += ((_a = data.value) === null || _a === void 0 ? void 0 : _a.length) || 0;
263
+ // Only report progress if Content-Length is available and non-zero
264
+ if (contentLength > 0) {
265
+ const percentage = Math.round((receivedLength / contentLength) * 100);
266
+ progressCallback(percentage);
267
+ }
268
+ }
269
+ }
270
+ catch (err) {
271
+ // Ignore abort errors from reader cancellation
272
+ if (err instanceof DOMException && err.name === 'AbortError')
273
+ return;
274
+ // Ignore other errors because we can only handle the main response
275
+ console.warn('Progress tracking error:', err);
276
+ }
277
+ finally {
278
+ // Remove the abort listener to prevent leaks
279
+ if (signal) {
280
+ signal.removeEventListener('abort', onAbort);
281
+ }
282
+ }
283
+ });
284
+ }
285
+ function fetchBlob(url, progressCallback, requestInit) {
286
+ return __awaiter$4(this, void 0, void 0, function* () {
287
+ var _a;
288
+ // Fetch the resource
289
+ const response = yield fetch(url, requestInit);
290
+ if (response.status >= 400) {
291
+ throw new Error(`Failed to fetch ${url}: ${response.status} (${response.statusText})`);
292
+ }
293
+ // Read the data to track progress
294
+ // Pass the abort signal so the progress reader can be cancelled
295
+ watchProgress(response.clone(), progressCallback, (_a = requestInit === null || requestInit === void 0 ? void 0 : requestInit.signal) !== null && _a !== void 0 ? _a : undefined);
296
+ return response.blob();
297
+ });
298
+ }
299
+ const Fetcher = {
300
+ fetchBlob,
301
+ };
302
+
303
+ /**
304
+ * Reactive primitives for managing state in WaveSurfer
305
+ *
306
+ * This module provides signal-based reactivity similar to SolidJS signals.
307
+ * Signals are reactive values that notify subscribers when they change.
308
+ */
309
+ /**
310
+ * Create a reactive signal that notifies subscribers when its value changes
311
+ *
312
+ * @example
313
+ * ```typescript
314
+ * const count = signal(0)
315
+ * count.subscribe(val => console.log('Count:', val))
316
+ * count.set(5) // Logs: Count: 5
317
+ * ```
318
+ */
319
+ function signal(initialValue) {
320
+ let _value = initialValue;
321
+ const subscribers = new Set();
322
+ return {
323
+ get value() {
324
+ return _value;
325
+ },
326
+ set(newValue) {
327
+ // Only update and notify if value actually changed
328
+ if (!Object.is(_value, newValue)) {
329
+ _value = newValue;
330
+ subscribers.forEach((fn) => fn(_value));
331
+ }
332
+ },
333
+ update(fn) {
334
+ this.set(fn(_value));
335
+ },
336
+ subscribe(callback) {
337
+ subscribers.add(callback);
338
+ return () => subscribers.delete(callback);
339
+ },
340
+ };
341
+ }
342
+ /**
343
+ * Create a computed value that automatically updates when its dependencies change
344
+ *
345
+ * @example
346
+ * ```typescript
347
+ * const count = signal(0)
348
+ * const doubled = computed(() => count.value * 2, [count])
349
+ * console.log(doubled.value) // 0
350
+ * count.set(5)
351
+ * console.log(doubled.value) // 10
352
+ * ```
353
+ */
354
+ function computed(fn, dependencies) {
355
+ const result = signal(fn());
356
+ // Subscribe to all dependencies immediately
357
+ // This ensures the computed value stays in sync even if no one is subscribed to it
358
+ dependencies.forEach((dep) => dep.subscribe(() => {
359
+ const newValue = fn();
360
+ // Update the result signal, which will notify our subscribers if value changed
361
+ if (!Object.is(result.value, newValue)) {
362
+ result.set(newValue);
363
+ }
364
+ }));
365
+ // Return a read-only signal that proxies the result
366
+ return {
367
+ get value() {
368
+ return result.value;
369
+ },
370
+ subscribe(callback) {
371
+ // Just subscribe to result changes
372
+ return result.subscribe(callback);
373
+ },
374
+ };
375
+ }
376
+ /**
377
+ * Run a side effect automatically when dependencies change
378
+ *
379
+ * @param fn - Effect function. Can return a cleanup function.
380
+ * @param dependencies - Signals that trigger the effect when they change
381
+ * @returns Unsubscribe function that stops the effect and runs cleanup
382
+ *
383
+ * @example
384
+ * ```typescript
385
+ * const count = signal(0)
386
+ * effect(() => {
387
+ * console.log('Count is:', count.value)
388
+ * return () => console.log('Cleanup')
389
+ * }, [count])
390
+ * count.set(5) // Logs: Cleanup, Count is: 5
391
+ * ```
392
+ */
393
+ function effect(fn, dependencies) {
394
+ let cleanup;
395
+ const run = () => {
396
+ // Run cleanup from previous execution
397
+ if (cleanup) {
398
+ cleanup();
399
+ cleanup = undefined;
400
+ }
401
+ // Run effect and capture new cleanup
402
+ cleanup = fn();
403
+ };
404
+ // Subscribe to all dependencies
405
+ const unsubscribes = dependencies.map((dep) => dep.subscribe(run));
406
+ // Run effect immediately
407
+ run();
408
+ // Return function that unsubscribes and runs cleanup
409
+ return () => {
410
+ if (cleanup) {
411
+ cleanup();
412
+ cleanup = undefined;
413
+ }
414
+ unsubscribes.forEach((unsub) => unsub());
415
+ };
416
+ }
417
+
418
+ var __awaiter$3 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
419
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
420
+ return new (P || (P = Promise))(function (resolve, reject) {
421
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
422
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
423
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
424
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
425
+ });
426
+ };
427
+ class Player extends EventEmitter {
428
+ // Expose reactive state as writable signals
429
+ // These are writable to allow WaveSurfer to compose them into centralized state
430
+ get isPlayingSignal() {
431
+ return this._isPlaying;
432
+ }
433
+ get currentTimeSignal() {
434
+ return this._currentTime;
435
+ }
436
+ get durationSignal() {
437
+ return this._duration;
438
+ }
439
+ get volumeSignal() {
440
+ return this._volume;
441
+ }
442
+ get mutedSignal() {
443
+ return this._muted;
444
+ }
445
+ get playbackRateSignal() {
446
+ return this._playbackRate;
447
+ }
448
+ get seekingSignal() {
449
+ return this._seeking;
450
+ }
451
+ constructor(options) {
452
+ super();
453
+ this.isExternalMedia = false;
454
+ this._ownBlobUrl = null;
455
+ this.reactiveMediaEventCleanups = [];
456
+ if (options.media) {
457
+ this.media = options.media;
458
+ this.isExternalMedia = true;
459
+ }
460
+ else {
461
+ this.media = document.createElement('audio');
462
+ }
463
+ // Initialize reactive state
464
+ this._isPlaying = signal(false);
465
+ this._currentTime = signal(0);
466
+ this._duration = signal(0);
467
+ this._volume = signal(this.media.volume);
468
+ this._muted = signal(this.media.muted);
469
+ this._playbackRate = signal(this.media.playbackRate || 1);
470
+ this._seeking = signal(false);
471
+ // Setup reactive media event handlers
472
+ this.setupReactiveMediaEvents();
473
+ // Controls
474
+ if (options.mediaControls) {
475
+ this.media.controls = true;
476
+ }
477
+ // Autoplay
478
+ if (options.autoplay) {
479
+ this.media.autoplay = true;
480
+ }
481
+ // Speed
482
+ if (options.playbackRate != null) {
483
+ this.onMediaEvent('canplay', () => {
484
+ if (options.playbackRate != null) {
485
+ this.media.playbackRate = options.playbackRate;
486
+ }
487
+ }, { once: true });
488
+ }
489
+ }
490
+ /**
491
+ * Setup reactive media event handlers that update signals
492
+ * This bridges the imperative HTMLMediaElement API to reactive state
493
+ */
494
+ setupReactiveMediaEvents() {
495
+ // Playing state
496
+ this.reactiveMediaEventCleanups.push(this.onMediaEvent('play', () => {
497
+ this._isPlaying.set(true);
498
+ }));
499
+ this.reactiveMediaEventCleanups.push(this.onMediaEvent('pause', () => {
500
+ this._isPlaying.set(false);
501
+ }));
502
+ this.reactiveMediaEventCleanups.push(this.onMediaEvent('ended', () => {
503
+ this._isPlaying.set(false);
504
+ }));
505
+ // Time tracking
506
+ this.reactiveMediaEventCleanups.push(this.onMediaEvent('timeupdate', () => {
507
+ this._currentTime.set(this.media.currentTime);
508
+ }));
509
+ this.reactiveMediaEventCleanups.push(this.onMediaEvent('durationchange', () => {
510
+ this._duration.set(this.media.duration || 0);
511
+ }));
512
+ this.reactiveMediaEventCleanups.push(this.onMediaEvent('loadedmetadata', () => {
513
+ this._duration.set(this.media.duration || 0);
514
+ }));
515
+ // Seeking state
516
+ this.reactiveMediaEventCleanups.push(this.onMediaEvent('seeking', () => {
517
+ this._seeking.set(true);
518
+ }));
519
+ this.reactiveMediaEventCleanups.push(this.onMediaEvent('seeked', () => {
520
+ this._seeking.set(false);
521
+ }));
522
+ // Volume and muted
523
+ this.reactiveMediaEventCleanups.push(this.onMediaEvent('volumechange', () => {
524
+ this._volume.set(this.media.volume);
525
+ this._muted.set(this.media.muted);
526
+ }));
527
+ // Playback rate
528
+ this.reactiveMediaEventCleanups.push(this.onMediaEvent('ratechange', () => {
529
+ this._playbackRate.set(this.media.playbackRate);
530
+ }));
531
+ }
532
+ onMediaEvent(event, callback, options) {
533
+ this.media.addEventListener(event, callback, options);
534
+ return () => this.media.removeEventListener(event, callback, options);
535
+ }
536
+ getSrc() {
537
+ return this.media.currentSrc || this.media.src || '';
538
+ }
539
+ revokeSrc() {
540
+ // Only revoke blob URLs that we created (not ones owned by external callers)
541
+ if (this._ownBlobUrl) {
542
+ URL.revokeObjectURL(this._ownBlobUrl);
543
+ this._ownBlobUrl = null;
544
+ }
545
+ }
546
+ canPlayType(type) {
547
+ return this.media.canPlayType(type) !== '';
548
+ }
549
+ setSrc(url, blob) {
550
+ const prevSrc = this.getSrc();
551
+ if (url && prevSrc === url)
552
+ return; // no need to change the source
553
+ this.revokeSrc();
554
+ const newSrc = blob instanceof Blob && (this.canPlayType(blob.type) || !url) ? URL.createObjectURL(blob) : url;
555
+ // Track blob URLs we created so we can revoke them on destroy
556
+ if (newSrc !== url) {
557
+ this._ownBlobUrl = newSrc;
558
+ }
559
+ // Reset the media element, otherwise it keeps the previous source
560
+ if (prevSrc) {
561
+ this.media.removeAttribute('src');
562
+ }
563
+ if (newSrc || url) {
564
+ try {
565
+ this.media.src = newSrc;
566
+ }
567
+ catch (_a) {
568
+ this.media.src = url;
569
+ }
570
+ }
571
+ }
572
+ destroy() {
573
+ // Cleanup reactive media event listeners
574
+ this.reactiveMediaEventCleanups.forEach((cleanup) => cleanup());
575
+ this.reactiveMediaEventCleanups = [];
576
+ // Revoke blob URLs that we created
577
+ this.revokeSrc();
578
+ // Clear all event emitter listeners
579
+ this.unAll();
580
+ if (this.isExternalMedia)
581
+ return;
582
+ this.media.pause();
583
+ this.media.removeAttribute('src');
584
+ // Load resets the media element to its initial state
585
+ this.media.load();
586
+ // Remove from DOM after cleanup
587
+ this.media.remove();
588
+ }
589
+ setMediaElement(element) {
590
+ // Cleanup reactive event listeners from old media element
591
+ this.reactiveMediaEventCleanups.forEach((cleanup) => cleanup());
592
+ this.reactiveMediaEventCleanups = [];
593
+ // Set new media element
594
+ this.media = element;
595
+ // Reinitialize reactive event listeners on new media element
596
+ this.setupReactiveMediaEvents();
597
+ }
598
+ /** Start playing the audio */
599
+ play() {
600
+ return __awaiter$3(this, void 0, void 0, function* () {
601
+ try {
602
+ return yield this.media.play();
603
+ }
604
+ catch (err) {
605
+ if (err instanceof DOMException && err.name === 'AbortError') {
606
+ return;
607
+ }
608
+ throw err;
609
+ }
610
+ });
611
+ }
612
+ /** Pause the audio */
613
+ pause() {
614
+ this.media.pause();
615
+ }
616
+ /** Check if the audio is playing */
617
+ isPlaying() {
618
+ return !this.media.paused && !this.media.ended;
619
+ }
620
+ /** Jump to a specific time in the audio (in seconds) */
621
+ setTime(time) {
622
+ this.media.currentTime = Math.max(0, Math.min(time, this.getDuration()));
623
+ }
624
+ /** Get the duration of the audio in seconds */
625
+ getDuration() {
626
+ return this.media.duration;
627
+ }
628
+ /** Get the current audio position in seconds */
629
+ getCurrentTime() {
630
+ return this.media.currentTime;
631
+ }
632
+ /** Get the audio volume */
633
+ getVolume() {
634
+ return this.media.volume;
635
+ }
636
+ /** Set the audio volume */
637
+ setVolume(volume) {
638
+ this.media.volume = volume;
639
+ }
640
+ /** Get the audio muted state */
641
+ getMuted() {
642
+ return this.media.muted;
643
+ }
644
+ /** Mute or unmute the audio */
645
+ setMuted(muted) {
646
+ this.media.muted = muted;
647
+ }
648
+ /** Get the playback speed */
649
+ getPlaybackRate() {
650
+ return this.media.playbackRate;
651
+ }
652
+ /** Check if the audio is seeking */
653
+ isSeeking() {
654
+ return this.media.seeking;
655
+ }
656
+ /** Set the playback speed, pass an optional false to NOT preserve the pitch */
657
+ setPlaybackRate(rate, preservePitch) {
658
+ // preservePitch is true by default in most browsers
659
+ if (preservePitch != null) {
660
+ this.media.preservesPitch = preservePitch;
661
+ }
662
+ this.media.playbackRate = rate;
663
+ }
664
+ /** Get the HTML media element */
665
+ getMediaElement() {
666
+ return this.media;
667
+ }
668
+ /** Set a sink id to change the audio output device */
669
+ setSinkId(sinkId) {
670
+ // See https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/setSinkId
671
+ const media = this.media;
672
+ return media.setSinkId(sinkId);
673
+ }
674
+ }
675
+
676
+ const DEFAULT_HEIGHT = 128;
677
+ const MAX_CANVAS_WIDTH = 8000;
678
+ const MAX_NODES = 10;
679
+ function clampToUnit(value) {
680
+ if (value < 0)
681
+ return 0;
682
+ if (value > 1)
683
+ return 1;
684
+ return value;
685
+ }
686
+ function calculateBarRenderConfig({ width, height, length, options, pixelRatio, }) {
687
+ const halfHeight = height / 2;
688
+ const barWidth = options.barWidth ? options.barWidth * pixelRatio : 1;
689
+ const barGap = options.barGap ? options.barGap * pixelRatio : options.barWidth ? barWidth / 2 : 0;
690
+ const barRadius = options.barRadius || 0;
691
+ const barMinHeight = options.barMinHeight ? options.barMinHeight * pixelRatio : 0;
692
+ const spacing = barWidth + barGap || 1;
693
+ const barIndexScale = length > 0 ? width / spacing / length : 0;
694
+ return {
695
+ halfHeight,
696
+ barWidth,
697
+ barGap,
698
+ barRadius,
699
+ barMinHeight,
700
+ barIndexScale,
701
+ barSpacing: spacing,
702
+ };
703
+ }
704
+ function calculateBarHeights({ maxTop, maxBottom, halfHeight, vScale, barMinHeight = 0, barAlign, }) {
705
+ let topHeight = Math.round(maxTop * halfHeight * vScale);
706
+ const bottomHeight = Math.round(maxBottom * halfHeight * vScale);
707
+ let totalHeight = topHeight + bottomHeight || 1;
708
+ if (totalHeight < barMinHeight) {
709
+ totalHeight = barMinHeight;
710
+ if (!barAlign) {
711
+ topHeight = totalHeight / 2;
712
+ }
713
+ }
714
+ return { topHeight, totalHeight };
715
+ }
716
+ function resolveBarYPosition({ barAlign, halfHeight, topHeight, totalHeight, canvasHeight, }) {
717
+ if (barAlign === 'top')
718
+ return 0;
719
+ if (barAlign === 'bottom')
720
+ return canvasHeight - totalHeight;
721
+ return halfHeight - topHeight;
722
+ }
723
+ function calculateBarSegments({ channelData, barIndexScale, barSpacing, barWidth, halfHeight, vScale, canvasHeight, barAlign, barMinHeight, }) {
724
+ const topChannel = channelData[0] || [];
725
+ const bottomChannel = channelData[1] || topChannel;
726
+ const length = topChannel.length;
727
+ const segments = [];
728
+ let prevX = 0;
729
+ let maxTop = 0;
730
+ let maxBottom = 0;
731
+ for (let i = 0; i <= length; i++) {
732
+ const x = Math.round(i * barIndexScale);
733
+ if (x > prevX) {
734
+ const { topHeight, totalHeight } = calculateBarHeights({
735
+ maxTop,
736
+ maxBottom,
737
+ halfHeight,
738
+ vScale,
739
+ barMinHeight,
740
+ barAlign,
741
+ });
742
+ const y = resolveBarYPosition({
743
+ barAlign,
744
+ halfHeight,
745
+ topHeight,
746
+ totalHeight,
747
+ canvasHeight,
748
+ });
749
+ segments.push({
750
+ x: prevX * barSpacing,
751
+ y,
752
+ width: barWidth,
753
+ height: totalHeight,
754
+ });
755
+ prevX = x;
756
+ maxTop = 0;
757
+ maxBottom = 0;
758
+ }
759
+ const magnitudeTop = Math.abs(topChannel[i] || 0);
760
+ const magnitudeBottom = Math.abs(bottomChannel[i] || 0);
761
+ if (magnitudeTop > maxTop)
762
+ maxTop = magnitudeTop;
763
+ if (magnitudeBottom > maxBottom)
764
+ maxBottom = magnitudeBottom;
765
+ }
766
+ return segments;
767
+ }
768
+ function getRelativePointerPosition(rect, clientX, clientY) {
769
+ const x = clientX - rect.left;
770
+ const y = clientY - rect.top;
771
+ const relativeX = x / rect.width;
772
+ const relativeY = y / rect.height;
773
+ return [relativeX, relativeY];
774
+ }
775
+ function resolveChannelHeight({ optionsHeight, optionsSplitChannels, parentHeight, numberOfChannels, defaultHeight = DEFAULT_HEIGHT, }) {
776
+ if (optionsHeight == null)
777
+ return defaultHeight;
778
+ const numericHeight = Number(optionsHeight);
779
+ if (!isNaN(numericHeight))
780
+ return numericHeight;
781
+ if (optionsHeight === 'auto') {
782
+ const height = parentHeight || defaultHeight;
783
+ if (optionsSplitChannels === null || optionsSplitChannels === void 0 ? void 0 : optionsSplitChannels.every((channel) => !channel.overlay)) {
784
+ return height / numberOfChannels;
785
+ }
786
+ return height;
787
+ }
788
+ return defaultHeight;
789
+ }
790
+ function getPixelRatio(devicePixelRatio) {
791
+ return Math.max(1, devicePixelRatio || 1);
792
+ }
793
+ function shouldRenderBars(options) {
794
+ return Boolean(options.barWidth || options.barGap || options.barAlign);
795
+ }
796
+ function resolveColorValue(color, devicePixelRatio, canvasHeight) {
797
+ if (!Array.isArray(color))
798
+ return color || '';
799
+ if (color.length === 0)
800
+ return '#999';
801
+ if (color.length < 2)
802
+ return color[0] || '';
803
+ const canvasElement = document.createElement('canvas');
804
+ const ctx = canvasElement.getContext('2d');
805
+ if (!ctx)
806
+ return color[0] || '';
807
+ const gradientHeight = canvasHeight || canvasElement.height * devicePixelRatio;
808
+ const gradient = ctx.createLinearGradient(0, 0, 0, gradientHeight);
809
+ const colorStopPercentage = 1 / (color.length - 1);
810
+ color.forEach((value, index) => {
811
+ gradient.addColorStop(index * colorStopPercentage, value);
812
+ });
813
+ return gradient;
814
+ }
815
+ function calculateWaveformLayout({ duration, minPxPerSec = 0, parentWidth, fillParent, pixelRatio, }) {
816
+ const scrollWidth = Math.ceil(duration * minPxPerSec);
817
+ const isScrollable = scrollWidth > parentWidth;
818
+ const useParentWidth = Boolean(fillParent && !isScrollable);
819
+ const width = (useParentWidth ? parentWidth : scrollWidth) * pixelRatio;
820
+ return {
821
+ scrollWidth,
822
+ isScrollable,
823
+ useParentWidth,
824
+ width,
825
+ };
826
+ }
827
+ function clampWidthToBarGrid(width, options) {
828
+ if (!shouldRenderBars(options))
829
+ return width;
830
+ const barWidth = options.barWidth || 0.5;
831
+ const barGap = options.barGap || barWidth / 2;
832
+ const totalBarWidth = barWidth + barGap;
833
+ if (totalBarWidth === 0)
834
+ return width;
835
+ return Math.floor(width / totalBarWidth) * totalBarWidth;
836
+ }
837
+ function calculateSingleCanvasWidth({ clientWidth, totalWidth, options, }) {
838
+ const baseWidth = Math.min(MAX_CANVAS_WIDTH, clientWidth, totalWidth);
839
+ return clampWidthToBarGrid(baseWidth, options);
840
+ }
841
+ function sliceChannelData({ channelData, offset, clampedWidth, totalWidth, }) {
842
+ return channelData.map((channel) => {
843
+ const start = Math.floor((offset / totalWidth) * channel.length);
844
+ const end = Math.floor(((offset + clampedWidth) / totalWidth) * channel.length);
845
+ return channel.slice(start, end);
846
+ });
847
+ }
848
+ function shouldClearCanvases(currentNodeCount) {
849
+ return currentNodeCount > MAX_NODES;
850
+ }
851
+ function getLazyRenderRange({ scrollLeft, totalWidth, numCanvases, }) {
852
+ if (totalWidth === 0)
853
+ return [0];
854
+ const viewPosition = scrollLeft / totalWidth;
855
+ const startCanvas = Math.floor(viewPosition * numCanvases);
856
+ return [startCanvas - 1, startCanvas, startCanvas + 1];
857
+ }
858
+ function calculateVerticalScale({ channelData, barHeight, normalize, maxPeak, }) {
859
+ var _a;
860
+ const baseScale = barHeight || 1;
861
+ if (!normalize)
862
+ return baseScale;
863
+ const firstChannel = channelData[0];
864
+ if (!firstChannel || firstChannel.length === 0)
865
+ return baseScale;
866
+ // Use fixed max peak if provided, otherwise calculate from data
867
+ let max = maxPeak !== null && maxPeak !== void 0 ? maxPeak : 0;
868
+ if (!maxPeak) {
869
+ for (let i = 0; i < firstChannel.length; i++) {
870
+ const value = (_a = firstChannel[i]) !== null && _a !== void 0 ? _a : 0;
871
+ const magnitude = Math.abs(value);
872
+ if (magnitude > max)
873
+ max = magnitude;
874
+ }
875
+ }
876
+ if (!max)
877
+ return baseScale;
878
+ return baseScale / max;
879
+ }
880
+ function calculateLinePaths({ channelData, width, height, vScale, }) {
881
+ const halfHeight = height / 2;
882
+ const primaryChannel = channelData[0] || [];
883
+ const secondaryChannel = channelData[1] || primaryChannel;
884
+ const channels = [primaryChannel, secondaryChannel];
885
+ return channels.map((channel, index) => {
886
+ const length = channel.length;
887
+ const hScale = length ? width / length : 0;
888
+ const baseY = halfHeight;
889
+ const direction = index === 0 ? -1 : 1;
890
+ const path = [{ x: 0, y: baseY }];
891
+ let prevX = 0;
892
+ let max = 0;
893
+ for (let i = 0; i <= length; i++) {
894
+ const x = Math.round(i * hScale);
895
+ if (x > prevX) {
896
+ const heightDelta = Math.round(max * halfHeight * vScale) || 1;
897
+ const y = baseY + heightDelta * direction;
898
+ path.push({ x: prevX, y });
899
+ prevX = x;
900
+ max = 0;
901
+ }
902
+ const value = Math.abs(channel[i] || 0);
903
+ if (value > max)
904
+ max = value;
905
+ }
906
+ path.push({ x: prevX, y: baseY });
907
+ return path;
908
+ });
909
+ }
910
+ function roundToHalfAwayFromZero(value) {
911
+ const scaled = value * 2;
912
+ const rounded = scaled < 0 ? Math.floor(scaled) : Math.ceil(scaled);
913
+ return rounded / 2;
914
+ }
915
+
916
+ /**
917
+ * Event stream utilities for converting DOM events to reactive signals
918
+ *
919
+ * These utilities allow composing event handling using reactive primitives.
920
+ */
921
+ /**
922
+ * Cleanup a stream created with event stream utilities
923
+ *
924
+ * This removes event listeners and unsubscribes from sources.
925
+ */
926
+ function cleanup(stream) {
927
+ const cleanupFn = stream._cleanup;
928
+ if (typeof cleanupFn === 'function') {
929
+ cleanupFn();
930
+ }
931
+ }
932
+
933
+ /**
934
+ * Reactive drag stream utilities
935
+ *
936
+ * Provides declarative drag handling using reactive streams.
937
+ * Automatically handles mouseup cleanup and supports constraints.
938
+ */
939
+ /**
940
+ * Create a reactive drag stream from an element
941
+ *
942
+ * Emits drag events (start, move, end) as the user drags the element.
943
+ * Automatically handles pointer capture, multi-touch prevention, and cleanup.
944
+ *
945
+ * @example
946
+ * ```typescript
947
+ * const dragSignal = createDragStream(element)
948
+ *
949
+ * effect(() => {
950
+ * const drag = dragSignal.value
951
+ * if (drag?.type === 'move') {
952
+ * console.log('Dragging:', drag.deltaX, drag.deltaY)
953
+ * }
954
+ * }, [dragSignal])
955
+ * ```
956
+ *
957
+ * @param element - Element to make draggable
958
+ * @param options - Drag configuration options
959
+ * @returns Signal emitting drag events and cleanup function
960
+ */
961
+ function createDragStream(element, options = {}) {
962
+ const { threshold = 3, mouseButton = 0, touchDelay = 100 } = options;
963
+ const dragSignal = signal(null);
964
+ const activePointers = new Map();
965
+ const isTouchDevice = matchMedia('(pointer: coarse)').matches;
966
+ let unsubscribeDocument = () => void 0;
967
+ const onPointerDown = (event) => {
968
+ if (event.button !== mouseButton)
969
+ return;
970
+ if (activePointers.has(event.pointerId))
971
+ return;
972
+ activePointers.set(event.pointerId, event);
973
+ if (activePointers.size > 1) {
974
+ return;
975
+ }
976
+ const dragPointerId = event.pointerId;
977
+ let startX = event.clientX;
978
+ let startY = event.clientY;
979
+ let isDragging = false;
980
+ const touchStartTime = Date.now();
981
+ const rect = element.getBoundingClientRect();
982
+ const { left, top } = rect;
983
+ const onPointerMove = (event) => {
984
+ if (event.pointerId !== dragPointerId)
985
+ return;
986
+ if (event.defaultPrevented || activePointers.size > 1) {
987
+ return;
988
+ }
989
+ if (isTouchDevice && Date.now() - touchStartTime < touchDelay)
990
+ return;
991
+ const x = event.clientX;
992
+ const y = event.clientY;
993
+ const dx = x - startX;
994
+ const dy = y - startY;
995
+ if (isDragging || Math.abs(dx) > threshold || Math.abs(dy) > threshold) {
996
+ event.preventDefault();
997
+ event.stopPropagation();
998
+ if (!isDragging) {
999
+ // Emit start event
1000
+ dragSignal.set({
1001
+ type: 'start',
1002
+ x: startX - left,
1003
+ y: startY - top,
1004
+ });
1005
+ isDragging = true;
1006
+ }
1007
+ // Emit move event
1008
+ dragSignal.set({
1009
+ type: 'move',
1010
+ x: x - left,
1011
+ y: y - top,
1012
+ deltaX: dx,
1013
+ deltaY: dy,
1014
+ });
1015
+ startX = x;
1016
+ startY = y;
1017
+ }
1018
+ };
1019
+ const onPointerUp = (event) => {
1020
+ // Only react to pointers that started on the element
1021
+ if (!activePointers.delete(event.pointerId))
1022
+ return;
1023
+ // Only the pointer that started the drag can end it
1024
+ if (event.pointerId === dragPointerId && isDragging) {
1025
+ const x = event.clientX;
1026
+ const y = event.clientY;
1027
+ // Emit end event
1028
+ dragSignal.set({
1029
+ type: 'end',
1030
+ x: x - left,
1031
+ y: y - top,
1032
+ });
1033
+ }
1034
+ // Keep listening until all pointers are released
1035
+ if (activePointers.size === 0) {
1036
+ unsubscribeDocument();
1037
+ }
1038
+ };
1039
+ const onPointerLeave = (e) => {
1040
+ if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
1041
+ onPointerUp(e);
1042
+ }
1043
+ };
1044
+ const onClick = (event) => {
1045
+ if (isDragging) {
1046
+ event.stopPropagation();
1047
+ event.preventDefault();
1048
+ }
1049
+ };
1050
+ const onTouchMove = (event) => {
1051
+ if (event.defaultPrevented || activePointers.size > 1) {
1052
+ return;
1053
+ }
1054
+ if (isDragging) {
1055
+ event.preventDefault();
1056
+ }
1057
+ };
1058
+ document.addEventListener('pointermove', onPointerMove);
1059
+ document.addEventListener('pointerup', onPointerUp);
1060
+ document.addEventListener('pointerout', onPointerLeave);
1061
+ document.addEventListener('pointercancel', onPointerLeave);
1062
+ document.addEventListener('touchmove', onTouchMove, { passive: false });
1063
+ document.addEventListener('click', onClick, { capture: true });
1064
+ unsubscribeDocument = () => {
1065
+ document.removeEventListener('pointermove', onPointerMove);
1066
+ document.removeEventListener('pointerup', onPointerUp);
1067
+ document.removeEventListener('pointerout', onPointerLeave);
1068
+ document.removeEventListener('pointercancel', onPointerLeave);
1069
+ document.removeEventListener('touchmove', onTouchMove);
1070
+ setTimeout(() => {
1071
+ document.removeEventListener('click', onClick, { capture: true });
1072
+ }, 10);
1073
+ };
1074
+ };
1075
+ element.addEventListener('pointerdown', onPointerDown);
1076
+ const cleanupFn = () => {
1077
+ unsubscribeDocument();
1078
+ element.removeEventListener('pointerdown', onPointerDown);
1079
+ activePointers.clear();
1080
+ cleanup(dragSignal);
1081
+ };
1082
+ return {
1083
+ signal: dragSignal,
1084
+ cleanup: cleanupFn,
1085
+ };
1086
+ }
1087
+
1088
+ /**
1089
+ * Reactive scroll stream utilities
1090
+ *
1091
+ * Provides declarative scroll handling using reactive streams.
1092
+ * Automatically handles scroll event optimization and cleanup.
1093
+ */
1094
+ // ============================================================================
1095
+ // Pure Scroll Calculation Functions
1096
+ // ============================================================================
1097
+ /**
1098
+ * Calculate visible percentages from scroll data
1099
+ * Pure function - no side effects
1100
+ *
1101
+ * @param scrollData - Current scroll dimensions
1102
+ * @returns Start and end positions as percentages (0-1)
1103
+ */
1104
+ function calculateScrollPercentages(scrollData) {
1105
+ const { scrollLeft, scrollWidth, clientWidth } = scrollData;
1106
+ if (scrollWidth === 0) {
1107
+ return { startX: 0, endX: 1 };
1108
+ }
1109
+ const startX = scrollLeft / scrollWidth;
1110
+ const endX = (scrollLeft + clientWidth) / scrollWidth;
1111
+ return {
1112
+ startX: Math.max(0, Math.min(1, startX)),
1113
+ endX: Math.max(0, Math.min(1, endX)),
1114
+ };
1115
+ }
1116
+ /**
1117
+ * Calculate scroll bounds in pixels
1118
+ * Pure function - no side effects
1119
+ *
1120
+ * @param scrollData - Current scroll dimensions
1121
+ * @returns Left and right scroll bounds in pixels
1122
+ */
1123
+ function calculateScrollBounds(scrollData) {
1124
+ return {
1125
+ left: scrollData.scrollLeft,
1126
+ right: scrollData.scrollLeft + scrollData.clientWidth,
1127
+ };
1128
+ }
1129
+ /**
1130
+ * Create a reactive scroll stream from an element
1131
+ *
1132
+ * Emits scroll data as the user scrolls the element.
1133
+ * Automatically computes derived values (percentages, bounds).
1134
+ *
1135
+ * @example
1136
+ * ```typescript
1137
+ * const scrollStream = createScrollStream(container)
1138
+ *
1139
+ * effect(() => {
1140
+ * const { startX, endX } = scrollStream.percentages.value
1141
+ * console.log('Visible:', startX, 'to', endX)
1142
+ * }, [scrollStream.percentages])
1143
+ *
1144
+ * scrollStream.cleanup()
1145
+ * ```
1146
+ *
1147
+ * @param element - Scrollable element
1148
+ * @returns Scroll stream with signals and cleanup
1149
+ */
1150
+ function createScrollStream(element) {
1151
+ // Create signals
1152
+ const scrollData = signal({
1153
+ scrollLeft: element.scrollLeft,
1154
+ scrollWidth: element.scrollWidth,
1155
+ clientWidth: element.clientWidth,
1156
+ });
1157
+ // Computed derived values
1158
+ const percentages = computed(() => {
1159
+ return calculateScrollPercentages(scrollData.value);
1160
+ }, [scrollData]);
1161
+ const bounds = computed(() => {
1162
+ return calculateScrollBounds(scrollData.value);
1163
+ }, [scrollData]);
1164
+ // Update scroll data on scroll event
1165
+ const onScroll = () => {
1166
+ scrollData.set({
1167
+ scrollLeft: element.scrollLeft,
1168
+ scrollWidth: element.scrollWidth,
1169
+ clientWidth: element.clientWidth,
1170
+ });
1171
+ };
1172
+ // Attach scroll listener
1173
+ element.addEventListener('scroll', onScroll, { passive: true });
1174
+ // Cleanup function
1175
+ const cleanupFn = () => {
1176
+ element.removeEventListener('scroll', onScroll);
1177
+ cleanup(scrollData);
1178
+ };
1179
+ return {
1180
+ scrollData,
1181
+ percentages,
1182
+ bounds,
1183
+ cleanup: cleanupFn,
1184
+ };
1185
+ }
1186
+
1187
+ var __awaiter$2 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
1188
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1189
+ return new (P || (P = Promise))(function (resolve, reject) {
1190
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1191
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1192
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1193
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1194
+ });
1195
+ };
1196
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
1197
+ var t = {};
1198
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1199
+ t[p] = s[p];
1200
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1201
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1202
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1203
+ t[p[i]] = s[p[i]];
1204
+ }
1205
+ return t;
1206
+ };
1207
+ const SMOOTH_SCROLL_FPS = 60;
1208
+ const SMOOTH_SCROLL_MAX_DELTA = 10;
1209
+ const LOW_ZOOM_PIXELS_PER_SECOND_THRESHOLD = SMOOTH_SCROLL_MAX_DELTA * SMOOTH_SCROLL_FPS;
1210
+ class Renderer extends EventEmitter {
1211
+ constructor(options, audioElement) {
1212
+ super();
1213
+ this.timeouts = [];
1214
+ this.isScrollable = false;
1215
+ this.audioData = null;
1216
+ this.resizeObserver = null;
1217
+ this.lastContainerWidth = 0;
1218
+ this.isDragging = false;
1219
+ this.subscriptions = [];
1220
+ this.unsubscribeOnScroll = [];
1221
+ this.dragStream = null;
1222
+ this.scrollStream = null;
1223
+ this.containerInlinePadding = 0;
1224
+ this.onClickWrapper = (e) => {
1225
+ const rect = this.wrapper.getBoundingClientRect();
1226
+ const [x, y] = getRelativePointerPosition(rect, e.clientX, e.clientY);
1227
+ this.emit('click', x, y);
1228
+ };
1229
+ this.onDblClickWrapper = (e) => {
1230
+ const rect = this.wrapper.getBoundingClientRect();
1231
+ const [x, y] = getRelativePointerPosition(rect, e.clientX, e.clientY);
1232
+ this.emit('dblclick', x, y);
1233
+ };
1234
+ this.subscriptions = [];
1235
+ this.options = options;
1236
+ const parent = this.parentFromOptionsContainer(options.container);
1237
+ this.parent = parent;
1238
+ const [div, shadow] = this.initHtml();
1239
+ parent.appendChild(div);
1240
+ this.container = div;
1241
+ this.scrollContainer = shadow.querySelector('.scroll');
1242
+ this.wrapper = shadow.querySelector('.wrapper');
1243
+ this.canvasWrapper = shadow.querySelector('.canvases');
1244
+ this.progressWrapper = shadow.querySelector('.progress');
1245
+ this.cursor = shadow.querySelector('.cursor');
1246
+ this.calculateInlinePadding();
1247
+ if (audioElement) {
1248
+ shadow.appendChild(audioElement);
1249
+ }
1250
+ this.initEvents();
1251
+ }
1252
+ parentFromOptionsContainer(container) {
1253
+ let parent;
1254
+ if (typeof container === 'string') {
1255
+ parent = document.querySelector(container);
1256
+ }
1257
+ else if (isHTMLElement(container)) {
1258
+ parent = container;
1259
+ }
1260
+ if (!parent) {
1261
+ throw new Error('Container not found');
1262
+ }
1263
+ return parent;
1264
+ }
1265
+ initEvents() {
1266
+ // Add a click listener
1267
+ this.wrapper.addEventListener('click', this.onClickWrapper);
1268
+ // Add a double click listener
1269
+ this.wrapper.addEventListener('dblclick', this.onDblClickWrapper);
1270
+ // Drag
1271
+ if (this.options.dragToSeek === true || typeof this.options.dragToSeek === 'object') {
1272
+ this.initDrag();
1273
+ }
1274
+ // Add a scroll listener using reactive stream
1275
+ this.scrollStream = createScrollStream(this.scrollContainer);
1276
+ const unsubscribeScroll = effect(() => {
1277
+ const { startX, endX } = this.scrollStream.percentages.value;
1278
+ const { left, right } = this.scrollStream.bounds.value;
1279
+ this.emit('scroll', startX, endX, left, right);
1280
+ }, [this.scrollStream.percentages, this.scrollStream.bounds]);
1281
+ this.subscriptions.push(unsubscribeScroll);
1282
+ // Re-render the waveform on container resize
1283
+ if (typeof ResizeObserver === 'function') {
1284
+ const delay = this.createDelay(100);
1285
+ this.resizeObserver = new ResizeObserver(() => {
1286
+ delay()
1287
+ .then(() => this.onContainerResize())
1288
+ .catch(() => undefined);
1289
+ });
1290
+ this.resizeObserver.observe(this.scrollContainer);
1291
+ }
1292
+ }
1293
+ onContainerResize() {
1294
+ const width = this.parent.clientWidth;
1295
+ this.calculateInlinePadding();
1296
+ if (width === this.lastContainerWidth && this.options.height !== 'auto')
1297
+ return;
1298
+ this.lastContainerWidth = width;
1299
+ this.reRender();
1300
+ this.emit('resize');
1301
+ }
1302
+ initDrag() {
1303
+ // Don't initialize drag if it's already set up
1304
+ if (this.dragStream)
1305
+ return;
1306
+ this.dragStream = createDragStream(this.wrapper);
1307
+ const unsubscribeDrag = effect(() => {
1308
+ const drag = this.dragStream.signal.value;
1309
+ if (!drag)
1310
+ return;
1311
+ const width = this.wrapper.getBoundingClientRect().width;
1312
+ const relX = clampToUnit(drag.x / width);
1313
+ if (drag.type === 'start') {
1314
+ this.isDragging = true;
1315
+ this.emit('dragstart', relX);
1316
+ }
1317
+ else if (drag.type === 'move') {
1318
+ this.emit('drag', relX);
1319
+ }
1320
+ else if (drag.type === 'end') {
1321
+ this.isDragging = false;
1322
+ this.emit('dragend', relX);
1323
+ }
1324
+ }, [this.dragStream.signal]);
1325
+ this.subscriptions.push(unsubscribeDrag);
1326
+ }
1327
+ calculateInlinePadding() {
1328
+ const { paddingLeft, paddingRight } = getComputedStyle(this.scrollContainer);
1329
+ const padding = parseFloat(paddingLeft) + parseFloat(paddingRight);
1330
+ this.containerInlinePadding = Number.isNaN(padding) ? 0 : padding;
1331
+ }
1332
+ initHtml() {
1333
+ const div = document.createElement('div');
1334
+ const shadow = div.attachShadow({ mode: 'open' });
1335
+ const cspNonce = this.options.cspNonce && typeof this.options.cspNonce === 'string' ? this.options.cspNonce.replace(/"/g, '') : '';
1336
+ shadow.innerHTML = `
1337
+ <style${cspNonce ? ` nonce="${cspNonce}"` : ''}>
1338
+ :host {
1339
+ user-select: none;
1340
+ min-width: 1px;
1341
+ }
1342
+ :host audio {
1343
+ display: block;
1344
+ width: 100%;
1345
+ }
1346
+ :host .scroll {
1347
+ overflow-x: auto;
1348
+ overflow-y: hidden;
1349
+ width: 100%;
1350
+ position: relative;
1351
+ }
1352
+ :host .noScrollbar {
1353
+ scrollbar-color: transparent;
1354
+ scrollbar-width: none;
1355
+ }
1356
+ :host .noScrollbar::-webkit-scrollbar {
1357
+ display: none;
1358
+ -webkit-appearance: none;
1359
+ }
1360
+ :host .wrapper {
1361
+ position: relative;
1362
+ overflow: visible;
1363
+ z-index: 2;
1364
+ }
1365
+ :host .canvases {
1366
+ min-height: ${this.getHeight(this.options.height, this.options.splitChannels)}px;
1367
+ pointer-events: none;
1368
+ }
1369
+ :host .canvases > div {
1370
+ position: relative;
1371
+ }
1372
+ :host canvas {
1373
+ display: block;
1374
+ position: absolute;
1375
+ top: 0;
1376
+ image-rendering: pixelated;
1377
+ }
1378
+ :host .progress {
1379
+ pointer-events: none;
1380
+ position: absolute;
1381
+ z-index: 2;
1382
+ top: 0;
1383
+ left: 0;
1384
+ width: 0;
1385
+ height: 100%;
1386
+ overflow: hidden;
1387
+ }
1388
+ :host .progress > div {
1389
+ position: relative;
1390
+ }
1391
+ :host .cursor {
1392
+ pointer-events: none;
1393
+ position: absolute;
1394
+ z-index: 5;
1395
+ top: 0;
1396
+ left: 0;
1397
+ height: 100%;
1398
+ border-radius: 2px;
1399
+ }
1400
+ </style>
1401
+
1402
+ <div class="scroll" part="scroll">
1403
+ <div class="wrapper" part="wrapper">
1404
+ <div class="canvases" part="canvases"></div>
1405
+ <div class="progress" part="progress"></div>
1406
+ <div class="cursor" part="cursor"></div>
1407
+ </div>
1408
+ </div>
1409
+ `;
1410
+ return [div, shadow];
1411
+ }
1412
+ /** Wavesurfer itself calls this method. Do not call it manually. */
1413
+ setOptions(options) {
1414
+ var _a;
1415
+ if (this.options.container !== options.container) {
1416
+ const newParent = this.parentFromOptionsContainer(options.container);
1417
+ newParent.appendChild(this.container);
1418
+ this.parent = newParent;
1419
+ }
1420
+ if (options.dragToSeek === true || typeof this.options.dragToSeek === 'object') {
1421
+ this.initDrag();
1422
+ }
1423
+ else {
1424
+ (_a = this.dragStream) === null || _a === void 0 ? void 0 : _a.cleanup();
1425
+ this.dragStream = null;
1426
+ }
1427
+ this.options = options;
1428
+ // Re-render the waveform
1429
+ this.reRender();
1430
+ }
1431
+ getWrapper() {
1432
+ return this.wrapper;
1433
+ }
1434
+ getWidth() {
1435
+ return this.scrollContainer.clientWidth - this.containerInlinePadding;
1436
+ }
1437
+ getScroll() {
1438
+ return this.scrollContainer.scrollLeft;
1439
+ }
1440
+ setScroll(pixels) {
1441
+ this.scrollContainer.scrollLeft = pixels;
1442
+ }
1443
+ setScrollPercentage(percent) {
1444
+ const { scrollWidth } = this.scrollContainer;
1445
+ const scrollStart = scrollWidth * percent;
1446
+ this.setScroll(scrollStart);
1447
+ }
1448
+ destroy() {
1449
+ var _a;
1450
+ // Remove DOM event listeners
1451
+ this.wrapper.removeEventListener('click', this.onClickWrapper);
1452
+ this.wrapper.removeEventListener('dblclick', this.onDblClickWrapper);
1453
+ // Clean up all timeouts
1454
+ this.timeouts.forEach((clear) => clear());
1455
+ this.timeouts = [];
1456
+ this.subscriptions.forEach((unsubscribe) => unsubscribe());
1457
+ this.container.remove();
1458
+ if (this.resizeObserver) {
1459
+ this.resizeObserver.disconnect();
1460
+ this.resizeObserver = null;
1461
+ }
1462
+ (_a = this.unsubscribeOnScroll) === null || _a === void 0 ? void 0 : _a.forEach((unsubscribe) => unsubscribe());
1463
+ this.unsubscribeOnScroll = [];
1464
+ if (this.dragStream) {
1465
+ this.dragStream.cleanup();
1466
+ this.dragStream = null;
1467
+ }
1468
+ if (this.scrollStream) {
1469
+ this.scrollStream.cleanup();
1470
+ this.scrollStream = null;
1471
+ }
1472
+ }
1473
+ createDelay(delayMs = 10) {
1474
+ let timeout;
1475
+ let rejectFn;
1476
+ const onClear = () => {
1477
+ if (timeout) {
1478
+ clearTimeout(timeout);
1479
+ timeout = undefined;
1480
+ }
1481
+ if (rejectFn) {
1482
+ rejectFn();
1483
+ rejectFn = undefined;
1484
+ }
1485
+ };
1486
+ this.timeouts.push(onClear);
1487
+ return () => {
1488
+ return new Promise((resolve, reject) => {
1489
+ // Clear any pending delay
1490
+ onClear();
1491
+ // Store reject function for cleanup
1492
+ rejectFn = reject;
1493
+ // Set new timeout
1494
+ timeout = setTimeout(() => {
1495
+ timeout = undefined;
1496
+ rejectFn = undefined;
1497
+ resolve();
1498
+ }, delayMs);
1499
+ });
1500
+ };
1501
+ }
1502
+ getHeight(optionsHeight, optionsSplitChannel) {
1503
+ var _a;
1504
+ const numberOfChannels = ((_a = this.audioData) === null || _a === void 0 ? void 0 : _a.numberOfChannels) || 1;
1505
+ return resolveChannelHeight({
1506
+ optionsHeight,
1507
+ optionsSplitChannels: optionsSplitChannel,
1508
+ parentHeight: this.parent.clientHeight,
1509
+ numberOfChannels,
1510
+ defaultHeight: DEFAULT_HEIGHT,
1511
+ });
1512
+ }
1513
+ convertColorValues(color, ctx) {
1514
+ return resolveColorValue(color, this.getPixelRatio(), ctx === null || ctx === void 0 ? void 0 : ctx.canvas.height);
1515
+ }
1516
+ getPixelRatio() {
1517
+ return getPixelRatio(window.devicePixelRatio);
1518
+ }
1519
+ renderBarWaveform(channelData, options, ctx, vScale) {
1520
+ const { width, height } = ctx.canvas;
1521
+ const { halfHeight, barWidth, barRadius, barIndexScale, barSpacing, barMinHeight } = calculateBarRenderConfig({
1522
+ width,
1523
+ height,
1524
+ length: (channelData[0] || []).length,
1525
+ options,
1526
+ pixelRatio: this.getPixelRatio(),
1527
+ });
1528
+ const segments = calculateBarSegments({
1529
+ channelData,
1530
+ barIndexScale,
1531
+ barSpacing,
1532
+ barWidth,
1533
+ halfHeight,
1534
+ vScale,
1535
+ canvasHeight: height,
1536
+ barAlign: options.barAlign,
1537
+ barMinHeight,
1538
+ });
1539
+ ctx.beginPath();
1540
+ for (const segment of segments) {
1541
+ if (barRadius && 'roundRect' in ctx) {
1542
+ ctx.roundRect(segment.x, segment.y, segment.width, segment.height, barRadius);
1543
+ }
1544
+ else {
1545
+ ctx.rect(segment.x, segment.y, segment.width, segment.height);
1546
+ }
1547
+ }
1548
+ ctx.fill();
1549
+ ctx.closePath();
1550
+ }
1551
+ renderLineWaveform(channelData, _options, ctx, vScale) {
1552
+ const { width, height } = ctx.canvas;
1553
+ const paths = calculateLinePaths({ channelData, width, height, vScale });
1554
+ ctx.beginPath();
1555
+ for (const path of paths) {
1556
+ if (!path.length)
1557
+ continue;
1558
+ ctx.moveTo(path[0].x, path[0].y);
1559
+ for (let i = 1; i < path.length; i++) {
1560
+ const point = path[i];
1561
+ ctx.lineTo(point.x, point.y);
1562
+ }
1563
+ }
1564
+ ctx.fill();
1565
+ ctx.closePath();
1566
+ }
1567
+ renderWaveform(channelData, options, ctx) {
1568
+ ctx.fillStyle = this.convertColorValues(options.waveColor, ctx);
1569
+ if (options.renderFunction) {
1570
+ options.renderFunction(channelData, ctx);
1571
+ return;
1572
+ }
1573
+ const vScale = calculateVerticalScale({
1574
+ channelData,
1575
+ barHeight: options.barHeight,
1576
+ normalize: options.normalize,
1577
+ maxPeak: options.maxPeak,
1578
+ });
1579
+ if (shouldRenderBars(options)) {
1580
+ this.renderBarWaveform(channelData, options, ctx, vScale);
1581
+ return;
1582
+ }
1583
+ this.renderLineWaveform(channelData, options, ctx, vScale);
1584
+ }
1585
+ renderSingleCanvas(data, options, width, height, offset, canvasContainer, progressContainer) {
1586
+ const pixelRatio = this.getPixelRatio();
1587
+ const canvas = document.createElement('canvas');
1588
+ canvas.width = Math.round(width * pixelRatio);
1589
+ canvas.height = Math.round(height * pixelRatio);
1590
+ canvas.style.width = `${width}px`;
1591
+ canvas.style.height = `${height}px`;
1592
+ canvas.style.left = `${Math.round(offset)}px`;
1593
+ canvasContainer.appendChild(canvas);
1594
+ const ctx = canvas.getContext('2d');
1595
+ if (options.renderFunction) {
1596
+ ctx.fillStyle = this.convertColorValues(options.waveColor, ctx);
1597
+ options.renderFunction(data, ctx);
1598
+ }
1599
+ else {
1600
+ this.renderWaveform(data, options, ctx);
1601
+ }
1602
+ // Draw a progress canvas
1603
+ if (canvas.width > 0 && canvas.height > 0) {
1604
+ const progressCanvas = canvas.cloneNode();
1605
+ const progressCtx = progressCanvas.getContext('2d');
1606
+ progressCtx.drawImage(canvas, 0, 0);
1607
+ // Set the composition method to draw only where the waveform is drawn
1608
+ progressCtx.globalCompositeOperation = 'source-in';
1609
+ progressCtx.fillStyle = this.convertColorValues(options.progressColor, progressCtx);
1610
+ // This rectangle acts as a mask thanks to the composition method
1611
+ progressCtx.fillRect(0, 0, canvas.width, canvas.height);
1612
+ progressContainer.appendChild(progressCanvas);
1613
+ }
1614
+ }
1615
+ renderMultiCanvas(channelData, options, width, height, canvasContainer, progressContainer) {
1616
+ const pixelRatio = this.getPixelRatio();
1617
+ const { clientWidth } = this.scrollContainer;
1618
+ const totalWidth = width / pixelRatio;
1619
+ const singleCanvasWidth = calculateSingleCanvasWidth({ clientWidth, totalWidth, options });
1620
+ let drawnIndexes = {};
1621
+ // Nothing to render
1622
+ if (singleCanvasWidth === 0)
1623
+ return;
1624
+ // Draw a single canvas
1625
+ const draw = (index) => {
1626
+ if (index < 0 || index >= numCanvases)
1627
+ return;
1628
+ if (drawnIndexes[index])
1629
+ return;
1630
+ drawnIndexes[index] = true;
1631
+ const offset = index * singleCanvasWidth;
1632
+ let clampedWidth = Math.min(totalWidth - offset, singleCanvasWidth);
1633
+ // Clamp the width to the bar grid to avoid empty canvases at the end
1634
+ clampedWidth = clampWidthToBarGrid(clampedWidth, options);
1635
+ if (clampedWidth <= 0)
1636
+ return;
1637
+ const data = sliceChannelData({ channelData, offset, clampedWidth, totalWidth });
1638
+ this.renderSingleCanvas(data, options, clampedWidth, height, offset, canvasContainer, progressContainer);
1639
+ };
1640
+ // Clear canvases to avoid too many DOM nodes
1641
+ const clearCanvases = () => {
1642
+ if (shouldClearCanvases(Object.keys(drawnIndexes).length)) {
1643
+ canvasContainer.innerHTML = '';
1644
+ progressContainer.innerHTML = '';
1645
+ drawnIndexes = {};
1646
+ }
1647
+ };
1648
+ // Calculate how many canvases to render
1649
+ const numCanvases = Math.ceil(totalWidth / singleCanvasWidth);
1650
+ // Render all canvases if the waveform doesn't scroll
1651
+ if (!this.isScrollable) {
1652
+ for (let i = 0; i < numCanvases; i++) {
1653
+ draw(i);
1654
+ }
1655
+ return;
1656
+ }
1657
+ // Lazy rendering
1658
+ const initialRange = getLazyRenderRange({
1659
+ scrollLeft: this.scrollContainer.scrollLeft,
1660
+ totalWidth,
1661
+ numCanvases,
1662
+ });
1663
+ initialRange.forEach((index) => draw(index));
1664
+ // Subscribe to the scroll event to draw additional canvases
1665
+ if (numCanvases > 1) {
1666
+ const unsubscribe = this.on('scroll', () => {
1667
+ const { scrollLeft } = this.scrollContainer;
1668
+ clearCanvases();
1669
+ getLazyRenderRange({ scrollLeft, totalWidth, numCanvases }).forEach((index) => draw(index));
1670
+ });
1671
+ this.unsubscribeOnScroll.push(unsubscribe);
1672
+ }
1673
+ }
1674
+ renderChannel(channelData, _a, width, channelIndex) {
1675
+ var { overlay } = _a, options = __rest(_a, ["overlay"]);
1676
+ // A container for canvases
1677
+ const canvasContainer = document.createElement('div');
1678
+ const height = this.getHeight(options.height, options.splitChannels);
1679
+ canvasContainer.style.height = `${height}px`;
1680
+ if (overlay && channelIndex > 0) {
1681
+ canvasContainer.style.marginTop = `-${height}px`;
1682
+ }
1683
+ this.canvasWrapper.style.minHeight = `${height}px`;
1684
+ this.canvasWrapper.appendChild(canvasContainer);
1685
+ // A container for progress canvases
1686
+ const progressContainer = canvasContainer.cloneNode();
1687
+ this.progressWrapper.appendChild(progressContainer);
1688
+ // Render the waveform
1689
+ this.renderMultiCanvas(channelData, options, width, height, canvasContainer, progressContainer);
1690
+ }
1691
+ render(audioData) {
1692
+ return __awaiter$2(this, void 0, void 0, function* () {
1693
+ var _a;
1694
+ // Clear previous timeouts
1695
+ this.timeouts.forEach((clear) => clear());
1696
+ this.timeouts = [];
1697
+ // Clear scroll subscriptions from previous render
1698
+ this.unsubscribeOnScroll.forEach((unsubscribe) => unsubscribe());
1699
+ this.unsubscribeOnScroll = [];
1700
+ // Clear the canvases
1701
+ this.canvasWrapper.innerHTML = '';
1702
+ this.progressWrapper.innerHTML = '';
1703
+ // Width
1704
+ if (this.options.width != null) {
1705
+ this.scrollContainer.style.width =
1706
+ typeof this.options.width === 'number' ? `${this.options.width}px` : this.options.width;
1707
+ }
1708
+ // Determine the width of the waveform
1709
+ const pixelRatio = this.getPixelRatio();
1710
+ const parentWidth = this.scrollContainer.clientWidth - this.containerInlinePadding;
1711
+ const { scrollWidth, isScrollable, useParentWidth, width } = calculateWaveformLayout({
1712
+ duration: audioData.duration,
1713
+ minPxPerSec: this.options.minPxPerSec || 0,
1714
+ parentWidth,
1715
+ fillParent: this.options.fillParent,
1716
+ pixelRatio,
1717
+ });
1718
+ // Whether the container should scroll
1719
+ this.isScrollable = isScrollable;
1720
+ // Set the width of the wrapper
1721
+ this.wrapper.style.width = useParentWidth ? '100%' : `${scrollWidth}px`;
1722
+ // Set additional styles
1723
+ this.scrollContainer.style.overflowX = this.isScrollable ? 'auto' : 'hidden';
1724
+ this.scrollContainer.classList.toggle('noScrollbar', !!this.options.hideScrollbar);
1725
+ this.cursor.style.backgroundColor = `${this.options.cursorColor || this.options.progressColor}`;
1726
+ this.cursor.style.width = `${this.options.cursorWidth}px`;
1727
+ this.audioData = audioData;
1728
+ this.emit('render');
1729
+ // Render the waveform
1730
+ if (this.options.splitChannels) {
1731
+ // Render a waveform for each channel
1732
+ for (let i = 0; i < audioData.numberOfChannels; i++) {
1733
+ const options = Object.assign(Object.assign({}, this.options), (_a = this.options.splitChannels) === null || _a === void 0 ? void 0 : _a[i]);
1734
+ this.renderChannel([audioData.getChannelData(i)], options, width, i);
1735
+ }
1736
+ }
1737
+ else {
1738
+ // Render a single waveform for the first two channels (left and right)
1739
+ const channels = [audioData.getChannelData(0)];
1740
+ if (audioData.numberOfChannels > 1)
1741
+ channels.push(audioData.getChannelData(1));
1742
+ this.renderChannel(channels, this.options, width, 0);
1743
+ }
1744
+ // Must be emitted asynchronously for backward compatibility
1745
+ Promise.resolve().then(() => this.emit('rendered'));
1746
+ });
1747
+ }
1748
+ reRender() {
1749
+ this.unsubscribeOnScroll.forEach((unsubscribe) => unsubscribe());
1750
+ this.unsubscribeOnScroll = [];
1751
+ // Return if the waveform has not been rendered yet
1752
+ if (!this.audioData)
1753
+ return;
1754
+ // Remember the current cursor position
1755
+ const { scrollWidth } = this.scrollContainer;
1756
+ const { right: before } = this.progressWrapper.getBoundingClientRect();
1757
+ // Re-render the waveform
1758
+ this.render(this.audioData);
1759
+ // Adjust the scroll position so that the cursor stays in the same place
1760
+ if (!this.isScrollable && this.scrollContainer.scrollLeft) {
1761
+ this.scrollContainer.scrollLeft = 0;
1762
+ }
1763
+ else if (this.isScrollable && scrollWidth !== this.scrollContainer.scrollWidth) {
1764
+ const { right: after } = this.progressWrapper.getBoundingClientRect();
1765
+ const delta = roundToHalfAwayFromZero(after - before);
1766
+ this.scrollContainer.scrollLeft += delta;
1767
+ }
1768
+ }
1769
+ zoom(minPxPerSec) {
1770
+ this.options.minPxPerSec = minPxPerSec;
1771
+ this.reRender();
1772
+ }
1773
+ scrollIntoView(progress, isPlaying = false) {
1774
+ var _a;
1775
+ const { scrollLeft, scrollWidth, clientWidth } = this.scrollContainer;
1776
+ const progressWidth = progress * scrollWidth;
1777
+ const startEdge = scrollLeft;
1778
+ const endEdge = scrollLeft + clientWidth;
1779
+ const middle = clientWidth / 2;
1780
+ if (this.isDragging) {
1781
+ // Scroll when dragging close to the edge of the viewport
1782
+ const minGap = 30;
1783
+ if (progressWidth + minGap > endEdge) {
1784
+ this.scrollContainer.scrollLeft += minGap;
1785
+ }
1786
+ else if (progressWidth - minGap < startEdge) {
1787
+ this.scrollContainer.scrollLeft -= minGap;
1788
+ }
1789
+ }
1790
+ else {
1791
+ if (progressWidth < startEdge || progressWidth > endEdge) {
1792
+ this.scrollContainer.scrollLeft = progressWidth - (this.options.autoCenter ? middle : 0);
1793
+ }
1794
+ // Keep the cursor centered when playing
1795
+ const center = progressWidth - scrollLeft - middle;
1796
+ if (isPlaying && this.options.autoCenter && center > 0) {
1797
+ const duration = (_a = this.audioData) === null || _a === void 0 ? void 0 : _a.duration;
1798
+ if (duration === undefined || duration <= 0) {
1799
+ this.scrollContainer.scrollLeft += center;
1800
+ return;
1801
+ }
1802
+ const pixelsPerSecond = scrollWidth / duration;
1803
+ if (pixelsPerSecond <= LOW_ZOOM_PIXELS_PER_SECOND_THRESHOLD) {
1804
+ this.scrollContainer.scrollLeft += Math.min(center, SMOOTH_SCROLL_MAX_DELTA);
1805
+ }
1806
+ else {
1807
+ this.scrollContainer.scrollLeft += center;
1808
+ }
1809
+ }
1810
+ }
1811
+ }
1812
+ renderProgress(progress, isPlaying) {
1813
+ if (isNaN(progress))
1814
+ return;
1815
+ const percents = progress * 100;
1816
+ this.canvasWrapper.style.clipPath = `polygon(${percents}% 0%, 100% 0%, 100% 100%, ${percents}% 100%)`;
1817
+ this.progressWrapper.style.width = `${percents}%`;
1818
+ this.cursor.style.left = `${percents}%`;
1819
+ this.cursor.style.transform = this.options.cursorWidth
1820
+ ? `translateX(-${progress * this.options.cursorWidth}px)`
1821
+ : '';
1822
+ // Only scroll if we have valid audio data to prevent race conditions during loading
1823
+ if (this.isScrollable && this.options.autoScroll && this.audioData && this.audioData.duration > 0) {
1824
+ this.scrollIntoView(progress, isPlaying);
1825
+ }
1826
+ }
1827
+ exportImage(format, quality, type) {
1828
+ return __awaiter$2(this, void 0, void 0, function* () {
1829
+ const canvases = this.canvasWrapper.querySelectorAll('canvas');
1830
+ if (!canvases.length) {
1831
+ throw new Error('No waveform data');
1832
+ }
1833
+ // Data URLs
1834
+ if (type === 'dataURL') {
1835
+ const images = Array.from(canvases).map((canvas) => canvas.toDataURL(format, quality));
1836
+ return Promise.resolve(images);
1837
+ }
1838
+ // Blobs
1839
+ return Promise.all(Array.from(canvases).map((canvas) => {
1840
+ return new Promise((resolve, reject) => {
1841
+ canvas.toBlob((blob) => {
1842
+ if (blob) {
1843
+ resolve(blob);
1844
+ }
1845
+ else {
1846
+ reject(new Error('Could not export image'));
1847
+ }
1848
+ }, format, quality);
1849
+ });
1850
+ }));
1851
+ });
1852
+ }
1853
+ }
1854
+
1855
+ class Timer extends EventEmitter {
1856
+ constructor() {
1857
+ super(...arguments);
1858
+ this.animationFrameId = null;
1859
+ this.isRunning = false;
1860
+ }
1861
+ start() {
1862
+ // Prevent multiple simultaneous loops
1863
+ if (this.isRunning)
1864
+ return;
1865
+ this.isRunning = true;
1866
+ const tick = () => {
1867
+ // Only continue if timer is still running
1868
+ if (!this.isRunning)
1869
+ return;
1870
+ this.emit('tick');
1871
+ // Schedule next frame
1872
+ this.animationFrameId = requestAnimationFrame(tick);
1873
+ };
1874
+ // Start the loop
1875
+ tick();
1876
+ }
1877
+ stop() {
1878
+ this.isRunning = false;
1879
+ // Cancel any pending animation frame
1880
+ if (this.animationFrameId !== null) {
1881
+ cancelAnimationFrame(this.animationFrameId);
1882
+ this.animationFrameId = null;
1883
+ }
1884
+ }
1885
+ destroy() {
1886
+ this.stop();
1887
+ this.unAll();
1888
+ }
1889
+ }
1890
+
1891
+ var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
1892
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1893
+ return new (P || (P = Promise))(function (resolve, reject) {
1894
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1895
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1896
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1897
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1898
+ });
1899
+ };
1900
+ function setWebAudioSessionPlayback() {
1901
+ const navigator = globalThis.navigator;
1902
+ if (!(navigator === null || navigator === void 0 ? void 0 : navigator.audioSession))
1903
+ return;
1904
+ try {
1905
+ navigator.audioSession.type = 'playback';
1906
+ }
1907
+ catch (e) {
1908
+ console.warn('Setting navigator.audioSession.type failed:', e);
1909
+ }
1910
+ }
1911
+ /**
1912
+ * A Web Audio buffer player emulating the behavior of an HTML5 Audio element.
1913
+ *
1914
+ * Note: This class does not manage blob: URLs. If you pass a blob: URL to setSrc(),
1915
+ * you are responsible for revoking it when done. The Player class (player.ts) handles
1916
+ * blob URL lifecycle management automatically.
1917
+ */
1918
+ class WebAudioPlayer extends EventEmitter {
1919
+ constructor(audioContext) {
1920
+ super();
1921
+ this.bufferNode = null;
1922
+ this.playStartTime = 0;
1923
+ this.playbackPosition = 0;
1924
+ this._muted = false;
1925
+ this._playbackRate = 1;
1926
+ this._duration = undefined;
1927
+ this.buffer = null;
1928
+ this.currentSrc = '';
1929
+ this.paused = true;
1930
+ this.crossOrigin = null;
1931
+ this.seeking = false;
1932
+ this.autoplay = false;
1933
+ /** Subscribe to an event. Returns an unsubscribe function. */
1934
+ this.addEventListener = this.on;
1935
+ /** Unsubscribe from an event */
1936
+ this.removeEventListener = this.un;
1937
+ this._destroyed = false;
1938
+ setWebAudioSessionPlayback();
1939
+ this.audioContext = audioContext || new AudioContext();
1940
+ this.gainNode = this.audioContext.createGain();
1941
+ this.gainNode.connect(this.audioContext.destination);
1942
+ }
1943
+ load() {
1944
+ return __awaiter$1(this, void 0, void 0, function* () {
1945
+ return;
1946
+ });
1947
+ }
1948
+ /** For compatibility with HTMLMediaElement.remove(). Delegates to destroy(). */
1949
+ remove() {
1950
+ this.destroy();
1951
+ }
1952
+ /** Clean up all resources. Idempotent — safe to call multiple times. */
1953
+ destroy() {
1954
+ if (this._destroyed)
1955
+ return;
1956
+ this._destroyed = true;
1957
+ // Clear currentSrc so any in-flight fetch/decode chains bail out
1958
+ // via their existing `this.currentSrc !== value` guards
1959
+ this.currentSrc = '';
1960
+ // Stop and disconnect buffer node
1961
+ if (this.bufferNode) {
1962
+ this.bufferNode.onended = null;
1963
+ try {
1964
+ this.bufferNode.stop();
1965
+ }
1966
+ catch (_a) {
1967
+ // Ignore InvalidStateError if node already stopped
1968
+ }
1969
+ this.bufferNode.disconnect();
1970
+ this.bufferNode = null;
1971
+ }
1972
+ // Disconnect gain node
1973
+ this.gainNode.disconnect();
1974
+ // Close audio context (returns a promise, catch rejection if already closed)
1975
+ // Guard with typeof check for mock environments where close may not exist
1976
+ if (typeof this.audioContext.close === 'function') {
1977
+ Promise.resolve(this.audioContext.close.call(this.audioContext)).catch(() => undefined);
1978
+ }
1979
+ // Clear buffer reference
1980
+ this.buffer = null;
1981
+ // Clear all event listeners
1982
+ this.unAll();
1983
+ }
1984
+ get src() {
1985
+ return this.currentSrc;
1986
+ }
1987
+ set src(value) {
1988
+ this.currentSrc = value;
1989
+ this._duration = undefined;
1990
+ if (!value) {
1991
+ this.buffer = null;
1992
+ this.emit('emptied');
1993
+ return;
1994
+ }
1995
+ fetch(value)
1996
+ .then((response) => {
1997
+ if (response.status >= 400) {
1998
+ throw new Error(`Failed to fetch ${value}: ${response.status} (${response.statusText})`);
1999
+ }
2000
+ return response.arrayBuffer();
2001
+ })
2002
+ .then((arrayBuffer) => {
2003
+ if (this.currentSrc !== value)
2004
+ return null;
2005
+ return this.audioContext.decodeAudioData(arrayBuffer);
2006
+ })
2007
+ .then((audioBuffer) => {
2008
+ if (this.currentSrc !== value)
2009
+ return;
2010
+ this.buffer = audioBuffer;
2011
+ this.emit('loadedmetadata');
2012
+ this.emit('canplay');
2013
+ if (this.autoplay)
2014
+ this.play();
2015
+ })
2016
+ .catch((err) => {
2017
+ // Emit error for proper error handling
2018
+ console.error('WebAudioPlayer load error:', err);
2019
+ });
2020
+ }
2021
+ _play() {
2022
+ if (!this.paused)
2023
+ return;
2024
+ this.paused = false;
2025
+ // Clean up old buffer node completely before creating new one
2026
+ if (this.bufferNode) {
2027
+ this.bufferNode.onended = null;
2028
+ this.bufferNode.disconnect();
2029
+ }
2030
+ this.bufferNode = this.audioContext.createBufferSource();
2031
+ if (this.buffer) {
2032
+ this.bufferNode.buffer = this.buffer;
2033
+ }
2034
+ this.bufferNode.playbackRate.value = this._playbackRate;
2035
+ this.bufferNode.connect(this.gainNode);
2036
+ let currentPos = this.playbackPosition;
2037
+ if (currentPos >= this.duration || currentPos < 0) {
2038
+ currentPos = 0;
2039
+ this.playbackPosition = 0;
2040
+ }
2041
+ this.bufferNode.start(this.audioContext.currentTime, currentPos);
2042
+ this.playStartTime = this.audioContext.currentTime;
2043
+ this.bufferNode.onended = () => {
2044
+ if (!this.paused && this.duration - this.currentTime < 0.01) {
2045
+ this.pause();
2046
+ this.emit('ended');
2047
+ }
2048
+ };
2049
+ }
2050
+ _pause() {
2051
+ this.paused = true;
2052
+ // Clear onended before stopping to prevent spurious 'ended' event
2053
+ if (this.bufferNode) {
2054
+ this.bufferNode.onended = null;
2055
+ try {
2056
+ this.bufferNode.stop();
2057
+ }
2058
+ catch (_a) {
2059
+ // Ignore InvalidStateError if node already stopped
2060
+ }
2061
+ }
2062
+ this.playbackPosition += (this.audioContext.currentTime - this.playStartTime) * this._playbackRate;
2063
+ }
2064
+ play() {
2065
+ return __awaiter$1(this, void 0, void 0, function* () {
2066
+ if (!this.paused)
2067
+ return;
2068
+ this._play();
2069
+ this.emit('play');
2070
+ });
2071
+ }
2072
+ pause() {
2073
+ if (this.paused)
2074
+ return;
2075
+ this._pause();
2076
+ this.emit('pause');
2077
+ }
2078
+ stopAt(timeSeconds) {
2079
+ // The stop is scheduled on the AudioContext clock, so convert the remaining
2080
+ // media time to real time via the playback rate
2081
+ const delay = (timeSeconds - this.currentTime) / this._playbackRate;
2082
+ const currentBufferNode = this.bufferNode;
2083
+ currentBufferNode === null || currentBufferNode === void 0 ? void 0 : currentBufferNode.stop(this.audioContext.currentTime + delay);
2084
+ currentBufferNode === null || currentBufferNode === void 0 ? void 0 : currentBufferNode.addEventListener('ended', () => {
2085
+ if (currentBufferNode === this.bufferNode) {
2086
+ this.bufferNode = null;
2087
+ this.pause();
2088
+ // The 'ended' event fires with some latency, so clamp the reported
2089
+ // position to the exact stop time
2090
+ this.playbackPosition = Math.min(timeSeconds, this.duration);
2091
+ this.emit('timeupdate');
2092
+ }
2093
+ }, { once: true });
2094
+ }
2095
+ setSinkId(deviceId) {
2096
+ return __awaiter$1(this, void 0, void 0, function* () {
2097
+ const ac = this.audioContext;
2098
+ return ac.setSinkId(deviceId);
2099
+ });
2100
+ }
2101
+ get playbackRate() {
2102
+ return this._playbackRate;
2103
+ }
2104
+ set playbackRate(value) {
2105
+ const wasPlaying = !this.paused;
2106
+ if (wasPlaying)
2107
+ this._pause();
2108
+ this._playbackRate = value;
2109
+ if (wasPlaying)
2110
+ this._play();
2111
+ if (this.bufferNode) {
2112
+ this.bufferNode.playbackRate.value = value;
2113
+ }
2114
+ }
2115
+ get currentTime() {
2116
+ return this.paused
2117
+ ? this.playbackPosition
2118
+ : this.playbackPosition + (this.audioContext.currentTime - this.playStartTime) * this._playbackRate;
2119
+ }
2120
+ set currentTime(value) {
2121
+ const wasPlaying = !this.paused;
2122
+ if (wasPlaying)
2123
+ this._pause();
2124
+ this.playbackPosition = value;
2125
+ if (wasPlaying)
2126
+ this._play();
2127
+ this.emit('seeking');
2128
+ this.emit('timeupdate');
2129
+ }
2130
+ get duration() {
2131
+ var _a, _b;
2132
+ return (_a = this._duration) !== null && _a !== void 0 ? _a : (((_b = this.buffer) === null || _b === void 0 ? void 0 : _b.duration) || 0);
2133
+ }
2134
+ set duration(value) {
2135
+ this._duration = value;
2136
+ }
2137
+ get volume() {
2138
+ return this.gainNode.gain.value;
2139
+ }
2140
+ set volume(value) {
2141
+ this.gainNode.gain.value = value;
2142
+ this.emit('volumechange');
2143
+ }
2144
+ get muted() {
2145
+ return this._muted;
2146
+ }
2147
+ set muted(value) {
2148
+ if (this._muted === value)
2149
+ return;
2150
+ this._muted = value;
2151
+ if (this._muted) {
2152
+ this.gainNode.disconnect();
2153
+ }
2154
+ else {
2155
+ this.gainNode.connect(this.audioContext.destination);
2156
+ }
2157
+ }
2158
+ canPlayType(mimeType) {
2159
+ return /^(audio|video)\//.test(mimeType);
2160
+ }
2161
+ /** Get the GainNode used to play the audio. Can be used to attach filters. */
2162
+ getGainNode() {
2163
+ return this.gainNode;
2164
+ }
2165
+ /** Get decoded audio */
2166
+ getChannelData() {
2167
+ const channels = [];
2168
+ if (!this.buffer)
2169
+ return channels;
2170
+ const numChannels = this.buffer.numberOfChannels;
2171
+ for (let i = 0; i < numChannels; i++) {
2172
+ channels.push(this.buffer.getChannelData(i));
2173
+ }
2174
+ return channels;
2175
+ }
2176
+ /**
2177
+ * Imitate `HTMLElement.removeAttribute` for compatibility with `Player`.
2178
+ */
2179
+ removeAttribute(attrName) {
2180
+ switch (attrName) {
2181
+ case 'src':
2182
+ this.src = '';
2183
+ break;
2184
+ case 'playbackRate':
2185
+ this.playbackRate = 0;
2186
+ break;
2187
+ case 'currentTime':
2188
+ this.currentTime = 0;
2189
+ break;
2190
+ case 'duration':
2191
+ this.duration = 0;
2192
+ break;
2193
+ case 'volume':
2194
+ this.volume = 0;
2195
+ break;
2196
+ case 'muted':
2197
+ this.muted = false;
2198
+ break;
2199
+ }
2200
+ }
2201
+ }
2202
+
2203
+ /**
2204
+ * Centralized reactive state for WaveSurfer
2205
+ *
2206
+ * This module provides a single source of truth for all WaveSurfer state.
2207
+ * State is managed using reactive signals that automatically notify subscribers.
2208
+ */
2209
+ /**
2210
+ * Create a new WaveSurfer state instance
2211
+ *
2212
+ * @param playerSignals - Optional signals from Player to compose with WaveSurfer state
2213
+ *
2214
+ * @example
2215
+ * ```typescript
2216
+ * // Without Player signals (standalone)
2217
+ * const { state, actions } = createWaveSurferState()
2218
+ *
2219
+ * // With Player signals (composed)
2220
+ * const { state, actions } = createWaveSurferState({
2221
+ * isPlaying: player.isPlayingSignal,
2222
+ * currentTime: player.currentTimeSignal,
2223
+ * // ...
2224
+ * })
2225
+ *
2226
+ * // Read state
2227
+ * console.log(state.isPlaying.value)
2228
+ *
2229
+ * // Update state
2230
+ * actions.setPlaying(true)
2231
+ *
2232
+ * // Subscribe to changes
2233
+ * state.isPlaying.subscribe(playing => {
2234
+ * console.log('Playing:', playing)
2235
+ * })
2236
+ * ```
2237
+ */
2238
+ function createWaveSurferState(playerSignals) {
2239
+ var _a, _b, _c, _d, _e, _f;
2240
+ // Use Player signals if provided, otherwise create new ones
2241
+ const currentTime = (_a = playerSignals === null || playerSignals === void 0 ? void 0 : playerSignals.currentTime) !== null && _a !== void 0 ? _a : signal(0);
2242
+ const duration = (_b = playerSignals === null || playerSignals === void 0 ? void 0 : playerSignals.duration) !== null && _b !== void 0 ? _b : signal(0);
2243
+ const isPlaying = (_c = playerSignals === null || playerSignals === void 0 ? void 0 : playerSignals.isPlaying) !== null && _c !== void 0 ? _c : signal(false);
2244
+ const isSeeking = (_d = playerSignals === null || playerSignals === void 0 ? void 0 : playerSignals.isSeeking) !== null && _d !== void 0 ? _d : signal(false);
2245
+ const volume = (_e = playerSignals === null || playerSignals === void 0 ? void 0 : playerSignals.volume) !== null && _e !== void 0 ? _e : signal(1);
2246
+ const playbackRate = (_f = playerSignals === null || playerSignals === void 0 ? void 0 : playerSignals.playbackRate) !== null && _f !== void 0 ? _f : signal(1);
2247
+ // WaveSurfer-specific signals (not in Player)
2248
+ const audioBuffer = signal(null);
2249
+ const peaks = signal(null);
2250
+ const url = signal('');
2251
+ const zoom = signal(0);
2252
+ const scrollPosition = signal(0);
2253
+ // Computed values (derived state)
2254
+ const isPaused = computed(() => !isPlaying.value, [isPlaying]);
2255
+ const canPlay = computed(() => audioBuffer.value !== null, [audioBuffer]);
2256
+ const isReady = computed(() => {
2257
+ return canPlay.value && duration.value > 0;
2258
+ }, [canPlay, duration]);
2259
+ const progress = computed(() => currentTime.value, [currentTime]);
2260
+ const progressPercent = computed(() => {
2261
+ return duration.value > 0 ? currentTime.value / duration.value : 0;
2262
+ }, [currentTime, duration]);
2263
+ // Public read-only state
2264
+ const state = {
2265
+ currentTime,
2266
+ duration,
2267
+ isPlaying,
2268
+ isPaused,
2269
+ isSeeking,
2270
+ volume,
2271
+ playbackRate,
2272
+ audioBuffer,
2273
+ peaks,
2274
+ url,
2275
+ zoom,
2276
+ scrollPosition,
2277
+ canPlay,
2278
+ isReady,
2279
+ progress,
2280
+ progressPercent,
2281
+ };
2282
+ // Actions that modify state
2283
+ const actions = {
2284
+ setCurrentTime: (time) => {
2285
+ const clampedTime = Math.max(0, Math.min(duration.value || Infinity, time));
2286
+ currentTime.set(clampedTime);
2287
+ },
2288
+ setDuration: (d) => {
2289
+ duration.set(Math.max(0, d));
2290
+ },
2291
+ setPlaying: (playing) => {
2292
+ isPlaying.set(playing);
2293
+ },
2294
+ setSeeking: (seeking) => {
2295
+ isSeeking.set(seeking);
2296
+ },
2297
+ setVolume: (v) => {
2298
+ const clampedVolume = Math.max(0, Math.min(1, v));
2299
+ volume.set(clampedVolume);
2300
+ },
2301
+ setPlaybackRate: (rate) => {
2302
+ const clampedRate = Math.max(0.1, Math.min(16, rate));
2303
+ playbackRate.set(clampedRate);
2304
+ },
2305
+ setAudioBuffer: (buffer) => {
2306
+ audioBuffer.set(buffer);
2307
+ if (buffer) {
2308
+ duration.set(buffer.duration);
2309
+ }
2310
+ },
2311
+ setPeaks: (p) => {
2312
+ peaks.set(p);
2313
+ },
2314
+ setUrl: (u) => {
2315
+ url.set(u);
2316
+ },
2317
+ setZoom: (z) => {
2318
+ zoom.set(Math.max(0, z));
2319
+ },
2320
+ setScrollPosition: (pos) => {
2321
+ scrollPosition.set(Math.max(0, pos));
2322
+ },
2323
+ };
2324
+ return { state, actions };
2325
+ }
2326
+
2327
+ /**
2328
+ * State-driven event emission utilities
2329
+ *
2330
+ * Automatically emit events when reactive state changes.
2331
+ * Ensures events are always in sync with state and removes manual emit() calls.
2332
+ */
2333
+ /**
2334
+ * Setup automatic event emission from state changes
2335
+ *
2336
+ * This function subscribes to all relevant state signals and automatically
2337
+ * emits corresponding events when state changes. This ensures:
2338
+ * - Events are always in sync with state
2339
+ * - No manual emit() calls needed
2340
+ * - Can't forget to emit an event
2341
+ * - Clear event sources (state changes)
2342
+ *
2343
+ * @example
2344
+ * ```typescript
2345
+ * const { state } = createWaveSurferState()
2346
+ * const wavesurfer = new WaveSurfer()
2347
+ *
2348
+ * const cleanup = setupStateEventEmission(state, wavesurfer)
2349
+ *
2350
+ * // Now state changes automatically emit events
2351
+ * state.isPlaying.set(true) // → wavesurfer.emit('play')
2352
+ * ```
2353
+ *
2354
+ * @param state - Reactive state to observe
2355
+ * @param emitter - Event emitter to emit events on
2356
+ * @returns Cleanup function that removes all subscriptions
2357
+ */
2358
+ function setupStateEventEmission(state, emitter) {
2359
+ const cleanups = [];
2360
+ // ============================================================================
2361
+ // Play/Pause Events
2362
+ // ============================================================================
2363
+ // Emit play/pause events when playing state changes
2364
+ cleanups.push(effect(() => {
2365
+ const isPlaying = state.isPlaying.value;
2366
+ emitter.emit(isPlaying ? 'play' : 'pause');
2367
+ }, [state.isPlaying]));
2368
+ // ============================================================================
2369
+ // Time Update Events
2370
+ // ============================================================================
2371
+ // Emit timeupdate when current time changes
2372
+ cleanups.push(effect(() => {
2373
+ const currentTime = state.currentTime.value;
2374
+ emitter.emit('timeupdate', currentTime);
2375
+ // Also emit audioprocess when playing
2376
+ if (state.isPlaying.value) {
2377
+ emitter.emit('audioprocess', currentTime);
2378
+ }
2379
+ }, [state.currentTime, state.isPlaying]));
2380
+ // ============================================================================
2381
+ // Seeking Events
2382
+ // ============================================================================
2383
+ // Emit seeking event when seeking state changes to true
2384
+ cleanups.push(effect(() => {
2385
+ const isSeeking = state.isSeeking.value;
2386
+ if (isSeeking) {
2387
+ emitter.emit('seeking', state.currentTime.value);
2388
+ }
2389
+ }, [state.isSeeking, state.currentTime]));
2390
+ // ============================================================================
2391
+ // Ready Event
2392
+ // ============================================================================
2393
+ // Emit ready when state becomes ready
2394
+ let wasReady = false;
2395
+ cleanups.push(effect(() => {
2396
+ const isReady = state.isReady.value;
2397
+ if (isReady && !wasReady) {
2398
+ wasReady = true;
2399
+ emitter.emit('ready', state.duration.value);
2400
+ }
2401
+ }, [state.isReady, state.duration]));
2402
+ // Reset wasReady when audio buffer is cleared (new load starting)
2403
+ // This allows the 'ready' event to fire again on subsequent loads
2404
+ cleanups.push(effect(() => {
2405
+ if (state.audioBuffer.value === null) {
2406
+ wasReady = false;
2407
+ }
2408
+ }, [state.audioBuffer]));
2409
+ // ============================================================================
2410
+ // Finish Event
2411
+ // ============================================================================
2412
+ // Emit finish when playback ends (reached duration and stopped)
2413
+ let wasPlayingAtEnd = false;
2414
+ cleanups.push(effect(() => {
2415
+ const isPlaying = state.isPlaying.value;
2416
+ const currentTime = state.currentTime.value;
2417
+ const duration = state.duration.value;
2418
+ // Check if we're at the end
2419
+ const isAtEnd = duration > 0 && currentTime >= duration;
2420
+ // Emit finish when we were playing at end and now stopped
2421
+ if (wasPlayingAtEnd && !isPlaying && isAtEnd) {
2422
+ emitter.emit('finish');
2423
+ }
2424
+ // Track if we're playing at the end
2425
+ wasPlayingAtEnd = isPlaying && isAtEnd;
2426
+ }, [state.isPlaying, state.currentTime, state.duration]));
2427
+ // ============================================================================
2428
+ // Zoom Events
2429
+ // ============================================================================
2430
+ // Emit zoom when zoom level changes
2431
+ cleanups.push(effect(() => {
2432
+ const zoom = state.zoom.value;
2433
+ if (zoom > 0) {
2434
+ emitter.emit('zoom', zoom);
2435
+ }
2436
+ }, [state.zoom]));
2437
+ // Return cleanup function
2438
+ return () => {
2439
+ cleanups.forEach((cleanup) => cleanup());
2440
+ };
2441
+ }
2442
+
2443
+ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
2444
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2445
+ return new (P || (P = Promise))(function (resolve, reject) {
2446
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2447
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2448
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2449
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
2450
+ });
2451
+ };
2452
+ const defaultOptions = {
2453
+ waveColor: '#999',
2454
+ progressColor: '#555',
2455
+ cursorWidth: 1,
2456
+ minPxPerSec: 0,
2457
+ fillParent: true,
2458
+ interact: true,
2459
+ dragToSeek: false,
2460
+ autoScroll: true,
2461
+ autoCenter: true,
2462
+ sampleRate: 8000,
2463
+ };
2464
+ class WaveSurfer extends Player {
2465
+ /** Create a new WaveSurfer instance */
2466
+ static create(options) {
2467
+ return new WaveSurfer(options);
2468
+ }
2469
+ /** Get the reactive state for advanced use cases */
2470
+ getState() {
2471
+ return this.wavesurferState;
2472
+ }
2473
+ /** Get the renderer instance for plugin access to reactive streams */
2474
+ getRenderer() {
2475
+ return this.renderer;
2476
+ }
2477
+ /** Create a new WaveSurfer instance */
2478
+ constructor(options) {
2479
+ const media = options.media ||
2480
+ (options.backend === 'WebAudio' ? new WebAudioPlayer() : undefined);
2481
+ super({
2482
+ media,
2483
+ mediaControls: options.mediaControls,
2484
+ autoplay: options.autoplay,
2485
+ playbackRate: options.audioRate,
2486
+ });
2487
+ this.plugins = [];
2488
+ this.decodedData = null;
2489
+ this.stopAtPosition = null;
2490
+ this.subscriptions = [];
2491
+ this.mediaSubscriptions = [];
2492
+ this.abortController = null;
2493
+ this._isDestroyed = false;
2494
+ this._loadVersion = 0;
2495
+ this.reactiveCleanups = [];
2496
+ this.options = Object.assign({}, defaultOptions, options);
2497
+ // Initialize reactive state
2498
+ // Pass Player signals to compose them into WaveSurferState
2499
+ const { state, actions } = createWaveSurferState({
2500
+ isPlaying: this.isPlayingSignal,
2501
+ currentTime: this.currentTimeSignal,
2502
+ duration: this.durationSignal,
2503
+ volume: this.volumeSignal,
2504
+ playbackRate: this.playbackRateSignal,
2505
+ isSeeking: this.seekingSignal,
2506
+ });
2507
+ this.wavesurferState = state;
2508
+ this.wavesurferActions = actions;
2509
+ this.timer = new Timer();
2510
+ const audioElement = media ? undefined : this.getMediaElement();
2511
+ this.renderer = new Renderer(this.options, audioElement);
2512
+ this.initPlayerEvents();
2513
+ this.initRendererEvents();
2514
+ this.initTimerEvents();
2515
+ this.initReactiveState();
2516
+ this.initPlugins();
2517
+ // Read the initial URL before load has been called
2518
+ const initialUrl = this.options.url || this.getSrc() || '';
2519
+ // Init and load async to allow external events to be registered
2520
+ Promise.resolve().then(() => {
2521
+ this.emit('init');
2522
+ // Load audio if URL or an external media with an src is passed,
2523
+ // of render w/o audio if pre-decoded peaks and duration are provided
2524
+ const { peaks, duration } = this.options;
2525
+ if (initialUrl || (peaks && duration)) {
2526
+ // Swallow async errors because they cannot be caught from a constructor call.
2527
+ // Subscribe to the wavesurfer's error event to handle them.
2528
+ this.load(initialUrl, peaks, duration).catch(() => {
2529
+ // Error already emitted by load()
2530
+ });
2531
+ }
2532
+ });
2533
+ }
2534
+ updateProgress(currentTime = this.getCurrentTime()) {
2535
+ this.renderer.renderProgress(currentTime / this.getDuration(), this.isPlaying());
2536
+ return currentTime;
2537
+ }
2538
+ initTimerEvents() {
2539
+ // The timer fires every 16ms for a smooth progress animation
2540
+ this.subscriptions.push(this.timer.on('tick', () => {
2541
+ if (!this.isSeeking()) {
2542
+ const currentTime = this.updateProgress();
2543
+ this.emit('timeupdate', currentTime);
2544
+ this.emit('audioprocess', currentTime);
2545
+ // Pause audio when it reaches the stopAtPosition
2546
+ if (this.stopAtPosition != null && this.isPlaying() && currentTime >= this.stopAtPosition) {
2547
+ // The timer may overshoot the stop position, so clamp the time back to it
2548
+ const stopAt = this.stopAtPosition;
2549
+ this.pause();
2550
+ this.setTime(stopAt);
2551
+ }
2552
+ }
2553
+ }));
2554
+ }
2555
+ initReactiveState() {
2556
+ // Bridge reactive state to EventEmitter for backwards compatibility
2557
+ this.reactiveCleanups.push(setupStateEventEmission(this.wavesurferState, {
2558
+ emit: this.emit.bind(this),
2559
+ }));
2560
+ }
2561
+ initPlayerEvents() {
2562
+ if (this.isPlaying()) {
2563
+ this.emit('play');
2564
+ this.timer.start();
2565
+ }
2566
+ this.mediaSubscriptions.push(this.onMediaEvent('timeupdate', () => {
2567
+ const currentTime = this.updateProgress();
2568
+ this.emit('timeupdate', currentTime);
2569
+ }), this.onMediaEvent('play', () => {
2570
+ this.emit('play');
2571
+ this.timer.start();
2572
+ }), this.onMediaEvent('pause', () => {
2573
+ this.emit('pause');
2574
+ this.timer.stop();
2575
+ this.stopAtPosition = null;
2576
+ }), this.onMediaEvent('emptied', () => {
2577
+ this.timer.stop();
2578
+ this.stopAtPosition = null;
2579
+ }), this.onMediaEvent('ended', () => {
2580
+ this.emit('timeupdate', this.getDuration());
2581
+ this.emit('finish');
2582
+ this.stopAtPosition = null;
2583
+ }), this.onMediaEvent('seeking', () => {
2584
+ this.emit('seeking', this.getCurrentTime());
2585
+ }), this.onMediaEvent('error', () => {
2586
+ var _a;
2587
+ this.emit('error', ((_a = this.getMediaElement().error) !== null && _a !== void 0 ? _a : new Error('Media error')));
2588
+ this.stopAtPosition = null;
2589
+ }));
2590
+ }
2591
+ initRendererEvents() {
2592
+ this.subscriptions.push(
2593
+ // Seek on click
2594
+ this.renderer.on('click', (relativeX, relativeY) => {
2595
+ if (this.options.interact) {
2596
+ this.seekTo(relativeX);
2597
+ this.emit('interaction', relativeX * this.getDuration());
2598
+ this.emit('click', relativeX, relativeY);
2599
+ }
2600
+ }),
2601
+ // Double click
2602
+ this.renderer.on('dblclick', (relativeX, relativeY) => {
2603
+ this.emit('dblclick', relativeX, relativeY);
2604
+ }),
2605
+ // Scroll
2606
+ this.renderer.on('scroll', (startX, endX, scrollLeft, scrollRight) => {
2607
+ const duration = this.getDuration();
2608
+ this.emit('scroll', startX * duration, endX * duration, scrollLeft, scrollRight);
2609
+ }),
2610
+ // Redraw
2611
+ this.renderer.on('render', () => {
2612
+ this.emit('redraw');
2613
+ }),
2614
+ // RedrawComplete
2615
+ this.renderer.on('rendered', () => {
2616
+ this.emit('redrawcomplete');
2617
+ }),
2618
+ // DragStart
2619
+ this.renderer.on('dragstart', (relativeX) => {
2620
+ this.emit('dragstart', relativeX);
2621
+ }),
2622
+ // DragEnd
2623
+ this.renderer.on('dragend', (relativeX) => {
2624
+ this.emit('dragend', relativeX);
2625
+ }),
2626
+ // Resize
2627
+ this.renderer.on('resize', () => {
2628
+ this.emit('resize');
2629
+ }));
2630
+ // Drag
2631
+ {
2632
+ let debounce;
2633
+ const unsubscribeDrag = this.renderer.on('drag', (relativeX) => {
2634
+ var _a;
2635
+ if (!this.options.interact)
2636
+ return;
2637
+ // Update the visual position
2638
+ this.renderer.renderProgress(relativeX);
2639
+ // Set the audio position with a debounce
2640
+ clearTimeout(debounce);
2641
+ let debounceTime = 0;
2642
+ const dragToSeek = this.options.dragToSeek;
2643
+ if (this.isPlaying()) {
2644
+ debounceTime = 0;
2645
+ }
2646
+ else if (dragToSeek === true) {
2647
+ debounceTime = 200;
2648
+ }
2649
+ else if (dragToSeek && typeof dragToSeek === 'object') {
2650
+ debounceTime = (_a = dragToSeek.debounceTime) !== null && _a !== void 0 ? _a : 200;
2651
+ }
2652
+ debounce = setTimeout(() => {
2653
+ this.seekTo(relativeX);
2654
+ }, debounceTime);
2655
+ this.emit('interaction', relativeX * this.getDuration());
2656
+ this.emit('drag', relativeX);
2657
+ });
2658
+ // Clear debounce timeout on destroy
2659
+ this.subscriptions.push(() => {
2660
+ clearTimeout(debounce);
2661
+ unsubscribeDrag();
2662
+ });
2663
+ }
2664
+ }
2665
+ initPlugins() {
2666
+ var _a;
2667
+ if (!((_a = this.options.plugins) === null || _a === void 0 ? void 0 : _a.length))
2668
+ return;
2669
+ this.options.plugins.forEach((plugin) => {
2670
+ this.registerPlugin(plugin);
2671
+ });
2672
+ }
2673
+ unsubscribePlayerEvents() {
2674
+ this.mediaSubscriptions.forEach((unsubscribe) => unsubscribe());
2675
+ this.mediaSubscriptions = [];
2676
+ }
2677
+ /** Set new wavesurfer options and re-render it */
2678
+ setOptions(options) {
2679
+ this.options = Object.assign({}, this.options, options);
2680
+ if (options.duration && !options.peaks) {
2681
+ this.decodedData = Decoder.createBuffer(this.exportPeaks(), options.duration);
2682
+ }
2683
+ if (options.peaks && options.duration) {
2684
+ // Create new decoded data buffer from peaks and duration
2685
+ this.decodedData = Decoder.createBuffer(options.peaks, options.duration);
2686
+ }
2687
+ this.renderer.setOptions(this.options);
2688
+ if (options.audioRate) {
2689
+ this.setPlaybackRate(options.audioRate);
2690
+ }
2691
+ if (options.mediaControls != null) {
2692
+ this.getMediaElement().controls = options.mediaControls;
2693
+ }
2694
+ }
2695
+ /** Register a wavesurfer.js plugin */
2696
+ registerPlugin(plugin) {
2697
+ // Check if the plugin is already registered
2698
+ if (this.plugins.includes(plugin)) {
2699
+ return plugin;
2700
+ }
2701
+ plugin._init(this);
2702
+ this.plugins.push(plugin);
2703
+ // Unregister plugin on destroy
2704
+ const unsubscribe = plugin.once('destroy', () => {
2705
+ this.plugins = this.plugins.filter((p) => p !== plugin);
2706
+ this.subscriptions = this.subscriptions.filter((fn) => fn !== unsubscribe);
2707
+ });
2708
+ this.subscriptions.push(unsubscribe);
2709
+ return plugin;
2710
+ }
2711
+ /** Unregister a wavesurfer.js plugin */
2712
+ unregisterPlugin(plugin) {
2713
+ this.plugins = this.plugins.filter((p) => p !== plugin);
2714
+ plugin.destroy();
2715
+ }
2716
+ /** For plugins only: get the waveform wrapper div */
2717
+ getWrapper() {
2718
+ return this.renderer.getWrapper();
2719
+ }
2720
+ /** For plugins only: get the scroll container client width */
2721
+ getWidth() {
2722
+ return this.renderer.getWidth();
2723
+ }
2724
+ /** Get the current scroll position in pixels */
2725
+ getScroll() {
2726
+ return this.renderer.getScroll();
2727
+ }
2728
+ /** Set the current scroll position in pixels */
2729
+ setScroll(pixels) {
2730
+ return this.renderer.setScroll(pixels);
2731
+ }
2732
+ /** Move the start of the viewing window to a specific time in the audio (in seconds) */
2733
+ setScrollTime(time) {
2734
+ const percentage = time / this.getDuration();
2735
+ this.renderer.setScrollPercentage(percentage);
2736
+ }
2737
+ /** Get all registered plugins */
2738
+ getActivePlugins() {
2739
+ return this.plugins;
2740
+ }
2741
+ loadAudio(url, blob, channelData, duration) {
2742
+ return __awaiter(this, void 0, void 0, function* () {
2743
+ var _a;
2744
+ // Re-entrancy guard: assign a version to this load call
2745
+ // If a newer load starts while this one is in-flight, this one will bail out
2746
+ const loadVersion = ++this._loadVersion;
2747
+ // Reusing an instance after destroy() is a supported behavior (see issue #3637
2748
+ // and cypress/e2e/abort.cy.js "load url after destroyed should emit ready").
2749
+ // Reset the destroyed flag so the instance can be reloaded. Stale in-flight
2750
+ // loads from before destroy() are still cancelled by the loadVersion guard
2751
+ // below, so this reset does not weaken the post-await bail-out checks.
2752
+ this._isDestroyed = false;
2753
+ this.emit('load', url);
2754
+ if (!this.options.media && this.isPlaying())
2755
+ this.pause();
2756
+ this.decodedData = null;
2757
+ this.stopAtPosition = null;
2758
+ // Abort any ongoing fetch before starting a new one
2759
+ (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
2760
+ this.abortController = null;
2761
+ // Fetch the entire audio as a blob if pre-decoded data is not provided
2762
+ if (!blob && !channelData) {
2763
+ const fetchParams = this.options.fetchParams || {};
2764
+ if (window.AbortController && !fetchParams.signal) {
2765
+ this.abortController = new AbortController();
2766
+ fetchParams.signal = this.abortController.signal;
2767
+ }
2768
+ const onProgress = (percentage) => this.emit('loading', percentage);
2769
+ blob = yield Fetcher.fetchBlob(url, onProgress, fetchParams);
2770
+ // Guard: bail if destroyed or a newer load started
2771
+ if (this._isDestroyed || loadVersion !== this._loadVersion)
2772
+ return;
2773
+ const overriddenMimeType = this.options.blobMimeType;
2774
+ if (overriddenMimeType) {
2775
+ blob = new Blob([blob], { type: overriddenMimeType });
2776
+ }
2777
+ }
2778
+ // Guard: bail if destroyed or a newer load started
2779
+ if (this._isDestroyed || loadVersion !== this._loadVersion)
2780
+ return;
2781
+ // Set the mediaelement source
2782
+ this.setSrc(url, blob);
2783
+ // Wait for the audio duration
2784
+ const audioDuration = yield new Promise((resolve) => {
2785
+ const staticDuration = duration || this.getDuration();
2786
+ if (staticDuration) {
2787
+ resolve(staticDuration);
2788
+ }
2789
+ else {
2790
+ this.mediaSubscriptions.push(this.onMediaEvent('loadedmetadata', () => resolve(this.getDuration()), { once: true }));
2791
+ }
2792
+ });
2793
+ // Guard: bail if destroyed or a newer load started
2794
+ if (this._isDestroyed || loadVersion !== this._loadVersion)
2795
+ return;
2796
+ // Set the duration if the player is a WebAudioPlayer without a URL
2797
+ if (!url && !blob) {
2798
+ const media = this.getMediaElement();
2799
+ if (media instanceof WebAudioPlayer) {
2800
+ media.duration = audioDuration;
2801
+ }
2802
+ }
2803
+ // Decode the audio data or use user-provided peaks
2804
+ if (channelData) {
2805
+ this.decodedData = Decoder.createBuffer(channelData, audioDuration || 0);
2806
+ }
2807
+ else if (blob) {
2808
+ const arrayBuffer = yield blob.arrayBuffer();
2809
+ // Guard: bail if destroyed or a newer load started
2810
+ if (this._isDestroyed || loadVersion !== this._loadVersion)
2811
+ return;
2812
+ this.decodedData = yield Decoder.decode(arrayBuffer, this.options.sampleRate);
2813
+ }
2814
+ // Guard: bail if destroyed or a newer load started
2815
+ if (this._isDestroyed || loadVersion !== this._loadVersion)
2816
+ return;
2817
+ if (this.decodedData) {
2818
+ this.emit('decode', this.getDuration());
2819
+ this.renderer.render(this.decodedData);
2820
+ }
2821
+ this.emit('ready', this.getDuration());
2822
+ });
2823
+ }
2824
+ /** Load an audio file by URL, with optional pre-decoded audio data */
2825
+ load(url, channelData, duration) {
2826
+ return __awaiter(this, void 0, void 0, function* () {
2827
+ try {
2828
+ return yield this.loadAudio(url, undefined, channelData, duration);
2829
+ }
2830
+ catch (err) {
2831
+ this.emit('error', err);
2832
+ throw err;
2833
+ }
2834
+ });
2835
+ }
2836
+ /** Load an audio blob */
2837
+ loadBlob(blob, channelData, duration) {
2838
+ return __awaiter(this, void 0, void 0, function* () {
2839
+ try {
2840
+ return yield this.loadAudio('', blob, channelData, duration);
2841
+ }
2842
+ catch (err) {
2843
+ this.emit('error', err);
2844
+ throw err;
2845
+ }
2846
+ });
2847
+ }
2848
+ /** Zoom the waveform by a given pixels-per-second factor */
2849
+ zoom(minPxPerSec) {
2850
+ if (!this.decodedData) {
2851
+ throw new Error('No audio loaded');
2852
+ }
2853
+ this.renderer.zoom(minPxPerSec);
2854
+ this.emit('zoom', minPxPerSec);
2855
+ }
2856
+ /** Get the decoded audio data */
2857
+ getDecodedData() {
2858
+ return this.decodedData;
2859
+ }
2860
+ /** Get decoded peaks */
2861
+ exportPeaks({ channels = 2, maxLength = 8000, precision = 10000 } = {}) {
2862
+ if (!this.decodedData) {
2863
+ throw new Error('The audio has not been decoded yet');
2864
+ }
2865
+ const maxChannels = Math.min(channels, this.decodedData.numberOfChannels);
2866
+ const peaks = [];
2867
+ for (let i = 0; i < maxChannels; i++) {
2868
+ const channel = this.decodedData.getChannelData(i);
2869
+ const data = [];
2870
+ const sampleSize = channel.length / maxLength;
2871
+ for (let j = 0; j < maxLength; j++) {
2872
+ const sample = channel.slice(Math.floor(j * sampleSize), Math.ceil((j + 1) * sampleSize));
2873
+ let max = 0;
2874
+ for (let x = 0; x < sample.length; x++) {
2875
+ const n = sample[x];
2876
+ if (Math.abs(n) > Math.abs(max))
2877
+ max = n;
2878
+ }
2879
+ data.push(Math.round(max * precision) / precision);
2880
+ }
2881
+ peaks.push(data);
2882
+ }
2883
+ return peaks;
2884
+ }
2885
+ /** Get the duration of the audio in seconds */
2886
+ getDuration() {
2887
+ let duration = super.getDuration() || 0;
2888
+ // Fall back to the decoded data duration if the media duration is incorrect
2889
+ if ((duration === 0 || duration === Infinity) && this.decodedData) {
2890
+ duration = this.decodedData.duration;
2891
+ }
2892
+ return duration;
2893
+ }
2894
+ /** Toggle if the waveform should react to clicks */
2895
+ toggleInteraction(isInteractive) {
2896
+ this.options.interact = isInteractive;
2897
+ }
2898
+ /** Jump to a specific time in the audio (in seconds) */
2899
+ setTime(time) {
2900
+ this.stopAtPosition = null;
2901
+ super.setTime(time);
2902
+ this.updateProgress(time);
2903
+ this.emit('timeupdate', time);
2904
+ }
2905
+ /** Seek to a ratio of audio as [0..1] (0 = beginning, 1 = end) */
2906
+ seekTo(progress) {
2907
+ const time = this.getDuration() * progress;
2908
+ this.setTime(time);
2909
+ }
2910
+ /** Start playing the audio */
2911
+ play(start, end) {
2912
+ const _super = Object.create(null, {
2913
+ play: { get: () => super.play }
2914
+ });
2915
+ return __awaiter(this, void 0, void 0, function* () {
2916
+ if (start != null) {
2917
+ this.setTime(start);
2918
+ }
2919
+ const playResult = yield _super.play.call(this);
2920
+ if (end != null) {
2921
+ if (this.media instanceof WebAudioPlayer) {
2922
+ this.media.stopAt(end);
2923
+ }
2924
+ else {
2925
+ this.stopAtPosition = end;
2926
+ }
2927
+ }
2928
+ return playResult;
2929
+ });
2930
+ }
2931
+ /** Play or pause the audio */
2932
+ playPause() {
2933
+ return __awaiter(this, void 0, void 0, function* () {
2934
+ return this.isPlaying() ? this.pause() : this.play();
2935
+ });
2936
+ }
2937
+ /** Stop the audio and go to the beginning */
2938
+ stop() {
2939
+ this.pause();
2940
+ this.setTime(0);
2941
+ }
2942
+ /** Skip N or -N seconds from the current position */
2943
+ skip(seconds) {
2944
+ this.setTime(this.getCurrentTime() + seconds);
2945
+ }
2946
+ /** Empty the waveform */
2947
+ empty() {
2948
+ this.load('', [[0]], 0.001);
2949
+ }
2950
+ /** Set HTML media element */
2951
+ setMediaElement(element) {
2952
+ this.unsubscribePlayerEvents();
2953
+ super.setMediaElement(element);
2954
+ this.initPlayerEvents();
2955
+ }
2956
+ exportImage() {
2957
+ return __awaiter(this, arguments, void 0, function* (format = 'image/png', quality = 1, type = 'dataURL') {
2958
+ return this.renderer.exportImage(format, quality, type);
2959
+ });
2960
+ }
2961
+ /** Unmount wavesurfer */
2962
+ destroy() {
2963
+ var _a;
2964
+ this._isDestroyed = true;
2965
+ this.emit('destroy');
2966
+ (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
2967
+ this.plugins.forEach((plugin) => plugin.destroy());
2968
+ this.subscriptions.forEach((unsubscribe) => unsubscribe());
2969
+ this.unsubscribePlayerEvents();
2970
+ this.reactiveCleanups.forEach((cleanup) => cleanup());
2971
+ this.reactiveCleanups = [];
2972
+ this.timer.destroy();
2973
+ this.renderer.destroy();
2974
+ super.destroy();
2975
+ }
2976
+ }
2977
+ WaveSurfer.BasePlugin = BasePlugin;
2978
+ WaveSurfer.dom = dom;
2979
+
2980
+ class AudioBubbleUI extends h {
2981
+ static get properties() {
2982
+ return {
2983
+ isPlaying: { type: Boolean },
2984
+ audioDuration: { type: String },
2985
+ isSelf: { type: Boolean },
2986
+ isDelivered: { type: Boolean },
2987
+ isRead: { type: Boolean },
2988
+ showFooter: { type: Boolean },
2989
+ textColor: { type: String },
2990
+ timeColor: { type: String },
2991
+ time: { type: String },
2992
+ bgColor: { type: String },
2993
+ borderRadius: { type: String },
2994
+ playAudioHandler: { type: Function },
2995
+ pauseAudioHandler: { type: Function },
2996
+ messageId: { type: String },
2997
+ reactions: { type: Object },
2998
+ showConfirmationPopup: { type: Boolean },
2999
+ selectedEmojiToRemove: { type: Object },
3000
+ showAllReactionsPopup: {type: Boolean},
3001
+ showReactionButton: {type: Boolean},
3002
+ showEmojiReactions: {type: Boolean},
3003
+ messageType: { type: Number },
3004
+ showReactionOnHover: {type: Boolean}
3005
+ };
3006
+ }
3007
+
3008
+ static get styles() {
3009
+ return i`
3010
+ :host {
3011
+ display: block;
3012
+ }
3013
+
3014
+ reaction-container {
3015
+ display: block;
3016
+ min-height: 150px;
3017
+ max-height: fit-content;
3018
+ min-width: 300px;
3019
+ max-width: 400px;
3020
+ position: absolute;
3021
+ z-index: 100;
3022
+ }
3023
+ .audio-bubble-wrapper {
3024
+ position: relative;
3025
+ display: flex;
3026
+ flex-direction: column;
3027
+ gap: 0.5rem;
3028
+ padding: 10px 10px 20px 10px;
3029
+ margin: 0.25rem 0px 0.25rem auto;
3030
+ border-radius: var(--radius-bubble);
3031
+ width: 336px;
3032
+ box-sizing: border-box;
3033
+ }
3034
+
3035
+ .sender-bg {
3036
+ background-color: var(--bg-outgoing-message);
3037
+ border: none;
3038
+ }
3039
+
3040
+ .receiver-bg {
3041
+ background-color: var(--bg-incoming-message);
3042
+ border: 1px solid var(--bubble-border, var(--primary));
3043
+ }
3044
+ .sender-text {
3045
+ color: var(--text-outgoing-message);
3046
+ }
3047
+
3048
+ .receiver-text {
3049
+ color: var(--text-incoming-message);
3050
+ }
3051
+
3052
+ .sender-icon svg {
3053
+ stroke: var(--text-outgoing-message);
3054
+ }
3055
+
3056
+ .receiver-icon svg {
3057
+ stroke: var(--text-incoming-message);
3058
+ }
3059
+
3060
+ .audio-content {
3061
+ display: flex;
3062
+ align-items: center;
3063
+ width: 100%;
3064
+ gap: 10px;
3065
+ }
3066
+
3067
+ .wavesurfer-timeline-progress {
3068
+ width: 10px !important;
3069
+ height: 10px !important;
3070
+ border-radius: 50% !important;
3071
+ background-color: red !important;
3072
+ }
3073
+
3074
+ .user_profile_picture {
3075
+ width: 55px;
3076
+ height: 55px;
3077
+ object-fit: cover;
3078
+ border-radius: 50%;
3079
+ }
3080
+
3081
+ @media (max-width: 768px) {
3082
+ .audio-bubble-wrapper {
3083
+ width: 280px;
3084
+ }
3085
+ }
3086
+
3087
+ .chat_audio_play_pause {
3088
+ width: 24px;
3089
+ height: 24px;
3090
+ min-width: 24px;
3091
+ cursor: pointer;
3092
+ display: flex;
3093
+ align-items: center;
3094
+ justify-content: center;
3095
+ }
3096
+
3097
+ .wave_container {
3098
+ flex: 1;
3099
+ height: 40px;
3100
+ min-height: 40px;
3101
+ border-radius: 4px;
3102
+ }
3103
+
3104
+ .audio-info {
3105
+ display: flex;
3106
+ align-items: center;
3107
+ justify-content: space-between;
3108
+ width: 100%;
3109
+ font-size: 10px;
3110
+ margin-top: 4px;
3111
+ }
3112
+
3113
+ .audio-time {
3114
+ font-size: 10px;
3115
+ }
3116
+
3117
+ .userContact_image {
3118
+ width: 55px;
3119
+ height: 55px;
3120
+ border-radius: 50%;
3121
+ background-color: #ccc;
3122
+ display: flex;
3123
+ align-items: center;
3124
+ justify-content: center;
3125
+ font-size: 24px;
3126
+ font-weight: bold;
3127
+ }
3128
+
3129
+ .pointer {
3130
+ cursor: pointer;
3131
+ }
3132
+
3133
+ .message-footer {
3134
+ display: flex;
3135
+ align-items: center;
3136
+ justify-content: flex-end;
3137
+ gap: 4px;
3138
+ width: 100%;
3139
+ margin-top: auto;
3140
+ font-size: 12px;
3141
+ }
3142
+
3143
+ .emoji-slider {
3144
+ position: absolute;
3145
+ }
3146
+
3147
+ emoji-reactions {
3148
+ position: absolute;
3149
+ top: 15px;
3150
+ z-index: 99;
3151
+ left: 0;
3152
+ }
3153
+
3154
+ .reaction-button {
3155
+ position: absolute;
3156
+ top: 50%;
3157
+ right: -25px;
3158
+ transform: translateY(-50%);
3159
+ cursor: pointer;
3160
+ z-index: 100;
3161
+ }
3162
+
3163
+ .remaining-count {
3164
+ background-color: var(--bg-primary-light);
3165
+ font-size: 14px;
3166
+ display: flex;
3167
+ justify-content: center;
3168
+ color: var(--text-primary-color);
3169
+ width: 25px;
3170
+ cursor: pointer;
3171
+ }
3172
+
3173
+ .reactions-display {
3174
+ position: absolute;
3175
+ bottom: -10px;
3176
+ right: 10px;
3177
+ display: grid;
3178
+ grid-template-columns: repeat(3, auto);
3179
+ gap: 0;
3180
+ margin-top: 4px;
3181
+ background-color: transparent;
3182
+ }
3183
+
3184
+ .reaction-item {
3185
+ display: flex;
3186
+ align-items: center;
3187
+ gap: 2px;
3188
+ border-radius: 12px;
3189
+ background: var(--bg-secondary-color);
3190
+ font-size: 20px;
3191
+ cursor: pointer;
3192
+ }
3193
+ `;
3194
+ }
3195
+
3196
+ constructor() {
3197
+ super();
3198
+ this.isPlaying = false;
3199
+ this.audioDuration = '0:00';
3200
+ this.isSelf = false;
3201
+ this.showReactionButton = false;
3202
+ this.showEmojiReactions = false;
3203
+ this.reactions = {};
3204
+ this.showAllReactionsPopup = false;
3205
+ this.showReactionOnHover = false;
3206
+ }
3207
+
3208
+ firstUpdated() {
3209
+ // Ensure everything is rendered first
3210
+ setTimeout(() => {
3211
+ const waveContainer = this.shadowRoot.querySelector('.wave_container');
3212
+ if (waveContainer) {
3213
+ // Make sure the component is fully rendered and attached to DOM
3214
+ this.dispatchEvent(
3215
+ new CustomEvent('waveformReady', {
3216
+ detail: waveContainer,
3217
+ bubbles: true,
3218
+ composed: true,
3219
+ }),
3220
+ );
3221
+ } else {
3222
+ console.error('Wave container element not found in shadowRoot');
3223
+ }
3224
+ }, 50);
3225
+ }
3226
+
3227
+ handleMouseEnter() {
3228
+ if(this.showReactionOnHover) {
3229
+ this.showReactionButton = true;
3230
+ }
3231
+ }
3232
+
3233
+
3234
+ handleReactionRemove(reaction) {
3235
+ this.showEmojiReactions = false;
3236
+
3237
+ this.showConfirmationPopup = true;
3238
+ this.selectedEmojiToRemove = reaction;
3239
+ setTimeout(() => {
3240
+ document.addEventListener('click', this.handleOutsideClick);
3241
+ }, 100);
3242
+ }
3243
+
3244
+ handleMouseLeave(e) {
3245
+ const messageContainer = this.renderRoot.querySelector('.message-container');
3246
+ const emojiReactions = this.renderRoot.querySelector('emoji-reactions');
3247
+ const reactionButton = this.renderRoot.querySelector('.reaction-button');
3248
+
3249
+ const isEmojiSliderOpen = this.showEmojiReactions;
3250
+
3251
+ const isMovingToMessage = messageContainer?.contains(e.relatedTarget);
3252
+ const isMovingToEmoji = emojiReactions && emojiReactions?.contains(e.relatedTarget);
3253
+ const isMovingToReactionButton = reactionButton && reactionButton?.contains(e.relatedTarget);
3254
+
3255
+ if (!isMovingToMessage && !isMovingToEmoji && !isMovingToReactionButton) {
3256
+ this.showReactionButton = false;
3257
+
3258
+ if (!isEmojiSliderOpen) {
3259
+ this.showEmojiReactions = false;
3260
+ }
3261
+ }
3262
+ }
3263
+
3264
+ handleOutsideClick = (e) => {
3265
+ const emojiReactions = this.renderRoot.querySelector('emoji-reactions');
3266
+ const messageContainer = this.renderRoot.querySelector('.message-container');
3267
+ const reactionContainer = this.renderRoot.querySelector('reaction-container');
3268
+
3269
+ const path = e.composedPath();
3270
+
3271
+ if ((this.showEmojiReactions &&
3272
+ !path.includes(emojiReactions) &&
3273
+ !path.includes(messageContainer)) ||
3274
+ (this.showConfirmationPopup &&
3275
+ !path.includes(reactionContainer) &&
3276
+ !path.includes(messageContainer))
3277
+ ) {
3278
+ this.showEmojiReactions = false;
3279
+ this.showConfirmationPopup = false;
3280
+ document.removeEventListener('click', this.handleOutsideClick);
3281
+ }
3282
+ }
3283
+ toggleEmojiReactions() {
3284
+ this.showConfirmationPopup = false;
3285
+
3286
+ this.showEmojiReactions = !this.showEmojiReactions;
3287
+
3288
+ if (this.showEmojiReactions) {
3289
+ setTimeout(() => {
3290
+ document.addEventListener('click', this.handleOutsideClick);
3291
+ }, 100);
3292
+ }
3293
+ }
3294
+ handleEmojiClick(emoji) {
3295
+ const currentUserId = this.userMetaData?.userId;
3296
+ const usersForEmoji = this.reactions[emoji.id] || [];
3297
+ const hasReaction = usersForEmoji.includes(currentUserId);
3298
+
3299
+ let existingReactionEmojiId = null;
3300
+
3301
+ for (const [emojiId, userIds] of Object.entries(this.reactions)) {
3302
+ if (userIds.includes(currentUserId)) {
3303
+ existingReactionEmojiId = emojiId;
3304
+ break;
3305
+ }
3306
+ }
3307
+
3308
+ if (existingReactionEmojiId && existingReactionEmojiId !== emoji.id) {
3309
+ this.dispatchEvent(
3310
+ new CustomEvent('reaction-removed', {
3311
+ detail: {
3312
+ messageId: this.messageId,
3313
+ emojiId: existingReactionEmojiId,
3314
+ },
3315
+ bubbles: true,
3316
+ composed: true,
3317
+ }),
3318
+ );
3319
+ }
3320
+
3321
+ if (hasReaction) {
3322
+ this.dispatchEvent(
3323
+ new CustomEvent('reaction-removed', {
3324
+ detail: {
3325
+ messageId: this.messageId,
3326
+ emojiId: emoji.id,
3327
+ },
3328
+ bubbles: true,
3329
+ composed: true,
3330
+ }),
3331
+ );
3332
+ } else {
3333
+ this.dispatchEvent(
3334
+ new CustomEvent('reaction-added', {
3335
+ detail: {
3336
+ messageId: this.messageId,
3337
+ emojiId: emoji.id,
3338
+ },
3339
+ bubbles: true,
3340
+ composed: true,
3341
+ }),
3342
+ );
3343
+ }
3344
+
3345
+ this.showEmojiReactions = false;
3346
+ document.removeEventListener('click', this.handleOutsideClick);
3347
+ }
3348
+ handleConfirmRemove() {
3349
+ if (this.selectedEmojiToRemove) {
3350
+ this.dispatchEvent(
3351
+ new CustomEvent('reaction-removed', {
3352
+ detail: {
3353
+ messageId: this.messageId,
3354
+ emojiId: this.selectedEmojiToRemove.emojiId,
3355
+ },
3356
+ bubbles: true,
3357
+ composed: true,
3358
+ }),
3359
+ );
3360
+ }
3361
+ this.closeConfirmationPopup();
3362
+ }
3363
+
3364
+ closeConfirmationPopup() {
3365
+ this.showConfirmationPopup = false;
3366
+ this.selectedEmojiToRemove = null;
3367
+ }
3368
+
3369
+
3370
+
3371
+ render() {
3372
+ const wrapperClass = `audio-bubble-wrapper ${this.isSelf ? 'sender-bg' : 'receiver-bg'}`;
3373
+ const textClass = this.isSelf ? 'sender-text' : 'receiver-text';
3374
+
3375
+ const emojiList = document.createElement('emoji-reactions').emojis;
3376
+ const allReactions = Object.keys(this.reactions)
3377
+ .map(reaction => {
3378
+ const matchingEmoji = emojiList.find(emoji => emoji.id === reaction);
3379
+ return {
3380
+ emojiId: reaction,
3381
+ messageId: this.reactions[reaction],
3382
+ src: matchingEmoji?.src,
3383
+ };
3384
+ })
3385
+ .filter(reaction => Array.isArray(reaction.messageId) && reaction.messageId.length > 0);
3386
+
3387
+ const visibleReactions = allReactions.slice(0, 2);
3388
+ const remainingCount = allReactions.length > 2 ? allReactions.length - 2 : 0;
3389
+
3390
+ return ke`
3391
+ <div class=${wrapperClass} @mouseover="${() => this.handleMouseEnter()}"
3392
+ @mouseout="${e => this.handleMouseLeave(e)}">
3393
+ ${this.messageType === 1
3394
+ ? ke`
3395
+ ${this.messageType === 1
3396
+ ? ke`
3397
+ <forward-ui></forward-ui>
3398
+ `
3399
+ : null}
3400
+ `
3401
+ : null}
3402
+ <div class="audio-content">
3403
+ ${this._renderPlayPauseIcon()}
3404
+ <div class="wave_container" id="waveform-container"></div>
3405
+ </div>
3406
+ ${!this.isSelf && this.showReactionButton
3407
+ ? ke`
3408
+ <div class="reaction-button" @click="${() => this.toggleEmojiReactions()}" ">
3409
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="var(--text-primary-color)">
3410
+ <path d="M612-516q25 0 42.5-17.5T672-576q0-25-17.5-42.5T612-636q-25 0-42.5 17.5T552-576q0 25 17.5 42.5T612-516Zm-264 0q25 0 42.5-17.5T408-576q0-25-17.5-42.5T348-636q-25 0-42.5 17.5T288-576q0 25 17.5 42.5T348-516Zm132 228q60 0 110.5-31t79.5-84H290q29 53 79.5 84T480-288Zm.28 192Q401-96 331-126t-122.5-82.5Q156-261 126-330.96t-30-149.5Q96-560 126-629.5q30-69.5 82.5-122T330.96-834q69.96-30 149.5-30t149.04 30q69.5 30 122 82.5T834-629.28q30 69.73 30 149Q864-401 834-331t-82.5 122.5Q699-156 629.28-126q-69.73 30-149 30ZM480-480Zm0 312q130 0 221-91t91-221q0-130-91-221t-221-91q-130 0-221 91t-91 221q0 130 91 221t221 91Z"/>
3411
+ </svg>
3412
+ </div>
3413
+ `
3414
+ : ''}
3415
+
3416
+ ${this.showConfirmationPopup
3417
+ ? ke` <reaction-container .messageId=${this.messageId} .userMetaData=${this.userMetaData} .reactions=${allReactions}></reaction-container> `
3418
+ : ''}
3419
+ ${this.showEmojiReactions
3420
+ ? ke`
3421
+ <emoji-reactions .isOpen="${this.showEmojiReactions}" .onEmojiSelect="${emoji => this.handleEmojiClick(emoji)}" .selectedEmojis="${this.reactions}"></emoji-reactions>
3422
+ `
3423
+ : ''}
3424
+
3425
+ <div class="reactions-display">
3426
+ ${visibleReactions?.map(
3427
+ reaction => ke`
3428
+ <span class="reaction-item" @click="${() => this.handleReactionRemove(reaction)}"> ${reaction.src ? ke`<span>${reaction.src}</span>` : ''} </span>
3429
+ `,
3430
+ )}
3431
+ ${remainingCount > 0
3432
+ ? ke`
3433
+ <span @click="${() => this.handleReactionRemove(visibleReactions[0])}" class="reaction-item remaining-count" "> +${remainingCount} </span>
3434
+
3435
+ `
3436
+ : ''}
3437
+ </div>
3438
+ <div class="audio-info">
3439
+ <span class="audio-time ${textClass}">${this.audioDuration}</span>
3440
+ </div>
3441
+
3442
+ ${this.showFooter ? ke`
3443
+ <div class="message-footer">
3444
+ <timestamp-element time="${this.time || new Date().toISOString()}" color="${this.timeColor}" ></timestamp-element>
3445
+ ${this.isSelf
3446
+ ? this.isRead
3447
+ ? ke`<blue-read-mark></blue-read-mark>`
3448
+ : this.isDelivered === 'true'
3449
+ ? ke`<double-mark></double-mark>`
3450
+ : this.isDelivered === 'pending'
3451
+ ? ke`<clock-mark></clock-mark>`
3452
+ : ke`<single-mark></single-mark>`
3453
+ : ''}
3454
+ </div>`:null}
3455
+ </div>
3456
+ `;
3457
+ }
3458
+
3459
+ _renderPlayPauseIcon() {
3460
+ const iconClass = `chat_audio_play_pause pointer ${this.isSelf ? 'sender-icon' : 'receiver-icon'}`;
3461
+ if (this.isPlaying) {
3462
+ return ke`
3463
+ <div @click=${this.pauseAudioHandler} class=${iconClass}>
3464
+ <svg
3465
+ xmlns="http://www.w3.org/2000/svg"
3466
+ width="24"
3467
+ height="24"
3468
+ viewBox="0 0 24 24"
3469
+ fill="none"
3470
+ stroke="currentColor"
3471
+ stroke-width="2"
3472
+ stroke-linecap="round"
3473
+ stroke-linejoin="round"
3474
+ >
3475
+ <rect x="6" y="4" width="4" height="16"></rect>
3476
+ <rect x="14" y="4" width="4" height="16"></rect>
3477
+ </svg>
3478
+ </div>
3479
+ `;
3480
+ } else {
3481
+ return ke`
3482
+ <div @click=${this.playAudioHandler} class=${iconClass}>
3483
+ <svg
3484
+ xmlns="http://www.w3.org/2000/svg"
3485
+ width="24"
3486
+ height="24"
3487
+ viewBox="0 0 24 24"
3488
+ fill="none"
3489
+ stroke="currentColor"
3490
+ stroke-width="2"
3491
+ stroke-linecap="round"
3492
+ stroke-linejoin="round"
3493
+ >
3494
+ <polygon points="5 3 19 12 5 21 5 3"></polygon>
3495
+ </svg>
3496
+ </div>
3497
+ `;
3498
+ }
3499
+ }
3500
+ }
3501
+
3502
+ customElements.define('audio-bubble-ui', AudioBubbleUI);
3503
+
3504
+ class MediaGallery extends h {
3505
+ static properties = {
3506
+ allAttachments: {
3507
+ type: Array,
3508
+ hasChanged(newVal, oldVal) {
3509
+ return JSON.stringify(newVal) !== JSON.stringify(oldVal);
3510
+ },
3511
+ },
3512
+ mainImageIndex: { type: Number },
3513
+ topbarBgColor: { type: String },
3514
+ iconColor: { type: String },
3515
+ galleryImageSize: { type: String },
3516
+ isZoomed: { type: Boolean },
3517
+ loadingMediaGallery: { type: Boolean },
3518
+ zoomLevel: { type: Number },
3519
+ isSharePopupOpen: { type: Boolean },
3520
+ shareLink: { type: String },
3521
+ };
3522
+
3523
+ static styles = i`
3524
+ :host {
3525
+ display: block;
3526
+ font-family: Arial, sans-serif;
3527
+ }
3528
+
3529
+ .media-gallery-container {
3530
+ width: 100%;
3531
+ height: 100%;
3532
+ z-index: 1000;
3533
+ display: flex;
3534
+ flex-direction: column;
3535
+ }
3536
+
3537
+ .topbar {
3538
+ display: flex;
3539
+ justify-content: flex-end;
3540
+ background-color: var(--bg-secondary-color);
3541
+ padding: 10px;
3542
+ }
3543
+
3544
+ .topbar-icon-container {
3545
+ display: flex;
3546
+ align-items: center;
3547
+ gap: 10px;
3548
+ }
3549
+
3550
+ .icon {
3551
+ cursor: pointer;
3552
+ color: var(--text-primary-color);
3553
+ }
3554
+
3555
+ .popup-overlay {
3556
+ position: fixed;
3557
+ top: 0;
3558
+ left: 0;
3559
+ height: 100%;
3560
+ width: 100%;
3561
+ background-color: var(--overlay-color);
3562
+ z-index: 999;
3563
+ display: flex;
3564
+ justify-content: center;
3565
+ align-items: center;
3566
+ }
3567
+
3568
+ .main-image-container {
3569
+ text-align: center;
3570
+ padding: 10px;
3571
+ background-color: var(--bg-primary-color);
3572
+ height: 50%;
3573
+ position: relative;
3574
+ touch-action: pan-y pinch-zoom;
3575
+ flex: 1;
3576
+ cursor: zoom-in;
3577
+ overflow: hidden;
3578
+ }
3579
+
3580
+ .main-image-container.zoomed {
3581
+ cursor: move;
3582
+ }
3583
+
3584
+ .main-image {
3585
+ max-width: 100%;
3586
+ height: 100%;
3587
+ border-radius: 5px;
3588
+ transition: transform 0.2s ease;
3589
+ object-fit: contain;
3590
+ }
3591
+
3592
+ .zoom-controls {
3593
+ position: absolute;
3594
+ bottom: 20px;
3595
+ left: 50%;
3596
+ transform: translateX(-50%);
3597
+ background: rgba(0, 0, 0, 0.6);
3598
+ border-radius: 20px;
3599
+ padding: 5px 10px;
3600
+ display: flex;
3601
+ align-items: center;
3602
+ gap: 10px;
3603
+ z-index: 10;
3604
+ }
3605
+
3606
+ .zoom-btn {
3607
+ background: none;
3608
+ border: none;
3609
+ color: white;
3610
+ font-size: 20px;
3611
+ cursor: pointer;
3612
+ width: 30px;
3613
+ height: 30px;
3614
+ display: flex;
3615
+ align-items: center;
3616
+ justify-content: center;
3617
+ }
3618
+
3619
+ .zoom-level {
3620
+ color: white;
3621
+ font-size: 14px;
3622
+ min-width: 50px;
3623
+ text-align: center;
3624
+ }
3625
+
3626
+ .nav-arrow {
3627
+ position: absolute;
3628
+ top: 50%;
3629
+ transform: translateY(-50%);
3630
+ background: rgba(0, 0, 0, 0.5);
3631
+ color: white;
3632
+ padding: 15px 10px;
3633
+ cursor: pointer;
3634
+ border: none;
3635
+ border-radius: 4px;
3636
+ font-size: 20px;
3637
+ z-index: 1;
3638
+ }
3639
+
3640
+ .nav-arrow:hover {
3641
+ background: rgba(0, 0, 0, 0.7);
3642
+ }
3643
+
3644
+ .nav-arrow.left {
3645
+ left: 10px;
3646
+ }
3647
+ .nav-arrow.right {
3648
+ right: 10px;
3649
+ }
3650
+
3651
+ .gallery {
3652
+ display: flex;
3653
+ gap: 10px;
3654
+ background-color: var(--bg-secondary-color);
3655
+ padding: 10px;
3656
+ overflow-x: auto;
3657
+ scrollbar-width: thin;
3658
+ }
3659
+
3660
+ .gallery::-webkit-scrollbar {
3661
+ height: 6px;
3662
+ }
3663
+
3664
+ .gallery::-webkit-scrollbar-thumb {
3665
+ background-color: rgba(0, 0, 0, 0.3);
3666
+ border-radius: 3px;
3667
+ }
3668
+
3669
+ .gallery-image,
3670
+ .gallery-video-container {
3671
+ width: var(--gallery-image-size, 70px);
3672
+ height: var(--gallery-image-size, 70px);
3673
+ flex-shrink: 0;
3674
+ border-radius: 5px;
3675
+ }
3676
+
3677
+ .gallery-image {
3678
+ object-fit: cover;
3679
+ cursor: pointer;
3680
+ transition: transform 0.2s;
3681
+ background-color: var(--base-color);
3682
+ }
3683
+
3684
+ .gallery-image:hover,
3685
+ .gallery-video-container:hover {
3686
+ transform: scale(1.05);
3687
+ }
3688
+
3689
+ .gallery-image.selected,
3690
+ .gallery-video-container.selected {
3691
+ transform: scale(1.1);
3692
+ outline: 3px solid var(--base-color);
3693
+ outline-offset: 2px;
3694
+ }
3695
+
3696
+ .unsupported-media {
3697
+ display: flex;
3698
+ justify-content: center;
3699
+ align-items: center;
3700
+ height: 100%;
3701
+ font-size: 20px;
3702
+ color: #808080;
3703
+ }
3704
+
3705
+ .video-thumbnail {
3706
+ width: 70px;
3707
+ height: 70px;
3708
+ }
3709
+
3710
+ .spinner-wrapper {
3711
+ position: absolute;
3712
+ top: 50%;
3713
+ left: 50%;
3714
+ transform: translate(-50%, -50%);
3715
+ display: flex;
3716
+ justify-content: center;
3717
+ align-items: center;
3718
+ }
3719
+
3720
+ .audio-wrapper{
3721
+ height: 100%;
3722
+ display: flex;
3723
+ align-items: center;
3724
+ justify-content: center;
3725
+ }
3726
+
3727
+ @media (max-width: 768px) {
3728
+ .main-image { max-height: 100%; }
3729
+ .gallery-image, .gallery-video-container {
3730
+ width: calc(var(--gallery-image-size, 70px) - 10px);
3731
+ height: calc(var(--gallery-image-size, 70px) - 10px);
3732
+ }
3733
+ }
3734
+ `;
3735
+
3736
+ constructor() {
3737
+ super();
3738
+ this.mainImageIndex = 0;
3739
+ this.topbarBgColor = '#f1f1f1';
3740
+ this.iconColor = 'var(--text-primary-color)';
3741
+ this.galleryImageSize = '70px';
3742
+ this.isZoomed = false;
3743
+ this.loadingMediaGallery = false;
3744
+ this._mediaItems = null;
3745
+ this._boundKeyHandler = this.handleKeyPress.bind(this);
3746
+ this._attachmentsHash = '';
3747
+
3748
+ // Zoom related properties
3749
+ this.zoomLevel = 1;
3750
+ this.minZoom = 1;
3751
+ this.maxZoom = 5;
3752
+ this.zoomStep = 0.5;
3753
+ this.isDragging = false;
3754
+ this.startX = 0;
3755
+ this.startY = 0;
3756
+ this.translateX = 0;
3757
+ this.translateY = 0;
3758
+ this.initialPinchDistance = 0;
3759
+
3760
+ // Image boundaries for constrained panning
3761
+ this.imageBounds = {
3762
+ width: 0,
3763
+ height: 0
3764
+ };
3765
+ this.containerBounds = {
3766
+ width: 0,
3767
+ height: 0
3768
+ };
3769
+ }
3770
+
3771
+ connectedCallback() {
3772
+ super.connectedCallback();
3773
+ window.addEventListener('keydown', this._boundKeyHandler);
3774
+ }
3775
+
3776
+ disconnectedCallback() {
3777
+ super.disconnectedCallback();
3778
+ window.removeEventListener('keydown', this._boundKeyHandler);
3779
+ this._removeZoomListeners();
3780
+ }
3781
+
3782
+ updated(changedProperties) {
3783
+ super.updated(changedProperties);
3784
+
3785
+ if (changedProperties.has('allAttachments')) {
3786
+ this.resetMediaItemsCache();
3787
+ }
3788
+
3789
+ if (changedProperties.has('mainImageIndex')) {
3790
+ // Reset zoom when changing images
3791
+ this.resetZoom();
3792
+ }
3793
+
3794
+ if (changedProperties.has('isZoomed')) {
3795
+ const mainContainer = this.shadowRoot.querySelector('.main-image-container');
3796
+ if (this.isZoomed) {
3797
+ mainContainer.classList.add('zoomed');
3798
+ this._setupZoomListeners();
3799
+ this._updateBoundingBoxes();
3800
+ } else {
3801
+ mainContainer.classList.remove('zoomed');
3802
+ this._removeZoomListeners();
3803
+ this.resetZoom();
3804
+ }
3805
+ }
3806
+
3807
+ if (changedProperties.has('zoomLevel')) {
3808
+ this._updateBoundingBoxes();
3809
+ }
3810
+ }
3811
+
3812
+ _updateBoundingBoxes() {
3813
+ requestAnimationFrame(() => {
3814
+ const container = this.shadowRoot.querySelector('.main-image-container');
3815
+ const image = this.shadowRoot.querySelector('.main-image');
3816
+
3817
+ if (!container || !image) return;
3818
+
3819
+ // Get the displayed dimensions of the image (not zoomed)
3820
+ const displayedWidth = image.offsetWidth / this.zoomLevel;
3821
+ const displayedHeight = image.offsetHeight / this.zoomLevel;
3822
+
3823
+ // Calculate the zoomed dimensions
3824
+ this.imageBounds = {
3825
+ width: displayedWidth * this.zoomLevel,
3826
+ height: displayedHeight * this.zoomLevel
3827
+ };
3828
+
3829
+ this.containerBounds = {
3830
+ width: container.clientWidth,
3831
+ height: container.clientHeight
3832
+ };
3833
+ });
3834
+ }
3835
+
3836
+ _calculateAttachmentsHash(attachments) {
3837
+ return JSON.stringify(attachments);
3838
+ }
3839
+
3840
+ _processAttachments() {
3841
+ if (!this.allAttachments) return [];
3842
+
3843
+ return this.allAttachments.reduce((acc, message) => {
3844
+ if (message.attachments?.length) {
3845
+ const validAttachments = message.attachments.filter(
3846
+ attachment => attachment.mimeType?.match(/^(image|video|audio)\//)
3847
+ );
3848
+ return [...acc, ...validAttachments];
3849
+ }
3850
+ return acc;
3851
+ }, []);
3852
+ }
3853
+
3854
+ get mediaItems() {
3855
+ const currentHash = this._calculateAttachmentsHash(this.allAttachments);
3856
+
3857
+ if (this._mediaItems === null || currentHash !== this._attachmentsHash) {
3858
+ this._attachmentsHash = currentHash;
3859
+ this._mediaItems = this._processAttachments();
3860
+ }
3861
+
3862
+ return this._mediaItems;
3863
+ }
3864
+
3865
+ resetMediaItemsCache() {
3866
+ this._mediaItems = null;
3867
+ this._attachmentsHash = '';
3868
+ }
3869
+
3870
+ handleKeyPress(event) {
3871
+ const currentMedia = this.mediaItems[this.mainImageIndex];
3872
+ const isImage = currentMedia?.mimeType?.startsWith('image/');
3873
+
3874
+ switch (event.key) {
3875
+ case 'ArrowLeft':
3876
+ this.navigateImage('prev');
3877
+ break;
3878
+ case 'ArrowRight':
3879
+ this.navigateImage('next');
3880
+ break;
3881
+ case 'Escape':
3882
+ if (this.isZoomed) {
3883
+ this.resetZoom();
3884
+ } else {
3885
+ this.closeGallery();
3886
+ }
3887
+ break;
3888
+ case '+':
3889
+ if (isImage) this.zoomIn();
3890
+ break;
3891
+ case '-':
3892
+ if (isImage) this.zoomOut();
3893
+ break;
3894
+ case ' ':
3895
+ case 'Enter':
3896
+ if (isImage) this.toggleZoom();
3897
+ break;
3898
+ }
3899
+ }
3900
+
3901
+ navigateImage(direction) {
3902
+ const newIndex = direction === 'next' ? Math.min(this.mainImageIndex + 1, this.mediaItems.length - 1) : Math.max(this.mainImageIndex - 1, 0);
3903
+
3904
+ if (newIndex !== this.mainImageIndex) {
3905
+ this.isZoomed = false;
3906
+ this.mainImageIndex = newIndex;
3907
+ }
3908
+ }
3909
+
3910
+ toggleZoom() {
3911
+ this.isZoomed = !this.isZoomed;
3912
+
3913
+ if (this.isZoomed) {
3914
+ this.zoomLevel = 1.5; // Start with slight zoom
3915
+ this._updateBoundingBoxes();
3916
+ this.updateZoomStyle();
3917
+ } else {
3918
+ this.resetZoom();
3919
+ }
3920
+ }
3921
+
3922
+ resetZoom() {
3923
+ this.zoomLevel = 1;
3924
+ this.translateX = 0;
3925
+ this.translateY = 0;
3926
+ this.isZoomed = false;
3927
+ this.updateZoomStyle();
3928
+ }
3929
+
3930
+ zoomIn(e) {
3931
+ if (e) e.stopPropagation();
3932
+
3933
+ if (this.zoomLevel < this.maxZoom) {
3934
+ this.zoomLevel = Math.min(this.zoomLevel + this.zoomStep, this.maxZoom);
3935
+ this._updateBoundingBoxes();
3936
+ this.constrainTranslation();
3937
+ this.updateZoomStyle();
3938
+ }
3939
+ }
3940
+
3941
+ zoomOut(e) {
3942
+ if (e) e.stopPropagation();
3943
+
3944
+ if (this.zoomLevel > this.minZoom) {
3945
+ this.zoomLevel = Math.max(this.zoomLevel - this.zoomStep, this.minZoom);
3946
+
3947
+ // If we're back at min zoom, reset position
3948
+ if (this.zoomLevel === this.minZoom) {
3949
+ this.translateX = 0;
3950
+ this.translateY = 0;
3951
+ } else {
3952
+ this._updateBoundingBoxes();
3953
+ this.constrainTranslation();
3954
+ }
3955
+
3956
+ this.updateZoomStyle();
3957
+ }
3958
+ }
3959
+
3960
+ // New method to constrain the translation within visible bounds
3961
+ constrainTranslation() {
3962
+ // Calculate how much the image extends beyond the container on each side when zoomed
3963
+ const overflowX = Math.max(0, this.imageBounds.width - this.containerBounds.width);
3964
+ const overflowY = Math.max(0, this.imageBounds.height - this.containerBounds.height);
3965
+
3966
+ // Ensure a minimum percentage of the image remains visible (e.g., 20%)
3967
+ const minVisibleWidth = this.containerBounds.width * 0.2;
3968
+ const minVisibleHeight = this.containerBounds.height * 0.2;
3969
+
3970
+ // Calculate maximum allowed translation
3971
+ // This allows the image to move until only the minimum visible portion remains
3972
+ const maxTranslateX = overflowX / 2 + (this.containerBounds.width - minVisibleWidth) / 2;
3973
+ const maxTranslateY = overflowY / 2 + (this.containerBounds.height - minVisibleHeight) / 2;
3974
+
3975
+ // Constrain the translation values
3976
+ this.translateX = Math.max(-maxTranslateX, Math.min(maxTranslateX, this.translateX));
3977
+ this.translateY = Math.max(-maxTranslateY, Math.min(maxTranslateY, this.translateY));
3978
+ }
3979
+
3980
+ updateZoomStyle() {
3981
+ const mainImage = this.shadowRoot.querySelector('.main-image');
3982
+ if (!mainImage) return;
3983
+
3984
+ mainImage.style.transform = `translate(${this.translateX}px, ${this.translateY}px) scale(${this.zoomLevel})`;
3985
+
3986
+ // Only show zoomed cursor when zoomed in
3987
+ const container = this.shadowRoot.querySelector('.main-image-container');
3988
+ if (container) {
3989
+ if (this.zoomLevel > 1) {
3990
+ container.classList.add('zoomed');
3991
+ } else {
3992
+ container.classList.remove('zoomed');
3993
+ }
3994
+ }
3995
+
3996
+ this.requestUpdate();
3997
+ }
3998
+
3999
+ _setupZoomListeners() {
4000
+ const container = this.shadowRoot.querySelector('.main-image-container');
4001
+ const mainImage = this.shadowRoot.querySelector('.main-image');
4002
+
4003
+ if (!container || !mainImage) return;
4004
+
4005
+ // Mouse events for desktop
4006
+ this._boundMouseDown = this.handleMouseDown.bind(this);
4007
+ this._boundMouseMove = this.handleMouseMove.bind(this);
4008
+ this._boundMouseUp = this.handleMouseUp.bind(this);
4009
+ this._boundWheel = this.handleWheel.bind(this);
4010
+
4011
+ // Touch events for mobile
4012
+ this._boundTouchStart = this.handleTouchStart.bind(this);
4013
+ this._boundTouchMove = this.handleTouchMove.bind(this);
4014
+ this._boundTouchEnd = this.handleTouchEnd.bind(this);
4015
+
4016
+ container.addEventListener('mousedown', this._boundMouseDown);
4017
+ window.addEventListener('mousemove', this._boundMouseMove);
4018
+ window.addEventListener('mouseup', this._boundMouseUp);
4019
+ container.addEventListener('wheel', this._boundWheel);
4020
+
4021
+ container.addEventListener('touchstart', this._boundTouchStart, { passive: false });
4022
+ container.addEventListener('touchmove', this._boundTouchMove, { passive: false });
4023
+ container.addEventListener('touchend', this._boundTouchEnd);
4024
+
4025
+ // Update bounding boxes on window resize
4026
+ this._boundResizeHandler = this._updateBoundingBoxes.bind(this);
4027
+ window.addEventListener('resize', this._boundResizeHandler);
4028
+
4029
+ // Initial update of bounding boxes
4030
+ this._updateBoundingBoxes();
4031
+ }
4032
+
4033
+ _removeZoomListeners() {
4034
+ const container = this.shadowRoot.querySelector('.main-image-container');
4035
+
4036
+ if (!container) return;
4037
+
4038
+ if (this._boundMouseDown) {
4039
+ container.removeEventListener('mousedown', this._boundMouseDown);
4040
+ window.removeEventListener('mousemove', this._boundMouseMove);
4041
+ window.removeEventListener('mouseup', this._boundMouseUp);
4042
+ container.removeEventListener('wheel', this._boundWheel);
4043
+
4044
+ container.removeEventListener('touchstart', this._boundTouchStart);
4045
+ container.removeEventListener('touchmove', this._boundTouchMove);
4046
+ container.removeEventListener('touchend', this._boundTouchEnd);
4047
+ }
4048
+
4049
+ if (this._boundResizeHandler) {
4050
+ window.removeEventListener('resize', this._boundResizeHandler);
4051
+ }
4052
+ }
4053
+
4054
+ handleMouseDown(e) {
4055
+ const currentMedia = this.mediaItems[this.mainImageIndex];
4056
+ const isImage = currentMedia?.mimeType?.startsWith('image/');
4057
+
4058
+ if (!isImage || this.zoomLevel <= 1) return;
4059
+
4060
+ this.isDragging = true;
4061
+ this.startX = e.clientX - this.translateX;
4062
+ this.startY = e.clientY - this.translateY;
4063
+ e.preventDefault();
4064
+ }
4065
+
4066
+ handleMouseMove(e) {
4067
+ if (!this.isDragging) return;
4068
+
4069
+ const newTranslateX = e.clientX - this.startX;
4070
+ const newTranslateY = e.clientY - this.startY;
4071
+
4072
+ this.translateX = newTranslateX;
4073
+ this.translateY = newTranslateY;
4074
+
4075
+ // Apply constraints to keep the image in view
4076
+ this.constrainTranslation();
4077
+ this.updateZoomStyle();
4078
+ e.preventDefault();
4079
+ }
4080
+
4081
+ handleMouseUp() {
4082
+ this.isDragging = false;
4083
+ }
4084
+
4085
+ handleWheel(e) {
4086
+ e.preventDefault();
4087
+
4088
+ const currentMedia = this.mediaItems[this.mainImageIndex];
4089
+ const isImage = currentMedia?.mimeType?.startsWith('image/');
4090
+
4091
+ if (!isImage) return;
4092
+
4093
+ // Get cursor position relative to container for zoom targeting
4094
+ const container = this.shadowRoot.querySelector('.main-image-container');
4095
+ container.getBoundingClientRect();
4096
+
4097
+ // Store old zoom level
4098
+ const oldZoom = this.zoomLevel;
4099
+
4100
+ if (e.deltaY < 0) {
4101
+ // Zoom in
4102
+ this.zoomIn();
4103
+ } else {
4104
+ // Zoom out
4105
+ this.zoomOut();
4106
+ }
4107
+
4108
+ // If zoom level actually changed and we're zoomed in
4109
+ if (oldZoom !== this.zoomLevel && this.zoomLevel > 1) {
4110
+ // Adjust translateX and translateY to zoom in/out around cursor position
4111
+ // This is a simplified approach - for more precise targeting, you'd need more complex math
4112
+ this.constrainTranslation();
4113
+ }
4114
+ }
4115
+
4116
+ handleTouchStart(e) {
4117
+ const currentMedia = this.mediaItems[this.mainImageIndex];
4118
+ const isImage = currentMedia?.mimeType?.startsWith('image/');
4119
+
4120
+ if (!isImage) return;
4121
+
4122
+ e.preventDefault();
4123
+
4124
+ if (e.touches.length === 1) {
4125
+ // Single touch - prepare for panning
4126
+ this.isDragging = true;
4127
+ this.startX = e.touches[0].clientX - this.translateX;
4128
+ this.startY = e.touches[0].clientY - this.translateY;
4129
+ }
4130
+ else if (e.touches.length === 2) {
4131
+ // Pinch to zoom
4132
+ this.isDragging = false;
4133
+ const touch1 = e.touches[0];
4134
+ const touch2 = e.touches[1];
4135
+ this.initialPinchDistance = Math.hypot(
4136
+ touch2.clientX - touch1.clientX,
4137
+ touch2.clientY - touch1.clientY
4138
+ );
4139
+ }
4140
+ }
4141
+
4142
+ handleTouchMove(e) {
4143
+ const currentMedia = this.mediaItems[this.mainImageIndex];
4144
+ const isImage = currentMedia?.mimeType?.startsWith('image/');
4145
+
4146
+ if (!isImage || this.zoomLevel <= 1 && e.touches.length === 1) return;
4147
+
4148
+ e.preventDefault();
4149
+
4150
+ if (e.touches.length === 1 && this.isDragging) {
4151
+ // Pan the image
4152
+ this.translateX = e.touches[0].clientX - this.startX;
4153
+ this.translateY = e.touches[0].clientY - this.startY;
4154
+
4155
+ // Apply constraints to keep the image in view
4156
+ this.constrainTranslation();
4157
+ this.updateZoomStyle();
4158
+ }
4159
+ else if (e.touches.length === 2) {
4160
+ // Pinch zoom
4161
+ const touch1 = e.touches[0];
4162
+ const touch2 = e.touches[1];
4163
+ const currentDistance = Math.hypot(
4164
+ touch2.clientX - touch1.clientX,
4165
+ touch2.clientY - touch1.clientY
4166
+ );
4167
+
4168
+ if (this.initialPinchDistance > 0) {
4169
+ const pinchRatio = currentDistance / this.initialPinchDistance;
4170
+ const newZoomLevel = Math.max(
4171
+ this.minZoom,
4172
+ Math.min(this.maxZoom, this.zoomLevel * pinchRatio)
4173
+ );
4174
+
4175
+ // Apply zoom centered on pinch point
4176
+ this.zoomLevel = newZoomLevel;
4177
+ this.initialPinchDistance = currentDistance;
4178
+
4179
+ this._updateBoundingBoxes();
4180
+ this.constrainTranslation();
4181
+ this.updateZoomStyle();
4182
+ }
4183
+ }
4184
+ }
4185
+
4186
+ handleTouchEnd(e) {
4187
+ this.isDragging = false;
4188
+ this.initialPinchDistance = 0;
4189
+
4190
+ // If we're at minimum zoom, reset position
4191
+ if (this.zoomLevel <= this.minZoom) {
4192
+ this.resetZoom();
4193
+ }
4194
+ }
4195
+
4196
+ handleShare() {
4197
+ const currentMedia = this.mediaItems[this.mainImageIndex];
4198
+ if (!currentMedia) return;
4199
+ drawerDialogService.openDialog('share-popup', {
4200
+ titleColor:"var(--text-primary-color)",
4201
+ ctaColor:"var(--bg-primary-color)",
4202
+ title:WEB_CONTENT.POPUP_MESSAGES.SHARE_MEDIA_LABEL,
4203
+ shareLink:currentMedia.mediaUrl
4204
+ });
4205
+
4206
+ }
4207
+
4208
+
4209
+ async handleDownload() {
4210
+ const currentMedia = this.mediaItems[this.mainImageIndex];
4211
+ if (!currentMedia) return;
4212
+
4213
+ const extension = currentMedia.mimeType?.includes('/') ? '.' + currentMedia.mimeType.split('/')[1] : '.jpg';
4214
+
4215
+ try {
4216
+ const response = await fetch(currentMedia.mediaUrl);
4217
+ const blob = await response.blob();
4218
+ const url = URL.createObjectURL(blob);
4219
+ const a = document.createElement('a');
4220
+ a.href = url;
4221
+ a.download = `chat-media${extension}`;
4222
+ document.body.appendChild(a);
4223
+ a.click();
4224
+ document.body.removeChild(a);
4225
+ URL.revokeObjectURL(url);
4226
+ } catch (error) {
4227
+ console.error('Download failed:', error);
4228
+ }
4229
+ }
4230
+
4231
+ openShareWindow(url) {
4232
+ window.open(`mailto:?body=${encodeURIComponent(url)}`, '_blank');
4233
+ }
4234
+
4235
+ closeGallery() {
4236
+ this.dispatchEvent(new CustomEvent('close', { bubbles: true, composed: true }));
4237
+ }
4238
+
4239
+
4240
+ render() {
4241
+ const items = this.mediaItems;
4242
+
4243
+ if (this.loadingMediaGallery && !items.length) {
4244
+ return ke`<div class="spinner-wrapper">
4245
+ <spinner-loader
4246
+ height="15px"
4247
+ width="15px"
4248
+ spinTime="1s"
4249
+ spinnerPrimaryColor="var(--bg-primary-color)"
4250
+ spinnerSecondaryColor="var(--text-primary-color)"
4251
+ spinnerBorderWidth="2px"
4252
+ ></spinner-loader>
4253
+ </div>`;
4254
+ }
4255
+
4256
+ if (!this.loadingMediaGallery && !items.length) {
4257
+ return ke`<div class="unsupported-media">${WEB_CONTENT.PLACEHOLDER_CONTENT.UNSUPPORTED_MEDIA}</div>`;
4258
+ }
4259
+
4260
+ const currentMedia = items[this.mainImageIndex];
4261
+ const isImage = currentMedia?.mimeType?.startsWith('image/');
4262
+ const isVideo = currentMedia?.mimeType?.startsWith('video/');
4263
+ const isAudio = currentMedia?.mimeType?.startsWith('audio/');
4264
+
4265
+ return ke`
4266
+ <div class="media-gallery-container">
4267
+ <div class="topbar">
4268
+ <div class="topbar-icon-container">
4269
+ ${!isAudio ? ke` <span class="icon" @click=${this.handleShare}>
4270
+ <svg width="20" height="20" fill="var(--text-primary-color)" viewBox="0 0 1920 1920">
4271
+ <path
4272
+ d="M1513.827 1278.28c-96.772 0-182.634 43.765-241.415 111.531l-564.2-325.737c11.807-33.498 19.508-69.049 19.508-106.654 0-34.91-7.06-68.022-17.327-99.595l563.815-325.48c58.782 66.482 143.746 109.35 239.619 109.35 177.243 0 320.86-143.618 320.86-320.86 0-177.244-143.617-320.86-320.86-320.86-177.243 0-320.86 143.616-320.86 320.86 0 35.165 7.059 68.407 17.454 99.98l-563.686 325.48C587.953 679.554 502.86 636.56 406.86 636.56 229.617 636.56 86 780.177 86 957.42c0 177.243 143.617 320.86 320.86 320.86 93.434 0 176.601-40.428 235.254-104.215l567.537 327.662c-9.882 30.803-16.684 63.145-16.684 97.413 0 177.243 143.617 320.86 320.86 320.86 177.243 0 320.86-143.617 320.86-320.86 0-177.243-143.617-320.86-320.86-320.86"
4273
+ />
4274
+ </svg>
4275
+ </span>` : null}
4276
+ <span class="icon" @click=${this.handleDownload}>
4277
+ <svg width="24" fill="var(--text-primary-color)" height="24" viewBox="0 0 24 24">
4278
+ <path
4279
+ d="M9.163 2.819C9 3.139 9 3.559 9 4.4V11H7.803c-.883 0-1.325 0-1.534.176a.75.75 0 0 0-.266.62c.017.274.322.593.931 1.232l4.198 4.401c.302.318.453.476.63.535a.749.749 0 0 0 .476 0c.177-.059.328-.217.63-.535l4.198-4.4c.61-.64.914-.96.93-1.233a.75.75 0 0 0-.265-.62C17.522 11 17.081 11 16.197 11H15V4.4c0-.84 0-1.26-.164-1.581a1.5 1.5 0 0 0-.655-.656C13.861 2 13.441 2 12.6 2h-1.2c-.84 0-1.26 0-1.581.163a1.5 1.5 0 0 0-.656.656zM5 21a1 1 0 0 0 1 1h12a1 1 0 1 0 0-2H6a1 1 0 0 0-1 1z"
4280
+ />
4281
+ </svg>
4282
+ </span>
4283
+ <span class="icon" @click=${this.closeGallery}>
4284
+ <svg width="24" height="24" fill="var(--text-primary-color)" viewBox="0 0 24 24">
4285
+ <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" />
4286
+ </svg>
4287
+ </span>
4288
+ </div>
4289
+ </div>
4290
+
4291
+ <div class="main-image-container">
4292
+ ${this.mainImageIndex > 0
4293
+ ? ke`<button class="nav-arrow left" @click=${e => (e.stopPropagation(), this.navigateImage('prev'))}>←</button>`
4294
+ : ''}
4295
+
4296
+ ${
4297
+ isImage
4298
+ ? ke`
4299
+ <img src="${currentMedia.mediaUrl}" alt="Main Image" class="main-image" @dblclick=${this.toggleZoom} />
4300
+ ${this.isZoomed && isImage ? ke`
4301
+ <div class="zoom-controls">
4302
+ <button class="zoom-btn" @click=${this.zoomOut}>−</button>
4303
+ <span class="zoom-level">${Math.round(this.zoomLevel * 100)}%</span>
4304
+ <button class="zoom-btn" @click=${this.zoomIn}>+</button>
4305
+ </div>
4306
+ ` : ''}
4307
+ `
4308
+ : isVideo
4309
+ ? ke`<video src="${currentMedia.mediaUrl}" class="main-image" controls autoplay></video>`
4310
+ : isAudio
4311
+ ? ke`
4312
+ <div class='audio-wrapper' key=${currentMedia?.mediaUrl}>
4313
+ <audio-bubble
4314
+ .audioUrl=${currentMedia?.mediaUrl}
4315
+ .showFooter=${false}
4316
+ ></audio-bubble>
4317
+ </div>
4318
+ `
4319
+ : ke`<div class="unsupported-media">${WEB_CONTENT.UNSUPPORTED_MEDIA_TYPES}</div>`}
4320
+
4321
+ ${this.mainImageIndex < items.length - 1
4322
+ ? ke`<button class="nav-arrow right" @click=${e => (e.stopPropagation(), this.navigateImage('next'))}>→</button>`
4323
+ : ''}
4324
+ </div>
4325
+
4326
+ <div class="gallery">
4327
+ ${items.map((media, index) => {
4328
+ const isVideo = media.mimeType?.startsWith('video/');
4329
+ const isAudio = media.mimeType?.startsWith('audio/');
4330
+ return isVideo
4331
+ ? ke`
4332
+ <div class="gallery-video-container ${index === this.mainImageIndex ? 'selected' : ''}"
4333
+ @click=${() => (this.mainImageIndex = index)}>
4334
+ <img class='video-thumbnail' src="${videoPlaceholderSvg}"></img>
4335
+ </div>`
4336
+ : isAudio
4337
+ ? ke`
4338
+ <img src="${equalizerSvg}"
4339
+ alt="Gallery Image ${index + 1}"
4340
+ class="gallery-image ${index === this.mainImageIndex ? 'selected' : ''}"
4341
+ @click=${() => (this.mainImageIndex = index)} />`
4342
+ : ke`
4343
+ <img src="${media.mediaUrl}"
4344
+ alt="Gallery Image ${index + 1}"
4345
+ class="gallery-image ${index === this.mainImageIndex ? 'selected' : ''}"
4346
+ @click=${() => (this.mainImageIndex = index)} />`;
4347
+ })}
4348
+ </div>
4349
+ </div>
4350
+ `;
4351
+ }
4352
+ }
4353
+
4354
+ customElements.define('media-gallery', MediaGallery);
4355
+
4356
+ const imagePlaceholderSvg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhLS0gVXBsb2FkZWQgdG86IFNWRyBSZXBvLCB3d3cuc3ZncmVwby5jb20sIEdlbmVyYXRvcjogU1ZHIFJlcG8gTWl4ZXIgVG9vbHMgLS0+CjxzdmcgZmlsbD0iIzAwMDAwMCIgd2lkdGg9IjgwMHB4IiBoZWlnaHQ9IjgwMHB4IiB2aWV3Qm94PSIwIDAgMzUgMzUiIGRhdGEtbmFtZT0iTGF5ZXIgMiIgaWQ9ImY3YjlkMzFiLTNkYjQtNDhkYi05NjMwLTViNDYyNDk5NmY1OCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMjkuNDY3LDM0Ljc0OUg1LjUzQTUuMjg4LDUuMjg4LDAsMCwxLC4yNSwyOS40NjdWNS41MzJBNS4yODYsNS4yODYsMCwwLDEsNS41My4yNTJIMjkuNDY3YTUuMjg2LDUuMjg2LDAsMCwxLDUuMjgsNS4yOFYyOS40NjdBNS4yODgsNS4yODgsMCwwLDEsMjkuNDY3LDM0Ljc0OVpNNS41MywyLjc1MmEyLjc4MywyLjc4MywwLDAsMC0yLjc4LDIuNzhWMjkuNDY3YTIuNzg0LDIuNzg0LDAsMCwwLDIuNzgsMi43ODJIMjkuNDY3YTIuNzg0LDIuNzg0LDAsMCwwLDIuNzgtMi43ODJWNS41MzJhMi43ODMsMi43ODMsMCwwLDAtMi43OC0yLjc4WiIvPjxwYXRoIGQ9Ik0xMS44NiwxNy4yMjZhNC40NjgsNC40NjgsMCwxLDEsNC40NjgtNC40NjhBNC40NzMsNC40NzMsMCwwLDEsMTEuODYsMTcuMjI2Wm0wLTYuNDM1YTEuOTY4LDEuOTY4LDAsMSwwLDEuOTY4LDEuOTY3QTEuOTcsMS45NywwLDAsMCwxMS44NiwxMC43OTFaIi8+PHBhdGggZD0iTTIuNjY0LDMxLjkyYTEuMjUsMS4yNSwwLDAsMS0uOTI5LTIuMDg1bDUuODc2LTYuNTQ3YTMuMjg4LDMuMjg4LDAsMCwxLDQuNTUzLS4zNDFsMi41MjUsMi4wODRhLjc3Ljc3LDAsMCwwLC42LjE3OC43OTQuNzk0LDAsMCwwLC41NDMtLjNsNi42NDQtOC41ODRhMy4yNzcsMy4yNzcsMCwwLDEsMi42LTEuMjc5aC4wMTJBMy4yODIsMy4yODIsMCwwLDEsMjcuNjczLDE2LjNsNi4zNzIsOC4xMDdhMS4yNSwxLjI1LDAsMCwxLTEuOTY2LDEuNTQ1bC02LjM3Mi04LjEwN2EuNzg1Ljc4NSwwLDAsMC0uNjI3LS4zLjg2NC44NjQsMCwwLDAtLjYzMS4zMDlMMTcuOCwyNi40MzRhMy4zLDMuMywwLDAsMS00LjcwNy41MjVsLTIuNTI1LTIuMDg0YS43OTQuNzk0LDAsMCwwLTEuMS4wODNMMy42LDMxLjVBMS4yNDUsMS4yNDUsMCwwLDEsMi42NjQsMzEuOTJaIi8+PC9zdmc+';
4357
+
4358
+ export { WaveSurfer as W, equalizerSvg as e, imagePlaceholderSvg as i, videoPlaceholderSvg as v };
4359
+
4360
+ //# sourceMappingURL=imagePlaceholder-e544f70b.js.map