gemi 0.111.0 → 0.112.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 (265) hide show
  1. package/dist/ai/Agent.d.ts +54 -1
  2. package/dist/ai/Agent.d.ts.map +1 -1
  3. package/dist/ai/AgentController.d.ts +41 -0
  4. package/dist/ai/AgentController.d.ts.map +1 -1
  5. package/dist/ai/client/index.d.ts +1 -1
  6. package/dist/ai/client/index.d.ts.map +1 -1
  7. package/dist/ai/contextCompaction.d.ts +247 -0
  8. package/dist/ai/contextCompaction.d.ts.map +1 -0
  9. package/dist/ai/contextWindow.d.ts +18 -0
  10. package/dist/ai/contextWindow.d.ts.map +1 -1
  11. package/dist/ai/index.d.ts +5 -1
  12. package/dist/ai/index.d.ts.map +1 -1
  13. package/dist/ai/index.js +93 -14
  14. package/dist/ai/index.js.map +16 -10
  15. package/dist/ai/jobs/AgentJob.d.ts +259 -0
  16. package/dist/ai/jobs/AgentJob.d.ts.map +1 -0
  17. package/dist/ai/jobs/AgentJobDeadlineSweep.d.ts +18 -0
  18. package/dist/ai/jobs/AgentJobDeadlineSweep.d.ts.map +1 -0
  19. package/dist/ai/jobs/AgentJobStore.d.ts +141 -0
  20. package/dist/ai/jobs/AgentJobStore.d.ts.map +1 -0
  21. package/dist/ai/jobs/DatabaseAgentJobStore.d.ts +82 -0
  22. package/dist/ai/jobs/DatabaseAgentJobStore.d.ts.map +1 -0
  23. package/dist/ai/jobs/contextBlock.d.ts +31 -0
  24. package/dist/ai/jobs/contextBlock.d.ts.map +1 -0
  25. package/dist/ai/jobs/index.d.ts +6 -0
  26. package/dist/ai/jobs/index.d.ts.map +1 -0
  27. package/dist/ai/jobs/overlay.d.ts +49 -0
  28. package/dist/ai/jobs/overlay.d.ts.map +1 -0
  29. package/dist/ai/providers/request.d.ts.map +1 -1
  30. package/dist/ai/store/Attachments.d.ts +6 -0
  31. package/dist/ai/store/Attachments.d.ts.map +1 -1
  32. package/dist/ai/store/MemoryAgentStore.d.ts +3 -0
  33. package/dist/ai/store/MemoryAgentStore.d.ts.map +1 -1
  34. package/dist/ai/types.d.ts +28 -0
  35. package/dist/ai/types.d.ts.map +1 -1
  36. package/dist/app/index.js +1 -1
  37. package/dist/bin/gemi.js +13 -2
  38. package/dist/bin/gemi.js.map +4 -4
  39. package/dist/bun/plugin.js +1 -1
  40. package/dist/bun/preload.js +1 -1
  41. package/dist/{chunk-30xjcyzh.js → chunk-0z2h35d7.js} +2 -2
  42. package/dist/{chunk-30xjcyzh.js.map → chunk-0z2h35d7.js.map} +1 -1
  43. package/dist/{chunk-358sdcx9.js → chunk-15a1mrdv.js} +2 -2
  44. package/dist/{chunk-358sdcx9.js.map → chunk-15a1mrdv.js.map} +1 -1
  45. package/dist/{chunk-hf7a51s3.js → chunk-18c3y8m3.js} +2 -2
  46. package/dist/{chunk-hf7a51s3.js.map → chunk-18c3y8m3.js.map} +1 -1
  47. package/dist/{chunk-tq85n8zh.js → chunk-1pvkw2pq.js} +2 -2
  48. package/dist/{chunk-tq85n8zh.js.map → chunk-1pvkw2pq.js.map} +1 -1
  49. package/dist/{chunk-8afxrmdc.js → chunk-2taa0brj.js} +2 -2
  50. package/dist/{chunk-8afxrmdc.js.map → chunk-2taa0brj.js.map} +1 -1
  51. package/dist/{chunk-5cygrbxv.js → chunk-30yg31sz.js} +2 -2
  52. package/dist/{chunk-5cygrbxv.js.map → chunk-30yg31sz.js.map} +1 -1
  53. package/dist/{chunk-3y8q8x11.js → chunk-3z9vhjd7.js} +2 -2
  54. package/dist/{chunk-3y8q8x11.js.map → chunk-3z9vhjd7.js.map} +1 -1
  55. package/dist/chunk-4sb1484x.js +46 -0
  56. package/dist/{chunk-h3864a8z.js.map → chunk-4sb1484x.js.map} +13 -4
  57. package/dist/{chunk-0sjh5v1n.js → chunk-53bek7sp.js} +1 -1
  58. package/dist/{chunk-xkc7ftnq.js → chunk-57edag57.js} +3 -3
  59. package/dist/{chunk-xkc7ftnq.js.map → chunk-57edag57.js.map} +1 -1
  60. package/dist/{chunk-ddr4qvvt.js → chunk-5az0mq4p.js} +3 -3
  61. package/dist/{chunk-ddr4qvvt.js.map → chunk-5az0mq4p.js.map} +1 -1
  62. package/dist/{chunk-nsvktvp4.js → chunk-5waxjsvv.js} +2 -2
  63. package/dist/{chunk-nsvktvp4.js.map → chunk-5waxjsvv.js.map} +1 -1
  64. package/dist/{chunk-rfcygmf5.js → chunk-6w79zajj.js} +3 -3
  65. package/dist/{chunk-rfcygmf5.js.map → chunk-6w79zajj.js.map} +1 -1
  66. package/dist/{chunk-gb37722w.js → chunk-75ptmewf.js} +3 -3
  67. package/dist/{chunk-gb37722w.js.map → chunk-75ptmewf.js.map} +1 -1
  68. package/dist/{chunk-pyj7cd9t.js → chunk-851k0b26.js} +2 -2
  69. package/dist/{chunk-pyj7cd9t.js.map → chunk-851k0b26.js.map} +1 -1
  70. package/dist/{chunk-m6ystvtk.js → chunk-8reepafh.js} +2 -2
  71. package/dist/{chunk-m6ystvtk.js.map → chunk-8reepafh.js.map} +1 -1
  72. package/dist/{chunk-nvv9wej6.js → chunk-9hr0bcfy.js} +3 -3
  73. package/dist/{chunk-nvv9wej6.js.map → chunk-9hr0bcfy.js.map} +1 -1
  74. package/dist/{chunk-yqavgpwd.js → chunk-a9q2cr4w.js} +2 -2
  75. package/dist/{chunk-yqavgpwd.js.map → chunk-a9q2cr4w.js.map} +1 -1
  76. package/dist/{chunk-cy5qp6mz.js → chunk-amvy4r59.js} +2 -2
  77. package/dist/{chunk-cy5qp6mz.js.map → chunk-amvy4r59.js.map} +1 -1
  78. package/dist/{chunk-twnn7r66.js → chunk-b1mk12xg.js} +2 -2
  79. package/dist/{chunk-twnn7r66.js.map → chunk-b1mk12xg.js.map} +1 -1
  80. package/dist/{chunk-a6453d9s.js → chunk-b7cqwcbm.js} +2 -2
  81. package/dist/{chunk-a6453d9s.js.map → chunk-b7cqwcbm.js.map} +1 -1
  82. package/dist/{chunk-nncz308h.js → chunk-b7qjp7r1.js} +2 -2
  83. package/dist/{chunk-nncz308h.js.map → chunk-b7qjp7r1.js.map} +1 -1
  84. package/dist/chunk-beks65me.js +19 -0
  85. package/dist/{chunk-mb7q7s0a.js.map → chunk-beks65me.js.map} +3 -4
  86. package/dist/chunk-bf1ets45.js +5 -0
  87. package/dist/{chunk-11fsn5mr.js.map → chunk-bf1ets45.js.map} +4 -3
  88. package/dist/{chunk-9rchedr4.js → chunk-bhw7k8vp.js} +2 -2
  89. package/dist/{chunk-9rchedr4.js.map → chunk-bhw7k8vp.js.map} +1 -1
  90. package/dist/{chunk-k1vw22t2.js → chunk-ck0v2kzw.js} +2 -2
  91. package/dist/{chunk-k1vw22t2.js.map → chunk-ck0v2kzw.js.map} +1 -1
  92. package/dist/{chunk-6vr7f5fq.js → chunk-csbc1fxa.js} +3 -3
  93. package/dist/{chunk-6vr7f5fq.js.map → chunk-csbc1fxa.js.map} +1 -1
  94. package/dist/{chunk-kf71mjxa.js → chunk-d0trs736.js} +3 -3
  95. package/dist/{chunk-kf71mjxa.js.map → chunk-d0trs736.js.map} +1 -1
  96. package/dist/{chunk-zhs1r1z0.js → chunk-d8ekyng4.js} +3 -3
  97. package/dist/{chunk-zhs1r1z0.js.map → chunk-d8ekyng4.js.map} +1 -1
  98. package/dist/chunk-d9an2nra.js +5 -0
  99. package/dist/{chunk-hn67spz6.js.map → chunk-d9an2nra.js.map} +1 -1
  100. package/dist/{chunk-0d9qsmx2.js → chunk-dan79jab.js} +2 -2
  101. package/dist/{chunk-0d9qsmx2.js.map → chunk-dan79jab.js.map} +1 -1
  102. package/dist/{chunk-1yx2e0bh.js → chunk-ddad3902.js} +2 -2
  103. package/dist/{chunk-1yx2e0bh.js.map → chunk-ddad3902.js.map} +1 -1
  104. package/dist/{chunk-3cg7y62b.js → chunk-dm59ze55.js} +2 -2
  105. package/dist/{chunk-3cg7y62b.js.map → chunk-dm59ze55.js.map} +1 -1
  106. package/dist/{chunk-wvsv1jgg.js → chunk-dx7wpz5b.js} +2 -2
  107. package/dist/{chunk-wvsv1jgg.js.map → chunk-dx7wpz5b.js.map} +1 -1
  108. package/dist/{chunk-q9s7kwgt.js → chunk-eazqda9z.js} +3 -3
  109. package/dist/{chunk-q9s7kwgt.js.map → chunk-eazqda9z.js.map} +1 -1
  110. package/dist/{chunk-td8tha3j.js → chunk-es487acc.js} +1 -1
  111. package/dist/{chunk-9s851qz8.js → chunk-et3vhkbf.js} +2 -2
  112. package/dist/{chunk-9s851qz8.js.map → chunk-et3vhkbf.js.map} +1 -1
  113. package/dist/{chunk-qd2v93y4.js → chunk-f1y8eggf.js} +2 -2
  114. package/dist/{chunk-qd2v93y4.js.map → chunk-f1y8eggf.js.map} +1 -1
  115. package/dist/{chunk-1pem26zc.js → chunk-ga7c7tq0.js} +3 -3
  116. package/dist/{chunk-1pem26zc.js.map → chunk-ga7c7tq0.js.map} +1 -1
  117. package/dist/{chunk-c098fzvk.js → chunk-gcs9ydjv.js} +2 -2
  118. package/dist/{chunk-c098fzvk.js.map → chunk-gcs9ydjv.js.map} +1 -1
  119. package/dist/{chunk-bn5yn731.js → chunk-hfyxvdjj.js} +2 -2
  120. package/dist/{chunk-bn5yn731.js.map → chunk-hfyxvdjj.js.map} +1 -1
  121. package/dist/chunk-j0sncgxc.js +14 -0
  122. package/dist/{chunk-mn5xw79b.js.map → chunk-j0sncgxc.js.map} +6 -5
  123. package/dist/{chunk-p7r2w4qw.js → chunk-j9jqxv1d.js} +3 -3
  124. package/dist/{chunk-p7r2w4qw.js.map → chunk-j9jqxv1d.js.map} +1 -1
  125. package/dist/{chunk-jbrwt3cs.js → chunk-jdtn0zk2.js} +4 -4
  126. package/dist/{chunk-jbrwt3cs.js.map → chunk-jdtn0zk2.js.map} +1 -1
  127. package/dist/{chunk-s6jjy4y9.js → chunk-jn59bsww.js} +2 -2
  128. package/dist/{chunk-s6jjy4y9.js.map → chunk-jn59bsww.js.map} +1 -1
  129. package/dist/chunk-jn8hh25v.js +24 -0
  130. package/dist/{chunk-wqvvjd5r.js.map → chunk-jn8hh25v.js.map} +2 -2
  131. package/dist/chunk-k7rbkhhw.js +6 -0
  132. package/dist/{chunk-tdsfke9q.js.map → chunk-k7rbkhhw.js.map} +2 -2
  133. package/dist/{chunk-he7z7y9j.js → chunk-kk502yk2.js} +2 -2
  134. package/dist/{chunk-he7z7y9j.js.map → chunk-kk502yk2.js.map} +1 -1
  135. package/dist/{chunk-wsttx9rg.js → chunk-mrdarm2q.js} +2 -2
  136. package/dist/{chunk-wsttx9rg.js.map → chunk-mrdarm2q.js.map} +1 -1
  137. package/dist/chunk-mvtgx1mr.js +4 -0
  138. package/dist/{chunk-x78jrs4y.js.map → chunk-mvtgx1mr.js.map} +2 -2
  139. package/dist/{chunk-et4pv1b1.js → chunk-mx9y9mtx.js} +1 -1
  140. package/dist/{chunk-cttmy1jp.js → chunk-p2fhtf5r.js} +3 -3
  141. package/dist/{chunk-cttmy1jp.js.map → chunk-p2fhtf5r.js.map} +1 -1
  142. package/dist/{chunk-w7jsh3xd.js → chunk-qtbf3w6w.js} +2 -2
  143. package/dist/{chunk-w7jsh3xd.js.map → chunk-qtbf3w6w.js.map} +1 -1
  144. package/dist/chunk-qx87cdfg.js +5 -0
  145. package/dist/chunk-qx87cdfg.js.map +10 -0
  146. package/dist/{chunk-1kr25rcg.js → chunk-qyp652jz.js} +3 -3
  147. package/dist/{chunk-1kr25rcg.js.map → chunk-qyp652jz.js.map} +1 -1
  148. package/dist/{chunk-8b2tw2yp.js → chunk-rend2sbk.js} +1 -1
  149. package/dist/chunk-rx2shb3t.js +25 -0
  150. package/dist/chunk-rx2shb3t.js.map +19 -0
  151. package/dist/{chunk-mwqg079k.js → chunk-ryzcfxq7.js} +2 -2
  152. package/dist/{chunk-mwqg079k.js.map → chunk-ryzcfxq7.js.map} +1 -1
  153. package/dist/{chunk-7tx5y712.js → chunk-s9rfgxj5.js} +2 -2
  154. package/dist/{chunk-7tx5y712.js.map → chunk-s9rfgxj5.js.map} +1 -1
  155. package/dist/{chunk-1c1d0e60.js → chunk-scbvv2e4.js} +3 -3
  156. package/dist/{chunk-1c1d0e60.js.map → chunk-scbvv2e4.js.map} +1 -1
  157. package/dist/{chunk-1bkr5wnt.js → chunk-tb126j80.js} +2 -2
  158. package/dist/{chunk-1bkr5wnt.js.map → chunk-tb126j80.js.map} +1 -1
  159. package/dist/{chunk-pwmgqq7z.js → chunk-teny6xkw.js} +2 -2
  160. package/dist/{chunk-pwmgqq7z.js.map → chunk-teny6xkw.js.map} +1 -1
  161. package/dist/{chunk-09ypnhjv.js → chunk-tmrmwthr.js} +2 -2
  162. package/dist/{chunk-09ypnhjv.js.map → chunk-tmrmwthr.js.map} +1 -1
  163. package/dist/{chunk-h4sw6nt3.js → chunk-vgdcz7tk.js} +3 -3
  164. package/dist/{chunk-h4sw6nt3.js.map → chunk-vgdcz7tk.js.map} +1 -1
  165. package/dist/{chunk-xk930yaw.js → chunk-wexs11yy.js} +2 -2
  166. package/dist/{chunk-xk930yaw.js.map → chunk-wexs11yy.js.map} +1 -1
  167. package/dist/{chunk-k1xt2tw7.js → chunk-xs4c2nvz.js} +2 -2
  168. package/dist/{chunk-k1xt2tw7.js.map → chunk-xs4c2nvz.js.map} +1 -1
  169. package/dist/{chunk-1va15sfq.js → chunk-xv74rhay.js} +2 -2
  170. package/dist/{chunk-1va15sfq.js.map → chunk-xv74rhay.js.map} +1 -1
  171. package/dist/{chunk-sq2wkynk.js → chunk-yv1psptb.js} +2 -2
  172. package/dist/{chunk-sq2wkynk.js.map → chunk-yv1psptb.js.map} +1 -1
  173. package/dist/{chunk-tk5q8hkv.js → chunk-zfter1x0.js} +4 -4
  174. package/dist/{chunk-tk5q8hkv.js.map → chunk-zfter1x0.js.map} +1 -1
  175. package/dist/client/ClientRouter.d.ts.map +1 -1
  176. package/dist/client/index.d.ts +2 -0
  177. package/dist/client/index.d.ts.map +1 -1
  178. package/dist/client/index.js +215 -2
  179. package/dist/client/index.js.map +1 -1
  180. package/dist/client/useSubscription.d.ts +70 -0
  181. package/dist/client/useSubscription.d.ts.map +1 -0
  182. package/dist/config/index.js +1 -1
  183. package/dist/console/run.js +2 -2
  184. package/dist/console/run.js.map +2 -2
  185. package/dist/container/index.js +2 -2
  186. package/dist/container/index.js.map +1 -1
  187. package/dist/database/index.js +2 -2
  188. package/dist/database/index.js.map +1 -1
  189. package/dist/email/index.js +2 -2
  190. package/dist/email/index.js.map +1 -1
  191. package/dist/facades/ChangeFeed.d.ts +42 -0
  192. package/dist/facades/ChangeFeed.d.ts.map +1 -0
  193. package/dist/facades/index.d.ts +1 -0
  194. package/dist/facades/index.d.ts.map +1 -1
  195. package/dist/facades/index.js +2 -2
  196. package/dist/facades/index.js.map +1 -1
  197. package/dist/foundation/index.js +2 -2
  198. package/dist/foundation/index.js.map +1 -1
  199. package/dist/http/ResourcePolicy.d.ts +141 -0
  200. package/dist/http/ResourcePolicy.d.ts.map +1 -0
  201. package/dist/http/errors.d.ts +13 -0
  202. package/dist/http/errors.d.ts.map +1 -1
  203. package/dist/http/index.d.ts +2 -1
  204. package/dist/http/index.d.ts.map +1 -1
  205. package/dist/http/index.js +2 -2
  206. package/dist/http/index.js.map +1 -1
  207. package/dist/i18n/dictionaryRuntime.js +2 -2
  208. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  209. package/dist/i18n/index.js +2 -2
  210. package/dist/i18n/index.js.map +2 -2
  211. package/dist/kernel/index.js +3 -3
  212. package/dist/kernel/index.js.map +3 -3
  213. package/dist/kernel/providers.d.ts.map +1 -1
  214. package/dist/orm/index.js +2 -2
  215. package/dist/orm/index.js.map +1 -1
  216. package/dist/server/index.js +2 -2
  217. package/dist/server/index.js.map +1 -1
  218. package/dist/services/change-feed/ChangeFeedDriver.d.ts +94 -0
  219. package/dist/services/change-feed/ChangeFeedDriver.d.ts.map +1 -0
  220. package/dist/services/change-feed/ChangeFeedManager.d.ts +166 -0
  221. package/dist/services/change-feed/ChangeFeedManager.d.ts.map +1 -0
  222. package/dist/services/change-feed/ChangeFeedServiceProvider.d.ts +11 -0
  223. package/dist/services/change-feed/ChangeFeedServiceProvider.d.ts.map +1 -0
  224. package/dist/services/change-feed/DatabaseChangeFeedDriver.d.ts +84 -0
  225. package/dist/services/change-feed/DatabaseChangeFeedDriver.d.ts.map +1 -0
  226. package/dist/services/change-feed/MemoryChangeFeedDriver.d.ts +26 -0
  227. package/dist/services/change-feed/MemoryChangeFeedDriver.d.ts.map +1 -0
  228. package/dist/services/change-feed/changeFeedDriverContract.d.ts +8 -0
  229. package/dist/services/change-feed/changeFeedDriverContract.d.ts.map +1 -0
  230. package/dist/services/change-feed/config.d.ts +42 -0
  231. package/dist/services/change-feed/config.d.ts.map +1 -0
  232. package/dist/services/change-feed/cursor.d.ts +17 -0
  233. package/dist/services/change-feed/cursor.d.ts.map +1 -0
  234. package/dist/services/change-feed/postgresListen.d.ts +30 -0
  235. package/dist/services/change-feed/postgresListen.d.ts.map +1 -0
  236. package/dist/services/change-feed/stream.d.ts +16 -0
  237. package/dist/services/change-feed/stream.d.ts.map +1 -0
  238. package/dist/services/change-feed/wire.d.ts +20 -0
  239. package/dist/services/change-feed/wire.d.ts.map +1 -0
  240. package/dist/services/index.d.ts +9 -0
  241. package/dist/services/index.d.ts.map +1 -1
  242. package/dist/services/index.js +3 -3
  243. package/dist/services/index.js.map +2 -2
  244. package/dist/services/queue/work.js +2 -2
  245. package/dist/services/queue/work.js.map +1 -1
  246. package/dist/services/router/ViewRouteDispatcher.d.ts +16 -0
  247. package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
  248. package/dist/stats/route-table.js +1 -1
  249. package/dist/support/index.js +2 -2
  250. package/dist/support/index.js.map +1 -1
  251. package/dist/vitest/index.js +1 -1
  252. package/package.json +6 -2
  253. package/skills/gemi-react-best-practices/rules/controller-authorize-every-tenant-read.md +16 -1
  254. package/dist/chunk-11fsn5mr.js +0 -5
  255. package/dist/chunk-h3864a8z.js +0 -17
  256. package/dist/chunk-hn67spz6.js +0 -5
  257. package/dist/chunk-mb7q7s0a.js +0 -19
  258. package/dist/chunk-mn5xw79b.js +0 -9
  259. package/dist/chunk-tdsfke9q.js +0 -6
  260. package/dist/chunk-wqvvjd5r.js +0 -24
  261. package/dist/chunk-x78jrs4y.js +0 -4
  262. /package/dist/{chunk-0sjh5v1n.js.map → chunk-53bek7sp.js.map} +0 -0
  263. /package/dist/{chunk-td8tha3j.js.map → chunk-es487acc.js.map} +0 -0
  264. /package/dist/{chunk-et4pv1b1.js.map → chunk-mx9y9mtx.js.map} +0 -0
  265. /package/dist/{chunk-8b2tw2yp.js.map → chunk-rend2sbk.js.map} +0 -0
@@ -1,17 +0,0 @@
1
- // @bun
2
- import{ne as KW,ue as o7}from"./chunk-nvv9wej6.js";import{Be as LZ,Ge as N3,lf as a7}from"./chunk-tq85n8zh.js";import{Af as w7,Bf as Vj,Cf as h,Hf as E,If as E8,Jf as A8,Kf as N8,Mf as Z$,Nf as V0,Of as r6,Wf as I5,Xf as P$,Yf as h7,mf as f8,qf as f7,rf as gj,sf as I8,tf as B8,wf as D8,xf as T8,yf as NZ,zf as F7}from"./chunk-mn5xw79b.js";import{$f as q0,_f as I3,ag as A1,bg as pj}from"./chunk-pwmgqq7z.js";import{cg as e5,dg as z8,eg as f}from"./chunk-sq2wkynk.js";import{hg as l7}from"./chunk-twnn7r66.js";import{ig as g7}from"./chunk-bn5yn731.js";import{jg as E7,kg as yZ,lg as mZ,mg as i7,ng as s7,zg as n7}from"./chunk-xkc7ftnq.js";import{Og as pZ}from"./chunk-s6jjy4y9.js";import{Tg as H7,Yg as $j}from"./chunk-wvsv1jgg.js";import{dh as P7,hh as n}from"./chunk-7tx5y712.js";import{ih as IZ,lh as I}from"./chunk-q9s7kwgt.js";import{zh as A7}from"./chunk-nsvktvp4.js";import{Eh as Jj}from"./chunk-1yx2e0bh.js";function x3($){return typeof $==="function"&&$.prototype!==void 0}function K1($){return typeof $==="string"?[$]:$}function f3($,Z){let J=Z?"attachment":"inline",j=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${J}; filename="${j}"; filename*=UTF-8''${encodeURIComponent($)}`}function OO($){return"total"in $&&"partial"in $&&"body"in $}function Gj(){return new Response("Not found",{status:404,headers:{"X-Content-Type-Options":"nosniff"}})}function HZ($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":T8($),"Content-Length":"0","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}})}async function XO($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(OO($))return{body:$.body,start:$.start,end:$.end,total:$.total,partial:$.partial,type:$.type,name:$.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}};let Z=$.file,J=Z instanceof Blob?Z:null,j=$.total??J?.size??-1;return{body:Z,start:$.start??0,end:$.end??j-1,total:j,partial:$.partial??!1,type:$.type??J?.type??"",name:$.name??Z?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function V8($,Z){if($ instanceof Response)return $;if(!$)return Gj();let J=await XO($),{body:j,start:W,end:Y,total:z,partial:O}=J;if(j instanceof Blob&&"exists"in j&&typeof j.exists==="function"){if(!await j.exists())return Gj()}let{range:X}=Z;if(X){if(z<=0)return HZ(Math.max(z,0));if(!O){if(j instanceof Blob){let Q=B8(X,z);if(!Q)return HZ(z);j=j.slice(Q.start,Q.end+1),W=Q.start,Y=Q.end,O=!0}}}let F=Boolean(X)&&O,G=F?206:J.status,K=new Headers;if(K.set("Accept-Ranges","bytes"),K.set("Content-Type",J.type||"application/octet-stream"),K.set("X-Content-Type-Options","nosniff"),F)K.set("Content-Range",D8(W,Y,z)),K.set("Content-Length",String(Y-W+1));else if(z>=0)K.set("Content-Length",String(z));if(J.name)K.set("Content-Disposition",f3(J.name,J.download));if(J.etag)K.set("ETag",J.etag);if(J.lastModified)K.set("Last-Modified",J.lastModified.toUTCString());for(let[Q,U]of Object.entries(J.extraHeaders))K.set(Q,U);if((Z.method??"GET").toUpperCase()==="HEAD"){if(j&&"cancel"in j&&typeof j.cancel==="function")await j.cancel();return new Response(null,{status:G,headers:K})}return new Response(j,{status:G,headers:K})}class A$ extends q0{limit;constructor($){super("The request body is too large.",{status:413});this.limit=$}}var Kj={b:1,k:1024,kb:1024,m:1048576,mb:1048576,g:1073741824,gb:1073741824};function xZ($){if(typeof $==="number"){if(Number.isFinite($)&&$>=0)return Math.floor($);if($===1/0)return 1/0}else{let Z=$.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 Kj)))return Math.floor(Number(J[1])*(Kj[J[2]]??1))}throw Error(`Invalid body limit ${JSON.stringify($)}. Use a byte count or a size such as "64kb", "1mb" or "none".`)}var SZ=new WeakMap;function Uj($){return SZ.has($)}function Bj($){return SZ.get($)?.limit??null}function Dj($){let Z=SZ.get($);return Z?Z.read>Z.limit:!1}function FO($){let Z=$.headers.get("Content-Length");if(Z===null||!/^\s*\d+\s*$/.test(Z))return null;return Number(Z)}function C8($,Z){let J=FO($);if(J!==null&&J>Z)throw new A$(Z)}function E3($,Z,J={}){let j=SZ.get($);if(j)j.limit=Z;else{let W={limit:Z,read:0,stream:void 0,used:!1};SZ.set($,W),KO($,W)}if(J.checkDeclared!==!1)C8($,Z)}function GO($){return Reflect.get(Object.getPrototypeOf($),"body",$)??null}function M8($,Z){if(Z.stream!==void 0)return Z.stream;let J=GO($);if(!J)return Z.stream=null;let j;return Z.stream=new ReadableStream({async pull(W){j??=J.getReader();let{done:Y,value:z}=await j.read();if(Y){W.close();return}if(Z.read+=z.byteLength,Z.read>Z.limit){let O=new A$(Z.limit);W.error(O),j.cancel(O).catch(()=>{});return}W.enqueue(z)},cancel(W){return j?j.cancel(W):J.cancel(W)}},{highWaterMark:0}),Z.stream}async function E$($,Z){if(C8($,Z.limit),Z.used||Z.stream?.locked)throw TypeError("Body already used");Z.used=!0;let J=M8($,Z);if(!J)return new Uint8Array(0);let j=J.getReader(),W=[],Y=0;for(;;){let{done:X,value:F}=await j.read();if(X)break;W.push(F),Y+=F.byteLength}let z=new Uint8Array(Y),O=0;for(let X of W)z.set(X,O),O+=X.byteLength;return z}function Qj($){return $.headers.get("Content-Type")??""}function KO($,Z){let J=(j,W)=>Object.defineProperty($,j,{configurable:!0,...W});J("body",{get:()=>M8($,Z)}),J("bodyUsed",{get:()=>Z.used||Boolean(Z.stream?.locked)||Reflect.get(Object.getPrototypeOf($),"bodyUsed",$)}),J("bytes",{value:()=>E$($,Z)}),J("arrayBuffer",{value:async()=>{let j=await E$($,Z);return j.buffer.slice(j.byteOffset,j.byteOffset+j.byteLength)}}),J("text",{value:async()=>new TextDecoder().decode(await E$($,Z))}),J("json",{value:async()=>JSON.parse(new TextDecoder().decode(await E$($,Z)))}),J("blob",{value:async()=>new Blob([await E$($,Z)],{type:Qj($)})}),J("formData",{value:async()=>new Response(await E$($,Z),{headers:{"Content-Type":Qj($)}}).formData()}),J("clone",{value:()=>{C8($,Z.limit);let j=M8($,Z),W=null;if(j){let[Y,z]=j.tee();Z.stream=Y,W=z}return new Request($.url,{method:$.method,headers:$.headers,body:W,signal:$.signal,duplex:"half"})}})}function Tj($){return x3($)}class $0{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,Z,J){this.method=$;this.handler=Z;this.methodName=J;this.handler=Z,this.methodName=J,this.method=$}get source(){if(!Tj(this.handler)||typeof this.methodName!=="string")return;return{controller:this.handler,methodName:this.methodName}}__internal_use(){return{run:this.run.bind(this),middlewares:this.middlewares}}run($){if(Tj(this.handler)){let Z=new this.handler;return Z[this.methodName].bind(Z)()}return this.handler()}middleware($){return this.middlewares=K1($),this}}class Mj{url;headers;__internal_brand="ProxyHandler";middlewares=[];constructor($,Z){this.url=$;this.headers=Z}middleware($){return this.middlewares=K1($),this}async run(){let $=new E,Z=$.headers.toJSON();for(let J of Vj($.rawRequest))delete Z[J];try{return await fetch(this.url,{method:$.rawRequest.method,headers:{...Z,...this.headers},body:$.rawRequest.body})}catch(J){if(Dj($.rawRequest))throw new A$(Bj($.rawRequest));throw J}}}class Cj{constructor(...$){return new $0(...$)}}class Ij extends $0{__internal_brand="StreamHandler";async run($){let Z=f.getStore(),J=Z?.req?.rawRequest,j=I8(J?.headers.get("Range"));if(Z)Z.rangeRequest=j;try{let W=await super.run($);return await V8(W,{range:j,method:J?.method})}catch(W){if(W instanceof N8)return HZ(W.total);throw W}finally{if(Z)Z.rangeRequest=null}}}class Nj{constructor(...$){return new Ij(...$)}}class Lj{__internal_brand="ResourceRoutes";first;second;constructor($){this.first={get:new $0("GET",$,"list"),post:new $0("POST",$,"store")},this.second={get:new $0("GET",$,"show"),put:new $0("PUT",$,"update"),delete:new $0("DELETE",$,"delete")}}middleware($){if($.list)this.first.get.middleware($.list);if($.store)this.first.post.middleware($.store);if($.show)this.second.get.middleware($.show);if($.update)this.second.put.middleware($.update);if($.delete)this.second.delete.middleware($.delete);return this}}class x0{static __brand="ApiRouter";routes={};middlewares=[];middleware($){}get($,Z){return new $0("GET",$,Z)}post($,Z){return new $0("POST",$,Z)}put($,Z){return new $0("PUT",$,Z)}patch($,Z){return new $0("PATCH",$,Z)}delete($,Z){return new $0("DELETE",$,Z)}resource($){return new Lj($)}agent($){if($.kind!=="agent-controller")throw TypeError(`this.agent() takes an AgentController class, and got ${QO($)}.`);return UO($,this)}file($,Z){return new Cj("GET",$,Z)}stream($,Z){return new Nj("GET",$,Z)}proxy($,Z={}){return new Mj($,Z)}}function QO($){if(typeof $==="function"&&$.name)return $.name;return typeof $}function UO($,Z){let J={stream:new $0("POST",$,"stream"),attach:new $0("POST",$,"attach"),stop:new $0("POST",$,"stop"),upload:new $0("POST",$,"upload")};return class extends x0{static __internal_brand="AgentRoute";static controller=$;static handlers=J;constructor(){super();this.middlewares=[...Z?.middlewares??[]]}routes={"/":J.stream,"/attach":J.attach,"/stop":J.stop,"/files":J.upload};static middleware(W){if(W.stream)J.stream.middleware(W.stream);if(W.attach)J.attach.middleware(W.attach);if(W.stop)J.stop.middleware(W.stop);if(W.upload)J.upload.middleware(W.upload);return this}}}class L8{as;input;bind;__internal_brand="McpModelParam";constructor($,Z,J){this.as=$;this.input=Z;this.bind=J}}class _8{method;url;meta;__internal_brand="McpRoute";constructor($,Z,J){this.method=$;this.url=Z;this.meta=J}}class _j{static __brand="McpRouter";routes={};param($){return new L8($.as,$.input,$.bind)}fromApiRoute($,Z,J){return new _8($,Z,J)}}function z0($,Z){return $.replace(/:([^/]+[*?]?)/g,(J,j)=>{let W=j.endsWith("?")||j.endsWith("*"),Y=W?j.slice(0,-1):j,z=Z[Y];if(z===void 0){if(W)return"";if(import.meta.env.DEV)throw Error(`Missing parameter: ${Y}`);console.error(`Missing parameter: ${Y} in URL: ${$}`)}return String(z)}).replace(/\/\//g,"/").replace(/\/$/,"")}class P8 extends q0{constructor($,Z=307){super("Redirect error");this.name="RedirectError",this.payload={api:{status:200,data:{},directive:{kind:"Redirect",path:$}},view:{status:Z,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:$}}}}}class A3{static to($,...Z){let[J={}]=Z,{search:j={},params:W={},permanent:Y,status:z}={params:{},status:307,permanent:!1,...J},O=new URLSearchParams(j).toString();throw new P8([z0($,W)||"/",O.toString()].filter(Boolean).join("?"),z??(Y?301:307))}static external($,Z=307){throw new P8($,Z)}}var Pj=Symbol.for("gemi.HttpResponse");class $${kind;body;status;headers;[Pj]=!0;constructor($,Z,J,j){this.kind=$;this.body=Z;this.status=J;this.headers=j}static json($,Z={}){let J=Z.status??200;return BO(J),new $$("json",$,J,new Headers(Z.headers))}static error($,Z,J={}){if(!Number.isInteger($)||$<400||$>599)throw RangeError(`HttpResponse.error: status must be an integer from 400 to 599, got ${$}.`);return $$.json({error:Z},{...J,status:$})}get ok(){return this.status>=200&&this.status<300}toResponse($,Z){let J=$,j=this.serialize(J);for(let W of Z)J.append("Set-Cookie",W);this.headers.forEach((W,Y)=>{if(Y.toLowerCase()!=="set-cookie")J.set(Y,W)});for(let W of this.headers.getSetCookie())J.append("Set-Cookie",W);if(this.status>=400&&!this.headers.has("Cache-Control"))J.set("Cache-Control","no-store");return new Response(j,{status:this.status,headers:J})}serialize($){switch(this.kind){case"json":return $.set("Content-Type","application/json"),JSON.stringify(this.body)??null}}}function BO($){if(!Number.isInteger($)||$<200||$>599)throw RangeError(`HttpResponse: status must be an integer from 200 to 599, got ${$}.`);if($===204||$===205||$===304)throw RangeError(`HttpResponse.json: a ${$} response has no body.`)}function b$($){return typeof $==="object"&&$!==null&&$[Pj]===!0}function DO($,Z,J={}){return $$.error($,Z,J)}class Hj{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[Z,J]=$;this.handler=(j)=>{return new Z()[J](j)}}}async run($,Z){let{destination:J,permanent:j=!1,status:W=307}=await this.handler($);if(!J)throw Error(`Redirect destination is required see ${Z}`);return A3.to(J,{permanent:j,status:W}),{}}middleware($){return this.middlewares=K1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function H8($,Z){if($ instanceof Response)return $;let J=$ instanceof Blob,j=J?$:$.file,W=J?$.name:$.name??$.file?.name,Y=(J?$.type:$.type??$.file?.type)||"",z=J?!1:$.download??!1,O=J?200:$.status??200;if(!J)for(let[X,F]of Object.entries($.headers??{}))Z.set(X,F);if(j instanceof Blob&&"exists"in j&&typeof j.exists==="function"){if(!await j.exists())return new Response("Not found",{status:404})}if(Z.set("Content-Type",Y||"application/octet-stream"),j instanceof Blob)Z.set("Content-Length",String(j.size));if(W)Z.set("Content-Disposition",f3(W,z));return new Response(j instanceof Blob?j.stream():j,{status:O,headers:Z})}class Sj{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[Z,J]=$;this.handler=(j)=>{return new Z()[J](j)}}}async run($,Z){let J=await this.handler($);if(!J)throw Error(`File route handler must return a file see ${Z}`);return{FILE:J}}middleware($){return this.middlewares=K1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}function xj($,Z){if(b$($))throw Error(`The handler of view "${Z}" returned an HttpResponse. HttpResponse is for api routes; a view handler returns its props.`);return $}class fj{viewPath;middlewares=[];featureGates=[];staticOptions=null;handler;constructor($,Z){this.viewPath=$;if(!Z)this.handler=()=>({});else if(typeof Z==="function")this.handler=Z;else{let[J,j]=Z;this.handler=(W)=>{return new J()[j](W)}}}async run($,Z){let J=xj(await this.handler($),this.viewPath);return{[this.viewPath]:{...J,breadcrumb:{label:J?.breadcrumb??"",href:Z}}}}middleware($){return this.middlewares=K1($),this}static($={}){return this.staticOptions={...$},this}feature($){return this.featureGates=[...this.featureGates,$],this}}class Ej{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,Z,J){this.viewPath=$;if(typeof Z==="function")this.handler=Z,this.children=class extends f1{routes=J??{}};else if(Array.isArray(Z)){let[j,W]=Z;this.handler=(Y)=>{return new j()[W](Y)},this.children=class extends f1{routes=J??{}}}else this.children=class extends f1{routes=Z},this.handler=()=>({})}async run($,Z){let J=xj(await this.handler($),this.viewPath);return{[this.viewPath]:{...J,breadcrumb:{label:J?.breadcrumb??"",href:Z}}}}alwaysRun(){return this.alwaysRuns=!0,this}middleware($){return this.middlewares=K1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class f1{middlewares=[];featureGates=[];routes={};view($,Z){return new fj($,Z)}file($){return new Sj($)}redirect($){return new Hj($)}layout($,Z,J){return new Ej($,Z,J)}}class M0{req;static runsOnRefusal=!1;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let Z=this;return class extends Z{config=$}}}function TO($){return $}function VO(){return{aliases:{},global:[],bodyLimit:null}}var v$="redirect";function fZ($,Z="/"){if(typeof $!=="string"||!$.startsWith("/"))return Z;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return Z;try{let J=new URL($,"http://gemi.invalid");if(J.origin!=="http://gemi.invalid")return Z;let j=`${J.search}${J.hash}`.replaceAll("/","%2F"),W=`${J.pathname}${j}`.replaceAll(":","%3A");return W.startsWith("//")?Z:W}catch{return Z}}function Aj($){let Z=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return Z?Z==="https":new URL($.url).protocol==="https:"}function MO($,Z=!0){let J=new URL($.rawRequest.url),j=J.pathname.replace(/\.(json|og)$/,""),[,W,...Y]=j.split("/");if(I(n).supportedLocales.includes(W))j=`/${Y.join("/")}`;return Z?`${j}${J.search}`:j}function CO($,Z){let J=(j)=>j.replace(/\/+$/,"")||"/";return J($)===J(Z)}function b3($,Z){let J=Z||I(A).config.signInPath,j=/^[a-z][a-z\d+.-]*:/i.test(J);if(j?!/^https?:\/\//i.test(J):!J.startsWith("/"))throw Error(`\`auth.signInPath\` must be a path like "/auth/sign-in", or an http(s) URL for sign-in hosted elsewhere. Got "${J}". A route's own \`"auth:<path>"\` cannot carry a URL, because the alias parser splits it on the colon.`);let W=new URL(J,"http://gemi.invalid");if($?.kind==="view"){let Y=MO($,!j);if(j||!CO(new URL(Y,W).pathname,W.pathname))W.searchParams.set(v$,Y)}return j?W.href:`${W.pathname}${W.search}`}var E1="access_token";function S8($){return $?.cookies?.get("access_token")||$?.headers?.get("access_token")||null}async function v3($,Z){let J=S8(Z);if(!J)return null;return(await $.getSession(J,Z.headers.get("User-Agent")))?.user??null}class bj extends M0{async run($){let Z=f.getStore(),J=Z.req;if(Z.user)return{};let j=await v3(I(A),J);if(!j)throw new Z$({redirectTo:b3(J,$)});return Z.setUser(j),{}}}class vj extends M0{async run(...$){let[Z="public",J="864000",...j]=$,W=`${Z}, max-age=${J}${j.length>0?", ":""}${j.join(", ")}`;if($.length===0)W="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="public")W="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="private")W="private, max-age=0, stale-while-revalidate=300, stale-if-error=600";if(this.req.rawRequest.method==="GET")this.req.ctx().setHeaders("Cache-Control",W);return{}}}var Rj={"Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Allow-Credentials":"true"};class wj extends M0{static runsOnRefusal=!0;config={origins:{"":{"Access-Control-Allow-Methods":"GET, HEAD, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Allow-Credentials":"true"}}};run(){let $=this.req,Z=$.rawRequest.headers.get("Origin");if(Z&&this.config.origins[Z]){$.ctx().setHeaders("Access-Control-Allow-Origin",Z);let J={...Rj,...this.config.origins[Z]};for(let[j,W]of Object.entries(J))$.ctx().setHeaders(j,W)}else if(Z&&this.config.origins["*"]){$.ctx().setHeaders("Access-Control-Allow-Origin","*");let J={...Rj,...this.config.origins["*"]};delete J["Access-Control-Allow-Credentials"];for(let[j,W]of Object.entries(J))$.ctx().setHeaders(j,W)}return{}}}class e0{config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,Z={}){let J=Z.limit??this.config.limit,j=Z.window??this.config.window,W=Z.cost??1;if(kj("window",j),kj("limit",J),!Number.isFinite(W)||W<0)throw Error(`Rate limiter cost must be zero or greater, got ${W}`);return await this.config.driver.consume({key:$,limit:J,window:j*1000,cost:W})}}function kj($,Z){if(!Number.isFinite(Z)||Z<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${Z}`)}class EZ extends q0{constructor($){super("Rate limit exceeded");let Z={"Content-Type":"application/json",...$?mj($):{}};this.payload={api:{status:429,data:{error:A1("rate_limit","Rate limit exceeded",429)},headers:Z},view:{error:{message:"Rate limit exceeded"},status:429,headers:Z}}}}class yj extends M0{async run($,Z){let J=IO();if(!J)return{};let j=await J.consume(this.key(),{limit:qj($)??this.config.limit,window:qj(Z)??this.config.window});if(this.config.headers!==!1){let W=this.req.ctx?.();if(W)for(let[Y,z]of Object.entries(mj(j)))W.setHeaders(Y,z)}if(!j.allowed)throw new EZ(j);return{}}key(){if(this.config.key)return this.config.key(this.req);return`${R$(this.req)}:${this.req.routePath??"*"}`}}function IO(){try{let $=I();return $.bound(e0)?$.make(e0):null}catch{return null}}function R$($){let Z=gj($.rawRequest);if(Z!==void 0)return Z;let J=$.headers.get("x-forwarded-for");if(J){let[j]=J.split(",");if(j?.trim())return j.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function mj($){let Z={"X-RateLimit-Limit":String($.limit),"X-RateLimit-Remaining":String($.remaining),"X-RateLimit-Reset":String(Math.ceil($.resetAt/1000))};if(!$.allowed)Z["Retry-After"]=String(Math.max(1,Math.ceil($.retryAfter/1000)));return Z}function qj($){if($===void 0||$===null||$==="")return;let Z=Number($);if(!Number.isFinite(Z)||Z<=0)return;return Z}class hj extends M0{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new x8;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new x8;return{}}}class x8 extends q0{constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:pj("csrf","Invalid CSRF token",403)}},view:{}}}class R3 extends M0{run($){let Z=$??this.config.limit;if(Z===void 0||Z==="")throw Error('`body-limit` needs a size, as in "body-limit:64kb".');return E3(this.req.rawRequest,xZ(Z)),{}}}class cj{policiesList={};constructor(){let $=this.register();for(let Z of $){let J=new Z;this.policiesList[Z.name]=J}}register(){return[]}}class lj{all($,Z){return!0}}import{lookup as AO}from"dns/promises";import*as bO from"http";import*as vO from"https";import*as p$ from"zlib";function NO($){if($==="")return null;let Z=$.split(".");if(Z.length>1&&Z[Z.length-1]==="")Z.pop();if(Z.length===0||Z.length>4)return null;let J=[];for(let Y of Z){let z=LO(Y);if(z===null)return null;J.push(z)}let j=J.pop();for(let Y of J)if(Y>255)return null;if(j>=256**(4-J.length))return null;let W=j;return J.forEach((Y,z)=>{W+=Y*256**(3-z)}),new Uint8Array([Math.floor(W/16777216)&255,Math.floor(W/65536)&255,Math.floor(W/256)&255,W&255])}function LO($){if($==="")return null;let Z=$,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 W=parseInt(Z,J);return Number.isSafeInteger(W)?W:null}function dj($){let Z=$;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 j=Z.split("::");if(j.length>2)return null;let W=(F,G)=>{if(F==="")return[];let K=[],Q=F.split(":");for(let U=0;U<Q.length;U++){let B=Q[U];if(G&&U===Q.length-1&&B.includes(".")){if(!/^\d{1,3}(\.\d{1,3}){3}$/.test(B))return null;let D=B.split(".").map(Number);if(D.some((T)=>T>255))return null;K.push(D[0]<<8|D[1],D[2]<<8|D[3]);continue}if(!/^[0-9a-f]{1,4}$/i.test(B))return null;K.push(parseInt(B,16))}return K},Y=W(j[0],j.length===1),z=j.length===2?W(j[1],!0):[];if(!Y||!z)return null;let O;if(j.length===2){let F=8-Y.length-z.length;if(F<1)return null;O=[...Y,...Array.from({length:F},()=>0),...z]}else O=Y;if(O.length!==8)return null;let X=new Uint8Array(16);return O.forEach((F,G)=>{X[G*2]=F>>8,X[G*2+1]=F&255}),X}function AZ($){let Z=dj($);if(Z)return{family:6,bytes:Z};let J=NO($);if(J)return{family:4,bytes:J};return null}function J$($){if($.family===6&&_O($.bytes))return{family:4,bytes:$.bytes.slice(12)};return $}function _O($){for(let Z=0;Z<10;Z++)if($[Z]!==0)return!1;return $[10]===255&&$[11]===255}function bZ($){if($.family===4)return Array.from($.bytes).join(".");let Z=[];for(let J=0;J<16;J+=2)Z.push(($.bytes[J]<<8|$.bytes[J+1]).toString(16));return Z.join(":")}function k$($){let Z=$.lastIndexOf("/"),J=Z===-1?$:$.slice(0,Z),j=/^[0-9.]+$/.test(J)?PO(J):dj(J);if(!j)return null;let W=J$(j.length===4?{family:4,bytes:j}:{family:6,bytes:j}),Y=W.family===4?32:128,z=Y;if(Z!==-1){let O=$.slice(Z+1);if(!/^\d{1,3}$/.test(O))return null;if(z=Number(O),j.length===16&&W.family===4)z-=96;if(z<0||z>Y)return null}return{family:W.family,bytes:W.bytes,prefix:z}}function PO($){return/^\d{1,3}(\.\d{1,3}){3}$/.test($)&&$.split(".").every((Z)=>Number(Z)<=255)?new Uint8Array($.split(".").map(Number)):null}function Q1($,Z){let J=J$($);if(J.family!==Z.family)return!1;let j=Z.prefix;for(let W=0;j>0;W++){let Y=Math.min(8,j),z=255<<8-Y&255;if((J.bytes[W]&z)!==(Z.bytes[W]&z))return!1;j-=Y}return!0}var w=($,Z)=>({cidr:k$($),kind:Z,text:$}),HO=[w("0.0.0.0/8","unspecified"),w("10.0.0.0/8","private"),w("100.64.0.0/10","shared"),w("127.0.0.0/8","loopback"),w("169.254.169.254/32","metadata"),w("169.254.0.0/16","link-local"),w("168.63.129.16/32","metadata"),w("172.16.0.0/12","private"),w("192.0.0.0/24","reserved"),w("192.0.2.0/24","documentation"),w("192.88.99.0/24","reserved"),w("192.168.0.0/16","private"),w("198.18.0.0/15","benchmarking"),w("198.51.100.0/24","documentation"),w("203.0.113.0/24","documentation"),w("224.0.0.0/4","multicast"),w("255.255.255.255/32","broadcast"),w("240.0.0.0/4","reserved")],SO=[w("::/128","unspecified"),w("::1/128","loopback"),w("64:ff9b:1::/48","private"),w("::/8","reserved"),w("100::/64","reserved"),w("2001:db8::/32","documentation"),w("2001::/23","reserved"),w("3fff::/20","documentation"),w("fd00:ec2::254/128","metadata"),w("fc00::/7","unique-local"),w("fe80::/10","link-local"),w("fec0::/10","private"),w("ff00::/8","multicast")],xO=k$("64:ff9b::/96"),fO=k$("2002::/16"),EO=k$("2000::/3");function w$($){let Z=typeof $==="string"?AZ($):$;if(!Z)return{kind:"reserved",range:"not an IP address"};let J=J$(Z);if(J.family===4){let W=HO.find((Y)=>Q1(J,Y.cidr));return W?{kind:W.kind,range:W.text}:null}if(Q1(J,xO))return w$({family:4,bytes:J.bytes.slice(12)});if(Q1(J,fO))return w$({family:4,bytes:J.bytes.slice(2,6)});let j=SO.find((W)=>Q1(J,W.cidr));if(j)return{kind:j.kind,range:j.text};return Q1(J,EO)?null:{kind:"reserved",range:"outside 2000::/3"}}function uj($,Z){let J=J$($),j=J$(Z);return J.family===j.family&&J.bytes.every((W,Y)=>W===j.bytes[Y])}class G0 extends Error{code="safe-fetch";url;constructor($,Z,J){super($,J);this.name=new.target.name,this.url=Z}}class U1 extends G0{reason;code="invalid-url";constructor($,Z,J){super(J,$);this.reason=Z}}class q$ extends G0{host;reason;code="blocked-host";constructor($,Z,J){super(J==="denied"?`Requests to ${Z} are not allowed.`:`${Z} is not on the list of hosts this request may reach.`,$);this.host=Z;this.reason=J}}class b1 extends G0{host;address;range;code="blocked-address";constructor($,Z,J,j){super(Z===J?`${J} is not a public address (${j}).`:`${Z} resolves to ${J}, which is not a public address (${j}).`,$);this.host=Z;this.address=J;this.range=j}}class g$ extends G0{host;code="dns";constructor($,Z,J){super(`Couldn't resolve ${Z}.`,$,{cause:J});this.host=Z}}class y$ extends G0{phase;ms;code="timeout";constructor($,Z,J){super(Z==="connect"?`Couldn't connect within ${J} ms.`:`The request didn't finish within ${J} ms.`,$);this.phase=Z;this.ms=J}}class m$ extends G0{limit;code="too-large";constructor($,Z){super(`The response is larger than ${Z} bytes.`,$);this.limit=Z}}class vZ extends G0{contentType;allowed;code="content-type";constructor($,Z,J){super(`The response is ${Z??"of no content type"}, not ${J.join(" or ")}.`,$);this.contentType=Z;this.allowed=J}}class RZ extends G0{limit;code="too-many-redirects";constructor($,Z){super(`More than ${Z} redirects.`,$);this.limit=Z}}class v1 extends G0{code="network";constructor($,Z){super(`The request failed: ${Z instanceof Error?Z.message:String(Z)}`,$,{cause:Z})}}class kZ extends Response{#W;#Z;address;constructor($,Z,J){super($,Z);this.#W=J.url,this.#Z=J.redirected,this.address=J.address}get url(){return this.#W}get redirected(){return this.#Z}}var wZ={timeout:30000,connectTimeout:1e4,maxSize:10485760,maxRedirects:5,ports:[80,443]},RO=new Set([301,302,303,307,308]),wO=new Set([101,103,204,205,304]),kO=["host","connection","content-length","transfer-encoding","keep-alive","upgrade"],qO=["authorization","cookie","proxy-authorization"];async function nj($,Z={}){let J=gO(Z),j=Z.signal;j?.throwIfAborted();let W=new AbortController,Y=W.signal,z=String($),O=(K)=>{if(!Y.aborted)W.abort(K)},X=setTimeout(()=>O(new y$(z,"total",J.timeout)),J.timeout),F=()=>O(j.reason);j?.addEventListener("abort",F,{once:!0});let G=()=>{clearTimeout(X),j?.removeEventListener("abort",F)};try{let K=sj(z,J),Q=(Z.method??"GET").toUpperCase(),U=new Headers(Z.headers);for(let D of kO)U.delete(D);if(!U.has("accept"))U.set("accept","*/*");if(!U.has("user-agent"))U.set("user-agent","gemi");if(!U.has("accept-encoding"))U.set("accept-encoding","gzip, deflate, br");let B=await hO(Q,Z.body,U);for(let D=0;;D++){z=K.href;let{request:T,response:M,address:L}=await cO(K,Q,U,B,J,Y),C=M.statusCode??0,H=M.headers.location;if(RO.has(C)&&H&&Z.redirect!=="manual"){if(T.destroy(),D>=J.maxRedirects)throw new RZ(K.href,J.maxRedirects);let P;try{P=new URL(H,K)}catch{throw new U1(H,"malformed",`The redirect to "${H}" is not a URL.`)}if(C===303?Q!=="HEAD":(C===301||C===302)&&Q==="POST"){Q="GET",B=null;let _=[];U.forEach((V,N)=>{if(N.startsWith("content-"))_.push(N)});for(let V of _)U.delete(V)}if(P.origin!==K.origin)for(let _ of qO)U.delete(_);K=sj(P.href,J);continue}return lO({url:K,hop:D,method:Q,request:T,response:M,address:L,policy:J,signal:Y,release:G})}}catch(K){throw G(),Y.aborted?Y.reason:K}}function gO($){let Z=(j,W)=>{let Y={hosts:[],ranges:[]};for(let z of j){let O=z.includes("/")||z.includes(":")||/^[\d.]+$/.test(z),X=O?k$(z):null;if(X)Y.ranges.push(X);else if(!O&&/^(\*\.)?[a-z0-9-]+(\.[a-z0-9-]+)*\.?$/i.test(z))Y.hosts.push(aj(z));else throw TypeError(`safeFetch: "${z}" in ${W} is not a host name or an IP range.`)}return Y},J=$.allowPrivate;return{timeout:$.timeout??wZ.timeout,connectTimeout:$.connectTimeout??wZ.connectTimeout,maxSize:$.maxSize??wZ.maxSize,maxRedirects:$.maxRedirects??wZ.maxRedirects,ports:$.ports??wZ.ports,allow:$.allow&&$.allow.length>0?Z($.allow,"allow"):null,deny:Z($.deny??[],"deny"),allowPrivate:J===!0?!0:Z(J||[],"allowPrivate").ranges,contentTypes:$.contentTypes?.length?$.contentTypes:null,resolve:$.resolve??yO}}async function yO($){return(await AO($,{all:!0,verbatim:!0})).map((J)=>J.address)}function aj($){return $.toLowerCase().replace(/\.$/,"")}function ij($,Z){return Z.some((J)=>J.startsWith("*.")?$.endsWith(J.slice(1)):$===J)}function sj($,Z){let J;try{J=new URL($)}catch{throw new U1($,"malformed",`"${$}" is not a URL.`)}if(J.protocol!=="http:"&&J.protocol!=="https:")throw new U1(J.href,"scheme",`Only http and https URLs can be fetched, not ${J.protocol.slice(0,-1)}.`);if(J.username||J.password)throw new U1(J.href,"credentials","The URL has a username or password in it.");let j=oj(J);if(Z.ports!=="any"&&!Z.ports.includes(j))throw new U1(J.href,"port",`Port ${j} is not allowed.`);return J}function oj($){return $.port?Number($.port):$.protocol==="https:"?443:80}async function mO($,Z,J){let j=aj($.hostname.replace(/^\[(.*)\]$/,"$1")),W=AZ(j),Y=W!==null&&(j.includes(":")||/^\d+\.\d+\.\d+\.\d+$/.test(j));if(!Y&&ij(j,Z.deny.hosts))throw new q$($.href,j,"denied");let z=!Y&&Z.allow!==null&&ij(j,Z.allow.hosts);if(Z.allow&&!z&&Z.allow.ranges.length===0)throw new q$($.href,j,"not-allowed");let O;if(Y)O=[W];else{let X;try{X=await pO(Z.resolve(j),J)}catch(F){if(J.aborted)throw J.reason;throw new g$($.href,j,F)}if(O=X.map((F)=>AZ(F)).filter((F)=>F!==null),O.length===0)throw new g$($.href,j)}for(let X of O){let F=bZ(X);if(Z.deny.ranges.some((K)=>Q1(X,K)))throw new b1($.href,j,F,"denied");if(Z.allow&&!z&&!Z.allow.ranges.some((K)=>Q1(X,K)))throw new b1($.href,j,F,"not-allowed");let G=w$(X);if(G&&Z.allowPrivate!==!0&&!Z.allowPrivate.some((K)=>Q1(X,K)))throw new b1($.href,j,F,G.kind)}return{host:j,addresses:O,isLiteral:Y}}function pO($,Z){if(Z.aborted)return Promise.reject(Z.reason);return new Promise((J,j)=>{let W=()=>j(Z.reason);Z.addEventListener("abort",W,{once:!0}),$.then((Y)=>{Z.removeEventListener("abort",W),J(Y)},(Y)=>{Z.removeEventListener("abort",W),j(Y)})})}async function hO($,Z,J){if(Z===void 0||Z===null)return null;if($==="GET"||$==="HEAD")throw TypeError(`safeFetch: a ${$} request can't have a body.`);let j=new Request("http://body.invalid/",{method:"POST",body:Z}),W=j.headers.get("content-type");if(W&&!J.has("content-type"))J.set("content-type",W);return new Uint8Array(await j.arrayBuffer())}async function cO($,Z,J,j,W,Y){let z=new AbortController,O=setTimeout(()=>z.abort(new y$($.href,"connect",W.connectTimeout)),W.connectTimeout),X=AbortSignal.any([Y,z.signal]);try{let{host:F,addresses:G,isLiteral:K}=await mO($,W,X),Q=$.protocol==="https:",U={};if(J.forEach((B,D)=>{U[D]=B}),j)U["content-length"]=String(j.byteLength);return await new Promise((B,D)=>{let T={method:Z,host:F,port:oj($),path:`${$.pathname}${$.search}`,headers:U,agent:!1,lookup:(_,V,N)=>{let x=V?.family,v=G.filter((y)=>!x||y.family===x);if(v.length===0)N(Object.assign(Error(`No IPv${x} address for ${F}`),{code:"ENOTFOUND"}));else if(V?.all)N(null,v.map((y)=>({address:bZ(y),family:y.family})));else N(null,bZ(v[0]),v[0].family)}};if(Q&&!K)T.servername=F;let M=(Q?vO:bO).request(T),L=null,C=(_)=>{X.removeEventListener("abort",H),M.destroy(),D(_)},H=()=>C(X.aborted?X.reason:Y.reason);X.addEventListener("abort",H,{once:!0});let P=(_)=>{let V=_?.remoteAddress;if(!V||L!==null)return!0;let N=AZ(V);if(!N||!G.some((x)=>uj(x,N)))return C(new b1($.href,F,V,"not-allowed")),!1;return L=bZ(J$(N)),!0};M.once("socket",(_)=>{let V=()=>{if(P(_)&&!Q)clearTimeout(O)};if(_.connecting)_.once("connect",V);else V();if(Q)_.once("secureConnect",()=>clearTimeout(O))}),M.once("response",(_)=>{if(clearTimeout(O),_.on("error",()=>{}),!P(_.socket))return;X.removeEventListener("abort",H),B({request:M,response:_,address:L})}),M.on("error",(_)=>{if(X.aborted)return C(X.reason);C(_ instanceof G0?_:new v1($.href,_))}),M.end(j??void 0)})}finally{clearTimeout(O)}}function lO({url:$,hop:Z,method:J,request:j,response:W,address:Y,policy:z,signal:O,release:X}){let F=W.statusCode??0;if(F<200||F>599)throw j.destroy(),new v1($.href,Error(`Unexpected status ${F}`));let G=new Headers,K=W.rawHeaders;for(let V=0;V<K.length;V+=2)G.append(K[V],K[V+1]);if(z.contentTypes){let V=G.get("content-type")?.split(";")[0].trim().toLowerCase()??null;if(!V||!z.contentTypes.some((N)=>dO(V,N)))throw j.destroy(),new vZ($.href,V,z.contentTypes)}let Q={url:$.href,redirected:Z>0,address:Y},U={status:F,statusText:W.statusMessage??"",headers:G};if(J==="HEAD"||wO.has(F))return j.destroy(),X(),new kZ(null,U,Q);let B=G.get("content-encoding")?.trim().toLowerCase(),D=B==="gzip"||B==="x-gzip"?p$.createGunzip():B==="deflate"?p$.createInflate():B==="br"?p$.createBrotliDecompress():null,T=Number(G.get("content-length"));if(!D&&Number.isFinite(T)&&T>z.maxSize)throw j.destroy(),new m$($.href,z.maxSize);if(D)G.delete("content-encoding"),G.delete("content-length");let M=D?W.pipe(D):W,L=0,C=!1,H=()=>{},P=()=>{C=!0,O.removeEventListener("abort",H),X()},_=new ReadableStream({start(V){let N=(v)=>{if(C)return;if(P(),v===void 0)V.close();else j.destroy(),D?.destroy(),V.error(v)};if(H=()=>N(O.reason),O.addEventListener("abort",H,{once:!0}),O.aborted)return H();M.on("data",(v)=>{if(C)return;if(L+=v.byteLength,L>z.maxSize)return N(new m$($.href,z.maxSize));if(V.enqueue(new Uint8Array(v)),(V.desiredSize??1)<=0)M.pause()}),M.once("end",()=>N());let x=(v)=>N(v instanceof G0?v:new v1($.href,v));if(M.on("error",x),D)W.on("error",x);W.once("aborted",()=>N(new v1($.href,Error("The response was cut off."))))},pull(){M.resume()},cancel(){if(C)return;P(),j.destroy(),D?.destroy()}});return new kZ(_,U,Q)}function dO($,Z){let J=Z.toLowerCase();return J.endsWith("/*")?$.startsWith(J.slice(0,-1)):$===J}import{createHmac as rj,randomBytes as uO}from"crypto";var b8="v2.";function v8($){return $.startsWith(b8)}function w3(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function tj($){let Z=uO(16).toString("hex"),J=rj("sha256",w3()).update(`${$}:${Z}`).digest("hex");return`${b8}${J}`}function k3($,Z){let J=rj("sha256",w3()).update(`legacy-session:${Z}:${$}`).digest("hex");return`${b8}${J}`}import{createHash as nO,createHmac as aO,randomInt as oO,timingSafeEqual as ZW}from"crypto";function ej($,Z){return Math.floor($/Z)*Z}function iO($,Z){if(Z<=0)return 0;return Math.min(1,Math.max(0,(Z-$)/Z))}function R8($,Z,J,j){return Z*iO(J,j)+$}function sO($){let{current:Z,previous:J,elapsed:j,window:W,limit:Y,cost:z}=$,O=Y-z;if(O<0)return W;let X=Math.max(0,W-j);if(J>0){let G=W*(1-(O-Z)/J);if(G<=W)return Math.max(0,Math.ceil(G-j))}if(Z<=O)return X;if(Z<=0)return X;let F=W*(1-O/Z);return X+Math.max(0,Math.ceil(F))}function $W($){let{allowed:Z,current:J,previous:j,now:W,elapsed:Y,window:z,limit:O,cost:X}=$;if(Z){let G=R8(J,j,Y,z);return{allowed:!0,limit:O,remaining:Math.max(0,Math.floor(O-G)),resetAt:W-Y+z,retryAfter:0}}let F=sO({current:J,previous:j,elapsed:Y,window:z,limit:O,cost:X});return{allowed:!1,limit:O,remaining:0,resetAt:W+F,retryAfter:F}}class w8{}class k8 extends w8{buckets=new Map;maxKeys;constructor($={}){super();this.maxKeys=Math.max(1,$.maxKeys??1e5)}consume($){let{key:Z,limit:J,window:j}=$,W=$.cost??1,Y=Date.now(),z=ej(Y,j),O=Y-z,X=this.roll(Z,j,z);X.limit=J;let G=R8(X.current,X.previous,O,j)+W<=J;if(G)X.current+=W;if(this.buckets.delete(Z),this.buckets.set(Z,X),this.buckets.size>this.maxKeys)this.evict(Y);return $W({allowed:G,current:X.current,previous:X.previous,now:Y,elapsed:O,window:j,limit:J,cost:W})}clear(){this.buckets.clear()}get size(){return this.buckets.size}roll($,Z,J){let j=this.buckets.get($);if(!j||j.window!==Z)return{window:Z,limit:0,windowStart:J,current:0,previous:0};if(j.windowStart===J)return j;if(j.windowStart+Z===J)return j.previous=j.current,j.current=0,j.windowStart=J,j;return j.previous=0,j.current=0,j.windowStart=J,j}evict($){for(let[j,W]of this.buckets)if($-W.windowStart>=W.window*2)this.buckets.delete(j);let Z=this.maxKeys-Math.floor(this.maxKeys/10);if(this.buckets.size<=Z)return;let J=[...this.buckets].map(([j,W],Y)=>({key:j,order:Y,spent:W.limit>0?(W.current+W.previous)/W.limit:0}));J.sort((j,W)=>j.spent-W.spent||j.order-W.order);for(let{key:j}of J){if(this.buckets.size<=Z)break;this.buckets.delete(j)}}}var WW="h1.";function q3($,Z,J){let j=aO("sha256",w3()).update(`gemi:one-time:${$}:${Z}:${J}`).digest("hex");return`${WW}${j}`}function qZ($,Z,J,j){let W=typeof j==="string"?j:"",Y=typeof J==="string"?J:"",z=Y.startsWith(WW),O=q3($,Z,W),X=Buffer.from(z?O:W),F=Buffer.from(Y);if(X.length!==F.length||W===""||Y==="")return ZW(X,X),!1;return ZW(X,F)}function YW($){let Z="";for(let J=0;J<$;J++)Z+=String(oO(0,10));return Z}var zW=320;function gZ($){if(typeof $!=="string")return null;let Z=$.trim();if(Z===""||Z.length>zW)return null;return Z.toLowerCase()}function q8($){if(typeof $!=="string")return null;let Z=$.trim();if(Z.length>zW)return null;let J=Z.toLowerCase();if(J.length<3||J.length>254||!/^[^\s@]+@[^\s@]+$/.test(J))return null;return J}var JW=null;function OW(){try{let $=I();if(typeof $?.bound==="function"&&$.bound(e0))return $.make(e0)}catch{}return JW??=new e0({driver:new k8,limit:1000,window:60}),JW}function jW($){return $.length<=64?$:`sha256:${nO("sha256").update($).digest("hex")}`}async function h$($,Z,J,j){let W=OW(),Y=[[`auth:code-${$}:ip:${jW(R$(J))}`,j.perIp]];if(Z!==null)Y.push([`auth:code-${$}:email:${jW(Z)}`,j.perEmail]);for(let[z,O]of Y){if(!O)continue;let[X,F]=O,G=await W.consume(z,{limit:X,window:F});if(!G.allowed)throw new EZ(G)}}async function XW($,Z,J,j=10){let W=Math.max(86400,Math.ceil(j*60*(J+1)));return(await OW().consume(`auth:code-attempt:${$}:${Z}`,{limit:J,window:W})).allowed}import{randomBytes as y8}from"crypto";class g8 extends E{schema={name:{string:"Invalid name",required:"Name is required","min:2":"Name must be at least 3 characters"},email:{string:"Invalid email",required:"Email is required",email:"Invalid email"},password:{"min:8":"Password must be at least 9 characters"}}}function g3($,Z,J,j=1/0){if(!Number.isInteger(Z)||Z<J||Z>j){let W=j===1/0?`an integer of at least ${J}`:`an integer from ${J} to ${j}`;throw Error(`auth.emailCode.${$} must be ${W}, got ${Z}`)}}function m8($={}){let Z=$.length??6,J=$.expiresInMinutes??10,j=$.linkExpiresInMinutes??10080,W=$.maxAttempts??5;return g3("length",Z,4,12),g3("expiresInMinutes",J,1),g3("linkExpiresInMinutes",j,1),g3("maxAttempts",W,1),{enabled:$.enabled??!1,createUser:$.createUser??!1,length:Z,expiresInMinutes:J,linkExpiresInMinutes:j,maxAttempts:W,requestLimit:{perEmail:$.requestLimit?.perEmail??[5,900],perIp:$.requestLimit?.perIp??[20,900]},verifyLimit:{perEmail:$.verifyLimit?.perEmail??[10,900],perIp:$.verifyLimit?.perIp??[50,900]},uniformMagicLinkResponse:$.uniformMagicLinkResponse??!1,send:$.send??(({email:Y,code:z})=>{if(Bun.env.NODE_ENV!=="production")console.info(`[gemi] email code for ${Y}: ${z} (set auth.emailCode.send to deliver it)`)})}}async function rO($,Z){if(typeof Z!=="string"||Z==="")return!1;try{return await Bun.password.verify($,Z)}catch{return!1}}function IB($){return $}function FW($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:g8,oauthProviders:{},verifyPassword:rO,hashPassword:async(Z)=>await Bun.password.hash(Z),generateForgotPasswordToken:async()=>y8(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return y8(32).toString("hex")},generateMagicLinkToken:()=>y8(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{},emailCode:m8($.emailCode),generateCode:()=>{return},onAuthenticated:()=>{}}}function p8($){if($&&typeof $==="object")delete $.password;return $}function tO(){return new Proxy({},{get:($,Z)=>KW(Z)})}var GW=new WeakMap;function QW($){if($&&typeof $==="object"){for(let Z of Object.values($))QW(Z);Object.freeze($)}return $}var eO={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}},$X=QW({token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:eO});class h8{models;constructor($=tO()){this.models=$}run($){return this.models.User.asSystem($)}sessionSelect(){return $X}transaction($){return this.models.User.transaction($)}withLegacySessionLock($,Z){let J=this.models.User.$connection??mZ(),j=I(pZ).connection(J),W=()=>this.transaction(async()=>{if(j.dialect==="postgres"){let O=`gemi:legacy-session:${$}`;await yZ()`SELECT pg_advisory_xact_lock(hashtextextended(${O}, 0))`}return Z()});if(j.dialect!=="sqlite"||yZ())return W();let z=(GW.get(j)??Promise.resolve()).then(W,W);return GW.set(j,z.catch(()=>{})),z}async createUser($){let Z=await this.run(()=>this.models.User.create({data:$}));return p8(Z)}async updateUserPassword($){let Z=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return p8(Z)}async findUserByEmailAddress($,Z){return await this.run(()=>this.models.User.findUnique({where:Z?{email:$,emailVerifiedAt:{not:null}}:{email:$}}))}async findUserByVerificationToken($){if(typeof $!=="string"||$==="")return null;return await this.run(()=>this.models.User.findFirst({where:{verificationToken:$}}))}async verifyUser($){return await this.run(()=>this.models.User.update({where:{email:$},data:{emailVerifiedAt:new Date}}))}async createSession($){return await this.run(()=>this.models.Session.create({data:$,include:{user:!0}}))}async createSessionV2($){return await this.run(()=>this.models.Session.create({data:$,select:this.sessionSelect()}))}async findSession($){if(!$.token)return null;try{return await this.run(()=>this.models.Session.findUnique({where:{token:$.token},select:this.sessionSelect()}))}catch(Z){return console.error("findSession failed:",Z),null}}async updateSession($){return await this.run(()=>this.models.Session.update({where:{token:$.token},data:{expiresAt:$.expiresAt},select:this.sessionSelect()}))}async deleteSession($){if(!$.token)return;await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}))}async claimLegacySession($){if(!$.token)return!1;let{count:Z}=await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}));return Z>0}async deleteAllUserSessions($){await this.run(()=>this.models.Session.deleteMany({where:{userId:$}}))}async createPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.create({data:{token:$.token,user:{connect:{id:$.user.id}}}}))}async findPasswordResetToken($){if(typeof $.token!=="string"||$.token==="")return null;return await this.run(()=>this.models.PasswordResetToken.findUnique({where:{token:$.token},include:{user:!0}}))}async deletePasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.delete({where:{token:$.token}}))}async findInvitation($,Z){if(typeof $!=="string"||typeof Z!=="string")return null;return await this.run(()=>this.models.OrganizationInvitation.findFirst({where:{publicId:$,email:Z}}))}async deleteInvitationById($){await this.run(()=>this.models.OrganizationInvitation.delete({where:{publicId:$}}))}async createAccount($){return await this.run(()=>this.models.Account.create({data:{userId:$.userId,organizationId:$.organizationId,organizationRole:$.organizationRole}}))}async createMagicLinkToken($){return await this.run(()=>this.models.MagicLinkToken.create({data:{email:$.email,token:$.token,pin:$.pin}}))}async findUserMagicLinkToken($){let Z=(J)=>typeof J==="string"&&J!=="";if(!Z($.email))return null;if($.token!==void 0&&!Z($.token))return null;if($.token===void 0&&!Z($.pin))return null;return await this.run(()=>$.token?this.models.MagicLinkToken.findUnique({where:{token_email:{token:$.token,email:$.email}}}):this.models.MagicLinkToken.findUnique({where:{pin_email:{pin:$.pin,email:$.email}}}))}async findMagicLinkTokenByEmail($){return await this.run(()=>this.models.MagicLinkToken.findFirst({where:{email:$},orderBy:{id:"desc"}}))}async claimMagicLinkToken($){let{count:Z}=await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{id:$}}));return Z===1}async deleteMagicLinkToken($){await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{email:$}}))}async createSocialAccount($){return await this.run(()=>this.models.SocialAccount.create({data:$}))}async findUserBySocialAccount($,Z){if(!Z)return null;let J=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:Z},include:{user:!0}}));return J?p8(J.user):null}async findSocialAccounts($,Z){return await this.run(()=>this.models.SocialAccount.findMany({where:{userId:$,provider:Z},orderBy:{id:"asc"}}))}async claimSocialAccount($,Z){let{count:J}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:Z}}));return J===1}}import{randomBytes as gG}from"crypto";function f0($,Z,J,j,W){return p0(Z,fW($,Z),J,j,W)}function p0($,Z,J,j,W,Y){let z=i8(Z,J,j);if(W&&Z!==z)throw RangeError(K9($,Z,J,j,Y));return z}function fW($,Z){let J=$[Z];if(J===void 0)throw TypeError(NJ(Z));return J}function X0($){return $!==null&&/object|function/.test(typeof $)}function b0($,Z=Map){let J=new Z;return(j,...W)=>{if(J.has(j))return J.get(j);let Y=$(j,...W);return J.set(j,Y),Y}}function $2($){return z$({name:$},1)}function z$($,Z){return d0((J)=>({value:J,configurable:1,writable:!Z}),$)}function EW($){return d0((Z)=>({get:Z,configurable:1}),$)}function e3($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function n$($,Z){let J={},j=$.length;for(let W of Z)J[$[--j]]=W;return J}function d0($,Z,J){let j={};for(let W in Z)j[W]=$(Z[W],W,J);return j}function aZ($,Z,J){let j={};for(let W=0;W<Z.length;W++){let Y=Z[W];j[Y]=$(Y,W,J)}return j}function ZX($,Z,J){let j={};for(let W=0;W<$.length;W++)j[Z[W]]=J[$[W]];return j}function R0($,Z){let J={};for(let j of $)J[j]=Z[j];return J}function Z2($,Z){let J={};for(let j in Z)$.has(j)||(J[j]=Z[j]);return J}function J2($){$={...$};let Z=Object.keys($);for(let J of Z)$[J]===void 0&&delete $[J];return $}function AW($,Z){for(let J of Z)if(!(J in $))return 0;return 1}function bW($,Z,J){for(let j of $)if(Z[j]!==J[j])return 0;return 1}function vW($,Z,J){let j={...J};for(let W=0;W<Z;W++)j[$[W]]=0;return j}function R($,...Z){return(...J)=>$(...Z,...J)}function UW($){return $[0].toUpperCase()+$.substring(1)}function oZ($){return $.slice().sort()}function d3($,Z){return String(Z).padStart($,"0")}function R1($,Z){return Math.sign($-Z)}function i8($,Z,J){return Math.min(Math.max($,Z),J)}function D1($,Z){return[Math.floor($/Z),cZ($,Z)]}function cZ($,Z){return($%Z+Z)%Z}function q1($,Z){return[$6($,Z),j2($,Z)]}function $6($,Z){return Math.trunc($/Z)||0}function j2($,Z){return $%Z||0}function y3($){return Math.abs($%1)===0.5}function RW($,Z,J){let j=0,W=0;for(let O=0;O<=Z;O++){let X=$[J[O]],F=Z1[O],G=c/F,[K,Q]=q1(X,G);j+=Q*F,W+=K}let[Y,z]=q1(j,c);return[W+Y,z]}function Z6($,Z,J){let j={};for(let W=Z;W>=0;W--){let Y=Z1[W];j[J[W]]=$6($,Y),$=j2($,Y)}return j}function wW($){return $===k?k6:[]}function kW($){return $===k?z3:[]}function qW($){return $===k?["year","day"]:[]}function gW($){if($!==void 0)return a($)}function yW($){if($!==void 0)return u0($)}function W2($){if($!==void 0)return rZ($)}function u0($){return hW(rZ($))}function rZ($){return pW(iX($))}function Y2($){if($==null)throw TypeError("Cannot be null or undefined");return $}function mW($,Z){if(Z==null)throw RangeError(NJ($));return Z}function V1($){if(!X0($))throw TypeError(G9);return $}function J6($,Z,J=$){if(typeof Z!==$)throw TypeError(j3(J,Z));return Z}function pW($,Z="number"){if(!Number.isInteger($))throw RangeError(VX(Z,$));return $||0}function hW($,Z="number"){if($<=0)throw RangeError(MX(Z,$));return $}function z2($){if(typeof $=="symbol")throw TypeError(LX);return String($)}function u3($,Z){return X0($)?String($):a($,Z)}function j6($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(NX($));return $}function cW($,Z="number"){if(typeof $=="bigint")throw TypeError(IX(Z));if($=Number($),!Number.isFinite($))throw RangeError(CX(Z,$));return $}function C0($,Z){return Math.trunc(cW($,Z))||0}function lW($,Z){return pW(cW($,Z),Z)}function BW($,Z){return hW(C0($,Z),Z)}function O2($,Z){let[J,j]=q1(Z,c),W=$+J,Y=Math.sign(W);return Y&&Y===-Math.sign(j)&&(W-=Y,j+=Y*c),[W,j]}function l$($,Z,J=1){return O2($[0]+Z[0]*J,$[1]+Z[1]*J)}function d$($,Z){return O2($[0],$[1]+Z)}function g0($,Z){return l$(Z,$,-1)}function N0($,Z){return R1($[0],Z[0])||R1($[1],Z[1])}function dW($,Z,J){return N0($,Z)===-1||N0($,J)===1}function W6($,Z=1){let J=BigInt(c/Z);return[Number($/J),Number($%J)*Z]}function u$($,Z=1){let J=c/Z,[j,W]=q1($,J);return[j,W*Z]}function uW($,Z=1){let[J,j]=$,W=Math.floor(j/Z),Y=c/Z;return BigInt(J)*BigInt(Y)+BigInt(W)}function y0($,Z=1,J){let[j,W]=$,[Y,z]=q1(W,Z);return j*(c/Z)+(Y+(J?z/Z:0))}function X2($,Z,J=D1){let[j,W]=$,[Y,z]=J(W,Z);return[j*(c/Z)+Y,z]}function F2($,Z){let J=$.formatToParts(Z),j={};for(let W of J)j[W.type]=W.value;return j}function G2($){return f0($,"isoYear",nZ,sZ,1),$.isoYear===nZ?f0($,"isoMonth",4,12,1):$.isoYear===sZ&&f0($,"isoMonth",1,9,1),$}function w1($){return M1({...$,...l0,isoHour:12}),$}function M1($){let Z=f0($,"isoYear",nZ,sZ,1),J=Z===nZ?1:Z===sZ?-1:0;return J&&m0(I0({...$,isoDay:$.isoDay+J,isoNanosecond:$.isoNanosecond-J})),$}function m0($){if(!$||dW($,eX,tX))throw RangeError(b6);return $}function g1($){return RW($,5,a0)[1]}function Y6($){let[Z,J]=D1($,c);return[Z6(J,5,a0),Z]}function iW($){return sW($)[0]}function sW($){return X2($,c0)}function L0($){return a$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function I0($){let Z=L0($);if(Z!==void 0){let[J,j]=q1(Z,A0);return[J,j*J1+($.isoMicrosecond||0)*D$+($.isoNanosecond||0)]}}function K2($,Z){let[J,j]=Y6(g1($)-Z);return m0(I0({...$,isoDay:$.isoDay+j,...J}))}function i3(...$){return a$(...$)/L9}function a$(...$){let[Z,J]=nW(...$),j=Z.valueOf();if(!isNaN(j))return j-J*A0}function nW($,Z=1,J=1,j=0,W=0,Y=0,z=0){let O=$===nZ?1:$===sZ?-1:0,X=new Date;return X.setUTCHours(j,W,Y,z),X.setUTCFullYear($,Z-1,J+O),[X,O]}function m1($,Z){let[J,j]=d$($,Z);j<0&&(j+=c,J-=1);let[W,Y]=D1(j,J1),[z,O]=D1(Y,D$);return z6(J*A0+W,z,O)}function z6($,Z=0,J=0){let j=Math.ceil(Math.max(0,Math.abs($)-rX)/A0)*Math.sign($),W=new Date($-j*A0);return n$(g6,[W.getUTCFullYear(),W.getUTCMonth()+1,W.getUTCDate()+j,W.getUTCHours(),W.getUTCMinutes(),W.getUTCSeconds(),W.getUTCMilliseconds(),Z,J])}function aW($){return[$.isoYear,$.isoMonth,$.isoDay]}function oW(){return B1}function Q2($,Z){switch(Z){case 2:return U2($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function rW($){return U2($)?366:365}function U2($){return $%4==0&&($%100!=0||$%400==0)}function tW($){let[Z,J]=nW($.isoYear,$.isoMonth,$.isoDay);return cZ(Z.getUTCDay()-J,7)||7}function eW({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function JX($){let Z=L0($);if(Z<ZF)return eW($);let J=F2(mJ(i$),Z),{era:j,eraYear:W}=Gz(J,i$);return[j,W]}function O6($){return O$($),X6($,1),$}function O$($){return $Y($,1),$}function DW($){return bW(bJ,$,$Y($))}function $Y($,Z){let{isoYear:J}=$,j=f0($,"isoMonth",1,oW(),Z);return{isoYear:J,isoMonth:j,isoDay:f0($,"isoDay",1,Q2(J,j),Z)}}function X6($,Z){return n$(a0,[f0($,"isoHour",0,23,Z),f0($,"isoMinute",0,59,Z),f0($,"isoSecond",0,59,Z),f0($,"isoMillisecond",0,999,Z),f0($,"isoMicrosecond",0,999,Z),f0($,"isoNanosecond",0,999,Z)])}function q($){return $===void 0?0:m9(V1($))}function tZ($,Z=0){$=i0($);let J=p9($),j=KF($,Z);return[m9($),j,J]}function B2($){return p9(i0($))}function ZY($){return $=i0($),wJ($,9,6,1)}function o$($,Z,J,j=9,W=0,Y=4){Z=i0(Z);let z=wJ(Z,j,W),O=V2(Z),X=X3(Z,Y),F=O3(Z,j,W,1);return z==null?z=Math.max(J,F):YY(z,F),O=M2(O,F,1),$&&(X=((G)=>G<4?(G+2)%4:G)(X)),[z,F,O,X]}function F6($,Z=6,J){let j=V2($=C2($,t3)),W=X3($,7),Y=O3($,Z);return Y=mW(t3,Y),j=M2(j,Y,void 0,J),[Y,j,W]}function D2($){return kJ(i0($))}function JY($,Z){return T2(i0($),Z)}function T2($,Z=4){let J=WY($);return[X3($,4),...jY(O3($,Z),J)]}function jY($,Z){return $!=null?[Z1[$],$<4?9-3*$:-1]:[Z===void 0?1:10**(9-Z),Z]}function V2($){let Z=$[lZ];return Z===void 0?1:C0(Z,lZ)}function M2($,Z,J,j){let W=j?c:Z1[Z+1];if(W){let Y=Z1[Z];if(W%(($=p0(lZ,$,1,W/Y-(j?0:1),1))*Y))throw RangeError(j3(lZ,$))}else $=p0(lZ,$,1,J?1e9:1,1);return $}function WY($){let Z=$[u8];if(Z!==void 0){if(typeof Z!="number"){if(z2(Z)==="auto")return;throw RangeError(j3(u8,Z))}Z=p0(u8,Math.floor(Z),0,9,1)}return Z}function i0($){return $===void 0?{}:V1($)}function C2($,Z){return typeof $=="string"?{[Z]:$}:V1($)}function Z0($){if($!==void 0){if(X0($))return Object.assign(Object.create(null),$);throw TypeError(G9)}}function G6($,Z){return $&&Object.assign(Object.create(null),$,{overflow:jF[Z]})}function I2($,Z,J=9,j=0,W){let Y=Z[$];if(Y===void 0)return W?j:void 0;if(Y=z2(Y),Y==="auto")return W?j:null;let z=o8[Y];if(z===void 0&&(z=aX[Y]),z===void 0)throw RangeError(B9($,Y,o8));return p0($,z,j,J,1,Y3),z}function X$($,Z,J,j=0){let W=J[$];if(W===void 0)return j;let Y=z2(W),z=Z[Y];if(z===void 0)throw RangeError(B9($,Y,Z));return z}function YY($,Z){if(Z>$)throw RangeError(hX)}function F0($){return{branding:m6,epochNanoseconds:$}}function U0($,Z,J){return{branding:L1,calendar:J,timeZone:Z,epochNanoseconds:$}}function J0($,Z=$.calendar){return{branding:V$,calendar:Z,...R0(k9,$)}}function j0($,Z=$.calendar){return{branding:T$,calendar:Z,...R0(vJ,$)}}function W$($,Z=$.calendar){return{branding:WZ,calendar:Z,...R0(vJ,$)}}function s3($,Z=$.calendar){return{branding:YZ,calendar:Z,...R0(vJ,$)}}function s0($){return{branding:y6,...R0(w9,$)}}function i($){return{branding:p6,sign:p1($),...R0(fJ,$)}}function zY($){return iW($.epochNanoseconds)}function K6($){return X2($.epochNanoseconds,J1)[0]}function OY($){return uW($.epochNanoseconds,D$)}function XY($){return uW($.epochNanoseconds)}function FY($){return $.epochNanoseconds}function K0($){return typeof $=="string"?$:a($.id)}function r$($,Z){return $===Z||K0($)===K0(Z)}function GY($,Z,J,j,W){let Y=Y$(j),[z,O]=((T,M)=>{let L=M((T=C2(T,e8))[g9]),C=GF(T);return C=mW(e8,C),[C,L]})(W,$);if(uZ(Math.max(z,Y),O))return TW(j,z);if(!O)throw RangeError(v6);let[X,F,G]=V6(Z,J,O),K=d2(G),Q=M6(G),U=u2(G),B=Q(F,X,j),D=U(F,X,B,z);return uZ(z,O)?TW(D,z):((T,M,L,C,H,P,_)=>{let V=p1(T),[N,x]=N2(C,AJ(L,T),L,V,H,P,_),v=L2(M,N,x);return T[g[L]]+v*V})(D,K(B),z,F,X,K,Q)}function TW($,Z){return y0(O0($),Z1[Z],1)}function N2($,Z,J,j,W,Y,z){let O=g[J],X={...Z,[O]:Z[O]+j},F=z($,W,Z),G=z($,W,X);return[Y(F),Y(G)]}function L2($,Z,J){let j=y0(g0(Z,J));if(!j)throw RangeError(W3);return y0(g0(Z,$))/j}function KY($,Z){let[J,j,W]=F6(Z,5,1);return F0(U6($.epochNanoseconds,J,j,W,1))}function QY($,Z,J){let{epochNanoseconds:j,timeZone:W,calendar:Y}=Z,[z,O,X]=F6(J);if(z===0&&O===1)return Z;let F=$(W);if(z===6)j=((G,K,Q,U)=>{let B=_0(Q,K),[D,T]=G(B),M=Q.epochNanoseconds,L=v0(K,D),C=v0(K,T);if(dW(M,L,C))throw RangeError(W3);return NY(L2(M,L,C),U)?C:L})(CY,F,Z,X);else{let G=F.getOffsetNanosecondsFor(j);j=G$(F,VY(m1(j,G),z,O,X),G,2,0,1)}return U0(j,W,Y)}function UY($,Z){return J0(VY($,...F6(Z)),$.calendar)}function BY($,Z){let[J,j,W]=F6(Z,5);var Y;return s0((Y=W,_2($,eZ(J,j),Y)[0]))}function DY($,Z){let J=$(Z.timeZone),j=_0(Z,J),[W,Y]=CY(j),z=y0(g0(v0(J,W),v0(J,Y)),w6,1);if(z<=0)throw RangeError(W3);return z}function TY($,Z){let{timeZone:J,calendar:j}=Z,W=((Y,z,O)=>v0(z,Y(_0(O,z))))(IY,$(J),Z);return U0(W,J,j)}function VY($,Z,J,j){return MY($,eZ(Z,J),j)}function MY($,Z,J){let[j,W]=_2($,Z,J);return M1({...K$($,W),...j})}function _2($,Z,J){return Y6(y1(g1($),Z,J))}function n3($){return y1($,R6,7)}function eZ($,Z){return Z1[$]*Z}function CY($){let Z=IY($);return[Z,K$(Z,1)]}function IY($){return oX(6,$)}function jX($,Z,J){let j=Math.min(Y$($),6);return e$(B6(O0($,j),Z,J),j)}function Q6($,Z,J,j,W,Y,z,O,X,F){if(j===0&&W===1)return $;let G=uZ(j,O)?C6(O)&&j<6&&J>=6?YX:WX:zX,[K,Q,U]=G($,Z,J,j,W,Y,z,O,X,F);return U&&j!==7&&(K=((B,D,T,M,L,C,H,P)=>{let _=p1(B);for(let V=M+1;V<=T;V++){if(V===7&&T!==7)continue;let N=AJ(V,B);N[g[V]]+=_;let x=y0(g0(H(P(L,C,N)),D));if(x&&Math.sign(x)!==_)break;B=N}return B})(K,Q,J,Math.max(6,j),z,O,X,F)),K}function U6($,Z,J,j,W){if(Z===6){let Y=((z)=>z[0]+z[1]/c)($);return[y1(Y,J,j),0]}return B6($,eZ(Z,J),j,W)}function B6($,Z,J,j){let[W,Y]=$;j&&Y<0&&(Y+=c,W-=1);let[z,O]=D1(y1(Y,Z,J),c);return O2(W+z,O)}function y1($,Z,J){return NY($/Z,J)*Z}function NY($,Z){return BF[Z]($)}function WX($,Z,J,j,W,Y){let z=p1($),O=O0($),X=U6(O,j,W,Y),F=g0(O,X),G=Math.sign(X[0]-O[0])===z,K=e$(X,Math.min(J,6));return[{...$,...K},l$(Z,F),G]}function YX($,Z,J,j,W,Y,z,O,X,F){let G=p1($),K=y0(O0($,5)),Q=eZ(j,W),U=y1(K,Q,Y),[B,D]=N2(z,{...$,...EJ},6,G,O,X,F),T=U-y0(g0(B,D)),M=0;T&&Math.sign(T)!==G?Z=d$(B,U):(M+=G,U=y1(T,Q,Y),Z=d$(D,U));let L=N6(U);return[{...$,...L,days:$.days+M},Z,Boolean(M)]}function zX($,Z,J,j,W,Y,z,O,X,F){let G=p1($),K=g[j],Q=AJ(j,$);j===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let U=$6($[K],W)*W;Q[K]=U;let[B,D]=N2(z,Q,j,W*G,O,X,F),T=U+L2(Z,B,D)*G*W,M=y1(T,W,Y),L=Math.sign(M-T)===G;return Q[K]=M,[Q,L?D:B,L]}function P2($,Z,J,j){let[W,Y,z,O]=((F)=>{let G=T2(F=i0(F));return[F.timeZone,...G]})(j),X=W!==void 0;return((F,G,K,Q,U,B)=>{K=B6(K,U,Q,1);let D=G.getOffsetNanosecondsFor(K);return b2(m1(K,D),B)+(F?F$(n3(D)):"Z")})(X,Z(X?$(W):M$),J.epochNanoseconds,Y,z,O)}function H2($,Z,J){let[j,W,Y,z,O,X]=((F)=>{F=i0(F);let G=kJ(F),K=WY(F),Q=UF(F),U=X3(F,4),B=O3(F,4);return[G,QF(F),Q,U,...jY(B,K)]})(J);return((F,G,K,Q,U,B,D,T,M,L)=>{Q=B6(Q,M,T,1);let C=F(K).getOffsetNanosecondsFor(Q);return b2(m1(Q,C),L)+F$(n3(C),D)+((H,P)=>P!==1?"["+(P===2?"!":"")+K0(H)+"]":"")(K,B)+v2(G,U)})($,Z.calendar,Z.timeZone,Z.epochNanoseconds,j,W,Y,z,O,X)}function S2($,Z){let[J,j,W,Y]=((F)=>(F=i0(F),[kJ(F),...T2(F)]))(Z);return z=$.calendar,O=J,X=Y,b2(MY($,W,j),X)+v2(z,O);var z,O,X}function x2($,Z){return J=$.calendar,j=$,W=D2(Z),a3(j)+v2(J,W);var J,j,W}function f2($,Z){return LY($.calendar,_Y,$,D2(Z))}function E2($,Z){return LY($.calendar,OX,$,D2(Z))}function A2($,Z){let[J,j,W]=JY(Z);return Y=W,PY(_2($,j,J)[0],Y);var Y}function D6($,Z){let[J,j,W]=JY(Z,3);return j>1&&($={...$,...jX($,j,J)}),((Y,z)=>{let{sign:O}=Y,X=O===-1?P0(Y):Y,{hours:F,minutes:G}=X,[K,Q]=X2(O0(X,3),c0,q1);vY(K);let U=R2(Q,z),B=z>=0||!O||U;return(O<0?"-":"")+"P"+VW({Y:j$(X.years),M:j$(X.months),W:j$(X.weeks),D:j$(X.days)})+(F||G||K||B?"T"+VW({H:j$(F),M:j$(G),S:j$(K,B)+U}):"")})($,W)}function LY($,Z,J,j){let W=K0($),Y=j>1||j===0&&W!==k;return j===1?W===k?Z(J):a3(J):Y?a3(J)+HY(W,j===2):Z(J)}function VW($){let Z=[];for(let J in $){let j=$[J];j&&Z.push(j,J)}return Z.join("")}function b2($,Z){return a3($)+"T"+PY($,Z)}function a3($){return _Y($)+"-"+h0($.isoDay)}function _Y($){let{isoYear:Z}=$;return(Z<0||Z>9999?SY(Z)+d3(6,Math.abs(Z)):d3(4,Z))+"-"+h0($.isoMonth)}function OX($){return h0($.isoMonth)+"-"+h0($.isoDay)}function PY($,Z){let J=[h0($.isoHour),h0($.isoMinute)];return Z!==-1&&J.push(h0($.isoSecond)+((j,W,Y,z)=>R2(j*J1+W*D$+Y,z))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,Z)),J.join(":")}function F$($,Z=0){if(Z===1)return"";let[J,j]=D1(Math.abs($),w6),[W,Y]=D1(j,R6),[z,O]=D1(Y,c0);return SY($)+h0(J)+":"+h0(W)+(z||O?":"+h0(z)+R2(O):"")}function v2($,Z){if(Z!==1){let J=K0($);if(Z>1||Z===0&&J!==k)return HY(J,Z===2)}return""}function HY($,Z){return"["+(Z?"!":"")+"u-ca="+$+"]"}function R2($,Z){let J=d3(9,$);return J=Z===void 0?J.replace(VF,""):J.slice(0,Z),J?"."+J:""}function SY($){return $<0?"-":"+"}function j$($,Z){return $||Z?$.toLocaleString("fullwide",{useGrouping:0}):""}function XX($,Z){let{epochNanoseconds:J}=$,j=(Z.getOffsetNanosecondsFor?Z:Z($.timeZone)).getOffsetNanosecondsFor(J),W=m1(J,j);return{calendar:$.calendar,...W,offsetNanoseconds:j}}function xY($,Z){let J=_0(Z,$);return{calendar:Z.calendar,...R0(k9,J),offset:F$(J.offsetNanoseconds),timeZone:Z.timeZone}}function G$($,Z,J,j=0,W=0,Y,z){if(J!==void 0&&j===1&&(j===1||z))return K2(Z,J);let O=$.getPossibleInstantsFor(Z);if(J!==void 0&&j!==3){let X=((F,G,K,Q)=>{let U=I0(G);Q&&(K=n3(K));for(let B of F){let D=y0(g0(B,U));if(Q&&(D=n3(D)),D===K)return B}})(O,Z,J,Y);if(X!==void 0)return X;if(j===0)throw RangeError(kX)}return z?I0(Z):v0($,Z,W,O)}function v0($,Z,J=0,j=$.getPossibleInstantsFor(Z)){if(j.length===1)return j[0];if(J===1)throw RangeError(qX);if(j.length)return j[J===3?1:0];let W=I0(Z),Y=((O,X)=>{let F=O.getOffsetNanosecondsFor(d$(X,-c));return k2(O.getOffsetNanosecondsFor(d$(X,c))-F)})($,W),z=Y*(J===2?-1:1);return(j=$.getPossibleInstantsFor(m1(W,z)))[J===2?0:j.length-1]}function w2($){if(Math.abs($)>=c)throw RangeError(RX);return $}function k2($){if($>c)throw RangeError(wX);return $}function q2($,Z,J){return F0(m0(l$(Z.epochNanoseconds,((j)=>{if(RY(j))throw RangeError(mX);return O0(j,5)})($?P0(J):J))))}function g2($,Z,J,j,W,Y=Object.create(null)){let z=Z(j.timeZone),O=$(j.calendar);return{...j,...c2(z,O,j,J?P0(W):W,Y)}}function y2($,Z,J,j,W=Object.create(null)){let{calendar:Y}=J;return J0(l2($(Y),J,Z?P0(j):j,W),Y)}function m2($,Z,J,j,W){let{calendar:Y}=J;return j0(T6($(Y),J,Z?P0(j):j,W),Y)}function p2($,Z,J,j,W=Object.create(null)){let Y=J.calendar,z=$(Y),O=dZ(z,J);Z&&(j=I6(j)),j.sign<0&&(O=z.dateAdd(O,{...Q0,months:1}),O=K$(O,-1));let X=z.dateAdd(O,j,W);return W$(dZ(z,X),Y)}function h2($,Z,J){return s0(fY(Z,$?P0(J):J)[0])}function c2($,Z,J,j,W){let Y=O0(j,5),z=J.epochNanoseconds;if(RY(j)){let O=_0(J,$);z=l$(v0($,{...T6(Z,O,{...j,...EJ},W),...R0(a0,O)}),Y)}else z=l$(z,Y),q(W);return{epochNanoseconds:m0(z)}}function l2($,Z,J,j){let[W,Y]=fY(Z,J);return M1({...T6($,Z,{...J,...EJ,days:J.days+Y},j),...W})}function T6($,Z,J,j){if(J.years||J.months||J.weeks)return $.dateAdd(Z,J,j);q(j);let W=J.days+O0(J,5)[0];return W?w1(K$(Z,W)):Z}function dZ($,Z,J=1){return K$(Z,J-$.day(Z))}function fY($,Z){let[J,j]=O0(Z,5),[W,Y]=Y6(g1($)+j);return[W,J+Y]}function K$($,Z){return Z?{...$,...z6(L0($)+Z*A0)}:$}function V6($,Z,J){let j=$(J.calendar);return C6(J)?[J,j,Z(J.timeZone)]:[{...J,...l0},j]}function d2($){return $?FY:I0}function M6($){return $?R(c2,$):l2}function u2($){return $?R(GX,$):KX}function C6($){return $&&$.epochNanoseconds}function uZ($,Z){return $<=6-(C6(Z)?1:0)}function i2($,Z,J,j,W,Y,z){let O=$(i0(z).relativeTo),X=Math.max(Y$(W),Y$(Y));if(uZ(X,O))return i(t$(((D,T,M,L)=>{let C=l$(O0(D),O0(T),L?-1:1);if(!Number.isFinite(C[0]))throw RangeError(b6);return{...Q0,...e$(C,M)}})(W,Y,X,j)));if(!O)throw RangeError(v6);j&&(Y=P0(Y));let[F,G,K]=V6(Z,J,O),Q=M6(K),U=u2(K),B=Q(G,F,W);return i(U(G,F,Q(G,B,Y),X))}function EY($,Z,J,j,W){let Y=Y$(j),[z,O,X,F,G]=((_,V,N)=>{_=C2(_,t3);let x=wJ(_),v=N(_[g9]),y=V2(_),r0=X3(_,7),m=O3(_);if(x===void 0&&m===void 0)throw RangeError(pX);return m==null&&(m=0),x==null&&(x=Math.max(m,V)),YY(x,m),y=M2(y,m,1),[x,m,y,r0,v]})(W,Y,$),K=Math.max(Y,z);if(!C6(G)&&K<=6)return i(t$(((_,V,N,x,v)=>{let y=U6(O0(_),N,x,v);return{...Q0,...e$(y,V)}})(j,z,O,X,F)));if(!G)throw RangeError(v6);let[Q,U,B]=V6(Z,J,G),D=d2(B),T=M6(B),M=u2(B),L=T(U,Q,j),C=M(U,Q,L,z),H=j.sign,P=p1(C);if(H&&P&&H!==P)throw RangeError(W3);return P&&(C=Q6(C,D(L),z,O,X,F,U,Q,D,T)),i(C)}function AY($){return $.sign===-1?I6($):$}function I6($){return i(P0($))}function P0($){let Z={};for(let J of g)Z[J]=-1*$[J]||0;return Z}function bY($){return!$.sign}function p1($,Z=g){let J=0;for(let j of Z){let W=Math.sign($[j]);if(W){if(J&&J!==W)throw RangeError(yX);J=W}}return J}function t$($){for(let Z of nX)p0(Z,$[Z],-PW,PW,1);return vY(y0(O0($),c0)),$}function vY($){if(!Number.isSafeInteger($))throw RangeError(gX)}function O0($,Z=6){return RW($,Z,g)}function e$($,Z=6){let[J,j]=$,W=Z6(j,Z,g);if(W[g[Z]]+=J*(c/Z1[Z]),!Number.isFinite(W[g[Z]]))throw RangeError(b6);return W}function N6($,Z=5){return Z6($,Z,g)}function RY($){return Boolean(p1($,R9))}function Y$($){let Z=9;for(;Z>0&&!$[g[Z]];Z--);return Z}function FX($,Z){return[$,Z]}function MW($){let Z=Math.floor($/c3)*c3;return[Z,Z+c3]}function wY($){let Z=h1($=u3($));if(!Z)throw RangeError(E0($));let J;if(Z.m)J=0;else{if(!Z.offset)throw RangeError(E0($));J=$Z(Z.offset)}return Z.timeZone&&o2(Z.timeZone,1),F0(K2(O6(Z),J))}function kY($){let Z=h1(a($));if(!Z)throw RangeError(E0($));if(Z.timeZone)return dY(Z,Z.offset?$Z(Z.offset):void 0);if(Z.m)throw RangeError(E0($));return iY(Z)}function qY($,Z){let J=h1(a($));if(!J||!J.timeZone)throw RangeError(E0($));let{offset:j}=J,W=j?$Z(j):void 0,[,Y,z]=tZ(Z);return dY(J,W,Y,z)}function $Z($){let Z=o2($);if(Z===void 0)throw RangeError(E0($));return Z}function gY($){let Z=h1(a($));if(!Z||Z.m)throw RangeError(E0($));return J0(uY(Z))}function L6($){let Z=h1(a($));if(!Z||Z.m)throw RangeError(E0($));return j0(Z.p?uY(Z):iY(Z))}function yY($,Z){let J=n2(a(Z));if(J)return s2(J),W$(G2(O$(J)));let j=L6(Z);return W$(dZ($(j.calendar),j))}function s2($){if($.calendar!==k)throw RangeError(T1($.calendar))}function mY($,Z){let J=a2(a(Z));if(J)return s2(J),s3(O$(J));let j=L6(Z),{calendar:W}=j,Y=$(W),[z,O,X]=Y.h(j),[F,G]=Y.I(z,O),[K,Q]=Y.N(F,G,X);return s3(w1(Y.P(K,Q,X)),W)}function pY($){let Z,J=((j)=>{let W=LF.exec(j);return W?(_6(W[10]),aY(W)):void 0})(a($));if(!J){if(J=h1($),!J)throw RangeError(E0($));if(!J.p)throw RangeError(E0($));if(J.m)throw RangeError(T1("Z"));s2(J)}if((Z=n2($))&&DW(Z))throw RangeError(E0($));if((Z=a2($))&&DW(Z))throw RangeError(E0($));return s0(X6(J,1))}function hY($){let Z=((J)=>{let j=HF.exec(J);return j?((W)=>{function Y(G,K,Q){let U=0,B=0;if(Q&&([U,X]=D1(X,Z1[Q])),G!==void 0){if(O)throw RangeError(T1(G));B=((D)=>{let T=parseInt(D);if(!Number.isFinite(T))throw RangeError(T1(D));return T})(G),z=1,K&&(X=r2(K)*(Z1[Q]/c0),O=1)}return U+B}let z=0,O=0,X=0,F={...n$(g,[Y(W[2]),Y(W[3]),Y(W[4]),Y(W[5]),Y(W[6],W[7],5),Y(W[8],W[9],4),Y(W[10],W[11],3)]),...Z6(X,2,g)};if(!z)throw RangeError(Q9(g));return t2(W[1])<0&&(F=P0(F)),F})(j):void 0})(a($));if(!Z)throw RangeError(E0($));return i(t$(Z))}function cY($){let Z=h1($)||n2($)||a2($);return Z?Z.calendar:$}function lY($){let Z=h1($);return Z&&(Z.timeZone||Z.m&&M$||Z.offset)||$}function dY($,Z,J=0,j=0){let W=P6($.timeZone),Y=h6(W);return U0(G$(Y,O6($),Z,J,j,!Y.v,$.m),W,$3($.calendar))}function uY($){return sY(M1(O6($)))}function iY($){return sY(w1(O$($)))}function sY($){return{...$,calendar:$3($.calendar)}}function h1($){let Z=NF.exec($);return Z?((J)=>{let j=J[10],W=(j||"").toUpperCase()==="Z";return{isoYear:nY(J),isoMonth:parseInt(J[4]),isoDay:parseInt(J[5]),...aY(J.slice(5)),..._6(J[16]),p:Boolean(J[6]),m:W,offset:W?void 0:j}})(Z):void 0}function n2($){let Z=CF.exec($);return Z?((J)=>({isoYear:nY(J),isoMonth:parseInt(J[4]),isoDay:1,..._6(J[5])}))(Z):void 0}function a2($){let Z=IF.exec($);return Z?((J)=>({isoYear:s$,isoMonth:parseInt(J[1]),isoDay:parseInt(J[2]),..._6(J[3])}))(Z):void 0}function o2($,Z){let J=_F.exec($);return J?((j,W)=>{let Y=j[4]||j[5];if(W&&Y)throw RangeError(T1(Y));return w2((c$(j[2])*w6+c$(j[3])*R6+c$(j[4])*c0+r2(j[5]||""))*t2(j[1]))})(J,Z):void 0}function nY($){let Z=t2($[1]),J=parseInt($[2]||$[3]);if(Z<0&&!J)throw RangeError(T1(-0));return Z*J}function aY($){let Z=c$($[3]);return{...Y6(r2($[4]||""))[0],isoHour:c$($[1]),isoMinute:c$($[2]),isoSecond:Z===60?59:Z}}function _6($){let Z,J,j=[];if($.replace(PF,(W,Y,z)=>{let O=Boolean(Y),[X,F]=z.split("=").reverse();if(F){if(F==="u-ca")j.push(X),Z||(Z=O);else if(O||/[A-Z]/.test(F))throw RangeError(T1(W))}else{if(J)throw RangeError(T1(W));J=X}return""}),j.length>1&&Z)throw RangeError(T1($));return{timeZone:J,calendar:j[0]||k}}function r2($){return parseInt($.padEnd(9,"0"))}function ZZ($){return new RegExp(`^${$}$`,"i")}function t2($){return $&&$!=="+"?-1:1}function c$($){return $===void 0?0:parseInt($)}function oY($){return P6(a($))}function P6($){let Z=e2($);return typeof Z=="number"?F$(Z):Z?((J)=>{if(xF.test(J))throw RangeError(vX);return J.toLowerCase().split("/").map((j,W)=>(j.length<=3||/\d/.test(j))&&!/etc|yap/.test(j)?j.toUpperCase():j.replace(/baja|dumont|[a-z]+/g,(Y,z)=>Y.length<=2&&!W||Y==="in"||Y==="chat"?Y.toUpperCase():Y.length>2||!z?UW(Y).replace(/island|noronha|murdo|rivadavia|urville/,UW):Y)).join("/")})($):M$}function CW($){let Z=e2($);return typeof Z=="number"?Z:Z?Z.resolvedOptions().timeZone:M$}function e2($){let Z=o2($=$.toUpperCase(),1);return Z!==void 0?Z:$!==M$?SF($):void 0}function $J($,Z){return N0($.epochNanoseconds,Z.epochNanoseconds)}function ZJ($,Z){return N0($.epochNanoseconds,Z.epochNanoseconds)}function rY($,Z,J,j,W,Y){let z=$(i0(Y).relativeTo),O=Math.max(Y$(j),Y$(W));if(bW(g,j,W))return 0;if(uZ(O,z))return N0(O0(j),O0(W));if(!z)throw RangeError(v6);let[X,F,G]=V6(Z,J,z),K=d2(G),Q=M6(G);return N0(K(Q(F,X,j)),K(Q(F,X,W)))}function JJ($,Z){return Q$($,Z)||H6($,Z)}function Q$($,Z){return R1(L0($),L0(Z))}function H6($,Z){return R1(g1($),g1(Z))}function tY($,Z){return!$J($,Z)}function eY($,Z){return!ZJ($,Z)&&!!S6($.timeZone,Z.timeZone)&&r$($.calendar,Z.calendar)}function $z($,Z){return!JJ($,Z)&&r$($.calendar,Z.calendar)}function Zz($,Z){return!Q$($,Z)&&r$($.calendar,Z.calendar)}function Jz($,Z){return!Q$($,Z)&&r$($.calendar,Z.calendar)}function jz($,Z){return!Q$($,Z)&&r$($.calendar,Z.calendar)}function Wz($,Z){return!H6($,Z)}function S6($,Z){if($===Z)return 1;let J=K0($),j=K0(Z);if(J===j)return 1;try{return CW(J)===CW(j)}catch(W){}}function jJ($,Z,J,j){let W=o$($,Z0(j),3,5),Y=x6(Z.epochNanoseconds,J.epochNanoseconds,...W);return i($?P0(Y):Y)}function WJ($,Z,J,j,W,Y){let z=E6(j.calendar,W.calendar),O=Z0(Y),[X,F,G,K]=o$(J,O,5),Q=j.epochNanoseconds,U=W.epochNanoseconds,B=N0(U,Q),D;if(B)if(X<6)D=x6(Q,U,X,F,G,K);else{let T=Z(((L,C)=>{if(!S6(L,C))throw RangeError(M9);return L})(j.timeZone,W.timeZone)),M=$(z);D=zz(M,T,j,W,B,X,O),D=Q6(D,U,X,F,G,K,M,j,FY,R(c2,T))}else D=Q0;return i(J?P0(D):D)}function YJ($,Z,J,j,W){let Y=E6(J.calendar,j.calendar),z=Z0(W),[O,X,F,G]=o$(Z,z,6),K=I0(J),Q=I0(j),U=N0(Q,K),B;if(U)if(O<=6)B=x6(K,Q,O,X,F,G);else{let D=$(Y);B=Oz(D,J,j,U,O,z),B=Q6(B,Q,O,X,F,G,D,J,I0,l2)}else B=Q0;return i(Z?P0(B):B)}function zJ($,Z,J,j,W){let Y=E6(J.calendar,j.calendar),z=Z0(W);return Yz(Z,()=>$(Y),J,j,...o$(Z,z,6,9,6),z)}function OJ($,Z,J,j,W){let Y=E6(J.calendar,j.calendar),z=Z0(W),O=o$(Z,z,9,9,8),X=$(Y);return Yz(Z,()=>X,dZ(X,J),dZ(X,j),...O,z)}function Yz($,Z,J,j,W,Y,z,O,X){let F=I0(J),G=I0(j),K;if(N0(G,F))if(W===6)K=x6(F,G,W,Y,z,O);else{let Q=Z();K=Q.dateUntil(J,j,W,X),Y===6&&z===1||(K=Q6(K,G,W,Y,z,O,Q,J,I0,T6))}else K=Q0;return i($?P0(K):K)}function XJ($,Z,J,j){let W=Z0(j),[Y,z,O,X]=o$($,W,5,5),F=y1(FJ(Z,J),eZ(z,O),X),G={...Q0,...N6(F,Y)};return i($?P0(G):G)}function GX($,Z,J,j,W,Y){let z=N0(j.epochNanoseconds,J.epochNanoseconds);return z?W<6?Xz(J.epochNanoseconds,j.epochNanoseconds,W):zz(Z,$,J,j,z,W,Y):Q0}function KX($,Z,J,j,W){let Y=I0(Z),z=I0(J),O=N0(z,Y);return O?j<=6?Xz(Y,z,j):Oz($,Z,J,O,j,W):Q0}function zz($,Z,J,j,W,Y,z){let[O,X,F]=((Q,U,B,D)=>{function T(){return V={...K$(C,P++*-D),...L},N=v0(Q,V),N0(H,N)===-D}let M=_0(U,Q),L=R0(a0,M),C=_0(B,Q),H=B.epochNanoseconds,P=0,_=FJ(M,C),V,N;if(Math.sign(_)===-D&&P++,T()&&(D===-1||T()))throw RangeError(W3);let x=y0(g0(N,H));return[M,V,x]})(Z,J,j,W);var G,K;return{...Y===6?(G=O,K=X,{...Q0,days:Fz(G,K)}):$.dateUntil(O,X,Y,z),...N6(F)}}function Oz($,Z,J,j,W,Y){let[z,O,X]=((F,G,K)=>{let Q=G,U=FJ(F,G);return Math.sign(U)===-K&&(Q=K$(G,-K),U+=c*K),[F,Q,U]})(Z,J,j);return{...$.dateUntil(z,O,W,Y),...N6(X)}}function x6($,Z,J,j,W,Y){return{...Q0,...e$(U6(g0($,Z),j,W,Y),J)}}function Xz($,Z,J){return{...Q0,...e$(g0($,Z),J)}}function Fz($,Z){return f6(L0($),L0(Z))}function f6($,Z){return Math.trunc((Z-$)/A0)}function FJ($,Z){return g1(Z)-g1($)}function E6($,Z){if(!r$($,Z))throw RangeError(PJ);return $}function QX($){function Z(W){return((Y,z)=>({...Gz(Y,z),F:Y.month,day:parseInt(Y.day)}))(F2(J,W),j)}let J=mJ($),j=o3($);return{id:$,O:UX(Z),B:BX(Z)}}function UX($){return b0((Z)=>{let J=L0(Z);return $(J)},WeakMap)}function BX($){let Z=$(0).year-$F;return b0((J)=>{let j,W=a$(J-Z),Y=[],z=[];do W+=400*A0;while((j=$(W)).year<=J);do W+=(1-j.day)*A0,j.year===J&&(Y.push(W),z.push(j.F)),W-=A0;while((j=$(W)).year>=J);return{k:Y.reverse(),C:N9(z.reverse())}})}function Gz($,Z){let J,j,W=Kz($);if($.era){let Y=A9[Z];Y!==void 0&&(J=Z==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),J==="bc"||J==="b"?J="bce":J!=="ad"&&J!=="a"||(J="ce"),j=W,W=Tz(j,Y[J]||0))}return{era:J,eraYear:j,year:W}}function Kz($){return parseInt($.relatedYear||$.year)}function s8($){let{year:Z,F:J,day:j}=this.O($),{C:W}=this.B(Z);return[Z,W[J]+1,j]}function iZ($,Z=1,J=1){return this.B($).k[Z-1]+(J-1)*A0}function m3($){let Z=NW(this,$),J=NW(this,$-1),j=Z.length;if(j>J.length){let W=Vz(this);if(W<0)return-W;for(let Y=0;Y<j;Y++)if(Z[Y]!==J[Y])return Y+1}}function p3($){return f6(iZ.call(this,$),iZ.call(this,$+1))}function IW($,Z){let{k:J}=this.B($),j=Z+1,W=J;return j>J.length&&(j=1,W=this.B($+1).k),f6(J[Z-1],W[j-1])}function h3($){return this.B($).k.length}function NW($,Z){return Object.keys($.B(Z).C)}function Qz($){return $3(a($))}function $3($){if(($=$.toLowerCase())!==k&&$!==q6&&o3($)!==o3(mJ($).resolvedOptions().calendar))throw RangeError(bX($));return $}function o3($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function Uz($){return this.R($)[0]}function Bz($){return this.R($)[1]}function GJ($){let[Z]=this.h($);return f6(this.q(Z),L0($))+1}function Dz($){let Z=EF.exec($);if(!Z)throw RangeError(EX($));return[parseInt(Z[1]),Boolean(Z[2])]}function r3($,Z,J){return $+(Z||J&&$>=J?1:0)}function n8($,Z){return $-(Z&&$>=Z?1:0)}function Tz($,Z){return(Z+$)*(Math.sign(Z)||1)||0}function a8($){return A9[Mz($)]}function Vz($){return uX[Mz($)]}function Mz($){return o3($.id||k)}function Cz($,Z,J,j){let W=c1(J,j,n0,[],S9);if(W.timeZone!==void 0){let Y=J.dateFromFields(W),z=U$(W),O=$(W.timeZone);return{epochNanoseconds:G$(Z(O),{...Y,...z},W.offset!==void 0?$Z(W.offset):void 0),timeZone:O}}return{...J.dateFromFields(W),...l0}}function Iz($,Z,J,j,W,Y){let z=c1(J,W,n0,P9,S9),O=$(z.timeZone),[X,F,G]=tZ(Y),K=J.dateFromFields(z,G6(Y,X)),Q=U$(z,X);return U0(G$(Z(O),{...K,...Q},z.offset!==void 0?$Z(z.offset):void 0,F,G),O,j)}function Nz($,Z,J){let j=c1($,Z,n0,[],N1),W=q(J);return J0(M1({...$.dateFromFields(j,G6(J,W)),...U$(j,W)}))}function KJ($,Z,J,j=[]){let W=c1($,Z,n0,j);return $.dateFromFields(W,J)}function QJ($,Z,J,j){let W=c1($,Z,xJ,j);return $.yearMonthFromFields(W,J)}function UJ($,Z,J,j,W=[]){let Y=c1($,J,n0,W);return Z&&Y.month!==void 0&&Y.monthCode===void 0&&Y.year===void 0&&(Y.year=s$),$.monthDayFromFields(Y,j)}function Lz($,Z){let J=q(Z);return s0(U$($1($,r8,[],1),J))}function _z($){let Z=$1($,fJ);return i(t$({...Q0,...Z}))}function c1($,Z,J,j=[],W=[]){return $1(Z,[...$.fields(J),...W].sort(),j)}function $1($,Z,J,j=!J){let W={},Y,z=0;for(let O of Z){if(O===Y)throw RangeError(_X(O));if(O==="constructor"||O==="__proto__")throw RangeError(LJ(O));let X=$[O];if(X!==void 0)z=1,HW[O]&&(X=HW[O](X,O)),W[O]=X;else if(J){if(J.includes(O))throw TypeError(NJ(O));W[O]=E9[O]}Y=O}if(j&&!z)throw TypeError(Q9(Z));return W}function U$($,Z){return X6(RF({...E9,...$}),Z)}function Pz($,Z,J,j,W,Y){let z=Z0(Y),{calendar:O,timeZone:X}=J;return U0(((F,G,K,Q,U)=>{let B=Z3(F,K,Q,n0,H9,_9),[D,T,M]=tZ(U,2);return G$(G,{...F.dateFromFields(B,G6(U,D)),...U$(B,D)},$Z(B.offset),T,M)})($(O),Z(X),j,W,z),X,O)}function Hz($,Z,J,j,W){let Y=Z0(W);return J0(((z,O,X,F)=>{let G=Z3(z,O,X,n0,N1),K=q(F);return M1({...z.dateFromFields(G,G6(F,K)),...U$(G,K)})})($(Z.calendar),J,j,Y))}function Sz($,Z,J,j,W){let Y=Z0(W);return((z,O,X,F)=>{let G=Z3(z,O,X,n0);return z.dateFromFields(G,F)})($(Z.calendar),J,j,Y)}function xz($,Z,J,j,W){let Y=Z0(W);return W$(((z,O,X,F)=>{let G=Z3(z,O,X,xJ);return z.yearMonthFromFields(G,F)})($(Z.calendar),J,j,Y))}function fz($,Z,J,j,W){let Y=Z0(W);return((z,O,X,F)=>{let G=Z3(z,O,X,n0);return z.monthDayFromFields(G,F)})($(Z.calendar),J,j,Y)}function Ez($,Z,J){return s0(((j,W,Y)=>{let z=q(Y);return U$({...R0(r8,j),...$1(W,r8)},z)})($,Z,J))}function Az($,Z){return i((J=$,j=Z,t$({...J,...$1(j,fJ)})));var J,j}function Z3($,Z,J,j,W=[],Y=[]){let z=[...$.fields(j),...W].sort(),O=$1(Z,z,Y),X=$1(J,z);return O=$.mergeFields(O,X),$1(O,z,[])}function BJ($,Z){let J=c1($,Z,f9);return $.monthDayFromFields(J)}function DJ($,Z,J){let j=c1($,Z,x9);return $.yearMonthFromFields(j,J)}function bz($,Z,J,j,W){Z=R0(J=$.fields(J),Z),j=$1(j,W=$.fields(W),[]);let Y=$.mergeFields(Z,j);return Y=$1(Y,[...J,...W].sort(),[]),$.dateFromFields(Y)}function c8($,Z){let{era:J,eraYear:j,year:W}=Z,Y=a8($);if(J!==void 0||j!==void 0){if(J===void 0||j===void 0)throw TypeError(HX);if(!Y)throw RangeError(PX);let z=Y[J];if(z===void 0)throw RangeError(xX(J));let O=Tz(j,z);if(W!==void 0&&W!==O)throw RangeError(SX);W=O}else if(W===void 0)throw TypeError(fX(Y));return W}function l8($,Z,J,j){let{month:W,monthCode:Y}=Z;if(Y!==void 0){let z=((O,X,F,G)=>{let K=O.U(F),[Q,U]=Dz(X),B=r3(Q,U,K);if(U){let D=Vz(O);if(D===void 0)throw RangeError(hZ);if(D>0){if(B>D)throw RangeError(hZ);if(K===void 0){if(G===1)throw RangeError(hZ);B--}}else{if(B!==-D)throw RangeError(hZ);if(K===void 0&&G===1)throw RangeError(hZ)}}return B})($,Y,J,j);if(W!==void 0&&W!==z)throw RangeError(T9);W=z,j=1}else if(W===void 0)throw TypeError(AX);return p0("month",W,1,$.L(J),j)}function LW($,Z,J,j,W){return f0(Z,"day",1,$.j(j,J),W)}function d8($,Z,J,j){let W=0,Y=[];for(let z of J)Z[z]!==void 0?W=1:Y.push(z);if(Object.assign($,Z),W)for(let z of j||Y)delete $[z]}function vz($){return F0(m0(W6(j6($))))}function Rz($,Z,J,j,W=k){return U0(m0(W6(j6(J))),Z(j),$(W))}function wz($,Z,J,j,W=0,Y=0,z=0,O=0,X=0,F=0,G=k){return J0(M1(O6(d0(C0,n$(g6,[Z,J,j,W,Y,z,O,X,F])))),$(G))}function kz($,Z,J,j,W=k){return j0(w1(O$(d0(C0,{isoYear:Z,isoMonth:J,isoDay:j}))),$(W))}function qz($,Z,J,j=k,W=1){let Y=C0(Z),z=C0(J),O=$(j);return W$(G2(O$({isoYear:Y,isoMonth:z,isoDay:C0(W)})),O)}function gz($,Z,J,j=k,W=s$){let Y=C0(Z),z=C0(J),O=$(j);return s3(w1(O$({isoYear:C0(W),isoMonth:Y,isoDay:z})),O)}function yz($=0,Z=0,J=0,j=0,W=0,Y=0){return s0(X6(d0(C0,n$(a0,[$,Z,J,j,W,Y])),1))}function mz($=0,Z=0,J=0,j=0,W=0,Y=0,z=0,O=0,X=0,F=0){return i(t$(d0(lW,n$(g,[$,Z,J,j,W,Y,z,O,X,F]))))}function TJ($,Z,J=k){return U0($.epochNanoseconds,Z,J)}function pz($){return F0($.epochNanoseconds)}function VJ($,Z){return J0(_0(Z,$))}function MJ($,Z){return j0(_0(Z,$))}function hz($,Z,J){return DJ($(Z.calendar),J)}function cz($,Z,J){return BJ($(Z.calendar),J)}function CJ($,Z){return s0(_0(Z,$))}function lz($,Z,J,j){let W=((Y,z,O,X)=>{let F=B2(X);return v0(Y(z),O,F)})($,J,Z,j);return U0(m0(W),J,Z.calendar)}function dz($,Z,J){let j=$(Z.calendar);return W$({...Z,...DJ(j,J)})}function uz($,Z,J){return BJ($(Z.calendar),J)}function iz($,Z,J,j,W){let Y=$(W.timeZone),z=W.plainTime,O=z!==void 0?Z(z):l0;return U0(v0(J(Y),{...j,...O}),Y,j.calendar)}function sz($,Z=l0){return J0(M1({...$,...Z}))}function nz($,Z,J){return DJ($(Z.calendar),J)}function az($,Z,J){return BJ($(Z.calendar),J)}function oz($,Z,J,j){return((W,Y,z)=>bz(W,Y,x9,V1(z),z3))($(Z.calendar),J,j)}function rz($,Z,J,j){return((W,Y,z)=>bz(W,Y,f9,V1(z),k6))($(Z.calendar),J,j)}function tz($,Z,J,j,W){let Y=V1(W),z=Z(Y.plainDate),O=$(Y.timeZone);return U0(v0(J(O),{...z,...j}),O,z.calendar)}function ez($,Z){return J0(M1({...$,...Z}))}function $9($){return F0(m0(u$($,c0)))}function Z9($){return F0(m0(u$($,J1)))}function J9($){return F0(m0(W6(j6($),D$)))}function j9($){return F0(m0(W6(j6($))))}function W9($,Z,J=l0){let j=Z.timeZone,W=$(j),Y={..._0(Z,W),...J};return U0(G$(W,Y,Y.offsetNanoseconds,2),j,Z.calendar)}function Y9($,Z,J){let j=Z.timeZone,W=$(j),Y={..._0(Z,W),...J},z=F9(Z.calendar,J.calendar);return U0(G$(W,Y,Y.offsetNanoseconds,2),j,z)}function z9($,Z=l0){return J0({...$,...Z})}function O9($,Z){return J0({...$,...Z},F9($.calendar,Z.calendar))}function A6($,Z){return{...$,calendar:Z}}function X9($,Z){return{...$,timeZone:Z}}function F9($,Z){if($===Z)return $;let J=K0($),j=K0(Z);if(J===j||J===k)return Z;if(j===k)return $;throw RangeError(PJ)}function DX($,Z){return(J)=>J===k?$:J===q6||J===i$?Object.assign(Object.create($),{id:J}):Object.assign(Object.create(Z),fF(J))}function B$($,Z,J){let j=new Set(J);return(W)=>(((Y,z)=>{for(let O of z)if(O in Y)return 1;return 0})(W=Z2(j,W),$)||Object.assign(W,Z),J&&(W.timeZone=M$,["full","long"].includes(W.timeStyle)&&(W.timeStyle="medium")),W)}function C1($,Z=IJ){let[J,,,j]=$;return(W,Y=aF,...z)=>{let O=Z(j&&j(...z),W,Y,J),X=O.resolvedOptions();return[O,...TX($,X,z)]}}function IJ($,Z,J,j){if(J=j(J),$){if(J.timeZone!==void 0)throw TypeError(cX);J.timeZone=$}return new l1(Z,J)}function TX($,Z,J){let[,j,W]=$;return J.map((Y)=>(Y.calendar&&((z,O,X)=>{if((X||z!==k)&&z!==O)throw RangeError(PJ)})(K0(Y.calendar),Z.calendar,W),j(Y,Z)))}function JZ($){let Z=J3();return m1(Z,$.getOffsetNanosecondsFor(Z))}function J3(){return u$(Date.now(),J1)}function I1(){return xW||(xW=new l1().resolvedOptions().timeZone)}var VX=($,Z)=>`Non-integer ${$}: ${Z}`,MX=($,Z)=>`Non-positive ${$}: ${Z}`,CX=($,Z)=>`Non-finite ${$}: ${Z}`,IX=($)=>`Cannot convert bigint to ${$}`,NX=($)=>`Invalid bigint: ${$}`,LX="Cannot convert Symbol to string",G9="Invalid object",K9=($,Z,J,j,W)=>W?K9($,W[Z],W[J],W[j]):j3($,Z)+`; must be between ${J}-${j}`,j3=($,Z)=>`Invalid ${$}: ${Z}`,NJ=($)=>`Missing ${$}`,LJ=($)=>`Invalid field ${$}`,_X=($)=>`Duplicate field ${$}`,Q9=($)=>"No valid fields: "+$.join(),U9="Invalid bag",B9=($,Z,J)=>j3($,Z)+"; must be "+Object.keys(J).join(),D9="Cannot use valueOf",_J="Invalid calling context",PX="Forbidden era/eraYear",HX="Mismatching era/eraYear",SX="Mismatching year/eraYear",xX=($)=>`Invalid era: ${$}`,fX=($)=>"Missing year"+($?"/era/eraYear":""),EX=($)=>`Invalid monthCode: ${$}`,T9="Mismatching month/monthCode",AX="Missing month/monthCode",_W="Cannot guess year",hZ="Invalid leap month",V9="Invalid protocol",W3="Invalid protocol results",PJ="Mismatching Calendars",bX=($)=>`Invalid Calendar: ${$}`,M9="Mismatching TimeZones",vX="Forbidden ICU TimeZone",RX="Out-of-bounds offset",wX="Out-of-bounds TimeZone gap",kX="Invalid TimeZone offset",qX="Ambiguous offset",b6="Out-of-bounds date",gX="Out-of-bounds duration",yX="Cannot mix duration signs",v6="Missing relativeTo",mX="Cannot use large units",pX="Required smallestUnit or largestUnit",hX="smallestUnit > largestUnit",E0=($)=>`Cannot parse: ${$}`,T1=($)=>`Invalid substring: ${$}`,C9=($)=>`Cannot format ${$}`,I9="Mismatching types for formatting",cX="Cannot specify TimeZone",N9=R(aZ,($,Z)=>Z),jZ=R(aZ,($,Z,J)=>J),h0=R(d3,2),o8={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},Y3=Object.keys(o8),A0=86400000,L9=1000,D$=1000,J1=1e6,c0=1e9,R6=60000000000,w6=3600000000000,c=86400000000000,Z1=[1,D$,J1,c0,R6,w6,c],N1=Y3.slice(0,6),r8=oZ(N1),_9=["offset"],P9=["timeZone"],H9=N1.concat(_9),S9=H9.concat(P9),t8=["era","eraYear"],lX=t8.concat(["year"]),k6=["year"],HJ=["monthCode"],SJ=["month"].concat(HJ),z3=["day"],xJ=SJ.concat(k6),x9=HJ.concat(k6),n0=z3.concat(xJ),dX=z3.concat(SJ),f9=z3.concat(HJ),E9=jZ(N1,0),k="iso8601",q6="gregory",i$="japanese",A9={[q6]:{bce:-1,ce:0},[i$]:{bce:-1,ce:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018},ethioaa:{era0:0},ethiopic:{era0:0,era1:5500},coptic:{era0:-1,era1:0},roc:{beforeroc:-1,minguo:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0}},uX={chinese:13,dangi:13,hebrew:-6},a=R(J6,"string"),b9=R(J6,"boolean"),iX=R(J6,"number"),v9=R(J6,"function"),g=Y3.map(($)=>$+"s"),fJ=oZ(g),sX=g.slice(0,6),R9=g.slice(6),nX=R9.slice(1),aX=N9(g),Q0=jZ(g,0),EJ=jZ(sX,0),AJ=R(vW,g),a0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],bJ=["isoDay","isoMonth","isoYear"],g6=a0.concat(bJ),vJ=oZ(bJ),w9=oZ(a0),k9=oZ(g6),l0=jZ(w9,0),oX=R(vW,g6),l1=Intl.DateTimeFormat,q9="en-GB",RJ=1e8,rX=RJ*A0,tX=[RJ,0],eX=[-RJ,0],sZ=275760,nZ=-271821,$F=1970,s$=1972,B1=12,ZF=a$(1868,9,8),JF=b0(JX,WeakMap),t3="smallestUnit",e8="unit",lZ="roundingIncrement",u8="fractionalSecondDigits",g9="relativeTo",y9={constrain:0,reject:1},jF=Object.keys(y9),WF={compatible:0,reject:1,earlier:2,later:3},YF={reject:0,use:1,prefer:2,ignore:3},zF={auto:0,never:1,critical:2,always:3},OF={auto:0,never:1,critical:2},XF={auto:0,never:1},FF={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},O3=R(I2,t3),wJ=R(I2,"largestUnit"),GF=R(I2,e8),m9=R(X$,"overflow",y9),p9=R(X$,"disambiguation",WF),KF=R(X$,"offset",YF),kJ=R(X$,"calendarName",zF),QF=R(X$,"timeZoneName",OF),UF=R(X$,"offset",XF),X3=R(X$,"roundingMode",FF),WZ="PlainYearMonth",YZ="PlainMonthDay",T$="PlainDate",V$="PlainDateTime",y6="PlainTime",L1="ZonedDateTime",m6="Instant",p6="Duration",BF=[Math.floor,($)=>y3($)?Math.floor($):Math.round($),Math.ceil,($)=>y3($)?Math.ceil($):Math.round($),Math.trunc,($)=>y3($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>y3($)?($=Math.trunc($)||0)+$%2:Math.round($)],M$="UTC",c3=5184000,DF=i3(1847),TF=i3(new Date().getUTCFullYear()+10),VF=/0+$/,_0=b0(XX,WeakMap),PW=4294967295,h6=b0(($)=>{let Z=e2($);return typeof Z=="object"?new c9(Z):new h9(Z||0)});class h9{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[K2($,this.v)]}l(){}}class c9{constructor($){this.$=((Z)=>{function J(X){let F=i8(X,z,O),[G,K]=MW(F),Q=W(G),U=W(K);return Q===U?Q:j(Y(G,K),Q,U,X)}function j(X,F,G,K){let Q,U;for(;(K===void 0||(Q=K<X[0]?F:K>=X[1]?G:void 0)===void 0)&&(U=X[1]-X[0]);){let B=X[0]+Math.floor(U/2);Z(B)===G?X[1]=B:X[0]=B+1}return Q}let W=b0(Z),Y=b0(FX),z=DF,O=TF;return{G(X){let F=J(X-86400),G=J(X+86400),K=X-F,Q=X-G;if(F===G)return[K];let U=J(K);return U===J(Q)?[X-U]:F>G?[K,Q]:[]},V:J,l(X,F){let G=i8(X,z,O),[K,Q]=MW(G),U=c3*F,B=F<0?()=>Q>z||(z=G,0):()=>K<O||(O=G,0);for(;B();){let D=W(K),T=W(Q);if(D!==T){let M=Y(K,Q);j(M,D,T);let L=M[0];if((R1(L,X)||1)===F)return L}K+=U,Q+=U}}}})(((Z)=>(J)=>{let j=F2(Z,J*L9);return i3(Kz(j),parseInt(j.month),parseInt(j.day),parseInt(j.hour),parseInt(j.minute),parseInt(j.second))-J})($))}getOffsetNanosecondsFor($){return this.$.V(iW($))*c0}getPossibleInstantsFor($){let[Z,J]=[i3((j=$).isoYear,j.isoMonth,j.isoDay,j.isoHour,j.isoMinute,j.isoSecond),j.isoMillisecond*J1+j.isoMicrosecond*D$+j.isoNanosecond];var j;return this.$.G(Z).map((W)=>m0(d$(u$(W,c0),J)))}l($,Z){let[J,j]=sW($),W=this.$.l(J+(Z>0||j?1:0),Z);if(W!==void 0)return u$(W,c0)}}var qJ="([+\u2212-])",l3="(?:[.,](\\d{1,9}))?",l9=`(?:(?:${qJ}(\\d{6}))|(\\d{4}))-?(\\d{2})`,gJ="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+l3+")?)?",yJ=qJ+gJ,MF=l9+"-?(\\d{2})(?:[T ]"+gJ+"(Z|"+yJ+")?)?",d9="\\[(!?)([^\\]]*)\\]",c6=`((?:${d9}){0,9})`,CF=ZZ(l9+c6),IF=ZZ("(?:--)?(\\d{2})-?(\\d{2})"+c6),NF=ZZ(MF+c6),LF=ZZ("T?"+gJ+"(?:"+yJ+")?"+c6),_F=ZZ(yJ),PF=new RegExp(d9,"g"),HF=ZZ(`${qJ}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${l3}H)?(?:(\\d+)${l3}M)?(?:(\\d+)${l3}S)?)?`),SF=b0(($)=>new l1(q9,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),xF=/^(AC|AE|AG|AR|AS|BE|BS|CA|CN|CS|CT|EA|EC|IE|IS|JS|MI|NE|NS|PL|PN|PR|PS|SS|VS)T$/,fF=b0(QX),mJ=b0(($)=>new l1(q9,{calendar:$,timeZone:M$,era:"short",year:"numeric",month:"short",day:"numeric"})),EF=/^M(\d{2})(L?)$/,AF={era:u3,eraYear:C0,year:C0,month:BW,monthCode:u3,day:BW},bF=jZ(N1,C0),vF=jZ(g,lW),HW=Object.assign({},AF,bF,vF,{offset:u3}),RF=R(ZX,N1,a0),SW={dateAdd($,Z,J){let j=q(J),W,{years:Y,months:z,weeks:O,days:X}=Z;if(X+=O0(Z,5)[0],Y||z)W=((F,G,K,Q,U)=>{let[B,D,T]=F.h(G);if(K){let[M,L]=F.I(B,D);B+=K,D=r3(M,L,F.U(B)),D=p0("month",D,1,F.L(B),U)}return Q&&([B,D]=F._(B,D,Q)),T=p0("day",T,1,F.j(B,D),U),F.q(B,D,T)})(this,$,Y,z,j);else{if(!O&&!X)return $;W=L0($)}return W+=(7*O+X)*A0,w1(z6(W))},dateUntil($,Z,J){if(J<=7){let X=0,F=Fz({...$,...l0},{...Z,...l0});return J===7&&([X,F]=q1(F,7)),{...Q0,weeks:X,days:F}}let j=this.h($),W=this.h(Z),[Y,z,O]=((X,F,G,K,Q,U,B)=>{let D=Q-F,T=U-G,M=B-K;if(D||T){let L=Math.sign(D||T),C=X.j(Q,U),H=0;if(Math.sign(M)===-L){let P=C;[Q,U]=X._(Q,U,-L),D=Q-F,T=U-G,C=X.j(Q,U),H=L<0?-P:C}if(M=B-Math.min(K,C)+H,D){let[P,_]=X.I(F,G),[V,N]=X.I(Q,U);if(T=V-P||Number(N)-Number(_),Math.sign(T)===-L){let x=L<0&&-X.L(Q);D=(Q-=L)-F,T=U-r3(P,_,X.U(Q))+(x||X.L(Q))}}}return[D,T,M]})(this,...j,...W);return J===8&&(z+=this.J(Y,j[0]),Y=0),{...Q0,years:Y,months:z,days:O}},dateFromFields($,Z){let J=q(Z),j=c8(this,$),W=l8(this,$,j,J),Y=LW(this,$,W,j,J);return j0(w1(this.P(j,W,Y)),this.id||k)},yearMonthFromFields($,Z){let J=q(Z),j=c8(this,$),W=l8(this,$,j,J);return W$(G2(this.P(j,W,1)),this.id||k)},monthDayFromFields($,Z){let J=q(Z),j=!this.id,{monthCode:W,year:Y,month:z}=$,O,X,F,G,K;if(W!==void 0){[O,X]=Dz(W),K=fW($,"day");let Q=this.N(O,X,K);if(!Q)throw RangeError(_W);if([F,G]=Q,z!==void 0&&z!==G)throw RangeError(T9);j&&(G=p0("month",G,1,B1,1),K=p0("day",K,1,Q2(Y!==void 0?Y:F,G),J))}else{F=Y===void 0&&j?s$:c8(this,$),G=l8(this,$,F,J),K=LW(this,$,G,F,J);let Q=this.U(F);X=G===Q,O=n8(G,Q);let U=this.N(O,X,K);if(!U)throw RangeError(_W);[F,G]=U}return s3(w1(this.P(F,G,K)),this.id||k)},fields($){return a8(this)&&$.includes("year")?[...$,...t8]:$},mergeFields($,Z){let J=Object.assign(Object.create(null),$);return d8(J,Z,SJ),a8(this)&&(d8(J,Z,lX),this.id===i$&&d8(J,Z,dX,t8)),J},inLeapYear($){let[Z]=this.h($);return this.K(Z)},monthsInYear($){let[Z]=this.h($);return this.L(Z)},daysInMonth($){let[Z,J]=this.h($);return this.j(Z,J)},daysInYear($){let[Z]=this.h($);return this.X(Z)},dayOfYear:GJ,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[Z,J]=this.h($),[j,W]=this.I(Z,J);return((Y,z)=>"M"+h0(Y)+(z?"L":""))(j,W)},dayOfWeek:tW,daysInWeek(){return 7}},wF={dayOfYear:GJ,h:aW,q:a$},kF=Object.assign({},wF,{weekOfYear:Uz,yearOfWeek:Bz,R($){function Z(U){return(7-U<j?7:0)-U}function J(U){let B=rW(Q+U),D=U||1,T=Z(cZ(X+B*D,7));return G=(B+(T-F)*D)/7}let j=this.id?1:4,W=tW($),Y=this.dayOfYear($),z=cZ(W-1,7),O=Y-1,X=cZ(z-O,7),F=Z(X),G,K=Math.floor((O-F)/7)+1,Q=$.isoYear;return K?K>J(0)&&(K=1,Q++):(K=J(-1),Q--),[K,Q,G]}}),qF={dayOfYear:GJ,h:s8,q:iZ,weekOfYear:Uz,yearOfWeek:Bz,R(){return[]}},zZ=DX(Object.assign({},SW,kF,{h:aW,ee($){return this.id===q6?eW($):this.id===i$?JF($):[]},I:($,Z)=>[Z,0],N($,Z){if(!Z)return[s$,$]},K:U2,U(){},L:oW,J:($)=>$*B1,j:Q2,X:rW,P:($,Z,J)=>({isoYear:$,isoMonth:Z,isoDay:J}),q:a$,_:($,Z,J)=>($+=$6(J,B1),(Z+=j2(J,B1))<1?($--,Z+=B1):Z>B1&&($++,Z-=B1),[$,Z]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},SW,qF,{h:s8,ee($){let Z=this.O($);return[Z.era,Z.eraYear]},I($,Z){let J=m3.call(this,$);return[n8(Z,J),J===Z]},N($,Z,J){let[j,W,Y]=s8.call(this,{isoYear:s$,isoMonth:B1,isoDay:31}),z=m3.call(this,j),O=W===z;(R1($,n8(W,z))||R1(Number(Z),Number(O))||R1(J,Y))===1&&j--;for(let X=0;X<100;X++){let F=j-X,G=m3.call(this,F),K=r3($,Z,G);if(Z===(K===G)&&J<=IW.call(this,F,K))return[F,K]}},K($){let Z=p3.call(this,$);return Z>p3.call(this,$-1)&&Z>p3.call(this,$+1)},U:m3,L:h3,J($,Z){let J=Z+$,j=Math.sign($),W=j<0?-1:0,Y=0;for(let z=Z;z!==J;z+=j)Y+=h3.call(this,z+W);return Y},j:IW,X:p3,P($,Z,J){return z6(iZ.call(this,$,Z,J))},q:iZ,_($,Z,J){if(J){if(Z+=J,!Number.isSafeInteger(Z))throw RangeError(b6);if(J<0)for(;Z<1;)Z+=h3.call(this,--$);else{let j;for(;Z>(j=h3.call(this,$));)Z-=j,$++}}return[$,Z]},year($){return this.O($).year},month($){let{year:Z,F:J}=this.O($),{C:j}=this.B(Z);return j[J]+1},day($){return this.O($).day}})),k1="numeric",OZ=["timeZoneName"],u9={month:k1,day:k1},pJ={year:k1,month:k1},hJ=Object.assign({},pJ,{day:k1}),cJ={hour:k1,minute:k1,second:k1},lJ=Object.assign({},hJ,cJ),gF=Object.assign({},lJ,{timeZoneName:"short"}),yF=Object.keys(pJ),mF=Object.keys(u9),pF=Object.keys(hJ),hF=Object.keys(cJ),dJ=["dateStyle"],cF=yF.concat(dJ),lF=mF.concat(dJ),uJ=pF.concat(dJ,["weekday"]),F3=hF.concat(["dayPeriod","timeStyle"]),iJ=uJ.concat(F3),dF=iJ.concat(OZ),uF=OZ.concat(F3),iF=OZ.concat(uJ),sF=OZ.concat(["day","weekday"],F3),nF=OZ.concat(["year","weekday"],F3),aF={},sJ=[B$(iJ,lJ),K6],i9=[B$(dF,gF),K6,0,($,Z)=>{let J=K0($.timeZone);if(Z&&K0(Z.timeZone)!==J)throw RangeError(M9);return J}],nJ=[B$(iJ,lJ,OZ),L0],aJ=[B$(uJ,hJ,uF),L0],oJ=[B$(F3,cJ,iF),($)=>g1($)/J1],rJ=[B$(cF,pJ,sF),L0,1],tJ=[B$(lF,u9,nF),L0,1],xW;function Y1($,Z,J,j,W){function Y(...X){if(!(this instanceof Y))throw TypeError(_J);o9(this,Z(...X))}function z(X,F){return Object.defineProperties(function(...G){return X.call(this,O(this),...G)},$2(F))}function O(X){let F=T0(X);if(!F||F.branding!==$)throw TypeError(_J);return F}return Object.defineProperties(Y.prototype,{...EW(d0(z,J)),...z$(d0(z,j)),...e3("Temporal."+$)}),Object.defineProperties(Y,{...z$(W),...$2($)}),[Y,(X)=>{let F=Object.create(Y.prototype);return o9(F,X),F},O]}function e9($){return $=$.concat("id").sort(),(Z)=>{if(!AW(Z,$))throw TypeError(V9);return Z}}function KZ($){if(T0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(U9);return $}function l6($,Z){let J={};for(let j in $)J[j]=({o:W},Y)=>{let z=T0(Y)||{},{branding:O}=z,X=O===T$||Z.includes(O)?z:S0(Y);return W[j](X)};return J}function Z4($){let Z={};for(let J in $)Z[J]=(j)=>{let{calendar:W}=j;return(Y=W,typeof Y=="string"?zZ(Y):(z=Y,Object.assign(Object.create(KG),{i:z})))[J](j);var Y,z};return Z}function n1(){throw TypeError(D9)}function K3({calendar:$}){return typeof $=="string"?new G4($):$}function s9($,Z){if(Z=Z0(Z),X0($)){let j=T0($);if(j&&j.branding===YZ)return q(Z),j;let W=J5($);return UJ(o6(W||k),!W,$,Z)}let J=mY(zZ,$);return q(Z),J}function $5($,Z,J){return j=Z.call($,H0(F0(J))),w2(rZ(j));var j}function d6($,Z=z5){let J=Object.keys(Z).sort(),j={};for(let W of J)j[W]=R(Z[W],$,v9($[W]));return j}function l($,Z){return typeof $=="string"?h6($):d6($,Z)}function Y0($){return l($,$4)}function j1($){if(X0($)){let Z=T0($);if(Z)switch(Z.branding){case m6:return Z;case L1:return F0(Z.epochNanoseconds)}}return wY($)}function n9($,Z,J){let j=Z.l(j1(J).epochNanoseconds,$);return j?H0(F0(j)):null}function u($){return X0($)?(T0($)||{}).timeZone||VG($):((Z)=>P6(lY(a(Z))))($)}function d1($,Z){if(X0($)){let J=T0($)||{};switch(J.branding){case y6:return q(Z),J;case V$:return q(Z),s0(J);case L1:return q(Z),CJ(Y0,J)}return Lz($,Z)}return q(Z),pY($)}function J4($){return $===void 0?void 0:d1($)}function XZ($,Z){if(Z=Z0(Z),X0($)){let j=T0($);return j&&j.branding===WZ?(q(Z),j):QJ(n6(Q3($)),$,Z)}let J=yY(zZ,$);return q(Z),J}function u1($,Z){if(Z=Z0(Z),X0($)){let j=T0($)||{};switch(j.branding){case V$:return q(Z),j;case T$:return q(Z),J0({...j,...l0});case L1:return q(Z),VJ(Y0,j)}return Nz(a6(Q3($)),$,Z)}let J=gY($);return q(Z),J}function S0($,Z){if(Z=Z0(Z),X0($)){let j=T0($)||{};switch(j.branding){case T$:return q(Z),j;case V$:return q(Z),j0(j);case L1:return q(Z),MJ(Y0,j)}return KJ(a6(Q3($)),$,Z)}let J=L6($);return q(Z),J}function Z5($,Z,J){return u0(Z.call($,r(j0(J,$))))}function z1($){return(Z)=>typeof Z=="string"?zZ(Z):((J,j)=>{let W=Object.keys(j).sort(),Y={};for(let z of W)Y[z]=R(j[z],J,J[z]);return Y})(Z,$)}function o($){if(X0($)){let Z=T0($);return Z&&Z.branding===p6?Z:_z($)}return hY($)}function G3($){if($!==void 0){if(X0($)){let Z=T0($)||{};switch(Z.branding){case L1:case T$:return Z;case V$:return j0(Z)}let J=Q3($);return{...Cz(u,l,a6(J),$),calendar:J}}return kY($)}}function Q3($){return J5($)||k}function J5($){let{calendar:Z}=$;if(Z!==void 0)return D0(Z)}function D0($){return X0($)?(T0($)||{}).calendar||vG($):((Z)=>$3(cY(a(Z))))($)}function FZ($,Z){if(Z=Z0(Z),X0($)){let J=T0($);if(J&&J.branding===L1)return tZ(Z),J;let j=Q3($);return Iz(u,l,a6(j),j,$,Z)}return qY($,Z)}function a9($){return d0((Z)=>(J)=>Z(eJ(J)),$)}function eJ($){return _0($,Y0)}function oF(){let $=l1.prototype,Z=Object.getOwnPropertyDescriptors($),J=Object.getOwnPropertyDescriptors(l1),j=function(W,Y={}){if(!(this instanceof j))return new j(W,Y);K4.set(this,((z,O={})=>{let X=new l1(z,O),F=X.resolvedOptions(),G=F.locale,K=R0(Object.keys(O),F),Q=b0(eF),U=(...B)=>{let D,T=B.map((M,L)=>{let C=T0(M),H=(C||{}).branding;if(L&&D&&D!==H)throw TypeError(I9);return D=H,C});return D?Q(D)(G,K,...T):[X,...B]};return U.u=X,U})(W,Y))};for(let W in Z){let Y=Z[W],z=W.startsWith("format")&&rF(W);typeof Y.value=="function"?Y.value=W==="constructor"?j:z||tF(W):z&&(Y.get=function(){return z.bind(this)})}return J.prototype.value=Object.create($,Z),Object.defineProperties(j,J),j}function rF($){return function(...Z){let J=K4.get(this),[j,...W]=J(...Z);return j[$](...W)}}function tF($){return function(...Z){return K4.get(this).u[$](...Z)}}function eF($){let Z=$G[$];if(!Z)throw TypeError(C9($));return C1(Z,b0(IJ))}var $G={Instant:sJ,PlainDateTime:nJ,PlainDate:aJ,PlainTime:oJ,PlainYearMonth:rJ,PlainMonthDay:tJ},ZG=C1(sJ),JG=C1(i9),jG=C1(nJ),WG=C1(aJ),YG=C1(oJ),zG=C1(rJ),OG=C1(tJ),j4={era:gW,eraYear:W2,year:rZ,month:u0,daysInMonth:u0,daysInYear:u0,inLeapYear:b9,monthsInYear:u0},i6={monthCode:a},W4={day:u0},j5={dayOfWeek:u0,dayOfYear:u0,weekOfYear:yW,yearOfWeek:W2,daysInWeek:u0},W5=Object.assign({},j4,i6,W4,j5),u6=new WeakMap,T0=u6.get.bind(u6),o9=u6.set.bind(u6),XG={...l6(j4,[WZ]),...l6(j5,[]),...l6(i6,[WZ,YZ]),...l6(W4,[YZ])},Y4=Z4(W5),FG=Z4({...j4,...i6}),GG=Z4({...i6,...W4}),U3={calendarId:($)=>K0($.calendar)},KG=d0(($,Z)=>function(J){let{i:j}=this;return $(j[Z](r(j0(J,j))))},W5),QG=aZ(($)=>(Z)=>Z[$],g.concat("sign")),z4=aZ(($,Z)=>(J)=>J[a0[Z]],N1),Y5={epochSeconds:zY,epochMilliseconds:K6,epochMicroseconds:OY,epochNanoseconds:XY},B3=R(Z2,new Set(["branding"])),[UG,GZ,BG]=Y1(YZ,R(gz,D0),{...U3,...GG},{getISOFields:B3,getCalendar:K3,with($,Z,J){return GZ(fz(EG,$,this,KZ(Z),J))},equals:($,Z)=>jz($,s9(Z)),toPlainDate($,Z){return r(rz(D3,$,this,Z))},toLocaleString($,Z,J){let[j,W]=OG(Z,J,$);return j.format(W)},toString:E2,toJSON:($)=>E2($),valueOf:n1},{from:($,Z)=>GZ(s9($,Z))}),z5={getOffsetNanosecondsFor:$5,getPossibleInstantsFor($,Z,J){let j=[...Z.call($,B0(J0(J,k)))].map((Y)=>TG(Y).epochNanoseconds),W=j.length;return W>1&&(j.sort(N0),k2(y0(g0(j[0],j[W-1])))),j}},$4={getOffsetNanosecondsFor:$5},[DG,H0,TG]=Y1(m6,vz,Y5,{add:($,Z)=>H0(q2(0,$,o(Z))),subtract:($,Z)=>H0(q2(1,$,o(Z))),until:($,Z,J)=>d(jJ(0,$,j1(Z),J)),since:($,Z,J)=>d(jJ(1,$,j1(Z),J)),round:($,Z)=>H0(KY($,Z)),equals:($,Z)=>tY($,j1(Z)),toZonedDateTime($,Z){let J=V1(Z);return W0(TJ($,u(J.timeZone),D0(J.calendar)))},toZonedDateTimeISO:($,Z)=>W0(TJ($,u(Z))),toLocaleString($,Z,J){let[j,W]=ZG(Z,J,$);return j.format(W)},toString:($,Z)=>P2(u,Y0,$,Z),toJSON:($)=>P2(u,Y0,$),valueOf:n1},{from:($)=>H0(j1($)),fromEpochSeconds:($)=>H0($9($)),fromEpochMilliseconds:($)=>H0(Z9($)),fromEpochMicroseconds:($)=>H0(J9($)),fromEpochNanoseconds:($)=>H0(j9($)),compare:($,Z)=>$J(j1($),j1(Z))}),[s6,EB]=Y1("TimeZone",($)=>{let Z=oY($);return{branding:"TimeZone",id:Z,o:h6(Z)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},Z)=>$.getPossibleInstantsFor(u1(Z)).map((J)=>H0(F0(J))),getOffsetNanosecondsFor:({o:$},Z)=>$.getOffsetNanosecondsFor(j1(Z).epochNanoseconds),getOffsetStringFor($,Z){let J=j1(Z).epochNanoseconds,j=d6(this,$4).getOffsetNanosecondsFor(J);return F$(j)},getPlainDateTimeFor($,Z,J=k){let j=j1(Z).epochNanoseconds,W=d6(this,$4).getOffsetNanosecondsFor(j);return B0(J0(m1(j,W),D0(J)))},getInstantFor($,Z,J){let j=u1(Z),W=B2(J),Y=d6(this);return H0(F0(v0(Y,j,W)))},getNextTransition:({o:$},Z)=>n9(1,$,Z),getPreviousTransition:({o:$},Z)=>n9(-1,$,Z),equals($,Z){return!!S6(this,u(Z))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let Z=u($);return typeof Z=="string"?new s6(Z):Z}}),VG=e9(Object.keys(z5)),[MG,i1]=Y1(y6,yz,z4,{getISOFields:B3,with($,Z,J){return i1(Ez(this,KZ(Z),J))},add:($,Z)=>i1(h2(0,$,o(Z))),subtract:($,Z)=>i1(h2(1,$,o(Z))),until:($,Z,J)=>d(XJ(0,$,d1(Z),J)),since:($,Z,J)=>d(XJ(1,$,d1(Z),J)),round:($,Z)=>i1(BY($,Z)),equals:($,Z)=>Wz($,d1(Z)),toZonedDateTime:($,Z)=>W0(tz(u,S0,l,$,Z)),toPlainDateTime:($,Z)=>B0(ez($,S0(Z))),toLocaleString($,Z,J){let[j,W]=YG(Z,J,$);return j.format(W)},toString:A2,toJSON:($)=>A2($),valueOf:n1},{from:($,Z)=>i1(d1($,Z)),compare:($,Z)=>H6(d1($),d1(Z))}),[CG,s1,IG]=Y1(WZ,R(qz,D0),{...U3,...FG},{getISOFields:B3,getCalendar:K3,with($,Z,J){return s1(xz(fG,$,this,KZ(Z),J))},add:($,Z,J)=>s1(p2(r9,0,$,o(Z),J)),subtract:($,Z,J)=>s1(p2(r9,1,$,o(Z),J)),until:($,Z,J)=>d(OJ(t9,0,$,XZ(Z),J)),since:($,Z,J)=>d(OJ(t9,1,$,XZ(Z),J)),equals:($,Z)=>Jz($,XZ(Z)),toPlainDate($,Z){return r(oz(D3,$,this,Z))},toLocaleString($,Z,J){let[j,W]=zG(Z,J,$);return j.format(W)},toString:f2,toJSON:($)=>f2($),valueOf:n1},{from:($,Z)=>s1(XZ($,Z)),compare:($,Z)=>Q$(XZ($),XZ(Z))}),[NG,B0]=Y1(V$,R(wz,D0),{...U3,...Y4,...z4},{getISOFields:B3,getCalendar:K3,with($,Z,J){return B0(Hz(D3,$,this,KZ(Z),J))},withCalendar:($,Z)=>B0(A6($,D0(Z))),withPlainDate:($,Z)=>B0(O9($,S0(Z))),withPlainTime:($,Z)=>B0(z9($,J4(Z))),add:($,Z,J)=>B0(y2(C$,0,$,o(Z),J)),subtract:($,Z,J)=>B0(y2(C$,1,$,o(Z),J)),until:($,Z,J)=>d(YJ(W1,0,$,u1(Z),J)),since:($,Z,J)=>d(YJ(W1,1,$,u1(Z),J)),round:($,Z)=>B0(UY($,Z)),equals:($,Z)=>$z($,u1(Z)),toZonedDateTime:($,Z,J)=>W0(lz(l,$,u(Z),J)),toPlainDate:($)=>r(j0($)),toPlainTime:($)=>i1(s0($)),toPlainYearMonth($){return s1(dz(n6,$,this))},toPlainMonthDay($){return GZ(uz(o6,$,this))},toLocaleString($,Z,J){let[j,W]=jG(Z,J,$);return j.format(W)},toString:S2,toJSON:($)=>S2($),valueOf:n1},{from:($,Z)=>B0(u1($,Z)),compare:($,Z)=>JJ(u1($),u1(Z))}),[LG,r,O5]=Y1(T$,R(kz,D0),{...U3,...Y4},{getISOFields:B3,getCalendar:K3,with($,Z,J){return r(Sz(D3,$,this,KZ(Z),J))},withCalendar:($,Z)=>r(A6($,D0(Z))),add:($,Z,J)=>r(m2(C$,0,$,o(Z),J)),subtract:($,Z,J)=>r(m2(C$,1,$,o(Z),J)),until:($,Z,J)=>d(zJ(W1,0,$,S0(Z),J)),since:($,Z,J)=>d(zJ(W1,1,$,S0(Z),J)),equals:($,Z)=>Zz($,S0(Z)),toZonedDateTime($,Z){let J=!X0(Z)||Z instanceof s6?{timeZone:Z}:Z;return W0(iz(u,d1,l,$,J))},toPlainDateTime:($,Z)=>B0(sz($,J4(Z))),toPlainYearMonth($){return s1(nz(n6,$,this))},toPlainMonthDay($){return GZ(az(o6,$,this))},toLocaleString($,Z,J){let[j,W]=WG(Z,J,$);return j.format(W)},toString:x2,toJSON:($)=>x2($),valueOf:n1},{from:($,Z)=>r(S0($,Z)),compare:($,Z)=>Q$(S0($),S0(Z))}),O4={fields($,Z,J){return[...Z.call($,J)]}},X5=Object.assign({dateFromFields($,Z,J,j){return O5(Z.call($,Object.assign(Object.create(null),J),j))}},O4),F5=Object.assign({yearMonthFromFields($,Z,J,j){return IG(Z.call($,Object.assign(Object.create(null),J),j))}},O4),G5=Object.assign({monthDayFromFields($,Z,J,j){return BG(Z.call($,Object.assign(Object.create(null),J),j))}},O4),X4={mergeFields($,Z,J,j){return V1(Z.call($,Object.assign(Object.create(null),J),Object.assign(Object.create(null),j)))}},_G=Object.assign({},X5,X4),PG=Object.assign({},F5,X4),HG=Object.assign({},G5,X4),F4={dateAdd($,Z,J,j,W){return O5(Z.call($,r(j0(J,$)),d(i(j)),W))}},K5=Object.assign({},F4,{dateUntil($,Z,J,j,W,Y){return bG(Z.call($,r(j0(J,$)),r(j0(j,$)),Object.assign(Object.create(null),Y,{largestUnit:Y3[W]})))}}),SG=Object.assign({},F4,{day:Z5}),xG=Object.assign({},K5,{day:Z5}),n6=z1(F5),a6=z1(X5),o6=z1(G5),fG=z1(PG),D3=z1(_G),EG=z1(HG),C$=z1(F4),W1=z1(K5),r9=z1(SG),t9=z1(xG),[AG,d,bG]=Y1(p6,mz,{...QG,blank:bY},{with:($,Z)=>d(Az($,Z)),negated:($)=>d(I6($)),abs:($)=>d(AY($)),add:($,Z,J)=>d(i2(G3,W1,l,0,$,o(Z),J)),subtract:($,Z,J)=>d(i2(G3,W1,l,1,$,o(Z),J)),round:($,Z)=>d(EY(G3,W1,l,$,Z)),total:($,Z)=>GY(G3,W1,l,$,Z),toLocaleString($,Z,J){return Intl.DurationFormat?new Intl.DurationFormat(Z,J).format(this):D6($)},toString:D6,toJSON:($)=>D6($),valueOf:n1},{from:($)=>d(o($)),compare:($,Z,J)=>rY(G3,C$,l,o($),o(Z),J)}),Q5={toString:($)=>$.id,toJSON:($)=>$.id,...XG,dateAdd:({id:$,o:Z},J,j,W)=>r(j0(Z.dateAdd(S0(J),o(j),W),$)),dateUntil:({o:$},Z,J,j)=>d(i($.dateUntil(S0(Z),S0(J),ZY(j)))),dateFromFields:({id:$,o:Z},J,j)=>r(KJ(Z,J,j,qW($))),yearMonthFromFields:({id:$,o:Z},J,j)=>s1(QJ(Z,J,j,wW($))),monthDayFromFields:({id:$,o:Z},J,j)=>GZ(UJ(Z,0,J,j,kW($))),fields({o:$},Z){let J=new Set(n0),j=[];for(let W of Z){if(a(W),!J.has(W))throw RangeError(LJ(W));J.delete(W),j.push(W)}return $.fields(j)},mergeFields:({o:$},Z,J)=>$.mergeFields(J2(Y2(Z)),J2(Y2(J)))},[G4]=Y1("Calendar",($)=>{let Z=Qz($);return{branding:"Calendar",id:Z,o:zZ(Z)}},{id:($)=>$.id},Q5,{from($){let Z=D0($);return typeof Z=="string"?new G4(Z):Z}}),vG=e9(Object.keys(Q5).slice(4)),[RG,W0]=Y1(L1,R(Rz,D0,u),{...Y5,...U3,...a9(Y4),...a9(z4),offset:($)=>F$(eJ($).offsetNanoseconds),offsetNanoseconds:($)=>eJ($).offsetNanoseconds,timeZoneId:($)=>K0($.timeZone),hoursInDay:($)=>DY(l,$)},{getISOFields:($)=>xY(Y0,$),getCalendar:K3,getTimeZone:({timeZone:$})=>typeof $=="string"?new s6($):$,with($,Z,J){return W0(Pz(D3,l,$,this,KZ(Z),J))},withCalendar:($,Z)=>W0(A6($,D0(Z))),withTimeZone:($,Z)=>W0(X9($,u(Z))),withPlainDate:($,Z)=>W0(Y9(l,$,S0(Z))),withPlainTime:($,Z)=>W0(W9(l,$,J4(Z))),add:($,Z,J)=>W0(g2(C$,l,0,$,o(Z),J)),subtract:($,Z,J)=>W0(g2(C$,l,1,$,o(Z),J)),until:($,Z,J)=>d(i(WJ(W1,l,0,$,FZ(Z),J))),since:($,Z,J)=>d(i(WJ(W1,l,1,$,FZ(Z),J))),round:($,Z)=>W0(QY(l,$,Z)),startOfDay:($)=>W0(TY(l,$)),equals:($,Z)=>eY($,FZ(Z)),toInstant:($)=>H0(pz($)),toPlainDateTime:($)=>B0(VJ(Y0,$)),toPlainDate:($)=>r(MJ(Y0,$)),toPlainTime:($)=>i1(CJ(Y0,$)),toPlainYearMonth($){return s1(hz(n6,$,this))},toPlainMonthDay($){return GZ(cz(o6,$,this))},toLocaleString($,Z,J={}){let[j,W]=JG(Z,J,$);return j.format(W)},toString:($,Z)=>H2(Y0,$,Z),toJSON:($)=>H2(Y0,$),valueOf:n1},{from:($,Z)=>W0(FZ($,Z)),compare:($,Z)=>ZJ(FZ($),FZ(Z))}),wG=Object.defineProperties({},{...e3("Temporal.Now"),...z$({timeZoneId:()=>I1(),instant:()=>H0(F0(J3())),zonedDateTime:($,Z=I1())=>W0(U0(J3(),u(Z),D0($))),zonedDateTimeISO:($=I1())=>W0(U0(J3(),u($),k)),plainDateTime:($,Z=I1())=>B0(J0(JZ(Y0(u(Z))),D0($))),plainDateTimeISO:($=I1())=>B0(J0(JZ(Y0(u($))),k)),plainDate:($,Z=I1())=>r(j0(JZ(Y0(u(Z))),D0($))),plainDateISO:($=I1())=>r(j0(JZ(Y0(u($))),k)),plainTimeISO:($=I1())=>i1(s0(JZ(Y0(u($)))))})}),QZ=Object.defineProperties({},{...e3("Temporal"),...z$({PlainYearMonth:CG,PlainMonthDay:UG,PlainDate:LG,PlainTime:MG,PlainDateTime:NG,ZonedDateTime:RG,Instant:DG,Calendar:G4,TimeZone:s6,Duration:AG,Now:wG})}),kG=oF(),K4=new WeakMap,qG=Object.defineProperties(Object.create(Intl),z$({DateTimeFormat:kG}));var Q4=new WeakMap;function yG($){let Z=Q4.get($);if(!Z)Z=$(gG(32).toString("hex")),Q4.set($,Z),Z.catch(()=>Q4.delete($));return Z}async function U4($,Z,J){if(typeof J==="string"&&J!=="")return await $.verifyPassword(Z,J);try{await $.verifyPassword(Z,await yG($.hashPassword))}catch{}return!1}async function I$($,Z){let J=Z.user??Z.session?.user;if(!J||!$.onAuthenticated)return;let{password:j,...W}=J;await $.onAuthenticated({...Z,user:W})}class T4 extends Error{}function B4($){return typeof $==="string"&&$!==""?$:null}function U5($){return gZ($)}var mG=256;function B5($){return typeof $==="string"&&$!==""&&$.length<=mG?$:null}var D4="intended_url";class V4 extends E{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class D5 extends E{schema={email:{required:"Email is required",email:"Invalid email"}}}class T5 extends E{schema={password:{required:"Password is required",password:"Invalid password"}}}class s extends f8{async me(){let $=await N$.user();if(!$)throw new E8;return $}async verifyEmail($=new E){let Z=await $.input(),{userProvider:J}=I(A),j=B4(Z.get("token"));if(!j)return{email:null};let W=await J.findUserByVerificationToken(j);if(!W)return{email:null};return await J.verifyUser(W.email),{email:W.email}}async signInWithMagicLink($=new E){let Z=I(A),{userProvider:J}=Z,j=B4($.search.get("token")),W=null;try{W=gZ(decodeURIComponent($.search.get("email")??""))}catch{}if(await h$("link",null,$,{perIp:Z.config.emailCode.verifyLimit.perIp}),!W||!j||!await Z.verifyMagicLinkToken(W,j))return{error:"Invalid token"};await J.verifyUser(W);let Y=await Z.createOrUpdateSession({email:W});return $.ctx().setCookie("access_token",Y.token,I(A).accessTokenCookieOptions($,Y.expiresAt)),await Z.config.onSignIn(Y,$.search.toJSON()),await I$(Z.config,{session:Y,isNewUser:!1,method:"magic-link",req:$}),{session:Y}}async verifyPinRequest($){let Z=I(A),J=await $.input(),{email:j,pin:W}=J.toJSON(),Y=gZ(j),z=B5(W);if(await h$("verify",Y,$,Z.config.emailCode.verifyLimit),!Y||!z)throw new h({pin:["Invalid pin"]});let O=await Z.verifyOneTimeCode(Y,z);if(O.status==="too_many_attempts")throw new h({pin:["Too many attempts"]});if(O.status!=="ok")throw new h({pin:["Invalid pin"]});return await Z.userProvider.verifyUser(Y),Y}async signInWithPinV2($=new E){let Z=I(A),J=await this.verifyPinRequest($),j=await Z.createOrUpdateSessionV2({email:J});return $.ctx().setCookie("access_token",j.token,I(A).accessTokenCookieOptions($,j.expiresAt)),await Z.config.onSignIn(j,$.search.toJSON()),await I$(Z.config,{session:j,isNewUser:!1,method:"magic-link",req:$}),j}async signInWithPin($=new E){let Z=I(A),J=await this.verifyPinRequest($),j=await Z.createOrUpdateSession({email:J});return $.ctx().setCookie("access_token",j.token,I(A).accessTokenCookieOptions($,j.expiresAt)),await Z.config.onSignIn(j,$.search.toJSON()),await I$(Z.config,{session:j,isNewUser:!1,method:"magic-link",req:$}),{session:j}}async signInV2($=new V4){let Z=await $.input(),{email:J,password:j}=Z.toJSON(),W=J.toLowerCase().trim(),Y=I(A),z=await Y.userProvider.findUserByEmailAddress(W,Y.config.verifyEmail),O=typeof j==="string"&&await U4(Y.config,j,z?.password);if(!z||!O)throw new h({invalid_credentials:["Invalid credentials"]});let X=await Y.createOrUpdateSessionV2({email:z.email,id:z.id});$.ctx().setCookie("access_token",X.token,I(A).accessTokenCookieOptions($,X.expiresAt)),await Y.config.onSignIn(z,$.search.toJSON()),await I$(Y.config,{session:X,user:z,isNewUser:!1,method:"password",req:$});let{password:F,...G}=z;return G}async signIn($=new V4){let Z=await $.input(),{email:J,password:j}=Z.toJSON(),W=J.toLowerCase().trim(),Y=I(A),z=await Y.userProvider.findUserByEmailAddress(W,Y.config.verifyEmail),O=typeof j==="string"&&await U4(Y.config,j,z?.password);if(!z||!O)throw new h({invalid_credentials:["Invalid credentials"]});let X=await Y.createOrUpdateSession({email:z.email,id:z.id});$.ctx().setCookie("access_token",X.token,I(A).accessTokenCookieOptions($,X.expiresAt)),await Y.config.onSignIn(z,$.search.toJSON()),await I$(Y.config,{session:X,user:z,isNewUser:!1,method:"password",req:$});let{password:F,...G}=z;return G}async signUp(){let $=I(A),{userProvider:Z,config:J}=$,j=new J.signUpRequest,W=await j.input(),{email:Y,password:z,name:O,invitationId:X}=W.toJSON(),F=U5(Y);if(!F)throw new h({email:["Invalid email"]});if(z!=null&&typeof z!=="string")throw new h({password:["Invalid password"]});if(X!=null&&typeof X!=="string")throw new h({invitationId:["Invalid invitation"]});if(await Z.findUserByEmailAddress(F,!1))throw new h({email:["Email address already exists"]});let K=await J.hashPassword(z),Q=I(n).detectLocale(j),U;if(X)U=await Z.findInvitation(X,F);let B,D="";if(U)B=await Z.transaction(async()=>{await Z.deleteInvitationById(X);let T=await Z.createUser({email:F,name:O,password:K,emailVerifiedAt:new Date,locale:Q});return await Z.createAccount({organizationId:U.organizationId,userId:T.id,organizationRole:U.role}),await J.onUserCreated(T),T});else D=await J.generateEmailVerificationToken(F),B=await Z.transaction(async()=>{let T=await Z.createUser({email:F,name:O,password:K,verificationToken:D,locale:Q});return await J.onUserCreated(T),T});return await J.onSignUp(B,D,j.search.toJSON()),B}async signOut($=new E){let Z=S8($),J=I(A),{config:j}=J,W=await J.revokeSession(Z,$.headers.get("User-Agent"));if($.ctx().setCookie("access_token","",I(A).accessTokenCookieOptions($,new Date(0))),I(A).cookieDomain($))$.ctx().setCookie("access_token","",{...I(A).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(W?.user)W.user.extension=await j.extendSession(W.user),await j.onSignOut(W.user);return{}}async forgotPassword($=new D5){let Z=await $.input(),J=U5(Z.get("email"));if(!J)return{};let{userProvider:j,config:W}=I(A),Y=await j.findUserByEmailAddress(J,W.verifyEmail);if(!Y)return{};let z=await W.generateForgotPasswordToken(Y);return await j.createPasswordResetToken({user:Y,token:z}),await W.onForgotPassword(Y,z),{}}async resetPassword($=new T5){let{userProvider:Z,config:J}=I(A),j=await $.input(),{password:W,token:Y}=j.toJSON(),z=B4(Y),O=z?await Z.findPasswordResetToken({token:z}):null;if(!O)throw new h({token:["Invalid token"]});if(QZ.Instant.from(O.createdAt.toISOString()).add({hours:24}).until(QZ.Now.instant()).sign>=0)throw new h({token:["Token expired"]});await Z.deletePasswordResetToken({token:z});let F=await Z.findUserByEmailAddress(O.user.email,J.verifyEmail);if(!F)throw new h({email:["User not found"]});let G=await J.hashPassword(W);return await Z.updateUserPassword({id:F.id,password:G}),await Z.deleteAllUserSessions(F.id),await J.onResetPassword(F),{}}async changePassword($=new E){let{userProvider:Z,config:J}=I(A),j=await N$.user(),W=await $.input(),{oldPassword:Y,newPassword:z}=W.toJSON();if(typeof z!=="string")throw new h({newPassword:["Invalid password"]});let O=await Z.findUserByEmailAddress(j.email,J.verifyEmail);if(!(typeof Y==="string"&&await U4(J,Y,O?.password)))throw new h({oldPassword:["Incorrect password"]});let F=await J.hashPassword(z);return await Z.updateUserPassword({id:j.id,password:F}),await Z.deleteAllUserSessions(j.id),{}}async oauthRedirect($=new E){let{provider:Z}=$.params,J=I(A).config.oauthProviders[Z];if(!J)throw Error(`Invalid provider: ${Z}`);let j=fZ($.search.get(v$),"");if(j)$.ctx().setCookie(D4,encodeURIComponent(j),{httpOnly:!0,sameSite:"Lax",secure:Aj($.rawRequest),maxAge:600});return{destination:await J.getRedirectUrl($)}}async oauthCallback($=new E){let{provider:Z}=$.params,J=I(A),{userProvider:j,config:W}=J,Y=W.oauthProviders[Z],{email:z,name:O,username:X,providerId:F}=await Y.onCallback($),G=F?await j.findUserBySocialAccount(Z,F):null,K="signin";if(!G){if(!z)return console.error("Authentication error: No email returned from OAuth provider callback"),{session:null};let D=I(n).detectLocale($);try{let T=await this.linkOAuthAccount({provider:Z,providerId:F,email:z,name:O,username:X,locale:D});if(T)G=T.user,K=T.action}catch(T){let M=F?await j.findUserBySocialAccount(Z,F):null;if(!M)throw T;G=M}if(!G)return{session:null}}let Q=await J.createOrUpdateSessionV2({email:G.email,id:G.id});if($.ctx().setCookie("access_token",Q.token,I(A).accessTokenCookieOptions($,Q.expiresAt)),K==="signup")await W.onSignUp(G,"",$.search.toJSON());else await W.onSignIn(G,$.search.toJSON());await I$(J.config,{session:Q,user:G,isNewUser:K==="signup",method:"oauth",req:$});let U=$.cookies.get(D4),B=W.redirectPath;if(U){try{B=fZ(decodeURIComponent(U),B)}catch{}$.ctx().setCookie(D4,"",{maxAge:-1})}return{session:Q,redirectTo:B}}async linkOAuthAccount($){let{provider:Z,providerId:J,email:j,name:W,username:Y,locale:z}=$,{userProvider:O,config:X}=I(A),F=(Q)=>({provider:Z,userId:Q,email:j,username:Y,providerId:J,expiresAt:new Date,accessToken:"",refreshToken:""}),G=await O.findUserByEmailAddress(j,!1);if(G){if(!J)return{user:G,action:"signin"};let Q=await O.findSocialAccounts(G.id,Z);if(Q.some((B)=>B.providerId===J))return{user:G,action:"signin"};if(Q.some((B)=>B.providerId))return console.error(`Authentication error: user ${G.id} is already linked to a different ${Z} account`),null;let U=Q[0];if(U){if(!await O.claimSocialAccount(U,J))throw Error(`${Z} account link changed concurrently`)}else await O.createSocialAccount(F(G.id));return{user:G,action:"signin"}}return{user:await O.transaction(async()=>{let Q=await O.createUser({email:j,name:W,locale:z,emailVerifiedAt:new Date});if(J)await O.createSocialAccount(F(Q.id));return await X.onUserCreated(Q),Q}),action:"signup"}}async createMagicLinkToken($=new E){let Z=await $.input(),J=gZ(Z.get("email")),j=I(A),{uniformMagicLinkResponse:W,requestLimit:Y}=j.config.emailCode;if(await h$("request",J,$,Y),!J)return{email:null};let{user:z,pin:O,token:X}=await j.createMagicLinkToken(J);if(z)return await j.config.onMagicLinkCreated(z,{email:J,pin:O,token:X}),{email:J};return{email:W?J:null}}async requestEmailCode($=new E){let Z=I(A),J=Z.config.emailCode;if(!J.enabled)throw new q0("Not found",{status:404});let j=await $.input(),W=q8(j.get("email"));if(await h$("request",W,$,J.requestLimit),!W)throw new h({email:["Invalid email"]});let Y=await Z.userProvider.findUserByEmailAddress(W,!1);if(Y||J.createUser){let{pin:z,token:O}=await Z.issueOneTimeCode(W,J.length);await J.send({email:W,code:z,token:O,isNewUser:!Y,req:$})}return{ok:!0}}async verifyEmailCode($=new E){let Z=I(A),{userProvider:J,config:j}=Z;if(!j.emailCode.enabled)throw new q0("Not found",{status:404});let W=await $.input(),{email:Y,code:z,name:O}=W.toJSON(),X=q8(Y),F=B5(z);if(await h$("verify",X,$,j.emailCode.verifyLimit),!X||!F)throw new h({code:["invalid_code"]});let G=await Z.verifyOneTimeCode(X,F,{claim:!1});if(G.status==="too_many_attempts")throw new h({code:["too_many_attempts"]});if(G.status!=="ok")throw new h({code:["invalid_code"]});let K=G.row,Q=await J.findUserByEmailAddress(X,!1),U=!1;if(Q){if(!await J.claimMagicLinkToken(K.id))throw new h({code:["invalid_code"]});await J.verifyUser(X)}else if(j.emailCode.createUser){let D=I(n).detectLocale($);try{Q=await J.transaction(async()=>{if(!await J.claimMagicLinkToken(K.id))throw new T4;let T=await J.createUser({email:X,name:typeof O==="string"?O.trim():"",emailVerifiedAt:new Date,locale:D});return await j.onUserCreated(T),T}),U=!0}catch(T){if(T instanceof T4)throw new h({code:["invalid_code"]});throw T}}else throw await J.claimMagicLinkToken(K.id),new h({code:["invalid_code"]});let B=await Z.createOrUpdateSessionV2({email:X,id:Q.id});return $.ctx().setCookie("access_token",B.token,I(A).accessTokenCookieOptions($,B.expiresAt)),await j.onSignIn(B,$.search.toJSON()),await I$(Z.config,{session:B,isNewUser:U,method:"email-code",req:$}),{session:B,isNewUser:U}}}class V5 extends f1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[s,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[s,"oauthCallback"])}}class M4 extends f1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[s,"signInWithMagicLink"]),"/oauth":V5}}class C4 extends x0{middlewares=["cache:private"];routes={"/sign-in":this.post(s,"signIn"),"/sign-in-v2":this.post(s,"signInV2"),"/sign-up":this.post(s,"signUp"),"/sign-out":this.post(s,"signOut"),"/forgot-password":this.post(s,"forgotPassword"),"/reset-password":this.post(s,"resetPassword"),"/change-password":this.post(s,"changePassword"),"/verify-email":this.post(s,"verifyEmail"),"/me":this.get(s,"me").middleware(["auth"]),"/magic-link":this.post(s,"createMagicLinkToken"),"/sign-in-with-pin":this.post(s,"signInWithPin"),"/sign-in-with-pin-v2":this.post(s,"signInWithPinV2"),"/email-code":this.post(s,"requestEmailCode"),"/email-code/verify":this.post(s,"verifyEmailCode")}}class I4 extends x0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let Z=new E().params.locale;return await I(n).onLocaleChange(Z),{locale:Z}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new E,Z=`/${$.params.scope??""}`,J=$.params.locale,j=I(n),W=J??j.detectLocale($),Y=j.getPageTranslations(W,Z);return $.ctx().setCookie("i18n-locale",W,{expires:new Date(Date.now()+31536000000)}),{[W]:Y}})}}class N4{}class L4 extends N4{async resize($,Z){let{height:J,width:j,quality:W,fit:Y}=Z;return await(await r6("The Sharp image optimization driver"))($).resize(j>0?j:void 0,J>0?J:void 0,{fit:Y}).webp({quality:W>0?W:80,force:!0}).toBuffer()}}function XD($){return $}function M5(){return{driver:new L4}}class _4 extends x0{routes={"/resize":this.file(async()=>{let $=new E,Z=new URL($.rawRequest.url),J=Z.searchParams.get("url"),j=Number(Z.searchParams.get("w")),W=Number(Z.searchParams.get("h")),Y=Z.searchParams.get("fit")??"cover",z=Number(Z.searchParams.get("q"));if(!J)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let X=`${J.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${J}`,F=await fetch(X);if(!F.ok)return new Response(JSON.stringify({error:"Image not found",info:X}),{headers:{"Content-Type":"application/json"},status:404});let G=Buffer.from(await F.arrayBuffer()),K=await I(C5).resize(G,{height:W,width:j,fit:Y,quality:z});F.headers.delete("Content-Type"),F.headers.delete("Content-Length");let Q=new Headers(F.headers);return Q.set("Content-Type","image/webp"),Q.set("Content-Length",`${K.byteLength}`),new Response(new Uint8Array(K),{headers:Q})})}}class C5{static token="image";driver;constructor($={}){this.driver=$.driver??M5().driver}resize($,Z){return this.driver.resize($,Z)}}class P4 extends x0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(I(I5).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function pG($){let Z=new Map;for(let J of $)if(typeof J==="string"){let[j,W=""]=J.split(":");if(j.startsWith("-")){if(Z.has(j.replace("-","")))Z.delete(j.replace("-",""))}else Z.set(j,W.split(",").filter(Boolean))}else Z.set(J,[]);return Z}var hG={"body-limit":R3};class UZ{config;static token="middleware";defaultBodyLimit;constructor($){this.config=$;this.defaultBodyLimit=$.bodyLimit===null||$.bodyLimit===void 0?null:xZ($.bodyLimit)}get aliases(){return{...hG,...this.config.aliases}}applyDefaultBodyLimit($){if(this.defaultBodyLimit!==null&&!Uj($))E3($,this.defaultBodyLimit,{checkDeclared:!1})}assertGlobalMiddleware(){for(let $ of this.config.global){if(typeof $!=="string")continue;let[Z]=$.split(":");if(Z.startsWith("-"))throw Error(`Global middleware "${$}" cancels an alias, but nothing is inherited into the global list. Remove it.`);if(!this.aliases[Z])throw Error(`Global middleware "${Z}" is not a registered alias. Add it to \`aliases\` in the middleware config, or list the class itself.`)}}runGlobalMiddleware(){return this.runMiddleware(this.config.global)}runMiddleware($){let Z=new E,J=this.aliases,j=[];for(let[W,Y]of pG($).entries())if(typeof W==="string"){let z=J[W];if(z){let O=new z(Z);j.push({run:()=>O.run.call(O,...Y),runsOnRefusal:N5(z)})}}else if(x3(W)){let z=new W(Z);j.push({run:z.run.bind(z),runsOnRefusal:N5(W)})}else j.push({run:W,runsOnRefusal:!1});return(async()=>{let W={};for(let Y=0;Y<j.length;Y++)try{W={...W,...await j[Y].run()}}catch(z){throw await cG(j.slice(Y+1)),z}return W})()}}function N5($){return $?.runsOnRefusal===!0}async function cG($){for(let Z of $){if(!Z.runsOnRefusal)continue;try{await Z.run()}catch(J){console.error(J)}}}function PD($){return $}function L5(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function _5(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function lG($){return"run"in $}function dG($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"patch")||Object.hasOwn($,"delete")}function uG($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function iG($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function sG($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function P5($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function H4($,Z="",J=[]){let j={};function W(Y,z,O,X,F){let G=Y==="/"?"":Y,K=Z==="/"?"":Z,Q=(`${K}${G}`===""?"/":`${K}${G}`).replaceAll("//","/");if(!j[Q])j[Q]={};j[Q][z.toUpperCase()]={exec:O,middleware:[...J,...X],...F?{source:F}:{}},j[Q].OPTIONS={exec:()=>{let B=new E().ctx().headers;return new Response(null,{headers:B,status:204})},middleware:[]}}for(let[Y,z]of Object.entries($)){if(sG(z)){let O=z;for(let X of["GET","POST","PUT","DELETE"])W(Y,X,O.run.bind(O),O.middlewares);continue}if(lG(z)){let O=z,X=O.method,F=O.middlewares,G=O.run.bind(O);if(W(Y,X,G,F,O.source),P5(z))W(Y,"HEAD",G,F,O.source)}if(dG(z))for(let[O,X]of Object.entries(z)){let F=X,G=F.middlewares,K=F.run.bind(F);if(W(Y,O,K,G,F.source),O==="get"&&P5(F))W(Y,"HEAD",K,G,F.source)}if(iG(z)){let O=new z,X=H4(O.routes,`${Z}${Y}`,O.middlewares);for(let[F,G]of Object.entries(X))j[F.replaceAll("//","/")]=G}if(uG(z)){let{first:O,second:X}=z;for(let[F,G]of Object.entries(O)){let K=G.middlewares,Q=G.run.bind(G),[U,...B]=Y.split("/").reverse();if(!U.startsWith(":"))throw Error("Resource route must end with a dynamic segment");W(B.reverse().join("/"),F,Q,K,G.source)}for(let[F,G]of Object.entries(X)){let K=G.middlewares,Q=G.run.bind(G);W(Y,F,Q,K,G.source)}}}return Object.fromEntries(Object.entries(j).sort(([Y],[z])=>{let O=Y.split("/").length+Y.split(":").length,X=z.split("/").length+z.split(":").length;return O-X}))}function t6($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function S4($,Z){if($==="/")return Z;if(Z==="/")return $;return`${$}${Z}`}function x4($){let Z=t6($);return Z.length>1?Z.replace(/\/$/,""):Z}function H5($,Z){return Z.map((J)=>({...J,path:x4(S4($,J.path))}))}function e6($){let Z={};for(let[J,j]of Object.entries($))if("run"in j){let W=j;if("children"in W){let Y=new W.children,z=e6(Y.routes);for(let[O,{exec:X,middleware:F,segments:G,features:K,static:Q}]of Object.entries(z)){let U=S4(J,O),B=(D)=>W.run.call(W,D,J);Z[t6(U)]={exec:[B,...X],middleware:[...W.middlewares,...F],features:[...W.featureGates,...K],viewPath:W.viewPath,segments:[{path:x4(J),viewPath:W.viewPath,...W.alwaysRuns?{alwaysRun:!0}:{}},...H5(J,G)],...Q?{static:Q}:{}}}}else{let Y=(z)=>W.run.call(W,z,J);Z[t6(J)]={exec:[Y],middleware:W.middlewares,features:W.featureGates,viewPath:W.viewPath,segments:[{path:x4(J),viewPath:W.viewPath}],..."staticOptions"in W&&W.staticOptions?{static:W.staticOptions}:{}}}}else{let W=new j,Y=e6(W.routes);for(let[z,{exec:O,middleware:X,viewPath:F,segments:G,features:K,static:Q}]of Object.entries(Y)){let U=S4(J,z);Z[t6(U)]={exec:O,middleware:[...W.middlewares,...X],features:[...W.featureGates,...K],viewPath:F,segments:H5(J,G),...Q?{static:Q}:{}}}}return Object.fromEntries(Object.entries(Z).sort(([J],[j])=>{let W=J.split("/").length+J.split(":").length,Y=j.split("/").length+j.split(":").length;return W-Y}))}var nG=Object.defineProperty,S=($,Z)=>nG($,"name",{value:Z,configurable:!0}),TZ=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,Z,J,j,W,Y){this.type=$,this.name=Z,this.prefix=J,this.value=j,this.suffix=W,this.modifier=Y}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};S(TZ,"Part");var aG=/[$_\p{ID_Start}]/u,oG=/[$_\u200C\u200D\p{ID_Continue}]/u,E4=".*";function S5($,Z){return(Z?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}S(S5,"isASCII");function v4($,Z=!1){let J=[],j=0;for(;j<$.length;){let W=$[j],Y=S(function(z){if(!Z)throw TypeError(z);J.push({type:"INVALID_CHAR",index:j,value:$[j++]})},"ErrorOrInvalid");if(W==="*"){J.push({type:"ASTERISK",index:j,value:$[j++]});continue}if(W==="+"||W==="?"){J.push({type:"OTHER_MODIFIER",index:j,value:$[j++]});continue}if(W==="\\"){J.push({type:"ESCAPED_CHAR",index:j++,value:$[j++]});continue}if(W==="{"){J.push({type:"OPEN",index:j,value:$[j++]});continue}if(W==="}"){J.push({type:"CLOSE",index:j,value:$[j++]});continue}if(W===":"){let z="",O=j+1;for(;O<$.length;){let X=$.substr(O,1);if(O===j+1&&aG.test(X)||O!==j+1&&oG.test(X)){z+=$[O++];continue}break}if(!z){Y(`Missing parameter name at ${j}`);continue}J.push({type:"NAME",index:j,value:z}),j=O;continue}if(W==="("){let z=1,O="",X=j+1,F=!1;if($[X]==="?"){Y(`Pattern cannot start with "?" at ${X}`);continue}for(;X<$.length;){if(!S5($[X],!1)){Y(`Invalid character '${$[X]}' at ${X}.`),F=!0;break}if($[X]==="\\"){O+=$[X++]+$[X++];continue}if($[X]===")"){if(z--,z===0){X++;break}}else if($[X]==="("&&(z++,$[X+1]!=="?")){Y(`Capturing groups are not allowed at ${X}`),F=!0;break}O+=$[X++]}if(F)continue;if(z){Y(`Unbalanced pattern at ${j}`);continue}if(!O){Y(`Missing pattern at ${j}`);continue}J.push({type:"REGEX",index:j,value:O}),j=X;continue}J.push({type:"CHAR",index:j,value:$[j++]})}return J.push({type:"END",index:j,value:""}),J}S(v4,"lexer");function R4($,Z={}){let J=v4($);Z.delimiter??="/#?",Z.prefixes??="./";let j=`[^${w0(Z.delimiter)}]+?`,W=[],Y=0,z=0,O="",X=new Set,F=S((C)=>{if(z<J.length&&J[z].type===C)return J[z++].value},"tryConsume"),G=S(()=>F("OTHER_MODIFIER")??F("ASTERISK"),"tryConsumeModifier"),K=S((C)=>{let H=F(C);if(H!==void 0)return H;let{type:P,index:_}=J[z];throw TypeError(`Unexpected ${P} at ${_}, expected ${C}`)},"mustConsume"),Q=S(()=>{let C="",H;for(;H=F("CHAR")??F("ESCAPED_CHAR");)C+=H;return C},"consumeText"),U=S((C)=>C,"DefaultEncodePart"),B=Z.encodePart||U,D="",T=S((C)=>{D+=C},"appendToPendingFixedValue"),M=S(()=>{D.length&&(W.push(new TZ(3,"","",B(D),"",3)),D="")},"maybeAddPartFromPendingFixedValue"),L=S((C,H,P,_,V)=>{let N=3;switch(V){case"?":N=1;break;case"*":N=0;break;case"+":N=2;break}if(!H&&!P&&N===3){T(C);return}if(M(),!H&&!P){if(!C)return;W.push(new TZ(3,"","",B(C),"",N));return}let x;P?P==="*"?x=E4:x=P:x=j;let v=2;x===j?(v=1,x=""):x===E4&&(v=0,x="");let y;if(H?y=H:P&&(y=Y++),X.has(y))throw TypeError(`Duplicate name '${y}'.`);X.add(y),W.push(new TZ(v,y,B(C),x,B(_),N))},"addPart");for(;z<J.length;){let C=F("CHAR"),H=F("NAME"),P=F("REGEX");if(!H&&!P&&(P=F("ASTERISK")),H||P){let V=C??"";Z.prefixes.indexOf(V)===-1&&(T(V),V=""),M();let N=G();L(V,H,P,"",N);continue}let _=C??F("ESCAPED_CHAR");if(_){T(_);continue}if(F("OPEN")){let V=Q(),N=F("NAME"),x=F("REGEX");!N&&!x&&(x=F("ASTERISK"));let v=Q();K("CLOSE");let y=G();L(V,N,x,v,y);continue}M(),K("END")}return W}S(R4,"parse");function w0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}S(w0,"escapeString");function A4($){return $&&$.ignoreCase?"ui":"u"}S(A4,"flags");function x5($,Z,J){return w4(R4($,J),Z,J)}S(x5,"stringToRegexp");function L$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}S(L$,"modifierToString");function w4($,Z,J={}){J.delimiter??="/#?",J.prefixes??="./",J.sensitive??=!1,J.strict??=!1,J.end??=!0,J.start??=!0,J.endsWith="";let j=J.start?"^":"";for(let O of $){if(O.type===3){O.modifier===3?j+=w0(O.value):j+=`(?:${w0(O.value)})${L$(O.modifier)}`;continue}Z&&Z.push(O.name);let X=`[^${w0(J.delimiter)}]+?`,F=O.value;if(O.type===1?F=X:O.type===0&&(F=E4),!O.prefix.length&&!O.suffix.length){O.modifier===3||O.modifier===1?j+=`(${F})${L$(O.modifier)}`:j+=`((?:${F})${L$(O.modifier)})`;continue}if(O.modifier===3||O.modifier===1){j+=`(?:${w0(O.prefix)}(${F})${w0(O.suffix)})`,j+=L$(O.modifier);continue}j+=`(?:${w0(O.prefix)}`,j+=`((?:${F})(?:`,j+=w0(O.suffix),j+=w0(O.prefix),j+=`(?:${F}))*)${w0(O.suffix)})`,O.modifier===0&&(j+="?")}let W=`[${w0(J.endsWith)}]|$`,Y=`[${w0(J.delimiter)}]`;if(J.end)return J.strict||(j+=`${Y}?`),J.endsWith.length?j+=`(?=${W})`:j+="$",new RegExp(j,A4(J));J.strict||(j+=`(?:${Y}(?=${W}))?`);let z=!1;if($.length){let O=$[$.length-1];O.type===3&&O.modifier===3&&(z=J.delimiter.indexOf(O)>-1)}return z||(j+=`(?=${Y}|${W})`),new RegExp(j,A4(J))}S(w4,"partsToRegexp");var o1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},rG={delimiter:".",prefixes:"",sensitive:!0,strict:!0},tG={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function f5($,Z){return $.length?$[0]==="/"?!0:!Z||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}S(f5,"isAbsolutePathname");function k4($,Z){return $.startsWith(Z)?$.substring(Z.length,$.length):$}S(k4,"maybeStripPrefix");function E5($,Z){return $.endsWith(Z)?$.substr(0,$.length-Z.length):$}S(E5,"maybeStripSuffix");function q4($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}S(q4,"treatAsIPv6Hostname");var A5=["ftp","file","http","https","ws","wss"];function g4($){if(!$)return!0;for(let Z of A5)if($.test(Z))return!0;return!1}S(g4,"isSpecialScheme");function b5($,Z){if($=k4($,"#"),Z||$==="")return $;let J=new URL("https://example.com");return J.hash=$,J.hash?J.hash.substring(1,J.hash.length):""}S(b5,"canonicalizeHash");function v5($,Z){if($=k4($,"?"),Z||$==="")return $;let J=new URL("https://example.com");return J.search=$,J.search?J.search.substring(1,J.search.length):""}S(v5,"canonicalizeSearch");function R5($,Z){return Z||$===""?$:q4($)?p4($):m4($)}S(R5,"canonicalizeHostname");function w5($,Z){if(Z||$==="")return $;let J=new URL("https://example.com");return J.password=$,J.password}S(w5,"canonicalizePassword");function k5($,Z){if(Z||$==="")return $;let J=new URL("https://example.com");return J.username=$,J.username}S(k5,"canonicalizeUsername");function q5($,Z,J){if(J||$==="")return $;if(Z&&!A5.includes(Z))return new URL(`${Z}:${$}`).pathname;let j=$[0]=="/";return $=new URL(j?$:"/-"+$,"https://example.com").pathname,j||($=$.substring(2,$.length)),$}S(q5,"canonicalizePathname");function g5($,Z,J){return y4(Z)===$&&($=""),J||$===""?$:h4($)}S(g5,"canonicalizePort");function y5($,Z){return $=E5($,":"),Z||$===""?$:$8($)}S(y5,"canonicalizeProtocol");function y4($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}S(y4,"defaultPortForProtocol");function $8($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}S($8,"protocolEncodeCallback");function m5($){if($==="")return $;let Z=new URL("https://example.com");return Z.username=$,Z.username}S(m5,"usernameEncodeCallback");function p5($){if($==="")return $;let Z=new URL("https://example.com");return Z.password=$,Z.password}S(p5,"passwordEncodeCallback");function m4($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let Z=new URL("https://example.com");return Z.hostname=$,Z.hostname}S(m4,"hostnameEncodeCallback");function p4($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}S(p4,"ipv6HostnameEncodeCallback");function h4($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}S(h4,"portEncodeCallback");function h5($){if($==="")return $;let Z=new URL("https://example.com");return Z.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?Z.pathname.substring(2,Z.pathname.length):Z.pathname}S(h5,"standardURLPathnameEncodeCallback");function c5($){return $===""?$:new URL(`data:${$}`).pathname}S(c5,"pathURLPathnameEncodeCallback");function l5($){if($==="")return $;let Z=new URL("https://example.com");return Z.search=$,Z.search.substring(1,Z.search.length)}S(l5,"searchEncodeCallback");function d5($){if($==="")return $;let Z=new URL("https://example.com");return Z.hash=$,Z.hash.substring(1,Z.hash.length)}S(d5,"hashEncodeCallback");var u5=class{#W;#Z=[];#J={};#$=0;#Y=1;#F=0;#O=0;#U=0;#B=0;#D=!1;constructor($){this.#W=$}get result(){return this.#J}parse(){for(this.#Z=v4(this.#W,!0);this.#$<this.#Z.length;this.#$+=this.#Y){if(this.#Y=1,this.#Z[this.#$].type==="END"){if(this.#O===0){this.#C(),this.#G()?this.#j(9,1):this.#K()?this.#j(8,1):this.#j(7,0);continue}else if(this.#O===2){this.#Q(5);continue}this.#j(10,0);break}if(this.#U>0)if(this.#S())this.#U-=1;else continue;if(this.#H()){this.#U+=1;continue}switch(this.#O){case 0:this.#I()&&this.#Q(1);break;case 1:if(this.#I()){this.#E();let $=7,Z=1;this.#L()?($=2,Z=3):this.#D&&($=2),this.#j($,Z)}break;case 2:this.#V()?this.#Q(3):(this.#M()||this.#K()||this.#G())&&this.#Q(5);break;case 3:this.#_()?this.#j(4,1):this.#V()&&this.#j(5,1);break;case 4:this.#V()&&this.#j(5,1);break;case 5:this.#x()?this.#B+=1:this.#f()&&(this.#B-=1),this.#P()&&!this.#B?this.#j(6,1):this.#M()?this.#j(7,0):this.#K()?this.#j(8,1):this.#G()&&this.#j(9,1);break;case 6:this.#M()?this.#j(7,0):this.#K()?this.#j(8,1):this.#G()&&this.#j(9,1);break;case 7:this.#K()?this.#j(8,1):this.#G()&&this.#j(9,1);break;case 8:this.#G()&&this.#j(9,1);break;case 9:break;case 10:break}}this.#J.hostname!==void 0&&this.#J.port===void 0&&(this.#J.port="")}#j($,Z){switch(this.#O){case 0:break;case 1:this.#J.protocol=this.#X();break;case 2:break;case 3:this.#J.username=this.#X();break;case 4:this.#J.password=this.#X();break;case 5:this.#J.hostname=this.#X();break;case 6:this.#J.port=this.#X();break;case 7:this.#J.pathname=this.#X();break;case 8:this.#J.search=this.#X();break;case 9:this.#J.hash=this.#X();break;case 10:break}this.#O!==0&&$!==10&&([1,2,3,4].includes(this.#O)&&[6,7,8,9].includes($)&&(this.#J.hostname??=""),[1,2,3,4,5,6].includes(this.#O)&&[8,9].includes($)&&(this.#J.pathname??=this.#D?"/":""),[1,2,3,4,5,6,7].includes(this.#O)&&$===9&&(this.#J.search??="")),this.#N($,Z)}#N($,Z){this.#O=$,this.#F=this.#$+Z,this.#$+=Z,this.#Y=0}#C(){this.#$=this.#F,this.#Y=0}#Q($){this.#C(),this.#O=$}#T($){return $<0&&($=this.#Z.length-$),$<this.#Z.length?this.#Z[$]:this.#Z[this.#Z.length-1]}#z($,Z){let J=this.#T($);return J.value===Z&&(J.type==="CHAR"||J.type==="ESCAPED_CHAR"||J.type==="INVALID_CHAR")}#I(){return this.#z(this.#$,":")}#L(){return this.#z(this.#$+1,"/")&&this.#z(this.#$+2,"/")}#V(){return this.#z(this.#$,"@")}#_(){return this.#z(this.#$,":")}#P(){return this.#z(this.#$,":")}#M(){return this.#z(this.#$,"/")}#K(){if(this.#z(this.#$,"?"))return!0;if(this.#Z[this.#$].value!=="?")return!1;let $=this.#T(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#G(){return this.#z(this.#$,"#")}#H(){return this.#Z[this.#$].type=="OPEN"}#S(){return this.#Z[this.#$].type=="CLOSE"}#x(){return this.#z(this.#$,"[")}#f(){return this.#z(this.#$,"]")}#X(){let $=this.#Z[this.#$],Z=this.#T(this.#F).index;return this.#W.substring(Z,$.index)}#E(){let $={};Object.assign($,o1),$.encodePart=$8;let Z=x5(this.#X(),void 0,$);this.#D=g4(Z)}};S(u5,"Parser");var f4=["protocol","username","password","hostname","port","pathname","search","hash"],a1="*";function b4($,Z){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let J=new URL($,Z);return{protocol:J.protocol.substring(0,J.protocol.length-1),username:J.username,password:J.password,hostname:J.hostname,port:J.port,pathname:J.pathname,search:J.search!==""?J.search.substring(1,J.search.length):void 0,hash:J.hash!==""?J.hash.substring(1,J.hash.length):void 0}}S(b4,"extractValues");function O1($,Z){return Z?DZ($):$}S(O1,"processBaseURLString");function BZ($,Z,J){let j;if(typeof Z.baseURL=="string")try{j=new URL(Z.baseURL),Z.protocol===void 0&&($.protocol=O1(j.protocol.substring(0,j.protocol.length-1),J)),!J&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&($.username=O1(j.username,J)),!J&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&Z.password===void 0&&($.password=O1(j.password,J)),Z.protocol===void 0&&Z.hostname===void 0&&($.hostname=O1(j.hostname,J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&($.port=O1(j.port,J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&($.pathname=O1(j.pathname,J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&($.search=O1(j.search.substring(1,j.search.length),J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&Z.hash===void 0&&($.hash=O1(j.hash.substring(1,j.hash.length),J))}catch{throw TypeError(`invalid baseURL '${Z.baseURL}'.`)}if(typeof Z.protocol=="string"&&($.protocol=y5(Z.protocol,J)),typeof Z.username=="string"&&($.username=k5(Z.username,J)),typeof Z.password=="string"&&($.password=w5(Z.password,J)),typeof Z.hostname=="string"&&($.hostname=R5(Z.hostname,J)),typeof Z.port=="string"&&($.port=g5(Z.port,$.protocol,J)),typeof Z.pathname=="string"){if($.pathname=Z.pathname,j&&!f5($.pathname,J)){let W=j.pathname.lastIndexOf("/");W>=0&&($.pathname=O1(j.pathname.substring(0,W+1),J)+$.pathname)}$.pathname=q5($.pathname,$.protocol,J)}return typeof Z.search=="string"&&($.search=v5(Z.search,J)),typeof Z.hash=="string"&&($.hash=b5(Z.hash,J)),$}S(BZ,"applyInit");function DZ($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}S(DZ,"escapePatternString");function i5($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}S(i5,"escapeRegexpString");function s5($,Z){Z.delimiter??="/#?",Z.prefixes??="./",Z.sensitive??=!1,Z.strict??=!1,Z.end??=!0,Z.start??=!0,Z.endsWith="";let J=".*",j=`[^${i5(Z.delimiter)}]+?`,W=/[$_\u200C\u200D\p{ID_Continue}]/u,Y="";for(let z=0;z<$.length;++z){let O=$[z];if(O.type===3){if(O.modifier===3){Y+=DZ(O.value);continue}Y+=`{${DZ(O.value)}}${L$(O.modifier)}`;continue}let X=O.hasCustomName(),F=!!O.suffix.length||!!O.prefix.length&&(O.prefix.length!==1||!Z.prefixes.includes(O.prefix)),G=z>0?$[z-1]:null,K=z<$.length-1?$[z+1]:null;if(!F&&X&&O.type===1&&O.modifier===3&&K&&!K.prefix.length&&!K.suffix.length)if(K.type===3){let Q=K.value.length>0?K.value[0]:"";F=W.test(Q)}else F=!K.hasCustomName();if(!F&&!O.prefix.length&&G&&G.type===3){let Q=G.value[G.value.length-1];F=Z.prefixes.includes(Q)}F&&(Y+="{"),Y+=DZ(O.prefix),X&&(Y+=`:${O.name}`),O.type===2?Y+=`(${O.value})`:O.type===1?X||(Y+=`(${j})`):O.type===0&&(!X&&(!G||G.type===3||G.modifier!==3||F||O.prefix!=="")?Y+="*":Y+=`(${J})`),O.type===1&&X&&O.suffix.length&&W.test(O.suffix[0])&&(Y+="\\"),Y+=DZ(O.suffix),F&&(Y+="}"),O.modifier!==3&&(Y+=L$(O.modifier))}return Y}S(s5,"partsToPattern");var c4=class{#W;#Z={};#J={};#$={};#Y={};#F=!1;constructor($={},Z,J){try{let j;if(typeof Z=="string"?j=Z:J=Z,typeof $=="string"){let O=new u5($);if(O.parse(),$=O.result,j===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=j}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(j)throw TypeError("parameter 1 is not of type 'string'.")}typeof J>"u"&&(J={ignoreCase:!1});let W={ignoreCase:J.ignoreCase===!0},Y={pathname:a1,protocol:a1,username:a1,password:a1,hostname:a1,port:a1,search:a1,hash:a1};this.#W=BZ(Y,$,!0),y4(this.#W.protocol)===this.#W.port&&(this.#W.port="");let z;for(z of f4){if(!(z in this.#W))continue;let O={},X=this.#W[z];switch(this.#J[z]=[],z){case"protocol":Object.assign(O,o1),O.encodePart=$8;break;case"username":Object.assign(O,o1),O.encodePart=m5;break;case"password":Object.assign(O,o1),O.encodePart=p5;break;case"hostname":Object.assign(O,rG),q4(X)?O.encodePart=p4:O.encodePart=m4;break;case"port":Object.assign(O,o1),O.encodePart=h4;break;case"pathname":g4(this.#Z.protocol)?(Object.assign(O,tG,W),O.encodePart=h5):(Object.assign(O,o1,W),O.encodePart=c5);break;case"search":Object.assign(O,o1,W),O.encodePart=l5;break;case"hash":Object.assign(O,o1,W),O.encodePart=d5;break}try{this.#Y[z]=R4(X,O),this.#Z[z]=w4(this.#Y[z],this.#J[z],O),this.#$[z]=s5(this.#Y[z],O),this.#F=this.#F||this.#Y[z].some((F)=>F.type===2)}catch{throw TypeError(`invalid ${z} pattern '${this.#W[z]}'.`)}}}catch(j){throw TypeError(`Failed to construct 'URLPattern': ${j.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},Z){let J={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?J=BZ(J,$,!1):J=BZ(J,b4($,Z),!1)}catch{return!1}let j;for(j of f4)if(!this.#Z[j].exec(J[j]))return!1;return!0}exec($={},Z){let J={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?J=BZ(J,$,!1):J=BZ(J,b4($,Z),!1)}catch{return null}let j={};Z?j.inputs=[$,Z]:j.inputs=[$];let W;for(W of f4){let Y=this.#Z[W].exec(J[W]);if(!Y)return null;let z={};for(let[O,X]of this.#J[W].entries())if(typeof X=="string"||typeof X=="number"){let F=Y[O+1];z[X]=F}j[W]={input:J[W]??"",groups:z}}return j}static compareComponent($,Z,J){let j=S((O,X)=>{for(let F of["type","modifier","prefix","value","suffix"]){if(O[F]<X[F])return-1;if(O[F]===X[F])continue;return 1}return 0},"comparePart"),W=new TZ(3,"","","","",3),Y=new TZ(0,"","","","",3),z=S((O,X)=>{let F=0;for(;F<Math.min(O.length,X.length);++F){let G=j(O[F],X[F]);if(G)return G}return O.length===X.length?0:j(O[F]??W,X[F]??W)},"comparePartList");return!Z.#$[$]&&!J.#$[$]?0:Z.#$[$]&&!J.#$[$]?z(Z.#Y[$],[Y]):!Z.#$[$]&&J.#$[$]?z([Y],J.#Y[$]):z(Z.#Y[$],J.#Y[$])}get protocol(){return this.#$.protocol}get username(){return this.#$.username}get password(){return this.#$.password}get hostname(){return this.#$.hostname}get port(){return this.#$.port}get pathname(){return this.#$.pathname}get search(){return this.#$.search}get hash(){return this.#$.hash}get hasRegExpGroups(){return this.#F}};S(c4,"URLPattern");function T3($,Z){for(let[J,j]of Object.entries($)){let W=new c4({pathname:J});if(W.test({pathname:Z}))return{routePath:J,params:W.exec({pathname:Z})?.pathname.groups??{},route:j}}return null}var _$={startIndex:0,carriedViews:[]};function n5($,Z){let J=z0($.path,Z);return J.includes("*")?null:J}function eG($,Z){if(!$)return _$;if($.search!==Z.search)return _$;let J=Math.min($.segments.length,Z.segments.length-1),j=0;while(j<J){let W=$.segments[j],Y=Z.segments[j];if(Y.alwaysRun)break;if(W.viewPath!==Y.viewPath)break;let z=n5(W,$.params),O=n5(Y,Z.params);if(z===null||O===null||z!==O)break;j++}if(j===0)return _$;return{startIndex:j,carriedViews:Z.segments.slice(0,j).map(({viewPath:W})=>W)}}function $K($,Z){let[,J,...j]=$.split("/");if(!Z.includes(J))return $;let W=`/${j.join("/")}`;return W==="/"?"/":W.replace(/\/$/,"")}function a5($){let{flatViewRoutes:Z,supportedLocales:J,from:j,origin:W,to:Y}=$;if(!j)return _$;let z;try{z=new URL(j,W)}catch{return _$}if(z.origin!==W)return _$;let O=T3(Z,$K(z.pathname,J));if(!O)return _$;return eG({segments:O.route.segments,params:O.params,search:z.search},Y)}var l4="x-gemi-from";import{createElement as P1,Fragment as L7}from"react";function ZK($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function Z8($){let Z={};for(let[J,j]of Object.entries($))if("run"in j){let W=j.viewPath;if("children"in j){Z[J]=[W];let Y=new j.children,z=Z8(Y.routes);for(let[O,X]of Object.entries(z)){let F=J==="/"?O:`${J}${O}`,G=O==="/"&&J!=="/"?J:F;Z[G]=[W,...X]}if(Z[J].length===1)delete Z[J]}else Z[J]=[W]}else{let W=new j,Y=Z8(W.routes);for(let[z,O]of Object.entries(Y)){let X=J==="/"?z:`${J}${z}`,F=z==="/"&&J!=="/"?J:X;Z[F]=O}}return Object.fromEntries(Object.entries(Z).map(([J,j])=>[ZK(J),j]))}function J8($,Z){let[J,j]=Z,W=$.find(([Y])=>Y===J);if(!W){$.push([J,[...j]]);return}for(let Y of j)J8(W[1],Y)}function j8($){let Z=[];for(let[J,j]of Object.entries($))if("run"in j){let W=j.viewPath;if(W==="__")continue;if(W==="REDIRECT")continue;if(W==="FILE")continue;if("children"in j){let Y=new j.children,z=j8(Y.routes);J8(Z,[W,z])}else J8(Z,[W,[]])}else{let W=new j,Y=j8(W.routes);for(let z of Y)J8(Z,z)}return Z}function d4($){let Z=[];for(let[J,j]of $)Z.push(J,...d4(j).flat());return Array.from(new Set(Z))}class r1 extends V0{static getFacadeAccessor(){return n}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),Z=f.getStore();if(Z)return Z.locale??$.detectLocale(Z.req);return $.defaultLocale}static timeZone(){return this.getFacadeRoot().detectTimeZone(f.getStore()?.req)}static formatter($={}){return this.getFacadeRoot().formatter($.locale??r1.locale(),$.timeZone??r1.timeZone())}static setLocale($=r1.locale(),Z={}){let J=this.getFacadeRoot(),j=$;if(!J.supportedLocales.includes($))j=J.defaultLocale;let W=f.getStore();if(Z.cookie!==!1)W.setCookie("i18n-locale",j,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1});return W.setLocale(j),j}}class u4{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var JK=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),jK=new Set(["svg","math"]);function o5($){return $===32||$===9||$===10||$===12||$===13}function r5($){return $>=65&&$<=90||$>=97&&$<=122}function W8($){return $>=65&&$<=90?$+32:$}function t5(){let $="data",Z="",J=!1,j="",W=0,Y=0,z=!1,O=0,X=0,F=()=>$==="data"&&O===0&&X===0,G=()=>{if(!J&&JK.has(Z)){$="rawText",j=`</${Z}`,W=0,Z="";return}if($="data",Z==="template")if(J)O=Math.max(0,O-1);else O+=1;else if(jK.has(Z)){if(J)X=Math.max(0,X-1);else if(!z)X+=1}Z=""},K=(Q)=>{switch($){case"data":if(Q===60)$="tagOpen";return;case"tagOpen":if(Q===33)$="bang",Y=0;else if(Q===47)$="endTagOpen";else if(r5(Q))$="tagName",J=!1,z=!1,Z=String.fromCharCode(W8(Q));else if(Q===63)$="bogus";else if(Q===60)$="tagOpen";else $="data";return;case"endTagOpen":if(r5(Q))$="tagName",J=!0,z=!1,Z=String.fromCharCode(W8(Q));else if(Q===62)$="data";else $="bogus";return;case"tagName":if(o5(Q)||Q===47)$="inTag",z=Q===47;else if(Q===62)G();else Z+=String.fromCharCode(W8(Q));return;case"inTag":if(Q===62){G();return}if(z=Q===47,Q===34)$="attrDouble";else if(Q===39)$="attrSingle";return;case"attrDouble":if(Q===34)$="inTag";z=!1;return;case"attrSingle":if(Q===39)$="inTag";z=!1;return;case"bang":if(Q===45){if(Y+=1,Y===2)$="comment",Y=0}else if(Q===62)$="data";else $="bogus";return;case"bogus":if(Q===62)$="data";return;case"comment":if(Q===45)Y=Y<2?Y+1:2;else if(Q===62&&Y>=2)$="data",Y=0;else Y=0;return;case"rawText":{if(W<j.length){if(W8(Q)===j.charCodeAt(W))W+=1;else W=Q===60?1:0;return}if(Q===62)$="data",Z="";else if(o5(Q)||Q===47)$="inTag",Z="";else W=Q===60?1:0;return}}};return{scanToInsertionPoint(Q){for(let U=0;U<Q.length;U++){if(F())return U;K(Q[U])}return Q.length},write(Q){for(let U=0;U<Q.length;U++)K(Q[U])},isSafe:F}}function _1($){let Z=JSON.stringify($);if(Z===void 0)return"undefined";return Z.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function WK($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${_1([$.path,$.variantKey,$.data])})</script>`}function YK($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${_1([$.id,$.locale,$.strings])})</script>`}function i4($,Z,J={},j){let W=new TextEncoder,Y=[],z=!1,O=!1,X=()=>{if(O)return;O=!0,J.onClose?.()};Z.onSettle((B)=>{if(B.status!=="resolved")return;Y.push(WK(B))}),j?.onUse((B)=>{Y.push(YK(B))});let F=$.getReader(),G=t5(),K=(B,D)=>{B.enqueue(D),J.onChunk?.(D)},Q=(B)=>{while(Y.length>0){let D=W.encode(Y.shift());G.write(D),K(B,D)}},U=(B,D)=>{if(Y.length===0){G.write(D),K(B,D);return}let T=G.scanToInsertionPoint(D);if(T>0)K(B,D.subarray(0,T));if(G.isSafe())Q(B);let M=D.subarray(T);if(M.length>0)G.write(M),K(B,M)};return new ReadableStream({async pull(B){let D;try{D=await F.read()}catch(L){throw X(),L}let{done:T,value:M}=D;if(T){Q(B),B.close(),X();return}if(!z){if(z=!0,G.write(M),K(B,M),J.onShell?.(),G.isSafe())Q(B);return}U(B,M)},cancel(B){return X(),F.cancel(B)}})}var zK=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function Y8($){if(!$)return!1;return zK.test($)}async function $7($,Z=()=>{}){let J=f.getStore(),j=J?.req??null,W=null;if(j?.rawRequest?.url)try{W=new URL(j.rawRequest.url).pathname}catch{W=null}return{user:J?.user??null,attributes:await OK($,Z),request:{path:W,routePath:j?.routePath??null,locale:J?.locale??null},anonymousId:e5(),isBot:Y8(j?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function Z7($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function OK($,Z){if(!$.context)return{};try{let J=f.getStore();return await $.context(J?.req??null)??{}}catch(J){return Z(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${J instanceof Error?J.message:String(J)}`),{}}}function J7($,Z){return`${$}:${Z}`}function s4($){let Z=new Bun.CryptoHasher("sha1").update($).digest("hex"),J=Number.parseInt(Z.slice(0,8),16);return Math.floor(J/4294967296*1e4)}function j7($,Z){if(Z>=100)return!0;if(Z<=0)return!1;return $<Math.round(Z*100)}function W7($,Z,J,j){if(j.unavailable)return{value:!1,reason:"unavailable"};if(j.active!==!0)return{value:!1,reason:"inactive"};if(Z.when){let Y;try{Y=Z.when(J)}catch(z){return j.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${z instanceof Error?z.message:String(z)}`),{value:!1,reason:"error"}}if(typeof Y==="boolean")return{value:Y,reason:"attributed"}}if(Z.rollout===void 0)return{value:!0,reason:"on"};if(J.isBot)return{value:!1,reason:"bot"};let W=FK($,Z,J,j.buckets);return j7(W,Z.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function XK($){let Z=$.user?.publicId??$.user?.id;if(Z!==void 0&&Z!==null)return String(Z);return $.anonymousId??""}function FK($,Z,J,j){let W=J7(Z.salt??$,XK(J));if(!j)return s4(W);let Y=j.get(W);if(Y!==void 0)return Y;let z=s4(W);return j.set(W,z),z}class Y7 extends Error{cause;kind="FeatureReloadFailed";constructor($){super(`Could not reload feature switches after a write, so the cached switches may still predate it: ${$ instanceof Error?$.message:String($)}`);this.cause=$}}class n4{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,Z,J,j=()=>{}){this.source=$;this.declared=Z;this.ttlMs=J;this.warn=j}async get(){let $=this.snapshot;if($&&Date.now()-$.loadedAt<this.ttlMs)return $;if($){if(Date.now()>=this.retryAfter)this.refresh().catch(()=>{});return $}return await this.refresh()}refresh(){return this.inflight??=this.load().finally(()=>{this.inflight=null}),this.inflight}async invalidate(){await this.inflight?.catch(()=>{});let $=this.generation,Z=await this.refresh();if(this.generation===$)throw new Y7(this.lastError);return Z}peek(){return this.snapshot}async load(){try{let $=await this.source.load(),{active:Z,audit:J}=this.readRows($);return this.snapshot={active:Z,audit:J,loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readRows($){let Z=new Map,J=new Map;for(let j of $??[]){let W=typeof j?.key==="string"?j.key:null;if(!W){this.warn("Ignoring a feature row with no `key`.");continue}if(!(W in this.declared)){this.warn(`Feature row "${W}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}Z.set(W,j.active===!0);let Y=GK(j);if(Y)J.set(W,Y)}return{active:Z,audit:J}}handleFailure($){let Z=$ instanceof Error?$.message:String($),J=Date.now();if(this.lastError=$,this.retryAfter=J+this.ttlMs,J-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=J,this.warn(`Could not load feature switches: ${Z}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,audit:new Map,loadedAt:J,unavailable:!0},this.snapshot}}function GK($){let Z={},J=$.updatedBy;if(typeof J==="string")Z.updatedBy=J;else if(J===null)Z.updatedBy=null;let j=$.updatedAt;if(j instanceof Date||typeof j==="string"||typeof j==="number"){let W=j instanceof Date?j:new Date(j);if(!Number.isNaN(W.getTime()))Z.updatedAt=W}return"updatedBy"in Z||"updatedAt"in Z?Z:null}class KK{}class QK extends Error{modelName;kind="FeatureModelMissing";constructor($){super(`No "${$}" model is registered, so every feature stays off. Add the model to prisma/schema.prisma and export it from app/models \u2014 see docs/feature-flags.md.`);this.modelName=$}}class a4 extends Error{sourceName;kind="FeatureSourceReadOnly";constructor($){super(`The feature source (${$}) is read-only, so Features.set() cannot write to it. Change the switch where that source reads from, or give the source a write() method.`);this.sourceName=$}}class z7 extends Error{key;kind="UndeclaredFeature";constructor($){super(`"${$}" is not declared in app/features, so it cannot be switched. A row for it would be ignored \u2014 declare the feature first.`);this.key=$}}class O7{manager;ctx;constructor($,Z){this.manager=$;this.ctx=Z}async enabled($){return(await this.explain($)).value}async explain($){return await this.manager.evaluateIn($,this.ctx,new Map)}async all(){return await this.manager.evaluateAllIn(this.ctx,new Map,{clientOnly:!1})}}class VZ{config;log;static token="features";store;declared;warnedAboutSize=!1;warnedAboutActor=!1;constructor($,Z=()=>{}){this.config=$;this.log=Z;this.declared=$.features??{},this.store=new n4($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,audit:Z,unavailable:J}=await this.switches();return{unavailable:J,features:Object.entries(this.declared).map(([j,W])=>({key:j,describe:W.describe,rollout:W.rollout,targeted:W.when!==void 0,serverOnly:W.serverOnly,salt:W.salt,active:$.get(j),...Z.get(j)}))}}async refresh(){if(!this.config.enabled)return;if(Object.keys(this.declared).length===0)return;await this.store.refresh()}async invalidate(){try{if(this.config.enabled&&Object.keys(this.declared).length>0)await this.store.invalidate()}finally{f.getStore()?.featureEvaluations?.clear()}}async set($,Z,J={}){if(typeof $!=="string"||!Object.hasOwn(this.declared,$))throw new z7(String($));if(typeof Z!=="boolean")throw TypeError(`Features.set("${$}", \u2026) takes a boolean, not ${Z===null?"null":typeof Z}.`);let j=UK(J.actor),W=this.config.source;if(typeof W.write!=="function")throw new a4(W.constructor?.name||"an anonymous source");let{actorRecorded:Y}=await W.write($,Z,{actor:j});if(j!==null&&!Y&&!this.warnedAboutActor)this.warnedAboutActor=!0,this.log('Features.set() was given an actor, but the feature source has nowhere to record it. For the database source, add a nullable `updatedBy String?` column to the feature flag model to keep "last changed by".');await this.invalidate()}async enabled($){return(await this.explain($)).value}async explain($){let Z=await this.requestContext();return await this.evaluateIn($,Z,this.requestBuckets())}async all(){let $=await this.requestContext();return await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!1})}async forClient(){if(!this.config.enabled)return{};let $=await this.requestContext(),Z=await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!0});return this.warnIfOversized(Object.keys(Z).length),Z}for($){return new O7(this,Z7($))}async evaluateIn($,Z,J){let j=this.memoFor(Z),W=j?.get($);if(W)return W;let Y=this.declared[$];if(!Y)return{value:!1,reason:"undeclared"};let{active:z,unavailable:O}=await this.switchFor($),X=W7($,Y,Z,{active:z,unavailable:O,buckets:J,warn:this.log});return j?.set($,X),this.notify($,X,Z),X}async evaluateAllIn($,Z,J){let j={};for(let[W,Y]of Object.entries(this.declared)){if(J.clientOnly&&Y.serverOnly)continue;j[W]=(await this.evaluateIn(W,$,Z)).value}return j}async switches(){if(!this.config.enabled||Object.keys(this.declared).length===0)return{active:new Map,audit:new Map,unavailable:!1};let $=await this.store.get();return{active:$.active,audit:$.audit,unavailable:$.unavailable}}async switchFor($){if(!this.config.enabled)return{active:!1,unavailable:!1};let Z=await this.store.get();return{active:Z.active.get($),unavailable:Z.unavailable}}async requestContext(){let $=f.getStore();if($?.featureContext)return $.featureContext;let Z=await $7(this.config,this.log);if($)$.featureContext=Z;return Z}memoFor($){let Z=f.getStore();if(!Z||Z.featureContext!==$)return null;return Z.featureEvaluations??=new Map,Z.featureEvaluations}requestBuckets(){let $=f.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,Z,J){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,Z,J)}catch(j){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${j instanceof Error?j.message:String(j)}`)}}warnIfOversized($){if(this.warnedAboutSize||$<=this.config.maxClientFlags)return;this.warnedAboutSize=!0,this.log(`${$} client-visible features are embedded in every document. Mark the ones only the server reads with \`serverOnly: true\` to keep them out of the payload.`)}}function UK($){if($===void 0||$===null)return null;if(typeof $==="string"){if($.length>0)return $}else if(typeof $==="object"){let{publicId:Z,id:J}=$;if(typeof Z==="string"&&Z.length>0)return Z;if(typeof J==="string"&&J.length>0||typeof J==="number")return String(J)}throw TypeError("Features.set() was given an `actor` that identifies nobody. Pass a string, or a user with a `publicId` or an `id`.")}function X7($){return Object.fromEntries(Object.entries($).filter(([,Z])=>{return Z!==null&&Z!==void 0}))}var BK=50;class MZ{fetcher;entries=new Map;settleListener=null;failListener=null;shellAt=null;settledBacklog=[];shipped=new Set;requestStartedAt=performance.now();renderStartedAt=null;discoveryHintsMuted=!1;constructor($){this.fetcher=$}elapsed(){return Math.round(performance.now()-this.requestStartedAt)}keyFor($,Z){return[$,Z].filter((J)=>J.length>0).join("?")}markRenderStart(){if(this.renderStartedAt===null)this.renderStartedAt=performance.now()}markShell(){if(this.shellAt===null)this.shellAt=this.elapsed()}summarize($){let Z=this.elapsed();return{shellAt:this.shellAt??Z,settledAt:Z,aborted:$,queries:Array.from(this.entries.values(),(J)=>({path:J.path,variantKey:J.variantKey,startedAt:J.startedAt,settledAt:J.settledAt,status:J.status,source:J.source}))}}onQueryFail($){this.failListener=$}muteDiscoveryHints(){this.discoveryHintsMuted=!0}maybeLogLateDiscovery($){if(!$.lateBy||this.discoveryHintsMuted)return;if($.status!=="resolved")return;if(Bun.env.NODE_ENV==="production")return;let Z="";try{let W=JSON.stringify($.data)?.length??0;Z=W>=1024?`${(W/1024).toFixed(1)} kB`:`${W} B`}catch{Z="an unserializable payload"}let J=($.settledAt??0)-$.startedAt,j=$.variantKey?`, { search: ${JSON.stringify(Object.fromEntries(new URLSearchParams($.variantKey)))} }`:"";console.warn(`[gemi] useQuery("${$.patternPath}") was discovered ${$.lateBy}ms into the `+`server render \u2014 under a suspended segment, so its fetch (${J}ms, resolved ${Z}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${j})\` in the view `+"handler starts it at request time \u2014 but note prefetched data is also re-fetched and "+`streamed into every client-side navigation payload for the route, even when the client already holds it, so weigh that bandwidth against the ${Z}. If the data is only needed conditionally (a closed popover, a hidden tab), \`{ lazy: true }\` + \`trigger()\` avoids running it here at all. \`Query.noPrefetch()\` in the handler marks the omission intentional and silences this hint for the route.`)}read($,Z){return this.entries.get(this.keyFor($,Z))}ensure($,Z={},J="render"){let j=Z.params??{},W=new URLSearchParams(X7(Z.search??{}));W.delete("json"),W.sort();let Y=z0($,j),z=W.toString(),O=this.keyFor(Y,z),X=this.entries.get(O);if(X)return X;let F;if(J==="render"&&this.renderStartedAt!==null){let U=Math.round(performance.now()-this.renderStartedAt);if(U>BK)F=U}let G,K=new Promise((U)=>{G=U}),Q={path:Y,patternPath:$,variantKey:z,lateBy:F,status:"pending",promise:K,source:J,startedAt:this.elapsed()};return this.entries.set(O,Q),this.fetcher($,j,W).then((U)=>{Q.status="resolved",Q.data=U},(U)=>{Q.status="rejected",Q.error=U}).then(()=>{if(Q.settledAt=this.elapsed(),this.maybeLogLateDiscovery(Q),Q.status==="rejected"&&this.failListener)this.failListener(Q);if(this.settleListener)this.settleListener(Q);else this.settledBacklog.push(Q);G()}),Q}async allSettled(){let $=0;while($!==this.entries.size)$=this.entries.size,await Promise.all(Array.from(this.entries.values(),(Z)=>Z.promise))}snapshotResolved(){let $={};for(let[Z,J]of this.entries){if(J.status!=="resolved")continue;this.shipped.add(Z),$[J.path]??={},$[J.path][J.variantKey]=J.data}return $}onSettle($){this.settleListener=(J)=>{if(this.shipped.has(this.keyFor(J.path,J.variantKey)))return;$(J)};let Z=this.settledBacklog;this.settledBacklog=[];for(let J of Z)this.settleListener(J)}}class t1 extends Error{path;variantKey;status;body;retryAfter;constructor($,Z,J,j,W){super(typeof j?.message==="string"?j.message:`Request to /api${$} failed with status ${J}`);this.path=$;this.variantKey=Z;this.status=J;this.body=j;this.retryAfter=W;this.name="QueryError"}}function CZ(){let $=JSON.stringify({error:A1("permission","Forbidden",403)});return new Response($,{status:403,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}function o4(){return{status:403,error:{message:"Forbidden"}}}function V3($){let Z=IZ.getStore();return(J,j,W)=>{let Y=new URL($.url).origin,z=[z0(J,j),W.toString()].filter((G)=>G.length>0).join("?"),O=new Request(`${Y}/${z}`,{headers:$.headers,signal:$.signal}),X=F7($);if(X)NZ(O,X);let F=new E(O,j);return IZ.run(Z,()=>f.run(F,async()=>{try{let G=await I(o0).dispatchers(X).api.getRouteData(J);if(b$(G)){if(!G.ok)throw new t1(z0(J,j),W.toString(),G.status,G.body);return G.body}if(G instanceof Response){let K=await G.json().catch(()=>null);if(!G.ok)throw new t1(z0(J,j),W.toString(),G.status,K);return K}return G}catch(G){if(G instanceof t1)throw G;let K=new t1(z0(J,j),W.toString(),500,{message:G instanceof Error?G.message:String(G)});throw K.cause=G,K}}))}}var DK=new Set(["script","style","template","title"]),TK=/\shidden([\s=/]|$)/i,VK=/"[^"]*"|'[^']*'/g;function MK($){let Z=0,J=0,j=0,W=0;while(W<$.length){let Y=$.indexOf("<",W),z=Y===-1?$.length:Y;if(z>W){let K=$.slice(W,z).replace(/\s+/g,"").length;if(j>0)J+=K;else Z+=K}if(Y===-1)break;if($.startsWith("<!--",Y)){let K=$.indexOf("-->",Y+4);W=K===-1?$.length:K+3;continue}let O=$.indexOf(">",Y);if(O===-1)break;let X=$.slice(Y+1,O);W=O+1;let F=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(X)?.[1]?.toLowerCase();if(!F)continue;let G=X.startsWith("/");if(!G&&DK.has(F)&&!X.endsWith("/")){let K=$.indexOf(`</${F}`,W);W=K===-1?$.length:K;continue}if(F!=="div")continue;if(G){if(j>0)j-=1}else if(j>0)j+=1;else if(TK.test(X.replace(VK,'""')))j=1}return{shellChars:Z,deferredChars:J}}var CK=1000,IK=64;function NK($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function LK($,Z){if(Z.deferredChars<CK)return null;if(Z.shellChars>=IK)return null;return`[gemi] GET ${$} streams ${NK(Z.deferredChars)} of its `+`content behind reveal scripts \u2014 a no-JS visitor sees ~${Z.shellChars} chars. If this is a public/content route, add "no-stream" to its middleware.`}function G7($=console.warn){let Z=new Set;return{shouldObserve(J){return!Z.has(J)},report(J,j){if(Z.has(J))return;let W=LK(J,j);if(!W)return;Z.add(J),$(W)}}}function K7(){let $=new TextDecoder,Z="";return{onChunk(J){Z+=$.decode(J,{stream:!0})},measure(){return Z+=$.decode(),MK(Z)}}}function Q7($,Z,J=1e4,j){let W=new TextEncoder,Y=()=>{};return new ReadableStream({start(z){let O=!1,X=(G)=>{if(O)return;O=!0,clearTimeout(F);try{z.close()}catch{}j?.({aborted:G})};Y=X,z.enqueue(W.encode(`${JSON.stringify($)}
3
- `)),Z.onSettle((G)=>{if(O||G.status!=="resolved")return;z.enqueue(W.encode(`${JSON.stringify([G.path,G.variantKey,G.data])}
4
- `))});let F=setTimeout(()=>X(!0),J);Z.allSettled().then(()=>X(!1),()=>X(!1))},cancel(){Y(!1)}})}import{Fragment as bT,createContext as _K,createElement as vT,lazy as RT,use as wT,useContext as kT}from"react";function U7($){return{islands:[],render:$,instances:new WeakMap,count:0}}var M3="gemi-slot",B7="data-slot",D7="data-gemi-slot";var PK=Symbol.for("gemi.staticRender"),T7=globalThis[PK]??=_K(null);import{createHash as HK}from"crypto";var SK="gemi-islands",r4='const d=document,c=JSON.parse(d.getElementById("gemi-islands").textContent),w=f=>(window.requestIdleCallback||setTimeout)(f),m=(e,o)=>{if(!e.g){e.g=1;import(o.s).then(x=>x.h(e,x.m[o.e])).catch(r=>console.error(r))}};for(const e of d.querySelectorAll("gemi-island")){const o=c.i[e.dataset.island];if(!o)continue;if(o.l=="eager")m(e,o);else if(o.l=="idle"||!window.IntersectionObserver||!e.children.length)w(()=>m(e,o));else{const v=new IntersectionObserver(n=>{if(n.some(x=>x.isIntersecting)){v.disconnect();m(e,o)}});for(const k of e.children)v.observe(k)}}',pT=`'sha256-${HK("sha256").update(r4).digest("base64")}'`,xK='await import("/refresh.js").catch(()=>{});await import("/@vite/client").catch(()=>{});'+r4;function V7($,Z,J,j){if(!J)return $;let W=j?$.lastIndexOf(Z):$.indexOf(Z);return W===-1?$+J:$.slice(0,W)+J+$.slice(W)}var fK=($)=>$.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;");function M7($,Z,J,j){if(Z.islands.length===0||!J)return $;let W=new Set,Y=Z.islands.map((X)=>{let F=X.module?J(X.module):void 0;if(!F)return console.error(`[gemi] island ${X.module??"(unknown module)"}: no client build entry. Declare it as island(() => import("./Component")) so gemi's Vite plugin builds it.`),null;if(X.load==="eager")for(let G of F.preload)W.add(G);return{s:F.src,e:X.export,l:X.load}});if(Y.every((X)=>X===null))return $;let z=[...W].map((X)=>`<link rel="modulepreload" href="${fK(X)}"/>`).join(""),O=`<script type="application/json" id="${SK}">${_1({i:Y})}</script><script type="module">${j?xK:r4}</script>`;return V7(V7($,"</head>",z,!1),"</body>",O,!0)}function EK($,Z){let J=/<(\/?)template\b[^>]*>/gi;J.lastIndex=Z;let j=0;for(let W=J.exec($);W;W=J.exec($))if(j+=W[1]?-1:1,j===0)return J.lastIndex;return-1}function C7($){let Z=`<template ${D7}="`;for(let J=$.lastIndexOf(Z);J!==-1;J=$.lastIndexOf(Z)){let j=EK($,J);if(j===-1)break;let W=J+Z.length,Y=$.slice(W,$.indexOf('"',W)),z=$.indexOf(">",W)+1,O=$.slice(z,j-11);$=$.slice(0,J)+$.slice(j);let X=`<${M3} ${B7}="${Y}" style="display:contents"></${M3}>`;$=$.split(X).join(`<${M3} style="display:contents">${O}</${M3}>`)}return $}function I7($){if(!$)return{locale:!0,session:!0,csrf:!0};return{locale:!1,session:$.session===!0,csrf:$.csrf===!0}}function N7($,Z){if($.getSetCookie().length>0){if(Z.cacheControl&&Bun.env.NODE_ENV!=="production")console.warn(`[gemi] A static view with cacheControl "${Z.cacheControl}" set a cookie, so it was sent "private, no-store" instead. Static pages are cacheable only when nothing on them sets a cookie.`);$.set("Cache-Control","private, no-store");return}if(Z.cacheControl&&!$.has("Cache-Control"))$.set("Cache-Control",Z.cacheControl)}var AK=async()=>(await import("./chunk-1kr25rcg.js")).default,t4,C3=async(...$)=>{return t4??=import("react-dom/server.browser").catch((Z)=>{throw t4=void 0,Z}),(await t4).renderToReadableStream(...$)},_7=1e4,bK=`
5
- !function(){try{var d=document.documentElement,c=d.classList;
6
- c.remove('light','dark');
7
- var e=localStorage.getItem('theme');
8
- if('system'===e||(!e&&'system'===defaultTheme)){
9
- var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);
10
- if(m.media!==t||m.matches){d.style.colorScheme='dark';c.add('dark')}
11
- else{d.style.colorScheme='light';c.add('light')}
12
- }else if(e){
13
- c.add(e||'')
14
- }}catch(e){}}()
15
- `;async function vK($,Z,J){let j=`${J==="italic"?"italic,":""}wght@${J==="italic"?"1,":""}${Z}`,z=(await(await fetch(`https://fonts.googleapis.com/css2?family=${$}:${j}&display=swap`,{headers:{"User-Agent":"Mozilla/5.0 Firefox/1.0"}})).text()).match(/url\(([^)]+)\)/)?.[1];return await fetch(z).then((O)=>O.arrayBuffer())}var Zj="/assets";function RK($){return $===Zj||$.startsWith(`${Zj}/`)}function wK($){let Z=$.filter(RK);if(Z.length>0){let J=Z.length>1;throw Error(`View route path${J?"s":""} ${Z.map((j)=>`"${j}"`).join(", ")} use${J?"":"s"} the reserved "${Zj}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function kK($){let Z=I(o0).resolver;return{...$.domain,root:Z.root,origin:Z.publicOrigin($.rawRequest)}}function e4($){let{status:Z=400,error:J}=$;return new Response(J?.message,{...$,status:Z})}function qK($){let{status:Z=400,data:J,directive:j,headers:W}=$;return new Response(JSON.stringify({data:J,directive:j}),{headers:W,status:Z})}class L3{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];staticRoutes=[];root=null;shellReporter=G7();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let Z=_5();this.partialRendering=$.partialRendering??Z.partialRendering,this.hooks={onRequestStart:$.onRequestStart??Z.onRequestStart,onRequestEnd:$.onRequestEnd??Z.onRequestEnd,onRequestFail:$.onRequestFail??Z.onRequestFail,onStreamComplete:$.onStreamComplete??Z.onStreamComplete};let J={"/":$.rootRouter,"/auth":M4};this.flatViewRoutes=e6(J),wK(Object.keys(this.flatViewRoutes)),this.routeManifest=Z8(J),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,j])=>j.at(-1)!=="FILE")),this.componentTree=j8(J),this.flatComponentTree=d4(this.componentTree),this.staticRoutes=Object.entries(this.flatViewRoutes).filter(([,j])=>j.static).map(([j])=>j);for(let j of this.staticRoutes){let W=this.flatViewRoutes[j].static?.layout;if(W&&!this.flatComponentTree.includes(W))this.flatComponentTree.push(W)}this.root=$.root}async passesFeatureGates($){let Z=I(VZ);for(let J of $)if(!await Z.enabled(J))return!1;return!0}async onRequestEnd($,Z={}){if(Z.mintSession!==!1)z8();return await this.hooks.onRequestEnd($)}completeStream($,Z){let J=(j)=>{P$.error(j?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(j)})};try{Promise.resolve(this.hooks.onStreamComplete($,Z)).catch(J)}catch(j){J(j)}}modulePreloadLinks($){let{clientEntry:Z,modulePreloadManifest:J,views:j,routeKey:W}=$,Y=()=>{let X=new Set(Z?.preload??[]);for(let F of j)for(let G of J?.[F]??[])X.add(G);return[...X].map((F)=>P1("link",{key:`modulepreload:${F}`,rel:"modulepreload",href:F}))};if(!J)return Y();let z=this.preloadCache.get(J);if(!z||z.clientEntry!==Z)z={clientEntry:Z,byRoute:new Map},this.preloadCache.set(J,z);let O=z.byRoute.get(W);if(!O)O=Y(),z.byRoute.set(W,O);return O}async renderStatic($){let{req:Z,runInRequestScope:J,staticView:j,currentViews:W,data:Y,serverQueries:z,headers:O}=$,X;if(j.layout){if(X=$.viewImportMap[j.layout],!X)throw Error(`The static layout "${j.layout}" was not found. It is a view path: a file at app/views/${j.layout}.tsx whose default export renders the document.`)}let F=await $.getStyles(W,{static:!0,layout:j.layout});z.markRenderStart();let G=$j(),K=new AbortController,Q=setTimeout(()=>K.abort(),_7),U=(D)=>{if(Bun.env.NODE_ENV!=="production")console.error(D)},B=U7(async(D,T)=>{let M=await C3(D,{signal:K.signal,identifierPrefix:T,progressiveChunkSize:Number.MAX_SAFE_INTEGER,onError:U});return await M.allReady.catch(()=>{}),await new Response(M).text()});try{let D=await C3(P1(T7.Provider,{value:B,children:P1(L7,{children:[...F,P1(this.root,{data:Y,viewImportMap:$.viewImportMap,viewModules:$.viewModules,serverQueries:z,dictionarySink:G,rootLayout:X,key:"root"})]})}),{signal:K.signal,progressiveChunkSize:Number.MAX_SAFE_INTEGER,onError:U});await D.allReady.catch(()=>{});let T=C7(await new Response(D).text());return new Response(M7(T,B,$.resolveIsland,Bun.env.NODE_ENV!=="production"),{status:200,headers:O})}finally{clearTimeout(Q),J(()=>this.completeStream(Z,z.summarize(K.signal.aborted)))}}async render($){let{req:Z,runInRequestScope:J,csrfTokenHMAC:j,currentPathName:W,headers:Y,i18n:z,params:O,pathname:X,serverQueries:F,userAgent:G,noStream:K,url:Q,user:U,viewData:B,breadcrumbs:D,urlLocaleSegment:T,meta:M,isOgRequest:L,appId:C,features:H,staticView:P}=$,_=X.replace(`/${T}`,""),V={kind:"view",data:{meta:M,pageData:{[_]:B},__csrf:j.toString("base64"),prefetchedData:{},i18n:z,auth:{user:U},routeManifest:this.clientRouteManifest,breadcrumbs:D,router:{urlLocaleSegment:T,pathname:W,params:O,currentPath:X,searchParams:Q.search,is404:!W?!0:!1,domain:Z.domain?kK(Z):null},appId:C,features:H,componentTree:[["404",[]],...this.componentTree],...this.staticRoutes.length>0?{staticRoutes:this.staticRoutes}:{}},head:{}},N=this.root,x=this.routeManifest[W];return async(v)=>{let{bootstrapModules:y=[],loaders:r0,getStyles:m,viewImportMap:p,cssManifest:t0,ogMap:_3,viewModules:P3,clientEntry:e1,modulePreloadManifest:S1,assetBase:x1,resolveIsland:H$}=v,t=e1?[]:y,H3=(e)=>[e,`window.loaders=${r0}`,...e1?[`import(${JSON.stringify(e1.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(L){let e=null,x$=null;for(let f$ of x??[])if(typeof _3[f$]==="function")x$=f$,e=_3[f$];if(!e)return new Response("Not found",{status:404});let t7=Object.values(V.data.pageData)[0];try{await C3(P1(e,t7[x$]),{onError:()=>{}})}catch(f$){let{fonts:e7,...$O}=f$.satoriOptions,ZO=await Promise.all(e7.map((S3)=>{return vK(S3.name,S3.weight,S3.style).then((zO)=>({...S3,data:zO}))})),Fj=new Headers(Y);Fj.set("Content-Type","image/png");let[JO,jO]=await Promise.all([AK(),r6("Rendering an OG image")]),WO=await JO(f$.jsx,{...$O,fonts:ZO}),YO=await jO(Buffer.from(WO)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(YO),{headers:Fj})}return new Response("data")}if(P&&W)return await this.renderStatic({req:Z,runInRequestScope:J,staticView:P,currentViews:x,data:V.data,serverQueries:F,headers:Y,getStyles:m,viewImportMap:p,viewModules:P3,resolveIsland:H$});if(V.data.cssManifest=t0,V.data.modulePreloadManifest=S1??{},x1&&x1!=="/")V.data.assetBase=x1;let U8=this.modulePreloadLinks({clientEntry:e1,modulePreloadManifest:S1,views:x??["404"],routeKey:W??"404"}),S$=await m(x);V.data.prefetchedData=F.snapshotResolved(),F.markRenderStart();let F1=new AbortController,PZ=setTimeout(()=>F1.abort(),_7),G1=Y8(G)||K,b=Bun.env.NODE_ENV!=="production"&&!G1&&W&&this.shellReporter.shouldObserve(W)?K7():null,k0=$j();try{let e=await C3(P1(L7,{children:[...U8,...S$,P1("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:bK}}),P1(N,{data:V.data,viewImportMap:p,viewModules:P3,serverQueries:F,dictionarySink:k0,key:"root"})]}),{bootstrapScriptContent:H3(`window.__GEMI_DATA__ = ${_1(V.data)}`),bootstrapModules:t,signal:F1.signal,...G1?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(x$){if(Bun.env.NODE_ENV!=="production")console.error(x$)}});if(e.allReady.catch(()=>{}).finally(()=>clearTimeout(PZ)),G1)await e.allReady.catch(()=>{});return new Response(i4(e,F,{onShell:G1?void 0:()=>F.markShell(),onChunk:b?.onChunk,onClose:()=>J(()=>{if(this.completeStream(Z,F.summarize(F1.signal.aborted)),b)this.shellReporter.report(W,b.measure())})},k0),{status:!W?404:200,headers:Y})}catch(e){if(clearTimeout(PZ),Bun.env.NODE_ENV==="production")throw J(()=>this.completeStream(Z,F.summarize(F1.signal.aborted))),e;let x$=await C3(P1("div"),{bootstrapScriptContent:H3(`window.error= ${_1(e.message)}; window.stack_trace=${_1(e.stack)};window.__GEMI_DATA__ = ${_1(V.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...t]:t});return new Response(i4(x$,F,{onClose:()=>J(()=>this.completeStream(Z,F.summarize(F1.signal.aborted)))}),{status:!W?404:200,headers:Y})}}}async handleViewRequest($,Z){let J=new URL($.url),j=J.pathname.endsWith(".json"),W=J.pathname.endsWith(".og"),Y=J.pathname.replace(".json","").replace(".og",""),[,z,...O]=Y.split("/"),X=`/${O.join("/")}`,F=null,G=null,K=I(n);if(!K.supportedLocales.includes(z))X=Y;else F=z,G=z;let U=G===null&&T3(this.flatViewRoutes,X)!==null;if(K.isLocaleAware&&!W&&G===null&&!U){let V=P7(z,K.supportedLocales,K.defaultLocale);if(V){let N=O.length?`/${O.join("/")}`:"";return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${V}${N}${j?".json":""}${J.search}`}})}}if(K.isLocaleAware&&!W){let V=I(n).detectLocale(new E($,{},"view",X));if(G===null&&V!==K.defaultLocale){let N=J.pathname==="/"?"":J.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${V}${N}${J.search}`}})}}X=X.replace("//","/");let B=[],D=[],T=null,M={},L=null,C=!1,H=[],P;try{let V=T3(this.flatViewRoutes,X);if(V){if(T=V.routePath,M=V.params,B=V.route.exec,D=V.route.middleware,H=V.route.features,C=D.includes("no-stream"),P=V.route.static,j&&this.partialRendering){let N=$.headers.get(l4),x=a5({flatViewRoutes:this.flatViewRoutes,supportedLocales:I(n).supportedLocales,from:N,origin:J.origin,to:{segments:V.route.segments,params:M,search:J.search}});if(x.startIndex>0)B=B.slice(x.startIndex),L={from:N,carriedViews:x.carriedViews}}}}catch(V){throw V}if(P&&j)return new Response("Not found",{status:404});let _=new E($,M,"view",T);return this.hooks.onRequestStart(_),await f.run(_,async()=>{let V=null,N=f.getStore(),x=IZ.getStore(),v=(p)=>IZ.run(x,()=>f.runWith(N,p));N.serverQueries=new MZ(V3($));let y=new Set;N.serverQueries.onQueryFail((p)=>{y.add(p.error);try{v(()=>Promise.resolve(this.hooks.onRequestFail(m,p.error)).catch(()=>{}))}catch{}});let r0=I7(P);if(G){let p=G.replaceAll("/","");r1.setLocale(p,{cookie:r0.locale})}else r1.setLocale(void 0,{cookie:r0.locale});let m=N.req;if(r0.session)z8();try{let p=!1;try{await I(UZ).runMiddleware(D)}catch(b){if(!LZ(b))throw b;p=!0}if(p||H.length>0&&!await this.passesFeatureGates(H))T=null,B=[],m.routePath="";let t0=I(n),_3=t0.isEnabled,P3=t0.isLocaleAware,e1=new E($,m.params),S1={defaultLocale:t0.defaultLocale,timeZone:t0.detectTimeZone(e1)};if(P3){let b=null;if(G)b=G.replaceAll("/",""),N.setLocale(b);else b=t0.detectLocale(e1),N.setLocale(b);let k0=_3?t0.getPageTranslations(b,m.routePath):{};S1={...S1,supportedLocales:t0.supportedLocales,currentLocale:b,dictionary:{[b]:k0},defaultLocale:t0.defaultLocale}}await H7(S1.currentLocale??"");let x1;try{x1=await Promise.all(B.map((b)=>b(m)))}catch(b){if(!LZ(b))throw b;T=null,B=[],m.routePath="",x1=[]}let{cookies:H$,headers:t}=N;V={data:x1,cookies:H$,headers:t,user:N.user,prefetchedData:N.serverQueries.snapshotResolved(),currentPathName:T,params:m.params,urlLocaleSegment:F,meta:N.renderMeta(),appId:I(u4).id,features:await I(VZ).forClient()};let{params:H3,user:U8}=V,S$={},F1={};for(let b of x1??[]){let[k0,e]=Object.entries(b)?.[0]??[];if(!k0||!e)continue;F1[`${k0}:${T}`]=e.breadcrumb,S$[k0]=e}let PZ=S$.FILE;if(PZ){for(let b of H$)t.append("Set-Cookie",b.toString());try{await this.onRequestEnd(m)}catch(b){P$.error(b?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(b)})}return await H8(PZ,t)}if(j){t.set("Content-Type","application/x-ndjson; charset=utf-8"),t.append("Vary",l4),H$.forEach((k0)=>t.append("Set-Cookie",k0.toString())),await this.hooks.onRequestEnd(m);let b={meta:L&&!N.metadata.touched?null:V.meta,data:{[X]:S$},breadcrumbs:F1,prefetchedData:N.serverQueries.snapshotResolved(),i18n:S1,features:V.features,is404:!T,appId:V.appId,partial:L};return new Response(Q7(b,N.serverQueries,void 0,({aborted:k0})=>v(()=>this.completeStream(m,N.serverQueries.summarize(k0)))),{headers:t})}if(t.set("Content-Type","text/html; charset=utf-8"),!C&&!(P&&T))t.append("Vary","User-Agent");let G1=Boolean(P&&T);if(!G1||r0.session)z8();for(let b of H$)t.append("Set-Cookie",b.toString());if(!G1||r0.csrf){let b=Bun.CSRF.generate(process.env.SECRET);t.append("Set-Cookie",`csrf_token=${b}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`)}try{await this.onRequestEnd(m,{mintSession:!G1||r0.session})}catch(b){P$.error(b?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(b)})}if(G1)N7(t,P);return await this.render({req:m,runInRequestScope:v,csrfTokenHMAC:Buffer.from(""),currentPathName:T,headers:t,i18n:S1,params:H3,pathname:J.pathname,serverQueries:N.serverQueries,userAgent:$.headers.get("user-agent"),noStream:C,url:J,user:U8,viewData:S$,breadcrumbs:F1,urlLocaleSegment:F,meta:V.meta,appId:V.appId,features:V.features,isOgRequest:W,staticView:T?P:void 0})}catch(p){if(p.kind===I3)if(j)return qK(p.payload.viewData??p.payload.api);else return e4(p.payload.view);if(!y.has(p))this.hooks.onRequestFail(m,p);if(N3(p))return console.error(p),j?CZ():e4(o4());if(p instanceof t1&&p.status===403)return j?CZ():e4(o4());throw p}},Z)}}function jj(){let $=JSON.stringify({error:A1("not_found","Not found",404)});return new Response($,{status:404,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}class b7 extends x0{routes={"/api-routes":this.get(()=>{let $=I(O8).flatRoutes,Z=[];for(let[J,j]of Object.entries($))for(let[W,Y]of Object.entries(j)){let{exec:z,middleware:O}=Y;Z.push({path:J,method:W,middleware:O})}return Z}),"/view-routes":this.get(()=>{let $=I(L3).flatViewRoutes,Z=[];for(let[J,{middleware:j,viewPath:W}]of Object.entries($))Z.push({path:J,method:"GET",viewPath:W,middleware:j});return Z})}}var gK=new Set([E1,"cookie","content-type","content-length","transfer-encoding","connection","host","user-agent","forwarded"]),yK=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,mK=/^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]*$/;function pK($,Z,J){for(let[j,W]of Object.entries(J.headers??{})){if(W===void 0||W===null)continue;let Y=j.toLowerCase();if(gK.has(Y)||Y.startsWith("x-forwarded-"))throw Error(`dispatchAs: credentials may not set the "${j}" header. The access token stays the initiator's, and the request's framing is dispatchAs's own.`);$.set(j,W)}for(let[j,W]of Object.entries(J.cookies??{})){if(W===void 0||W===null)continue;if(j===E1)throw Error(`dispatchAs: credentials may not set the "${E1}" cookie. The access token stays the initiator's.`);if(!yK.test(j)||!mK.test(W))throw Error(`dispatchAs: "${j}" is not a cookie a Cookie header can carry.`);Z.push(`${j}=${W}`)}}function hK($,Z){let J=$.body.getReader(),j=!1,W=()=>{if(j)return;j=!0;try{Z()}catch(z){console.error(z)}},Y=new ReadableStream({async pull(z){let O;try{O=await J.read()}catch(X){W(),z.error(X);return}if(O.done){W();try{z.close()}catch{}return}try{z.enqueue(O.value)}catch{}},async cancel(z){try{await J.cancel(z)}finally{W()}}},{highWaterMark:0});return new Response(Y,{status:$.status,statusText:$.statusText,headers:$.headers})}function S7($){let{status:Z=400,data:J,headers:j}=$,W=new Headers({"Content-Type":"application/json",...j});if(!W.has("Cache-Control"))W.set("Cache-Control","no-store");return new Response(JSON.stringify(J),{status:Z,headers:W})}function x7($,Z,J){let j=[];Z?.forEach((z,O)=>j.push([O,z]));let W=[...typeof Z?.getSetCookie==="function"?Z.getSetCookie():[],...Array.from(J??[])];if(j.length===0&&W.length===0)return $;let Y=(z)=>{for(let[O,X]of j){if(O.toLowerCase()==="set-cookie")continue;if(!z.has(O))z.set(O,X)}for(let O of W)z.append("Set-Cookie",O)};try{return Y($.headers),$}catch{let z=new Headers($.headers);return Y(z),new Response($.body,{status:$.status,statusText:$.statusText,headers:z})}}class O8{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let Z=L5();this.onRequestStart=$.onRequestStart??Z.onRequestStart,this.onRequestEnd=$.onRequestEnd??Z.onRequestEnd,this.onRequestFail=$.onRequestFail??Z.onRequestFail,this.flatRoutes=H4({"/":$.rootRouter,"/auth":C4,"/__gemi__/services/i18n":I4,"/__gemi__/services/logs":P4,"/__gemi__/services/image":_4,"/__gemi__/debug":b7})}getRouteHandlerAndParams($){let Z=new URL($.url),J=A7(Z.pathname),j={},W;for(let[Y]of Object.entries(this.flatRoutes))try{let z=new URLPattern({pathname:Y});if(z.test({pathname:J})){W=Y,j=z.exec({pathname:J})?.pathname.groups;break}}catch(z){console.error(z)}return{params:j,path:W}}async runRouteMiddleware($,Z){let j=this.flatRoutes[$][Z.rawRequest.method].middleware;try{await I(UZ).runMiddleware(j)}catch(W){if(W.kind===I3)return S7(W.payload.api);else{if(LZ(W))return jj();if(this.onRequestFail(Z,W),console.error(W),N3(W))return CZ();throw W}}}async getRouteData($){let Z=this.flatRoutes[$],J=f.getStore(),j=Z[J.req.rawRequest.method].exec??(()=>Promise.resolve({})),W={};try{W=await j()}catch(Y){if(Y.kind===I3)return S7(Y.payload.api);if(LZ(Y))return jj();if(this.onRequestFail(J.req,Y),console.error(Y),N3(Y))return CZ();throw Y}return W}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,Z,J){let j=async()=>{try{if(!this.isFrameworkRoute(J))await this.onRequestEnd(Z)}catch(W){P$.error(W?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(W)})}finally{$.destroy()}};if(!$.hasPendingWork()){await j();return}$.whenIdle().then(j).catch((W)=>{console.error(W)})}isOpenEndedBody($,Z){return $.method!=="HEAD"&&!Z.headers.has("Content-Length")&&Z.body!==null}async handleApiRequest($,Z){let{params:J,path:j}=this.getRouteHandlerAndParams($),W=this.flatRoutes[j];if(!W||!W[$.method])return new Response(JSON.stringify({error:A1("not_found","Not found",404)}),{status:404});let Y=new E($,J,"api",j);if(!this.isFrameworkRoute(j))this.onRequestStart(Y);return await f.run(Y,async()=>{let z=f.getStore(),O=!1,X=async()=>{O=!0,await this.endRequest(z,Y,j)};try{let F=I(n);if(F.isEnabled){let D=F.detectLocale(Y);z.setLocale(D)}z.setRequest(Y),I(UZ).applyDefaultBodyLimit($);let G=await this.runRouteMiddleware(j,Y);if(G instanceof Response){let D=x7(G,z.headers,z.cookies);return await X(),D}let K=await this.getRouteData(j),Q=z.headers,U=z.cookies;if(K instanceof Response){let D=x7(K,Q,U);if(this.isOpenEndedBody($,D)){let T=hK(D,()=>this.endRequest(z,Y,j));return O=!0,T}return await X(),D}let B=(b$(K)?K:$$.json(K)).toResponse(Q,U);return await X(),B}catch(F){if(!O)try{await X()}catch(G){console.error(G)}throw F}},Z)}async dispatchAs($,Z,J,j,W){let Y=new URL($.rawRequest.url).origin,z=new URL(`${Y}/api${J}`),O=`/api${J.split(/[?#]/)[0]}`;if(!J.startsWith("/")||z.origin!==Y||z.pathname!==O||z.hash!==""||z.pathname.startsWith("/api/__gemi__")||z.pathname==="/api/auth"||z.pathname.startsWith("/api/auth/"))throw Error(`dispatchAs: "${J}" is not an app api path. Pass the route's own path, without "/api", with every param encoded.`);let X=new Headers,F=[],G=$.cookies.get(E1);if(G)F.push(`${E1}=${G}`);if(W?.credentials)pK(X,F,W.credentials);if(F.length>0)X.set("Cookie",F.join("; "));let K=$.headers.get(E1);if(K)X.set(E1,K);let Q=$.headers.get("User-Agent");if(Q)X.set("User-Agent",Q);let U;if(j instanceof FormData)U=j;else if(j!==void 0)X.set("Content-Type","application/json"),U=JSON.stringify(j);let B=new Request(z,{method:Z,headers:X,body:U});if(f7(B,R$($)),$.domain)NZ(B,$.domain);return f.exit(()=>E7.exit(()=>this.handleApiRequest(B)))}}import{timingSafeEqual as cK}from"crypto";var F8="",zj="*",lK=60000,dK=1e4,Wj=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,X8=16,v7=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,Yj="x-forwarded-host";function R7($){return $.startsWith(":")}function Oj($,Z){if($===null)return!1;let J=Buffer.from($,"utf8"),j=Buffer.from(Z,"utf8");return J.length===j.length&&cK(J,j)}function uK($){if(!$)return null;if($===!0)return{header:Yj,secret:null};return{header:($.hostHeader??Yj).toLowerCase(),secret:$.secret?{header:$.secret.header.toLowerCase(),value:$.secret.value}:null}}function iK($){if(!$||$===!0)return;let{hostHeader:Z,secret:J}=$;if(Z!==void 0&&(typeof Z!=="string"||!v7.test(Z)))throw Error(`\`route.domains.trustProxy.hostHeader\` must be a single header name, e.g. "x-forwarded-host". Got ${JSON.stringify(Z)}.`);if(!J)return;if(typeof J.header!=="string"||!v7.test(J.header))throw Error(`\`route.domains.trustProxy.secret.header\` must be a header name. Got "${J.header}".`);if(J.header.toLowerCase()===(Z??Yj).toLowerCase())throw Error("`route.domains.trustProxy.secret.header` names the same header as `hostHeader`; the secret needs a header of its own.");if(typeof J.value!=="string"||J.value.length<X8)throw Error(`\`route.domains.trustProxy.secret.value\` must be at least ${X8} characters. A guessable one lets any client name its own host.`)}function X1($){if(!$)return null;try{return new URL(`http://${$.trim()}`).hostname.toLowerCase().replace(/\.$/,"")||null}catch{return null}}function sK($){try{let Z=new URL(`http://${$.trim()}`),J=Z.hostname.toLowerCase().replace(/\.$/,"");return J?Z.port?`${J}:${Z.port}`:J:null}catch{return null}}function nK($){let Z=X1($.root),J=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!Z||Z!==J||!Z.split(".").every((Y)=>Wj.test(Y)))throw Error(`\`route.domains.root\` must be a bare hostname, e.g. "example.com" \u2014 no scheme, port or path. Got "${$.root}".`);if($.custom&&($.custom.cacheTtlMs??0)<0)throw Error(`\`route.domains.custom.cacheTtlMs\` is ${$.custom.cacheTtlMs}; it cannot be negative. Use 0 to disable the cache.`);if($.ask&&$.ask.secret.length<X8)throw Error(`\`route.domains.ask.secret\` must be at least ${X8} characters. A guessable one is worse than leaving \`ask\` out.`);iK($.trustProxy);let j=new Set,W=null;for(let Y of $.groups??[]){let{subdomain:z}=Y;if(j.has(z))throw Error(`\`route.domains\` declares the subdomain "${z}" twice.`);if(j.add(z),R7(z)){if(!/^:[A-Za-z_][A-Za-z0-9_]*$/.test(z))throw Error(`"${z}" is not a valid param subdomain. It must be a single \`:name\` label.`);if(W)throw Error(`\`route.domains\` declares two param subdomains, "${W.subdomain}" and "${z}"; a host could match either.`);W=Y;continue}if(Y.exists)throw Error(`The subdomain "${z}" is fixed, so \`exists\` has no param to check. It only applies to a \`:param\` subdomain.`);if(!z.split(".").every((O)=>Wj.test(O)))throw Error(`"${z}" is not a valid subdomain.`)}if($.custom&&!j.has($.custom.group))throw Error(`\`route.domains.custom.group\` is "${$.custom.group}", but no group declares that subdomain.`);if($.ask&&W&&!W.exists)throw Error(`\`route.domains.ask\` is set, so "${W.subdomain}" needs an \`exists\` to say which tenants are real. Without one every host under the root would be approved for a certificate.`)}class Xj{root;hostTrust;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;proxySecretHeader;constructor($){nK($),this.root=X1($.root),this.hostTrust=uK($.trustProxy);for(let Z of $.groups??[])if(R7(Z.subdomain))this.param={...Z,name:Z.subdomain.slice(1)};else this.fixed.set(Z.subdomain.toLowerCase(),Z);this.custom=$.custom??null,this.cacheTtlMs=this.custom?.cacheTtlMs??lK,this.askSecret=$.ask?.secret??null,this.proxySecretHeader=this.hostTrust?.secret?.header??null}forwardedHost($){let Z=this.hostTrust;if(!Z)return null;if(Z.secret&&!Oj($.headers.get(Z.secret.header),Z.secret.value))return null;return $.headers.get(Z.header)?.split(",")[0]?.trim()||null}hostOf($){return X1(this.forwardedHost($))??X1(new URL($.url).host)}publicOrigin($){let Z=new URL($.url),J=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),j=J==="http"||J==="https"?J:Z.protocol.replace(/:$/,""),W=this.forwardedHost($),Y=W&&X1(W)?sK(W):null;return`${j}://${Y??Z.host}`}async resolve($){let Z=this.hostOf($);if(!Z)return null;let J=await this.match(Z,$);if(J)return J;if(this.custom?.fallback&&!this.isUnderRoot(Z))return{host:Z,group:zj,params:{},custom:!0};return null}async allows($,Z){let J=X1($);return J?await this.match(J,Z)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,Z){if($===this.root)return{host:$,group:F8,params:{},custom:!1};if($.endsWith(`.${this.root}`)){let j=$.slice(0,-(this.root.length+1)),W=this.fixed.get(j);if(W)return{host:$,group:W.subdomain,params:{},custom:!1};if(this.param&&Wj.test(j)){let Y={[this.param.name]:j};if(this.param.exists&&!await this.param.exists(Y,Z))return null;return{host:$,group:this.param.subdomain,params:Y,custom:!1}}return null}if(!this.custom)return null;let J=await this.resolveCustom($);return J?{host:$,group:this.custom.group,params:J,custom:!0}:null}async resolveCustom($){let Z=Date.now(),J=this.cache.get($);if(J&&J.expiresAt>Z)return this.cache.delete($),this.cache.set($,J),J.value;let j=this.inFlight.get($);if(j)return j;let W=(async()=>await this.custom.resolve($)??null)();this.inFlight.set($,W);let Y;try{Y=await W}finally{this.inFlight.delete($)}if(this.cacheTtlMs>0){if(this.cache.size>=dK)this.cache.delete(this.cache.keys().next().value);this.cache.delete($),this.cache.set($,{value:Y,expiresAt:Date.now()+this.cacheTtlMs})}return Y}forget($){if($===void 0)this.cache.clear();else{let Z=X1($);if(Z)this.cache.delete(Z)}}}var aK="/__gemi__/domains/ask";class o0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,Z){this.groups.set(F8,$);let{domains:J}=Z;if(this.acceptsCustomDomains=Boolean(J?.custom),!J){this.resolver=null;return}this.resolver=new Xj(J);let j=(W)=>({api:W.api?new O8({...Z.api,...W.api}):$.api,view:W.view?new L3({...Z.view,...W.view}):$.view});for(let W of J.groups??[])this.groups.set(W.subdomain,j(W));if(J.custom?.fallback)this.groups.set(zj,j(J.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);if(this.resolver.proxySecretHeader)w7($,this.resolver.proxySecretHeader);let Z=await this.resolver.resolve($);if(!Z)return null;return NZ($,Z),this.dispatchers(Z)}async ask($){if(!this.resolver?.askSecret||$.method!=="GET")return null;let Z=new URL($.url);if(Z.pathname!==aK)return null;if(!Oj(Z.searchParams.get("secret"),this.resolver.askSecret))return null;let J=Z.searchParams.get("domain"),j=J?await this.resolver.allows(J,$):!1;return new Response(null,{status:j?200:404})}dispatchers($){return this.groups.get($?.group??F8)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}viewGroups(){let $=new Set,Z=[];for(let[J,j]of this.groups){if($.has(j.view))continue;$.add(j.view),Z.push({group:J,view:j.view})}return Z}}function G8($){let Z=new Date($??0).getTime();return Number.isFinite(Z)?Z:0}var k7=600000;function q7($,Z){return[k3($,Z),k3($,Z-1)]}class A{static token="auth";config;provider;constructor($={},Z=new h8){this.config={...g7(FW($),$),emailCode:m8($.emailCode)},this.provider=Z}get userProvider(){return this.provider}accessTokenCookieOptions($,Z){return{expires:Z,secure:this.publicOrigin($).startsWith("https://"),httpOnly:!0,domain:this.cookieDomain($)}}publicOrigin($){let Z=I().bound(o0)?I(o0).resolver:null;return Z?Z.publicOrigin($.rawRequest):new URL($.rawRequest.url).origin}cookieDomain($){let Z=this.config.cookieDomain;if(!Z)return;let J=Z==="root"?I(o0).resolver?.root:X1(Z);if(!J)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let j=$.domain?.host??X1(new URL($.rawRequest.url).host);return j===J||j?.endsWith(`.${J}`)?J:void 0}async getSession($,Z){if(!$)return null;if(!v8($))return this.config.migrateLegacySession?this.convertLegacySession($,Z,this.config.migrateLegacySession):null;let J=await this.userProvider.findSession({token:$,userAgent:Z});if(!J?.user)return null;let j=Date.now(),W=G8(J.expiresAt),Y=G8(J.absoluteExpiresAt);if(W<=j||Y<=j)return await this.userProvider.deleteSession({token:$}),null;let O=await this.slideSession(J,j);return O.user.extension=await this.config.extendSession(O.user),O}async convertLegacySession($,Z,J){let j=f.getStore()?.req;if(!j)return null;let W=Date.now(),Y=Math.floor(W/k7),z=null,O=await this.userProvider.findSession({token:$,userAgent:Z});if(O?.user){if(!await J(O,{token:$,req:j,userAgent:Z}))return null;let F=k3($,Y),G=O.user.id;if(await this.userProvider.withLegacySessionLock($,async()=>{if(!await this.userProvider.claimLegacySession({token:$}))return!1;return await this.userProvider.createSessionV2({token:F,userId:G,userAgent:Z,...this.freshLifetime(W)}),!0}))z=F}if(!z){for(let F of q7($,Y))if((await this.userProvider.findSession({token:F,userAgent:Z}))?.user){z=F;break}}if(!z)return null;let X=await this.getSession(z,Z);if(X)j.ctx().setCookie("access_token",z,this.accessTokenCookieOptions(j,new Date(X.expiresAt)));return X}async revokeSession($,Z){if(!$)return await this.userProvider.deleteSession({token:$}),null;if(v8($)||!this.config.migrateLegacySession){let W=await this.userProvider.findSession({token:$,userAgent:Z});return await this.userProvider.deleteSession({token:$}),W}let J=Math.floor(Date.now()/k7),j=q7($,J);return this.userProvider.withLegacySessionLock($,async()=>{let W=await this.userProvider.findSession({token:$,userAgent:Z});for(let Y of j){if(W?.user)break;W=await this.userProvider.findSession({token:Y,userAgent:Z})}await this.userProvider.deleteSession({token:$});for(let Y of j)await this.userProvider.deleteSession({token:Y});return W})}requestCarryingCookie($){let Z=f.getStore()?.req;return Z?.cookies.get("access_token")===$?Z:null}async slideSession($,Z){let J=this.config.sessionExpiresInHours*3600000;if(new Date($.expiresAt).getTime()-Z>=J/2)return $;let j=new Date(Math.min(Z+J,new Date($.absoluteExpiresAt).getTime())),W=await this.userProvider.updateSession({token:$.token,expiresAt:j}),Y=this.requestCarryingCookie($.token);if(Y)Y.ctx().setCookie("access_token",$.token,this.accessTokenCookieOptions(Y,j));if(!W)return $;return{...$,expiresAt:W.expiresAt??j}}freshLifetime($){return{expiresAt:new Date($+this.config.sessionExpiresInHours*3600000),absoluteExpiresAt:new Date($+this.config.sessionAbsoluteExpiresInHours*3600000)}}async generateMagicLink($){}async upsertSession($){await this.userProvider.findSession({token:"",userAgent:""})}async authenticate($){try{let Z=await this.userProvider.findUserByEmailAddress($,!1);if(!Z)throw Error(`User not found with email: ${$}`);let J=await this.createOrUpdateSession({email:$,id:Z.id}),j=new E;if(j.ctx().setCookie("access_token",J.token,this.accessTokenCookieOptions(j,J.expiresAt)),J?.user)J.user.extension=await this.config.extendSession(J.user);return J}catch(Z){console.log(Z)}}async createOrUpdateSessionV2($){let Z=await this.createOrUpdateSession($),J=null;if(Z?.user)J=await this.config.extendSession(Z.user),Z.user.extension=J;return Z}async createOrUpdateSession($){let Z=new E,J=$.id??(await this.userProvider.findUserByEmailAddress($.email,!1))?.id;if(!J)throw new Z$;let j=Bun.env.NODE_ENV==="development"?"local":Z.headers.get("User-Agent"),W=tj(J),Y=await this.userProvider.createSessionV2({token:W,userId:J,userAgent:j,...this.freshLifetime(Date.now())}),z=await this.userProvider.findSession({token:W,userAgent:j??""});return z?.user?z:Y}async createMagicLinkToken($){let Z=await this.userProvider.findUserByEmailAddress($,!1);if(Z){let{pin:J,token:j}=await this.issueOneTimeCode($,6);return{user:Z,email:$,pin:J,token:j}}return{}}async issueOneTimeCode($,Z){await this.userProvider.deleteMagicLinkToken($);let J=await this.config.generateMagicLinkToken($),j=await this.config.generateCode($),W=typeof j==="string"&&j!==""?j:YW(Z);return await this.userProvider.createMagicLinkToken({email:$,token:q3("link",$,J),pin:q3("pin",$,W)}),{email:$,pin:W,token:J}}async verifyOneTimeCode($,Z,J={}){let{expiresInMinutes:j,maxAttempts:W}=this.config.emailCode,Y=await this.userProvider.findMagicLinkTokenByEmail($);if(!Y)return qZ("pin",$,null,Z),{status:"invalid"};let z=G8(Y.createdAt);if(z+j*60000<=Date.now())return qZ("pin",$,null,Z),{status:"expired"};if(!await XW(Y.id,z,W,j))return await this.userProvider.claimMagicLinkToken(Y.id),{status:"too_many_attempts"};if(!qZ("pin",$,Y.pin,Z))return{status:"invalid"};if(J.claim!==!1&&!await this.userProvider.claimMagicLinkToken(Y.id))return{status:"invalid"};return{status:"ok",row:Y}}async verifyMagicLinkToken($,Z){let J=await this.userProvider.findMagicLinkTokenByEmail($),j=qZ("link",$,J?.token,Z);if(!J||!j)return!1;if(G8(J.createdAt)+this.config.emailCode.linkExpiresInMinutes*60000<=Date.now())return!1;return await this.userProvider.claimMagicLinkToken(J.id)}}class N$ extends V0{static getFacadeAccessor(){return A}static async user(){let $=f.getStore(),Z=$?.user;if(!Z){if(Z=await v3(this.getFacadeRoot(),$?.req),Z)$?.setUser(Z)}if(Z)return Z;throw new Z$({redirectTo:b3($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let Z=f.getStore()?.req;return fZ(Z?.search.get(v$),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let Z=await N$.user();if(!await $(Z))throw new A8}static async guardSafe($){let Z=await N$.user();try{return await $(Z)}catch(J){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class K8{static ensure($,Z={}){let J=f.getStore();if(J.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return J.serverQueries??=new MZ(V3(J.req.rawRequest)),J.serverQueries.ensure($,Z,"prefetch")}static async instant($,...Z){let J=K8.ensure($,Z[0]);if(await J.promise,J.status==="rejected")throw J.error;return J.data}static prefetch($,...Z){K8.ensure($,Z[0])}static noPrefetch(){let $=f.getStore();if($.req.kind==="api")throw Error("Query.noPrefetch() cannot be called from an API request");$.serverQueries??=new MZ(V3($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}function y7($,Z,J="/"){let j=new URL($.origin),W=Z.host?Z.host:Z.subdomain?`${Z.subdomain}.${$.root}`:$.root,Y=new URL(J.startsWith("/")?J:`/${J}`,j),z=oK(W);if(!z)throw Error(`"${W}" is not a hostname, so there is no URL for it. Give a bare host, optionally with a port \u2014 no scheme, path or credentials.`);if(Y.hostname=z.hostname,z.port)Y.port=z.port;return Y.toString()}function oK($){try{let Z=new URL(`http://${$.trim()}`);return Z.host===$.trim().toLowerCase()&&Z.pathname==="/"?{hostname:Z.hostname,port:Z.port}:null}catch{return null}}class m7{static absolute($,...Z){return`${process.env.HOST_NAME}${z0(String($),Z[0]??{})}`}static relative($,...Z){return z0(String($),Z[0]??{})}static forDomain($,Z,...J){let j=I(o0).resolver;if(!j)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let W=f.getStore()?.req?.rawRequest,Y=W?j.publicOrigin(W):process.env.HOST_NAME;if(!Y)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return y7({root:j.root,origin:Y},$,z0(String(Z),J[0]??{}))}}class p7{name="Meta";static description($){f.getStore().metadata.description($)}static title($){f.getStore().metadata.title($)}static openGraph($){f.getStore().metadata.openGraph($)}}var rK={set($,Z,J){f.getStore().setCookie($,Z,J)},setIfAbsent($,Z,J){if(f.getStore().req.cookies.has($))return!1;return f.getStore().setCookie($,Z,J),!0},delete($,Z){f.getStore().deleteCookie($,Z)}};class H1 extends V0{static getFacadeAccessor(){return h7}static get client(){return this.getFacadeRoot().client}static get($){return H1.client.get($)}static set($,Z){return H1.client.set($,Z)}static del(...$){return H1.client.del(...$)}static exists($){return H1.client.exists($)}static incr($){return H1.client.incr($)}static expire($,Z){return H1.client.expire($,Z)}static ttl($){return H1.client.ttl($)}}class c7 extends V0{static getFacadeAccessor(){return e0}static consume($,Z={}){return this.getFacadeRoot().consume($,Z)}}class d7 extends V0{static getFacadeAccessor(){return l7}static run($,Z,J){return this.getFacadeRoot().run($,Z,J)}static acquire($,Z={}){return this.getFacadeRoot().acquire($,Z)}}class u7 extends V0{static getFacadeAccessor(){return VZ}static enabled($){return this.getFacadeRoot().enabled($)}static all(){return this.getFacadeRoot().forClient()}static explain($){return this.getFacadeRoot().explain($)}static for($){return this.getFacadeRoot().for($)}static list(){return this.getFacadeRoot().list()}static set($,Z,J){return this.getFacadeRoot().set($,Z,J)}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class Q8{bound;constructor($){this.bound=$}get name(){return this.bound??mZ()}get sql(){return this.connection().sql}get dialect(){return this.connection().dialect}async query($){return await this.run($,"query")}async execute($){let Z=await this.run($,"execute");return Number(Z?.count??0)}async transaction($){let Z=this.name,J=this.connection(Z);return n7(J.sql,(j)=>i7(Z,()=>$(j)),{slowTransactionThreshold:J.config.slowTransactionThreshold,connection:Z})}async schema(){let $=this.connection(),{introspect:Z}=await import("./chunk-et4pv1b1.js");return Z(this.handle()??$.sql,$.dialect)}run($,Z){let J=this.connection(),{text:j,values:W}=o7($,a7(J.dialect),Z);return(this.handle()??J.sql).unsafe(j,W)}handle(){let $=yZ();if($===void 0)return;return mZ()===this.name?$:void 0}connection($=this.name){return s7($),I(pZ).connection($)}}var _Z=new Q8;class r7 extends V0{static getFacadeAccessor(){return pZ}static connection($){return new Q8($)}static get sql(){return _Z.sql}static get dialect(){return _Z.dialect}static query($){return _Z.query($)}static execute($){return _Z.execute($)}static transaction($){return _Z.transaction($)}static schema(){return _Z.schema()}static close(){return this.getFacadeRoot().close()}}export{K1 as qc,HZ as rc,V8 as sc,A$ as tc,xZ as uc,x0 as vc,L8 as wc,_8 as xc,_j as yc,A3 as zc,$$ as Ac,DO as Bc,H8 as Cc,f1 as Dc,M0 as Ec,TO as Fc,VO as Gc,b8 as Hc,v8 as Ic,tj as Jc,e0 as Kc,EZ as Lc,yj as Mc,R$ as Nc,ej as Oc,$W as Pc,w8 as Qc,k8 as Rc,q3 as Sc,qZ as Tc,IB as Uc,FW as Vc,$X as Wc,h8 as Xc,N$ as Yc,r1 as Zc,K8 as _c,m7 as $c,p7 as ad,rK as bd,H1 as cd,c7 as dd,d7 as ed,J7 as fd,s4 as gd,j7 as hd,W7 as id,XK as jd,Y7 as kd,n4 as ld,KK as md,QK as nd,a4 as od,z7 as pd,O7 as qd,VZ as rd,u7 as sd,Q8 as td,r7 as ud,N4 as vd,L4 as wd,XD as xd,M5 as yd,C5 as zd,R3 as Ad,UZ as Bd,PD as Cd,L5 as Dd,_5 as Ed,u4 as Fd,CZ as Gd,o4 as Hd,pT as Id,Zj as Jd,RK as Kd,e4 as Ld,qK as Md,L3 as Nd,jj as Od,S7 as Pd,x7 as Qd,O8 as Rd,o0 as Sd,A as Td,bj as Ud,vj as Vd,wj as Wd,hj as Xd,cj as Yd,lj as Zd,w$ as _d,G0 as $d,U1 as ae,q$ as be,b1 as ce,g$ as de,y$ as ee,m$ as fe,vZ as ge,RZ as he,v1 as ie,kZ as je,nj as ke};
16
-
17
- //# debugId=48421F6974C91AD564756E2164756E21
@@ -1,5 +0,0 @@
1
- // @bun
2
- import{oc as o}from"./chunk-zhs1r1z0.js";import{pc as i}from"./chunk-qd2v93y4.js";import{ig as t}from"./chunk-bn5yn731.js";import{hh as r}from"./chunk-7tx5y712.js";class n extends i{register(){this.app.singleton(r,()=>new r(t(o(),this.app.config.get("translation",{}))))}}
3
- export{n as eb};
4
-
5
- //# debugId=77A8E90EA59741AA64756E2164756E21
@@ -1,19 +0,0 @@
1
- // @bun
2
- import{ec as B,gc as T}from"./chunk-1pem26zc.js";import{vh as _,wh as $,xh as L}from"./chunk-m6ystvtk.js";class D extends Error{code;constructor(q,z=1){super(q);this.code=z;this.name="CommandFailed"}}class Y{static commandName="unset";static description="";static args=[];static options=[];run(q){}}function u(q){return q}function A(){return{commands:[],commandsDir:"app/commands"}}var S=Symbol.for("gemi.console.builder");function E(q){if(q.trim()==="")throw Error("A command name cannot be empty.");if(/[{}]/.test(q)||/\s/.test(q))throw Error(`Invalid command name ${JSON.stringify(q)}. gemi does not parse a signature string; the name is the whole of it. Declare arguments with .arg() and flags with .option():
3
-
4
- defineCommand("mail:send")
5
- .arg("user", { required: true })
6
- .option("queue", { type: "boolean" })
7
- .handle(async ({ args, options }) => { ... })`)}function p(q){E(q);let z=[],F=[],J="",V={[S]:q,describe(G){return J=G,V},arg(G,H={}){if(H.required&&H.default!==void 0)throw Error(`Argument "${G}" of command "${q}" is both required and has a default. An argument that is supplied when absent cannot also be `+"absent \u2014 drop one.");if(H.variadic&&H.default!==void 0)throw Error(`Argument "${G}" of command "${q}" is variadic and has a default. A variadic argument collects the remaining values and is an empty list when there are none, so the default could never `+"apply \u2014 drop it, or drop `variadic`.");let Q=z.find((P)=>P.variadic);if(Q)throw Error(`Argument "${G}" of command "${q}" is declared after the variadic argument "${Q.name}", which collects everything that follows, so "${G}" could never receive a value. A variadic argument must be declared last.`);if(z.some((P)=>P.name===G))throw Error(`Command "${q}" declares the argument "${G}" twice.`);return z.push({...H,name:G}),V},option(G,H){if(F.some((X)=>X.name===G))throw Error(`Command "${q}" declares the option "${G}" twice.`);let Q="alias"in H?H.alias:void 0,P=Q===void 0?void 0:F.find((X)=>("alias"in X)&&X.alias===Q);if(P)throw Error(`Options "${P.name}" and "${G}" of command "${q}" both use the alias "-${Q}".`);return F.push({...H,name:G}),V},handle(G){let H=q,Q=J,P=class extends Y{static commandName=H;static description=Q;static args=[...z];static options=[...F];run(X){return G(X)}};return delete V[S],Object.defineProperty(P,"name",{value:H,configurable:!0}),P}};return V}function C(q){return typeof q==="object"&&q!==null&&typeof q[S]==="string"}class Z{name;cron;withoutOverlapping=!1;onOneServer=!1;shouldRun(){return!0}callback(q){}onTick(){}onComplete(){}static exp(q){return q}}function d(q){return q}function I(){return{jobs:[],jobsDir:"app/cron"}}function o(q){return q}function U(){return{listeners:[],listenersDir:"app/listeners"}}class M{static name="unset";static event;queued=!1;maxAttempts=3;backoff=0;worker=!1}import{existsSync as W}from"fs";import{dirname as R,isAbsolute as k,join as j}from"path";function K(q){return k(q)?q:j(L(),q)}function O(q,z,F){if(W(q)||W(R(q)))return;console.warn(`No ${z} were discovered: neither ${q} nor the directory above it exists, so this process cannot see the application's source. If this is a deploy that ships only the build output, list the classes explicitly in app/config/${F}.ts so they travel with it.`)}async function Vq(q=T().jobsDir){let z=K(q);O(z,"queue jobs","queue");let F=await $(z,B);return x(F),F}function x(q){for(let z of q){if(Object.getOwnPropertyDescriptor(z,"name")?.writable)continue;console.warn(`Queued job ${z.name} does not declare \`static name\`, so it is registered under its class name. A production build minifies the class that dispatches it and renames it, while discovery reads this `+"file from source and does not \u2014 so the dispatch would be dropped in "+`production and nowhere else. Add: static name = "${z.name}";`)}}async function Xq(q=I().jobsDir){let z=K(q);return O(z,"cron jobs","schedule"),await $(z,Z)}async function Yq(q=A().commandsDir){let z=K(q);O(z,"commands","command");let F=[],J=await $(z,Y,[],(V,G)=>{if(C(V))F.push(G)});return y(F),J}function y(q){if(q.length===0)return;let z=q.length===1?`${q[0]} exports a command builder that never called \`.handle()\``:`${q.length} files export a command builder that never called \`.handle()\`:
8
- ${q.join(`
9
- `)}`;throw new _(`${z}, so there is no command to run. \`.handle()\` is what turns `+`the chain into a command \u2014 finish it:
10
-
11
- `+` export default defineCommand("my-command")
12
- .handle(async ({ line }) => { line("hello") })`)}async function $q(q=U().listenersDir){let z=K(q);O(z,"event listeners","events");let F=await $(z,M);return w(F),N(F),f(F),F}function w(q){let z=q.filter((F)=>!F.event);if(z.length===0)return;throw new _(`${z.map((F)=>F.name).join(", ")} declare no \`static event\`, so there is no event name to register them under and their \`handle\` would never run. Every listener binds to exactly one event:
13
-
14
- static event = UserRegistered;
15
-
16
- If this is an abstract base its subclasses extend, move it out of the `+"listeners directory \u2014 the walk excludes gemi's `Listener` and "+"nothing else, so a base sitting beside its subclasses is registered and run like one of them.")}function N(q){for(let z of q){if(Object.getOwnPropertyDescriptor(z,"name")?.writable)continue;console.warn(`Event listener ${z.name} does not declare \`static name\`, so it is registered under its class name, which a production build renames. Nothing reads that name across a build boundary while the `+"listener is sync, which is why this is a warning \u2014 but adding "+`\`queued = true\` to it is refused at boot for the same reason, because the queue's key is that string. Add: static name = "${z.name}";`)}}function f(q){let z=new Set;for(let{event:F}of q){if(z.has(F))continue;if(Object.getOwnPropertyDescriptor(F,"name")?.writable)continue;z.add(F),console.warn(`Event ${F.name} does not declare \`static name\`, so it is dispatched under its class name. A production build minifies the code that dispatches it and renames the class, while discovery reads `+"the listener's copy from source and does not \u2014 so the dispatch would "+`reach no listener in production and nowhere else. Add: static name = "${F.name}";`)}}
17
- export{D as Ob,Y as Pb,u as Qb,A as Rb,p as Sb,Z as Tb,d as Ub,I as Vb,o as Wb,U as Xb,M as Yb,Vq as Zb,Xq as _b,Yq as $b,$q as ac};
18
-
19
- //# debugId=CD91943D947C5AF864756E2164756E21