@deffa5556/bail 1.0.6 → 1.0.7

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 (314) hide show
  1. package/cjs/WAProto/index.cjs +106053 -0
  2. package/cjs/deffa/config.cjs +14 -0
  3. package/cjs/deffa/plugins/ai/deepseekr1.cjs +35 -0
  4. package/cjs/deffa/plugins/ai/gita.cjs +26 -0
  5. package/cjs/deffa/plugins/ai/glm47flash.cjs +35 -0
  6. package/cjs/deffa/plugins/ai/gptoss120b.cjs +35 -0
  7. package/cjs/deffa/plugins/ai/qwq32b.cjs +35 -0
  8. package/cjs/deffa/plugins/berita/antara.cjs +25 -0
  9. package/cjs/deffa/plugins/berita/cnbcindonesia.cjs +25 -0
  10. package/cjs/deffa/plugins/berita/cnn.cjs +25 -0
  11. package/cjs/deffa/plugins/berita/kompas.cjs +25 -0
  12. package/cjs/deffa/plugins/berita/liputan6.cjs +25 -0
  13. package/cjs/deffa/plugins/berita/merdeka.cjs +25 -0
  14. package/cjs/deffa/plugins/berita/sindonews.cjs +25 -0
  15. package/cjs/deffa/plugins/berita/tribunnews.cjs +25 -0
  16. package/cjs/deffa/plugins/downloader/douyin.cjs +30 -0
  17. package/cjs/deffa/plugins/downloader/facebook.cjs +30 -0
  18. package/cjs/deffa/plugins/downloader/github.cjs +35 -0
  19. package/cjs/deffa/plugins/downloader/lahelu.cjs +30 -0
  20. package/cjs/deffa/plugins/downloader/snackvideo.cjs +30 -0
  21. package/cjs/deffa/plugins/downloader/soundcloud.cjs +30 -0
  22. package/cjs/deffa/plugins/downloader/tiktok.cjs +30 -0
  23. package/cjs/deffa/plugins/downloader/tiktokhd.cjs +30 -0
  24. package/cjs/deffa/plugins/downloader/twitter.cjs +30 -0
  25. package/cjs/deffa/plugins/downloader/ummy.cjs +36 -0
  26. package/cjs/deffa/plugins/index.cjs +213 -0
  27. package/cjs/deffa/plugins/info/bmkg.cjs +34 -0
  28. package/cjs/deffa/plugins/info/cuaca.cjs +31 -0
  29. package/cjs/deffa/plugins/info/jadwaltv.cjs +29 -0
  30. package/cjs/deffa/plugins/maker/brat.cjs +45 -0
  31. package/cjs/deffa/plugins/maker/bratvid.cjs +52 -0
  32. package/cjs/deffa/plugins/search/8font.cjs +28 -0
  33. package/cjs/deffa/plugins/search/applemusic.cjs +28 -0
  34. package/cjs/deffa/plugins/search/bimg.cjs +30 -0
  35. package/cjs/deffa/plugins/search/brave.cjs +34 -0
  36. package/cjs/deffa/plugins/search/duckduckgo.cjs +28 -0
  37. package/cjs/deffa/plugins/search/lahelu.cjs +28 -0
  38. package/cjs/deffa/plugins/search/mangatoon.cjs +28 -0
  39. package/cjs/deffa/plugins/search/mcpedl.cjs +28 -0
  40. package/cjs/deffa/plugins/search/myinstants.cjs +28 -0
  41. package/cjs/deffa/plugins/search/otakotaku.cjs +28 -0
  42. package/cjs/deffa/plugins/search/pinterest.cjs +30 -0
  43. package/cjs/deffa/plugins/search/resep.cjs +28 -0
  44. package/cjs/deffa/plugins/search/seegore.cjs +30 -0
  45. package/cjs/deffa/plugins/search/soundcloud.cjs +28 -0
  46. package/cjs/deffa/plugins/search/youtube.cjs +28 -0
  47. package/cjs/deffa/plugins/stalk/github.cjs +38 -0
  48. package/cjs/deffa/plugins/stalk/pinterest.cjs +37 -0
  49. package/cjs/deffa/plugins/stalk/threads.cjs +34 -0
  50. package/cjs/deffa/plugins/stalk/tiktok.cjs +37 -0
  51. package/cjs/deffa/plugins/stalk/twitter.cjs +37 -0
  52. package/cjs/deffa/plugins/stalk/youtube.cjs +37 -0
  53. package/cjs/lib/Defaults/index.cjs +158 -0
  54. package/cjs/lib/Discord/Client.cjs +263 -0
  55. package/cjs/lib/Discord/Constants.cjs +1842 -0
  56. package/cjs/lib/Discord/connect-dc.cjs +11 -0
  57. package/cjs/lib/Discord/esm-bridge.cjs +136 -0
  58. package/cjs/lib/Discord/gateway/Dispatcher.cjs +93 -0
  59. package/cjs/lib/Discord/gateway/Shard.cjs +695 -0
  60. package/cjs/lib/Discord/gateway/ShardManager.cjs +344 -0
  61. package/cjs/lib/Discord/gateway/compression/base.cjs +13 -0
  62. package/cjs/lib/Discord/gateway/compression/config.cjs +47 -0
  63. package/cjs/lib/Discord/gateway/compression/pako.cjs +44 -0
  64. package/cjs/lib/Discord/gateway/compression/zlib-native.cjs +47 -0
  65. package/cjs/lib/Discord/gateway/compression/zlib-sync.cjs +31 -0
  66. package/cjs/lib/Discord/gateway/compression/zstd-napi.cjs +80 -0
  67. package/cjs/lib/Discord/gateway/compression/zstd-native.cjs +46 -0
  68. package/cjs/lib/Discord/gateway/events.cjs +956 -0
  69. package/cjs/lib/Discord/index.cjs +238 -0
  70. package/cjs/lib/Discord/rest/Bucket.cjs +69 -0
  71. package/cjs/lib/Discord/rest/DiscordHTTPError.cjs +63 -0
  72. package/cjs/lib/Discord/rest/DiscordRESTError.cjs +84 -0
  73. package/cjs/lib/Discord/rest/OAuthHelper.cjs +226 -0
  74. package/cjs/lib/Discord/rest/RESTManager.cjs +116 -0
  75. package/cjs/lib/Discord/rest/RequestHandler.cjs +320 -0
  76. package/cjs/lib/Discord/rest/SequentialBucket.cjs +69 -0
  77. package/cjs/lib/Discord/routes/Applications.cjs +625 -0
  78. package/cjs/lib/Discord/routes/Channels.cjs +1199 -0
  79. package/cjs/lib/Discord/routes/Guilds.cjs +1792 -0
  80. package/cjs/lib/Discord/routes/Interactions.cjs +212 -0
  81. package/cjs/lib/Discord/routes/Lobbies.cjs +197 -0
  82. package/cjs/lib/Discord/routes/Miscellaneous.cjs +120 -0
  83. package/cjs/lib/Discord/routes/OAuth.cjs +350 -0
  84. package/cjs/lib/Discord/routes/Users.cjs +107 -0
  85. package/cjs/lib/Discord/routes/Webhooks.cjs +308 -0
  86. package/cjs/lib/Discord/structures/AnnouncementChannel.cjs +46 -0
  87. package/cjs/lib/Discord/structures/AnnouncementThreadChannel.cjs +28 -0
  88. package/cjs/lib/Discord/structures/Application.cjs +345 -0
  89. package/cjs/lib/Discord/structures/ApplicationCommand.cjs +109 -0
  90. package/cjs/lib/Discord/structures/Attachment.cjs +46 -0
  91. package/cjs/lib/Discord/structures/AuditLogEntry.cjs +41 -0
  92. package/cjs/lib/Discord/structures/AutoModerationRule.cjs +117 -0
  93. package/cjs/lib/Discord/structures/AutocompleteInteraction.cjs +90 -0
  94. package/cjs/lib/Discord/structures/Base.cjs +56 -0
  95. package/cjs/lib/Discord/structures/BaseEntitlement.cjs +40 -0
  96. package/cjs/lib/Discord/structures/CategoryChannel.cjs +102 -0
  97. package/cjs/lib/Discord/structures/Channel.cjs +89 -0
  98. package/cjs/lib/Discord/structures/ClientApplication.cjs +269 -0
  99. package/cjs/lib/Discord/structures/CommandInteraction.cjs +294 -0
  100. package/cjs/lib/Discord/structures/ComponentInteraction.cjs +306 -0
  101. package/cjs/lib/Discord/structures/Entitlement.cjs +24 -0
  102. package/cjs/lib/Discord/structures/ExtendedUser.cjs +48 -0
  103. package/cjs/lib/Discord/structures/ForumChannel.cjs +20 -0
  104. package/cjs/lib/Discord/structures/GroupChannel.cjs +160 -0
  105. package/cjs/lib/Discord/structures/Guild.cjs +1289 -0
  106. package/cjs/lib/Discord/structures/GuildChannel.cjs +82 -0
  107. package/cjs/lib/Discord/structures/GuildPreview.cjs +141 -0
  108. package/cjs/lib/Discord/structures/GuildScheduledEvent.cjs +166 -0
  109. package/cjs/lib/Discord/structures/GuildTemplate.cjs +96 -0
  110. package/cjs/lib/Discord/structures/Integration.cjs +123 -0
  111. package/cjs/lib/Discord/structures/Interaction.cjs +78 -0
  112. package/cjs/lib/Discord/structures/InteractionResolvedChannel.cjs +36 -0
  113. package/cjs/lib/Discord/structures/Invite.cjs +196 -0
  114. package/cjs/lib/Discord/structures/InviteGuild.cjs +117 -0
  115. package/cjs/lib/Discord/structures/InviteRole.cjs +88 -0
  116. package/cjs/lib/Discord/structures/Lobby.cjs +84 -0
  117. package/cjs/lib/Discord/structures/LobbyMember.cjs +30 -0
  118. package/cjs/lib/Discord/structures/MediaChannel.cjs +20 -0
  119. package/cjs/lib/Discord/structures/Member.cjs +300 -0
  120. package/cjs/lib/Discord/structures/Message.cjs +553 -0
  121. package/cjs/lib/Discord/structures/ModalSubmitInteraction.cjs +263 -0
  122. package/cjs/lib/Discord/structures/OAuthApplication.cjs +203 -0
  123. package/cjs/lib/Discord/structures/OAuthGuild.cjs +98 -0
  124. package/cjs/lib/Discord/structures/PartialApplication.cjs +97 -0
  125. package/cjs/lib/Discord/structures/Permission.cjs +61 -0
  126. package/cjs/lib/Discord/structures/PermissionOverwrite.cjs +46 -0
  127. package/cjs/lib/Discord/structures/PingInteraction.cjs +27 -0
  128. package/cjs/lib/Discord/structures/Poll.cjs +69 -0
  129. package/cjs/lib/Discord/structures/PrimaryGuild.cjs +93 -0
  130. package/cjs/lib/Discord/structures/PrivateChannel.cjs +131 -0
  131. package/cjs/lib/Discord/structures/PrivateThreadChannel.cjs +28 -0
  132. package/cjs/lib/Discord/structures/PublicThreadChannel.cjs +36 -0
  133. package/cjs/lib/Discord/structures/Role.cjs +126 -0
  134. package/cjs/lib/Discord/structures/SKU.cjs +58 -0
  135. package/cjs/lib/Discord/structures/Soundboard.cjs +58 -0
  136. package/cjs/lib/Discord/structures/StageChannel.cjs +45 -0
  137. package/cjs/lib/Discord/structures/StageInstance.cjs +80 -0
  138. package/cjs/lib/Discord/structures/Subscription.cjs +21 -0
  139. package/cjs/lib/Discord/structures/Team.cjs +70 -0
  140. package/cjs/lib/Discord/structures/TestEntitlement.cjs +22 -0
  141. package/cjs/lib/Discord/structures/TextChannel.cjs +48 -0
  142. package/cjs/lib/Discord/structures/TextableChannel.cjs +265 -0
  143. package/cjs/lib/Discord/structures/TextableVoiceChannel.cjs +70 -0
  144. package/cjs/lib/Discord/structures/ThreadChannel.cjs +276 -0
  145. package/cjs/lib/Discord/structures/ThreadOnlyChannel.cjs +205 -0
  146. package/cjs/lib/Discord/structures/ThreadableChannel.cjs +57 -0
  147. package/cjs/lib/Discord/structures/UnavailableGuild.cjs +21 -0
  148. package/cjs/lib/Discord/structures/User.cjs +223 -0
  149. package/cjs/lib/Discord/structures/VoiceChannel.cjs +34 -0
  150. package/cjs/lib/Discord/structures/VoiceState.cjs +113 -0
  151. package/cjs/lib/Discord/structures/Webhook.cjs +224 -0
  152. package/cjs/lib/Discord/util/Collection.cjs +77 -0
  153. package/cjs/lib/Discord/util/Errors.cjs +81 -0
  154. package/cjs/lib/Discord/util/QueryBuilder.cjs +20 -0
  155. package/cjs/lib/Discord/util/Routes.cjs +293 -0
  156. package/cjs/lib/Discord/util/SimpleCollection.cjs +78 -0
  157. package/cjs/lib/Discord/util/Time.cjs +92 -0
  158. package/cjs/lib/Discord/util/TypedCollection.cjs +78 -0
  159. package/cjs/lib/Discord/util/TypedEmitter.cjs +20 -0
  160. package/cjs/lib/Discord/util/Util.cjs +906 -0
  161. package/cjs/lib/Discord/util/interactions/InteractionOptionsWrapper.cjs +207 -0
  162. package/cjs/lib/Discord/util/interactions/MessageInteractionResponse.cjs +26 -0
  163. package/cjs/lib/Discord/util/interactions/ModalSubmitInteractionComponentsWrapper.cjs +98 -0
  164. package/cjs/lib/Discord/util/interactions/SelectMenuValuesWrapper.cjs +77 -0
  165. package/cjs/lib/Discord/util/interactions/shared.cjs +20 -0
  166. package/cjs/lib/Discord/util/warning.cjs +34 -0
  167. package/cjs/lib/Signal/Group/ciphertext-message.cjs +16 -0
  168. package/cjs/lib/Signal/Group/group-session-builder.cjs +67 -0
  169. package/cjs/lib/Signal/Group/group_cipher.cjs +86 -0
  170. package/cjs/lib/Signal/Group/index.cjs +58 -0
  171. package/cjs/lib/Signal/Group/keyhelper.cjs +56 -0
  172. package/cjs/lib/Signal/Group/sender-chain-key.cjs +30 -0
  173. package/cjs/lib/Signal/Group/sender-key-distribution-message.cjs +67 -0
  174. package/cjs/lib/Signal/Group/sender-key-message.cjs +70 -0
  175. package/cjs/lib/Signal/Group/sender-key-name.cjs +52 -0
  176. package/cjs/lib/Signal/Group/sender-key-record.cjs +45 -0
  177. package/cjs/lib/Signal/Group/sender-key-state.cjs +88 -0
  178. package/cjs/lib/Signal/Group/sender-message-key.cjs +30 -0
  179. package/cjs/lib/Signal/libsignal.cjs +467 -0
  180. package/cjs/lib/Signal/lid-mapping.cjs +281 -0
  181. package/cjs/lib/Socket/Client/index.cjs +19 -0
  182. package/cjs/lib/Socket/Client/types.cjs +15 -0
  183. package/cjs/lib/Socket/Client/websocket.cjs +61 -0
  184. package/cjs/lib/Socket/business.cjs +384 -0
  185. package/cjs/lib/Socket/chats.cjs +1221 -0
  186. package/cjs/lib/Socket/communities.cjs +440 -0
  187. package/cjs/lib/Socket/groups.cjs +353 -0
  188. package/cjs/lib/Socket/index.cjs +14 -0
  189. package/cjs/lib/Socket/messages-recv.cjs +1772 -0
  190. package/cjs/lib/Socket/messages-send.cjs +1376 -0
  191. package/cjs/lib/Socket/mex.cjs +46 -0
  192. package/cjs/lib/Socket/newsletter.cjs +230 -0
  193. package/cjs/lib/Socket/socket.cjs +976 -0
  194. package/cjs/lib/Store/index.cjs +20 -0
  195. package/cjs/lib/Store/make-in-memory-store.cjs +470 -0
  196. package/cjs/lib/Store/make-ordered-dictionary.cjs +82 -0
  197. package/cjs/lib/Store/object-repository.cjs +28 -0
  198. package/cjs/lib/Telegram/button.cjs +147 -0
  199. package/cjs/lib/Telegram/composer.cjs +582 -0
  200. package/cjs/lib/Telegram/context.cjs +853 -0
  201. package/cjs/lib/Telegram/core/helpers/args.cjs +57 -0
  202. package/cjs/lib/Telegram/core/helpers/check.cjs +55 -0
  203. package/cjs/lib/Telegram/core/helpers/compact.cjs +16 -0
  204. package/cjs/lib/Telegram/core/helpers/deunionize.cjs +12 -0
  205. package/cjs/lib/Telegram/core/helpers/formatting.cjs +91 -0
  206. package/cjs/lib/Telegram/core/helpers/util.cjs +50 -0
  207. package/cjs/lib/Telegram/core/network/client.cjs +338 -0
  208. package/cjs/lib/Telegram/core/network/error.cjs +21 -0
  209. package/cjs/lib/Telegram/core/network/multipart-stream.cjs +79 -0
  210. package/cjs/lib/Telegram/core/network/polling.cjs +87 -0
  211. package/cjs/lib/Telegram/core/network/webhook.cjs +54 -0
  212. package/cjs/lib/Telegram/core/types/typegram.cjs +31 -0
  213. package/cjs/lib/Telegram/deffa-telegraf.cjs +264 -0
  214. package/cjs/lib/Telegram/esm-bridge.cjs +20 -0
  215. package/cjs/lib/Telegram/filters.cjs +69 -0
  216. package/cjs/lib/Telegram/format.cjs +58 -0
  217. package/cjs/lib/Telegram/future.cjs +140 -0
  218. package/cjs/lib/Telegram/index.cjs +67 -0
  219. package/cjs/lib/Telegram/input.cjs +61 -0
  220. package/cjs/lib/Telegram/markup.cjs +129 -0
  221. package/cjs/lib/Telegram/middleware.cjs +2 -0
  222. package/cjs/lib/Telegram/reactions.cjs +84 -0
  223. package/cjs/lib/Telegram/router.cjs +46 -0
  224. package/cjs/lib/Telegram/scenes/base.cjs +39 -0
  225. package/cjs/lib/Telegram/scenes/context.cjs +104 -0
  226. package/cjs/lib/Telegram/scenes/index.cjs +21 -0
  227. package/cjs/lib/Telegram/scenes/stage.cjs +49 -0
  228. package/cjs/lib/Telegram/scenes/wizard/context.cjs +31 -0
  229. package/cjs/lib/Telegram/scenes/wizard/index.cjs +45 -0
  230. package/cjs/lib/Telegram/scenes.cjs +21 -0
  231. package/cjs/lib/Telegram/session.cjs +166 -0
  232. package/cjs/lib/Telegram/telegram-types.cjs +6 -0
  233. package/cjs/lib/Telegram/telegram.cjs +945 -0
  234. package/cjs/lib/Telegram/types.cjs +2 -0
  235. package/cjs/lib/Telegram/utils.cjs +5 -0
  236. package/cjs/lib/Types/Auth.cjs +3 -0
  237. package/cjs/lib/Types/Bussines.cjs +3 -0
  238. package/cjs/lib/Types/Call.cjs +3 -0
  239. package/cjs/lib/Types/Chat.cjs +11 -0
  240. package/cjs/lib/Types/Contact.cjs +3 -0
  241. package/cjs/lib/Types/Events.cjs +4 -0
  242. package/cjs/lib/Types/GroupMetadata.cjs +3 -0
  243. package/cjs/lib/Types/Label.cjs +26 -0
  244. package/cjs/lib/Types/LabelAssociation.cjs +8 -0
  245. package/cjs/lib/Types/Message.cjs +19 -0
  246. package/cjs/lib/Types/Mex.cjs +40 -0
  247. package/cjs/lib/Types/Product.cjs +3 -0
  248. package/cjs/lib/Types/RichType.cjs +24 -0
  249. package/cjs/lib/Types/Signal.cjs +4 -0
  250. package/cjs/lib/Types/Socket.cjs +4 -0
  251. package/cjs/lib/Types/State.cjs +54 -0
  252. package/cjs/lib/Types/USync.cjs +4 -0
  253. package/cjs/lib/Types/index.cjs +42 -0
  254. package/cjs/lib/Utils/auth-utils.cjs +312 -0
  255. package/cjs/lib/Utils/browser-utils.cjs +39 -0
  256. package/cjs/lib/Utils/business.cjs +241 -0
  257. package/cjs/lib/Utils/chat-utils.cjs +890 -0
  258. package/cjs/lib/Utils/companion-reg-client-utils.cjs +51 -0
  259. package/cjs/lib/Utils/crypto.cjs +170 -0
  260. package/cjs/lib/Utils/decode-wa-message.cjs +330 -0
  261. package/cjs/lib/Utils/event-buffer.cjs +629 -0
  262. package/cjs/lib/Utils/generics.cjs +427 -0
  263. package/cjs/lib/Utils/history.cjs +141 -0
  264. package/cjs/lib/Utils/identity-change-handler.cjs +56 -0
  265. package/cjs/lib/Utils/index.cjs +43 -0
  266. package/cjs/lib/Utils/link-preview.cjs +122 -0
  267. package/cjs/lib/Utils/logger.cjs +8 -0
  268. package/cjs/lib/Utils/lt-hash.cjs +11 -0
  269. package/cjs/lib/Utils/make-mutex.cjs +38 -0
  270. package/cjs/lib/Utils/message-retry-manager.cjs +267 -0
  271. package/cjs/lib/Utils/messages-media.cjs +906 -0
  272. package/cjs/lib/Utils/messages.cjs +1909 -0
  273. package/cjs/lib/Utils/noise-handler.cjs +205 -0
  274. package/cjs/lib/Utils/offline-node-processor.cjs +43 -0
  275. package/cjs/lib/Utils/pre-key-manager.cjs +113 -0
  276. package/cjs/lib/Utils/process-message.cjs +755 -0
  277. package/cjs/lib/Utils/reporting-utils.cjs +263 -0
  278. package/cjs/lib/Utils/rich-message-utils.cjs +434 -0
  279. package/cjs/lib/Utils/session-guard.cjs +163 -0
  280. package/cjs/lib/Utils/signal.cjs +214 -0
  281. package/cjs/lib/Utils/stanza-ack.cjs +41 -0
  282. package/cjs/lib/Utils/sync-action-utils.cjs +54 -0
  283. package/cjs/lib/Utils/tc-token-utils.cjs +174 -0
  284. package/cjs/lib/Utils/text-sticker.cjs +174 -0
  285. package/cjs/lib/Utils/use-multi-file-auth-state.cjs +125 -0
  286. package/cjs/lib/Utils/use-single-file-auth-state.cjs +113 -0
  287. package/cjs/lib/Utils/use-sqlite-auth-state.cjs +145 -0
  288. package/cjs/lib/Utils/validate-connection.cjs +210 -0
  289. package/cjs/lib/WABinary/constants.cjs +1470 -0
  290. package/cjs/lib/WABinary/decode.cjs +301 -0
  291. package/cjs/lib/WABinary/encode.cjs +257 -0
  292. package/cjs/lib/WABinary/generic-utils.cjs +240 -0
  293. package/cjs/lib/WABinary/index.cjs +22 -0
  294. package/cjs/lib/WABinary/jid-utils.cjs +114 -0
  295. package/cjs/lib/WABinary/types.cjs +37 -0
  296. package/cjs/lib/WAM/BinaryInfo.cjs +14 -0
  297. package/cjs/lib/WAM/constants.cjs +22856 -0
  298. package/cjs/lib/WAM/encode.cjs +154 -0
  299. package/cjs/lib/WAM/index.cjs +20 -0
  300. package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.cjs +56 -0
  301. package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.cjs +58 -0
  302. package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.cjs +31 -0
  303. package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.cjs +42 -0
  304. package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.cjs +29 -0
  305. package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.cjs +55 -0
  306. package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.cjs +33 -0
  307. package/cjs/lib/WAUSync/Protocols/index.cjs +22 -0
  308. package/cjs/lib/WAUSync/USyncQuery.cjs +102 -0
  309. package/cjs/lib/WAUSync/USyncUser.cjs +35 -0
  310. package/cjs/lib/WAUSync/index.cjs +20 -0
  311. package/cjs/lib/index.cjs +372 -0
  312. package/cjs/lib/plugins/loader.cjs +117 -0
  313. package/lib/Defaults/index.js +1 -1
  314. package/package.json +11 -6
@@ -0,0 +1,629 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.makeEventBuffer = void 0;
7
+ const events_1 = __importDefault(require("events"));
8
+ const index_js_1 = require("../Types/index.cjs");
9
+ const generics_js_1 = require("./generics.cjs");
10
+ const messages_js_1 = require("./messages.cjs");
11
+ const process_message_js_1 = require("./process-message.cjs");
12
+ const BUFFERABLE_EVENT = [
13
+ 'messaging-history.set',
14
+ 'chats.upsert',
15
+ 'chats.update',
16
+ 'chats.delete',
17
+ 'contacts.upsert',
18
+ 'contacts.update',
19
+ 'messages.upsert',
20
+ 'messages.update',
21
+ 'messages.delete',
22
+ 'messages.reaction',
23
+ 'message-receipt.update',
24
+ 'groups.update'
25
+ ];
26
+ const BUFFERABLE_EVENT_SET = new Set(BUFFERABLE_EVENT);
27
+ /**
28
+ * The event buffer logically consolidates different events into a single event
29
+ * making the data processing more efficient.
30
+ */
31
+ const makeEventBuffer = (logger) => {
32
+ const ev = new events_1.default();
33
+ const historyCache = new Set();
34
+ let data = makeBufferData();
35
+ let isBuffering = false;
36
+ let bufferTimeout = null;
37
+ let flushPendingTimeout = null; // Add a specific timer for the debounced flush to prevent leak
38
+ let bufferCount = 0;
39
+ const MAX_HISTORY_CACHE_SIZE = 10000; // Limit the history cache size to prevent memory bloat
40
+ const BUFFER_TIMEOUT_MS = 30000; // 30 seconds
41
+ // take the generic event and fire it as a baileys event
42
+ ev.on('event', (map) => {
43
+ for (const event in map) {
44
+ ev.emit(event, map[event]);
45
+ }
46
+ });
47
+ function buffer() {
48
+ if (!isBuffering) {
49
+ logger.debug('Event buffer activated');
50
+ isBuffering = true;
51
+ bufferCount = 0;
52
+ if (bufferTimeout) {
53
+ clearTimeout(bufferTimeout);
54
+ }
55
+ bufferTimeout = setTimeout(() => {
56
+ if (isBuffering) {
57
+ logger.warn('Buffer timeout reached, auto-flushing');
58
+ flush();
59
+ }
60
+ }, BUFFER_TIMEOUT_MS);
61
+ }
62
+ // Always increment count when requested
63
+ bufferCount++;
64
+ }
65
+ function flush() {
66
+ if (!isBuffering) {
67
+ return false;
68
+ }
69
+ logger.debug({ bufferCount }, 'Flushing event buffer');
70
+ isBuffering = false;
71
+ bufferCount = 0;
72
+ // Clear timeout
73
+ if (bufferTimeout) {
74
+ clearTimeout(bufferTimeout);
75
+ bufferTimeout = null;
76
+ }
77
+ if (flushPendingTimeout) {
78
+ clearTimeout(flushPendingTimeout);
79
+ flushPendingTimeout = null;
80
+ }
81
+ // Clear history cache if it exceeds the max size
82
+ if (historyCache.size > MAX_HISTORY_CACHE_SIZE) {
83
+ logger.debug({ cacheSize: historyCache.size }, 'Clearing history cache');
84
+ historyCache.clear();
85
+ }
86
+ const newData = makeBufferData();
87
+ const chatUpdates = Object.values(data.chatUpdates);
88
+ let conditionalChatUpdatesLeft = 0;
89
+ for (const update of chatUpdates) {
90
+ if (update.conditional) {
91
+ conditionalChatUpdatesLeft += 1;
92
+ newData.chatUpdates[update.id] = update;
93
+ delete data.chatUpdates[update.id];
94
+ }
95
+ }
96
+ const consolidatedData = consolidateEvents(data);
97
+ if (Object.keys(consolidatedData).length) {
98
+ ev.emit('event', consolidatedData);
99
+ }
100
+ data = newData;
101
+ logger.trace({ conditionalChatUpdatesLeft }, 'released buffered events');
102
+ return true;
103
+ }
104
+ return {
105
+ process(handler) {
106
+ const listener = async (map) => {
107
+ await handler(map);
108
+ };
109
+ ev.on('event', listener);
110
+ return () => {
111
+ ev.off('event', listener);
112
+ };
113
+ },
114
+ emit(event, evData) {
115
+ // Check if this is a messages.upsert with a different type than what's buffered
116
+ // If so, flush the buffered messages first to avoid type overshadowing
117
+ if (event === 'messages.upsert') {
118
+ const { type } = evData;
119
+ const existingUpserts = Object.values(data.messageUpserts);
120
+ if (existingUpserts.length > 0) {
121
+ const bufferedType = existingUpserts[0].type;
122
+ if (bufferedType !== type) {
123
+ logger.debug({ bufferedType, newType: type }, 'messages.upsert type mismatch, emitting buffered messages');
124
+ // Emit the buffered messages with their correct type
125
+ ev.emit('event', {
126
+ 'messages.upsert': {
127
+ messages: existingUpserts.map(m => m.message),
128
+ type: bufferedType
129
+ }
130
+ });
131
+ // Clear the message upserts from the buffer
132
+ data.messageUpserts = {};
133
+ }
134
+ }
135
+ }
136
+ if (isBuffering && BUFFERABLE_EVENT_SET.has(event)) {
137
+ append(data, historyCache, event, evData, logger);
138
+ return true;
139
+ }
140
+ return ev.emit('event', { [event]: evData });
141
+ },
142
+ isBuffering() {
143
+ return isBuffering;
144
+ },
145
+ buffer,
146
+ flush,
147
+ createBufferedFunction(work) {
148
+ return async (...args) => {
149
+ buffer();
150
+ try {
151
+ const result = await work(...args);
152
+ // If this is the only buffer, flush after a small delay
153
+ if (bufferCount === 1) {
154
+ setTimeout(() => {
155
+ if (isBuffering && bufferCount === 1) {
156
+ flush();
157
+ }
158
+ }, 100); // Small delay to allow nested buffers
159
+ }
160
+ return result;
161
+ }
162
+ catch (error) {
163
+ throw error;
164
+ }
165
+ finally {
166
+ bufferCount = Math.max(0, bufferCount - 1);
167
+ if (bufferCount === 0) {
168
+ // Only schedule ONE timeout, not 10,000
169
+ if (!flushPendingTimeout) {
170
+ flushPendingTimeout = setTimeout(flush, 100);
171
+ }
172
+ }
173
+ }
174
+ };
175
+ },
176
+ on: (...args) => ev.on(...args),
177
+ off: (...args) => ev.off(...args),
178
+ removeAllListeners: (...args) => ev.removeAllListeners(...args),
179
+ destroy() {
180
+ // Clear buffer timeout
181
+ if (bufferTimeout) {
182
+ clearTimeout(bufferTimeout);
183
+ bufferTimeout = null;
184
+ }
185
+ if (flushPendingTimeout) {
186
+ clearTimeout(flushPendingTimeout);
187
+ flushPendingTimeout = null;
188
+ }
189
+ // Clear history cache
190
+ historyCache.clear();
191
+ // Reset buffer data
192
+ data = makeBufferData();
193
+ isBuffering = false;
194
+ bufferCount = 0;
195
+ // Remove all listeners
196
+ ev.removeAllListeners();
197
+ logger.debug('Event buffer destroyed');
198
+ }
199
+ };
200
+ };
201
+ exports.makeEventBuffer = makeEventBuffer;
202
+ const makeBufferData = () => {
203
+ return {
204
+ historySets: {
205
+ chats: {},
206
+ messages: {},
207
+ contacts: {},
208
+ isLatest: false,
209
+ empty: true
210
+ },
211
+ chatUpserts: {},
212
+ chatUpdates: {},
213
+ chatDeletes: new Set(),
214
+ contactUpserts: {},
215
+ contactUpdates: {},
216
+ messageUpserts: {},
217
+ messageUpdates: {},
218
+ messageReactions: {},
219
+ messageDeletes: {},
220
+ messageReceipts: {},
221
+ groupUpdates: {}
222
+ };
223
+ };
224
+ function append(data, historyCache, event,
225
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
226
+ eventData, logger) {
227
+ switch (event) {
228
+ case 'messaging-history.set':
229
+ for (const chat of eventData.chats) {
230
+ const id = chat.id || '';
231
+ const existingChat = data.historySets.chats[id];
232
+ if (existingChat) {
233
+ existingChat.endOfHistoryTransferType = chat.endOfHistoryTransferType;
234
+ }
235
+ if (!existingChat && !historyCache.has(id)) {
236
+ data.historySets.chats[id] = chat;
237
+ historyCache.add(id);
238
+ absorbingChatUpdate(chat);
239
+ }
240
+ }
241
+ for (const contact of eventData.contacts) {
242
+ const existingContact = data.historySets.contacts[contact.id];
243
+ if (existingContact) {
244
+ Object.assign(existingContact, (0, generics_js_1.trimUndefined)(contact));
245
+ }
246
+ else {
247
+ const historyContactId = `c:${contact.id}`;
248
+ const hasAnyName = contact.notify || contact.name || contact.verifiedName;
249
+ if (!historyCache.has(historyContactId) || hasAnyName) {
250
+ data.historySets.contacts[contact.id] = contact;
251
+ historyCache.add(historyContactId);
252
+ }
253
+ }
254
+ }
255
+ for (const message of eventData.messages) {
256
+ const key = stringifyMessageKey(message.key);
257
+ const existingMsg = data.historySets.messages[key];
258
+ if (!existingMsg && !historyCache.has(key)) {
259
+ data.historySets.messages[key] = message;
260
+ historyCache.add(key);
261
+ }
262
+ }
263
+ data.historySets.empty = false;
264
+ data.historySets.syncType = eventData.syncType;
265
+ if (eventData.pastParticipants?.length) {
266
+ const merged = new Map();
267
+ const sigOf = (p) => `${p.userJid || ''}:${p.leaveTs || ''}:${p.leaveReason || ''}`;
268
+ const ingest = (entry) => {
269
+ const key = entry.groupJid ?? JSON.stringify(entry);
270
+ const existing = merged.get(key);
271
+ if (!existing) {
272
+ merged.set(key, { ...entry, pastParticipants: [...(entry.pastParticipants || [])] });
273
+ return;
274
+ }
275
+ const seen = new Set((existing.pastParticipants || []).map(sigOf));
276
+ for (const p of entry.pastParticipants || []) {
277
+ const sig = sigOf(p);
278
+ if (!seen.has(sig)) {
279
+ existing.pastParticipants.push(p);
280
+ seen.add(sig);
281
+ }
282
+ }
283
+ };
284
+ for (const entry of data.historySets.pastParticipants || [])
285
+ ingest(entry);
286
+ for (const entry of eventData.pastParticipants)
287
+ ingest(entry);
288
+ data.historySets.pastParticipants = [...merged.values()];
289
+ }
290
+ data.historySets.progress = eventData.progress;
291
+ data.historySets.chunkOrder = eventData.chunkOrder;
292
+ data.historySets.peerDataRequestSessionId = eventData.peerDataRequestSessionId;
293
+ data.historySets.isLatest = eventData.isLatest || data.historySets.isLatest;
294
+ break;
295
+ case 'chats.upsert':
296
+ for (const chat of eventData) {
297
+ const id = chat.id || '';
298
+ let upsert = data.chatUpserts[id];
299
+ if (id && !upsert) {
300
+ upsert = data.historySets.chats[id];
301
+ if (upsert) {
302
+ logger.debug({ chatId: id }, 'absorbed chat upsert in chat set');
303
+ }
304
+ }
305
+ if (upsert) {
306
+ upsert = concatChats(upsert, chat);
307
+ }
308
+ else {
309
+ upsert = chat;
310
+ data.chatUpserts[id] = upsert;
311
+ }
312
+ absorbingChatUpdate(upsert);
313
+ if (data.chatDeletes.has(id)) {
314
+ data.chatDeletes.delete(id);
315
+ }
316
+ }
317
+ break;
318
+ case 'chats.update':
319
+ for (const update of eventData) {
320
+ const chatId = update.id;
321
+ const conditionMatches = update.conditional ? update.conditional(data) : true;
322
+ if (conditionMatches) {
323
+ delete update.conditional;
324
+ // if there is an existing upsert, merge the update into it
325
+ const upsert = data.historySets.chats[chatId] || data.chatUpserts[chatId];
326
+ if (upsert) {
327
+ concatChats(upsert, update);
328
+ }
329
+ else {
330
+ // merge the update into the existing update
331
+ const chatUpdate = data.chatUpdates[chatId] || {};
332
+ data.chatUpdates[chatId] = concatChats(chatUpdate, update);
333
+ }
334
+ }
335
+ else if (conditionMatches === undefined) {
336
+ // condition yet to be fulfilled
337
+ data.chatUpdates[chatId] = update;
338
+ }
339
+ // otherwise -- condition not met, update is invalid
340
+ // if the chat has been updated
341
+ // ignore any existing chat delete
342
+ if (data.chatDeletes.has(chatId)) {
343
+ data.chatDeletes.delete(chatId);
344
+ }
345
+ }
346
+ break;
347
+ case 'chats.delete':
348
+ for (const chatId of eventData) {
349
+ if (!data.chatDeletes.has(chatId)) {
350
+ data.chatDeletes.add(chatId);
351
+ }
352
+ // remove any prior updates & upserts
353
+ if (data.chatUpdates[chatId]) {
354
+ delete data.chatUpdates[chatId];
355
+ }
356
+ if (data.chatUpserts[chatId]) {
357
+ delete data.chatUpserts[chatId];
358
+ }
359
+ if (data.historySets.chats[chatId]) {
360
+ delete data.historySets.chats[chatId];
361
+ }
362
+ }
363
+ break;
364
+ case 'contacts.upsert':
365
+ for (const contact of eventData) {
366
+ let upsert = data.contactUpserts[contact.id];
367
+ if (!upsert) {
368
+ upsert = data.historySets.contacts[contact.id];
369
+ if (upsert) {
370
+ logger.debug({ contactId: contact.id }, 'absorbed contact upsert in contact set');
371
+ }
372
+ }
373
+ if (upsert) {
374
+ upsert = Object.assign(upsert, (0, generics_js_1.trimUndefined)(contact));
375
+ }
376
+ else {
377
+ upsert = contact;
378
+ data.contactUpserts[contact.id] = upsert;
379
+ }
380
+ if (data.contactUpdates[contact.id]) {
381
+ upsert = Object.assign(data.contactUpdates[contact.id], (0, generics_js_1.trimUndefined)(contact));
382
+ delete data.contactUpdates[contact.id];
383
+ }
384
+ }
385
+ break;
386
+ case 'contacts.update':
387
+ const contactUpdates = eventData;
388
+ for (const update of contactUpdates) {
389
+ const id = update.id;
390
+ // merge into prior upsert
391
+ const upsert = data.historySets.contacts[id] || data.contactUpserts[id];
392
+ if (upsert) {
393
+ Object.assign(upsert, update);
394
+ }
395
+ else {
396
+ // merge into prior update
397
+ const contactUpdate = data.contactUpdates[id] || {};
398
+ data.contactUpdates[id] = Object.assign(contactUpdate, update);
399
+ }
400
+ }
401
+ break;
402
+ case 'messages.upsert':
403
+ const { messages, type } = eventData;
404
+ for (const message of messages) {
405
+ const key = stringifyMessageKey(message.key);
406
+ let existing = data.messageUpserts[key]?.message;
407
+ if (!existing) {
408
+ existing = data.historySets.messages[key];
409
+ if (existing) {
410
+ logger.debug({ messageId: key }, 'absorbed message upsert in message set');
411
+ }
412
+ }
413
+ if (existing) {
414
+ message.messageTimestamp = existing.messageTimestamp;
415
+ }
416
+ if (data.messageUpdates[key]) {
417
+ logger.debug('absorbed prior message update in message upsert');
418
+ Object.assign(message, data.messageUpdates[key].update);
419
+ delete data.messageUpdates[key];
420
+ }
421
+ if (data.historySets.messages[key]) {
422
+ data.historySets.messages[key] = message;
423
+ }
424
+ else {
425
+ data.messageUpserts[key] = {
426
+ message,
427
+ type: type === 'notify' || data.messageUpserts[key]?.type === 'notify' ? 'notify' : type
428
+ };
429
+ }
430
+ }
431
+ break;
432
+ case 'messages.update':
433
+ const msgUpdates = eventData;
434
+ for (const { key, update } of msgUpdates) {
435
+ const keyStr = stringifyMessageKey(key);
436
+ const existing = data.historySets.messages[keyStr] || data.messageUpserts[keyStr]?.message;
437
+ if (existing) {
438
+ Object.assign(existing, update);
439
+ // if the message was received & read by us
440
+ // the chat counter must have been incremented
441
+ // so we need to decrement it
442
+ if (update.status === index_js_1.WAMessageStatus.READ && !key.fromMe) {
443
+ decrementChatReadCounterIfMsgDidUnread(existing);
444
+ }
445
+ }
446
+ else {
447
+ const msgUpdate = data.messageUpdates[keyStr] || { key, update: {} };
448
+ Object.assign(msgUpdate.update, update);
449
+ data.messageUpdates[keyStr] = msgUpdate;
450
+ }
451
+ }
452
+ break;
453
+ case 'messages.delete':
454
+ const deleteData = eventData;
455
+ if ('keys' in deleteData) {
456
+ const { keys } = deleteData;
457
+ for (const key of keys) {
458
+ const keyStr = stringifyMessageKey(key);
459
+ if (!data.messageDeletes[keyStr]) {
460
+ data.messageDeletes[keyStr] = key;
461
+ }
462
+ if (data.messageUpserts[keyStr]) {
463
+ delete data.messageUpserts[keyStr];
464
+ }
465
+ if (data.messageUpdates[keyStr]) {
466
+ delete data.messageUpdates[keyStr];
467
+ }
468
+ }
469
+ }
470
+ else {
471
+ // TODO: add support
472
+ }
473
+ break;
474
+ case 'messages.reaction':
475
+ const reactions = eventData;
476
+ for (const { key, reaction } of reactions) {
477
+ const keyStr = stringifyMessageKey(key);
478
+ const existing = data.messageUpserts[keyStr];
479
+ if (existing) {
480
+ (0, messages_js_1.updateMessageWithReaction)(existing.message, reaction);
481
+ }
482
+ else {
483
+ data.messageReactions[keyStr] = data.messageReactions[keyStr] || { key, reactions: [] };
484
+ (0, messages_js_1.updateMessageWithReaction)(data.messageReactions[keyStr], reaction);
485
+ }
486
+ }
487
+ break;
488
+ case 'message-receipt.update':
489
+ const receipts = eventData;
490
+ for (const { key, receipt } of receipts) {
491
+ const keyStr = stringifyMessageKey(key);
492
+ const existing = data.messageUpserts[keyStr];
493
+ if (existing) {
494
+ (0, messages_js_1.updateMessageWithReceipt)(existing.message, receipt);
495
+ }
496
+ else {
497
+ data.messageReceipts[keyStr] = data.messageReceipts[keyStr] || { key, userReceipt: [] };
498
+ (0, messages_js_1.updateMessageWithReceipt)(data.messageReceipts[keyStr], receipt);
499
+ }
500
+ }
501
+ break;
502
+ case 'groups.update':
503
+ const groupUpdates = eventData;
504
+ for (const update of groupUpdates) {
505
+ const id = update.id;
506
+ const groupUpdate = data.groupUpdates[id] || {};
507
+ if (!data.groupUpdates[id]) {
508
+ data.groupUpdates[id] = Object.assign(groupUpdate, update);
509
+ }
510
+ }
511
+ break;
512
+ default:
513
+ throw new Error(`"${event}" cannot be buffered`);
514
+ }
515
+ function absorbingChatUpdate(existing) {
516
+ const chatId = existing.id || '';
517
+ const update = data.chatUpdates[chatId];
518
+ if (update) {
519
+ const conditionMatches = update.conditional ? update.conditional(data) : true;
520
+ if (conditionMatches) {
521
+ delete update.conditional;
522
+ logger.debug({ chatId }, 'absorbed chat update in existing chat');
523
+ Object.assign(existing, concatChats(update, existing));
524
+ delete data.chatUpdates[chatId];
525
+ }
526
+ else if (conditionMatches === false) {
527
+ logger.debug({ chatId }, 'chat update condition fail, removing');
528
+ delete data.chatUpdates[chatId];
529
+ }
530
+ }
531
+ }
532
+ function decrementChatReadCounterIfMsgDidUnread(message) {
533
+ // decrement chat unread counter
534
+ // if the message has already been marked read by us
535
+ const chatId = message.key.remoteJid;
536
+ const chat = data.chatUpdates[chatId] || data.chatUpserts[chatId];
537
+ if ((0, process_message_js_1.isRealMessage)(message) &&
538
+ (0, process_message_js_1.shouldIncrementChatUnread)(message) &&
539
+ typeof chat?.unreadCount === 'number' &&
540
+ chat.unreadCount > 0) {
541
+ logger.debug({ chatId: chat.id }, 'decrementing chat counter');
542
+ chat.unreadCount -= 1;
543
+ if (chat.unreadCount === 0) {
544
+ delete chat.unreadCount;
545
+ }
546
+ }
547
+ }
548
+ }
549
+ function consolidateEvents(data) {
550
+ const map = {};
551
+ if (!data.historySets.empty) {
552
+ map['messaging-history.set'] = {
553
+ chats: Object.values(data.historySets.chats),
554
+ messages: Object.values(data.historySets.messages),
555
+ contacts: Object.values(data.historySets.contacts),
556
+ pastParticipants: data.historySets.pastParticipants,
557
+ syncType: data.historySets.syncType,
558
+ progress: data.historySets.progress,
559
+ isLatest: data.historySets.isLatest,
560
+ chunkOrder: data.historySets.chunkOrder,
561
+ peerDataRequestSessionId: data.historySets.peerDataRequestSessionId
562
+ };
563
+ }
564
+ const chatUpsertList = Object.values(data.chatUpserts);
565
+ if (chatUpsertList.length) {
566
+ map['chats.upsert'] = chatUpsertList;
567
+ }
568
+ const chatUpdateList = Object.values(data.chatUpdates);
569
+ if (chatUpdateList.length) {
570
+ map['chats.update'] = chatUpdateList;
571
+ }
572
+ const chatDeleteList = Array.from(data.chatDeletes);
573
+ if (chatDeleteList.length) {
574
+ map['chats.delete'] = chatDeleteList;
575
+ }
576
+ const messageUpsertList = Object.values(data.messageUpserts);
577
+ if (messageUpsertList.length) {
578
+ const type = messageUpsertList[0].type;
579
+ map['messages.upsert'] = {
580
+ messages: messageUpsertList.map(m => m.message),
581
+ type
582
+ };
583
+ }
584
+ const messageUpdateList = Object.values(data.messageUpdates);
585
+ if (messageUpdateList.length) {
586
+ map['messages.update'] = messageUpdateList;
587
+ }
588
+ const messageDeleteList = Object.values(data.messageDeletes);
589
+ if (messageDeleteList.length) {
590
+ map['messages.delete'] = { keys: messageDeleteList };
591
+ }
592
+ const messageReactionList = Object.values(data.messageReactions).flatMap(({ key, reactions }) => reactions.flatMap(reaction => ({ key, reaction })));
593
+ if (messageReactionList.length) {
594
+ map['messages.reaction'] = messageReactionList;
595
+ }
596
+ const messageReceiptList = Object.values(data.messageReceipts).flatMap(({ key, userReceipt }) => userReceipt.flatMap(receipt => ({ key, receipt })));
597
+ if (messageReceiptList.length) {
598
+ map['message-receipt.update'] = messageReceiptList;
599
+ }
600
+ const contactUpsertList = Object.values(data.contactUpserts);
601
+ if (contactUpsertList.length) {
602
+ map['contacts.upsert'] = contactUpsertList;
603
+ }
604
+ const contactUpdateList = Object.values(data.contactUpdates);
605
+ if (contactUpdateList.length) {
606
+ map['contacts.update'] = contactUpdateList;
607
+ }
608
+ const groupUpdateList = Object.values(data.groupUpdates);
609
+ if (groupUpdateList.length) {
610
+ map['groups.update'] = groupUpdateList;
611
+ }
612
+ return map;
613
+ }
614
+ function concatChats(a, b) {
615
+ if (b.unreadCount === null && // neutralize unread counter
616
+ a.unreadCount < 0) {
617
+ a.unreadCount = undefined;
618
+ b.unreadCount = undefined;
619
+ }
620
+ if (typeof a.unreadCount === 'number' && typeof b.unreadCount === 'number') {
621
+ b = { ...b };
622
+ if (b.unreadCount >= 0) {
623
+ b.unreadCount = Math.max(b.unreadCount, 0) + Math.max(a.unreadCount, 0);
624
+ }
625
+ }
626
+ return Object.assign(a, b);
627
+ }
628
+ const stringifyMessageKey = (key) => `${key.remoteJid},${key.id},${key.fromMe ? '1' : '0'}`;
629
+ //# sourceMappingURL=event-buffer.js.map