@mtkruto/node 0.67.1 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (355) hide show
  1. package/esm/0_errors.js +2 -6
  2. package/esm/3_errors.js +2 -12
  3. package/esm/3_transport.d.ts +3 -3
  4. package/esm/3_transport.js +3 -3
  5. package/esm/3_types.d.ts +8 -7
  6. package/esm/3_types.d.ts.map +1 -1
  7. package/esm/3_types.js +8 -7
  8. package/esm/4_errors.js +2 -12
  9. package/esm/_dnt.polyfills.d.ts +99 -0
  10. package/esm/_dnt.polyfills.d.ts.map +1 -1
  11. package/esm/_dnt.polyfills.js +127 -1
  12. package/esm/_dnt.test_polyfills.d.ts.map +1 -0
  13. package/esm/client/0_filters_test.d.ts.map +1 -1
  14. package/esm/client/0_markdown_test.d.ts.map +1 -1
  15. package/esm/client/0_params.d.ts +2 -0
  16. package/esm/client/0_params.d.ts.map +1 -1
  17. package/esm/client/0_password.d.ts +5 -5
  18. package/esm/client/0_password.d.ts.map +1 -1
  19. package/esm/client/0_password_test.d.ts.map +1 -1
  20. package/esm/client/0_storage_operations.js +143 -155
  21. package/esm/client/0_storage_operations_test.d.ts.map +1 -1
  22. package/esm/client/0_utilities.d.ts +1 -1
  23. package/esm/client/0_utilities_test.d.ts.map +1 -1
  24. package/esm/client/1_client_plain.js +4 -22
  25. package/esm/client/1_composer.js +8 -21
  26. package/esm/client/2_account_manager.js +85 -97
  27. package/esm/client/2_bot_info_manager.js +26 -38
  28. package/esm/client/2_business_connection_manager.js +10 -23
  29. package/esm/client/2_client_encrypted.js +194 -211
  30. package/esm/client/2_file_manager.d.ts +4 -3
  31. package/esm/client/2_file_manager.d.ts.map +1 -1
  32. package/esm/client/2_file_manager.js +268 -224
  33. package/esm/client/2_file_manager_test.d.ts.map +1 -1
  34. package/esm/client/2_network_statistics_manager.js +8 -21
  35. package/esm/client/2_payment_manager.js +7 -20
  36. package/esm/client/2_reaction_manager.js +7 -20
  37. package/esm/client/2_translations_manager.js +97 -107
  38. package/esm/client/2_update_manager.js +764 -759
  39. package/esm/client/3_client_encrypted_pool.js +10 -26
  40. package/esm/client/3_client_encrypted_pool_test.d.ts.map +1 -1
  41. package/esm/client/3_message_manager.d.ts +1 -1
  42. package/esm/client/3_message_manager.js +441 -448
  43. package/esm/client/3_message_manager_test.d.ts.map +1 -1
  44. package/esm/client/3_video_chat_manager.d.ts +1 -1
  45. package/esm/client/3_video_chat_manager.js +57 -68
  46. package/esm/client/4_callback_query_manager.js +18 -30
  47. package/esm/client/4_chat_list_manager.js +322 -318
  48. package/esm/client/4_chat_manager.js +118 -131
  49. package/esm/client/4_forum_manager.js +67 -73
  50. package/esm/client/4_gift_manager.js +16 -29
  51. package/esm/client/4_inline_query_manager.js +16 -28
  52. package/esm/client/4_link_preview_manager.js +6 -19
  53. package/esm/client/4_poll_manager.js +44 -57
  54. package/esm/client/4_story_manager.js +41 -53
  55. package/esm/client/5_client.d.ts +7 -0
  56. package/esm/client/5_client.d.ts.map +1 -1
  57. package/esm/client/5_client.js +1271 -1290
  58. package/esm/connection/1_connection_tcp.node.js +48 -65
  59. package/esm/connection/1_connection_web_socket.js +75 -91
  60. package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  61. package/esm/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
  62. package/esm/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
  63. package/esm/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
  64. package/esm/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
  65. package/esm/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
  66. package/esm/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
  67. package/esm/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
  68. package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
  69. package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
  70. package/esm/deps/jsr.io/@std/internal/1.0.10/format.js +70 -0
  71. package/esm/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
  72. package/esm/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
  73. package/esm/mod.js +2 -12
  74. package/esm/session/0_session_state.js +12 -38
  75. package/esm/session/1_session.js +49 -72
  76. package/esm/session/2_session_encrypted.js +324 -320
  77. package/esm/storage/1_utilities_test.d.ts.map +1 -1
  78. package/esm/storage/2_storage_indexed_db.js +26 -44
  79. package/esm/storage/2_storage_local_storage.node.js +12 -25
  80. package/esm/storage/2_storage_memory.js +24 -41
  81. package/esm/storage/2_storage_session_storage.js +3 -16
  82. package/esm/tl/0_utilities_test.d.ts.map +1 -1
  83. package/esm/tl/1_tl_reader.js +80 -88
  84. package/esm/tl/1_tl_reader_test.d.ts.map +1 -1
  85. package/esm/tl/1_tl_writer.js +155 -164
  86. package/esm/tl/1_tl_writer_test.d.ts.map +1 -1
  87. package/esm/tl/2_telegram.d.ts +9 -10
  88. package/esm/tl/2_telegram.d.ts.map +1 -1
  89. package/esm/tl/2_telegram.js +10 -10
  90. package/esm/transport/0_transport.js +1 -8
  91. package/esm/transport/1_transport_abridged.js +11 -24
  92. package/esm/transport/1_transport_intermediate.js +10 -23
  93. package/{script/transport/2_transport_provider.d.ts → esm/transport/1_transport_provider.d.ts} +1 -1
  94. package/esm/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
  95. package/{script/transport/3_transport_provider_tcp.d.ts → esm/transport/2_transport_provider_tcp.d.ts} +2 -2
  96. package/esm/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
  97. package/esm/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +1 -1
  98. package/esm/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
  99. package/esm/transport/2_transport_provider_web_socket.d.ts.map +1 -0
  100. package/esm/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +1 -1
  101. package/esm/types/0_upload_progress.d.ts +29 -0
  102. package/esm/types/0_upload_progress.d.ts.map +1 -0
  103. package/esm/types/0_upload_progress.js +20 -0
  104. package/esm/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
  105. package/esm/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
  106. package/esm/types/1_sticker.d.ts +1 -1
  107. package/esm/types/1_sticker.d.ts.map +1 -1
  108. package/esm/types/2_chat.d.ts.map +1 -1
  109. package/esm/types/2_poll_answer.d.ts +19 -0
  110. package/esm/types/2_poll_answer.d.ts.map +1 -1
  111. package/esm/types/2_poll_answer.js +19 -0
  112. package/esm/types/2_pre_checkout_query.d.ts.map +1 -1
  113. package/esm/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
  114. package/esm/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
  115. package/esm/types/{3_reply_markup.js → 2_reply_markup.js} +1 -1
  116. package/esm/types/2_story_interactive_area.d.ts.map +1 -1
  117. package/esm/types/3_chat_member_updated.d.ts.map +1 -1
  118. package/esm/types/3_story.d.ts.map +1 -1
  119. package/esm/types/5_message.d.ts +1 -1
  120. package/esm/types/5_message.d.ts.map +1 -1
  121. package/esm/types/5_message.js +1 -1
  122. package/esm/types/6_inline_query_result.d.ts +1 -1
  123. package/esm/types/6_inline_query_result.js +1 -1
  124. package/esm/types/7_update.d.ts +21 -2
  125. package/esm/types/7_update.d.ts.map +1 -1
  126. package/esm/utilities/0_bigint_test.d.ts.map +1 -1
  127. package/esm/utilities/0_buffer.d.ts +1 -1
  128. package/esm/utilities/0_buffer.d.ts.map +1 -1
  129. package/esm/utilities/0_buffer_test.d.ts.map +1 -1
  130. package/esm/utilities/0_hash.d.ts +2 -2
  131. package/esm/utilities/0_hash.d.ts.map +1 -1
  132. package/esm/utilities/0_mutex.js +4 -19
  133. package/esm/utilities/0_part_stream.js +11 -25
  134. package/esm/utilities/0_part_stream_test.d.ts.map +1 -1
  135. package/esm/utilities/0_rle.d.ts +2 -2
  136. package/esm/utilities/0_rle.d.ts.map +1 -1
  137. package/esm/utilities/0_rle_test.d.ts.map +1 -1
  138. package/esm/utilities/0_text.d.ts +20 -1
  139. package/esm/utilities/0_text.d.ts.map +1 -1
  140. package/esm/utilities/0_text.js +19 -0
  141. package/esm/utilities/1_auth.d.ts +1 -1
  142. package/esm/utilities/1_auth.d.ts.map +1 -1
  143. package/esm/utilities/1_base64.d.ts +1 -1
  144. package/esm/utilities/1_base64.d.ts.map +1 -1
  145. package/esm/utilities/1_base64_test.d.ts.map +1 -1
  146. package/esm/utilities/1_crypto.js +42 -53
  147. package/esm/utilities/1_crypto_test.d.ts.map +1 -1
  148. package/esm/utilities/1_logger.d.ts +2 -2
  149. package/esm/utilities/1_math_test.d.ts.map +1 -1
  150. package/esm/utilities/2_queue.js +29 -47
  151. package/package.json +1 -1
  152. package/script/0_errors.js +2 -6
  153. package/script/2_tl.js +17 -7
  154. package/script/3_errors.js +2 -12
  155. package/script/3_transport.d.ts +3 -3
  156. package/script/3_transport.js +3 -3
  157. package/script/3_types.d.ts +8 -7
  158. package/script/3_types.d.ts.map +1 -1
  159. package/script/3_types.js +8 -7
  160. package/script/4_constants.js +17 -7
  161. package/script/4_errors.js +2 -12
  162. package/script/_dnt.polyfills.d.ts +99 -0
  163. package/script/_dnt.polyfills.d.ts.map +1 -1
  164. package/script/_dnt.polyfills.js +128 -0
  165. package/script/_dnt.test_polyfills.d.ts.map +1 -0
  166. package/script/client/0_filters_test.d.ts.map +1 -1
  167. package/script/client/0_markdown_test.d.ts.map +1 -1
  168. package/script/client/0_params.d.ts +2 -0
  169. package/script/client/0_params.d.ts.map +1 -1
  170. package/script/client/0_password.d.ts +5 -5
  171. package/script/client/0_password.d.ts.map +1 -1
  172. package/script/client/0_password.js +17 -7
  173. package/script/client/0_password_test.d.ts.map +1 -1
  174. package/script/client/0_storage_operations.js +143 -155
  175. package/script/client/0_storage_operations_test.d.ts.map +1 -1
  176. package/script/client/0_utilities.d.ts +1 -1
  177. package/script/client/0_utilities_test.d.ts.map +1 -1
  178. package/script/client/1_client_plain.js +4 -22
  179. package/script/client/1_composer.js +8 -21
  180. package/script/client/2_account_manager.js +85 -97
  181. package/script/client/2_bot_info_manager.js +26 -38
  182. package/script/client/2_business_connection_manager.js +10 -23
  183. package/script/client/2_client_encrypted.js +195 -212
  184. package/script/client/2_file_manager.d.ts +4 -3
  185. package/script/client/2_file_manager.d.ts.map +1 -1
  186. package/script/client/2_file_manager.js +285 -231
  187. package/script/client/2_file_manager_test.d.ts.map +1 -1
  188. package/script/client/2_network_statistics_manager.js +8 -21
  189. package/script/client/2_payment_manager.js +7 -20
  190. package/script/client/2_reaction_manager.js +7 -20
  191. package/script/client/2_translations_manager.js +98 -108
  192. package/script/client/2_update_manager.js +764 -759
  193. package/script/client/3_client_encrypted_pool.js +10 -26
  194. package/script/client/3_client_encrypted_pool_test.d.ts.map +1 -1
  195. package/script/client/3_message_manager.d.ts +1 -1
  196. package/script/client/3_message_manager.js +441 -448
  197. package/script/client/3_message_manager_test.d.ts.map +1 -1
  198. package/script/client/3_video_chat_manager.d.ts +1 -1
  199. package/script/client/3_video_chat_manager.js +57 -68
  200. package/script/client/4_callback_query_manager.js +18 -30
  201. package/script/client/4_chat_list_manager.js +322 -318
  202. package/script/client/4_chat_manager.js +118 -131
  203. package/script/client/4_forum_manager.js +67 -73
  204. package/script/client/4_gift_manager.js +16 -29
  205. package/script/client/4_inline_query_manager.js +16 -28
  206. package/script/client/4_link_preview_manager.js +6 -19
  207. package/script/client/4_poll_manager.js +44 -57
  208. package/script/client/4_story_manager.js +41 -53
  209. package/script/client/5_client.d.ts +7 -0
  210. package/script/client/5_client.d.ts.map +1 -1
  211. package/script/client/5_client.js +1271 -1290
  212. package/script/connection/1_connection_tcp.node.js +48 -65
  213. package/script/connection/1_connection_web_socket.js +92 -98
  214. package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  215. package/script/deps/jsr.io/@std/assert/1.0.13/equal.js +17 -7
  216. package/script/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
  217. package/script/deps/jsr.io/@std/async/1.0.13/delay.js +17 -7
  218. package/script/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
  219. package/script/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
  220. package/script/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
  221. package/script/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
  222. package/script/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
  223. package/script/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
  224. package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
  225. package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
  226. package/script/deps/jsr.io/@std/internal/1.0.10/format.js +106 -0
  227. package/script/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
  228. package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +17 -7
  229. package/script/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
  230. package/script/deps/jsr.io/@std/path/1.1.0/_os.js +17 -7
  231. package/script/mod.js +19 -19
  232. package/script/session/0_session_state.js +12 -38
  233. package/script/session/1_session.js +66 -79
  234. package/script/session/2_session_encrypted.js +325 -321
  235. package/script/storage/1_utilities_test.d.ts.map +1 -1
  236. package/script/storage/2_storage_indexed_db.js +26 -44
  237. package/script/storage/2_storage_local_storage.node.js +12 -25
  238. package/script/storage/2_storage_memory.js +24 -41
  239. package/script/storage/2_storage_session_storage.js +3 -16
  240. package/script/tl/0_utilities_test.d.ts.map +1 -1
  241. package/script/tl/1_tl_reader.js +81 -89
  242. package/script/tl/1_tl_reader_test.d.ts.map +1 -1
  243. package/script/tl/1_tl_writer.js +156 -165
  244. package/script/tl/1_tl_writer_test.d.ts.map +1 -1
  245. package/script/tl/2_telegram.d.ts +9 -10
  246. package/script/tl/2_telegram.d.ts.map +1 -1
  247. package/script/tl/2_telegram.js +32 -10
  248. package/script/transport/0_obfuscation.js +17 -7
  249. package/script/transport/0_transport.js +1 -8
  250. package/script/transport/1_transport_abridged.js +11 -24
  251. package/script/transport/1_transport_intermediate.js +10 -23
  252. package/{esm/transport/2_transport_provider.d.ts → script/transport/1_transport_provider.d.ts} +1 -1
  253. package/script/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
  254. package/{esm/transport/3_transport_provider_tcp.d.ts → script/transport/2_transport_provider_tcp.d.ts} +2 -2
  255. package/script/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
  256. package/script/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +3 -3
  257. package/script/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
  258. package/script/transport/2_transport_provider_web_socket.d.ts.map +1 -0
  259. package/script/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +2 -2
  260. package/script/types/0_upload_progress.d.ts +29 -0
  261. package/script/types/0_upload_progress.d.ts.map +1 -0
  262. package/script/types/0_upload_progress.js +21 -0
  263. package/script/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
  264. package/script/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
  265. package/script/types/1_sticker.d.ts +1 -1
  266. package/script/types/1_sticker.d.ts.map +1 -1
  267. package/script/types/2_chat.d.ts.map +1 -1
  268. package/script/types/2_poll_answer.d.ts +19 -0
  269. package/script/types/2_poll_answer.d.ts.map +1 -1
  270. package/script/types/2_poll_answer.js +19 -0
  271. package/script/types/2_pre_checkout_query.d.ts.map +1 -1
  272. package/script/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
  273. package/script/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
  274. package/script/types/{3_reply_markup.js → 2_reply_markup.js} +3 -3
  275. package/script/types/2_story_interactive_area.d.ts.map +1 -1
  276. package/script/types/3_chat_member_updated.d.ts.map +1 -1
  277. package/script/types/3_story.d.ts.map +1 -1
  278. package/script/types/5_message.d.ts +1 -1
  279. package/script/types/5_message.d.ts.map +1 -1
  280. package/script/types/5_message.js +2 -2
  281. package/script/types/6_inline_query_result.d.ts +1 -1
  282. package/script/types/6_inline_query_result.js +4 -4
  283. package/script/types/7_update.d.ts +21 -2
  284. package/script/types/7_update.d.ts.map +1 -1
  285. package/script/utilities/0_bigint.js +17 -7
  286. package/script/utilities/0_bigint_test.d.ts.map +1 -1
  287. package/script/utilities/0_buffer.d.ts +1 -1
  288. package/script/utilities/0_buffer.d.ts.map +1 -1
  289. package/script/utilities/0_buffer_test.d.ts.map +1 -1
  290. package/script/utilities/0_env.js +17 -7
  291. package/script/utilities/0_hash.d.ts +2 -2
  292. package/script/utilities/0_hash.d.ts.map +1 -1
  293. package/script/utilities/0_hash.js +17 -7
  294. package/script/utilities/0_misc.js +17 -7
  295. package/script/utilities/0_mutex.js +4 -19
  296. package/script/utilities/0_part_stream.js +11 -25
  297. package/script/utilities/0_part_stream_test.d.ts.map +1 -1
  298. package/script/utilities/0_rle.d.ts +2 -2
  299. package/script/utilities/0_rle.d.ts.map +1 -1
  300. package/script/utilities/0_rle_test.d.ts.map +1 -1
  301. package/script/utilities/0_text.d.ts +20 -1
  302. package/script/utilities/0_text.d.ts.map +1 -1
  303. package/script/utilities/0_text.js +19 -0
  304. package/script/utilities/1_auth.d.ts +1 -1
  305. package/script/utilities/1_auth.d.ts.map +1 -1
  306. package/script/utilities/1_auth.js +17 -7
  307. package/script/utilities/1_base64.d.ts +1 -1
  308. package/script/utilities/1_base64.d.ts.map +1 -1
  309. package/script/utilities/1_base64_test.d.ts.map +1 -1
  310. package/script/utilities/1_crypto.js +60 -61
  311. package/script/utilities/1_crypto_test.d.ts.map +1 -1
  312. package/script/utilities/1_logger.d.ts +2 -2
  313. package/script/utilities/1_math_test.d.ts.map +1 -1
  314. package/script/utilities/2_queue.js +30 -48
  315. package/esm/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
  316. package/esm/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
  317. package/esm/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
  318. package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
  319. package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
  320. package/esm/deps/jsr.io/@std/internal/1.0.9/format.js +0 -37
  321. package/esm/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
  322. package/esm/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
  323. package/esm/transport/3_transport_provider_web_socket.d.ts.map +0 -1
  324. package/script/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
  325. package/script/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
  326. package/script/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
  327. package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
  328. package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
  329. package/script/deps/jsr.io/@std/internal/1.0.9/format.js +0 -63
  330. package/script/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
  331. package/script/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
  332. package/script/transport/3_transport_provider_web_socket.d.ts.map +0 -1
  333. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
  334. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
  335. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
  336. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
  337. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
  338. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
  339. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
  340. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +0 -0
  341. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
  342. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
  343. /package/esm/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
  344. /package/esm/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
  345. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
  346. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
  347. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
  348. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
  349. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
  350. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
  351. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
  352. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
  353. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
  354. /package/script/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
  355. /package/script/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
@@ -17,18 +17,6 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
21
- if (kind === "m") throw new TypeError("Private method is not writable");
22
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
23
- 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");
24
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
25
- };
26
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
27
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
28
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
29
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
- };
31
- var _MessageManager_instances, _a, _MessageManager_c, _MessageManager_LresolveFileId, _MessageManager_checkParams, _MessageManager_constructReplyMarkup, _MessageManager_resolveSendAs, _MessageManager_constructReplyTo, _MessageManager_sendDocumentInner, _MessageManager_sendMedia, _MessageManager_CAPTIONABLE_MESSAGE_TYPES, _MessageManager_editInlineMessageTextInner, _MessageManager_resolveInputMediaInner, _MessageManager_resolveInputMedia, _MessageManager_sendReaction, _MessageManager_getCachedVoiceTranscription, _MessageManager_cacheVoiceTranscription;
32
20
  import { contentType, unreachable } from "../0_deps.js";
33
21
  import { InputError } from "../0_errors.js";
34
22
  import { encodeText, fromUnixTimestamp, getLogger, getRandomId } from "../1_utilities.js";
@@ -57,31 +45,21 @@ const messageManagerUpdates = [
57
45
  "updateTranscribedAudio",
58
46
  ];
59
47
  export class MessageManager {
48
+ #c;
49
+ #LresolveFileId;
60
50
  constructor(c) {
61
- _MessageManager_instances.add(this);
62
- _MessageManager_c.set(this, void 0);
63
- _MessageManager_LresolveFileId.set(this, void 0);
64
- Object.defineProperty(this, "usernameResolver", {
65
- enumerable: true,
66
- configurable: true,
67
- writable: true,
68
- value: async (v) => {
69
- const inputPeer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(v).then((v) => Api.as("inputPeerUser", v));
70
- return { ...inputPeer, _: "inputUser" };
71
- }
72
- });
73
- __classPrivateFieldSet(this, _MessageManager_c, c, "f");
51
+ this.#c = c;
74
52
  const L = getLogger("MessageManager").client(c.id);
75
- __classPrivateFieldSet(this, _MessageManager_LresolveFileId, L.branch("resolveFileId"), "f");
53
+ this.#LresolveFileId = L.branch("resolveFileId");
76
54
  }
77
55
  async getMessages(chatId, messageIds) {
78
56
  checkArray(messageIds, checkMessageId);
79
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
57
+ const peer = await this.#c.getInputPeer(chatId);
80
58
  let messages_ = new Array();
81
- const chatId_ = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeerChatId(peer);
59
+ const chatId_ = await this.#c.getInputPeerChatId(peer);
82
60
  let shouldFetch = false;
83
61
  for (const messageId of messageIds) {
84
- const message = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getMessage(chatId_, messageId);
62
+ const message = await this.#c.messageStorage.getMessage(chatId_, messageId);
85
63
  if (message == null) {
86
64
  messages_ = [];
87
65
  shouldFetch = true;
@@ -93,10 +71,10 @@ export class MessageManager {
93
71
  }
94
72
  if (shouldFetch) {
95
73
  if (canBeInputChannel(peer)) {
96
- messages_ = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.getMessages", channel: toInputChannel(peer), id: messageIds.map((v) => ({ _: "inputMessageID", id: v })) }).then((v) => Api.as("messages.channelMessages", v).messages);
74
+ messages_ = await this.#c.invoke({ _: "channels.getMessages", channel: toInputChannel(peer), id: messageIds.map((v) => ({ _: "inputMessageID", id: v })) }).then((v) => Api.as("messages.channelMessages", v).messages);
97
75
  }
98
76
  else {
99
- messages_ = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
77
+ messages_ = await this.#c.invoke({
100
78
  _: "messages.getMessages",
101
79
  id: messageIds.map((v) => ({ _: "inputMessageID", id: v })),
102
80
  }).then((v) => Api.as("messages.messages", v).messages);
@@ -159,9 +137,23 @@ export class MessageManager {
159
137
  }
160
138
  return [text, entities];
161
139
  }
140
+ #checkParams(params) {
141
+ if (params && "replyMarkup" in params && params.replyMarkup !== undefined) {
142
+ this.#c.storage.assertBot("replyMarkup");
143
+ }
144
+ if (params && "businessConnectionId" in params && params.businessConnectionId !== undefined) {
145
+ this.#c.storage.assertBot("businessConnectionId");
146
+ }
147
+ if (params && "sendAs" in params && params.sendAs !== undefined) {
148
+ this.#c.storage.assertUser("sendAs");
149
+ }
150
+ if (params && "sendAt" in params && params.sendAt !== undefined) {
151
+ this.#c.storage.assertUser("businessConsendAtnectionId");
152
+ }
153
+ }
162
154
  async parseText(text_, params) {
163
- const [text, entities_] = _a.parseText(text_, params?.entities ?? [], params?.parseMode ?? __classPrivateFieldGet(this, _MessageManager_c, "f").parseMode);
164
- const entities = entities_?.length > 0 ? await Promise.all(entities_.map((v) => messageEntityToTlObject(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity))) : undefined;
155
+ const [text, entities_] = MessageManager.parseText(text_, params?.entities ?? [], params?.parseMode ?? this.#c.parseMode);
156
+ const entities = entities_?.length > 0 ? await Promise.all(entities_.map((v) => messageEntityToTlObject(v, this.#c.getEntity))) : undefined;
165
157
  return [text, entities];
166
158
  }
167
159
  async updatesToMessages(chatId, updates, businessConnectionId) {
@@ -203,35 +195,35 @@ export class MessageManager {
203
195
  let poll = null;
204
196
  let pollResults = null;
205
197
  if (pollId) {
206
- [poll, pollResults] = await Promise.all([__classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getPoll(pollId), __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getPollResults(pollId)]);
198
+ [poll, pollResults] = await Promise.all([this.#c.messageStorage.getPoll(pollId), this.#c.messageStorage.getPollResults(pollId)]);
207
199
  }
208
- const message = await constructMessage_(message_, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity, this.getMessage.bind(this), __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.getStickerSetName.bind(__classPrivateFieldGet(this, _MessageManager_c, "f").fileManager), r, business, poll ?? undefined, pollResults ?? undefined);
200
+ const message = await constructMessage_(message_, this.#c.getEntity, this.getMessage.bind(this), this.#c.fileManager.getStickerSetName.bind(this.#c.fileManager), r, business, poll ?? undefined, pollResults ?? undefined);
209
201
  if (!poll && mediaPoll) {
210
- await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.setPoll(mediaPoll.poll.id, mediaPoll.poll);
202
+ await this.#c.storage.setPoll(mediaPoll.poll.id, mediaPoll.poll);
211
203
  }
212
204
  if (!pollResults && mediaPoll) {
213
- await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.setPollResults(mediaPoll.poll.id, mediaPoll.results);
205
+ await this.#c.storage.setPollResults(mediaPoll.poll.id, mediaPoll.results);
214
206
  }
215
207
  return message;
216
208
  }
217
209
  async forwardMessages(from, to, messageIds, params) {
218
210
  checkArray(messageIds, checkMessageId);
219
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.forwardMessages", from_peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(from), to_peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(to), id: messageIds, random_id: messageIds.map(() => getRandomId()), silent: params?.disableNotification || undefined, top_msg_id: params?.messageThreadId, noforwards: params?.disableNotification || undefined, send_as: params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined, drop_author: params?.dropSenderName || undefined, drop_media_captions: params?.dropCaption || undefined });
211
+ const result = await this.#c.invoke({ _: "messages.forwardMessages", from_peer: await this.#c.getInputPeer(from), to_peer: await this.#c.getInputPeer(to), id: messageIds, random_id: messageIds.map(() => getRandomId()), silent: params?.disableNotification || undefined, top_msg_id: params?.messageThreadId, noforwards: params?.disableNotification || undefined, send_as: params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined, drop_author: params?.dropSenderName || undefined, drop_media_captions: params?.dropCaption || undefined });
220
212
  return await this.updatesToMessages(to, result);
221
213
  }
222
214
  async getHistory(chatId, params) {
223
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("getHistory");
215
+ this.#c.storage.assertUser("getHistory");
224
216
  const limit = getLimit(params?.limit);
225
217
  let offsetId = params?.fromMessageId ?? 0;
226
218
  if (offsetId < 0) {
227
219
  offsetId = 0;
228
220
  }
229
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
221
+ const peer = await this.#c.getInputPeer(chatId);
230
222
  const messages = new Array();
231
223
  if (messages.length > 0) {
232
224
  offsetId = messages[messages.length - 1].id; // TODO: track id of oldest message and don't send requests for it
233
225
  }
234
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.getHistory", peer: peer, offset_id: offsetId, offset_date: 0, add_offset: 0, limit, max_id: 0, min_id: 0, hash: 0n });
226
+ const result = await this.#c.invoke({ _: "messages.getHistory", peer: peer, offset_id: offsetId, offset_date: 0, add_offset: 0, limit, max_id: 0, min_id: 0, hash: 0n });
235
227
  if (!("messages" in result)) {
236
228
  unreachable();
237
229
  }
@@ -241,23 +233,40 @@ export class MessageManager {
241
233
  }
242
234
  return messages;
243
235
  }
236
+ usernameResolver = async (v) => {
237
+ const inputPeer = await this.#c.getInputPeer(v).then((v) => Api.as("inputPeerUser", v));
238
+ return { ...inputPeer, _: "inputUser" };
239
+ };
240
+ async #constructReplyMarkup(params) {
241
+ if (params?.replyMarkup) {
242
+ this.#c.storage.assertBot("replyMarkup");
243
+ return await replyMarkupToTlObject(params.replyMarkup, this.usernameResolver.bind(this));
244
+ }
245
+ }
246
+ async #resolveSendAs(params) {
247
+ const sendAs = params?.sendAs;
248
+ if (sendAs !== undefined) {
249
+ this.#c.storage.assertUser("sendAs");
250
+ return sendAs ? await this.#c.getInputPeer(sendAs) : undefined;
251
+ }
252
+ }
244
253
  async sendMessage(chatId, text, params) {
245
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
254
+ this.#checkParams(params);
246
255
  const [message, entities] = await this.parseText(text, params);
247
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
248
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
256
+ const replyMarkup = await this.#constructReplyMarkup(params);
257
+ const peer = await this.#c.getInputPeer(chatId);
249
258
  const randomId = getRandomId();
250
259
  const noWebpage = params?.linkPreview?.disable ? true : undefined;
251
260
  const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
252
261
  const silent = params?.disableNotification ? true : undefined;
253
262
  const noforwards = params?.protectContent ? true : undefined;
254
- const sendAs = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveSendAs).call(this, params);
263
+ const sendAs = await this.#resolveSendAs(params);
255
264
  const effect = params?.effectId ? BigInt(params.effectId) : undefined;
256
265
  const schedule_date = params?.sendAt;
257
266
  const allow_paid_floodskip = params?.paidBroadcast ? true : undefined;
258
267
  let result;
259
268
  if (!noWebpage && params?.linkPreview?.url) {
260
- result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
269
+ result = await this.#c.invoke({
261
270
  _: "messages.sendMedia",
262
271
  peer,
263
272
  random_id: randomId,
@@ -272,7 +281,7 @@ export class MessageManager {
272
281
  invert_media: invertMedia,
273
282
  silent,
274
283
  noforwards,
275
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
284
+ reply_to: await this.#constructReplyTo(params),
276
285
  send_as: sendAs,
277
286
  entities,
278
287
  reply_markup: replyMarkup,
@@ -282,7 +291,7 @@ export class MessageManager {
282
291
  }, { businessConnectionId: params?.businessConnectionId });
283
292
  }
284
293
  else {
285
- result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
294
+ result = await this.#c.invoke({
286
295
  _: "messages.sendMessage",
287
296
  peer,
288
297
  random_id: randomId,
@@ -291,7 +300,7 @@ export class MessageManager {
291
300
  invert_media: invertMedia,
292
301
  silent,
293
302
  noforwards,
294
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
303
+ reply_to: await this.#constructReplyTo(params),
295
304
  send_as: sendAs,
296
305
  entities,
297
306
  reply_markup: replyMarkup,
@@ -303,21 +312,38 @@ export class MessageManager {
303
312
  const message_ = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
304
313
  return assertMessageType(message_, "text");
305
314
  }
315
+ async #constructReplyTo(params) {
316
+ const topMsgId = params?.messageThreadId;
317
+ if (!params?.replyTo) {
318
+ if (topMsgId) {
319
+ return { _: "inputReplyToMessage", reply_to_msg_id: topMsgId };
320
+ }
321
+ else {
322
+ return undefined;
323
+ }
324
+ }
325
+ if ("messageId" in params.replyTo) {
326
+ return { _: "inputReplyToMessage", reply_to_msg_id: params.replyTo.messageId, top_msg_id: topMsgId, quote_text: params.replyTo.quote?.text, quote_entities: await Promise.all(params.replyTo.quote?.entities.map((v) => messageEntityToTlObject(v, this.#c.getEntity)) ?? []), quote_offset: params.replyTo.quote?.offset };
327
+ }
328
+ else {
329
+ return { _: "inputReplyToStory", peer: await this.#c.getInputPeer(params.replyTo.chatId), story_id: params.replyTo.storyId };
330
+ }
331
+ }
306
332
  async sendVenue(chatId, latitude, longitude, title, address, params) {
307
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
308
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
333
+ this.#checkParams(params);
334
+ const peer = await this.#c.getInputPeer(chatId);
309
335
  const randomId = getRandomId();
310
336
  const silent = params?.disableNotification ? true : undefined;
311
337
  const noforwards = params?.protectContent ? true : undefined;
312
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
313
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
314
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
338
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
339
+ const replyMarkup = await this.#constructReplyMarkup(params);
340
+ const result = await this.#c.invoke({
315
341
  _: "messages.sendMedia",
316
342
  peer,
317
343
  random_id: randomId,
318
344
  silent,
319
345
  noforwards,
320
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
346
+ reply_to: await this.#constructReplyTo(params),
321
347
  send_as: sendAs,
322
348
  reply_markup: replyMarkup,
323
349
  media: ({
@@ -342,20 +368,20 @@ export class MessageManager {
342
368
  return assertMessageType(message, "venue");
343
369
  }
344
370
  async sendContact(chatId, firstName, number, params) {
345
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
346
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
371
+ this.#checkParams(params);
372
+ const peer = await this.#c.getInputPeer(chatId);
347
373
  const randomId = getRandomId();
348
374
  const silent = params?.disableNotification ? true : undefined;
349
375
  const noforwards = params?.protectContent ? true : undefined;
350
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
351
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
352
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
376
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
377
+ const replyMarkup = await this.#constructReplyMarkup(params);
378
+ const result = await this.#c.invoke({
353
379
  _: "messages.sendMedia",
354
380
  peer,
355
381
  random_id: randomId,
356
382
  silent,
357
383
  noforwards,
358
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
384
+ reply_to: await this.#constructReplyTo(params),
359
385
  send_as: sendAs,
360
386
  reply_markup: replyMarkup,
361
387
  media: ({
@@ -374,20 +400,20 @@ export class MessageManager {
374
400
  return assertMessageType(message, "contact");
375
401
  }
376
402
  async sendDice(chatId, params) {
377
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
378
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
403
+ this.#checkParams(params);
404
+ const peer = await this.#c.getInputPeer(chatId);
379
405
  const randomId = getRandomId();
380
406
  const silent = params?.disableNotification ? true : undefined;
381
407
  const noforwards = params?.protectContent ? true : undefined;
382
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
383
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
384
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
408
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
409
+ const replyMarkup = await this.#constructReplyMarkup(params);
410
+ const result = await this.#c.invoke({
385
411
  _: "messages.sendMedia",
386
412
  peer,
387
413
  random_id: randomId,
388
414
  silent,
389
415
  noforwards,
390
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
416
+ reply_to: await this.#constructReplyTo(params),
391
417
  send_as: sendAs,
392
418
  reply_markup: replyMarkup,
393
419
  media: ({
@@ -403,20 +429,20 @@ export class MessageManager {
403
429
  return assertMessageType(message, "dice");
404
430
  }
405
431
  async sendLocation(chatId, latitude, longitude, params) {
406
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
407
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
432
+ this.#checkParams(params);
433
+ const peer = await this.#c.getInputPeer(chatId);
408
434
  const randomId = getRandomId();
409
435
  const silent = params?.disableNotification ? true : undefined;
410
436
  const noforwards = params?.protectContent ? true : undefined;
411
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
412
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
413
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
437
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
438
+ const replyMarkup = await this.#constructReplyMarkup(params);
439
+ const result = await this.#c.invoke({
414
440
  _: "messages.sendMedia",
415
441
  peer,
416
442
  random_id: randomId,
417
443
  silent,
418
444
  noforwards,
419
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
445
+ reply_to: await this.#constructReplyTo(params),
420
446
  send_as: sendAs,
421
447
  reply_markup: replyMarkup,
422
448
  media: params?.livePeriod !== undefined
@@ -450,53 +476,95 @@ export class MessageManager {
450
476
  return assertMessageType(message, "location");
451
477
  }
452
478
  async sendVideoNote(chatId, audio, params) {
453
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
454
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, audio, params, FileType.VideoNote, [
479
+ this.#checkParams(params);
480
+ const message = await this.#sendDocumentInner(chatId, audio, params, FileType.VideoNote, [
455
481
  { _: "documentAttributeVideo", round_message: true, w: params?.length ?? 0, h: params?.length ?? 0, duration: params?.duration ?? 0 },
456
482
  ], false);
457
483
  return assertMessageType(message, "videoNote");
458
484
  }
459
485
  async sendAudio(chatId, audio, params) {
460
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
461
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, audio, params, FileType.Audio, [
486
+ this.#checkParams(params);
487
+ const message = await this.#sendDocumentInner(chatId, audio, params, FileType.Audio, [
462
488
  { _: "documentAttributeAudio", duration: params?.duration ?? 0, performer: params?.performer, title: params?.title },
463
489
  ]);
464
490
  return assertMessageType(message, "audio");
465
491
  }
466
492
  async sendVoice(chatId, voice, params) {
467
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
468
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, voice, params, FileType.VoiceNote, [
493
+ this.#checkParams(params);
494
+ const message = await this.#sendDocumentInner(chatId, voice, params, FileType.VoiceNote, [
469
495
  { _: "documentAttributeAudio", voice: true, duration: params?.duration ?? 0 },
470
496
  ]);
471
497
  return assertMessageType(message, "voice");
472
498
  }
473
499
  async sendAnimation(chatId, animation, params) {
474
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
475
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, animation, params, FileType.Animation, [
500
+ this.#checkParams(params);
501
+ const message = await this.#sendDocumentInner(chatId, animation, params, FileType.Animation, [
476
502
  { _: "documentAttributeAnimated" },
477
503
  { _: "documentAttributeVideo", supports_streaming: true, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
478
504
  ]);
479
505
  return assertMessageType(message, "animation");
480
506
  }
481
507
  async sendVideo(chatId, video, params) {
482
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
483
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, video, params, FileType.Video, [
508
+ this.#checkParams(params);
509
+ const message = await this.#sendDocumentInner(chatId, video, params, FileType.Video, [
484
510
  { _: "documentAttributeVideo", supports_streaming: params?.supportsStreaming ? true : undefined, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
485
511
  ]);
486
512
  return assertMessageType(message, "video");
487
513
  }
514
+ async #sendDocumentInner(chatId, document, params, fileType, otherAttribs, urlSupported = true, expectedMimeTypes) {
515
+ let media = null;
516
+ const spoiler = params?.hasSpoiler ? true : undefined;
517
+ const ttl_seconds = params && "selfDestruct" in params && typeof params.selfDestruct !== undefined ? selfDestructOptionToInt(params.selfDestruct) : undefined;
518
+ if (typeof document === "string") {
519
+ const fileId = this.resolveFileId(document, fileType);
520
+ if (fileId != null) {
521
+ media = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => Api.is("documentAttributeSticker", v))?.alt || undefined, ttl_seconds };
522
+ }
523
+ }
524
+ if (media == null) {
525
+ if (typeof document === "string" && isHttpUrl(document)) {
526
+ if (!urlSupported) {
527
+ throw new InputError("URL not supported.");
528
+ }
529
+ media = { _: "inputMediaDocumentExternal", url: document, spoiler, ttl_seconds };
530
+ }
531
+ else {
532
+ let mimeType;
533
+ const file = await this.#c.fileManager.upload(document, params, (name) => {
534
+ mimeType = params?.mimeType ?? contentType(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
535
+ if (expectedMimeTypes && !expectedMimeTypes.includes(mimeType)) {
536
+ unreachable();
537
+ }
538
+ if (name.endsWith(".tgs") && fileType == FileType.Document) {
539
+ name += "-";
540
+ }
541
+ return name;
542
+ });
543
+ if (Api.is("inputFileStoryDocument", file)) {
544
+ unreachable();
545
+ }
546
+ let thumb = undefined;
547
+ if (params?.thumbnail) {
548
+ thumb = await this.#c.fileManager.upload(params.thumbnail, { chunkSize: params?.chunkSize, signal: params?.signal });
549
+ }
550
+ media = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == FileType.Document ? true : undefined, ttl_seconds };
551
+ }
552
+ }
553
+ const message = await this.#sendMedia(chatId, media, params);
554
+ return message;
555
+ }
488
556
  async sendDocument(chatId, document, params) {
489
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
490
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, document, params, FileType.Document, []);
557
+ this.#checkParams(params);
558
+ const message = await this.#sendDocumentInner(chatId, document, params, FileType.Document, []);
491
559
  return assertMessageType(message, "document");
492
560
  }
493
561
  async sendSticker(chatId, sticker, params) {
494
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
495
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, sticker, params, FileType.Sticker, [{ _: "documentAttributeSticker", alt: params?.emoji || "", stickerset: { _: "inputStickerSetEmpty" } }], undefined, STICKER_MIME_TYPES);
562
+ this.#checkParams(params);
563
+ const message = await this.#sendDocumentInner(chatId, sticker, params, FileType.Sticker, [{ _: "documentAttributeSticker", alt: params?.emoji || "", stickerset: { _: "inputStickerSetEmpty" } }], undefined, STICKER_MIME_TYPES);
496
564
  return assertMessageType(message, "sticker");
497
565
  }
498
566
  async sendPhoto(chatId, photo, params) {
499
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
567
+ this.#checkParams(params);
500
568
  let media = null;
501
569
  const spoiler = params?.hasSpoiler ? true : undefined;
502
570
  const ttl_seconds = params && "selfDestruct" in params && params.selfDestruct !== undefined ? selfDestructOptionToInt(params.selfDestruct) : undefined;
@@ -511,13 +579,48 @@ export class MessageManager {
511
579
  media = { _: "inputMediaPhotoExternal", url: photo, spoiler, ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? selfDestructOptionToInt(params.selfDestruct) : undefined };
512
580
  }
513
581
  else {
514
- const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(photo, params, null, false);
582
+ const file = await this.#c.fileManager.upload(photo, params, null, false);
515
583
  media = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? selfDestructOptionToInt(params.selfDestruct) : undefined };
516
584
  }
517
585
  }
518
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendMedia).call(this, chatId, media, params);
586
+ const message = await this.#sendMedia(chatId, media, params);
519
587
  return assertMessageType(message, "photo");
520
588
  }
589
+ async #sendMedia(chatId, media, params) {
590
+ if (params?.starCount !== undefined) {
591
+ if (params.starCount <= 0) {
592
+ throw new InputError("starCount cannot be zero or negative");
593
+ }
594
+ media = { _: "inputMediaPaidMedia", stars_amount: BigInt(params.starCount), extended_media: [media] };
595
+ }
596
+ const peer = await this.#c.getInputPeer(chatId);
597
+ const randomId = getRandomId();
598
+ const silent = params?.disableNotification ? true : undefined;
599
+ const noforwards = params?.protectContent ? true : undefined;
600
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
601
+ const replyMarkup = await this.#constructReplyMarkup(params);
602
+ const caption_ = params?.caption;
603
+ const parseResult = caption_ !== undefined ? await this.parseText(caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
604
+ const caption = parseResult === undefined ? undefined : parseResult[0];
605
+ const captionEntities = parseResult === undefined ? undefined : parseResult[1];
606
+ const result = await this.#c.invoke({
607
+ _: "messages.sendMedia",
608
+ peer,
609
+ random_id: randomId,
610
+ silent,
611
+ noforwards,
612
+ reply_markup: replyMarkup,
613
+ reply_to: await this.#constructReplyTo(params),
614
+ send_as: sendAs,
615
+ media,
616
+ message: caption ?? "",
617
+ entities: captionEntities,
618
+ effect: params?.effectId ? BigInt(params.effectId) : undefined,
619
+ schedule_date: params?.sendAt,
620
+ allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
621
+ }, { businessConnectionId: params?.businessConnectionId });
622
+ return (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
623
+ }
521
624
  resolveFileId(maybeFileId, expectedFileType) {
522
625
  expectedFileType = Array.isArray(expectedFileType) ? expectedFileType : [expectedFileType];
523
626
  let fileId = null;
@@ -525,7 +628,7 @@ export class MessageManager {
525
628
  fileId = deserializeFileId(maybeFileId);
526
629
  }
527
630
  catch (err) {
528
- __classPrivateFieldGet(this, _MessageManager_LresolveFileId, "f").warning(err);
631
+ this.#LresolveFileId.warning(err);
529
632
  }
530
633
  if (fileId != null) {
531
634
  if (!expectedFileType.includes(fileId.type)) {
@@ -540,7 +643,7 @@ export class MessageManager {
540
643
  return null;
541
644
  }
542
645
  async sendPoll(chatId, question, options, params) {
543
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
646
+ this.#checkParams(params);
544
647
  question = question?.trim();
545
648
  if (!question) {
546
649
  throw new Error("Question must not be empty.");
@@ -548,12 +651,12 @@ export class MessageManager {
548
651
  if (!Array.isArray(options) || options.length < 2) {
549
652
  throw new Error("There must be at least two options.");
550
653
  }
551
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
654
+ const peer = await this.#c.getInputPeer(chatId);
552
655
  const randomId = getRandomId();
553
656
  const silent = params?.disableNotification ? true : undefined;
554
657
  const noforwards = params?.protectContent ? true : undefined;
555
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
556
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
658
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
659
+ const replyMarkup = await this.#constructReplyMarkup(params);
557
660
  const explanation = params?.explanation;
558
661
  const parseResult = explanation !== undefined ? await this.parseText(explanation, { parseMode: params?.explanationParseMode, entities: params?.explanationEntities }) : undefined;
559
662
  const solution = parseResult === undefined ? undefined : parseResult[0];
@@ -567,14 +670,14 @@ export class MessageManager {
567
670
  const questionParseResult = await this.parseText(question, { parseMode: params?.questionParseMode, entities: params?.questionEntities });
568
671
  const poll = { _: "poll", id: getRandomId(), answers, question: { _: "textWithEntities", text: questionParseResult[0], entities: questionParseResult[1] ?? [] }, closed: params?.isClosed ? true : undefined, close_date: params?.closeDate, close_period: params?.openPeriod ? params.openPeriod : undefined, multiple_choice: params?.allowMultipleAnswers ? true : undefined, public_voters: params?.isAnonymous === false ? true : undefined, quiz: params?.type == "quiz" ? true : undefined };
569
672
  const media = { _: "inputMediaPoll", poll, correct_answers: params?.correctOptionIndex !== undefined ? [encodeText(String(params.correctOptionIndex))] : undefined, solution, solution_entities: solutionEntities };
570
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
673
+ const result = await this.#c.invoke({
571
674
  _: "messages.sendMedia",
572
675
  peer,
573
676
  random_id: randomId,
574
677
  silent,
575
678
  noforwards,
576
679
  reply_markup: replyMarkup,
577
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
680
+ reply_to: await this.#constructReplyTo(params),
578
681
  send_as: sendAs,
579
682
  media,
580
683
  message: "",
@@ -586,26 +689,26 @@ export class MessageManager {
586
689
  return assertMessageType(message, "poll");
587
690
  }
588
691
  async editMessageReplyMarkup(chatId, messageId, params) {
589
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
590
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
692
+ this.#checkParams(params);
693
+ const result = await this.#c.invoke({
591
694
  _: "messages.editMessage",
592
695
  id: checkMessageId(messageId),
593
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
594
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
696
+ peer: await this.#c.getInputPeer(chatId),
697
+ reply_markup: await this.#constructReplyMarkup(params),
595
698
  }, { businessConnectionId: params?.businessConnectionId });
596
699
  const message_ = (await this.updatesToMessages(chatId, result))[0];
597
700
  return message_;
598
701
  }
599
702
  async editInlineMessageReplyMarkup(inlineMessageId, params) {
600
703
  const id = await deserializeInlineMessageId(inlineMessageId);
601
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
704
+ await this.#c.invoke({
602
705
  _: "messages.editInlineBotMessage",
603
706
  id,
604
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
707
+ reply_markup: await this.#constructReplyMarkup(params),
605
708
  }, { dc: getDc(id.dc_id) });
606
709
  }
607
710
  async editMessageText(chatId, messageId, text, params) {
608
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
711
+ this.#checkParams(params);
609
712
  {
610
713
  const message = await this.getMessage(chatId, messageId);
611
714
  if (!message) {
@@ -628,27 +731,28 @@ export class MessageManager {
628
731
  if (!noWebpage && params?.linkPreview?.url) {
629
732
  media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.largeMedia ? true : undefined, force_small_media: params.linkPreview.smallMedia ? true : undefined, optional: message.length ? undefined : true };
630
733
  }
631
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
734
+ const result = await this.#c.invoke({
632
735
  _: "messages.editMessage",
633
736
  id: checkMessageId(messageId),
634
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
737
+ peer: await this.#c.getInputPeer(chatId),
635
738
  entities,
636
739
  message,
637
740
  media,
638
741
  no_webpage: noWebpage,
639
742
  invert_media: invertMedia,
640
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
743
+ reply_markup: await this.#constructReplyMarkup(params),
641
744
  }, { businessConnectionId: params?.businessConnectionId });
642
745
  const message_ = (await this.updatesToMessages(chatId, result))[0];
643
746
  return assertMessageType(message_, "text");
644
747
  }
748
+ static #CAPTIONABLE_MESSAGE_TYPES = ["photo", "document", "video", "animation", "voice", "audio", "video"];
645
749
  async editMessageCaption(chatId, messageId, params) {
646
750
  let canHaveCaption = false;
647
751
  const message_ = await this.getMessage(chatId, messageId);
648
752
  if (!message_) {
649
753
  throw new InputError("Message not found.");
650
754
  }
651
- for (const type of __classPrivateFieldGet(_a, _a, "f", _MessageManager_CAPTIONABLE_MESSAGE_TYPES)) {
755
+ for (const type of MessageManager.#CAPTIONABLE_MESSAGE_TYPES) {
652
756
  if (isMessageType(message_, type)) {
653
757
  canHaveCaption = true;
654
758
  }
@@ -657,24 +761,133 @@ export class MessageManager {
657
761
  throw new InputError("The referenced message cannot have a caption.");
658
762
  }
659
763
  const [message, entities] = await this.parseText(params?.caption ?? "", params);
660
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
764
+ const result = await this.#c.invoke({
661
765
  _: "messages.editMessage",
662
766
  id: checkMessageId(messageId),
663
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
767
+ peer: await this.#c.getInputPeer(chatId),
664
768
  entities: message ? entities : [],
665
769
  message,
666
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
770
+ reply_markup: await this.#constructReplyMarkup(params),
667
771
  }, { businessConnectionId: params?.businessConnectionId });
668
772
  return (await this.updatesToMessages(chatId, result))[0];
669
773
  }
774
+ async #editInlineMessageTextInner(inlineMessageId, text, params, allowEmpty = true) {
775
+ this.#checkParams(params);
776
+ const [message, entities] = await this.parseText(text, params);
777
+ if (!allowEmpty && !message) {
778
+ throw new InputError("Message text cannot be empty.");
779
+ }
780
+ const id = await deserializeInlineMessageId(inlineMessageId);
781
+ if (params?.linkPreview && params.linkPreview.type != "input") {
782
+ throw new InputError("Expected link preview of type input.");
783
+ }
784
+ const noWebpage = params?.linkPreview && params.linkPreview.type == "input" && params.linkPreview.disable ? true : undefined;
785
+ const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
786
+ let media = undefined;
787
+ if (!noWebpage && params?.linkPreview?.url) {
788
+ media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.largeMedia ? true : undefined, force_small_media: params.linkPreview.smallMedia ? true : undefined, optional: message.length ? undefined : true };
789
+ }
790
+ await this.#c.invoke({
791
+ _: "messages.editInlineBotMessage",
792
+ id,
793
+ entities,
794
+ message,
795
+ media,
796
+ no_webpage: noWebpage,
797
+ invert_media: invertMedia,
798
+ reply_markup: await this.#constructReplyMarkup(params),
799
+ }, { dc: getDc(id.dc_id) });
800
+ }
670
801
  async editInlineMessageText(inlineMessageId, text, params) {
671
- await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_editInlineMessageTextInner).call(this, inlineMessageId, text, params, false);
802
+ await this.#editInlineMessageTextInner(inlineMessageId, text, params, false);
672
803
  }
673
804
  async editInlineMessageCaption(inlineMessageId, params) {
674
- await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_editInlineMessageTextInner).call(this, inlineMessageId, params?.caption ?? "", params);
805
+ await this.#editInlineMessageTextInner(inlineMessageId, params?.caption ?? "", params);
806
+ }
807
+ async #resolveInputMediaInner(document, media, fileType, otherAttribs) {
808
+ let media_ = null;
809
+ const spoiler = "hasSpoiler" in media && media.hasSpoiler ? true : undefined;
810
+ if (typeof document === "string") {
811
+ const fileId = this.resolveFileId(document, fileType);
812
+ if (fileId != null) {
813
+ media_ = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => Api.is("documentAttributeSticker", v))?.alt || undefined };
814
+ }
815
+ }
816
+ if (media_ == null) {
817
+ if (typeof document === "string" && isHttpUrl(document)) {
818
+ media_ = { _: "inputMediaDocumentExternal", url: document, spoiler };
819
+ }
820
+ else {
821
+ let mimeType;
822
+ const file = await this.#c.fileManager.upload(document, media, (name) => {
823
+ mimeType = media?.mimeType ?? contentType(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
824
+ if (name.endsWith(".tgs") && fileType == FileType.Document) {
825
+ name += "-";
826
+ }
827
+ return name;
828
+ });
829
+ if (Api.is("inputFileStoryDocument", file)) {
830
+ unreachable();
831
+ }
832
+ let thumb = undefined;
833
+ if ("thumbnail" in media && media.thumbnail) {
834
+ thumb = await this.#c.fileManager.upload(media.thumbnail, { chunkSize: media?.chunkSize, signal: media?.signal });
835
+ }
836
+ media_ = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == FileType.Document ? true : undefined };
837
+ }
838
+ }
839
+ return media_;
840
+ }
841
+ async #resolveInputMedia(media) {
842
+ if ("animation" in media) {
843
+ return await this.#resolveInputMediaInner(media.animation, media, FileType.Animation, [
844
+ { _: "documentAttributeAnimated" },
845
+ { _: "documentAttributeVideo", supports_streaming: true, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
846
+ ]);
847
+ }
848
+ else if ("audio" in media) {
849
+ return await this.#resolveInputMediaInner(media.audio, media, FileType.Audio, [
850
+ { _: "documentAttributeAudio", duration: media?.duration ?? 0, performer: media?.performer, title: media?.title },
851
+ ]);
852
+ }
853
+ else if ("document" in media) {
854
+ return await this.#resolveInputMediaInner(media.document, media, FileType.Document, []);
855
+ }
856
+ else if ("photo" in media) {
857
+ let media_ = null;
858
+ const spoiler = media.hasSpoiler ? true : undefined;
859
+ const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? selfDestructOptionToInt(media.selfDestruct) : undefined;
860
+ if (typeof media.photo === "string") {
861
+ const fileId = this.resolveFileId(media.photo, [FileType.Photo, FileType.ProfilePhoto]);
862
+ if (fileId != null) {
863
+ media_ = { _: "inputMediaPhoto", id: { ...fileId, _: "inputPhoto" }, spoiler, ttl_seconds };
864
+ }
865
+ }
866
+ if (media_ == null) {
867
+ if (typeof media.photo === "string" && isHttpUrl(media.photo)) {
868
+ media_ = { _: "inputMediaPhotoExternal", url: media.photo, spoiler };
869
+ }
870
+ else {
871
+ const file = await this.#c.fileManager.upload(media.photo, media, null, false);
872
+ media_ = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds };
873
+ }
874
+ }
875
+ return media_;
876
+ }
877
+ else if ("video" in media) {
878
+ const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? selfDestructOptionToInt(media.selfDestruct) : undefined;
879
+ const media_ = await this.#resolveInputMediaInner(media.video, media, FileType.Video, [
880
+ { _: "documentAttributeVideo", supports_streaming: media?.supportsStreaming ? true : undefined, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
881
+ ]);
882
+ media_.ttl_seconds = ttl_seconds;
883
+ return media_;
884
+ }
885
+ else {
886
+ unreachable();
887
+ }
675
888
  }
676
889
  async editMessageMedia(chatId, messageId, media, params) {
677
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
890
+ this.#checkParams(params);
678
891
  const message = await this.getMessage(chatId, messageId);
679
892
  if (!message) {
680
893
  throw new InputError("Message not found.");
@@ -683,12 +896,12 @@ export class MessageManager {
683
896
  throw new InputError("Unexpected message type.");
684
897
  }
685
898
  const [text, entities] = media.caption !== undefined ? await this.parseText(media.caption, { entities: media.captionEntities, parseMode: media.parseMode }) : ["", []];
686
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
899
+ const result = await this.#c.invoke({
687
900
  _: "messages.editMessage",
688
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
901
+ peer: await this.#c.getInputPeer(chatId),
689
902
  id: messageId,
690
- media: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMedia).call(this, media),
691
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
903
+ media: await this.#resolveInputMedia(media),
904
+ reply_markup: await this.#constructReplyMarkup(params),
692
905
  message: text,
693
906
  entities,
694
907
  }, { businessConnectionId: params?.businessConnectionId });
@@ -696,66 +909,69 @@ export class MessageManager {
696
909
  return message_;
697
910
  }
698
911
  async editInlineMessageMedia(inlineMessageId, media, params) {
699
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
700
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageMedia");
912
+ this.#checkParams(params);
913
+ this.#c.storage.assertBot("editInlineMessageMedia");
701
914
  const id = await deserializeInlineMessageId(inlineMessageId);
702
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
915
+ await this.#c.invoke({
703
916
  _: "messages.editInlineBotMessage",
704
917
  id,
705
- media: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMedia).call(this, media),
706
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
918
+ media: await this.#resolveInputMedia(media),
919
+ reply_markup: await this.#constructReplyMarkup(params),
707
920
  }, { dc: getDc(id.dc_id) });
708
921
  }
709
922
  async deleteMessages(chatId, messageIds, params) {
710
923
  checkArray(messageIds, checkMessageId);
711
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
924
+ const peer = await this.#c.getInputPeer(chatId);
712
925
  if (canBeInputChannel(peer)) {
713
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.deleteMessages", channel: toInputChannel(peer), id: messageIds });
926
+ await this.#c.invoke({ _: "channels.deleteMessages", channel: toInputChannel(peer), id: messageIds });
714
927
  }
715
928
  else {
716
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.deleteMessages", id: messageIds, revoke: params?.onlyForMe ? undefined : true });
929
+ await this.#c.invoke({ _: "messages.deleteMessages", id: messageIds, revoke: params?.onlyForMe ? undefined : true });
717
930
  }
718
931
  }
719
932
  async deleteScheduledMessages(chatId, messageIds) {
720
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessage");
933
+ this.#c.storage.assertUser("sendScheduledMessage");
721
934
  checkArray(messageIds, checkMessageId);
722
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
723
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.deleteScheduledMessages", peer, id: messageIds });
935
+ const peer = await this.#c.getInputPeer(chatId);
936
+ await this.#c.invoke({ _: "messages.deleteScheduledMessages", peer, id: messageIds });
724
937
  }
725
938
  async deleteScheduledMessage(chatId, messageId) {
726
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("deleteScheduledMessage");
939
+ this.#c.storage.assertUser("deleteScheduledMessage");
727
940
  return await this.deleteScheduledMessages(chatId, [messageId]);
728
941
  }
729
942
  async sendScheduledMessages(chatId, messageIds) {
730
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessages");
943
+ this.#c.storage.assertUser("sendScheduledMessages");
731
944
  checkArray(messageIds, checkMessageId);
732
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
733
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.sendScheduledMessages", peer, id: messageIds });
945
+ const peer = await this.#c.getInputPeer(chatId);
946
+ const result = await this.#c.invoke({ _: "messages.sendScheduledMessages", peer, id: messageIds });
734
947
  return await this.updatesToMessages(chatId, result);
735
948
  }
736
949
  async sendScheduledMessage(chatId, messageId) {
737
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessage");
950
+ this.#c.storage.assertUser("sendScheduledMessage");
738
951
  return (await this.sendScheduledMessages(chatId, [messageId]))[0];
739
952
  }
740
953
  async deleteChatMemberMessages(chatId, memberId) {
741
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("deleteChatMemberMessages");
742
- const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
743
- const participant = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(memberId);
744
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.deleteParticipantHistory", channel, participant });
954
+ this.#c.storage.assertUser("deleteChatMemberMessages");
955
+ const channel = await this.#c.getInputChannel(chatId);
956
+ const participant = await this.#c.getInputPeer(memberId);
957
+ await this.#c.invoke({ _: "channels.deleteParticipantHistory", channel, participant });
745
958
  }
746
959
  async pinMessage(chatId, messageId, params) {
747
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
748
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.updatePinnedMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: checkMessageId(messageId), silent: params?.disableNotification ? true : undefined, pm_oneside: params?.bothSides ? undefined : true });
960
+ this.#checkParams(params);
961
+ await this.#c.invoke({ _: "messages.updatePinnedMessage", peer: await this.#c.getInputPeer(chatId), id: checkMessageId(messageId), silent: params?.disableNotification ? true : undefined, pm_oneside: params?.bothSides ? undefined : true });
749
962
  }
750
963
  async unpinMessage(chatId, messageId, params) {
751
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
752
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.updatePinnedMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: checkMessageId(messageId), unpin: true }, { businessConnectionId: params?.businessConnectionId });
964
+ this.#checkParams(params);
965
+ await this.#c.invoke({ _: "messages.updatePinnedMessage", peer: await this.#c.getInputPeer(chatId), id: checkMessageId(messageId), unpin: true }, { businessConnectionId: params?.businessConnectionId });
753
966
  }
754
967
  async unpinMessages(chatId) {
755
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.unpinAllMessages", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId) });
968
+ await this.#c.invoke({ _: "messages.unpinAllMessages", peer: await this.#c.getInputPeer(chatId) });
969
+ }
970
+ async #sendReaction(chatId, messageId, reactions, params) {
971
+ await this.#c.invoke({ _: "messages.sendReaction", peer: await this.#c.getInputPeer(chatId), msg_id: checkMessageId(messageId), reaction: reactions.map((v) => reactionToTlObject(v)), big: params?.big ? true : undefined, add_to_recent: params?.addToRecents ? true : undefined });
756
972
  }
757
973
  async setReactions(chatId, messageId, reactions, params) {
758
- await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendReaction).call(this, chatId, messageId, reactions, params);
974
+ await this.#sendReaction(chatId, messageId, reactions, params);
759
975
  }
760
976
  async addReaction(chatId, messageId, reaction, params) {
761
977
  const message = await this.getMessage(chatId, messageId);
@@ -792,7 +1008,7 @@ export class MessageManager {
792
1008
  if (Api.is("updateNewMessage", update) || Api.is("updateNewChannelMessage", update) || Api.is("updateEditMessage", update) || Api.is("updateEditChannelMessage", update)) {
793
1009
  if (Api.is("message", update.message) || Api.is("messageService", update.message)) {
794
1010
  const chatId = Api.peerToChatId(update.message.peer_id);
795
- await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.setMessage(chatId, update.message.id, update.message);
1011
+ await this.#c.messageStorage.setMessage(chatId, update.message.id, update.message);
796
1012
  }
797
1013
  }
798
1014
  if (Api.isOneOf([
@@ -808,13 +1024,13 @@ export class MessageManager {
808
1024
  const isOutgoing = update.message.out;
809
1025
  let shouldIgnore = false;
810
1026
  if (isOutgoing) {
811
- if (__classPrivateFieldGet(this, _MessageManager_c, "f").outgoingMessages == null) {
812
- __classPrivateFieldGet(this, _MessageManager_c, "f").outgoingMessages = __classPrivateFieldGet(this, _MessageManager_c, "f").storage.accountType == "user" ? "all" : "business";
1027
+ if (this.#c.outgoingMessages == null) {
1028
+ this.#c.outgoingMessages = this.#c.storage.accountType == "user" ? "all" : "business";
813
1029
  }
814
- if (__classPrivateFieldGet(this, _MessageManager_c, "f").outgoingMessages == "none") {
1030
+ if (this.#c.outgoingMessages == "none") {
815
1031
  shouldIgnore = true;
816
1032
  }
817
- else if (__classPrivateFieldGet(this, _MessageManager_c, "f").outgoingMessages == "business") {
1033
+ else if (this.#c.outgoingMessages == "business") {
818
1034
  if (!Api.is("updateBotNewBusinessMessage", update) && !Api.is("updateBotEditBusinessMessage", update)) {
819
1035
  shouldIgnore = true;
820
1036
  }
@@ -839,7 +1055,7 @@ export class MessageManager {
839
1055
  if (Api.is("updateDeleteMessages", update)) {
840
1056
  const deletedMessages = new Array();
841
1057
  for (const messageId of update.messages) {
842
- const chatId = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getMessageChat(messageId);
1058
+ const chatId = await this.#c.messageStorage.getMessageChat(messageId);
843
1059
  if (chatId) {
844
1060
  deletedMessages.push({ chatId, messageId });
845
1061
  }
@@ -852,7 +1068,7 @@ export class MessageManager {
852
1068
  const chatId = Api.getChannelChatId(update.channel_id);
853
1069
  const deletedMessages = new Array();
854
1070
  for (const messageId of update.messages) {
855
- const message = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getMessage(chatId, messageId);
1071
+ const message = await this.#c.messageStorage.getMessage(chatId, messageId);
856
1072
  if (message != null) {
857
1073
  deletedMessages.push({ chatId, messageId });
858
1074
  }
@@ -871,13 +1087,13 @@ export class MessageManager {
871
1087
  }
872
1088
  if (Api.is("updateTranscribedAudio", update)) {
873
1089
  const voiceTranscription = constructVoiceTranscription(update);
874
- await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.setVoiceTranscription(voiceTranscription);
1090
+ await this.#c.messageStorage.setVoiceTranscription(voiceTranscription);
875
1091
  return { voiceTranscription };
876
1092
  }
877
1093
  return null;
878
1094
  }
879
1095
  async sendChatAction(chatId, action, params) {
880
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1096
+ this.#checkParams(params);
881
1097
  let action_;
882
1098
  switch (action) {
883
1099
  case "type":
@@ -916,11 +1132,11 @@ export class MessageManager {
916
1132
  default:
917
1133
  throw new InputError(`Invalid chat action: ${action}`);
918
1134
  }
919
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.setTyping", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId }, { businessConnectionId: params?.businessConnectionId });
1135
+ await this.#c.invoke({ _: "messages.setTyping", peer: await this.#c.getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId }, { businessConnectionId: params?.businessConnectionId });
920
1136
  }
921
1137
  async searchMessages(chatId, query, params) {
922
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("searchMessages");
923
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.search", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), q: query, add_offset: 0, filter: messageSearchFilterToTlObject(params?.filter ?? "empty"), hash: 0n, limit: getLimit(params?.limit), max_date: 0, max_id: 0, min_date: 0, min_id: 0, offset_id: params?.after ? params.after : 0, from_id: params?.from ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.from) : undefined });
1138
+ this.#c.storage.assertUser("searchMessages");
1139
+ const result = await this.#c.invoke({ _: "messages.search", peer: await this.#c.getInputPeer(chatId), q: query, add_offset: 0, filter: messageSearchFilterToTlObject(params?.filter ?? "empty"), hash: 0n, limit: getLimit(params?.limit), max_date: 0, max_id: 0, min_date: 0, min_id: 0, offset_id: params?.after ? params.after : 0, from_id: params?.from ? await this.#c.getInputPeer(params.from) : undefined });
924
1140
  if (!("messages" in result)) {
925
1141
  unreachable();
926
1142
  }
@@ -932,25 +1148,25 @@ export class MessageManager {
932
1148
  return messages;
933
1149
  }
934
1150
  async blockUser(userId) {
935
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("blockUser");
936
- const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
937
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "contacts.block", id });
1151
+ this.#c.storage.assertUser("blockUser");
1152
+ const id = await this.#c.getInputPeer(userId);
1153
+ await this.#c.invoke({ _: "contacts.block", id });
938
1154
  }
939
1155
  async unblockUser(userId) {
940
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("unblockUser");
941
- const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
942
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "contacts.unblock", id });
1156
+ this.#c.storage.assertUser("unblockUser");
1157
+ const id = await this.#c.getInputPeer(userId);
1158
+ await this.#c.invoke({ _: "contacts.unblock", id });
943
1159
  }
944
1160
  async setChatStickerSet(chatId, setName) {
945
- const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
946
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetShortName", short_name: setName } });
1161
+ const channel = await this.#c.getInputChannel(chatId);
1162
+ await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetShortName", short_name: setName } });
947
1163
  }
948
1164
  async deleteChatStickerSet(chatId) {
949
- const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
950
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
1165
+ const channel = await this.#c.getInputChannel(chatId);
1166
+ await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
951
1167
  }
952
1168
  async stopPoll(chatId, messageId, params) {
953
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1169
+ this.#checkParams(params);
954
1170
  const message = await this.getMessage(chatId, messageId);
955
1171
  if (!message) {
956
1172
  throw new InputError("Message not found.");
@@ -961,26 +1177,26 @@ export class MessageManager {
961
1177
  if (message.poll.isClosed) {
962
1178
  throw new InputError("Poll is already stopped.");
963
1179
  }
964
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1180
+ const result = await this.#c.invoke({
965
1181
  _: "messages.editMessage",
966
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
1182
+ peer: await this.#c.getInputPeer(chatId),
967
1183
  id: messageId,
968
1184
  media: ({ _: "inputMediaPoll", poll: ({ _: "poll", id: BigInt(message.poll.id), closed: true, question: { _: "textWithEntities", text: "", entities: [] }, answers: [] }) }),
969
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
1185
+ reply_markup: await this.#constructReplyMarkup(params),
970
1186
  }, { businessConnectionId: params?.businessConnectionId });
971
1187
  const message_ = (await this.updatesToMessages(chatId, result))[0];
972
1188
  return assertMessageType(message_, "poll").poll;
973
1189
  }
974
1190
  async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
975
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1191
+ this.#checkParams(params);
976
1192
  const message = await this.getMessage(chatId, messageId);
977
1193
  if (message && "location" in message && message.location.livePeriod) {
978
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1194
+ const result = await this.#c.invoke({
979
1195
  _: "messages.editMessage",
980
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
1196
+ peer: await this.#c.getInputPeer(chatId),
981
1197
  id: messageId,
982
1198
  media: ({ _: "inputMediaGeoLive", geo_point: ({ _: "inputGeoPoint", lat: latitude, long: longitude, accuracy_radius: params?.horizontalAccuracy }), heading: params?.heading, proximity_notification_radius: params?.proximityAlertRadius }),
983
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
1199
+ reply_markup: await this.#constructReplyMarkup(params),
984
1200
  }, { businessConnectionId: params?.businessConnectionId });
985
1201
  const message = (await this.updatesToMessages(chatId, result))[0];
986
1202
  return assertMessageType(message, "location");
@@ -988,19 +1204,19 @@ export class MessageManager {
988
1204
  unreachable();
989
1205
  }
990
1206
  async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
991
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
992
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageLiveLocation");
1207
+ this.#checkParams(params);
1208
+ this.#c.storage.assertBot("editInlineMessageLiveLocation");
993
1209
  const id = await deserializeInlineMessageId(inlineMessageId);
994
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1210
+ await this.#c.invoke({
995
1211
  _: "messages.editInlineBotMessage",
996
1212
  id,
997
1213
  media: ({ _: "inputMediaGeoLive", geo_point: ({ _: "inputGeoPoint", lat: latitude, long: longitude, accuracy_radius: params?.horizontalAccuracy }), heading: params?.heading, proximity_notification_radius: params?.proximityAlertRadius }),
998
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
1214
+ reply_markup: await this.#constructReplyMarkup(params),
999
1215
  }, { dc: getDc(id.dc_id) });
1000
1216
  }
1001
1217
  async sendInvoice(chatId, title, description, payload, currency, prices, params) {
1002
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("sendInvoice");
1003
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1218
+ this.#c.storage.assertBot("sendInvoice");
1219
+ this.#checkParams(params);
1004
1220
  if (title.length < 1) {
1005
1221
  throw new InputError("Invoice title cannot be empty.");
1006
1222
  }
@@ -1027,7 +1243,7 @@ export class MessageManager {
1027
1243
  phone_to_provider: params?.sendPhoneNumberToProvider || undefined,
1028
1244
  flexible: params?.flexible || undefined,
1029
1245
  };
1030
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendMedia).call(this, chatId, {
1246
+ const message = await this.#sendMedia(chatId, {
1031
1247
  _: "inputMediaInvoice",
1032
1248
  title,
1033
1249
  description,
@@ -1053,7 +1269,7 @@ export class MessageManager {
1053
1269
  return assertMessageType(message, "invoice");
1054
1270
  }
1055
1271
  async sendMediaGroup(chatId, media, params) {
1056
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1272
+ this.#checkParams(params);
1057
1273
  {
1058
1274
  if (!Array.isArray(media) || !media.length) {
1059
1275
  throw new InputError("Media group must not be empty.");
@@ -1079,25 +1295,25 @@ export class MessageManager {
1079
1295
  for (const v of media) {
1080
1296
  const randomId = getRandomId();
1081
1297
  const [message, entities] = v.caption !== undefined ? await this.parseText(v.caption, { entities: v.captionEntities, parseMode: v.parseMode }) : ["", []];
1082
- multiMedia.push({ _: "inputSingleMedia", message, entities, random_id: randomId, media: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMedia).call(this, v) });
1298
+ multiMedia.push({ _: "inputSingleMedia", message, entities, random_id: randomId, media: await this.#resolveInputMedia(v) });
1083
1299
  }
1084
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1300
+ const peer = await this.#c.getInputPeer(chatId);
1085
1301
  for (const [i, media_] of multiMedia.entries()) {
1086
1302
  if (Api.is("inputMediaUploadedPhoto", media_.media)) {
1087
- const result = Api.as("messageMediaPhoto", await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.uploadMedia", media: media_.media, peer }));
1303
+ const result = Api.as("messageMediaPhoto", await this.#c.invoke({ _: "messages.uploadMedia", media: media_.media, peer }));
1088
1304
  const photo = Api.as("photo", result.photo);
1089
1305
  multiMedia[i] = { ...media_, media: { _: "inputMediaPhoto", id: { ...photo, _: "inputPhoto" } } };
1090
1306
  }
1091
1307
  else if (Api.is("inputMediaUploadedDocument", media_.media)) {
1092
- const result = Api.as("messageMediaDocument", await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.uploadMedia", media: media_.media, peer }));
1308
+ const result = Api.as("messageMediaDocument", await this.#c.invoke({ _: "messages.uploadMedia", media: media_.media, peer }));
1093
1309
  const document = Api.as("document", result.document);
1094
1310
  multiMedia[i] = { ...media_, media: { _: "inputMediaDocument", id: { ...document, _: "inputDocument" } } };
1095
1311
  }
1096
1312
  }
1097
1313
  const silent = params?.disableNotification ? true : undefined;
1098
1314
  const noforwards = params?.protectContent ? true : undefined;
1099
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
1100
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1315
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
1316
+ const result = await this.#c.invoke({
1101
1317
  _: "messages.sendMultiMedia",
1102
1318
  peer,
1103
1319
  multi_media: multiMedia,
@@ -1105,19 +1321,19 @@ export class MessageManager {
1105
1321
  noforwards,
1106
1322
  silent,
1107
1323
  send_as: sendAs,
1108
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
1324
+ reply_to: await this.#constructReplyTo(params),
1109
1325
  allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
1110
1326
  });
1111
1327
  return await this.updatesToMessages(chatId, result);
1112
1328
  }
1113
1329
  async readMessages(chatId, untilMessageId) {
1114
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("readMessages");
1115
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1330
+ this.#c.storage.assertUser("readMessages");
1331
+ const peer = await this.#c.getInputPeer(chatId);
1116
1332
  const max_id = untilMessageId;
1117
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.readHistory", peer, max_id });
1333
+ await this.#c.invoke({ _: "messages.readHistory", peer, max_id });
1118
1334
  }
1119
1335
  async startBot(botId, params) {
1120
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("startBot");
1336
+ this.#c.storage.assertUser("startBot");
1121
1337
  const start_param = params?.deeplink?.trim() || "";
1122
1338
  if (params?.chatId !== undefined && !start_param) {
1123
1339
  throw new InputError("deeplink cannot be unspecified while chatId is specified.");
@@ -1125,13 +1341,13 @@ export class MessageManager {
1125
1341
  if (!params?.deeplink) {
1126
1342
  return await this.sendMessage(botId, "/start");
1127
1343
  }
1128
- const bot = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputUser(botId);
1129
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params?.chatId || botId);
1130
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.startBot", bot, peer, random_id: getRandomId(), start_param });
1344
+ const bot = await this.#c.getInputUser(botId);
1345
+ const peer = await this.#c.getInputPeer(params?.chatId || botId);
1346
+ const result = await this.#c.invoke({ _: "messages.startBot", bot, peer, random_id: getRandomId(), start_param });
1131
1347
  return (await this.updatesToMessages(botId, result))[0];
1132
1348
  }
1133
1349
  async transcribeVoice(chatId, messageId) {
1134
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("transcribeVoice");
1350
+ this.#c.storage.assertUser("transcribeVoice");
1135
1351
  const message = await this.getMessage(chatId, messageId);
1136
1352
  if (message == null) {
1137
1353
  throw new InputError("Message not found.");
@@ -1139,16 +1355,32 @@ export class MessageManager {
1139
1355
  if (!isMessageType(message, "voice")) {
1140
1356
  throw new InputError("Message not voice.");
1141
1357
  }
1142
- const cachedTranscription = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_getCachedVoiceTranscription).call(this, message);
1358
+ const cachedTranscription = await this.#getCachedVoiceTranscription(message);
1143
1359
  if (cachedTranscription) {
1144
1360
  return cachedTranscription;
1145
1361
  }
1146
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1147
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.transcribeAudio", peer, msg_id: messageId });
1148
- return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_cacheVoiceTranscription).call(this, message, constructVoiceTranscription(result));
1362
+ const peer = await this.#c.getInputPeer(chatId);
1363
+ const result = await this.#c.invoke({ _: "messages.transcribeAudio", peer, msg_id: messageId });
1364
+ return await this.#cacheVoiceTranscription(message, constructVoiceTranscription(result));
1365
+ }
1366
+ async #getCachedVoiceTranscription(message) {
1367
+ const reference = await this.#c.messageStorage.getVoiceTranscriptionReference(message.chat.id, message.id, fromUnixTimestamp(message.editDate ?? message.date));
1368
+ if (!reference) {
1369
+ return null;
1370
+ }
1371
+ const voiceTranscription = await this.#c.messageStorage.getVoiceTranscription(reference);
1372
+ if (!voiceTranscription || !voiceTranscription.done) {
1373
+ return null;
1374
+ }
1375
+ return voiceTranscription;
1376
+ }
1377
+ async #cacheVoiceTranscription(message, voiceTranscription) {
1378
+ await this.#c.messageStorage.setVoiceTranscriptionReference(message.chat.id, message.id, fromUnixTimestamp(message.editDate ?? message.date), BigInt(voiceTranscription.id));
1379
+ await this.#c.messageStorage.setVoiceTranscription(voiceTranscription);
1380
+ return voiceTranscription;
1149
1381
  }
1150
1382
  async resolveMessageLink(link) {
1151
- const parseResult = _a.parseMessageLink(link);
1383
+ const parseResult = MessageManager.parseMessageLink(link);
1152
1384
  if (parseResult == null) {
1153
1385
  throw new InputError("Invalid messsage link.");
1154
1386
  }
@@ -1235,20 +1467,20 @@ export class MessageManager {
1235
1467
  return [peer, id];
1236
1468
  }
1237
1469
  async openMiniApp(botId, chatId, params) {
1238
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("openMiniApp");
1470
+ this.#c.storage.assertUser("openMiniApp");
1239
1471
  const from_bot_menu = params?.fromMenu ? true : undefined;
1240
1472
  const silent = params?.disableNotification ? true : undefined;
1241
1473
  const compact = params?.mode === "compact" ? true : undefined;
1242
1474
  const fullscreen = params?.mode === "fullscreen" ? true : undefined;
1243
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1244
- const bot = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputUser(botId);
1475
+ const peer = await this.#c.getInputPeer(chatId);
1476
+ const bot = await this.#c.getInputUser(botId);
1245
1477
  const url = params?.url;
1246
1478
  const start_param = params?.startParameter;
1247
1479
  const theme_params = params?.themeParameters ? { _: "dataJSON", data: params.themeParameters } : undefined;
1248
- const platform = __classPrivateFieldGet(this, _MessageManager_c, "f").langPack ?? "";
1249
- const reply_to = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params);
1250
- const send_as = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
1251
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1480
+ const platform = this.#c.langPack ?? "";
1481
+ const reply_to = await this.#constructReplyTo(params);
1482
+ const send_as = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
1483
+ const result = await this.#c.invoke({
1252
1484
  _: "messages.requestWebView",
1253
1485
  from_bot_menu,
1254
1486
  silent,
@@ -1266,242 +1498,3 @@ export class MessageManager {
1266
1498
  return constructMiniAppInfo(result);
1267
1499
  }
1268
1500
  }
1269
- _a = MessageManager, _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_checkParams = function _MessageManager_checkParams(params) {
1270
- if (params && "replyMarkup" in params && params.replyMarkup !== undefined) {
1271
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
1272
- }
1273
- if (params && "businessConnectionId" in params && params.businessConnectionId !== undefined) {
1274
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("businessConnectionId");
1275
- }
1276
- if (params && "sendAs" in params && params.sendAs !== undefined) {
1277
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
1278
- }
1279
- if (params && "sendAt" in params && params.sendAt !== undefined) {
1280
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("businessConsendAtnectionId");
1281
- }
1282
- }, _MessageManager_constructReplyMarkup = async function _MessageManager_constructReplyMarkup(params) {
1283
- if (params?.replyMarkup) {
1284
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
1285
- return await replyMarkupToTlObject(params.replyMarkup, this.usernameResolver.bind(this));
1286
- }
1287
- }, _MessageManager_resolveSendAs = async function _MessageManager_resolveSendAs(params) {
1288
- const sendAs = params?.sendAs;
1289
- if (sendAs !== undefined) {
1290
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
1291
- return sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(sendAs) : undefined;
1292
- }
1293
- }, _MessageManager_constructReplyTo = async function _MessageManager_constructReplyTo(params) {
1294
- const topMsgId = params?.messageThreadId;
1295
- if (!params?.replyTo) {
1296
- if (topMsgId) {
1297
- return { _: "inputReplyToMessage", reply_to_msg_id: topMsgId };
1298
- }
1299
- else {
1300
- return undefined;
1301
- }
1302
- }
1303
- if ("messageId" in params.replyTo) {
1304
- return { _: "inputReplyToMessage", reply_to_msg_id: params.replyTo.messageId, top_msg_id: topMsgId, quote_text: params.replyTo.quote?.text, quote_entities: await Promise.all(params.replyTo.quote?.entities.map((v) => messageEntityToTlObject(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity)) ?? []), quote_offset: params.replyTo.quote?.offset };
1305
- }
1306
- else {
1307
- return { _: "inputReplyToStory", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.replyTo.chatId), story_id: params.replyTo.storyId };
1308
- }
1309
- }, _MessageManager_sendDocumentInner = async function _MessageManager_sendDocumentInner(chatId, document, params, fileType, otherAttribs, urlSupported = true, expectedMimeTypes) {
1310
- let media = null;
1311
- const spoiler = params?.hasSpoiler ? true : undefined;
1312
- const ttl_seconds = params && "selfDestruct" in params && typeof params.selfDestruct !== undefined ? selfDestructOptionToInt(params.selfDestruct) : undefined;
1313
- if (typeof document === "string") {
1314
- const fileId = this.resolveFileId(document, fileType);
1315
- if (fileId != null) {
1316
- media = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => Api.is("documentAttributeSticker", v))?.alt || undefined, ttl_seconds };
1317
- }
1318
- }
1319
- if (media == null) {
1320
- if (typeof document === "string" && isHttpUrl(document)) {
1321
- if (!urlSupported) {
1322
- throw new InputError("URL not supported.");
1323
- }
1324
- media = { _: "inputMediaDocumentExternal", url: document, spoiler, ttl_seconds };
1325
- }
1326
- else {
1327
- let mimeType;
1328
- const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(document, params, (name) => {
1329
- mimeType = params?.mimeType ?? contentType(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
1330
- if (expectedMimeTypes && !expectedMimeTypes.includes(mimeType)) {
1331
- unreachable();
1332
- }
1333
- if (name.endsWith(".tgs") && fileType == FileType.Document) {
1334
- name += "-";
1335
- }
1336
- return name;
1337
- });
1338
- if (Api.is("inputFileStoryDocument", file)) {
1339
- unreachable();
1340
- }
1341
- let thumb = undefined;
1342
- if (params?.thumbnail) {
1343
- thumb = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(params.thumbnail, { chunkSize: params?.chunkSize, signal: params?.signal });
1344
- }
1345
- media = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == FileType.Document ? true : undefined, ttl_seconds };
1346
- }
1347
- }
1348
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendMedia).call(this, chatId, media, params);
1349
- return message;
1350
- }, _MessageManager_sendMedia = async function _MessageManager_sendMedia(chatId, media, params) {
1351
- if (params?.starCount !== undefined) {
1352
- if (params.starCount <= 0) {
1353
- throw new InputError("starCount cannot be zero or negative");
1354
- }
1355
- media = { _: "inputMediaPaidMedia", stars_amount: BigInt(params.starCount), extended_media: [media] };
1356
- }
1357
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1358
- const randomId = getRandomId();
1359
- const silent = params?.disableNotification ? true : undefined;
1360
- const noforwards = params?.protectContent ? true : undefined;
1361
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
1362
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
1363
- const caption_ = params?.caption;
1364
- const parseResult = caption_ !== undefined ? await this.parseText(caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
1365
- const caption = parseResult === undefined ? undefined : parseResult[0];
1366
- const captionEntities = parseResult === undefined ? undefined : parseResult[1];
1367
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1368
- _: "messages.sendMedia",
1369
- peer,
1370
- random_id: randomId,
1371
- silent,
1372
- noforwards,
1373
- reply_markup: replyMarkup,
1374
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
1375
- send_as: sendAs,
1376
- media,
1377
- message: caption ?? "",
1378
- entities: captionEntities,
1379
- effect: params?.effectId ? BigInt(params.effectId) : undefined,
1380
- schedule_date: params?.sendAt,
1381
- allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
1382
- }, { businessConnectionId: params?.businessConnectionId });
1383
- return (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
1384
- }, _MessageManager_editInlineMessageTextInner = async function _MessageManager_editInlineMessageTextInner(inlineMessageId, text, params, allowEmpty = true) {
1385
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1386
- const [message, entities] = await this.parseText(text, params);
1387
- if (!allowEmpty && !message) {
1388
- throw new InputError("Message text cannot be empty.");
1389
- }
1390
- const id = await deserializeInlineMessageId(inlineMessageId);
1391
- if (params?.linkPreview && params.linkPreview.type != "input") {
1392
- throw new InputError("Expected link preview of type input.");
1393
- }
1394
- const noWebpage = params?.linkPreview && params.linkPreview.type == "input" && params.linkPreview.disable ? true : undefined;
1395
- const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
1396
- let media = undefined;
1397
- if (!noWebpage && params?.linkPreview?.url) {
1398
- media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.largeMedia ? true : undefined, force_small_media: params.linkPreview.smallMedia ? true : undefined, optional: message.length ? undefined : true };
1399
- }
1400
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1401
- _: "messages.editInlineBotMessage",
1402
- id,
1403
- entities,
1404
- message,
1405
- media,
1406
- no_webpage: noWebpage,
1407
- invert_media: invertMedia,
1408
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
1409
- }, { dc: getDc(id.dc_id) });
1410
- }, _MessageManager_resolveInputMediaInner = async function _MessageManager_resolveInputMediaInner(document, media, fileType, otherAttribs) {
1411
- let media_ = null;
1412
- const spoiler = "hasSpoiler" in media && media.hasSpoiler ? true : undefined;
1413
- if (typeof document === "string") {
1414
- const fileId = this.resolveFileId(document, fileType);
1415
- if (fileId != null) {
1416
- media_ = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => Api.is("documentAttributeSticker", v))?.alt || undefined };
1417
- }
1418
- }
1419
- if (media_ == null) {
1420
- if (typeof document === "string" && isHttpUrl(document)) {
1421
- media_ = { _: "inputMediaDocumentExternal", url: document, spoiler };
1422
- }
1423
- else {
1424
- let mimeType;
1425
- const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(document, media, (name) => {
1426
- mimeType = media?.mimeType ?? contentType(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
1427
- if (name.endsWith(".tgs") && fileType == FileType.Document) {
1428
- name += "-";
1429
- }
1430
- return name;
1431
- });
1432
- if (Api.is("inputFileStoryDocument", file)) {
1433
- unreachable();
1434
- }
1435
- let thumb = undefined;
1436
- if ("thumbnail" in media && media.thumbnail) {
1437
- thumb = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(media.thumbnail, { chunkSize: media?.chunkSize, signal: media?.signal });
1438
- }
1439
- media_ = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == FileType.Document ? true : undefined };
1440
- }
1441
- }
1442
- return media_;
1443
- }, _MessageManager_resolveInputMedia = async function _MessageManager_resolveInputMedia(media) {
1444
- if ("animation" in media) {
1445
- return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.animation, media, FileType.Animation, [
1446
- { _: "documentAttributeAnimated" },
1447
- { _: "documentAttributeVideo", supports_streaming: true, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
1448
- ]);
1449
- }
1450
- else if ("audio" in media) {
1451
- return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.audio, media, FileType.Audio, [
1452
- { _: "documentAttributeAudio", duration: media?.duration ?? 0, performer: media?.performer, title: media?.title },
1453
- ]);
1454
- }
1455
- else if ("document" in media) {
1456
- return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.document, media, FileType.Document, []);
1457
- }
1458
- else if ("photo" in media) {
1459
- let media_ = null;
1460
- const spoiler = media.hasSpoiler ? true : undefined;
1461
- const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? selfDestructOptionToInt(media.selfDestruct) : undefined;
1462
- if (typeof media.photo === "string") {
1463
- const fileId = this.resolveFileId(media.photo, [FileType.Photo, FileType.ProfilePhoto]);
1464
- if (fileId != null) {
1465
- media_ = { _: "inputMediaPhoto", id: { ...fileId, _: "inputPhoto" }, spoiler, ttl_seconds };
1466
- }
1467
- }
1468
- if (media_ == null) {
1469
- if (typeof media.photo === "string" && isHttpUrl(media.photo)) {
1470
- media_ = { _: "inputMediaPhotoExternal", url: media.photo, spoiler };
1471
- }
1472
- else {
1473
- const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(media.photo, media, null, false);
1474
- media_ = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds };
1475
- }
1476
- }
1477
- return media_;
1478
- }
1479
- else if ("video" in media) {
1480
- const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? selfDestructOptionToInt(media.selfDestruct) : undefined;
1481
- const media_ = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.video, media, FileType.Video, [
1482
- { _: "documentAttributeVideo", supports_streaming: media?.supportsStreaming ? true : undefined, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
1483
- ]);
1484
- media_.ttl_seconds = ttl_seconds;
1485
- return media_;
1486
- }
1487
- else {
1488
- unreachable();
1489
- }
1490
- }, _MessageManager_sendReaction = async function _MessageManager_sendReaction(chatId, messageId, reactions, params) {
1491
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.sendReaction", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), msg_id: checkMessageId(messageId), reaction: reactions.map((v) => reactionToTlObject(v)), big: params?.big ? true : undefined, add_to_recent: params?.addToRecents ? true : undefined });
1492
- }, _MessageManager_getCachedVoiceTranscription = async function _MessageManager_getCachedVoiceTranscription(message) {
1493
- const reference = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getVoiceTranscriptionReference(message.chat.id, message.id, fromUnixTimestamp(message.editDate ?? message.date));
1494
- if (!reference) {
1495
- return null;
1496
- }
1497
- const voiceTranscription = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getVoiceTranscription(reference);
1498
- if (!voiceTranscription || !voiceTranscription.done) {
1499
- return null;
1500
- }
1501
- return voiceTranscription;
1502
- }, _MessageManager_cacheVoiceTranscription = async function _MessageManager_cacheVoiceTranscription(message, voiceTranscription) {
1503
- await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.setVoiceTranscriptionReference(message.chat.id, message.id, fromUnixTimestamp(message.editDate ?? message.date), BigInt(voiceTranscription.id));
1504
- await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.setVoiceTranscription(voiceTranscription);
1505
- return voiceTranscription;
1506
- };
1507
- _MessageManager_CAPTIONABLE_MESSAGE_TYPES = { value: ["photo", "document", "video", "animation", "voice", "audio", "video"] };