gemi 0.119.2 → 0.120.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +2 -2
- package/dist/ai/index.js.map +1 -1
- package/dist/app/index.js +2 -2
- package/dist/app/index.js.map +1 -1
- package/dist/bin/gemi.js +32 -5
- package/dist/bin/gemi.js.map +6 -5
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-x5m12vkw.js → chunk-0ejjgzwc.js} +2 -2
- package/dist/{chunk-x5m12vkw.js.map → chunk-0ejjgzwc.js.map} +1 -1
- package/dist/{chunk-7rffbkmg.js → chunk-0k02tza1.js} +1 -1
- package/dist/{chunk-14xk8kq0.js → chunk-0yj0s1pn.js} +2 -2
- package/dist/{chunk-14xk8kq0.js.map → chunk-0yj0s1pn.js.map} +1 -1
- package/dist/{chunk-6pqbsc5y.js → chunk-19dpzp4y.js} +3 -3
- package/dist/{chunk-6pqbsc5y.js.map → chunk-19dpzp4y.js.map} +1 -1
- package/dist/{chunk-3vt172y7.js → chunk-1wnnkde0.js} +3 -3
- package/dist/{chunk-3vt172y7.js.map → chunk-1wnnkde0.js.map} +1 -1
- package/dist/{chunk-ct1vwaw7.js → chunk-1xdrs2hx.js} +3 -3
- package/dist/{chunk-ct1vwaw7.js.map → chunk-1xdrs2hx.js.map} +1 -1
- package/dist/{chunk-79rtpahn.js → chunk-2c0s0561.js} +2 -2
- package/dist/{chunk-79rtpahn.js.map → chunk-2c0s0561.js.map} +1 -1
- package/dist/{chunk-nfq127pg.js → chunk-2n3pgfnb.js} +2 -2
- package/dist/{chunk-nfq127pg.js.map → chunk-2n3pgfnb.js.map} +1 -1
- package/dist/{chunk-s2h85rbf.js → chunk-32n8t8x6.js} +2 -2
- package/dist/{chunk-s2h85rbf.js.map → chunk-32n8t8x6.js.map} +1 -1
- package/dist/{chunk-6gfsjgra.js → chunk-3gsv1vv1.js} +2 -2
- package/dist/{chunk-6gfsjgra.js.map → chunk-3gsv1vv1.js.map} +1 -1
- package/dist/{chunk-862jeyz0.js → chunk-3wnghdsx.js} +2 -2
- package/dist/{chunk-862jeyz0.js.map → chunk-3wnghdsx.js.map} +1 -1
- package/dist/{chunk-yn4x9wxc.js → chunk-471htqmz.js} +2 -2
- package/dist/{chunk-yn4x9wxc.js.map → chunk-471htqmz.js.map} +1 -1
- package/dist/{chunk-w1zqg54r.js → chunk-48gmyaxc.js} +2 -2
- package/dist/{chunk-w1zqg54r.js.map → chunk-48gmyaxc.js.map} +1 -1
- package/dist/{chunk-299zx9dv.js → chunk-4acpw92g.js} +3 -3
- package/dist/{chunk-299zx9dv.js.map → chunk-4acpw92g.js.map} +1 -1
- package/dist/{chunk-9c5s06gc.js → chunk-4fx8p02c.js} +2 -2
- package/dist/{chunk-9c5s06gc.js.map → chunk-4fx8p02c.js.map} +1 -1
- package/dist/{chunk-xpz1bp50.js → chunk-51w5ktv2.js} +3 -3
- package/dist/{chunk-xpz1bp50.js.map → chunk-51w5ktv2.js.map} +1 -1
- package/dist/{chunk-9qkjkse0.js → chunk-5nj94s66.js} +4 -4
- package/dist/{chunk-9qkjkse0.js.map → chunk-5nj94s66.js.map} +1 -1
- package/dist/{chunk-j632p533.js → chunk-5tdxbwzg.js} +3 -3
- package/dist/{chunk-j632p533.js.map → chunk-5tdxbwzg.js.map} +1 -1
- package/dist/{chunk-zq1bhsdg.js → chunk-65beps2q.js} +3 -3
- package/dist/{chunk-zq1bhsdg.js.map → chunk-65beps2q.js.map} +1 -1
- package/dist/{chunk-xeh1mw1d.js → chunk-6yhpprzs.js} +3 -3
- package/dist/{chunk-xeh1mw1d.js.map → chunk-6yhpprzs.js.map} +1 -1
- package/dist/{chunk-620yeafr.js → chunk-7ftj43vp.js} +2 -2
- package/dist/{chunk-620yeafr.js.map → chunk-7ftj43vp.js.map} +1 -1
- package/dist/{chunk-4kj4e22e.js → chunk-7g649j8h.js} +2 -2
- package/dist/{chunk-4kj4e22e.js.map → chunk-7g649j8h.js.map} +1 -1
- package/dist/{chunk-675kzd7z.js → chunk-7mmw0jr2.js} +2 -2
- package/dist/{chunk-675kzd7z.js.map → chunk-7mmw0jr2.js.map} +1 -1
- package/dist/{chunk-k1ncgq7p.js → chunk-9d2d08qm.js} +2 -2
- package/dist/{chunk-k1ncgq7p.js.map → chunk-9d2d08qm.js.map} +1 -1
- package/dist/{chunk-wdg83tgd.js → chunk-9rr5h818.js} +3 -3
- package/dist/{chunk-wdg83tgd.js.map → chunk-9rr5h818.js.map} +1 -1
- package/dist/{chunk-30xxc6r7.js → chunk-9xyxbxgk.js} +2 -2
- package/dist/{chunk-30xxc6r7.js.map → chunk-9xyxbxgk.js.map} +1 -1
- package/dist/{chunk-khd9ft0s.js → chunk-ar4d3vmr.js} +3 -3
- package/dist/{chunk-khd9ft0s.js.map → chunk-ar4d3vmr.js.map} +1 -1
- package/dist/chunk-b5a5vvkk.js +57 -0
- package/dist/{chunk-bz5gda3b.js.map → chunk-b5a5vvkk.js.map} +7 -6
- package/dist/{chunk-6ggmk2eg.js → chunk-c0v61fp5.js} +2 -2
- package/dist/{chunk-6ggmk2eg.js.map → chunk-c0v61fp5.js.map} +1 -1
- package/dist/{chunk-bw2pfaz3.js → chunk-c7qs1xp3.js} +2 -2
- package/dist/{chunk-bw2pfaz3.js.map → chunk-c7qs1xp3.js.map} +1 -1
- package/dist/{chunk-2kegxt0s.js → chunk-cca0grq3.js} +2 -2
- package/dist/{chunk-2kegxt0s.js.map → chunk-cca0grq3.js.map} +1 -1
- package/dist/{chunk-b336h3hj.js → chunk-cskqet01.js} +2 -2
- package/dist/{chunk-b336h3hj.js.map → chunk-cskqet01.js.map} +1 -1
- package/dist/{chunk-pzk2a5sr.js → chunk-cvr5624r.js} +1 -1
- package/dist/chunk-cytq2msw.js +24 -0
- package/dist/{chunk-w8d37mcq.js.map → chunk-cytq2msw.js.map} +3 -3
- package/dist/{chunk-8507ez1g.js → chunk-d2c3947c.js} +2 -2
- package/dist/{chunk-8507ez1g.js.map → chunk-d2c3947c.js.map} +1 -1
- package/dist/{chunk-q0djcyj2.js → chunk-d5f1m3d2.js} +2 -2
- package/dist/{chunk-q0djcyj2.js.map → chunk-d5f1m3d2.js.map} +1 -1
- package/dist/{chunk-f9tfpn3w.js → chunk-dedqr5wb.js} +2 -2
- package/dist/{chunk-f9tfpn3w.js.map → chunk-dedqr5wb.js.map} +1 -1
- package/dist/{chunk-h02kyxgg.js → chunk-dhbgrv58.js} +1 -1
- package/dist/{chunk-d4dd7jde.js → chunk-dwedx1jb.js} +3 -3
- package/dist/{chunk-d4dd7jde.js.map → chunk-dwedx1jb.js.map} +1 -1
- package/dist/{chunk-5crtgt1y.js → chunk-ep0baa9g.js} +2 -2
- package/dist/{chunk-5crtgt1y.js.map → chunk-ep0baa9g.js.map} +1 -1
- package/dist/{chunk-kk77x2v4.js → chunk-er8acmch.js} +7 -7
- package/dist/{chunk-kk77x2v4.js.map → chunk-er8acmch.js.map} +3 -3
- package/dist/{chunk-thz75w6e.js → chunk-fcqx2t0p.js} +2 -2
- package/dist/{chunk-thz75w6e.js.map → chunk-fcqx2t0p.js.map} +1 -1
- package/dist/{chunk-1p87gdd2.js → chunk-fenc5tpv.js} +2 -2
- package/dist/{chunk-1p87gdd2.js.map → chunk-fenc5tpv.js.map} +1 -1
- package/dist/{chunk-fmea4sak.js → chunk-gc2dz11k.js} +2 -2
- package/dist/{chunk-fmea4sak.js.map → chunk-gc2dz11k.js.map} +1 -1
- package/dist/{chunk-qxxbp3nn.js → chunk-gemzbw7f.js} +2 -2
- package/dist/{chunk-qxxbp3nn.js.map → chunk-gemzbw7f.js.map} +1 -1
- package/dist/{chunk-qpy25jj9.js → chunk-gy81nd9a.js} +2 -2
- package/dist/{chunk-qpy25jj9.js.map → chunk-gy81nd9a.js.map} +1 -1
- package/dist/{chunk-c8vttyem.js → chunk-h43jp8ws.js} +2 -2
- package/dist/{chunk-c8vttyem.js.map → chunk-h43jp8ws.js.map} +1 -1
- package/dist/chunk-htgmy3x7.js +5 -0
- package/dist/{chunk-15v719sq.js.map → chunk-htgmy3x7.js.map} +1 -1
- package/dist/{chunk-xqd3zde5.js → chunk-jaa6xkeh.js} +2 -2
- package/dist/{chunk-xqd3zde5.js.map → chunk-jaa6xkeh.js.map} +1 -1
- package/dist/{chunk-2bja99cq.js → chunk-kk18xqgc.js} +2 -2
- package/dist/{chunk-2bja99cq.js.map → chunk-kk18xqgc.js.map} +1 -1
- package/dist/{chunk-mcjbck8e.js → chunk-krk7mcgm.js} +3 -3
- package/dist/{chunk-mcjbck8e.js.map → chunk-krk7mcgm.js.map} +1 -1
- package/dist/{chunk-hd5ztshp.js → chunk-krtybgz1.js} +2 -2
- package/dist/{chunk-hd5ztshp.js.map → chunk-krtybgz1.js.map} +1 -1
- package/dist/{chunk-fjhnn3de.js → chunk-m53fgf20.js} +3 -3
- package/dist/{chunk-fjhnn3de.js.map → chunk-m53fgf20.js.map} +1 -1
- package/dist/{chunk-4c1npv8k.js → chunk-m83zm86m.js} +2 -2
- package/dist/{chunk-4c1npv8k.js.map → chunk-m83zm86m.js.map} +1 -1
- package/dist/{chunk-q6a30w8w.js → chunk-meg8rtr6.js} +2 -2
- package/dist/{chunk-q6a30w8w.js.map → chunk-meg8rtr6.js.map} +1 -1
- package/dist/{chunk-vy0tnx2s.js → chunk-mr94nfp1.js} +3 -3
- package/dist/{chunk-vy0tnx2s.js.map → chunk-mr94nfp1.js.map} +1 -1
- package/dist/{chunk-zb8zzf5x.js → chunk-nz8z8jr1.js} +3 -3
- package/dist/{chunk-zb8zzf5x.js.map → chunk-nz8z8jr1.js.map} +1 -1
- package/dist/{chunk-d38x71xy.js → chunk-pemhmjzp.js} +3 -3
- package/dist/{chunk-d38x71xy.js.map → chunk-pemhmjzp.js.map} +1 -1
- package/dist/{chunk-d2v78b77.js → chunk-pn2x59ge.js} +3 -3
- package/dist/{chunk-d2v78b77.js.map → chunk-pn2x59ge.js.map} +1 -1
- package/dist/{chunk-qm6j85fq.js → chunk-qphjhpad.js} +2 -2
- package/dist/{chunk-qm6j85fq.js.map → chunk-qphjhpad.js.map} +1 -1
- package/dist/{chunk-p5xy9cn8.js → chunk-qsz9241c.js} +2 -2
- package/dist/{chunk-p5xy9cn8.js.map → chunk-qsz9241c.js.map} +1 -1
- package/dist/{chunk-d6nhcqvt.js → chunk-qy8c0gzr.js} +2 -2
- package/dist/{chunk-d6nhcqvt.js.map → chunk-qy8c0gzr.js.map} +1 -1
- package/dist/{chunk-7ns5506p.js → chunk-r01aqf0q.js} +2 -2
- package/dist/{chunk-7ns5506p.js.map → chunk-r01aqf0q.js.map} +1 -1
- package/dist/{chunk-0p6mdba6.js → chunk-rhvc1axc.js} +2 -2
- package/dist/{chunk-0p6mdba6.js.map → chunk-rhvc1axc.js.map} +1 -1
- package/dist/{chunk-pjz79c2c.js → chunk-s07v65x6.js} +3 -3
- package/dist/{chunk-pjz79c2c.js.map → chunk-s07v65x6.js.map} +1 -1
- package/dist/{chunk-q00f25na.js → chunk-s5k3yq6t.js} +2 -2
- package/dist/{chunk-q00f25na.js.map → chunk-s5k3yq6t.js.map} +1 -1
- package/dist/{chunk-ty8gxbgj.js → chunk-s6vvqsd0.js} +3 -3
- package/dist/{chunk-ty8gxbgj.js.map → chunk-s6vvqsd0.js.map} +3 -3
- package/dist/{chunk-2854taf5.js → chunk-sx340k85.js} +2 -2
- package/dist/{chunk-2854taf5.js.map → chunk-sx340k85.js.map} +1 -1
- package/dist/{chunk-j5q5ysng.js → chunk-tewhms9w.js} +2 -2
- package/dist/{chunk-j5q5ysng.js.map → chunk-tewhms9w.js.map} +1 -1
- package/dist/{chunk-7pxdvvrz.js → chunk-tk135gmj.js} +3 -3
- package/dist/{chunk-7pxdvvrz.js.map → chunk-tk135gmj.js.map} +1 -1
- package/dist/{chunk-yvd4pgd9.js → chunk-vx7hvyvq.js} +2 -2
- package/dist/{chunk-yvd4pgd9.js.map → chunk-vx7hvyvq.js.map} +1 -1
- package/dist/{chunk-xecnc8zv.js → chunk-wjkh2gem.js} +1 -1
- package/dist/{chunk-511zqetr.js → chunk-wqe47c0j.js} +2 -2
- package/dist/{chunk-511zqetr.js.map → chunk-wqe47c0j.js.map} +1 -1
- package/dist/{chunk-2y0r4b7g.js → chunk-y6wt5b6t.js} +1 -1
- package/dist/{chunk-kkx8a35r.js → chunk-yds7zwc3.js} +2 -2
- package/dist/{chunk-kkx8a35r.js.map → chunk-yds7zwc3.js.map} +1 -1
- package/dist/{chunk-w7am9q0q.js → chunk-zefs2b6h.js} +2 -2
- package/dist/{chunk-w7am9q0q.js.map → chunk-zefs2b6h.js.map} +1 -1
- package/dist/{chunk-de4t48j9.js → chunk-zg6hmc48.js} +1 -1
- package/dist/{chunk-svn6zvzd.js → chunk-zrcd9hxr.js} +2 -2
- package/dist/{chunk-svn6zvzd.js.map → chunk-zrcd9hxr.js.map} +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +26 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/staticNavigation.d.ts +26 -0
- package/dist/client/staticNavigation.d.ts.map +1 -0
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/ViewRouter.d.ts +36 -2
- package/dist/http/ViewRouter.d.ts.map +1 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +2 -2
- package/dist/i18n/dictionaryRuntime.js.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +2 -2
- package/dist/internal/islandRuntime.d.ts +16 -0
- package/dist/internal/islandRuntime.d.ts.map +1 -1
- package/dist/internal/staticNavigationRuntime.d.ts +8 -0
- package/dist/internal/staticNavigationRuntime.d.ts.map +1 -0
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +2 -2
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +1 -1
- package/dist/server/devFetch.d.ts.map +1 -1
- package/dist/server/httpProd.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +3 -3
- package/dist/services/index.js.map +2 -2
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/services/router/ViewRouteDispatcher.d.ts +5 -0
- package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
- package/dist/services/router/staticDocument.d.ts +30 -21
- package/dist/services/router/staticDocument.d.ts.map +1 -1
- package/dist/stats/bundleStats.d.ts +6 -2
- package/dist/stats/bundleStats.d.ts.map +1 -1
- package/dist/stats/route-table.js +2 -2
- package/dist/stats/route-table.js.map +3 -3
- package/dist/stats/routeTable.d.ts +5 -1
- package/dist/stats/routeTable.d.ts.map +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +185 -2
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/staticDocument.d.ts +80 -0
- package/dist/testing/staticDocument.d.ts.map +1 -0
- package/dist/vitest/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-15v719sq.js +0 -5
- package/dist/chunk-bz5gda3b.js +0 -57
- package/dist/chunk-w8d37mcq.js +0 -24
- /package/dist/{chunk-7rffbkmg.js.map → chunk-0k02tza1.js.map} +0 -0
- /package/dist/{chunk-pzk2a5sr.js.map → chunk-cvr5624r.js.map} +0 -0
- /package/dist/{chunk-h02kyxgg.js.map → chunk-dhbgrv58.js.map} +0 -0
- /package/dist/{chunk-xecnc8zv.js.map → chunk-wjkh2gem.js.map} +0 -0
- /package/dist/{chunk-2y0r4b7g.js.map → chunk-y6wt5b6t.js.map} +0 -0
- /package/dist/{chunk-de4t48j9.js.map → chunk-zg6hmc48.js.map} +0 -0
package/dist/chunk-bz5gda3b.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{gf as WG}from"./chunk-zq1bhsdg.js";import{Af as JG}from"./chunk-fjhnn3de.js";import{$f as E3,Bf as kZ,Cg as Oz,Dg as A$,Eg as vX,Ff as NX,Fg as uX,Gf as X5,Hf as G5,Hg as lX,If as R8,Jf as _8,Mf as S8,Nf as x8,Of as CZ,Pf as ZX,Qf as xX,Rf as hJ,Sf as g,Xf as S,Yf as n8,Zf as m$,_f as b8,bg as J$,cg as c,dg as J8,rg as R3,yg as p$}from"./chunk-299zx9dv.js";import{Kg as _Z,Lg as P0,Mg as w1,Ng as K5}from"./chunk-2kegxt0s.js";import{Og as lz,Pg as O8,Qg as H}from"./chunk-4c1npv8k.js";import{Tg as Xz,Wg as U3}from"./chunk-ct1vwaw7.js";import{_g as l5,bh as qX}from"./chunk-6pqbsc5y.js";import{th as P3,yh as SZ}from"./chunk-kkx8a35r.js";import{Oh as kX}from"./chunk-q6a30w8w.js";import{Ph as I8}from"./chunk-c8vttyem.js";import{Qh as LX,Rh as V1,Sh as z$,Th as $G,Uh as ZG,Wh as EJ,Xh as cX,ei as jG}from"./chunk-pjz79c2c.js";import{ti as X$}from"./chunk-fmea4sak.js";import{Di as IJ,yi as IX}from"./chunk-b336h3hj.js";import{Ki as TX,Pi as a}from"./chunk-1p87gdd2.js";import{Qi as HZ,Ti as T}from"./chunk-zb8zzf5x.js";import{Wi as iX}from"./chunk-nfq127pg.js";import{fj as HX}from"./chunk-0p6mdba6.js";import{kj as B8}from"./chunk-j5q5ysng.js";function H3($){return typeof $==="function"&&$.prototype!==void 0}function K1($){return typeof $==="string"?[$]:$}function C3($,Z){let j=Z?"attachment":"inline",J=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${j}; filename="${J}"; filename*=UTF-8''${encodeURIComponent($)}`}function UG($){return"total"in $&&"partial"in $&&"body"in $}function wJ(){return new Response("Not found",{status:404,headers:{"X-Content-Type-Options":"nosniff"}})}function fZ($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":x8($),"Content-Length":"0","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}})}async function VG($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(UG($))return{body:$.body,start:$.start,end:$.end,total:$.total,partial:$.partial,type:$.type,name:$.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}};let Z=$.file,j=Z instanceof Blob?Z:null,J=$.total??j?.size??-1;return{body:Z,start:$.start??0,end:$.end??J-1,total:J,partial:$.partial??!1,type:$.type??j?.type??"",name:$.name??Z?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function A8($,Z){if($ instanceof Response)return $;if(!$)return wJ();let j=await VG($),{body:J,start:W,end:Y,total:z,partial:X}=j;if(J instanceof Blob&&"exists"in J&&typeof J.exists==="function"){if(!await J.exists())return wJ()}let{range:G}=Z;if(G){if(z<=0)return fZ(Math.max(z,0));if(!X){if(J instanceof Blob){let K=_8(G,z);if(!K)return fZ(z);J=J.slice(K.start,K.end+1),W=K.start,Y=K.end,X=!0}}}let F=Boolean(G)&&X,Q=F?206:j.status,O=new Headers;if(O.set("Accept-Ranges","bytes"),O.set("Content-Type",j.type||"application/octet-stream"),O.set("X-Content-Type-Options","nosniff"),F)O.set("Content-Range",S8(W,Y,z)),O.set("Content-Length",String(Y-W+1));else if(z>=0)O.set("Content-Length",String(z));if(j.name)O.set("Content-Disposition",C3(j.name,j.download));if(j.etag)O.set("ETag",j.etag);if(j.lastModified)O.set("Last-Modified",j.lastModified.toUTCString());for(let[K,D]of Object.entries(j.extraHeaders))O.set(K,D);if((Z.method??"GET").toUpperCase()==="HEAD"){if(J&&"cancel"in J&&typeof J.cancel==="function")await J.cancel();return new Response(null,{status:Q,headers:O})}return new Response(J,{status:Q,headers:O})}class k$ extends P0{limit;constructor($){super("The request body is too large.",{status:413});this.limit=$}}var kJ={b:1,k:1024,kb:1024,m:1048576,mb:1048576,g:1073741824,gb:1073741824};function RZ($){if(typeof $==="number"){if(Number.isFinite($)&&$>=0)return Math.floor($);if($===1/0)return 1/0}else{let Z=$.trim().toLowerCase();if(Z==="none"||Z==="off")return 1/0;let j=/^(\d+(?:\.\d+)?)\s*([a-z]*)$/.exec(Z);if(j&&(j[2]===""||(j[2]in kJ)))return Math.floor(Number(j[1])*(kJ[j[2]]??1))}throw Error(`Invalid body limit ${JSON.stringify($)}. Use a byte count or a size such as "64kb", "1mb" or "none".`)}var EZ=new WeakMap;function qJ($){return EZ.has($)}function gJ($){return EZ.get($)?.limit??null}function mJ($){let Z=EZ.get($);return Z?Z.read>Z.limit:!1}function TG($){let Z=$.headers.get("Content-Length");if(Z===null||!/^\s*\d+\s*$/.test(Z))return null;return Number(Z)}function E8($,Z){let j=TG($);if(j!==null&&j>Z)throw new k$(Z)}function _3($,Z,j={}){let J=EZ.get($);if(J)J.limit=Z;else{let W={limit:Z,read:0,stream:void 0,used:!1};EZ.set($,W),MG($,W)}if(j.checkDeclared!==!1)E8($,Z)}function IG($){return Reflect.get(Object.getPrototypeOf($),"body",$)??null}function f8($,Z){if(Z.stream!==void 0)return Z.stream;let j=IG($);if(!j)return Z.stream=null;let J;return Z.stream=new ReadableStream({async pull(W){J??=j.getReader();let{done:Y,value:z}=await J.read();if(Y){W.close();return}if(Z.read+=z.byteLength,Z.read>Z.limit){let X=new k$(Z.limit);W.error(X),J.cancel(X).catch(()=>{});return}W.enqueue(z)},cancel(W){return J?J.cancel(W):j.cancel(W)}},{highWaterMark:0}),Z.stream}async function w$($,Z){if(E8($,Z.limit),Z.used||Z.stream?.locked)throw TypeError("Body already used");Z.used=!0;let j=f8($,Z);if(!j)return new Uint8Array(0);let J=j.getReader(),W=[],Y=0;for(;;){let{done:G,value:F}=await J.read();if(G)break;W.push(F),Y+=F.byteLength}let z=new Uint8Array(Y),X=0;for(let G of W)z.set(G,X),X+=G.byteLength;return z}function yJ($){return $.headers.get("Content-Type")??""}function MG($,Z){let j=(J,W)=>Object.defineProperty($,J,{configurable:!0,...W});j("body",{get:()=>f8($,Z)}),j("bodyUsed",{get:()=>Z.used||Boolean(Z.stream?.locked)||Reflect.get(Object.getPrototypeOf($),"bodyUsed",$)}),j("bytes",{value:()=>w$($,Z)}),j("arrayBuffer",{value:async()=>{let J=await w$($,Z);return J.buffer.slice(J.byteOffset,J.byteOffset+J.byteLength)}}),j("text",{value:async()=>new TextDecoder().decode(await w$($,Z))}),j("json",{value:async()=>JSON.parse(new TextDecoder().decode(await w$($,Z)))}),j("blob",{value:async()=>new Blob([await w$($,Z)],{type:yJ($)})}),j("formData",{value:async()=>new Response(await w$($,Z),{headers:{"Content-Type":yJ($)}}).formData()}),j("clone",{value:()=>{E8($,Z.limit);let J=f8($,Z),W=null;if(J){let[Y,z]=J.tee();Z.stream=Y,W=z}return new Request($.url,{method:$.method,headers:$.headers,body:W,signal:$.signal,duplex:"half"})}})}function pJ($){return H3($)}class j0{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,Z,j){this.method=$;this.handler=Z;this.methodName=j;this.handler=Z,this.methodName=j,this.method=$}get source(){if(!pJ(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(pJ(this.handler)){let Z=new this.handler;return Z[this.methodName].bind(Z)()}return this.handler()}middleware($){return this.middlewares=K1($),this}}class cJ{url;headers;__internal_brand="ProxyHandler";middlewares=[];constructor($,Z){this.url=$;this.headers=Z}middleware($){return this.middlewares=K1($),this}async run(){let $=new S,Z=$.headers.toJSON();for(let j of hJ($.rawRequest))delete Z[j];try{return await fetch(this.url,{method:$.rawRequest.method,headers:{...Z,...this.headers},body:$.rawRequest.body})}catch(j){if(mJ($.rawRequest))throw new k$(gJ($.rawRequest));throw j}}}class dJ{constructor(...$){return new j0(...$)}}class uJ extends j0{__internal_brand="StreamHandler";async run($){let Z=H.getStore(),j=Z?.req?.rawRequest,J=R8(j?.headers.get("Range"));if(Z)Z.rangeRequest=J;try{let W=await super.run($);return await A8(W,{range:J,method:j?.method})}catch(W){if(W instanceof b8)return fZ(W.total);throw W}finally{if(Z)Z.rangeRequest=null}}}class lJ{constructor(...$){return new uJ(...$)}}class iJ{__internal_brand="ResourceRoutes";first;second;constructor($){this.first={get:new j0("GET",$,"list"),post:new j0("POST",$,"store")},this.second={get:new j0("GET",$,"show"),put:new j0("PUT",$,"update"),delete:new j0("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 f0{static __brand="ApiRouter";routes={};middlewares=[];middleware($){}get($,Z){return new j0("GET",$,Z)}post($,Z){return new j0("POST",$,Z)}put($,Z){return new j0("PUT",$,Z)}patch($,Z){return new j0("PATCH",$,Z)}delete($,Z){return new j0("DELETE",$,Z)}resource($){return new iJ($)}agent($){if($.kind!=="agent-controller")throw TypeError(`this.agent() takes an AgentController class, and got ${PG($)}.`);return NG($,this)}file($,Z){return new dJ("GET",$,Z)}stream($,Z){return new lJ("GET",$,Z)}proxy($,Z={}){return new cJ($,Z)}}function PG($){if(typeof $==="function"&&$.name)return $.name;return typeof $}function NG($,Z){let j={stream:new j0("POST",$,"stream"),attach:new j0("POST",$,"attach"),stop:new j0("POST",$,"stop"),upload:new j0("POST",$,"upload")};return class extends f0{static __internal_brand="AgentRoute";static controller=$;static handlers=j;constructor(){super();this.middlewares=[...Z?.middlewares??[]]}routes={"/":j.stream,"/attach":j.attach,"/stop":j.stop,"/files":j.upload};static middleware(W){if(W.stream)j.stream.middleware(W.stream);if(W.attach)j.attach.middleware(W.attach);if(W.stop)j.stop.middleware(W.stop);if(W.upload)j.upload.middleware(W.upload);return this}}}class v8{as;input;bind;__internal_brand="McpModelParam";constructor($,Z,j){this.as=$;this.input=Z;this.bind=j}}class w8{method;url;meta;__internal_brand="McpRoute";constructor($,Z,j){this.method=$;this.url=Z;this.meta=j}}class sJ{static __brand="McpRouter";routes={};scopes;param($){return new v8($.as,$.input,$.bind)}fromApiRoute($,Z,j){return new w8($,Z,j)}}function F0($,Z){return $.replace(/:([^/]+[*?]?)/g,(j,J)=>{let W=J.endsWith("?")||J.endsWith("*"),Y=W?J.slice(0,-1):J,z=Z[Y];if(z===void 0){if(W)return"";if(import.meta.env.DEV)throw Error(`Missing parameter: ${Y}`);console.error(`Missing parameter: ${Y} in URL: ${$}`)}return String(z)}).replace(/\/\//g,"/").replace(/\/$/,"")}class k8 extends P0{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 O1{static to($,...Z){let[j={}]=Z,{search:J={},params:W={},permanent:Y,status:z}={params:{},status:307,permanent:!1,...j},X=new URLSearchParams(J).toString();throw new k8([F0($,W)||"/",X.toString()].filter(Boolean).join("?"),z??(Y?301:307))}static external($,Z=307){throw new k8($,Z)}}var nJ=Symbol.for("gemi.HttpResponse");class j${kind;body;status;headers;[nJ]=!0;constructor($,Z,j,J){this.kind=$;this.body=Z;this.status=j;this.headers=J}static json($,Z={}){let j=Z.status??200;return LG(j),new j$("json",$,j,new Headers(Z.headers))}static error($,Z,j={}){if(!Number.isInteger($)||$<400||$>599)throw RangeError(`HttpResponse.error: status must be an integer from 400 to 599, got ${$}.`);return j$.json({error:Z},{...j,status:$})}get ok(){return this.status>=200&&this.status<300}toResponse($,Z){let j=$,J=this.serialize(j);for(let W of Z)j.append("Set-Cookie",W);this.headers.forEach((W,Y)=>{if(Y.toLowerCase()!=="set-cookie")j.set(Y,W)});for(let W of this.headers.getSetCookie())j.append("Set-Cookie",W);if(this.status>=400&&!this.headers.has("Cache-Control"))j.set("Cache-Control","no-store");return new Response(J,{status:this.status,headers:j})}serialize($){switch(this.kind){case"json":return $.set("Content-Type","application/json"),JSON.stringify(this.body)??null}}}function LG($){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 y$($){return typeof $==="object"&&$!==null&&$[nJ]===!0}function HG($,Z,j={}){return j$.error($,Z,j)}class oJ{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[Z,j]=$;this.handler=(J)=>{return new Z()[j](J)}}}async run($,Z){let{destination:j,permanent:J=!1,status:W=307}=await this.handler($);if(!j)throw Error(`Redirect destination is required see ${Z}`);return O1.to(j,{permanent:J,status:W}),{}}middleware($){return this.middlewares=K1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function y8($,Z){if($ instanceof Response)return $;let j=$ instanceof Blob,J=j?$:$.file,W=j?$.name:$.name??$.file?.name,Y=(j?$.type:$.type??$.file?.type)||"",z=j?!1:$.download??!1,X=j?200:$.status??200;if(!j)for(let[G,F]of Object.entries($.headers??{}))Z.set(G,F);if(J instanceof Blob&&"exists"in J&&typeof J.exists==="function"){if(!await J.exists())return new Response("Not found",{status:404})}if(Z.set("Content-Type",Y||"application/octet-stream"),J instanceof Blob)Z.set("Content-Length",String(J.size));if(W)Z.set("Content-Disposition",C3(W,z));return new Response(J instanceof Blob?J.stream():J,{status:X,headers:Z})}class aJ{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[Z,j]=$;this.handler=(J)=>{return new Z()[j](J)}}}async run($,Z){let j=await this.handler($);if(!j)throw Error(`File route handler must return a file see ${Z}`);return{FILE:j}}middleware($){return this.middlewares=K1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}function rJ($,Z){if(y$($))throw Error(`The handler of view "${Z}" returned an HttpResponse. HttpResponse is for api routes; a view handler returns its props.`);return $}class tJ{viewPath;middlewares=[];featureGates=[];staticOptions=null;handler;constructor($,Z){this.viewPath=$;if(!Z)this.handler=()=>({});else if(typeof Z==="function")this.handler=Z;else{let[j,J]=Z;this.handler=(W)=>{return new j()[J](W)}}}async run($,Z){let j=rJ(await this.handler($),this.viewPath);return{[this.viewPath]:{...j,breadcrumb:{label:j?.breadcrumb??"",href:Z}}}}middleware($){return this.middlewares=K1($),this}static($={}){return this.staticOptions={...$},this}feature($){return this.featureGates=[...this.featureGates,$],this}}class eJ{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,Z,j){this.viewPath=$;if(typeof Z==="function")this.handler=Z,this.children=class extends B1{routes=j??{}};else if(Array.isArray(Z)){let[J,W]=Z;this.handler=(Y)=>{return new J()[W](Y)},this.children=class extends B1{routes=j??{}}}else this.children=class extends B1{routes=Z},this.handler=()=>({})}async run($,Z){let j=rJ(await this.handler($),this.viewPath);return{[this.viewPath]:{...j,breadcrumb:{label:j?.breadcrumb??"",href:Z}}}}alwaysRun(){return this.alwaysRuns=!0,this}middleware($){return this.middlewares=K1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class B1{middlewares=[];featureGates=[];routes={};view($,Z){return new tJ($,Z)}file($){return new aJ($)}redirect($){return new oJ($)}layout($,Z,j){return new eJ($,Z,j)}}class o{req;static runsOnRefusal=!1;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let Z=this;return class extends Z{config=$}}}function CG($){return $}function _G(){return{aliases:{},global:[],bodyLimit:null}}var D1="redirect";function U1($,Z="/"){if(typeof $!=="string"||!$.startsWith("/"))return Z;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return Z;try{let j=new URL($,"http://gemi.invalid");if(j.origin!=="http://gemi.invalid")return Z;let J=`${j.search}${j.hash}`.replaceAll("/","%2F"),W=`${j.pathname}${J}`.replaceAll(":","%3A");return W.startsWith("//")?Z:W}catch{return Z}}function q$($){let Z=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return Z?Z==="https":new URL($.url).protocol==="https:"}function SG($,Z=!0){let j=new URL($.rawRequest.url),J=j.pathname.replace(/\.(json|og)$/,""),[,W,...Y]=J.split("/");if(T(a).supportedLocales.includes(W))J=`/${Y.join("/")}`;return Z?`${J}${j.search}`:J}function xG($,Z){let j=(J)=>J.replace(/\/+$/,"")||"/";return j($)===j(Z)}function S3($,Z){let j=Z||T(E).config.signInPath,J=/^[a-z][a-z\d+.-]*:/i.test(j);if(J?!/^https?:\/\//i.test(j):!j.startsWith("/"))throw Error(`\`auth.signInPath\` must be a path like "/auth/sign-in", or an http(s) URL for sign-in hosted elsewhere. Got "${j}". A route's own \`"auth:<path>"\` cannot carry a URL, because the alias parser splits it on the colon.`);let W=new URL(j,"http://gemi.invalid");if($?.kind==="view"){let Y=SG($,!J);if(J||!xG(new URL(Y,W).pathname,W.pathname))W.searchParams.set(D1,Y)}return J?W.href:`${W.pathname}${W.search}`}var v1="access_token";function bZ($){return $?.cookies?.get("access_token")||$?.headers?.get("access_token")||null}async function x3($,Z){let j=bZ(Z);if(!j)return null;return(await $.getSession(j,Z.headers.get("User-Agent")))?.user??null}class $5 extends o{async run($){let Z=H.getStore(),j=Z.req;if(Z.user)return{};let J=await x3(T(E),j);if(!J)throw new J$({redirectTo:S3(j,$)});return Z.setUser(J),{}}}var g8="gemi_same_site",q8="private, no-cache, no-store, max-age=0, must-revalidate";class A3 extends o{run(){let $=H.getStore(),Z=$?.req;if(!Z||$.user)return{};let j=Z.rawRequest;if(Z.kind!=="view"||j.method!=="GET"&&j.method!=="HEAD")return{};let J=new URL(j.url);if(/\.(json|og)$/.test(J.pathname))return{};if(J.searchParams.has(g8))return{};if(bZ(Z))return{};let W=j.headers.get("Sec-Fetch-Site");if(W&&W!=="cross-site")return{};throw J.searchParams.set(g8,"1"),new Z5(`${J.pathname}${J.search}`)}}class Z5 extends P0{location;constructor($){super("Same-site bounce");this.location=$;this.name="SameSiteBounce";let Z=AG($),j={"Content-Type":"text/html; charset=utf-8","Cache-Control":q8,"Referrer-Policy":"no-referrer","X-Robots-Tag":"noindex"};this.payload={api:{status:401,data:{},headers:{"Cache-Control":q8}},viewData:{status:200,data:{},headers:{"Cache-Control":q8},directive:{kind:"Redirect",path:$}},view:{status:200,headers:j,body:`<!doctype html><html><head><meta charset="utf-8"><meta name="robots" content="noindex"><meta name="referrer" content="no-referrer"><meta http-equiv="refresh" content="0;url=${Z}"><title>Redirecting</title></head><body><p><a href="${Z}">Continue</a></p></body></html>`}}}}function AG($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}class j5 extends o{async run(...$){let[Z="public",j="864000",...J]=$,W=`${Z}, max-age=${j}${J.length>0?", ":""}${J.join(", ")}`;if($.length===0)W="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="public")W="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="private")W="private, max-age=0, stale-while-revalidate=300, stale-if-error=600";if(this.req.rawRequest.method==="GET")this.req.ctx().setHeaders("Cache-Control",W);return{}}}var J5={"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 W5 extends o{static runsOnRefusal=!0;config={origins:{"":{"Access-Control-Allow-Methods":"GET, HEAD, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Allow-Credentials":"true"}}};run(){let $=this.req,Z=$.rawRequest.headers.get("Origin");if(Z&&this.config.origins[Z]){$.ctx().setHeaders("Access-Control-Allow-Origin",Z);let j={...J5,...this.config.origins[Z]};for(let[J,W]of Object.entries(j))$.ctx().setHeaders(J,W)}else if(Z&&this.config.origins["*"]){$.ctx().setHeaders("Access-Control-Allow-Origin","*");let j={...J5,...this.config.origins["*"]};delete j["Access-Control-Allow-Credentials"];for(let[J,W]of Object.entries(j))$.ctx().setHeaders(J,W)}return{}}}class e0{config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,Z={}){let j=Z.limit??this.config.limit,J=Z.window??this.config.window,W=Z.cost??1;if(Y5("window",J),Y5("limit",j),!Number.isFinite(W)||W<0)throw Error(`Rate limiter cost must be zero or greater, got ${W}`);return await this.config.driver.consume({key:$,limit:j,window:J*1000,cost:W})}}function Y5($,Z){if(!Number.isFinite(Z)||Z<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${Z}`)}class vZ extends P0{constructor($){super("Rate limit exceeded");let Z={"Content-Type":"application/json",...$?Q5($):{}};this.payload={api:{status:429,data:{error:w1("rate_limit","Rate limit exceeded",429)},headers:Z},view:{error:{message:"Rate limit exceeded"},status:429,headers:Z}}}}class F5 extends o{async run($,Z){let j=fG();if(!j)return{};let J=await j.consume(this.key(),{limit:z5($)??this.config.limit,window:z5(Z)??this.config.window});if(this.config.headers!==!1){let W=this.req.ctx?.();if(W)for(let[Y,z]of Object.entries(Q5(J)))W.setHeaders(Y,z)}if(!J.allowed)throw new vZ(J);return{}}key(){if(this.config.key)return this.config.key(this.req);let $=X5(this.req.rawRequest);if($)return`mcp:${$.via}:${$.id}:${this.req.routePath??"*"}`;return`${g$(this.req)}:${this.req.routePath??"*"}`}}function fG(){try{let $=T();return $.bound(e0)?$.make(e0):null}catch{return null}}function g$($){let Z=G5($.rawRequest);if(Z!==void 0)return Z;let j=$.headers.get("x-forwarded-for");if(j){let[J]=j.split(",");if(J?.trim())return J.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function Q5($){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 z5($){if($===void 0||$===null||$==="")return;let Z=Number($);if(!Number.isFinite(Z)||Z<=0)return;return Z}class O5 extends o{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new m8;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new m8;return{}}}class m8 extends P0{constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:K5("csrf","Invalid CSRF token",403)}},view:{}}}class f3 extends o{run($){let Z=$??this.config.limit;if(Z===void 0||Z==="")throw Error('`body-limit` needs a size, as in "body-limit:64kb".');return _3(this.req.rawRequest,RZ(Z)),{}}}class B5{policiesList={};constructor(){let $=this.register();for(let Z of $){let j=new Z;this.policiesList[Z.name]=j}}register(){return[]}}class D5{all($,Z){return!0}}class p8{options;param;refuse;answers=new WeakMap;constructor($){this.options=$;this.param=$.param,this.refuse=$.refuse??"not_found"}refusal(){return this.refuse==="forbidden"?new m$:new E3}authorize($,Z){if(typeof Z==="number"&&Number.isFinite(Z))Z=String(Z);if(typeof Z!=="string"||Z==="")return Promise.reject(this.refusal());let j=this.answers.get($.rawRequest);if(!j)j=new Map,this.answers.set($.rawRequest,j);let J=j.get(Z);if(!J)J=this.decide($,Z),j.set(Z,J);return J}async allows($,Z){try{return await this.authorize($,Z),!0}catch(j){if(this.isRefusal(j))return!1;throw j}}fromRoute($=new S,Z=this.param){if(Z===void 0)throw Error('This resource policy has no `param`. Give `defineResourcePolicy` one, or name it: `fromRoute(req, "pageId")`, or `alias:pageId` on the middleware.');return this.authorize($,$.params?.[Z])}get middleware(){if(!this.middlewareClass){let $=(Z,j)=>this.fromRoute(Z,j||void 0);this.middlewareClass=class extends o{async run(j){await $(this.req,j)}}}return this.middlewareClass}middlewareClass;forAgent($){return{authorize:async(Z,{threadId:j,body:J})=>{let W;if(j!==void 0){if(W=$.thread?await $.thread(j,Z):null,W===null||W===void 0)throw this.refusal()}if(J!==void 0){let Y=await $.body(J,Z);if(await this.authorize(Z,Y),j!==void 0&&String(W)!==String(Y))throw this.refusal();return}if(j!==void 0)await this.authorize(Z,W)}}}async decide($,Z){let j=await this.options.load(Z,$);if(j===null||j===void 0||!await this.options.allow(j,$))throw this.refusal();return j}isRefusal($){return this.refuse==="forbidden"?$ instanceof m$:$ instanceof E3}}function EG($){return new p8($)}async function b3($,Z,j=!1){if(!$.body)return new Uint8Array;let[J,W]=await uG($.body),z=J.length>=2&&J[0]===31&&J[1]===139?W.pipeThrough(new DecompressionStream("gzip")):W;return dG(z,Z,j,$.url)}async function dG($,Z,j,J){let W=$.getReader(),Y=[],z=0;try{for(;;){let{done:F,value:Q}=await W.read();if(F)break;if(z+Q.byteLength>Z){if(!j)throw new R3(J,Z);Y.push(Q.subarray(0,Z-z)),z=Z;break}Y.push(Q),z+=Q.byteLength}}finally{W.cancel().catch(()=>{})}let X=new Uint8Array(z),G=0;for(let F of Y)X.set(F,G),G+=F.byteLength;return X}async function uG($){let Z=$.getReader(),j=await Z.read(),J=j.done?new Uint8Array:j.value,W=new ReadableStream({start(Y){if(j.done)Y.close();else Y.enqueue(J)},async pull(Y){let z=await Z.read();if(z.done)Y.close();else Y.enqueue(z.value)},cancel(Y){return Z.cancel(Y)}});return[J,W]}function v3($){return new TextDecoder("utf-8").decode($)}var lG={"&":"&","<":"<",">":">",'"':""","'":"'"};function W$($){return $.replace(/[&<>"']/g,(Z)=>lG[Z])}var iG={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function h8($){if(!$.includes("&"))return $;return $.replace(/&(#x[0-9a-fA-F]{1,6}|#[0-9]{1,7}|[a-zA-Z]{2,4});/g,(Z,j)=>{if(j[0]!=="#")return iG[j]??Z;let J=j[1]==="x"?parseInt(j.slice(2),16):parseInt(j.slice(1),10);return J>0&&J<=1114111?String.fromCodePoint(J):Z})}function c8($){let Z=$.indexOf(":");return(Z===-1?$:$.slice(Z+1)).toLowerCase()}function U5($,Z){let j=$.length,J=0;while(J<j){if(Z.stopped?.())return;let W=$.indexOf("<",J);if(W===-1){Z.text(h8($.slice(J)));return}if(W>J)Z.text(h8($.slice(J,W)));if($.startsWith("<!--",W)){let Y=$.indexOf("-->",W+4);if(Y===-1)return;J=Y+3}else if($.startsWith("<![CDATA[",W)){let Y=$.indexOf("]]>",W+9);if(Y===-1)return;Z.text($.slice(W+9,Y)),J=Y+3}else if($.startsWith("<?",W)){let Y=$.indexOf("?>",W+2);if(Y===-1)return;J=Y+2}else if($.startsWith("<!",W)){let Y=$.indexOf(">",W+2);if(Y===-1)return;let z=$.indexOf("[",W+2);if(z!==-1&&z<Y){let X=$.indexOf("]",z+1);if(X===-1)return;let G=$.indexOf(">",X+1);if(G===-1)return;J=G+1}else J=Y+1}else if($[W+1]==="/"){let Y=$.indexOf(">",W+2);if(Y===-1)return;Z.close(c8($.slice(W+2,Y).trim())),J=Y+1}else{let Y=sG($,W+1);if(Y===-1)return;let z=$.slice(W+1,Y),X=z.endsWith("/");if(X)z=z.slice(0,-1);let G=z.search(/[\s]|$/),F=c8(z.slice(0,G));if(F){if(Z.open(F,nG(z.slice(G)),X),X)Z.close(F)}J=Y+1}}}function sG($,Z){let j=null;for(let J=Z;J<$.length;J++){let W=$[J];if(j){if(W===j)j=null}else if(W==='"'||W==="'")j=W;else if(W===">")return J}return-1}function nG($){let Z={},j=/([^\s=]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;for(let J of $.matchAll(j))Z[c8(J[1])]=h8(J[2]??J[3]??"");return Z}class J0 extends Error{url;status;constructor($,Z=null,j=null){super($);this.url=Z;this.status=j;this.name="SitemapError"}}var P5="http://www.sitemaps.org/schemas/sitemap/0.9",oG="http://www.w3.org/1999/xhtml",l8=`<?xml version="1.0" encoding="UTF-8"?>
|
|
3
|
-
`,V5=`<urlset xmlns="${P5}" xmlns:xhtml="${oG}">
|
|
4
|
-
`,T5=`</urlset>
|
|
5
|
-
`,Y$=50000,wZ=52428800,I5=2048,aG=new Set(["always","hourly","daily","weekly","monthly","yearly","never"]),rG=/^\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2}))?)?)?$/,tG="application/xml; charset=utf-8",M5=new TextEncoder;function i8($,Z){let j;try{j=new URL($)}catch{throw new J0(`Sitemap: ${Z} "${$}" is not an absolute URL.`)}if(j.protocol!=="http:"&&j.protocol!=="https:")throw new J0(`Sitemap: ${Z} "${$}" is not an http(s) URL.`);let J=j.href;if(J.length>I5)throw new J0(`Sitemap: ${Z} is over ${I5} characters: "${J.slice(0,80)}\u2026".`);return J}function N5($,Z){if($ instanceof Date){if(Number.isNaN($.getTime()))throw new J0(`Sitemap: lastmod of ${Z} is an invalid Date.`);return $.toISOString()}if(!rG.test($))throw new J0(`Sitemap: lastmod "${$}" of ${Z} is not a W3C datetime (e.g. "2026-10-07" or "2026-10-07T12:00:00Z").`);return $}function eG($){let Z=i8($.loc,"loc"),j=`<url><loc>${W$(Z)}</loc>`;if($.lastmod!=null)j+=`<lastmod>${W$(N5($.lastmod,Z))}</lastmod>`;if($.changefreq!=null){if(!aG.has($.changefreq))throw new J0(`Sitemap: changefreq "${$.changefreq}" of ${Z} is not one the protocol knows.`);j+=`<changefreq>${$.changefreq}</changefreq>`}if($.priority!=null){let J=$.priority;if(!Number.isFinite(J)||J<0||J>1)throw new J0(`Sitemap: priority ${J} of ${Z} is not between 0 and 1.`);j+=`<priority>${Number(J.toFixed(4))}</priority>`}for(let J of $.alternates??[]){let W=J.hrefLang?.trim();if(!W)throw new J0(`Sitemap: an alternate of ${Z} has no hrefLang.`);let Y=i8(J.href,`alternate href of ${Z}`);j+=`<xhtml:link rel="alternate" hreflang="${W$(W)}" href="${W$(Y)}"/>`}return`${j}</url>
|
|
6
|
-
`}function $F($){let Z=$.maxUrls??Y$,j=$.maxBytes??wZ;if(!Number.isInteger(Z)||Z<1||Z>Y$)throw RangeError(`Sitemap: maxUrls must be an integer from 1 to ${Y$}.`);if(!Number.isInteger(j)||j<1||j>wZ)throw RangeError(`Sitemap: maxBytes must be an integer from 1 to ${wZ}.`);return{maxUrls:Z,maxBytes:j}}function L5($,Z={}){let{maxUrls:j,maxBytes:J}=$F(Z),W=M5.encode(l8+V5+T5).byteLength,Y=[],z=[],X=W,G=()=>{Y.push(l8+V5+z.join("")+T5),z=[],X=W};for(let F of $){let Q=eG(F),O=M5.encode(Q).byteLength;if(W+O>J)throw new J0(`Sitemap: the entry for ${F.loc} alone is over maxBytes (${J}).`);if(z.length===j||X+O>J)G();z.push(Q),X+=O}if(z.length>0||Y.length===0)G();return Y}function H5($){let Z="",j=0;for(let J of $){if(++j>Y$)throw new J0(`Sitemap: an index can list at most ${Y$} sitemaps.`);let W=i8(J.loc,"sitemap loc");if(Z+=`<sitemap><loc>${W$(W)}</loc>`,J.lastmod!=null)Z+=`<lastmod>${W$(N5(J.lastmod,W))}</lastmod>`;Z+=`</sitemap>
|
|
7
|
-
`}return`${l8}<sitemapindex xmlns="${P5}">
|
|
8
|
-
${Z}</sitemapindex>
|
|
9
|
-
`}function d8($,Z,j){let J=new Headers(j);if(!J.has("content-type"))J.set("content-type",tG);return new Response($,{status:Z,headers:J})}function ZF($){if($===null||$===void 0||$==="")return null;let Z=String($);return/^[1-9]\d{0,8}$/.test(Z)?Number(Z):NaN}function jF($,Z={}){let j=L5($,Z),J=ZF(Z.page);if(J!==null){let Y=j[J-1];return Y?d8(Y,200,Z.headers):new Response("Not found",{status:404,headers:{"cache-control":"no-store"}})}if(j.length===1)return d8(j[0],200,Z.headers);let W=Z.pageUrl;if(!W)throw new J0(`Sitemap: the entries need ${j.length} files, so Sitemap.response needs \`pageUrl\` to list them in an index.`);return d8(H5(j.map((Y,z)=>({loc:W(z+1)}))),200,Z.headers)}function u8($){try{let Z=new URL($.trim());return Z.protocol==="http:"||Z.protocol==="https:"?Z.href:null}catch{return null}}function C5($,Z={}){let j=Z.maxUrls??1/0,J=$.replace(/^\uFEFF/,"").trimStart();if(!J.startsWith("<")){let K=[];for(let D of J.split(/\r?\n/)){if(K.length>=j)break;let B=D.trim()?u8(D):null;if(B)K.push({loc:B})}if(K.length===0&&J.length>0)throw new J0("Sitemap: the document is neither XML nor a list of URLs.");return{kind:"urlset",urls:K}}let W=null,Y=[],z=[],X=[],G=null,F=null,Q="",O=()=>W==="index"?z.length:Y.length;if(U5(J,{stopped:()=>O()>=j,open(K,D){let B=X[X.length-1];if(X.push(K),W===null){if(K==="urlset")W="urlset";else if(K==="sitemapindex")W="index";return}if(W==="urlset"&&K==="url"&&B==="urlset"||W==="index"&&K==="sitemap"&&B==="sitemapindex")G={};else if(G&&(B==="url"||B==="sitemap")&&(K==="loc"||K==="lastmod"||K==="changefreq"||K==="priority"))F=K,Q="";else if(G&&W==="urlset"&&B==="url"&&K==="link"){let U=D.href?u8(D.href):null;if(D.rel?.toLowerCase()==="alternate"&&D.hreflang&&U)(G.alternates??=[]).push({hrefLang:D.hreflang,href:U})}},close(K){let D=X.lastIndexOf(K);if(D===-1)return;if(X.length=D,F&&K===F&&G)G[F]=Q.trim(),F=null;else if(G&&(K==="url"||K==="sitemap")){let B=G;G=null,F=null;let U=B.loc?u8(B.loc):null;if(!U)return;if(W==="index"){z.push(B.lastmod?{loc:U,lastmod:B.lastmod}:{loc:U});return}let V={loc:U};if(B.lastmod)V.lastmod=B.lastmod;if(B.changefreq)V.changefreq=B.changefreq;let I=B.priority?Number(B.priority):NaN;if(Number.isFinite(I))V.priority=I;if(B.alternates)V.alternates=B.alternates;Y.push(V)}},text(K){if(F)Q+=K}}),W===null)throw new J0("Sitemap: the document has no <urlset> or <sitemapindex>.");return W==="index"?{kind:W,sitemaps:z}:{kind:W,urls:Y}}async function*JF($,Z={}){let{maxUrls:j=Y$,maxSitemaps:J=50,maxDepth:W=3,maxSize:Y=wZ,onError:z,...X}=Z,G=[{url:String($),depth:0}],F=new Set,Q=0,O=0;while(G.length>0&&O<j&&Q<J){let K=G.shift(),D=K.url.replace(/#.*$/,"");if(F.has(D))continue;F.add(D),Q++;let B;try{let U=await p$(K.url,{...X,maxSize:Y});if(!U.ok)throw U.body?.cancel().catch(()=>{}),new J0(`Sitemap: ${K.url} answered ${U.status}.`,K.url,U.status);let V=v3(await b3(U,Y));B=C5(V,{maxUrls:Math.max(j-O,J-Q)})}catch(U){if(K.depth===0||!z||X.signal?.aborted)throw U;z(U,K.url);continue}if(B.kind==="index"){if(K.depth>=W)continue;G=B.sitemaps.slice(0,J-Q).map((V)=>({url:V.loc,depth:K.depth+1})).concat(G);continue}for(let U of B.urls)if(yield{...U,sitemap:K.url},++O>=j)return}}var _5={response:jF,chunk:L5,index:H5,parse:C5,read:JF,MAX_URLS:Y$,MAX_BYTES:wZ};var WF=512000,YF=new TextEncoder;function S5($){let Z=$.trim();if(Z==="*")return"*";return(/^[a-zA-Z_-]+/.exec(Z)?.[0]??"").toLowerCase()}function x5($){let Z="";for(let j=0;j<$.length;j++){let J=$[j];if(J==="%"&&/^[0-9a-fA-F]{2}$/.test($.slice(j+1,j+3)))Z+=`%${$.slice(j+1,j+3).toUpperCase()}`,j+=2;else if(J.charCodeAt(0)>126||J.charCodeAt(0)<=32){let W=$.codePointAt(j);if(W>65535)j++;for(let Y of YF.encode(String.fromCodePoint(W)))Z+=`%${Y.toString(16).toUpperCase().padStart(2,"0")}`}else Z+=J}return Z}function zF($,Z){let j=$.endsWith("$"),J=j?$.slice(0,-1):$,W=0,Y=0,z=-1,X=0;while(Y<Z.length)if(W<J.length&&J[W]!=="*"&&J[W]===Z[Y])W++,Y++;else if(W<J.length&&J[W]==="*")z=W++,X=Y;else if(W===J.length&&!j)return!0;else if(z!==-1)W=z+1,Y=++X;else return!1;while(W<J.length&&J[W]==="*")W++;return W===J.length}class h${groups;sitemaps;status;constructor($,Z,j="parsed"){this.groups=$;this.sitemaps=Z;this.status=j}groupsFor($){let Z=S5($)||"*";if(Z!=="*"){let j=this.groups.filter((J)=>J.userAgents.includes(Z));if(j.length>0)return j}return this.groups.filter((j)=>j.userAgents.includes("*"))}isAllowed($,Z="*"){let j;if($ instanceof URL||/^[a-z][a-z0-9+.-]*:/i.test($)){let W=new URL(String($));j=W.pathname+W.search}else j=$.startsWith("/")?$:`/${$}`;if(j==="/robots.txt")return!0;if(this.status==="unavailable")return!0;if(this.status==="unreachable")return!1;j=x5(j);let J=null;for(let W of this.groupsFor(Z))for(let Y of W.rules){if(!zF(Y.path,j))continue;let z=Y.path.length,X=Y.type==="allow";if(!J||z>J.length||z===J.length&&X)J={length:z,allow:X}}return J?J.allow:!0}crawlDelay($="*"){for(let Z of this.groupsFor($))if(Z.crawlDelay!==void 0)return Z.crawlDelay;return null}}var XF={"user-agent":"user-agent",useragent:"user-agent","user agent":"user-agent",allow:"allow",disallow:"disallow",dissallow:"disallow",disalow:"disallow",sitemap:"sitemap","site-map":"sitemap","crawl-delay":"crawl-delay"};function A5($,Z={}){let j=[],J=[],W=null,Y=!1;for(let z of $.replace(/^\uFEFF/,"").split(/\r\n|\r|\n/)){let X=z.indexOf("#"),G=(X===-1?z:z.slice(0,X)).trim(),F=G.indexOf(":");if(F===-1)continue;let Q=XF[G.slice(0,F).trim().toLowerCase()],O=G.slice(F+1).trim();if(!Q)continue;if(Q==="sitemap"){if(!O||/\s/.test(O))continue;try{let K=Z.url?new URL(O,Z.url):new URL(O);if(K.protocol==="http:"||K.protocol==="https:")J.push(K.href)}catch{}continue}if(Q==="user-agent"){if(!Y||!W)W={userAgents:[],rules:[]},j.push(W),Y=!0;let K=S5(O);if(K)W.userAgents.push(K);continue}if(!W)continue;if(Y=!1,Q==="crawl-delay"){let K=Number(O);if(Number.isFinite(K)&&K>=0)W.crawlDelay=K;continue}if(!O)continue;W.rules.push({type:Q,path:x5(O)})}return new h$(j,J)}async function GF($,Z={}){let{maxSize:j=WF,...J}=Z,W=new URL("/robots.txt",$),Y=await p$(W,{...J,maxSize:Number.MAX_SAFE_INTEGER}),z=Y.status;if(z===429||z>=500)return Y.body?.cancel().catch(()=>{}),new h$([],[],"unreachable");if(z>=400)return Y.body?.cancel().catch(()=>{}),new h$([],[],"unavailable");let X=await b3(Y,j,!0),G=v3(X);if(X.byteLength>=j)G=G.slice(0,Math.max(0,G.lastIndexOf(`
|
|
10
|
-
`)));return A5(G,{url:Y.url})}function s8($){return $===void 0?[]:typeof $==="string"?[$]:$}function w3($,Z){if(/[\r\n]/.test(Z))throw TypeError(`Robots: the ${$} value ${JSON.stringify(Z)} has a line break in it.`);return`${$}: ${Z}
|
|
11
|
-
`}function f5($){let Z=[];for(let J of $.rules??[]){let W=s8(J.userAgent);if(W.length===0)throw TypeError("Robots: a rule needs at least one userAgent.");let Y=W.map((X)=>w3("User-agent",X)).join(""),z=[...s8(J.allow).map((X)=>["Allow",X]),...s8(J.disallow).map((X)=>["Disallow",X])];for(let[X,G]of z){if(!G.startsWith("/")&&!G.startsWith("*"))throw TypeError(`Robots: ${X} "${G}" must start with "/" or "*".`);Y+=w3(X,G)}if(z.length===0)Y+=`Disallow:
|
|
12
|
-
`;if(J.crawlDelay!==void 0){if(!Number.isFinite(J.crawlDelay)||J.crawlDelay<0)throw TypeError(`Robots: crawlDelay ${J.crawlDelay} is not a number of seconds.`);Y+=w3("Crawl-delay",String(J.crawlDelay))}Z.push(Y)}let j=($.sitemaps??[]).map((J)=>{let W;try{W=new URL(J)}catch{throw TypeError(`Robots: sitemap "${J}" is not an absolute URL.`)}return w3("Sitemap",W.href)});if(j.length>0)Z.push(j.join(""));return Z.join(`
|
|
13
|
-
`)}function FF($,Z={}){let j=new Headers(Z.headers);if(!j.has("content-type"))j.set("content-type","text/plain; charset=utf-8");return new Response(f5($),{status:200,headers:j})}var E5={response:FF,text:f5,parse:A5,fetch:GF};import{createHmac as R5,randomBytes as QF}from"crypto";var o8="v2.";function a8($){return $.startsWith(o8)}function c$(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function b5($){let Z=QF(16).toString("hex"),j=R5("sha256",c$()).update(`${$}:${Z}`).digest("hex");return`${o8}${j}`}function k3($,Z){let j=R5("sha256",c$()).update(`legacy-session:${Z}:${$}`).digest("hex");return`${o8}${j}`}import{createHash as BF,createHmac as DF,randomInt as UF,timingSafeEqual as k5}from"crypto";function v5($,Z){return Math.floor($/Z)*Z}function KF($,Z){if(Z<=0)return 0;return Math.min(1,Math.max(0,(Z-$)/Z))}function r8($,Z,j,J){return Z*KF(j,J)+$}function OF($){let{current:Z,previous:j,elapsed:J,window:W,limit:Y,cost:z}=$,X=Y-z;if(X<0)return W;let G=Math.max(0,W-J);if(j>0){let Q=W*(1-(X-Z)/j);if(Q<=W)return Math.max(0,Math.ceil(Q-J))}if(Z<=X)return G;if(Z<=0)return G;let F=W*(1-X/Z);return G+Math.max(0,Math.ceil(F))}function w5($){let{allowed:Z,current:j,previous:J,now:W,elapsed:Y,window:z,limit:X,cost:G}=$;if(Z){let Q=r8(j,J,Y,z);return{allowed:!0,limit:X,remaining:Math.max(0,Math.floor(X-Q)),resetAt:W-Y+z,retryAfter:0}}let F=OF({current:j,previous:J,elapsed:Y,window:z,limit:X,cost:G});return{allowed:!1,limit:X,remaining:0,resetAt:W+F,retryAfter:F}}class t8{}class e8 extends t8{buckets=new Map;maxKeys;constructor($={}){super();this.maxKeys=Math.max(1,$.maxKeys??1e5)}consume($){let{key:Z,limit:j,window:J}=$,W=$.cost??1,Y=Date.now(),z=v5(Y,J),X=Y-z,G=this.roll(Z,J,z);G.limit=j;let Q=r8(G.current,G.previous,X,J)+W<=j;if(Q)G.current+=W;if(this.buckets.delete(Z),this.buckets.set(Z,G),this.buckets.size>this.maxKeys)this.evict(Y);return w5({allowed:Q,current:G.current,previous:G.previous,now:Y,elapsed:X,window:J,limit:j,cost:W})}clear(){this.buckets.clear()}get size(){return this.buckets.size}roll($,Z,j){let J=this.buckets.get($);if(!J||J.window!==Z)return{window:Z,limit:0,windowStart:j,current:0,previous:0};if(J.windowStart===j)return J;if(J.windowStart+Z===j)return J.previous=J.current,J.current=0,J.windowStart=j,J;return J.previous=0,J.current=0,J.windowStart=j,J}evict($){for(let[J,W]of this.buckets)if($-W.windowStart>=W.window*2)this.buckets.delete(J);let Z=this.maxKeys-Math.floor(this.maxKeys/10);if(this.buckets.size<=Z)return;let j=[...this.buckets].map(([J,W],Y)=>({key:J,order:Y,spent:W.limit>0?(W.current+W.previous)/W.limit:0}));j.sort((J,W)=>J.spent-W.spent||J.order-W.order);for(let{key:J}of j){if(this.buckets.size<=Z)break;this.buckets.delete(J)}}}var g5="h1.";function y3($,Z,j){let J=DF("sha256",c$()).update(`gemi:one-time:${$}:${Z}:${j}`).digest("hex");return`${g5}${J}`}function yZ($,Z,j,J){let W=typeof J==="string"?J:"",Y=typeof j==="string"?j:"",z=Y.startsWith(g5),X=y3($,Z,W),G=Buffer.from(z?X:W),F=Buffer.from(Y);if(G.length!==F.length||W===""||Y==="")return k5(G,G),!1;return k5(G,F)}function m5($){let Z="";for(let j=0;j<$;j++)Z+=String(UF(0,10));return Z}var p5=320;function qZ($){if(typeof $!=="string")return null;let Z=$.trim();if(Z===""||Z.length>p5)return null;return Z.toLowerCase()}function q3($){if(typeof $!=="string")return null;let Z=$.trim();if(Z.length>p5)return null;let j=Z.toLowerCase();if(j.length<3||j.length>254||!/^[^\s@]+@[^\s@]+$/.test(j))return null;return j}var y5=null;function h5(){try{let $=T();if(typeof $?.bound==="function"&&$.bound(e0))return $.make(e0)}catch{}return y5??=new e0({driver:new e8,limit:1000,window:60}),y5}function q5($){return $.length<=64?$:`sha256:${BF("sha256").update($).digest("hex")}`}async function d$($,Z,j,J){let W=h5(),Y=[[`auth:code-${$}:ip:${q5(g$(j))}`,J.perIp]];if(Z!==null)Y.push([`auth:code-${$}:email:${q5(Z)}`,J.perEmail]);for(let[z,X]of Y){if(!X)continue;let[G,F]=X,Q=await W.consume(z,{limit:G,window:F});if(!Q.allowed)throw new vZ(Q)}}async function c5($,Z,j,J=10){let W=Math.max(86400,Math.ceil(J*60*(j+1)));return(await h5().consume(`auth:code-attempt:${$}:${Z}`,{limit:j,window:W})).allowed}import{randomBytes as Zj}from"crypto";class $j extends S{schema={name:{string:"Invalid name",required:"Name is required","min:2":"Name must be at least 3 characters"},email:{string:"Invalid email",required:"Email is required",email:"Invalid email"},password:{"min:8":"Password must be at least 9 characters"}}}function g3($,Z,j,J=1/0){if(!Number.isInteger(Z)||Z<j||Z>J){let W=J===1/0?`an integer of at least ${j}`:`an integer from ${j} to ${J}`;throw Error(`auth.emailCode.${$} must be ${W}, got ${Z}`)}}function jj($={}){let Z=$.length??6,j=$.expiresInMinutes??10,J=$.linkExpiresInMinutes??10080,W=$.maxAttempts??5;return g3("length",Z,4,12),g3("expiresInMinutes",j,1),g3("linkExpiresInMinutes",J,1),g3("maxAttempts",W,1),{enabled:$.enabled??!1,createUser:$.createUser??!1,length:Z,expiresInMinutes:j,linkExpiresInMinutes:J,maxAttempts:W,requestLimit:{perEmail:$.requestLimit?.perEmail??[5,900],perIp:$.requestLimit?.perIp??[20,900]},verifyLimit:{perEmail:$.verifyLimit?.perEmail??[10,900],perIp:$.verifyLimit?.perIp??[50,900]},uniformMagicLinkResponse:$.uniformMagicLinkResponse??!1,send:$.send??(({email:Y,code:z})=>{if(Bun.env.NODE_ENV!=="production")console.info(`[gemi] email code for ${Y}: ${z} (set auth.emailCode.send to deliver it)`)})}}async function VF($,Z){if(typeof Z!=="string"||Z==="")return!1;try{return await Bun.password.verify($,Z)}catch{return!1}}function PV($){return $}function d5($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:$j,oauthProviders:{},oauthFailurePath:null,connections:{},connectionStore:null,onConnected:()=>{},verifyPassword:VF,hashPassword:async(Z)=>await Bun.password.hash(Z),generateForgotPasswordToken:async()=>Zj(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return Zj(32).toString("hex")},generateMagicLinkToken:()=>Zj(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{},emailCode:jj($.emailCode),generateCode:()=>{return},onAuthenticated:()=>{}}}function Jj($){if($&&typeof $==="object")delete $.password;return $}function TF(){return new Proxy({},{get:($,Z)=>l5(Z)})}var u5=new WeakMap;function i5($){if($&&typeof $==="object"){for(let Z of Object.values($))i5(Z);Object.freeze($)}return $}var IF={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}},MF=i5({token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:IF});class Wj{models;constructor($=TF()){this.models=$}run($){return this.models.User.asSystem($)}sessionSelect(){return MF}transaction($){return this.models.User.transaction($)}withLegacySessionLock($,Z){let j=this.models.User.$connection??z$(),J=T(X$).connection(j),W=()=>this.transaction(async()=>{if(J.dialect==="postgres"){let X=`gemi:legacy-session:${$}`;await V1()`SELECT pg_advisory_xact_lock(hashtextextended(${X}, 0))`}return Z()});if(J.dialect!=="sqlite"||V1())return W();let z=(u5.get(J)??Promise.resolve()).then(W,W);return u5.set(J,z.catch(()=>{})),z}async createUser($){let Z=await this.run(()=>this.models.User.create({data:$}));return Jj(Z)}async updateUserPassword($){let Z=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return Jj(Z)}async findUserByEmailAddress($,Z){return await this.run(()=>this.models.User.findUnique({where:Z?{email:$,emailVerifiedAt:{not:null}}:{email:$}}))}async findUserByVerificationToken($){if(typeof $!=="string"||$==="")return null;return await this.run(()=>this.models.User.findFirst({where:{verificationToken:$}}))}async verifyUser($){return await this.run(()=>this.models.User.update({where:{email:$},data:{emailVerifiedAt:new Date}}))}async createSession($){return await this.run(()=>this.models.Session.create({data:$,include:{user:!0}}))}async createSessionV2($){return await this.run(()=>this.models.Session.create({data:$,select:this.sessionSelect()}))}async findSession($){if(!$.token)return null;try{return await this.run(()=>this.models.Session.findUnique({where:{token:$.token},select:this.sessionSelect()}))}catch(Z){return console.error("findSession failed:",Z),null}}async updateSession($){return await this.run(()=>this.models.Session.update({where:{token:$.token},data:{expiresAt:$.expiresAt},select:this.sessionSelect()}))}async deleteSession($){if(!$.token)return;await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}))}async claimLegacySession($){if(!$.token)return!1;let{count:Z}=await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}));return Z>0}async deleteAllUserSessions($){await this.run(()=>this.models.Session.deleteMany({where:{userId:$}}))}async createPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.create({data:{token:$.token,user:{connect:{id:$.user.id}}}}))}async findPasswordResetToken($){if(typeof $.token!=="string"||$.token==="")return null;return await this.run(()=>this.models.PasswordResetToken.findUnique({where:{token:$.token},include:{user:!0}}))}async deletePasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.delete({where:{token:$.token}}))}async findInvitation($,Z){if(typeof $!=="string"||typeof Z!=="string")return null;return await this.run(()=>this.models.OrganizationInvitation.findFirst({where:{publicId:$,email:Z}}))}async deleteInvitationById($){await this.run(()=>this.models.OrganizationInvitation.delete({where:{publicId:$}}))}async createAccount($){return await this.run(()=>this.models.Account.create({data:{userId:$.userId,organizationId:$.organizationId,organizationRole:$.organizationRole}}))}async createMagicLinkToken($){return await this.run(()=>this.models.MagicLinkToken.create({data:{email:$.email,token:$.token,pin:$.pin}}))}async findUserMagicLinkToken($){let Z=(j)=>typeof j==="string"&&j!=="";if(!Z($.email))return null;if($.token!==void 0&&!Z($.token))return null;if($.token===void 0&&!Z($.pin))return null;return await this.run(()=>$.token?this.models.MagicLinkToken.findUnique({where:{token_email:{token:$.token,email:$.email}}}):this.models.MagicLinkToken.findUnique({where:{pin_email:{pin:$.pin,email:$.email}}}))}async findMagicLinkTokenByEmail($){return await this.run(()=>this.models.MagicLinkToken.findFirst({where:{email:$},orderBy:{id:"desc"}}))}async claimMagicLinkToken($){let{count:Z}=await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{id:$}}));return Z===1}async deleteMagicLinkToken($){await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{email:$}}))}async createSocialAccount($){return await this.run(()=>this.models.SocialAccount.create({data:$}))}async findUserBySocialAccount($,Z){if(!Z)return null;let j=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:Z},include:{user:!0}}));return j?Jj(j.user):null}async findSocialAccounts($,Z){return await this.run(()=>this.models.SocialAccount.findMany({where:{userId:$,provider:Z},orderBy:{id:"asc"}}))}async claimSocialAccount($,Z){let{count:j}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:Z}}));return j===1}}import{randomBytes as FO}from"crypto";function E0($,Z,j,J,W){return p0(Z,GW($,Z),j,J,W)}function p0($,Z,j,J,W,Y){let z=Fj(Z,j,J);if(W&&Z!==z)throw RangeError(l9($,Z,j,J,Y));return z}function GW($,Z){let j=$[Z];if(j===void 0)throw TypeError(g2(Z));return j}function K0($){return $!==null&&/object|function/.test(typeof $)}function v0($,Z=Map){let j=new Z;return(J,...W)=>{if(j.has(J))return j.get(J);let Y=$(J,...W);return j.set(J,Y),Y}}function Tj($){return K$({name:$},1)}function K$($,Z){return u0((j)=>({value:j,configurable:1,writable:!Z}),$)}function FW($){return u0((Z)=>({get:Z,configurable:1}),$)}function $6($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function a$($,Z){let j={},J=$.length;for(let W of Z)j[$[--J]]=W;return j}function u0($,Z,j){let J={};for(let W in Z)J[W]=$(Z[W],W,j);return J}function iZ($,Z,j){let J={};for(let W=0;W<Z.length;W++){let Y=Z[W];J[Y]=$(Y,W,j)}return J}function PF($,Z,j){let J={};for(let W=0;W<$.length;W++)J[Z[W]]=j[$[W]];return J}function k0($,Z){let j={};for(let J of $)j[J]=Z[J];return j}function Ij($,Z){let j={};for(let J in Z)$.has(J)||(j[J]=Z[J]);return j}function Mj($){$={...$};let Z=Object.keys($);for(let j of Z)$[j]===void 0&&delete $[j];return $}function QW($,Z){for(let j of Z)if(!(j in $))return 0;return 1}function KW($,Z,j){for(let J of $)if(Z[J]!==j[J])return 0;return 1}function OW($,Z,j){let J={...j};for(let W=0;W<Z;W++)J[$[W]]=0;return J}function b($,...Z){return(...j)=>$(...Z,...j)}function s5($){return $[0].toUpperCase()+$.substring(1)}function sZ($){return $.slice().sort()}function l3($,Z){return String(Z).padStart($,"0")}function k1($,Z){return Math.sign($-Z)}function Fj($,Z,j){return Math.min(Math.max($,Z),j)}function I1($,Z){return[Math.floor($/Z),mZ($,Z)]}function mZ($,Z){return($%Z+Z)%Z}function g1($,Z){return[Z6($,Z),Pj($,Z)]}function Z6($,Z){return Math.trunc($/Z)||0}function Pj($,Z){return $%Z||0}function m3($){return Math.abs($%1)===0.5}function BW($,Z,j){let J=0,W=0;for(let X=0;X<=Z;X++){let G=$[j[X]],F=Z1[X],Q=m/F,[O,K]=g1(G,Q);J+=K*F,W+=O}let[Y,z]=g1(J,m);return[W+Y,z]}function j6($,Z,j){let J={};for(let W=Z;W>=0;W--){let Y=Z1[W];J[j[W]]=Z6($,Y),$=Pj($,Y)}return J}function DW($){return $===v?y6:[]}function UW($){return $===v?J3:[]}function VW($){return $===v?["year","day"]:[]}function TW($){if($!==void 0)return r($)}function IW($){if($!==void 0)return l0($)}function Nj($){if($!==void 0)return nZ($)}function l0($){return NW(nZ($))}function nZ($){return PW(KQ($))}function Lj($){if($==null)throw TypeError("Cannot be null or undefined");return $}function MW($,Z){if(Z==null)throw RangeError(g2($));return Z}function P1($){if(!K0($))throw TypeError(u9);return $}function J6($,Z,j=$){if(typeof Z!==$)throw TypeError($3(j,Z));return Z}function PW($,Z="number"){if(!Number.isInteger($))throw RangeError(yF(Z,$));return $||0}function NW($,Z="number"){if($<=0)throw RangeError(qF(Z,$));return $}function Hj($){if(typeof $=="symbol")throw TypeError(hF);return String($)}function i3($,Z){return K0($)?String($):r($,Z)}function W6($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(pF($));return $}function LW($,Z="number"){if(typeof $=="bigint")throw TypeError(mF(Z));if($=Number($),!Number.isFinite($))throw RangeError(gF(Z,$));return $}function N0($,Z){return Math.trunc(LW($,Z))||0}function HW($,Z){return PW(LW($,Z),Z)}function n5($,Z){return NW(N0($,Z),Z)}function Cj($,Z){let[j,J]=g1(Z,m),W=$+j,Y=Math.sign(W);return Y&&Y===-Math.sign(J)&&(W-=Y,J+=Y*m),[W,J]}function l$($,Z,j=1){return Cj($[0]+Z[0]*j,$[1]+Z[1]*j)}function i$($,Z){return Cj($[0],$[1]+Z)}function q0($,Z){return l$(Z,$,-1)}function H0($,Z){return k1($[0],Z[0])||k1($[1],Z[1])}function CW($,Z,j){return H0($,Z)===-1||H0($,j)===1}function Y6($,Z=1){let j=BigInt(m/Z);return[Number($/j),Number($%j)*Z]}function s$($,Z=1){let j=m/Z,[J,W]=g1($,j);return[J,W*Z]}function _W($,Z=1){let[j,J]=$,W=Math.floor(J/Z),Y=m/Z;return BigInt(j)*BigInt(Y)+BigInt(W)}function g0($,Z=1,j){let[J,W]=$,[Y,z]=g1(W,Z);return J*(m/Z)+(Y+(j?z/Z:0))}function _j($,Z,j=I1){let[J,W]=$,[Y,z]=j(W,Z);return[J*(m/Z)+Y,z]}function Sj($,Z){let j=$.formatToParts(Z),J={};for(let W of j)J[W.type]=W.value;return J}function xj($){return E0($,"isoYear",lZ,uZ,1),$.isoYear===lZ?E0($,"isoMonth",4,12,1):$.isoYear===uZ&&E0($,"isoMonth",1,9,1),$}function y1($){return N1({...$,...d0,isoHour:12}),$}function N1($){let Z=E0($,"isoYear",lZ,uZ,1),j=Z===lZ?1:Z===uZ?-1:0;return j&&m0(L0({...$,isoDay:$.isoDay+j,isoNanosecond:$.isoNanosecond-j})),$}function m0($){if(!$||CW($,IQ,TQ))throw RangeError(b6);return $}function m1($){return BW($,5,o0)[1]}function z6($){let[Z,j]=I1($,m);return[j6(j,5,o0),Z]}function SW($){return xW($)[0]}function xW($){return _j($,c0)}function C0($){return r$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function L0($){let Z=C0($);if(Z!==void 0){let[j,J]=g1(Z,b0);return[j,J*j1+($.isoMicrosecond||0)*P$+($.isoNanosecond||0)]}}function Aj($,Z){let[j,J]=z6(m1($)-Z);return m0(L0({...$,isoDay:$.isoDay+J,...j}))}function s3(...$){return r$(...$)/jY}function r$(...$){let[Z,j]=AW(...$),J=Z.valueOf();if(!isNaN(J))return J-j*b0}function AW($,Z=1,j=1,J=0,W=0,Y=0,z=0){let X=$===lZ?1:$===uZ?-1:0,G=new Date;return G.setUTCHours(J,W,Y,z),G.setUTCFullYear($,Z-1,j+X),[G,X]}function h1($,Z){let[j,J]=i$($,Z);J<0&&(J+=m,j-=1);let[W,Y]=I1(J,j1),[z,X]=I1(Y,P$);return X6(j*b0+W,z,X)}function X6($,Z=0,j=0){let J=Math.ceil(Math.max(0,Math.abs($)-VQ)/b0)*Math.sign($),W=new Date($-J*b0);return a$(g6,[W.getUTCFullYear(),W.getUTCMonth()+1,W.getUTCDate()+J,W.getUTCHours(),W.getUTCMinutes(),W.getUTCSeconds(),W.getUTCMilliseconds(),Z,j])}function fW($){return[$.isoYear,$.isoMonth,$.isoDay]}function EW(){return T1}function fj($,Z){switch(Z){case 2:return Ej($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function RW($){return Ej($)?366:365}function Ej($){return $%4==0&&($%100!=0||$%400==0)}function bW($){let[Z,j]=AW($.isoYear,$.isoMonth,$.isoDay);return mZ(Z.getUTCDay()-j,7)||7}function vW({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function NF($){let Z=C0($);if(Z<PQ)return vW($);let j=Sj(j4(n$),Z),{era:J,eraYear:W}=u7(j,n$);return[J,W]}function G6($){return O$($),F6($,1),$}function O$($){return wW($,1),$}function o5($){return KW(n2,$,wW($))}function wW($,Z){let{isoYear:j}=$,J=E0($,"isoMonth",1,EW(),Z);return{isoYear:j,isoMonth:J,isoDay:E0($,"isoDay",1,fj(j,J),Z)}}function F6($,Z){return a$(o0,[E0($,"isoHour",0,23,Z),E0($,"isoMinute",0,59,Z),E0($,"isoSecond",0,59,Z),E0($,"isoMillisecond",0,999,Z),E0($,"isoMicrosecond",0,999,Z),E0($,"isoNanosecond",0,999,Z)])}function k($){return $===void 0?0:MY(P1($))}function oZ($,Z=0){$=i0($);let j=PY($),J=EQ($,Z);return[MY($),J,j]}function Rj($){return PY(i0($))}function kW($){return $=i0($),r2($,9,6,1)}function t$($,Z,j,J=9,W=0,Y=4){Z=i0(Z);let z=r2(Z,J,W),X=wj(Z),G=Y3(Z,Y),F=W3(Z,J,W,1);return z==null?z=Math.max(j,F):mW(z,F),X=kj(X,F,1),$&&(G=((Q)=>Q<4?(Q+2)%4:Q)(G)),[z,F,X,G]}function Q6($,Z=6,j){let J=wj($=yj($,e3)),W=Y3($,7),Y=W3($,Z);return Y=MW(e3,Y),J=kj(J,Y,void 0,j),[Y,J,W]}function bj($){return t2(i0($))}function yW($,Z){return vj(i0($),Z)}function vj($,Z=4){let j=gW($);return[Y3($,4),...qW(W3($,Z),j)]}function qW($,Z){return $!=null?[Z1[$],$<4?9-3*$:-1]:[Z===void 0?1:10**(9-Z),Z]}function wj($){let Z=$[pZ];return Z===void 0?1:N0(Z,pZ)}function kj($,Z,j,J){let W=J?m:Z1[Z+1];if(W){let Y=Z1[Z];if(W%(($=p0(pZ,$,1,W/Y-(J?0:1),1))*Y))throw RangeError($3(pZ,$))}else $=p0(pZ,$,1,j?1e9:1,1);return $}function gW($){let Z=$[Gj];if(Z!==void 0){if(typeof Z!="number"){if(Hj(Z)==="auto")return;throw RangeError($3(Gj,Z))}Z=p0(Gj,Math.floor(Z),0,9,1)}return Z}function i0($){return $===void 0?{}:P1($)}function yj($,Z){return typeof $=="string"?{[Z]:$}:P1($)}function W0($){if($!==void 0){if(K0($))return Object.assign(Object.create(null),$);throw TypeError(u9)}}function K6($,Z){return $&&Object.assign(Object.create(null),$,{overflow:LQ[Z]})}function qj($,Z,j=9,J=0,W){let Y=Z[$];if(Y===void 0)return W?J:void 0;if(Y=Hj(Y),Y==="auto")return W?J:null;let z=Bj[Y];if(z===void 0&&(z=DQ[Y]),z===void 0)throw RangeError(n9($,Y,Bj));return p0($,z,J,j,1,j3),z}function B$($,Z,j,J=0){let W=j[$];if(W===void 0)return J;let Y=Hj(W),z=Z[Y];if(z===void 0)throw RangeError(n9($,Y,Z));return z}function mW($,Z){if(Z>$)throw RangeError(zQ)}function O0($){return{branding:p6,epochNanoseconds:$}}function V0($,Z,j){return{branding:_1,calendar:j,timeZone:Z,epochNanoseconds:$}}function Y0($,Z=$.calendar){return{branding:L$,calendar:Z,...k0(UY,$)}}function z0($,Z=$.calendar){return{branding:N$,calendar:Z,...k0(o2,$)}}function F$($,Z=$.calendar){return{branding:zZ,calendar:Z,...k0(o2,$)}}function n3($,Z=$.calendar){return{branding:XZ,calendar:Z,...k0(o2,$)}}function s0($){return{branding:m6,...k0(DY,$)}}function i($){return{branding:h6,sign:c1($),...k0(l2,$)}}function pW($){return SW($.epochNanoseconds)}function O6($){return _j($.epochNanoseconds,j1)[0]}function hW($){return _W($.epochNanoseconds,P$)}function cW($){return _W($.epochNanoseconds)}function dW($){return $.epochNanoseconds}function D0($){return typeof $=="string"?$:r($.id)}function e$($,Z){return $===Z||D0($)===D0(Z)}function uW($,Z,j,J,W){let Y=Q$(J),[z,X]=((V,I)=>{let P=I((V=yj(V,Vj))[TY]),M=fQ(V);return M=MW(Vj,M),[M,P]})(W,$);if(cZ(Math.max(z,Y),X))return a5(J,z);if(!X)throw RangeError(v6);let[G,F,Q]=I6(Z,j,X),O=X2(Q),K=M6(Q),D=G2(Q),B=K(F,G,J),U=D(F,G,B,z);return cZ(z,X)?a5(U,z):((V,I,P,M,x,f,A)=>{let _=c1(V),[L,N]=gj(M,s2(P,V),P,_,x,f,A),l=mj(I,L,N);return V[y[P]]+l*_})(U,O(B),z,F,G,O,K)}function a5($,Z){return g0(Q0($),Z1[Z],1)}function gj($,Z,j,J,W,Y,z){let X=y[j],G={...Z,[X]:Z[X]+J},F=z($,W,Z),Q=z($,W,G);return[Y(F),Y(Q)]}function mj($,Z,j){let J=g0(q0(Z,j));if(!J)throw RangeError(Z3);return g0(q0(Z,$))/J}function lW($,Z){let[j,J,W]=Q6(Z,5,1);return O0(D6($.epochNanoseconds,j,J,W,1))}function iW($,Z,j){let{epochNanoseconds:J,timeZone:W,calendar:Y}=Z,[z,X,G]=Q6(j);if(z===0&&X===1)return Z;let F=$(W);if(z===6)J=((Q,O,K,D)=>{let B=_0(K,O),[U,V]=Q(B),I=K.epochNanoseconds,P=w0(O,U),M=w0(O,V);if(CW(I,P,M))throw RangeError(Z3);return Z7(mj(I,P,M),D)?M:P})(eW,F,Z,G);else{let Q=F.getOffsetNanosecondsFor(J);J=U$(F,rW(h1(J,Q),z,X,G),Q,2,0,1)}return V0(J,W,Y)}function sW($,Z){return Y0(rW($,...Q6(Z)),$.calendar)}function nW($,Z){let[j,J,W]=Q6(Z,5);var Y;return s0((Y=W,pj($,aZ(j,J),Y)[0]))}function oW($,Z){let j=$(Z.timeZone),J=_0(Z,j),[W,Y]=eW(J),z=g0(q0(w0(j,W),w0(j,Y)),k6,1);if(z<=0)throw RangeError(Z3);return z}function aW($,Z){let{timeZone:j,calendar:J}=Z,W=((Y,z,X)=>w0(z,Y(_0(X,z))))($7,$(j),Z);return V0(W,j,J)}function rW($,Z,j,J){return tW($,aZ(Z,j),J)}function tW($,Z,j){let[J,W]=pj($,Z,j);return N1({...V$($,W),...J})}function pj($,Z,j){return z6(p1(m1($),Z,j))}function o3($){return p1($,w6,7)}function aZ($,Z){return Z1[$]*Z}function eW($){let Z=$7($);return[Z,V$(Z,1)]}function $7($){return UQ(6,$)}function LF($,Z,j){let J=Math.min(Q$($),6);return ZZ(U6(Q0($,J),Z,j),J)}function B6($,Z,j,J,W,Y,z,X,G,F){if(J===0&&W===1)return $;let Q=cZ(J,X)?P6(X)&&J<6&&j>=6?CF:HF:_F,[O,K,D]=Q($,Z,j,J,W,Y,z,X,G,F);return D&&J!==7&&(O=((B,U,V,I,P,M,x,f)=>{let A=c1(B);for(let _=I+1;_<=V;_++){if(_===7&&V!==7)continue;let L=s2(_,B);L[y[_]]+=A;let N=g0(q0(x(f(P,M,L)),U));if(N&&Math.sign(N)!==A)break;B=L}return B})(O,K,j,Math.max(6,J),z,X,G,F)),O}function D6($,Z,j,J,W){if(Z===6){let Y=((z)=>z[0]+z[1]/m)($);return[p1(Y,j,J),0]}return U6($,aZ(Z,j),J,W)}function U6($,Z,j,J){let[W,Y]=$;J&&Y<0&&(Y+=m,W-=1);let[z,X]=I1(p1(Y,Z,j),m);return Cj(W+z,X)}function p1($,Z,j){return Z7($/Z,j)*Z}function Z7($,Z){return vQ[Z]($)}function HF($,Z,j,J,W,Y){let z=c1($),X=Q0($),G=D6(X,J,W,Y),F=q0(X,G),Q=Math.sign(G[0]-X[0])===z,O=ZZ(G,Math.min(j,6));return[{...$,...O},l$(Z,F),Q]}function CF($,Z,j,J,W,Y,z,X,G,F){let Q=c1($),O=g0(Q0($,5)),K=aZ(J,W),D=p1(O,K,Y),[B,U]=gj(z,{...$,...i2},6,Q,X,G,F),V=D-g0(q0(B,U)),I=0;V&&Math.sign(V)!==Q?Z=i$(B,D):(I+=Q,D=p1(V,K,Y),Z=i$(U,D));let P=L6(D);return[{...$,...P,days:$.days+I},Z,Boolean(I)]}function _F($,Z,j,J,W,Y,z,X,G,F){let Q=c1($),O=y[J],K=s2(J,$);J===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let D=Z6($[O],W)*W;K[O]=D;let[B,U]=gj(z,K,J,W*Q,X,G,F),V=D+mj(Z,B,U)*Q*W,I=p1(V,W,Y),P=Math.sign(I-V)===Q;return K[O]=I,[K,P?U:B,P]}function hj($,Z,j,J){let[W,Y,z,X]=((F)=>{let Q=vj(F=i0(F));return[F.timeZone,...Q]})(J),G=W!==void 0;return((F,Q,O,K,D,B)=>{O=U6(O,D,K,1);let U=Q.getOffsetNanosecondsFor(O);return nj(h1(O,U),B)+(F?D$(o3(U)):"Z")})(G,Z(G?$(W):H$),j.epochNanoseconds,Y,z,X)}function cj($,Z,j){let[J,W,Y,z,X,G]=((F)=>{F=i0(F);let Q=t2(F),O=gW(F),K=bQ(F),D=Y3(F,4),B=W3(F,4);return[Q,RQ(F),K,D,...qW(B,O)]})(j);return((F,Q,O,K,D,B,U,V,I,P)=>{K=U6(K,I,V,1);let M=F(O).getOffsetNanosecondsFor(K);return nj(h1(K,M),P)+D$(o3(M),U)+((x,f)=>f!==1?"["+(f===2?"!":"")+D0(x)+"]":"")(O,B)+oj(Q,D)})($,Z.calendar,Z.timeZone,Z.epochNanoseconds,J,W,Y,z,X,G)}function dj($,Z){let[j,J,W,Y]=((F)=>(F=i0(F),[t2(F),...vj(F)]))(Z);return z=$.calendar,X=j,G=Y,nj(tW($,W,J),G)+oj(z,X);var z,X,G}function uj($,Z){return j=$.calendar,J=$,W=bj(Z),a3(J)+oj(j,W);var j,J,W}function lj($,Z){return j7($.calendar,J7,$,bj(Z))}function ij($,Z){return j7($.calendar,SF,$,bj(Z))}function sj($,Z){let[j,J,W]=yW(Z);return Y=W,W7(pj($,J,j)[0],Y);var Y}function V6($,Z){let[j,J,W]=yW(Z,3);return J>1&&($={...$,...LF($,J,j)}),((Y,z)=>{let{sign:X}=Y,G=X===-1?S0(Y):Y,{hours:F,minutes:Q}=G,[O,K]=_j(Q0(G,3),c0,g1);O7(O);let D=aj(K,z),B=z>=0||!X||D;return(X<0?"-":"")+"P"+r5({Y:G$(G.years),M:G$(G.months),W:G$(G.weeks),D:G$(G.days)})+(F||Q||O||B?"T"+r5({H:G$(F),M:G$(Q),S:G$(O,B)+D}):"")})($,W)}function j7($,Z,j,J){let W=D0($),Y=J>1||J===0&&W!==v;return J===1?W===v?Z(j):a3(j):Y?a3(j)+Y7(W,J===2):Z(j)}function r5($){let Z=[];for(let j in $){let J=$[j];J&&Z.push(J,j)}return Z.join("")}function nj($,Z){return a3($)+"T"+W7($,Z)}function a3($){return J7($)+"-"+h0($.isoDay)}function J7($){let{isoYear:Z}=$;return(Z<0||Z>9999?z7(Z)+l3(6,Math.abs(Z)):l3(4,Z))+"-"+h0($.isoMonth)}function SF($){return h0($.isoMonth)+"-"+h0($.isoDay)}function W7($,Z){let j=[h0($.isoHour),h0($.isoMinute)];return Z!==-1&&j.push(h0($.isoSecond)+((J,W,Y,z)=>aj(J*j1+W*P$+Y,z))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,Z)),j.join(":")}function D$($,Z=0){if(Z===1)return"";let[j,J]=I1(Math.abs($),k6),[W,Y]=I1(J,w6),[z,X]=I1(Y,c0);return z7($)+h0(j)+":"+h0(W)+(z||X?":"+h0(z)+aj(X):"")}function oj($,Z){if(Z!==1){let j=D0($);if(Z>1||Z===0&&j!==v)return Y7(j,Z===2)}return""}function Y7($,Z){return"["+(Z?"!":"")+"u-ca="+$+"]"}function aj($,Z){let j=l3(9,$);return j=Z===void 0?j.replace(yQ,""):j.slice(0,Z),j?"."+j:""}function z7($){return $<0?"-":"+"}function G$($,Z){return $||Z?$.toLocaleString("fullwide",{useGrouping:0}):""}function xF($,Z){let{epochNanoseconds:j}=$,J=(Z.getOffsetNanosecondsFor?Z:Z($.timeZone)).getOffsetNanosecondsFor(j),W=h1(j,J);return{calendar:$.calendar,...W,offsetNanoseconds:J}}function X7($,Z){let j=_0(Z,$);return{calendar:Z.calendar,...k0(UY,j),offset:D$(j.offsetNanoseconds),timeZone:Z.timeZone}}function U$($,Z,j,J=0,W=0,Y,z){if(j!==void 0&&J===1&&(J===1||z))return Aj(Z,j);let X=$.getPossibleInstantsFor(Z);if(j!==void 0&&J!==3){let G=((F,Q,O,K)=>{let D=L0(Q);K&&(O=o3(O));for(let B of F){let U=g0(q0(B,D));if(K&&(U=o3(U)),U===O)return B}})(X,Z,j,Y);if(G!==void 0)return G;if(J===0)throw RangeError($Q)}return z?L0(Z):w0($,Z,W,X)}function w0($,Z,j=0,J=$.getPossibleInstantsFor(Z)){if(J.length===1)return J[0];if(j===1)throw RangeError(ZQ);if(J.length)return J[j===3?1:0];let W=L0(Z),Y=((X,G)=>{let F=X.getOffsetNanosecondsFor(i$(G,-m));return tj(X.getOffsetNanosecondsFor(i$(G,m))-F)})($,W),z=Y*(j===2?-1:1);return(J=$.getPossibleInstantsFor(h1(W,z)))[j===2?0:J.length-1]}function rj($){if(Math.abs($)>=m)throw RangeError(tF);return $}function tj($){if($>m)throw RangeError(eF);return $}function ej($,Z,j){return O0(m0(l$(Z.epochNanoseconds,((J)=>{if(B7(J))throw RangeError(WQ);return Q0(J,5)})($?S0(j):j))))}function $2($,Z,j,J,W,Y=Object.create(null)){let z=Z(J.timeZone),X=$(J.calendar);return{...J,...Y2(z,X,J,j?S0(W):W,Y)}}function Z2($,Z,j,J,W=Object.create(null)){let{calendar:Y}=j;return Y0(z2($(Y),j,Z?S0(J):J,W),Y)}function j2($,Z,j,J,W){let{calendar:Y}=j;return z0(T6($(Y),j,Z?S0(J):J,W),Y)}function J2($,Z,j,J,W=Object.create(null)){let Y=j.calendar,z=$(Y),X=hZ(z,j);Z&&(J=N6(J)),J.sign<0&&(X=z.dateAdd(X,{...U0,months:1}),X=V$(X,-1));let G=z.dateAdd(X,J,W);return F$(hZ(z,G),Y)}function W2($,Z,j){return s0(G7(Z,$?S0(j):j)[0])}function Y2($,Z,j,J,W){let Y=Q0(J,5),z=j.epochNanoseconds;if(B7(J)){let X=_0(j,$);z=l$(w0($,{...T6(Z,X,{...J,...i2},W),...k0(o0,X)}),Y)}else z=l$(z,Y),k(W);return{epochNanoseconds:m0(z)}}function z2($,Z,j,J){let[W,Y]=G7(Z,j);return N1({...T6($,Z,{...j,...i2,days:j.days+Y},J),...W})}function T6($,Z,j,J){if(j.years||j.months||j.weeks)return $.dateAdd(Z,j,J);k(J);let W=j.days+Q0(j,5)[0];return W?y1(V$(Z,W)):Z}function hZ($,Z,j=1){return V$(Z,j-$.day(Z))}function G7($,Z){let[j,J]=Q0(Z,5),[W,Y]=z6(m1($)+J);return[W,j+Y]}function V$($,Z){return Z?{...$,...X6(C0($)+Z*b0)}:$}function I6($,Z,j){let J=$(j.calendar);return P6(j)?[j,J,Z(j.timeZone)]:[{...j,...d0},J]}function X2($){return $?dW:L0}function M6($){return $?b(Y2,$):z2}function G2($){return $?b(fF,$):EF}function P6($){return $&&$.epochNanoseconds}function cZ($,Z){return $<=6-(P6(Z)?1:0)}function F2($,Z,j,J,W,Y,z){let X=$(i0(z).relativeTo),G=Math.max(Q$(W),Q$(Y));if(cZ(G,X))return i($Z(((U,V,I,P)=>{let M=l$(Q0(U),Q0(V),P?-1:1);if(!Number.isFinite(M[0]))throw RangeError(b6);return{...U0,...ZZ(M,I)}})(W,Y,G,J)));if(!X)throw RangeError(v6);J&&(Y=S0(Y));let[F,Q,O]=I6(Z,j,X),K=M6(O),D=G2(O),B=K(Q,F,W);return i(D(Q,F,K(Q,B,Y),G))}function F7($,Z,j,J,W){let Y=Q$(J),[z,X,G,F,Q]=((A,_,L)=>{A=yj(A,e3);let N=r2(A),l=L(A[TY]),d=wj(A),E1=Y3(A,7),$0=W3(A);if(N===void 0&&$0===void 0)throw RangeError(YQ);return $0==null&&($0=0),N==null&&(N=Math.max($0,_)),mW(N,$0),d=kj(d,$0,1),[N,$0,d,E1,l]})(W,Y,$),O=Math.max(Y,z);if(!P6(Q)&&O<=6)return i($Z(((A,_,L,N,l)=>{let d=D6(Q0(A),L,N,l);return{...U0,...ZZ(d,_)}})(J,z,X,G,F)));if(!Q)throw RangeError(v6);let[K,D,B]=I6(Z,j,Q),U=X2(B),V=M6(B),I=G2(B),P=V(D,K,J),M=I(D,K,P,z),x=J.sign,f=c1(M);if(x&&f&&x!==f)throw RangeError(Z3);return f&&(M=B6(M,U(P),z,X,G,F,D,K,U,V)),i(M)}function Q7($){return $.sign===-1?N6($):$}function N6($){return i(S0($))}function S0($){let Z={};for(let j of y)Z[j]=-1*$[j]||0;return Z}function K7($){return!$.sign}function c1($,Z=y){let j=0;for(let J of Z){let W=Math.sign($[J]);if(W){if(j&&j!==W)throw RangeError(JQ);j=W}}return j}function $Z($){for(let Z of BQ)p0(Z,$[Z],-WW,WW,1);return O7(g0(Q0($),c0)),$}function O7($){if(!Number.isSafeInteger($))throw RangeError(jQ)}function Q0($,Z=6){return BW($,Z,y)}function ZZ($,Z=6){let[j,J]=$,W=j6(J,Z,y);if(W[y[Z]]+=j*(m/Z1[Z]),!Number.isFinite(W[y[Z]]))throw RangeError(b6);return W}function L6($,Z=5){return j6($,Z,y)}function B7($){return Boolean(c1($,BY))}function Q$($){let Z=9;for(;Z>0&&!$[y[Z]];Z--);return Z}function AF($,Z){return[$,Z]}function t5($){let Z=Math.floor($/d3)*d3;return[Z,Z+d3]}function D7($){let Z=d1($=i3($));if(!Z)throw RangeError(R0($));let j;if(Z.m)j=0;else{if(!Z.offset)throw RangeError(R0($));j=jZ(Z.offset)}return Z.timeZone&&B2(Z.timeZone,1),O0(Aj(G6(Z),j))}function U7($){let Z=d1(r($));if(!Z)throw RangeError(R0($));if(Z.timeZone)return C7(Z,Z.offset?jZ(Z.offset):void 0);if(Z.m)throw RangeError(R0($));return S7(Z)}function V7($,Z){let j=d1(r($));if(!j||!j.timeZone)throw RangeError(R0($));let{offset:J}=j,W=J?jZ(J):void 0,[,Y,z]=oZ(Z);return C7(j,W,Y,z)}function jZ($){let Z=B2($);if(Z===void 0)throw RangeError(R0($));return Z}function T7($){let Z=d1(r($));if(!Z||Z.m)throw RangeError(R0($));return Y0(_7(Z))}function H6($){let Z=d1(r($));if(!Z||Z.m)throw RangeError(R0($));return z0(Z.p?_7(Z):S7(Z))}function I7($,Z){let j=K2(r(Z));if(j)return Q2(j),F$(xj(O$(j)));let J=H6(Z);return F$(hZ($(J.calendar),J))}function Q2($){if($.calendar!==v)throw RangeError(M1($.calendar))}function M7($,Z){let j=O2(r(Z));if(j)return Q2(j),n3(O$(j));let J=H6(Z),{calendar:W}=J,Y=$(W),[z,X,G]=Y.h(J),[F,Q]=Y.I(z,X),[O,K]=Y.N(F,Q,G);return n3(y1(Y.P(O,K,G)),W)}function P7($){let Z,j=((J)=>{let W=hQ.exec(J);return W?(C6(W[10]),f7(W)):void 0})(r($));if(!j){if(j=d1($),!j)throw RangeError(R0($));if(!j.p)throw RangeError(R0($));if(j.m)throw RangeError(M1("Z"));Q2(j)}if((Z=K2($))&&o5(Z))throw RangeError(R0($));if((Z=O2($))&&o5(Z))throw RangeError(R0($));return s0(F6(j,1))}function N7($){let Z=((j)=>{let J=uQ.exec(j);return J?((W)=>{function Y(Q,O,K){let D=0,B=0;if(K&&([D,G]=I1(G,Z1[K])),Q!==void 0){if(X)throw RangeError(M1(Q));B=((U)=>{let V=parseInt(U);if(!Number.isFinite(V))throw RangeError(M1(U));return V})(Q),z=1,O&&(G=D2(O)*(Z1[K]/c0),X=1)}return D+B}let z=0,X=0,G=0,F={...a$(y,[Y(W[2]),Y(W[3]),Y(W[4]),Y(W[5]),Y(W[6],W[7],5),Y(W[8],W[9],4),Y(W[10],W[11],3)]),...j6(G,2,y)};if(!z)throw RangeError(i9(y));return U2(W[1])<0&&(F=S0(F)),F})(J):void 0})(r($));if(!Z)throw RangeError(R0($));return i($Z(Z))}function L7($){let Z=d1($)||K2($)||O2($);return Z?Z.calendar:$}function H7($){let Z=d1($);return Z&&(Z.timeZone||Z.m&&H$||Z.offset)||$}function C7($,Z,j=0,J=0){let W=_6($.timeZone),Y=c6(W);return V0(U$(Y,G6($),Z,j,J,!Y.v,$.m),W,rZ($.calendar))}function _7($){return x7(N1(G6($)))}function S7($){return x7(y1(O$($)))}function x7($){return{...$,calendar:rZ($.calendar)}}function d1($){let Z=pQ.exec($);return Z?((j)=>{let J=j[10],W=(J||"").toUpperCase()==="Z";return{isoYear:A7(j),isoMonth:parseInt(j[4]),isoDay:parseInt(j[5]),...f7(j.slice(5)),...C6(j[16]),p:Boolean(j[6]),m:W,offset:W?void 0:J}})(Z):void 0}function K2($){let Z=gQ.exec($);return Z?((j)=>({isoYear:A7(j),isoMonth:parseInt(j[4]),isoDay:1,...C6(j[5])}))(Z):void 0}function O2($){let Z=mQ.exec($);return Z?((j)=>({isoYear:o$,isoMonth:parseInt(j[1]),isoDay:parseInt(j[2]),...C6(j[3])}))(Z):void 0}function B2($,Z){let j=cQ.exec($);return j?((J,W)=>{let Y=J[4]||J[5];if(W&&Y)throw RangeError(M1(Y));return rj((u$(J[2])*k6+u$(J[3])*w6+u$(J[4])*c0+D2(J[5]||""))*U2(J[1]))})(j,Z):void 0}function A7($){let Z=U2($[1]),j=parseInt($[2]||$[3]);if(Z<0&&!j)throw RangeError(M1(-0));return Z*j}function f7($){let Z=u$($[3]);return{...z6(D2($[4]||""))[0],isoHour:u$($[1]),isoMinute:u$($[2]),isoSecond:Z===60?59:Z}}function C6($){let Z,j,J=[];if($.replace(dQ,(W,Y,z)=>{let X=Boolean(Y),[G,F]=z.split("=").reverse();if(F){if(F==="u-ca")J.push(G),Z||(Z=X);else if(X||/[A-Z]/.test(F))throw RangeError(M1(W))}else{if(j)throw RangeError(M1(W));j=G}return""}),J.length>1&&Z)throw RangeError(M1($));return{timeZone:j,calendar:J[0]||v}}function D2($){return parseInt($.padEnd(9,"0"))}function JZ($){return new RegExp(`^${$}$`,"i")}function U2($){return $&&$!=="+"?-1:1}function u$($){return $===void 0?0:parseInt($)}function E7($){return _6(r($))}function _6($){let Z=V2($);return typeof Z=="number"?D$(Z):Z?((j)=>{if(iQ.test(j))throw RangeError(rF);return j.toLowerCase().split("/").map((J,W)=>(J.length<=3||/\d/.test(J))&&!/etc|yap/.test(J)?J.toUpperCase():J.replace(/baja|dumont|[a-z]+/g,(Y,z)=>Y.length<=2&&!W||Y==="in"||Y==="chat"?Y.toUpperCase():Y.length>2||!z?s5(Y).replace(/island|noronha|murdo|rivadavia|urville/,s5):Y)).join("/")})($):H$}function e5($){let Z=V2($);return typeof Z=="number"?Z:Z?Z.resolvedOptions().timeZone:H$}function V2($){let Z=B2($=$.toUpperCase(),1);return Z!==void 0?Z:$!==H$?lQ($):void 0}function T2($,Z){return H0($.epochNanoseconds,Z.epochNanoseconds)}function I2($,Z){return H0($.epochNanoseconds,Z.epochNanoseconds)}function R7($,Z,j,J,W,Y){let z=$(i0(Y).relativeTo),X=Math.max(Q$(J),Q$(W));if(KW(y,J,W))return 0;if(cZ(X,z))return H0(Q0(J),Q0(W));if(!z)throw RangeError(v6);let[G,F,Q]=I6(Z,j,z),O=X2(Q),K=M6(Q);return H0(O(K(F,G,J)),O(K(F,G,W)))}function M2($,Z){return T$($,Z)||S6($,Z)}function T$($,Z){return k1(C0($),C0(Z))}function S6($,Z){return k1(m1($),m1(Z))}function b7($,Z){return!T2($,Z)}function v7($,Z){return!I2($,Z)&&!!x6($.timeZone,Z.timeZone)&&e$($.calendar,Z.calendar)}function w7($,Z){return!M2($,Z)&&e$($.calendar,Z.calendar)}function k7($,Z){return!T$($,Z)&&e$($.calendar,Z.calendar)}function y7($,Z){return!T$($,Z)&&e$($.calendar,Z.calendar)}function q7($,Z){return!T$($,Z)&&e$($.calendar,Z.calendar)}function g7($,Z){return!S6($,Z)}function x6($,Z){if($===Z)return 1;let j=D0($),J=D0(Z);if(j===J)return 1;try{return e5(j)===e5(J)}catch(W){}}function P2($,Z,j,J){let W=t$($,W0(J),3,5),Y=A6(Z.epochNanoseconds,j.epochNanoseconds,...W);return i($?S0(Y):Y)}function N2($,Z,j,J,W,Y){let z=E6(J.calendar,W.calendar),X=W0(Y),[G,F,Q,O]=t$(j,X,5),K=J.epochNanoseconds,D=W.epochNanoseconds,B=H0(D,K),U;if(B)if(G<6)U=A6(K,D,G,F,Q,O);else{let V=Z(((P,M)=>{if(!x6(P,M))throw RangeError(t9);return P})(J.timeZone,W.timeZone)),I=$(z);U=p7(I,V,J,W,B,G,X),U=B6(U,D,G,F,Q,O,I,J,dW,b(Y2,V))}else U=U0;return i(j?S0(U):U)}function L2($,Z,j,J,W){let Y=E6(j.calendar,J.calendar),z=W0(W),[X,G,F,Q]=t$(Z,z,6),O=L0(j),K=L0(J),D=H0(K,O),B;if(D)if(X<=6)B=A6(O,K,X,G,F,Q);else{let U=$(Y);B=h7(U,j,J,D,X,z),B=B6(B,K,X,G,F,Q,U,j,L0,z2)}else B=U0;return i(Z?S0(B):B)}function H2($,Z,j,J,W){let Y=E6(j.calendar,J.calendar),z=W0(W);return m7(Z,()=>$(Y),j,J,...t$(Z,z,6,9,6),z)}function C2($,Z,j,J,W){let Y=E6(j.calendar,J.calendar),z=W0(W),X=t$(Z,z,9,9,8),G=$(Y);return m7(Z,()=>G,hZ(G,j),hZ(G,J),...X,z)}function m7($,Z,j,J,W,Y,z,X,G){let F=L0(j),Q=L0(J),O;if(H0(Q,F))if(W===6)O=A6(F,Q,W,Y,z,X);else{let K=Z();O=K.dateUntil(j,J,W,G),Y===6&&z===1||(O=B6(O,Q,W,Y,z,X,K,j,L0,T6))}else O=U0;return i($?S0(O):O)}function _2($,Z,j,J){let W=W0(J),[Y,z,X,G]=t$($,W,5,5),F=p1(S2(Z,j),aZ(z,X),G),Q={...U0,...L6(F,Y)};return i($?S0(Q):Q)}function fF($,Z,j,J,W,Y){let z=H0(J.epochNanoseconds,j.epochNanoseconds);return z?W<6?c7(j.epochNanoseconds,J.epochNanoseconds,W):p7(Z,$,j,J,z,W,Y):U0}function EF($,Z,j,J,W){let Y=L0(Z),z=L0(j),X=H0(z,Y);return X?J<=6?c7(Y,z,J):h7($,Z,j,X,J,W):U0}function p7($,Z,j,J,W,Y,z){let[X,G,F]=((K,D,B,U)=>{function V(){return _={...V$(M,f++*-U),...P},L=w0(K,_),H0(x,L)===-U}let I=_0(D,K),P=k0(o0,I),M=_0(B,K),x=B.epochNanoseconds,f=0,A=S2(I,M),_,L;if(Math.sign(A)===-U&&f++,V()&&(U===-1||V()))throw RangeError(Z3);let N=g0(q0(L,x));return[I,_,N]})(Z,j,J,W);var Q,O;return{...Y===6?(Q=X,O=G,{...U0,days:d7(Q,O)}):$.dateUntil(X,G,Y,z),...L6(F)}}function h7($,Z,j,J,W,Y){let[z,X,G]=((F,Q,O)=>{let K=Q,D=S2(F,Q);return Math.sign(D)===-O&&(K=V$(Q,-O),D+=m*O),[F,K,D]})(Z,j,J);return{...$.dateUntil(z,X,W,Y),...L6(G)}}function A6($,Z,j,J,W,Y){return{...U0,...ZZ(D6(q0($,Z),J,W,Y),j)}}function c7($,Z,j){return{...U0,...ZZ(q0($,Z),j)}}function d7($,Z){return f6(C0($),C0(Z))}function f6($,Z){return Math.trunc((Z-$)/b0)}function S2($,Z){return m1(Z)-m1($)}function E6($,Z){if(!e$($,Z))throw RangeError(h2);return $}function RF($){function Z(W){return((Y,z)=>({...u7(Y,z),F:Y.month,day:parseInt(Y.day)}))(Sj(j,W),J)}let j=j4($),J=r3($);return{id:$,O:bF(Z),B:vF(Z)}}function bF($){return v0((Z)=>{let j=C0(Z);return $(j)},WeakMap)}function vF($){let Z=$(0).year-MQ;return v0((j)=>{let J,W=r$(j-Z),Y=[],z=[];do W+=400*b0;while((J=$(W)).year<=j);do W+=(1-J.day)*b0,J.year===j&&(Y.push(W),z.push(J.F)),W-=b0;while((J=$(W)).year>=j);return{k:Y.reverse(),C:ZY(z.reverse())}})}function u7($,Z){let j,J,W=l7($);if($.era){let Y=QY[Z];Y!==void 0&&(j=Z==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),j==="bc"||j==="b"?j="bce":j!=="ad"&&j!=="a"||(j="ce"),J=W,W=a7(J,Y[j]||0))}return{era:j,eraYear:J,year:W}}function l7($){return parseInt($.relatedYear||$.year)}function Qj($){let{year:Z,F:j,day:J}=this.O($),{C:W}=this.B(Z);return[Z,W[j]+1,J]}function dZ($,Z=1,j=1){return this.B($).k[Z-1]+(j-1)*b0}function p3($){let Z=ZW(this,$),j=ZW(this,$-1),J=Z.length;if(J>j.length){let W=r7(this);if(W<0)return-W;for(let Y=0;Y<J;Y++)if(Z[Y]!==j[Y])return Y+1}}function h3($){return f6(dZ.call(this,$),dZ.call(this,$+1))}function $W($,Z){let{k:j}=this.B($),J=Z+1,W=j;return J>j.length&&(J=1,W=this.B($+1).k),f6(j[Z-1],W[J-1])}function c3($){return this.B($).k.length}function ZW($,Z){return Object.keys($.B(Z).C)}function i7($){return rZ(r($))}function rZ($){if(($=$.toLowerCase())!==v&&$!==q6&&r3($)!==r3(j4($).resolvedOptions().calendar))throw RangeError(aF($));return $}function r3($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function s7($){return this.R($)[0]}function n7($){return this.R($)[1]}function x2($){let[Z]=this.h($);return f6(this.q(Z),C0($))+1}function o7($){let Z=nQ.exec($);if(!Z)throw RangeError(nF($));return[parseInt(Z[1]),Boolean(Z[2])]}function t3($,Z,j){return $+(Z||j&&$>=j?1:0)}function Kj($,Z){return $-(Z&&$>=Z?1:0)}function a7($,Z){return(Z+$)*(Math.sign(Z)||1)||0}function Oj($){return QY[t7($)]}function r7($){return QQ[t7($)]}function t7($){return r3($.id||v)}function e7($,Z,j,J){let W=u1(j,J,n0,[],zY);if(W.timeZone!==void 0){let Y=j.dateFromFields(W),z=I$(W),X=$(W.timeZone);return{epochNanoseconds:U$(Z(X),{...Y,...z},W.offset!==void 0?jZ(W.offset):void 0),timeZone:X}}return{...j.dateFromFields(W),...d0}}function $9($,Z,j,J,W,Y){let z=u1(j,W,n0,WY,zY),X=$(z.timeZone),[G,F,Q]=oZ(Y),O=j.dateFromFields(z,K6(Y,G)),K=I$(z,G);return V0(U$(Z(X),{...O,...K},z.offset!==void 0?jZ(z.offset):void 0,F,Q),X,J)}function Z9($,Z,j){let J=u1($,Z,n0,[],C1),W=k(j);return Y0(N1({...$.dateFromFields(J,K6(j,W)),...I$(J,W)}))}function A2($,Z,j,J=[]){let W=u1($,Z,n0,J);return $.dateFromFields(W,j)}function f2($,Z,j,J){let W=u1($,Z,u2,J);return $.yearMonthFromFields(W,j)}function E2($,Z,j,J,W=[]){let Y=u1($,j,n0,W);return Z&&Y.month!==void 0&&Y.monthCode===void 0&&Y.year===void 0&&(Y.year=o$),$.monthDayFromFields(Y,J)}function j9($,Z){let j=k(Z);return s0(I$($1($,Dj,[],1),j))}function J9($){let Z=$1($,l2);return i($Z({...U0,...Z}))}function u1($,Z,j,J=[],W=[]){return $1(Z,[...$.fields(j),...W].sort(),J)}function $1($,Z,j,J=!j){let W={},Y,z=0;for(let X of Z){if(X===Y)throw RangeError(cF(X));if(X==="constructor"||X==="__proto__")throw RangeError(m2(X));let G=$[X];if(G!==void 0)z=1,YW[X]&&(G=YW[X](G,X)),W[X]=G;else if(j){if(j.includes(X))throw TypeError(g2(X));W[X]=FY[X]}Y=X}if(J&&!z)throw TypeError(i9(Z));return W}function I$($,Z){return F6(tQ({...FY,...$}),Z)}function W9($,Z,j,J,W,Y){let z=W0(Y),{calendar:X,timeZone:G}=j;return V0(((F,Q,O,K,D)=>{let B=tZ(F,O,K,n0,YY,JY),[U,V,I]=oZ(D,2);return U$(Q,{...F.dateFromFields(B,K6(D,U)),...I$(B,U)},jZ(B.offset),V,I)})($(X),Z(G),J,W,z),G,X)}function Y9($,Z,j,J,W){let Y=W0(W);return Y0(((z,X,G,F)=>{let Q=tZ(z,X,G,n0,C1),O=k(F);return N1({...z.dateFromFields(Q,K6(F,O)),...I$(Q,O)})})($(Z.calendar),j,J,Y))}function z9($,Z,j,J,W){let Y=W0(W);return((z,X,G,F)=>{let Q=tZ(z,X,G,n0);return z.dateFromFields(Q,F)})($(Z.calendar),j,J,Y)}function X9($,Z,j,J,W){let Y=W0(W);return F$(((z,X,G,F)=>{let Q=tZ(z,X,G,u2);return z.yearMonthFromFields(Q,F)})($(Z.calendar),j,J,Y))}function G9($,Z,j,J,W){let Y=W0(W);return((z,X,G,F)=>{let Q=tZ(z,X,G,n0);return z.monthDayFromFields(Q,F)})($(Z.calendar),j,J,Y)}function F9($,Z,j){return s0(((J,W,Y)=>{let z=k(Y);return I$({...k0(Dj,J),...$1(W,Dj)},z)})($,Z,j))}function Q9($,Z){return i((j=$,J=Z,$Z({...j,...$1(J,l2)})));var j,J}function tZ($,Z,j,J,W=[],Y=[]){let z=[...$.fields(J),...W].sort(),X=$1(Z,z,Y),G=$1(j,z);return X=$.mergeFields(X,G),$1(X,z,[])}function R2($,Z){let j=u1($,Z,GY);return $.monthDayFromFields(j)}function b2($,Z,j){let J=u1($,Z,XY);return $.yearMonthFromFields(J,j)}function K9($,Z,j,J,W){Z=k0(j=$.fields(j),Z),J=$1(J,W=$.fields(W),[]);let Y=$.mergeFields(Z,J);return Y=$1(Y,[...j,...W].sort(),[]),$.dateFromFields(Y)}function Yj($,Z){let{era:j,eraYear:J,year:W}=Z,Y=Oj($);if(j!==void 0||J!==void 0){if(j===void 0||J===void 0)throw TypeError(uF);if(!Y)throw RangeError(dF);let z=Y[j];if(z===void 0)throw RangeError(iF(j));let X=a7(J,z);if(W!==void 0&&W!==X)throw RangeError(lF);W=X}else if(W===void 0)throw TypeError(sF(Y));return W}function zj($,Z,j,J){let{month:W,monthCode:Y}=Z;if(Y!==void 0){let z=((X,G,F,Q)=>{let O=X.U(F),[K,D]=o7(G),B=t3(K,D,O);if(D){let U=r7(X);if(U===void 0)throw RangeError(gZ);if(U>0){if(B>U)throw RangeError(gZ);if(O===void 0){if(Q===1)throw RangeError(gZ);B--}}else{if(B!==-U)throw RangeError(gZ);if(O===void 0&&Q===1)throw RangeError(gZ)}}return B})($,Y,j,J);if(W!==void 0&&W!==z)throw RangeError(a9);W=z,J=1}else if(W===void 0)throw TypeError(oF);return p0("month",W,1,$.L(j),J)}function jW($,Z,j,J,W){return E0(Z,"day",1,$.j(J,j),W)}function Xj($,Z,j,J){let W=0,Y=[];for(let z of j)Z[z]!==void 0?W=1:Y.push(z);if(Object.assign($,Z),W)for(let z of J||Y)delete $[z]}function O9($){return O0(m0(Y6(W6($))))}function B9($,Z,j,J,W=v){return V0(m0(Y6(W6(j))),Z(J),$(W))}function D9($,Z,j,J,W=0,Y=0,z=0,X=0,G=0,F=0,Q=v){return Y0(N1(G6(u0(N0,a$(g6,[Z,j,J,W,Y,z,X,G,F])))),$(Q))}function U9($,Z,j,J,W=v){return z0(y1(O$(u0(N0,{isoYear:Z,isoMonth:j,isoDay:J}))),$(W))}function V9($,Z,j,J=v,W=1){let Y=N0(Z),z=N0(j),X=$(J);return F$(xj(O$({isoYear:Y,isoMonth:z,isoDay:N0(W)})),X)}function T9($,Z,j,J=v,W=o$){let Y=N0(Z),z=N0(j),X=$(J);return n3(y1(O$({isoYear:N0(W),isoMonth:Y,isoDay:z})),X)}function I9($=0,Z=0,j=0,J=0,W=0,Y=0){return s0(F6(u0(N0,a$(o0,[$,Z,j,J,W,Y])),1))}function M9($=0,Z=0,j=0,J=0,W=0,Y=0,z=0,X=0,G=0,F=0){return i($Z(u0(HW,a$(y,[$,Z,j,J,W,Y,z,X,G,F]))))}function v2($,Z,j=v){return V0($.epochNanoseconds,Z,j)}function P9($){return O0($.epochNanoseconds)}function w2($,Z){return Y0(_0(Z,$))}function k2($,Z){return z0(_0(Z,$))}function N9($,Z,j){return b2($(Z.calendar),j)}function L9($,Z,j){return R2($(Z.calendar),j)}function y2($,Z){return s0(_0(Z,$))}function H9($,Z,j,J){let W=((Y,z,X,G)=>{let F=Rj(G);return w0(Y(z),X,F)})($,j,Z,J);return V0(m0(W),j,Z.calendar)}function C9($,Z,j){let J=$(Z.calendar);return F$({...Z,...b2(J,j)})}function _9($,Z,j){return R2($(Z.calendar),j)}function S9($,Z,j,J,W){let Y=$(W.timeZone),z=W.plainTime,X=z!==void 0?Z(z):d0;return V0(w0(j(Y),{...J,...X}),Y,J.calendar)}function x9($,Z=d0){return Y0(N1({...$,...Z}))}function A9($,Z,j){return b2($(Z.calendar),j)}function f9($,Z,j){return R2($(Z.calendar),j)}function E9($,Z,j,J){return((W,Y,z)=>K9(W,Y,XY,P1(z),J3))($(Z.calendar),j,J)}function R9($,Z,j,J){return((W,Y,z)=>K9(W,Y,GY,P1(z),y6))($(Z.calendar),j,J)}function b9($,Z,j,J,W){let Y=P1(W),z=Z(Y.plainDate),X=$(Y.timeZone);return V0(w0(j(X),{...z,...J}),X,z.calendar)}function v9($,Z){return Y0(N1({...$,...Z}))}function w9($){return O0(m0(s$($,c0)))}function k9($){return O0(m0(s$($,j1)))}function y9($){return O0(m0(Y6(W6($),P$)))}function q9($){return O0(m0(Y6(W6($))))}function g9($,Z,j=d0){let J=Z.timeZone,W=$(J),Y={..._0(Z,W),...j};return V0(U$(W,Y,Y.offsetNanoseconds,2),J,Z.calendar)}function m9($,Z,j){let J=Z.timeZone,W=$(J),Y={..._0(Z,W),...j},z=d9(Z.calendar,j.calendar);return V0(U$(W,Y,Y.offsetNanoseconds,2),J,z)}function p9($,Z=d0){return Y0({...$,...Z})}function h9($,Z){return Y0({...$,...Z},d9($.calendar,Z.calendar))}function R6($,Z){return{...$,calendar:Z}}function c9($,Z){return{...$,timeZone:Z}}function d9($,Z){if($===Z)return $;let j=D0($),J=D0(Z);if(j===J||j===v)return Z;if(J===v)return $;throw RangeError(h2)}function wF($,Z){return(j)=>j===v?$:j===q6||j===n$?Object.assign(Object.create($),{id:j}):Object.assign(Object.create(Z),sQ(j))}function M$($,Z,j){let J=new Set(j);return(W)=>(((Y,z)=>{for(let X of z)if(X in Y)return 1;return 0})(W=Ij(J,W),$)||Object.assign(W,Z),j&&(W.timeZone=H$,["full","long"].includes(W.timeStyle)&&(W.timeStyle="medium")),W)}function L1($,Z=q2){let[j,,,J]=$;return(W,Y=DK,...z)=>{let X=Z(J&&J(...z),W,Y,j),G=X.resolvedOptions();return[X,...kF($,G,z)]}}function q2($,Z,j,J){if(j=J(j),$){if(j.timeZone!==void 0)throw TypeError(XQ);j.timeZone=$}return new l1(Z,j)}function kF($,Z,j){let[,J,W]=$;return j.map((Y)=>(Y.calendar&&((z,X,G)=>{if((G||z!==v)&&z!==X)throw RangeError(h2)})(D0(Y.calendar),Z.calendar,W),J(Y,Z)))}function WZ($){let Z=eZ();return h1(Z,$.getOffsetNanosecondsFor(Z))}function eZ(){return s$(Date.now(),j1)}function H1(){return XW||(XW=new l1().resolvedOptions().timeZone)}var yF=($,Z)=>`Non-integer ${$}: ${Z}`,qF=($,Z)=>`Non-positive ${$}: ${Z}`,gF=($,Z)=>`Non-finite ${$}: ${Z}`,mF=($)=>`Cannot convert bigint to ${$}`,pF=($)=>`Invalid bigint: ${$}`,hF="Cannot convert Symbol to string",u9="Invalid object",l9=($,Z,j,J,W)=>W?l9($,W[Z],W[j],W[J]):$3($,Z)+`; must be between ${j}-${J}`,$3=($,Z)=>`Invalid ${$}: ${Z}`,g2=($)=>`Missing ${$}`,m2=($)=>`Invalid field ${$}`,cF=($)=>`Duplicate field ${$}`,i9=($)=>"No valid fields: "+$.join(),s9="Invalid bag",n9=($,Z,j)=>$3($,Z)+"; must be "+Object.keys(j).join(),o9="Cannot use valueOf",p2="Invalid calling context",dF="Forbidden era/eraYear",uF="Mismatching era/eraYear",lF="Mismatching year/eraYear",iF=($)=>`Invalid era: ${$}`,sF=($)=>"Missing year"+($?"/era/eraYear":""),nF=($)=>`Invalid monthCode: ${$}`,a9="Mismatching month/monthCode",oF="Missing month/monthCode",JW="Cannot guess year",gZ="Invalid leap month",r9="Invalid protocol",Z3="Invalid protocol results",h2="Mismatching Calendars",aF=($)=>`Invalid Calendar: ${$}`,t9="Mismatching TimeZones",rF="Forbidden ICU TimeZone",tF="Out-of-bounds offset",eF="Out-of-bounds TimeZone gap",$Q="Invalid TimeZone offset",ZQ="Ambiguous offset",b6="Out-of-bounds date",jQ="Out-of-bounds duration",JQ="Cannot mix duration signs",v6="Missing relativeTo",WQ="Cannot use large units",YQ="Required smallestUnit or largestUnit",zQ="smallestUnit > largestUnit",R0=($)=>`Cannot parse: ${$}`,M1=($)=>`Invalid substring: ${$}`,e9=($)=>`Cannot format ${$}`,$Y="Mismatching types for formatting",XQ="Cannot specify TimeZone",ZY=b(iZ,($,Z)=>Z),YZ=b(iZ,($,Z,j)=>j),h0=b(l3,2),Bj={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},j3=Object.keys(Bj),b0=86400000,jY=1000,P$=1000,j1=1e6,c0=1e9,w6=60000000000,k6=3600000000000,m=86400000000000,Z1=[1,P$,j1,c0,w6,k6,m],C1=j3.slice(0,6),Dj=sZ(C1),JY=["offset"],WY=["timeZone"],YY=C1.concat(JY),zY=YY.concat(WY),Uj=["era","eraYear"],GQ=Uj.concat(["year"]),y6=["year"],c2=["monthCode"],d2=["month"].concat(c2),J3=["day"],u2=d2.concat(y6),XY=c2.concat(y6),n0=J3.concat(u2),FQ=J3.concat(d2),GY=J3.concat(c2),FY=YZ(C1,0),v="iso8601",q6="gregory",n$="japanese",QY={[q6]:{bce:-1,ce:0},[n$]:{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}},QQ={chinese:13,dangi:13,hebrew:-6},r=b(J6,"string"),KY=b(J6,"boolean"),KQ=b(J6,"number"),OY=b(J6,"function"),y=j3.map(($)=>$+"s"),l2=sZ(y),OQ=y.slice(0,6),BY=y.slice(6),BQ=BY.slice(1),DQ=ZY(y),U0=YZ(y,0),i2=YZ(OQ,0),s2=b(OW,y),o0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],n2=["isoDay","isoMonth","isoYear"],g6=o0.concat(n2),o2=sZ(n2),DY=sZ(o0),UY=sZ(g6),d0=YZ(DY,0),UQ=b(OW,g6),l1=Intl.DateTimeFormat,VY="en-GB",a2=1e8,VQ=a2*b0,TQ=[a2,0],IQ=[-a2,0],uZ=275760,lZ=-271821,MQ=1970,o$=1972,T1=12,PQ=r$(1868,9,8),NQ=v0(NF,WeakMap),e3="smallestUnit",Vj="unit",pZ="roundingIncrement",Gj="fractionalSecondDigits",TY="relativeTo",IY={constrain:0,reject:1},LQ=Object.keys(IY),HQ={compatible:0,reject:1,earlier:2,later:3},CQ={reject:0,use:1,prefer:2,ignore:3},_Q={auto:0,never:1,critical:2,always:3},SQ={auto:0,never:1,critical:2},xQ={auto:0,never:1},AQ={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},W3=b(qj,e3),r2=b(qj,"largestUnit"),fQ=b(qj,Vj),MY=b(B$,"overflow",IY),PY=b(B$,"disambiguation",HQ),EQ=b(B$,"offset",CQ),t2=b(B$,"calendarName",_Q),RQ=b(B$,"timeZoneName",SQ),bQ=b(B$,"offset",xQ),Y3=b(B$,"roundingMode",AQ),zZ="PlainYearMonth",XZ="PlainMonthDay",N$="PlainDate",L$="PlainDateTime",m6="PlainTime",_1="ZonedDateTime",p6="Instant",h6="Duration",vQ=[Math.floor,($)=>m3($)?Math.floor($):Math.round($),Math.ceil,($)=>m3($)?Math.ceil($):Math.round($),Math.trunc,($)=>m3($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>m3($)?($=Math.trunc($)||0)+$%2:Math.round($)],H$="UTC",d3=5184000,wQ=s3(1847),kQ=s3(new Date().getUTCFullYear()+10),yQ=/0+$/,_0=v0(xF,WeakMap),WW=4294967295,c6=v0(($)=>{let Z=V2($);return typeof Z=="object"?new LY(Z):new NY(Z||0)});class NY{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[Aj($,this.v)]}l(){}}class LY{constructor($){this.$=((Z)=>{function j(G){let F=Fj(G,z,X),[Q,O]=t5(F),K=W(Q),D=W(O);return K===D?K:J(Y(Q,O),K,D,G)}function J(G,F,Q,O){let K,D;for(;(O===void 0||(K=O<G[0]?F:O>=G[1]?Q:void 0)===void 0)&&(D=G[1]-G[0]);){let B=G[0]+Math.floor(D/2);Z(B)===Q?G[1]=B:G[0]=B+1}return K}let W=v0(Z),Y=v0(AF),z=wQ,X=kQ;return{G(G){let F=j(G-86400),Q=j(G+86400),O=G-F,K=G-Q;if(F===Q)return[O];let D=j(O);return D===j(K)?[G-D]:F>Q?[O,K]:[]},V:j,l(G,F){let Q=Fj(G,z,X),[O,K]=t5(Q),D=d3*F,B=F<0?()=>K>z||(z=Q,0):()=>O<X||(X=Q,0);for(;B();){let U=W(O),V=W(K);if(U!==V){let I=Y(O,K);J(I,U,V);let P=I[0];if((k1(P,G)||1)===F)return P}O+=D,K+=D}}}})(((Z)=>(j)=>{let J=Sj(Z,j*jY);return s3(l7(J),parseInt(J.month),parseInt(J.day),parseInt(J.hour),parseInt(J.minute),parseInt(J.second))-j})($))}getOffsetNanosecondsFor($){return this.$.V(SW($))*c0}getPossibleInstantsFor($){let[Z,j]=[s3((J=$).isoYear,J.isoMonth,J.isoDay,J.isoHour,J.isoMinute,J.isoSecond),J.isoMillisecond*j1+J.isoMicrosecond*P$+J.isoNanosecond];var J;return this.$.G(Z).map((W)=>m0(i$(s$(W,c0),j)))}l($,Z){let[j,J]=xW($),W=this.$.l(j+(Z>0||J?1:0),Z);if(W!==void 0)return s$(W,c0)}}var e2="([+\u2212-])",u3="(?:[.,](\\d{1,9}))?",HY=`(?:(?:${e2}(\\d{6}))|(\\d{4}))-?(\\d{2})`,$4="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+u3+")?)?",Z4=e2+$4,qQ=HY+"-?(\\d{2})(?:[T ]"+$4+"(Z|"+Z4+")?)?",CY="\\[(!?)([^\\]]*)\\]",d6=`((?:${CY}){0,9})`,gQ=JZ(HY+d6),mQ=JZ("(?:--)?(\\d{2})-?(\\d{2})"+d6),pQ=JZ(qQ+d6),hQ=JZ("T?"+$4+"(?:"+Z4+")?"+d6),cQ=JZ(Z4),dQ=new RegExp(CY,"g"),uQ=JZ(`${e2}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${u3}H)?(?:(\\d+)${u3}M)?(?:(\\d+)${u3}S)?)?`),lQ=v0(($)=>new l1(VY,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),iQ=/^(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$/,sQ=v0(RF),j4=v0(($)=>new l1(VY,{calendar:$,timeZone:H$,era:"short",year:"numeric",month:"short",day:"numeric"})),nQ=/^M(\d{2})(L?)$/,oQ={era:i3,eraYear:N0,year:N0,month:n5,monthCode:i3,day:n5},aQ=YZ(C1,N0),rQ=YZ(y,HW),YW=Object.assign({},oQ,aQ,rQ,{offset:i3}),tQ=b(PF,C1,o0),zW={dateAdd($,Z,j){let J=k(j),W,{years:Y,months:z,weeks:X,days:G}=Z;if(G+=Q0(Z,5)[0],Y||z)W=((F,Q,O,K,D)=>{let[B,U,V]=F.h(Q);if(O){let[I,P]=F.I(B,U);B+=O,U=t3(I,P,F.U(B)),U=p0("month",U,1,F.L(B),D)}return K&&([B,U]=F._(B,U,K)),V=p0("day",V,1,F.j(B,U),D),F.q(B,U,V)})(this,$,Y,z,J);else{if(!X&&!G)return $;W=C0($)}return W+=(7*X+G)*b0,y1(X6(W))},dateUntil($,Z,j){if(j<=7){let G=0,F=d7({...$,...d0},{...Z,...d0});return j===7&&([G,F]=g1(F,7)),{...U0,weeks:G,days:F}}let J=this.h($),W=this.h(Z),[Y,z,X]=((G,F,Q,O,K,D,B)=>{let U=K-F,V=D-Q,I=B-O;if(U||V){let P=Math.sign(U||V),M=G.j(K,D),x=0;if(Math.sign(I)===-P){let f=M;[K,D]=G._(K,D,-P),U=K-F,V=D-Q,M=G.j(K,D),x=P<0?-f:M}if(I=B-Math.min(O,M)+x,U){let[f,A]=G.I(F,Q),[_,L]=G.I(K,D);if(V=_-f||Number(L)-Number(A),Math.sign(V)===-P){let N=P<0&&-G.L(K);U=(K-=P)-F,V=D-t3(f,A,G.U(K))+(N||G.L(K))}}}return[U,V,I]})(this,...J,...W);return j===8&&(z+=this.J(Y,J[0]),Y=0),{...U0,years:Y,months:z,days:X}},dateFromFields($,Z){let j=k(Z),J=Yj(this,$),W=zj(this,$,J,j),Y=jW(this,$,W,J,j);return z0(y1(this.P(J,W,Y)),this.id||v)},yearMonthFromFields($,Z){let j=k(Z),J=Yj(this,$),W=zj(this,$,J,j);return F$(xj(this.P(J,W,1)),this.id||v)},monthDayFromFields($,Z){let j=k(Z),J=!this.id,{monthCode:W,year:Y,month:z}=$,X,G,F,Q,O;if(W!==void 0){[X,G]=o7(W),O=GW($,"day");let K=this.N(X,G,O);if(!K)throw RangeError(JW);if([F,Q]=K,z!==void 0&&z!==Q)throw RangeError(a9);J&&(Q=p0("month",Q,1,T1,1),O=p0("day",O,1,fj(Y!==void 0?Y:F,Q),j))}else{F=Y===void 0&&J?o$:Yj(this,$),Q=zj(this,$,F,j),O=jW(this,$,Q,F,j);let K=this.U(F);G=Q===K,X=Kj(Q,K);let D=this.N(X,G,O);if(!D)throw RangeError(JW);[F,Q]=D}return n3(y1(this.P(F,Q,O)),this.id||v)},fields($){return Oj(this)&&$.includes("year")?[...$,...Uj]:$},mergeFields($,Z){let j=Object.assign(Object.create(null),$);return Xj(j,Z,d2),Oj(this)&&(Xj(j,Z,GQ),this.id===n$&&Xj(j,Z,FQ,Uj)),j},inLeapYear($){let[Z]=this.h($);return this.K(Z)},monthsInYear($){let[Z]=this.h($);return this.L(Z)},daysInMonth($){let[Z,j]=this.h($);return this.j(Z,j)},daysInYear($){let[Z]=this.h($);return this.X(Z)},dayOfYear:x2,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[Z,j]=this.h($),[J,W]=this.I(Z,j);return((Y,z)=>"M"+h0(Y)+(z?"L":""))(J,W)},dayOfWeek:bW,daysInWeek(){return 7}},eQ={dayOfYear:x2,h:fW,q:r$},$K=Object.assign({},eQ,{weekOfYear:s7,yearOfWeek:n7,R($){function Z(D){return(7-D<J?7:0)-D}function j(D){let B=RW(K+D),U=D||1,V=Z(mZ(G+B*U,7));return Q=(B+(V-F)*U)/7}let J=this.id?1:4,W=bW($),Y=this.dayOfYear($),z=mZ(W-1,7),X=Y-1,G=mZ(z-X,7),F=Z(G),Q,O=Math.floor((X-F)/7)+1,K=$.isoYear;return O?O>j(0)&&(O=1,K++):(O=j(-1),K--),[O,K,Q]}}),ZK={dayOfYear:x2,h:Qj,q:dZ,weekOfYear:s7,yearOfWeek:n7,R(){return[]}},GZ=wF(Object.assign({},zW,$K,{h:fW,ee($){return this.id===q6?vW($):this.id===n$?NQ($):[]},I:($,Z)=>[Z,0],N($,Z){if(!Z)return[o$,$]},K:Ej,U(){},L:EW,J:($)=>$*T1,j:fj,X:RW,P:($,Z,j)=>({isoYear:$,isoMonth:Z,isoDay:j}),q:r$,_:($,Z,j)=>($+=Z6(j,T1),(Z+=Pj(j,T1))<1?($--,Z+=T1):Z>T1&&($++,Z-=T1),[$,Z]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},zW,ZK,{h:Qj,ee($){let Z=this.O($);return[Z.era,Z.eraYear]},I($,Z){let j=p3.call(this,$);return[Kj(Z,j),j===Z]},N($,Z,j){let[J,W,Y]=Qj.call(this,{isoYear:o$,isoMonth:T1,isoDay:31}),z=p3.call(this,J),X=W===z;(k1($,Kj(W,z))||k1(Number(Z),Number(X))||k1(j,Y))===1&&J--;for(let G=0;G<100;G++){let F=J-G,Q=p3.call(this,F),O=t3($,Z,Q);if(Z===(O===Q)&&j<=$W.call(this,F,O))return[F,O]}},K($){let Z=h3.call(this,$);return Z>h3.call(this,$-1)&&Z>h3.call(this,$+1)},U:p3,L:c3,J($,Z){let j=Z+$,J=Math.sign($),W=J<0?-1:0,Y=0;for(let z=Z;z!==j;z+=J)Y+=c3.call(this,z+W);return Y},j:$W,X:h3,P($,Z,j){return X6(dZ.call(this,$,Z,j))},q:dZ,_($,Z,j){if(j){if(Z+=j,!Number.isSafeInteger(Z))throw RangeError(b6);if(j<0)for(;Z<1;)Z+=c3.call(this,--$);else{let J;for(;Z>(J=c3.call(this,$));)Z-=J,$++}}return[$,Z]},year($){return this.O($).year},month($){let{year:Z,F:j}=this.O($),{C:J}=this.B(Z);return J[j]+1},day($){return this.O($).day}})),q1="numeric",FZ=["timeZoneName"],_Y={month:q1,day:q1},J4={year:q1,month:q1},W4=Object.assign({},J4,{day:q1}),Y4={hour:q1,minute:q1,second:q1},z4=Object.assign({},W4,Y4),jK=Object.assign({},z4,{timeZoneName:"short"}),JK=Object.keys(J4),WK=Object.keys(_Y),YK=Object.keys(W4),zK=Object.keys(Y4),X4=["dateStyle"],XK=JK.concat(X4),GK=WK.concat(X4),G4=YK.concat(X4,["weekday"]),z3=zK.concat(["dayPeriod","timeStyle"]),F4=G4.concat(z3),FK=F4.concat(FZ),QK=FZ.concat(z3),KK=FZ.concat(G4),OK=FZ.concat(["day","weekday"],z3),BK=FZ.concat(["year","weekday"],z3),DK={},Q4=[M$(F4,z4),O6],SY=[M$(FK,jK),O6,0,($,Z)=>{let j=D0($.timeZone);if(Z&&D0(Z.timeZone)!==j)throw RangeError(t9);return j}],K4=[M$(F4,z4,FZ),C0],O4=[M$(G4,W4,QK),C0],B4=[M$(z3,Y4,KK),($)=>m1($)/j1],D4=[M$(XK,J4,OK),C0,1],U4=[M$(GK,_Y,BK),C0,1],XW;function Y1($,Z,j,J,W){function Y(...G){if(!(this instanceof Y))throw TypeError(p2);EY(this,Z(...G))}function z(G,F){return Object.defineProperties(function(...Q){return G.call(this,X(this),...Q)},Tj(F))}function X(G){let F=M0(G);if(!F||F.branding!==$)throw TypeError(p2);return F}return Object.defineProperties(Y.prototype,{...FW(u0(z,j)),...K$(u0(z,J)),...$6("Temporal."+$)}),Object.defineProperties(Y,{...K$(W),...Tj($)}),[Y,(G)=>{let F=Object.create(Y.prototype);return EY(F,G),F},X]}function vY($){return $=$.concat("id").sort(),(Z)=>{if(!QW(Z,$))throw TypeError(r9);return Z}}function BZ($){if(M0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(s9);return $}function u6($,Z){let j={};for(let J in $)j[J]=({o:W},Y)=>{let z=M0(Y)||{},{branding:X}=z,G=X===N$||Z.includes(X)?z:A0(Y);return W[J](G)};return j}function I4($){let Z={};for(let j in $)Z[j]=(J)=>{let{calendar:W}=J;return(Y=W,typeof Y=="string"?GZ(Y):(z=Y,Object.assign(Object.create(EK),{i:z})))[j](J);var Y,z};return Z}function a1(){throw TypeError(o9)}function G3({calendar:$}){return typeof $=="string"?new x4($):$}function xY($,Z){if(Z=W0(Z),K0($)){let J=M0($);if(J&&J.branding===XZ)return k(Z),J;let W=yY($);return E2(r6(W||v),!W,$,Z)}let j=M7(GZ,$);return k(Z),j}function wY($,Z,j){return J=Z.call($,x0(O0(j))),rj(nZ(J));var J}function l6($,Z=pY){let j=Object.keys(Z).sort(),J={};for(let W of j)J[W]=b(Z[W],$,OY($[W]));return J}function p($,Z){return typeof $=="string"?c6($):l6($,Z)}function G0($){return p($,T4)}function J1($){if(K0($)){let Z=M0($);if(Z)switch(Z.branding){case p6:return Z;case _1:return O0(Z.epochNanoseconds)}}return D7($)}function AY($,Z,j){let J=Z.l(J1(j).epochNanoseconds,$);return J?x0(O0(J)):null}function u($){return K0($)?(M0($)||{}).timeZone||yK($):((Z)=>_6(H7(r(Z))))($)}function i1($,Z){if(K0($)){let j=M0($)||{};switch(j.branding){case m6:return k(Z),j;case L$:return k(Z),s0(j);case _1:return k(Z),y2(G0,j)}return j9($,Z)}return k(Z),P7($)}function M4($){return $===void 0?void 0:i1($)}function QZ($,Z){if(Z=W0(Z),K0($)){let J=M0($);return J&&J.branding===zZ?(k(Z),J):f2(o6(F3($)),$,Z)}let j=I7(GZ,$);return k(Z),j}function s1($,Z){if(Z=W0(Z),K0($)){let J=M0($)||{};switch(J.branding){case L$:return k(Z),J;case N$:return k(Z),Y0({...J,...d0});case _1:return k(Z),w2(G0,J)}return Z9(a6(F3($)),$,Z)}let j=T7($);return k(Z),j}function A0($,Z){if(Z=W0(Z),K0($)){let J=M0($)||{};switch(J.branding){case N$:return k(Z),J;case L$:return k(Z),z0(J);case _1:return k(Z),k2(G0,J)}return A2(a6(F3($)),$,Z)}let j=H6($);return k(Z),j}function kY($,Z,j){return l0(Z.call($,e(z0(j,$))))}function z1($){return(Z)=>typeof Z=="string"?GZ(Z):((j,J)=>{let W=Object.keys(J).sort(),Y={};for(let z of W)Y[z]=b(J[z],j,j[z]);return Y})(Z,$)}function t($){if(K0($)){let Z=M0($);return Z&&Z.branding===h6?Z:J9($)}return N7($)}function X3($){if($!==void 0){if(K0($)){let Z=M0($)||{};switch(Z.branding){case _1:case N$:return Z;case L$:return z0(Z)}let j=F3($);return{...e7(u,p,a6(j),$),calendar:j}}return U7($)}}function F3($){return yY($)||v}function yY($){let{calendar:Z}=$;if(Z!==void 0)return I0(Z)}function I0($){return K0($)?(M0($)||{}).calendar||rK($):((Z)=>rZ(L7(r(Z))))($)}function KZ($,Z){if(Z=W0(Z),K0($)){let j=M0($);if(j&&j.branding===_1)return oZ(Z),j;let J=F3($);return $9(u,p,a6(J),J,$,Z)}return V7($,Z)}function fY($){return u0((Z)=>(j)=>Z(V4(j)),$)}function V4($){return _0($,G0)}function UK(){let $=l1.prototype,Z=Object.getOwnPropertyDescriptors($),j=Object.getOwnPropertyDescriptors(l1),J=function(W,Y={}){if(!(this instanceof J))return new J(W,Y);A4.set(this,((z,X={})=>{let G=new l1(z,X),F=G.resolvedOptions(),Q=F.locale,O=k0(Object.keys(X),F),K=v0(IK),D=(...B)=>{let U,V=B.map((I,P)=>{let M=M0(I),x=(M||{}).branding;if(P&&U&&U!==x)throw TypeError($Y);return U=x,M});return U?K(U)(Q,O,...V):[G,...B]};return D.u=G,D})(W,Y))};for(let W in Z){let Y=Z[W],z=W.startsWith("format")&&VK(W);typeof Y.value=="function"?Y.value=W==="constructor"?J:z||TK(W):z&&(Y.get=function(){return z.bind(this)})}return j.prototype.value=Object.create($,Z),Object.defineProperties(J,j),J}function VK($){return function(...Z){let j=A4.get(this),[J,...W]=j(...Z);return J[$](...W)}}function TK($){return function(...Z){return A4.get(this).u[$](...Z)}}function IK($){let Z=MK[$];if(!Z)throw TypeError(e9($));return L1(Z,v0(q2))}var MK={Instant:Q4,PlainDateTime:K4,PlainDate:O4,PlainTime:B4,PlainYearMonth:D4,PlainMonthDay:U4},PK=L1(Q4),NK=L1(SY),LK=L1(K4),HK=L1(O4),CK=L1(B4),_K=L1(D4),SK=L1(U4),P4={era:TW,eraYear:Nj,year:nZ,month:l0,daysInMonth:l0,daysInYear:l0,inLeapYear:KY,monthsInYear:l0},s6={monthCode:r},N4={day:l0},qY={dayOfWeek:l0,dayOfYear:l0,weekOfYear:IW,yearOfWeek:Nj,daysInWeek:l0},gY=Object.assign({},P4,s6,N4,qY),i6=new WeakMap,M0=i6.get.bind(i6),EY=i6.set.bind(i6),xK={...u6(P4,[zZ]),...u6(qY,[]),...u6(s6,[zZ,XZ]),...u6(N4,[XZ])},L4=I4(gY),AK=I4({...P4,...s6}),fK=I4({...s6,...N4}),Q3={calendarId:($)=>D0($.calendar)},EK=u0(($,Z)=>function(j){let{i:J}=this;return $(J[Z](e(z0(j,J))))},gY),RK=iZ(($)=>(Z)=>Z[$],y.concat("sign")),H4=iZ(($,Z)=>(j)=>j[o0[Z]],C1),mY={epochSeconds:pW,epochMilliseconds:O6,epochMicroseconds:hW,epochNanoseconds:cW},K3=b(Ij,new Set(["branding"])),[bK,OZ,vK]=Y1(XZ,b(T9,I0),{...Q3,...fK},{getISOFields:K3,getCalendar:G3,with($,Z,j){return OZ(G9(nK,$,this,BZ(Z),j))},equals:($,Z)=>q7($,xY(Z)),toPlainDate($,Z){return e(R9(O3,$,this,Z))},toLocaleString($,Z,j){let[J,W]=SK(Z,j,$);return J.format(W)},toString:ij,toJSON:($)=>ij($),valueOf:a1},{from:($,Z)=>OZ(xY($,Z))}),pY={getOffsetNanosecondsFor:wY,getPossibleInstantsFor($,Z,j){let J=[...Z.call($,T0(Y0(j,v)))].map((Y)=>kK(Y).epochNanoseconds),W=J.length;return W>1&&(J.sort(H0),tj(g0(q0(J[0],J[W-1])))),J}},T4={getOffsetNanosecondsFor:wY},[wK,x0,kK]=Y1(p6,O9,mY,{add:($,Z)=>x0(ej(0,$,t(Z))),subtract:($,Z)=>x0(ej(1,$,t(Z))),until:($,Z,j)=>h(P2(0,$,J1(Z),j)),since:($,Z,j)=>h(P2(1,$,J1(Z),j)),round:($,Z)=>x0(lW($,Z)),equals:($,Z)=>b7($,J1(Z)),toZonedDateTime($,Z){let j=P1(Z);return X0(v2($,u(j.timeZone),I0(j.calendar)))},toZonedDateTimeISO:($,Z)=>X0(v2($,u(Z))),toLocaleString($,Z,j){let[J,W]=PK(Z,j,$);return J.format(W)},toString:($,Z)=>hj(u,G0,$,Z),toJSON:($)=>hj(u,G0,$),valueOf:a1},{from:($)=>x0(J1($)),fromEpochSeconds:($)=>x0(w9($)),fromEpochMilliseconds:($)=>x0(k9($)),fromEpochMicroseconds:($)=>x0(y9($)),fromEpochNanoseconds:($)=>x0(q9($)),compare:($,Z)=>T2(J1($),J1(Z))}),[n6,fV]=Y1("TimeZone",($)=>{let Z=E7($);return{branding:"TimeZone",id:Z,o:c6(Z)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},Z)=>$.getPossibleInstantsFor(s1(Z)).map((j)=>x0(O0(j))),getOffsetNanosecondsFor:({o:$},Z)=>$.getOffsetNanosecondsFor(J1(Z).epochNanoseconds),getOffsetStringFor($,Z){let j=J1(Z).epochNanoseconds,J=l6(this,T4).getOffsetNanosecondsFor(j);return D$(J)},getPlainDateTimeFor($,Z,j=v){let J=J1(Z).epochNanoseconds,W=l6(this,T4).getOffsetNanosecondsFor(J);return T0(Y0(h1(J,W),I0(j)))},getInstantFor($,Z,j){let J=s1(Z),W=Rj(j),Y=l6(this);return x0(O0(w0(Y,J,W)))},getNextTransition:({o:$},Z)=>AY(1,$,Z),getPreviousTransition:({o:$},Z)=>AY(-1,$,Z),equals($,Z){return!!x6(this,u(Z))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let Z=u($);return typeof Z=="string"?new n6(Z):Z}}),yK=vY(Object.keys(pY)),[qK,n1]=Y1(m6,I9,H4,{getISOFields:K3,with($,Z,j){return n1(F9(this,BZ(Z),j))},add:($,Z)=>n1(W2(0,$,t(Z))),subtract:($,Z)=>n1(W2(1,$,t(Z))),until:($,Z,j)=>h(_2(0,$,i1(Z),j)),since:($,Z,j)=>h(_2(1,$,i1(Z),j)),round:($,Z)=>n1(nW($,Z)),equals:($,Z)=>g7($,i1(Z)),toZonedDateTime:($,Z)=>X0(b9(u,A0,p,$,Z)),toPlainDateTime:($,Z)=>T0(v9($,A0(Z))),toLocaleString($,Z,j){let[J,W]=CK(Z,j,$);return J.format(W)},toString:sj,toJSON:($)=>sj($),valueOf:a1},{from:($,Z)=>n1(i1($,Z)),compare:($,Z)=>S6(i1($),i1(Z))}),[gK,o1,mK]=Y1(zZ,b(V9,I0),{...Q3,...AK},{getISOFields:K3,getCalendar:G3,with($,Z,j){return o1(X9(sK,$,this,BZ(Z),j))},add:($,Z,j)=>o1(J2(RY,0,$,t(Z),j)),subtract:($,Z,j)=>o1(J2(RY,1,$,t(Z),j)),until:($,Z,j)=>h(C2(bY,0,$,QZ(Z),j)),since:($,Z,j)=>h(C2(bY,1,$,QZ(Z),j)),equals:($,Z)=>y7($,QZ(Z)),toPlainDate($,Z){return e(E9(O3,$,this,Z))},toLocaleString($,Z,j){let[J,W]=_K(Z,j,$);return J.format(W)},toString:lj,toJSON:($)=>lj($),valueOf:a1},{from:($,Z)=>o1(QZ($,Z)),compare:($,Z)=>T$(QZ($),QZ(Z))}),[pK,T0]=Y1(L$,b(D9,I0),{...Q3,...L4,...H4},{getISOFields:K3,getCalendar:G3,with($,Z,j){return T0(Y9(O3,$,this,BZ(Z),j))},withCalendar:($,Z)=>T0(R6($,I0(Z))),withPlainDate:($,Z)=>T0(h9($,A0(Z))),withPlainTime:($,Z)=>T0(p9($,M4(Z))),add:($,Z,j)=>T0(Z2(C$,0,$,t(Z),j)),subtract:($,Z,j)=>T0(Z2(C$,1,$,t(Z),j)),until:($,Z,j)=>h(L2(W1,0,$,s1(Z),j)),since:($,Z,j)=>h(L2(W1,1,$,s1(Z),j)),round:($,Z)=>T0(sW($,Z)),equals:($,Z)=>w7($,s1(Z)),toZonedDateTime:($,Z,j)=>X0(H9(p,$,u(Z),j)),toPlainDate:($)=>e(z0($)),toPlainTime:($)=>n1(s0($)),toPlainYearMonth($){return o1(C9(o6,$,this))},toPlainMonthDay($){return OZ(_9(r6,$,this))},toLocaleString($,Z,j){let[J,W]=LK(Z,j,$);return J.format(W)},toString:dj,toJSON:($)=>dj($),valueOf:a1},{from:($,Z)=>T0(s1($,Z)),compare:($,Z)=>M2(s1($),s1(Z))}),[hK,e,hY]=Y1(N$,b(U9,I0),{...Q3,...L4},{getISOFields:K3,getCalendar:G3,with($,Z,j){return e(z9(O3,$,this,BZ(Z),j))},withCalendar:($,Z)=>e(R6($,I0(Z))),add:($,Z,j)=>e(j2(C$,0,$,t(Z),j)),subtract:($,Z,j)=>e(j2(C$,1,$,t(Z),j)),until:($,Z,j)=>h(H2(W1,0,$,A0(Z),j)),since:($,Z,j)=>h(H2(W1,1,$,A0(Z),j)),equals:($,Z)=>k7($,A0(Z)),toZonedDateTime($,Z){let j=!K0(Z)||Z instanceof n6?{timeZone:Z}:Z;return X0(S9(u,i1,p,$,j))},toPlainDateTime:($,Z)=>T0(x9($,M4(Z))),toPlainYearMonth($){return o1(A9(o6,$,this))},toPlainMonthDay($){return OZ(f9(r6,$,this))},toLocaleString($,Z,j){let[J,W]=HK(Z,j,$);return J.format(W)},toString:uj,toJSON:($)=>uj($),valueOf:a1},{from:($,Z)=>e(A0($,Z)),compare:($,Z)=>T$(A0($),A0(Z))}),C4={fields($,Z,j){return[...Z.call($,j)]}},cY=Object.assign({dateFromFields($,Z,j,J){return hY(Z.call($,Object.assign(Object.create(null),j),J))}},C4),dY=Object.assign({yearMonthFromFields($,Z,j,J){return mK(Z.call($,Object.assign(Object.create(null),j),J))}},C4),uY=Object.assign({monthDayFromFields($,Z,j,J){return vK(Z.call($,Object.assign(Object.create(null),j),J))}},C4),_4={mergeFields($,Z,j,J){return P1(Z.call($,Object.assign(Object.create(null),j),Object.assign(Object.create(null),J)))}},cK=Object.assign({},cY,_4),dK=Object.assign({},dY,_4),uK=Object.assign({},uY,_4),S4={dateAdd($,Z,j,J,W){return hY(Z.call($,e(z0(j,$)),h(i(J)),W))}},lY=Object.assign({},S4,{dateUntil($,Z,j,J,W,Y){return aK(Z.call($,e(z0(j,$)),e(z0(J,$)),Object.assign(Object.create(null),Y,{largestUnit:j3[W]})))}}),lK=Object.assign({},S4,{day:kY}),iK=Object.assign({},lY,{day:kY}),o6=z1(dY),a6=z1(cY),r6=z1(uY),sK=z1(dK),O3=z1(cK),nK=z1(uK),C$=z1(S4),W1=z1(lY),RY=z1(lK),bY=z1(iK),[oK,h,aK]=Y1(h6,M9,{...RK,blank:K7},{with:($,Z)=>h(Q9($,Z)),negated:($)=>h(N6($)),abs:($)=>h(Q7($)),add:($,Z,j)=>h(F2(X3,W1,p,0,$,t(Z),j)),subtract:($,Z,j)=>h(F2(X3,W1,p,1,$,t(Z),j)),round:($,Z)=>h(F7(X3,W1,p,$,Z)),total:($,Z)=>uW(X3,W1,p,$,Z),toLocaleString($,Z,j){return Intl.DurationFormat?new Intl.DurationFormat(Z,j).format(this):V6($)},toString:V6,toJSON:($)=>V6($),valueOf:a1},{from:($)=>h(t($)),compare:($,Z,j)=>R7(X3,C$,p,t($),t(Z),j)}),iY={toString:($)=>$.id,toJSON:($)=>$.id,...xK,dateAdd:({id:$,o:Z},j,J,W)=>e(z0(Z.dateAdd(A0(j),t(J),W),$)),dateUntil:({o:$},Z,j,J)=>h(i($.dateUntil(A0(Z),A0(j),kW(J)))),dateFromFields:({id:$,o:Z},j,J)=>e(A2(Z,j,J,VW($))),yearMonthFromFields:({id:$,o:Z},j,J)=>o1(f2(Z,j,J,DW($))),monthDayFromFields:({id:$,o:Z},j,J)=>OZ(E2(Z,0,j,J,UW($))),fields({o:$},Z){let j=new Set(n0),J=[];for(let W of Z){if(r(W),!j.has(W))throw RangeError(m2(W));j.delete(W),J.push(W)}return $.fields(J)},mergeFields:({o:$},Z,j)=>$.mergeFields(Mj(Lj(Z)),Mj(Lj(j)))},[x4]=Y1("Calendar",($)=>{let Z=i7($);return{branding:"Calendar",id:Z,o:GZ(Z)}},{id:($)=>$.id},iY,{from($){let Z=I0($);return typeof Z=="string"?new x4(Z):Z}}),rK=vY(Object.keys(iY).slice(4)),[tK,X0]=Y1(_1,b(B9,I0,u),{...mY,...Q3,...fY(L4),...fY(H4),offset:($)=>D$(V4($).offsetNanoseconds),offsetNanoseconds:($)=>V4($).offsetNanoseconds,timeZoneId:($)=>D0($.timeZone),hoursInDay:($)=>oW(p,$)},{getISOFields:($)=>X7(G0,$),getCalendar:G3,getTimeZone:({timeZone:$})=>typeof $=="string"?new n6($):$,with($,Z,j){return X0(W9(O3,p,$,this,BZ(Z),j))},withCalendar:($,Z)=>X0(R6($,I0(Z))),withTimeZone:($,Z)=>X0(c9($,u(Z))),withPlainDate:($,Z)=>X0(m9(p,$,A0(Z))),withPlainTime:($,Z)=>X0(g9(p,$,M4(Z))),add:($,Z,j)=>X0($2(C$,p,0,$,t(Z),j)),subtract:($,Z,j)=>X0($2(C$,p,1,$,t(Z),j)),until:($,Z,j)=>h(i(N2(W1,p,0,$,KZ(Z),j))),since:($,Z,j)=>h(i(N2(W1,p,1,$,KZ(Z),j))),round:($,Z)=>X0(iW(p,$,Z)),startOfDay:($)=>X0(aW(p,$)),equals:($,Z)=>v7($,KZ(Z)),toInstant:($)=>x0(P9($)),toPlainDateTime:($)=>T0(w2(G0,$)),toPlainDate:($)=>e(k2(G0,$)),toPlainTime:($)=>n1(y2(G0,$)),toPlainYearMonth($){return o1(N9(o6,$,this))},toPlainMonthDay($){return OZ(L9(r6,$,this))},toLocaleString($,Z,j={}){let[J,W]=NK(Z,j,$);return J.format(W)},toString:($,Z)=>cj(G0,$,Z),toJSON:($)=>cj(G0,$),valueOf:a1},{from:($,Z)=>X0(KZ($,Z)),compare:($,Z)=>I2(KZ($),KZ(Z))}),eK=Object.defineProperties({},{...$6("Temporal.Now"),...K$({timeZoneId:()=>H1(),instant:()=>x0(O0(eZ())),zonedDateTime:($,Z=H1())=>X0(V0(eZ(),u(Z),I0($))),zonedDateTimeISO:($=H1())=>X0(V0(eZ(),u($),v)),plainDateTime:($,Z=H1())=>T0(Y0(WZ(G0(u(Z))),I0($))),plainDateTimeISO:($=H1())=>T0(Y0(WZ(G0(u($))),v)),plainDate:($,Z=H1())=>e(z0(WZ(G0(u(Z))),I0($))),plainDateISO:($=H1())=>e(z0(WZ(G0(u($))),v)),plainTimeISO:($=H1())=>n1(s0(WZ(G0(u($)))))})}),DZ=Object.defineProperties({},{...$6("Temporal"),...K$({PlainYearMonth:gK,PlainMonthDay:bK,PlainDate:hK,PlainTime:qK,PlainDateTime:pK,ZonedDateTime:tK,Instant:wK,Calendar:x4,TimeZone:n6,Duration:oK,Now:eK})}),$O=UK(),A4=new WeakMap,ZO=Object.defineProperties(Object.create(Intl),K$({DateTimeFormat:$O}));class f4 extends Error{code;constructor($,Z=`OAuth callback failed: ${$}`){super(Z);this.name="OAuthCallbackError",this.code=$}}class jO{linkByEmail=!0;createUsers=!0}import{createHash as E4,createHmac as JO,randomBytes as sY,timingSafeEqual as aY}from"crypto";var D3=600,t6="gemi_oauth",WO=`__Host-${t6}`;function UZ($,Z=t6){if(Z===t6)return $?WO:t6;return $?`__Host-${Z}`:Z}function B3($){return $.toString("base64url")}function rY($){return JO("sha256",c$()).update(`gemi-oauth-state:${$}`).digest()}function nY($,Z){let j=E4("sha256").update($).digest(),J=E4("sha256").update(Z).digest();return aY(j,J)&&$.length===Z.length}function e6($,Z=Date.now(),j={}){let J=B3(sY(32)),W=B3(sY(32)),Y=YO(W),z={provider:$,state:J,codeVerifier:W,expiresAt:Z+D3*1000,...j.subject!==void 0?{subject:j.subject}:{},...j.returnTo!==void 0?{returnTo:j.returnTo}:{}};return{state:J,codeVerifier:W,codeChallenge:Y,cookieValue:zO(z)}}function YO($){return B3(E4("sha256").update($).digest())}function zO($){let Z=B3(Buffer.from(JSON.stringify($)));return`${Z}.${B3(rY(Z))}`}function XO($){if(typeof $!=="string"||$==="")return null;let Z=$.indexOf(".");if(Z<=0||Z!==$.lastIndexOf("."))return null;let j=$.slice(0,Z),J=Buffer.from($.slice(Z+1),"base64url"),W=rY(j);if(J.length!==W.length||!aY(J,W))return null;try{let Y=JSON.parse(Buffer.from(j,"base64url").toString("utf8"));if(typeof Y?.provider!=="string"||typeof Y?.state!=="string"||typeof Y?.codeVerifier!=="string"||typeof Y?.expiresAt!=="number"||Y.subject!==void 0&&typeof Y.subject!=="string"||Y.returnTo!==void 0&&typeof Y.returnTo!=="string")return null;return Y}catch{return null}}var r1=new Map,oY=1e4;function GO($,Z,j){if(r1.size>=oY){for(let[J,W]of r1)if(W<=j)r1.delete(J);while(r1.size>=oY){let J=r1.keys().next().value;if(J===void 0)break;r1.delete(J)}}r1.set($,Z)}function $8($){let Z=$.now??Date.now();if(!$.cookieValue||!$.returnedState)return{ok:!1,reason:"missing_state"};let j=XO($.cookieValue);if(!j)return{ok:!1,reason:"invalid_state"};let J=nY(j.state,$.returnedState),W=nY(j.provider,$.provider);if(!J||!W)return{ok:!1,reason:"invalid_state"};if(j.expiresAt<=Z)return{ok:!1,reason:"expired_state"};if(r1.has(j.state))return{ok:!1,reason:"invalid_state"};return GO(j.state,j.expiresAt,Z),{ok:!0,payload:j}}var R4=new WeakMap;function QO($){let Z=R4.get($);if(!Z)Z=$(FO(32).toString("hex")),R4.set($,Z),Z.catch(()=>R4.delete($));return Z}async function b4($,Z,j){if(typeof j==="string"&&j!=="")return await $.verifyPassword(Z,j);try{await $.verifyPassword(Z,await QO($.hashPassword))}catch{}return!1}async function _$($,Z){let j=Z.user??Z.session?.user;if(!j||!$.onAuthenticated)return;let{password:J,...W}=j;await $.onAuthenticated({...Z,user:W})}class w4 extends Error{}function v4($){return typeof $==="string"&&$!==""?$:null}function tY($){return qZ($)}var KO=256;function eY($){return typeof $==="string"&&$!==""&&$.length<=KO?$:null}var Z8="intended_url";function Zz($){if($.cookies.get(Z8))$.ctx().setCookie(Z8,"",{maxAge:-1})}function $z($){let Z=$.cookies.get(Z8);if(!Z)return null;Zz($);try{return U1(decodeURIComponent(Z),"")||null}catch{return null}}class k4 extends S{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class jz extends S{schema={email:{required:"Email is required",email:"Invalid email"}}}class Jz extends S{schema={password:{required:"Password is required",password:"Invalid password"}}}class s extends kZ{async me(){let $=await X1.user();if(!$)throw new n8;return $}async verifyEmail($=new S){let Z=await $.input(),{userProvider:j}=T(E),J=v4(Z.get("token"));if(!J)return{email:null};let W=await j.findUserByVerificationToken(J);if(!W)return{email:null};return await j.verifyUser(W.email),{email:W.email}}async signInWithMagicLink($=new S){let Z=T(E),{userProvider:j}=Z,J=v4($.search.get("token")),W=null;try{W=qZ(decodeURIComponent($.search.get("email")??""))}catch{}if(await d$("link",null,$,{perIp:Z.config.emailCode.verifyLimit.perIp}),!W||!J||!await Z.verifyMagicLinkToken(W,J))return{error:"Invalid token"};await j.verifyUser(W);let Y=await Z.createOrUpdateSession({email:W});return $.ctx().setCookie("access_token",Y.token,T(E).accessTokenCookieOptions($,Y.expiresAt)),await Z.config.onSignIn(Y,$.search.toJSON()),await _$(Z.config,{session:Y,isNewUser:!1,method:"magic-link",req:$}),{session:Y}}async verifyPinRequest($){let Z=T(E),j=await $.input(),{email:J,pin:W}=j.toJSON(),Y=qZ(J),z=eY(W);if(await d$("verify",Y,$,Z.config.emailCode.verifyLimit),!Y||!z)throw new g({pin:["Invalid pin"]});let X=await Z.verifyOneTimeCode(Y,z);if(X.status==="too_many_attempts")throw new g({pin:["Too many attempts"]});if(X.status!=="ok")throw new g({pin:["Invalid pin"]});return await Z.userProvider.verifyUser(Y),Y}async signInWithPinV2($=new S){let Z=T(E),j=await this.verifyPinRequest($),J=await Z.createOrUpdateSessionV2({email:j});return $.ctx().setCookie("access_token",J.token,T(E).accessTokenCookieOptions($,J.expiresAt)),await Z.config.onSignIn(J,$.search.toJSON()),await _$(Z.config,{session:J,isNewUser:!1,method:"magic-link",req:$}),J}async signInWithPin($=new S){let Z=T(E),j=await this.verifyPinRequest($),J=await Z.createOrUpdateSession({email:j});return $.ctx().setCookie("access_token",J.token,T(E).accessTokenCookieOptions($,J.expiresAt)),await Z.config.onSignIn(J,$.search.toJSON()),await _$(Z.config,{session:J,isNewUser:!1,method:"magic-link",req:$}),{session:J}}async signInV2($=new k4){let Z=await $.input(),{email:j,password:J}=Z.toJSON(),W=j.toLowerCase().trim(),Y=T(E),z=await Y.userProvider.findUserByEmailAddress(W,Y.config.verifyEmail),X=typeof J==="string"&&await b4(Y.config,J,z?.password);if(!z||!X)throw new g({invalid_credentials:["Invalid credentials"]});let G=await Y.createOrUpdateSessionV2({email:z.email,id:z.id});$.ctx().setCookie("access_token",G.token,T(E).accessTokenCookieOptions($,G.expiresAt)),await Y.config.onSignIn(z,$.search.toJSON()),await _$(Y.config,{session:G,user:z,isNewUser:!1,method:"password",req:$});let{password:F,...Q}=z;return Q}async signIn($=new k4){let Z=await $.input(),{email:j,password:J}=Z.toJSON(),W=j.toLowerCase().trim(),Y=T(E),z=await Y.userProvider.findUserByEmailAddress(W,Y.config.verifyEmail),X=typeof J==="string"&&await b4(Y.config,J,z?.password);if(!z||!X)throw new g({invalid_credentials:["Invalid credentials"]});let G=await Y.createOrUpdateSession({email:z.email,id:z.id});$.ctx().setCookie("access_token",G.token,T(E).accessTokenCookieOptions($,G.expiresAt)),await Y.config.onSignIn(z,$.search.toJSON()),await _$(Y.config,{session:G,user:z,isNewUser:!1,method:"password",req:$});let{password:F,...Q}=z;return Q}async signUp(){let $=T(E),{userProvider:Z,config:j}=$,J=new j.signUpRequest,W=await J.input(),{email:Y,password:z,name:X,invitationId:G}=W.toJSON(),F=tY(Y);if(!F)throw new g({email:["Invalid email"]});if(z!=null&&typeof z!=="string")throw new g({password:["Invalid password"]});if(G!=null&&typeof G!=="string")throw new g({invitationId:["Invalid invitation"]});if(await Z.findUserByEmailAddress(F,!1))throw new g({email:["Email address already exists"]});let O=await j.hashPassword(z),K=T(a).detectLocale(J),D;if(G)D=await Z.findInvitation(G,F);let B,U="";if(D)B=await Z.transaction(async()=>{await Z.deleteInvitationById(G);let V=await Z.createUser({email:F,name:X,password:O,emailVerifiedAt:new Date,locale:K});return await Z.createAccount({organizationId:D.organizationId,userId:V.id,organizationRole:D.role}),await j.onUserCreated(V),V});else U=await j.generateEmailVerificationToken(F),B=await Z.transaction(async()=>{let V=await Z.createUser({email:F,name:X,password:O,verificationToken:U,locale:K});return await j.onUserCreated(V),V});return await j.onSignUp(B,U,J.search.toJSON()),B}async signOut($=new S){let Z=bZ($),j=T(E),{config:J}=j,W=await j.revokeSession(Z,$.headers.get("User-Agent"));if($.ctx().setCookie("access_token","",T(E).accessTokenCookieOptions($,new Date(0))),T(E).cookieDomain($))$.ctx().setCookie("access_token","",{...T(E).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(W?.user)W.user.extension=await J.extendSession(W.user),await J.onSignOut(W.user);return{}}async forgotPassword($=new jz){let Z=await $.input(),j=tY(Z.get("email"));if(!j)return{};let{userProvider:J,config:W}=T(E),Y=await J.findUserByEmailAddress(j,W.verifyEmail);if(!Y)return{};let z=await W.generateForgotPasswordToken(Y);return await J.createPasswordResetToken({user:Y,token:z}),await W.onForgotPassword(Y,z),{}}async resetPassword($=new Jz){let{userProvider:Z,config:j}=T(E),J=await $.input(),{password:W,token:Y}=J.toJSON(),z=v4(Y),X=z?await Z.findPasswordResetToken({token:z}):null;if(!X)throw new g({token:["Invalid token"]});if(DZ.Instant.from(X.createdAt.toISOString()).add({hours:24}).until(DZ.Now.instant()).sign>=0)throw new g({token:["Token expired"]});await Z.deletePasswordResetToken({token:z});let F=await Z.findUserByEmailAddress(X.user.email,j.verifyEmail);if(!F)throw new g({email:["User not found"]});let Q=await j.hashPassword(W);return await Z.updateUserPassword({id:F.id,password:Q}),await Z.deleteAllUserSessions(F.id),await j.onResetPassword(F),{}}async changePassword($=new S){let{userProvider:Z,config:j}=T(E),J=await X1.user(),W=await $.input(),{oldPassword:Y,newPassword:z}=W.toJSON();if(typeof z!=="string")throw new g({newPassword:["Invalid password"]});let X=await Z.findUserByEmailAddress(J.email,j.verifyEmail);if(!(typeof Y==="string"&&await b4(j,Y,X?.password)))throw new g({oldPassword:["Incorrect password"]});let F=await j.hashPassword(z);return await Z.updateUserPassword({id:J.id,password:F}),await Z.deleteAllUserSessions(J.id),{}}async oauthRedirect($=new S){let{provider:Z}=$.params,j=T(E).config.oauthProviders[Z];if(!j)throw Error(`Invalid provider: ${Z}`);let J=q$($.rawRequest),W=U1($.search.get(D1),"");if(W)$.ctx().setCookie(Z8,encodeURIComponent(W),{httpOnly:!0,sameSite:"Lax",secure:J,maxAge:600});else Zz($);let{state:Y,codeChallenge:z,cookieValue:X}=e6(Z);return $.ctx().setCookie(UZ(J),X,{httpOnly:!0,sameSite:"Lax",secure:J,maxAge:D3}),{destination:await j.getRedirectUrl($,{state:Y,codeChallenge:z,codeChallengeMethod:"S256"})}}async oauthCallback($=new S){let{provider:Z}=$.params,j=T(E),{userProvider:J,config:W}=j,Y=W.oauthProviders[Z],z=q$($.rawRequest),X=UZ(z),G=$.cookies.get(X);if(G!==void 0&&G!==null)$.ctx().setCookie(X,"",{httpOnly:!0,sameSite:"Lax",secure:z,maxAge:-1});if(!Y)return this.oauthFailure($,"unknown_provider");let F=$.search.get("error");if(F)return this.oauthFailure($,/^[a-z0-9_]{1,64}$/.test(F)?F:"provider_error");let Q=$8({provider:Z,cookieValue:G,returnedState:$.search.get("state")});if("reason"in Q)return console.error(`Authentication error: OAuth callback refused (${Q.reason})`),this.oauthFailure($,Q.reason);if(!$.search.get("code"))return this.oauthFailure($,"missing_code");let O;try{O=await Y.onCallback($,{state:Q.payload.state,codeVerifier:Q.payload.codeVerifier})}catch(A){if(A instanceof f4)return this.oauthFailure($,A.code);return console.error("Authentication error: OAuth provider callback failed",A),this.oauthFailure($,"provider_error")}let{name:K,username:D,providerId:B,emailVerified:U}=O??{},V=typeof O?.email==="string"?O.email:void 0,I=V?q3(V):null,P=B?await J.findUserBySocialAccount(Z,B):null,M="signin";if(!P){if(!I)return console.error("Authentication error: No usable email returned from OAuth provider callback"),this.oauthFailure($,V?"invalid_email":B?"missing_email":"no_identity");if(U===!1)return console.error("Authentication error: OAuth provider returned an unverified email"),this.oauthFailure($,"email_not_verified");let A=T(a).detectLocale($);try{let _=await this.linkOAuthAccount({provider:Z,providerId:B,email:I,rawEmail:V,name:K,username:D,locale:A,linkExisting:Y.linkByEmail!==!1,createUser:Y.createUsers!==!1});if(_==="account_exists")return console.error(`Authentication error: a ${Z} sign-in matched an existing user by email, and ${Z} does not link by email`),this.oauthFailure($,"account_exists");if(_==="signup_disabled")return console.error(`Authentication error: a ${Z} sign-in is not linked to a user, and ${Z} does not create users`),this.oauthFailure($,"signup_disabled");if(_)P=_.user,M=_.action}catch(_){let L=B?await J.findUserBySocialAccount(Z,B):null;if(!L)throw _;P=L}if(!P)return this.oauthFailure($,"account_conflict")}let x=await j.createOrUpdateSessionV2({email:P.email,id:P.id});if($.ctx().setCookie("access_token",x.token,T(E).accessTokenCookieOptions($,x.expiresAt)),M==="signup")await W.onSignUp(P,"",$.search.toJSON());else await W.onSignIn(P,$.search.toJSON());await _$(j.config,{session:x,user:P,isNewUser:M==="signup",method:"oauth",req:$});let f=$z($)??W.redirectPath;return{session:x,redirectTo:f}}oauthFailure($,Z){let j=$z($),J=T(E).config.oauthFailurePath;if(J){let W=U1(J,"");if(W){let Y=new URL(W,"http://gemi.invalid");if(Y.searchParams.set("error",Z),j)Y.searchParams.set(D1,j);O1.external(`${Y.pathname}${Y.search}${Y.hash}`)}else console.error(`auth.oauthFailurePath must be a same-origin path, got ${JSON.stringify(J)}`)}return{session:null,error:Z,redirectTo:j}}async linkOAuthAccount($){let{provider:Z,providerId:j,email:J,rawEmail:W,name:Y,username:z,locale:X}=$,{userProvider:G,config:F}=T(E),Q=(B)=>({provider:Z,userId:B,email:J,username:z,providerId:j,expiresAt:new Date,accessToken:"",refreshToken:""}),O=await G.findUserByEmailAddress(J,!1),K=W?.trim();if(!O&&K&&K!==J)O=await G.findUserByEmailAddress(K,!1);if(O){if($.linkExisting===!1)return"account_exists";if(!j)return{user:O,action:"signin"};let B=await G.findSocialAccounts(O.id,Z);if(B.some((V)=>V.providerId===j))return{user:O,action:"signin"};if(B.some((V)=>V.providerId))return console.error(`Authentication error: user ${O.id} is already linked to a different ${Z} account`),null;let U=B[0];if(U){if(!await G.claimSocialAccount(U,j))throw Error(`${Z} account link changed concurrently`)}else await G.createSocialAccount(Q(O.id));return{user:O,action:"signin"}}if($.createUser===!1)return"signup_disabled";return{user:await G.transaction(async()=>{let B=await G.createUser({email:J,name:Y,locale:X,emailVerifiedAt:new Date});if(j)await G.createSocialAccount(Q(B.id));return await F.onUserCreated(B),B}),action:"signup"}}async createMagicLinkToken($=new S){let Z=await $.input(),j=qZ(Z.get("email")),J=T(E),{uniformMagicLinkResponse:W,requestLimit:Y}=J.config.emailCode;if(await d$("request",j,$,Y),!j)return{email:null};let{user:z,pin:X,token:G}=await J.createMagicLinkToken(j);if(z)return await J.config.onMagicLinkCreated(z,{email:j,pin:X,token:G}),{email:j};return{email:W?j:null}}async requestEmailCode($=new S){let Z=T(E),j=Z.config.emailCode;if(!j.enabled)throw new P0("Not found",{status:404});let J=await $.input(),W=q3(J.get("email"));if(await d$("request",W,$,j.requestLimit),!W)throw new g({email:["Invalid email"]});let Y=await Z.userProvider.findUserByEmailAddress(W,!1);if(Y||j.createUser){let{pin:z,token:X}=await Z.issueOneTimeCode(W,j.length);await j.send({email:W,code:z,token:X,isNewUser:!Y,req:$})}return{ok:!0}}async verifyEmailCode($=new S){let Z=T(E),{userProvider:j,config:J}=Z;if(!J.emailCode.enabled)throw new P0("Not found",{status:404});let W=await $.input(),{email:Y,code:z,name:X}=W.toJSON(),G=q3(Y),F=eY(z);if(await d$("verify",G,$,J.emailCode.verifyLimit),!G||!F)throw new g({code:["invalid_code"]});let Q=await Z.verifyOneTimeCode(G,F,{claim:!1});if(Q.status==="too_many_attempts")throw new g({code:["too_many_attempts"]});if(Q.status!=="ok")throw new g({code:["invalid_code"]});let O=Q.row,K=await j.findUserByEmailAddress(G,!1),D=!1;if(K){if(!await j.claimMagicLinkToken(O.id))throw new g({code:["invalid_code"]});await j.verifyUser(G)}else if(J.emailCode.createUser){let U=T(a).detectLocale($);try{K=await j.transaction(async()=>{if(!await j.claimMagicLinkToken(O.id))throw new w4;let V=await j.createUser({email:G,name:typeof X==="string"?X.trim():"",emailVerifiedAt:new Date,locale:U});return await J.onUserCreated(V),V}),D=!0}catch(V){if(V instanceof w4)throw new g({code:["invalid_code"]});throw V}}else throw await j.claimMagicLinkToken(O.id),new g({code:["invalid_code"]});let B=await Z.createOrUpdateSessionV2({email:G,id:K.id});return $.ctx().setCookie("access_token",B.token,T(E).accessTokenCookieOptions($,B.expiresAt)),await J.onSignIn(B,$.search.toJSON()),await _$(Z.config,{session:B,isNewUser:D,method:"email-code",req:$}),{session:B,isNewUser:D}}}var Wz="gemi_oauth_connection";class j8 extends kZ{async connect($=new S){let Z=String($.params.provider??""),J=T(U3).providers[Z],W=await X1.user(),Y=U1($.search.get(D1),"");if(!J)return this.finish(Y,Z,"unknown_provider");let z=q$($.rawRequest),{state:X,codeChallenge:G,cookieValue:F}=e6(Yz(Z),Date.now(),{subject:String(W.id),...Y?{returnTo:Y}:{}});return $.ctx().setCookie(UZ(z,Wz),F,{httpOnly:!0,sameSite:"Lax",secure:z,maxAge:D3}),O1.external(J.authorizationUrl({state:X,codeChallenge:G,redirectUri:zz($,Z,J.config.redirectUri)})),{destination:"/"}}async callback($=new S){let Z=String($.params.provider??""),j=T(U3),J=await X1.user(),W=q$($.rawRequest),Y=UZ(W,Wz),z=$.cookies.get(Y);if(z!==void 0&&z!==null)$.ctx().setCookie(Y,"",{httpOnly:!0,sameSite:"Lax",secure:W,maxAge:-1});let X=$8({provider:Yz(Z),cookieValue:z,returnedState:$.search.get("state")}),G="payload"in X?X.payload.returnTo??"":"",F=j.providers[Z];if(!F)return this.finish(G,Z,"unknown_provider");let Q=$.search.get("error");if(Q)return this.finish(G,Z,/^[a-z0-9_]{1,64}$/.test(Q)?Q:"provider_error");if("reason"in X)return console.error(`OAuth connection refused (${X.reason})`),this.finish(G,Z,X.reason);if(X.payload.subject!==String(J.id))return this.finish(G,Z,"user_mismatch");let O=$.search.get("code");if(!O)return this.finish(G,Z,"missing_code");try{let K=await F.exchangeCode({code:O,codeVerifier:X.payload.codeVerifier,redirectUri:zz($,Z,F.config.redirectUri)}),D=await j.save(J,Z,K);await T(E).config.onConnected({user:J,provider:Z,connection:D,req:$})}catch(K){if(K instanceof Xz)return console.error(`OAuth connection to ${Z} failed: ${K.message}`),this.finish(G,Z,K.providerError??K.code);throw K}return this.finish(G,Z)}finish($,Z,j){let J=$||U1(T(E).config.redirectPath,"/"),W=new URL(J,"http://gemi.invalid");if(W.searchParams.set("connection",Z),j)W.searchParams.set("connection_error",j);throw O1.external(`${W.pathname}${W.search}${W.hash}`),Error("unreachable: Redirect.external throws")}}function Yz($){return`connection:${$}`}function zz($,Z,j){if(j)return j;return`${(process.env.HOST_NAME||new URL($.rawRequest.url).origin).replace(/\/$/,"")}/auth/connections/${encodeURIComponent(Z)}/callback`}class Gz extends B1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[s,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[s,"oauthCallback"])}}class Fz extends B1{middlewares=["cache:private"];routes={"/:provider":this.redirect([j8,"connect"]).middleware(["auth"]),"/:provider/callback":this.redirect([j8,"callback"]).middleware([A3,"auth"])}}class y4 extends B1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[s,"signInWithMagicLink"]),"/oauth":Gz,"/connections":Fz}}class q4 extends f0{middlewares=["cache:private"];routes={"/sign-in":this.post(s,"signIn"),"/sign-in-v2":this.post(s,"signInV2"),"/sign-up":this.post(s,"signUp"),"/sign-out":this.post(s,"signOut"),"/forgot-password":this.post(s,"forgotPassword"),"/reset-password":this.post(s,"resetPassword"),"/change-password":this.post(s,"changePassword"),"/verify-email":this.post(s,"verifyEmail"),"/me":this.get(s,"me").middleware(["auth"]),"/magic-link":this.post(s,"createMagicLinkToken"),"/sign-in-with-pin":this.post(s,"signInWithPin"),"/sign-in-with-pin-v2":this.post(s,"signInWithPinV2"),"/email-code":this.post(s,"requestEmailCode"),"/email-code/verify":this.post(s,"verifyEmailCode")}}class g4 extends f0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let Z=new S().params.locale;return await T(a).onLocaleChange(Z),{locale:Z}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new S,Z=`/${$.params.scope??""}`,j=$.params.locale,J=T(a),W=j??J.detectLocale($),Y=J.getPageTranslations(W,Z);return $.ctx().setCookie("i18n-locale",W,{expires:new Date(Date.now()+31536000000)}),{[W]:Y}})}}class m4{}class p4 extends m4{async resize($,Z){let{height:j,width:J,quality:W,fit:Y}=Z;return await(await J8("The Sharp image optimization driver"))($).resize(J>0?J:void 0,j>0?j:void 0,{fit:Y}).webp({quality:W>0?W:80,force:!0}).toBuffer()}}function AT($){return $}function Qz(){return{driver:new p4}}class h4 extends f0{routes={"/resize":this.file(async()=>{let $=new S,Z=new URL($.rawRequest.url),j=Z.searchParams.get("url"),J=Number(Z.searchParams.get("w")),W=Number(Z.searchParams.get("h")),Y=Z.searchParams.get("fit")??"cover",z=Number(Z.searchParams.get("q"));if(!j)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let G=`${j.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${j}`,F=await fetch(G);if(!F.ok)return new Response(JSON.stringify({error:"Image not found",info:G}),{headers:{"Content-Type":"application/json"},status:404});let Q=Buffer.from(await F.arrayBuffer()),O=await T(Kz).resize(Q,{height:W,width:J,fit:Y,quality:z});F.headers.delete("Content-Type"),F.headers.delete("Content-Length");let K=new Headers(F.headers);return K.set("Content-Type","image/webp"),K.set("Content-Length",`${O.byteLength}`),new Response(new Uint8Array(O),{headers:K})})}}class Kz{static token="image";driver;constructor($={}){this.driver=$.driver??Qz().driver}resize($,Z){return this.driver.resize($,Z)}}class c4 extends f0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(T(Oz).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function OO($){let Z=new Map;for(let j of $)if(typeof j==="string"){let[J,W=""]=j.split(":");if(J.startsWith("-")){if(Z.has(J.replace("-","")))Z.delete(J.replace("-",""))}else Z.set(J,W.split(",").filter(Boolean))}else Z.set(j,[]);return Z}var BO={"body-limit":f3};class VZ{config;static token="middleware";defaultBodyLimit;constructor($){this.config=$;this.defaultBodyLimit=$.bodyLimit===null||$.bodyLimit===void 0?null:RZ($.bodyLimit)}get aliases(){return{...BO,...this.config.aliases}}applyDefaultBodyLimit($){if(this.defaultBodyLimit!==null&&!qJ($))_3($,this.defaultBodyLimit,{checkDeclared:!1})}assertGlobalMiddleware(){for(let $ of this.config.global){if(typeof $!=="string")continue;let[Z]=$.split(":");if(Z.startsWith("-"))throw Error(`Global middleware "${$}" cancels an alias, but nothing is inherited into the global list. Remove it.`);if(!this.aliases[Z])throw Error(`Global middleware "${Z}" is not a registered alias. Add it to \`aliases\` in the middleware config, or list the class itself.`)}}runGlobalMiddleware(){return this.runMiddleware(this.config.global)}runMiddleware($){let Z=new S,j=this.aliases,J=[];for(let[W,Y]of OO($).entries())if(typeof W==="string"){let z=j[W];if(z){let X=new z(Z);J.push({run:()=>X.run.call(X,...Y),runsOnRefusal:Bz(z)})}}else if(H3(W)){let z=new W(Z);J.push({run:z.run.bind(z),runsOnRefusal:Bz(W)})}else J.push({run:W,runsOnRefusal:!1});return(async()=>{let W={};for(let Y=0;Y<J.length;Y++)try{W={...W,...await J[Y].run()}}catch(z){throw await DO(J.slice(Y+1)),z}return W})()}}function Bz($){return $?.runsOnRefusal===!0}async function DO($){for(let Z of $){if(!Z.runsOnRefusal)continue;try{await Z.run()}catch(j){console.error(j)}}}function uT($){return $}function Dz(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function Uz(){return{partialRendering:!0,localeRouting:"prefix",onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function UO($){return"run"in $}function VO($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"patch")||Object.hasOwn($,"delete")}function TO($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function IO($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function MO($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function Vz($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function d4($,Z="",j=[]){let J={};function W(Y,z,X,G,F){let Q=Y==="/"?"":Y,O=Z==="/"?"":Z,K=(`${O}${Q}`===""?"/":`${O}${Q}`).replaceAll("//","/");if(!J[K])J[K]={};J[K][z.toUpperCase()]={exec:X,middleware:[...j,...G],...F?{source:F}:{}},J[K].OPTIONS={exec:()=>{let B=new S().ctx().headers;return new Response(null,{headers:B,status:204})},middleware:[]}}for(let[Y,z]of Object.entries($)){if(MO(z)){let X=z;for(let G of["GET","POST","PUT","DELETE"])W(Y,G,X.run.bind(X),X.middlewares);continue}if(UO(z)){let X=z,G=X.method,F=X.middlewares,Q=X.run.bind(X);if(W(Y,G,Q,F,X.source),Vz(z))W(Y,"HEAD",Q,F,X.source)}if(VO(z))for(let[X,G]of Object.entries(z)){let F=G,Q=F.middlewares,O=F.run.bind(F);if(W(Y,X,O,Q,F.source),X==="get"&&Vz(F))W(Y,"HEAD",O,Q,F.source)}if(IO(z)){let X=new z,G=d4(X.routes,`${Z}${Y}`,X.middlewares);for(let[F,Q]of Object.entries(G))J[F.replaceAll("//","/")]=Q}if(TO(z)){let{first:X,second:G}=z;for(let[F,Q]of Object.entries(X)){let O=Q.middlewares,K=Q.run.bind(Q),[D,...B]=Y.split("/").reverse();if(!D.startsWith(":"))throw Error("Resource route must end with a dynamic segment");W(B.reverse().join("/"),F,K,O,Q.source)}for(let[F,Q]of Object.entries(G)){let O=Q.middlewares,K=Q.run.bind(Q);W(Y,F,K,O,Q.source)}}}return Object.fromEntries(Object.entries(J).sort(([Y],[z])=>{let X=Y.split("/").length+Y.split(":").length,G=z.split("/").length+z.split(":").length;return X-G}))}function W8($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function u4($,Z){if($==="/")return Z;if(Z==="/")return $;return`${$}${Z}`}function l4($){let Z=W8($);return Z.length>1?Z.replace(/\/$/,""):Z}function Tz($,Z){return Z.map((j)=>({...j,path:l4(u4($,j.path))}))}function Y8($){let Z={};for(let[j,J]of Object.entries($))if("run"in J){let W=J;if("children"in W){let Y=new W.children,z=Y8(Y.routes);for(let[X,{exec:G,middleware:F,segments:Q,features:O,static:K}]of Object.entries(z)){let D=u4(j,X),B=(U)=>W.run.call(W,U,j);Z[W8(D)]={exec:[B,...G],middleware:[...W.middlewares,...F],features:[...W.featureGates,...O],viewPath:W.viewPath,segments:[{path:l4(j),viewPath:W.viewPath,...W.alwaysRuns?{alwaysRun:!0}:{}},...Tz(j,Q)],...K?{static:K}:{}}}}else{let Y=(z)=>W.run.call(W,z,j);Z[W8(j)]={exec:[Y],middleware:W.middlewares,features:W.featureGates,viewPath:W.viewPath,segments:[{path:l4(j),viewPath:W.viewPath}],..."staticOptions"in W&&W.staticOptions?{static:W.staticOptions}:{}}}}else{let W=new J,Y=Y8(W.routes);for(let[z,{exec:X,middleware:G,viewPath:F,segments:Q,features:O,static:K}]of Object.entries(Y)){let D=u4(j,z);Z[W8(D)]={exec:X,middleware:[...W.middlewares,...G],features:[...W.featureGates,...O],viewPath:F,segments:Tz(j,Q),...K?{static:K}:{}}}}return Object.fromEntries(Object.entries(Z).sort(([j],[J])=>{let W=j.split("/").length+j.split(":").length,Y=J.split("/").length+J.split(":").length;return W-Y}))}var PO=Object.defineProperty,C=($,Z)=>PO($,"name",{value:Z,configurable:!0}),MZ=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,Z,j,J,W,Y){this.type=$,this.name=Z,this.prefix=j,this.value=J,this.suffix=W,this.modifier=Y}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};C(MZ,"Part");var NO=/[$_\p{ID_Start}]/u,LO=/[$_\u200C\u200D\p{ID_Continue}]/u,s4=".*";function Iz($,Z){return(Z?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}C(Iz,"isASCII");function a4($,Z=!1){let j=[],J=0;for(;J<$.length;){let W=$[J],Y=C(function(z){if(!Z)throw TypeError(z);j.push({type:"INVALID_CHAR",index:J,value:$[J++]})},"ErrorOrInvalid");if(W==="*"){j.push({type:"ASTERISK",index:J,value:$[J++]});continue}if(W==="+"||W==="?"){j.push({type:"OTHER_MODIFIER",index:J,value:$[J++]});continue}if(W==="\\"){j.push({type:"ESCAPED_CHAR",index:J++,value:$[J++]});continue}if(W==="{"){j.push({type:"OPEN",index:J,value:$[J++]});continue}if(W==="}"){j.push({type:"CLOSE",index:J,value:$[J++]});continue}if(W===":"){let z="",X=J+1;for(;X<$.length;){let G=$.substr(X,1);if(X===J+1&&NO.test(G)||X!==J+1&&LO.test(G)){z+=$[X++];continue}break}if(!z){Y(`Missing parameter name at ${J}`);continue}j.push({type:"NAME",index:J,value:z}),J=X;continue}if(W==="("){let z=1,X="",G=J+1,F=!1;if($[G]==="?"){Y(`Pattern cannot start with "?" at ${G}`);continue}for(;G<$.length;){if(!Iz($[G],!1)){Y(`Invalid character '${$[G]}' at ${G}.`),F=!0;break}if($[G]==="\\"){X+=$[G++]+$[G++];continue}if($[G]===")"){if(z--,z===0){G++;break}}else if($[G]==="("&&(z++,$[G+1]!=="?")){Y(`Capturing groups are not allowed at ${G}`),F=!0;break}X+=$[G++]}if(F)continue;if(z){Y(`Unbalanced pattern at ${J}`);continue}if(!X){Y(`Missing pattern at ${J}`);continue}j.push({type:"REGEX",index:J,value:X}),J=G;continue}j.push({type:"CHAR",index:J,value:$[J++]})}return j.push({type:"END",index:J,value:""}),j}C(a4,"lexer");function r4($,Z={}){let j=a4($);Z.delimiter??="/#?",Z.prefixes??="./";let J=`[^${y0(Z.delimiter)}]+?`,W=[],Y=0,z=0,X="",G=new Set,F=C((M)=>{if(z<j.length&&j[z].type===M)return j[z++].value},"tryConsume"),Q=C(()=>F("OTHER_MODIFIER")??F("ASTERISK"),"tryConsumeModifier"),O=C((M)=>{let x=F(M);if(x!==void 0)return x;let{type:f,index:A}=j[z];throw TypeError(`Unexpected ${f} at ${A}, expected ${M}`)},"mustConsume"),K=C(()=>{let M="",x;for(;x=F("CHAR")??F("ESCAPED_CHAR");)M+=x;return M},"consumeText"),D=C((M)=>M,"DefaultEncodePart"),B=Z.encodePart||D,U="",V=C((M)=>{U+=M},"appendToPendingFixedValue"),I=C(()=>{U.length&&(W.push(new MZ(3,"","",B(U),"",3)),U="")},"maybeAddPartFromPendingFixedValue"),P=C((M,x,f,A,_)=>{let L=3;switch(_){case"?":L=1;break;case"*":L=0;break;case"+":L=2;break}if(!x&&!f&&L===3){V(M);return}if(I(),!x&&!f){if(!M)return;W.push(new MZ(3,"","",B(M),"",L));return}let N;f?f==="*"?N=s4:N=f:N=J;let l=2;N===J?(l=1,N=""):N===s4&&(l=0,N="");let d;if(x?d=x:f&&(d=Y++),G.has(d))throw TypeError(`Duplicate name '${d}'.`);G.add(d),W.push(new MZ(l,d,B(M),N,B(A),L))},"addPart");for(;z<j.length;){let M=F("CHAR"),x=F("NAME"),f=F("REGEX");if(!x&&!f&&(f=F("ASTERISK")),x||f){let _=M??"";Z.prefixes.indexOf(_)===-1&&(V(_),_=""),I();let L=Q();P(_,x,f,"",L);continue}let A=M??F("ESCAPED_CHAR");if(A){V(A);continue}if(F("OPEN")){let _=K(),L=F("NAME"),N=F("REGEX");!L&&!N&&(N=F("ASTERISK"));let l=K();O("CLOSE");let d=Q();P(_,L,N,l,d);continue}I(),O("END")}return W}C(r4,"parse");function y0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}C(y0,"escapeString");function n4($){return $&&$.ignoreCase?"ui":"u"}C(n4,"flags");function Mz($,Z,j){return t4(r4($,j),Z,j)}C(Mz,"stringToRegexp");function S$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}C(S$,"modifierToString");function t4($,Z,j={}){j.delimiter??="/#?",j.prefixes??="./",j.sensitive??=!1,j.strict??=!1,j.end??=!0,j.start??=!0,j.endsWith="";let J=j.start?"^":"";for(let X of $){if(X.type===3){X.modifier===3?J+=y0(X.value):J+=`(?:${y0(X.value)})${S$(X.modifier)}`;continue}Z&&Z.push(X.name);let G=`[^${y0(j.delimiter)}]+?`,F=X.value;if(X.type===1?F=G:X.type===0&&(F=s4),!X.prefix.length&&!X.suffix.length){X.modifier===3||X.modifier===1?J+=`(${F})${S$(X.modifier)}`:J+=`((?:${F})${S$(X.modifier)})`;continue}if(X.modifier===3||X.modifier===1){J+=`(?:${y0(X.prefix)}(${F})${y0(X.suffix)})`,J+=S$(X.modifier);continue}J+=`(?:${y0(X.prefix)}`,J+=`((?:${F})(?:`,J+=y0(X.suffix),J+=y0(X.prefix),J+=`(?:${F}))*)${y0(X.suffix)})`,X.modifier===0&&(J+="?")}let W=`[${y0(j.endsWith)}]|$`,Y=`[${y0(j.delimiter)}]`;if(j.end)return j.strict||(J+=`${Y}?`),j.endsWith.length?J+=`(?=${W})`:J+="$",new RegExp(J,n4(j));j.strict||(J+=`(?:${Y}(?=${W}))?`);let z=!1;if($.length){let X=$[$.length-1];X.type===3&&X.modifier===3&&(z=j.delimiter.indexOf(X)>-1)}return z||(J+=`(?=${Y}|${W})`),new RegExp(J,n4(j))}C(t4,"partsToRegexp");var e1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},HO={delimiter:".",prefixes:"",sensitive:!0,strict:!0},CO={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Pz($,Z){return $.length?$[0]==="/"?!0:!Z||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}C(Pz,"isAbsolutePathname");function e4($,Z){return $.startsWith(Z)?$.substring(Z.length,$.length):$}C(e4,"maybeStripPrefix");function Nz($,Z){return $.endsWith(Z)?$.substr(0,$.length-Z.length):$}C(Nz,"maybeStripSuffix");function $J($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}C($J,"treatAsIPv6Hostname");var Lz=["ftp","file","http","https","ws","wss"];function ZJ($){if(!$)return!0;for(let Z of Lz)if($.test(Z))return!0;return!1}C(ZJ,"isSpecialScheme");function Hz($,Z){if($=e4($,"#"),Z||$==="")return $;let j=new URL("https://example.com");return j.hash=$,j.hash?j.hash.substring(1,j.hash.length):""}C(Hz,"canonicalizeHash");function Cz($,Z){if($=e4($,"?"),Z||$==="")return $;let j=new URL("https://example.com");return j.search=$,j.search?j.search.substring(1,j.search.length):""}C(Cz,"canonicalizeSearch");function _z($,Z){return Z||$===""?$:$J($)?WJ($):JJ($)}C(_z,"canonicalizeHostname");function Sz($,Z){if(Z||$==="")return $;let j=new URL("https://example.com");return j.password=$,j.password}C(Sz,"canonicalizePassword");function xz($,Z){if(Z||$==="")return $;let j=new URL("https://example.com");return j.username=$,j.username}C(xz,"canonicalizeUsername");function Az($,Z,j){if(j||$==="")return $;if(Z&&!Lz.includes(Z))return new URL(`${Z}:${$}`).pathname;let J=$[0]=="/";return $=new URL(J?$:"/-"+$,"https://example.com").pathname,J||($=$.substring(2,$.length)),$}C(Az,"canonicalizePathname");function fz($,Z,j){return jJ(Z)===$&&($=""),j||$===""?$:YJ($)}C(fz,"canonicalizePort");function Ez($,Z){return $=Nz($,":"),Z||$===""?$:z8($)}C(Ez,"canonicalizeProtocol");function jJ($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}C(jJ,"defaultPortForProtocol");function z8($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}C(z8,"protocolEncodeCallback");function Rz($){if($==="")return $;let Z=new URL("https://example.com");return Z.username=$,Z.username}C(Rz,"usernameEncodeCallback");function bz($){if($==="")return $;let Z=new URL("https://example.com");return Z.password=$,Z.password}C(bz,"passwordEncodeCallback");function JJ($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let Z=new URL("https://example.com");return Z.hostname=$,Z.hostname}C(JJ,"hostnameEncodeCallback");function WJ($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}C(WJ,"ipv6HostnameEncodeCallback");function YJ($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}C(YJ,"portEncodeCallback");function vz($){if($==="")return $;let Z=new URL("https://example.com");return Z.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?Z.pathname.substring(2,Z.pathname.length):Z.pathname}C(vz,"standardURLPathnameEncodeCallback");function wz($){return $===""?$:new URL(`data:${$}`).pathname}C(wz,"pathURLPathnameEncodeCallback");function kz($){if($==="")return $;let Z=new URL("https://example.com");return Z.search=$,Z.search.substring(1,Z.search.length)}C(kz,"searchEncodeCallback");function yz($){if($==="")return $;let Z=new URL("https://example.com");return Z.hash=$,Z.hash.substring(1,Z.hash.length)}C(yz,"hashEncodeCallback");var qz=class{#Y;#J=[];#Z={};#$=0;#W=1;#F=0;#X=0;#B=0;#D=0;#U=!1;constructor($){this.#Y=$}get result(){return this.#Z}parse(){for(this.#J=a4(this.#Y,!0);this.#$<this.#J.length;this.#$+=this.#W){if(this.#W=1,this.#J[this.#$].type==="END"){if(this.#X===0){this.#M(),this.#Q()?this.#j(9,1):this.#K()?this.#j(8,1):this.#j(7,0);continue}else if(this.#X===2){this.#O(5);continue}this.#j(10,0);break}if(this.#B>0)if(this.#S())this.#B-=1;else continue;if(this.#_()){this.#B+=1;continue}switch(this.#X){case 0:this.#P()&&this.#O(1);break;case 1:if(this.#P()){this.#f();let $=7,Z=1;this.#L()?($=2,Z=3):this.#U&&($=2),this.#j($,Z)}break;case 2:this.#T()?this.#O(3):(this.#I()||this.#K()||this.#Q())&&this.#O(5);break;case 3:this.#H()?this.#j(4,1):this.#T()&&this.#j(5,1);break;case 4:this.#T()&&this.#j(5,1);break;case 5:this.#x()?this.#D+=1:this.#A()&&(this.#D-=1),this.#C()&&!this.#D?this.#j(6,1):this.#I()?this.#j(7,0):this.#K()?this.#j(8,1):this.#Q()&&this.#j(9,1);break;case 6:this.#I()?this.#j(7,0):this.#K()?this.#j(8,1):this.#Q()&&this.#j(9,1);break;case 7:this.#K()?this.#j(8,1):this.#Q()&&this.#j(9,1);break;case 8:this.#Q()&&this.#j(9,1);break;case 9:break;case 10:break}}this.#Z.hostname!==void 0&&this.#Z.port===void 0&&(this.#Z.port="")}#j($,Z){switch(this.#X){case 0:break;case 1:this.#Z.protocol=this.#G();break;case 2:break;case 3:this.#Z.username=this.#G();break;case 4:this.#Z.password=this.#G();break;case 5:this.#Z.hostname=this.#G();break;case 6:this.#Z.port=this.#G();break;case 7:this.#Z.pathname=this.#G();break;case 8:this.#Z.search=this.#G();break;case 9:this.#Z.hash=this.#G();break;case 10:break}this.#X!==0&&$!==10&&([1,2,3,4].includes(this.#X)&&[6,7,8,9].includes($)&&(this.#Z.hostname??=""),[1,2,3,4,5,6].includes(this.#X)&&[8,9].includes($)&&(this.#Z.pathname??=this.#U?"/":""),[1,2,3,4,5,6,7].includes(this.#X)&&$===9&&(this.#Z.search??="")),this.#N($,Z)}#N($,Z){this.#X=$,this.#F=this.#$+Z,this.#$+=Z,this.#W=0}#M(){this.#$=this.#F,this.#W=0}#O($){this.#M(),this.#X=$}#V($){return $<0&&($=this.#J.length-$),$<this.#J.length?this.#J[$]:this.#J[this.#J.length-1]}#z($,Z){let j=this.#V($);return j.value===Z&&(j.type==="CHAR"||j.type==="ESCAPED_CHAR"||j.type==="INVALID_CHAR")}#P(){return this.#z(this.#$,":")}#L(){return this.#z(this.#$+1,"/")&&this.#z(this.#$+2,"/")}#T(){return this.#z(this.#$,"@")}#H(){return this.#z(this.#$,":")}#C(){return this.#z(this.#$,":")}#I(){return this.#z(this.#$,"/")}#K(){if(this.#z(this.#$,"?"))return!0;if(this.#J[this.#$].value!=="?")return!1;let $=this.#V(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#Q(){return this.#z(this.#$,"#")}#_(){return this.#J[this.#$].type=="OPEN"}#S(){return this.#J[this.#$].type=="CLOSE"}#x(){return this.#z(this.#$,"[")}#A(){return this.#z(this.#$,"]")}#G(){let $=this.#J[this.#$],Z=this.#V(this.#F).index;return this.#Y.substring(Z,$.index)}#f(){let $={};Object.assign($,e1),$.encodePart=z8;let Z=Mz(this.#G(),void 0,$);this.#U=ZJ(Z)}};C(qz,"Parser");var i4=["protocol","username","password","hostname","port","pathname","search","hash"],t1="*";function o4($,Z){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let j=new URL($,Z);return{protocol:j.protocol.substring(0,j.protocol.length-1),username:j.username,password:j.password,hostname:j.hostname,port:j.port,pathname:j.pathname,search:j.search!==""?j.search.substring(1,j.search.length):void 0,hash:j.hash!==""?j.hash.substring(1,j.hash.length):void 0}}C(o4,"extractValues");function G1($,Z){return Z?IZ($):$}C(G1,"processBaseURLString");function TZ($,Z,j){let J;if(typeof Z.baseURL=="string")try{J=new URL(Z.baseURL),Z.protocol===void 0&&($.protocol=G1(J.protocol.substring(0,J.protocol.length-1),j)),!j&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&($.username=G1(J.username,j)),!j&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&Z.password===void 0&&($.password=G1(J.password,j)),Z.protocol===void 0&&Z.hostname===void 0&&($.hostname=G1(J.hostname,j)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&($.port=G1(J.port,j)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&($.pathname=G1(J.pathname,j)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&($.search=G1(J.search.substring(1,J.search.length),j)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&Z.hash===void 0&&($.hash=G1(J.hash.substring(1,J.hash.length),j))}catch{throw TypeError(`invalid baseURL '${Z.baseURL}'.`)}if(typeof Z.protocol=="string"&&($.protocol=Ez(Z.protocol,j)),typeof Z.username=="string"&&($.username=xz(Z.username,j)),typeof Z.password=="string"&&($.password=Sz(Z.password,j)),typeof Z.hostname=="string"&&($.hostname=_z(Z.hostname,j)),typeof Z.port=="string"&&($.port=fz(Z.port,$.protocol,j)),typeof Z.pathname=="string"){if($.pathname=Z.pathname,J&&!Pz($.pathname,j)){let W=J.pathname.lastIndexOf("/");W>=0&&($.pathname=G1(J.pathname.substring(0,W+1),j)+$.pathname)}$.pathname=Az($.pathname,$.protocol,j)}return typeof Z.search=="string"&&($.search=Cz(Z.search,j)),typeof Z.hash=="string"&&($.hash=Hz(Z.hash,j)),$}C(TZ,"applyInit");function IZ($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}C(IZ,"escapePatternString");function gz($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}C(gz,"escapeRegexpString");function mz($,Z){Z.delimiter??="/#?",Z.prefixes??="./",Z.sensitive??=!1,Z.strict??=!1,Z.end??=!0,Z.start??=!0,Z.endsWith="";let j=".*",J=`[^${gz(Z.delimiter)}]+?`,W=/[$_\u200C\u200D\p{ID_Continue}]/u,Y="";for(let z=0;z<$.length;++z){let X=$[z];if(X.type===3){if(X.modifier===3){Y+=IZ(X.value);continue}Y+=`{${IZ(X.value)}}${S$(X.modifier)}`;continue}let G=X.hasCustomName(),F=!!X.suffix.length||!!X.prefix.length&&(X.prefix.length!==1||!Z.prefixes.includes(X.prefix)),Q=z>0?$[z-1]:null,O=z<$.length-1?$[z+1]:null;if(!F&&G&&X.type===1&&X.modifier===3&&O&&!O.prefix.length&&!O.suffix.length)if(O.type===3){let K=O.value.length>0?O.value[0]:"";F=W.test(K)}else F=!O.hasCustomName();if(!F&&!X.prefix.length&&Q&&Q.type===3){let K=Q.value[Q.value.length-1];F=Z.prefixes.includes(K)}F&&(Y+="{"),Y+=IZ(X.prefix),G&&(Y+=`:${X.name}`),X.type===2?Y+=`(${X.value})`:X.type===1?G||(Y+=`(${J})`):X.type===0&&(!G&&(!Q||Q.type===3||Q.modifier!==3||F||X.prefix!=="")?Y+="*":Y+=`(${j})`),X.type===1&&G&&X.suffix.length&&W.test(X.suffix[0])&&(Y+="\\"),Y+=IZ(X.suffix),F&&(Y+="}"),X.modifier!==3&&(Y+=S$(X.modifier))}return Y}C(mz,"partsToPattern");var zJ=class{#Y;#J={};#Z={};#$={};#W={};#F=!1;constructor($={},Z,j){try{let J;if(typeof Z=="string"?J=Z:j=Z,typeof $=="string"){let X=new qz($);if(X.parse(),$=X.result,J===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=J}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(J)throw TypeError("parameter 1 is not of type 'string'.")}typeof j>"u"&&(j={ignoreCase:!1});let W={ignoreCase:j.ignoreCase===!0},Y={pathname:t1,protocol:t1,username:t1,password:t1,hostname:t1,port:t1,search:t1,hash:t1};this.#Y=TZ(Y,$,!0),jJ(this.#Y.protocol)===this.#Y.port&&(this.#Y.port="");let z;for(z of i4){if(!(z in this.#Y))continue;let X={},G=this.#Y[z];switch(this.#Z[z]=[],z){case"protocol":Object.assign(X,e1),X.encodePart=z8;break;case"username":Object.assign(X,e1),X.encodePart=Rz;break;case"password":Object.assign(X,e1),X.encodePart=bz;break;case"hostname":Object.assign(X,HO),$J(G)?X.encodePart=WJ:X.encodePart=JJ;break;case"port":Object.assign(X,e1),X.encodePart=YJ;break;case"pathname":ZJ(this.#J.protocol)?(Object.assign(X,CO,W),X.encodePart=vz):(Object.assign(X,e1,W),X.encodePart=wz);break;case"search":Object.assign(X,e1,W),X.encodePart=kz;break;case"hash":Object.assign(X,e1,W),X.encodePart=yz;break}try{this.#W[z]=r4(G,X),this.#J[z]=t4(this.#W[z],this.#Z[z],X),this.#$[z]=mz(this.#W[z],X),this.#F=this.#F||this.#W[z].some((F)=>F.type===2)}catch{throw TypeError(`invalid ${z} pattern '${this.#Y[z]}'.`)}}}catch(J){throw TypeError(`Failed to construct 'URLPattern': ${J.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},Z){let j={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?j=TZ(j,$,!1):j=TZ(j,o4($,Z),!1)}catch{return!1}let J;for(J of i4)if(!this.#J[J].exec(j[J]))return!1;return!0}exec($={},Z){let j={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?j=TZ(j,$,!1):j=TZ(j,o4($,Z),!1)}catch{return null}let J={};Z?J.inputs=[$,Z]:J.inputs=[$];let W;for(W of i4){let Y=this.#J[W].exec(j[W]);if(!Y)return null;let z={};for(let[X,G]of this.#Z[W].entries())if(typeof G=="string"||typeof G=="number"){let F=Y[X+1];z[G]=F}J[W]={input:j[W]??"",groups:z}}return J}static compareComponent($,Z,j){let J=C((X,G)=>{for(let F of["type","modifier","prefix","value","suffix"]){if(X[F]<G[F])return-1;if(X[F]===G[F])continue;return 1}return 0},"comparePart"),W=new MZ(3,"","","","",3),Y=new MZ(0,"","","","",3),z=C((X,G)=>{let F=0;for(;F<Math.min(X.length,G.length);++F){let Q=J(X[F],G[F]);if(Q)return Q}return X.length===G.length?0:J(X[F]??W,G[F]??W)},"comparePartList");return!Z.#$[$]&&!j.#$[$]?0:Z.#$[$]&&!j.#$[$]?z(Z.#W[$],[Y]):!Z.#$[$]&&j.#$[$]?z([Y],j.#W[$]):z(Z.#W[$],j.#W[$])}get protocol(){return this.#$.protocol}get username(){return this.#$.username}get password(){return this.#$.password}get hostname(){return this.#$.hostname}get port(){return this.#$.port}get pathname(){return this.#$.pathname}get search(){return this.#$.search}get hash(){return this.#$.hash}get hasRegExpGroups(){return this.#F}};C(zJ,"URLPattern");function V3($,Z){for(let[j,J]of Object.entries($)){let W=new zJ({pathname:j});if(W.test({pathname:Z}))return{routePath:j,params:W.exec({pathname:Z})?.pathname.groups??{},route:J}}return null}var x$={startIndex:0,carriedViews:[]};function pz($,Z){let j=F0($.path,Z);return j.includes("*")?null:j}function _O($,Z){if(!$)return x$;if($.search!==Z.search)return x$;let j=Math.min($.segments.length,Z.segments.length-1),J=0;while(J<j){let W=$.segments[J],Y=Z.segments[J];if(Y.alwaysRun)break;if(W.viewPath!==Y.viewPath)break;let z=pz(W,$.params),X=pz(Y,Z.params);if(z===null||X===null||z!==X)break;J++}if(J===0)return x$;return{startIndex:J,carriedViews:Z.segments.slice(0,J).map(({viewPath:W})=>W)}}function SO($,Z){let[,j,...J]=$.split("/");if(!Z.includes(j))return $;let W=`/${J.join("/")}`;return W==="/"?"/":W.replace(/\/$/,"")}function hz($){let{flatViewRoutes:Z,supportedLocales:j,from:J,origin:W,to:Y}=$;if(!J)return x$;let z;try{z=new URL(J,W)}catch{return x$}if(z.origin!==W)return x$;let X=V3(Z,SO(z.pathname,j));if(!X)return x$;return _O({segments:X.route.segments,params:X.params,search:z.search},Y)}var XJ="x-gemi-from";import{createElement as A1,Fragment as DX}from"react";function xO($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function X8($){let Z={};for(let[j,J]of Object.entries($))if("run"in J){let W=J.viewPath;if("children"in J){Z[j]=[W];let Y=new J.children,z=X8(Y.routes);for(let[X,G]of Object.entries(z)){let F=j==="/"?X:`${j}${X}`,Q=X==="/"&&j!=="/"?j:F;Z[Q]=[W,...G]}if(Z[j].length===1)delete Z[j]}else Z[j]=[W]}else{let W=new J,Y=X8(W.routes);for(let[z,X]of Object.entries(Y)){let G=j==="/"?z:`${j}${z}`,F=z==="/"&&j!=="/"?j:G;Z[F]=X}}return Object.fromEntries(Object.entries(Z).map(([j,J])=>[xO(j),J]))}function G8($,Z){let[j,J]=Z,W=$.find(([Y])=>Y===j);if(!W){$.push([j,[...J]]);return}for(let Y of J)G8(W[1],Y)}function F8($){let Z=[];for(let[j,J]of Object.entries($))if("run"in J){let W=J.viewPath;if(W==="__")continue;if(W==="REDIRECT")continue;if(W==="FILE")continue;if("children"in J){let Y=new J.children,z=F8(Y.routes);G8(Z,[W,z])}else G8(Z,[W,[]])}else{let W=new J,Y=F8(W.routes);for(let z of Y)G8(Z,z)}return Z}function GJ($){let Z=[];for(let[j,J]of $)Z.push(j,...GJ(J).flat());return Array.from(new Set(Z))}class $$ extends c{static getFacadeAccessor(){return a}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),Z=H.getStore();if(Z)return Z.locale??$.detectLocale(Z.req);return $.defaultLocale}static timeZone(){return this.getFacadeRoot().detectTimeZone(H.getStore()?.req)}static formatter($={}){return this.getFacadeRoot().formatter($.locale??$$.locale(),$.timeZone??$$.timeZone())}static setLocale($=$$.locale(),Z={}){let j=this.getFacadeRoot(),J=$;if(!j.supportedLocales.includes($))J=j.defaultLocale;let W=H.getStore();if(Z.cookie!==!1)W.setCookie("i18n-locale",J,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1});return W.setLocale(J),J}}class FJ{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var AO=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),fO=new Set(["svg","math"]);function cz($){return $===32||$===9||$===10||$===12||$===13}function dz($){return $>=65&&$<=90||$>=97&&$<=122}function Q8($){return $>=65&&$<=90?$+32:$}function uz(){let $="data",Z="",j=!1,J="",W=0,Y=0,z=!1,X=0,G=0,F=()=>$==="data"&&X===0&&G===0,Q=()=>{if(!j&&AO.has(Z)){$="rawText",J=`</${Z}`,W=0,Z="";return}if($="data",Z==="template")if(j)X=Math.max(0,X-1);else X+=1;else if(fO.has(Z)){if(j)G=Math.max(0,G-1);else if(!z)G+=1}Z=""},O=(K)=>{switch($){case"data":if(K===60)$="tagOpen";return;case"tagOpen":if(K===33)$="bang",Y=0;else if(K===47)$="endTagOpen";else if(dz(K))$="tagName",j=!1,z=!1,Z=String.fromCharCode(Q8(K));else if(K===63)$="bogus";else if(K===60)$="tagOpen";else $="data";return;case"endTagOpen":if(dz(K))$="tagName",j=!0,z=!1,Z=String.fromCharCode(Q8(K));else if(K===62)$="data";else $="bogus";return;case"tagName":if(cz(K)||K===47)$="inTag",z=K===47;else if(K===62)Q();else Z+=String.fromCharCode(Q8(K));return;case"inTag":if(K===62){Q();return}if(z=K===47,K===34)$="attrDouble";else if(K===39)$="attrSingle";return;case"attrDouble":if(K===34)$="inTag";z=!1;return;case"attrSingle":if(K===39)$="inTag";z=!1;return;case"bang":if(K===45){if(Y+=1,Y===2)$="comment",Y=0}else if(K===62)$="data";else $="bogus";return;case"bogus":if(K===62)$="data";return;case"comment":if(K===45)Y=Y<2?Y+1:2;else if(K===62&&Y>=2)$="data",Y=0;else Y=0;return;case"rawText":{if(W<J.length){if(Q8(K)===J.charCodeAt(W))W+=1;else W=K===60?1:0;return}if(K===62)$="data",Z="";else if(cz(K)||K===47)$="inTag",Z="";else W=K===60?1:0;return}}};return{scanToInsertionPoint(K){for(let D=0;D<K.length;D++){if(F())return D;O(K[D])}return K.length},write(K){for(let D=0;D<K.length;D++)O(K[D])},isSafe:F}}function S1($){let Z=JSON.stringify($);if(Z===void 0)return"undefined";return Z.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function EO($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${S1([$.path,$.variantKey,$.data])})</script>`}function RO($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${S1([$.id,$.locale,$.strings])})</script>`}function QJ($,Z,j={},J){let W=new TextEncoder,Y=[],z=!1,X=!1,G=()=>{if(X)return;X=!0,j.onClose?.()};Z.onSettle((B)=>{if(B.status!=="resolved")return;Y.push(EO(B))}),J?.onUse((B)=>{Y.push(RO(B))});let F=$.getReader(),Q=uz(),O=(B,U)=>{B.enqueue(U),j.onChunk?.(U)},K=(B)=>{while(Y.length>0){let U=W.encode(Y.shift());Q.write(U),O(B,U)}},D=(B,U)=>{if(Y.length===0){Q.write(U),O(B,U);return}let V=Q.scanToInsertionPoint(U);if(V>0)O(B,U.subarray(0,V));if(Q.isSafe())K(B);let I=U.subarray(V);if(I.length>0)Q.write(I),O(B,I)};return new ReadableStream({async pull(B){let U;try{U=await F.read()}catch(P){throw G(),P}let{done:V,value:I}=U;if(V){K(B),B.close(),G();return}if(!z){if(z=!0,Q.write(I),O(B,I),j.onShell?.(),Q.isSafe())K(B);return}D(B,I)},cancel(B){return G(),F.cancel(B)}})}var bO=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function K8($){if(!$)return!1;return bO.test($)}async function iz($,Z=()=>{}){let j=H.getStore(),J=j?.req??null,W=null;if(J?.rawRequest?.url)try{W=new URL(J.rawRequest.url).pathname}catch{W=null}return{user:j?.user??null,attributes:await vO($,Z),request:{path:W,routePath:J?.routePath??null,locale:j?.locale??null},anonymousId:lz(),isBot:K8(J?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function sz($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function vO($,Z){if(!$.context)return{};try{let j=H.getStore();return await $.context(j?.req??null)??{}}catch(j){return Z(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${j instanceof Error?j.message:String(j)}`),{}}}function nz($,Z){return`${$}:${Z}`}function KJ($){let Z=new Bun.CryptoHasher("sha1").update($).digest("hex"),j=Number.parseInt(Z.slice(0,8),16);return Math.floor(j/4294967296*1e4)}function oz($,Z){if(Z>=100)return!0;if(Z<=0)return!1;return $<Math.round(Z*100)}function az($,Z,j,J){if(J.unavailable)return{value:!1,reason:"unavailable"};if(J.active!==!0)return{value:!1,reason:"inactive"};if(Z.when){let Y;try{Y=Z.when(j)}catch(z){return J.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${z instanceof Error?z.message:String(z)}`),{value:!1,reason:"error"}}if(typeof Y==="boolean")return{value:Y,reason:"attributed"}}if(Z.rollout===void 0)return{value:!0,reason:"on"};if(j.isBot)return{value:!1,reason:"bot"};let W=kO($,Z,j,J.buckets);return oz(W,Z.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function wO($){let Z=$.user?.publicId??$.user?.id;if(Z!==void 0&&Z!==null)return String(Z);return $.anonymousId??""}function kO($,Z,j,J){let W=nz(Z.salt??$,wO(j));if(!J)return KJ(W);let Y=J.get(W);if(Y!==void 0)return Y;let z=KJ(W);return J.set(W,z),z}class rz 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 OJ{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,Z,j,J=()=>{}){this.source=$;this.declared=Z;this.ttlMs=j;this.warn=J}async get(){let $=this.snapshot;if($&&Date.now()-$.loadedAt<this.ttlMs)return $;if($){if(Date.now()>=this.retryAfter)this.refresh().catch(()=>{});return $}return await this.refresh()}refresh(){return this.inflight??=this.load().finally(()=>{this.inflight=null}),this.inflight}async invalidate(){await this.inflight?.catch(()=>{});let $=this.generation,Z=await this.refresh();if(this.generation===$)throw new rz(this.lastError);return Z}peek(){return this.snapshot}async load(){try{let $=await this.source.load(),{active:Z,audit:j}=this.readRows($);return this.snapshot={active:Z,audit:j,loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readRows($){let Z=new Map,j=new Map;for(let J of $??[]){let W=typeof J?.key==="string"?J.key:null;if(!W){this.warn("Ignoring a feature row with no `key`.");continue}if(!(W in this.declared)){this.warn(`Feature row "${W}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}Z.set(W,J.active===!0);let Y=yO(J);if(Y)j.set(W,Y)}return{active:Z,audit:j}}handleFailure($){let Z=$ instanceof Error?$.message:String($),j=Date.now();if(this.lastError=$,this.retryAfter=j+this.ttlMs,j-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=j,this.warn(`Could not load feature switches: ${Z}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,audit:new Map,loadedAt:j,unavailable:!0},this.snapshot}}function yO($){let Z={},j=$.updatedBy;if(typeof j==="string")Z.updatedBy=j;else if(j===null)Z.updatedBy=null;let J=$.updatedAt;if(J instanceof Date||typeof J==="string"||typeof J==="number"){let W=J instanceof Date?J:new Date(J);if(!Number.isNaN(W.getTime()))Z.updatedAt=W}return"updatedBy"in Z||"updatedAt"in Z?Z:null}class qO{}class gO 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 BJ 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 tz 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 ez{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 PZ{config;log;static token="features";store;declared;warnedAboutSize=!1;warnedAboutActor=!1;constructor($,Z=()=>{}){this.config=$;this.log=Z;this.declared=$.features??{},this.store=new OJ($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,audit:Z,unavailable:j}=await this.switches();return{unavailable:j,features:Object.entries(this.declared).map(([J,W])=>({key:J,describe:W.describe,rollout:W.rollout,targeted:W.when!==void 0,serverOnly:W.serverOnly,salt:W.salt,active:$.get(J),...Z.get(J)}))}}async refresh(){if(!this.config.enabled)return;if(Object.keys(this.declared).length===0)return;await this.store.refresh()}async invalidate(){try{if(this.config.enabled&&Object.keys(this.declared).length>0)await this.store.invalidate()}finally{H.getStore()?.featureEvaluations?.clear()}}async set($,Z,j={}){if(typeof $!=="string"||!Object.hasOwn(this.declared,$))throw new tz(String($));if(typeof Z!=="boolean")throw TypeError(`Features.set("${$}", \u2026) takes a boolean, not ${Z===null?"null":typeof Z}.`);let J=mO(j.actor),W=this.config.source;if(typeof W.write!=="function")throw new BJ(W.constructor?.name||"an anonymous source");let{actorRecorded:Y}=await W.write($,Z,{actor:J});if(J!==null&&!Y&&!this.warnedAboutActor)this.warnedAboutActor=!0,this.log('Features.set() was given an actor, but the feature source has nowhere to record it. For the database source, add a nullable `updatedBy String?` column to the feature flag model to keep "last changed by".');await this.invalidate()}async enabled($){return(await this.explain($)).value}async explain($){let Z=await this.requestContext();return await this.evaluateIn($,Z,this.requestBuckets())}async all(){let $=await this.requestContext();return await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!1})}async forClient(){if(!this.config.enabled)return{};let $=await this.requestContext(),Z=await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!0});return this.warnIfOversized(Object.keys(Z).length),Z}for($){return new ez(this,sz($))}async evaluateIn($,Z,j){let J=this.memoFor(Z),W=J?.get($);if(W)return W;let Y=this.declared[$];if(!Y)return{value:!1,reason:"undeclared"};let{active:z,unavailable:X}=await this.switchFor($),G=az($,Y,Z,{active:z,unavailable:X,buckets:j,warn:this.log});return J?.set($,G),this.notify($,G,Z),G}async evaluateAllIn($,Z,j){let J={};for(let[W,Y]of Object.entries(this.declared)){if(j.clientOnly&&Y.serverOnly)continue;J[W]=(await this.evaluateIn(W,$,Z)).value}return J}async switches(){if(!this.config.enabled||Object.keys(this.declared).length===0)return{active:new Map,audit:new Map,unavailable:!1};let $=await this.store.get();return{active:$.active,audit:$.audit,unavailable:$.unavailable}}async switchFor($){if(!this.config.enabled)return{active:!1,unavailable:!1};let Z=await this.store.get();return{active:Z.active.get($),unavailable:Z.unavailable}}async requestContext(){let $=H.getStore();if($?.featureContext)return $.featureContext;let Z=await iz(this.config,this.log);if($)$.featureContext=Z;return Z}memoFor($){let Z=H.getStore();if(!Z||Z.featureContext!==$)return null;return Z.featureEvaluations??=new Map,Z.featureEvaluations}requestBuckets(){let $=H.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,Z,j){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,Z,j)}catch(J){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${J instanceof Error?J.message:String(J)}`)}}warnIfOversized($){if(this.warnedAboutSize||$<=this.config.maxClientFlags)return;this.warnedAboutSize=!0,this.log(`${$} client-visible features are embedded in every document. Mark the ones only the server reads with \`serverOnly: true\` to keep them out of the payload.`)}}function mO($){if($===void 0||$===null)return null;if(typeof $==="string"){if($.length>0)return $}else if(typeof $==="object"){let{publicId:Z,id:j}=$;if(typeof Z==="string"&&Z.length>0)return Z;if(typeof j==="string"&&j.length>0||typeof j==="number")return String(j)}throw TypeError("Features.set() was given an `actor` that identifies nobody. Pass a string, or a user with a `publicId` or an `id`.")}function $X($){return Object.fromEntries(Object.entries($).filter(([,Z])=>{return Z!==null&&Z!==void 0}))}var pO=50;class NZ{fetcher;entries=new Map;settleListener=null;failListener=null;shellAt=null;settledBacklog=[];shipped=new Set;requestStartedAt=performance.now();renderStartedAt=null;discoveryHintsMuted=!1;constructor($){this.fetcher=$}elapsed(){return Math.round(performance.now()-this.requestStartedAt)}keyFor($,Z){return[$,Z].filter((j)=>j.length>0).join("?")}markRenderStart(){if(this.renderStartedAt===null)this.renderStartedAt=performance.now()}markShell(){if(this.shellAt===null)this.shellAt=this.elapsed()}summarize($){let Z=this.elapsed();return{shellAt:this.shellAt??Z,settledAt:Z,aborted:$,queries:Array.from(this.entries.values(),(j)=>({path:j.path,variantKey:j.variantKey,startedAt:j.startedAt,settledAt:j.settledAt,status:j.status,source:j.source}))}}onQueryFail($){this.failListener=$}muteDiscoveryHints(){this.discoveryHintsMuted=!0}maybeLogLateDiscovery($){if(!$.lateBy||this.discoveryHintsMuted)return;if($.status!=="resolved")return;if(Bun.env.NODE_ENV==="production")return;let Z="";try{let W=JSON.stringify($.data)?.length??0;Z=W>=1024?`${(W/1024).toFixed(1)} kB`:`${W} B`}catch{Z="an unserializable payload"}let j=($.settledAt??0)-$.startedAt,J=$.variantKey?`, { search: ${JSON.stringify(Object.fromEntries(new URLSearchParams($.variantKey)))} }`:"";console.warn(`[gemi] useQuery("${$.patternPath}") was discovered ${$.lateBy}ms into the `+`server render \u2014 under a suspended segment, so its fetch (${j}ms, resolved ${Z}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${J})\` in the view `+"handler starts it at request time \u2014 but note prefetched data is also re-fetched and "+`streamed into every client-side navigation payload for the route, even when the client already holds it, so weigh that bandwidth against the ${Z}. If the data is only needed conditionally (a closed popover, a hidden tab), \`{ lazy: true }\` + \`trigger()\` avoids running it here at all. \`Query.noPrefetch()\` in the handler marks the omission intentional and silences this hint for the route.`)}read($,Z){return this.entries.get(this.keyFor($,Z))}ensure($,Z={},j="render"){let J=Z.params??{},W=new URLSearchParams($X(Z.search??{}));W.delete("json"),W.sort();let Y=F0($,J),z=W.toString(),X=this.keyFor(Y,z),G=this.entries.get(X);if(G)return G;let F;if(j==="render"&&this.renderStartedAt!==null){let D=Math.round(performance.now()-this.renderStartedAt);if(D>pO)F=D}let Q,O=new Promise((D)=>{Q=D}),K={path:Y,patternPath:$,variantKey:z,lateBy:F,status:"pending",promise:O,source:j,startedAt:this.elapsed()};return this.entries.set(X,K),this.fetcher($,J,W).then((D)=>{K.status="resolved",K.data=D},(D)=>{K.status="rejected",K.error=D}).then(()=>{if(K.settledAt=this.elapsed(),this.maybeLogLateDiscovery(K),K.status==="rejected"&&this.failListener)this.failListener(K);if(this.settleListener)this.settleListener(K);else this.settledBacklog.push(K);Q()}),K}async allSettled(){let $=0;while($!==this.entries.size)$=this.entries.size,await Promise.all(Array.from(this.entries.values(),(Z)=>Z.promise))}snapshotResolved(){let $={};for(let[Z,j]of this.entries){if(j.status!=="resolved")continue;this.shipped.add(Z),$[j.path]??={},$[j.path][j.variantKey]=j.data}return $}onSettle($){this.settleListener=(j)=>{if(this.shipped.has(this.keyFor(j.path,j.variantKey)))return;$(j)};let Z=this.settledBacklog;this.settledBacklog=[];for(let j of Z)this.settleListener(j)}}class x1 extends Error{path;variantKey;status;body;retryAfter;constructor($,Z,j,J,W){super(typeof J?.message==="string"?J.message:`Request to /api${$} failed with status ${j}`);this.path=$;this.variantKey=Z;this.status=j;this.body=J;this.retryAfter=W;this.name="QueryError"}}function LZ(){let $=JSON.stringify({error:w1("permission","Forbidden",403)});return new Response($,{status:403,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}function DJ(){return{status:403,error:{message:"Forbidden"}}}function T3($){let Z=HZ.getStore();return(j,J,W)=>{let Y=new URL($.url).origin,z=[F0(j,J),W.toString()].filter((Q)=>Q.length>0).join("?"),X=new Request(`${Y}/${z}`,{headers:$.headers,signal:$.signal}),G=ZX($);if(G)CZ(X,G);let F=new S(X,J);return HZ.run(Z,()=>H.run(F,async()=>{try{let Q=await T(a0).dispatchers(G).api.getRouteData(j);if(y$(Q)){if(!Q.ok)throw new x1(F0(j,J),W.toString(),Q.status,Q.body);return Q.body}if(Q instanceof Response){let O=await Q.json().catch(()=>null);if(!Q.ok)throw new x1(F0(j,J),W.toString(),Q.status,O);return O}return Q}catch(Q){if(Q instanceof x1)throw Q;let O=new x1(F0(j,J),W.toString(),500,{message:Q instanceof Error?Q.message:String(Q)});throw O.cause=Q,O}}))}}var hO=new Set(["script","style","template","title"]),cO=/\shidden([\s=/]|$)/i,dO=/"[^"]*"|'[^']*'/g;function uO($){let Z=0,j=0,J=0,W=0;while(W<$.length){let Y=$.indexOf("<",W),z=Y===-1?$.length:Y;if(z>W){let O=$.slice(W,z).replace(/\s+/g,"").length;if(J>0)j+=O;else Z+=O}if(Y===-1)break;if($.startsWith("<!--",Y)){let O=$.indexOf("-->",Y+4);W=O===-1?$.length:O+3;continue}let X=$.indexOf(">",Y);if(X===-1)break;let G=$.slice(Y+1,X);W=X+1;let F=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(G)?.[1]?.toLowerCase();if(!F)continue;let Q=G.startsWith("/");if(!Q&&hO.has(F)&&!G.endsWith("/")){let O=$.indexOf(`</${F}`,W);W=O===-1?$.length:O;continue}if(F!=="div")continue;if(Q){if(J>0)J-=1}else if(J>0)J+=1;else if(cO.test(G.replace(dO,'""')))J=1}return{shellChars:Z,deferredChars:j}}var lO=1000,iO=64;function sO($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function nO($,Z){if(Z.deferredChars<lO)return null;if(Z.shellChars>=iO)return null;return`[gemi] GET ${$} streams ${sO(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 jX($=console.warn){let Z=new Set;return{shouldObserve(j){return!Z.has(j)},report(j,J){if(Z.has(j))return;let W=nO(j,J);if(!W)return;Z.add(j),$(W)}}}function JX(){let $=new TextDecoder,Z="";return{onChunk(j){Z+=$.decode(j,{stream:!0})},measure(){return Z+=$.decode(),uO(Z)}}}function WX($,Z,j=1e4,J){let W=new TextEncoder,Y=()=>{};return new ReadableStream({start(z){let X=!1,G=(Q)=>{if(X)return;X=!0,clearTimeout(F);try{z.close()}catch{}J?.({aborted:Q})};Y=G,z.enqueue(W.encode(`${JSON.stringify($)}
|
|
14
|
-
`)),Z.onSettle((Q)=>{if(X||Q.status!=="resolved")return;z.enqueue(W.encode(`${JSON.stringify([Q.path,Q.variantKey,Q.data])}
|
|
15
|
-
`))});let F=setTimeout(()=>G(!0),j);Z.allSettled().then(()=>G(!1),()=>G(!1))},cancel(){Y(!1)}})}import{Fragment as rI,createContext as oO,createElement as tI,lazy as eI,use as $M,useContext as ZM}from"react";function YX($){return{islands:[],render:$,instances:new WeakMap,count:0}}var I3="gemi-slot",zX="data-slot",XX="data-gemi-slot";var aO=Symbol.for("gemi.staticRender"),GX=globalThis[aO]??=oO(null);import{createHash as rO}from"crypto";var tO="gemi-islands",UJ='const d=document,c=JSON.parse(d.getElementById("gemi-islands").textContent),w=f=>(window.requestIdleCallback||setTimeout)(f),m=(e,o)=>{if(!e.g){e.g=1;import(o.s).then(x=>x.h(e,x.m[o.e])).catch(r=>console.error(r))}};for(const e of d.querySelectorAll("gemi-island")){const o=c.i[e.dataset.island];if(!o)continue;if(o.l=="eager")m(e,o);else if(o.l=="idle"||!window.IntersectionObserver||!e.children.length)w(()=>m(e,o));else{const v=new IntersectionObserver(n=>{if(n.some(x=>x.isIntersecting)){v.disconnect();m(e,o)}});for(const k of e.children)v.observe(k)}}',zM=`'sha256-${rO("sha256").update(UJ).digest("base64")}'`,eO='await import("/refresh.js").catch(()=>{});await import("/@vite/client").catch(()=>{});'+UJ;function FX($,Z,j,J){if(!j)return $;let W=J?$.lastIndexOf(Z):$.indexOf(Z);return W===-1?$+j:$.slice(0,W)+j+$.slice(W)}var $B=($)=>$.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<");function QX($,Z,j,J){if(Z.islands.length===0||!j)return $;let W=new Set,Y=Z.islands.map((G)=>{let F=G.module?j(G.module):void 0;if(!F)return console.error(`[gemi] island ${G.module??"(unknown module)"}: no client build entry. Declare it as island(() => import("./Component")) so gemi's Vite plugin builds it.`),null;if(G.load==="eager")for(let Q of F.preload)W.add(Q);return{s:F.src,e:G.export,l:G.load}});if(Y.every((G)=>G===null))return $;let z=[...W].map((G)=>`<link rel="modulepreload" href="${$B(G)}"/>`).join(""),X=`<script type="application/json" id="${tO}">${S1({i:Y})}</script><script type="module">${J?eO:UJ}</script>`;return FX(FX($,"</head>",z,!1),"</body>",X,!0)}function ZB($,Z){let j=/<(\/?)template\b[^>]*>/gi;j.lastIndex=Z;let J=0;for(let W=j.exec($);W;W=j.exec($))if(J+=W[1]?-1:1,J===0)return j.lastIndex;return-1}function KX($){let Z=`<template ${XX}="`;for(let j=$.lastIndexOf(Z);j!==-1;j=$.lastIndexOf(Z)){let J=ZB($,j);if(J===-1)break;let W=j+Z.length,Y=$.slice(W,$.indexOf('"',W)),z=$.indexOf(">",W)+1,X=$.slice(z,J-11);$=$.slice(0,j)+$.slice(J);let G=`<${I3} ${zX}="${Y}" style="display:contents"></${I3}>`;$=$.split(G).join(`<${I3} style="display:contents">${X}</${I3}>`)}return $}function OX($){if(!$)return{locale:!0,session:!0,csrf:!0};return{locale:!1,session:$.session===!0,csrf:$.csrf===!0}}function BX($,Z){if($.getSetCookie().length>0){if(Z.cacheControl&&Bun.env.NODE_ENV!=="production")console.warn(`[gemi] A static view with cacheControl "${Z.cacheControl}" set a cookie, so it was sent "private, no-store" instead. Static pages are cacheable only when nothing on them sets a cookie.`);$.set("Cache-Control","private, no-store");return}if(Z.cacheControl&&!$.has("Cache-Control"))$.set("Cache-Control",Z.cacheControl)}var jB=async()=>(await import("./chunk-mcjbck8e.js")).default,VJ,M3=async(...$)=>{return VJ??=import("react-dom/server.browser").catch((Z)=>{throw VJ=void 0,Z}),(await VJ).renderToReadableStream(...$)},UX=1e4,VX="no-locale",JB=`
|
|
16
|
-
!function(){try{var d=document.documentElement,c=d.classList;
|
|
17
|
-
c.remove('light','dark');
|
|
18
|
-
var e=localStorage.getItem('theme');
|
|
19
|
-
if('system'===e||(!e&&'system'===defaultTheme)){
|
|
20
|
-
var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);
|
|
21
|
-
if(m.media!==t||m.matches){d.style.colorScheme='dark';c.add('dark')}
|
|
22
|
-
else{d.style.colorScheme='light';c.add('light')}
|
|
23
|
-
}else if(e){
|
|
24
|
-
c.add(e||'')
|
|
25
|
-
}}catch(e){}}()
|
|
26
|
-
`;async function WB($,Z,j){let J=`${j==="italic"?"italic,":""}wght@${j==="italic"?"1,":""}${Z}`,z=(await(await fetch(`https://fonts.googleapis.com/css2?family=${$}:${J}&display=swap`,{headers:{"User-Agent":"Mozilla/5.0 Firefox/1.0"}})).text()).match(/url\(([^)]+)\)/)?.[1];return await fetch(z).then((X)=>X.arrayBuffer())}var MJ="/assets";function YB($){return $===MJ||$.startsWith(`${MJ}/`)}function zB($){let Z=$.filter(YB);if(Z.length>0){let j=Z.length>1;throw Error(`View route path${j?"s":""} ${Z.map((J)=>`"${J}"`).join(", ")} use${j?"":"s"} the reserved "${MJ}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function XB($){let Z=T(a0).resolver;return{...$.domain,root:Z.root,origin:Z.publicOrigin($.rawRequest)}}function TJ($){let{status:Z=400,error:j,body:J,...W}=$;return new Response(J??j?.message,{...W,status:Z})}function GB($){let{status:Z=400,data:j,directive:J,headers:W}=$;return new Response(JSON.stringify({data:j,directive:J}),{headers:W,status:Z})}class N3{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];staticRoutes=[];root=null;shellReporter=jX();preloadCache=new WeakMap;hooks;partialRendering;localeRouting;constructor($){let Z=Uz();this.partialRendering=$.partialRendering??Z.partialRendering,this.localeRouting=$.localeRouting??Z.localeRouting,this.hooks={onRequestStart:$.onRequestStart??Z.onRequestStart,onRequestEnd:$.onRequestEnd??Z.onRequestEnd,onRequestFail:$.onRequestFail??Z.onRequestFail,onStreamComplete:$.onStreamComplete??Z.onStreamComplete};let j={"/":$.rootRouter,"/auth":y4};this.flatViewRoutes=Y8(j),zB(Object.keys(this.flatViewRoutes)),this.routeManifest=X8(j),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,J])=>J.at(-1)!=="FILE")),this.componentTree=F8(j),this.flatComponentTree=GJ(this.componentTree),this.staticRoutes=Object.entries(this.flatViewRoutes).filter(([,J])=>J.static).map(([J])=>J);for(let J of this.staticRoutes){let W=this.flatViewRoutes[J].static?.layout;if(W&&!this.flatComponentTree.includes(W))this.flatComponentTree.push(W)}this.root=$.root}async passesFeatureGates($){let Z=T(PZ);for(let j of $)if(!await Z.enabled(j))return!1;return!0}async onRequestEnd($,Z={}){if(Z.mintSession!==!1)O8();return await this.hooks.onRequestEnd($)}completeStream($,Z){let j=(J)=>{A$.error(J?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(J)})};try{Promise.resolve(this.hooks.onStreamComplete($,Z)).catch(j)}catch(J){j(J)}}modulePreloadLinks($){let{clientEntry:Z,modulePreloadManifest:j,views:J,routeKey:W}=$,Y=()=>{let G=new Set(Z?.preload??[]);for(let F of J)for(let Q of j?.[F]??[])G.add(Q);return[...G].map((F)=>A1("link",{key:`modulepreload:${F}`,rel:"modulepreload",href:F}))};if(!j)return Y();let z=this.preloadCache.get(j);if(!z||z.clientEntry!==Z)z={clientEntry:Z,byRoute:new Map},this.preloadCache.set(j,z);let X=z.byRoute.get(W);if(!X)X=Y(),z.byRoute.set(W,X);return X}async renderStatic($){let{req:Z,runInRequestScope:j,staticView:J,currentViews:W,data:Y,serverQueries:z,headers:X}=$,G;if(J.layout){if(G=$.viewImportMap[J.layout],!G)throw Error(`The static layout "${J.layout}" was not found. It is a view path: a file at app/views/${J.layout}.tsx whose default export renders the document.`)}let F=await $.getStyles(W,{static:!0,layout:J.layout});z.markRenderStart();let Q=IJ(),O=new AbortController,K=setTimeout(()=>O.abort(),UX),D=(U)=>{if(Bun.env.NODE_ENV!=="production")console.error(U)},B=YX(async(U,V)=>{let I=await M3(U,{signal:O.signal,identifierPrefix:V,progressiveChunkSize:Number.MAX_SAFE_INTEGER,onError:D});return await I.allReady.catch(()=>{}),await new Response(I).text()});try{let U=await M3(A1(GX.Provider,{value:B,children:A1(DX,{children:[...F,A1(this.root,{data:Y,viewImportMap:$.viewImportMap,viewModules:$.viewModules,serverQueries:z,dictionarySink:Q,rootLayout:G,key:"root"})]})}),{signal:O.signal,progressiveChunkSize:Number.MAX_SAFE_INTEGER,onError:D});await U.allReady.catch(()=>{});let V=KX(await new Response(U).text());return new Response(QX(V,B,$.resolveIsland,Bun.env.NODE_ENV!=="production"),{status:200,headers:X})}finally{clearTimeout(K),j(()=>this.completeStream(Z,z.summarize(O.signal.aborted)))}}async render($){let{req:Z,runInRequestScope:j,csrfTokenHMAC:J,currentPathName:W,headers:Y,i18n:z,params:X,pathname:G,serverQueries:F,userAgent:Q,noStream:O,url:K,user:D,viewData:B,breadcrumbs:U,urlLocaleSegment:V,meta:I,isOgRequest:P,appId:M,features:x,staticView:f}=$,A=G.replace(`/${V}`,""),_={kind:"view",data:{meta:I,pageData:{[A]:B},__csrf:J.toString("base64"),prefetchedData:{},i18n:z,auth:{user:D},routeManifest:this.clientRouteManifest,breadcrumbs:U,router:{urlLocaleSegment:V,pathname:W,params:X,currentPath:G,searchParams:K.search,is404:!W?!0:!1,domain:Z.domain?XB(Z):null},appId:M,features:x,componentTree:[["404",[]],...this.componentTree],...this.staticRoutes.length>0?{staticRoutes:this.staticRoutes}:{}},head:{}},L=this.root,N=this.routeManifest[W];return async(l)=>{let{bootstrapModules:d=[],loaders:E1,getStyles:$0,viewImportMap:n,cssManifest:w,ogMap:B0,viewModules:f$,clientEntry:E$,modulePreloadManifest:AZ,assetBase:Q1,resolveIsland:R$}=l,R1=E$?[]:d,Z0=(q)=>[q,`window.loaders=${E1}`,...E$?[`import(${JSON.stringify(E$.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(P){let q=null,t0=null;for(let v$ of N??[])if(typeof B0[v$]==="function")t0=v$,q=B0[v$];if(!q)return new Response("Not found",{status:404});let zG=Object.values(_.data.pageData)[0];try{await M3(A1(q,zG[t0]),{onError:()=>{}})}catch(v$){let{fonts:XG,...GG}=v$.satoriOptions,FG=await Promise.all(XG.map((L3)=>{return WB(L3.name,L3.weight,L3.style).then((DG)=>({...L3,data:DG}))})),vJ=new Headers(Y);vJ.set("Content-Type","image/png");let[QG,KG]=await Promise.all([jB(),J8("Rendering an OG image")]),OG=await QG(v$.jsx,{...GG,fonts:FG}),BG=await KG(Buffer.from(OG)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(BG),{headers:vJ})}return new Response("data")}if(f&&W)return await this.renderStatic({req:Z,runInRequestScope:j,staticView:f,currentViews:N,data:_.data,serverQueries:F,headers:Y,getStyles:$0,viewImportMap:n,viewModules:f$,resolveIsland:R$});if(_.data.cssManifest=w,_.data.modulePreloadManifest=AZ??{},Q1&&Q1!=="/")_.data.assetBase=Q1;let H8=this.modulePreloadLinks({clientEntry:E$,modulePreloadManifest:AZ,views:N??["404"],routeKey:W??"404"}),C8=await $0(N);_.data.prefetchedData=F.snapshotResolved(),F.markRenderStart();let r0=new AbortController,b$=setTimeout(()=>r0.abort(),UX),Z$=K8(Q)||O,b1=Bun.env.NODE_ENV!=="production"&&!Z$&&W&&this.shellReporter.shouldObserve(W)?JX():null,R=IJ();try{let q=await M3(A1(DX,{children:[...H8,...C8,A1("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:JB}}),A1(L,{data:_.data,viewImportMap:n,viewModules:f$,serverQueries:F,dictionarySink:R,key:"root"})]}),{bootstrapScriptContent:Z0(`window.__GEMI_DATA__ = ${S1(_.data)}`),bootstrapModules:R1,signal:r0.signal,...Z$?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(t0){if(Bun.env.NODE_ENV!=="production")console.error(t0)}});if(q.allReady.catch(()=>{}).finally(()=>clearTimeout(b$)),Z$)await q.allReady.catch(()=>{});return new Response(QJ(q,F,{onShell:Z$?void 0:()=>F.markShell(),onChunk:b1?.onChunk,onClose:()=>j(()=>{if(this.completeStream(Z,F.summarize(r0.signal.aborted)),b1)this.shellReporter.report(W,b1.measure())})},R),{status:!W?$.refusedStatus??404:200,headers:Y})}catch(q){if(clearTimeout(b$),Bun.env.NODE_ENV==="production")throw j(()=>this.completeStream(Z,F.summarize(r0.signal.aborted))),q;let t0=await M3(A1("div"),{bootstrapScriptContent:Z0(`window.error= ${S1(q.message)}; window.stack_trace=${S1(q.stack)};window.__GEMI_DATA__ = ${S1(_.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...R1]:R1});return new Response(QJ(t0,F,{onClose:()=>j(()=>this.completeStream(Z,F.summarize(r0.signal.aborted)))}),{status:!W?$.refusedStatus??404:200,headers:Y})}}}viewRefusalStatus($,Z,j){if(P3(Z))return 404;if(Z?.kind===_Z){let J=Z.payload?.view?.status;return J===403||J===404?J:null}if(SZ(Z)){if(!j.has(Z))this.hooks.onRequestFail($,Z);return console.error(Z),403}if(Z instanceof x1&&(Z.status===403||Z.status===404))return Z.status;return null}async handleViewRequest($,Z){let j=new URL($.url),J=j.pathname.endsWith(".json"),W=j.pathname.endsWith(".og"),Y=j.pathname.replace(".json","").replace(".og",""),[,z,...X]=Y.split("/"),G=Y,F=null,Q=null,O=T(a),K=V3(this.flatViewRoutes,Y),D=O.isLocaleAware&&this.localeRouting==="prefix"&&!K?.route.middleware.includes(VX);if(D&&O.supportedLocales.includes(z))G=`/${X.join("/")}`,F=z,Q=z;if(D&&!W&&Q===null&&!(Q===null&&K!==null)){let L=TX(z,O.supportedLocales,O.defaultLocale);if(L){let N=X.length?`/${X.join("/")}`:"";return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${L}${N}${J?".json":""}${j.search}`}})}}if(D&&!W){let L=T(a).detectLocale(new S($,{},"view",G));if(Q===null&&L!==O.defaultLocale){let N=j.pathname==="/"?"":j.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${L}${N}${j.search}`}})}}G=G.replace("//","/");let U=[],V=[],I=null,P={},M=null,x=!1,f=[],A;try{let L=V3(this.flatViewRoutes,G);if(Q&&L?.route.middleware.includes(VX))L=null;if(L){if(I=L.routePath,P=L.params,U=L.route.exec,V=L.route.middleware,f=L.route.features,x=V.includes("no-stream"),A=L.route.static,J&&this.partialRendering){let N=$.headers.get(XJ),l=hz({flatViewRoutes:this.flatViewRoutes,supportedLocales:T(a).supportedLocales,from:N,origin:j.origin,to:{segments:L.route.segments,params:P,search:j.search}});if(l.startIndex>0)U=U.slice(l.startIndex),M={from:N,carriedViews:l.carriedViews}}}}catch(L){throw L}if(A&&J)return new Response("Not found",{status:404});let _=new S($,P,"view",I);return this.hooks.onRequestStart(_),await H.run(_,async()=>{let L=null,N=H.getStore(),l=HZ.getStore(),d=(w)=>HZ.run(l,()=>H.runWith(N,w));N.serverQueries=new NZ(T3($));let E1=new Set;N.serverQueries.onQueryFail((w)=>{E1.add(w.error);try{d(()=>Promise.resolve(this.hooks.onRequestFail(n,w.error)).catch(()=>{}))}catch{}});let $0=OX(A);if(Q){let w=Q.replaceAll("/","");$$.setLocale(w,{cookie:$0.locale})}else if(O.isLocaleAware&&!D)N.setLocale(O.defaultLocale);else $$.setLocale(void 0,{cookie:$0.locale});let n=N.req;if($0.session)O8();try{let w=null;try{await T(VZ).runMiddleware(V)}catch(R){if(w=this.viewRefusalStatus(n,R,E1),w===null)throw R}if(w!==null||f.length>0&&!await this.passesFeatureGates(f))I=null,U=[],n.routePath="";let B0=T(a),f$=B0.isEnabled,E$=B0.isLocaleAware,AZ=new S($,n.params),Q1={defaultLocale:B0.defaultLocale,timeZone:B0.detectTimeZone(AZ)};if(E$){let R=null;if(Q)R=Q.replaceAll("/",""),N.setLocale(R);else if(!D)R=N.locale??B0.defaultLocale;else R=B0.detectLocale(AZ),N.setLocale(R);let q=f$?B0.getPageTranslations(R,n.routePath):{};Q1={...Q1,supportedLocales:B0.supportedLocales,currentLocale:R,dictionary:{[R]:q},defaultLocale:B0.defaultLocale,...D?{}:{localeRouting:"off"}}}await IX(Q1.currentLocale??"");let R$;try{R$=await Promise.all(U.map((R)=>R(n)))}catch(R){if(w=this.viewRefusalStatus(n,R,E1),w===null)throw R;I=null,U=[],n.routePath="",R$=[]}let{cookies:R1,headers:Z0}=N;if(w!==null)Z0.set("Cache-Control","no-store");L={data:R$,cookies:R1,headers:Z0,user:N.user,prefetchedData:N.serverQueries.snapshotResolved(),currentPathName:I,params:n.params,urlLocaleSegment:F,meta:N.renderMeta(),appId:T(FJ).id,features:await T(PZ).forClient()};let{params:H8,user:C8}=L,r0={},b$={};for(let R of R$??[]){let[q,t0]=Object.entries(R)?.[0]??[];if(!q||!t0)continue;b$[`${q}:${I}`]=t0.breadcrumb,r0[q]=t0}let Z$=r0.FILE;if(Z$){for(let R of R1)Z0.append("Set-Cookie",R.toString());try{await this.onRequestEnd(n)}catch(R){A$.error(R?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(R)})}return await y8(Z$,Z0)}if(J){Z0.set("Content-Type","application/x-ndjson; charset=utf-8"),Z0.append("Vary",XJ),R1.forEach((q)=>Z0.append("Set-Cookie",q.toString())),await this.hooks.onRequestEnd(n);let R={meta:M&&!N.metadata.touched?null:L.meta,data:{[G]:r0},breadcrumbs:b$,prefetchedData:N.serverQueries.snapshotResolved(),i18n:Q1,features:L.features,is404:!I,appId:L.appId,partial:M};return new Response(WX(R,N.serverQueries,void 0,({aborted:q})=>d(()=>this.completeStream(n,N.serverQueries.summarize(q)))),{headers:Z0})}if(Z0.set("Content-Type","text/html; charset=utf-8"),!x&&!(A&&I))Z0.append("Vary","User-Agent");let b1=Boolean(A&&I);if(!b1||$0.session)O8();for(let R of R1)Z0.append("Set-Cookie",R.toString());if(!b1||$0.csrf){let R=Bun.CSRF.generate(process.env.SECRET);Z0.append("Set-Cookie",`csrf_token=${R}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`)}try{await this.onRequestEnd(n,{mintSession:!b1||$0.session})}catch(R){A$.error(R?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(R)})}if(b1)BX(Z0,A);return await this.render({req:n,runInRequestScope:d,csrfTokenHMAC:Buffer.from(""),currentPathName:I,headers:Z0,i18n:Q1,params:H8,pathname:j.pathname,serverQueries:N.serverQueries,userAgent:$.headers.get("user-agent"),noStream:x,url:j,user:C8,viewData:r0,breadcrumbs:b$,urlLocaleSegment:F,meta:L.meta,appId:L.appId,features:L.features,isOgRequest:W,staticView:I?A:void 0,refusedStatus:w??void 0})}catch(w){if(w.kind===_Z){let B0=J?GB(w.payload.viewData??w.payload.api):TJ(w.payload.view);for(let f$ of N.cookies)B0.headers.append("Set-Cookie",f$.toString());return B0}if(!E1.has(w))this.hooks.onRequestFail(n,w);if(SZ(w))return console.error(w),J?LZ():TJ(DJ());if(w instanceof x1&&w.status===403)return J?LZ():TJ(DJ());throw w}},Z)}}function PJ(){let $=JSON.stringify({error:w1("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 CX extends f0{routes={"/api-routes":this.get(()=>{let $=T(D8).flatRoutes,Z=[];for(let[j,J]of Object.entries($))for(let[W,Y]of Object.entries(J)){let{exec:z,middleware:X}=Y;Z.push({path:j,method:W,middleware:X})}return Z}),"/view-routes":this.get(()=>{let $=T(N3).flatViewRoutes,Z=[];for(let[j,{middleware:J,viewPath:W}]of Object.entries($))Z.push({path:j,method:"GET",viewPath:W,middleware:J});return Z})}}var FB=new Set([v1,"cookie","content-type","content-length","transfer-encoding","connection","host","user-agent","forwarded"]),QB=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,KB=/^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]*$/;function OB($,Z,j,J){for(let[W,Y]of Object.entries(j.headers??{})){if(Y===void 0||Y===null)continue;let z=W.toLowerCase();if(FB.has(z)||z.startsWith("x-forwarded-"))throw Error(`dispatchAs: credentials may not set the "${W}" header. The access token stays the initiator's, and the request's framing is dispatchAs's own.`);if(J&&z==="authorization")throw Error(`dispatchAs: credentials may not set "Authorization" on a call dispatched as an identity. The caller's token is for the MCP endpoint and is never passed on.`);$.set(W,Y)}for(let[W,Y]of Object.entries(j.cookies??{})){if(Y===void 0||Y===null)continue;if(W===v1)throw Error(`dispatchAs: credentials may not set the "${v1}" cookie. The access token stays the initiator's.`);if(!QB.test(W)||!KB.test(Y))throw Error(`dispatchAs: "${W}" is not a cookie a Cookie header can carry.`);Z.push(`${W}=${Y}`)}}function BB($,Z){let j=$.body.getReader(),J=!1,W=()=>{if(J)return;J=!0;try{Z()}catch(z){console.error(z)}},Y=new ReadableStream({async pull(z){let X;try{X=await j.read()}catch(G){W(),z.error(G);return}if(X.done){W();try{z.close()}catch{}return}try{z.enqueue(X.value)}catch{}},async cancel(z){try{await j.cancel(z)}finally{W()}}},{highWaterMark:0});return new Response(Y,{status:$.status,statusText:$.statusText,headers:$.headers})}function MX($){let{status:Z=400,data:j,headers:J}=$,W=new Headers({"Content-Type":"application/json",...J});if(!W.has("Cache-Control"))W.set("Cache-Control","no-store");return new Response(JSON.stringify(j),{status:Z,headers:W})}function PX($,Z,j){let J=[];Z?.forEach((z,X)=>J.push([X,z]));let W=[...typeof Z?.getSetCookie==="function"?Z.getSetCookie():[],...Array.from(j??[])];if(J.length===0&&W.length===0)return $;let Y=(z)=>{for(let[X,G]of J){if(X.toLowerCase()==="set-cookie")continue;if(!z.has(X))z.set(X,G)}for(let X of W)z.append("Set-Cookie",X)};try{return Y($.headers),$}catch{let z=new Headers($.headers);return Y(z),new Response($.body,{status:$.status,statusText:$.statusText,headers:z})}}class D8{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let Z=Dz();this.onRequestStart=$.onRequestStart??Z.onRequestStart,this.onRequestEnd=$.onRequestEnd??Z.onRequestEnd,this.onRequestFail=$.onRequestFail??Z.onRequestFail,this.flatRoutes=d4({"/":$.rootRouter,"/auth":q4,"/__gemi__/services/i18n":g4,"/__gemi__/services/logs":c4,"/__gemi__/services/image":h4,"/__gemi__/debug":CX})}getRouteHandlerAndParams($){let Z=new URL($.url),j=HX(Z.pathname),J={},W;for(let[Y]of Object.entries(this.flatRoutes))try{let z=new URLPattern({pathname:Y});if(z.test({pathname:j})){W=Y,J=z.exec({pathname:j})?.pathname.groups;break}}catch(z){console.error(z)}return{params:J,path:W}}async runRouteMiddleware($,Z){let J=this.flatRoutes[$][Z.rawRequest.method].middleware;try{await T(VZ).runMiddleware(J)}catch(W){if(W.kind===_Z)return MX(W.payload.api);else{if(P3(W))return PJ();if(this.onRequestFail(Z,W),console.error(W),SZ(W))return LZ();throw W}}}async getRouteData($){let Z=this.flatRoutes[$],j=H.getStore(),J=Z[j.req.rawRequest.method].exec??(()=>Promise.resolve({})),W={};try{W=await J()}catch(Y){if(Y.kind===_Z)return MX(Y.payload.api);if(P3(Y))return PJ();if(this.onRequestFail(j.req,Y),console.error(Y),SZ(Y))return LZ();throw Y}return W}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,Z,j){let J=async()=>{try{if(!this.isFrameworkRoute(j))await this.onRequestEnd(Z)}catch(W){A$.error(W?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(W)})}finally{$.destroy()}};if(!$.hasPendingWork()){await J();return}$.whenIdle().then(J).catch((W)=>{console.error(W)})}isOpenEndedBody($,Z){return $.method!=="HEAD"&&!Z.headers.has("Content-Length")&&Z.body!==null}async handleApiRequest($,Z){let{params:j,path:J}=this.getRouteHandlerAndParams($),W=this.flatRoutes[J];if(!W||!W[$.method])return new Response(JSON.stringify({error:w1("not_found","Not found",404)}),{status:404});let Y=new S($,j,"api",J);if(!this.isFrameworkRoute(J))this.onRequestStart(Y);return await H.run(Y,async()=>{let z=H.getStore(),X=!1,G=async()=>{X=!0,await this.endRequest(z,Y,J)};try{let F=T(a);if(F.isEnabled){let U=F.detectLocale(Y);z.setLocale(U)}z.setRequest(Y),T(VZ).applyDefaultBodyLimit($);let Q=await this.runRouteMiddleware(J,Y);if(Q instanceof Response){let U=PX(Q,z.headers,z.cookies);return await G(),U}let O=await this.getRouteData(J),K=z.headers,D=z.cookies;if(O instanceof Response){let U=PX(O,K,D);if(this.isOpenEndedBody($,U)){let V=BB(U,()=>this.endRequest(z,Y,J));return X=!0,V}return await G(),U}let B=(y$(O)?O:j$.json(O)).toResponse(K,D);return await G(),B}catch(F){if(!X)try{await G()}catch(Q){console.error(Q)}throw F}},Z)}async dispatchAs($,Z,j,J,W){let Y=new URL($.rawRequest.url).origin,z=new URL(`${Y}/api${j}`),X=`/api${j.split(/[?#]/)[0]}`;if(!j.startsWith("/")||z.origin!==Y||z.pathname!==X||z.hash!==""||z.pathname.startsWith("/api/__gemi__")||z.pathname==="/api/auth"||z.pathname.startsWith("/api/auth/"))throw Error(`dispatchAs: "${j}" is not an app api path. Pass the route's own path, without "/api", with every param encoded.`);let G=W?.identity;if(G!==void 0&&(typeof G!=="object"||!G?.user))throw Error("dispatchAs: identity needs the user to dispatch as.");let F=new Headers,Q=[],O=G?null:$.cookies.get(v1);if(O)Q.push(`${v1}=${O}`);if(W?.credentials)OB(F,Q,W.credentials,G!==void 0);if(Q.length>0)F.set("Cookie",Q.join("; "));let K=G?null:$.headers.get(v1);if(K)F.set(v1,K);let D=$.headers.get("User-Agent");if(D)F.set("User-Agent",D);let B;if(J instanceof FormData)B=J;else if(J!==void 0)F.set("Content-Type","application/json"),B=JSON.stringify(J);let U=new Request(z,{method:Z,headers:F,body:B,...W?.signal?{signal:W.signal}:{}});if(NX(U,g$($),G?.grant,W?.progress),$.domain)CZ(U,$.domain);let V=G?{user:G.user}:void 0;return H.exit(()=>LX.exit(()=>this.handleApiRequest(U,V)))}}import{timingSafeEqual as DB}from"crypto";var V8="",HJ="*",UB=60000,VB=1e4,NJ=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,U8=16,_X=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,LJ="x-forwarded-host";function SX($){return $.startsWith(":")}function CJ($,Z){if($===null)return!1;let j=Buffer.from($,"utf8"),J=Buffer.from(Z,"utf8");return j.length===J.length&&DB(j,J)}function TB($){if(!$)return null;if($===!0)return{header:LJ,secret:null};return{header:($.hostHeader??LJ).toLowerCase(),secret:$.secret?{header:$.secret.header.toLowerCase(),value:$.secret.value}:null}}function IB($){if(!$||$===!0)return;let{hostHeader:Z,secret:j}=$;if(Z!==void 0&&(typeof Z!=="string"||!_X.test(Z)))throw Error(`\`route.domains.trustProxy.hostHeader\` must be a single header name, e.g. "x-forwarded-host". Got ${JSON.stringify(Z)}.`);if(!j)return;if(typeof j.header!=="string"||!_X.test(j.header))throw Error(`\`route.domains.trustProxy.secret.header\` must be a header name. Got "${j.header}".`);if(j.header.toLowerCase()===(Z??LJ).toLowerCase())throw Error("`route.domains.trustProxy.secret.header` names the same header as `hostHeader`; the secret needs a header of its own.");if(typeof j.value!=="string"||j.value.length<U8)throw Error(`\`route.domains.trustProxy.secret.value\` must be at least ${U8} characters. A guessable one lets any client name its own host.`)}function F1($){if(!$)return null;try{return new URL(`http://${$.trim()}`).hostname.toLowerCase().replace(/\.$/,"")||null}catch{return null}}function MB($){try{let Z=new URL(`http://${$.trim()}`),j=Z.hostname.toLowerCase().replace(/\.$/,"");return j?Z.port?`${j}:${Z.port}`:j:null}catch{return null}}function PB($){let Z=F1($.root),j=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!Z||Z!==j||!Z.split(".").every((Y)=>NJ.test(Y)))throw Error(`\`route.domains.root\` must be a bare hostname, e.g. "example.com" \u2014 no scheme, port or path. Got "${$.root}".`);if($.custom&&($.custom.cacheTtlMs??0)<0)throw Error(`\`route.domains.custom.cacheTtlMs\` is ${$.custom.cacheTtlMs}; it cannot be negative. Use 0 to disable the cache.`);if($.ask&&$.ask.secret.length<U8)throw Error(`\`route.domains.ask.secret\` must be at least ${U8} characters. A guessable one is worse than leaving \`ask\` out.`);IB($.trustProxy);let J=new Set,W=null;for(let Y of $.groups??[]){let{subdomain:z}=Y;if(J.has(z))throw Error(`\`route.domains\` declares the subdomain "${z}" twice.`);if(J.add(z),SX(z)){if(!/^:[A-Za-z_][A-Za-z0-9_]*$/.test(z))throw Error(`"${z}" is not a valid param subdomain. It must be a single \`:name\` label.`);if(W)throw Error(`\`route.domains\` declares two param subdomains, "${W.subdomain}" and "${z}"; a host could match either.`);W=Y;continue}if(Y.exists)throw Error(`The subdomain "${z}" is fixed, so \`exists\` has no param to check. It only applies to a \`:param\` subdomain.`);if(!z.split(".").every((X)=>NJ.test(X)))throw Error(`"${z}" is not a valid subdomain.`)}if($.custom&&!J.has($.custom.group))throw Error(`\`route.domains.custom.group\` is "${$.custom.group}", but no group declares that subdomain.`);if($.ask&&W&&!W.exists)throw Error(`\`route.domains.ask\` is set, so "${W.subdomain}" needs an \`exists\` to say which tenants are real. Without one every host under the root would be approved for a certificate.`)}class _J{root;hostTrust;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;proxySecretHeader;constructor($){PB($),this.root=F1($.root),this.hostTrust=TB($.trustProxy);for(let Z of $.groups??[])if(SX(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??UB,this.askSecret=$.ask?.secret??null,this.proxySecretHeader=this.hostTrust?.secret?.header??null}forwardedHost($){let Z=this.hostTrust;if(!Z)return null;if(Z.secret&&!CJ($.headers.get(Z.secret.header),Z.secret.value))return null;return $.headers.get(Z.header)?.split(",")[0]?.trim()||null}hostOf($){return F1(this.forwardedHost($))??F1(new URL($.url).host)}publicOrigin($){let Z=new URL($.url),j=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),J=j==="http"||j==="https"?j:Z.protocol.replace(/:$/,""),W=this.forwardedHost($),Y=W&&F1(W)?MB(W):null;return`${J}://${Y??Z.host}`}async resolve($){let Z=this.hostOf($);if(!Z)return null;let j=await this.match(Z,$);if(j)return j;if(this.custom?.fallback&&!this.isUnderRoot(Z))return{host:Z,group:HJ,params:{},custom:!0};return null}async allows($,Z){let j=F1($);return j?await this.match(j,Z)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,Z){if($===this.root)return{host:$,group:V8,params:{},custom:!1};if($.endsWith(`.${this.root}`)){let J=$.slice(0,-(this.root.length+1)),W=this.fixed.get(J);if(W)return{host:$,group:W.subdomain,params:{},custom:!1};if(this.param&&NJ.test(J)){let Y={[this.param.name]:J};if(this.param.exists&&!await this.param.exists(Y,Z))return null;return{host:$,group:this.param.subdomain,params:Y,custom:!1}}return null}if(!this.custom)return null;let j=await this.resolveCustom($);return j?{host:$,group:this.custom.group,params:j,custom:!0}:null}async resolveCustom($){let Z=Date.now(),j=this.cache.get($);if(j&&j.expiresAt>Z)return this.cache.delete($),this.cache.set($,j),j.value;let J=this.inFlight.get($);if(J)return J;let W=(async()=>await this.custom.resolve($)??null)();this.inFlight.set($,W);let Y;try{Y=await W}finally{this.inFlight.delete($)}if(this.cacheTtlMs>0){if(this.cache.size>=VB)this.cache.delete(this.cache.keys().next().value);this.cache.delete($),this.cache.set($,{value:Y,expiresAt:Date.now()+this.cacheTtlMs})}return Y}forget($){if($===void 0)this.cache.clear();else{let Z=F1($);if(Z)this.cache.delete(Z)}}}var NB="/__gemi__/domains/ask";class a0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,Z){this.groups.set(V8,$);let{domains:j}=Z;if(this.acceptsCustomDomains=Boolean(j?.custom),!j){this.resolver=null;return}this.resolver=new _J(j);let J=(W)=>({api:W.api?new D8({...Z.api,...W.api}):$.api,view:W.view?new N3({...Z.view,...W.view}):$.view});for(let W of j.groups??[])this.groups.set(W.subdomain,J(W));if(j.custom?.fallback)this.groups.set(HJ,J(j.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);if(this.resolver.proxySecretHeader)xX($,this.resolver.proxySecretHeader);let Z=await this.resolver.resolve($);if(!Z)return null;return CZ($,Z),this.dispatchers(Z)}async ask($){if(!this.resolver?.askSecret||$.method!=="GET")return null;let Z=new URL($.url);if(Z.pathname!==NB)return null;if(!CJ(Z.searchParams.get("secret"),this.resolver.askSecret))return null;let j=Z.searchParams.get("domain"),J=j?await this.resolver.allows(j,$):!1;return new Response(null,{status:J?200:404})}dispatchers($){return this.groups.get($?.group??V8)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}viewGroups(){let $=new Set,Z=[];for(let[j,J]of this.groups){if($.has(J.view))continue;$.add(J.view),Z.push({group:j,view:J.view})}return Z}}function T8($){let Z=new Date($??0).getTime();return Number.isFinite(Z)?Z:0}var AX=600000;function fX($,Z){return[k3($,Z),k3($,Z-1)]}class E{static token="auth";config;provider;constructor($={},Z=new Wj){this.config={...I8(d5($),$),emailCode:jj($.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=T().bound(a0)?T(a0).resolver:null;return Z?Z.publicOrigin($.rawRequest):new URL($.rawRequest.url).origin}cookieDomain($){let Z=this.config.cookieDomain;if(!Z)return;let j=Z==="root"?T(a0).resolver?.root:F1(Z);if(!j)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let J=$.domain?.host??F1(new URL($.rawRequest.url).host);return J===j||J?.endsWith(`.${j}`)?j:void 0}async getSession($,Z){if(!$)return null;if(!a8($))return this.config.migrateLegacySession?this.convertLegacySession($,Z,this.config.migrateLegacySession):null;let j=await this.userProvider.findSession({token:$,userAgent:Z});if(!j?.user)return null;let J=Date.now(),W=T8(j.expiresAt),Y=T8(j.absoluteExpiresAt);if(W<=J||Y<=J)return await this.userProvider.deleteSession({token:$}),null;let X=await this.slideSession(j,J);return X.user.extension=await this.config.extendSession(X.user),X}async convertLegacySession($,Z,j){let J=H.getStore()?.req;if(!J)return null;let W=Date.now(),Y=Math.floor(W/AX),z=null,X=await this.userProvider.findSession({token:$,userAgent:Z});if(X?.user){if(!await j(X,{token:$,req:J,userAgent:Z}))return null;let F=k3($,Y),Q=X.user.id;if(await this.userProvider.withLegacySessionLock($,async()=>{if(!await this.userProvider.claimLegacySession({token:$}))return!1;return await this.userProvider.createSessionV2({token:F,userId:Q,userAgent:Z,...this.freshLifetime(W)}),!0}))z=F}if(!z){for(let F of fX($,Y))if((await this.userProvider.findSession({token:F,userAgent:Z}))?.user){z=F;break}}if(!z)return null;let G=await this.getSession(z,Z);if(G)J.ctx().setCookie("access_token",z,this.accessTokenCookieOptions(J,new Date(G.expiresAt)));return G}async revokeSession($,Z){if(!$)return await this.userProvider.deleteSession({token:$}),null;if(a8($)||!this.config.migrateLegacySession){let W=await this.userProvider.findSession({token:$,userAgent:Z});return await this.userProvider.deleteSession({token:$}),W}let j=Math.floor(Date.now()/AX),J=fX($,j);return this.userProvider.withLegacySessionLock($,async()=>{let W=await this.userProvider.findSession({token:$,userAgent:Z});for(let Y of J){if(W?.user)break;W=await this.userProvider.findSession({token:Y,userAgent:Z})}await this.userProvider.deleteSession({token:$});for(let Y of J)await this.userProvider.deleteSession({token:Y});return W})}requestCarryingCookie($){let Z=H.getStore()?.req;return Z?.cookies.get("access_token")===$?Z:null}async slideSession($,Z){let j=this.config.sessionExpiresInHours*3600000;if(new Date($.expiresAt).getTime()-Z>=j/2)return $;let J=new Date(Math.min(Z+j,new Date($.absoluteExpiresAt).getTime())),W=await this.userProvider.updateSession({token:$.token,expiresAt:J}),Y=this.requestCarryingCookie($.token);if(Y)Y.ctx().setCookie("access_token",$.token,this.accessTokenCookieOptions(Y,J));if(!W)return $;return{...$,expiresAt:W.expiresAt??J}}freshLifetime($){return{expiresAt:new Date($+this.config.sessionExpiresInHours*3600000),absoluteExpiresAt:new Date($+this.config.sessionAbsoluteExpiresInHours*3600000)}}async generateMagicLink($){}async upsertSession($){await this.userProvider.findSession({token:"",userAgent:""})}async authenticate($){try{let Z=await this.userProvider.findUserByEmailAddress($,!1);if(!Z)throw Error(`User not found with email: ${$}`);let j=await this.createOrUpdateSession({email:$,id:Z.id}),J=new S;if(J.ctx().setCookie("access_token",j.token,this.accessTokenCookieOptions(J,j.expiresAt)),j?.user)j.user.extension=await this.config.extendSession(j.user);return j}catch(Z){console.log(Z)}}async createOrUpdateSessionV2($){let Z=await this.createOrUpdateSession($),j=null;if(Z?.user)j=await this.config.extendSession(Z.user),Z.user.extension=j;return Z}async createOrUpdateSession($){let Z=new S,j=$.id??(await this.userProvider.findUserByEmailAddress($.email,!1))?.id;if(!j)throw new J$;let J=Bun.env.NODE_ENV==="development"?"local":Z.headers.get("User-Agent"),W=b5(j),Y=await this.userProvider.createSessionV2({token:W,userId:j,userAgent:J,...this.freshLifetime(Date.now())}),z=await this.userProvider.findSession({token:W,userAgent:J??""});return z?.user?z:Y}async createMagicLinkToken($){let Z=await this.userProvider.findUserByEmailAddress($,!1);if(Z){let{pin:j,token:J}=await this.issueOneTimeCode($,6);return{user:Z,email:$,pin:j,token:J}}return{}}async issueOneTimeCode($,Z){await this.userProvider.deleteMagicLinkToken($);let j=await this.config.generateMagicLinkToken($),J=await this.config.generateCode($),W=typeof J==="string"&&J!==""?J:m5(Z);return await this.userProvider.createMagicLinkToken({email:$,token:y3("link",$,j),pin:y3("pin",$,W)}),{email:$,pin:W,token:j}}async verifyOneTimeCode($,Z,j={}){let{expiresInMinutes:J,maxAttempts:W}=this.config.emailCode,Y=await this.userProvider.findMagicLinkTokenByEmail($);if(!Y)return yZ("pin",$,null,Z),{status:"invalid"};let z=T8(Y.createdAt);if(z+J*60000<=Date.now())return yZ("pin",$,null,Z),{status:"expired"};if(!await c5(Y.id,z,W,J))return await this.userProvider.claimMagicLinkToken(Y.id),{status:"too_many_attempts"};if(!yZ("pin",$,Y.pin,Z))return{status:"invalid"};if(j.claim!==!1&&!await this.userProvider.claimMagicLinkToken(Y.id))return{status:"invalid"};return{status:"ok",row:Y}}async verifyMagicLinkToken($,Z){let j=await this.userProvider.findMagicLinkTokenByEmail($),J=yZ("link",$,j?.token,Z);if(!j||!J)return!1;if(T8(j.createdAt)+this.config.emailCode.linkExpiresInMinutes*60000<=Date.now())return!1;return await this.userProvider.claimMagicLinkToken(j.id)}}class X1 extends c{static getFacadeAccessor(){return E}static async user(){let $=H.getStore(),Z=$?.user;if(!Z){if(Z=await x3(this.getFacadeRoot(),$?.req),Z)$?.setUser(Z)}if(Z)return Z;throw new J$({redirectTo:S3($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let Z=H.getStore()?.req;return U1(Z?.search.get(D1),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let Z=await X1.user();if(!await $(Z))throw new m$}static async guardSafe($){let Z=await X1.user();try{return await $(Z)}catch(j){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class M8{static ensure($,Z={}){let j=H.getStore();if(j.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return j.serverQueries??=new NZ(T3(j.req.rawRequest)),j.serverQueries.ensure($,Z,"prefetch")}static async instant($,...Z){let j=M8.ensure($,Z[0]);if(await j.promise,j.status==="rejected")throw j.error;return j.data}static prefetch($,...Z){M8.ensure($,Z[0])}static noPrefetch(){let $=H.getStore();if($.req.kind==="api")throw Error("Query.noPrefetch() cannot be called from an API request");$.serverQueries??=new NZ(T3($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}function EX($,Z,j="/"){let J=new URL($.origin),W=Z.host?Z.host:Z.subdomain?`${Z.subdomain}.${$.root}`:$.root,Y=new URL(j.startsWith("/")?j:`/${j}`,J),z=LB(W);if(!z)throw Error(`"${W}" is not a hostname, so there is no URL for it. Give a bare host, optionally with a port \u2014 no scheme, path or credentials.`);if(Y.hostname=z.hostname,z.port)Y.port=z.port;return Y.toString()}function LB($){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 RX{static absolute($,...Z){return`${process.env.HOST_NAME}${F0(String($),Z[0]??{})}`}static relative($,...Z){return F0(String($),Z[0]??{})}static forDomain($,Z,...j){let J=T(a0).resolver;if(!J)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let W=H.getStore()?.req?.rawRequest,Y=W?J.publicOrigin(W):process.env.HOST_NAME;if(!Y)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return EX({root:J.root,origin:Y},$,F0(String(Z),j[0]??{}))}}class bX{name="Meta";static description($){H.getStore().metadata.description($)}static title($){H.getStore().metadata.title($)}static openGraph($){H.getStore().metadata.openGraph($)}static htmlAttributes($){H.getStore().metadata.htmlAttributes($)}static canonical($){H.getStore().metadata.canonical($)}static alternates($){H.getStore().metadata.alternates($)}static fonts($){H.getStore().metadata.fonts($)}}var HB={set($,Z,j){H.getStore().setCookie($,Z,j)},setIfAbsent($,Z,j){if(H.getStore().req.cookies.has($))return!1;return H.getStore().setCookie($,Z,j),!0},delete($,Z){H.getStore().deleteCookie($,Z)}};class f1 extends c{static getFacadeAccessor(){return vX}static get client(){return this.getFacadeRoot().client}static get($){return f1.client.get($)}static set($,Z){return f1.client.set($,Z)}static del(...$){return f1.client.del(...$)}static exists($){return f1.client.exists($)}static incr($){return f1.client.incr($)}static expire($,Z){return f1.client.expire($,Z)}static ttl($){return f1.client.ttl($)}}class wX extends c{static getFacadeAccessor(){return e0}static consume($,Z={}){return this.getFacadeRoot().consume($,Z)}}class yX extends c{static getFacadeAccessor(){return kX}static run($,Z,j){return this.getFacadeRoot().run($,Z,j)}static acquire($,Z={}){return this.getFacadeRoot().acquire($,Z)}}class gX extends c{static getFacadeAccessor(){return qX}static encrypt($){return this.getFacadeRoot().encrypt($)}static decrypt($){return this.getFacadeRoot().decrypt($)}static needsReencryption($){return this.getFacadeRoot().needsReencryption($)}}class mX extends c{static getFacadeAccessor(){return U3}static for($,Z){return this.getFacadeRoot().for($,Z)}static list($){return this.getFacadeRoot().list($)}static save($,Z,j){return this.getFacadeRoot().save($,Z,j)}static fake($={}){return this.getFacadeRoot().fake($)}static restore(){this.getFacadeRoot().restore()}}function CN($){return $}function pX(){return{driver:"memory",pollInterval:30000,maxSubscriptions:1e4,batchSize:100,keepaliveInterval:5000}}function P8($){let Z=new URLSearchParams;for(let[j,J]of $)Z.append(j,String(J));return Z.toString()}function SJ($){let Z=new Map;if(!$)return Z;let j;try{j=new URLSearchParams($)}catch{return Z}for(let[J,W]of j){let Y=Number(W);if(W!==""&&Number.isSafeInteger(Y)&&Y>=0)Z.set(J,Y)}return Z}var{SQL:CB}=globalThis.Bun;function _B(){return Bun.semver.satisfies(Bun.version,">=1.4.0")}var SB=async($)=>{let Z=new CB($,{max:1,idleTimeout:0,maxLifetime:0});return{listen:(j,J,W)=>Z.listen(j,J,W),close:()=>Z.close({timeout:1})}},xB=async($)=>{let Z;try{Z=(await import("./chunk-7rffbkmg.js")).default}catch(J){throw Error("The change feed's database driver needs a Postgres client that can LISTEN: Bun 1.4 or later, or the `postgres` package (bun add postgres).",{cause:J})}let j=Z($,{max:1,idle_timeout:0,max_lifetime:null,fetch_types:!1,onnotice:()=>{}});return{listen:(J,W,Y)=>j.listen(J,W,Y),close:()=>j.end({timeout:1}).catch(()=>{})}},hX=($)=>_B()?SB($):xB($);var AB=/^[A-Za-z_][A-Za-z0-9_]*$/;class xJ{headsTable;entriesTable;notifyChannel;sql;dialect;connection;url;retain;listener;sqliteTurn=Promise.resolve();constructor($,Z={}){if($.dialect!=="postgres"&&$.dialect!=="sqlite")throw Error(`The change feed's database driver supports Postgres and SQLite, not ${$.dialect}.`);let j=Z.headsTable??"gemi_change_heads",J=Z.entriesTable??"gemi_changes",W=Z.notifyChannel??"gemi_changes";for(let z of[j,J,W])if(!AB.test(z))throw Error(`"${z}" is not a plain identifier. Use letters, digits and underscores.`);let Y=Z.retain??1000;if(!Number.isInteger(Y)||Y<1)throw Error(`The change feed's retain must be a whole number, 1 or more; got ${Y}.`);this.headsTable=j,this.entriesTable=J,this.notifyChannel=W,this.sql=$.sql,this.dialect=$.dialect,this.connection=$.name,this.url=$.url,this.retain=Y,this.listener=Z.listener??hX}async createTable(){for(let $ of fB(this.headsTable,this.entriesTable))await this.sql.unsafe($)}joinsTransaction(){return this.transaction()!==void 0}publish($,Z){let j=this.transaction();if(!j){let W=()=>this.sql.begin((z)=>this.append(z,$,Z));if(this.dialect!=="sqlite")return W();let Y=this.sqliteTurn.then(W);return this.sqliteTurn=Y.catch(()=>{}),Y}let J=this.append(j,$,Z);return cX(J),J}async append($,Z,j){let J=$.unsafe(`"${this.headsTable}"`),W=$.unsafe(`"${this.entriesTable}"`),[Y]=await $`
|
|
27
|
-
INSERT INTO ${J} (channel, seq) VALUES (${Z}, 1)
|
|
28
|
-
ON CONFLICT (channel) DO UPDATE SET seq = ${J}.seq + 1
|
|
29
|
-
RETURNING seq
|
|
30
|
-
`,z=Number(Y.seq);if(await $`
|
|
31
|
-
INSERT INTO ${W} (channel, seq, data, created_at)
|
|
32
|
-
VALUES (${Z}, ${z}, ${JSON.stringify(j??null)}, ${Date.now()})
|
|
33
|
-
`,z>this.retain)await $`DELETE FROM ${W} WHERE channel = ${Z} AND seq <= ${z-this.retain}`;if(this.dialect==="postgres")await $`SELECT pg_notify(${this.notifyChannel}, ${`${z} ${Z}`})`;return z}async heads($){let Z=new Map($.map((W)=>[W,0]));if($.length===0)return Z;let j=this.sql,J=await j`
|
|
34
|
-
SELECT channel, seq FROM ${j.unsafe(`"${this.headsTable}"`)}
|
|
35
|
-
WHERE channel IN ${j([...$])}
|
|
36
|
-
`;for(let W of J)Z.set(W.channel,Number(W.seq));return Z}async read($,Z,j){let J=this.sql,[W]=await J`
|
|
37
|
-
SELECT seq FROM ${J.unsafe(`"${this.headsTable}"`)} WHERE channel = ${$}
|
|
38
|
-
`,Y=W?Number(W.seq):0;if(Z>Y)return{entries:[],head:Y,gap:!0};if(Z===Y)return{entries:[],head:Y,gap:!1};let z=await J`
|
|
39
|
-
SELECT seq, data FROM ${J.unsafe(`"${this.entriesTable}"`)}
|
|
40
|
-
WHERE channel = ${$} AND seq > ${Z}
|
|
41
|
-
ORDER BY seq
|
|
42
|
-
LIMIT ${j}
|
|
43
|
-
`;if(z.length===0||Number(z[0].seq)!==Z+1)return{entries:[],head:Y,gap:!0};return{entries:z.map((X)=>({seq:Number(X.seq),data:JSON.parse(X.data)})),head:Y,gap:!1}}async listen($,Z){if(this.dialect!=="postgres")return{close:async()=>{}};if(!this.url)throw Error("The change feed's database driver needs the connection's url to LISTEN. Build it from a DatabaseManager connection, which has one.");let j=await this.listener(this.url);try{await j.listen(this.notifyChannel,(J)=>{let W=J.indexOf(" "),Y=Number(J.slice(0,W));if(W>0&&Number.isInteger(Y))$(J.slice(W+1),Y)},Z)}catch(J){throw await j.close(),J}return{close:()=>j.close()}}transaction(){if(this.dialect==="sqlite"||this.connection===void 0)return;let $=V1();if($===void 0||z$()!==this.connection)return;return $}}function fB($,Z){return[`CREATE TABLE IF NOT EXISTS "${$}" (
|
|
44
|
-
"channel" TEXT NOT NULL PRIMARY KEY,
|
|
45
|
-
"seq" BIGINT NOT NULL
|
|
46
|
-
)`,`CREATE TABLE IF NOT EXISTS "${Z}" (
|
|
47
|
-
"channel" TEXT NOT NULL,
|
|
48
|
-
"seq" BIGINT NOT NULL,
|
|
49
|
-
"data" TEXT NOT NULL,
|
|
50
|
-
"created_at" BIGINT NOT NULL,
|
|
51
|
-
PRIMARY KEY ("channel", "seq")
|
|
52
|
-
)`]}class AJ{logs=new Map;retain;constructor($={}){let Z=$.retain??1000;if(!Number.isInteger(Z)||Z<1)throw Error(`The change feed's retain must be a whole number, 1 or more; got ${Z}.`);this.retain=Z}async publish($,Z){let j=this.logs.get($);if(!j)j={head:0,entries:[]},this.logs.set($,j);let J=++j.head;if(j.entries.push({seq:J,data:Z===void 0?null:structuredClone(Z)}),j.entries.length>this.retain)j.entries.splice(0,j.entries.length-this.retain);return J}async heads($){return new Map($.map((Z)=>[Z,this.logs.get(Z)?.head??0]))}async read($,Z,j){let J=this.logs.get($),W=J?.head??0;if(Z>W)return{entries:[],head:W,gap:!0};if(!J||Z===W)return{entries:[],head:W,gap:!1};let Y=J.entries[0]?.seq??W+1;if(Y>Z+1)return{entries:[],head:W,gap:!0};let z=Z+1-Y;return{entries:J.entries.slice(z,z+j),head:W,gap:!1}}}var sX=new TextEncoder;function dX($,Z){return sX.encode(`id: ${$}
|
|
53
|
-
data: ${JSON.stringify(Z)}
|
|
54
|
-
|
|
55
|
-
`)}function nX($,Z,j,J){let W=Z instanceof Request?Z:Z.rawRequest,Y=J.cursor??W.headers.get("Last-Event-ID")??new URL(W.url).searchParams.get("cursor"),z;try{z=$.subscribe(j,{cursor:Y,signal:W.signal})}catch(K){if(!(K instanceof N8))throw K;return new Response(JSON.stringify({error:"The change feed is at capacity."}),{status:503,headers:{"Content-Type":"application/json","Retry-After":String(J.retryAfter??5)}})}let X=null,G=!1,F=!1,Q=(K)=>{if(X)clearInterval(X);if(X=null,z.close(),F)return;F=!0;try{K.close()}catch{}},O=new ReadableStream({start(K){X=setInterval(()=>{if(iX())return Q(K);try{K.enqueue(sX.encode(uX))}catch{Q(K)}},$.config.keepaliveInterval)},async pull(K){try{if(!G){if(await z.ready(),G=!0,!F)K.enqueue(dX(z.cursor,{type:"ready"}));return}let D=await z.next();if(D.done||F)return Q(K);K.enqueue(dX(z.cursor,D.value))}catch(D){if(!F)console.error("[gemi] A change feed stream failed.",D);Q(K)}},cancel(){if(F=!0,X)clearInterval(X);X=null,z.close()}});return new Response(O,{headers:lX()})}var oX=255,aX=500,EB=30000;class N8 extends Error{limit;constructor($){super(`The change feed holds its limit of ${$} subscriptions.`);this.limit=$;this.name="ChangeFeedFullError"}}class bJ{options;static token="changeFeed";driver;config;followers=new Map;all=new Set;listenState="off";listening=null;retryTimer=null;backoffMs=aX;pollTimer=null;polling=null;constructor($={},Z={}){this.options=Z;this.config=I8(pX(),$),this.driver=bB(this.config.driver,Z.application)}get subscriptions(){return this.all.size}get isListening(){return this.listenState==="listening"}async publish($,Z){RJ($);let j=Z===void 0?null:Z;if(V1()!==void 0&&!this.driver.joinsTransaction?.())return EJ(async()=>{this.wake($,await this.driver.publish($,j))}),null;let J=await this.driver.publish($,j);return EJ(()=>this.wake($,J)),J}async head($){return RJ($),(await this.driver.heads([$])).get($)??0}async cursor($){let Z=fJ($);return P8(await this.driver.heads(Z))}subscribe($,Z={}){let j=fJ($);if(this.all.size>=this.config.maxSubscriptions)throw new N8(this.config.maxSubscriptions);let J=new rX(this,j,RB(Z.cursor),this.config,Z.signal);this.all.add(J);for(let W of j){let Y=this.followers.get(W);if(!Y)this.followers.set(W,Y=new Set);Y.add(J)}return this.startListening(),this.startPolling(),J}stream($,Z,j={}){return nX(this,$,fJ(Z),j)}async close(){if(this.listenState="closed",this.retryTimer)clearTimeout(this.retryTimer);this.retryTimer=null,this.stopPolling();for(let Z of this.all)Z.close();let $=this.listening;this.listening=null,await $?.close(),await this.driver.close?.()}forget($){if(!this.all.delete($))return;for(let Z of $.channels){let j=this.followers.get(Z);if(j?.delete($),j?.size===0)this.followers.delete(Z)}if(this.all.size===0)this.stopPolling()}poll(){return this.polling??=(async()=>{try{let $=[...this.followers.keys()];for(let Z=0;Z<$.length;Z+=500){let j=await this.driver.heads($.slice(Z,Z+500));for(let[J,W]of j)this.wake(J,W)}}catch($){console.error("[gemi] The change feed could not read its channels' heads.",$)}finally{this.polling=null}})(),this.polling}startPolling(){if(this.pollTimer)return;this.pollTimer=setInterval(()=>void this.poll(),this.config.pollInterval),this.pollTimer.unref?.()}stopPolling(){if(this.pollTimer)clearInterval(this.pollTimer);this.pollTimer=null}wake($,Z){for(let j of this.followers.get($)??[])j.moved($,Z)}resync(){this.poll()}startListening(){if(this.listenState!=="off"||!this.driver.listen)return;this.connect()}async connect(){this.listenState="connecting",this.retryTimer=null;try{let $=await this.driver.listen((Z,j)=>this.wake(Z,j),()=>this.resync());if(this.listenState!=="connecting"){await $.close();return}this.listening=$,this.listenState="listening",this.backoffMs=aX,this.resync()}catch($){if(this.listenState!=="connecting")return;console.error(`[gemi] The change feed could not listen for other instances' changes; retrying in ${this.backoffMs}ms.`,$),this.listenState="retrying",this.retryTimer=setTimeout(()=>void this.connect(),this.backoffMs),this.retryTimer.unref?.(),this.backoffMs=Math.min(this.backoffMs*2,EB)}}}class rX{manager;config;signal;channels;positions=new Map;readTo=new Map;dirty=new Set;pending=[];started=null;wakeUp=null;closed=!1;onAbort=()=>this.close();constructor($,Z,j,J,W){this.manager=$;this.config=J;this.signal=W;this.channels=Z;for(let Y of Z){let z=j.get(Y);if(z!==void 0)this.positions.set(Y,z),this.readTo.set(Y,z),this.dirty.add(Y)}if(W?.aborted)this.close();else W?.addEventListener("abort",this.onAbort,{once:!0})}get cursor(){return P8(this.positions)}get isClosed(){return this.closed}ready(){return this.started??=(async()=>{let $=this.channels.filter((j)=>!this.positions.has(j));if($.length===0)return;let Z=await this.manager.driver.heads($);for(let j of $){let J=Z.get(j)??0;this.positions.set(j,J),this.readTo.set(j,J)}})(),this.started}async next(){await this.ready();for(;;){if(this.closed)return{done:!0,value:void 0};let $=this.pending.shift();if($)return this.positions.set($.channel,$.seq),{done:!1,value:$};let Z=this.dirty.values().next().value;if(Z!==void 0){await this.read(Z);continue}await this.idle()}}async return(){return this.close(),{done:!0,value:void 0}}[Symbol.asyncIterator](){return this}close(){if(this.closed)return;this.closed=!0,this.pending.length=0,this.signal?.removeEventListener("abort",this.onAbort),this.manager.forget(this),this.wake()}moved($,Z){let j=this.readTo.get($);if(j!==void 0&&Z===j)return;this.dirty.add($),this.wake()}async read($){let Z=this.readTo.get($)??0;this.dirty.delete($);let{batchSize:j}=this.config,{entries:J,head:W,gap:Y}=await this.manager.driver.read($,Z,j);if(this.closed)return;if(Y){this.readTo.set($,W),this.pending.push({type:"reset",channel:$,seq:W});return}for(let z of J)this.readTo.set($,z.seq),this.pending.push({type:"change",channel:$,seq:z.seq,data:z.data});if(J.length===j)this.dirty.add($)}idle(){return new Promise(($)=>{this.wakeUp=$})}wake(){let $=this.wakeUp;this.wakeUp=null,$?.()}}function RJ($){if(typeof $!=="string"||$===""||$.length>oX)throw Error(`A change feed channel is a string of 1 to ${oX} characters; got ${JSON.stringify($)}.`)}function fJ($){let Z=[...new Set(typeof $==="string"?[$]:$)];if(Z.length===0)throw Error("A change feed subscription needs at least one channel.");for(let j of Z)RJ(j);return Z}function RB($){if($===void 0||$===null)return new Map;if(typeof $==="string")return SJ($);let Z=$ instanceof Map?[...$]:Object.entries($);return SJ(P8(new Map(Z)))}function bB($,Z){if($==="memory")return new AJ;if($==="database"||typeof $==="function"){if(!Z&&($==="database"||$.length>0))throw Error("The change feed driver needs the application it belongs to, and this ChangeFeedManager was built without one. Pass { application }.");if($==="database")return new xJ(Z.make(X$));return $(Z)}if(typeof $==="string")throw Error(`Unknown change feed driver "${$}". The changeFeed slice's driver is "memory", "database", a ChangeFeedDriver, or a function returning one.`);return $}class tX extends c{static getFacadeAccessor(){return bJ}static publish($,Z){return this.getFacadeRoot().publish($,Z)}static head($){return this.getFacadeRoot().head($)}static cursor($){return this.getFacadeRoot().cursor($)}static subscribe($,Z){return this.getFacadeRoot().subscribe($,Z)}static stream($,Z,j){return this.getFacadeRoot().stream($,Z,j)}}class eX extends c{static getFacadeAccessor(){return PZ}static enabled($){return this.getFacadeRoot().enabled($)}static all(){return this.getFacadeRoot().forClient()}static explain($){return this.getFacadeRoot().explain($)}static for($){return this.getFacadeRoot().for($)}static list(){return this.getFacadeRoot().list()}static set($,Z,j){return this.getFacadeRoot().set($,Z,j)}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class L8{bound;constructor($){this.bound=$}get name(){return this.bound??z$()}get sql(){return this.connection().sql}get dialect(){return this.connection().dialect}async query($){return await this.run($,"query")}async execute($){let Z=await this.run($,"execute");return Number(Z?.count??0)}async transaction($){let Z=this.name,j=this.connection(Z);return jG(j.sql,(J)=>$G(Z,()=>$(J)),{slowTransactionThreshold:j.config.slowTransactionThreshold,connection:Z})}async schema(){let $=this.connection(),{introspect:Z}=await import("./chunk-2y0r4b7g.js");return Z(this.handle()??$.sql,$.dialect)}run($,Z){let j=this.connection(),{text:J,values:W}=WG($,JG(j.dialect),Z);return(this.handle()??j.sql).unsafe(J,W)}handle(){let $=V1();if($===void 0)return;return z$()===this.name?$:void 0}connection($=this.name){return ZG($),T(X$).connection($)}}var xZ=new L8;class YG extends c{static getFacadeAccessor(){return X$}static connection($){return new L8($)}static get sql(){return xZ.sql}static get dialect(){return xZ.dialect}static query($){return xZ.query($)}static execute($){return xZ.execute($)}static transaction($){return xZ.transaction($)}static schema(){return xZ.schema()}static close(){return this.getFacadeRoot().close()}}export{K1 as Zc,fZ as _c,A8 as $c,k$ as ad,RZ as bd,f0 as cd,v8 as dd,w8 as ed,sJ as fd,O1 as gd,j$ as hd,HG as id,y8 as jd,B1 as kd,o as ld,CG as md,_G as nd,o8 as od,a8 as pd,b5 as qd,e0 as rd,vZ as sd,F5 as td,g$ as ud,v5 as vd,w5 as wd,t8 as xd,e8 as yd,y3 as zd,yZ as Ad,PV as Bd,d5 as Cd,MF as Dd,Wj as Ed,x3 as Fd,g8 as Gd,A3 as Hd,X1 as Id,$$ as Jd,M8 as Kd,RX as Ld,bX as Md,HB as Nd,f1 as Od,wX as Pd,yX as Qd,gX as Rd,mX as Sd,CN as Td,pX as Ud,P8 as Vd,SJ as Wd,xJ as Xd,AJ as Yd,N8 as Zd,bJ as _d,rX as $d,tX as ae,nz as be,KJ as ce,oz as de,az as ee,wO as fe,rz as ge,OJ as he,qO as ie,gO as je,BJ as ke,tz as le,ez as me,PZ as ne,eX as oe,L8 as pe,YG as qe,f4 as re,jO as se,m4 as te,p4 as ue,AT as ve,Qz as we,Kz as xe,f3 as ye,VZ as ze,uT as Ae,Dz as Be,Uz as Ce,FJ as De,LZ as Ee,DJ as Fe,zM as Ge,MJ as He,YB as Ie,TJ as Je,GB as Ke,N3 as Le,PJ as Me,MX as Ne,PX as Oe,D8 as Pe,a0 as Qe,E as Re,$5 as Se,j5 as Te,W5 as Ue,O5 as Ve,B5 as We,D5 as Xe,p8 as Ye,EG as Ze,J0 as _e,_5 as $e,h$ as af,E5 as bf};
|
|
56
|
-
|
|
57
|
-
//# debugId=305560AF76113A8764756E2164756E21
|