gemi 0.95.0 → 0.96.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 (183) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/app/index.js +1 -1
  4. package/dist/bun/plugin.js +1 -1
  5. package/dist/bun/preload.js +1 -1
  6. package/dist/{chunk-p3mdtnvv.js → chunk-1pbwrzwp.js} +2 -2
  7. package/dist/{chunk-j2nx0dtq.js.map → chunk-1pbwrzwp.js.map} +1 -1
  8. package/dist/{chunk-qqev9e50.js → chunk-1vs4xhcg.js} +2 -2
  9. package/dist/{chunk-qqev9e50.js.map → chunk-1vs4xhcg.js.map} +1 -1
  10. package/dist/{chunk-7dnb21s9.js → chunk-2tm56xq1.js} +2 -2
  11. package/dist/{chunk-7dnb21s9.js.map → chunk-2tm56xq1.js.map} +1 -1
  12. package/dist/{chunk-j9x86xsc.js → chunk-3tn480wt.js} +2 -2
  13. package/dist/{chunk-j9x86xsc.js.map → chunk-3tn480wt.js.map} +1 -1
  14. package/dist/{chunk-7hfv5n00.js → chunk-48dek9s7.js} +3 -3
  15. package/dist/{chunk-7hfv5n00.js.map → chunk-48dek9s7.js.map} +1 -1
  16. package/dist/{chunk-b8m6zs7e.js → chunk-4qjy1bts.js} +2 -2
  17. package/dist/{chunk-b8m6zs7e.js.map → chunk-4qjy1bts.js.map} +1 -1
  18. package/dist/{chunk-7s5nh5mx.js → chunk-4rns9cnb.js} +2 -2
  19. package/dist/{chunk-7s5nh5mx.js.map → chunk-4rns9cnb.js.map} +1 -1
  20. package/dist/{chunk-1hnpr3xt.js → chunk-5wgx5n2q.js} +2 -2
  21. package/dist/{chunk-1hnpr3xt.js.map → chunk-5wgx5n2q.js.map} +1 -1
  22. package/dist/{chunk-xtqxy492.js → chunk-6397mbr2.js} +3 -3
  23. package/dist/{chunk-xtqxy492.js.map → chunk-6397mbr2.js.map} +1 -1
  24. package/dist/{chunk-tcefqn3d.js → chunk-63cp4s8g.js} +2 -2
  25. package/dist/{chunk-tcefqn3d.js.map → chunk-63cp4s8g.js.map} +1 -1
  26. package/dist/{chunk-56gce2z7.js → chunk-64j3yef2.js} +2 -2
  27. package/dist/{chunk-56gce2z7.js.map → chunk-64j3yef2.js.map} +1 -1
  28. package/dist/{chunk-j2nx0dtq.js → chunk-68zf43ah.js} +2 -2
  29. package/dist/{chunk-p3mdtnvv.js.map → chunk-68zf43ah.js.map} +1 -1
  30. package/dist/{chunk-7ktsceyz.js → chunk-69yw2pb1.js} +2 -2
  31. package/dist/{chunk-7ktsceyz.js.map → chunk-69yw2pb1.js.map} +1 -1
  32. package/dist/{chunk-x24davqq.js → chunk-6abjjfjr.js} +2 -2
  33. package/dist/{chunk-x24davqq.js.map → chunk-6abjjfjr.js.map} +1 -1
  34. package/dist/{chunk-z9ydpvc8.js → chunk-77kw61f4.js} +2 -2
  35. package/dist/{chunk-z9ydpvc8.js.map → chunk-77kw61f4.js.map} +1 -1
  36. package/dist/{chunk-h24rv10h.js → chunk-7fn3wwyq.js} +2 -2
  37. package/dist/{chunk-h24rv10h.js.map → chunk-7fn3wwyq.js.map} +1 -1
  38. package/dist/{chunk-mf936r5e.js → chunk-7keqx61j.js} +2 -2
  39. package/dist/{chunk-mf936r5e.js.map → chunk-7keqx61j.js.map} +1 -1
  40. package/dist/{chunk-jrp35qrk.js → chunk-80t4tfke.js} +1 -1
  41. package/dist/{chunk-323715e8.js → chunk-8ma08vxq.js} +2 -2
  42. package/dist/{chunk-323715e8.js.map → chunk-8ma08vxq.js.map} +1 -1
  43. package/dist/{chunk-nqabsqty.js → chunk-99wzvsz5.js} +4 -4
  44. package/dist/{chunk-nqabsqty.js.map → chunk-99wzvsz5.js.map} +1 -1
  45. package/dist/{chunk-2jse74pn.js → chunk-a9nxjfdy.js} +2 -2
  46. package/dist/{chunk-2jse74pn.js.map → chunk-a9nxjfdy.js.map} +1 -1
  47. package/dist/{chunk-2yyr5tdc.js → chunk-aa13sgs2.js} +1 -1
  48. package/dist/{chunk-jxhznqhe.js → chunk-bf1q3m7a.js} +2 -2
  49. package/dist/{chunk-jxhznqhe.js.map → chunk-bf1q3m7a.js.map} +1 -1
  50. package/dist/{chunk-3fjkbcra.js → chunk-bvsevtpp.js} +1 -1
  51. package/dist/{chunk-nfhy3sp8.js → chunk-c0k26g4n.js} +2 -2
  52. package/dist/{chunk-nfhy3sp8.js.map → chunk-c0k26g4n.js.map} +1 -1
  53. package/dist/{chunk-ssqxzcad.js → chunk-c9vga0sk.js} +3 -3
  54. package/dist/{chunk-ssqxzcad.js.map → chunk-c9vga0sk.js.map} +1 -1
  55. package/dist/{chunk-w98tp5fa.js → chunk-cp8gxeqs.js} +2 -2
  56. package/dist/{chunk-w98tp5fa.js.map → chunk-cp8gxeqs.js.map} +1 -1
  57. package/dist/{chunk-5en4ydde.js → chunk-dn2mw39y.js} +2 -2
  58. package/dist/{chunk-5en4ydde.js.map → chunk-dn2mw39y.js.map} +1 -1
  59. package/dist/{chunk-qxda7pzm.js → chunk-f6s7ddjz.js} +2 -2
  60. package/dist/{chunk-qxda7pzm.js.map → chunk-f6s7ddjz.js.map} +1 -1
  61. package/dist/chunk-f9t39vwk.js +5 -0
  62. package/dist/chunk-f9t39vwk.js.map +10 -0
  63. package/dist/{chunk-fq03tz45.js → chunk-gykbgtvg.js} +2 -2
  64. package/dist/{chunk-fq03tz45.js.map → chunk-gykbgtvg.js.map} +1 -1
  65. package/dist/{chunk-mym0zxxp.js → chunk-h15bd9vn.js} +2 -2
  66. package/dist/{chunk-mym0zxxp.js.map → chunk-h15bd9vn.js.map} +1 -1
  67. package/dist/{chunk-38k1kjyb.js → chunk-hsec03gh.js} +2 -2
  68. package/dist/{chunk-38k1kjyb.js.map → chunk-hsec03gh.js.map} +1 -1
  69. package/dist/{chunk-2shkf2gs.js → chunk-jhaeemjf.js} +2 -2
  70. package/dist/{chunk-2shkf2gs.js.map → chunk-jhaeemjf.js.map} +1 -1
  71. package/dist/{chunk-bk4f99s4.js → chunk-jv38q9n7.js} +2 -2
  72. package/dist/{chunk-bk4f99s4.js.map → chunk-jv38q9n7.js.map} +1 -1
  73. package/dist/{chunk-fyxp4bn0.js → chunk-kcp39g56.js} +2 -2
  74. package/dist/{chunk-fyxp4bn0.js.map → chunk-kcp39g56.js.map} +1 -1
  75. package/dist/{chunk-qj5ts9d5.js → chunk-msg6re1f.js} +2 -2
  76. package/dist/{chunk-qj5ts9d5.js.map → chunk-msg6re1f.js.map} +1 -1
  77. package/dist/{chunk-kzh8bkg5.js → chunk-n63xjrck.js} +2 -2
  78. package/dist/{chunk-kzh8bkg5.js.map → chunk-n63xjrck.js.map} +1 -1
  79. package/dist/{chunk-9g5cpkkk.js → chunk-nffk2cj3.js} +2 -2
  80. package/dist/{chunk-9g5cpkkk.js.map → chunk-nffk2cj3.js.map} +1 -1
  81. package/dist/{chunk-z16nyxb8.js → chunk-np5b3cd7.js} +2 -2
  82. package/dist/{chunk-z16nyxb8.js.map → chunk-np5b3cd7.js.map} +1 -1
  83. package/dist/{chunk-twhf7w1x.js → chunk-pjg7gqnh.js} +1 -1
  84. package/dist/{chunk-f6veb369.js → chunk-prg5k57m.js} +2 -2
  85. package/dist/{chunk-f6veb369.js.map → chunk-prg5k57m.js.map} +1 -1
  86. package/dist/chunk-qttatc7h.js +5 -0
  87. package/dist/chunk-qttatc7h.js.map +12 -0
  88. package/dist/chunk-rc4z7ykq.js +17 -0
  89. package/dist/{chunk-ykbehyp9.js.map → chunk-rc4z7ykq.js.map} +4 -4
  90. package/dist/{chunk-5px4rkzf.js → chunk-shb51m4y.js} +2 -2
  91. package/dist/{chunk-5px4rkzf.js.map → chunk-shb51m4y.js.map} +1 -1
  92. package/dist/{chunk-8g99gnsd.js → chunk-snz7nze3.js} +2 -2
  93. package/dist/{chunk-8g99gnsd.js.map → chunk-snz7nze3.js.map} +1 -1
  94. package/dist/{chunk-qpek76vn.js → chunk-tymhsmgq.js} +3 -3
  95. package/dist/{chunk-qpek76vn.js.map → chunk-tymhsmgq.js.map} +1 -1
  96. package/dist/{chunk-f6e2t4vb.js → chunk-xf9axxzx.js} +3 -3
  97. package/dist/{chunk-f6e2t4vb.js.map → chunk-xf9axxzx.js.map} +1 -1
  98. package/dist/{chunk-et6thczw.js → chunk-xmjhensy.js} +2 -2
  99. package/dist/{chunk-et6thczw.js.map → chunk-xmjhensy.js.map} +1 -1
  100. package/dist/{chunk-37jb6q13.js → chunk-xp6nr441.js} +2 -2
  101. package/dist/{chunk-37jb6q13.js.map → chunk-xp6nr441.js.map} +1 -1
  102. package/dist/{chunk-bedkys40.js → chunk-y4fp0eg9.js} +2 -2
  103. package/dist/{chunk-bedkys40.js.map → chunk-y4fp0eg9.js.map} +1 -1
  104. package/dist/chunk-yhkffean.js +5 -0
  105. package/dist/{chunk-dhe96f7z.js.map → chunk-yhkffean.js.map} +1 -1
  106. package/dist/{chunk-qz2p0hv5.js → chunk-yk2mtcwv.js} +2 -2
  107. package/dist/{chunk-qz2p0hv5.js.map → chunk-yk2mtcwv.js.map} +1 -1
  108. package/dist/{chunk-zyw42zny.js → chunk-z8jf7jwg.js} +2 -2
  109. package/dist/{chunk-zyw42zny.js.map → chunk-z8jf7jwg.js.map} +1 -1
  110. package/dist/chunks/{ThemeProvider-z_MW40tl.js → ThemeProvider-Cqfwr6dk.js} +2 -2
  111. package/dist/chunks/ThemeProvider-Cqfwr6dk.js.map +1 -0
  112. package/dist/chunks/useParams-BN3XXfmG.js.map +1 -1
  113. package/dist/client/I18nContext.d.ts.map +1 -1
  114. package/dist/client/RouteStateContext.d.ts +3 -0
  115. package/dist/client/RouteStateContext.d.ts.map +1 -1
  116. package/dist/client/ServerDataProvider.d.ts +2 -0
  117. package/dist/client/ServerDataProvider.d.ts.map +1 -1
  118. package/dist/client/index.d.ts +2 -0
  119. package/dist/client/index.d.ts.map +1 -1
  120. package/dist/client/index.js +118 -2
  121. package/dist/client/index.js.map +1 -1
  122. package/dist/client/useDictionary.d.ts +5 -0
  123. package/dist/client/useDictionary.d.ts.map +1 -1
  124. package/dist/client/useFormatter.d.ts +24 -0
  125. package/dist/client/useFormatter.d.ts.map +1 -0
  126. package/dist/client/useRouteData.d.ts +2 -0
  127. package/dist/client/useRouteData.d.ts.map +1 -1
  128. package/dist/config/index.js +1 -1
  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 +1 -1
  134. package/dist/email/index.js +2 -2
  135. package/dist/email/index.js.map +1 -1
  136. package/dist/facades/Lang.d.ts +19 -0
  137. package/dist/facades/Lang.d.ts.map +1 -1
  138. package/dist/facades/index.js +1 -1
  139. package/dist/foundation/index.js +2 -2
  140. package/dist/foundation/index.js.map +1 -1
  141. package/dist/http/index.js +1 -1
  142. package/dist/i18n/Translator.d.ts +17 -0
  143. package/dist/i18n/Translator.d.ts.map +1 -1
  144. package/dist/i18n/config.d.ts +15 -0
  145. package/dist/i18n/config.d.ts.map +1 -1
  146. package/dist/i18n/dictionaryRuntime.js +1 -1
  147. package/dist/i18n/formatter.d.ts +52 -0
  148. package/dist/i18n/formatter.d.ts.map +1 -0
  149. package/dist/i18n/index.d.ts +1 -0
  150. package/dist/i18n/index.d.ts.map +1 -1
  151. package/dist/i18n/index.js +2 -2
  152. package/dist/i18n/index.js.map +2 -2
  153. package/dist/kernel/index.js +2 -2
  154. package/dist/kernel/index.js.map +1 -1
  155. package/dist/orm/index.js +2 -2
  156. package/dist/orm/index.js.map +1 -1
  157. package/dist/server/index.js +2 -2
  158. package/dist/server/index.js.map +1 -1
  159. package/dist/services/index.js +2 -2
  160. package/dist/services/index.js.map +1 -1
  161. package/dist/services/queue/work.js +2 -2
  162. package/dist/services/queue/work.js.map +1 -1
  163. package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
  164. package/dist/support/index.js +2 -2
  165. package/dist/support/index.js.map +1 -1
  166. package/dist/testing/Page.d.ts +2 -0
  167. package/dist/testing/Page.d.ts.map +1 -1
  168. package/dist/testing/index.js +10 -4
  169. package/dist/testing/index.js.map +1 -1
  170. package/package.json +1 -1
  171. package/skills/gemi-react-best-practices/SKILL.md +1 -0
  172. package/skills/gemi-react-best-practices/rules/i18n-format-with-use-formatter.md +41 -0
  173. package/dist/chunk-dhe96f7z.js +0 -5
  174. package/dist/chunk-m3z60v9d.js +0 -5
  175. package/dist/chunk-m3z60v9d.js.map +0 -11
  176. package/dist/chunk-safv6h9x.js +0 -5
  177. package/dist/chunk-safv6h9x.js.map +0 -10
  178. package/dist/chunk-ykbehyp9.js +0 -17
  179. package/dist/chunks/ThemeProvider-z_MW40tl.js.map +0 -1
  180. /package/dist/{chunk-jrp35qrk.js.map → chunk-80t4tfke.js.map} +0 -0
  181. /package/dist/{chunk-2yyr5tdc.js.map → chunk-aa13sgs2.js.map} +0 -0
  182. /package/dist/{chunk-3fjkbcra.js.map → chunk-bvsevtpp.js.map} +0 -0
  183. /package/dist/{chunk-twhf7w1x.js.map → chunk-pjg7gqnh.js.map} +0 -0
@@ -0,0 +1,17 @@
1
+ // @bun
2
+ import{Nd as C8,Ud as iJ}from"./chunk-bf1q3m7a.js";import{$d as ZZ,Le as dJ,ee as uZ}from"./chunk-adm5g1v8.js";import{$e as b4,Me as s3,Qe as SJ,Re as o4,Se as p3,Te as k3,We as g3,Xe as y3,Ye as e$,Ze as BJ,_e as AJ,af as y,ff as _,gf as n3,hf as a3,if as h3,kf as l1,lf as K0,mf as I3,uf as x7,vf as U$,wf as kJ}from"./chunk-h15bd9vn.js";import{Af as I1,Bf as e4,yf as iZ,zf as a0}from"./chunk-9xf2fx98.js";import{Cf as TJ,Df as V4,Ef as N}from"./chunk-eqtsfvvd.js";import{Hf as yJ}from"./chunk-br9p390p.js";import{If as NJ,Jf as DZ,Kf as FZ,Lf as hJ,Mf as cJ,Xf as lJ}from"./chunk-n4807648.js";import{kg as UZ}from"./chunk-ghz3e8b7.js";import{pg as VJ,ug as IJ}from"./chunk-7vjbebst.js";import{vg as vJ}from"./chunk-3fr22rtg.js";import{Cg as fJ,Gg as u}from"./chunk-qttatc7h.js";import{Hg as t$,Kg as C}from"./chunk-48dek9s7.js";import{Yg as _J}from"./chunk-2tm56xq1.js";import{bh as L4}from"./chunk-68zf43ah.js";function tZ($){return typeof $==="function"&&$.prototype!==void 0}function W1($){return typeof $==="string"?[$]:$}function eZ($,Z){let O=Z?"attachment":"inline",j=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${O}; filename="${j}"; filename*=UTF-8''${encodeURIComponent($)}`}function OW($){return"total"in $&&"partial"in $&&"body"in $}function A4(){return new Response("Not found",{status:404,headers:{"X-Content-Type-Options":"nosniff"}})}function TZ($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":y3($),"Content-Length":"0","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}})}async function jW($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(OW($))return{body:$.body,start:$.start,end:$.end,total:$.total,partial:$.partial,type:$.type,name:$.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}};let Z=$.file,O=Z instanceof Blob?Z:null,j=$.total??O?.size??-1;return{body:Z,start:$.start??0,end:$.end??j-1,total:j,partial:$.partial??!1,type:$.type??O?.type??"",name:$.name??Z?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function m3($,Z){if($ instanceof Response)return $;if(!$)return A4();let O=await jW($),{body:j,start:T,end:z,total:J,partial:W}=O;if(j instanceof Blob&&"exists"in j&&typeof j.exists==="function"){if(!await j.exists())return A4()}let{range:Y}=Z;if(Y){if(J<=0)return TZ(Math.max(J,0));if(!W){if(j instanceof Blob){let F=k3(Y,J);if(!F)return TZ(J);j=j.slice(F.start,F.end+1),T=F.start,z=F.end,W=!0}}}let X=Boolean(Y)&&W,D=X?206:O.status,U=new Headers;if(U.set("Accept-Ranges","bytes"),U.set("Content-Type",O.type||"application/octet-stream"),U.set("X-Content-Type-Options","nosniff"),X)U.set("Content-Range",g3(T,z,J)),U.set("Content-Length",String(z-T+1));else if(J>=0)U.set("Content-Length",String(J));if(O.name)U.set("Content-Disposition",eZ(O.name,O.download));if(O.etag)U.set("ETag",O.etag);if(O.lastModified)U.set("Last-Modified",O.lastModified.toUTCString());for(let[F,B]of Object.entries(O.extraHeaders))U.set(F,B);if((Z.method??"GET").toUpperCase()==="HEAD"){if(j&&"cancel"in j&&typeof j.cancel==="function")await j.cancel();return new Response(null,{status:D,headers:U})}return new Response(j,{status:D,headers:U})}function H4($){return tZ($)}class r{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,Z,O){this.method=$;this.handler=Z;this.methodName=O;this.handler=Z,this.methodName=O,this.method=$}get source(){if(!H4(this.handler)||typeof this.methodName!=="string")return;return{controller:this.handler,methodName:this.methodName}}__internal_use(){return{run:this.run.bind(this),middlewares:this.middlewares}}run($){if(H4(this.handler)){let Z=new this.handler;return Z[this.methodName].bind(Z)()}return this.handler()}middleware($){return this.middlewares=W1($),this}}class v4{url;headers;__internal_brand="ProxyHandler";middlewares=[];constructor($,Z){this.url=$;this.headers=Z}middleware($){return this.middlewares=W1($),this}run(){let $=new _,Z=$.headers.toJSON();for(let O of b4($.rawRequest))delete Z[O];return fetch(this.url,{method:$.rawRequest.method,headers:{...Z,...this.headers},body:$.rawRequest.body})}}class w4{constructor(...$){return new r(...$)}}class R4 extends r{__internal_brand="StreamHandler";async run($){let Z=N.getStore(),O=Z?.req?.rawRequest,j=p3(O?.headers.get("Range"));if(Z)Z.rangeRequest=j;try{let T=await super.run($);return await m3(T,{range:j,method:O?.method})}catch(T){if(T instanceof h3)return TZ(T.total);throw T}finally{if(Z)Z.rangeRequest=null}}}class q4{constructor(...$){return new R4(...$)}}class k4{__internal_brand="ResourceRoutes";first;second;constructor($){this.first={get:new r("GET",$,"list"),post:new r("POST",$,"store")},this.second={get:new r("GET",$,"show"),put:new r("PUT",$,"update"),delete:new r("DELETE",$,"delete")}}middleware($){if($.list)this.first.get.middleware($.list);if($.store)this.first.post.middleware($.store);if($.show)this.second.get.middleware($.show);if($.update)this.second.put.middleware($.update);if($.delete)this.second.delete.middleware($.delete);return this}}class N0{static __brand="ApiRouter";routes={};middlewares=[];middleware($){}get($,Z){return new r("GET",$,Z)}post($,Z){return new r("POST",$,Z)}put($,Z){return new r("PUT",$,Z)}patch($,Z){return new r("PATCH",$,Z)}delete($,Z){return new r("DELETE",$,Z)}resource($){return new k4($)}agent($){return TW($,this)}file($,Z){return new w4("GET",$,Z)}stream($,Z){return new q4("GET",$,Z)}proxy($,Z={}){return new v4($,Z)}}function TW($,Z){let O={stream:new r("POST",$,"stream"),attach:new r("POST",$,"attach"),stop:new r("POST",$,"stop"),upload:new r("POST",$,"upload")};return class extends N0{static __internal_brand="AgentRoute";static controller=$;static handlers=O;constructor(){super();this.middlewares=[...Z?.middlewares??[]]}routes={"/":O.stream,"/attach":O.attach,"/stop":O.stop,"/files":O.upload};static middleware(T){if(T.stream)O.stream.middleware(T.stream);if(T.attach)O.attach.middleware(T.attach);if(T.stop)O.stop.middleware(T.stop);if(T.upload)O.upload.middleware(T.upload);return this}}}class c3{method;url;meta;__internal_brand="McpRoute";constructor($,Z,O){this.method=$;this.url=Z;this.meta=O}}class g4{static __brand="McpRouter";routes={};fromApiRoute($,Z,O){return new c3($,Z,O)}}function z0($,Z){return $.replace(/:([^/]+[*?]?)/g,(O,j)=>{let T=j.endsWith("?")||j.endsWith("*"),z=T?j.slice(0,-1):j,J=Z[z];if(J===void 0){if(T)return"";if(import.meta.env.DEV)throw Error(`Missing parameter: ${z}`);console.error(`Missing parameter: ${z} in URL: ${$}`)}return String(J)}).replace(/\/\//g,"/").replace(/\/$/,"")}class l3 extends a0{constructor($,Z=307){super("Redirect error");this.name="RedirectError",this.payload={api:{status:200,data:{},directive:{kind:"Redirect",path:$}},view:{status:Z,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:$}}}}}class $O{static to($,...Z){let[O={}]=Z,{search:j={},params:T={},permanent:z,status:J}={params:{},status:307,permanent:!1,...O},W=new URLSearchParams(j).toString();throw new l3([z0($,T)||"/",W.toString()].filter(Boolean).join("?"),J??(z?301:307))}static external($,Z=307){throw new l3($,Z)}}var y4=Symbol.for("gemi.HttpResponse");class c1{kind;body;status;headers;[y4]=!0;constructor($,Z,O,j){this.kind=$;this.body=Z;this.status=O;this.headers=j}static json($,Z={}){let O=Z.status??200;return zW(O),new c1("json",$,O,new Headers(Z.headers))}static error($,Z,O={}){if(!Number.isInteger($)||$<400||$>599)throw RangeError(`HttpResponse.error: status must be an integer from 400 to 599, got ${$}.`);return c1.json({error:Z},{...O,status:$})}get ok(){return this.status>=200&&this.status<300}toResponse($,Z){let O=$,j=this.serialize(O);for(let T of Z)O.append("Set-Cookie",T);this.headers.forEach((T,z)=>{if(z.toLowerCase()!=="set-cookie")O.set(z,T)});for(let T of this.headers.getSetCookie())O.append("Set-Cookie",T);if(this.status>=400&&!this.headers.has("Cache-Control"))O.set("Cache-Control","no-store");return new Response(j,{status:this.status,headers:O})}serialize($){switch(this.kind){case"json":return $.set("Content-Type","application/json"),JSON.stringify(this.body)??null}}}function zW($){if(!Number.isInteger($)||$<200||$>599)throw RangeError(`HttpResponse: status must be an integer from 200 to 599, got ${$}.`);if($===204||$===205||$===304)throw RangeError(`HttpResponse.json: a ${$} response has no body.`)}function C$($){return typeof $==="object"&&$!==null&&$[y4]===!0}function JW($,Z,O={}){return c1.error($,Z,O)}class m4{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[Z,O]=$;this.handler=(j)=>{return new Z()[O](j)}}}async run($,Z){let{destination:O,permanent:j=!1,status:T=307}=await this.handler($);if(!O)throw Error(`Redirect destination is required see ${Z}`);return $O.to(O,{permanent:j,status:T}),{}}middleware($){return this.middlewares=W1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function d3($,Z){if($ instanceof Response)return $;let O=$ instanceof Blob,j=O?$:$.file,T=O?$.name:$.name??$.file?.name,z=(O?$.type:$.type??$.file?.type)||"",J=O?!1:$.download??!1,W=O?200:$.status??200;if(!O)for(let[Y,X]of Object.entries($.headers??{}))Z.set(Y,X);if(j instanceof Blob&&"exists"in j&&typeof j.exists==="function"){if(!await j.exists())return new Response("Not found",{status:404})}if(Z.set("Content-Type",z||"application/octet-stream"),j instanceof Blob)Z.set("Content-Length",String(j.size));if(T)Z.set("Content-Disposition",eZ(T,J));return new Response(j instanceof Blob?j.stream():j,{status:W,headers:Z})}class p4{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[Z,O]=$;this.handler=(j)=>{return new Z()[O](j)}}}async run($,Z){let O=await this.handler($);if(!O)throw Error(`File route handler must return a file see ${Z}`);return{FILE:O}}middleware($){return this.middlewares=W1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}function h4($,Z){if(C$($))throw Error(`The handler of view "${Z}" returned an HttpResponse. HttpResponse is for api routes; a view handler returns its props.`);return $}class c4{viewPath;middlewares=[];featureGates=[];handler;constructor($,Z){this.viewPath=$;if(!Z)this.handler=()=>({});else if(typeof Z==="function")this.handler=Z;else{let[O,j]=Z;this.handler=(T)=>{return new O()[j](T)}}}async run($,Z){let O=h4(await this.handler($),this.viewPath);return{[this.viewPath]:{...O,breadcrumb:{label:O?.breadcrumb??"",href:Z}}}}middleware($){return this.middlewares=W1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class l4{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,Z,O){this.viewPath=$;if(typeof Z==="function")this.handler=Z,this.children=class extends V1{routes=O??{}};else if(Array.isArray(Z)){let[j,T]=Z;this.handler=(z)=>{return new j()[T](z)},this.children=class extends V1{routes=O??{}}}else this.children=class extends V1{routes=Z},this.handler=()=>({})}async run($,Z){let O=h4(await this.handler($),this.viewPath);return{[this.viewPath]:{...O,breadcrumb:{label:O?.breadcrumb??"",href:Z}}}}alwaysRun(){return this.alwaysRuns=!0,this}middleware($){return this.middlewares=W1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class V1{middlewares=[];featureGates=[];routes={};view($,Z){return new c4($,Z)}file($){return new p4($)}redirect($){return new m4($)}layout($,Z,O){return new l4($,Z,O)}}class w0{req;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let Z=this;return class extends Z{config=$}}}function WW($){return $}function YW(){return{aliases:{},global:[]}}var f$="redirect";function zZ($,Z="/"){if(typeof $!=="string"||!$.startsWith("/"))return Z;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return Z;try{let O=new URL($,"http://gemi.invalid");if(O.origin!=="http://gemi.invalid")return Z;let j=`${O.search}${O.hash}`.replaceAll("/","%2F"),T=`${O.pathname}${j}`.replaceAll(":","%3A");return T.startsWith("//")?Z:T}catch{return Z}}function d4($){let Z=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return Z?Z==="https":new URL($.url).protocol==="https:"}function XW($,Z=!0){let O=new URL($.rawRequest.url),j=O.pathname.replace(/\.(json|og)$/,""),[,T,...z]=j.split("/");if(C(u).supportedLocales.includes(T))j=`/${z.join("/")}`;return Z?`${j}${O.search}`:j}function DW($,Z){let O=(j)=>j.replace(/\/+$/,"")||"/";return O($)===O(Z)}function ZO($,Z){let O=Z||C(A).config.signInPath,j=/^[a-z][a-z\d+.-]*:/i.test(O);if(j?!/^https?:\/\//i.test(O):!O.startsWith("/"))throw Error(`\`auth.signInPath\` must be a path like "/auth/sign-in", or an http(s) URL for sign-in hosted elsewhere. Got "${O}". A route's own \`"auth:<path>"\` cannot carry a URL, because the alias parser splits it on the colon.`);let T=new URL(O,"http://gemi.invalid");if($?.kind==="view"){let z=XW($,!j);if(j||!DW(new URL(z,T).pathname,T.pathname))T.searchParams.set(f$,z)}return j?T.href:`${T.pathname}${T.search}`}var JZ="access_token";function i3($){return $?.cookies?.get("access_token")||$?.headers?.get("access_token")||null}async function OO($,Z){let O=i3(Z);if(!O)return null;return(await $.getSession(O,Z.headers.get("User-Agent")))?.user??null}class i4 extends w0{async run($){let Z=N.getStore(),O=Z.req;if(Z.user)return{};let j=await OO(C(A),O);if(!j)throw new l1({redirectTo:ZO(O,$)});return Z.setUser(j),{}}}class u4 extends w0{async run(...$){let[Z="public",O="864000",...j]=$,T=`${Z}, max-age=${O}${j.length>0?", ":""}${j.join(", ")}`;if($.length===0)T="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="public")T="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="private")T="private, max-age=0, stale-while-revalidate=300, stale-if-error=600";if(this.req.rawRequest.method==="GET")this.req.ctx().setHeaders("Cache-Control",T);return{}}}var FW={"Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Allow-Credentials":"true"};class s4 extends w0{config={origins:{"":{"Access-Control-Allow-Methods":"GET, HEAD, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Allow-Credentials":"true"}}};run(){let $=this.req,Z=$.rawRequest.headers.get("Origin");if(this.config.origins[Z]){$.ctx().setHeaders("Access-Control-Allow-Origin",Z);let O={...FW,...this.config.origins[Z]};for(let[j,T]of Object.entries(O))$.ctx().setHeaders(j,T)}return{}}}class o0{config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,Z={}){let O=Z.limit??this.config.limit,j=Z.window??this.config.window,T=Z.cost??1;if(n4("window",j),n4("limit",O),!Number.isFinite(T)||T<0)throw Error(`Rate limiter cost must be zero or greater, got ${T}`);return await this.config.driver.consume({key:$,limit:O,window:j*1000,cost:T})}}function n4($,Z){if(!Number.isFinite(Z)||Z<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${Z}`)}class WZ extends a0{constructor($){super("Rate limit exceeded");let Z={"Content-Type":"application/json",...$?t4($):{}};this.payload={api:{status:429,data:{error:I1("rate_limit","Rate limit exceeded",429)},headers:Z},view:{error:{message:"Rate limit exceeded"},status:429,headers:Z}}}}class r4 extends w0{async run($,Z){let O=UW();if(!O)return{};let j=await O.consume(this.key(),{limit:a4($)??this.config.limit,window:a4(Z)??this.config.window});if(this.config.headers!==!1){let T=this.req.ctx?.();if(T)for(let[z,J]of Object.entries(t4(j)))T.setHeaders(z,J)}if(!j.allowed)throw new WZ(j);return{}}key(){if(this.config.key)return this.config.key(this.req);return`${V$(this.req)}:${this.req.routePath??"*"}`}}function UW(){try{let $=C();return $.bound(o0)?$.make(o0):null}catch{return null}}function V$($){let Z=o4($.rawRequest);if(Z!==void 0)return Z;let O=$.headers.get("x-forwarded-for");if(O){let[j]=O.split(",");if(j?.trim())return j.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function t4($){let Z={"X-RateLimit-Limit":String($.limit),"X-RateLimit-Remaining":String($.remaining),"X-RateLimit-Reset":String(Math.ceil($.resetAt/1000))};if(!$.allowed)Z["Retry-After"]=String(Math.max(1,Math.ceil($.retryAfter/1000)));return Z}function a4($){if($===void 0||$===null||$==="")return;let Z=Number($);if(!Number.isFinite(Z)||Z<=0)return;return Z}class $8 extends w0{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new u3;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new u3;return{}}}class u3 extends a0{constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:e4("csrf","Invalid CSRF token",403)}},view:{}}}class Z8{policiesList={};constructor(){let $=this.register();for(let Z of $){let O=new Z;this.policiesList[Z.name]=O}}register(){return[]}}class O8{all($,Z){return!0}}import{createHmac as j8,randomBytes as GW}from"crypto";var o3="v2.";function r3($){return $.startsWith(o3)}function jO(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function T8($){let Z=GW(16).toString("hex"),O=j8("sha256",jO()).update(`${$}:${Z}`).digest("hex");return`${o3}${O}`}function TO($,Z){let O=j8("sha256",jO()).update(`legacy-session:${Z}:${$}`).digest("hex");return`${o3}${O}`}import{createHash as QW,createHmac as CW,randomInt as fW,timingSafeEqual as W8}from"crypto";function z8($,Z){return Math.floor($/Z)*Z}function BW($,Z){if(Z<=0)return 0;return Math.min(1,Math.max(0,(Z-$)/Z))}function t3($,Z,O,j){return Z*BW(O,j)+$}function KW($){let{current:Z,previous:O,elapsed:j,window:T,limit:z,cost:J}=$,W=z-J;if(W<0)return T;let Y=Math.max(0,T-j);if(O>0){let D=T*(1-(W-Z)/O);if(D<=T)return Math.max(0,Math.ceil(D-j))}if(Z<=W)return Y;if(Z<=0)return Y;let X=T*(1-W/Z);return Y+Math.max(0,Math.ceil(X))}function J8($){let{allowed:Z,current:O,previous:j,now:T,elapsed:z,window:J,limit:W,cost:Y}=$;if(Z){let D=t3(O,j,z,J);return{allowed:!0,limit:W,remaining:Math.max(0,Math.floor(W-D)),resetAt:T-z+J,retryAfter:0}}let X=KW({current:O,previous:j,elapsed:z,window:J,limit:W,cost:Y});return{allowed:!1,limit:W,remaining:0,resetAt:T+X,retryAfter:X}}class e3{}class $j extends e3{buckets=new Map;maxKeys;constructor($={}){super();this.maxKeys=Math.max(1,$.maxKeys??1e5)}consume($){let{key:Z,limit:O,window:j}=$,T=$.cost??1,z=Date.now(),J=z8(z,j),W=z-J,Y=this.roll(Z,j,J);Y.limit=O;let D=t3(Y.current,Y.previous,W,j)+T<=O;if(D)Y.current+=T;if(this.buckets.delete(Z),this.buckets.set(Z,Y),this.buckets.size>this.maxKeys)this.evict(z);return J8({allowed:D,current:Y.current,previous:Y.previous,now:z,elapsed:W,window:j,limit:O,cost:T})}clear(){this.buckets.clear()}get size(){return this.buckets.size}roll($,Z,O){let j=this.buckets.get($);if(!j||j.window!==Z)return{window:Z,limit:0,windowStart:O,current:0,previous:0};if(j.windowStart===O)return j;if(j.windowStart+Z===O)return j.previous=j.current,j.current=0,j.windowStart=O,j;return j.previous=0,j.current=0,j.windowStart=O,j}evict($){for(let[j,T]of this.buckets)if($-T.windowStart>=T.window*2)this.buckets.delete(j);let Z=this.maxKeys-Math.floor(this.maxKeys/10);if(this.buckets.size<=Z)return;let O=[...this.buckets].map(([j,T],z)=>({key:j,order:z,spent:T.limit>0?(T.current+T.previous)/T.limit:0}));O.sort((j,T)=>j.spent-T.spent||j.order-T.order);for(let{key:j}of O){if(this.buckets.size<=Z)break;this.buckets.delete(j)}}}var D8="h1.";function zO($,Z,O){let j=CW("sha256",jO()).update(`gemi:one-time:${$}:${Z}:${O}`).digest("hex");return`${D8}${j}`}function YZ($,Z,O,j){let T=typeof j==="string"?j:"",z=typeof O==="string"?O:"",J=z.startsWith(D8),W=zO($,Z,T),Y=Buffer.from(J?W:T),X=Buffer.from(z);if(Y.length!==X.length||T===""||z==="")return W8(Y,Y),!1;return W8(Y,X)}function F8($){let Z="";for(let O=0;O<$;O++)Z+=String(fW(0,10));return Z}var U8=320;function XZ($){if(typeof $!=="string")return null;let Z=$.trim();if(Z===""||Z.length>U8)return null;return Z.toLowerCase()}function Zj($){if(typeof $!=="string")return null;let Z=$.trim();if(Z.length>U8)return null;let O=Z.toLowerCase();if(O.length<3||O.length>254||!/^[^\s@]+@[^\s@]+$/.test(O))return null;return O}var Y8=null;function G8(){try{let $=C();if(typeof $?.bound==="function"&&$.bound(o0))return $.make(o0)}catch{}return Y8??=new o0({driver:new $j,limit:1000,window:60}),Y8}function X8($){return $.length<=64?$:`sha256:${QW("sha256").update($).digest("hex")}`}async function I$($,Z,O,j){let T=G8(),z=[[`auth:code-${$}:ip:${X8(V$(O))}`,j.perIp]];if(Z!==null)z.push([`auth:code-${$}:email:${X8(Z)}`,j.perEmail]);for(let[J,W]of z){if(!W)continue;let[Y,X]=W,D=await T.consume(J,{limit:Y,window:X});if(!D.allowed)throw new WZ(D)}}async function B8($,Z,O,j=10){let T=Math.max(86400,Math.ceil(j*60*(O+1)));return(await G8().consume(`auth:code-attempt:${$}:${Z}`,{limit:O,window:T})).allowed}import{randomBytes as jj}from"crypto";class Oj extends _{schema={name:{string:"Invalid name",required:"Name is required","min:2":"Name must be at least 3 characters"},email:{string:"Invalid email",required:"Email is required",email:"Invalid email"},password:{"min:8":"Password must be at least 9 characters"}}}function JO($,Z,O,j=1/0){if(!Number.isInteger(Z)||Z<O||Z>j){let T=j===1/0?`an integer of at least ${O}`:`an integer from ${O} to ${j}`;throw Error(`auth.emailCode.${$} must be ${T}, got ${Z}`)}}function Tj($={}){let Z=$.length??6,O=$.expiresInMinutes??10,j=$.linkExpiresInMinutes??10080,T=$.maxAttempts??5;return JO("length",Z,4,12),JO("expiresInMinutes",O,1),JO("linkExpiresInMinutes",j,1),JO("maxAttempts",T,1),{enabled:$.enabled??!1,createUser:$.createUser??!1,length:Z,expiresInMinutes:O,linkExpiresInMinutes:j,maxAttempts:T,requestLimit:{perEmail:$.requestLimit?.perEmail??[5,900],perIp:$.requestLimit?.perIp??[20,900]},verifyLimit:{perEmail:$.verifyLimit?.perEmail??[10,900],perIp:$.verifyLimit?.perIp??[50,900]},uniformMagicLinkResponse:$.uniformMagicLinkResponse??!1,send:$.send??(({email:z,code:J})=>{if(Bun.env.NODE_ENV!=="production")console.info(`[gemi] email code for ${z}: ${J} (set auth.emailCode.send to deliver it)`)})}}async function VW($,Z){if(typeof Z!=="string"||Z==="")return!1;try{return await Bun.password.verify($,Z)}catch{return!1}}function UU($){return $}function K8($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:Oj,oauthProviders:{},verifyPassword:VW,hashPassword:async(Z)=>await Bun.password.hash(Z),generateForgotPasswordToken:async()=>jj(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return jj(32).toString("hex")},generateMagicLinkToken:()=>jj(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{},emailCode:Tj($.emailCode),generateCode:()=>{return},onAuthenticated:()=>{}}}function zj($){if($&&typeof $==="object")delete $.password;return $}function IW(){return new Proxy({},{get:($,Z)=>C8(Z)})}var Q8=new WeakMap;function f8($){if($&&typeof $==="object"){for(let Z of Object.values($))f8(Z);Object.freeze($)}return $}var LW={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}},MW=f8({token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:LW});class Jj{models;constructor($=IW()){this.models=$}run($){return this.models.User.asSystem($)}sessionSelect(){return MW}transaction($){return this.models.User.transaction($)}withLegacySessionLock($,Z){let O=this.models.User.$connection??FZ(),j=C(UZ).connection(O),T=()=>this.transaction(async()=>{if(j.dialect==="postgres"){let W=`gemi:legacy-session:${$}`;await DZ()`SELECT pg_advisory_xact_lock(hashtextextended(${W}, 0))`}return Z()});if(j.dialect!=="sqlite"||DZ())return T();let J=(Q8.get(j)??Promise.resolve()).then(T,T);return Q8.set(j,J.catch(()=>{})),J}async createUser($){let Z=await this.run(()=>this.models.User.create({data:$}));return zj(Z)}async updateUserPassword($){let Z=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return zj(Z)}async findUserByEmailAddress($,Z){return await this.run(()=>this.models.User.findUnique({where:Z?{email:$,emailVerifiedAt:{not:null}}:{email:$}}))}async findUserByVerificationToken($){if(typeof $!=="string"||$==="")return null;return await this.run(()=>this.models.User.findFirst({where:{verificationToken:$}}))}async verifyUser($){return await this.run(()=>this.models.User.update({where:{email:$},data:{emailVerifiedAt:new Date}}))}async createSession($){return await this.run(()=>this.models.Session.create({data:$,include:{user:!0}}))}async createSessionV2($){return await this.run(()=>this.models.Session.create({data:$,select:this.sessionSelect()}))}async findSession($){if(!$.token)return null;try{return await this.run(()=>this.models.Session.findUnique({where:{token:$.token},select:this.sessionSelect()}))}catch(Z){return console.error("findSession failed:",Z),null}}async updateSession($){return await this.run(()=>this.models.Session.update({where:{token:$.token},data:{expiresAt:$.expiresAt},select:this.sessionSelect()}))}async deleteSession($){if(!$.token)return;await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}))}async claimLegacySession($){if(!$.token)return!1;let{count:Z}=await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}));return Z>0}async deleteAllUserSessions($){await this.run(()=>this.models.Session.deleteMany({where:{userId:$}}))}async createPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.create({data:{token:$.token,user:{connect:{id:$.user.id}}}}))}async findPasswordResetToken($){if(typeof $.token!=="string"||$.token==="")return null;return await this.run(()=>this.models.PasswordResetToken.findUnique({where:{token:$.token},include:{user:!0}}))}async deletePasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.delete({where:{token:$.token}}))}async findInvitation($,Z){if(typeof $!=="string"||typeof Z!=="string")return null;return await this.run(()=>this.models.OrganizationInvitation.findFirst({where:{publicId:$,email:Z}}))}async deleteInvitationById($){await this.run(()=>this.models.OrganizationInvitation.delete({where:{publicId:$}}))}async createAccount($){return await this.run(()=>this.models.Account.create({data:{userId:$.userId,organizationId:$.organizationId,organizationRole:$.organizationRole}}))}async createMagicLinkToken($){return await this.run(()=>this.models.MagicLinkToken.create({data:{email:$.email,token:$.token,pin:$.pin}}))}async findUserMagicLinkToken($){let Z=(O)=>typeof O==="string"&&O!=="";if(!Z($.email))return null;if($.token!==void 0&&!Z($.token))return null;if($.token===void 0&&!Z($.pin))return null;return await this.run(()=>$.token?this.models.MagicLinkToken.findUnique({where:{token_email:{token:$.token,email:$.email}}}):this.models.MagicLinkToken.findUnique({where:{pin_email:{pin:$.pin,email:$.email}}}))}async findMagicLinkTokenByEmail($){return await this.run(()=>this.models.MagicLinkToken.findFirst({where:{email:$},orderBy:{id:"desc"}}))}async claimMagicLinkToken($){let{count:Z}=await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{id:$}}));return Z===1}async deleteMagicLinkToken($){await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{email:$}}))}async createSocialAccount($){return await this.run(()=>this.models.SocialAccount.create({data:$}))}async findUserBySocialAccount($,Z){if(!Z)return null;let O=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:Z},include:{user:!0}}));return O?zj(O.user):null}async findSocialAccounts($,Z){return await this.run(()=>this.models.SocialAccount.findMany({where:{userId:$,provider:Z},orderBy:{id:"asc"}}))}async claimSocialAccount($,Z){let{count:O}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:Z}}));return O===1}}import{randomBytes as zX}from"crypto";function _0($,Z,O,j,T){return g0(Z,R8($,Z),O,j,T)}function g0($,Z,O,j,T,z){let J=Fj(Z,O,j);if(T&&Z!==J)throw RangeError(C2($,Z,O,j,z));return J}function R8($,Z){let O=$[Z];if(O===void 0)throw TypeError(pT(Z));return O}function W0($){return $!==null&&/object|function/.test(typeof $)}function E0($,Z=Map){let O=new Z;return(j,...T)=>{if(O.has(j))return O.get(j);let z=$(j,...T);return O.set(j,z),z}}function Vj($){return s1({name:$},1)}function s1($,Z){return h0((O)=>({value:O,configurable:1,writable:!Z}),$)}function q8($){return h0((Z)=>({get:Z,configurable:1}),$)}function MO($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function P$($,Z){let O={},j=$.length;for(let T of Z)O[$[--j]]=T;return O}function h0($,Z,O){let j={};for(let T in Z)j[T]=$(Z[T],T,O);return j}function LZ($,Z,O){let j={};for(let T=0;T<Z.length;T++){let z=Z[T];j[z]=$(z,T,O)}return j}function SW($,Z,O){let j={};for(let T=0;T<$.length;T++)j[Z[T]]=O[$[T]];return j}function H0($,Z){let O={};for(let j of $)O[j]=Z[j];return O}function Ij($,Z){let O={};for(let j in Z)$.has(j)||(O[j]=Z[j]);return O}function Lj($){$={...$};let Z=Object.keys($);for(let O of Z)$[O]===void 0&&delete $[O];return $}function k8($,Z){for(let O of Z)if(!(O in $))return 0;return 1}function g8($,Z,O){for(let j of $)if(Z[j]!==O[j])return 0;return 1}function y8($,Z,O){let j={...O};for(let T=0;T<Z;T++)j[$[T]]=0;return j}function v($,...Z){return(...O)=>$(...Z,...O)}function V8($){return $[0].toUpperCase()+$.substring(1)}function MZ($){return $.slice().sort()}function GO($,Z){return String(Z).padStart($,"0")}function L1($,Z){return Math.sign($-Z)}function Fj($,Z,O){return Math.min(Math.max($,Z),O)}function X1($,Z){return[Math.floor($/Z),BZ($,Z)]}function BZ($,Z){return($%Z+Z)%Z}function N1($,Z){return[SO($,Z),Mj($,Z)]}function SO($,Z){return Math.trunc($/Z)||0}function Mj($,Z){return $%Z||0}function WO($){return Math.abs($%1)===0.5}function m8($,Z,O){let j=0,T=0;for(let W=0;W<=Z;W++){let Y=$[O[W]],X=t0[W],D=m/X,[U,F]=N1(Y,D);j+=F*X,T+=U}let[z,J]=N1(j,m);return[T+z,J]}function NO($,Z,O){let j={};for(let T=Z;T>=0;T--){let z=t0[T];j[O[T]]=SO($,z),$=Mj($,z)}return j}function p8($){return $===w?T3:[]}function h8($){return $===w?vZ:[]}function c8($){return $===w?["year","day"]:[]}function l8($){if($!==void 0)return s($)}function d8($){if($!==void 0)return c0($)}function Sj($){if($!==void 0)return SZ($)}function c0($){return s8(SZ($))}function SZ($){return u8(BY($))}function Nj($){if($==null)throw TypeError("Cannot be null or undefined");return $}function i8($,Z){if(Z==null)throw RangeError(pT($));return Z}function F1($){if(!W0($))throw TypeError(Q2);return $}function _O($,Z,O=$){if(typeof Z!==$)throw TypeError(AZ(O,Z));return Z}function u8($,Z="number"){if(!Number.isInteger($))throw RangeError(mW(Z,$));return $||0}function s8($,Z="number"){if($<=0)throw RangeError(pW(Z,$));return $}function _j($){if(typeof $=="symbol")throw TypeError(dW);return String($)}function BO($,Z){return W0($)?String($):s($,Z)}function xO($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(lW($));return $}function n8($,Z="number"){if(typeof $=="bigint")throw TypeError(cW(Z));if($=Number($),!Number.isFinite($))throw RangeError(hW(Z,$));return $}function Q0($,Z){return Math.trunc(n8($,Z))||0}function a8($,Z){return u8(n8($,Z),Z)}function I8($,Z){return s8(Q0($,Z),Z)}function xj($,Z){let[O,j]=N1(Z,m),T=$+O,z=Math.sign(T);return z&&z===-Math.sign(j)&&(T-=z,j+=z*m),[T,j]}function M$($,Z,O=1){return xj($[0]+Z[0]*O,$[1]+Z[1]*O)}function S$($,Z){return xj($[0],$[1]+Z)}function R0($,Z){return M$(Z,$,-1)}function f0($,Z){return L1($[0],Z[0])||L1($[1],Z[1])}function o8($,Z,O){return f0($,Z)===-1||f0($,O)===1}function PO($,Z=1){let O=BigInt(m/Z);return[Number($/O),Number($%O)*Z]}function N$($,Z=1){let O=m/Z,[j,T]=N1($,O);return[j,T*Z]}function r8($,Z=1){let[O,j]=$,T=Math.floor(j/Z),z=m/Z;return BigInt(O)*BigInt(z)+BigInt(T)}function q0($,Z=1,O){let[j,T]=$,[z,J]=N1(T,Z);return j*(m/Z)+(z+(O?J/Z:0))}function Pj($,Z,O=X1){let[j,T]=$,[z,J]=O(T,Z);return[j*(m/Z)+z,J]}function Ej($,Z){let O=$.formatToParts(Z),j={};for(let T of O)j[T.type]=T.value;return j}function Aj($){return _0($,"isoYear",IZ,VZ,1),$.isoYear===IZ?_0($,"isoMonth",4,12,1):$.isoYear===VZ&&_0($,"isoMonth",1,9,1),$}function M1($){return U1({...$,...p0,isoHour:12}),$}function U1($){let Z=_0($,"isoYear",IZ,VZ,1),O=Z===IZ?1:Z===VZ?-1:0;return O&&k0(C0({...$,isoDay:$.isoDay+O,isoNanosecond:$.isoNanosecond-O})),$}function k0($){if(!$||o8($,LY,IY))throw RangeError($3);return $}function _1($){return m8($,5,u0)[1]}function EO($){let[Z,O]=X1($,m);return[NO(O,5,u0),Z]}function t8($){return e8($)[0]}function e8($){return Pj($,m0)}function V0($){return E$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function C0($){let Z=V0($);if(Z!==void 0){let[O,j]=N1(Z,P0);return[O,j*e0+($.isoMicrosecond||0)*O$+($.isoNanosecond||0)]}}function Hj($,Z){let[O,j]=EO(_1($)-Z);return k0(C0({...$,isoDay:$.isoDay+j,...O}))}function KO(...$){return E$(...$)/E2}function E$(...$){let[Z,O]=$5(...$),j=Z.valueOf();if(!isNaN(j))return j-O*P0}function $5($,Z=1,O=1,j=0,T=0,z=0,J=0){let W=$===IZ?1:$===VZ?-1:0,Y=new Date;return Y.setUTCHours(j,T,z,J),Y.setUTCFullYear($,Z-1,O+W),[Y,W]}function P1($,Z){let[O,j]=S$($,Z);j<0&&(j+=m,O-=1);let[T,z]=X1(j,e0),[J,W]=X1(z,O$);return AO(O*P0+T,J,W)}function AO($,Z=0,O=0){let j=Math.ceil(Math.max(0,Math.abs($)-VY)/P0)*Math.sign($),T=new Date($-j*P0);return P$(J3,[T.getUTCFullYear(),T.getUTCMonth()+1,T.getUTCDate()+j,T.getUTCHours(),T.getUTCMinutes(),T.getUTCSeconds(),T.getUTCMilliseconds(),Z,O])}function Z5($){return[$.isoYear,$.isoMonth,$.isoDay]}function O5(){return Y1}function bj($,Z){switch(Z){case 2:return vj($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function j5($){return vj($)?366:365}function vj($){return $%4==0&&($%100!=0||$%400==0)}function T5($){let[Z,O]=$5($.isoYear,$.isoMonth,$.isoDay);return BZ(Z.getUTCDay()-O,7)||7}function z5({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function NW($){let Z=V0($);if(Z<SY)return z5($);let O=Ej(T6(_$),Z),{era:j,eraYear:T}=Qz(O,_$);return[j,T]}function HO($){return n1($),bO($,1),$}function n1($){return J5($,1),$}function L8($){return g8(oT,$,J5($))}function J5($,Z){let{isoYear:O}=$,j=_0($,"isoMonth",1,O5(),Z);return{isoYear:O,isoMonth:j,isoDay:_0($,"isoDay",1,bj(O,j),Z)}}function bO($,Z){return P$(u0,[_0($,"isoHour",0,23,Z),_0($,"isoMinute",0,59,Z),_0($,"isoSecond",0,59,Z),_0($,"isoMillisecond",0,999,Z),_0($,"isoMicrosecond",0,999,Z),_0($,"isoNanosecond",0,999,Z)])}function q($){return $===void 0?0:i2(F1($))}function NZ($,Z=0){$=l0($);let O=u2($),j=wY($,Z);return[i2($),j,O]}function wj($){return u2(l0($))}function W5($){return $=l0($),eT($,9,6,1)}function A$($,Z,O,j=9,T=0,z=4){Z=l0(Z);let J=eT(Z,j,T),W=kj(Z),Y=RZ(Z,z),X=wZ(Z,j,T,1);return J==null?J=Math.max(O,X):F5(J,X),W=gj(W,X,1),$&&(Y=((D)=>D<4?(D+2)%4:D)(Y)),[J,X,W,Y]}function vO($,Z=6,O){let j=kj($=yj($,LO)),T=RZ($,7),z=wZ($,Z);return z=i8(LO,z),j=gj(j,z,void 0,O),[z,j,T]}function Rj($){return $6(l0($))}function Y5($,Z){return qj(l0($),Z)}function qj($,Z=4){let O=D5($);return[RZ($,4),...X5(wZ($,Z),O)]}function X5($,Z){return $!=null?[t0[$],$<4?9-3*$:-1]:[Z===void 0?1:10**(9-Z),Z]}function kj($){let Z=$[KZ];return Z===void 0?1:Q0(Z,KZ)}function gj($,Z,O,j){let T=j?m:t0[Z+1];if(T){let z=t0[Z];if(T%(($=g0(KZ,$,1,T/z-(j?0:1),1))*z))throw RangeError(AZ(KZ,$))}else $=g0(KZ,$,1,O?1e9:1,1);return $}function D5($){let Z=$[Dj];if(Z!==void 0){if(typeof Z!="number"){if(_j(Z)==="auto")return;throw RangeError(AZ(Dj,Z))}Z=g0(Dj,Math.floor(Z),0,9,1)}return Z}function l0($){return $===void 0?{}:F1($)}function yj($,Z){return typeof $=="string"?{[Z]:$}:F1($)}function t($){if($!==void 0){if(W0($))return Object.assign(Object.create(null),$);throw TypeError(Q2)}}function wO($,Z){return $&&Object.assign(Object.create(null),$,{overflow:_Y[Z]})}function mj($,Z,O=9,j=0,T){let z=Z[$];if(z===void 0)return T?j:void 0;if(z=_j(z),z==="auto")return T?j:null;let J=Kj[z];if(J===void 0&&(J=CY[z]),J===void 0)throw RangeError(I2($,z,Kj));return g0($,J,j,O,1,bZ),J}function a1($,Z,O,j=0){let T=O[$];if(T===void 0)return j;let z=_j(T),J=Z[z];if(J===void 0)throw RangeError(I2($,z,Z));return J}function F5($,Z){if(Z>$)throw RangeError(XY)}function Y0($){return{branding:Y3,epochNanoseconds:$}}function F0($,Z,O){return{branding:Q1,calendar:O,timeZone:Z,epochNanoseconds:$}}function e($,Z=$.calendar){return{branding:T$,calendar:Z,...H0(h2,$)}}function $0($,Z=$.calendar){return{branding:j$,calendar:Z,...H0(rT,$)}}function i1($,Z=$.calendar){return{branding:g$,calendar:Z,...H0(rT,$)}}function QO($,Z=$.calendar){return{branding:y$,calendar:Z,...H0(rT,$)}}function d0($){return{branding:W3,...H0(p2,$)}}function l($){return{branding:X3,sign:E1($),...H0(sT,$)}}function U5($){return t8($.epochNanoseconds)}function RO($){return Pj($.epochNanoseconds,e0)[0]}function G5($){return r8($.epochNanoseconds,O$)}function B5($){return r8($.epochNanoseconds)}function K5($){return $.epochNanoseconds}function X0($){return typeof $=="string"?$:s($.id)}function H$($,Z){return $===Z||X0($)===X0(Z)}function Q5($,Z,O,j,T){let z=u1(j),[J,W]=((Q,f)=>{let L=f((Q=yj(Q,fj))[l2]),V=vY(Q);return V=i8(fj,V),[V,L]})(T,$);if(CZ(Math.max(J,z),W))return M8(j,J);if(!W)throw RangeError(Z3);let[Y,X,D]=pO(Z,O,W),U=XT(D),F=hO(D),B=DT(D),G=F(X,Y,j),K=B(X,Y,G,J);return CZ(J,W)?M8(K,J):((Q,f,L,V,x,P,I)=>{let M=E1(Q),[E,H]=pj(V,aT(L,Q),L,M,x,P,I),j0=hj(f,E,H);return Q[k[L]]+j0*M})(K,U(G),J,X,Y,U,F)}function M8($,Z){return q0(J0($),t0[Z],1)}function pj($,Z,O,j,T,z,J){let W=k[O],Y={...Z,[W]:Z[W]+j},X=J($,T,Z),D=J($,T,Y);return[z(X),z(D)]}function hj($,Z,O){let j=q0(R0(Z,O));if(!j)throw RangeError(HZ);return q0(R0(Z,$))/j}function C5($,Z){let[O,j,T]=vO(Z,5,1);return Y0(kO($.epochNanoseconds,O,j,T,1))}function f5($,Z,O){let{epochNanoseconds:j,timeZone:T,calendar:z}=Z,[J,W,Y]=vO(O);if(J===0&&W===1)return Z;let X=$(T);if(J===6)j=((D,U,F,B)=>{let G=I0(F,U),[K,Q]=D(G),f=F.epochNanoseconds,L=A0(U,K),V=A0(U,Q);if(o8(f,L,V))throw RangeError(HZ);return P5(hj(f,L,V),B)?V:L})(_5,X,Z,Y);else{let D=X.getOffsetNanosecondsFor(j);j=r1(X,S5(P1(j,D),J,W,Y),D,2,0,1)}return F0(j,T,z)}function V5($,Z){return e(S5($,...vO(Z)),$.calendar)}function I5($,Z){let[O,j,T]=vO(Z,5);var z;return d0((z=T,cj($,_Z(O,j),z)[0]))}function L5($,Z){let O=$(Z.timeZone),j=I0(Z,O),[T,z]=_5(j),J=q0(R0(A0(O,T),A0(O,z)),j3,1);if(J<=0)throw RangeError(HZ);return J}function M5($,Z){let{timeZone:O,calendar:j}=Z,T=((z,J,W)=>A0(J,z(I0(W,J))))(x5,$(O),Z);return F0(T,O,j)}function S5($,Z,O,j){return N5($,_Z(Z,O),j)}function N5($,Z,O){let[j,T]=cj($,Z,O);return U1({...t1($,T),...j})}function cj($,Z,O){return EO(x1(_1($),Z,O))}function CO($){return x1($,O3,7)}function _Z($,Z){return t0[$]*Z}function _5($){let Z=x5($);return[Z,t1(Z,1)]}function x5($){return fY(6,$)}function _W($,Z,O){let j=Math.min(u1($),6);return v$(gO(J0($,j),Z,O),j)}function qO($,Z,O,j,T,z,J,W,Y,X){if(j===0&&T===1)return $;let D=CZ(j,W)?cO(W)&&j<6&&O>=6?PW:xW:EW,[U,F,B]=D($,Z,O,j,T,z,J,W,Y,X);return B&&j!==7&&(U=((G,K,Q,f,L,V,x,P)=>{let I=E1(G);for(let M=f+1;M<=Q;M++){if(M===7&&Q!==7)continue;let E=aT(M,G);E[k[M]]+=I;let H=q0(R0(x(P(L,V,E)),K));if(H&&Math.sign(H)!==I)break;G=E}return G})(U,F,O,Math.max(6,j),J,W,Y,X)),U}function kO($,Z,O,j,T){if(Z===6){let z=((J)=>J[0]+J[1]/m)($);return[x1(z,O,j),0]}return gO($,_Z(Z,O),j,T)}function gO($,Z,O,j){let[T,z]=$;j&&z<0&&(z+=m,T-=1);let[J,W]=X1(x1(z,Z,O),m);return xj(T+J,W)}function x1($,Z,O){return P5($/Z,O)*Z}function P5($,Z){return kY[Z]($)}function xW($,Z,O,j,T,z){let J=E1($),W=J0($),Y=kO(W,j,T,z),X=R0(W,Y),D=Math.sign(Y[0]-W[0])===J,U=v$(Y,Math.min(O,6));return[{...$,...U},M$(Z,X),D]}function PW($,Z,O,j,T,z,J,W,Y,X){let D=E1($),U=q0(J0($,5)),F=_Z(j,T),B=x1(U,F,z),[G,K]=pj(J,{...$,...nT},6,D,W,Y,X),Q=B-q0(R0(G,K)),f=0;Q&&Math.sign(Q)!==D?Z=S$(G,B):(f+=D,B=x1(Q,F,z),Z=S$(K,B));let L=dO(B);return[{...$,...L,days:$.days+f},Z,Boolean(f)]}function EW($,Z,O,j,T,z,J,W,Y,X){let D=E1($),U=k[j],F=aT(j,$);j===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let B=SO($[U],T)*T;F[U]=B;let[G,K]=pj(J,F,j,T*D,W,Y,X),Q=B+hj(Z,G,K)*D*T,f=x1(Q,T,z),L=Math.sign(f-Q)===D;return F[U]=f,[F,L?K:G,L]}function lj($,Z,O,j){let[T,z,J,W]=((X)=>{let D=qj(X=l0(X));return[X.timeZone,...D]})(j),Y=T!==void 0;return((X,D,U,F,B,G)=>{U=gO(U,B,F,1);let K=D.getOffsetNanosecondsFor(U);return oj(P1(U,K),G)+(X?o1(CO(K)):"Z")})(Y,Z(Y?$(T):z$),O.epochNanoseconds,z,J,W)}function dj($,Z,O){let[j,T,z,J,W,Y]=((X)=>{X=l0(X);let D=$6(X),U=D5(X),F=qY(X),B=RZ(X,4),G=wZ(X,4);return[D,RY(X),F,B,...X5(G,U)]})(O);return((X,D,U,F,B,G,K,Q,f,L)=>{F=gO(F,f,Q,1);let V=X(U).getOffsetNanosecondsFor(F);return oj(P1(F,V),L)+o1(CO(V),K)+((x,P)=>P!==1?"["+(P===2?"!":"")+X0(x)+"]":"")(U,G)+rj(D,B)})($,Z.calendar,Z.timeZone,Z.epochNanoseconds,j,T,z,J,W,Y)}function ij($,Z){let[O,j,T,z]=((X)=>(X=l0(X),[$6(X),...qj(X)]))(Z);return J=$.calendar,W=O,Y=z,oj(N5($,T,j),Y)+rj(J,W);var J,W,Y}function uj($,Z){return O=$.calendar,j=$,T=Rj(Z),fO(j)+rj(O,T);var O,j,T}function sj($,Z){return E5($.calendar,A5,$,Rj(Z))}function nj($,Z){return E5($.calendar,AW,$,Rj(Z))}function aj($,Z){let[O,j,T]=Y5(Z);return z=T,H5(cj($,j,O)[0],z);var z}function yO($,Z){let[O,j,T]=Y5(Z,3);return j>1&&($={...$,..._W($,j,O)}),((z,J)=>{let{sign:W}=z,Y=W===-1?L0(z):z,{hours:X,minutes:D}=Y,[U,F]=Pj(J0(Y,3),m0,N1);y5(U);let B=tj(F,J),G=J>=0||!W||B;return(W<0?"-":"")+"P"+S8({Y:d1(Y.years),M:d1(Y.months),W:d1(Y.weeks),D:d1(Y.days)})+(X||D||U||G?"T"+S8({H:d1(X),M:d1(D),S:d1(U,G)+B}):"")})($,T)}function E5($,Z,O,j){let T=X0($),z=j>1||j===0&&T!==w;return j===1?T===w?Z(O):fO(O):z?fO(O)+b5(T,j===2):Z(O)}function S8($){let Z=[];for(let O in $){let j=$[O];j&&Z.push(j,O)}return Z.join("")}function oj($,Z){return fO($)+"T"+H5($,Z)}function fO($){return A5($)+"-"+y0($.isoDay)}function A5($){let{isoYear:Z}=$;return(Z<0||Z>9999?v5(Z)+GO(6,Math.abs(Z)):GO(4,Z))+"-"+y0($.isoMonth)}function AW($){return y0($.isoMonth)+"-"+y0($.isoDay)}function H5($,Z){let O=[y0($.isoHour),y0($.isoMinute)];return Z!==-1&&O.push(y0($.isoSecond)+((j,T,z,J)=>tj(j*e0+T*O$+z,J))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,Z)),O.join(":")}function o1($,Z=0){if(Z===1)return"";let[O,j]=X1(Math.abs($),j3),[T,z]=X1(j,O3),[J,W]=X1(z,m0);return v5($)+y0(O)+":"+y0(T)+(J||W?":"+y0(J)+tj(W):"")}function rj($,Z){if(Z!==1){let O=X0($);if(Z>1||Z===0&&O!==w)return b5(O,Z===2)}return""}function b5($,Z){return"["+(Z?"!":"")+"u-ca="+$+"]"}function tj($,Z){let O=GO(9,$);return O=Z===void 0?O.replace(mY,""):O.slice(0,Z),O?"."+O:""}function v5($){return $<0?"-":"+"}function d1($,Z){return $||Z?$.toLocaleString("fullwide",{useGrouping:0}):""}function HW($,Z){let{epochNanoseconds:O}=$,j=(Z.getOffsetNanosecondsFor?Z:Z($.timeZone)).getOffsetNanosecondsFor(O),T=P1(O,j);return{calendar:$.calendar,...T,offsetNanoseconds:j}}function w5($,Z){let O=I0(Z,$);return{calendar:Z.calendar,...H0(h2,O),offset:o1(O.offsetNanoseconds),timeZone:Z.timeZone}}function r1($,Z,O,j=0,T=0,z,J){if(O!==void 0&&j===1&&(j===1||J))return Hj(Z,O);let W=$.getPossibleInstantsFor(Z);if(O!==void 0&&j!==3){let Y=((X,D,U,F)=>{let B=C0(D);F&&(U=CO(U));for(let G of X){let K=q0(R0(G,B));if(F&&(K=CO(K)),K===U)return G}})(W,Z,O,z);if(Y!==void 0)return Y;if(j===0)throw RangeError(jY)}return J?C0(Z):A0($,Z,T,W)}function A0($,Z,O=0,j=$.getPossibleInstantsFor(Z)){if(j.length===1)return j[0];if(O===1)throw RangeError(TY);if(j.length)return j[O===3?1:0];let T=C0(Z),z=((W,Y)=>{let X=W.getOffsetNanosecondsFor(S$(Y,-m));return $T(W.getOffsetNanosecondsFor(S$(Y,m))-X)})($,T),J=z*(O===2?-1:1);return(j=$.getPossibleInstantsFor(P1(T,J)))[O===2?0:j.length-1]}function ej($){if(Math.abs($)>=m)throw RangeError(ZY);return $}function $T($){if($>m)throw RangeError(OY);return $}function ZT($,Z,O){return Y0(k0(M$(Z.epochNanoseconds,((j)=>{if(m5(j))throw RangeError(WY);return J0(j,5)})($?L0(O):O))))}function OT($,Z,O,j,T,z=Object.create(null)){let J=Z(j.timeZone),W=$(j.calendar);return{...j,...WT(J,W,j,O?L0(T):T,z)}}function jT($,Z,O,j,T=Object.create(null)){let{calendar:z}=O;return e(YT($(z),O,Z?L0(j):j,T),z)}function TT($,Z,O,j,T){let{calendar:z}=O;return $0(mO($(z),O,Z?L0(j):j,T),z)}function zT($,Z,O,j,T=Object.create(null)){let z=O.calendar,J=$(z),W=QZ(J,O);Z&&(j=lO(j)),j.sign<0&&(W=J.dateAdd(W,{...D0,months:1}),W=t1(W,-1));let Y=J.dateAdd(W,j,T);return i1(QZ(J,Y),z)}function JT($,Z,O){return d0(R5(Z,$?L0(O):O)[0])}function WT($,Z,O,j,T){let z=J0(j,5),J=O.epochNanoseconds;if(m5(j)){let W=I0(O,$);J=M$(A0($,{...mO(Z,W,{...j,...nT},T),...H0(u0,W)}),z)}else J=M$(J,z),q(T);return{epochNanoseconds:k0(J)}}function YT($,Z,O,j){let[T,z]=R5(Z,O);return U1({...mO($,Z,{...O,...nT,days:O.days+z},j),...T})}function mO($,Z,O,j){if(O.years||O.months||O.weeks)return $.dateAdd(Z,O,j);q(j);let T=O.days+J0(O,5)[0];return T?M1(t1(Z,T)):Z}function QZ($,Z,O=1){return t1(Z,O-$.day(Z))}function R5($,Z){let[O,j]=J0(Z,5),[T,z]=EO(_1($)+j);return[T,O+z]}function t1($,Z){return Z?{...$,...AO(V0($)+Z*P0)}:$}function pO($,Z,O){let j=$(O.calendar);return cO(O)?[O,j,Z(O.timeZone)]:[{...O,...p0},j]}function XT($){return $?K5:C0}function hO($){return $?v(WT,$):YT}function DT($){return $?v(vW,$):wW}function cO($){return $&&$.epochNanoseconds}function CZ($,Z){return $<=6-(cO(Z)?1:0)}function FT($,Z,O,j,T,z,J){let W=$(l0(J).relativeTo),Y=Math.max(u1(T),u1(z));if(CZ(Y,W))return l(b$(((K,Q,f,L)=>{let V=M$(J0(K),J0(Q),L?-1:1);if(!Number.isFinite(V[0]))throw RangeError($3);return{...D0,...v$(V,f)}})(T,z,Y,j)));if(!W)throw RangeError(Z3);j&&(z=L0(z));let[X,D,U]=pO(Z,O,W),F=hO(U),B=DT(U),G=F(D,X,T);return l(B(D,X,F(D,G,z),Y))}function q5($,Z,O,j,T){let z=u1(j),[J,W,Y,X,D]=((I,M,E)=>{I=yj(I,LO);let H=eT(I),j0=E(I[l2]),R=kj(I),g=RZ(I,7),i=wZ(I);if(H===void 0&&i===void 0)throw RangeError(YY);return i==null&&(i=0),H==null&&(H=Math.max(i,M)),F5(H,i),R=gj(R,i,1),[H,i,R,g,j0]})(T,z,$),U=Math.max(z,J);if(!cO(D)&&U<=6)return l(b$(((I,M,E,H,j0)=>{let R=kO(J0(I),E,H,j0);return{...D0,...v$(R,M)}})(j,J,W,Y,X)));if(!D)throw RangeError(Z3);let[F,B,G]=pO(Z,O,D),K=XT(G),Q=hO(G),f=DT(G),L=Q(B,F,j),V=f(B,F,L,J),x=j.sign,P=E1(V);if(x&&P&&x!==P)throw RangeError(HZ);return P&&(V=qO(V,K(L),J,W,Y,X,B,F,K,Q)),l(V)}function k5($){return $.sign===-1?lO($):$}function lO($){return l(L0($))}function L0($){let Z={};for(let O of k)Z[O]=-1*$[O]||0;return Z}function g5($){return!$.sign}function E1($,Z=k){let O=0;for(let j of Z){let T=Math.sign($[j]);if(T){if(O&&O!==T)throw RangeError(JY);O=T}}return O}function b$($){for(let Z of QY)g0(Z,$[Z],-H8,H8,1);return y5(q0(J0($),m0)),$}function y5($){if(!Number.isSafeInteger($))throw RangeError(zY)}function J0($,Z=6){return m8($,Z,k)}function v$($,Z=6){let[O,j]=$,T=NO(j,Z,k);if(T[k[Z]]+=O*(m/t0[Z]),!Number.isFinite(T[k[Z]]))throw RangeError($3);return T}function dO($,Z=5){return NO($,Z,k)}function m5($){return Boolean(E1($,m2))}function u1($){let Z=9;for(;Z>0&&!$[k[Z]];Z--);return Z}function bW($,Z){return[$,Z]}function N8($){let Z=Math.floor($/FO)*FO;return[Z,Z+FO]}function p5($){let Z=A1($=BO($));if(!Z)throw RangeError(x0($));let O;if(Z.m)O=0;else{if(!Z.offset)throw RangeError(x0($));O=w$(Z.offset)}return Z.timeZone&&KT(Z.timeZone,1),Y0(Hj(HO(Z),O))}function h5($){let Z=A1(s($));if(!Z)throw RangeError(x0($));if(Z.timeZone)return o5(Z,Z.offset?w$(Z.offset):void 0);if(Z.m)throw RangeError(x0($));return t5(Z)}function c5($,Z){let O=A1(s($));if(!O||!O.timeZone)throw RangeError(x0($));let{offset:j}=O,T=j?w$(j):void 0,[,z,J]=NZ(Z);return o5(O,T,z,J)}function w$($){let Z=KT($);if(Z===void 0)throw RangeError(x0($));return Z}function l5($){let Z=A1(s($));if(!Z||Z.m)throw RangeError(x0($));return e(r5(Z))}function iO($){let Z=A1(s($));if(!Z||Z.m)throw RangeError(x0($));return $0(Z.p?r5(Z):t5(Z))}function d5($,Z){let O=GT(s(Z));if(O)return UT(O),i1(Aj(n1(O)));let j=iO(Z);return i1(QZ($(j.calendar),j))}function UT($){if($.calendar!==w)throw RangeError(D1($.calendar))}function i5($,Z){let O=BT(s(Z));if(O)return UT(O),QO(n1(O));let j=iO(Z),{calendar:T}=j,z=$(T),[J,W,Y]=z.h(j),[X,D]=z.I(J,W),[U,F]=z.N(X,D,Y);return QO(M1(z.P(U,F,Y)),T)}function u5($){let Z,O=((j)=>{let T=dY.exec(j);return T?(uO(T[10]),Zz(T)):void 0})(s($));if(!O){if(O=A1($),!O)throw RangeError(x0($));if(!O.p)throw RangeError(x0($));if(O.m)throw RangeError(D1("Z"));UT(O)}if((Z=GT($))&&L8(Z))throw RangeError(x0($));if((Z=BT($))&&L8(Z))throw RangeError(x0($));return d0(bO(O,1))}function s5($){let Z=((O)=>{let j=sY.exec(O);return j?((T)=>{function z(D,U,F){let B=0,G=0;if(F&&([B,Y]=X1(Y,t0[F])),D!==void 0){if(W)throw RangeError(D1(D));G=((K)=>{let Q=parseInt(K);if(!Number.isFinite(Q))throw RangeError(D1(K));return Q})(D),J=1,U&&(Y=QT(U)*(t0[F]/m0),W=1)}return B+G}let J=0,W=0,Y=0,X={...P$(k,[z(T[2]),z(T[3]),z(T[4]),z(T[5]),z(T[6],T[7],5),z(T[8],T[9],4),z(T[10],T[11],3)]),...NO(Y,2,k)};if(!J)throw RangeError(f2(k));return CT(T[1])<0&&(X=L0(X)),X})(j):void 0})(s($));if(!Z)throw RangeError(x0($));return l(b$(Z))}function n5($){let Z=A1($)||GT($)||BT($);return Z?Z.calendar:$}function a5($){let Z=A1($);return Z&&(Z.timeZone||Z.m&&z$||Z.offset)||$}function o5($,Z,O=0,j=0){let T=sO($.timeZone),z=D3(T);return F0(r1(z,HO($),Z,O,j,!z.v,$.m),T,xZ($.calendar))}function r5($){return e5(U1(HO($)))}function t5($){return e5(M1(n1($)))}function e5($){return{...$,calendar:xZ($.calendar)}}function A1($){let Z=lY.exec($);return Z?((O)=>{let j=O[10],T=(j||"").toUpperCase()==="Z";return{isoYear:$z(O),isoMonth:parseInt(O[4]),isoDay:parseInt(O[5]),...Zz(O.slice(5)),...uO(O[16]),p:Boolean(O[6]),m:T,offset:T?void 0:j}})(Z):void 0}function GT($){let Z=hY.exec($);return Z?((O)=>({isoYear:$z(O),isoMonth:parseInt(O[4]),isoDay:1,...uO(O[5])}))(Z):void 0}function BT($){let Z=cY.exec($);return Z?((O)=>({isoYear:x$,isoMonth:parseInt(O[1]),isoDay:parseInt(O[2]),...uO(O[3])}))(Z):void 0}function KT($,Z){let O=iY.exec($);return O?((j,T)=>{let z=j[4]||j[5];if(T&&z)throw RangeError(D1(z));return ej((L$(j[2])*j3+L$(j[3])*O3+L$(j[4])*m0+QT(j[5]||""))*CT(j[1]))})(O,Z):void 0}function $z($){let Z=CT($[1]),O=parseInt($[2]||$[3]);if(Z<0&&!O)throw RangeError(D1(-0));return Z*O}function Zz($){let Z=L$($[3]);return{...EO(QT($[4]||""))[0],isoHour:L$($[1]),isoMinute:L$($[2]),isoSecond:Z===60?59:Z}}function uO($){let Z,O,j=[];if($.replace(uY,(T,z,J)=>{let W=Boolean(z),[Y,X]=J.split("=").reverse();if(X){if(X==="u-ca")j.push(Y),Z||(Z=W);else if(W||/[A-Z]/.test(X))throw RangeError(D1(T))}else{if(O)throw RangeError(D1(T));O=Y}return""}),j.length>1&&Z)throw RangeError(D1($));return{timeZone:O,calendar:j[0]||w}}function QT($){return parseInt($.padEnd(9,"0"))}function R$($){return new RegExp(`^${$}$`,"i")}function CT($){return $&&$!=="+"?-1:1}function L$($){return $===void 0?0:parseInt($)}function Oz($){return sO(s($))}function sO($){let Z=fT($);return typeof Z=="number"?o1(Z):Z?((O)=>{if(aY.test(O))throw RangeError($Y);return O.toLowerCase().split("/").map((j,T)=>(j.length<=3||/\d/.test(j))&&!/etc|yap/.test(j)?j.toUpperCase():j.replace(/baja|dumont|[a-z]+/g,(z,J)=>z.length<=2&&!T||z==="in"||z==="chat"?z.toUpperCase():z.length>2||!J?V8(z).replace(/island|noronha|murdo|rivadavia|urville/,V8):z)).join("/")})($):z$}function _8($){let Z=fT($);return typeof Z=="number"?Z:Z?Z.resolvedOptions().timeZone:z$}function fT($){let Z=KT($=$.toUpperCase(),1);return Z!==void 0?Z:$!==z$?nY($):void 0}function VT($,Z){return f0($.epochNanoseconds,Z.epochNanoseconds)}function IT($,Z){return f0($.epochNanoseconds,Z.epochNanoseconds)}function jz($,Z,O,j,T,z){let J=$(l0(z).relativeTo),W=Math.max(u1(j),u1(T));if(g8(k,j,T))return 0;if(CZ(W,J))return f0(J0(j),J0(T));if(!J)throw RangeError(Z3);let[Y,X,D]=pO(Z,O,J),U=XT(D),F=hO(D);return f0(U(F(X,Y,j)),U(F(X,Y,T)))}function LT($,Z){return e1($,Z)||nO($,Z)}function e1($,Z){return L1(V0($),V0(Z))}function nO($,Z){return L1(_1($),_1(Z))}function Tz($,Z){return!VT($,Z)}function zz($,Z){return!IT($,Z)&&!!aO($.timeZone,Z.timeZone)&&H$($.calendar,Z.calendar)}function Jz($,Z){return!LT($,Z)&&H$($.calendar,Z.calendar)}function Wz($,Z){return!e1($,Z)&&H$($.calendar,Z.calendar)}function Yz($,Z){return!e1($,Z)&&H$($.calendar,Z.calendar)}function Xz($,Z){return!e1($,Z)&&H$($.calendar,Z.calendar)}function Dz($,Z){return!nO($,Z)}function aO($,Z){if($===Z)return 1;let O=X0($),j=X0(Z);if(O===j)return 1;try{return _8(O)===_8(j)}catch(T){}}function MT($,Z,O,j){let T=A$($,t(j),3,5),z=oO(Z.epochNanoseconds,O.epochNanoseconds,...T);return l($?L0(z):z)}function ST($,Z,O,j,T,z){let J=tO(j.calendar,T.calendar),W=t(z),[Y,X,D,U]=A$(O,W,5),F=j.epochNanoseconds,B=T.epochNanoseconds,G=f0(B,F),K;if(G)if(Y<6)K=oO(F,B,Y,X,D,U);else{let Q=Z(((L,V)=>{if(!aO(L,V))throw RangeError(N2);return L})(j.timeZone,T.timeZone)),f=$(J);K=Uz(f,Q,j,T,G,Y,W),K=qO(K,B,Y,X,D,U,f,j,K5,v(WT,Q))}else K=D0;return l(O?L0(K):K)}function NT($,Z,O,j,T){let z=tO(O.calendar,j.calendar),J=t(T),[W,Y,X,D]=A$(Z,J,6),U=C0(O),F=C0(j),B=f0(F,U),G;if(B)if(W<=6)G=oO(U,F,W,Y,X,D);else{let K=$(z);G=Gz(K,O,j,B,W,J),G=qO(G,F,W,Y,X,D,K,O,C0,YT)}else G=D0;return l(Z?L0(G):G)}function _T($,Z,O,j,T){let z=tO(O.calendar,j.calendar),J=t(T);return Fz(Z,()=>$(z),O,j,...A$(Z,J,6,9,6),J)}function xT($,Z,O,j,T){let z=tO(O.calendar,j.calendar),J=t(T),W=A$(Z,J,9,9,8),Y=$(z);return Fz(Z,()=>Y,QZ(Y,O),QZ(Y,j),...W,J)}function Fz($,Z,O,j,T,z,J,W,Y){let X=C0(O),D=C0(j),U;if(f0(D,X))if(T===6)U=oO(X,D,T,z,J,W);else{let F=Z();U=F.dateUntil(O,j,T,Y),z===6&&J===1||(U=qO(U,D,T,z,J,W,F,O,C0,mO))}else U=D0;return l($?L0(U):U)}function PT($,Z,O,j){let T=t(j),[z,J,W,Y]=A$($,T,5,5),X=x1(ET(Z,O),_Z(J,W),Y),D={...D0,...dO(X,z)};return l($?L0(D):D)}function vW($,Z,O,j,T,z){let J=f0(j.epochNanoseconds,O.epochNanoseconds);return J?T<6?Bz(O.epochNanoseconds,j.epochNanoseconds,T):Uz(Z,$,O,j,J,T,z):D0}function wW($,Z,O,j,T){let z=C0(Z),J=C0(O),W=f0(J,z);return W?j<=6?Bz(z,J,j):Gz($,Z,O,W,j,T):D0}function Uz($,Z,O,j,T,z,J){let[W,Y,X]=((F,B,G,K)=>{function Q(){return M={...t1(V,P++*-K),...L},E=A0(F,M),f0(x,E)===-K}let f=I0(B,F),L=H0(u0,f),V=I0(G,F),x=G.epochNanoseconds,P=0,I=ET(f,V),M,E;if(Math.sign(I)===-K&&P++,Q()&&(K===-1||Q()))throw RangeError(HZ);let H=q0(R0(E,x));return[f,M,H]})(Z,O,j,T);var D,U;return{...z===6?(D=W,U=Y,{...D0,days:Kz(D,U)}):$.dateUntil(W,Y,z,J),...dO(X)}}function Gz($,Z,O,j,T,z){let[J,W,Y]=((X,D,U)=>{let F=D,B=ET(X,D);return Math.sign(B)===-U&&(F=t1(D,-U),B+=m*U),[X,F,B]})(Z,O,j);return{...$.dateUntil(J,W,T,z),...dO(Y)}}function oO($,Z,O,j,T,z){return{...D0,...v$(kO(R0($,Z),j,T,z),O)}}function Bz($,Z,O){return{...D0,...v$(R0($,Z),O)}}function Kz($,Z){return rO(V0($),V0(Z))}function rO($,Z){return Math.trunc((Z-$)/P0)}function ET($,Z){return _1(Z)-_1($)}function tO($,Z){if(!H$($,Z))throw RangeError(lT);return $}function RW($){function Z(T){return((z,J)=>({...Qz(z,J),F:z.month,day:parseInt(z.day)}))(Ej(O,T),j)}let O=T6($),j=VO($);return{id:$,O:qW(Z),B:kW(Z)}}function qW($){return E0((Z)=>{let O=V0(Z);return $(O)},WeakMap)}function kW($){let Z=$(0).year-MY;return E0((O)=>{let j,T=E$(O-Z),z=[],J=[];do T+=400*P0;while((j=$(T)).year<=O);do T+=(1-j.day)*P0,j.year===O&&(z.push(T),J.push(j.F)),T-=P0;while((j=$(T)).year>=O);return{k:z.reverse(),C:P2(J.reverse())}})}function Qz($,Z){let O,j,T=Cz($);if($.era){let z=k2[Z];z!==void 0&&(O=Z==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),O==="bc"||O==="b"?O="bce":O!=="ad"&&O!=="a"||(O="ce"),j=T,T=Mz(j,z[O]||0))}return{era:O,eraYear:j,year:T}}function Cz($){return parseInt($.relatedYear||$.year)}function Uj($){let{year:Z,F:O,day:j}=this.O($),{C:T}=this.B(Z);return[Z,T[O]+1,j]}function fZ($,Z=1,O=1){return this.B($).k[Z-1]+(O-1)*P0}function YO($){let Z=P8(this,$),O=P8(this,$-1),j=Z.length;if(j>O.length){let T=Sz(this);if(T<0)return-T;for(let z=0;z<j;z++)if(Z[z]!==O[z])return z+1}}function XO($){return rO(fZ.call(this,$),fZ.call(this,$+1))}function x8($,Z){let{k:O}=this.B($),j=Z+1,T=O;return j>O.length&&(j=1,T=this.B($+1).k),rO(O[Z-1],T[j-1])}function DO($){return this.B($).k.length}function P8($,Z){return Object.keys($.B(Z).C)}function fz($){return xZ(s($))}function xZ($){if(($=$.toLowerCase())!==w&&$!==z3&&VO($)!==VO(T6($).resolvedOptions().calendar))throw RangeError(eW($));return $}function VO($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function Vz($){return this.R($)[0]}function Iz($){return this.R($)[1]}function AT($){let[Z]=this.h($);return rO(this.q(Z),V0($))+1}function Lz($){let Z=rY.exec($);if(!Z)throw RangeError(rW($));return[parseInt(Z[1]),Boolean(Z[2])]}function IO($,Z,O){return $+(Z||O&&$>=O?1:0)}function Gj($,Z){return $-(Z&&$>=Z?1:0)}function Mz($,Z){return(Z+$)*(Math.sign(Z)||1)||0}function Bj($){return k2[Nz($)]}function Sz($){return GY[Nz($)]}function Nz($){return VO($.id||w)}function _z($,Z,O,j){let T=H1(O,j,i0,[],v2);if(T.timeZone!==void 0){let z=O.dateFromFields(T),J=$$(T),W=$(T.timeZone);return{epochNanoseconds:r1(Z(W),{...z,...J},T.offset!==void 0?w$(T.offset):void 0),timeZone:W}}return{...O.dateFromFields(T),...p0}}function xz($,Z,O,j,T,z){let J=H1(O,T,i0,H2,v2),W=$(J.timeZone),[Y,X,D]=NZ(z),U=O.dateFromFields(J,wO(z,Y)),F=$$(J,Y);return F0(r1(Z(W),{...U,...F},J.offset!==void 0?w$(J.offset):void 0,X,D),W,j)}function Pz($,Z,O){let j=H1($,Z,i0,[],K1),T=q(O);return e(U1({...$.dateFromFields(j,wO(O,T)),...$$(j,T)}))}function HT($,Z,O,j=[]){let T=H1($,Z,i0,j);return $.dateFromFields(T,O)}function bT($,Z,O,j){let T=H1($,Z,uT,j);return $.yearMonthFromFields(T,O)}function vT($,Z,O,j,T=[]){let z=H1($,O,i0,T);return Z&&z.month!==void 0&&z.monthCode===void 0&&z.year===void 0&&(z.year=x$),$.monthDayFromFields(z,j)}function Ez($,Z){let O=q(Z);return d0($$(r0($,Qj,[],1),O))}function Az($){let Z=r0($,sT);return l(b$({...D0,...Z}))}function H1($,Z,O,j=[],T=[]){return r0(Z,[...$.fields(O),...T].sort(),j)}function r0($,Z,O,j=!O){let T={},z,J=0;for(let W of Z){if(W===z)throw RangeError(iW(W));if(W==="constructor"||W==="__proto__")throw RangeError(hT(W));let Y=$[W];if(Y!==void 0)J=1,b8[W]&&(Y=b8[W](Y,W)),T[W]=Y;else if(O){if(O.includes(W))throw TypeError(pT(W));T[W]=q2[W]}z=W}if(j&&!J)throw TypeError(f2(Z));return T}function $$($,Z){return bO(Z9({...q2,...$}),Z)}function Hz($,Z,O,j,T,z){let J=t(z),{calendar:W,timeZone:Y}=O;return F0(((X,D,U,F,B)=>{let G=PZ(X,U,F,i0,b2,A2),[K,Q,f]=NZ(B,2);return r1(D,{...X.dateFromFields(G,wO(B,K)),...$$(G,K)},w$(G.offset),Q,f)})($(W),Z(Y),j,T,J),Y,W)}function bz($,Z,O,j,T){let z=t(T);return e(((J,W,Y,X)=>{let D=PZ(J,W,Y,i0,K1),U=q(X);return U1({...J.dateFromFields(D,wO(X,U)),...$$(D,U)})})($(Z.calendar),O,j,z))}function vz($,Z,O,j,T){let z=t(T);return((J,W,Y,X)=>{let D=PZ(J,W,Y,i0);return J.dateFromFields(D,X)})($(Z.calendar),O,j,z)}function wz($,Z,O,j,T){let z=t(T);return i1(((J,W,Y,X)=>{let D=PZ(J,W,Y,uT);return J.yearMonthFromFields(D,X)})($(Z.calendar),O,j,z))}function Rz($,Z,O,j,T){let z=t(T);return((J,W,Y,X)=>{let D=PZ(J,W,Y,i0);return J.monthDayFromFields(D,X)})($(Z.calendar),O,j,z)}function qz($,Z,O){return d0(((j,T,z)=>{let J=q(z);return $$({...H0(Qj,j),...r0(T,Qj)},J)})($,Z,O))}function kz($,Z){return l((O=$,j=Z,b$({...O,...r0(j,sT)})));var O,j}function PZ($,Z,O,j,T=[],z=[]){let J=[...$.fields(j),...T].sort(),W=r0(Z,J,z),Y=r0(O,J);return W=$.mergeFields(W,Y),r0(W,J,[])}function wT($,Z){let O=H1($,Z,R2);return $.monthDayFromFields(O)}function RT($,Z,O){let j=H1($,Z,w2);return $.yearMonthFromFields(j,O)}function gz($,Z,O,j,T){Z=H0(O=$.fields(O),Z),j=r0(j,T=$.fields(T),[]);let z=$.mergeFields(Z,j);return z=r0(z,[...O,...T].sort(),[]),$.dateFromFields(z)}function Wj($,Z){let{era:O,eraYear:j,year:T}=Z,z=Bj($);if(O!==void 0||j!==void 0){if(O===void 0||j===void 0)throw TypeError(sW);if(!z)throw RangeError(uW);let J=z[O];if(J===void 0)throw RangeError(aW(O));let W=Mz(j,J);if(T!==void 0&&T!==W)throw RangeError(nW);T=W}else if(T===void 0)throw TypeError(oW(z));return T}function Yj($,Z,O,j){let{month:T,monthCode:z}=Z;if(z!==void 0){let J=((W,Y,X,D)=>{let U=W.U(X),[F,B]=Lz(Y),G=IO(F,B,U);if(B){let K=Sz(W);if(K===void 0)throw RangeError(GZ);if(K>0){if(G>K)throw RangeError(GZ);if(U===void 0){if(D===1)throw RangeError(GZ);G--}}else{if(G!==-K)throw RangeError(GZ);if(U===void 0&&D===1)throw RangeError(GZ)}}return G})($,z,O,j);if(T!==void 0&&T!==J)throw RangeError(M2);T=J,j=1}else if(T===void 0)throw TypeError(tW);return g0("month",T,1,$.L(O),j)}function E8($,Z,O,j,T){return _0(Z,"day",1,$.j(j,O),T)}function Xj($,Z,O,j){let T=0,z=[];for(let J of O)Z[J]!==void 0?T=1:z.push(J);if(Object.assign($,Z),T)for(let J of j||z)delete $[J]}function yz($){return Y0(k0(PO(xO($))))}function mz($,Z,O,j,T=w){return F0(k0(PO(xO(O))),Z(j),$(T))}function pz($,Z,O,j,T=0,z=0,J=0,W=0,Y=0,X=0,D=w){return e(U1(HO(h0(Q0,P$(J3,[Z,O,j,T,z,J,W,Y,X])))),$(D))}function hz($,Z,O,j,T=w){return $0(M1(n1(h0(Q0,{isoYear:Z,isoMonth:O,isoDay:j}))),$(T))}function cz($,Z,O,j=w,T=1){let z=Q0(Z),J=Q0(O),W=$(j);return i1(Aj(n1({isoYear:z,isoMonth:J,isoDay:Q0(T)})),W)}function lz($,Z,O,j=w,T=x$){let z=Q0(Z),J=Q0(O),W=$(j);return QO(M1(n1({isoYear:Q0(T),isoMonth:z,isoDay:J})),W)}function dz($=0,Z=0,O=0,j=0,T=0,z=0){return d0(bO(h0(Q0,P$(u0,[$,Z,O,j,T,z])),1))}function iz($=0,Z=0,O=0,j=0,T=0,z=0,J=0,W=0,Y=0,X=0){return l(b$(h0(a8,P$(k,[$,Z,O,j,T,z,J,W,Y,X]))))}function qT($,Z,O=w){return F0($.epochNanoseconds,Z,O)}function uz($){return Y0($.epochNanoseconds)}function kT($,Z){return e(I0(Z,$))}function gT($,Z){return $0(I0(Z,$))}function sz($,Z,O){return RT($(Z.calendar),O)}function nz($,Z,O){return wT($(Z.calendar),O)}function yT($,Z){return d0(I0(Z,$))}function az($,Z,O,j){let T=((z,J,W,Y)=>{let X=wj(Y);return A0(z(J),W,X)})($,O,Z,j);return F0(k0(T),O,Z.calendar)}function oz($,Z,O){let j=$(Z.calendar);return i1({...Z,...RT(j,O)})}function rz($,Z,O){return wT($(Z.calendar),O)}function tz($,Z,O,j,T){let z=$(T.timeZone),J=T.plainTime,W=J!==void 0?Z(J):p0;return F0(A0(O(z),{...j,...W}),z,j.calendar)}function ez($,Z=p0){return e(U1({...$,...Z}))}function $2($,Z,O){return RT($(Z.calendar),O)}function Z2($,Z,O){return wT($(Z.calendar),O)}function O2($,Z,O,j){return((T,z,J)=>gz(T,z,w2,F1(J),vZ))($(Z.calendar),O,j)}function j2($,Z,O,j){return((T,z,J)=>gz(T,z,R2,F1(J),T3))($(Z.calendar),O,j)}function T2($,Z,O,j,T){let z=F1(T),J=Z(z.plainDate),W=$(z.timeZone);return F0(A0(O(W),{...J,...j}),W,J.calendar)}function z2($,Z){return e(U1({...$,...Z}))}function J2($){return Y0(k0(N$($,m0)))}function W2($){return Y0(k0(N$($,e0)))}function Y2($){return Y0(k0(PO(xO($),O$)))}function X2($){return Y0(k0(PO(xO($))))}function D2($,Z,O=p0){let j=Z.timeZone,T=$(j),z={...I0(Z,T),...O};return F0(r1(T,z,z.offsetNanoseconds,2),j,Z.calendar)}function F2($,Z,O){let j=Z.timeZone,T=$(j),z={...I0(Z,T),...O},J=K2(Z.calendar,O.calendar);return F0(r1(T,z,z.offsetNanoseconds,2),j,J)}function U2($,Z=p0){return e({...$,...Z})}function G2($,Z){return e({...$,...Z},K2($.calendar,Z.calendar))}function eO($,Z){return{...$,calendar:Z}}function B2($,Z){return{...$,timeZone:Z}}function K2($,Z){if($===Z)return $;let O=X0($),j=X0(Z);if(O===j||O===w)return Z;if(j===w)return $;throw RangeError(lT)}function gW($,Z){return(O)=>O===w?$:O===z3||O===_$?Object.assign(Object.create($),{id:O}):Object.assign(Object.create(Z),oY(O))}function Z$($,Z,O){let j=new Set(O);return(T)=>(((z,J)=>{for(let W of J)if(W in z)return 1;return 0})(T=Ij(j,T),$)||Object.assign(T,Z),O&&(T.timeZone=z$,["full","long"].includes(T.timeStyle)&&(T.timeStyle="medium")),T)}function G1($,Z=mT){let[O,,,j]=$;return(T,z=C9,...J)=>{let W=Z(j&&j(...J),T,z,O),Y=W.resolvedOptions();return[W,...yW($,Y,J)]}}function mT($,Z,O,j){if(O=j(O),$){if(O.timeZone!==void 0)throw TypeError(DY);O.timeZone=$}return new b1(Z,O)}function yW($,Z,O){let[,j,T]=$;return O.map((z)=>(z.calendar&&((J,W,Y)=>{if((Y||J!==w)&&J!==W)throw RangeError(lT)})(X0(z.calendar),Z.calendar,T),j(z,Z)))}function q$($){let Z=EZ();return P1(Z,$.getOffsetNanosecondsFor(Z))}function EZ(){return N$(Date.now(),e0)}function B1(){return w8||(w8=new b1().resolvedOptions().timeZone)}var mW=($,Z)=>`Non-integer ${$}: ${Z}`,pW=($,Z)=>`Non-positive ${$}: ${Z}`,hW=($,Z)=>`Non-finite ${$}: ${Z}`,cW=($)=>`Cannot convert bigint to ${$}`,lW=($)=>`Invalid bigint: ${$}`,dW="Cannot convert Symbol to string",Q2="Invalid object",C2=($,Z,O,j,T)=>T?C2($,T[Z],T[O],T[j]):AZ($,Z)+`; must be between ${O}-${j}`,AZ=($,Z)=>`Invalid ${$}: ${Z}`,pT=($)=>`Missing ${$}`,hT=($)=>`Invalid field ${$}`,iW=($)=>`Duplicate field ${$}`,f2=($)=>"No valid fields: "+$.join(),V2="Invalid bag",I2=($,Z,O)=>AZ($,Z)+"; must be "+Object.keys(O).join(),L2="Cannot use valueOf",cT="Invalid calling context",uW="Forbidden era/eraYear",sW="Mismatching era/eraYear",nW="Mismatching year/eraYear",aW=($)=>`Invalid era: ${$}`,oW=($)=>"Missing year"+($?"/era/eraYear":""),rW=($)=>`Invalid monthCode: ${$}`,M2="Mismatching month/monthCode",tW="Missing month/monthCode",A8="Cannot guess year",GZ="Invalid leap month",S2="Invalid protocol",HZ="Invalid protocol results",lT="Mismatching Calendars",eW=($)=>`Invalid Calendar: ${$}`,N2="Mismatching TimeZones",$Y="Forbidden ICU TimeZone",ZY="Out-of-bounds offset",OY="Out-of-bounds TimeZone gap",jY="Invalid TimeZone offset",TY="Ambiguous offset",$3="Out-of-bounds date",zY="Out-of-bounds duration",JY="Cannot mix duration signs",Z3="Missing relativeTo",WY="Cannot use large units",YY="Required smallestUnit or largestUnit",XY="smallestUnit > largestUnit",x0=($)=>`Cannot parse: ${$}`,D1=($)=>`Invalid substring: ${$}`,_2=($)=>`Cannot format ${$}`,x2="Mismatching types for formatting",DY="Cannot specify TimeZone",P2=v(LZ,($,Z)=>Z),k$=v(LZ,($,Z,O)=>O),y0=v(GO,2),Kj={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},bZ=Object.keys(Kj),P0=86400000,E2=1000,O$=1000,e0=1e6,m0=1e9,O3=60000000000,j3=3600000000000,m=86400000000000,t0=[1,O$,e0,m0,O3,j3,m],K1=bZ.slice(0,6),Qj=MZ(K1),A2=["offset"],H2=["timeZone"],b2=K1.concat(A2),v2=b2.concat(H2),Cj=["era","eraYear"],FY=Cj.concat(["year"]),T3=["year"],dT=["monthCode"],iT=["month"].concat(dT),vZ=["day"],uT=iT.concat(T3),w2=dT.concat(T3),i0=vZ.concat(uT),UY=vZ.concat(iT),R2=vZ.concat(dT),q2=k$(K1,0),w="iso8601",z3="gregory",_$="japanese",k2={[z3]:{bce:-1,ce:0},[_$]:{bce:-1,ce:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018},ethioaa:{era0:0},ethiopic:{era0:0,era1:5500},coptic:{era0:-1,era1:0},roc:{beforeroc:-1,minguo:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0}},GY={chinese:13,dangi:13,hebrew:-6},s=v(_O,"string"),g2=v(_O,"boolean"),BY=v(_O,"number"),y2=v(_O,"function"),k=bZ.map(($)=>$+"s"),sT=MZ(k),KY=k.slice(0,6),m2=k.slice(6),QY=m2.slice(1),CY=P2(k),D0=k$(k,0),nT=k$(KY,0),aT=v(y8,k),u0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],oT=["isoDay","isoMonth","isoYear"],J3=u0.concat(oT),rT=MZ(oT),p2=MZ(u0),h2=MZ(J3),p0=k$(p2,0),fY=v(y8,J3),b1=Intl.DateTimeFormat,c2="en-GB",tT=1e8,VY=tT*P0,IY=[tT,0],LY=[-tT,0],VZ=275760,IZ=-271821,MY=1970,x$=1972,Y1=12,SY=E$(1868,9,8),NY=E0(NW,WeakMap),LO="smallestUnit",fj="unit",KZ="roundingIncrement",Dj="fractionalSecondDigits",l2="relativeTo",d2={constrain:0,reject:1},_Y=Object.keys(d2),xY={compatible:0,reject:1,earlier:2,later:3},PY={reject:0,use:1,prefer:2,ignore:3},EY={auto:0,never:1,critical:2,always:3},AY={auto:0,never:1,critical:2},HY={auto:0,never:1},bY={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},wZ=v(mj,LO),eT=v(mj,"largestUnit"),vY=v(mj,fj),i2=v(a1,"overflow",d2),u2=v(a1,"disambiguation",xY),wY=v(a1,"offset",PY),$6=v(a1,"calendarName",EY),RY=v(a1,"timeZoneName",AY),qY=v(a1,"offset",HY),RZ=v(a1,"roundingMode",bY),g$="PlainYearMonth",y$="PlainMonthDay",j$="PlainDate",T$="PlainDateTime",W3="PlainTime",Q1="ZonedDateTime",Y3="Instant",X3="Duration",kY=[Math.floor,($)=>WO($)?Math.floor($):Math.round($),Math.ceil,($)=>WO($)?Math.ceil($):Math.round($),Math.trunc,($)=>WO($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>WO($)?($=Math.trunc($)||0)+$%2:Math.round($)],z$="UTC",FO=5184000,gY=KO(1847),yY=KO(new Date().getUTCFullYear()+10),mY=/0+$/,I0=E0(HW,WeakMap),H8=4294967295,D3=E0(($)=>{let Z=fT($);return typeof Z=="object"?new n2(Z):new s2(Z||0)});class s2{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[Hj($,this.v)]}l(){}}class n2{constructor($){this.$=((Z)=>{function O(Y){let X=Fj(Y,J,W),[D,U]=N8(X),F=T(D),B=T(U);return F===B?F:j(z(D,U),F,B,Y)}function j(Y,X,D,U){let F,B;for(;(U===void 0||(F=U<Y[0]?X:U>=Y[1]?D:void 0)===void 0)&&(B=Y[1]-Y[0]);){let G=Y[0]+Math.floor(B/2);Z(G)===D?Y[1]=G:Y[0]=G+1}return F}let T=E0(Z),z=E0(bW),J=gY,W=yY;return{G(Y){let X=O(Y-86400),D=O(Y+86400),U=Y-X,F=Y-D;if(X===D)return[U];let B=O(U);return B===O(F)?[Y-B]:X>D?[U,F]:[]},V:O,l(Y,X){let D=Fj(Y,J,W),[U,F]=N8(D),B=FO*X,G=X<0?()=>F>J||(J=D,0):()=>U<W||(W=D,0);for(;G();){let K=T(U),Q=T(F);if(K!==Q){let f=z(U,F);j(f,K,Q);let L=f[0];if((L1(L,Y)||1)===X)return L}U+=B,F+=B}}}})(((Z)=>(O)=>{let j=Ej(Z,O*E2);return KO(Cz(j),parseInt(j.month),parseInt(j.day),parseInt(j.hour),parseInt(j.minute),parseInt(j.second))-O})($))}getOffsetNanosecondsFor($){return this.$.V(t8($))*m0}getPossibleInstantsFor($){let[Z,O]=[KO((j=$).isoYear,j.isoMonth,j.isoDay,j.isoHour,j.isoMinute,j.isoSecond),j.isoMillisecond*e0+j.isoMicrosecond*O$+j.isoNanosecond];var j;return this.$.G(Z).map((T)=>k0(S$(N$(T,m0),O)))}l($,Z){let[O,j]=e8($),T=this.$.l(O+(Z>0||j?1:0),Z);if(T!==void 0)return N$(T,m0)}}var Z6="([+\u2212-])",UO="(?:[.,](\\d{1,9}))?",a2=`(?:(?:${Z6}(\\d{6}))|(\\d{4}))-?(\\d{2})`,O6="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+UO+")?)?",j6=Z6+O6,pY=a2+"-?(\\d{2})(?:[T ]"+O6+"(Z|"+j6+")?)?",o2="\\[(!?)([^\\]]*)\\]",F3=`((?:${o2}){0,9})`,hY=R$(a2+F3),cY=R$("(?:--)?(\\d{2})-?(\\d{2})"+F3),lY=R$(pY+F3),dY=R$("T?"+O6+"(?:"+j6+")?"+F3),iY=R$(j6),uY=new RegExp(o2,"g"),sY=R$(`${Z6}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${UO}H)?(?:(\\d+)${UO}M)?(?:(\\d+)${UO}S)?)?`),nY=E0(($)=>new b1(c2,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),aY=/^(AC|AE|AG|AR|AS|BE|BS|CA|CN|CS|CT|EA|EC|IE|IS|JS|MI|NE|NS|PL|PN|PR|PS|SS|VS)T$/,oY=E0(RW),T6=E0(($)=>new b1(c2,{calendar:$,timeZone:z$,era:"short",year:"numeric",month:"short",day:"numeric"})),rY=/^M(\d{2})(L?)$/,tY={era:BO,eraYear:Q0,year:Q0,month:I8,monthCode:BO,day:I8},eY=k$(K1,Q0),$9=k$(k,a8),b8=Object.assign({},tY,eY,$9,{offset:BO}),Z9=v(SW,K1,u0),v8={dateAdd($,Z,O){let j=q(O),T,{years:z,months:J,weeks:W,days:Y}=Z;if(Y+=J0(Z,5)[0],z||J)T=((X,D,U,F,B)=>{let[G,K,Q]=X.h(D);if(U){let[f,L]=X.I(G,K);G+=U,K=IO(f,L,X.U(G)),K=g0("month",K,1,X.L(G),B)}return F&&([G,K]=X._(G,K,F)),Q=g0("day",Q,1,X.j(G,K),B),X.q(G,K,Q)})(this,$,z,J,j);else{if(!W&&!Y)return $;T=V0($)}return T+=(7*W+Y)*P0,M1(AO(T))},dateUntil($,Z,O){if(O<=7){let Y=0,X=Kz({...$,...p0},{...Z,...p0});return O===7&&([Y,X]=N1(X,7)),{...D0,weeks:Y,days:X}}let j=this.h($),T=this.h(Z),[z,J,W]=((Y,X,D,U,F,B,G)=>{let K=F-X,Q=B-D,f=G-U;if(K||Q){let L=Math.sign(K||Q),V=Y.j(F,B),x=0;if(Math.sign(f)===-L){let P=V;[F,B]=Y._(F,B,-L),K=F-X,Q=B-D,V=Y.j(F,B),x=L<0?-P:V}if(f=G-Math.min(U,V)+x,K){let[P,I]=Y.I(X,D),[M,E]=Y.I(F,B);if(Q=M-P||Number(E)-Number(I),Math.sign(Q)===-L){let H=L<0&&-Y.L(F);K=(F-=L)-X,Q=B-IO(P,I,Y.U(F))+(H||Y.L(F))}}}return[K,Q,f]})(this,...j,...T);return O===8&&(J+=this.J(z,j[0]),z=0),{...D0,years:z,months:J,days:W}},dateFromFields($,Z){let O=q(Z),j=Wj(this,$),T=Yj(this,$,j,O),z=E8(this,$,T,j,O);return $0(M1(this.P(j,T,z)),this.id||w)},yearMonthFromFields($,Z){let O=q(Z),j=Wj(this,$),T=Yj(this,$,j,O);return i1(Aj(this.P(j,T,1)),this.id||w)},monthDayFromFields($,Z){let O=q(Z),j=!this.id,{monthCode:T,year:z,month:J}=$,W,Y,X,D,U;if(T!==void 0){[W,Y]=Lz(T),U=R8($,"day");let F=this.N(W,Y,U);if(!F)throw RangeError(A8);if([X,D]=F,J!==void 0&&J!==D)throw RangeError(M2);j&&(D=g0("month",D,1,Y1,1),U=g0("day",U,1,bj(z!==void 0?z:X,D),O))}else{X=z===void 0&&j?x$:Wj(this,$),D=Yj(this,$,X,O),U=E8(this,$,D,X,O);let F=this.U(X);Y=D===F,W=Gj(D,F);let B=this.N(W,Y,U);if(!B)throw RangeError(A8);[X,D]=B}return QO(M1(this.P(X,D,U)),this.id||w)},fields($){return Bj(this)&&$.includes("year")?[...$,...Cj]:$},mergeFields($,Z){let O=Object.assign(Object.create(null),$);return Xj(O,Z,iT),Bj(this)&&(Xj(O,Z,FY),this.id===_$&&Xj(O,Z,UY,Cj)),O},inLeapYear($){let[Z]=this.h($);return this.K(Z)},monthsInYear($){let[Z]=this.h($);return this.L(Z)},daysInMonth($){let[Z,O]=this.h($);return this.j(Z,O)},daysInYear($){let[Z]=this.h($);return this.X(Z)},dayOfYear:AT,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[Z,O]=this.h($),[j,T]=this.I(Z,O);return((z,J)=>"M"+y0(z)+(J?"L":""))(j,T)},dayOfWeek:T5,daysInWeek(){return 7}},O9={dayOfYear:AT,h:Z5,q:E$},j9=Object.assign({},O9,{weekOfYear:Vz,yearOfWeek:Iz,R($){function Z(B){return(7-B<j?7:0)-B}function O(B){let G=j5(F+B),K=B||1,Q=Z(BZ(Y+G*K,7));return D=(G+(Q-X)*K)/7}let j=this.id?1:4,T=T5($),z=this.dayOfYear($),J=BZ(T-1,7),W=z-1,Y=BZ(J-W,7),X=Z(Y),D,U=Math.floor((W-X)/7)+1,F=$.isoYear;return U?U>O(0)&&(U=1,F++):(U=O(-1),F--),[U,F,D]}}),T9={dayOfYear:AT,h:Uj,q:fZ,weekOfYear:Vz,yearOfWeek:Iz,R(){return[]}},m$=gW(Object.assign({},v8,j9,{h:Z5,ee($){return this.id===z3?z5($):this.id===_$?NY($):[]},I:($,Z)=>[Z,0],N($,Z){if(!Z)return[x$,$]},K:vj,U(){},L:O5,J:($)=>$*Y1,j:bj,X:j5,P:($,Z,O)=>({isoYear:$,isoMonth:Z,isoDay:O}),q:E$,_:($,Z,O)=>($+=SO(O,Y1),(Z+=Mj(O,Y1))<1?($--,Z+=Y1):Z>Y1&&($++,Z-=Y1),[$,Z]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},v8,T9,{h:Uj,ee($){let Z=this.O($);return[Z.era,Z.eraYear]},I($,Z){let O=YO.call(this,$);return[Gj(Z,O),O===Z]},N($,Z,O){let[j,T,z]=Uj.call(this,{isoYear:x$,isoMonth:Y1,isoDay:31}),J=YO.call(this,j),W=T===J;(L1($,Gj(T,J))||L1(Number(Z),Number(W))||L1(O,z))===1&&j--;for(let Y=0;Y<100;Y++){let X=j-Y,D=YO.call(this,X),U=IO($,Z,D);if(Z===(U===D)&&O<=x8.call(this,X,U))return[X,U]}},K($){let Z=XO.call(this,$);return Z>XO.call(this,$-1)&&Z>XO.call(this,$+1)},U:YO,L:DO,J($,Z){let O=Z+$,j=Math.sign($),T=j<0?-1:0,z=0;for(let J=Z;J!==O;J+=j)z+=DO.call(this,J+T);return z},j:x8,X:XO,P($,Z,O){return AO(fZ.call(this,$,Z,O))},q:fZ,_($,Z,O){if(O){if(Z+=O,!Number.isSafeInteger(Z))throw RangeError($3);if(O<0)for(;Z<1;)Z+=DO.call(this,--$);else{let j;for(;Z>(j=DO.call(this,$));)Z-=j,$++}}return[$,Z]},year($){return this.O($).year},month($){let{year:Z,F:O}=this.O($),{C:j}=this.B(Z);return j[O]+1},day($){return this.O($).day}})),S1="numeric",p$=["timeZoneName"],r2={month:S1,day:S1},z6={year:S1,month:S1},J6=Object.assign({},z6,{day:S1}),W6={hour:S1,minute:S1,second:S1},Y6=Object.assign({},J6,W6),z9=Object.assign({},Y6,{timeZoneName:"short"}),J9=Object.keys(z6),W9=Object.keys(r2),Y9=Object.keys(J6),X9=Object.keys(W6),X6=["dateStyle"],D9=J9.concat(X6),F9=W9.concat(X6),D6=Y9.concat(X6,["weekday"]),qZ=X9.concat(["dayPeriod","timeStyle"]),F6=D6.concat(qZ),U9=F6.concat(p$),G9=p$.concat(qZ),B9=p$.concat(D6),K9=p$.concat(["day","weekday"],qZ),Q9=p$.concat(["year","weekday"],qZ),C9={},U6=[Z$(F6,Y6),RO],t2=[Z$(U9,z9),RO,0,($,Z)=>{let O=X0($.timeZone);if(Z&&X0(Z.timeZone)!==O)throw RangeError(N2);return O}],G6=[Z$(F6,Y6,p$),V0],B6=[Z$(D6,J6,G9),V0],K6=[Z$(qZ,W6,B9),($)=>_1($)/e0],Q6=[Z$(D9,z6,K9),V0,1],C6=[Z$(F9,r2,Q9),V0,1],w8;function O1($,Z,O,j,T){function z(...Y){if(!(this instanceof z))throw TypeError(cT);O7(this,Z(...Y))}function J(Y,X){return Object.defineProperties(function(...D){return Y.call(this,W(this),...D)},Vj(X))}function W(Y){let X=B0(Y);if(!X||X.branding!==$)throw TypeError(cT);return X}return Object.defineProperties(z.prototype,{...q8(h0(J,O)),...s1(h0(J,j)),...MO("Temporal."+$)}),Object.defineProperties(z,{...s1(T),...Vj($)}),[z,(Y)=>{let X=Object.create(z.prototype);return O7(X,Y),X},W]}function z7($){return $=$.concat("id").sort(),(Z)=>{if(!k8(Z,$))throw TypeError(S2);return Z}}function d$($){if(B0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(V2);return $}function U3($,Z){let O={};for(let j in $)O[j]=({o:T},z)=>{let J=B0(z)||{},{branding:W}=J,Y=W===j$||Z.includes(W)?J:S0(z);return T[j](Y)};return O}function I6($){let Z={};for(let O in $)Z[O]=(j)=>{let{calendar:T}=j;return(z=T,typeof z=="string"?m$(z):(J=z,Object.assign(Object.create(w9),{i:J})))[O](j);var z,J};return Z}function k1(){throw TypeError(L2)}function gZ({calendar:$}){return typeof $=="string"?new A6($):$}function e2($,Z){if(Z=t(Z),W0($)){let j=B0($);if(j&&j.branding===y$)return q(Z),j;let T=Y7($);return vT(V3(T||w),!T,$,Z)}let O=i5(m$,$);return q(Z),O}function J7($,Z,O){return j=Z.call($,M0(Y0(O))),ej(SZ(j));var j}function G3($,Z=U7){let O=Object.keys(Z).sort(),j={};for(let T of O)j[T]=v(Z[T],$,y2($[T]));return j}function p($,Z){return typeof $=="string"?D3($):G3($,Z)}function O0($){return p($,V6)}function $1($){if(W0($)){let Z=B0($);if(Z)switch(Z.branding){case Y3:return Z;case Q1:return Y0(Z.epochNanoseconds)}}return p5($)}function $7($,Z,O){let j=Z.l($1(O).epochNanoseconds,$);return j?M0(Y0(j)):null}function c($){return W0($)?(B0($)||{}).timeZone||m9($):((Z)=>sO(a5(s(Z))))($)}function v1($,Z){if(W0($)){let O=B0($)||{};switch(O.branding){case W3:return q(Z),O;case T$:return q(Z),d0(O);case Q1:return q(Z),yT(O0,O)}return Ez($,Z)}return q(Z),u5($)}function L6($){return $===void 0?void 0:v1($)}function h$($,Z){if(Z=t(Z),W0($)){let j=B0($);return j&&j.branding===g$?(q(Z),j):bT(C3(yZ($)),$,Z)}let O=d5(m$,$);return q(Z),O}function w1($,Z){if(Z=t(Z),W0($)){let j=B0($)||{};switch(j.branding){case T$:return q(Z),j;case j$:return q(Z),e({...j,...p0});case Q1:return q(Z),kT(O0,j)}return Pz(f3(yZ($)),$,Z)}let O=l5($);return q(Z),O}function S0($,Z){if(Z=t(Z),W0($)){let j=B0($)||{};switch(j.branding){case j$:return q(Z),j;case T$:return q(Z),$0(j);case Q1:return q(Z),gT(O0,j)}return HT(f3(yZ($)),$,Z)}let O=iO($);return q(Z),O}function W7($,Z,O){return c0(Z.call($,a($0(O,$))))}function j1($){return(Z)=>typeof Z=="string"?m$(Z):((O,j)=>{let T=Object.keys(j).sort(),z={};for(let J of T)z[J]=v(j[J],O,O[J]);return z})(Z,$)}function n($){if(W0($)){let Z=B0($);return Z&&Z.branding===X3?Z:Az($)}return s5($)}function kZ($){if($!==void 0){if(W0($)){let Z=B0($)||{};switch(Z.branding){case Q1:case j$:return Z;case T$:return $0(Z)}let O=yZ($);return{..._z(c,p,f3(O),$),calendar:O}}return h5($)}}function yZ($){return Y7($)||w}function Y7($){let{calendar:Z}=$;if(Z!==void 0)return G0(Z)}function G0($){return W0($)?(B0($)||{}).calendar||$X($):((Z)=>xZ(n5(s(Z))))($)}function c$($,Z){if(Z=t(Z),W0($)){let O=B0($);if(O&&O.branding===Q1)return NZ(Z),O;let j=yZ($);return xz(c,p,f3(j),j,$,Z)}return c5($,Z)}function Z7($){return h0((Z)=>(O)=>Z(f6(O)),$)}function f6($){return I0($,O0)}function f9(){let $=b1.prototype,Z=Object.getOwnPropertyDescriptors($),O=Object.getOwnPropertyDescriptors(b1),j=function(T,z={}){if(!(this instanceof j))return new j(T,z);H6.set(this,((J,W={})=>{let Y=new b1(J,W),X=Y.resolvedOptions(),D=X.locale,U=H0(Object.keys(W),X),F=E0(L9),B=(...G)=>{let K,Q=G.map((f,L)=>{let V=B0(f),x=(V||{}).branding;if(L&&K&&K!==x)throw TypeError(x2);return K=x,V});return K?F(K)(D,U,...Q):[Y,...G]};return B.u=Y,B})(T,z))};for(let T in Z){let z=Z[T],J=T.startsWith("format")&&V9(T);typeof z.value=="function"?z.value=T==="constructor"?j:J||I9(T):J&&(z.get=function(){return J.bind(this)})}return O.prototype.value=Object.create($,Z),Object.defineProperties(j,O),j}function V9($){return function(...Z){let O=H6.get(this),[j,...T]=O(...Z);return j[$](...T)}}function I9($){return function(...Z){return H6.get(this).u[$](...Z)}}function L9($){let Z=M9[$];if(!Z)throw TypeError(_2($));return G1(Z,E0(mT))}var M9={Instant:U6,PlainDateTime:G6,PlainDate:B6,PlainTime:K6,PlainYearMonth:Q6,PlainMonthDay:C6},S9=G1(U6),N9=G1(t2),_9=G1(G6),x9=G1(B6),P9=G1(K6),E9=G1(Q6),A9=G1(C6),M6={era:l8,eraYear:Sj,year:SZ,month:c0,daysInMonth:c0,daysInYear:c0,inLeapYear:g2,monthsInYear:c0},K3={monthCode:s},S6={day:c0},X7={dayOfWeek:c0,dayOfYear:c0,weekOfYear:d8,yearOfWeek:Sj,daysInWeek:c0},D7=Object.assign({},M6,K3,S6,X7),B3=new WeakMap,B0=B3.get.bind(B3),O7=B3.set.bind(B3),H9={...U3(M6,[g$]),...U3(X7,[]),...U3(K3,[g$,y$]),...U3(S6,[y$])},N6=I6(D7),b9=I6({...M6,...K3}),v9=I6({...K3,...S6}),mZ={calendarId:($)=>X0($.calendar)},w9=h0(($,Z)=>function(O){let{i:j}=this;return $(j[Z](a($0(O,j))))},D7),R9=LZ(($)=>(Z)=>Z[$],k.concat("sign")),_6=LZ(($,Z)=>(O)=>O[u0[Z]],K1),F7={epochSeconds:U5,epochMilliseconds:RO,epochMicroseconds:G5,epochNanoseconds:B5},pZ=v(Ij,new Set(["branding"])),[q9,l$,k9]=O1(y$,v(lz,G0),{...mZ,...v9},{getISOFields:pZ,getCalendar:gZ,with($,Z,O){return l$(Rz(r9,$,this,d$(Z),O))},equals:($,Z)=>Xz($,e2(Z)),toPlainDate($,Z){return a(j2(hZ,$,this,Z))},toLocaleString($,Z,O){let[j,T]=A9(Z,O,$);return j.format(T)},toString:nj,toJSON:($)=>nj($),valueOf:k1},{from:($,Z)=>l$(e2($,Z))}),U7={getOffsetNanosecondsFor:J7,getPossibleInstantsFor($,Z,O){let j=[...Z.call($,U0(e(O,w)))].map((z)=>y9(z).epochNanoseconds),T=j.length;return T>1&&(j.sort(f0),$T(q0(R0(j[0],j[T-1])))),j}},V6={getOffsetNanosecondsFor:J7},[g9,M0,y9]=O1(Y3,yz,F7,{add:($,Z)=>M0(ZT(0,$,n(Z))),subtract:($,Z)=>M0(ZT(1,$,n(Z))),until:($,Z,O)=>h(MT(0,$,$1(Z),O)),since:($,Z,O)=>h(MT(1,$,$1(Z),O)),round:($,Z)=>M0(C5($,Z)),equals:($,Z)=>Tz($,$1(Z)),toZonedDateTime($,Z){let O=F1(Z);return Z0(qT($,c(O.timeZone),G0(O.calendar)))},toZonedDateTimeISO:($,Z)=>Z0(qT($,c(Z))),toLocaleString($,Z,O){let[j,T]=S9(Z,O,$);return j.format(T)},toString:($,Z)=>lj(c,O0,$,Z),toJSON:($)=>lj(c,O0,$),valueOf:k1},{from:($)=>M0($1($)),fromEpochSeconds:($)=>M0(J2($)),fromEpochMilliseconds:($)=>M0(W2($)),fromEpochMicroseconds:($)=>M0(Y2($)),fromEpochNanoseconds:($)=>M0(X2($)),compare:($,Z)=>VT($1($),$1(Z))}),[Q3,LU]=O1("TimeZone",($)=>{let Z=Oz($);return{branding:"TimeZone",id:Z,o:D3(Z)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},Z)=>$.getPossibleInstantsFor(w1(Z)).map((O)=>M0(Y0(O))),getOffsetNanosecondsFor:({o:$},Z)=>$.getOffsetNanosecondsFor($1(Z).epochNanoseconds),getOffsetStringFor($,Z){let O=$1(Z).epochNanoseconds,j=G3(this,V6).getOffsetNanosecondsFor(O);return o1(j)},getPlainDateTimeFor($,Z,O=w){let j=$1(Z).epochNanoseconds,T=G3(this,V6).getOffsetNanosecondsFor(j);return U0(e(P1(j,T),G0(O)))},getInstantFor($,Z,O){let j=w1(Z),T=wj(O),z=G3(this);return M0(Y0(A0(z,j,T)))},getNextTransition:({o:$},Z)=>$7(1,$,Z),getPreviousTransition:({o:$},Z)=>$7(-1,$,Z),equals($,Z){return!!aO(this,c(Z))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let Z=c($);return typeof Z=="string"?new Q3(Z):Z}}),m9=z7(Object.keys(U7)),[p9,R1]=O1(W3,dz,_6,{getISOFields:pZ,with($,Z,O){return R1(qz(this,d$(Z),O))},add:($,Z)=>R1(JT(0,$,n(Z))),subtract:($,Z)=>R1(JT(1,$,n(Z))),until:($,Z,O)=>h(PT(0,$,v1(Z),O)),since:($,Z,O)=>h(PT(1,$,v1(Z),O)),round:($,Z)=>R1(I5($,Z)),equals:($,Z)=>Dz($,v1(Z)),toZonedDateTime:($,Z)=>Z0(T2(c,S0,p,$,Z)),toPlainDateTime:($,Z)=>U0(z2($,S0(Z))),toLocaleString($,Z,O){let[j,T]=P9(Z,O,$);return j.format(T)},toString:aj,toJSON:($)=>aj($),valueOf:k1},{from:($,Z)=>R1(v1($,Z)),compare:($,Z)=>nO(v1($),v1(Z))}),[h9,q1,c9]=O1(g$,v(cz,G0),{...mZ,...b9},{getISOFields:pZ,getCalendar:gZ,with($,Z,O){return q1(wz(o9,$,this,d$(Z),O))},add:($,Z,O)=>q1(zT(j7,0,$,n(Z),O)),subtract:($,Z,O)=>q1(zT(j7,1,$,n(Z),O)),until:($,Z,O)=>h(xT(T7,0,$,h$(Z),O)),since:($,Z,O)=>h(xT(T7,1,$,h$(Z),O)),equals:($,Z)=>Yz($,h$(Z)),toPlainDate($,Z){return a(O2(hZ,$,this,Z))},toLocaleString($,Z,O){let[j,T]=E9(Z,O,$);return j.format(T)},toString:sj,toJSON:($)=>sj($),valueOf:k1},{from:($,Z)=>q1(h$($,Z)),compare:($,Z)=>e1(h$($),h$(Z))}),[l9,U0]=O1(T$,v(pz,G0),{...mZ,...N6,..._6},{getISOFields:pZ,getCalendar:gZ,with($,Z,O){return U0(bz(hZ,$,this,d$(Z),O))},withCalendar:($,Z)=>U0(eO($,G0(Z))),withPlainDate:($,Z)=>U0(G2($,S0(Z))),withPlainTime:($,Z)=>U0(U2($,L6(Z))),add:($,Z,O)=>U0(jT(J$,0,$,n(Z),O)),subtract:($,Z,O)=>U0(jT(J$,1,$,n(Z),O)),until:($,Z,O)=>h(NT(Z1,0,$,w1(Z),O)),since:($,Z,O)=>h(NT(Z1,1,$,w1(Z),O)),round:($,Z)=>U0(V5($,Z)),equals:($,Z)=>Jz($,w1(Z)),toZonedDateTime:($,Z,O)=>Z0(az(p,$,c(Z),O)),toPlainDate:($)=>a($0($)),toPlainTime:($)=>R1(d0($)),toPlainYearMonth($){return q1(oz(C3,$,this))},toPlainMonthDay($){return l$(rz(V3,$,this))},toLocaleString($,Z,O){let[j,T]=_9(Z,O,$);return j.format(T)},toString:ij,toJSON:($)=>ij($),valueOf:k1},{from:($,Z)=>U0(w1($,Z)),compare:($,Z)=>LT(w1($),w1(Z))}),[d9,a,G7]=O1(j$,v(hz,G0),{...mZ,...N6},{getISOFields:pZ,getCalendar:gZ,with($,Z,O){return a(vz(hZ,$,this,d$(Z),O))},withCalendar:($,Z)=>a(eO($,G0(Z))),add:($,Z,O)=>a(TT(J$,0,$,n(Z),O)),subtract:($,Z,O)=>a(TT(J$,1,$,n(Z),O)),until:($,Z,O)=>h(_T(Z1,0,$,S0(Z),O)),since:($,Z,O)=>h(_T(Z1,1,$,S0(Z),O)),equals:($,Z)=>Wz($,S0(Z)),toZonedDateTime($,Z){let O=!W0(Z)||Z instanceof Q3?{timeZone:Z}:Z;return Z0(tz(c,v1,p,$,O))},toPlainDateTime:($,Z)=>U0(ez($,L6(Z))),toPlainYearMonth($){return q1($2(C3,$,this))},toPlainMonthDay($){return l$(Z2(V3,$,this))},toLocaleString($,Z,O){let[j,T]=x9(Z,O,$);return j.format(T)},toString:uj,toJSON:($)=>uj($),valueOf:k1},{from:($,Z)=>a(S0($,Z)),compare:($,Z)=>e1(S0($),S0(Z))}),x6={fields($,Z,O){return[...Z.call($,O)]}},B7=Object.assign({dateFromFields($,Z,O,j){return G7(Z.call($,Object.assign(Object.create(null),O),j))}},x6),K7=Object.assign({yearMonthFromFields($,Z,O,j){return c9(Z.call($,Object.assign(Object.create(null),O),j))}},x6),Q7=Object.assign({monthDayFromFields($,Z,O,j){return k9(Z.call($,Object.assign(Object.create(null),O),j))}},x6),P6={mergeFields($,Z,O,j){return F1(Z.call($,Object.assign(Object.create(null),O),Object.assign(Object.create(null),j)))}},i9=Object.assign({},B7,P6),u9=Object.assign({},K7,P6),s9=Object.assign({},Q7,P6),E6={dateAdd($,Z,O,j,T){return G7(Z.call($,a($0(O,$)),h(l(j)),T))}},C7=Object.assign({},E6,{dateUntil($,Z,O,j,T,z){return e9(Z.call($,a($0(O,$)),a($0(j,$)),Object.assign(Object.create(null),z,{largestUnit:bZ[T]})))}}),n9=Object.assign({},E6,{day:W7}),a9=Object.assign({},C7,{day:W7}),C3=j1(K7),f3=j1(B7),V3=j1(Q7),o9=j1(u9),hZ=j1(i9),r9=j1(s9),J$=j1(E6),Z1=j1(C7),j7=j1(n9),T7=j1(a9),[t9,h,e9]=O1(X3,iz,{...R9,blank:g5},{with:($,Z)=>h(kz($,Z)),negated:($)=>h(lO($)),abs:($)=>h(k5($)),add:($,Z,O)=>h(FT(kZ,Z1,p,0,$,n(Z),O)),subtract:($,Z,O)=>h(FT(kZ,Z1,p,1,$,n(Z),O)),round:($,Z)=>h(q5(kZ,Z1,p,$,Z)),total:($,Z)=>Q5(kZ,Z1,p,$,Z),toLocaleString($,Z,O){return Intl.DurationFormat?new Intl.DurationFormat(Z,O).format(this):yO($)},toString:yO,toJSON:($)=>yO($),valueOf:k1},{from:($)=>h(n($)),compare:($,Z,O)=>jz(kZ,J$,p,n($),n(Z),O)}),f7={toString:($)=>$.id,toJSON:($)=>$.id,...H9,dateAdd:({id:$,o:Z},O,j,T)=>a($0(Z.dateAdd(S0(O),n(j),T),$)),dateUntil:({o:$},Z,O,j)=>h(l($.dateUntil(S0(Z),S0(O),W5(j)))),dateFromFields:({id:$,o:Z},O,j)=>a(HT(Z,O,j,c8($))),yearMonthFromFields:({id:$,o:Z},O,j)=>q1(bT(Z,O,j,p8($))),monthDayFromFields:({id:$,o:Z},O,j)=>l$(vT(Z,0,O,j,h8($))),fields({o:$},Z){let O=new Set(i0),j=[];for(let T of Z){if(s(T),!O.has(T))throw RangeError(hT(T));O.delete(T),j.push(T)}return $.fields(j)},mergeFields:({o:$},Z,O)=>$.mergeFields(Lj(Nj(Z)),Lj(Nj(O)))},[A6]=O1("Calendar",($)=>{let Z=fz($);return{branding:"Calendar",id:Z,o:m$(Z)}},{id:($)=>$.id},f7,{from($){let Z=G0($);return typeof Z=="string"?new A6(Z):Z}}),$X=z7(Object.keys(f7).slice(4)),[ZX,Z0]=O1(Q1,v(mz,G0,c),{...F7,...mZ,...Z7(N6),...Z7(_6),offset:($)=>o1(f6($).offsetNanoseconds),offsetNanoseconds:($)=>f6($).offsetNanoseconds,timeZoneId:($)=>X0($.timeZone),hoursInDay:($)=>L5(p,$)},{getISOFields:($)=>w5(O0,$),getCalendar:gZ,getTimeZone:({timeZone:$})=>typeof $=="string"?new Q3($):$,with($,Z,O){return Z0(Hz(hZ,p,$,this,d$(Z),O))},withCalendar:($,Z)=>Z0(eO($,G0(Z))),withTimeZone:($,Z)=>Z0(B2($,c(Z))),withPlainDate:($,Z)=>Z0(F2(p,$,S0(Z))),withPlainTime:($,Z)=>Z0(D2(p,$,L6(Z))),add:($,Z,O)=>Z0(OT(J$,p,0,$,n(Z),O)),subtract:($,Z,O)=>Z0(OT(J$,p,1,$,n(Z),O)),until:($,Z,O)=>h(l(ST(Z1,p,0,$,c$(Z),O))),since:($,Z,O)=>h(l(ST(Z1,p,1,$,c$(Z),O))),round:($,Z)=>Z0(f5(p,$,Z)),startOfDay:($)=>Z0(M5(p,$)),equals:($,Z)=>zz($,c$(Z)),toInstant:($)=>M0(uz($)),toPlainDateTime:($)=>U0(kT(O0,$)),toPlainDate:($)=>a(gT(O0,$)),toPlainTime:($)=>R1(yT(O0,$)),toPlainYearMonth($){return q1(sz(C3,$,this))},toPlainMonthDay($){return l$(nz(V3,$,this))},toLocaleString($,Z,O={}){let[j,T]=N9(Z,O,$);return j.format(T)},toString:($,Z)=>dj(O0,$,Z),toJSON:($)=>dj(O0,$),valueOf:k1},{from:($,Z)=>Z0(c$($,Z)),compare:($,Z)=>IT(c$($),c$(Z))}),OX=Object.defineProperties({},{...MO("Temporal.Now"),...s1({timeZoneId:()=>B1(),instant:()=>M0(Y0(EZ())),zonedDateTime:($,Z=B1())=>Z0(F0(EZ(),c(Z),G0($))),zonedDateTimeISO:($=B1())=>Z0(F0(EZ(),c($),w)),plainDateTime:($,Z=B1())=>U0(e(q$(O0(c(Z))),G0($))),plainDateTimeISO:($=B1())=>U0(e(q$(O0(c($))),w)),plainDate:($,Z=B1())=>a($0(q$(O0(c(Z))),G0($))),plainDateISO:($=B1())=>a($0(q$(O0(c($))),w)),plainTimeISO:($=B1())=>R1(d0(q$(O0(c($)))))})}),i$=Object.defineProperties({},{...MO("Temporal"),...s1({PlainYearMonth:h9,PlainMonthDay:q9,PlainDate:d9,PlainTime:p9,PlainDateTime:l9,ZonedDateTime:ZX,Instant:g9,Calendar:A6,TimeZone:Q3,Duration:t9,Now:OX})}),jX=f9(),H6=new WeakMap,TX=Object.defineProperties(Object.create(Intl),s1({DateTimeFormat:jX}));var b6=new WeakMap;function JX($){let Z=b6.get($);if(!Z)Z=$(zX(32).toString("hex")),b6.set($,Z),Z.catch(()=>b6.delete($));return Z}async function v6($,Z,O){if(typeof O==="string"&&O!=="")return await $.verifyPassword(Z,O);try{await $.verifyPassword(Z,await JX($.hashPassword))}catch{}return!1}async function W$($,Z){let O=Z.user??Z.session?.user;if(!O||!$.onAuthenticated)return;let{password:j,...T}=O;await $.onAuthenticated({...Z,user:T})}class q6 extends Error{}function w6($){return typeof $==="string"&&$!==""?$:null}function V7($){return XZ($)}var WX=256;function I7($){return typeof $==="string"&&$!==""&&$.length<=WX?$:null}var R6="intended_url";class k6 extends _{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class L7 extends _{schema={email:{required:"Email is required",email:"Invalid email"}}}class M7 extends _{schema={password:{required:"Password is required",password:"Invalid password"}}}class d extends s3{async me(){let $=await Y$.user();if(!$)throw new n3;return $}async verifyEmail($=new _){let Z=await $.input(),{userProvider:O}=C(A),j=w6(Z.get("token"));if(!j)return{email:null};let T=await O.findUserByVerificationToken(j);if(!T)return{email:null};return await O.verifyUser(T.email),{email:T.email}}async signInWithMagicLink($=new _){let Z=C(A),{userProvider:O}=Z,j=w6($.search.get("token")),T=null;try{T=XZ(decodeURIComponent($.search.get("email")??""))}catch{}if(await I$("link",null,$,{perIp:Z.config.emailCode.verifyLimit.perIp}),!T||!j||!await Z.verifyMagicLinkToken(T,j))return{error:"Invalid token"};await O.verifyUser(T);let z=await Z.createOrUpdateSession({email:T});return $.ctx().setCookie("access_token",z.token,C(A).accessTokenCookieOptions($,z.expiresAt)),await Z.config.onSignIn(z,$.search.toJSON()),await W$(Z.config,{session:z,isNewUser:!1,method:"magic-link",req:$}),{session:z}}async verifyPinRequest($){let Z=C(A),O=await $.input(),{email:j,pin:T}=O.toJSON(),z=XZ(j),J=I7(T);if(await I$("verify",z,$,Z.config.emailCode.verifyLimit),!z||!J)throw new y({pin:["Invalid pin"]});let W=await Z.verifyOneTimeCode(z,J);if(W.status==="too_many_attempts")throw new y({pin:["Too many attempts"]});if(W.status!=="ok")throw new y({pin:["Invalid pin"]});return await Z.userProvider.verifyUser(z),z}async signInWithPinV2($=new _){let Z=C(A),O=await this.verifyPinRequest($),j=await Z.createOrUpdateSessionV2({email:O});return $.ctx().setCookie("access_token",j.token,C(A).accessTokenCookieOptions($,j.expiresAt)),await Z.config.onSignIn(j,$.search.toJSON()),await W$(Z.config,{session:j,isNewUser:!1,method:"magic-link",req:$}),j}async signInWithPin($=new _){let Z=C(A),O=await this.verifyPinRequest($),j=await Z.createOrUpdateSession({email:O});return $.ctx().setCookie("access_token",j.token,C(A).accessTokenCookieOptions($,j.expiresAt)),await Z.config.onSignIn(j,$.search.toJSON()),await W$(Z.config,{session:j,isNewUser:!1,method:"magic-link",req:$}),{session:j}}async signInV2($=new k6){let Z=await $.input(),{email:O,password:j}=Z.toJSON(),T=O.toLowerCase().trim(),z=C(A),J=await z.userProvider.findUserByEmailAddress(T,z.config.verifyEmail),W=typeof j==="string"&&await v6(z.config,j,J?.password);if(!J||!W)throw new y({invalid_credentials:["Invalid credentials"]});let Y=await z.createOrUpdateSessionV2({email:J.email,id:J.id});$.ctx().setCookie("access_token",Y.token,C(A).accessTokenCookieOptions($,Y.expiresAt)),await z.config.onSignIn(J,$.search.toJSON()),await W$(z.config,{session:Y,user:J,isNewUser:!1,method:"password",req:$});let{password:X,...D}=J;return D}async signIn($=new k6){let Z=await $.input(),{email:O,password:j}=Z.toJSON(),T=O.toLowerCase().trim(),z=C(A),J=await z.userProvider.findUserByEmailAddress(T,z.config.verifyEmail),W=typeof j==="string"&&await v6(z.config,j,J?.password);if(!J||!W)throw new y({invalid_credentials:["Invalid credentials"]});let Y=await z.createOrUpdateSession({email:J.email,id:J.id});$.ctx().setCookie("access_token",Y.token,C(A).accessTokenCookieOptions($,Y.expiresAt)),await z.config.onSignIn(J,$.search.toJSON()),await W$(z.config,{session:Y,user:J,isNewUser:!1,method:"password",req:$});let{password:X,...D}=J;return D}async signUp(){let $=C(A),{userProvider:Z,config:O}=$,j=new O.signUpRequest,T=await j.input(),{email:z,password:J,name:W,invitationId:Y}=T.toJSON(),X=V7(z);if(!X)throw new y({email:["Invalid email"]});if(J!=null&&typeof J!=="string")throw new y({password:["Invalid password"]});if(Y!=null&&typeof Y!=="string")throw new y({invitationId:["Invalid invitation"]});if(await Z.findUserByEmailAddress(X,!1))throw new y({email:["Email address already exists"]});let U=await O.hashPassword(J),F=C(u).detectLocale(j),B;if(Y)B=await Z.findInvitation(Y,X);let G,K="";if(B)G=await Z.transaction(async()=>{await Z.deleteInvitationById(Y);let Q=await Z.createUser({email:X,name:W,password:U,emailVerifiedAt:new Date,locale:F});return await Z.createAccount({organizationId:B.organizationId,userId:Q.id,organizationRole:B.role}),await O.onUserCreated(Q),Q});else K=await O.generateEmailVerificationToken(X),G=await Z.transaction(async()=>{let Q=await Z.createUser({email:X,name:W,password:U,verificationToken:K,locale:F});return await O.onUserCreated(Q),Q});return await O.onSignUp(G,K,j.search.toJSON()),G}async signOut($=new _){let Z=i3($),O=C(A),{config:j}=O,T=await O.revokeSession(Z,$.headers.get("User-Agent"));if($.ctx().setCookie("access_token","",C(A).accessTokenCookieOptions($,new Date(0))),C(A).cookieDomain($))$.ctx().setCookie("access_token","",{...C(A).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(T?.user)T.user.extension=await j.extendSession(T.user),await j.onSignOut(T.user);return{}}async forgotPassword($=new L7){let Z=await $.input(),O=V7(Z.get("email"));if(!O)return{};let{userProvider:j,config:T}=C(A),z=await j.findUserByEmailAddress(O,T.verifyEmail);if(!z)return{};let J=await T.generateForgotPasswordToken(z);return await j.createPasswordResetToken({user:z,token:J}),await T.onForgotPassword(z,J),{}}async resetPassword($=new M7){let{userProvider:Z,config:O}=C(A),j=await $.input(),{password:T,token:z}=j.toJSON(),J=w6(z),W=J?await Z.findPasswordResetToken({token:J}):null;if(!W)throw new y({token:["Invalid token"]});if(i$.Instant.from(W.createdAt.toISOString()).add({hours:24}).until(i$.Now.instant()).sign>=0)throw new y({token:["Token expired"]});await Z.deletePasswordResetToken({token:J});let X=await Z.findUserByEmailAddress(W.user.email,O.verifyEmail);if(!X)throw new y({email:["User not found"]});let D=await O.hashPassword(T);return await Z.updateUserPassword({id:X.id,password:D}),await Z.deleteAllUserSessions(X.id),await O.onResetPassword(X),{}}async changePassword($=new _){let{userProvider:Z,config:O}=C(A),j=await Y$.user(),T=await $.input(),{oldPassword:z,newPassword:J}=T.toJSON();if(typeof J!=="string")throw new y({newPassword:["Invalid password"]});let W=await Z.findUserByEmailAddress(j.email,O.verifyEmail);if(!(typeof z==="string"&&await v6(O,z,W?.password)))throw new y({oldPassword:["Incorrect password"]});let X=await O.hashPassword(J);return await Z.updateUserPassword({id:j.id,password:X}),await Z.deleteAllUserSessions(j.id),{}}async oauthRedirect($=new _){let{provider:Z}=$.params,O=C(A).config.oauthProviders[Z];if(!O)throw Error(`Invalid provider: ${Z}`);let j=zZ($.search.get(f$),"");if(j)$.ctx().setCookie(R6,encodeURIComponent(j),{httpOnly:!0,sameSite:"Lax",secure:d4($.rawRequest),maxAge:600});return{destination:await O.getRedirectUrl($)}}async oauthCallback($=new _){let{provider:Z}=$.params,O=C(A),{userProvider:j,config:T}=O,z=T.oauthProviders[Z],{email:J,name:W,username:Y,providerId:X}=await z.onCallback($),D=X?await j.findUserBySocialAccount(Z,X):null,U="signin";if(!D){if(!J)return console.error("Authentication error: No email returned from OAuth provider callback"),{session:null};let K=C(u).detectLocale($);try{let Q=await this.linkOAuthAccount({provider:Z,providerId:X,email:J,name:W,username:Y,locale:K});if(Q)D=Q.user,U=Q.action}catch(Q){let f=X?await j.findUserBySocialAccount(Z,X):null;if(!f)throw Q;D=f}if(!D)return{session:null}}let F=await O.createOrUpdateSessionV2({email:D.email,id:D.id});if($.ctx().setCookie("access_token",F.token,C(A).accessTokenCookieOptions($,F.expiresAt)),U==="signup")await T.onSignUp(D,"",$.search.toJSON());else await T.onSignIn(D,$.search.toJSON());await W$(O.config,{session:F,user:D,isNewUser:U==="signup",method:"oauth",req:$});let B=$.cookies.get(R6),G=T.redirectPath;if(B){try{G=zZ(decodeURIComponent(B),G)}catch{}$.ctx().setCookie(R6,"",{maxAge:-1})}return{session:F,redirectTo:G}}async linkOAuthAccount($){let{provider:Z,providerId:O,email:j,name:T,username:z,locale:J}=$,{userProvider:W,config:Y}=C(A),X=(F)=>({provider:Z,userId:F,email:j,username:z,providerId:O,expiresAt:new Date,accessToken:"",refreshToken:""}),D=await W.findUserByEmailAddress(j,!1);if(D){if(!O)return{user:D,action:"signin"};let F=await W.findSocialAccounts(D.id,Z);if(F.some((G)=>G.providerId===O))return{user:D,action:"signin"};if(F.some((G)=>G.providerId))return console.error(`Authentication error: user ${D.id} is already linked to a different ${Z} account`),null;let B=F[0];if(B){if(!await W.claimSocialAccount(B,O))throw Error(`${Z} account link changed concurrently`)}else await W.createSocialAccount(X(D.id));return{user:D,action:"signin"}}return{user:await W.transaction(async()=>{let F=await W.createUser({email:j,name:T,locale:J,emailVerifiedAt:new Date});if(O)await W.createSocialAccount(X(F.id));return await Y.onUserCreated(F),F}),action:"signup"}}async createMagicLinkToken($=new _){let Z=await $.input(),O=XZ(Z.get("email")),j=C(A),{uniformMagicLinkResponse:T,requestLimit:z}=j.config.emailCode;if(await I$("request",O,$,z),!O)return{email:null};let{user:J,pin:W,token:Y}=await j.createMagicLinkToken(O);if(J)return await j.config.onMagicLinkCreated(J,{email:O,pin:W,token:Y}),{email:O};return{email:T?O:null}}async requestEmailCode($=new _){let Z=C(A),O=Z.config.emailCode;if(!O.enabled)throw new a0("Not found",{status:404});let j=await $.input(),T=Zj(j.get("email"));if(await I$("request",T,$,O.requestLimit),!T)throw new y({email:["Invalid email"]});let z=await Z.userProvider.findUserByEmailAddress(T,!1);if(z||O.createUser){let{pin:J,token:W}=await Z.issueOneTimeCode(T,O.length);await O.send({email:T,code:J,token:W,isNewUser:!z,req:$})}return{ok:!0}}async verifyEmailCode($=new _){let Z=C(A),{userProvider:O,config:j}=Z;if(!j.emailCode.enabled)throw new a0("Not found",{status:404});let T=await $.input(),{email:z,code:J,name:W}=T.toJSON(),Y=Zj(z),X=I7(J);if(await I$("verify",Y,$,j.emailCode.verifyLimit),!Y||!X)throw new y({code:["invalid_code"]});let D=await Z.verifyOneTimeCode(Y,X,{claim:!1});if(D.status==="too_many_attempts")throw new y({code:["too_many_attempts"]});if(D.status!=="ok")throw new y({code:["invalid_code"]});let U=D.row,F=await O.findUserByEmailAddress(Y,!1),B=!1;if(F){if(!await O.claimMagicLinkToken(U.id))throw new y({code:["invalid_code"]});await O.verifyUser(Y)}else if(j.emailCode.createUser){let K=C(u).detectLocale($);try{F=await O.transaction(async()=>{if(!await O.claimMagicLinkToken(U.id))throw new q6;let Q=await O.createUser({email:Y,name:typeof W==="string"?W.trim():"",emailVerifiedAt:new Date,locale:K});return await j.onUserCreated(Q),Q}),B=!0}catch(Q){if(Q instanceof q6)throw new y({code:["invalid_code"]});throw Q}}else throw await O.claimMagicLinkToken(U.id),new y({code:["invalid_code"]});let G=await Z.createOrUpdateSessionV2({email:Y,id:F.id});return $.ctx().setCookie("access_token",G.token,C(A).accessTokenCookieOptions($,G.expiresAt)),await j.onSignIn(G,$.search.toJSON()),await W$(Z.config,{session:G,isNewUser:B,method:"email-code",req:$}),{session:G,isNewUser:B}}}class S7 extends V1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[d,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[d,"oauthCallback"])}}class g6 extends V1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[d,"signInWithMagicLink"]),"/oauth":S7}}class y6 extends N0{middlewares=["cache:private"];routes={"/sign-in":this.post(d,"signIn"),"/sign-in-v2":this.post(d,"signInV2"),"/sign-up":this.post(d,"signUp"),"/sign-out":this.post(d,"signOut"),"/forgot-password":this.post(d,"forgotPassword"),"/reset-password":this.post(d,"resetPassword"),"/change-password":this.post(d,"changePassword"),"/verify-email":this.post(d,"verifyEmail"),"/me":this.get(d,"me").middleware(["auth"]),"/magic-link":this.post(d,"createMagicLinkToken"),"/sign-in-with-pin":this.post(d,"signInWithPin"),"/sign-in-with-pin-v2":this.post(d,"signInWithPinV2"),"/email-code":this.post(d,"requestEmailCode"),"/email-code/verify":this.post(d,"verifyEmailCode")}}class m6 extends N0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let Z=new _().params.locale;return await C(u).onLocaleChange(Z),{locale:Z}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new _,Z=`/${$.params.scope??""}`,O=$.params.locale,j=C(u),T=O??j.detectLocale($),z=j.getPageTranslations(T,Z);return $.ctx().setCookie("i18n-locale",T,{expires:new Date(Date.now()+31536000000)}),{[T]:z}})}}class p6{}class h6 extends p6{async resize($,Z){let{height:O,width:j,quality:T,fit:z}=Z;return await(await I3("The Sharp image optimization driver"))($).resize(j>0?j:void 0,O>0?O:void 0,{fit:z}).webp({quality:T>0?T:80,force:!0}).toBuffer()}}function $G($){return $}function N7(){return{driver:new h6}}class c6 extends N0{routes={"/resize":this.file(async()=>{let $=new _,Z=new URL($.rawRequest.url),O=Z.searchParams.get("url"),j=Number(Z.searchParams.get("w")),T=Number(Z.searchParams.get("h")),z=Z.searchParams.get("fit")??"cover",J=Number(Z.searchParams.get("q"));if(!O)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let Y=`${O.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${O}`,X=await fetch(Y);if(!X.ok)return new Response(JSON.stringify({error:"Image not found",info:Y}),{headers:{"Content-Type":"application/json"},status:404});let D=Buffer.from(await X.arrayBuffer()),U=await C(_7).resize(D,{height:T,width:j,fit:z,quality:J});X.headers.delete("Content-Type"),X.headers.delete("Content-Length");let F=new Headers(X.headers);return F.set("Content-Type","image/webp"),F.set("Content-Length",`${U.byteLength}`),new Response(new Uint8Array(U),{headers:F})})}}class _7{static token="image";driver;constructor($={}){this.driver=$.driver??N7().driver}resize($,Z){return this.driver.resize($,Z)}}class l6 extends N0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(C(x7).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function YX($){let Z=new Map;for(let O of $)if(typeof O==="string"){let[j,T=""]=O.split(":");if(j.startsWith("-")){if(Z.has(j.replace("-","")))Z.delete(j.replace("-",""))}else Z.set(j,T.split(",").filter(Boolean))}else Z.set(O,[]);return Z}class cZ{config;static token="middleware";constructor($){this.config=$}get aliases(){return this.config.aliases}assertGlobalMiddleware(){for(let $ of this.config.global){if(typeof $!=="string")continue;let[Z]=$.split(":");if(Z.startsWith("-"))throw Error(`Global middleware "${$}" cancels an alias, but nothing is inherited into the global list. Remove it.`);if(!this.aliases[Z])throw Error(`Global middleware "${Z}" is not a registered alias. Add it to \`aliases\` in the middleware config, or list the class itself.`)}}runGlobalMiddleware(){return this.runMiddleware(this.config.global)}runMiddleware($){let Z=new _;return Array.from(YX($).entries()).map(([O,j])=>{if(typeof O==="string"){let T=this.aliases[O];if(T){let z=new T(Z);return()=>z.run.call(z,...j)}}else{if(tZ(O)){let T=new O(Z);return T.run.bind(T)}return O}}).filter(Boolean).reduce((O,j)=>{return async()=>{return{...await O(),...await j()}}},()=>Promise.resolve({}))()}}function BG($){return $}function P7(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function E7(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function XX($){return"run"in $}function DX($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"patch")||Object.hasOwn($,"delete")}function FX($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function UX($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function GX($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function A7($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function d6($,Z="",O=[]){let j={};function T(z,J,W,Y,X){let D=z==="/"?"":z,U=Z==="/"?"":Z,F=(`${U}${D}`===""?"/":`${U}${D}`).replaceAll("//","/");if(!j[F])j[F]={};j[F][J.toUpperCase()]={exec:W,middleware:[...O,...Y],...X?{source:X}:{}},j[F].OPTIONS={exec:()=>{let G=new _().ctx().headers;return new Response(null,{headers:G,status:204})},middleware:[]}}for(let[z,J]of Object.entries($)){if(GX(J)){let W=J;for(let Y of["GET","POST","PUT","DELETE"])T(z,Y,W.run.bind(W),W.middlewares);continue}if(XX(J)){let W=J,Y=W.method,X=W.middlewares,D=W.run.bind(W);if(T(z,Y,D,X,W.source),A7(J))T(z,"HEAD",D,X,W.source)}if(DX(J))for(let[W,Y]of Object.entries(J)){let X=Y,D=X.middlewares,U=X.run.bind(X);if(T(z,W,U,D,X.source),W==="get"&&A7(X))T(z,"HEAD",U,D,X.source)}if(UX(J)){let W=new J,Y=d6(W.routes,`${Z}${z}`,W.middlewares);for(let[X,D]of Object.entries(Y))j[X.replaceAll("//","/")]=D}if(FX(J)){let{first:W,second:Y}=J;for(let[X,D]of Object.entries(W)){let U=D.middlewares,F=D.run.bind(D),[B,...G]=z.split("/").reverse();if(!B.startsWith(":"))throw Error("Resource route must end with a dynamic segment");T(G.reverse().join("/"),X,F,U,D.source)}for(let[X,D]of Object.entries(Y)){let U=D.middlewares,F=D.run.bind(D);T(z,X,F,U,D.source)}}}return Object.fromEntries(Object.entries(j).sort(([z],[J])=>{let W=z.split("/").length+z.split(":").length,Y=J.split("/").length+J.split(":").length;return W-Y}))}function L3($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function i6($,Z){if($==="/")return Z;if(Z==="/")return $;return`${$}${Z}`}function u6($){let Z=L3($);return Z.length>1?Z.replace(/\/$/,""):Z}function H7($,Z){return Z.map((O)=>({...O,path:u6(i6($,O.path))}))}function M3($){let Z={};for(let[O,j]of Object.entries($))if("run"in j){let T=j;if("children"in T){let z=new T.children,J=M3(z.routes);for(let[W,{exec:Y,middleware:X,segments:D,features:U}]of Object.entries(J)){let F=i6(O,W),B=(G)=>T.run.call(T,G,O);Z[L3(F)]={exec:[B,...Y],middleware:[...T.middlewares,...X],features:[...T.featureGates,...U],viewPath:T.viewPath,segments:[{path:u6(O),viewPath:T.viewPath,...T.alwaysRuns?{alwaysRun:!0}:{}},...H7(O,D)]}}}else{let z=(J)=>T.run.call(T,J,O);Z[L3(O)]={exec:[z],middleware:T.middlewares,features:T.featureGates,viewPath:T.viewPath,segments:[{path:u6(O),viewPath:T.viewPath}]}}}else{let T=new j,z=M3(T.routes);for(let[J,{exec:W,middleware:Y,viewPath:X,segments:D,features:U}]of Object.entries(z)){let F=i6(O,J);Z[L3(F)]={exec:W,middleware:[...T.middlewares,...Y],features:[...T.featureGates,...U],viewPath:X,segments:H7(O,D)}}}return Object.fromEntries(Object.entries(Z).sort(([O],[j])=>{let T=O.split("/").length+O.split(":").length,z=j.split("/").length+j.split(":").length;return T-z}))}var BX=Object.defineProperty,S=($,Z)=>BX($,"name",{value:Z,configurable:!0}),n$=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,Z,O,j,T,z){this.type=$,this.name=Z,this.prefix=O,this.value=j,this.suffix=T,this.modifier=z}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};S(n$,"Part");var KX=/[$_\p{ID_Start}]/u,QX=/[$_\u200C\u200D\p{ID_Continue}]/u,n6=".*";function b7($,Z){return(Z?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}S(b7,"isASCII");function r6($,Z=!1){let O=[],j=0;for(;j<$.length;){let T=$[j],z=S(function(J){if(!Z)throw TypeError(J);O.push({type:"INVALID_CHAR",index:j,value:$[j++]})},"ErrorOrInvalid");if(T==="*"){O.push({type:"ASTERISK",index:j,value:$[j++]});continue}if(T==="+"||T==="?"){O.push({type:"OTHER_MODIFIER",index:j,value:$[j++]});continue}if(T==="\\"){O.push({type:"ESCAPED_CHAR",index:j++,value:$[j++]});continue}if(T==="{"){O.push({type:"OPEN",index:j,value:$[j++]});continue}if(T==="}"){O.push({type:"CLOSE",index:j,value:$[j++]});continue}if(T===":"){let J="",W=j+1;for(;W<$.length;){let Y=$.substr(W,1);if(W===j+1&&KX.test(Y)||W!==j+1&&QX.test(Y)){J+=$[W++];continue}break}if(!J){z(`Missing parameter name at ${j}`);continue}O.push({type:"NAME",index:j,value:J}),j=W;continue}if(T==="("){let J=1,W="",Y=j+1,X=!1;if($[Y]==="?"){z(`Pattern cannot start with "?" at ${Y}`);continue}for(;Y<$.length;){if(!b7($[Y],!1)){z(`Invalid character '${$[Y]}' at ${Y}.`),X=!0;break}if($[Y]==="\\"){W+=$[Y++]+$[Y++];continue}if($[Y]===")"){if(J--,J===0){Y++;break}}else if($[Y]==="("&&(J++,$[Y+1]!=="?")){z(`Capturing groups are not allowed at ${Y}`),X=!0;break}W+=$[Y++]}if(X)continue;if(J){z(`Unbalanced pattern at ${j}`);continue}if(!W){z(`Missing pattern at ${j}`);continue}O.push({type:"REGEX",index:j,value:W}),j=Y;continue}O.push({type:"CHAR",index:j,value:$[j++]})}return O.push({type:"END",index:j,value:""}),O}S(r6,"lexer");function t6($,Z={}){let O=r6($);Z.delimiter??="/#?",Z.prefixes??="./";let j=`[^${b0(Z.delimiter)}]+?`,T=[],z=0,J=0,W="",Y=new Set,X=S((V)=>{if(J<O.length&&O[J].type===V)return O[J++].value},"tryConsume"),D=S(()=>X("OTHER_MODIFIER")??X("ASTERISK"),"tryConsumeModifier"),U=S((V)=>{let x=X(V);if(x!==void 0)return x;let{type:P,index:I}=O[J];throw TypeError(`Unexpected ${P} at ${I}, expected ${V}`)},"mustConsume"),F=S(()=>{let V="",x;for(;x=X("CHAR")??X("ESCAPED_CHAR");)V+=x;return V},"consumeText"),B=S((V)=>V,"DefaultEncodePart"),G=Z.encodePart||B,K="",Q=S((V)=>{K+=V},"appendToPendingFixedValue"),f=S(()=>{K.length&&(T.push(new n$(3,"","",G(K),"",3)),K="")},"maybeAddPartFromPendingFixedValue"),L=S((V,x,P,I,M)=>{let E=3;switch(M){case"?":E=1;break;case"*":E=0;break;case"+":E=2;break}if(!x&&!P&&E===3){Q(V);return}if(f(),!x&&!P){if(!V)return;T.push(new n$(3,"","",G(V),"",E));return}let H;P?P==="*"?H=n6:H=P:H=j;let j0=2;H===j?(j0=1,H=""):H===n6&&(j0=0,H="");let R;if(x?R=x:P&&(R=z++),Y.has(R))throw TypeError(`Duplicate name '${R}'.`);Y.add(R),T.push(new n$(j0,R,G(V),H,G(I),E))},"addPart");for(;J<O.length;){let V=X("CHAR"),x=X("NAME"),P=X("REGEX");if(!x&&!P&&(P=X("ASTERISK")),x||P){let M=V??"";Z.prefixes.indexOf(M)===-1&&(Q(M),M=""),f();let E=D();L(M,x,P,"",E);continue}let I=V??X("ESCAPED_CHAR");if(I){Q(I);continue}if(X("OPEN")){let M=F(),E=X("NAME"),H=X("REGEX");!E&&!H&&(H=X("ASTERISK"));let j0=F();U("CLOSE");let R=D();L(M,E,H,j0,R);continue}f(),U("END")}return T}S(t6,"parse");function b0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}S(b0,"escapeString");function a6($){return $&&$.ignoreCase?"ui":"u"}S(a6,"flags");function v7($,Z,O){return e6(t6($,O),Z,O)}S(v7,"stringToRegexp");function X$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}S(X$,"modifierToString");function e6($,Z,O={}){O.delimiter??="/#?",O.prefixes??="./",O.sensitive??=!1,O.strict??=!1,O.end??=!0,O.start??=!0,O.endsWith="";let j=O.start?"^":"";for(let W of $){if(W.type===3){W.modifier===3?j+=b0(W.value):j+=`(?:${b0(W.value)})${X$(W.modifier)}`;continue}Z&&Z.push(W.name);let Y=`[^${b0(O.delimiter)}]+?`,X=W.value;if(W.type===1?X=Y:W.type===0&&(X=n6),!W.prefix.length&&!W.suffix.length){W.modifier===3||W.modifier===1?j+=`(${X})${X$(W.modifier)}`:j+=`((?:${X})${X$(W.modifier)})`;continue}if(W.modifier===3||W.modifier===1){j+=`(?:${b0(W.prefix)}(${X})${b0(W.suffix)})`,j+=X$(W.modifier);continue}j+=`(?:${b0(W.prefix)}`,j+=`((?:${X})(?:`,j+=b0(W.suffix),j+=b0(W.prefix),j+=`(?:${X}))*)${b0(W.suffix)})`,W.modifier===0&&(j+="?")}let T=`[${b0(O.endsWith)}]|$`,z=`[${b0(O.delimiter)}]`;if(O.end)return O.strict||(j+=`${z}?`),O.endsWith.length?j+=`(?=${T})`:j+="$",new RegExp(j,a6(O));O.strict||(j+=`(?:${z}(?=${T}))?`);let J=!1;if($.length){let W=$[$.length-1];W.type===3&&W.modifier===3&&(J=O.delimiter.indexOf(W)>-1)}return J||(j+=`(?=${z}|${T})`),new RegExp(j,a6(O))}S(e6,"partsToRegexp");var y1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},CX={delimiter:".",prefixes:"",sensitive:!0,strict:!0},fX={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function w7($,Z){return $.length?$[0]==="/"?!0:!Z||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}S(w7,"isAbsolutePathname");function $4($,Z){return $.startsWith(Z)?$.substring(Z.length,$.length):$}S($4,"maybeStripPrefix");function R7($,Z){return $.endsWith(Z)?$.substr(0,$.length-Z.length):$}S(R7,"maybeStripSuffix");function Z4($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}S(Z4,"treatAsIPv6Hostname");var q7=["ftp","file","http","https","ws","wss"];function O4($){if(!$)return!0;for(let Z of q7)if($.test(Z))return!0;return!1}S(O4,"isSpecialScheme");function k7($,Z){if($=$4($,"#"),Z||$==="")return $;let O=new URL("https://example.com");return O.hash=$,O.hash?O.hash.substring(1,O.hash.length):""}S(k7,"canonicalizeHash");function g7($,Z){if($=$4($,"?"),Z||$==="")return $;let O=new URL("https://example.com");return O.search=$,O.search?O.search.substring(1,O.search.length):""}S(g7,"canonicalizeSearch");function y7($,Z){return Z||$===""?$:Z4($)?z4($):T4($)}S(y7,"canonicalizeHostname");function m7($,Z){if(Z||$==="")return $;let O=new URL("https://example.com");return O.password=$,O.password}S(m7,"canonicalizePassword");function p7($,Z){if(Z||$==="")return $;let O=new URL("https://example.com");return O.username=$,O.username}S(p7,"canonicalizeUsername");function h7($,Z,O){if(O||$==="")return $;if(Z&&!q7.includes(Z))return new URL(`${Z}:${$}`).pathname;let j=$[0]=="/";return $=new URL(j?$:"/-"+$,"https://example.com").pathname,j||($=$.substring(2,$.length)),$}S(h7,"canonicalizePathname");function c7($,Z,O){return j4(Z)===$&&($=""),O||$===""?$:J4($)}S(c7,"canonicalizePort");function l7($,Z){return $=R7($,":"),Z||$===""?$:S3($)}S(l7,"canonicalizeProtocol");function j4($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}S(j4,"defaultPortForProtocol");function S3($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}S(S3,"protocolEncodeCallback");function d7($){if($==="")return $;let Z=new URL("https://example.com");return Z.username=$,Z.username}S(d7,"usernameEncodeCallback");function i7($){if($==="")return $;let Z=new URL("https://example.com");return Z.password=$,Z.password}S(i7,"passwordEncodeCallback");function T4($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let Z=new URL("https://example.com");return Z.hostname=$,Z.hostname}S(T4,"hostnameEncodeCallback");function z4($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}S(z4,"ipv6HostnameEncodeCallback");function J4($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}S(J4,"portEncodeCallback");function u7($){if($==="")return $;let Z=new URL("https://example.com");return Z.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?Z.pathname.substring(2,Z.pathname.length):Z.pathname}S(u7,"standardURLPathnameEncodeCallback");function s7($){return $===""?$:new URL(`data:${$}`).pathname}S(s7,"pathURLPathnameEncodeCallback");function n7($){if($==="")return $;let Z=new URL("https://example.com");return Z.search=$,Z.search.substring(1,Z.search.length)}S(n7,"searchEncodeCallback");function a7($){if($==="")return $;let Z=new URL("https://example.com");return Z.hash=$,Z.hash.substring(1,Z.hash.length)}S(a7,"hashEncodeCallback");var o7=class{#z;#j=[];#Z={};#$=0;#T=1;#X=0;#W=0;#G=0;#B=0;#K=!1;constructor($){this.#z=$}get result(){return this.#Z}parse(){for(this.#j=r6(this.#z,!0);this.#$<this.#j.length;this.#$+=this.#T){if(this.#T=1,this.#j[this.#$].type==="END"){if(this.#W===0){this.#V(),this.#D()?this.#O(9,1):this.#F()?this.#O(8,1):this.#O(7,0);continue}else if(this.#W===2){this.#U(5);continue}this.#O(10,0);break}if(this.#G>0)if(this.#x())this.#G-=1;else continue;if(this.#_()){this.#G+=1;continue}switch(this.#W){case 0:this.#I()&&this.#U(1);break;case 1:if(this.#I()){this.#A();let $=7,Z=1;this.#M()?($=2,Z=3):this.#K&&($=2),this.#O($,Z)}break;case 2:this.#C()?this.#U(3):(this.#f()||this.#F()||this.#D())&&this.#U(5);break;case 3:this.#S()?this.#O(4,1):this.#C()&&this.#O(5,1);break;case 4:this.#C()&&this.#O(5,1);break;case 5:this.#P()?this.#B+=1:this.#E()&&(this.#B-=1),this.#N()&&!this.#B?this.#O(6,1):this.#f()?this.#O(7,0):this.#F()?this.#O(8,1):this.#D()&&this.#O(9,1);break;case 6:this.#f()?this.#O(7,0):this.#F()?this.#O(8,1):this.#D()&&this.#O(9,1);break;case 7:this.#F()?this.#O(8,1):this.#D()&&this.#O(9,1);break;case 8:this.#D()&&this.#O(9,1);break;case 9:break;case 10:break}}this.#Z.hostname!==void 0&&this.#Z.port===void 0&&(this.#Z.port="")}#O($,Z){switch(this.#W){case 0:break;case 1:this.#Z.protocol=this.#Y();break;case 2:break;case 3:this.#Z.username=this.#Y();break;case 4:this.#Z.password=this.#Y();break;case 5:this.#Z.hostname=this.#Y();break;case 6:this.#Z.port=this.#Y();break;case 7:this.#Z.pathname=this.#Y();break;case 8:this.#Z.search=this.#Y();break;case 9:this.#Z.hash=this.#Y();break;case 10:break}this.#W!==0&&$!==10&&([1,2,3,4].includes(this.#W)&&[6,7,8,9].includes($)&&(this.#Z.hostname??=""),[1,2,3,4,5,6].includes(this.#W)&&[8,9].includes($)&&(this.#Z.pathname??=this.#K?"/":""),[1,2,3,4,5,6,7].includes(this.#W)&&$===9&&(this.#Z.search??="")),this.#L($,Z)}#L($,Z){this.#W=$,this.#X=this.#$+Z,this.#$+=Z,this.#T=0}#V(){this.#$=this.#X,this.#T=0}#U($){this.#V(),this.#W=$}#Q($){return $<0&&($=this.#j.length-$),$<this.#j.length?this.#j[$]:this.#j[this.#j.length-1]}#J($,Z){let O=this.#Q($);return O.value===Z&&(O.type==="CHAR"||O.type==="ESCAPED_CHAR"||O.type==="INVALID_CHAR")}#I(){return this.#J(this.#$,":")}#M(){return this.#J(this.#$+1,"/")&&this.#J(this.#$+2,"/")}#C(){return this.#J(this.#$,"@")}#S(){return this.#J(this.#$,":")}#N(){return this.#J(this.#$,":")}#f(){return this.#J(this.#$,"/")}#F(){if(this.#J(this.#$,"?"))return!0;if(this.#j[this.#$].value!=="?")return!1;let $=this.#Q(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#D(){return this.#J(this.#$,"#")}#_(){return this.#j[this.#$].type=="OPEN"}#x(){return this.#j[this.#$].type=="CLOSE"}#P(){return this.#J(this.#$,"[")}#E(){return this.#J(this.#$,"]")}#Y(){let $=this.#j[this.#$],Z=this.#Q(this.#X).index;return this.#z.substring(Z,$.index)}#A(){let $={};Object.assign($,y1),$.encodePart=S3;let Z=v7(this.#Y(),void 0,$);this.#K=O4(Z)}};S(o7,"Parser");var s6=["protocol","username","password","hostname","port","pathname","search","hash"],g1="*";function o6($,Z){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let O=new URL($,Z);return{protocol:O.protocol.substring(0,O.protocol.length-1),username:O.username,password:O.password,hostname:O.hostname,port:O.port,pathname:O.pathname,search:O.search!==""?O.search.substring(1,O.search.length):void 0,hash:O.hash!==""?O.hash.substring(1,O.hash.length):void 0}}S(o6,"extractValues");function T1($,Z){return Z?s$($):$}S(T1,"processBaseURLString");function u$($,Z,O){let j;if(typeof Z.baseURL=="string")try{j=new URL(Z.baseURL),Z.protocol===void 0&&($.protocol=T1(j.protocol.substring(0,j.protocol.length-1),O)),!O&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&($.username=T1(j.username,O)),!O&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&Z.password===void 0&&($.password=T1(j.password,O)),Z.protocol===void 0&&Z.hostname===void 0&&($.hostname=T1(j.hostname,O)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&($.port=T1(j.port,O)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&($.pathname=T1(j.pathname,O)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&($.search=T1(j.search.substring(1,j.search.length),O)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&Z.hash===void 0&&($.hash=T1(j.hash.substring(1,j.hash.length),O))}catch{throw TypeError(`invalid baseURL '${Z.baseURL}'.`)}if(typeof Z.protocol=="string"&&($.protocol=l7(Z.protocol,O)),typeof Z.username=="string"&&($.username=p7(Z.username,O)),typeof Z.password=="string"&&($.password=m7(Z.password,O)),typeof Z.hostname=="string"&&($.hostname=y7(Z.hostname,O)),typeof Z.port=="string"&&($.port=c7(Z.port,$.protocol,O)),typeof Z.pathname=="string"){if($.pathname=Z.pathname,j&&!w7($.pathname,O)){let T=j.pathname.lastIndexOf("/");T>=0&&($.pathname=T1(j.pathname.substring(0,T+1),O)+$.pathname)}$.pathname=h7($.pathname,$.protocol,O)}return typeof Z.search=="string"&&($.search=g7(Z.search,O)),typeof Z.hash=="string"&&($.hash=k7(Z.hash,O)),$}S(u$,"applyInit");function s$($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}S(s$,"escapePatternString");function r7($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}S(r7,"escapeRegexpString");function t7($,Z){Z.delimiter??="/#?",Z.prefixes??="./",Z.sensitive??=!1,Z.strict??=!1,Z.end??=!0,Z.start??=!0,Z.endsWith="";let O=".*",j=`[^${r7(Z.delimiter)}]+?`,T=/[$_\u200C\u200D\p{ID_Continue}]/u,z="";for(let J=0;J<$.length;++J){let W=$[J];if(W.type===3){if(W.modifier===3){z+=s$(W.value);continue}z+=`{${s$(W.value)}}${X$(W.modifier)}`;continue}let Y=W.hasCustomName(),X=!!W.suffix.length||!!W.prefix.length&&(W.prefix.length!==1||!Z.prefixes.includes(W.prefix)),D=J>0?$[J-1]:null,U=J<$.length-1?$[J+1]:null;if(!X&&Y&&W.type===1&&W.modifier===3&&U&&!U.prefix.length&&!U.suffix.length)if(U.type===3){let F=U.value.length>0?U.value[0]:"";X=T.test(F)}else X=!U.hasCustomName();if(!X&&!W.prefix.length&&D&&D.type===3){let F=D.value[D.value.length-1];X=Z.prefixes.includes(F)}X&&(z+="{"),z+=s$(W.prefix),Y&&(z+=`:${W.name}`),W.type===2?z+=`(${W.value})`:W.type===1?Y||(z+=`(${j})`):W.type===0&&(!Y&&(!D||D.type===3||D.modifier!==3||X||W.prefix!=="")?z+="*":z+=`(${O})`),W.type===1&&Y&&W.suffix.length&&T.test(W.suffix[0])&&(z+="\\"),z+=s$(W.suffix),X&&(z+="}"),W.modifier!==3&&(z+=X$(W.modifier))}return z}S(t7,"partsToPattern");var W4=class{#z;#j={};#Z={};#$={};#T={};#X=!1;constructor($={},Z,O){try{let j;if(typeof Z=="string"?j=Z:O=Z,typeof $=="string"){let W=new o7($);if(W.parse(),$=W.result,j===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=j}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(j)throw TypeError("parameter 1 is not of type 'string'.")}typeof O>"u"&&(O={ignoreCase:!1});let T={ignoreCase:O.ignoreCase===!0},z={pathname:g1,protocol:g1,username:g1,password:g1,hostname:g1,port:g1,search:g1,hash:g1};this.#z=u$(z,$,!0),j4(this.#z.protocol)===this.#z.port&&(this.#z.port="");let J;for(J of s6){if(!(J in this.#z))continue;let W={},Y=this.#z[J];switch(this.#Z[J]=[],J){case"protocol":Object.assign(W,y1),W.encodePart=S3;break;case"username":Object.assign(W,y1),W.encodePart=d7;break;case"password":Object.assign(W,y1),W.encodePart=i7;break;case"hostname":Object.assign(W,CX),Z4(Y)?W.encodePart=z4:W.encodePart=T4;break;case"port":Object.assign(W,y1),W.encodePart=J4;break;case"pathname":O4(this.#j.protocol)?(Object.assign(W,fX,T),W.encodePart=u7):(Object.assign(W,y1,T),W.encodePart=s7);break;case"search":Object.assign(W,y1,T),W.encodePart=n7;break;case"hash":Object.assign(W,y1,T),W.encodePart=a7;break}try{this.#T[J]=t6(Y,W),this.#j[J]=e6(this.#T[J],this.#Z[J],W),this.#$[J]=t7(this.#T[J],W),this.#X=this.#X||this.#T[J].some((X)=>X.type===2)}catch{throw TypeError(`invalid ${J} pattern '${this.#z[J]}'.`)}}}catch(j){throw TypeError(`Failed to construct 'URLPattern': ${j.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},Z){let O={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?O=u$(O,$,!1):O=u$(O,o6($,Z),!1)}catch{return!1}let j;for(j of s6)if(!this.#j[j].exec(O[j]))return!1;return!0}exec($={},Z){let O={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?O=u$(O,$,!1):O=u$(O,o6($,Z),!1)}catch{return null}let j={};Z?j.inputs=[$,Z]:j.inputs=[$];let T;for(T of s6){let z=this.#j[T].exec(O[T]);if(!z)return null;let J={};for(let[W,Y]of this.#Z[T].entries())if(typeof Y=="string"||typeof Y=="number"){let X=z[W+1];J[Y]=X}j[T]={input:O[T]??"",groups:J}}return j}static compareComponent($,Z,O){let j=S((W,Y)=>{for(let X of["type","modifier","prefix","value","suffix"]){if(W[X]<Y[X])return-1;if(W[X]===Y[X])continue;return 1}return 0},"comparePart"),T=new n$(3,"","","","",3),z=new n$(0,"","","","",3),J=S((W,Y)=>{let X=0;for(;X<Math.min(W.length,Y.length);++X){let D=j(W[X],Y[X]);if(D)return D}return W.length===Y.length?0:j(W[X]??T,Y[X]??T)},"comparePartList");return!Z.#$[$]&&!O.#$[$]?0:Z.#$[$]&&!O.#$[$]?J(Z.#T[$],[z]):!Z.#$[$]&&O.#$[$]?J([z],O.#T[$]):J(Z.#T[$],O.#T[$])}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.#X}};S(W4,"URLPattern");function lZ($,Z){for(let[O,j]of Object.entries($)){let T=new W4({pathname:O});if(T.test({pathname:Z}))return{routePath:O,params:T.exec({pathname:Z})?.pathname.groups??{},route:j}}return null}var D$={startIndex:0,carriedViews:[]};function e7($,Z){let O=z0($.path,Z);return O.includes("*")?null:O}function VX($,Z){if(!$)return D$;if($.search!==Z.search)return D$;let O=Math.min($.segments.length,Z.segments.length-1),j=0;while(j<O){let T=$.segments[j],z=Z.segments[j];if(z.alwaysRun)break;if(T.viewPath!==z.viewPath)break;let J=e7(T,$.params),W=e7(z,Z.params);if(J===null||W===null||J!==W)break;j++}if(j===0)return D$;return{startIndex:j,carriedViews:Z.segments.slice(0,j).map(({viewPath:T})=>T)}}function IX($,Z){let[,O,...j]=$.split("/");if(!Z.includes(O))return $;let T=`/${j.join("/")}`;return T==="/"?"/":T.replace(/\/$/,"")}function $J($){let{flatViewRoutes:Z,supportedLocales:O,from:j,origin:T,to:z}=$;if(!j)return D$;let J;try{J=new URL(j,T)}catch{return D$}if(J.origin!==T)return D$;let W=lZ(Z,IX(J.pathname,O));if(!W)return D$;return VX({segments:W.route.segments,params:W.params,search:J.search},z)}var Y4="x-gemi-from";import{createElement as $Z,Fragment as lX}from"react";function LX($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function N3($){let Z={};for(let[O,j]of Object.entries($))if("run"in j){let T=j.viewPath;if("children"in j){Z[O]=[T];let z=new j.children,J=N3(z.routes);for(let[W,Y]of Object.entries(J)){let X=O==="/"?W:`${O}${W}`,D=W==="/"&&O!=="/"?O:X;Z[D]=[T,...Y]}if(Z[O].length===1)delete Z[O]}else Z[O]=[T]}else{let T=new j,z=N3(T.routes);for(let[J,W]of Object.entries(z)){let Y=O==="/"?J:`${O}${J}`,X=J==="/"&&O!=="/"?O:Y;Z[X]=W}}return Object.fromEntries(Object.entries(Z).map(([O,j])=>[LX(O),j]))}function _3($){let Z=[];for(let[O,j]of Object.entries($))if("run"in j){let T=j.viewPath;if(T==="__")continue;if(T==="REDIRECT")continue;if(T==="FILE")continue;if("children"in j){let z=new j.children,J=_3(z.routes);Z.push([T,J])}else Z.push([T,[]])}else{let T=new j,z=_3(T.routes);Z.push(...z)}return Z}function X4($){let Z=[];for(let[O,j]of $)Z.push(O,...X4(j).flat());return Array.from(new Set(Z))}class m1 extends K0{static getFacadeAccessor(){return u}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),Z=N.getStore();if(Z)return Z.locale??$.detectLocale(Z.req);return $.defaultLocale}static timeZone(){return this.getFacadeRoot().detectTimeZone(N.getStore()?.req)}static formatter($={}){return this.getFacadeRoot().formatter($.locale??m1.locale(),$.timeZone??m1.timeZone())}static setLocale($=m1.locale()){let Z=this.getFacadeRoot(),O=$;if(!Z.supportedLocales.includes($))O=Z.defaultLocale;let j=N.getStore();return j.setCookie("i18n-locale",O,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1}),j.setLocale(O),O}}class D4{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var MX=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),SX=new Set(["svg","math"]);function ZJ($){return $===32||$===9||$===10||$===12||$===13}function OJ($){return $>=65&&$<=90||$>=97&&$<=122}function x3($){return $>=65&&$<=90?$+32:$}function jJ(){let $="data",Z="",O=!1,j="",T=0,z=0,J=!1,W=0,Y=0,X=()=>$==="data"&&W===0&&Y===0,D=()=>{if(!O&&MX.has(Z)){$="rawText",j=`</${Z}`,T=0,Z="";return}if($="data",Z==="template")if(O)W=Math.max(0,W-1);else W+=1;else if(SX.has(Z)){if(O)Y=Math.max(0,Y-1);else if(!J)Y+=1}Z=""},U=(F)=>{switch($){case"data":if(F===60)$="tagOpen";return;case"tagOpen":if(F===33)$="bang",z=0;else if(F===47)$="endTagOpen";else if(OJ(F))$="tagName",O=!1,J=!1,Z=String.fromCharCode(x3(F));else if(F===63)$="bogus";else if(F===60)$="tagOpen";else $="data";return;case"endTagOpen":if(OJ(F))$="tagName",O=!0,J=!1,Z=String.fromCharCode(x3(F));else if(F===62)$="data";else $="bogus";return;case"tagName":if(ZJ(F)||F===47)$="inTag",J=F===47;else if(F===62)D();else Z+=String.fromCharCode(x3(F));return;case"inTag":if(F===62){D();return}if(J=F===47,F===34)$="attrDouble";else if(F===39)$="attrSingle";return;case"attrDouble":if(F===34)$="inTag";J=!1;return;case"attrSingle":if(F===39)$="inTag";J=!1;return;case"bang":if(F===45){if(z+=1,z===2)$="comment",z=0}else if(F===62)$="data";else $="bogus";return;case"bogus":if(F===62)$="data";return;case"comment":if(F===45)z=z<2?z+1:2;else if(F===62&&z>=2)$="data",z=0;else z=0;return;case"rawText":{if(T<j.length){if(x3(F)===j.charCodeAt(T))T+=1;else T=F===60?1:0;return}if(F===62)$="data",Z="";else if(ZJ(F)||F===47)$="inTag",Z="";else T=F===60?1:0;return}}};return{scanToInsertionPoint(F){for(let B=0;B<F.length;B++){if(X())return B;U(F[B])}return F.length},write(F){for(let B=0;B<F.length;B++)U(F[B])},isSafe:X}}function F$($){let Z=JSON.stringify($);if(Z===void 0)return"undefined";return Z.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function NX($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${F$([$.path,$.variantKey,$.data])})</script>`}function _X($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${F$([$.id,$.locale,$.strings])})</script>`}function F4($,Z,O={},j){let T=new TextEncoder,z=[],J=!1,W=!1,Y=()=>{if(W)return;W=!0,O.onClose?.()};Z.onSettle((G)=>{if(G.status!=="resolved")return;z.push(NX(G))}),j?.onUse((G)=>{z.push(_X(G))});let X=$.getReader(),D=jJ(),U=(G,K)=>{G.enqueue(K),O.onChunk?.(K)},F=(G)=>{while(z.length>0){let K=T.encode(z.shift());D.write(K),U(G,K)}},B=(G,K)=>{if(z.length===0){D.write(K),U(G,K);return}let Q=D.scanToInsertionPoint(K);if(Q>0)U(G,K.subarray(0,Q));if(D.isSafe())F(G);let f=K.subarray(Q);if(f.length>0)D.write(f),U(G,f)};return new ReadableStream({async pull(G){let K;try{K=await X.read()}catch(L){throw Y(),L}let{done:Q,value:f}=K;if(Q){F(G),G.close(),Y();return}if(!J){if(J=!0,D.write(f),U(G,f),O.onShell?.(),D.isSafe())F(G);return}B(G,f)},cancel(G){return Y(),X.cancel(G)}})}var xX=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function P3($){if(!$)return!1;return xX.test($)}async function zJ($,Z=()=>{}){let O=N.getStore(),j=O?.req??null,T=null;if(j?.rawRequest?.url)try{T=new URL(j.rawRequest.url).pathname}catch{T=null}return{user:O?.user??null,attributes:await PX($,Z),request:{path:T,routePath:j?.routePath??null,locale:O?.locale??null},anonymousId:TJ(),isBot:P3(j?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function JJ($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function PX($,Z){if(!$.context)return{};try{let O=N.getStore();return await $.context(O?.req??null)??{}}catch(O){return Z(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${O instanceof Error?O.message:String(O)}`),{}}}function WJ($,Z){return`${$}:${Z}`}function U4($){let Z=new Bun.CryptoHasher("sha1").update($).digest("hex"),O=Number.parseInt(Z.slice(0,8),16);return Math.floor(O/4294967296*1e4)}function YJ($,Z){if(Z>=100)return!0;if(Z<=0)return!1;return $<Math.round(Z*100)}function XJ($,Z,O,j){if(j.unavailable)return{value:!1,reason:"unavailable"};if(j.active!==!0)return{value:!1,reason:"inactive"};if(Z.when){let z;try{z=Z.when(O)}catch(J){return j.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${J instanceof Error?J.message:String(J)}`),{value:!1,reason:"error"}}if(typeof z==="boolean")return{value:z,reason:"attributed"}}if(Z.rollout===void 0)return{value:!0,reason:"on"};if(O.isBot)return{value:!1,reason:"bot"};let T=AX($,Z,O,j.buckets);return YJ(T,Z.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function EX($){let Z=$.user?.publicId??$.user?.id;if(Z!==void 0&&Z!==null)return String(Z);return $.anonymousId??""}function AX($,Z,O,j){let T=WJ(Z.salt??$,EX(O));if(!j)return U4(T);let z=j.get(T);if(z!==void 0)return z;let J=U4(T);return j.set(T,J),J}class DJ extends Error{cause;kind="FeatureReloadFailed";constructor($){super(`Could not reload feature switches after a write, so the cached switches may still predate it: ${$ instanceof Error?$.message:String($)}`);this.cause=$}}class G4{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,Z,O,j=()=>{}){this.source=$;this.declared=Z;this.ttlMs=O;this.warn=j}async get(){let $=this.snapshot;if($&&Date.now()-$.loadedAt<this.ttlMs)return $;if($){if(Date.now()>=this.retryAfter)this.refresh().catch(()=>{});return $}return await this.refresh()}refresh(){return this.inflight??=this.load().finally(()=>{this.inflight=null}),this.inflight}async invalidate(){await this.inflight?.catch(()=>{});let $=this.generation,Z=await this.refresh();if(this.generation===$)throw new DJ(this.lastError);return Z}peek(){return this.snapshot}async load(){try{let $=await this.source.load(),{active:Z,audit:O}=this.readRows($);return this.snapshot={active:Z,audit:O,loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readRows($){let Z=new Map,O=new Map;for(let j of $??[]){let T=typeof j?.key==="string"?j.key:null;if(!T){this.warn("Ignoring a feature row with no `key`.");continue}if(!(T in this.declared)){this.warn(`Feature row "${T}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}Z.set(T,j.active===!0);let z=HX(j);if(z)O.set(T,z)}return{active:Z,audit:O}}handleFailure($){let Z=$ instanceof Error?$.message:String($),O=Date.now();if(this.lastError=$,this.retryAfter=O+this.ttlMs,O-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=O,this.warn(`Could not load feature switches: ${Z}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,audit:new Map,loadedAt:O,unavailable:!0},this.snapshot}}function HX($){let Z={},O=$.updatedBy;if(typeof O==="string")Z.updatedBy=O;else if(O===null)Z.updatedBy=null;let j=$.updatedAt;if(j instanceof Date||typeof j==="string"||typeof j==="number"){let T=j instanceof Date?j:new Date(j);if(!Number.isNaN(T.getTime()))Z.updatedAt=T}return"updatedBy"in Z||"updatedAt"in Z?Z:null}class bX{}class vX extends Error{modelName;kind="FeatureModelMissing";constructor($){super(`No "${$}" model is registered, so every feature stays off. Add the model to prisma/schema.prisma and export it from app/models \u2014 see docs/feature-flags.md.`);this.modelName=$}}class B4 extends Error{sourceName;kind="FeatureSourceReadOnly";constructor($){super(`The feature source (${$}) is read-only, so Features.set() cannot write to it. Change the switch where that source reads from, or give the source a write() method.`);this.sourceName=$}}class FJ extends Error{key;kind="UndeclaredFeature";constructor($){super(`"${$}" is not declared in app/features, so it cannot be switched. A row for it would be ignored \u2014 declare the feature first.`);this.key=$}}class UJ{manager;ctx;constructor($,Z){this.manager=$;this.ctx=Z}async enabled($){return(await this.explain($)).value}async explain($){return await this.manager.evaluateIn($,this.ctx,new Map)}async all(){return await this.manager.evaluateAllIn(this.ctx,new Map,{clientOnly:!1})}}class a${config;log;static token="features";store;declared;warnedAboutSize=!1;warnedAboutActor=!1;constructor($,Z=()=>{}){this.config=$;this.log=Z;this.declared=$.features??{},this.store=new G4($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,audit:Z,unavailable:O}=await this.switches();return{unavailable:O,features:Object.entries(this.declared).map(([j,T])=>({key:j,describe:T.describe,rollout:T.rollout,targeted:T.when!==void 0,serverOnly:T.serverOnly,salt:T.salt,active:$.get(j),...Z.get(j)}))}}async refresh(){if(!this.config.enabled)return;if(Object.keys(this.declared).length===0)return;await this.store.refresh()}async invalidate(){try{if(this.config.enabled&&Object.keys(this.declared).length>0)await this.store.invalidate()}finally{N.getStore()?.featureEvaluations?.clear()}}async set($,Z,O={}){if(typeof $!=="string"||!Object.hasOwn(this.declared,$))throw new FJ(String($));if(typeof Z!=="boolean")throw TypeError(`Features.set("${$}", \u2026) takes a boolean, not ${Z===null?"null":typeof Z}.`);let j=wX(O.actor),T=this.config.source;if(typeof T.write!=="function")throw new B4(T.constructor?.name||"an anonymous source");let{actorRecorded:z}=await T.write($,Z,{actor:j});if(j!==null&&!z&&!this.warnedAboutActor)this.warnedAboutActor=!0,this.log('Features.set() was given an actor, but the feature source has nowhere to record it. For the database source, add a nullable `updatedBy String?` column to the feature flag model to keep "last changed by".');await this.invalidate()}async enabled($){return(await this.explain($)).value}async explain($){let Z=await this.requestContext();return await this.evaluateIn($,Z,this.requestBuckets())}async all(){let $=await this.requestContext();return await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!1})}async forClient(){if(!this.config.enabled)return{};let $=await this.requestContext(),Z=await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!0});return this.warnIfOversized(Object.keys(Z).length),Z}for($){return new UJ(this,JJ($))}async evaluateIn($,Z,O){let j=this.memoFor(Z),T=j?.get($);if(T)return T;let z=this.declared[$];if(!z)return{value:!1,reason:"undeclared"};let{active:J,unavailable:W}=await this.switchFor($),Y=XJ($,z,Z,{active:J,unavailable:W,buckets:O,warn:this.log});return j?.set($,Y),this.notify($,Y,Z),Y}async evaluateAllIn($,Z,O){let j={};for(let[T,z]of Object.entries(this.declared)){if(O.clientOnly&&z.serverOnly)continue;j[T]=(await this.evaluateIn(T,$,Z)).value}return j}async switches(){if(!this.config.enabled||Object.keys(this.declared).length===0)return{active:new Map,audit:new Map,unavailable:!1};let $=await this.store.get();return{active:$.active,audit:$.audit,unavailable:$.unavailable}}async switchFor($){if(!this.config.enabled)return{active:!1,unavailable:!1};let Z=await this.store.get();return{active:Z.active.get($),unavailable:Z.unavailable}}async requestContext(){let $=N.getStore();if($?.featureContext)return $.featureContext;let Z=await zJ(this.config,this.log);if($)$.featureContext=Z;return Z}memoFor($){let Z=N.getStore();if(!Z||Z.featureContext!==$)return null;return Z.featureEvaluations??=new Map,Z.featureEvaluations}requestBuckets(){let $=N.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,Z,O){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,Z,O)}catch(j){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${j instanceof Error?j.message:String(j)}`)}}warnIfOversized($){if(this.warnedAboutSize||$<=this.config.maxClientFlags)return;this.warnedAboutSize=!0,this.log(`${$} client-visible features are embedded in every document. Mark the ones only the server reads with \`serverOnly: true\` to keep them out of the payload.`)}}function wX($){if($===void 0||$===null)return null;if(typeof $==="string"){if($.length>0)return $}else if(typeof $==="object"){let{publicId:Z,id:O}=$;if(typeof Z==="string"&&Z.length>0)return Z;if(typeof O==="string"&&O.length>0||typeof O==="number")return String(O)}throw TypeError("Features.set() was given an `actor` that identifies nobody. Pass a string, or a user with a `publicId` or an `id`.")}function GJ($){return Object.fromEntries(Object.entries($).filter(([,Z])=>{return Z!==null&&Z!==void 0}))}var RX=50;class o${fetcher;entries=new Map;settleListener=null;failListener=null;shellAt=null;settledBacklog=[];shipped=new Set;requestStartedAt=performance.now();renderStartedAt=null;discoveryHintsMuted=!1;constructor($){this.fetcher=$}elapsed(){return Math.round(performance.now()-this.requestStartedAt)}keyFor($,Z){return[$,Z].filter((O)=>O.length>0).join("?")}markRenderStart(){if(this.renderStartedAt===null)this.renderStartedAt=performance.now()}markShell(){if(this.shellAt===null)this.shellAt=this.elapsed()}summarize($){let Z=this.elapsed();return{shellAt:this.shellAt??Z,settledAt:Z,aborted:$,queries:Array.from(this.entries.values(),(O)=>({path:O.path,variantKey:O.variantKey,startedAt:O.startedAt,settledAt:O.settledAt,status:O.status,source:O.source}))}}onQueryFail($){this.failListener=$}muteDiscoveryHints(){this.discoveryHintsMuted=!0}maybeLogLateDiscovery($){if(!$.lateBy||this.discoveryHintsMuted)return;if($.status!=="resolved")return;if(Bun.env.NODE_ENV==="production")return;let Z="";try{let T=JSON.stringify($.data)?.length??0;Z=T>=1024?`${(T/1024).toFixed(1)} kB`:`${T} B`}catch{Z="an unserializable payload"}let O=($.settledAt??0)-$.startedAt,j=$.variantKey?`, { search: ${JSON.stringify(Object.fromEntries(new URLSearchParams($.variantKey)))} }`:"";console.warn(`[gemi] useQuery("${$.patternPath}") was discovered ${$.lateBy}ms into the `+`server render \u2014 under a suspended segment, so its fetch (${O}ms, resolved ${Z}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${j})\` in the view `+"handler starts it at request time \u2014 but note prefetched data is also re-fetched and "+`streamed into every client-side navigation payload for the route, even when the client already holds it, so weigh that bandwidth against the ${Z}. If the data is only needed conditionally (a closed popover, a hidden tab), \`{ lazy: true }\` + \`trigger()\` avoids running it here at all. \`Query.noPrefetch()\` in the handler marks the omission intentional and silences this hint for the route.`)}read($,Z){return this.entries.get(this.keyFor($,Z))}ensure($,Z={},O="render"){let j=Z.params??{},T=new URLSearchParams(GJ(Z.search??{}));T.delete("json"),T.sort();let z=z0($,j),J=T.toString(),W=this.keyFor(z,J),Y=this.entries.get(W);if(Y)return Y;let X;if(O==="render"&&this.renderStartedAt!==null){let B=Math.round(performance.now()-this.renderStartedAt);if(B>RX)X=B}let D,U=new Promise((B)=>{D=B}),F={path:z,patternPath:$,variantKey:J,lateBy:X,status:"pending",promise:U,source:O,startedAt:this.elapsed()};return this.entries.set(W,F),this.fetcher($,j,T).then((B)=>{F.status="resolved",F.data=B},(B)=>{F.status="rejected",F.error=B}).then(()=>{if(F.settledAt=this.elapsed(),this.maybeLogLateDiscovery(F),F.status==="rejected"&&this.failListener)this.failListener(F);if(this.settleListener)this.settleListener(F);else this.settledBacklog.push(F);D()}),F}async allSettled(){let $=0;while($!==this.entries.size)$=this.entries.size,await Promise.all(Array.from(this.entries.values(),(Z)=>Z.promise))}snapshotResolved(){let $={};for(let[Z,O]of this.entries){if(O.status!=="resolved")continue;this.shipped.add(Z),$[O.path]??={},$[O.path][O.variantKey]=O.data}return $}onSettle($){this.settleListener=(O)=>{if(this.shipped.has(this.keyFor(O.path,O.variantKey)))return;$(O)};let Z=this.settledBacklog;this.settledBacklog=[];for(let O of Z)this.settleListener(O)}}class p1 extends Error{path;variantKey;status;body;retryAfter;constructor($,Z,O,j,T){super(typeof j?.message==="string"?j.message:`Request to /api${$} failed with status ${O}`);this.path=$;this.variantKey=Z;this.status=O;this.body=j;this.retryAfter=T;this.name="QueryError"}}function r$(){let $=JSON.stringify({error:I1("permission","Forbidden",403)});return new Response($,{status:403,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}function K4(){return{status:403,error:{message:"Forbidden"}}}function dZ($){let Z=t$.getStore();return(O,j,T)=>{let z=new URL($.url).origin,J=[z0(O,j),T.toString()].filter((D)=>D.length>0).join("?"),W=new Request(`${z}/${J}`,{headers:$.headers,signal:$.signal}),Y=BJ($);if(Y)e$(W,Y);let X=new _(W,j);return t$.run(Z,()=>N.run(X,async()=>{try{let D=await C(s0).dispatchers(Y).api.getRouteData(O);if(C$(D)){if(!D.ok)throw new p1(z0(O,j),T.toString(),D.status,D.body);return D.body}if(D instanceof Response){let U=await D.json().catch(()=>null);if(!D.ok)throw new p1(z0(O,j),T.toString(),D.status,U);return U}return D}catch(D){if(D instanceof p1)throw D;let U=new p1(z0(O,j),T.toString(),500,{message:D instanceof Error?D.message:String(D)});throw U.cause=D,U}}))}}var qX=new Set(["script","style","template","title"]),kX=/\shidden([\s=/]|$)/i,gX=/"[^"]*"|'[^']*'/g;function yX($){let Z=0,O=0,j=0,T=0;while(T<$.length){let z=$.indexOf("<",T),J=z===-1?$.length:z;if(J>T){let U=$.slice(T,J).replace(/\s+/g,"").length;if(j>0)O+=U;else Z+=U}if(z===-1)break;if($.startsWith("<!--",z)){let U=$.indexOf("-->",z+4);T=U===-1?$.length:U+3;continue}let W=$.indexOf(">",z);if(W===-1)break;let Y=$.slice(z+1,W);T=W+1;let X=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(Y)?.[1]?.toLowerCase();if(!X)continue;let D=Y.startsWith("/");if(!D&&qX.has(X)&&!Y.endsWith("/")){let U=$.indexOf(`</${X}`,T);T=U===-1?$.length:U;continue}if(X!=="div")continue;if(D){if(j>0)j-=1}else if(j>0)j+=1;else if(kX.test(Y.replace(gX,'""')))j=1}return{shellChars:Z,deferredChars:O}}var mX=1000,pX=64;function hX($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function cX($,Z){if(Z.deferredChars<mX)return null;if(Z.shellChars>=pX)return null;return`[gemi] GET ${$} streams ${hX(Z.deferredChars)} of its `+`content behind reveal scripts \u2014 a no-JS visitor sees ~${Z.shellChars} chars. If this is a public/content route, add "no-stream" to its middleware.`}function KJ($=console.warn){let Z=new Set;return{shouldObserve(O){return!Z.has(O)},report(O,j){if(Z.has(O))return;let T=cX(O,j);if(!T)return;Z.add(O),$(T)}}}function QJ(){let $=new TextDecoder,Z="";return{onChunk(O){Z+=$.decode(O,{stream:!0})},measure(){return Z+=$.decode(),yX(Z)}}}function CJ($,Z,O=1e4,j){let T=new TextEncoder,z=()=>{};return new ReadableStream({start(J){let W=!1,Y=(D)=>{if(W)return;W=!0,clearTimeout(X);try{J.close()}catch{}j?.({aborted:D})};z=Y,J.enqueue(T.encode(`${JSON.stringify($)}
3
+ `)),Z.onSettle((D)=>{if(W||D.status!=="resolved")return;J.enqueue(T.encode(`${JSON.stringify([D.path,D.variantKey,D.data])}
4
+ `))});let X=setTimeout(()=>Y(!0),O);Z.allSettled().then(()=>Y(!1),()=>Y(!1))},cancel(){z(!1)}})}var dX=async()=>(await import("./chunk-tymhsmgq.js")).default,Q4,C4=async(...$)=>{return Q4??=import("react-dom/server.browser").catch((Z)=>{throw Q4=void 0,Z}),(await Q4).renderToReadableStream(...$)},iX=1e4,uX=`
5
+ !function(){try{var d=document.documentElement,c=d.classList;
6
+ c.remove('light','dark');
7
+ var e=localStorage.getItem('theme');
8
+ if('system'===e||(!e&&'system'===defaultTheme)){
9
+ var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);
10
+ if(m.media!==t||m.matches){d.style.colorScheme='dark';c.add('dark')}
11
+ else{d.style.colorScheme='light';c.add('light')}
12
+ }else if(e){
13
+ c.add(e||'')
14
+ }}catch(e){}}()
15
+ `;async function sX($,Z,O){let j=`${O==="italic"?"italic,":""}wght@${O==="italic"?"1,":""}${Z}`,J=(await(await fetch(`https://fonts.googleapis.com/css2?family=${$}:${j}&display=swap`,{headers:{"User-Agent":"Mozilla/5.0 Firefox/1.0"}})).text()).match(/url\(([^)]+)\)/)?.[1];return await fetch(J).then((W)=>W.arrayBuffer())}var I4="/assets";function nX($){return $===I4||$.startsWith(`${I4}/`)}function aX($){let Z=$.filter(nX);if(Z.length>0){let O=Z.length>1;throw Error(`View route path${O?"s":""} ${Z.map((j)=>`"${j}"`).join(", ")} use${O?"":"s"} the reserved "${I4}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function oX($){let Z=C(s0).resolver;return{...$.domain,root:Z.root,origin:Z.publicOrigin($.rawRequest)}}function f4($){let{status:Z=400,error:O}=$;return new Response(O?.message,{...$,status:Z})}function rX($){let{status:Z=400,data:O,directive:j,headers:T}=$;return new Response(JSON.stringify({data:O,directive:j}),{headers:T,status:Z})}class sZ{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];root=null;shellReporter=KJ();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let Z=E7();this.partialRendering=$.partialRendering??Z.partialRendering,this.hooks={onRequestStart:$.onRequestStart??Z.onRequestStart,onRequestEnd:$.onRequestEnd??Z.onRequestEnd,onRequestFail:$.onRequestFail??Z.onRequestFail,onStreamComplete:$.onStreamComplete??Z.onStreamComplete};let O={"/":$.rootRouter,"/auth":g6};this.flatViewRoutes=M3(O),aX(Object.keys(this.flatViewRoutes)),this.routeManifest=N3(O),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,j])=>j.at(-1)!=="FILE")),this.componentTree=_3(O),this.flatComponentTree=X4(this.componentTree),this.root=$.root}async passesFeatureGates($){let Z=C(a$);for(let O of $)if(!await Z.enabled(O))return!1;return!0}async onRequestEnd($){return V4(),await this.hooks.onRequestEnd($)}completeStream($,Z){let O=(j)=>{U$.error(j?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(j)})};try{Promise.resolve(this.hooks.onStreamComplete($,Z)).catch(O)}catch(j){O(j)}}modulePreloadLinks($){let{clientEntry:Z,modulePreloadManifest:O,views:j,routeKey:T}=$,z=()=>{let Y=new Set(Z?.preload??[]);for(let X of j)for(let D of O?.[X]??[])Y.add(D);return[...Y].map((X)=>$Z("link",{key:`modulepreload:${X}`,rel:"modulepreload",href:X}))};if(!O)return z();let J=this.preloadCache.get(O);if(!J||J.clientEntry!==Z)J={clientEntry:Z,byRoute:new Map},this.preloadCache.set(O,J);let W=J.byRoute.get(T);if(!W)W=z(),J.byRoute.set(T,W);return W}async render($){let{req:Z,runInRequestScope:O,csrfTokenHMAC:j,currentPathName:T,headers:z,i18n:J,params:W,pathname:Y,serverQueries:X,userAgent:D,noStream:U,url:F,user:B,viewData:G,breadcrumbs:K,urlLocaleSegment:Q,meta:f,isOgRequest:L,appId:V,features:x}=$,P=Y.replace(`/${Q}`,""),I={kind:"view",data:{meta:f,pageData:{[P]:G},__csrf:j.toString("base64"),prefetchedData:{},i18n:J,auth:{user:B},routeManifest:this.clientRouteManifest,breadcrumbs:K,router:{urlLocaleSegment:Q,pathname:T,params:W,currentPath:Y,searchParams:F.search,is404:!T?!0:!1,domain:Z.domain?oX(Z):null},appId:V,features:x,componentTree:[["404",[]],...this.componentTree]},head:{}},M=this.root,E=this.routeManifest[T];return async(H)=>{let{bootstrapModules:j0=[],loaders:R,getStyles:g,viewImportMap:i,cssManifest:R3,ogMap:nZ,viewModules:aZ,clientEntry:n0,modulePreloadManifest:h1,assetBase:f1}=H,T0=n0?[]:j0,oZ=(o)=>[o,`window.loaders=${R}`,...n0?[`import(${JSON.stringify(n0.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(L){let o=null,K$=null;for(let Q$ of E??[])if(typeof nZ[Q$]==="function")K$=Q$,o=nZ[Q$];if(!o)return new Response("Not found",{status:404});let sJ=Object.values(I.data.pageData)[0];try{await C4($Z(o,sJ[K$]),{onError:()=>{}})}catch(Q$){let{fonts:nJ,...aJ}=Q$.satoriOptions,oJ=await Promise.all(nJ.map((rZ)=>{return sX(rZ.name,rZ.weight,rZ.style).then((ZW)=>({...rZ,data:ZW}))})),E4=new Headers(z);E4.set("Content-Type","image/png");let[rJ,tJ]=await Promise.all([dX(),I3("Rendering an OG image")]),eJ=await rJ(Q$.jsx,{...aJ,fonts:oJ}),$W=await tJ(Buffer.from(eJ)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array($W),{headers:E4})}return new Response("data")}if(I.data.cssManifest=R3,I.data.modulePreloadManifest=h1??{},f1&&f1!=="/")I.data.assetBase=f1;let q3=this.modulePreloadLinks({clientEntry:n0,modulePreloadManifest:h1,views:E??["404"],routeKey:T??"404"}),G$=await g(E);I.data.prefetchedData=X.snapshotResolved(),X.markRenderStart();let J1=new AbortController,jZ=setTimeout(()=>J1.abort(),iX),B$=P3(D)||U,b=Bun.env.NODE_ENV!=="production"&&!B$&&T&&this.shellReporter.shouldObserve(T)?QJ():null,v0=IJ();try{let o=await C4($Z(lX,{children:[...q3,...G$,$Z("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:uX}}),$Z(M,{data:I.data,viewImportMap:i,viewModules:aZ,serverQueries:X,dictionarySink:v0,key:"root"})]}),{bootstrapScriptContent:oZ(`window.__GEMI_DATA__ = ${F$(I.data)}`),bootstrapModules:T0,signal:J1.signal,...B$?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(K$){if(Bun.env.NODE_ENV!=="production")console.error(K$)}});if(o.allReady.catch(()=>{}).finally(()=>clearTimeout(jZ)),B$)await o.allReady.catch(()=>{});return new Response(F4(o,X,{onShell:B$?void 0:()=>X.markShell(),onChunk:b?.onChunk,onClose:()=>O(()=>{if(this.completeStream(Z,X.summarize(J1.signal.aborted)),b)this.shellReporter.report(T,b.measure())})},v0),{status:!T?404:200,headers:z})}catch(o){if(clearTimeout(jZ),Bun.env.NODE_ENV==="production")throw O(()=>this.completeStream(Z,X.summarize(J1.signal.aborted))),o;let K$=await C4($Z("div"),{bootstrapScriptContent:oZ(`window.error= ${F$(o.message)}; window.stack_trace=${F$(o.stack)};window.__GEMI_DATA__ = ${F$(I.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...T0]:T0});return new Response(F4(K$,X,{onClose:()=>O(()=>this.completeStream(Z,X.summarize(J1.signal.aborted)))}),{status:!T?404:200,headers:z})}}}async handleViewRequest($,Z){let O=new URL($.url),j=O.pathname.endsWith(".json"),T=O.pathname.endsWith(".og"),z=O.pathname.replace(".json","").replace(".og",""),[,J,...W]=z.split("/"),Y=`/${W.join("/")}`,X=null,D=null,U=C(u);if(!U.supportedLocales.includes(J))Y=z;else X=J,D=J;let B=D===null&&lZ(this.flatViewRoutes,Y)!==null;if(U.isLocaleAware&&!T&&D===null&&!B){let I=fJ(J,U.supportedLocales,U.defaultLocale);if(I){let M=W.length?`/${W.join("/")}`:"";return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${I}${M}${j?".json":""}${O.search}`}})}}if(U.isLocaleAware&&!T){let I=C(u).detectLocale(new _($,{},"view",Y));if(D===null&&I!==U.defaultLocale){let M=O.pathname==="/"?"":O.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${I}${M}${O.search}`}})}}Y=Y.replace("//","/");let G=[],K=[],Q=null,f={},L=null,V=!1,x=[];try{let I=lZ(this.flatViewRoutes,Y);if(I){if(Q=I.routePath,f=I.params,G=I.route.exec,K=I.route.middleware,x=I.route.features,V=K.includes("no-stream"),j&&this.partialRendering){let M=$.headers.get(Y4),E=$J({flatViewRoutes:this.flatViewRoutes,supportedLocales:C(u).supportedLocales,from:M,origin:O.origin,to:{segments:I.route.segments,params:f,search:O.search}});if(E.startIndex>0)G=G.slice(E.startIndex),L={from:M,carriedViews:E.carriedViews}}}}catch(I){throw I}let P=new _($,f,"view",Q);return this.hooks.onRequestStart(P),await N.run(P,async()=>{let I=null,M=N.getStore(),E=t$.getStore(),H=(g)=>t$.run(E,()=>N.runWith(M,g));M.serverQueries=new o$(dZ($));let j0=new Set;if(M.serverQueries.onQueryFail((g)=>{j0.add(g.error);try{H(()=>Promise.resolve(this.hooks.onRequestFail(R,g.error)).catch(()=>{}))}catch{}}),D){let g=D.replaceAll("/","");m1.setLocale(g)}else m1.setLocale();let R=M.req;V4();try{let g=!1;try{await C(cZ).runMiddleware(K)}catch(b){if(!ZZ(b))throw b;g=!0}if(g||x.length>0&&!await this.passesFeatureGates(x))Q=null,G=[],R.routePath="";let i=C(u),R3=i.isEnabled,nZ=i.isLocaleAware,aZ=new _($,R.params),n0={defaultLocale:i.defaultLocale,timeZone:i.detectTimeZone(aZ)};if(nZ){let b=null;if(D)b=D.replaceAll("/",""),M.setLocale(b);else b=i.detectLocale(aZ),M.setLocale(b);let v0=R3?i.getPageTranslations(b,R.routePath):{};n0={...n0,supportedLocales:i.supportedLocales,currentLocale:b,dictionary:{[b]:v0},defaultLocale:i.defaultLocale}}await VJ(n0.currentLocale??"");let h1;try{h1=await Promise.all(G.map((b)=>b(R)))}catch(b){if(!ZZ(b))throw b;Q=null,G=[],R.routePath="",h1=[]}let{cookies:f1,headers:T0}=M;I={data:h1,cookies:f1,headers:T0,user:M.user,prefetchedData:M.serverQueries.snapshotResolved(),currentPathName:Q,params:R.params,urlLocaleSegment:X,meta:M.renderMeta(),appId:C(D4).id,features:await C(a$).forClient()};let{params:oZ,user:q3}=I,G$={},J1={};for(let b of h1??[]){let[v0,o]=Object.entries(b)?.[0]??[];if(!v0||!o)continue;J1[`${v0}:${Q}`]=o.breadcrumb,G$[v0]=o}let jZ=G$.FILE;if(jZ){for(let b of f1)T0.append("Set-Cookie",b.toString());try{await this.onRequestEnd(R)}catch(b){U$.error(b?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(b)})}return await d3(jZ,T0)}if(j){T0.set("Content-Type","application/x-ndjson; charset=utf-8"),T0.append("Vary",Y4),f1.forEach((v0)=>T0.append("Set-Cookie",v0.toString())),await this.hooks.onRequestEnd(R);let b={meta:L&&!M.metadata.touched?null:I.meta,data:{[Y]:G$},breadcrumbs:J1,prefetchedData:M.serverQueries.snapshotResolved(),i18n:n0,features:I.features,is404:!Q,appId:I.appId,partial:L};return new Response(CJ(b,M.serverQueries,void 0,({aborted:v0})=>H(()=>this.completeStream(R,M.serverQueries.summarize(v0)))),{headers:T0})}if(T0.set("Content-Type","text/html; charset=utf-8"),!V)T0.append("Vary","User-Agent");for(let b of f1)T0.append("Set-Cookie",b.toString());let B$=Bun.CSRF.generate(process.env.SECRET);T0.append("Set-Cookie",`csrf_token=${B$}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`);try{await this.onRequestEnd(R)}catch(b){U$.error(b?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(b)})}return await this.render({req:R,runInRequestScope:H,csrfTokenHMAC:Buffer.from(""),currentPathName:Q,headers:T0,i18n:n0,params:oZ,pathname:O.pathname,serverQueries:M.serverQueries,userAgent:$.headers.get("user-agent"),noStream:V,url:O,user:q3,viewData:G$,breadcrumbs:J1,urlLocaleSegment:X,meta:I.meta,appId:I.appId,features:I.features,isOgRequest:T})}catch(g){if(g.kind===iZ)if(j)return rX(g.payload.viewData??g.payload.api);else return f4(g.payload.view);if(!j0.has(g))this.hooks.onRequestFail(R,g);if(uZ(g))return console.error(g),j?r$():f4(K4());if(g instanceof p1&&g.status===403)return j?r$():f4(K4());throw g}},Z)}}function M4(){let $=JSON.stringify({error:I1("not_found","Not found",404)});return new Response($,{status:404,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}class xJ extends N0{routes={"/api-routes":this.get(()=>{let $=C(E3).flatRoutes,Z=[];for(let[O,j]of Object.entries($))for(let[T,z]of Object.entries(j)){let{exec:J,middleware:W}=z;Z.push({path:O,method:T,middleware:W})}return Z}),"/view-routes":this.get(()=>{let $=C(sZ).flatViewRoutes,Z=[];for(let[O,{middleware:j,viewPath:T}]of Object.entries($))Z.push({path:O,method:"GET",viewPath:T,middleware:j});return Z})}}function tX($,Z){let O=$.body.getReader(),j=!1,T=()=>{if(j)return;j=!0;try{Z()}catch(J){console.error(J)}},z=new ReadableStream({async pull(J){let W;try{W=await O.read()}catch(Y){T(),J.error(Y);return}if(W.done){T();try{J.close()}catch{}return}try{J.enqueue(W.value)}catch{}},async cancel(J){try{await O.cancel(J)}finally{T()}}},{highWaterMark:0});return new Response(z,{status:$.status,statusText:$.statusText,headers:$.headers})}function LJ($){let{status:Z=400,data:O,headers:j}=$,T=new Headers({"Content-Type":"application/json",...j});if(!T.has("Cache-Control"))T.set("Cache-Control","no-store");return new Response(JSON.stringify(O),{status:Z,headers:T})}function MJ($,Z,O){let j=[];Z?.forEach((J,W)=>j.push([W,J]));let T=[...typeof Z?.getSetCookie==="function"?Z.getSetCookie():[],...Array.from(O??[])];if(j.length===0&&T.length===0)return $;let z=(J)=>{for(let[W,Y]of j){if(W.toLowerCase()==="set-cookie")continue;if(!J.has(W))J.set(W,Y)}for(let W of T)J.append("Set-Cookie",W)};try{return z($.headers),$}catch{let J=new Headers($.headers);return z(J),new Response($.body,{status:$.status,statusText:$.statusText,headers:J})}}class E3{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let Z=P7();this.onRequestStart=$.onRequestStart??Z.onRequestStart,this.onRequestEnd=$.onRequestEnd??Z.onRequestEnd,this.onRequestFail=$.onRequestFail??Z.onRequestFail,this.flatRoutes=d6({"/":$.rootRouter,"/auth":y6,"/__gemi__/services/i18n":m6,"/__gemi__/services/logs":l6,"/__gemi__/services/image":c6,"/__gemi__/debug":xJ})}getRouteHandlerAndParams($){let Z=new URL($.url),O=_J(Z.pathname),j={},T;for(let[z]of Object.entries(this.flatRoutes))try{let J=new URLPattern({pathname:z});if(J.test({pathname:O})){T=z,j=J.exec({pathname:O})?.pathname.groups;break}}catch(J){console.error(J)}return{params:j,path:T}}async runRouteMiddleware($,Z){let j=this.flatRoutes[$][Z.rawRequest.method].middleware;try{await C(cZ).runMiddleware(j)}catch(T){if(T.kind===iZ)return LJ(T.payload.api);else{if(ZZ(T))return M4();if(this.onRequestFail(Z,T),console.error(T),uZ(T))return r$();throw T}}}async getRouteData($){let Z=this.flatRoutes[$],O=N.getStore(),j=Z[O.req.rawRequest.method].exec??(()=>Promise.resolve({})),T={};try{T=await j()}catch(z){if(z.kind===iZ)return LJ(z.payload.api);if(ZZ(z))return M4();if(this.onRequestFail(O.req,z),console.error(z),uZ(z))return r$();throw z}return T}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,Z,O){let j=async()=>{try{if(!this.isFrameworkRoute(O))await this.onRequestEnd(Z)}catch(T){U$.error(T?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(T)})}finally{$.destroy()}};if(!$.hasPendingWork()){await j();return}$.whenIdle().then(j).catch((T)=>{console.error(T)})}isOpenEndedBody($,Z){return $.method!=="HEAD"&&!Z.headers.has("Content-Length")&&Z.body!==null}async handleApiRequest($,Z){let{params:O,path:j}=this.getRouteHandlerAndParams($),T=this.flatRoutes[j];if(!T||!T[$.method])return new Response(JSON.stringify({error:I1("not_found","Not found",404)}),{status:404});let z=new _($,O,"api",j);if(!this.isFrameworkRoute(j))this.onRequestStart(z);return await N.run(z,async()=>{let J=N.getStore(),W=!1,Y=async()=>{W=!0,await this.endRequest(J,z,j)};try{let X=C(u);if(X.isEnabled){let K=X.detectLocale(z);J.setLocale(K)}J.setRequest(z);let D=await this.runRouteMiddleware(j,z);if(D instanceof Response){let K=MJ(D,J.headers,J.cookies);return await Y(),K}let U=await this.getRouteData(j),F=J.headers,B=J.cookies;if(U instanceof Response){let K=MJ(U,F,B);if(this.isOpenEndedBody($,K)){let Q=tX(K,()=>this.endRequest(J,z,j));return W=!0,Q}return await Y(),K}let G=(C$(U)?U:c1.json(U)).toResponse(F,B);return await Y(),G}catch(X){if(!W)try{await Y()}catch(D){console.error(D)}throw X}},Z)}async dispatchAs($,Z,O,j){let T=new URL($.rawRequest.url).origin,z=new URL(`${T}/api${O}`),J=`/api${O.split(/[?#]/)[0]}`;if(!O.startsWith("/")||z.origin!==T||z.pathname!==J||z.hash!==""||z.pathname.startsWith("/api/__gemi__")||z.pathname==="/api/auth"||z.pathname.startsWith("/api/auth/"))throw Error(`dispatchAs: "${O}" is not an app api path. Pass the route's own path, without "/api", with every param encoded.`);let W=new Headers,Y=$.cookies.get(JZ);if(Y)W.set("Cookie",`${JZ}=${Y}`);let X=$.headers.get(JZ);if(X)W.set(JZ,X);let D=$.headers.get("User-Agent");if(D)W.set("User-Agent",D);let U;if(j instanceof FormData)U=j;else if(j!==void 0)W.set("Content-Type","application/json"),U=JSON.stringify(j);let F=new Request(z,{method:Z,headers:W,body:U});if(SJ(F,V$($)),$.domain)e$(F,$.domain);return N.exit(()=>NJ.exit(()=>this.handleApiRequest(F)))}}import{timingSafeEqual as eX}from"crypto";var H3="",_4="*",$D=60000,ZD=1e4,S4=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,A3=16,PJ=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,N4="x-forwarded-host";function EJ($){return $.startsWith(":")}function x4($,Z){if($===null)return!1;let O=Buffer.from($,"utf8"),j=Buffer.from(Z,"utf8");return O.length===j.length&&eX(O,j)}function OD($){if(!$)return null;if($===!0)return{header:N4,secret:null};return{header:($.hostHeader??N4).toLowerCase(),secret:$.secret?{header:$.secret.header.toLowerCase(),value:$.secret.value}:null}}function jD($){if(!$||$===!0)return;let{hostHeader:Z,secret:O}=$;if(Z!==void 0&&(typeof Z!=="string"||!PJ.test(Z)))throw Error(`\`route.domains.trustProxy.hostHeader\` must be a single header name, e.g. "x-forwarded-host". Got ${JSON.stringify(Z)}.`);if(!O)return;if(typeof O.header!=="string"||!PJ.test(O.header))throw Error(`\`route.domains.trustProxy.secret.header\` must be a header name. Got "${O.header}".`);if(O.header.toLowerCase()===(Z??N4).toLowerCase())throw Error("`route.domains.trustProxy.secret.header` names the same header as `hostHeader`; the secret needs a header of its own.");if(typeof O.value!=="string"||O.value.length<A3)throw Error(`\`route.domains.trustProxy.secret.value\` must be at least ${A3} characters. A guessable one lets any client name its own host.`)}function z1($){if(!$)return null;try{return new URL(`http://${$.trim()}`).hostname.toLowerCase().replace(/\.$/,"")||null}catch{return null}}function TD($){try{let Z=new URL(`http://${$.trim()}`),O=Z.hostname.toLowerCase().replace(/\.$/,"");return O?Z.port?`${O}:${Z.port}`:O:null}catch{return null}}function zD($){let Z=z1($.root),O=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!Z||Z!==O||!Z.split(".").every((z)=>S4.test(z)))throw Error(`\`route.domains.root\` must be a bare hostname, e.g. "example.com" \u2014 no scheme, port or path. Got "${$.root}".`);if($.custom&&($.custom.cacheTtlMs??0)<0)throw Error(`\`route.domains.custom.cacheTtlMs\` is ${$.custom.cacheTtlMs}; it cannot be negative. Use 0 to disable the cache.`);if($.ask&&$.ask.secret.length<A3)throw Error(`\`route.domains.ask.secret\` must be at least ${A3} characters. A guessable one is worse than leaving \`ask\` out.`);jD($.trustProxy);let j=new Set,T=null;for(let z of $.groups??[]){let{subdomain:J}=z;if(j.has(J))throw Error(`\`route.domains\` declares the subdomain "${J}" twice.`);if(j.add(J),EJ(J)){if(!/^:[A-Za-z_][A-Za-z0-9_]*$/.test(J))throw Error(`"${J}" is not a valid param subdomain. It must be a single \`:name\` label.`);if(T)throw Error(`\`route.domains\` declares two param subdomains, "${T.subdomain}" and "${J}"; a host could match either.`);T=z;continue}if(z.exists)throw Error(`The subdomain "${J}" is fixed, so \`exists\` has no param to check. It only applies to a \`:param\` subdomain.`);if(!J.split(".").every((W)=>S4.test(W)))throw Error(`"${J}" is not a valid subdomain.`)}if($.custom&&!j.has($.custom.group))throw Error(`\`route.domains.custom.group\` is "${$.custom.group}", but no group declares that subdomain.`);if($.ask&&T&&!T.exists)throw Error(`\`route.domains.ask\` is set, so "${T.subdomain}" needs an \`exists\` to say which tenants are real. Without one every host under the root would be approved for a certificate.`)}class P4{root;hostTrust;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;proxySecretHeader;constructor($){zD($),this.root=z1($.root),this.hostTrust=OD($.trustProxy);for(let Z of $.groups??[])if(EJ(Z.subdomain))this.param={...Z,name:Z.subdomain.slice(1)};else this.fixed.set(Z.subdomain.toLowerCase(),Z);this.custom=$.custom??null,this.cacheTtlMs=this.custom?.cacheTtlMs??$D,this.askSecret=$.ask?.secret??null,this.proxySecretHeader=this.hostTrust?.secret?.header??null}forwardedHost($){let Z=this.hostTrust;if(!Z)return null;if(Z.secret&&!x4($.headers.get(Z.secret.header),Z.secret.value))return null;return $.headers.get(Z.header)?.split(",")[0]?.trim()||null}hostOf($){return z1(this.forwardedHost($))??z1(new URL($.url).host)}publicOrigin($){let Z=new URL($.url),O=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),j=O==="http"||O==="https"?O:Z.protocol.replace(/:$/,""),T=this.forwardedHost($),z=T&&z1(T)?TD(T):null;return`${j}://${z??Z.host}`}async resolve($){let Z=this.hostOf($);if(!Z)return null;let O=await this.match(Z,$);if(O)return O;if(this.custom?.fallback&&!this.isUnderRoot(Z))return{host:Z,group:_4,params:{},custom:!0};return null}async allows($,Z){let O=z1($);return O?await this.match(O,Z)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,Z){if($===this.root)return{host:$,group:H3,params:{},custom:!1};if($.endsWith(`.${this.root}`)){let j=$.slice(0,-(this.root.length+1)),T=this.fixed.get(j);if(T)return{host:$,group:T.subdomain,params:{},custom:!1};if(this.param&&S4.test(j)){let z={[this.param.name]:j};if(this.param.exists&&!await this.param.exists(z,Z))return null;return{host:$,group:this.param.subdomain,params:z,custom:!1}}return null}if(!this.custom)return null;let O=await this.resolveCustom($);return O?{host:$,group:this.custom.group,params:O,custom:!0}:null}async resolveCustom($){let Z=Date.now(),O=this.cache.get($);if(O&&O.expiresAt>Z)return this.cache.delete($),this.cache.set($,O),O.value;let j=this.inFlight.get($);if(j)return j;let T=(async()=>await this.custom.resolve($)??null)();this.inFlight.set($,T);let z;try{z=await T}finally{this.inFlight.delete($)}if(this.cacheTtlMs>0){if(this.cache.size>=ZD)this.cache.delete(this.cache.keys().next().value);this.cache.delete($),this.cache.set($,{value:z,expiresAt:Date.now()+this.cacheTtlMs})}return z}forget($){if($===void 0)this.cache.clear();else{let Z=z1($);if(Z)this.cache.delete(Z)}}}var JD="/__gemi__/domains/ask";class s0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,Z){this.groups.set(H3,$);let{domains:O}=Z;if(this.acceptsCustomDomains=Boolean(O?.custom),!O){this.resolver=null;return}this.resolver=new P4(O);let j=(T)=>({api:T.api?new E3({...Z.api,...T.api}):$.api,view:T.view?new sZ({...Z.view,...T.view}):$.view});for(let T of O.groups??[])this.groups.set(T.subdomain,j(T));if(O.custom?.fallback)this.groups.set(_4,j(O.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);if(this.resolver.proxySecretHeader)AJ($,this.resolver.proxySecretHeader);let Z=await this.resolver.resolve($);if(!Z)return null;return e$($,Z),this.dispatchers(Z)}async ask($){if(!this.resolver?.askSecret||$.method!=="GET")return null;let Z=new URL($.url);if(Z.pathname!==JD)return null;if(!x4(Z.searchParams.get("secret"),this.resolver.askSecret))return null;let O=Z.searchParams.get("domain"),j=O?await this.resolver.allows(O,$):!1;return new Response(null,{status:j?200:404})}dispatchers($){return this.groups.get($?.group??H3)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}}function b3($){let Z=new Date($??0).getTime();return Number.isFinite(Z)?Z:0}var HJ=600000;function bJ($,Z){return[TO($,Z),TO($,Z-1)]}class A{static token="auth";config;provider;constructor($={},Z=new Jj){this.config={...vJ(K8($),$),emailCode:Tj($.emailCode)},this.provider=Z}get userProvider(){return this.provider}accessTokenCookieOptions($,Z){return{expires:Z,secure:this.publicOrigin($).startsWith("https://"),httpOnly:!0,domain:this.cookieDomain($)}}publicOrigin($){let Z=C().bound(s0)?C(s0).resolver:null;return Z?Z.publicOrigin($.rawRequest):new URL($.rawRequest.url).origin}cookieDomain($){let Z=this.config.cookieDomain;if(!Z)return;let O=Z==="root"?C(s0).resolver?.root:z1(Z);if(!O)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let j=$.domain?.host??z1(new URL($.rawRequest.url).host);return j===O||j?.endsWith(`.${O}`)?O:void 0}async getSession($,Z){if(!$)return null;if(!r3($))return this.config.migrateLegacySession?this.convertLegacySession($,Z,this.config.migrateLegacySession):null;let O=await this.userProvider.findSession({token:$,userAgent:Z});if(!O?.user)return null;let j=Date.now(),T=b3(O.expiresAt),z=b3(O.absoluteExpiresAt);if(T<=j||z<=j)return await this.userProvider.deleteSession({token:$}),null;let W=await this.slideSession(O,j);return W.user.extension=await this.config.extendSession(W.user),W}async convertLegacySession($,Z,O){let j=N.getStore()?.req;if(!j)return null;let T=Date.now(),z=Math.floor(T/HJ),J=null,W=await this.userProvider.findSession({token:$,userAgent:Z});if(W?.user){if(!await O(W,{token:$,req:j,userAgent:Z}))return null;let X=TO($,z),D=W.user.id;if(await this.userProvider.withLegacySessionLock($,async()=>{if(!await this.userProvider.claimLegacySession({token:$}))return!1;return await this.userProvider.createSessionV2({token:X,userId:D,userAgent:Z,...this.freshLifetime(T)}),!0}))J=X}if(!J){for(let X of bJ($,z))if((await this.userProvider.findSession({token:X,userAgent:Z}))?.user){J=X;break}}if(!J)return null;let Y=await this.getSession(J,Z);if(Y)j.ctx().setCookie("access_token",J,this.accessTokenCookieOptions(j,new Date(Y.expiresAt)));return Y}async revokeSession($,Z){if(!$)return await this.userProvider.deleteSession({token:$}),null;if(r3($)||!this.config.migrateLegacySession){let T=await this.userProvider.findSession({token:$,userAgent:Z});return await this.userProvider.deleteSession({token:$}),T}let O=Math.floor(Date.now()/HJ),j=bJ($,O);return this.userProvider.withLegacySessionLock($,async()=>{let T=await this.userProvider.findSession({token:$,userAgent:Z});for(let z of j){if(T?.user)break;T=await this.userProvider.findSession({token:z,userAgent:Z})}await this.userProvider.deleteSession({token:$});for(let z of j)await this.userProvider.deleteSession({token:z});return T})}requestCarryingCookie($){let Z=N.getStore()?.req;return Z?.cookies.get("access_token")===$?Z:null}async slideSession($,Z){let O=this.config.sessionExpiresInHours*3600000;if(new Date($.expiresAt).getTime()-Z>=O/2)return $;let j=new Date(Math.min(Z+O,new Date($.absoluteExpiresAt).getTime())),T=await this.userProvider.updateSession({token:$.token,expiresAt:j}),z=this.requestCarryingCookie($.token);if(z)z.ctx().setCookie("access_token",$.token,this.accessTokenCookieOptions(z,j));if(!T)return $;return{...$,expiresAt:T.expiresAt??j}}freshLifetime($){return{expiresAt:new Date($+this.config.sessionExpiresInHours*3600000),absoluteExpiresAt:new Date($+this.config.sessionAbsoluteExpiresInHours*3600000)}}async generateMagicLink($){}async upsertSession($){await this.userProvider.findSession({token:"",userAgent:""})}async authenticate($){try{let Z=await this.userProvider.findUserByEmailAddress($,!1);if(!Z)throw Error(`User not found with email: ${$}`);let O=await this.createOrUpdateSession({email:$,id:Z.id}),j=new _;if(j.ctx().setCookie("access_token",O.token,this.accessTokenCookieOptions(j,O.expiresAt)),O?.user)O.user.extension=await this.config.extendSession(O.user);return O}catch(Z){console.log(Z)}}async createOrUpdateSessionV2($){let Z=await this.createOrUpdateSession($),O=null;if(Z?.user)O=await this.config.extendSession(Z.user),Z.user.extension=O;return Z}async createOrUpdateSession($){let Z=new _,O=$.id??(await this.userProvider.findUserByEmailAddress($.email,!1))?.id;if(!O)throw new l1;let j=Bun.env.NODE_ENV==="development"?"local":Z.headers.get("User-Agent"),T=T8(O),z=await this.userProvider.createSessionV2({token:T,userId:O,userAgent:j,...this.freshLifetime(Date.now())}),J=await this.userProvider.findSession({token:T,userAgent:j??""});return J?.user?J:z}async createMagicLinkToken($){let Z=await this.userProvider.findUserByEmailAddress($,!1);if(Z){let{pin:O,token:j}=await this.issueOneTimeCode($,6);return{user:Z,email:$,pin:O,token:j}}return{}}async issueOneTimeCode($,Z){await this.userProvider.deleteMagicLinkToken($);let O=await this.config.generateMagicLinkToken($),j=await this.config.generateCode($),T=typeof j==="string"&&j!==""?j:F8(Z);return await this.userProvider.createMagicLinkToken({email:$,token:zO("link",$,O),pin:zO("pin",$,T)}),{email:$,pin:T,token:O}}async verifyOneTimeCode($,Z,O={}){let{expiresInMinutes:j,maxAttempts:T}=this.config.emailCode,z=await this.userProvider.findMagicLinkTokenByEmail($);if(!z)return YZ("pin",$,null,Z),{status:"invalid"};let J=b3(z.createdAt);if(J+j*60000<=Date.now())return YZ("pin",$,null,Z),{status:"expired"};if(!await B8(z.id,J,T,j))return await this.userProvider.claimMagicLinkToken(z.id),{status:"too_many_attempts"};if(!YZ("pin",$,z.pin,Z))return{status:"invalid"};if(O.claim!==!1&&!await this.userProvider.claimMagicLinkToken(z.id))return{status:"invalid"};return{status:"ok",row:z}}async verifyMagicLinkToken($,Z){let O=await this.userProvider.findMagicLinkTokenByEmail($),j=YZ("link",$,O?.token,Z);if(!O||!j)return!1;if(b3(O.createdAt)+this.config.emailCode.linkExpiresInMinutes*60000<=Date.now())return!1;return await this.userProvider.claimMagicLinkToken(O.id)}}class Y$ extends K0{static getFacadeAccessor(){return A}static async user(){let $=N.getStore(),Z=$?.user;if(!Z){if(Z=await OO(this.getFacadeRoot(),$?.req),Z)$?.setUser(Z)}if(Z)return Z;throw new l1({redirectTo:ZO($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let Z=N.getStore()?.req;return zZ(Z?.search.get(f$),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let Z=await Y$.user();if(!await $(Z))throw new a3}static async guardSafe($){let Z=await Y$.user();try{return await $(Z)}catch(O){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class v3{static ensure($,Z={}){let O=N.getStore();if(O.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return O.serverQueries??=new o$(dZ(O.req.rawRequest)),O.serverQueries.ensure($,Z,"prefetch")}static async instant($,...Z){let O=v3.ensure($,Z[0]);if(await O.promise,O.status==="rejected")throw O.error;return O.data}static prefetch($,...Z){v3.ensure($,Z[0])}static noPrefetch(){let $=N.getStore();if($.req.kind==="api")throw Error("Query.noPrefetch() cannot be called from an API request");$.serverQueries??=new o$(dZ($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}function wJ($,Z,O="/"){let j=new URL($.origin),T=Z.host?Z.host:Z.subdomain?`${Z.subdomain}.${$.root}`:$.root,z=new URL(O.startsWith("/")?O:`/${O}`,j),J=WD(T);if(!J)throw Error(`"${T}" is not a hostname, so there is no URL for it. Give a bare host, optionally with a port \u2014 no scheme, path or credentials.`);if(z.hostname=J.hostname,J.port)z.port=J.port;return z.toString()}function WD($){try{let Z=new URL(`http://${$.trim()}`);return Z.host===$.trim().toLowerCase()&&Z.pathname==="/"?{hostname:Z.hostname,port:Z.port}:null}catch{return null}}class RJ{static absolute($,...Z){return`${process.env.HOST_NAME}${z0(String($),Z[0]??{})}`}static relative($,...Z){return z0(String($),Z[0]??{})}static forDomain($,Z,...O){let j=C(s0).resolver;if(!j)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let T=N.getStore()?.req?.rawRequest,z=T?j.publicOrigin(T):process.env.HOST_NAME;if(!z)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return wJ({root:j.root,origin:z},$,z0(String(Z),O[0]??{}))}}class qJ{name="Meta";static description($){N.getStore().metadata.description($)}static title($){N.getStore().metadata.title($)}static openGraph($){N.getStore().metadata.openGraph($)}}var YD={set($,Z,O){N.getStore().setCookie($,Z,O)},setIfAbsent($,Z,O){if(N.getStore().req.cookies.has($))return!1;return N.getStore().setCookie($,Z,O),!0},delete($,Z){N.getStore().deleteCookie($,Z)}};class C1 extends K0{static getFacadeAccessor(){return kJ}static get client(){return this.getFacadeRoot().client}static get($){return C1.client.get($)}static set($,Z){return C1.client.set($,Z)}static del(...$){return C1.client.del(...$)}static exists($){return C1.client.exists($)}static incr($){return C1.client.incr($)}static expire($,Z){return C1.client.expire($,Z)}static ttl($){return C1.client.ttl($)}}class gJ extends K0{static getFacadeAccessor(){return o0}static consume($,Z={}){return this.getFacadeRoot().consume($,Z)}}class mJ extends K0{static getFacadeAccessor(){return yJ}static run($,Z,O){return this.getFacadeRoot().run($,Z,O)}static acquire($,Z={}){return this.getFacadeRoot().acquire($,Z)}}class pJ extends K0{static getFacadeAccessor(){return a$}static enabled($){return this.getFacadeRoot().enabled($)}static all(){return this.getFacadeRoot().forClient()}static explain($){return this.getFacadeRoot().explain($)}static for($){return this.getFacadeRoot().for($)}static list(){return this.getFacadeRoot().list()}static set($,Z,O){return this.getFacadeRoot().set($,Z,O)}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class w3{bound;constructor($){this.bound=$}get name(){return this.bound??FZ()}get sql(){return this.connection().sql}get dialect(){return this.connection().dialect}async query($){return await this.run($,"query")}async execute($){let Z=await this.run($,"execute");return Number(Z?.count??0)}async transaction($){let Z=this.name,O=this.connection(Z);return lJ(O.sql,(j)=>hJ(Z,()=>$(j)),{slowTransactionThreshold:O.config.slowTransactionThreshold,connection:Z})}async schema(){let $=this.connection(),{introspect:Z}=await import("./chunk-aa13sgs2.js");return Z(this.handle()??$.sql,$.dialect)}run($,Z){let O=this.connection(),{text:j,values:T}=iJ($,dJ(O.dialect),Z);return(this.handle()??O.sql).unsafe(j,T)}handle(){let $=DZ();if($===void 0)return;return FZ()===this.name?$:void 0}connection($=this.name){return cJ($),C(UZ).connection($)}}var OZ=new w3;class uJ extends K0{static getFacadeAccessor(){return UZ}static connection($){return new w3($)}static get sql(){return OZ.sql}static get dialect(){return OZ.dialect}static query($){return OZ.query($)}static execute($){return OZ.execute($)}static transaction($){return OZ.transaction($)}static schema(){return OZ.schema()}static close(){return this.getFacadeRoot().close()}}export{W1 as gc,TZ as hc,m3 as ic,N0 as jc,c3 as kc,g4 as lc,$O as mc,c1 as nc,JW as oc,d3 as pc,V1 as qc,w0 as rc,WW as sc,YW as tc,o3 as uc,r3 as vc,T8 as wc,o0 as xc,WZ as yc,r4 as zc,V$ as Ac,z8 as Bc,J8 as Cc,e3 as Dc,$j as Ec,zO as Fc,YZ as Gc,UU as Hc,K8 as Ic,MW as Jc,Jj as Kc,Y$ as Lc,m1 as Mc,v3 as Nc,RJ as Oc,qJ as Pc,YD as Qc,C1 as Rc,gJ as Sc,mJ as Tc,WJ as Uc,U4 as Vc,YJ as Wc,XJ as Xc,EX as Yc,DJ as Zc,G4 as _c,bX as $c,vX as ad,B4 as bd,FJ as cd,UJ as dd,a$ as ed,pJ as fd,w3 as gd,uJ as hd,p6 as id,h6 as jd,$G as kd,N7 as ld,_7 as md,cZ as nd,BG as od,P7 as pd,E7 as qd,D4 as rd,r$ as sd,K4 as td,I4 as ud,nX as vd,f4 as wd,rX as xd,sZ as yd,M4 as zd,LJ as Ad,MJ as Bd,E3 as Cd,s0 as Dd,A as Ed,i4 as Fd,u4 as Gd,s4 as Hd,$8 as Id,Z8 as Jd,O8 as Kd};
16
+
17
+ //# debugId=AC038C6BF6E23BD964756E2164756E21