gemi 0.119.2 → 0.120.1

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 (234) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/app/index.js +2 -2
  4. package/dist/app/index.js.map +1 -1
  5. package/dist/bin/gemi.js +32 -5
  6. package/dist/bin/gemi.js.map +6 -5
  7. package/dist/bun/plugin.js +1 -1
  8. package/dist/bun/preload.js +1 -1
  9. package/dist/{chunk-x5m12vkw.js → chunk-0ejjgzwc.js} +2 -2
  10. package/dist/{chunk-x5m12vkw.js.map → chunk-0ejjgzwc.js.map} +1 -1
  11. package/dist/{chunk-7rffbkmg.js → chunk-0k02tza1.js} +1 -1
  12. package/dist/{chunk-14xk8kq0.js → chunk-0yj0s1pn.js} +2 -2
  13. package/dist/{chunk-14xk8kq0.js.map → chunk-0yj0s1pn.js.map} +1 -1
  14. package/dist/{chunk-6pqbsc5y.js → chunk-19dpzp4y.js} +3 -3
  15. package/dist/{chunk-6pqbsc5y.js.map → chunk-19dpzp4y.js.map} +1 -1
  16. package/dist/{chunk-3vt172y7.js → chunk-1wnnkde0.js} +3 -3
  17. package/dist/{chunk-3vt172y7.js.map → chunk-1wnnkde0.js.map} +1 -1
  18. package/dist/{chunk-ct1vwaw7.js → chunk-1xdrs2hx.js} +3 -3
  19. package/dist/{chunk-ct1vwaw7.js.map → chunk-1xdrs2hx.js.map} +1 -1
  20. package/dist/{chunk-79rtpahn.js → chunk-2c0s0561.js} +2 -2
  21. package/dist/{chunk-79rtpahn.js.map → chunk-2c0s0561.js.map} +1 -1
  22. package/dist/{chunk-nfq127pg.js → chunk-2n3pgfnb.js} +2 -2
  23. package/dist/{chunk-nfq127pg.js.map → chunk-2n3pgfnb.js.map} +1 -1
  24. package/dist/{chunk-s2h85rbf.js → chunk-32n8t8x6.js} +2 -2
  25. package/dist/{chunk-s2h85rbf.js.map → chunk-32n8t8x6.js.map} +1 -1
  26. package/dist/{chunk-6gfsjgra.js → chunk-3gsv1vv1.js} +2 -2
  27. package/dist/{chunk-6gfsjgra.js.map → chunk-3gsv1vv1.js.map} +1 -1
  28. package/dist/{chunk-862jeyz0.js → chunk-3wnghdsx.js} +2 -2
  29. package/dist/{chunk-862jeyz0.js.map → chunk-3wnghdsx.js.map} +1 -1
  30. package/dist/{chunk-yn4x9wxc.js → chunk-471htqmz.js} +2 -2
  31. package/dist/{chunk-yn4x9wxc.js.map → chunk-471htqmz.js.map} +1 -1
  32. package/dist/{chunk-w1zqg54r.js → chunk-48gmyaxc.js} +2 -2
  33. package/dist/{chunk-w1zqg54r.js.map → chunk-48gmyaxc.js.map} +1 -1
  34. package/dist/{chunk-299zx9dv.js → chunk-4acpw92g.js} +3 -3
  35. package/dist/{chunk-299zx9dv.js.map → chunk-4acpw92g.js.map} +1 -1
  36. package/dist/{chunk-9c5s06gc.js → chunk-4fx8p02c.js} +2 -2
  37. package/dist/{chunk-9c5s06gc.js.map → chunk-4fx8p02c.js.map} +1 -1
  38. package/dist/{chunk-xpz1bp50.js → chunk-51w5ktv2.js} +3 -3
  39. package/dist/{chunk-xpz1bp50.js.map → chunk-51w5ktv2.js.map} +1 -1
  40. package/dist/{chunk-9qkjkse0.js → chunk-5nj94s66.js} +4 -4
  41. package/dist/{chunk-9qkjkse0.js.map → chunk-5nj94s66.js.map} +1 -1
  42. package/dist/{chunk-j632p533.js → chunk-5tdxbwzg.js} +3 -3
  43. package/dist/{chunk-j632p533.js.map → chunk-5tdxbwzg.js.map} +1 -1
  44. package/dist/{chunk-zq1bhsdg.js → chunk-65beps2q.js} +3 -3
  45. package/dist/{chunk-zq1bhsdg.js.map → chunk-65beps2q.js.map} +1 -1
  46. package/dist/{chunk-xeh1mw1d.js → chunk-6yhpprzs.js} +3 -3
  47. package/dist/{chunk-xeh1mw1d.js.map → chunk-6yhpprzs.js.map} +1 -1
  48. package/dist/{chunk-620yeafr.js → chunk-7ftj43vp.js} +2 -2
  49. package/dist/{chunk-620yeafr.js.map → chunk-7ftj43vp.js.map} +1 -1
  50. package/dist/{chunk-4kj4e22e.js → chunk-7g649j8h.js} +2 -2
  51. package/dist/{chunk-4kj4e22e.js.map → chunk-7g649j8h.js.map} +1 -1
  52. package/dist/{chunk-675kzd7z.js → chunk-7mmw0jr2.js} +2 -2
  53. package/dist/{chunk-675kzd7z.js.map → chunk-7mmw0jr2.js.map} +1 -1
  54. package/dist/{chunk-k1ncgq7p.js → chunk-9d2d08qm.js} +2 -2
  55. package/dist/{chunk-k1ncgq7p.js.map → chunk-9d2d08qm.js.map} +1 -1
  56. package/dist/{chunk-wdg83tgd.js → chunk-9rr5h818.js} +3 -3
  57. package/dist/{chunk-wdg83tgd.js.map → chunk-9rr5h818.js.map} +1 -1
  58. package/dist/{chunk-30xxc6r7.js → chunk-9xyxbxgk.js} +2 -2
  59. package/dist/{chunk-30xxc6r7.js.map → chunk-9xyxbxgk.js.map} +1 -1
  60. package/dist/{chunk-khd9ft0s.js → chunk-ar4d3vmr.js} +3 -3
  61. package/dist/{chunk-khd9ft0s.js.map → chunk-ar4d3vmr.js.map} +1 -1
  62. package/dist/chunk-b5a5vvkk.js +57 -0
  63. package/dist/{chunk-bz5gda3b.js.map → chunk-b5a5vvkk.js.map} +7 -6
  64. package/dist/{chunk-6ggmk2eg.js → chunk-c0v61fp5.js} +2 -2
  65. package/dist/{chunk-6ggmk2eg.js.map → chunk-c0v61fp5.js.map} +1 -1
  66. package/dist/{chunk-bw2pfaz3.js → chunk-c7qs1xp3.js} +2 -2
  67. package/dist/{chunk-bw2pfaz3.js.map → chunk-c7qs1xp3.js.map} +1 -1
  68. package/dist/{chunk-2kegxt0s.js → chunk-cca0grq3.js} +2 -2
  69. package/dist/{chunk-2kegxt0s.js.map → chunk-cca0grq3.js.map} +1 -1
  70. package/dist/{chunk-b336h3hj.js → chunk-cskqet01.js} +2 -2
  71. package/dist/{chunk-b336h3hj.js.map → chunk-cskqet01.js.map} +1 -1
  72. package/dist/{chunk-pzk2a5sr.js → chunk-cvr5624r.js} +1 -1
  73. package/dist/chunk-cytq2msw.js +24 -0
  74. package/dist/{chunk-w8d37mcq.js.map → chunk-cytq2msw.js.map} +3 -3
  75. package/dist/{chunk-8507ez1g.js → chunk-d2c3947c.js} +2 -2
  76. package/dist/{chunk-8507ez1g.js.map → chunk-d2c3947c.js.map} +1 -1
  77. package/dist/{chunk-q0djcyj2.js → chunk-d5f1m3d2.js} +2 -2
  78. package/dist/{chunk-q0djcyj2.js.map → chunk-d5f1m3d2.js.map} +1 -1
  79. package/dist/{chunk-f9tfpn3w.js → chunk-dedqr5wb.js} +2 -2
  80. package/dist/{chunk-f9tfpn3w.js.map → chunk-dedqr5wb.js.map} +1 -1
  81. package/dist/{chunk-h02kyxgg.js → chunk-dhbgrv58.js} +1 -1
  82. package/dist/{chunk-d4dd7jde.js → chunk-dwedx1jb.js} +3 -3
  83. package/dist/{chunk-d4dd7jde.js.map → chunk-dwedx1jb.js.map} +1 -1
  84. package/dist/{chunk-5crtgt1y.js → chunk-ep0baa9g.js} +2 -2
  85. package/dist/{chunk-5crtgt1y.js.map → chunk-ep0baa9g.js.map} +1 -1
  86. package/dist/{chunk-kk77x2v4.js → chunk-er8acmch.js} +7 -7
  87. package/dist/{chunk-kk77x2v4.js.map → chunk-er8acmch.js.map} +3 -3
  88. package/dist/{chunk-thz75w6e.js → chunk-fcqx2t0p.js} +2 -2
  89. package/dist/{chunk-thz75w6e.js.map → chunk-fcqx2t0p.js.map} +1 -1
  90. package/dist/{chunk-1p87gdd2.js → chunk-fenc5tpv.js} +2 -2
  91. package/dist/{chunk-1p87gdd2.js.map → chunk-fenc5tpv.js.map} +1 -1
  92. package/dist/{chunk-fmea4sak.js → chunk-gc2dz11k.js} +2 -2
  93. package/dist/{chunk-fmea4sak.js.map → chunk-gc2dz11k.js.map} +1 -1
  94. package/dist/{chunk-qxxbp3nn.js → chunk-gemzbw7f.js} +2 -2
  95. package/dist/{chunk-qxxbp3nn.js.map → chunk-gemzbw7f.js.map} +1 -1
  96. package/dist/{chunk-qpy25jj9.js → chunk-gy81nd9a.js} +2 -2
  97. package/dist/{chunk-qpy25jj9.js.map → chunk-gy81nd9a.js.map} +1 -1
  98. package/dist/{chunk-c8vttyem.js → chunk-h43jp8ws.js} +2 -2
  99. package/dist/{chunk-c8vttyem.js.map → chunk-h43jp8ws.js.map} +1 -1
  100. package/dist/chunk-htgmy3x7.js +5 -0
  101. package/dist/{chunk-15v719sq.js.map → chunk-htgmy3x7.js.map} +1 -1
  102. package/dist/{chunk-xqd3zde5.js → chunk-jaa6xkeh.js} +2 -2
  103. package/dist/{chunk-xqd3zde5.js.map → chunk-jaa6xkeh.js.map} +1 -1
  104. package/dist/{chunk-2bja99cq.js → chunk-kk18xqgc.js} +2 -2
  105. package/dist/{chunk-2bja99cq.js.map → chunk-kk18xqgc.js.map} +1 -1
  106. package/dist/{chunk-mcjbck8e.js → chunk-krk7mcgm.js} +3 -3
  107. package/dist/{chunk-mcjbck8e.js.map → chunk-krk7mcgm.js.map} +1 -1
  108. package/dist/{chunk-hd5ztshp.js → chunk-krtybgz1.js} +2 -2
  109. package/dist/{chunk-hd5ztshp.js.map → chunk-krtybgz1.js.map} +1 -1
  110. package/dist/{chunk-fjhnn3de.js → chunk-m53fgf20.js} +3 -3
  111. package/dist/{chunk-fjhnn3de.js.map → chunk-m53fgf20.js.map} +1 -1
  112. package/dist/{chunk-4c1npv8k.js → chunk-m83zm86m.js} +2 -2
  113. package/dist/{chunk-4c1npv8k.js.map → chunk-m83zm86m.js.map} +1 -1
  114. package/dist/{chunk-q6a30w8w.js → chunk-meg8rtr6.js} +2 -2
  115. package/dist/{chunk-q6a30w8w.js.map → chunk-meg8rtr6.js.map} +1 -1
  116. package/dist/{chunk-vy0tnx2s.js → chunk-mr94nfp1.js} +3 -3
  117. package/dist/{chunk-vy0tnx2s.js.map → chunk-mr94nfp1.js.map} +1 -1
  118. package/dist/{chunk-zb8zzf5x.js → chunk-nz8z8jr1.js} +3 -3
  119. package/dist/{chunk-zb8zzf5x.js.map → chunk-nz8z8jr1.js.map} +1 -1
  120. package/dist/{chunk-d38x71xy.js → chunk-pemhmjzp.js} +3 -3
  121. package/dist/{chunk-d38x71xy.js.map → chunk-pemhmjzp.js.map} +1 -1
  122. package/dist/{chunk-d2v78b77.js → chunk-pn2x59ge.js} +3 -3
  123. package/dist/{chunk-d2v78b77.js.map → chunk-pn2x59ge.js.map} +1 -1
  124. package/dist/{chunk-qm6j85fq.js → chunk-qphjhpad.js} +2 -2
  125. package/dist/{chunk-qm6j85fq.js.map → chunk-qphjhpad.js.map} +1 -1
  126. package/dist/{chunk-p5xy9cn8.js → chunk-qsz9241c.js} +2 -2
  127. package/dist/{chunk-p5xy9cn8.js.map → chunk-qsz9241c.js.map} +1 -1
  128. package/dist/{chunk-d6nhcqvt.js → chunk-qy8c0gzr.js} +2 -2
  129. package/dist/{chunk-d6nhcqvt.js.map → chunk-qy8c0gzr.js.map} +1 -1
  130. package/dist/{chunk-7ns5506p.js → chunk-r01aqf0q.js} +2 -2
  131. package/dist/{chunk-7ns5506p.js.map → chunk-r01aqf0q.js.map} +1 -1
  132. package/dist/{chunk-0p6mdba6.js → chunk-rhvc1axc.js} +2 -2
  133. package/dist/{chunk-0p6mdba6.js.map → chunk-rhvc1axc.js.map} +1 -1
  134. package/dist/{chunk-pjz79c2c.js → chunk-s07v65x6.js} +3 -3
  135. package/dist/{chunk-pjz79c2c.js.map → chunk-s07v65x6.js.map} +1 -1
  136. package/dist/{chunk-q00f25na.js → chunk-s5k3yq6t.js} +2 -2
  137. package/dist/{chunk-q00f25na.js.map → chunk-s5k3yq6t.js.map} +1 -1
  138. package/dist/{chunk-ty8gxbgj.js → chunk-s6vvqsd0.js} +3 -3
  139. package/dist/{chunk-ty8gxbgj.js.map → chunk-s6vvqsd0.js.map} +3 -3
  140. package/dist/{chunk-2854taf5.js → chunk-sx340k85.js} +2 -2
  141. package/dist/{chunk-2854taf5.js.map → chunk-sx340k85.js.map} +1 -1
  142. package/dist/{chunk-j5q5ysng.js → chunk-tewhms9w.js} +2 -2
  143. package/dist/{chunk-j5q5ysng.js.map → chunk-tewhms9w.js.map} +1 -1
  144. package/dist/{chunk-7pxdvvrz.js → chunk-tk135gmj.js} +3 -3
  145. package/dist/{chunk-7pxdvvrz.js.map → chunk-tk135gmj.js.map} +1 -1
  146. package/dist/{chunk-yvd4pgd9.js → chunk-vx7hvyvq.js} +2 -2
  147. package/dist/{chunk-yvd4pgd9.js.map → chunk-vx7hvyvq.js.map} +1 -1
  148. package/dist/{chunk-xecnc8zv.js → chunk-wjkh2gem.js} +1 -1
  149. package/dist/{chunk-511zqetr.js → chunk-wqe47c0j.js} +2 -2
  150. package/dist/{chunk-511zqetr.js.map → chunk-wqe47c0j.js.map} +1 -1
  151. package/dist/{chunk-2y0r4b7g.js → chunk-y6wt5b6t.js} +1 -1
  152. package/dist/{chunk-kkx8a35r.js → chunk-yds7zwc3.js} +2 -2
  153. package/dist/{chunk-kkx8a35r.js.map → chunk-yds7zwc3.js.map} +1 -1
  154. package/dist/{chunk-w7am9q0q.js → chunk-zefs2b6h.js} +2 -2
  155. package/dist/{chunk-w7am9q0q.js.map → chunk-zefs2b6h.js.map} +1 -1
  156. package/dist/{chunk-de4t48j9.js → chunk-zg6hmc48.js} +1 -1
  157. package/dist/{chunk-svn6zvzd.js → chunk-zrcd9hxr.js} +2 -2
  158. package/dist/{chunk-svn6zvzd.js.map → chunk-zrcd9hxr.js.map} +1 -1
  159. package/dist/client/index.d.ts +1 -0
  160. package/dist/client/index.d.ts.map +1 -1
  161. package/dist/client/index.js +26 -1
  162. package/dist/client/index.js.map +1 -1
  163. package/dist/client/staticNavigation.d.ts +26 -0
  164. package/dist/client/staticNavigation.d.ts.map +1 -0
  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/index.js +2 -2
  175. package/dist/facades/index.js.map +1 -1
  176. package/dist/foundation/index.js +2 -2
  177. package/dist/foundation/index.js.map +1 -1
  178. package/dist/http/ViewRouter.d.ts +36 -2
  179. package/dist/http/ViewRouter.d.ts.map +1 -1
  180. package/dist/http/index.d.ts +1 -1
  181. package/dist/http/index.d.ts.map +1 -1
  182. package/dist/http/index.js +2 -2
  183. package/dist/http/index.js.map +1 -1
  184. package/dist/i18n/dictionaryRuntime.js +2 -2
  185. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  186. package/dist/i18n/index.js +2 -2
  187. package/dist/i18n/index.js.map +2 -2
  188. package/dist/internal/islandRuntime.d.ts +16 -0
  189. package/dist/internal/islandRuntime.d.ts.map +1 -1
  190. package/dist/internal/staticNavigationRuntime.d.ts +8 -0
  191. package/dist/internal/staticNavigationRuntime.d.ts.map +1 -0
  192. package/dist/kernel/index.js +2 -2
  193. package/dist/kernel/index.js.map +2 -2
  194. package/dist/orm/index.js +2 -2
  195. package/dist/orm/index.js.map +1 -1
  196. package/dist/server/devFetch.d.ts.map +1 -1
  197. package/dist/server/httpProd.d.ts.map +1 -1
  198. package/dist/server/index.js +2 -2
  199. package/dist/server/index.js.map +1 -1
  200. package/dist/services/index.d.ts +1 -1
  201. package/dist/services/index.d.ts.map +1 -1
  202. package/dist/services/index.js +3 -3
  203. package/dist/services/index.js.map +2 -2
  204. package/dist/services/queue/work.js +2 -2
  205. package/dist/services/queue/work.js.map +1 -1
  206. package/dist/services/router/ViewRouteDispatcher.d.ts +5 -0
  207. package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
  208. package/dist/services/router/staticDocument.d.ts +30 -21
  209. package/dist/services/router/staticDocument.d.ts.map +1 -1
  210. package/dist/stats/bundleStats.d.ts +6 -2
  211. package/dist/stats/bundleStats.d.ts.map +1 -1
  212. package/dist/stats/route-table.js +2 -2
  213. package/dist/stats/route-table.js.map +3 -3
  214. package/dist/stats/routeTable.d.ts +5 -1
  215. package/dist/stats/routeTable.d.ts.map +1 -1
  216. package/dist/support/index.js +2 -2
  217. package/dist/support/index.js.map +1 -1
  218. package/dist/testing/index.d.ts +2 -0
  219. package/dist/testing/index.d.ts.map +1 -1
  220. package/dist/testing/index.js +185 -2
  221. package/dist/testing/index.js.map +1 -1
  222. package/dist/testing/staticDocument.d.ts +80 -0
  223. package/dist/testing/staticDocument.d.ts.map +1 -0
  224. package/dist/vitest/index.js +1 -1
  225. package/package.json +1 -1
  226. package/dist/chunk-15v719sq.js +0 -5
  227. package/dist/chunk-bz5gda3b.js +0 -57
  228. package/dist/chunk-w8d37mcq.js +0 -24
  229. /package/dist/{chunk-7rffbkmg.js.map → chunk-0k02tza1.js.map} +0 -0
  230. /package/dist/{chunk-pzk2a5sr.js.map → chunk-cvr5624r.js.map} +0 -0
  231. /package/dist/{chunk-h02kyxgg.js.map → chunk-dhbgrv58.js.map} +0 -0
  232. /package/dist/{chunk-xecnc8zv.js.map → chunk-wjkh2gem.js.map} +0 -0
  233. /package/dist/{chunk-2y0r4b7g.js.map → chunk-y6wt5b6t.js.map} +0 -0
  234. /package/dist/{chunk-de4t48j9.js.map → chunk-zg6hmc48.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{hb as I8}from"../chunk-thz75w6e.js";import{Ab as z8,Bb as X8,Cb as B8,Db as M8,Eb as k,Fb as j8,Gb as N8,Hb as x8,Ib as L8,Jb as D8,Kb as F8,Lb as H8,Mb as U8,Nb as S8,Ob as O8,Pb as R8,Qb as f8,Rb as _8,Sb as k8,Tb as C8,ib as N5,jb as x5,kb as L5,lb as D5,mb as z4,nb as F5,ob as Q4,pb as Y4,qb as I1,rb as H5,sb as S5,tb as W8,vb as J8,wb as Z8,xb as Y8,yb as G8,zb as K8}from"../chunk-khd9ft0s.js";import"../chunk-vy0tnx2s.js";import{kc as h5,lc as g5,mc as E5,nc as m5,oc as c5,pc as d5,qc as p5,rc as l5,sc as n5,tc as i5,uc as o5,vc as s5,wc as a5,xc as t5,yc as r5,zc as e5}from"../chunk-wdg83tgd.js";import{Ac as u5}from"../chunk-675kzd7z.js";import{Bc as U5,Cc as O5,Dc as R5,Ec as f5,Fc as _5,Gc as k5,Hc as C5,Ic as I5,Jc as b5,Kc as T5,Lc as v5,Mc as P5,Nc as w5,Oc as V5,Pc as q5,Qc as y5,Rc as A5}from"../chunk-d4dd7jde.js";import{Wc as $8,Xc as Q8}from"../chunk-7pxdvvrz.js";import"../chunk-30xxc6r7.js";import{$d as AW,Ae as J5,Bd as GW,Be as Z5,Cd as KW,Ce as $5,De as Q5,Fd as A0,Ge as Y5,Le as G5,Pe as K5,Re as b1,Td as bW,Ud as TW,Vd as vW,Wd as PW,Xd as wW,Yd as VW,Zd as qW,_d as yW,be as hW,ce as gW,de as EW,ee as mW,fe as cW,ge as uW,he as dW,ie as x0,je as pW,ke as lW,le as nW,md as e6,me as iW,nd as WW,ne as oW,od as JW,pd as ZW,qd as $W,rd as QW,re as q,se as j1,te as sW,ud as y0,ue as aW,vd as S0,ve as tW,wd as O0,we as rW,xd as t1,xe as eW,yd as YW,ze as W5}from"../chunk-bz5gda3b.js";import"../chunk-zq1bhsdg.js";import"../chunk-fjhnn3de.js";import{Ag as NW,Cg as xW,Eg as _1,Jf as a1,Kf as i1,Lf as K1,Xf as $4,_f as i,ag as c,eg as o1,fg as z1,gg as f1,hg as zW,ig as XW,jg as BW,kg as MW,zg as jW}from"../chunk-299zx9dv.js";import"../chunk-2kegxt0s.js";import"../chunk-4c1npv8k.js";import{Rg as OW,Sg as RW,Tg as fW,Ug as _W,Vg as kW,Wg as CW,Xg as IW}from"../chunk-ct1vwaw7.js";import{bh as HW,ch as UW,dh as SW}from"../chunk-6pqbsc5y.js";import"../chunk-kkx8a35r.js";import{Mh as LW,Nh as DW,Oh as FW}from"../chunk-q6a30w8w.js";import"../chunk-c8vttyem.js";import"../chunk-pjz79c2c.js";import"../chunk-fmea4sak.js";import"../chunk-b336h3hj.js";import{Ei as z5,Fi as X5,Gi as B5,Hi as M5,Ji as j5}from"../chunk-3vt172y7.js";import"../chunk-1p87gdd2.js";import{Ti as v}from"../chunk-zb8zzf5x.js";import"../chunk-9c5s06gc.js";import"../chunk-nfq127pg.js";import"../chunk-q0djcyj2.js";import"../chunk-0p6mdba6.js";import{kj as D0}from"../chunk-j5q5ysng.js";import{Buffer as L0}from"buffer";class F0 extends z1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-9qkjkse0.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:J}={}){J?.throwIfAborted();let Z,$,Q,Y=process.env.BUCKET_NAME;if(W instanceof Blob)Z=W,Q=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,$=W.type;else Z=W.body,Q=W.name,Y=W.bucket??Y,$=W.contentType||(Z instanceof Blob||Z instanceof File?Z.type:void 0);$=$||void 0;let G=Z instanceof L0?Z:Z instanceof Blob||Z instanceof File?L0.from(await Z.arrayBuffer()):"",{sdk:K,client:z}=await this.connect();return J?.throwIfAborted(),await z.send(new K.PutObjectCommand({Bucket:Y,Key:Q,Body:G,ContentType:$}),{abortSignal:J}),Q}async delete(W){let J=typeof W==="string"?W:W.name,Z=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!J)throw Error("Object name has to be specified");let{sdk:$,client:Q}=await this.connect();try{await Q.send(new $.DeleteObjectCommand({Bucket:Z,Key:J}))}catch(Y){if(Y?.name==="NoSuchKey"||Y?.$metadata?.httpStatusCode===404)return;throw Y}}async*pages(W,{bucket:J,signal:Z}){let{sdk:$,client:Q}=await this.connect(),Y;do{Z?.throwIfAborted();let G=await Q.send(new $.ListObjectsV2Command({Bucket:J??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:Y}),{abortSignal:Z});yield(G.Contents??[]).map((K)=>({name:K.Key,size:K.Size??0,lastModified:K.LastModified??new Date(0)})),Y=G.IsTruncated?G.NextContinuationToken:void 0}while(Y)}async*objects(W,J={}){for await(let Z of this.pages(W,J))yield*Z}async deletePrefix(W,J={}){o1(W);let Z=J.bucket??process.env.BUCKET_NAME,{sdk:$,client:Q}=await this.connect(),Y=0;for await(let G of this.pages(W,{...J,bucket:Z})){if(G.length===0)continue;J.signal?.throwIfAborted();let z=(await Q.send(new $.DeleteObjectsCommand({Bucket:Z,Delete:{Objects:G.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:J.signal}))?.Errors??[];if(z.length>0){let X=z[0];throw Error(`S3 could not delete ${z.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}Y+=G.length}return Y}async list(W){let{sdk:J,client:Z}=await this.connect();return await Z.send(new J.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:J}={}){J?.throwIfAborted();let Z=process.env.BUCKET_NAME,$;if(typeof W==="string")$=W;else Z=W.bucket??Z,$=W.name;if(!$)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();J?.throwIfAborted();let G=await Y.send(new Q.GetObjectCommand({Bucket:Z,Key:$}),{abortSignal:J}),K=f1(G.Body.transformToWebStream(),J);return J?.throwIfAborted(),new Response(K,{headers:{"Content-Type":G.ContentType,"Content-Length":G.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":G.LastModified?.toUTCString()||"",ETag:G.ETag||""}})}async read(W){let J=typeof W==="string"?{name:W}:W,Z=J.bucket??process.env.BUCKET_NAME,{name:$,range:Q=null}=J;if(!$)throw Error("Object name has to be specified");let{sdk:Y,client:G}=await this.connect(),K;try{K=await G.send(new Y.GetObjectCommand({Bucket:Z,Key:$,Range:Q?i1(Q):void 0}))}catch(M){if(M?.name==="InvalidRange"||M?.$metadata?.httpStatusCode===416)throw new i(await this.size({name:$,bucket:Z}));if(M?.name==="NoSuchKey"||M?.$metadata?.httpStatusCode===404)throw new c($);throw M}let z=K1(K.ContentRange),X=Boolean(z)&&K.$metadata?.httpStatusCode===206,B=z?.total??K.ContentLength??0;return{body:K.Body.transformToWebStream(),start:z?.start??0,end:z?.end??B-1,total:B,partial:X,type:K.ContentType??"application/octet-stream",etag:K.ETag||void 0,lastModified:K.LastModified,name:$}}async size(W){let J=typeof W==="string"?W:W.name,Z=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:$,client:Q}=await this.connect();try{return(await Q.send(new $.HeadObjectCommand({Bucket:Z,Key:J}))).ContentLength??0}catch(Y){if(Y?.name==="NotFound"||Y?.$metadata?.httpStatusCode===404)throw new c(J);throw Y}}}import{Buffer as H0}from"buffer";import{Readable as H6}from"stream";function s1(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function U6(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class U0 extends z1{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 J=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(J)return W.BlobServiceClient.fromConnectionString(J);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,J){if(!W)throw Error("Object name has to be specified");let Z=J??this.config.container??process.env.BUCKET_NAME;if(!Z)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient(Z).getBlockBlobClient(W)}async put(W,{signal:J}={}){J?.throwIfAborted();let Z,$,Q,Y;if(W instanceof Blob)Z=W,Q=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,$=W.type;else Z=W.body,Q=W.name,Y=W.bucket,$=W.contentType??(Z instanceof Blob||Z instanceof File?Z.type:void 0);let G=Z instanceof H0?Z:H0.from(await Z.arrayBuffer()),K=await this.blob(Q,Y);return J?.throwIfAborted(),await K.uploadData(G,{blobHTTPHeaders:$?{blobContentType:$}:void 0,abortSignal:J}),Q}async*objects(W,{bucket:J,signal:Z}={}){Z?.throwIfAborted();let $=J??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let Y=(await this.serviceClient()).getContainerClient($);for await(let G of Y.listBlobsFlat({prefix:W}))Z?.throwIfAborted(),yield{name:G.name,size:G.properties?.contentLength??0,lastModified:G.properties?.lastModified??new Date(0)}}async list(W){let J=this.config.container??process.env.BUCKET_NAME,$=(await this.serviceClient()).getContainerClient(J),Q=[];for await(let Y of $.listBlobsFlat({prefix:W}))Q.push(Y.name);return Q}async fetch(W,{signal:J}={}){J?.throwIfAborted();let Z=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},J);return new Response(Z.body,{headers:{"Content-Type":Z.type,"Content-Length":String(Z.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":Z.lastModified?.toUTCString()??"",ETag:Z.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,J){let{name:Z,bucket:$,range:Q=null}=W,Y=await this.blob(Z,$);J?.throwIfAborted();let G,K,z=Q?.kind==="suffix"||Q?.kind==="offset"&&Q.end===null&&Q.start===0;if(Q&&z){let H=await this.size({name:Z,bucket:$}),m=a1(Q,H);if(!m)throw new i(H);G=m.start,K=m.length}else if(Q?.kind==="offset")G=Q.start,K=Q.end===null?void 0:Q.end-Q.start+1;let X;try{X=await Y.download(G,K,J?{abortSignal:J}:void 0)}catch(H){if(U6(H))throw new i(await this.size({name:Z,bucket:$}));if(s1(H))throw new c(Z);throw H}let B=K1(X.contentRange),M=Boolean(B),D=B?.total??X.contentLength??0,S=await S6(X);if(S instanceof ReadableStream)S=f1(S,J);return J?.throwIfAborted(),{body:S,start:B?.start??0,end:B?.end??D-1,total:D,partial:M,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:Z}}async size(W){let J=typeof W==="string"?W:W.name,Z=typeof W==="string"?void 0:W.bucket,$=await this.blob(J,Z);try{return(await $.getProperties()).contentLength??0}catch(Q){if(s1(Q))throw new c(J);throw Q}}async delete(W){let J=typeof W==="string"?W:W.name,Z=typeof W==="string"?void 0:W.bucket,$=await this.blob(J,Z);try{await $.delete()}catch(Q){if(s1(Q))return;throw Q}}}async function S6(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return H6.toWeb(W.readableStreamBody);return null}function O6(W){return W}var R6=`
2
+ import{cb as b8}from"../chunk-fcqx2t0p.js";import{Ab as N8,Bb as x8,Cb as L8,Db as D8,Eb as F8,Fb as H8,Gb as U8,Hb as S8,Ib as O8,Jb as R8,Kb as f8,Lb as _8,Mb as k8,Nb as C8,Ob as I8,db as x5,eb as L5,fb as D5,gb as F5,hb as z4,ib as H5,jb as Q4,kb as Y4,lb as I1,mb as U5,nb as O5,ob as J8,qb as Z8,rb as $8,sb as G8,tb as K8,ub as z8,vb as X8,wb as B8,xb as M8,yb as j8,zb as k}from"../chunk-ar4d3vmr.js";import"../chunk-mr94nfp1.js";import{fc as g5,gc as E5,hc as m5,ic as c5,jc as u5,kc as p5,lc as l5,mc as n5,nc as i5,oc as o5,pc as s5,qc as a5,rc as t5,sc as r5,tc as e5,uc as W8}from"../chunk-9rr5h818.js";import{vc as d5}from"../chunk-7mmw0jr2.js";import{Ac as k5,Bc as C5,Cc as I5,Dc as b5,Ec as T5,Fc as v5,Gc as P5,Hc as w5,Ic as V5,Jc as q5,Kc as y5,Lc as A5,Mc as h5,wc as S5,xc as R5,yc as f5,zc as _5}from"../chunk-dwedx1jb.js";import{Rc as Q8,Sc as Y8}from"../chunk-tk135gmj.js";import"../chunk-9xyxbxgk.js";import{$d as mW,Ad as A0,Be as Y5,Ce as G5,He as K5,Le as z5,Ne as b1,Od as bW,Pd as TW,Qd as vW,Rd as PW,Sd as wW,Td as VW,Ud as qW,Vd as yW,Wd as AW,Yd as hW,Zd as gW,_d as EW,ae as cW,be as uW,ce as dW,de as x0,ee as pW,fe as lW,ge as nW,hd as e6,he as iW,id as WW,ie as oW,jd as JW,kd as ZW,ld as $W,md as QW,me as q,ne as j1,oe as sW,pd as y0,pe as aW,qd as S0,qe as tW,rd as O0,re as rW,sd as t1,se as eW,td as YW,ue as W5,ve as J5,wd as GW,we as Z5,xd as KW,xe as $5,ye as Q5}from"../chunk-b5a5vvkk.js";import"../chunk-65beps2q.js";import"../chunk-m53fgf20.js";import{Ag as _1,Ff as a1,Gf as i1,Hf as K1,Tf as $4,Wf as i,Yf as c,ag as o1,bg as z1,cg as f1,dg as zW,eg as XW,fg as BW,gg as MW,vg as jW,wg as NW,yg as xW}from"../chunk-4acpw92g.js";import"../chunk-cca0grq3.js";import"../chunk-m83zm86m.js";import{Ng as OW,Og as RW,Pg as fW,Qg as _W,Rg as kW,Sg as CW,Tg as IW}from"../chunk-1xdrs2hx.js";import{$g as SW,Zg as HW,_g as UW}from"../chunk-19dpzp4y.js";import"../chunk-yds7zwc3.js";import{Ih as LW,Jh as DW,Kh as FW}from"../chunk-meg8rtr6.js";import"../chunk-h43jp8ws.js";import"../chunk-s07v65x6.js";import"../chunk-gc2dz11k.js";import"../chunk-cskqet01.js";import{Ai as X5,Bi as B5,Ci as M5,Di as j5,Fi as N5}from"../chunk-1wnnkde0.js";import"../chunk-fenc5tpv.js";import{Pi as v}from"../chunk-nz8z8jr1.js";import"../chunk-4fx8p02c.js";import"../chunk-er8acmch.js";import"../chunk-2n3pgfnb.js";import"../chunk-d5f1m3d2.js";import"../chunk-rhvc1axc.js";import{mj as D0}from"../chunk-tewhms9w.js";import{Buffer as L0}from"buffer";class F0 extends z1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-5nj94s66.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:J}={}){J?.throwIfAborted();let Z,$,Q,Y=process.env.BUCKET_NAME;if(W instanceof Blob)Z=W,Q=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,$=W.type;else Z=W.body,Q=W.name,Y=W.bucket??Y,$=W.contentType||(Z instanceof Blob||Z instanceof File?Z.type:void 0);$=$||void 0;let G=Z instanceof L0?Z:Z instanceof Blob||Z instanceof File?L0.from(await Z.arrayBuffer()):"",{sdk:K,client:z}=await this.connect();return J?.throwIfAborted(),await z.send(new K.PutObjectCommand({Bucket:Y,Key:Q,Body:G,ContentType:$}),{abortSignal:J}),Q}async delete(W){let J=typeof W==="string"?W:W.name,Z=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!J)throw Error("Object name has to be specified");let{sdk:$,client:Q}=await this.connect();try{await Q.send(new $.DeleteObjectCommand({Bucket:Z,Key:J}))}catch(Y){if(Y?.name==="NoSuchKey"||Y?.$metadata?.httpStatusCode===404)return;throw Y}}async*pages(W,{bucket:J,signal:Z}){let{sdk:$,client:Q}=await this.connect(),Y;do{Z?.throwIfAborted();let G=await Q.send(new $.ListObjectsV2Command({Bucket:J??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:Y}),{abortSignal:Z});yield(G.Contents??[]).map((K)=>({name:K.Key,size:K.Size??0,lastModified:K.LastModified??new Date(0)})),Y=G.IsTruncated?G.NextContinuationToken:void 0}while(Y)}async*objects(W,J={}){for await(let Z of this.pages(W,J))yield*Z}async deletePrefix(W,J={}){o1(W);let Z=J.bucket??process.env.BUCKET_NAME,{sdk:$,client:Q}=await this.connect(),Y=0;for await(let G of this.pages(W,{...J,bucket:Z})){if(G.length===0)continue;J.signal?.throwIfAborted();let z=(await Q.send(new $.DeleteObjectsCommand({Bucket:Z,Delete:{Objects:G.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:J.signal}))?.Errors??[];if(z.length>0){let X=z[0];throw Error(`S3 could not delete ${z.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}Y+=G.length}return Y}async list(W){let{sdk:J,client:Z}=await this.connect();return await Z.send(new J.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:J}={}){J?.throwIfAborted();let Z=process.env.BUCKET_NAME,$;if(typeof W==="string")$=W;else Z=W.bucket??Z,$=W.name;if(!$)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();J?.throwIfAborted();let G=await Y.send(new Q.GetObjectCommand({Bucket:Z,Key:$}),{abortSignal:J}),K=f1(G.Body.transformToWebStream(),J);return J?.throwIfAborted(),new Response(K,{headers:{"Content-Type":G.ContentType,"Content-Length":G.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":G.LastModified?.toUTCString()||"",ETag:G.ETag||""}})}async read(W){let J=typeof W==="string"?{name:W}:W,Z=J.bucket??process.env.BUCKET_NAME,{name:$,range:Q=null}=J;if(!$)throw Error("Object name has to be specified");let{sdk:Y,client:G}=await this.connect(),K;try{K=await G.send(new Y.GetObjectCommand({Bucket:Z,Key:$,Range:Q?i1(Q):void 0}))}catch(M){if(M?.name==="InvalidRange"||M?.$metadata?.httpStatusCode===416)throw new i(await this.size({name:$,bucket:Z}));if(M?.name==="NoSuchKey"||M?.$metadata?.httpStatusCode===404)throw new c($);throw M}let z=K1(K.ContentRange),X=Boolean(z)&&K.$metadata?.httpStatusCode===206,B=z?.total??K.ContentLength??0;return{body:K.Body.transformToWebStream(),start:z?.start??0,end:z?.end??B-1,total:B,partial:X,type:K.ContentType??"application/octet-stream",etag:K.ETag||void 0,lastModified:K.LastModified,name:$}}async size(W){let J=typeof W==="string"?W:W.name,Z=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:$,client:Q}=await this.connect();try{return(await Q.send(new $.HeadObjectCommand({Bucket:Z,Key:J}))).ContentLength??0}catch(Y){if(Y?.name==="NotFound"||Y?.$metadata?.httpStatusCode===404)throw new c(J);throw Y}}}import{Buffer as H0}from"buffer";import{Readable as H6}from"stream";function s1(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function U6(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class U0 extends z1{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 J=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(J)return W.BlobServiceClient.fromConnectionString(J);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,J){if(!W)throw Error("Object name has to be specified");let Z=J??this.config.container??process.env.BUCKET_NAME;if(!Z)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient(Z).getBlockBlobClient(W)}async put(W,{signal:J}={}){J?.throwIfAborted();let Z,$,Q,Y;if(W instanceof Blob)Z=W,Q=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,$=W.type;else Z=W.body,Q=W.name,Y=W.bucket,$=W.contentType??(Z instanceof Blob||Z instanceof File?Z.type:void 0);let G=Z instanceof H0?Z:H0.from(await Z.arrayBuffer()),K=await this.blob(Q,Y);return J?.throwIfAborted(),await K.uploadData(G,{blobHTTPHeaders:$?{blobContentType:$}:void 0,abortSignal:J}),Q}async*objects(W,{bucket:J,signal:Z}={}){Z?.throwIfAborted();let $=J??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let Y=(await this.serviceClient()).getContainerClient($);for await(let G of Y.listBlobsFlat({prefix:W}))Z?.throwIfAborted(),yield{name:G.name,size:G.properties?.contentLength??0,lastModified:G.properties?.lastModified??new Date(0)}}async list(W){let J=this.config.container??process.env.BUCKET_NAME,$=(await this.serviceClient()).getContainerClient(J),Q=[];for await(let Y of $.listBlobsFlat({prefix:W}))Q.push(Y.name);return Q}async fetch(W,{signal:J}={}){J?.throwIfAborted();let Z=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},J);return new Response(Z.body,{headers:{"Content-Type":Z.type,"Content-Length":String(Z.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":Z.lastModified?.toUTCString()??"",ETag:Z.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,J){let{name:Z,bucket:$,range:Q=null}=W,Y=await this.blob(Z,$);J?.throwIfAborted();let G,K,z=Q?.kind==="suffix"||Q?.kind==="offset"&&Q.end===null&&Q.start===0;if(Q&&z){let H=await this.size({name:Z,bucket:$}),m=a1(Q,H);if(!m)throw new i(H);G=m.start,K=m.length}else if(Q?.kind==="offset")G=Q.start,K=Q.end===null?void 0:Q.end-Q.start+1;let X;try{X=await Y.download(G,K,J?{abortSignal:J}:void 0)}catch(H){if(U6(H))throw new i(await this.size({name:Z,bucket:$}));if(s1(H))throw new c(Z);throw H}let B=K1(X.contentRange),M=Boolean(B),D=B?.total??X.contentLength??0,S=await S6(X);if(S instanceof ReadableStream)S=f1(S,J);return J?.throwIfAborted(),{body:S,start:B?.start??0,end:B?.end??D-1,total:D,partial:M,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:Z}}async size(W){let J=typeof W==="string"?W:W.name,Z=typeof W==="string"?void 0:W.bucket,$=await this.blob(J,Z);try{return(await $.getProperties()).contentLength??0}catch(Q){if(s1(Q))throw new c(J);throw Q}}async delete(W){let J=typeof W==="string"?W:W.name,Z=typeof W==="string"?void 0:W.bucket,$=await this.blob(J,Z);try{await $.delete()}catch(Q){if(s1(Q))return;throw Q}}}async function S6(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return H6.toWeb(W.readableStreamBody);return null}function O6(W){return W}var R6=`
3
3
  local currentKey = KEYS[1]
4
4
  local previousKey = KEYS[2]
5
5
  local limit = tonumber(ARGV[1])
@@ -67,6 +67,6 @@ ${W.resolution}.`;console.warn(Z),console.warn("To disable this message, import
67
67
  `)return this.emit(j.DataKeepAlive);this.parser.push(J.toString())}),this.resetKeepAliveTimeout()}initEventsFromParser(){let W=this.requestData.payloadIsError;this.parser.on(l.ParsedData,(J)=>{if(W&&W(J))this.emit(j.DataError,J),this.emit(j.Error,{type:j.DataError,error:J,message:"Twitter sent a payload that is detected as an error payload."});else this.emit(j.Data,J)}),this.parser.on(l.ParseError,(J)=>{this.emit(j.TweetParseError,J),this.emit(j.Error,{type:j.TweetParseError,error:J,message:"Failed to parse stream data."})})}resetKeepAliveTimeout(){if(this.unbindKeepAliveTimeout(),this.keepAliveTimeoutMs!==1/0)this.keepAliveTimeout=setTimeout(this.onKeepAliveTimeout,this.keepAliveTimeoutMs)}onKeepAliveTimeout(){this.emit(j.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(j.ConnectionClosed),this.closeWithoutEmit()}destroy(){this.removeAllListeners(),this.close()}async clone(){let J=await new U1(this.requestData).makeRequestAsStream(),Z=this.eventNames();for(let $ of Z){let Q=this.listeners($);for(let Y of Q)J.on($,Y)}return J}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(J){if(this.emit(j.ConnectError,0),this.emit(j.Error,{type:j.ConnectError,error:J,message:"Connect error - Initial connection just failed."}),this.autoReconnect)this.makeAutoReconnectRetry(0,J);else throw J}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:J,res:Z,originalResponse:$}=await new U1(this.requestData).makeRequestAndResolveWhenReady();this.req=J,this.res=Z,this.originalResponse=$,this.emit(W?j.Connected:j.Reconnected),this.parser.reset(),this.initEventsFromRequest()}finally{this.connectionProcessRunning=!1}}async onConnectionError(W=0){if(this.unbindTimeouts(),this.closeWithoutEmit(),!this.autoReconnect){this.emit(j.ConnectionClosed);return}if(W>=this.autoReconnectRetries){this.emit(j.ReconnectLimitExceeded),this.emit(j.ConnectionClosed);return}try{this.emit(j.ReconnectAttempt,W),await this.reconnect()}catch(J){this.emit(j.ReconnectError,W),this.emit(j.Error,{type:j.ReconnectError,error:J,message:`Reconnect error - ${W+1} attempts made yet.`}),this.makeAutoReconnectRetry(W,J)}}makeAutoReconnectRetry(W,J){let Z=this.nextRetryTimeout(W+1,J);this.retryTimeout=setTimeout(()=>{this.onConnectionError(W+1)},Z)}async*[Symbol.asyncIterator](){let W=new s0(this);try{while(!0){if(!this.req||this.req.aborted)throw Error("Connection closed");if(W.hasStack())yield*W.popStack();let{type:J,payload:Z}=await W.nextEvent();if(J==="error")throw Z}}finally{W.destroy()}}}var V1=t0;function r0(W){var J;if(!((J=W.clientSettings.plugins)===null||J===void 0?void 0:J.length))return!1;for(let Z of W.clientSettings.plugins)if(Z.onRequestError||Z.onResponseError)return!0;return!1}async function e0(W,J,Z,$){let Q;if($ instanceof x1||$ instanceof L1)Q=await this.applyPluginMethod("onRequestError",{client:this,url:this.getUrlObjectFromUrlString(W.url),params:W,computedParams:J,requestOptions:Z,error:$});else if($ instanceof D1)Q=await this.applyPluginMethod("onResponseError",{client:this,url:this.getUrlObjectFromUrlString(W.url),params:W,computedParams:J,requestOptions:Z,error:$});if(Q&&Q instanceof F1)return Q.value;return Promise.reject($)}import*as Z6 from"crypto";class C{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,J){return Z6.createHmac("sha1",J).update(W).digest("base64")}authorize(W,J={}){let Z={oauth_consumer_key:this.consumerKeys.key,oauth_nonce:this.getNonce(),oauth_signature_method:"HMAC-SHA1",oauth_timestamp:this.getTimestamp(),oauth_version:"1.0"};if(J.key!==void 0)Z.oauth_token=J.key;if(!W.data)W.data={};return Z.oauth_signature=this.getSignature(W,J.secret,Z),Z}toHeader(W){let J=J6(W),Z="OAuth ";for(let $ of J){if($.key.indexOf("oauth_")!==0)continue;Z+=C.percentEncode($.key)+'="'+C.percentEncode($.value)+'",'}return{Authorization:Z.slice(0,Z.length-1)}}getNonce(){let J="";for(let Z=0;Z<this.nonceLength;Z++)J+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.trunc(Math.random()*62)];return J}getTimestamp(){return Math.trunc(new Date().getTime()/1000)}getSignature(W,J,Z){return this.hash(this.getBaseString(W,Z),this.getSigningKey(J))}getSigningKey(W){return C.percentEncode(this.consumerKeys.secret)+"&"+C.percentEncode(W||"")}getBaseString(W,J){return W.method.toUpperCase()+"&"+C.percentEncode(this.getBaseUrl(W.url))+"&"+C.percentEncode(this.getParameterString(W,J))}getParameterString(W,J){let Z=J6(o6(W6(J,W6(W.data,i6(W.url))))),$="";for(let{key:Q,value:Y}of Z)if(Y&&Array.isArray(Y)){Y.sort();let G="";Y.forEach((K,z)=>{if(G+=Q+"="+K,z<Y.length)G+="&"}),$+=G}else $+=Q+"="+Y+"&";return $.slice(0,$.length-1)}getBaseUrl(W){return W.split("?")[0]}}var S1=C;function W6(W,J){return{...W||{},...J||{}}}function J6(W){return Object.keys(W).sort().map((J)=>({key:J,value:W[J]}))}function n6(W){let J=W.split("&"),Z={};for(let $ of J){let[Q,Y=""]=$.split("=");if(Z[Q]){if(!Array.isArray(Z[Q]))Z[Q]=[Z[Q]];Z[Q].push(decodeURIComponent(Y))}else Z[Q]=decodeURIComponent(Y)}return Z}function i6(W){let J=W.split("?");if(J.length===1)return{};return n6(J[1])}function o6(W){let J={};for(let Z in W){let $=W[Z];if($&&Array.isArray($))$=$.map((Q)=>C.percentEncode(Q));else $=C.percentEncode($);J[C.percentEncode(Z)]=$}return J}class I{constructor(){this._boundary="",this._chunks=[]}bodyAppend(...W){let J=W.map((Z)=>Z instanceof Buffer?Z:Buffer.from(Z));this._chunks.push(...J)}append(W,J,Z){let $=J instanceof Buffer?J:J.toString(),Q=this.getMultipartHeader(W,$,Z);this.bodyAppend(Q,$,I.LINE_BREAK)}getHeaders(){return{"content-type":"multipart/form-data; boundary="+this.getBoundary()}}getLength(){return this._chunks.reduce((W,J)=>W+J.length,this.getMultipartFooter().length)}getBuffer(){let W=[...this._chunks,this.getMultipartFooter()],J=Buffer.alloc(this.getLength()),Z=0;for(let $ of W)for(let Q=0;Q<$.length;Z++,Q++)J[Z]=$[Q];return J}getBoundary(){if(!this._boundary)this.generateBoundary();return this._boundary}generateBoundary(){let W="--------------------------";for(let J=0;J<24;J++)W+=Math.floor(Math.random()*10).toString(16);this._boundary=W}getMultipartHeader(W,J,Z){if(!Z)Z=J instanceof Buffer?I.DEFAULT_CONTENT_TYPE:"";let $={"Content-Disposition":["form-data",`name="${W}"`],"Content-Type":Z},Q="";for(let[Y,G]of Object.entries($)){if(!G.length)continue;Q+=Y+": "+P1(G).join("; ")+I.LINE_BREAK}return"--"+this.getBoundary()+I.LINE_BREAK+Q+I.LINE_BREAK}getMultipartFooter(){if(this._footerChunk)return this._footerChunk;return this._footerChunk=Buffer.from("--"+this.getBoundary()+"--"+I.LINE_BREAK)}}I.LINE_BREAK=`\r
68
68
  `;I.DEFAULT_CONTENT_TYPE="application/octet-stream";class F4{static formatQueryToString(W){let J={};for(let Z in W)if(typeof W[Z]==="string")J[Z]=W[Z];else if(typeof W[Z]<"u")J[Z]=String(W[Z]);return J}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 J=W.pathname.split("/1.1/",2)[1];if(this.JSON_1_1_ENDPOINTS.has(J))return"json";return"url"}static addQueryParamsToUrl(W,J){let Z=Object.entries(J);if(Z.length){let $="";for(let[Q,Y]of Z)$+=($.length?"&":"?")+`${S1.percentEncode(Q)}=${S1.percentEncode(Y)}`;W.search=$}}static constructBodyParams(W,J,Z){if(W instanceof Buffer)return W;if(Z==="json"){if(!J["content-type"])J["content-type"]="application/json;charset=UTF-8";return JSON.stringify(W)}else if(Z==="url"){if(!J["content-type"])J["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(Z==="raw")throw Error("You can only use raw body mode with Buffers. To give a string, use Buffer.from(str).");else{let $=new I;for(let Q in W)$.append(Q,W[Q]);if(!J["content-type"]){let Q=$.getHeaders();J["content-type"]=Q["content-type"]}return $.getBuffer()}}static setBodyLengthHeader(W,J){var Z;if(W.headers=(Z=W.headers)!==null&&Z!==void 0?Z:{},typeof J==="string")W.headers["content-length"]=Buffer.byteLength(J);else W.headers["content-length"]=J.length}static isOAuthSerializable(W){return!(W instanceof Buffer)}static mergeQueryAndBodyForOAuth(W,J){let Z={};for(let $ in W)Z[$]=W[$];if(this.isOAuthSerializable(J))for(let $ in J){let Q=J[$];if(this.isOAuthSerializable(Q))Z[$]=typeof Q==="object"&&Q!==null&&"toString"in Q?Q.toString():Q}return Z}static moveUrlQueryParamsIntoObject(W,J){for(let[Z,$]of W.searchParams)J[Z]=$;return W.search="",W}static applyRequestParametersToUrl(W,J){return W.pathname=W.pathname.replace(/:([A-Z_-]+)/ig,(Z,$)=>{if(J[$]!==void 0)return String(J[$]);return Z}),W}}F4.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 R=F4;import*as $6 from"crypto";class n{static getCodeVerifier(){return this.generateRandomString(128)}static getCodeChallengeFromVerifier(W){return this.escapeBase64Url($6.createHash("sha256").update(W).digest("base64"))}static getAuthHeader(W,J){let Z=encodeURIComponent(W)+":"+encodeURIComponent(J);return Buffer.from(Z).toString("base64")}static generateRandomString(W){let J="",Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";for(let $=0;$<W;$++)J+=Z[Math.floor(Math.random()*Z.length)];return J}static escapeBase64Url(W){return W.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}}class r{constructor(W){if(this.rateLimits={},this.clientSettings={},W)this.clientSettings=W}getRateLimits(){return this.rateLimits}saveRateLimit(W,J){this.rateLimits[W]=J}async send(W){var J,Z,$,Q,Y;if((J=this.clientSettings.plugins)===null||J===void 0?void 0:J.length){let M=await this.applyPreRequestConfigHooks(W);if(M)return M}let G=this.getHttpRequestArgs(W),K={method:G.method,headers:G.headers,timeout:W.timeout,agent:this.clientSettings.httpAgent},z=W.enableRateLimitSave!==!1;if(G.body)R.setBodyLengthHeader(K,G.body);if((Z=this.clientSettings.plugins)===null||Z===void 0?void 0:Z.length)await this.applyPreRequestHooks(W,G,K);let X=new U1({url:G.url,options:K,body:G.body,rateLimitSaver:z?this.saveRateLimit.bind(this,G.rawUrl):void 0,requestEventDebugHandler:W.requestEventDebugHandler,compression:(Q=($=W.compression)!==null&&$!==void 0?$:this.clientSettings.compression)!==null&&Q!==void 0?Q:!0,forceParseMode:W.forceParseMode}).makeRequest();if(r0(this))X=this.applyResponseErrorHooks(W,G,K,X);let B=await X;if((Y=this.clientSettings.plugins)===null||Y===void 0?void 0:Y.length){let M=await this.applyPostRequestHooks(W,G,K,B);if(M)return M.value}return B}sendStream(W){var J,Z;if(this.clientSettings.plugins)this.applyPreStreamRequestConfigHooks(W);let $=this.getHttpRequestArgs(W),Q={method:$.method,headers:$.headers,agent:this.clientSettings.httpAgent},Y=W.enableRateLimitSave!==!1,G=W.autoConnect!==!1;if($.body)R.setBodyLengthHeader(Q,$.body);let K={url:$.url,options:Q,body:$.body,rateLimitSaver:Y?this.saveRateLimit.bind(this,$.rawUrl):void 0,payloadIsError:W.payloadIsError,compression:(Z=(J=W.compression)!==null&&J!==void 0?J:this.clientSettings.compression)!==null&&Z!==void 0?Z:!0},z=new V1(K);if(!G)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 J=encodeURIComponent(W.username)+":"+encodeURIComponent(W.password);this.basicToken=Buffer.from(J).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 S1({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,J){var Z;let $;for(let Q of this.getPlugins()){let Y=await((Z=Q[W])===null||Z===void 0?void 0:Z.call(Q,J));if(Y&&Y instanceof F1)$=Y}return $}writeAuthHeaders({headers:W,bodyInSignature:J,url:Z,method:$,query:Q,body:Y}){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 "+n.getAuthHeader(this.clientId,this.clientSecret);else if(this.consumerSecret&&this._oauth){let G=J?R.mergeQueryAndBodyForOAuth(Q,Y):Q,K=this._oauth.authorize({url:Z.toString(),method:$,data:G},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:J,query:Z={},body:$={},headers:Q,forceBodyMode:Y,enableAuth:G,params:K}){let z=void 0;if(J=J.toUpperCase(),Q=Q!==null&&Q!==void 0?Q:{},!Q["x-user-agent"])Q["x-user-agent"]="Node.twitter-api-v2";let X=this.getUrlObjectFromUrlString(W),B=X.origin+X.pathname;if(K)R.applyRequestParametersToUrl(X,K);let M=R.formatQueryToString(Z);if(R.moveUrlQueryParamsIntoObject(X,M),!($ instanceof Buffer))n0($);let D=Y!==null&&Y!==void 0?Y:R.autoDetectBodyType(X);if(G!==!1){let S=r.BODY_METHODS.has(J)&&D==="url";Q=this.writeAuthHeaders({headers:Q,bodyInSignature:S,method:J,query:M,url:X,body:$})}if(r.BODY_METHODS.has(J))z=R.constructBodyParams($,Q,D)||void 0;return R.addQueryParamsToUrl(X,M),{rawUrl:B,url:X,method:J,headers:Q,body:z}}async applyPreRequestConfigHooks(W){var J;let Z=this.getUrlObjectFromUrlString(W.url);for(let $ of this.getPlugins()){let Q=await((J=$.onBeforeRequestConfig)===null||J===void 0?void 0:J.call($,{client:this,url:Z,params:W}));if(Q)return Q}}applyPreStreamRequestConfigHooks(W){var J;let Z=this.getUrlObjectFromUrlString(W.url);for(let $ of this.getPlugins())(J=$.onBeforeStreamRequestConfig)===null||J===void 0||J.call($,{client:this,url:Z,params:W})}async applyPreRequestHooks(W,J,Z){await this.applyPluginMethod("onBeforeRequest",{client:this,url:this.getUrlObjectFromUrlString(W.url),params:W,computedParams:J,requestOptions:Z})}async applyPostRequestHooks(W,J,Z,$){return await this.applyPluginMethod("onAfterRequest",{client:this,url:this.getUrlObjectFromUrlString(W.url),params:W,computedParams:J,requestOptions:Z,response:$})}applyResponseErrorHooks(W,J,Z,$){return $.catch(e0.bind(this,W,J,Z))}}r.BODY_METHODS=new Set(["POST","PUT","PATCH"]);class g{constructor(W,J={}){if(this._currentUser=null,this._currentUserV2=null,W instanceof g)this._requestMaker=W._requestMaker;else this._requestMaker=new r(J),this._requestMaker.initializeToken(W)}setPrefix(W){this._prefix=W}cloneWithPrefix(W){let J=this.constructor(this);return J.setPrefix(W),J}getActiveTokens(){return this._requestMaker.getActiveTokens()}getPlugins(){return this._requestMaker.getPlugins()}getPluginOfType(W){return this.getPlugins().find((J)=>J instanceof W)}hasHitRateLimit(W){var J;if(this.isRateLimitStatusObsolete(W))return!1;return((J=this.getLastRateLimitStatus(W))===null||J===void 0?void 0:J.remaining)===0}isRateLimitStatusObsolete(W){let J=this.getLastRateLimitStatus(W);if(J===void 0)return!0;return J.reset*1000<Date.now()}getLastRateLimitStatus(W){let J=W.match(/^https?:\/\//)?W:this._prefix+W;return this._requestMaker.getRateLimits()[J]}getCurrentUserObject(W=!1){if(!W&&this._currentUser){if(this._currentUser.value)return Promise.resolve(this._currentUser.value);return this._currentUser.promise}return this._currentUser=L4(()=>this.get("account/verify_credentials.json",{tweet_mode:"extended"},{prefix:A})),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=L4(()=>this.get("users/me",void 0,{prefix:y})),this._currentUserV2.promise}async get(W,J={},{fullResponse:Z,prefix:$=this._prefix,...Q}={}){if($)W=$+W;let Y=await this._requestMaker.send({url:W,method:"GET",query:J,...Q});return Z?Y:Y.data}async delete(W,J={},{fullResponse:Z,prefix:$=this._prefix,...Q}={}){if($)W=$+W;let Y=await this._requestMaker.send({url:W,method:"DELETE",query:J,...Q});return Z?Y:Y.data}async post(W,J,{fullResponse:Z,prefix:$=this._prefix,...Q}={}){if($)W=$+W;let Y=await this._requestMaker.send({url:W,method:"POST",body:J,...Q});return Z?Y:Y.data}async put(W,J,{fullResponse:Z,prefix:$=this._prefix,...Q}={}){if($)W=$+W;let Y=await this._requestMaker.send({url:W,method:"PUT",body:J,...Q});return Z?Y:Y.data}async patch(W,J,{fullResponse:Z,prefix:$=this._prefix,...Q}={}){if($)W=$+W;let Y=await this._requestMaker.send({url:W,method:"PATCH",body:J,...Q});return Z?Y:Y.data}getStream(W,J,{prefix:Z=this._prefix,...$}={}){return this._requestMaker.sendStream({url:Z?Z+W:W,method:"GET",query:J,...$})}postStream(W,J,{prefix:Z=this._prefix,...$}={}){return this._requestMaker.sendStream({url:Z?Z+W:W,method:"POST",body:J,...$})}}class f extends g{constructor(W){if(!(W instanceof g))throw Error("You must instance SubTwitterApi instance from existing TwitterApi instance.");super(W)}}class e extends t{constructor(){super(...arguments);this.hasFinishedFetch=!1}refreshInstanceFromResult(W,J){let Z=W.data;if(this._rateLimit=W.rateLimit,J)this._realData.push(...Z),this.hasFinishedFetch=Z.length===0}getNextQueryParams(W){let J=BigInt(this._realData[this._realData.length-1].id_str);return{...this.injectQueryParams(W),max_id:(J-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 H4 extends e{constructor(){super(...arguments);this._endpoint="statuses/home_timeline.json"}}class U4 extends e{constructor(){super(...arguments);this._endpoint="statuses/mentions_timeline.json"}}class y1 extends e{constructor(){super(...arguments);this._endpoint="statuses/user_timeline.json"}}class S4 extends e{constructor(){super(...arguments);this._endpoint="lists/statuses.json"}}class A1 extends e{constructor(){super(...arguments);this._endpoint="favorites/list.json"}}class O4 extends F{constructor(){super(...arguments);this._endpoint="mutes/users/list.json"}refreshInstanceFromResult(W,J){let Z=W.data;if(this._rateLimit=W.rateLimit,J)this._realData.users.push(...Z.users),this._realData.next_cursor=Z.next_cursor}getPageLengthFromRequest(W){return W.data.users.length}getItemArray(){return this.users}get users(){return this._realData.users}}class R4 extends F{constructor(){super(...arguments);this._endpoint="mutes/users/ids.json",this._maxResultsWhenFetchLast=5000}refreshInstanceFromResult(W,J){let Z=W.data;if(this._rateLimit=W.rateLimit,J)this._realData.ids.push(...Z.ids),this._realData.next_cursor=Z.next_cursor}getPageLengthFromRequest(W){return W.data.ids.length}getItemArray(){return this.ids}get ids(){return this._realData.ids}}class f4 extends F{constructor(){super(...arguments);this._endpoint="followers/list.json"}refreshInstanceFromResult(W,J){let Z=W.data;if(this._rateLimit=W.rateLimit,J)this._realData.users.push(...Z.users),this._realData.next_cursor=Z.next_cursor}getPageLengthFromRequest(W){return W.data.users.length}getItemArray(){return this.users}get users(){return this._realData.users}}class _4 extends F{constructor(){super(...arguments);this._endpoint="followers/ids.json",this._maxResultsWhenFetchLast=5000}refreshInstanceFromResult(W,J){let Z=W.data;if(this._rateLimit=W.rateLimit,J)this._realData.ids.push(...Z.ids),this._realData.next_cursor=Z.next_cursor}getPageLengthFromRequest(W){return W.data.ids.length}getItemArray(){return this.ids}get ids(){return this._realData.ids}}class k4 extends F{constructor(){super(...arguments);this._endpoint="friends/list.json"}refreshInstanceFromResult(W,J){let Z=W.data;if(this._rateLimit=W.rateLimit,J)this._realData.users.push(...Z.users),this._realData.next_cursor=Z.next_cursor}getPageLengthFromRequest(W){return W.data.users.length}getItemArray(){return this.users}get users(){return this._realData.users}}class C4 extends F{constructor(){super(...arguments);this._endpoint="friends/ids.json",this._maxResultsWhenFetchLast=5000}refreshInstanceFromResult(W,J){let Z=W.data;if(this._rateLimit=W.rateLimit,J)this._realData.ids.push(...Z.ids),this._realData.next_cursor=Z.next_cursor}getPageLengthFromRequest(W){return W.data.ids.length}getItemArray(){return this.ids}get ids(){return this._realData.ids}}class I4 extends t{constructor(){super(...arguments);this._endpoint="users/search.json"}refreshInstanceFromResult(W,J){let Z=W.data;if(this._rateLimit=W.rateLimit,J)this._realData.push(...Z)}getNextQueryParams(W){var J;let Z=Number((J=this._queryParams.page)!==null&&J!==void 0?J:"1");return{...this._queryParams,page:Z+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 h1 extends F{constructor(){super(...arguments);this._endpoint="friendships/incoming.json",this._maxResultsWhenFetchLast=5000}refreshInstanceFromResult(W,J){let Z=W.data;if(this._rateLimit=W.rateLimit,J)this._realData.ids.push(...Z.ids),this._realData.next_cursor=Z.next_cursor}getPageLengthFromRequest(W){return W.data.ids.length}getItemArray(){return this.ids}get ids(){return this._realData.ids}}class b4 extends h1{constructor(){super(...arguments);this._endpoint="friendships/outgoing.json"}}class g1 extends F{refreshInstanceFromResult(W,J){let Z=W.data;if(this._rateLimit=W.rateLimit,J)this._realData.lists.push(...Z.lists),this._realData.next_cursor=Z.next_cursor}getPageLengthFromRequest(W){return W.data.lists.length}getItemArray(){return this.lists}get lists(){return this._realData.lists}}class T4 extends g1{constructor(){super(...arguments);this._endpoint="lists/memberships.json"}}class v4 extends g1{constructor(){super(...arguments);this._endpoint="lists/ownerships.json"}}class P4 extends g1{constructor(){super(...arguments);this._endpoint="lists/subscriptions.json"}}class w4 extends F{refreshInstanceFromResult(W,J){let Z=W.data;if(this._rateLimit=W.rateLimit,J)this._realData.users.push(...Z.users),this._realData.next_cursor=Z.next_cursor}getPageLengthFromRequest(W){return W.data.users.length}getItemArray(){return this.users}get users(){return this._realData.users}}class V4 extends w4{constructor(){super(...arguments);this._endpoint="lists/members.json"}}class q4 extends w4{constructor(){super(...arguments);this._endpoint="lists/subscribers.json"}}class W1 extends f{constructor(){super(...arguments);this._prefix=A}singleTweet(W,J={}){return this.get("statuses/show.json",{tweet_mode:"extended",id:W,...J})}tweets(W,J={}){return this.post("statuses/lookup.json",{tweet_mode:"extended",id:W,...J})}oembedTweet(W,J={}){return this.get("oembed",{url:`https://x.com/i/statuses/${W}`,...J},{prefix:"https://publish.x.com/"})}async homeTimeline(W={}){let J={tweet_mode:"extended",...W},Z=await this.get("statuses/home_timeline.json",J,{fullResponse:!0});return new H4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async mentionTimeline(W={}){let J={tweet_mode:"extended",...W},Z=await this.get("statuses/mentions_timeline.json",J,{fullResponse:!0});return new U4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async userTimeline(W,J={}){let Z={tweet_mode:"extended",user_id:W,...J},$=await this.get("statuses/user_timeline.json",Z,{fullResponse:!0});return new y1({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:Z})}async userTimelineByUsername(W,J={}){let Z={tweet_mode:"extended",screen_name:W,...J},$=await this.get("statuses/user_timeline.json",Z,{fullResponse:!0});return new y1({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:Z})}async favoriteTimeline(W,J={}){let Z={tweet_mode:"extended",user_id:W,...J},$=await this.get("favorites/list.json",Z,{fullResponse:!0});return new A1({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:Z})}async favoriteTimelineByUsername(W,J={}){let Z={tweet_mode:"extended",screen_name:W,...J},$=await this.get("favorites/list.json",Z,{fullResponse:!0});return new A1({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:Z})}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 J={tweet_mode:"extended",...W},Z=await this.get("mutes/users/list.json",J,{fullResponse:!0});return new O4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async listMutedUserIds(W={}){let J={stringify_ids:!0,...W},Z=await this.get("mutes/users/ids.json",J,{fullResponse:!0});return new R4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async userFriendList(W={}){let J={...W},Z=await this.get("friends/list.json",J,{fullResponse:!0});return new k4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async userFollowerList(W={}){let J={...W},Z=await this.get("followers/list.json",J,{fullResponse:!0});return new f4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async userFollowerIds(W={}){let J={stringify_ids:!0,...W},Z=await this.get("followers/ids.json",J,{fullResponse:!0});return new _4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async userFollowingIds(W={}){let J={stringify_ids:!0,...W},Z=await this.get("friends/ids.json",J,{fullResponse:!0});return new C4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async searchUsers(W,J={}){let Z={q:W,tweet_mode:"extended",page:1,...J},$=await this.get("users/search.json",Z,{fullResponse:!0});return new I4({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:Z})}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 J={stringify_ids:!0,...W},Z=await this.get("friendships/incoming.json",J,{fullResponse:!0});return new h1({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async friendshipsOutgoing(W={}){let J={stringify_ids:!0,...W},Z=await this.get("friendships/outgoing.json",J,{fullResponse:!0});return new b4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}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 J={tweet_mode:"extended",...W},Z=await this.get("lists/members.json",J,{fullResponse:!0});return new V4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}listGetMember(W){return this.get("lists/members/show.json",{tweet_mode:"extended",...W})}async listMemberships(W={}){let J={tweet_mode:"extended",...W},Z=await this.get("lists/memberships.json",J,{fullResponse:!0});return new T4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async listOwnerships(W={}){let J={tweet_mode:"extended",...W},Z=await this.get("lists/ownerships.json",J,{fullResponse:!0});return new v4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async listStatuses(W){let J={tweet_mode:"extended",...W},Z=await this.get("lists/statuses.json",J,{fullResponse:!0});return new S4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}async listSubscribers(W={}){let J={tweet_mode:"extended",...W},Z=await this.get("lists/subscribers.json",J,{fullResponse:!0});return new q4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}listGetSubscriber(W){return this.get("lists/subscribers/show.json",{tweet_mode:"extended",...W})}async listSubscriptions(W={}){let J={tweet_mode:"extended",...W},Z=await this.get("lists/subscriptions.json",J,{fullResponse:!0});return new P4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}mediaInfo(W){return this.get("media/upload.json",{command:"STATUS",media_id:W},{prefix:w})}filterStream({autoConnect:W,...J}={}){let Z={};for(let[Q,Y]of Object.entries(J))if(Q==="follow"||Q==="track")Z[Q]=Y.toString();else if(Q==="locations"){let G=Y;Z.locations=P1(G).map((K)=>`${K.lng},${K.lat}`).join(",")}else Z[Q]=Y;return this.stream.postStream("statuses/filter.json",Z,{autoConnect:W})}sampleStream({autoConnect:W,...J}={}){return this.stream.getStream("statuses/sample.json",J,{autoConnect:W})}get stream(){let W=new E1(this);return W.setPrefix(d0),W}trendsByPlace(W,J={}){return this.get("trends/place.json",{id:W,...J})}trendsAvailable(){return this.get("trends/available.json")}trendsClosest(W,J){return this.get("trends/closest.json",{lat:W,long:J})}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 E from"fs";async function y4(W){let J=await A4(W);if(typeof J==="number")return new Promise((Z,$)=>{E.readFile(J,(Q,Y)=>{if(Q)return $(Q);Z(Y)})});else if(J instanceof Buffer)return J;else return J.readFile()}function A4(W){if(typeof W==="string")return E.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 Q6(W){if(typeof W==="number")return(await new Promise((Z,$)=>{E.fstat(W,(Q,Y)=>{if(Q)$(Q);Z(Y)})})).size;else if(W instanceof Buffer)return W.length;else return(await W.stat()).size}function Y6(W,J,Z){if(typeof Z==="string")return Z;else if(typeof W==="string"&&!J)return s6(W);else if(typeof J==="string")return a6(J);throw Error("You must specify type if file is a file handle or Buffer.")}function s6(W){if(W.endsWith(".jpeg")||W.endsWith(".jpg"))return L.Jpeg;if(W.endsWith(".png"))return L.Png;if(W.endsWith(".webp"))return L.Webp;if(W.endsWith(".gif"))return L.Gif;if(W.endsWith(".mpeg4")||W.endsWith(".mp4"))return L.Mp4;if(W.endsWith(".mov")||W.endsWith(".mov"))return L.Mov;if(W.endsWith(".srt"))return L.Srt;return D4({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"}),L.Jpeg}function a6(W){if(D4({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 L.Gif;if(W==="jpg")return L.Jpeg;if(W==="png")return L.Png;if(W==="webp")return L.Webp;if(W==="srt")return L.Srt;if(W==="mp4"||W==="longmp4")return L.Mp4;if(W==="mov")return L.Mov;return W}function G6(W,J){if(W===L.Mp4||W===L.Mov)return J==="tweet"?"TweetVideo":"DmVideo";if(W===L.Gif)return J==="tweet"?"TweetGif":"DmGif";if(W===L.Srt)return"Subtitles";else return J==="tweet"?"TweetImage":"DmImage"}function h4(W){return new Promise((J)=>setTimeout(J,W*1000))}async function g4(W,J,Z=0,$){if(W instanceof Buffer){let Y=W.slice(Z,Z+J);return[Y,Y.length]}if(!$)throw Error("Well, we will need a buffer to store file content.");let Q;if(typeof W==="number")Q=await new Promise((Y,G)=>{E.read(W,$,0,J,Z,(K,z)=>{if(K)G(K);Y(z)})});else Q=(await W.read($,0,J,Z)).bytesRead;return[$,Q]}var E4="media/upload.json";class J1 extends W1{constructor(){super(...arguments);this._prefix=A}get readOnly(){return this}tweet(W,J={}){let Z={status:W,tweet_mode:"extended",...J};return this.post("statuses/update.json",Z)}async quote(W,J,Z={}){let $="https://x.com/i/statuses/"+J;return this.tweet(W,{...Z,attachment_url:$})}async tweetThread(W){let J=[];for(let Z of W){let $=J.length?J[J.length-1]:null,Q={...typeof Z==="string"?{status:Z}:Z},Y=$?$.id_str:Q.in_reply_to_status_id,G=Q.status;if(Y)J.push(await this.reply(G,Y,Q));else J.push(await this.tweet(G,Q))}return J}reply(W,J,Z={}){return this.tweet(W,{auto_populate_reply_metadata:!0,in_reply_to_status_id:J,...Z})}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,J={}){let Z={banner:await y4(W),...J};return this.post("account/update_profile_banner.json",Z,{forceBodyMode:"form-data"})}async updateAccountProfileImage(W,J={}){let Z={tweet_mode:"extended",image:await y4(W),...J};return this.post("account/update_profile_image.json",Z,{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 Z=W.user_id&&H1(W.user_id)||W.screen_name&&H1(W.screen_name)?"lists/members/create_all.json":"lists/members/create.json";return this.post(Z,W)}removeListMembers(W){let Z=W.user_id&&H1(W.user_id)||W.screen_name&&H1(W.screen_name)?"lists/members/destroy_all.json":"lists/members/destroy.json";return this.post(Z,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,J){return this.post("media/metadata/create.json",{media_id:W,...J},{prefix:w,forceBodyMode:"json"})}createMediaSubtitles(W,J){return this.post("media/subtitles/create.json",{media_id:W,media_category:"TweetVideo",subtitle_info:{subtitles:J}},{prefix:w,forceBodyMode:"json"})}deleteMediaSubtitles(W,...J){return this.post("media/subtitles/delete.json",{media_id:W,media_category:"TweetVideo",subtitle_info:{subtitles:J.map((Z)=>({language_code:Z}))}},{prefix:w,forceBodyMode:"json"})}async uploadMedia(W,J={},Z=!1){var $;let Q=($=J.chunkLength)!==null&&$!==void 0?$:1048576,{fileHandle:Y,mediaCategory:G,fileSize:K,mimeType:z}=await this.getUploadMediaRequirements(W,J);try{let X=await this.post(E4,{command:"INIT",total_bytes:K,media_type:z,media_category:G,additional_owners:J.additionalOwners,shared:J.shared?!0:void 0},{prefix:w});await this.mediaChunkedUpload(Y,Q,X.media_id_string,J.maxConcurrentUploads);let B=await this.post(E4,{command:"FINALIZE",media_id:X.media_id_string},{prefix:w});if(B.processing_info&&B.processing_info.state!=="succeeded")await this.awaitForMediaProcessingCompletion(B);if(Z)return B;else return B.media_id_string}finally{if(typeof W==="number")m4.close(W,()=>{});else if(typeof Y==="object"&&!(Y instanceof Buffer))Y.close()}}async awaitForMediaProcessingCompletion(W){var J;while(!0){W=await this.mediaInfo(W.media_id_string);let{processing_info:Z}=W;if(!Z||Z.state==="succeeded")return;if((J=Z.error)===null||J===void 0?void 0:J.code){let{name:$,message:Q}=Z.error;throw Error(`Failed to process media: ${$} - ${Q}.`)}if(Z.state==="failed")throw Error("Failed to process the media.");if(Z.check_after_secs)await h4(Z.check_after_secs);else await h4(5)}}async getUploadMediaRequirements(W,{mimeType:J,type:Z,target:$,longVideo:Q}={}){let Y;try{Y=await A4(W);let G=Y6(W,Z,J),K;if(G===L.Mp4&&(!J&&!Z&&$!=="dm"||Q))K="amplify_video";else K=G6(G,$!==null&&$!==void 0?$:"tweet");return{fileHandle:Y,mediaCategory:K,fileSize:await Q6(Y),mimeType:G}}catch(G){if(typeof W==="number")m4.close(W,()=>{});else if(typeof Y==="object"&&!(Y instanceof Buffer))Y.close();throw G}}async mediaChunkedUpload(W,J,Z,$=3){let Q=0;if($<1)throw RangeError("Bad maxConcurrentUploads parameter.");let Y=W instanceof Buffer?void 0:Buffer.alloc(J),G,K,z=0;[G,K]=await g4(W,J,z,Y),z+=K;let X=new Set;while(K){let B=G.slice(0,K);if(B.length){let M=this.post(E4,{command:"APPEND",media_id:Z,segment_index:Q,media:B},{prefix:w});X.add(M),M.then(()=>{X.delete(M)}),Q++}if(X.size>=$)await Promise.race(X);[G,K]=await g4(W,J,z,Y),z+=K}await Promise.all([...X])}}class K6 extends J1{constructor(){super(...arguments);this._prefix=A}get readWrite(){return this}sendDm({recipient_id:W,custom_profile_id:J,...Z}){let $={event:{type:h.Create,[h.Create]:{target:{recipient_id:W},message_data:Z}}};if(J)$.event[h.Create].custom_profile_id=J;return this.post("direct_messages/events/new.json",$,{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 J={...W},Z=await this.get("direct_messages/events/list.json",J,{fullResponse:!0});return new N4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}newWelcomeDm(W,J){let Z={[h.WelcomeCreate]:{name:W,message_data:J}};return this.post("direct_messages/welcome_messages/new.json",Z,{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,J){let Z={message_data:J};return this.put("direct_messages/welcome_messages/update.json",Z,{forceBodyMode:"json",query:{id:W}})}async listWelcomeDms(W={}){let J={...W},Z=await this.get("direct_messages/welcome_messages/list.json",J,{fullResponse:!0});return new x4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J})}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 J={...W};return this.get("direct_messages/welcome_messages/rules/list.json",J)}async setWelcomeDm(W,J=!0){var Z;let $=await this.listWelcomeDmRules();if((Z=$.welcome_message_rules)===null||Z===void 0?void 0:Z.length){for(let Q of $.welcome_message_rules)if(await this.deleteWelcomeDmRule(Q.id),J)await this.deleteWelcomeDm(Q.welcome_message_id)}return this.newWelcomeDmRule(W)}markDmAsRead(W,J){return this.post("direct_messages/mark_read.json",{last_read_event_id:W,recipient_id:J},{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 Z=W[h.Create].message_data.attachment;if(!Z)throw Error("The given direct message doesn't contain any attachment");W=Z.media.media_url_https}let J=await this.get(W,void 0,{forceParseMode:"buffer",prefix:""});if(!J.length)throw Error("Image not found. Make sure you are logged with credentials able to access direct messages, and check the URL.");return J}}var E1=K6;class x{constructor(W){this.result=W}get tweets(){return x.tweets(this.result)}static tweets(W){var J,Z;return(Z=(J=W.includes)===null||J===void 0?void 0:J.tweets)!==null&&Z!==void 0?Z:[]}tweetById(W){return x.tweetById(this.result,W)}static tweetById(W,J){return this.tweets(W).find((Z)=>Z.id===J)}retweet(W){return x.retweet(this.result,W)}static retweet(W,J){var Z;let $=((Z=J.referenced_tweets)!==null&&Z!==void 0?Z:[]).filter((Q)=>Q.type==="retweeted").map((Q)=>Q.id);return this.tweets(W).find((Q)=>$.includes(Q.id))}quote(W){return x.quote(this.result,W)}static quote(W,J){var Z;let $=((Z=J.referenced_tweets)!==null&&Z!==void 0?Z:[]).filter((Q)=>Q.type==="quoted").map((Q)=>Q.id);return this.tweets(W).find((Q)=>$.includes(Q.id))}repliedTo(W){return x.repliedTo(this.result,W)}static repliedTo(W,J){var Z;let $=((Z=J.referenced_tweets)!==null&&Z!==void 0?Z:[]).filter((Q)=>Q.type==="replied_to").map((Q)=>Q.id);return this.tweets(W).find((Q)=>$.includes(Q.id))}author(W){return x.author(this.result,W)}static author(W,J){let Z=J.author_id;return Z?this.users(W).find(($)=>$.id===Z):void 0}repliedToAuthor(W){return x.repliedToAuthor(this.result,W)}static repliedToAuthor(W,J){let Z=J.in_reply_to_user_id;return Z?this.users(W).find(($)=>$.id===Z):void 0}get users(){return x.users(this.result)}static users(W){var J,Z;return(Z=(J=W.includes)===null||J===void 0?void 0:J.users)!==null&&Z!==void 0?Z:[]}userById(W){return x.userById(this.result,W)}static userById(W,J){return this.users(W).find((Z)=>Z.id===J)}pinnedTweet(W){return x.pinnedTweet(this.result,W)}static pinnedTweet(W,J){return J.pinned_tweet_id?this.tweets(W).find((Z)=>Z.id===J.pinned_tweet_id):void 0}get media(){return x.media(this.result)}static media(W){var J,Z;return(Z=(J=W.includes)===null||J===void 0?void 0:J.media)!==null&&Z!==void 0?Z:[]}medias(W){return x.medias(this.result,W)}static medias(W,J){var Z,$;let Q=($=(Z=J.attachments)===null||Z===void 0?void 0:Z.media_keys)!==null&&$!==void 0?$:[];return this.media(W).filter((Y)=>Q.includes(Y.media_key))}get polls(){return x.polls(this.result)}static polls(W){var J,Z;return(Z=(J=W.includes)===null||J===void 0?void 0:J.polls)!==null&&Z!==void 0?Z:[]}poll(W){return x.poll(this.result,W)}static poll(W,J){var Z,$;let Q=($=(Z=J.attachments)===null||Z===void 0?void 0:Z.poll_ids)!==null&&$!==void 0?$:[];if(Q.length){let Y=Q[0];return this.polls(W).find((G)=>G.id===Y)}return}get places(){return x.places(this.result)}static places(W){var J,Z;return(Z=(J=W.includes)===null||J===void 0?void 0:J.places)!==null&&Z!==void 0?Z:[]}place(W){return x.place(this.result,W)}static place(W,J){var Z;let $=(Z=J.geo)===null||Z===void 0?void 0:Z.place_id;return $?this.places(W).find((Q)=>Q.id===$):void 0}listOwner(W){return x.listOwner(this.result,W)}static listOwner(W,J){let Z=J.owner_id;return Z?this.users(W).find(($)=>$.id===Z):void 0}spaceCreator(W){return x.spaceCreator(this.result,W)}static spaceCreator(W,J){let Z=J.creator_id;return Z?this.users(W).find(($)=>$.id===Z):void 0}spaceHosts(W){return x.spaceHosts(this.result,W)}static spaceHosts(W,J){var Z;let $=(Z=J.host_ids)!==null&&Z!==void 0?Z:[];return this.users(W).filter((Q)=>$.includes(Q.id))}spaceSpeakers(W){return x.spaceSpeakers(this.result,W)}static spaceSpeakers(W,J){var Z;let $=(Z=J.speaker_ids)!==null&&Z!==void 0?Z:[];return this.users(W).filter((Q)=>$.includes(Q.id))}spaceInvitedUsers(W){return x.spaceInvitedUsers(this.result,W)}static spaceInvitedUsers(W,J){var Z;let $=(Z=J.invited_user_ids)!==null&&Z!==void 0?Z:[];return this.users(W).filter((Q)=>$.includes(Q.id))}}class m1 extends j4{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 J=this._realData.includes;for(let[Z,$]of Object.entries(W.includes)){if(!J[Z])J[Z]=[];J[Z]=[...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 x(this._realData);if(this._includesInstance)return this._includesInstance;return this._includesInstance=new x(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 T extends m1{refreshInstanceFromResult(W,J){var Z;let $=W.data,Q=(Z=$.data)!==null&&Z!==void 0?Z:[];if(this._rateLimit=W.rateLimit,!this._realData.data)this._realData.data=[];if(J)this._realData.meta.result_count+=$.meta.result_count,this._realData.meta.next_token=$.meta.next_token,this._realData.data.push(...Q);else this._realData.meta.result_count+=$.meta.result_count,this._realData.meta.previous_token=$.meta.previous_token,this._realData.data.unshift(...Q);this.updateIncludes($)}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 J,Z;return(Z=(J=W.data.data)===null||J===void 0?void 0:J.length)!==null&&Z!==void 0?Z:0}isFetchLastOver(W){var J;return!((J=W.data.data)===null||J===void 0?void 0:J.length)||!this.canFetchNextPage(W.data)}canFetchNextPage(W){var J;return!!((J=W.meta)===null||J===void 0?void 0:J.next_token)}}class c4 extends m1{refreshInstanceFromResult(W,J){var Z;let $=W.data,Q=(Z=$.data)!==null&&Z!==void 0?Z:[];if(this._rateLimit=W.rateLimit,!this._realData.data)this._realData.data=[];if(J)this._realData.meta.oldest_id=$.meta.oldest_id,this._realData.meta.result_count+=$.meta.result_count,this._realData.meta.next_token=$.meta.next_token,this._realData.data.push(...Q);else this._realData.meta.newest_id=$.meta.newest_id,this._realData.meta.result_count+=$.meta.result_count,this._realData.data.unshift(...Q);this.updateIncludes($)}getNextQueryParams(W){this.assertUsable();let J={...this.injectQueryParams(W)};if(this._realData.meta.next_token)J.next_token=this._realData.meta.next_token;else{if(J.start_time)J.since_id=this.dateStringToSnowflakeId(J.start_time),delete J.start_time;if(J.end_time)delete J.end_time;J.until_id=this._realData.meta.oldest_id}return J}getPreviousQueryParams(W){return this.assertUsable(),{...this.injectQueryParams(W),since_id:this._realData.meta.newest_id}}getPageLengthFromRequest(W){var J,Z;return(Z=(J=W.data.data)===null||J===void 0?void 0:J.length)!==null&&Z!==void 0?Z:0}isFetchLastOver(W){var J;return!((J=W.data.data)===null||J===void 0?void 0:J.length)||!this.canFetchNextPage(W.data)}canFetchNextPage(W){return!!W.meta.next_token}getItemArray(){return this.tweets}dateStringToSnowflakeId(W){let J=BigInt("1288834974657"),Z=new Date(W);if(isNaN(Z.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(Z.valueOf())-J<<BigInt("22")).toString()}get tweets(){var W;return(W=this._realData.data)!==null&&W!==void 0?W:[]}get meta(){return super.meta}}class Z1 extends T{refreshInstanceFromResult(W,J){super.refreshInstanceFromResult(W,J);let Z=W.data;if(J)this._realData.meta.oldest_id=Z.meta.oldest_id;else this._realData.meta.newest_id=Z.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 u4 extends c4{constructor(){super(...arguments);this._endpoint="tweets/search/recent"}}class d4 extends c4{constructor(){super(...arguments);this._endpoint="tweets/search/all"}}class p4 extends Z1{constructor(){super(...arguments);this._endpoint="tweets/:id/quote_tweets"}}class l4 extends Z1{constructor(){super(...arguments);this._endpoint="users/:id/timelines/reverse_chronological"}}class n4 extends Z1{constructor(){super(...arguments);this._endpoint="users/:id/tweets"}}class i4 extends Z1{constructor(){super(...arguments);this._endpoint="users/:id/mentions"}}class o4 extends Z1{constructor(){super(...arguments);this._endpoint="users/:id/bookmarks"}}class s4 extends T{get tweets(){var W;return(W=this._realData.data)!==null&&W!==void 0?W:[]}get meta(){return super.meta}getItemArray(){return this.tweets}}class a4 extends s4{constructor(){super(...arguments);this._endpoint="users/:id/liked_tweets"}}class t4 extends s4{constructor(){super(...arguments);this._endpoint="lists/:id/tweets"}}class V extends T{getItemArray(){return this.users}get users(){var W;return(W=this._realData.data)!==null&&W!==void 0?W:[]}get meta(){return super.meta}}class r4 extends V{constructor(){super(...arguments);this._endpoint="users/:id/blocking"}}class e4 extends V{constructor(){super(...arguments);this._endpoint="users/:id/muting"}}class W0 extends V{constructor(){super(...arguments);this._endpoint="users/:id/followers"}}class J0 extends V{constructor(){super(...arguments);this._endpoint="users/:id/following"}}class Z0 extends V{constructor(){super(...arguments);this._endpoint="lists/:id/members"}}class $0 extends V{constructor(){super(...arguments);this._endpoint="lists/:id/followers"}}class Q0 extends V{constructor(){super(...arguments);this._endpoint="tweets/:id/liking_users"}}class Y0 extends V{constructor(){super(...arguments);this._endpoint="tweets/:id/retweeted_by"}}class c1 extends T{getItemArray(){return this.lists}get lists(){var W;return(W=this._realData.data)!==null&&W!==void 0?W:[]}get meta(){return super.meta}}class G0 extends c1{constructor(){super(...arguments);this._endpoint="users/:id/owned_lists"}}class K0 extends c1{constructor(){super(...arguments);this._endpoint="users/:id/list_memberships"}}class z0 extends c1{constructor(){super(...arguments);this._endpoint="users/:id/followed_lists"}}class $1 extends f{constructor(){super(...arguments);this._prefix=o}}class u1 extends T{getItemArray(){return this.events}get events(){var W;return(W=this._realData.data)!==null&&W!==void 0?W:[]}get meta(){return super.meta}}class X0 extends u1{constructor(){super(...arguments);this._endpoint="dm_events"}}class B0 extends u1{constructor(){super(...arguments);this._endpoint="dm_conversations/with/:participant_id/dm_events"}}class M0 extends u1{constructor(){super(...arguments);this._endpoint="dm_conversations/:dm_conversation_id/dm_events"}}class Q1 extends f{constructor(){super(...arguments);this._prefix=y}get labs(){if(this._labs)return this._labs;return this._labs=new $1(this)}async search(W,J={}){let Z=typeof W==="string"?{...J,query:W}:{...W},$=await this.get("tweets/search/recent",Z,{fullResponse:!0});return new u4({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:Z})}async searchAll(W,J={}){let Z={...J,query:W},$=await this.get("tweets/search/all",Z,{fullResponse:!0});return new d4({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:Z})}singleTweet(W,J={}){return this.get("tweets/:id",J,{params:{id:W}})}tweets(W,J={}){return this.get("tweets",{ids:W,...J})}tweetCountRecent(W,J={}){return this.get("tweets/counts/recent",{query:W,...J})}tweetCountAll(W,J={}){return this.get("tweets/counts/all",{query:W,...J})}async tweetRetweetedBy(W,J={}){let{asPaginator:Z,...$}=J,Q=await this.get("tweets/:id/retweeted_by",$,{fullResponse:!0,params:{id:W}});if(!Z)return Q.data;return new Y0({realData:Q.data,rateLimit:Q.rateLimit,instance:this,queryParams:$,sharedParams:{id:W}})}async tweetLikedBy(W,J={}){let{asPaginator:Z,...$}=J,Q=await this.get("tweets/:id/liking_users",$,{fullResponse:!0,params:{id:W}});if(!Z)return Q.data;return new Q0({realData:Q.data,rateLimit:Q.rateLimit,instance:this,queryParams:$,sharedParams:{id:W}})}async homeTimeline(W={}){let J=await this.getCurrentUserV2Object(),Z=await this.get("users/:id/timelines/reverse_chronological",W,{fullResponse:!0,params:{id:J.data.id}});return new l4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:W,sharedParams:{id:J.data.id}})}async userTimeline(W,J={}){let Z=await this.get("users/:id/tweets",J,{fullResponse:!0,params:{id:W}});return new n4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J,sharedParams:{id:W}})}async userMentionTimeline(W,J={}){let Z=await this.get("users/:id/mentions",J,{fullResponse:!0,params:{id:W}});return new i4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J,sharedParams:{id:W}})}async quotes(W,J={}){let Z=await this.get("tweets/:id/quote_tweets",J,{fullResponse:!0,params:{id:W}});return new p4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:J,sharedParams:{id:W}})}async bookmarks(W={}){let J=await this.getCurrentUserV2Object(),Z=await this.get("users/:id/bookmarks",W,{fullResponse:!0,params:{id:J.data.id}});return new o4({realData:Z.data,rateLimit:Z.rateLimit,instance:this,queryParams:W,sharedParams:{id:J.data.id}})}me(W={}){return this.get("users/me",W)}user(W,J={}){return this.get("users/:id",J,{params:{id:W}})}users(W,J={}){let Z=Array.isArray(W)?W.join(","):W;return this.get("users",{...J,ids:Z})}userByUsername(W,J={}){return this.get("users/by/username/:username",J,{params:{username:W}})}usersByUsernames(W,J={}){return W=Array.isArray(W)?W.join(","):W,this.get("users/by",{...J,usernames:W})}async followers(W,J={}){let{asPaginator:Z,...$}=J,Q={id:W};if(!Z)return this.get("users/:id/followers",$,{params:Q});let Y=await this.get("users/:id/followers",$,{fullResponse:!0,params:Q});return new W0({realData:Y.data,rateLimit:Y.rateLimit,instance:this,queryParams:$,sharedParams:Q})}async following(W,J={}){let{asPaginator:Z,...$}=J,Q={id:W};if(!Z)return this.get("users/:id/following",$,{params:Q});let Y=await this.get("users/:id/following",$,{fullResponse:!0,params:Q});return new J0({realData:Y.data,rateLimit:Y.rateLimit,instance:this,queryParams:$,sharedParams:Q})}async userLikedTweets(W,J={}){let Z={id:W},$=await this.get("users/:id/liked_tweets",J,{fullResponse:!0,params:Z});return new a4({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:{...J},sharedParams:Z})}async userBlockingUsers(W,J={}){let Z={id:W},$=await this.get("users/:id/blocking",J,{fullResponse:!0,params:Z});return new r4({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:{...J},sharedParams:Z})}async userMutingUsers(W,J={}){let Z={id:W},$=await this.get("users/:id/muting",J,{fullResponse:!0,params:Z});return new e4({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:{...J},sharedParams:Z})}list(W,J={}){return this.get("lists/:id",J,{params:{id:W}})}async listsOwned(W,J={}){let Z={id:W},$=await this.get("users/:id/owned_lists",J,{fullResponse:!0,params:Z});return new G0({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:{...J},sharedParams:Z})}async listMemberships(W,J={}){let Z={id:W},$=await this.get("users/:id/list_memberships",J,{fullResponse:!0,params:Z});return new K0({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:{...J},sharedParams:Z})}async listFollowed(W,J={}){let Z={id:W},$=await this.get("users/:id/followed_lists",J,{fullResponse:!0,params:Z});return new z0({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:{...J},sharedParams:Z})}async listTweets(W,J={}){let Z={id:W},$=await this.get("lists/:id/tweets",J,{fullResponse:!0,params:Z});return new t4({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:{...J},sharedParams:Z})}async listMembers(W,J={}){let Z={id:W},$=await this.get("lists/:id/members",J,{fullResponse:!0,params:Z});return new Z0({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:{...J},sharedParams:Z})}async listFollowers(W,J={}){let Z={id:W},$=await this.get("lists/:id/followers",J,{fullResponse:!0,params:Z});return new $0({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:{...J},sharedParams:Z})}async listDmEvents(W={}){let J=await this.get("dm_events",W,{fullResponse:!0});return new X0({realData:J.data,rateLimit:J.rateLimit,instance:this,queryParams:{...W}})}async listDmEventsWithParticipant(W,J={}){let Z={participant_id:W},$=await this.get("dm_conversations/with/:participant_id/dm_events",J,{fullResponse:!0,params:Z});return new B0({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:{...J},sharedParams:Z})}async listDmEventsOfConversation(W,J={}){let Z={dm_conversation_id:W},$=await this.get("dm_conversations/:dm_conversation_id/dm_events",J,{fullResponse:!0,params:Z});return new M0({realData:$.data,rateLimit:$.rateLimit,instance:this,queryParams:{...J},sharedParams:Z})}space(W,J={}){return this.get("spaces/:id",J,{params:{id:W}})}spaces(W,J={}){return this.get("spaces",{ids:W,...J})}spacesByCreators(W,J={}){return this.get("spaces/by/creator_ids",{user_ids:W,...J})}searchSpaces(W){return this.get("spaces/search",W)}spaceBuyers(W,J={}){return this.get("spaces/:id/buyers",J,{params:{id:W}})}spaceTweets(W,J={}){return this.get("spaces/:id/tweets",J,{params:{id:W}})}searchStream({autoConnect:W,...J}={}){return this.getStream("tweets/search/stream",J,{payloadIsError:w1,autoConnect:W})}streamRules(W={}){return this.get("tweets/search/stream/rules",W)}updateStreamRules(W,J={}){return this.post("tweets/search/stream/rules",W,{query:J})}sampleStream({autoConnect:W,...J}={}){return this.getStream("tweets/sample/stream",J,{payloadIsError:w1,autoConnect:W})}sample10Stream({autoConnect:W,...J}={}){return this.getStream("tweets/sample10/stream",J,{payloadIsError:w1,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 J=await this.post("compliance/jobs",{type:W.type,name:W.name}),Z=W.ids instanceof Buffer?W.ids:Buffer.from(W.ids.join(`
69
69
  `));return await this.put(J.data.upload_url,Z,{forceBodyMode:"raw",enableAuth:!1,headers:{"Content-Type":"text/plain"},prefix:""}),J}async complianceJobResult(W){let J=W;while(J.status!=="complete"){if(J.status==="expired"||J.status==="failed")throw Error("Job failed to be completed.");await new Promise(($)=>setTimeout($,3500)),J=(await this.complianceJob(W.id)).data}return(await this.get(W.download_url,void 0,{enableAuth:!1,prefix:""})).trim().split(`
70
- `).filter(($)=>$).map(($)=>JSON.parse($))}async usage(W={}){return this.get("usage/tweets",W)}community(W,J={}){return this.get("communities/:id",J,{params:{id:W}})}searchCommunities(W,J={}){return this.get("communities/search",{query:W,...J})}}class Y1 extends $1{constructor(){super(...arguments);this._prefix=o}get readOnly(){return this}}class G1 extends Q1{constructor(){super(...arguments);this._prefix=y}get readOnly(){return this}get labs(){if(this._labs)return this._labs;return this._labs=new Y1(this)}hideReply(W,J){return this.put("tweets/:id/hidden",{hidden:J},{params:{id:W}})}like(W,J){return this.post("users/:id/likes",{tweet_id:J},{params:{id:W}})}unlike(W,J){return this.delete("users/:id/likes/:tweet_id",void 0,{params:{id:W,tweet_id:J}})}retweet(W,J){return this.post("users/:id/retweets",{tweet_id:J},{params:{id:W}})}unretweet(W,J){return this.delete("users/:id/retweets/:tweet_id",void 0,{params:{id:W,tweet_id:J}})}tweet(W,J={}){if(typeof W==="object")J=W;else J={text:W,...J};return this.post("tweets",J)}async uploadMedia(W,J,Z=1048576){let $=J.media_category;if(!J.media_category){if(J.media_type.includes("gif"))$="tweet_gif";else if(J.media_type.includes("image"))$="tweet_image";else if(J.media_type.includes("video"))$="tweet_video"}let Q={additional_owners:J.additional_owners,media_type:J.media_type,total_bytes:W.length,media_category:$},G=(await this.post("media/upload/initialize",Q)).data.id,K=Math.ceil(W.length/Z),z=new Uint8Array(W);for(let B=0;B<K;B++){let M=B*Z,D=Math.min(M+Z,W.length),S=z.slice(M,D),H=Buffer.from(S),m={segment_index:B,media:H};await this.post(`media/upload/${G}/append`,m,{forceBodyMode:"form-data"})}if((await this.post(`media/upload/${G}/finalize`)).data.processing_info)await this.waitForMediaProcessing(G);return G}async waitForMediaProcessing(W){var J;let $=(await this.get("media/upload",{command:"STATUS",media_id:W})).data.processing_info;if(!$)return;switch($.state){case"succeeded":return;case"failed":throw Error(`Media processing failed: ${(J=$.error)===null||J===void 0?void 0:J.message}`);case"pending":case"in_progress":{let Q=$===null||$===void 0?void 0:$.check_after_secs;if(Q&&Q>0)await new Promise((Y)=>setTimeout(Y,Q*1000)),await this.waitForMediaProcessing(W)}}}createMediaMetadata(W,J){return this.post("media/metadata",{id:W,metadata:J})}reply(W,J,Z={}){var $;let Q={in_reply_to_tweet_id:J,...($=Z.reply)!==null&&$!==void 0?$:{}};return this.post("tweets",{text:W,...Z,reply:Q})}quote(W,J,Z={}){return this.tweet(W,{...Z,quote_tweet_id:J})}async tweetThread(W){var J,Z;let $=[];for(let Q of W){let Y=$.length?$[$.length-1]:null,G={...typeof Q==="string"?{text:Q}:Q},K=Y?Y.data.id:(J=G.reply)===null||J===void 0?void 0:J.in_reply_to_tweet_id,z=(Z=G.text)!==null&&Z!==void 0?Z:"";if(K)$.push(await this.reply(z,K,G));else $.push(await this.tweet(z,G))}return $}deleteTweet(W){return this.delete("tweets/:id",void 0,{params:{id:W}})}async bookmark(W){let J=await this.getCurrentUserV2Object();return this.post("users/:id/bookmarks",{tweet_id:W},{params:{id:J.data.id}})}async deleteBookmark(W){let J=await this.getCurrentUserV2Object();return this.delete("users/:id/bookmarks/:tweet_id",void 0,{params:{id:J.data.id,tweet_id:W}})}follow(W,J){return this.post("users/:id/following",{target_user_id:J},{params:{id:W}})}unfollow(W,J){return this.delete("users/:source_user_id/following/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:J}})}block(W,J){return this.post("users/:id/blocking",{target_user_id:J},{params:{id:W}})}unblock(W,J){return this.delete("users/:source_user_id/blocking/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:J}})}mute(W,J){return this.post("users/:id/muting",{target_user_id:J},{params:{id:W}})}unmute(W,J){return this.delete("users/:source_user_id/muting/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:J}})}createList(W){return this.post("lists",W)}updateList(W,J={}){return this.put("lists/:id",J,{params:{id:W}})}removeList(W){return this.delete("lists/:id",void 0,{params:{id:W}})}addListMember(W,J){return this.post("lists/:id/members",{user_id:J},{params:{id:W}})}removeListMember(W,J){return this.delete("lists/:id/members/:user_id",void 0,{params:{id:W,user_id:J}})}subscribeToList(W,J){return this.post("users/:id/followed_lists",{list_id:J},{params:{id:W}})}unsubscribeOfList(W,J){return this.delete("users/:id/followed_lists/:list_id",void 0,{params:{id:W,list_id:J}})}pinList(W,J){return this.post("users/:id/pinned_lists",{list_id:J},{params:{id:W}})}unpinList(W,J){return this.delete("users/:id/pinned_lists/:list_id",void 0,{params:{id:W,list_id:J}})}sendDmInConversation(W,J){return this.post("dm_conversations/:dm_conversation_id/messages",J,{params:{dm_conversation_id:W}})}sendDmToParticipant(W,J){return this.post("dm_conversations/with/:participant_id/messages",J,{params:{participant_id:W}})}createDmConversation(W){return this.post("dm_conversations",W)}}class z6 extends Y1{constructor(){super(...arguments);this._prefix=o}get readWrite(){return this}}var X6=z6;class B6 extends G1{constructor(){super(...arguments);this._prefix=y}get readWrite(){return this}get labs(){if(this._labs)return this._labs;return this._labs=new X6(this)}}var M6=B6;class O1 extends g{get v1(){if(this._v1)return this._v1;return this._v1=new W1(this)}get v2(){if(this._v2)return this._v2;return this._v2=new Q1(this)}async currentUser(W=!1){return await this.getCurrentUserObject(W)}async currentUserV2(W=!1){return await this.getCurrentUserV2Object(W)}search(W,J){return this.v2.search(W,J)}async generateAuthLink(W="oob",{authAccessType:J,linkMode:Z="authenticate",forceLogin:$,screenName:Q}={}){let Y=await this.post("https://api.x.com/oauth/request_token",{oauth_callback:W,x_auth_access_type:J}),G=`https://api.x.com/oauth/${Z}?oauth_token=${encodeURIComponent(Y.oauth_token)}`;if($!==void 0)G+=`&force_login=${encodeURIComponent($)}`;if(Q!==void 0)G+=`&screen_name=${encodeURIComponent(Q)}`;if(this._requestMaker.hasPlugins())this._requestMaker.applyPluginMethod("onOAuth1RequestToken",{client:this._requestMaker,url:G,oauthResult:Y});return{url:G,...Y}}async login(W){let J=this.getActiveTokens();if(J.type!=="oauth-1.0a")throw Error("You must setup TwitterApi instance with consumer keys to accept OAuth 1.0 login");let Z=await this.post("https://api.x.com/oauth/access_token",{oauth_token:J.accessToken,oauth_verifier:W}),$=new this.constructor({appKey:J.appKey,appSecret:J.appSecret,accessToken:Z.oauth_token,accessSecret:Z.oauth_token_secret},this._requestMaker.clientSettings);return{accessToken:Z.oauth_token,accessSecret:Z.oauth_token_secret,userId:Z.user_id,screenName:Z.screen_name,client:$}}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 Z=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(Z.access_token,this._requestMaker.clientSettings)}generateOAuth2AuthLink(W,J={}){var 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 Q=(Z=J.state)!==null&&Z!==void 0?Z:n.generateRandomString(32),Y=n.getCodeVerifier(),G=n.getCodeChallengeFromVerifier(Y),K=($=J.scope)!==null&&$!==void 0?$:"",z=Array.isArray(K)?K.join(" "):K,X=new URL("https://x.com/i/oauth2/authorize"),B={response_type:"code",client_id:this._requestMaker.clientId,redirect_uri:W,state:Q,code_challenge:G,code_challenge_method:"s256",scope:z};R.addQueryParamsToUrl(X,B);let M={url:X.toString(),state:Q,codeVerifier:Y,codeChallenge:G};if(this._requestMaker.hasPlugins())this._requestMaker.applyPluginMethod("onOAuth2RequestToken",{client:this._requestMaker,result:M,redirectUri:W});return M}async loginWithOAuth2({code:W,codeVerifier:J,redirectUri:Z}){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 $=await this.post("https://api.x.com/2/oauth2/token",{code:W,code_verifier:J,redirect_uri:Z,grant_type:"authorization_code",client_id:this._requestMaker.clientId,client_secret:this._requestMaker.clientSecret});return this.parseOAuth2AccessTokenResult($)}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 J=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(J)}async revokeOAuth2Token(W,J="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:J})}parseOAuth2AccessTokenResult(W){let J=new this.constructor(W.access_token,this._requestMaker.clientSettings),Z=W.scope.split(" ").filter(($)=>$);return{client:J,expiresIn:W.expires_in,accessToken:W.access_token,scope:Z,refreshToken:W.refresh_token}}}class R1 extends O1{get v1(){if(this._v1)return this._v1;return this._v1=new J1(this)}get v2(){if(this._v2)return this._v2;return this._v2=new G1(this)}get readOnly(){return this}}class d1 extends f{constructor(){super(...arguments);this._prefix=s}}class p1 extends d1{constructor(){super(...arguments);this._prefix=s}get readOnly(){return this}}class l1 extends f{constructor(){super(...arguments);this._prefix=a}}class n1 extends l1{constructor(){super(...arguments);this._prefix=a}get readOnly(){return this}}class j6 extends n1{constructor(){super(...arguments);this._prefix=a}get readWrite(){return this}}var N6=j6;class x6 extends p1{constructor(){super(...arguments);this._prefix=s}get readWrite(){return this}get sandbox(){if(this._sandbox)return this._sandbox;return this._sandbox=new N6(this)}}var L6=x6;class j0 extends R1{get v1(){if(this._v1)return this._v1;return this._v1=new E1(this)}get v2(){if(this._v2)return this._v2;return this._v2=new M6(this)}get readWrite(){return this}get ads(){if(this._ads)return this._ads;return this._ads=new L6(this)}static getErrors(W){var J;if(typeof W!=="object")return[];if(!("data"in W))return[];return(J=W.data.errors)!==null&&J!==void 0?J:[]}static getProfileImageInSize(W,J){let Z=W.split("/").pop(),$=["normal","bigger","mini"],Q=W;for(let G of $)if(Z.includes(`_${G}`)){Q=W.replace(`_${G}`,"");break}if(J==="original")return Q;let Y=Q.lastIndexOf(".");if(Y!==-1){let G=Q.slice(Y+1);return Q.slice(0,Y)+"_"+J+"."+G}else return Q+"_"+J}}var t6={clientId:process.env.X_CLIENT_ID,clientSecret:process.env.X_SECRET,redirectPath:"/auth/oauth/x/callback",scope:["tweet.read","users.read","offline.access"]};class D6 extends j1{config;client;constructor(W={}){super();this.config={...t6,...W},this.client=new j0({clientId:this.config.clientId,clientSecret:this.config.clientSecret})}redirectUri(){return`${process.env.HOST_NAME??""}${this.config.redirectPath}`}getRedirectUrl(W,J){if(!J)throw Error("XOAuthProvider needs the state and PKCE challenge gemi passes.");let Z=new URL("https://x.com/i/oauth2/authorize"),$={response_type:"code",client_id:this.config.clientId,redirect_uri:this.redirectUri(),state:J.state,code_challenge:J.codeChallenge,code_challenge_method:J.codeChallengeMethod,scope:this.config.scope.join(" ")};for(let[Q,Y]of Object.entries($))Z.searchParams.set(Q,Y);return Z.toString()}async onCallback(W,J){let Z=W.search.get("code");if(!Z)throw new q("missing_code");if(!J?.codeVerifier)throw new q("invalid_state");let $;try{$=await this.client.loginWithOAuth2({code:Z,codeVerifier:J.codeVerifier,redirectUri:this.redirectUri()})}catch(X){throw console.error("X OAuth error: token exchange failed",X),new q("exchange_failed")}let{data:Q}=await $.client.v2.me({"user.fields":["name","username","entities"]}),{name:Y,email:G,id:K="",username:z}=Q??{};return{name:Y,email:G,username:z,providerId:K}}}class N0{describe;rollout;when;serverOnly;salt;constructor(W={}){if(W.rollout!==void 0){let{rollout:J}=W;if(!Number.isFinite(J)||J<0||J>100)throw Error(`A feature's \`rollout\` must be a number between 0 and 100, received ${String(J)}.`)}this.describe=W.describe,this.rollout=W.rollout,this.when=W.when,this.serverOnly=W.serverOnly??!1,this.salt=W.salt}}function r6(W={}){return new N0(W)}class F6 extends x0{rows=new Map;constructor(W={}){super();for(let[J,Z]of Object.entries(W))this.rows.set(J,{key:J,active:Z})}async load(){return[...this.rows.values()].map((W)=>({...W}))}async write(W,J,Z){return this.rows.set(W,{key:W,active:J,updatedBy:Z.actor,updatedAt:new Date}),{actorRecorded:!0}}}export{$5 as viewRouteConfigDefaults,Q8 as translationConfigDefaults,i1 as toRangeHeaderValue,cW as subjectFor,jW as sniffContentType,p5 as scheduleConfigDefaults,a1 as resolveRange,_8 as redisConfigDefaults,O8 as rateLimiterConfigDefaults,I5 as queueConfigDefaults,K1 as parseContentRange,$W as mintSessionToken,WW as middlewareConfigDefaults,M5 as mailConfigDefaults,F8 as logConfigDefaults,ZW as isSessionToken,NW as isActiveContentType,EW as inRollout,rW as imageConfigDefaults,BW as filesystemConfigDefaults,z8 as featuresConfigDefaults,n5 as eventConfigDefaults,mW as evaluateFeature,vW as encodeCursor,a5 as discoverWorkflows,e5 as discoverListeners,s5 as discoverJobs,t5 as discoverCronJobs,r5 as discoverCommands,$8 as defineTranslationConfig,d5 as defineScheduleConfig,J5 as defineRouteConfig,f8 as defineRedisConfig,S8 as defineRateLimiterConfig,C5 as defineQueueConfig,e6 as defineMiddlewareConfig,B5 as defineMailConfig,D8 as defineLogConfig,tW as defineImageConfig,XW as defineFilesystemConfig,K8 as defineFeaturesConfig,r6 as defineFeature,l5 as defineEventConfig,O6 as defineEncryptionConfig,E5 as defineCommandConfig,c5 as defineCommand,bW as defineChangeFeedConfig,GW as defineAuthConfig,PW as decodeCursor,f5 as createWorkflowTableStatements,m5 as commandConfigDefaults,TW as changeFeedConfigDefaults,gW as bucketOf,hW as bucketKey,z4 as bearerToken,KW as authConfigDefaults,o1 as assertDeletablePrefix,Z5 as apiRouteConfigDefaults,D6 as XOAuthProvider,y5 as WorkflowRuntime,V5 as WorkflowCancelledError,o5 as Workflow,P5 as WaitTimeoutError,G5 as ViewRouteDispatcher,nW as UndeclaredFeatureError,w5 as StepTimeoutError,v5 as StepFailedError,q5 as Step,F6 as StaticFeatureFlagSource,aW as Sharp,S5 as Scheduler,Y8 as ScheduleServiceProvider,JW as SESSION_TOKEN_PREFIX,F0 as S3Driver,C8 as RouteServiceProvider,X5 as ResendDriver,k8 as RedisServiceProvider,R0 as RedisRateLimiter,_1 as RedisManager,R8 as RateLimiterServiceProvider,t1 as RateLimiterDriver,QW as RateLimiter,i as RangeNotSatisfiableError,W8 as QueueServiceProvider,A5 as QueueManager,IW as ProviderConnection,_W as OAuthReconnectRequiredError,j1 as OAuthProvider,kW as OAuthConnectionProvider,fW as OAuthConnectionError,q as OAuthCallbackError,U8 as MiddlewareServiceProvider,W5 as MiddlewareRegistry,b5 as MemoryWorkflowStore,T5 as MemoryQueueDriver,E0 as MemoryMcpOAuthStore,U5 as MemoryLockStore,OW as MemoryConnectionStore,VW as MemoryChangeFeedDriver,x5 as McpToolError,D5 as McpRegistry,h0 as McpOAuthServer,H5 as McpHttpServer,L5 as McpCallRefusedError,F5 as McpApiKeyResolver,B8 as MailServiceProvider,j5 as MailManager,H8 as LogServiceProvider,xW as LogManager,FW as LockManager,LW as LockLostError,i5 as Listener,L8 as KernelIdServiceProvider,Q5 as KernelId,k5 as Job,YW as InMemoryRateLimiter,x8 as ImageServiceProvider,sW as ImageOptimizationDriver,eW as ImageManager,Y5 as ISLAND_LOADER_CSP_HASH,DW as HeldLock,u0 as GoogleOAuthProvider,N8 as FilesystemServiceProvider,MW as FilesystemManager,zW as FileSystemDriver,z1 as FileStorageDriver,c as FileNotFoundError,X8 as FeaturesServiceProvider,lW as FeatureSourceReadOnlyError,iW as FeatureScope,uW as FeatureReloadError,pW as FeatureModelMissingError,oW as FeatureManager,dW as FeatureFlagStore,x0 as FeatureFlagSource,N0 as Feature,j8 as EventServiceProvider,k as EventManager,c0 as Event,M8 as EncryptionServiceProvider,UW as EncryptionKeyError,HW as Encrypter,z5 as EmailDriver,SW as DecryptionError,R5 as DatabaseWorkflowStore,_5 as DatabaseQueueDriver,O5 as DatabaseLockStore,G8 as DatabaseFeatureFlagSource,RW as DatabaseConnectionStore,wW as DatabaseChangeFeedDriver,N5 as DEFAULT_MCP_SCOPE,u5 as CronJob,CW as ConnectionManager,I8 as CommandRegistry,h5 as CommandFailed,g5 as Command,AW as ChangeFeedSubscription,J8 as ChangeFeedServiceProvider,yW as ChangeFeedManager,qW as ChangeFeedFullError,k1 as CONSENT_PAGE_HEADERS,U0 as AzureBlobDriver,Z8 as AuthServiceProvider,b1 as AuthManager,K5 as ApiRouteDispatcher};
70
+ `).filter(($)=>$).map(($)=>JSON.parse($))}async usage(W={}){return this.get("usage/tweets",W)}community(W,J={}){return this.get("communities/:id",J,{params:{id:W}})}searchCommunities(W,J={}){return this.get("communities/search",{query:W,...J})}}class Y1 extends $1{constructor(){super(...arguments);this._prefix=o}get readOnly(){return this}}class G1 extends Q1{constructor(){super(...arguments);this._prefix=y}get readOnly(){return this}get labs(){if(this._labs)return this._labs;return this._labs=new Y1(this)}hideReply(W,J){return this.put("tweets/:id/hidden",{hidden:J},{params:{id:W}})}like(W,J){return this.post("users/:id/likes",{tweet_id:J},{params:{id:W}})}unlike(W,J){return this.delete("users/:id/likes/:tweet_id",void 0,{params:{id:W,tweet_id:J}})}retweet(W,J){return this.post("users/:id/retweets",{tweet_id:J},{params:{id:W}})}unretweet(W,J){return this.delete("users/:id/retweets/:tweet_id",void 0,{params:{id:W,tweet_id:J}})}tweet(W,J={}){if(typeof W==="object")J=W;else J={text:W,...J};return this.post("tweets",J)}async uploadMedia(W,J,Z=1048576){let $=J.media_category;if(!J.media_category){if(J.media_type.includes("gif"))$="tweet_gif";else if(J.media_type.includes("image"))$="tweet_image";else if(J.media_type.includes("video"))$="tweet_video"}let Q={additional_owners:J.additional_owners,media_type:J.media_type,total_bytes:W.length,media_category:$},G=(await this.post("media/upload/initialize",Q)).data.id,K=Math.ceil(W.length/Z),z=new Uint8Array(W);for(let B=0;B<K;B++){let M=B*Z,D=Math.min(M+Z,W.length),S=z.slice(M,D),H=Buffer.from(S),m={segment_index:B,media:H};await this.post(`media/upload/${G}/append`,m,{forceBodyMode:"form-data"})}if((await this.post(`media/upload/${G}/finalize`)).data.processing_info)await this.waitForMediaProcessing(G);return G}async waitForMediaProcessing(W){var J;let $=(await this.get("media/upload",{command:"STATUS",media_id:W})).data.processing_info;if(!$)return;switch($.state){case"succeeded":return;case"failed":throw Error(`Media processing failed: ${(J=$.error)===null||J===void 0?void 0:J.message}`);case"pending":case"in_progress":{let Q=$===null||$===void 0?void 0:$.check_after_secs;if(Q&&Q>0)await new Promise((Y)=>setTimeout(Y,Q*1000)),await this.waitForMediaProcessing(W)}}}createMediaMetadata(W,J){return this.post("media/metadata",{id:W,metadata:J})}reply(W,J,Z={}){var $;let Q={in_reply_to_tweet_id:J,...($=Z.reply)!==null&&$!==void 0?$:{}};return this.post("tweets",{text:W,...Z,reply:Q})}quote(W,J,Z={}){return this.tweet(W,{...Z,quote_tweet_id:J})}async tweetThread(W){var J,Z;let $=[];for(let Q of W){let Y=$.length?$[$.length-1]:null,G={...typeof Q==="string"?{text:Q}:Q},K=Y?Y.data.id:(J=G.reply)===null||J===void 0?void 0:J.in_reply_to_tweet_id,z=(Z=G.text)!==null&&Z!==void 0?Z:"";if(K)$.push(await this.reply(z,K,G));else $.push(await this.tweet(z,G))}return $}deleteTweet(W){return this.delete("tweets/:id",void 0,{params:{id:W}})}async bookmark(W){let J=await this.getCurrentUserV2Object();return this.post("users/:id/bookmarks",{tweet_id:W},{params:{id:J.data.id}})}async deleteBookmark(W){let J=await this.getCurrentUserV2Object();return this.delete("users/:id/bookmarks/:tweet_id",void 0,{params:{id:J.data.id,tweet_id:W}})}follow(W,J){return this.post("users/:id/following",{target_user_id:J},{params:{id:W}})}unfollow(W,J){return this.delete("users/:source_user_id/following/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:J}})}block(W,J){return this.post("users/:id/blocking",{target_user_id:J},{params:{id:W}})}unblock(W,J){return this.delete("users/:source_user_id/blocking/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:J}})}mute(W,J){return this.post("users/:id/muting",{target_user_id:J},{params:{id:W}})}unmute(W,J){return this.delete("users/:source_user_id/muting/:target_user_id",void 0,{params:{source_user_id:W,target_user_id:J}})}createList(W){return this.post("lists",W)}updateList(W,J={}){return this.put("lists/:id",J,{params:{id:W}})}removeList(W){return this.delete("lists/:id",void 0,{params:{id:W}})}addListMember(W,J){return this.post("lists/:id/members",{user_id:J},{params:{id:W}})}removeListMember(W,J){return this.delete("lists/:id/members/:user_id",void 0,{params:{id:W,user_id:J}})}subscribeToList(W,J){return this.post("users/:id/followed_lists",{list_id:J},{params:{id:W}})}unsubscribeOfList(W,J){return this.delete("users/:id/followed_lists/:list_id",void 0,{params:{id:W,list_id:J}})}pinList(W,J){return this.post("users/:id/pinned_lists",{list_id:J},{params:{id:W}})}unpinList(W,J){return this.delete("users/:id/pinned_lists/:list_id",void 0,{params:{id:W,list_id:J}})}sendDmInConversation(W,J){return this.post("dm_conversations/:dm_conversation_id/messages",J,{params:{dm_conversation_id:W}})}sendDmToParticipant(W,J){return this.post("dm_conversations/with/:participant_id/messages",J,{params:{participant_id:W}})}createDmConversation(W){return this.post("dm_conversations",W)}}class z6 extends Y1{constructor(){super(...arguments);this._prefix=o}get readWrite(){return this}}var X6=z6;class B6 extends G1{constructor(){super(...arguments);this._prefix=y}get readWrite(){return this}get labs(){if(this._labs)return this._labs;return this._labs=new X6(this)}}var M6=B6;class O1 extends g{get v1(){if(this._v1)return this._v1;return this._v1=new W1(this)}get v2(){if(this._v2)return this._v2;return this._v2=new Q1(this)}async currentUser(W=!1){return await this.getCurrentUserObject(W)}async currentUserV2(W=!1){return await this.getCurrentUserV2Object(W)}search(W,J){return this.v2.search(W,J)}async generateAuthLink(W="oob",{authAccessType:J,linkMode:Z="authenticate",forceLogin:$,screenName:Q}={}){let Y=await this.post("https://api.x.com/oauth/request_token",{oauth_callback:W,x_auth_access_type:J}),G=`https://api.x.com/oauth/${Z}?oauth_token=${encodeURIComponent(Y.oauth_token)}`;if($!==void 0)G+=`&force_login=${encodeURIComponent($)}`;if(Q!==void 0)G+=`&screen_name=${encodeURIComponent(Q)}`;if(this._requestMaker.hasPlugins())this._requestMaker.applyPluginMethod("onOAuth1RequestToken",{client:this._requestMaker,url:G,oauthResult:Y});return{url:G,...Y}}async login(W){let J=this.getActiveTokens();if(J.type!=="oauth-1.0a")throw Error("You must setup TwitterApi instance with consumer keys to accept OAuth 1.0 login");let Z=await this.post("https://api.x.com/oauth/access_token",{oauth_token:J.accessToken,oauth_verifier:W}),$=new this.constructor({appKey:J.appKey,appSecret:J.appSecret,accessToken:Z.oauth_token,accessSecret:Z.oauth_token_secret},this._requestMaker.clientSettings);return{accessToken:Z.oauth_token,accessSecret:Z.oauth_token_secret,userId:Z.user_id,screenName:Z.screen_name,client:$}}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 Z=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(Z.access_token,this._requestMaker.clientSettings)}generateOAuth2AuthLink(W,J={}){var 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 Q=(Z=J.state)!==null&&Z!==void 0?Z:n.generateRandomString(32),Y=n.getCodeVerifier(),G=n.getCodeChallengeFromVerifier(Y),K=($=J.scope)!==null&&$!==void 0?$:"",z=Array.isArray(K)?K.join(" "):K,X=new URL("https://x.com/i/oauth2/authorize"),B={response_type:"code",client_id:this._requestMaker.clientId,redirect_uri:W,state:Q,code_challenge:G,code_challenge_method:"s256",scope:z};R.addQueryParamsToUrl(X,B);let M={url:X.toString(),state:Q,codeVerifier:Y,codeChallenge:G};if(this._requestMaker.hasPlugins())this._requestMaker.applyPluginMethod("onOAuth2RequestToken",{client:this._requestMaker,result:M,redirectUri:W});return M}async loginWithOAuth2({code:W,codeVerifier:J,redirectUri:Z}){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 $=await this.post("https://api.x.com/2/oauth2/token",{code:W,code_verifier:J,redirect_uri:Z,grant_type:"authorization_code",client_id:this._requestMaker.clientId,client_secret:this._requestMaker.clientSecret});return this.parseOAuth2AccessTokenResult($)}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 J=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(J)}async revokeOAuth2Token(W,J="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:J})}parseOAuth2AccessTokenResult(W){let J=new this.constructor(W.access_token,this._requestMaker.clientSettings),Z=W.scope.split(" ").filter(($)=>$);return{client:J,expiresIn:W.expires_in,accessToken:W.access_token,scope:Z,refreshToken:W.refresh_token}}}class R1 extends O1{get v1(){if(this._v1)return this._v1;return this._v1=new J1(this)}get v2(){if(this._v2)return this._v2;return this._v2=new G1(this)}get readOnly(){return this}}class d1 extends f{constructor(){super(...arguments);this._prefix=s}}class p1 extends d1{constructor(){super(...arguments);this._prefix=s}get readOnly(){return this}}class l1 extends f{constructor(){super(...arguments);this._prefix=a}}class n1 extends l1{constructor(){super(...arguments);this._prefix=a}get readOnly(){return this}}class j6 extends n1{constructor(){super(...arguments);this._prefix=a}get readWrite(){return this}}var N6=j6;class x6 extends p1{constructor(){super(...arguments);this._prefix=s}get readWrite(){return this}get sandbox(){if(this._sandbox)return this._sandbox;return this._sandbox=new N6(this)}}var L6=x6;class j0 extends R1{get v1(){if(this._v1)return this._v1;return this._v1=new E1(this)}get v2(){if(this._v2)return this._v2;return this._v2=new M6(this)}get readWrite(){return this}get ads(){if(this._ads)return this._ads;return this._ads=new L6(this)}static getErrors(W){var J;if(typeof W!=="object")return[];if(!("data"in W))return[];return(J=W.data.errors)!==null&&J!==void 0?J:[]}static getProfileImageInSize(W,J){let Z=W.split("/").pop(),$=["normal","bigger","mini"],Q=W;for(let G of $)if(Z.includes(`_${G}`)){Q=W.replace(`_${G}`,"");break}if(J==="original")return Q;let Y=Q.lastIndexOf(".");if(Y!==-1){let G=Q.slice(Y+1);return Q.slice(0,Y)+"_"+J+"."+G}else return Q+"_"+J}}var t6={clientId:process.env.X_CLIENT_ID,clientSecret:process.env.X_SECRET,redirectPath:"/auth/oauth/x/callback",scope:["tweet.read","users.read","offline.access"]};class D6 extends j1{config;client;constructor(W={}){super();this.config={...t6,...W},this.client=new j0({clientId:this.config.clientId,clientSecret:this.config.clientSecret})}redirectUri(){return`${process.env.HOST_NAME??""}${this.config.redirectPath}`}getRedirectUrl(W,J){if(!J)throw Error("XOAuthProvider needs the state and PKCE challenge gemi passes.");let Z=new URL("https://x.com/i/oauth2/authorize"),$={response_type:"code",client_id:this.config.clientId,redirect_uri:this.redirectUri(),state:J.state,code_challenge:J.codeChallenge,code_challenge_method:J.codeChallengeMethod,scope:this.config.scope.join(" ")};for(let[Q,Y]of Object.entries($))Z.searchParams.set(Q,Y);return Z.toString()}async onCallback(W,J){let Z=W.search.get("code");if(!Z)throw new q("missing_code");if(!J?.codeVerifier)throw new q("invalid_state");let $;try{$=await this.client.loginWithOAuth2({code:Z,codeVerifier:J.codeVerifier,redirectUri:this.redirectUri()})}catch(X){throw console.error("X OAuth error: token exchange failed",X),new q("exchange_failed")}let{data:Q}=await $.client.v2.me({"user.fields":["name","username","entities"]}),{name:Y,email:G,id:K="",username:z}=Q??{};return{name:Y,email:G,username:z,providerId:K}}}class N0{describe;rollout;when;serverOnly;salt;constructor(W={}){if(W.rollout!==void 0){let{rollout:J}=W;if(!Number.isFinite(J)||J<0||J>100)throw Error(`A feature's \`rollout\` must be a number between 0 and 100, received ${String(J)}.`)}this.describe=W.describe,this.rollout=W.rollout,this.when=W.when,this.serverOnly=W.serverOnly??!1,this.salt=W.salt}}function r6(W={}){return new N0(W)}class F6 extends x0{rows=new Map;constructor(W={}){super();for(let[J,Z]of Object.entries(W))this.rows.set(J,{key:J,active:Z})}async load(){return[...this.rows.values()].map((W)=>({...W}))}async write(W,J,Z){return this.rows.set(W,{key:W,active:J,updatedBy:Z.actor,updatedAt:new Date}),{actorRecorded:!0}}}export{$5 as viewRouteConfigDefaults,Y8 as translationConfigDefaults,i1 as toRangeHeaderValue,cW as subjectFor,jW as sniffContentType,l5 as scheduleConfigDefaults,a1 as resolveRange,k8 as redisConfigDefaults,R8 as rateLimiterConfigDefaults,b5 as queueConfigDefaults,K1 as parseContentRange,$W as mintSessionToken,WW as middlewareConfigDefaults,j5 as mailConfigDefaults,H8 as logConfigDefaults,ZW as isSessionToken,NW as isActiveContentType,EW as inRollout,rW as imageConfigDefaults,BW as filesystemConfigDefaults,X8 as featuresConfigDefaults,i5 as eventConfigDefaults,mW as evaluateFeature,vW as encodeCursor,t5 as discoverWorkflows,W8 as discoverListeners,a5 as discoverJobs,r5 as discoverCronJobs,e5 as discoverCommands,Q8 as defineTranslationConfig,p5 as defineScheduleConfig,J5 as defineRouteConfig,_8 as defineRedisConfig,O8 as defineRateLimiterConfig,I5 as defineQueueConfig,e6 as defineMiddlewareConfig,M5 as defineMailConfig,F8 as defineLogConfig,tW as defineImageConfig,XW as defineFilesystemConfig,z8 as defineFeaturesConfig,r6 as defineFeature,n5 as defineEventConfig,O6 as defineEncryptionConfig,m5 as defineCommandConfig,u5 as defineCommand,bW as defineChangeFeedConfig,GW as defineAuthConfig,PW as decodeCursor,_5 as createWorkflowTableStatements,c5 as commandConfigDefaults,TW as changeFeedConfigDefaults,gW as bucketOf,hW as bucketKey,z4 as bearerToken,KW as authConfigDefaults,o1 as assertDeletablePrefix,Z5 as apiRouteConfigDefaults,D6 as XOAuthProvider,A5 as WorkflowRuntime,q5 as WorkflowCancelledError,s5 as Workflow,w5 as WaitTimeoutError,K5 as ViewRouteDispatcher,nW as UndeclaredFeatureError,V5 as StepTimeoutError,P5 as StepFailedError,y5 as Step,F6 as StaticFeatureFlagSource,aW as Sharp,O5 as Scheduler,G8 as ScheduleServiceProvider,G5 as STATIC_NAVIGATION_CSP_HASH,JW as SESSION_TOKEN_PREFIX,F0 as S3Driver,I8 as RouteServiceProvider,B5 as ResendDriver,C8 as RedisServiceProvider,R0 as RedisRateLimiter,_1 as RedisManager,f8 as RateLimiterServiceProvider,t1 as RateLimiterDriver,QW as RateLimiter,i as RangeNotSatisfiableError,J8 as QueueServiceProvider,h5 as QueueManager,IW as ProviderConnection,_W as OAuthReconnectRequiredError,j1 as OAuthProvider,kW as OAuthConnectionProvider,fW as OAuthConnectionError,q as OAuthCallbackError,S8 as MiddlewareServiceProvider,W5 as MiddlewareRegistry,T5 as MemoryWorkflowStore,v5 as MemoryQueueDriver,E0 as MemoryMcpOAuthStore,S5 as MemoryLockStore,OW as MemoryConnectionStore,VW as MemoryChangeFeedDriver,L5 as McpToolError,F5 as McpRegistry,h0 as McpOAuthServer,U5 as McpHttpServer,D5 as McpCallRefusedError,H5 as McpApiKeyResolver,M8 as MailServiceProvider,N5 as MailManager,U8 as LogServiceProvider,xW as LogManager,FW as LockManager,LW as LockLostError,o5 as Listener,D8 as KernelIdServiceProvider,Q5 as KernelId,C5 as Job,YW as InMemoryRateLimiter,L8 as ImageServiceProvider,sW as ImageOptimizationDriver,eW as ImageManager,Y5 as ISLAND_LOADER_CSP_HASH,DW as HeldLock,u0 as GoogleOAuthProvider,x8 as FilesystemServiceProvider,MW as FilesystemManager,zW as FileSystemDriver,z1 as FileStorageDriver,c as FileNotFoundError,B8 as FeaturesServiceProvider,lW as FeatureSourceReadOnlyError,iW as FeatureScope,uW as FeatureReloadError,pW as FeatureModelMissingError,oW as FeatureManager,dW as FeatureFlagStore,x0 as FeatureFlagSource,N0 as Feature,N8 as EventServiceProvider,k as EventManager,c0 as Event,j8 as EncryptionServiceProvider,UW as EncryptionKeyError,HW as Encrypter,X5 as EmailDriver,SW as DecryptionError,f5 as DatabaseWorkflowStore,k5 as DatabaseQueueDriver,R5 as DatabaseLockStore,K8 as DatabaseFeatureFlagSource,RW as DatabaseConnectionStore,wW as DatabaseChangeFeedDriver,x5 as DEFAULT_MCP_SCOPE,d5 as CronJob,CW as ConnectionManager,b8 as CommandRegistry,g5 as CommandFailed,E5 as Command,AW as ChangeFeedSubscription,Z8 as ChangeFeedServiceProvider,yW as ChangeFeedManager,qW as ChangeFeedFullError,k1 as CONSENT_PAGE_HEADERS,U0 as AzureBlobDriver,$8 as AuthServiceProvider,b1 as AuthManager,z5 as ApiRouteDispatcher};
71
71
 
72
- //# debugId=F615F66477697EF864756E2164756E21
72
+ //# debugId=E60B67AE90882D1464756E2164756E21