gemi 0.108.0 → 0.109.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/app/index.js +1 -1
  4. package/dist/bin/gemi.js +74 -16
  5. package/dist/bin/gemi.js.map +6 -5
  6. package/dist/bun/plugin.js +1 -1
  7. package/dist/bun/preload.js +1 -1
  8. package/dist/{chunk-9jz4rggd.js → chunk-1es50p4k.js} +2 -2
  9. package/dist/{chunk-9jz4rggd.js.map → chunk-1es50p4k.js.map} +1 -1
  10. package/dist/{chunk-2gmgd05c.js → chunk-367kyrdx.js} +2 -2
  11. package/dist/{chunk-2gmgd05c.js.map → chunk-367kyrdx.js.map} +1 -1
  12. package/dist/{chunk-h7pafjej.js → chunk-3x86bhfn.js} +3 -3
  13. package/dist/{chunk-h7pafjej.js.map → chunk-3x86bhfn.js.map} +1 -1
  14. package/dist/{chunk-kda25fn4.js → chunk-52vsdnny.js} +1 -1
  15. package/dist/{chunk-m31pfz1s.js → chunk-5d6eaxab.js} +2 -2
  16. package/dist/{chunk-m31pfz1s.js.map → chunk-5d6eaxab.js.map} +1 -1
  17. package/dist/{chunk-njkk498k.js → chunk-6zekebzt.js} +2 -2
  18. package/dist/{chunk-njkk498k.js.map → chunk-6zekebzt.js.map} +1 -1
  19. package/dist/{chunk-00y49jcf.js → chunk-7mc5e61r.js} +2 -2
  20. package/dist/{chunk-00y49jcf.js.map → chunk-7mc5e61r.js.map} +1 -1
  21. package/dist/{chunk-47rgq59q.js → chunk-7ssjzp87.js} +2 -2
  22. package/dist/{chunk-47rgq59q.js.map → chunk-7ssjzp87.js.map} +1 -1
  23. package/dist/{chunk-5wt25tyd.js → chunk-9m18pknp.js} +2 -2
  24. package/dist/{chunk-5wt25tyd.js.map → chunk-9m18pknp.js.map} +1 -1
  25. package/dist/{chunk-vj2t77x1.js → chunk-9qw9fa6z.js} +2 -2
  26. package/dist/{chunk-vj2t77x1.js.map → chunk-9qw9fa6z.js.map} +1 -1
  27. package/dist/{chunk-v52dyw0q.js → chunk-c8dhvdrs.js} +2 -2
  28. package/dist/{chunk-v52dyw0q.js.map → chunk-c8dhvdrs.js.map} +1 -1
  29. package/dist/{chunk-kstvyvr0.js → chunk-d2tngs73.js} +2 -2
  30. package/dist/{chunk-kstvyvr0.js.map → chunk-d2tngs73.js.map} +1 -1
  31. package/dist/{chunk-q7y9v2v5.js → chunk-d5sbnzng.js} +13 -13
  32. package/dist/{chunk-q7y9v2v5.js.map → chunk-d5sbnzng.js.map} +5 -4
  33. package/dist/{chunk-1npdp1w2.js → chunk-dpy08xw4.js} +2 -2
  34. package/dist/{chunk-1npdp1w2.js.map → chunk-dpy08xw4.js.map} +1 -1
  35. package/dist/{chunk-h3t4n0bn.js → chunk-ehasw3qm.js} +2 -2
  36. package/dist/{chunk-h3t4n0bn.js.map → chunk-ehasw3qm.js.map} +1 -1
  37. package/dist/{chunk-331s9wqr.js → chunk-eyg88bgv.js} +2 -2
  38. package/dist/{chunk-331s9wqr.js.map → chunk-eyg88bgv.js.map} +1 -1
  39. package/dist/{chunk-fq3sb3xt.js → chunk-f7jhkg8x.js} +3 -3
  40. package/dist/{chunk-fq3sb3xt.js.map → chunk-f7jhkg8x.js.map} +1 -1
  41. package/dist/chunk-fe1pcnw6.js +6 -0
  42. package/dist/chunk-fe1pcnw6.js.map +11 -0
  43. package/dist/chunk-fj6yftm7.js +58 -0
  44. package/dist/{chunk-b9av1sgb.js.map → chunk-fj6yftm7.js.map} +3 -3
  45. package/dist/{chunk-2mhx4e4g.js → chunk-g5a3ptsa.js} +2 -2
  46. package/dist/{chunk-2mhx4e4g.js.map → chunk-g5a3ptsa.js.map} +1 -1
  47. package/dist/{chunk-2q7m8a16.js → chunk-g74qwhvf.js} +2 -2
  48. package/dist/{chunk-2q7m8a16.js.map → chunk-g74qwhvf.js.map} +1 -1
  49. package/dist/{chunk-eytdyahy.js → chunk-g7fr2cy2.js} +2 -2
  50. package/dist/{chunk-eytdyahy.js.map → chunk-g7fr2cy2.js.map} +1 -1
  51. package/dist/{chunk-yebaheh7.js → chunk-ga533cpz.js} +2 -2
  52. package/dist/{chunk-yebaheh7.js.map → chunk-ga533cpz.js.map} +1 -1
  53. package/dist/{chunk-q2fyp44f.js → chunk-gdsby5jh.js} +2 -2
  54. package/dist/{chunk-q2fyp44f.js.map → chunk-gdsby5jh.js.map} +1 -1
  55. package/dist/{chunk-sbyqs03h.js → chunk-grs8dnkd.js} +2 -2
  56. package/dist/{chunk-sbyqs03h.js.map → chunk-grs8dnkd.js.map} +1 -1
  57. package/dist/{chunk-k17prwhx.js → chunk-h15eae7g.js} +2 -2
  58. package/dist/{chunk-k17prwhx.js.map → chunk-h15eae7g.js.map} +1 -1
  59. package/dist/{chunk-9mqqr05d.js → chunk-h6g9g8qc.js} +3 -3
  60. package/dist/{chunk-9mqqr05d.js.map → chunk-h6g9g8qc.js.map} +1 -1
  61. package/dist/{chunk-82hpq0bq.js → chunk-hf32yq23.js} +2 -2
  62. package/dist/{chunk-82hpq0bq.js.map → chunk-hf32yq23.js.map} +1 -1
  63. package/dist/{chunk-xpyhmg45.js → chunk-hgz8sx40.js} +2 -2
  64. package/dist/{chunk-3s3awh38.js.map → chunk-hgz8sx40.js.map} +1 -1
  65. package/dist/{chunk-8pynv9rw.js → chunk-jc4j61xb.js} +2 -2
  66. package/dist/{chunk-8pynv9rw.js.map → chunk-jc4j61xb.js.map} +1 -1
  67. package/dist/{chunk-h4x7cba0.js → chunk-jgtean4t.js} +2 -2
  68. package/dist/{chunk-h4x7cba0.js.map → chunk-jgtean4t.js.map} +1 -1
  69. package/dist/{chunk-6rz8kyqb.js → chunk-jm4jn28j.js} +2 -2
  70. package/dist/{chunk-6rz8kyqb.js.map → chunk-jm4jn28j.js.map} +1 -1
  71. package/dist/{chunk-jnw73s8c.js → chunk-k1ezptt8.js} +2 -2
  72. package/dist/{chunk-jnw73s8c.js.map → chunk-k1ezptt8.js.map} +1 -1
  73. package/dist/{chunk-xg9vye7c.js → chunk-m9609t1y.js} +1 -1
  74. package/dist/{chunk-mhq2bd9c.js → chunk-mp5krm14.js} +3 -3
  75. package/dist/{chunk-mhq2bd9c.js.map → chunk-mp5krm14.js.map} +1 -1
  76. package/dist/{chunk-k9qmr2wa.js → chunk-ngw4xzrt.js} +3 -3
  77. package/dist/{chunk-k9qmr2wa.js.map → chunk-ngw4xzrt.js.map} +1 -1
  78. package/dist/{chunk-ydkjf626.js → chunk-nxxx0m1a.js} +2 -2
  79. package/dist/{chunk-ydkjf626.js.map → chunk-nxxx0m1a.js.map} +1 -1
  80. package/dist/{chunk-rn2kgbg4.js → chunk-pa3khk46.js} +2 -2
  81. package/dist/{chunk-rn2kgbg4.js.map → chunk-pa3khk46.js.map} +1 -1
  82. package/dist/{chunk-wsftnxzs.js → chunk-q8k7f11z.js} +2 -2
  83. package/dist/{chunk-wsftnxzs.js.map → chunk-q8k7f11z.js.map} +1 -1
  84. package/dist/{chunk-rjernda5.js → chunk-qnq110tw.js} +2 -2
  85. package/dist/{chunk-rjernda5.js.map → chunk-qnq110tw.js.map} +1 -1
  86. package/dist/{chunk-ftgd68se.js → chunk-qyyxzy04.js} +2 -2
  87. package/dist/{chunk-ftgd68se.js.map → chunk-qyyxzy04.js.map} +1 -1
  88. package/dist/{chunk-pj2e1p07.js → chunk-qz9aaw5x.js} +2 -2
  89. package/dist/{chunk-pj2e1p07.js.map → chunk-qz9aaw5x.js.map} +1 -1
  90. package/dist/{chunk-2xqrh6d0.js → chunk-r9gzbjc5.js} +1 -1
  91. package/dist/{chunk-wedwkqe7.js → chunk-rgfzqwpg.js} +3 -3
  92. package/dist/{chunk-wedwkqe7.js.map → chunk-rgfzqwpg.js.map} +1 -1
  93. package/dist/{chunk-hdhahvd4.js → chunk-rjcsdazt.js} +2 -2
  94. package/dist/{chunk-hdhahvd4.js.map → chunk-rjcsdazt.js.map} +1 -1
  95. package/dist/chunk-s5aa4hty.js +17 -0
  96. package/dist/{chunk-ncfxmtd5.js.map → chunk-s5aa4hty.js.map} +8 -6
  97. package/dist/{chunk-rh9j8cwv.js → chunk-sp2v357a.js} +3 -3
  98. package/dist/{chunk-rh9j8cwv.js.map → chunk-sp2v357a.js.map} +1 -1
  99. package/dist/{chunk-cfsscms3.js → chunk-t0bp8nrc.js} +4 -4
  100. package/dist/{chunk-cfsscms3.js.map → chunk-t0bp8nrc.js.map} +1 -1
  101. package/dist/{chunk-kqff894s.js → chunk-t3qw9syt.js} +2 -2
  102. package/dist/{chunk-kqff894s.js.map → chunk-t3qw9syt.js.map} +1 -1
  103. package/dist/{chunk-zrdbytx4.js → chunk-t85rca2p.js} +2 -2
  104. package/dist/{chunk-zrdbytx4.js.map → chunk-t85rca2p.js.map} +1 -1
  105. package/dist/{chunk-tyhrrnp5.js → chunk-tr9mxdth.js} +3 -3
  106. package/dist/{chunk-tyhrrnp5.js.map → chunk-tr9mxdth.js.map} +1 -1
  107. package/dist/{chunk-6wrhc9bq.js → chunk-vee4j6ft.js} +2 -2
  108. package/dist/{chunk-6wrhc9bq.js.map → chunk-vee4j6ft.js.map} +1 -1
  109. package/dist/{chunk-kqz8jp6v.js → chunk-vna85rdq.js} +2 -2
  110. package/dist/{chunk-kqz8jp6v.js.map → chunk-vna85rdq.js.map} +1 -1
  111. package/dist/{chunk-4rr9wmh8.js → chunk-vsnmdtrs.js} +2 -2
  112. package/dist/{chunk-4rr9wmh8.js.map → chunk-vsnmdtrs.js.map} +1 -1
  113. package/dist/{chunk-anp4kv3w.js → chunk-vwkdfngg.js} +1 -1
  114. package/dist/chunk-w3j53r0a.js +24 -0
  115. package/dist/{chunk-h2hdpm70.js.map → chunk-w3j53r0a.js.map} +4 -4
  116. package/dist/{chunk-gqpge54c.js → chunk-wdpdqjr1.js} +2 -2
  117. package/dist/{chunk-gqpge54c.js.map → chunk-wdpdqjr1.js.map} +1 -1
  118. package/dist/{chunk-wzqkdmjd.js → chunk-whe0x70j.js} +2 -2
  119. package/dist/{chunk-wzqkdmjd.js.map → chunk-whe0x70j.js.map} +1 -1
  120. package/dist/{chunk-1rs13253.js → chunk-wqsdjweb.js} +3 -3
  121. package/dist/{chunk-1rs13253.js.map → chunk-wqsdjweb.js.map} +1 -1
  122. package/dist/{chunk-3s3awh38.js → chunk-wvwee7dn.js} +2 -2
  123. package/dist/{chunk-xpyhmg45.js.map → chunk-wvwee7dn.js.map} +1 -1
  124. package/dist/{chunk-ffagkj3x.js → chunk-y66ntxbg.js} +2 -2
  125. package/dist/{chunk-ffagkj3x.js.map → chunk-y66ntxbg.js.map} +1 -1
  126. package/dist/chunk-z9x8x3wq.js +5 -0
  127. package/dist/{chunk-mrvcaakf.js.map → chunk-z9x8x3wq.js.map} +1 -1
  128. package/dist/{chunk-we2sj339.js → chunk-zh1t33nq.js} +2 -2
  129. package/dist/{chunk-we2sj339.js.map → chunk-zh1t33nq.js.map} +1 -1
  130. package/dist/{chunk-661wezaf.js → chunk-zhm3qvrc.js} +2 -2
  131. package/dist/{chunk-661wezaf.js.map → chunk-zhm3qvrc.js.map} +1 -1
  132. package/dist/{chunk-kh273hj0.js → chunk-zys7kecf.js} +2 -2
  133. package/dist/{chunk-kh273hj0.js.map → chunk-zys7kecf.js.map} +1 -1
  134. package/dist/{chunk-fwympxqk.js → chunk-zz7h6tdr.js} +2 -2
  135. package/dist/{chunk-fwympxqk.js.map → chunk-zz7h6tdr.js.map} +1 -1
  136. package/dist/chunks/{ThemeProvider-Cqfwr6dk.js → ThemeProvider-BgLyzzOL.js} +8 -2
  137. package/dist/chunks/ThemeProvider-BgLyzzOL.js.map +1 -0
  138. package/dist/client/ClientRouterContext.d.ts.map +1 -1
  139. package/dist/client/ServerDataProvider.d.ts +2 -0
  140. package/dist/client/ServerDataProvider.d.ts.map +1 -1
  141. package/dist/client/createRoot.d.ts.map +1 -1
  142. package/dist/client/index.d.ts +2 -0
  143. package/dist/client/index.d.ts.map +1 -1
  144. package/dist/client/index.js +72 -3
  145. package/dist/client/index.js.map +1 -1
  146. package/dist/client/islands.d.ts +84 -0
  147. package/dist/client/islands.d.ts.map +1 -0
  148. package/dist/config/index.js +1 -1
  149. package/dist/console/run.js +2 -2
  150. package/dist/console/run.js.map +1 -1
  151. package/dist/container/index.js +2 -2
  152. package/dist/container/index.js.map +1 -1
  153. package/dist/database/index.js +2 -2
  154. package/dist/database/index.js.map +1 -1
  155. package/dist/email/index.js +2 -2
  156. package/dist/email/index.js.map +1 -1
  157. package/dist/facades/index.js +2 -2
  158. package/dist/facades/index.js.map +1 -1
  159. package/dist/foundation/index.js +2 -2
  160. package/dist/foundation/index.js.map +1 -1
  161. package/dist/http/ViewRouter.d.ts +38 -0
  162. package/dist/http/ViewRouter.d.ts.map +1 -1
  163. package/dist/http/index.d.ts +1 -1
  164. package/dist/http/index.d.ts.map +1 -1
  165. package/dist/http/index.js +2 -2
  166. package/dist/http/index.js.map +1 -1
  167. package/dist/i18n/dictionaryRuntime.js +2 -2
  168. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  169. package/dist/i18n/index.js +2 -2
  170. package/dist/i18n/index.js.map +1 -1
  171. package/dist/kernel/index.js +2 -2
  172. package/dist/kernel/index.js.map +1 -1
  173. package/dist/orm/index.js +2 -2
  174. package/dist/orm/index.js.map +1 -1
  175. package/dist/server/devFetch.d.ts.map +1 -1
  176. package/dist/server/httpProd.d.ts.map +1 -1
  177. package/dist/server/index.js +2 -2
  178. package/dist/server/index.js.map +1 -1
  179. package/dist/server/modulePreloads.d.ts +17 -0
  180. package/dist/server/modulePreloads.d.ts.map +1 -1
  181. package/dist/server/styles.d.ts +3 -1
  182. package/dist/server/styles.d.ts.map +1 -1
  183. package/dist/services/index.d.ts +1 -0
  184. package/dist/services/index.d.ts.map +1 -1
  185. package/dist/services/index.js +3 -3
  186. package/dist/services/index.js.map +2 -2
  187. package/dist/services/queue/work.js +2 -2
  188. package/dist/services/queue/work.js.map +1 -1
  189. package/dist/services/router/ViewRouteDispatcher.d.ts +27 -1
  190. package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
  191. package/dist/services/router/createFlatViewRoutes.d.ts +13 -1
  192. package/dist/services/router/createFlatViewRoutes.d.ts.map +1 -1
  193. package/dist/services/router/staticDocument.d.ts +44 -0
  194. package/dist/services/router/staticDocument.d.ts.map +1 -0
  195. package/dist/support/index.js +2 -2
  196. package/dist/support/index.js.map +1 -1
  197. package/dist/testing/index.js +1 -1
  198. package/dist/vite/index.mjs +72 -3
  199. package/dist/vitest/index.js +1 -1
  200. package/package.json +1 -1
  201. package/dist/chunk-b9av1sgb.js +0 -58
  202. package/dist/chunk-cewyag0d.js +0 -6
  203. package/dist/chunk-cewyag0d.js.map +0 -11
  204. package/dist/chunk-h2hdpm70.js +0 -24
  205. package/dist/chunk-mrvcaakf.js +0 -5
  206. package/dist/chunk-ncfxmtd5.js +0 -17
  207. package/dist/chunks/ThemeProvider-Cqfwr6dk.js.map +0 -1
  208. /package/dist/{chunk-kda25fn4.js.map → chunk-52vsdnny.js.map} +0 -0
  209. /package/dist/{chunk-xg9vye7c.js.map → chunk-m9609t1y.js.map} +0 -0
  210. /package/dist/{chunk-2xqrh6d0.js.map → chunk-r9gzbjc5.js.map} +0 -0
  211. /package/dist/{chunk-anp4kv3w.js.map → chunk-vwkdfngg.js.map} +0 -0
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{H as A}from"./chunk-kh273hj0.js";import{V as T}from"./chunk-pj2e1p07.js";import"./chunk-eytdyahy.js";import{$ as y}from"./chunk-8pynv9rw.js";import{qh as r}from"./chunk-3s3awh38.js";var u=r(A(),1);var i=r(y(),1),E=r(A(),1);import{exec as d}from"child_process";import{promisify as I}from"util";var x=r(T(),1),_=(c,n,e)=>{if(n.Version!==1)throw Error(`Profile ${c} credential_process did not return Version 1.`);if(n.AccessKeyId===void 0||n.SecretAccessKey===void 0)throw Error(`Profile ${c} credential_process returned invalid credentials.`);if(n.Expiration){let w=new Date;if(new Date(n.Expiration)<w)throw Error(`Profile ${c} credential_process returned expired credentials.`)}let s=n.AccountId;if(!s&&e?.[c]?.aws_account_id)s=e[c].aws_account_id;let t={accessKeyId:n.AccessKeyId,secretAccessKey:n.SecretAccessKey,...n.SessionToken&&{sessionToken:n.SessionToken},...n.Expiration&&{expiration:new Date(n.Expiration)},...n.CredentialScope&&{credentialScope:n.CredentialScope},...s&&{accountId:s}};return x.setCredentialFeature(t,"CREDENTIALS_PROCESS","w"),t};var K=async(c,n,e)=>{let s=n[c];if(n[c]){let t=s.credential_process;if(t!==void 0){let w=I(E.externalDataInterceptor?.getTokenRecord?.().exec??d);try{let{stdout:o}=await w(t),S;try{S=JSON.parse(o.trim())}catch{throw Error(`Profile ${c} credential_process returned invalid JSON.`)}return _(c,S,n)}catch(o){throw new i.CredentialsProviderError(o.message,{logger:e})}}else throw new i.CredentialsProviderError(`Profile ${c} did not contain credential_process.`,{logger:e})}else throw new i.CredentialsProviderError(`Profile ${c} could not be found in shared credentials file.`,{logger:e})};var R=(c={})=>async({callerClientConfig:n}={})=>{c.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");let e=await u.parseKnownFiles(c);return K(u.getProfileName({profile:c.profile??n?.profile}),e,c.logger)};export{R as fromProcess};
2
+ import{H as A}from"./chunk-zys7kecf.js";import{V as T}from"./chunk-qz9aaw5x.js";import"./chunk-g7fr2cy2.js";import{$ as y}from"./chunk-jc4j61xb.js";import{rh as r}from"./chunk-wvwee7dn.js";var u=r(A(),1);var i=r(y(),1),E=r(A(),1);import{exec as d}from"child_process";import{promisify as I}from"util";var x=r(T(),1),_=(c,n,e)=>{if(n.Version!==1)throw Error(`Profile ${c} credential_process did not return Version 1.`);if(n.AccessKeyId===void 0||n.SecretAccessKey===void 0)throw Error(`Profile ${c} credential_process returned invalid credentials.`);if(n.Expiration){let w=new Date;if(new Date(n.Expiration)<w)throw Error(`Profile ${c} credential_process returned expired credentials.`)}let s=n.AccountId;if(!s&&e?.[c]?.aws_account_id)s=e[c].aws_account_id;let t={accessKeyId:n.AccessKeyId,secretAccessKey:n.SecretAccessKey,...n.SessionToken&&{sessionToken:n.SessionToken},...n.Expiration&&{expiration:new Date(n.Expiration)},...n.CredentialScope&&{credentialScope:n.CredentialScope},...s&&{accountId:s}};return x.setCredentialFeature(t,"CREDENTIALS_PROCESS","w"),t};var K=async(c,n,e)=>{let s=n[c];if(n[c]){let t=s.credential_process;if(t!==void 0){let w=I(E.externalDataInterceptor?.getTokenRecord?.().exec??d);try{let{stdout:o}=await w(t),S;try{S=JSON.parse(o.trim())}catch{throw Error(`Profile ${c} credential_process returned invalid JSON.`)}return _(c,S,n)}catch(o){throw new i.CredentialsProviderError(o.message,{logger:e})}}else throw new i.CredentialsProviderError(`Profile ${c} did not contain credential_process.`,{logger:e})}else throw new i.CredentialsProviderError(`Profile ${c} could not be found in shared credentials file.`,{logger:e})};var R=(c={})=>async({callerClientConfig:n}={})=>{c.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");let e=await u.parseKnownFiles(c);return K(u.getProfileName({profile:c.profile??n?.profile}),e,c.logger)};export{R as fromProcess};
3
3
 
4
- //# debugId=6C647A27BFD1CB5464756E2164756E21
4
+ //# debugId=4831F73829DFFBEF64756E2164756E21
@@ -7,6 +7,6 @@
7
7
  "import { setCredentialFeature } from \"@aws-sdk/core/client\";\nexport const getValidatedProcessCredentials = (profileName, data, profiles) => {\n if (data.Version !== 1) {\n throw Error(`Profile ${profileName} credential_process did not return Version 1.`);\n }\n if (data.AccessKeyId === undefined || data.SecretAccessKey === undefined) {\n throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);\n }\n if (data.Expiration) {\n const currentTime = new Date();\n const expireTime = new Date(data.Expiration);\n if (expireTime < currentTime) {\n throw Error(`Profile ${profileName} credential_process returned expired credentials.`);\n }\n }\n let accountId = data.AccountId;\n if (!accountId && profiles?.[profileName]?.aws_account_id) {\n accountId = profiles[profileName].aws_account_id;\n }\n const credentials = {\n accessKeyId: data.AccessKeyId,\n secretAccessKey: data.SecretAccessKey,\n ...(data.SessionToken && { sessionToken: data.SessionToken }),\n ...(data.Expiration && { expiration: new Date(data.Expiration) }),\n ...(data.CredentialScope && { credentialScope: data.CredentialScope }),\n ...(accountId && { accountId }),\n };\n setCredentialFeature(credentials, \"CREDENTIALS_PROCESS\", \"w\");\n return credentials;\n};\n"
8
8
  ],
9
9
  "mappings": ";qNAAA,SCAA,SACA,KACA,SAAS,sBACT,oBAAS,aCHT,eACa,EAAiC,CAAC,EAAa,EAAM,IAAa,CAC3E,GAAI,EAAK,UAAY,EACjB,MAAM,MAAM,WAAW,gDAA0D,EAErF,GAAI,EAAK,cAAgB,QAAa,EAAK,kBAAoB,OAC3D,MAAM,MAAM,WAAW,oDAA8D,EAEzF,GAAI,EAAK,WAAY,CACjB,IAAM,EAAc,IAAI,KAExB,GADmB,IAAI,KAAK,EAAK,UAAU,EAC1B,EACb,MAAM,MAAM,WAAW,oDAA8D,EAG7F,IAAI,EAAY,EAAK,UACrB,GAAI,CAAC,GAAa,IAAW,IAAc,eACvC,EAAY,EAAS,GAAa,eAEtC,IAAM,EAAc,CAChB,YAAa,EAAK,YAClB,gBAAiB,EAAK,mBAClB,EAAK,cAAgB,CAAE,aAAc,EAAK,YAAa,KACvD,EAAK,YAAc,CAAE,WAAY,IAAI,KAAK,EAAK,UAAU,CAAE,KAC3D,EAAK,iBAAmB,CAAE,gBAAiB,EAAK,eAAgB,KAChE,GAAa,CAAE,WAAU,CACjC,EAEA,OADA,uBAAqB,EAAa,sBAAuB,GAAG,EACrD,GDvBJ,IAAM,EAA4B,MAAO,EAAa,EAAU,IAAW,CAC9E,IAAM,EAAU,EAAS,GACzB,GAAI,EAAS,GAAc,CACvB,IAAM,EAAoB,EAAQ,mBAClC,GAAI,IAAsB,OAAW,CACjC,IAAM,EAAc,EAAU,2BAAyB,iBAAiB,EAAE,MAAQ,CAAI,EACtF,GAAI,CACA,IAAQ,UAAW,MAAM,EAAY,CAAiB,EAClD,EACJ,GAAI,CACA,EAAO,KAAK,MAAM,EAAO,KAAK,CAAC,EAEnC,KAAM,CACF,MAAM,MAAM,WAAW,6CAAuD,EAElF,OAAO,EAA+B,EAAa,EAAM,CAAQ,EAErE,MAAO,EAAO,CACV,MAAM,IAAI,2BAAyB,EAAM,QAAS,CAAE,QAAO,CAAC,GAIhE,WAAM,IAAI,2BAAyB,WAAW,wCAAmD,CAAE,QAAO,CAAC,EAI/G,WAAM,IAAI,2BAAyB,WAAW,mDAA8D,CACxG,QACJ,CAAC,GD/BF,IAAM,EAAc,CAAC,EAAO,CAAC,IAAM,OAAS,sBAAuB,CAAC,IAAM,CAC7E,EAAK,QAAQ,MAAM,oDAAoD,EACvE,IAAM,EAAW,MAAM,kBAAgB,CAAI,EAC3C,OAAO,EAA0B,iBAAe,CAC5C,QAAS,EAAK,SAAW,GAAoB,OACjD,CAAC,EAAG,EAAU,EAAK,MAAM",
10
- "debugId": "6C647A27BFD1CB5464756E2164756E21",
10
+ "debugId": "4831F73829DFFBEF64756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -0,0 +1,17 @@
1
+ // @bun
2
+ import{fe as GJ,me as h5}from"./chunk-3x86bhfn.js";import{df as p5,te as IZ,ye as M3}from"./chunk-dpy08xw4.js";import{Af as Hj,Bf as xj,Cf as Mj,Ef as e1,Ff as B0,Gf as aO,Of as C9,Pf as L$,Qf as R5,ef as fj,if as M5,jf as k4,kf as Cj,lf as Kj,of as Uj,pf as Qj,qf as MZ,rf as z5,sf as S5,tf as D4,uf as p,zf as A}from"./chunk-sp2v357a.js";import{Sf as C3,Tf as q0,Uf as x1,Vf as y4}from"./chunk-zz7h6tdr.js";import{Wf as o9,Xf as t2,Yf as x}from"./chunk-6zekebzt.js";import{$f as w5}from"./chunk-wdpdqjr1.js";import{ag as x5}from"./chunk-9m18pknp.js";import{bg as I5,cg as yZ,dg as mZ,eg as g5,fg as y5,qg as m5}from"./chunk-ngw4xzrt.js";import{Fg as pZ}from"./chunk-vsnmdtrs.js";import{Kg as D5,Pg as e2}from"./chunk-7ssjzp87.js";import{Wg as B5,_g as s}from"./chunk-g74qwhvf.js";import{$g as CZ,ch as I}from"./chunk-h6g9g8qc.js";import{qh as N5}from"./chunk-hf32yq23.js";import{vh as Z4}from"./chunk-wvwee7dn.js";function S3($){return typeof $==="function"&&$.prototype!==void 0}function G1($){return typeof $==="string"?[$]:$}function f3($,Z){let O=Z?"attachment":"inline",j=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${O}; filename="${j}"; filename*=UTF-8''${encodeURIComponent($)}`}function t5($){return"total"in $&&"partial"in $&&"body"in $}function G4(){return new Response("Not found",{status:404,headers:{"X-Content-Type-Options":"nosniff"}})}function SZ($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":Qj($),"Content-Length":"0","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}})}async function e5($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(t5($))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,O=Z instanceof Blob?Z:null,j=$.total??O?.size??-1;return{body:Z,start:$.start??0,end:$.end??j-1,total:j,partial:$.partial??!1,type:$.type??O?.type??"",name:$.name??Z?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function Bj($,Z){if($ instanceof Response)return $;if(!$)return G4();let O=await e5($),{body:j,start:J,end:W,total:z,partial:Y}=O;if(j instanceof Blob&&"exists"in j&&typeof j.exists==="function"){if(!await j.exists())return G4()}let{range:X}=Z;if(X){if(z<=0)return SZ(Math.max(z,0));if(!Y){if(j instanceof Blob){let T=Kj(X,z);if(!T)return SZ(z);j=j.slice(T.start,T.end+1),J=T.start,W=T.end,Y=!0}}}let G=Boolean(X)&&Y,F=G?206:O.status,K=new Headers;if(K.set("Accept-Ranges","bytes"),K.set("Content-Type",O.type||"application/octet-stream"),K.set("X-Content-Type-Options","nosniff"),G)K.set("Content-Range",Uj(J,W,z)),K.set("Content-Length",String(W-J+1));else if(z>=0)K.set("Content-Length",String(z));if(O.name)K.set("Content-Disposition",f3(O.name,O.download));if(O.etag)K.set("ETag",O.etag);if(O.lastModified)K.set("Last-Modified",O.lastModified.toUTCString());for(let[T,U]of Object.entries(O.extraHeaders))K.set(T,U);if((Z.method??"GET").toUpperCase()==="HEAD"){if(j&&"cancel"in j&&typeof j.cancel==="function")await j.cancel();return new Response(null,{status:F,headers:K})}return new Response(j,{status:F,headers:K})}class x$ extends q0{limit;constructor($){super("The request body is too large.",{status:413});this.limit=$}}var F4={b:1,k:1024,kb:1024,m:1048576,mb:1048576,g:1073741824,gb:1073741824};function HZ($){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 O=/^(\d+(?:\.\d+)?)\s*([a-z]*)$/.exec(Z);if(O&&(O[2]===""||(O[2]in F4)))return Math.floor(Number(O[1])*(F4[O[2]]??1))}throw Error(`Invalid body limit ${JSON.stringify($)}. Use a byte count or a size such as "64kb", "1mb" or "none".`)}var fZ=new WeakMap;function K4($){return fZ.has($)}function U4($){return fZ.get($)?.limit??null}function Q4($){let Z=fZ.get($);return Z?Z.read>Z.limit:!1}function $7($){let Z=$.headers.get("Content-Length");if(Z===null||!/^\s*\d+\s*$/.test(Z))return null;return Number(Z)}function Vj($,Z){let O=$7($);if(O!==null&&O>Z)throw new x$(Z)}function H3($,Z,O={}){let j=fZ.get($);if(j)j.limit=Z;else{let J={limit:Z,read:0,stream:void 0,used:!1};fZ.set($,J),O7($,J)}if(O.checkDeclared!==!1)Vj($,Z)}function Z7($){return Reflect.get(Object.getPrototypeOf($),"body",$)??null}function Dj($,Z){if(Z.stream!==void 0)return Z.stream;let O=Z7($);if(!O)return Z.stream=null;let j;return Z.stream=new ReadableStream({async pull(J){j??=O.getReader();let{done:W,value:z}=await j.read();if(W){J.close();return}if(Z.read+=z.byteLength,Z.read>Z.limit){let Y=new x$(Z.limit);J.error(Y),j.cancel(Y).catch(()=>{});return}J.enqueue(z)},cancel(J){return j?j.cancel(J):O.cancel(J)}},{highWaterMark:0}),Z.stream}async function H$($,Z){if(Vj($,Z.limit),Z.used||Z.stream?.locked)throw TypeError("Body already used");Z.used=!0;let O=Dj($,Z);if(!O)return new Uint8Array(0);let j=O.getReader(),J=[],W=0;for(;;){let{done:X,value:G}=await j.read();if(X)break;J.push(G),W+=G.byteLength}let z=new Uint8Array(W),Y=0;for(let X of J)z.set(X,Y),Y+=X.byteLength;return z}function T4($){return $.headers.get("Content-Type")??""}function O7($,Z){let O=(j,J)=>Object.defineProperty($,j,{configurable:!0,...J});O("body",{get:()=>Dj($,Z)}),O("bodyUsed",{get:()=>Z.used||Boolean(Z.stream?.locked)||Reflect.get(Object.getPrototypeOf($),"bodyUsed",$)}),O("bytes",{value:()=>H$($,Z)}),O("arrayBuffer",{value:async()=>{let j=await H$($,Z);return j.buffer.slice(j.byteOffset,j.byteOffset+j.byteLength)}}),O("text",{value:async()=>new TextDecoder().decode(await H$($,Z))}),O("json",{value:async()=>JSON.parse(new TextDecoder().decode(await H$($,Z)))}),O("blob",{value:async()=>new Blob([await H$($,Z)],{type:T4($)})}),O("formData",{value:async()=>new Response(await H$($,Z),{headers:{"Content-Type":T4($)}}).formData()}),O("clone",{value:()=>{Vj($,Z.limit);let j=Dj($,Z),J=null;if(j){let[W,z]=j.tee();Z.stream=W,J=z}return new Request($.url,{method:$.method,headers:$.headers,body:J,signal:$.signal,duplex:"half"})}})}function B4($){return S3($)}class t{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,Z,O){this.method=$;this.handler=Z;this.methodName=O;this.handler=Z,this.methodName=O,this.method=$}get source(){if(!B4(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(B4(this.handler)){let Z=new this.handler;return Z[this.methodName].bind(Z)()}return this.handler()}middleware($){return this.middlewares=G1($),this}}class V4{url;headers;__internal_brand="ProxyHandler";middlewares=[];constructor($,Z){this.url=$;this.headers=Z}middleware($){return this.middlewares=G1($),this}async run(){let $=new A,Z=$.headers.toJSON();for(let O of D4($.rawRequest))delete Z[O];try{return await fetch(this.url,{method:$.rawRequest.method,headers:{...Z,...this.headers},body:$.rawRequest.body})}catch(O){if(Q4($.rawRequest))throw new x$(U4($.rawRequest));throw O}}}class C4{constructor(...$){return new t(...$)}}class M4 extends t{__internal_brand="StreamHandler";async run($){let Z=x.getStore(),O=Z?.req?.rawRequest,j=Cj(O?.headers.get("Range"));if(Z)Z.rangeRequest=j;try{let J=await super.run($);return await Bj(J,{range:j,method:O?.method})}catch(J){if(J instanceof Mj)return SZ(J.total);throw J}finally{if(Z)Z.rangeRequest=null}}}class I4{constructor(...$){return new M4(...$)}}class N4{__internal_brand="ResourceRoutes";first;second;constructor($){this.first={get:new t("GET",$,"list"),post:new t("POST",$,"store")},this.second={get:new t("GET",$,"show"),put:new t("PUT",$,"update"),delete:new t("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 t("GET",$,Z)}post($,Z){return new t("POST",$,Z)}put($,Z){return new t("PUT",$,Z)}patch($,Z){return new t("PATCH",$,Z)}delete($,Z){return new t("DELETE",$,Z)}resource($){return new N4($)}agent($){if($.kind!=="agent-controller")throw TypeError(`this.agent() takes an AgentController class, and got ${j7($)}.`);return J7($,this)}file($,Z){return new C4("GET",$,Z)}stream($,Z){return new I4("GET",$,Z)}proxy($,Z={}){return new V4($,Z)}}function j7($){if(typeof $==="function"&&$.name)return $.name;return typeof $}function J7($,Z){let O={stream:new t("POST",$,"stream"),attach:new t("POST",$,"attach"),stop:new t("POST",$,"stop"),upload:new t("POST",$,"upload")};return class extends x0{static __internal_brand="AgentRoute";static controller=$;static handlers=O;constructor(){super();this.middlewares=[...Z?.middlewares??[]]}routes={"/":O.stream,"/attach":O.attach,"/stop":O.stop,"/files":O.upload};static middleware(J){if(J.stream)O.stream.middleware(J.stream);if(J.attach)O.attach.middleware(J.attach);if(J.stop)O.stop.middleware(J.stop);if(J.upload)O.upload.middleware(J.upload);return this}}}class Ij{as;input;bind;__internal_brand="McpModelParam";constructor($,Z,O){this.as=$;this.input=Z;this.bind=O}}class Nj{method;url;meta;__internal_brand="McpRoute";constructor($,Z,O){this.method=$;this.url=Z;this.meta=O}}class L4{static __brand="McpRouter";routes={};param($){return new Ij($.as,$.input,$.bind)}fromApiRoute($,Z,O){return new Nj($,Z,O)}}function J0($,Z){return $.replace(/:([^/]+[*?]?)/g,(O,j)=>{let J=j.endsWith("?")||j.endsWith("*"),W=J?j.slice(0,-1):j,z=Z[W];if(z===void 0){if(J)return"";if(import.meta.env.DEV)throw Error(`Missing parameter: ${W}`);console.error(`Missing parameter: ${W} in URL: ${$}`)}return String(z)}).replace(/\/\//g,"/").replace(/\/$/,"")}class Lj 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 x3{static to($,...Z){let[O={}]=Z,{search:j={},params:J={},permanent:W,status:z}={params:{},status:307,permanent:!1,...O},Y=new URLSearchParams(j).toString();throw new Lj([J0($,J)||"/",Y.toString()].filter(Boolean).join("?"),z??(W?301:307))}static external($,Z=307){throw new Lj($,Z)}}var _4=Symbol.for("gemi.HttpResponse");class t1{kind;body;status;headers;[_4]=!0;constructor($,Z,O,j){this.kind=$;this.body=Z;this.status=O;this.headers=j}static json($,Z={}){let O=Z.status??200;return W7(O),new t1("json",$,O,new Headers(Z.headers))}static error($,Z,O={}){if(!Number.isInteger($)||$<400||$>599)throw RangeError(`HttpResponse.error: status must be an integer from 400 to 599, got ${$}.`);return t1.json({error:Z},{...O,status:$})}get ok(){return this.status>=200&&this.status<300}toResponse($,Z){let O=$,j=this.serialize(O);for(let J of Z)O.append("Set-Cookie",J);this.headers.forEach((J,W)=>{if(W.toLowerCase()!=="set-cookie")O.set(W,J)});for(let J of this.headers.getSetCookie())O.append("Set-Cookie",J);if(this.status>=400&&!this.headers.has("Cache-Control"))O.set("Cache-Control","no-store");return new Response(j,{status:this.status,headers:O})}serialize($){switch(this.kind){case"json":return $.set("Content-Type","application/json"),JSON.stringify(this.body)??null}}}function W7($){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 A$($){return typeof $==="object"&&$!==null&&$[_4]===!0}function z7($,Z,O={}){return t1.error($,Z,O)}class P4{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[Z,O]=$;this.handler=(j)=>{return new Z()[O](j)}}}async run($,Z){let{destination:O,permanent:j=!1,status:J=307}=await this.handler($);if(!O)throw Error(`Redirect destination is required see ${Z}`);return x3.to(O,{permanent:j,status:J}),{}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function _j($,Z){if($ instanceof Response)return $;let O=$ instanceof Blob,j=O?$:$.file,J=O?$.name:$.name??$.file?.name,W=(O?$.type:$.type??$.file?.type)||"",z=O?!1:$.download??!1,Y=O?200:$.status??200;if(!O)for(let[X,G]of Object.entries($.headers??{}))Z.set(X,G);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",W||"application/octet-stream"),j instanceof Blob)Z.set("Content-Length",String(j.size));if(J)Z.set("Content-Disposition",f3(J,z));return new Response(j instanceof Blob?j.stream():j,{status:Y,headers:Z})}class S4{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[Z,O]=$;this.handler=(j)=>{return new Z()[O](j)}}}async run($,Z){let O=await this.handler($);if(!O)throw Error(`File route handler must return a file see ${Z}`);return{FILE:O}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}function f4($,Z){if(A$($))throw Error(`The handler of view "${Z}" returned an HttpResponse. HttpResponse is for api routes; a view handler returns its props.`);return $}class H4{viewPath;middlewares=[];featureGates=[];staticOptions=null;handler;constructor($,Z){this.viewPath=$;if(!Z)this.handler=()=>({});else if(typeof Z==="function")this.handler=Z;else{let[O,j]=Z;this.handler=(J)=>{return new O()[j](J)}}}async run($,Z){let O=f4(await this.handler($),this.viewPath);return{[this.viewPath]:{...O,breadcrumb:{label:O?.breadcrumb??"",href:Z}}}}middleware($){return this.middlewares=G1($),this}static($={}){return this.staticOptions={...$},this}feature($){return this.featureGates=[...this.featureGates,$],this}}class x4{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,Z,O){this.viewPath=$;if(typeof Z==="function")this.handler=Z,this.children=class extends f1{routes=O??{}};else if(Array.isArray(Z)){let[j,J]=Z;this.handler=(W)=>{return new j()[J](W)},this.children=class extends f1{routes=O??{}}}else this.children=class extends f1{routes=Z},this.handler=()=>({})}async run($,Z){let O=f4(await this.handler($),this.viewPath);return{[this.viewPath]:{...O,breadcrumb:{label:O?.breadcrumb??"",href:Z}}}}alwaysRun(){return this.alwaysRuns=!0,this}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class f1{middlewares=[];featureGates=[];routes={};view($,Z){return new H4($,Z)}file($){return new S4($)}redirect($){return new P4($)}layout($,Z,O){return new x4($,Z,O)}}class V0{req;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let Z=this;return class extends Z{config=$}}}function Y7($){return $}function X7(){return{aliases:{},global:[],bodyLimit:null}}var E$="redirect";function xZ($,Z="/"){if(typeof $!=="string"||!$.startsWith("/"))return Z;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return Z;try{let O=new URL($,"http://gemi.invalid");if(O.origin!=="http://gemi.invalid")return Z;let j=`${O.search}${O.hash}`.replaceAll("/","%2F"),J=`${O.pathname}${j}`.replaceAll(":","%3A");return J.startsWith("//")?Z:J}catch{return Z}}function A4($){let Z=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return Z?Z==="https":new URL($.url).protocol==="https:"}function G7($,Z=!0){let O=new URL($.rawRequest.url),j=O.pathname.replace(/\.(json|og)$/,""),[,J,...W]=j.split("/");if(I(s).supportedLocales.includes(J))j=`/${W.join("/")}`;return Z?`${j}${O.search}`:j}function F7($,Z){let O=(j)=>j.replace(/\/+$/,"")||"/";return O($)===O(Z)}function A3($,Z){let O=Z||I(E).config.signInPath,j=/^[a-z][a-z\d+.-]*:/i.test(O);if(j?!/^https?:\/\//i.test(O):!O.startsWith("/"))throw Error(`\`auth.signInPath\` must be a path like "/auth/sign-in", or an http(s) URL for sign-in hosted elsewhere. Got "${O}". A route's own \`"auth:<path>"\` cannot carry a URL, because the alias parser splits it on the colon.`);let J=new URL(O,"http://gemi.invalid");if($?.kind==="view"){let W=G7($,!j);if(j||!F7(new URL(W,J).pathname,J.pathname))J.searchParams.set(E$,W)}return j?J.href:`${J.pathname}${J.search}`}var H1="access_token";function Pj($){return $?.cookies?.get("access_token")||$?.headers?.get("access_token")||null}async function E3($,Z){let O=Pj(Z);if(!O)return null;return(await $.getSession(O,Z.headers.get("User-Agent")))?.user??null}class E4 extends V0{async run($){let Z=x.getStore(),O=Z.req;if(Z.user)return{};let j=await E3(I(E),O);if(!j)throw new e1({redirectTo:A3(O,$)});return Z.setUser(j),{}}}class b4 extends V0{async run(...$){let[Z="public",O="864000",...j]=$,J=`${Z}, max-age=${O}${j.length>0?", ":""}${j.join(", ")}`;if($.length===0)J="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="public")J="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="private")J="private, max-age=0, stale-while-revalidate=300, stale-if-error=600";if(this.req.rawRequest.method==="GET")this.req.ctx().setHeaders("Cache-Control",J);return{}}}var T7={"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 R4 extends V0{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(this.config.origins[Z]){$.ctx().setHeaders("Access-Control-Allow-Origin",Z);let O={...T7,...this.config.origins[Z]};for(let[j,J]of Object.entries(O))$.ctx().setHeaders(j,J)}return{}}}class e0{config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,Z={}){let O=Z.limit??this.config.limit,j=Z.window??this.config.window,J=Z.cost??1;if(v4("window",j),v4("limit",O),!Number.isFinite(J)||J<0)throw Error(`Rate limiter cost must be zero or greater, got ${J}`);return await this.config.driver.consume({key:$,limit:O,window:j*1000,cost:J})}}function v4($,Z){if(!Number.isFinite(Z)||Z<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${Z}`)}class AZ extends q0{constructor($){super("Rate limit exceeded");let Z={"Content-Type":"application/json",...$?g4($):{}};this.payload={api:{status:429,data:{error:x1("rate_limit","Rate limit exceeded",429)},headers:Z},view:{error:{message:"Rate limit exceeded"},status:429,headers:Z}}}}class q4 extends V0{async run($,Z){let O=K7();if(!O)return{};let j=await O.consume(this.key(),{limit:w4($)??this.config.limit,window:w4(Z)??this.config.window});if(this.config.headers!==!1){let J=this.req.ctx?.();if(J)for(let[W,z]of Object.entries(g4(j)))J.setHeaders(W,z)}if(!j.allowed)throw new AZ(j);return{}}key(){if(this.config.key)return this.config.key(this.req);return`${b$(this.req)}:${this.req.routePath??"*"}`}}function K7(){try{let $=I();return $.bound(e0)?$.make(e0):null}catch{return null}}function b$($){let Z=k4($.rawRequest);if(Z!==void 0)return Z;let O=$.headers.get("x-forwarded-for");if(O){let[j]=O.split(",");if(j?.trim())return j.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function g4($){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 w4($){if($===void 0||$===null||$==="")return;let Z=Number($);if(!Number.isFinite(Z)||Z<=0)return;return Z}class m4 extends V0{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new Sj;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new Sj;return{}}}class Sj extends q0{constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:y4("csrf","Invalid CSRF token",403)}},view:{}}}class b3 extends V0{run($){let Z=$??this.config.limit;if(Z===void 0||Z==="")throw Error('`body-limit` needs a size, as in "body-limit:64kb".');return H3(this.req.rawRequest,HZ(Z)),{}}}class p4{policiesList={};constructor(){let $=this.register();for(let Z of $){let O=new Z;this.policiesList[Z.name]=O}}register(){return[]}}class h4{all($,Z){return!0}}import{lookup as L7}from"dns/promises";import*as _7 from"http";import*as P7 from"https";import*as y$ from"zlib";function U7($){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 O=[];for(let W of Z){let z=Q7(W);if(z===null)return null;O.push(z)}let j=O.pop();for(let W of O)if(W>255)return null;if(j>=256**(4-O.length))return null;let J=j;return O.forEach((W,z)=>{J+=W*256**(3-z)}),new Uint8Array([Math.floor(J/16777216)&255,Math.floor(J/65536)&255,Math.floor(J/256)&255,J&255])}function Q7($){if($==="")return null;let Z=$,O=10;if(/^0x/i.test(Z)){if(Z=Z.slice(2),O=16,Z==="")return 0}else if(Z.length>1&&Z.startsWith("0"))Z=Z.slice(1),O=8;if(!(O===16?/^[0-9a-f]+$/i:O===8?/^[0-7]+$/:/^[0-9]+$/).test(Z))return null;let J=parseInt(Z,O);return Number.isSafeInteger(J)?J:null}function c4($){let Z=$;if(Z.startsWith("[")&&Z.endsWith("]"))Z=Z.slice(1,-1);let O=Z.indexOf("%");if(O!==-1)Z=Z.slice(0,O);if(!Z.includes(":"))return null;let j=Z.split("::");if(j.length>2)return null;let J=(G,F)=>{if(G==="")return[];let K=[],T=G.split(":");for(let U=0;U<T.length;U++){let Q=T[U];if(F&&U===T.length-1&&Q.includes(".")){if(!/^\d{1,3}(\.\d{1,3}){3}$/.test(Q))return null;let B=Q.split(".").map(Number);if(B.some((D)=>D>255))return null;K.push(B[0]<<8|B[1],B[2]<<8|B[3]);continue}if(!/^[0-9a-f]{1,4}$/i.test(Q))return null;K.push(parseInt(Q,16))}return K},W=J(j[0],j.length===1),z=j.length===2?J(j[1],!0):[];if(!W||!z)return null;let Y;if(j.length===2){let G=8-W.length-z.length;if(G<1)return null;Y=[...W,...Array.from({length:G},()=>0),...z]}else Y=W;if(Y.length!==8)return null;let X=new Uint8Array(16);return Y.forEach((G,F)=>{X[F*2]=G>>8,X[F*2+1]=G&255}),X}function EZ($){let Z=c4($);if(Z)return{family:6,bytes:Z};let O=U7($);if(O)return{family:4,bytes:O};return null}function $$($){if($.family===6&&B7($.bytes))return{family:4,bytes:$.bytes.slice(12)};return $}function B7($){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 O=0;O<16;O+=2)Z.push(($.bytes[O]<<8|$.bytes[O+1]).toString(16));return Z.join(":")}function v$($){let Z=$.lastIndexOf("/"),O=Z===-1?$:$.slice(0,Z),j=/^[0-9.]+$/.test(O)?D7(O):c4(O);if(!j)return null;let J=$$(j.length===4?{family:4,bytes:j}:{family:6,bytes:j}),W=J.family===4?32:128,z=W;if(Z!==-1){let Y=$.slice(Z+1);if(!/^\d{1,3}$/.test(Y))return null;if(z=Number(Y),j.length===16&&J.family===4)z-=96;if(z<0||z>W)return null}return{family:J.family,bytes:J.bytes,prefix:z}}function D7($){return/^\d{1,3}(\.\d{1,3}){3}$/.test($)&&$.split(".").every((Z)=>Number(Z)<=255)?new Uint8Array($.split(".").map(Number)):null}function F1($,Z){let O=$$($);if(O.family!==Z.family)return!1;let j=Z.prefix;for(let J=0;j>0;J++){let W=Math.min(8,j),z=255<<8-W&255;if((O.bytes[J]&z)!==(Z.bytes[J]&z))return!1;j-=W}return!0}var k=($,Z)=>({cidr:v$($),kind:Z,text:$}),V7=[k("0.0.0.0/8","unspecified"),k("10.0.0.0/8","private"),k("100.64.0.0/10","shared"),k("127.0.0.0/8","loopback"),k("169.254.169.254/32","metadata"),k("169.254.0.0/16","link-local"),k("168.63.129.16/32","metadata"),k("172.16.0.0/12","private"),k("192.0.0.0/24","reserved"),k("192.0.2.0/24","documentation"),k("192.88.99.0/24","reserved"),k("192.168.0.0/16","private"),k("198.18.0.0/15","benchmarking"),k("198.51.100.0/24","documentation"),k("203.0.113.0/24","documentation"),k("224.0.0.0/4","multicast"),k("255.255.255.255/32","broadcast"),k("240.0.0.0/4","reserved")],C7=[k("::/128","unspecified"),k("::1/128","loopback"),k("64:ff9b:1::/48","private"),k("::/8","reserved"),k("100::/64","reserved"),k("2001:db8::/32","documentation"),k("2001::/23","reserved"),k("3fff::/20","documentation"),k("fd00:ec2::254/128","metadata"),k("fc00::/7","unique-local"),k("fe80::/10","link-local"),k("fec0::/10","private"),k("ff00::/8","multicast")],M7=v$("64:ff9b::/96"),I7=v$("2002::/16"),N7=v$("2000::/3");function R$($){let Z=typeof $==="string"?EZ($):$;if(!Z)return{kind:"reserved",range:"not an IP address"};let O=$$(Z);if(O.family===4){let J=V7.find((W)=>F1(O,W.cidr));return J?{kind:J.kind,range:J.text}:null}if(F1(O,M7))return R$({family:4,bytes:O.bytes.slice(12)});if(F1(O,I7))return R$({family:4,bytes:O.bytes.slice(2,6)});let j=C7.find((J)=>F1(O,J.cidr));if(j)return{kind:j.kind,range:j.text};return F1(O,N7)?null:{kind:"reserved",range:"outside 2000::/3"}}function l4($,Z){let O=$$($),j=$$(Z);return O.family===j.family&&O.bytes.every((J,W)=>J===j.bytes[W])}class X0 extends Error{code="safe-fetch";url;constructor($,Z,O){super($,O);this.name=new.target.name,this.url=Z}}class T1 extends X0{reason;code="invalid-url";constructor($,Z,O){super(O,$);this.reason=Z}}class w$ extends X0{host;reason;code="blocked-host";constructor($,Z,O){super(O==="denied"?`Requests to ${Z} are not allowed.`:`${Z} is not on the list of hosts this request may reach.`,$);this.host=Z;this.reason=O}}class A1 extends X0{host;address;range;code="blocked-address";constructor($,Z,O,j){super(Z===O?`${O} is not a public address (${j}).`:`${Z} resolves to ${O}, which is not a public address (${j}).`,$);this.host=Z;this.address=O;this.range=j}}class k$ extends X0{host;code="dns";constructor($,Z,O){super(`Couldn't resolve ${Z}.`,$,{cause:O});this.host=Z}}class q$ extends X0{phase;ms;code="timeout";constructor($,Z,O){super(Z==="connect"?`Couldn't connect within ${O} ms.`:`The request didn't finish within ${O} ms.`,$);this.phase=Z;this.ms=O}}class g$ extends X0{limit;code="too-large";constructor($,Z){super(`The response is larger than ${Z} bytes.`,$);this.limit=Z}}class RZ extends X0{contentType;allowed;code="content-type";constructor($,Z,O){super(`The response is ${Z??"of no content type"}, not ${O.join(" or ")}.`,$);this.contentType=Z;this.allowed=O}}class vZ extends X0{limit;code="too-many-redirects";constructor($,Z){super(`More than ${Z} redirects.`,$);this.limit=Z}}class E1 extends X0{code="network";constructor($,Z){super(`The request failed: ${Z instanceof Error?Z.message:String(Z)}`,$,{cause:Z})}}class kZ extends Response{#J;#Z;address;constructor($,Z,O){super($,Z);this.#J=O.url,this.#Z=O.redirected,this.address=O.address}get url(){return this.#J}get redirected(){return this.#Z}}var wZ={timeout:30000,connectTimeout:1e4,maxSize:10485760,maxRedirects:5,ports:[80,443]},S7=new Set([301,302,303,307,308]),f7=new Set([101,103,204,205,304]),H7=["host","connection","content-length","transfer-encoding","keep-alive","upgrade"],x7=["authorization","cookie","proxy-authorization"];async function u4($,Z={}){let O=A7(Z),j=Z.signal;j?.throwIfAborted();let J=new AbortController,W=J.signal,z=String($),Y=(K)=>{if(!W.aborted)J.abort(K)},X=setTimeout(()=>Y(new q$(z,"total",O.timeout)),O.timeout),G=()=>Y(j.reason);j?.addEventListener("abort",G,{once:!0});let F=()=>{clearTimeout(X),j?.removeEventListener("abort",G)};try{let K=i4(z,O),T=(Z.method??"GET").toUpperCase(),U=new Headers(Z.headers);for(let B of H7)U.delete(B);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 Q=await v7(T,Z.body,U);for(let B=0;;B++){z=K.href;let{request:D,response:C,address:L}=await w7(K,T,U,Q,O,W),M=C.statusCode??0,P=C.headers.location;if(S7.has(M)&&P&&Z.redirect!=="manual"){if(D.destroy(),B>=O.maxRedirects)throw new vZ(K.href,O.maxRedirects);let f;try{f=new URL(P,K)}catch{throw new T1(P,"malformed",`The redirect to "${P}" is not a URL.`)}if(M===303?T!=="HEAD":(M===301||M===302)&&T==="POST"){T="GET",Q=null;let _=[];U.forEach((V,N)=>{if(N.startsWith("content-"))_.push(N)});for(let V of _)U.delete(V)}if(f.origin!==K.origin)for(let _ of x7)U.delete(_);K=i4(f.href,O);continue}return k7({url:K,hop:B,method:T,request:D,response:C,address:L,policy:O,signal:W,release:F})}}catch(K){throw F(),W.aborted?W.reason:K}}function A7($){let Z=(j,J)=>{let W={hosts:[],ranges:[]};for(let z of j){let Y=z.includes("/")||z.includes(":")||/^[\d.]+$/.test(z),X=Y?v$(z):null;if(X)W.ranges.push(X);else if(!Y&&/^(\*\.)?[a-z0-9-]+(\.[a-z0-9-]+)*\.?$/i.test(z))W.hosts.push(s4(z));else throw TypeError(`safeFetch: "${z}" in ${J} is not a host name or an IP range.`)}return W},O=$.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:O===!0?!0:Z(O||[],"allowPrivate").ranges,contentTypes:$.contentTypes?.length?$.contentTypes:null,resolve:$.resolve??E7}}async function E7($){return(await L7($,{all:!0,verbatim:!0})).map((O)=>O.address)}function s4($){return $.toLowerCase().replace(/\.$/,"")}function d4($,Z){return Z.some((O)=>O.startsWith("*.")?$.endsWith(O.slice(1)):$===O)}function i4($,Z){let O;try{O=new URL($)}catch{throw new T1($,"malformed",`"${$}" is not a URL.`)}if(O.protocol!=="http:"&&O.protocol!=="https:")throw new T1(O.href,"scheme",`Only http and https URLs can be fetched, not ${O.protocol.slice(0,-1)}.`);if(O.username||O.password)throw new T1(O.href,"credentials","The URL has a username or password in it.");let j=n4(O);if(Z.ports!=="any"&&!Z.ports.includes(j))throw new T1(O.href,"port",`Port ${j} is not allowed.`);return O}function n4($){return $.port?Number($.port):$.protocol==="https:"?443:80}async function b7($,Z,O){let j=s4($.hostname.replace(/^\[(.*)\]$/,"$1")),J=EZ(j),W=J!==null&&(j.includes(":")||/^\d+\.\d+\.\d+\.\d+$/.test(j));if(!W&&d4(j,Z.deny.hosts))throw new w$($.href,j,"denied");let z=!W&&Z.allow!==null&&d4(j,Z.allow.hosts);if(Z.allow&&!z&&Z.allow.ranges.length===0)throw new w$($.href,j,"not-allowed");let Y;if(W)Y=[J];else{let X;try{X=await R7(Z.resolve(j),O)}catch(G){if(O.aborted)throw O.reason;throw new k$($.href,j,G)}if(Y=X.map((G)=>EZ(G)).filter((G)=>G!==null),Y.length===0)throw new k$($.href,j)}for(let X of Y){let G=bZ(X);if(Z.deny.ranges.some((K)=>F1(X,K)))throw new A1($.href,j,G,"denied");if(Z.allow&&!z&&!Z.allow.ranges.some((K)=>F1(X,K)))throw new A1($.href,j,G,"not-allowed");let F=R$(X);if(F&&Z.allowPrivate!==!0&&!Z.allowPrivate.some((K)=>F1(X,K)))throw new A1($.href,j,G,F.kind)}return{host:j,addresses:Y,isLiteral:W}}function R7($,Z){if(Z.aborted)return Promise.reject(Z.reason);return new Promise((O,j)=>{let J=()=>j(Z.reason);Z.addEventListener("abort",J,{once:!0}),$.then((W)=>{Z.removeEventListener("abort",J),O(W)},(W)=>{Z.removeEventListener("abort",J),j(W)})})}async function v7($,Z,O){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}),J=j.headers.get("content-type");if(J&&!O.has("content-type"))O.set("content-type",J);return new Uint8Array(await j.arrayBuffer())}async function w7($,Z,O,j,J,W){let z=new AbortController,Y=setTimeout(()=>z.abort(new q$($.href,"connect",J.connectTimeout)),J.connectTimeout),X=AbortSignal.any([W,z.signal]);try{let{host:G,addresses:F,isLiteral:K}=await b7($,J,X),T=$.protocol==="https:",U={};if(O.forEach((Q,B)=>{U[B]=Q}),j)U["content-length"]=String(j.byteLength);return await new Promise((Q,B)=>{let D={method:Z,host:G,port:n4($),path:`${$.pathname}${$.search}`,headers:U,agent:!1,lookup:(_,V,N)=>{let H=V?.family,R=F.filter((m)=>!H||m.family===H);if(R.length===0)N(Object.assign(Error(`No IPv${H} address for ${G}`),{code:"ENOTFOUND"}));else if(V?.all)N(null,R.map((m)=>({address:bZ(m),family:m.family})));else N(null,bZ(R[0]),R[0].family)}};if(T&&!K)D.servername=G;let C=(T?P7:_7).request(D),L=null,M=(_)=>{X.removeEventListener("abort",P),C.destroy(),B(_)},P=()=>M(X.aborted?X.reason:W.reason);X.addEventListener("abort",P,{once:!0});let f=(_)=>{let V=_?.remoteAddress;if(!V||L!==null)return!0;let N=EZ(V);if(!N||!F.some((H)=>l4(H,N)))return M(new A1($.href,G,V,"not-allowed")),!1;return L=bZ($$(N)),!0};C.once("socket",(_)=>{let V=()=>{if(f(_)&&!T)clearTimeout(Y)};if(_.connecting)_.once("connect",V);else V();if(T)_.once("secureConnect",()=>clearTimeout(Y))}),C.once("response",(_)=>{if(clearTimeout(Y),_.on("error",()=>{}),!f(_.socket))return;X.removeEventListener("abort",P),Q({request:C,response:_,address:L})}),C.on("error",(_)=>{if(X.aborted)return M(X.reason);M(_ instanceof X0?_:new E1($.href,_))}),C.end(j??void 0)})}finally{clearTimeout(Y)}}function k7({url:$,hop:Z,method:O,request:j,response:J,address:W,policy:z,signal:Y,release:X}){let G=J.statusCode??0;if(G<200||G>599)throw j.destroy(),new E1($.href,Error(`Unexpected status ${G}`));let F=new Headers,K=J.rawHeaders;for(let V=0;V<K.length;V+=2)F.append(K[V],K[V+1]);if(z.contentTypes){let V=F.get("content-type")?.split(";")[0].trim().toLowerCase()??null;if(!V||!z.contentTypes.some((N)=>q7(V,N)))throw j.destroy(),new RZ($.href,V,z.contentTypes)}let T={url:$.href,redirected:Z>0,address:W},U={status:G,statusText:J.statusMessage??"",headers:F};if(O==="HEAD"||f7.has(G))return j.destroy(),X(),new kZ(null,U,T);let Q=F.get("content-encoding")?.trim().toLowerCase(),B=Q==="gzip"||Q==="x-gzip"?y$.createGunzip():Q==="deflate"?y$.createInflate():Q==="br"?y$.createBrotliDecompress():null,D=Number(F.get("content-length"));if(!B&&Number.isFinite(D)&&D>z.maxSize)throw j.destroy(),new g$($.href,z.maxSize);if(B)F.delete("content-encoding"),F.delete("content-length");let C=B?J.pipe(B):J,L=0,M=!1,P=()=>{},f=()=>{M=!0,Y.removeEventListener("abort",P),X()},_=new ReadableStream({start(V){let N=(R)=>{if(M)return;if(f(),R===void 0)V.close();else j.destroy(),B?.destroy(),V.error(R)};if(P=()=>N(Y.reason),Y.addEventListener("abort",P,{once:!0}),Y.aborted)return P();C.on("data",(R)=>{if(M)return;if(L+=R.byteLength,L>z.maxSize)return N(new g$($.href,z.maxSize));if(V.enqueue(new Uint8Array(R)),(V.desiredSize??1)<=0)C.pause()}),C.once("end",()=>N());let H=(R)=>N(R instanceof X0?R:new E1($.href,R));if(C.on("error",H),B)J.on("error",H);J.once("aborted",()=>N(new E1($.href,Error("The response was cut off."))))},pull(){C.resume()},cancel(){if(M)return;f(),j.destroy(),B?.destroy()}});return new kZ(_,U,T)}function q7($,Z){let O=Z.toLowerCase();return O.endsWith("/*")?$.startsWith(O.slice(0,-1)):$===O}import{createHmac as a4,randomBytes as g7}from"crypto";var Aj="v2.";function Ej($){return $.startsWith(Aj)}function R3(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function o4($){let Z=g7(16).toString("hex"),O=a4("sha256",R3()).update(`${$}:${Z}`).digest("hex");return`${Aj}${O}`}function v3($,Z){let O=a4("sha256",R3()).update(`legacy-session:${Z}:${$}`).digest("hex");return`${Aj}${O}`}import{createHash as p7,createHmac as h7,randomInt as c7,timingSafeEqual as e4}from"crypto";function r4($,Z){return Math.floor($/Z)*Z}function y7($,Z){if(Z<=0)return 0;return Math.min(1,Math.max(0,(Z-$)/Z))}function bj($,Z,O,j){return Z*y7(O,j)+$}function m7($){let{current:Z,previous:O,elapsed:j,window:J,limit:W,cost:z}=$,Y=W-z;if(Y<0)return J;let X=Math.max(0,J-j);if(O>0){let F=J*(1-(Y-Z)/O);if(F<=J)return Math.max(0,Math.ceil(F-j))}if(Z<=Y)return X;if(Z<=0)return X;let G=J*(1-Y/Z);return X+Math.max(0,Math.ceil(G))}function t4($){let{allowed:Z,current:O,previous:j,now:J,elapsed:W,window:z,limit:Y,cost:X}=$;if(Z){let F=bj(O,j,W,z);return{allowed:!0,limit:Y,remaining:Math.max(0,Math.floor(Y-F)),resetAt:J-W+z,retryAfter:0}}let G=m7({current:O,previous:j,elapsed:W,window:z,limit:Y,cost:X});return{allowed:!1,limit:Y,remaining:0,resetAt:J+G,retryAfter:G}}class Rj{}class vj extends Rj{buckets=new Map;maxKeys;constructor($={}){super();this.maxKeys=Math.max(1,$.maxKeys??1e5)}consume($){let{key:Z,limit:O,window:j}=$,J=$.cost??1,W=Date.now(),z=r4(W,j),Y=W-z,X=this.roll(Z,j,z);X.limit=O;let F=bj(X.current,X.previous,Y,j)+J<=O;if(F)X.current+=J;if(this.buckets.delete(Z),this.buckets.set(Z,X),this.buckets.size>this.maxKeys)this.evict(W);return t4({allowed:F,current:X.current,previous:X.previous,now:W,elapsed:Y,window:j,limit:O,cost:J})}clear(){this.buckets.clear()}get size(){return this.buckets.size}roll($,Z,O){let j=this.buckets.get($);if(!j||j.window!==Z)return{window:Z,limit:0,windowStart:O,current:0,previous:0};if(j.windowStart===O)return j;if(j.windowStart+Z===O)return j.previous=j.current,j.current=0,j.windowStart=O,j;return j.previous=0,j.current=0,j.windowStart=O,j}evict($){for(let[j,J]of this.buckets)if($-J.windowStart>=J.window*2)this.buckets.delete(j);let Z=this.maxKeys-Math.floor(this.maxKeys/10);if(this.buckets.size<=Z)return;let O=[...this.buckets].map(([j,J],W)=>({key:j,order:W,spent:J.limit>0?(J.current+J.previous)/J.limit:0}));O.sort((j,J)=>j.spent-J.spent||j.order-J.order);for(let{key:j}of O){if(this.buckets.size<=Z)break;this.buckets.delete(j)}}}var OJ="h1.";function w3($,Z,O){let j=h7("sha256",R3()).update(`gemi:one-time:${$}:${Z}:${O}`).digest("hex");return`${OJ}${j}`}function qZ($,Z,O,j){let J=typeof j==="string"?j:"",W=typeof O==="string"?O:"",z=W.startsWith(OJ),Y=w3($,Z,J),X=Buffer.from(z?Y:J),G=Buffer.from(W);if(X.length!==G.length||J===""||W==="")return e4(X,X),!1;return e4(X,G)}function jJ($){let Z="";for(let O=0;O<$;O++)Z+=String(c7(0,10));return Z}var JJ=320;function gZ($){if(typeof $!=="string")return null;let Z=$.trim();if(Z===""||Z.length>JJ)return null;return Z.toLowerCase()}function wj($){if(typeof $!=="string")return null;let Z=$.trim();if(Z.length>JJ)return null;let O=Z.toLowerCase();if(O.length<3||O.length>254||!/^[^\s@]+@[^\s@]+$/.test(O))return null;return O}var $J=null;function WJ(){try{let $=I();if(typeof $?.bound==="function"&&$.bound(e0))return $.make(e0)}catch{}return $J??=new e0({driver:new vj,limit:1000,window:60}),$J}function ZJ($){return $.length<=64?$:`sha256:${p7("sha256").update($).digest("hex")}`}async function m$($,Z,O,j){let J=WJ(),W=[[`auth:code-${$}:ip:${ZJ(b$(O))}`,j.perIp]];if(Z!==null)W.push([`auth:code-${$}:email:${ZJ(Z)}`,j.perEmail]);for(let[z,Y]of W){if(!Y)continue;let[X,G]=Y,F=await J.consume(z,{limit:X,window:G});if(!F.allowed)throw new AZ(F)}}async function zJ($,Z,O,j=10){let J=Math.max(86400,Math.ceil(j*60*(O+1)));return(await WJ().consume(`auth:code-attempt:${$}:${Z}`,{limit:O,window:J})).allowed}import{randomBytes as qj}from"crypto";class kj extends A{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 k3($,Z,O,j=1/0){if(!Number.isInteger(Z)||Z<O||Z>j){let J=j===1/0?`an integer of at least ${O}`:`an integer from ${O} to ${j}`;throw Error(`auth.emailCode.${$} must be ${J}, got ${Z}`)}}function gj($={}){let Z=$.length??6,O=$.expiresInMinutes??10,j=$.linkExpiresInMinutes??10080,J=$.maxAttempts??5;return k3("length",Z,4,12),k3("expiresInMinutes",O,1),k3("linkExpiresInMinutes",j,1),k3("maxAttempts",J,1),{enabled:$.enabled??!1,createUser:$.createUser??!1,length:Z,expiresInMinutes:O,linkExpiresInMinutes:j,maxAttempts:J,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:W,code:z})=>{if(Bun.env.NODE_ENV!=="production")console.info(`[gemi] email code for ${W}: ${z} (set auth.emailCode.send to deliver it)`)})}}async function l7($,Z){if(typeof Z!=="string"||Z==="")return!1;try{return await Bun.password.verify($,Z)}catch{return!1}}function FQ($){return $}function YJ($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:kj,oauthProviders:{},verifyPassword:l7,hashPassword:async(Z)=>await Bun.password.hash(Z),generateForgotPasswordToken:async()=>qj(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return qj(32).toString("hex")},generateMagicLinkToken:()=>qj(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{},emailCode:gj($.emailCode),generateCode:()=>{return},onAuthenticated:()=>{}}}function yj($){if($&&typeof $==="object")delete $.password;return $}function d7(){return new Proxy({},{get:($,Z)=>GJ(Z)})}var XJ=new WeakMap;function FJ($){if($&&typeof $==="object"){for(let Z of Object.values($))FJ(Z);Object.freeze($)}return $}var i7={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}},u7=FJ({token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:i7});class mj{models;constructor($=d7()){this.models=$}run($){return this.models.User.asSystem($)}sessionSelect(){return u7}transaction($){return this.models.User.transaction($)}withLegacySessionLock($,Z){let O=this.models.User.$connection??mZ(),j=I(pZ).connection(O),J=()=>this.transaction(async()=>{if(j.dialect==="postgres"){let Y=`gemi:legacy-session:${$}`;await yZ()`SELECT pg_advisory_xact_lock(hashtextextended(${Y}, 0))`}return Z()});if(j.dialect!=="sqlite"||yZ())return J();let z=(XJ.get(j)??Promise.resolve()).then(J,J);return XJ.set(j,z.catch(()=>{})),z}async createUser($){let Z=await this.run(()=>this.models.User.create({data:$}));return yj(Z)}async updateUserPassword($){let Z=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return yj(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=(O)=>typeof O==="string"&&O!=="";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 O=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:Z},include:{user:!0}}));return O?yj(O.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:O}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:Z}}));return O===1}}import{randomBytes as AF}from"crypto";function A0($,Z,O,j,J){return h0(Z,fJ($,Z),O,j,J)}function h0($,Z,O,j,J,W){let z=dj(Z,O,j);if(J&&Z!==z)throw RangeError(GY($,Z,O,j,W));return z}function fJ($,Z){let O=$[Z];if(O===void 0)throw TypeError(M8(Z));return O}function z0($){return $!==null&&/object|function/.test(typeof $)}function R0($,Z=Map){let O=new Z;return(j,...J)=>{if(O.has(j))return O.get(j);let W=$(j,...J);return O.set(j,W),W}}function tj($){return J$({name:$},1)}function J$($,Z){return i0((O)=>({value:O,configurable:1,writable:!Z}),$)}function HJ($){return i0((Z)=>({get:Z,configurable:1}),$)}function r3($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function u$($,Z){let O={},j=$.length;for(let J of Z)O[$[--j]]=J;return O}function i0($,Z,O){let j={};for(let J in Z)j[J]=$(Z[J],J,O);return j}function aZ($,Z,O){let j={};for(let J=0;J<Z.length;J++){let W=Z[J];j[W]=$(W,J,O)}return j}function s7($,Z,O){let j={};for(let J=0;J<$.length;J++)j[Z[J]]=O[$[J]];return j}function w0($,Z){let O={};for(let j of $)O[j]=Z[j];return O}function ej($,Z){let O={};for(let j in Z)$.has(j)||(O[j]=Z[j]);return O}function $6($){$={...$};let Z=Object.keys($);for(let O of Z)$[O]===void 0&&delete $[O];return $}function xJ($,Z){for(let O of Z)if(!(O in $))return 0;return 1}function AJ($,Z,O){for(let j of $)if(Z[j]!==O[j])return 0;return 1}function EJ($,Z,O){let j={...O};for(let J=0;J<Z;J++)j[$[J]]=0;return j}function w($,...Z){return(...O)=>$(...Z,...O)}function TJ($){return $[0].toUpperCase()+$.substring(1)}function oZ($){return $.slice().sort()}function c3($,Z){return String(Z).padStart($,"0")}function b1($,Z){return Math.sign($-Z)}function dj($,Z,O){return Math.min(Math.max($,Z),O)}function U1($,Z){return[Math.floor($/Z),cZ($,Z)]}function cZ($,Z){return($%Z+Z)%Z}function w1($,Z){return[t3($,Z),Z6($,Z)]}function t3($,Z){return Math.trunc($/Z)||0}function Z6($,Z){return $%Z||0}function q3($){return Math.abs($%1)===0.5}function bJ($,Z,O){let j=0,J=0;for(let Y=0;Y<=Z;Y++){let X=$[O[Y]],G=Z1[Y],F=h/G,[K,T]=w1(X,F);j+=T*G,J+=K}let[W,z]=w1(j,h);return[J+W,z]}function e3($,Z,O){let j={};for(let J=Z;J>=0;J--){let W=Z1[J];j[O[J]]=t3($,W),$=Z6($,W)}return j}function RJ($){return $===q?vO:[]}function vJ($){return $===q?z3:[]}function wJ($){return $===q?["year","day"]:[]}function kJ($){if($!==void 0)return n($)}function qJ($){if($!==void 0)return u0($)}function O6($){if($!==void 0)return rZ($)}function u0($){return mJ(rZ($))}function rZ($){return yJ(yX($))}function j6($){if($==null)throw TypeError("Cannot be null or undefined");return $}function gJ($,Z){if(Z==null)throw RangeError(M8($));return Z}function B1($){if(!z0($))throw TypeError(XY);return $}function $O($,Z,O=$){if(typeof Z!==$)throw TypeError(j3(O,Z));return Z}function yJ($,Z="number"){if(!Number.isInteger($))throw RangeError(GX(Z,$));return $||0}function mJ($,Z="number"){if($<=0)throw RangeError(FX(Z,$));return $}function J6($){if(typeof $=="symbol")throw TypeError(QX);return String($)}function l3($,Z){return z0($)?String($):n($,Z)}function ZO($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(UX($));return $}function pJ($,Z="number"){if(typeof $=="bigint")throw TypeError(KX(Z));if($=Number($),!Number.isFinite($))throw RangeError(TX(Z,$));return $}function C0($,Z){return Math.trunc(pJ($,Z))||0}function hJ($,Z){return yJ(pJ($,Z),Z)}function KJ($,Z){return mJ(C0($,Z),Z)}function W6($,Z){let[O,j]=w1(Z,h),J=$+O,W=Math.sign(J);return W&&W===-Math.sign(j)&&(J-=W,j+=W*h),[J,j]}function h$($,Z,O=1){return W6($[0]+Z[0]*O,$[1]+Z[1]*O)}function c$($,Z){return W6($[0],$[1]+Z)}function g0($,Z){return h$(Z,$,-1)}function I0($,Z){return b1($[0],Z[0])||b1($[1],Z[1])}function cJ($,Z,O){return I0($,Z)===-1||I0($,O)===1}function OO($,Z=1){let O=BigInt(h/Z);return[Number($/O),Number($%O)*Z]}function l$($,Z=1){let O=h/Z,[j,J]=w1($,O);return[j,J*Z]}function lJ($,Z=1){let[O,j]=$,J=Math.floor(j/Z),W=h/Z;return BigInt(O)*BigInt(W)+BigInt(J)}function y0($,Z=1,O){let[j,J]=$,[W,z]=w1(J,Z);return j*(h/Z)+(W+(O?z/Z:0))}function z6($,Z,O=U1){let[j,J]=$,[W,z]=O(J,Z);return[j*(h/Z)+W,z]}function Y6($,Z){let O=$.formatToParts(Z),j={};for(let J of O)j[J.type]=J.value;return j}function X6($){return A0($,"isoYear",nZ,sZ,1),$.isoYear===nZ?A0($,"isoMonth",4,12,1):$.isoYear===sZ&&A0($,"isoMonth",1,9,1),$}function R1($){return D1({...$,...d0,isoHour:12}),$}function D1($){let Z=A0($,"isoYear",nZ,sZ,1),O=Z===nZ?1:Z===sZ?-1:0;return O&&m0(M0({...$,isoDay:$.isoDay+O,isoNanosecond:$.isoNanosecond-O})),$}function m0($){if(!$||cJ($,iX,dX))throw RangeError(AO);return $}function k1($){return bJ($,5,o0)[1]}function jO($){let[Z,O]=U1($,h);return[e3(O,5,o0),Z]}function dJ($){return iJ($)[0]}function iJ($){return z6($,l0)}function N0($){return s$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function M0($){let Z=N0($);if(Z!==void 0){let[O,j]=w1(Z,b0);return[O,j*O1+($.isoMicrosecond||0)*U$+($.isoNanosecond||0)]}}function G6($,Z){let[O,j]=jO(k1($)-Z);return m0(M0({...$,isoDay:$.isoDay+j,...O}))}function d3(...$){return s$(...$)/IY}function s$(...$){let[Z,O]=uJ(...$),j=Z.valueOf();if(!isNaN(j))return j-O*b0}function uJ($,Z=1,O=1,j=0,J=0,W=0,z=0){let Y=$===nZ?1:$===sZ?-1:0,X=new Date;return X.setUTCHours(j,J,W,z),X.setUTCFullYear($,Z-1,O+Y),[X,Y]}function g1($,Z){let[O,j]=c$($,Z);j<0&&(j+=h,O-=1);let[J,W]=U1(j,O1),[z,Y]=U1(W,U$);return JO(O*b0+J,z,Y)}function JO($,Z=0,O=0){let j=Math.ceil(Math.max(0,Math.abs($)-lX)/b0)*Math.sign($),J=new Date($-j*b0);return u$(kO,[J.getUTCFullYear(),J.getUTCMonth()+1,J.getUTCDate()+j,J.getUTCHours(),J.getUTCMinutes(),J.getUTCSeconds(),J.getUTCMilliseconds(),Z,O])}function sJ($){return[$.isoYear,$.isoMonth,$.isoDay]}function nJ(){return K1}function F6($,Z){switch(Z){case 2:return T6($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function aJ($){return T6($)?366:365}function T6($){return $%4==0&&($%100!=0||$%400==0)}function oJ($){let[Z,O]=uJ($.isoYear,$.isoMonth,$.isoDay);return cZ(Z.getUTCDay()-O,7)||7}function rJ({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function n7($){let Z=N0($);if(Z<sX)return rJ($);let O=Y6(g8(d$),Z),{era:j,eraYear:J}=Xz(O,d$);return[j,J]}function WO($){return W$($),zO($,1),$}function W$($){return tJ($,1),$}function UJ($){return AJ(A8,$,tJ($))}function tJ($,Z){let{isoYear:O}=$,j=A0($,"isoMonth",1,nJ(),Z);return{isoYear:O,isoMonth:j,isoDay:A0($,"isoDay",1,F6(O,j),Z)}}function zO($,Z){return u$(o0,[A0($,"isoHour",0,23,Z),A0($,"isoMinute",0,59,Z),A0($,"isoSecond",0,59,Z),A0($,"isoMillisecond",0,999,Z),A0($,"isoMicrosecond",0,999,Z),A0($,"isoNanosecond",0,999,Z)])}function g($){return $===void 0?0:gY(B1($))}function tZ($,Z=0){$=s0($);let O=yY($),j=jG($,Z);return[gY($),j,O]}function K6($){return yY(s0($))}function eJ($){return $=s0($),R8($,9,6,1)}function n$($,Z,O,j=9,J=0,W=4){Z=s0(Z);let z=R8(Z,j,J),Y=B6(Z),X=X3(Z,W),G=Y3(Z,j,J,1);return z==null?z=Math.max(O,G):jW(z,G),Y=D6(Y,G,1),$&&(X=((F)=>F<4?(F+2)%4:F)(X)),[z,G,Y,X]}function YO($,Z=6,O){let j=B6($=V6($,o3)),J=X3($,7),W=Y3($,Z);return W=gJ(o3,W),j=D6(j,W,void 0,O),[W,j,J]}function U6($){return v8(s0($))}function $W($,Z){return Q6(s0($),Z)}function Q6($,Z=4){let O=OW($);return[X3($,4),...ZW(Y3($,Z),O)]}function ZW($,Z){return $!=null?[Z1[$],$<4?9-3*$:-1]:[Z===void 0?1:10**(9-Z),Z]}function B6($){let Z=$[lZ];return Z===void 0?1:C0(Z,lZ)}function D6($,Z,O,j){let J=j?h:Z1[Z+1];if(J){let W=Z1[Z];if(J%(($=h0(lZ,$,1,J/W-(j?0:1),1))*W))throw RangeError(j3(lZ,$))}else $=h0(lZ,$,1,O?1e9:1,1);return $}function OW($){let Z=$[lj];if(Z!==void 0){if(typeof Z!="number"){if(J6(Z)==="auto")return;throw RangeError(j3(lj,Z))}Z=h0(lj,Math.floor(Z),0,9,1)}return Z}function s0($){return $===void 0?{}:B1($)}function V6($,Z){return typeof $=="string"?{[Z]:$}:B1($)}function e($){if($!==void 0){if(z0($))return Object.assign(Object.create(null),$);throw TypeError(XY)}}function XO($,Z){return $&&Object.assign(Object.create(null),$,{overflow:aX[Z]})}function C6($,Z,O=9,j=0,J){let W=Z[$];if(W===void 0)return J?j:void 0;if(W=J6(W),W==="auto")return J?j:null;let z=nj[W];if(z===void 0&&(z=hX[W]),z===void 0)throw RangeError(KY($,W,nj));return h0($,z,j,O,1,W3),z}function z$($,Z,O,j=0){let J=O[$];if(J===void 0)return j;let W=J6(J),z=Z[W];if(z===void 0)throw RangeError(KY($,W,Z));return z}function jW($,Z){if(Z>$)throw RangeError(vX)}function Y0($){return{branding:gO,epochNanoseconds:$}}function T0($,Z,O){return{branding:I1,calendar:O,timeZone:Z,epochNanoseconds:$}}function $0($,Z=$.calendar){return{branding:B$,calendar:Z,...w0(vY,$)}}function Z0($,Z=$.calendar){return{branding:Q$,calendar:Z,...w0(E8,$)}}function O$($,Z=$.calendar){return{branding:OZ,calendar:Z,...w0(E8,$)}}function i3($,Z=$.calendar){return{branding:jZ,calendar:Z,...w0(E8,$)}}function n0($){return{branding:qO,...w0(RY,$)}}function i($){return{branding:yO,sign:y1($),...w0(f8,$)}}function JW($){return dJ($.epochNanoseconds)}function GO($){return z6($.epochNanoseconds,O1)[0]}function WW($){return lJ($.epochNanoseconds,U$)}function zW($){return lJ($.epochNanoseconds)}function YW($){return $.epochNanoseconds}function G0($){return typeof $=="string"?$:n($.id)}function a$($,Z){return $===Z||G0($)===G0(Z)}function XW($,Z,O,j,J){let W=j$(j),[z,Y]=((D,C)=>{let L=C((D=V6(D,rj))[kY]),M=OG(D);return M=gJ(rj,M),[M,L]})(J,$);if(iZ(Math.max(z,W),Y))return QJ(j,z);if(!Y)throw RangeError(EO);let[X,G,F]=BO(Z,O,Y),K=c6(F),T=DO(F),U=l6(F),Q=T(G,X,j),B=U(G,X,Q,z);return iZ(z,Y)?QJ(B,z):((D,C,L,M,P,f,_)=>{let V=y1(D),[N,H]=M6(M,x8(L,D),L,V,P,f,_),R=I6(C,N,H);return D[y[L]]+R*V})(B,K(Q),z,G,X,K,T)}function QJ($,Z){return y0(W0($),Z1[Z],1)}function M6($,Z,O,j,J,W,z){let Y=y[O],X={...Z,[Y]:Z[Y]+j},G=z($,J,Z),F=z($,J,X);return[W(G),W(F)]}function I6($,Z,O){let j=y0(g0(Z,O));if(!j)throw RangeError(J3);return y0(g0(Z,$))/j}function GW($,Z){let[O,j,J]=YO(Z,5,1);return Y0(TO($.epochNanoseconds,O,j,J,1))}function FW($,Z,O){let{epochNanoseconds:j,timeZone:J,calendar:W}=Z,[z,Y,X]=YO(O);if(z===0&&Y===1)return Z;let G=$(J);if(z===6)j=((F,K,T,U)=>{let Q=L0(T,K),[B,D]=F(Q),C=T.epochNanoseconds,L=v0(K,B),M=v0(K,D);if(cJ(C,L,M))throw RangeError(J3);return MW(I6(C,L,M),U)?M:L})(VW,G,Z,X);else{let F=G.getOffsetNanosecondsFor(j);j=X$(G,BW(g1(j,F),z,Y,X),F,2,0,1)}return T0(j,J,W)}function TW($,Z){return $0(BW($,...YO(Z)),$.calendar)}function KW($,Z){let[O,j,J]=YO(Z,5);var W;return n0((W=J,N6($,eZ(O,j),W)[0]))}function UW($,Z){let O=$(Z.timeZone),j=L0(Z,O),[J,W]=VW(j),z=y0(g0(v0(O,J),v0(O,W)),RO,1);if(z<=0)throw RangeError(J3);return z}function QW($,Z){let{timeZone:O,calendar:j}=Z,J=((W,z,Y)=>v0(z,W(L0(Y,z))))(CW,$(O),Z);return T0(J,O,j)}function BW($,Z,O,j){return DW($,eZ(Z,O),j)}function DW($,Z,O){let[j,J]=N6($,Z,O);return D1({...G$($,J),...j})}function N6($,Z,O){return jO(q1(k1($),Z,O))}function u3($){return q1($,bO,7)}function eZ($,Z){return Z1[$]*Z}function VW($){let Z=CW($);return[Z,G$(Z,1)]}function CW($){return cX(6,$)}function a7($,Z,O){let j=Math.min(j$($),6);return r$(KO(W0($,j),Z,O),j)}function FO($,Z,O,j,J,W,z,Y,X,G){if(j===0&&J===1)return $;let F=iZ(j,Y)?VO(Y)&&j<6&&O>=6?r7:o7:t7,[K,T,U]=F($,Z,O,j,J,W,z,Y,X,G);return U&&j!==7&&(K=((Q,B,D,C,L,M,P,f)=>{let _=y1(Q);for(let V=C+1;V<=D;V++){if(V===7&&D!==7)continue;let N=x8(V,Q);N[y[V]]+=_;let H=y0(g0(P(f(L,M,N)),B));if(H&&Math.sign(H)!==_)break;Q=N}return Q})(K,T,O,Math.max(6,j),z,Y,X,G)),K}function TO($,Z,O,j,J){if(Z===6){let W=((z)=>z[0]+z[1]/h)($);return[q1(W,O,j),0]}return KO($,eZ(Z,O),j,J)}function KO($,Z,O,j){let[J,W]=$;j&&W<0&&(W+=h,J-=1);let[z,Y]=U1(q1(W,Z,O),h);return W6(J+z,Y)}function q1($,Z,O){return MW($/Z,O)*Z}function MW($,Z){return zG[Z]($)}function o7($,Z,O,j,J,W){let z=y1($),Y=W0($),X=TO(Y,j,J,W),G=g0(Y,X),F=Math.sign(X[0]-Y[0])===z,K=r$(X,Math.min(O,6));return[{...$,...K},h$(Z,G),F]}function r7($,Z,O,j,J,W,z,Y,X,G){let F=y1($),K=y0(W0($,5)),T=eZ(j,J),U=q1(K,T,W),[Q,B]=M6(z,{...$,...H8},6,F,Y,X,G),D=U-y0(g0(Q,B)),C=0;D&&Math.sign(D)!==F?Z=c$(Q,U):(C+=F,U=q1(D,T,W),Z=c$(B,U));let L=MO(U);return[{...$,...L,days:$.days+C},Z,Boolean(C)]}function t7($,Z,O,j,J,W,z,Y,X,G){let F=y1($),K=y[j],T=x8(j,$);j===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let U=t3($[K],J)*J;T[K]=U;let[Q,B]=M6(z,T,j,J*F,Y,X,G),D=U+I6(Z,Q,B)*F*J,C=q1(D,J,W),L=Math.sign(C-D)===F;return T[K]=C,[T,L?B:Q,L]}function L6($,Z,O,j){let[J,W,z,Y]=((G)=>{let F=Q6(G=s0(G));return[G.timeZone,...F]})(j),X=J!==void 0;return((G,F,K,T,U,Q)=>{K=KO(K,U,T,1);let B=F.getOffsetNanosecondsFor(K);return A6(g1(K,B),Q)+(G?Y$(u3(B)):"Z")})(X,Z(X?$(J):D$),O.epochNanoseconds,W,z,Y)}function _6($,Z,O){let[j,J,W,z,Y,X]=((G)=>{G=s0(G);let F=v8(G),K=OW(G),T=WG(G),U=X3(G,4),Q=Y3(G,4);return[F,JG(G),T,U,...ZW(Q,K)]})(O);return((G,F,K,T,U,Q,B,D,C,L)=>{T=KO(T,C,D,1);let M=G(K).getOffsetNanosecondsFor(T);return A6(g1(T,M),L)+Y$(u3(M),B)+((P,f)=>f!==1?"["+(f===2?"!":"")+G0(P)+"]":"")(K,Q)+E6(F,U)})($,Z.calendar,Z.timeZone,Z.epochNanoseconds,j,J,W,z,Y,X)}function P6($,Z){let[O,j,J,W]=((G)=>(G=s0(G),[v8(G),...Q6(G)]))(Z);return z=$.calendar,Y=O,X=W,A6(DW($,J,j),X)+E6(z,Y);var z,Y,X}function S6($,Z){return O=$.calendar,j=$,J=U6(Z),s3(j)+E6(O,J);var O,j,J}function f6($,Z){return IW($.calendar,NW,$,U6(Z))}function H6($,Z){return IW($.calendar,e7,$,U6(Z))}function x6($,Z){let[O,j,J]=$W(Z);return W=J,LW(N6($,j,O)[0],W);var W}function UO($,Z){let[O,j,J]=$W(Z,3);return j>1&&($={...$,...a7($,j,O)}),((W,z)=>{let{sign:Y}=W,X=Y===-1?_0(W):W,{hours:G,minutes:F}=X,[K,T]=z6(W0(X,3),l0,w1);EW(K);let U=b6(T,z),Q=z>=0||!Y||U;return(Y<0?"-":"")+"P"+BJ({Y:Z$(X.years),M:Z$(X.months),W:Z$(X.weeks),D:Z$(X.days)})+(G||F||K||Q?"T"+BJ({H:Z$(G),M:Z$(F),S:Z$(K,Q)+U}):"")})($,J)}function IW($,Z,O,j){let J=G0($),W=j>1||j===0&&J!==q;return j===1?J===q?Z(O):s3(O):W?s3(O)+_W(J,j===2):Z(O)}function BJ($){let Z=[];for(let O in $){let j=$[O];j&&Z.push(j,O)}return Z.join("")}function A6($,Z){return s3($)+"T"+LW($,Z)}function s3($){return NW($)+"-"+c0($.isoDay)}function NW($){let{isoYear:Z}=$;return(Z<0||Z>9999?PW(Z)+c3(6,Math.abs(Z)):c3(4,Z))+"-"+c0($.isoMonth)}function e7($){return c0($.isoMonth)+"-"+c0($.isoDay)}function LW($,Z){let O=[c0($.isoHour),c0($.isoMinute)];return Z!==-1&&O.push(c0($.isoSecond)+((j,J,W,z)=>b6(j*O1+J*U$+W,z))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,Z)),O.join(":")}function Y$($,Z=0){if(Z===1)return"";let[O,j]=U1(Math.abs($),RO),[J,W]=U1(j,bO),[z,Y]=U1(W,l0);return PW($)+c0(O)+":"+c0(J)+(z||Y?":"+c0(z)+b6(Y):"")}function E6($,Z){if(Z!==1){let O=G0($);if(Z>1||Z===0&&O!==q)return _W(O,Z===2)}return""}function _W($,Z){return"["+(Z?"!":"")+"u-ca="+$+"]"}function b6($,Z){let O=c3(9,$);return O=Z===void 0?O.replace(GG,""):O.slice(0,Z),O?"."+O:""}function PW($){return $<0?"-":"+"}function Z$($,Z){return $||Z?$.toLocaleString("fullwide",{useGrouping:0}):""}function $X($,Z){let{epochNanoseconds:O}=$,j=(Z.getOffsetNanosecondsFor?Z:Z($.timeZone)).getOffsetNanosecondsFor(O),J=g1(O,j);return{calendar:$.calendar,...J,offsetNanoseconds:j}}function SW($,Z){let O=L0(Z,$);return{calendar:Z.calendar,...w0(vY,O),offset:Y$(O.offsetNanoseconds),timeZone:Z.timeZone}}function X$($,Z,O,j=0,J=0,W,z){if(O!==void 0&&j===1&&(j===1||z))return G6(Z,O);let Y=$.getPossibleInstantsFor(Z);if(O!==void 0&&j!==3){let X=((G,F,K,T)=>{let U=M0(F);T&&(K=u3(K));for(let Q of G){let B=y0(g0(Q,U));if(T&&(B=u3(B)),B===K)return Q}})(Y,Z,O,W);if(X!==void 0)return X;if(j===0)throw RangeError(HX)}return z?M0(Z):v0($,Z,J,Y)}function v0($,Z,O=0,j=$.getPossibleInstantsFor(Z)){if(j.length===1)return j[0];if(O===1)throw RangeError(xX);if(j.length)return j[O===3?1:0];let J=M0(Z),W=((Y,X)=>{let G=Y.getOffsetNanosecondsFor(c$(X,-h));return v6(Y.getOffsetNanosecondsFor(c$(X,h))-G)})($,J),z=W*(O===2?-1:1);return(j=$.getPossibleInstantsFor(g1(J,z)))[O===2?0:j.length-1]}function R6($){if(Math.abs($)>=h)throw RangeError(SX);return $}function v6($){if($>h)throw RangeError(fX);return $}function w6($,Z,O){return Y0(m0(h$(Z.epochNanoseconds,((j)=>{if(bW(j))throw RangeError(bX);return W0(j,5)})($?_0(O):O))))}function k6($,Z,O,j,J,W=Object.create(null)){let z=Z(j.timeZone),Y=$(j.calendar);return{...j,...p6(z,Y,j,O?_0(J):J,W)}}function q6($,Z,O,j,J=Object.create(null)){let{calendar:W}=O;return $0(h6($(W),O,Z?_0(j):j,J),W)}function g6($,Z,O,j,J){let{calendar:W}=O;return Z0(QO($(W),O,Z?_0(j):j,J),W)}function y6($,Z,O,j,J=Object.create(null)){let W=O.calendar,z=$(W),Y=dZ(z,O);Z&&(j=CO(j)),j.sign<0&&(Y=z.dateAdd(Y,{...F0,months:1}),Y=G$(Y,-1));let X=z.dateAdd(Y,j,J);return O$(dZ(z,X),W)}function m6($,Z,O){return n0(fW(Z,$?_0(O):O)[0])}function p6($,Z,O,j,J){let W=W0(j,5),z=O.epochNanoseconds;if(bW(j)){let Y=L0(O,$);z=h$(v0($,{...QO(Z,Y,{...j,...H8},J),...w0(o0,Y)}),W)}else z=h$(z,W),g(J);return{epochNanoseconds:m0(z)}}function h6($,Z,O,j){let[J,W]=fW(Z,O);return D1({...QO($,Z,{...O,...H8,days:O.days+W},j),...J})}function QO($,Z,O,j){if(O.years||O.months||O.weeks)return $.dateAdd(Z,O,j);g(j);let J=O.days+W0(O,5)[0];return J?R1(G$(Z,J)):Z}function dZ($,Z,O=1){return G$(Z,O-$.day(Z))}function fW($,Z){let[O,j]=W0(Z,5),[J,W]=jO(k1($)+j);return[J,O+W]}function G$($,Z){return Z?{...$,...JO(N0($)+Z*b0)}:$}function BO($,Z,O){let j=$(O.calendar);return VO(O)?[O,j,Z(O.timeZone)]:[{...O,...d0},j]}function c6($){return $?YW:M0}function DO($){return $?w(p6,$):h6}function l6($){return $?w(OX,$):jX}function VO($){return $&&$.epochNanoseconds}function iZ($,Z){return $<=6-(VO(Z)?1:0)}function d6($,Z,O,j,J,W,z){let Y=$(s0(z).relativeTo),X=Math.max(j$(J),j$(W));if(iZ(X,Y))return i(o$(((B,D,C,L)=>{let M=h$(W0(B),W0(D),L?-1:1);if(!Number.isFinite(M[0]))throw RangeError(AO);return{...F0,...r$(M,C)}})(J,W,X,j)));if(!Y)throw RangeError(EO);j&&(W=_0(W));let[G,F,K]=BO(Z,O,Y),T=DO(K),U=l6(K),Q=T(F,G,J);return i(U(F,G,T(F,Q,W),X))}function HW($,Z,O,j,J){let W=j$(j),[z,Y,X,G,F]=((_,V,N)=>{_=V6(_,o3);let H=R8(_),R=N(_[kY]),m=B6(_),r=X3(_,7),v=Y3(_);if(H===void 0&&v===void 0)throw RangeError(RX);return v==null&&(v=0),H==null&&(H=Math.max(v,V)),jW(H,v),m=D6(m,v,1),[H,v,m,r,R]})(J,W,$),K=Math.max(W,z);if(!VO(F)&&K<=6)return i(o$(((_,V,N,H,R)=>{let m=TO(W0(_),N,H,R);return{...F0,...r$(m,V)}})(j,z,Y,X,G)));if(!F)throw RangeError(EO);let[T,U,Q]=BO(Z,O,F),B=c6(Q),D=DO(Q),C=l6(Q),L=D(U,T,j),M=C(U,T,L,z),P=j.sign,f=y1(M);if(P&&f&&P!==f)throw RangeError(J3);return f&&(M=FO(M,B(L),z,Y,X,G,U,T,B,D)),i(M)}function xW($){return $.sign===-1?CO($):$}function CO($){return i(_0($))}function _0($){let Z={};for(let O of y)Z[O]=-1*$[O]||0;return Z}function AW($){return!$.sign}function y1($,Z=y){let O=0;for(let j of Z){let J=Math.sign($[j]);if(J){if(O&&O!==J)throw RangeError(EX);O=J}}return O}function o$($){for(let Z of pX)h0(Z,$[Z],-LJ,LJ,1);return EW(y0(W0($),l0)),$}function EW($){if(!Number.isSafeInteger($))throw RangeError(AX)}function W0($,Z=6){return bJ($,Z,y)}function r$($,Z=6){let[O,j]=$,J=e3(j,Z,y);if(J[y[Z]]+=O*(h/Z1[Z]),!Number.isFinite(J[y[Z]]))throw RangeError(AO);return J}function MO($,Z=5){return e3($,Z,y)}function bW($){return Boolean(y1($,bY))}function j$($){let Z=9;for(;Z>0&&!$[y[Z]];Z--);return Z}function ZX($,Z){return[$,Z]}function DJ($){let Z=Math.floor($/p3)*p3;return[Z,Z+p3]}function RW($){let Z=m1($=l3($));if(!Z)throw RangeError(E0($));let O;if(Z.m)O=0;else{if(!Z.offset)throw RangeError(E0($));O=t$(Z.offset)}return Z.timeZone&&n6(Z.timeZone,1),Y0(G6(WO(Z),O))}function vW($){let Z=m1(n($));if(!Z)throw RangeError(E0($));if(Z.timeZone)return cW(Z,Z.offset?t$(Z.offset):void 0);if(Z.m)throw RangeError(E0($));return dW(Z)}function wW($,Z){let O=m1(n($));if(!O||!O.timeZone)throw RangeError(E0($));let{offset:j}=O,J=j?t$(j):void 0,[,W,z]=tZ(Z);return cW(O,J,W,z)}function t$($){let Z=n6($);if(Z===void 0)throw RangeError(E0($));return Z}function kW($){let Z=m1(n($));if(!Z||Z.m)throw RangeError(E0($));return $0(lW(Z))}function IO($){let Z=m1(n($));if(!Z||Z.m)throw RangeError(E0($));return Z0(Z.p?lW(Z):dW(Z))}function qW($,Z){let O=u6(n(Z));if(O)return i6(O),O$(X6(W$(O)));let j=IO(Z);return O$(dZ($(j.calendar),j))}function i6($){if($.calendar!==q)throw RangeError(Q1($.calendar))}function gW($,Z){let O=s6(n(Z));if(O)return i6(O),i3(W$(O));let j=IO(Z),{calendar:J}=j,W=$(J),[z,Y,X]=W.h(j),[G,F]=W.I(z,Y),[K,T]=W.N(G,F,X);return i3(R1(W.P(K,T,X)),J)}function yW($){let Z,O=((j)=>{let J=QG.exec(j);return J?(NO(J[10]),sW(J)):void 0})(n($));if(!O){if(O=m1($),!O)throw RangeError(E0($));if(!O.p)throw RangeError(E0($));if(O.m)throw RangeError(Q1("Z"));i6(O)}if((Z=u6($))&&UJ(Z))throw RangeError(E0($));if((Z=s6($))&&UJ(Z))throw RangeError(E0($));return n0(zO(O,1))}function mW($){let Z=((O)=>{let j=VG.exec(O);return j?((J)=>{function W(F,K,T){let U=0,Q=0;if(T&&([U,X]=U1(X,Z1[T])),F!==void 0){if(Y)throw RangeError(Q1(F));Q=((B)=>{let D=parseInt(B);if(!Number.isFinite(D))throw RangeError(Q1(B));return D})(F),z=1,K&&(X=a6(K)*(Z1[T]/l0),Y=1)}return U+Q}let z=0,Y=0,X=0,G={...u$(y,[W(J[2]),W(J[3]),W(J[4]),W(J[5]),W(J[6],J[7],5),W(J[8],J[9],4),W(J[10],J[11],3)]),...e3(X,2,y)};if(!z)throw RangeError(FY(y));return o6(J[1])<0&&(G=_0(G)),G})(j):void 0})(n($));if(!Z)throw RangeError(E0($));return i(o$(Z))}function pW($){let Z=m1($)||u6($)||s6($);return Z?Z.calendar:$}function hW($){let Z=m1($);return Z&&(Z.timeZone||Z.m&&D$||Z.offset)||$}function cW($,Z,O=0,j=0){let J=LO($.timeZone),W=mO(J);return T0(X$(W,WO($),Z,O,j,!W.v,$.m),J,$3($.calendar))}function lW($){return iW(D1(WO($)))}function dW($){return iW(R1(W$($)))}function iW($){return{...$,calendar:$3($.calendar)}}function m1($){let Z=UG.exec($);return Z?((O)=>{let j=O[10],J=(j||"").toUpperCase()==="Z";return{isoYear:uW(O),isoMonth:parseInt(O[4]),isoDay:parseInt(O[5]),...sW(O.slice(5)),...NO(O[16]),p:Boolean(O[6]),m:J,offset:J?void 0:j}})(Z):void 0}function u6($){let Z=TG.exec($);return Z?((O)=>({isoYear:uW(O),isoMonth:parseInt(O[4]),isoDay:1,...NO(O[5])}))(Z):void 0}function s6($){let Z=KG.exec($);return Z?((O)=>({isoYear:i$,isoMonth:parseInt(O[1]),isoDay:parseInt(O[2]),...NO(O[3])}))(Z):void 0}function n6($,Z){let O=BG.exec($);return O?((j,J)=>{let W=j[4]||j[5];if(J&&W)throw RangeError(Q1(W));return R6((p$(j[2])*RO+p$(j[3])*bO+p$(j[4])*l0+a6(j[5]||""))*o6(j[1]))})(O,Z):void 0}function uW($){let Z=o6($[1]),O=parseInt($[2]||$[3]);if(Z<0&&!O)throw RangeError(Q1(-0));return Z*O}function sW($){let Z=p$($[3]);return{...jO(a6($[4]||""))[0],isoHour:p$($[1]),isoMinute:p$($[2]),isoSecond:Z===60?59:Z}}function NO($){let Z,O,j=[];if($.replace(DG,(J,W,z)=>{let Y=Boolean(W),[X,G]=z.split("=").reverse();if(G){if(G==="u-ca")j.push(X),Z||(Z=Y);else if(Y||/[A-Z]/.test(G))throw RangeError(Q1(J))}else{if(O)throw RangeError(Q1(J));O=X}return""}),j.length>1&&Z)throw RangeError(Q1($));return{timeZone:O,calendar:j[0]||q}}function a6($){return parseInt($.padEnd(9,"0"))}function e$($){return new RegExp(`^${$}$`,"i")}function o6($){return $&&$!=="+"?-1:1}function p$($){return $===void 0?0:parseInt($)}function nW($){return LO(n($))}function LO($){let Z=r6($);return typeof Z=="number"?Y$(Z):Z?((O)=>{if(MG.test(O))throw RangeError(PX);return O.toLowerCase().split("/").map((j,J)=>(j.length<=3||/\d/.test(j))&&!/etc|yap/.test(j)?j.toUpperCase():j.replace(/baja|dumont|[a-z]+/g,(W,z)=>W.length<=2&&!J||W==="in"||W==="chat"?W.toUpperCase():W.length>2||!z?TJ(W).replace(/island|noronha|murdo|rivadavia|urville/,TJ):W)).join("/")})($):D$}function VJ($){let Z=r6($);return typeof Z=="number"?Z:Z?Z.resolvedOptions().timeZone:D$}function r6($){let Z=n6($=$.toUpperCase(),1);return Z!==void 0?Z:$!==D$?CG($):void 0}function t6($,Z){return I0($.epochNanoseconds,Z.epochNanoseconds)}function e6($,Z){return I0($.epochNanoseconds,Z.epochNanoseconds)}function aW($,Z,O,j,J,W){let z=$(s0(W).relativeTo),Y=Math.max(j$(j),j$(J));if(AJ(y,j,J))return 0;if(iZ(Y,z))return I0(W0(j),W0(J));if(!z)throw RangeError(EO);let[X,G,F]=BO(Z,O,z),K=c6(F),T=DO(F);return I0(K(T(G,X,j)),K(T(G,X,J)))}function $8($,Z){return F$($,Z)||_O($,Z)}function F$($,Z){return b1(N0($),N0(Z))}function _O($,Z){return b1(k1($),k1(Z))}function oW($,Z){return!t6($,Z)}function rW($,Z){return!e6($,Z)&&!!PO($.timeZone,Z.timeZone)&&a$($.calendar,Z.calendar)}function tW($,Z){return!$8($,Z)&&a$($.calendar,Z.calendar)}function eW($,Z){return!F$($,Z)&&a$($.calendar,Z.calendar)}function $z($,Z){return!F$($,Z)&&a$($.calendar,Z.calendar)}function Zz($,Z){return!F$($,Z)&&a$($.calendar,Z.calendar)}function Oz($,Z){return!_O($,Z)}function PO($,Z){if($===Z)return 1;let O=G0($),j=G0(Z);if(O===j)return 1;try{return VJ(O)===VJ(j)}catch(J){}}function Z8($,Z,O,j){let J=n$($,e(j),3,5),W=SO(Z.epochNanoseconds,O.epochNanoseconds,...J);return i($?_0(W):W)}function O8($,Z,O,j,J,W){let z=HO(j.calendar,J.calendar),Y=e(W),[X,G,F,K]=n$(O,Y,5),T=j.epochNanoseconds,U=J.epochNanoseconds,Q=I0(U,T),B;if(Q)if(X<6)B=SO(T,U,X,G,F,K);else{let D=Z(((L,M)=>{if(!PO(L,M))throw RangeError(DY);return L})(j.timeZone,J.timeZone)),C=$(z);B=Jz(C,D,j,J,Q,X,Y),B=FO(B,U,X,G,F,K,C,j,YW,w(p6,D))}else B=F0;return i(O?_0(B):B)}function j8($,Z,O,j,J){let W=HO(O.calendar,j.calendar),z=e(J),[Y,X,G,F]=n$(Z,z,6),K=M0(O),T=M0(j),U=I0(T,K),Q;if(U)if(Y<=6)Q=SO(K,T,Y,X,G,F);else{let B=$(W);Q=Wz(B,O,j,U,Y,z),Q=FO(Q,T,Y,X,G,F,B,O,M0,h6)}else Q=F0;return i(Z?_0(Q):Q)}function J8($,Z,O,j,J){let W=HO(O.calendar,j.calendar),z=e(J);return jz(Z,()=>$(W),O,j,...n$(Z,z,6,9,6),z)}function W8($,Z,O,j,J){let W=HO(O.calendar,j.calendar),z=e(J),Y=n$(Z,z,9,9,8),X=$(W);return jz(Z,()=>X,dZ(X,O),dZ(X,j),...Y,z)}function jz($,Z,O,j,J,W,z,Y,X){let G=M0(O),F=M0(j),K;if(I0(F,G))if(J===6)K=SO(G,F,J,W,z,Y);else{let T=Z();K=T.dateUntil(O,j,J,X),W===6&&z===1||(K=FO(K,F,J,W,z,Y,T,O,M0,QO))}else K=F0;return i($?_0(K):K)}function z8($,Z,O,j){let J=e(j),[W,z,Y,X]=n$($,J,5,5),G=q1(Y8(Z,O),eZ(z,Y),X),F={...F0,...MO(G,W)};return i($?_0(F):F)}function OX($,Z,O,j,J,W){let z=I0(j.epochNanoseconds,O.epochNanoseconds);return z?J<6?zz(O.epochNanoseconds,j.epochNanoseconds,J):Jz(Z,$,O,j,z,J,W):F0}function jX($,Z,O,j,J){let W=M0(Z),z=M0(O),Y=I0(z,W);return Y?j<=6?zz(W,z,j):Wz($,Z,O,Y,j,J):F0}function Jz($,Z,O,j,J,W,z){let[Y,X,G]=((T,U,Q,B)=>{function D(){return V={...G$(M,f++*-B),...L},N=v0(T,V),I0(P,N)===-B}let C=L0(U,T),L=w0(o0,C),M=L0(Q,T),P=Q.epochNanoseconds,f=0,_=Y8(C,M),V,N;if(Math.sign(_)===-B&&f++,D()&&(B===-1||D()))throw RangeError(J3);let H=y0(g0(N,P));return[C,V,H]})(Z,O,j,J);var F,K;return{...W===6?(F=Y,K=X,{...F0,days:Yz(F,K)}):$.dateUntil(Y,X,W,z),...MO(G)}}function Wz($,Z,O,j,J,W){let[z,Y,X]=((G,F,K)=>{let T=F,U=Y8(G,F);return Math.sign(U)===-K&&(T=G$(F,-K),U+=h*K),[G,T,U]})(Z,O,j);return{...$.dateUntil(z,Y,J,W),...MO(X)}}function SO($,Z,O,j,J,W){return{...F0,...r$(TO(g0($,Z),j,J,W),O)}}function zz($,Z,O){return{...F0,...r$(g0($,Z),O)}}function Yz($,Z){return fO(N0($),N0(Z))}function fO($,Z){return Math.trunc((Z-$)/b0)}function Y8($,Z){return k1(Z)-k1($)}function HO($,Z){if(!a$($,Z))throw RangeError(L8);return $}function JX($){function Z(J){return((W,z)=>({...Xz(W,z),F:W.month,day:parseInt(W.day)}))(Y6(O,J),j)}let O=g8($),j=n3($);return{id:$,O:WX(Z),B:zX(Z)}}function WX($){return R0((Z)=>{let O=N0(Z);return $(O)},WeakMap)}function zX($){let Z=$(0).year-uX;return R0((O)=>{let j,J=s$(O-Z),W=[],z=[];do J+=400*b0;while((j=$(J)).year<=O);do J+=(1-j.day)*b0,j.year===O&&(W.push(J),z.push(j.F)),J-=b0;while((j=$(J)).year>=O);return{k:W.reverse(),C:MY(z.reverse())}})}function Xz($,Z){let O,j,J=Gz($);if($.era){let W=xY[Z];W!==void 0&&(O=Z==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),O==="bc"||O==="b"?O="bce":O!=="ad"&&O!=="a"||(O="ce"),j=J,J=Qz(j,W[O]||0))}return{era:O,eraYear:j,year:J}}function Gz($){return parseInt($.relatedYear||$.year)}function ij($){let{year:Z,F:O,day:j}=this.O($),{C:J}=this.B(Z);return[Z,J[O]+1,j]}function uZ($,Z=1,O=1){return this.B($).k[Z-1]+(O-1)*b0}function g3($){let Z=MJ(this,$),O=MJ(this,$-1),j=Z.length;if(j>O.length){let J=Bz(this);if(J<0)return-J;for(let W=0;W<j;W++)if(Z[W]!==O[W])return W+1}}function y3($){return fO(uZ.call(this,$),uZ.call(this,$+1))}function CJ($,Z){let{k:O}=this.B($),j=Z+1,J=O;return j>O.length&&(j=1,J=this.B($+1).k),fO(O[Z-1],J[j-1])}function m3($){return this.B($).k.length}function MJ($,Z){return Object.keys($.B(Z).C)}function Fz($){return $3(n($))}function $3($){if(($=$.toLowerCase())!==q&&$!==wO&&n3($)!==n3(g8($).resolvedOptions().calendar))throw RangeError(_X($));return $}function n3($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function Tz($){return this.R($)[0]}function Kz($){return this.R($)[1]}function X8($){let[Z]=this.h($);return fO(this.q(Z),N0($))+1}function Uz($){let Z=NG.exec($);if(!Z)throw RangeError(NX($));return[parseInt(Z[1]),Boolean(Z[2])]}function a3($,Z,O){return $+(Z||O&&$>=O?1:0)}function uj($,Z){return $-(Z&&$>=Z?1:0)}function Qz($,Z){return(Z+$)*(Math.sign(Z)||1)||0}function sj($){return xY[Dz($)]}function Bz($){return gX[Dz($)]}function Dz($){return n3($.id||q)}function Vz($,Z,O,j){let J=p1(O,j,a0,[],PY);if(J.timeZone!==void 0){let W=O.dateFromFields(J),z=T$(J),Y=$(J.timeZone);return{epochNanoseconds:X$(Z(Y),{...W,...z},J.offset!==void 0?t$(J.offset):void 0),timeZone:Y}}return{...O.dateFromFields(J),...d0}}function Cz($,Z,O,j,J,W){let z=p1(O,J,a0,LY,PY),Y=$(z.timeZone),[X,G,F]=tZ(W),K=O.dateFromFields(z,XO(W,X)),T=T$(z,X);return T0(X$(Z(Y),{...K,...T},z.offset!==void 0?t$(z.offset):void 0,G,F),Y,j)}function Mz($,Z,O){let j=p1($,Z,a0,[],M1),J=g(O);return $0(D1({...$.dateFromFields(j,XO(O,J)),...T$(j,J)}))}function G8($,Z,O,j=[]){let J=p1($,Z,a0,j);return $.dateFromFields(J,O)}function F8($,Z,O,j){let J=p1($,Z,S8,j);return $.yearMonthFromFields(J,O)}function T8($,Z,O,j,J=[]){let W=p1($,O,a0,J);return Z&&W.month!==void 0&&W.monthCode===void 0&&W.year===void 0&&(W.year=i$),$.monthDayFromFields(W,j)}function Iz($,Z){let O=g(Z);return n0(T$($1($,aj,[],1),O))}function Nz($){let Z=$1($,f8);return i(o$({...F0,...Z}))}function p1($,Z,O,j=[],J=[]){return $1(Z,[...$.fields(O),...J].sort(),j)}function $1($,Z,O,j=!O){let J={},W,z=0;for(let Y of Z){if(Y===W)throw RangeError(BX(Y));if(Y==="constructor"||Y==="__proto__")throw RangeError(I8(Y));let X=$[Y];if(X!==void 0)z=1,_J[Y]&&(X=_J[Y](X,Y)),J[Y]=X;else if(O){if(O.includes(Y))throw TypeError(M8(Y));J[Y]=HY[Y]}W=Y}if(j&&!z)throw TypeError(FY(Z));return J}function T$($,Z){return zO(SG({...HY,...$}),Z)}function Lz($,Z,O,j,J,W){let z=e(W),{calendar:Y,timeZone:X}=O;return T0(((G,F,K,T,U)=>{let Q=Z3(G,K,T,a0,_Y,NY),[B,D,C]=tZ(U,2);return X$(F,{...G.dateFromFields(Q,XO(U,B)),...T$(Q,B)},t$(Q.offset),D,C)})($(Y),Z(X),j,J,z),X,Y)}function _z($,Z,O,j,J){let W=e(J);return $0(((z,Y,X,G)=>{let F=Z3(z,Y,X,a0,M1),K=g(G);return D1({...z.dateFromFields(F,XO(G,K)),...T$(F,K)})})($(Z.calendar),O,j,W))}function Pz($,Z,O,j,J){let W=e(J);return((z,Y,X,G)=>{let F=Z3(z,Y,X,a0);return z.dateFromFields(F,G)})($(Z.calendar),O,j,W)}function Sz($,Z,O,j,J){let W=e(J);return O$(((z,Y,X,G)=>{let F=Z3(z,Y,X,S8);return z.yearMonthFromFields(F,G)})($(Z.calendar),O,j,W))}function fz($,Z,O,j,J){let W=e(J);return((z,Y,X,G)=>{let F=Z3(z,Y,X,a0);return z.monthDayFromFields(F,G)})($(Z.calendar),O,j,W)}function Hz($,Z,O){return n0(((j,J,W)=>{let z=g(W);return T$({...w0(aj,j),...$1(J,aj)},z)})($,Z,O))}function xz($,Z){return i((O=$,j=Z,o$({...O,...$1(j,f8)})));var O,j}function Z3($,Z,O,j,J=[],W=[]){let z=[...$.fields(j),...J].sort(),Y=$1(Z,z,W),X=$1(O,z);return Y=$.mergeFields(Y,X),$1(Y,z,[])}function K8($,Z){let O=p1($,Z,fY);return $.monthDayFromFields(O)}function U8($,Z,O){let j=p1($,Z,SY);return $.yearMonthFromFields(j,O)}function Az($,Z,O,j,J){Z=w0(O=$.fields(O),Z),j=$1(j,J=$.fields(J),[]);let W=$.mergeFields(Z,j);return W=$1(W,[...O,...J].sort(),[]),$.dateFromFields(W)}function pj($,Z){let{era:O,eraYear:j,year:J}=Z,W=sj($);if(O!==void 0||j!==void 0){if(O===void 0||j===void 0)throw TypeError(VX);if(!W)throw RangeError(DX);let z=W[O];if(z===void 0)throw RangeError(MX(O));let Y=Qz(j,z);if(J!==void 0&&J!==Y)throw RangeError(CX);J=Y}else if(J===void 0)throw TypeError(IX(W));return J}function hj($,Z,O,j){let{month:J,monthCode:W}=Z;if(W!==void 0){let z=((Y,X,G,F)=>{let K=Y.U(G),[T,U]=Uz(X),Q=a3(T,U,K);if(U){let B=Bz(Y);if(B===void 0)throw RangeError(hZ);if(B>0){if(Q>B)throw RangeError(hZ);if(K===void 0){if(F===1)throw RangeError(hZ);Q--}}else{if(Q!==-B)throw RangeError(hZ);if(K===void 0&&F===1)throw RangeError(hZ)}}return Q})($,W,O,j);if(J!==void 0&&J!==z)throw RangeError(QY);J=z,j=1}else if(J===void 0)throw TypeError(LX);return h0("month",J,1,$.L(O),j)}function IJ($,Z,O,j,J){return A0(Z,"day",1,$.j(j,O),J)}function cj($,Z,O,j){let J=0,W=[];for(let z of O)Z[z]!==void 0?J=1:W.push(z);if(Object.assign($,Z),J)for(let z of j||W)delete $[z]}function Ez($){return Y0(m0(OO(ZO($))))}function bz($,Z,O,j,J=q){return T0(m0(OO(ZO(O))),Z(j),$(J))}function Rz($,Z,O,j,J=0,W=0,z=0,Y=0,X=0,G=0,F=q){return $0(D1(WO(i0(C0,u$(kO,[Z,O,j,J,W,z,Y,X,G])))),$(F))}function vz($,Z,O,j,J=q){return Z0(R1(W$(i0(C0,{isoYear:Z,isoMonth:O,isoDay:j}))),$(J))}function wz($,Z,O,j=q,J=1){let W=C0(Z),z=C0(O),Y=$(j);return O$(X6(W$({isoYear:W,isoMonth:z,isoDay:C0(J)})),Y)}function kz($,Z,O,j=q,J=i$){let W=C0(Z),z=C0(O),Y=$(j);return i3(R1(W$({isoYear:C0(J),isoMonth:W,isoDay:z})),Y)}function qz($=0,Z=0,O=0,j=0,J=0,W=0){return n0(zO(i0(C0,u$(o0,[$,Z,O,j,J,W])),1))}function gz($=0,Z=0,O=0,j=0,J=0,W=0,z=0,Y=0,X=0,G=0){return i(o$(i0(hJ,u$(y,[$,Z,O,j,J,W,z,Y,X,G]))))}function Q8($,Z,O=q){return T0($.epochNanoseconds,Z,O)}function yz($){return Y0($.epochNanoseconds)}function B8($,Z){return $0(L0(Z,$))}function D8($,Z){return Z0(L0(Z,$))}function mz($,Z,O){return U8($(Z.calendar),O)}function pz($,Z,O){return K8($(Z.calendar),O)}function V8($,Z){return n0(L0(Z,$))}function hz($,Z,O,j){let J=((W,z,Y,X)=>{let G=K6(X);return v0(W(z),Y,G)})($,O,Z,j);return T0(m0(J),O,Z.calendar)}function cz($,Z,O){let j=$(Z.calendar);return O$({...Z,...U8(j,O)})}function lz($,Z,O){return K8($(Z.calendar),O)}function dz($,Z,O,j,J){let W=$(J.timeZone),z=J.plainTime,Y=z!==void 0?Z(z):d0;return T0(v0(O(W),{...j,...Y}),W,j.calendar)}function iz($,Z=d0){return $0(D1({...$,...Z}))}function uz($,Z,O){return U8($(Z.calendar),O)}function sz($,Z,O){return K8($(Z.calendar),O)}function nz($,Z,O,j){return((J,W,z)=>Az(J,W,SY,B1(z),z3))($(Z.calendar),O,j)}function az($,Z,O,j){return((J,W,z)=>Az(J,W,fY,B1(z),vO))($(Z.calendar),O,j)}function oz($,Z,O,j,J){let W=B1(J),z=Z(W.plainDate),Y=$(W.timeZone);return T0(v0(O(Y),{...z,...j}),Y,z.calendar)}function rz($,Z){return $0(D1({...$,...Z}))}function tz($){return Y0(m0(l$($,l0)))}function ez($){return Y0(m0(l$($,O1)))}function $Y($){return Y0(m0(OO(ZO($),U$)))}function ZY($){return Y0(m0(OO(ZO($))))}function OY($,Z,O=d0){let j=Z.timeZone,J=$(j),W={...L0(Z,J),...O};return T0(X$(J,W,W.offsetNanoseconds,2),j,Z.calendar)}function jY($,Z,O){let j=Z.timeZone,J=$(j),W={...L0(Z,J),...O},z=YY(Z.calendar,O.calendar);return T0(X$(J,W,W.offsetNanoseconds,2),j,z)}function JY($,Z=d0){return $0({...$,...Z})}function WY($,Z){return $0({...$,...Z},YY($.calendar,Z.calendar))}function xO($,Z){return{...$,calendar:Z}}function zY($,Z){return{...$,timeZone:Z}}function YY($,Z){if($===Z)return $;let O=G0($),j=G0(Z);if(O===j||O===q)return Z;if(j===q)return $;throw RangeError(L8)}function YX($,Z){return(O)=>O===q?$:O===wO||O===d$?Object.assign(Object.create($),{id:O}):Object.assign(Object.create(Z),IG(O))}function K$($,Z,O){let j=new Set(O);return(J)=>(((W,z)=>{for(let Y of z)if(Y in W)return 1;return 0})(J=ej(j,J),$)||Object.assign(J,Z),O&&(J.timeZone=D$,["full","long"].includes(J.timeStyle)&&(J.timeStyle="medium")),J)}function V1($,Z=C8){let[O,,,j]=$;return(J,W=hG,...z)=>{let Y=Z(j&&j(...z),J,W,O),X=Y.resolvedOptions();return[Y,...XX($,X,z)]}}function C8($,Z,O,j){if(O=j(O),$){if(O.timeZone!==void 0)throw TypeError(wX);O.timeZone=$}return new h1(Z,O)}function XX($,Z,O){let[,j,J]=$;return O.map((W)=>(W.calendar&&((z,Y,X)=>{if((X||z!==q)&&z!==Y)throw RangeError(L8)})(G0(W.calendar),Z.calendar,J),j(W,Z)))}function $Z($){let Z=O3();return g1(Z,$.getOffsetNanosecondsFor(Z))}function O3(){return l$(Date.now(),O1)}function C1(){return SJ||(SJ=new h1().resolvedOptions().timeZone)}var GX=($,Z)=>`Non-integer ${$}: ${Z}`,FX=($,Z)=>`Non-positive ${$}: ${Z}`,TX=($,Z)=>`Non-finite ${$}: ${Z}`,KX=($)=>`Cannot convert bigint to ${$}`,UX=($)=>`Invalid bigint: ${$}`,QX="Cannot convert Symbol to string",XY="Invalid object",GY=($,Z,O,j,J)=>J?GY($,J[Z],J[O],J[j]):j3($,Z)+`; must be between ${O}-${j}`,j3=($,Z)=>`Invalid ${$}: ${Z}`,M8=($)=>`Missing ${$}`,I8=($)=>`Invalid field ${$}`,BX=($)=>`Duplicate field ${$}`,FY=($)=>"No valid fields: "+$.join(),TY="Invalid bag",KY=($,Z,O)=>j3($,Z)+"; must be "+Object.keys(O).join(),UY="Cannot use valueOf",N8="Invalid calling context",DX="Forbidden era/eraYear",VX="Mismatching era/eraYear",CX="Mismatching year/eraYear",MX=($)=>`Invalid era: ${$}`,IX=($)=>"Missing year"+($?"/era/eraYear":""),NX=($)=>`Invalid monthCode: ${$}`,QY="Mismatching month/monthCode",LX="Missing month/monthCode",NJ="Cannot guess year",hZ="Invalid leap month",BY="Invalid protocol",J3="Invalid protocol results",L8="Mismatching Calendars",_X=($)=>`Invalid Calendar: ${$}`,DY="Mismatching TimeZones",PX="Forbidden ICU TimeZone",SX="Out-of-bounds offset",fX="Out-of-bounds TimeZone gap",HX="Invalid TimeZone offset",xX="Ambiguous offset",AO="Out-of-bounds date",AX="Out-of-bounds duration",EX="Cannot mix duration signs",EO="Missing relativeTo",bX="Cannot use large units",RX="Required smallestUnit or largestUnit",vX="smallestUnit > largestUnit",E0=($)=>`Cannot parse: ${$}`,Q1=($)=>`Invalid substring: ${$}`,VY=($)=>`Cannot format ${$}`,CY="Mismatching types for formatting",wX="Cannot specify TimeZone",MY=w(aZ,($,Z)=>Z),ZZ=w(aZ,($,Z,O)=>O),c0=w(c3,2),nj={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},W3=Object.keys(nj),b0=86400000,IY=1000,U$=1000,O1=1e6,l0=1e9,bO=60000000000,RO=3600000000000,h=86400000000000,Z1=[1,U$,O1,l0,bO,RO,h],M1=W3.slice(0,6),aj=oZ(M1),NY=["offset"],LY=["timeZone"],_Y=M1.concat(NY),PY=_Y.concat(LY),oj=["era","eraYear"],kX=oj.concat(["year"]),vO=["year"],_8=["monthCode"],P8=["month"].concat(_8),z3=["day"],S8=P8.concat(vO),SY=_8.concat(vO),a0=z3.concat(S8),qX=z3.concat(P8),fY=z3.concat(_8),HY=ZZ(M1,0),q="iso8601",wO="gregory",d$="japanese",xY={[wO]:{bce:-1,ce:0},[d$]:{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}},gX={chinese:13,dangi:13,hebrew:-6},n=w($O,"string"),AY=w($O,"boolean"),yX=w($O,"number"),EY=w($O,"function"),y=W3.map(($)=>$+"s"),f8=oZ(y),mX=y.slice(0,6),bY=y.slice(6),pX=bY.slice(1),hX=MY(y),F0=ZZ(y,0),H8=ZZ(mX,0),x8=w(EJ,y),o0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],A8=["isoDay","isoMonth","isoYear"],kO=o0.concat(A8),E8=oZ(A8),RY=oZ(o0),vY=oZ(kO),d0=ZZ(RY,0),cX=w(EJ,kO),h1=Intl.DateTimeFormat,wY="en-GB",b8=1e8,lX=b8*b0,dX=[b8,0],iX=[-b8,0],sZ=275760,nZ=-271821,uX=1970,i$=1972,K1=12,sX=s$(1868,9,8),nX=R0(n7,WeakMap),o3="smallestUnit",rj="unit",lZ="roundingIncrement",lj="fractionalSecondDigits",kY="relativeTo",qY={constrain:0,reject:1},aX=Object.keys(qY),oX={compatible:0,reject:1,earlier:2,later:3},rX={reject:0,use:1,prefer:2,ignore:3},tX={auto:0,never:1,critical:2,always:3},eX={auto:0,never:1,critical:2},$G={auto:0,never:1},ZG={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},Y3=w(C6,o3),R8=w(C6,"largestUnit"),OG=w(C6,rj),gY=w(z$,"overflow",qY),yY=w(z$,"disambiguation",oX),jG=w(z$,"offset",rX),v8=w(z$,"calendarName",tX),JG=w(z$,"timeZoneName",eX),WG=w(z$,"offset",$G),X3=w(z$,"roundingMode",ZG),OZ="PlainYearMonth",jZ="PlainMonthDay",Q$="PlainDate",B$="PlainDateTime",qO="PlainTime",I1="ZonedDateTime",gO="Instant",yO="Duration",zG=[Math.floor,($)=>q3($)?Math.floor($):Math.round($),Math.ceil,($)=>q3($)?Math.ceil($):Math.round($),Math.trunc,($)=>q3($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>q3($)?($=Math.trunc($)||0)+$%2:Math.round($)],D$="UTC",p3=5184000,YG=d3(1847),XG=d3(new Date().getUTCFullYear()+10),GG=/0+$/,L0=R0($X,WeakMap),LJ=4294967295,mO=R0(($)=>{let Z=r6($);return typeof Z=="object"?new pY(Z):new mY(Z||0)});class mY{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[G6($,this.v)]}l(){}}class pY{constructor($){this.$=((Z)=>{function O(X){let G=dj(X,z,Y),[F,K]=DJ(G),T=J(F),U=J(K);return T===U?T:j(W(F,K),T,U,X)}function j(X,G,F,K){let T,U;for(;(K===void 0||(T=K<X[0]?G:K>=X[1]?F:void 0)===void 0)&&(U=X[1]-X[0]);){let Q=X[0]+Math.floor(U/2);Z(Q)===F?X[1]=Q:X[0]=Q+1}return T}let J=R0(Z),W=R0(ZX),z=YG,Y=XG;return{G(X){let G=O(X-86400),F=O(X+86400),K=X-G,T=X-F;if(G===F)return[K];let U=O(K);return U===O(T)?[X-U]:G>F?[K,T]:[]},V:O,l(X,G){let F=dj(X,z,Y),[K,T]=DJ(F),U=p3*G,Q=G<0?()=>T>z||(z=F,0):()=>K<Y||(Y=F,0);for(;Q();){let B=J(K),D=J(T);if(B!==D){let C=W(K,T);j(C,B,D);let L=C[0];if((b1(L,X)||1)===G)return L}K+=U,T+=U}}}})(((Z)=>(O)=>{let j=Y6(Z,O*IY);return d3(Gz(j),parseInt(j.month),parseInt(j.day),parseInt(j.hour),parseInt(j.minute),parseInt(j.second))-O})($))}getOffsetNanosecondsFor($){return this.$.V(dJ($))*l0}getPossibleInstantsFor($){let[Z,O]=[d3((j=$).isoYear,j.isoMonth,j.isoDay,j.isoHour,j.isoMinute,j.isoSecond),j.isoMillisecond*O1+j.isoMicrosecond*U$+j.isoNanosecond];var j;return this.$.G(Z).map((J)=>m0(c$(l$(J,l0),O)))}l($,Z){let[O,j]=iJ($),J=this.$.l(O+(Z>0||j?1:0),Z);if(J!==void 0)return l$(J,l0)}}var w8="([+\u2212-])",h3="(?:[.,](\\d{1,9}))?",hY=`(?:(?:${w8}(\\d{6}))|(\\d{4}))-?(\\d{2})`,k8="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+h3+")?)?",q8=w8+k8,FG=hY+"-?(\\d{2})(?:[T ]"+k8+"(Z|"+q8+")?)?",cY="\\[(!?)([^\\]]*)\\]",pO=`((?:${cY}){0,9})`,TG=e$(hY+pO),KG=e$("(?:--)?(\\d{2})-?(\\d{2})"+pO),UG=e$(FG+pO),QG=e$("T?"+k8+"(?:"+q8+")?"+pO),BG=e$(q8),DG=new RegExp(cY,"g"),VG=e$(`${w8}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${h3}H)?(?:(\\d+)${h3}M)?(?:(\\d+)${h3}S)?)?`),CG=R0(($)=>new h1(wY,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),MG=/^(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$/,IG=R0(JX),g8=R0(($)=>new h1(wY,{calendar:$,timeZone:D$,era:"short",year:"numeric",month:"short",day:"numeric"})),NG=/^M(\d{2})(L?)$/,LG={era:l3,eraYear:C0,year:C0,month:KJ,monthCode:l3,day:KJ},_G=ZZ(M1,C0),PG=ZZ(y,hJ),_J=Object.assign({},LG,_G,PG,{offset:l3}),SG=w(s7,M1,o0),PJ={dateAdd($,Z,O){let j=g(O),J,{years:W,months:z,weeks:Y,days:X}=Z;if(X+=W0(Z,5)[0],W||z)J=((G,F,K,T,U)=>{let[Q,B,D]=G.h(F);if(K){let[C,L]=G.I(Q,B);Q+=K,B=a3(C,L,G.U(Q)),B=h0("month",B,1,G.L(Q),U)}return T&&([Q,B]=G._(Q,B,T)),D=h0("day",D,1,G.j(Q,B),U),G.q(Q,B,D)})(this,$,W,z,j);else{if(!Y&&!X)return $;J=N0($)}return J+=(7*Y+X)*b0,R1(JO(J))},dateUntil($,Z,O){if(O<=7){let X=0,G=Yz({...$,...d0},{...Z,...d0});return O===7&&([X,G]=w1(G,7)),{...F0,weeks:X,days:G}}let j=this.h($),J=this.h(Z),[W,z,Y]=((X,G,F,K,T,U,Q)=>{let B=T-G,D=U-F,C=Q-K;if(B||D){let L=Math.sign(B||D),M=X.j(T,U),P=0;if(Math.sign(C)===-L){let f=M;[T,U]=X._(T,U,-L),B=T-G,D=U-F,M=X.j(T,U),P=L<0?-f:M}if(C=Q-Math.min(K,M)+P,B){let[f,_]=X.I(G,F),[V,N]=X.I(T,U);if(D=V-f||Number(N)-Number(_),Math.sign(D)===-L){let H=L<0&&-X.L(T);B=(T-=L)-G,D=U-a3(f,_,X.U(T))+(H||X.L(T))}}}return[B,D,C]})(this,...j,...J);return O===8&&(z+=this.J(W,j[0]),W=0),{...F0,years:W,months:z,days:Y}},dateFromFields($,Z){let O=g(Z),j=pj(this,$),J=hj(this,$,j,O),W=IJ(this,$,J,j,O);return Z0(R1(this.P(j,J,W)),this.id||q)},yearMonthFromFields($,Z){let O=g(Z),j=pj(this,$),J=hj(this,$,j,O);return O$(X6(this.P(j,J,1)),this.id||q)},monthDayFromFields($,Z){let O=g(Z),j=!this.id,{monthCode:J,year:W,month:z}=$,Y,X,G,F,K;if(J!==void 0){[Y,X]=Uz(J),K=fJ($,"day");let T=this.N(Y,X,K);if(!T)throw RangeError(NJ);if([G,F]=T,z!==void 0&&z!==F)throw RangeError(QY);j&&(F=h0("month",F,1,K1,1),K=h0("day",K,1,F6(W!==void 0?W:G,F),O))}else{G=W===void 0&&j?i$:pj(this,$),F=hj(this,$,G,O),K=IJ(this,$,F,G,O);let T=this.U(G);X=F===T,Y=uj(F,T);let U=this.N(Y,X,K);if(!U)throw RangeError(NJ);[G,F]=U}return i3(R1(this.P(G,F,K)),this.id||q)},fields($){return sj(this)&&$.includes("year")?[...$,...oj]:$},mergeFields($,Z){let O=Object.assign(Object.create(null),$);return cj(O,Z,P8),sj(this)&&(cj(O,Z,kX),this.id===d$&&cj(O,Z,qX,oj)),O},inLeapYear($){let[Z]=this.h($);return this.K(Z)},monthsInYear($){let[Z]=this.h($);return this.L(Z)},daysInMonth($){let[Z,O]=this.h($);return this.j(Z,O)},daysInYear($){let[Z]=this.h($);return this.X(Z)},dayOfYear:X8,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[Z,O]=this.h($),[j,J]=this.I(Z,O);return((W,z)=>"M"+c0(W)+(z?"L":""))(j,J)},dayOfWeek:oJ,daysInWeek(){return 7}},fG={dayOfYear:X8,h:sJ,q:s$},HG=Object.assign({},fG,{weekOfYear:Tz,yearOfWeek:Kz,R($){function Z(U){return(7-U<j?7:0)-U}function O(U){let Q=aJ(T+U),B=U||1,D=Z(cZ(X+Q*B,7));return F=(Q+(D-G)*B)/7}let j=this.id?1:4,J=oJ($),W=this.dayOfYear($),z=cZ(J-1,7),Y=W-1,X=cZ(z-Y,7),G=Z(X),F,K=Math.floor((Y-G)/7)+1,T=$.isoYear;return K?K>O(0)&&(K=1,T++):(K=O(-1),T--),[K,T,F]}}),xG={dayOfYear:X8,h:ij,q:uZ,weekOfYear:Tz,yearOfWeek:Kz,R(){return[]}},JZ=YX(Object.assign({},PJ,HG,{h:sJ,ee($){return this.id===wO?rJ($):this.id===d$?nX($):[]},I:($,Z)=>[Z,0],N($,Z){if(!Z)return[i$,$]},K:T6,U(){},L:nJ,J:($)=>$*K1,j:F6,X:aJ,P:($,Z,O)=>({isoYear:$,isoMonth:Z,isoDay:O}),q:s$,_:($,Z,O)=>($+=t3(O,K1),(Z+=Z6(O,K1))<1?($--,Z+=K1):Z>K1&&($++,Z-=K1),[$,Z]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},PJ,xG,{h:ij,ee($){let Z=this.O($);return[Z.era,Z.eraYear]},I($,Z){let O=g3.call(this,$);return[uj(Z,O),O===Z]},N($,Z,O){let[j,J,W]=ij.call(this,{isoYear:i$,isoMonth:K1,isoDay:31}),z=g3.call(this,j),Y=J===z;(b1($,uj(J,z))||b1(Number(Z),Number(Y))||b1(O,W))===1&&j--;for(let X=0;X<100;X++){let G=j-X,F=g3.call(this,G),K=a3($,Z,F);if(Z===(K===F)&&O<=CJ.call(this,G,K))return[G,K]}},K($){let Z=y3.call(this,$);return Z>y3.call(this,$-1)&&Z>y3.call(this,$+1)},U:g3,L:m3,J($,Z){let O=Z+$,j=Math.sign($),J=j<0?-1:0,W=0;for(let z=Z;z!==O;z+=j)W+=m3.call(this,z+J);return W},j:CJ,X:y3,P($,Z,O){return JO(uZ.call(this,$,Z,O))},q:uZ,_($,Z,O){if(O){if(Z+=O,!Number.isSafeInteger(Z))throw RangeError(AO);if(O<0)for(;Z<1;)Z+=m3.call(this,--$);else{let j;for(;Z>(j=m3.call(this,$));)Z-=j,$++}}return[$,Z]},year($){return this.O($).year},month($){let{year:Z,F:O}=this.O($),{C:j}=this.B(Z);return j[O]+1},day($){return this.O($).day}})),v1="numeric",WZ=["timeZoneName"],lY={month:v1,day:v1},y8={year:v1,month:v1},m8=Object.assign({},y8,{day:v1}),p8={hour:v1,minute:v1,second:v1},h8=Object.assign({},m8,p8),AG=Object.assign({},h8,{timeZoneName:"short"}),EG=Object.keys(y8),bG=Object.keys(lY),RG=Object.keys(m8),vG=Object.keys(p8),c8=["dateStyle"],wG=EG.concat(c8),kG=bG.concat(c8),l8=RG.concat(c8,["weekday"]),G3=vG.concat(["dayPeriod","timeStyle"]),d8=l8.concat(G3),qG=d8.concat(WZ),gG=WZ.concat(G3),yG=WZ.concat(l8),mG=WZ.concat(["day","weekday"],G3),pG=WZ.concat(["year","weekday"],G3),hG={},i8=[K$(d8,h8),GO],dY=[K$(qG,AG),GO,0,($,Z)=>{let O=G0($.timeZone);if(Z&&G0(Z.timeZone)!==O)throw RangeError(DY);return O}],u8=[K$(d8,h8,WZ),N0],s8=[K$(l8,m8,gG),N0],n8=[K$(G3,p8,yG),($)=>k1($)/O1],a8=[K$(wG,y8,mG),N0,1],o8=[K$(kG,lY,pG),N0,1],SJ;function W1($,Z,O,j,J){function W(...X){if(!(this instanceof W))throw TypeError(N8);nY(this,Z(...X))}function z(X,G){return Object.defineProperties(function(...F){return X.call(this,Y(this),...F)},tj(G))}function Y(X){let G=Q0(X);if(!G||G.branding!==$)throw TypeError(N8);return G}return Object.defineProperties(W.prototype,{...HJ(i0(z,O)),...J$(i0(z,j)),...r3("Temporal."+$)}),Object.defineProperties(W,{...J$(J),...tj($)}),[W,(X)=>{let G=Object.create(W.prototype);return nY(G,X),G},Y]}function rY($){return $=$.concat("id").sort(),(Z)=>{if(!xJ(Z,$))throw TypeError(BY);return Z}}function GZ($){if(Q0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(TY);return $}function hO($,Z){let O={};for(let j in $)O[j]=({o:J},W)=>{let z=Q0(W)||{},{branding:Y}=z,X=Y===Q$||Z.includes(Y)?z:S0(W);return J[j](X)};return O}function e8($){let Z={};for(let O in $)Z[O]=(j)=>{let{calendar:J}=j;return(W=J,typeof W=="string"?JZ(W):(z=W,Object.assign(Object.create(jF),{i:z})))[O](j);var W,z};return Z}function u1(){throw TypeError(UY)}function T3({calendar:$}){return typeof $=="string"?new X2($):$}function iY($,Z){if(Z=e(Z),z0($)){let j=Q0($);if(j&&j.branding===jZ)return g(Z),j;let J=$9($);return T8(nO(J||q),!J,$,Z)}let O=gW(JZ,$);return g(Z),O}function tY($,Z,O){return j=Z.call($,P0(Y0(O))),R6(rZ(j));var j}function cO($,Z=J9){let O=Object.keys(Z).sort(),j={};for(let J of O)j[J]=w(Z[J],$,EY($[J]));return j}function c($,Z){return typeof $=="string"?mO($):cO($,Z)}function j0($){return c($,t8)}function j1($){if(z0($)){let Z=Q0($);if(Z)switch(Z.branding){case gO:return Z;case I1:return Y0(Z.epochNanoseconds)}}return RW($)}function uY($,Z,O){let j=Z.l(j1(O).epochNanoseconds,$);return j?P0(Y0(j)):null}function d($){return z0($)?(Q0($)||{}).timeZone||GF($):((Z)=>LO(hW(n(Z))))($)}function c1($,Z){if(z0($)){let O=Q0($)||{};switch(O.branding){case qO:return g(Z),O;case B$:return g(Z),n0(O);case I1:return g(Z),V8(j0,O)}return Iz($,Z)}return g(Z),yW($)}function $2($){return $===void 0?void 0:c1($)}function zZ($,Z){if(Z=e(Z),z0($)){let j=Q0($);return j&&j.branding===OZ?(g(Z),j):F8(uO(K3($)),$,Z)}let O=qW(JZ,$);return g(Z),O}function l1($,Z){if(Z=e(Z),z0($)){let j=Q0($)||{};switch(j.branding){case B$:return g(Z),j;case Q$:return g(Z),$0({...j,...d0});case I1:return g(Z),B8(j0,j)}return Mz(sO(K3($)),$,Z)}let O=kW($);return g(Z),O}function S0($,Z){if(Z=e(Z),z0($)){let j=Q0($)||{};switch(j.branding){case Q$:return g(Z),j;case B$:return g(Z),Z0(j);case I1:return g(Z),D8(j0,j)}return G8(sO(K3($)),$,Z)}let O=IO($);return g(Z),O}function eY($,Z,O){return u0(Z.call($,o(Z0(O,$))))}function z1($){return(Z)=>typeof Z=="string"?JZ(Z):((O,j)=>{let J=Object.keys(j).sort(),W={};for(let z of J)W[z]=w(j[z],O,O[z]);return W})(Z,$)}function a($){if(z0($)){let Z=Q0($);return Z&&Z.branding===yO?Z:Nz($)}return mW($)}function F3($){if($!==void 0){if(z0($)){let Z=Q0($)||{};switch(Z.branding){case I1:case Q$:return Z;case B$:return Z0(Z)}let O=K3($);return{...Vz(d,c,sO(O),$),calendar:O}}return vW($)}}function K3($){return $9($)||q}function $9($){let{calendar:Z}=$;if(Z!==void 0)return U0(Z)}function U0($){return z0($)?(Q0($)||{}).calendar||PF($):((Z)=>$3(pW(n(Z))))($)}function YZ($,Z){if(Z=e(Z),z0($)){let O=Q0($);if(O&&O.branding===I1)return tZ(Z),O;let j=K3($);return Cz(d,c,sO(j),j,$,Z)}return wW($,Z)}function sY($){return i0((Z)=>(O)=>Z(r8(O)),$)}function r8($){return L0($,j0)}function cG(){let $=h1.prototype,Z=Object.getOwnPropertyDescriptors($),O=Object.getOwnPropertyDescriptors(h1),j=function(J,W={}){if(!(this instanceof j))return new j(J,W);G2.set(this,((z,Y={})=>{let X=new h1(z,Y),G=X.resolvedOptions(),F=G.locale,K=w0(Object.keys(Y),G),T=R0(iG),U=(...Q)=>{let B,D=Q.map((C,L)=>{let M=Q0(C),P=(M||{}).branding;if(L&&B&&B!==P)throw TypeError(CY);return B=P,M});return B?T(B)(F,K,...D):[X,...Q]};return U.u=X,U})(J,W))};for(let J in Z){let W=Z[J],z=J.startsWith("format")&&lG(J);typeof W.value=="function"?W.value=J==="constructor"?j:z||dG(J):z&&(W.get=function(){return z.bind(this)})}return O.prototype.value=Object.create($,Z),Object.defineProperties(j,O),j}function lG($){return function(...Z){let O=G2.get(this),[j,...J]=O(...Z);return j[$](...J)}}function dG($){return function(...Z){return G2.get(this).u[$](...Z)}}function iG($){let Z=uG[$];if(!Z)throw TypeError(VY($));return V1(Z,R0(C8))}var uG={Instant:i8,PlainDateTime:u8,PlainDate:s8,PlainTime:n8,PlainYearMonth:a8,PlainMonthDay:o8},sG=V1(i8),nG=V1(dY),aG=V1(u8),oG=V1(s8),rG=V1(n8),tG=V1(a8),eG=V1(o8),Z2={era:kJ,eraYear:O6,year:rZ,month:u0,daysInMonth:u0,daysInYear:u0,inLeapYear:AY,monthsInYear:u0},dO={monthCode:n},O2={day:u0},Z9={dayOfWeek:u0,dayOfYear:u0,weekOfYear:qJ,yearOfWeek:O6,daysInWeek:u0},O9=Object.assign({},Z2,dO,O2,Z9),lO=new WeakMap,Q0=lO.get.bind(lO),nY=lO.set.bind(lO),$F={...hO(Z2,[OZ]),...hO(Z9,[]),...hO(dO,[OZ,jZ]),...hO(O2,[jZ])},j2=e8(O9),ZF=e8({...Z2,...dO}),OF=e8({...dO,...O2}),U3={calendarId:($)=>G0($.calendar)},jF=i0(($,Z)=>function(O){let{i:j}=this;return $(j[Z](o(Z0(O,j))))},O9),JF=aZ(($)=>(Z)=>Z[$],y.concat("sign")),J2=aZ(($,Z)=>(O)=>O[o0[Z]],M1),j9={epochSeconds:JW,epochMilliseconds:GO,epochMicroseconds:WW,epochNanoseconds:zW},Q3=w(ej,new Set(["branding"])),[WF,XZ,zF]=W1(jZ,w(kz,U0),{...U3,...OF},{getISOFields:Q3,getCalendar:T3,with($,Z,O){return XZ(fz(NF,$,this,GZ(Z),O))},equals:($,Z)=>Zz($,iY(Z)),toPlainDate($,Z){return o(az(B3,$,this,Z))},toLocaleString($,Z,O){let[j,J]=eG(Z,O,$);return j.format(J)},toString:H6,toJSON:($)=>H6($),valueOf:u1},{from:($,Z)=>XZ(iY($,Z))}),J9={getOffsetNanosecondsFor:tY,getPossibleInstantsFor($,Z,O){let j=[...Z.call($,K0($0(O,q)))].map((W)=>XF(W).epochNanoseconds),J=j.length;return J>1&&(j.sort(I0),v6(y0(g0(j[0],j[J-1])))),j}},t8={getOffsetNanosecondsFor:tY},[YF,P0,XF]=W1(gO,Ez,j9,{add:($,Z)=>P0(w6(0,$,a(Z))),subtract:($,Z)=>P0(w6(1,$,a(Z))),until:($,Z,O)=>l(Z8(0,$,j1(Z),O)),since:($,Z,O)=>l(Z8(1,$,j1(Z),O)),round:($,Z)=>P0(GW($,Z)),equals:($,Z)=>oW($,j1(Z)),toZonedDateTime($,Z){let O=B1(Z);return O0(Q8($,d(O.timeZone),U0(O.calendar)))},toZonedDateTimeISO:($,Z)=>O0(Q8($,d(Z))),toLocaleString($,Z,O){let[j,J]=sG(Z,O,$);return j.format(J)},toString:($,Z)=>L6(d,j0,$,Z),toJSON:($)=>L6(d,j0,$),valueOf:u1},{from:($)=>P0(j1($)),fromEpochSeconds:($)=>P0(tz($)),fromEpochMilliseconds:($)=>P0(ez($)),fromEpochMicroseconds:($)=>P0($Y($)),fromEpochNanoseconds:($)=>P0(ZY($)),compare:($,Z)=>t6(j1($),j1(Z))}),[iO,MQ]=W1("TimeZone",($)=>{let Z=nW($);return{branding:"TimeZone",id:Z,o:mO(Z)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},Z)=>$.getPossibleInstantsFor(l1(Z)).map((O)=>P0(Y0(O))),getOffsetNanosecondsFor:({o:$},Z)=>$.getOffsetNanosecondsFor(j1(Z).epochNanoseconds),getOffsetStringFor($,Z){let O=j1(Z).epochNanoseconds,j=cO(this,t8).getOffsetNanosecondsFor(O);return Y$(j)},getPlainDateTimeFor($,Z,O=q){let j=j1(Z).epochNanoseconds,J=cO(this,t8).getOffsetNanosecondsFor(j);return K0($0(g1(j,J),U0(O)))},getInstantFor($,Z,O){let j=l1(Z),J=K6(O),W=cO(this);return P0(Y0(v0(W,j,J)))},getNextTransition:({o:$},Z)=>uY(1,$,Z),getPreviousTransition:({o:$},Z)=>uY(-1,$,Z),equals($,Z){return!!PO(this,d(Z))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let Z=d($);return typeof Z=="string"?new iO(Z):Z}}),GF=rY(Object.keys(J9)),[FF,d1]=W1(qO,qz,J2,{getISOFields:Q3,with($,Z,O){return d1(Hz(this,GZ(Z),O))},add:($,Z)=>d1(m6(0,$,a(Z))),subtract:($,Z)=>d1(m6(1,$,a(Z))),until:($,Z,O)=>l(z8(0,$,c1(Z),O)),since:($,Z,O)=>l(z8(1,$,c1(Z),O)),round:($,Z)=>d1(KW($,Z)),equals:($,Z)=>Oz($,c1(Z)),toZonedDateTime:($,Z)=>O0(oz(d,S0,c,$,Z)),toPlainDateTime:($,Z)=>K0(rz($,S0(Z))),toLocaleString($,Z,O){let[j,J]=rG(Z,O,$);return j.format(J)},toString:x6,toJSON:($)=>x6($),valueOf:u1},{from:($,Z)=>d1(c1($,Z)),compare:($,Z)=>_O(c1($),c1(Z))}),[TF,i1,KF]=W1(OZ,w(wz,U0),{...U3,...ZF},{getISOFields:Q3,getCalendar:T3,with($,Z,O){return i1(Sz(IF,$,this,GZ(Z),O))},add:($,Z,O)=>i1(y6(aY,0,$,a(Z),O)),subtract:($,Z,O)=>i1(y6(aY,1,$,a(Z),O)),until:($,Z,O)=>l(W8(oY,0,$,zZ(Z),O)),since:($,Z,O)=>l(W8(oY,1,$,zZ(Z),O)),equals:($,Z)=>$z($,zZ(Z)),toPlainDate($,Z){return o(nz(B3,$,this,Z))},toLocaleString($,Z,O){let[j,J]=tG(Z,O,$);return j.format(J)},toString:f6,toJSON:($)=>f6($),valueOf:u1},{from:($,Z)=>i1(zZ($,Z)),compare:($,Z)=>F$(zZ($),zZ(Z))}),[UF,K0]=W1(B$,w(Rz,U0),{...U3,...j2,...J2},{getISOFields:Q3,getCalendar:T3,with($,Z,O){return K0(_z(B3,$,this,GZ(Z),O))},withCalendar:($,Z)=>K0(xO($,U0(Z))),withPlainDate:($,Z)=>K0(WY($,S0(Z))),withPlainTime:($,Z)=>K0(JY($,$2(Z))),add:($,Z,O)=>K0(q6(V$,0,$,a(Z),O)),subtract:($,Z,O)=>K0(q6(V$,1,$,a(Z),O)),until:($,Z,O)=>l(j8(J1,0,$,l1(Z),O)),since:($,Z,O)=>l(j8(J1,1,$,l1(Z),O)),round:($,Z)=>K0(TW($,Z)),equals:($,Z)=>tW($,l1(Z)),toZonedDateTime:($,Z,O)=>O0(hz(c,$,d(Z),O)),toPlainDate:($)=>o(Z0($)),toPlainTime:($)=>d1(n0($)),toPlainYearMonth($){return i1(cz(uO,$,this))},toPlainMonthDay($){return XZ(lz(nO,$,this))},toLocaleString($,Z,O){let[j,J]=aG(Z,O,$);return j.format(J)},toString:P6,toJSON:($)=>P6($),valueOf:u1},{from:($,Z)=>K0(l1($,Z)),compare:($,Z)=>$8(l1($),l1(Z))}),[QF,o,W9]=W1(Q$,w(vz,U0),{...U3,...j2},{getISOFields:Q3,getCalendar:T3,with($,Z,O){return o(Pz(B3,$,this,GZ(Z),O))},withCalendar:($,Z)=>o(xO($,U0(Z))),add:($,Z,O)=>o(g6(V$,0,$,a(Z),O)),subtract:($,Z,O)=>o(g6(V$,1,$,a(Z),O)),until:($,Z,O)=>l(J8(J1,0,$,S0(Z),O)),since:($,Z,O)=>l(J8(J1,1,$,S0(Z),O)),equals:($,Z)=>eW($,S0(Z)),toZonedDateTime($,Z){let O=!z0(Z)||Z instanceof iO?{timeZone:Z}:Z;return O0(dz(d,c1,c,$,O))},toPlainDateTime:($,Z)=>K0(iz($,$2(Z))),toPlainYearMonth($){return i1(uz(uO,$,this))},toPlainMonthDay($){return XZ(sz(nO,$,this))},toLocaleString($,Z,O){let[j,J]=oG(Z,O,$);return j.format(J)},toString:S6,toJSON:($)=>S6($),valueOf:u1},{from:($,Z)=>o(S0($,Z)),compare:($,Z)=>F$(S0($),S0(Z))}),W2={fields($,Z,O){return[...Z.call($,O)]}},z9=Object.assign({dateFromFields($,Z,O,j){return W9(Z.call($,Object.assign(Object.create(null),O),j))}},W2),Y9=Object.assign({yearMonthFromFields($,Z,O,j){return KF(Z.call($,Object.assign(Object.create(null),O),j))}},W2),X9=Object.assign({monthDayFromFields($,Z,O,j){return zF(Z.call($,Object.assign(Object.create(null),O),j))}},W2),z2={mergeFields($,Z,O,j){return B1(Z.call($,Object.assign(Object.create(null),O),Object.assign(Object.create(null),j)))}},BF=Object.assign({},z9,z2),DF=Object.assign({},Y9,z2),VF=Object.assign({},X9,z2),Y2={dateAdd($,Z,O,j,J){return W9(Z.call($,o(Z0(O,$)),l(i(j)),J))}},G9=Object.assign({},Y2,{dateUntil($,Z,O,j,J,W){return _F(Z.call($,o(Z0(O,$)),o(Z0(j,$)),Object.assign(Object.create(null),W,{largestUnit:W3[J]})))}}),CF=Object.assign({},Y2,{day:eY}),MF=Object.assign({},G9,{day:eY}),uO=z1(Y9),sO=z1(z9),nO=z1(X9),IF=z1(DF),B3=z1(BF),NF=z1(VF),V$=z1(Y2),J1=z1(G9),aY=z1(CF),oY=z1(MF),[LF,l,_F]=W1(yO,gz,{...JF,blank:AW},{with:($,Z)=>l(xz($,Z)),negated:($)=>l(CO($)),abs:($)=>l(xW($)),add:($,Z,O)=>l(d6(F3,J1,c,0,$,a(Z),O)),subtract:($,Z,O)=>l(d6(F3,J1,c,1,$,a(Z),O)),round:($,Z)=>l(HW(F3,J1,c,$,Z)),total:($,Z)=>XW(F3,J1,c,$,Z),toLocaleString($,Z,O){return Intl.DurationFormat?new Intl.DurationFormat(Z,O).format(this):UO($)},toString:UO,toJSON:($)=>UO($),valueOf:u1},{from:($)=>l(a($)),compare:($,Z,O)=>aW(F3,V$,c,a($),a(Z),O)}),F9={toString:($)=>$.id,toJSON:($)=>$.id,...$F,dateAdd:({id:$,o:Z},O,j,J)=>o(Z0(Z.dateAdd(S0(O),a(j),J),$)),dateUntil:({o:$},Z,O,j)=>l(i($.dateUntil(S0(Z),S0(O),eJ(j)))),dateFromFields:({id:$,o:Z},O,j)=>o(G8(Z,O,j,wJ($))),yearMonthFromFields:({id:$,o:Z},O,j)=>i1(F8(Z,O,j,RJ($))),monthDayFromFields:({id:$,o:Z},O,j)=>XZ(T8(Z,0,O,j,vJ($))),fields({o:$},Z){let O=new Set(a0),j=[];for(let J of Z){if(n(J),!O.has(J))throw RangeError(I8(J));O.delete(J),j.push(J)}return $.fields(j)},mergeFields:({o:$},Z,O)=>$.mergeFields($6(j6(Z)),$6(j6(O)))},[X2]=W1("Calendar",($)=>{let Z=Fz($);return{branding:"Calendar",id:Z,o:JZ(Z)}},{id:($)=>$.id},F9,{from($){let Z=U0($);return typeof Z=="string"?new X2(Z):Z}}),PF=rY(Object.keys(F9).slice(4)),[SF,O0]=W1(I1,w(bz,U0,d),{...j9,...U3,...sY(j2),...sY(J2),offset:($)=>Y$(r8($).offsetNanoseconds),offsetNanoseconds:($)=>r8($).offsetNanoseconds,timeZoneId:($)=>G0($.timeZone),hoursInDay:($)=>UW(c,$)},{getISOFields:($)=>SW(j0,$),getCalendar:T3,getTimeZone:({timeZone:$})=>typeof $=="string"?new iO($):$,with($,Z,O){return O0(Lz(B3,c,$,this,GZ(Z),O))},withCalendar:($,Z)=>O0(xO($,U0(Z))),withTimeZone:($,Z)=>O0(zY($,d(Z))),withPlainDate:($,Z)=>O0(jY(c,$,S0(Z))),withPlainTime:($,Z)=>O0(OY(c,$,$2(Z))),add:($,Z,O)=>O0(k6(V$,c,0,$,a(Z),O)),subtract:($,Z,O)=>O0(k6(V$,c,1,$,a(Z),O)),until:($,Z,O)=>l(i(O8(J1,c,0,$,YZ(Z),O))),since:($,Z,O)=>l(i(O8(J1,c,1,$,YZ(Z),O))),round:($,Z)=>O0(FW(c,$,Z)),startOfDay:($)=>O0(QW(c,$)),equals:($,Z)=>rW($,YZ(Z)),toInstant:($)=>P0(yz($)),toPlainDateTime:($)=>K0(B8(j0,$)),toPlainDate:($)=>o(D8(j0,$)),toPlainTime:($)=>d1(V8(j0,$)),toPlainYearMonth($){return i1(mz(uO,$,this))},toPlainMonthDay($){return XZ(pz(nO,$,this))},toLocaleString($,Z,O={}){let[j,J]=nG(Z,O,$);return j.format(J)},toString:($,Z)=>_6(j0,$,Z),toJSON:($)=>_6(j0,$),valueOf:u1},{from:($,Z)=>O0(YZ($,Z)),compare:($,Z)=>e6(YZ($),YZ(Z))}),fF=Object.defineProperties({},{...r3("Temporal.Now"),...J$({timeZoneId:()=>C1(),instant:()=>P0(Y0(O3())),zonedDateTime:($,Z=C1())=>O0(T0(O3(),d(Z),U0($))),zonedDateTimeISO:($=C1())=>O0(T0(O3(),d($),q)),plainDateTime:($,Z=C1())=>K0($0($Z(j0(d(Z))),U0($))),plainDateTimeISO:($=C1())=>K0($0($Z(j0(d($))),q)),plainDate:($,Z=C1())=>o(Z0($Z(j0(d(Z))),U0($))),plainDateISO:($=C1())=>o(Z0($Z(j0(d($))),q)),plainTimeISO:($=C1())=>d1(n0($Z(j0(d($)))))})}),FZ=Object.defineProperties({},{...r3("Temporal"),...J$({PlainYearMonth:TF,PlainMonthDay:WF,PlainDate:QF,PlainTime:FF,PlainDateTime:UF,ZonedDateTime:SF,Instant:YF,Calendar:X2,TimeZone:iO,Duration:LF,Now:fF})}),HF=cG(),G2=new WeakMap,xF=Object.defineProperties(Object.create(Intl),J$({DateTimeFormat:HF}));var F2=new WeakMap;function EF($){let Z=F2.get($);if(!Z)Z=$(AF(32).toString("hex")),F2.set($,Z),Z.catch(()=>F2.delete($));return Z}async function T2($,Z,O){if(typeof O==="string"&&O!=="")return await $.verifyPassword(Z,O);try{await $.verifyPassword(Z,await EF($.hashPassword))}catch{}return!1}async function C$($,Z){let O=Z.user??Z.session?.user;if(!O||!$.onAuthenticated)return;let{password:j,...J}=O;await $.onAuthenticated({...Z,user:J})}class Q2 extends Error{}function K2($){return typeof $==="string"&&$!==""?$:null}function T9($){return gZ($)}var bF=256;function K9($){return typeof $==="string"&&$!==""&&$.length<=bF?$:null}var U2="intended_url";class B2 extends A{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class U9 extends A{schema={email:{required:"Email is required",email:"Invalid email"}}}class Q9 extends A{schema={password:{required:"Password is required",password:"Invalid password"}}}class u extends fj{async me(){let $=await M$.user();if(!$)throw new Hj;return $}async verifyEmail($=new A){let Z=await $.input(),{userProvider:O}=I(E),j=K2(Z.get("token"));if(!j)return{email:null};let J=await O.findUserByVerificationToken(j);if(!J)return{email:null};return await O.verifyUser(J.email),{email:J.email}}async signInWithMagicLink($=new A){let Z=I(E),{userProvider:O}=Z,j=K2($.search.get("token")),J=null;try{J=gZ(decodeURIComponent($.search.get("email")??""))}catch{}if(await m$("link",null,$,{perIp:Z.config.emailCode.verifyLimit.perIp}),!J||!j||!await Z.verifyMagicLinkToken(J,j))return{error:"Invalid token"};await O.verifyUser(J);let W=await Z.createOrUpdateSession({email:J});return $.ctx().setCookie("access_token",W.token,I(E).accessTokenCookieOptions($,W.expiresAt)),await Z.config.onSignIn(W,$.search.toJSON()),await C$(Z.config,{session:W,isNewUser:!1,method:"magic-link",req:$}),{session:W}}async verifyPinRequest($){let Z=I(E),O=await $.input(),{email:j,pin:J}=O.toJSON(),W=gZ(j),z=K9(J);if(await m$("verify",W,$,Z.config.emailCode.verifyLimit),!W||!z)throw new p({pin:["Invalid pin"]});let Y=await Z.verifyOneTimeCode(W,z);if(Y.status==="too_many_attempts")throw new p({pin:["Too many attempts"]});if(Y.status!=="ok")throw new p({pin:["Invalid pin"]});return await Z.userProvider.verifyUser(W),W}async signInWithPinV2($=new A){let Z=I(E),O=await this.verifyPinRequest($),j=await Z.createOrUpdateSessionV2({email:O});return $.ctx().setCookie("access_token",j.token,I(E).accessTokenCookieOptions($,j.expiresAt)),await Z.config.onSignIn(j,$.search.toJSON()),await C$(Z.config,{session:j,isNewUser:!1,method:"magic-link",req:$}),j}async signInWithPin($=new A){let Z=I(E),O=await this.verifyPinRequest($),j=await Z.createOrUpdateSession({email:O});return $.ctx().setCookie("access_token",j.token,I(E).accessTokenCookieOptions($,j.expiresAt)),await Z.config.onSignIn(j,$.search.toJSON()),await C$(Z.config,{session:j,isNewUser:!1,method:"magic-link",req:$}),{session:j}}async signInV2($=new B2){let Z=await $.input(),{email:O,password:j}=Z.toJSON(),J=O.toLowerCase().trim(),W=I(E),z=await W.userProvider.findUserByEmailAddress(J,W.config.verifyEmail),Y=typeof j==="string"&&await T2(W.config,j,z?.password);if(!z||!Y)throw new p({invalid_credentials:["Invalid credentials"]});let X=await W.createOrUpdateSessionV2({email:z.email,id:z.id});$.ctx().setCookie("access_token",X.token,I(E).accessTokenCookieOptions($,X.expiresAt)),await W.config.onSignIn(z,$.search.toJSON()),await C$(W.config,{session:X,user:z,isNewUser:!1,method:"password",req:$});let{password:G,...F}=z;return F}async signIn($=new B2){let Z=await $.input(),{email:O,password:j}=Z.toJSON(),J=O.toLowerCase().trim(),W=I(E),z=await W.userProvider.findUserByEmailAddress(J,W.config.verifyEmail),Y=typeof j==="string"&&await T2(W.config,j,z?.password);if(!z||!Y)throw new p({invalid_credentials:["Invalid credentials"]});let X=await W.createOrUpdateSession({email:z.email,id:z.id});$.ctx().setCookie("access_token",X.token,I(E).accessTokenCookieOptions($,X.expiresAt)),await W.config.onSignIn(z,$.search.toJSON()),await C$(W.config,{session:X,user:z,isNewUser:!1,method:"password",req:$});let{password:G,...F}=z;return F}async signUp(){let $=I(E),{userProvider:Z,config:O}=$,j=new O.signUpRequest,J=await j.input(),{email:W,password:z,name:Y,invitationId:X}=J.toJSON(),G=T9(W);if(!G)throw new p({email:["Invalid email"]});if(z!=null&&typeof z!=="string")throw new p({password:["Invalid password"]});if(X!=null&&typeof X!=="string")throw new p({invitationId:["Invalid invitation"]});if(await Z.findUserByEmailAddress(G,!1))throw new p({email:["Email address already exists"]});let K=await O.hashPassword(z),T=I(s).detectLocale(j),U;if(X)U=await Z.findInvitation(X,G);let Q,B="";if(U)Q=await Z.transaction(async()=>{await Z.deleteInvitationById(X);let D=await Z.createUser({email:G,name:Y,password:K,emailVerifiedAt:new Date,locale:T});return await Z.createAccount({organizationId:U.organizationId,userId:D.id,organizationRole:U.role}),await O.onUserCreated(D),D});else B=await O.generateEmailVerificationToken(G),Q=await Z.transaction(async()=>{let D=await Z.createUser({email:G,name:Y,password:K,verificationToken:B,locale:T});return await O.onUserCreated(D),D});return await O.onSignUp(Q,B,j.search.toJSON()),Q}async signOut($=new A){let Z=Pj($),O=I(E),{config:j}=O,J=await O.revokeSession(Z,$.headers.get("User-Agent"));if($.ctx().setCookie("access_token","",I(E).accessTokenCookieOptions($,new Date(0))),I(E).cookieDomain($))$.ctx().setCookie("access_token","",{...I(E).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(J?.user)J.user.extension=await j.extendSession(J.user),await j.onSignOut(J.user);return{}}async forgotPassword($=new U9){let Z=await $.input(),O=T9(Z.get("email"));if(!O)return{};let{userProvider:j,config:J}=I(E),W=await j.findUserByEmailAddress(O,J.verifyEmail);if(!W)return{};let z=await J.generateForgotPasswordToken(W);return await j.createPasswordResetToken({user:W,token:z}),await J.onForgotPassword(W,z),{}}async resetPassword($=new Q9){let{userProvider:Z,config:O}=I(E),j=await $.input(),{password:J,token:W}=j.toJSON(),z=K2(W),Y=z?await Z.findPasswordResetToken({token:z}):null;if(!Y)throw new p({token:["Invalid token"]});if(FZ.Instant.from(Y.createdAt.toISOString()).add({hours:24}).until(FZ.Now.instant()).sign>=0)throw new p({token:["Token expired"]});await Z.deletePasswordResetToken({token:z});let G=await Z.findUserByEmailAddress(Y.user.email,O.verifyEmail);if(!G)throw new p({email:["User not found"]});let F=await O.hashPassword(J);return await Z.updateUserPassword({id:G.id,password:F}),await Z.deleteAllUserSessions(G.id),await O.onResetPassword(G),{}}async changePassword($=new A){let{userProvider:Z,config:O}=I(E),j=await M$.user(),J=await $.input(),{oldPassword:W,newPassword:z}=J.toJSON();if(typeof z!=="string")throw new p({newPassword:["Invalid password"]});let Y=await Z.findUserByEmailAddress(j.email,O.verifyEmail);if(!(typeof W==="string"&&await T2(O,W,Y?.password)))throw new p({oldPassword:["Incorrect password"]});let G=await O.hashPassword(z);return await Z.updateUserPassword({id:j.id,password:G}),await Z.deleteAllUserSessions(j.id),{}}async oauthRedirect($=new A){let{provider:Z}=$.params,O=I(E).config.oauthProviders[Z];if(!O)throw Error(`Invalid provider: ${Z}`);let j=xZ($.search.get(E$),"");if(j)$.ctx().setCookie(U2,encodeURIComponent(j),{httpOnly:!0,sameSite:"Lax",secure:A4($.rawRequest),maxAge:600});return{destination:await O.getRedirectUrl($)}}async oauthCallback($=new A){let{provider:Z}=$.params,O=I(E),{userProvider:j,config:J}=O,W=J.oauthProviders[Z],{email:z,name:Y,username:X,providerId:G}=await W.onCallback($),F=G?await j.findUserBySocialAccount(Z,G):null,K="signin";if(!F){if(!z)return console.error("Authentication error: No email returned from OAuth provider callback"),{session:null};let B=I(s).detectLocale($);try{let D=await this.linkOAuthAccount({provider:Z,providerId:G,email:z,name:Y,username:X,locale:B});if(D)F=D.user,K=D.action}catch(D){let C=G?await j.findUserBySocialAccount(Z,G):null;if(!C)throw D;F=C}if(!F)return{session:null}}let T=await O.createOrUpdateSessionV2({email:F.email,id:F.id});if($.ctx().setCookie("access_token",T.token,I(E).accessTokenCookieOptions($,T.expiresAt)),K==="signup")await J.onSignUp(F,"",$.search.toJSON());else await J.onSignIn(F,$.search.toJSON());await C$(O.config,{session:T,user:F,isNewUser:K==="signup",method:"oauth",req:$});let U=$.cookies.get(U2),Q=J.redirectPath;if(U){try{Q=xZ(decodeURIComponent(U),Q)}catch{}$.ctx().setCookie(U2,"",{maxAge:-1})}return{session:T,redirectTo:Q}}async linkOAuthAccount($){let{provider:Z,providerId:O,email:j,name:J,username:W,locale:z}=$,{userProvider:Y,config:X}=I(E),G=(T)=>({provider:Z,userId:T,email:j,username:W,providerId:O,expiresAt:new Date,accessToken:"",refreshToken:""}),F=await Y.findUserByEmailAddress(j,!1);if(F){if(!O)return{user:F,action:"signin"};let T=await Y.findSocialAccounts(F.id,Z);if(T.some((Q)=>Q.providerId===O))return{user:F,action:"signin"};if(T.some((Q)=>Q.providerId))return console.error(`Authentication error: user ${F.id} is already linked to a different ${Z} account`),null;let U=T[0];if(U){if(!await Y.claimSocialAccount(U,O))throw Error(`${Z} account link changed concurrently`)}else await Y.createSocialAccount(G(F.id));return{user:F,action:"signin"}}return{user:await Y.transaction(async()=>{let T=await Y.createUser({email:j,name:J,locale:z,emailVerifiedAt:new Date});if(O)await Y.createSocialAccount(G(T.id));return await X.onUserCreated(T),T}),action:"signup"}}async createMagicLinkToken($=new A){let Z=await $.input(),O=gZ(Z.get("email")),j=I(E),{uniformMagicLinkResponse:J,requestLimit:W}=j.config.emailCode;if(await m$("request",O,$,W),!O)return{email:null};let{user:z,pin:Y,token:X}=await j.createMagicLinkToken(O);if(z)return await j.config.onMagicLinkCreated(z,{email:O,pin:Y,token:X}),{email:O};return{email:J?O:null}}async requestEmailCode($=new A){let Z=I(E),O=Z.config.emailCode;if(!O.enabled)throw new q0("Not found",{status:404});let j=await $.input(),J=wj(j.get("email"));if(await m$("request",J,$,O.requestLimit),!J)throw new p({email:["Invalid email"]});let W=await Z.userProvider.findUserByEmailAddress(J,!1);if(W||O.createUser){let{pin:z,token:Y}=await Z.issueOneTimeCode(J,O.length);await O.send({email:J,code:z,token:Y,isNewUser:!W,req:$})}return{ok:!0}}async verifyEmailCode($=new A){let Z=I(E),{userProvider:O,config:j}=Z;if(!j.emailCode.enabled)throw new q0("Not found",{status:404});let J=await $.input(),{email:W,code:z,name:Y}=J.toJSON(),X=wj(W),G=K9(z);if(await m$("verify",X,$,j.emailCode.verifyLimit),!X||!G)throw new p({code:["invalid_code"]});let F=await Z.verifyOneTimeCode(X,G,{claim:!1});if(F.status==="too_many_attempts")throw new p({code:["too_many_attempts"]});if(F.status!=="ok")throw new p({code:["invalid_code"]});let K=F.row,T=await O.findUserByEmailAddress(X,!1),U=!1;if(T){if(!await O.claimMagicLinkToken(K.id))throw new p({code:["invalid_code"]});await O.verifyUser(X)}else if(j.emailCode.createUser){let B=I(s).detectLocale($);try{T=await O.transaction(async()=>{if(!await O.claimMagicLinkToken(K.id))throw new Q2;let D=await O.createUser({email:X,name:typeof Y==="string"?Y.trim():"",emailVerifiedAt:new Date,locale:B});return await j.onUserCreated(D),D}),U=!0}catch(D){if(D instanceof Q2)throw new p({code:["invalid_code"]});throw D}}else throw await O.claimMagicLinkToken(K.id),new p({code:["invalid_code"]});let Q=await Z.createOrUpdateSessionV2({email:X,id:T.id});return $.ctx().setCookie("access_token",Q.token,I(E).accessTokenCookieOptions($,Q.expiresAt)),await j.onSignIn(Q,$.search.toJSON()),await C$(Z.config,{session:Q,isNewUser:U,method:"email-code",req:$}),{session:Q,isNewUser:U}}}class B9 extends f1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[u,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[u,"oauthCallback"])}}class D2 extends f1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[u,"signInWithMagicLink"]),"/oauth":B9}}class V2 extends x0{middlewares=["cache:private"];routes={"/sign-in":this.post(u,"signIn"),"/sign-in-v2":this.post(u,"signInV2"),"/sign-up":this.post(u,"signUp"),"/sign-out":this.post(u,"signOut"),"/forgot-password":this.post(u,"forgotPassword"),"/reset-password":this.post(u,"resetPassword"),"/change-password":this.post(u,"changePassword"),"/verify-email":this.post(u,"verifyEmail"),"/me":this.get(u,"me").middleware(["auth"]),"/magic-link":this.post(u,"createMagicLinkToken"),"/sign-in-with-pin":this.post(u,"signInWithPin"),"/sign-in-with-pin-v2":this.post(u,"signInWithPinV2"),"/email-code":this.post(u,"requestEmailCode"),"/email-code/verify":this.post(u,"verifyEmailCode")}}class C2 extends x0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let Z=new A().params.locale;return await I(s).onLocaleChange(Z),{locale:Z}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new A,Z=`/${$.params.scope??""}`,O=$.params.locale,j=I(s),J=O??j.detectLocale($),W=j.getPageTranslations(J,Z);return $.ctx().setCookie("i18n-locale",J,{expires:new Date(Date.now()+31536000000)}),{[J]:W}})}}class M2{}class I2 extends M2{async resize($,Z){let{height:O,width:j,quality:J,fit:W}=Z;return await(await aO("The Sharp image optimization driver"))($).resize(j>0?j:void 0,O>0?O:void 0,{fit:W}).webp({quality:J>0?J:80,force:!0}).toBuffer()}}function tQ($){return $}function D9(){return{driver:new I2}}class N2 extends x0{routes={"/resize":this.file(async()=>{let $=new A,Z=new URL($.rawRequest.url),O=Z.searchParams.get("url"),j=Number(Z.searchParams.get("w")),J=Number(Z.searchParams.get("h")),W=Z.searchParams.get("fit")??"cover",z=Number(Z.searchParams.get("q"));if(!O)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let X=`${O.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${O}`,G=await fetch(X);if(!G.ok)return new Response(JSON.stringify({error:"Image not found",info:X}),{headers:{"Content-Type":"application/json"},status:404});let F=Buffer.from(await G.arrayBuffer()),K=await I(V9).resize(F,{height:J,width:j,fit:W,quality:z});G.headers.delete("Content-Type"),G.headers.delete("Content-Length");let T=new Headers(G.headers);return T.set("Content-Type","image/webp"),T.set("Content-Length",`${K.byteLength}`),new Response(new Uint8Array(K),{headers:T})})}}class V9{static token="image";driver;constructor($={}){this.driver=$.driver??D9().driver}resize($,Z){return this.driver.resize($,Z)}}class L2 extends x0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(I(C9).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function RF($){let Z=new Map;for(let O of $)if(typeof O==="string"){let[j,J=""]=O.split(":");if(j.startsWith("-")){if(Z.has(j.replace("-","")))Z.delete(j.replace("-",""))}else Z.set(j,J.split(",").filter(Boolean))}else Z.set(O,[]);return Z}var vF={"body-limit":b3};class TZ{config;static token="middleware";defaultBodyLimit;constructor($){this.config=$;this.defaultBodyLimit=$.bodyLimit===null||$.bodyLimit===void 0?null:HZ($.bodyLimit)}get aliases(){return{...vF,...this.config.aliases}}applyDefaultBodyLimit($){if(this.defaultBodyLimit!==null&&!K4($))H3($,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 A,O=this.aliases;return Array.from(RF($).entries()).map(([j,J])=>{if(typeof j==="string"){let W=O[j];if(W){let z=new W(Z);return()=>z.run.call(z,...J)}}else{if(S3(j)){let W=new j(Z);return W.run.bind(W)}return j}}).filter(Boolean).reduce((j,J)=>{return async()=>{return{...await j(),...await J()}}},()=>Promise.resolve({}))()}}function QB($){return $}function M9(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function I9(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function wF($){return"run"in $}function kF($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"patch")||Object.hasOwn($,"delete")}function qF($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function gF($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function yF($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function N9($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function _2($,Z="",O=[]){let j={};function J(W,z,Y,X,G){let F=W==="/"?"":W,K=Z==="/"?"":Z,T=(`${K}${F}`===""?"/":`${K}${F}`).replaceAll("//","/");if(!j[T])j[T]={};j[T][z.toUpperCase()]={exec:Y,middleware:[...O,...X],...G?{source:G}:{}},j[T].OPTIONS={exec:()=>{let Q=new A().ctx().headers;return new Response(null,{headers:Q,status:204})},middleware:[]}}for(let[W,z]of Object.entries($)){if(yF(z)){let Y=z;for(let X of["GET","POST","PUT","DELETE"])J(W,X,Y.run.bind(Y),Y.middlewares);continue}if(wF(z)){let Y=z,X=Y.method,G=Y.middlewares,F=Y.run.bind(Y);if(J(W,X,F,G,Y.source),N9(z))J(W,"HEAD",F,G,Y.source)}if(kF(z))for(let[Y,X]of Object.entries(z)){let G=X,F=G.middlewares,K=G.run.bind(G);if(J(W,Y,K,F,G.source),Y==="get"&&N9(G))J(W,"HEAD",K,F,G.source)}if(gF(z)){let Y=new z,X=_2(Y.routes,`${Z}${W}`,Y.middlewares);for(let[G,F]of Object.entries(X))j[G.replaceAll("//","/")]=F}if(qF(z)){let{first:Y,second:X}=z;for(let[G,F]of Object.entries(Y)){let K=F.middlewares,T=F.run.bind(F),[U,...Q]=W.split("/").reverse();if(!U.startsWith(":"))throw Error("Resource route must end with a dynamic segment");J(Q.reverse().join("/"),G,T,K,F.source)}for(let[G,F]of Object.entries(X)){let K=F.middlewares,T=F.run.bind(F);J(W,G,T,K,F.source)}}}return Object.fromEntries(Object.entries(j).sort(([W],[z])=>{let Y=W.split("/").length+W.split(":").length,X=z.split("/").length+z.split(":").length;return Y-X}))}function oO($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function P2($,Z){if($==="/")return Z;if(Z==="/")return $;return`${$}${Z}`}function S2($){let Z=oO($);return Z.length>1?Z.replace(/\/$/,""):Z}function L9($,Z){return Z.map((O)=>({...O,path:S2(P2($,O.path))}))}function rO($){let Z={};for(let[O,j]of Object.entries($))if("run"in j){let J=j;if("children"in J){let W=new J.children,z=rO(W.routes);for(let[Y,{exec:X,middleware:G,segments:F,features:K,static:T}]of Object.entries(z)){let U=P2(O,Y),Q=(B)=>J.run.call(J,B,O);Z[oO(U)]={exec:[Q,...X],middleware:[...J.middlewares,...G],features:[...J.featureGates,...K],viewPath:J.viewPath,segments:[{path:S2(O),viewPath:J.viewPath,...J.alwaysRuns?{alwaysRun:!0}:{}},...L9(O,F)],...T?{static:T}:{}}}}else{let W=(z)=>J.run.call(J,z,O);Z[oO(O)]={exec:[W],middleware:J.middlewares,features:J.featureGates,viewPath:J.viewPath,segments:[{path:S2(O),viewPath:J.viewPath}],..."staticOptions"in J&&J.staticOptions?{static:J.staticOptions}:{}}}}else{let J=new j,W=rO(J.routes);for(let[z,{exec:Y,middleware:X,viewPath:G,segments:F,features:K,static:T}]of Object.entries(W)){let U=P2(O,z);Z[oO(U)]={exec:Y,middleware:[...J.middlewares,...X],features:[...J.featureGates,...K],viewPath:G,segments:L9(O,F),...T?{static:T}:{}}}}return Object.fromEntries(Object.entries(Z).sort(([O],[j])=>{let J=O.split("/").length+O.split(":").length,W=j.split("/").length+j.split(":").length;return J-W}))}var mF=Object.defineProperty,S=($,Z)=>mF($,"name",{value:Z,configurable:!0}),QZ=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,Z,O,j,J,W){this.type=$,this.name=Z,this.prefix=O,this.value=j,this.suffix=J,this.modifier=W}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};S(QZ,"Part");var pF=/[$_\p{ID_Start}]/u,hF=/[$_\u200C\u200D\p{ID_Continue}]/u,H2=".*";function _9($,Z){return(Z?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}S(_9,"isASCII");function E2($,Z=!1){let O=[],j=0;for(;j<$.length;){let J=$[j],W=S(function(z){if(!Z)throw TypeError(z);O.push({type:"INVALID_CHAR",index:j,value:$[j++]})},"ErrorOrInvalid");if(J==="*"){O.push({type:"ASTERISK",index:j,value:$[j++]});continue}if(J==="+"||J==="?"){O.push({type:"OTHER_MODIFIER",index:j,value:$[j++]});continue}if(J==="\\"){O.push({type:"ESCAPED_CHAR",index:j++,value:$[j++]});continue}if(J==="{"){O.push({type:"OPEN",index:j,value:$[j++]});continue}if(J==="}"){O.push({type:"CLOSE",index:j,value:$[j++]});continue}if(J===":"){let z="",Y=j+1;for(;Y<$.length;){let X=$.substr(Y,1);if(Y===j+1&&pF.test(X)||Y!==j+1&&hF.test(X)){z+=$[Y++];continue}break}if(!z){W(`Missing parameter name at ${j}`);continue}O.push({type:"NAME",index:j,value:z}),j=Y;continue}if(J==="("){let z=1,Y="",X=j+1,G=!1;if($[X]==="?"){W(`Pattern cannot start with "?" at ${X}`);continue}for(;X<$.length;){if(!_9($[X],!1)){W(`Invalid character '${$[X]}' at ${X}.`),G=!0;break}if($[X]==="\\"){Y+=$[X++]+$[X++];continue}if($[X]===")"){if(z--,z===0){X++;break}}else if($[X]==="("&&(z++,$[X+1]!=="?")){W(`Capturing groups are not allowed at ${X}`),G=!0;break}Y+=$[X++]}if(G)continue;if(z){W(`Unbalanced pattern at ${j}`);continue}if(!Y){W(`Missing pattern at ${j}`);continue}O.push({type:"REGEX",index:j,value:Y}),j=X;continue}O.push({type:"CHAR",index:j,value:$[j++]})}return O.push({type:"END",index:j,value:""}),O}S(E2,"lexer");function b2($,Z={}){let O=E2($);Z.delimiter??="/#?",Z.prefixes??="./";let j=`[^${k0(Z.delimiter)}]+?`,J=[],W=0,z=0,Y="",X=new Set,G=S((M)=>{if(z<O.length&&O[z].type===M)return O[z++].value},"tryConsume"),F=S(()=>G("OTHER_MODIFIER")??G("ASTERISK"),"tryConsumeModifier"),K=S((M)=>{let P=G(M);if(P!==void 0)return P;let{type:f,index:_}=O[z];throw TypeError(`Unexpected ${f} at ${_}, expected ${M}`)},"mustConsume"),T=S(()=>{let M="",P;for(;P=G("CHAR")??G("ESCAPED_CHAR");)M+=P;return M},"consumeText"),U=S((M)=>M,"DefaultEncodePart"),Q=Z.encodePart||U,B="",D=S((M)=>{B+=M},"appendToPendingFixedValue"),C=S(()=>{B.length&&(J.push(new QZ(3,"","",Q(B),"",3)),B="")},"maybeAddPartFromPendingFixedValue"),L=S((M,P,f,_,V)=>{let N=3;switch(V){case"?":N=1;break;case"*":N=0;break;case"+":N=2;break}if(!P&&!f&&N===3){D(M);return}if(C(),!P&&!f){if(!M)return;J.push(new QZ(3,"","",Q(M),"",N));return}let H;f?f==="*"?H=H2:H=f:H=j;let R=2;H===j?(R=1,H=""):H===H2&&(R=0,H="");let m;if(P?m=P:f&&(m=W++),X.has(m))throw TypeError(`Duplicate name '${m}'.`);X.add(m),J.push(new QZ(R,m,Q(M),H,Q(_),N))},"addPart");for(;z<O.length;){let M=G("CHAR"),P=G("NAME"),f=G("REGEX");if(!P&&!f&&(f=G("ASTERISK")),P||f){let V=M??"";Z.prefixes.indexOf(V)===-1&&(D(V),V=""),C();let N=F();L(V,P,f,"",N);continue}let _=M??G("ESCAPED_CHAR");if(_){D(_);continue}if(G("OPEN")){let V=T(),N=G("NAME"),H=G("REGEX");!N&&!H&&(H=G("ASTERISK"));let R=T();K("CLOSE");let m=F();L(V,N,H,R,m);continue}C(),K("END")}return J}S(b2,"parse");function k0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}S(k0,"escapeString");function x2($){return $&&$.ignoreCase?"ui":"u"}S(x2,"flags");function P9($,Z,O){return R2(b2($,O),Z,O)}S(P9,"stringToRegexp");function I$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}S(I$,"modifierToString");function R2($,Z,O={}){O.delimiter??="/#?",O.prefixes??="./",O.sensitive??=!1,O.strict??=!1,O.end??=!0,O.start??=!0,O.endsWith="";let j=O.start?"^":"";for(let Y of $){if(Y.type===3){Y.modifier===3?j+=k0(Y.value):j+=`(?:${k0(Y.value)})${I$(Y.modifier)}`;continue}Z&&Z.push(Y.name);let X=`[^${k0(O.delimiter)}]+?`,G=Y.value;if(Y.type===1?G=X:Y.type===0&&(G=H2),!Y.prefix.length&&!Y.suffix.length){Y.modifier===3||Y.modifier===1?j+=`(${G})${I$(Y.modifier)}`:j+=`((?:${G})${I$(Y.modifier)})`;continue}if(Y.modifier===3||Y.modifier===1){j+=`(?:${k0(Y.prefix)}(${G})${k0(Y.suffix)})`,j+=I$(Y.modifier);continue}j+=`(?:${k0(Y.prefix)}`,j+=`((?:${G})(?:`,j+=k0(Y.suffix),j+=k0(Y.prefix),j+=`(?:${G}))*)${k0(Y.suffix)})`,Y.modifier===0&&(j+="?")}let J=`[${k0(O.endsWith)}]|$`,W=`[${k0(O.delimiter)}]`;if(O.end)return O.strict||(j+=`${W}?`),O.endsWith.length?j+=`(?=${J})`:j+="$",new RegExp(j,x2(O));O.strict||(j+=`(?:${W}(?=${J}))?`);let z=!1;if($.length){let Y=$[$.length-1];Y.type===3&&Y.modifier===3&&(z=O.delimiter.indexOf(Y)>-1)}return z||(j+=`(?=${W}|${J})`),new RegExp(j,x2(O))}S(R2,"partsToRegexp");var n1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},cF={delimiter:".",prefixes:"",sensitive:!0,strict:!0},lF={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function S9($,Z){return $.length?$[0]==="/"?!0:!Z||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}S(S9,"isAbsolutePathname");function v2($,Z){return $.startsWith(Z)?$.substring(Z.length,$.length):$}S(v2,"maybeStripPrefix");function f9($,Z){return $.endsWith(Z)?$.substr(0,$.length-Z.length):$}S(f9,"maybeStripSuffix");function w2($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}S(w2,"treatAsIPv6Hostname");var H9=["ftp","file","http","https","ws","wss"];function k2($){if(!$)return!0;for(let Z of H9)if($.test(Z))return!0;return!1}S(k2,"isSpecialScheme");function x9($,Z){if($=v2($,"#"),Z||$==="")return $;let O=new URL("https://example.com");return O.hash=$,O.hash?O.hash.substring(1,O.hash.length):""}S(x9,"canonicalizeHash");function A9($,Z){if($=v2($,"?"),Z||$==="")return $;let O=new URL("https://example.com");return O.search=$,O.search?O.search.substring(1,O.search.length):""}S(A9,"canonicalizeSearch");function E9($,Z){return Z||$===""?$:w2($)?y2($):g2($)}S(E9,"canonicalizeHostname");function b9($,Z){if(Z||$==="")return $;let O=new URL("https://example.com");return O.password=$,O.password}S(b9,"canonicalizePassword");function R9($,Z){if(Z||$==="")return $;let O=new URL("https://example.com");return O.username=$,O.username}S(R9,"canonicalizeUsername");function v9($,Z,O){if(O||$==="")return $;if(Z&&!H9.includes(Z))return new URL(`${Z}:${$}`).pathname;let j=$[0]=="/";return $=new URL(j?$:"/-"+$,"https://example.com").pathname,j||($=$.substring(2,$.length)),$}S(v9,"canonicalizePathname");function w9($,Z,O){return q2(Z)===$&&($=""),O||$===""?$:m2($)}S(w9,"canonicalizePort");function k9($,Z){return $=f9($,":"),Z||$===""?$:tO($)}S(k9,"canonicalizeProtocol");function q2($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}S(q2,"defaultPortForProtocol");function tO($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}S(tO,"protocolEncodeCallback");function q9($){if($==="")return $;let Z=new URL("https://example.com");return Z.username=$,Z.username}S(q9,"usernameEncodeCallback");function g9($){if($==="")return $;let Z=new URL("https://example.com");return Z.password=$,Z.password}S(g9,"passwordEncodeCallback");function g2($){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(g2,"hostnameEncodeCallback");function y2($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}S(y2,"ipv6HostnameEncodeCallback");function m2($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}S(m2,"portEncodeCallback");function y9($){if($==="")return $;let Z=new URL("https://example.com");return Z.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?Z.pathname.substring(2,Z.pathname.length):Z.pathname}S(y9,"standardURLPathnameEncodeCallback");function m9($){return $===""?$:new URL(`data:${$}`).pathname}S(m9,"pathURLPathnameEncodeCallback");function p9($){if($==="")return $;let Z=new URL("https://example.com");return Z.search=$,Z.search.substring(1,Z.search.length)}S(p9,"searchEncodeCallback");function h9($){if($==="")return $;let Z=new URL("https://example.com");return Z.hash=$,Z.hash.substring(1,Z.hash.length)}S(h9,"hashEncodeCallback");var c9=class{#J;#Z=[];#O={};#$=0;#W=1;#G=0;#Y=0;#U=0;#Q=0;#B=!1;constructor($){this.#J=$}get result(){return this.#O}parse(){for(this.#Z=E2(this.#J,!0);this.#$<this.#Z.length;this.#$+=this.#W){if(this.#W=1,this.#Z[this.#$].type==="END"){if(this.#Y===0){this.#M(),this.#F()?this.#j(9,1):this.#T()?this.#j(8,1):this.#j(7,0);continue}else if(this.#Y===2){this.#K(5);continue}this.#j(10,0);break}if(this.#U>0)if(this.#f())this.#U-=1;else continue;if(this.#S()){this.#U+=1;continue}switch(this.#Y){case 0:this.#I()&&this.#K(1);break;case 1:if(this.#I()){this.#A();let $=7,Z=1;this.#L()?($=2,Z=3):this.#B&&($=2),this.#j($,Z)}break;case 2:this.#V()?this.#K(3):(this.#C()||this.#T()||this.#F())&&this.#K(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.#H()?this.#Q+=1:this.#x()&&(this.#Q-=1),this.#P()&&!this.#Q?this.#j(6,1):this.#C()?this.#j(7,0):this.#T()?this.#j(8,1):this.#F()&&this.#j(9,1);break;case 6:this.#C()?this.#j(7,0):this.#T()?this.#j(8,1):this.#F()&&this.#j(9,1);break;case 7:this.#T()?this.#j(8,1):this.#F()&&this.#j(9,1);break;case 8:this.#F()&&this.#j(9,1);break;case 9:break;case 10:break}}this.#O.hostname!==void 0&&this.#O.port===void 0&&(this.#O.port="")}#j($,Z){switch(this.#Y){case 0:break;case 1:this.#O.protocol=this.#X();break;case 2:break;case 3:this.#O.username=this.#X();break;case 4:this.#O.password=this.#X();break;case 5:this.#O.hostname=this.#X();break;case 6:this.#O.port=this.#X();break;case 7:this.#O.pathname=this.#X();break;case 8:this.#O.search=this.#X();break;case 9:this.#O.hash=this.#X();break;case 10:break}this.#Y!==0&&$!==10&&([1,2,3,4].includes(this.#Y)&&[6,7,8,9].includes($)&&(this.#O.hostname??=""),[1,2,3,4,5,6].includes(this.#Y)&&[8,9].includes($)&&(this.#O.pathname??=this.#B?"/":""),[1,2,3,4,5,6,7].includes(this.#Y)&&$===9&&(this.#O.search??="")),this.#N($,Z)}#N($,Z){this.#Y=$,this.#G=this.#$+Z,this.#$+=Z,this.#W=0}#M(){this.#$=this.#G,this.#W=0}#K($){this.#M(),this.#Y=$}#D($){return $<0&&($=this.#Z.length-$),$<this.#Z.length?this.#Z[$]:this.#Z[this.#Z.length-1]}#z($,Z){let O=this.#D($);return O.value===Z&&(O.type==="CHAR"||O.type==="ESCAPED_CHAR"||O.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.#$,":")}#C(){return this.#z(this.#$,"/")}#T(){if(this.#z(this.#$,"?"))return!0;if(this.#Z[this.#$].value!=="?")return!1;let $=this.#D(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#F(){return this.#z(this.#$,"#")}#S(){return this.#Z[this.#$].type=="OPEN"}#f(){return this.#Z[this.#$].type=="CLOSE"}#H(){return this.#z(this.#$,"[")}#x(){return this.#z(this.#$,"]")}#X(){let $=this.#Z[this.#$],Z=this.#D(this.#G).index;return this.#J.substring(Z,$.index)}#A(){let $={};Object.assign($,n1),$.encodePart=tO;let Z=P9(this.#X(),void 0,$);this.#B=k2(Z)}};S(c9,"Parser");var f2=["protocol","username","password","hostname","port","pathname","search","hash"],s1="*";function A2($,Z){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let O=new URL($,Z);return{protocol:O.protocol.substring(0,O.protocol.length-1),username:O.username,password:O.password,hostname:O.hostname,port:O.port,pathname:O.pathname,search:O.search!==""?O.search.substring(1,O.search.length):void 0,hash:O.hash!==""?O.hash.substring(1,O.hash.length):void 0}}S(A2,"extractValues");function Y1($,Z){return Z?UZ($):$}S(Y1,"processBaseURLString");function KZ($,Z,O){let j;if(typeof Z.baseURL=="string")try{j=new URL(Z.baseURL),Z.protocol===void 0&&($.protocol=Y1(j.protocol.substring(0,j.protocol.length-1),O)),!O&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&($.username=Y1(j.username,O)),!O&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&Z.password===void 0&&($.password=Y1(j.password,O)),Z.protocol===void 0&&Z.hostname===void 0&&($.hostname=Y1(j.hostname,O)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&($.port=Y1(j.port,O)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&($.pathname=Y1(j.pathname,O)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&($.search=Y1(j.search.substring(1,j.search.length),O)),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=Y1(j.hash.substring(1,j.hash.length),O))}catch{throw TypeError(`invalid baseURL '${Z.baseURL}'.`)}if(typeof Z.protocol=="string"&&($.protocol=k9(Z.protocol,O)),typeof Z.username=="string"&&($.username=R9(Z.username,O)),typeof Z.password=="string"&&($.password=b9(Z.password,O)),typeof Z.hostname=="string"&&($.hostname=E9(Z.hostname,O)),typeof Z.port=="string"&&($.port=w9(Z.port,$.protocol,O)),typeof Z.pathname=="string"){if($.pathname=Z.pathname,j&&!S9($.pathname,O)){let J=j.pathname.lastIndexOf("/");J>=0&&($.pathname=Y1(j.pathname.substring(0,J+1),O)+$.pathname)}$.pathname=v9($.pathname,$.protocol,O)}return typeof Z.search=="string"&&($.search=A9(Z.search,O)),typeof Z.hash=="string"&&($.hash=x9(Z.hash,O)),$}S(KZ,"applyInit");function UZ($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}S(UZ,"escapePatternString");function l9($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}S(l9,"escapeRegexpString");function d9($,Z){Z.delimiter??="/#?",Z.prefixes??="./",Z.sensitive??=!1,Z.strict??=!1,Z.end??=!0,Z.start??=!0,Z.endsWith="";let O=".*",j=`[^${l9(Z.delimiter)}]+?`,J=/[$_\u200C\u200D\p{ID_Continue}]/u,W="";for(let z=0;z<$.length;++z){let Y=$[z];if(Y.type===3){if(Y.modifier===3){W+=UZ(Y.value);continue}W+=`{${UZ(Y.value)}}${I$(Y.modifier)}`;continue}let X=Y.hasCustomName(),G=!!Y.suffix.length||!!Y.prefix.length&&(Y.prefix.length!==1||!Z.prefixes.includes(Y.prefix)),F=z>0?$[z-1]:null,K=z<$.length-1?$[z+1]:null;if(!G&&X&&Y.type===1&&Y.modifier===3&&K&&!K.prefix.length&&!K.suffix.length)if(K.type===3){let T=K.value.length>0?K.value[0]:"";G=J.test(T)}else G=!K.hasCustomName();if(!G&&!Y.prefix.length&&F&&F.type===3){let T=F.value[F.value.length-1];G=Z.prefixes.includes(T)}G&&(W+="{"),W+=UZ(Y.prefix),X&&(W+=`:${Y.name}`),Y.type===2?W+=`(${Y.value})`:Y.type===1?X||(W+=`(${j})`):Y.type===0&&(!X&&(!F||F.type===3||F.modifier!==3||G||Y.prefix!=="")?W+="*":W+=`(${O})`),Y.type===1&&X&&Y.suffix.length&&J.test(Y.suffix[0])&&(W+="\\"),W+=UZ(Y.suffix),G&&(W+="}"),Y.modifier!==3&&(W+=I$(Y.modifier))}return W}S(d9,"partsToPattern");var p2=class{#J;#Z={};#O={};#$={};#W={};#G=!1;constructor($={},Z,O){try{let j;if(typeof Z=="string"?j=Z:O=Z,typeof $=="string"){let Y=new c9($);if(Y.parse(),$=Y.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 O>"u"&&(O={ignoreCase:!1});let J={ignoreCase:O.ignoreCase===!0},W={pathname:s1,protocol:s1,username:s1,password:s1,hostname:s1,port:s1,search:s1,hash:s1};this.#J=KZ(W,$,!0),q2(this.#J.protocol)===this.#J.port&&(this.#J.port="");let z;for(z of f2){if(!(z in this.#J))continue;let Y={},X=this.#J[z];switch(this.#O[z]=[],z){case"protocol":Object.assign(Y,n1),Y.encodePart=tO;break;case"username":Object.assign(Y,n1),Y.encodePart=q9;break;case"password":Object.assign(Y,n1),Y.encodePart=g9;break;case"hostname":Object.assign(Y,cF),w2(X)?Y.encodePart=y2:Y.encodePart=g2;break;case"port":Object.assign(Y,n1),Y.encodePart=m2;break;case"pathname":k2(this.#Z.protocol)?(Object.assign(Y,lF,J),Y.encodePart=y9):(Object.assign(Y,n1,J),Y.encodePart=m9);break;case"search":Object.assign(Y,n1,J),Y.encodePart=p9;break;case"hash":Object.assign(Y,n1,J),Y.encodePart=h9;break}try{this.#W[z]=b2(X,Y),this.#Z[z]=R2(this.#W[z],this.#O[z],Y),this.#$[z]=d9(this.#W[z],Y),this.#G=this.#G||this.#W[z].some((G)=>G.type===2)}catch{throw TypeError(`invalid ${z} pattern '${this.#J[z]}'.`)}}}catch(j){throw TypeError(`Failed to construct 'URLPattern': ${j.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},Z){let O={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"?O=KZ(O,$,!1):O=KZ(O,A2($,Z),!1)}catch{return!1}let j;for(j of f2)if(!this.#Z[j].exec(O[j]))return!1;return!0}exec($={},Z){let O={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"?O=KZ(O,$,!1):O=KZ(O,A2($,Z),!1)}catch{return null}let j={};Z?j.inputs=[$,Z]:j.inputs=[$];let J;for(J of f2){let W=this.#Z[J].exec(O[J]);if(!W)return null;let z={};for(let[Y,X]of this.#O[J].entries())if(typeof X=="string"||typeof X=="number"){let G=W[Y+1];z[X]=G}j[J]={input:O[J]??"",groups:z}}return j}static compareComponent($,Z,O){let j=S((Y,X)=>{for(let G of["type","modifier","prefix","value","suffix"]){if(Y[G]<X[G])return-1;if(Y[G]===X[G])continue;return 1}return 0},"comparePart"),J=new QZ(3,"","","","",3),W=new QZ(0,"","","","",3),z=S((Y,X)=>{let G=0;for(;G<Math.min(Y.length,X.length);++G){let F=j(Y[G],X[G]);if(F)return F}return Y.length===X.length?0:j(Y[G]??J,X[G]??J)},"comparePartList");return!Z.#$[$]&&!O.#$[$]?0:Z.#$[$]&&!O.#$[$]?z(Z.#W[$],[W]):!Z.#$[$]&&O.#$[$]?z([W],O.#W[$]):z(Z.#W[$],O.#W[$])}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.#G}};S(p2,"URLPattern");function D3($,Z){for(let[O,j]of Object.entries($)){let J=new p2({pathname:O});if(J.test({pathname:Z}))return{routePath:O,params:J.exec({pathname:Z})?.pathname.groups??{},route:j}}return null}var N$={startIndex:0,carriedViews:[]};function i9($,Z){let O=J0($.path,Z);return O.includes("*")?null:O}function dF($,Z){if(!$)return N$;if($.search!==Z.search)return N$;let O=Math.min($.segments.length,Z.segments.length-1),j=0;while(j<O){let J=$.segments[j],W=Z.segments[j];if(W.alwaysRun)break;if(J.viewPath!==W.viewPath)break;let z=i9(J,$.params),Y=i9(W,Z.params);if(z===null||Y===null||z!==Y)break;j++}if(j===0)return N$;return{startIndex:j,carriedViews:Z.segments.slice(0,j).map(({viewPath:J})=>J)}}function iF($,Z){let[,O,...j]=$.split("/");if(!Z.includes(O))return $;let J=`/${j.join("/")}`;return J==="/"?"/":J.replace(/\/$/,"")}function u9($){let{flatViewRoutes:Z,supportedLocales:O,from:j,origin:J,to:W}=$;if(!j)return N$;let z;try{z=new URL(j,J)}catch{return N$}if(z.origin!==J)return N$;let Y=D3(Z,iF(z.pathname,O));if(!Y)return N$;return dF({segments:Y.route.segments,params:Y.params,search:z.search},W)}var h2="x-gemi-from";import{createElement as L1,Fragment as U5}from"react";function uF($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function eO($){let Z={};for(let[O,j]of Object.entries($))if("run"in j){let J=j.viewPath;if("children"in j){Z[O]=[J];let W=new j.children,z=eO(W.routes);for(let[Y,X]of Object.entries(z)){let G=O==="/"?Y:`${O}${Y}`,F=Y==="/"&&O!=="/"?O:G;Z[F]=[J,...X]}if(Z[O].length===1)delete Z[O]}else Z[O]=[J]}else{let J=new j,W=eO(J.routes);for(let[z,Y]of Object.entries(W)){let X=O==="/"?z:`${O}${z}`,G=z==="/"&&O!=="/"?O:X;Z[G]=Y}}return Object.fromEntries(Object.entries(Z).map(([O,j])=>[uF(O),j]))}function $j($,Z){let[O,j]=Z,J=$.find(([W])=>W===O);if(!J){$.push([O,[...j]]);return}for(let W of j)$j(J[1],W)}function Zj($){let Z=[];for(let[O,j]of Object.entries($))if("run"in j){let J=j.viewPath;if(J==="__")continue;if(J==="REDIRECT")continue;if(J==="FILE")continue;if("children"in j){let W=new j.children,z=Zj(W.routes);$j(Z,[J,z])}else $j(Z,[J,[]])}else{let J=new j,W=Zj(J.routes);for(let z of W)$j(Z,z)}return Z}function c2($){let Z=[];for(let[O,j]of $)Z.push(O,...c2(j).flat());return Array.from(new Set(Z))}class a1 extends B0{static getFacadeAccessor(){return s}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),Z=x.getStore();if(Z)return Z.locale??$.detectLocale(Z.req);return $.defaultLocale}static timeZone(){return this.getFacadeRoot().detectTimeZone(x.getStore()?.req)}static formatter($={}){return this.getFacadeRoot().formatter($.locale??a1.locale(),$.timeZone??a1.timeZone())}static setLocale($=a1.locale()){let Z=this.getFacadeRoot(),O=$;if(!Z.supportedLocales.includes($))O=Z.defaultLocale;let j=x.getStore();return j.setCookie("i18n-locale",O,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1}),j.setLocale(O),O}}class l2{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var sF=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),nF=new Set(["svg","math"]);function s9($){return $===32||$===9||$===10||$===12||$===13}function n9($){return $>=65&&$<=90||$>=97&&$<=122}function Oj($){return $>=65&&$<=90?$+32:$}function a9(){let $="data",Z="",O=!1,j="",J=0,W=0,z=!1,Y=0,X=0,G=()=>$==="data"&&Y===0&&X===0,F=()=>{if(!O&&sF.has(Z)){$="rawText",j=`</${Z}`,J=0,Z="";return}if($="data",Z==="template")if(O)Y=Math.max(0,Y-1);else Y+=1;else if(nF.has(Z)){if(O)X=Math.max(0,X-1);else if(!z)X+=1}Z=""},K=(T)=>{switch($){case"data":if(T===60)$="tagOpen";return;case"tagOpen":if(T===33)$="bang",W=0;else if(T===47)$="endTagOpen";else if(n9(T))$="tagName",O=!1,z=!1,Z=String.fromCharCode(Oj(T));else if(T===63)$="bogus";else if(T===60)$="tagOpen";else $="data";return;case"endTagOpen":if(n9(T))$="tagName",O=!0,z=!1,Z=String.fromCharCode(Oj(T));else if(T===62)$="data";else $="bogus";return;case"tagName":if(s9(T)||T===47)$="inTag",z=T===47;else if(T===62)F();else Z+=String.fromCharCode(Oj(T));return;case"inTag":if(T===62){F();return}if(z=T===47,T===34)$="attrDouble";else if(T===39)$="attrSingle";return;case"attrDouble":if(T===34)$="inTag";z=!1;return;case"attrSingle":if(T===39)$="inTag";z=!1;return;case"bang":if(T===45){if(W+=1,W===2)$="comment",W=0}else if(T===62)$="data";else $="bogus";return;case"bogus":if(T===62)$="data";return;case"comment":if(T===45)W=W<2?W+1:2;else if(T===62&&W>=2)$="data",W=0;else W=0;return;case"rawText":{if(J<j.length){if(Oj(T)===j.charCodeAt(J))J+=1;else J=T===60?1:0;return}if(T===62)$="data",Z="";else if(s9(T)||T===47)$="inTag",Z="";else J=T===60?1:0;return}}};return{scanToInsertionPoint(T){for(let U=0;U<T.length;U++){if(G())return U;K(T[U])}return T.length},write(T){for(let U=0;U<T.length;U++)K(T[U])},isSafe:G}}function N1($){let Z=JSON.stringify($);if(Z===void 0)return"undefined";return Z.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function aF($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${N1([$.path,$.variantKey,$.data])})</script>`}function oF($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${N1([$.id,$.locale,$.strings])})</script>`}function d2($,Z,O={},j){let J=new TextEncoder,W=[],z=!1,Y=!1,X=()=>{if(Y)return;Y=!0,O.onClose?.()};Z.onSettle((Q)=>{if(Q.status!=="resolved")return;W.push(aF(Q))}),j?.onUse((Q)=>{W.push(oF(Q))});let G=$.getReader(),F=a9(),K=(Q,B)=>{Q.enqueue(B),O.onChunk?.(B)},T=(Q)=>{while(W.length>0){let B=J.encode(W.shift());F.write(B),K(Q,B)}},U=(Q,B)=>{if(W.length===0){F.write(B),K(Q,B);return}let D=F.scanToInsertionPoint(B);if(D>0)K(Q,B.subarray(0,D));if(F.isSafe())T(Q);let C=B.subarray(D);if(C.length>0)F.write(C),K(Q,C)};return new ReadableStream({async pull(Q){let B;try{B=await G.read()}catch(L){throw X(),L}let{done:D,value:C}=B;if(D){T(Q),Q.close(),X();return}if(!z){if(z=!0,F.write(C),K(Q,C),O.onShell?.(),F.isSafe())T(Q);return}U(Q,C)},cancel(Q){return X(),G.cancel(Q)}})}var rF=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function jj($){if(!$)return!1;return rF.test($)}async function r9($,Z=()=>{}){let O=x.getStore(),j=O?.req??null,J=null;if(j?.rawRequest?.url)try{J=new URL(j.rawRequest.url).pathname}catch{J=null}return{user:O?.user??null,attributes:await tF($,Z),request:{path:J,routePath:j?.routePath??null,locale:O?.locale??null},anonymousId:o9(),isBot:jj(j?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function t9($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function tF($,Z){if(!$.context)return{};try{let O=x.getStore();return await $.context(O?.req??null)??{}}catch(O){return Z(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${O instanceof Error?O.message:String(O)}`),{}}}function e9($,Z){return`${$}:${Z}`}function i2($){let Z=new Bun.CryptoHasher("sha1").update($).digest("hex"),O=Number.parseInt(Z.slice(0,8),16);return Math.floor(O/4294967296*1e4)}function $5($,Z){if(Z>=100)return!0;if(Z<=0)return!1;return $<Math.round(Z*100)}function Z5($,Z,O,j){if(j.unavailable)return{value:!1,reason:"unavailable"};if(j.active!==!0)return{value:!1,reason:"inactive"};if(Z.when){let W;try{W=Z.when(O)}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 W==="boolean")return{value:W,reason:"attributed"}}if(Z.rollout===void 0)return{value:!0,reason:"on"};if(O.isBot)return{value:!1,reason:"bot"};let J=$T($,Z,O,j.buckets);return $5(J,Z.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function eF($){let Z=$.user?.publicId??$.user?.id;if(Z!==void 0&&Z!==null)return String(Z);return $.anonymousId??""}function $T($,Z,O,j){let J=e9(Z.salt??$,eF(O));if(!j)return i2(J);let W=j.get(J);if(W!==void 0)return W;let z=i2(J);return j.set(J,z),z}class O5 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 u2{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,Z,O,j=()=>{}){this.source=$;this.declared=Z;this.ttlMs=O;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 O5(this.lastError);return Z}peek(){return this.snapshot}async load(){try{let $=await this.source.load(),{active:Z,audit:O}=this.readRows($);return this.snapshot={active:Z,audit:O,loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readRows($){let Z=new Map,O=new Map;for(let j of $??[]){let J=typeof j?.key==="string"?j.key:null;if(!J){this.warn("Ignoring a feature row with no `key`.");continue}if(!(J in this.declared)){this.warn(`Feature row "${J}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}Z.set(J,j.active===!0);let W=ZT(j);if(W)O.set(J,W)}return{active:Z,audit:O}}handleFailure($){let Z=$ instanceof Error?$.message:String($),O=Date.now();if(this.lastError=$,this.retryAfter=O+this.ttlMs,O-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=O,this.warn(`Could not load feature switches: ${Z}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,audit:new Map,loadedAt:O,unavailable:!0},this.snapshot}}function ZT($){let Z={},O=$.updatedBy;if(typeof O==="string")Z.updatedBy=O;else if(O===null)Z.updatedBy=null;let j=$.updatedAt;if(j instanceof Date||typeof j==="string"||typeof j==="number"){let J=j instanceof Date?j:new Date(j);if(!Number.isNaN(J.getTime()))Z.updatedAt=J}return"updatedBy"in Z||"updatedAt"in Z?Z:null}class OT{}class jT 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 s2 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 j5 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 J5{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 BZ{config;log;static token="features";store;declared;warnedAboutSize=!1;warnedAboutActor=!1;constructor($,Z=()=>{}){this.config=$;this.log=Z;this.declared=$.features??{},this.store=new u2($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,audit:Z,unavailable:O}=await this.switches();return{unavailable:O,features:Object.entries(this.declared).map(([j,J])=>({key:j,describe:J.describe,rollout:J.rollout,targeted:J.when!==void 0,serverOnly:J.serverOnly,salt:J.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{x.getStore()?.featureEvaluations?.clear()}}async set($,Z,O={}){if(typeof $!=="string"||!Object.hasOwn(this.declared,$))throw new j5(String($));if(typeof Z!=="boolean")throw TypeError(`Features.set("${$}", \u2026) takes a boolean, not ${Z===null?"null":typeof Z}.`);let j=JT(O.actor),J=this.config.source;if(typeof J.write!=="function")throw new s2(J.constructor?.name||"an anonymous source");let{actorRecorded:W}=await J.write($,Z,{actor:j});if(j!==null&&!W&&!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 J5(this,t9($))}async evaluateIn($,Z,O){let j=this.memoFor(Z),J=j?.get($);if(J)return J;let W=this.declared[$];if(!W)return{value:!1,reason:"undeclared"};let{active:z,unavailable:Y}=await this.switchFor($),X=Z5($,W,Z,{active:z,unavailable:Y,buckets:O,warn:this.log});return j?.set($,X),this.notify($,X,Z),X}async evaluateAllIn($,Z,O){let j={};for(let[J,W]of Object.entries(this.declared)){if(O.clientOnly&&W.serverOnly)continue;j[J]=(await this.evaluateIn(J,$,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 $=x.getStore();if($?.featureContext)return $.featureContext;let Z=await r9(this.config,this.log);if($)$.featureContext=Z;return Z}memoFor($){let Z=x.getStore();if(!Z||Z.featureContext!==$)return null;return Z.featureEvaluations??=new Map,Z.featureEvaluations}requestBuckets(){let $=x.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,Z,O){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,Z,O)}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 JT($){if($===void 0||$===null)return null;if(typeof $==="string"){if($.length>0)return $}else if(typeof $==="object"){let{publicId:Z,id:O}=$;if(typeof Z==="string"&&Z.length>0)return Z;if(typeof O==="string"&&O.length>0||typeof O==="number")return String(O)}throw TypeError("Features.set() was given an `actor` that identifies nobody. Pass a string, or a user with a `publicId` or an `id`.")}function W5($){return Object.fromEntries(Object.entries($).filter(([,Z])=>{return Z!==null&&Z!==void 0}))}var WT=50;class DZ{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((O)=>O.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(),(O)=>({path:O.path,variantKey:O.variantKey,startedAt:O.startedAt,settledAt:O.settledAt,status:O.status,source:O.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 J=JSON.stringify($.data)?.length??0;Z=J>=1024?`${(J/1024).toFixed(1)} kB`:`${J} B`}catch{Z="an unserializable payload"}let O=($.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 (${O}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={},O="render"){let j=Z.params??{},J=new URLSearchParams(W5(Z.search??{}));J.delete("json"),J.sort();let W=J0($,j),z=J.toString(),Y=this.keyFor(W,z),X=this.entries.get(Y);if(X)return X;let G;if(O==="render"&&this.renderStartedAt!==null){let U=Math.round(performance.now()-this.renderStartedAt);if(U>WT)G=U}let F,K=new Promise((U)=>{F=U}),T={path:W,patternPath:$,variantKey:z,lateBy:G,status:"pending",promise:K,source:O,startedAt:this.elapsed()};return this.entries.set(Y,T),this.fetcher($,j,J).then((U)=>{T.status="resolved",T.data=U},(U)=>{T.status="rejected",T.error=U}).then(()=>{if(T.settledAt=this.elapsed(),this.maybeLogLateDiscovery(T),T.status==="rejected"&&this.failListener)this.failListener(T);if(this.settleListener)this.settleListener(T);else this.settledBacklog.push(T);F()}),T}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,O]of this.entries){if(O.status!=="resolved")continue;this.shipped.add(Z),$[O.path]??={},$[O.path][O.variantKey]=O.data}return $}onSettle($){this.settleListener=(O)=>{if(this.shipped.has(this.keyFor(O.path,O.variantKey)))return;$(O)};let Z=this.settledBacklog;this.settledBacklog=[];for(let O of Z)this.settleListener(O)}}class o1 extends Error{path;variantKey;status;body;retryAfter;constructor($,Z,O,j,J){super(typeof j?.message==="string"?j.message:`Request to /api${$} failed with status ${O}`);this.path=$;this.variantKey=Z;this.status=O;this.body=j;this.retryAfter=J;this.name="QueryError"}}function VZ(){let $=JSON.stringify({error:x1("permission","Forbidden",403)});return new Response($,{status:403,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}function n2(){return{status:403,error:{message:"Forbidden"}}}function V3($){let Z=CZ.getStore();return(O,j,J)=>{let W=new URL($.url).origin,z=[J0(O,j),J.toString()].filter((F)=>F.length>0).join("?"),Y=new Request(`${W}/${z}`,{headers:$.headers,signal:$.signal}),X=z5($);if(X)MZ(Y,X);let G=new A(Y,j);return CZ.run(Z,()=>x.run(G,async()=>{try{let F=await I(r0).dispatchers(X).api.getRouteData(O);if(A$(F)){if(!F.ok)throw new o1(J0(O,j),J.toString(),F.status,F.body);return F.body}if(F instanceof Response){let K=await F.json().catch(()=>null);if(!F.ok)throw new o1(J0(O,j),J.toString(),F.status,K);return K}return F}catch(F){if(F instanceof o1)throw F;let K=new o1(J0(O,j),J.toString(),500,{message:F instanceof Error?F.message:String(F)});throw K.cause=F,K}}))}}var zT=new Set(["script","style","template","title"]),YT=/\shidden([\s=/]|$)/i,XT=/"[^"]*"|'[^']*'/g;function GT($){let Z=0,O=0,j=0,J=0;while(J<$.length){let W=$.indexOf("<",J),z=W===-1?$.length:W;if(z>J){let K=$.slice(J,z).replace(/\s+/g,"").length;if(j>0)O+=K;else Z+=K}if(W===-1)break;if($.startsWith("<!--",W)){let K=$.indexOf("-->",W+4);J=K===-1?$.length:K+3;continue}let Y=$.indexOf(">",W);if(Y===-1)break;let X=$.slice(W+1,Y);J=Y+1;let G=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(X)?.[1]?.toLowerCase();if(!G)continue;let F=X.startsWith("/");if(!F&&zT.has(G)&&!X.endsWith("/")){let K=$.indexOf(`</${G}`,J);J=K===-1?$.length:K;continue}if(G!=="div")continue;if(F){if(j>0)j-=1}else if(j>0)j+=1;else if(YT.test(X.replace(XT,'""')))j=1}return{shellChars:Z,deferredChars:O}}var FT=1000,TT=64;function KT($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function UT($,Z){if(Z.deferredChars<FT)return null;if(Z.shellChars>=TT)return null;return`[gemi] GET ${$} streams ${KT(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 Y5($=console.warn){let Z=new Set;return{shouldObserve(O){return!Z.has(O)},report(O,j){if(Z.has(O))return;let J=UT(O,j);if(!J)return;Z.add(O),$(J)}}}function X5(){let $=new TextDecoder,Z="";return{onChunk(O){Z+=$.decode(O,{stream:!0})},measure(){return Z+=$.decode(),GT(Z)}}}function G5($,Z,O=1e4,j){let J=new TextEncoder,W=()=>{};return new ReadableStream({start(z){let Y=!1,X=(F)=>{if(Y)return;Y=!0,clearTimeout(G);try{z.close()}catch{}j?.({aborted:F})};W=X,z.enqueue(J.encode(`${JSON.stringify($)}
3
+ `)),Z.onSettle((F)=>{if(Y||F.status!=="resolved")return;z.enqueue(J.encode(`${JSON.stringify([F.path,F.variantKey,F.data])}
4
+ `))});let G=setTimeout(()=>X(!0),O);Z.allSettled().then(()=>X(!1),()=>X(!1))},cancel(){W(!1)}})}import{createContext as QT,createElement as ND,useContext as LD}from"react";var BT=Symbol.for("gemi.staticRender"),F5=globalThis[BT]??=QT(null);import{createHash as DT}from"crypto";var VT="gemi-islands",a2='const d=document,c=JSON.parse(d.getElementById("gemi-islands").textContent),w=f=>(window.requestIdleCallback||setTimeout)(f),m=(e,s)=>import(s).then(x=>{if(!e.g){e.g=1;const p=e.getAttribute("data-props");x.default(e,p?JSON.parse(p):void 0)}}).catch(r=>console.error(r));for(const e of d.querySelectorAll("gemi-island")){const o=c[e.getAttribute("name")];if(!o)continue;if(o.load=="eager")m(e,o.src);else if(o.load=="idle"||!window.IntersectionObserver||!e.children.length)w(()=>m(e,o.src));else{const v=new IntersectionObserver(n=>{if(n.some(x=>x.isIntersecting)){v.disconnect();m(e,o.src)}});for(const k of e.children)v.observe(k)}}',fD=`'sha256-${DT("sha256").update(a2).digest("base64")}'`,CT=`await import("/refresh.js").catch(()=>{});${a2}`;function T5($,Z,O,j){if(!O)return $;let J=j?$.lastIndexOf(Z):$.indexOf(Z);return J===-1?$+O:$.slice(0,J)+O+$.slice(J)}var MT=($)=>$.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;");function K5($,Z,O,j){if(Z.islands.size===0)return $;let J={},W=new Set;for(let[X,{module:G,load:F}]of Z.islands){let K=O?.(G);if(!K){console.error(`[gemi] island "${X}": no client build entry for ${G}. Is it named *.island.ts(x) under app/?`);continue}if(J[X]={src:K.src,load:F},F==="eager")for(let T of K.preload)W.add(T)}if(Object.keys(J).length===0)return $;let z=[...W].map((X)=>`<link rel="modulepreload" href="${MT(X)}"/>`).join(""),Y=`<script type="application/json" id="${VT}">${N1(J)}</script><script type="module">${j?CT:a2}</script>`;return T5(T5($,"</head>",z,!1),"</body>",Y,!0)}var IT=async()=>(await import("./chunk-rgfzqwpg.js")).default,o2,Jj=async(...$)=>{return o2??=import("react-dom/server.browser").catch((Z)=>{throw o2=void 0,Z}),(await o2).renderToReadableStream(...$)},Q5=1e4,NT=`
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 LT($,Z,O){let j=`${O==="italic"?"italic,":""}wght@${O==="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((Y)=>Y.arrayBuffer())}var $4="/assets";function _T($){return $===$4||$.startsWith(`${$4}/`)}function PT($){let Z=$.filter(_T);if(Z.length>0){let O=Z.length>1;throw Error(`View route path${O?"s":""} ${Z.map((j)=>`"${j}"`).join(", ")} use${O?"":"s"} the reserved "${$4}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function ST($){let Z=I(r0).resolver;return{...$.domain,root:Z.root,origin:Z.publicOrigin($.rawRequest)}}function r2($){let{status:Z=400,error:O}=$;return new Response(O?.message,{...$,status:Z})}function fT($){let{status:Z=400,data:O,directive:j,headers:J}=$;return new Response(JSON.stringify({data:O,directive:j}),{headers:J,status:Z})}class I3{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];staticRoutes=[];root=null;shellReporter=Y5();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let Z=I9();this.partialRendering=$.partialRendering??Z.partialRendering,this.hooks={onRequestStart:$.onRequestStart??Z.onRequestStart,onRequestEnd:$.onRequestEnd??Z.onRequestEnd,onRequestFail:$.onRequestFail??Z.onRequestFail,onStreamComplete:$.onStreamComplete??Z.onStreamComplete};let O={"/":$.rootRouter,"/auth":D2};this.flatViewRoutes=rO(O),PT(Object.keys(this.flatViewRoutes)),this.routeManifest=eO(O),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,j])=>j.at(-1)!=="FILE")),this.componentTree=Zj(O),this.flatComponentTree=c2(this.componentTree),this.staticRoutes=Object.entries(this.flatViewRoutes).filter(([,j])=>j.static).map(([j])=>j);for(let j of this.staticRoutes){let J=this.flatViewRoutes[j].static?.layout;if(J&&!this.flatComponentTree.includes(J))this.flatComponentTree.push(J)}this.root=$.root}async passesFeatureGates($){let Z=I(BZ);for(let O of $)if(!await Z.enabled(O))return!1;return!0}async onRequestEnd($){return t2(),await this.hooks.onRequestEnd($)}completeStream($,Z){let O=(j)=>{L$.error(j?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(j)})};try{Promise.resolve(this.hooks.onStreamComplete($,Z)).catch(O)}catch(j){O(j)}}modulePreloadLinks($){let{clientEntry:Z,modulePreloadManifest:O,views:j,routeKey:J}=$,W=()=>{let X=new Set(Z?.preload??[]);for(let G of j)for(let F of O?.[G]??[])X.add(F);return[...X].map((G)=>L1("link",{key:`modulepreload:${G}`,rel:"modulepreload",href:G}))};if(!O)return W();let z=this.preloadCache.get(O);if(!z||z.clientEntry!==Z)z={clientEntry:Z,byRoute:new Map},this.preloadCache.set(O,z);let Y=z.byRoute.get(J);if(!Y)Y=W(),z.byRoute.set(J,Y);return Y}async renderStatic($){let{req:Z,runInRequestScope:O,staticView:j,currentViews:J,data:W,serverQueries:z,headers:Y}=$,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 G=await $.getStyles(J,{static:!0,layout:j.layout});z.markRenderStart();let F={islands:new Map},K=e2(),T=new AbortController,U=setTimeout(()=>T.abort(),Q5);try{let Q=await Jj(L1(F5.Provider,{value:F,children:L1(U5,{children:[...G,L1(this.root,{data:W,viewImportMap:$.viewImportMap,viewModules:$.viewModules,serverQueries:z,dictionarySink:K,rootLayout:X,key:"root"})]})}),{signal:T.signal,progressiveChunkSize:Number.MAX_SAFE_INTEGER,onError(D){if(Bun.env.NODE_ENV!=="production")console.error(D)}});await Q.allReady.catch(()=>{});let B=await new Response(Q).text();return new Response(K5(B,F,$.resolveIsland,Bun.env.NODE_ENV!=="production"),{status:200,headers:Y})}finally{clearTimeout(U),O(()=>this.completeStream(Z,z.summarize(T.signal.aborted)))}}async render($){let{req:Z,runInRequestScope:O,csrfTokenHMAC:j,currentPathName:J,headers:W,i18n:z,params:Y,pathname:X,serverQueries:G,userAgent:F,noStream:K,url:T,user:U,viewData:Q,breadcrumbs:B,urlLocaleSegment:D,meta:C,isOgRequest:L,appId:M,features:P,staticView:f}=$,_=X.replace(`/${D}`,""),V={kind:"view",data:{meta:C,pageData:{[_]:Q},__csrf:j.toString("base64"),prefetchedData:{},i18n:z,auth:{user:U},routeManifest:this.clientRouteManifest,breadcrumbs:B,router:{urlLocaleSegment:D,pathname:J,params:Y,currentPath:X,searchParams:T.search,is404:!J?!0:!1,domain:Z.domain?ST(Z):null},appId:M,features:P,componentTree:[["404",[]],...this.componentTree],...this.staticRoutes.length>0?{staticRoutes:this.staticRoutes}:{}},head:{}},N=this.root,H=this.routeManifest[J];return async(R)=>{let{bootstrapModules:m=[],loaders:r,getStyles:v,viewImportMap:p0,cssManifest:Tj,ogMap:N3,viewModules:LZ,clientEntry:t0,modulePreloadManifest:r1,assetBase:P1,resolveIsland:D0}=R,_Z=t0?[]:m,L3=(H0)=>[H0,`window.loaders=${r}`,...t0?[`import(${JSON.stringify(t0.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(L){let H0=null,S$=null;for(let f$ of H??[])if(typeof N3[f$]==="function")S$=f$,H0=N3[f$];if(!H0)return new Response("Not found",{status:404});let l5=Object.values(V.data.pageData)[0];try{await Jj(L1(H0,l5[S$]),{onError:()=>{}})}catch(f$){let{fonts:d5,...i5}=f$.satoriOptions,u5=await Promise.all(d5.map((P3)=>{return LT(P3.name,P3.weight,P3.style).then((r5)=>({...P3,data:r5}))})),X4=new Headers(W);X4.set("Content-Type","image/png");let[s5,n5]=await Promise.all([IT(),aO("Rendering an OG image")]),a5=await s5(f$.jsx,{...i5,fonts:u5}),o5=await n5(Buffer.from(a5)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(o5),{headers:X4})}return new Response("data")}if(f&&J)return await this.renderStatic({req:Z,runInRequestScope:O,staticView:f,currentViews:H,data:V.data,serverQueries:G,headers:W,getStyles:v,viewImportMap:p0,viewModules:LZ,resolveIsland:D0});if(V.data.cssManifest=Tj,V.data.modulePreloadManifest=r1??{},P1&&P1!=="/")V.data.assetBase=P1;let _$=this.modulePreloadLinks({clientEntry:t0,modulePreloadManifest:r1,views:H??["404"],routeKey:J??"404"}),PZ=await v(H);V.data.prefetchedData=G.snapshotResolved(),G.markRenderStart();let S1=new AbortController,_3=setTimeout(()=>S1.abort(),Q5),b=jj(F)||K,f0=Bun.env.NODE_ENV!=="production"&&!b&&J&&this.shellReporter.shouldObserve(J)?X5():null,P$=e2();try{let H0=await Jj(L1(U5,{children:[..._$,...PZ,L1("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:NT}}),L1(N,{data:V.data,viewImportMap:p0,viewModules:LZ,serverQueries:G,dictionarySink:P$,key:"root"})]}),{bootstrapScriptContent:L3(`window.__GEMI_DATA__ = ${N1(V.data)}`),bootstrapModules:_Z,signal:S1.signal,...b?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(S$){if(Bun.env.NODE_ENV!=="production")console.error(S$)}});if(H0.allReady.catch(()=>{}).finally(()=>clearTimeout(_3)),b)await H0.allReady.catch(()=>{});return new Response(d2(H0,G,{onShell:b?void 0:()=>G.markShell(),onChunk:f0?.onChunk,onClose:()=>O(()=>{if(this.completeStream(Z,G.summarize(S1.signal.aborted)),f0)this.shellReporter.report(J,f0.measure())})},P$),{status:!J?404:200,headers:W})}catch(H0){if(clearTimeout(_3),Bun.env.NODE_ENV==="production")throw O(()=>this.completeStream(Z,G.summarize(S1.signal.aborted))),H0;let S$=await Jj(L1("div"),{bootstrapScriptContent:L3(`window.error= ${N1(H0.message)}; window.stack_trace=${N1(H0.stack)};window.__GEMI_DATA__ = ${N1(V.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",..._Z]:_Z});return new Response(d2(S$,G,{onClose:()=>O(()=>this.completeStream(Z,G.summarize(S1.signal.aborted)))}),{status:!J?404:200,headers:W})}}}async handleViewRequest($,Z){let O=new URL($.url),j=O.pathname.endsWith(".json"),J=O.pathname.endsWith(".og"),W=O.pathname.replace(".json","").replace(".og",""),[,z,...Y]=W.split("/"),X=`/${Y.join("/")}`,G=null,F=null,K=I(s);if(!K.supportedLocales.includes(z))X=W;else G=z,F=z;let U=F===null&&D3(this.flatViewRoutes,X)!==null;if(K.isLocaleAware&&!J&&F===null&&!U){let V=B5(z,K.supportedLocales,K.defaultLocale);if(V){let N=Y.length?`/${Y.join("/")}`:"";return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${V}${N}${j?".json":""}${O.search}`}})}}if(K.isLocaleAware&&!J){let V=I(s).detectLocale(new A($,{},"view",X));if(F===null&&V!==K.defaultLocale){let N=O.pathname==="/"?"":O.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${V}${N}${O.search}`}})}}X=X.replace("//","/");let Q=[],B=[],D=null,C={},L=null,M=!1,P=[],f;try{let V=D3(this.flatViewRoutes,X);if(V){if(D=V.routePath,C=V.params,Q=V.route.exec,B=V.route.middleware,P=V.route.features,M=B.includes("no-stream"),f=V.route.static,j&&this.partialRendering){let N=$.headers.get(h2),H=u9({flatViewRoutes:this.flatViewRoutes,supportedLocales:I(s).supportedLocales,from:N,origin:O.origin,to:{segments:V.route.segments,params:C,search:O.search}});if(H.startIndex>0)Q=Q.slice(H.startIndex),L={from:N,carriedViews:H.carriedViews}}}}catch(V){throw V}if(f&&j)return new Response("Not found",{status:404});let _=new A($,C,"view",D);return this.hooks.onRequestStart(_),await x.run(_,async()=>{let V=null,N=x.getStore(),H=CZ.getStore(),R=(v)=>CZ.run(H,()=>x.runWith(N,v));N.serverQueries=new DZ(V3($));let m=new Set;if(N.serverQueries.onQueryFail((v)=>{m.add(v.error);try{R(()=>Promise.resolve(this.hooks.onRequestFail(r,v.error)).catch(()=>{}))}catch{}}),F){let v=F.replaceAll("/","");a1.setLocale(v)}else a1.setLocale();let r=N.req;t2();try{let v=!1;try{await I(TZ).runMiddleware(B)}catch(b){if(!IZ(b))throw b;v=!0}if(v||P.length>0&&!await this.passesFeatureGates(P))D=null,Q=[],r.routePath="";let p0=I(s),Tj=p0.isEnabled,N3=p0.isLocaleAware,LZ=new A($,r.params),t0={defaultLocale:p0.defaultLocale,timeZone:p0.detectTimeZone(LZ)};if(N3){let b=null;if(F)b=F.replaceAll("/",""),N.setLocale(b);else b=p0.detectLocale(LZ),N.setLocale(b);let f0=Tj?p0.getPageTranslations(b,r.routePath):{};t0={...t0,supportedLocales:p0.supportedLocales,currentLocale:b,dictionary:{[b]:f0},defaultLocale:p0.defaultLocale}}await D5(t0.currentLocale??"");let r1;try{r1=await Promise.all(Q.map((b)=>b(r)))}catch(b){if(!IZ(b))throw b;D=null,Q=[],r.routePath="",r1=[]}let{cookies:P1,headers:D0}=N;V={data:r1,cookies:P1,headers:D0,user:N.user,prefetchedData:N.serverQueries.snapshotResolved(),currentPathName:D,params:r.params,urlLocaleSegment:G,meta:N.renderMeta(),appId:I(l2).id,features:await I(BZ).forClient()};let{params:_Z,user:L3}=V,_$={},PZ={};for(let b of r1??[]){let[f0,P$]=Object.entries(b)?.[0]??[];if(!f0||!P$)continue;PZ[`${f0}:${D}`]=P$.breadcrumb,_$[f0]=P$}let S1=_$.FILE;if(S1){for(let b of P1)D0.append("Set-Cookie",b.toString());try{await this.onRequestEnd(r)}catch(b){L$.error(b?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(b)})}return await _j(S1,D0)}if(j){D0.set("Content-Type","application/x-ndjson; charset=utf-8"),D0.append("Vary",h2),P1.forEach((f0)=>D0.append("Set-Cookie",f0.toString())),await this.hooks.onRequestEnd(r);let b={meta:L&&!N.metadata.touched?null:V.meta,data:{[X]:_$},breadcrumbs:PZ,prefetchedData:N.serverQueries.snapshotResolved(),i18n:t0,features:V.features,is404:!D,appId:V.appId,partial:L};return new Response(G5(b,N.serverQueries,void 0,({aborted:f0})=>R(()=>this.completeStream(r,N.serverQueries.summarize(f0)))),{headers:D0})}if(D0.set("Content-Type","text/html; charset=utf-8"),!M&&!(f&&D))D0.append("Vary","User-Agent");for(let b of P1)D0.append("Set-Cookie",b.toString());let _3=Bun.CSRF.generate(process.env.SECRET);D0.append("Set-Cookie",`csrf_token=${_3}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`);try{await this.onRequestEnd(r)}catch(b){L$.error(b?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(b)})}return await this.render({req:r,runInRequestScope:R,csrfTokenHMAC:Buffer.from(""),currentPathName:D,headers:D0,i18n:t0,params:_Z,pathname:O.pathname,serverQueries:N.serverQueries,userAgent:$.headers.get("user-agent"),noStream:M,url:O,user:L3,viewData:_$,breadcrumbs:PZ,urlLocaleSegment:G,meta:V.meta,appId:V.appId,features:V.features,isOgRequest:J,staticView:D?f:void 0})}catch(v){if(v.kind===C3)if(j)return fT(v.payload.viewData??v.payload.api);else return r2(v.payload.view);if(!m.has(v))this.hooks.onRequestFail(r,v);if(M3(v))return console.error(v),j?VZ():r2(n2());if(v instanceof o1&&v.status===403)return j?VZ():r2(n2());throw v}},Z)}}function O4(){let $=JSON.stringify({error:x1("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 L5 extends x0{routes={"/api-routes":this.get(()=>{let $=I(Wj).flatRoutes,Z=[];for(let[O,j]of Object.entries($))for(let[J,W]of Object.entries(j)){let{exec:z,middleware:Y}=W;Z.push({path:O,method:J,middleware:Y})}return Z}),"/view-routes":this.get(()=>{let $=I(I3).flatViewRoutes,Z=[];for(let[O,{middleware:j,viewPath:J}]of Object.entries($))Z.push({path:O,method:"GET",viewPath:J,middleware:j});return Z})}}var HT=new Set([H1,"cookie","content-type","content-length","transfer-encoding","connection","host","user-agent","forwarded"]),xT=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,AT=/^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]*$/;function ET($,Z,O){for(let[j,J]of Object.entries(O.headers??{})){if(J===void 0||J===null)continue;let W=j.toLowerCase();if(HT.has(W)||W.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,J)}for(let[j,J]of Object.entries(O.cookies??{})){if(J===void 0||J===null)continue;if(j===H1)throw Error(`dispatchAs: credentials may not set the "${H1}" cookie. The access token stays the initiator's.`);if(!xT.test(j)||!AT.test(J))throw Error(`dispatchAs: "${j}" is not a cookie a Cookie header can carry.`);Z.push(`${j}=${J}`)}}function bT($,Z){let O=$.body.getReader(),j=!1,J=()=>{if(j)return;j=!0;try{Z()}catch(z){console.error(z)}},W=new ReadableStream({async pull(z){let Y;try{Y=await O.read()}catch(X){J(),z.error(X);return}if(Y.done){J();try{z.close()}catch{}return}try{z.enqueue(Y.value)}catch{}},async cancel(z){try{await O.cancel(z)}finally{J()}}},{highWaterMark:0});return new Response(W,{status:$.status,statusText:$.statusText,headers:$.headers})}function V5($){let{status:Z=400,data:O,headers:j}=$,J=new Headers({"Content-Type":"application/json",...j});if(!J.has("Cache-Control"))J.set("Cache-Control","no-store");return new Response(JSON.stringify(O),{status:Z,headers:J})}function C5($,Z,O){let j=[];Z?.forEach((z,Y)=>j.push([Y,z]));let J=[...typeof Z?.getSetCookie==="function"?Z.getSetCookie():[],...Array.from(O??[])];if(j.length===0&&J.length===0)return $;let W=(z)=>{for(let[Y,X]of j){if(Y.toLowerCase()==="set-cookie")continue;if(!z.has(Y))z.set(Y,X)}for(let Y of J)z.append("Set-Cookie",Y)};try{return W($.headers),$}catch{let z=new Headers($.headers);return W(z),new Response($.body,{status:$.status,statusText:$.statusText,headers:z})}}class Wj{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let Z=M9();this.onRequestStart=$.onRequestStart??Z.onRequestStart,this.onRequestEnd=$.onRequestEnd??Z.onRequestEnd,this.onRequestFail=$.onRequestFail??Z.onRequestFail,this.flatRoutes=_2({"/":$.rootRouter,"/auth":V2,"/__gemi__/services/i18n":C2,"/__gemi__/services/logs":L2,"/__gemi__/services/image":N2,"/__gemi__/debug":L5})}getRouteHandlerAndParams($){let Z=new URL($.url),O=N5(Z.pathname),j={},J;for(let[W]of Object.entries(this.flatRoutes))try{let z=new URLPattern({pathname:W});if(z.test({pathname:O})){J=W,j=z.exec({pathname:O})?.pathname.groups;break}}catch(z){console.error(z)}return{params:j,path:J}}async runRouteMiddleware($,Z){let j=this.flatRoutes[$][Z.rawRequest.method].middleware;try{await I(TZ).runMiddleware(j)}catch(J){if(J.kind===C3)return V5(J.payload.api);else{if(IZ(J))return O4();if(this.onRequestFail(Z,J),console.error(J),M3(J))return VZ();throw J}}}async getRouteData($){let Z=this.flatRoutes[$],O=x.getStore(),j=Z[O.req.rawRequest.method].exec??(()=>Promise.resolve({})),J={};try{J=await j()}catch(W){if(W.kind===C3)return V5(W.payload.api);if(IZ(W))return O4();if(this.onRequestFail(O.req,W),console.error(W),M3(W))return VZ();throw W}return J}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,Z,O){let j=async()=>{try{if(!this.isFrameworkRoute(O))await this.onRequestEnd(Z)}catch(J){L$.error(J?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(J)})}finally{$.destroy()}};if(!$.hasPendingWork()){await j();return}$.whenIdle().then(j).catch((J)=>{console.error(J)})}isOpenEndedBody($,Z){return $.method!=="HEAD"&&!Z.headers.has("Content-Length")&&Z.body!==null}async handleApiRequest($,Z){let{params:O,path:j}=this.getRouteHandlerAndParams($),J=this.flatRoutes[j];if(!J||!J[$.method])return new Response(JSON.stringify({error:x1("not_found","Not found",404)}),{status:404});let W=new A($,O,"api",j);if(!this.isFrameworkRoute(j))this.onRequestStart(W);return await x.run(W,async()=>{let z=x.getStore(),Y=!1,X=async()=>{Y=!0,await this.endRequest(z,W,j)};try{let G=I(s);if(G.isEnabled){let B=G.detectLocale(W);z.setLocale(B)}z.setRequest(W),I(TZ).applyDefaultBodyLimit($);let F=await this.runRouteMiddleware(j,W);if(F instanceof Response){let B=C5(F,z.headers,z.cookies);return await X(),B}let K=await this.getRouteData(j),T=z.headers,U=z.cookies;if(K instanceof Response){let B=C5(K,T,U);if(this.isOpenEndedBody($,B)){let D=bT(B,()=>this.endRequest(z,W,j));return Y=!0,D}return await X(),B}let Q=(A$(K)?K:t1.json(K)).toResponse(T,U);return await X(),Q}catch(G){if(!Y)try{await X()}catch(F){console.error(F)}throw G}},Z)}async dispatchAs($,Z,O,j,J){let W=new URL($.rawRequest.url).origin,z=new URL(`${W}/api${O}`),Y=`/api${O.split(/[?#]/)[0]}`;if(!O.startsWith("/")||z.origin!==W||z.pathname!==Y||z.hash!==""||z.pathname.startsWith("/api/__gemi__")||z.pathname==="/api/auth"||z.pathname.startsWith("/api/auth/"))throw Error(`dispatchAs: "${O}" is not an app api path. Pass the route's own path, without "/api", with every param encoded.`);let X=new Headers,G=[],F=$.cookies.get(H1);if(F)G.push(`${H1}=${F}`);if(J?.credentials)ET(X,G,J.credentials);if(G.length>0)X.set("Cookie",G.join("; "));let K=$.headers.get(H1);if(K)X.set(H1,K);let T=$.headers.get("User-Agent");if(T)X.set("User-Agent",T);let U;if(j instanceof FormData)U=j;else if(j!==void 0)X.set("Content-Type","application/json"),U=JSON.stringify(j);let Q=new Request(z,{method:Z,headers:X,body:U});if(M5(Q,b$($)),$.domain)MZ(Q,$.domain);return x.exit(()=>I5.exit(()=>this.handleApiRequest(Q)))}}import{timingSafeEqual as RT}from"crypto";var Yj="",W4="*",vT=60000,wT=1e4,j4=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,zj=16,_5=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,J4="x-forwarded-host";function P5($){return $.startsWith(":")}function z4($,Z){if($===null)return!1;let O=Buffer.from($,"utf8"),j=Buffer.from(Z,"utf8");return O.length===j.length&&RT(O,j)}function kT($){if(!$)return null;if($===!0)return{header:J4,secret:null};return{header:($.hostHeader??J4).toLowerCase(),secret:$.secret?{header:$.secret.header.toLowerCase(),value:$.secret.value}:null}}function qT($){if(!$||$===!0)return;let{hostHeader:Z,secret:O}=$;if(Z!==void 0&&(typeof Z!=="string"||!_5.test(Z)))throw Error(`\`route.domains.trustProxy.hostHeader\` must be a single header name, e.g. "x-forwarded-host". Got ${JSON.stringify(Z)}.`);if(!O)return;if(typeof O.header!=="string"||!_5.test(O.header))throw Error(`\`route.domains.trustProxy.secret.header\` must be a header name. Got "${O.header}".`);if(O.header.toLowerCase()===(Z??J4).toLowerCase())throw Error("`route.domains.trustProxy.secret.header` names the same header as `hostHeader`; the secret needs a header of its own.");if(typeof O.value!=="string"||O.value.length<zj)throw Error(`\`route.domains.trustProxy.secret.value\` must be at least ${zj} 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 gT($){try{let Z=new URL(`http://${$.trim()}`),O=Z.hostname.toLowerCase().replace(/\.$/,"");return O?Z.port?`${O}:${Z.port}`:O:null}catch{return null}}function yT($){let Z=X1($.root),O=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!Z||Z!==O||!Z.split(".").every((W)=>j4.test(W)))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<zj)throw Error(`\`route.domains.ask.secret\` must be at least ${zj} characters. A guessable one is worse than leaving \`ask\` out.`);qT($.trustProxy);let j=new Set,J=null;for(let W of $.groups??[]){let{subdomain:z}=W;if(j.has(z))throw Error(`\`route.domains\` declares the subdomain "${z}" twice.`);if(j.add(z),P5(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(J)throw Error(`\`route.domains\` declares two param subdomains, "${J.subdomain}" and "${z}"; a host could match either.`);J=W;continue}if(W.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((Y)=>j4.test(Y)))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&&J&&!J.exists)throw Error(`\`route.domains.ask\` is set, so "${J.subdomain}" needs an \`exists\` to say which tenants are real. Without one every host under the root would be approved for a certificate.`)}class Y4{root;hostTrust;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;proxySecretHeader;constructor($){yT($),this.root=X1($.root),this.hostTrust=kT($.trustProxy);for(let Z of $.groups??[])if(P5(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??vT,this.askSecret=$.ask?.secret??null,this.proxySecretHeader=this.hostTrust?.secret?.header??null}forwardedHost($){let Z=this.hostTrust;if(!Z)return null;if(Z.secret&&!z4($.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),O=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),j=O==="http"||O==="https"?O:Z.protocol.replace(/:$/,""),J=this.forwardedHost($),W=J&&X1(J)?gT(J):null;return`${j}://${W??Z.host}`}async resolve($){let Z=this.hostOf($);if(!Z)return null;let O=await this.match(Z,$);if(O)return O;if(this.custom?.fallback&&!this.isUnderRoot(Z))return{host:Z,group:W4,params:{},custom:!0};return null}async allows($,Z){let O=X1($);return O?await this.match(O,Z)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,Z){if($===this.root)return{host:$,group:Yj,params:{},custom:!1};if($.endsWith(`.${this.root}`)){let j=$.slice(0,-(this.root.length+1)),J=this.fixed.get(j);if(J)return{host:$,group:J.subdomain,params:{},custom:!1};if(this.param&&j4.test(j)){let W={[this.param.name]:j};if(this.param.exists&&!await this.param.exists(W,Z))return null;return{host:$,group:this.param.subdomain,params:W,custom:!1}}return null}if(!this.custom)return null;let O=await this.resolveCustom($);return O?{host:$,group:this.custom.group,params:O,custom:!0}:null}async resolveCustom($){let Z=Date.now(),O=this.cache.get($);if(O&&O.expiresAt>Z)return this.cache.delete($),this.cache.set($,O),O.value;let j=this.inFlight.get($);if(j)return j;let J=(async()=>await this.custom.resolve($)??null)();this.inFlight.set($,J);let W;try{W=await J}finally{this.inFlight.delete($)}if(this.cacheTtlMs>0){if(this.cache.size>=wT)this.cache.delete(this.cache.keys().next().value);this.cache.delete($),this.cache.set($,{value:W,expiresAt:Date.now()+this.cacheTtlMs})}return W}forget($){if($===void 0)this.cache.clear();else{let Z=X1($);if(Z)this.cache.delete(Z)}}}var mT="/__gemi__/domains/ask";class r0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,Z){this.groups.set(Yj,$);let{domains:O}=Z;if(this.acceptsCustomDomains=Boolean(O?.custom),!O){this.resolver=null;return}this.resolver=new Y4(O);let j=(J)=>({api:J.api?new Wj({...Z.api,...J.api}):$.api,view:J.view?new I3({...Z.view,...J.view}):$.view});for(let J of O.groups??[])this.groups.set(J.subdomain,j(J));if(O.custom?.fallback)this.groups.set(W4,j(O.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);if(this.resolver.proxySecretHeader)S5($,this.resolver.proxySecretHeader);let Z=await this.resolver.resolve($);if(!Z)return null;return MZ($,Z),this.dispatchers(Z)}async ask($){if(!this.resolver?.askSecret||$.method!=="GET")return null;let Z=new URL($.url);if(Z.pathname!==mT)return null;if(!z4(Z.searchParams.get("secret"),this.resolver.askSecret))return null;let O=Z.searchParams.get("domain"),j=O?await this.resolver.allows(O,$):!1;return new Response(null,{status:j?200:404})}dispatchers($){return this.groups.get($?.group??Yj)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}}function Xj($){let Z=new Date($??0).getTime();return Number.isFinite(Z)?Z:0}var f5=600000;function H5($,Z){return[v3($,Z),v3($,Z-1)]}class E{static token="auth";config;provider;constructor($={},Z=new mj){this.config={...x5(YJ($),$),emailCode:gj($.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(r0)?I(r0).resolver:null;return Z?Z.publicOrigin($.rawRequest):new URL($.rawRequest.url).origin}cookieDomain($){let Z=this.config.cookieDomain;if(!Z)return;let O=Z==="root"?I(r0).resolver?.root:X1(Z);if(!O)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let j=$.domain?.host??X1(new URL($.rawRequest.url).host);return j===O||j?.endsWith(`.${O}`)?O:void 0}async getSession($,Z){if(!$)return null;if(!Ej($))return this.config.migrateLegacySession?this.convertLegacySession($,Z,this.config.migrateLegacySession):null;let O=await this.userProvider.findSession({token:$,userAgent:Z});if(!O?.user)return null;let j=Date.now(),J=Xj(O.expiresAt),W=Xj(O.absoluteExpiresAt);if(J<=j||W<=j)return await this.userProvider.deleteSession({token:$}),null;let Y=await this.slideSession(O,j);return Y.user.extension=await this.config.extendSession(Y.user),Y}async convertLegacySession($,Z,O){let j=x.getStore()?.req;if(!j)return null;let J=Date.now(),W=Math.floor(J/f5),z=null,Y=await this.userProvider.findSession({token:$,userAgent:Z});if(Y?.user){if(!await O(Y,{token:$,req:j,userAgent:Z}))return null;let G=v3($,W),F=Y.user.id;if(await this.userProvider.withLegacySessionLock($,async()=>{if(!await this.userProvider.claimLegacySession({token:$}))return!1;return await this.userProvider.createSessionV2({token:G,userId:F,userAgent:Z,...this.freshLifetime(J)}),!0}))z=G}if(!z){for(let G of H5($,W))if((await this.userProvider.findSession({token:G,userAgent:Z}))?.user){z=G;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(Ej($)||!this.config.migrateLegacySession){let J=await this.userProvider.findSession({token:$,userAgent:Z});return await this.userProvider.deleteSession({token:$}),J}let O=Math.floor(Date.now()/f5),j=H5($,O);return this.userProvider.withLegacySessionLock($,async()=>{let J=await this.userProvider.findSession({token:$,userAgent:Z});for(let W of j){if(J?.user)break;J=await this.userProvider.findSession({token:W,userAgent:Z})}await this.userProvider.deleteSession({token:$});for(let W of j)await this.userProvider.deleteSession({token:W});return J})}requestCarryingCookie($){let Z=x.getStore()?.req;return Z?.cookies.get("access_token")===$?Z:null}async slideSession($,Z){let O=this.config.sessionExpiresInHours*3600000;if(new Date($.expiresAt).getTime()-Z>=O/2)return $;let j=new Date(Math.min(Z+O,new Date($.absoluteExpiresAt).getTime())),J=await this.userProvider.updateSession({token:$.token,expiresAt:j}),W=this.requestCarryingCookie($.token);if(W)W.ctx().setCookie("access_token",$.token,this.accessTokenCookieOptions(W,j));if(!J)return $;return{...$,expiresAt:J.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 O=await this.createOrUpdateSession({email:$,id:Z.id}),j=new A;if(j.ctx().setCookie("access_token",O.token,this.accessTokenCookieOptions(j,O.expiresAt)),O?.user)O.user.extension=await this.config.extendSession(O.user);return O}catch(Z){console.log(Z)}}async createOrUpdateSessionV2($){let Z=await this.createOrUpdateSession($),O=null;if(Z?.user)O=await this.config.extendSession(Z.user),Z.user.extension=O;return Z}async createOrUpdateSession($){let Z=new A,O=$.id??(await this.userProvider.findUserByEmailAddress($.email,!1))?.id;if(!O)throw new e1;let j=Bun.env.NODE_ENV==="development"?"local":Z.headers.get("User-Agent"),J=o4(O),W=await this.userProvider.createSessionV2({token:J,userId:O,userAgent:j,...this.freshLifetime(Date.now())}),z=await this.userProvider.findSession({token:J,userAgent:j??""});return z?.user?z:W}async createMagicLinkToken($){let Z=await this.userProvider.findUserByEmailAddress($,!1);if(Z){let{pin:O,token:j}=await this.issueOneTimeCode($,6);return{user:Z,email:$,pin:O,token:j}}return{}}async issueOneTimeCode($,Z){await this.userProvider.deleteMagicLinkToken($);let O=await this.config.generateMagicLinkToken($),j=await this.config.generateCode($),J=typeof j==="string"&&j!==""?j:jJ(Z);return await this.userProvider.createMagicLinkToken({email:$,token:w3("link",$,O),pin:w3("pin",$,J)}),{email:$,pin:J,token:O}}async verifyOneTimeCode($,Z,O={}){let{expiresInMinutes:j,maxAttempts:J}=this.config.emailCode,W=await this.userProvider.findMagicLinkTokenByEmail($);if(!W)return qZ("pin",$,null,Z),{status:"invalid"};let z=Xj(W.createdAt);if(z+j*60000<=Date.now())return qZ("pin",$,null,Z),{status:"expired"};if(!await zJ(W.id,z,J,j))return await this.userProvider.claimMagicLinkToken(W.id),{status:"too_many_attempts"};if(!qZ("pin",$,W.pin,Z))return{status:"invalid"};if(O.claim!==!1&&!await this.userProvider.claimMagicLinkToken(W.id))return{status:"invalid"};return{status:"ok",row:W}}async verifyMagicLinkToken($,Z){let O=await this.userProvider.findMagicLinkTokenByEmail($),j=qZ("link",$,O?.token,Z);if(!O||!j)return!1;if(Xj(O.createdAt)+this.config.emailCode.linkExpiresInMinutes*60000<=Date.now())return!1;return await this.userProvider.claimMagicLinkToken(O.id)}}class M$ extends B0{static getFacadeAccessor(){return E}static async user(){let $=x.getStore(),Z=$?.user;if(!Z){if(Z=await E3(this.getFacadeRoot(),$?.req),Z)$?.setUser(Z)}if(Z)return Z;throw new e1({redirectTo:A3($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let Z=x.getStore()?.req;return xZ(Z?.search.get(E$),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let Z=await M$.user();if(!await $(Z))throw new xj}static async guardSafe($){let Z=await M$.user();try{return await $(Z)}catch(O){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class Gj{static ensure($,Z={}){let O=x.getStore();if(O.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return O.serverQueries??=new DZ(V3(O.req.rawRequest)),O.serverQueries.ensure($,Z,"prefetch")}static async instant($,...Z){let O=Gj.ensure($,Z[0]);if(await O.promise,O.status==="rejected")throw O.error;return O.data}static prefetch($,...Z){Gj.ensure($,Z[0])}static noPrefetch(){let $=x.getStore();if($.req.kind==="api")throw Error("Query.noPrefetch() cannot be called from an API request");$.serverQueries??=new DZ(V3($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}function A5($,Z,O="/"){let j=new URL($.origin),J=Z.host?Z.host:Z.subdomain?`${Z.subdomain}.${$.root}`:$.root,W=new URL(O.startsWith("/")?O:`/${O}`,j),z=pT(J);if(!z)throw Error(`"${J}" 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(W.hostname=z.hostname,z.port)W.port=z.port;return W.toString()}function pT($){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 E5{static absolute($,...Z){return`${process.env.HOST_NAME}${J0(String($),Z[0]??{})}`}static relative($,...Z){return J0(String($),Z[0]??{})}static forDomain($,Z,...O){let j=I(r0).resolver;if(!j)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let J=x.getStore()?.req?.rawRequest,W=J?j.publicOrigin(J):process.env.HOST_NAME;if(!W)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return A5({root:j.root,origin:W},$,J0(String(Z),O[0]??{}))}}class b5{name="Meta";static description($){x.getStore().metadata.description($)}static title($){x.getStore().metadata.title($)}static openGraph($){x.getStore().metadata.openGraph($)}}var hT={set($,Z,O){x.getStore().setCookie($,Z,O)},setIfAbsent($,Z,O){if(x.getStore().req.cookies.has($))return!1;return x.getStore().setCookie($,Z,O),!0},delete($,Z){x.getStore().deleteCookie($,Z)}};class _1 extends B0{static getFacadeAccessor(){return R5}static get client(){return this.getFacadeRoot().client}static get($){return _1.client.get($)}static set($,Z){return _1.client.set($,Z)}static del(...$){return _1.client.del(...$)}static exists($){return _1.client.exists($)}static incr($){return _1.client.incr($)}static expire($,Z){return _1.client.expire($,Z)}static ttl($){return _1.client.ttl($)}}class v5 extends B0{static getFacadeAccessor(){return e0}static consume($,Z={}){return this.getFacadeRoot().consume($,Z)}}class k5 extends B0{static getFacadeAccessor(){return w5}static run($,Z,O){return this.getFacadeRoot().run($,Z,O)}static acquire($,Z={}){return this.getFacadeRoot().acquire($,Z)}}class q5 extends B0{static getFacadeAccessor(){return BZ}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,O){return this.getFacadeRoot().set($,Z,O)}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class Fj{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,O=this.connection(Z);return m5(O.sql,(j)=>g5(Z,()=>$(j)),{slowTransactionThreshold:O.config.slowTransactionThreshold,connection:Z})}async schema(){let $=this.connection(),{introspect:Z}=await import("./chunk-r9gzbjc5.js");return Z(this.handle()??$.sql,$.dialect)}run($,Z){let O=this.connection(),{text:j,values:J}=h5($,p5(O.dialect),Z);return(this.handle()??O.sql).unsafe(j,J)}handle(){let $=yZ();if($===void 0)return;return mZ()===this.name?$:void 0}connection($=this.name){return y5($),I(pZ).connection($)}}var NZ=new Fj;class c5 extends B0{static getFacadeAccessor(){return pZ}static connection($){return new Fj($)}static get sql(){return NZ.sql}static get dialect(){return NZ.dialect}static query($){return NZ.query($)}static execute($){return NZ.execute($)}static transaction($){return NZ.transaction($)}static schema(){return NZ.schema()}static close(){return this.getFacadeRoot().close()}}export{G1 as ic,SZ as jc,Bj as kc,x$ as lc,HZ as mc,x0 as nc,Ij as oc,Nj as pc,L4 as qc,x3 as rc,t1 as sc,z7 as tc,_j as uc,f1 as vc,V0 as wc,Y7 as xc,X7 as yc,Aj as zc,Ej as Ac,o4 as Bc,e0 as Cc,AZ as Dc,q4 as Ec,b$ as Fc,r4 as Gc,t4 as Hc,Rj as Ic,vj as Jc,w3 as Kc,qZ as Lc,FQ as Mc,YJ as Nc,u7 as Oc,mj as Pc,M$ as Qc,a1 as Rc,Gj as Sc,E5 as Tc,b5 as Uc,hT as Vc,_1 as Wc,v5 as Xc,k5 as Yc,e9 as Zc,i2 as _c,$5 as $c,Z5 as ad,eF as bd,O5 as cd,u2 as dd,OT as ed,jT as fd,s2 as gd,j5 as hd,J5 as id,BZ as jd,q5 as kd,Fj as ld,c5 as md,M2 as nd,I2 as od,tQ as pd,D9 as qd,V9 as rd,b3 as sd,TZ as td,QB as ud,M9 as vd,I9 as wd,l2 as xd,VZ as yd,n2 as zd,fD as Ad,$4 as Bd,_T as Cd,r2 as Dd,fT as Ed,I3 as Fd,O4 as Gd,V5 as Hd,C5 as Id,Wj as Jd,r0 as Kd,E as Ld,E4 as Md,b4 as Nd,R4 as Od,m4 as Pd,p4 as Qd,h4 as Rd,R$ as Sd,X0 as Td,T1 as Ud,w$ as Vd,A1 as Wd,k$ as Xd,q$ as Yd,g$ as Zd,RZ as _d,vZ as $d,E1 as ae,kZ as be,u4 as ce};
16
+
17
+ //# debugId=11384551F860111464756E2164756E21