@maincode-ai/matilda-code 0.21.12 → 0.21.13-nightly.20261026.e0eae1d8c

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 (194) hide show
  1. package/bundled/mainy/SKILL.md +0 -2
  2. package/bundled/mainy/docs/_meta.ts +0 -2
  3. package/bundled/mainy/docs/configuration/auth.md +5 -10
  4. package/bundled/mainy/docs/configuration/model-providers.md +31 -217
  5. package/bundled/mainy/docs/configuration/settings.md +32 -4
  6. package/bundled/mainy/docs/features/auto-mode.md +1 -1
  7. package/bundled/mainy/docs/features/channels/_meta.ts +0 -3
  8. package/bundled/mainy/docs/features/channels/overview.md +8 -16
  9. package/bundled/mainy/docs/features/commands.md +4 -4
  10. package/bundled/mainy/docs/features/hooks.md +9 -7
  11. package/bundled/mainy/docs/features/language.md +2 -29
  12. package/bundled/mainy/docs/features/sub-agents.md +1 -1
  13. package/bundled/mainy/docs/features/worktree.md +3 -5
  14. package/bundled/mainy/docs/integration-github-action.md +3 -3
  15. package/bundled/mainy/docs/matilda-serve.md +1 -1
  16. package/bundled/mainy/docs/quickstart.md +2 -2
  17. package/bundled/mainy/docs/support/troubleshooting.md +3 -10
  18. package/chunks/agent-4FTU3WN6.js +3 -0
  19. package/chunks/agent-headless-QJUVHPFC.js +3 -0
  20. package/chunks/{askUserQuestion-2QI4NSFJ.js → askUserQuestion-QKX4NEFX.js} +1 -1
  21. package/chunks/{ca-I2HEEIL7.js → ca-C2V7I65K.js} +6 -6
  22. package/chunks/{chunk-6E766NPX.js → chunk-2ONZZ46N.js} +2 -2
  23. package/chunks/chunk-36K4HBVM.js +7 -0
  24. package/chunks/{chunk-EQGA7LH7.js → chunk-3B2HABK7.js} +1 -1
  25. package/chunks/{chunk-MCQUPLRE.js → chunk-5NMK4Y7C.js} +1 -1
  26. package/chunks/chunk-5YT4GCK7.js +14 -0
  27. package/chunks/{chunk-27Q5KW3A.js → chunk-62AFAL4I.js} +10 -10
  28. package/chunks/chunk-75KP2FVD.js +81 -0
  29. package/chunks/chunk-7ZODGQO6.js +4 -0
  30. package/chunks/chunk-BZB7HYRC.js +37 -0
  31. package/chunks/{chunk-YRQP3SLC.js → chunk-EXNHJQCD.js} +1 -1
  32. package/chunks/chunk-FCGYRGV4.js +9 -0
  33. package/chunks/chunk-G4YMVWG4.js +8 -0
  34. package/chunks/{chunk-6T2GIM76.js → chunk-HDARIAVM.js} +1 -1
  35. package/chunks/{chunk-YJAKOETP.js → chunk-HM5LCKDB.js} +2 -2
  36. package/chunks/chunk-IIQ5YERM.js +120 -0
  37. package/chunks/{chunk-CSJTA7NE.js → chunk-JGJ7BVZN.js} +18 -18
  38. package/chunks/{chunk-GTVCJCHR.js → chunk-JIKQI4MZ.js} +1 -1
  39. package/chunks/{chunk-WV3IUPZS.js → chunk-LHDCAN7Z.js} +1 -1
  40. package/chunks/chunk-LZDHANXA.js +89 -0
  41. package/chunks/{chunk-PGXQZVLX.js → chunk-NOE4UNQN.js} +1 -1
  42. package/chunks/chunk-OEZS5R3S.js +207 -0
  43. package/chunks/{chunk-OOEH6ZSV.js → chunk-PTMCLADZ.js} +1 -1
  44. package/chunks/{chunk-2HTPVSGT.js → chunk-PYZNGIIR.js} +1 -1
  45. package/chunks/chunk-QJJTUDDA.js +56 -0
  46. package/chunks/{chunk-LUNDTQ3G.js → chunk-R34HYLL4.js} +1 -1
  47. package/chunks/{chunk-QVCGLQCI.js → chunk-RK4LPGBV.js} +3 -3
  48. package/chunks/{chunk-DE3HKC2W.js → chunk-RYHMPK5G.js} +1 -1
  49. package/chunks/chunk-SR7ARGUY.js +13 -0
  50. package/chunks/{chunk-JRECUFB3.js → chunk-SY6JRCN3.js} +636 -654
  51. package/chunks/chunk-TUKNB5CQ.js +33 -0
  52. package/chunks/{chunk-VTGICC67.js → chunk-TZ4FRU6B.js} +1 -1
  53. package/chunks/chunk-U7V7APDV.js +9 -0
  54. package/chunks/{chunk-CZGZ3KK7.js → chunk-UVWZ44ZW.js} +1 -1
  55. package/chunks/{chunk-HYVP4472.js → chunk-V6UPUMP3.js} +1 -1
  56. package/chunks/{chunk-DOOFGSRV.js → chunk-VLDZBRTL.js} +1 -1
  57. package/chunks/{computer-use-WKDNUTLD.js → computer-use-OXAMR75N.js} +1 -1
  58. package/chunks/contextCommand-ERLW5VWL.js +3 -0
  59. package/chunks/{cron-create-F2LXM2OA.js → cron-create-AUDQ6STP.js} +1 -1
  60. package/chunks/{cron-delete-DE6Q2S2L.js → cron-delete-P5HE3PDD.js} +1 -1
  61. package/chunks/{cron-list-IAQEJVV7.js → cron-list-NR5FZBK2.js} +1 -1
  62. package/chunks/{de-AQXFJYZI.js → de-KOUI2CEW.js} +5 -5
  63. package/chunks/{devtools-5JRKK3E7.js → devtools-G5DWLP2N.js} +1 -1
  64. package/chunks/dist-XXTQNTKQ.js +42 -0
  65. package/chunks/dist-ZFZZLIQU.js +3 -0
  66. package/chunks/{edit-QQNJZ55P.js → edit-REFR5ROS.js} +1 -1
  67. package/chunks/{en-EJLDYIBM.js → en-RMYRLXC2.js} +4 -4
  68. package/chunks/{enter-worktree-5X5SAMBJ.js → enter-worktree-WO3DT2G7.js} +1 -1
  69. package/chunks/{enterPlanMode-HP35SPLN.js → enterPlanMode-PLRHEU5A.js} +1 -1
  70. package/chunks/{exit-worktree-SRKZBEYF.js → exit-worktree-J5PW6DCV.js} +1 -1
  71. package/chunks/{exitPlanMode-WSPTGGVN.js → exitPlanMode-KXUPNLCJ.js} +2 -2
  72. package/chunks/{fr-6TDHK7F2.js → fr-R3QF3LA2.js} +5 -5
  73. package/chunks/glob-ZVTVRDQO.js +22 -0
  74. package/chunks/{goal-tools-C6BSBHCF.js → goal-tools-XVKQJL5I.js} +1 -1
  75. package/chunks/{grep-MVCOBUYW.js → grep-R7CWUNNE.js} +1 -1
  76. package/chunks/{ja-GGNJR7AR.js → ja-A5OQLXUZ.js} +5 -5
  77. package/chunks/{keychain-token-storage-KQK6MNOJ.js → keychain-token-storage-IM4UB4P4.js} +1 -1
  78. package/chunks/{ls-JYJXFSXN.js → ls-DEAFYDVV.js} +1 -1
  79. package/chunks/{lsp-DYDK6XCS.js → lsp-DL7W47VY.js} +1 -1
  80. package/chunks/matildaAgentContentGenerator-57EIU5XE.js +8 -0
  81. package/chunks/mcp-client-X7LEGSP3.js +3 -0
  82. package/chunks/monitor-KPWTMH3V.js +32 -0
  83. package/chunks/{multipart-parser-JI75T2O5.js → multipart-parser-FKHYAVGR.js} +1 -1
  84. package/chunks/notebook-edit-3ZH5M2TC.js +17 -0
  85. package/chunks/openaiContentGenerator-6PXSD3T7.js +37 -0
  86. package/chunks/{pt-D6L2QTDM.js → pt-RG3S3KA7.js} +5 -5
  87. package/chunks/read-file-JNS7WRUP.js +3 -0
  88. package/chunks/ripGrep-ICJDGIIV.js +3 -0
  89. package/chunks/{ru-BNJCHDYO.js → ru-5S5HLRT7.js} +5 -5
  90. package/chunks/scheduler-QC2PPMFP.js +8 -0
  91. package/chunks/{send-message-P3SMWNEE.js → send-message-V2WYLN5X.js} +1 -1
  92. package/chunks/{serve-FXH6EBQ6.js → serve-NUVQULZJ.js} +59 -48
  93. package/chunks/shell-5LNI7URE.js +3 -0
  94. package/chunks/{skill-HZPFEAPF.js → skill-QFATRHQW.js} +1 -1
  95. package/chunks/src-6UPZ7TVB.js +3 -0
  96. package/chunks/src-LZEU4AYF.js +5 -0
  97. package/chunks/{symbol-search-EAIZPWN7.js → symbol-search-WL6ZHUUN.js} +1 -1
  98. package/chunks/{syntheticOutput-432LXITX.js → syntheticOutput-3KW6SQAF.js} +1 -1
  99. package/chunks/task-create-PNW5SN27.js +3 -0
  100. package/chunks/{task-detach-XMSJ3HBM.js → task-detach-B7PDPFBA.js} +1 -1
  101. package/chunks/task-list-GGZATGK5.js +9 -0
  102. package/chunks/{task-stop-NTS62FLG.js → task-stop-UKBBE2KG.js} +1 -1
  103. package/chunks/{task-update-AR26UFYZ.js → task-update-4RHVUBUV.js} +1 -1
  104. package/chunks/{team-create-PYXFVIR5.js → team-create-2TJC3X57.js} +1 -1
  105. package/chunks/team-delete-4UJ7SU65.js +8 -0
  106. package/chunks/todoWrite-NEBVKOSG.js +3 -0
  107. package/chunks/{tool-search-RKZDSRYS.js → tool-search-R5GS64YR.js} +1 -1
  108. package/chunks/{web-fetch-VW3SVDQ6.js → web-fetch-H3XJMAEF.js} +17 -17
  109. package/chunks/{web-search-XQUIZARL.js → web-search-Q6RWPEIB.js} +1 -1
  110. package/chunks/{workflow-YXNXDRWZ.js → workflow-3A7KN3E3.js} +2 -2
  111. package/chunks/write-file-O7Q6SKZC.js +15 -0
  112. package/cli.js +502 -498
  113. package/locales/ca.js +1 -28
  114. package/locales/de.js +1 -28
  115. package/locales/en.js +1 -30
  116. package/locales/fr.js +1 -30
  117. package/locales/ja.js +1 -28
  118. package/locales/pt.js +1 -28
  119. package/locales/ru.js +1 -28
  120. package/package.json +2 -2
  121. package/sandbox-macos-permissive-closed.sb +0 -1
  122. package/sandbox-macos-permissive-open.sb +0 -1
  123. package/sandbox-macos-permissive-proxied.sb +0 -1
  124. package/sandbox-macos-restrictive-closed.sb +0 -1
  125. package/sandbox-macos-restrictive-open.sb +0 -1
  126. package/sandbox-macos-restrictive-proxied.sb +0 -1
  127. package/bundled/mainy/docs/features/channels/dingtalk.md +0 -134
  128. package/bundled/mainy/docs/features/channels/feishu.md +0 -186
  129. package/bundled/mainy/docs/features/channels/weixin.md +0 -106
  130. package/bundled/mainy/docs/integration-jetbrains.md +0 -81
  131. package/bundled/mainy/docs/integration-zed.md +0 -72
  132. package/chunks/agent-WM63A6NK.js +0 -3
  133. package/chunks/agent-headless-QIUBDKPW.js +0 -3
  134. package/chunks/anthropicContentGenerator-VKFTAIU3.js +0 -39
  135. package/chunks/chunk-2MOGYHWM.js +0 -8
  136. package/chunks/chunk-3IRGBRSP.js +0 -113
  137. package/chunks/chunk-3YLXGE6T.js +0 -8
  138. package/chunks/chunk-4F4DA5UI.js +0 -8
  139. package/chunks/chunk-4J6DC24J.js +0 -59
  140. package/chunks/chunk-4Q2SNBUH.js +0 -18
  141. package/chunks/chunk-5C2RJ5RR.js +0 -37
  142. package/chunks/chunk-6EQMZNIY.js +0 -8
  143. package/chunks/chunk-6GBNB5Z2.js +0 -3
  144. package/chunks/chunk-6Z2MV7ZY.js +0 -186
  145. package/chunks/chunk-BVOCFLC4.js +0 -56
  146. package/chunks/chunk-FPO57O66.js +0 -39
  147. package/chunks/chunk-G7R2XEEF.js +0 -7
  148. package/chunks/chunk-GOJCMVJJ.js +0 -8
  149. package/chunks/chunk-JCE3JAVC.js +0 -25
  150. package/chunks/chunk-KHHJYBR5.js +0 -9
  151. package/chunks/chunk-LJR4RZZ2.js +0 -3
  152. package/chunks/chunk-MO2HXJG5.js +0 -9
  153. package/chunks/chunk-O44XK65C.js +0 -8
  154. package/chunks/chunk-OA56BXPD.js +0 -3
  155. package/chunks/chunk-PA6532AY.js +0 -6
  156. package/chunks/chunk-QN6Y6NPA.js +0 -3
  157. package/chunks/chunk-S3CWEVTS.js +0 -15
  158. package/chunks/chunk-SDTWBD62.js +0 -8
  159. package/chunks/chunk-U347OO7S.js +0 -9
  160. package/chunks/chunk-UIRBHC5X.js +0 -3
  161. package/chunks/chunk-VI74YQQO.js +0 -8
  162. package/chunks/chunk-VYZOOSMP.js +0 -30
  163. package/chunks/chunk-WC2VTVCE.js +0 -27
  164. package/chunks/chunk-WVY2P6WH.js +0 -26
  165. package/chunks/chunk-WZ75OGYY.js +0 -14
  166. package/chunks/chunk-XMZIY7XX.js +0 -13
  167. package/chunks/chunk-YV3PUOBU.js +0 -65
  168. package/chunks/contextCommand-DAB3HOHY.js +0 -3
  169. package/chunks/dist-7UYRLSLE.js +0 -3
  170. package/chunks/dist-ME6647DQ.js +0 -195
  171. package/chunks/dist-P6SLWL5V.js +0 -42
  172. package/chunks/dist-VG3ZDJ2A.js +0 -28
  173. package/chunks/dist-YTCHM57U.js +0 -23
  174. package/chunks/fileFromPath-7UCWPD4W.js +0 -3
  175. package/chunks/geminiContentGenerator-RJ73DQAP.js +0 -8
  176. package/chunks/glob-QQ6LGKDX.js +0 -22
  177. package/chunks/matildaAgentContentGenerator-YUYS4336.js +0 -8
  178. package/chunks/matildaContentGenerator-O4Z2QPCP.js +0 -8
  179. package/chunks/matildaOAuth2-7COTQQR2.js +0 -3
  180. package/chunks/mcp-client-RXVQU5VI.js +0 -3
  181. package/chunks/monitor-77KXDXPR.js +0 -32
  182. package/chunks/notebook-edit-TKJD2EQZ.js +0 -17
  183. package/chunks/openaiContentGenerator-2EALAM3U.js +0 -3
  184. package/chunks/read-file-3KUAH6ND.js +0 -3
  185. package/chunks/ripGrep-U2PLKXMY.js +0 -3
  186. package/chunks/scheduler-J7VU2V5Y.js +0 -8
  187. package/chunks/shell-PXR2AXDD.js +0 -3
  188. package/chunks/src-RFAEPLY7.js +0 -3
  189. package/chunks/src-WZTRMETQ.js +0 -5
  190. package/chunks/task-create-Z3QRCMX4.js +0 -3
  191. package/chunks/task-list-GXAJW3JP.js +0 -9
  192. package/chunks/team-delete-OMYVUAQU.js +0 -8
  193. package/chunks/todoWrite-5NZ7CHTC.js +0 -3
  194. package/chunks/write-file-XDDLTGSG.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{f as ot}from"./chunk-EQGA7LH7.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};
@@ -1,28 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a as Hr,b as vr,c as qr}from"./chunk-WZ75OGYY.js";import"./chunk-XMZIY7XX.js";import{f as Bt}from"./chunk-EQGA7LH7.js";import"./chunk-T2T2UEPY.js";import"./chunk-M53RP3YP.js";import{c as Pt}from"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-UIRBHC5X.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import{b as l}from"./chunk-GZPNIYVZ.js";import{e as Mr,f as Qe}from"./chunk-OWGSC52X.js";l();l();import{mkdirSync as js,writeFileSync as $s}from"node:fs";import{randomUUID as zs}from"node:crypto";import{basename as Js,join as Fr}from"node:path";import{tmpdir as Ws}from"node:os";l();l();var Ye="/v1.0/im/bot/messages/get";l();l();l();l();l();function Ee(t,e){return function(){return t.apply(e,arguments)}}var{toString:jr}=Object.prototype,{getPrototypeOf:et}=Object,{iterator:Fe,toStringTag:Mt}=Symbol,Me=(t=>e=>{let n=jr.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),W=t=>(t=t.toLowerCase(),e=>Me(e)===t),He=t=>e=>typeof e===t,{isArray:he}=Array,me=He("undefined");function Te(t){return t!==null&&!me(t)&&t.constructor!==null&&!me(t.constructor)&&q(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}var Ht=W("ArrayBuffer");function $r(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Ht(t.buffer),e}var zr=He("string"),q=He("function"),vt=He("number"),xe=t=>t!==null&&typeof t=="object",Jr=t=>t===!0||t===!1,Ue=t=>{if(Me(t)!=="object")return!1;let e=et(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Mt in t)&&!(Fe in t)},Wr=t=>{if(!xe(t)||Te(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Vr=W("Date"),Kr=W("File"),Gr=t=>!!(t&&typeof t.uri<"u"),Xr=t=>t&&typeof t.getParts<"u",Qr=W("Blob"),Yr=W("FileList"),Zr=t=>xe(t)&&q(t.pipe);function en(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof globalThis<"u"?globalThis:{}}var It=en(),Ut=typeof It.FormData<"u"?It.FormData:void 0,tn=t=>{let e;return t&&(Ut&&t instanceof Ut||q(t.append)&&((e=Me(t))==="formdata"||e==="object"&&q(t.toString)&&t.toString()==="[object FormData]"))},rn=W("URLSearchParams"),[nn,sn,on,an]=["ReadableStream","Request","Response","Headers"].map(W),cn=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Se(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,s;if(typeof t!="object"&&(t=[t]),he(t))for(r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else{if(Te(t))return;let i=n?Object.getOwnPropertyNames(t):Object.keys(t),o=i.length,c;for(r=0;r<o;r++)c=i[r],e.call(null,t[c],c,t)}}function qt(t,e){if(Te(t))return null;e=e.toLowerCase();let n=Object.keys(t),r=n.length,s;for(;r-- >0;)if(s=n[r],e===s.toLowerCase())return s;return null}var ae=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:globalThis,jt=t=>!me(t)&&t!==ae;function Ze(){let{caseless:t,skipUndefined:e}=jt(this)&&this||{},n={},r=(s,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;let o=t&&qt(n,i)||i;Ue(n[o])&&Ue(s)?n[o]=Ze(n[o],s):Ue(s)?n[o]=Ze({},s):he(s)?n[o]=s.slice():(!e||!me(s))&&(n[o]=s)};for(let s=0,i=arguments.length;s<i;s++)arguments[s]&&Se(arguments[s],r);return n}var ln=(t,e,n,{allOwnKeys:r}={})=>(Se(e,(s,i)=>{n&&q(s)?Object.defineProperty(t,i,{value:Ee(s,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,i,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),un=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),fn=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},dn=(t,e,n,r)=>{let s,i,o,c={};if(e=e||{},t==null)return e;do{for(s=Object.getOwnPropertyNames(t),i=s.length;i-- >0;)o=s[i],(!r||r(o,t,e))&&!c[o]&&(e[o]=t[o],c[o]=!0);t=n!==!1&&et(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},pn=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;let r=t.indexOf(e,n);return r!==-1&&r===n},mn=t=>{if(!t)return null;if(he(t))return t;let e=t.length;if(!vt(e))return null;let n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},hn=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&et(Uint8Array)),yn=(t,e)=>{let r=(t&&t[Fe]).call(t),s;for(;(s=r.next())&&!s.done;){let i=s.value;e.call(t,i[0],i[1])}},bn=(t,e)=>{let n,r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},gn=W("HTMLFormElement"),wn=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ft=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),Rn=W("RegExp"),$t=(t,e)=>{let n=Object.getOwnPropertyDescriptors(t),r={};Se(n,(s,i)=>{let o;(o=e(s,i,t))!==!1&&(r[i]=o||s)}),Object.defineProperties(t,r)},En=t=>{$t(t,(e,n)=>{if(q(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;let r=t[n];if(q(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Tn=(t,e)=>{let n={},r=s=>{s.forEach(i=>{n[i]=!0})};return he(t)?r(t):r(String(t).split(e)),n},xn=()=>{},Sn=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function An(t){return!!(t&&q(t.append)&&t[Mt]==="FormData"&&t[Fe])}var Cn=t=>{let e=new Array(10),n=(r,s)=>{if(xe(r)){if(e.indexOf(r)>=0)return;if(Te(r))return r;if(!("toJSON"in r)){e[s]=r;let i=he(r)?[]:{};return Se(r,(o,c)=>{let d=n(o,s+1);!me(d)&&(i[c]=d)}),e[s]=void 0,i}}return r};return n(t,0)},On=W("AsyncFunction"),_n=t=>t&&(xe(t)||q(t))&&q(t.then)&&q(t.catch),zt=((t,e)=>t?setImmediate:e?((n,r)=>(ae.addEventListener("message",({source:s,data:i})=>{s===ae&&i===n&&r.length&&r.shift()()},!1),s=>{r.push(s),ae.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",q(ae.postMessage)),kn=typeof queueMicrotask<"u"?queueMicrotask.bind(ae):typeof process<"u"&&process.nextTick||zt,Dn=t=>t!=null&&q(t[Fe]),a={isArray:he,isArrayBuffer:Ht,isBuffer:Te,isFormData:tn,isArrayBufferView:$r,isString:zr,isNumber:vt,isBoolean:Jr,isObject:xe,isPlainObject:Ue,isEmptyObject:Wr,isReadableStream:nn,isRequest:sn,isResponse:on,isHeaders:an,isUndefined:me,isDate:Vr,isFile:Kr,isReactNativeBlob:Gr,isReactNative:Xr,isBlob:Qr,isRegExp:Rn,isFunction:q,isStream:Zr,isURLSearchParams:rn,isTypedArray:hn,isFileList:Yr,forEach:Se,merge:Ze,extend:ln,trim:cn,stripBOM:un,inherits:fn,toFlatObject:dn,kindOf:Me,kindOfTest:W,endsWith:pn,toArray:mn,forEachEntry:yn,matchAll:bn,isHTMLForm:gn,hasOwnProperty:Ft,hasOwnProp:Ft,reduceDescriptors:$t,freezeMethods:En,toObjectSet:Tn,toCamelCase:wn,noop:xn,toFiniteNumber:Sn,findKey:qt,global:ae,isContextDefined:jt,isSpecCompliantForm:An,toJSONObject:Cn,isAsyncFn:On,isThenable:_n,setImmediate:zt,asap:kn,isIterable:Dn};l();l();l();l();l();var F=class t extends Error{static from(e,n,r,s,i,o){let c=new t(e.message,n||e.code,r,s,i);return c.cause=e,c.name=e.name,e.status!=null&&c.status==null&&(c.status=e.status),o&&Object.assign(c,o),c}constructor(e,n,r,s,i){super(e),Object.defineProperty(this,"message",{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),s&&(this.request=s),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}};F.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";F.ERR_BAD_OPTION="ERR_BAD_OPTION";F.ECONNABORTED="ECONNABORTED";F.ETIMEDOUT="ETIMEDOUT";F.ERR_NETWORK="ERR_NETWORK";F.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";F.ERR_DEPRECATED="ERR_DEPRECATED";F.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";F.ERR_BAD_REQUEST="ERR_BAD_REQUEST";F.ERR_CANCELED="ERR_CANCELED";F.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";F.ERR_INVALID_URL="ERR_INVALID_URL";var y=F;l();var Jt=Qe(Hr(),1),ve=Jt.default;function rt(t){return a.isPlainObject(t)||a.isArray(t)}function Wt(t){return a.endsWith(t,"[]")?t.slice(0,-2):t}function tt(t,e,n){return t?t.concat(e).map(function(s,i){return s=Wt(s),!n&&i?"["+s+"]":s}).join(n?".":""):e}function Nn(t){return a.isArray(t)&&!t.some(rt)}var Ln=a.toFlatObject(a,{},null,function(e){return/^is[A-Z]/.test(e)});function Pn(t,e,n){if(!a.isObject(t))throw new TypeError("target must be an object");e=e||new(ve||FormData),n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,m){return!a.isUndefined(m[g])});let r=n.metaTokens,s=n.visitor||f,i=n.dots,o=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(e);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(p){if(p===null)return"";if(a.isDate(p))return p.toISOString();if(a.isBoolean(p))return p.toString();if(!d&&a.isBlob(p))throw new y("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(p)||a.isTypedArray(p)?d&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function f(p,g,m){let S=p;if(a.isReactNative(e)&&a.isReactNativeBlob(p))return e.append(tt(m,g,i),u(p)),!1;if(p&&!m&&typeof p=="object"){if(a.endsWith(g,"{}"))g=r?g:g.slice(0,-2),p=JSON.stringify(p);else if(a.isArray(p)&&Nn(p)||(a.isFileList(p)||a.endsWith(g,"[]"))&&(S=a.toArray(p)))return g=Wt(g),S.forEach(function(T,_){!(a.isUndefined(T)||T===null)&&e.append(o===!0?tt([g],_,i):o===null?g:g+"[]",u(T))}),!1}return rt(p)?!0:(e.append(tt(m,g,i),u(p)),!1)}let h=[],b=Object.assign(Ln,{defaultVisitor:f,convertValue:u,isVisitable:rt});function R(p,g){if(!a.isUndefined(p)){if(h.indexOf(p)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(p),a.forEach(p,function(S,C){(!(a.isUndefined(S)||S===null)&&s.call(e,S,a.isString(C)?C.trim():C,g,b))===!0&&R(S,g?g.concat(C):[C])}),h.pop()}}if(!a.isObject(t))throw new TypeError("data must be an object");return R(t),e}var re=Pn;function Vt(t){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function Kt(t,e){this._pairs=[],t&&re(t,this,e)}var Gt=Kt.prototype;Gt.append=function(e,n){this._pairs.push([e,n])};Gt.toString=function(e){let n=e?function(r){return e.call(this,r,Vt)}:Vt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};var Xt=Kt;function Bn(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ce(t,e,n){if(!e)return t;let r=n&&n.encode||Bn,s=a.isFunction(n)?{serialize:n}:n,i=s&&s.serialize,o;if(i?o=i(e,s):o=a.isURLSearchParams(e)?e.toString():new Xt(e,s).toString(r),o){let c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}l();var nt=class{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){a.forEach(this.handlers,function(r){r!==null&&e(r)})}},st=nt;l();l();l();l();var ne={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0};l();l();l();import Un from"crypto";l();import In from"url";var Qt=In.URLSearchParams;var ot="abcdefghijklmnopqrstuvwxyz",Yt="0123456789",Zt={DIGIT:Yt,ALPHA:ot,ALPHA_DIGIT:ot+ot.toUpperCase()+Yt},Fn=(t=16,e=Zt.ALPHA_DIGIT)=>{let n="",{length:r}=e,s=new Uint32Array(t);Un.randomFillSync(s);for(let i=0;i<t;i++)n+=e[s[i]%r];return n},er={isNode:!0,classes:{URLSearchParams:Qt,FormData:ve,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:Zt,generateString:Fn,protocols:["http","https","file","data"]};var ct={};Mr(ct,{hasBrowserEnv:()=>at,hasStandardBrowserEnv:()=>Mn,hasStandardBrowserWebWorkerEnv:()=>Hn,navigator:()=>it,origin:()=>vn});l();var at=typeof window<"u"&&typeof document<"u",it=typeof navigator=="object"&&navigator||void 0,Mn=at&&(!it||["ReactNative","NativeScript","NS"].indexOf(it.product)<0),Hn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",vn=at&&window.location.href||"http://localhost";var x={...ct,...er};function lt(t,e){return re(t,new x.classes.URLSearchParams,{visitor:function(n,r,s,i){return x.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...e})}l();function qn(t){return a.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function jn(t){let e={},n=Object.keys(t),r,s=n.length,i;for(r=0;r<s;r++)i=n[r],e[i]=t[i];return e}function $n(t){function e(n,r,s,i){let o=n[i++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),d=i>=n.length;return o=!o&&a.isArray(s)?s.length:o,d?(a.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!c):((!s[o]||!a.isObject(s[o]))&&(s[o]=[]),e(n,r,s[o],i)&&a.isArray(s[o])&&(s[o]=jn(s[o])),!c)}if(a.isFormData(t)&&a.isFunction(t.entries)){let n={};return a.forEachEntry(t,(r,s)=>{e(qn(r),s,n,0)}),n}return null}var qe=$n;function zn(t,e,n){if(a.isString(t))try{return(e||JSON.parse)(t),a.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}var ut={transitional:ne,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){let r=n.getContentType()||"",s=r.indexOf("application/json")>-1,i=a.isObject(e);if(i&&a.isHTMLForm(e)&&(e=new FormData(e)),a.isFormData(e))return s?JSON.stringify(qe(e)):e;if(a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)||a.isReadableStream(e))return e;if(a.isArrayBufferView(e))return e.buffer;if(a.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let c;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return lt(e,this.formSerializer).toString();if((c=a.isFileList(e))||r.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return re(c?{"files[]":e}:e,d&&new d,this.formSerializer)}}return i||s?(n.setContentType("application/json",!1),zn(e)):e}],transformResponse:[function(e){let n=this.transitional||ut.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(e)||a.isReadableStream(e))return e;if(e&&a.isString(e)&&(r&&!this.responseType||s)){let o=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?y.from(c,y.ERR_BAD_RESPONSE,this,null,this.response):c}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:x.classes.FormData,Blob:x.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],t=>{ut.headers[t]={}});var ye=ut;l();l();var Jn=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),tr=t=>{let e={},n,r,s;return t&&t.split(`
4
- `).forEach(function(o){s=o.indexOf(":"),n=o.substring(0,s).trim().toLowerCase(),r=o.substring(s+1).trim(),!(!n||e[n]&&Jn[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e};var rr=Symbol("internals");function Ae(t){return t&&String(t).trim().toLowerCase()}function je(t){return t===!1||t==null?t:a.isArray(t)?t.map(je):String(t)}function Wn(t){let e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}var Vn=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function ft(t,e,n,r,s){if(a.isFunction(r))return r.call(this,e,n);if(s&&(e=n),!!a.isString(e)){if(a.isString(r))return e.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(e)}}function Kn(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function Gn(t,e){let n=a.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(s,i,o){return this[r].call(this,e,s,i,o)},configurable:!0})})}var be=class{constructor(e){e&&this.set(e)}set(e,n,r){let s=this;function i(c,d,u){let f=Ae(d);if(!f)throw new Error("header name must be a non-empty string");let h=a.findKey(s,f);(!h||s[h]===void 0||u===!0||u===void 0&&s[h]!==!1)&&(s[h||d]=je(c))}let o=(c,d)=>a.forEach(c,(u,f)=>i(u,f,d));if(a.isPlainObject(e)||e instanceof this.constructor)o(e,n);else if(a.isString(e)&&(e=e.trim())&&!Vn(e))o(tr(e),n);else if(a.isObject(e)&&a.isIterable(e)){let c={},d,u;for(let f of e){if(!a.isArray(f))throw TypeError("Object iterator must return a key-value pair");c[u=f[0]]=(d=c[u])?a.isArray(d)?[...d,f[1]]:[d,f[1]]:f[1]}o(c,n)}else e!=null&&i(n,e,r);return this}get(e,n){if(e=Ae(e),e){let r=a.findKey(this,e);if(r){let s=this[r];if(!n)return s;if(n===!0)return Wn(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=Ae(e),e){let r=a.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||ft(this,this[r],r,n)))}return!1}delete(e,n){let r=this,s=!1;function i(o){if(o=Ae(o),o){let c=a.findKey(r,o);c&&(!n||ft(r,r[c],c,n))&&(delete r[c],s=!0)}}return a.isArray(e)?e.forEach(i):i(e),s}clear(e){let n=Object.keys(this),r=n.length,s=!1;for(;r--;){let i=n[r];(!e||ft(this,this[i],i,e,!0))&&(delete this[i],s=!0)}return s}normalize(e){let n=this,r={};return a.forEach(this,(s,i)=>{let o=a.findKey(r,i);if(o){n[o]=je(s),delete n[i];return}let c=e?Kn(i):String(i).trim();c!==i&&delete n[i],n[c]=je(s),r[c]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=e&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
5
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){let r=new this(e);return n.forEach(s=>r.set(s)),r}static accessor(e){let r=(this[rr]=this[rr]={accessors:{}}).accessors,s=this.prototype;function i(o){let c=Ae(o);r[c]||(Gn(s,o),r[c]=!0)}return a.isArray(e)?e.forEach(i):i(e),this}};be.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(be.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}});a.freezeMethods(be);var O=be;function Ce(t,e){let n=this||ye,r=e||n,s=O.from(r.headers),i=r.data;return a.forEach(t,function(c){i=c.call(n,i,s.normalize(),e?e.status:void 0)}),s.normalize(),i}l();function Oe(t){return!!(t&&t.__CANCEL__)}l();var dt=class extends y{constructor(e,n,r){super(e??"canceled",y.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}},$=dt;l();l();l();function G(t,e,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}l();l();function pt(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}l();function mt(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function le(t,e,n){let r=!pt(e);return t&&(r||n==!1)?mt(t,e):e}var mr=Qe(vr(),1),br=Qe(qr(),1);import ls from"http";import us from"https";import hr from"http2";import yr from"util";import oe from"zlib";l();var ue="1.13.6";l();l();function _e(t){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}var Xn=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function ht(t,e,n){let r=n&&n.Blob||x.classes.Blob,s=_e(t);if(e===void 0&&r&&(e=!0),s==="data"){t=s.length?t.slice(s.length+1):t;let i=Xn.exec(t);if(!i)throw new y("Invalid URL",y.ERR_INVALID_URL);let o=i[1],c=i[2],d=i[3],u=Buffer.from(decodeURIComponent(d),c?"base64":"utf8");if(e){if(!r)throw new y("Blob is not supported",y.ERR_NOT_SUPPORT);return new r([u],{type:o})}return u}throw new y("Unsupported protocol "+s,y.ERR_NOT_SUPPORT)}import se from"stream";l();import Qn from"stream";var yt=Symbol("internals"),bt=class extends Qn.Transform{constructor(e){e=a.toFlatObject(e,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(r,s)=>!a.isUndefined(s[r])),super({readableHighWaterMark:e.chunkSize});let n=this[yt]={timeWindow:e.timeWindow,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",r=>{r==="progress"&&(n.isCaptured||(n.isCaptured=!0))})}_read(e){let n=this[yt];return n.onReadCallback&&n.onReadCallback(),super._read(e)}_transform(e,n,r){let s=this[yt],i=s.maxRate,o=this.readableHighWaterMark,c=s.timeWindow,d=1e3/c,u=i/d,f=s.minChunkSize!==!1?Math.max(s.minChunkSize,u*.01):0,h=(R,p)=>{let g=Buffer.byteLength(R);s.bytesSeen+=g,s.bytes+=g,s.isCaptured&&this.emit("progress",s.bytesSeen),this.push(R)?process.nextTick(p):s.onReadCallback=()=>{s.onReadCallback=null,process.nextTick(p)}},b=(R,p)=>{let g=Buffer.byteLength(R),m=null,S=o,C,T=0;if(i){let _=Date.now();(!s.ts||(T=_-s.ts)>=c)&&(s.ts=_,C=u-s.bytes,s.bytes=C<0?-C:0,T=0),C=u-s.bytes}if(i){if(C<=0)return setTimeout(()=>{p(null,R)},c-T);C<S&&(S=C)}S&&g>S&&g-S>f&&(m=R.subarray(S),R=R.subarray(0,S)),h(R,m?()=>{process.nextTick(p,null,m)}:p)};b(e,function R(p,g){if(p)return r(p);g?b(g,R):r(null)})}},gt=bt;import{EventEmitter as fs}from"events";l();import Zn from"util";import{Readable as es}from"stream";l();var{asyncIterator:nr}=Symbol,Yn=async function*(t){t.stream?yield*t.stream():t.arrayBuffer?yield await t.arrayBuffer():t[nr]?yield*t[nr]():yield t},$e=Yn;var ts=x.ALPHABET.ALPHA_DIGIT+"-_",ke=typeof TextEncoder=="function"?new TextEncoder:new Zn.TextEncoder,fe=`\r
6
- `,rs=ke.encode(fe),ns=2,wt=class{constructor(e,n){let{escapeName:r}=this.constructor,s=a.isString(n),i=`Content-Disposition: form-data; name="${r(e)}"${!s&&n.name?`; filename="${r(n.name)}"`:""}${fe}`;s?n=ke.encode(String(n).replace(/\r?\n|\r\n?/g,fe)):i+=`Content-Type: ${n.type||"application/octet-stream"}${fe}`,this.headers=ke.encode(i+fe),this.contentLength=s?n.byteLength:n.size,this.size=this.headers.byteLength+this.contentLength+ns,this.name=e,this.value=n}async*encode(){yield this.headers;let{value:e}=this;a.isTypedArray(e)?yield e:yield*$e(e),yield rs}static escapeName(e){return String(e).replace(/[\r\n"]/g,n=>({"\r":"%0D","\n":"%0A",'"':"%22"})[n])}},ss=(t,e,n)=>{let{tag:r="form-data-boundary",size:s=25,boundary:i=r+"-"+x.generateString(s,ts)}=n||{};if(!a.isFormData(t))throw TypeError("FormData instance required");if(i.length<1||i.length>70)throw Error("boundary must be 10-70 characters long");let o=ke.encode("--"+i+fe),c=ke.encode("--"+i+"--"+fe),d=c.byteLength,u=Array.from(t.entries()).map(([h,b])=>{let R=new wt(h,b);return d+=R.size,R});d+=o.byteLength*u.length,d=a.toFiniteNumber(d);let f={"Content-Type":`multipart/form-data; boundary=${i}`};return Number.isFinite(d)&&(f["Content-Length"]=d),e&&e(f),es.from(async function*(){for(let h of u)yield o,yield*h.encode();yield c}())},sr=ss;l();import os from"stream";var Rt=class extends os.Transform{__transform(e,n,r){this.push(e),r()}_transform(e,n,r){if(e.length!==0&&(this._transform=this.__transform,e[0]!==120)){let s=Buffer.alloc(2);s[0]=120,s[1]=156,this.push(s,n)}this.__transform(e,n,r)}},or=Rt;l();var is=(t,e)=>a.isAsyncFn(t)?function(...n){let r=n.pop();t.apply(this,n).then(s=>{try{e?r(null,...e(s)):r(null,s)}catch(i){r(i)}},r)}:t,ir=is;l();l();function as(t,e){t=t||10;let n=new Array(t),r=new Array(t),s=0,i=0,o;return e=e!==void 0?e:1e3,function(d){let u=Date.now(),f=r[i];o||(o=u),n[s]=d,r[s]=u;let h=i,b=0;for(;h!==s;)b+=n[h++],h=h%t;if(s=(s+1)%t,s===i&&(i=(i+1)%t),u-o<e)return;let R=f&&u-f;return R?Math.round(b*1e3/R):void 0}}var ar=as;l();function cs(t,e){let n=0,r=1e3/e,s,i,o=(u,f=Date.now())=>{n=f,s=null,i&&(clearTimeout(i),i=null),t(...u)};return[(...u)=>{let f=Date.now(),h=f-n;h>=r?o(u,f):(s=u,i||(i=setTimeout(()=>{i=null,o(s)},r-h)))},()=>s&&o(s)]}var cr=cs;var Y=(t,e,n=3)=>{let r=0,s=ar(50,250);return cr(i=>{let o=i.loaded,c=i.lengthComputable?i.total:void 0,d=o-r,u=s(d),f=o<=c;r=o;let h={loaded:o,total:c,progress:c?o/c:void 0,bytes:d,rate:u||void 0,estimated:u&&c&&f?(c-o)/u:void 0,event:i,lengthComputable:c!=null,[e?"download":"upload"]:!0};t(h)},n)},ge=(t,e)=>{let n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},we=t=>(...e)=>a.asap(()=>t(...e));l();function Et(t){if(!t||typeof t!="string"||!t.startsWith("data:"))return 0;let e=t.indexOf(",");if(e<0)return 0;let n=t.slice(5,e),r=t.slice(e+1);if(/;base64/i.test(n)){let i=r.length,o=r.length;for(let b=0;b<o;b++)if(r.charCodeAt(b)===37&&b+2<o){let R=r.charCodeAt(b+1),p=r.charCodeAt(b+2);(R>=48&&R<=57||R>=65&&R<=70||R>=97&&R<=102)&&(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102)&&(i-=2,b+=2)}let c=0,d=o-1,u=b=>b>=2&&r.charCodeAt(b-2)===37&&r.charCodeAt(b-1)===51&&(r.charCodeAt(b)===68||r.charCodeAt(b)===100);d>=0&&(r.charCodeAt(d)===61?(c++,d--):u(d)&&(c++,d-=3)),c===1&&d>=0&&(r.charCodeAt(d)===61||u(d))&&c++;let h=Math.floor(i/4)*3-(c||0);return h>0?h:0}return Buffer.byteLength(r,"utf8")}var lr={flush:oe.constants.Z_SYNC_FLUSH,finishFlush:oe.constants.Z_SYNC_FLUSH},ds={flush:oe.constants.BROTLI_OPERATION_FLUSH,finishFlush:oe.constants.BROTLI_OPERATION_FLUSH},ur=a.isFunction(oe.createBrotliDecompress),{http:ps,https:ms}=br.default,hs=/https:?/,fr=x.protocols.map(t=>t+":"),dr=(t,[e,n])=>(t.on("end",n).on("error",n),e),Tt=class{constructor(){this.sessions=Object.create(null)}getSession(e,n){n=Object.assign({sessionTimeout:1e3},n);let r=this.sessions[e];if(r){let f=r.length;for(let h=0;h<f;h++){let[b,R]=r[h];if(!b.destroyed&&!b.closed&&yr.isDeepStrictEqual(R,n))return b}}let s=hr.connect(e,n),i,o=()=>{if(i)return;i=!0;let f=r,h=f.length,b=h;for(;b--;)if(f[b][0]===s){h===1?delete this.sessions[e]:f.splice(b,1);return}},c=s.request,{sessionTimeout:d}=n;if(d!=null){let f,h=0;s.request=function(){let b=c.apply(this,arguments);return h++,f&&(clearTimeout(f),f=null),b.once("close",()=>{--h||(f=setTimeout(()=>{f=null,o()},d))}),b}}s.once("close",o);let u=[s,n];return r?r.push(u):r=this.sessions[e]=[u],s}},ys=new Tt;function bs(t,e){t.beforeRedirects.proxy&&t.beforeRedirects.proxy(t),t.beforeRedirects.config&&t.beforeRedirects.config(t,e)}function gr(t,e,n){let r=e;if(!r&&r!==!1){let s=mr.default.getProxyForUrl(n);s&&(r=new URL(s))}if(r){if(r.username&&(r.auth=(r.username||"")+":"+(r.password||"")),r.auth){if(!!(r.auth.username||r.auth.password))r.auth=(r.auth.username||"")+":"+(r.auth.password||"");else if(typeof r.auth=="object")throw new y("Invalid proxy authorization",y.ERR_BAD_OPTION,{proxy:r});let o=Buffer.from(r.auth,"utf8").toString("base64");t.headers["Proxy-Authorization"]="Basic "+o}t.headers.host=t.hostname+(t.port?":"+t.port:"");let s=r.hostname||r.host;t.hostname=s,t.host=s,t.port=r.port,t.path=n,r.protocol&&(t.protocol=r.protocol.includes(":")?r.protocol:`${r.protocol}:`)}t.beforeRedirects.proxy=function(i){gr(i,e,i.href)}}var gs=typeof process<"u"&&a.kindOf(process)==="process",ws=t=>new Promise((e,n)=>{let r,s,i=(d,u)=>{s||(s=!0,r&&r(d,u))},o=d=>{i(d),e(d)},c=d=>{i(d,!0),n(d)};t(o,c,d=>r=d).catch(c)}),Rs=({address:t,family:e})=>{if(!a.isString(t))throw TypeError("address must be a string");return{address:t,family:e||(t.indexOf(".")<0?6:4)}},pr=(t,e)=>Rs(a.isObject(t)?t:{address:t,family:e}),Es={request(t,e){let n=t.protocol+"//"+t.hostname+":"+(t.port||(t.protocol==="https:"?443:80)),{http2Options:r,headers:s}=t,i=ys.getSession(n,r),{HTTP2_HEADER_SCHEME:o,HTTP2_HEADER_METHOD:c,HTTP2_HEADER_PATH:d,HTTP2_HEADER_STATUS:u}=hr.constants,f={[o]:t.protocol.replace(":",""),[c]:t.method,[d]:t.path};a.forEach(s,(b,R)=>{R.charAt(0)!==":"&&(f[R]=b)});let h=i.request(f);return h.once("response",b=>{let R=h;b=Object.assign({},b);let p=b[u];delete b[u],R.headers=b,R.statusCode=+p,e(R)}),h}},wr=gs&&function(e){return ws(async function(r,s,i){let{data:o,lookup:c,family:d,httpVersion:u=1,http2Options:f}=e,{responseType:h,responseEncoding:b}=e,R=e.method.toUpperCase(),p,g=!1,m;if(u=+u,Number.isNaN(u))throw TypeError(`Invalid protocol version: '${e.httpVersion}' is not a number`);if(u!==1&&u!==2)throw TypeError(`Unsupported protocol version '${u}'`);let S=u===2;if(c){let E=ir(c,w=>a.isArray(w)?w:[w]);c=(w,A,j)=>{E(w,A,(D,J,te)=>{if(D)return j(D);let v=a.isArray(J)?J.map(Ie=>pr(Ie)):[pr(J,te)];A.all?j(D,v):j(D,v[0].address,v[0].family)})}}let C=new fs;function T(E){try{C.emit("abort",!E||E.type?new $(null,e,m):E)}catch(w){console.warn("emit error",w)}}C.once("abort",s);let _=()=>{e.cancelToken&&e.cancelToken.unsubscribe(T),e.signal&&e.signal.removeEventListener("abort",T),C.removeAllListeners()};(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(T),e.signal&&(e.signal.aborted?T():e.signal.addEventListener("abort",T))),i((E,w)=>{if(p=!0,w){g=!0,_();return}let{data:A}=E;if(A instanceof se.Readable||A instanceof se.Duplex){let j=se.finished(A,()=>{j(),_()})}else _()});let M=le(e.baseURL,e.url,e.allowAbsoluteUrls),k=new URL(M,x.hasBrowserEnv?x.origin:void 0),L=k.protocol||fr[0];if(L==="data:"){if(e.maxContentLength>-1){let w=String(e.url||M||"");if(Et(w)>e.maxContentLength)return s(new y("maxContentLength size of "+e.maxContentLength+" exceeded",y.ERR_BAD_RESPONSE,e))}let E;if(R!=="GET")return G(r,s,{status:405,statusText:"method not allowed",headers:{},config:e});try{E=ht(e.url,h==="blob",{Blob:e.env&&e.env.Blob})}catch(w){throw y.from(w,y.ERR_BAD_REQUEST,e)}return h==="text"?(E=E.toString(b),(!b||b==="utf8")&&(E=a.stripBOM(E))):h==="stream"&&(E=se.Readable.from(E)),G(r,s,{data:E,status:200,statusText:"OK",headers:new O,config:e})}if(fr.indexOf(L)===-1)return s(new y("Unsupported protocol "+L,y.ERR_BAD_REQUEST,e));let P=O.from(e.headers).normalize();P.set("User-Agent","axios/"+ue,!1);let{onUploadProgress:Z,onDownloadProgress:de}=e,ie=e.maxRate,X,K;if(a.isSpecCompliantForm(o)){let E=P.getContentType(/boundary=([-_\w\d]{10,70})/i);o=sr(o,w=>{P.set(w)},{tag:`axios-${ue}-boundary`,boundary:E&&E[1]||void 0})}else if(a.isFormData(o)&&a.isFunction(o.getHeaders)){if(P.set(o.getHeaders()),!P.hasContentLength())try{let E=await yr.promisify(o.getLength).call(o);Number.isFinite(E)&&E>=0&&P.setContentLength(E)}catch{}}else if(a.isBlob(o)||a.isFile(o))o.size&&P.setContentType(o.type||"application/octet-stream"),P.setContentLength(o.size||0),o=se.Readable.from($e(o));else if(o&&!a.isStream(o)){if(!Buffer.isBuffer(o))if(a.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(a.isString(o))o=Buffer.from(o,"utf-8");else return s(new y("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",y.ERR_BAD_REQUEST,e));if(P.setContentLength(o.length,!1),e.maxBodyLength>-1&&o.length>e.maxBodyLength)return s(new y("Request body larger than maxBodyLength limit",y.ERR_BAD_REQUEST,e))}let Q=a.toFiniteNumber(P.getContentLength());a.isArray(ie)?(X=ie[0],K=ie[1]):X=K=ie,o&&(Z||X)&&(a.isStream(o)||(o=se.Readable.from(o,{objectMode:!1})),o=se.pipeline([o,new gt({maxRate:a.toFiniteNumber(X)})],a.noop),Z&&o.on("progress",dr(o,ge(Q,Y(we(Z),!1,3)))));let ee;if(e.auth){let E=e.auth.username||"",w=e.auth.password||"";ee=E+":"+w}if(!ee&&k.username){let E=k.username,w=k.password;ee=E+":"+w}ee&&P.delete("authorization");let B;try{B=ce(k.pathname+k.search,e.params,e.paramsSerializer).replace(/^\?/,"")}catch(E){let w=new Error(E.message);return w.config=e,w.url=e.url,w.exists=!0,s(w)}P.set("Accept-Encoding","gzip, compress, deflate"+(ur?", br":""),!1);let I={path:B,method:R,headers:P.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:ee,protocol:L,family:d,beforeRedirect:bs,beforeRedirects:{},http2Options:f};!a.isUndefined(c)&&(I.lookup=c),e.socketPath?I.socketPath=e.socketPath:(I.hostname=k.hostname.startsWith("[")?k.hostname.slice(1,-1):k.hostname,I.port=k.port,gr(I,e.proxy,L+"//"+k.hostname+(k.port?":"+k.port:"")+I.path));let H,pe=hs.test(I.protocol);if(I.agent=pe?e.httpsAgent:e.httpAgent,S?H=Es:e.transport?H=e.transport:e.maxRedirects===0?H=pe?us:ls:(e.maxRedirects&&(I.maxRedirects=e.maxRedirects),e.beforeRedirect&&(I.beforeRedirects.config=e.beforeRedirect),H=pe?ms:ps),e.maxBodyLength>-1?I.maxBodyLength=e.maxBodyLength:I.maxBodyLength=1/0,e.insecureHTTPParser&&(I.insecureHTTPParser=e.insecureHTTPParser),m=H.request(I,function(w){if(m.destroyed)return;let A=[w],j=a.toFiniteNumber(w.headers["content-length"]);if(de||K){let v=new gt({maxRate:a.toFiniteNumber(K)});de&&v.on("progress",dr(v,ge(j,Y(we(de),!0,3)))),A.push(v)}let D=w,J=w.req||m;if(e.decompress!==!1&&w.headers["content-encoding"])switch((R==="HEAD"||w.statusCode===204)&&delete w.headers["content-encoding"],(w.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":A.push(oe.createUnzip(lr)),delete w.headers["content-encoding"];break;case"deflate":A.push(new or),A.push(oe.createUnzip(lr)),delete w.headers["content-encoding"];break;case"br":ur&&(A.push(oe.createBrotliDecompress(ds)),delete w.headers["content-encoding"])}D=A.length>1?se.pipeline(A,a.noop):A[0];let te={status:w.statusCode,statusText:w.statusMessage,headers:new O(w.headers),config:e,request:J};if(h==="stream")te.data=D,G(r,s,te);else{let v=[],Ie=0;D.on("data",function(U){v.push(U),Ie+=U.length,e.maxContentLength>-1&&Ie>e.maxContentLength&&(g=!0,D.destroy(),T(new y("maxContentLength size of "+e.maxContentLength+" exceeded",y.ERR_BAD_RESPONSE,e,J)))}),D.on("aborted",function(){if(g)return;let U=new y("stream has been aborted",y.ERR_BAD_RESPONSE,e,J);D.destroy(U),s(U)}),D.on("error",function(U){m.destroyed||s(y.from(U,null,e,J))}),D.on("end",function(){try{let U=v.length===1?v[0]:Buffer.concat(v);h!=="arraybuffer"&&(U=U.toString(b),(!b||b==="utf8")&&(U=a.stripBOM(U))),te.data=U}catch(U){return s(y.from(U,null,e,te.request,te))}G(r,s,te)})}C.once("abort",v=>{D.destroyed||(D.emit("error",v),D.destroy())})}),C.once("abort",E=>{m.close?m.close():m.destroy(E)}),m.on("error",function(w){s(y.from(w,null,e,m))}),m.on("socket",function(w){w.setKeepAlive(!0,1e3*60)}),e.timeout){let E=parseInt(e.timeout,10);if(Number.isNaN(E)){T(new y("error trying to parse `config.timeout` to int",y.ERR_BAD_OPTION_VALUE,e,m));return}m.setTimeout(E,function(){if(p)return;let A=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",j=e.transitional||ne;e.timeoutErrorMessage&&(A=e.timeoutErrorMessage),T(new y(A,j.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,m))})}else m.setTimeout(0);if(a.isStream(o)){let E=!1,w=!1;o.on("end",()=>{E=!0}),o.once("error",A=>{w=!0,m.destroy(A)}),o.on("close",()=>{!E&&!w&&T(new $("Request stream has been aborted",e,m))}),o.pipe(m)}else o&&m.write(o),m.end()})};l();l();l();var Rr=x.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,x.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(x.origin),x.navigator&&/(msie|trident)/i.test(x.navigator.userAgent)):()=>!0;l();var Er=x.hasStandardBrowserEnv?{write(t,e,n,r,s,i,o){if(typeof document>"u")return;let c=[`${t}=${encodeURIComponent(e)}`];a.isNumber(n)&&c.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&c.push(`path=${r}`),a.isString(s)&&c.push(`domain=${s}`),i===!0&&c.push("secure"),a.isString(o)&&c.push(`SameSite=${o}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;let e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};l();var Tr=t=>t instanceof O?{...t}:t;function V(t,e){e=e||{};let n={};function r(u,f,h,b){return a.isPlainObject(u)&&a.isPlainObject(f)?a.merge.call({caseless:b},u,f):a.isPlainObject(f)?a.merge({},f):a.isArray(f)?f.slice():f}function s(u,f,h,b){if(a.isUndefined(f)){if(!a.isUndefined(u))return r(void 0,u,h,b)}else return r(u,f,h,b)}function i(u,f){if(!a.isUndefined(f))return r(void 0,f)}function o(u,f){if(a.isUndefined(f)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,f)}function c(u,f,h){if(h in e)return r(u,f);if(h in t)return r(void 0,u)}let d={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(u,f,h)=>s(Tr(u),Tr(f),h,!0)};return a.forEach(Object.keys({...t,...e}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;let h=a.hasOwnProp(d,f)?d[f]:s,b=h(t[f],e[f],f);a.isUndefined(b)&&h!==c||(n[f]=b)}),n}var ze=t=>{let e=V({},t),{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:c}=e;if(e.headers=o=O.from(o),e.url=ce(le(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),a.isFormData(n)){if(x.hasStandardBrowserEnv||x.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(a.isFunction(n.getHeaders)){let d=n.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([f,h])=>{u.includes(f.toLowerCase())&&o.set(f,h)})}}if(x.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(e)),r||r!==!1&&Rr(e.url))){let d=s&&i&&Er.read(i);d&&o.set(s,d)}return e};var Ts=typeof XMLHttpRequest<"u",xr=Ts&&function(t){return new Promise(function(n,r){let s=ze(t),i=s.data,o=O.from(s.headers).normalize(),{responseType:c,onUploadProgress:d,onDownloadProgress:u}=s,f,h,b,R,p;function g(){R&&R(),p&&p(),s.cancelToken&&s.cancelToken.unsubscribe(f),s.signal&&s.signal.removeEventListener("abort",f)}let m=new XMLHttpRequest;m.open(s.method.toUpperCase(),s.url,!0),m.timeout=s.timeout;function S(){if(!m)return;let T=O.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),M={data:!c||c==="text"||c==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:T,config:t,request:m};G(function(L){n(L),g()},function(L){r(L),g()},M),m=null}"onloadend"in m?m.onloadend=S:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(S)},m.onabort=function(){m&&(r(new y("Request aborted",y.ECONNABORTED,t,m)),m=null)},m.onerror=function(_){let M=_&&_.message?_.message:"Network Error",k=new y(M,y.ERR_NETWORK,t,m);k.event=_||null,r(k),m=null},m.ontimeout=function(){let _=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded",M=s.transitional||ne;s.timeoutErrorMessage&&(_=s.timeoutErrorMessage),r(new y(_,M.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,t,m)),m=null},i===void 0&&o.setContentType(null),"setRequestHeader"in m&&a.forEach(o.toJSON(),function(_,M){m.setRequestHeader(M,_)}),a.isUndefined(s.withCredentials)||(m.withCredentials=!!s.withCredentials),c&&c!=="json"&&(m.responseType=s.responseType),u&&([b,p]=Y(u,!0),m.addEventListener("progress",b)),d&&m.upload&&([h,R]=Y(d),m.upload.addEventListener("progress",h),m.upload.addEventListener("loadend",R)),(s.cancelToken||s.signal)&&(f=T=>{m&&(r(!T||T.type?new $(null,t,m):T),m.abort(),m=null)},s.cancelToken&&s.cancelToken.subscribe(f),s.signal&&(s.signal.aborted?f():s.signal.addEventListener("abort",f)));let C=_e(s.url);if(C&&x.protocols.indexOf(C)===-1){r(new y("Unsupported protocol "+C+":",y.ERR_BAD_REQUEST,t));return}m.send(i||null)})};l();l();var xs=(t,e)=>{let{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,s,i=function(u){if(!s){s=!0,c();let f=u instanceof Error?u:this.reason;r.abort(f instanceof y?f:new $(f instanceof Error?f.message:f))}},o=e&&setTimeout(()=>{o=null,i(new y(`timeout of ${e}ms exceeded`,y.ETIMEDOUT))},e),c=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),t=null)};t.forEach(u=>u.addEventListener("abort",i));let{signal:d}=r;return d.unsubscribe=()=>a.asap(c),d}},Sr=xs;l();var Ss=function*(t,e){let n=t.byteLength;if(!e||n<e){yield t;return}let r=0,s;for(;r<n;)s=r+e,yield t.slice(r,s),r=s},As=async function*(t,e){for await(let n of Cs(t))yield*Ss(n,e)},Cs=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}let e=t.getReader();try{for(;;){let{done:n,value:r}=await e.read();if(n)break;yield r}}finally{await e.cancel()}},xt=(t,e,n,r)=>{let s=As(t,e),i=0,o,c=d=>{o||(o=!0,r&&r(d))};return new ReadableStream({async pull(d){try{let{done:u,value:f}=await s.next();if(u){c(),d.close();return}let h=f.byteLength;if(n){let b=i+=h;n(b)}d.enqueue(new Uint8Array(f))}catch(u){throw c(u),u}},cancel(d){return c(d),s.return()}},{highWaterMark:2})};var Ar=64*1024,{isFunction:Je}=a,Os=(({Request:t,Response:e})=>({Request:t,Response:e}))(a.global),{ReadableStream:Cr,TextEncoder:Or}=a.global,_r=(t,...e)=>{try{return!!t(...e)}catch{return!1}},_s=t=>{t=a.merge.call({skipUndefined:!0},Os,t);let{fetch:e,Request:n,Response:r}=t,s=e?Je(e):typeof fetch=="function",i=Je(n),o=Je(r);if(!s)return!1;let c=s&&Je(Cr),d=s&&(typeof Or=="function"?(p=>g=>p.encode(g))(new Or):async p=>new Uint8Array(await new n(p).arrayBuffer())),u=i&&c&&_r(()=>{let p=!1,g=new n(x.origin,{body:new Cr,method:"POST",get duplex(){return p=!0,"half"}}).headers.has("Content-Type");return p&&!g}),f=o&&c&&_r(()=>a.isReadableStream(new r("").body)),h={stream:f&&(p=>p.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(p=>{!h[p]&&(h[p]=(g,m)=>{let S=g&&g[p];if(S)return S.call(g);throw new y(`Response type '${p}' is not supported`,y.ERR_NOT_SUPPORT,m)})});let b=async p=>{if(p==null)return 0;if(a.isBlob(p))return p.size;if(a.isSpecCompliantForm(p))return(await new n(x.origin,{method:"POST",body:p}).arrayBuffer()).byteLength;if(a.isArrayBufferView(p)||a.isArrayBuffer(p))return p.byteLength;if(a.isURLSearchParams(p)&&(p=p+""),a.isString(p))return(await d(p)).byteLength},R=async(p,g)=>{let m=a.toFiniteNumber(p.getContentLength());return m??b(g)};return async p=>{let{url:g,method:m,data:S,signal:C,cancelToken:T,timeout:_,onDownloadProgress:M,onUploadProgress:k,responseType:L,headers:P,withCredentials:Z="same-origin",fetchOptions:de}=ze(p),ie=e||fetch;L=L?(L+"").toLowerCase():"text";let X=Sr([C,T&&T.toAbortSignal()],_),K=null,Q=X&&X.unsubscribe&&(()=>{X.unsubscribe()}),ee;try{if(k&&u&&m!=="get"&&m!=="head"&&(ee=await R(P,S))!==0){let w=new n(g,{method:"POST",body:S,duplex:"half"}),A;if(a.isFormData(S)&&(A=w.headers.get("content-type"))&&P.setContentType(A),w.body){let[j,D]=ge(ee,Y(we(k)));S=xt(w.body,Ar,j,D)}}a.isString(Z)||(Z=Z?"include":"omit");let B=i&&"credentials"in n.prototype,I={...de,signal:X,method:m.toUpperCase(),headers:P.normalize().toJSON(),body:S,duplex:"half",credentials:B?Z:void 0};K=i&&new n(g,I);let H=await(i?ie(K,de):ie(g,I)),pe=f&&(L==="stream"||L==="response");if(f&&(M||pe&&Q)){let w={};["status","statusText","headers"].forEach(J=>{w[J]=H[J]});let A=a.toFiniteNumber(H.headers.get("content-length")),[j,D]=M&&ge(A,Y(we(M),!0))||[];H=new r(xt(H.body,Ar,j,()=>{D&&D(),Q&&Q()}),w)}L=L||"text";let E=await h[a.findKey(h,L)||"text"](H,p);return!pe&&Q&&Q(),await new Promise((w,A)=>{G(w,A,{data:E,headers:O.from(H.headers),status:H.status,statusText:H.statusText,config:p,request:K})})}catch(B){throw Q&&Q(),B&&B.name==="TypeError"&&/Load failed|fetch/i.test(B.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,p,K,B&&B.response),{cause:B.cause||B}):y.from(B,B&&B.code,p,K,B&&B.response)}}},ks=new Map,St=t=>{let e=t&&t.env||{},{fetch:n,Request:r,Response:s}=e,i=[r,s,n],o=i.length,c=o,d,u,f=ks;for(;c--;)d=i[c],u=f.get(d),u===void 0&&f.set(d,u=c?new Map:_s(e)),f=u;return u},Fc=St();var At={http:wr,xhr:xr,fetch:{get:St}};a.forEach(At,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});var kr=t=>`- ${t}`,Ns=t=>a.isFunction(t)||t===null||t===!1;function Ls(t,e){t=a.isArray(t)?t:[t];let{length:n}=t,r,s,i={};for(let o=0;o<n;o++){r=t[o];let c;if(s=r,!Ns(r)&&(s=At[(c=String(r)).toLowerCase()],s===void 0))throw new y(`Unknown adapter '${c}'`);if(s&&(a.isFunction(s)||(s=s.get(e))))break;i[c||"#"+o]=s}if(!s){let o=Object.entries(i).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build")),c=n?o.length>1?`since :
7
- `+o.map(kr).join(`
8
- `):" "+kr(o[0]):"as no adapter specified";throw new y("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return s}var We={getAdapter:Ls,adapters:At};function Ct(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new $(null,t)}function Ve(t){return Ct(t),t.headers=O.from(t.headers),t.data=Ce.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),We.getAdapter(t.adapter||ye.adapter,t)(t).then(function(r){return Ct(t),r.data=Ce.call(t,t.transformResponse,r),r.headers=O.from(r.headers),r},function(r){return Oe(r)||(Ct(t),r&&r.response&&(r.response.data=Ce.call(t,t.transformResponse,r.response),r.response.headers=O.from(r.response.headers))),Promise.reject(r)})}l();var Ke={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Ke[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});var Dr={};Ke.transitional=function(e,n,r){function s(i,o){return"[Axios v"+ue+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,c)=>{if(e===!1)throw new y(s(o," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!Dr[o]&&(Dr[o]=!0,console.warn(s(o," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(i,o,c):!0}};Ke.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function Ps(t,e,n){if(typeof t!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);let r=Object.keys(t),s=r.length;for(;s-- >0;){let i=r[s],o=e[i];if(o){let c=t[i],d=c===void 0||o(c,i,t);if(d!==!0)throw new y("option "+i+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+i,y.ERR_BAD_OPTION)}}var De={assertOptions:Ps,validators:Ke};var z=De.validators,Re=class{constructor(e){this.defaults=e||{},this.interceptors={request:new st,response:new st}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;let i=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
9
- `+i):r.stack=i}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=V(this.defaults,n);let{transitional:r,paramsSerializer:s,headers:i}=n;r!==void 0&&De.assertOptions(r,{silentJSONParsing:z.transitional(z.boolean),forcedJSONParsing:z.transitional(z.boolean),clarifyTimeoutError:z.transitional(z.boolean),legacyInterceptorReqResOrdering:z.transitional(z.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:De.assertOptions(s,{encode:z.function,serialize:z.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),De.assertOptions(n,{baseUrl:z.spelling("baseURL"),withXsrfToken:z.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&a.merge(i.common,i[n.method]);i&&a.forEach(["delete","get","head","post","put","patch","common"],p=>{delete i[p]}),n.headers=O.concat(o,i);let c=[],d=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(n)===!1)return;d=d&&g.synchronous;let m=n.transitional||ne;m&&m.legacyInterceptorReqResOrdering?c.unshift(g.fulfilled,g.rejected):c.push(g.fulfilled,g.rejected)});let u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let f,h=0,b;if(!d){let p=[Ve.bind(this),void 0];for(p.unshift(...c),p.push(...u),b=p.length,f=Promise.resolve(n);h<b;)f=f.then(p[h++],p[h++]);return f}b=c.length;let R=n;for(;h<b;){let p=c[h++],g=c[h++];try{R=p(R)}catch(m){g.call(this,m);break}}try{f=Ve.call(this,R)}catch(p){return Promise.reject(p)}for(h=0,b=u.length;h<b;)f=f.then(u[h++],u[h++]);return f}getUri(e){e=V(this.defaults,e);let n=le(e.baseURL,e.url,e.allowAbsoluteUrls);return ce(n,e.params,e.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(e){Re.prototype[e]=function(n,r){return this.request(V(r||{},{method:e,url:n,data:(r||{}).data}))}});a.forEach(["post","put","patch"],function(e){function n(r){return function(i,o,c){return this.request(V(c||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}Re.prototype[e]=n(),Re.prototype[e+"Form"]=n(!0)});var Ne=Re;l();var Ot=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});let r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i,o=new Promise(c=>{r.subscribe(c),i=c}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},e(function(i,o,c){r.reason||(r.reason=new $(i,o,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){let e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new t(function(s){e=s}),cancel:e}}},Nr=Ot;l();function _t(t){return function(n){return t.apply(null,n)}}l();function kt(t){return a.isObject(t)&&t.isAxiosError===!0}l();var Dt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Dt).forEach(([t,e])=>{Dt[e]=t});var Lr=Dt;function Pr(t){let e=new Ne(t),n=Ee(Ne.prototype.request,e);return a.extend(n,Ne.prototype,e,{allOwnKeys:!0}),a.extend(n,e,null,{allOwnKeys:!0}),n.create=function(s){return Pr(V(t,s))},n}var N=Pr(ye);N.Axios=Ne;N.CanceledError=$;N.CancelToken=Nr;N.isCancel=Oe;N.VERSION=ue;N.toFormData=re;N.AxiosError=y;N.Cancel=N.CanceledError;N.all=function(e){return Promise.all(e)};N.spread=_t;N.isAxiosError=kt;N.mergeConfig=V;N.AxiosHeaders=O;N.formToJSON=t=>qe(a.isHTMLForm(t)?new FormData(t):t);N.getAdapter=We.getAdapter;N.HttpStatusCode=Lr;N.default=N;var Le=N;var{Axios:zl,AxiosError:Jl,CanceledError:Wl,isCancel:Vl,CancelToken:Kl,VERSION:Gl,all:Xl,Cancel:Ql,isAxiosError:Yl,spread:Zl,toFormData:eu,AxiosHeaders:tu,HttpStatusCode:ru,formToJSON:nu,getAdapter:su,mergeConfig:ou}=Le;import Bs from"events";var Ge=(t=>(t.SUCCESS="SUCCESS",t.LATER="LATER",t))(Ge||{}),Is={autoReconnect:!0,keepAlive:!1,ua:"",subscriptions:[{type:"EVENT",topic:"*"}]},Pe=class extends Bs{debug=!0;connected=!1;registered=!1;reconnecting=!1;userDisconnect=!1;reconnectInterval=1e3;heartbeat_interval=8e3;heartbeatIntervallId;sslopts={rejectUnauthorized:!0};config;socket;dw_url;isAlive=!1;onEventReceived=e=>({status:"SUCCESS"});constructor(e){if(super(),this.config={...Is,...e},!this.config.clientId||!this.config.clientSecret)throw console.error("clientId or clientSecret is null"),new Error("clientId or clientSecret is null")}getConfig(){return{...this.config}}printDebug(e){if(this.debug){let n="["+new Date().toISOString()+"]";console.info(n,e)}}registerAllEventListener(e){return this.onEventReceived=e,this}registerCallbackListener(e,n){if(!e||!n)throw console.error("registerCallbackListener: eventId and callback must be defined"),new Error("registerCallbackListener: eventId and callback must be defined");return this.config.subscriptions.find(r=>r.topic===e&&r.type==="CALLBACK")||this.config.subscriptions.push({type:"CALLBACK",topic:e}),this.on(e,n),this}async getEndpoint(){this.printDebug("get connect endpoint by config"),console.log(this.config);let e=await Le.get(`https://oapi.dingtalk.com/gettoken?appkey=${this.config.clientId}&appsecret=${this.config.clientSecret}`);if(e.status===200&&e.data.access_token){this.config.access_token=e.data.access_token;let n=await Le({url:"https://api.dingtalk.com/v1.0/gateway/connections/open",method:"POST",responseType:"json",data:{clientId:this.config.clientId,clientSecret:this.config.clientSecret,ua:this.config.ua,subscriptions:this.config.subscriptions},headers:{Accept:"application/json","access-token":e.data.access_token}});if(console.log("res.data",JSON.stringify(n.data)),n.data){this.config.endpoint=n.data;let{endpoint:r,ticket:s}=n.data;if(!r||!s)throw this.printDebug("endpoint or ticket is null"),new Error("endpoint or ticket is null");return this.dw_url=`${r}?ticket=${s}`,this}else throw new Error("build: get endpoint failed")}else throw new Error("build: get access_token failed")}_connect(){return new Promise((e,n)=>{this.userDisconnect=!1,this.printDebug("Connecting to dingtalk websocket @ "+this.dw_url),this.socket=new Pt(this.dw_url,this.sslopts),this.socket.on("open",()=>{this.connected=!0,this.printDebug("Socket open"),this.config.keepAlive&&(this.isAlive=!0,this.heartbeatIntervallId=setInterval(()=>{var r,s;if(this.isAlive===!1)return console.error("TERMINATE SOCKET: Ping Pong does not transfer heartbeat within heartbeat intervall"),(r=this.socket)==null?void 0:r.terminate();this.isAlive=!1,(s=this.socket)==null||s.ping("",!0)},this.heartbeat_interval))}),this.socket.on("pong",()=>{this.heartbeat()}),this.socket.on("message",r=>{this.onDownStream(r)}),this.socket.on("close",r=>{this.printDebug("Socket closed"),this.connected=!1,this.registered=!1,this.config.autoReconnect&&!this.userDisconnect&&(this.reconnecting=!0,this.printDebug("Reconnecting in "+this.reconnectInterval/1e3+" seconds..."),setTimeout(this.connect.bind(this),this.reconnectInterval))}),this.socket.on("error",r=>{this.printDebug("SOCKET ERROR"),console.warn("ERROR",r)}),e()})}async connect(){await this.getEndpoint(),await this._connect()}disconnect(){var e;console.info("Disconnecting."),this.userDisconnect=!0,this.config.keepAlive&&this.heartbeatIntervallId!==void 0&&clearInterval(this.heartbeatIntervallId),(e=this.socket)==null||e.close()}heartbeat(){this.isAlive=!0,this.printDebug("CLIENT-SIDE HEARTBEAT")}onDownStream(e){this.printDebug("Received message from dingtalk websocket server"),this.printDebug(e),console.log(e);let n=JSON.parse(e);switch(n.type){case"SYSTEM":this.onSystem(n);break;case"EVENT":this.onEvent(n);break;case"CALLBACK":this.onCallback(n);break}}onSystem(e){var n;switch(e.headers.topic){case"CONNECTED":{this.printDebug("CONNECTED");break}case"REGISTERED":{this.registered=!0,this.reconnecting=!1;break}case"disconnect":{this.connected=!1,this.registered=!1;break}case"KEEPALIVE":{this.heartbeat();break}case"ping":{this.printDebug("PING"),(n=this.socket)==null||n.send(JSON.stringify({code:200,headers:e.headers,message:"OK",data:e.data}));break}}}onEvent(e){var n;this.printDebug("received event, message="+JSON.stringify(e));let r=this.onEventReceived(e);(n=this.socket)==null||n.send(JSON.stringify({code:200,headers:{contentType:"application/json",messageId:e.headers.messageId},message:"OK",data:JSON.stringify(r)}))}onCallback(e){this.emit(e.headers.topic,e)}send(e,n){var r;if(!e)throw console.error("send: messageId must be defined"),new Error("send: messageId must be defined");let s={code:200,headers:{contentType:"application/json",messageId:e},message:"OK",data:JSON.stringify(n)};(r=this.socket)==null||r.send(JSON.stringify(s))}};l();function Us(t){let e=t.trim();if(!e.includes("-"))return!1;let n=e.replace(/^\|/,"").replace(/\|$/,"").split("|").map(r=>r.trim());return n.length>0&&n.every(r=>/^:?-{3,}:?$/.test(r))}function Br(t){let e=t.trim();return e.includes("|")&&!e.startsWith("```")}function Fs(t){return t.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>e.trim())}function Ms(t){return t.map(Fs).filter(n=>n.length>0).map(n=>n.join(" | ")).join(`
10
- `)}function Hs(t){let e=t.split(`
11
- `),n=[],r=0,s=!1;for(;r<e.length;){let i=e[r]||"";if(i.trim().startsWith("```")){s=!s,n.push(i),r++;continue}if(!s&&r+1<e.length&&Br(i)&&Us(e[r+1]||"")){let o=[i];for(r+=2;r<e.length&&Br(e[r]||"");)o.push(e[r]||""),r++;n.push(Ms(o));continue}n.push(i),r++}return n.join(`
12
- `)}function vs(t){if(!t||t.length<=3800)return[t];let e=[],n="",r=t.split(`
13
- `),s=!1;for(let i of r){let o=(i.match(/```/g)||[]).length;n.length+i.length+1>3800&&n.length>0&&(s&&(n+="\n```"),e.push(n),n=s?"```":""),n+=(n?`
14
- `:"")+i,o%2===1&&(s=!s)}return n&&e.push(n),e}function Ir(t){return(t.split(`
15
- `)[0]||"").replace(/^[#*\s\->]+/,"").slice(0,20)||"Reply"}function Ur(t){let e=Hs(t);return vs(e)}l();var qs="https://api.dingtalk.com/v1.0/robot/messageFiles/download";async function Nt(t,e,n){if(!t||!e||!n)return null;try{let r=await fetch(qs,{method:"POST",headers:{"x-acs-dingtalk-access-token":n,"Content-Type":"application/json"},body:JSON.stringify({downloadCode:t,robotCode:e})});if(!r.ok){let u=await r.text().catch(()=>"");return process.stderr.write(`[DingTalk] downloadMedia API failed: HTTP ${r.status} ${u}
16
- `),null}let s=await r.json(),i=s.downloadUrl??s.data?.downloadUrl;if(!i)return process.stderr.write(`[DingTalk] downloadMedia: no downloadUrl in response
17
- `),null;let o=await fetch(i);if(!o.ok)return process.stderr.write(`[DingTalk] downloadMedia file fetch failed: HTTP ${o.status}
18
- `),null;let c=o.headers.get("content-type")||"application/octet-stream";return{buffer:Buffer.from(await o.arrayBuffer()),mimeType:c}}catch(r){return process.stderr.write(`[DingTalk] downloadMedia error: ${r instanceof Error?r.message:r}
19
- `),null}}var Vs=5*60*1e3,Lt="\u{1F440}",Ks="2659900",Gs="im_bg_1",Xs="https://api.dingtalk.com/v1.0/robot/emotion",Be=class extends Bt{client;seenMessages=new Map;dedupTimer;webhooks=new Map;constructor(e,n,r,s){if(super(e,n,r,s),!n.clientId||!n.clientSecret)throw new Error(`Channel "${e}" requires clientId and clientSecret for DingTalk.`);this.client=new Pe({clientId:n.clientId,clientSecret:n.clientSecret})}async connect(){this.client.registerCallbackListener(Ye,e=>{this.client.send(e.headers.messageId,{status:Ge.SUCCESS,message:"ok"}),this.onMessage(e)}),await this.client.connect(),this.dedupTimer=setInterval(()=>{let e=Date.now();for(let[n,r]of this.seenMessages)e-r>Vs&&this.seenMessages.delete(n)},6e4),process.stderr.write(`[DingTalk:${this.name}] Connected via stream.
20
- `)}async sendMessage(e,n){let r=this.webhooks.get(e);if(!r){process.stderr.write(`[DingTalk:${this.name}] No webhook for chatId ${e}, cannot send.
21
- `);return}let s=Ur(n),i=Ir(n);for(let o=0;o<s.length;o++){let c=s[o],d={msgtype:"markdown",markdown:{title:o===0?i:`${i} (cont.)`,text:c}},u=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!u.ok){let f=await u.text().catch(()=>"");process.stderr.write(`[DingTalk:${this.name}] sendMessage failed: HTTP ${u.status} ${f}
22
- `)}}}getAccessToken(){return this.client.getConfig().access_token}async emotionApi(e,n,r){let s=this.getAccessToken();if(!s)return;let i=this.config.clientId;if(!(!i||!n||!r))try{let o=await fetch(`${Xs}/${e}`,{method:"POST",headers:{"x-acs-dingtalk-access-token":s,"Content-Type":"application/json"},body:JSON.stringify({robotCode:i,openMsgId:n,openConversationId:r,emotionType:2,emotionName:Lt,textEmotion:{emotionId:Ks,emotionName:Lt,text:Lt,backgroundId:Gs}})});if(!o.ok){let c=await o.text().catch(()=>"");process.stderr.write(`[DingTalk:${this.name}] emotion/${e} failed: ${o.status} ${c}
23
- `)}}catch{}}async attachReaction(e,n){await this.emotionApi("reply",e,n)}async recallReaction(e,n){await this.emotionApi("recall",e,n)}disconnect(){this.dedupTimer&&clearInterval(this.dedupTimer),this.client.disconnect(),process.stderr.write(`[DingTalk:${this.name}] Disconnected.
24
- `)}isConversationId(e){return!!e&&!e.startsWith("http")}onPromptStart(e,n,r){!r||!this.isConversationId(e)||this.attachReaction(r,e).catch(()=>{})}onPromptEnd(e,n,r){!r||!this.isConversationId(e)||this.recallReaction(r,e).catch(()=>{})}extractQuotedContext(e){if(e.text?.isReplyMsg&&e.text.repliedMsg){let n=e.text.repliedMsg,r=!!e.chatbotUserId&&n.senderId===e.chatbotUserId;return{referencedText:this.summarizeRepliedContent(n)||void 0,isReplyToBot:r}}if(e.quoteMessage){let n=e.quoteMessage,r=!!e.chatbotUserId&&n.senderId===e.chatbotUserId;return{referencedText:n.text?.content?.trim()||void 0,isReplyToBot:r}}return{isReplyToBot:!1}}summarizeRepliedContent(e){let n=e.msgType,r=e.content;if(r?.text?.trim())return r.text.trim();if(r?.richText&&Array.isArray(r.richText)){let s=[];for(let o of r.richText){let c=o.type||"text";c==="text"&&o.text?s.push(o.text):c==="picture"?s.push("[image]"):c==="at"&&o.atName&&s.push(`@${o.atName}`)}let i=s.join("").trim();if(i)return i}switch(n){case"picture":return"[image]";case"file":return`[file: ${r?.fileName||"file"}]`;case"audio":return"[audio]";case"video":return"[video]";default:break}return""}extractContent(e){let n=e.msgtype||"text";if(n==="richText"){let r=e.content?.richText;if(!Array.isArray(r))return{text:"",downloadCodes:[]};let s="",i=[];for(let o of r){let c=o.type||"text";c==="text"&&o.text?s+=o.text:c==="picture"&&o.downloadCode&&i.push(o.downloadCode)}return{text:s.trim()||(i.length>0?"(image)":""),downloadCodes:i,mediaType:i.length>0?"image":void 0}}if(n==="picture"){let r=e.content?.downloadCode;return{text:"(image)",downloadCodes:r?[r]:[],mediaType:"image"}}if(n==="file"){let r=e.content?.downloadCode,s=e.content?.fileName||void 0;return{text:`(file: ${s||"file"})`,downloadCodes:r?[r]:[],mediaType:"file",fileName:s}}if(n==="audio"){let r=e.content?.downloadCode;return{text:e.content?.recognition||"(audio)",downloadCodes:r?[r]:[],mediaType:"audio"}}if(n==="video"){let r=e.content?.downloadCode;return{text:"(video)",downloadCodes:r?[r]:[],mediaType:"video"}}return{text:e.text?.content?.trim()||"",downloadCodes:[]}}async attachMedia(e,n,r,s){let i=this.getAccessToken(),o=this.config.clientId;if(!i||!o){process.stderr.write(`[DingTalk:${this.name}] Cannot download media: missing token or robotCode.
25
- `);return}let c=await Nt(n,o,i);if(c)if(r==="image"){let d=c.mimeType.startsWith("image/")?c.mimeType:"image/jpeg";e.attachments=[...e.attachments||[],{type:"image",data:c.buffer.toString("base64"),mimeType:d}]}else{let d=Fr(Ws(),"channel-files",zs());js(d,{recursive:!0});let u=Js(s||"")||`dingtalk_${r}_${Date.now()}`,f=Fr(d,u);$s(f,c.buffer),(e.text===`(file: ${s||"file"})`||e.text==="(audio)"||e.text==="(video)")&&(e.text=""),e.attachments=[...e.attachments||[],{type:r,filePath:f,mimeType:c.mimeType,fileName:u}]}}onMessage(e){try{let n=typeof e.data=="string"?JSON.parse(e.data):e.data,r=n.msgId||e.headers.messageId;if(r&&this.seenMessages.has(r))return;r&&this.seenMessages.set(r,Date.now());let s=n.conversationType==="2",i=n.sessionWebhook,o=n.conversationId;if(!i){process.stderr.write(`[DingTalk:${this.name}] No sessionWebhook in message, skipping.
26
- `);return}o&&this.webhooks.set(o,i);let c=!!n.isInAtList,d=this.extractContent(n),u=d.text;c&&(u=u.replace(/@\S+/,"").trim());let f=this.extractQuotedContext(n),h=o||i,b=c?u:u||d.text,R={channelName:this.name,senderId:n.senderStaffId||n.senderId||"",senderName:n.senderNick||"Unknown",chatId:h,text:b,isGroup:s,isMentioned:c,isReplyToBot:f.isReplyToBot,referencedText:f.referencedText};R.messageId=r,(async()=>{d.downloadCodes.length>0&&d.mediaType&&await this.attachMedia(R,d.downloadCodes[0],d.mediaType,d.fileName),await this.handleInbound(R)})().catch(g=>{process.stderr.write(`[DingTalk:${this.name}] Error handling message: ${g}
27
- `),this.sendMessage(h,"Sorry, something went wrong processing your message.").catch(()=>{})})}catch(n){process.stderr.write(`[DingTalk:${this.name}] Failed to parse message: ${n}
28
- `)}}};var Bu={channelType:"dingtalk",displayName:"DingTalk",requiredConfigFields:["clientId","clientSecret"],createChannel:(t,e,n,r)=>new Be(t,e,n,r)};export{Be as DingtalkChannel,Nt as downloadMedia,Bu as plugin};
@@ -1,23 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a as M,b as A,c as P,f as _,h as N,i as E,j as W,k as D,l as B,m as L}from"./chunk-6GBNB5Z2.js";import{f as C}from"./chunk-EQGA7LH7.js";import"./chunk-T2T2UEPY.js";import"./chunk-M53RP3YP.js";import{b as p}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";p();p();import{mkdirSync as Ue,writeFileSync as Ce}from"node:fs";import{randomUUID as Me}from"node:crypto";import{basename as Ae,join as Z}from"node:path";import{tmpdir as Pe}from"node:os";p();p();var h={NONE:0,USER:1,BOT:2},g={NONE:0,TEXT:1,IMAGE:2,VOICE:3,FILE:4,VIDEO:5},T={NEW:0,GENERATING:1,FINISH:2},$={TYPING:1,CANCEL:2};import{existsSync as re,readFileSync as ne,writeFileSync as oe}from"node:fs";import{join as ie}from"node:path";var F=new Map;function k(e){return F.get(e)}function R(){return ie(A(),"cursor.txt")}function se(){let e=R();return re(e)?ne(e,"utf-8").trim():""}function ae(e){oe(R(),e,"utf-8")}async function G(e){let{baseUrl:t,token:o,onMessage:r,abortSignal:i}=e,s=se(),c=0,a=4e4;for(process.stderr.write(`[weixin] Starting message poll loop...
4
- `);!i.aborted;)try{let n=await N(t,o,s,a,i);if(n.errcode===-14){process.stderr.write(`[weixin] Session expired (errcode -14). Pausing 30s...
5
- `),await new Promise(l=>setTimeout(l,3e4));continue}if(n.ret!==0&&n.ret!==void 0)throw new Error(`getUpdates error: ret=${n.ret} errcode=${n.errcode} ${n.errmsg}`);if(c=0,n.longpolling_timeout_ms&&n.longpolling_timeout_ms>0&&(a=n.longpolling_timeout_ms+5e3),n.msgs&&n.msgs.length>0)for(let l of n.msgs)await ce(l,r);n.get_updates_buf&&(s=n.get_updates_buf,ae(s))}catch(n){if(i.aborted)break;c++,process.stderr.write(`[weixin] Poll error (${c}): ${n instanceof Error?n.message:n}
6
- `),c>=3?(process.stderr.write(`[weixin] Too many consecutive errors, backing off 30s...
7
- `),await new Promise(l=>setTimeout(l,3e4)),c=0):await new Promise(l=>setTimeout(l,2e3))}process.stderr.write(`[weixin] Poll loop stopped.
8
- `)}async function ce(e,t){if(e.message_type!==h.USER)return;let o=e.from_user_id;if(!o)return;e.context_token&&F.set(o,e.context_token);let r="",i,s,c;if(e.item_list)for(let a of e.item_list){if(a.type===g.TEXT&&a.text_item?.text&&(r+=(r?`
9
- `:"")+a.text_item.text),a.ref_msg){let n=a.ref_msg.message_item;n?.text_item?.text?c=n.text_item.text:a.ref_msg.title&&(c=a.ref_msg.title)}if(a.type===g.IMAGE&&a.image_item){let n=a.image_item.media;n?.encrypt_query_param&&n.aes_key&&(i={encryptQueryParam:n.encrypt_query_param,aesKey:n.aes_key})}else if(a.type===g.FILE&&a.file_item){let n=a.file_item.media;n?.encrypt_query_param&&n.aes_key&&(s={encryptQueryParam:n.encrypt_query_param,aesKey:n.aes_key,fileName:a.file_item.file_name||`file_${Date.now()}`})}}!r&&!i&&!s||await t({fromUserId:o,messageId:String(e.message_id||""),text:r||(s?`(file: ${s.fileName})`:"(image)"),image:i,file:s,refText:c})}p();import{randomBytes as j,randomUUID as Q}from"node:crypto";import{readFileSync as he,statSync as ye,realpathSync as b,openSync as xe,readSync as we,closeSync as _e}from"node:fs";import{tmpdir as K}from"node:os";import{resolve as q,extname as be,win32 as Ee,posix as Te}from"node:path";p();import{createCipheriv as le,createDecipheriv as me,createHash as pe}from"node:crypto";var fe="https://novac2c.cdn.weixin.qq.com/c2c";function ge(e){return`${fe}/download?encrypted_query_param=${encodeURIComponent(e)}`}function de(e,t){let o=me("aes-128-ecb",t,null);return Buffer.concat([o.update(e),o.final()])}function ue(e){let t=Buffer.from(e,"base64");if(t.length===16)return t;if(t.length===32&&/^[0-9a-fA-F]{32}$/.test(t.toString("ascii")))return Buffer.from(t.toString("ascii"),"hex");throw new Error(`Invalid aes_key: expected 16 raw bytes or 32 hex chars, got ${t.length} bytes`)}async function I(e,t){let o=ge(e),r=new AbortController,i=setTimeout(()=>r.abort(),4e4);try{let s=await fetch(o,{signal:r.signal});if(!s.ok)throw new Error(`CDN download failed: HTTP ${s.status}`);let c=Buffer.from(await s.arrayBuffer()),a=ue(t);return de(c,a)}finally{clearTimeout(i)}}function O(e,t){let o=le("aes-128-ecb",t,null);return Buffer.concat([o.update(e),o.final()])}function v(e){return pe("md5").update(e).digest("hex")}function $e(e){return e.replace(/```[\s\S]*?\n([\s\S]*?)```/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/\*\*\*(.+?)\*\*\*/g,"$1").replace(/\*\*(.+?)\*\*/g,"$1").replace(/\*(.+?)\*/g,"$1").replace(/___(.+?)___/g,"$1").replace(/__(.+?)__/g,"$1").replace(/_(.+?)_/g,"$1").replace(/~~(.+?)~~/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1 ($2)").replace(/!\[([^\]]*)\]\([^)]+\)/g,"[$1]").replace(/^>\s+/gm,"").replace(/^[-*_]{3,}$/gm,"---").replace(/^[\s]*[-*+]\s+/gm,"- ").replace(/^[\s]*(\d+)\.\s+/gm,"$1. ").replace(/\n{3,}/g,`
10
-
11
- `).trim()}var ke=new Set([".png",".jpg",".jpeg",".gif",".webp"]),z=20*1024*1024;function H(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")}function X(e){return e.replace(/\//g,"\\")}function Ie(e,t){let o=H(e)||H(t),r=o?Ee:Te,i=o?X(t):t,s=o?X(e):e,c=r.relative(i,s);return c===""||!c.startsWith("..")&&!r.isAbsolute(c)}function S(e){if(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return"image/png";if(e[0]===71&&e[1]===73&&e[2]===70)return"image/gif";if(e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70)return"image/webp";if(e[0]===255&&e[1]===216&&e[2]===255)return"image/jpeg";throw new Error("Unrecognized image format: magic bytes do not match any supported type")}function Se(e,t=[]){let o=q(e),r=be(o).toLowerCase();if(!ke.has(r))throw new Error(`Image extension not allowed: ${r} (path: ${o})`);let i=(()=>{try{return b(o)}catch{throw new Error(`Image file not found: ${o}`)}})(),s=ye(i);if(!s.isFile())throw new Error(`Not a regular file: ${i}`);if(s.size>z)throw new Error(`Image too large: ${s.size} bytes (max ${z})`);if(!["/tmp/",b("/tmp/")+"/",K()+"/",b(K())+"/",...t.map(n=>b(q(n))+"/")].some(n=>Ie(i,n)))throw new Error(`Image path outside allowed directories: ${i}`);let a;try{a=xe(i,"r");let n=Buffer.alloc(16),l=we(a,n,0,16,0),m=S(n.slice(0,l)),f={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"}[r];if(m!==f)throw new Error(`Image type mismatch: ext=${r} expects ${f} but got ${m}`)}finally{a!==void 0&&_e(a)}return i}async function U(e){let{to:t,text:o,baseUrl:r,token:i,contextToken:s}=e,c=$e(o);await E(r,i,{to_user_id:t,from_user_id:"",client_id:Q(),message_type:h.BOT,message_state:T.FINISH,context_token:s,item_list:[{type:g.TEXT,text_item:{text:c}}]})}async function Y(e){let{to:t,imagePath:o,baseUrl:r,token:i,contextToken:s,workspaceDirs:c}=e,a=Se(o,c),n=he(a),l=n.length,m=v(n),d=j(16),f=d.toString("hex"),x=j(16).toString("hex"),w=Math.ceil((l+1)/16)*16,u=await B(r,i,t,x,l,m,w,f),V=O(n,d),ee=await L(u,x,V),te=Buffer.from(f,"ascii").toString("base64");await E(r,i,{to_user_id:t,from_user_id:"",client_id:Q(),message_type:h.BOT,message_state:T.FINISH,context_token:s,item_list:[{type:g.IMAGE,image_item:{aeskey:f,mid_size:w,media:{encrypt_query_param:ee,aes_key:te,encrypt_type:1}}}]})}var J=new Map;function Ne(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var y=class extends C{abortController=null;baseUrl;token="";constructor(t,o,r,i){super(t,o,r,i),this.baseUrl=o.baseUrl||M}async connect(){let t=["","If you created an image file (screenshot, chart, etc.), you can send it to the user by writing:","[IMAGE: /absolute/path/to/file.png]","","The marker is stripped from text and the image is uploaded automatically.","","CRITICAL: Only use real file paths. Do NOT write [IMAGE: ...] with:","- Example paths like /path/to/file or /tmp/cat.png","- Placeholder symbols like ...","- Paths that don't exist on disk"].join(`
12
- `);this.config.instructions?this.config.instructions.includes("[IMAGE:")||(this.config.instructions=this.config.instructions+`
13
- `+t):this.config.instructions=["## WeChat Channel","","You are a concise coding assistant responding via WeChat.","Keep responses under 500 characters. Use plain text only.","","Users can also send you images.",t].join(`
14
- `);let o=P();if(!o)throw new Error('WeChat account not configured. Run "matilda channel configure-weixin" first.');this.token=o.token,o.baseUrl&&(this.baseUrl=o.baseUrl),this.abortController=new AbortController,G({baseUrl:this.baseUrl,token:this.token,onMessage:async r=>{let i={channelName:this.name,senderId:r.fromUserId,senderName:r.fromUserId,chatId:r.fromUserId,text:r.text,isGroup:!1,isMentioned:!1,isReplyToBot:!1,referencedText:r.refText};this.handleInboundWithMedia(i,r.image,r.file).catch(s=>{let c=s instanceof Error?s.message:JSON.stringify(s,null,2);process.stderr.write(`[Weixin:${this.name}] Error handling message: ${c}
15
- `)})},abortSignal:this.abortController.signal}).catch(r=>{this.abortController?.signal.aborted||process.stderr.write(`[Weixin:${this.name}] Poll loop error: ${r}
16
- `)}),process.stderr.write(`[Weixin:${this.name}] Connected to WeChat (${this.baseUrl})
17
- `)}onPromptStart(t){this.setTyping(t,!0).catch(()=>{})}onPromptEnd(t){this.setTyping(t,!1).catch(()=>{})}async handleInboundWithMedia(t,o,r){if(o)try{let i=await I(o.encryptQueryParam,o.aesKey);t.imageBase64=i.toString("base64"),t.imageMimeType=S(i)}catch(i){process.stderr.write(`[Weixin:${this.name}] Failed to download image: ${i instanceof Error?i.message:i}
18
- `)}if(r)try{let i=await I(r.encryptQueryParam,r.aesKey),s=Z(Pe(),"channel-files",Me());Ue(s,{recursive:!0});let c=Z(s,Ae(r.fileName)||`file_${Date.now()}`);Ce(c,i),t.attachments=[{type:"file",filePath:c,mimeType:"application/octet-stream",fileName:r.fileName}]}catch(i){process.stderr.write(`[Weixin:${this.name}] Failed to download file: ${i instanceof Error?i.message:i}
19
- `),t.text=`(User sent a file "${r.fileName}" but download failed)`}await super.handleInbound(t)}async sendMessage(t,o){let r=k(t)||"",i=o.replace(/```[\s\S]*?```/g,"").replace(/`[^`]*`/g,""),s=/\[IMAGE:\s*([^\]]+)\]/gi,c=[];for(let n of i.matchAll(s)){let l=n[1]?.trim();l&&c.push(l)}let a=o;for(let n of c)a=a.replace(new RegExp(`\\[IMAGE:\\s*${Ne(n)}\\]`,"gi"),"");if(a=a.replace(/\n{3,}/g,`
20
-
21
- `).trim(),a&&await U({to:t,text:a,baseUrl:this.baseUrl,token:this.token,contextToken:r}),c.length){let n=[this.config.cwd];for(let l of c)try{await Y({to:t,imagePath:l,baseUrl:this.baseUrl,token:this.token,contextToken:r,workspaceDirs:n})}catch(m){let d=m instanceof _?m.status:0,f=m instanceof _?m.ret:void 0,x=m instanceof _?m.errcode:void 0,w=m instanceof Error?m.message:String(m);process.stderr.write(`[Weixin:${this.name}] Failed to send image (status=${d} ret=${f} errcode=${x}): ${w}
22
- `);try{await U({to:t,text:"\u56FE\u7247\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",baseUrl:this.baseUrl,token:this.token,contextToken:r})}catch(u){process.stderr.write(`[Weixin:${this.name}] Fallback text also failed: ${u instanceof Error?u.message:String(u)}
23
- `)}}}}disconnect(){this.abortController&&(this.abortController.abort(),this.abortController=null)}async setTyping(t,o){try{let r=J.get(t);if(!r){let i=k(t),s=await W(this.baseUrl,this.token,t,i);s.typing_ticket&&(r=s.typing_ticket,J.set(t,r))}if(!r)return;await D(this.baseUrl,this.token,{ilink_user_id:t,typing_ticket:r,status:o?$.TYPING:$.CANCEL})}catch{}}};var ut={channelType:"weixin",displayName:"WeChat",createChannel:(e,t,o,r)=>new y(e,t,o,r)};export{y as WeixinChannel,ut as plugin};
@@ -1,3 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{c as h,d as j}from"./chunk-4Q2SNBUH.js";import{a as P}from"./chunk-O44XK65C.js";import{b as l}from"./chunk-GZPNIYVZ.js";import{f as b}from"./chunk-OWGSC52X.js";l();var p=b(P(),1);import{statSync as S,createReadStream as _,promises as u}from"fs";import{basename as g}from"path";l();var M=e=>Object.prototype.toString.call(e).slice(8,-1).toLowerCase();function F(e){if(M(e)!=="object")return!1;let t=Object.getPrototypeOf(e);return t==null?!0:(t.constructor&&t.constructor.toString())===Object.toString()}var m=F;var w=function(e,t,r,i,o){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?o.call(e,r):o?o.value=r:t.set(e,r),r},a=function(e,t,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(e):i?i.value:t.get(e)},s,c,E="The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.",d=class e{constructor(t){s.set(this,void 0),c.set(this,void 0),w(this,s,t.path,"f"),w(this,c,t.start||0,"f"),this.name=g(a(this,s,"f")),this.size=t.size,this.lastModified=t.lastModified}slice(t,r){return new e({path:a(this,s,"f"),lastModified:this.lastModified,size:r-t,start:t})}async*stream(){let{mtimeMs:t}=await u.stat(a(this,s,"f"));if(t>this.lastModified)throw new p.default(E,"NotReadableError");this.size&&(yield*_(a(this,s,"f"),{start:a(this,c,"f"),end:a(this,c,"f")+this.size-1}))}get[(s=new WeakMap,c=new WeakMap,Symbol.toStringTag)](){return"File"}};function y(e,{mtimeMs:t,size:r},i,o={}){let n;m(i)?[o,n]=[i,void 0]:n=i;let f=new d({path:e,size:r,lastModified:t});return n||(n=f.name),new h([f],n,{...o,lastModified:f.lastModified})}function O(e,t,r={}){let i=S(e);return y(e,i,t,r)}async function q(e,t,r){let i=await u.stat(e);return y(e,i,t,r)}export{q as fileFromPath,O as fileFromPathSync,j as isFile};
@@ -1,8 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a as g}from"./chunk-6EQMZNIY.js";import{g as u}from"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import{f as d}from"./chunk-SDTWBD62.js";import"./chunk-LUNDTQ3G.js";import"./chunk-27Q5KW3A.js";import"./chunk-FWDMPRKU.js";import{b as m}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";m();m();var p=class{googleGenAI;contentGeneratorConfig;constructor(e,t){let r=t?.customHeaders,n=r?(()=>{let i=e.httpOptions,s=i?.headers??{},l=Object.fromEntries(Object.entries(r).filter(([a])=>!d(a)));return{...e,httpOptions:{...i??{},headers:{...s,...l}}}})():e;this.googleGenAI=new u(n),this.contentGeneratorConfig=t}buildGenerateContentConfig(e){let t=this.contentGeneratorConfig?.samplingParams,r=e.config||{},n=(i,s,l)=>{let a=r[s];return i!==void 0?i:a!==void 0?a:l};return{...r,temperature:n(t?.temperature,"temperature",1),topP:n(t?.top_p,"topP",.95),topK:n(t?.top_k,"topK",64),maxOutputTokens:n(t?.max_tokens,"maxOutputTokens"),presencePenalty:n(t?.presence_penalty,"presencePenalty"),frequencyPenalty:n(t?.frequency_penalty,"frequencyPenalty"),thinkingConfig:n(this.buildThinkingConfig(),"thinkingConfig",{includeThoughts:!0,thinkingLevel:"THINKING_LEVEL_UNSPECIFIED"})}}buildThinkingConfig(){let e=this.contentGeneratorConfig?.reasoning;if(e===!1)return{includeThoughts:!1};if(e)return{includeThoughts:!0,thinkingLevel:e.effort==="low"?"LOW":e.effort==="high"||e.effort==="max"?"HIGH":"THINKING_LEVEL_UNSPECIFIED"}}async generateContent(e,t){let r={...e,contents:this.stripUnsupportedFields(e.contents),config:this.buildGenerateContentConfig(e)};return this.googleGenAI.models.generateContent(r)}async generateContentStream(e,t){let r={...e,contents:this.stripUnsupportedFields(e.contents),config:this.buildGenerateContentConfig(e)};return this.googleGenAI.models.generateContentStream(r)}stripUnsupportedFields(e){return!e||typeof e=="string"?e:Array.isArray(e)?e.map(t=>this.stripContentFields(t)):this.stripContentFields(e)}stripContentFields(e){if(typeof e=="string")return e;if(!("role"in e)&&!("parts"in e))return this.stripPartFields(e);let t=e;return t.parts?{...t,parts:t.parts.map(r=>this.stripPartFields(r))}:t}stripPartFields(e){if(typeof e=="string")return e;let t={...e};if(t.inlineData){let{displayName:r,...n}=t.inlineData;t.inlineData=n}if(t.fileData){let{displayName:r,...n}=t.fileData;t.fileData=n}if(t.functionResponse?.parts){let r=t.functionResponse.parts.map(n=>{let i=this.convertUnsupportedMediaToText(n);return this.stripPartFields(i)});t.functionResponse={...t.functionResponse,parts:r}}return t}convertUnsupportedMediaToText(e){if(typeof e=="string")return e;let t=e.inlineData?.mimeType||"",r=e.fileData?.mimeType||"";if(t.startsWith("audio/")||t.startsWith("video/")){let n=e.inlineData?.displayName,i=n?` (${n})`:"";return{text:`Unsupported media type for Gemini: ${t}${i}.`}}if(r.startsWith("audio/")||r.startsWith("video/")){let n=e.fileData?.displayName,i=n?` (${n})`:"";return{text:`Unsupported media type for Gemini: ${r}${i}.`}}return e}async countTokens(e){return this.googleGenAI.models.countTokens(e)}async embedContent(e){return this.googleGenAI.models.embedContent(e)}useSummarizedThinking(){return!0}};function T(o,e){let i={...{"User-Agent":o.userAgent||`MatildaCode/0.21.12 (${process.platform}; ${process.arch})`}};if(e?.getUsageStatisticsEnabled()){let f=new g().getInstallationId();i={...i,"x-gemini-api-privileged-user-id":`${f}`}}let s=o.baseUrl?{headers:i,baseUrl:o.baseUrl}:{headers:i};return new p({apiKey:o.apiKey===""?void 0:o.apiKey,vertexai:o.vertexai,httpOptions:s},o)}export{p as GeminiContentGenerator,T as createGeminiContentGenerator};
4
- /**
5
- * @license
6
- * Copyright 2025 Google LLC
7
- * SPDX-License-Identifier: Apache-2.0
8
- */