gemi 0.204.2 → 0.205.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 (248) hide show
  1. package/dist/ai/AgentProvider.d.ts +83 -3
  2. package/dist/ai/AgentProvider.d.ts.map +1 -1
  3. package/dist/ai/client/index.js +12 -10
  4. package/dist/ai/client/index.js.map +1 -1
  5. package/dist/ai/index.d.ts +2 -2
  6. package/dist/ai/index.d.ts.map +1 -1
  7. package/dist/ai/index.js +4 -4
  8. package/dist/ai/index.js.map +3 -3
  9. package/dist/ai/providers/anthropicRequest.d.ts +142 -0
  10. package/dist/ai/providers/anthropicRequest.d.ts.map +1 -0
  11. package/dist/ai/providers/anthropicStream.d.ts +54 -0
  12. package/dist/ai/providers/anthropicStream.d.ts.map +1 -0
  13. package/dist/ai/providers/call.d.ts +14 -3
  14. package/dist/ai/providers/call.d.ts.map +1 -1
  15. package/dist/ai/providers/capabilities.d.ts +31 -0
  16. package/dist/ai/providers/capabilities.d.ts.map +1 -1
  17. package/dist/ai/providers/endpoints.d.ts +51 -0
  18. package/dist/ai/providers/endpoints.d.ts.map +1 -1
  19. package/dist/ai/providers/http.d.ts.map +1 -1
  20. package/dist/ai/providers/request.d.ts +43 -1
  21. package/dist/ai/providers/request.d.ts.map +1 -1
  22. package/dist/ai/runtime.d.ts +5 -1
  23. package/dist/ai/runtime.d.ts.map +1 -1
  24. package/dist/ai/testing/RecordingProvider.d.ts +5 -2
  25. package/dist/ai/testing/RecordingProvider.d.ts.map +1 -1
  26. package/dist/ai/testing/index.js +3 -3
  27. package/dist/ai/testing/index.js.map +3 -3
  28. package/dist/ai/types.d.ts +34 -0
  29. package/dist/ai/types.d.ts.map +1 -1
  30. package/dist/ai/usageMeter.d.ts +4 -1
  31. package/dist/ai/usageMeter.d.ts.map +1 -1
  32. package/dist/app/index.js +2 -2
  33. package/dist/app/index.js.map +1 -1
  34. package/dist/bun/plugin.js +2 -2
  35. package/dist/bun/plugin.js.map +1 -1
  36. package/dist/bun/preload.js +2 -2
  37. package/dist/bun/preload.js.map +1 -1
  38. package/dist/{chunk-2t1eyzvq.js → chunk-06w8hhnk.js} +2 -2
  39. package/dist/{chunk-2t1eyzvq.js.map → chunk-06w8hhnk.js.map} +1 -1
  40. package/dist/{chunk-0t1d9s34.js → chunk-09hzyf9g.js} +3 -3
  41. package/dist/{chunk-0t1d9s34.js.map → chunk-09hzyf9g.js.map} +1 -1
  42. package/dist/{chunk-bq4pgzcd.js → chunk-0cckwd91.js} +2 -2
  43. package/dist/{chunk-bq4pgzcd.js.map → chunk-0cckwd91.js.map} +1 -1
  44. package/dist/{chunk-9hqnecjt.js → chunk-0eq7am78.js} +2 -2
  45. package/dist/{chunk-9hqnecjt.js.map → chunk-0eq7am78.js.map} +1 -1
  46. package/dist/{chunk-jma5d7zd.js → chunk-1em8t2x1.js} +3 -3
  47. package/dist/{chunk-jma5d7zd.js.map → chunk-1em8t2x1.js.map} +1 -1
  48. package/dist/{chunk-ek0dvbck.js → chunk-1tc6j8bn.js} +3 -3
  49. package/dist/{chunk-ek0dvbck.js.map → chunk-1tc6j8bn.js.map} +1 -1
  50. package/dist/{chunk-dk1xxtgk.js → chunk-24tj4dzx.js} +2 -2
  51. package/dist/{chunk-dk1xxtgk.js.map → chunk-24tj4dzx.js.map} +1 -1
  52. package/dist/{chunk-s5hdrpam.js → chunk-34vvev4a.js} +3 -3
  53. package/dist/{chunk-s5hdrpam.js.map → chunk-34vvev4a.js.map} +1 -1
  54. package/dist/{chunk-f52maa9b.js → chunk-3830ee5d.js} +2 -2
  55. package/dist/{chunk-f52maa9b.js.map → chunk-3830ee5d.js.map} +1 -1
  56. package/dist/{chunk-yykrvrpt.js → chunk-39dz1abf.js} +1 -1
  57. package/dist/{chunk-yjvqq4hj.js → chunk-3ek0s8fx.js} +2 -2
  58. package/dist/{chunk-yjvqq4hj.js.map → chunk-3ek0s8fx.js.map} +1 -1
  59. package/dist/{chunk-vsd5h2d9.js → chunk-3z8d8v8q.js} +3 -3
  60. package/dist/{chunk-vsd5h2d9.js.map → chunk-3z8d8v8q.js.map} +1 -1
  61. package/dist/{chunk-f9c8bnzx.js → chunk-460c8k50.js} +3 -3
  62. package/dist/{chunk-f9c8bnzx.js.map → chunk-460c8k50.js.map} +1 -1
  63. package/dist/{chunk-wxyxnbh6.js → chunk-4ksnhx8x.js} +4 -4
  64. package/dist/{chunk-wxyxnbh6.js.map → chunk-4ksnhx8x.js.map} +1 -1
  65. package/dist/chunk-4q59y78y.js +5 -0
  66. package/dist/{chunk-cf7xc02m.js.map → chunk-4q59y78y.js.map} +1 -1
  67. package/dist/{chunk-4m8t67px.js → chunk-65btke6p.js} +2 -2
  68. package/dist/{chunk-4m8t67px.js.map → chunk-65btke6p.js.map} +1 -1
  69. package/dist/{chunk-efnerp0c.js → chunk-6cx6kh04.js} +2 -2
  70. package/dist/{chunk-efnerp0c.js.map → chunk-6cx6kh04.js.map} +1 -1
  71. package/dist/{chunk-jmsfkzav.js → chunk-6ge27ygx.js} +2 -2
  72. package/dist/{chunk-jmsfkzav.js.map → chunk-6ge27ygx.js.map} +1 -1
  73. package/dist/{chunk-x26jb60f.js → chunk-6x2zbh1q.js} +2 -2
  74. package/dist/{chunk-x26jb60f.js.map → chunk-6x2zbh1q.js.map} +1 -1
  75. package/dist/{chunk-0hfzzb3k.js → chunk-6zpf257t.js} +3 -3
  76. package/dist/{chunk-0hfzzb3k.js.map → chunk-6zpf257t.js.map} +1 -1
  77. package/dist/{chunk-cq7hk8v9.js → chunk-72e857nw.js} +2 -2
  78. package/dist/{chunk-cq7hk8v9.js.map → chunk-72e857nw.js.map} +1 -1
  79. package/dist/{chunk-4v5c4mes.js → chunk-77dt2tap.js} +2 -2
  80. package/dist/{chunk-4v5c4mes.js.map → chunk-77dt2tap.js.map} +1 -1
  81. package/dist/{chunk-ptpzh61m.js → chunk-78g1cngk.js} +2 -2
  82. package/dist/{chunk-ptpzh61m.js.map → chunk-78g1cngk.js.map} +1 -1
  83. package/dist/{chunk-d7kknkmq.js → chunk-7wzhdq1x.js} +3 -3
  84. package/dist/{chunk-d7kknkmq.js.map → chunk-7wzhdq1x.js.map} +1 -1
  85. package/dist/{chunk-cg009t41.js → chunk-8a5wngew.js} +2 -2
  86. package/dist/{chunk-cg009t41.js.map → chunk-8a5wngew.js.map} +1 -1
  87. package/dist/{chunk-6g1xac70.js → chunk-8ar7180x.js} +2 -2
  88. package/dist/{chunk-6g1xac70.js.map → chunk-8ar7180x.js.map} +1 -1
  89. package/dist/{chunk-d3k38gk1.js → chunk-8d2g78vc.js} +2 -2
  90. package/dist/{chunk-d3k38gk1.js.map → chunk-8d2g78vc.js.map} +1 -1
  91. package/dist/{chunk-yrbvfda9.js → chunk-8ncqxja2.js} +1 -1
  92. package/dist/{chunk-6w6q9mxe.js → chunk-8q5kxzxn.js} +3 -3
  93. package/dist/{chunk-6w6q9mxe.js.map → chunk-8q5kxzxn.js.map} +1 -1
  94. package/dist/{chunk-y45whafz.js → chunk-9m6mkaqb.js} +2 -2
  95. package/dist/{chunk-y45whafz.js.map → chunk-9m6mkaqb.js.map} +1 -1
  96. package/dist/{chunk-zk1vwwv6.js → chunk-9qyet3nb.js} +2 -2
  97. package/dist/{chunk-zk1vwwv6.js.map → chunk-9qyet3nb.js.map} +1 -1
  98. package/dist/{chunk-p2nqksdq.js → chunk-a7rgrcs0.js} +3 -3
  99. package/dist/{chunk-p2nqksdq.js.map → chunk-a7rgrcs0.js.map} +1 -1
  100. package/dist/{chunk-x244kqcc.js → chunk-a7zqp5m7.js} +2 -2
  101. package/dist/{chunk-x244kqcc.js.map → chunk-a7zqp5m7.js.map} +1 -1
  102. package/dist/{chunk-y5kfqq4f.js → chunk-aed0vv5g.js} +2 -2
  103. package/dist/{chunk-y5kfqq4f.js.map → chunk-aed0vv5g.js.map} +1 -1
  104. package/dist/{chunk-9m7c4mws.js → chunk-ba1h9pm6.js} +2 -2
  105. package/dist/{chunk-9m7c4mws.js.map → chunk-ba1h9pm6.js.map} +1 -1
  106. package/dist/chunk-bb74k64k.js +11 -0
  107. package/dist/chunk-bb74k64k.js.map +21 -0
  108. package/dist/{chunk-7gxmf9rg.js → chunk-bpqkzpkt.js} +2 -2
  109. package/dist/{chunk-7gxmf9rg.js.map → chunk-bpqkzpkt.js.map} +1 -1
  110. package/dist/{chunk-qcrj4t72.js → chunk-bxznwntw.js} +2 -2
  111. package/dist/{chunk-qcrj4t72.js.map → chunk-bxznwntw.js.map} +1 -1
  112. package/dist/{chunk-4c0rb2ng.js → chunk-c8bvpkr2.js} +2 -2
  113. package/dist/{chunk-4c0rb2ng.js.map → chunk-c8bvpkr2.js.map} +1 -1
  114. package/dist/{chunk-jeq8wvj6.js → chunk-cffx7wqp.js} +2 -2
  115. package/dist/{chunk-jeq8wvj6.js.map → chunk-cffx7wqp.js.map} +1 -1
  116. package/dist/{chunk-8jfnn7v6.js → chunk-djnn8vvp.js} +2 -2
  117. package/dist/{chunk-8jfnn7v6.js.map → chunk-djnn8vvp.js.map} +1 -1
  118. package/dist/{chunk-s6bq91cm.js → chunk-dwya9z8p.js} +2 -2
  119. package/dist/{chunk-s6bq91cm.js.map → chunk-dwya9z8p.js.map} +1 -1
  120. package/dist/chunk-e0scxs81.js +5 -0
  121. package/dist/{chunk-xwqdh388.js.map → chunk-e0scxs81.js.map} +4 -4
  122. package/dist/{chunk-0shq2d31.js → chunk-eeq9ty68.js} +2 -2
  123. package/dist/{chunk-0shq2d31.js.map → chunk-eeq9ty68.js.map} +1 -1
  124. package/dist/{chunk-77x9vxht.js → chunk-emt36pxm.js} +2 -2
  125. package/dist/{chunk-77x9vxht.js.map → chunk-emt36pxm.js.map} +1 -1
  126. package/dist/{chunk-k62338g2.js → chunk-etcds9w3.js} +2 -2
  127. package/dist/{chunk-k62338g2.js.map → chunk-etcds9w3.js.map} +1 -1
  128. package/dist/{chunk-kgjcszx0.js → chunk-fe2nkshn.js} +2 -2
  129. package/dist/{chunk-kgjcszx0.js.map → chunk-fe2nkshn.js.map} +1 -1
  130. package/dist/{chunk-d5d3a8bm.js → chunk-fhn92are.js} +2 -2
  131. package/dist/{chunk-d5d3a8bm.js.map → chunk-fhn92are.js.map} +1 -1
  132. package/dist/{chunk-crqbzfd5.js → chunk-g6tqje74.js} +2 -2
  133. package/dist/{chunk-crqbzfd5.js.map → chunk-g6tqje74.js.map} +1 -1
  134. package/dist/{chunk-p9pwskv6.js → chunk-hke4hzfm.js} +2 -2
  135. package/dist/{chunk-p9pwskv6.js.map → chunk-hke4hzfm.js.map} +1 -1
  136. package/dist/{chunk-3gkxnfef.js → chunk-hqg4dfca.js} +2 -2
  137. package/dist/{chunk-3gkxnfef.js.map → chunk-hqg4dfca.js.map} +1 -1
  138. package/dist/{chunk-39hed4yr.js → chunk-hthyn5pj.js} +3 -3
  139. package/dist/{chunk-39hed4yr.js.map → chunk-hthyn5pj.js.map} +1 -1
  140. package/dist/{chunk-w3mc696j.js → chunk-jn1h76sa.js} +2 -2
  141. package/dist/{chunk-w3mc696j.js.map → chunk-jn1h76sa.js.map} +1 -1
  142. package/dist/{chunk-ezvtkbp9.js → chunk-jy26hy7z.js} +2 -2
  143. package/dist/{chunk-ezvtkbp9.js.map → chunk-jy26hy7z.js.map} +1 -1
  144. package/dist/{chunk-5km0np8s.js → chunk-jy61580r.js} +2 -2
  145. package/dist/{chunk-5km0np8s.js.map → chunk-jy61580r.js.map} +1 -1
  146. package/dist/{chunk-phvvxv1a.js → chunk-k8peybx0.js} +3 -3
  147. package/dist/{chunk-phvvxv1a.js.map → chunk-k8peybx0.js.map} +1 -1
  148. package/dist/{chunk-3xzhbkya.js → chunk-m3v661b3.js} +3 -3
  149. package/dist/{chunk-3xzhbkya.js.map → chunk-m3v661b3.js.map} +1 -1
  150. package/dist/{chunk-js9rm7g0.js → chunk-ndcqbwsj.js} +2 -2
  151. package/dist/{chunk-js9rm7g0.js.map → chunk-ndcqbwsj.js.map} +1 -1
  152. package/dist/{chunk-cdgnwzwf.js → chunk-ne51fxg2.js} +2 -2
  153. package/dist/{chunk-cdgnwzwf.js.map → chunk-ne51fxg2.js.map} +1 -1
  154. package/dist/{chunk-b1mdan5a.js → chunk-nfher0gz.js} +2 -2
  155. package/dist/{chunk-b1mdan5a.js.map → chunk-nfher0gz.js.map} +1 -1
  156. package/dist/{chunk-e5mqjren.js → chunk-njnng5ew.js} +4 -4
  157. package/dist/{chunk-e5mqjren.js.map → chunk-njnng5ew.js.map} +1 -1
  158. package/dist/{chunk-e3ehv27z.js → chunk-p9c5rc1z.js} +3 -3
  159. package/dist/{chunk-e3ehv27z.js.map → chunk-p9c5rc1z.js.map} +1 -1
  160. package/dist/{chunk-rr8bzm6k.js → chunk-q1t9gvm1.js} +2 -2
  161. package/dist/{chunk-rr8bzm6k.js.map → chunk-q1t9gvm1.js.map} +1 -1
  162. package/dist/{chunk-xvk6aqd7.js → chunk-q751b0jx.js} +3 -3
  163. package/dist/{chunk-xvk6aqd7.js.map → chunk-q751b0jx.js.map} +1 -1
  164. package/dist/{chunk-1kehwa3s.js → chunk-qc0e278w.js} +1 -1
  165. package/dist/{chunk-re9ac4tc.js → chunk-rbkvkv2m.js} +4 -4
  166. package/dist/{chunk-re9ac4tc.js.map → chunk-rbkvkv2m.js.map} +1 -1
  167. package/dist/{chunk-k1gt7fgy.js → chunk-rjtge67x.js} +3 -3
  168. package/dist/{chunk-k1gt7fgy.js.map → chunk-rjtge67x.js.map} +1 -1
  169. package/dist/{chunk-ybcdxrqx.js → chunk-s1fa5f8b.js} +2 -2
  170. package/dist/{chunk-ybcdxrqx.js.map → chunk-s1fa5f8b.js.map} +1 -1
  171. package/dist/{chunk-8pw4zjnx.js → chunk-scw0vknj.js} +1 -1
  172. package/dist/{chunk-gc9g7c4p.js → chunk-sjve1yvv.js} +3 -3
  173. package/dist/{chunk-gc9g7c4p.js.map → chunk-sjve1yvv.js.map} +1 -1
  174. package/dist/{chunk-wn4j741t.js → chunk-te4vz0rw.js} +2 -2
  175. package/dist/{chunk-wn4j741t.js.map → chunk-te4vz0rw.js.map} +1 -1
  176. package/dist/{chunk-2ngdhbz7.js → chunk-tx5zrdmb.js} +2 -2
  177. package/dist/{chunk-2ngdhbz7.js.map → chunk-tx5zrdmb.js.map} +1 -1
  178. package/dist/{chunk-pq15dt8j.js → chunk-v1d7xya8.js} +15 -15
  179. package/dist/{chunk-pq15dt8j.js.map → chunk-v1d7xya8.js.map} +5 -5
  180. package/dist/{chunk-fq5b1k4n.js → chunk-v2fd69at.js} +2 -2
  181. package/dist/{chunk-fq5b1k4n.js.map → chunk-v2fd69at.js.map} +1 -1
  182. package/dist/{chunk-n5k42dh7.js → chunk-vebstesm.js} +3 -3
  183. package/dist/{chunk-n5k42dh7.js.map → chunk-vebstesm.js.map} +1 -1
  184. package/dist/{chunk-n3kg99yw.js → chunk-vyaedzr8.js} +3 -3
  185. package/dist/{chunk-n3kg99yw.js.map → chunk-vyaedzr8.js.map} +1 -1
  186. package/dist/{chunk-9bjggtdt.js → chunk-wdrmzjtq.js} +2 -2
  187. package/dist/{chunk-9bjggtdt.js.map → chunk-wdrmzjtq.js.map} +1 -1
  188. package/dist/{chunk-5gvc03cv.js → chunk-wfees83q.js} +3 -3
  189. package/dist/{chunk-5gvc03cv.js.map → chunk-wfees83q.js.map} +1 -1
  190. package/dist/{chunk-n26atakz.js → chunk-wpfempaj.js} +3 -3
  191. package/dist/{chunk-n26atakz.js.map → chunk-wpfempaj.js.map} +1 -1
  192. package/dist/{chunk-0pgk811s.js → chunk-wrfz0jsw.js} +2 -2
  193. package/dist/{chunk-0pgk811s.js.map → chunk-wrfz0jsw.js.map} +1 -1
  194. package/dist/{chunk-c7nbzryd.js → chunk-xgc5tj8k.js} +3 -3
  195. package/dist/{chunk-c7nbzryd.js.map → chunk-xgc5tj8k.js.map} +1 -1
  196. package/dist/{chunk-1e82gfk9.js → chunk-yj1h4rzn.js} +3 -3
  197. package/dist/{chunk-1e82gfk9.js.map → chunk-yj1h4rzn.js.map} +1 -1
  198. package/dist/{chunk-k9882kqg.js → chunk-zf1eqgzt.js} +2 -2
  199. package/dist/{chunk-k9882kqg.js.map → chunk-zf1eqgzt.js.map} +1 -1
  200. package/dist/{chunk-4ex4s616.js → chunk-znw55n6g.js} +2 -2
  201. package/dist/{chunk-4ex4s616.js.map → chunk-znw55n6g.js.map} +1 -1
  202. package/dist/{chunk-6bfj0mbp.js → chunk-zvk6dydb.js} +3 -3
  203. package/dist/{chunk-6bfj0mbp.js.map → chunk-zvk6dydb.js.map} +1 -1
  204. package/dist/config/index.js +1 -1
  205. package/dist/console/run.js +2 -2
  206. package/dist/console/run.js.map +1 -1
  207. package/dist/container/index.js +2 -2
  208. package/dist/container/index.js.map +1 -1
  209. package/dist/database/index.js +2 -2
  210. package/dist/database/index.js.map +1 -1
  211. package/dist/email/index.js +2 -2
  212. package/dist/email/index.js.map +1 -1
  213. package/dist/facades/index.js +2 -2
  214. package/dist/facades/index.js.map +1 -1
  215. package/dist/foundation/index.js +2 -2
  216. package/dist/foundation/index.js.map +1 -1
  217. package/dist/http/index.js +2 -2
  218. package/dist/http/index.js.map +1 -1
  219. package/dist/i18n/dictionaryRuntime.js +2 -2
  220. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  221. package/dist/i18n/index.js +2 -2
  222. package/dist/i18n/index.js.map +1 -1
  223. package/dist/kernel/index.js +2 -2
  224. package/dist/kernel/index.js.map +1 -1
  225. package/dist/orm/index.js +2 -2
  226. package/dist/orm/index.js.map +1 -1
  227. package/dist/probe/index.js +2 -2
  228. package/dist/probe/index.js.map +1 -1
  229. package/dist/server/index.js +2 -2
  230. package/dist/server/index.js.map +1 -1
  231. package/dist/services/index.js +2 -2
  232. package/dist/services/index.js.map +1 -1
  233. package/dist/services/queue/work.js +2 -2
  234. package/dist/services/queue/work.js.map +1 -1
  235. package/dist/stats/route-table.js +1 -1
  236. package/dist/support/index.js +2 -2
  237. package/dist/support/index.js.map +1 -1
  238. package/dist/vitest/index.js +2 -2
  239. package/dist/vitest/index.js.map +1 -1
  240. package/package.json +1 -1
  241. package/dist/chunk-1x60thpm.js +0 -8
  242. package/dist/chunk-1x60thpm.js.map +0 -19
  243. package/dist/chunk-cf7xc02m.js +0 -5
  244. package/dist/chunk-xwqdh388.js +0 -5
  245. /package/dist/{chunk-yykrvrpt.js.map → chunk-39dz1abf.js.map} +0 -0
  246. /package/dist/{chunk-yrbvfda9.js.map → chunk-8ncqxja2.js.map} +0 -0
  247. /package/dist/{chunk-1kehwa3s.js.map → chunk-qc0e278w.js.map} +0 -0
  248. /package/dist/{chunk-8pw4zjnx.js.map → chunk-scw0vknj.js.map} +0 -0
@@ -5,6 +5,6 @@
5
5
  "'use strict';\n\nvar utilUtf8 = require('@smithy/util-utf8');\n\nclass EventStreamSerde {\n marshaller;\n serializer;\n deserializer;\n serdeContext;\n defaultContentType;\n constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, }) {\n this.marshaller = marshaller;\n this.serializer = serializer;\n this.deserializer = deserializer;\n this.serdeContext = serdeContext;\n this.defaultContentType = defaultContentType;\n }\n async serializeEventStream({ eventStream, requestSchema, initialRequest, }) {\n const marshaller = this.marshaller;\n const eventStreamMember = requestSchema.getEventStreamMember();\n const unionSchema = requestSchema.getMemberSchema(eventStreamMember);\n const serializer = this.serializer;\n const defaultContentType = this.defaultContentType;\n const initialRequestMarker = Symbol(\"initialRequestMarker\");\n const eventStreamIterable = {\n async *[Symbol.asyncIterator]() {\n if (initialRequest) {\n const headers = {\n \":event-type\": { type: \"string\", value: \"initial-request\" },\n \":message-type\": { type: \"string\", value: \"event\" },\n \":content-type\": { type: \"string\", value: defaultContentType },\n };\n serializer.write(requestSchema, initialRequest);\n const body = serializer.flush();\n yield {\n [initialRequestMarker]: true,\n headers,\n body,\n };\n }\n for await (const page of eventStream) {\n yield page;\n }\n },\n };\n return marshaller.serialize(eventStreamIterable, (event) => {\n if (event[initialRequestMarker]) {\n return {\n headers: event.headers,\n body: event.body,\n };\n }\n const unionMember = Object.keys(event).find((key) => {\n return key !== \"__type\";\n }) ?? \"\";\n const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);\n const headers = {\n \":event-type\": { type: \"string\", value: eventType },\n \":message-type\": { type: \"string\", value: \"event\" },\n \":content-type\": { type: \"string\", value: explicitPayloadContentType ?? defaultContentType },\n ...additionalHeaders,\n };\n return {\n headers,\n body,\n };\n });\n }\n async deserializeEventStream({ response, responseSchema, initialResponseContainer, }) {\n const marshaller = this.marshaller;\n const eventStreamMember = responseSchema.getEventStreamMember();\n const unionSchema = responseSchema.getMemberSchema(eventStreamMember);\n const memberSchemas = unionSchema.getMemberSchemas();\n const initialResponseMarker = Symbol(\"initialResponseMarker\");\n const asyncIterable = marshaller.deserialize(response.body, async (event) => {\n const unionMember = Object.keys(event).find((key) => {\n return key !== \"__type\";\n }) ?? \"\";\n const body = event[unionMember].body;\n if (unionMember === \"initial-response\") {\n const dataObject = await this.deserializer.read(responseSchema, body);\n delete dataObject[eventStreamMember];\n return {\n [initialResponseMarker]: true,\n ...dataObject,\n };\n }\n else if (unionMember in memberSchemas) {\n const eventStreamSchema = memberSchemas[unionMember];\n if (eventStreamSchema.isStructSchema()) {\n const out = {};\n let hasBindings = false;\n for (const [name, member] of eventStreamSchema.structIterator()) {\n const { eventHeader, eventPayload } = member.getMergedTraits();\n hasBindings = hasBindings || Boolean(eventHeader || eventPayload);\n if (eventPayload) {\n if (member.isBlobSchema()) {\n out[name] = body;\n }\n else if (member.isStringSchema()) {\n out[name] = (this.serdeContext?.utf8Encoder ?? utilUtf8.toUtf8)(body);\n }\n else if (member.isStructSchema()) {\n out[name] = await this.deserializer.read(member, body);\n }\n }\n else if (eventHeader) {\n const value = event[unionMember].headers[name]?.value;\n if (value != null) {\n if (member.isNumericSchema()) {\n if (value && typeof value === \"object\" && \"bytes\" in value) {\n out[name] = BigInt(value.toString());\n }\n else {\n out[name] = Number(value);\n }\n }\n else {\n out[name] = value;\n }\n }\n }\n }\n if (hasBindings) {\n return {\n [unionMember]: out,\n };\n }\n if (body.byteLength === 0) {\n return {\n [unionMember]: {},\n };\n }\n }\n return {\n [unionMember]: await this.deserializer.read(eventStreamSchema, body),\n };\n }\n else {\n return {\n $unknown: event,\n };\n }\n });\n const asyncIterator = asyncIterable[Symbol.asyncIterator]();\n const firstEvent = await asyncIterator.next();\n if (firstEvent.done) {\n return asyncIterable;\n }\n if (firstEvent.value?.[initialResponseMarker]) {\n if (!responseSchema) {\n throw new Error(\"@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.\");\n }\n for (const [key, value] of Object.entries(firstEvent.value)) {\n initialResponseContainer[key] = value;\n }\n }\n return {\n async *[Symbol.asyncIterator]() {\n if (!firstEvent?.value?.[initialResponseMarker]) {\n yield firstEvent.value;\n }\n while (true) {\n const { done, value } = await asyncIterator.next();\n if (done) {\n break;\n }\n yield value;\n }\n },\n };\n }\n writeEventBody(unionMember, unionSchema, event) {\n const serializer = this.serializer;\n let eventType = unionMember;\n let explicitPayloadMember = null;\n let explicitPayloadContentType;\n const isKnownSchema = (() => {\n const struct = unionSchema.getSchema();\n return struct[4].includes(unionMember);\n })();\n const additionalHeaders = {};\n if (!isKnownSchema) {\n const [type, value] = event[unionMember];\n eventType = type;\n serializer.write(15, value);\n }\n else {\n const eventSchema = unionSchema.getMemberSchema(unionMember);\n if (eventSchema.isStructSchema()) {\n for (const [memberName, memberSchema] of eventSchema.structIterator()) {\n const { eventHeader, eventPayload } = memberSchema.getMergedTraits();\n if (eventPayload) {\n explicitPayloadMember = memberName;\n }\n else if (eventHeader) {\n const value = event[unionMember][memberName];\n let type = \"binary\";\n if (memberSchema.isNumericSchema()) {\n if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {\n type = \"integer\";\n }\n else {\n type = \"long\";\n }\n }\n else if (memberSchema.isTimestampSchema()) {\n type = \"timestamp\";\n }\n else if (memberSchema.isStringSchema()) {\n type = \"string\";\n }\n else if (memberSchema.isBooleanSchema()) {\n type = \"boolean\";\n }\n if (value != null) {\n additionalHeaders[memberName] = {\n type,\n value,\n };\n delete event[unionMember][memberName];\n }\n }\n }\n if (explicitPayloadMember !== null) {\n const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);\n if (payloadSchema.isBlobSchema()) {\n explicitPayloadContentType = \"application/octet-stream\";\n }\n else if (payloadSchema.isStringSchema()) {\n explicitPayloadContentType = \"text/plain\";\n }\n serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);\n }\n else {\n serializer.write(eventSchema, event[unionMember]);\n }\n }\n else if (eventSchema.isUnitSchema()) {\n serializer.write(eventSchema, {});\n }\n else {\n throw new Error(\"@smithy/core/event-streams - non-struct member not supported in event stream union.\");\n }\n }\n const messageSerialization = serializer.flush() ?? new Uint8Array();\n const body = typeof messageSerialization === \"string\"\n ? (this.serdeContext?.utf8Decoder ?? utilUtf8.fromUtf8)(messageSerialization)\n : messageSerialization;\n return {\n body,\n eventType,\n explicitPayloadContentType,\n additionalHeaders,\n };\n }\n}\n\nexports.EventStreamSerde = EventStreamSerde;\n"
6
6
  ],
7
7
  "mappings": ";uFAIA,AAAM,CAAiB,CACnB,WACA,WACA,aACA,aACA,mBACA,WAAW,EAAG,aAAY,aAAY,eAAc,eAAc,sBAAuB,CACrF,KAAK,WAAa,EAClB,KAAK,WAAa,EAClB,KAAK,aAAe,EACpB,KAAK,aAAe,EACpB,KAAK,mBAAqB,OAExB,qBAAoB,EAAG,cAAa,gBAAe,kBAAmB,CACxE,IAAM,EAAa,KAAK,WAClB,EAAoB,EAAc,qBAAqB,EACvD,EAAc,EAAc,gBAAgB,CAAiB,EAC7D,EAAa,KAAK,WAClB,EAAqB,KAAK,mBAC1B,EAAuB,OAAO,sBAAsB,EACpD,EAAsB,QAChB,OAAO,cAAc,EAAG,CAC5B,GAAI,EAAgB,CAChB,IAAM,EAAU,CACZ,cAAe,CAAE,KAAM,SAAU,MAAO,iBAAkB,EAC1D,gBAAiB,CAAE,KAAM,SAAU,MAAO,OAAQ,EAClD,gBAAiB,CAAE,KAAM,SAAU,MAAO,CAAmB,CACjE,EACA,EAAW,MAAM,EAAe,CAAc,EAC9C,IAAM,EAAO,EAAW,MAAM,EAC9B,KAAM,EACD,GAAuB,GACxB,UACA,MACJ,EAEJ,cAAiB,KAAQ,EACrB,MAAM,EAGlB,EACA,OAAO,EAAW,UAAU,EAAqB,CAAC,IAAU,CACxD,GAAI,EAAM,GACN,MAAO,CACH,QAAS,EAAM,QACf,KAAM,EAAM,IAChB,EAEJ,IAAM,EAAc,OAAO,KAAK,CAAK,EAAE,KAAK,CAAC,IAAQ,CACjD,OAAO,IAAQ,SAClB,GAAK,IACE,oBAAmB,OAAM,YAAW,8BAA+B,KAAK,eAAe,EAAa,EAAa,CAAK,EAO9H,MAAO,CACH,QAPY,CACZ,cAAe,CAAE,KAAM,SAAU,MAAO,CAAU,EAClD,gBAAiB,CAAE,KAAM,SAAU,MAAO,OAAQ,EAClD,gBAAiB,CAAE,KAAM,SAAU,MAAO,GAA8B,CAAmB,KACxF,CACP,EAGI,MACJ,EACH,OAEC,uBAAsB,EAAG,WAAU,iBAAgB,4BAA6B,CAClF,IAAM,EAAa,KAAK,WAClB,EAAoB,EAAe,qBAAqB,EAExD,EADc,EAAe,gBAAgB,CAAiB,EAClC,iBAAiB,EAC7C,EAAwB,OAAO,uBAAuB,EACtD,EAAgB,EAAW,YAAY,EAAS,KAAM,MAAO,IAAU,CACzE,IAAM,EAAc,OAAO,KAAK,CAAK,EAAE,KAAK,CAAC,IAAQ,CACjD,OAAO,IAAQ,SAClB,GAAK,GACA,EAAO,EAAM,GAAa,KAChC,GAAI,IAAgB,mBAAoB,CACpC,IAAM,EAAa,MAAM,KAAK,aAAa,KAAK,EAAgB,CAAI,EAEpE,OADA,OAAO,EAAW,GACX,EACF,GAAwB,MACtB,CACP,EAEC,QAAI,KAAe,EAAe,CACnC,IAAM,EAAoB,EAAc,GACxC,GAAI,EAAkB,eAAe,EAAG,CACpC,IAAM,EAAM,CAAC,EACT,EAAc,GAClB,QAAY,EAAM,KAAW,EAAkB,eAAe,EAAG,CAC7D,IAAQ,cAAa,gBAAiB,EAAO,gBAAgB,EAE7D,GADA,EAAc,GAAe,QAAQ,GAAe,CAAY,EAC5D,GACA,GAAI,EAAO,aAAa,EACpB,EAAI,GAAQ,EAEX,QAAI,EAAO,eAAe,EAC3B,EAAI,IAAS,KAAK,cAAc,aAAe,EAAS,QAAQ,CAAI,EAEnE,QAAI,EAAO,eAAe,EAC3B,EAAI,GAAQ,MAAM,KAAK,aAAa,KAAK,EAAQ,CAAI,EAGxD,QAAI,EAAa,CAClB,IAAM,EAAQ,EAAM,GAAa,QAAQ,IAAO,MAChD,GAAI,GAAS,KACT,GAAI,EAAO,gBAAgB,EACvB,GAAI,GAAS,OAAO,IAAU,UAAY,UAAW,EACjD,EAAI,GAAQ,OAAO,EAAM,SAAS,CAAC,EAGnC,OAAI,GAAQ,OAAO,CAAK,EAI5B,OAAI,GAAQ,GAK5B,GAAI,EACA,MAAO,EACF,GAAc,CACnB,EAEJ,GAAI,EAAK,aAAe,EACpB,MAAO,EACF,GAAc,CAAC,CACpB,EAGR,MAAO,EACF,GAAc,MAAM,KAAK,aAAa,KAAK,EAAmB,CAAI,CACvE,EAGA,WAAO,CACH,SAAU,CACd,EAEP,EACK,EAAgB,EAAc,OAAO,eAAe,EACpD,EAAa,MAAM,EAAc,KAAK,EAC5C,GAAI,EAAW,KACX,OAAO,EAEX,GAAI,EAAW,QAAQ,GAAwB,CAC3C,GAAI,CAAC,EACD,MAAU,MAAM,4GAA4G,EAEhI,QAAY,EAAK,KAAU,OAAO,QAAQ,EAAW,KAAK,EACtD,EAAyB,GAAO,EAGxC,MAAO,QACK,OAAO,cAAc,EAAG,CAC5B,GAAI,CAAC,GAAY,QAAQ,GACrB,MAAM,EAAW,MAErB,MAAO,GAAM,CACT,IAAQ,OAAM,SAAU,MAAM,EAAc,KAAK,EACjD,GAAI,EACA,MAEJ,MAAM,GAGlB,EAEJ,cAAc,CAAC,EAAa,EAAa,EAAO,CAC5C,IAAM,EAAa,KAAK,WACpB,EAAY,EACZ,EAAwB,KACxB,EACE,GAAiB,IAAM,CAEzB,OADe,EAAY,UAAU,EACvB,GAAG,SAAS,CAAW,IACtC,EACG,EAAoB,CAAC,EAC3B,GAAI,CAAC,EAAe,CAChB,IAAO,EAAM,GAAS,EAAM,GAC5B,EAAY,EACZ,EAAW,MAAM,GAAI,CAAK,EAEzB,KACD,IAAM,EAAc,EAAY,gBAAgB,CAAW,EAC3D,GAAI,EAAY,eAAe,EAAG,CAC9B,QAAY,EAAY,KAAiB,EAAY,eAAe,EAAG,CACnE,IAAQ,cAAa,gBAAiB,EAAa,gBAAgB,EACnE,GAAI,EACA,EAAwB,EAEvB,QAAI,EAAa,CAClB,IAAM,EAAQ,EAAM,GAAa,GAC7B,EAAO,SACX,GAAI,EAAa,gBAAgB,EAC7B,GAAK,aAAa,GAAS,GAAS,WAChC,EAAO,UAGP,OAAO,OAGV,QAAI,EAAa,kBAAkB,EACpC,EAAO,YAEN,QAAI,EAAa,eAAe,EACjC,EAAO,SAEN,QAAI,EAAa,gBAAgB,EAClC,EAAO,UAEX,GAAI,GAAS,KACT,EAAkB,GAAc,CAC5B,OACA,OACJ,EACA,OAAO,EAAM,GAAa,IAItC,GAAI,IAA0B,KAAM,CAChC,IAAM,EAAgB,EAAY,gBAAgB,CAAqB,EACvE,GAAI,EAAc,aAAa,EAC3B,EAA6B,2BAE5B,QAAI,EAAc,eAAe,EAClC,EAA6B,aAEjC,EAAW,MAAM,EAAe,EAAM,GAAa,EAAsB,EAGzE,OAAW,MAAM,EAAa,EAAM,EAAY,EAGnD,QAAI,EAAY,aAAa,EAC9B,EAAW,MAAM,EAAa,CAAC,CAAC,EAGhC,WAAU,MAAM,qFAAqF,EAG7G,IAAM,EAAuB,EAAW,MAAM,GAAK,IAAI,WAIvD,MAAO,CACH,KAJS,OAAO,IAAyB,UACtC,KAAK,cAAc,aAAe,EAAS,UAAU,CAAoB,EAC1E,EAGF,YACA,6BACA,mBACJ,EAER,KA9PI,EAgQI,eAhQJ,MAgQI,EAAmB",
8
- "debugId": "4B793B0C6434711F64756E2164756E21",
8
+ "debugId": "993234EDBF05FD5264756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Je as G}from"./chunk-f52maa9b.js";import{hi as F}from"./chunk-jma5d7zd.js";import{Vk as E}from"./chunk-dk1xxtgk.js";import{Dl as x,ql as B}from"./chunk-k62338g2.js";class J extends G{register(){this.app.singleton(x,()=>{let j=new x(E(B(),this.app.config.get("database",{})));return K(j),j})}async shutdown(){if(!this.app.resolved(x))return;await this.app.make(x).close()}}function K(j){if(Bun.env.NODE_ENV!=="development")return;for(let z of j.connectionNames){let A=j.connection(z);if(F(A.dialect))continue;let H=z===j.name?"DATABASE_URL":`The "${z}" database connection`;console.warn(`[gemi] ${H} points at ${A.dialect}, which the gemi ORM `+"does not implement \u2014 only sqlite and postgres are. The connection "+`works, so raw SQL through DB.query / DB.sql and transactions are fine, but every model operation will raise UnsupportedDialectError.
2
+ import{Le as G}from"./chunk-3830ee5d.js";import{ji as F}from"./chunk-1em8t2x1.js";import{Xk as E}from"./chunk-24tj4dzx.js";import{Fl as x,sl as B}from"./chunk-etcds9w3.js";class J extends G{register(){this.app.singleton(x,()=>{let j=new x(E(B(),this.app.config.get("database",{})));return K(j),j})}async shutdown(){if(!this.app.resolved(x))return;await this.app.make(x).close()}}function K(j){if(Bun.env.NODE_ENV!=="development")return;for(let z of j.connectionNames){let A=j.connection(z);if(F(A.dialect))continue;let H=z===j.name?"DATABASE_URL":`The "${z}" database connection`;console.warn(`[gemi] ${H} points at ${A.dialect}, which the gemi ORM `+"does not implement \u2014 only sqlite and postgres are. The connection "+`works, so raw SQL through DB.query / DB.sql and transactions are fine, but every model operation will raise UnsupportedDialectError.
3
3
  (development only)`)}}
4
- export{J as Ra};
4
+ export{J as Ta};
5
5
 
6
- //# debugId=8B0C78139EC6CE3264756E2164756E21
6
+ //# debugId=75A461EB73E6012F64756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "import { ormSupports } from \"../orm/dialect\";\nimport { ServiceProvider } from \"../support/ServiceProvider\";\nimport { withDefaults } from \"../support/withDefaults\";\nimport { databaseConfigDefaults, type DatabaseConfig } from \"./config\";\nimport { DatabaseManager } from \"./DatabaseManager\";\n\nexport class DatabaseServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n DatabaseManager,\n () => {\n const database = new DatabaseManager(\n withDefaults(\n databaseConfigDefaults(),\n this.app.config.get<DatabaseConfig>(\"database\", {}),\n ),\n );\n\n warnIfOrmUnavailable(database);\n return database;\n },\n );\n }\n\n /**\n * Closes every connection's pool. Registered early, so it runs late: after\n * the queue and the scheduler have waited for their jobs, which still need\n * it. Bun's `close()` lets a query already sent finish.\n *\n * On the way out of a production server this only tidies up before the\n * exit. Under `gemi dev` it is the whole point: a `bun --hot` reload boots\n * a new application with a new pool, and the replaced one's is closed here\n * rather than left holding its connections for the life of the process\n * (#652).\n */\n async shutdown() {\n // Resolving the manager now would open a pool only to close it.\n if (!this.app.resolved(DatabaseManager)) return;\n await this.app.make(DatabaseManager).close();\n }\n}\n\n/**\n * Say it at boot, not on the first model query.\n *\n * `DatabaseManager` connects to MySQL and MariaDB without complaint — Bun's\n * client speaks them — and the ORM's compiler has no dialect for either. So a\n * deploy pointed at one starts, passes a health check, serves whatever does not\n * touch a model, and raises `UnsupportedDialectError` on the first `findMany`.\n * That is the latest and most expensive moment to learn it.\n *\n * A **warning rather than a throw**, deliberately: raw SQL through `DB.query`\n * and `DB.sql` genuinely works on those dialects, and so do transactions.\n * Refusing to construct the manager would break code that is correct today to\n * pre-empt an error the ORM already raises clearly. The supported set is a\n * property of the query compiler, not of the connection.\n *\n * Development only, for the same reason the slow-transaction warning is: it is\n * a diagnostic aimed at whoever is choosing the database, and it should not\n * add noise to a production log every time the container starts.\n */\nfunction warnIfOrmUnavailable(database: DatabaseManager): void {\n if (process.env.NODE_ENV !== \"development\") return;\n\n // Every connection, not only the default one. A named connection is a whole\n // pool an application will run model queries on — `Model.on(\"analytics\")` —\n // so it can be pointed at MySQL exactly as the default can, and warning about\n // only one of them would make the check pass while the query that raises is\n // on the other.\n for (const name of database.connectionNames) {\n const connection = database.connection(name);\n if (ormSupports(connection.dialect)) continue;\n\n const source =\n name === database.name\n ? \"DATABASE_URL\"\n : `The \"${name}\" database connection`;\n\n console.warn(\n `[gemi] ${source} points at ${connection.dialect}, which the gemi ORM ` +\n `does not implement — only sqlite and postgres are. The connection ` +\n `works, so raw SQL through DB.query / DB.sql and transactions are ` +\n `fine, but every model operation will raise ` +\n `UnsupportedDialectError.\\n(development only)`,\n );\n }\n}\n"
6
6
  ],
7
7
  "mappings": ";8LAMO,AAAM,IAAgC,LAAgB,CAC3D,QAAQ,EAAG,CACT,KAAK,IAAI,UACP,EACA,IAAM,CACJ,IAAM,EAAW,IAAI,EACnB,EACE,EAAuB,EACvB,KAAK,IAAI,OAAO,IAAoB,WAAY,CAAC,CAAC,CACpD,CACF,EAGA,OADA,EAAqB,CAAQ,EACtB,EAEX,OAcI,SAAQ,EAAG,CAEf,GAAI,CAAC,KAAK,IAAI,SAAS,CAAe,EAAG,OACzC,MAAM,KAAK,IAAI,KAAK,CAAe,EAAE,MAAM,EAE/C,CAqBA,SAAS,CAAoB,CAAC,EAAiC,CAC7D,GAAI,mBAAyB,cAAe,OAO5C,QAAW,KAAQ,EAAS,gBAAiB,CAC3C,IAAM,EAAa,EAAS,WAAW,CAAI,EAC3C,GAAI,EAAY,EAAW,OAAO,EAAG,SAErC,IAAM,EACJ,IAAS,EAAS,KACd,eACA,QAAQ,yBAEd,QAAQ,KACN,UAAU,eAAoB,EAAW,+BACvC,0EACA;AAAA,mBAGJ",
8
- "debugId": "8B0C78139EC6CE3264756E2164756E21",
8
+ "debugId": "75A461EB73E6012F64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Dm as s}from"./chunk-k9882kqg.js";var i=s((t,e)=>{e.exports={name:"@aws-sdk/nested-clients",version:"3.996.14",description:"Nested clients for AWS SDK packages.",main:"./dist-cjs/index.js",module:"./dist-es/index.js",types:"./dist-types/index.d.ts",scripts:{build:"yarn lint && concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs","build:cjs":"node ../../scripts/compilation/inline nested-clients","build:es":"tsc -p tsconfig.es.json","build:include:deps":'yarn g:turbo run build -F="$npm_package_name"',"build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4",clean:"premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",lint:"node ../../scripts/validation/submodules-linter.js --pkg nested-clients",test:"yarn g:vitest run","test:watch":"yarn g:vitest watch"},engines:{node:">=20.0.0"},sideEffects:!1,author:{name:"AWS SDK for JavaScript Team",url:"https://aws.amazon.com/javascript/"},license:"Apache-2.0",dependencies:{"@aws-crypto/sha256-browser":"5.2.0","@aws-crypto/sha256-js":"5.2.0","@aws-sdk/core":"^3.973.24","@aws-sdk/middleware-host-header":"^3.972.8","@aws-sdk/middleware-logger":"^3.972.8","@aws-sdk/middleware-recursion-detection":"^3.972.8","@aws-sdk/middleware-user-agent":"^3.972.25","@aws-sdk/region-config-resolver":"^3.972.9","@aws-sdk/types":"^3.973.6","@aws-sdk/util-endpoints":"^3.996.5","@aws-sdk/util-user-agent-browser":"^3.972.8","@aws-sdk/util-user-agent-node":"^3.973.11","@smithy/config-resolver":"^4.4.13","@smithy/core":"^3.23.12","@smithy/fetch-http-handler":"^5.3.15","@smithy/hash-node":"^4.2.12","@smithy/invalid-dependency":"^4.2.12","@smithy/middleware-content-length":"^4.2.12","@smithy/middleware-endpoint":"^4.4.27","@smithy/middleware-retry":"^4.4.44","@smithy/middleware-serde":"^4.2.15","@smithy/middleware-stack":"^4.2.12","@smithy/node-config-provider":"^4.3.12","@smithy/node-http-handler":"^4.5.0","@smithy/protocol-http":"^5.3.12","@smithy/smithy-client":"^4.12.7","@smithy/types":"^4.13.1","@smithy/url-parser":"^4.2.12","@smithy/util-base64":"^4.3.2","@smithy/util-body-length-browser":"^4.2.2","@smithy/util-body-length-node":"^4.2.3","@smithy/util-defaults-mode-browser":"^4.3.43","@smithy/util-defaults-mode-node":"^4.2.47","@smithy/util-endpoints":"^3.3.3","@smithy/util-middleware":"^4.2.12","@smithy/util-retry":"^4.2.12","@smithy/util-utf8":"^4.2.2",tslib:"^2.6.2"},devDependencies:{concurrently:"7.0.0","downlevel-dts":"0.10.1",premove:"4.0.0",typescript:"~5.8.3"},typesVersions:{"<4.5":{"dist-types/*":["dist-types/ts3.4/*"]}},files:["./cognito-identity.d.ts","./cognito-identity.js","./signin.d.ts","./signin.js","./sso-oidc.d.ts","./sso-oidc.js","./sso.d.ts","./sso.js","./sts.d.ts","./sts.js","dist-*/**"],browser:{"./dist-es/submodules/cognito-identity/runtimeConfig":"./dist-es/submodules/cognito-identity/runtimeConfig.browser","./dist-es/submodules/signin/runtimeConfig":"./dist-es/submodules/signin/runtimeConfig.browser","./dist-es/submodules/sso-oidc/runtimeConfig":"./dist-es/submodules/sso-oidc/runtimeConfig.browser","./dist-es/submodules/sso/runtimeConfig":"./dist-es/submodules/sso/runtimeConfig.browser","./dist-es/submodules/sts/runtimeConfig":"./dist-es/submodules/sts/runtimeConfig.browser"},"react-native":{},homepage:"https://github.com/aws/aws-sdk-js-v3/tree/main/packages/nested-clients",repository:{type:"git",url:"https://github.com/aws/aws-sdk-js-v3.git",directory:"packages/nested-clients"},exports:{"./package.json":"./package.json","./sso-oidc":{types:"./dist-types/submodules/sso-oidc/index.d.ts",module:"./dist-es/submodules/sso-oidc/index.js",node:"./dist-cjs/submodules/sso-oidc/index.js",import:"./dist-es/submodules/sso-oidc/index.js",require:"./dist-cjs/submodules/sso-oidc/index.js"},"./sts":{types:"./dist-types/submodules/sts/index.d.ts",module:"./dist-es/submodules/sts/index.js",node:"./dist-cjs/submodules/sts/index.js",import:"./dist-es/submodules/sts/index.js",require:"./dist-cjs/submodules/sts/index.js"},"./signin":{types:"./dist-types/submodules/signin/index.d.ts",module:"./dist-es/submodules/signin/index.js",node:"./dist-cjs/submodules/signin/index.js",import:"./dist-es/submodules/signin/index.js",require:"./dist-cjs/submodules/signin/index.js"},"./cognito-identity":{types:"./dist-types/submodules/cognito-identity/index.d.ts",module:"./dist-es/submodules/cognito-identity/index.js",node:"./dist-cjs/submodules/cognito-identity/index.js",import:"./dist-es/submodules/cognito-identity/index.js",require:"./dist-cjs/submodules/cognito-identity/index.js"},"./sso":{types:"./dist-types/submodules/sso/index.d.ts",module:"./dist-es/submodules/sso/index.js",node:"./dist-cjs/submodules/sso/index.js",import:"./dist-es/submodules/sso/index.js",require:"./dist-cjs/submodules/sso/index.js"}}}});
2
+ import{Fm as s}from"./chunk-zf1eqgzt.js";var i=s((t,e)=>{e.exports={name:"@aws-sdk/nested-clients",version:"3.996.14",description:"Nested clients for AWS SDK packages.",main:"./dist-cjs/index.js",module:"./dist-es/index.js",types:"./dist-types/index.d.ts",scripts:{build:"yarn lint && concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs","build:cjs":"node ../../scripts/compilation/inline nested-clients","build:es":"tsc -p tsconfig.es.json","build:include:deps":'yarn g:turbo run build -F="$npm_package_name"',"build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4",clean:"premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",lint:"node ../../scripts/validation/submodules-linter.js --pkg nested-clients",test:"yarn g:vitest run","test:watch":"yarn g:vitest watch"},engines:{node:">=20.0.0"},sideEffects:!1,author:{name:"AWS SDK for JavaScript Team",url:"https://aws.amazon.com/javascript/"},license:"Apache-2.0",dependencies:{"@aws-crypto/sha256-browser":"5.2.0","@aws-crypto/sha256-js":"5.2.0","@aws-sdk/core":"^3.973.24","@aws-sdk/middleware-host-header":"^3.972.8","@aws-sdk/middleware-logger":"^3.972.8","@aws-sdk/middleware-recursion-detection":"^3.972.8","@aws-sdk/middleware-user-agent":"^3.972.25","@aws-sdk/region-config-resolver":"^3.972.9","@aws-sdk/types":"^3.973.6","@aws-sdk/util-endpoints":"^3.996.5","@aws-sdk/util-user-agent-browser":"^3.972.8","@aws-sdk/util-user-agent-node":"^3.973.11","@smithy/config-resolver":"^4.4.13","@smithy/core":"^3.23.12","@smithy/fetch-http-handler":"^5.3.15","@smithy/hash-node":"^4.2.12","@smithy/invalid-dependency":"^4.2.12","@smithy/middleware-content-length":"^4.2.12","@smithy/middleware-endpoint":"^4.4.27","@smithy/middleware-retry":"^4.4.44","@smithy/middleware-serde":"^4.2.15","@smithy/middleware-stack":"^4.2.12","@smithy/node-config-provider":"^4.3.12","@smithy/node-http-handler":"^4.5.0","@smithy/protocol-http":"^5.3.12","@smithy/smithy-client":"^4.12.7","@smithy/types":"^4.13.1","@smithy/url-parser":"^4.2.12","@smithy/util-base64":"^4.3.2","@smithy/util-body-length-browser":"^4.2.2","@smithy/util-body-length-node":"^4.2.3","@smithy/util-defaults-mode-browser":"^4.3.43","@smithy/util-defaults-mode-node":"^4.2.47","@smithy/util-endpoints":"^3.3.3","@smithy/util-middleware":"^4.2.12","@smithy/util-retry":"^4.2.12","@smithy/util-utf8":"^4.2.2",tslib:"^2.6.2"},devDependencies:{concurrently:"7.0.0","downlevel-dts":"0.10.1",premove:"4.0.0",typescript:"~5.8.3"},typesVersions:{"<4.5":{"dist-types/*":["dist-types/ts3.4/*"]}},files:["./cognito-identity.d.ts","./cognito-identity.js","./signin.d.ts","./signin.js","./sso-oidc.d.ts","./sso-oidc.js","./sso.d.ts","./sso.js","./sts.d.ts","./sts.js","dist-*/**"],browser:{"./dist-es/submodules/cognito-identity/runtimeConfig":"./dist-es/submodules/cognito-identity/runtimeConfig.browser","./dist-es/submodules/signin/runtimeConfig":"./dist-es/submodules/signin/runtimeConfig.browser","./dist-es/submodules/sso-oidc/runtimeConfig":"./dist-es/submodules/sso-oidc/runtimeConfig.browser","./dist-es/submodules/sso/runtimeConfig":"./dist-es/submodules/sso/runtimeConfig.browser","./dist-es/submodules/sts/runtimeConfig":"./dist-es/submodules/sts/runtimeConfig.browser"},"react-native":{},homepage:"https://github.com/aws/aws-sdk-js-v3/tree/main/packages/nested-clients",repository:{type:"git",url:"https://github.com/aws/aws-sdk-js-v3.git",directory:"packages/nested-clients"},exports:{"./package.json":"./package.json","./sso-oidc":{types:"./dist-types/submodules/sso-oidc/index.d.ts",module:"./dist-es/submodules/sso-oidc/index.js",node:"./dist-cjs/submodules/sso-oidc/index.js",import:"./dist-es/submodules/sso-oidc/index.js",require:"./dist-cjs/submodules/sso-oidc/index.js"},"./sts":{types:"./dist-types/submodules/sts/index.d.ts",module:"./dist-es/submodules/sts/index.js",node:"./dist-cjs/submodules/sts/index.js",import:"./dist-es/submodules/sts/index.js",require:"./dist-cjs/submodules/sts/index.js"},"./signin":{types:"./dist-types/submodules/signin/index.d.ts",module:"./dist-es/submodules/signin/index.js",node:"./dist-cjs/submodules/signin/index.js",import:"./dist-es/submodules/signin/index.js",require:"./dist-cjs/submodules/signin/index.js"},"./cognito-identity":{types:"./dist-types/submodules/cognito-identity/index.d.ts",module:"./dist-es/submodules/cognito-identity/index.js",node:"./dist-cjs/submodules/cognito-identity/index.js",import:"./dist-es/submodules/cognito-identity/index.js",require:"./dist-cjs/submodules/cognito-identity/index.js"},"./sso":{types:"./dist-types/submodules/sso/index.d.ts",module:"./dist-es/submodules/sso/index.js",node:"./dist-cjs/submodules/sso/index.js",import:"./dist-es/submodules/sso/index.js",require:"./dist-cjs/submodules/sso/index.js"}}}});
3
3
  export{i as h};
4
4
 
5
- //# debugId=630E041A87771DE864756E2164756E21
5
+ //# debugId=5DD5A8A563A7333764756E2164756E21
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "630E041A87771DE864756E2164756E21",
7
+ "debugId": "5DD5A8A563A7333764756E2164756E21",
8
8
  "names": []
9
9
  }
@@ -2,6 +2,6 @@
2
2
  import{existsSync as $,readdirSync as B}from"fs";import{join as Y,relative as G}from"path";function J(K,Q=[]){let U=[],X=(H)=>{let z=G(K,H).split("\\").join("/");return Q.some((q)=>z===q||z.startsWith(`${q}/`))},V=(H)=>{for(let z of B(H,{withFileTypes:!0}).sort((q,Z)=>q.name<Z.name?-1:q.name>Z.name?1:0)){let q=Y(H,z.name);if(X(q))continue;if(z.isDirectory()){if(z.name.startsWith(".")||z.name==="node_modules")continue;if($(Y(q,"package.json")))continue;V(q);continue}if(!z.name.endsWith(".ts")&&!z.name.endsWith(".tsx"))continue;if(z.name.endsWith(".d.ts"))continue;if(/\.(test|test-d|spec|bench)\.tsx?$/.test(z.name))continue;U.push(q)}};if(!$(K))return U;return V(K),U}class A extends Error{constructor(K,Q){super(K,Q);this.name="DiscoveryError"}}async function W(K,Q,U=[],X){let V=new Set;for(let H of J(K,U)){let z;try{z=await import(H)}catch(q){throw new A(`${H} could not be imported, so the classes in it could not be discovered:
3
3
  ${q.message}
4
4
  List the classes explicitly in the config slice for this directory to skip the walk.`,{cause:q})}for(let q of Object.values(z)){if(typeof q==="function"&&q!==Q&&Object.prototype.isPrototypeOf.call(Q,q)){V.add(q);continue}X?.(q,H)}}return[...V]}function F(){return Y(process.cwd(),process.env.GEMI_PROJECT_DIR??"")}
5
- export{J as vm,A as wm,W as xm,F as ym};
5
+ export{J as xm,A as ym,W as zm,F as Am};
6
6
 
7
- //# debugId=CE1E38B25178491F64756E2164756E21
7
+ //# debugId=F71908125BD8177064756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "import { existsSync, readdirSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\n\n/**\n * Finding the classes an application declared and never imported — the walk\n * #322 and #323 both end at.\n *\n * ### Why it has to run the files\n *\n * A job that is written and not listed does not fail; it disappears.\n * `QueueManager.run` looks a dispatched name up in the map its config built and\n * drops what is not there, so the dispatch is simply lost. A cron drifts worse:\n * nothing is waiting on a tick, so a job that never fires reports nothing to\n * anyone. What both come down to is that `app/config/queue.ts` naming every\n * `Job` subclass is the *only* thing putting those classes in the module graph —\n * the list and the directory are two spellings of one set, kept in step by hand.\n *\n * The way out of that is to read the directory, and there is no static read that\n * will do: the class does not exist until its module has run. So **every file\n * walked here is imported**, and a file that *does something* when imported does\n * it here — at boot, in production, on every start. `gemi check models` makes\n * the same trade for the same reason and pays it once per CI run; a caller of\n * this pays it once per process.\n *\n * ### What that asks of a caller\n *\n * **Point it at a directory of class declarations, not at `app/`.** The skip\n * rules on `sourceFiles` drop what certainly is not one — tests, benchmarks,\n * `.d.ts`, vendored packages — and nothing else. Widening the guesses is how a\n * discovery pass ends up quietly covering less than the directory holds, which\n * is the same silence in a new place.\n *\n * **Let a broken file stop the boot.** `discoverClasses` rethrows an import\n * failure naming the file rather than dropping it and carrying on, for the same\n * reason: four classes found out of five looks exactly like five out of five.\n *\n * **Leave a way out.** Discovery is what should happen when an app said\n * nothing. An app that lists its classes explicitly must not reach this file at\n * all — that is the escape hatch for a directory holding something this cannot\n * import, and it is the sentence an error from here should point at.\n *\n * ### One more thing worth knowing\n *\n * This imports by absolute path, while the application imports the same files\n * through the `@/app/*` alias. Bun keys its module registry by the *resolved*\n * path, so those two specifiers land on one module: a job already reached from\n * a controller is not evaluated a second time here, and the class object is the\n * same one. `gemi build` leaves that true in production — `packages: \"external\"`\n * keeps the app's own code out of `dist/server/server.mjs` and resolves it from\n * source at runtime, exactly as `gemi dev` does.\n *\n * Nothing here depends on that holding, and deliberately: `QueueManager` and the\n * `Scheduler`'s cross-reload registry are both keyed by name rather than by\n * class identity, so a build that did inline the app's modules would produce a\n * duplicate class object and still register the right job. Worth knowing before\n * writing a registry keyed the other way.\n */\n\n/**\n * The files under `dir` that could declare a class.\n *\n * Everything underneath it, because apps do group classes into folders, minus\n * what cannot be one. Each of these is going to be *imported*, so the exclusions\n * are about what is certainly not source rather than about what is probably not:\n *\n * - **Declaration files.** `.d.ts` has no runtime module behind it.\n * - **Tests, type tests and benchmarks**, by the suffix a runner already\n * recognises.\n * - **Dot-directories and `node_modules`.**\n * - **Any directory holding a `package.json`.** That is a package that happens\n * to live here — a vendored client, a generated SDK — not this app's source,\n * and importing its entry point runs somebody else's module graph. The\n * template has two under `app/models`.\n *\n * `ignore` is the escape hatch for the rest: a path prefix, relative to `dir`,\n * naming a file or a directory of adjacent code that runs something on import.\n * Nothing is ignored by default.\n *\n * The order is the same on every run over the same tree, which matters because\n * the caller is going to import in it: entries are sorted per directory before\n * recursing, and `readdirSync` order is the filesystem's rather than\n * alphabetical — a tree written `A.ts` then `B.ts` reads back `B.ts` first on\n * the machines this was tested on. Sorting per directory rather than sorting the\n * finished list is deliberate: for a tree holding both `a.ts` and `a/b.ts`, this\n * emits `a/b.ts` first, because the directory sorts before the file.\n *\n * A directory that does not exist yields an empty list rather than throwing.\n * \"The app has no jobs yet\" is an ordinary state and not this function's to\n * complain about — but it is indistinguishable from \"the app's source did not\n * ship\", so a caller that boots on the answer owes the reader a word about which\n * one it got.\n */\nexport function sourceFiles(dir: string, ignore: string[] = []): string[] {\n const out: string[] = [];\n\n const ignored = (path: string) => {\n const rel = relative(dir, path).split(\"\\\\\").join(\"/\");\n return ignore.some(\n (pattern) => rel === pattern || rel.startsWith(`${pattern}/`),\n );\n };\n\n const walk = (current: string) => {\n for (const entry of readdirSync(current, { withFileTypes: true }).sort(\n (a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0),\n )) {\n const path = join(current, entry.name);\n if (ignored(path)) continue;\n\n if (entry.isDirectory()) {\n if (entry.name.startsWith(\".\") || entry.name === \"node_modules\")\n continue;\n if (existsSync(join(path, \"package.json\"))) continue;\n walk(path);\n continue;\n }\n\n if (!entry.name.endsWith(\".ts\") && !entry.name.endsWith(\".tsx\")) continue;\n if (entry.name.endsWith(\".d.ts\")) continue;\n if (/\\.(test|test-d|spec|bench)\\.tsx?$/.test(entry.name)) continue;\n\n out.push(path);\n }\n };\n\n if (!existsSync(dir)) return out;\n\n walk(dir);\n return out;\n}\n\n/**\n * A class, as much of one as this file can name. `abstract` so that a base an\n * app never instantiates directly is a legal argument.\n */\ntype ClassLike = abstract new (...args: never[]) => unknown;\n\n/**\n * A file that would not import, reported with the file that would not import.\n *\n * Separate from a bare rethrow because the stack of a failed dynamic import\n * names the module that failed to *resolve*, several frames deep, and says\n * nothing about the walk that asked for it — so the reader learns that some\n * `?raw` specifier is unresolvable without learning that discovery is what\n * imported it, or that listing the classes explicitly is how they get their boot\n * back.\n */\nexport class DiscoveryError extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = \"DiscoveryError\";\n }\n}\n\n/**\n * Every exported class under `dir` whose prototype chain reaches `base`.\n *\n * `base` is a parameter rather than an import so that this file names no\n * service and stays cheap to depend on — `bin/check-models.ts` uses the walker\n * above and is bundled into `dist/bin/gemi.js`, which is not somewhere gemi's\n * service layer should end up. It is also what lets a test hand in a base class\n * of its own instead of standing up a project that can resolve `gemi/services`.\n *\n * `base` itself is never returned. A directory whose files import their base\n * from a sibling — the shape an app reaches for when several jobs share a gate —\n * re-exports it as often as not, and a framework that scheduled the abstract\n * base along with its subclasses would be running a job nobody wrote.\n *\n * A class is returned once no matter how many exports name it. A barrel in the\n * directory re-exporting everything beside it is the ordinary case, and it makes\n * every class reachable twice.\n *\n * The order is the walk's, and within a file the module namespace's, which the\n * language sorts by name. So the answer is the same on every run — worth having\n * where the caller is a scheduler and the alternative is a boot order that\n * depends on the filesystem.\n *\n * `onSkipped` is handed every export that did *not* match, with the file it came\n * from. Discovery's characteristic failure is a thing the author wrote and this\n * walk cannot see, and by the time an export has been discarded here the\n * information about why is gone — the caller is left holding \"four classes\"\n * where the directory holds five. A caller that can recognise its own\n * near-misses, as `discoverCommands` recognises a builder chain that was never\n * finished, uses this to say so by name instead.\n *\n * @throws DiscoveryError if a walked file cannot be imported. Not a skip: a file\n * that will not load is a class the caller was going to be told about and now is\n * not, which is the failure discovery exists to remove.\n */\nexport async function discoverClasses<T extends ClassLike>(\n dir: string,\n base: T,\n ignore: string[] = [],\n onSkipped?: (value: unknown, file: string) => void,\n): Promise<T[]> {\n const found = new Set<T>();\n\n for (const path of sourceFiles(dir, ignore)) {\n let module: Record<string, unknown>;\n\n try {\n module = (await import(path)) as Record<string, unknown>;\n } catch (error) {\n throw new DiscoveryError(\n `${path} could not be imported, so the classes in it could not be ` +\n `discovered:\\n ${(error as Error).message}\\n` +\n `List the classes explicitly in the config slice for this directory ` +\n `to skip the walk.`,\n { cause: error },\n );\n }\n\n for (const value of Object.values(module)) {\n if (\n typeof value === \"function\" &&\n value !== base &&\n Object.prototype.isPrototypeOf.call(base, value)\n ) {\n found.add(value as unknown as T);\n continue;\n }\n\n onSkipped?.(value, path);\n }\n }\n\n return [...found];\n}\n\n/**\n * The directory an app's `app/` sits in, as the running process can know it.\n *\n * `ROOT_DIR` is the obvious answer and is not available: `Server.start` awaits\n * `waitForBoot()` — every provider's `register` and `boot` — and only then\n * imports the http layer that sets it. Anything resolving paths during boot is\n * earlier than the variable it would want.\n *\n * What it can use is the same rule `httpProd` computes `ROOT_DIR` with a moment\n * later, which is why that file now calls this instead of repeating it. `gemi\n * dev` and `gemi start` both spawn the server with no `cwd`, so the process\n * inherits the CLI's, and the CLI takes `process.cwd()` for the project root\n * itself — `bun/preload.ts` reads `gemi.config` from it on the same assumption.\n *\n * `httpDev` computes a bare `process.cwd()`, so it and `httpProd` already\n * disagree whenever `GEMI_PROJECT_DIR` is set. Nothing in this repo sets it and\n * `gemi start` ignores it when locating the built entry point, so the two rules\n * are the same rule for every configuration that runs today; the divergence is\n * older than this function and wants its own fix.\n */\nexport function projectRoot(): string {\n return join(process.cwd(), process.env.GEMI_PROJECT_DIR ?? \"\");\n}\n"
6
6
  ],
7
7
  "mappings": ";AAAA,qBAAS,iBAAY,WACrB,eAAS,cAAM,aA2FR,SAAS,CAAW,CAAC,EAAa,EAAmB,CAAC,EAAa,CACxE,IAAM,EAAgB,CAAC,EAEjB,EAAU,CAAC,IAAiB,CAChC,IAAM,EAAM,EAAS,EAAK,CAAI,EAAE,MAAM,IAAI,EAAE,KAAK,GAAG,EACpD,OAAO,EAAO,KACZ,CAAC,IAAY,IAAQ,GAAW,EAAI,WAAW,GAAG,IAAU,CAC9D,GAGI,EAAO,CAAC,IAAoB,CAChC,QAAW,KAAS,EAAY,EAAS,CAAE,cAAe,EAAK,CAAC,EAAE,KAChE,CAAC,EAAG,IAAO,EAAE,KAAO,EAAE,KAAO,GAAK,EAAE,KAAO,EAAE,KAAO,EAAI,CAC1D,EAAG,CACD,IAAM,EAAO,EAAK,EAAS,EAAM,IAAI,EACrC,GAAI,EAAQ,CAAI,EAAG,SAEnB,GAAI,EAAM,YAAY,EAAG,CACvB,GAAI,EAAM,KAAK,WAAW,GAAG,GAAK,EAAM,OAAS,eAC/C,SACF,GAAI,EAAW,EAAK,EAAM,cAAc,CAAC,EAAG,SAC5C,EAAK,CAAI,EACT,SAGF,GAAI,CAAC,EAAM,KAAK,SAAS,KAAK,GAAK,CAAC,EAAM,KAAK,SAAS,MAAM,EAAG,SACjE,GAAI,EAAM,KAAK,SAAS,OAAO,EAAG,SAClC,GAAI,oCAAoC,KAAK,EAAM,IAAI,EAAG,SAE1D,EAAI,KAAK,CAAI,IAIjB,GAAI,CAAC,EAAW,CAAG,EAAG,OAAO,EAG7B,OADA,EAAK,CAAG,EACD,EAmBF,MAAM,UAAuB,KAAM,CACxC,WAAW,CAAC,EAAiB,EAA+B,CAC1D,MAAM,EAAS,CAAO,EACtB,KAAK,KAAO,iBAEhB,CAqCA,eAAsB,CAAoC,CACxD,EACA,EACA,EAAmB,CAAC,EACpB,EACc,CACd,IAAM,EAAQ,IAAI,IAElB,QAAW,KAAQ,EAAY,EAAK,CAAM,EAAG,CAC3C,IAAI,EAEJ,GAAI,CACF,EAAU,MAAa,UACvB,MAAO,EAAO,CACd,MAAM,IAAI,EACR,GAAG;AAAA,MACoB,EAAgB;AAAA,sFAGvC,CAAE,MAAO,CAAM,CACjB,EAGF,QAAW,KAAS,OAAO,OAAO,CAAM,EAAG,CACzC,GACE,OAAO,IAAU,YACjB,IAAU,GACV,OAAO,UAAU,cAAc,KAAK,EAAM,CAAK,EAC/C,CACA,EAAM,IAAI,CAAqB,EAC/B,SAGF,IAAY,EAAO,CAAI,GAI3B,MAAO,CAAC,GAAG,CAAK,EAuBX,SAAS,CAAW,EAAW,CACpC,OAAO,EAAK,QAAQ,IAAI,EAAG,QAAQ,IAAI,kBAAoB,EAAE",
8
- "debugId": "CE1E38B25178491F64756E2164756E21",
8
+ "debugId": "F71908125BD8177064756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Dm as y}from"./chunk-k9882kqg.js";var v=y((x)=>{class s extends Error{name="ProviderError";tryNextLink;constructor(r,t=!0){let n,e=!0;if(typeof t==="boolean")n=void 0,e=t;else if(t!=null&&typeof t==="object")n=t.logger,e=t.tryNextLink??!0;super(r);this.tryNextLink=e,Object.setPrototypeOf(this,s.prototype),n?.debug?.(`@smithy/property-provider ${e?"->":"(!)"} ${r}`)}static from(r,t=!0){return Object.assign(new this(r.message,t),r)}}class f extends s{name="CredentialsProviderError";constructor(r,t=!0){super(r,t);Object.setPrototypeOf(this,f.prototype)}}class l extends s{name="TokenProviderError";constructor(r,t=!0){super(r,t);Object.setPrototypeOf(this,l.prototype)}}var p=(...r)=>async()=>{if(r.length===0)throw new s("No providers in chain");let t;for(let n of r)try{return await n()}catch(e){if(t=e,e?.tryNextLink)continue;throw e}throw t},d=(r)=>()=>Promise.resolve(r),h=(r,t,n)=>{let e,o,i,c=!1,a=async()=>{if(!o)o=r();try{e=await o,i=!0,c=!1}finally{o=void 0}return e};if(t===void 0)return async(u)=>{if(!i||u?.forceRefresh)e=await a();return e};return async(u)=>{if(!i||u?.forceRefresh)e=await a();if(c)return e;if(n&&!n(e))return c=!0,e;if(t(e))return await a(),e;return e}};x.CredentialsProviderError=f;x.ProviderError=s;x.TokenProviderError=l;x.chain=p;x.fromStatic=d;x.memoize=h});
2
+ import{Fm as y}from"./chunk-zf1eqgzt.js";var v=y((x)=>{class s extends Error{name="ProviderError";tryNextLink;constructor(r,t=!0){let n,e=!0;if(typeof t==="boolean")n=void 0,e=t;else if(t!=null&&typeof t==="object")n=t.logger,e=t.tryNextLink??!0;super(r);this.tryNextLink=e,Object.setPrototypeOf(this,s.prototype),n?.debug?.(`@smithy/property-provider ${e?"->":"(!)"} ${r}`)}static from(r,t=!0){return Object.assign(new this(r.message,t),r)}}class f extends s{name="CredentialsProviderError";constructor(r,t=!0){super(r,t);Object.setPrototypeOf(this,f.prototype)}}class l extends s{name="TokenProviderError";constructor(r,t=!0){super(r,t);Object.setPrototypeOf(this,l.prototype)}}var p=(...r)=>async()=>{if(r.length===0)throw new s("No providers in chain");let t;for(let n of r)try{return await n()}catch(e){if(t=e,e?.tryNextLink)continue;throw e}throw t},d=(r)=>()=>Promise.resolve(r),h=(r,t,n)=>{let e,o,i,c=!1,a=async()=>{if(!o)o=r();try{e=await o,i=!0,c=!1}finally{o=void 0}return e};if(t===void 0)return async(u)=>{if(!i||u?.forceRefresh)e=await a();return e};return async(u)=>{if(!i||u?.forceRefresh)e=await a();if(c)return e;if(n&&!n(e))return c=!0,e;if(t(e))return await a(),e;return e}};x.CredentialsProviderError=f;x.ProviderError=s;x.TokenProviderError=l;x.chain=p;x.fromStatic=d;x.memoize=h});
3
3
  export{v as Y};
4
4
 
5
- //# debugId=169EA17931F8779564756E2164756E21
5
+ //# debugId=F5CCB4A1466313AF64756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "'use strict';\n\nclass ProviderError extends Error {\n name = \"ProviderError\";\n tryNextLink;\n constructor(message, options = true) {\n let logger;\n let tryNextLink = true;\n if (typeof options === \"boolean\") {\n logger = undefined;\n tryNextLink = options;\n }\n else if (options != null && typeof options === \"object\") {\n logger = options.logger;\n tryNextLink = options.tryNextLink ?? true;\n }\n super(message);\n this.tryNextLink = tryNextLink;\n Object.setPrototypeOf(this, ProviderError.prototype);\n logger?.debug?.(`@smithy/property-provider ${tryNextLink ? \"->\" : \"(!)\"} ${message}`);\n }\n static from(error, options = true) {\n return Object.assign(new this(error.message, options), error);\n }\n}\n\nclass CredentialsProviderError extends ProviderError {\n name = \"CredentialsProviderError\";\n constructor(message, options = true) {\n super(message, options);\n Object.setPrototypeOf(this, CredentialsProviderError.prototype);\n }\n}\n\nclass TokenProviderError extends ProviderError {\n name = \"TokenProviderError\";\n constructor(message, options = true) {\n super(message, options);\n Object.setPrototypeOf(this, TokenProviderError.prototype);\n }\n}\n\nconst chain = (...providers) => async () => {\n if (providers.length === 0) {\n throw new ProviderError(\"No providers in chain\");\n }\n let lastProviderError;\n for (const provider of providers) {\n try {\n const credentials = await provider();\n return credentials;\n }\n catch (err) {\n lastProviderError = err;\n if (err?.tryNextLink) {\n continue;\n }\n throw err;\n }\n }\n throw lastProviderError;\n};\n\nconst fromStatic = (staticValue) => () => Promise.resolve(staticValue);\n\nconst memoize = (provider, isExpired, requiresRefresh) => {\n let resolved;\n let pending;\n let hasResult;\n let isConstant = false;\n const coalesceProvider = async () => {\n if (!pending) {\n pending = provider();\n }\n try {\n resolved = await pending;\n hasResult = true;\n isConstant = false;\n }\n finally {\n pending = undefined;\n }\n return resolved;\n };\n if (isExpired === undefined) {\n return async (options) => {\n if (!hasResult || options?.forceRefresh) {\n resolved = await coalesceProvider();\n }\n return resolved;\n };\n }\n return async (options) => {\n if (!hasResult || options?.forceRefresh) {\n resolved = await coalesceProvider();\n }\n if (isConstant) {\n return resolved;\n }\n if (requiresRefresh && !requiresRefresh(resolved)) {\n isConstant = true;\n return resolved;\n }\n if (isExpired(resolved)) {\n await coalesceProvider();\n return resolved;\n }\n return resolved;\n };\n};\n\nexports.CredentialsProviderError = CredentialsProviderError;\nexports.ProviderError = ProviderError;\nexports.TokenProviderError = TokenProviderError;\nexports.chain = chain;\nexports.fromStatic = fromStatic;\nexports.memoize = memoize;\n"
6
6
  ],
7
7
  "mappings": ";uDAEA,MAAM,UAAsB,KAAM,CAC9B,KAAO,gBACP,YACA,WAAW,CAAC,EAAS,EAAU,GAAM,CACjC,IAAI,EACA,EAAc,GAClB,GAAI,OAAO,IAAY,UACnB,EAAS,OACT,EAAc,EAEb,QAAI,GAAW,MAAQ,OAAO,IAAY,SAC3C,EAAS,EAAQ,OACjB,EAAc,EAAQ,aAAe,GAEzC,MAAM,CAAO,EACb,KAAK,YAAc,EACnB,OAAO,eAAe,KAAM,EAAc,SAAS,EACnD,GAAQ,QAAQ,6BAA6B,EAAc,KAAO,SAAS,GAAS,QAEjF,KAAI,CAAC,EAAO,EAAU,GAAM,CAC/B,OAAO,OAAO,OAAO,IAAI,KAAK,EAAM,QAAS,CAAO,EAAG,CAAK,EAEpE,CAEA,MAAM,UAAiC,CAAc,CACjD,KAAO,2BACP,WAAW,CAAC,EAAS,EAAU,GAAM,CACjC,MAAM,EAAS,CAAO,EACtB,OAAO,eAAe,KAAM,EAAyB,SAAS,EAEtE,CAEA,MAAM,UAA2B,CAAc,CAC3C,KAAO,qBACP,WAAW,CAAC,EAAS,EAAU,GAAM,CACjC,MAAM,EAAS,CAAO,EACtB,OAAO,eAAe,KAAM,EAAmB,SAAS,EAEhE,CAEA,IAAM,EAAQ,IAAI,IAAc,SAAY,CACxC,GAAI,EAAU,SAAW,EACrB,MAAM,IAAI,EAAc,uBAAuB,EAEnD,IAAI,EACJ,QAAW,KAAY,EACnB,GAAI,CAEA,OADoB,MAAM,EAAS,EAGvC,MAAO,EAAK,CAER,GADA,EAAoB,EAChB,GAAK,YACL,SAEJ,MAAM,EAGd,MAAM,GAGJ,EAAa,CAAC,IAAgB,IAAM,QAAQ,QAAQ,CAAW,EAE/D,EAAU,CAAC,EAAU,EAAW,IAAoB,CACtD,IAAI,EACA,EACA,EACA,EAAa,GACX,EAAmB,SAAY,CACjC,GAAI,CAAC,EACD,EAAU,EAAS,EAEvB,GAAI,CACA,EAAW,MAAM,EACjB,EAAY,GACZ,EAAa,UAEjB,CACI,EAAU,OAEd,OAAO,GAEX,GAAI,IAAc,OACd,MAAO,OAAO,IAAY,CACtB,GAAI,CAAC,GAAa,GAAS,aACvB,EAAW,MAAM,EAAiB,EAEtC,OAAO,GAGf,MAAO,OAAO,IAAY,CACtB,GAAI,CAAC,GAAa,GAAS,aACvB,EAAW,MAAM,EAAiB,EAEtC,GAAI,EACA,OAAO,EAEX,GAAI,GAAmB,CAAC,EAAgB,CAAQ,EAE5C,OADA,EAAa,GACN,EAEX,GAAI,EAAU,CAAQ,EAElB,OADA,MAAM,EAAiB,EAChB,EAEX,OAAO,IAIP,2BAA2B,EAC3B,gBAAgB,EAChB,qBAAqB,EACrB,QAAQ,EACR,aAAa,EACb,UAAU",
8
- "debugId": "169EA17931F8779564756E2164756E21",
8
+ "debugId": "F5CCB4A1466313AF64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Gj as C,Hj as W1,Ij as H1}from"./chunk-y5kfqq4f.js";import{Nj as I1,Qj as E}from"./chunk-ezvtkbp9.js";import{Rj as A1}from"./chunk-6g1xac70.js";import{Zl as G0}from"./chunk-4m8t67px.js";import{bm as G1}from"./chunk-n3kg99yw.js";import{ym as Q1}from"./chunk-4v5c4mes.js";import{Gm as SQ}from"./chunk-k9882kqg.js";class c1{static kind="controller";constructor(){}}class x0 extends c1{}function D1(Q){let Z=new Map;if(!Q)return Z;for(let J of Q.split(";")){let $=J.indexOf("=");if($===-1)continue;let K=J.slice(0,$).trim();if(!K)continue;Z.set(K,J.slice($+1).trim())}return Z}function oQ(Q){return D1(Q.headers.get("cookie"))}function m(Q){if(!/^\d+$/.test(Q))return null;let Z=Number(Q);return Number.isSafeInteger(Z)?Z:null}function p1(Q){if(!Q)return null;let Z=Q.trim();if(!/^bytes=/i.test(Z))return null;let $=Z.slice(6).split(",").map((V)=>V.trim()).filter((V)=>V!=="");if($.length!==1)return null;let K=$[0],X=K.indexOf("-");if(X===-1)return null;let Y=K.slice(0,X),W=K.slice(X+1);if(Y===""){let V=m(W);if(V===null)return null;return{kind:"suffix",suffixLength:V}}let G=m(Y);if(G===null)return null;if(W==="")return{kind:"offset",start:G,end:null};let H=m(W);if(H===null||H<G)return null;return{kind:"offset",start:G,end:H}}function u1(Q,Z){if(!Number.isFinite(Z)||Z<=0)return null;let J,$;if(Q.kind==="suffix"){if(Q.suffixLength<=0)return null;J=Math.max(0,Z-Q.suffixLength),$=Z-1}else{if(Q.start>=Z)return null;if(J=Q.start,$=Q.end===null?Z-1:Math.min(Q.end,Z-1),$<J)return null}return{start:J,end:$,length:$-J+1}}function aQ(Q){if(Q.kind==="suffix")return`bytes=-${Q.suffixLength}`;return Q.end===null?`bytes=${Q.start}-`:`bytes=${Q.start}-${Q.end}`}function tQ(Q){if(!Q)return null;let Z=/^bytes\s+(\d+)-(\d+)\/(\d+)$/i.exec(Q.trim());if(!Z)return null;let J=m(Z[1]),$=m(Z[2]),K=m(Z[3]);if(J===null||$===null||K===null||$<J)return null;return{start:J,end:$,total:K}}function rQ(Q,Z,J){return`bytes ${Q}-${Z}/${J}`}function d1(Q){return`bytes */${Q}`}import{randomBytes as q0}from"crypto";var M1=new WeakMap;function R1(Q){let Z=M1.get(Q);if(!Z)Z=q0(16).toString("base64"),M1.set(Q,Z);return Z}function JZ(Q){return M1.get(Q)}function $Z(){let Q=E.getStore()?.req?.rawRequest;if(!Q)throw Error("cspNonce() is only available while a request is being handled.");return R1(Q)}class s extends C{errors={};constructor(Q){super("Validation error");this.name="ValidationError",this.errors=Q,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:Q,status:400}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}function l1(Q){let[Z,J]=Q.match(/\d+|\D+/g)??[];if(!Z||!J)return 0;let $=Number.parseInt(Z);switch(J){case"B":return $;case"KB":return $*1024;case"MB":return $*1024*1024;case"GB":return $*1024*1024*1024;case"TB":return $*1024*1024*1024*1024;default:return 0}}function b0(Q){switch(Q){case"image":return"image";case"png":return"image/png";case"jpg":return"image/jpeg";case"jpeg":return"image/jpeg";case"ttf":return"font/ttf";case"excel":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"csv":return"text/csv";case"word":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"pdf":return"application/pdf";case"json":return"application/json";default:return Q}}function i1(Q){if(typeof Q==="string"||Array.isArray(Q))return Q.length;return}function B1(Q){return typeof Q==="number"&&!Number.isNaN(Q)}var y0=["required","string","boolean","number","email","password","min","max","gte","lte","file","fileType","fileSize","array","object","in"];class x extends Error{name="InvalidValidationRuleError"}function Y1(Q,Z){let J=Z===void 0||Z.trim()===""?Number.NaN:Number(Z);if(Number.isNaN(J))throw new x(`Validation rule "${Q}:${Z??""}" needs a number, e.g. "${Q}:3"`);return J}function n1(Q){let Z=!1,J=0;for(let $ of Object.values(Q)){if(!$||typeof $!=="object")continue;for(let K of Object.keys($)){let X=K.indexOf(":"),Y=X===-1?K:K.slice(0,X);if(Y!=="file"&&Y!=="fileType"&&Y!=="fileSize")continue;if(Z=!0,Y==="fileSize")J+=l1(K.slice(X+1))}}return Z?J:null}function o1(Q){let Z=Q.indexOf(":"),J=Z===-1?Q:Q.slice(0,Z),$=Z===-1?void 0:Q.slice(Z+1);switch(J){case"required":return(K)=>{if(K instanceof Blob)return K.size>0;if(K===null||K===void 0)return!1;if(typeof K==="string"||Array.isArray(K))return K.length>0;return!0};case"string":return(K)=>typeof K==="string";case"boolean":return(K)=>typeof K==="boolean";case"number":return(K)=>B1(K);case"password":return(K)=>{return typeof K==="string"&&/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(K)};case"min":{let K=Y1(J,$);return(X)=>{let Y=i1(X);return Y!==void 0&&Y>=K}}case"max":{let K=Y1(J,$);return(X)=>{let Y=i1(X);return Y!==void 0&&Y<=K}}case"gte":{let K=Y1(J,$);return(X)=>B1(X)&&X>=K}case"lte":{let K=Y1(J,$);return(X)=>B1(X)&&X<=K}case"email":return(K)=>{return typeof K==="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(K)};case"file":return(K)=>{return K instanceof Blob};case"fileType":{if(!$)throw new x('Validation rule "fileType" needs a type, e.g. "fileType:png" or "fileType:image"');let K=b0($);return(X)=>X instanceof Blob&&X.type.startsWith(K)}case"fileSize":{let K=l1($??"");if(K===0&&!/^0+(B|KB|MB|GB|TB)$/.test($??""))throw new x(`Validation rule "fileSize:${$??""}" needs a whole size in B, KB, MB, GB or TB, e.g. "fileSize:5MB"`);return(X)=>X instanceof Blob&&X.size<=K}case"array":return(K)=>Array.isArray(K);case"object":return(K)=>typeof K==="object"&&K!==null&&!Array.isArray(K)&&!(K instanceof Blob);case"in":{let K=($??"").split(",").filter((X)=>X!=="");if(K.length===0)throw new x('Validation rule "in" needs a comma-separated list, e.g. "in:draft,published"');return(X)=>typeof X==="string"&&K.includes(X)}default:throw new x(`Unknown validation rule "${Q}". Known rules: ${y0.join(", ")}`)}}class C1 extends C{limit;constructor(Q){super("The request body is too large.",{status:413});this.limit=Q}}var s1={b:1,k:1024,kb:1024,m:1048576,mb:1048576,g:1073741824,gb:1073741824};function HZ(Q){if(typeof Q==="number"){if(Number.isFinite(Q)&&Q>=0)return Math.floor(Q);if(Q===1/0)return 1/0}else{let Z=Q.trim().toLowerCase();if(Z==="none"||Z==="off")return 1/0;let J=/^(\d+(?:\.\d+)?)\s*([a-z]*)$/.exec(Z);if(J&&(J[2]===""||(J[2]in s1)))return Math.floor(Number(J[1])*(s1[J[2]]??1))}throw Error(`Invalid body limit ${JSON.stringify(Q)}. Use a byte count or a size such as "64kb", "1mb" or "none".`)}var p=new WeakMap;function VZ(Q){return p.has(Q)}function OZ(Q){return p.get(Q)?.limit??null}function jZ(Q){let Z=p.get(Q);return Z?Z.read>Z.limit:!1}function f0(Q){let Z=Q.headers.get("Content-Length");if(Z===null||!/^\s*\d+\s*$/.test(Z))return null;return Number(Z)}function L1(Q,Z){let J=f0(Q);if(J!==null&&J>Z)throw new C1(Z)}function zZ(Q,Z,J={}){let $=J.uploadLimit??null,K=p.get(Q);if(K)K.limit=Z,K.uploadLimit=$;else{let X={limit:Z,uploadLimit:$,read:0,stream:void 0,used:!1};p.set(Q,X),g0(Q,X)}if(J.checkDeclared!==!1)L1(Q,Z)}function t1(Q,Z){let J=p.get(Q);if(!J||J.uploadLimit===null||J.used||J.read>0)return;J.limit=Math.max(J.limit,J.uploadLimit,Z+J.limit),J.uploadLimit=null}function v0(Q){return Reflect.get(Object.getPrototypeOf(Q),"body",Q)??null}function N1(Q,Z){if(Z.stream!==void 0)return Z.stream;let J=v0(Q);if(!J)return Z.stream=null;let $;return Z.stream=new ReadableStream({async pull(K){$??=J.getReader();let{done:X,value:Y}=await $.read();if(X){K.close();return}if(Z.read+=Y.byteLength,Z.read>Z.limit){let W=new C1(Z.limit);K.error(W),$.cancel(W).catch(()=>{});return}K.enqueue(Y)},cancel(K){return $?$.cancel(K):J.cancel(K)}},{highWaterMark:0}),Z.stream}async function c(Q,Z){if(L1(Q,Z.limit),Z.used||Z.stream?.locked)throw TypeError("Body already used");Z.used=!0;let J=N1(Q,Z);if(!J)return new Uint8Array(0);let $=J.getReader(),K=[],X=0;for(;;){let{done:G,value:H}=await $.read();if(G)break;K.push(H),X+=H.byteLength}let Y=new Uint8Array(X),W=0;for(let G of K)Y.set(G,W),W+=G.byteLength;return Y}function a1(Q){return Q.headers.get("Content-Type")??""}function g0(Q,Z){let J=($,K)=>Object.defineProperty(Q,$,{configurable:!0,...K});J("body",{get:()=>N1(Q,Z)}),J("bodyUsed",{get:()=>Z.used||Boolean(Z.stream?.locked)||Reflect.get(Object.getPrototypeOf(Q),"bodyUsed",Q)}),J("bytes",{value:()=>c(Q,Z)}),J("arrayBuffer",{value:async()=>{let $=await c(Q,Z);return $.buffer.slice($.byteOffset,$.byteOffset+$.byteLength)}}),J("text",{value:async()=>new TextDecoder().decode(await c(Q,Z))}),J("json",{value:async()=>JSON.parse(new TextDecoder().decode(await c(Q,Z)))}),J("blob",{value:async()=>new Blob([await c(Q,Z)],{type:a1(Q)})}),J("formData",{value:async()=>new Response(await c(Q,Z),{headers:{"Content-Type":a1(Q)}}).formData()}),J("clone",{value:()=>{L1(Q,Z.limit);let $=N1(Q,Z),K=null;if($){let[X,Y]=$.tee();Z.stream=X,K=Y}return new Request(Q.url,{method:Q.method,headers:Q.headers,body:K,signal:Q.signal,duplex:"half"})}})}function r1(Q){if(typeof Q!=="string")return null;let[Z]=Q.split(";",1),J=Z.trim().toLowerCase();return J===""?null:J}function e1(Q){if(Q===null)return!1;if(Q==="application/json")return!0;let Z=Q.indexOf("/");return Z>0&&Q.endsWith("+json")&&Q.length>Z+1+5}var a=new WeakMap;function DZ(Q,Z,J,$){a.set(Q,{clientAddress:Z,...J?{grant:Object.freeze({...J,scopes:Object.freeze([...J.scopes])})}:{},...$?{progress:$}:{}})}function Q0(Q){return a.get(Q)?.progress}function Z0(Q){return a.get(Q)?.grant}function J0(Q){return a.has(Q)}function MZ(Q){return a.get(Q)?.clientAddress}var $0=new WeakMap;function BZ(Q,Z){$0.set(Q,Z)}function K0(Q){return $0.get(Q)??null}var _1=new WeakMap;function NZ(Q,Z){let J=_1.get(Q)??[];if(!J.includes(Z))_1.set(Q,[...J,Z])}function CZ(Q){return _1.get(Q)??[]}class u{data;constructor(Q){this.data=Q}get(Q){return this.data[Q]}has(Q){return this.data[Q]!==void 0}toJSON(){return this.data}}function X0(Q){return typeof Q==="object"&&Q!==null&&!(Q instanceof Blob)}function h0(Q,Z){if(!Z.includes(".")||Object.hasOwn(Q,Z))return[{path:[Z],value:Q[Z]}];let J=[{path:[],value:Q}];for(let $ of Z.split(".")){let K=[];for(let{path:X,value:Y}of J){if($==="*"){if(Array.isArray(Y))Y.forEach((W,G)=>K.push({path:[...X,G],value:W}));else if(X0(Y))for(let[W,G]of Object.entries(Y))K.push({path:[...X,W],value:G});continue}if(Array.isArray(Y)&&/^\d+$/.test($)){K.push({path:[...X,Number($)],value:Y[Number($)]});continue}K.push({path:[...X,$],value:X0(Y)&&Object.hasOwn(Y,$)?Y[$]:void 0})}J=K}return J}function Y0(Q){return Q.join(".")}class m0{kind;rawRequest;headers;cookies;search;schema={};routePath;params;domain;state;constructor(Q,Z,J,$){if(!Q){let G=E.getStore().req;this.params=G.params,this.rawRequest=G.rawRequest,this.kind=G.kind,this.routePath=G.routePath,this.domain=G.domain??null,this.state=G.state??new I1}else this.params=Z,this.rawRequest=Q,this.routePath=$,this.kind=J??"api",this.domain=K0(Q),this.state=new I1;this.headers=this.rawRequest.headers;let K=D1(this.rawRequest.headers.get("Cookie")),X=new URL(this.rawRequest.url),Y=new Map;for(let[G,H]of X.searchParams)if(Y.has(G)){let V=Y.get(G);if(Array.isArray(V))V.push(H),Y.set(G,V);else Y.set(G,[V,H])}else Y.set(G,H);let W=Object.fromEntries(Y.entries());this.search=new u(W),this.cookies=K}locale(){let Q=E.getStore();if(Q.locale)return Q.locale;let Z=G1(G0);return Z.isLocaleAware?Z.detectLocale(Q.req):Q.locale}ctx(){return E.getStore()}isModelOriginated(){return J0(this.rawRequest)}mcpGrant(){return Z0(this.rawRequest)??null}cspNonce(){return R1(this.rawRequest)}reportProgress(Q){let Z=Q0(this.rawRequest);if(!Z)return!1;return Z(Q),!0}get signal(){return this.rawRequest.signal}range(){return p1(this.rawRequest.headers.get("Range"))}refine(Q){return{}}async parseBody(){let Q=r1(this.rawRequest.headers.get("Content-Type"));if(e1(Q))return new u(await this.parseJsonBody());if(Q==="application/x-www-form-urlencoded"||Q==="multipart/form-data"){if(Q==="multipart/form-data"&&!A1(this.schema)){let $=n1(this.schema??{});if($!==null)t1(this.rawRequest,$)}let Z;try{Z=await this.rawRequest.formData()}catch($){if($ instanceof C)throw $;throw new C("The request body could not be read as a form.")}let J=new Map;for(let[$,K]of Z.entries())if(J.has($)){let X=J.get($);if(Array.isArray(X))X.push(K);else J.set($,[X,K])}else J.set($,K);return new u(Object.fromEntries(J.entries()))}return new u({})}async parseJsonBody(){if(!this.rawRequest.body)return{};let Q;try{Q=await this.rawRequest.text()}catch(J){if(J instanceof C)throw J;throw new C("The request body could not be read.")}if(Q.trim()==="")return{};let Z;try{Z=JSON.parse(Q)}catch{throw new C("The request body is not valid JSON.")}if(Z===null||typeof Z!=="object")throw new C("The request body must be a JSON object.");return Z}validateInput(Q){if(A1(this.schema))return this.validateWithSchema(Q);let Z=Q.toJSON()??{},J={},$=Object.entries(this.schema).map(([K,X])=>({key:K,rules:Object.entries(X).map(([Y,W])=>({rule:Y,message:W,check:typeof W==="function"?null:this.ruleFor(K,Y)}))}));for(let{key:K,rules:X}of $)for(let{path:Y,value:W}of h0(Z,K)){let G=this.checkField(W,X);if(G.length>0){let H=J[Y0(Y)]??=[];for(let V of G)if(!H.includes(V))H.push(V)}}if(this.addRefinements(J,Z),Object.keys(J).length>0)throw new s(J);return Q}checkField(Q,Z){let J=Z.some(({rule:X})=>X==="required"),$=Q===void 0||Q===null||Q==="",K=[];for(let{rule:X,message:Y,check:W}of Z){let G=Y,H=!1;if(typeof Y==="function")G=Y(Q),H=typeof G>"u";else H=W(Q);if(H)continue;if($&&!J)continue;if(X==="required")return[String(G)];if(!K.includes(String(G)))K.push(String(G))}return K}validateWithSchema(Q){let Z=this.schema.validate(Q.toJSON()),J={};if("issues"in Z)for(let K of Z.issues){let X=Y0(K.path),Y=J[X]??=[];if(!Y.includes(K.message))Y.push(K.message)}let $="value"in Z?new u(Z.value):Q;if(this.addRefinements(J,$.toJSON()),Object.keys(J).length>0)throw new s(J);return $}addRefinements(Q,Z){for(let[J,$]of Object.entries(this.refine(Z)??{})){let K=Q[J]??[];Q[J]=K.includes($)?K:[...K,$]}}ruleFor(Q,Z){try{return o1(Z)}catch(J){if(J instanceof x)throw new x(`${this.constructor.name}.schema.${Q}: ${J.message}`);throw J}}async input(){return this.validateInput(await this.parseBody())}async safeInput(){let Q=await this.parseBody();try{return{isValid:!0,errors:{},input:this.validateInput(Q)}}catch(Z){if(!(Z instanceof s))throw Z;return{isValid:!1,errors:Z.errors,input:Q}}}}var W0="x-gemi-sign-in";class c0 extends C{error;constructor(Q="Not authorized"){super(Q);this.name="AuthorizationError",this.error=Q,this.payload={api:{status:401,data:{error:H1("authorization",this.error,401)}},view:{}}}}class F1 extends C{static apiStatus=403;error;constructor(Q="Insufficient permissions"){super(Q);this.name="InsufficientPermissionsError",this.error=Q,this.payload={api:{status:F1.apiStatus,data:{error:H1("permission",this.error,F1.apiStatus)}},view:{status:403}}}}class w1 extends C{total;constructor(Q){super("Range not satisfiable");this.total=Q;this.name="RangeNotSatisfiableError",this.payload={api:{status:416,data:{error:W1("range_not_satisfiable","Range not satisfiable",416)},headers:{"Content-Range":d1(Q),"Accept-Ranges":"bytes","Cache-Control":"no-store"}},view:{}}}}class p0 extends C{constructor(Q="Not found"){super(Q);this.name="NotFoundError",this.payload={api:{status:404,data:{error:W1("not_found",Q,404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class v extends C{fileName;constructor(Q){super("File not found");this.fileName=Q;this.name="FileNotFoundError",this.payload={api:{status:404,data:{error:W1("not_found","Not found",404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class u0 extends C{constructor(Q={}){super("Authentication error");this.name="AuthenticationError";let Z=Q.redirectTo??"/auth/sign-in";this.payload={api:{status:401,data:{error:H1("authentication","Authentication error",401)},headers:{[W0]:Z}},viewData:{status:200,data:{},headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate"},directive:{kind:"Redirect",path:Z}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:Z}}}}}class t{static getFacadeAccessor(){throw Error(`Facade [${this.name}] does not implement getFacadeAccessor().`)}static getFacadeRoot(){return G1(this.getFacadeAccessor())}}import{Buffer as d0}from"buffer";function V1(Q){if(typeof Q!=="string"||/^[\s/.]*$/.test(Q))throw Error(`Refusing to delete by prefix ${JSON.stringify(Q)}: it would match the whole store`)}class r{async putStream({body:Q,...Z},J={}){J.signal?.throwIfAborted();let $=[],K=Q.getReader();try{for(;;){J.signal?.throwIfAborted();let{done:X,value:Y}=await K.read();if(X)break;$.push(Y)}}catch(X){throw await K.cancel(X).catch(()=>{}),X}return this.put({...Z,body:d0.concat($)},J)}async*objects(Q,Z={}){throw Error(`${this.constructor.name} does not implement objects(). Override it to list objects in this backend.`)}async deletePrefix(Q,Z={}){V1(Q);let J=[];for await(let $ of this.objects(Q,Z))J.push($.name);for(let $ of J)Z.signal?.throwIfAborted(),await this.delete({name:$,bucket:Z.bucket});return J.length}async delete(Q){throw Error(`${this.constructor.name} does not implement delete(). Override it to remove objects from this backend.`)}async read(Q){let Z=typeof Q==="string"?{name:Q}:Q,J=await this.fetch({name:Z.name,bucket:Z.bucket});if(!J.ok)throw new v(Z.name);let $=J.headers.get("Content-Type")??"application/octet-stream",K=J.headers.get("ETag")??void 0,X=J.headers.get("Last-Modified"),Y=X?new Date(X):void 0;if(Z.range){let H=await J.blob();return{body:H,start:0,end:H.size-1,total:H.size,partial:!1,type:$,etag:K,lastModified:Y,name:Z.name}}let W=Number(J.headers.get("Content-Length")),G=Number.isFinite(W)?W:0;return{body:J.body,start:0,end:G-1,total:G,partial:!1,type:$,etag:K,lastModified:Y,name:Z.name}}async size(Q){let Z=typeof Q==="string"?Q:Q.name,J=typeof Q==="string"?void 0:Q.bucket,$=await this.fetch({name:Z,bucket:J});if(!$.ok)throw new v(Z);let K=Number($.headers.get("Content-Length"));if(Number.isFinite(K))return await $.body?.cancel(),K;return(await $.blob()).size}}function H0(Q,Z){if(!Z)return Q;let J=Q.getReader(),$=!1,K,X=()=>{if($=!0,K)Z.removeEventListener("abort",K)};return new ReadableStream({start(Y){if(K=()=>{if($)return;X(),Y.error(Z.reason),J.cancel(Z.reason).catch(()=>{})},Z.aborted)K();else Z.addEventListener("abort",K,{once:!0})},async pull(Y){let W;try{W=await J.read()}catch(G){if($)return;X(),Y.error(G);return}if($)return;if(W.done){X(),Y.close();return}Y.enqueue(W.value)},cancel(Y){return X(),J.cancel(Y)}},{highWaterMark:0})}import{mkdir as i0,open as l0,readdir as T1,rename as n0,rmdir as o0,stat as s0,unlink as V0}from"fs/promises";import{dirname as a0,isAbsolute as S1,relative as e,resolve as d,sep as y}from"path";class k1 extends r{configured;constructor(Q){super();this.configured=Q}get folderPath(){return this.configured??`${Q1()}/storage`}async put(Q,{signal:Z}={}){Z?.throwIfAborted();let J,$;if(Q instanceof Blob)J=Q,$=`${Bun.randomUUIDv7()}.${Q.type.split("/")[1].split(";")[0]}`;else J=Q.body,$=Q.name;let K=J instanceof Buffer?J:J instanceof Blob||J instanceof File?Buffer.from(await J.arrayBuffer()):"",X=`${this.folderPath}/${$}`;return Z?.throwIfAborted(),await Bun.write(X,K),$}async putStream({name:Q,body:Z},{signal:J}={}){let $=Z.getReader(),K=null;try{if(J?.throwIfAborted(),!Q)throw Error("Object name has to be specified");let X=d(this.folderPath),Y=d(X,Q),W=e(X,Y);if(!W||W===".."||W.startsWith(`..${y}`)||S1(W))throw Error(`Refusing to write "${Q}": it is outside the storage folder`);await i0(a0(Y),{recursive:!0}),K=`${Y}.${Bun.randomUUIDv7()}.partial`;let G=await l0(K,"wx");try{for(;;){J?.throwIfAborted();let{done:H,value:V}=await $.read();if(H)break;for(let O=0;O<V.byteLength;){let{bytesWritten:R}=await G.write(V,O);O+=R}}}finally{await G.close()}return J?.throwIfAborted(),await n0(K,Y),Q}catch(X){if(await $.cancel(X).catch(()=>{}),K)await V0(K).catch(()=>{});throw X}}async fetch(Q,{signal:Z}={}){Z?.throwIfAborted();let J=process.env.BUCKET_NAME,$;if(typeof Q==="string")$=Q;else J=Q.bucket??J,$=Q.name;if(!$)throw Error("Object name has to be specified");let K=`${this.folderPath}/${$}`,X=Bun.file(K),Y=H0(Bun.file(K).stream(),Z),W=new Date(X.lastModified).toUTCString();return new Response(Y,{headers:{"Content-Type":X.type,"Content-Length":String(X.size),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":W}})}async read(Q){let Z=typeof Q==="string"?{name:Q}:Q,{name:J,range:$=null}=Z;if(!J)throw Error("Object name has to be specified");let K=Bun.file(`${this.folderPath}/${J}`);if(!await K.exists())throw new v(J);let X=K.size,Y=$?u1($,X):null;if($&&!Y)throw new w1(X);let W=Y?.start??0,G=Y?Y.end:X-1;return{body:Y?K.slice(W,G+1):K,start:W,end:G,total:X,partial:Boolean(Y),type:K.type||"application/octet-stream",lastModified:new Date(K.lastModified),name:J}}async size(Q){let Z=typeof Q==="string"?Q:Q.name,J=Bun.file(`${this.folderPath}/${Z}`);if(!await J.exists())throw new v(Z);return J.size}async delete(Q){let Z=typeof Q==="string"?Q:Q.name;if(!Z)throw Error("Object name has to be specified");let J=d(this.folderPath),$=d(J,Z),K=e(J,$);if(!K||K===".."||K.startsWith(`..${y}`)||S1(K))throw Error(`Refusing to delete "${Z}": it is outside the storage folder`);try{await V0($)}catch(X){if(X?.code==="ENOENT")return;throw X}}resolvePrefix(Q){let Z=d(this.folderPath),J=Q.lastIndexOf("/"),$=J===-1?"":Q.slice(0,J),K=J===-1?Q:Q.slice(J+1),X=d(Z,$),Y=e(Z,X);if(Y===".."||Y.startsWith(`..${y}`)||S1(Y))throw Error(`Refusing to list "${Q}": it is outside the storage folder`);let W=Y.split(y).join("/");return{root:Z,dir:X,match:W?`${W}/${K}`:K}}async*objects(Q,{signal:Z}={}){Z?.throwIfAborted();let{root:J,dir:$,match:K}=this.resolvePrefix(Q),X=[],Y=async(W)=>{let G;try{G=await T1(W,{withFileTypes:!0})}catch(H){if(H?.code==="ENOENT"||H?.code==="ENOTDIR")return;throw H}for(let H of G){let V=`${W}${y}${H.name}`,O=e(J,V).split(y).join("/");if(H.isDirectory()){if(`${O}/`.startsWith(K)||K.startsWith(`${O}/`))await Y(V)}else if(H.isFile()&&O.startsWith(K))X.push(O)}};await Y($),X.sort();for(let W of X){Z?.throwIfAborted();let G;try{G=await s0(`${J}/${W}`)}catch(H){if(H?.code==="ENOENT")continue;throw H}yield{name:W,size:G.size,lastModified:G.mtime}}}async deletePrefix(Q,Z={}){V1(Q);let{root:J,match:$}=this.resolvePrefix(Q);V1($);let K=await super.deletePrefix(Q,Z);if(K>0)await this.pruneEmptyDirs(J,$);return K}async pruneEmptyDirs(Q,Z){let J=[],$=async(K)=>{let X;try{X=await T1(K,{withFileTypes:!0})}catch{return}for(let Y of X){if(!Y.isDirectory())continue;let W=`${K}${y}${Y.name}`,G=e(Q,W).split(y).join("/");if(`${G}/`.startsWith(Z)||Z.startsWith(`${G}/`)){if(await $(W),`${G}/`.startsWith(Z))J.push(W)}}};await $(Q);for(let K of J)try{await o0(K)}catch{}}async list(){return await T1(this.folderPath)}}var f=30000;function X8(Q){return Q}function O0(){return{driver:new k1,fetchTimeoutMs:f,fetchIdleTimeoutMs:f}}class E1{static token="filesystem";driver;fetchTimeoutMs;fetchIdleTimeoutMs;constructor(Q={}){this.driver=Q.driver??O0().driver,this.fetchTimeoutMs=Q.fetchTimeoutMs??f,this.fetchIdleTimeoutMs=Q.fetchIdleTimeoutMs??f}}class j0 extends Error{driver;limit;timeoutMs;object;code="storage-fetch-timeout";constructor(Q,Z,J,$){super(Z==="fetchTimeoutMs"?`${Q}: no response for "${$}" within ${J}ms (fetchTimeoutMs)`:`${Q}: the body of "${$}" sent nothing for ${J}ms (fetchIdleTimeoutMs)`);this.driver=Q;this.limit=Z;this.timeoutMs=J;this.object=$;this.name="StorageFetchTimeoutError"}}async function z0(Q,Z,J,$){let{fetchTimeoutMs:K,fetchIdleTimeoutMs:X}=$;if(J.signal||!K&&!X)return Q.fetch(Z,J);let Y=new AbortController,W=Q.constructor?.name||"FileStorageDriver",G=typeof Z==="string"?Z:Z.name,H=(R,z)=>{let U=new j0(W,R,z,G);return Y.abort(U),U},V=Promise.resolve(Q.fetch(Z,{...J,signal:Y.signal})),O;if(K){let R,z=new Promise((U,D)=>{R=setTimeout(()=>D(H("fetchTimeoutMs",K)),K)});try{O=await Promise.race([V,z])}catch(U){if(Y.signal.aborted)throw V.then((D)=>D.body?.cancel(Y.signal.reason).catch(()=>{}),()=>{}),Y.signal.reason;throw U}finally{clearTimeout(R)}}else O=await V;if(!X||!O.body)return O;return new Response(t0(O.body,X,()=>H("fetchIdleTimeoutMs",X)),{status:O.status,statusText:O.statusText,headers:O.headers})}function t0(Q,Z,J){let $=Q.getReader();return new ReadableStream({async pull(K){let X,Y,W=new Promise((G,H)=>{X=setTimeout(()=>{Y=J(),H(Y)},Z)});try{let G=await Promise.race([$.read(),W]);if(G.done)K.close();else K.enqueue(G.value)}catch(G){let H=Y??G;K.error(H),$.cancel(H).catch(()=>{})}finally{clearTimeout(X)}},cancel(K){return $.cancel(K)}},{highWaterMark:0})}class A extends Error{code="safe-fetch";url;constructor(Q,Z,J){super(Q,J);this.name=new.target.name,this.url=Z}}class g extends A{reason;code="invalid-url";constructor(Q,Z,J){super(J,Q);this.reason=Z}}class O1 extends A{host;reason;code="blocked-host";constructor(Q,Z,J){super(J==="denied"?`Requests to ${Z} are not allowed.`:`${Z} is not on the list of hosts this request may reach.`,Q);this.host=Z;this.reason=J}}class i extends A{host;address;range;code="blocked-address";constructor(Q,Z,J,$){super(Z===J?`${J} is not a public address (${$}).`:`${Z} resolves to ${J}, which is not a public address (${$}).`,Q);this.host=Z;this.address=J;this.range=$}}class j1 extends A{host;code="dns";constructor(Q,Z,J){super(`Couldn't resolve ${Z}.`,Q,{cause:J});this.host=Z}}class z1 extends A{phase;ms;code="timeout";constructor(Q,Z,J){super(Z==="connect"?`Couldn't connect within ${J} ms.`:`The request didn't finish within ${J} ms.`,Q);this.phase=Z;this.ms=J}}class P1 extends A{limit;code="too-large";constructor(Q,Z){super(`The response is larger than ${Z} bytes.`,Q);this.limit=Z}}class Z1 extends A{contentType;allowed;code="content-type";constructor(Q,Z,J){super(`The response is ${Z??"of no content type"}, not ${J.join(" or ")}.`,Q);this.contentType=Z;this.allowed=J}}class x1 extends A{limit;code="too-many-redirects";constructor(Q,Z){super(`More than ${Z} redirects.`,Q);this.limit=Z}}class l extends A{code="network";constructor(Q,Z){super(`The request failed: ${Z instanceof Error?Z.message:String(Z)}`,Q,{cause:Z})}}class q1 extends A{status;code="http-status";constructor(Q,Z){super(`The server answered ${Z}.`,Q);this.status=Z}}function r0(Q){if(Q==="")return null;let Z=Q.split(".");if(Z.length>1&&Z[Z.length-1]==="")Z.pop();if(Z.length===0||Z.length>4)return null;let J=[];for(let X of Z){let Y=e0(X);if(Y===null)return null;J.push(Y)}let $=J.pop();for(let X of J)if(X>255)return null;if($>=256**(4-J.length))return null;let K=$;return J.forEach((X,Y)=>{K+=X*256**(3-Y)}),new Uint8Array([Math.floor(K/16777216)&255,Math.floor(K/65536)&255,Math.floor(K/256)&255,K&255])}function e0(Q){if(Q==="")return null;let Z=Q,J=10;if(/^0x/i.test(Z)){if(Z=Z.slice(2),J=16,Z==="")return 0}else if(Z.length>1&&Z.startsWith("0"))Z=Z.slice(1),J=8;if(!(J===16?/^[0-9a-f]+$/i:J===8?/^[0-7]+$/:/^[0-9]+$/).test(Z))return null;let K=parseInt(Z,J);return Number.isSafeInteger(K)?K:null}function P0(Q){let Z=Q;if(Z.startsWith("[")&&Z.endsWith("]"))Z=Z.slice(1,-1);let J=Z.indexOf("%");if(J!==-1)Z=Z.slice(0,J);if(!Z.includes(":"))return null;let $=Z.split("::");if($.length>2)return null;let K=(H,V)=>{if(H==="")return[];let O=[],R=H.split(":");for(let z=0;z<R.length;z++){let U=R[z];if(V&&z===R.length-1&&U.includes(".")){if(!/^\d{1,3}(\.\d{1,3}){3}$/.test(U))return null;let D=U.split(".").map(Number);if(D.some((F)=>F>255))return null;O.push(D[0]<<8|D[1],D[2]<<8|D[3]);continue}if(!/^[0-9a-f]{1,4}$/i.test(U))return null;O.push(parseInt(U,16))}return O},X=K($[0],$.length===1),Y=$.length===2?K($[1],!0):[];if(!X||!Y)return null;let W;if($.length===2){let H=8-X.length-Y.length;if(H<1)return null;W=[...X,...Array.from({length:H},()=>0),...Y]}else W=X;if(W.length!==8)return null;let G=new Uint8Array(16);return W.forEach((H,V)=>{G[V*2]=H>>8,G[V*2+1]=H&255}),G}function J1(Q){let Z=P0(Q);if(Z)return{family:6,bytes:Z};let J=r0(Q);if(J)return{family:4,bytes:J};return null}function h(Q){if(Q.family===6&&QQ(Q.bytes))return{family:4,bytes:Q.bytes.slice(12)};return Q}function QQ(Q){for(let Z=0;Z<10;Z++)if(Q[Z]!==0)return!1;return Q[10]===255&&Q[11]===255}function $1(Q){if(Q.family===4)return Array.from(Q.bytes).join(".");let Z=[];for(let J=0;J<16;J+=2)Z.push((Q.bytes[J]<<8|Q.bytes[J+1]).toString(16));return Z.join(":")}function n(Q){let Z=Q.lastIndexOf("/"),J=Z===-1?Q:Q.slice(0,Z),$=/^[0-9.]+$/.test(J)?ZQ(J):P0(J);if(!$)return null;let K=h($.length===4?{family:4,bytes:$}:{family:6,bytes:$}),X=K.family===4?32:128,Y=X;if(Z!==-1){let W=Q.slice(Z+1);if(!/^\d{1,3}$/.test(W))return null;if(Y=Number(W),$.length===16&&K.family===4)Y-=96;if(Y<0||Y>X)return null}return{family:K.family,bytes:K.bytes,prefix:Y}}function ZQ(Q){return/^\d{1,3}(\.\d{1,3}){3}$/.test(Q)&&Q.split(".").every((Z)=>Number(Z)<=255)?new Uint8Array(Q.split(".").map(Number)):null}function q(Q,Z){let J=h(Q);if(J.family!==Z.family)return!1;let $=Z.prefix;for(let K=0;$>0;K++){let X=Math.min(8,$),Y=255<<8-X&255;if((J.bytes[K]&Y)!==(Z.bytes[K]&Y))return!1;$-=X}return!0}var P=(Q,Z)=>({cidr:n(Q),kind:Z,text:Q}),JQ=[P("0.0.0.0/8","unspecified"),P("10.0.0.0/8","private"),P("100.64.0.0/10","shared"),P("127.0.0.0/8","loopback"),P("169.254.169.254/32","metadata"),P("169.254.0.0/16","link-local"),P("168.63.129.16/32","metadata"),P("172.16.0.0/12","private"),P("192.0.0.0/24","reserved"),P("192.0.2.0/24","documentation"),P("192.88.99.0/24","reserved"),P("192.168.0.0/16","private"),P("198.18.0.0/15","benchmarking"),P("198.51.100.0/24","documentation"),P("203.0.113.0/24","documentation"),P("224.0.0.0/4","multicast"),P("255.255.255.255/32","broadcast"),P("240.0.0.0/4","reserved")],$Q=[P("::/128","unspecified"),P("::1/128","loopback"),P("64:ff9b:1::/48","private"),P("::/8","reserved"),P("100::/64","reserved"),P("2001:db8::/32","documentation"),P("2001::/23","reserved"),P("3fff::/20","documentation"),P("fd00:ec2::254/128","metadata"),P("fc00::/7","unique-local"),P("fe80::/10","link-local"),P("fec0::/10","private"),P("ff00::/8","multicast")],KQ=n("64:ff9b::/96"),XQ=n("2002::/16"),YQ=n("2000::/3");function U1(Q){let Z=typeof Q==="string"?J1(Q):Q;if(!Z)return{kind:"reserved",range:"not an IP address"};let J=h(Z);if(J.family===4){let K=JQ.find((X)=>q(J,X.cidr));return K?{kind:K.kind,range:K.text}:null}if(q(J,KQ))return U1({family:4,bytes:J.bytes.slice(12)});if(q(J,XQ))return U1({family:4,bytes:J.bytes.slice(2,6)});let $=$Q.find((K)=>q(J,K.cidr));if($)return{kind:$.kind,range:$.text};return q(J,YQ)?null:{kind:"reserved",range:"outside 2000::/3"}}function U0(Q,Z){let J=h(Q),$=h(Z);return J.family===$.family&&J.bytes.every((K,X)=>K===$.bytes[X])}import{lookup as GQ}from"dns/promises";import*as WQ from"http";import*as HQ from"https";import*as o from"zlib";class b1 extends Response{#Q;#Z;address;constructor(Q,Z,J){super(Q,Z);this.#Q=J.url,this.#Z=J.redirected,this.address=J.address}get url(){return this.#Q}get redirected(){return this.#Z}}var K1={timeout:30000,connectTimeout:1e4,maxSize:10485760,maxRedirects:5,ports:[80,443]},VQ=new Set([301,302,303,307,308]),OQ=new Set([101,103,204,205,304]),jQ=["host","connection","content-length","transfer-encoding","keep-alive","upgrade"],zQ=["authorization","cookie","proxy-authorization"];async function R0(Q,Z={}){let J=PQ(Z),$=Z.signal;$?.throwIfAborted();let K=new AbortController,X=K.signal,Y=String(Q),W=(O)=>{if(!X.aborted)K.abort(O)},G=setTimeout(()=>W(new z1(Y,"total",J.timeout)),J.timeout),H=()=>W($.reason);$?.addEventListener("abort",H,{once:!0});let V=()=>{clearTimeout(G),$?.removeEventListener("abort",H)};try{let O=M0(Y,J),R=(Z.method??"GET").toUpperCase(),z=new Headers(Z.headers);for(let D of jQ)z.delete(D);if(!z.has("accept"))z.set("accept","*/*");if(!z.has("user-agent"))z.set("user-agent","gemi");if(!z.has("accept-encoding"))z.set("accept-encoding","gzip, deflate, br");let U=await RQ(R,Z.body,z);for(let D=0;;D++){Y=O.href;let{request:F,response:N,address:S}=await BQ(O,R,z,U,J,X),_=N.statusCode??0,I=N.headers.location;if(VQ.has(_)&&I&&Z.redirect!=="manual"){if(F.destroy(),D>=J.maxRedirects)throw new x1(O.href,J.maxRedirects);let k;try{k=new URL(I,O)}catch{throw new g(I,"malformed",`The redirect to "${I}" is not a URL.`)}if(_===303?R!=="HEAD":(_===301||_===302)&&R==="POST"){R="GET",U=null;let B=[];z.forEach((M,j)=>{if(j.startsWith("content-"))B.push(j)});for(let M of B)z.delete(M)}if(k.origin!==O.origin)for(let B of zQ)z.delete(B);O=M0(k.href,J);continue}return NQ({url:O,hop:D,method:R,request:F,response:N,address:S,policy:J,signal:X,release:V})}}catch(O){throw V(),X.aborted?X.reason:O}}function PQ(Q){let Z=($,K)=>{let X={hosts:[],ranges:[]};for(let Y of $){let W=Y.includes("/")||Y.includes(":")||/^[\d.]+$/.test(Y),G=W?n(Y):null;if(G)X.ranges.push(G);else if(!W&&/^(\*\.)?[a-z0-9-]+(\.[a-z0-9-]+)*\.?$/i.test(Y))X.hosts.push(B0(Y));else throw TypeError(`safeFetch: "${Y}" in ${K} is not a host name or an IP range.`)}return X},J=Q.allowPrivate;return{timeout:Q.timeout??K1.timeout,connectTimeout:Q.connectTimeout??K1.connectTimeout,maxSize:Q.maxSize??K1.maxSize,maxRedirects:Q.maxRedirects??K1.maxRedirects,ports:Q.ports??K1.ports,allow:Q.allow&&Q.allow.length>0?Z(Q.allow,"allow"):null,deny:Z(Q.deny??[],"deny"),allowPrivate:J===!0?!0:Z(J||[],"allowPrivate").ranges,contentTypes:Q.contentTypes?.length?Q.contentTypes:null,resolve:Q.resolve??UQ}}async function UQ(Q){return(await GQ(Q,{all:!0,verbatim:!0})).map((J)=>J.address)}function B0(Q){return Q.toLowerCase().replace(/\.$/,"")}function D0(Q,Z){return Z.some((J)=>J.startsWith("*.")?Q.endsWith(J.slice(1)):Q===J)}function M0(Q,Z){let J;try{J=new URL(Q)}catch{throw new g(Q,"malformed",`"${Q}" is not a URL.`)}if(J.protocol!=="http:"&&J.protocol!=="https:")throw new g(J.href,"scheme",`Only http and https URLs can be fetched, not ${J.protocol.slice(0,-1)}.`);if(J.username||J.password)throw new g(J.href,"credentials","The URL has a username or password in it.");let $=N0(J);if(Z.ports!=="any"&&!Z.ports.includes($))throw new g(J.href,"port",`Port ${$} is not allowed.`);return J}function N0(Q){return Q.port?Number(Q.port):Q.protocol==="https:"?443:80}async function DQ(Q,Z,J){let $=B0(Q.hostname.replace(/^\[(.*)\]$/,"$1")),K=J1($),X=K!==null&&($.includes(":")||/^\d+\.\d+\.\d+\.\d+$/.test($));if(!X&&D0($,Z.deny.hosts))throw new O1(Q.href,$,"denied");let Y=!X&&Z.allow!==null&&D0($,Z.allow.hosts);if(Z.allow&&!Y&&Z.allow.ranges.length===0)throw new O1(Q.href,$,"not-allowed");let W;if(X)W=[K];else{let G;try{G=await MQ(Z.resolve($),J)}catch(H){if(J.aborted)throw J.reason;throw new j1(Q.href,$,H)}if(W=G.map((H)=>J1(H)).filter((H)=>H!==null),W.length===0)throw new j1(Q.href,$)}for(let G of W){let H=$1(G);if(Z.deny.ranges.some((O)=>q(G,O)))throw new i(Q.href,$,H,"denied");if(Z.allow&&!Y&&!Z.allow.ranges.some((O)=>q(G,O)))throw new i(Q.href,$,H,"not-allowed");let V=U1(G);if(V&&Z.allowPrivate!==!0&&!Z.allowPrivate.some((O)=>q(G,O)))throw new i(Q.href,$,H,V.kind)}return{host:$,addresses:W,isLiteral:X}}function MQ(Q,Z){if(Z.aborted)return Promise.reject(Z.reason);return new Promise((J,$)=>{let K=()=>$(Z.reason);Z.addEventListener("abort",K,{once:!0}),Q.then((X)=>{Z.removeEventListener("abort",K),J(X)},(X)=>{Z.removeEventListener("abort",K),$(X)})})}async function RQ(Q,Z,J){if(Z===void 0||Z===null)return null;if(Q==="GET"||Q==="HEAD")throw TypeError(`safeFetch: a ${Q} request can't have a body.`);let $=new Request("http://body.invalid/",{method:"POST",body:Z}),K=$.headers.get("content-type");if(K&&!J.has("content-type"))J.set("content-type",K);return new Uint8Array(await $.arrayBuffer())}async function BQ(Q,Z,J,$,K,X){let Y=new AbortController,W=setTimeout(()=>Y.abort(new z1(Q.href,"connect",K.connectTimeout)),K.connectTimeout),G=AbortSignal.any([X,Y.signal]);try{let{host:H,addresses:V,isLiteral:O}=await DQ(Q,K,G),R=Q.protocol==="https:",z={};if(J.forEach((U,D)=>{z[D]=U}),$)z["content-length"]=String($.byteLength);return await new Promise((U,D)=>{let F={method:Z,host:H,port:N0(Q),path:`${Q.pathname}${Q.search}`,headers:z,agent:!1,lookup:(B,M,j)=>{let w=M?.family,L=V.filter((X1)=>!w||X1.family===w);if(L.length===0)j(Object.assign(Error(`No IPv${w} address for ${H}`),{code:"ENOTFOUND"}));else if(M?.all)j(null,L.map((X1)=>({address:$1(X1),family:X1.family})));else j(null,$1(L[0]),L[0].family)}};if(R&&!O)F.servername=H;let N=(R?HQ:WQ).request(F),S=null,_=(B)=>{G.removeEventListener("abort",I),N.destroy(),D(B)},I=()=>_(G.aborted?G.reason:X.reason);G.addEventListener("abort",I,{once:!0});let k=(B)=>{let M=B?.remoteAddress;if(!M||S!==null)return!0;let j=J1(M);if(!j||!V.some((w)=>U0(w,j)))return _(new i(Q.href,H,M,"not-allowed")),!1;return S=$1(h(j)),!0};N.once("socket",(B)=>{let M=()=>{if(k(B)&&!R)clearTimeout(W)};if(B.connecting)B.once("connect",M);else M();if(R)B.once("secureConnect",()=>clearTimeout(W))}),N.once("response",(B)=>{if(clearTimeout(W),B.on("error",()=>{}),!k(B.socket))return;G.removeEventListener("abort",I),U({request:N,response:B,address:S})}),N.on("error",(B)=>{if(G.aborted)return _(G.reason);_(B instanceof A?B:new l(Q.href,B))}),N.end($??void 0)})}finally{clearTimeout(W)}}function NQ({url:Q,hop:Z,method:J,request:$,response:K,address:X,policy:Y,signal:W,release:G}){let H=K.statusCode??0;if(H<200||H>599)throw $.destroy(),new l(Q.href,Error(`Unexpected status ${H}`));let V=new Headers,O=K.rawHeaders;for(let M=0;M<O.length;M+=2)V.append(O[M],O[M+1]);if(Y.contentTypes){let M=V.get("content-type")?.split(";")[0].trim().toLowerCase()??null;if(!M||!Y.contentTypes.some((j)=>CQ(M,j)))throw $.destroy(),new Z1(Q.href,M,Y.contentTypes)}let R={url:Q.href,redirected:Z>0,address:X},z={status:H,statusText:K.statusMessage??"",headers:V};if(J==="HEAD"||OQ.has(H))return $.destroy(),G(),new b1(null,z,R);let U=V.get("content-encoding")?.trim().toLowerCase(),D=U==="gzip"||U==="x-gzip"?o.createGunzip():U==="deflate"?o.createInflate():U==="br"?o.createBrotliDecompress():null,F=Number(V.get("content-length"));if(!D&&Number.isFinite(F)&&F>Y.maxSize)throw $.destroy(),new P1(Q.href,Y.maxSize);if(D)V.delete("content-encoding"),V.delete("content-length");let N=D?K.pipe(D):K,S=0,_=!1,I=()=>{},k=()=>{_=!0,W.removeEventListener("abort",I),G()},B=new ReadableStream({start(M){let j=(L)=>{if(_)return;if(k(),L===void 0)M.close();else $.destroy(),D?.destroy(),M.error(L)};if(I=()=>j(W.reason),W.addEventListener("abort",I,{once:!0}),W.aborted)return I();N.on("data",(L)=>{if(_)return;if(S+=L.byteLength,S>Y.maxSize)return j(new P1(Q.href,Y.maxSize));if(M.enqueue(new Uint8Array(L)),(M.desiredSize??1)<=0)N.pause()}),N.once("end",()=>j());let w=(L)=>j(L instanceof A?L:new l(Q.href,L));if(N.on("error",w),D)K.on("error",w);K.once("aborted",()=>j(new l(Q.href,Error("The response was cut off."))))},pull(){N.resume()},cancel(){if(_)return;k(),$.destroy(),D?.destroy()}});return new b1(B,z,R)}function CQ(Q,Z){let J=Z.toLowerCase();return J.endsWith("/*")?Q.startsWith(J.slice(0,-1)):Q===J}function L0(Q){return IQ(Q)??FQ(Q)??wQ(Q)}var y1=4096,LQ={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/avif":"avif","image/heic":"heic","image/heif":"heif","image/bmp":"bmp","image/tiff":"tiff","image/x-icon":"ico","image/svg+xml":"svg","audio/mpeg":"mp3","audio/aac":"aac","audio/mp4":"m4a","audio/ogg":"ogg","audio/flac":"flac","audio/wav":"wav","video/mp4":"mp4","video/quicktime":"mov","video/webm":"webm","video/x-matroska":"mkv","video/x-msvideo":"avi","font/woff":"woff","font/woff2":"woff2","font/ttf":"ttf","font/otf":"otf","application/pdf":"pdf","application/zip":"zip","application/gzip":"gz","application/xml":"xml","text/html":"html","text/plain":"txt","application/octet-stream":"bin"};function _0(Q){return LQ[Q]??"bin"}function T(Q,Z,J=0){if(Q.length<J+Z.length)return!1;return Z.every(($,K)=>Q[J+K]===$)}function b(Q,Z,J){return String.fromCharCode(...Q.subarray(Z,J))}var _Q={avif:"image/avif",avis:"image/avif",heic:"image/heic",heix:"image/heic",hevc:"image/heic",hevx:"image/heic",heim:"image/heic",heis:"image/heic",mif1:"image/heif",msf1:"image/heif","qt ":"video/quicktime","M4A ":"audio/mp4","M4B ":"audio/mp4"};function IQ(Q){if(T(Q,[137,80,78,71,13,10,26,10]))return"image/png";if(T(Q,[255,216,255]))return"image/jpeg";if(Q.length>=6&&(b(Q,0,6)==="GIF87a"||b(Q,0,6)==="GIF89a"))return"image/gif";if(Q.length>=12&&b(Q,0,4)==="RIFF"){let Z=b(Q,8,12);if(Z==="WEBP")return"image/webp";if(Z==="WAVE")return"audio/wav";if(Z==="AVI ")return"video/x-msvideo"}if(Q.length>=12&&b(Q,4,8)==="ftyp"){let Z=b(Q,8,12);return _Q[Z]??"video/mp4"}if(T(Q,[73,73,42,0])||T(Q,[77,77,0,42]))return"image/tiff";if(T(Q,[66,77])&&T(Q,[0,0,0,0],6))return"image/bmp";if(T(Q,[0,0,1,0])&&Q.length>=6&&Q[4]>0)return"image/x-icon";if(T(Q,[37,80,68,70,45]))return"application/pdf";if(T(Q,[80,75,3,4]))return"application/zip";if(T(Q,[31,139]))return"application/gzip";if(T(Q,[26,69,223,163]))return b(Q,0,Math.min(Q.length,64)).includes("webm")?"video/webm":"video/x-matroska";if(Q.length>=4){let Z=b(Q,0,4);if(Z==="OggS")return"audio/ogg";if(Z==="fLaC")return"audio/flac";if(Z==="wOFF")return"font/woff";if(Z==="wOF2")return"font/woff2";if(Z==="OTTO")return"font/otf"}if(T(Q,[0,1,0,0,0]))return"font/ttf";if(Q.length>=3&&b(Q,0,3)==="ID3")return"audio/mpeg";if(Q.length>=2&&Q[0]===255){if((Q[1]&246)===240)return"audio/aac";if((Q[1]&224)===224&&(Q[1]&6)!==0)return"audio/mpeg"}return null}var AQ=["!doctype html","html","head","script","iframe","h1","div","font","table","a","style","title","b","body","br","p","!--"];function FQ(Q){let Z=new TextDecoder("utf-8",{fatal:!1}).decode(Q);if(Z.charCodeAt(0)===65279)Z=Z.slice(1);if(Z=Z.trimStart(),!Z.startsWith("<"))return null;let J=Z.toLowerCase(),$=J;for(;;){$=$.trimStart();let K=/^(<\?[\s\S]*?\?>|<!--[\s\S]*?-->|<!doctype[^>]*>)/.exec($);if(!K)break;$=$.slice(K[0].length)}if(/^<svg[\s>/]/.test($))return"image/svg+xml";for(let K of AQ){if(!J.startsWith(`<${K}`))continue;if(/^[\s>]/.test(J.charAt(K.length+1)))return"text/html"}if(/^<(html|head|body)[\s>]/.test($))return"text/html";if(J.startsWith("<?xml"))return"application/xml";return null}function wQ(Q){if(Q.length===0)return"application/octet-stream";for(let Z of Q)if(Z<32&&Z!==9&&Z!==10&&Z!==12&&Z!==13&&Z!==27)return"application/octet-stream";try{return new TextDecoder("utf-8",{fatal:!0}).decode(Q,{stream:!0}),"text/plain"}catch{return"application/octet-stream"}}var TQ=new Set(["text/html","application/xhtml+xml","image/svg+xml","text/xml","application/xml","text/xsl","application/xslt+xml"]);function C0(Q){let Z=Q.split(";")[0].trim().toLowerCase();return TQ.has(Z)||Z.endsWith("+xml")}function I0(Q,Z){let J=Q.split(";")[0].trim().toLowerCase();return Z.some(($)=>{let K=$.split(";")[0].trim().toLowerCase();if(K==="*/*"||K==="*")return!C0(J);if(K.endsWith("/*"))return J.startsWith(K.slice(0,-1))&&!C0(J);return J===K})}import{Buffer as EQ}from"buffer";async function A0(Q){try{return(await import("sharp")).default}catch(Z){throw Error(`${Q} requires the 'sharp' package. Install it with \`bun add sharp\`.`,{cause:Z})}}async function F0(Q,Z,J={}){let{name:$,directory:K,bucket:X,maxSize:Y,timeout:W,contentTypes:G,signal:H}=J;if($!==void 0&&K!==void 0)throw TypeError("Storage.putFromUrl(): pass `name` or `directory`, not both.");if($!==void 0&&!$)throw TypeError("Storage.putFromUrl(): `name` is empty.");let V=await R0(Z,{...J.fetch,method:"GET",redirect:"follow",contentTypes:void 0,signal:H,timeout:W,maxSize:Y});if(!V.ok)throw await V.body?.cancel().catch(()=>{}),new q1(V.url,V.status);let O=(V.body??new Response(new Uint8Array).body).getReader(),R=async(j)=>{throw await O.cancel(j).catch(()=>{}),j},z=[],U=0,D=!1;while(U<y1){let{done:j,value:w}=await O.read();if(j){D=!0;break}z.push(w),U+=w.byteLength}let F=kQ(z,U),N=L0(F.subarray(0,Math.min(U,y1))),S=G?.length?G:["*/*"];if(!I0(N,S))await R(new Z1(V.url,N,S));let _=$??[(K??"").replace(/\/+$/,""),`${Bun.randomUUIDv7()}.${_0(N)}`].filter(Boolean).join("/"),I=U,k=new ReadableStream({start(j){if(U>0)j.enqueue(F);if(D)j.close()},async pull(j){let{done:w,value:L}=await O.read();if(w){j.close();return}I+=L.byteLength,j.enqueue(L)},cancel(j){return O.cancel(j)}}),B={name:_,bucket:X,body:k,contentType:N},M;try{M=Q.putStream?await Q.putStream(B,{signal:H}):await r.prototype.putStream.call(Q,B,{signal:H})}catch(j){throw await R(j),j}return{name:M,contentType:N,size:I,url:V.url}}function kQ(Q,Z){if(Q.length===1)return Q[0];let J=new Uint8Array(Z),$=0;for(let K of Q)J.set(K,$),$+=K.byteLength;return J}class xQ extends t{static getFacadeAccessor(){return E1}static async put(Q,Z={}){return this.getFacadeRoot().driver.put(Q,Z)}static async putFromUrl(Q,Z={}){return F0(this.getFacadeRoot().driver,Q,Z)}static async metadata(Q){let Z=EQ.from(await Q.arrayBuffer()),J=await A0("Storage.metadata()");try{return await J(Z).metadata()}catch{return{}}}static async fetch(Q,Z={}){Z.signal?.throwIfAborted();let J=this.getFacadeRoot();return z0(J.driver,Q,Z,{fetchTimeoutMs:J.fetchTimeoutMs??f,fetchIdleTimeoutMs:J.fetchIdleTimeoutMs??f})}static async read(Q,Z={}){let J=typeof Q==="string"?{name:Q}:{...Q},$="range"in Z?Z.range??null:J.range!==void 0?J.range:E.getStore()?.rangeRequest??null;return this.getFacadeRoot().driver.read({...J,range:$})}static list(Q){return this.getFacadeRoot().driver.list(Q)}static objects(Q,Z={}){return this.getFacadeRoot().driver.objects(Q,Z)}static async deletePrefix(Q,Z={}){return this.getFacadeRoot().driver.deletePrefix(Q,Z)}static async delete(Q){return this.getFacadeRoot().driver.delete(Q)}}var w0=["cookie","set-cookie","authorization","proxy-authorization","x-api-key"];function x8(Q){return Q}function q8(){let Q=Bun.env.NODE_ENV==="development";return{maxFileSize:10485760,console:Q,consoleFormat:Q?"text":"json",requestFields:[],redactHeaders:[],onLogFileClosed:()=>{},onLogCreated:()=>{}}}import{mkdir as v1,readdir as fQ,access as vQ}from"fs/promises";var f1=["debug","info","notice","warning","error","critical","alert","emergency"],qQ=f1.indexOf("warning");function S0(Q){if(!Q)return-1;if(Q===!0)return 0;let Z=f1.indexOf(Q);return Z===-1?0:Z}function bQ(){let Q=new WeakSet;return function(Z,J){if(typeof J==="bigint")return J.toString();if(J instanceof Error){let $={name:J.name,message:J.message,stack:J.stack};for(let K of Object.keys(J))$[K]=J[K];if(J.cause!==void 0)$.cause=J.cause;return $}if(J!==null&&typeof J==="object"){if(Q.has(J))return"[Circular]";Q.add(J)}return J}}function T0(Q){try{return JSON.stringify(Q,bQ())}catch{return'"[Unserializable]"'}}function yQ(Q,Z){if(Z==="json")return T0({...Q.metadata,timestamp:Q.timestamp,level:Q.level,message:Q.message});let J=Object.keys(Q.metadata).length>0;return`${Q.timestamp} ${Q.level.toUpperCase()} ${Q.message}${J?` ${T0(Q.metadata)}`:""}`}function k0(Q,Z){let J=f1.indexOf(Q.level);if(Z.threshold===-1||J<Z.threshold)return;try{let $=yQ(Q,Z.format)+`
2
+ import{Ij as C,Jj as W1,Kj as H1}from"./chunk-aed0vv5g.js";import{Pj as I1,Sj as E}from"./chunk-jy26hy7z.js";import{Tj as A1}from"./chunk-8ar7180x.js";import{$l as G0}from"./chunk-65btke6p.js";import{dm as G1}from"./chunk-vyaedzr8.js";import{Am as Q1}from"./chunk-77dt2tap.js";import{Im as SQ}from"./chunk-zf1eqgzt.js";class c1{static kind="controller";constructor(){}}class x0 extends c1{}function D1(Q){let Z=new Map;if(!Q)return Z;for(let J of Q.split(";")){let $=J.indexOf("=");if($===-1)continue;let K=J.slice(0,$).trim();if(!K)continue;Z.set(K,J.slice($+1).trim())}return Z}function oQ(Q){return D1(Q.headers.get("cookie"))}function m(Q){if(!/^\d+$/.test(Q))return null;let Z=Number(Q);return Number.isSafeInteger(Z)?Z:null}function p1(Q){if(!Q)return null;let Z=Q.trim();if(!/^bytes=/i.test(Z))return null;let $=Z.slice(6).split(",").map((V)=>V.trim()).filter((V)=>V!=="");if($.length!==1)return null;let K=$[0],X=K.indexOf("-");if(X===-1)return null;let Y=K.slice(0,X),W=K.slice(X+1);if(Y===""){let V=m(W);if(V===null)return null;return{kind:"suffix",suffixLength:V}}let G=m(Y);if(G===null)return null;if(W==="")return{kind:"offset",start:G,end:null};let H=m(W);if(H===null||H<G)return null;return{kind:"offset",start:G,end:H}}function u1(Q,Z){if(!Number.isFinite(Z)||Z<=0)return null;let J,$;if(Q.kind==="suffix"){if(Q.suffixLength<=0)return null;J=Math.max(0,Z-Q.suffixLength),$=Z-1}else{if(Q.start>=Z)return null;if(J=Q.start,$=Q.end===null?Z-1:Math.min(Q.end,Z-1),$<J)return null}return{start:J,end:$,length:$-J+1}}function aQ(Q){if(Q.kind==="suffix")return`bytes=-${Q.suffixLength}`;return Q.end===null?`bytes=${Q.start}-`:`bytes=${Q.start}-${Q.end}`}function tQ(Q){if(!Q)return null;let Z=/^bytes\s+(\d+)-(\d+)\/(\d+)$/i.exec(Q.trim());if(!Z)return null;let J=m(Z[1]),$=m(Z[2]),K=m(Z[3]);if(J===null||$===null||K===null||$<J)return null;return{start:J,end:$,total:K}}function rQ(Q,Z,J){return`bytes ${Q}-${Z}/${J}`}function d1(Q){return`bytes */${Q}`}import{randomBytes as q0}from"crypto";var M1=new WeakMap;function R1(Q){let Z=M1.get(Q);if(!Z)Z=q0(16).toString("base64"),M1.set(Q,Z);return Z}function JZ(Q){return M1.get(Q)}function $Z(){let Q=E.getStore()?.req?.rawRequest;if(!Q)throw Error("cspNonce() is only available while a request is being handled.");return R1(Q)}class s extends C{errors={};constructor(Q){super("Validation error");this.name="ValidationError",this.errors=Q,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:Q,status:400}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}function l1(Q){let[Z,J]=Q.match(/\d+|\D+/g)??[];if(!Z||!J)return 0;let $=Number.parseInt(Z);switch(J){case"B":return $;case"KB":return $*1024;case"MB":return $*1024*1024;case"GB":return $*1024*1024*1024;case"TB":return $*1024*1024*1024*1024;default:return 0}}function b0(Q){switch(Q){case"image":return"image";case"png":return"image/png";case"jpg":return"image/jpeg";case"jpeg":return"image/jpeg";case"ttf":return"font/ttf";case"excel":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"csv":return"text/csv";case"word":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"pdf":return"application/pdf";case"json":return"application/json";default:return Q}}function i1(Q){if(typeof Q==="string"||Array.isArray(Q))return Q.length;return}function B1(Q){return typeof Q==="number"&&!Number.isNaN(Q)}var y0=["required","string","boolean","number","email","password","min","max","gte","lte","file","fileType","fileSize","array","object","in"];class x extends Error{name="InvalidValidationRuleError"}function Y1(Q,Z){let J=Z===void 0||Z.trim()===""?Number.NaN:Number(Z);if(Number.isNaN(J))throw new x(`Validation rule "${Q}:${Z??""}" needs a number, e.g. "${Q}:3"`);return J}function n1(Q){let Z=!1,J=0;for(let $ of Object.values(Q)){if(!$||typeof $!=="object")continue;for(let K of Object.keys($)){let X=K.indexOf(":"),Y=X===-1?K:K.slice(0,X);if(Y!=="file"&&Y!=="fileType"&&Y!=="fileSize")continue;if(Z=!0,Y==="fileSize")J+=l1(K.slice(X+1))}}return Z?J:null}function o1(Q){let Z=Q.indexOf(":"),J=Z===-1?Q:Q.slice(0,Z),$=Z===-1?void 0:Q.slice(Z+1);switch(J){case"required":return(K)=>{if(K instanceof Blob)return K.size>0;if(K===null||K===void 0)return!1;if(typeof K==="string"||Array.isArray(K))return K.length>0;return!0};case"string":return(K)=>typeof K==="string";case"boolean":return(K)=>typeof K==="boolean";case"number":return(K)=>B1(K);case"password":return(K)=>{return typeof K==="string"&&/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(K)};case"min":{let K=Y1(J,$);return(X)=>{let Y=i1(X);return Y!==void 0&&Y>=K}}case"max":{let K=Y1(J,$);return(X)=>{let Y=i1(X);return Y!==void 0&&Y<=K}}case"gte":{let K=Y1(J,$);return(X)=>B1(X)&&X>=K}case"lte":{let K=Y1(J,$);return(X)=>B1(X)&&X<=K}case"email":return(K)=>{return typeof K==="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(K)};case"file":return(K)=>{return K instanceof Blob};case"fileType":{if(!$)throw new x('Validation rule "fileType" needs a type, e.g. "fileType:png" or "fileType:image"');let K=b0($);return(X)=>X instanceof Blob&&X.type.startsWith(K)}case"fileSize":{let K=l1($??"");if(K===0&&!/^0+(B|KB|MB|GB|TB)$/.test($??""))throw new x(`Validation rule "fileSize:${$??""}" needs a whole size in B, KB, MB, GB or TB, e.g. "fileSize:5MB"`);return(X)=>X instanceof Blob&&X.size<=K}case"array":return(K)=>Array.isArray(K);case"object":return(K)=>typeof K==="object"&&K!==null&&!Array.isArray(K)&&!(K instanceof Blob);case"in":{let K=($??"").split(",").filter((X)=>X!=="");if(K.length===0)throw new x('Validation rule "in" needs a comma-separated list, e.g. "in:draft,published"');return(X)=>typeof X==="string"&&K.includes(X)}default:throw new x(`Unknown validation rule "${Q}". Known rules: ${y0.join(", ")}`)}}class C1 extends C{limit;constructor(Q){super("The request body is too large.",{status:413});this.limit=Q}}var s1={b:1,k:1024,kb:1024,m:1048576,mb:1048576,g:1073741824,gb:1073741824};function HZ(Q){if(typeof Q==="number"){if(Number.isFinite(Q)&&Q>=0)return Math.floor(Q);if(Q===1/0)return 1/0}else{let Z=Q.trim().toLowerCase();if(Z==="none"||Z==="off")return 1/0;let J=/^(\d+(?:\.\d+)?)\s*([a-z]*)$/.exec(Z);if(J&&(J[2]===""||(J[2]in s1)))return Math.floor(Number(J[1])*(s1[J[2]]??1))}throw Error(`Invalid body limit ${JSON.stringify(Q)}. Use a byte count or a size such as "64kb", "1mb" or "none".`)}var p=new WeakMap;function VZ(Q){return p.has(Q)}function OZ(Q){return p.get(Q)?.limit??null}function jZ(Q){let Z=p.get(Q);return Z?Z.read>Z.limit:!1}function f0(Q){let Z=Q.headers.get("Content-Length");if(Z===null||!/^\s*\d+\s*$/.test(Z))return null;return Number(Z)}function L1(Q,Z){let J=f0(Q);if(J!==null&&J>Z)throw new C1(Z)}function zZ(Q,Z,J={}){let $=J.uploadLimit??null,K=p.get(Q);if(K)K.limit=Z,K.uploadLimit=$;else{let X={limit:Z,uploadLimit:$,read:0,stream:void 0,used:!1};p.set(Q,X),g0(Q,X)}if(J.checkDeclared!==!1)L1(Q,Z)}function t1(Q,Z){let J=p.get(Q);if(!J||J.uploadLimit===null||J.used||J.read>0)return;J.limit=Math.max(J.limit,J.uploadLimit,Z+J.limit),J.uploadLimit=null}function v0(Q){return Reflect.get(Object.getPrototypeOf(Q),"body",Q)??null}function N1(Q,Z){if(Z.stream!==void 0)return Z.stream;let J=v0(Q);if(!J)return Z.stream=null;let $;return Z.stream=new ReadableStream({async pull(K){$??=J.getReader();let{done:X,value:Y}=await $.read();if(X){K.close();return}if(Z.read+=Y.byteLength,Z.read>Z.limit){let W=new C1(Z.limit);K.error(W),$.cancel(W).catch(()=>{});return}K.enqueue(Y)},cancel(K){return $?$.cancel(K):J.cancel(K)}},{highWaterMark:0}),Z.stream}async function c(Q,Z){if(L1(Q,Z.limit),Z.used||Z.stream?.locked)throw TypeError("Body already used");Z.used=!0;let J=N1(Q,Z);if(!J)return new Uint8Array(0);let $=J.getReader(),K=[],X=0;for(;;){let{done:G,value:H}=await $.read();if(G)break;K.push(H),X+=H.byteLength}let Y=new Uint8Array(X),W=0;for(let G of K)Y.set(G,W),W+=G.byteLength;return Y}function a1(Q){return Q.headers.get("Content-Type")??""}function g0(Q,Z){let J=($,K)=>Object.defineProperty(Q,$,{configurable:!0,...K});J("body",{get:()=>N1(Q,Z)}),J("bodyUsed",{get:()=>Z.used||Boolean(Z.stream?.locked)||Reflect.get(Object.getPrototypeOf(Q),"bodyUsed",Q)}),J("bytes",{value:()=>c(Q,Z)}),J("arrayBuffer",{value:async()=>{let $=await c(Q,Z);return $.buffer.slice($.byteOffset,$.byteOffset+$.byteLength)}}),J("text",{value:async()=>new TextDecoder().decode(await c(Q,Z))}),J("json",{value:async()=>JSON.parse(new TextDecoder().decode(await c(Q,Z)))}),J("blob",{value:async()=>new Blob([await c(Q,Z)],{type:a1(Q)})}),J("formData",{value:async()=>new Response(await c(Q,Z),{headers:{"Content-Type":a1(Q)}}).formData()}),J("clone",{value:()=>{L1(Q,Z.limit);let $=N1(Q,Z),K=null;if($){let[X,Y]=$.tee();Z.stream=X,K=Y}return new Request(Q.url,{method:Q.method,headers:Q.headers,body:K,signal:Q.signal,duplex:"half"})}})}function r1(Q){if(typeof Q!=="string")return null;let[Z]=Q.split(";",1),J=Z.trim().toLowerCase();return J===""?null:J}function e1(Q){if(Q===null)return!1;if(Q==="application/json")return!0;let Z=Q.indexOf("/");return Z>0&&Q.endsWith("+json")&&Q.length>Z+1+5}var a=new WeakMap;function DZ(Q,Z,J,$){a.set(Q,{clientAddress:Z,...J?{grant:Object.freeze({...J,scopes:Object.freeze([...J.scopes])})}:{},...$?{progress:$}:{}})}function Q0(Q){return a.get(Q)?.progress}function Z0(Q){return a.get(Q)?.grant}function J0(Q){return a.has(Q)}function MZ(Q){return a.get(Q)?.clientAddress}var $0=new WeakMap;function BZ(Q,Z){$0.set(Q,Z)}function K0(Q){return $0.get(Q)??null}var _1=new WeakMap;function NZ(Q,Z){let J=_1.get(Q)??[];if(!J.includes(Z))_1.set(Q,[...J,Z])}function CZ(Q){return _1.get(Q)??[]}class u{data;constructor(Q){this.data=Q}get(Q){return this.data[Q]}has(Q){return this.data[Q]!==void 0}toJSON(){return this.data}}function X0(Q){return typeof Q==="object"&&Q!==null&&!(Q instanceof Blob)}function h0(Q,Z){if(!Z.includes(".")||Object.hasOwn(Q,Z))return[{path:[Z],value:Q[Z]}];let J=[{path:[],value:Q}];for(let $ of Z.split(".")){let K=[];for(let{path:X,value:Y}of J){if($==="*"){if(Array.isArray(Y))Y.forEach((W,G)=>K.push({path:[...X,G],value:W}));else if(X0(Y))for(let[W,G]of Object.entries(Y))K.push({path:[...X,W],value:G});continue}if(Array.isArray(Y)&&/^\d+$/.test($)){K.push({path:[...X,Number($)],value:Y[Number($)]});continue}K.push({path:[...X,$],value:X0(Y)&&Object.hasOwn(Y,$)?Y[$]:void 0})}J=K}return J}function Y0(Q){return Q.join(".")}class m0{kind;rawRequest;headers;cookies;search;schema={};routePath;params;domain;state;constructor(Q,Z,J,$){if(!Q){let G=E.getStore().req;this.params=G.params,this.rawRequest=G.rawRequest,this.kind=G.kind,this.routePath=G.routePath,this.domain=G.domain??null,this.state=G.state??new I1}else this.params=Z,this.rawRequest=Q,this.routePath=$,this.kind=J??"api",this.domain=K0(Q),this.state=new I1;this.headers=this.rawRequest.headers;let K=D1(this.rawRequest.headers.get("Cookie")),X=new URL(this.rawRequest.url),Y=new Map;for(let[G,H]of X.searchParams)if(Y.has(G)){let V=Y.get(G);if(Array.isArray(V))V.push(H),Y.set(G,V);else Y.set(G,[V,H])}else Y.set(G,H);let W=Object.fromEntries(Y.entries());this.search=new u(W),this.cookies=K}locale(){let Q=E.getStore();if(Q.locale)return Q.locale;let Z=G1(G0);return Z.isLocaleAware?Z.detectLocale(Q.req):Q.locale}ctx(){return E.getStore()}isModelOriginated(){return J0(this.rawRequest)}mcpGrant(){return Z0(this.rawRequest)??null}cspNonce(){return R1(this.rawRequest)}reportProgress(Q){let Z=Q0(this.rawRequest);if(!Z)return!1;return Z(Q),!0}get signal(){return this.rawRequest.signal}range(){return p1(this.rawRequest.headers.get("Range"))}refine(Q){return{}}async parseBody(){let Q=r1(this.rawRequest.headers.get("Content-Type"));if(e1(Q))return new u(await this.parseJsonBody());if(Q==="application/x-www-form-urlencoded"||Q==="multipart/form-data"){if(Q==="multipart/form-data"&&!A1(this.schema)){let $=n1(this.schema??{});if($!==null)t1(this.rawRequest,$)}let Z;try{Z=await this.rawRequest.formData()}catch($){if($ instanceof C)throw $;throw new C("The request body could not be read as a form.")}let J=new Map;for(let[$,K]of Z.entries())if(J.has($)){let X=J.get($);if(Array.isArray(X))X.push(K);else J.set($,[X,K])}else J.set($,K);return new u(Object.fromEntries(J.entries()))}return new u({})}async parseJsonBody(){if(!this.rawRequest.body)return{};let Q;try{Q=await this.rawRequest.text()}catch(J){if(J instanceof C)throw J;throw new C("The request body could not be read.")}if(Q.trim()==="")return{};let Z;try{Z=JSON.parse(Q)}catch{throw new C("The request body is not valid JSON.")}if(Z===null||typeof Z!=="object")throw new C("The request body must be a JSON object.");return Z}validateInput(Q){if(A1(this.schema))return this.validateWithSchema(Q);let Z=Q.toJSON()??{},J={},$=Object.entries(this.schema).map(([K,X])=>({key:K,rules:Object.entries(X).map(([Y,W])=>({rule:Y,message:W,check:typeof W==="function"?null:this.ruleFor(K,Y)}))}));for(let{key:K,rules:X}of $)for(let{path:Y,value:W}of h0(Z,K)){let G=this.checkField(W,X);if(G.length>0){let H=J[Y0(Y)]??=[];for(let V of G)if(!H.includes(V))H.push(V)}}if(this.addRefinements(J,Z),Object.keys(J).length>0)throw new s(J);return Q}checkField(Q,Z){let J=Z.some(({rule:X})=>X==="required"),$=Q===void 0||Q===null||Q==="",K=[];for(let{rule:X,message:Y,check:W}of Z){let G=Y,H=!1;if(typeof Y==="function")G=Y(Q),H=typeof G>"u";else H=W(Q);if(H)continue;if($&&!J)continue;if(X==="required")return[String(G)];if(!K.includes(String(G)))K.push(String(G))}return K}validateWithSchema(Q){let Z=this.schema.validate(Q.toJSON()),J={};if("issues"in Z)for(let K of Z.issues){let X=Y0(K.path),Y=J[X]??=[];if(!Y.includes(K.message))Y.push(K.message)}let $="value"in Z?new u(Z.value):Q;if(this.addRefinements(J,$.toJSON()),Object.keys(J).length>0)throw new s(J);return $}addRefinements(Q,Z){for(let[J,$]of Object.entries(this.refine(Z)??{})){let K=Q[J]??[];Q[J]=K.includes($)?K:[...K,$]}}ruleFor(Q,Z){try{return o1(Z)}catch(J){if(J instanceof x)throw new x(`${this.constructor.name}.schema.${Q}: ${J.message}`);throw J}}async input(){return this.validateInput(await this.parseBody())}async safeInput(){let Q=await this.parseBody();try{return{isValid:!0,errors:{},input:this.validateInput(Q)}}catch(Z){if(!(Z instanceof s))throw Z;return{isValid:!1,errors:Z.errors,input:Q}}}}var W0="x-gemi-sign-in";class c0 extends C{error;constructor(Q="Not authorized"){super(Q);this.name="AuthorizationError",this.error=Q,this.payload={api:{status:401,data:{error:H1("authorization",this.error,401)}},view:{}}}}class F1 extends C{static apiStatus=403;error;constructor(Q="Insufficient permissions"){super(Q);this.name="InsufficientPermissionsError",this.error=Q,this.payload={api:{status:F1.apiStatus,data:{error:H1("permission",this.error,F1.apiStatus)}},view:{status:403}}}}class w1 extends C{total;constructor(Q){super("Range not satisfiable");this.total=Q;this.name="RangeNotSatisfiableError",this.payload={api:{status:416,data:{error:W1("range_not_satisfiable","Range not satisfiable",416)},headers:{"Content-Range":d1(Q),"Accept-Ranges":"bytes","Cache-Control":"no-store"}},view:{}}}}class p0 extends C{constructor(Q="Not found"){super(Q);this.name="NotFoundError",this.payload={api:{status:404,data:{error:W1("not_found",Q,404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class v extends C{fileName;constructor(Q){super("File not found");this.fileName=Q;this.name="FileNotFoundError",this.payload={api:{status:404,data:{error:W1("not_found","Not found",404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class u0 extends C{constructor(Q={}){super("Authentication error");this.name="AuthenticationError";let Z=Q.redirectTo??"/auth/sign-in";this.payload={api:{status:401,data:{error:H1("authentication","Authentication error",401)},headers:{[W0]:Z}},viewData:{status:200,data:{},headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate"},directive:{kind:"Redirect",path:Z}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:Z}}}}}class t{static getFacadeAccessor(){throw Error(`Facade [${this.name}] does not implement getFacadeAccessor().`)}static getFacadeRoot(){return G1(this.getFacadeAccessor())}}import{Buffer as d0}from"buffer";function V1(Q){if(typeof Q!=="string"||/^[\s/.]*$/.test(Q))throw Error(`Refusing to delete by prefix ${JSON.stringify(Q)}: it would match the whole store`)}class r{async putStream({body:Q,...Z},J={}){J.signal?.throwIfAborted();let $=[],K=Q.getReader();try{for(;;){J.signal?.throwIfAborted();let{done:X,value:Y}=await K.read();if(X)break;$.push(Y)}}catch(X){throw await K.cancel(X).catch(()=>{}),X}return this.put({...Z,body:d0.concat($)},J)}async*objects(Q,Z={}){throw Error(`${this.constructor.name} does not implement objects(). Override it to list objects in this backend.`)}async deletePrefix(Q,Z={}){V1(Q);let J=[];for await(let $ of this.objects(Q,Z))J.push($.name);for(let $ of J)Z.signal?.throwIfAborted(),await this.delete({name:$,bucket:Z.bucket});return J.length}async delete(Q){throw Error(`${this.constructor.name} does not implement delete(). Override it to remove objects from this backend.`)}async read(Q){let Z=typeof Q==="string"?{name:Q}:Q,J=await this.fetch({name:Z.name,bucket:Z.bucket});if(!J.ok)throw new v(Z.name);let $=J.headers.get("Content-Type")??"application/octet-stream",K=J.headers.get("ETag")??void 0,X=J.headers.get("Last-Modified"),Y=X?new Date(X):void 0;if(Z.range){let H=await J.blob();return{body:H,start:0,end:H.size-1,total:H.size,partial:!1,type:$,etag:K,lastModified:Y,name:Z.name}}let W=Number(J.headers.get("Content-Length")),G=Number.isFinite(W)?W:0;return{body:J.body,start:0,end:G-1,total:G,partial:!1,type:$,etag:K,lastModified:Y,name:Z.name}}async size(Q){let Z=typeof Q==="string"?Q:Q.name,J=typeof Q==="string"?void 0:Q.bucket,$=await this.fetch({name:Z,bucket:J});if(!$.ok)throw new v(Z);let K=Number($.headers.get("Content-Length"));if(Number.isFinite(K))return await $.body?.cancel(),K;return(await $.blob()).size}}function H0(Q,Z){if(!Z)return Q;let J=Q.getReader(),$=!1,K,X=()=>{if($=!0,K)Z.removeEventListener("abort",K)};return new ReadableStream({start(Y){if(K=()=>{if($)return;X(),Y.error(Z.reason),J.cancel(Z.reason).catch(()=>{})},Z.aborted)K();else Z.addEventListener("abort",K,{once:!0})},async pull(Y){let W;try{W=await J.read()}catch(G){if($)return;X(),Y.error(G);return}if($)return;if(W.done){X(),Y.close();return}Y.enqueue(W.value)},cancel(Y){return X(),J.cancel(Y)}},{highWaterMark:0})}import{mkdir as i0,open as l0,readdir as T1,rename as n0,rmdir as o0,stat as s0,unlink as V0}from"fs/promises";import{dirname as a0,isAbsolute as S1,relative as e,resolve as d,sep as y}from"path";class k1 extends r{configured;constructor(Q){super();this.configured=Q}get folderPath(){return this.configured??`${Q1()}/storage`}async put(Q,{signal:Z}={}){Z?.throwIfAborted();let J,$;if(Q instanceof Blob)J=Q,$=`${Bun.randomUUIDv7()}.${Q.type.split("/")[1].split(";")[0]}`;else J=Q.body,$=Q.name;let K=J instanceof Buffer?J:J instanceof Blob||J instanceof File?Buffer.from(await J.arrayBuffer()):"",X=`${this.folderPath}/${$}`;return Z?.throwIfAborted(),await Bun.write(X,K),$}async putStream({name:Q,body:Z},{signal:J}={}){let $=Z.getReader(),K=null;try{if(J?.throwIfAborted(),!Q)throw Error("Object name has to be specified");let X=d(this.folderPath),Y=d(X,Q),W=e(X,Y);if(!W||W===".."||W.startsWith(`..${y}`)||S1(W))throw Error(`Refusing to write "${Q}": it is outside the storage folder`);await i0(a0(Y),{recursive:!0}),K=`${Y}.${Bun.randomUUIDv7()}.partial`;let G=await l0(K,"wx");try{for(;;){J?.throwIfAborted();let{done:H,value:V}=await $.read();if(H)break;for(let O=0;O<V.byteLength;){let{bytesWritten:R}=await G.write(V,O);O+=R}}}finally{await G.close()}return J?.throwIfAborted(),await n0(K,Y),Q}catch(X){if(await $.cancel(X).catch(()=>{}),K)await V0(K).catch(()=>{});throw X}}async fetch(Q,{signal:Z}={}){Z?.throwIfAborted();let J=process.env.BUCKET_NAME,$;if(typeof Q==="string")$=Q;else J=Q.bucket??J,$=Q.name;if(!$)throw Error("Object name has to be specified");let K=`${this.folderPath}/${$}`,X=Bun.file(K),Y=H0(Bun.file(K).stream(),Z),W=new Date(X.lastModified).toUTCString();return new Response(Y,{headers:{"Content-Type":X.type,"Content-Length":String(X.size),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":W}})}async read(Q){let Z=typeof Q==="string"?{name:Q}:Q,{name:J,range:$=null}=Z;if(!J)throw Error("Object name has to be specified");let K=Bun.file(`${this.folderPath}/${J}`);if(!await K.exists())throw new v(J);let X=K.size,Y=$?u1($,X):null;if($&&!Y)throw new w1(X);let W=Y?.start??0,G=Y?Y.end:X-1;return{body:Y?K.slice(W,G+1):K,start:W,end:G,total:X,partial:Boolean(Y),type:K.type||"application/octet-stream",lastModified:new Date(K.lastModified),name:J}}async size(Q){let Z=typeof Q==="string"?Q:Q.name,J=Bun.file(`${this.folderPath}/${Z}`);if(!await J.exists())throw new v(Z);return J.size}async delete(Q){let Z=typeof Q==="string"?Q:Q.name;if(!Z)throw Error("Object name has to be specified");let J=d(this.folderPath),$=d(J,Z),K=e(J,$);if(!K||K===".."||K.startsWith(`..${y}`)||S1(K))throw Error(`Refusing to delete "${Z}": it is outside the storage folder`);try{await V0($)}catch(X){if(X?.code==="ENOENT")return;throw X}}resolvePrefix(Q){let Z=d(this.folderPath),J=Q.lastIndexOf("/"),$=J===-1?"":Q.slice(0,J),K=J===-1?Q:Q.slice(J+1),X=d(Z,$),Y=e(Z,X);if(Y===".."||Y.startsWith(`..${y}`)||S1(Y))throw Error(`Refusing to list "${Q}": it is outside the storage folder`);let W=Y.split(y).join("/");return{root:Z,dir:X,match:W?`${W}/${K}`:K}}async*objects(Q,{signal:Z}={}){Z?.throwIfAborted();let{root:J,dir:$,match:K}=this.resolvePrefix(Q),X=[],Y=async(W)=>{let G;try{G=await T1(W,{withFileTypes:!0})}catch(H){if(H?.code==="ENOENT"||H?.code==="ENOTDIR")return;throw H}for(let H of G){let V=`${W}${y}${H.name}`,O=e(J,V).split(y).join("/");if(H.isDirectory()){if(`${O}/`.startsWith(K)||K.startsWith(`${O}/`))await Y(V)}else if(H.isFile()&&O.startsWith(K))X.push(O)}};await Y($),X.sort();for(let W of X){Z?.throwIfAborted();let G;try{G=await s0(`${J}/${W}`)}catch(H){if(H?.code==="ENOENT")continue;throw H}yield{name:W,size:G.size,lastModified:G.mtime}}}async deletePrefix(Q,Z={}){V1(Q);let{root:J,match:$}=this.resolvePrefix(Q);V1($);let K=await super.deletePrefix(Q,Z);if(K>0)await this.pruneEmptyDirs(J,$);return K}async pruneEmptyDirs(Q,Z){let J=[],$=async(K)=>{let X;try{X=await T1(K,{withFileTypes:!0})}catch{return}for(let Y of X){if(!Y.isDirectory())continue;let W=`${K}${y}${Y.name}`,G=e(Q,W).split(y).join("/");if(`${G}/`.startsWith(Z)||Z.startsWith(`${G}/`)){if(await $(W),`${G}/`.startsWith(Z))J.push(W)}}};await $(Q);for(let K of J)try{await o0(K)}catch{}}async list(){return await T1(this.folderPath)}}var f=30000;function X8(Q){return Q}function O0(){return{driver:new k1,fetchTimeoutMs:f,fetchIdleTimeoutMs:f}}class E1{static token="filesystem";driver;fetchTimeoutMs;fetchIdleTimeoutMs;constructor(Q={}){this.driver=Q.driver??O0().driver,this.fetchTimeoutMs=Q.fetchTimeoutMs??f,this.fetchIdleTimeoutMs=Q.fetchIdleTimeoutMs??f}}class j0 extends Error{driver;limit;timeoutMs;object;code="storage-fetch-timeout";constructor(Q,Z,J,$){super(Z==="fetchTimeoutMs"?`${Q}: no response for "${$}" within ${J}ms (fetchTimeoutMs)`:`${Q}: the body of "${$}" sent nothing for ${J}ms (fetchIdleTimeoutMs)`);this.driver=Q;this.limit=Z;this.timeoutMs=J;this.object=$;this.name="StorageFetchTimeoutError"}}async function z0(Q,Z,J,$){let{fetchTimeoutMs:K,fetchIdleTimeoutMs:X}=$;if(J.signal||!K&&!X)return Q.fetch(Z,J);let Y=new AbortController,W=Q.constructor?.name||"FileStorageDriver",G=typeof Z==="string"?Z:Z.name,H=(R,z)=>{let U=new j0(W,R,z,G);return Y.abort(U),U},V=Promise.resolve(Q.fetch(Z,{...J,signal:Y.signal})),O;if(K){let R,z=new Promise((U,D)=>{R=setTimeout(()=>D(H("fetchTimeoutMs",K)),K)});try{O=await Promise.race([V,z])}catch(U){if(Y.signal.aborted)throw V.then((D)=>D.body?.cancel(Y.signal.reason).catch(()=>{}),()=>{}),Y.signal.reason;throw U}finally{clearTimeout(R)}}else O=await V;if(!X||!O.body)return O;return new Response(t0(O.body,X,()=>H("fetchIdleTimeoutMs",X)),{status:O.status,statusText:O.statusText,headers:O.headers})}function t0(Q,Z,J){let $=Q.getReader();return new ReadableStream({async pull(K){let X,Y,W=new Promise((G,H)=>{X=setTimeout(()=>{Y=J(),H(Y)},Z)});try{let G=await Promise.race([$.read(),W]);if(G.done)K.close();else K.enqueue(G.value)}catch(G){let H=Y??G;K.error(H),$.cancel(H).catch(()=>{})}finally{clearTimeout(X)}},cancel(K){return $.cancel(K)}},{highWaterMark:0})}class A extends Error{code="safe-fetch";url;constructor(Q,Z,J){super(Q,J);this.name=new.target.name,this.url=Z}}class g extends A{reason;code="invalid-url";constructor(Q,Z,J){super(J,Q);this.reason=Z}}class O1 extends A{host;reason;code="blocked-host";constructor(Q,Z,J){super(J==="denied"?`Requests to ${Z} are not allowed.`:`${Z} is not on the list of hosts this request may reach.`,Q);this.host=Z;this.reason=J}}class i extends A{host;address;range;code="blocked-address";constructor(Q,Z,J,$){super(Z===J?`${J} is not a public address (${$}).`:`${Z} resolves to ${J}, which is not a public address (${$}).`,Q);this.host=Z;this.address=J;this.range=$}}class j1 extends A{host;code="dns";constructor(Q,Z,J){super(`Couldn't resolve ${Z}.`,Q,{cause:J});this.host=Z}}class z1 extends A{phase;ms;code="timeout";constructor(Q,Z,J){super(Z==="connect"?`Couldn't connect within ${J} ms.`:`The request didn't finish within ${J} ms.`,Q);this.phase=Z;this.ms=J}}class P1 extends A{limit;code="too-large";constructor(Q,Z){super(`The response is larger than ${Z} bytes.`,Q);this.limit=Z}}class Z1 extends A{contentType;allowed;code="content-type";constructor(Q,Z,J){super(`The response is ${Z??"of no content type"}, not ${J.join(" or ")}.`,Q);this.contentType=Z;this.allowed=J}}class x1 extends A{limit;code="too-many-redirects";constructor(Q,Z){super(`More than ${Z} redirects.`,Q);this.limit=Z}}class l extends A{code="network";constructor(Q,Z){super(`The request failed: ${Z instanceof Error?Z.message:String(Z)}`,Q,{cause:Z})}}class q1 extends A{status;code="http-status";constructor(Q,Z){super(`The server answered ${Z}.`,Q);this.status=Z}}function r0(Q){if(Q==="")return null;let Z=Q.split(".");if(Z.length>1&&Z[Z.length-1]==="")Z.pop();if(Z.length===0||Z.length>4)return null;let J=[];for(let X of Z){let Y=e0(X);if(Y===null)return null;J.push(Y)}let $=J.pop();for(let X of J)if(X>255)return null;if($>=256**(4-J.length))return null;let K=$;return J.forEach((X,Y)=>{K+=X*256**(3-Y)}),new Uint8Array([Math.floor(K/16777216)&255,Math.floor(K/65536)&255,Math.floor(K/256)&255,K&255])}function e0(Q){if(Q==="")return null;let Z=Q,J=10;if(/^0x/i.test(Z)){if(Z=Z.slice(2),J=16,Z==="")return 0}else if(Z.length>1&&Z.startsWith("0"))Z=Z.slice(1),J=8;if(!(J===16?/^[0-9a-f]+$/i:J===8?/^[0-7]+$/:/^[0-9]+$/).test(Z))return null;let K=parseInt(Z,J);return Number.isSafeInteger(K)?K:null}function P0(Q){let Z=Q;if(Z.startsWith("[")&&Z.endsWith("]"))Z=Z.slice(1,-1);let J=Z.indexOf("%");if(J!==-1)Z=Z.slice(0,J);if(!Z.includes(":"))return null;let $=Z.split("::");if($.length>2)return null;let K=(H,V)=>{if(H==="")return[];let O=[],R=H.split(":");for(let z=0;z<R.length;z++){let U=R[z];if(V&&z===R.length-1&&U.includes(".")){if(!/^\d{1,3}(\.\d{1,3}){3}$/.test(U))return null;let D=U.split(".").map(Number);if(D.some((F)=>F>255))return null;O.push(D[0]<<8|D[1],D[2]<<8|D[3]);continue}if(!/^[0-9a-f]{1,4}$/i.test(U))return null;O.push(parseInt(U,16))}return O},X=K($[0],$.length===1),Y=$.length===2?K($[1],!0):[];if(!X||!Y)return null;let W;if($.length===2){let H=8-X.length-Y.length;if(H<1)return null;W=[...X,...Array.from({length:H},()=>0),...Y]}else W=X;if(W.length!==8)return null;let G=new Uint8Array(16);return W.forEach((H,V)=>{G[V*2]=H>>8,G[V*2+1]=H&255}),G}function J1(Q){let Z=P0(Q);if(Z)return{family:6,bytes:Z};let J=r0(Q);if(J)return{family:4,bytes:J};return null}function h(Q){if(Q.family===6&&QQ(Q.bytes))return{family:4,bytes:Q.bytes.slice(12)};return Q}function QQ(Q){for(let Z=0;Z<10;Z++)if(Q[Z]!==0)return!1;return Q[10]===255&&Q[11]===255}function $1(Q){if(Q.family===4)return Array.from(Q.bytes).join(".");let Z=[];for(let J=0;J<16;J+=2)Z.push((Q.bytes[J]<<8|Q.bytes[J+1]).toString(16));return Z.join(":")}function n(Q){let Z=Q.lastIndexOf("/"),J=Z===-1?Q:Q.slice(0,Z),$=/^[0-9.]+$/.test(J)?ZQ(J):P0(J);if(!$)return null;let K=h($.length===4?{family:4,bytes:$}:{family:6,bytes:$}),X=K.family===4?32:128,Y=X;if(Z!==-1){let W=Q.slice(Z+1);if(!/^\d{1,3}$/.test(W))return null;if(Y=Number(W),$.length===16&&K.family===4)Y-=96;if(Y<0||Y>X)return null}return{family:K.family,bytes:K.bytes,prefix:Y}}function ZQ(Q){return/^\d{1,3}(\.\d{1,3}){3}$/.test(Q)&&Q.split(".").every((Z)=>Number(Z)<=255)?new Uint8Array(Q.split(".").map(Number)):null}function q(Q,Z){let J=h(Q);if(J.family!==Z.family)return!1;let $=Z.prefix;for(let K=0;$>0;K++){let X=Math.min(8,$),Y=255<<8-X&255;if((J.bytes[K]&Y)!==(Z.bytes[K]&Y))return!1;$-=X}return!0}var P=(Q,Z)=>({cidr:n(Q),kind:Z,text:Q}),JQ=[P("0.0.0.0/8","unspecified"),P("10.0.0.0/8","private"),P("100.64.0.0/10","shared"),P("127.0.0.0/8","loopback"),P("169.254.169.254/32","metadata"),P("169.254.0.0/16","link-local"),P("168.63.129.16/32","metadata"),P("172.16.0.0/12","private"),P("192.0.0.0/24","reserved"),P("192.0.2.0/24","documentation"),P("192.88.99.0/24","reserved"),P("192.168.0.0/16","private"),P("198.18.0.0/15","benchmarking"),P("198.51.100.0/24","documentation"),P("203.0.113.0/24","documentation"),P("224.0.0.0/4","multicast"),P("255.255.255.255/32","broadcast"),P("240.0.0.0/4","reserved")],$Q=[P("::/128","unspecified"),P("::1/128","loopback"),P("64:ff9b:1::/48","private"),P("::/8","reserved"),P("100::/64","reserved"),P("2001:db8::/32","documentation"),P("2001::/23","reserved"),P("3fff::/20","documentation"),P("fd00:ec2::254/128","metadata"),P("fc00::/7","unique-local"),P("fe80::/10","link-local"),P("fec0::/10","private"),P("ff00::/8","multicast")],KQ=n("64:ff9b::/96"),XQ=n("2002::/16"),YQ=n("2000::/3");function U1(Q){let Z=typeof Q==="string"?J1(Q):Q;if(!Z)return{kind:"reserved",range:"not an IP address"};let J=h(Z);if(J.family===4){let K=JQ.find((X)=>q(J,X.cidr));return K?{kind:K.kind,range:K.text}:null}if(q(J,KQ))return U1({family:4,bytes:J.bytes.slice(12)});if(q(J,XQ))return U1({family:4,bytes:J.bytes.slice(2,6)});let $=$Q.find((K)=>q(J,K.cidr));if($)return{kind:$.kind,range:$.text};return q(J,YQ)?null:{kind:"reserved",range:"outside 2000::/3"}}function U0(Q,Z){let J=h(Q),$=h(Z);return J.family===$.family&&J.bytes.every((K,X)=>K===$.bytes[X])}import{lookup as GQ}from"dns/promises";import*as WQ from"http";import*as HQ from"https";import*as o from"zlib";class b1 extends Response{#Q;#Z;address;constructor(Q,Z,J){super(Q,Z);this.#Q=J.url,this.#Z=J.redirected,this.address=J.address}get url(){return this.#Q}get redirected(){return this.#Z}}var K1={timeout:30000,connectTimeout:1e4,maxSize:10485760,maxRedirects:5,ports:[80,443]},VQ=new Set([301,302,303,307,308]),OQ=new Set([101,103,204,205,304]),jQ=["host","connection","content-length","transfer-encoding","keep-alive","upgrade"],zQ=["authorization","cookie","proxy-authorization"];async function R0(Q,Z={}){let J=PQ(Z),$=Z.signal;$?.throwIfAborted();let K=new AbortController,X=K.signal,Y=String(Q),W=(O)=>{if(!X.aborted)K.abort(O)},G=setTimeout(()=>W(new z1(Y,"total",J.timeout)),J.timeout),H=()=>W($.reason);$?.addEventListener("abort",H,{once:!0});let V=()=>{clearTimeout(G),$?.removeEventListener("abort",H)};try{let O=M0(Y,J),R=(Z.method??"GET").toUpperCase(),z=new Headers(Z.headers);for(let D of jQ)z.delete(D);if(!z.has("accept"))z.set("accept","*/*");if(!z.has("user-agent"))z.set("user-agent","gemi");if(!z.has("accept-encoding"))z.set("accept-encoding","gzip, deflate, br");let U=await RQ(R,Z.body,z);for(let D=0;;D++){Y=O.href;let{request:F,response:N,address:S}=await BQ(O,R,z,U,J,X),_=N.statusCode??0,I=N.headers.location;if(VQ.has(_)&&I&&Z.redirect!=="manual"){if(F.destroy(),D>=J.maxRedirects)throw new x1(O.href,J.maxRedirects);let k;try{k=new URL(I,O)}catch{throw new g(I,"malformed",`The redirect to "${I}" is not a URL.`)}if(_===303?R!=="HEAD":(_===301||_===302)&&R==="POST"){R="GET",U=null;let B=[];z.forEach((M,j)=>{if(j.startsWith("content-"))B.push(j)});for(let M of B)z.delete(M)}if(k.origin!==O.origin)for(let B of zQ)z.delete(B);O=M0(k.href,J);continue}return NQ({url:O,hop:D,method:R,request:F,response:N,address:S,policy:J,signal:X,release:V})}}catch(O){throw V(),X.aborted?X.reason:O}}function PQ(Q){let Z=($,K)=>{let X={hosts:[],ranges:[]};for(let Y of $){let W=Y.includes("/")||Y.includes(":")||/^[\d.]+$/.test(Y),G=W?n(Y):null;if(G)X.ranges.push(G);else if(!W&&/^(\*\.)?[a-z0-9-]+(\.[a-z0-9-]+)*\.?$/i.test(Y))X.hosts.push(B0(Y));else throw TypeError(`safeFetch: "${Y}" in ${K} is not a host name or an IP range.`)}return X},J=Q.allowPrivate;return{timeout:Q.timeout??K1.timeout,connectTimeout:Q.connectTimeout??K1.connectTimeout,maxSize:Q.maxSize??K1.maxSize,maxRedirects:Q.maxRedirects??K1.maxRedirects,ports:Q.ports??K1.ports,allow:Q.allow&&Q.allow.length>0?Z(Q.allow,"allow"):null,deny:Z(Q.deny??[],"deny"),allowPrivate:J===!0?!0:Z(J||[],"allowPrivate").ranges,contentTypes:Q.contentTypes?.length?Q.contentTypes:null,resolve:Q.resolve??UQ}}async function UQ(Q){return(await GQ(Q,{all:!0,verbatim:!0})).map((J)=>J.address)}function B0(Q){return Q.toLowerCase().replace(/\.$/,"")}function D0(Q,Z){return Z.some((J)=>J.startsWith("*.")?Q.endsWith(J.slice(1)):Q===J)}function M0(Q,Z){let J;try{J=new URL(Q)}catch{throw new g(Q,"malformed",`"${Q}" is not a URL.`)}if(J.protocol!=="http:"&&J.protocol!=="https:")throw new g(J.href,"scheme",`Only http and https URLs can be fetched, not ${J.protocol.slice(0,-1)}.`);if(J.username||J.password)throw new g(J.href,"credentials","The URL has a username or password in it.");let $=N0(J);if(Z.ports!=="any"&&!Z.ports.includes($))throw new g(J.href,"port",`Port ${$} is not allowed.`);return J}function N0(Q){return Q.port?Number(Q.port):Q.protocol==="https:"?443:80}async function DQ(Q,Z,J){let $=B0(Q.hostname.replace(/^\[(.*)\]$/,"$1")),K=J1($),X=K!==null&&($.includes(":")||/^\d+\.\d+\.\d+\.\d+$/.test($));if(!X&&D0($,Z.deny.hosts))throw new O1(Q.href,$,"denied");let Y=!X&&Z.allow!==null&&D0($,Z.allow.hosts);if(Z.allow&&!Y&&Z.allow.ranges.length===0)throw new O1(Q.href,$,"not-allowed");let W;if(X)W=[K];else{let G;try{G=await MQ(Z.resolve($),J)}catch(H){if(J.aborted)throw J.reason;throw new j1(Q.href,$,H)}if(W=G.map((H)=>J1(H)).filter((H)=>H!==null),W.length===0)throw new j1(Q.href,$)}for(let G of W){let H=$1(G);if(Z.deny.ranges.some((O)=>q(G,O)))throw new i(Q.href,$,H,"denied");if(Z.allow&&!Y&&!Z.allow.ranges.some((O)=>q(G,O)))throw new i(Q.href,$,H,"not-allowed");let V=U1(G);if(V&&Z.allowPrivate!==!0&&!Z.allowPrivate.some((O)=>q(G,O)))throw new i(Q.href,$,H,V.kind)}return{host:$,addresses:W,isLiteral:X}}function MQ(Q,Z){if(Z.aborted)return Promise.reject(Z.reason);return new Promise((J,$)=>{let K=()=>$(Z.reason);Z.addEventListener("abort",K,{once:!0}),Q.then((X)=>{Z.removeEventListener("abort",K),J(X)},(X)=>{Z.removeEventListener("abort",K),$(X)})})}async function RQ(Q,Z,J){if(Z===void 0||Z===null)return null;if(Q==="GET"||Q==="HEAD")throw TypeError(`safeFetch: a ${Q} request can't have a body.`);let $=new Request("http://body.invalid/",{method:"POST",body:Z}),K=$.headers.get("content-type");if(K&&!J.has("content-type"))J.set("content-type",K);return new Uint8Array(await $.arrayBuffer())}async function BQ(Q,Z,J,$,K,X){let Y=new AbortController,W=setTimeout(()=>Y.abort(new z1(Q.href,"connect",K.connectTimeout)),K.connectTimeout),G=AbortSignal.any([X,Y.signal]);try{let{host:H,addresses:V,isLiteral:O}=await DQ(Q,K,G),R=Q.protocol==="https:",z={};if(J.forEach((U,D)=>{z[D]=U}),$)z["content-length"]=String($.byteLength);return await new Promise((U,D)=>{let F={method:Z,host:H,port:N0(Q),path:`${Q.pathname}${Q.search}`,headers:z,agent:!1,lookup:(B,M,j)=>{let w=M?.family,L=V.filter((X1)=>!w||X1.family===w);if(L.length===0)j(Object.assign(Error(`No IPv${w} address for ${H}`),{code:"ENOTFOUND"}));else if(M?.all)j(null,L.map((X1)=>({address:$1(X1),family:X1.family})));else j(null,$1(L[0]),L[0].family)}};if(R&&!O)F.servername=H;let N=(R?HQ:WQ).request(F),S=null,_=(B)=>{G.removeEventListener("abort",I),N.destroy(),D(B)},I=()=>_(G.aborted?G.reason:X.reason);G.addEventListener("abort",I,{once:!0});let k=(B)=>{let M=B?.remoteAddress;if(!M||S!==null)return!0;let j=J1(M);if(!j||!V.some((w)=>U0(w,j)))return _(new i(Q.href,H,M,"not-allowed")),!1;return S=$1(h(j)),!0};N.once("socket",(B)=>{let M=()=>{if(k(B)&&!R)clearTimeout(W)};if(B.connecting)B.once("connect",M);else M();if(R)B.once("secureConnect",()=>clearTimeout(W))}),N.once("response",(B)=>{if(clearTimeout(W),B.on("error",()=>{}),!k(B.socket))return;G.removeEventListener("abort",I),U({request:N,response:B,address:S})}),N.on("error",(B)=>{if(G.aborted)return _(G.reason);_(B instanceof A?B:new l(Q.href,B))}),N.end($??void 0)})}finally{clearTimeout(W)}}function NQ({url:Q,hop:Z,method:J,request:$,response:K,address:X,policy:Y,signal:W,release:G}){let H=K.statusCode??0;if(H<200||H>599)throw $.destroy(),new l(Q.href,Error(`Unexpected status ${H}`));let V=new Headers,O=K.rawHeaders;for(let M=0;M<O.length;M+=2)V.append(O[M],O[M+1]);if(Y.contentTypes){let M=V.get("content-type")?.split(";")[0].trim().toLowerCase()??null;if(!M||!Y.contentTypes.some((j)=>CQ(M,j)))throw $.destroy(),new Z1(Q.href,M,Y.contentTypes)}let R={url:Q.href,redirected:Z>0,address:X},z={status:H,statusText:K.statusMessage??"",headers:V};if(J==="HEAD"||OQ.has(H))return $.destroy(),G(),new b1(null,z,R);let U=V.get("content-encoding")?.trim().toLowerCase(),D=U==="gzip"||U==="x-gzip"?o.createGunzip():U==="deflate"?o.createInflate():U==="br"?o.createBrotliDecompress():null,F=Number(V.get("content-length"));if(!D&&Number.isFinite(F)&&F>Y.maxSize)throw $.destroy(),new P1(Q.href,Y.maxSize);if(D)V.delete("content-encoding"),V.delete("content-length");let N=D?K.pipe(D):K,S=0,_=!1,I=()=>{},k=()=>{_=!0,W.removeEventListener("abort",I),G()},B=new ReadableStream({start(M){let j=(L)=>{if(_)return;if(k(),L===void 0)M.close();else $.destroy(),D?.destroy(),M.error(L)};if(I=()=>j(W.reason),W.addEventListener("abort",I,{once:!0}),W.aborted)return I();N.on("data",(L)=>{if(_)return;if(S+=L.byteLength,S>Y.maxSize)return j(new P1(Q.href,Y.maxSize));if(M.enqueue(new Uint8Array(L)),(M.desiredSize??1)<=0)N.pause()}),N.once("end",()=>j());let w=(L)=>j(L instanceof A?L:new l(Q.href,L));if(N.on("error",w),D)K.on("error",w);K.once("aborted",()=>j(new l(Q.href,Error("The response was cut off."))))},pull(){N.resume()},cancel(){if(_)return;k(),$.destroy(),D?.destroy()}});return new b1(B,z,R)}function CQ(Q,Z){let J=Z.toLowerCase();return J.endsWith("/*")?Q.startsWith(J.slice(0,-1)):Q===J}function L0(Q){return IQ(Q)??FQ(Q)??wQ(Q)}var y1=4096,LQ={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/avif":"avif","image/heic":"heic","image/heif":"heif","image/bmp":"bmp","image/tiff":"tiff","image/x-icon":"ico","image/svg+xml":"svg","audio/mpeg":"mp3","audio/aac":"aac","audio/mp4":"m4a","audio/ogg":"ogg","audio/flac":"flac","audio/wav":"wav","video/mp4":"mp4","video/quicktime":"mov","video/webm":"webm","video/x-matroska":"mkv","video/x-msvideo":"avi","font/woff":"woff","font/woff2":"woff2","font/ttf":"ttf","font/otf":"otf","application/pdf":"pdf","application/zip":"zip","application/gzip":"gz","application/xml":"xml","text/html":"html","text/plain":"txt","application/octet-stream":"bin"};function _0(Q){return LQ[Q]??"bin"}function T(Q,Z,J=0){if(Q.length<J+Z.length)return!1;return Z.every(($,K)=>Q[J+K]===$)}function b(Q,Z,J){return String.fromCharCode(...Q.subarray(Z,J))}var _Q={avif:"image/avif",avis:"image/avif",heic:"image/heic",heix:"image/heic",hevc:"image/heic",hevx:"image/heic",heim:"image/heic",heis:"image/heic",mif1:"image/heif",msf1:"image/heif","qt ":"video/quicktime","M4A ":"audio/mp4","M4B ":"audio/mp4"};function IQ(Q){if(T(Q,[137,80,78,71,13,10,26,10]))return"image/png";if(T(Q,[255,216,255]))return"image/jpeg";if(Q.length>=6&&(b(Q,0,6)==="GIF87a"||b(Q,0,6)==="GIF89a"))return"image/gif";if(Q.length>=12&&b(Q,0,4)==="RIFF"){let Z=b(Q,8,12);if(Z==="WEBP")return"image/webp";if(Z==="WAVE")return"audio/wav";if(Z==="AVI ")return"video/x-msvideo"}if(Q.length>=12&&b(Q,4,8)==="ftyp"){let Z=b(Q,8,12);return _Q[Z]??"video/mp4"}if(T(Q,[73,73,42,0])||T(Q,[77,77,0,42]))return"image/tiff";if(T(Q,[66,77])&&T(Q,[0,0,0,0],6))return"image/bmp";if(T(Q,[0,0,1,0])&&Q.length>=6&&Q[4]>0)return"image/x-icon";if(T(Q,[37,80,68,70,45]))return"application/pdf";if(T(Q,[80,75,3,4]))return"application/zip";if(T(Q,[31,139]))return"application/gzip";if(T(Q,[26,69,223,163]))return b(Q,0,Math.min(Q.length,64)).includes("webm")?"video/webm":"video/x-matroska";if(Q.length>=4){let Z=b(Q,0,4);if(Z==="OggS")return"audio/ogg";if(Z==="fLaC")return"audio/flac";if(Z==="wOFF")return"font/woff";if(Z==="wOF2")return"font/woff2";if(Z==="OTTO")return"font/otf"}if(T(Q,[0,1,0,0,0]))return"font/ttf";if(Q.length>=3&&b(Q,0,3)==="ID3")return"audio/mpeg";if(Q.length>=2&&Q[0]===255){if((Q[1]&246)===240)return"audio/aac";if((Q[1]&224)===224&&(Q[1]&6)!==0)return"audio/mpeg"}return null}var AQ=["!doctype html","html","head","script","iframe","h1","div","font","table","a","style","title","b","body","br","p","!--"];function FQ(Q){let Z=new TextDecoder("utf-8",{fatal:!1}).decode(Q);if(Z.charCodeAt(0)===65279)Z=Z.slice(1);if(Z=Z.trimStart(),!Z.startsWith("<"))return null;let J=Z.toLowerCase(),$=J;for(;;){$=$.trimStart();let K=/^(<\?[\s\S]*?\?>|<!--[\s\S]*?-->|<!doctype[^>]*>)/.exec($);if(!K)break;$=$.slice(K[0].length)}if(/^<svg[\s>/]/.test($))return"image/svg+xml";for(let K of AQ){if(!J.startsWith(`<${K}`))continue;if(/^[\s>]/.test(J.charAt(K.length+1)))return"text/html"}if(/^<(html|head|body)[\s>]/.test($))return"text/html";if(J.startsWith("<?xml"))return"application/xml";return null}function wQ(Q){if(Q.length===0)return"application/octet-stream";for(let Z of Q)if(Z<32&&Z!==9&&Z!==10&&Z!==12&&Z!==13&&Z!==27)return"application/octet-stream";try{return new TextDecoder("utf-8",{fatal:!0}).decode(Q,{stream:!0}),"text/plain"}catch{return"application/octet-stream"}}var TQ=new Set(["text/html","application/xhtml+xml","image/svg+xml","text/xml","application/xml","text/xsl","application/xslt+xml"]);function C0(Q){let Z=Q.split(";")[0].trim().toLowerCase();return TQ.has(Z)||Z.endsWith("+xml")}function I0(Q,Z){let J=Q.split(";")[0].trim().toLowerCase();return Z.some(($)=>{let K=$.split(";")[0].trim().toLowerCase();if(K==="*/*"||K==="*")return!C0(J);if(K.endsWith("/*"))return J.startsWith(K.slice(0,-1))&&!C0(J);return J===K})}import{Buffer as EQ}from"buffer";async function A0(Q){try{return(await import("sharp")).default}catch(Z){throw Error(`${Q} requires the 'sharp' package. Install it with \`bun add sharp\`.`,{cause:Z})}}async function F0(Q,Z,J={}){let{name:$,directory:K,bucket:X,maxSize:Y,timeout:W,contentTypes:G,signal:H}=J;if($!==void 0&&K!==void 0)throw TypeError("Storage.putFromUrl(): pass `name` or `directory`, not both.");if($!==void 0&&!$)throw TypeError("Storage.putFromUrl(): `name` is empty.");let V=await R0(Z,{...J.fetch,method:"GET",redirect:"follow",contentTypes:void 0,signal:H,timeout:W,maxSize:Y});if(!V.ok)throw await V.body?.cancel().catch(()=>{}),new q1(V.url,V.status);let O=(V.body??new Response(new Uint8Array).body).getReader(),R=async(j)=>{throw await O.cancel(j).catch(()=>{}),j},z=[],U=0,D=!1;while(U<y1){let{done:j,value:w}=await O.read();if(j){D=!0;break}z.push(w),U+=w.byteLength}let F=kQ(z,U),N=L0(F.subarray(0,Math.min(U,y1))),S=G?.length?G:["*/*"];if(!I0(N,S))await R(new Z1(V.url,N,S));let _=$??[(K??"").replace(/\/+$/,""),`${Bun.randomUUIDv7()}.${_0(N)}`].filter(Boolean).join("/"),I=U,k=new ReadableStream({start(j){if(U>0)j.enqueue(F);if(D)j.close()},async pull(j){let{done:w,value:L}=await O.read();if(w){j.close();return}I+=L.byteLength,j.enqueue(L)},cancel(j){return O.cancel(j)}}),B={name:_,bucket:X,body:k,contentType:N},M;try{M=Q.putStream?await Q.putStream(B,{signal:H}):await r.prototype.putStream.call(Q,B,{signal:H})}catch(j){throw await R(j),j}return{name:M,contentType:N,size:I,url:V.url}}function kQ(Q,Z){if(Q.length===1)return Q[0];let J=new Uint8Array(Z),$=0;for(let K of Q)J.set(K,$),$+=K.byteLength;return J}class xQ extends t{static getFacadeAccessor(){return E1}static async put(Q,Z={}){return this.getFacadeRoot().driver.put(Q,Z)}static async putFromUrl(Q,Z={}){return F0(this.getFacadeRoot().driver,Q,Z)}static async metadata(Q){let Z=EQ.from(await Q.arrayBuffer()),J=await A0("Storage.metadata()");try{return await J(Z).metadata()}catch{return{}}}static async fetch(Q,Z={}){Z.signal?.throwIfAborted();let J=this.getFacadeRoot();return z0(J.driver,Q,Z,{fetchTimeoutMs:J.fetchTimeoutMs??f,fetchIdleTimeoutMs:J.fetchIdleTimeoutMs??f})}static async read(Q,Z={}){let J=typeof Q==="string"?{name:Q}:{...Q},$="range"in Z?Z.range??null:J.range!==void 0?J.range:E.getStore()?.rangeRequest??null;return this.getFacadeRoot().driver.read({...J,range:$})}static list(Q){return this.getFacadeRoot().driver.list(Q)}static objects(Q,Z={}){return this.getFacadeRoot().driver.objects(Q,Z)}static async deletePrefix(Q,Z={}){return this.getFacadeRoot().driver.deletePrefix(Q,Z)}static async delete(Q){return this.getFacadeRoot().driver.delete(Q)}}var w0=["cookie","set-cookie","authorization","proxy-authorization","x-api-key"];function x8(Q){return Q}function q8(){let Q=Bun.env.NODE_ENV==="development";return{maxFileSize:10485760,console:Q,consoleFormat:Q?"text":"json",requestFields:[],redactHeaders:[],onLogFileClosed:()=>{},onLogCreated:()=>{}}}import{mkdir as v1,readdir as fQ,access as vQ}from"fs/promises";var f1=["debug","info","notice","warning","error","critical","alert","emergency"],qQ=f1.indexOf("warning");function S0(Q){if(!Q)return-1;if(Q===!0)return 0;let Z=f1.indexOf(Q);return Z===-1?0:Z}function bQ(){let Q=new WeakSet;return function(Z,J){if(typeof J==="bigint")return J.toString();if(J instanceof Error){let $={name:J.name,message:J.message,stack:J.stack};for(let K of Object.keys(J))$[K]=J[K];if(J.cause!==void 0)$.cause=J.cause;return $}if(J!==null&&typeof J==="object"){if(Q.has(J))return"[Circular]";Q.add(J)}return J}}function T0(Q){try{return JSON.stringify(Q,bQ())}catch{return'"[Unserializable]"'}}function yQ(Q,Z){if(Z==="json")return T0({...Q.metadata,timestamp:Q.timestamp,level:Q.level,message:Q.message});let J=Object.keys(Q.metadata).length>0;return`${Q.timestamp} ${Q.level.toUpperCase()} ${Q.message}${J?` ${T0(Q.metadata)}`:""}`}function k0(Q,Z){let J=f1.indexOf(Q.level);if(Z.threshold===-1||J<Z.threshold)return;try{let $=yQ(Q,Z.format)+`
3
3
  `;if(J>=qQ)process.stderr.write($);else process.stdout.write($)}catch{}}async function g1(Q){try{return await vQ(Q),!0}catch{return!1}}class h1{config;static token="log";writer;isReady=!1;flushTimeout;fileSize=0;writerSize=0;isCreatingFile=!1;bootPromise=null;currentLogFilePath;get logsDirPath(){return`${Q1()}/storage/logs`}consoleThreshold;redactedHeaders;constructor(Q){this.config=Q;this.consoleThreshold=S0(Q.console),this.redactedHeaders=new Set([...w0,...Q.redactHeaders??[]].map((Z)=>Z.toLowerCase()))}requestMetadata(Q){let Z=new URL(Q.url),J={method:Q.method,path:Z.pathname,userAgent:Q.headers.get("user-agent")??void 0},$=Q.headers.get("x-request-id");if($)J.requestId=$;let K=this.config.requestFields??[];if(K.includes("url"))J.url=Q.url;if(K.includes("headers")){let X={};Q.headers.forEach((Y,W)=>{X[W]=this.redactedHeaders.has(W)?"[redacted]":Y}),J.headers=X}return J}boot(){if(!this.bootPromise)this.bootPromise=this.createStorage().catch((Q)=>{console.error("Log storage unavailable, file logging disabled",Q)}).then(()=>{this.isReady=!0});return this.bootPromise}async createStorage(){let Q=`${Q1()}/storage`;if(!await g1(Q))await v1(Q);if(!await g1(this.logsDirPath))await v1(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await g1(this.logsDirPath))await v1(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let J=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed(J),this.fileSize=0,this.writerSize=0}let Z=(await fQ(this.logsDirPath)).sort().reverse()[0];if(Z){let J=Bun.file(`${this.logsDirPath}/${Z}`);if(J.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${Z}`,this.writer=J.writer(),this.writer.write(await J.text()),this.writer.write(`
4
4
  `),this.writer.flush(),this.fileSize=J.size}if(!this.writer){let J=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${J}`;let $=Bun.file(`${this.logsDirPath}/${J}`);this.writer=$.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log(Q,Z,J={}){if(!this.isReady)await this.boot();let $=E.getStore(),K={},X={};if($)X={method:$.req.rawRequest.method,path:new URL($.req.rawRequest.url).pathname},K=this.requestMetadata($.req.rawRequest);let Y={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:Q,message:Z,metadata:{...K,...J}};if(this.consoleThreshold!==-1)k0({timestamp:Y.timestamp,level:Q,message:Z,metadata:{...X,...J}},{threshold:this.consoleThreshold,format:this.config.consoleFormat});let W="";try{W=JSON.stringify(Y)}catch(G){console.log("Error parsing log object",G)}try{let G=this.config.onLogCreated(Y);if(G instanceof Promise)G.catch((H)=>console.error("Error in onLogCreated",H))}catch(G){console.error("Error in onLogCreated",G)}if(!this.writer)return;this.writerSize+=W.length,this.fileSize+=W.length;try{this.writer.write(W),this.writer.write(`
5
5
  `),this.tryFlush()}catch(G){console.error("Error writing log",G)}}async tryFlush(){if(this.fileSize>this.config.maxFileSize){if(!this.isCreatingFile)await this.newLogFile()}if(this.writerSize>this.config.maxFileSize/2)await this.writer.flush(),this.writerSize=0,await this.newLogFile();else clearTimeout(this.flushTimeout),this.flushTimeout=setTimeout(async()=>{await this.writer.flush(),this.writerSize=0},100)}}class gQ extends t{static getFacadeAccessor(){return h1}static debug(Q,Z){this.getFacadeRoot().log("debug",Q,Z)}static info(Q,Z){this.getFacadeRoot().log("info",Q,Z)}static notice(Q,Z){this.getFacadeRoot().log("notice",Q,Z)}static warning(Q,Z){this.getFacadeRoot().log("warning",Q,Z)}static error(Q,Z){this.getFacadeRoot().log("error",Q,Z)}static critical(Q,Z){this.getFacadeRoot().log("critical",Q,Z)}static alert(Q,Z){this.getFacadeRoot().log("alert",Q,Z)}static emergency(Q,Z){this.getFacadeRoot().log("emergency",Q,Z)}}class hQ{config;static token="redis";instance=null;connectingSince=null;downSince=null;replaceDelay=500;constructor(Q={}){this.config=Q}get client(){if(this.instance===null)return this.build();let Q=this.instance;if(this.isDown(Q,Date.now())){this.instance=null;try{Q.close()}catch{}return this.build()}return Q}set client(Q){this.instance=Q,this.connectingSince=null,this.downSince=null,this.replaceDelay=500}close(){let Q=this.instance;this.instance=null,this.connectingSince=null,this.downSince=null,this.replaceDelay=500,Q?.close()}build(){let Q=new(mQ())(this.config.url,this.config.options);if(this.instance=Q,this.downSince=null,this.connectingSince=null,typeof Q.connect==="function"){this.connectingSince=Date.now();let Z;try{Z=Promise.resolve(Q.connect())}catch(J){Z=Promise.reject(J)}Z.then(()=>{if(this.instance!==Q)return;this.connectingSince=null,this.replaceDelay=500},()=>{if(this.instance!==Q)return;this.connectingSince=null})}return Q}isDown(Q,Z){if(Q.connected!==!1||typeof Q.connect!=="function")return this.downSince=null,!1;if(this.connectingSince!==null){let J=(this.config.options?.connectionTimeout??1e4)+5000;if(Z-this.connectingSince<J)return!1;this.connectingSince=null}if(this.downSince??=Z,Z-this.downSince<this.replaceDelay)return!1;return this.replaceDelay=Math.min(this.replaceDelay*2,1e4),!0}}function mQ(){let Q=globalThis.Bun?.RedisClient;if(typeof Q!=="function")throw Error("Redis requires Bun's built-in Redis client, which this runtime does not provide. Run the app under Bun, or bind your own client for the 'redis' token.");return Q}var m1=new TextEncoder;function E0(Q){return`id: ${Q.seq}
@@ -8,6 +8,6 @@ data: ${JSON.stringify(Q.event)}
8
8
  `}var cQ=5000,pQ=`: keepalive
9
9
 
10
10
  `;function uQ(Q,Z=cQ){let J=null,$=!1,K=()=>{if($)return;if(J!==null)clearTimeout(J);J=setTimeout(()=>{if(J=null,$)return;try{Q.enqueue(m1.encode(pQ))}catch{X();return}K()},Z)},X=()=>{if($=!0,J!==null)clearTimeout(J);J=null};return K(),{touch:K,stop:X}}function dQ(){return{"Content-Type":"text/event-stream","Cache-Control":"no-store, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}}function l8(Q,Z=200){let J=Q[Symbol.asyncIterator](),$=-1,K,X=new ReadableStream({start(Y){K=uQ(Y)},async pull(Y){try{let W=await J.next();if(W.done){K.stop(),Y.close();return}$=W.value.seq,Y.enqueue(m1.encode(E0(W.value))),K.touch()}catch(W){let G={type:"error",error:lQ(W)};K.stop(),Y.enqueue(m1.encode(E0({seq:$+1,event:G}))),Y.close()}},cancel(Y){K.stop(),J.return?.(Y)}});return new Response(X,{status:Z,headers:dQ()})}var iQ=new Set(["frame_cursor_evicted","live_run_not_found"]);function lQ(Q){let Z=Q&&typeof Q==="object"?Q.code:void 0;if(Q instanceof Error&&typeof Z==="string"&&iQ.has(Z))return{code:"unknown",message:Q.message,retryable:!1};return console.error("[gemi/ai] agent stream failed",Q),{code:"unknown",message:"The run's stream failed.",retryable:!1}}
11
- export{c1 as ki,x0 as li,oQ as mi,r1 as ni,DZ as oi,Z0 as pi,MZ as qi,p1 as ri,u1 as si,aQ as ti,tQ as ui,rQ as vi,d1 as wi,R1 as xi,JZ as yi,$Z as zi,BZ as Ai,K0 as Bi,NZ as Ci,CZ as Di,s as Ei,x as Fi,C1 as Gi,HZ as Hi,VZ as Ii,OZ as Ji,jZ as Ki,zZ as Li,m0 as Mi,W0 as Ni,c0 as Oi,F1 as Pi,w1 as Qi,p0 as Ri,v as Si,u0 as Ti,t as Ui,A0 as Vi,V1 as Wi,r as Xi,H0 as Yi,k1 as Zi,X8 as _i,O0 as $i,E1 as aj,j0 as bj,A as cj,g as dj,O1 as ej,i as fj,j1 as gj,z1 as hj,P1 as ij,Z1 as jj,x1 as kj,l as lj,q1 as mj,J1 as nj,U1 as oj,b1 as pj,R0 as qj,L0 as rj,C0 as sj,xQ as tj,x8 as uj,q8 as vj,h1 as wj,gQ as xj,hQ as yj,E0 as zj,pQ as Aj,uQ as Bj,dQ as Cj,l8 as Dj};
11
+ export{c1 as mi,x0 as ni,oQ as oi,r1 as pi,DZ as qi,Z0 as ri,MZ as si,p1 as ti,u1 as ui,aQ as vi,tQ as wi,rQ as xi,d1 as yi,R1 as zi,JZ as Ai,$Z as Bi,BZ as Ci,K0 as Di,NZ as Ei,CZ as Fi,s as Gi,x as Hi,C1 as Ii,HZ as Ji,VZ as Ki,OZ as Li,jZ as Mi,zZ as Ni,m0 as Oi,W0 as Pi,c0 as Qi,F1 as Ri,w1 as Si,p0 as Ti,v as Ui,u0 as Vi,t as Wi,A0 as Xi,V1 as Yi,r as Zi,H0 as _i,k1 as $i,X8 as aj,O0 as bj,E1 as cj,j0 as dj,A as ej,g as fj,O1 as gj,i as hj,j1 as ij,z1 as jj,P1 as kj,Z1 as lj,x1 as mj,l as nj,q1 as oj,J1 as pj,U1 as qj,b1 as rj,R0 as sj,L0 as tj,C0 as uj,xQ as vj,x8 as wj,q8 as xj,h1 as yj,gQ as zj,hQ as Aj,E0 as Bj,pQ as Cj,uQ as Dj,dQ as Ej,l8 as Fj};
12
12
 
13
- //# debugId=14311764DF71A2DE64756E2164756E21
13
+ //# debugId=197283A01BF9627764756E2164756E21