@mtkruto/node 0.62.0 → 0.63.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 (513) hide show
  1. package/esm/2_tl.d.ts +6 -6
  2. package/esm/2_tl.d.ts.map +1 -1
  3. package/esm/2_tl.js +6 -6
  4. package/esm/3_errors.d.ts +1 -2
  5. package/esm/3_errors.d.ts.map +1 -1
  6. package/esm/3_errors.js +2 -1
  7. package/esm/4_constants.d.ts +0 -1
  8. package/esm/4_constants.d.ts.map +1 -1
  9. package/esm/4_constants.js +0 -1
  10. package/esm/4_errors.d.ts +2 -2
  11. package/esm/4_errors.d.ts.map +1 -1
  12. package/esm/4_session.d.ts +24 -0
  13. package/esm/4_session.d.ts.map +1 -0
  14. package/esm/4_session.js +23 -0
  15. package/esm/5_client.d.ts +1 -1
  16. package/esm/5_client.js +1 -1
  17. package/esm/client/0_client_abstract.d.ts +28 -26
  18. package/esm/client/0_client_abstract.d.ts.map +1 -1
  19. package/esm/client/0_client_abstract.js +16 -88
  20. package/esm/client/0_params.d.ts +5 -0
  21. package/esm/client/0_params.d.ts.map +1 -1
  22. package/esm/client/0_password.d.ts.map +1 -1
  23. package/esm/client/0_password.js +2 -2
  24. package/esm/client/0_storage_operations.d.ts +4 -4
  25. package/esm/client/0_storage_operations.d.ts.map +1 -1
  26. package/esm/client/0_storage_operations.js +14 -14
  27. package/esm/client/0_update_processor.d.ts +19 -0
  28. package/esm/client/0_update_processor.d.ts.map +1 -1
  29. package/esm/client/0_update_processor.js +19 -0
  30. package/esm/client/0_utilities.d.ts +6 -2
  31. package/esm/client/0_utilities.d.ts.map +1 -1
  32. package/esm/client/0_utilities.js +21 -23
  33. package/esm/client/1_client_plain.d.ts +9 -6
  34. package/esm/client/1_client_plain.d.ts.map +1 -1
  35. package/esm/client/1_client_plain.js +26 -41
  36. package/esm/client/1_types.d.ts +4 -23
  37. package/esm/client/1_types.d.ts.map +1 -1
  38. package/esm/client/2_account_manager.js +10 -10
  39. package/esm/client/2_business_connection_manager.d.ts.map +1 -1
  40. package/esm/client/2_business_connection_manager.js +4 -4
  41. package/esm/client/2_client_encrypted.d.ts +58 -0
  42. package/esm/client/2_client_encrypted.d.ts.map +1 -0
  43. package/esm/client/2_client_encrypted.js +265 -0
  44. package/esm/client/2_file_manager.d.ts.map +1 -1
  45. package/esm/client/2_file_manager.js +54 -74
  46. package/esm/client/2_network_statistics_manager.d.ts +1 -1
  47. package/esm/client/2_network_statistics_manager.d.ts.map +1 -1
  48. package/esm/client/2_network_statistics_manager.js +3 -3
  49. package/esm/client/2_payment_manager.d.ts.map +1 -1
  50. package/esm/client/2_payment_manager.js +3 -3
  51. package/esm/client/2_reaction_manager.d.ts.map +1 -1
  52. package/esm/client/2_reaction_manager.js +10 -10
  53. package/esm/client/2_translations_manager.d.ts +19 -0
  54. package/esm/client/2_translations_manager.d.ts.map +1 -1
  55. package/esm/client/2_translations_manager.js +24 -5
  56. package/esm/client/2_update_manager.d.ts +4 -4
  57. package/esm/client/2_update_manager.d.ts.map +1 -1
  58. package/esm/client/2_update_manager.js +69 -79
  59. package/esm/client/3_client_encrypted_pool.d.ts +30 -0
  60. package/esm/client/3_client_encrypted_pool.d.ts.map +1 -0
  61. package/esm/client/3_client_encrypted_pool.js +70 -0
  62. package/esm/client/3_message_manager.d.ts.map +1 -1
  63. package/esm/client/3_message_manager.js +100 -74
  64. package/esm/client/3_video_chat_manager.d.ts.map +1 -1
  65. package/esm/client/3_video_chat_manager.js +15 -20
  66. package/esm/client/4_callback_query_manager.d.ts.map +1 -1
  67. package/esm/client/4_callback_query_manager.js +2 -2
  68. package/esm/client/4_chat_list_manager.d.ts.map +1 -1
  69. package/esm/client/4_chat_list_manager.js +33 -33
  70. package/esm/client/4_chat_manager.d.ts.map +1 -1
  71. package/esm/client/4_chat_manager.js +25 -25
  72. package/esm/client/4_gift_manager.js +2 -2
  73. package/esm/client/4_inline_query_manager.d.ts.map +1 -1
  74. package/esm/client/4_inline_query_manager.js +4 -4
  75. package/esm/client/4_poll_manager.d.ts.map +1 -1
  76. package/esm/client/4_poll_manager.js +5 -5
  77. package/esm/client/4_story_manager.d.ts.map +1 -1
  78. package/esm/client/4_story_manager.js +10 -10
  79. package/esm/client/5_client.d.ts +3 -9
  80. package/esm/client/5_client.d.ts.map +1 -1
  81. package/esm/client/5_client.js +290 -306
  82. package/esm/connection/0_connection.d.ts +5 -4
  83. package/esm/connection/0_connection.d.ts.map +1 -1
  84. package/esm/connection/1_connection_web_socket.js +2 -2
  85. package/esm/mod.d.ts +1 -1
  86. package/esm/mod.d.ts.map +1 -1
  87. package/esm/mod.js +1 -1
  88. package/{script/tl/2_tl_reader.d.ts → esm/session/0_session_error.d.ts} +4 -7
  89. package/esm/session/0_session_error.d.ts.map +1 -0
  90. package/esm/{tl/2_tl_reader.d.ts → session/0_session_error.js} +5 -7
  91. package/esm/{tl/2_tl_writer.d.ts → session/0_session_state.d.ts} +7 -5
  92. package/esm/session/0_session_state.d.ts.map +1 -0
  93. package/esm/session/0_session_state.js +77 -0
  94. package/esm/session/1_session.d.ts +31 -0
  95. package/esm/session/1_session.d.ts.map +1 -0
  96. package/esm/session/1_session.js +149 -0
  97. package/esm/session/2_session_encrypted.d.ts +40 -0
  98. package/esm/session/2_session_encrypted.d.ts.map +1 -0
  99. package/esm/session/2_session_encrypted.js +416 -0
  100. package/esm/session/2_session_plain.d.ts +25 -0
  101. package/esm/session/2_session_plain.d.ts.map +1 -0
  102. package/esm/session/2_session_plain.js +56 -0
  103. package/esm/tl/0_tl_error.d.ts +22 -0
  104. package/esm/tl/0_tl_error.d.ts.map +1 -0
  105. package/esm/tl/0_tl_error.js +21 -0
  106. package/esm/tl/0_types.d.ts +25 -0
  107. package/esm/tl/0_types.d.ts.map +1 -0
  108. package/esm/tl/0_types.js +20 -0
  109. package/esm/tl/0_utilities.d.ts +32 -0
  110. package/esm/tl/0_utilities.d.ts.map +1 -0
  111. package/esm/tl/0_utilities.js +51 -0
  112. package/esm/tl/0_utilities_test.d.ts.map +1 -0
  113. package/esm/tl/1_mtproto_api.d.ts +371 -0
  114. package/esm/tl/1_mtproto_api.d.ts.map +1 -0
  115. package/esm/tl/1_mtproto_api.js +416 -0
  116. package/esm/tl/{0_api.d.ts → 1_telegram_api.d.ts} +23 -340
  117. package/esm/tl/1_telegram_api.d.ts.map +1 -0
  118. package/esm/tl/{0_api.js → 1_telegram_api.js} +4945 -11109
  119. package/{script/tl/0_tl_raw_reader.d.ts → esm/tl/1_tl_reader.d.ts} +5 -2
  120. package/esm/tl/1_tl_reader.d.ts.map +1 -0
  121. package/esm/tl/{2_tl_reader.js → 1_tl_reader.js} +107 -40
  122. package/esm/tl/1_tl_reader_test.d.ts.map +1 -0
  123. package/esm/tl/{0_tl_raw_writer.d.ts → 1_tl_writer.d.ts} +5 -2
  124. package/esm/tl/1_tl_writer.d.ts.map +1 -0
  125. package/esm/tl/{2_tl_writer.js → 1_tl_writer.js} +80 -23
  126. package/esm/tl/1_tl_writer_test.d.ts.map +1 -0
  127. package/esm/tl/1_utilities.d.ts +9 -24
  128. package/esm/tl/1_utilities.d.ts.map +1 -1
  129. package/esm/tl/1_utilities.js +18 -64
  130. package/esm/tl/2_message.d.ts +2 -2
  131. package/esm/tl/2_message.d.ts.map +1 -1
  132. package/esm/tl/2_message.js +7 -7
  133. package/esm/tl/2_mtproto.d.ts +33 -0
  134. package/esm/tl/2_mtproto.d.ts.map +1 -0
  135. package/esm/tl/2_mtproto.js +53 -0
  136. package/{script/tl/2_utilities.d.ts → esm/tl/2_telegram.d.ts} +16 -2
  137. package/esm/tl/2_telegram.d.ts.map +1 -0
  138. package/esm/tl/{2_utilities.js → 2_telegram.js} +46 -1
  139. package/esm/transport/0_transport.d.ts +1 -1
  140. package/esm/transport/0_transport.d.ts.map +1 -1
  141. package/esm/types/0_chat_photo.d.ts.map +1 -1
  142. package/esm/types/0_chat_photo.js +2 -2
  143. package/esm/types/0_giveaway_parameters.d.ts.map +1 -1
  144. package/esm/types/0_giveaway_parameters.js +3 -3
  145. package/esm/types/0_location.d.ts.map +1 -1
  146. package/esm/types/0_location.js +5 -5
  147. package/esm/types/0_message_entity.d.ts.map +1 -1
  148. package/esm/types/0_message_entity.js +20 -20
  149. package/esm/types/0_reaction.d.ts.map +1 -1
  150. package/esm/types/0_reaction.js +4 -4
  151. package/esm/types/0_slow_mode_duration.d.ts +19 -0
  152. package/esm/types/0_slow_mode_duration.d.ts.map +1 -1
  153. package/esm/types/0_slow_mode_duration.js +19 -0
  154. package/esm/types/0_thumbnail.d.ts.map +1 -1
  155. package/esm/types/0_thumbnail.js +3 -3
  156. package/esm/types/0_translation.d.ts +19 -0
  157. package/esm/types/0_translation.d.ts.map +1 -1
  158. package/esm/types/0_translation.js +22 -3
  159. package/esm/types/0_video_chat.d.ts.map +1 -1
  160. package/esm/types/0_video_chat.js +2 -2
  161. package/esm/types/1_animation.d.ts.map +1 -1
  162. package/esm/types/1_animation.js +2 -2
  163. package/esm/types/1_audio.d.ts.map +1 -1
  164. package/esm/types/1_audio.js +2 -2
  165. package/esm/types/1_bot_command_scope.d.ts.map +1 -1
  166. package/esm/types/1_bot_command_scope.js +2 -2
  167. package/esm/types/1_chat_p.d.ts.map +1 -1
  168. package/esm/types/1_chat_p.js +6 -6
  169. package/esm/types/1_document.d.ts.map +1 -1
  170. package/esm/types/1_document.js +2 -2
  171. package/esm/types/1_keyboard_button.d.ts.map +1 -1
  172. package/esm/types/1_keyboard_button.js +10 -10
  173. package/esm/types/1_message_reaction.d.ts.map +1 -1
  174. package/esm/types/1_message_reaction.js +6 -6
  175. package/esm/types/1_photo.d.ts.map +1 -1
  176. package/esm/types/1_photo.js +3 -3
  177. package/esm/types/1_sticker.d.ts.map +1 -1
  178. package/esm/types/1_sticker.js +8 -8
  179. package/esm/types/1_story_privacy.d.ts.map +1 -1
  180. package/esm/types/1_story_privacy.js +7 -7
  181. package/esm/types/1_user.d.ts.map +1 -1
  182. package/esm/types/1_user.js +2 -2
  183. package/esm/types/1_venue.d.ts.map +1 -1
  184. package/esm/types/1_venue.js +2 -2
  185. package/esm/types/1_video.d.ts.map +1 -1
  186. package/esm/types/1_video.js +2 -2
  187. package/esm/types/1_video_note.d.ts.map +1 -1
  188. package/esm/types/1_video_note.js +2 -2
  189. package/esm/types/2_chat.d.ts.map +1 -1
  190. package/esm/types/2_chat.js +8 -8
  191. package/esm/types/2_chat_member.d.ts.map +1 -1
  192. package/esm/types/2_chat_member.js +10 -10
  193. package/esm/types/2_chat_settings.d.ts +19 -0
  194. package/esm/types/2_chat_settings.d.ts.map +1 -1
  195. package/esm/types/2_chat_settings.js +21 -2
  196. package/esm/types/2_chosen_inline_result.d.ts.map +1 -1
  197. package/esm/types/2_chosen_inline_result.js +4 -4
  198. package/esm/types/2_game.d.ts.map +1 -1
  199. package/esm/types/2_game.js +4 -4
  200. package/esm/types/2_gift_upgraded_component.d.ts.map +1 -1
  201. package/esm/types/2_gift_upgraded_component.js +3 -3
  202. package/esm/types/2_inactive_chat.d.ts.map +1 -1
  203. package/esm/types/2_inactive_chat.js +2 -2
  204. package/esm/types/2_inline_keyboard_button.d.ts.map +1 -1
  205. package/esm/types/2_inline_keyboard_button.js +10 -10
  206. package/esm/types/2_inline_query.d.ts.map +1 -1
  207. package/esm/types/2_inline_query.js +7 -7
  208. package/esm/types/2_message_reactions.d.ts.map +1 -1
  209. package/esm/types/2_message_reactions.js +2 -2
  210. package/esm/types/2_story_content.d.ts.map +1 -1
  211. package/esm/types/2_story_content.js +6 -6
  212. package/esm/types/2_story_interactive_area.d.ts.map +1 -1
  213. package/esm/types/2_story_interactive_area.js +9 -9
  214. package/esm/types/3_chat_member_updated.d.ts.map +1 -1
  215. package/esm/types/3_chat_member_updated.js +2 -2
  216. package/esm/types/3_gift.d.ts.map +1 -1
  217. package/esm/types/3_gift.js +3 -3
  218. package/esm/types/3_join_request.d.ts.map +1 -1
  219. package/esm/types/3_join_request.js +2 -2
  220. package/esm/types/3_reply_markup.d.ts.map +1 -1
  221. package/esm/types/3_reply_markup.js +5 -5
  222. package/esm/types/4_claimed_gift.d.ts.map +1 -1
  223. package/esm/types/4_claimed_gift.js +2 -2
  224. package/esm/types/4_inline_query_result.d.ts.map +1 -1
  225. package/esm/types/4_inline_query_result.js +14 -14
  226. package/esm/types/4_message.d.ts.map +1 -1
  227. package/esm/types/4_message.js +57 -57
  228. package/esm/types/5_callback_query.d.ts +1 -1
  229. package/esm/types/5_callback_query.d.ts.map +1 -1
  230. package/esm/types/5_callback_query.js +7 -8
  231. package/esm/types/5_chat_list_item.d.ts.map +1 -1
  232. package/esm/types/5_chat_list_item.js +5 -5
  233. package/esm/types/5_claimed_gifts.d.ts.map +1 -1
  234. package/esm/types/5_claimed_gifts.js +6 -6
  235. package/esm/types/_file_id.d.ts.map +1 -1
  236. package/esm/types/_file_id.js +3 -3
  237. package/package.json +1 -1
  238. package/script/2_tl.d.ts +6 -6
  239. package/script/2_tl.d.ts.map +1 -1
  240. package/script/2_tl.js +11 -11
  241. package/script/3_errors.d.ts +1 -2
  242. package/script/3_errors.d.ts.map +1 -1
  243. package/script/3_errors.js +2 -1
  244. package/script/4_constants.d.ts +0 -1
  245. package/script/4_constants.d.ts.map +1 -1
  246. package/script/4_constants.js +1 -2
  247. package/script/4_errors.d.ts +2 -2
  248. package/script/4_errors.d.ts.map +1 -1
  249. package/script/4_session.d.ts +24 -0
  250. package/script/4_session.d.ts.map +1 -0
  251. package/script/4_session.js +39 -0
  252. package/script/5_client.d.ts +1 -1
  253. package/script/5_client.js +1 -1
  254. package/script/client/0_client_abstract.d.ts +28 -26
  255. package/script/client/0_client_abstract.d.ts.map +1 -1
  256. package/script/client/0_client_abstract.js +18 -113
  257. package/script/client/0_params.d.ts +5 -0
  258. package/script/client/0_params.d.ts.map +1 -1
  259. package/script/client/0_password.d.ts.map +1 -1
  260. package/script/client/0_password.js +1 -1
  261. package/script/client/0_storage_operations.d.ts +4 -4
  262. package/script/client/0_storage_operations.d.ts.map +1 -1
  263. package/script/client/0_storage_operations.js +13 -13
  264. package/script/client/0_update_processor.d.ts +19 -0
  265. package/script/client/0_update_processor.d.ts.map +1 -1
  266. package/script/client/0_update_processor.js +19 -0
  267. package/script/client/0_utilities.d.ts +6 -2
  268. package/script/client/0_utilities.d.ts.map +1 -1
  269. package/script/client/0_utilities.js +22 -24
  270. package/script/client/1_client_plain.d.ts +9 -6
  271. package/script/client/1_client_plain.d.ts.map +1 -1
  272. package/script/client/1_client_plain.js +25 -40
  273. package/script/client/1_types.d.ts +4 -23
  274. package/script/client/1_types.d.ts.map +1 -1
  275. package/script/client/2_account_manager.js +9 -9
  276. package/script/client/2_business_connection_manager.d.ts.map +1 -1
  277. package/script/client/2_business_connection_manager.js +3 -3
  278. package/script/client/2_client_encrypted.d.ts +58 -0
  279. package/script/client/2_client_encrypted.d.ts.map +1 -0
  280. package/script/client/2_client_encrypted.js +269 -0
  281. package/script/client/2_file_manager.d.ts.map +1 -1
  282. package/script/client/2_file_manager.js +52 -72
  283. package/script/client/2_network_statistics_manager.d.ts +1 -1
  284. package/script/client/2_network_statistics_manager.d.ts.map +1 -1
  285. package/script/client/2_network_statistics_manager.js +3 -3
  286. package/script/client/2_payment_manager.d.ts.map +1 -1
  287. package/script/client/2_payment_manager.js +2 -2
  288. package/script/client/2_reaction_manager.d.ts.map +1 -1
  289. package/script/client/2_reaction_manager.js +9 -9
  290. package/script/client/2_translations_manager.d.ts +19 -0
  291. package/script/client/2_translations_manager.d.ts.map +1 -1
  292. package/script/client/2_translations_manager.js +23 -4
  293. package/script/client/2_update_manager.d.ts +4 -4
  294. package/script/client/2_update_manager.d.ts.map +1 -1
  295. package/script/client/2_update_manager.js +68 -78
  296. package/script/client/3_client_encrypted_pool.d.ts +30 -0
  297. package/script/client/3_client_encrypted_pool.d.ts.map +1 -0
  298. package/script/client/3_client_encrypted_pool.js +74 -0
  299. package/script/client/3_message_manager.d.ts.map +1 -1
  300. package/script/client/3_message_manager.js +99 -73
  301. package/script/client/3_video_chat_manager.d.ts.map +1 -1
  302. package/script/client/3_video_chat_manager.js +14 -19
  303. package/script/client/4_callback_query_manager.d.ts.map +1 -1
  304. package/script/client/4_callback_query_manager.js +1 -1
  305. package/script/client/4_chat_list_manager.d.ts.map +1 -1
  306. package/script/client/4_chat_list_manager.js +32 -32
  307. package/script/client/4_chat_manager.d.ts.map +1 -1
  308. package/script/client/4_chat_manager.js +24 -24
  309. package/script/client/4_gift_manager.js +1 -1
  310. package/script/client/4_inline_query_manager.d.ts.map +1 -1
  311. package/script/client/4_inline_query_manager.js +3 -3
  312. package/script/client/4_poll_manager.d.ts.map +1 -1
  313. package/script/client/4_poll_manager.js +4 -4
  314. package/script/client/4_story_manager.d.ts.map +1 -1
  315. package/script/client/4_story_manager.js +9 -9
  316. package/script/client/5_client.d.ts +3 -9
  317. package/script/client/5_client.d.ts.map +1 -1
  318. package/script/client/5_client.js +284 -300
  319. package/script/connection/0_connection.d.ts +5 -4
  320. package/script/connection/0_connection.d.ts.map +1 -1
  321. package/script/connection/1_connection_web_socket.js +2 -2
  322. package/script/mod.d.ts +1 -1
  323. package/script/mod.d.ts.map +1 -1
  324. package/script/mod.js +1 -2
  325. package/script/session/0_session_error.d.ts +24 -0
  326. package/script/session/0_session_error.d.ts.map +1 -0
  327. package/script/session/0_session_error.js +29 -0
  328. package/script/{tl/2_tl_writer.d.ts → session/0_session_state.d.ts} +7 -5
  329. package/script/session/0_session_state.d.ts.map +1 -0
  330. package/script/session/0_session_state.js +81 -0
  331. package/script/session/1_session.d.ts +31 -0
  332. package/script/session/1_session.d.ts.map +1 -0
  333. package/script/session/1_session.js +176 -0
  334. package/script/session/2_session_encrypted.d.ts +40 -0
  335. package/script/session/2_session_encrypted.d.ts.map +1 -0
  336. package/script/session/2_session_encrypted.js +420 -0
  337. package/script/session/2_session_plain.d.ts +25 -0
  338. package/script/session/2_session_plain.d.ts.map +1 -0
  339. package/script/session/2_session_plain.js +60 -0
  340. package/script/tl/0_tl_error.d.ts +22 -0
  341. package/script/tl/0_tl_error.d.ts.map +1 -0
  342. package/script/tl/0_tl_error.js +25 -0
  343. package/script/tl/0_types.d.ts +25 -0
  344. package/script/tl/0_types.d.ts.map +1 -0
  345. package/script/tl/0_types.js +21 -0
  346. package/script/tl/0_utilities.d.ts +32 -0
  347. package/script/tl/0_utilities.d.ts.map +1 -0
  348. package/script/tl/0_utilities.js +59 -0
  349. package/script/tl/0_utilities_test.d.ts.map +1 -0
  350. package/script/tl/1_mtproto_api.d.ts +371 -0
  351. package/script/tl/1_mtproto_api.d.ts.map +1 -0
  352. package/script/tl/1_mtproto_api.js +419 -0
  353. package/script/tl/{0_api.d.ts → 1_telegram_api.d.ts} +23 -340
  354. package/script/tl/1_telegram_api.d.ts.map +1 -0
  355. package/script/tl/{0_api.js → 1_telegram_api.js} +4947 -11134
  356. package/{esm/tl/0_tl_raw_reader.d.ts → script/tl/1_tl_reader.d.ts} +5 -2
  357. package/script/tl/1_tl_reader.d.ts.map +1 -0
  358. package/script/tl/1_tl_reader.js +218 -0
  359. package/script/tl/1_tl_reader_test.d.ts.map +1 -0
  360. package/script/tl/{0_tl_raw_writer.d.ts → 1_tl_writer.d.ts} +5 -2
  361. package/script/tl/1_tl_writer.d.ts.map +1 -0
  362. package/script/tl/{2_tl_writer.js → 1_tl_writer.js} +102 -45
  363. package/script/tl/1_tl_writer_test.d.ts.map +1 -0
  364. package/script/tl/1_utilities.d.ts +9 -24
  365. package/script/tl/1_utilities.d.ts.map +1 -1
  366. package/script/tl/1_utilities.js +19 -72
  367. package/script/tl/2_message.d.ts +2 -2
  368. package/script/tl/2_message.d.ts.map +1 -1
  369. package/script/tl/2_message.js +7 -7
  370. package/script/tl/2_mtproto.d.ts +33 -0
  371. package/script/tl/2_mtproto.d.ts.map +1 -0
  372. package/script/tl/2_mtproto.js +78 -0
  373. package/{esm/tl/2_utilities.d.ts → script/tl/2_telegram.d.ts} +16 -2
  374. package/script/tl/2_telegram.d.ts.map +1 -0
  375. package/script/tl/2_telegram.js +167 -0
  376. package/script/transport/0_transport.d.ts +1 -1
  377. package/script/transport/0_transport.d.ts.map +1 -1
  378. package/script/types/0_chat_photo.d.ts.map +1 -1
  379. package/script/types/0_chat_photo.js +1 -1
  380. package/script/types/0_giveaway_parameters.d.ts.map +1 -1
  381. package/script/types/0_giveaway_parameters.js +2 -2
  382. package/script/types/0_location.d.ts.map +1 -1
  383. package/script/types/0_location.js +4 -4
  384. package/script/types/0_message_entity.d.ts.map +1 -1
  385. package/script/types/0_message_entity.js +19 -19
  386. package/script/types/0_reaction.d.ts.map +1 -1
  387. package/script/types/0_reaction.js +3 -3
  388. package/script/types/0_slow_mode_duration.d.ts +19 -0
  389. package/script/types/0_slow_mode_duration.d.ts.map +1 -1
  390. package/script/types/0_slow_mode_duration.js +19 -0
  391. package/script/types/0_thumbnail.d.ts.map +1 -1
  392. package/script/types/0_thumbnail.js +2 -2
  393. package/script/types/0_translation.d.ts +19 -0
  394. package/script/types/0_translation.d.ts.map +1 -1
  395. package/script/types/0_translation.js +21 -2
  396. package/script/types/0_video_chat.d.ts.map +1 -1
  397. package/script/types/0_video_chat.js +1 -1
  398. package/script/types/1_animation.d.ts.map +1 -1
  399. package/script/types/1_animation.js +1 -1
  400. package/script/types/1_audio.d.ts.map +1 -1
  401. package/script/types/1_audio.js +1 -1
  402. package/script/types/1_bot_command_scope.d.ts.map +1 -1
  403. package/script/types/1_bot_command_scope.js +1 -1
  404. package/script/types/1_chat_p.d.ts.map +1 -1
  405. package/script/types/1_chat_p.js +5 -5
  406. package/script/types/1_document.d.ts.map +1 -1
  407. package/script/types/1_document.js +1 -1
  408. package/script/types/1_keyboard_button.d.ts.map +1 -1
  409. package/script/types/1_keyboard_button.js +9 -9
  410. package/script/types/1_message_reaction.d.ts.map +1 -1
  411. package/script/types/1_message_reaction.js +5 -5
  412. package/script/types/1_photo.d.ts.map +1 -1
  413. package/script/types/1_photo.js +2 -2
  414. package/script/types/1_sticker.d.ts.map +1 -1
  415. package/script/types/1_sticker.js +7 -7
  416. package/script/types/1_story_privacy.d.ts.map +1 -1
  417. package/script/types/1_story_privacy.js +6 -6
  418. package/script/types/1_user.d.ts.map +1 -1
  419. package/script/types/1_user.js +1 -1
  420. package/script/types/1_venue.d.ts.map +1 -1
  421. package/script/types/1_venue.js +1 -1
  422. package/script/types/1_video.d.ts.map +1 -1
  423. package/script/types/1_video.js +1 -1
  424. package/script/types/1_video_note.d.ts.map +1 -1
  425. package/script/types/1_video_note.js +1 -1
  426. package/script/types/2_chat.d.ts.map +1 -1
  427. package/script/types/2_chat.js +7 -7
  428. package/script/types/2_chat_member.d.ts.map +1 -1
  429. package/script/types/2_chat_member.js +9 -9
  430. package/script/types/2_chat_settings.d.ts +19 -0
  431. package/script/types/2_chat_settings.d.ts.map +1 -1
  432. package/script/types/2_chat_settings.js +20 -1
  433. package/script/types/2_chosen_inline_result.d.ts.map +1 -1
  434. package/script/types/2_chosen_inline_result.js +3 -3
  435. package/script/types/2_game.d.ts.map +1 -1
  436. package/script/types/2_game.js +3 -3
  437. package/script/types/2_gift_upgraded_component.d.ts.map +1 -1
  438. package/script/types/2_gift_upgraded_component.js +2 -2
  439. package/script/types/2_inactive_chat.d.ts.map +1 -1
  440. package/script/types/2_inactive_chat.js +1 -1
  441. package/script/types/2_inline_keyboard_button.d.ts.map +1 -1
  442. package/script/types/2_inline_keyboard_button.js +9 -9
  443. package/script/types/2_inline_query.d.ts.map +1 -1
  444. package/script/types/2_inline_query.js +6 -6
  445. package/script/types/2_message_reactions.d.ts.map +1 -1
  446. package/script/types/2_message_reactions.js +1 -1
  447. package/script/types/2_story_content.d.ts.map +1 -1
  448. package/script/types/2_story_content.js +5 -5
  449. package/script/types/2_story_interactive_area.d.ts.map +1 -1
  450. package/script/types/2_story_interactive_area.js +8 -8
  451. package/script/types/3_chat_member_updated.d.ts.map +1 -1
  452. package/script/types/3_chat_member_updated.js +1 -1
  453. package/script/types/3_gift.d.ts.map +1 -1
  454. package/script/types/3_gift.js +2 -2
  455. package/script/types/3_join_request.d.ts.map +1 -1
  456. package/script/types/3_join_request.js +1 -1
  457. package/script/types/3_reply_markup.d.ts.map +1 -1
  458. package/script/types/3_reply_markup.js +4 -4
  459. package/script/types/4_claimed_gift.d.ts.map +1 -1
  460. package/script/types/4_claimed_gift.js +1 -1
  461. package/script/types/4_inline_query_result.d.ts.map +1 -1
  462. package/script/types/4_inline_query_result.js +13 -13
  463. package/script/types/4_message.d.ts.map +1 -1
  464. package/script/types/4_message.js +56 -56
  465. package/script/types/5_callback_query.d.ts +1 -1
  466. package/script/types/5_callback_query.d.ts.map +1 -1
  467. package/script/types/5_callback_query.js +6 -7
  468. package/script/types/5_chat_list_item.d.ts.map +1 -1
  469. package/script/types/5_chat_list_item.js +4 -4
  470. package/script/types/5_claimed_gifts.d.ts.map +1 -1
  471. package/script/types/5_claimed_gifts.js +5 -5
  472. package/script/types/_file_id.d.ts.map +1 -1
  473. package/script/types/_file_id.js +2 -2
  474. package/esm/client/0_message.d.ts +0 -29
  475. package/esm/client/0_message.d.ts.map +0 -1
  476. package/esm/client/0_message.js +0 -83
  477. package/esm/client/1_client_encrypted.d.ts +0 -52
  478. package/esm/client/1_client_encrypted.d.ts.map +0 -1
  479. package/esm/client/1_client_encrypted.js +0 -381
  480. package/esm/tl/0_api.d.ts.map +0 -1
  481. package/esm/tl/0_tl_raw_reader.d.ts.map +0 -1
  482. package/esm/tl/0_tl_raw_reader.js +0 -97
  483. package/esm/tl/0_tl_raw_reader_test.d.ts.map +0 -1
  484. package/esm/tl/0_tl_raw_writer.d.ts.map +0 -1
  485. package/esm/tl/0_tl_raw_writer.js +0 -86
  486. package/esm/tl/0_tl_raw_writer_test.d.ts.map +0 -1
  487. package/esm/tl/1_utilities_test.d.ts.map +0 -1
  488. package/esm/tl/2_tl_reader.d.ts.map +0 -1
  489. package/esm/tl/2_tl_reader_test.d.ts.map +0 -1
  490. package/esm/tl/2_tl_writer.d.ts.map +0 -1
  491. package/esm/tl/2_tl_writer_test.d.ts.map +0 -1
  492. package/esm/tl/2_utilities.d.ts.map +0 -1
  493. package/script/client/0_message.d.ts +0 -29
  494. package/script/client/0_message.d.ts.map +0 -1
  495. package/script/client/0_message.js +0 -90
  496. package/script/client/1_client_encrypted.d.ts +0 -52
  497. package/script/client/1_client_encrypted.d.ts.map +0 -1
  498. package/script/client/1_client_encrypted.js +0 -385
  499. package/script/tl/0_api.d.ts.map +0 -1
  500. package/script/tl/0_tl_raw_reader.d.ts.map +0 -1
  501. package/script/tl/0_tl_raw_reader.js +0 -102
  502. package/script/tl/0_tl_raw_reader_test.d.ts.map +0 -1
  503. package/script/tl/0_tl_raw_writer.d.ts.map +0 -1
  504. package/script/tl/0_tl_raw_writer.js +0 -90
  505. package/script/tl/0_tl_raw_writer_test.d.ts.map +0 -1
  506. package/script/tl/1_utilities_test.d.ts.map +0 -1
  507. package/script/tl/2_tl_reader.d.ts.map +0 -1
  508. package/script/tl/2_tl_reader.js +0 -150
  509. package/script/tl/2_tl_reader_test.d.ts.map +0 -1
  510. package/script/tl/2_tl_writer.d.ts.map +0 -1
  511. package/script/tl/2_tl_writer_test.d.ts.map +0 -1
  512. package/script/tl/2_utilities.d.ts.map +0 -1
  513. package/script/tl/2_utilities.js +0 -98
@@ -29,7 +29,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
29
29
  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");
30
30
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
31
31
  };
32
- var _Client_instances, _a, _Client_client, _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_pollManager, _Client_storyManager, _Client_managers, _Client_storage_, _Client_messageStorage_, _Client_parseMode, _Client_apiId, _Client_apiHash, _Client_publicKeys, _Client_outgoingMessages, _Client_persistCache, _Client_disableUpdates, _Client_authString, _Client_cdn, _Client_L, _Client_LsignIn, _Client_LpingLoop, _Client_LhandleMigrationError, _Client_L$initConncetion, _Client_Lmin, _Client_reconnecting, _Client_reconnect, _Client_getApiId, _Client_getCdnConnectionPool, _Client_getCdnConnection, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_lastConnect, _Client_connectionInited, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_connectionInsuranceLoopStarted, _Client_connectionInsuranceLoopAbortController, _Client_startConnectionInsuranceLoop, _Client_connectionInsuranceLoop, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_startPingLoop, _Client_pingLoop, _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;
32
+ 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_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_L, _Client_LsignIn, _Client_LupdateGapRecoveryLoop, _Client_LhandleMigrationError, _Client_Lmin, _Client_setMainClient, _Client_newClient, _Client_disconnectAllClients, _Client_client_get, _Client_getApiId, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_lastConnect, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_lastUpdates, _Client_updateGapRecoveryLoopAbortController, _Client_startUpdateGapRecoveryLoop, _Client_updateGapRecoveryLoop, _Client_clientDisconnectionLoopAbortController, _Client_startClientDisconnectionLoop, _Client_clientDisconnectionLoop, _Client_getClient, _Client_getMainClientMutex, _Client_getMainClient, _Client_getDownloadClient, _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;
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.Client = exports.handleMigrationError = exports.restartAuth = exports.Composer = void 0;
35
35
  const _0_deps_js_1 = require("../0_deps.js");
@@ -45,18 +45,18 @@ const _4_errors_js_2 = require("../4_errors.js");
45
45
  const _0_password_js_1 = require("./0_password.js");
46
46
  const _0_storage_operations_js_1 = require("./0_storage_operations.js");
47
47
  const _0_utilities_js_1 = require("./0_utilities.js");
48
- const _1_client_encrypted_js_1 = require("./1_client_encrypted.js");
49
- const _1_client_plain_js_1 = require("./1_client_plain.js");
50
48
  const _1_composer_js_1 = require("./1_composer.js");
51
49
  const _2_account_manager_js_1 = require("./2_account_manager.js");
52
50
  const _2_bot_info_manager_js_1 = require("./2_bot_info_manager.js");
53
51
  const _2_business_connection_manager_js_1 = require("./2_business_connection_manager.js");
52
+ const _2_client_encrypted_js_1 = require("./2_client_encrypted.js");
54
53
  const _2_file_manager_js_1 = require("./2_file_manager.js");
55
54
  const _2_network_statistics_manager_js_1 = require("./2_network_statistics_manager.js");
56
55
  const _2_payment_manager_js_1 = require("./2_payment_manager.js");
57
56
  const _2_reaction_manager_js_1 = require("./2_reaction_manager.js");
58
57
  const _2_translations_manager_js_1 = require("./2_translations_manager.js");
59
58
  const _2_update_manager_js_1 = require("./2_update_manager.js");
59
+ const _3_client_encrypted_pool_js_1 = require("./3_client_encrypted_pool.js");
60
60
  const _3_message_manager_js_1 = require("./3_message_manager.js");
61
61
  const _3_video_chat_manager_js_1 = require("./3_video_chat_manager.js");
62
62
  const _4_callback_query_manager_js_1 = require("./4_callback_query_manager.js");
@@ -115,7 +115,9 @@ class Client extends Composer {
115
115
  constructor(params) {
116
116
  super();
117
117
  _Client_instances.add(this);
118
- _Client_client.set(this, void 0);
118
+ _Client_clients.set(this, new Array());
119
+ _Client_downloadPools.set(this, {});
120
+ _Client_uploadPools.set(this, {});
119
121
  _Client_guaranteeUpdateDelivery.set(this, void 0);
120
122
  // 2_
121
123
  _Client_accountManager.set(this, void 0);
@@ -158,6 +160,7 @@ class Client extends Composer {
158
160
  _Client_parseMode.set(this, void 0);
159
161
  _Client_apiId.set(this, void 0);
160
162
  _Client_apiHash.set(this, void 0);
163
+ _Client_transportProvider.set(this, void 0);
161
164
  Object.defineProperty(this, "appVersion", {
162
165
  enumerable: true,
163
166
  configurable: true,
@@ -199,14 +202,11 @@ class Client extends Composer {
199
202
  _Client_persistCache.set(this, void 0);
200
203
  _Client_disableUpdates.set(this, void 0);
201
204
  _Client_authString.set(this, void 0);
202
- _Client_cdn.set(this, void 0);
203
205
  _Client_L.set(this, void 0);
204
206
  _Client_LsignIn.set(this, void 0);
205
- _Client_LpingLoop.set(this, void 0);
207
+ _Client_LupdateGapRecoveryLoop.set(this, void 0);
206
208
  _Client_LhandleMigrationError.set(this, void 0);
207
- _Client_L$initConncetion.set(this, void 0);
208
209
  _Client_Lmin.set(this, void 0);
209
- _Client_reconnecting.set(this, false);
210
210
  _Client_constructContext.set(this, async (update) => {
211
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
212
  const reactions = "messageInteractions" in update ? update.messageInteractions : undefined;
@@ -611,7 +611,6 @@ class Client extends Composer {
611
611
  });
612
612
  _Client_lastPropagatedConnectionState.set(this, null);
613
613
  _Client_stateChangeHandler.set(this, ((connected) => {
614
- (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_reconnect).call(this));
615
614
  const connectionState = connected ? "ready" : "notConnected";
616
615
  if (__classPrivateFieldGet(this, _Client_lastPropagatedConnectionState, "f") != connectionState) {
617
616
  __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateConnectionState).call(this, connectionState);
@@ -620,13 +619,11 @@ class Client extends Composer {
620
619
  _Client_storageInited.set(this, false);
621
620
  _Client_connectMutex.set(this, new _1_utilities_js_1.Mutex());
622
621
  _Client_lastConnect.set(this, null);
623
- _Client_connectionInited.set(this, false);
624
622
  _Client_lastPropagatedAuthorizationState.set(this, null);
625
- _Client_connectionInsuranceLoopStarted.set(this, false);
626
- _Client_connectionInsuranceLoopAbortController.set(this, null);
627
- _Client_pingLoopAbortController.set(this, null);
628
- _Client_pingInterval.set(this, 56 * _0_deps_js_1.SECOND);
629
623
  _Client_lastUpdates.set(this, new Date());
624
+ _Client_updateGapRecoveryLoopAbortController.set(this, null);
625
+ _Client_clientDisconnectionLoopAbortController.set(this, null);
626
+ _Client_getMainClientMutex.set(this, new _1_utilities_js_1.Mutex());
630
627
  _Client_handleInvokeError.set(this, skipInvoke());
631
628
  /**
632
629
  * Invokes a function waiting and returning its reply if the second parameter is not `true`. Requires the client
@@ -655,34 +652,11 @@ class Client extends Composer {
655
652
  });
656
653
  _Client_authStringImported.set(this, false);
657
654
  _Client_lastGetMe.set(this, null);
658
- __classPrivateFieldSet(this, _Client_client, new _1_client_encrypted_js_1.ClientEncrypted(params), "f");
659
- __classPrivateFieldGet(this, _Client_client, "f").stateChangeHandler = __classPrivateFieldGet(this, _Client_stateChangeHandler, "f").bind(this);
660
- __classPrivateFieldGet(this, _Client_client, "f").handlers = {
661
- serverSaltReassigned: async (newServerSalt) => {
662
- await this.storage.setServerSalt(newServerSalt);
663
- },
664
- updates: (updates, call, callback) => {
665
- __classPrivateFieldGet(this, _Client_updateManager, "f").processUpdates(updates, true, call, callback);
666
- __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
667
- },
668
- result: async (result, callback) => {
669
- await __classPrivateFieldGet(this, _Client_updateManager, "f").processResult(result);
670
- callback();
671
- },
672
- error: async (_err, source) => {
673
- switch (source) {
674
- case "deserialization":
675
- await __classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap(source);
676
- break;
677
- case "decryption":
678
- await this.reconnect();
679
- await __classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap(source);
680
- break;
681
- }
682
- },
683
- };
655
+ _Client_previouslyConnected.set(this, false);
656
+ _Client_lastConnectionState.set(this, false);
684
657
  __classPrivateFieldSet(this, _Client_apiId, params?.apiId ?? 0, "f");
685
658
  __classPrivateFieldSet(this, _Client_apiHash, params?.apiHash ?? "", "f");
659
+ __classPrivateFieldSet(this, _Client_transportProvider, params?.transportProvider, "f");
686
660
  __classPrivateFieldSet(this, _Client_storage_, params?.storage || new _2_storage_js_1.StorageMemory(), "f");
687
661
  __classPrivateFieldSet(this, _Client_persistCache, params?.persistCache ?? false, "f");
688
662
  if (!__classPrivateFieldGet(this, _Client_persistCache, "f")) {
@@ -710,19 +684,17 @@ class Client extends Composer {
710
684
  __classPrivateFieldSet(this, _Client_guaranteeUpdateDelivery, params?.guaranteeUpdateDelivery ?? false, "f");
711
685
  const L = __classPrivateFieldSet(this, _Client_L, (0, _1_utilities_js_1.getLogger)("Client").client(id++), "f");
712
686
  __classPrivateFieldSet(this, _Client_LsignIn, L.branch("signIn"), "f");
713
- __classPrivateFieldSet(this, _Client_LpingLoop, L.branch("pingLoop"), "f");
687
+ __classPrivateFieldSet(this, _Client_LupdateGapRecoveryLoop, L.branch("updateGapRecoveryLoop"), "f");
714
688
  __classPrivateFieldSet(this, _Client_LhandleMigrationError, L.branch("[handleMigrationError]"), "f");
715
- __classPrivateFieldSet(this, _Client_L$initConncetion, L.branch("#initConnection"), "f");
716
689
  __classPrivateFieldSet(this, _Client_Lmin, L.branch("min"), "f");
717
- __classPrivateFieldSet(this, _Client_cdn, params?.cdn ?? false, "f");
718
690
  const c = {
719
691
  id,
720
- invoke: async (function_, businessConnectionId) => {
721
- if (businessConnectionId) {
722
- return await this.invoke({ _: "invokeWithBusinessConnection", connection_id: businessConnectionId, query: function_ });
692
+ invoke: async (function_, params) => {
693
+ if (params?.businessConnectionId) {
694
+ return await this.invoke({ _: "invokeWithBusinessConnection", connection_id: params.businessConnectionId, query: function_ }, params);
723
695
  }
724
696
  else {
725
- return await this.invoke(function_);
697
+ return await this.invoke(function_, params);
726
698
  }
727
699
  },
728
700
  storage: this.storage,
@@ -738,9 +710,6 @@ class Client extends Composer {
738
710
  getEntity: this[getEntity].bind(this),
739
711
  handleUpdate: __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).bind(this),
740
712
  parseMode: __classPrivateFieldGet(this, _Client_parseMode, "f"),
741
- getCdnConnection: __classPrivateFieldGet(this, _Client_instances, "m", _Client_getCdnConnection).bind(this),
742
- getCdnConnectionPool: __classPrivateFieldGet(this, _Client_instances, "m", _Client_getCdnConnectionPool).bind(this),
743
- cdn: __classPrivateFieldGet(this, _Client_cdn, "f"),
744
713
  outgoingMessages: __classPrivateFieldGet(this, _Client_outgoingMessages, "f"),
745
714
  dropPendingUpdates: params?.dropPendingUpdates,
746
715
  disconnected: () => this.disconnected,
@@ -770,12 +739,6 @@ class Client extends Composer {
770
739
  __classPrivateFieldSet(this, _Client_pollManager, new _4_poll_manager_js_1.PollManager({ ...c, messageManager }), "f");
771
740
  __classPrivateFieldSet(this, _Client_storyManager, new _4_story_manager_js_1.StoryManager({ ...c, fileManager, messageManager }), "f");
772
741
  __classPrivateFieldGet(this, _Client_updateManager, "f").setUpdateHandler(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).bind(this));
773
- const transportProvider = __classPrivateFieldGet(this, _Client_client, "f").transportProvider;
774
- __classPrivateFieldGet(this, _Client_client, "f").transportProvider = (params) => {
775
- const transport = transportProvider(params);
776
- transport.connection.callback = __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getTransportReadWriteCallback();
777
- return transport;
778
- };
779
742
  this.invoke.use(async ({ error }, next) => {
780
743
  if (error instanceof _0_errors_js_1.ConnectionError) {
781
744
  while (!this.connected) {
@@ -791,7 +754,7 @@ class Client extends Composer {
791
754
  }
792
755
  return true;
793
756
  }
794
- else if ((0, _2_tl_js_1.is)("bad_msg_notification", error)) {
757
+ else if (_2_tl_js_1.Mtproto.is("bad_msg_notification", error)) {
795
758
  return true;
796
759
  }
797
760
  else {
@@ -813,10 +776,10 @@ class Client extends Composer {
813
776
  }
814
777
  // direct ClientEncrypted property proxies
815
778
  get connected() {
816
- return __classPrivateFieldGet(this, _Client_client, "f").connected;
779
+ return __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.connected ?? false;
817
780
  }
818
781
  get disconnected() {
819
- return __classPrivateFieldGet(this, _Client_client, "f").disconnected;
782
+ return __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.disconnected ?? true;
820
783
  }
821
784
  /**
822
785
  * Sets the DC and resets the auth key stored in the session provider
@@ -831,7 +794,6 @@ class Client extends Composer {
831
794
  await this.storage.setAuthKey(null);
832
795
  await this.storage.getAuthKey();
833
796
  }
834
- __classPrivateFieldGet(this, _Client_client, "f").setDc(dc);
835
797
  }
836
798
  /**
837
799
  * Loads the session if `setDc` was not called, initializes and connnects
@@ -844,39 +806,33 @@ class Client extends Composer {
844
806
  if (this.connected) {
845
807
  return;
846
808
  }
847
- if (__classPrivateFieldGet(this, _Client_lastConnect, "f") != null && Date.now() - __classPrivateFieldGet(this, _Client_lastConnect, "f").getTime() <= 10 * _0_deps_js_1.SECOND) {
848
- await new Promise((r) => setTimeout(r, 3 * _0_deps_js_1.SECOND));
849
- }
850
809
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
851
810
  if (__classPrivateFieldGet(this, _Client_authString, "f") && !__classPrivateFieldGet(this, _Client_authStringImported, "f")) {
852
811
  await this.importAuthString(__classPrivateFieldGet(this, _Client_authString, "f"));
853
812
  }
854
813
  const [authKey, dc] = await Promise.all([this.storage.getAuthKey(), this.storage.getDc()]);
855
814
  if (authKey != null && dc != null) {
856
- await __classPrivateFieldGet(this, _Client_client, "f").setAuthKey(authKey);
857
- __classPrivateFieldGet(this, _Client_client, "f").setDc(dc);
858
- if (__classPrivateFieldGet(this, _Client_client, "f").serverSalt == 0n) {
859
- __classPrivateFieldGet(this, _Client_client, "f").serverSalt = await this.storage.getServerSalt() ?? 0n;
815
+ if (!__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get) || __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc != dc) {
816
+ __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.disconnect();
817
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMainClient).call(this, await __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, true, false));
818
+ }
819
+ await __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).setAuthKey(authKey);
820
+ if (__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).serverSalt == 0n) {
821
+ __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).serverSalt = await this.storage.getServerSalt() ?? 0n;
860
822
  }
861
823
  }
862
824
  else {
863
- const plain = new _1_client_plain_js_1.ClientPlain({ initialDc: __classPrivateFieldGet(this, _Client_client, "f").initialDc, transportProvider: __classPrivateFieldGet(this, _Client_client, "f").transportProvider, cdn: __classPrivateFieldGet(this, _Client_client, "f").cdn, publicKeys: __classPrivateFieldGet(this, _Client_publicKeys, "f") });
864
- const dc = await this.storage.getDc();
865
- if (dc != null) {
866
- plain.setDc(dc);
867
- __classPrivateFieldGet(this, _Client_client, "f").setDc(dc);
825
+ const dc = await this.storage.getDc() ?? _4_constants_js_1.INITIAL_DC;
826
+ if (!__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get) || __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc != dc) {
827
+ __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.disconnect();
828
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMainClient).call(this, await __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, true, false));
868
829
  }
869
- await plain.connect();
870
- const [authKey, serverSalt] = await plain.createAuthKey();
871
- (0, _1_utilities_js_1.drop)(plain.disconnect());
872
- await __classPrivateFieldGet(this, _Client_client, "f").setAuthKey(authKey);
873
- __classPrivateFieldGet(this, _Client_client, "f").serverSalt = serverSalt;
874
830
  }
875
- await __classPrivateFieldGet(this, _Client_client, "f").connect();
831
+ await __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).connect();
876
832
  __classPrivateFieldSet(this, _Client_lastConnect, new Date(), "f");
877
- await Promise.all([this.storage.setAuthKey(__classPrivateFieldGet(this, _Client_client, "f").authKey), this.storage.setDc(__classPrivateFieldGet(this, _Client_client, "f").dc), this.storage.setServerSalt(__classPrivateFieldGet(this, _Client_client, "f").serverSalt)]);
878
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_startConnectionInsuranceLoop).call(this);
879
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_startPingLoop).call(this);
833
+ 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)]);
834
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_startUpdateGapRecoveryLoop).call(this);
835
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_startClientDisconnectionLoop).call(this);
880
836
  }
881
837
  finally {
882
838
  unlock();
@@ -886,120 +842,54 @@ class Client extends Composer {
886
842
  if (dc) {
887
843
  await this.setDc(dc);
888
844
  }
889
- await __classPrivateFieldGet(this, _Client_client, "f").reconnect();
845
+ this.disconnect();
846
+ await this.connect();
890
847
  }
891
- async [(_Client_client = 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_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_publicKeys = new WeakMap(), _Client_outgoingMessages = new WeakMap(), _Client_persistCache = new WeakMap(), _Client_disableUpdates = new WeakMap(), _Client_authString = new WeakMap(), _Client_cdn = new WeakMap(), _Client_L = new WeakMap(), _Client_LsignIn = new WeakMap(), _Client_LpingLoop = new WeakMap(), _Client_LhandleMigrationError = new WeakMap(), _Client_L$initConncetion = new WeakMap(), _Client_Lmin = new WeakMap(), _Client_reconnecting = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_stateChangeHandler = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_lastConnect = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_connectionInsuranceLoopStarted = new WeakMap(), _Client_connectionInsuranceLoopAbortController = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_authStringImported = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_instances = new WeakSet(), _Client_reconnect = async function _Client_reconnect() {
892
- if (this.connected) {
893
- return;
894
- }
895
- if (this.disconnected) {
896
- __classPrivateFieldGet(this, _Client_L, "f").debug("not reconnecting");
897
- return;
898
- }
899
- if (__classPrivateFieldGet(this, _Client_reconnecting, "f")) {
900
- return;
848
+ 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_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_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_lastConnect = 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) {
849
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_disconnectAllClients).call(this);
850
+ __classPrivateFieldSet(this, _Client_clients, [client], "f");
851
+ client.handlers.onUpdate = (updates) => {
852
+ __classPrivateFieldGet(this, _Client_updateManager, "f").processUpdates(updates, true, null);
853
+ __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
854
+ };
855
+ client.handlers.onDeserializationError = async () => {
856
+ await __classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("deserialization error");
857
+ };
858
+ client.onConnectionStateChange = __classPrivateFieldGet(this, _Client_instances, "m", _Client_onConnectionStateChange).bind(this);
859
+ }, _Client_newClient = async function _Client_newClient(dc, main, cdn) {
860
+ const apiId = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getApiId).call(this);
861
+ const client = new _2_client_encrypted_js_1.ClientEncrypted(dc, apiId, {
862
+ appVersion: this.appVersion,
863
+ deviceModel: this.deviceModel,
864
+ langCode: this.language,
865
+ langPack: this.platform,
866
+ systemLangCode: this.systemLangCode,
867
+ systemVersion: this.systemVersion,
868
+ transportProvider: __classPrivateFieldGet(this, _Client_transportProvider, "f"),
869
+ cdn,
870
+ disableUpdates: !main || cdn,
871
+ publicKeys: __classPrivateFieldGet(this, _Client_publicKeys, "f"),
872
+ });
873
+ client.connectionCallback = __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getTransportReadWriteCallback(cdn);
874
+ return client;
875
+ }, _Client_disconnectAllClients = function _Client_disconnectAllClients() {
876
+ for (const client of __classPrivateFieldGet(this, _Client_clients, "f")) {
877
+ client.disconnect();
901
878
  }
902
- __classPrivateFieldSet(this, _Client_reconnecting, true, "f");
903
- try {
904
- let delay = 5;
905
- while (!this.connected) {
906
- __classPrivateFieldGet(this, _Client_L, "f").debug("reconnecting");
907
- __classPrivateFieldGet(this, _Client_pingLoopAbortController, "f")?.abort();
908
- try {
909
- await this.connect();
910
- __classPrivateFieldGet(this, _Client_L, "f").debug("reconnected");
911
- (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("reconnect"));
912
- break;
913
- }
914
- catch (err) {
915
- if (delay < 15) {
916
- delay += 5;
917
- }
918
- __classPrivateFieldGet(this, _Client_L, "f").debug(`failed to reconnect, retrying in ${delay}:`, err);
919
- }
920
- await new Promise((r) => setTimeout(r, delay * _0_deps_js_1.SECOND));
921
- }
879
+ for (const pool of Object.values(__classPrivateFieldGet(this, _Client_downloadPools, "f"))) {
880
+ pool.disconnect();
922
881
  }
923
- finally {
924
- __classPrivateFieldSet(this, _Client_reconnecting, false, "f");
882
+ for (const pool of Object.values(__classPrivateFieldGet(this, _Client_uploadPools, "f"))) {
883
+ pool.disconnect();
925
884
  }
885
+ }, _Client_client_get = function _Client_client_get() {
886
+ return __classPrivateFieldGet(this, _Client_clients, "f")[0];
926
887
  }, _Client_getApiId = async function _Client_getApiId() {
927
888
  const apiId = __classPrivateFieldGet(this, _Client_apiId, "f") || await this.storage.getApiId();
928
889
  if (!apiId) {
929
890
  throw new _0_errors_js_1.InputError("apiId not set");
930
891
  }
931
892
  return apiId;
932
- }, _Client_getCdnConnectionPool = function _Client_getCdnConnectionPool(connectionCount, dcId) {
933
- const connections = new Array();
934
- for (let i = 0; i < connectionCount; ++i) {
935
- connections.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_getCdnConnection).call(this, dcId));
936
- }
937
- let prev = 0;
938
- return {
939
- size: connectionCount,
940
- invoke: () => {
941
- if (prev + 1 > connections.length)
942
- prev = 0;
943
- const connection = connections[prev++];
944
- return connection.invoke;
945
- },
946
- connect: async () => {
947
- for await (const connection of connections) {
948
- await connection.connect();
949
- }
950
- },
951
- disconnect: async () => {
952
- for await (const connection of connections) {
953
- await connection.disconnect();
954
- }
955
- },
956
- };
957
- }, _Client_getCdnConnection = function _Client_getCdnConnection(dcId) {
958
- const provider = this.storage.provider;
959
- const client = new _a({
960
- storage: (!dcId || dcId == __classPrivateFieldGet(this, _Client_client, "f").dcId) ? provider : provider.branch(`download_client_${dcId}`),
961
- apiId: __classPrivateFieldGet(this, _Client_apiId, "f"),
962
- apiHash: __classPrivateFieldGet(this, _Client_apiHash, "f"),
963
- transportProvider: __classPrivateFieldGet(this, _Client_client, "f").transportProvider,
964
- appVersion: this.appVersion,
965
- deviceModel: this.deviceModel,
966
- language: this.language,
967
- platform: this.platform,
968
- systemLangCode: this.systemLangCode,
969
- systemVersion: this.systemVersion,
970
- cdn: true,
971
- initialDc: (0, _3_transport_js_1.getDc)(dcId || __classPrivateFieldGet(this, _Client_client, "f").dcId),
972
- });
973
- __classPrivateFieldGet(client, _Client_client, "f").serverSalt = __classPrivateFieldGet(this, _Client_client, "f").serverSalt;
974
- client.invoke.use(async (ctx, next) => {
975
- if (ctx.error instanceof _4_errors_js_1.AuthKeyUnregistered && dcId) {
976
- try {
977
- const exportedAuth = await this.invoke({ _: "auth.exportAuthorization", dc_id: dcId });
978
- await client.invoke({ ...exportedAuth, _: "auth.importAuthorization" });
979
- return true;
980
- }
981
- catch (err) {
982
- throw err;
983
- }
984
- }
985
- else {
986
- return await next();
987
- }
988
- });
989
- return {
990
- invoke: client.invoke.bind(client),
991
- connect: async () => {
992
- await client.connect();
993
- if (dcId && dcId != __classPrivateFieldGet(this, _Client_client, "f").dcId) {
994
- let dc = String(dcId);
995
- if (__classPrivateFieldGet(this, _Client_client, "f").dcId < 0) {
996
- dc += "-test";
997
- }
998
- await client.setDc(dc);
999
- }
1000
- },
1001
- disconnect: client.disconnect.bind(client),
1002
- };
1003
893
  }, _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
1004
894
  __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
1005
895
  __classPrivateFieldSet(this, _Client_lastPropagatedConnectionState, connectionState, "f");
@@ -1013,18 +903,15 @@ class Client extends Composer {
1013
903
  }
1014
904
  }, exports.handleMigrationError)](err) {
1015
905
  let newDc = String(err.dc);
1016
- if (Math.abs(__classPrivateFieldGet(this, _Client_client, "f").dcId) >= 10_000) {
906
+ if (Math.abs((0, _3_transport_js_1.getDcId)(__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc, __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).cdn)) >= 10_000) {
1017
907
  newDc += "-test";
1018
908
  }
1019
909
  await this.reconnect(newDc);
1020
910
  __classPrivateFieldGet(this, _Client_LhandleMigrationError, "f").debug(`migrated to DC${newDc}`);
1021
911
  }
1022
- async disconnect() {
1023
- __classPrivateFieldSet(this, _Client_connectionInited, false, "f");
1024
- await __classPrivateFieldGet(this, _Client_client, "f").disconnect();
912
+ disconnect() {
913
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_disconnectAllClients).call(this);
1025
914
  __classPrivateFieldGet(this, _Client_updateManager, "f").closeAllChats();
1026
- __classPrivateFieldGet(this, _Client_pingLoopAbortController, "f")?.abort();
1027
- __classPrivateFieldGet(this, _Client_connectionInsuranceLoopAbortController, "f")?.abort();
1028
915
  }
1029
916
  /**
1030
917
  * Signs in using the provided parameters if not already signed in.
@@ -1060,12 +947,12 @@ class Client extends Composer {
1060
947
  params = { phone: () => (0, _1_utilities_js_1.mustPrompt)("Phone number:"), code: () => (0, _1_utilities_js_1.mustPrompt)("Verification code:"), password: () => (0, _1_utilities_js_1.mustPrompt)("Password:") };
1061
948
  }
1062
949
  }
1063
- __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("authorizing with", typeof params === "string" ? "bot token" : (0, _2_tl_js_1.is)("auth.exportedAuthorization", params) ? "exported authorization" : "AuthorizeUserParams");
950
+ __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("authorizing with", typeof params === "string" ? "bot token" : _2_tl_js_1.Api.is("auth.exportedAuthorization", params) ? "exported authorization" : "AuthorizeUserParams");
1064
951
  if (params && "botToken" in params) {
1065
952
  while (true) {
1066
953
  try {
1067
954
  const auth = await this.invoke({ _: "auth.importBotAuthorization", api_id: apiId, api_hash: __classPrivateFieldGet(this, _Client_apiHash, "f"), bot_auth_token: params.botToken, flags: 0 });
1068
- await this.storage.setAccountId(Number((0, _2_tl_js_1.as)("auth.authorization", auth).user.id));
955
+ await this.storage.setAccountId(Number(_2_tl_js_1.Api.as("auth.authorization", auth).user.id));
1069
956
  await this.storage.setAccountType("bot");
1070
957
  break;
1071
958
  }
@@ -1097,7 +984,7 @@ class Client extends Composer {
1097
984
  api_id: __classPrivateFieldGet(this, _Client_apiId, "f"),
1098
985
  api_hash: __classPrivateFieldGet(this, _Client_apiHash, "f"),
1099
986
  settings: { _: "codeSettings" },
1100
- }).then((v) => (0, _2_tl_js_1.as)("auth.sentCode", v));
987
+ }).then((v) => _2_tl_js_1.Api.as("auth.sentCode", v));
1101
988
  try {
1102
989
  sentCode = await sendCode();
1103
990
  }
@@ -1132,7 +1019,7 @@ class Client extends Composer {
1132
1019
  phone_code: code,
1133
1020
  phone_code_hash: sentCode.phone_code_hash,
1134
1021
  });
1135
- await this.storage.setAccountId(Number((0, _2_tl_js_1.as)("auth.authorization", auth).user.id));
1022
+ await this.storage.setAccountId(Number(_2_tl_js_1.Api.as("auth.authorization", auth).user.id));
1136
1023
  await this.storage.setAccountType("user");
1137
1024
  __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
1138
1025
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
@@ -1154,14 +1041,14 @@ class Client extends Composer {
1154
1041
  }
1155
1042
  password: while (true) {
1156
1043
  const ap = await this.invoke({ _: "account.getPassword" });
1157
- if (!((0, _2_tl_js_1.is)("passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow", ap.current_algo))) {
1044
+ if (!(_2_tl_js_1.Api.is("passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow", ap.current_algo))) {
1158
1045
  throw new Error(`Handling ${ap.current_algo?._} not implemented`);
1159
1046
  }
1160
1047
  try {
1161
1048
  const password = typeof params.password === "string" ? params.password : await params.password(ap.hint ?? null);
1162
1049
  const input = await (0, _0_password_js_1.checkPassword)(password, ap);
1163
1050
  const auth = await this.invoke({ _: "auth.checkPassword", password: input });
1164
- await this.storage.setAccountId(Number((0, _2_tl_js_1.as)("auth.authorization", auth).user.id));
1051
+ await this.storage.setAccountId(Number(_2_tl_js_1.Api.as("auth.authorization", auth).user.id));
1165
1052
  await this.storage.setAccountType("user");
1166
1053
  __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
1167
1054
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
@@ -1209,12 +1096,6 @@ class Client extends Composer {
1209
1096
  await this.connect();
1210
1097
  await this.signIn(params);
1211
1098
  }
1212
- /**
1213
- * Alias for `invoke` with its second parameter being `true`.
1214
- */
1215
- send(function_) {
1216
- return this.invoke(function_, true);
1217
- }
1218
1099
  exportAuthString() {
1219
1100
  return this.storage.exportAuthString(__classPrivateFieldGet(this, _Client_apiId, "f"));
1220
1101
  }
@@ -1236,7 +1117,7 @@ class Client extends Composer {
1236
1117
  return { _: "inputPeerSelf" };
1237
1118
  }
1238
1119
  const inputPeer = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getInputPeerInner).call(this, id);
1239
- if ((((0, _2_tl_js_1.is)("inputPeerUser", inputPeer) || (0, _2_tl_js_1.is)("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n) && await this.storage.getAccountType() == "bot") {
1120
+ if (((_2_tl_js_1.Api.is("inputPeerUser", inputPeer) || _2_tl_js_1.Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n) && await this.storage.getAccountType() == "bot") {
1240
1121
  if ("channel_id" in inputPeer) {
1241
1122
  inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChannelAccessHash).call(this, inputPeer.channel_id);
1242
1123
  }
@@ -1244,7 +1125,7 @@ class Client extends Composer {
1244
1125
  inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUserAccessHash).call(this, inputPeer.user_id);
1245
1126
  }
1246
1127
  }
1247
- if (((0, _2_tl_js_1.is)("inputPeerUser", inputPeer) || (0, _2_tl_js_1.is)("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n && await this.storage.getAccountType() == "user") {
1128
+ if ((_2_tl_js_1.Api.is("inputPeerUser", inputPeer) || _2_tl_js_1.Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n && await this.storage.getAccountType() == "user") {
1248
1129
  throw new _0_errors_js_1.AccessError(`Cannot access the chat ${id} because there is no access hash for it.`);
1249
1130
  }
1250
1131
  return inputPeer;
@@ -1284,110 +1165,202 @@ class Client extends Composer {
1284
1165
  throw new Error("Unauthorized");
1285
1166
  }
1286
1167
  return id;
1287
- }, _Client_startConnectionInsuranceLoop = function _Client_startConnectionInsuranceLoop() {
1288
- (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_connectionInsuranceLoop).call(this));
1289
- }, _Client_connectionInsuranceLoop = async function _Client_connectionInsuranceLoop() {
1290
- if (__classPrivateFieldGet(this, _Client_connectionInsuranceLoopStarted, "f")) {
1291
- return;
1292
- }
1293
- __classPrivateFieldSet(this, _Client_connectionInsuranceLoopAbortController, new AbortController(), "f");
1294
- __classPrivateFieldSet(this, _Client_connectionInsuranceLoopStarted, true, "f");
1295
- while (!this.disconnected) {
1168
+ }, _Client_startUpdateGapRecoveryLoop = function _Client_startUpdateGapRecoveryLoop() {
1169
+ (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_updateGapRecoveryLoop).call(this));
1170
+ }, _Client_updateGapRecoveryLoop = async function _Client_updateGapRecoveryLoop() {
1171
+ __classPrivateFieldSet(this, _Client_updateGapRecoveryLoopAbortController, new AbortController(), "f");
1172
+ while (this.connected) {
1296
1173
  try {
1297
1174
  await new Promise((resolve, reject) => {
1298
- const timeout = setTimeout(resolve, 10 * _0_deps_js_1.SECOND);
1299
- __classPrivateFieldGet(this, _Client_connectionInsuranceLoopAbortController, "f").signal.onabort = () => {
1300
- reject(__classPrivateFieldGet(this, _Client_connectionInsuranceLoopAbortController, "f")?.signal.reason);
1175
+ const timeout = setTimeout(resolve, 60 * _0_deps_js_1.SECOND);
1176
+ __classPrivateFieldGet(this, _Client_updateGapRecoveryLoopAbortController, "f").signal.onabort = () => {
1177
+ reject(__classPrivateFieldGet(this, _Client_updateGapRecoveryLoopAbortController, "f")?.signal.reason);
1301
1178
  clearTimeout(timeout);
1302
1179
  };
1303
1180
  });
1181
+ if (!this.connected) {
1182
+ continue;
1183
+ }
1184
+ __classPrivateFieldGet(this, _Client_updateGapRecoveryLoopAbortController, "f").signal.throwIfAborted();
1185
+ if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * _0_deps_js_1.MINUTE) {
1186
+ (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("lastUpdates").then(() => {
1187
+ __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
1188
+ }));
1189
+ }
1304
1190
  }
1305
- catch {
1306
- break;
1307
- }
1308
- if (!this.connected) {
1309
- (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_reconnect).call(this));
1191
+ catch (err) {
1192
+ if (err instanceof DOMException && err.name == "AbortError") {
1193
+ __classPrivateFieldSet(this, _Client_updateGapRecoveryLoopAbortController, new AbortController(), "f");
1194
+ }
1195
+ if (!this.connected) {
1196
+ continue;
1197
+ }
1198
+ __classPrivateFieldGet(this, _Client_LupdateGapRecoveryLoop, "f").error(err);
1310
1199
  }
1311
1200
  }
1312
- __classPrivateFieldSet(this, _Client_connectionInsuranceLoopStarted, false, "f");
1313
- }, _Client_startPingLoop = function _Client_startPingLoop() {
1314
- (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_pingLoop).call(this));
1315
- }, _Client_pingLoop = async function _Client_pingLoop() {
1316
- if (__classPrivateFieldGet(this, _Client_cdn, "f")) {
1317
- return;
1318
- }
1319
- __classPrivateFieldSet(this, _Client_pingLoopAbortController, new AbortController(), "f");
1320
- let timeElapsed = 0;
1201
+ }, _Client_startClientDisconnectionLoop = function _Client_startClientDisconnectionLoop() {
1202
+ (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_clientDisconnectionLoop).call(this));
1203
+ }, _Client_clientDisconnectionLoop = async function _Client_clientDisconnectionLoop() {
1204
+ __classPrivateFieldSet(this, _Client_clientDisconnectionLoopAbortController, new AbortController(), "f");
1321
1205
  while (this.connected) {
1322
- const then = Date.now();
1323
1206
  try {
1324
1207
  await new Promise((resolve, reject) => {
1325
- const timeout = setTimeout(resolve, __classPrivateFieldGet(this, _Client_pingInterval, "f") - timeElapsed);
1326
- __classPrivateFieldGet(this, _Client_pingLoopAbortController, "f").signal.onabort = () => {
1327
- reject(__classPrivateFieldGet(this, _Client_pingLoopAbortController, "f")?.signal.reason);
1208
+ const timeout = setTimeout(resolve, 60 * _0_deps_js_1.SECOND);
1209
+ __classPrivateFieldGet(this, _Client_clientDisconnectionLoopAbortController, "f").signal.onabort = () => {
1210
+ reject(__classPrivateFieldGet(this, _Client_clientDisconnectionLoopAbortController, "f")?.signal.reason);
1328
1211
  clearTimeout(timeout);
1329
1212
  };
1330
1213
  });
1331
1214
  if (!this.connected) {
1332
1215
  continue;
1333
1216
  }
1334
- __classPrivateFieldGet(this, _Client_pingLoopAbortController, "f").signal.throwIfAborted();
1335
- await this.invoke({ _: "ping_delay_disconnect", ping_id: (0, _1_utilities_js_1.getRandomId)(), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") / _0_deps_js_1.SECOND + 15 });
1336
- __classPrivateFieldGet(this, _Client_pingLoopAbortController, "f").signal.throwIfAborted();
1337
- if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * _0_deps_js_1.MINUTE) {
1338
- (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("lastUpdates").then(() => {
1339
- __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
1340
- }));
1341
- }
1217
+ __classPrivateFieldGet(this, _Client_clientDisconnectionLoopAbortController, "f").signal.throwIfAborted();
1218
+ const now = Date.now();
1219
+ const disconnectAfter = 5 * _0_deps_js_1.MINUTE;
1220
+ __classPrivateFieldGet(this, _Client_clients, "f").map((client, i) => {
1221
+ if (i > 0 && !client.disconnected && client.lastRequest && now - client.lastRequest.getTime() >= disconnectAfter) {
1222
+ client?.disconnect();
1223
+ }
1224
+ });
1342
1225
  }
1343
1226
  catch (err) {
1344
1227
  if (err instanceof DOMException && err.name == "AbortError") {
1345
- __classPrivateFieldSet(this, _Client_pingLoopAbortController, new AbortController(), "f");
1228
+ __classPrivateFieldSet(this, _Client_clientDisconnectionLoopAbortController, new AbortController(), "f");
1346
1229
  }
1347
1230
  if (!this.connected) {
1348
1231
  continue;
1349
1232
  }
1350
- __classPrivateFieldGet(this, _Client_LpingLoop, "f").error(err);
1351
1233
  }
1352
- finally {
1353
- timeElapsed = Date.now() - then;
1234
+ }
1235
+ }, _Client_getClient = async function _Client_getClient(params) {
1236
+ let client;
1237
+ switch (params.type) {
1238
+ case undefined:
1239
+ client = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMainClient).call(this, params.dc);
1240
+ break;
1241
+ case "download":
1242
+ client = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getDownloadClient).call(this, params.dc);
1243
+ break;
1244
+ case "upload":
1245
+ client = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUploadClient).call(this);
1246
+ break;
1247
+ }
1248
+ if (client !== __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get) && !this.disconnected && client.disconnected) {
1249
+ await client.connect();
1250
+ }
1251
+ return client;
1252
+ }, _Client_getMainClient = async function _Client_getMainClient(dc) {
1253
+ if (dc === undefined || dc == __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.dc) {
1254
+ return __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get);
1255
+ }
1256
+ let client = __classPrivateFieldGet(this, _Client_clients, "f").find((v) => v.dc == dc);
1257
+ if (client) {
1258
+ return client;
1259
+ }
1260
+ const release = await __classPrivateFieldGet(this, _Client_getMainClientMutex, "f").lock();
1261
+ client = __classPrivateFieldGet(this, _Client_clients, "f").find((v) => v.dc == dc);
1262
+ if (client) {
1263
+ return client;
1264
+ }
1265
+ try {
1266
+ client = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, false);
1267
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setupClient).call(this, client);
1268
+ __classPrivateFieldGet(this, _Client_clients, "f").push(client);
1269
+ return client;
1270
+ }
1271
+ finally {
1272
+ release();
1273
+ }
1274
+ }, _Client_getDownloadClient = async function _Client_getDownloadClient(dc) {
1275
+ dc ??= __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc;
1276
+ const pool = __classPrivateFieldGet(this, _Client_downloadPools, "f")[dc] ??= new _3_client_encrypted_pool_js_1.ClientEncryptedPool(_0_utilities_js_1.DOWNLOAD_REQUEST_PER_CONNECTION);
1277
+ if (!pool.size) {
1278
+ for (let i = 0; i < _0_utilities_js_1.DOWNLOAD_POOL_SIZE; ++i) {
1279
+ pool.add(await __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, true));
1354
1280
  }
1355
1281
  }
1356
- }, _Client_invoke = async function _Client_invoke(function_, noWait) {
1282
+ const client = pool.nextClient();
1283
+ if (client.authKey.length) {
1284
+ return client;
1285
+ }
1286
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setupClient).call(this, client);
1287
+ return client;
1288
+ }, _Client_getUploadClient = async function _Client_getUploadClient() {
1289
+ const dc = __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc;
1290
+ const pool = __classPrivateFieldGet(this, _Client_uploadPools, "f")[dc] ??= new _3_client_encrypted_pool_js_1.ClientEncryptedPool(_0_utilities_js_1.UPLOAD_REQUEST_PER_CONNECTION);
1291
+ if (!pool.size) {
1292
+ for (let i = 0; i < _0_utilities_js_1.UPLOAD_POOL_SIZE; ++i) {
1293
+ pool.add(await __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, true));
1294
+ }
1295
+ }
1296
+ const client = pool.nextClient();
1297
+ if (client.authKey.length) {
1298
+ return client;
1299
+ }
1300
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setupClient).call(this, client);
1301
+ return client;
1302
+ }, _Client_setupClient = async function _Client_setupClient(client) {
1303
+ const storage = client.dc == __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc ? this.storage : new _0_storage_operations_js_1.StorageOperations(this.storage.provider.branch(client.dc + (client.cdn ? "_cdn" : "")));
1304
+ const [authKey, serverSalt] = await Promise.all([storage.getAuthKey(), storage.getServerSalt()]);
1305
+ if (authKey) {
1306
+ await client.setAuthKey(authKey);
1307
+ if (serverSalt) {
1308
+ client.serverSalt = serverSalt;
1309
+ }
1310
+ }
1311
+ await client.connect();
1312
+ if (!authKey) {
1313
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_importAuthorization).call(this, client);
1314
+ }
1315
+ await Promise.all([storage.setAuthKey(client.authKey), storage.setServerSalt(client.serverSalt)]);
1316
+ client.handlers.onNewServerSalt = async (serverSalt) => {
1317
+ await storage.setServerSalt(serverSalt);
1318
+ };
1319
+ }, _Client_importAuthorization = async function _Client_importAuthorization(client) {
1320
+ if (__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc == client.dc && __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).cdn == client.cdn) {
1321
+ const [authKey, serverSalt] = await Promise.all([this.storage.getAuthKey(), this.storage.getServerSalt()]);
1322
+ if (authKey) {
1323
+ await client.setAuthKey(authKey);
1324
+ if (serverSalt) {
1325
+ client.serverSalt = serverSalt;
1326
+ }
1327
+ }
1328
+ return;
1329
+ }
1330
+ const exportedAuthorization = await __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).invoke({ _: "auth.exportAuthorization", dc_id: (0, _3_transport_js_1.getDcId)(client.dc, client.cdn) });
1331
+ await client.invoke({ ...exportedAuthorization, _: "auth.importAuthorization" });
1332
+ }, _Client_invoke = async function _Client_invoke(function_, params) {
1333
+ if (!__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)) {
1334
+ throw new _0_errors_js_1.ConnectionError("Not connected.");
1335
+ }
1357
1336
  let n = 1;
1337
+ let client;
1358
1338
  while (true) {
1339
+ client = params ? await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getClient).call(this, params) : __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get);
1340
+ const main = client === __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get);
1359
1341
  try {
1360
- if (__classPrivateFieldGet(this, _Client_disableUpdates, "f") && !(0, _0_utilities_js_1.isMtprotoFunction)(function_) && !(0, _0_utilities_js_1.isCdnFunction)(function_)) {
1361
- function_ = { _: "invokeWithoutUpdates", query: function_ };
1362
- }
1363
- if (!__classPrivateFieldGet(this, _Client_connectionInited, "f") && !(0, _0_utilities_js_1.isMtprotoFunction)(function_)) {
1364
- __classPrivateFieldSet(this, _Client_connectionInited, true, "f");
1365
- __classPrivateFieldGet(this, _Client_L, "f").debug("init");
1366
- const result = await __classPrivateFieldGet(this, _Client_client, "f").invoke({
1367
- _: "initConnection",
1368
- api_id: await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getApiId).call(this),
1369
- app_version: this.appVersion,
1370
- device_model: this.deviceModel,
1371
- lang_code: this.language,
1372
- lang_pack: this.platform,
1373
- query: {
1374
- _: "invokeWithLayer",
1375
- layer: _4_constants_js_1.LAYER,
1376
- query: function_,
1377
- },
1378
- system_lang_code: this.systemLangCode,
1379
- system_version: this.systemVersion,
1380
- }, noWait);
1381
- __classPrivateFieldGet(this, _Client_L$initConncetion, "f").debug("connection inited");
1382
- return result;
1383
- }
1384
- else {
1385
- return await __classPrivateFieldGet(this, _Client_client, "f").invoke(function_, noWait);
1342
+ const result = await client.invoke(function_);
1343
+ if (main) {
1344
+ try {
1345
+ await __classPrivateFieldGet(this, _Client_updateManager, "f").processResult(result);
1346
+ }
1347
+ catch (err) {
1348
+ __classPrivateFieldGet(this, _Client_L, "f").error("failed to process result:", err);
1349
+ }
1350
+ if (_2_tl_js_1.Api.isOfEnum("Update", result) || _2_tl_js_1.Api.isOfEnum("Updates", result)) {
1351
+ return new Promise((resolve) => {
1352
+ __classPrivateFieldGet(this, _Client_updateManager, "f").processUpdates(result, true, null, () => resolve(result));
1353
+ });
1354
+ }
1386
1355
  }
1356
+ return result;
1387
1357
  }
1388
1358
  catch (err) {
1389
- if (err instanceof _4_errors_js_1.ConnectionNotInited) {
1390
- __classPrivateFieldSet(this, _Client_connectionInited, false, "f");
1359
+ if (err instanceof _4_errors_js_1.AuthKeyUnregistered && !main) {
1360
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_importAuthorization).call(this, client);
1361
+ continue;
1362
+ }
1363
+ else if (err instanceof _0_errors_js_1.ConnectionError && !main && !this.disconnected) {
1391
1364
  continue;
1392
1365
  }
1393
1366
  else if (await __classPrivateFieldGet(this, _Client_handleInvokeError, "f").call(this, Object.freeze({ client: this, error: err, function: function_, n: n++ }), () => Promise.resolve(false))) {
@@ -1400,27 +1373,27 @@ class Client extends Composer {
1400
1373
  }
1401
1374
  }, _Client_getUserAccessHash = async function _Client_getUserAccessHash(userId) {
1402
1375
  const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUser", user_id: userId, access_hash: 0n }] });
1403
- const user = (0, _2_tl_js_1.as)("user", users[0]);
1376
+ const user = _2_tl_js_1.Api.as("user", users[0]);
1404
1377
  if (user) {
1405
1378
  await this.messageStorage.setEntity(user);
1406
1379
  }
1407
1380
  return user?.access_hash ?? 0n;
1408
1381
  }, _Client_getChannelAccessHash = async function _Client_getChannelAccessHash(channelId) {
1409
1382
  const channels = await this.invoke({ _: "channels.getChannels", id: [{ _: "inputChannel", channel_id: channelId, access_hash: 0n }] });
1410
- const channel = (0, _2_tl_js_1.as)("channel", channels.chats[0]);
1383
+ const channel = _2_tl_js_1.Api.as("channel", channels.chats[0]);
1411
1384
  if (channel) {
1412
1385
  await this.messageStorage.setEntity(channel);
1413
1386
  }
1414
1387
  return channel?.access_hash ?? 0n;
1415
1388
  }, _Client_getInputPeerChatId = async function _Client_getInputPeerChatId(inputPeer) {
1416
- if ((0, _2_tl_js_1.isOneOf)(["inputPeerSelf", "inputUserSelf"], inputPeer)) {
1389
+ if (_2_tl_js_1.Api.isOneOf(["inputPeerSelf", "inputUserSelf"], inputPeer)) {
1417
1390
  return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this);
1418
1391
  }
1419
- else if ((0, _2_tl_js_1.isOneOf)(["inputPeerEmpty", "inputUserEmpty", "inputChannelEmpty"], inputPeer)) {
1392
+ else if (_2_tl_js_1.Api.isOneOf(["inputPeerEmpty", "inputUserEmpty", "inputChannelEmpty"], inputPeer)) {
1420
1393
  (0, _0_deps_js_1.unreachable)();
1421
1394
  }
1422
1395
  else {
1423
- return (0, _2_tl_js_1.peerToChatId)(inputPeer);
1396
+ return _2_tl_js_1.Api.peerToChatId(inputPeer);
1424
1397
  }
1425
1398
  }, _Client_getInputPeerInner = async function _Client_getInputPeerInner(id) {
1426
1399
  const idn = Number(id);
@@ -1440,24 +1413,24 @@ class Client extends Composer {
1440
1413
  const resolved = await this.invoke({ _: "contacts.resolveUsername", username: id });
1441
1414
  await __classPrivateFieldGet(this, _Client_updateManager, "f").processChats(resolved.chats, resolved);
1442
1415
  await __classPrivateFieldGet(this, _Client_updateManager, "f").processUsers(resolved.users, resolved);
1443
- if ((0, _2_tl_js_1.is)("peerUser", resolved.peer)) {
1444
- resolvedId = (0, _2_tl_js_1.peerToChatId)(resolved.peer);
1416
+ if (_2_tl_js_1.Api.is("peerUser", resolved.peer)) {
1417
+ resolvedId = _2_tl_js_1.Api.peerToChatId(resolved.peer);
1445
1418
  }
1446
- else if ((0, _2_tl_js_1.is)("peerChannel", resolved.peer)) {
1447
- resolvedId = (0, _2_tl_js_1.peerToChatId)(resolved.peer);
1419
+ else if (_2_tl_js_1.Api.is("peerChannel", resolved.peer)) {
1420
+ resolvedId = _2_tl_js_1.Api.peerToChatId(resolved.peer);
1448
1421
  }
1449
1422
  else {
1450
1423
  (0, _0_deps_js_1.unreachable)();
1451
1424
  }
1452
1425
  }
1453
- const resolvedIdType = (0, _2_tl_js_1.getChatIdPeerType)(resolvedId);
1426
+ const resolvedIdType = _2_tl_js_1.Api.getChatIdPeerType(resolvedId);
1454
1427
  if (resolvedIdType == "user") {
1455
1428
  const accessHash = await this.messageStorage.getUserAccessHash(resolvedId);
1456
- peer = { _: "inputPeerUser", user_id: (0, _2_tl_js_1.chatIdToPeerId)(resolvedId), access_hash: accessHash ?? 0n };
1429
+ peer = { _: "inputPeerUser", user_id: _2_tl_js_1.Api.chatIdToPeerId(resolvedId), access_hash: accessHash ?? 0n };
1457
1430
  }
1458
1431
  else if (resolvedIdType == "channel") {
1459
1432
  const accessHash = await this.messageStorage.getChannelAccessHash(resolvedId);
1460
- peer = { _: "inputPeerChannel", channel_id: (0, _2_tl_js_1.chatIdToPeerId)(resolvedId), access_hash: accessHash ?? 0n };
1433
+ peer = { _: "inputPeerChannel", channel_id: _2_tl_js_1.Api.chatIdToPeerId(resolvedId), access_hash: accessHash ?? 0n };
1461
1434
  }
1462
1435
  else {
1463
1436
  (0, _0_deps_js_1.unreachable)();
@@ -1465,20 +1438,20 @@ class Client extends Composer {
1465
1438
  }
1466
1439
  else if (id > 0) {
1467
1440
  const accessHash = await this.messageStorage.getUserAccessHash(id);
1468
- peer = { _: "inputPeerUser", user_id: (0, _2_tl_js_1.chatIdToPeerId)(id), access_hash: accessHash ?? 0n };
1441
+ peer = { _: "inputPeerUser", user_id: _2_tl_js_1.Api.chatIdToPeerId(id), access_hash: accessHash ?? 0n };
1469
1442
  }
1470
1443
  else if (-_4_constants_js_1.MAX_CHAT_ID <= id) {
1471
1444
  peer = { _: "inputPeerChat", chat_id: BigInt(Math.abs(id)) };
1472
1445
  }
1473
1446
  else if (_1_utilities_js_1.ZERO_CHANNEL_ID - _4_constants_js_1.MAX_CHANNEL_ID <= id && id != _1_utilities_js_1.ZERO_CHANNEL_ID) {
1474
1447
  const accessHash = await this.messageStorage.getChannelAccessHash(id);
1475
- peer = { _: "inputPeerChannel", channel_id: (0, _2_tl_js_1.chatIdToPeerId)(id), access_hash: accessHash ?? 0n };
1448
+ peer = { _: "inputPeerChannel", channel_id: _2_tl_js_1.Api.chatIdToPeerId(id), access_hash: accessHash ?? 0n };
1476
1449
  }
1477
1450
  else {
1478
1451
  throw new _0_errors_js_1.InputError("The ID is of an format unknown.");
1479
1452
  }
1480
- if (!(0, _2_tl_js_1.is)("inputPeerChat", peer) && !peer.access_hash) {
1481
- const chatId = (0, _2_tl_js_1.peerToChatId)(peer);
1453
+ if (!_2_tl_js_1.Api.is("inputPeerChat", peer) && !peer.access_hash) {
1454
+ const chatId = _2_tl_js_1.Api.peerToChatId(peer);
1482
1455
  const minPeerReference = await this.messageStorage.getLastMinPeerReference(chatId);
1483
1456
  if (minPeerReference) {
1484
1457
  const minInputPeer = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMinInputPeer).call(this, (0, _0_utilities_js_1.canBeInputChannel)(peer) ? "channel" : "user", { ...minPeerReference, senderId: chatId });
@@ -1491,22 +1464,22 @@ class Client extends Composer {
1491
1464
  return peer;
1492
1465
  }, _Client_getMinInputPeer = async function _Client_getMinInputPeer(type, reference) {
1493
1466
  const entity = await this.messageStorage.getEntity(reference.chatId);
1494
- if ((0, _2_tl_js_1.isOneOf)(["channel", "channelForbidden"], entity) && entity.access_hash) {
1467
+ if (_2_tl_js_1.Api.isOneOf(["channel", "channelForbidden"], entity) && entity.access_hash) {
1495
1468
  const peer = { _: "inputPeerChannel", channel_id: entity.id, access_hash: entity.access_hash };
1496
1469
  if (type == "user") {
1497
- return { _: "inputPeerUserFromMessage", peer, msg_id: reference.messageId, user_id: (0, _2_tl_js_1.chatIdToPeerId)(reference.senderId) };
1470
+ return { _: "inputPeerUserFromMessage", peer, msg_id: reference.messageId, user_id: _2_tl_js_1.Api.chatIdToPeerId(reference.senderId) };
1498
1471
  }
1499
1472
  else {
1500
- return { _: "inputPeerChannelFromMessage", peer, msg_id: reference.messageId, channel_id: (0, _2_tl_js_1.chatIdToPeerId)(reference.senderId) };
1473
+ return { _: "inputPeerChannelFromMessage", peer, msg_id: reference.messageId, channel_id: _2_tl_js_1.Api.chatIdToPeerId(reference.senderId) };
1501
1474
  }
1502
1475
  }
1503
1476
  else {
1504
1477
  return null;
1505
1478
  }
1506
1479
  }, getEntity)](peer) {
1507
- const id = (0, _2_tl_js_1.peerToChatId)(peer);
1480
+ const id = _2_tl_js_1.Api.peerToChatId(peer);
1508
1481
  const entity = await this.messageStorage.getEntity(id);
1509
- if (entity == null && await this.storage.getAccountType() == "bot" && (0, _2_tl_js_1.is)("peerUser", peer) || (0, _2_tl_js_1.is)("peerChannel", peer)) {
1482
+ if (entity == null && await this.storage.getAccountType() == "bot" && _2_tl_js_1.Api.is("peerUser", peer) || _2_tl_js_1.Api.is("peerChannel", peer)) {
1510
1483
  await this.getInputPeer(id);
1511
1484
  }
1512
1485
  else {
@@ -1526,7 +1499,7 @@ class Client extends Composer {
1526
1499
  let user_ = await this[getEntity]({ _: "peerUser", user_id: BigInt(await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this)) });
1527
1500
  if (user_ == null) {
1528
1501
  const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUserSelf" }] });
1529
- user_ = (0, _2_tl_js_1.as)("user", users[0]);
1502
+ user_ = _2_tl_js_1.Api.as("user", users[0]);
1530
1503
  await this.messageStorage.setEntity(user_);
1531
1504
  }
1532
1505
  const user = (0, _3_types_js_1.constructUser)(user_);
@@ -3325,7 +3298,7 @@ class Client extends Composer {
3325
3298
  }
3326
3299
  }
3327
3300
  exports.Client = Client;
3328
- _a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
3301
+ _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
3329
3302
  if (__classPrivateFieldGet(this, _Client_disableUpdates, "f") && !("authorizationState" in update) && !("connectionState" in update)) {
3330
3303
  return;
3331
3304
  }
@@ -3341,7 +3314,7 @@ _a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(up
3341
3314
  });
3342
3315
  }, _Client_handleUpdate = async function _Client_handleUpdate(update) {
3343
3316
  const promises = new Array();
3344
- if ((0, _2_tl_js_1.is)("updateUserName", update)) {
3317
+ if (_2_tl_js_1.Api.is("updateUserName", update)) {
3345
3318
  await this.messageStorage.updateUsernames(Number(update.user_id), update.usernames.map((v) => v.username));
3346
3319
  const peer = { ...update, _: "peerUser" };
3347
3320
  const entity = await this[getEntity](peer);
@@ -3457,4 +3430,15 @@ _a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(up
3457
3430
  __classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
3458
3431
  return user;
3459
3432
  }
3433
+ }, _Client_onConnectionStateChange = function _Client_onConnectionStateChange(connected) {
3434
+ if (__classPrivateFieldGet(this, _Client_lastConnectionState, "f") != connected) {
3435
+ if (connected) {
3436
+ if (__classPrivateFieldGet(this, _Client_previouslyConnected, "f")) {
3437
+ (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("reconnect"));
3438
+ }
3439
+ __classPrivateFieldSet(this, _Client_previouslyConnected, true, "f");
3440
+ }
3441
+ const connectionState = connected ? "ready" : "notConnected";
3442
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
3443
+ }
3460
3444
  };