@maincode-ai/matilda-code 0.21.13 → 0.22.0-nightly.20261102.db95a17c4

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 (252) hide show
  1. package/chunks/agent-4GIFJO5G.js +3 -0
  2. package/chunks/agent-headless-DXJESNI4.js +3 -0
  3. package/chunks/{askUserQuestion-BNSWGD26.js → askUserQuestion-7PM7G5YF.js} +3 -3
  4. package/chunks/ca-JKEHLTNL.js +23 -0
  5. package/chunks/chunk-225CZWD7.js +89 -0
  6. package/chunks/chunk-2QIC3OCV.js +9 -0
  7. package/chunks/chunk-33UVJMVE.js +120 -0
  8. package/chunks/chunk-35BBGAHD.js +2604 -0
  9. package/chunks/{chunk-DHDD5YJC.js → chunk-4KS2KEXK.js} +69 -69
  10. package/chunks/chunk-4MLFC664.js +3 -0
  11. package/chunks/{chunk-RNKDFE2S.js → chunk-5B2QERWR.js} +1 -1
  12. package/chunks/chunk-66WJUORA.js +8 -0
  13. package/chunks/chunk-6U5VOTWB.js +56 -0
  14. package/chunks/chunk-7MUWF4DK.js +80 -0
  15. package/chunks/{chunk-6M5G5FBH.js → chunk-BVTXZTL3.js} +1 -1
  16. package/chunks/chunk-CVGGYRNK.js +31 -0
  17. package/chunks/chunk-DUB7JMQV.js +13 -0
  18. package/chunks/chunk-ESNPNLMQ.js +8 -0
  19. package/chunks/chunk-GT6MSEK4.js +3 -0
  20. package/chunks/chunk-HEJO7OBH.js +3 -0
  21. package/chunks/chunk-JNHB73E3.js +9 -0
  22. package/chunks/chunk-JR5CSCG4.js +8 -0
  23. package/chunks/{chunk-EZDV7A76.js → chunk-KRVXBQRC.js} +1 -1
  24. package/chunks/{chunk-AOOZREGV.js → chunk-LBQNFSZ2.js} +1 -1
  25. package/chunks/{chunk-MEV5XQI2.js → chunk-QBXL5UBB.js} +1 -1
  26. package/chunks/{chunk-P5TG5CON.js → chunk-QDWS3VZT.js} +1 -1
  27. package/chunks/{chunk-QZI2ZGZY.js → chunk-QMZREVY3.js} +1 -1
  28. package/chunks/chunk-QUYQBKDE.js +8 -0
  29. package/chunks/chunk-QXSBPCBA.js +8 -0
  30. package/chunks/chunk-S2E5ZRPH.js +14 -0
  31. package/chunks/chunk-TUKNB5CQ.js +33 -0
  32. package/chunks/chunk-UM6CLO7D.js +7 -0
  33. package/chunks/{chunk-6T2GIM76.js → chunk-VVUY7VKR.js} +1 -1
  34. package/chunks/{chunk-5OHGYMKP.js → chunk-WENVHSCJ.js} +1 -1
  35. package/chunks/{chunk-27Q5KW3A.js → chunk-ZABH4QIL.js} +10 -10
  36. package/chunks/chunk-ZSGBDQXU.js +11 -0
  37. package/chunks/{computer-use-J4GAM4M6.js → computer-use-IZGLKENV.js} +1 -1
  38. package/chunks/{cron-create-IDWSZENI.js → cron-create-BTSJUVNT.js} +1 -1
  39. package/chunks/cron-delete-PTE3RC2W.js +3 -0
  40. package/chunks/cron-list-SINKHOIZ.js +5 -0
  41. package/chunks/de-GMGNR5CZ.js +23 -0
  42. package/chunks/{devtools-XRQ4YJ5S.js → devtools-7YNCRYZV.js} +1 -1
  43. package/chunks/{chunk-OOEH6ZSV.js → dist-UWUWLWTO.js} +2 -2
  44. package/chunks/{edit-X2S2ZXRN.js → edit-MDQEZ7BA.js} +1 -1
  45. package/chunks/en-3NQMLVKW.js +23 -0
  46. package/chunks/{enter-worktree-TUCGNCLO.js → enter-worktree-SZK65VXF.js} +1 -1
  47. package/chunks/enterPlanMode-5VWIIVHI.js +18 -0
  48. package/chunks/{exit-worktree-7FLITFZI.js → exit-worktree-OBHUK4TF.js} +1 -1
  49. package/chunks/{exitPlanMode-O5UUJ3GM.js → exitPlanMode-SXFQC4G2.js} +2 -2
  50. package/chunks/fr-WS3EBB36.js +23 -0
  51. package/chunks/{getMachineId-bsd-ZYBNK2JG.js → getMachineId-bsd-ETKQTB6C.js} +1 -1
  52. package/chunks/{getMachineId-darwin-CM2MQGUI.js → getMachineId-darwin-AKNRWOWB.js} +1 -1
  53. package/chunks/{getMachineId-linux-SYE2KMCW.js → getMachineId-linux-2QSD7FTP.js} +1 -1
  54. package/chunks/{getMachineId-unsupported-6IHVG2XO.js → getMachineId-unsupported-UXSV7I24.js} +1 -1
  55. package/chunks/{getMachineId-win-S3J3JSUM.js → getMachineId-win-4MTFXGP3.js} +1 -1
  56. package/chunks/glob-JKIZ3ZJQ.js +22 -0
  57. package/chunks/{goal-tools-YQOA6OKU.js → goal-tools-YJMECZYD.js} +3 -3
  58. package/chunks/{grep-VAB2VSXM.js → grep-Q4T5AE6K.js} +1 -1
  59. package/chunks/ja-GBCDQ43R.js +23 -0
  60. package/chunks/keychain-token-storage-4PY5J6U6.js +3 -0
  61. package/chunks/ls-BQCCCPIX.js +15 -0
  62. package/chunks/{lsp-NGLDRHZU.js → lsp-MHJJJ7K3.js} +1 -1
  63. package/chunks/mcp-client-CSF5QZEY.js +3 -0
  64. package/chunks/monitor-JUAVWVLY.js +32 -0
  65. package/chunks/{multipart-parser-JI75T2O5.js → multipart-parser-FKHYAVGR.js} +1 -1
  66. package/chunks/notebook-edit-NNOMEUER.js +17 -0
  67. package/chunks/openaiContentGenerator-DTKOYRBL.js +47 -0
  68. package/chunks/pt-VID6J2CM.js +23 -0
  69. package/chunks/read-file-4EX4B3TB.js +3 -0
  70. package/chunks/ripGrep-JL6UDNCR.js +3 -0
  71. package/chunks/ru-EB6V6EAN.js +23 -0
  72. package/chunks/scheduler-GCGZAI7D.js +8 -0
  73. package/chunks/send-message-S4P5QKSW.js +8 -0
  74. package/chunks/shell-J7EX7B57.js +3 -0
  75. package/chunks/{skill-ETQM5NI3.js → skill-V6NTJ4O4.js} +1 -1
  76. package/chunks/src-LZEU4AYF.js +5 -0
  77. package/chunks/symbol-search-5QJNW7PY.js +19 -0
  78. package/chunks/{syntheticOutput-WZDPECYS.js → syntheticOutput-3XIAIUIR.js} +1 -1
  79. package/chunks/task-create-KGPY7O4J.js +3 -0
  80. package/chunks/{task-detach-TBAVUOTC.js → task-detach-ZD3A7225.js} +1 -1
  81. package/chunks/task-list-P7GQWYAD.js +9 -0
  82. package/chunks/{task-stop-HDSARSJ6.js → task-stop-VFJRBA6P.js} +1 -1
  83. package/chunks/{task-update-MW2VT2XV.js → task-update-OOMH4WRA.js} +1 -1
  84. package/chunks/{team-create-VMYNLZCC.js → team-create-POMZOM44.js} +2 -2
  85. package/chunks/team-delete-ZJBEQDPE.js +8 -0
  86. package/chunks/todoWrite-EWYRFK7W.js +3 -0
  87. package/chunks/{tool-search-WX6FOE35.js → tool-search-5Z7MO565.js} +1 -1
  88. package/chunks/{web-fetch-CKYBHGLF.js → web-fetch-M4TUYAFG.js} +17 -17
  89. package/chunks/web-search-CBKF36JM.js +26 -0
  90. package/chunks/{workflow-WBSRQG3N.js → workflow-F57TWWPS.js} +2 -2
  91. package/chunks/write-file-UK4BVL3M.js +15 -0
  92. package/cli.js +642 -678
  93. package/examples/starter/README.md +0 -3
  94. package/locales/ca.js +3 -87
  95. package/locales/de.js +3 -91
  96. package/locales/en.js +3 -91
  97. package/locales/fr.js +3 -88
  98. package/locales/ja.js +3 -92
  99. package/locales/pt.js +3 -92
  100. package/locales/ru.js +3 -91
  101. package/package.json +2 -2
  102. package/sandbox-macos-permissive-proxied.sb +1 -1
  103. package/sandbox-macos-restrictive-closed.sb +14 -1
  104. package/sandbox-macos-restrictive-open.sb +14 -1
  105. package/sandbox-macos-restrictive-proxied.sb +15 -2
  106. package/bundled/mainy/SKILL.md +0 -157
  107. package/bundled/mainy/docs/_meta.ts +0 -32
  108. package/bundled/mainy/docs/common-workflow.md +0 -571
  109. package/bundled/mainy/docs/configuration/_meta.ts +0 -7
  110. package/bundled/mainy/docs/configuration/auth.md +0 -82
  111. package/bundled/mainy/docs/configuration/matilda-ignore.md +0 -55
  112. package/bundled/mainy/docs/configuration/model-providers.md +0 -516
  113. package/bundled/mainy/docs/configuration/settings.md +0 -818
  114. package/bundled/mainy/docs/configuration/themes.md +0 -199
  115. package/bundled/mainy/docs/configuration/trusted-folders.md +0 -67
  116. package/bundled/mainy/docs/extension/_meta.ts +0 -9
  117. package/bundled/mainy/docs/extension/extension-releasing.md +0 -204
  118. package/bundled/mainy/docs/extension/getting-started-extensions.md +0 -299
  119. package/bundled/mainy/docs/extension/introduction.md +0 -338
  120. package/bundled/mainy/docs/features/_meta.ts +0 -27
  121. package/bundled/mainy/docs/features/approval-mode.md +0 -388
  122. package/bundled/mainy/docs/features/arena.md +0 -219
  123. package/bundled/mainy/docs/features/auto-mode.md +0 -308
  124. package/bundled/mainy/docs/features/channels/_meta.ts +0 -5
  125. package/bundled/mainy/docs/features/channels/overview.md +0 -328
  126. package/bundled/mainy/docs/features/channels/plugins.md +0 -87
  127. package/bundled/mainy/docs/features/channels/telegram.md +0 -120
  128. package/bundled/mainy/docs/features/code-review.md +0 -291
  129. package/bundled/mainy/docs/features/commands.md +0 -528
  130. package/bundled/mainy/docs/features/dual-output.md +0 -627
  131. package/bundled/mainy/docs/features/followup-suggestions.md +0 -109
  132. package/bundled/mainy/docs/features/headless.md +0 -448
  133. package/bundled/mainy/docs/features/hooks.md +0 -1308
  134. package/bundled/mainy/docs/features/language.md +0 -144
  135. package/bundled/mainy/docs/features/lsp.md +0 -496
  136. package/bundled/mainy/docs/features/markdown-rendering.md +0 -183
  137. package/bundled/mainy/docs/features/mcp.md +0 -423
  138. package/bundled/mainy/docs/features/memory.md +0 -185
  139. package/bundled/mainy/docs/features/sandbox.md +0 -249
  140. package/bundled/mainy/docs/features/scheduled-tasks.md +0 -139
  141. package/bundled/mainy/docs/features/skills.md +0 -347
  142. package/bundled/mainy/docs/features/status-line.md +0 -397
  143. package/bundled/mainy/docs/features/structured-output.md +0 -309
  144. package/bundled/mainy/docs/features/sub-agents.md +0 -737
  145. package/bundled/mainy/docs/features/tips.md +0 -54
  146. package/bundled/mainy/docs/features/token-caching.md +0 -29
  147. package/bundled/mainy/docs/features/tool-use-summaries.md +0 -178
  148. package/bundled/mainy/docs/features/worktree.md +0 -343
  149. package/bundled/mainy/docs/ide-integration/_meta.ts +0 -4
  150. package/bundled/mainy/docs/ide-integration/ide-companion-spec.md +0 -182
  151. package/bundled/mainy/docs/ide-integration/ide-integration.md +0 -144
  152. package/bundled/mainy/docs/integration-github-action.md +0 -241
  153. package/bundled/mainy/docs/integration-jetbrains.md +0 -81
  154. package/bundled/mainy/docs/integration-vscode.md +0 -39
  155. package/bundled/mainy/docs/integration-zed.md +0 -72
  156. package/bundled/mainy/docs/matilda-serve-deploy-local.md +0 -221
  157. package/bundled/mainy/docs/matilda-serve.md +0 -661
  158. package/bundled/mainy/docs/overview.md +0 -64
  159. package/bundled/mainy/docs/quickstart.md +0 -234
  160. package/bundled/mainy/docs/reference/_meta.ts +0 -3
  161. package/bundled/mainy/docs/reference/keyboard-shortcuts.md +0 -91
  162. package/bundled/mainy/docs/support/Uninstall.md +0 -65
  163. package/bundled/mainy/docs/support/_meta.ts +0 -6
  164. package/bundled/mainy/docs/support/tos-privacy.md +0 -94
  165. package/bundled/mainy/docs/support/troubleshooting.md +0 -127
  166. package/chunks/agent-SRAIVZEE.js +0 -3
  167. package/chunks/agent-headless-XRDOZESG.js +0 -3
  168. package/chunks/anthropicContentGenerator-LLDIKDMQ.js +0 -39
  169. package/chunks/ca-NPYL24ME.js +0 -25
  170. package/chunks/chunk-27HUYW23.js +0 -22
  171. package/chunks/chunk-2HTPVSGT.js +0 -3
  172. package/chunks/chunk-3B2HABK7.js +0 -30
  173. package/chunks/chunk-3MTZTNAU.js +0 -101
  174. package/chunks/chunk-3YLXGE6T.js +0 -8
  175. package/chunks/chunk-47XR7IMP.js +0 -8
  176. package/chunks/chunk-4F4DA5UI.js +0 -8
  177. package/chunks/chunk-4Q2SNBUH.js +0 -18
  178. package/chunks/chunk-6EQMZNIY.js +0 -8
  179. package/chunks/chunk-6I6VGTKD.js +0 -8
  180. package/chunks/chunk-DC7LAFZZ.js +0 -8
  181. package/chunks/chunk-DE3HKC2W.js +0 -9
  182. package/chunks/chunk-FWDMPRKU.js +0 -3
  183. package/chunks/chunk-G7R2XEEF.js +0 -7
  184. package/chunks/chunk-GOJCMVJJ.js +0 -8
  185. package/chunks/chunk-GTVCJCHR.js +0 -8
  186. package/chunks/chunk-IJEGHQ7Z.js +0 -32
  187. package/chunks/chunk-JCE3JAVC.js +0 -25
  188. package/chunks/chunk-KHHJYBR5.js +0 -9
  189. package/chunks/chunk-LUNDTQ3G.js +0 -8
  190. package/chunks/chunk-LWARA7JY.js +0 -37
  191. package/chunks/chunk-M53RP3YP.js +0 -31
  192. package/chunks/chunk-MTMU7JYZ.js +0 -11
  193. package/chunks/chunk-O44XK65C.js +0 -8
  194. package/chunks/chunk-OA56BXPD.js +0 -3
  195. package/chunks/chunk-PEKAUGYV.js +0 -2621
  196. package/chunks/chunk-PGUG43HG.js +0 -24
  197. package/chunks/chunk-PGXQZVLX.js +0 -8
  198. package/chunks/chunk-QKYGQLWC.js +0 -8
  199. package/chunks/chunk-QN6Y6NPA.js +0 -3
  200. package/chunks/chunk-RI54U73U.js +0 -56
  201. package/chunks/chunk-RPFSFS7Z.js +0 -39
  202. package/chunks/chunk-SDTWBD62.js +0 -8
  203. package/chunks/chunk-SOEIVSM5.js +0 -113
  204. package/chunks/chunk-SVSY6AWS.js +0 -59
  205. package/chunks/chunk-T2T2UEPY.js +0 -4
  206. package/chunks/chunk-TISQNFB5.js +0 -3
  207. package/chunks/chunk-TWJLOEAI.js +0 -31
  208. package/chunks/chunk-VI74YQQO.js +0 -8
  209. package/chunks/chunk-VYZOOSMP.js +0 -30
  210. package/chunks/chunk-W4QSMIWO.js +0 -9
  211. package/chunks/chunk-WC2VTVCE.js +0 -27
  212. package/chunks/chunk-YV3PUOBU.js +0 -65
  213. package/chunks/chunk-ZX34M2GF.js +0 -14
  214. package/chunks/contextCommand-5F5M7NA4.js +0 -3
  215. package/chunks/cron-delete-NQCDZDUI.js +0 -3
  216. package/chunks/cron-list-Z4XMC3TO.js +0 -5
  217. package/chunks/de-34YZHGC6.js +0 -25
  218. package/chunks/dist-7UYRLSLE.js +0 -3
  219. package/chunks/dist-PH6JW7XD.js +0 -42
  220. package/chunks/en-QLGMD6OS.js +0 -25
  221. package/chunks/enterPlanMode-SQEZAAIR.js +0 -18
  222. package/chunks/fileFromPath-7UCWPD4W.js +0 -3
  223. package/chunks/fr-EDNBQACJ.js +0 -25
  224. package/chunks/geminiContentGenerator-FIZFLPU3.js +0 -8
  225. package/chunks/glob-GSFTYAS2.js +0 -22
  226. package/chunks/ja-LV4RLM3M.js +0 -25
  227. package/chunks/keychain-token-storage-KQK6MNOJ.js +0 -3
  228. package/chunks/ls-IZJ3CKZY.js +0 -15
  229. package/chunks/matildaAgentContentGenerator-QQHPCFJ5.js +0 -8
  230. package/chunks/matildaContentGenerator-W7Z33ONU.js +0 -8
  231. package/chunks/matildaOAuth2-7COTQQR2.js +0 -3
  232. package/chunks/mcp-client-DXUNIEIB.js +0 -3
  233. package/chunks/monitor-4PFIGAGG.js +0 -32
  234. package/chunks/notebook-edit-MWJYAATJ.js +0 -17
  235. package/chunks/openaiContentGenerator-NDVJL6QL.js +0 -3
  236. package/chunks/pt-5SQ4DGL7.js +0 -25
  237. package/chunks/read-file-WPZKPXWA.js +0 -3
  238. package/chunks/ripGrep-7LZDZFTX.js +0 -3
  239. package/chunks/ru-7K24S53N.js +0 -25
  240. package/chunks/scheduler-DK2MVKXX.js +0 -8
  241. package/chunks/send-message-TCPX5UDU.js +0 -8
  242. package/chunks/serve-GSZPJI2O.js +0 -1026
  243. package/chunks/shell-PRS47PDP.js +0 -3
  244. package/chunks/src-UB7DZRYK.js +0 -3
  245. package/chunks/src-WZTRMETQ.js +0 -5
  246. package/chunks/symbol-search-HARHZ5AH.js +0 -19
  247. package/chunks/task-create-XRNIDT4T.js +0 -3
  248. package/chunks/task-list-Z6BDZZID.js +0 -9
  249. package/chunks/team-delete-F7QDC2TE.js +0 -8
  250. package/chunks/todoWrite-SCF5M24M.js +0 -3
  251. package/chunks/web-search-67DFNS5V.js +0 -26
  252. package/chunks/write-file-S5FAX4JJ.js +0 -15
@@ -1,42 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a as rt,b as Ms}from"./chunk-QN6Y6NPA.js";import{e as ot}from"./chunk-3B2HABK7.js";import"./chunk-T2T2UEPY.js";import"./chunk-M53RP3YP.js";import{a as Cs}from"./chunk-OOEH6ZSV.js";import{a as ws}from"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import{b as h}from"./chunk-GZPNIYVZ.js";import{a as K,d as y,f as nt}from"./chunk-OWGSC52X.js";var re=y(Y=>{"use strict";h();Object.defineProperty(Y,"__esModule",{value:!0});Y.matchFilter=Is;Y.parse=ft;Y.preprocess=_t;var at=new Map;function Is(n){var e;let t=Array.isArray(n)?n:[n],s=t.join(","),i=(e=at.get(s))!==null&&e!==void 0?e:(()=>{let r=ft(t),o=Ss(r);return at.set(s,o),o})();return r=>i(r)}function ft(n){return Array.isArray(n)?n.map(e=>e.split(":")):[n.split(":")]}function Ss(n){let e=n.flatMap(i=>ks(i,_t(i))),t=Ts(e),s=Ps(t);return i=>!!s(i.update,i)}function _t(n){let e=ne,t=[n].flatMap(s=>{let[i,r,o]=s;if(!(i in mt))return[s];if(!i&&!r&&!o)return[s];let d=mt[i].map(c=>[c,r,o]);return r===void 0||r in Ae&&(r||o)?d:d.filter(([c])=>{var l;return!!(!((l=e[c])===null||l===void 0)&&l[r])})}).flatMap(s=>{let[i,r,o]=s;if(!(r in Ae))return[s];if(!r&&!o)return[s];let d=Ae[r].map(c=>[i,c,o]);return o===void 0?d:d.filter(([,c])=>{var l,p;return!!(!((p=(l=e[i])===null||l===void 0?void 0:l[c])===null||p===void 0)&&p[o])})});if(t.length===0)throw new Error(`Shortcuts in '${n.join(":")}' do not expand to any valid filter query`);return t}function ks(n,e){if(e.length===0)throw new Error("Empty filter query given");let t=e.map(As).filter(s=>s!==!0);if(t.length===0)return e;throw t.length===1?new Error(t[0]):new Error(`Invalid filter query '${n.join(":")}'. There are ${t.length} errors after expanding the contained shortcuts: ${t.join("; ")}`)}function As(n){let[e,t,s,...i]=n;if(e===void 0)return"Empty filter query given";if(!(e in ne)){let a=Object.keys(ne);return`Invalid L1 filter '${e}' given in '${n.join(":")}'. Permitted values are: ${a.map(d=>`'${d}'`).join(", ")}.`}if(t===void 0)return!0;let r=ne[e];if(!(t in r)){let a=Object.keys(r);return`Invalid L2 filter '${t}' given in '${n.join(":")}'. Permitted values are: ${a.map(d=>`'${d}'`).join(", ")}.`}if(s===void 0)return!0;let o=r[t];if(!(s in o)){let a=Object.keys(o);return`Invalid L3 filter '${s}' given in '${n.join(":")}'. ${a.length===0?`No further filtering is possible after '${e}:${t}'.`:`Permitted values are: ${a.map(d=>`'${d}'`).join(", ")}.`}`}return i.length===0?!0:`Cannot filter further than three levels, ':${i.join(":")}' is invalid!`}function Ts(n){var e,t;let s={};for(let[i,r,o]of n){let a=(e=s[i])!==null&&e!==void 0?e:s[i]={};if(r!==void 0){let d=(t=a[r])!==null&&t!==void 0?t:a[r]=new Set;o!==void 0&&d.add(o)}}return s}function ke(n,e){return(t,s)=>n(t,s)||e(t,s)}function ut(n,e){return(t,s)=>{let i=n(t,s);return i&&e(i,s)}}function dt(n){return(e,t)=>n(e,t)!=null}function Ps(n){let e=Object.entries(n).map(([t,s])=>{let i=o=>o[t],r=Object.entries(s).map(([o,a])=>{let d=l=>l[o],c=Array.from(a).map(l=>l==="me"?(m,_)=>{let g=_.me.id;return ct(m,w=>w.id===g)}:m=>ct(m,_=>_[l]||_.type===l));return c.length===0?dt(d):ut(d,c.reduce(ke))});return r.length===0?dt(i):ut(i,r.reduce(ke))});if(e.length===0)throw new Error("Cannot create filter function for empty query");return e.reduce(ke)}function ct(n,e){let t=s=>s!=null&&e(s);return Array.isArray(n)?n.some(t):t(n)}var lt={mention:{},hashtag:{},cashtag:{},bot_command:{},url:{},email:{},phone_number:{},bold:{},italic:{},underline:{},strikethrough:{},spoiler:{},blockquote:{},expandable_blockquote:{},code:{},pre:{},text_link:{},text_mention:{},custom_emoji:{}},Te={me:{},is_bot:{},is_premium:{},added_to_attachment_menu:{}},Es={user:{},hidden_user:{},chat:{},channel:{}},js={is_video:{},is_animated:{},premium_animation:{}},Pe={emoji:{},custom_emoji:{},paid:{}},ht={can_be_upgraded:{},is_upgrade_separate:{},is_private:{}},yt={forward_origin:Es,is_topic_message:{},is_automatic_forward:{},business_connection_id:{},text:{},animation:{},audio:{},document:{},paid_media:{},photo:{},sticker:js,story:{},video:{},video_note:{},voice:{},contact:{},dice:{},game:{},poll:{},venue:{},location:{},entities:lt,caption_entities:lt,caption:{},link_preview_options:{url:{},prefer_small_media:{},prefer_large_media:{},show_above_text:{}},effect_id:{},paid_star_count:{},has_media_spoiler:{},new_chat_title:{},new_chat_photo:{},delete_chat_photo:{},message_auto_delete_timer_changed:{},pinned_message:{},invoice:{},proximity_alert_triggered:{},chat_background_set:{},giveaway_created:{},giveaway:{only_new_members:{},has_public_winners:{}},giveaway_winners:{only_new_members:{},was_refunded:{}},giveaway_completed:{},gift:ht,gift_upgrade_sent:ht,unique_gift:{transfer_star_count:{}},paid_message_price_changed:{},video_chat_scheduled:{},video_chat_started:{},video_chat_ended:{},video_chat_participants_invited:{},web_app_data:{}},ie={...yt,direct_messages_topic:{},chat_owner_left:{new_owner:{}},chat_owner_changd:{},new_chat_members:Te,left_chat_member:Te,group_chat_created:{},supergroup_chat_created:{},migrate_to_chat_id:{},migrate_from_chat_id:{},successful_payment:{},refunded_payment:{},users_shared:{},chat_shared:{},connected_website:{},write_access_allowed:{},passport_data:{},boost_added:{},forum_topic_created:{is_name_implicit:{}},forum_topic_edited:{name:{},icon_custom_emoji_id:{}},forum_topic_closed:{},forum_topic_reopened:{},general_forum_topic_hidden:{},general_forum_topic_unhidden:{},checklist:{others_can_add_tasks:{},others_can_mark_tasks_as_done:{}},checklist_tasks_done:{},checklist_tasks_added:{},suggested_post_info:{},suggested_post_approved:{},suggested_post_approval_failed:{},suggested_post_declined:{},suggested_post_paid:{},suggested_post_refunded:{},sender_boost_count:{}},pt={...yt,channel_chat_created:{},direct_message_price_changed:{},is_paid_post:{}},Rs={can_reply:{},is_enabled:{}},Bs={old_reaction:Pe,new_reaction:Pe},Fs={reactions:Pe},$s={data:{},game_short_name:{}},gt={from:Te},ne={message:ie,edited_message:ie,channel_post:pt,edited_channel_post:pt,business_connection:Rs,business_message:ie,edited_business_message:ie,deleted_business_messages:{},inline_query:{},chosen_inline_result:{},callback_query:$s,shipping_query:{},pre_checkout_query:{},poll:{},poll_answer:{},my_chat_member:gt,chat_member:gt,chat_join_request:{},message_reaction:Bs,message_reaction_count:Fs,chat_boost:{},removed_chat_boost:{},purchased_paid_media:{}},mt={"":["message","channel_post"],msg:["message","channel_post"],edit:["edited_message","edited_channel_post"]},Ae={"":["entities","caption_entities"],media:["photo","video"],file:["photo","animation","audio","document","video","video_note","voice","sticker"]}});var de=y(ue=>{"use strict";h();Object.defineProperty(ue,"__esModule",{value:!0});ue.Context=void 0;var Ls=re(),S={filterQuery(n){let e=(0,Ls.matchFilter)(n);return t=>e(t)},text(n){let e=S.filterQuery([":text",":caption"]),t=$(n);return s=>{var i,r;if(!e(s))return!1;let o=(i=s.message)!==null&&i!==void 0?i:s.channelPost,a=(r=o.text)!==null&&r!==void 0?r:o.caption;return L(s,a,t)}},command(n){let e=S.filterQuery(":entities:bot_command"),t=new Set,s=new Set;return ae(n).forEach(i=>{if(i.startsWith("/"))throw new Error(`Do not include '/' when registering command handlers (use '${i.substring(1)}' not '${i}')`);(i.includes("@")?t:s).add(i)}),i=>{var r,o;if(!e(i))return!1;let a=(r=i.message)!==null&&r!==void 0?r:i.channelPost,d=(o=a.text)!==null&&o!==void 0?o:a.caption;return a.entities.some(c=>{if(c.type!=="bot_command"||c.offset!==0)return!1;let l=d.substring(1,c.length);if(s.has(l)||t.has(l))return i.match=d.substring(l.length+1).trimStart(),!0;let p=l.indexOf("@");if(p===-1)return!1;let m=l.substring(p+1).toLowerCase(),_=i.me.username.toLowerCase();if(m!==_)return!1;let g=l.substring(0,p);return s.has(g)?(i.match=d.substring(l.length+1).trimStart(),!0):!1})}},reaction(n){let e=S.filterQuery("message_reaction"),t=typeof n=="string"?[{type:"emoji",emoji:n}]:(Array.isArray(n)?n:[n]).map(o=>typeof o=="string"?{type:"emoji",emoji:o}:o),s=new Set(t.filter(o=>o.type==="emoji").map(o=>o.emoji)),i=new Set(t.filter(o=>o.type==="custom_emoji").map(o=>o.custom_emoji_id)),r=t.some(o=>o.type==="paid");return o=>{if(!e(o))return!1;let{old_reaction:a,new_reaction:d}=o.messageReaction;for(let c of d){let l=!1;if(c.type==="emoji"){for(let p of a)if(p.type==="emoji"&&p.emoji===c.emoji){l=!0;break}}else if(c.type==="custom_emoji"){for(let p of a)if(p.type==="custom_emoji"&&p.custom_emoji_id===c.custom_emoji_id){l=!0;break}}else if(c.type==="paid"){for(let p of a)if(p.type==="paid"){l=!0;break}}if(!l)if(c.type==="emoji"){if(s.has(c.emoji))return!0}else if(c.type==="custom_emoji"){if(i.has(c.custom_emoji_id))return!0}else if(c.type==="paid"){if(r)return!0}else return!0}return!1}},chatType(n){let e=new Set(ae(n));return t=>{var s;return((s=t.chat)===null||s===void 0?void 0:s.type)!==void 0&&e.has(t.chat.type)}},callbackQuery(n){let e=S.filterQuery("callback_query:data"),t=$(n);return s=>e(s)&&L(s,s.callbackQuery.data,t)},gameQuery(n){let e=S.filterQuery("callback_query:game_short_name"),t=$(n);return s=>e(s)&&L(s,s.callbackQuery.game_short_name,t)},inlineQuery(n){let e=S.filterQuery("inline_query"),t=$(n);return s=>e(s)&&L(s,s.inlineQuery.query,t)},chosenInlineResult(n){let e=S.filterQuery("chosen_inline_result"),t=$(n);return s=>e(s)&&L(s,s.chosenInlineResult.result_id,t)},preCheckoutQuery(n){let e=S.filterQuery("pre_checkout_query"),t=$(n);return s=>e(s)&&L(s,s.preCheckoutQuery.invoice_payload,t)},shippingQuery(n){let e=S.filterQuery("shipping_query"),t=$(n);return s=>e(s)&&L(s,s.shippingQuery.invoice_payload,t)}},oe=class n{constructor(e,t,s){this.update=e,this.api=t,this.me=s}get message(){return this.update.message}get editedMessage(){return this.update.edited_message}get channelPost(){return this.update.channel_post}get editedChannelPost(){return this.update.edited_channel_post}get businessConnection(){return this.update.business_connection}get businessMessage(){return this.update.business_message}get editedBusinessMessage(){return this.update.edited_business_message}get deletedBusinessMessages(){return this.update.deleted_business_messages}get messageReaction(){return this.update.message_reaction}get messageReactionCount(){return this.update.message_reaction_count}get inlineQuery(){return this.update.inline_query}get chosenInlineResult(){return this.update.chosen_inline_result}get callbackQuery(){return this.update.callback_query}get shippingQuery(){return this.update.shipping_query}get preCheckoutQuery(){return this.update.pre_checkout_query}get poll(){return this.update.poll}get pollAnswer(){return this.update.poll_answer}get myChatMember(){return this.update.my_chat_member}get chatMember(){return this.update.chat_member}get chatJoinRequest(){return this.update.chat_join_request}get chatBoost(){return this.update.chat_boost}get removedChatBoost(){return this.update.removed_chat_boost}get purchasedPaidMedia(){return this.update.purchased_paid_media}get msg(){var e,t,s,i,r,o,a;return(o=(r=(i=(s=(t=(e=this.message)!==null&&e!==void 0?e:this.editedMessage)!==null&&t!==void 0?t:this.channelPost)!==null&&s!==void 0?s:this.editedChannelPost)!==null&&i!==void 0?i:this.businessMessage)!==null&&r!==void 0?r:this.editedBusinessMessage)!==null&&o!==void 0?o:(a=this.callbackQuery)===null||a===void 0?void 0:a.message}get chat(){var e,t,s,i,r,o,a,d,c;return(c=(d=(a=(o=(r=(i=(s=(t=(e=this.msg)!==null&&e!==void 0?e:this.deletedBusinessMessages)!==null&&t!==void 0?t:this.messageReaction)!==null&&s!==void 0?s:this.messageReactionCount)!==null&&i!==void 0?i:this.myChatMember)!==null&&r!==void 0?r:this.chatMember)!==null&&o!==void 0?o:this.chatJoinRequest)!==null&&a!==void 0?a:this.chatBoost)!==null&&d!==void 0?d:this.removedChatBoost)===null||c===void 0?void 0:c.chat}get senderChat(){var e;return(e=this.msg)===null||e===void 0?void 0:e.sender_chat}get from(){var e,t,s,i,r,o,a,d,c,l,p,m,_,g,w,M,v;return(a=(o=(t=(e=this.businessConnection)!==null&&e!==void 0?e:this.messageReaction)!==null&&t!==void 0?t:(r=(i=(s=this.chatBoost)===null||s===void 0?void 0:s.boost)!==null&&i!==void 0?i:this.removedChatBoost)===null||r===void 0?void 0:r.source)===null||o===void 0?void 0:o.user)!==null&&a!==void 0?a:(v=(M=(w=(g=(_=(m=(p=(l=(c=(d=this.callbackQuery)!==null&&d!==void 0?d:this.msg)!==null&&c!==void 0?c:this.inlineQuery)!==null&&l!==void 0?l:this.chosenInlineResult)!==null&&p!==void 0?p:this.shippingQuery)!==null&&m!==void 0?m:this.preCheckoutQuery)!==null&&_!==void 0?_:this.myChatMember)!==null&&g!==void 0?g:this.chatMember)!==null&&w!==void 0?w:this.chatJoinRequest)!==null&&M!==void 0?M:this.purchasedPaidMedia)===null||v===void 0?void 0:v.from}get msgId(){var e,t,s,i,r;return(i=(t=(e=this.msg)===null||e===void 0?void 0:e.message_id)!==null&&t!==void 0?t:(s=this.messageReaction)===null||s===void 0?void 0:s.message_id)!==null&&i!==void 0?i:(r=this.messageReactionCount)===null||r===void 0?void 0:r.message_id}get chatId(){var e,t,s;return(t=(e=this.chat)===null||e===void 0?void 0:e.id)!==null&&t!==void 0?t:(s=this.businessConnection)===null||s===void 0?void 0:s.user_chat_id}get inlineMessageId(){var e,t,s;return(t=(e=this.callbackQuery)===null||e===void 0?void 0:e.inline_message_id)!==null&&t!==void 0?t:(s=this.chosenInlineResult)===null||s===void 0?void 0:s.inline_message_id}get businessConnectionId(){var e,t,s,i,r;return(i=(t=(e=this.msg)===null||e===void 0?void 0:e.business_connection_id)!==null&&t!==void 0?t:(s=this.businessConnection)===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:(r=this.deletedBusinessMessages)===null||r===void 0?void 0:r.business_connection_id}entities(e){var t,s;let i=this.msg;if(i===void 0)return[];let r=(t=i.text)!==null&&t!==void 0?t:i.caption;if(r===void 0)return[];let o=(s=i.entities)!==null&&s!==void 0?s:i.caption_entities;if(o===void 0)return[];if(e!==void 0){let a=new Set(ae(e));o=o.filter(d=>a.has(d.type))}return o.map(a=>({...a,text:r.substring(a.offset,a.offset+a.length)}))}reactions(){let e=[],t=[],s=[],i=[],r=[],o=[],a=[],d=[],c=!1,l=!1,p=this.messageReaction;if(p!==void 0){let{old_reaction:m,new_reaction:_}=p;for(let g of _)g.type==="emoji"?e.push(g.emoji):g.type==="custom_emoji"?r.push(g.custom_emoji_id):g.type==="paid"&&(c=l=!0);for(let g of m)g.type==="emoji"?i.push(g.emoji):g.type==="custom_emoji"?d.push(g.custom_emoji_id):g.type==="paid"&&(l=!1);t.push(...e),o.push(...r);for(let g=0;g<i.length;g++){let w=t.length;if(w===0)break;let M=i[g];for(let v=0;v<w;v++)if(M===t[v]){s.push(M),i.splice(g,1),t.splice(v,1),g--;break}}for(let g=0;g<d.length;g++){let w=o.length;if(w===0)break;let M=d[g];for(let v=0;v<w;v++)if(M===o[v]){a.push(M),d.splice(g,1),o.splice(v,1),g--;break}}}return{emoji:e,emojiAdded:t,emojiKept:s,emojiRemoved:i,customEmoji:r,customEmojiAdded:o,customEmojiKept:a,customEmojiRemoved:d,paid:c,paidAdded:l}}has(e){return n.has.filterQuery(e)(this)}hasText(e){return n.has.text(e)(this)}hasCommand(e){return n.has.command(e)(this)}hasReaction(e){return n.has.reaction(e)(this)}hasChatType(e){return n.has.chatType(e)(this)}hasCallbackQuery(e){return n.has.callbackQuery(e)(this)}hasGameQuery(e){return n.has.gameQuery(e)(this)}hasInlineQuery(e){return n.has.inlineQuery(e)(this)}hasChosenInlineResult(e){return n.has.chosenInlineResult(e)(this)}hasPreCheckoutQuery(e){return n.has.preCheckoutQuery(e)(this)}hasShippingQuery(e){return n.has.shippingQuery(e)(this)}reply(e,t,s){var i;let r=this.msg;return this.api.sendMessage(u(this.chatId,"sendMessage"),e,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}replyWithDraft(e,t,s){let i=this.msg;return this.api.sendMessageDraft(u(this.chatId,"sendMessageDraft"),this.update.update_id,e,{...i?.is_topic_message?{message_thread_id:i?.message_thread_id}:{},...t},s)}forwardMessage(e,t,s){var i;let r=this.msg;return this.api.forwardMessage(e,u(this.chatId,"forwardMessage"),u(this.msgId,"forwardMessage"),{direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}forwardMessages(e,t,s,i){var r;let o=this.msg;return this.api.forwardMessages(e,u(this.chatId,"forwardMessages"),t,{direct_messages_topic_id:(r=o?.direct_messages_topic)===null||r===void 0?void 0:r.topic_id,...s},i)}copyMessage(e,t,s){var i;let r=this.msg;return this.api.copyMessage(e,u(this.chatId,"copyMessage"),u(this.msgId,"copyMessage"),{direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}copyMessages(e,t,s,i){var r;let o=this.msg;return this.api.copyMessages(e,u(this.chatId,"copyMessages"),t,{direct_messages_topic_id:(r=o?.direct_messages_topic)===null||r===void 0?void 0:r.topic_id,...s},i)}replyWithPhoto(e,t,s){var i;let r=this.msg;return this.api.sendPhoto(u(this.chatId,"sendPhoto"),e,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}replyWithAudio(e,t,s){var i;let r=this.msg;return this.api.sendAudio(u(this.chatId,"sendAudio"),e,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}replyWithDocument(e,t,s){var i;let r=this.msg;return this.api.sendDocument(u(this.chatId,"sendDocument"),e,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}replyWithVideo(e,t,s){var i;let r=this.msg;return this.api.sendVideo(u(this.chatId,"sendVideo"),e,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}replyWithAnimation(e,t,s){var i;let r=this.msg;return this.api.sendAnimation(u(this.chatId,"sendAnimation"),e,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}replyWithVoice(e,t,s){var i;let r=this.msg;return this.api.sendVoice(u(this.chatId,"sendVoice"),e,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}replyWithVideoNote(e,t,s){var i;let r=this.msg;return this.api.sendVideoNote(u(this.chatId,"sendVideoNote"),e,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}replyWithMediaGroup(e,t,s){var i;let r=this.msg;return this.api.sendMediaGroup(u(this.chatId,"sendMediaGroup"),e,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}replyWithLocation(e,t,s,i){var r;let o=this.msg;return this.api.sendLocation(u(this.chatId,"sendLocation"),e,t,{business_connection_id:this.businessConnectionId,...o?.is_topic_message?{message_thread_id:o.message_thread_id}:{},direct_messages_topic_id:(r=o?.direct_messages_topic)===null||r===void 0?void 0:r.topic_id,...s},i)}editMessageLiveLocation(e,t,s,i){let r=this.inlineMessageId;return r!==void 0?this.api.editMessageLiveLocationInline(r,e,t,{business_connection_id:this.businessConnectionId,...s},i):this.api.editMessageLiveLocation(u(this.chatId,"editMessageLiveLocation"),u(this.msgId,"editMessageLiveLocation"),e,t,{business_connection_id:this.businessConnectionId,...s},i)}stopMessageLiveLocation(e,t){let s=this.inlineMessageId;return s!==void 0?this.api.stopMessageLiveLocationInline(s,{business_connection_id:this.businessConnectionId,...e},t):this.api.stopMessageLiveLocation(u(this.chatId,"stopMessageLiveLocation"),u(this.msgId,"stopMessageLiveLocation"),{business_connection_id:this.businessConnectionId,...e},t)}sendPaidMedia(e,t,s,i){var r,o;let a=this.msg;return this.api.sendPaidMedia(u(this.chatId,"sendPaidMedia"),e,t,{business_connection_id:this.businessConnectionId,...a?.is_topic_message?{message_thread_id:a.message_thread_id}:{},direct_messages_topic_id:(o=(r=this.msg)===null||r===void 0?void 0:r.direct_messages_topic)===null||o===void 0?void 0:o.topic_id,...s},i)}replyWithVenue(e,t,s,i,r,o){var a;let d=this.msg;return this.api.sendVenue(u(this.chatId,"sendVenue"),e,t,s,i,{business_connection_id:this.businessConnectionId,...d?.is_topic_message?{message_thread_id:d.message_thread_id}:{},direct_messages_topic_id:(a=d?.direct_messages_topic)===null||a===void 0?void 0:a.topic_id,...r},o)}replyWithContact(e,t,s,i){var r;let o=this.msg;return this.api.sendContact(u(this.chatId,"sendContact"),e,t,{business_connection_id:this.businessConnectionId,...o?.is_topic_message?{message_thread_id:o.message_thread_id}:{},direct_messages_topic_id:(r=o?.direct_messages_topic)===null||r===void 0?void 0:r.topic_id,...s},i)}replyWithPoll(e,t,s,i){let r=this.msg;return this.api.sendPoll(u(this.chatId,"sendPoll"),e,t,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},...s},i)}replyWithChecklist(e,t,s){return this.api.sendChecklist(u(this.businessConnectionId,"sendChecklist"),u(this.chatId,"sendChecklist"),e,t,s)}editMessageChecklist(e,t,s){var i,r,o,a;let d=u(this.msg,"editMessageChecklist"),c=(a=(r=(i=d.checklist_tasks_done)===null||i===void 0?void 0:i.checklist_message)!==null&&r!==void 0?r:(o=d.checklist_tasks_added)===null||o===void 0?void 0:o.checklist_message)!==null&&a!==void 0?a:d;return this.api.editMessageChecklist(u(this.businessConnectionId,"editMessageChecklist"),u(c.chat.id,"editMessageChecklist"),u(c.message_id,"editMessageChecklist"),e,t,s)}replyWithDice(e,t,s){var i;let r=this.msg;return this.api.sendDice(u(this.chatId,"sendDice"),e,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}replyWithChatAction(e,t,s){let i=this.msg;return this.api.sendChatAction(u(this.chatId,"sendChatAction"),e,{business_connection_id:this.businessConnectionId,message_thread_id:i?.message_thread_id,...t},s)}react(e,t,s){return this.api.setMessageReaction(u(this.chatId,"setMessageReaction"),u(this.msgId,"setMessageReaction"),typeof e=="string"?[{type:"emoji",emoji:e}]:(Array.isArray(e)?e:[e]).map(i=>typeof i=="string"?{type:"emoji",emoji:i}:i),t,s)}getUserProfilePhotos(e,t){return this.api.getUserProfilePhotos(u(this.from,"getUserProfilePhotos").id,e,t)}getUserProfileAudios(e,t){return this.api.getUserProfileAudios(u(this.from,"getUserProfileAudios").id,e,t)}setUserEmojiStatus(e,t){return this.api.setUserEmojiStatus(u(this.from,"setUserEmojiStatus").id,e,t)}getUserChatBoosts(e,t){return this.api.getUserChatBoosts(e??u(this.chatId,"getUserChatBoosts"),u(this.from,"getUserChatBoosts").id,t)}getUserGifts(e,t){return this.api.getUserGifts(u(this.from,"getUserGifts").id,e,t)}getChatGifts(e,t){return this.api.getChatGifts(u(this.chatId,"getChatGifts"),e,t)}getBusinessConnection(e){return this.api.getBusinessConnection(u(this.businessConnectionId,"getBusinessConnection"),e)}getFile(e){var t,s,i,r,o,a;let d=u(this.msg,"getFile"),c=d.photo!==void 0?d.photo[d.photo.length-1]:(a=(o=(r=(i=(s=(t=d.animation)!==null&&t!==void 0?t:d.audio)!==null&&s!==void 0?s:d.document)!==null&&i!==void 0?i:d.video)!==null&&r!==void 0?r:d.video_note)!==null&&o!==void 0?o:d.voice)!==null&&a!==void 0?a:d.sticker;return this.api.getFile(u(c,"getFile").file_id,e)}kickAuthor(...e){return this.banAuthor(...e)}banAuthor(e,t){return this.api.banChatMember(u(this.chatId,"banAuthor"),u(this.from,"banAuthor").id,e,t)}kickChatMember(...e){return this.banChatMember(...e)}banChatMember(e,t,s){return this.api.banChatMember(u(this.chatId,"banChatMember"),e,t,s)}unbanChatMember(e,t,s){return this.api.unbanChatMember(u(this.chatId,"unbanChatMember"),e,t,s)}restrictAuthor(e,t,s){return this.api.restrictChatMember(u(this.chatId,"restrictAuthor"),u(this.from,"restrictAuthor").id,e,t,s)}restrictChatMember(e,t,s,i){return this.api.restrictChatMember(u(this.chatId,"restrictChatMember"),e,t,s,i)}promoteAuthor(e,t){return this.api.promoteChatMember(u(this.chatId,"promoteAuthor"),u(this.from,"promoteAuthor").id,e,t)}promoteChatMember(e,t,s){return this.api.promoteChatMember(u(this.chatId,"promoteChatMember"),e,t,s)}setChatAdministratorAuthorCustomTitle(e,t){return this.api.setChatAdministratorCustomTitle(u(this.chatId,"setChatAdministratorAuthorCustomTitle"),u(this.from,"setChatAdministratorAuthorCustomTitle").id,e,t)}setChatAdministratorCustomTitle(e,t,s){return this.api.setChatAdministratorCustomTitle(u(this.chatId,"setChatAdministratorCustomTitle"),e,t,s)}setAuthorTag(e,t){return this.api.setChatMemberTag(u(this.chatId,"setChatMemberTag"),u(this.from,"setChatMemberTag").id,e,t)}setChatMemberTag(e,t,s){return this.api.setChatMemberTag(u(this.chatId,"setChatMemberTag"),e,t,s)}banChatSenderChat(e,t){return this.api.banChatSenderChat(u(this.chatId,"banChatSenderChat"),e,t)}unbanChatSenderChat(e,t){return this.api.unbanChatSenderChat(u(this.chatId,"unbanChatSenderChat"),e,t)}setChatPermissions(e,t,s){return this.api.setChatPermissions(u(this.chatId,"setChatPermissions"),e,t,s)}exportChatInviteLink(e){return this.api.exportChatInviteLink(u(this.chatId,"exportChatInviteLink"),e)}createChatInviteLink(e,t){return this.api.createChatInviteLink(u(this.chatId,"createChatInviteLink"),e,t)}editChatInviteLink(e,t,s){return this.api.editChatInviteLink(u(this.chatId,"editChatInviteLink"),e,t,s)}createChatSubscriptionInviteLink(e,t,s,i){return this.api.createChatSubscriptionInviteLink(u(this.chatId,"createChatSubscriptionInviteLink"),e,t,s,i)}editChatSubscriptionInviteLink(e,t,s){return this.api.editChatSubscriptionInviteLink(u(this.chatId,"editChatSubscriptionInviteLink"),e,t,s)}revokeChatInviteLink(e,t){return this.api.revokeChatInviteLink(u(this.chatId,"editChatInviteLink"),e,t)}approveChatJoinRequest(e,t){return this.api.approveChatJoinRequest(u(this.chatId,"approveChatJoinRequest"),e,t)}declineChatJoinRequest(e,t){return this.api.declineChatJoinRequest(u(this.chatId,"declineChatJoinRequest"),e,t)}approveSuggestedPost(e,t){return this.api.approveSuggestedPost(u(this.chatId,"approveSuggestedPost"),u(this.msgId,"approveSuggestedPost"),e,t)}declineSuggestedPost(e,t){return this.api.declineSuggestedPost(u(this.chatId,"declineSuggestedPost"),u(this.msgId,"declineSuggestedPost"),e,t)}setChatPhoto(e,t){return this.api.setChatPhoto(u(this.chatId,"setChatPhoto"),e,t)}deleteChatPhoto(e){return this.api.deleteChatPhoto(u(this.chatId,"deleteChatPhoto"),e)}setChatTitle(e,t){return this.api.setChatTitle(u(this.chatId,"setChatTitle"),e,t)}setChatDescription(e,t){return this.api.setChatDescription(u(this.chatId,"setChatDescription"),e,t)}pinChatMessage(e,t,s){return this.api.pinChatMessage(u(this.chatId,"pinChatMessage"),e,{business_connection_id:this.businessConnectionId,...t},s)}unpinChatMessage(e,t,s){return this.api.unpinChatMessage(u(this.chatId,"unpinChatMessage"),e,{business_connection_id:this.businessConnectionId,...t},s)}unpinAllChatMessages(e){return this.api.unpinAllChatMessages(u(this.chatId,"unpinAllChatMessages"),e)}leaveChat(e){return this.api.leaveChat(u(this.chatId,"leaveChat"),e)}getChat(e){return this.api.getChat(u(this.chatId,"getChat"),e)}getChatAdministrators(e){return this.api.getChatAdministrators(u(this.chatId,"getChatAdministrators"),e)}getChatMembersCount(...e){return this.getChatMemberCount(...e)}getChatMemberCount(e){return this.api.getChatMemberCount(u(this.chatId,"getChatMemberCount"),e)}getAuthor(e){return this.api.getChatMember(u(this.chatId,"getAuthor"),u(this.from,"getAuthor").id,e)}getChatMember(e,t){return this.api.getChatMember(u(this.chatId,"getChatMember"),e,t)}setChatStickerSet(e,t){return this.api.setChatStickerSet(u(this.chatId,"setChatStickerSet"),e,t)}deleteChatStickerSet(e){return this.api.deleteChatStickerSet(u(this.chatId,"deleteChatStickerSet"),e)}createForumTopic(e,t,s){return this.api.createForumTopic(u(this.chatId,"createForumTopic"),e,t,s)}editForumTopic(e,t){let s=u(this.msg,"editForumTopic"),i=u(s.message_thread_id,"editForumTopic");return this.api.editForumTopic(s.chat.id,i,e,t)}closeForumTopic(e){let t=u(this.msg,"closeForumTopic"),s=u(t.message_thread_id,"closeForumTopic");return this.api.closeForumTopic(t.chat.id,s,e)}reopenForumTopic(e){let t=u(this.msg,"reopenForumTopic"),s=u(t.message_thread_id,"reopenForumTopic");return this.api.reopenForumTopic(t.chat.id,s,e)}deleteForumTopic(e){let t=u(this.msg,"deleteForumTopic"),s=u(t.message_thread_id,"deleteForumTopic");return this.api.deleteForumTopic(t.chat.id,s,e)}unpinAllForumTopicMessages(e){let t=u(this.msg,"unpinAllForumTopicMessages"),s=u(t.message_thread_id,"unpinAllForumTopicMessages");return this.api.unpinAllForumTopicMessages(t.chat.id,s,e)}editGeneralForumTopic(e,t){return this.api.editGeneralForumTopic(u(this.chatId,"editGeneralForumTopic"),e,t)}closeGeneralForumTopic(e){return this.api.closeGeneralForumTopic(u(this.chatId,"closeGeneralForumTopic"),e)}reopenGeneralForumTopic(e){return this.api.reopenGeneralForumTopic(u(this.chatId,"reopenGeneralForumTopic"),e)}hideGeneralForumTopic(e){return this.api.hideGeneralForumTopic(u(this.chatId,"hideGeneralForumTopic"),e)}unhideGeneralForumTopic(e){return this.api.unhideGeneralForumTopic(u(this.chatId,"unhideGeneralForumTopic"),e)}unpinAllGeneralForumTopicMessages(e){return this.api.unpinAllGeneralForumTopicMessages(u(this.chatId,"unpinAllGeneralForumTopicMessages"),e)}answerCallbackQuery(e,t){return this.api.answerCallbackQuery(u(this.callbackQuery,"answerCallbackQuery").id,typeof e=="string"?{text:e}:e,t)}setChatMenuButton(e,t){return this.api.setChatMenuButton(e,t)}getChatMenuButton(e,t){return this.api.getChatMenuButton(e,t)}setMyDefaultAdministratorRights(e,t){return this.api.setMyDefaultAdministratorRights(e,t)}getMyDefaultAdministratorRights(e,t){return this.api.getMyDefaultAdministratorRights(e,t)}editMessageText(e,t,s){var i,r,o,a,d;let c=this.inlineMessageId;return c!==void 0?this.api.editMessageTextInline(c,e,{business_connection_id:this.businessConnectionId,...t},s):this.api.editMessageText(u(this.chatId,"editMessageText"),u((a=(r=(i=this.msg)===null||i===void 0?void 0:i.message_id)!==null&&r!==void 0?r:(o=this.messageReaction)===null||o===void 0?void 0:o.message_id)!==null&&a!==void 0?a:(d=this.messageReactionCount)===null||d===void 0?void 0:d.message_id,"editMessageText"),e,{business_connection_id:this.businessConnectionId,...t},s)}editMessageCaption(e,t){var s,i,r,o,a;let d=this.inlineMessageId;return d!==void 0?this.api.editMessageCaptionInline(d,{business_connection_id:this.businessConnectionId,...e},t):this.api.editMessageCaption(u(this.chatId,"editMessageCaption"),u((o=(i=(s=this.msg)===null||s===void 0?void 0:s.message_id)!==null&&i!==void 0?i:(r=this.messageReaction)===null||r===void 0?void 0:r.message_id)!==null&&o!==void 0?o:(a=this.messageReactionCount)===null||a===void 0?void 0:a.message_id,"editMessageCaption"),{business_connection_id:this.businessConnectionId,...e},t)}editMessageMedia(e,t,s){var i,r,o,a,d;let c=this.inlineMessageId;return c!==void 0?this.api.editMessageMediaInline(c,e,{business_connection_id:this.businessConnectionId,...t},s):this.api.editMessageMedia(u(this.chatId,"editMessageMedia"),u((a=(r=(i=this.msg)===null||i===void 0?void 0:i.message_id)!==null&&r!==void 0?r:(o=this.messageReaction)===null||o===void 0?void 0:o.message_id)!==null&&a!==void 0?a:(d=this.messageReactionCount)===null||d===void 0?void 0:d.message_id,"editMessageMedia"),e,{business_connection_id:this.businessConnectionId,...t},s)}editMessageReplyMarkup(e,t){var s,i,r,o,a;let d=this.inlineMessageId;return d!==void 0?this.api.editMessageReplyMarkupInline(d,{business_connection_id:this.businessConnectionId,...e},t):this.api.editMessageReplyMarkup(u(this.chatId,"editMessageReplyMarkup"),u((o=(i=(s=this.msg)===null||s===void 0?void 0:s.message_id)!==null&&i!==void 0?i:(r=this.messageReaction)===null||r===void 0?void 0:r.message_id)!==null&&o!==void 0?o:(a=this.messageReactionCount)===null||a===void 0?void 0:a.message_id,"editMessageReplyMarkup"),{business_connection_id:this.businessConnectionId,...e},t)}stopPoll(e,t){var s,i,r,o,a;return this.api.stopPoll(u(this.chatId,"stopPoll"),u((o=(i=(s=this.msg)===null||s===void 0?void 0:s.message_id)!==null&&i!==void 0?i:(r=this.messageReaction)===null||r===void 0?void 0:r.message_id)!==null&&o!==void 0?o:(a=this.messageReactionCount)===null||a===void 0?void 0:a.message_id,"stopPoll"),{business_connection_id:this.businessConnectionId,...e},t)}deleteMessage(e){var t,s,i,r,o;return this.api.deleteMessage(u(this.chatId,"deleteMessage"),u((r=(s=(t=this.msg)===null||t===void 0?void 0:t.message_id)!==null&&s!==void 0?s:(i=this.messageReaction)===null||i===void 0?void 0:i.message_id)!==null&&r!==void 0?r:(o=this.messageReactionCount)===null||o===void 0?void 0:o.message_id,"deleteMessage"),e)}deleteMessages(e,t){return this.api.deleteMessages(u(this.chatId,"deleteMessages"),e,t)}deleteBusinessMessages(e,t){return this.api.deleteBusinessMessages(u(this.businessConnectionId,"deleteBusinessMessages"),e,t)}setBusinessAccountName(e,t,s){return this.api.setBusinessAccountName(u(this.businessConnectionId,"setBusinessAccountName"),e,t,s)}setBusinessAccountUsername(e,t){return this.api.setBusinessAccountUsername(u(this.businessConnectionId,"setBusinessAccountUsername"),e,t)}setBusinessAccountBio(e,t){return this.api.setBusinessAccountBio(u(this.businessConnectionId,"setBusinessAccountBio"),e,t)}setBusinessAccountProfilePhoto(e,t,s){return this.api.setBusinessAccountProfilePhoto(u(this.businessConnectionId,"setBusinessAccountProfilePhoto"),e,t,s)}removeBusinessAccountProfilePhoto(e,t){return this.api.removeBusinessAccountProfilePhoto(u(this.businessConnectionId,"removeBusinessAccountProfilePhoto"),e,t)}setBusinessAccountGiftSettings(e,t,s){return this.api.setBusinessAccountGiftSettings(u(this.businessConnectionId,"setBusinessAccountGiftSettings"),e,t,s)}getBusinessAccountStarBalance(e){return this.api.getBusinessAccountStarBalance(u(this.businessConnectionId,"getBusinessAccountStarBalance"),e)}transferBusinessAccountStars(e,t){return this.api.transferBusinessAccountStars(u(this.businessConnectionId,"transferBusinessAccountStars"),e,t)}getBusinessAccountGifts(e,t){return this.api.getBusinessAccountGifts(u(this.businessConnectionId,"getBusinessAccountGifts"),e,t)}convertGiftToStars(e,t){return this.api.convertGiftToStars(u(this.businessConnectionId,"convertGiftToStars"),e,t)}upgradeGift(e,t,s){return this.api.upgradeGift(u(this.businessConnectionId,"upgradeGift"),e,t,s)}transferGift(e,t,s,i){return this.api.transferGift(u(this.businessConnectionId,"transferGift"),e,t,s,i)}postStory(e,t,s,i){return this.api.postStory(u(this.businessConnectionId,"postStory"),e,t,s,i)}repostStory(e,t,s){var i;let r=u((i=this.msg)===null||i===void 0?void 0:i.story,"repostStory");return this.api.repostStory(u(this.businessConnectionId,"repostStory"),r.chat.id,r.id,e,t,s)}editStory(e,t,s,i){return this.api.editStory(u(this.businessConnectionId,"editStory"),e,t,s,i)}deleteStory(e,t){return this.api.deleteStory(u(this.businessConnectionId,"deleteStory"),e,t)}replyWithSticker(e,t,s){var i;let r=this.msg;return this.api.sendSticker(u(this.chatId,"sendSticker"),e,{business_connection_id:this.businessConnectionId,...r?.is_topic_message?{message_thread_id:r.message_thread_id}:{},direct_messages_topic_id:(i=r?.direct_messages_topic)===null||i===void 0?void 0:i.topic_id,...t},s)}getCustomEmojiStickers(e){var t,s;return this.api.getCustomEmojiStickers(((s=(t=this.msg)===null||t===void 0?void 0:t.entities)!==null&&s!==void 0?s:[]).filter(i=>i.type==="custom_emoji").map(i=>i.custom_emoji_id),e)}replyWithGift(e,t,s){return this.api.sendGift(u(this.from,"sendGift").id,e,t,s)}giftPremiumSubscription(e,t,s,i){return this.api.giftPremiumSubscription(u(this.from,"giftPremiumSubscription").id,e,t,s,i)}replyWithGiftToChannel(e,t,s){return this.api.sendGiftToChannel(u(this.chat,"sendGift").id,e,t,s)}answerInlineQuery(e,t,s){return this.api.answerInlineQuery(u(this.inlineQuery,"answerInlineQuery").id,e,t,s)}savePreparedInlineMessage(e,t,s){return this.api.savePreparedInlineMessage(u(this.from,"savePreparedInlineMessage").id,e,t,s)}replyWithInvoice(e,t,s,i,r,o,a){var d;let c=this.msg;return this.api.sendInvoice(u(this.chatId,"sendInvoice"),e,t,s,i,r,{...c?.is_topic_message?{message_thread_id:c.message_thread_id}:{},direct_messages_topic_id:(d=c?.direct_messages_topic)===null||d===void 0?void 0:d.topic_id,...o},a)}answerShippingQuery(e,t,s){return this.api.answerShippingQuery(u(this.shippingQuery,"answerShippingQuery").id,e,t,s)}answerPreCheckoutQuery(e,t,s){return this.api.answerPreCheckoutQuery(u(this.preCheckoutQuery,"answerPreCheckoutQuery").id,e,typeof t=="string"?{error_message:t}:t,s)}refundStarPayment(e){var t;return this.api.refundStarPayment(u(this.from,"refundStarPayment").id,u((t=this.msg)===null||t===void 0?void 0:t.successful_payment,"refundStarPayment").telegram_payment_charge_id,e)}editUserStarSubscription(e,t,s){return this.api.editUserStarSubscription(u(this.from,"editUserStarSubscription").id,e,t,s)}verifyUser(e,t){return this.api.verifyUser(u(this.from,"verifyUser").id,e,t)}verifyChat(e,t){return this.api.verifyChat(u(this.chatId,"verifyChat"),e,t)}removeUserVerification(e){return this.api.removeUserVerification(u(this.from,"removeUserVerification").id,e)}removeChatVerification(e){return this.api.removeChatVerification(u(this.chatId,"removeChatVerification"),e)}readBusinessMessage(e){return this.api.readBusinessMessage(u(this.businessConnectionId,"readBusinessMessage"),u(this.chatId,"readBusinessMessage"),u(this.msgId,"readBusinessMessage"),e)}setPassportDataErrors(e,t){return this.api.setPassportDataErrors(u(this.from,"setPassportDataErrors").id,e,t)}replyWithGame(e,t,s){let i=this.msg;return this.api.sendGame(u(this.chatId,"sendGame"),e,{business_connection_id:this.businessConnectionId,...i?.is_topic_message?{message_thread_id:i.message_thread_id}:{},...t},s)}};ue.Context=oe;oe.has=S;function u(n,e){if(n===void 0)throw new Error(`Missing information for API call to ${e}`);return n}function $(n){return ae(n).map(e=>typeof e=="string"?t=>t===e?e:null:t=>t.match(e))}function L(n,e,t){for(let s of t){let i=s(e);if(i)return n.match=i,!0}return!1}function ae(n){return Array.isArray(n)?n:[n]}});var Re=y(q=>{"use strict";h();Object.defineProperty(q,"__esModule",{value:!0});q.Composer=q.BotError=void 0;q.run=bt;var I=de(),ce=class extends Error{constructor(e,t){super(qs(e)),this.error=e,this.ctx=t,this.name="BotError",e instanceof Error&&(this.stack=e.stack)}};q.BotError=ce;function qs(n){let e;if(n instanceof Error)e=`${n.name} in middleware: ${n.message}`;else{let t=typeof n;switch(e=`Non-error value of type ${t} thrown in middleware`,t){case"bigint":case"boolean":case"number":case"symbol":e+=`: ${n}`;break;case"string":e+=`: ${String(n).substring(0,50)}`;break;default:e+="!";break}}return e}function V(n){return typeof n=="function"?n:(e,t)=>n.middleware()(e,t)}function vt(n,e){return async(t,s)=>{let i=!1;await n(t,async()=>{if(i)throw new Error("`next` already called before!");i=!0,await e(t,s)})}}function Ee(n,e){return e()}var Us=()=>Promise.resolve();async function bt(n,e){await n(e,Us)}var je=class n{constructor(...e){this.handler=e.length===0?Ee:e.map(V).reduce(vt)}middleware(){return this.handler}use(...e){let t=new n(...e);return this.handler=vt(this.handler,V(t)),t}on(e,...t){return this.filter(I.Context.has.filterQuery(e),...t)}hears(e,...t){return this.filter(I.Context.has.text(e),...t)}command(e,...t){return this.filter(I.Context.has.command(e),...t)}reaction(e,...t){return this.filter(I.Context.has.reaction(e),...t)}chatType(e,...t){return this.filter(I.Context.has.chatType(e),...t)}callbackQuery(e,...t){return this.filter(I.Context.has.callbackQuery(e),...t)}gameQuery(e,...t){return this.filter(I.Context.has.gameQuery(e),...t)}inlineQuery(e,...t){return this.filter(I.Context.has.inlineQuery(e),...t)}chosenInlineResult(e,...t){return this.filter(I.Context.has.chosenInlineResult(e),...t)}preCheckoutQuery(e,...t){return this.filter(I.Context.has.preCheckoutQuery(e),...t)}shippingQuery(e,...t){return this.filter(I.Context.has.shippingQuery(e),...t)}filter(e,...t){let s=new n(...t);return this.branch(e,s,Ee),s}drop(e,...t){return this.filter(async s=>!await e(s),...t)}fork(...e){let t=new n(...e),s=V(t);return this.use((i,r)=>Promise.all([r(),bt(s,i)])),t}lazy(e){return this.use(async(t,s)=>{let i=await e(t),r=Array.isArray(i)?i:[i];await V(new n(...r))(t,s)})}route(e,t,s=Ee){return this.lazy(async i=>{var r;let o=await e(i);return(r=o===void 0||!t[o]?s:t[o])!==null&&r!==void 0?r:[]})}branch(e,t,s){return this.lazy(async i=>await e(i)?t:s)}errorBoundary(e,...t){let s=new n(...t),i=V(s);return this.use(async(r,o)=>{let a=!1,d=()=>(a=!0,Promise.resolve());try{await i(r,d)}catch(c){a=!1,await e(new ce(c,r),d)}a&&await o()}),s}};q.Composer=je});var j=y(A=>{"use strict";h();Object.defineProperty(A,"__esModule",{value:!0});A.defaultAdapter=A.itrToStream=A.debug=void 0;A.baseFetchConfig=zs;var Gs=K("http"),Os=K("https"),Ds=K("stream"),Qs=ws();Object.defineProperty(A,"debug",{enumerable:!0,get:function(){return Qs.debug}});var Ns=n=>Ds.Readable.from(n,{objectMode:!1});A.itrToStream=Ns;var xs=new Map,Ws=new Map;function wt(n,e,t){let s=n.get(e);return s===void 0&&(s=t(),n.set(e,s)),s}function zs(n){return n.startsWith("https:")?{compress:!0,agent:wt(Ws,n,()=>new Os.Agent({keepAlive:!0}))}:n.startsWith("http:")?{agent:wt(xs,n,()=>new Gs.Agent({keepAlive:!0}))}:{}}A.defaultAdapter="express"});var pe=y(R=>{"use strict";h();Object.defineProperty(R,"__esModule",{value:!0});R.HttpError=R.GrammyError=void 0;R.toGrammyError=Ks;R.toHttpError=Vs;var Hs=j(),Ct=(0,Hs.debug)("grammy:warn"),le=class extends Error{constructor(e,t,s,i){var r;super(`${e} (${t.error_code}: ${t.description})`),this.method=s,this.payload=i,this.ok=!1,this.name="GrammyError",this.error_code=t.error_code,this.description=t.description,this.parameters=(r=t.parameters)!==null&&r!==void 0?r:{}}};R.GrammyError=le;function Ks(n,e,t){switch(n.error_code){case 401:Ct("Error 401 means that your bot token is wrong, talk to https://t.me/BotFather to check it.");break;case 409:Ct("Error 409 means that you are running your bot several times on long polling. Consider revoking the bot token if you believe that no other instance is running.");break}return new le(`Call to '${e}' failed!`,n,e,t)}var he=class extends Error{constructor(e,t){super(e),this.error=t,this.name="HttpError"}};R.HttpError=he;function Ys(n){return typeof n=="object"&&n!==null&&"status"in n&&"statusText"in n}function Vs(n,e,t){let s=`Network request for '${n}' failed!`;return Ys(t)&&(s+=` (${t.status}: ${t.statusText})`),e&&t instanceof Error&&(s+=` ${t.message}`),new he(s,t)}});var Mt=y(()=>{h()});var kt=y(T=>{"use strict";h();var Js=T&&T.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Xs=T&&T.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Js(e,n,t)};Object.defineProperty(T,"__esModule",{value:!0});T.InputFile=void 0;var It=K("fs"),Zs=rt(),ge=K("path"),ei=j(),ti=(0,ei.debug)("grammy:warn");Xs(Mt(),T);var Be=class n{constructor(e,t){this.consumed=!1,this.fileData=e,t??(t=this.guessFilename(e)),this.filename=t,typeof e=="string"&&(e.startsWith("http:")||e.startsWith("https:"))&&ti(`InputFile received the local file path '${e}' that looks like a URL. Is this a mistake?`)}guessFilename(e){if(typeof e=="string")return(0,ge.basename)(e);if("url"in e)return(0,ge.basename)(e.url);if(e instanceof URL){if(e.pathname!=="/"){let t=(0,ge.basename)(e.pathname);if(t)return t}return(0,ge.basename)(e.hostname)}}async toRaw(){if(this.consumed)throw new Error("Cannot reuse InputFile data source!");let e=this.fileData;return typeof e=="string"?(0,It.createReadStream)(e):e instanceof URL?e.protocol==="file"?(0,It.createReadStream)(e.pathname):St(e):"url"in e?St(e.url):e instanceof Uint8Array?e:typeof e=="function"?new n(await e()).toRaw():(this.consumed=!0,e)}toJSON(){throw new Error("InputFile instances must be sent via grammY")}};T.InputFile=Be;async function*St(n){let{body:e}=await(0,Zs.default)(n);for await(let t of e){if(typeof t=="string")throw new Error(`Could not transfer file, received string data instead of bytes from '${n}'`);yield t}}});var Fe=y(U=>{"use strict";h();var si=U&&U.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),ii=U&&U.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&si(e,n,t)};Object.defineProperty(U,"__esModule",{value:!0});ii(kt(),U)});var Pt=y(X=>{"use strict";h();Object.defineProperty(X,"__esModule",{value:!0});X.requiresFormDataUpload=$e;X.createJsonPayload=ri;X.createFormDataPayload=ai;var ni=j(),me=Fe();function $e(n){return n instanceof me.InputFile||typeof n=="object"&&n!==null&&Object.values(n).some(e=>Array.isArray(e)?e.some($e):e instanceof me.InputFile||$e(e))}function At(n){return JSON.stringify(n,(e,t)=>t??void 0)}function ri(n){return{method:"POST",headers:{"content-type":"application/json",connection:"keep-alive"},body:At(n)}}async function*oi(n,e){try{yield*n}catch(t){e(t)}}function ai(n,e){let t=ui(),s=di(n,t),i=oi(s,e),r=(0,ni.itrToStream)(i);return{method:"POST",headers:{"content-type":`multipart/form-data; boundary=${t}`,connection:"keep-alive"},body:r}}function ui(){return"----------"+Tt(32)}function Tt(n=16){return Array.from(Array(n)).map(()=>Math.random().toString(36)[2]||0).join("")}var J=new TextEncoder;async function*di(n,e){let t=Le(n);yield J.encode(`--${e}\r
4
- `);let s=J.encode(`\r
5
- --${e}\r
6
- `),i=!0;for(let[r,o]of Object.entries(n))o!=null&&(i||(yield s),yield ci(r,o instanceof me.InputFile?o.toJSON():typeof o=="object"?At(o):o),i=!1);for(let{id:r,origin:o,file:a}of t)i||(yield s),yield*li(r,o,a),i=!1;yield J.encode(`\r
7
- --${e}--\r
8
- `)}function Le(n){return typeof n!="object"||n===null?[]:Object.entries(n).flatMap(([e,t])=>{if(Array.isArray(t))return t.flatMap(s=>Le(s));if(t instanceof me.InputFile){let s=Tt();Object.assign(t,{toJSON:()=>`attach://${s}`});let i=e==="media"&&"type"in n&&typeof n.type=="string"?n.type:e;return{id:s,origin:i,file:t}}else return Le(t)})}function ci(n,e){return J.encode(`content-disposition:form-data;name="${n}"\r
9
- \r
10
- ${e}`)}async function*li(n,e,t){let s=t.filename||`${e}.${hi(e)}`;if(s.includes("\r")||s.includes(`
11
- `))throw new Error(`File paths cannot contain carriage-return (\\r) or newline (\\n) characters! Filename for property '${e}' was:
12
- """
13
- ${s}
14
- """`);yield J.encode(`content-disposition:form-data;name="${n}";filename=${s}\r
15
- content-type:application/octet-stream\r
16
- \r
17
- `);let i=await t.toRaw();i instanceof Uint8Array?yield i:yield*i}function hi(n){switch(n){case"certificate":return"pem";case"photo":case"thumbnail":return"jpg";case"voice":return"ogg";case"audio":return"mp3";case"animation":case"video":case"video_note":return"mp4";case"sticker":return"webp";default:return"dat"}}});var qe=y(O=>{"use strict";h();Object.defineProperty(O,"__esModule",{value:!0});O.fetch=O.AbortController=void 0;var pi=Ms();Object.defineProperty(O,"AbortController",{enumerable:!0,get:function(){return pi.AbortController}});var gi=rt();Object.defineProperty(O,"fetch",{enumerable:!0,get:function(){return gi.default}})});var Bt=y(Ge=>{"use strict";h();Object.defineProperty(Ge,"__esModule",{value:!0});Ge.createRawApi=_i;var jt=j(),Et=pe(),fe=Pt(),mi=(0,jt.debug)("grammy:core");function fi(n,e){return(t,s,i)=>e(n,t,s,i)}var Ue=class{constructor(e,t={},s={}){var i,r,o,a,d,c;this.token=e,this.webhookReplyEnvelope=s,this.hasUsedWebhookReply=!1,this.installedTransformers=[],this.call=async(g,w,M)=>{let v=w??{};mi(`Calling ${g}`),M!==void 0&&Mi(g,v,M);let B=this.options,st=(0,fe.requiresFormDataUpload)(v);if(this.webhookReplyEnvelope.send!==void 0&&!this.hasUsedWebhookReply&&!st&&B.canUseWebhookReply(g)){this.hasUsedWebhookReply=!0;let F=(0,fe.createJsonPayload)({...v,method:g});return await this.webhookReplyEnvelope.send(F.body),{ok:!0,result:!0}}let Ie=Ci(M),Se=bi(Ie,B.timeoutSeconds,g),it=wi(Ie),fs=B.buildUrl(B.apiRoot,this.token,g,B.environment),_s=st?(0,fe.createFormDataPayload)(v,F=>it.catch(F)):(0,fe.createJsonPayload)(v),ys=Ie.signal,vs={...B.baseFetchConfig,signal:ys,..._s},bs=[this.fetch(fs,vs).then(F=>F.json()),it.promise,Se.promise];try{return await Promise.race(bs)}catch(F){throw(0,Et.toHttpError)(g,B.sensitiveLogs,F)}finally{Se.handle!==void 0&&clearTimeout(Se.handle)}};let l=(i=t.apiRoot)!==null&&i!==void 0?i:"https://api.telegram.org",p=(r=t.environment)!==null&&r!==void 0?r:"prod",{fetch:m}=t,_=m??Rt.fetch;if(this.options={apiRoot:l,environment:p,buildUrl:(o=t.buildUrl)!==null&&o!==void 0?o:yi,timeoutSeconds:(a=t.timeoutSeconds)!==null&&a!==void 0?a:500,baseFetchConfig:{...(0,jt.baseFetchConfig)(l),...t.baseFetchConfig},canUseWebhookReply:(d=t.canUseWebhookReply)!==null&&d!==void 0?d:()=>!1,sensitiveLogs:(c=t.sensitiveLogs)!==null&&c!==void 0?c:!1,fetch:(...g)=>_(...g)},this.fetch=this.options.fetch,this.options.apiRoot.endsWith("/"))throw new Error(`Remove the trailing '/' from the 'apiRoot' option (use '${this.options.apiRoot.substring(0,this.options.apiRoot.length-1)}' instead of '${this.options.apiRoot}')`)}use(...e){return this.call=e.reduce(fi,this.call),this.installedTransformers.push(...e),this}async callApi(e,t,s){let i=await this.call(e,t,s);if(i.ok)return i.result;throw(0,Et.toGrammyError)(i,e,t)}};function _i(n,e,t){let s=new Ue(n,e,t),i={get(d,c){return c==="toJSON"?"__internal":c==="getMe"||c==="getWebhookInfo"||c==="getForumTopicIconStickers"||c==="getAvailableGifts"||c==="logOut"||c==="close"||c==="getMyStarBalance"||c==="removeMyProfilePhoto"?s.callApi.bind(s,c,{}):s.callApi.bind(s,c)},...vi},r=new Proxy({},i),o=s.installedTransformers,a={raw:r,installedTransformers:o,use:(...d)=>(s.use(...d),a)};return a}var yi=(n,e,t,s)=>`${n}/bot${e}/${s==="test"?"test/":""}${t}`,vi={set(){return!1},defineProperty(){return!1},deleteProperty(){return!1},ownKeys(){return[]}};function bi(n,e,t){let s;return{promise:new Promise((r,o)=>{s=setTimeout(()=>{let a=`Request to '${t}' timed out after ${e} seconds`;o(new Error(a)),n.abort()},1e3*e)}),handle:s}}function wi(n){let e=s=>{throw s};return{promise:new Promise((s,i)=>{e=r=>{i(r),n.abort()}}),catch:e}}function Ci(n){let e=new Rt.AbortController;if(n===void 0)return e;let t=n;function s(){e.abort(),t.removeEventListener("abort",s)}return t.aborted?s():t.addEventListener("abort",s),{abort:s,signal:e.signal}}function Mi(n,e,t){if(typeof t?.addEventListener=="function")return;let s=JSON.stringify(e);s.length>20&&(s=s.substring(0,16)+" ...");let i=JSON.stringify(t);throw i.length>20&&(i=i.substring(0,16)+" ..."),new Error(`Incorrect abort signal instance found! You passed two payloads to '${n}' but you should merge the second one containing '${i}' into the first one containing '${s}'! If you are using context shortcuts, you may want to use a method on 'ctx.api' instead.
18
-
19
- If you want to prevent such mistakes in the future, consider using TypeScript. https://www.typescriptlang.org/`)}var Rt=qe()});var De=y(_e=>{"use strict";h();Object.defineProperty(_e,"__esModule",{value:!0});_e.Api=void 0;var Ii=Bt(),Oe=class{constructor(e,t,s){this.token=e,this.options=t;let{raw:i,use:r,installedTransformers:o}=(0,Ii.createRawApi)(e,t,s);this.raw=i,this.config={use:r,installedTransformers:()=>o.slice()}}getUpdates(e,t){return this.raw.getUpdates({...e},t)}setWebhook(e,t,s){return this.raw.setWebhook({url:e,...t},s)}deleteWebhook(e,t){return this.raw.deleteWebhook({...e},t)}getWebhookInfo(e){return this.raw.getWebhookInfo(e)}getMe(e){return this.raw.getMe(e)}logOut(e){return this.raw.logOut(e)}close(e){return this.raw.close(e)}sendMessage(e,t,s,i){return this.raw.sendMessage({chat_id:e,text:t,...s},i)}sendMessageDraft(e,t,s,i,r){return this.raw.sendMessageDraft({chat_id:e,draft_id:t,text:s,...i},r)}forwardMessage(e,t,s,i,r){return this.raw.forwardMessage({chat_id:e,from_chat_id:t,message_id:s,...i},r)}forwardMessages(e,t,s,i,r){return this.raw.forwardMessages({chat_id:e,from_chat_id:t,message_ids:s,...i},r)}copyMessage(e,t,s,i,r){return this.raw.copyMessage({chat_id:e,from_chat_id:t,message_id:s,...i},r)}copyMessages(e,t,s,i,r){return this.raw.copyMessages({chat_id:e,from_chat_id:t,message_ids:s,...i},r)}sendPhoto(e,t,s,i){return this.raw.sendPhoto({chat_id:e,photo:t,...s},i)}sendAudio(e,t,s,i){return this.raw.sendAudio({chat_id:e,audio:t,...s},i)}sendDocument(e,t,s,i){return this.raw.sendDocument({chat_id:e,document:t,...s},i)}sendVideo(e,t,s,i){return this.raw.sendVideo({chat_id:e,video:t,...s},i)}sendAnimation(e,t,s,i){return this.raw.sendAnimation({chat_id:e,animation:t,...s},i)}sendVoice(e,t,s,i){return this.raw.sendVoice({chat_id:e,voice:t,...s},i)}sendVideoNote(e,t,s,i){return this.raw.sendVideoNote({chat_id:e,video_note:t,...s},i)}sendMediaGroup(e,t,s,i){return this.raw.sendMediaGroup({chat_id:e,media:t,...s},i)}sendLocation(e,t,s,i,r){return this.raw.sendLocation({chat_id:e,latitude:t,longitude:s,...i},r)}editMessageLiveLocation(e,t,s,i,r,o){return this.raw.editMessageLiveLocation({chat_id:e,message_id:t,latitude:s,longitude:i,...r},o)}editMessageLiveLocationInline(e,t,s,i,r){return this.raw.editMessageLiveLocation({inline_message_id:e,latitude:t,longitude:s,...i},r)}stopMessageLiveLocation(e,t,s,i){return this.raw.stopMessageLiveLocation({chat_id:e,message_id:t,...s},i)}stopMessageLiveLocationInline(e,t,s){return this.raw.stopMessageLiveLocation({inline_message_id:e,...t},s)}sendPaidMedia(e,t,s,i,r){return this.raw.sendPaidMedia({chat_id:e,star_count:t,media:s,...i},r)}sendVenue(e,t,s,i,r,o,a){return this.raw.sendVenue({chat_id:e,latitude:t,longitude:s,title:i,address:r,...o},a)}sendContact(e,t,s,i,r){return this.raw.sendContact({chat_id:e,phone_number:t,first_name:s,...i},r)}sendPoll(e,t,s,i,r){let o=s.map(a=>typeof a=="string"?{text:a}:a);return this.raw.sendPoll({chat_id:e,question:t,options:o,...i},r)}sendChecklist(e,t,s,i,r){return this.raw.sendChecklist({business_connection_id:e,chat_id:t,checklist:s,...i},r)}editMessageChecklist(e,t,s,i,r,o){return this.raw.editMessageChecklist({business_connection_id:e,chat_id:t,message_id:s,checklist:i,...r},o)}sendDice(e,t,s,i){return this.raw.sendDice({chat_id:e,emoji:t,...s},i)}setMessageReaction(e,t,s,i,r){return this.raw.setMessageReaction({chat_id:e,message_id:t,reaction:s,...i},r)}sendChatAction(e,t,s,i){return this.raw.sendChatAction({chat_id:e,action:t,...s},i)}getUserProfilePhotos(e,t,s){return this.raw.getUserProfilePhotos({user_id:e,...t},s)}getUserProfileAudios(e,t,s){return this.raw.getUserProfileAudios({user_id:e,...t},s)}setUserEmojiStatus(e,t,s){return this.raw.setUserEmojiStatus({user_id:e,...t},s)}getUserChatBoosts(e,t,s){return this.raw.getUserChatBoosts({chat_id:e,user_id:t},s)}getUserGifts(e,t,s){return this.raw.getUserGifts({user_id:e,...t},s)}getChatGifts(e,t,s){return this.raw.getChatGifts({chat_id:e,...t},s)}getBusinessConnection(e,t){return this.raw.getBusinessConnection({business_connection_id:e},t)}getFile(e,t){return this.raw.getFile({file_id:e},t)}kickChatMember(...e){return this.banChatMember(...e)}banChatMember(e,t,s,i){return this.raw.banChatMember({chat_id:e,user_id:t,...s},i)}unbanChatMember(e,t,s,i){return this.raw.unbanChatMember({chat_id:e,user_id:t,...s},i)}restrictChatMember(e,t,s,i,r){return this.raw.restrictChatMember({chat_id:e,user_id:t,permissions:s,...i},r)}promoteChatMember(e,t,s,i){return this.raw.promoteChatMember({chat_id:e,user_id:t,...s},i)}setChatAdministratorCustomTitle(e,t,s,i){return this.raw.setChatAdministratorCustomTitle({chat_id:e,user_id:t,custom_title:s},i)}setChatMemberTag(e,t,s,i){return this.raw.setChatMemberTag({chat_id:e,user_id:t,tag:s},i)}banChatSenderChat(e,t,s){return this.raw.banChatSenderChat({chat_id:e,sender_chat_id:t},s)}unbanChatSenderChat(e,t,s){return this.raw.unbanChatSenderChat({chat_id:e,sender_chat_id:t},s)}setChatPermissions(e,t,s,i){return this.raw.setChatPermissions({chat_id:e,permissions:t,...s},i)}exportChatInviteLink(e,t){return this.raw.exportChatInviteLink({chat_id:e},t)}createChatInviteLink(e,t,s){return this.raw.createChatInviteLink({chat_id:e,...t},s)}editChatInviteLink(e,t,s,i){return this.raw.editChatInviteLink({chat_id:e,invite_link:t,...s},i)}createChatSubscriptionInviteLink(e,t,s,i,r){return this.raw.createChatSubscriptionInviteLink({chat_id:e,subscription_period:t,subscription_price:s,...i},r)}editChatSubscriptionInviteLink(e,t,s,i){return this.raw.editChatSubscriptionInviteLink({chat_id:e,invite_link:t,...s},i)}revokeChatInviteLink(e,t,s){return this.raw.revokeChatInviteLink({chat_id:e,invite_link:t},s)}approveChatJoinRequest(e,t,s){return this.raw.approveChatJoinRequest({chat_id:e,user_id:t},s)}declineChatJoinRequest(e,t,s){return this.raw.declineChatJoinRequest({chat_id:e,user_id:t},s)}approveSuggestedPost(e,t,s,i){return this.raw.approveSuggestedPost({chat_id:e,message_id:t,...s},i)}declineSuggestedPost(e,t,s,i){return this.raw.declineSuggestedPost({chat_id:e,message_id:t,...s},i)}setChatPhoto(e,t,s){return this.raw.setChatPhoto({chat_id:e,photo:t},s)}deleteChatPhoto(e,t){return this.raw.deleteChatPhoto({chat_id:e},t)}setChatTitle(e,t,s){return this.raw.setChatTitle({chat_id:e,title:t},s)}setChatDescription(e,t,s){return this.raw.setChatDescription({chat_id:e,description:t},s)}pinChatMessage(e,t,s,i){return this.raw.pinChatMessage({chat_id:e,message_id:t,...s},i)}unpinChatMessage(e,t,s,i){return this.raw.unpinChatMessage({chat_id:e,message_id:t,...s},i)}unpinAllChatMessages(e,t){return this.raw.unpinAllChatMessages({chat_id:e},t)}leaveChat(e,t){return this.raw.leaveChat({chat_id:e},t)}getChat(e,t){return this.raw.getChat({chat_id:e},t)}getChatAdministrators(e,t){return this.raw.getChatAdministrators({chat_id:e},t)}getChatMembersCount(...e){return this.getChatMemberCount(...e)}getChatMemberCount(e,t){return this.raw.getChatMemberCount({chat_id:e},t)}getChatMember(e,t,s){return this.raw.getChatMember({chat_id:e,user_id:t},s)}setChatStickerSet(e,t,s){return this.raw.setChatStickerSet({chat_id:e,sticker_set_name:t},s)}deleteChatStickerSet(e,t){return this.raw.deleteChatStickerSet({chat_id:e},t)}getForumTopicIconStickers(e){return this.raw.getForumTopicIconStickers(e)}createForumTopic(e,t,s,i){return this.raw.createForumTopic({chat_id:e,name:t,...s},i)}editForumTopic(e,t,s,i){return this.raw.editForumTopic({chat_id:e,message_thread_id:t,...s},i)}closeForumTopic(e,t,s){return this.raw.closeForumTopic({chat_id:e,message_thread_id:t},s)}reopenForumTopic(e,t,s){return this.raw.reopenForumTopic({chat_id:e,message_thread_id:t},s)}deleteForumTopic(e,t,s){return this.raw.deleteForumTopic({chat_id:e,message_thread_id:t},s)}unpinAllForumTopicMessages(e,t,s){return this.raw.unpinAllForumTopicMessages({chat_id:e,message_thread_id:t},s)}editGeneralForumTopic(e,t,s){return this.raw.editGeneralForumTopic({chat_id:e,name:t},s)}closeGeneralForumTopic(e,t){return this.raw.closeGeneralForumTopic({chat_id:e},t)}reopenGeneralForumTopic(e,t){return this.raw.reopenGeneralForumTopic({chat_id:e},t)}hideGeneralForumTopic(e,t){return this.raw.hideGeneralForumTopic({chat_id:e},t)}unhideGeneralForumTopic(e,t){return this.raw.unhideGeneralForumTopic({chat_id:e},t)}unpinAllGeneralForumTopicMessages(e,t){return this.raw.unpinAllGeneralForumTopicMessages({chat_id:e},t)}answerCallbackQuery(e,t,s){return this.raw.answerCallbackQuery({callback_query_id:e,...t},s)}setMyName(e,t,s){return this.raw.setMyName({name:e,...t},s)}getMyName(e,t){return this.raw.getMyName(e??{},t)}setMyCommands(e,t,s){return this.raw.setMyCommands({commands:e,...t},s)}deleteMyCommands(e,t){return this.raw.deleteMyCommands({...e},t)}getMyCommands(e,t){return this.raw.getMyCommands({...e},t)}setMyDescription(e,t,s){return this.raw.setMyDescription({description:e,...t},s)}getMyDescription(e,t){return this.raw.getMyDescription({...e},t)}setMyShortDescription(e,t,s){return this.raw.setMyShortDescription({short_description:e,...t},s)}getMyShortDescription(e,t){return this.raw.getMyShortDescription({...e},t)}setMyProfilePhoto(e,t){return this.raw.setMyProfilePhoto({photo:e},t)}removeMyProfilePhoto(e){return this.raw.removeMyProfilePhoto(e)}setChatMenuButton(e,t){return this.raw.setChatMenuButton({...e},t)}getChatMenuButton(e,t){return this.raw.getChatMenuButton({...e},t)}setMyDefaultAdministratorRights(e,t){return this.raw.setMyDefaultAdministratorRights({...e},t)}getMyDefaultAdministratorRights(e,t){return this.raw.getMyDefaultAdministratorRights({...e},t)}getMyStarBalance(e){return this.raw.getMyStarBalance(e)}editMessageText(e,t,s,i,r){return this.raw.editMessageText({chat_id:e,message_id:t,text:s,...i},r)}editMessageTextInline(e,t,s,i){return this.raw.editMessageText({inline_message_id:e,text:t,...s},i)}editMessageCaption(e,t,s,i){return this.raw.editMessageCaption({chat_id:e,message_id:t,...s},i)}editMessageCaptionInline(e,t,s){return this.raw.editMessageCaption({inline_message_id:e,...t},s)}editMessageMedia(e,t,s,i,r){return this.raw.editMessageMedia({chat_id:e,message_id:t,media:s,...i},r)}editMessageMediaInline(e,t,s,i){return this.raw.editMessageMedia({inline_message_id:e,media:t,...s},i)}editMessageReplyMarkup(e,t,s,i){return this.raw.editMessageReplyMarkup({chat_id:e,message_id:t,...s},i)}editMessageReplyMarkupInline(e,t,s){return this.raw.editMessageReplyMarkup({inline_message_id:e,...t},s)}stopPoll(e,t,s,i){return this.raw.stopPoll({chat_id:e,message_id:t,...s},i)}deleteMessage(e,t,s){return this.raw.deleteMessage({chat_id:e,message_id:t},s)}deleteMessages(e,t,s){return this.raw.deleteMessages({chat_id:e,message_ids:t},s)}deleteBusinessMessages(e,t,s){return this.raw.deleteBusinessMessages({business_connection_id:e,message_ids:t},s)}setBusinessAccountName(e,t,s,i){return this.raw.setBusinessAccountName({business_connection_id:e,first_name:t,...s},i)}setBusinessAccountUsername(e,t,s){return this.raw.setBusinessAccountUsername({business_connection_id:e,username:t},s)}setBusinessAccountBio(e,t,s){return this.raw.setBusinessAccountBio({business_connection_id:e,bio:t},s)}setBusinessAccountProfilePhoto(e,t,s,i){return this.raw.setBusinessAccountProfilePhoto({business_connection_id:e,photo:t,...s},i)}removeBusinessAccountProfilePhoto(e,t,s){return this.raw.removeBusinessAccountProfilePhoto({business_connection_id:e,...t},s)}setBusinessAccountGiftSettings(e,t,s,i){return this.raw.setBusinessAccountGiftSettings({business_connection_id:e,show_gift_button:t,accepted_gift_types:s},i)}getBusinessAccountStarBalance(e,t){return this.raw.getBusinessAccountStarBalance({business_connection_id:e},t)}transferBusinessAccountStars(e,t,s){return this.raw.transferBusinessAccountStars({business_connection_id:e,star_count:t},s)}getBusinessAccountGifts(e,t,s){return this.raw.getBusinessAccountGifts({business_connection_id:e,...t},s)}convertGiftToStars(e,t,s){return this.raw.convertGiftToStars({business_connection_id:e,owned_gift_id:t},s)}upgradeGift(e,t,s,i){return this.raw.upgradeGift({business_connection_id:e,owned_gift_id:t,...s},i)}transferGift(e,t,s,i,r){return this.raw.transferGift({business_connection_id:e,owned_gift_id:t,new_owner_chat_id:s,star_count:i},r)}postStory(e,t,s,i,r){return this.raw.postStory({business_connection_id:e,content:t,active_period:s,...i},r)}repostStory(e,t,s,i,r,o){return this.raw.repostStory({business_connection_id:e,from_chat_id:t,from_story_id:s,active_period:i,...r},o)}editStory(e,t,s,i,r){return this.raw.editStory({business_connection_id:e,story_id:t,content:s,...i},r)}deleteStory(e,t,s){return this.raw.deleteStory({business_connection_id:e,story_id:t},s)}sendSticker(e,t,s,i){return this.raw.sendSticker({chat_id:e,sticker:t,...s},i)}getStickerSet(e,t){return this.raw.getStickerSet({name:e},t)}getCustomEmojiStickers(e,t){return this.raw.getCustomEmojiStickers({custom_emoji_ids:e},t)}uploadStickerFile(e,t,s,i){return this.raw.uploadStickerFile({user_id:e,sticker_format:t,sticker:s},i)}createNewStickerSet(e,t,s,i,r,o){return this.raw.createNewStickerSet({user_id:e,name:t,title:s,stickers:i,...r},o)}addStickerToSet(e,t,s,i){return this.raw.addStickerToSet({user_id:e,name:t,sticker:s},i)}setStickerPositionInSet(e,t,s){return this.raw.setStickerPositionInSet({sticker:e,position:t},s)}deleteStickerFromSet(e,t){return this.raw.deleteStickerFromSet({sticker:e},t)}replaceStickerInSet(e,t,s,i,r){return this.raw.replaceStickerInSet({user_id:e,name:t,old_sticker:s,sticker:i},r)}setStickerEmojiList(e,t,s){return this.raw.setStickerEmojiList({sticker:e,emoji_list:t},s)}setStickerKeywords(e,t,s){return this.raw.setStickerKeywords({sticker:e,keywords:t},s)}setStickerMaskPosition(e,t,s){return this.raw.setStickerMaskPosition({sticker:e,mask_position:t},s)}setStickerSetTitle(e,t,s){return this.raw.setStickerSetTitle({name:e,title:t},s)}deleteStickerSet(e,t){return this.raw.deleteStickerSet({name:e},t)}setStickerSetThumbnail(e,t,s,i,r){return this.raw.setStickerSetThumbnail({name:e,user_id:t,thumbnail:s,format:i},r)}setCustomEmojiStickerSetThumbnail(e,t,s){return this.raw.setCustomEmojiStickerSetThumbnail({name:e,custom_emoji_id:t},s)}getAvailableGifts(e){return this.raw.getAvailableGifts(e)}sendGift(e,t,s,i){return this.raw.sendGift({user_id:e,gift_id:t,...s},i)}giftPremiumSubscription(e,t,s,i,r){return this.raw.giftPremiumSubscription({user_id:e,month_count:t,star_count:s,...i},r)}sendGiftToChannel(e,t,s,i){return this.raw.sendGift({chat_id:e,gift_id:t,...s},i)}answerInlineQuery(e,t,s,i){return this.raw.answerInlineQuery({inline_query_id:e,results:t,...s},i)}answerWebAppQuery(e,t,s){return this.raw.answerWebAppQuery({web_app_query_id:e,result:t},s)}savePreparedInlineMessage(e,t,s,i){return this.raw.savePreparedInlineMessage({user_id:e,result:t,...s},i)}sendInvoice(e,t,s,i,r,o,a,d){return this.raw.sendInvoice({chat_id:e,title:t,description:s,payload:i,currency:r,prices:o,...a},d)}createInvoiceLink(e,t,s,i,r,o,a,d){return this.raw.createInvoiceLink({title:e,description:t,payload:s,provider_token:i,currency:r,prices:o,...a},d)}answerShippingQuery(e,t,s,i){return this.raw.answerShippingQuery({shipping_query_id:e,ok:t,...s},i)}answerPreCheckoutQuery(e,t,s,i){return this.raw.answerPreCheckoutQuery({pre_checkout_query_id:e,ok:t,...s},i)}getStarTransactions(e,t){return this.raw.getStarTransactions({...e},t)}refundStarPayment(e,t,s){return this.raw.refundStarPayment({user_id:e,telegram_payment_charge_id:t},s)}editUserStarSubscription(e,t,s,i){return this.raw.editUserStarSubscription({user_id:e,telegram_payment_charge_id:t,is_canceled:s},i)}verifyUser(e,t,s){return this.raw.verifyUser({user_id:e,...t},s)}verifyChat(e,t,s){return this.raw.verifyChat({chat_id:e,...t},s)}removeUserVerification(e,t){return this.raw.removeUserVerification({user_id:e},t)}removeChatVerification(e,t){return this.raw.removeChatVerification({chat_id:e},t)}readBusinessMessage(e,t,s,i){return this.raw.readBusinessMessage({business_connection_id:e,chat_id:t,message_id:s},i)}setPassportDataErrors(e,t,s){return this.raw.setPassportDataErrors({user_id:e,errors:t},s)}sendGame(e,t,s,i){return this.raw.sendGame({chat_id:e,game_short_name:t,...s},i)}setGameScore(e,t,s,i,r,o){return this.raw.setGameScore({chat_id:e,message_id:t,user_id:s,score:i,...r},o)}setGameScoreInline(e,t,s,i,r){return this.raw.setGameScore({inline_message_id:e,user_id:t,score:s,...i},r)}getGameHighScores(e,t,s,i){return this.raw.getGameHighScores({chat_id:e,message_id:t,user_id:s},i)}getGameHighScoresInline(e,t,s){return this.raw.getGameHighScores({inline_message_id:e,user_id:t},s)}};_e.Api=Oe});var ze=y(P=>{"use strict";h();Object.defineProperty(P,"__esModule",{value:!0});P.Bot=P.BotError=P.DEFAULT_UPDATE_TYPES=void 0;var Z=Re();Object.defineProperty(P,"BotError",{enumerable:!0,get:function(){return Z.BotError}});var Si=de(),Ft=De(),Qe=pe(),$t=re(),We=j(),k=(0,We.debug)("grammy:bot"),ki=(0,We.debug)("grammy:warn"),D=(0,We.debug)("grammy:error");P.DEFAULT_UPDATE_TYPES=["message","edited_message","channel_post","edited_channel_post","business_connection","business_message","edited_business_message","deleted_business_messages","inline_query","chosen_inline_result","callback_query","shipping_query","pre_checkout_query","purchased_paid_media","poll","poll_answer","my_chat_member","chat_join_request","chat_boost","removed_chat_boost"];var Ne=class extends Z.Composer{constructor(e,t){var s;if(super(),this.token=e,this.pollingRunning=!1,this.lastTriedUpdateId=0,this.observedUpdateTypes=new Set,this.errorHandler=async i=>{var r,o;throw console.error("Error in middleware while handling update",(o=(r=i.ctx)===null||r===void 0?void 0:r.update)===null||o===void 0?void 0:o.update_id,i.error),console.error("No error handler was set!"),console.error("Set your own error handler with `bot.catch = ...`"),this.pollingRunning&&(console.error("Stopping bot"),await this.stop()),i},!e)throw new Error("Empty token!");this.me=t?.botInfo,this.clientConfig=t?.client,this.ContextConstructor=(s=t?.ContextConstructor)!==null&&s!==void 0?s:Si.Context,this.api=new Ft.Api(e,this.clientConfig)}set botInfo(e){this.me=e}get botInfo(){if(this.me===void 0)throw new Error("Bot information unavailable! Make sure to call `await bot.init()` before accessing `bot.botInfo`!");return this.me}on(e,...t){for(let[s]of(0,$t.parse)(e).flatMap($t.preprocess))this.observedUpdateTypes.add(s);return super.on(e,...t)}reaction(e,...t){return this.observedUpdateTypes.add("message_reaction"),super.reaction(e,...t)}isInited(){return this.me!==void 0}async init(e){var t;if(!this.isInited()){k("Initializing bot"),(t=this.mePromise)!==null&&t!==void 0||(this.mePromise=Lt(()=>this.api.getMe(e),e));let s;try{s=await this.mePromise}finally{this.mePromise=void 0}this.me===void 0?this.me=s:k("Bot info was set by now, will not overwrite")}k(`I am ${this.me.username}!`)}async handleUpdates(e){for(let t of e){this.lastTriedUpdateId=t.update_id;try{await this.handleUpdate(t)}catch(s){if(s instanceof Z.BotError)await this.errorHandler(s);else throw console.error("FATAL: grammY unable to handle:",s),s}}}async handleUpdate(e,t){if(this.me===void 0)throw new Error("Bot not initialized! Either call `await bot.init()`, or directly set the `botInfo` option in the `Bot` constructor to specify a known bot info object.");k(`Processing update ${e.update_id}`);let s=new Ft.Api(this.token,this.clientConfig,t),i=this.api.config.installedTransformers();i.length>0&&s.config.use(...i);let r=new this.ContextConstructor(e,s,this.me);try{await(0,Z.run)(this.middleware(),r)}catch(o){throw D(`Error in middleware for update ${e.update_id}`),new Z.BotError(o,r)}}async start(e){var t,s,i;let r=[];if(this.isInited()||r.push(this.init((t=this.pollingAbortController)===null||t===void 0?void 0:t.signal)),this.pollingRunning){await Promise.all(r),k("Simple long polling already running!");return}this.pollingRunning=!0,this.pollingAbortController=new Pi.AbortController;try{r.push(Lt(async()=>{var o;await this.api.deleteWebhook({drop_pending_updates:e?.drop_pending_updates},(o=this.pollingAbortController)===null||o===void 0?void 0:o.signal)},(s=this.pollingAbortController)===null||s===void 0?void 0:s.signal)),await Promise.all(r),await((i=e?.onStart)===null||i===void 0?void 0:i.call(e,this.botInfo))}catch(o){throw this.pollingRunning=!1,this.pollingAbortController=void 0,o}this.pollingRunning&&(Ai(this.observedUpdateTypes,e?.allowed_updates),this.use=Ti,k("Starting simple long polling"),await this.loop(e),k("Middleware is done running"))}async stop(){var e;if(this.pollingRunning){k("Stopping bot, saving update offset"),this.pollingRunning=!1,(e=this.pollingAbortController)===null||e===void 0||e.abort();let t=this.lastTriedUpdateId+1;await this.api.getUpdates({offset:t,limit:1}).finally(()=>this.pollingAbortController=void 0)}else k("Bot is not running!")}isRunning(){return this.pollingRunning}catch(e){this.errorHandler=e}async loop(e){var t,s;let i=e?.limit,r=(t=e?.timeout)!==null&&t!==void 0?t:30,o=(s=e?.allowed_updates)!==null&&s!==void 0?s:[];try{for(;this.pollingRunning;){let a=await this.fetchUpdates({limit:i,timeout:r,allowed_updates:o});if(a===void 0)break;await this.handleUpdates(a),o=void 0}}finally{this.pollingRunning=!1}}async fetchUpdates({limit:e,timeout:t,allowed_updates:s}){var i;let r=this.lastTriedUpdateId+1,o;do try{o=await this.api.getUpdates({offset:r,limit:e,timeout:t,allowed_updates:s},(i=this.pollingAbortController)===null||i===void 0?void 0:i.signal)}catch(a){await this.handlePollingError(a)}while(o===void 0&&this.pollingRunning);return o}async handlePollingError(e){var t;if(!this.pollingRunning){k("Pending getUpdates request cancelled");return}let s=3;if(e instanceof Qe.GrammyError){if(D(e.message),e.error_code===401||e.error_code===409)throw e;e.error_code===429&&(D("Bot API server is closing."),s=(t=e.parameters.retry_after)!==null&&t!==void 0?t:s)}else D(e);D(`Call to getUpdates failed, retrying in ${s} seconds ...`),await xe(s)}};P.Bot=Ne;async function Lt(n,e){let s=50;async function i(o){let a=!1,d="rethrow";if(o instanceof Qe.HttpError)a=!0,d="retry";else if(o instanceof Qe.GrammyError){if(o.error_code>=500)a=!0,d="retry";else if(o.error_code===429){let c=o.parameters.retry_after;typeof c=="number"?(await xe(c,e),s=50):a=!0,d="retry"}}if(a){s!==50&&await xe(s,e);let c=20*60*1e3;s=Math.min(c,2*s)}return d}let r={ok:!1};for(;!r.ok;)try{r={ok:!0,value:await n()}}catch(o){switch(D(o),await i(o)){case"retry":continue;case"rethrow":throw o}}return r.value}async function xe(n,e){let t,s;function i(){s?.(new Error("Aborted delay")),t!==void 0&&clearTimeout(t)}try{await new Promise((r,o)=>{if(s=o,e?.aborted){i();return}e?.addEventListener("abort",i),t=setTimeout(r,1e3*n)})}finally{e?.removeEventListener("abort",i)}}function Ai(n,e=P.DEFAULT_UPDATE_TYPES){let t=Array.from(n).filter(s=>!e.includes(s));t.length>0&&ki(`You registered listeners for the following update types, but you did not specify them in \`allowed_updates\` so they may not be received: ${t.map(s=>`'${s}'`).join(", ")}`)}function Ti(){throw new Error(`It looks like you are registering more listeners on your bot from within other listeners! This means that every time your bot handles a message like this one, new listeners will be added. This list grows until your machine crashes, so grammY throws this error to tell you that you should probably do things a bit differently. If you're unsure how to resolve this problem, you can ask in the group chat: https://telegram.me/grammyjs
20
-
21
- On the other hand, if you actually know what you're doing and you do need to install further middleware while your bot is running, consider installing a composer instance on your bot, and in turn augment the composer after the fact. This way, you can circumvent this protection against memory leaks.`)}var Pi=qe()});var Ut=y(ee=>{"use strict";h();Object.defineProperty(ee,"__esModule",{value:!0});ee.API_CONSTANTS=void 0;var qt=ze(),Ei=[...qt.DEFAULT_UPDATE_TYPES,"chat_member","message_reaction","message_reaction_count"],ji={can_send_messages:!0,can_send_audios:!0,can_send_documents:!0,can_send_photos:!0,can_send_videos:!0,can_send_video_notes:!0,can_send_voice_notes:!0,can_send_polls:!0,can_send_other_messages:!0,can_add_web_page_previews:!0,can_change_info:!0,can_invite_users:!0,can_edit_tag:!0,can_pin_messages:!0,can_manage_topics:!0};ee.API_CONSTANTS={DEFAULT_UPDATE_TYPES:qt.DEFAULT_UPDATE_TYPES,ALL_UPDATE_TYPES:Ei,ALL_CHAT_PERMISSIONS:ji};Object.freeze(ee.API_CONSTANTS)});var Gt=y(ye=>{"use strict";h();Object.defineProperty(ye,"__esModule",{value:!0});ye.InlineQueryResultBuilder=void 0;function b(n){return{...n,...He(n)}}function He(n){return{text(e,t={}){let s={message_text:e,...t};return{...n,input_message_content:s}},location(e,t,s={}){let i={latitude:e,longitude:t,...s};return{...n,input_message_content:i}},venue(e,t,s,i,r){let o={title:e,latitude:t,longitude:s,address:i,...r};return{...n,input_message_content:o}},contact(e,t,s={}){let i={first_name:e,phone_number:t,...s};return{...n,input_message_content:i}},invoice(e,t,s,i,r,o,a={}){let d={title:e,description:t,payload:s,provider_token:i,currency:r,prices:o,...a};return{...n,input_message_content:d}}}}ye.InlineQueryResultBuilder={article(n,e,t={}){return He({type:"article",id:n,title:e,...t})},audio(n,e,t,s={}){return b({type:"audio",id:n,title:e,audio_url:typeof t=="string"?t:t.href,...s})},audioCached(n,e,t={}){return b({type:"audio",id:n,audio_file_id:e,...t})},contact(n,e,t,s={}){return b({type:"contact",id:n,phone_number:e,first_name:t,...s})},documentPdf(n,e,t,s={}){return b({type:"document",mime_type:"application/pdf",id:n,title:e,document_url:typeof t=="string"?t:t.href,...s})},documentZip(n,e,t,s={}){return b({type:"document",mime_type:"application/zip",id:n,title:e,document_url:typeof t=="string"?t:t.href,...s})},documentCached(n,e,t,s={}){return b({type:"document",id:n,title:e,document_file_id:t,...s})},game(n,e,t={}){return{type:"game",id:n,game_short_name:e,...t}},gif(n,e,t,s={}){return b({type:"gif",id:n,gif_url:typeof e=="string"?e:e.href,thumbnail_url:typeof t=="string"?t:t.href,...s})},gifCached(n,e,t={}){return b({type:"gif",id:n,gif_file_id:e,...t})},location(n,e,t,s,i={}){return b({type:"location",id:n,title:e,latitude:t,longitude:s,...i})},mpeg4gif(n,e,t,s={}){return b({type:"mpeg4_gif",id:n,mpeg4_url:typeof e=="string"?e:e.href,thumbnail_url:typeof t=="string"?t:t.href,...s})},mpeg4gifCached(n,e,t={}){return b({type:"mpeg4_gif",id:n,mpeg4_file_id:e,...t})},photo(n,e,t={}){let s=typeof e=="string"?e:e.href;return b({type:"photo",id:n,photo_url:s,thumbnail_url:s,...t})},photoCached(n,e,t={}){return b({type:"photo",id:n,photo_file_id:e,...t})},stickerCached(n,e,t={}){return b({type:"sticker",id:n,sticker_file_id:e,...t})},venue(n,e,t,s,i,r={}){return b({type:"venue",id:n,title:e,latitude:t,longitude:s,address:i,...r})},videoHtml(n,e,t,s,i={}){return He({type:"video",mime_type:"text/html",id:n,title:e,video_url:typeof t=="string"?t:t.href,thumbnail_url:typeof s=="string"?s:s.href,...i})},videoMp4(n,e,t,s,i={}){return b({type:"video",mime_type:"video/mp4",id:n,title:e,video_url:typeof t=="string"?t:t.href,thumbnail_url:typeof s=="string"?s:s.href,...i})},videoCached(n,e,t,s={}){return b({type:"video",id:n,title:e,video_file_id:t,...s})},voice(n,e,t,s={}){return b({type:"voice",id:n,title:e,voice_url:typeof t=="string"?t:t.href,...s})},voiceCached(n,e,t,s={}){return b({type:"voice",id:n,title:e,voice_file_id:t,...s})}}});var Ot=y(ve=>{"use strict";h();Object.defineProperty(ve,"__esModule",{value:!0});ve.InputMediaBuilder=void 0;ve.InputMediaBuilder={photo(n,e={}){return{type:"photo",media:n,...e}},video(n,e={}){return{type:"video",media:n,...e}},animation(n,e={}){return{type:"animation",media:n,...e}},audio(n,e={}){return{type:"audio",media:n,...e}},document(n,e={}){return{type:"document",media:n,...e}}}});var Nt=y(Q=>{"use strict";h();Object.defineProperty(Q,"__esModule",{value:!0});Q.InlineKeyboard=Q.Keyboard=void 0;var Ke=class n{constructor(e=[[]]){this.keyboard=e}add(...e){var t;return(t=this.keyboard[this.keyboard.length-1])===null||t===void 0||t.push(...e),this}row(...e){return this.keyboard.push(e),this}text(e,t){return this.add(n.text(e,t))}static text(e,t){return typeof t=="string"?{text:e,style:t}:{text:e,...t}}requestUsers(e,t,s={}){return this.add(n.requestUsers(e,t,s))}static requestUsers(e,t,s={}){return typeof e=="string"?{text:e,request_users:{request_id:t,...s}}:{...e,request_users:{request_id:t,...s}}}requestChat(e,t,s={chat_is_channel:!1}){return this.add(n.requestChat(e,t,s))}static requestChat(e,t,s={chat_is_channel:!1}){let i={request_id:t,...s};return typeof e=="string"?{text:e,request_chat:i}:{...e,request_chat:i}}requestContact(e){return this.add(n.requestContact(e))}static requestContact(e){return typeof e=="string"?{text:e,request_contact:!0}:{...e,request_contact:!0}}requestLocation(e){return this.add(n.requestLocation(e))}static requestLocation(e){return typeof e=="string"?{text:e,request_location:!0}:{...e,request_location:!0}}requestPoll(e,t){return this.add(n.requestPoll(e,t))}static requestPoll(e,t){let s={type:t};return typeof e=="string"?{text:e,request_poll:s}:{...e,request_poll:s}}webApp(e,t){return this.add(n.webApp(e,t))}static webApp(e,t){let s={url:t};return typeof e=="string"?{text:e,web_app:s}:{...e,web_app:s}}style(e){let t=this.keyboard.length;if(t===0)throw new Error("Need to add a button before applying a style!");let s=this.keyboard[t-1],i=s.length;if(i===0)throw new Error("Need to add a button before applying a style!");let r=s[i-1];return typeof r=="string"&&(r={text:r},s[i-1]=r),r.style=e,this}danger(){return this.style("danger")}success(){return this.style("success")}primary(){return this.style("primary")}icon(e){let t=this.keyboard.length;if(t===0)throw new Error("Need to add a button before adding an icon!");let s=this.keyboard[t-1],i=s.length;if(i===0)throw new Error("Need to add a button before adding an icon!");let r=s[i-1];return typeof r=="string"&&(r={text:r},s[i-1]=r),r.icon_custom_emoji_id=e,this}persistent(e=!0){return this.is_persistent=e,this}selected(e=!0){return this.selective=e,this}oneTime(e=!0){return this.one_time_keyboard=e,this}resized(e=!0){return this.resize_keyboard=e,this}placeholder(e){return this.input_field_placeholder=e,this}toTransposed(){let e=this.keyboard,t=Dt(e);return this.clone(t)}toFlowed(e,t={}){let s=this.keyboard,i=Qt(s,e,t);return this.clone(i)}clone(e=this.keyboard){let t=new n(e.map(s=>s.slice()));return t.is_persistent=this.is_persistent,t.selective=this.selective,t.one_time_keyboard=this.one_time_keyboard,t.resize_keyboard=this.resize_keyboard,t.input_field_placeholder=this.input_field_placeholder,t}append(...e){for(let t of e){let s=n.from(t);this.keyboard.push(...s.keyboard.map(i=>i.slice()))}return this}build(){return this.keyboard}static from(e){if(e instanceof n)return e.clone();function t(s){return typeof s=="string"?n.text(s):s}return new n(e.map(s=>s.map(t)))}};Q.Keyboard=Ke;var Ye=class n{constructor(e=[[]]){this.inline_keyboard=e}add(...e){var t;return(t=this.inline_keyboard[this.inline_keyboard.length-1])===null||t===void 0||t.push(...e),this}row(...e){return this.inline_keyboard.push(e),this}url(e,t){return this.add(n.url(e,t))}static url(e,t){return typeof e=="string"?{text:e,url:t}:{...e,url:t}}text(e,t=typeof e=="string"?e:e.text){return this.add(n.text(e,t))}static text(e,t=typeof e=="string"?e:e.text){return typeof e=="string"?{text:e,callback_data:t}:{...e,callback_data:t}}webApp(e,t){return this.add(n.webApp(e,t))}static webApp(e,t){let s=typeof t=="string"?{url:t}:t;return typeof e=="string"?{text:e,web_app:s}:{...e,web_app:s}}login(e,t){return this.add(n.login(e,t))}static login(e,t){let s=typeof t=="string"?{url:t}:t;return typeof e=="string"?{text:e,login_url:s}:{...e,login_url:s}}switchInline(e,t=""){return this.add(n.switchInline(e,t))}static switchInline(e,t=""){return typeof e=="string"?{text:e,switch_inline_query:t}:{...e,switch_inline_query:t}}switchInlineCurrent(e,t=""){return this.add(n.switchInlineCurrent(e,t))}static switchInlineCurrent(e,t=""){return typeof e=="string"?{text:e,switch_inline_query_current_chat:t}:{...e,switch_inline_query_current_chat:t}}switchInlineChosen(e,t={}){return this.add(n.switchInlineChosen(e,t))}static switchInlineChosen(e,t={}){return typeof e=="string"?{text:e,switch_inline_query_chosen_chat:t}:{...e,switch_inline_query_chosen_chat:t}}copyText(e,t){return this.add(n.copyText(e,t))}static copyText(e,t){let s=typeof t=="string"?{text:t}:t;return typeof e=="string"?{text:e,copy_text:s}:{...e,copy_text:s}}game(e){return this.add(n.game(e))}static game(e){let t={};return typeof e=="string"?{text:e,callback_game:t}:{...e,callback_game:t}}pay(e){return this.add(n.pay(e))}static pay(e){return typeof e=="string"?{text:e,pay:!0}:{...e,pay:!0}}style(e){let t=this.inline_keyboard.length;if(t===0)throw new Error("Need to add a button before applying a style!");let s=this.inline_keyboard[t-1],i=s.length;if(i===0)throw new Error("Need to add a button before applying a style!");return s[i-1].style=e,this}danger(){return this.style("danger")}success(){return this.style("success")}primary(){return this.style("primary")}icon(e){let t=this.inline_keyboard.length;if(t===0)throw new Error("Need to add a button before adding an icon!");let s=this.inline_keyboard[t-1],i=s.length;if(i===0)throw new Error("Need to add a button before adding an icon!");return s[i-1].icon_custom_emoji_id=e,this}toTransposed(){let e=this.inline_keyboard,t=Dt(e);return new n(t)}toFlowed(e,t={}){let s=this.inline_keyboard,i=Qt(s,e,t);return new n(i)}clone(){return new n(this.inline_keyboard.map(e=>e.slice()))}append(...e){for(let t of e){let s=n.from(t);this.inline_keyboard.push(...s.inline_keyboard.map(i=>i.slice()))}return this}static from(e){return e instanceof n?e.clone():new n(e.map(t=>t.slice()))}};Q.InlineKeyboard=Ye;function Dt(n){var e;let t=[];for(let s=0;s<n.length;s++){let i=n[s];for(let r=0;r<i.length;r++){let o=i[r];((e=t[r])!==null&&e!==void 0?e:t[r]=[]).push(o)}}return t}function Qt(n,e,{fillLastRow:t=!1}){var s;let i=e;t&&(i=n.map(a=>a.length).reduce((a,d)=>a+d,0)%e);let r=[];for(let o of n)for(let a of o){let d=Math.max(0,r.length-1),c=d===0?i:e,l=(s=r[d])!==null&&s!==void 0?s:r[d]=[];l.length===c&&(l=[],r.push(l)),l.push(a)}return r}});var Ht=y(G=>{"use strict";h();Object.defineProperty(G,"__esModule",{value:!0});G.MemorySessionStorage=void 0;G.session=Fi;G.lazySession=qi;G.enhanceStorage=Gi;var Ri=j(),Bi=(0,Ri.debug)("grammy:session");function Fi(n={}){return n.type==="multi"?Li(n):$i(n)}function $i(n){let{initial:e,storage:t,getSessionKey:s,custom:i}=Ve(n);return async(r,o)=>{let a=new te(t,r,"session",e),d=await s(r);await a.init(d,{custom:i,lazy:!1}),await o(),await a.finish()}}function Li(n){let e=Object.keys(n).filter(s=>s!=="type"),t=Object.fromEntries(e.map(s=>[s,Ve(n[s])]));return async(s,i)=>{s.session={};let r=await Promise.all(e.map(async o=>{let{initial:a,storage:d,getSessionKey:c,custom:l}=t[o],p=new te(d,s.session,o,a),m=await c(s);return await p.init(m,{custom:l,lazy:!1}),p}));await i(),s.session==null&&r.forEach(o=>o.delete()),await Promise.all(r.map(o=>o.finish()))}}function qi(n={}){if(n.type!==void 0&&n.type!=="single")throw new Error("Cannot use lazy multi sessions!");let{initial:e,storage:t,getSessionKey:s,custom:i}=Ve(n);return async(r,o)=>{let a=new te(t,r,"session",e),d=await s(r);await a.init(d,{custom:i,lazy:!0}),await o(),await a.finish()}}var te=class{constructor(e,t,s,i){this.storage=e,this.obj=t,this.prop=s,this.initial=i,this.fetching=!1,this.read=!1,this.wrote=!1}load(){if(this.key!==void 0&&!this.wrote)return this.promise===void 0&&(this.fetching=!0,this.promise=Promise.resolve(this.storage.read(this.key)).then(e=>{var t;return this.fetching=!1,this.wrote?this.value:e!==void 0?(this.value=e,e):(e=(t=this.initial)===null||t===void 0?void 0:t.call(this),e!==void 0&&(this.wrote=!0,this.value=e),e)})),this.promise}async init(e,t){this.key=e,t.lazy||await this.load(),Object.defineProperty(this.obj,this.prop,{enumerable:!0,get:()=>{if(e===void 0){let s=Wt("access",t);throw new Error(s)}return this.read=!0,!t.lazy||this.wrote?this.value:(this.load(),this.fetching?this.promise:this.value)},set:s=>{if(e===void 0){let i=Wt("assign",t);throw new Error(i)}this.wrote=!0,this.fetching=!1,this.value=s}})}delete(){Object.assign(this.obj,{[this.prop]:void 0})}async finish(){if(this.key!==void 0&&(this.read&&await this.load(),this.read||this.wrote)){let e=await this.value;e==null?await this.storage.delete(this.key):await this.storage.write(this.key,e)}}};function Ve(n={}){let{prefix:e="",getSessionKey:t=xt,initial:s,storage:i}=n;return i==null&&(Bi("Storing session data in memory, all data will be lost when the bot restarts."),i=new be),{initial:s,storage:i,getSessionKey:async o=>{let a=await t(o);return a===void 0?void 0:e+a},custom:t!==xt}}function xt(n){var e;return(e=n.chatId)===null||e===void 0?void 0:e.toString()}function Wt(n,e){let{lazy:t=!1,custom:s}=e;return`Cannot ${n} ${t?"lazy ":""}session data because ${s?"the custom `getSessionKey` function returned undefined for this update":"this update does not belong to a chat, so the session key is undefined"}!`}function Ui(n){return n===void 0||typeof n=="object"&&n!==null&&"__d"in n}function Gi(n){let{storage:e,millisecondsToLive:t,migrations:s}=n;return e=Oi(e),t!==void 0&&(e=Di(e,t)),s!==void 0&&(e=Qi(e,s)),Ni(e)}function Oi(n){return{read:async e=>{let t=await n.read(e);return Ui(t)?t:{__d:t}},write:(e,t)=>n.write(e,t),delete:e=>n.delete(e)}}function Di(n,e){let t={read:async s=>{let i=await n.read(s);if(i!==void 0){if(i.e===void 0)return await t.write(s,i),i;if(i.e<Date.now()){await t.delete(s);return}return i}},write:async(s,i)=>{i.e=zt(i,e).expires,await n.write(s,i)},delete:s=>n.delete(s)};return t}function Qi(n,e){let t=Object.keys(e).map(c=>parseInt(c)).sort((c,l)=>c-l),s=t.length;if(s===0)throw new Error("No migrations given!");let i=t[0],r=s-1,o=t[r],a=new Map;t.forEach((c,l)=>a.set(c,l));function d(c){let l=r;for(;c<=t[l];)l--;return l}return{read:async c=>{var l;let p=await n.read(c);if(p===void 0)return p;let{__d:m,v:_=i-1}=p,g=1+((l=a.get(_))!==null&&l!==void 0?l:d(_));for(;g<s;g++)m=e[t[g]](m);return{...p,v:o,__d:m}},write:(c,l)=>n.write(c,{v:o,...l}),delete:c=>n.delete(c)}}function Ni(n){return{read:e=>Promise.resolve(n.read(e)).then(t=>t?.__d),write:(e,t)=>n.write(e,{__d:t}),delete:e=>n.delete(e)}}var be=class{constructor(e){this.timeToLive=e,this.storage=new Map}read(e){let t=this.storage.get(e);if(t!==void 0){if(t.expires!==void 0&&t.expires<Date.now()){this.delete(e);return}return t.session}}readAll(){return this.readAllValues()}readAllKeys(){return Array.from(this.storage.keys())}readAllValues(){return Array.from(this.storage.keys()).map(e=>this.read(e)).filter(e=>e!==void 0)}readAllEntries(){return Array.from(this.storage.keys()).map(e=>[e,this.read(e)]).filter(e=>e[1]!==void 0)}has(e){return this.storage.has(e)}write(e,t){this.storage.set(e,zt(t,this.timeToLive))}delete(e){this.storage.delete(e)}};G.MemorySessionStorage=be;function zt(n,e){if(e!==void 0&&e<1/0){let t=Date.now();return{session:n,expires:t+e}}else return{session:n}}});var Yt=y(Ce=>{"use strict";h();Object.defineProperty(Ce,"__esModule",{value:!0});Ce.adapters=void 0;var C="X-Telegram-Bot-Api-Secret-Token",we=C.toLowerCase(),E="secret token is wrong",N=()=>new Response(null,{status:200}),x=n=>new Response(n,{status:200,headers:{"Content-Type":"application/json"}}),W=()=>new Response('"unauthorized"',{status:401,statusText:E}),xi=(n,e,t)=>({get update(){var s;return JSON.parse((s=n.body)!==null&&s!==void 0?s:"{}")},header:n.headers[C],end:()=>t(null,{statusCode:200}),respond:s=>t(null,{statusCode:200,headers:{"Content-Type":"application/json"},body:s}),unauthorized:()=>t(null,{statusCode:401})}),Wi=(n,e)=>{let t;return{get update(){var s;return JSON.parse((s=n.body)!==null&&s!==void 0?s:"{}")},header:n.headers[C],end:()=>t({statusCode:200}),respond:s=>t({statusCode:200,headers:{"Content-Type":"application/json"},body:s}),unauthorized:()=>t({statusCode:401}),handlerReturn:new Promise(s=>t=s)}},zi=(n,e)=>{var t,s;return{get update(){return e.body},header:(s=(t=n.res)===null||t===void 0?void 0:t.headers)===null||s===void 0?void 0:s[C],end:()=>n.res={status:200,body:""},respond:i=>{var r,o,a,d;(o=(r=n.res)===null||r===void 0?void 0:r.set)===null||o===void 0||o.call(r,"Content-Type","application/json"),(d=(a=n.res)===null||a===void 0?void 0:a.send)===null||d===void 0||d.call(a,i)},unauthorized:()=>{var i,r;(r=(i=n.res)===null||i===void 0?void 0:i.send)===null||r===void 0||r.call(i,401,E)}}},Hi=n=>{let e;return{get update(){return n.json()},header:n.headers.get(C)||void 0,end:()=>e({status:204}),respond:t=>e({jsonBody:t}),unauthorized:()=>e({status:401,body:E}),handlerReturn:new Promise(t=>e=t)}},Ki=n=>{let e;return{get update(){return n.json()},header:n.headers.get(C)||void 0,end:()=>{e(N())},respond:t=>{e(x(t))},unauthorized:()=>{e(W())},handlerReturn:new Promise(t=>e=t)}},Yi=n=>{let e;return n.respondWith(new Promise(t=>{e=t})),{get update(){return n.request.json()},header:n.request.headers.get(C)||void 0,end:()=>{e(N())},respond:t=>{e(x(t))},unauthorized:()=>{e(W())}}},Vi=n=>{let e;return{get update(){return n.json()},header:n.headers.get(C)||void 0,end:()=>{e(N())},respond:t=>{e(x(t))},unauthorized:()=>{e(W())},handlerReturn:new Promise(t=>e=t)}},Ji=(n,e)=>({get update(){return n.body},header:n.header(C),end:()=>e.end(),respond:t=>{e.set("Content-Type","application/json"),e.send(t)},unauthorized:()=>{e.status(401).send(E)}}),Xi=(n,e)=>({get update(){return n.body},header:n.headers[we],end:()=>e.send(""),respond:t=>e.headers({"Content-Type":"application/json"}).send(t),unauthorized:()=>e.code(401).send(E)}),Zi=n=>{let e;return{get update(){return n.req.json()},header:n.req.header(C),end:()=>{e(n.body(""))},respond:t=>{e(n.json(t))},unauthorized:()=>{n.status(401),e(n.body(""))},handlerReturn:new Promise(t=>e=t)}},Kt=(n,e)=>{let t=n.headers[we];return{get update(){return new Promise((s,i)=>{let r=[];n.on("data",o=>r.push(o)).once("end",()=>{let o=Buffer.concat(r).toString("utf-8");try{s(JSON.parse(o))}catch(a){i(a)}}).once("error",i)})},header:Array.isArray(t)?t[0]:t,end:()=>e.end(),respond:s=>e.writeHead(200,{"Content-Type":"application/json"}).end(s),unauthorized:()=>e.writeHead(401).end(E)}},en=n=>({get update(){return n.request.body},header:n.get(C)||void 0,end:()=>{n.body=""},respond:e=>{n.set("Content-Type","application/json"),n.response.body=e},unauthorized:()=>{n.status=401}}),tn=(n,e)=>({get update(){return n.body},header:n.headers[we],end:()=>e.end(),respond:t=>e.status(200).json(t),unauthorized:()=>e.status(401).send(E)}),sn=n=>({get update(){return n.body},header:n.headers.get(C)||void 0,end:()=>n.response.sendStatus(200),respond:e=>n.response.status(200).send(e),unauthorized:()=>n.response.status(401).send(E)}),nn=n=>({get update(){return n.request.body.json()},header:n.request.headers.get(C)||void 0,end:()=>{n.response.status=200},respond:e=>{n.response.type="json",n.response.body=e},unauthorized:()=>{n.response.status=401}}),rn=n=>({get update(){return n.request.json()},header:n.request.headers.get(C)||void 0,end:()=>n.respondWith(N()),respond:e=>n.respondWith(x(e)),unauthorized:()=>n.respondWith(W())}),on=n=>{let e;return{get update(){return n.json()},header:n.headers.get(C)||void 0,end:()=>{e&&e(N())},respond:t=>{e&&e(x(t))},unauthorized:()=>{e&&e(W())},handlerReturn:new Promise(t=>e=t)}},an=({request:n})=>{let e;return{get update(){return n.json()},header:n.headers.get(C)||void 0,end:()=>{e&&e(N())},respond:t=>{e&&e(x(t))},unauthorized:()=>{e&&e(W())},handlerReturn:new Promise(t=>e=t)}},un=(n,e)=>{var t;return{get update(){return n.json()},header:(t=n.headers.get(C))!==null&&t!==void 0?t:void 0,end:()=>e.end(null),respond:s=>e.send(200,s),unauthorized:()=>e.send(401,E)}},dn=n=>{let e;return{get update(){return n.body},header:n.headers[we],end(){e("")},respond(t){n.set.headers["content-type"]="application/json",e(t)},unauthorized(){n.set.status=401,e("")},handlerReturn:new Promise(t=>e=t)}};Ce.adapters={"aws-lambda":xi,"aws-lambda-async":Wi,azure:zi,"azure-v4":Hi,bun:Ki,cloudflare:Yi,"cloudflare-mod":Vi,elysia:dn,express:Ji,fastify:Xi,hono:Zi,http:Kt,https:Kt,koa:en,"next-js":tn,nhttp:sn,oak:nn,serveHttp:rn,"std/http":on,sveltekit:an,worktop:un}});var Xt=y(Je=>{"use strict";h();Object.defineProperty(Je,"__esModule",{value:!0});Je.webhookCallback=gn;var Jt=j(),cn=Yt(),Vt=(0,Jt.debug)("grammy:error"),ln=(n,e,t,s=()=>e('"unauthorized"'))=>({update:Promise.resolve(n),respond:e,header:t,unauthorized:s}),hn={...cn.adapters,callback:ln};function pn(n,e){if(e===void 0)return!0;if(n===void 0)return!1;let t=new TextEncoder,s=t.encode(n),i=t.encode(e);if(s.length!==i.length)return!1;let r=0;for(let o=0;o<i.length;o++){let a=o<s.length?s[o]:0,d=i[o];r|=a^d}return r===0}function gn(n,e=Jt.defaultAdapter,t,s,i){if(n.isRunning())throw new Error("Bot is already running via long polling, the webhook setup won't receive any updates!");n.start=()=>{throw new Error("You already started the bot via webhooks, calling `bot.start()` starts the bot with long polling and this will prevent your webhook setup from receiving any updates!")};let{onTimeout:r="throw",timeoutMilliseconds:o=1e4,secretToken:a}=typeof t=="object"?t:{onTimeout:t,timeoutMilliseconds:s,secretToken:i},d=!1,c=typeof e=="string"?hn[e]:e;return async(...l)=>{var p;let m=c(...l);if(d||(await n.init(),d=!0),!pn(m.header,a))return await m.unauthorized(),m.handlerReturn;let _=!1,g={async send(w){_=!0,await m.respond(w)}};return await mn(n.handleUpdate(await m.update,g),typeof r=="function"?()=>r(...l):r,o),_||(p=m.end)===null||p===void 0||p.call(m),m.handlerReturn}}function mn(n,e,t){return t===1/0?n:new Promise((s,i)=>{let r=setTimeout(()=>{Vt(`Request timed out after ${t} ms`),e==="throw"?i(new Error(`Request timed out after ${t} ms`)):(typeof e=="function"&&e(),s());let o=Date.now();n.finally(()=>{let a=Date.now()-o;Vt(`Request completed ${a} ms after timeout!`)})},t);n.then(s).catch(i).finally(()=>clearTimeout(r))})}});var ts=y(f=>{"use strict";h();var fn=f&&f.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,i)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),z=f&&f.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&fn(e,n,t)};Object.defineProperty(f,"__esModule",{value:!0});f.HttpError=f.GrammyError=f.Api=f.matchFilter=f.Composer=f.Context=f.InputFile=f.BotError=f.Bot=void 0;var Zt=ze();Object.defineProperty(f,"Bot",{enumerable:!0,get:function(){return Zt.Bot}});Object.defineProperty(f,"BotError",{enumerable:!0,get:function(){return Zt.BotError}});var _n=Fe();Object.defineProperty(f,"InputFile",{enumerable:!0,get:function(){return _n.InputFile}});var yn=de();Object.defineProperty(f,"Context",{enumerable:!0,get:function(){return yn.Context}});z(Ut(),f);z(Gt(),f);z(Ot(),f);z(Nt(),f);z(Ht(),f);z(Xt(),f);var vn=Re();Object.defineProperty(f,"Composer",{enumerable:!0,get:function(){return vn.Composer}});var bn=re();Object.defineProperty(f,"matchFilter",{enumerable:!0,get:function(){return bn.matchFilter}});var wn=De();Object.defineProperty(f,"Api",{enumerable:!0,get:function(){return wn.Api}});var es=pe();Object.defineProperty(f,"GrammyError",{enumerable:!0,get:function(){return es.GrammyError}});Object.defineProperty(f,"HttpError",{enumerable:!0,get:function(){return es.HttpError}})});h();h();var gs=nt(ts(),1),ms=nt(Cs(),1);import{mkdirSync as cs,writeFileSync as ls}from"node:fs";import{randomUUID as hs}from"node:crypto";import{basename as Sn,join as Me}from"node:path";import{tmpdir as ps}from"node:os";h();h();h();function is(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function H(n,e,t){let s=new RegExp(String.raw`(?<!\w)${ss(e)}(.*?)${ss(e)}(?!\w)`,"gs");return t==='span class="tg-spoiler"'?n.replace(s,'<span class="tg-spoiler">$1</span>'):n.replace(s,`<${t}>$1</${t}>`)}function ss(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}h();var Xe=/(`{3,})(\w+)?\r?\n?[\s\S]*?(?:\r?\n)?\1/gs;function Cn(n){let e=n.replace(Xe,""),t=[];for(let r of e.split(/\r?\n/)){let o=r.trim().match(/^(?<fence>`{3,})(?<lang>\w+)?$/);if(!o||!o.groups)continue;let a=o.groups.fence;t.length&&a===t[t.length-1]?t.pop():t.push(a)}let s=n;t.length&&(s+=`
22
- `+t[t.length-1]);let i=s.replace(Xe,"");return(i.match(/```/g)||[]).length%2!==0&&(s+="```"),i=s.replace(Xe,""),(i.match(/`/g)||[]).length%2!==0&&(s+="`"),s}function ns(n){let e=Cn(n),t=[],s={},i=/(`{3,})(\w+)?\r?\n?([\s\S]*?)(\r?\n?)\1/gs,r=e;for(let o of e.matchAll(i)){let a=(o[2]||"").trim(),c=((o[3]||"")+(o[4]||"")).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;"),l=`CODEBLOCKPLACEHOLDER${t.length}`;t.push(l);let p=a?`<pre><code class="language-${a}">${c}</code></pre>`:`<pre><code>${c}</code></pre>`;s[l]=p,r=r.replace(o[0],l)}return{modifiedText:r,codeBlocks:s}}function rs(n,e){let t=n;for(let[s,i]of Object.entries(e))t=t.replace(s,i);return t}function os(n){let e={},t=0;return{modifiedText:n.replace(/`([^`]+)`/g,(i,r)=>{let o=`INLINECODEPLACEHOLDER${t++}`;return e[o]=r,o}),inlineSnippets:e}}h();function as(n){let e=n.split(`
23
- `),t=[],s=[],i=!1,r=!1;for(let o of e)o.startsWith("**>")?(i=!0,r=!0,s.push(o.slice(3).trim())):o.startsWith(">")?(i||(i=!0,r=!1),s.push(o.slice(1).trim())):(i&&(t.push(r?`<blockquote expandable>${s.join(`
24
- `)}</blockquote>`:`<blockquote>${s.join(`
25
- `)}</blockquote>`),s=[],i=!1,r=!1),t.push(o));return i&&t.push(r?`<blockquote expandable>${s.join(`
26
- `)}</blockquote>`:`<blockquote>${s.join(`
27
- `)}</blockquote>`),t.join(`
28
- `)}h();function us(n){let e=n.replaceAll("&lt;blockquote&gt;","<blockquote>").replaceAll("&lt;/blockquote&gt;","</blockquote>");return e=e.replaceAll("&lt;blockquote expandable&gt;","<blockquote expandable>").replaceAll("&lt;/blockquote&gt;","</blockquote>"),e}function ds(n){return n.replaceAll('&lt;span class="tg-spoiler"&gt;','<span class="tg-spoiler">').replaceAll("&lt;/span&gt;","</span>")}function Ze(n){let e=as(n),{modifiedText:t,codeBlocks:s}=ns(e);e=t;let i=os(e);e=i.modifiedText,e=is(e),e=e.replace(/^(#{1,6})\s+(.+)$/gm,"<b>$2</b>"),e=e.replace(/^(\s*)[\-*]\s+(.+)$/gm,"$1\u2022 $2"),e=e.replace(/\*\*\*(.*?)\*\*\*/gs,"<b><i>$1</i></b>"),e=e.replace(/___(.*?)___/gs,"<u><i>$1</i></u>"),e=H(e,"**","b"),e=H(e,"__","u"),e=H(e,"~~","s"),e=H(e,"||",'span class="tg-spoiler"'),e=e.replace(/(?<![A-Za-z0-9])\*(?=[^\s])(.*?)(?<!\s)\*(?![A-Za-z0-9])/gs,"<i>$1</i>"),e=H(e,"_","i"),e=e.replace(/【[^】]+】/g,"");let r=/(?:!?)\[((?:[^\[\]]|\[.*?\])*)\]\(([^)]+)\)/g;e=e.replace(r,'<a href="$2">$1</a>');for(let[o,a]of Object.entries(i.inlineSnippets)){let d=a.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;");e=e.replace(o,`<code>${d}</code>`)}return e=rs(e,s),e=us(e),e=ds(e),e=e.replace(/\n{3,}/g,`
29
-
30
- `),e.trim()}h();var et=class{constructor(){this.openTags=[]}feed(e){let t=/<\/?([a-zA-Z0-9]+)([^>]*)>/g,s;for(;s=t.exec(e);){let i=e[s.index+1]==="/",r=s[1];if(i){for(let o=this.openTags.length-1;o>=0;o--)if(this.openTags[o][0]===r){this.openTags.splice(o,1);break}}else if(["b","i","u","s","code","pre","a","span","blockquote"].includes(r)){let o=Mn(s[2]);this.openTags.push([r,o])}}}getOpenTagsHtml(){return this.openTags.map(([e,t])=>{let s=t.length?" "+t.map(([i,r])=>`${i}="${r}"`).join(" "):"";return`<${e}${s}>`}).join("")}getClosingTagsHtml(){return[...this.openTags].reverse().map(([e])=>`</${e}>`).join("")}};function Mn(n){let e=[],t=/(\w+)=["']([^"']*)["']/g,s;for(;s=t.exec(n);)e.push([s[1],s[2]]);return e}function In(n){let e=n.match(/^<pre><code(.*?)>([\s\S]*)<\/code><\/pre>$/);if(e){let[,o,a]=e,d=a.split(/(\r?\n)/),c=[],l="";for(let p of d)l.length+p.length+24>4096&&(c.push(`<pre><code${o}>${l}</code></pre>`),l=""),l+=p;return l&&c.push(`<pre><code${o}>${l}</code></pre>`),c}let s=n.slice(5,-6).split(/(\r?\n)/),i=[],r="";for(let o of s)r.length+o.length+11>4096&&(i.push(`<pre>${r}</pre>`),r=""),r+=o;return r&&i.push(`<pre>${r}</pre>`),i}function tt(n){let e=[],t=/(<pre>.*?<\/pre>|<pre><code.*?<\/code><\/pre>)/gs,s=n.split(t);for(let o of s)if(o)if(o.startsWith("<pre>")||o.startsWith("<pre><code"))e.push(...In(o));else{let a=new et,d="",c=o.split(/(\n\s*\n|<br\s*\/?>(?:\n)?|\n)/);for(let l of c){let p=d+l;if(p.length>4096){a.feed(d);let m=a.getOpenTagsHtml(),_=a.getClosingTagsHtml();e.push(m+d+_),d=l}else d=p}if(d.trim()){a.feed(d);let l=a.getOpenTagsHtml(),p=a.getClosingTagsHtml();e.push(l+d+p)}}let i=[],r="";for(let o of e)r.length+o.length<=4096?r+=o:(r&&i.push(r),r=o);return r&&i.push(r),i}var se=class extends ot{bot;botId=0;botUsername="";constructor(e,t,s,i){super(e,t,s,i);let r=this.proxy?{client:{baseFetchConfig:{agent:new ms.HttpsProxyAgent(this.proxy)}}}:void 0;this.bot=new gs.Bot(t.token,r)}getFileUrl(e){return`https://api.telegram.org/file/bot${this.bot.token}/${e}`}async connect(){let e=await this.bot.api.getMe();this.botId=e.id,this.botUsername=e.username??"",this.bot.on("message:text",async t=>{let s=t.message,i=s.text,r=this.buildEnvelope(s,i,s.entities);this.handleInbound(r).catch(o=>{process.stderr.write(`[Telegram:${this.name}] Error handling message: ${o}
31
- `),t.reply("Sorry, something went wrong processing your message.").catch(()=>{})})}),this.bot.on("message:photo",async t=>{let s=t.message,i=this.buildEnvelope(s,s.caption||"(image)",s.caption_entities),r=s.photo[s.photo.length-1];if(r){try{let o=await t.api.getFile(r.file_id),a=this.getFileUrl(o.file_path),d=await fetch(a);if(!d.ok)throw new Error(`HTTP ${d.status}`);let c=Buffer.from(await d.arrayBuffer());i.imageBase64=c.toString("base64"),i.imageMimeType="image/jpeg"}catch(o){process.stderr.write(`[Telegram:${this.name}] Failed to download photo: ${o instanceof Error?o.message:o}
32
- `)}this.handleInbound(i).catch(o=>{process.stderr.write(`[Telegram:${this.name}] Error handling message: ${o}
33
- `),t.reply("Sorry, something went wrong processing your message.").catch(()=>{})})}}),this.bot.on("message:document",async t=>{let s=t.message,i=s.document,r=i.file_name||`file_${Date.now()}`,o=this.buildEnvelope(s,s.caption||`(file: ${r})`,s.caption_entities);try{let a=await t.api.getFile(i.file_id),d=this.getFileUrl(a.file_path),c=await fetch(d);if(!c.ok)throw new Error(`HTTP ${c.status}`);let l=Buffer.from(await c.arrayBuffer()),p=Me(ps(),"channel-files",hs());cs(p,{recursive:!0});let m=Me(p,Sn(r)||`file_${Date.now()}`);ls(m,l),o.text=s.caption||"",o.attachments=[{type:"file",filePath:m,mimeType:i.mime_type||"application/octet-stream",fileName:r}]}catch(a){process.stderr.write(`[Telegram:${this.name}] Failed to download document: ${a instanceof Error?a.message:a}
34
- `),o.text=(s.caption||"")+`
35
-
36
- (User sent a file "${r}" but download failed)`}this.handleInbound(o).catch(a=>{process.stderr.write(`[Telegram:${this.name}] Error handling message: ${a}
37
- `),t.reply("Sorry, something went wrong processing your message.").catch(()=>{})})}),this.bot.on("message:voice",async t=>{let s=t.message,i=s.voice,r=`voice_${Date.now()}.ogg`,o=this.buildEnvelope(s,s.caption||"(voice message)",s.caption_entities);try{let a=await t.api.getFile(i.file_id),d=this.getFileUrl(a.file_path),c=await fetch(d);if(!c.ok)throw new Error(`HTTP ${c.status}`);let l=Buffer.from(await c.arrayBuffer()),p=Me(ps(),"channel-files",hs());cs(p,{recursive:!0});let m=Me(p,r);ls(m,l),o.text=s.caption||"",o.attachments=[{type:"audio",filePath:m,mimeType:i.mime_type||"audio/ogg",fileName:r}]}catch(a){process.stderr.write(`[Telegram:${this.name}] Failed to download voice message: ${a instanceof Error?a.message:a}
38
- `),o.text=(s.caption||"")+`
39
-
40
- (User sent a voice message but download failed)`}this.handleInbound(o).catch(a=>{process.stderr.write(`[Telegram:${this.name}] Error handling message: ${a}
41
- `),t.reply("Sorry, something went wrong processing your message.").catch(()=>{})})}),this.bot.start({drop_pending_updates:!0}).catch(t=>{process.stderr.write(`[Telegram:${this.name}] Bot launch error: ${t}
42
- `)}),process.once("SIGINT",()=>this.bot.stop()),process.once("SIGTERM",()=>this.bot.stop())}typingIntervals=new Map;onPromptStart(e){let t=this.typingIntervals.get(e);t&&clearInterval(t);let s=()=>this.bot.api.sendChatAction(e,"typing").catch(()=>{});s(),this.typingIntervals.set(e,setInterval(s,4e3))}onPromptEnd(e){let t=this.typingIntervals.get(e);t&&(clearInterval(t),this.typingIntervals.delete(e))}async sendMessage(e,t){let s=Ze(t),i=tt(s);for(let r of i)try{await this.bot.api.sendMessage(e,r,{parse_mode:"HTML"})}catch{await this.bot.api.sendMessage(e,r.replace(/<[^>]*>/g,""))}}disconnect(){this.bot.stop()}buildEnvelope(e,t,s){let i=e.chat.type==="group"||e.chat.type==="supergroup",r=s?.some(c=>c.type==="mention"&&this.botUsername&&t.slice(c.offset,c.offset+c.length).toLowerCase()===`@${this.botUsername.toLowerCase()}`)??!1,o=e.reply_to_message?.from?.id===this.botId,a=t;r&&this.botUsername&&(a=t.replace(new RegExp(`@${this.botUsername}`,"gi"),"").trim());let d=e.reply_to_message?.text||void 0;return{channelName:this.name,senderId:String(e.from.id),senderName:e.from.first_name+(e.from.last_name?` ${e.from.last_name}`:""),chatId:String(e.chat.id),text:a,isGroup:i,isMentioned:r,isReplyToBot:o,referencedText:d}}};var Wr={channelType:"telegram",displayName:"Telegram",requiredConfigFields:["token"],createChannel:(n,e,t,s)=>new se(n,e,t,s)};export{se as TelegramChannel,Wr as plugin};