gemi 0.58.1 → 0.60.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 (231) hide show
  1. package/dist/ai/Agent.d.ts +33 -0
  2. package/dist/ai/Agent.d.ts.map +1 -0
  3. package/dist/ai/AgentController.d.ts +8 -0
  4. package/dist/ai/AgentController.d.ts.map +1 -0
  5. package/dist/ai/useChat.d.ts +12 -0
  6. package/dist/ai/useChat.d.ts.map +1 -0
  7. package/dist/app/index.js +1 -1
  8. package/dist/bin/gemi.js +500 -16
  9. package/dist/bin/gemi.js.map +10 -5
  10. package/dist/broadcasting/index.js +1 -1
  11. package/dist/bun/plugin.js +1 -1
  12. package/dist/bun/preload.js +1 -1
  13. package/dist/{chunk-szss069z.js → chunk-06j6rsew.js} +2 -2
  14. package/dist/{chunk-szss069z.js.map → chunk-06j6rsew.js.map} +1 -1
  15. package/dist/{chunk-yjzs247s.js → chunk-0fm6jh9b.js} +2 -2
  16. package/dist/{chunk-yjzs247s.js.map → chunk-0fm6jh9b.js.map} +1 -1
  17. package/dist/chunk-23h0dmx2.js +5 -0
  18. package/dist/{chunk-87qab82w.js.map → chunk-23h0dmx2.js.map} +3 -3
  19. package/dist/{chunk-m3xy5xyf.js → chunk-2cwcfwg3.js} +2 -2
  20. package/dist/{chunk-m3xy5xyf.js.map → chunk-2cwcfwg3.js.map} +1 -1
  21. package/dist/{chunk-xzk827r3.js → chunk-2khdxyjb.js} +2 -2
  22. package/dist/{chunk-xzk827r3.js.map → chunk-2khdxyjb.js.map} +1 -1
  23. package/dist/{chunk-sy7jbdeb.js → chunk-3296fwss.js} +2 -2
  24. package/dist/{chunk-sy7jbdeb.js.map → chunk-3296fwss.js.map} +1 -1
  25. package/dist/{chunk-xdv1b8mr.js → chunk-3gvjn3q4.js} +2 -2
  26. package/dist/{chunk-xdv1b8mr.js.map → chunk-3gvjn3q4.js.map} +1 -1
  27. package/dist/{chunk-jhkjz9jr.js → chunk-4dan69s4.js} +2 -2
  28. package/dist/{chunk-3zxwscmf.js.map → chunk-4dan69s4.js.map} +1 -1
  29. package/dist/{chunk-hxf1re93.js → chunk-4mcyyh1v.js} +2 -2
  30. package/dist/{chunk-hxf1re93.js.map → chunk-4mcyyh1v.js.map} +1 -1
  31. package/dist/{chunk-w62m5f0n.js → chunk-5gdv4n4a.js} +3 -3
  32. package/dist/{chunk-w62m5f0n.js.map → chunk-5gdv4n4a.js.map} +1 -1
  33. package/dist/{chunk-j0c6ytkj.js → chunk-8kj3zrm9.js} +3 -3
  34. package/dist/{chunk-j0c6ytkj.js.map → chunk-8kj3zrm9.js.map} +1 -1
  35. package/dist/{chunk-0a2xgcj3.js → chunk-98a3k7bp.js} +2 -2
  36. package/dist/{chunk-0a2xgcj3.js.map → chunk-98a3k7bp.js.map} +1 -1
  37. package/dist/{chunk-5athahgr.js → chunk-9gsdcjt7.js} +2 -2
  38. package/dist/{chunk-5athahgr.js.map → chunk-9gsdcjt7.js.map} +1 -1
  39. package/dist/{chunk-pmhd6zfc.js → chunk-b0t4zp6b.js} +2 -2
  40. package/dist/{chunk-pmhd6zfc.js.map → chunk-b0t4zp6b.js.map} +1 -1
  41. package/dist/{chunk-3xadx444.js → chunk-bn1v4sfs.js} +2 -2
  42. package/dist/{chunk-3xadx444.js.map → chunk-bn1v4sfs.js.map} +1 -1
  43. package/dist/{chunk-9m2tbf3n.js → chunk-c40n5r4v.js} +2 -2
  44. package/dist/{chunk-9m2tbf3n.js.map → chunk-c40n5r4v.js.map} +1 -1
  45. package/dist/{chunk-a2sgjpvq.js → chunk-cejf873g.js} +2 -2
  46. package/dist/{chunk-a2sgjpvq.js.map → chunk-cejf873g.js.map} +1 -1
  47. package/dist/{chunk-tss5svjr.js → chunk-cw9y6k15.js} +2 -2
  48. package/dist/{chunk-tss5svjr.js.map → chunk-cw9y6k15.js.map} +1 -1
  49. package/dist/{chunk-5n2rvfh3.js → chunk-cyrxdj6a.js} +2 -2
  50. package/dist/{chunk-5n2rvfh3.js.map → chunk-cyrxdj6a.js.map} +1 -1
  51. package/dist/chunk-dgasxgsm.js +19 -0
  52. package/dist/{chunk-hwa5sqw5.js.map → chunk-dgasxgsm.js.map} +6 -6
  53. package/dist/{chunk-3g5bjvdf.js → chunk-f6dd4gd8.js} +2 -2
  54. package/dist/{chunk-3g5bjvdf.js.map → chunk-f6dd4gd8.js.map} +1 -1
  55. package/dist/{chunk-qgxr0g36.js → chunk-fb4cy6sq.js} +2 -2
  56. package/dist/{chunk-qgxr0g36.js.map → chunk-fb4cy6sq.js.map} +1 -1
  57. package/dist/{chunk-7ef5n8k2.js → chunk-fbvvqf9b.js} +2 -2
  58. package/dist/{chunk-7ef5n8k2.js.map → chunk-fbvvqf9b.js.map} +1 -1
  59. package/dist/{chunk-zbxgbr12.js → chunk-fxy42w6n.js} +2 -2
  60. package/dist/{chunk-zbxgbr12.js.map → chunk-fxy42w6n.js.map} +1 -1
  61. package/dist/{chunk-xey9cbap.js → chunk-get4mkx8.js} +2 -2
  62. package/dist/{chunk-xey9cbap.js.map → chunk-get4mkx8.js.map} +1 -1
  63. package/dist/{chunk-3zxwscmf.js → chunk-gwchvzdp.js} +2 -2
  64. package/dist/{chunk-jhkjz9jr.js.map → chunk-gwchvzdp.js.map} +1 -1
  65. package/dist/{chunk-k0fvsyeh.js → chunk-hsfjt13m.js} +1 -1
  66. package/dist/{chunk-yf7vz71n.js → chunk-hwhw98hc.js} +1 -1
  67. package/dist/{chunk-fjm4y8bn.js → chunk-hxb1eg2z.js} +2 -2
  68. package/dist/{chunk-fjm4y8bn.js.map → chunk-hxb1eg2z.js.map} +1 -1
  69. package/dist/{chunk-7b0x860b.js → chunk-j06g4sqc.js} +2 -2
  70. package/dist/{chunk-7b0x860b.js.map → chunk-j06g4sqc.js.map} +1 -1
  71. package/dist/{chunk-dgsgjg53.js → chunk-j23cengk.js} +2 -2
  72. package/dist/{chunk-dgsgjg53.js.map → chunk-j23cengk.js.map} +1 -1
  73. package/dist/{chunk-vj6f2bmb.js → chunk-khf9xda6.js} +3 -3
  74. package/dist/{chunk-vj6f2bmb.js.map → chunk-khf9xda6.js.map} +1 -1
  75. package/dist/{chunk-437085pe.js → chunk-p3qd0gqa.js} +2 -2
  76. package/dist/{chunk-437085pe.js.map → chunk-p3qd0gqa.js.map} +1 -1
  77. package/dist/{chunk-gw6agevz.js → chunk-pkjq9833.js} +3 -3
  78. package/dist/{chunk-gw6agevz.js.map → chunk-pkjq9833.js.map} +1 -1
  79. package/dist/{chunk-7j6wbv12.js → chunk-q0y0j3ne.js} +2 -2
  80. package/dist/{chunk-7j6wbv12.js.map → chunk-q0y0j3ne.js.map} +1 -1
  81. package/dist/chunk-q6qghsy7.js +5 -0
  82. package/dist/{chunk-b35e128b.js.map → chunk-q6qghsy7.js.map} +1 -1
  83. package/dist/{chunk-wbrj0gya.js → chunk-qva4841r.js} +2 -2
  84. package/dist/{chunk-wbrj0gya.js.map → chunk-qva4841r.js.map} +1 -1
  85. package/dist/{chunk-86jebsm4.js → chunk-rkbv3df7.js} +3 -3
  86. package/dist/{chunk-86jebsm4.js.map → chunk-rkbv3df7.js.map} +1 -1
  87. package/dist/{chunk-keehyx51.js → chunk-rpjsmr41.js} +2 -2
  88. package/dist/{chunk-keehyx51.js.map → chunk-rpjsmr41.js.map} +1 -1
  89. package/dist/{chunk-mwpdp09e.js → chunk-spbgpndn.js} +2 -2
  90. package/dist/{chunk-mwpdp09e.js.map → chunk-spbgpndn.js.map} +1 -1
  91. package/dist/{chunk-yy0eb9wn.js → chunk-stq96kya.js} +2 -2
  92. package/dist/{chunk-yy0eb9wn.js.map → chunk-stq96kya.js.map} +1 -1
  93. package/dist/{chunk-d125j8t0.js → chunk-tds3xq6b.js} +3 -3
  94. package/dist/{chunk-d125j8t0.js.map → chunk-tds3xq6b.js.map} +1 -1
  95. package/dist/{chunk-3337e5g0.js → chunk-tey1xayb.js} +2 -2
  96. package/dist/{chunk-3337e5g0.js.map → chunk-tey1xayb.js.map} +1 -1
  97. package/dist/{chunk-w7rf99w6.js → chunk-vj9538yn.js} +2 -2
  98. package/dist/{chunk-w7rf99w6.js.map → chunk-vj9538yn.js.map} +1 -1
  99. package/dist/{chunk-yed5whgs.js → chunk-wcv6qtpq.js} +3 -3
  100. package/dist/{chunk-yed5whgs.js.map → chunk-wcv6qtpq.js.map} +1 -1
  101. package/dist/{chunk-vr90r27j.js → chunk-wzvs3sym.js} +2 -2
  102. package/dist/{chunk-vr90r27j.js.map → chunk-wzvs3sym.js.map} +1 -1
  103. package/dist/{chunk-cyaz97p5.js → chunk-x6y1z4cq.js} +2 -2
  104. package/dist/{chunk-cyaz97p5.js.map → chunk-x6y1z4cq.js.map} +1 -1
  105. package/dist/chunk-x8beq9c4.js +55 -0
  106. package/dist/chunk-x8beq9c4.js.map +11 -0
  107. package/dist/{chunk-6235kb30.js → chunk-xecj8025.js} +3 -3
  108. package/dist/{chunk-6235kb30.js.map → chunk-xecj8025.js.map} +1 -1
  109. package/dist/chunk-y3zz410b.js +6 -0
  110. package/dist/{chunk-4sz6pwtn.js.map → chunk-y3zz410b.js.map} +2 -2
  111. package/dist/{chunk-eejmhtnc.js → chunk-y64j80v9.js} +2 -2
  112. package/dist/{chunk-eejmhtnc.js.map → chunk-y64j80v9.js.map} +1 -1
  113. package/dist/{chunk-zh2egcyb.js → chunk-ygfwtgvm.js} +2 -2
  114. package/dist/{chunk-zh2egcyb.js.map → chunk-ygfwtgvm.js.map} +1 -1
  115. package/dist/{chunk-4yt5x8s2.js → chunk-ys904esh.js} +2 -2
  116. package/dist/{chunk-4yt5x8s2.js.map → chunk-ys904esh.js.map} +1 -1
  117. package/dist/{chunk-y6a8r2bn.js → chunk-z1e55w67.js} +3 -3
  118. package/dist/{chunk-y6a8r2bn.js.map → chunk-z1e55w67.js.map} +1 -1
  119. package/dist/{chunk-qb5mv6pj.js → chunk-z2tcxwyr.js} +3 -3
  120. package/dist/{chunk-qb5mv6pj.js.map → chunk-z2tcxwyr.js.map} +1 -1
  121. package/dist/{chunk-hppagzz4.js → chunk-zhbrkpb3.js} +4 -4
  122. package/dist/{chunk-hppagzz4.js.map → chunk-zhbrkpb3.js.map} +1 -1
  123. package/dist/{chunk-grdahng8.js → chunk-zqsfanvk.js} +2 -2
  124. package/dist/{chunk-grdahng8.js.map → chunk-zqsfanvk.js.map} +1 -1
  125. package/dist/config/index.d.ts +2 -0
  126. package/dist/config/index.d.ts.map +1 -1
  127. package/dist/config/index.js +2 -2
  128. package/dist/config/index.js.map +3 -3
  129. package/dist/console/run.js +2 -2
  130. package/dist/console/run.js.map +1 -1
  131. package/dist/container/index.js +2 -2
  132. package/dist/container/index.js.map +1 -1
  133. package/dist/database/index.js +2 -2
  134. package/dist/database/index.js.map +1 -1
  135. package/dist/email/index.js +2 -2
  136. package/dist/email/index.js.map +1 -1
  137. package/dist/facades/Features.d.ts +67 -1
  138. package/dist/facades/Features.d.ts.map +1 -1
  139. package/dist/facades/index.js +2 -2
  140. package/dist/facades/index.js.map +1 -1
  141. package/dist/foundation/index.js +2 -2
  142. package/dist/foundation/index.js.map +1 -1
  143. package/dist/http/index.js +2 -2
  144. package/dist/http/index.js.map +1 -1
  145. package/dist/i18n/dictionaryRuntime.js +2 -2
  146. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  147. package/dist/i18n/index.js +2 -2
  148. package/dist/i18n/index.js.map +2 -2
  149. package/dist/kernel/index.js +2 -2
  150. package/dist/kernel/index.js.map +1 -1
  151. package/dist/orm/index.js +2 -2
  152. package/dist/orm/index.js.map +1 -1
  153. package/dist/server/Server.d.ts.map +1 -1
  154. package/dist/server/httpDev.d.ts.map +1 -1
  155. package/dist/server/index.js +2 -2
  156. package/dist/server/index.js.map +3 -3
  157. package/dist/services/events/Event.d.ts +6 -0
  158. package/dist/services/events/Event.d.ts.map +1 -1
  159. package/dist/services/features/FeatureFlagStore.d.ts +56 -0
  160. package/dist/services/features/FeatureFlagStore.d.ts.map +1 -1
  161. package/dist/services/features/FeatureManager.d.ts +35 -1
  162. package/dist/services/features/FeatureManager.d.ts.map +1 -1
  163. package/dist/services/features/types.d.ts +62 -0
  164. package/dist/services/features/types.d.ts.map +1 -1
  165. package/dist/services/index.d.ts +2 -2
  166. package/dist/services/index.d.ts.map +1 -1
  167. package/dist/services/index.js +8 -8
  168. package/dist/services/index.js.map +3 -3
  169. package/dist/services/logging/LogManager.d.ts +10 -1
  170. package/dist/services/logging/LogManager.d.ts.map +1 -1
  171. package/dist/services/logging/LogServiceProvider.d.ts +10 -0
  172. package/dist/services/logging/LogServiceProvider.d.ts.map +1 -1
  173. package/dist/support/index.js +2 -2
  174. package/dist/support/index.js.map +1 -1
  175. package/package.json +3 -2
  176. package/skills/gemi-react-best-practices/SKILL.md +231 -0
  177. package/skills/gemi-react-best-practices/rules/_sections.md +56 -0
  178. package/skills/gemi-react-best-practices/rules/_template.md +28 -0
  179. package/skills/gemi-react-best-practices/rules/bundle-deep-imports.md +48 -0
  180. package/skills/gemi-react-best-practices/rules/bundle-mount-gate-heavy-panels.md +63 -0
  181. package/skills/gemi-react-best-practices/rules/client-form-vs-mutation-hooks.md +57 -0
  182. package/skills/gemi-react-best-practices/rules/client-loading-error-exports.md +54 -0
  183. package/skills/gemi-react-best-practices/rules/client-no-effect-data-flow.md +68 -0
  184. package/skills/gemi-react-best-practices/rules/client-typed-links.md +51 -0
  185. package/skills/gemi-react-best-practices/rules/controller-authorize-every-tenant-read.md +65 -0
  186. package/skills/gemi-react-best-practices/rules/controller-parse-request-at-the-boundary.md +54 -0
  187. package/skills/gemi-react-best-practices/rules/controller-redirect-facade-throws.md +68 -0
  188. package/skills/gemi-react-best-practices/rules/controller-request-schema.md +61 -0
  189. package/skills/gemi-react-best-practices/rules/controller-throw-framework-errors.md +57 -0
  190. package/skills/gemi-react-best-practices/rules/i18n-define-dictionary-inline.md +58 -0
  191. package/skills/gemi-react-best-practices/rules/orm-analytics-connection.md +53 -0
  192. package/skills/gemi-react-best-practices/rules/orm-include-not-n-plus-one.md +56 -0
  193. package/skills/gemi-react-best-practices/rules/orm-paginate-helper.md +69 -0
  194. package/skills/gemi-react-best-practices/rules/orm-plain-rows-by-default.md +55 -0
  195. package/skills/gemi-react-best-practices/rules/orm-select-narrow.md +58 -0
  196. package/skills/gemi-react-best-practices/rules/orm-transaction-no-io.md +54 -0
  197. package/skills/gemi-react-best-practices/rules/orm-transaction-sequential.md +64 -0
  198. package/skills/gemi-react-best-practices/rules/payload-dont-overprefetch.md +54 -0
  199. package/skills/gemi-react-best-practices/rules/payload-instant-vs-prefetch.md +58 -0
  200. package/skills/gemi-react-best-practices/rules/payload-minimal-view-props.md +51 -0
  201. package/skills/gemi-react-best-practices/rules/payload-parallel-controller-work.md +56 -0
  202. package/skills/gemi-react-best-practices/rules/payload-prefetch-late-queries.md +58 -0
  203. package/skills/gemi-react-best-practices/rules/payload-prefetch-mirrors-usequery.md +52 -0
  204. package/skills/gemi-react-best-practices/rules/query-debounce-search-variant.md +52 -0
  205. package/skills/gemi-react-best-practices/rules/query-keep-previous-data.md +40 -0
  206. package/skills/gemi-react-best-practices/rules/query-lazy-vs-mount-gate.md +54 -0
  207. package/skills/gemi-react-best-practices/rules/query-mutate-over-refetch.md +55 -0
  208. package/skills/gemi-react-best-practices/rules/query-no-hand-rolled-fetch.md +60 -0
  209. package/skills/gemi-react-best-practices/rules/query-revalidate-on-focus.md +44 -0
  210. package/skills/gemi-react-best-practices/rules/query-share-cache-key.md +51 -0
  211. package/skills/gemi-react-best-practices/rules/query-suspense-default.md +52 -0
  212. package/skills/gemi-react-best-practices/rules/routing-cache-policy-constants.md +53 -0
  213. package/skills/gemi-react-best-practices/rules/routing-middleware-dsl.md +60 -0
  214. package/skills/gemi-react-best-practices/rules/routing-resource-routes.md +59 -0
  215. package/skills/gemi-react-best-practices/rules/routing-routers-are-classes.md +55 -0
  216. package/skills/gemi-react-best-practices/rules/service-lazy-not-module-scope.md +63 -0
  217. package/skills/gemi-react-best-practices/rules/service-queue-is-in-memory.md +52 -0
  218. package/skills/gemi-react-best-practices/rules/service-static-token-and-name.md +52 -0
  219. package/skills/gemi-react-best-practices/rules/structure-discovered-vs-registered.md +71 -0
  220. package/skills/gemi-react-best-practices/rules/structure-do-not-reinvent-the-framework.md +58 -0
  221. package/skills/gemi-react-best-practices/rules/testing-assert-behaviour-over-markup.md +54 -0
  222. package/skills/gemi-react-best-practices/rules/testing-match-the-suite.md +57 -0
  223. package/skills/gemi-react-best-practices/rules/testing-page-seeds-real-inputs.md +65 -0
  224. package/dist/chunk-01e3gk86.js +0 -55
  225. package/dist/chunk-01e3gk86.js.map +0 -11
  226. package/dist/chunk-4sz6pwtn.js +0 -6
  227. package/dist/chunk-87qab82w.js +0 -5
  228. package/dist/chunk-b35e128b.js +0 -5
  229. package/dist/chunk-hwa5sqw5.js +0 -19
  230. /package/dist/{chunk-k0fvsyeh.js.map → chunk-hsfjt13m.js.map} +0 -0
  231. /package/dist/{chunk-yf7vz71n.js.map → chunk-hwhw98hc.js.map} +0 -0
@@ -1,19 +0,0 @@
1
- // @bun
2
- import{$c as a$,Rc as o$,Sc as P1,Tc as r$,Uc as t$,ed as $f}from"./chunk-86jebsm4.js";import{Md as e$,pd as R1}from"./chunk-y6a8r2bn.js";import{Rd as c$,Wd as q$}from"./chunk-7j6wbv12.js";import{$d as c1,De as H,He as l$,Xd as l1,Zd as e1,ee as A0,ge as c,he as Q,le as u1,me as F0,ne as q1,oe as J0,pe as p1,qe as y,re as R,te as p$,ue as r0,ze as Q0}from"./chunk-hxf1re93.js";import{Oe as F$,Pe as v1,Qe as V}from"./chunk-qb5mv6pj.js";import{wf as b}from"./chunk-cyaz97p5.js";import{Af as j,xf as V0}from"./chunk-d125j8t0.js";import{Hf as n0}from"./chunk-jhkjz9jr.js";class _{static getFacadeAccessor(){throw Error(`Facade [${this.name}] does not implement getFacadeAccessor().`)}static getFacadeRoot(){return j(this.getFacadeAccessor())}}import{AsyncLocalStorage as Bf}from"async_hooks";class d0{config;static token="broadcast";publishCb;context=new Bf;constructor($){this.config=$}get channels(){return this.config.channels}onPublish($){this.publishCb=$}publish(...$){let[f,i,z]=$;this.publishCb(f,i,z)}async handleMessage($,f){let i=JSON.parse(f);if(i.type==="subscribe"){let z=Object.entries(this.channels).sort(([U],[Y])=>U.length-Y.length);for(let[U,Y]of z){let O=new URLPattern({pathname:U});if(O.test({pathname:i.topic})){let W=O.exec({pathname:i.topic})?.pathname.groups,C=new Y;if(await C.subscribe.call(C,W))$.subscribe(i.topic);break}}}if(i.type==="broadcast")$.publish(i.topic,JSON.stringify({topic:i.topic,data:i.payload}));if(i.type==="unsubscribe")$.unsubscribe(i.topic)}run($,f){let i=$.get("Cookie"),z=new Map;if(i){let U=i.split(";");for(let Y of U){let[O,W]=Y.split("=");z.set(O.trim(),W.trim())}}this.context.run({headers:$,cookies:z},f)}}class M0 extends _{static getFacadeAccessor(){return d0}static channel($,f){let i=this.getFacadeRoot(),z=i.channels[$];if(!z)return console.error(`Channel ${$} not found`),{publish:()=>{}};let U=new z;return{publish:(Y,O=!1)=>{let W=R($,f);i.publish(W,JSON.stringify({topic:W,data:U.publish(Y)}),O)}}}}class o extends _{static getFacadeAccessor(){return H}static async user(){let $=V.getStore(),f=M0.getFacadeRoot().context.getStore(),i="",z="";if($?.req)i=$.req.cookies.get("access_token"),z=$.req.headers.get("User-Agent");if(f?.cookies)z=f.headers.get("User-Agent"),i=f.cookies.get("access_token");let U=$?.user;if(!U)U=(await this.getFacadeRoot().getSession(i,z))?.user,$?.setUser(U);if(U)return U;throw new p1}static async guard($){let f=await o.user();if(!f)throw new F0;try{if(!await $(f))throw new F0}catch(i){throw new F0}}static async guardSafe($){let f=await o.user();if(!f)return!1;try{return await $(f)}catch(i){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class Z0 extends _{static getFacadeAccessor(){return b}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),f=V.getStore();if(f)return f.locale??$.detectLocale(f.req);return $.defaultLocale}static setLocale($=Z0.locale()){let f=this.getFacadeRoot(),i=$;if(!f.supportedLocales.includes($))i=f.defaultLocale;let z=V.getStore();return z.setCookie("i18n-locale",i,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1}),z.setLocale(i),i}}import{Buffer as Gf}from"buffer";async function C0($){try{return(await import("sharp")).default}catch(f){throw Error(`${$} requires the 'sharp' package. Install it with \`bun add sharp\`.`,{cause:f})}}class l0{async read($){let f=typeof $==="string"?{name:$}:$,i=await this.fetch({name:f.name,bucket:f.bucket});if(!i.ok)throw new J0(f.name);let z=i.headers.get("Content-Type")??"application/octet-stream",U=i.headers.get("ETag")??void 0,Y=i.headers.get("Last-Modified"),O=Y?new Date(Y):void 0;if(f.range){let Z=await i.blob();return{body:Z,start:0,end:Z.size-1,total:Z.size,partial:!1,type:z,etag:U,lastModified:O,name:f.name}}let W=Number(i.headers.get("Content-Length")),C=Number.isFinite(W)?W:0;return{body:i.body,start:0,end:C-1,total:C,partial:!1,type:z,etag:U,lastModified:O,name:f.name}}async size($){let f=typeof $==="string"?$:$.name,i=typeof $==="string"?void 0:$.bucket,z=await this.fetch({name:f,bucket:i});if(!z.ok)throw new J0(f);let U=Number(z.headers.get("Content-Length"));if(Number.isFinite(U))return await z.body?.cancel(),U;return(await z.blob()).size}}import{readdir as If}from"fs/promises";class u0 extends l0{folderPath;constructor($=`${process.env.ROOT_DIR}/storage`){super();this.folderPath=$}async put($){let f,i;if($ instanceof Blob)f=$,i=`${Bun.randomUUIDv7()}.${$.type.split("/")[1].split(";")[0]}`;else f=$.body,i=$.name;let z=f instanceof Buffer?f:f instanceof Blob||f instanceof File?Buffer.from(await f.arrayBuffer()):"",U=`${this.folderPath}/${i}`;return await Bun.write(U,z),i}async fetch($){let f=process.env.BUCKET_NAME,i;if(typeof $==="string")i=$;else f=$.bucket??f,i=$.name;if(!i)throw Error("Object name has to be specified");let z=`${this.folderPath}/${i}`,U=Bun.file(z),Y=Bun.file(z).stream(),O=new Date(U.lastModified).toUTCString();return new Response(Y,{headers:{"Content-Type":U.type,"Content-Length":String(U.size),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":O}})}async read($){let f=typeof $==="string"?{name:$}:$,{name:i,range:z=null}=f;if(!i)throw Error("Object name has to be specified");let U=Bun.file(`${this.folderPath}/${i}`);if(!await U.exists())throw new J0(i);let Y=U.size,O=z?c1(z,Y):null;if(z&&!O)throw new q1(Y);let W=O?.start??0,C=O?O.end:Y-1;return{body:O?U.slice(W,C+1):U,start:W,end:C,total:Y,partial:Boolean(O),type:U.type||"application/octet-stream",lastModified:new Date(U.lastModified),name:i}}async size($){let f=typeof $==="string"?$:$.name,i=Bun.file(`${this.folderPath}/${f}`);if(!await i.exists())throw new J0(f);return i.size}async list(){return await If(this.folderPath)}}function Fi($){return $}function y1(){return{driver:new u0}}class s0{static token="filesystem";driver;constructor($={}){this.driver=$.driver??y1().driver}}class d1 extends _{static getFacadeAccessor(){return s0}static async put($){return this.getFacadeRoot().driver.put($)}static async metadata($){let f=Gf.from(await $.arrayBuffer()),i=await C0("Storage.metadata()");try{return await i(f).metadata()}catch{return{}}}static async fetch($){return this.getFacadeRoot().driver.fetch($)}static async read($,f={}){let i=typeof $==="string"?{name:$}:{...$},z="range"in f?f.range??null:i.range!==void 0?i.range:V.getStore()?.rangeRequest??null;return this.getFacadeRoot().driver.read({...i,range:z})}static list($){return this.getFacadeRoot().driver.list($)}static delete(){}}function n1($){return Object.fromEntries(Object.entries($).filter(([,f])=>{return f!==null&&f!==void 0}))}var jf=50;class X0{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($,f){return[$,f].filter((i)=>i.length>0).join("?")}markRenderStart(){if(this.renderStartedAt===null)this.renderStartedAt=performance.now()}markShell(){if(this.shellAt===null)this.shellAt=this.elapsed()}summarize($){let f=this.elapsed();return{shellAt:this.shellAt??f,settledAt:f,aborted:$,queries:Array.from(this.entries.values(),(i)=>({path:i.path,variantKey:i.variantKey,startedAt:i.startedAt,settledAt:i.settledAt,status:i.status,source:i.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 f="";try{let U=JSON.stringify($.data)?.length??0;f=U>=1024?`${(U/1024).toFixed(1)} kB`:`${U} B`}catch{f="an unserializable payload"}let i=($.settledAt??0)-$.startedAt,z=$.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 (${i}ms, resolved ${f}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${z})\` 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 ${f}. 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($,f){return this.entries.get(this.keyFor($,f))}ensure($,f={},i="render"){let z=f.params??{},U=new URLSearchParams(n1(f.search??{}));U.delete("json"),U.sort();let Y=R($,z),O=U.toString(),W=this.keyFor(Y,O),C=this.entries.get(W);if(C)return C;let Z;if(i==="render"&&this.renderStartedAt!==null){let L=Math.round(performance.now()-this.renderStartedAt);if(L>jf)Z=L}let X,B=new Promise((L)=>{X=L}),J={path:Y,patternPath:$,variantKey:O,lateBy:Z,status:"pending",promise:B,source:i,startedAt:this.elapsed()};return this.entries.set(W,J),this.fetcher($,z,U).then((L)=>{J.status="resolved",J.data=L},(L)=>{J.status="rejected",J.error=L}).then(()=>{if(J.settledAt=this.elapsed(),this.maybeLogLateDiscovery(J),J.status==="rejected"&&this.failListener)this.failListener(J);if(this.settleListener)this.settleListener(J);else this.settledBacklog.push(J);X()}),J}async allSettled(){let $=0;while($!==this.entries.size)$=this.entries.size,await Promise.all(Array.from(this.entries.values(),(f)=>f.promise))}snapshotResolved(){let $={};for(let[f,i]of this.entries){if(i.status!=="resolved")continue;this.shipped.add(f),$[i.path]??={},$[i.path][i.variantKey]=i.data}return $}onSettle($){this.settleListener=(i)=>{if(this.shipped.has(this.keyFor(i.path,i.variantKey)))return;$(i)};let f=this.settledBacklog;this.settledBacklog=[];for(let i of f)this.settleListener(i)}}class w0 extends Error{path;variantKey;status;body;constructor($,f,i,z){super(typeof z?.message==="string"?z.message:`Request to /api${$} failed with status ${i}`);this.path=$;this.variantKey=f;this.status=i;this.body=z;this.name="QueryError"}}class o0 extends Q{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class s1 extends Q{schema={email:{required:"Email is required",email:"Invalid email"}}}class o1 extends Q{schema={password:{required:"Password is required",password:"Invalid password"}}}class S extends l1{async me(){let $=await o.user();if(!$)throw new u1;return $}async verifyEmail($=new Q){let f=await $.input(),{userProvider:i}=j(H),z=await i.findUserByVerificationToken(f.get("token"));if(!z)return{email:null};return await i.verifyUser(z.email),{email:z.email}}async signInWithMagicLink($=new Q){let f=j(H),{userProvider:i}=f,z=$.search.get("token"),U=decodeURIComponent($.search.get("email")).toLowerCase().trim(),Y=null;try{Y=await i.findUserMagicLinkToken({email:U,token:z})}catch(C){return console.log(C),{error:JSON.stringify(C)}}if(!Y)return{error:"Invalid token"};await i.verifyUser(U),await i.deleteMagicLinkToken(U);let O=await f.createOrUpdateSession({email:U}),W=new URL($.rawRequest.url);return $.ctx().setCookie("access_token",O.token,{expires:O.expiresAt,secure:!W.origin.includes("localhost"),httpOnly:!0}),await f.config.onSignIn(O,$.search.toJSON()),{session:O}}async signInWithPinV2($=new Q){let f=j(H),{userProvider:i}=f,z=await $.input(),{email:U,pin:Y}=z.toJSON(),O=U.toLowerCase().trim();if(!await i.findUserMagicLinkToken({email:O,pin:Y}))throw new c({pin:["Invalid pin"]});await i.deleteMagicLinkToken(O),await i.verifyUser(O);let C=await f.createOrUpdateSessionV2({email:O}),Z=new URL($.rawRequest.url);return $.ctx().setCookie("access_token",C.token,{expires:C.expiresAt,secure:!Z.origin.includes("localhost"),httpOnly:!0}),await f.config.onSignIn(C,$.search.toJSON()),C}async signInWithPin($=new Q){let f=j(H),{userProvider:i}=f,z=await $.input(),{email:U,pin:Y}=z.toJSON(),O=U.toLowerCase().trim();if(!await i.findUserMagicLinkToken({email:O,pin:Y}))throw new c({pin:["Invalid pin"]});await i.deleteMagicLinkToken(O),await i.verifyUser(O);let C=await f.createOrUpdateSession({email:O}),Z=new URL($.rawRequest.url);return $.ctx().setCookie("access_token",C.token,{expires:C.expiresAt,secure:!Z.origin.includes("localhost"),httpOnly:!0}),await f.config.onSignIn(C,$.search.toJSON()),{session:C}}async signInV2($=new o0){let f=new URL($.rawRequest.url),i=await $.input(),{email:z,password:U}=i.toJSON(),Y=z.toLowerCase().trim(),O=j(H),W=await O.userProvider.findUserByEmailAddress(Y,O.config.verifyEmail);if(!W)throw new c({invalid_credentials:["Invalid credentials"]});if(!await O.config.verifyPassword(U,W.password))throw new c({invalid_credentials:["Invalid credentials"]});let Z=await O.createOrUpdateSessionV2({email:W.email,id:W.id});$.ctx().setCookie("access_token",Z.token,{expires:Z.expiresAt,secure:!f.origin.includes("localhost"),httpOnly:!0}),await O.config.onSignIn(W,$.search.toJSON());let{password:X,...B}=W;return B}async signIn($=new o0){let f=await $.input(),{email:i,password:z}=f.toJSON(),U=i.toLowerCase().trim(),Y=j(H),O=await Y.userProvider.findUserByEmailAddress(U,Y.config.verifyEmail);if(!O)throw new c({invalid_credentials:["Invalid credentials"]});if(!await Y.config.verifyPassword(z,O.password))throw new c({invalid_credentials:["Invalid credentials"]});let C=await Y.createOrUpdateSession({email:O.email,id:O.id}),Z=new URL($.rawRequest.url);$.ctx().setCookie("access_token",C.token,{expires:C.expiresAt,secure:!Z.origin.includes("localhost"),httpOnly:!0}),await Y.config.onSignIn(O,$.search.toJSON());let{password:X,...B}=O;return B}async signUp(){let $=j(H),{userProvider:f,config:i}=$,z=new i.signUpRequest,U=await z.input(),{email:Y,password:O,name:W,invitationId:C}=U.toJSON(),Z=Y.toLowerCase().trim();if(await f.findUserByEmailAddress(Z,!1))throw new c({email:["Email address already exists"]});let B=await i.hashPassword(O),J=j(b).detectLocale(z),L;if(C)L=await f.findInvitation(C,Z);let G,N="";if(L)G=await f.transaction(async()=>{await f.deleteInvitationById(C);let D=await f.createUser({email:Z,name:W,password:B,emailVerifiedAt:new Date,locale:J});return await f.createAccount({organizationId:L.organizationId,userId:D.id,organizationRole:L.role}),await i.onUserCreated(D),D});else N=await i.generateEmailVerificationToken(Z),G=await f.transaction(async()=>{let D=await f.createUser({email:Z,name:W,password:B,verificationToken:N,locale:J});return await i.onUserCreated(D),D});return await i.onSignUp(G,N,z.search.toJSON()),G}async signOut($=new Q){let f=$.cookies.get("access_token"),i=await o.user(),{userProvider:z,config:U}=j(H);await z.deleteSession({token:f});let Y=new URL($.rawRequest.url);return $.ctx().setCookie("access_token","",{expires:new Date(0),secure:!Y.origin.includes("localhost"),httpOnly:!0}),await U.onSignOut(i),{}}async forgotPassword($=new s1){let i=(await $.input()).get("email").toLowerCase().trim(),{userProvider:z,config:U}=j(H),Y=await z.findUserByEmailAddress(i,U.verifyEmail);if(!Y)return{};let O=await U.generateForgotPasswordToken(Y);return await z.createPasswordResetToken({user:Y,token:O}),await U.onForgotPassword(Y,O),{}}async resetPassword($=new o1){let{userProvider:f,config:i}=j(H),z=await $.input(),{password:U,token:Y}=z.toJSON(),O=await f.findPasswordResetToken({token:Y});if(!O)throw new c({token:["Invalid token"]});if(Q0.Instant.from(O.createdAt.toISOString()).add({hours:24}).until(Q0.Now.instant()).sign>=0)throw new c({token:["Token expired"]});await f.deletePasswordResetToken({token:Y});let C=await f.findUserByEmailAddress(O.user.email,i.verifyEmail);if(!C)throw new c({email:["User not found"]});let Z=await i.hashPassword(U);return await f.updateUserPassword({id:C.id,password:Z}),await f.deleteAllUserSessions(C.id),await i.onResetPassword(C),{}}async changePassword($=new Q){let{userProvider:f,config:i}=j(H),z=await o.user(),U=await $.input(),{oldPassword:Y,newPassword:O}=U.toJSON(),{password:W}=await f.findUserByEmailAddress(z.email,i.verifyEmail);if(!await i.verifyPassword(Y,W))throw new c({oldPassword:["Incorrect password"]});let Z=await i.hashPassword(O);return await f.updateUserPassword({id:z.id,password:Z}),await f.deleteAllUserSessions(z.id),{}}async oauthRedirect($=new Q){let{provider:f}=$.params,i=j(H).config.oauthProviders[f];if(!i)throw Error(`Invalid provider: ${f}`);return{destination:await i.getRedirectUrl($)}}async oauthCallback($=new Q){let{provider:f}=$.params,i=j(H),{userProvider:z,config:U}=i,Y=U.oauthProviders[f],{email:O,name:W}=await Y.onCallback($);if(!O)return console.error("Authentication error: No email returned from OAuth provider callback"),{session:null};let C=await z.findUserByEmailAddress(O,!1),Z=j(b).detectLocale($),X="signin";if(!C)X="signup",C=await z.transaction(async()=>{let L=await z.createUser({email:O,name:W,locale:Z,emailVerifiedAt:new Date});return await z.createSocialAccount({provider:f,userId:L.id,email:O,username:W,providerId:"",expiresAt:new Date,accessToken:"",refreshToken:""}),await U.onUserCreated(L),L});let B=await i.createOrUpdateSessionV2({email:C.email,id:C.id}),J=new URL($.rawRequest.url);if($.ctx().setCookie("access_token",B.token,{secure:!J.origin.includes("localhost"),httpOnly:!0,expires:B.expiresAt}),X==="signup")await U.onSignUp(C,"",$.search.toJSON());else await U.onSignIn(C,$.search.toJSON());return{session:B}}async createMagicLinkToken($=new Q){let i=(await $.input()).get("email").toLowerCase().trim(),z=j(H),{user:U,pin:Y,token:O}=await z.createMagicLinkToken(i);if(U)return await z.config.onMagicLinkCreated(U,{email:i,pin:Y,token:O}),{email:i};return{email:null}}}class r1 extends r0{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[S,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[S,"oauthCallback"])}}class t0 extends r0{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[S,"signInWithMagicLink"]),"/oauth":r1}}class a0 extends y{middlewares=["cache:private"];routes={"/sign-in":this.post(S,"signIn"),"/sign-in-v2":this.post(S,"signInV2"),"/sign-up":this.post(S,"signUp"),"/sign-out":this.post(S,"signOut"),"/forgot-password":this.post(S,"forgotPassword"),"/reset-password":this.post(S,"resetPassword"),"/change-password":this.post(S,"changePassword"),"/verify-email":this.post(S,"verifyEmail"),"/me":this.get(S,"me").middleware(["auth"]),"/magic-link":this.post(S,"createMagicLinkToken"),"/sign-in-with-pin":this.post(S,"signInWithPin"),"/sign-in-with-pin-v2":this.post(S,"signInWithPinV2")}}class e0 extends y{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let f=new Q().params.locale;return await j(b).onLocaleChange(f),{locale:f}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new Q,f=`/${$.params.scope??""}`,i=$.params.locale,z=j(b),U=i??z.detectLocale($),Y=z.getPageTranslations(U,f);return $.ctx().setCookie("i18n-locale",U,{expires:new Date(Date.now()+31536000000)}),{[U]:Y}})}}class $1{}class f1 extends $1{async resize($,f){let{height:i,width:z,quality:U,fit:Y}=f;return await(await C0("The Sharp image optimization driver"))($).resize(z>0?z:void 0,i>0?i:void 0,{fit:Y}).webp({quality:U>0?U:80,force:!0}).toBuffer()}}function G3($){return $}function t1(){return{driver:new f1}}class i1 extends y{routes={"/resize":this.file(async()=>{let $=new Q,f=new URL($.rawRequest.url),i=f.searchParams.get("url"),z=Number(f.searchParams.get("w")),U=Number(f.searchParams.get("h")),Y=f.searchParams.get("fit")??"cover",O=Number(f.searchParams.get("q"));if(!i)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let C=`${i.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${i}`,Z=await fetch(C);if(!Z.ok)return new Response(JSON.stringify({error:"Image not found",info:C}),{headers:{"Content-Type":"application/json"},status:404});let X=Buffer.from(await Z.arrayBuffer()),B=await j(a1).resize(X,{height:U,width:z,fit:Y,quality:O});Z.headers.delete("Content-Type"),Z.headers.delete("Content-Length");let J=new Headers(Z.headers);return J.set("Content-Type","image/webp"),J.set("Content-Length",`${B.byteLength}`),new Response(new Uint8Array(B),{headers:J})})}}class a1{static token="image";driver;constructor($={}){this.driver=$.driver??t1().driver}resize($,f){return this.driver.resize($,f)}}import{mkdir as z1,readdir as Lf,access as Kf}from"fs/promises";async function U1($){try{return await Kf($),!0}catch{return!1}}class N0{config;static token="log";writer;isReady=!1;logsDirPath=`${process.env.ROOT_DIR}/storage/logs`;flushTimeout;fileSize=0;writerSize=0;isCreatingFile=!1;bootPromise=null;currentLogFilePath;constructor($){this.config=$}boot(){if(!this.bootPromise)this.bootPromise=this.createStorage().then(()=>{this.isReady=!0});return this.bootPromise}async createStorage(){if(!process.env.ROOT_DIR)return;if(!await U1(`${process.env.ROOT_DIR}/storage`))await z1(`${process.env.ROOT_DIR}/storage`);if(!await U1(this.logsDirPath))await z1(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await U1(this.logsDirPath))await z1(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let i=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed(i),this.fileSize=0,this.writerSize=0}let f=(await Lf(this.logsDirPath)).sort().reverse()[0];if(f){let i=Bun.file(`${this.logsDirPath}/${f}`);if(i.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${f}`,this.writer=i.writer(),this.writer.write(await i.text()),this.writer.write(`
3
- `),this.writer.flush(),this.fileSize=i.size}if(!this.writer){let i=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${i}`;let z=Bun.file(`${this.logsDirPath}/${i}`);this.writer=z.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log($,f,i={}){if(!this.isReady)await this.boot();let z=V.getStore(),U={};if(z)U={url:z.req.rawRequest.url,method:z.req.rawRequest.method,headers:z.req.rawRequest.headers,body:z.req.rawRequest.body};let Y={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:$,message:f,metadata:{...U,...i}},O="";try{O=JSON.stringify(Y)}catch(W){console.log("Error parsing log object",W)}this.writerSize+=O.length,this.fileSize+=O.length;try{this.writer.write(O),this.writer.write(`
4
- `),this.config.onLogCreated(Y),this.tryFlush()}catch(W){console.error("Error writing log",W)}}async tryFlush(){if(this.fileSize>this.config.maxFileSize){if(!this.isCreatingFile)await this.newLogFile()}if(this.writerSize>this.config.maxFileSize/2)await this.writer.flush(),this.writerSize=0,await this.newLogFile();else clearTimeout(this.flushTimeout),this.flushTimeout=setTimeout(async()=>{await this.writer.flush(),this.writerSize=0},100)}}class W1 extends y{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(j(N0).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function Vf($){let f=new Map;for(let i of $)if(typeof i==="string"){let[z,U=""]=i.split(":");if(z.startsWith("-")){if(f.has(z.replace("-","")))f.delete(z.replace("-",""))}else f.set(z,U.split(",").filter(Boolean))}else f.set(i,[]);return f}class T0{config;static token="middleware";constructor($){this.config=$}get aliases(){return this.config.aliases}runMiddleware($){let f=new Q;return Array.from(Vf($).entries()).map(([i,z])=>{if(typeof i==="string"){let U=this.aliases[i];if(U){let Y=new U(f);return()=>Y.run.call(Y,...z)}}else{if(e1(i)){let U=new i(f);return U.run.bind(U)}return i}}).filter(Boolean).reduce((i,z)=>{return async()=>{return{...await i(),...await z()}}},()=>Promise.resolve({}))()}}function H3($){return $}function $$(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function f$(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function wf($){return"run"in $}function Qf($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"delete")}function Nf($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function Tf($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function Af($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function Ef($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function O1($,f="",i=[]){let z={};function U(Y,O,W,C){let Z=Y==="/"?"":Y,X=f==="/"?"":f,B=(`${X}${Z}`===""?"/":`${X}${Z}`).replaceAll("//","/");if(!z[B])z[B]={};z[B][O.toUpperCase()]={exec:W,middleware:[...i,...C]},z[B].OPTIONS={exec:()=>{let L=new Q().ctx().headers;return new Response(null,{headers:L,status:204})},middleware:[]}}for(let[Y,O]of Object.entries($)){if(Af(O)){let W=O;for(let C of["GET","POST","PUT","DELETE"])U(Y,C,W.run.bind(W),[]);continue}if(wf(O)){let W=O,C=W.method,Z=W.middlewares,X=W.run.bind(W);if(U(Y,C,X,Z),Ef(O))U(Y,"HEAD",X,Z)}if(Qf(O))for(let[W,C]of Object.entries(O)){let Z=C.middlewares,X=C.run.bind(C);U(Y,W,X,Z)}if(Tf(O)){let W=new O,C=O1(W.routes,`${f}${Y}`,W.middlewares);for(let[Z,X]of Object.entries(C))z[Z.replaceAll("//","/")]=X}if(Nf(O)){let{first:W,second:C}=O;for(let[Z,X]of Object.entries(W)){let B=X.middlewares,J=X.run.bind(X),[L,...G]=Y.split("/").reverse();if(!L.startsWith(":"))throw Error("Resource route must end with a dynamic segment");U(G.reverse().join("/"),Z,J,B)}for(let[Z,X]of Object.entries(C)){let B=X.middlewares,J=X.run.bind(X);U(Y,Z,J,B)}}}return Object.fromEntries(Object.entries(z).sort(([Y],[O])=>{let W=Y.split("/").length+Y.split(":").length,C=O.split("/").length+O.split(":").length;return W-C}))}function H0($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function Y1($,f){if($==="/")return f;if(f==="/")return $;return`${$}${f}`}function Z1($){let f=H0($);return f.length>1?f.replace(/\/$/,""):f}function i$($,f){return f.map((i)=>({...i,path:Z1(Y1($,i.path))}))}function S0($){let f={};for(let[i,z]of Object.entries($))if("run"in z){let U=z;if("children"in U){let Y=new U.children,O=S0(Y.routes);for(let[W,{exec:C,middleware:Z,segments:X,features:B}]of Object.entries(O)){let J=Y1(i,W),L=(G)=>U.run.call(U,G,i);f[H0(J)]={exec:[L,...C],middleware:[...U.middlewares,...Z],features:[...U.featureGates,...B],viewPath:U.viewPath,segments:[{path:Z1(i),viewPath:U.viewPath,...U.alwaysRuns?{alwaysRun:!0}:{}},...i$(i,X)]}}}else{let Y=(O)=>U.run.call(U,O,i);f[H0(i)]={exec:[Y],middleware:U.middlewares,features:U.featureGates,viewPath:U.viewPath,segments:[{path:Z1(i),viewPath:U.viewPath}]}}}else{let U=new z,Y=S0(U.routes);for(let[O,{exec:W,middleware:C,viewPath:Z,segments:X,features:B}]of Object.entries(Y)){let J=Y1(i,O);f[H0(J)]={exec:W,middleware:[...U.middlewares,...C],features:[...U.featureGates,...B],viewPath:Z,segments:i$(i,X)}}}return Object.fromEntries(Object.entries(f).sort(([i],[z])=>{let U=i.split("/").length+i.split(":").length,Y=z.split("/").length+z.split(":").length;return U-Y}))}var xf=Object.defineProperty,I=($,f)=>xf($,"name",{value:f,configurable:!0}),G0=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,f,i,z,U,Y){this.type=$,this.name=f,this.prefix=i,this.value=z,this.suffix=U,this.modifier=Y}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};I(G0,"Part");var Df=/[$_\p{ID_Start}]/u,gf=/[$_\u200C\u200D\p{ID_Continue}]/u,J1=".*";function z$($,f){return(f?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}I(z$,"isASCII");function I1($,f=!1){let i=[],z=0;for(;z<$.length;){let U=$[z],Y=I(function(O){if(!f)throw TypeError(O);i.push({type:"INVALID_CHAR",index:z,value:$[z++]})},"ErrorOrInvalid");if(U==="*"){i.push({type:"ASTERISK",index:z,value:$[z++]});continue}if(U==="+"||U==="?"){i.push({type:"OTHER_MODIFIER",index:z,value:$[z++]});continue}if(U==="\\"){i.push({type:"ESCAPED_CHAR",index:z++,value:$[z++]});continue}if(U==="{"){i.push({type:"OPEN",index:z,value:$[z++]});continue}if(U==="}"){i.push({type:"CLOSE",index:z,value:$[z++]});continue}if(U===":"){let O="",W=z+1;for(;W<$.length;){let C=$.substr(W,1);if(W===z+1&&Df.test(C)||W!==z+1&&gf.test(C)){O+=$[W++];continue}break}if(!O){Y(`Missing parameter name at ${z}`);continue}i.push({type:"NAME",index:z,value:O}),z=W;continue}if(U==="("){let O=1,W="",C=z+1,Z=!1;if($[C]==="?"){Y(`Pattern cannot start with "?" at ${C}`);continue}for(;C<$.length;){if(!z$($[C],!1)){Y(`Invalid character '${$[C]}' at ${C}.`),Z=!0;break}if($[C]==="\\"){W+=$[C++]+$[C++];continue}if($[C]===")"){if(O--,O===0){C++;break}}else if($[C]==="("&&(O++,$[C+1]!=="?")){Y(`Capturing groups are not allowed at ${C}`),Z=!0;break}W+=$[C++]}if(Z)continue;if(O){Y(`Unbalanced pattern at ${z}`);continue}if(!W){Y(`Missing pattern at ${z}`);continue}i.push({type:"REGEX",index:z,value:W}),z=C;continue}i.push({type:"CHAR",index:z,value:$[z++]})}return i.push({type:"END",index:z,value:""}),i}I(I1,"lexer");function G1($,f={}){let i=I1($);f.delimiter??="/#?",f.prefixes??="./";let z=`[^${h(f.delimiter)}]+?`,U=[],Y=0,O=0,W="",C=new Set,Z=I((x)=>{if(O<i.length&&i[O].type===x)return i[O++].value},"tryConsume"),X=I(()=>Z("OTHER_MODIFIER")??Z("ASTERISK"),"tryConsumeModifier"),B=I((x)=>{let K=Z(x);if(K!==void 0)return K;let{type:w,index:g}=i[O];throw TypeError(`Unexpected ${w} at ${g}, expected ${x}`)},"mustConsume"),J=I(()=>{let x="",K;for(;K=Z("CHAR")??Z("ESCAPED_CHAR");)x+=K;return x},"consumeText"),L=I((x)=>x,"DefaultEncodePart"),G=f.encodePart||L,N="",D=I((x)=>{N+=x},"appendToPendingFixedValue"),F=I(()=>{N.length&&(U.push(new G0(3,"","",G(N),"",3)),N="")},"maybeAddPartFromPendingFixedValue"),q=I((x,K,w,g,k)=>{let M=3;switch(k){case"?":M=1;break;case"*":M=0;break;case"+":M=2;break}if(!K&&!w&&M===3){D(x);return}if(F(),!K&&!w){if(!x)return;U.push(new G0(3,"","",G(x),"",M));return}let E;w?w==="*"?E=J1:E=w:E=z;let T=2;E===z?(T=1,E=""):E===J1&&(T=0,E="");let v;if(K?v=K:w&&(v=Y++),C.has(v))throw TypeError(`Duplicate name '${v}'.`);C.add(v),U.push(new G0(T,v,G(x),E,G(g),M))},"addPart");for(;O<i.length;){let x=Z("CHAR"),K=Z("NAME"),w=Z("REGEX");if(!K&&!w&&(w=Z("ASTERISK")),K||w){let k=x??"";f.prefixes.indexOf(k)===-1&&(D(k),k=""),F();let M=X();q(k,K,w,"",M);continue}let g=x??Z("ESCAPED_CHAR");if(g){D(g);continue}if(Z("OPEN")){let k=J(),M=Z("NAME"),E=Z("REGEX");!M&&!E&&(E=Z("ASTERISK"));let T=J();B("CLOSE");let v=X();q(k,M,E,T,v);continue}F(),B("END")}return U}I(G1,"parse");function h($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}I(h,"escapeString");function X1($){return $&&$.ignoreCase?"ui":"u"}I(X1,"flags");function U$($,f,i){return j1(G1($,i),f,i)}I(U$,"stringToRegexp");function $0($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}I($0,"modifierToString");function j1($,f,i={}){i.delimiter??="/#?",i.prefixes??="./",i.sensitive??=!1,i.strict??=!1,i.end??=!0,i.start??=!0,i.endsWith="";let z=i.start?"^":"";for(let W of $){if(W.type===3){W.modifier===3?z+=h(W.value):z+=`(?:${h(W.value)})${$0(W.modifier)}`;continue}f&&f.push(W.name);let C=`[^${h(i.delimiter)}]+?`,Z=W.value;if(W.type===1?Z=C:W.type===0&&(Z=J1),!W.prefix.length&&!W.suffix.length){W.modifier===3||W.modifier===1?z+=`(${Z})${$0(W.modifier)}`:z+=`((?:${Z})${$0(W.modifier)})`;continue}if(W.modifier===3||W.modifier===1){z+=`(?:${h(W.prefix)}(${Z})${h(W.suffix)})`,z+=$0(W.modifier);continue}z+=`(?:${h(W.prefix)}`,z+=`((?:${Z})(?:`,z+=h(W.suffix),z+=h(W.prefix),z+=`(?:${Z}))*)${h(W.suffix)})`,W.modifier===0&&(z+="?")}let U=`[${h(i.endsWith)}]|$`,Y=`[${h(i.delimiter)}]`;if(i.end)return i.strict||(z+=`${Y}?`),i.endsWith.length?z+=`(?=${U})`:z+="$",new RegExp(z,X1(i));i.strict||(z+=`(?:${Y}(?=${U}))?`);let O=!1;if($.length){let W=$[$.length-1];W.type===3&&W.modifier===3&&(O=i.delimiter.indexOf(W)>-1)}return O||(z+=`(?=${Y}|${U})`),new RegExp(z,X1(i))}I(j1,"partsToRegexp");var t={delimiter:"",prefixes:"",sensitive:!0,strict:!0},_f={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Mf={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function W$($,f){return $.length?$[0]==="/"?!0:!f||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}I(W$,"isAbsolutePathname");function L1($,f){return $.startsWith(f)?$.substring(f.length,$.length):$}I(L1,"maybeStripPrefix");function O$($,f){return $.endsWith(f)?$.substr(0,$.length-f.length):$}I(O$,"maybeStripSuffix");function K1($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}I(K1,"treatAsIPv6Hostname");var Y$=["ftp","file","http","https","ws","wss"];function V1($){if(!$)return!0;for(let f of Y$)if($.test(f))return!0;return!1}I(V1,"isSpecialScheme");function Z$($,f){if($=L1($,"#"),f||$==="")return $;let i=new URL("https://example.com");return i.hash=$,i.hash?i.hash.substring(1,i.hash.length):""}I(Z$,"canonicalizeHash");function C$($,f){if($=L1($,"?"),f||$==="")return $;let i=new URL("https://example.com");return i.search=$,i.search?i.search.substring(1,i.search.length):""}I(C$,"canonicalizeSearch");function J$($,f){return f||$===""?$:K1($)?N1($):Q1($)}I(J$,"canonicalizeHostname");function X$($,f){if(f||$==="")return $;let i=new URL("https://example.com");return i.password=$,i.password}I(X$,"canonicalizePassword");function B$($,f){if(f||$==="")return $;let i=new URL("https://example.com");return i.username=$,i.username}I(B$,"canonicalizeUsername");function I$($,f,i){if(i||$==="")return $;if(f&&!Y$.includes(f))return new URL(`${f}:${$}`).pathname;let z=$[0]=="/";return $=new URL(z?$:"/-"+$,"https://example.com").pathname,z||($=$.substring(2,$.length)),$}I(I$,"canonicalizePathname");function G$($,f,i){return w1(f)===$&&($=""),i||$===""?$:T1($)}I(G$,"canonicalizePort");function j$($,f){return $=O$($,":"),f||$===""?$:v0($)}I(j$,"canonicalizeProtocol");function w1($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}I(w1,"defaultPortForProtocol");function v0($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}I(v0,"protocolEncodeCallback");function L$($){if($==="")return $;let f=new URL("https://example.com");return f.username=$,f.username}I(L$,"usernameEncodeCallback");function K$($){if($==="")return $;let f=new URL("https://example.com");return f.password=$,f.password}I(K$,"passwordEncodeCallback");function Q1($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let f=new URL("https://example.com");return f.hostname=$,f.hostname}I(Q1,"hostnameEncodeCallback");function N1($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}I(N1,"ipv6HostnameEncodeCallback");function T1($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}I(T1,"portEncodeCallback");function V$($){if($==="")return $;let f=new URL("https://example.com");return f.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?f.pathname.substring(2,f.pathname.length):f.pathname}I(V$,"standardURLPathnameEncodeCallback");function w$($){return $===""?$:new URL(`data:${$}`).pathname}I(w$,"pathURLPathnameEncodeCallback");function Q$($){if($==="")return $;let f=new URL("https://example.com");return f.search=$,f.search.substring(1,f.search.length)}I(Q$,"searchEncodeCallback");function N$($){if($==="")return $;let f=new URL("https://example.com");return f.hash=$,f.hash.substring(1,f.hash.length)}I(N$,"hashEncodeCallback");var T$=class{#W;#z=[];#f={};#$=0;#U=1;#C=0;#Y=0;#I=0;#G=0;#j=!1;constructor($){this.#W=$}get result(){return this.#f}parse(){for(this.#z=I1(this.#W,!0);this.#$<this.#z.length;this.#$+=this.#U){if(this.#U=1,this.#z[this.#$].type==="END"){if(this.#Y===0){this.#w(),this.#J()?this.#i(9,1):this.#X()?this.#i(8,1):this.#i(7,0);continue}else if(this.#Y===2){this.#B(5);continue}this.#i(10,0);break}if(this.#I>0)if(this.#D())this.#I-=1;else continue;if(this.#x()){this.#I+=1;continue}switch(this.#Y){case 0:this.#Q()&&this.#B(1);break;case 1:if(this.#Q()){this.#M();let $=7,f=1;this.#T()?($=2,f=3):this.#j&&($=2),this.#i($,f)}break;case 2:this.#K()?this.#B(3):(this.#V()||this.#X()||this.#J())&&this.#B(5);break;case 3:this.#A()?this.#i(4,1):this.#K()&&this.#i(5,1);break;case 4:this.#K()&&this.#i(5,1);break;case 5:this.#g()?this.#G+=1:this.#_()&&(this.#G-=1),this.#E()&&!this.#G?this.#i(6,1):this.#V()?this.#i(7,0):this.#X()?this.#i(8,1):this.#J()&&this.#i(9,1);break;case 6:this.#V()?this.#i(7,0):this.#X()?this.#i(8,1):this.#J()&&this.#i(9,1);break;case 7:this.#X()?this.#i(8,1):this.#J()&&this.#i(9,1);break;case 8:this.#J()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#f.hostname!==void 0&&this.#f.port===void 0&&(this.#f.port="")}#i($,f){switch(this.#Y){case 0:break;case 1:this.#f.protocol=this.#Z();break;case 2:break;case 3:this.#f.username=this.#Z();break;case 4:this.#f.password=this.#Z();break;case 5:this.#f.hostname=this.#Z();break;case 6:this.#f.port=this.#Z();break;case 7:this.#f.pathname=this.#Z();break;case 8:this.#f.search=this.#Z();break;case 9:this.#f.hash=this.#Z();break;case 10:break}this.#Y!==0&&$!==10&&([1,2,3,4].includes(this.#Y)&&[6,7,8,9].includes($)&&(this.#f.hostname??=""),[1,2,3,4,5,6].includes(this.#Y)&&[8,9].includes($)&&(this.#f.pathname??=this.#j?"/":""),[1,2,3,4,5,6,7].includes(this.#Y)&&$===9&&(this.#f.search??="")),this.#N($,f)}#N($,f){this.#Y=$,this.#C=this.#$+f,this.#$+=f,this.#U=0}#w(){this.#$=this.#C,this.#U=0}#B($){this.#w(),this.#Y=$}#L($){return $<0&&($=this.#z.length-$),$<this.#z.length?this.#z[$]:this.#z[this.#z.length-1]}#O($,f){let i=this.#L($);return i.value===f&&(i.type==="CHAR"||i.type==="ESCAPED_CHAR"||i.type==="INVALID_CHAR")}#Q(){return this.#O(this.#$,":")}#T(){return this.#O(this.#$+1,"/")&&this.#O(this.#$+2,"/")}#K(){return this.#O(this.#$,"@")}#A(){return this.#O(this.#$,":")}#E(){return this.#O(this.#$,":")}#V(){return this.#O(this.#$,"/")}#X(){if(this.#O(this.#$,"?"))return!0;if(this.#z[this.#$].value!=="?")return!1;let $=this.#L(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#J(){return this.#O(this.#$,"#")}#x(){return this.#z[this.#$].type=="OPEN"}#D(){return this.#z[this.#$].type=="CLOSE"}#g(){return this.#O(this.#$,"[")}#_(){return this.#O(this.#$,"]")}#Z(){let $=this.#z[this.#$],f=this.#L(this.#C).index;return this.#W.substring(f,$.index)}#M(){let $={};Object.assign($,t),$.encodePart=v0;let f=U$(this.#Z(),void 0,$);this.#j=V1(f)}};I(T$,"Parser");var C1=["protocol","username","password","hostname","port","pathname","search","hash"],r="*";function B1($,f){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let i=new URL($,f);return{protocol:i.protocol.substring(0,i.protocol.length-1),username:i.username,password:i.password,hostname:i.hostname,port:i.port,pathname:i.pathname,search:i.search!==""?i.search.substring(1,i.search.length):void 0,hash:i.hash!==""?i.hash.substring(1,i.hash.length):void 0}}I(B1,"extractValues");function d($,f){return f?I0($):$}I(d,"processBaseURLString");function B0($,f,i){let z;if(typeof f.baseURL=="string")try{z=new URL(f.baseURL),f.protocol===void 0&&($.protocol=d(z.protocol.substring(0,z.protocol.length-1),i)),!i&&f.protocol===void 0&&f.hostname===void 0&&f.port===void 0&&f.username===void 0&&($.username=d(z.username,i)),!i&&f.protocol===void 0&&f.hostname===void 0&&f.port===void 0&&f.username===void 0&&f.password===void 0&&($.password=d(z.password,i)),f.protocol===void 0&&f.hostname===void 0&&($.hostname=d(z.hostname,i)),f.protocol===void 0&&f.hostname===void 0&&f.port===void 0&&($.port=d(z.port,i)),f.protocol===void 0&&f.hostname===void 0&&f.port===void 0&&f.pathname===void 0&&($.pathname=d(z.pathname,i)),f.protocol===void 0&&f.hostname===void 0&&f.port===void 0&&f.pathname===void 0&&f.search===void 0&&($.search=d(z.search.substring(1,z.search.length),i)),f.protocol===void 0&&f.hostname===void 0&&f.port===void 0&&f.pathname===void 0&&f.search===void 0&&f.hash===void 0&&($.hash=d(z.hash.substring(1,z.hash.length),i))}catch{throw TypeError(`invalid baseURL '${f.baseURL}'.`)}if(typeof f.protocol=="string"&&($.protocol=j$(f.protocol,i)),typeof f.username=="string"&&($.username=B$(f.username,i)),typeof f.password=="string"&&($.password=X$(f.password,i)),typeof f.hostname=="string"&&($.hostname=J$(f.hostname,i)),typeof f.port=="string"&&($.port=G$(f.port,$.protocol,i)),typeof f.pathname=="string"){if($.pathname=f.pathname,z&&!W$($.pathname,i)){let U=z.pathname.lastIndexOf("/");U>=0&&($.pathname=d(z.pathname.substring(0,U+1),i)+$.pathname)}$.pathname=I$($.pathname,$.protocol,i)}return typeof f.search=="string"&&($.search=C$(f.search,i)),typeof f.hash=="string"&&($.hash=Z$(f.hash,i)),$}I(B0,"applyInit");function I0($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}I(I0,"escapePatternString");function A$($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}I(A$,"escapeRegexpString");function E$($,f){f.delimiter??="/#?",f.prefixes??="./",f.sensitive??=!1,f.strict??=!1,f.end??=!0,f.start??=!0,f.endsWith="";let i=".*",z=`[^${A$(f.delimiter)}]+?`,U=/[$_\u200C\u200D\p{ID_Continue}]/u,Y="";for(let O=0;O<$.length;++O){let W=$[O];if(W.type===3){if(W.modifier===3){Y+=I0(W.value);continue}Y+=`{${I0(W.value)}}${$0(W.modifier)}`;continue}let C=W.hasCustomName(),Z=!!W.suffix.length||!!W.prefix.length&&(W.prefix.length!==1||!f.prefixes.includes(W.prefix)),X=O>0?$[O-1]:null,B=O<$.length-1?$[O+1]:null;if(!Z&&C&&W.type===1&&W.modifier===3&&B&&!B.prefix.length&&!B.suffix.length)if(B.type===3){let J=B.value.length>0?B.value[0]:"";Z=U.test(J)}else Z=!B.hasCustomName();if(!Z&&!W.prefix.length&&X&&X.type===3){let J=X.value[X.value.length-1];Z=f.prefixes.includes(J)}Z&&(Y+="{"),Y+=I0(W.prefix),C&&(Y+=`:${W.name}`),W.type===2?Y+=`(${W.value})`:W.type===1?C||(Y+=`(${z})`):W.type===0&&(!C&&(!X||X.type===3||X.modifier!==3||Z||W.prefix!=="")?Y+="*":Y+=`(${i})`),W.type===1&&C&&W.suffix.length&&U.test(W.suffix[0])&&(Y+="\\"),Y+=I0(W.suffix),Z&&(Y+="}"),W.modifier!==3&&(Y+=$0(W.modifier))}return Y}I(E$,"partsToPattern");var A1=class{#W;#z={};#f={};#$={};#U={};#C=!1;constructor($={},f,i){try{let z;if(typeof f=="string"?z=f:i=f,typeof $=="string"){let W=new T$($);if(W.parse(),$=W.result,z===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=z}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(z)throw TypeError("parameter 1 is not of type 'string'.")}typeof i>"u"&&(i={ignoreCase:!1});let U={ignoreCase:i.ignoreCase===!0},Y={pathname:r,protocol:r,username:r,password:r,hostname:r,port:r,search:r,hash:r};this.#W=B0(Y,$,!0),w1(this.#W.protocol)===this.#W.port&&(this.#W.port="");let O;for(O of C1){if(!(O in this.#W))continue;let W={},C=this.#W[O];switch(this.#f[O]=[],O){case"protocol":Object.assign(W,t),W.encodePart=v0;break;case"username":Object.assign(W,t),W.encodePart=L$;break;case"password":Object.assign(W,t),W.encodePart=K$;break;case"hostname":Object.assign(W,_f),K1(C)?W.encodePart=N1:W.encodePart=Q1;break;case"port":Object.assign(W,t),W.encodePart=T1;break;case"pathname":V1(this.#z.protocol)?(Object.assign(W,Mf,U),W.encodePart=V$):(Object.assign(W,t,U),W.encodePart=w$);break;case"search":Object.assign(W,t,U),W.encodePart=Q$;break;case"hash":Object.assign(W,t,U),W.encodePart=N$;break}try{this.#U[O]=G1(C,W),this.#z[O]=j1(this.#U[O],this.#f[O],W),this.#$[O]=E$(this.#U[O],W),this.#C=this.#C||this.#U[O].some((Z)=>Z.type===2)}catch{throw TypeError(`invalid ${O} pattern '${this.#W[O]}'.`)}}}catch(z){throw TypeError(`Failed to construct 'URLPattern': ${z.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},f){let i={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&f)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?i=B0(i,$,!1):i=B0(i,B1($,f),!1)}catch{return!1}let z;for(z of C1)if(!this.#z[z].exec(i[z]))return!1;return!0}exec($={},f){let i={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&f)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?i=B0(i,$,!1):i=B0(i,B1($,f),!1)}catch{return null}let z={};f?z.inputs=[$,f]:z.inputs=[$];let U;for(U of C1){let Y=this.#z[U].exec(i[U]);if(!Y)return null;let O={};for(let[W,C]of this.#f[U].entries())if(typeof C=="string"||typeof C=="number"){let Z=Y[W+1];O[C]=Z}z[U]={input:i[U]??"",groups:O}}return z}static compareComponent($,f,i){let z=I((W,C)=>{for(let Z of["type","modifier","prefix","value","suffix"]){if(W[Z]<C[Z])return-1;if(W[Z]===C[Z])continue;return 1}return 0},"comparePart"),U=new G0(3,"","","","",3),Y=new G0(0,"","","","",3),O=I((W,C)=>{let Z=0;for(;Z<Math.min(W.length,C.length);++Z){let X=z(W[Z],C[Z]);if(X)return X}return W.length===C.length?0:z(W[Z]??U,C[Z]??U)},"comparePartList");return!f.#$[$]&&!i.#$[$]?0:f.#$[$]&&!i.#$[$]?O(f.#U[$],[Y]):!f.#$[$]&&i.#$[$]?O([Y],i.#U[$]):O(f.#U[$],i.#U[$])}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.#C}};I(A1,"URLPattern");function b0($,f){for(let[i,z]of Object.entries($)){let U=new A1({pathname:i});if(U.test({pathname:f}))return{routePath:i,params:U.exec({pathname:f})?.pathname.groups??{},route:z}}return null}var f0={startIndex:0,carriedViews:[]};function x$($,f){let i=R($.path,f);return i.includes("*")?null:i}function Ff($,f){if(!$)return f0;if($.search!==f.search)return f0;let i=Math.min($.segments.length,f.segments.length-1),z=0;while(z<i){let U=$.segments[z],Y=f.segments[z];if(Y.alwaysRun)break;if(U.viewPath!==Y.viewPath)break;let O=x$(U,$.params),W=x$(Y,f.params);if(O===null||W===null||O!==W)break;z++}if(z===0)return f0;return{startIndex:z,carriedViews:f.segments.slice(0,z).map(({viewPath:U})=>U)}}function Hf($,f){let[,i,...z]=$.split("/");if(!f.includes(i))return $;let U=`/${z.join("/")}`;return U==="/"?"/":U.replace(/\/$/,"")}function D$($){let{flatViewRoutes:f,supportedLocales:i,from:z,origin:U,to:Y}=$;if(!z)return f0;let O;try{O=new URL(z,U)}catch{return f0}if(O.origin!==U)return f0;let W=b0(f,Hf(O.pathname,i));if(!W)return f0;return Ff({segments:W.route.segments,params:W.params,search:O.search},Y)}var E1="x-gemi-from";import{createElement as K0,Fragment as of}from"react";function Sf($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function k0($){let f={};for(let[i,z]of Object.entries($))if("run"in z){let U=z.viewPath;if("children"in z){f[i]=[U];let Y=new z.children,O=k0(Y.routes);for(let[W,C]of Object.entries(O)){let Z=i==="/"?W:`${i}${W}`,X=W==="/"&&i!=="/"?i:Z;f[X]=[U,...C]}if(f[i].length===1)delete f[i]}else f[i]=[U]}else{let U=new z,Y=k0(U.routes);for(let[O,W]of Object.entries(Y)){let C=i==="/"?O:`${i}${O}`,Z=O==="/"&&i!=="/"?i:C;f[Z]=W}}return Object.fromEntries(Object.entries(f).map(([i,z])=>[Sf(i),z]))}function P0($){let f=[];for(let[i,z]of Object.entries($))if("run"in z){let U=z.viewPath;if(U==="__")continue;if(U==="REDIRECT")continue;if(U==="FILE")continue;if("children"in z){let Y=new z.children,O=P0(Y.routes);f.push([U,O])}else f.push([U,[]])}else{let U=new z,Y=P0(U.routes);f.push(...Y)}return f}function x1($){let f=[];for(let[i,z]of $)f.push(i,...x1(z).flat());return Array.from(new Set(f))}class j0 extends _{static getFacadeAccessor(){return N0}static debug($,f){this.getFacadeRoot().log("debug",$,f)}static info($,f){this.getFacadeRoot().log("info",$,f)}static notice($,f){this.getFacadeRoot().log("notice",$,f)}static warning($,f){this.getFacadeRoot().log("warning",$,f)}static error($,f){this.getFacadeRoot().log("error",$,f)}static critical($,f){this.getFacadeRoot().log("critical",$,f)}static alert($,f){this.getFacadeRoot().log("alert",$,f)}static emergency($,f){this.getFacadeRoot().log("emergency",$,f)}}class D1{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var vf=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),bf=new Set(["svg","math"]);function g$($){return $===32||$===9||$===10||$===12||$===13}function _$($){return $>=65&&$<=90||$>=97&&$<=122}function R0($){return $>=65&&$<=90?$+32:$}function M$(){let $="data",f="",i=!1,z="",U=0,Y=0,O=!1,W=0,C=0,Z=()=>$==="data"&&W===0&&C===0,X=()=>{if(!i&&vf.has(f)){$="rawText",z=`</${f}`,U=0,f="";return}if($="data",f==="template")if(i)W=Math.max(0,W-1);else W+=1;else if(bf.has(f)){if(i)C=Math.max(0,C-1);else if(!O)C+=1}f=""},B=(J)=>{switch($){case"data":if(J===60)$="tagOpen";return;case"tagOpen":if(J===33)$="bang",Y=0;else if(J===47)$="endTagOpen";else if(_$(J))$="tagName",i=!1,O=!1,f=String.fromCharCode(R0(J));else if(J===63)$="bogus";else if(J===60)$="tagOpen";else $="data";return;case"endTagOpen":if(_$(J))$="tagName",i=!0,O=!1,f=String.fromCharCode(R0(J));else if(J===62)$="data";else $="bogus";return;case"tagName":if(g$(J)||J===47)$="inTag",O=J===47;else if(J===62)X();else f+=String.fromCharCode(R0(J));return;case"inTag":if(J===62){X();return}if(O=J===47,J===34)$="attrDouble";else if(J===39)$="attrSingle";return;case"attrDouble":if(J===34)$="inTag";O=!1;return;case"attrSingle":if(J===39)$="inTag";O=!1;return;case"bang":if(J===45){if(Y+=1,Y===2)$="comment",Y=0}else if(J===62)$="data";else $="bogus";return;case"bogus":if(J===62)$="data";return;case"comment":if(J===45)Y=Y<2?Y+1:2;else if(J===62&&Y>=2)$="data",Y=0;else Y=0;return;case"rawText":{if(U<z.length){if(R0(J)===z.charCodeAt(U))U+=1;else U=J===60?1:0;return}if(J===62)$="data",f="";else if(g$(J)||J===47)$="inTag",f="";else U=J===60?1:0;return}}};return{scanToInsertionPoint(J){for(let L=0;L<J.length;L++){if(Z())return L;B(J[L])}return J.length},write(J){for(let L=0;L<J.length;L++)B(J[L])},isSafe:Z}}function i0($){let f=JSON.stringify($);if(f===void 0)return"undefined";return f.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function kf($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${i0([$.path,$.variantKey,$.data])})</script>`}function Pf($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${i0([$.id,$.locale,$.strings])})</script>`}function g1($,f,i={},z){let U=new TextEncoder,Y=[],O=!1,W=!1,C=()=>{if(W)return;W=!0,i.onClose?.()};f.onSettle((G)=>{if(G.status!=="resolved")return;Y.push(kf(G))}),z?.onUse((G)=>{Y.push(Pf(G))});let Z=$.getReader(),X=M$(),B=(G,N)=>{G.enqueue(N),i.onChunk?.(N)},J=(G)=>{while(Y.length>0){let N=U.encode(Y.shift());X.write(N),B(G,N)}},L=(G,N)=>{if(Y.length===0){X.write(N),B(G,N);return}let D=X.scanToInsertionPoint(N);if(D>0)B(G,N.subarray(0,D));if(X.isSafe())J(G);let F=N.subarray(D);if(F.length>0)X.write(F),B(G,F)};return new ReadableStream({async pull(G){let N;try{N=await Z.read()}catch(q){throw C(),q}let{done:D,value:F}=N;if(D){J(G),G.close(),C();return}if(!O){if(O=!0,X.write(F),B(G,F),i.onShell?.(),X.isSafe())J(G);return}L(G,F)},cancel(G){return C(),Z.cancel(G)}})}var Rf=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function h0($){if(!$)return!1;return Rf.test($)}async function H$($,f=()=>{}){let i=V.getStore(),z=i?.req??null,U=null;if(z?.rawRequest?.url)try{U=new URL(z.rawRequest.url).pathname}catch{U=null}return{user:i?.user??null,attributes:await hf($,f),request:{path:U,routePath:z?.routePath??null,locale:i?.locale??null},anonymousId:F$(),isBot:h0(z?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function S$($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function hf($,f){if(!$.context)return{};try{let i=V.getStore();return await $.context(i?.req??null)??{}}catch(i){return f(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${i instanceof Error?i.message:String(i)}`),{}}}function v$($,f){return`${$}:${f}`}function _1($){let f=new Bun.CryptoHasher("sha1").update($).digest("hex"),i=Number.parseInt(f.slice(0,8),16);return Math.floor(i/4294967296*1e4)}function b$($,f){if(f>=100)return!0;if(f<=0)return!1;return $<Math.round(f*100)}function k$($,f,i,z){if(z.unavailable)return{value:!1,reason:"unavailable"};if(z.active!==!0)return{value:!1,reason:"inactive"};if(f.when){let Y;try{Y=f.when(i)}catch(O){return z.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${O instanceof Error?O.message:String(O)}`),{value:!1,reason:"error"}}if(typeof Y==="boolean")return{value:Y,reason:"attributed"}}if(f.rollout===void 0)return{value:!0,reason:"on"};if(i.isBot)return{value:!1,reason:"bot"};let U=pf($,f,i,z.buckets);return b$(U,f.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function mf($){let f=$.user?.publicId??$.user?.id;if(f!==void 0&&f!==null)return String(f);return $.anonymousId??""}function pf($,f,i,z){let U=v$(f.salt??$,mf(i));if(!z)return _1(U);let Y=z.get(U);if(Y!==void 0)return Y;let O=_1(U);return z.set(U,O),O}class M1{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;constructor($,f,i,z=()=>{}){this.source=$;this.declared=f;this.ttlMs=i;this.warn=z}async get(){let $=this.snapshot;if($&&Date.now()-$.loadedAt<this.ttlMs)return $;if($)return this.refresh().catch(()=>{}),$;return await this.refresh()}refresh(){return this.inflight??=this.load().finally(()=>{this.inflight=null}),this.inflight}peek(){return this.snapshot}async load(){try{let $=await this.source.load();return this.snapshot={active:this.readSwitches($),loadedAt:Date.now(),unavailable:!1},this.snapshot}catch($){return this.handleFailure($)}}readSwitches($){let f=new Map;for(let i of $??[]){let z=typeof i?.key==="string"?i.key:null;if(!z){this.warn("Ignoring a feature row with no `key`.");continue}if(!(z in this.declared)){this.warn(`Feature row "${z}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}f.set(z,i.active===!0)}return f}handleFailure($){let f=$ instanceof Error?$.message:String($),i=Date.now();if(i-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=i,this.warn(`Could not load feature switches: ${f}`);if(this.snapshot)return this.snapshot={...this.snapshot,loadedAt:i},this.snapshot;return this.snapshot={active:new Map,loadedAt:i,unavailable:!0},this.snapshot}}class P${manager;ctx;constructor($,f){this.manager=$;this.ctx=f}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 L0{config;log;static token="features";store;declared;warnedAboutSize=!1;constructor($,f=()=>{}){this.config=$;this.log=f;this.declared=$.features??{},this.store=new M1($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async refresh(){if(!this.config.enabled)return;if(Object.keys(this.declared).length===0)return;await this.store.refresh()}async enabled($){return(await this.explain($)).value}async explain($){let f=await this.requestContext();return await this.evaluateIn($,f,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(),f=await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!0});return this.warnIfOversized(Object.keys(f).length),f}for($){return new P$(this,S$($))}async evaluateIn($,f,i){let z=this.memoFor(f),U=z?.get($);if(U)return U;let Y=this.declared[$];if(!Y)return{value:!1,reason:"undeclared"};let{active:O,unavailable:W}=await this.switchFor($),C=k$($,Y,f,{active:O,unavailable:W,buckets:i,warn:this.log});return z?.set($,C),this.notify($,C,f),C}async evaluateAllIn($,f,i){let z={};for(let[U,Y]of Object.entries(this.declared)){if(i.clientOnly&&Y.serverOnly)continue;z[U]=(await this.evaluateIn(U,$,f)).value}return z}async switchFor($){if(!this.config.enabled)return{active:!1,unavailable:!1};let f=await this.store.get();return{active:f.active.get($),unavailable:f.unavailable}}async requestContext(){let $=V.getStore();if($?.featureContext)return $.featureContext;let f=await H$(this.config,this.log);if($)$.featureContext=f;return f}memoFor($){let f=V.getStore();if(!f||f.featureContext!==$)return null;return f.featureEvaluations??=new Map,f.featureEvaluations}requestBuckets(){let $=V.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,f,i){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,f,i)}catch(z){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${z instanceof Error?z.message:String(z)}`)}}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.`)}}var cf=new Set(["script","style","template","title"]),qf=/\shidden([\s=/]|$)/i,yf=/"[^"]*"|'[^']*'/g;function df($){let f=0,i=0,z=0,U=0;while(U<$.length){let Y=$.indexOf("<",U),O=Y===-1?$.length:Y;if(O>U){let B=$.slice(U,O).replace(/\s+/g,"").length;if(z>0)i+=B;else f+=B}if(Y===-1)break;if($.startsWith("<!--",Y)){let B=$.indexOf("-->",Y+4);U=B===-1?$.length:B+3;continue}let W=$.indexOf(">",Y);if(W===-1)break;let C=$.slice(Y+1,W);U=W+1;let Z=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(C)?.[1]?.toLowerCase();if(!Z)continue;let X=C.startsWith("/");if(!X&&cf.has(Z)&&!C.endsWith("/")){let B=$.indexOf(`</${Z}`,U);U=B===-1?$.length:B;continue}if(Z!=="div")continue;if(X){if(z>0)z-=1}else if(z>0)z+=1;else if(qf.test(C.replace(yf,'""')))z=1}return{shellChars:f,deferredChars:i}}var nf=1000,lf=64;function uf($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function sf($,f){if(f.deferredChars<nf)return null;if(f.shellChars>=lf)return null;return`[gemi] GET ${$} streams ${uf(f.deferredChars)} of its `+`content behind reveal scripts \u2014 a no-JS visitor sees ~${f.shellChars} chars. If this is a public/content route, add "no-stream" to its middleware.`}function R$($=console.warn){let f=new Set;return{shouldObserve(i){return!f.has(i)},report(i,z){if(f.has(i))return;let U=sf(i,z);if(!U)return;f.add(i),$(U)}}}function h$(){let $=new TextDecoder,f="";return{onChunk(i){f+=$.decode(i,{stream:!0})},measure(){return f+=$.decode(),df(f)}}}function m$($,f,i=1e4,z){let U=new TextEncoder,Y=()=>{};return new ReadableStream({start(O){let W=!1,C=(X)=>{if(W)return;W=!0,clearTimeout(Z);try{O.close()}catch{}z?.({aborted:X})};Y=C,O.enqueue(U.encode(`${JSON.stringify($)}
5
- `)),f.onSettle((X)=>{if(W||X.status!=="resolved")return;O.enqueue(U.encode(`${JSON.stringify([X.path,X.variantKey,X.data])}
6
- `))});let Z=setTimeout(()=>C(!0),i);f.allSettled().then(()=>C(!1),()=>C(!1))},cancel(){Y(!1)}})}var rf=async()=>(await import("./chunk-yed5whgs.js")).default,F1,H1=async(...$)=>{return F1??=import("react-dom/server.browser").catch((f)=>{throw F1=void 0,f}),(await F1).renderToReadableStream(...$)},tf=1e4,af=`
7
- !function(){try{var d=document.documentElement,c=d.classList;
8
- c.remove('light','dark');
9
- var e=localStorage.getItem('theme');
10
- if('system'===e||(!e&&'system'===defaultTheme)){
11
- var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);
12
- if(m.media!==t||m.matches){d.style.colorScheme='dark';c.add('dark')}
13
- else{d.style.colorScheme='light';c.add('light')}
14
- }else if(e){
15
- c.add(e||'')
16
- }}catch(e){}}()
17
- `;async function ef($,f,i){let z=`${i==="italic"?"italic,":""}wght@${i==="italic"?"1,":""}${f}`,O=(await(await fetch(`https://fonts.googleapis.com/css2?family=${$}:${z}&display=swap`,{headers:{"User-Agent":"Mozilla/5.0 Firefox/1.0"}})).text()).match(/url\(([^)]+)\)/)?.[1];return await fetch(O).then((W)=>W.arrayBuffer())}var S1="/assets";function $i($){let f=$.filter((i)=>i===S1||i.startsWith(`${S1}/`));if(f.length>0){let i=f.length>1;throw Error(`View route path${i?"s":""} ${f.map((z)=>`"${z}"`).join(", ")} use${i?"":"s"} the reserved "${S1}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}class b1{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];root=null;shellReporter=R$();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let f=f$();this.partialRendering=$.partialRendering??f.partialRendering,this.hooks={onRequestStart:$.onRequestStart??f.onRequestStart,onRequestEnd:$.onRequestEnd??f.onRequestEnd,onRequestFail:$.onRequestFail??f.onRequestFail,onStreamComplete:$.onStreamComplete??f.onStreamComplete};let i={"/":$.rootRouter,"/auth":t0};this.flatViewRoutes=S0(i),$i(Object.keys(this.flatViewRoutes)),this.routeManifest=k0(i),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,z])=>z.at(-1)!=="FILE")),this.componentTree=P0(i),this.flatComponentTree=x1(this.componentTree),this.root=$.root}async passesFeatureGates($){let f=j(L0);for(let i of $)if(!await f.enabled(i))return!1;return!0}async onRequestEnd($){return v1(),await this.hooks.onRequestEnd($)}completeStream($,f){let i=(z)=>{j0.error(z?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(z)})};try{Promise.resolve(this.hooks.onStreamComplete($,f)).catch(i)}catch(z){i(z)}}modulePreloadLinks($){let{clientEntry:f,modulePreloadManifest:i,views:z,routeKey:U}=$,Y=()=>{let C=new Set(f?.preload??[]);for(let Z of z)for(let X of i?.[Z]??[])C.add(X);return[...C].map((Z)=>K0("link",{key:`modulepreload:${Z}`,rel:"modulepreload",href:Z}))};if(!i)return Y();let O=this.preloadCache.get(i);if(!O||O.clientEntry!==f)O={clientEntry:f,byRoute:new Map},this.preloadCache.set(i,O);let W=O.byRoute.get(U);if(!W)W=Y(),O.byRoute.set(U,W);return W}async render($){let{req:f,runInRequestScope:i,csrfTokenHMAC:z,currentPathName:U,headers:Y,i18n:O,params:W,pathname:C,serverQueries:Z,userAgent:X,noStream:B,url:J,user:L,viewData:G,breadcrumbs:N,urlLocaleSegment:D,meta:F,isOgRequest:q,appId:x,features:K}=$,w=C.replace(`/${D}`,""),g={kind:"view",data:{meta:F,pageData:{[w]:G},__csrf:z.toString("base64"),prefetchedData:{},i18n:O,auth:{user:L},routeManifest:this.clientRouteManifest,breadcrumbs:N,router:{urlLocaleSegment:D,pathname:U,params:W,currentPath:C,searchParams:J.search,is404:!U?!0:!1},appId:x,features:K,componentTree:[["404",[]],...this.componentTree]},head:{}},k=this.root,M=this.routeManifest[U];return async(E)=>{let{bootstrapModules:T=[],loaders:v,getStyles:a,viewImportMap:l,cssManifest:z0,ogMap:e,viewModules:P,clientEntry:U0,modulePreloadManifest:D0}=E,u=U0?[]:T,W0=(p)=>[p,`window.loaders=${v}`,...U0?[`import(${JSON.stringify(U0.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(q){let p=null,O0=null;for(let Y0 of M??[])if(typeof e[Y0]==="function")O0=Y0,p=e[Y0];if(!p)return new Response("Not found",{status:404});let zf=Object.values(g.data.pageData)[0];try{await H1(K0(p,zf[O0]),{onError:()=>{}})}catch(Y0){let{fonts:Uf,...Wf}=Y0.satoriOptions,Of=await Promise.all(Uf.map((_0)=>{return ef(_0.name,_0.weight,_0.style).then((Xf)=>({..._0,data:Xf}))})),m1=new Headers(Y);m1.set("Content-Type","image/png");let[Yf,Zf]=await Promise.all([rf(),C0("Rendering an OG image")]),Cf=await Yf(Y0.jsx,{...Wf,fonts:Of}),Jf=await Zf(Buffer.from(Cf)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(Jf),{headers:m1})}return new Response("data")}g.data.cssManifest=z0,g.data.modulePreloadManifest=D0??{};let g0=this.modulePreloadLinks({clientEntry:U0,modulePreloadManifest:D0,views:M??["404"],routeKey:U??"404"}),q0=await a(M);g.data.prefetchedData=Z.snapshotResolved(),Z.markRenderStart();let A=new AbortController,m=setTimeout(()=>A.abort(),tf),s=h0(X)||B,y0=Bun.env.NODE_ENV!=="production"&&!s&&U&&this.shellReporter.shouldObserve(U)?h$():null,h1=q$();try{let p=await H1(K0(of,{children:[...g0,...q0,K0("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:af}}),K0(k,{data:g.data,viewImportMap:l,viewModules:P,serverQueries:Z,dictionarySink:h1,key:"root"})]}),{bootstrapScriptContent:W0(`window.__GEMI_DATA__ = ${i0(g.data)}`),bootstrapModules:u,signal:A.signal,...s?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(O0){if(Bun.env.NODE_ENV!=="production")console.error(O0)}});if(p.allReady.catch(()=>{}).finally(()=>clearTimeout(m)),s)await p.allReady.catch(()=>{});return new Response(g1(p,Z,{onShell:s?void 0:()=>Z.markShell(),onChunk:y0?.onChunk,onClose:()=>i(()=>{if(this.completeStream(f,Z.summarize(A.signal.aborted)),y0)this.shellReporter.report(U,y0.measure())})},h1),{status:!U?404:200,headers:Y})}catch(p){clearTimeout(m);let O0=await H1(K0("div"),{bootstrapScriptContent:W0(`window.error= ${i0(p.message)}; window.stack_trace=${i0(p.stack)};window.__GEMI_DATA__ = ${i0(g.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...u]:u});return new Response(g1(O0,Z,{onClose:()=>i(()=>this.completeStream(f,Z.summarize(A.signal.aborted)))}),{status:!U?404:200,headers:Y})}}}async handleViewRequest($){let f=new URL($.url),i=f.pathname.endsWith(".json"),z=f.pathname.endsWith(".og"),U=f.pathname.replace(".json","").replace(".og",""),[,Y,...O]=U.split("/"),W=`/${O.join("/")}`,C=null,Z=null,X=j(b);if(!X.supportedLocales.includes(Y))W=U;else C=Y,Z=Y;if(X.isLocaleAware&&!z){let K=j(b).detectLocale(new Q($,{},"view",W));if(Z===null&&K!==X.defaultLocale){let w=f.pathname==="/"?"":f.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${K}${w}${f.search}`}})}}W=W.replace("//","/");let J=[],L=[],G=null,N={},D=null,F=!1,q=[];try{let K=b0(this.flatViewRoutes,W);if(K){if(G=K.routePath,N=K.params,J=K.route.exec,L=K.route.middleware,q=K.route.features,F=L.includes("no-stream"),i&&this.partialRendering){let w=$.headers.get(E1),g=D$({flatViewRoutes:this.flatViewRoutes,supportedLocales:j(b).supportedLocales,from:w,origin:f.origin,to:{segments:K.route.segments,params:N,search:f.search}});if(g.startIndex>0)J=J.slice(g.startIndex),D={from:w,carriedViews:g.carriedViews}}}}catch(K){throw K}let x=new Q($,N,"view",G);return this.hooks.onRequestStart(x),await V.run(x,async()=>{let K=null,w=V.getStore(),g=V0.getStore(),k=(T)=>V0.run(g,()=>V.runWith(w,T));w.serverQueries=new X0(E0($));let M=new Set;if(w.serverQueries.onQueryFail((T)=>{M.add(T.error);try{k(()=>Promise.resolve(this.hooks.onRequestFail(E,T.error)).catch(()=>{}))}catch{}}),Z){let T=Z.replaceAll("/","");Z0.setLocale(T)}else Z0.setLocale();let E=w.req;v1();try{if(await j(T0).runMiddleware(L),q.length>0&&!await this.passesFeatureGates(q))G=null,J=[],E.routePath="";let T=j(b),v=T.isEnabled,a=T.isLocaleAware,l={};if(a){let A=null;if(Z)A=Z.replaceAll("/",""),w.setLocale(A);else A=T.detectLocale(new Q($,E.params)),w.setLocale(A);let m=v?T.getPageTranslations(A,E.routePath):{};l={supportedLocales:T.supportedLocales,currentLocale:A,dictionary:{[A]:m},defaultLocale:T.defaultLocale}}await c$(l.currentLocale??"");let z0=await Promise.all(J.map((A)=>A(E))),e=w.cookies,P=w.headers;K={data:z0,cookies:e,headers:P,user:w.user,prefetchedData:w.serverQueries.snapshotResolved(),currentPathName:G,params:E.params,urlLocaleSegment:C,meta:w.renderMeta(),appId:j(D1).id,features:await j(L0).forClient()};let{params:U0,user:D0}=K,u={},W0={};for(let A of z0??[]){let[m,s]=Object.entries(A)?.[0]??[];if(!m||!s)continue;W0[`${m}:${G}`]=s.breadcrumb,u[m]=s}let g0=u.FILE;if(g0){for(let A of e)P.append("Set-Cookie",A.toString());try{await this.onRequestEnd(E)}catch(A){j0.error(A?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(A)})}return await p$(g0,P)}if(i){P.set("Content-Type","application/x-ndjson; charset=utf-8"),P.append("Vary",E1),e.forEach((m)=>P.append("Set-Cookie",m.toString())),await this.hooks.onRequestEnd(E);let A={meta:D&&!w.metadata.touched?null:K.meta,data:{[W]:u},breadcrumbs:W0,prefetchedData:w.serverQueries.snapshotResolved(),i18n:l,features:K.features,is404:!G,appId:K.appId,partial:D};return new Response(m$(A,w.serverQueries,void 0,({aborted:m})=>k(()=>this.completeStream(E,w.serverQueries.summarize(m)))),{headers:P})}if(P.set("Content-Type","text/html; charset=utf-8"),!F)P.append("Vary","User-Agent");for(let A of e)P.append("Set-Cookie",A.toString());let q0=Bun.CSRF.generate(process.env.SECRET);P.append("Set-Cookie",`csrf_token=${q0}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`);try{await this.onRequestEnd(E)}catch(A){j0.error(A?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(A)})}return await this.render({req:E,runInRequestScope:k,csrfTokenHMAC:Buffer.from(""),currentPathName:G,headers:P,i18n:l,params:U0,pathname:f.pathname,serverQueries:w.serverQueries,userAgent:$.headers.get("user-agent"),noStream:F,url:f,user:D0,viewData:u,breadcrumbs:W0,urlLocaleSegment:C,meta:K.meta,appId:K.appId,features:K.features,isOgRequest:z})}catch(T){if(T.kind===A0)if(i){let{status:v=400,data:a,directive:l,headers:z0}=T.payload.api;return new Response(JSON.stringify({data:a,directive:l}),{headers:z0,status:v})}else{let{status:v=400,error:a}=T.payload.view;return new Response(a?.message,{...T.payload.view,status:v})}if(!M.has(T))this.hooks.onRequestFail(E,T);throw T}})}}class y$ extends y{routes={"/api-routes":this.get(()=>{let $=j(m0).flatRoutes,f=[];for(let[i,z]of Object.entries($))for(let[U,Y]of Object.entries(z)){let{exec:O,middleware:W}=Y;f.push({path:i,method:U,middleware:W})}return f}),"/view-routes":this.get(()=>{let $=j(b1).flatViewRoutes,f=[];for(let[i,{middleware:z,viewPath:U}]of Object.entries($))f.push({path:i,method:"GET",viewPath:U,middleware:z});return f})}}class m0{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let f=$$();this.onRequestStart=$.onRequestStart??f.onRequestStart,this.onRequestEnd=$.onRequestEnd??f.onRequestEnd,this.onRequestFail=$.onRequestFail??f.onRequestFail,this.flatRoutes=O1({"/":$.rootRouter,"/auth":a0,"/__gemi__/services/i18n":e0,"/__gemi__/services/logs":W1,"/__gemi__/services/image":i1,"/__gemi__/debug":y$})}getRouteHandlerAndParams($){let i=new URL($.url).pathname.replace("/api",""),z={},U;for(let[Y]of Object.entries(this.flatRoutes))try{let O=new URLPattern({pathname:Y});if(O.test({pathname:i})){U=Y,z=O.exec({pathname:i})?.pathname.groups;break}}catch(O){console.error(O)}return{params:z,path:U}}async runRouteMiddleware($,f){let z=this.flatRoutes[$][f.rawRequest.method].middleware;try{await j(T0).runMiddleware(z)}catch(U){if(U.kind===A0){if(f.rawRequest.url.includes("/api")){let{status:Y=400,data:O,headers:W}=U.payload.api;return new Response(JSON.stringify(O),{status:Y,headers:{"Content-Type":"application/json",...W}})}}else throw this.onRequestFail(f,U),console.error(U),U}}async getRouteData($){let f=this.flatRoutes[$],i=V.getStore(),z=f[i.req.rawRequest.method].exec??(()=>Promise.resolve({})),U={};try{U=await z()}catch(Y){if(Y.kind===A0){let{status:O=400,data:W,headers:C}=Y.payload.api;return new Response(JSON.stringify(W),{status:O,headers:{"Content-Type":"application/json",...C}})}throw this.onRequestFail(i.req,Y),console.error(Y),Y}return U}mergeContextIntoResponse($,f,i){let z=[];f?.forEach((O,W)=>z.push([W,O]));let U=[...typeof f?.getSetCookie==="function"?f.getSetCookie():[],...Array.from(i??[])];if(z.length===0&&U.length===0)return $;let Y=(O)=>{for(let[W,C]of z){if(W.toLowerCase()==="set-cookie")continue;if(!O.has(W))O.set(W,C)}for(let W of U)O.append("Set-Cookie",W)};try{return Y($.headers),$}catch{let O=new Headers($.headers);return Y(O),new Response($.body,{status:$.status,statusText:$.statusText,headers:O})}}async handleApiRequest($){let{params:f,path:i}=this.getRouteHandlerAndParams($),z=this.flatRoutes[i];if(!z||!z[$.method])return new Response(JSON.stringify({error:{message:"Not found"}}),{status:404});let U=new Q($,f,"api",i);if(!$.url.includes("/__gemi__"))this.onRequestStart(U);return await V.run(U,async()=>{let Y=V.getStore(),O=j(b);if(O.isEnabled){let B=O.detectLocale(U);Y.setLocale(B)}Y.setRequest(U);let W=await this.runRouteMiddleware(i,U);if(W instanceof Response)return W;let C=await this.getRouteData(i),Z=Y.headers,X=Y.cookies;if(C instanceof Response){let B=this.mergeContextIntoResponse(C,Z,X);if(!$.url.includes("/__gemi__"))this.onRequestEnd(U);return Y.destroy(),B}if(Z.set("Content-Type","application/json"),X.forEach((B)=>Z.append("Set-Cookie",B.toString())),!$.url.includes("/__gemi__"))this.onRequestEnd(U);return Y.destroy(),new Response(JSON.stringify(C),{headers:Z})})}}function E0($){let f=V0.getStore();return(i,z,U)=>{let Y=new URL($.url).origin,O=[R(i,z),U.toString()].filter((Z)=>Z.length>0).join("?"),W=new Request(`${Y}/${O}`,{headers:$.headers}),C=new Q(W,z);return V0.run(f,()=>V.run(C,async()=>{try{let Z=await j(m0).getRouteData(i);if(Z instanceof Response){let X=await Z.json().catch(()=>null);if(!Z.ok)throw new w0(R(i,z),U.toString(),Z.status,X);return X}return Z}catch(Z){if(Z instanceof w0)throw Z;let X=new w0(R(i,z),U.toString(),500,{message:Z instanceof Error?Z.message:String(Z)});throw X.cause=Z,X}}))}}class p0{static ensure($,f={}){let i=V.getStore();if(i.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return i.serverQueries??=new X0(E0(i.req.rawRequest)),i.serverQueries.ensure($,f,"prefetch")}static async instant($,...f){let i=p0.ensure($,f[0]);if(await i.promise,i.status==="rejected")throw i.error;return i.data}static prefetch($,...f){p0.ensure($,f[0])}static noPrefetch(){let $=V.getStore();if($.req.kind==="api")throw Error("Query.noPrefetch() cannot be called from an API request");$.serverQueries??=new X0(E0($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}class d${static absolute($,...f){return`${process.env.HOST_NAME}${R(String($),f[0]??{})}`}static relative($,...f){return R(String($),f[0]??{})}}class n${name="Meta";static description($){V.getStore().metadata.description($)}static title($){V.getStore().metadata.title($)}static openGraph($){V.getStore().metadata.openGraph($)}}var fi={set($,f,i){V.getStore().setCookie($,f,i)},setIfAbsent($,f,i){if(V.getStore().req.cookies.has($))return!1;return V.getStore().setCookie($,f,i),!0},delete($){V.getStore().deleteCookie($)}};class k1{config;static token="redis";instance=null;constructor($={}){this.config=$}get client(){return this.instance??=new(ii())(this.config.url,this.config.options)}set client($){this.instance=$}}function ii(){let $=globalThis.Bun?.RedisClient;if(typeof $!=="function")throw Error("Redis requires Bun's built-in Redis client, which this runtime does not provide. Run the app under Bun, or bind your own client for the 'redis' token.");return $}class n extends _{static getFacadeAccessor(){return k1}static get client(){return this.getFacadeRoot().client}static get($){return n.client.get($)}static set($,f){return n.client.set($,f)}static del(...$){return n.client.del(...$)}static exists($){return n.client.exists($)}static incr($){return n.client.incr($)}static expire($,f){return n.client.expire($,f)}static ttl($){return n.client.ttl($)}}class u$ extends _{static getFacadeAccessor(){return l$}static consume($,f={}){return this.getFacadeRoot().consume($,f)}}class s$ extends _{static getFacadeAccessor(){return L0}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 refresh(){return this.getFacadeRoot().refresh()}}class c0{bound;constructor($){this.bound=$}get name(){return this.bound??P1()}get sql(){return this.connection().sql}get dialect(){return this.connection().dialect}async query($){return await this.run($,"query")}async execute($){let f=await this.run($,"execute");return Number(f?.count??0)}async transaction($){let f=this.name,i=this.connection(f);return a$(i.sql,(z)=>r$(f,()=>$(z)),{slowTransactionThreshold:i.config.slowTransactionThreshold,connection:f})}run($,f){let i=this.connection(),{text:z,values:U}=$f($,e$(i.dialect),f);return(this.handle()??i.sql).unsafe(z,U)}handle(){let $=o$();if($===void 0)return;return P1()===this.name?$:void 0}connection($=this.name){return t$($),j(R1).connection($)}}var x0=new c0;class ff extends _{static getFacadeAccessor(){return R1}static connection($){return new c0($)}static get sql(){return x0.sql}static get dialect(){return x0.dialect}static query($){return x0.query($)}static execute($){return x0.execute($)}static transaction($){return x0.transaction($)}static close(){return this.getFacadeRoot().close()}}export{_ as Zb,d0 as _b,M0 as $b,o as ac,Z0 as bc,l0 as cc,u0 as dc,Fi as ec,y1 as fc,s0 as gc,d1 as hc,$1 as ic,f1 as jc,G3 as kc,t1 as lc,a1 as mc,N0 as nc,T0 as oc,H3 as pc,$$ as qc,f$ as rc,A1 as sc,j0 as tc,D1 as uc,v$ as vc,_1 as wc,b$ as xc,k$ as yc,mf as zc,M1 as Ac,P$ as Bc,L0 as Cc,S1 as Dc,b1 as Ec,m0 as Fc,p0 as Gc,d$ as Hc,n$ as Ic,fi as Jc,k1 as Kc,n as Lc,u$ as Mc,s$ as Nc,c0 as Oc,ff as Pc};
18
-
19
- //# debugId=EC6A422AE840373D64756E2164756E21