@mtkruto/node 0.67.1 → 0.68.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 (355) hide show
  1. package/esm/0_errors.js +2 -6
  2. package/esm/3_errors.js +2 -12
  3. package/esm/3_transport.d.ts +3 -3
  4. package/esm/3_transport.js +3 -3
  5. package/esm/3_types.d.ts +8 -7
  6. package/esm/3_types.d.ts.map +1 -1
  7. package/esm/3_types.js +8 -7
  8. package/esm/4_errors.js +2 -12
  9. package/esm/_dnt.polyfills.d.ts +99 -0
  10. package/esm/_dnt.polyfills.d.ts.map +1 -1
  11. package/esm/_dnt.polyfills.js +127 -1
  12. package/esm/_dnt.test_polyfills.d.ts.map +1 -0
  13. package/esm/client/0_filters_test.d.ts.map +1 -1
  14. package/esm/client/0_markdown_test.d.ts.map +1 -1
  15. package/esm/client/0_params.d.ts +2 -0
  16. package/esm/client/0_params.d.ts.map +1 -1
  17. package/esm/client/0_password.d.ts +5 -5
  18. package/esm/client/0_password.d.ts.map +1 -1
  19. package/esm/client/0_password_test.d.ts.map +1 -1
  20. package/esm/client/0_storage_operations.js +143 -155
  21. package/esm/client/0_storage_operations_test.d.ts.map +1 -1
  22. package/esm/client/0_utilities.d.ts +1 -1
  23. package/esm/client/0_utilities_test.d.ts.map +1 -1
  24. package/esm/client/1_client_plain.js +4 -22
  25. package/esm/client/1_composer.js +8 -21
  26. package/esm/client/2_account_manager.js +85 -97
  27. package/esm/client/2_bot_info_manager.js +26 -38
  28. package/esm/client/2_business_connection_manager.js +10 -23
  29. package/esm/client/2_client_encrypted.js +194 -211
  30. package/esm/client/2_file_manager.d.ts +4 -3
  31. package/esm/client/2_file_manager.d.ts.map +1 -1
  32. package/esm/client/2_file_manager.js +268 -224
  33. package/esm/client/2_file_manager_test.d.ts.map +1 -1
  34. package/esm/client/2_network_statistics_manager.js +8 -21
  35. package/esm/client/2_payment_manager.js +7 -20
  36. package/esm/client/2_reaction_manager.js +7 -20
  37. package/esm/client/2_translations_manager.js +97 -107
  38. package/esm/client/2_update_manager.js +764 -759
  39. package/esm/client/3_client_encrypted_pool.js +10 -26
  40. package/esm/client/3_client_encrypted_pool_test.d.ts.map +1 -1
  41. package/esm/client/3_message_manager.d.ts +1 -1
  42. package/esm/client/3_message_manager.js +441 -448
  43. package/esm/client/3_message_manager_test.d.ts.map +1 -1
  44. package/esm/client/3_video_chat_manager.d.ts +1 -1
  45. package/esm/client/3_video_chat_manager.js +57 -68
  46. package/esm/client/4_callback_query_manager.js +18 -30
  47. package/esm/client/4_chat_list_manager.js +322 -318
  48. package/esm/client/4_chat_manager.js +118 -131
  49. package/esm/client/4_forum_manager.js +67 -73
  50. package/esm/client/4_gift_manager.js +16 -29
  51. package/esm/client/4_inline_query_manager.js +16 -28
  52. package/esm/client/4_link_preview_manager.js +6 -19
  53. package/esm/client/4_poll_manager.js +44 -57
  54. package/esm/client/4_story_manager.js +41 -53
  55. package/esm/client/5_client.d.ts +7 -0
  56. package/esm/client/5_client.d.ts.map +1 -1
  57. package/esm/client/5_client.js +1271 -1290
  58. package/esm/connection/1_connection_tcp.node.js +48 -65
  59. package/esm/connection/1_connection_web_socket.js +75 -91
  60. package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  61. package/esm/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
  62. package/esm/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
  63. package/esm/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
  64. package/esm/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
  65. package/esm/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
  66. package/esm/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
  67. package/esm/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
  68. package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
  69. package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
  70. package/esm/deps/jsr.io/@std/internal/1.0.10/format.js +70 -0
  71. package/esm/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
  72. package/esm/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
  73. package/esm/mod.js +2 -12
  74. package/esm/session/0_session_state.js +12 -38
  75. package/esm/session/1_session.js +49 -72
  76. package/esm/session/2_session_encrypted.js +324 -320
  77. package/esm/storage/1_utilities_test.d.ts.map +1 -1
  78. package/esm/storage/2_storage_indexed_db.js +26 -44
  79. package/esm/storage/2_storage_local_storage.node.js +12 -25
  80. package/esm/storage/2_storage_memory.js +24 -41
  81. package/esm/storage/2_storage_session_storage.js +3 -16
  82. package/esm/tl/0_utilities_test.d.ts.map +1 -1
  83. package/esm/tl/1_tl_reader.js +80 -88
  84. package/esm/tl/1_tl_reader_test.d.ts.map +1 -1
  85. package/esm/tl/1_tl_writer.js +155 -164
  86. package/esm/tl/1_tl_writer_test.d.ts.map +1 -1
  87. package/esm/tl/2_telegram.d.ts +9 -10
  88. package/esm/tl/2_telegram.d.ts.map +1 -1
  89. package/esm/tl/2_telegram.js +10 -10
  90. package/esm/transport/0_transport.js +1 -8
  91. package/esm/transport/1_transport_abridged.js +11 -24
  92. package/esm/transport/1_transport_intermediate.js +10 -23
  93. package/{script/transport/2_transport_provider.d.ts → esm/transport/1_transport_provider.d.ts} +1 -1
  94. package/esm/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
  95. package/{script/transport/3_transport_provider_tcp.d.ts → esm/transport/2_transport_provider_tcp.d.ts} +2 -2
  96. package/esm/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
  97. package/esm/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +1 -1
  98. package/esm/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
  99. package/esm/transport/2_transport_provider_web_socket.d.ts.map +1 -0
  100. package/esm/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +1 -1
  101. package/esm/types/0_upload_progress.d.ts +29 -0
  102. package/esm/types/0_upload_progress.d.ts.map +1 -0
  103. package/esm/types/0_upload_progress.js +20 -0
  104. package/esm/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
  105. package/esm/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
  106. package/esm/types/1_sticker.d.ts +1 -1
  107. package/esm/types/1_sticker.d.ts.map +1 -1
  108. package/esm/types/2_chat.d.ts.map +1 -1
  109. package/esm/types/2_poll_answer.d.ts +19 -0
  110. package/esm/types/2_poll_answer.d.ts.map +1 -1
  111. package/esm/types/2_poll_answer.js +19 -0
  112. package/esm/types/2_pre_checkout_query.d.ts.map +1 -1
  113. package/esm/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
  114. package/esm/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
  115. package/esm/types/{3_reply_markup.js → 2_reply_markup.js} +1 -1
  116. package/esm/types/2_story_interactive_area.d.ts.map +1 -1
  117. package/esm/types/3_chat_member_updated.d.ts.map +1 -1
  118. package/esm/types/3_story.d.ts.map +1 -1
  119. package/esm/types/5_message.d.ts +1 -1
  120. package/esm/types/5_message.d.ts.map +1 -1
  121. package/esm/types/5_message.js +1 -1
  122. package/esm/types/6_inline_query_result.d.ts +1 -1
  123. package/esm/types/6_inline_query_result.js +1 -1
  124. package/esm/types/7_update.d.ts +21 -2
  125. package/esm/types/7_update.d.ts.map +1 -1
  126. package/esm/utilities/0_bigint_test.d.ts.map +1 -1
  127. package/esm/utilities/0_buffer.d.ts +1 -1
  128. package/esm/utilities/0_buffer.d.ts.map +1 -1
  129. package/esm/utilities/0_buffer_test.d.ts.map +1 -1
  130. package/esm/utilities/0_hash.d.ts +2 -2
  131. package/esm/utilities/0_hash.d.ts.map +1 -1
  132. package/esm/utilities/0_mutex.js +4 -19
  133. package/esm/utilities/0_part_stream.js +11 -25
  134. package/esm/utilities/0_part_stream_test.d.ts.map +1 -1
  135. package/esm/utilities/0_rle.d.ts +2 -2
  136. package/esm/utilities/0_rle.d.ts.map +1 -1
  137. package/esm/utilities/0_rle_test.d.ts.map +1 -1
  138. package/esm/utilities/0_text.d.ts +20 -1
  139. package/esm/utilities/0_text.d.ts.map +1 -1
  140. package/esm/utilities/0_text.js +19 -0
  141. package/esm/utilities/1_auth.d.ts +1 -1
  142. package/esm/utilities/1_auth.d.ts.map +1 -1
  143. package/esm/utilities/1_base64.d.ts +1 -1
  144. package/esm/utilities/1_base64.d.ts.map +1 -1
  145. package/esm/utilities/1_base64_test.d.ts.map +1 -1
  146. package/esm/utilities/1_crypto.js +42 -53
  147. package/esm/utilities/1_crypto_test.d.ts.map +1 -1
  148. package/esm/utilities/1_logger.d.ts +2 -2
  149. package/esm/utilities/1_math_test.d.ts.map +1 -1
  150. package/esm/utilities/2_queue.js +29 -47
  151. package/package.json +1 -1
  152. package/script/0_errors.js +2 -6
  153. package/script/2_tl.js +17 -7
  154. package/script/3_errors.js +2 -12
  155. package/script/3_transport.d.ts +3 -3
  156. package/script/3_transport.js +3 -3
  157. package/script/3_types.d.ts +8 -7
  158. package/script/3_types.d.ts.map +1 -1
  159. package/script/3_types.js +8 -7
  160. package/script/4_constants.js +17 -7
  161. package/script/4_errors.js +2 -12
  162. package/script/_dnt.polyfills.d.ts +99 -0
  163. package/script/_dnt.polyfills.d.ts.map +1 -1
  164. package/script/_dnt.polyfills.js +128 -0
  165. package/script/_dnt.test_polyfills.d.ts.map +1 -0
  166. package/script/client/0_filters_test.d.ts.map +1 -1
  167. package/script/client/0_markdown_test.d.ts.map +1 -1
  168. package/script/client/0_params.d.ts +2 -0
  169. package/script/client/0_params.d.ts.map +1 -1
  170. package/script/client/0_password.d.ts +5 -5
  171. package/script/client/0_password.d.ts.map +1 -1
  172. package/script/client/0_password.js +17 -7
  173. package/script/client/0_password_test.d.ts.map +1 -1
  174. package/script/client/0_storage_operations.js +143 -155
  175. package/script/client/0_storage_operations_test.d.ts.map +1 -1
  176. package/script/client/0_utilities.d.ts +1 -1
  177. package/script/client/0_utilities_test.d.ts.map +1 -1
  178. package/script/client/1_client_plain.js +4 -22
  179. package/script/client/1_composer.js +8 -21
  180. package/script/client/2_account_manager.js +85 -97
  181. package/script/client/2_bot_info_manager.js +26 -38
  182. package/script/client/2_business_connection_manager.js +10 -23
  183. package/script/client/2_client_encrypted.js +195 -212
  184. package/script/client/2_file_manager.d.ts +4 -3
  185. package/script/client/2_file_manager.d.ts.map +1 -1
  186. package/script/client/2_file_manager.js +285 -231
  187. package/script/client/2_file_manager_test.d.ts.map +1 -1
  188. package/script/client/2_network_statistics_manager.js +8 -21
  189. package/script/client/2_payment_manager.js +7 -20
  190. package/script/client/2_reaction_manager.js +7 -20
  191. package/script/client/2_translations_manager.js +98 -108
  192. package/script/client/2_update_manager.js +764 -759
  193. package/script/client/3_client_encrypted_pool.js +10 -26
  194. package/script/client/3_client_encrypted_pool_test.d.ts.map +1 -1
  195. package/script/client/3_message_manager.d.ts +1 -1
  196. package/script/client/3_message_manager.js +441 -448
  197. package/script/client/3_message_manager_test.d.ts.map +1 -1
  198. package/script/client/3_video_chat_manager.d.ts +1 -1
  199. package/script/client/3_video_chat_manager.js +57 -68
  200. package/script/client/4_callback_query_manager.js +18 -30
  201. package/script/client/4_chat_list_manager.js +322 -318
  202. package/script/client/4_chat_manager.js +118 -131
  203. package/script/client/4_forum_manager.js +67 -73
  204. package/script/client/4_gift_manager.js +16 -29
  205. package/script/client/4_inline_query_manager.js +16 -28
  206. package/script/client/4_link_preview_manager.js +6 -19
  207. package/script/client/4_poll_manager.js +44 -57
  208. package/script/client/4_story_manager.js +41 -53
  209. package/script/client/5_client.d.ts +7 -0
  210. package/script/client/5_client.d.ts.map +1 -1
  211. package/script/client/5_client.js +1271 -1290
  212. package/script/connection/1_connection_tcp.node.js +48 -65
  213. package/script/connection/1_connection_web_socket.js +92 -98
  214. package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  215. package/script/deps/jsr.io/@std/assert/1.0.13/equal.js +17 -7
  216. package/script/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
  217. package/script/deps/jsr.io/@std/async/1.0.13/delay.js +17 -7
  218. package/script/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
  219. package/script/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
  220. package/script/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
  221. package/script/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
  222. package/script/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
  223. package/script/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
  224. package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
  225. package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
  226. package/script/deps/jsr.io/@std/internal/1.0.10/format.js +106 -0
  227. package/script/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
  228. package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +17 -7
  229. package/script/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
  230. package/script/deps/jsr.io/@std/path/1.1.0/_os.js +17 -7
  231. package/script/mod.js +19 -19
  232. package/script/session/0_session_state.js +12 -38
  233. package/script/session/1_session.js +66 -79
  234. package/script/session/2_session_encrypted.js +325 -321
  235. package/script/storage/1_utilities_test.d.ts.map +1 -1
  236. package/script/storage/2_storage_indexed_db.js +26 -44
  237. package/script/storage/2_storage_local_storage.node.js +12 -25
  238. package/script/storage/2_storage_memory.js +24 -41
  239. package/script/storage/2_storage_session_storage.js +3 -16
  240. package/script/tl/0_utilities_test.d.ts.map +1 -1
  241. package/script/tl/1_tl_reader.js +81 -89
  242. package/script/tl/1_tl_reader_test.d.ts.map +1 -1
  243. package/script/tl/1_tl_writer.js +156 -165
  244. package/script/tl/1_tl_writer_test.d.ts.map +1 -1
  245. package/script/tl/2_telegram.d.ts +9 -10
  246. package/script/tl/2_telegram.d.ts.map +1 -1
  247. package/script/tl/2_telegram.js +32 -10
  248. package/script/transport/0_obfuscation.js +17 -7
  249. package/script/transport/0_transport.js +1 -8
  250. package/script/transport/1_transport_abridged.js +11 -24
  251. package/script/transport/1_transport_intermediate.js +10 -23
  252. package/{esm/transport/2_transport_provider.d.ts → script/transport/1_transport_provider.d.ts} +1 -1
  253. package/script/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
  254. package/{esm/transport/3_transport_provider_tcp.d.ts → script/transport/2_transport_provider_tcp.d.ts} +2 -2
  255. package/script/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
  256. package/script/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +3 -3
  257. package/script/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
  258. package/script/transport/2_transport_provider_web_socket.d.ts.map +1 -0
  259. package/script/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +2 -2
  260. package/script/types/0_upload_progress.d.ts +29 -0
  261. package/script/types/0_upload_progress.d.ts.map +1 -0
  262. package/script/types/0_upload_progress.js +21 -0
  263. package/script/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
  264. package/script/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
  265. package/script/types/1_sticker.d.ts +1 -1
  266. package/script/types/1_sticker.d.ts.map +1 -1
  267. package/script/types/2_chat.d.ts.map +1 -1
  268. package/script/types/2_poll_answer.d.ts +19 -0
  269. package/script/types/2_poll_answer.d.ts.map +1 -1
  270. package/script/types/2_poll_answer.js +19 -0
  271. package/script/types/2_pre_checkout_query.d.ts.map +1 -1
  272. package/script/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
  273. package/script/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
  274. package/script/types/{3_reply_markup.js → 2_reply_markup.js} +3 -3
  275. package/script/types/2_story_interactive_area.d.ts.map +1 -1
  276. package/script/types/3_chat_member_updated.d.ts.map +1 -1
  277. package/script/types/3_story.d.ts.map +1 -1
  278. package/script/types/5_message.d.ts +1 -1
  279. package/script/types/5_message.d.ts.map +1 -1
  280. package/script/types/5_message.js +2 -2
  281. package/script/types/6_inline_query_result.d.ts +1 -1
  282. package/script/types/6_inline_query_result.js +4 -4
  283. package/script/types/7_update.d.ts +21 -2
  284. package/script/types/7_update.d.ts.map +1 -1
  285. package/script/utilities/0_bigint.js +17 -7
  286. package/script/utilities/0_bigint_test.d.ts.map +1 -1
  287. package/script/utilities/0_buffer.d.ts +1 -1
  288. package/script/utilities/0_buffer.d.ts.map +1 -1
  289. package/script/utilities/0_buffer_test.d.ts.map +1 -1
  290. package/script/utilities/0_env.js +17 -7
  291. package/script/utilities/0_hash.d.ts +2 -2
  292. package/script/utilities/0_hash.d.ts.map +1 -1
  293. package/script/utilities/0_hash.js +17 -7
  294. package/script/utilities/0_misc.js +17 -7
  295. package/script/utilities/0_mutex.js +4 -19
  296. package/script/utilities/0_part_stream.js +11 -25
  297. package/script/utilities/0_part_stream_test.d.ts.map +1 -1
  298. package/script/utilities/0_rle.d.ts +2 -2
  299. package/script/utilities/0_rle.d.ts.map +1 -1
  300. package/script/utilities/0_rle_test.d.ts.map +1 -1
  301. package/script/utilities/0_text.d.ts +20 -1
  302. package/script/utilities/0_text.d.ts.map +1 -1
  303. package/script/utilities/0_text.js +19 -0
  304. package/script/utilities/1_auth.d.ts +1 -1
  305. package/script/utilities/1_auth.d.ts.map +1 -1
  306. package/script/utilities/1_auth.js +17 -7
  307. package/script/utilities/1_base64.d.ts +1 -1
  308. package/script/utilities/1_base64.d.ts.map +1 -1
  309. package/script/utilities/1_base64_test.d.ts.map +1 -1
  310. package/script/utilities/1_crypto.js +60 -61
  311. package/script/utilities/1_crypto_test.d.ts.map +1 -1
  312. package/script/utilities/1_logger.d.ts +2 -2
  313. package/script/utilities/1_math_test.d.ts.map +1 -1
  314. package/script/utilities/2_queue.js +30 -48
  315. package/esm/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
  316. package/esm/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
  317. package/esm/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
  318. package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
  319. package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
  320. package/esm/deps/jsr.io/@std/internal/1.0.9/format.js +0 -37
  321. package/esm/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
  322. package/esm/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
  323. package/esm/transport/3_transport_provider_web_socket.d.ts.map +0 -1
  324. package/script/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
  325. package/script/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
  326. package/script/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
  327. package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
  328. package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
  329. package/script/deps/jsr.io/@std/internal/1.0.9/format.js +0 -63
  330. package/script/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
  331. package/script/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
  332. package/script/transport/3_transport_provider_web_socket.d.ts.map +0 -1
  333. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
  334. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
  335. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
  336. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
  337. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
  338. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
  339. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
  340. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +0 -0
  341. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
  342. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
  343. /package/esm/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
  344. /package/esm/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
  345. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
  346. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
  347. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
  348. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
  349. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
  350. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
  351. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
  352. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
  353. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
  354. /package/script/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
  355. /package/script/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
@@ -17,18 +17,6 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
21
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
22
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
23
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
24
- };
25
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
26
- if (kind === "m") throw new TypeError("Private method is not writable");
27
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
28
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
29
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
30
- };
31
- var _Client_instances, _Client_clients, _Client_downloadPools, _Client_uploadPools, _Client_guaranteeUpdateDelivery, _Client_accountManager, _Client_botInfoManager, _Client_businessConnectionManager, _Client_fileManager, _Client_networkStatisticsManager, _Client_paymentManager, _Client_reactionManager, _Client_translationsManager, _Client_updateManager, _Client_messageManager, _Client_videoChatManager, _Client_callbackQueryManager, _Client_chatListManager, _Client_chatManager, _Client_forumManager, _Client_giftManager, _Client_inlineQueryManager, _Client_linkPreviewManager, _Client_pollManager, _Client_storyManager, _Client_managers, _Client_storage_, _Client_messageStorage_, _Client_parseMode, _Client_apiId, _Client_apiHash, _Client_transportProvider, _Client_publicKeys, _Client_outgoingMessages, _Client_persistCache, _Client_disableUpdates, _Client_authString, _Client_initialDc, _Client_L, _Client_LsignIn, _Client_LupdateGapRecoveryLoop, _Client_LhandleMigrationError, _Client_Lmin, _Client_setMainClient, _Client_newClient, _Client_disconnectAllClients, _Client_client_get, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_getIsPremium, _Client_lastUpdates, _Client_updateGapRecoveryLoopAbortController, _Client_startUpdateGapRecoveryLoop, _Client_updateGapRecoveryLoop, _Client_clientDisconnectionLoopAbortController, _Client_startClientDisconnectionLoop, _Client_clientDisconnectionLoop, _Client_getClient, _Client_getMainClientMutex, _Client_getMainClient, _Client_getDownloadClient, _Client_getUploadPoolSize, _Client_getUploadClient, _Client_setupClient, _Client_importAuthorization, _Client_invoke, _Client_handleInvokeError, _Client_authStringImported, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerChatId, _Client_getInputPeerInner, _Client_getMinInputPeer, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe, _Client_previouslyConnected, _Client_lastConnectionState, _Client_onConnectionStateChange;
32
20
  import { delay, MINUTE, SECOND, unreachable } from "../0_deps.js";
33
21
  import { AccessError, ConnectionError, InputError } from "../0_errors.js";
34
22
  import { cleanObject, drop, getLogger, mustPrompt, mustPromptOneOf, Mutex, ZERO_CHANNEL_ID } from "../1_utilities.js";
@@ -79,615 +67,130 @@ const getEntity = Symbol();
79
67
  * An MTKruto client.
80
68
  */
81
69
  export class Client extends Composer {
70
+ #clients = new Array();
71
+ #downloadPools = {};
72
+ #uploadPools = {};
73
+ #guaranteeUpdateDelivery;
74
+ // 2_
75
+ #accountManager;
76
+ #botInfoManager;
77
+ #businessConnectionManager;
78
+ #fileManager;
79
+ #networkStatisticsManager;
80
+ #paymentManager;
81
+ #reactionManager;
82
+ #translationsManager;
83
+ #updateManager;
84
+ // 3_
85
+ #messageManager;
86
+ #videoChatManager;
87
+ // 4_
88
+ #callbackQueryManager;
89
+ #chatListManager;
90
+ #chatManager;
91
+ #forumManager;
92
+ #giftManager;
93
+ #inlineQueryManager;
94
+ #linkPreviewManager;
95
+ #pollManager;
96
+ #storyManager;
97
+ // deno-lint-ignore no-explicit-any
98
+ #managers;
82
99
  // deno-lint-ignore no-explicit-any
83
100
  get managers() {
84
- return __classPrivateFieldGet(this, _Client_managers, "f") ?? (__classPrivateFieldSet(this, _Client_managers, __classPrivateFieldGet(this, _Client_managers, "f") ?? {
101
+ return this.#managers ?? (this.#managers ??= {
85
102
  // 2_
86
- accountManager: __classPrivateFieldGet(this, _Client_accountManager, "f"),
87
- botInfoManager: __classPrivateFieldGet(this, _Client_botInfoManager, "f"),
88
- businessConnectionManager: __classPrivateFieldGet(this, _Client_businessConnectionManager, "f"),
89
- fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f"),
90
- networkStatisticsManager: __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f"),
91
- paymentManager: __classPrivateFieldGet(this, _Client_paymentManager, "f"),
92
- reactionManager: __classPrivateFieldGet(this, _Client_reactionManager, "f"),
93
- translationsManager: __classPrivateFieldGet(this, _Client_translationsManager, "f"),
94
- updateManager: __classPrivateFieldGet(this, _Client_updateManager, "f"),
103
+ accountManager: this.#accountManager,
104
+ botInfoManager: this.#botInfoManager,
105
+ businessConnectionManager: this.#businessConnectionManager,
106
+ fileManager: this.#fileManager,
107
+ networkStatisticsManager: this.#networkStatisticsManager,
108
+ paymentManager: this.#paymentManager,
109
+ reactionManager: this.#reactionManager,
110
+ translationsManager: this.#translationsManager,
111
+ updateManager: this.#updateManager,
95
112
  // 3_
96
- messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f"),
97
- videoChatManager: __classPrivateFieldGet(this, _Client_videoChatManager, "f"),
113
+ messageManager: this.#messageManager,
114
+ videoChatManager: this.#videoChatManager,
98
115
  // 4_
99
- callbackQueryManager: __classPrivateFieldGet(this, _Client_callbackQueryManager, "f"),
100
- chatListManager: __classPrivateFieldGet(this, _Client_chatListManager, "f"),
101
- chatManager: __classPrivateFieldGet(this, _Client_chatManager, "f"),
102
- forumManager: __classPrivateFieldGet(this, _Client_forumManager, "f"),
103
- giftManager: __classPrivateFieldGet(this, _Client_giftManager, "f"),
104
- inlineQueryManager: __classPrivateFieldGet(this, _Client_inlineQueryManager, "f"),
105
- linkPreviewManager: __classPrivateFieldGet(this, _Client_linkPreviewManager, "f"),
106
- pollManager: __classPrivateFieldGet(this, _Client_pollManager, "f"),
107
- storyManager: __classPrivateFieldGet(this, _Client_storyManager, "f"),
108
- }, "f"));
116
+ callbackQueryManager: this.#callbackQueryManager,
117
+ chatListManager: this.#chatListManager,
118
+ chatManager: this.#chatManager,
119
+ forumManager: this.#forumManager,
120
+ giftManager: this.#giftManager,
121
+ inlineQueryManager: this.#inlineQueryManager,
122
+ linkPreviewManager: this.#linkPreviewManager,
123
+ pollManager: this.#pollManager,
124
+ storyManager: this.#storyManager,
125
+ });
109
126
  }
127
+ #storage_;
128
+ #messageStorage_;
129
+ storage;
130
+ messageStorage;
131
+ #parseMode;
132
+ #apiId;
133
+ #apiHash;
134
+ #transportProvider;
135
+ appVersion;
136
+ deviceModel;
137
+ language;
138
+ platform;
139
+ systemLangCode;
140
+ systemVersion;
141
+ #publicKeys;
142
+ #outgoingMessages;
143
+ #persistCache;
144
+ #disableUpdates;
145
+ #authString;
146
+ #initialDc;
147
+ #L;
148
+ #LsignIn;
149
+ #LupdateGapRecoveryLoop;
150
+ #LhandleMigrationError;
151
+ #Lmin;
110
152
  /**
111
153
  * Constructs the client.
112
154
  */
113
155
  constructor(params) {
114
156
  super();
115
- _Client_instances.add(this);
116
- _Client_clients.set(this, new Array());
117
- _Client_downloadPools.set(this, {});
118
- _Client_uploadPools.set(this, {});
119
- _Client_guaranteeUpdateDelivery.set(this, void 0);
120
- // 2_
121
- _Client_accountManager.set(this, void 0);
122
- _Client_botInfoManager.set(this, void 0);
123
- _Client_businessConnectionManager.set(this, void 0);
124
- _Client_fileManager.set(this, void 0);
125
- _Client_networkStatisticsManager.set(this, void 0);
126
- _Client_paymentManager.set(this, void 0);
127
- _Client_reactionManager.set(this, void 0);
128
- _Client_translationsManager.set(this, void 0);
129
- _Client_updateManager.set(this, void 0);
130
- // 3_
131
- _Client_messageManager.set(this, void 0);
132
- _Client_videoChatManager.set(this, void 0);
133
- // 4_
134
- _Client_callbackQueryManager.set(this, void 0);
135
- _Client_chatListManager.set(this, void 0);
136
- _Client_chatManager.set(this, void 0);
137
- _Client_forumManager.set(this, void 0);
138
- _Client_giftManager.set(this, void 0);
139
- _Client_inlineQueryManager.set(this, void 0);
140
- _Client_linkPreviewManager.set(this, void 0);
141
- _Client_pollManager.set(this, void 0);
142
- _Client_storyManager.set(this, void 0);
143
- // deno-lint-ignore no-explicit-any
144
- _Client_managers.set(this, void 0);
145
- _Client_storage_.set(this, void 0);
146
- _Client_messageStorage_.set(this, void 0);
147
- Object.defineProperty(this, "storage", {
148
- enumerable: true,
149
- configurable: true,
150
- writable: true,
151
- value: void 0
152
- });
153
- Object.defineProperty(this, "messageStorage", {
154
- enumerable: true,
155
- configurable: true,
156
- writable: true,
157
- value: void 0
158
- });
159
- _Client_parseMode.set(this, void 0);
160
- _Client_apiId.set(this, void 0);
161
- _Client_apiHash.set(this, void 0);
162
- _Client_transportProvider.set(this, void 0);
163
- Object.defineProperty(this, "appVersion", {
164
- enumerable: true,
165
- configurable: true,
166
- writable: true,
167
- value: void 0
168
- });
169
- Object.defineProperty(this, "deviceModel", {
170
- enumerable: true,
171
- configurable: true,
172
- writable: true,
173
- value: void 0
174
- });
175
- Object.defineProperty(this, "language", {
176
- enumerable: true,
177
- configurable: true,
178
- writable: true,
179
- value: void 0
180
- });
181
- Object.defineProperty(this, "platform", {
182
- enumerable: true,
183
- configurable: true,
184
- writable: true,
185
- value: void 0
186
- });
187
- Object.defineProperty(this, "systemLangCode", {
188
- enumerable: true,
189
- configurable: true,
190
- writable: true,
191
- value: void 0
192
- });
193
- Object.defineProperty(this, "systemVersion", {
194
- enumerable: true,
195
- configurable: true,
196
- writable: true,
197
- value: void 0
198
- });
199
- _Client_publicKeys.set(this, void 0);
200
- _Client_outgoingMessages.set(this, void 0);
201
- _Client_persistCache.set(this, void 0);
202
- _Client_disableUpdates.set(this, void 0);
203
- _Client_authString.set(this, void 0);
204
- _Client_initialDc.set(this, void 0);
205
- _Client_L.set(this, void 0);
206
- _Client_LsignIn.set(this, void 0);
207
- _Client_LupdateGapRecoveryLoop.set(this, void 0);
208
- _Client_LhandleMigrationError.set(this, void 0);
209
- _Client_Lmin.set(this, void 0);
210
- _Client_constructContext.set(this, async (update) => {
211
- const msg = "message" in update ? update.message : "editedMessage" in update ? update.editedMessage : "scheduledMessage" in update ? update.scheduledMessage : "callbackQuery" in update ? update.callbackQuery.message : undefined;
212
- const reactions = "messageInteractions" in update ? update.messageInteractions : undefined;
213
- const mustGetMsg = () => {
214
- if (msg !== undefined) {
215
- return { chatId: msg.chat.id, messageId: msg.id, businessConnectionId: msg.businessConnectionId, senderId: msg.from?.id, userId: msg.from?.id };
216
- }
217
- else if (reactions !== undefined) {
218
- return { chatId: reactions.chatId, messageId: reactions.messageId };
219
- }
220
- else {
221
- unreachable();
222
- }
223
- };
224
- const mustGetUserId = () => {
225
- if (msg?.from) {
226
- return msg.from.id;
227
- }
228
- else if ("callbackQuery" in update) {
229
- return update.callbackQuery.from.id;
230
- }
231
- else if ("chosenInlineResult" in update) {
232
- return update.chosenInlineResult.from.id;
233
- }
234
- else {
235
- unreachable();
236
- }
237
- };
238
- const mustGetInlineMsgId = () => {
239
- if ("chosenInlineResult" in update) {
240
- if (update.chosenInlineResult.inlineMessageId) {
241
- return update.chosenInlineResult.inlineMessageId;
242
- }
243
- }
244
- else if ("callbackQuery" in update) {
245
- if (update.callbackQuery.inlineMessageId) {
246
- return update.callbackQuery.inlineMessageId;
247
- }
248
- }
249
- unreachable();
250
- };
251
- const chat_ = "messageReactions" in update ? update.messageReactions.chat : "messageReactionCount" in update ? update.messageReactionCount.chat : "chatMember" in update ? update.chatMember.chat : "myChatMember" in update ? update.myChatMember.chat : "joinRequest" in update ? update.joinRequest.chat : "story" in update ? update.story.chat : undefined;
252
- const chat = chat_ ?? msg?.chat;
253
- const from = "callbackQuery" in update ? update.callbackQuery.from : "inlineQuery" in update ? update.inlineQuery.from : "chatMember" in update ? update.chatMember.from : "myChatMember" in update ? update.myChatMember.from : "messageReactions" in update ? update.messageReactions.user : "preCheckoutQuery" in update ? update.preCheckoutQuery.from : "joinRequest" in update ? update.joinRequest.from : "businessConnection" in update ? update.businessConnection.user : "pollAnswer" in update ? update.pollAnswer.from : msg?.from ? msg.from : undefined;
254
- const getReplyTo = (quote, chatId, messageId) => {
255
- if ("story" in update) {
256
- return { chatId: update.story.chat.id, storyId: update.story.id };
257
- }
258
- const isPrivate = chatId > 0;
259
- const shouldQuote = quote === undefined ? !isPrivate : quote;
260
- return shouldQuote ? { messageId } : undefined;
261
- };
262
- const me = "connectionState" in update ? __classPrivateFieldGet(this, _Client_lastGetMe, "f") : ("authorizationState" in update && !update.authorizationState.authorized) ? __classPrivateFieldGet(this, _Client_lastGetMe, "f") : await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMe).call(this);
263
- const context = {
264
- ...update,
265
- client: this,
266
- me: (me == null ? undefined : me),
267
- msg: msg,
268
- chat: chat,
269
- from: from,
270
- get toJSON() {
271
- return () => update;
272
- },
273
- reply: (text, params) => {
274
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
275
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
276
- return this.sendMessage(chatId, text, { ...params, replyTo, businessConnectionId });
277
- },
278
- replyPoll: (question, options, params) => {
279
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
280
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
281
- return this.sendPoll(chatId, question, options, { ...params, replyTo, businessConnectionId });
282
- },
283
- replyPhoto: (photo, params) => {
284
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
285
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
286
- return this.sendPhoto(chatId, photo, { ...params, replyTo, businessConnectionId });
287
- },
288
- replyMediaGroup: (media, params) => {
289
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
290
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
291
- return this.sendMediaGroup(chatId, media, { ...params, replyTo, businessConnectionId });
292
- },
293
- replyInvoice: (title, description, payload, currency, prices, params) => {
294
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
295
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
296
- return this.sendInvoice(chatId, title, description, payload, currency, prices, { ...params, replyTo, businessConnectionId });
297
- },
298
- replyDocument: (document, params) => {
299
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
300
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
301
- return this.sendDocument(chatId, document, { ...params, replyTo, businessConnectionId });
302
- },
303
- replySticker: (sticker, params) => {
304
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
305
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
306
- return this.sendSticker(chatId, sticker, { ...params, replyTo, businessConnectionId });
307
- },
308
- replyContact: (firstName, number, params) => {
309
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
310
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
311
- return this.sendContact(chatId, firstName, number, { ...params, replyTo, businessConnectionId });
312
- },
313
- replyLocation: (latitude, longitude, params) => {
314
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
315
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
316
- return this.sendLocation(chatId, latitude, longitude, { ...params, replyTo, businessConnectionId });
317
- },
318
- replyDice: (params) => {
319
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
320
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
321
- return this.sendDice(chatId, { ...params, replyTo, businessConnectionId });
322
- },
323
- replyVenue: (latitude, longitude, title, address, params) => {
324
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
325
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
326
- return this.sendVenue(chatId, latitude, longitude, title, address, { ...params, replyTo, businessConnectionId });
327
- },
328
- replyVideo: (video, params) => {
329
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
330
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
331
- return this.sendVideo(chatId, video, { ...params, replyTo, businessConnectionId });
332
- },
333
- replyAnimation: (document, params) => {
334
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
335
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
336
- return this.sendAnimation(chatId, document, { ...params, replyTo, businessConnectionId });
337
- },
338
- replyVoice: (document, params) => {
339
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
340
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
341
- return this.sendVoice(chatId, document, { ...params, replyTo, businessConnectionId });
342
- },
343
- replyAudio: (document, params) => {
344
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
345
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
346
- return this.sendAudio(chatId, document, { ...params, replyTo, businessConnectionId });
347
- },
348
- replyVideoNote: (videoNote, params) => {
349
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
350
- const replyTo = getReplyTo(params?.quote, chatId, messageId);
351
- return this.sendVideoNote(chatId, videoNote, { ...params, replyTo, businessConnectionId });
352
- },
353
- delete: () => {
354
- const { chatId, messageId } = mustGetMsg();
355
- return this.deleteMessage(chatId, messageId);
356
- },
357
- forward: (to, params) => {
358
- const { chatId, messageId } = mustGetMsg();
359
- return this.forwardMessage(chatId, to, messageId, params);
360
- },
361
- pin: (params) => {
362
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
363
- return this.pinMessage(chatId, messageId, { ...params, businessConnectionId });
364
- },
365
- unpin: () => {
366
- const { chatId, messageId, businessConnectionId } = mustGetMsg();
367
- return this.unpinMessage(chatId, messageId, { businessConnectionId });
368
- },
369
- banSender: (params) => {
370
- const { chatId, senderId } = mustGetMsg();
371
- if (!senderId) {
372
- unreachable();
373
- }
374
- return this.banChatMember(chatId, senderId, params);
375
- },
376
- kickSender: () => {
377
- const { chatId, senderId } = mustGetMsg();
378
- if (!senderId) {
379
- unreachable();
380
- }
381
- return this.kickChatMember(chatId, senderId);
382
- },
383
- setSenderRights: (params) => {
384
- const { chatId, senderId } = mustGetMsg();
385
- if (!senderId) {
386
- unreachable();
387
- }
388
- return this.setChatMemberRights(chatId, senderId, params);
389
- },
390
- getChatAdministrators: () => {
391
- const { chatId } = mustGetMsg();
392
- return this.getChatAdministrators(chatId);
393
- },
394
- react: (reactions, params) => {
395
- const { chatId, messageId } = mustGetMsg();
396
- return this.setReactions(chatId, messageId, reactions, params);
397
- },
398
- answerCallbackQuery: (params) => {
399
- if (!("callbackQuery" in update)) {
400
- unreachable();
401
- }
402
- return this.answerCallbackQuery(update.callbackQuery.id, params);
403
- },
404
- answerInlineQuery: (results, params) => {
405
- if (!("inlineQuery" in update)) {
406
- unreachable();
407
- }
408
- return this.answerInlineQuery(update.inlineQuery.id, results, params);
409
- },
410
- sendChatAction: (chatAction, params) => {
411
- const { chatId } = mustGetMsg();
412
- return this.sendChatAction(chatId, chatAction, params);
413
- },
414
- editInlineMessageText: (text, params) => {
415
- const inlineMessageId = mustGetInlineMsgId();
416
- return this.editInlineMessageText(inlineMessageId, text, params);
417
- },
418
- editInlineMessageMedia: (media, params) => {
419
- const inlineMessageId = mustGetInlineMsgId();
420
- return this.editInlineMessageMedia(inlineMessageId, media, params);
421
- },
422
- editInlineMessageCaption: (params) => {
423
- const inlineMessageId = mustGetInlineMsgId();
424
- return this.editInlineMessageCaption(inlineMessageId, params);
425
- },
426
- editInlineMessageLiveLocation: (latitude, longitude, params) => {
427
- const inlineMessageId = mustGetInlineMsgId();
428
- return this.editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
429
- },
430
- editInlineMessageReplyMarkup: (params) => {
431
- const inlineMessageId = mustGetInlineMsgId();
432
- return this.editInlineMessageReplyMarkup(inlineMessageId, params);
433
- },
434
- editMessageText: (messageId, text, params) => {
435
- const { chatId } = mustGetMsg();
436
- return this.editMessageText(chatId, messageId, text, params);
437
- },
438
- editMessageCaption: (messageId, params) => {
439
- const { chatId } = mustGetMsg();
440
- return this.editMessageCaption(chatId, messageId, params);
441
- },
442
- editMessageMedia: (messageId, media, params) => {
443
- const { chatId } = mustGetMsg();
444
- return this.editMessageMedia(chatId, messageId, media, params);
445
- },
446
- editMessageLiveLocation: (messageId, latitude, longitude, params) => {
447
- const { chatId } = mustGetMsg();
448
- return this.editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
449
- },
450
- editMessageReplyMarkup: (messageId, params) => {
451
- const { chatId } = mustGetMsg();
452
- return this.editMessageReplyMarkup(chatId, messageId, params);
453
- },
454
- getMessage: (messageId) => {
455
- const { chatId } = mustGetMsg();
456
- return this.getMessage(chatId, messageId);
457
- },
458
- getMessages: (messageIds) => {
459
- const { chatId } = mustGetMsg();
460
- return this.getMessages(chatId, messageIds);
461
- },
462
- forwardMessage: (to, messageId, params) => {
463
- const { chatId } = mustGetMsg();
464
- return this.forwardMessage(chatId, to, messageId, params);
465
- },
466
- forwardMessages: (to, messageIds, params) => {
467
- const { chatId } = mustGetMsg();
468
- return this.forwardMessages(chatId, to, messageIds, params);
469
- },
470
- deleteMessage: (messageId, params) => {
471
- const { chatId } = mustGetMsg();
472
- return this.deleteMessage(chatId, messageId, params);
473
- },
474
- deleteMessages: (messageIds, params) => {
475
- const { chatId } = mustGetMsg();
476
- return this.deleteMessages(chatId, messageIds, params);
477
- },
478
- pinMessage: (messageId, params) => {
479
- const { chatId } = mustGetMsg();
480
- return this.pinMessage(chatId, messageId, params);
481
- },
482
- unpinMessage: (messageId) => {
483
- const { chatId } = mustGetMsg();
484
- return this.unpinMessage(chatId, messageId);
485
- },
486
- unpinMessages: () => {
487
- const { chatId } = mustGetMsg();
488
- return this.unpinMessages(chatId);
489
- },
490
- setAvailableReactions: (availableReactions) => {
491
- const { chatId } = mustGetMsg();
492
- return this.setAvailableReactions(chatId, availableReactions);
493
- },
494
- addReaction: (messageId, reaction, params) => {
495
- const { chatId } = mustGetMsg();
496
- return this.addReaction(chatId, messageId, reaction, params);
497
- },
498
- removeReaction: (messageId, reaction) => {
499
- const { chatId } = mustGetMsg();
500
- return this.removeReaction(chatId, messageId, reaction);
501
- },
502
- setReactions: (messageId, reactions, params) => {
503
- const { chatId } = mustGetMsg();
504
- return this.setReactions(chatId, messageId, reactions, params);
505
- },
506
- read: () => {
507
- const { chatId, messageId } = mustGetMsg();
508
- return this.readMessages(chatId, messageId);
509
- },
510
- setChatPhoto: (photo, params) => {
511
- const { chatId } = mustGetMsg();
512
- return this.setChatPhoto(chatId, photo, params);
513
- },
514
- deleteChatPhoto: () => {
515
- const { chatId } = mustGetMsg();
516
- return this.deleteChatPhoto(chatId);
517
- },
518
- banChatMember: (memberId, params) => {
519
- const { chatId } = mustGetMsg();
520
- return this.banChatMember(chatId, memberId, params);
521
- },
522
- unbanChatMember: (memberId) => {
523
- const { chatId } = mustGetMsg();
524
- return this.unbanChatMember(chatId, memberId);
525
- },
526
- kickChatMember: (memberId) => {
527
- const { chatId } = mustGetMsg();
528
- return this.kickChatMember(chatId, memberId);
529
- },
530
- setChatMemberRights: (memberId, params) => {
531
- const { chatId } = mustGetMsg();
532
- return this.setChatMemberRights(chatId, memberId, params);
533
- },
534
- deleteChatMemberMessages: (userId) => {
535
- const { chatId } = mustGetMsg();
536
- return this.deleteChatMemberMessages(chatId, userId);
537
- },
538
- searchMessages: (query, params) => {
539
- const { chatId } = mustGetMsg();
540
- return this.searchMessages(chatId, query, params);
541
- },
542
- setBoostsRequiredToCircumventRestrictions: (boosts) => {
543
- const { chatId } = mustGetMsg();
544
- return this.setBoostsRequiredToCircumventRestrictions(chatId, boosts);
545
- },
546
- createInviteLink: (params) => {
547
- const { chatId } = mustGetMsg();
548
- return this.createInviteLink(chatId, params);
549
- },
550
- getCreatedInviteLinks: (params) => {
551
- const { chatId } = mustGetMsg();
552
- return this.getCreatedInviteLinks(chatId, params);
553
- },
554
- leave: () => {
555
- const { chatId } = mustGetMsg();
556
- return this.leaveChat(chatId);
557
- },
558
- block: () => {
559
- return this.blockUser(mustGetUserId());
560
- },
561
- unblock: () => {
562
- return this.unblockUser(mustGetUserId());
563
- },
564
- getChatMember: (userId) => {
565
- const { chatId } = mustGetMsg();
566
- return this.getChatMember(chatId, userId);
567
- },
568
- getChatMembers: (params) => {
569
- const { chatId } = mustGetMsg();
570
- return this.getChatMembers(chatId, params);
571
- },
572
- setChatStickerSet: (setName) => {
573
- const { chatId } = mustGetMsg();
574
- return this.setChatStickerSet(chatId, setName);
575
- },
576
- deleteChatStickerSet: () => {
577
- const { chatId } = mustGetMsg();
578
- return this.deleteChatStickerSet(chatId);
579
- },
580
- getBusinessConnection: () => {
581
- const { businessConnectionId } = mustGetMsg();
582
- if (!businessConnectionId) {
583
- unreachable();
584
- }
585
- return this.getBusinessConnection(businessConnectionId);
586
- },
587
- answerPreCheckoutQuery: (ok, params) => {
588
- if (!("preCheckoutQuery" in update)) {
589
- unreachable();
590
- }
591
- return this.answerPreCheckoutQuery(update.preCheckoutQuery.id, ok, params);
592
- },
593
- approveJoinRequest: () => {
594
- const { chatId, userId } = mustGetMsg();
595
- if (!userId) {
596
- unreachable();
597
- }
598
- return this.approveJoinRequest(chatId, userId);
599
- },
600
- declineJoinRequest: () => {
601
- const { chatId, userId } = mustGetMsg();
602
- if (!userId) {
603
- unreachable();
604
- }
605
- return this.declineJoinRequest(chatId, userId);
606
- },
607
- };
608
- return cleanObject(context);
609
- });
610
- _Client_lastPropagatedConnectionState.set(this, null);
611
- _Client_stateChangeHandler.set(this, ((connected) => {
612
- const connectionState = connected ? "ready" : "notConnected";
613
- if (__classPrivateFieldGet(this, _Client_lastPropagatedConnectionState, "f") != connectionState) {
614
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateConnectionState).call(this, connectionState);
615
- }
616
- }).bind(this));
617
- _Client_storageInited.set(this, false);
618
- _Client_connectMutex.set(this, new Mutex());
619
- _Client_lastPropagatedAuthorizationState.set(this, null);
620
- _Client_lastUpdates.set(this, new Date());
621
- _Client_updateGapRecoveryLoopAbortController.set(this, void 0);
622
- _Client_clientDisconnectionLoopAbortController.set(this, void 0);
623
- _Client_getMainClientMutex.set(this, new Mutex());
624
- _Client_handleInvokeError.set(this, skipInvoke());
625
- /**
626
- * Invokes a function waiting and returning its reply if the second parameter is not `true`. Requires the client
627
- * to be connected.
628
- *
629
- * @param function_ The function to invoke.
630
- */
631
- Object.defineProperty(this, "invoke", {
632
- enumerable: true,
633
- configurable: true,
634
- writable: true,
635
- value: Object.assign(__classPrivateFieldGet(this, _Client_instances, "m", _Client_invoke), {
636
- use: (handler) => {
637
- const handle = __classPrivateFieldGet(this, _Client_handleInvokeError, "f");
638
- __classPrivateFieldSet(this, _Client_handleInvokeError, async (ctx, next) => {
639
- let result = null;
640
- return await handle(ctx, async () => {
641
- if (result != null)
642
- return result;
643
- result = await handler(ctx, next);
644
- return result;
645
- });
646
- }, "f");
647
- },
648
- })
649
- });
650
- _Client_authStringImported.set(this, false);
651
- _Client_lastGetMe.set(this, null);
652
- _Client_previouslyConnected.set(this, false);
653
- _Client_lastConnectionState.set(this, false);
654
- __classPrivateFieldSet(this, _Client_apiId, params?.apiId ?? 0, "f");
655
- __classPrivateFieldSet(this, _Client_apiHash, params?.apiHash ?? "", "f");
656
- __classPrivateFieldSet(this, _Client_transportProvider, params?.transportProvider, "f");
657
- __classPrivateFieldSet(this, _Client_initialDc, params?.initialDc ?? INITIAL_DC, "f");
658
- __classPrivateFieldSet(this, _Client_storage_, params?.storage || new StorageMemory(), "f");
659
- __classPrivateFieldSet(this, _Client_persistCache, params?.persistCache ?? false, "f");
660
- if (!__classPrivateFieldGet(this, _Client_persistCache, "f")) {
661
- __classPrivateFieldSet(this, _Client_messageStorage_, new StorageMemory(), "f");
157
+ this.#apiId = params?.apiId ?? 0;
158
+ this.#apiHash = params?.apiHash ?? "";
159
+ this.#transportProvider = params?.transportProvider;
160
+ this.#initialDc = params?.initialDc ?? INITIAL_DC;
161
+ this.#storage_ = params?.storage || new StorageMemory();
162
+ this.#persistCache = params?.persistCache ?? false;
163
+ if (!this.#persistCache) {
164
+ this.#messageStorage_ = new StorageMemory();
662
165
  }
663
166
  else {
664
- __classPrivateFieldSet(this, _Client_messageStorage_, __classPrivateFieldGet(this, _Client_storage_, "f"), "f");
167
+ this.#messageStorage_ = this.#storage_;
665
168
  }
666
- this.storage = new StorageOperations(__classPrivateFieldGet(this, _Client_storage_, "f"));
667
- this.messageStorage = new StorageOperations(__classPrivateFieldGet(this, _Client_messageStorage_, "f"));
668
- __classPrivateFieldSet(this, _Client_parseMode, params?.parseMode ?? null, "f");
669
- __classPrivateFieldSet(this, _Client_disableUpdates, params?.disableUpdates ?? false, "f");
670
- __classPrivateFieldSet(this, _Client_authString, params?.authString, "f");
169
+ this.storage = new StorageOperations(this.#storage_);
170
+ this.messageStorage = new StorageOperations(this.#messageStorage_);
171
+ this.#parseMode = params?.parseMode ?? null;
172
+ this.#disableUpdates = params?.disableUpdates ?? false;
173
+ this.#authString = params?.authString;
671
174
  this.appVersion = params?.appVersion ?? APP_VERSION;
672
175
  this.deviceModel = params?.deviceModel ?? DEVICE_MODEL;
673
176
  this.language = params?.language ?? LANG_CODE;
674
177
  this.platform = params?.platform ?? LANG_PACK;
675
178
  this.systemLangCode = params?.systemLangCode ?? SYSTEM_LANG_CODE;
676
179
  this.systemVersion = params?.systemVersion ?? SYSTEM_VERSION;
677
- __classPrivateFieldSet(this, _Client_publicKeys, params?.publicKeys, "f");
678
- __classPrivateFieldSet(this, _Client_outgoingMessages, params?.outgoingMessages ?? null, "f");
180
+ this.#publicKeys = params?.publicKeys;
181
+ this.#outgoingMessages = params?.outgoingMessages ?? null;
679
182
  if (params?.prefixes) {
680
183
  this.prefixes = params?.prefixes;
681
184
  }
682
- __classPrivateFieldSet(this, _Client_guaranteeUpdateDelivery, params?.guaranteeUpdateDelivery ?? false, "f");
683
- const L = __classPrivateFieldSet(this, _Client_L, getLogger("Client").client(id++), "f");
684
- __classPrivateFieldSet(this, _Client_LsignIn, L.branch("signIn"), "f");
685
- __classPrivateFieldSet(this, _Client_LupdateGapRecoveryLoop, L.branch("updateGapRecoveryLoop"), "f");
686
- __classPrivateFieldSet(this, _Client_LhandleMigrationError, L.branch("[handleMigrationError]"), "f");
687
- __classPrivateFieldSet(this, _Client_Lmin, L.branch("min"), "f");
185
+ this.#guaranteeUpdateDelivery = params?.guaranteeUpdateDelivery ?? false;
186
+ const L = this.#L = getLogger("Client").client(id++);
187
+ this.#LsignIn = L.branch("signIn");
188
+ this.#LupdateGapRecoveryLoop = L.branch("updateGapRecoveryLoop");
189
+ this.#LhandleMigrationError = L.branch("[handleMigrationError]");
190
+ this.#Lmin = L.branch("min");
688
191
  const c = {
689
192
  id,
690
- getUploadPoolSize: __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUploadPoolSize).bind(this),
193
+ getUploadPoolSize: this.#getUploadPoolSize.bind(this),
691
194
  invoke: async (function_, params) => {
692
195
  if (params?.businessConnectionId) {
693
196
  if (Mtproto.is("ping", function_)) {
@@ -701,48 +204,48 @@ export class Client extends Composer {
701
204
  },
702
205
  storage: this.storage,
703
206
  messageStorage: this.messageStorage,
704
- guaranteeUpdateDelivery: __classPrivateFieldGet(this, _Client_guaranteeUpdateDelivery, "f"),
705
- setConnectionState: __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateConnectionState).bind(this),
706
- resetConnectionState: () => __classPrivateFieldGet(this, _Client_stateChangeHandler, "f").call(this, this.connected),
707
- getSelfId: __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).bind(this),
708
- getIsPremium: __classPrivateFieldGet(this, _Client_instances, "m", _Client_getIsPremium).bind(this),
207
+ guaranteeUpdateDelivery: this.#guaranteeUpdateDelivery,
208
+ setConnectionState: this.#propagateConnectionState.bind(this),
209
+ resetConnectionState: () => this.#stateChangeHandler(this.connected),
210
+ getSelfId: this.#getSelfId.bind(this),
211
+ getIsPremium: this.#getIsPremium.bind(this),
709
212
  getInputPeer: this.getInputPeer.bind(this),
710
213
  getInputChannel: this.getInputChannel.bind(this),
711
214
  getInputUser: this.getInputUser.bind(this),
712
- getInputPeerChatId: __classPrivateFieldGet(this, _Client_instances, "m", _Client_getInputPeerChatId).bind(this),
215
+ getInputPeerChatId: this.#getInputPeerChatId.bind(this),
713
216
  getEntity: this[getEntity].bind(this),
714
- handleUpdate: __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).bind(this),
715
- parseMode: __classPrivateFieldGet(this, _Client_parseMode, "f"),
716
- outgoingMessages: __classPrivateFieldGet(this, _Client_outgoingMessages, "f"),
217
+ handleUpdate: this.#queueHandleCtxUpdate.bind(this),
218
+ parseMode: this.#parseMode,
219
+ outgoingMessages: this.#outgoingMessages,
717
220
  dropPendingUpdates: params?.dropPendingUpdates,
718
221
  disconnected: () => this.disconnected,
719
222
  langPack: this.platform,
720
223
  langCode: this.language,
721
224
  };
722
225
  // 2_
723
- __classPrivateFieldSet(this, _Client_accountManager, new AccountManager(c), "f");
724
- __classPrivateFieldSet(this, _Client_botInfoManager, new BotInfoManager(c), "f");
725
- __classPrivateFieldSet(this, _Client_businessConnectionManager, new BusinessConnectionManager(c), "f");
726
- const fileManager = __classPrivateFieldSet(this, _Client_fileManager, new FileManager(c), "f");
727
- __classPrivateFieldSet(this, _Client_networkStatisticsManager, new NetworkStatisticsManager(c), "f");
728
- __classPrivateFieldSet(this, _Client_paymentManager, new PaymentManager(c), "f");
729
- __classPrivateFieldSet(this, _Client_reactionManager, new ReactionManager(c), "f");
730
- __classPrivateFieldSet(this, _Client_translationsManager, new TranslationsManager(c), "f");
731
- __classPrivateFieldSet(this, _Client_updateManager, new UpdateManager(c), "f");
226
+ this.#accountManager = new AccountManager(c);
227
+ this.#botInfoManager = new BotInfoManager(c);
228
+ this.#businessConnectionManager = new BusinessConnectionManager(c);
229
+ const fileManager = this.#fileManager = new FileManager(c);
230
+ this.#networkStatisticsManager = new NetworkStatisticsManager(c);
231
+ this.#paymentManager = new PaymentManager(c);
232
+ this.#reactionManager = new ReactionManager(c);
233
+ this.#translationsManager = new TranslationsManager(c);
234
+ this.#updateManager = new UpdateManager(c);
732
235
  // 3_
733
- const messageManager = __classPrivateFieldSet(this, _Client_messageManager, new MessageManager({ ...c, fileManager }), "f");
734
- __classPrivateFieldSet(this, _Client_videoChatManager, new VideoChatManager({ ...c, fileManager }), "f");
236
+ const messageManager = this.#messageManager = new MessageManager({ ...c, fileManager });
237
+ this.#videoChatManager = new VideoChatManager({ ...c, fileManager });
735
238
  // 4_
736
- __classPrivateFieldSet(this, _Client_callbackQueryManager, new CallbackQueryManager({ ...c, messageManager }), "f");
737
- __classPrivateFieldSet(this, _Client_chatListManager, new ChatListManager({ ...c, fileManager, messageManager }), "f");
738
- __classPrivateFieldSet(this, _Client_chatManager, new ChatManager({ ...c, fileManager, messageManager }), "f");
739
- __classPrivateFieldSet(this, _Client_forumManager, new ForumManager({ ...c, messageManager }), "f");
740
- __classPrivateFieldSet(this, _Client_giftManager, new GiftManager({ ...c, messageManager }), "f");
741
- __classPrivateFieldSet(this, _Client_inlineQueryManager, new InlineQueryManager({ ...c, messageManager }), "f");
742
- __classPrivateFieldSet(this, _Client_linkPreviewManager, new LinkPreviewManager({ ...c, messageManager }), "f");
743
- __classPrivateFieldSet(this, _Client_pollManager, new PollManager({ ...c, messageManager }), "f");
744
- __classPrivateFieldSet(this, _Client_storyManager, new StoryManager({ ...c, fileManager, messageManager }), "f");
745
- __classPrivateFieldGet(this, _Client_updateManager, "f").setUpdateHandler(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).bind(this));
239
+ this.#callbackQueryManager = new CallbackQueryManager({ ...c, messageManager });
240
+ this.#chatListManager = new ChatListManager({ ...c, fileManager, messageManager });
241
+ this.#chatManager = new ChatManager({ ...c, fileManager, messageManager });
242
+ this.#forumManager = new ForumManager({ ...c, messageManager });
243
+ this.#giftManager = new GiftManager({ ...c, messageManager });
244
+ this.#inlineQueryManager = new InlineQueryManager({ ...c, messageManager });
245
+ this.#linkPreviewManager = new LinkPreviewManager({ ...c, messageManager });
246
+ this.#pollManager = new PollManager({ ...c, messageManager });
247
+ this.#storyManager = new StoryManager({ ...c, fileManager, messageManager });
248
+ this.#updateManager.setUpdateHandler(this.#handleUpdate.bind(this));
746
249
  if (params?.defaultHandlers ?? true) {
747
250
  this.invoke.use(async ({ error }, next) => {
748
251
  if (error instanceof FloodWait && error.seconds <= 10) {
@@ -756,123 +259,622 @@ export class Client extends Composer {
756
259
  });
757
260
  }
758
261
  }
262
+ #setMainClient(client) {
263
+ this.#disconnectAllClients();
264
+ this.#clients = [client];
265
+ client.handlers.onUpdate = (updates) => {
266
+ this.#updateManager.processUpdates(updates, true, null);
267
+ this.#lastUpdates = new Date();
268
+ };
269
+ client.handlers.onDeserializationError = async () => {
270
+ await this.#updateManager.recoverUpdateGap("deserialization error");
271
+ };
272
+ client.handlers.onNewServerSalt = async (serverSalt) => {
273
+ await this.storage.setServerSalt(serverSalt);
274
+ };
275
+ client.onConnectionStateChange = this.#onConnectionStateChange.bind(this);
276
+ }
277
+ #newClient(dc, main, cdn) {
278
+ const client = new ClientEncrypted(dc, this.#apiId, {
279
+ appVersion: this.appVersion,
280
+ deviceModel: this.deviceModel,
281
+ langCode: this.language,
282
+ langPack: this.platform,
283
+ systemLangCode: this.systemLangCode,
284
+ systemVersion: this.systemVersion,
285
+ transportProvider: this.#transportProvider,
286
+ cdn,
287
+ disableUpdates: !main || cdn,
288
+ publicKeys: this.#publicKeys,
289
+ });
290
+ client.connectionCallback = this.#networkStatisticsManager.getTransportReadWriteCallback(cdn);
291
+ return client;
292
+ }
293
+ #disconnectAllClients() {
294
+ for (const client of this.#clients) {
295
+ client.disconnect();
296
+ }
297
+ for (const pool of Object.values(this.#downloadPools)) {
298
+ pool.disconnect();
299
+ }
300
+ for (const pool of Object.values(this.#uploadPools)) {
301
+ pool.disconnect();
302
+ }
303
+ }
304
+ get #client() {
305
+ return this.#clients[0];
306
+ }
759
307
  // direct ClientEncrypted property proxies
760
308
  get connected() {
761
- return __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.connected ?? false;
309
+ return this.#client?.connected ?? false;
762
310
  }
763
311
  get disconnected() {
764
- return __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.disconnected ?? true;
312
+ return this.#client?.disconnected ?? true;
313
+ }
314
+ #constructContext = async (update) => {
315
+ const msg = "message" in update ? update.message : "editedMessage" in update ? update.editedMessage : "scheduledMessage" in update ? update.scheduledMessage : "callbackQuery" in update ? update.callbackQuery.message : undefined;
316
+ const reactions = "messageInteractions" in update ? update.messageInteractions : undefined;
317
+ const mustGetMsg = () => {
318
+ if (msg !== undefined) {
319
+ return { chatId: msg.chat.id, messageId: msg.id, businessConnectionId: msg.businessConnectionId, senderId: msg.from?.id, userId: msg.from?.id };
320
+ }
321
+ else if (reactions !== undefined) {
322
+ return { chatId: reactions.chatId, messageId: reactions.messageId };
323
+ }
324
+ else {
325
+ unreachable();
326
+ }
327
+ };
328
+ const mustGetUserId = () => {
329
+ if (msg?.from) {
330
+ return msg.from.id;
331
+ }
332
+ else if ("callbackQuery" in update) {
333
+ return update.callbackQuery.from.id;
334
+ }
335
+ else if ("chosenInlineResult" in update) {
336
+ return update.chosenInlineResult.from.id;
337
+ }
338
+ else {
339
+ unreachable();
340
+ }
341
+ };
342
+ const mustGetInlineMsgId = () => {
343
+ if ("chosenInlineResult" in update) {
344
+ if (update.chosenInlineResult.inlineMessageId) {
345
+ return update.chosenInlineResult.inlineMessageId;
346
+ }
347
+ }
348
+ else if ("callbackQuery" in update) {
349
+ if (update.callbackQuery.inlineMessageId) {
350
+ return update.callbackQuery.inlineMessageId;
351
+ }
352
+ }
353
+ unreachable();
354
+ };
355
+ const chat_ = "messageReactions" in update ? update.messageReactions.chat : "messageReactionCount" in update ? update.messageReactionCount.chat : "chatMember" in update ? update.chatMember.chat : "myChatMember" in update ? update.myChatMember.chat : "joinRequest" in update ? update.joinRequest.chat : "story" in update ? update.story.chat : undefined;
356
+ const chat = chat_ ?? msg?.chat;
357
+ const from = "callbackQuery" in update ? update.callbackQuery.from : "inlineQuery" in update ? update.inlineQuery.from : "chatMember" in update ? update.chatMember.from : "myChatMember" in update ? update.myChatMember.from : "messageReactions" in update ? update.messageReactions.user : "preCheckoutQuery" in update ? update.preCheckoutQuery.from : "joinRequest" in update ? update.joinRequest.from : "businessConnection" in update ? update.businessConnection.user : "pollAnswer" in update ? update.pollAnswer.from : msg?.from ? msg.from : undefined;
358
+ const getReplyTo = (quote, chatId, messageId) => {
359
+ if ("story" in update) {
360
+ return { chatId: update.story.chat.id, storyId: update.story.id };
361
+ }
362
+ const isPrivate = chatId > 0;
363
+ const shouldQuote = quote === undefined ? !isPrivate : quote;
364
+ return shouldQuote ? { messageId } : undefined;
365
+ };
366
+ const me = "connectionState" in update ? this.#lastGetMe : ("authorizationState" in update && !update.authorizationState.authorized) ? this.#lastGetMe : await this.#getMe();
367
+ const context = {
368
+ ...update,
369
+ client: this,
370
+ me: (me == null ? undefined : me),
371
+ msg: msg,
372
+ chat: chat,
373
+ from: from,
374
+ get toJSON() {
375
+ return () => update;
376
+ },
377
+ reply: (text, params) => {
378
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
379
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
380
+ return this.sendMessage(chatId, text, { ...params, replyTo, businessConnectionId });
381
+ },
382
+ replyPoll: (question, options, params) => {
383
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
384
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
385
+ return this.sendPoll(chatId, question, options, { ...params, replyTo, businessConnectionId });
386
+ },
387
+ replyPhoto: (photo, params) => {
388
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
389
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
390
+ return this.sendPhoto(chatId, photo, { ...params, replyTo, businessConnectionId });
391
+ },
392
+ replyMediaGroup: (media, params) => {
393
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
394
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
395
+ return this.sendMediaGroup(chatId, media, { ...params, replyTo, businessConnectionId });
396
+ },
397
+ replyInvoice: (title, description, payload, currency, prices, params) => {
398
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
399
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
400
+ return this.sendInvoice(chatId, title, description, payload, currency, prices, { ...params, replyTo, businessConnectionId });
401
+ },
402
+ replyDocument: (document, params) => {
403
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
404
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
405
+ return this.sendDocument(chatId, document, { ...params, replyTo, businessConnectionId });
406
+ },
407
+ replySticker: (sticker, params) => {
408
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
409
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
410
+ return this.sendSticker(chatId, sticker, { ...params, replyTo, businessConnectionId });
411
+ },
412
+ replyContact: (firstName, number, params) => {
413
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
414
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
415
+ return this.sendContact(chatId, firstName, number, { ...params, replyTo, businessConnectionId });
416
+ },
417
+ replyLocation: (latitude, longitude, params) => {
418
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
419
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
420
+ return this.sendLocation(chatId, latitude, longitude, { ...params, replyTo, businessConnectionId });
421
+ },
422
+ replyDice: (params) => {
423
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
424
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
425
+ return this.sendDice(chatId, { ...params, replyTo, businessConnectionId });
426
+ },
427
+ replyVenue: (latitude, longitude, title, address, params) => {
428
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
429
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
430
+ return this.sendVenue(chatId, latitude, longitude, title, address, { ...params, replyTo, businessConnectionId });
431
+ },
432
+ replyVideo: (video, params) => {
433
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
434
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
435
+ return this.sendVideo(chatId, video, { ...params, replyTo, businessConnectionId });
436
+ },
437
+ replyAnimation: (document, params) => {
438
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
439
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
440
+ return this.sendAnimation(chatId, document, { ...params, replyTo, businessConnectionId });
441
+ },
442
+ replyVoice: (document, params) => {
443
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
444
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
445
+ return this.sendVoice(chatId, document, { ...params, replyTo, businessConnectionId });
446
+ },
447
+ replyAudio: (document, params) => {
448
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
449
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
450
+ return this.sendAudio(chatId, document, { ...params, replyTo, businessConnectionId });
451
+ },
452
+ replyVideoNote: (videoNote, params) => {
453
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
454
+ const replyTo = getReplyTo(params?.quote, chatId, messageId);
455
+ return this.sendVideoNote(chatId, videoNote, { ...params, replyTo, businessConnectionId });
456
+ },
457
+ delete: () => {
458
+ const { chatId, messageId } = mustGetMsg();
459
+ return this.deleteMessage(chatId, messageId);
460
+ },
461
+ forward: (to, params) => {
462
+ const { chatId, messageId } = mustGetMsg();
463
+ return this.forwardMessage(chatId, to, messageId, params);
464
+ },
465
+ pin: (params) => {
466
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
467
+ return this.pinMessage(chatId, messageId, { ...params, businessConnectionId });
468
+ },
469
+ unpin: () => {
470
+ const { chatId, messageId, businessConnectionId } = mustGetMsg();
471
+ return this.unpinMessage(chatId, messageId, { businessConnectionId });
472
+ },
473
+ banSender: (params) => {
474
+ const { chatId, senderId } = mustGetMsg();
475
+ if (!senderId) {
476
+ unreachable();
477
+ }
478
+ return this.banChatMember(chatId, senderId, params);
479
+ },
480
+ kickSender: () => {
481
+ const { chatId, senderId } = mustGetMsg();
482
+ if (!senderId) {
483
+ unreachable();
484
+ }
485
+ return this.kickChatMember(chatId, senderId);
486
+ },
487
+ setSenderRights: (params) => {
488
+ const { chatId, senderId } = mustGetMsg();
489
+ if (!senderId) {
490
+ unreachable();
491
+ }
492
+ return this.setChatMemberRights(chatId, senderId, params);
493
+ },
494
+ getChatAdministrators: () => {
495
+ const { chatId } = mustGetMsg();
496
+ return this.getChatAdministrators(chatId);
497
+ },
498
+ react: (reactions, params) => {
499
+ const { chatId, messageId } = mustGetMsg();
500
+ return this.setReactions(chatId, messageId, reactions, params);
501
+ },
502
+ answerCallbackQuery: (params) => {
503
+ if (!("callbackQuery" in update)) {
504
+ unreachable();
505
+ }
506
+ return this.answerCallbackQuery(update.callbackQuery.id, params);
507
+ },
508
+ answerInlineQuery: (results, params) => {
509
+ if (!("inlineQuery" in update)) {
510
+ unreachable();
511
+ }
512
+ return this.answerInlineQuery(update.inlineQuery.id, results, params);
513
+ },
514
+ sendChatAction: (chatAction, params) => {
515
+ const { chatId } = mustGetMsg();
516
+ return this.sendChatAction(chatId, chatAction, params);
517
+ },
518
+ editInlineMessageText: (text, params) => {
519
+ const inlineMessageId = mustGetInlineMsgId();
520
+ return this.editInlineMessageText(inlineMessageId, text, params);
521
+ },
522
+ editInlineMessageMedia: (media, params) => {
523
+ const inlineMessageId = mustGetInlineMsgId();
524
+ return this.editInlineMessageMedia(inlineMessageId, media, params);
525
+ },
526
+ editInlineMessageCaption: (params) => {
527
+ const inlineMessageId = mustGetInlineMsgId();
528
+ return this.editInlineMessageCaption(inlineMessageId, params);
529
+ },
530
+ editInlineMessageLiveLocation: (latitude, longitude, params) => {
531
+ const inlineMessageId = mustGetInlineMsgId();
532
+ return this.editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
533
+ },
534
+ editInlineMessageReplyMarkup: (params) => {
535
+ const inlineMessageId = mustGetInlineMsgId();
536
+ return this.editInlineMessageReplyMarkup(inlineMessageId, params);
537
+ },
538
+ editMessageText: (messageId, text, params) => {
539
+ const { chatId } = mustGetMsg();
540
+ return this.editMessageText(chatId, messageId, text, params);
541
+ },
542
+ editMessageCaption: (messageId, params) => {
543
+ const { chatId } = mustGetMsg();
544
+ return this.editMessageCaption(chatId, messageId, params);
545
+ },
546
+ editMessageMedia: (messageId, media, params) => {
547
+ const { chatId } = mustGetMsg();
548
+ return this.editMessageMedia(chatId, messageId, media, params);
549
+ },
550
+ editMessageLiveLocation: (messageId, latitude, longitude, params) => {
551
+ const { chatId } = mustGetMsg();
552
+ return this.editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
553
+ },
554
+ editMessageReplyMarkup: (messageId, params) => {
555
+ const { chatId } = mustGetMsg();
556
+ return this.editMessageReplyMarkup(chatId, messageId, params);
557
+ },
558
+ getMessage: (messageId) => {
559
+ const { chatId } = mustGetMsg();
560
+ return this.getMessage(chatId, messageId);
561
+ },
562
+ getMessages: (messageIds) => {
563
+ const { chatId } = mustGetMsg();
564
+ return this.getMessages(chatId, messageIds);
565
+ },
566
+ forwardMessage: (to, messageId, params) => {
567
+ const { chatId } = mustGetMsg();
568
+ return this.forwardMessage(chatId, to, messageId, params);
569
+ },
570
+ forwardMessages: (to, messageIds, params) => {
571
+ const { chatId } = mustGetMsg();
572
+ return this.forwardMessages(chatId, to, messageIds, params);
573
+ },
574
+ deleteMessage: (messageId, params) => {
575
+ const { chatId } = mustGetMsg();
576
+ return this.deleteMessage(chatId, messageId, params);
577
+ },
578
+ deleteMessages: (messageIds, params) => {
579
+ const { chatId } = mustGetMsg();
580
+ return this.deleteMessages(chatId, messageIds, params);
581
+ },
582
+ pinMessage: (messageId, params) => {
583
+ const { chatId } = mustGetMsg();
584
+ return this.pinMessage(chatId, messageId, params);
585
+ },
586
+ unpinMessage: (messageId) => {
587
+ const { chatId } = mustGetMsg();
588
+ return this.unpinMessage(chatId, messageId);
589
+ },
590
+ unpinMessages: () => {
591
+ const { chatId } = mustGetMsg();
592
+ return this.unpinMessages(chatId);
593
+ },
594
+ setAvailableReactions: (availableReactions) => {
595
+ const { chatId } = mustGetMsg();
596
+ return this.setAvailableReactions(chatId, availableReactions);
597
+ },
598
+ addReaction: (messageId, reaction, params) => {
599
+ const { chatId } = mustGetMsg();
600
+ return this.addReaction(chatId, messageId, reaction, params);
601
+ },
602
+ removeReaction: (messageId, reaction) => {
603
+ const { chatId } = mustGetMsg();
604
+ return this.removeReaction(chatId, messageId, reaction);
605
+ },
606
+ setReactions: (messageId, reactions, params) => {
607
+ const { chatId } = mustGetMsg();
608
+ return this.setReactions(chatId, messageId, reactions, params);
609
+ },
610
+ read: () => {
611
+ const { chatId, messageId } = mustGetMsg();
612
+ return this.readMessages(chatId, messageId);
613
+ },
614
+ setChatPhoto: (photo, params) => {
615
+ const { chatId } = mustGetMsg();
616
+ return this.setChatPhoto(chatId, photo, params);
617
+ },
618
+ deleteChatPhoto: () => {
619
+ const { chatId } = mustGetMsg();
620
+ return this.deleteChatPhoto(chatId);
621
+ },
622
+ banChatMember: (memberId, params) => {
623
+ const { chatId } = mustGetMsg();
624
+ return this.banChatMember(chatId, memberId, params);
625
+ },
626
+ unbanChatMember: (memberId) => {
627
+ const { chatId } = mustGetMsg();
628
+ return this.unbanChatMember(chatId, memberId);
629
+ },
630
+ kickChatMember: (memberId) => {
631
+ const { chatId } = mustGetMsg();
632
+ return this.kickChatMember(chatId, memberId);
633
+ },
634
+ setChatMemberRights: (memberId, params) => {
635
+ const { chatId } = mustGetMsg();
636
+ return this.setChatMemberRights(chatId, memberId, params);
637
+ },
638
+ deleteChatMemberMessages: (userId) => {
639
+ const { chatId } = mustGetMsg();
640
+ return this.deleteChatMemberMessages(chatId, userId);
641
+ },
642
+ searchMessages: (query, params) => {
643
+ const { chatId } = mustGetMsg();
644
+ return this.searchMessages(chatId, query, params);
645
+ },
646
+ setBoostsRequiredToCircumventRestrictions: (boosts) => {
647
+ const { chatId } = mustGetMsg();
648
+ return this.setBoostsRequiredToCircumventRestrictions(chatId, boosts);
649
+ },
650
+ createInviteLink: (params) => {
651
+ const { chatId } = mustGetMsg();
652
+ return this.createInviteLink(chatId, params);
653
+ },
654
+ getCreatedInviteLinks: (params) => {
655
+ const { chatId } = mustGetMsg();
656
+ return this.getCreatedInviteLinks(chatId, params);
657
+ },
658
+ leave: () => {
659
+ const { chatId } = mustGetMsg();
660
+ return this.leaveChat(chatId);
661
+ },
662
+ block: () => {
663
+ return this.blockUser(mustGetUserId());
664
+ },
665
+ unblock: () => {
666
+ return this.unblockUser(mustGetUserId());
667
+ },
668
+ getChatMember: (userId) => {
669
+ const { chatId } = mustGetMsg();
670
+ return this.getChatMember(chatId, userId);
671
+ },
672
+ getChatMembers: (params) => {
673
+ const { chatId } = mustGetMsg();
674
+ return this.getChatMembers(chatId, params);
675
+ },
676
+ setChatStickerSet: (setName) => {
677
+ const { chatId } = mustGetMsg();
678
+ return this.setChatStickerSet(chatId, setName);
679
+ },
680
+ deleteChatStickerSet: () => {
681
+ const { chatId } = mustGetMsg();
682
+ return this.deleteChatStickerSet(chatId);
683
+ },
684
+ getBusinessConnection: () => {
685
+ const { businessConnectionId } = mustGetMsg();
686
+ if (!businessConnectionId) {
687
+ unreachable();
688
+ }
689
+ return this.getBusinessConnection(businessConnectionId);
690
+ },
691
+ answerPreCheckoutQuery: (ok, params) => {
692
+ if (!("preCheckoutQuery" in update)) {
693
+ unreachable();
694
+ }
695
+ return this.answerPreCheckoutQuery(update.preCheckoutQuery.id, ok, params);
696
+ },
697
+ approveJoinRequest: () => {
698
+ const { chatId, userId } = mustGetMsg();
699
+ if (!userId) {
700
+ unreachable();
701
+ }
702
+ return this.approveJoinRequest(chatId, userId);
703
+ },
704
+ declineJoinRequest: () => {
705
+ const { chatId, userId } = mustGetMsg();
706
+ if (!userId) {
707
+ unreachable();
708
+ }
709
+ return this.declineJoinRequest(chatId, userId);
710
+ },
711
+ };
712
+ return cleanObject(context);
713
+ };
714
+ #propagateConnectionState(connectionState) {
715
+ this.#queueHandleCtxUpdate({ connectionState });
716
+ this.#lastPropagatedConnectionState = connectionState;
717
+ }
718
+ #lastPropagatedConnectionState = null;
719
+ #stateChangeHandler = ((connected) => {
720
+ const connectionState = connected ? "ready" : "notConnected";
721
+ if (this.#lastPropagatedConnectionState != connectionState) {
722
+ this.#propagateConnectionState(connectionState);
723
+ }
724
+ }).bind(this);
725
+ #storageInited = false;
726
+ async #initStorage() {
727
+ if (!this.#storageInited) {
728
+ await this.storage.initialize();
729
+ if (!this.#guaranteeUpdateDelivery) {
730
+ await this.storage.deleteUpdates();
731
+ }
732
+ this.#storageInited = true;
733
+ }
765
734
  }
735
+ #connectMutex = new Mutex();
766
736
  /**
767
737
  * Loads the session if `setDc` was not called, initializes and connnects
768
738
  * a `ClientPlain` to generate auth key if there was none, and connects the client.
769
739
  * Before establishing the connection, the session is saved.
770
740
  */
771
741
  async connect() {
772
- const unlock = await __classPrivateFieldGet(this, _Client_connectMutex, "f").lock();
742
+ const unlock = await this.#connectMutex.lock();
773
743
  try {
774
744
  if (this.connected) {
775
745
  return;
776
746
  }
777
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
778
- if (__classPrivateFieldGet(this, _Client_authString, "f") && !__classPrivateFieldGet(this, _Client_authStringImported, "f")) {
779
- await this.importAuthString(__classPrivateFieldGet(this, _Client_authString, "f"));
747
+ await this.#initStorage();
748
+ if (this.#authString && !this.#authStringImported) {
749
+ await this.importAuthString(this.#authString);
780
750
  }
781
751
  const [authKey, dc] = await Promise.all([this.storage.getAuthKey(), this.storage.getDc()]);
782
752
  if (authKey != null && dc != null) {
783
- if (!__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get) || __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc != dc) {
784
- __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.disconnect();
785
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMainClient).call(this, __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, true, false));
753
+ if (!this.#client || this.#client.dc != dc) {
754
+ this.#client?.disconnect();
755
+ this.#setMainClient(this.#newClient(dc, true, false));
786
756
  }
787
- await __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).setAuthKey(authKey);
788
- if (__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).serverSalt == 0n) {
789
- __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).serverSalt = await this.storage.getServerSalt() ?? 0n;
757
+ await this.#client.setAuthKey(authKey);
758
+ if (this.#client.serverSalt == 0n) {
759
+ this.#client.serverSalt = await this.storage.getServerSalt() ?? 0n;
790
760
  }
791
761
  }
792
762
  else {
793
- const dc = await this.storage.getDc() ?? __classPrivateFieldGet(this, _Client_initialDc, "f");
794
- if (!__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get) || __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc != dc) {
795
- __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.disconnect();
796
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMainClient).call(this, __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, true, false));
763
+ const dc = await this.storage.getDc() ?? this.#initialDc;
764
+ if (!this.#client || this.#client.dc != dc) {
765
+ this.#client?.disconnect();
766
+ this.#setMainClient(this.#newClient(dc, true, false));
797
767
  }
798
768
  }
799
- await __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).connect();
800
- await Promise.all([this.storage.setAuthKey(__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).authKey), this.storage.setDc(__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc), this.storage.setServerSalt(__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).serverSalt)]);
801
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_startUpdateGapRecoveryLoop).call(this);
802
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_startClientDisconnectionLoop).call(this);
769
+ await this.#client.connect();
770
+ await Promise.all([this.storage.setAuthKey(this.#client.authKey), this.storage.setDc(this.#client.dc), this.storage.setServerSalt(this.#client.serverSalt)]);
771
+ this.#startUpdateGapRecoveryLoop();
772
+ this.#startClientDisconnectionLoop();
803
773
  }
804
774
  finally {
805
775
  unlock();
806
776
  }
807
777
  }
808
- async [(_Client_clients = new WeakMap(), _Client_downloadPools = new WeakMap(), _Client_uploadPools = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_accountManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_businessConnectionManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_paymentManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_translationsManager = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_videoChatManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_chatManager = new WeakMap(), _Client_forumManager = new WeakMap(), _Client_giftManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_linkPreviewManager = new WeakMap(), _Client_pollManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_managers = new WeakMap(), _Client_storage_ = new WeakMap(), _Client_messageStorage_ = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_apiId = new WeakMap(), _Client_apiHash = new WeakMap(), _Client_transportProvider = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_outgoingMessages = new WeakMap(), _Client_persistCache = new WeakMap(), _Client_disableUpdates = new WeakMap(), _Client_authString = new WeakMap(), _Client_initialDc = new WeakMap(), _Client_L = new WeakMap(), _Client_LsignIn = new WeakMap(), _Client_LupdateGapRecoveryLoop = new WeakMap(), _Client_LhandleMigrationError = new WeakMap(), _Client_Lmin = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_stateChangeHandler = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_updateGapRecoveryLoopAbortController = new WeakMap(), _Client_clientDisconnectionLoopAbortController = new WeakMap(), _Client_getMainClientMutex = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_authStringImported = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_previouslyConnected = new WeakMap(), _Client_lastConnectionState = new WeakMap(), _Client_instances = new WeakSet(), _Client_setMainClient = function _Client_setMainClient(client) {
809
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_disconnectAllClients).call(this);
810
- __classPrivateFieldSet(this, _Client_clients, [client], "f");
811
- client.handlers.onUpdate = (updates) => {
812
- __classPrivateFieldGet(this, _Client_updateManager, "f").processUpdates(updates, true, null);
813
- __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
814
- };
815
- client.handlers.onDeserializationError = async () => {
816
- await __classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("deserialization error");
817
- };
818
- client.handlers.onNewServerSalt = async (serverSalt) => {
819
- await this.storage.setServerSalt(serverSalt);
820
- };
821
- client.onConnectionStateChange = __classPrivateFieldGet(this, _Client_instances, "m", _Client_onConnectionStateChange).bind(this);
822
- }, _Client_newClient = function _Client_newClient(dc, main, cdn) {
823
- const client = new ClientEncrypted(dc, __classPrivateFieldGet(this, _Client_apiId, "f"), {
824
- appVersion: this.appVersion,
825
- deviceModel: this.deviceModel,
826
- langCode: this.language,
827
- langPack: this.platform,
828
- systemLangCode: this.systemLangCode,
829
- systemVersion: this.systemVersion,
830
- transportProvider: __classPrivateFieldGet(this, _Client_transportProvider, "f"),
831
- cdn,
832
- disableUpdates: !main || cdn,
833
- publicKeys: __classPrivateFieldGet(this, _Client_publicKeys, "f"),
834
- });
835
- client.connectionCallback = __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getTransportReadWriteCallback(cdn);
836
- return client;
837
- }, _Client_disconnectAllClients = function _Client_disconnectAllClients() {
838
- for (const client of __classPrivateFieldGet(this, _Client_clients, "f")) {
839
- client.disconnect();
840
- }
841
- for (const pool of Object.values(__classPrivateFieldGet(this, _Client_downloadPools, "f"))) {
842
- pool.disconnect();
843
- }
844
- for (const pool of Object.values(__classPrivateFieldGet(this, _Client_uploadPools, "f"))) {
845
- pool.disconnect();
846
- }
847
- }, _Client_client_get = function _Client_client_get() {
848
- return __classPrivateFieldGet(this, _Client_clients, "f")[0];
849
- }, _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
850
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
851
- __classPrivateFieldSet(this, _Client_lastPropagatedConnectionState, connectionState, "f");
852
- }, _Client_initStorage = async function _Client_initStorage() {
853
- if (!__classPrivateFieldGet(this, _Client_storageInited, "f")) {
854
- await this.storage.initialize();
855
- if (!__classPrivateFieldGet(this, _Client_guaranteeUpdateDelivery, "f")) {
856
- await this.storage.deleteUpdates();
857
- }
858
- __classPrivateFieldSet(this, _Client_storageInited, true, "f");
859
- }
860
- }, handleMigrationError)](err) {
778
+ async [handleMigrationError](err) {
861
779
  let newDc = String(err.dc);
862
- if (Math.abs(getDcId(__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc, __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).cdn)) >= 10_000) {
780
+ if (Math.abs(getDcId(this.#client.dc, this.#client.cdn)) >= 10_000) {
863
781
  newDc += "-test";
864
782
  }
865
783
  this.disconnect();
866
784
  await this.storage.setDc(newDc);
867
785
  await this.storage.setAuthKey(null);
868
786
  await this.connect();
869
- __classPrivateFieldGet(this, _Client_LhandleMigrationError, "f").debug(`migrated to DC${newDc}`);
787
+ this.#LhandleMigrationError.debug(`migrated to DC${newDc}`);
870
788
  }
871
789
  disconnect() {
872
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_disconnectAllClients).call(this);
873
- __classPrivateFieldGet(this, _Client_clientDisconnectionLoopAbortController, "f")?.abort();
874
- __classPrivateFieldGet(this, _Client_updateGapRecoveryLoopAbortController, "f")?.abort();
875
- __classPrivateFieldGet(this, _Client_updateManager, "f").closeAllChats();
790
+ this.#disconnectAllClients();
791
+ this.#clientDisconnectionLoopAbortController?.abort();
792
+ this.#updateGapRecoveryLoopAbortController?.abort();
793
+ this.#updateManager.closeAllChats();
794
+ }
795
+ #lastPropagatedAuthorizationState = null;
796
+ async #propagateAuthorizationState(authorized) {
797
+ if (this.#lastPropagatedAuthorizationState != authorized) {
798
+ await this.#handleCtxUpdate({ authorizationState: { authorized } });
799
+ this.#lastPropagatedAuthorizationState = authorized;
800
+ }
801
+ }
802
+ async #getSelfId() {
803
+ const id = await this.storage.getAccountId();
804
+ if (id == null) {
805
+ throw new Error("Unauthorized");
806
+ }
807
+ return id;
808
+ }
809
+ async #getIsPremium() {
810
+ const maybeIsPremium = await this.storage.getIsPremium();
811
+ if (maybeIsPremium != null) {
812
+ return maybeIsPremium;
813
+ }
814
+ return this.#lastGetMe?.isPremium ?? false;
815
+ }
816
+ #lastUpdates = new Date();
817
+ #updateGapRecoveryLoopAbortController;
818
+ #startUpdateGapRecoveryLoop() {
819
+ drop(this.#updateGapRecoveryLoop());
820
+ }
821
+ async #updateGapRecoveryLoop() {
822
+ this.#updateGapRecoveryLoopAbortController?.abort();
823
+ const controller = this.#updateGapRecoveryLoopAbortController = new AbortController();
824
+ while (this.connected) {
825
+ try {
826
+ await delay(60 * SECOND, { signal: controller.signal });
827
+ if (!this.connected) {
828
+ break;
829
+ }
830
+ controller.signal.throwIfAborted();
831
+ if (Date.now() - this.#lastUpdates.getTime() >= 15 * MINUTE) {
832
+ drop(this.#updateManager.recoverUpdateGap("lastUpdates").then(() => {
833
+ this.#lastUpdates = new Date();
834
+ }));
835
+ }
836
+ }
837
+ catch (err) {
838
+ if (err instanceof DOMException && err.name == "AbortError") {
839
+ break;
840
+ }
841
+ else if (!this.connected) {
842
+ break;
843
+ }
844
+ this.#LupdateGapRecoveryLoop.error(err);
845
+ }
846
+ }
847
+ }
848
+ #clientDisconnectionLoopAbortController;
849
+ #startClientDisconnectionLoop() {
850
+ drop(this.#clientDisconnectionLoop());
851
+ }
852
+ async #clientDisconnectionLoop() {
853
+ const controller = this.#clientDisconnectionLoopAbortController = new AbortController();
854
+ while (this.connected) {
855
+ try {
856
+ await delay(60 * SECOND, { signal: controller.signal });
857
+ if (!this.connected) {
858
+ break;
859
+ }
860
+ controller.signal.throwIfAborted();
861
+ const now = Date.now();
862
+ const disconnectAfter = 5 * MINUTE;
863
+ this.#clients.map((client, i) => {
864
+ if (i > 0 && !client.disconnected && client.lastRequest && now - client.lastRequest.getTime() >= disconnectAfter) {
865
+ client?.disconnect();
866
+ }
867
+ });
868
+ }
869
+ catch (err) {
870
+ if (err instanceof DOMException && err.name == "AbortError") {
871
+ break;
872
+ }
873
+ else if (!this.connected) {
874
+ break;
875
+ }
876
+ }
877
+ }
876
878
  }
877
879
  /**
878
880
  * Signs in using the provided parameters if not already signed in.
@@ -884,10 +886,10 @@ export class Client extends Composer {
884
886
  */
885
887
  async signIn(params) {
886
888
  try {
887
- await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("signIn");
888
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
889
- drop(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("signIn"));
890
- __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("already signed in");
889
+ await this.#updateManager.fetchState("signIn");
890
+ await this.#propagateAuthorizationState(true);
891
+ drop(this.#updateManager.recoverUpdateGap("signIn"));
892
+ this.#LsignIn.debug("already signed in");
891
893
  return;
892
894
  }
893
895
  catch (err) {
@@ -895,10 +897,10 @@ export class Client extends Composer {
895
897
  throw err;
896
898
  }
897
899
  }
898
- if (!__classPrivateFieldGet(this, _Client_apiId, "f")) {
900
+ if (!this.#apiId) {
899
901
  throw new InputError("apiId not set");
900
902
  }
901
- if (!__classPrivateFieldGet(this, _Client_apiHash, "f")) {
903
+ if (!this.#apiHash) {
902
904
  throw new InputError("apiHash not set");
903
905
  }
904
906
  if (typeof params === "undefined") {
@@ -910,11 +912,11 @@ export class Client extends Composer {
910
912
  params = { phone: () => mustPrompt("Phone number:"), code: () => mustPrompt("Verification code:"), password: () => mustPrompt("Password:") };
911
913
  }
912
914
  }
913
- __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("authorizing with", typeof params === "string" ? "bot token" : Api.is("auth.exportedAuthorization", params) ? "exported authorization" : "AuthorizeUserParams");
915
+ this.#LsignIn.debug("authorizing with", typeof params === "string" ? "bot token" : Api.is("auth.exportedAuthorization", params) ? "exported authorization" : "AuthorizeUserParams");
914
916
  if (params && "botToken" in params) {
915
917
  while (true) {
916
918
  try {
917
- const auth = await this.invoke({ _: "auth.importBotAuthorization", api_id: __classPrivateFieldGet(this, _Client_apiId, "f"), api_hash: __classPrivateFieldGet(this, _Client_apiHash, "f"), bot_auth_token: params.botToken, flags: 0 });
919
+ const auth = await this.invoke({ _: "auth.importBotAuthorization", api_id: this.#apiId, api_hash: this.#apiHash, bot_auth_token: params.botToken, flags: 0 });
918
920
  await this.storage.setAccountId(Number(Api.as("auth.authorization", auth).user.id));
919
921
  await this.storage.setAccountType("bot");
920
922
  break;
@@ -929,9 +931,9 @@ export class Client extends Composer {
929
931
  }
930
932
  }
931
933
  }
932
- __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("authorized as bot");
933
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
934
- await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("authorize");
934
+ this.#LsignIn.debug("authorized as bot");
935
+ await this.#propagateAuthorizationState(true);
936
+ await this.#updateManager.fetchState("authorize");
935
937
  return;
936
938
  }
937
939
  auth: while (true) {
@@ -944,8 +946,8 @@ export class Client extends Composer {
944
946
  const sendCode = () => this.invoke({
945
947
  _: "auth.sendCode",
946
948
  phone_number: phone,
947
- api_id: __classPrivateFieldGet(this, _Client_apiId, "f"),
948
- api_hash: __classPrivateFieldGet(this, _Client_apiHash, "f"),
949
+ api_id: this.#apiId,
950
+ api_hash: this.#apiHash,
949
951
  settings: { _: "codeSettings" },
950
952
  }).then((v) => Api.as("auth.sentCode", v));
951
953
  try {
@@ -965,281 +967,150 @@ export class Client extends Composer {
965
967
  catch (err) {
966
968
  if (err instanceof PhoneNumberInvalid) {
967
969
  continue;
968
- }
969
- else {
970
- throw err;
971
- }
972
- }
973
- }
974
- __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("verification code sent");
975
- let err;
976
- code: while (true) {
977
- const code = typeof params.code === "string" ? params.code : await params.code();
978
- try {
979
- const auth = await this.invoke({
980
- _: "auth.signIn",
981
- phone_number: phone,
982
- phone_code: code,
983
- phone_code_hash: sentCode.phone_code_hash,
984
- });
985
- await this.storage.setAccountId(Number(Api.as("auth.authorization", auth).user.id));
986
- await this.storage.setAccountType("user");
987
- __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
988
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
989
- await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("signIn");
990
- return;
991
- }
992
- catch (err_) {
993
- if (err_ instanceof PhoneCodeInvalid) {
994
- continue code;
995
- }
996
- else {
997
- err = err_;
998
- break code;
999
- }
1000
- }
1001
- }
1002
- if (!(err instanceof SessionPasswordNeeded)) {
1003
- throw err;
1004
- }
1005
- password: while (true) {
1006
- const ap = await this.invoke({ _: "account.getPassword" });
1007
- if (!(Api.is("passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow", ap.current_algo))) {
1008
- throw new Error(`Handling ${ap.current_algo?._} not implemented`);
1009
- }
1010
- try {
1011
- const password = typeof params.password === "string" ? params.password : await params.password(ap.hint ?? null);
1012
- const input = await checkPassword(password, ap);
1013
- const auth = await this.invoke({ _: "auth.checkPassword", password: input });
1014
- await this.storage.setAccountId(Number(Api.as("auth.authorization", auth).user.id));
1015
- await this.storage.setAccountType("user");
1016
- __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
1017
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
1018
- await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("signIn");
1019
- return;
1020
- }
1021
- catch (err) {
1022
- if (err instanceof PasswordHashInvalid) {
1023
- continue password;
1024
- }
1025
- else {
1026
- throw err;
1027
- }
1028
- }
1029
- }
1030
- }
1031
- catch (err) {
1032
- if (err == restartAuth) {
1033
- continue auth;
1034
- }
1035
- else {
1036
- throw err;
1037
- }
1038
- }
1039
- }
1040
- }
1041
- async signOut() {
1042
- try {
1043
- await Promise.all([
1044
- this.storage.reset(),
1045
- this.invoke({ _: "auth.logOut" }).then(() => {
1046
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, false);
1047
- }),
1048
- ]);
1049
- }
1050
- finally {
1051
- __classPrivateFieldSet(this, _Client_lastGetMe, null, "f");
1052
- this.disconnect();
1053
- await this.connect();
1054
- }
1055
- }
1056
- /**
1057
- * Same as calling `.connect()` followed by `.signIn(params)`.
1058
- */
1059
- async start(params) {
1060
- await this.connect();
1061
- await this.signIn(params);
1062
- }
1063
- exportAuthString() {
1064
- return this.storage.exportAuthString(__classPrivateFieldGet(this, _Client_apiId, "f"));
1065
- }
1066
- async importAuthString(authString) {
1067
- if (this.connected) {
1068
- throw new Error("Cannot import auth string while the client is connected");
1069
- }
1070
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
1071
- await this.storage.importAuthString(authString);
1072
- __classPrivateFieldSet(this, _Client_authStringImported, true, "f");
1073
- if (!__classPrivateFieldGet(this, _Client_apiId, "f")) {
1074
- __classPrivateFieldSet(this, _Client_apiId, await this.storage.getApiId() ?? 0, "f");
1075
- }
1076
- }
1077
- /**
1078
- * Get a chat's inputPeer. Useful when calling API functions directly.
1079
- *
1080
- * @param id The identifier of a chat.
1081
- */
1082
- async getInputPeer(id) {
1083
- if (id === "me" || id == await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this)) {
1084
- return { _: "inputPeerSelf" };
1085
- }
1086
- const inputPeer = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getInputPeerInner).call(this, id);
1087
- if (((Api.is("inputPeerUser", inputPeer) || Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n) && await this.storage.getAccountType() == "user") {
1088
- if ("channel_id" in inputPeer) {
1089
- inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChannelAccessHash).call(this, inputPeer.channel_id);
1090
- }
1091
- else {
1092
- inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUserAccessHash).call(this, inputPeer.user_id);
1093
- }
1094
- }
1095
- if ((Api.is("inputPeerUser", inputPeer) || Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n && await this.storage.getAccountType() == "user") {
1096
- throw new AccessError(`Cannot access the chat ${id} because there is no access hash for it.`);
1097
- }
1098
- return inputPeer;
1099
- }
1100
- /**
1101
- * Get a channel or a supergroup's inputChannel. Useful when calling API functions directly.
1102
- *
1103
- * @param id The identifier of the channel or the supergroup.
1104
- */
1105
- async getInputChannel(id) {
1106
- const inputPeer = await this.getInputPeer(id);
1107
- if (!canBeInputChannel(inputPeer)) {
1108
- throw new TypeError(`The chat ${id} is not a channel neither a supergroup.`);
1109
- }
1110
- return toInputChannel(inputPeer);
1111
- }
1112
- /**
1113
- * Get a user's inputUser. Useful when calling API functions directly.
1114
- *
1115
- * @param id The identifier of the user.
1116
- */
1117
- async getInputUser(id) {
1118
- const inputPeer = await this.getInputPeer(id);
1119
- if (!canBeInputUser(inputPeer)) {
1120
- throw new TypeError(`The chat ${id} is not a private chat.`);
1121
- }
1122
- return toInputUser(inputPeer);
1123
- }
1124
- async [(_Client_propagateAuthorizationState = async function _Client_propagateAuthorizationState(authorized) {
1125
- if (__classPrivateFieldGet(this, _Client_lastPropagatedAuthorizationState, "f") != authorized) {
1126
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, { authorizationState: { authorized } });
1127
- __classPrivateFieldSet(this, _Client_lastPropagatedAuthorizationState, authorized, "f");
1128
- }
1129
- }, _Client_getSelfId = async function _Client_getSelfId() {
1130
- const id = await this.storage.getAccountId();
1131
- if (id == null) {
1132
- throw new Error("Unauthorized");
1133
- }
1134
- return id;
1135
- }, _Client_getIsPremium = async function _Client_getIsPremium() {
1136
- const maybeIsPremium = await this.storage.getIsPremium();
1137
- if (maybeIsPremium != null) {
1138
- return maybeIsPremium;
1139
- }
1140
- return __classPrivateFieldGet(this, _Client_lastGetMe, "f")?.isPremium ?? false;
1141
- }, _Client_startUpdateGapRecoveryLoop = function _Client_startUpdateGapRecoveryLoop() {
1142
- drop(__classPrivateFieldGet(this, _Client_instances, "m", _Client_updateGapRecoveryLoop).call(this));
1143
- }, _Client_updateGapRecoveryLoop = async function _Client_updateGapRecoveryLoop() {
1144
- __classPrivateFieldGet(this, _Client_updateGapRecoveryLoopAbortController, "f")?.abort();
1145
- const controller = __classPrivateFieldSet(this, _Client_updateGapRecoveryLoopAbortController, new AbortController(), "f");
1146
- while (this.connected) {
1147
- try {
1148
- await delay(60 * SECOND, { signal: controller.signal });
1149
- if (!this.connected) {
1150
- break;
1151
- }
1152
- controller.signal.throwIfAborted();
1153
- if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * MINUTE) {
1154
- drop(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("lastUpdates").then(() => {
1155
- __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
1156
- }));
1157
- }
1158
- }
1159
- catch (err) {
1160
- if (err instanceof DOMException && err.name == "AbortError") {
1161
- break;
970
+ }
971
+ else {
972
+ throw err;
973
+ }
974
+ }
1162
975
  }
1163
- else if (!this.connected) {
1164
- break;
976
+ this.#LsignIn.debug("verification code sent");
977
+ let err;
978
+ code: while (true) {
979
+ const code = typeof params.code === "string" ? params.code : await params.code();
980
+ try {
981
+ const auth = await this.invoke({
982
+ _: "auth.signIn",
983
+ phone_number: phone,
984
+ phone_code: code,
985
+ phone_code_hash: sentCode.phone_code_hash,
986
+ });
987
+ await this.storage.setAccountId(Number(Api.as("auth.authorization", auth).user.id));
988
+ await this.storage.setAccountType("user");
989
+ this.#LsignIn.debug("signed in as user");
990
+ await this.#propagateAuthorizationState(true);
991
+ await this.#updateManager.fetchState("signIn");
992
+ return;
993
+ }
994
+ catch (err_) {
995
+ if (err_ instanceof PhoneCodeInvalid) {
996
+ continue code;
997
+ }
998
+ else {
999
+ err = err_;
1000
+ break code;
1001
+ }
1002
+ }
1165
1003
  }
1166
- __classPrivateFieldGet(this, _Client_LupdateGapRecoveryLoop, "f").error(err);
1167
- }
1168
- }
1169
- }, _Client_startClientDisconnectionLoop = function _Client_startClientDisconnectionLoop() {
1170
- drop(__classPrivateFieldGet(this, _Client_instances, "m", _Client_clientDisconnectionLoop).call(this));
1171
- }, _Client_clientDisconnectionLoop = async function _Client_clientDisconnectionLoop() {
1172
- const controller = __classPrivateFieldSet(this, _Client_clientDisconnectionLoopAbortController, new AbortController(), "f");
1173
- while (this.connected) {
1174
- try {
1175
- await delay(60 * SECOND, { signal: controller.signal });
1176
- if (!this.connected) {
1177
- break;
1004
+ if (!(err instanceof SessionPasswordNeeded)) {
1005
+ throw err;
1178
1006
  }
1179
- controller.signal.throwIfAborted();
1180
- const now = Date.now();
1181
- const disconnectAfter = 5 * MINUTE;
1182
- __classPrivateFieldGet(this, _Client_clients, "f").map((client, i) => {
1183
- if (i > 0 && !client.disconnected && client.lastRequest && now - client.lastRequest.getTime() >= disconnectAfter) {
1184
- client?.disconnect();
1007
+ password: while (true) {
1008
+ const ap = await this.invoke({ _: "account.getPassword" });
1009
+ if (!(Api.is("passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow", ap.current_algo))) {
1010
+ throw new Error(`Handling ${ap.current_algo?._} not implemented`);
1185
1011
  }
1186
- });
1012
+ try {
1013
+ const password = typeof params.password === "string" ? params.password : await params.password(ap.hint ?? null);
1014
+ const input = await checkPassword(password, ap);
1015
+ const auth = await this.invoke({ _: "auth.checkPassword", password: input });
1016
+ await this.storage.setAccountId(Number(Api.as("auth.authorization", auth).user.id));
1017
+ await this.storage.setAccountType("user");
1018
+ this.#LsignIn.debug("signed in as user");
1019
+ await this.#propagateAuthorizationState(true);
1020
+ await this.#updateManager.fetchState("signIn");
1021
+ return;
1022
+ }
1023
+ catch (err) {
1024
+ if (err instanceof PasswordHashInvalid) {
1025
+ continue password;
1026
+ }
1027
+ else {
1028
+ throw err;
1029
+ }
1030
+ }
1031
+ }
1187
1032
  }
1188
1033
  catch (err) {
1189
- if (err instanceof DOMException && err.name == "AbortError") {
1190
- break;
1034
+ if (err == restartAuth) {
1035
+ continue auth;
1191
1036
  }
1192
- else if (!this.connected) {
1193
- break;
1037
+ else {
1038
+ throw err;
1194
1039
  }
1195
1040
  }
1196
1041
  }
1197
- }, _Client_getClient = async function _Client_getClient(params) {
1042
+ }
1043
+ async signOut() {
1044
+ try {
1045
+ await Promise.all([
1046
+ this.storage.reset(),
1047
+ this.invoke({ _: "auth.logOut" }).then(() => {
1048
+ this.#propagateAuthorizationState(false);
1049
+ }),
1050
+ ]);
1051
+ }
1052
+ finally {
1053
+ this.#lastGetMe = null;
1054
+ this.disconnect();
1055
+ await this.connect();
1056
+ }
1057
+ }
1058
+ /**
1059
+ * Same as calling `.connect()` followed by `.signIn(params)`.
1060
+ */
1061
+ async start(params) {
1062
+ await this.connect();
1063
+ await this.signIn(params);
1064
+ }
1065
+ async #getClient(params) {
1198
1066
  let client;
1199
1067
  switch (params.type) {
1200
1068
  case undefined:
1201
- client = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMainClient).call(this, params.dc);
1069
+ client = await this.#getMainClient(params.dc);
1202
1070
  break;
1203
1071
  case "download":
1204
- client = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getDownloadClient).call(this, params.dc);
1072
+ client = await this.#getDownloadClient(params.dc);
1205
1073
  break;
1206
1074
  case "upload":
1207
- client = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUploadClient).call(this);
1075
+ client = await this.#getUploadClient();
1208
1076
  break;
1209
1077
  }
1210
- if (client !== __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get) && !this.disconnected && client.disconnected) {
1078
+ if (client !== this.#client && !this.disconnected && client.disconnected) {
1211
1079
  await client.connect();
1212
1080
  }
1213
1081
  return client;
1214
- }, _Client_getMainClient = async function _Client_getMainClient(dc) {
1215
- if (dc === undefined || dc == __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.dc) {
1216
- return __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get);
1082
+ }
1083
+ #getMainClientMutex = new Mutex();
1084
+ async #getMainClient(dc) {
1085
+ if (dc === undefined || dc == this.#client?.dc) {
1086
+ return this.#client;
1217
1087
  }
1218
- let client = __classPrivateFieldGet(this, _Client_clients, "f").find((v) => v.dc == dc);
1088
+ let client = this.#clients.find((v) => v.dc == dc);
1219
1089
  if (client) {
1220
1090
  return client;
1221
1091
  }
1222
- const unlock = await __classPrivateFieldGet(this, _Client_getMainClientMutex, "f").lock();
1223
- client = __classPrivateFieldGet(this, _Client_clients, "f").find((v) => v.dc == dc);
1092
+ const unlock = await this.#getMainClientMutex.lock();
1093
+ client = this.#clients.find((v) => v.dc == dc);
1224
1094
  if (client) {
1225
1095
  return client;
1226
1096
  }
1227
1097
  try {
1228
- client = __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, false);
1229
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setupClient).call(this, client);
1230
- __classPrivateFieldGet(this, _Client_clients, "f").push(client);
1098
+ client = this.#newClient(dc, false, false);
1099
+ await this.#setupClient(client);
1100
+ this.#clients.push(client);
1231
1101
  return client;
1232
1102
  }
1233
1103
  finally {
1234
1104
  unlock();
1235
1105
  }
1236
- }, _Client_getDownloadClient = async function _Client_getDownloadClient(dc) {
1237
- dc ??= __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc;
1238
- const pool = __classPrivateFieldGet(this, _Client_downloadPools, "f")[dc] ??= new ClientEncryptedPool();
1106
+ }
1107
+ async #getDownloadClient(dc) {
1108
+ dc ??= this.#client.dc;
1109
+ const pool = this.#downloadPools[dc] ??= new ClientEncryptedPool();
1239
1110
  if (!pool.size) {
1240
1111
  if (!pool.size) {
1241
1112
  for (let i = 0; i < DOWNLOAD_POOL_SIZE; ++i) {
1242
- pool.add(__classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, true));
1113
+ pool.add(this.#newClient(dc, false, true));
1243
1114
  }
1244
1115
  }
1245
1116
  }
@@ -1247,28 +1118,31 @@ export class Client extends Composer {
1247
1118
  if (client.authKey.length) {
1248
1119
  return client;
1249
1120
  }
1250
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setupClient).call(this, client);
1121
+ await this.#setupClient(client);
1251
1122
  return client;
1252
- }, _Client_getUploadPoolSize = async function _Client_getUploadPoolSize() {
1253
- const dc = __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc;
1254
- return (dc != "2" && dc != "4") || await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getIsPremium).call(this) ? 8 : 4;
1255
- }, _Client_getUploadClient = async function _Client_getUploadClient() {
1256
- const dc = __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc;
1257
- const poolSize = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUploadPoolSize).call(this);
1258
- const pool = __classPrivateFieldGet(this, _Client_uploadPools, "f")[dc] ??= new ClientEncryptedPool();
1123
+ }
1124
+ async #getUploadPoolSize() {
1125
+ const dc = this.#client.dc;
1126
+ return (dc != "2" && dc != "4") || await this.#getIsPremium() ? 8 : 4;
1127
+ }
1128
+ async #getUploadClient() {
1129
+ const dc = this.#client.dc;
1130
+ const poolSize = await this.#getUploadPoolSize();
1131
+ const pool = this.#uploadPools[dc] ??= new ClientEncryptedPool();
1259
1132
  if (!pool.size) {
1260
1133
  for (let i = 0; i < poolSize; ++i) {
1261
- pool.add(await __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, true));
1134
+ pool.add(await this.#newClient(dc, false, true));
1262
1135
  }
1263
1136
  }
1264
1137
  const client = pool.nextClient();
1265
1138
  if (client.authKey.length) {
1266
1139
  return client;
1267
1140
  }
1268
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setupClient).call(this, client);
1141
+ await this.#setupClient(client);
1269
1142
  return client;
1270
- }, _Client_setupClient = async function _Client_setupClient(client) {
1271
- const storage = client.dc == __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc ? this.storage : new StorageOperations(this.storage.provider.branch(client.dc + (client.cdn ? "_cdn" : "")));
1143
+ }
1144
+ async #setupClient(client) {
1145
+ const storage = client.dc == this.#client.dc ? this.storage : new StorageOperations(this.storage.provider.branch(client.dc + (client.cdn ? "_cdn" : "")));
1272
1146
  const [authKey, serverSalt] = await Promise.all([storage.getAuthKey(), storage.getServerSalt()]);
1273
1147
  if (authKey) {
1274
1148
  await client.setAuthKey(authKey);
@@ -1278,17 +1152,18 @@ export class Client extends Composer {
1278
1152
  }
1279
1153
  await client.connect();
1280
1154
  if (!authKey) {
1281
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_importAuthorization).call(this, client);
1155
+ await this.#importAuthorization(client);
1282
1156
  }
1283
1157
  await storage.setAuthKey(client.authKey);
1284
- if (client.dc !== __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc) {
1158
+ if (client.dc !== this.#client.dc) {
1285
1159
  await storage.setServerSalt(client.serverSalt);
1286
1160
  client.handlers.onNewServerSalt = async (serverSalt) => {
1287
1161
  await storage.setServerSalt(serverSalt);
1288
1162
  };
1289
1163
  }
1290
- }, _Client_importAuthorization = async function _Client_importAuthorization(client) {
1291
- if (__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc == client.dc && __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).cdn == client.cdn) {
1164
+ }
1165
+ async #importAuthorization(client) {
1166
+ if (this.#client.dc == client.dc && this.#client.cdn == client.cdn) {
1292
1167
  const [authKey, serverSalt] = await Promise.all([this.storage.getAuthKey(), this.storage.getServerSalt()]);
1293
1168
  if (authKey) {
1294
1169
  await client.setAuthKey(authKey);
@@ -1298,29 +1173,30 @@ export class Client extends Composer {
1298
1173
  }
1299
1174
  return;
1300
1175
  }
1301
- const exportedAuthorization = await __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).invoke({ _: "auth.exportAuthorization", dc_id: getDcId(client.dc, client.cdn) });
1176
+ const exportedAuthorization = await this.#client.invoke({ _: "auth.exportAuthorization", dc_id: getDcId(client.dc, client.cdn) });
1302
1177
  await client.invoke({ ...exportedAuthorization, _: "auth.importAuthorization" });
1303
- }, _Client_invoke = async function _Client_invoke(function_, params) {
1304
- if (!__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)) {
1178
+ }
1179
+ async #invoke(function_, params) {
1180
+ if (!this.#client) {
1305
1181
  throw new ConnectionError("Not connected.");
1306
1182
  }
1307
1183
  let n = 1;
1308
1184
  let client;
1309
1185
  while (true) {
1310
- client = params ? await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getClient).call(this, params) : __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get);
1311
- const main = client === __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get);
1186
+ client = params ? await this.#getClient(params) : this.#client;
1187
+ const main = client === this.#client;
1312
1188
  try {
1313
1189
  const result = await client.invoke(function_);
1314
1190
  if (main) {
1315
1191
  try {
1316
- await __classPrivateFieldGet(this, _Client_updateManager, "f").processResult(result);
1192
+ await this.#updateManager.processResult(result);
1317
1193
  }
1318
1194
  catch (err) {
1319
- __classPrivateFieldGet(this, _Client_L, "f").error("failed to process result:", err);
1195
+ this.#L.error("failed to process result:", err);
1320
1196
  }
1321
1197
  if (Api.isOfEnum("Update", result) || Api.isOfEnum("Updates", result)) {
1322
1198
  return new Promise((resolve) => {
1323
- __classPrivateFieldGet(this, _Client_updateManager, "f").processUpdates(result, true, Mtproto.is("ping", function_) ? null : function_, () => resolve(result));
1199
+ this.#updateManager.processUpdates(result, true, Mtproto.is("ping", function_) ? null : function_, () => resolve(result));
1324
1200
  });
1325
1201
  }
1326
1202
  }
@@ -1328,13 +1204,13 @@ export class Client extends Composer {
1328
1204
  }
1329
1205
  catch (err) {
1330
1206
  if (err instanceof AuthKeyUnregistered && !main) {
1331
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_importAuthorization).call(this, client);
1207
+ await this.#importAuthorization(client);
1332
1208
  continue;
1333
1209
  }
1334
1210
  else if (err instanceof ConnectionError && !main && !this.disconnected) {
1335
1211
  continue;
1336
1212
  }
1337
- else if (await __classPrivateFieldGet(this, _Client_handleInvokeError, "f").call(this, Object.freeze({ client: this, error: err, function: function_, n: n++ }), () => Promise.resolve(false))) {
1213
+ else if (await this.#handleInvokeError(Object.freeze({ client: this, error: err, function: function_, n: n++ }), () => Promise.resolve(false))) {
1338
1214
  continue;
1339
1215
  }
1340
1216
  else {
@@ -1342,23 +1218,85 @@ export class Client extends Composer {
1342
1218
  }
1343
1219
  }
1344
1220
  }
1345
- }, _Client_getUserAccessHash = async function _Client_getUserAccessHash(userId) {
1221
+ }
1222
+ #handleInvokeError = skipInvoke();
1223
+ /**
1224
+ * Invokes a function waiting and returning its reply if the second parameter is not `true`. Requires the client
1225
+ * to be connected.
1226
+ *
1227
+ * @param function_ The function to invoke.
1228
+ */
1229
+ invoke = Object.assign(this.#invoke, {
1230
+ use: (handler) => {
1231
+ const handle = this.#handleInvokeError;
1232
+ this.#handleInvokeError = async (ctx, next) => {
1233
+ let result = null;
1234
+ return await handle(ctx, async () => {
1235
+ if (result != null)
1236
+ return result;
1237
+ result = await handler(ctx, next);
1238
+ return result;
1239
+ });
1240
+ };
1241
+ },
1242
+ });
1243
+ exportAuthString() {
1244
+ return this.storage.exportAuthString(this.#apiId);
1245
+ }
1246
+ #authStringImported = false;
1247
+ async importAuthString(authString) {
1248
+ if (this.connected) {
1249
+ throw new Error("Cannot import auth string while the client is connected");
1250
+ }
1251
+ await this.#initStorage();
1252
+ await this.storage.importAuthString(authString);
1253
+ this.#authStringImported = true;
1254
+ if (!this.#apiId) {
1255
+ this.#apiId = await this.storage.getApiId() ?? 0;
1256
+ }
1257
+ }
1258
+ async #getUserAccessHash(userId) {
1346
1259
  const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUser", user_id: userId, access_hash: 0n }] });
1347
1260
  const user = Api.is("user", users[0]) ? users[0] : undefined;
1348
1261
  if (user) {
1349
1262
  await this.messageStorage.setEntity(user);
1350
1263
  }
1351
1264
  return user?.access_hash ?? 0n;
1352
- }, _Client_getChannelAccessHash = async function _Client_getChannelAccessHash(channelId) {
1265
+ }
1266
+ async #getChannelAccessHash(channelId) {
1353
1267
  const channels = await this.invoke({ _: "channels.getChannels", id: [{ _: "inputChannel", channel_id: channelId, access_hash: 0n }] });
1354
1268
  const channel = Api.is("channel", channels.chats[0]) ? channels.chats[0] : undefined;
1355
1269
  if (channel) {
1356
1270
  await this.messageStorage.setEntity(channel);
1357
1271
  }
1358
1272
  return channel?.access_hash ?? 0n;
1359
- }, _Client_getInputPeerChatId = async function _Client_getInputPeerChatId(inputPeer) {
1273
+ }
1274
+ /**
1275
+ * Get a chat's inputPeer. Useful when calling API functions directly.
1276
+ *
1277
+ * @param id The identifier of a chat.
1278
+ */
1279
+ async getInputPeer(id) {
1280
+ if (id === "me" || id == await this.#getSelfId()) {
1281
+ return { _: "inputPeerSelf" };
1282
+ }
1283
+ const inputPeer = await this.#getInputPeerInner(id);
1284
+ if (((Api.is("inputPeerUser", inputPeer) || Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n) && await this.storage.getAccountType() == "bot") {
1285
+ if ("channel_id" in inputPeer) {
1286
+ inputPeer.access_hash = await this.#getChannelAccessHash(inputPeer.channel_id);
1287
+ }
1288
+ else {
1289
+ inputPeer.access_hash = await this.#getUserAccessHash(inputPeer.user_id);
1290
+ }
1291
+ }
1292
+ if ((Api.is("inputPeerUser", inputPeer) || Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n) {
1293
+ throw new AccessError(`Cannot access the chat ${id} because there is no access hash for it.`);
1294
+ }
1295
+ return inputPeer;
1296
+ }
1297
+ async #getInputPeerChatId(inputPeer) {
1360
1298
  if (Api.isOneOf(["inputPeerSelf", "inputUserSelf"], inputPeer)) {
1361
- return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this);
1299
+ return await this.#getSelfId();
1362
1300
  }
1363
1301
  else if (Api.isOneOf(["inputPeerEmpty", "inputUserEmpty", "inputChannelEmpty"], inputPeer)) {
1364
1302
  unreachable();
@@ -1366,7 +1304,32 @@ export class Client extends Composer {
1366
1304
  else {
1367
1305
  return Api.peerToChatId(inputPeer);
1368
1306
  }
1369
- }, _Client_getInputPeerInner = async function _Client_getInputPeerInner(id) {
1307
+ }
1308
+ /**
1309
+ * Get a channel or a supergroup's inputChannel. Useful when calling API functions directly.
1310
+ *
1311
+ * @param id The identifier of the channel or the supergroup.
1312
+ */
1313
+ async getInputChannel(id) {
1314
+ const inputPeer = await this.getInputPeer(id);
1315
+ if (!canBeInputChannel(inputPeer)) {
1316
+ throw new TypeError(`The chat ${id} is not a channel neither a supergroup.`);
1317
+ }
1318
+ return toInputChannel(inputPeer);
1319
+ }
1320
+ /**
1321
+ * Get a user's inputUser. Useful when calling API functions directly.
1322
+ *
1323
+ * @param id The identifier of the user.
1324
+ */
1325
+ async getInputUser(id) {
1326
+ const inputPeer = await this.getInputPeer(id);
1327
+ if (!canBeInputUser(inputPeer)) {
1328
+ throw new TypeError(`The chat ${id} is not a private chat.`);
1329
+ }
1330
+ return toInputUser(inputPeer);
1331
+ }
1332
+ async #getInputPeerInner(id) {
1370
1333
  const idn = Number(id);
1371
1334
  if (!isNaN(idn)) {
1372
1335
  id = idn;
@@ -1382,8 +1345,8 @@ export class Client extends Composer {
1382
1345
  }
1383
1346
  else {
1384
1347
  const resolved = await this.invoke({ _: "contacts.resolveUsername", username: id });
1385
- await __classPrivateFieldGet(this, _Client_updateManager, "f").processChats(resolved.chats, resolved);
1386
- await __classPrivateFieldGet(this, _Client_updateManager, "f").processUsers(resolved.users, resolved);
1348
+ await this.#updateManager.processChats(resolved.chats, resolved);
1349
+ await this.#updateManager.processUsers(resolved.users, resolved);
1387
1350
  if (Api.is("peerUser", resolved.peer)) {
1388
1351
  resolvedId = Api.peerToChatId(resolved.peer);
1389
1352
  }
@@ -1425,15 +1388,16 @@ export class Client extends Composer {
1425
1388
  const chatId = Api.peerToChatId(peer);
1426
1389
  const minPeerReference = await this.messageStorage.getLastMinPeerReference(chatId);
1427
1390
  if (minPeerReference) {
1428
- const minInputPeer = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMinInputPeer).call(this, canBeInputChannel(peer) ? "channel" : "user", { ...minPeerReference, senderId: chatId });
1391
+ const minInputPeer = await this.#getMinInputPeer(canBeInputChannel(peer) ? "channel" : "user", { ...minPeerReference, senderId: chatId });
1429
1392
  if (minInputPeer) {
1430
- __classPrivateFieldGet(this, _Client_Lmin, "f").debug("resolved input min peer", minInputPeer);
1393
+ this.#Lmin.debug("resolved input min peer", minInputPeer);
1431
1394
  peer = minInputPeer;
1432
1395
  }
1433
1396
  }
1434
1397
  }
1435
1398
  return peer;
1436
- }, _Client_getMinInputPeer = async function _Client_getMinInputPeer(type, reference) {
1399
+ }
1400
+ async #getMinInputPeer(type, reference) {
1437
1401
  const entity = await this.messageStorage.getEntity(reference.chatId);
1438
1402
  if (Api.isOneOf(["channel", "channelForbidden"], entity) && entity.access_hash) {
1439
1403
  const peer = { _: "inputPeerChannel", channel_id: entity.id, access_hash: entity.access_hash };
@@ -1447,7 +1411,8 @@ export class Client extends Composer {
1447
1411
  else {
1448
1412
  return null;
1449
1413
  }
1450
- }, getEntity)](peer) {
1414
+ }
1415
+ async [getEntity](peer) {
1451
1416
  const id = Api.peerToChatId(peer);
1452
1417
  const entity = await this.messageStorage.getEntity(id);
1453
1418
  if (entity == null && await this.storage.getAccountType() == "bot" && Api.is("peerUser", peer) || Api.is("peerChannel", peer)) {
@@ -1458,6 +1423,131 @@ export class Client extends Composer {
1458
1423
  }
1459
1424
  return await this.messageStorage.getEntity(id);
1460
1425
  }
1426
+ async #handleCtxUpdate(update) {
1427
+ if (this.#disableUpdates && !("authorizationState" in update) && !("connectionState" in update)) {
1428
+ return;
1429
+ }
1430
+ try {
1431
+ await this.middleware()(await this.#constructContext(update), resolve);
1432
+ }
1433
+ catch (err) {
1434
+ this.#L.error("Failed to handle update:", err);
1435
+ throw err;
1436
+ }
1437
+ }
1438
+ #queueHandleCtxUpdate(update) {
1439
+ this.#updateManager.getHandleUpdateQueue(UpdateManager.MAIN_BOX_ID).add(async () => {
1440
+ await this.#handleCtxUpdate(update);
1441
+ });
1442
+ }
1443
+ async #handleUpdate(update) {
1444
+ const promises = new Array();
1445
+ if (Api.is("updateUserName", update)) {
1446
+ await this.messageStorage.updateUsernames(Number(update.user_id), update.usernames.map((v) => v.username));
1447
+ const peer = { ...update, _: "peerUser" };
1448
+ const entity = await this[getEntity](peer);
1449
+ if (entity != null) {
1450
+ entity.usernames = update.usernames;
1451
+ entity.first_name = update.first_name;
1452
+ entity.last_name = update.last_name;
1453
+ await this.messageStorage.setEntity(entity);
1454
+ }
1455
+ }
1456
+ if (this.#messageManager.canHandleUpdate(update)) {
1457
+ promises.push(() => this.#messageManager.handleUpdate(update));
1458
+ }
1459
+ if (this.#chatManager.canHandleUpdate(update)) {
1460
+ promises.push(() => this.#chatManager.handleUpdate(update));
1461
+ }
1462
+ if (this.#pollManager.canHandleUpdate(update)) {
1463
+ promises.push(() => this.#pollManager.handleUpdate(update));
1464
+ }
1465
+ if (this.#videoChatManager.canHandleUpdate(update)) {
1466
+ promises.push(() => this.#videoChatManager.handleUpdate(update));
1467
+ }
1468
+ if (this.#callbackQueryManager.canHandleUpdate(update)) {
1469
+ promises.push(() => this.#callbackQueryManager.handleUpdate(update));
1470
+ }
1471
+ if (this.#inlineQueryManager.canHandleUpdate(update)) {
1472
+ promises.push(() => this.#inlineQueryManager.handleUpdate(update));
1473
+ }
1474
+ if (this.#linkPreviewManager.canHandleUpdate(update)) {
1475
+ promises.push(() => this.#linkPreviewManager.handleUpdate(update));
1476
+ }
1477
+ if (this.#reactionManager.canHandleUpdate(update)) {
1478
+ promises.push(() => this.#reactionManager.handleUpdate(update));
1479
+ }
1480
+ if (this.#chatListManager.canHandleUpdate(update)) {
1481
+ promises.push(() => this.#chatListManager.handleUpdate(update));
1482
+ }
1483
+ if (this.#storyManager.canHandleUpdate(update)) {
1484
+ promises.push(() => this.#storyManager.handleUpdate(update));
1485
+ }
1486
+ if (this.#businessConnectionManager.canHandleUpdate(update)) {
1487
+ promises.push(() => this.#businessConnectionManager.handleUpdate(update));
1488
+ }
1489
+ if (this.#storyManager.canHandleUpdate(update)) {
1490
+ promises.push(() => this.#storyManager.handleUpdate(update));
1491
+ }
1492
+ if (this.#paymentManager.canHandleUpdate(update)) {
1493
+ promises.push(() => this.#paymentManager.handleUpdate(update));
1494
+ }
1495
+ if (this.#translationsManager.canHandleUpdate(update)) {
1496
+ promises.push(() => this.#translationsManager.handleUpdate(update));
1497
+ }
1498
+ return () => Promise.resolve().then(async () => {
1499
+ const updates = new Array();
1500
+ for (const promise of promises) {
1501
+ try {
1502
+ const update = await promise();
1503
+ if (update) {
1504
+ updates.push(update);
1505
+ }
1506
+ }
1507
+ catch (err) {
1508
+ this.#L.error("failed to construct update:", err);
1509
+ }
1510
+ }
1511
+ for (const update of updates) {
1512
+ try {
1513
+ await this.#handleCtxUpdate(update);
1514
+ }
1515
+ finally {
1516
+ if ("deletedMessages" in update) {
1517
+ for (const { chatId, messageId } of update.deletedMessages) {
1518
+ await this.messageStorage.setMessage(chatId, messageId, null);
1519
+ await this.#chatListManager.reassignChatLastMessage(chatId);
1520
+ }
1521
+ }
1522
+ }
1523
+ }
1524
+ });
1525
+ }
1526
+ #lastGetMe = null;
1527
+ async #getMe() {
1528
+ if (this.#lastGetMe != null) {
1529
+ return this.#lastGetMe;
1530
+ }
1531
+ else {
1532
+ const user = await this.getMe();
1533
+ this.#lastGetMe = user;
1534
+ return user;
1535
+ }
1536
+ }
1537
+ #previouslyConnected = false;
1538
+ #lastConnectionState = false;
1539
+ #onConnectionStateChange(connected) {
1540
+ if (this.#lastConnectionState != connected) {
1541
+ if (connected) {
1542
+ if (this.#previouslyConnected) {
1543
+ drop(this.#updateManager.recoverUpdateGap("reconnect"));
1544
+ }
1545
+ this.#previouslyConnected = true;
1546
+ }
1547
+ const connectionState = connected ? "ready" : "notConnected";
1548
+ this.#queueHandleCtxUpdate({ connectionState });
1549
+ }
1550
+ }
1461
1551
  //
1462
1552
  // ========================= ACCOUNT ========================= //
1463
1553
  //
@@ -1467,7 +1557,7 @@ export class Client extends Composer {
1467
1557
  * @method ac
1468
1558
  */
1469
1559
  async getMe() {
1470
- let user_ = await this[getEntity]({ _: "peerUser", user_id: BigInt(await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this)) });
1560
+ let user_ = await this[getEntity]({ _: "peerUser", user_id: BigInt(await this.#getSelfId()) });
1471
1561
  if (user_ == null) {
1472
1562
  const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUserSelf" }] });
1473
1563
  user_ = Api.as("user", users[0]);
@@ -1475,7 +1565,7 @@ export class Client extends Composer {
1475
1565
  await this.storage.setIsPremium(user_.premium ?? false);
1476
1566
  }
1477
1567
  const user = constructUser(user_);
1478
- __classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
1568
+ this.#lastGetMe = user;
1479
1569
  return user;
1480
1570
  }
1481
1571
  /**
@@ -1486,7 +1576,7 @@ export class Client extends Composer {
1486
1576
  * @param username The username to show.
1487
1577
  */
1488
1578
  async showUsername(id, username) {
1489
- await __classPrivateFieldGet(this, _Client_accountManager, "f").showUsername(id, username);
1579
+ await this.#accountManager.showUsername(id, username);
1490
1580
  }
1491
1581
  /**
1492
1582
  * Hide a username from the current account, a bot account, a supergroup, or a channel's profile. User-only.
@@ -1496,7 +1586,7 @@ export class Client extends Composer {
1496
1586
  * @param username The username to hide.
1497
1587
  */
1498
1588
  async hideUsername(id, username) {
1499
- await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsername(id, username);
1589
+ await this.#accountManager.hideUsername(id, username);
1500
1590
  }
1501
1591
  /**
1502
1592
  * Reorder the usernames of the current account, a bot account, a supergroup, or a channel's profile. User-only.
@@ -1507,7 +1597,7 @@ export class Client extends Composer {
1507
1597
  * @returns Whether the order was changed.
1508
1598
  */
1509
1599
  async reorderUsernames(id, order) {
1510
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").reorderUsernames(id, order);
1600
+ return await this.#accountManager.reorderUsernames(id, order);
1511
1601
  }
1512
1602
  /**
1513
1603
  * Hide all usernames from a supergroup or a channel's profile. User-only.
@@ -1516,7 +1606,7 @@ export class Client extends Composer {
1516
1606
  * @param id A supergroup ID or a channel ID.
1517
1607
  */
1518
1608
  async hideUsernames(id) {
1519
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsernames(id);
1609
+ return await this.#accountManager.hideUsernames(id);
1520
1610
  }
1521
1611
  /**
1522
1612
  * Get a business connection. Bot-only.
@@ -1526,7 +1616,7 @@ export class Client extends Composer {
1526
1616
  * @cache
1527
1617
  */
1528
1618
  async getBusinessConnection(id) {
1529
- return await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").getBusinessConnection(id);
1619
+ return await this.#businessConnectionManager.getBusinessConnection(id);
1530
1620
  }
1531
1621
  /**
1532
1622
  * Set the current account's online status. User-only.
@@ -1535,7 +1625,7 @@ export class Client extends Composer {
1535
1625
  * @param online The new online status.
1536
1626
  */
1537
1627
  async setOnline(online) {
1538
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setOnline(online);
1628
+ await this.#accountManager.setOnline(online);
1539
1629
  }
1540
1630
  /**
1541
1631
  * Set the current account's emoji status. User-only.
@@ -1544,7 +1634,7 @@ export class Client extends Composer {
1544
1634
  * @param id The identifier of the emoji to be used as the new status.
1545
1635
  */
1546
1636
  async setEmojiStatus(id, params) {
1547
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setEmojiStatus(id, params);
1637
+ await this.#accountManager.setEmojiStatus(id, params);
1548
1638
  }
1549
1639
  /**
1550
1640
  * Set the emoji status of a bot's user. Bot-only.
@@ -1554,7 +1644,7 @@ export class Client extends Composer {
1554
1644
  * @param id The identifier of the emoji to be used as the new status.
1555
1645
  */
1556
1646
  async setUserEmojiStatus(userId, id, params) {
1557
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setUserEmojiStatus(userId, id, params);
1647
+ await this.#accountManager.setUserEmojiStatus(userId, id, params);
1558
1648
  }
1559
1649
  /**
1560
1650
  * Update the profile of the current user. At least one parameter must be specified. User-only.
@@ -1562,7 +1652,7 @@ export class Client extends Composer {
1562
1652
  * @method ac
1563
1653
  */
1564
1654
  async updateProfile(params) {
1565
- await __classPrivateFieldGet(this, _Client_accountManager, "f").updateProfile(params);
1655
+ await this.#accountManager.updateProfile(params);
1566
1656
  }
1567
1657
  /**
1568
1658
  * Set the birthday of the current user. User-only.
@@ -1570,7 +1660,7 @@ export class Client extends Composer {
1570
1660
  * @method ac
1571
1661
  */
1572
1662
  async setBirthday(params) {
1573
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setBirthday(params);
1663
+ await this.#accountManager.setBirthday(params);
1574
1664
  }
1575
1665
  /**
1576
1666
  * Set the personal channel of the current user. User-only.
@@ -1578,7 +1668,7 @@ export class Client extends Composer {
1578
1668
  * @method ac
1579
1669
  */
1580
1670
  async setPersonalChannel(params) {
1581
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setPersonalChannel(params);
1671
+ await this.#accountManager.setPersonalChannel(params);
1582
1672
  }
1583
1673
  /**
1584
1674
  * Set the name color of the current user. User-only.
@@ -1587,7 +1677,7 @@ export class Client extends Composer {
1587
1677
  * @param color The identifier of the color to set.
1588
1678
  */
1589
1679
  async setNameColor(color, params) {
1590
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setNameColor(color, params);
1680
+ await this.#accountManager.setNameColor(color, params);
1591
1681
  }
1592
1682
  /**
1593
1683
  * Set the profile color of the current user. User-only.
@@ -1596,7 +1686,7 @@ export class Client extends Composer {
1596
1686
  * @param color The identifier of the color to set.
1597
1687
  */
1598
1688
  async setProfileColor(color, params) {
1599
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setProfileColor(color, params);
1689
+ await this.#accountManager.setProfileColor(color, params);
1600
1690
  }
1601
1691
  /**
1602
1692
  * Set the location of the current user. User-only.
@@ -1604,7 +1694,7 @@ export class Client extends Composer {
1604
1694
  * @method ac
1605
1695
  */
1606
1696
  async setLocation(params) {
1607
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setLocation(params);
1697
+ await this.#accountManager.setLocation(params);
1608
1698
  }
1609
1699
  //
1610
1700
  // ========================= MESSAGES ========================= //
@@ -1618,7 +1708,7 @@ export class Client extends Composer {
1618
1708
  * @returns The sent text message.
1619
1709
  */
1620
1710
  async sendMessage(chatId, text, params) {
1621
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendMessage(chatId, text, params);
1711
+ return await this.#messageManager.sendMessage(chatId, text, params);
1622
1712
  }
1623
1713
  /**
1624
1714
  * Send a photo.
@@ -1629,7 +1719,7 @@ export class Client extends Composer {
1629
1719
  * @returns The sent photo.
1630
1720
  */
1631
1721
  async sendPhoto(chatId, photo, params) {
1632
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendPhoto(chatId, photo, params);
1722
+ return await this.#messageManager.sendPhoto(chatId, photo, params);
1633
1723
  }
1634
1724
  /**
1635
1725
  * Send a document.
@@ -1640,7 +1730,7 @@ export class Client extends Composer {
1640
1730
  * @returns The sent document.
1641
1731
  */
1642
1732
  async sendDocument(chatId, document, params) {
1643
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendDocument(chatId, document, params);
1733
+ return await this.#messageManager.sendDocument(chatId, document, params);
1644
1734
  }
1645
1735
  /**
1646
1736
  * Send a sticker.
@@ -1651,7 +1741,7 @@ export class Client extends Composer {
1651
1741
  * @returns The sent sticker.
1652
1742
  */
1653
1743
  async sendSticker(chatId, sticker, params) {
1654
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendSticker(chatId, sticker, params);
1744
+ return await this.#messageManager.sendSticker(chatId, sticker, params);
1655
1745
  }
1656
1746
  /**
1657
1747
  * Send a video.
@@ -1662,7 +1752,7 @@ export class Client extends Composer {
1662
1752
  * @returns The sent video.
1663
1753
  */
1664
1754
  async sendVideo(chatId, video, params) {
1665
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVideo(chatId, video, params);
1755
+ return await this.#messageManager.sendVideo(chatId, video, params);
1666
1756
  }
1667
1757
  /**
1668
1758
  * Send an animation.
@@ -1673,7 +1763,7 @@ export class Client extends Composer {
1673
1763
  * @returns The sent animation.
1674
1764
  */
1675
1765
  async sendAnimation(chatId, animation, params) {
1676
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendAnimation(chatId, animation, params);
1766
+ return await this.#messageManager.sendAnimation(chatId, animation, params);
1677
1767
  }
1678
1768
  /**
1679
1769
  * Send a voice message.
@@ -1684,7 +1774,7 @@ export class Client extends Composer {
1684
1774
  * @returns The sent voice message.
1685
1775
  */
1686
1776
  async sendVoice(chatId, voice, params) {
1687
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVoice(chatId, voice, params);
1777
+ return await this.#messageManager.sendVoice(chatId, voice, params);
1688
1778
  }
1689
1779
  /**
1690
1780
  * Send an audio file.
@@ -1695,7 +1785,7 @@ export class Client extends Composer {
1695
1785
  * @returns The sent audio filr.
1696
1786
  */
1697
1787
  async sendAudio(chatId, audio, params) {
1698
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendAudio(chatId, audio, params);
1788
+ return await this.#messageManager.sendAudio(chatId, audio, params);
1699
1789
  }
1700
1790
  /**
1701
1791
  * Send a media group.
@@ -1706,7 +1796,7 @@ export class Client extends Composer {
1706
1796
  * @returns The sent messages.
1707
1797
  */
1708
1798
  async sendMediaGroup(chatId, media, params) {
1709
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendMediaGroup(chatId, media, params);
1799
+ return await this.#messageManager.sendMediaGroup(chatId, media, params);
1710
1800
  }
1711
1801
  /**
1712
1802
  * Send a video note.
@@ -1717,7 +1807,7 @@ export class Client extends Composer {
1717
1807
  * @returns The sent video note.
1718
1808
  */
1719
1809
  async sendVideoNote(chatId, videoNote, params) {
1720
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVideoNote(chatId, videoNote, params);
1810
+ return await this.#messageManager.sendVideoNote(chatId, videoNote, params);
1721
1811
  }
1722
1812
  /**
1723
1813
  * Send a location.
@@ -1729,7 +1819,7 @@ export class Client extends Composer {
1729
1819
  * @returns The sent location.
1730
1820
  */
1731
1821
  async sendLocation(chatId, latitude, longitude, params) {
1732
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendLocation(chatId, latitude, longitude, params);
1822
+ return await this.#messageManager.sendLocation(chatId, latitude, longitude, params);
1733
1823
  }
1734
1824
  /**
1735
1825
  * Send a contact.
@@ -1741,7 +1831,7 @@ export class Client extends Composer {
1741
1831
  * @returns The sent contact.
1742
1832
  */
1743
1833
  async sendContact(chatId, firstName, number, params) {
1744
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendContact(chatId, firstName, number, params);
1834
+ return await this.#messageManager.sendContact(chatId, firstName, number, params);
1745
1835
  }
1746
1836
  /**
1747
1837
  * Send a dice.
@@ -1751,7 +1841,7 @@ export class Client extends Composer {
1751
1841
  * @returns The sent dice.
1752
1842
  */
1753
1843
  async sendDice(chatId, params) {
1754
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendDice(chatId, params);
1844
+ return await this.#messageManager.sendDice(chatId, params);
1755
1845
  }
1756
1846
  /**
1757
1847
  * Send a venue.
@@ -1765,7 +1855,7 @@ export class Client extends Composer {
1765
1855
  * @returns The sent venue.
1766
1856
  */
1767
1857
  async sendVenue(chatId, latitude, longitude, title, address, params) {
1768
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVenue(chatId, latitude, longitude, title, address, params);
1858
+ return await this.#messageManager.sendVenue(chatId, latitude, longitude, title, address, params);
1769
1859
  }
1770
1860
  /**
1771
1861
  * Send a poll.
@@ -1777,7 +1867,7 @@ export class Client extends Composer {
1777
1867
  * @returns The sent poll.
1778
1868
  */
1779
1869
  async sendPoll(chatId, question, options, params) {
1780
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendPoll(chatId, question, options, params);
1870
+ return await this.#messageManager.sendPoll(chatId, question, options, params);
1781
1871
  }
1782
1872
  /**
1783
1873
  * Send an invoice. Bot-only.
@@ -1792,7 +1882,7 @@ export class Client extends Composer {
1792
1882
  * @returns The sent invoice.
1793
1883
  */
1794
1884
  async sendInvoice(chatId, title, description, payload, currency, prices, params) {
1795
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendInvoice(chatId, title, description, payload, currency, prices, params);
1885
+ return await this.#messageManager.sendInvoice(chatId, title, description, payload, currency, prices, params);
1796
1886
  }
1797
1887
  /**
1798
1888
  * Edit a message's text.
@@ -1804,7 +1894,7 @@ export class Client extends Composer {
1804
1894
  * @returns The edited text message.
1805
1895
  */
1806
1896
  async editMessageText(chatId, messageId, text, params) {
1807
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").editMessageText(chatId, messageId, text, params);
1897
+ return await this.#messageManager.editMessageText(chatId, messageId, text, params);
1808
1898
  }
1809
1899
  /**
1810
1900
  * Edit a message's caption.
@@ -1816,7 +1906,7 @@ export class Client extends Composer {
1816
1906
  * @returns The edited message.
1817
1907
  */
1818
1908
  async editMessageCaption(chatId, messageId, params) {
1819
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").editMessageCaption(chatId, messageId, params);
1909
+ return await this.#messageManager.editMessageCaption(chatId, messageId, params);
1820
1910
  }
1821
1911
  /**
1822
1912
  * Edit a message's media.
@@ -1828,7 +1918,7 @@ export class Client extends Composer {
1828
1918
  * @returns The edited message.
1829
1919
  */
1830
1920
  async editMessageMedia(chatId, messageId, media, params) {
1831
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").editMessageMedia(chatId, messageId, media, params);
1921
+ return await this.#messageManager.editMessageMedia(chatId, messageId, media, params);
1832
1922
  }
1833
1923
  /**
1834
1924
  * Edit an inline message's media.
@@ -1838,7 +1928,7 @@ export class Client extends Composer {
1838
1928
  * @param media The new media of the message.
1839
1929
  */
1840
1930
  async editInlineMessageMedia(inlineMessageId, media, params) {
1841
- await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageMedia(inlineMessageId, media, params);
1931
+ await this.#messageManager.editInlineMessageMedia(inlineMessageId, media, params);
1842
1932
  }
1843
1933
  /**
1844
1934
  * Edit an inline message's text. Bot-only.
@@ -1848,7 +1938,7 @@ export class Client extends Composer {
1848
1938
  * @param text The new text of the message.
1849
1939
  */
1850
1940
  async editInlineMessageText(inlineMessageId, text, params) {
1851
- await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageText(inlineMessageId, text, params);
1941
+ await this.#messageManager.editInlineMessageText(inlineMessageId, text, params);
1852
1942
  }
1853
1943
  /**
1854
1944
  * Edit an inline message's caption. Bot-only.
@@ -1857,7 +1947,7 @@ export class Client extends Composer {
1857
1947
  * @param inlineMessageId The identifier of the inline message.
1858
1948
  */
1859
1949
  async editInlineMessageCaption(inlineMessageId, params) {
1860
- await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageCaption(inlineMessageId, params);
1950
+ await this.#messageManager.editInlineMessageCaption(inlineMessageId, params);
1861
1951
  }
1862
1952
  /**
1863
1953
  * Edit a message's reply markup.
@@ -1868,7 +1958,7 @@ export class Client extends Composer {
1868
1958
  * @returns The edited message.
1869
1959
  */
1870
1960
  async editMessageReplyMarkup(chatId, messageId, params) {
1871
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").editMessageReplyMarkup(chatId, messageId, params);
1961
+ return await this.#messageManager.editMessageReplyMarkup(chatId, messageId, params);
1872
1962
  }
1873
1963
  /**
1874
1964
  * Edit an inline message's reply markup. Bot-only.
@@ -1877,7 +1967,7 @@ export class Client extends Composer {
1877
1967
  * @param inlineMessageId The identifier of the inline message.
1878
1968
  */
1879
1969
  async editInlineMessageReplyMarkup(inlineMessageId, params) {
1880
- await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageReplyMarkup(inlineMessageId, params);
1970
+ await this.#messageManager.editInlineMessageReplyMarkup(inlineMessageId, params);
1881
1971
  }
1882
1972
  /**
1883
1973
  * Edit a message's live location.
@@ -1890,7 +1980,7 @@ export class Client extends Composer {
1890
1980
  * @returns The edited location message.
1891
1981
  */
1892
1982
  async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
1893
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
1983
+ return await this.#messageManager.editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
1894
1984
  }
1895
1985
  /**
1896
1986
  * Edit an inline message's live location. Bot-only.
@@ -1902,7 +1992,7 @@ export class Client extends Composer {
1902
1992
  * @returns The edited location message.
1903
1993
  */
1904
1994
  async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
1905
- await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
1995
+ await this.#messageManager.editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
1906
1996
  }
1907
1997
  /**
1908
1998
  * Retrieve multiple messages.
@@ -1917,7 +2007,7 @@ export class Client extends Composer {
1917
2007
  * @cache
1918
2008
  */
1919
2009
  async getMessages(chatId, messageIds) {
1920
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getMessages(chatId, messageIds);
2010
+ return await this.#messageManager.getMessages(chatId, messageIds);
1921
2011
  }
1922
2012
  /**
1923
2013
  * Retrieve a single message.
@@ -1932,7 +2022,7 @@ export class Client extends Composer {
1932
2022
  * @cache
1933
2023
  */
1934
2024
  async getMessage(chatId, messageId) {
1935
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getMessage(chatId, messageId);
2025
+ return await this.#messageManager.getMessage(chatId, messageId);
1936
2026
  }
1937
2027
  /**
1938
2028
  * Retrieve a message using its link.
@@ -1945,7 +2035,7 @@ export class Client extends Composer {
1945
2035
  * @returns The message that was linked to.
1946
2036
  */
1947
2037
  async resolveMessageLink(link) {
1948
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").resolveMessageLink(link);
2038
+ return await this.#messageManager.resolveMessageLink(link);
1949
2039
  }
1950
2040
  /**
1951
2041
  * Delete multiple messages.
@@ -1955,7 +2045,7 @@ export class Client extends Composer {
1955
2045
  * @param messageIds The identifiers of the messages to delete.
1956
2046
  */
1957
2047
  async deleteMessages(chatId, messageIds, params) {
1958
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteMessages(chatId, messageIds, params);
2048
+ await this.#messageManager.deleteMessages(chatId, messageIds, params);
1959
2049
  }
1960
2050
  /**
1961
2051
  * Delete a single message.
@@ -1965,7 +2055,7 @@ export class Client extends Composer {
1965
2055
  * @param messageId The identifier of the message to delete.
1966
2056
  */
1967
2057
  async deleteMessage(chatId, messageId, params) {
1968
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteMessages(chatId, [messageId], params);
2058
+ await this.#messageManager.deleteMessages(chatId, [messageId], params);
1969
2059
  }
1970
2060
  /**
1971
2061
  * Delete all messages sent by a specific member of a chat. User-only.
@@ -1975,7 +2065,7 @@ export class Client extends Composer {
1975
2065
  * @param memberId The identifier of the member.
1976
2066
  */
1977
2067
  async deleteChatMemberMessages(chatId, memberId) {
1978
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatMemberMessages(chatId, memberId);
2068
+ await this.#messageManager.deleteChatMemberMessages(chatId, memberId);
1979
2069
  }
1980
2070
  /**
1981
2071
  * Delete multiple scheduled messages.
@@ -1985,7 +2075,7 @@ export class Client extends Composer {
1985
2075
  * @param messageIds The identifiers of the scheduled messages to delete.
1986
2076
  */
1987
2077
  async deleteScheduledMessages(chatId, messageIds) {
1988
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteScheduledMessages(chatId, messageIds);
2078
+ await this.#messageManager.deleteScheduledMessages(chatId, messageIds);
1989
2079
  }
1990
2080
  /**
1991
2081
  * Delete a scheduled message.
@@ -1995,7 +2085,7 @@ export class Client extends Composer {
1995
2085
  * @param messageId The identifier of the scheduled message to delete.
1996
2086
  */
1997
2087
  async deleteScheduledMessage(chatId, messageId) {
1998
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteScheduledMessage(chatId, messageId);
2088
+ await this.#messageManager.deleteScheduledMessage(chatId, messageId);
1999
2089
  }
2000
2090
  /**
2001
2091
  * Send multiple scheduled messages before their schedule.
@@ -2005,7 +2095,7 @@ export class Client extends Composer {
2005
2095
  * @param messageIds The identifiers of the scheduled messages to send.
2006
2096
  */
2007
2097
  async sendScheduledMessages(chatId, messageIds) {
2008
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendScheduledMessages(chatId, messageIds);
2098
+ return await this.#messageManager.sendScheduledMessages(chatId, messageIds);
2009
2099
  }
2010
2100
  /**
2011
2101
  * Send a scheduled message before its schedule.
@@ -2015,7 +2105,7 @@ export class Client extends Composer {
2015
2105
  * @param messageId The identifier of the scheduled message to send.
2016
2106
  */
2017
2107
  async sendScheduledMessage(chatId, messageId) {
2018
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendScheduledMessage(chatId, messageId);
2108
+ return await this.#messageManager.sendScheduledMessage(chatId, messageId);
2019
2109
  }
2020
2110
  /**
2021
2111
  * Pin a message in a chat.
@@ -2025,7 +2115,7 @@ export class Client extends Composer {
2025
2115
  * @param messageId The identifier of the message.
2026
2116
  */
2027
2117
  async pinMessage(chatId, messageId, params) {
2028
- await __classPrivateFieldGet(this, _Client_messageManager, "f").pinMessage(chatId, messageId, params);
2118
+ await this.#messageManager.pinMessage(chatId, messageId, params);
2029
2119
  }
2030
2120
  /**
2031
2121
  * Unpin a pinned message.
@@ -2035,7 +2125,7 @@ export class Client extends Composer {
2035
2125
  * @param messageId The identifier of the message.
2036
2126
  */
2037
2127
  async unpinMessage(chatId, messageId, params) {
2038
- await __classPrivateFieldGet(this, _Client_messageManager, "f").unpinMessage(chatId, messageId, params);
2128
+ await this.#messageManager.unpinMessage(chatId, messageId, params);
2039
2129
  }
2040
2130
  /**
2041
2131
  * Unpin all pinned messages.
@@ -2044,7 +2134,7 @@ export class Client extends Composer {
2044
2134
  * @param chatId The identifier of a chat.
2045
2135
  */
2046
2136
  async unpinMessages(chatId) {
2047
- await __classPrivateFieldGet(this, _Client_messageManager, "f").unpinMessages(chatId);
2137
+ await this.#messageManager.unpinMessages(chatId);
2048
2138
  }
2049
2139
  /**
2050
2140
  * Forward multiple messages.
@@ -2056,7 +2146,7 @@ export class Client extends Composer {
2056
2146
  * @returns The forwarded messages.
2057
2147
  */
2058
2148
  async forwardMessages(from, to, messageIds, params) {
2059
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").forwardMessages(from, to, messageIds, params);
2149
+ return await this.#messageManager.forwardMessages(from, to, messageIds, params);
2060
2150
  }
2061
2151
  /**
2062
2152
  * Forward a single message.
@@ -2079,7 +2169,7 @@ export class Client extends Composer {
2079
2169
  * @returns The new state of the poll.
2080
2170
  */
2081
2171
  async stopPoll(chatId, messageId, params) {
2082
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").stopPoll(chatId, messageId, params);
2172
+ return await this.#messageManager.stopPoll(chatId, messageId, params);
2083
2173
  }
2084
2174
  /**
2085
2175
  * Send a chat action.
@@ -2090,7 +2180,7 @@ export class Client extends Composer {
2090
2180
  * @param messageThreadId The thread to send the chat action to.
2091
2181
  */
2092
2182
  async sendChatAction(chatId, action, params) {
2093
- await __classPrivateFieldGet(this, _Client_messageManager, "f").sendChatAction(chatId, action, params);
2183
+ await this.#messageManager.sendChatAction(chatId, action, params);
2094
2184
  }
2095
2185
  /**
2096
2186
  * Search the messages of a chat. User-only.
@@ -2100,7 +2190,7 @@ export class Client extends Composer {
2100
2190
  * @param query The message search query.
2101
2191
  */
2102
2192
  async searchMessages(chatId, query, params) {
2103
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").searchMessages(chatId, query, params);
2193
+ return await this.#messageManager.searchMessages(chatId, query, params);
2104
2194
  }
2105
2195
  /**
2106
2196
  * Mark messages as read. User-only.
@@ -2110,7 +2200,7 @@ export class Client extends Composer {
2110
2200
  * @param untilMessageId The identifier of the message that will be marked as read, along with any other unread messages before it.
2111
2201
  */
2112
2202
  async readMessages(chatId, untilMessageId) {
2113
- await __classPrivateFieldGet(this, _Client_messageManager, "f").readMessages(chatId, untilMessageId);
2203
+ await this.#messageManager.readMessages(chatId, untilMessageId);
2114
2204
  }
2115
2205
  /**
2116
2206
  * Start a bot. User-only.
@@ -2120,7 +2210,7 @@ export class Client extends Composer {
2120
2210
  * @returns The start message.
2121
2211
  */
2122
2212
  async startBot(botId, params) {
2123
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").startBot(botId, params);
2213
+ return await this.#messageManager.startBot(botId, params);
2124
2214
  }
2125
2215
  /**
2126
2216
  * Transcribe a voice message. User-only.
@@ -2131,7 +2221,7 @@ export class Client extends Composer {
2131
2221
  * @cache
2132
2222
  */
2133
2223
  async transcribeVoice(chatId, messageId) {
2134
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").transcribeVoice(chatId, messageId);
2224
+ return await this.#messageManager.transcribeVoice(chatId, messageId);
2135
2225
  }
2136
2226
  /**
2137
2227
  * Get the link preview for a message that is about to be sent. User-only.
@@ -2140,7 +2230,7 @@ export class Client extends Composer {
2140
2230
  * @param text The message's text.
2141
2231
  */
2142
2232
  async getLinkPreview(text, params) {
2143
- return await __classPrivateFieldGet(this, _Client_linkPreviewManager, "f").getLinkPreview(text, params);
2233
+ return await this.#linkPreviewManager.getLinkPreview(text, params);
2144
2234
  }
2145
2235
  /**
2146
2236
  * Open a mini app. User-only.
@@ -2151,7 +2241,16 @@ export class Client extends Composer {
2151
2241
  * @cache
2152
2242
  */
2153
2243
  async openMiniApp(botId, chatId, params) {
2154
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").openMiniApp(botId, chatId, params);
2244
+ return await this.#messageManager.openMiniApp(botId, chatId, params);
2245
+ }
2246
+ /**
2247
+ * Get a progress ID that can be passed to relevant send* methods to receive upload progress updates for them.
2248
+ *
2249
+ * @method ms
2250
+ * @cache
2251
+ */
2252
+ async getProgressId() {
2253
+ return await this.#fileManager.getProgressId();
2155
2254
  }
2156
2255
  //
2157
2256
  // ========================= POLLS ========================= //
@@ -2165,7 +2264,7 @@ export class Client extends Composer {
2165
2264
  * @param optionIndexes The indexes of the options to cast for.
2166
2265
  */
2167
2266
  async vote(chatId, messageId, optionIndexes) {
2168
- await __classPrivateFieldGet(this, _Client_pollManager, "f").vote(chatId, messageId, optionIndexes);
2267
+ await this.#pollManager.vote(chatId, messageId, optionIndexes);
2169
2268
  }
2170
2269
  /**
2171
2270
  * Retract a vote. User-only.
@@ -2175,7 +2274,7 @@ export class Client extends Composer {
2175
2274
  * @param messageId The identifier of the message that includes the poll.
2176
2275
  */
2177
2276
  async retractVote(chatId, messageId) {
2178
- await __classPrivateFieldGet(this, _Client_pollManager, "f").retractVote(chatId, messageId);
2277
+ await this.#pollManager.retractVote(chatId, messageId);
2179
2278
  }
2180
2279
  //
2181
2280
  // ========================= FILES ========================= //
@@ -2194,7 +2293,7 @@ export class Client extends Composer {
2194
2293
  * @cache file
2195
2294
  */
2196
2295
  async *download(fileId, params) {
2197
- for await (const chunk of __classPrivateFieldGet(this, _Client_fileManager, "f").download(fileId, params)) {
2296
+ for await (const chunk of this.#fileManager.download(fileId, params)) {
2198
2297
  yield chunk;
2199
2298
  }
2200
2299
  }
@@ -2207,7 +2306,7 @@ export class Client extends Composer {
2207
2306
  * @cache
2208
2307
  */
2209
2308
  async getCustomEmojiStickers(id) {
2210
- return await __classPrivateFieldGet(this, _Client_fileManager, "f").getCustomEmojiStickers(id);
2309
+ return await this.#fileManager.getCustomEmojiStickers(id);
2211
2310
  }
2212
2311
  //
2213
2312
  // ========================= CHATS ========================= //
@@ -2218,7 +2317,7 @@ export class Client extends Composer {
2218
2317
  * @method ch
2219
2318
  */
2220
2319
  async getChats(params) {
2221
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChats(params?.from, params?.after, params?.limit);
2320
+ return await this.#chatListManager.getChats(params?.from, params?.after, params?.limit);
2222
2321
  }
2223
2322
  /**
2224
2323
  * Get a chat.
@@ -2227,7 +2326,7 @@ export class Client extends Composer {
2227
2326
  * @cache
2228
2327
  */
2229
2328
  async getChat(chatId) {
2230
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChat(chatId);
2329
+ return await this.#chatListManager.getChat(chatId);
2231
2330
  }
2232
2331
  /**
2233
2332
  * Get chat history. User-only.
@@ -2236,7 +2335,7 @@ export class Client extends Composer {
2236
2335
  * @param chatId The identifier of a chat.
2237
2336
  */
2238
2337
  async getHistory(chatId, params) {
2239
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getHistory(chatId, params);
2338
+ return await this.#messageManager.getHistory(chatId, params);
2240
2339
  }
2241
2340
  /**
2242
2341
  * Set a chat's available reactions. User-only.
@@ -2246,7 +2345,7 @@ export class Client extends Composer {
2246
2345
  * @param availableReactions The new available reactions.
2247
2346
  */
2248
2347
  async setAvailableReactions(chatId, availableReactions) {
2249
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setAvailableReactions(chatId, availableReactions);
2348
+ await this.#chatManager.setAvailableReactions(chatId, availableReactions);
2250
2349
  }
2251
2350
  /**
2252
2351
  * Set a chat's photo.
@@ -2256,7 +2355,7 @@ export class Client extends Composer {
2256
2355
  * @param photo A photo to set as the chat's photo.
2257
2356
  */
2258
2357
  async setChatPhoto(chatId, photo, params) {
2259
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setChatPhoto(chatId, photo, params);
2358
+ await this.#chatManager.setChatPhoto(chatId, photo, params);
2260
2359
  }
2261
2360
  /**
2262
2361
  * Delete a chat's photo.
@@ -2265,7 +2364,7 @@ export class Client extends Composer {
2265
2364
  * @param chatId The identifier of a chat.
2266
2365
  */
2267
2366
  async deleteChatPhoto(chatId) {
2268
- await __classPrivateFieldGet(this, _Client_chatManager, "f").deleteChatPhoto(chatId);
2367
+ await this.#chatManager.deleteChatPhoto(chatId);
2269
2368
  }
2270
2369
  /**
2271
2370
  * Ban a member from a chat.
@@ -2275,7 +2374,7 @@ export class Client extends Composer {
2275
2374
  * @param memberId The identifier of the member.
2276
2375
  */
2277
2376
  async banChatMember(chatId, memberId, params) {
2278
- await __classPrivateFieldGet(this, _Client_chatManager, "f").banChatMember(chatId, memberId, params);
2377
+ await this.#chatManager.banChatMember(chatId, memberId, params);
2279
2378
  }
2280
2379
  /**
2281
2380
  * Unban a member from a chat.
@@ -2285,7 +2384,7 @@ export class Client extends Composer {
2285
2384
  * @param memberId The identifier of the member.
2286
2385
  */
2287
2386
  async unbanChatMember(chatId, memberId) {
2288
- await __classPrivateFieldGet(this, _Client_chatManager, "f").unbanChatMember(chatId, memberId);
2387
+ await this.#chatManager.unbanChatMember(chatId, memberId);
2289
2388
  }
2290
2389
  /**
2291
2390
  * Kick a member from a chat. Same as a banChatMember call followed by unbanChatMember.
@@ -2295,8 +2394,8 @@ export class Client extends Composer {
2295
2394
  * @param memberId The identifier of the member.
2296
2395
  */
2297
2396
  async kickChatMember(chatId, memberId) {
2298
- await __classPrivateFieldGet(this, _Client_chatManager, "f").banChatMember(chatId, memberId);
2299
- await __classPrivateFieldGet(this, _Client_chatManager, "f").unbanChatMember(chatId, memberId);
2397
+ await this.#chatManager.banChatMember(chatId, memberId);
2398
+ await this.#chatManager.unbanChatMember(chatId, memberId);
2300
2399
  }
2301
2400
  /**
2302
2401
  * Set the rights of a chat member.
@@ -2306,7 +2405,7 @@ export class Client extends Composer {
2306
2405
  * @param memberId The identifier of the member.
2307
2406
  */
2308
2407
  async setChatMemberRights(chatId, memberId, params) {
2309
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setChatMemberRights(chatId, memberId, params);
2408
+ await this.#chatManager.setChatMemberRights(chatId, memberId, params);
2310
2409
  }
2311
2410
  /**
2312
2411
  * Get the administrators of a chat.
@@ -2316,7 +2415,7 @@ export class Client extends Composer {
2316
2415
  * @returns The chat's administrators.
2317
2416
  */
2318
2417
  async getChatAdministrators(chatId) {
2319
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChatAdministrators(chatId);
2418
+ return await this.#chatListManager.getChatAdministrators(chatId);
2320
2419
  }
2321
2420
  /**
2322
2421
  * Enable join requests in a chat. User-only.
@@ -2325,7 +2424,7 @@ export class Client extends Composer {
2325
2424
  * @param chatId The identifier of a chat. Must be a channel or a supergroup.
2326
2425
  */
2327
2426
  async enableJoinRequests(chatId) {
2328
- await __classPrivateFieldGet(this, _Client_chatManager, "f").enableJoinRequests(chatId);
2427
+ await this.#chatManager.enableJoinRequests(chatId);
2329
2428
  }
2330
2429
  /**
2331
2430
  * Disable join requests in a chat. User-only.
@@ -2334,7 +2433,7 @@ export class Client extends Composer {
2334
2433
  * @param chatId The identifier of a chat. Must be a channel or a supergroup.
2335
2434
  */
2336
2435
  async disableJoinRequests(chatId) {
2337
- await __classPrivateFieldGet(this, _Client_chatManager, "f").disableJoinRequests(chatId);
2436
+ await this.#chatManager.disableJoinRequests(chatId);
2338
2437
  }
2339
2438
  /**
2340
2439
  * Get inactive chats. User-only.
@@ -2343,7 +2442,7 @@ export class Client extends Composer {
2343
2442
  * @retuns A list of inactive chats the current user is member of.
2344
2443
  */
2345
2444
  async getInactiveChats() {
2346
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").getInactiveChats();
2445
+ return await this.#accountManager.getInactiveChats();
2347
2446
  }
2348
2447
  /**
2349
2448
  * Get the invite links created for a chat. User-only.
@@ -2353,7 +2452,7 @@ export class Client extends Composer {
2353
2452
  * @returns The invite links created for the chat. This might be a subset of the results if they were less than `limit`. The parameters `afterDate` and `afterInviteLink` can be used for pagination.
2354
2453
  */
2355
2454
  async getCreatedInviteLinks(chatId, params) {
2356
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").getCreatedInviteLinks(chatId, params);
2455
+ return await this.#chatManager.getCreatedInviteLinks(chatId, params);
2357
2456
  }
2358
2457
  /**
2359
2458
  * Join a chat. User-only.
@@ -2362,7 +2461,7 @@ export class Client extends Composer {
2362
2461
  * @param chatId The identifier of a chat.
2363
2462
  */
2364
2463
  async joinChat(chatId) {
2365
- await __classPrivateFieldGet(this, _Client_chatManager, "f").joinChat(chatId);
2464
+ await this.#chatManager.joinChat(chatId);
2366
2465
  }
2367
2466
  /**
2368
2467
  * Leave a chat.
@@ -2371,7 +2470,7 @@ export class Client extends Composer {
2371
2470
  * @param chatId The identifier of a chat.
2372
2471
  */
2373
2472
  async leaveChat(chatId) {
2374
- await __classPrivateFieldGet(this, _Client_chatManager, "f").leaveChat(chatId);
2473
+ await this.#chatManager.leaveChat(chatId);
2375
2474
  }
2376
2475
  /**
2377
2476
  * Get information on a user's chat membership.
@@ -2381,7 +2480,7 @@ export class Client extends Composer {
2381
2480
  * @param userId The identifier of the user.
2382
2481
  */
2383
2482
  async getChatMember(chatId, userId) {
2384
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChatMember(chatId, userId);
2483
+ return await this.#chatListManager.getChatMember(chatId, userId);
2385
2484
  }
2386
2485
  /**
2387
2486
  * Get the members of a chat.
@@ -2390,7 +2489,7 @@ export class Client extends Composer {
2390
2489
  * @param chatId The identifier of a chat.
2391
2490
  */
2392
2491
  async getChatMembers(chatId, params) {
2393
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChatMembers(chatId, params);
2492
+ return await this.#chatListManager.getChatMembers(chatId, params);
2394
2493
  }
2395
2494
  /**
2396
2495
  * Set a chat's sticker set.
@@ -2400,7 +2499,7 @@ export class Client extends Composer {
2400
2499
  * @param setName The name of the set.
2401
2500
  */
2402
2501
  async setChatStickerSet(chatId, setName) {
2403
- await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatStickerSet(chatId, setName);
2502
+ await this.#messageManager.setChatStickerSet(chatId, setName);
2404
2503
  }
2405
2504
  /**
2406
2505
  * Delete a chat's sticker set.
@@ -2409,7 +2508,7 @@ export class Client extends Composer {
2409
2508
  * @param chatId The identifier of a chat. Must be a supergroup.
2410
2509
  */
2411
2510
  async deleteChatStickerSet(chatId) {
2412
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatStickerSet(chatId);
2511
+ await this.#messageManager.deleteChatStickerSet(chatId);
2413
2512
  }
2414
2513
  /**
2415
2514
  * Set the number of boosts required to circument a chat's default restrictions. User-only.
@@ -2419,7 +2518,7 @@ export class Client extends Composer {
2419
2518
  * @param boosts The number of boosts required to circumvent its restrictions.
2420
2519
  */
2421
2520
  async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
2422
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setBoostsRequiredToCircumventRestrictions(chatId, boosts);
2521
+ await this.#chatManager.setBoostsRequiredToCircumventRestrictions(chatId, boosts);
2423
2522
  }
2424
2523
  /**
2425
2524
  * Create an invite link.
@@ -2429,7 +2528,7 @@ export class Client extends Composer {
2429
2528
  * @returns The newly created invite link.
2430
2529
  */
2431
2530
  async createInviteLink(chatId, params) {
2432
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").createInviteLink(chatId, params);
2531
+ return await this.#chatManager.createInviteLink(chatId, params);
2433
2532
  }
2434
2533
  /**
2435
2534
  * Approve a join request.
@@ -2439,7 +2538,7 @@ export class Client extends Composer {
2439
2538
  * @param userId The user who made the join request.
2440
2539
  */
2441
2540
  async approveJoinRequest(chatId, userId) {
2442
- await __classPrivateFieldGet(this, _Client_chatManager, "f").approveJoinRequest(chatId, userId);
2541
+ await this.#chatManager.approveJoinRequest(chatId, userId);
2443
2542
  }
2444
2543
  /**
2445
2544
  * Decline a join request.
@@ -2449,7 +2548,7 @@ export class Client extends Composer {
2449
2548
  * @param userId The user who made the join request.
2450
2549
  */
2451
2550
  async declineJoinRequest(chatId, userId) {
2452
- await __classPrivateFieldGet(this, _Client_chatManager, "f").declineJoinRequest(chatId, userId);
2551
+ await this.#chatManager.declineJoinRequest(chatId, userId);
2453
2552
  }
2454
2553
  /**
2455
2554
  * Approve all join requests. User-only.
@@ -2458,7 +2557,7 @@ export class Client extends Composer {
2458
2557
  * @param chatId The identifier of a chat with the join requests.
2459
2558
  */
2460
2559
  async approveJoinRequests(chatId, params) {
2461
- await __classPrivateFieldGet(this, _Client_chatManager, "f").approveJoinRequests(chatId, params);
2560
+ await this.#chatManager.approveJoinRequests(chatId, params);
2462
2561
  }
2463
2562
  /**
2464
2563
  * Decline all join requests. User-only.
@@ -2467,7 +2566,7 @@ export class Client extends Composer {
2467
2566
  * @param chatId The identifier of a chat with the join requests.
2468
2567
  */
2469
2568
  async declineJoinRequests(chatId, params) {
2470
- await __classPrivateFieldGet(this, _Client_chatManager, "f").declineJoinRequests(chatId, params);
2569
+ await this.#chatManager.declineJoinRequests(chatId, params);
2471
2570
  }
2472
2571
  /**
2473
2572
  * Get pending join requests in a chat. User-only.
@@ -2476,7 +2575,7 @@ export class Client extends Composer {
2476
2575
  * @param chatId The identifier of a chat with the join requests.
2477
2576
  */
2478
2577
  async getJoinRequests(chatId, params) {
2479
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").getJoinRequests(chatId, params);
2578
+ return await this.#chatManager.getJoinRequests(chatId, params);
2480
2579
  }
2481
2580
  /**
2482
2581
  * Add a single user to a chat.
@@ -2487,7 +2586,7 @@ export class Client extends Composer {
2487
2586
  * @returns An array of FailedInvitation that has at most a length of 1. If empty, it means that the user was added.
2488
2587
  */
2489
2588
  async addChatMember(chatId, userId, params) {
2490
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").addChatMember(chatId, userId, params);
2589
+ return await this.#chatManager.addChatMember(chatId, userId, params);
2491
2590
  }
2492
2591
  /**
2493
2592
  * Add multiple users at once to a channel or a supergroup.
@@ -2497,7 +2596,7 @@ export class Client extends Composer {
2497
2596
  * @param userId The identifiers of the users to add to the channel or supergroup.
2498
2597
  */
2499
2598
  async addChatMembers(chatId, userIds) {
2500
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").addChatMembers(chatId, userIds);
2599
+ return await this.#chatManager.addChatMembers(chatId, userIds);
2501
2600
  }
2502
2601
  /**
2503
2602
  * Open a chat.
@@ -2506,7 +2605,7 @@ export class Client extends Composer {
2506
2605
  * @param chatId The identifier of a chat to open.
2507
2606
  */
2508
2607
  async openChat(chatId) {
2509
- await __classPrivateFieldGet(this, _Client_updateManager, "f").openChat(chatId);
2608
+ await this.#updateManager.openChat(chatId);
2510
2609
  }
2511
2610
  /**
2512
2611
  * Close a chat previously opened by openChat.
@@ -2515,7 +2614,7 @@ export class Client extends Composer {
2515
2614
  * @param chatId The identifier of a chat to close.
2516
2615
  */
2517
2616
  async closeChat(chatId) {
2518
- await __classPrivateFieldGet(this, _Client_updateManager, "f").closeChat(chatId);
2617
+ await this.#updateManager.closeChat(chatId);
2519
2618
  }
2520
2619
  /**
2521
2620
  * Create a group. User-only.
@@ -2525,7 +2624,7 @@ export class Client extends Composer {
2525
2624
  * @returns The created group.
2526
2625
  */
2527
2626
  async createGroup(title, params) {
2528
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").createGroup(title, params);
2627
+ return await this.#chatListManager.createGroup(title, params);
2529
2628
  }
2530
2629
  /**
2531
2630
  * Create a supergroup. User-only.
@@ -2535,7 +2634,7 @@ export class Client extends Composer {
2535
2634
  * @returns The created supergroup.
2536
2635
  */
2537
2636
  async createSupergroup(title, params) {
2538
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").createSupergroup(title, params);
2637
+ return await this.#chatListManager.createSupergroup(title, params);
2539
2638
  }
2540
2639
  /**
2541
2640
  * Create a channel. User-only.
@@ -2545,7 +2644,7 @@ export class Client extends Composer {
2545
2644
  * @returns The created channel.
2546
2645
  */
2547
2646
  async createChannel(title, params) {
2548
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").createChannel(title, params);
2647
+ return await this.#chatListManager.createChannel(title, params);
2549
2648
  }
2550
2649
  /**
2551
2650
  * Set the time to live of the messages of a chat. User-only.
@@ -2555,7 +2654,7 @@ export class Client extends Composer {
2555
2654
  * @param messageTtl The time to live of the messages in seconds.
2556
2655
  */
2557
2656
  async setMessageTtl(chatId, messageTtl) {
2558
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").setMessageTtl(chatId, messageTtl);
2657
+ await this.#chatListManager.setMessageTtl(chatId, messageTtl);
2559
2658
  }
2560
2659
  /**
2561
2660
  * Archive multiple chats. User-only.
@@ -2564,7 +2663,7 @@ export class Client extends Composer {
2564
2663
  * @param chatIds The identifiers of the chats to archive.
2565
2664
  */
2566
2665
  async archiveChats(chatIds) {
2567
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").archiveChats(chatIds);
2666
+ await this.#chatListManager.archiveChats(chatIds);
2568
2667
  }
2569
2668
  /**
2570
2669
  * Archive a single chat. User-only.
@@ -2573,7 +2672,7 @@ export class Client extends Composer {
2573
2672
  * @param chatId The identifier of a chat.
2574
2673
  */
2575
2674
  async archiveChat(chatId) {
2576
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").archiveChat(chatId);
2675
+ await this.#chatListManager.archiveChat(chatId);
2577
2676
  }
2578
2677
  /**
2579
2678
  * Unarchive multiple chats. User-only.
@@ -2582,7 +2681,7 @@ export class Client extends Composer {
2582
2681
  * @param chatIds The identifiers of the chats to unarchive.
2583
2682
  */
2584
2683
  async unarchiveChats(chatIds) {
2585
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").unarchiveChats(chatIds);
2684
+ await this.#chatListManager.unarchiveChats(chatIds);
2586
2685
  }
2587
2686
  /**
2588
2687
  * Unarchive a single chat. User-only.
@@ -2591,7 +2690,7 @@ export class Client extends Composer {
2591
2690
  * @param chatId The identifier of a chat.
2592
2691
  */
2593
2692
  async unarchiveChat(chatId) {
2594
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").unarchiveChat(chatId);
2693
+ await this.#chatListManager.unarchiveChat(chatId);
2595
2694
  }
2596
2695
  /**
2597
2696
  * Get common chats between a user and the current one. User-only.
@@ -2600,7 +2699,7 @@ export class Client extends Composer {
2600
2699
  * @param userId The identifier of the user to get the common chats with them.
2601
2700
  */
2602
2701
  async getCommonChats(userId, params) {
2603
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getCommonChats(userId, params);
2702
+ return await this.#chatListManager.getCommonChats(userId, params);
2604
2703
  }
2605
2704
  /**
2606
2705
  * Get the settings of a chat. User-only.
@@ -2609,7 +2708,7 @@ export class Client extends Composer {
2609
2708
  * @param chatId The identifier of a chat.
2610
2709
  */
2611
2710
  async getChatSettings(chatId) {
2612
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChatSettings(chatId);
2711
+ return await this.#chatListManager.getChatSettings(chatId);
2613
2712
  }
2614
2713
  /**
2615
2714
  * Disable business bots in a private chat. User-only.
@@ -2618,7 +2717,7 @@ export class Client extends Composer {
2618
2717
  * @param chatId The identifier of the private chat to disable business bots in.
2619
2718
  */
2620
2719
  async disableBusinessBots(chatId) {
2621
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").disableBusinessBots(chatId);
2720
+ await this.#chatListManager.disableBusinessBots(chatId);
2622
2721
  }
2623
2722
  /**
2624
2723
  * Enable business bots in a private chat. User-only.
@@ -2627,7 +2726,7 @@ export class Client extends Composer {
2627
2726
  * @param chatId The identifier of the private chat to enable business bots in.
2628
2727
  */
2629
2728
  async enableBusinessBots(chatId) {
2630
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").enableBusinessBots(chatId);
2729
+ await this.#chatListManager.enableBusinessBots(chatId);
2631
2730
  }
2632
2731
  /**
2633
2732
  * Disable slow mode in a group. User-only.
@@ -2636,7 +2735,7 @@ export class Client extends Composer {
2636
2735
  * @param chatId The identifier of the group to disable slow mode in.
2637
2736
  */
2638
2737
  async disableSlowMode(chatId) {
2639
- await __classPrivateFieldGet(this, _Client_chatManager, "f").disableSlowMode(chatId);
2738
+ await this.#chatManager.disableSlowMode(chatId);
2640
2739
  }
2641
2740
  /**
2642
2741
  * Change slow mode in a group. User-only.
@@ -2646,7 +2745,7 @@ export class Client extends Composer {
2646
2745
  * @param duration New slow mode duration.
2647
2746
  */
2648
2747
  async setSlowMode(chatId, duration) {
2649
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setSlowMode(chatId, duration);
2748
+ await this.#chatManager.setSlowMode(chatId, duration);
2650
2749
  }
2651
2750
  /**
2652
2751
  * Change the title of a chat.
@@ -2656,7 +2755,7 @@ export class Client extends Composer {
2656
2755
  * @param title The new title.
2657
2756
  */
2658
2757
  async setChatTitle(chatId, title) {
2659
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setChatTitle(chatId, title);
2758
+ await this.#chatManager.setChatTitle(chatId, title);
2660
2759
  }
2661
2760
  /**
2662
2761
  * Change the description of a chat.
@@ -2666,7 +2765,7 @@ export class Client extends Composer {
2666
2765
  * @param description The new description.
2667
2766
  */
2668
2767
  async setChatDescription(chatId, description) {
2669
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setChatDescription(chatId, description);
2768
+ await this.#chatManager.setChatDescription(chatId, description);
2670
2769
  }
2671
2770
  /**
2672
2771
  * Hide or show the member list of a group to non-admins. User-only.
@@ -2676,7 +2775,7 @@ export class Client extends Composer {
2676
2775
  * @param visible Whether the member list of the group should be visible.
2677
2776
  */
2678
2777
  async setMemberListVisibility(chatId, visible) {
2679
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setMemberListVisibility(chatId, visible);
2778
+ await this.#chatManager.setMemberListVisibility(chatId, visible);
2680
2779
  }
2681
2780
  /**
2682
2781
  * Enable or disable topics in a group. User-only.
@@ -2686,7 +2785,7 @@ export class Client extends Composer {
2686
2785
  * @param enabled Whether topics should be enabled in the group.
2687
2786
  */
2688
2787
  async setTopicsEnabled(chatId, enabled) {
2689
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setTopicsEnabled(chatId, enabled);
2788
+ await this.#chatManager.setTopicsEnabled(chatId, enabled);
2690
2789
  }
2691
2790
  /**
2692
2791
  * Enable or disable automatic anti-spam in a group. User-only.
@@ -2696,7 +2795,7 @@ export class Client extends Composer {
2696
2795
  * @param enabled Whether automatic anti-spam should be enabled in the group.
2697
2796
  */
2698
2797
  async setAntispamEnabled(chatId, enabled) {
2699
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setAntispamEnabled(chatId, enabled);
2798
+ await this.#chatManager.setAntispamEnabled(chatId, enabled);
2700
2799
  }
2701
2800
  /**
2702
2801
  * Enable or disable post signatures in a channel. User-only.
@@ -2706,7 +2805,7 @@ export class Client extends Composer {
2706
2805
  * @param enabled Whether post signatures should be enabled in the channel.
2707
2806
  */
2708
2807
  async setSignaturesEnabled(chatId, enabled, params) {
2709
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setSignaturesEnabled(chatId, enabled, params);
2808
+ await this.#chatManager.setSignaturesEnabled(chatId, enabled, params);
2710
2809
  }
2711
2810
  /**
2712
2811
  * Delete a chat. User-only.
@@ -2715,7 +2814,7 @@ export class Client extends Composer {
2715
2814
  * @param chatId The identifier of a chat.
2716
2815
  */
2717
2816
  async deleteChat(chatId) {
2718
- await __classPrivateFieldGet(this, _Client_chatManager, "f").deleteChat(chatId);
2817
+ await this.#chatManager.deleteChat(chatId);
2719
2818
  }
2720
2819
  /**
2721
2820
  * Get discussion chat suggestions. User-only.
@@ -2723,7 +2822,7 @@ export class Client extends Composer {
2723
2822
  * @method ch
2724
2823
  */
2725
2824
  async getDiscussionChatSuggestions() {
2726
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").getDiscussionChatSuggestions();
2825
+ return await this.#chatManager.getDiscussionChatSuggestions();
2727
2826
  }
2728
2827
  /**
2729
2828
  * Set a channel's discussion chat. User-only.
@@ -2733,7 +2832,7 @@ export class Client extends Composer {
2733
2832
  * @param discussionChatId The identifier of a chat to use as discussion for the channel.
2734
2833
  */
2735
2834
  async setDiscussionChat(chatId, discussionChatId) {
2736
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setDiscussionChat(chatId, discussionChatId);
2835
+ await this.#chatManager.setDiscussionChat(chatId, discussionChatId);
2737
2836
  }
2738
2837
  /**
2739
2838
  * Transfer the ownership of a chat. User-only.
@@ -2744,7 +2843,7 @@ export class Client extends Composer {
2744
2843
  * @param password The password of the current account.
2745
2844
  */
2746
2845
  async transferChatOwnership(chatId, userId, password) {
2747
- await __classPrivateFieldGet(this, _Client_chatManager, "f").transferChatOwnership(chatId, userId, password);
2846
+ await this.#chatManager.transferChatOwnership(chatId, userId, password);
2748
2847
  }
2749
2848
  /**
2750
2849
  * Create a forum topic.
@@ -2755,7 +2854,7 @@ export class Client extends Composer {
2755
2854
  * @returns The created topic.
2756
2855
  */
2757
2856
  async createTopic(chatId, title, params) {
2758
- return await __classPrivateFieldGet(this, _Client_forumManager, "f").createTopic(chatId, title, params);
2857
+ return await this.#forumManager.createTopic(chatId, title, params);
2759
2858
  }
2760
2859
  /**
2761
2860
  * Edit a forum topic.
@@ -2767,7 +2866,7 @@ export class Client extends Composer {
2767
2866
  * @returns The new topic.
2768
2867
  */
2769
2868
  async editTopic(chatId, topicId, title, params) {
2770
- return await __classPrivateFieldGet(this, _Client_forumManager, "f").editTopic(chatId, topicId, title, params);
2869
+ return await this.#forumManager.editTopic(chatId, topicId, title, params);
2771
2870
  }
2772
2871
  /**
2773
2872
  * Hide the general forum topic.
@@ -2776,7 +2875,7 @@ export class Client extends Composer {
2776
2875
  * @param chatId The identifier of a chat.
2777
2876
  */
2778
2877
  async hideGeneralTopic(chatId) {
2779
- await __classPrivateFieldGet(this, _Client_forumManager, "f").hideGeneralTopic(chatId);
2878
+ await this.#forumManager.hideGeneralTopic(chatId);
2780
2879
  }
2781
2880
  /**
2782
2881
  * Show the general forum topic.
@@ -2785,7 +2884,7 @@ export class Client extends Composer {
2785
2884
  * @param chatId The identifier of a chat.
2786
2885
  */
2787
2886
  async showGeneralTopic(chatId) {
2788
- await __classPrivateFieldGet(this, _Client_forumManager, "f").showGeneralTopic(chatId);
2887
+ await this.#forumManager.showGeneralTopic(chatId);
2789
2888
  }
2790
2889
  /**
2791
2890
  * Close a forum topic.
@@ -2795,7 +2894,7 @@ export class Client extends Composer {
2795
2894
  * @param topicId The identifier of the topic.
2796
2895
  */
2797
2896
  async closeTopic(chatId, topicId) {
2798
- await __classPrivateFieldGet(this, _Client_forumManager, "f").closeTopic(chatId, topicId);
2897
+ await this.#forumManager.closeTopic(chatId, topicId);
2799
2898
  }
2800
2899
  /**
2801
2900
  * Reopen a forum topic.
@@ -2805,7 +2904,7 @@ export class Client extends Composer {
2805
2904
  * @param topicId The identifier of the topic.
2806
2905
  */
2807
2906
  async reopenTopic(chatId, topicId) {
2808
- await __classPrivateFieldGet(this, _Client_forumManager, "f").reopenTopic(chatId, topicId);
2907
+ await this.#forumManager.reopenTopic(chatId, topicId);
2809
2908
  }
2810
2909
  /**
2811
2910
  * Pin a forum topic.
@@ -2815,7 +2914,7 @@ export class Client extends Composer {
2815
2914
  * @param topicId The identifier of the topic.
2816
2915
  */
2817
2916
  async pinTopic(chatId, topicId) {
2818
- await __classPrivateFieldGet(this, _Client_forumManager, "f").pinTopic(chatId, topicId);
2917
+ await this.#forumManager.pinTopic(chatId, topicId);
2819
2918
  }
2820
2919
  /**
2821
2920
  * Unpin a forum topic.
@@ -2825,7 +2924,7 @@ export class Client extends Composer {
2825
2924
  * @param topicId The identifier of the topic.
2826
2925
  */
2827
2926
  async unpinTopic(chatId, topicId) {
2828
- await __classPrivateFieldGet(this, _Client_forumManager, "f").unpinTopic(chatId, topicId);
2927
+ await this.#forumManager.unpinTopic(chatId, topicId);
2829
2928
  }
2830
2929
  //
2831
2930
  // ========================= CALLBACK QUERIES ========================= //
@@ -2841,7 +2940,7 @@ export class Client extends Composer {
2841
2940
  * @cache
2842
2941
  */
2843
2942
  async sendCallbackQuery(botId, messageId, question) {
2844
- return await __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").sendCallbackQuery(botId, messageId, question);
2943
+ return await this.#callbackQueryManager.sendCallbackQuery(botId, messageId, question);
2845
2944
  }
2846
2945
  /**
2847
2946
  * Answer a callback query. Bot-only.
@@ -2850,7 +2949,7 @@ export class Client extends Composer {
2850
2949
  * @param id ID of the callback query to answer.
2851
2950
  */
2852
2951
  async answerCallbackQuery(id, params) {
2853
- await __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").answerCallbackQuery(id, params);
2952
+ await this.#callbackQueryManager.answerCallbackQuery(id, params);
2854
2953
  }
2855
2954
  //
2856
2955
  // ========================= INLINE QUERIES ========================= //
@@ -2865,7 +2964,7 @@ export class Client extends Composer {
2865
2964
  * @cache
2866
2965
  */
2867
2966
  async sendInlineQuery(botId, chatId, params) {
2868
- return await __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").sendInlineQuery(botId, chatId, params);
2967
+ return await this.#inlineQueryManager.sendInlineQuery(botId, chatId, params);
2869
2968
  }
2870
2969
  /**
2871
2970
  * Answer an inline query. Bot-only.
@@ -2875,7 +2974,7 @@ export class Client extends Composer {
2875
2974
  * @param results The results to answer with.
2876
2975
  */
2877
2976
  async answerInlineQuery(id, results, params) {
2878
- await __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").answerInlineQuery(id, results, params);
2977
+ await this.#inlineQueryManager.answerInlineQuery(id, results, params);
2879
2978
  }
2880
2979
  //
2881
2980
  // ========================= BOTS ========================= //
@@ -2886,7 +2985,7 @@ export class Client extends Composer {
2886
2985
  * @method bs
2887
2986
  */
2888
2987
  async setMyDescription(params) {
2889
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyDescription(params);
2988
+ await this.#botInfoManager.setMyDescription(params);
2890
2989
  }
2891
2990
  /**
2892
2991
  * Set the bot's name in the given language. Bot-only.
@@ -2894,7 +2993,7 @@ export class Client extends Composer {
2894
2993
  * @method bs
2895
2994
  */
2896
2995
  async setMyName(params) {
2897
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyName(params);
2996
+ await this.#botInfoManager.setMyName(params);
2898
2997
  }
2899
2998
  /**
2900
2999
  * Set the bot's short description in the given language. Bot-only.
@@ -2902,7 +3001,7 @@ export class Client extends Composer {
2902
3001
  * @method bs
2903
3002
  */
2904
3003
  async setMyShortDescription(params) {
2905
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyShortDescription(params);
3004
+ await this.#botInfoManager.setMyShortDescription(params);
2906
3005
  }
2907
3006
  /**
2908
3007
  * Get the bot's description in the given language. Bot-only.
@@ -2911,7 +3010,7 @@ export class Client extends Composer {
2911
3010
  * @returns The current bot's description in the specified language.
2912
3011
  */
2913
3012
  async getMyDescription(params) {
2914
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyDescription(params);
3013
+ return await this.#botInfoManager.getMyDescription(params);
2915
3014
  }
2916
3015
  /**
2917
3016
  * Get the bot's name in the given language. Bot-only.
@@ -2920,7 +3019,7 @@ export class Client extends Composer {
2920
3019
  * @returns The current bot's name in the specified language.
2921
3020
  */
2922
3021
  async getMyName(params) {
2923
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyName(params);
3022
+ return await this.#botInfoManager.getMyName(params);
2924
3023
  }
2925
3024
  /**
2926
3025
  * Get the bot's short description in the given language. Bot-only.
@@ -2929,7 +3028,7 @@ export class Client extends Composer {
2929
3028
  * @returns The current bot's short description in the specified language.
2930
3029
  */
2931
3030
  async getMyShortDescription(params) {
2932
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyShortDescription(params);
3031
+ return await this.#botInfoManager.getMyShortDescription(params);
2933
3032
  }
2934
3033
  /**
2935
3034
  * Set the bot's commands in the given scope and/or language. Bot-only.
@@ -2938,7 +3037,7 @@ export class Client extends Composer {
2938
3037
  * @param commands The commands to set.
2939
3038
  */
2940
3039
  async setMyCommands(commands, params) {
2941
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyCommands(commands, params);
3040
+ await this.#botInfoManager.setMyCommands(commands, params);
2942
3041
  }
2943
3042
  /**
2944
3043
  * Get the bot's commands in the given scope and/or language. Bot-only.
@@ -2947,7 +3046,7 @@ export class Client extends Composer {
2947
3046
  * @returns The current bot's commands in the specified language.
2948
3047
  */
2949
3048
  async getMyCommands(params) {
2950
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyCommands(params);
3049
+ return await this.#botInfoManager.getMyCommands(params);
2951
3050
  }
2952
3051
  //
2953
3052
  // ========================= REACTIONS ========================= //
@@ -2961,7 +3060,7 @@ export class Client extends Composer {
2961
3060
  * @param reactions The new reactions.
2962
3061
  */
2963
3062
  async setReactions(chatId, messageId, reactions, params) {
2964
- await __classPrivateFieldGet(this, _Client_messageManager, "f").setReactions(chatId, messageId, reactions, params);
3063
+ await this.#messageManager.setReactions(chatId, messageId, reactions, params);
2965
3064
  }
2966
3065
  /**
2967
3066
  * Make a reaction to a message.
@@ -2972,7 +3071,7 @@ export class Client extends Composer {
2972
3071
  * @param reaction The reaction to add.
2973
3072
  */
2974
3073
  async addReaction(chatId, messageId, reaction, params) {
2975
- await __classPrivateFieldGet(this, _Client_messageManager, "f").addReaction(chatId, messageId, reaction, params);
3074
+ await this.#messageManager.addReaction(chatId, messageId, reaction, params);
2976
3075
  }
2977
3076
  /**
2978
3077
  * Undo a reaction made to a message.
@@ -2983,7 +3082,7 @@ export class Client extends Composer {
2983
3082
  * @param reaction The reaction to remove.
2984
3083
  */
2985
3084
  async removeReaction(chatId, messageId, reaction) {
2986
- await __classPrivateFieldGet(this, _Client_messageManager, "f").removeReaction(chatId, messageId, reaction);
3085
+ await this.#messageManager.removeReaction(chatId, messageId, reaction);
2987
3086
  }
2988
3087
  //
2989
3088
  // ========================= STORIES ========================= //
@@ -2996,7 +3095,7 @@ export class Client extends Composer {
2996
3095
  * @returns The created story.
2997
3096
  */
2998
3097
  async createStory(chatId, content, params) {
2999
- return await __classPrivateFieldGet(this, _Client_storyManager, "f").createStory(chatId, content, params);
3098
+ return await this.#storyManager.createStory(chatId, content, params);
3000
3099
  }
3001
3100
  /**
3002
3101
  * Retrieve multiple stories. User-only.
@@ -3010,7 +3109,7 @@ export class Client extends Composer {
3010
3109
  if (!storyIds.length) {
3011
3110
  return [];
3012
3111
  }
3013
- return await __classPrivateFieldGet(this, _Client_storyManager, "f").getStories(chatId, storyIds);
3112
+ return await this.#storyManager.getStories(chatId, storyIds);
3014
3113
  }
3015
3114
  /**
3016
3115
  * Retrieve a single story. User-only.
@@ -3021,7 +3120,7 @@ export class Client extends Composer {
3021
3120
  * @returns The retrieved story.
3022
3121
  */
3023
3122
  async getStory(chatId, storyId) {
3024
- return await __classPrivateFieldGet(this, _Client_storyManager, "f").getStory(chatId, storyId);
3123
+ return await this.#storyManager.getStory(chatId, storyId);
3025
3124
  }
3026
3125
  /**
3027
3126
  * Delete multiple stories. User-only.
@@ -3031,7 +3130,7 @@ export class Client extends Composer {
3031
3130
  * @param storyIds The identifiers of the stories to delete.
3032
3131
  */
3033
3132
  async deleteStories(chatId, storyIds) {
3034
- await __classPrivateFieldGet(this, _Client_storyManager, "f").deleteStories(chatId, storyIds);
3133
+ await this.#storyManager.deleteStories(chatId, storyIds);
3035
3134
  }
3036
3135
  /**
3037
3136
  * Delete a single story. User-only.
@@ -3041,7 +3140,7 @@ export class Client extends Composer {
3041
3140
  * @param storyId The identifier of the story to delete.
3042
3141
  */
3043
3142
  async deleteStory(chatId, storyId) {
3044
- await __classPrivateFieldGet(this, _Client_storyManager, "f").deleteStory(chatId, storyId);
3143
+ await this.#storyManager.deleteStory(chatId, storyId);
3045
3144
  }
3046
3145
  /**
3047
3146
  * Add multiple stories to highlights. User-only.
@@ -3051,7 +3150,7 @@ export class Client extends Composer {
3051
3150
  * @param storyIds The identifiers of the stories to add to highlights.
3052
3151
  */
3053
3152
  async addStoriesToHighlights(chatId, storyIds) {
3054
- await __classPrivateFieldGet(this, _Client_storyManager, "f").addStoriesToHighlights(chatId, storyIds);
3153
+ await this.#storyManager.addStoriesToHighlights(chatId, storyIds);
3055
3154
  }
3056
3155
  /**
3057
3156
  * Add a single story to highlights. User-only.
@@ -3061,7 +3160,7 @@ export class Client extends Composer {
3061
3160
  * @param storyId The identifier of the story to add to highlights.
3062
3161
  */
3063
3162
  async addStoryToHighlights(chatId, storyId) {
3064
- await __classPrivateFieldGet(this, _Client_storyManager, "f").addStoryToHighlights(chatId, storyId);
3163
+ await this.#storyManager.addStoryToHighlights(chatId, storyId);
3065
3164
  }
3066
3165
  /**
3067
3166
  * Remove multiple stories from highlights. User-only.
@@ -3071,7 +3170,7 @@ export class Client extends Composer {
3071
3170
  * @param storyIds The identifiers of the stories to remove from highlights.
3072
3171
  */
3073
3172
  async removeStoriesFromHighlights(chatId, storyIds) {
3074
- await __classPrivateFieldGet(this, _Client_storyManager, "f").removeStoriesFromHighlights(chatId, storyIds);
3173
+ await this.#storyManager.removeStoriesFromHighlights(chatId, storyIds);
3075
3174
  }
3076
3175
  /**
3077
3176
  * Remove a single story from highlights. User-only.
@@ -3081,7 +3180,7 @@ export class Client extends Composer {
3081
3180
  * @param storyId The identifier of the story to remove from highlights.
3082
3181
  */
3083
3182
  async removeStoryFromHighlights(chatId, storyId) {
3084
- await __classPrivateFieldGet(this, _Client_storyManager, "f").removeStoryFromHighlights(chatId, storyId);
3183
+ await this.#storyManager.removeStoryFromHighlights(chatId, storyId);
3085
3184
  }
3086
3185
  //
3087
3186
  // ========================= MISC ========================= //
@@ -3092,7 +3191,7 @@ export class Client extends Composer {
3092
3191
  * @method mc
3093
3192
  */
3094
3193
  async getNetworkStatistics() {
3095
- return await __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getNetworkStatistics();
3194
+ return await this.#networkStatisticsManager.getNetworkStatistics();
3096
3195
  }
3097
3196
  /**
3098
3197
  * Block a user. User-only.
@@ -3101,7 +3200,7 @@ export class Client extends Composer {
3101
3200
  * @param userId The identifier of the user to block.
3102
3201
  */
3103
3202
  async blockUser(userId) {
3104
- await __classPrivateFieldGet(this, _Client_messageManager, "f").blockUser(userId);
3203
+ await this.#messageManager.blockUser(userId);
3105
3204
  }
3106
3205
  /**
3107
3206
  * Unblock a user. User-only.
@@ -3110,7 +3209,7 @@ export class Client extends Composer {
3110
3209
  * @param userId The identifier of the user to unblock.
3111
3210
  */
3112
3211
  async unblockUser(userId) {
3113
- await __classPrivateFieldGet(this, _Client_messageManager, "f").unblockUser(userId);
3212
+ await this.#messageManager.unblockUser(userId);
3114
3213
  }
3115
3214
  //
3116
3215
  // ========================= VIDEO CHATS ========================= //
@@ -3123,7 +3222,7 @@ export class Client extends Composer {
3123
3222
  * @returns The started video chat.
3124
3223
  */
3125
3224
  async startVideoChat(chatId, params) {
3126
- return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").startVideoChat(chatId, params);
3225
+ return await this.#videoChatManager.startVideoChat(chatId, params);
3127
3226
  }
3128
3227
  /**
3129
3228
  * Schedule a video chat. User-only.
@@ -3134,7 +3233,7 @@ export class Client extends Composer {
3134
3233
  * @returns The scheduled video chat.
3135
3234
  */
3136
3235
  async scheduleVideoChat(chatId, startAt, params) {
3137
- return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").scheduleVideoChat(chatId, startAt, params);
3236
+ return await this.#videoChatManager.scheduleVideoChat(chatId, startAt, params);
3138
3237
  }
3139
3238
  /**
3140
3239
  * Join a video chat. User-only.
@@ -3145,7 +3244,7 @@ export class Client extends Composer {
3145
3244
  * @returns Parameters to be passed to the used WebRTC library.
3146
3245
  */
3147
3246
  async joinVideoChat(id, params_, params) {
3148
- return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").joinVideoChat(id, params_, params);
3247
+ return await this.#videoChatManager.joinVideoChat(id, params_, params);
3149
3248
  }
3150
3249
  /**
3151
3250
  * Leave a video chat. User-only.
@@ -3154,7 +3253,7 @@ export class Client extends Composer {
3154
3253
  * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
3155
3254
  */
3156
3255
  async leaveVideoChat(id) {
3157
- await __classPrivateFieldGet(this, _Client_videoChatManager, "f").leaveVideoChat(id);
3256
+ await this.#videoChatManager.leaveVideoChat(id);
3158
3257
  }
3159
3258
  /**
3160
3259
  * Join a live stream. User-only.
@@ -3163,7 +3262,7 @@ export class Client extends Composer {
3163
3262
  * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
3164
3263
  */
3165
3264
  async joinLiveStream(id) {
3166
- await __classPrivateFieldGet(this, _Client_videoChatManager, "f").joinLiveStream(id);
3265
+ await this.#videoChatManager.joinLiveStream(id);
3167
3266
  }
3168
3267
  /**
3169
3268
  * Get a video chat. User-only.
@@ -3173,7 +3272,7 @@ export class Client extends Composer {
3173
3272
  * @cache
3174
3273
  */
3175
3274
  async getVideoChat(id) {
3176
- return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").getVideoChat(id);
3275
+ return await this.#videoChatManager.getVideoChat(id);
3177
3276
  }
3178
3277
  /**
3179
3278
  * Get live stream channels. User-only.
@@ -3182,7 +3281,7 @@ export class Client extends Composer {
3182
3281
  * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
3183
3282
  */
3184
3283
  async getLiveStreamChannels(id) {
3185
- return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").getLiveStreamChannels(id);
3284
+ return await this.#videoChatManager.getLiveStreamChannels(id);
3186
3285
  }
3187
3286
  /**
3188
3287
  * Download a live stream chunk. User-only.
@@ -3194,7 +3293,7 @@ export class Client extends Composer {
3194
3293
  * @param timestamp Millisecond timestamp of the chunk to download.
3195
3294
  */
3196
3295
  async *downloadLiveStreamChunk(id, channelId, scale, timestamp, params) {
3197
- yield* __classPrivateFieldGet(this, _Client_videoChatManager, "f").downloadLiveStreamChunk(id, channelId, scale, timestamp, params);
3296
+ yield* this.#videoChatManager.downloadLiveStreamChunk(id, channelId, scale, timestamp, params);
3198
3297
  }
3199
3298
  //
3200
3299
  // ========================= PAYMENTS ========================= //
@@ -3207,7 +3306,7 @@ export class Client extends Composer {
3207
3306
  * @param ok Whether the checkout is going to be processed.
3208
3307
  */
3209
3308
  async answerPreCheckoutQuery(preCheckoutQueryId, ok, params) {
3210
- await __classPrivateFieldGet(this, _Client_paymentManager, "f").answerPreCheckoutQuery(preCheckoutQueryId, ok, params);
3309
+ await this.#paymentManager.answerPreCheckoutQuery(preCheckoutQueryId, ok, params);
3211
3310
  }
3212
3311
  /**
3213
3312
  * Refund a star payment. Bot-only.
@@ -3217,7 +3316,7 @@ export class Client extends Composer {
3217
3316
  * @param telegramPaymentChargeId The identifier of the charge.
3218
3317
  */
3219
3318
  async refundStarPayment(userId, telegramPaymentChargeId) {
3220
- await __classPrivateFieldGet(this, _Client_paymentManager, "f").refundStarPayment(userId, telegramPaymentChargeId);
3319
+ await this.#paymentManager.refundStarPayment(userId, telegramPaymentChargeId);
3221
3320
  }
3222
3321
  //
3223
3322
  // ========================= CONTACTS ========================= //
@@ -3228,7 +3327,7 @@ export class Client extends Composer {
3228
3327
  * @method co
3229
3328
  */
3230
3329
  async getContacts() {
3231
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").getContacts();
3330
+ return await this.#accountManager.getContacts();
3232
3331
  }
3233
3332
  /**
3234
3333
  * Delete multiple contacts. User-only.
@@ -3237,7 +3336,7 @@ export class Client extends Composer {
3237
3336
  * @param userIds The identifiers of contacts to delete.
3238
3337
  */
3239
3338
  async deleteContacts(userIds) {
3240
- await __classPrivateFieldGet(this, _Client_accountManager, "f").deleteContacts(userIds);
3339
+ await this.#accountManager.deleteContacts(userIds);
3241
3340
  }
3242
3341
  /**
3243
3342
  * Delete a single contact. User-only.
@@ -3246,7 +3345,7 @@ export class Client extends Composer {
3246
3345
  * @param userId The identifier of the contact to delete.
3247
3346
  */
3248
3347
  async deleteContact(userId) {
3249
- await __classPrivateFieldGet(this, _Client_accountManager, "f").deleteContact(userId);
3348
+ await this.#accountManager.deleteContact(userId);
3250
3349
  }
3251
3350
  /**
3252
3351
  * Add a contact. User-only.
@@ -3255,7 +3354,7 @@ export class Client extends Composer {
3255
3354
  * @param userId The identifier of the user to add as contact.
3256
3355
  */
3257
3356
  async addContact(userId, params) {
3258
- await __classPrivateFieldGet(this, _Client_accountManager, "f").addContact(userId, params);
3357
+ await this.#accountManager.addContact(userId, params);
3259
3358
  }
3260
3359
  //
3261
3360
  // ========================= TRANSLATIONS ========================= //
@@ -3267,7 +3366,7 @@ export class Client extends Composer {
3267
3366
  * @cache
3268
3367
  */
3269
3368
  async getTranslations(params) {
3270
- return await __classPrivateFieldGet(this, _Client_translationsManager, "f").getTranslations(params);
3369
+ return await this.#translationsManager.getTranslations(params);
3271
3370
  }
3272
3371
  //
3273
3372
  // ========================= GIFTS ========================= //
@@ -3278,7 +3377,7 @@ export class Client extends Composer {
3278
3377
  * @method gf
3279
3378
  */
3280
3379
  async getGifts() {
3281
- return await __classPrivateFieldGet(this, _Client_giftManager, "f").getGifts();
3380
+ return await this.#giftManager.getGifts();
3282
3381
  }
3283
3382
  /**
3284
3383
  * Get gifts claimed by a user or a channel. User-only.
@@ -3287,7 +3386,7 @@ export class Client extends Composer {
3287
3386
  * @param chatId The identifier of a user or a channel to get gifts for.
3288
3387
  */
3289
3388
  async getClaimedGifts(chatId, params) {
3290
- return await __classPrivateFieldGet(this, _Client_giftManager, "f").getClaimedGifts(chatId, params);
3389
+ return await this.#giftManager.getClaimedGifts(chatId, params);
3291
3390
  }
3292
3391
  /**
3293
3392
  * Send a gift.
@@ -3297,7 +3396,7 @@ export class Client extends Composer {
3297
3396
  * @param giftId The identifier of the gift to send.
3298
3397
  */
3299
3398
  async sendGift(chatId, giftId, params) {
3300
- await __classPrivateFieldGet(this, _Client_giftManager, "f").sendGift(chatId, giftId, params);
3399
+ await this.#giftManager.sendGift(chatId, giftId, params);
3301
3400
  }
3302
3401
  /**
3303
3402
  * Sell a gift.
@@ -3307,7 +3406,7 @@ export class Client extends Composer {
3307
3406
  * @param messageId The identifier of the service message announcing the receival of the gift.
3308
3407
  */
3309
3408
  async sellGift(userId, messageId) {
3310
- await __classPrivateFieldGet(this, _Client_giftManager, "f").sellGift(userId, messageId);
3409
+ await this.#giftManager.sellGift(userId, messageId);
3311
3410
  }
3312
3411
  /**
3313
3412
  * Get a gift using its slug.
@@ -3316,124 +3415,6 @@ export class Client extends Composer {
3316
3415
  * @param slug The slug of a gift.
3317
3416
  */
3318
3417
  async getGift(slug) {
3319
- return await __classPrivateFieldGet(this, _Client_giftManager, "f").getGift(slug);
3418
+ return await this.#giftManager.getGift(slug);
3320
3419
  }
3321
3420
  }
3322
- _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
3323
- if (__classPrivateFieldGet(this, _Client_disableUpdates, "f") && !("authorizationState" in update) && !("connectionState" in update)) {
3324
- return;
3325
- }
3326
- try {
3327
- await this.middleware()(await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, update), resolve);
3328
- }
3329
- catch (err) {
3330
- __classPrivateFieldGet(this, _Client_L, "f").error("Failed to handle update:", err);
3331
- throw err;
3332
- }
3333
- }, _Client_queueHandleCtxUpdate = function _Client_queueHandleCtxUpdate(update) {
3334
- __classPrivateFieldGet(this, _Client_updateManager, "f").getHandleUpdateQueue(UpdateManager.MAIN_BOX_ID).add(async () => {
3335
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, update);
3336
- });
3337
- }, _Client_handleUpdate = async function _Client_handleUpdate(update) {
3338
- const promises = new Array();
3339
- if (Api.is("updateUserName", update)) {
3340
- await this.messageStorage.updateUsernames(Number(update.user_id), update.usernames.map((v) => v.username));
3341
- const peer = { ...update, _: "peerUser" };
3342
- const entity = await this[getEntity](peer);
3343
- if (entity != null) {
3344
- entity.usernames = update.usernames;
3345
- entity.first_name = update.first_name;
3346
- entity.last_name = update.last_name;
3347
- await this.messageStorage.setEntity(entity);
3348
- }
3349
- }
3350
- if (__classPrivateFieldGet(this, _Client_messageManager, "f").canHandleUpdate(update)) {
3351
- promises.push(() => __classPrivateFieldGet(this, _Client_messageManager, "f").handleUpdate(update));
3352
- }
3353
- if (__classPrivateFieldGet(this, _Client_chatManager, "f").canHandleUpdate(update)) {
3354
- promises.push(() => __classPrivateFieldGet(this, _Client_chatManager, "f").handleUpdate(update));
3355
- }
3356
- if (__classPrivateFieldGet(this, _Client_pollManager, "f").canHandleUpdate(update)) {
3357
- promises.push(() => __classPrivateFieldGet(this, _Client_pollManager, "f").handleUpdate(update));
3358
- }
3359
- if (__classPrivateFieldGet(this, _Client_videoChatManager, "f").canHandleUpdate(update)) {
3360
- promises.push(() => __classPrivateFieldGet(this, _Client_videoChatManager, "f").handleUpdate(update));
3361
- }
3362
- if (__classPrivateFieldGet(this, _Client_callbackQueryManager, "f").canHandleUpdate(update)) {
3363
- promises.push(() => __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").handleUpdate(update));
3364
- }
3365
- if (__classPrivateFieldGet(this, _Client_inlineQueryManager, "f").canHandleUpdate(update)) {
3366
- promises.push(() => __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").handleUpdate(update));
3367
- }
3368
- if (__classPrivateFieldGet(this, _Client_linkPreviewManager, "f").canHandleUpdate(update)) {
3369
- promises.push(() => __classPrivateFieldGet(this, _Client_linkPreviewManager, "f").handleUpdate(update));
3370
- }
3371
- if (__classPrivateFieldGet(this, _Client_reactionManager, "f").canHandleUpdate(update)) {
3372
- promises.push(() => __classPrivateFieldGet(this, _Client_reactionManager, "f").handleUpdate(update));
3373
- }
3374
- if (__classPrivateFieldGet(this, _Client_chatListManager, "f").canHandleUpdate(update)) {
3375
- promises.push(() => __classPrivateFieldGet(this, _Client_chatListManager, "f").handleUpdate(update));
3376
- }
3377
- if (__classPrivateFieldGet(this, _Client_storyManager, "f").canHandleUpdate(update)) {
3378
- promises.push(() => __classPrivateFieldGet(this, _Client_storyManager, "f").handleUpdate(update));
3379
- }
3380
- if (__classPrivateFieldGet(this, _Client_businessConnectionManager, "f").canHandleUpdate(update)) {
3381
- promises.push(() => __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update));
3382
- }
3383
- if (__classPrivateFieldGet(this, _Client_storyManager, "f").canHandleUpdate(update)) {
3384
- promises.push(() => __classPrivateFieldGet(this, _Client_storyManager, "f").handleUpdate(update));
3385
- }
3386
- if (__classPrivateFieldGet(this, _Client_paymentManager, "f").canHandleUpdate(update)) {
3387
- promises.push(() => __classPrivateFieldGet(this, _Client_paymentManager, "f").handleUpdate(update));
3388
- }
3389
- if (__classPrivateFieldGet(this, _Client_translationsManager, "f").canHandleUpdate(update)) {
3390
- promises.push(() => __classPrivateFieldGet(this, _Client_translationsManager, "f").handleUpdate(update));
3391
- }
3392
- return () => Promise.resolve().then(async () => {
3393
- const updates = new Array();
3394
- for (const promise of promises) {
3395
- try {
3396
- const update = await promise();
3397
- if (update) {
3398
- updates.push(update);
3399
- }
3400
- }
3401
- catch (err) {
3402
- __classPrivateFieldGet(this, _Client_L, "f").error("failed to construct update:", err);
3403
- }
3404
- }
3405
- for (const update of updates) {
3406
- try {
3407
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, update);
3408
- }
3409
- finally {
3410
- if ("deletedMessages" in update) {
3411
- for (const { chatId, messageId } of update.deletedMessages) {
3412
- await this.messageStorage.setMessage(chatId, messageId, null);
3413
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").reassignChatLastMessage(chatId);
3414
- }
3415
- }
3416
- }
3417
- }
3418
- });
3419
- }, _Client_getMe = async function _Client_getMe() {
3420
- if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") != null) {
3421
- return __classPrivateFieldGet(this, _Client_lastGetMe, "f");
3422
- }
3423
- else {
3424
- const user = await this.getMe();
3425
- __classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
3426
- return user;
3427
- }
3428
- }, _Client_onConnectionStateChange = function _Client_onConnectionStateChange(connected) {
3429
- if (__classPrivateFieldGet(this, _Client_lastConnectionState, "f") != connected) {
3430
- if (connected) {
3431
- if (__classPrivateFieldGet(this, _Client_previouslyConnected, "f")) {
3432
- drop(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("reconnect"));
3433
- }
3434
- __classPrivateFieldSet(this, _Client_previouslyConnected, true, "f");
3435
- }
3436
- const connectionState = connected ? "ready" : "notConnected";
3437
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
3438
- }
3439
- };