gemi 0.83.0 → 0.84.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/dist/ai/Agent.d.ts +38 -0
  2. package/dist/ai/Agent.d.ts.map +1 -1
  3. package/dist/ai/generate.d.ts +177 -0
  4. package/dist/ai/generate.d.ts.map +1 -0
  5. package/dist/ai/index.d.ts +2 -0
  6. package/dist/ai/index.d.ts.map +1 -1
  7. package/dist/ai/index.js +11 -11
  8. package/dist/ai/index.js.map +7 -5
  9. package/dist/ai/runtime.d.ts +115 -0
  10. package/dist/ai/runtime.d.ts.map +1 -0
  11. package/dist/ai/types.d.ts +4 -0
  12. package/dist/ai/types.d.ts.map +1 -1
  13. package/dist/app/App.d.ts +0 -5
  14. package/dist/app/App.d.ts.map +1 -1
  15. package/dist/app/index.js +1 -1
  16. package/dist/auth/AuthController.d.ts.map +1 -1
  17. package/dist/auth/accessToken.d.ts +45 -0
  18. package/dist/auth/accessToken.d.ts.map +1 -0
  19. package/dist/auth/config.d.ts +3 -3
  20. package/dist/auth/signInRedirect.d.ts +1 -1
  21. package/dist/bin/gemi.js +2 -33
  22. package/dist/bin/gemi.js.map +6 -6
  23. package/dist/bin/migrate/index.d.ts.map +1 -1
  24. package/dist/bin/migrate/tables.d.ts.map +1 -1
  25. package/dist/bun/plugin.js +1 -1
  26. package/dist/bun/preload.js +1 -1
  27. package/dist/{chunk-7dk4b1fn.js → chunk-159hyeng.js} +2 -2
  28. package/dist/{chunk-7dk4b1fn.js.map → chunk-159hyeng.js.map} +1 -1
  29. package/dist/{chunk-fya5147b.js → chunk-1cebv3h8.js} +2 -2
  30. package/dist/{chunk-fya5147b.js.map → chunk-1cebv3h8.js.map} +1 -1
  31. package/dist/{chunk-gzx3rskd.js → chunk-1evk2pma.js} +4 -4
  32. package/dist/{chunk-gzx3rskd.js.map → chunk-1evk2pma.js.map} +1 -1
  33. package/dist/{chunk-hfxx52vr.js → chunk-1s914cdj.js} +3 -3
  34. package/dist/{chunk-hfxx52vr.js.map → chunk-1s914cdj.js.map} +1 -1
  35. package/dist/chunk-302mkqeq.js +7 -0
  36. package/dist/{chunk-817dxq6w.js.map → chunk-302mkqeq.js.map} +4 -4
  37. package/dist/{chunk-03xrgp1m.js → chunk-3z6wkvwj.js} +2 -2
  38. package/dist/{chunk-03xrgp1m.js.map → chunk-3z6wkvwj.js.map} +1 -1
  39. package/dist/{chunk-2gprnzc3.js → chunk-3zb2ycxj.js} +2 -2
  40. package/dist/{chunk-2gprnzc3.js.map → chunk-3zb2ycxj.js.map} +1 -1
  41. package/dist/{chunk-9146818v.js → chunk-495qwteq.js} +3 -3
  42. package/dist/{chunk-9146818v.js.map → chunk-495qwteq.js.map} +1 -1
  43. package/dist/chunk-49akdtfe.js +17 -0
  44. package/dist/{chunk-rs0xmd64.js.map → chunk-49akdtfe.js.map} +11 -12
  45. package/dist/{chunk-0e5z1x9w.js → chunk-53we503k.js} +2 -2
  46. package/dist/{chunk-0e5z1x9w.js.map → chunk-53we503k.js.map} +3 -3
  47. package/dist/{chunk-q7ngq6c5.js → chunk-57ryyhh3.js} +2 -2
  48. package/dist/{chunk-q7ngq6c5.js.map → chunk-57ryyhh3.js.map} +1 -1
  49. package/dist/{chunk-mc1xsz8j.js → chunk-73dk6k4p.js} +3 -3
  50. package/dist/{chunk-mc1xsz8j.js.map → chunk-73dk6k4p.js.map} +1 -1
  51. package/dist/{chunk-t2htq1v0.js → chunk-82nn71zs.js} +2 -2
  52. package/dist/{chunk-t2htq1v0.js.map → chunk-82nn71zs.js.map} +1 -1
  53. package/dist/{chunk-bwwjkdts.js → chunk-87x692j7.js} +2 -2
  54. package/dist/{chunk-bwwjkdts.js.map → chunk-87x692j7.js.map} +1 -1
  55. package/dist/{chunk-zv7417j0.js → chunk-8mmfpqgs.js} +2 -2
  56. package/dist/{chunk-v0j7spj5.js.map → chunk-8mmfpqgs.js.map} +1 -1
  57. package/dist/{chunk-d2tpgkg2.js → chunk-ah9ajys0.js} +1 -1
  58. package/dist/{chunk-zbhqa2z7.js → chunk-ash9e6fn.js} +2 -2
  59. package/dist/{chunk-zbhqa2z7.js.map → chunk-ash9e6fn.js.map} +1 -1
  60. package/dist/{chunk-mmq47yh3.js → chunk-aztkrzvf.js} +2 -2
  61. package/dist/{chunk-mmq47yh3.js.map → chunk-aztkrzvf.js.map} +1 -1
  62. package/dist/chunk-b9dejyaq.js +6 -0
  63. package/dist/{chunk-cmj9xnbp.js.map → chunk-b9dejyaq.js.map} +2 -2
  64. package/dist/{chunk-actjm3wr.js → chunk-bn9pzgww.js} +2 -2
  65. package/dist/{chunk-actjm3wr.js.map → chunk-bn9pzgww.js.map} +1 -1
  66. package/dist/{chunk-2frgq249.js → chunk-cfvq30n4.js} +2 -2
  67. package/dist/{chunk-2frgq249.js.map → chunk-cfvq30n4.js.map} +1 -1
  68. package/dist/{chunk-egw90hq5.js → chunk-cg4k40zy.js} +2 -2
  69. package/dist/{chunk-egw90hq5.js.map → chunk-cg4k40zy.js.map} +1 -1
  70. package/dist/{chunk-1dgab0qn.js → chunk-d0qwdeza.js} +2 -2
  71. package/dist/{chunk-1dgab0qn.js.map → chunk-d0qwdeza.js.map} +1 -1
  72. package/dist/{chunk-1k783c44.js → chunk-dvpxkzms.js} +2 -2
  73. package/dist/{chunk-1k783c44.js.map → chunk-dvpxkzms.js.map} +1 -1
  74. package/dist/chunk-e43drft2.js +5 -0
  75. package/dist/{chunk-z9x8fx21.js.map → chunk-e43drft2.js.map} +5 -7
  76. package/dist/{chunk-8ndqqsf0.js → chunk-ekppwzyg.js} +2 -2
  77. package/dist/{chunk-8ndqqsf0.js.map → chunk-ekppwzyg.js.map} +1 -1
  78. package/dist/{chunk-3h1pd6ec.js → chunk-en3mtnsg.js} +2 -2
  79. package/dist/{chunk-3h1pd6ec.js.map → chunk-en3mtnsg.js.map} +1 -1
  80. package/dist/{chunk-v8s1dmc2.js → chunk-enf9mdac.js} +2 -2
  81. package/dist/{chunk-v8s1dmc2.js.map → chunk-enf9mdac.js.map} +1 -1
  82. package/dist/{chunk-gppm9gkg.js → chunk-eysexnqb.js} +2 -2
  83. package/dist/{chunk-gppm9gkg.js.map → chunk-eysexnqb.js.map} +1 -1
  84. package/dist/{chunk-06p4zq4m.js → chunk-g6qe6wyb.js} +2 -2
  85. package/dist/{chunk-06p4zq4m.js.map → chunk-g6qe6wyb.js.map} +1 -1
  86. package/dist/{chunk-fpy7m803.js → chunk-gr61ymse.js} +2 -2
  87. package/dist/{chunk-fpy7m803.js.map → chunk-gr61ymse.js.map} +1 -1
  88. package/dist/{chunk-0kpvbnz0.js → chunk-j9wqzemf.js} +2 -2
  89. package/dist/{chunk-0kpvbnz0.js.map → chunk-j9wqzemf.js.map} +1 -1
  90. package/dist/{chunk-9z5g1rf6.js → chunk-jg9eqd3r.js} +1 -1
  91. package/dist/{chunk-6sd7an1r.js → chunk-k2qh3hvd.js} +2 -2
  92. package/dist/{chunk-6sd7an1r.js.map → chunk-k2qh3hvd.js.map} +1 -1
  93. package/dist/{chunk-d2esms7y.js → chunk-kb3xk9r8.js} +2 -2
  94. package/dist/{chunk-d2esms7y.js.map → chunk-kb3xk9r8.js.map} +1 -1
  95. package/dist/{chunk-2c89p8pf.js → chunk-kfavcgv2.js} +2 -2
  96. package/dist/{chunk-2c89p8pf.js.map → chunk-kfavcgv2.js.map} +1 -1
  97. package/dist/{chunk-5krm6p9w.js → chunk-m0zba09s.js} +3 -3
  98. package/dist/{chunk-5krm6p9w.js.map → chunk-m0zba09s.js.map} +1 -1
  99. package/dist/{chunk-wmbpdjvs.js → chunk-m4xw99vm.js} +2 -2
  100. package/dist/{chunk-wmbpdjvs.js.map → chunk-m4xw99vm.js.map} +1 -1
  101. package/dist/{chunk-6c0s1mb7.js → chunk-ng8pp9k2.js} +2 -2
  102. package/dist/{chunk-6c0s1mb7.js.map → chunk-ng8pp9k2.js.map} +1 -1
  103. package/dist/{chunk-zbpgt20r.js → chunk-nvj1z2rs.js} +2 -2
  104. package/dist/{chunk-zbpgt20r.js.map → chunk-nvj1z2rs.js.map} +1 -1
  105. package/dist/{chunk-h2pbrneh.js → chunk-pa0ya991.js} +2 -2
  106. package/dist/{chunk-h2pbrneh.js.map → chunk-pa0ya991.js.map} +1 -1
  107. package/dist/{chunk-a3mgkrb2.js → chunk-pgpqsgzx.js} +1 -1
  108. package/dist/{chunk-sexaj89x.js → chunk-pt59xjfc.js} +2 -2
  109. package/dist/{chunk-sexaj89x.js.map → chunk-pt59xjfc.js.map} +1 -1
  110. package/dist/{chunk-8vnb3hfz.js → chunk-r5e4vpa1.js} +2 -2
  111. package/dist/{chunk-8vnb3hfz.js.map → chunk-r5e4vpa1.js.map} +1 -1
  112. package/dist/{chunk-vxxk4syx.js → chunk-r8nhndzb.js} +2 -2
  113. package/dist/{chunk-vxxk4syx.js.map → chunk-r8nhndzb.js.map} +1 -1
  114. package/dist/{chunk-vax2fp2k.js → chunk-rmv1jp9p.js} +2 -2
  115. package/dist/{chunk-vax2fp2k.js.map → chunk-rmv1jp9p.js.map} +1 -1
  116. package/dist/{chunk-d07y2ddw.js → chunk-rqh2wdhb.js} +2 -2
  117. package/dist/{chunk-d07y2ddw.js.map → chunk-rqh2wdhb.js.map} +1 -1
  118. package/dist/{chunk-9hbwvcxn.js → chunk-rv7da58g.js} +2 -2
  119. package/dist/chunk-rv7da58g.js.map +10 -0
  120. package/dist/{chunk-2y9haf48.js → chunk-tdnfhe7x.js} +3 -3
  121. package/dist/{chunk-2y9haf48.js.map → chunk-tdnfhe7x.js.map} +1 -1
  122. package/dist/chunk-tmwsvf02.js +5 -0
  123. package/dist/{chunk-nc82trtm.js.map → chunk-tmwsvf02.js.map} +1 -1
  124. package/dist/{chunk-0zr926cf.js → chunk-v1nm4tcq.js} +2 -2
  125. package/dist/{chunk-0zr926cf.js.map → chunk-v1nm4tcq.js.map} +1 -1
  126. package/dist/{chunk-mwrh96hx.js → chunk-v27a4se1.js} +3 -3
  127. package/dist/chunk-v27a4se1.js.map +12 -0
  128. package/dist/chunk-vfrrzr10.js +4 -0
  129. package/dist/chunk-vfrrzr10.js.map +10 -0
  130. package/dist/{chunk-s7rhttvd.js → chunk-vmpzg4z5.js} +3 -3
  131. package/dist/{chunk-s7rhttvd.js.map → chunk-vmpzg4z5.js.map} +1 -1
  132. package/dist/{chunk-aecx542w.js → chunk-w099t7zj.js} +2 -2
  133. package/dist/{chunk-aecx542w.js.map → chunk-w099t7zj.js.map} +1 -1
  134. package/dist/chunk-wh728wd6.js +5 -0
  135. package/dist/chunk-wh728wd6.js.map +10 -0
  136. package/dist/{chunk-vqexqkfk.js → chunk-wkdzz0rx.js} +3 -3
  137. package/dist/chunk-wkdzz0rx.js.map +10 -0
  138. package/dist/{chunk-vngyybzh.js → chunk-wsx3j5ws.js} +2 -2
  139. package/dist/{chunk-vngyybzh.js.map → chunk-wsx3j5ws.js.map} +1 -1
  140. package/dist/{chunk-7y6gpg08.js → chunk-wwdaswxh.js} +3 -3
  141. package/dist/{chunk-7y6gpg08.js.map → chunk-wwdaswxh.js.map} +1 -1
  142. package/dist/{chunk-nq2hm5xm.js → chunk-xhha1gb3.js} +2 -2
  143. package/dist/{chunk-nq2hm5xm.js.map → chunk-xhha1gb3.js.map} +1 -1
  144. package/dist/{chunk-dk0kdrkm.js → chunk-yk8s5egf.js} +2 -2
  145. package/dist/{chunk-dk0kdrkm.js.map → chunk-yk8s5egf.js.map} +1 -1
  146. package/dist/{chunk-y7gfg6tj.js → chunk-ys4fejmx.js} +2 -2
  147. package/dist/{chunk-y7gfg6tj.js.map → chunk-ys4fejmx.js.map} +1 -1
  148. package/dist/{chunk-6eprvf4s.js → chunk-z409rk5j.js} +2 -2
  149. package/dist/{chunk-6eprvf4s.js.map → chunk-z409rk5j.js.map} +1 -1
  150. package/dist/{chunk-t6yzarvt.js → chunk-z7442w3q.js} +2 -2
  151. package/dist/{chunk-t6yzarvt.js.map → chunk-z7442w3q.js.map} +1 -1
  152. package/dist/{chunk-v0j7spj5.js → chunk-zfch4da5.js} +2 -2
  153. package/dist/{chunk-zv7417j0.js.map → chunk-zfch4da5.js.map} +1 -1
  154. package/dist/{chunk-f46ntdj3.js → chunk-zp971jp2.js} +3 -3
  155. package/dist/{chunk-f46ntdj3.js.map → chunk-zp971jp2.js.map} +1 -1
  156. package/dist/chunks/{ThemeProvider-BiNFL6l7.js → ThemeProvider-Dn3UREDn.js} +64 -90
  157. package/dist/chunks/ThemeProvider-Dn3UREDn.js.map +1 -0
  158. package/dist/client/ClientRouter.d.ts.map +1 -1
  159. package/dist/client/QueryResource.d.ts +14 -0
  160. package/dist/client/QueryResource.d.ts.map +1 -1
  161. package/dist/client/index.d.ts +0 -2
  162. package/dist/client/index.d.ts.map +1 -1
  163. package/dist/client/index.js +4 -29
  164. package/dist/client/index.js.map +1 -1
  165. package/dist/config/index.js +1 -1
  166. package/dist/console/run.js +2 -2
  167. package/dist/console/run.js.map +1 -1
  168. package/dist/container/index.js +2 -2
  169. package/dist/container/index.js.map +1 -1
  170. package/dist/database/index.js +2 -2
  171. package/dist/database/index.js.map +1 -1
  172. package/dist/email/index.js +2 -2
  173. package/dist/email/index.js.map +1 -1
  174. package/dist/facades/Auth.d.ts +14 -0
  175. package/dist/facades/Auth.d.ts.map +1 -1
  176. package/dist/facades/index.d.ts +0 -1
  177. package/dist/facades/index.d.ts.map +1 -1
  178. package/dist/facades/index.js +2 -2
  179. package/dist/facades/index.js.map +1 -1
  180. package/dist/foundation/Application.d.ts +7 -3
  181. package/dist/foundation/Application.d.ts.map +1 -1
  182. package/dist/foundation/app.d.ts +1 -1
  183. package/dist/foundation/index.js +2 -2
  184. package/dist/foundation/index.js.map +1 -1
  185. package/dist/http/AuthenticationMiddlware.d.ts +4 -3
  186. package/dist/http/AuthenticationMiddlware.d.ts.map +1 -1
  187. package/dist/http/HttpRequest.d.ts.map +1 -1
  188. package/dist/http/index.js +2 -2
  189. package/dist/http/index.js.map +1 -1
  190. package/dist/i18n/dictionaryRuntime.js +2 -2
  191. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  192. package/dist/i18n/index.js +2 -2
  193. package/dist/i18n/index.js.map +1 -1
  194. package/dist/internal/gemiExternals.d.ts +1 -1
  195. package/dist/internal/gemiExternals.d.ts.map +1 -1
  196. package/dist/kernel/Kernel.d.ts +0 -2
  197. package/dist/kernel/Kernel.d.ts.map +1 -1
  198. package/dist/kernel/context.d.ts +3 -4
  199. package/dist/kernel/context.d.ts.map +1 -1
  200. package/dist/kernel/index.js +3 -3
  201. package/dist/kernel/index.js.map +5 -5
  202. package/dist/kernel/providers.d.ts.map +1 -1
  203. package/dist/orm/context.d.ts +1 -2
  204. package/dist/orm/context.d.ts.map +1 -1
  205. package/dist/orm/index.js +2 -2
  206. package/dist/orm/index.js.map +1 -1
  207. package/dist/server/index.js +2 -2
  208. package/dist/server/index.js.map +1 -1
  209. package/dist/services/cron/ScheduleServiceProvider.d.ts +7 -2
  210. package/dist/services/cron/ScheduleServiceProvider.d.ts.map +1 -1
  211. package/dist/services/index.d.ts +0 -3
  212. package/dist/services/index.d.ts.map +1 -1
  213. package/dist/services/index.js +3 -3
  214. package/dist/services/index.js.map +2 -2
  215. package/dist/services/logging/LogManager.d.ts.map +1 -1
  216. package/dist/services/queue/QueueServiceProvider.d.ts +8 -2
  217. package/dist/services/queue/QueueServiceProvider.d.ts.map +1 -1
  218. package/dist/services/queue/work.js +2 -2
  219. package/dist/services/queue/work.js.map +1 -1
  220. package/dist/services/router/ApiRouteDispatcher.d.ts.map +1 -1
  221. package/dist/services/router/globalMiddleware.d.ts +5 -3
  222. package/dist/services/router/globalMiddleware.d.ts.map +1 -1
  223. package/dist/support/ServiceProvider.d.ts +14 -1
  224. package/dist/support/ServiceProvider.d.ts.map +1 -1
  225. package/dist/support/index.d.ts +1 -1
  226. package/dist/support/index.d.ts.map +1 -1
  227. package/dist/support/index.js +2 -2
  228. package/dist/support/index.js.map +1 -1
  229. package/dist/testing/Page.d.ts.map +1 -1
  230. package/dist/testing/index.js +16 -24
  231. package/dist/testing/index.js.map +1 -1
  232. package/package.json +1 -2
  233. package/dist/broadcasting/BroadcastingChannel.d.ts +0 -5
  234. package/dist/broadcasting/BroadcastingChannel.d.ts.map +0 -1
  235. package/dist/broadcasting/index.d.ts +0 -2
  236. package/dist/broadcasting/index.d.ts.map +0 -1
  237. package/dist/broadcasting/index.js +0 -4
  238. package/dist/broadcasting/index.js.map +0 -10
  239. package/dist/chunk-817dxq6w.js +0 -7
  240. package/dist/chunk-9hbwvcxn.js.map +0 -10
  241. package/dist/chunk-cmj9xnbp.js +0 -6
  242. package/dist/chunk-f9mwxne0.js +0 -4
  243. package/dist/chunk-f9mwxne0.js.map +0 -10
  244. package/dist/chunk-fffph77x.js +0 -5
  245. package/dist/chunk-fffph77x.js.map +0 -10
  246. package/dist/chunk-mwrh96hx.js.map +0 -12
  247. package/dist/chunk-nc82trtm.js +0 -5
  248. package/dist/chunk-rs0xmd64.js +0 -17
  249. package/dist/chunk-vqexqkfk.js.map +0 -10
  250. package/dist/chunk-z9x8fx21.js +0 -5
  251. package/dist/chunks/ThemeProvider-BiNFL6l7.js.map +0 -1
  252. package/dist/client/WebsocketContext.d.ts +0 -10
  253. package/dist/client/WebsocketContext.d.ts.map +0 -1
  254. package/dist/client/useBroadcast.d.ts +0 -4
  255. package/dist/client/useBroadcast.d.ts.map +0 -1
  256. package/dist/client/useSubscription.d.ts +0 -5
  257. package/dist/client/useSubscription.d.ts.map +0 -1
  258. package/dist/facades/Broadcast.d.ts +0 -9
  259. package/dist/facades/Broadcast.d.ts.map +0 -1
  260. package/dist/http/BroadcastingRouter.d.ts +0 -8
  261. package/dist/http/BroadcastingRouter.d.ts.map +0 -1
  262. package/dist/services/pubsub/BroadcastManager.d.ts +0 -24
  263. package/dist/services/pubsub/BroadcastManager.d.ts.map +0 -1
  264. package/dist/services/pubsub/BroadcastServiceProvider.d.ts +0 -5
  265. package/dist/services/pubsub/BroadcastServiceProvider.d.ts.map +0 -1
  266. package/dist/services/pubsub/config.d.ts +0 -7
  267. package/dist/services/pubsub/config.d.ts.map +0 -1
  268. package/dist/services/pubsub/types.d.ts +0 -6
  269. package/dist/services/pubsub/types.d.ts.map +0 -1
  270. /package/dist/{chunk-d2tpgkg2.js.map → chunk-ah9ajys0.js.map} +0 -0
  271. /package/dist/{chunk-9z5g1rf6.js.map → chunk-jg9eqd3r.js.map} +0 -0
  272. /package/dist/{chunk-a3mgkrb2.js.map → chunk-pgpqsgzx.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ya as uW}from"../chunk-zytmxty5.js";import{Ab as yW,Bb as VW,Cb as gW,Db as cW,Eb as EW,Fb as mW,Za as d6,_a as xW,ab as MW,bb as LW,cb as DW,db as FW,eb as OW,fb as HW,gb as UW,hb as U,ib as SW,jb as fW,kb as RW,lb as kW,mb as _W,nb as CW,ob as vW,pb as bW,qb as IW,rb as TW,sb as qW,tb as s4,ub as a4,vb as g1,wb as hW,xb as PW,yb as wW,zb as AW}from"../chunk-z9x8fx21.js";import"../chunk-zbhqa2z7.js";import{Ib as s6,Jb as a6,Kb as t6,Lb as r6,Mb as e6,Nb as WW,Ob as YW,Pb as JW,Qb as ZW,Rb as GW,Sb as $W,Tb as QW,Ub as KW,Vb as XW,Wb as zW,Xb as BW}from"../chunk-s7rhttvd.js";import{$b as i6,Yb as p6,Zb as l6,_b as n6,ac as o6}from"../chunk-hfxx52vr.js";import{fc as jW,gc as NW}from"../chunk-0kpvbnz0.js";import"../chunk-9hbwvcxn.js";import{Ad as y6,Cc as Q6,Cd as V6,Kc as D1,Mc as M6,Oc as j6,Pc as N6,Qc as L6,Rc as D6,Sc as F6,Tc as O6,Uc as H6,Vc as d4,Wc as U6,Xc as S6,Yc as f6,Zc as R6,_c as k6,cd as _6,dd as C6,ed as v6,fd as b6,gd as I6,hd as T6,id as q6,jd as h6,kd as P6,md as w6,oc as b0,tc as e0,td as A6,uc as W6,vc as Y6,wc as J6,xc as Z6,yc as G6,zc as $6}from"../chunk-rs0xmd64.js";import"../chunk-2y9haf48.js";import"../chunk-1dgab0qn.js";import{Re as V1,Se as A1,Te as Y1,ff as g,gf as w,kf as J1,lf as L1,mf as K6,nf as X6,of as z6,pf as B6,rf as x6}from"../chunk-817dxq6w.js";import"../chunk-vax2fp2k.js";import"../chunk-wmbpdjvs.js";import"../chunk-vqexqkfk.js";import"../chunk-06p4zq4m.js";import"../chunk-03xrgp1m.js";import{ig as g6,jg as c6,kg as E6,lg as m6,mg as u6}from"../chunk-f46ntdj3.js";import"../chunk-3h1pd6ec.js";import{rg as c}from"../chunk-mwrh96hx.js";import"../chunk-fffph77x.js";import"../chunk-vxxk4syx.js";import"../chunk-fpy7m803.js";import"../chunk-8vnb3hfz.js";import"../chunk-d2esms7y.js";import{Lg as l4}from"../chunk-v0j7spj5.js";import{Buffer as p4}from"buffer";class n4 extends J1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-gzx3rskd.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Y}={}){Y?.throwIfAborted();let J,Z,G,$=process.env.BUCKET_NAME;if(W instanceof Blob)J=W,G=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Z=W.type;else J=W.body,G=W.name,$=W.bucket??$,Z=W.contentType||(J instanceof Blob||J instanceof File?J.type:void 0);Z=Z||void 0;let Q=J instanceof p4?J:J instanceof Blob||J instanceof File?p4.from(await J.arrayBuffer()):"",{sdk:K,client:z}=await this.connect();return Y?.throwIfAborted(),await z.send(new K.PutObjectCommand({Bucket:$,Key:G,Body:Q,ContentType:Z}),{abortSignal:Y}),G}async delete(W){let Y=typeof W==="string"?W:W.name,J=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Y)throw Error("Object name has to be specified");let{sdk:Z,client:G}=await this.connect();try{await G.send(new Z.DeleteObjectCommand({Bucket:J,Key:Y}))}catch($){if($?.name==="NoSuchKey"||$?.$metadata?.httpStatusCode===404)return;throw $}}async list(W){let{sdk:Y,client:J}=await this.connect();return await J.send(new Y.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Y}={}){Y?.throwIfAborted();let J=process.env.BUCKET_NAME,Z;if(typeof W==="string")Z=W;else J=W.bucket??J,Z=W.name;if(!Z)throw Error("Object name has to be specified");let{sdk:G,client:$}=await this.connect();Y?.throwIfAborted();let Q=await $.send(new G.GetObjectCommand({Bucket:J,Key:Z}),{abortSignal:Y}),K=L1(Q.Body.transformToWebStream(),Y);return Y?.throwIfAborted(),new Response(K,{headers:{"Content-Type":Q.ContentType,"Content-Length":Q.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":Q.LastModified?.toUTCString()||"",ETag:Q.ETag||""}})}async read(W){let Y=typeof W==="string"?{name:W}:W,J=Y.bucket??process.env.BUCKET_NAME,{name:Z,range:G=null}=Y;if(!Z)throw Error("Object name has to be specified");let{sdk:$,client:Q}=await this.connect(),K;try{K=await Q.send(new $.GetObjectCommand({Bucket:J,Key:Z,Range:G?A1(G):void 0}))}catch(M){if(M?.name==="InvalidRange"||M?.$metadata?.httpStatusCode===416)throw new g(await this.size({name:Z,bucket:J}));if(M?.name==="NoSuchKey"||M?.$metadata?.httpStatusCode===404)throw new w(Z);throw M}let z=Y1(K.ContentRange),X=Boolean(z)&&K.$metadata?.httpStatusCode===206,x=z?.total??K.ContentLength??0;return{body:K.Body.transformToWebStream(),start:z?.start??0,end:z?.end??x-1,total:x,partial:X,type:K.ContentType??"application/octet-stream",etag:K.ETag||void 0,lastModified:K.LastModified,name:Z}}async size(W){let Y=typeof W==="string"?W:W.name,J=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Z,client:G}=await this.connect();try{return(await G.send(new Z.HeadObjectCommand({Bucket:J,Key:Y}))).ContentLength??0}catch($){if($?.name==="NotFound"||$?.$metadata?.httpStatusCode===404)throw new w(Y);throw $}}}import{Buffer as i4}from"buffer";import{Readable as q0}from"stream";function y1(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function h0(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class o4 extends J1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Y=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Y)return W.BlobServiceClient.fromConnectionString(Y);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Y){if(!W)throw Error("Object name has to be specified");let J=Y??this.config.container??process.env.BUCKET_NAME;if(!J)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient(J).getBlockBlobClient(W)}async put(W,{signal:Y}={}){Y?.throwIfAborted();let J,Z,G,$;if(W instanceof Blob)J=W,G=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Z=W.type;else J=W.body,G=W.name,$=W.bucket,Z=W.contentType??(J instanceof Blob||J instanceof File?J.type:void 0);let Q=J instanceof i4?J:i4.from(await J.arrayBuffer()),K=await this.blob(G,$);return Y?.throwIfAborted(),await K.uploadData(Q,{blobHTTPHeaders:Z?{blobContentType:Z}:void 0,abortSignal:Y}),G}async list(W){let Y=this.config.container??process.env.BUCKET_NAME,Z=(await this.serviceClient()).getContainerClient(Y),G=[];for await(let $ of Z.listBlobsFlat({prefix:W}))G.push($.name);return G}async fetch(W,{signal:Y}={}){Y?.throwIfAborted();let J=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Y);return new Response(J.body,{headers:{"Content-Type":J.type,"Content-Length":String(J.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.lastModified?.toUTCString()??"",ETag:J.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Y){let{name:J,bucket:Z,range:G=null}=W,$=await this.blob(J,Z);Y?.throwIfAborted();let Q,K,z=G?.kind==="suffix"||G?.kind==="offset"&&G.end===null&&G.start===0;if(G&&z){let b=await this.size({name:J,bucket:Z}),W1=V1(G,b);if(!W1)throw new g(b);Q=W1.start,K=W1.length}else if(G?.kind==="offset")Q=G.start,K=G.end===null?void 0:G.end-G.start+1;let X;try{X=await $.download(Q,K,Y?{abortSignal:Y}:void 0)}catch(b){if(h0(b))throw new g(await this.size({name:J,bucket:Z}));if(y1(b))throw new w(J);throw b}let x=Y1(X.contentRange),M=Boolean(x),R=x?.total??X.contentLength??0,v=await P0(X);if(v instanceof ReadableStream)v=L1(v,Y);return Y?.throwIfAborted(),{body:v,start:x?.start??0,end:x?.end??R-1,total:R,partial:M,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:J}}async size(W){let Y=typeof W==="string"?W:W.name,J=typeof W==="string"?void 0:W.bucket,Z=await this.blob(Y,J);try{return(await Z.getProperties()).contentLength??0}catch(G){if(y1(G))throw new w(Y);throw G}}async delete(W){let Y=typeof W==="string"?W:W.name,J=typeof W==="string"?void 0:W.bucket,Z=await this.blob(Y,J);try{await Z.delete()}catch(G){if(y1(G))return;throw G}}}async function P0(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return q0.toWeb(W.readableStreamBody);return null}var w0=`
2
+ import{Ya as gW}from"../chunk-zytmxty5.js";import{Ab as AW,Bb as yW,Cb as VW,Za as u6,_a as BW,ab as xW,bb as NW,cb as LW,db as DW,eb as FW,fb as OW,gb as HW,hb as U,ib as UW,jb as SW,kb as fW,lb as RW,mb as kW,nb as _W,ob as CW,pb as vW,qb as s4,rb as a4,sb as g1,tb as bW,ub as IW,vb as TW,wb as qW,xb as hW,yb as PW,zb as wW}from"../chunk-e43drft2.js";import"../chunk-ash9e6fn.js";import{Fb as o6,Gb as s6,Hb as a6,Ib as t6,Jb as r6,Kb as e6,Lb as WW,Mb as YW,Nb as JW,Ob as ZW,Pb as GW,Qb as $W,Rb as QW,Sb as KW,Tb as XW,Ub as zW}from"../chunk-vmpzg4z5.js";import{Vb as d6,Wb as p6,Xb as l6,Yb as n6,Zb as i6}from"../chunk-1s914cdj.js";import{cc as MW,dc as jW}from"../chunk-j9wqzemf.js";import"../chunk-rv7da58g.js";import{$c as C6,Fc as D1,Hc as x6,Jc as M6,Kc as j6,Lc as N6,Mc as L6,Nc as D6,Oc as F6,Pc as O6,Qc as d4,Rc as H6,Sc as U6,Tc as S6,Uc as f6,Vc as R6,Zc as k6,_c as _6,ad as v6,bd as b6,cd as I6,dd as T6,ed as q6,fd as h6,hd as P6,lc as b0,od as w6,qc as e0,rc as W6,sc as Y6,tc as J6,uc as Z6,vc as G6,vd as A6,wc as $6,xd as y6}from"../chunk-49akdtfe.js";import"../chunk-tdnfhe7x.js";import"../chunk-d0qwdeza.js";import{$e as g,Le as V1,Me as A1,Ne as Y1,af as w,ef as J1,ff as L1,gf as Q6,hf as K6,if as X6,jf as z6,lf as B6}from"../chunk-302mkqeq.js";import"../chunk-rmv1jp9p.js";import"../chunk-wkdzz0rx.js";import"../chunk-g6qe6wyb.js";import"../chunk-3z6wkvwj.js";import"../chunk-m4xw99vm.js";import{cg as V6,dg as g6,eg as c6,fg as E6,gg as m6}from"../chunk-zp971jp2.js";import"../chunk-en3mtnsg.js";import{lg as c}from"../chunk-v27a4se1.js";import"../chunk-wh728wd6.js";import"../chunk-r8nhndzb.js";import"../chunk-gr61ymse.js";import"../chunk-r5e4vpa1.js";import"../chunk-kb3xk9r8.js";import{Fg as l4}from"../chunk-zfch4da5.js";import{Buffer as p4}from"buffer";class n4 extends J1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-1evk2pma.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Y}={}){Y?.throwIfAborted();let J,Z,G,$=process.env.BUCKET_NAME;if(W instanceof Blob)J=W,G=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Z=W.type;else J=W.body,G=W.name,$=W.bucket??$,Z=W.contentType||(J instanceof Blob||J instanceof File?J.type:void 0);Z=Z||void 0;let Q=J instanceof p4?J:J instanceof Blob||J instanceof File?p4.from(await J.arrayBuffer()):"",{sdk:K,client:z}=await this.connect();return Y?.throwIfAborted(),await z.send(new K.PutObjectCommand({Bucket:$,Key:G,Body:Q,ContentType:Z}),{abortSignal:Y}),G}async delete(W){let Y=typeof W==="string"?W:W.name,J=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Y)throw Error("Object name has to be specified");let{sdk:Z,client:G}=await this.connect();try{await G.send(new Z.DeleteObjectCommand({Bucket:J,Key:Y}))}catch($){if($?.name==="NoSuchKey"||$?.$metadata?.httpStatusCode===404)return;throw $}}async list(W){let{sdk:Y,client:J}=await this.connect();return await J.send(new Y.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Y}={}){Y?.throwIfAborted();let J=process.env.BUCKET_NAME,Z;if(typeof W==="string")Z=W;else J=W.bucket??J,Z=W.name;if(!Z)throw Error("Object name has to be specified");let{sdk:G,client:$}=await this.connect();Y?.throwIfAborted();let Q=await $.send(new G.GetObjectCommand({Bucket:J,Key:Z}),{abortSignal:Y}),K=L1(Q.Body.transformToWebStream(),Y);return Y?.throwIfAborted(),new Response(K,{headers:{"Content-Type":Q.ContentType,"Content-Length":Q.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":Q.LastModified?.toUTCString()||"",ETag:Q.ETag||""}})}async read(W){let Y=typeof W==="string"?{name:W}:W,J=Y.bucket??process.env.BUCKET_NAME,{name:Z,range:G=null}=Y;if(!Z)throw Error("Object name has to be specified");let{sdk:$,client:Q}=await this.connect(),K;try{K=await Q.send(new $.GetObjectCommand({Bucket:J,Key:Z,Range:G?A1(G):void 0}))}catch(M){if(M?.name==="InvalidRange"||M?.$metadata?.httpStatusCode===416)throw new g(await this.size({name:Z,bucket:J}));if(M?.name==="NoSuchKey"||M?.$metadata?.httpStatusCode===404)throw new w(Z);throw M}let z=Y1(K.ContentRange),X=Boolean(z)&&K.$metadata?.httpStatusCode===206,x=z?.total??K.ContentLength??0;return{body:K.Body.transformToWebStream(),start:z?.start??0,end:z?.end??x-1,total:x,partial:X,type:K.ContentType??"application/octet-stream",etag:K.ETag||void 0,lastModified:K.LastModified,name:Z}}async size(W){let Y=typeof W==="string"?W:W.name,J=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Z,client:G}=await this.connect();try{return(await G.send(new Z.HeadObjectCommand({Bucket:J,Key:Y}))).ContentLength??0}catch($){if($?.name==="NotFound"||$?.$metadata?.httpStatusCode===404)throw new w(Y);throw $}}}import{Buffer as i4}from"buffer";import{Readable as q0}from"stream";function y1(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function h0(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class o4 extends J1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Y=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Y)return W.BlobServiceClient.fromConnectionString(Y);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Y){if(!W)throw Error("Object name has to be specified");let J=Y??this.config.container??process.env.BUCKET_NAME;if(!J)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient(J).getBlockBlobClient(W)}async put(W,{signal:Y}={}){Y?.throwIfAborted();let J,Z,G,$;if(W instanceof Blob)J=W,G=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Z=W.type;else J=W.body,G=W.name,$=W.bucket,Z=W.contentType??(J instanceof Blob||J instanceof File?J.type:void 0);let Q=J instanceof i4?J:i4.from(await J.arrayBuffer()),K=await this.blob(G,$);return Y?.throwIfAborted(),await K.uploadData(Q,{blobHTTPHeaders:Z?{blobContentType:Z}:void 0,abortSignal:Y}),G}async list(W){let Y=this.config.container??process.env.BUCKET_NAME,Z=(await this.serviceClient()).getContainerClient(Y),G=[];for await(let $ of Z.listBlobsFlat({prefix:W}))G.push($.name);return G}async fetch(W,{signal:Y}={}){Y?.throwIfAborted();let J=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Y);return new Response(J.body,{headers:{"Content-Type":J.type,"Content-Length":String(J.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.lastModified?.toUTCString()??"",ETag:J.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Y){let{name:J,bucket:Z,range:G=null}=W,$=await this.blob(J,Z);Y?.throwIfAborted();let Q,K,z=G?.kind==="suffix"||G?.kind==="offset"&&G.end===null&&G.start===0;if(G&&z){let b=await this.size({name:J,bucket:Z}),W1=V1(G,b);if(!W1)throw new g(b);Q=W1.start,K=W1.length}else if(G?.kind==="offset")Q=G.start,K=G.end===null?void 0:G.end-G.start+1;let X;try{X=await $.download(Q,K,Y?{abortSignal:Y}:void 0)}catch(b){if(h0(b))throw new g(await this.size({name:J,bucket:Z}));if(y1(b))throw new w(J);throw b}let x=Y1(X.contentRange),M=Boolean(x),R=x?.total??X.contentLength??0,v=await P0(X);if(v instanceof ReadableStream)v=L1(v,Y);return Y?.throwIfAborted(),{body:v,start:x?.start??0,end:x?.end??R-1,total:R,partial:M,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:J}}async size(W){let Y=typeof W==="string"?W:W.name,J=typeof W==="string"?void 0:W.bucket,Z=await this.blob(Y,J);try{return(await Z.getProperties()).contentLength??0}catch(G){if(y1(G))throw new w(Y);throw G}}async delete(W){let Y=typeof W==="string"?W:W.name,J=typeof W==="string"?void 0:W.bucket,Z=await this.blob(Y,J);try{await Z.delete()}catch(G){if(y1(G))return;throw G}}}async function P0(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return q0.toWeb(W.readableStreamBody);return null}var w0=`
3
3
  local currentKey = KEYS[1]
4
4
  local previousKey = KEYS[2]
5
5
  local limit = tonumber(ARGV[1])
@@ -32,6 +32,6 @@ ${W.resolution}.`;console.warn(J),console.warn("To disable this message, import
32
32
  `)return this.emit(B.DataKeepAlive);this.parser.push(Y.toString())}),this.resetKeepAliveTimeout()}initEventsFromParser(){let W=this.requestData.payloadIsError;this.parser.on(y.ParsedData,(Y)=>{if(W&&W(Y))this.emit(B.DataError,Y),this.emit(B.Error,{type:B.DataError,error:Y,message:"Twitter sent a payload that is detected as an error payload."});else this.emit(B.Data,Y)}),this.parser.on(y.ParseError,(Y)=>{this.emit(B.TweetParseError,Y),this.emit(B.Error,{type:B.TweetParseError,error:Y,message:"Failed to parse stream data."})})}resetKeepAliveTimeout(){if(this.unbindKeepAliveTimeout(),this.keepAliveTimeoutMs!==1/0)this.keepAliveTimeout=setTimeout(this.onKeepAliveTimeout,this.keepAliveTimeoutMs)}onKeepAliveTimeout(){this.emit(B.ConnectionLost),this.onConnectionError()}unbindTimeouts(){this.unbindRetryTimeout(),this.unbindKeepAliveTimeout()}unbindKeepAliveTimeout(){if(this.keepAliveTimeout)clearTimeout(this.keepAliveTimeout),this.keepAliveTimeout=void 0}unbindRetryTimeout(){if(this.retryTimeout)clearTimeout(this.retryTimeout),this.retryTimeout=void 0}closeWithoutEmit(){if(this.unbindTimeouts(),this.res)this.res.removeAllListeners(),this.res.destroy();if(this.req)this.req.removeAllListeners(),this.req.destroy()}close(){this.emit(B.ConnectionClosed),this.closeWithoutEmit()}destroy(){this.removeAllListeners(),this.close()}async clone(){let Y=await new x1(this.requestData).makeRequestAsStream(),J=this.eventNames();for(let Z of J){let G=this.listeners(Z);for(let $ of G)Y.on(Z,$)}return Y}async connect(W={}){if(typeof W.autoReconnect<"u")this.autoReconnect=W.autoReconnect;if(typeof W.autoReconnectRetries<"u")this.autoReconnectRetries=W.autoReconnectRetries==="unlimited"?1/0:W.autoReconnectRetries;if(typeof W.keepAliveTimeout<"u")this.keepAliveTimeoutMs=W.keepAliveTimeout==="disable"?1/0:W.keepAliveTimeout;if(typeof W.nextRetryTimeout<"u")this.nextRetryTimeout=W.nextRetryTimeout;this.unbindTimeouts();try{await this.reconnect()}catch(Y){if(this.emit(B.ConnectError,0),this.emit(B.Error,{type:B.ConnectError,error:Y,message:"Connect error - Initial connection just failed."}),this.autoReconnect)this.makeAutoReconnectRetry(0,Y);else throw Y}return this}async reconnect(){if(this.connectionProcessRunning)throw Error("Connection process is already running.");this.connectionProcessRunning=!0;try{let W=!0;if(this.req)W=!1,this.closeWithoutEmit();let{req:Y,res:J,originalResponse:Z}=await new x1(this.requestData).makeRequestAndResolveWhenReady();this.req=Y,this.res=J,this.originalResponse=Z,this.emit(W?B.Connected:B.Reconnected),this.parser.reset(),this.initEventsFromRequest()}finally{this.connectionProcessRunning=!1}}async onConnectionError(W=0){if(this.unbindTimeouts(),this.closeWithoutEmit(),!this.autoReconnect){this.emit(B.ConnectionClosed);return}if(W>=this.autoReconnectRetries){this.emit(B.ReconnectLimitExceeded),this.emit(B.ConnectionClosed);return}try{this.emit(B.ReconnectAttempt,W),await this.reconnect()}catch(Y){this.emit(B.ReconnectError,W),this.emit(B.Error,{type:B.ReconnectError,error:Y,message:`Reconnect error - ${W+1} attempts made yet.`}),this.makeAutoReconnectRetry(W,Y)}}makeAutoReconnectRetry(W,Y){let J=this.nextRetryTimeout(W+1,Y);this.retryTimeout=setTimeout(()=>{this.onConnectionError(W+1)},J)}async*[Symbol.asyncIterator](){let W=new K0(this);try{while(!0){if(!this.req||this.req.aborted)throw Error("Connection closed");if(W.hasStack())yield*W.popStack();let{type:Y,payload:J}=await W.nextEvent();if(Y==="error")throw J}}finally{W.destroy()}}}var S1=z0;function B0(W){var Y;if(!((Y=W.clientSettings.plugins)===null||Y===void 0?void 0:Y.length))return!1;for(let J of W.clientSettings.plugins)if(J.onRequestError||J.onResponseError)return!0;return!1}async function x0(W,Y,J,Z){let G;if(Z instanceof Q1||Z instanceof K1)G=await this.applyPluginMethod("onRequestError",{client:this,url:this.getUrlObjectFromUrlString(W.url),params:W,computedParams:Y,requestOptions:J,error:Z});else if(Z instanceof X1)G=await this.applyPluginMethod("onResponseError",{client:this,url:this.getUrlObjectFromUrlString(W.url),params:W,computedParams:Y,requestOptions:J,error:Z});if(G&&G instanceof z1)return G.value;return Promise.reject(Z)}import*as N0 from"crypto";class S{constructor(W){this.nonceLength=32,this.consumerKeys=W.consumerKeys}static percentEncode(W){return encodeURIComponent(W).replace(/!/g,"%21").replace(/\*/g,"%2A").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29")}hash(W,Y){return N0.createHmac("sha1",Y).update(W).digest("base64")}authorize(W,Y={}){let J={oauth_consumer_key:this.consumerKeys.key,oauth_nonce:this.getNonce(),oauth_signature_method:"HMAC-SHA1",oauth_timestamp:this.getTimestamp(),oauth_version:"1.0"};if(Y.key!==void 0)J.oauth_token=Y.key;if(!W.data)W.data={};return J.oauth_signature=this.getSignature(W,Y.secret,J),J}toHeader(W){let Y=j0(W),J="OAuth ";for(let Z of Y){if(Z.key.indexOf("oauth_")!==0)continue;J+=S.percentEncode(Z.key)+'="'+S.percentEncode(Z.value)+'",'}return{Authorization:J.slice(0,J.length-1)}}getNonce(){let Y="";for(let J=0;J<this.nonceLength;J++)Y+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.trunc(Math.random()*62)];return Y}getTimestamp(){return Math.trunc(new Date().getTime()/1000)}getSignature(W,Y,J){return this.hash(this.getBaseString(W,J),this.getSigningKey(Y))}getSigningKey(W){return S.percentEncode(this.consumerKeys.secret)+"&"+S.percentEncode(W||"")}getBaseString(W,Y){return W.method.toUpperCase()+"&"+S.percentEncode(this.getBaseUrl(W.url))+"&"+S.percentEncode(this.getParameterString(W,Y))}getParameterString(W,Y){let J=j0(o0(M0(Y,M0(W.data,i0(W.url))))),Z="";for(let{key:G,value:$}of J)if($&&Array.isArray($)){$.sort();let Q="";$.forEach((K,z)=>{if(Q+=G+"="+K,z<$.length)Q+="&"}),Z+=Q}else Z+=G+"="+$+"&";return Z.slice(0,Z.length-1)}getBaseUrl(W){return W.split("?")[0]}}var M1=S;function M0(W,Y){return{...W||{},...Y||{}}}function j0(W){return Object.keys(W).sort().map((Y)=>({key:Y,value:W[Y]}))}function n0(W){let Y=W.split("&"),J={};for(let Z of Y){let[G,$=""]=Z.split("=");if(J[G]){if(!Array.isArray(J[G]))J[G]=[J[G]];J[G].push(decodeURIComponent($))}else J[G]=decodeURIComponent($)}return J}function i0(W){let Y=W.split("?");if(Y.length===1)return{};return n0(Y[1])}function o0(W){let Y={};for(let J in W){let Z=W[J];if(Z&&Array.isArray(Z))Z=Z.map((G)=>S.percentEncode(G));else Z=S.percentEncode(Z);Y[S.percentEncode(J)]=Z}return Y}class f{constructor(){this._boundary="",this._chunks=[]}bodyAppend(...W){let Y=W.map((J)=>J instanceof Buffer?J:Buffer.from(J));this._chunks.push(...Y)}append(W,Y,J){let Z=Y instanceof Buffer?Y:Y.toString(),G=this.getMultipartHeader(W,Z,J);this.bodyAppend(G,Z,f.LINE_BREAK)}getHeaders(){return{"content-type":"multipart/form-data; boundary="+this.getBoundary()}}getLength(){return this._chunks.reduce((W,Y)=>W+Y.length,this.getMultipartFooter().length)}getBuffer(){let W=[...this._chunks,this.getMultipartFooter()],Y=Buffer.alloc(this.getLength()),J=0;for(let Z of W)for(let G=0;G<Z.length;J++,G++)Y[J]=Z[G];return Y}getBoundary(){if(!this._boundary)this.generateBoundary();return this._boundary}generateBoundary(){let W="--------------------------";for(let Y=0;Y<24;Y++)W+=Math.floor(Math.random()*10).toString(16);this._boundary=W}getMultipartHeader(W,Y,J){if(!J)J=Y instanceof Buffer?f.DEFAULT_CONTENT_TYPE:"";let Z={"Content-Disposition":["form-data",`name="${W}"`],"Content-Type":J},G="";for(let[$,Q]of Object.entries(Z)){if(!Q.length)continue;G+=$+": "+H1(Q).join("; ")+f.LINE_BREAK}return"--"+this.getBoundary()+f.LINE_BREAK+G+f.LINE_BREAK}getMultipartFooter(){if(this._footerChunk)return this._footerChunk;return this._footerChunk=Buffer.from("--"+this.getBoundary()+"--"+f.LINE_BREAK)}}f.LINE_BREAK=`\r
33
33
  `;f.DEFAULT_CONTENT_TYPE="application/octet-stream";class n1{static formatQueryToString(W){let Y={};for(let J in W)if(typeof W[J]==="string")Y[J]=W[J];else if(typeof W[J]<"u")Y[J]=String(W[J]);return Y}static autoDetectBodyType(W){if(W.pathname.startsWith("/2/")||W.pathname.startsWith("/labs/2/")){if(W.password.startsWith("/2/oauth2"))return"url";return"json"}if(W.hostname==="upload.x.com"){if(W.pathname==="/1.1/media/upload.json")return"form-data";return"json"}let Y=W.pathname.split("/1.1/",2)[1];if(this.JSON_1_1_ENDPOINTS.has(Y))return"json";return"url"}static addQueryParamsToUrl(W,Y){let J=Object.entries(Y);if(J.length){let Z="";for(let[G,$]of J)Z+=(Z.length?"&":"?")+`${M1.percentEncode(G)}=${M1.percentEncode($)}`;W.search=Z}}static constructBodyParams(W,Y,J){if(W instanceof Buffer)return W;if(J==="json"){if(!Y["content-type"])Y["content-type"]="application/json;charset=UTF-8";return JSON.stringify(W)}else if(J==="url"){if(!Y["content-type"])Y["content-type"]="application/x-www-form-urlencoded;charset=UTF-8";if(Object.keys(W).length)return new URLSearchParams(W).toString().replace(/\*/g,"%2A");return""}else if(J==="raw")throw Error("You can only use raw body mode with Buffers. To give a string, use Buffer.from(str).");else{let Z=new f;for(let G in W)Z.append(G,W[G]);if(!Y["content-type"]){let G=Z.getHeaders();Y["content-type"]=G["content-type"]}return Z.getBuffer()}}static setBodyLengthHeader(W,Y){var J;if(W.headers=(J=W.headers)!==null&&J!==void 0?J:{},typeof Y==="string")W.headers["content-length"]=Buffer.byteLength(Y);else W.headers["content-length"]=Y.length}static isOAuthSerializable(W){return!(W instanceof Buffer)}static mergeQueryAndBodyForOAuth(W,Y){let J={};for(let Z in W)J[Z]=W[Z];if(this.isOAuthSerializable(Y))for(let Z in Y){let G=Y[Z];if(this.isOAuthSerializable(G))J[Z]=typeof G==="object"&&G!==null&&"toString"in G?G.toString():G}return J}static moveUrlQueryParamsIntoObject(W,Y){for(let[J,Z]of W.searchParams)Y[J]=Z;return W.search="",W}static applyRequestParametersToUrl(W,Y){return W.pathname=W.pathname.replace(/:([A-Z_-]+)/ig,(J,Z)=>{if(Y[Z]!==void 0)return String(Y[Z]);return J}),W}}n1.JSON_1_1_ENDPOINTS=new Set(["direct_messages/events/new.json","direct_messages/welcome_messages/new.json","direct_messages/welcome_messages/rules/new.json","media/metadata/create.json","collections/entries/curate.json"]);var O=n1;import*as L0 from"crypto";class V{static getCodeVerifier(){return this.generateRandomString(128)}static getCodeChallengeFromVerifier(W){return this.escapeBase64Url(L0.createHash("sha256").update(W).digest("base64"))}static getAuthHeader(W,Y){let J=encodeURIComponent(W)+":"+encodeURIComponent(Y);return Buffer.from(J).toString("base64")}static generateRandomString(W){let Y="",J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";for(let Z=0;Z<W;Z++)Y+=J[Math.floor(Math.random()*J.length)];return Y}static escapeBase64Url(W){return W.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}}class l{constructor(W){if(this.rateLimits={},this.clientSettings={},W)this.clientSettings=W}getRateLimits(){return this.rateLimits}saveRateLimit(W,Y){this.rateLimits[W]=Y}async send(W){var Y,J,Z,G,$;if((Y=this.clientSettings.plugins)===null||Y===void 0?void 0:Y.length){let M=await this.applyPreRequestConfigHooks(W);if(M)return M}let Q=this.getHttpRequestArgs(W),K={method:Q.method,headers:Q.headers,timeout:W.timeout,agent:this.clientSettings.httpAgent},z=W.enableRateLimitSave!==!1;if(Q.body)O.setBodyLengthHeader(K,Q.body);if((J=this.clientSettings.plugins)===null||J===void 0?void 0:J.length)await this.applyPreRequestHooks(W,Q,K);let X=new x1({url:Q.url,options:K,body:Q.body,rateLimitSaver:z?this.saveRateLimit.bind(this,Q.rawUrl):void 0,requestEventDebugHandler:W.requestEventDebugHandler,compression:(G=(Z=W.compression)!==null&&Z!==void 0?Z:this.clientSettings.compression)!==null&&G!==void 0?G:!0,forceParseMode:W.forceParseMode}).makeRequest();if(B0(this))X=this.applyResponseErrorHooks(W,Q,K,X);let x=await X;if(($=this.clientSettings.plugins)===null||$===void 0?void 0:$.length){let M=await this.applyPostRequestHooks(W,Q,K,x);if(M)return M.value}return x}sendStream(W){var Y,J;if(this.clientSettings.plugins)this.applyPreStreamRequestConfigHooks(W);let Z=this.getHttpRequestArgs(W),G={method:Z.method,headers:Z.headers,agent:this.clientSettings.httpAgent},$=W.enableRateLimitSave!==!1,Q=W.autoConnect!==!1;if(Z.body)O.setBodyLengthHeader(G,Z.body);let K={url:Z.url,options:G,body:Z.body,rateLimitSaver:$?this.saveRateLimit.bind(this,Z.rawUrl):void 0,payloadIsError:W.payloadIsError,compression:(J=(Y=W.compression)!==null&&Y!==void 0?Y:this.clientSettings.compression)!==null&&J!==void 0?J:!0},z=new S1(K);if(!Q)return z;return z.connect()}initializeToken(W){if(typeof W==="string")this.bearerToken=W;else if(typeof W==="object"&&"appKey"in W){if(this.consumerToken=W.appKey,this.consumerSecret=W.appSecret,W.accessToken&&W.accessSecret)this.accessToken=W.accessToken,this.accessSecret=W.accessSecret;this._oauth=this.buildOAuth()}else if(typeof W==="object"&&"username"in W){let Y=encodeURIComponent(W.username)+":"+encodeURIComponent(W.password);this.basicToken=Buffer.from(Y).toString("base64")}else if(typeof W==="object"&&"clientId"in W)this.clientId=W.clientId,this.clientSecret=W.clientSecret}getActiveTokens(){if(this.bearerToken)return{type:"oauth2",bearerToken:this.bearerToken};else if(this.basicToken)return{type:"basic",token:this.basicToken};else if(this.consumerSecret&&this._oauth)return{type:"oauth-1.0a",appKey:this.consumerToken,appSecret:this.consumerSecret,accessToken:this.accessToken,accessSecret:this.accessSecret};else if(this.clientId)return{type:"oauth2-user",clientId:this.clientId};return{type:"none"}}buildOAuth(){if(!this.consumerSecret||!this.consumerToken)throw Error("Invalid consumer tokens");return new M1({consumerKeys:{key:this.consumerToken,secret:this.consumerSecret}})}getOAuthAccessTokens(){if(!this.accessSecret||!this.accessToken)return;return{key:this.accessToken,secret:this.accessSecret}}getPlugins(){var W;return(W=this.clientSettings.plugins)!==null&&W!==void 0?W:[]}hasPlugins(){var W;return!!((W=this.clientSettings.plugins)===null||W===void 0?void 0:W.length)}async applyPluginMethod(W,Y){var J;let Z;for(let G of this.getPlugins()){let $=await((J=G[W])===null||J===void 0?void 0:J.call(G,Y));if($&&$ instanceof z1)Z=$}return Z}writeAuthHeaders({headers:W,bodyInSignature:Y,url:J,method:Z,query:G,body:$}){if(W={...W},this.bearerToken)W.Authorization="Bearer "+this.bearerToken;else if(this.basicToken)W.Authorization="Basic "+this.basicToken;else if(this.clientId&&this.clientSecret)W.Authorization="Basic "+V.getAuthHeader(this.clientId,this.clientSecret);else if(this.consumerSecret&&this._oauth){let Q=Y?O.mergeQueryAndBodyForOAuth(G,$):G,K=this._oauth.authorize({url:J.toString(),method:Z,data:Q},this.getOAuthAccessTokens());W={...W,...this._oauth.toHeader(K)}}return W}getUrlObjectFromUrlString(W){if(!W.startsWith("http"))W="https://"+W;return new URL(W)}getHttpRequestArgs({url:W,method:Y,query:J={},body:Z={},headers:G,forceBodyMode:$,enableAuth:Q,params:K}){let z=void 0;if(Y=Y.toUpperCase(),G=G!==null&&G!==void 0?G:{},!G["x-user-agent"])G["x-user-agent"]="Node.twitter-api-v2";let X=this.getUrlObjectFromUrlString(W),x=X.origin+X.pathname;if(K)O.applyRequestParametersToUrl(X,K);let M=O.formatQueryToString(J);if(O.moveUrlQueryParamsIntoObject(X,M),!(Z instanceof Buffer))G0(Z);let R=$!==null&&$!==void 0?$:O.autoDetectBodyType(X);if(Q!==!1){let v=l.BODY_METHODS.has(Y)&&R==="url";G=this.writeAuthHeaders({headers:G,bodyInSignature:v,method:Y,query:M,url:X,body:Z})}if(l.BODY_METHODS.has(Y))z=O.constructBodyParams(Z,G,R)||void 0;return O.addQueryParamsToUrl(X,M),{rawUrl:x,url:X,method:Y,headers:G,body:z}}async applyPreRequestConfigHooks(W){var Y;let J=this.getUrlObjectFromUrlString(W.url);for(let Z of this.getPlugins()){let G=await((Y=Z.onBeforeRequestConfig)===null||Y===void 0?void 0:Y.call(Z,{client:this,url:J,params:W}));if(G)return G}}applyPreStreamRequestConfigHooks(W){var Y;let J=this.getUrlObjectFromUrlString(W.url);for(let Z of this.getPlugins())(Y=Z.onBeforeStreamRequestConfig)===null||Y===void 0||Y.call(Z,{client:this,url:J,params:W})}async applyPreRequestHooks(W,Y,J){await this.applyPluginMethod("onBeforeRequest",{client:this,url:this.getUrlObjectFromUrlString(W.url),params:W,computedParams:Y,requestOptions:J})}async applyPostRequestHooks(W,Y,J,Z){return await this.applyPluginMethod("onAfterRequest",{client:this,url:this.getUrlObjectFromUrlString(W.url),params:W,computedParams:Y,requestOptions:J,response:Z})}applyResponseErrorHooks(W,Y,J,Z){return Z.catch(x0.bind(this,W,Y,J))}}l.BODY_METHODS=new Set(["POST","PUT","PATCH"]);class h{constructor(W,Y={}){if(this._currentUser=null,this._currentUserV2=null,W instanceof h)this._requestMaker=W._requestMaker;else this._requestMaker=new l(Y),this._requestMaker.initializeToken(W)}setPrefix(W){this._prefix=W}cloneWithPrefix(W){let Y=this.constructor(this);return Y.setPrefix(W),Y}getActiveTokens(){return this._requestMaker.getActiveTokens()}getPlugins(){return this._requestMaker.getPlugins()}getPluginOfType(W){return this.getPlugins().find((Y)=>Y instanceof W)}hasHitRateLimit(W){var Y;if(this.isRateLimitStatusObsolete(W))return!1;return((Y=this.getLastRateLimitStatus(W))===null||Y===void 0?void 0:Y.remaining)===0}isRateLimitStatusObsolete(W){let Y=this.getLastRateLimitStatus(W);if(Y===void 0)return!0;return Y.reset*1000<Date.now()}getLastRateLimitStatus(W){let Y=W.match(/^https?:\/\//)?W:this._prefix+W;return this._requestMaker.getRateLimits()[Y]}getCurrentUserObject(W=!1){if(!W&&this._currentUser){if(this._currentUser.value)return Promise.resolve(this._currentUser.value);return this._currentUser.promise}return this._currentUser=p1(()=>this.get("account/verify_credentials.json",{tweet_mode:"extended"},{prefix:T})),this._currentUser.promise}getCurrentUserV2Object(W=!1){if(!W&&this._currentUserV2){if(this._currentUserV2.value)return Promise.resolve(this._currentUserV2.value);return this._currentUserV2.promise}return this._currentUserV2=p1(()=>this.get("users/me",void 0,{prefix:I})),this._currentUserV2.promise}async get(W,Y={},{fullResponse:J,prefix:Z=this._prefix,...G}={}){if(Z)W=Z+W;let $=await this._requestMaker.send({url:W,method:"GET",query:Y,...G});return J?$:$.data}async delete(W,Y={},{fullResponse:J,prefix:Z=this._prefix,...G}={}){if(Z)W=Z+W;let $=await this._requestMaker.send({url:W,method:"DELETE",query:Y,...G});return J?$:$.data}async post(W,Y,{fullResponse:J,prefix:Z=this._prefix,...G}={}){if(Z)W=Z+W;let $=await this._requestMaker.send({url:W,method:"POST",body:Y,...G});return J?$:$.data}async put(W,Y,{fullResponse:J,prefix:Z=this._prefix,...G}={}){if(Z)W=Z+W;let $=await this._requestMaker.send({url:W,method:"PUT",body:Y,...G});return J?$:$.data}async patch(W,Y,{fullResponse:J,prefix:Z=this._prefix,...G}={}){if(Z)W=Z+W;let $=await this._requestMaker.send({url:W,method:"PATCH",body:Y,...G});return J?$:$.data}getStream(W,Y,{prefix:J=this._prefix,...Z}={}){return this._requestMaker.sendStream({url:J?J+W:W,method:"GET",query:Y,...Z})}postStream(W,Y,{prefix:J=this._prefix,...Z}={}){return this._requestMaker.sendStream({url:J?J+W:W,method:"POST",body:Y,...Z})}}class H extends h{constructor(W){if(!(W instanceof h))throw Error("You must instance SubTwitterApi instance from existing TwitterApi instance.");super(W)}}class n extends p{constructor(){super(...arguments);this.hasFinishedFetch=!1}refreshInstanceFromResult(W,Y){let J=W.data;if(this._rateLimit=W.rateLimit,Y)this._realData.push(...J),this.hasFinishedFetch=J.length===0}getNextQueryParams(W){let Y=BigInt(this._realData[this._realData.length-1].id_str);return{...this.injectQueryParams(W),max_id:(Y-BigInt(1)).toString()}}getPageLengthFromRequest(W){return W.data.length}isFetchLastOver(W){return!W.data.length}canFetchNextPage(W){return W.length>0}getItemArray(){return this.tweets}get tweets(){return this._realData}get done(){return super.done||this.hasFinishedFetch}}class i1 extends n{constructor(){super(...arguments);this._endpoint="statuses/home_timeline.json"}}class o1 extends n{constructor(){super(...arguments);this._endpoint="statuses/mentions_timeline.json"}}class R1 extends n{constructor(){super(...arguments);this._endpoint="statuses/user_timeline.json"}}class s1 extends n{constructor(){super(...arguments);this._endpoint="lists/statuses.json"}}class k1 extends n{constructor(){super(...arguments);this._endpoint="favorites/list.json"}}class a1 extends L{constructor(){super(...arguments);this._endpoint="mutes/users/list.json"}refreshInstanceFromResult(W,Y){let J=W.data;if(this._rateLimit=W.rateLimit,Y)this._realData.users.push(...J.users),this._realData.next_cursor=J.next_cursor}getPageLengthFromRequest(W){return W.data.users.length}getItemArray(){return this.users}get users(){return this._realData.users}}class t1 extends L{constructor(){super(...arguments);this._endpoint="mutes/users/ids.json",this._maxResultsWhenFetchLast=5000}refreshInstanceFromResult(W,Y){let J=W.data;if(this._rateLimit=W.rateLimit,Y)this._realData.ids.push(...J.ids),this._realData.next_cursor=J.next_cursor}getPageLengthFromRequest(W){return W.data.ids.length}getItemArray(){return this.ids}get ids(){return this._realData.ids}}class r1 extends L{constructor(){super(...arguments);this._endpoint="followers/list.json"}refreshInstanceFromResult(W,Y){let J=W.data;if(this._rateLimit=W.rateLimit,Y)this._realData.users.push(...J.users),this._realData.next_cursor=J.next_cursor}getPageLengthFromRequest(W){return W.data.users.length}getItemArray(){return this.users}get users(){return this._realData.users}}class e1 extends L{constructor(){super(...arguments);this._endpoint="followers/ids.json",this._maxResultsWhenFetchLast=5000}refreshInstanceFromResult(W,Y){let J=W.data;if(this._rateLimit=W.rateLimit,Y)this._realData.ids.push(...J.ids),this._realData.next_cursor=J.next_cursor}getPageLengthFromRequest(W){return W.data.ids.length}getItemArray(){return this.ids}get ids(){return this._realData.ids}}class W4 extends L{constructor(){super(...arguments);this._endpoint="friends/list.json"}refreshInstanceFromResult(W,Y){let J=W.data;if(this._rateLimit=W.rateLimit,Y)this._realData.users.push(...J.users),this._realData.next_cursor=J.next_cursor}getPageLengthFromRequest(W){return W.data.users.length}getItemArray(){return this.users}get users(){return this._realData.users}}class Y4 extends L{constructor(){super(...arguments);this._endpoint="friends/ids.json",this._maxResultsWhenFetchLast=5000}refreshInstanceFromResult(W,Y){let J=W.data;if(this._rateLimit=W.rateLimit,Y)this._realData.ids.push(...J.ids),this._realData.next_cursor=J.next_cursor}getPageLengthFromRequest(W){return W.data.ids.length}getItemArray(){return this.ids}get ids(){return this._realData.ids}}class J4 extends p{constructor(){super(...arguments);this._endpoint="users/search.json"}refreshInstanceFromResult(W,Y){let J=W.data;if(this._rateLimit=W.rateLimit,Y)this._realData.push(...J)}getNextQueryParams(W){var Y;let J=Number((Y=this._queryParams.page)!==null&&Y!==void 0?Y:"1");return{...this._queryParams,page:J+1,...W?{count:W}:{}}}getPageLengthFromRequest(W){return W.data.length}isFetchLastOver(W){return!W.data.length}canFetchNextPage(W){return W.length>0}getItemArray(){return this.users}get users(){return this._realData}}class _1 extends L{constructor(){super(...arguments);this._endpoint="friendships/incoming.json",this._maxResultsWhenFetchLast=5000}refreshInstanceFromResult(W,Y){let J=W.data;if(this._rateLimit=W.rateLimit,Y)this._realData.ids.push(...J.ids),this._realData.next_cursor=J.next_cursor}getPageLengthFromRequest(W){return W.data.ids.length}getItemArray(){return this.ids}get ids(){return this._realData.ids}}class Z4 extends _1{constructor(){super(...arguments);this._endpoint="friendships/outgoing.json"}}class C1 extends L{refreshInstanceFromResult(W,Y){let J=W.data;if(this._rateLimit=W.rateLimit,Y)this._realData.lists.push(...J.lists),this._realData.next_cursor=J.next_cursor}getPageLengthFromRequest(W){return W.data.lists.length}getItemArray(){return this.lists}get lists(){return this._realData.lists}}class G4 extends C1{constructor(){super(...arguments);this._endpoint="lists/memberships.json"}}class $4 extends C1{constructor(){super(...arguments);this._endpoint="lists/ownerships.json"}}class Q4 extends C1{constructor(){super(...arguments);this._endpoint="lists/subscriptions.json"}}class K4 extends L{refreshInstanceFromResult(W,Y){let J=W.data;if(this._rateLimit=W.rateLimit,Y)this._realData.users.push(...J.users),this._realData.next_cursor=J.next_cursor}getPageLengthFromRequest(W){return W.data.users.length}getItemArray(){return this.users}get users(){return this._realData.users}}class X4 extends K4{constructor(){super(...arguments);this._endpoint="lists/members.json"}}class z4 extends K4{constructor(){super(...arguments);this._endpoint="lists/subscribers.json"}}class i extends H{constructor(){super(...arguments);this._prefix=T}singleTweet(W,Y={}){return this.get("statuses/show.json",{tweet_mode:"extended",id:W,...Y})}tweets(W,Y={}){return this.post("statuses/lookup.json",{tweet_mode:"extended",id:W,...Y})}oembedTweet(W,Y={}){return this.get("oembed",{url:`https://x.com/i/statuses/${W}`,...Y},{prefix:"https://publish.x.com/"})}async homeTimeline(W={}){let Y={tweet_mode:"extended",...W},J=await this.get("statuses/home_timeline.json",Y,{fullResponse:!0});return new i1({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async mentionTimeline(W={}){let Y={tweet_mode:"extended",...W},J=await this.get("statuses/mentions_timeline.json",Y,{fullResponse:!0});return new o1({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async userTimeline(W,Y={}){let J={tweet_mode:"extended",user_id:W,...Y},Z=await this.get("statuses/user_timeline.json",J,{fullResponse:!0});return new R1({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async userTimelineByUsername(W,Y={}){let J={tweet_mode:"extended",screen_name:W,...Y},Z=await this.get("statuses/user_timeline.json",J,{fullResponse:!0});return new R1({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async favoriteTimeline(W,Y={}){let J={tweet_mode:"extended",user_id:W,...Y},Z=await this.get("favorites/list.json",J,{fullResponse:!0});return new k1({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async favoriteTimelineByUsername(W,Y={}){let J={tweet_mode:"extended",screen_name:W,...Y},Z=await this.get("favorites/list.json",J,{fullResponse:!0});return new k1({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}user(W){return this.get("users/show.json",{tweet_mode:"extended",...W})}users(W){return this.get("users/lookup.json",{tweet_mode:"extended",...W})}verifyCredentials(W={}){return this.get("account/verify_credentials.json",W)}async listMutedUsers(W={}){let Y={tweet_mode:"extended",...W},J=await this.get("mutes/users/list.json",Y,{fullResponse:!0});return new a1({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async listMutedUserIds(W={}){let Y={stringify_ids:!0,...W},J=await this.get("mutes/users/ids.json",Y,{fullResponse:!0});return new t1({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async userFriendList(W={}){let Y={...W},J=await this.get("friends/list.json",Y,{fullResponse:!0});return new W4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async userFollowerList(W={}){let Y={...W},J=await this.get("followers/list.json",Y,{fullResponse:!0});return new r1({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async userFollowerIds(W={}){let Y={stringify_ids:!0,...W},J=await this.get("followers/ids.json",Y,{fullResponse:!0});return new e1({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async userFollowingIds(W={}){let Y={stringify_ids:!0,...W},J=await this.get("friends/ids.json",Y,{fullResponse:!0});return new Y4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async searchUsers(W,Y={}){let J={q:W,tweet_mode:"extended",page:1,...Y},Z=await this.get("users/search.json",J,{fullResponse:!0});return new J4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}friendship(W){return this.get("friendships/show.json",W)}friendships(W){return this.get("friendships/lookup.json",W)}friendshipsNoRetweets(){return this.get("friendships/no_retweets/ids.json",{stringify_ids:!0})}async friendshipsIncoming(W={}){let Y={stringify_ids:!0,...W},J=await this.get("friendships/incoming.json",Y,{fullResponse:!0});return new _1({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async friendshipsOutgoing(W={}){let Y={stringify_ids:!0,...W},J=await this.get("friendships/outgoing.json",Y,{fullResponse:!0});return new Z4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}accountSettings(){return this.get("account/settings.json")}userProfileBannerSizes(W){return this.get("users/profile_banner.json",W)}list(W){return this.get("lists/show.json",{tweet_mode:"extended",...W})}lists(W={}){return this.get("lists/list.json",{tweet_mode:"extended",...W})}async listMembers(W={}){let Y={tweet_mode:"extended",...W},J=await this.get("lists/members.json",Y,{fullResponse:!0});return new X4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}listGetMember(W){return this.get("lists/members/show.json",{tweet_mode:"extended",...W})}async listMemberships(W={}){let Y={tweet_mode:"extended",...W},J=await this.get("lists/memberships.json",Y,{fullResponse:!0});return new G4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async listOwnerships(W={}){let Y={tweet_mode:"extended",...W},J=await this.get("lists/ownerships.json",Y,{fullResponse:!0});return new $4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async listStatuses(W){let Y={tweet_mode:"extended",...W},J=await this.get("lists/statuses.json",Y,{fullResponse:!0});return new s1({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}async listSubscribers(W={}){let Y={tweet_mode:"extended",...W},J=await this.get("lists/subscribers.json",Y,{fullResponse:!0});return new z4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}listGetSubscriber(W){return this.get("lists/subscribers/show.json",{tweet_mode:"extended",...W})}async listSubscriptions(W={}){let Y={tweet_mode:"extended",...W},J=await this.get("lists/subscriptions.json",Y,{fullResponse:!0});return new Q4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}mediaInfo(W){return this.get("media/upload.json",{command:"STATUS",media_id:W},{prefix:_})}filterStream({autoConnect:W,...Y}={}){let J={};for(let[G,$]of Object.entries(Y))if(G==="follow"||G==="track")J[G]=$.toString();else if(G==="locations"){let Q=$;J.locations=H1(Q).map((K)=>`${K.lng},${K.lat}`).join(",")}else J[G]=$;return this.stream.postStream("statuses/filter.json",J,{autoConnect:W})}sampleStream({autoConnect:W,...Y}={}){return this.stream.getStream("statuses/sample.json",Y,{autoConnect:W})}get stream(){let W=new v1(this);return W.setPrefix(Y0),W}trendsByPlace(W,Y={}){return this.get("trends/place.json",{id:W,...Y})}trendsAvailable(){return this.get("trends/available.json")}trendsClosest(W,Y){return this.get("trends/closest.json",{lat:W,long:Y})}geoPlace(W){return this.get("geo/id/:place_id.json",void 0,{params:{place_id:W}})}geoSearch(W){return this.get("geo/search.json",W)}geoReverseGeoCode(W){return this.get("geo/reverse_geocode.json",W)}rateLimitStatuses(...W){return this.get("application/rate_limit_status.json",{resources:W})}supportedLanguages(){return this.get("help/languages.json")}}import*as P from"fs";async function B4(W){let Y=await x4(W);if(typeof Y==="number")return new Promise((J,Z)=>{P.readFile(Y,(G,$)=>{if(G)return Z(G);J($)})});else if(Y instanceof Buffer)return Y;else return Y.readFile()}function x4(W){if(typeof W==="string")return P.promises.open(W,"r");else if(typeof W==="number")return W;else if(typeof W==="object"&&!(W instanceof Buffer))return W;else if(!(W instanceof Buffer))throw Error("Given file is not valid, please check its type.");else return W}async function D0(W){if(typeof W==="number")return(await new Promise((J,Z)=>{P.fstat(W,(G,$)=>{if(G)Z(G);J($)})})).size;else if(W instanceof Buffer)return W.length;else return(await W.stat()).size}function F0(W,Y,J){if(typeof J==="string")return J;else if(typeof W==="string"&&!Y)return s0(W);else if(typeof Y==="string")return a0(Y);throw Error("You must specify type if file is a file handle or Buffer.")}function s0(W){if(W.endsWith(".jpeg")||W.endsWith(".jpg"))return N.Jpeg;if(W.endsWith(".png"))return N.Png;if(W.endsWith(".webp"))return N.Webp;if(W.endsWith(".gif"))return N.Gif;if(W.endsWith(".mpeg4")||W.endsWith(".mp4"))return N.Mp4;if(W.endsWith(".mov")||W.endsWith(".mov"))return N.Mov;if(W.endsWith(".srt"))return N.Srt;return l1({instance:"TwitterApiv1ReadWrite",method:"uploadMedia",problem:"options.mimeType is missing and filename couldn't help to resolve MIME type, so it will fallback to image/jpeg",resolution:"If you except to give filenames without extensions, please specify explicitlty the MIME type using options.mimeType"}),N.Jpeg}function a0(W){if(l1({instance:"TwitterApiv1ReadWrite",method:"uploadMedia",problem:"you're using options.type",resolution:"Remove options.type argument and migrate to options.mimeType which takes the real MIME type. If you're using type=longmp4, add options.longVideo alongside of mimeType=EUploadMimeType.Mp4"}),W==="gif")return N.Gif;if(W==="jpg")return N.Jpeg;if(W==="png")return N.Png;if(W==="webp")return N.Webp;if(W==="srt")return N.Srt;if(W==="mp4"||W==="longmp4")return N.Mp4;if(W==="mov")return N.Mov;return W}function O0(W,Y){if(W===N.Mp4||W===N.Mov)return Y==="tweet"?"TweetVideo":"DmVideo";if(W===N.Gif)return Y==="tweet"?"TweetGif":"DmGif";if(W===N.Srt)return"Subtitles";else return Y==="tweet"?"TweetImage":"DmImage"}function M4(W){return new Promise((Y)=>setTimeout(Y,W*1000))}async function j4(W,Y,J=0,Z){if(W instanceof Buffer){let $=W.slice(J,J+Y);return[$,$.length]}if(!Z)throw Error("Well, we will need a buffer to store file content.");let G;if(typeof W==="number")G=await new Promise(($,Q)=>{P.read(W,Z,0,Y,J,(K,z)=>{if(K)Q(K);$(z)})});else G=(await W.read(Z,0,Y,J)).bytesRead;return[Z,G]}var N4="media/upload.json";class o extends i{constructor(){super(...arguments);this._prefix=T}get readOnly(){return this}tweet(W,Y={}){let J={status:W,tweet_mode:"extended",...Y};return this.post("statuses/update.json",J)}async quote(W,Y,J={}){let Z="https://x.com/i/statuses/"+Y;return this.tweet(W,{...J,attachment_url:Z})}async tweetThread(W){let Y=[];for(let J of W){let Z=Y.length?Y[Y.length-1]:null,G={...typeof J==="string"?{status:J}:J},$=Z?Z.id_str:G.in_reply_to_status_id,Q=G.status;if($)Y.push(await this.reply(Q,$,G));else Y.push(await this.tweet(Q,G))}return Y}reply(W,Y,J={}){return this.tweet(W,{auto_populate_reply_metadata:!0,in_reply_to_status_id:Y,...J})}deleteTweet(W){return this.post("statuses/destroy/:id.json",{tweet_mode:"extended"},{params:{id:W}})}reportUserAsSpam(W){return this.post("users/report_spam.json",{tweet_mode:"extended",...W})}updateFriendship(W){return this.post("friendships/update.json",W)}createFriendship(W){return this.post("friendships/create.json",W)}destroyFriendship(W){return this.post("friendships/destroy.json",W)}updateAccountSettings(W){return this.post("account/settings.json",W)}updateAccountProfile(W){return this.post("account/update_profile.json",W)}async updateAccountProfileBanner(W,Y={}){let J={banner:await B4(W),...Y};return this.post("account/update_profile_banner.json",J,{forceBodyMode:"form-data"})}async updateAccountProfileImage(W,Y={}){let J={tweet_mode:"extended",image:await B4(W),...Y};return this.post("account/update_profile_image.json",J,{forceBodyMode:"form-data"})}removeAccountProfileBanner(){return this.post("account/remove_profile_banner.json")}createList(W){return this.post("lists/create.json",{tweet_mode:"extended",...W})}updateList(W){return this.post("lists/update.json",{tweet_mode:"extended",...W})}removeList(W){return this.post("lists/destroy.json",{tweet_mode:"extended",...W})}addListMembers(W){let J=W.user_id&&B1(W.user_id)||W.screen_name&&B1(W.screen_name)?"lists/members/create_all.json":"lists/members/create.json";return this.post(J,W)}removeListMembers(W){let J=W.user_id&&B1(W.user_id)||W.screen_name&&B1(W.screen_name)?"lists/members/destroy_all.json":"lists/members/destroy.json";return this.post(J,W)}subscribeToList(W){return this.post("lists/subscribers/create.json",{tweet_mode:"extended",...W})}unsubscribeOfList(W){return this.post("lists/subscribers/destroy.json",{tweet_mode:"extended",...W})}createMediaMetadata(W,Y){return this.post("media/metadata/create.json",{media_id:W,...Y},{prefix:_,forceBodyMode:"json"})}createMediaSubtitles(W,Y){return this.post("media/subtitles/create.json",{media_id:W,media_category:"TweetVideo",subtitle_info:{subtitles:Y}},{prefix:_,forceBodyMode:"json"})}deleteMediaSubtitles(W,...Y){return this.post("media/subtitles/delete.json",{media_id:W,media_category:"TweetVideo",subtitle_info:{subtitles:Y.map((J)=>({language_code:J}))}},{prefix:_,forceBodyMode:"json"})}async uploadMedia(W,Y={},J=!1){var Z;let G=(Z=Y.chunkLength)!==null&&Z!==void 0?Z:1048576,{fileHandle:$,mediaCategory:Q,fileSize:K,mimeType:z}=await this.getUploadMediaRequirements(W,Y);try{let X=await this.post(N4,{command:"INIT",total_bytes:K,media_type:z,media_category:Q,additional_owners:Y.additionalOwners,shared:Y.shared?!0:void 0},{prefix:_});await this.mediaChunkedUpload($,G,X.media_id_string,Y.maxConcurrentUploads);let x=await this.post(N4,{command:"FINALIZE",media_id:X.media_id_string},{prefix:_});if(x.processing_info&&x.processing_info.state!=="succeeded")await this.awaitForMediaProcessingCompletion(x);if(J)return x;else return x.media_id_string}finally{if(typeof W==="number")L4.close(W,()=>{});else if(typeof $==="object"&&!($ instanceof Buffer))$.close()}}async awaitForMediaProcessingCompletion(W){var Y;while(!0){W=await this.mediaInfo(W.media_id_string);let{processing_info:J}=W;if(!J||J.state==="succeeded")return;if((Y=J.error)===null||Y===void 0?void 0:Y.code){let{name:Z,message:G}=J.error;throw Error(`Failed to process media: ${Z} - ${G}.`)}if(J.state==="failed")throw Error("Failed to process the media.");if(J.check_after_secs)await M4(J.check_after_secs);else await M4(5)}}async getUploadMediaRequirements(W,{mimeType:Y,type:J,target:Z,longVideo:G}={}){let $;try{$=await x4(W);let Q=F0(W,J,Y),K;if(Q===N.Mp4&&(!Y&&!J&&Z!=="dm"||G))K="amplify_video";else K=O0(Q,Z!==null&&Z!==void 0?Z:"tweet");return{fileHandle:$,mediaCategory:K,fileSize:await D0($),mimeType:Q}}catch(Q){if(typeof W==="number")L4.close(W,()=>{});else if(typeof $==="object"&&!($ instanceof Buffer))$.close();throw Q}}async mediaChunkedUpload(W,Y,J,Z=3){let G=0;if(Z<1)throw RangeError("Bad maxConcurrentUploads parameter.");let $=W instanceof Buffer?void 0:Buffer.alloc(Y),Q,K,z=0;[Q,K]=await j4(W,Y,z,$),z+=K;let X=new Set;while(K){let x=Q.slice(0,K);if(x.length){let M=this.post(N4,{command:"APPEND",media_id:J,segment_index:G,media:x},{prefix:_});X.add(M),M.then(()=>{X.delete(M)}),G++}if(X.size>=Z)await Promise.race(X);[Q,K]=await j4(W,Y,z,$),z+=K}await Promise.all([...X])}}class H0 extends o{constructor(){super(...arguments);this._prefix=T}get readWrite(){return this}sendDm({recipient_id:W,custom_profile_id:Y,...J}){let Z={event:{type:q.Create,[q.Create]:{target:{recipient_id:W},message_data:J}}};if(Y)Z.event[q.Create].custom_profile_id=Y;return this.post("direct_messages/events/new.json",Z,{forceBodyMode:"json"})}getDmEvent(W){return this.get("direct_messages/events/show.json",{id:W})}deleteDm(W){return this.delete("direct_messages/events/destroy.json",{id:W})}async listDmEvents(W={}){let Y={...W},J=await this.get("direct_messages/events/list.json",Y,{fullResponse:!0});return new u1({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}newWelcomeDm(W,Y){let J={[q.WelcomeCreate]:{name:W,message_data:Y}};return this.post("direct_messages/welcome_messages/new.json",J,{forceBodyMode:"json"})}getWelcomeDm(W){return this.get("direct_messages/welcome_messages/show.json",{id:W})}deleteWelcomeDm(W){return this.delete("direct_messages/welcome_messages/destroy.json",{id:W})}updateWelcomeDm(W,Y){let J={message_data:Y};return this.put("direct_messages/welcome_messages/update.json",J,{forceBodyMode:"json",query:{id:W}})}async listWelcomeDms(W={}){let Y={...W},J=await this.get("direct_messages/welcome_messages/list.json",Y,{fullResponse:!0});return new d1({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y})}newWelcomeDmRule(W){return this.post("direct_messages/welcome_messages/rules/new.json",{welcome_message_rule:{welcome_message_id:W}},{forceBodyMode:"json"})}getWelcomeDmRule(W){return this.get("direct_messages/welcome_messages/rules/show.json",{id:W})}deleteWelcomeDmRule(W){return this.delete("direct_messages/welcome_messages/rules/destroy.json",{id:W})}async listWelcomeDmRules(W={}){let Y={...W};return this.get("direct_messages/welcome_messages/rules/list.json",Y)}async setWelcomeDm(W,Y=!0){var J;let Z=await this.listWelcomeDmRules();if((J=Z.welcome_message_rules)===null||J===void 0?void 0:J.length){for(let G of Z.welcome_message_rules)if(await this.deleteWelcomeDmRule(G.id),Y)await this.deleteWelcomeDm(G.welcome_message_id)}return this.newWelcomeDmRule(W)}markDmAsRead(W,Y){return this.post("direct_messages/mark_read.json",{last_read_event_id:W,recipient_id:Y},{forceBodyMode:"url"})}indicateDmTyping(W){return this.post("direct_messages/indicate_typing.json",{recipient_id:W},{forceBodyMode:"url"})}async downloadDmImage(W){if(typeof W!=="string"){let J=W[q.Create].message_data.attachment;if(!J)throw Error("The given direct message doesn't contain any attachment");W=J.media.media_url_https}let Y=await this.get(W,void 0,{forceParseMode:"buffer",prefix:""});if(!Y.length)throw Error("Image not found. Make sure you are logged with credentials able to access direct messages, and check the URL.");return Y}}var v1=H0;class j{constructor(W){this.result=W}get tweets(){return j.tweets(this.result)}static tweets(W){var Y,J;return(J=(Y=W.includes)===null||Y===void 0?void 0:Y.tweets)!==null&&J!==void 0?J:[]}tweetById(W){return j.tweetById(this.result,W)}static tweetById(W,Y){return this.tweets(W).find((J)=>J.id===Y)}retweet(W){return j.retweet(this.result,W)}static retweet(W,Y){var J;let Z=((J=Y.referenced_tweets)!==null&&J!==void 0?J:[]).filter((G)=>G.type==="retweeted").map((G)=>G.id);return this.tweets(W).find((G)=>Z.includes(G.id))}quote(W){return j.quote(this.result,W)}static quote(W,Y){var J;let Z=((J=Y.referenced_tweets)!==null&&J!==void 0?J:[]).filter((G)=>G.type==="quoted").map((G)=>G.id);return this.tweets(W).find((G)=>Z.includes(G.id))}repliedTo(W){return j.repliedTo(this.result,W)}static repliedTo(W,Y){var J;let Z=((J=Y.referenced_tweets)!==null&&J!==void 0?J:[]).filter((G)=>G.type==="replied_to").map((G)=>G.id);return this.tweets(W).find((G)=>Z.includes(G.id))}author(W){return j.author(this.result,W)}static author(W,Y){let J=Y.author_id;return J?this.users(W).find((Z)=>Z.id===J):void 0}repliedToAuthor(W){return j.repliedToAuthor(this.result,W)}static repliedToAuthor(W,Y){let J=Y.in_reply_to_user_id;return J?this.users(W).find((Z)=>Z.id===J):void 0}get users(){return j.users(this.result)}static users(W){var Y,J;return(J=(Y=W.includes)===null||Y===void 0?void 0:Y.users)!==null&&J!==void 0?J:[]}userById(W){return j.userById(this.result,W)}static userById(W,Y){return this.users(W).find((J)=>J.id===Y)}pinnedTweet(W){return j.pinnedTweet(this.result,W)}static pinnedTweet(W,Y){return Y.pinned_tweet_id?this.tweets(W).find((J)=>J.id===Y.pinned_tweet_id):void 0}get media(){return j.media(this.result)}static media(W){var Y,J;return(J=(Y=W.includes)===null||Y===void 0?void 0:Y.media)!==null&&J!==void 0?J:[]}medias(W){return j.medias(this.result,W)}static medias(W,Y){var J,Z;let G=(Z=(J=Y.attachments)===null||J===void 0?void 0:J.media_keys)!==null&&Z!==void 0?Z:[];return this.media(W).filter(($)=>G.includes($.media_key))}get polls(){return j.polls(this.result)}static polls(W){var Y,J;return(J=(Y=W.includes)===null||Y===void 0?void 0:Y.polls)!==null&&J!==void 0?J:[]}poll(W){return j.poll(this.result,W)}static poll(W,Y){var J,Z;let G=(Z=(J=Y.attachments)===null||J===void 0?void 0:J.poll_ids)!==null&&Z!==void 0?Z:[];if(G.length){let $=G[0];return this.polls(W).find((Q)=>Q.id===$)}return}get places(){return j.places(this.result)}static places(W){var Y,J;return(J=(Y=W.includes)===null||Y===void 0?void 0:Y.places)!==null&&J!==void 0?J:[]}place(W){return j.place(this.result,W)}static place(W,Y){var J;let Z=(J=Y.geo)===null||J===void 0?void 0:J.place_id;return Z?this.places(W).find((G)=>G.id===Z):void 0}listOwner(W){return j.listOwner(this.result,W)}static listOwner(W,Y){let J=Y.owner_id;return J?this.users(W).find((Z)=>Z.id===J):void 0}spaceCreator(W){return j.spaceCreator(this.result,W)}static spaceCreator(W,Y){let J=Y.creator_id;return J?this.users(W).find((Z)=>Z.id===J):void 0}spaceHosts(W){return j.spaceHosts(this.result,W)}static spaceHosts(W,Y){var J;let Z=(J=Y.host_ids)!==null&&J!==void 0?J:[];return this.users(W).filter((G)=>Z.includes(G.id))}spaceSpeakers(W){return j.spaceSpeakers(this.result,W)}static spaceSpeakers(W,Y){var J;let Z=(J=Y.speaker_ids)!==null&&J!==void 0?J:[];return this.users(W).filter((G)=>Z.includes(G.id))}spaceInvitedUsers(W){return j.spaceInvitedUsers(this.result,W)}static spaceInvitedUsers(W,Y){var J;let Z=(J=Y.invited_user_ids)!==null&&J!==void 0?J:[];return this.users(W).filter((G)=>Z.includes(G.id))}}class b1 extends m1{updateIncludes(W){if(W.errors){if(!this._realData.errors)this._realData.errors=[];this._realData.errors=[...this._realData.errors,...W.errors]}if(!W.includes)return;if(!this._realData.includes)this._realData.includes={};let Y=this._realData.includes;for(let[J,Z]of Object.entries(W.includes)){if(!Y[J])Y[J]=[];Y[J]=[...Y[J],...Z]}}assertUsable(){if(this.unusable)throw Error("Unable to use this paginator to fetch more data, as it does not contain any metadata. Check .errors property for more details.")}get meta(){return this._realData.meta}get includes(){var W;if(!((W=this._realData)===null||W===void 0?void 0:W.includes))return new j(this._realData);if(this._includesInstance)return this._includesInstance;return this._includesInstance=new j(this._realData)}get errors(){var W;return(W=this._realData.errors)!==null&&W!==void 0?W:[]}get unusable(){return this.errors.length>0&&!this._realData.meta&&!this._realData.data}}class k extends b1{refreshInstanceFromResult(W,Y){var J;let Z=W.data,G=(J=Z.data)!==null&&J!==void 0?J:[];if(this._rateLimit=W.rateLimit,!this._realData.data)this._realData.data=[];if(Y)this._realData.meta.result_count+=Z.meta.result_count,this._realData.meta.next_token=Z.meta.next_token,this._realData.data.push(...G);else this._realData.meta.result_count+=Z.meta.result_count,this._realData.meta.previous_token=Z.meta.previous_token,this._realData.data.unshift(...G);this.updateIncludes(Z)}getNextQueryParams(W){return this.assertUsable(),{...this.injectQueryParams(W),pagination_token:this._realData.meta.next_token}}getPreviousQueryParams(W){return this.assertUsable(),{...this.injectQueryParams(W),pagination_token:this._realData.meta.previous_token}}getPageLengthFromRequest(W){var Y,J;return(J=(Y=W.data.data)===null||Y===void 0?void 0:Y.length)!==null&&J!==void 0?J:0}isFetchLastOver(W){var Y;return!((Y=W.data.data)===null||Y===void 0?void 0:Y.length)||!this.canFetchNextPage(W.data)}canFetchNextPage(W){var Y;return!!((Y=W.meta)===null||Y===void 0?void 0:Y.next_token)}}class D4 extends b1{refreshInstanceFromResult(W,Y){var J;let Z=W.data,G=(J=Z.data)!==null&&J!==void 0?J:[];if(this._rateLimit=W.rateLimit,!this._realData.data)this._realData.data=[];if(Y)this._realData.meta.oldest_id=Z.meta.oldest_id,this._realData.meta.result_count+=Z.meta.result_count,this._realData.meta.next_token=Z.meta.next_token,this._realData.data.push(...G);else this._realData.meta.newest_id=Z.meta.newest_id,this._realData.meta.result_count+=Z.meta.result_count,this._realData.data.unshift(...G);this.updateIncludes(Z)}getNextQueryParams(W){this.assertUsable();let Y={...this.injectQueryParams(W)};if(this._realData.meta.next_token)Y.next_token=this._realData.meta.next_token;else{if(Y.start_time)Y.since_id=this.dateStringToSnowflakeId(Y.start_time),delete Y.start_time;if(Y.end_time)delete Y.end_time;Y.until_id=this._realData.meta.oldest_id}return Y}getPreviousQueryParams(W){return this.assertUsable(),{...this.injectQueryParams(W),since_id:this._realData.meta.newest_id}}getPageLengthFromRequest(W){var Y,J;return(J=(Y=W.data.data)===null||Y===void 0?void 0:Y.length)!==null&&J!==void 0?J:0}isFetchLastOver(W){var Y;return!((Y=W.data.data)===null||Y===void 0?void 0:Y.length)||!this.canFetchNextPage(W.data)}canFetchNextPage(W){return!!W.meta.next_token}getItemArray(){return this.tweets}dateStringToSnowflakeId(W){let Y=BigInt("1288834974657"),J=new Date(W);if(isNaN(J.valueOf()))throw Error("Unable to convert start_time/end_time to a valid date. A ISO 8601 DateTime is excepted, please check your input.");return(BigInt(J.valueOf())-Y<<BigInt("22")).toString()}get tweets(){var W;return(W=this._realData.data)!==null&&W!==void 0?W:[]}get meta(){return super.meta}}class s extends k{refreshInstanceFromResult(W,Y){super.refreshInstanceFromResult(W,Y);let J=W.data;if(Y)this._realData.meta.oldest_id=J.meta.oldest_id;else this._realData.meta.newest_id=J.meta.newest_id}getItemArray(){return this.tweets}get tweets(){var W;return(W=this._realData.data)!==null&&W!==void 0?W:[]}get meta(){return super.meta}}class F4 extends D4{constructor(){super(...arguments);this._endpoint="tweets/search/recent"}}class O4 extends D4{constructor(){super(...arguments);this._endpoint="tweets/search/all"}}class H4 extends s{constructor(){super(...arguments);this._endpoint="tweets/:id/quote_tweets"}}class U4 extends s{constructor(){super(...arguments);this._endpoint="users/:id/timelines/reverse_chronological"}}class S4 extends s{constructor(){super(...arguments);this._endpoint="users/:id/tweets"}}class f4 extends s{constructor(){super(...arguments);this._endpoint="users/:id/mentions"}}class R4 extends s{constructor(){super(...arguments);this._endpoint="users/:id/bookmarks"}}class k4 extends k{get tweets(){var W;return(W=this._realData.data)!==null&&W!==void 0?W:[]}get meta(){return super.meta}getItemArray(){return this.tweets}}class _4 extends k4{constructor(){super(...arguments);this._endpoint="users/:id/liked_tweets"}}class C4 extends k4{constructor(){super(...arguments);this._endpoint="lists/:id/tweets"}}class C extends k{getItemArray(){return this.users}get users(){var W;return(W=this._realData.data)!==null&&W!==void 0?W:[]}get meta(){return super.meta}}class v4 extends C{constructor(){super(...arguments);this._endpoint="users/:id/blocking"}}class b4 extends C{constructor(){super(...arguments);this._endpoint="users/:id/muting"}}class I4 extends C{constructor(){super(...arguments);this._endpoint="users/:id/followers"}}class T4 extends C{constructor(){super(...arguments);this._endpoint="users/:id/following"}}class q4 extends C{constructor(){super(...arguments);this._endpoint="lists/:id/members"}}class h4 extends C{constructor(){super(...arguments);this._endpoint="lists/:id/followers"}}class P4 extends C{constructor(){super(...arguments);this._endpoint="tweets/:id/liking_users"}}class w4 extends C{constructor(){super(...arguments);this._endpoint="tweets/:id/retweeted_by"}}class I1 extends k{getItemArray(){return this.lists}get lists(){var W;return(W=this._realData.data)!==null&&W!==void 0?W:[]}get meta(){return super.meta}}class A4 extends I1{constructor(){super(...arguments);this._endpoint="users/:id/owned_lists"}}class y4 extends I1{constructor(){super(...arguments);this._endpoint="users/:id/list_memberships"}}class V4 extends I1{constructor(){super(...arguments);this._endpoint="users/:id/followed_lists"}}class a extends H{constructor(){super(...arguments);this._prefix=m}}class T1 extends k{getItemArray(){return this.events}get events(){var W;return(W=this._realData.data)!==null&&W!==void 0?W:[]}get meta(){return super.meta}}class g4 extends T1{constructor(){super(...arguments);this._endpoint="dm_events"}}class c4 extends T1{constructor(){super(...arguments);this._endpoint="dm_conversations/with/:participant_id/dm_events"}}class E4 extends T1{constructor(){super(...arguments);this._endpoint="dm_conversations/:dm_conversation_id/dm_events"}}class t extends H{constructor(){super(...arguments);this._prefix=I}get labs(){if(this._labs)return this._labs;return this._labs=new a(this)}async search(W,Y={}){let J=typeof W==="string"?{...Y,query:W}:{...W},Z=await this.get("tweets/search/recent",J,{fullResponse:!0});return new F4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async searchAll(W,Y={}){let J={...Y,query:W},Z=await this.get("tweets/search/all",J,{fullResponse:!0});return new O4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}singleTweet(W,Y={}){return this.get("tweets/:id",Y,{params:{id:W}})}tweets(W,Y={}){return this.get("tweets",{ids:W,...Y})}tweetCountRecent(W,Y={}){return this.get("tweets/counts/recent",{query:W,...Y})}tweetCountAll(W,Y={}){return this.get("tweets/counts/all",{query:W,...Y})}async tweetRetweetedBy(W,Y={}){let{asPaginator:J,...Z}=Y,G=await this.get("tweets/:id/retweeted_by",Z,{fullResponse:!0,params:{id:W}});if(!J)return G.data;return new w4({realData:G.data,rateLimit:G.rateLimit,instance:this,queryParams:Z,sharedParams:{id:W}})}async tweetLikedBy(W,Y={}){let{asPaginator:J,...Z}=Y,G=await this.get("tweets/:id/liking_users",Z,{fullResponse:!0,params:{id:W}});if(!J)return G.data;return new P4({realData:G.data,rateLimit:G.rateLimit,instance:this,queryParams:Z,sharedParams:{id:W}})}async homeTimeline(W={}){let Y=await this.getCurrentUserV2Object(),J=await this.get("users/:id/timelines/reverse_chronological",W,{fullResponse:!0,params:{id:Y.data.id}});return new U4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:W,sharedParams:{id:Y.data.id}})}async userTimeline(W,Y={}){let J=await this.get("users/:id/tweets",Y,{fullResponse:!0,params:{id:W}});return new S4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y,sharedParams:{id:W}})}async userMentionTimeline(W,Y={}){let J=await this.get("users/:id/mentions",Y,{fullResponse:!0,params:{id:W}});return new f4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y,sharedParams:{id:W}})}async quotes(W,Y={}){let J=await this.get("tweets/:id/quote_tweets",Y,{fullResponse:!0,params:{id:W}});return new H4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:Y,sharedParams:{id:W}})}async bookmarks(W={}){let Y=await this.getCurrentUserV2Object(),J=await this.get("users/:id/bookmarks",W,{fullResponse:!0,params:{id:Y.data.id}});return new R4({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:W,sharedParams:{id:Y.data.id}})}me(W={}){return this.get("users/me",W)}user(W,Y={}){return this.get("users/:id",Y,{params:{id:W}})}users(W,Y={}){let J=Array.isArray(W)?W.join(","):W;return this.get("users",{...Y,ids:J})}userByUsername(W,Y={}){return this.get("users/by/username/:username",Y,{params:{username:W}})}usersByUsernames(W,Y={}){return W=Array.isArray(W)?W.join(","):W,this.get("users/by",{...Y,usernames:W})}async followers(W,Y={}){let{asPaginator:J,...Z}=Y,G={id:W};if(!J)return this.get("users/:id/followers",Z,{params:G});let $=await this.get("users/:id/followers",Z,{fullResponse:!0,params:G});return new I4({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:Z,sharedParams:G})}async following(W,Y={}){let{asPaginator:J,...Z}=Y,G={id:W};if(!J)return this.get("users/:id/following",Z,{params:G});let $=await this.get("users/:id/following",Z,{fullResponse:!0,params:G});return new T4({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:Z,sharedParams:G})}async userLikedTweets(W,Y={}){let J={id:W},Z=await this.get("users/:id/liked_tweets",Y,{fullResponse:!0,params:J});return new _4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:{...Y},sharedParams:J})}async userBlockingUsers(W,Y={}){let J={id:W},Z=await this.get("users/:id/blocking",Y,{fullResponse:!0,params:J});return new v4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:{...Y},sharedParams:J})}async userMutingUsers(W,Y={}){let J={id:W},Z=await this.get("users/:id/muting",Y,{fullResponse:!0,params:J});return new b4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:{...Y},sharedParams:J})}list(W,Y={}){return this.get("lists/:id",Y,{params:{id:W}})}async listsOwned(W,Y={}){let J={id:W},Z=await this.get("users/:id/owned_lists",Y,{fullResponse:!0,params:J});return new A4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:{...Y},sharedParams:J})}async listMemberships(W,Y={}){let J={id:W},Z=await this.get("users/:id/list_memberships",Y,{fullResponse:!0,params:J});return new y4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:{...Y},sharedParams:J})}async listFollowed(W,Y={}){let J={id:W},Z=await this.get("users/:id/followed_lists",Y,{fullResponse:!0,params:J});return new V4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:{...Y},sharedParams:J})}async listTweets(W,Y={}){let J={id:W},Z=await this.get("lists/:id/tweets",Y,{fullResponse:!0,params:J});return new C4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:{...Y},sharedParams:J})}async listMembers(W,Y={}){let J={id:W},Z=await this.get("lists/:id/members",Y,{fullResponse:!0,params:J});return new q4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:{...Y},sharedParams:J})}async listFollowers(W,Y={}){let J={id:W},Z=await this.get("lists/:id/followers",Y,{fullResponse:!0,params:J});return new h4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:{...Y},sharedParams:J})}async listDmEvents(W={}){let Y=await this.get("dm_events",W,{fullResponse:!0});return new g4({realData:Y.data,rateLimit:Y.rateLimit,instance:this,queryParams:{...W}})}async listDmEventsWithParticipant(W,Y={}){let J={participant_id:W},Z=await this.get("dm_conversations/with/:participant_id/dm_events",Y,{fullResponse:!0,params:J});return new c4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:{...Y},sharedParams:J})}async listDmEventsOfConversation(W,Y={}){let J={dm_conversation_id:W},Z=await this.get("dm_conversations/:dm_conversation_id/dm_events",Y,{fullResponse:!0,params:J});return new E4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:{...Y},sharedParams:J})}space(W,Y={}){return this.get("spaces/:id",Y,{params:{id:W}})}spaces(W,Y={}){return this.get("spaces",{ids:W,...Y})}spacesByCreators(W,Y={}){return this.get("spaces/by/creator_ids",{user_ids:W,...Y})}searchSpaces(W){return this.get("spaces/search",W)}spaceBuyers(W,Y={}){return this.get("spaces/:id/buyers",Y,{params:{id:W}})}spaceTweets(W,Y={}){return this.get("spaces/:id/tweets",Y,{params:{id:W}})}searchStream({autoConnect:W,...Y}={}){return this.getStream("tweets/search/stream",Y,{payloadIsError:U1,autoConnect:W})}streamRules(W={}){return this.get("tweets/search/stream/rules",W)}updateStreamRules(W,Y={}){return this.post("tweets/search/stream/rules",W,{query:Y})}sampleStream({autoConnect:W,...Y}={}){return this.getStream("tweets/sample/stream",Y,{payloadIsError:U1,autoConnect:W})}sample10Stream({autoConnect:W,...Y}={}){return this.getStream("tweets/sample10/stream",Y,{payloadIsError:U1,autoConnect:W})}complianceJobs(W){return this.get("compliance/jobs",W)}complianceJob(W){return this.get("compliance/jobs/:id",void 0,{params:{id:W}})}async sendComplianceJob(W){let Y=await this.post("compliance/jobs",{type:W.type,name:W.name}),J=W.ids instanceof Buffer?W.ids:Buffer.from(W.ids.join(`
34
34
  `));return await this.put(Y.data.upload_url,J,{forceBodyMode:"raw",enableAuth:!1,headers:{"Content-Type":"text/plain"},prefix:""}),Y}async complianceJobResult(W){let Y=W;while(Y.status!=="complete"){if(Y.status==="expired"||Y.status==="failed")throw Error("Job failed to be completed.");await new Promise((Z)=>setTimeout(Z,3500)),Y=(await this.complianceJob(W.id)).data}return(await this.get(W.download_url,void 0,{enableAuth:!1,prefix:""})).trim().split(`
35
- `).filter((Z)=>Z).map((Z)=>JSON.parse(Z))}async usage(W={}){return this.get("usage/tweets",W)}community(W,Y={}){return this.get("communities/:id",Y,{params:{id:W}})}searchCommunities(W,Y={}){return this.get("communities/search",{query:W,...Y})}}class r extends a{constructor(){super(...arguments);this._prefix=m}get readOnly(){return this}}class e extends t{constructor(){super(...arguments);this._prefix=I}get readOnly(){return this}get labs(){if(this._labs)return this._labs;return this._labs=new r(this)}hideReply(W,Y){return this.put("tweets/:id/hidden",{hidden:Y},{params:{id:W}})}like(W,Y){return this.post("users/:id/likes",{tweet_id:Y},{params:{id:W}})}unlike(W,Y){return this.delete("users/:id/likes/:tweet_id",void 0,{params:{id:W,tweet_id:Y}})}retweet(W,Y){return this.post("users/:id/retweets",{tweet_id:Y},{params:{id:W}})}unretweet(W,Y){return this.delete("users/:id/retweets/:tweet_id",void 0,{params:{id:W,tweet_id:Y}})}tweet(W,Y={}){if(typeof W==="object")Y=W;else Y={text:W,...Y};return this.post("tweets",Y)}async uploadMedia(W,Y,J=1048576){let Z=Y.media_category;if(!Y.media_category){if(Y.media_type.includes("gif"))Z="tweet_gif";else if(Y.media_type.includes("image"))Z="tweet_image";else if(Y.media_type.includes("video"))Z="tweet_video"}let G={additional_owners:Y.additional_owners,media_type:Y.media_type,total_bytes:W.length,media_category:Z},Q=(await this.post("media/upload/initialize",G)).data.id,K=Math.ceil(W.length/J),z=new Uint8Array(W);for(let x=0;x<K;x++){let M=x*J,R=Math.min(M+J,W.length),v=z.slice(M,R),b=Buffer.from(v),W1={segment_index:x,media:b};await this.post(`media/upload/${Q}/append`,W1,{forceBodyMode:"form-data"})}if((await this.post(`media/upload/${Q}/finalize`)).data.processing_info)await this.waitForMediaProcessing(Q);return Q}async waitForMediaProcessing(W){var Y;let Z=(await this.get("media/upload",{command:"STATUS",media_id:W})).data.processing_info;if(!Z)return;switch(Z.state){case"succeeded":return;case"failed":throw Error(`Media processing failed: ${(Y=Z.error)===null||Y===void 0?void 0:Y.message}`);case"pending":case"in_progress":{let G=Z===null||Z===void 0?void 0:Z.check_after_secs;if(G&&G>0)await new Promise(($)=>setTimeout($,G*1000)),await this.waitForMediaProcessing(W)}}}createMediaMetadata(W,Y){return this.post("media/metadata",{id:W,metadata:Y})}reply(W,Y,J={}){var Z;let G={in_reply_to_tweet_id:Y,...(Z=J.reply)!==null&&Z!==void 0?Z:{}};return this.post("tweets",{text:W,...J,reply:G})}quote(W,Y,J={}){return this.tweet(W,{...J,quote_tweet_id:Y})}async tweetThread(W){var Y,J;let Z=[];for(let G of W){let $=Z.length?Z[Z.length-1]:null,Q={...typeof G==="string"?{text:G}:G},K=$?$.data.id:(Y=Q.reply)===null||Y===void 0?void 0:Y.in_reply_to_tweet_id,z=(J=Q.text)!==null&&J!==void 0?J:"";if(K)Z.push(await this.reply(z,K,Q));else Z.push(await this.tweet(z,Q))}return Z}deleteTweet(W){return this.delete("tweets/:id",void 0,{params:{id:W}})}async bookmark(W){let Y=await this.getCurrentUserV2Object();return this.post("users/:id/bookmarks",{tweet_id:W},{params:{id:Y.data.id}})}async deleteBookmark(W){let Y=await this.getCurrentUserV2Object();return this.delete("users/:id/bookmarks/:tweet_id",void 0,{params:{id:Y.data.id,tweet_id:W}})}follow(W,Y){return this.post("users/:id/following",{target_user_id:Y},{params:{id:W}})}unfollow(W,Y){return this.delete("users/:source_user_id/following/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:Y}})}block(W,Y){return this.post("users/:id/blocking",{target_user_id:Y},{params:{id:W}})}unblock(W,Y){return this.delete("users/:source_user_id/blocking/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:Y}})}mute(W,Y){return this.post("users/:id/muting",{target_user_id:Y},{params:{id:W}})}unmute(W,Y){return this.delete("users/:source_user_id/muting/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:Y}})}createList(W){return this.post("lists",W)}updateList(W,Y={}){return this.put("lists/:id",Y,{params:{id:W}})}removeList(W){return this.delete("lists/:id",void 0,{params:{id:W}})}addListMember(W,Y){return this.post("lists/:id/members",{user_id:Y},{params:{id:W}})}removeListMember(W,Y){return this.delete("lists/:id/members/:user_id",void 0,{params:{id:W,user_id:Y}})}subscribeToList(W,Y){return this.post("users/:id/followed_lists",{list_id:Y},{params:{id:W}})}unsubscribeOfList(W,Y){return this.delete("users/:id/followed_lists/:list_id",void 0,{params:{id:W,list_id:Y}})}pinList(W,Y){return this.post("users/:id/pinned_lists",{list_id:Y},{params:{id:W}})}unpinList(W,Y){return this.delete("users/:id/pinned_lists/:list_id",void 0,{params:{id:W,list_id:Y}})}sendDmInConversation(W,Y){return this.post("dm_conversations/:dm_conversation_id/messages",Y,{params:{dm_conversation_id:W}})}sendDmToParticipant(W,Y){return this.post("dm_conversations/with/:participant_id/messages",Y,{params:{participant_id:W}})}createDmConversation(W){return this.post("dm_conversations",W)}}class U0 extends r{constructor(){super(...arguments);this._prefix=m}get readWrite(){return this}}var S0=U0;class f0 extends e{constructor(){super(...arguments);this._prefix=I}get readWrite(){return this}get labs(){if(this._labs)return this._labs;return this._labs=new S0(this)}}var R0=f0;class j1 extends h{get v1(){if(this._v1)return this._v1;return this._v1=new i(this)}get v2(){if(this._v2)return this._v2;return this._v2=new t(this)}async currentUser(W=!1){return await this.getCurrentUserObject(W)}async currentUserV2(W=!1){return await this.getCurrentUserV2Object(W)}search(W,Y){return this.v2.search(W,Y)}async generateAuthLink(W="oob",{authAccessType:Y,linkMode:J="authenticate",forceLogin:Z,screenName:G}={}){let $=await this.post("https://api.x.com/oauth/request_token",{oauth_callback:W,x_auth_access_type:Y}),Q=`https://api.x.com/oauth/${J}?oauth_token=${encodeURIComponent($.oauth_token)}`;if(Z!==void 0)Q+=`&force_login=${encodeURIComponent(Z)}`;if(G!==void 0)Q+=`&screen_name=${encodeURIComponent(G)}`;if(this._requestMaker.hasPlugins())this._requestMaker.applyPluginMethod("onOAuth1RequestToken",{client:this._requestMaker,url:Q,oauthResult:$});return{url:Q,...$}}async login(W){let Y=this.getActiveTokens();if(Y.type!=="oauth-1.0a")throw Error("You must setup TwitterApi instance with consumer keys to accept OAuth 1.0 login");let J=await this.post("https://api.x.com/oauth/access_token",{oauth_token:Y.accessToken,oauth_verifier:W}),Z=new this.constructor({appKey:Y.appKey,appSecret:Y.appSecret,accessToken:J.oauth_token,accessSecret:J.oauth_token_secret},this._requestMaker.clientSettings);return{accessToken:J.oauth_token,accessSecret:J.oauth_token_secret,userId:J.user_id,screenName:J.screen_name,client:Z}}async appLogin(){let W=this.getActiveTokens();if(W.type!=="oauth-1.0a")throw Error("You must setup TwitterApi instance with consumer keys to accept app-only login");let J=await new this.constructor({username:W.appKey,password:W.appSecret},this._requestMaker.clientSettings).post("https://api.x.com/oauth2/token",{grant_type:"client_credentials"});return new this.constructor(J.access_token,this._requestMaker.clientSettings)}generateOAuth2AuthLink(W,Y={}){var J,Z;if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. You can find your client ID in Twitter Developer Portal. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");let G=(J=Y.state)!==null&&J!==void 0?J:V.generateRandomString(32),$=V.getCodeVerifier(),Q=V.getCodeChallengeFromVerifier($),K=(Z=Y.scope)!==null&&Z!==void 0?Z:"",z=Array.isArray(K)?K.join(" "):K,X=new URL("https://x.com/i/oauth2/authorize"),x={response_type:"code",client_id:this._requestMaker.clientId,redirect_uri:W,state:G,code_challenge:Q,code_challenge_method:"s256",scope:z};O.addQueryParamsToUrl(X,x);let M={url:X.toString(),state:G,codeVerifier:$,codeChallenge:Q};if(this._requestMaker.hasPlugins())this._requestMaker.applyPluginMethod("onOAuth2RequestToken",{client:this._requestMaker,result:M,redirectUri:W});return M}async loginWithOAuth2({code:W,codeVerifier:Y,redirectUri:J}){if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");let Z=await this.post("https://api.x.com/2/oauth2/token",{code:W,code_verifier:Y,redirect_uri:J,grant_type:"authorization_code",client_id:this._requestMaker.clientId,client_secret:this._requestMaker.clientSecret});return this.parseOAuth2AccessTokenResult(Z)}async refreshOAuth2Token(W){if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");let Y=await this.post("https://api.x.com/2/oauth2/token",{refresh_token:W,grant_type:"refresh_token",client_id:this._requestMaker.clientId,client_secret:this._requestMaker.clientSecret});return this.parseOAuth2AccessTokenResult(Y)}async revokeOAuth2Token(W,Y="access_token"){if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");return await this.post("https://api.x.com/2/oauth2/revoke",{client_id:this._requestMaker.clientId,client_secret:this._requestMaker.clientSecret,token:W,token_type_hint:Y})}parseOAuth2AccessTokenResult(W){let Y=new this.constructor(W.access_token,this._requestMaker.clientSettings),J=W.scope.split(" ").filter((Z)=>Z);return{client:Y,expiresIn:W.expires_in,accessToken:W.access_token,scope:J,refreshToken:W.refresh_token}}}class N1 extends j1{get v1(){if(this._v1)return this._v1;return this._v1=new o(this)}get v2(){if(this._v2)return this._v2;return this._v2=new e(this)}get readOnly(){return this}}class q1 extends H{constructor(){super(...arguments);this._prefix=u}}class h1 extends q1{constructor(){super(...arguments);this._prefix=u}get readOnly(){return this}}class P1 extends H{constructor(){super(...arguments);this._prefix=d}}class w1 extends P1{constructor(){super(...arguments);this._prefix=d}get readOnly(){return this}}class k0 extends w1{constructor(){super(...arguments);this._prefix=d}get readWrite(){return this}}var _0=k0;class C0 extends h1{constructor(){super(...arguments);this._prefix=u}get readWrite(){return this}get sandbox(){if(this._sandbox)return this._sandbox;return this._sandbox=new _0(this)}}var v0=C0;class m4 extends N1{get v1(){if(this._v1)return this._v1;return this._v1=new v1(this)}get v2(){if(this._v2)return this._v2;return this._v2=new R0(this)}get readWrite(){return this}get ads(){if(this._ads)return this._ads;return this._ads=new v0(this)}static getErrors(W){var Y;if(typeof W!=="object")return[];if(!("data"in W))return[];return(Y=W.data.errors)!==null&&Y!==void 0?Y:[]}static getProfileImageInSize(W,Y){let J=W.split("/").pop(),Z=["normal","bigger","mini"],G=W;for(let Q of Z)if(J.includes(`_${Q}`)){G=W.replace(`_${Q}`,"");break}if(Y==="original")return G;let $=G.lastIndexOf(".");if($!==-1){let Q=G.slice($+1);return G.slice(0,$)+"_"+Y+"."+Q}else return G+"_"+Y}}var t0={clientId:process.env.X_CLIENT_ID,clientSecret:process.env.X_SECRET,redirectPath:"/auth/oauth/x/callback",scope:["tweet.read","users.read","offline.access"]};class I0 extends E{config;client;oauthStates=new Map;constructor(W={}){super();this.config={...t0,...W},this.client=new m4({clientId:this.config.clientId,clientSecret:this.config.clientSecret})}getRedirectUrl(){let{url:W,codeVerifier:Y,state:J}=this.client.generateOAuth2AuthLink(`${process.env.HOST_NAME}${this.config.redirectPath}`,{scope:this.config.scope});return this.oauthStates.set(J,{state:J,codeVerifier:Y}),b0.to(W),W}async onCallback(W){let Y=W.search.get("code"),J=W.search.get("state"),Z=this.oauthStates.get(J);if(!Z)throw Error("Invalid or expired OAuth state");let G=await this.client.loginWithOAuth2({code:Y,codeVerifier:Z.codeVerifier,redirectUri:`${process.env.HOST_NAME}${this.config.redirectPath}`});this.oauthStates.delete(J);let{data:$}=await G.client.v2.me({"user.fields":["name","username","entities"]}),{name:Q,email:K,id:z="",username:X}=$??{};return{name:Q,email:K,username:X,providerId:z}}}class u4{describe;rollout;when;serverOnly;salt;constructor(W={}){if(W.rollout!==void 0){let{rollout:Y}=W;if(!Number.isFinite(Y)||Y<0||Y>100)throw Error(`A feature's \`rollout\` must be a number between 0 and 100, received ${String(Y)}.`)}this.describe=W.describe,this.rollout=W.rollout,this.when=W.when,this.serverOnly=W.serverOnly??!1,this.salt=W.salt}}function r0(W={}){return new u4(W)}class T0 extends d4{rows=new Map;constructor(W={}){super();for(let[Y,J]of Object.entries(W))this.rows.set(Y,{key:Y,active:J})}async load(){return[...this.rows.values()].map((W)=>({...W}))}async write(W,Y,J){return this.rows.set(W,{key:W,active:Y,updatedBy:J.actor,updatedAt:new Date}),{actorRecorded:!0}}}export{P6 as viewRouteConfigDefaults,NW as translationConfigDefaults,A1 as toRangeHeaderValue,F6 as subjectFor,JW as scheduleConfigDefaults,V1 as resolveRange,VW as redisConfigDefaults,wW as rateLimiterConfigDefaults,n6 as queueConfigDefaults,Y1 as parseContentRange,Z6 as mintSessionToken,W6 as middlewareConfigDefaults,m6 as mailConfigDefaults,CW as logConfigDefaults,J6 as isSessionToken,L6 as inRollout,b6 as imageConfigDefaults,z6 as filesystemConfigDefaults,OW as featuresConfigDefaults,GW as eventConfigDefaults,D6 as evaluateFeature,BW as discoverListeners,KW as discoverJobs,XW as discoverCronJobs,zW as discoverCommands,jW as defineTranslationConfig,YW as defineScheduleConfig,q6 as defineRouteConfig,yW as defineRedisConfig,PW as defineRateLimiterConfig,l6 as defineQueueConfig,e0 as defineMiddlewareConfig,E6 as defineMailConfig,_W as defineLogConfig,v6 as defineImageConfig,X6 as defineFilesystemConfig,FW as defineFeaturesConfig,r0 as defineFeature,ZW as defineEventConfig,t6 as defineCommandConfig,e6 as defineCommand,IW as defineBroadcastConfig,G6 as defineAuthConfig,r6 as commandConfigDefaults,N6 as bucketOf,j6 as bucketKey,TW as broadcastConfigDefaults,$6 as authConfigDefaults,h6 as apiRouteConfigDefaults,I0 as XOAuthProvider,A6 as ViewRouteDispatcher,f6 as UndeclaredFeatureError,T0 as StaticFeatureFlagSource,C6 as Sharp,d6 as Scheduler,LW as ScheduleServiceProvider,Y6 as SESSION_TOKEN_PREFIX,n4 as S3Driver,mW as RouteServiceProvider,c6 as ResendDriver,gW as RedisServiceProvider,t4 as RedisRateLimiter,D1 as RedisManager,AW as RateLimiterServiceProvider,g1 as RateLimiterDriver,M6 as RateLimiter,g as RangeNotSatisfiableError,xW as QueueServiceProvider,o6 as QueueManager,E as OAuthProvider,bW as MiddlewareServiceProvider,T6 as MiddlewareRegistry,i6 as MemoryQueueDriver,cW as McpToolError,EW as McpRegistry,UW as MailServiceProvider,u6 as MailManager,vW as LogServiceProvider,x6 as LogManager,$W as Listener,kW as KernelIdServiceProvider,w6 as KernelId,QW as Job,hW as InMemoryRateLimiter,RW as ImageServiceProvider,_6 as ImageOptimizationDriver,I6 as ImageManager,W0 as GoogleOAuthProvider,fW as FilesystemServiceProvider,B6 as FilesystemManager,K6 as FileSystemDriver,J1 as FileStorageDriver,w as FileNotFoundError,HW as FeaturesServiceProvider,S6 as FeatureSourceReadOnlyError,R6 as FeatureScope,O6 as FeatureReloadError,U6 as FeatureModelMissingError,k6 as FeatureManager,H6 as FeatureFlagStore,d4 as FeatureFlagSource,u4 as Feature,SW as EventServiceProvider,U as EventManager,e4 as Event,g6 as EmailDriver,p6 as DatabaseQueueDriver,DW as DatabaseFeatureFlagSource,WW as CronJob,uW as CommandRegistry,s6 as CommandFailed,a6 as Command,qW as BroadcastServiceProvider,Q6 as BroadcastManager,o4 as AzureBlobDriver,MW as AuthServiceProvider,V6 as AuthManager,y6 as ApiRouteDispatcher};
35
+ `).filter((Z)=>Z).map((Z)=>JSON.parse(Z))}async usage(W={}){return this.get("usage/tweets",W)}community(W,Y={}){return this.get("communities/:id",Y,{params:{id:W}})}searchCommunities(W,Y={}){return this.get("communities/search",{query:W,...Y})}}class r extends a{constructor(){super(...arguments);this._prefix=m}get readOnly(){return this}}class e extends t{constructor(){super(...arguments);this._prefix=I}get readOnly(){return this}get labs(){if(this._labs)return this._labs;return this._labs=new r(this)}hideReply(W,Y){return this.put("tweets/:id/hidden",{hidden:Y},{params:{id:W}})}like(W,Y){return this.post("users/:id/likes",{tweet_id:Y},{params:{id:W}})}unlike(W,Y){return this.delete("users/:id/likes/:tweet_id",void 0,{params:{id:W,tweet_id:Y}})}retweet(W,Y){return this.post("users/:id/retweets",{tweet_id:Y},{params:{id:W}})}unretweet(W,Y){return this.delete("users/:id/retweets/:tweet_id",void 0,{params:{id:W,tweet_id:Y}})}tweet(W,Y={}){if(typeof W==="object")Y=W;else Y={text:W,...Y};return this.post("tweets",Y)}async uploadMedia(W,Y,J=1048576){let Z=Y.media_category;if(!Y.media_category){if(Y.media_type.includes("gif"))Z="tweet_gif";else if(Y.media_type.includes("image"))Z="tweet_image";else if(Y.media_type.includes("video"))Z="tweet_video"}let G={additional_owners:Y.additional_owners,media_type:Y.media_type,total_bytes:W.length,media_category:Z},Q=(await this.post("media/upload/initialize",G)).data.id,K=Math.ceil(W.length/J),z=new Uint8Array(W);for(let x=0;x<K;x++){let M=x*J,R=Math.min(M+J,W.length),v=z.slice(M,R),b=Buffer.from(v),W1={segment_index:x,media:b};await this.post(`media/upload/${Q}/append`,W1,{forceBodyMode:"form-data"})}if((await this.post(`media/upload/${Q}/finalize`)).data.processing_info)await this.waitForMediaProcessing(Q);return Q}async waitForMediaProcessing(W){var Y;let Z=(await this.get("media/upload",{command:"STATUS",media_id:W})).data.processing_info;if(!Z)return;switch(Z.state){case"succeeded":return;case"failed":throw Error(`Media processing failed: ${(Y=Z.error)===null||Y===void 0?void 0:Y.message}`);case"pending":case"in_progress":{let G=Z===null||Z===void 0?void 0:Z.check_after_secs;if(G&&G>0)await new Promise(($)=>setTimeout($,G*1000)),await this.waitForMediaProcessing(W)}}}createMediaMetadata(W,Y){return this.post("media/metadata",{id:W,metadata:Y})}reply(W,Y,J={}){var Z;let G={in_reply_to_tweet_id:Y,...(Z=J.reply)!==null&&Z!==void 0?Z:{}};return this.post("tweets",{text:W,...J,reply:G})}quote(W,Y,J={}){return this.tweet(W,{...J,quote_tweet_id:Y})}async tweetThread(W){var Y,J;let Z=[];for(let G of W){let $=Z.length?Z[Z.length-1]:null,Q={...typeof G==="string"?{text:G}:G},K=$?$.data.id:(Y=Q.reply)===null||Y===void 0?void 0:Y.in_reply_to_tweet_id,z=(J=Q.text)!==null&&J!==void 0?J:"";if(K)Z.push(await this.reply(z,K,Q));else Z.push(await this.tweet(z,Q))}return Z}deleteTweet(W){return this.delete("tweets/:id",void 0,{params:{id:W}})}async bookmark(W){let Y=await this.getCurrentUserV2Object();return this.post("users/:id/bookmarks",{tweet_id:W},{params:{id:Y.data.id}})}async deleteBookmark(W){let Y=await this.getCurrentUserV2Object();return this.delete("users/:id/bookmarks/:tweet_id",void 0,{params:{id:Y.data.id,tweet_id:W}})}follow(W,Y){return this.post("users/:id/following",{target_user_id:Y},{params:{id:W}})}unfollow(W,Y){return this.delete("users/:source_user_id/following/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:Y}})}block(W,Y){return this.post("users/:id/blocking",{target_user_id:Y},{params:{id:W}})}unblock(W,Y){return this.delete("users/:source_user_id/blocking/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:Y}})}mute(W,Y){return this.post("users/:id/muting",{target_user_id:Y},{params:{id:W}})}unmute(W,Y){return this.delete("users/:source_user_id/muting/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:Y}})}createList(W){return this.post("lists",W)}updateList(W,Y={}){return this.put("lists/:id",Y,{params:{id:W}})}removeList(W){return this.delete("lists/:id",void 0,{params:{id:W}})}addListMember(W,Y){return this.post("lists/:id/members",{user_id:Y},{params:{id:W}})}removeListMember(W,Y){return this.delete("lists/:id/members/:user_id",void 0,{params:{id:W,user_id:Y}})}subscribeToList(W,Y){return this.post("users/:id/followed_lists",{list_id:Y},{params:{id:W}})}unsubscribeOfList(W,Y){return this.delete("users/:id/followed_lists/:list_id",void 0,{params:{id:W,list_id:Y}})}pinList(W,Y){return this.post("users/:id/pinned_lists",{list_id:Y},{params:{id:W}})}unpinList(W,Y){return this.delete("users/:id/pinned_lists/:list_id",void 0,{params:{id:W,list_id:Y}})}sendDmInConversation(W,Y){return this.post("dm_conversations/:dm_conversation_id/messages",Y,{params:{dm_conversation_id:W}})}sendDmToParticipant(W,Y){return this.post("dm_conversations/with/:participant_id/messages",Y,{params:{participant_id:W}})}createDmConversation(W){return this.post("dm_conversations",W)}}class U0 extends r{constructor(){super(...arguments);this._prefix=m}get readWrite(){return this}}var S0=U0;class f0 extends e{constructor(){super(...arguments);this._prefix=I}get readWrite(){return this}get labs(){if(this._labs)return this._labs;return this._labs=new S0(this)}}var R0=f0;class j1 extends h{get v1(){if(this._v1)return this._v1;return this._v1=new i(this)}get v2(){if(this._v2)return this._v2;return this._v2=new t(this)}async currentUser(W=!1){return await this.getCurrentUserObject(W)}async currentUserV2(W=!1){return await this.getCurrentUserV2Object(W)}search(W,Y){return this.v2.search(W,Y)}async generateAuthLink(W="oob",{authAccessType:Y,linkMode:J="authenticate",forceLogin:Z,screenName:G}={}){let $=await this.post("https://api.x.com/oauth/request_token",{oauth_callback:W,x_auth_access_type:Y}),Q=`https://api.x.com/oauth/${J}?oauth_token=${encodeURIComponent($.oauth_token)}`;if(Z!==void 0)Q+=`&force_login=${encodeURIComponent(Z)}`;if(G!==void 0)Q+=`&screen_name=${encodeURIComponent(G)}`;if(this._requestMaker.hasPlugins())this._requestMaker.applyPluginMethod("onOAuth1RequestToken",{client:this._requestMaker,url:Q,oauthResult:$});return{url:Q,...$}}async login(W){let Y=this.getActiveTokens();if(Y.type!=="oauth-1.0a")throw Error("You must setup TwitterApi instance with consumer keys to accept OAuth 1.0 login");let J=await this.post("https://api.x.com/oauth/access_token",{oauth_token:Y.accessToken,oauth_verifier:W}),Z=new this.constructor({appKey:Y.appKey,appSecret:Y.appSecret,accessToken:J.oauth_token,accessSecret:J.oauth_token_secret},this._requestMaker.clientSettings);return{accessToken:J.oauth_token,accessSecret:J.oauth_token_secret,userId:J.user_id,screenName:J.screen_name,client:Z}}async appLogin(){let W=this.getActiveTokens();if(W.type!=="oauth-1.0a")throw Error("You must setup TwitterApi instance with consumer keys to accept app-only login");let J=await new this.constructor({username:W.appKey,password:W.appSecret},this._requestMaker.clientSettings).post("https://api.x.com/oauth2/token",{grant_type:"client_credentials"});return new this.constructor(J.access_token,this._requestMaker.clientSettings)}generateOAuth2AuthLink(W,Y={}){var J,Z;if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. You can find your client ID in Twitter Developer Portal. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");let G=(J=Y.state)!==null&&J!==void 0?J:V.generateRandomString(32),$=V.getCodeVerifier(),Q=V.getCodeChallengeFromVerifier($),K=(Z=Y.scope)!==null&&Z!==void 0?Z:"",z=Array.isArray(K)?K.join(" "):K,X=new URL("https://x.com/i/oauth2/authorize"),x={response_type:"code",client_id:this._requestMaker.clientId,redirect_uri:W,state:G,code_challenge:Q,code_challenge_method:"s256",scope:z};O.addQueryParamsToUrl(X,x);let M={url:X.toString(),state:G,codeVerifier:$,codeChallenge:Q};if(this._requestMaker.hasPlugins())this._requestMaker.applyPluginMethod("onOAuth2RequestToken",{client:this._requestMaker,result:M,redirectUri:W});return M}async loginWithOAuth2({code:W,codeVerifier:Y,redirectUri:J}){if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");let Z=await this.post("https://api.x.com/2/oauth2/token",{code:W,code_verifier:Y,redirect_uri:J,grant_type:"authorization_code",client_id:this._requestMaker.clientId,client_secret:this._requestMaker.clientSecret});return this.parseOAuth2AccessTokenResult(Z)}async refreshOAuth2Token(W){if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");let Y=await this.post("https://api.x.com/2/oauth2/token",{refresh_token:W,grant_type:"refresh_token",client_id:this._requestMaker.clientId,client_secret:this._requestMaker.clientSecret});return this.parseOAuth2AccessTokenResult(Y)}async revokeOAuth2Token(W,Y="access_token"){if(!this._requestMaker.clientId)throw Error("Twitter API instance is not initialized with client ID. Please build an instance with: new TwitterApi({ clientId: '<yourClientId>' })");return await this.post("https://api.x.com/2/oauth2/revoke",{client_id:this._requestMaker.clientId,client_secret:this._requestMaker.clientSecret,token:W,token_type_hint:Y})}parseOAuth2AccessTokenResult(W){let Y=new this.constructor(W.access_token,this._requestMaker.clientSettings),J=W.scope.split(" ").filter((Z)=>Z);return{client:Y,expiresIn:W.expires_in,accessToken:W.access_token,scope:J,refreshToken:W.refresh_token}}}class N1 extends j1{get v1(){if(this._v1)return this._v1;return this._v1=new o(this)}get v2(){if(this._v2)return this._v2;return this._v2=new e(this)}get readOnly(){return this}}class q1 extends H{constructor(){super(...arguments);this._prefix=u}}class h1 extends q1{constructor(){super(...arguments);this._prefix=u}get readOnly(){return this}}class P1 extends H{constructor(){super(...arguments);this._prefix=d}}class w1 extends P1{constructor(){super(...arguments);this._prefix=d}get readOnly(){return this}}class k0 extends w1{constructor(){super(...arguments);this._prefix=d}get readWrite(){return this}}var _0=k0;class C0 extends h1{constructor(){super(...arguments);this._prefix=u}get readWrite(){return this}get sandbox(){if(this._sandbox)return this._sandbox;return this._sandbox=new _0(this)}}var v0=C0;class m4 extends N1{get v1(){if(this._v1)return this._v1;return this._v1=new v1(this)}get v2(){if(this._v2)return this._v2;return this._v2=new R0(this)}get readWrite(){return this}get ads(){if(this._ads)return this._ads;return this._ads=new v0(this)}static getErrors(W){var Y;if(typeof W!=="object")return[];if(!("data"in W))return[];return(Y=W.data.errors)!==null&&Y!==void 0?Y:[]}static getProfileImageInSize(W,Y){let J=W.split("/").pop(),Z=["normal","bigger","mini"],G=W;for(let Q of Z)if(J.includes(`_${Q}`)){G=W.replace(`_${Q}`,"");break}if(Y==="original")return G;let $=G.lastIndexOf(".");if($!==-1){let Q=G.slice($+1);return G.slice(0,$)+"_"+Y+"."+Q}else return G+"_"+Y}}var t0={clientId:process.env.X_CLIENT_ID,clientSecret:process.env.X_SECRET,redirectPath:"/auth/oauth/x/callback",scope:["tweet.read","users.read","offline.access"]};class I0 extends E{config;client;oauthStates=new Map;constructor(W={}){super();this.config={...t0,...W},this.client=new m4({clientId:this.config.clientId,clientSecret:this.config.clientSecret})}getRedirectUrl(){let{url:W,codeVerifier:Y,state:J}=this.client.generateOAuth2AuthLink(`${process.env.HOST_NAME}${this.config.redirectPath}`,{scope:this.config.scope});return this.oauthStates.set(J,{state:J,codeVerifier:Y}),b0.to(W),W}async onCallback(W){let Y=W.search.get("code"),J=W.search.get("state"),Z=this.oauthStates.get(J);if(!Z)throw Error("Invalid or expired OAuth state");let G=await this.client.loginWithOAuth2({code:Y,codeVerifier:Z.codeVerifier,redirectUri:`${process.env.HOST_NAME}${this.config.redirectPath}`});this.oauthStates.delete(J);let{data:$}=await G.client.v2.me({"user.fields":["name","username","entities"]}),{name:Q,email:K,id:z="",username:X}=$??{};return{name:Q,email:K,username:X,providerId:z}}}class u4{describe;rollout;when;serverOnly;salt;constructor(W={}){if(W.rollout!==void 0){let{rollout:Y}=W;if(!Number.isFinite(Y)||Y<0||Y>100)throw Error(`A feature's \`rollout\` must be a number between 0 and 100, received ${String(Y)}.`)}this.describe=W.describe,this.rollout=W.rollout,this.when=W.when,this.serverOnly=W.serverOnly??!1,this.salt=W.salt}}function r0(W={}){return new u4(W)}class T0 extends d4{rows=new Map;constructor(W={}){super();for(let[Y,J]of Object.entries(W))this.rows.set(Y,{key:Y,active:J})}async load(){return[...this.rows.values()].map((W)=>({...W}))}async write(W,Y,J){return this.rows.set(W,{key:W,active:Y,updatedBy:J.actor,updatedAt:new Date}),{actorRecorded:!0}}}export{h6 as viewRouteConfigDefaults,jW as translationConfigDefaults,A1 as toRangeHeaderValue,D6 as subjectFor,YW as scheduleConfigDefaults,V1 as resolveRange,PW as redisConfigDefaults,TW as rateLimiterConfigDefaults,l6 as queueConfigDefaults,Y1 as parseContentRange,Z6 as mintSessionToken,W6 as middlewareConfigDefaults,E6 as mailConfigDefaults,_W as logConfigDefaults,J6 as isSessionToken,N6 as inRollout,v6 as imageConfigDefaults,X6 as filesystemConfigDefaults,FW as featuresConfigDefaults,ZW as eventConfigDefaults,L6 as evaluateFeature,zW as discoverListeners,QW as discoverJobs,KW as discoverCronJobs,XW as discoverCommands,MW as defineTranslationConfig,WW as defineScheduleConfig,T6 as defineRouteConfig,hW as defineRedisConfig,IW as defineRateLimiterConfig,p6 as defineQueueConfig,e0 as defineMiddlewareConfig,c6 as defineMailConfig,kW as defineLogConfig,C6 as defineImageConfig,K6 as defineFilesystemConfig,DW as defineFeaturesConfig,r0 as defineFeature,JW as defineEventConfig,a6 as defineCommandConfig,r6 as defineCommand,G6 as defineAuthConfig,t6 as commandConfigDefaults,j6 as bucketOf,M6 as bucketKey,$6 as authConfigDefaults,q6 as apiRouteConfigDefaults,I0 as XOAuthProvider,w6 as ViewRouteDispatcher,S6 as UndeclaredFeatureError,T0 as StaticFeatureFlagSource,_6 as Sharp,u6 as Scheduler,NW as ScheduleServiceProvider,Y6 as SESSION_TOKEN_PREFIX,n4 as S3Driver,VW as RouteServiceProvider,g6 as ResendDriver,wW as RedisServiceProvider,t4 as RedisRateLimiter,D1 as RedisManager,qW as RateLimiterServiceProvider,g1 as RateLimiterDriver,x6 as RateLimiter,g as RangeNotSatisfiableError,BW as QueueServiceProvider,i6 as QueueManager,E as OAuthProvider,vW as MiddlewareServiceProvider,I6 as MiddlewareRegistry,n6 as MemoryQueueDriver,AW as McpToolError,yW as McpRegistry,HW as MailServiceProvider,m6 as MailManager,CW as LogServiceProvider,B6 as LogManager,GW as Listener,RW as KernelIdServiceProvider,P6 as KernelId,$W as Job,bW as InMemoryRateLimiter,fW as ImageServiceProvider,k6 as ImageOptimizationDriver,b6 as ImageManager,W0 as GoogleOAuthProvider,SW as FilesystemServiceProvider,z6 as FilesystemManager,Q6 as FileSystemDriver,J1 as FileStorageDriver,w as FileNotFoundError,OW as FeaturesServiceProvider,U6 as FeatureSourceReadOnlyError,f6 as FeatureScope,F6 as FeatureReloadError,H6 as FeatureModelMissingError,R6 as FeatureManager,O6 as FeatureFlagStore,d4 as FeatureFlagSource,u4 as Feature,UW as EventServiceProvider,U as EventManager,e4 as Event,V6 as EmailDriver,d6 as DatabaseQueueDriver,LW as DatabaseFeatureFlagSource,e6 as CronJob,gW as CommandRegistry,o6 as CommandFailed,s6 as Command,o4 as AzureBlobDriver,xW as AuthServiceProvider,y6 as AuthManager,A6 as ApiRouteDispatcher};
36
36
 
37
- //# debugId=E28F3554ED77005B64756E2164756E21
37
+ //# debugId=A88670D68D90E18564756E2164756E21